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
|
---|---|---|---|---|---|---|---|---|---|---|
26,002 | static void virtio_setup(uint64_t dev_info)
{
struct schib schib;
int i;
int r;
bool found = false;
bool check_devno = false;
uint16_t dev_no = -1;
blk_schid.one = 1;
if (dev_info != -1) {
check_devno = true;
dev_no = dev_info & 0xffff;
debug_print_int("device no. ", dev_no);
blk_schid.ssid = (dev_info >> 16) & 0x3;
if (blk_schid.ssid != 0) {
debug_print_int("ssid ", blk_schid.ssid);
if (enable_mss_facility() != 0) {
virtio_panic("Failed to enable mss facility\n");
}
}
}
for (i = 0; i < 0x10000; i++) {
blk_schid.sch_no = i;
r = stsch_err(blk_schid, &schib);
if (r == 3) {
break;
}
if (schib.pmcw.dnv) {
if (!check_devno || (schib.pmcw.dev == dev_no)) {
if (virtio_is_blk(blk_schid)) {
found = true;
break;
}
}
}
}
if (!found) {
virtio_panic("No virtio-blk device found!\n");
}
virtio_setup_block(blk_schid);
}
| false | qemu | 5d739a4787a53da8d787551c8de27ad39fabdb34 | static void virtio_setup(uint64_t dev_info)
{
struct schib schib;
int i;
int r;
bool found = false;
bool check_devno = false;
uint16_t dev_no = -1;
blk_schid.one = 1;
if (dev_info != -1) {
check_devno = true;
dev_no = dev_info & 0xffff;
debug_print_int("device no. ", dev_no);
blk_schid.ssid = (dev_info >> 16) & 0x3;
if (blk_schid.ssid != 0) {
debug_print_int("ssid ", blk_schid.ssid);
if (enable_mss_facility() != 0) {
virtio_panic("Failed to enable mss facility\n");
}
}
}
for (i = 0; i < 0x10000; i++) {
blk_schid.sch_no = i;
r = stsch_err(blk_schid, &schib);
if (r == 3) {
break;
}
if (schib.pmcw.dnv) {
if (!check_devno || (schib.pmcw.dev == dev_no)) {
if (virtio_is_blk(blk_schid)) {
found = true;
break;
}
}
}
}
if (!found) {
virtio_panic("No virtio-blk device found!\n");
}
virtio_setup_block(blk_schid);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(uint64_t VAR_0)
{
struct VAR_1 VAR_1;
int VAR_2;
int VAR_3;
bool found = false;
bool check_devno = false;
uint16_t dev_no = -1;
blk_schid.one = 1;
if (VAR_0 != -1) {
check_devno = true;
dev_no = VAR_0 & 0xffff;
debug_print_int("device no. ", dev_no);
blk_schid.ssid = (VAR_0 >> 16) & 0x3;
if (blk_schid.ssid != 0) {
debug_print_int("ssid ", blk_schid.ssid);
if (enable_mss_facility() != 0) {
virtio_panic("Failed to enable mss facility\n");
}
}
}
for (VAR_2 = 0; VAR_2 < 0x10000; VAR_2++) {
blk_schid.sch_no = VAR_2;
VAR_3 = stsch_err(blk_schid, &VAR_1);
if (VAR_3 == 3) {
break;
}
if (VAR_1.pmcw.dnv) {
if (!check_devno || (VAR_1.pmcw.dev == dev_no)) {
if (virtio_is_blk(blk_schid)) {
found = true;
break;
}
}
}
}
if (!found) {
virtio_panic("No virtio-blk device found!\n");
}
virtio_setup_block(blk_schid);
}
| [
"static void FUNC_0(uint64_t VAR_0)\n{",
"struct VAR_1 VAR_1;",
"int VAR_2;",
"int VAR_3;",
"bool found = false;",
"bool check_devno = false;",
"uint16_t dev_no = -1;",
"blk_schid.one = 1;",
"if (VAR_0 != -1) {",
"check_devno = true;",
"dev_no = VAR_0 & 0xffff;",
"debug_print_int(\"device no. \", dev_no);",
"blk_schid.ssid = (VAR_0 >> 16) & 0x3;",
"if (blk_schid.ssid != 0) {",
"debug_print_int(\"ssid \", blk_schid.ssid);",
"if (enable_mss_facility() != 0) {",
"virtio_panic(\"Failed to enable mss facility\\n\");",
"}",
"}",
"}",
"for (VAR_2 = 0; VAR_2 < 0x10000; VAR_2++) {",
"blk_schid.sch_no = VAR_2;",
"VAR_3 = stsch_err(blk_schid, &VAR_1);",
"if (VAR_3 == 3) {",
"break;",
"}",
"if (VAR_1.pmcw.dnv) {",
"if (!check_devno || (VAR_1.pmcw.dev == dev_no)) {",
"if (virtio_is_blk(blk_schid)) {",
"found = true;",
"break;",
"}",
"}",
"}",
"}",
"if (!found) {",
"virtio_panic(\"No virtio-blk device found!\\n\");",
"}",
"virtio_setup_block(blk_schid);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
]
] |
26,004 | void memory_region_init_ram(MemoryRegion *mr,
const char *name,
uint64_t size)
{
memory_region_init(mr, name, size);
mr->ram = true;
mr->terminates = true;
mr->destructor = memory_region_destructor_ram;
mr->ram_addr = qemu_ram_alloc(size, mr);
mr->backend_registered = true;
}
| false | qemu | 26a83ad0e793465b74a8b06a65f2f6fdc5615413 | void memory_region_init_ram(MemoryRegion *mr,
const char *name,
uint64_t size)
{
memory_region_init(mr, name, size);
mr->ram = true;
mr->terminates = true;
mr->destructor = memory_region_destructor_ram;
mr->ram_addr = qemu_ram_alloc(size, mr);
mr->backend_registered = true;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(MemoryRegion *VAR_0,
const char *VAR_1,
uint64_t VAR_2)
{
memory_region_init(VAR_0, VAR_1, VAR_2);
VAR_0->ram = true;
VAR_0->terminates = true;
VAR_0->destructor = memory_region_destructor_ram;
VAR_0->ram_addr = qemu_ram_alloc(VAR_2, VAR_0);
VAR_0->backend_registered = true;
}
| [
"void FUNC_0(MemoryRegion *VAR_0,\nconst char *VAR_1,\nuint64_t VAR_2)\n{",
"memory_region_init(VAR_0, VAR_1, VAR_2);",
"VAR_0->ram = true;",
"VAR_0->terminates = true;",
"VAR_0->destructor = memory_region_destructor_ram;",
"VAR_0->ram_addr = qemu_ram_alloc(VAR_2, VAR_0);",
"VAR_0->backend_registered = true;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
26,005 | static uint64_t pchip_read(void *opaque, hwaddr addr, unsigned size)
{
TyphoonState *s = opaque;
uint64_t ret = 0;
if (addr & 4) {
return s->latch_tmp;
}
switch (addr) {
case 0x0000:
/* WSBA0: Window Space Base Address Register. */
ret = s->pchip.win[0].base_addr;
break;
case 0x0040:
/* WSBA1 */
ret = s->pchip.win[1].base_addr;
break;
case 0x0080:
/* WSBA2 */
ret = s->pchip.win[2].base_addr;
break;
case 0x00c0:
/* WSBA3 */
ret = s->pchip.win[3].base_addr;
break;
case 0x0100:
/* WSM0: Window Space Mask Register. */
ret = s->pchip.win[0].mask;
break;
case 0x0140:
/* WSM1 */
ret = s->pchip.win[1].mask;
break;
case 0x0180:
/* WSM2 */
ret = s->pchip.win[2].mask;
break;
case 0x01c0:
/* WSM3 */
ret = s->pchip.win[3].mask;
break;
case 0x0200:
/* TBA0: Translated Base Address Register. */
ret = (uint64_t)s->pchip.win[0].translated_base_pfn << 10;
break;
case 0x0240:
/* TBA1 */
ret = (uint64_t)s->pchip.win[1].translated_base_pfn << 10;
break;
case 0x0280:
/* TBA2 */
ret = (uint64_t)s->pchip.win[2].translated_base_pfn << 10;
break;
case 0x02c0:
/* TBA3 */
ret = (uint64_t)s->pchip.win[3].translated_base_pfn << 10;
break;
case 0x0300:
/* PCTL: Pchip Control Register. */
ret = s->pchip.ctl;
break;
case 0x0340:
/* PLAT: Pchip Master Latency Register. */
break;
case 0x03c0:
/* PERROR: Pchip Error Register. */
break;
case 0x0400:
/* PERRMASK: Pchip Error Mask Register. */
break;
case 0x0440:
/* PERRSET: Pchip Error Set Register. */
break;
case 0x0480:
/* TLBIV: Translation Buffer Invalidate Virtual Register (WO). */
break;
case 0x04c0:
/* TLBIA: Translation Buffer Invalidate All Register (WO). */
break;
case 0x0500: /* PMONCTL */
case 0x0540: /* PMONCNT */
case 0x0800: /* SPRST */
break;
default:
cpu_unassigned_access(current_cpu, addr, false, false, 0, size);
return -1;
}
s->latch_tmp = ret >> 32;
return ret;
}
| false | qemu | 678421650dc166cd6cb35bb2bc0baf1b481b40ca | static uint64_t pchip_read(void *opaque, hwaddr addr, unsigned size)
{
TyphoonState *s = opaque;
uint64_t ret = 0;
if (addr & 4) {
return s->latch_tmp;
}
switch (addr) {
case 0x0000:
ret = s->pchip.win[0].base_addr;
break;
case 0x0040:
ret = s->pchip.win[1].base_addr;
break;
case 0x0080:
ret = s->pchip.win[2].base_addr;
break;
case 0x00c0:
ret = s->pchip.win[3].base_addr;
break;
case 0x0100:
ret = s->pchip.win[0].mask;
break;
case 0x0140:
ret = s->pchip.win[1].mask;
break;
case 0x0180:
ret = s->pchip.win[2].mask;
break;
case 0x01c0:
ret = s->pchip.win[3].mask;
break;
case 0x0200:
ret = (uint64_t)s->pchip.win[0].translated_base_pfn << 10;
break;
case 0x0240:
ret = (uint64_t)s->pchip.win[1].translated_base_pfn << 10;
break;
case 0x0280:
ret = (uint64_t)s->pchip.win[2].translated_base_pfn << 10;
break;
case 0x02c0:
ret = (uint64_t)s->pchip.win[3].translated_base_pfn << 10;
break;
case 0x0300:
ret = s->pchip.ctl;
break;
case 0x0340:
break;
case 0x03c0:
break;
case 0x0400:
break;
case 0x0440:
break;
case 0x0480:
break;
case 0x04c0:
break;
case 0x0500:
case 0x0540:
case 0x0800:
break;
default:
cpu_unassigned_access(current_cpu, addr, false, false, 0, size);
return -1;
}
s->latch_tmp = ret >> 32;
return ret;
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, hwaddr addr, unsigned size)
{
TyphoonState *s = opaque;
uint64_t ret = 0;
if (addr & 4) {
return s->latch_tmp;
}
switch (addr) {
case 0x0000:
ret = s->pchip.win[0].base_addr;
break;
case 0x0040:
ret = s->pchip.win[1].base_addr;
break;
case 0x0080:
ret = s->pchip.win[2].base_addr;
break;
case 0x00c0:
ret = s->pchip.win[3].base_addr;
break;
case 0x0100:
ret = s->pchip.win[0].mask;
break;
case 0x0140:
ret = s->pchip.win[1].mask;
break;
case 0x0180:
ret = s->pchip.win[2].mask;
break;
case 0x01c0:
ret = s->pchip.win[3].mask;
break;
case 0x0200:
ret = (uint64_t)s->pchip.win[0].translated_base_pfn << 10;
break;
case 0x0240:
ret = (uint64_t)s->pchip.win[1].translated_base_pfn << 10;
break;
case 0x0280:
ret = (uint64_t)s->pchip.win[2].translated_base_pfn << 10;
break;
case 0x02c0:
ret = (uint64_t)s->pchip.win[3].translated_base_pfn << 10;
break;
case 0x0300:
ret = s->pchip.ctl;
break;
case 0x0340:
break;
case 0x03c0:
break;
case 0x0400:
break;
case 0x0440:
break;
case 0x0480:
break;
case 0x04c0:
break;
case 0x0500:
case 0x0540:
case 0x0800:
break;
default:
cpu_unassigned_access(current_cpu, addr, false, false, 0, size);
return -1;
}
s->latch_tmp = ret >> 32;
return ret;
}
| [
"static uint64_t FUNC_0(void *opaque, hwaddr addr, unsigned size)\n{",
"TyphoonState *s = opaque;",
"uint64_t ret = 0;",
"if (addr & 4) {",
"return s->latch_tmp;",
"}",
"switch (addr) {",
"case 0x0000:\nret = s->pchip.win[0].base_addr;",
"break;",
"case 0x0040:\nret = s->pchip.win[1].base_addr;",
"break;",
"case 0x0080:\nret = s->pchip.win[2].base_addr;",
"break;",
"case 0x00c0:\nret = s->pchip.win[3].base_addr;",
"break;",
"case 0x0100:\nret = s->pchip.win[0].mask;",
"break;",
"case 0x0140:\nret = s->pchip.win[1].mask;",
"break;",
"case 0x0180:\nret = s->pchip.win[2].mask;",
"break;",
"case 0x01c0:\nret = s->pchip.win[3].mask;",
"break;",
"case 0x0200:\nret = (uint64_t)s->pchip.win[0].translated_base_pfn << 10;",
"break;",
"case 0x0240:\nret = (uint64_t)s->pchip.win[1].translated_base_pfn << 10;",
"break;",
"case 0x0280:\nret = (uint64_t)s->pchip.win[2].translated_base_pfn << 10;",
"break;",
"case 0x02c0:\nret = (uint64_t)s->pchip.win[3].translated_base_pfn << 10;",
"break;",
"case 0x0300:\nret = s->pchip.ctl;",
"break;",
"case 0x0340:\nbreak;",
"case 0x03c0:\nbreak;",
"case 0x0400:\nbreak;",
"case 0x0440:\nbreak;",
"case 0x0480:\nbreak;",
"case 0x04c0:\nbreak;",
"case 0x0500:\ncase 0x0540:\ncase 0x0800:\nbreak;",
"default:\ncpu_unassigned_access(current_cpu, addr, false, false, 0, size);",
"return -1;",
"}",
"s->latch_tmp = ret >> 32;",
"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
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21,
25
],
[
27
],
[
29,
33
],
[
35
],
[
37,
41
],
[
43
],
[
45,
49
],
[
51
],
[
55,
59
],
[
61
],
[
63,
67
],
[
69
],
[
71,
75
],
[
77
],
[
79,
83
],
[
85
],
[
89,
93
],
[
95
],
[
97,
101
],
[
103
],
[
105,
109
],
[
111
],
[
113,
117
],
[
119
],
[
123,
127
],
[
129
],
[
131,
135
],
[
137,
141
],
[
143,
147
],
[
149,
153
],
[
155,
159
],
[
161,
165
],
[
167,
169,
171,
173
],
[
177,
179
],
[
181
],
[
183
],
[
187
],
[
189
],
[
191
]
] |
26,006 | void cpu_x86_update_dr7(CPUX86State *env, uint32_t new_dr7)
{
int i;
for (i = 0; i < DR7_MAX_BP; i++) {
hw_breakpoint_remove(env, i);
}
env->dr[7] = new_dr7;
for (i = 0; i < DR7_MAX_BP; i++) {
hw_breakpoint_insert(env, i);
}
}
| false | qemu | 36eb6e096729f9aade3a6af7dbe4d0a990335d7e | void cpu_x86_update_dr7(CPUX86State *env, uint32_t new_dr7)
{
int i;
for (i = 0; i < DR7_MAX_BP; i++) {
hw_breakpoint_remove(env, i);
}
env->dr[7] = new_dr7;
for (i = 0; i < DR7_MAX_BP; i++) {
hw_breakpoint_insert(env, i);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(CPUX86State *VAR_0, uint32_t VAR_1)
{
int VAR_2;
for (VAR_2 = 0; VAR_2 < DR7_MAX_BP; VAR_2++) {
hw_breakpoint_remove(VAR_0, VAR_2);
}
VAR_0->dr[7] = VAR_1;
for (VAR_2 = 0; VAR_2 < DR7_MAX_BP; VAR_2++) {
hw_breakpoint_insert(VAR_0, VAR_2);
}
}
| [
"void FUNC_0(CPUX86State *VAR_0, uint32_t VAR_1)\n{",
"int VAR_2;",
"for (VAR_2 = 0; VAR_2 < DR7_MAX_BP; VAR_2++) {",
"hw_breakpoint_remove(VAR_0, VAR_2);",
"}",
"VAR_0->dr[7] = VAR_1;",
"for (VAR_2 = 0; VAR_2 < DR7_MAX_BP; VAR_2++) {",
"hw_breakpoint_insert(VAR_0, VAR_2);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
26,009 | int ffurl_get_file_handle(URLContext *h)
{
if (!h->prot->url_get_file_handle)
return -1;
return h->prot->url_get_file_handle(h);
}
| false | FFmpeg | be4dfbf7b71e44a53ca8da882a081e35ea134c83 | int ffurl_get_file_handle(URLContext *h)
{
if (!h->prot->url_get_file_handle)
return -1;
return h->prot->url_get_file_handle(h);
}
| {
"code": [],
"line_no": []
} | int FUNC_0(URLContext *VAR_0)
{
if (!VAR_0->prot->url_get_file_handle)
return -1;
return VAR_0->prot->url_get_file_handle(VAR_0);
}
| [
"int FUNC_0(URLContext *VAR_0)\n{",
"if (!VAR_0->prot->url_get_file_handle)\nreturn -1;",
"return VAR_0->prot->url_get_file_handle(VAR_0);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
],
[
11
]
] |
26,010 | static void cmd_read_toc_pma_atip(IDEState *s, uint8_t* buf)
{
int format, msf, start_track, len;
uint64_t total_sectors = s->nb_sectors >> 2;
int max_len;
if (total_sectors == 0) {
ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
return;
}
max_len = ube16_to_cpu(buf + 7);
format = buf[9] >> 6;
msf = (buf[1] >> 1) & 1;
start_track = buf[6];
switch(format) {
case 0:
len = cdrom_read_toc(total_sectors, buf, msf, start_track);
if (len < 0)
goto error_cmd;
ide_atapi_cmd_reply(s, len, max_len);
break;
case 1:
/* multi session : only a single session defined */
memset(buf, 0, 12);
buf[1] = 0x0a;
buf[2] = 0x01;
buf[3] = 0x01;
ide_atapi_cmd_reply(s, 12, max_len);
break;
case 2:
len = cdrom_read_toc_raw(total_sectors, buf, msf, start_track);
if (len < 0)
goto error_cmd;
ide_atapi_cmd_reply(s, len, max_len);
break;
default:
error_cmd:
ide_atapi_cmd_error(s, SENSE_ILLEGAL_REQUEST,
ASC_INV_FIELD_IN_CMD_PACKET);
}
}
| false | qemu | 7a2c4b82340d621bff462672b29c88d2020d68c1 | static void cmd_read_toc_pma_atip(IDEState *s, uint8_t* buf)
{
int format, msf, start_track, len;
uint64_t total_sectors = s->nb_sectors >> 2;
int max_len;
if (total_sectors == 0) {
ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
return;
}
max_len = ube16_to_cpu(buf + 7);
format = buf[9] >> 6;
msf = (buf[1] >> 1) & 1;
start_track = buf[6];
switch(format) {
case 0:
len = cdrom_read_toc(total_sectors, buf, msf, start_track);
if (len < 0)
goto error_cmd;
ide_atapi_cmd_reply(s, len, max_len);
break;
case 1:
memset(buf, 0, 12);
buf[1] = 0x0a;
buf[2] = 0x01;
buf[3] = 0x01;
ide_atapi_cmd_reply(s, 12, max_len);
break;
case 2:
len = cdrom_read_toc_raw(total_sectors, buf, msf, start_track);
if (len < 0)
goto error_cmd;
ide_atapi_cmd_reply(s, len, max_len);
break;
default:
error_cmd:
ide_atapi_cmd_error(s, SENSE_ILLEGAL_REQUEST,
ASC_INV_FIELD_IN_CMD_PACKET);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(IDEState *VAR_0, uint8_t* VAR_1)
{
int VAR_2, VAR_3, VAR_4, VAR_5;
uint64_t total_sectors = VAR_0->nb_sectors >> 2;
int VAR_6;
if (total_sectors == 0) {
ide_atapi_cmd_error(VAR_0, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
return;
}
VAR_6 = ube16_to_cpu(VAR_1 + 7);
VAR_2 = VAR_1[9] >> 6;
VAR_3 = (VAR_1[1] >> 1) & 1;
VAR_4 = VAR_1[6];
switch(VAR_2) {
case 0:
VAR_5 = cdrom_read_toc(total_sectors, VAR_1, VAR_3, VAR_4);
if (VAR_5 < 0)
goto error_cmd;
ide_atapi_cmd_reply(VAR_0, VAR_5, VAR_6);
break;
case 1:
memset(VAR_1, 0, 12);
VAR_1[1] = 0x0a;
VAR_1[2] = 0x01;
VAR_1[3] = 0x01;
ide_atapi_cmd_reply(VAR_0, 12, VAR_6);
break;
case 2:
VAR_5 = cdrom_read_toc_raw(total_sectors, VAR_1, VAR_3, VAR_4);
if (VAR_5 < 0)
goto error_cmd;
ide_atapi_cmd_reply(VAR_0, VAR_5, VAR_6);
break;
default:
error_cmd:
ide_atapi_cmd_error(VAR_0, SENSE_ILLEGAL_REQUEST,
ASC_INV_FIELD_IN_CMD_PACKET);
}
}
| [
"static void FUNC_0(IDEState *VAR_0, uint8_t* VAR_1)\n{",
"int VAR_2, VAR_3, VAR_4, VAR_5;",
"uint64_t total_sectors = VAR_0->nb_sectors >> 2;",
"int VAR_6;",
"if (total_sectors == 0) {",
"ide_atapi_cmd_error(VAR_0, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);",
"return;",
"}",
"VAR_6 = ube16_to_cpu(VAR_1 + 7);",
"VAR_2 = VAR_1[9] >> 6;",
"VAR_3 = (VAR_1[1] >> 1) & 1;",
"VAR_4 = VAR_1[6];",
"switch(VAR_2) {",
"case 0:\nVAR_5 = cdrom_read_toc(total_sectors, VAR_1, VAR_3, VAR_4);",
"if (VAR_5 < 0)\ngoto error_cmd;",
"ide_atapi_cmd_reply(VAR_0, VAR_5, VAR_6);",
"break;",
"case 1:\nmemset(VAR_1, 0, 12);",
"VAR_1[1] = 0x0a;",
"VAR_1[2] = 0x01;",
"VAR_1[3] = 0x01;",
"ide_atapi_cmd_reply(VAR_0, 12, VAR_6);",
"break;",
"case 2:\nVAR_5 = cdrom_read_toc_raw(total_sectors, VAR_1, VAR_3, VAR_4);",
"if (VAR_5 < 0)\ngoto error_cmd;",
"ide_atapi_cmd_reply(VAR_0, VAR_5, VAR_6);",
"break;",
"default:\nerror_cmd:\nide_atapi_cmd_error(VAR_0, SENSE_ILLEGAL_REQUEST,\nASC_INV_FIELD_IN_CMD_PACKET);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
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,
37
],
[
39,
41
],
[
43
],
[
45
],
[
47,
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63,
65
],
[
67,
69
],
[
71
],
[
73
],
[
75,
77,
79,
81
],
[
83
],
[
85
]
] |
26,011 | av_cold void ff_rv40dsp_init(RV34DSPContext *c, DSPContext* dsp) {
ff_rv34dsp_init(c, dsp);
c->put_pixels_tab[0][ 0] = dsp->put_h264_qpel_pixels_tab[0][0];
c->put_pixels_tab[0][ 1] = put_rv40_qpel16_mc10_c;
c->put_pixels_tab[0][ 2] = dsp->put_h264_qpel_pixels_tab[0][2];
c->put_pixels_tab[0][ 3] = put_rv40_qpel16_mc30_c;
c->put_pixels_tab[0][ 4] = put_rv40_qpel16_mc01_c;
c->put_pixels_tab[0][ 5] = put_rv40_qpel16_mc11_c;
c->put_pixels_tab[0][ 6] = put_rv40_qpel16_mc21_c;
c->put_pixels_tab[0][ 7] = put_rv40_qpel16_mc31_c;
c->put_pixels_tab[0][ 8] = dsp->put_h264_qpel_pixels_tab[0][8];
c->put_pixels_tab[0][ 9] = put_rv40_qpel16_mc12_c;
c->put_pixels_tab[0][10] = put_rv40_qpel16_mc22_c;
c->put_pixels_tab[0][11] = put_rv40_qpel16_mc32_c;
c->put_pixels_tab[0][12] = put_rv40_qpel16_mc03_c;
c->put_pixels_tab[0][13] = put_rv40_qpel16_mc13_c;
c->put_pixels_tab[0][14] = put_rv40_qpel16_mc23_c;
c->put_pixels_tab[0][15] = ff_put_rv40_qpel16_mc33_c;
c->avg_pixels_tab[0][ 0] = dsp->avg_h264_qpel_pixels_tab[0][0];
c->avg_pixels_tab[0][ 1] = avg_rv40_qpel16_mc10_c;
c->avg_pixels_tab[0][ 2] = dsp->avg_h264_qpel_pixels_tab[0][2];
c->avg_pixels_tab[0][ 3] = avg_rv40_qpel16_mc30_c;
c->avg_pixels_tab[0][ 4] = avg_rv40_qpel16_mc01_c;
c->avg_pixels_tab[0][ 5] = avg_rv40_qpel16_mc11_c;
c->avg_pixels_tab[0][ 6] = avg_rv40_qpel16_mc21_c;
c->avg_pixels_tab[0][ 7] = avg_rv40_qpel16_mc31_c;
c->avg_pixels_tab[0][ 8] = dsp->avg_h264_qpel_pixels_tab[0][8];
c->avg_pixels_tab[0][ 9] = avg_rv40_qpel16_mc12_c;
c->avg_pixels_tab[0][10] = avg_rv40_qpel16_mc22_c;
c->avg_pixels_tab[0][11] = avg_rv40_qpel16_mc32_c;
c->avg_pixels_tab[0][12] = avg_rv40_qpel16_mc03_c;
c->avg_pixels_tab[0][13] = avg_rv40_qpel16_mc13_c;
c->avg_pixels_tab[0][14] = avg_rv40_qpel16_mc23_c;
c->avg_pixels_tab[0][15] = ff_avg_rv40_qpel16_mc33_c;
c->put_pixels_tab[1][ 0] = dsp->put_h264_qpel_pixels_tab[1][0];
c->put_pixels_tab[1][ 1] = put_rv40_qpel8_mc10_c;
c->put_pixels_tab[1][ 2] = dsp->put_h264_qpel_pixels_tab[1][2];
c->put_pixels_tab[1][ 3] = put_rv40_qpel8_mc30_c;
c->put_pixels_tab[1][ 4] = put_rv40_qpel8_mc01_c;
c->put_pixels_tab[1][ 5] = put_rv40_qpel8_mc11_c;
c->put_pixels_tab[1][ 6] = put_rv40_qpel8_mc21_c;
c->put_pixels_tab[1][ 7] = put_rv40_qpel8_mc31_c;
c->put_pixels_tab[1][ 8] = dsp->put_h264_qpel_pixels_tab[1][8];
c->put_pixels_tab[1][ 9] = put_rv40_qpel8_mc12_c;
c->put_pixels_tab[1][10] = put_rv40_qpel8_mc22_c;
c->put_pixels_tab[1][11] = put_rv40_qpel8_mc32_c;
c->put_pixels_tab[1][12] = put_rv40_qpel8_mc03_c;
c->put_pixels_tab[1][13] = put_rv40_qpel8_mc13_c;
c->put_pixels_tab[1][14] = put_rv40_qpel8_mc23_c;
c->put_pixels_tab[1][15] = ff_put_rv40_qpel8_mc33_c;
c->avg_pixels_tab[1][ 0] = dsp->avg_h264_qpel_pixels_tab[1][0];
c->avg_pixels_tab[1][ 1] = avg_rv40_qpel8_mc10_c;
c->avg_pixels_tab[1][ 2] = dsp->avg_h264_qpel_pixels_tab[1][2];
c->avg_pixels_tab[1][ 3] = avg_rv40_qpel8_mc30_c;
c->avg_pixels_tab[1][ 4] = avg_rv40_qpel8_mc01_c;
c->avg_pixels_tab[1][ 5] = avg_rv40_qpel8_mc11_c;
c->avg_pixels_tab[1][ 6] = avg_rv40_qpel8_mc21_c;
c->avg_pixels_tab[1][ 7] = avg_rv40_qpel8_mc31_c;
c->avg_pixels_tab[1][ 8] = dsp->avg_h264_qpel_pixels_tab[1][8];
c->avg_pixels_tab[1][ 9] = avg_rv40_qpel8_mc12_c;
c->avg_pixels_tab[1][10] = avg_rv40_qpel8_mc22_c;
c->avg_pixels_tab[1][11] = avg_rv40_qpel8_mc32_c;
c->avg_pixels_tab[1][12] = avg_rv40_qpel8_mc03_c;
c->avg_pixels_tab[1][13] = avg_rv40_qpel8_mc13_c;
c->avg_pixels_tab[1][14] = avg_rv40_qpel8_mc23_c;
c->avg_pixels_tab[1][15] = ff_avg_rv40_qpel8_mc33_c;
c->put_chroma_pixels_tab[0] = put_rv40_chroma_mc8_c;
c->put_chroma_pixels_tab[1] = put_rv40_chroma_mc4_c;
c->avg_chroma_pixels_tab[0] = avg_rv40_chroma_mc8_c;
c->avg_chroma_pixels_tab[1] = avg_rv40_chroma_mc4_c;
c->rv40_weight_pixels_tab[0][0] = rv40_weight_func_rnd_16;
c->rv40_weight_pixels_tab[0][1] = rv40_weight_func_rnd_8;
c->rv40_weight_pixels_tab[1][0] = rv40_weight_func_nornd_16;
c->rv40_weight_pixels_tab[1][1] = rv40_weight_func_nornd_8;
c->rv40_weak_loop_filter[0] = rv40_h_weak_loop_filter;
c->rv40_weak_loop_filter[1] = rv40_v_weak_loop_filter;
c->rv40_strong_loop_filter[0] = rv40_h_strong_loop_filter;
c->rv40_strong_loop_filter[1] = rv40_v_strong_loop_filter;
c->rv40_loop_filter_strength[0] = rv40_h_loop_filter_strength;
c->rv40_loop_filter_strength[1] = rv40_v_loop_filter_strength;
if (ARCH_X86)
ff_rv40dsp_init_x86(c, dsp);
if (HAVE_NEON)
ff_rv40dsp_init_neon(c, dsp);
}
| false | FFmpeg | 507dce2536fea4b78a9f4973f77e1fa20cfe1b81 | av_cold void ff_rv40dsp_init(RV34DSPContext *c, DSPContext* dsp) {
ff_rv34dsp_init(c, dsp);
c->put_pixels_tab[0][ 0] = dsp->put_h264_qpel_pixels_tab[0][0];
c->put_pixels_tab[0][ 1] = put_rv40_qpel16_mc10_c;
c->put_pixels_tab[0][ 2] = dsp->put_h264_qpel_pixels_tab[0][2];
c->put_pixels_tab[0][ 3] = put_rv40_qpel16_mc30_c;
c->put_pixels_tab[0][ 4] = put_rv40_qpel16_mc01_c;
c->put_pixels_tab[0][ 5] = put_rv40_qpel16_mc11_c;
c->put_pixels_tab[0][ 6] = put_rv40_qpel16_mc21_c;
c->put_pixels_tab[0][ 7] = put_rv40_qpel16_mc31_c;
c->put_pixels_tab[0][ 8] = dsp->put_h264_qpel_pixels_tab[0][8];
c->put_pixels_tab[0][ 9] = put_rv40_qpel16_mc12_c;
c->put_pixels_tab[0][10] = put_rv40_qpel16_mc22_c;
c->put_pixels_tab[0][11] = put_rv40_qpel16_mc32_c;
c->put_pixels_tab[0][12] = put_rv40_qpel16_mc03_c;
c->put_pixels_tab[0][13] = put_rv40_qpel16_mc13_c;
c->put_pixels_tab[0][14] = put_rv40_qpel16_mc23_c;
c->put_pixels_tab[0][15] = ff_put_rv40_qpel16_mc33_c;
c->avg_pixels_tab[0][ 0] = dsp->avg_h264_qpel_pixels_tab[0][0];
c->avg_pixels_tab[0][ 1] = avg_rv40_qpel16_mc10_c;
c->avg_pixels_tab[0][ 2] = dsp->avg_h264_qpel_pixels_tab[0][2];
c->avg_pixels_tab[0][ 3] = avg_rv40_qpel16_mc30_c;
c->avg_pixels_tab[0][ 4] = avg_rv40_qpel16_mc01_c;
c->avg_pixels_tab[0][ 5] = avg_rv40_qpel16_mc11_c;
c->avg_pixels_tab[0][ 6] = avg_rv40_qpel16_mc21_c;
c->avg_pixels_tab[0][ 7] = avg_rv40_qpel16_mc31_c;
c->avg_pixels_tab[0][ 8] = dsp->avg_h264_qpel_pixels_tab[0][8];
c->avg_pixels_tab[0][ 9] = avg_rv40_qpel16_mc12_c;
c->avg_pixels_tab[0][10] = avg_rv40_qpel16_mc22_c;
c->avg_pixels_tab[0][11] = avg_rv40_qpel16_mc32_c;
c->avg_pixels_tab[0][12] = avg_rv40_qpel16_mc03_c;
c->avg_pixels_tab[0][13] = avg_rv40_qpel16_mc13_c;
c->avg_pixels_tab[0][14] = avg_rv40_qpel16_mc23_c;
c->avg_pixels_tab[0][15] = ff_avg_rv40_qpel16_mc33_c;
c->put_pixels_tab[1][ 0] = dsp->put_h264_qpel_pixels_tab[1][0];
c->put_pixels_tab[1][ 1] = put_rv40_qpel8_mc10_c;
c->put_pixels_tab[1][ 2] = dsp->put_h264_qpel_pixels_tab[1][2];
c->put_pixels_tab[1][ 3] = put_rv40_qpel8_mc30_c;
c->put_pixels_tab[1][ 4] = put_rv40_qpel8_mc01_c;
c->put_pixels_tab[1][ 5] = put_rv40_qpel8_mc11_c;
c->put_pixels_tab[1][ 6] = put_rv40_qpel8_mc21_c;
c->put_pixels_tab[1][ 7] = put_rv40_qpel8_mc31_c;
c->put_pixels_tab[1][ 8] = dsp->put_h264_qpel_pixels_tab[1][8];
c->put_pixels_tab[1][ 9] = put_rv40_qpel8_mc12_c;
c->put_pixels_tab[1][10] = put_rv40_qpel8_mc22_c;
c->put_pixels_tab[1][11] = put_rv40_qpel8_mc32_c;
c->put_pixels_tab[1][12] = put_rv40_qpel8_mc03_c;
c->put_pixels_tab[1][13] = put_rv40_qpel8_mc13_c;
c->put_pixels_tab[1][14] = put_rv40_qpel8_mc23_c;
c->put_pixels_tab[1][15] = ff_put_rv40_qpel8_mc33_c;
c->avg_pixels_tab[1][ 0] = dsp->avg_h264_qpel_pixels_tab[1][0];
c->avg_pixels_tab[1][ 1] = avg_rv40_qpel8_mc10_c;
c->avg_pixels_tab[1][ 2] = dsp->avg_h264_qpel_pixels_tab[1][2];
c->avg_pixels_tab[1][ 3] = avg_rv40_qpel8_mc30_c;
c->avg_pixels_tab[1][ 4] = avg_rv40_qpel8_mc01_c;
c->avg_pixels_tab[1][ 5] = avg_rv40_qpel8_mc11_c;
c->avg_pixels_tab[1][ 6] = avg_rv40_qpel8_mc21_c;
c->avg_pixels_tab[1][ 7] = avg_rv40_qpel8_mc31_c;
c->avg_pixels_tab[1][ 8] = dsp->avg_h264_qpel_pixels_tab[1][8];
c->avg_pixels_tab[1][ 9] = avg_rv40_qpel8_mc12_c;
c->avg_pixels_tab[1][10] = avg_rv40_qpel8_mc22_c;
c->avg_pixels_tab[1][11] = avg_rv40_qpel8_mc32_c;
c->avg_pixels_tab[1][12] = avg_rv40_qpel8_mc03_c;
c->avg_pixels_tab[1][13] = avg_rv40_qpel8_mc13_c;
c->avg_pixels_tab[1][14] = avg_rv40_qpel8_mc23_c;
c->avg_pixels_tab[1][15] = ff_avg_rv40_qpel8_mc33_c;
c->put_chroma_pixels_tab[0] = put_rv40_chroma_mc8_c;
c->put_chroma_pixels_tab[1] = put_rv40_chroma_mc4_c;
c->avg_chroma_pixels_tab[0] = avg_rv40_chroma_mc8_c;
c->avg_chroma_pixels_tab[1] = avg_rv40_chroma_mc4_c;
c->rv40_weight_pixels_tab[0][0] = rv40_weight_func_rnd_16;
c->rv40_weight_pixels_tab[0][1] = rv40_weight_func_rnd_8;
c->rv40_weight_pixels_tab[1][0] = rv40_weight_func_nornd_16;
c->rv40_weight_pixels_tab[1][1] = rv40_weight_func_nornd_8;
c->rv40_weak_loop_filter[0] = rv40_h_weak_loop_filter;
c->rv40_weak_loop_filter[1] = rv40_v_weak_loop_filter;
c->rv40_strong_loop_filter[0] = rv40_h_strong_loop_filter;
c->rv40_strong_loop_filter[1] = rv40_v_strong_loop_filter;
c->rv40_loop_filter_strength[0] = rv40_h_loop_filter_strength;
c->rv40_loop_filter_strength[1] = rv40_v_loop_filter_strength;
if (ARCH_X86)
ff_rv40dsp_init_x86(c, dsp);
if (HAVE_NEON)
ff_rv40dsp_init_neon(c, dsp);
}
| {
"code": [],
"line_no": []
} | av_cold void FUNC_0(RV34DSPContext *c, DSPContext* dsp) {
ff_rv34dsp_init(c, dsp);
c->put_pixels_tab[0][ 0] = dsp->put_h264_qpel_pixels_tab[0][0];
c->put_pixels_tab[0][ 1] = put_rv40_qpel16_mc10_c;
c->put_pixels_tab[0][ 2] = dsp->put_h264_qpel_pixels_tab[0][2];
c->put_pixels_tab[0][ 3] = put_rv40_qpel16_mc30_c;
c->put_pixels_tab[0][ 4] = put_rv40_qpel16_mc01_c;
c->put_pixels_tab[0][ 5] = put_rv40_qpel16_mc11_c;
c->put_pixels_tab[0][ 6] = put_rv40_qpel16_mc21_c;
c->put_pixels_tab[0][ 7] = put_rv40_qpel16_mc31_c;
c->put_pixels_tab[0][ 8] = dsp->put_h264_qpel_pixels_tab[0][8];
c->put_pixels_tab[0][ 9] = put_rv40_qpel16_mc12_c;
c->put_pixels_tab[0][10] = put_rv40_qpel16_mc22_c;
c->put_pixels_tab[0][11] = put_rv40_qpel16_mc32_c;
c->put_pixels_tab[0][12] = put_rv40_qpel16_mc03_c;
c->put_pixels_tab[0][13] = put_rv40_qpel16_mc13_c;
c->put_pixels_tab[0][14] = put_rv40_qpel16_mc23_c;
c->put_pixels_tab[0][15] = ff_put_rv40_qpel16_mc33_c;
c->avg_pixels_tab[0][ 0] = dsp->avg_h264_qpel_pixels_tab[0][0];
c->avg_pixels_tab[0][ 1] = avg_rv40_qpel16_mc10_c;
c->avg_pixels_tab[0][ 2] = dsp->avg_h264_qpel_pixels_tab[0][2];
c->avg_pixels_tab[0][ 3] = avg_rv40_qpel16_mc30_c;
c->avg_pixels_tab[0][ 4] = avg_rv40_qpel16_mc01_c;
c->avg_pixels_tab[0][ 5] = avg_rv40_qpel16_mc11_c;
c->avg_pixels_tab[0][ 6] = avg_rv40_qpel16_mc21_c;
c->avg_pixels_tab[0][ 7] = avg_rv40_qpel16_mc31_c;
c->avg_pixels_tab[0][ 8] = dsp->avg_h264_qpel_pixels_tab[0][8];
c->avg_pixels_tab[0][ 9] = avg_rv40_qpel16_mc12_c;
c->avg_pixels_tab[0][10] = avg_rv40_qpel16_mc22_c;
c->avg_pixels_tab[0][11] = avg_rv40_qpel16_mc32_c;
c->avg_pixels_tab[0][12] = avg_rv40_qpel16_mc03_c;
c->avg_pixels_tab[0][13] = avg_rv40_qpel16_mc13_c;
c->avg_pixels_tab[0][14] = avg_rv40_qpel16_mc23_c;
c->avg_pixels_tab[0][15] = ff_avg_rv40_qpel16_mc33_c;
c->put_pixels_tab[1][ 0] = dsp->put_h264_qpel_pixels_tab[1][0];
c->put_pixels_tab[1][ 1] = put_rv40_qpel8_mc10_c;
c->put_pixels_tab[1][ 2] = dsp->put_h264_qpel_pixels_tab[1][2];
c->put_pixels_tab[1][ 3] = put_rv40_qpel8_mc30_c;
c->put_pixels_tab[1][ 4] = put_rv40_qpel8_mc01_c;
c->put_pixels_tab[1][ 5] = put_rv40_qpel8_mc11_c;
c->put_pixels_tab[1][ 6] = put_rv40_qpel8_mc21_c;
c->put_pixels_tab[1][ 7] = put_rv40_qpel8_mc31_c;
c->put_pixels_tab[1][ 8] = dsp->put_h264_qpel_pixels_tab[1][8];
c->put_pixels_tab[1][ 9] = put_rv40_qpel8_mc12_c;
c->put_pixels_tab[1][10] = put_rv40_qpel8_mc22_c;
c->put_pixels_tab[1][11] = put_rv40_qpel8_mc32_c;
c->put_pixels_tab[1][12] = put_rv40_qpel8_mc03_c;
c->put_pixels_tab[1][13] = put_rv40_qpel8_mc13_c;
c->put_pixels_tab[1][14] = put_rv40_qpel8_mc23_c;
c->put_pixels_tab[1][15] = ff_put_rv40_qpel8_mc33_c;
c->avg_pixels_tab[1][ 0] = dsp->avg_h264_qpel_pixels_tab[1][0];
c->avg_pixels_tab[1][ 1] = avg_rv40_qpel8_mc10_c;
c->avg_pixels_tab[1][ 2] = dsp->avg_h264_qpel_pixels_tab[1][2];
c->avg_pixels_tab[1][ 3] = avg_rv40_qpel8_mc30_c;
c->avg_pixels_tab[1][ 4] = avg_rv40_qpel8_mc01_c;
c->avg_pixels_tab[1][ 5] = avg_rv40_qpel8_mc11_c;
c->avg_pixels_tab[1][ 6] = avg_rv40_qpel8_mc21_c;
c->avg_pixels_tab[1][ 7] = avg_rv40_qpel8_mc31_c;
c->avg_pixels_tab[1][ 8] = dsp->avg_h264_qpel_pixels_tab[1][8];
c->avg_pixels_tab[1][ 9] = avg_rv40_qpel8_mc12_c;
c->avg_pixels_tab[1][10] = avg_rv40_qpel8_mc22_c;
c->avg_pixels_tab[1][11] = avg_rv40_qpel8_mc32_c;
c->avg_pixels_tab[1][12] = avg_rv40_qpel8_mc03_c;
c->avg_pixels_tab[1][13] = avg_rv40_qpel8_mc13_c;
c->avg_pixels_tab[1][14] = avg_rv40_qpel8_mc23_c;
c->avg_pixels_tab[1][15] = ff_avg_rv40_qpel8_mc33_c;
c->put_chroma_pixels_tab[0] = put_rv40_chroma_mc8_c;
c->put_chroma_pixels_tab[1] = put_rv40_chroma_mc4_c;
c->avg_chroma_pixels_tab[0] = avg_rv40_chroma_mc8_c;
c->avg_chroma_pixels_tab[1] = avg_rv40_chroma_mc4_c;
c->rv40_weight_pixels_tab[0][0] = rv40_weight_func_rnd_16;
c->rv40_weight_pixels_tab[0][1] = rv40_weight_func_rnd_8;
c->rv40_weight_pixels_tab[1][0] = rv40_weight_func_nornd_16;
c->rv40_weight_pixels_tab[1][1] = rv40_weight_func_nornd_8;
c->rv40_weak_loop_filter[0] = rv40_h_weak_loop_filter;
c->rv40_weak_loop_filter[1] = rv40_v_weak_loop_filter;
c->rv40_strong_loop_filter[0] = rv40_h_strong_loop_filter;
c->rv40_strong_loop_filter[1] = rv40_v_strong_loop_filter;
c->rv40_loop_filter_strength[0] = rv40_h_loop_filter_strength;
c->rv40_loop_filter_strength[1] = rv40_v_loop_filter_strength;
if (ARCH_X86)
ff_rv40dsp_init_x86(c, dsp);
if (HAVE_NEON)
ff_rv40dsp_init_neon(c, dsp);
}
| [
"av_cold void FUNC_0(RV34DSPContext *c, DSPContext* dsp) {",
"ff_rv34dsp_init(c, dsp);",
"c->put_pixels_tab[0][ 0] = dsp->put_h264_qpel_pixels_tab[0][0];",
"c->put_pixels_tab[0][ 1] = put_rv40_qpel16_mc10_c;",
"c->put_pixels_tab[0][ 2] = dsp->put_h264_qpel_pixels_tab[0][2];",
"c->put_pixels_tab[0][ 3] = put_rv40_qpel16_mc30_c;",
"c->put_pixels_tab[0][ 4] = put_rv40_qpel16_mc01_c;",
"c->put_pixels_tab[0][ 5] = put_rv40_qpel16_mc11_c;",
"c->put_pixels_tab[0][ 6] = put_rv40_qpel16_mc21_c;",
"c->put_pixels_tab[0][ 7] = put_rv40_qpel16_mc31_c;",
"c->put_pixels_tab[0][ 8] = dsp->put_h264_qpel_pixels_tab[0][8];",
"c->put_pixels_tab[0][ 9] = put_rv40_qpel16_mc12_c;",
"c->put_pixels_tab[0][10] = put_rv40_qpel16_mc22_c;",
"c->put_pixels_tab[0][11] = put_rv40_qpel16_mc32_c;",
"c->put_pixels_tab[0][12] = put_rv40_qpel16_mc03_c;",
"c->put_pixels_tab[0][13] = put_rv40_qpel16_mc13_c;",
"c->put_pixels_tab[0][14] = put_rv40_qpel16_mc23_c;",
"c->put_pixels_tab[0][15] = ff_put_rv40_qpel16_mc33_c;",
"c->avg_pixels_tab[0][ 0] = dsp->avg_h264_qpel_pixels_tab[0][0];",
"c->avg_pixels_tab[0][ 1] = avg_rv40_qpel16_mc10_c;",
"c->avg_pixels_tab[0][ 2] = dsp->avg_h264_qpel_pixels_tab[0][2];",
"c->avg_pixels_tab[0][ 3] = avg_rv40_qpel16_mc30_c;",
"c->avg_pixels_tab[0][ 4] = avg_rv40_qpel16_mc01_c;",
"c->avg_pixels_tab[0][ 5] = avg_rv40_qpel16_mc11_c;",
"c->avg_pixels_tab[0][ 6] = avg_rv40_qpel16_mc21_c;",
"c->avg_pixels_tab[0][ 7] = avg_rv40_qpel16_mc31_c;",
"c->avg_pixels_tab[0][ 8] = dsp->avg_h264_qpel_pixels_tab[0][8];",
"c->avg_pixels_tab[0][ 9] = avg_rv40_qpel16_mc12_c;",
"c->avg_pixels_tab[0][10] = avg_rv40_qpel16_mc22_c;",
"c->avg_pixels_tab[0][11] = avg_rv40_qpel16_mc32_c;",
"c->avg_pixels_tab[0][12] = avg_rv40_qpel16_mc03_c;",
"c->avg_pixels_tab[0][13] = avg_rv40_qpel16_mc13_c;",
"c->avg_pixels_tab[0][14] = avg_rv40_qpel16_mc23_c;",
"c->avg_pixels_tab[0][15] = ff_avg_rv40_qpel16_mc33_c;",
"c->put_pixels_tab[1][ 0] = dsp->put_h264_qpel_pixels_tab[1][0];",
"c->put_pixels_tab[1][ 1] = put_rv40_qpel8_mc10_c;",
"c->put_pixels_tab[1][ 2] = dsp->put_h264_qpel_pixels_tab[1][2];",
"c->put_pixels_tab[1][ 3] = put_rv40_qpel8_mc30_c;",
"c->put_pixels_tab[1][ 4] = put_rv40_qpel8_mc01_c;",
"c->put_pixels_tab[1][ 5] = put_rv40_qpel8_mc11_c;",
"c->put_pixels_tab[1][ 6] = put_rv40_qpel8_mc21_c;",
"c->put_pixels_tab[1][ 7] = put_rv40_qpel8_mc31_c;",
"c->put_pixels_tab[1][ 8] = dsp->put_h264_qpel_pixels_tab[1][8];",
"c->put_pixels_tab[1][ 9] = put_rv40_qpel8_mc12_c;",
"c->put_pixels_tab[1][10] = put_rv40_qpel8_mc22_c;",
"c->put_pixels_tab[1][11] = put_rv40_qpel8_mc32_c;",
"c->put_pixels_tab[1][12] = put_rv40_qpel8_mc03_c;",
"c->put_pixels_tab[1][13] = put_rv40_qpel8_mc13_c;",
"c->put_pixels_tab[1][14] = put_rv40_qpel8_mc23_c;",
"c->put_pixels_tab[1][15] = ff_put_rv40_qpel8_mc33_c;",
"c->avg_pixels_tab[1][ 0] = dsp->avg_h264_qpel_pixels_tab[1][0];",
"c->avg_pixels_tab[1][ 1] = avg_rv40_qpel8_mc10_c;",
"c->avg_pixels_tab[1][ 2] = dsp->avg_h264_qpel_pixels_tab[1][2];",
"c->avg_pixels_tab[1][ 3] = avg_rv40_qpel8_mc30_c;",
"c->avg_pixels_tab[1][ 4] = avg_rv40_qpel8_mc01_c;",
"c->avg_pixels_tab[1][ 5] = avg_rv40_qpel8_mc11_c;",
"c->avg_pixels_tab[1][ 6] = avg_rv40_qpel8_mc21_c;",
"c->avg_pixels_tab[1][ 7] = avg_rv40_qpel8_mc31_c;",
"c->avg_pixels_tab[1][ 8] = dsp->avg_h264_qpel_pixels_tab[1][8];",
"c->avg_pixels_tab[1][ 9] = avg_rv40_qpel8_mc12_c;",
"c->avg_pixels_tab[1][10] = avg_rv40_qpel8_mc22_c;",
"c->avg_pixels_tab[1][11] = avg_rv40_qpel8_mc32_c;",
"c->avg_pixels_tab[1][12] = avg_rv40_qpel8_mc03_c;",
"c->avg_pixels_tab[1][13] = avg_rv40_qpel8_mc13_c;",
"c->avg_pixels_tab[1][14] = avg_rv40_qpel8_mc23_c;",
"c->avg_pixels_tab[1][15] = ff_avg_rv40_qpel8_mc33_c;",
"c->put_chroma_pixels_tab[0] = put_rv40_chroma_mc8_c;",
"c->put_chroma_pixels_tab[1] = put_rv40_chroma_mc4_c;",
"c->avg_chroma_pixels_tab[0] = avg_rv40_chroma_mc8_c;",
"c->avg_chroma_pixels_tab[1] = avg_rv40_chroma_mc4_c;",
"c->rv40_weight_pixels_tab[0][0] = rv40_weight_func_rnd_16;",
"c->rv40_weight_pixels_tab[0][1] = rv40_weight_func_rnd_8;",
"c->rv40_weight_pixels_tab[1][0] = rv40_weight_func_nornd_16;",
"c->rv40_weight_pixels_tab[1][1] = rv40_weight_func_nornd_8;",
"c->rv40_weak_loop_filter[0] = rv40_h_weak_loop_filter;",
"c->rv40_weak_loop_filter[1] = rv40_v_weak_loop_filter;",
"c->rv40_strong_loop_filter[0] = rv40_h_strong_loop_filter;",
"c->rv40_strong_loop_filter[1] = rv40_v_strong_loop_filter;",
"c->rv40_loop_filter_strength[0] = rv40_h_loop_filter_strength;",
"c->rv40_loop_filter_strength[1] = rv40_v_loop_filter_strength;",
"if (ARCH_X86)\nff_rv40dsp_init_x86(c, dsp);",
"if (HAVE_NEON)\nff_rv40dsp_init_neon(c, dsp);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173,
175
],
[
177,
179
],
[
181
]
] |
26,012 | static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
{
int i, consumed, ret = 0;
s->ref = NULL;
s->eos = 0;
/* split the input packet into NAL units, so we know the upper bound on the
* number of slices in the frame */
s->nb_nals = 0;
while (length >= 4) {
HEVCNAL *nal;
int extract_length = 0;
if (s->is_nalff) {
int i;
for (i = 0; i < s->nal_length_size; i++)
extract_length = (extract_length << 8) | buf[i];
buf += s->nal_length_size;
length -= s->nal_length_size;
if (extract_length > length) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid NAL unit size.\n");
ret = AVERROR_INVALIDDATA;
goto fail;
}
} else {
if (buf[2] == 0) {
length--;
buf++;
continue;
}
if (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
buf += 3;
length -= 3;
}
if (!s->is_nalff)
extract_length = length;
if (s->nals_allocated < s->nb_nals + 1) {
int new_size = s->nals_allocated + 1;
HEVCNAL *tmp = av_realloc_array(s->nals, new_size, sizeof(*tmp));
if (!tmp) {
ret = AVERROR(ENOMEM);
goto fail;
}
s->nals = tmp;
memset(s->nals + s->nals_allocated, 0, (new_size - s->nals_allocated) * sizeof(*tmp));
av_reallocp_array(&s->skipped_bytes_nal, new_size, sizeof(*s->skipped_bytes_nal));
av_reallocp_array(&s->skipped_bytes_pos_size_nal, new_size, sizeof(*s->skipped_bytes_pos_size_nal));
av_reallocp_array(&s->skipped_bytes_pos_nal, new_size, sizeof(*s->skipped_bytes_pos_nal));
s->skipped_bytes_pos_size_nal[s->nals_allocated] = 1024; // initial buffer size
s->skipped_bytes_pos_nal[s->nals_allocated] = av_malloc_array(s->skipped_bytes_pos_size_nal[s->nals_allocated], sizeof(*s->skipped_bytes_pos));
s->nals_allocated = new_size;
}
s->skipped_bytes_pos_size = s->skipped_bytes_pos_size_nal[s->nb_nals];
s->skipped_bytes_pos = s->skipped_bytes_pos_nal[s->nb_nals];
nal = &s->nals[s->nb_nals];
consumed = extract_rbsp(s, buf, extract_length, nal);
s->skipped_bytes_nal[s->nb_nals] = s->skipped_bytes;
s->skipped_bytes_pos_size_nal[s->nb_nals] = s->skipped_bytes_pos_size;
s->skipped_bytes_pos_nal[s->nb_nals++] = s->skipped_bytes_pos;
if (consumed < 0) {
ret = consumed;
goto fail;
}
ret = init_get_bits8(&s->HEVClc->gb, nal->data, nal->size);
if (ret < 0)
goto fail;
hls_nal_unit(s);
if (s->nal_unit_type == NAL_EOS_NUT || s->nal_unit_type == NAL_EOB_NUT)
s->eos = 1;
buf += consumed;
length -= consumed;
}
/* parse the NAL units */
for (i = 0; i < s->nb_nals; i++) {
int ret;
s->skipped_bytes = s->skipped_bytes_nal[i];
s->skipped_bytes_pos = s->skipped_bytes_pos_nal[i];
ret = decode_nal_unit(s, s->nals[i].data, s->nals[i].size);
if (ret < 0) {
av_log(s->avctx, AV_LOG_WARNING, "Error parsing NAL unit #%d.\n", i);
if (s->avctx->err_recognition & AV_EF_EXPLODE)
goto fail;
}
}
fail:
if (s->ref && s->threads_type == FF_THREAD_FRAME)
ff_thread_report_progress(&s->ref->tf, INT_MAX, 0);
return ret;
}
| false | FFmpeg | f7f88018393b96ae410041e9a0fc51f4c082002e | static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
{
int i, consumed, ret = 0;
s->ref = NULL;
s->eos = 0;
s->nb_nals = 0;
while (length >= 4) {
HEVCNAL *nal;
int extract_length = 0;
if (s->is_nalff) {
int i;
for (i = 0; i < s->nal_length_size; i++)
extract_length = (extract_length << 8) | buf[i];
buf += s->nal_length_size;
length -= s->nal_length_size;
if (extract_length > length) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid NAL unit size.\n");
ret = AVERROR_INVALIDDATA;
goto fail;
}
} else {
if (buf[2] == 0) {
length--;
buf++;
continue;
}
if (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
buf += 3;
length -= 3;
}
if (!s->is_nalff)
extract_length = length;
if (s->nals_allocated < s->nb_nals + 1) {
int new_size = s->nals_allocated + 1;
HEVCNAL *tmp = av_realloc_array(s->nals, new_size, sizeof(*tmp));
if (!tmp) {
ret = AVERROR(ENOMEM);
goto fail;
}
s->nals = tmp;
memset(s->nals + s->nals_allocated, 0, (new_size - s->nals_allocated) * sizeof(*tmp));
av_reallocp_array(&s->skipped_bytes_nal, new_size, sizeof(*s->skipped_bytes_nal));
av_reallocp_array(&s->skipped_bytes_pos_size_nal, new_size, sizeof(*s->skipped_bytes_pos_size_nal));
av_reallocp_array(&s->skipped_bytes_pos_nal, new_size, sizeof(*s->skipped_bytes_pos_nal));
s->skipped_bytes_pos_size_nal[s->nals_allocated] = 1024;
s->skipped_bytes_pos_nal[s->nals_allocated] = av_malloc_array(s->skipped_bytes_pos_size_nal[s->nals_allocated], sizeof(*s->skipped_bytes_pos));
s->nals_allocated = new_size;
}
s->skipped_bytes_pos_size = s->skipped_bytes_pos_size_nal[s->nb_nals];
s->skipped_bytes_pos = s->skipped_bytes_pos_nal[s->nb_nals];
nal = &s->nals[s->nb_nals];
consumed = extract_rbsp(s, buf, extract_length, nal);
s->skipped_bytes_nal[s->nb_nals] = s->skipped_bytes;
s->skipped_bytes_pos_size_nal[s->nb_nals] = s->skipped_bytes_pos_size;
s->skipped_bytes_pos_nal[s->nb_nals++] = s->skipped_bytes_pos;
if (consumed < 0) {
ret = consumed;
goto fail;
}
ret = init_get_bits8(&s->HEVClc->gb, nal->data, nal->size);
if (ret < 0)
goto fail;
hls_nal_unit(s);
if (s->nal_unit_type == NAL_EOS_NUT || s->nal_unit_type == NAL_EOB_NUT)
s->eos = 1;
buf += consumed;
length -= consumed;
}
for (i = 0; i < s->nb_nals; i++) {
int ret;
s->skipped_bytes = s->skipped_bytes_nal[i];
s->skipped_bytes_pos = s->skipped_bytes_pos_nal[i];
ret = decode_nal_unit(s, s->nals[i].data, s->nals[i].size);
if (ret < 0) {
av_log(s->avctx, AV_LOG_WARNING, "Error parsing NAL unit #%d.\n", i);
if (s->avctx->err_recognition & AV_EF_EXPLODE)
goto fail;
}
}
fail:
if (s->ref && s->threads_type == FF_THREAD_FRAME)
ff_thread_report_progress(&s->ref->tf, INT_MAX, 0);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(HEVCContext *VAR_0, const uint8_t *VAR_1, int VAR_2)
{
int VAR_7, VAR_4, VAR_5 = 0;
VAR_0->ref = NULL;
VAR_0->eos = 0;
VAR_0->nb_nals = 0;
while (VAR_2 >= 4) {
HEVCNAL *nal;
int VAR_6 = 0;
if (VAR_0->is_nalff) {
int VAR_7;
for (VAR_7 = 0; VAR_7 < VAR_0->nal_length_size; VAR_7++)
VAR_6 = (VAR_6 << 8) | VAR_1[VAR_7];
VAR_1 += VAR_0->nal_length_size;
VAR_2 -= VAR_0->nal_length_size;
if (VAR_6 > VAR_2) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid NAL unit size.\n");
VAR_5 = AVERROR_INVALIDDATA;
goto fail;
}
} else {
if (VAR_1[2] == 0) {
VAR_2--;
VAR_1++;
continue;
}
if (VAR_1[0] != 0 || VAR_1[1] != 0 || VAR_1[2] != 1) {
VAR_5 = AVERROR_INVALIDDATA;
goto fail;
}
VAR_1 += 3;
VAR_2 -= 3;
}
if (!VAR_0->is_nalff)
VAR_6 = VAR_2;
if (VAR_0->nals_allocated < VAR_0->nb_nals + 1) {
int VAR_7 = VAR_0->nals_allocated + 1;
HEVCNAL *tmp = av_realloc_array(VAR_0->nals, VAR_7, sizeof(*tmp));
if (!tmp) {
VAR_5 = AVERROR(ENOMEM);
goto fail;
}
VAR_0->nals = tmp;
memset(VAR_0->nals + VAR_0->nals_allocated, 0, (VAR_7 - VAR_0->nals_allocated) * sizeof(*tmp));
av_reallocp_array(&VAR_0->skipped_bytes_nal, VAR_7, sizeof(*VAR_0->skipped_bytes_nal));
av_reallocp_array(&VAR_0->skipped_bytes_pos_size_nal, VAR_7, sizeof(*VAR_0->skipped_bytes_pos_size_nal));
av_reallocp_array(&VAR_0->skipped_bytes_pos_nal, VAR_7, sizeof(*VAR_0->skipped_bytes_pos_nal));
VAR_0->skipped_bytes_pos_size_nal[VAR_0->nals_allocated] = 1024;
VAR_0->skipped_bytes_pos_nal[VAR_0->nals_allocated] = av_malloc_array(VAR_0->skipped_bytes_pos_size_nal[VAR_0->nals_allocated], sizeof(*VAR_0->skipped_bytes_pos));
VAR_0->nals_allocated = VAR_7;
}
VAR_0->skipped_bytes_pos_size = VAR_0->skipped_bytes_pos_size_nal[VAR_0->nb_nals];
VAR_0->skipped_bytes_pos = VAR_0->skipped_bytes_pos_nal[VAR_0->nb_nals];
nal = &VAR_0->nals[VAR_0->nb_nals];
VAR_4 = extract_rbsp(VAR_0, VAR_1, VAR_6, nal);
VAR_0->skipped_bytes_nal[VAR_0->nb_nals] = VAR_0->skipped_bytes;
VAR_0->skipped_bytes_pos_size_nal[VAR_0->nb_nals] = VAR_0->skipped_bytes_pos_size;
VAR_0->skipped_bytes_pos_nal[VAR_0->nb_nals++] = VAR_0->skipped_bytes_pos;
if (VAR_4 < 0) {
VAR_5 = VAR_4;
goto fail;
}
VAR_5 = init_get_bits8(&VAR_0->HEVClc->gb, nal->data, nal->size);
if (VAR_5 < 0)
goto fail;
hls_nal_unit(VAR_0);
if (VAR_0->nal_unit_type == NAL_EOS_NUT || VAR_0->nal_unit_type == NAL_EOB_NUT)
VAR_0->eos = 1;
VAR_1 += VAR_4;
VAR_2 -= VAR_4;
}
for (VAR_7 = 0; VAR_7 < VAR_0->nb_nals; VAR_7++) {
int VAR_5;
VAR_0->skipped_bytes = VAR_0->skipped_bytes_nal[VAR_7];
VAR_0->skipped_bytes_pos = VAR_0->skipped_bytes_pos_nal[VAR_7];
VAR_5 = decode_nal_unit(VAR_0, VAR_0->nals[VAR_7].data, VAR_0->nals[VAR_7].size);
if (VAR_5 < 0) {
av_log(VAR_0->avctx, AV_LOG_WARNING, "Error parsing NAL unit #%d.\n", VAR_7);
if (VAR_0->avctx->err_recognition & AV_EF_EXPLODE)
goto fail;
}
}
fail:
if (VAR_0->ref && VAR_0->threads_type == FF_THREAD_FRAME)
ff_thread_report_progress(&VAR_0->ref->tf, INT_MAX, 0);
return VAR_5;
}
| [
"static int FUNC_0(HEVCContext *VAR_0, const uint8_t *VAR_1, int VAR_2)\n{",
"int VAR_7, VAR_4, VAR_5 = 0;",
"VAR_0->ref = NULL;",
"VAR_0->eos = 0;",
"VAR_0->nb_nals = 0;",
"while (VAR_2 >= 4) {",
"HEVCNAL *nal;",
"int VAR_6 = 0;",
"if (VAR_0->is_nalff) {",
"int VAR_7;",
"for (VAR_7 = 0; VAR_7 < VAR_0->nal_length_size; VAR_7++)",
"VAR_6 = (VAR_6 << 8) | VAR_1[VAR_7];",
"VAR_1 += VAR_0->nal_length_size;",
"VAR_2 -= VAR_0->nal_length_size;",
"if (VAR_6 > VAR_2) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Invalid NAL unit size.\\n\");",
"VAR_5 = AVERROR_INVALIDDATA;",
"goto fail;",
"}",
"} else {",
"if (VAR_1[2] == 0) {",
"VAR_2--;",
"VAR_1++;",
"continue;",
"}",
"if (VAR_1[0] != 0 || VAR_1[1] != 0 || VAR_1[2] != 1) {",
"VAR_5 = AVERROR_INVALIDDATA;",
"goto fail;",
"}",
"VAR_1 += 3;",
"VAR_2 -= 3;",
"}",
"if (!VAR_0->is_nalff)\nVAR_6 = VAR_2;",
"if (VAR_0->nals_allocated < VAR_0->nb_nals + 1) {",
"int VAR_7 = VAR_0->nals_allocated + 1;",
"HEVCNAL *tmp = av_realloc_array(VAR_0->nals, VAR_7, sizeof(*tmp));",
"if (!tmp) {",
"VAR_5 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"VAR_0->nals = tmp;",
"memset(VAR_0->nals + VAR_0->nals_allocated, 0, (VAR_7 - VAR_0->nals_allocated) * sizeof(*tmp));",
"av_reallocp_array(&VAR_0->skipped_bytes_nal, VAR_7, sizeof(*VAR_0->skipped_bytes_nal));",
"av_reallocp_array(&VAR_0->skipped_bytes_pos_size_nal, VAR_7, sizeof(*VAR_0->skipped_bytes_pos_size_nal));",
"av_reallocp_array(&VAR_0->skipped_bytes_pos_nal, VAR_7, sizeof(*VAR_0->skipped_bytes_pos_nal));",
"VAR_0->skipped_bytes_pos_size_nal[VAR_0->nals_allocated] = 1024;",
"VAR_0->skipped_bytes_pos_nal[VAR_0->nals_allocated] = av_malloc_array(VAR_0->skipped_bytes_pos_size_nal[VAR_0->nals_allocated], sizeof(*VAR_0->skipped_bytes_pos));",
"VAR_0->nals_allocated = VAR_7;",
"}",
"VAR_0->skipped_bytes_pos_size = VAR_0->skipped_bytes_pos_size_nal[VAR_0->nb_nals];",
"VAR_0->skipped_bytes_pos = VAR_0->skipped_bytes_pos_nal[VAR_0->nb_nals];",
"nal = &VAR_0->nals[VAR_0->nb_nals];",
"VAR_4 = extract_rbsp(VAR_0, VAR_1, VAR_6, nal);",
"VAR_0->skipped_bytes_nal[VAR_0->nb_nals] = VAR_0->skipped_bytes;",
"VAR_0->skipped_bytes_pos_size_nal[VAR_0->nb_nals] = VAR_0->skipped_bytes_pos_size;",
"VAR_0->skipped_bytes_pos_nal[VAR_0->nb_nals++] = VAR_0->skipped_bytes_pos;",
"if (VAR_4 < 0) {",
"VAR_5 = VAR_4;",
"goto fail;",
"}",
"VAR_5 = init_get_bits8(&VAR_0->HEVClc->gb, nal->data, nal->size);",
"if (VAR_5 < 0)\ngoto fail;",
"hls_nal_unit(VAR_0);",
"if (VAR_0->nal_unit_type == NAL_EOS_NUT || VAR_0->nal_unit_type == NAL_EOB_NUT)\nVAR_0->eos = 1;",
"VAR_1 += VAR_4;",
"VAR_2 -= VAR_4;",
"}",
"for (VAR_7 = 0; VAR_7 < VAR_0->nb_nals; VAR_7++) {",
"int VAR_5;",
"VAR_0->skipped_bytes = VAR_0->skipped_bytes_nal[VAR_7];",
"VAR_0->skipped_bytes_pos = VAR_0->skipped_bytes_pos_nal[VAR_7];",
"VAR_5 = decode_nal_unit(VAR_0, VAR_0->nals[VAR_7].data, VAR_0->nals[VAR_7].size);",
"if (VAR_5 < 0) {",
"av_log(VAR_0->avctx, AV_LOG_WARNING, \"Error parsing NAL unit #%d.\\n\", VAR_7);",
"if (VAR_0->avctx->err_recognition & AV_EF_EXPLODE)\ngoto fail;",
"}",
"}",
"fail:\nif (VAR_0->ref && VAR_0->threads_type == FF_THREAD_FRAME)\nff_thread_report_progress(&VAR_0->ref->tf, INT_MAX, 0);",
"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
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
83,
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
133
],
[
135
],
[
137
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155,
157
],
[
159
],
[
163,
165
],
[
169
],
[
171
],
[
173
],
[
179
],
[
181
],
[
183
],
[
185
],
[
189
],
[
191
],
[
193
],
[
195,
197
],
[
199
],
[
201
],
[
205,
207,
209
],
[
213
],
[
215
]
] |
26,013 | static always_inline void gen_intermediate_code_internal (CPUState *env,
TranslationBlock *tb,
int search_pc)
{
DisasContext ctx, *ctxp = &ctx;
opc_handler_t **table, *handler;
target_ulong pc_start;
uint16_t *gen_opc_end;
CPUBreakpoint *bp;
int j, lj = -1;
int num_insns;
int max_insns;
pc_start = tb->pc;
gen_opc_end = gen_opc_buf + OPC_MAX_SIZE;
ctx.nip = pc_start;
ctx.tb = tb;
ctx.exception = POWERPC_EXCP_NONE;
ctx.spr_cb = env->spr_cb;
ctx.mem_idx = env->mmu_idx;
ctx.access_type = -1;
ctx.le_mode = env->hflags & (1 << MSR_LE) ? 1 : 0;
#if defined(TARGET_PPC64)
ctx.sf_mode = msr_sf;
#endif
ctx.fpu_enabled = msr_fp;
if ((env->flags & POWERPC_FLAG_SPE) && msr_spe)
ctx.spe_enabled = msr_spe;
else
ctx.spe_enabled = 0;
if ((env->flags & POWERPC_FLAG_VRE) && msr_vr)
ctx.altivec_enabled = msr_vr;
else
ctx.altivec_enabled = 0;
if ((env->flags & POWERPC_FLAG_SE) && msr_se)
ctx.singlestep_enabled = CPU_SINGLE_STEP;
else
ctx.singlestep_enabled = 0;
if ((env->flags & POWERPC_FLAG_BE) && msr_be)
ctx.singlestep_enabled |= CPU_BRANCH_STEP;
if (unlikely(env->singlestep_enabled))
ctx.singlestep_enabled |= GDBSTUB_SINGLE_STEP;
#if defined (DO_SINGLE_STEP) && 0
/* Single step trace mode */
msr_se = 1;
#endif
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0)
max_insns = CF_COUNT_MASK;
gen_icount_start();
/* Set env in case of segfault during code fetch */
while (ctx.exception == POWERPC_EXCP_NONE && gen_opc_ptr < gen_opc_end) {
if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) {
TAILQ_FOREACH(bp, &env->breakpoints, entry) {
if (bp->pc == ctx.nip) {
gen_debug_exception(ctxp);
break;
}
}
}
if (unlikely(search_pc)) {
j = gen_opc_ptr - gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j)
gen_opc_instr_start[lj++] = 0;
gen_opc_pc[lj] = ctx.nip;
gen_opc_instr_start[lj] = 1;
gen_opc_icount[lj] = num_insns;
}
}
LOG_DISAS("----------------\n");
LOG_DISAS("nip=" ADDRX " super=%d ir=%d\n",
ctx.nip, ctx.mem_idx, (int)msr_ir);
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
gen_io_start();
if (unlikely(ctx.le_mode)) {
ctx.opcode = bswap32(ldl_code(ctx.nip));
} else {
ctx.opcode = ldl_code(ctx.nip);
}
LOG_DISAS("translate opcode %08x (%02x %02x %02x) (%s)\n",
ctx.opcode, opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), little_endian ? "little" : "big");
ctx.nip += 4;
table = env->opcodes;
num_insns++;
handler = table[opc1(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc2(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc3(ctx.opcode)];
}
}
/* Is opcode *REALLY* valid ? */
if (unlikely(handler->handler == &gen_invalid)) {
if (qemu_log_enabled()) {
qemu_log("invalid/unsupported opcode: "
"%02x - %02x - %02x (%08x) " ADDRX " %d\n",
opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir);
} else {
printf("invalid/unsupported opcode: "
"%02x - %02x - %02x (%08x) " ADDRX " %d\n",
opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir);
}
} else {
if (unlikely((ctx.opcode & handler->inval) != 0)) {
if (qemu_log_enabled()) {
qemu_log("invalid bits: %08x for opcode: "
"%02x - %02x - %02x (%08x) " ADDRX "\n",
ctx.opcode & handler->inval, opc1(ctx.opcode),
opc2(ctx.opcode), opc3(ctx.opcode),
ctx.opcode, ctx.nip - 4);
} else {
printf("invalid bits: %08x for opcode: "
"%02x - %02x - %02x (%08x) " ADDRX "\n",
ctx.opcode & handler->inval, opc1(ctx.opcode),
opc2(ctx.opcode), opc3(ctx.opcode),
ctx.opcode, ctx.nip - 4);
}
gen_inval_exception(ctxp, POWERPC_EXCP_INVAL_INVAL);
break;
}
}
(*(handler->handler))(&ctx);
#if defined(DO_PPC_STATISTICS)
handler->count++;
#endif
/* Check trace mode exceptions */
if (unlikely(ctx.singlestep_enabled & CPU_SINGLE_STEP &&
(ctx.nip <= 0x100 || ctx.nip > 0xF00) &&
ctx.exception != POWERPC_SYSCALL &&
ctx.exception != POWERPC_EXCP_TRAP &&
ctx.exception != POWERPC_EXCP_BRANCH)) {
gen_exception(ctxp, POWERPC_EXCP_TRACE);
} else if (unlikely(((ctx.nip & (TARGET_PAGE_SIZE - 1)) == 0) ||
(env->singlestep_enabled) ||
num_insns >= max_insns)) {
/* if we reach a page boundary or are single stepping, stop
* generation
*/
break;
}
#if defined (DO_SINGLE_STEP)
break;
#endif
}
if (tb->cflags & CF_LAST_IO)
gen_io_end();
if (ctx.exception == POWERPC_EXCP_NONE) {
gen_goto_tb(&ctx, 0, ctx.nip);
} else if (ctx.exception != POWERPC_EXCP_BRANCH) {
if (unlikely(env->singlestep_enabled)) {
gen_debug_exception(ctxp);
}
/* Generate the return instruction */
tcg_gen_exit_tb(0);
}
gen_icount_end(tb, num_insns);
*gen_opc_ptr = INDEX_op_end;
if (unlikely(search_pc)) {
j = gen_opc_ptr - gen_opc_buf;
lj++;
while (lj <= j)
gen_opc_instr_start[lj++] = 0;
} else {
tb->size = ctx.nip - pc_start;
tb->icount = num_insns;
}
#if defined(DEBUG_DISAS)
qemu_log_mask(CPU_LOG_TB_CPU, "---------------- excp: %04x\n", ctx.exception);
log_cpu_state_mask(CPU_LOG_TB_CPU, env, 0);
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
int flags;
flags = env->bfd_mach;
flags |= ctx.le_mode << 16;
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(pc_start, ctx.nip - pc_start, flags);
qemu_log("\n");
}
#endif
}
| false | qemu | af4b6c54c141c1e2d3637fc15b912e82b88828cf | static always_inline void gen_intermediate_code_internal (CPUState *env,
TranslationBlock *tb,
int search_pc)
{
DisasContext ctx, *ctxp = &ctx;
opc_handler_t **table, *handler;
target_ulong pc_start;
uint16_t *gen_opc_end;
CPUBreakpoint *bp;
int j, lj = -1;
int num_insns;
int max_insns;
pc_start = tb->pc;
gen_opc_end = gen_opc_buf + OPC_MAX_SIZE;
ctx.nip = pc_start;
ctx.tb = tb;
ctx.exception = POWERPC_EXCP_NONE;
ctx.spr_cb = env->spr_cb;
ctx.mem_idx = env->mmu_idx;
ctx.access_type = -1;
ctx.le_mode = env->hflags & (1 << MSR_LE) ? 1 : 0;
#if defined(TARGET_PPC64)
ctx.sf_mode = msr_sf;
#endif
ctx.fpu_enabled = msr_fp;
if ((env->flags & POWERPC_FLAG_SPE) && msr_spe)
ctx.spe_enabled = msr_spe;
else
ctx.spe_enabled = 0;
if ((env->flags & POWERPC_FLAG_VRE) && msr_vr)
ctx.altivec_enabled = msr_vr;
else
ctx.altivec_enabled = 0;
if ((env->flags & POWERPC_FLAG_SE) && msr_se)
ctx.singlestep_enabled = CPU_SINGLE_STEP;
else
ctx.singlestep_enabled = 0;
if ((env->flags & POWERPC_FLAG_BE) && msr_be)
ctx.singlestep_enabled |= CPU_BRANCH_STEP;
if (unlikely(env->singlestep_enabled))
ctx.singlestep_enabled |= GDBSTUB_SINGLE_STEP;
#if defined (DO_SINGLE_STEP) && 0
msr_se = 1;
#endif
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0)
max_insns = CF_COUNT_MASK;
gen_icount_start();
while (ctx.exception == POWERPC_EXCP_NONE && gen_opc_ptr < gen_opc_end) {
if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) {
TAILQ_FOREACH(bp, &env->breakpoints, entry) {
if (bp->pc == ctx.nip) {
gen_debug_exception(ctxp);
break;
}
}
}
if (unlikely(search_pc)) {
j = gen_opc_ptr - gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j)
gen_opc_instr_start[lj++] = 0;
gen_opc_pc[lj] = ctx.nip;
gen_opc_instr_start[lj] = 1;
gen_opc_icount[lj] = num_insns;
}
}
LOG_DISAS("----------------\n");
LOG_DISAS("nip=" ADDRX " super=%d ir=%d\n",
ctx.nip, ctx.mem_idx, (int)msr_ir);
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
gen_io_start();
if (unlikely(ctx.le_mode)) {
ctx.opcode = bswap32(ldl_code(ctx.nip));
} else {
ctx.opcode = ldl_code(ctx.nip);
}
LOG_DISAS("translate opcode %08x (%02x %02x %02x) (%s)\n",
ctx.opcode, opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), little_endian ? "little" : "big");
ctx.nip += 4;
table = env->opcodes;
num_insns++;
handler = table[opc1(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc2(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc3(ctx.opcode)];
}
}
if (unlikely(handler->handler == &gen_invalid)) {
if (qemu_log_enabled()) {
qemu_log("invalid/unsupported opcode: "
"%02x - %02x - %02x (%08x) " ADDRX " %d\n",
opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir);
} else {
printf("invalid/unsupported opcode: "
"%02x - %02x - %02x (%08x) " ADDRX " %d\n",
opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir);
}
} else {
if (unlikely((ctx.opcode & handler->inval) != 0)) {
if (qemu_log_enabled()) {
qemu_log("invalid bits: %08x for opcode: "
"%02x - %02x - %02x (%08x) " ADDRX "\n",
ctx.opcode & handler->inval, opc1(ctx.opcode),
opc2(ctx.opcode), opc3(ctx.opcode),
ctx.opcode, ctx.nip - 4);
} else {
printf("invalid bits: %08x for opcode: "
"%02x - %02x - %02x (%08x) " ADDRX "\n",
ctx.opcode & handler->inval, opc1(ctx.opcode),
opc2(ctx.opcode), opc3(ctx.opcode),
ctx.opcode, ctx.nip - 4);
}
gen_inval_exception(ctxp, POWERPC_EXCP_INVAL_INVAL);
break;
}
}
(*(handler->handler))(&ctx);
#if defined(DO_PPC_STATISTICS)
handler->count++;
#endif
if (unlikely(ctx.singlestep_enabled & CPU_SINGLE_STEP &&
(ctx.nip <= 0x100 || ctx.nip > 0xF00) &&
ctx.exception != POWERPC_SYSCALL &&
ctx.exception != POWERPC_EXCP_TRAP &&
ctx.exception != POWERPC_EXCP_BRANCH)) {
gen_exception(ctxp, POWERPC_EXCP_TRACE);
} else if (unlikely(((ctx.nip & (TARGET_PAGE_SIZE - 1)) == 0) ||
(env->singlestep_enabled) ||
num_insns >= max_insns)) {
break;
}
#if defined (DO_SINGLE_STEP)
break;
#endif
}
if (tb->cflags & CF_LAST_IO)
gen_io_end();
if (ctx.exception == POWERPC_EXCP_NONE) {
gen_goto_tb(&ctx, 0, ctx.nip);
} else if (ctx.exception != POWERPC_EXCP_BRANCH) {
if (unlikely(env->singlestep_enabled)) {
gen_debug_exception(ctxp);
}
tcg_gen_exit_tb(0);
}
gen_icount_end(tb, num_insns);
*gen_opc_ptr = INDEX_op_end;
if (unlikely(search_pc)) {
j = gen_opc_ptr - gen_opc_buf;
lj++;
while (lj <= j)
gen_opc_instr_start[lj++] = 0;
} else {
tb->size = ctx.nip - pc_start;
tb->icount = num_insns;
}
#if defined(DEBUG_DISAS)
qemu_log_mask(CPU_LOG_TB_CPU, "---------------- excp: %04x\n", ctx.exception);
log_cpu_state_mask(CPU_LOG_TB_CPU, env, 0);
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
int flags;
flags = env->bfd_mach;
flags |= ctx.le_mode << 16;
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(pc_start, ctx.nip - pc_start, flags);
qemu_log("\n");
}
#endif
}
| {
"code": [],
"line_no": []
} | static always_inline void FUNC_0 (CPUState *env,
TranslationBlock *tb,
int search_pc)
{
DisasContext ctx, *ctxp = &ctx;
opc_handler_t **table, *handler;
target_ulong pc_start;
uint16_t *gen_opc_end;
CPUBreakpoint *bp;
int VAR_0, VAR_1 = -1;
int VAR_2;
int VAR_3;
pc_start = tb->pc;
gen_opc_end = gen_opc_buf + OPC_MAX_SIZE;
ctx.nip = pc_start;
ctx.tb = tb;
ctx.exception = POWERPC_EXCP_NONE;
ctx.spr_cb = env->spr_cb;
ctx.mem_idx = env->mmu_idx;
ctx.access_type = -1;
ctx.le_mode = env->hflags & (1 << MSR_LE) ? 1 : 0;
#if defined(TARGET_PPC64)
ctx.sf_mode = msr_sf;
#endif
ctx.fpu_enabled = msr_fp;
if ((env->flags & POWERPC_FLAG_SPE) && msr_spe)
ctx.spe_enabled = msr_spe;
else
ctx.spe_enabled = 0;
if ((env->flags & POWERPC_FLAG_VRE) && msr_vr)
ctx.altivec_enabled = msr_vr;
else
ctx.altivec_enabled = 0;
if ((env->flags & POWERPC_FLAG_SE) && msr_se)
ctx.singlestep_enabled = CPU_SINGLE_STEP;
else
ctx.singlestep_enabled = 0;
if ((env->flags & POWERPC_FLAG_BE) && msr_be)
ctx.singlestep_enabled |= CPU_BRANCH_STEP;
if (unlikely(env->singlestep_enabled))
ctx.singlestep_enabled |= GDBSTUB_SINGLE_STEP;
#if defined (DO_SINGLE_STEP) && 0
msr_se = 1;
#endif
VAR_2 = 0;
VAR_3 = tb->cflags & CF_COUNT_MASK;
if (VAR_3 == 0)
VAR_3 = CF_COUNT_MASK;
gen_icount_start();
while (ctx.exception == POWERPC_EXCP_NONE && gen_opc_ptr < gen_opc_end) {
if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) {
TAILQ_FOREACH(bp, &env->breakpoints, entry) {
if (bp->pc == ctx.nip) {
gen_debug_exception(ctxp);
break;
}
}
}
if (unlikely(search_pc)) {
VAR_0 = gen_opc_ptr - gen_opc_buf;
if (VAR_1 < VAR_0) {
VAR_1++;
while (VAR_1 < VAR_0)
gen_opc_instr_start[VAR_1++] = 0;
gen_opc_pc[VAR_1] = ctx.nip;
gen_opc_instr_start[VAR_1] = 1;
gen_opc_icount[VAR_1] = VAR_2;
}
}
LOG_DISAS("----------------\n");
LOG_DISAS("nip=" ADDRX " super=%d ir=%d\n",
ctx.nip, ctx.mem_idx, (int)msr_ir);
if (VAR_2 + 1 == VAR_3 && (tb->cflags & CF_LAST_IO))
gen_io_start();
if (unlikely(ctx.le_mode)) {
ctx.opcode = bswap32(ldl_code(ctx.nip));
} else {
ctx.opcode = ldl_code(ctx.nip);
}
LOG_DISAS("translate opcode %08x (%02x %02x %02x) (%s)\n",
ctx.opcode, opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), little_endian ? "little" : "big");
ctx.nip += 4;
table = env->opcodes;
VAR_2++;
handler = table[opc1(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc2(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc3(ctx.opcode)];
}
}
if (unlikely(handler->handler == &gen_invalid)) {
if (qemu_log_enabled()) {
qemu_log("invalid/unsupported opcode: "
"%02x - %02x - %02x (%08x) " ADDRX " %d\n",
opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir);
} else {
printf("invalid/unsupported opcode: "
"%02x - %02x - %02x (%08x) " ADDRX " %d\n",
opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir);
}
} else {
if (unlikely((ctx.opcode & handler->inval) != 0)) {
if (qemu_log_enabled()) {
qemu_log("invalid bits: %08x for opcode: "
"%02x - %02x - %02x (%08x) " ADDRX "\n",
ctx.opcode & handler->inval, opc1(ctx.opcode),
opc2(ctx.opcode), opc3(ctx.opcode),
ctx.opcode, ctx.nip - 4);
} else {
printf("invalid bits: %08x for opcode: "
"%02x - %02x - %02x (%08x) " ADDRX "\n",
ctx.opcode & handler->inval, opc1(ctx.opcode),
opc2(ctx.opcode), opc3(ctx.opcode),
ctx.opcode, ctx.nip - 4);
}
gen_inval_exception(ctxp, POWERPC_EXCP_INVAL_INVAL);
break;
}
}
(*(handler->handler))(&ctx);
#if defined(DO_PPC_STATISTICS)
handler->count++;
#endif
if (unlikely(ctx.singlestep_enabled & CPU_SINGLE_STEP &&
(ctx.nip <= 0x100 || ctx.nip > 0xF00) &&
ctx.exception != POWERPC_SYSCALL &&
ctx.exception != POWERPC_EXCP_TRAP &&
ctx.exception != POWERPC_EXCP_BRANCH)) {
gen_exception(ctxp, POWERPC_EXCP_TRACE);
} else if (unlikely(((ctx.nip & (TARGET_PAGE_SIZE - 1)) == 0) ||
(env->singlestep_enabled) ||
VAR_2 >= VAR_3)) {
break;
}
#if defined (DO_SINGLE_STEP)
break;
#endif
}
if (tb->cflags & CF_LAST_IO)
gen_io_end();
if (ctx.exception == POWERPC_EXCP_NONE) {
gen_goto_tb(&ctx, 0, ctx.nip);
} else if (ctx.exception != POWERPC_EXCP_BRANCH) {
if (unlikely(env->singlestep_enabled)) {
gen_debug_exception(ctxp);
}
tcg_gen_exit_tb(0);
}
gen_icount_end(tb, VAR_2);
*gen_opc_ptr = INDEX_op_end;
if (unlikely(search_pc)) {
VAR_0 = gen_opc_ptr - gen_opc_buf;
VAR_1++;
while (VAR_1 <= VAR_0)
gen_opc_instr_start[VAR_1++] = 0;
} else {
tb->size = ctx.nip - pc_start;
tb->icount = VAR_2;
}
#if defined(DEBUG_DISAS)
qemu_log_mask(CPU_LOG_TB_CPU, "---------------- excp: %04x\n", ctx.exception);
log_cpu_state_mask(CPU_LOG_TB_CPU, env, 0);
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
int flags;
flags = env->bfd_mach;
flags |= ctx.le_mode << 16;
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(pc_start, ctx.nip - pc_start, flags);
qemu_log("\n");
}
#endif
}
| [
"static always_inline void FUNC_0 (CPUState *env,\nTranslationBlock *tb,\nint search_pc)\n{",
"DisasContext ctx, *ctxp = &ctx;",
"opc_handler_t **table, *handler;",
"target_ulong pc_start;",
"uint16_t *gen_opc_end;",
"CPUBreakpoint *bp;",
"int VAR_0, VAR_1 = -1;",
"int VAR_2;",
"int VAR_3;",
"pc_start = tb->pc;",
"gen_opc_end = gen_opc_buf + OPC_MAX_SIZE;",
"ctx.nip = pc_start;",
"ctx.tb = tb;",
"ctx.exception = POWERPC_EXCP_NONE;",
"ctx.spr_cb = env->spr_cb;",
"ctx.mem_idx = env->mmu_idx;",
"ctx.access_type = -1;",
"ctx.le_mode = env->hflags & (1 << MSR_LE) ? 1 : 0;",
"#if defined(TARGET_PPC64)\nctx.sf_mode = msr_sf;",
"#endif\nctx.fpu_enabled = msr_fp;",
"if ((env->flags & POWERPC_FLAG_SPE) && msr_spe)\nctx.spe_enabled = msr_spe;",
"else\nctx.spe_enabled = 0;",
"if ((env->flags & POWERPC_FLAG_VRE) && msr_vr)\nctx.altivec_enabled = msr_vr;",
"else\nctx.altivec_enabled = 0;",
"if ((env->flags & POWERPC_FLAG_SE) && msr_se)\nctx.singlestep_enabled = CPU_SINGLE_STEP;",
"else\nctx.singlestep_enabled = 0;",
"if ((env->flags & POWERPC_FLAG_BE) && msr_be)\nctx.singlestep_enabled |= CPU_BRANCH_STEP;",
"if (unlikely(env->singlestep_enabled))\nctx.singlestep_enabled |= GDBSTUB_SINGLE_STEP;",
"#if defined (DO_SINGLE_STEP) && 0\nmsr_se = 1;",
"#endif\nVAR_2 = 0;",
"VAR_3 = tb->cflags & CF_COUNT_MASK;",
"if (VAR_3 == 0)\nVAR_3 = CF_COUNT_MASK;",
"gen_icount_start();",
"while (ctx.exception == POWERPC_EXCP_NONE && gen_opc_ptr < gen_opc_end) {",
"if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) {",
"TAILQ_FOREACH(bp, &env->breakpoints, entry) {",
"if (bp->pc == ctx.nip) {",
"gen_debug_exception(ctxp);",
"break;",
"}",
"}",
"}",
"if (unlikely(search_pc)) {",
"VAR_0 = gen_opc_ptr - gen_opc_buf;",
"if (VAR_1 < VAR_0) {",
"VAR_1++;",
"while (VAR_1 < VAR_0)\ngen_opc_instr_start[VAR_1++] = 0;",
"gen_opc_pc[VAR_1] = ctx.nip;",
"gen_opc_instr_start[VAR_1] = 1;",
"gen_opc_icount[VAR_1] = VAR_2;",
"}",
"}",
"LOG_DISAS(\"----------------\\n\");",
"LOG_DISAS(\"nip=\" ADDRX \" super=%d ir=%d\\n\",\nctx.nip, ctx.mem_idx, (int)msr_ir);",
"if (VAR_2 + 1 == VAR_3 && (tb->cflags & CF_LAST_IO))\ngen_io_start();",
"if (unlikely(ctx.le_mode)) {",
"ctx.opcode = bswap32(ldl_code(ctx.nip));",
"} else {",
"ctx.opcode = ldl_code(ctx.nip);",
"}",
"LOG_DISAS(\"translate opcode %08x (%02x %02x %02x) (%s)\\n\",\nctx.opcode, opc1(ctx.opcode), opc2(ctx.opcode),\nopc3(ctx.opcode), little_endian ? \"little\" : \"big\");",
"ctx.nip += 4;",
"table = env->opcodes;",
"VAR_2++;",
"handler = table[opc1(ctx.opcode)];",
"if (is_indirect_opcode(handler)) {",
"table = ind_table(handler);",
"handler = table[opc2(ctx.opcode)];",
"if (is_indirect_opcode(handler)) {",
"table = ind_table(handler);",
"handler = table[opc3(ctx.opcode)];",
"}",
"}",
"if (unlikely(handler->handler == &gen_invalid)) {",
"if (qemu_log_enabled()) {",
"qemu_log(\"invalid/unsupported opcode: \"\n\"%02x - %02x - %02x (%08x) \" ADDRX \" %d\\n\",\nopc1(ctx.opcode), opc2(ctx.opcode),\nopc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir);",
"} else {",
"printf(\"invalid/unsupported opcode: \"\n\"%02x - %02x - %02x (%08x) \" ADDRX \" %d\\n\",\nopc1(ctx.opcode), opc2(ctx.opcode),\nopc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir);",
"}",
"} else {",
"if (unlikely((ctx.opcode & handler->inval) != 0)) {",
"if (qemu_log_enabled()) {",
"qemu_log(\"invalid bits: %08x for opcode: \"\n\"%02x - %02x - %02x (%08x) \" ADDRX \"\\n\",\nctx.opcode & handler->inval, opc1(ctx.opcode),\nopc2(ctx.opcode), opc3(ctx.opcode),\nctx.opcode, ctx.nip - 4);",
"} else {",
"printf(\"invalid bits: %08x for opcode: \"\n\"%02x - %02x - %02x (%08x) \" ADDRX \"\\n\",\nctx.opcode & handler->inval, opc1(ctx.opcode),\nopc2(ctx.opcode), opc3(ctx.opcode),\nctx.opcode, ctx.nip - 4);",
"}",
"gen_inval_exception(ctxp, POWERPC_EXCP_INVAL_INVAL);",
"break;",
"}",
"}",
"(*(handler->handler))(&ctx);",
"#if defined(DO_PPC_STATISTICS)\nhandler->count++;",
"#endif\nif (unlikely(ctx.singlestep_enabled & CPU_SINGLE_STEP &&\n(ctx.nip <= 0x100 || ctx.nip > 0xF00) &&\nctx.exception != POWERPC_SYSCALL &&\nctx.exception != POWERPC_EXCP_TRAP &&\nctx.exception != POWERPC_EXCP_BRANCH)) {",
"gen_exception(ctxp, POWERPC_EXCP_TRACE);",
"} else if (unlikely(((ctx.nip & (TARGET_PAGE_SIZE - 1)) == 0) ||",
"(env->singlestep_enabled) ||\nVAR_2 >= VAR_3)) {",
"break;",
"}",
"#if defined (DO_SINGLE_STEP)\nbreak;",
"#endif\n}",
"if (tb->cflags & CF_LAST_IO)\ngen_io_end();",
"if (ctx.exception == POWERPC_EXCP_NONE) {",
"gen_goto_tb(&ctx, 0, ctx.nip);",
"} else if (ctx.exception != POWERPC_EXCP_BRANCH) {",
"if (unlikely(env->singlestep_enabled)) {",
"gen_debug_exception(ctxp);",
"}",
"tcg_gen_exit_tb(0);",
"}",
"gen_icount_end(tb, VAR_2);",
"*gen_opc_ptr = INDEX_op_end;",
"if (unlikely(search_pc)) {",
"VAR_0 = gen_opc_ptr - gen_opc_buf;",
"VAR_1++;",
"while (VAR_1 <= VAR_0)\ngen_opc_instr_start[VAR_1++] = 0;",
"} else {",
"tb->size = ctx.nip - pc_start;",
"tb->icount = VAR_2;",
"}",
"#if defined(DEBUG_DISAS)\nqemu_log_mask(CPU_LOG_TB_CPU, \"---------------- excp: %04x\\n\", ctx.exception);",
"log_cpu_state_mask(CPU_LOG_TB_CPU, env, 0);",
"if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {",
"int flags;",
"flags = env->bfd_mach;",
"flags |= ctx.le_mode << 16;",
"qemu_log(\"IN: %s\\n\", lookup_symbol(pc_start));",
"log_target_disas(pc_start, ctx.nip - pc_start, flags);",
"qemu_log(\"\\n\");",
"}",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49,
51
],
[
53,
55
],
[
57,
59
],
[
61,
63
],
[
65,
67
],
[
69,
71
],
[
73,
75
],
[
77,
79
],
[
81,
83
],
[
85,
89
],
[
91,
93
],
[
95
],
[
97,
99
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133,
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149,
151
],
[
153,
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167,
169,
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
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,
271,
273,
275,
277,
279
],
[
281
],
[
283
],
[
285,
287
],
[
295
],
[
297
],
[
299,
301
],
[
303,
305
],
[
307,
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
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
]
] |
26,014 | static int slb_lookup (CPUPPCState *env, target_ulong eaddr,
target_ulong *vsid, target_ulong *page_mask, int *attr)
{
target_phys_addr_t sr_base;
target_ulong mask;
uint64_t tmp64;
uint32_t tmp;
int n, ret;
int slb_nr;
ret = -5;
sr_base = env->spr[SPR_ASR];
#if defined(DEBUG_SLB)
if (loglevel != 0) {
fprintf(logfile, "%s: eaddr " ADDRX " base " PADDRX "\n",
__func__, eaddr, sr_base);
}
#endif
mask = 0x0000000000000000ULL; /* Avoid gcc warning */
slb_nr = env->slb_nr;
for (n = 0; n < slb_nr; n++) {
tmp64 = ldq_phys(sr_base);
tmp = ldl_phys(sr_base + 8);
#if defined(DEBUG_SLB)
if (loglevel != 0) {
fprintf(logfile, "%s: seg %d " PADDRX " %016" PRIx64 " %08"
PRIx32 "\n", __func__, n, sr_base, tmp64, tmp);
}
#endif
if (tmp64 & 0x0000000008000000ULL) {
/* SLB entry is valid */
switch (tmp64 & 0x0000000006000000ULL) {
case 0x0000000000000000ULL:
/* 256 MB segment */
mask = 0xFFFFFFFFF0000000ULL;
break;
case 0x0000000002000000ULL:
/* 1 TB segment */
mask = 0xFFFF000000000000ULL;
break;
case 0x0000000004000000ULL:
case 0x0000000006000000ULL:
/* Reserved => segment is invalid */
continue;
}
if ((eaddr & mask) == (tmp64 & mask)) {
/* SLB match */
*vsid = ((tmp64 << 24) | (tmp >> 8)) & 0x0003FFFFFFFFFFFFULL;
*page_mask = ~mask;
*attr = tmp & 0xFF;
ret = 0;
break;
}
}
sr_base += 12;
}
return ret;
}
| false | qemu | eacc324914c2dc7aecec3b4ea920252b685b5c8e | static int slb_lookup (CPUPPCState *env, target_ulong eaddr,
target_ulong *vsid, target_ulong *page_mask, int *attr)
{
target_phys_addr_t sr_base;
target_ulong mask;
uint64_t tmp64;
uint32_t tmp;
int n, ret;
int slb_nr;
ret = -5;
sr_base = env->spr[SPR_ASR];
#if defined(DEBUG_SLB)
if (loglevel != 0) {
fprintf(logfile, "%s: eaddr " ADDRX " base " PADDRX "\n",
__func__, eaddr, sr_base);
}
#endif
mask = 0x0000000000000000ULL;
slb_nr = env->slb_nr;
for (n = 0; n < slb_nr; n++) {
tmp64 = ldq_phys(sr_base);
tmp = ldl_phys(sr_base + 8);
#if defined(DEBUG_SLB)
if (loglevel != 0) {
fprintf(logfile, "%s: seg %d " PADDRX " %016" PRIx64 " %08"
PRIx32 "\n", __func__, n, sr_base, tmp64, tmp);
}
#endif
if (tmp64 & 0x0000000008000000ULL) {
switch (tmp64 & 0x0000000006000000ULL) {
case 0x0000000000000000ULL:
mask = 0xFFFFFFFFF0000000ULL;
break;
case 0x0000000002000000ULL:
mask = 0xFFFF000000000000ULL;
break;
case 0x0000000004000000ULL:
case 0x0000000006000000ULL:
continue;
}
if ((eaddr & mask) == (tmp64 & mask)) {
*vsid = ((tmp64 << 24) | (tmp >> 8)) & 0x0003FFFFFFFFFFFFULL;
*page_mask = ~mask;
*attr = tmp & 0xFF;
ret = 0;
break;
}
}
sr_base += 12;
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0 (CPUPPCState *VAR_0, target_ulong VAR_1,
target_ulong *VAR_2, target_ulong *VAR_3, int *VAR_4)
{
target_phys_addr_t sr_base;
target_ulong mask;
uint64_t tmp64;
uint32_t tmp;
int VAR_5, VAR_6;
int VAR_7;
VAR_6 = -5;
sr_base = VAR_0->spr[SPR_ASR];
#if defined(DEBUG_SLB)
if (loglevel != 0) {
fprintf(logfile, "%s: VAR_1 " ADDRX " base " PADDRX "\VAR_5",
__func__, VAR_1, sr_base);
}
#endif
mask = 0x0000000000000000ULL;
VAR_7 = VAR_0->VAR_7;
for (VAR_5 = 0; VAR_5 < VAR_7; VAR_5++) {
tmp64 = ldq_phys(sr_base);
tmp = ldl_phys(sr_base + 8);
#if defined(DEBUG_SLB)
if (loglevel != 0) {
fprintf(logfile, "%s: seg %d " PADDRX " %016" PRIx64 " %08"
PRIx32 "\VAR_5", __func__, VAR_5, sr_base, tmp64, tmp);
}
#endif
if (tmp64 & 0x0000000008000000ULL) {
switch (tmp64 & 0x0000000006000000ULL) {
case 0x0000000000000000ULL:
mask = 0xFFFFFFFFF0000000ULL;
break;
case 0x0000000002000000ULL:
mask = 0xFFFF000000000000ULL;
break;
case 0x0000000004000000ULL:
case 0x0000000006000000ULL:
continue;
}
if ((VAR_1 & mask) == (tmp64 & mask)) {
*VAR_2 = ((tmp64 << 24) | (tmp >> 8)) & 0x0003FFFFFFFFFFFFULL;
*VAR_3 = ~mask;
*VAR_4 = tmp & 0xFF;
VAR_6 = 0;
break;
}
}
sr_base += 12;
}
return VAR_6;
}
| [
"static int FUNC_0 (CPUPPCState *VAR_0, target_ulong VAR_1,\ntarget_ulong *VAR_2, target_ulong *VAR_3, int *VAR_4)\n{",
"target_phys_addr_t sr_base;",
"target_ulong mask;",
"uint64_t tmp64;",
"uint32_t tmp;",
"int VAR_5, VAR_6;",
"int VAR_7;",
"VAR_6 = -5;",
"sr_base = VAR_0->spr[SPR_ASR];",
"#if defined(DEBUG_SLB)\nif (loglevel != 0) {",
"fprintf(logfile, \"%s: VAR_1 \" ADDRX \" base \" PADDRX \"\\VAR_5\",\n__func__, VAR_1, sr_base);",
"}",
"#endif\nmask = 0x0000000000000000ULL;",
"VAR_7 = VAR_0->VAR_7;",
"for (VAR_5 = 0; VAR_5 < VAR_7; VAR_5++) {",
"tmp64 = ldq_phys(sr_base);",
"tmp = ldl_phys(sr_base + 8);",
"#if defined(DEBUG_SLB)\nif (loglevel != 0) {",
"fprintf(logfile, \"%s: seg %d \" PADDRX \" %016\" PRIx64 \" %08\"\nPRIx32 \"\\VAR_5\", __func__, VAR_5, sr_base, tmp64, tmp);",
"}",
"#endif\nif (tmp64 & 0x0000000008000000ULL) {",
"switch (tmp64 & 0x0000000006000000ULL) {",
"case 0x0000000000000000ULL:\nmask = 0xFFFFFFFFF0000000ULL;",
"break;",
"case 0x0000000002000000ULL:\nmask = 0xFFFF000000000000ULL;",
"break;",
"case 0x0000000004000000ULL:\ncase 0x0000000006000000ULL:\ncontinue;",
"}",
"if ((VAR_1 & mask) == (tmp64 & mask)) {",
"*VAR_2 = ((tmp64 << 24) | (tmp >> 8)) & 0x0003FFFFFFFFFFFFULL;",
"*VAR_3 = ~mask;",
"*VAR_4 = tmp & 0xFF;",
"VAR_6 = 0;",
"break;",
"}",
"}",
"sr_base += 12;",
"}",
"return VAR_6;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25,
27
],
[
29,
31
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47,
49
],
[
51,
53
],
[
55
],
[
57,
59
],
[
63
],
[
65,
69
],
[
71
],
[
73,
77
],
[
79
],
[
81,
83,
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
]
] |
26,015 | static const mon_cmd_t *monitor_parse_command(Monitor *mon,
const char *cmdline,
QDict *qdict)
{
const char *p, *typestr;
int c;
const mon_cmd_t *cmd;
char cmdname[256];
char buf[1024];
char *key;
#ifdef DEBUG
monitor_printf(mon, "command='%s'\n", cmdline);
#endif
/* extract the command name */
p = get_command_name(cmdline, cmdname, sizeof(cmdname));
if (!p)
return NULL;
/* find the command */
for(cmd = mon_cmds; cmd->name != NULL; cmd++) {
if (compare_cmd(cmdname, cmd->name))
break;
}
if (cmd->name == NULL) {
monitor_printf(mon, "unknown command: '%s'\n", cmdname);
return NULL;
}
/* parse the parameters */
typestr = cmd->args_type;
for(;;) {
typestr = key_get_info(typestr, &key);
if (!typestr)
break;
c = *typestr;
typestr++;
switch(c) {
case 'F':
case 'B':
case 's':
{
int ret;
while (qemu_isspace(*p))
p++;
if (*typestr == '?') {
typestr++;
if (*p == '\0') {
/* no optional string: NULL argument */
break;
}
}
ret = get_str(buf, sizeof(buf), &p);
if (ret < 0) {
switch(c) {
case 'F':
monitor_printf(mon, "%s: filename expected\n",
cmdname);
break;
case 'B':
monitor_printf(mon, "%s: block device name expected\n",
cmdname);
break;
default:
monitor_printf(mon, "%s: string expected\n", cmdname);
break;
}
goto fail;
}
qdict_put(qdict, key, qstring_from_str(buf));
}
break;
case '/':
{
int count, format, size;
while (qemu_isspace(*p))
p++;
if (*p == '/') {
/* format found */
p++;
count = 1;
if (qemu_isdigit(*p)) {
count = 0;
while (qemu_isdigit(*p)) {
count = count * 10 + (*p - '0');
p++;
}
}
size = -1;
format = -1;
for(;;) {
switch(*p) {
case 'o':
case 'd':
case 'u':
case 'x':
case 'i':
case 'c':
format = *p++;
break;
case 'b':
size = 1;
p++;
break;
case 'h':
size = 2;
p++;
break;
case 'w':
size = 4;
p++;
break;
case 'g':
case 'L':
size = 8;
p++;
break;
default:
goto next;
}
}
next:
if (*p != '\0' && !qemu_isspace(*p)) {
monitor_printf(mon, "invalid char in format: '%c'\n",
*p);
goto fail;
}
if (format < 0)
format = default_fmt_format;
if (format != 'i') {
/* for 'i', not specifying a size gives -1 as size */
if (size < 0)
size = default_fmt_size;
default_fmt_size = size;
}
default_fmt_format = format;
} else {
count = 1;
format = default_fmt_format;
if (format != 'i') {
size = default_fmt_size;
} else {
size = -1;
}
}
qdict_put(qdict, "count", qint_from_int(count));
qdict_put(qdict, "format", qint_from_int(format));
qdict_put(qdict, "size", qint_from_int(size));
}
break;
case 'i':
case 'l':
{
int64_t val;
while (qemu_isspace(*p))
p++;
if (*typestr == '?' || *typestr == '.') {
if (*typestr == '?') {
if (*p == '\0') {
typestr++;
break;
}
} else {
if (*p == '.') {
p++;
while (qemu_isspace(*p))
p++;
} else {
typestr++;
break;
}
}
typestr++;
}
if (get_expr(mon, &val, &p))
goto fail;
/* Check if 'i' is greater than 32-bit */
if ((c == 'i') && ((val >> 32) & 0xffffffff)) {
monitor_printf(mon, "\'%s\' has failed: ", cmdname);
monitor_printf(mon, "integer is for 32-bit values\n");
goto fail;
}
qdict_put(qdict, key, qint_from_int(val));
}
break;
case '-':
{
const char *tmp = p;
int has_option, skip_key = 0;
/* option */
c = *typestr++;
if (c == '\0')
goto bad_type;
while (qemu_isspace(*p))
p++;
has_option = 0;
if (*p == '-') {
p++;
if(c != *p) {
if(!is_valid_option(p, typestr)) {
monitor_printf(mon, "%s: unsupported option -%c\n",
cmdname, *p);
goto fail;
} else {
skip_key = 1;
}
}
if(skip_key) {
p = tmp;
} else {
p++;
has_option = 1;
}
}
qdict_put(qdict, key, qint_from_int(has_option));
}
break;
default:
bad_type:
monitor_printf(mon, "%s: unknown type '%c'\n", cmdname, c);
goto fail;
}
qemu_free(key);
key = NULL;
}
/* check that all arguments were parsed */
while (qemu_isspace(*p))
p++;
if (*p != '\0') {
monitor_printf(mon, "%s: extraneous characters at the end of line\n",
cmdname);
goto fail;
}
return cmd;
fail:
qemu_free(key);
return NULL;
}
| false | qemu | 7fd669a1c49743073e53166798244f15b1a8e0d2 | static const mon_cmd_t *monitor_parse_command(Monitor *mon,
const char *cmdline,
QDict *qdict)
{
const char *p, *typestr;
int c;
const mon_cmd_t *cmd;
char cmdname[256];
char buf[1024];
char *key;
#ifdef DEBUG
monitor_printf(mon, "command='%s'\n", cmdline);
#endif
p = get_command_name(cmdline, cmdname, sizeof(cmdname));
if (!p)
return NULL;
for(cmd = mon_cmds; cmd->name != NULL; cmd++) {
if (compare_cmd(cmdname, cmd->name))
break;
}
if (cmd->name == NULL) {
monitor_printf(mon, "unknown command: '%s'\n", cmdname);
return NULL;
}
typestr = cmd->args_type;
for(;;) {
typestr = key_get_info(typestr, &key);
if (!typestr)
break;
c = *typestr;
typestr++;
switch(c) {
case 'F':
case 'B':
case 's':
{
int ret;
while (qemu_isspace(*p))
p++;
if (*typestr == '?') {
typestr++;
if (*p == '\0') {
break;
}
}
ret = get_str(buf, sizeof(buf), &p);
if (ret < 0) {
switch(c) {
case 'F':
monitor_printf(mon, "%s: filename expected\n",
cmdname);
break;
case 'B':
monitor_printf(mon, "%s: block device name expected\n",
cmdname);
break;
default:
monitor_printf(mon, "%s: string expected\n", cmdname);
break;
}
goto fail;
}
qdict_put(qdict, key, qstring_from_str(buf));
}
break;
case '/':
{
int count, format, size;
while (qemu_isspace(*p))
p++;
if (*p == '/') {
p++;
count = 1;
if (qemu_isdigit(*p)) {
count = 0;
while (qemu_isdigit(*p)) {
count = count * 10 + (*p - '0');
p++;
}
}
size = -1;
format = -1;
for(;;) {
switch(*p) {
case 'o':
case 'd':
case 'u':
case 'x':
case 'i':
case 'c':
format = *p++;
break;
case 'b':
size = 1;
p++;
break;
case 'h':
size = 2;
p++;
break;
case 'w':
size = 4;
p++;
break;
case 'g':
case 'L':
size = 8;
p++;
break;
default:
goto next;
}
}
next:
if (*p != '\0' && !qemu_isspace(*p)) {
monitor_printf(mon, "invalid char in format: '%c'\n",
*p);
goto fail;
}
if (format < 0)
format = default_fmt_format;
if (format != 'i') {
if (size < 0)
size = default_fmt_size;
default_fmt_size = size;
}
default_fmt_format = format;
} else {
count = 1;
format = default_fmt_format;
if (format != 'i') {
size = default_fmt_size;
} else {
size = -1;
}
}
qdict_put(qdict, "count", qint_from_int(count));
qdict_put(qdict, "format", qint_from_int(format));
qdict_put(qdict, "size", qint_from_int(size));
}
break;
case 'i':
case 'l':
{
int64_t val;
while (qemu_isspace(*p))
p++;
if (*typestr == '?' || *typestr == '.') {
if (*typestr == '?') {
if (*p == '\0') {
typestr++;
break;
}
} else {
if (*p == '.') {
p++;
while (qemu_isspace(*p))
p++;
} else {
typestr++;
break;
}
}
typestr++;
}
if (get_expr(mon, &val, &p))
goto fail;
if ((c == 'i') && ((val >> 32) & 0xffffffff)) {
monitor_printf(mon, "\'%s\' has failed: ", cmdname);
monitor_printf(mon, "integer is for 32-bit values\n");
goto fail;
}
qdict_put(qdict, key, qint_from_int(val));
}
break;
case '-':
{
const char *tmp = p;
int has_option, skip_key = 0;
c = *typestr++;
if (c == '\0')
goto bad_type;
while (qemu_isspace(*p))
p++;
has_option = 0;
if (*p == '-') {
p++;
if(c != *p) {
if(!is_valid_option(p, typestr)) {
monitor_printf(mon, "%s: unsupported option -%c\n",
cmdname, *p);
goto fail;
} else {
skip_key = 1;
}
}
if(skip_key) {
p = tmp;
} else {
p++;
has_option = 1;
}
}
qdict_put(qdict, key, qint_from_int(has_option));
}
break;
default:
bad_type:
monitor_printf(mon, "%s: unknown type '%c'\n", cmdname, c);
goto fail;
}
qemu_free(key);
key = NULL;
}
while (qemu_isspace(*p))
p++;
if (*p != '\0') {
monitor_printf(mon, "%s: extraneous characters at the end of line\n",
cmdname);
goto fail;
}
return cmd;
fail:
qemu_free(key);
return NULL;
}
| {
"code": [],
"line_no": []
} | static const mon_cmd_t *FUNC_0(Monitor *mon,
const char *cmdline,
QDict *qdict)
{
const char *VAR_0, *VAR_1;
int VAR_2;
const mon_cmd_t *VAR_3;
char VAR_4[256];
char VAR_5[1024];
char *VAR_6;
#ifdef DEBUG
monitor_printf(mon, "command='%s'\n", cmdline);
#endif
VAR_0 = get_command_name(cmdline, VAR_4, sizeof(VAR_4));
if (!VAR_0)
return NULL;
for(VAR_3 = mon_cmds; VAR_3->name != NULL; VAR_3++) {
if (compare_cmd(VAR_4, VAR_3->name))
break;
}
if (VAR_3->name == NULL) {
monitor_printf(mon, "unknown command: '%s'\n", VAR_4);
return NULL;
}
VAR_1 = VAR_3->args_type;
for(;;) {
VAR_1 = key_get_info(VAR_1, &VAR_6);
if (!VAR_1)
break;
VAR_2 = *VAR_1;
VAR_1++;
switch(VAR_2) {
case 'F':
case 'B':
case 's':
{
int VAR_7;
while (qemu_isspace(*VAR_0))
VAR_0++;
if (*VAR_1 == '?') {
VAR_1++;
if (*VAR_0 == '\0') {
break;
}
}
VAR_7 = get_str(VAR_5, sizeof(VAR_5), &VAR_0);
if (VAR_7 < 0) {
switch(VAR_2) {
case 'F':
monitor_printf(mon, "%s: filename expected\n",
VAR_4);
break;
case 'B':
monitor_printf(mon, "%s: block device name expected\n",
VAR_4);
break;
default:
monitor_printf(mon, "%s: string expected\n", VAR_4);
break;
}
goto fail;
}
qdict_put(qdict, VAR_6, qstring_from_str(VAR_5));
}
break;
case '/':
{
int VAR_8, VAR_9, VAR_10;
while (qemu_isspace(*VAR_0))
VAR_0++;
if (*VAR_0 == '/') {
VAR_0++;
VAR_8 = 1;
if (qemu_isdigit(*VAR_0)) {
VAR_8 = 0;
while (qemu_isdigit(*VAR_0)) {
VAR_8 = VAR_8 * 10 + (*VAR_0 - '0');
VAR_0++;
}
}
VAR_10 = -1;
VAR_9 = -1;
for(;;) {
switch(*VAR_0) {
case 'o':
case 'd':
case 'u':
case 'x':
case 'i':
case 'VAR_2':
VAR_9 = *VAR_0++;
break;
case 'b':
VAR_10 = 1;
VAR_0++;
break;
case 'h':
VAR_10 = 2;
VAR_0++;
break;
case 'w':
VAR_10 = 4;
VAR_0++;
break;
case 'g':
case 'L':
VAR_10 = 8;
VAR_0++;
break;
default:
goto next;
}
}
next:
if (*VAR_0 != '\0' && !qemu_isspace(*VAR_0)) {
monitor_printf(mon, "invalid char in VAR_9: '%VAR_2'\n",
*VAR_0);
goto fail;
}
if (VAR_9 < 0)
VAR_9 = default_fmt_format;
if (VAR_9 != 'i') {
if (VAR_10 < 0)
VAR_10 = default_fmt_size;
default_fmt_size = VAR_10;
}
default_fmt_format = VAR_9;
} else {
VAR_8 = 1;
VAR_9 = default_fmt_format;
if (VAR_9 != 'i') {
VAR_10 = default_fmt_size;
} else {
VAR_10 = -1;
}
}
qdict_put(qdict, "VAR_8", qint_from_int(VAR_8));
qdict_put(qdict, "VAR_9", qint_from_int(VAR_9));
qdict_put(qdict, "VAR_10", qint_from_int(VAR_10));
}
break;
case 'i':
case 'l':
{
int64_t val;
while (qemu_isspace(*VAR_0))
VAR_0++;
if (*VAR_1 == '?' || *VAR_1 == '.') {
if (*VAR_1 == '?') {
if (*VAR_0 == '\0') {
VAR_1++;
break;
}
} else {
if (*VAR_0 == '.') {
VAR_0++;
while (qemu_isspace(*VAR_0))
VAR_0++;
} else {
VAR_1++;
break;
}
}
VAR_1++;
}
if (get_expr(mon, &val, &VAR_0))
goto fail;
if ((VAR_2 == 'i') && ((val >> 32) & 0xffffffff)) {
monitor_printf(mon, "\'%s\' has failed: ", VAR_4);
monitor_printf(mon, "integer is for 32-bit values\n");
goto fail;
}
qdict_put(qdict, VAR_6, qint_from_int(val));
}
break;
case '-':
{
const char *VAR_11 = VAR_0;
int VAR_12, VAR_13 = 0;
VAR_2 = *VAR_1++;
if (VAR_2 == '\0')
goto bad_type;
while (qemu_isspace(*VAR_0))
VAR_0++;
VAR_12 = 0;
if (*VAR_0 == '-') {
VAR_0++;
if(VAR_2 != *VAR_0) {
if(!is_valid_option(VAR_0, VAR_1)) {
monitor_printf(mon, "%s: unsupported option -%VAR_2\n",
VAR_4, *VAR_0);
goto fail;
} else {
VAR_13 = 1;
}
}
if(VAR_13) {
VAR_0 = VAR_11;
} else {
VAR_0++;
VAR_12 = 1;
}
}
qdict_put(qdict, VAR_6, qint_from_int(VAR_12));
}
break;
default:
bad_type:
monitor_printf(mon, "%s: unknown type '%VAR_2'\n", VAR_4, VAR_2);
goto fail;
}
qemu_free(VAR_6);
VAR_6 = NULL;
}
while (qemu_isspace(*VAR_0))
VAR_0++;
if (*VAR_0 != '\0') {
monitor_printf(mon, "%s: extraneous characters at the end of line\n",
VAR_4);
goto fail;
}
return VAR_3;
fail:
qemu_free(VAR_6);
return NULL;
}
| [
"static const mon_cmd_t *FUNC_0(Monitor *mon,\nconst char *cmdline,\nQDict *qdict)\n{",
"const char *VAR_0, *VAR_1;",
"int VAR_2;",
"const mon_cmd_t *VAR_3;",
"char VAR_4[256];",
"char VAR_5[1024];",
"char *VAR_6;",
"#ifdef DEBUG\nmonitor_printf(mon, \"command='%s'\\n\", cmdline);",
"#endif\nVAR_0 = get_command_name(cmdline, VAR_4, sizeof(VAR_4));",
"if (!VAR_0)\nreturn NULL;",
"for(VAR_3 = mon_cmds; VAR_3->name != NULL; VAR_3++) {",
"if (compare_cmd(VAR_4, VAR_3->name))\nbreak;",
"}",
"if (VAR_3->name == NULL) {",
"monitor_printf(mon, \"unknown command: '%s'\\n\", VAR_4);",
"return NULL;",
"}",
"VAR_1 = VAR_3->args_type;",
"for(;;) {",
"VAR_1 = key_get_info(VAR_1, &VAR_6);",
"if (!VAR_1)\nbreak;",
"VAR_2 = *VAR_1;",
"VAR_1++;",
"switch(VAR_2) {",
"case 'F':\ncase 'B':\ncase 's':\n{",
"int VAR_7;",
"while (qemu_isspace(*VAR_0))\nVAR_0++;",
"if (*VAR_1 == '?') {",
"VAR_1++;",
"if (*VAR_0 == '\\0') {",
"break;",
"}",
"}",
"VAR_7 = get_str(VAR_5, sizeof(VAR_5), &VAR_0);",
"if (VAR_7 < 0) {",
"switch(VAR_2) {",
"case 'F':\nmonitor_printf(mon, \"%s: filename expected\\n\",\nVAR_4);",
"break;",
"case 'B':\nmonitor_printf(mon, \"%s: block device name expected\\n\",\nVAR_4);",
"break;",
"default:\nmonitor_printf(mon, \"%s: string expected\\n\", VAR_4);",
"break;",
"}",
"goto fail;",
"}",
"qdict_put(qdict, VAR_6, qstring_from_str(VAR_5));",
"}",
"break;",
"case '/':\n{",
"int VAR_8, VAR_9, VAR_10;",
"while (qemu_isspace(*VAR_0))\nVAR_0++;",
"if (*VAR_0 == '/') {",
"VAR_0++;",
"VAR_8 = 1;",
"if (qemu_isdigit(*VAR_0)) {",
"VAR_8 = 0;",
"while (qemu_isdigit(*VAR_0)) {",
"VAR_8 = VAR_8 * 10 + (*VAR_0 - '0');",
"VAR_0++;",
"}",
"}",
"VAR_10 = -1;",
"VAR_9 = -1;",
"for(;;) {",
"switch(*VAR_0) {",
"case 'o':\ncase 'd':\ncase 'u':\ncase 'x':\ncase 'i':\ncase 'VAR_2':\nVAR_9 = *VAR_0++;",
"break;",
"case 'b':\nVAR_10 = 1;",
"VAR_0++;",
"break;",
"case 'h':\nVAR_10 = 2;",
"VAR_0++;",
"break;",
"case 'w':\nVAR_10 = 4;",
"VAR_0++;",
"break;",
"case 'g':\ncase 'L':\nVAR_10 = 8;",
"VAR_0++;",
"break;",
"default:\ngoto next;",
"}",
"}",
"next:\nif (*VAR_0 != '\\0' && !qemu_isspace(*VAR_0)) {",
"monitor_printf(mon, \"invalid char in VAR_9: '%VAR_2'\\n\",\n*VAR_0);",
"goto fail;",
"}",
"if (VAR_9 < 0)\nVAR_9 = default_fmt_format;",
"if (VAR_9 != 'i') {",
"if (VAR_10 < 0)\nVAR_10 = default_fmt_size;",
"default_fmt_size = VAR_10;",
"}",
"default_fmt_format = VAR_9;",
"} else {",
"VAR_8 = 1;",
"VAR_9 = default_fmt_format;",
"if (VAR_9 != 'i') {",
"VAR_10 = default_fmt_size;",
"} else {",
"VAR_10 = -1;",
"}",
"}",
"qdict_put(qdict, \"VAR_8\", qint_from_int(VAR_8));",
"qdict_put(qdict, \"VAR_9\", qint_from_int(VAR_9));",
"qdict_put(qdict, \"VAR_10\", qint_from_int(VAR_10));",
"}",
"break;",
"case 'i':\ncase 'l':\n{",
"int64_t val;",
"while (qemu_isspace(*VAR_0))\nVAR_0++;",
"if (*VAR_1 == '?' || *VAR_1 == '.') {",
"if (*VAR_1 == '?') {",
"if (*VAR_0 == '\\0') {",
"VAR_1++;",
"break;",
"}",
"} else {",
"if (*VAR_0 == '.') {",
"VAR_0++;",
"while (qemu_isspace(*VAR_0))\nVAR_0++;",
"} else {",
"VAR_1++;",
"break;",
"}",
"}",
"VAR_1++;",
"}",
"if (get_expr(mon, &val, &VAR_0))\ngoto fail;",
"if ((VAR_2 == 'i') && ((val >> 32) & 0xffffffff)) {",
"monitor_printf(mon, \"\\'%s\\' has failed: \", VAR_4);",
"monitor_printf(mon, \"integer is for 32-bit values\\n\");",
"goto fail;",
"}",
"qdict_put(qdict, VAR_6, qint_from_int(val));",
"}",
"break;",
"case '-':\n{",
"const char *VAR_11 = VAR_0;",
"int VAR_12, VAR_13 = 0;",
"VAR_2 = *VAR_1++;",
"if (VAR_2 == '\\0')\ngoto bad_type;",
"while (qemu_isspace(*VAR_0))\nVAR_0++;",
"VAR_12 = 0;",
"if (*VAR_0 == '-') {",
"VAR_0++;",
"if(VAR_2 != *VAR_0) {",
"if(!is_valid_option(VAR_0, VAR_1)) {",
"monitor_printf(mon, \"%s: unsupported option -%VAR_2\\n\",\nVAR_4, *VAR_0);",
"goto fail;",
"} else {",
"VAR_13 = 1;",
"}",
"}",
"if(VAR_13) {",
"VAR_0 = VAR_11;",
"} else {",
"VAR_0++;",
"VAR_12 = 1;",
"}",
"}",
"qdict_put(qdict, VAR_6, qint_from_int(VAR_12));",
"}",
"break;",
"default:\nbad_type:\nmonitor_printf(mon, \"%s: unknown type '%VAR_2'\\n\", VAR_4, VAR_2);",
"goto fail;",
"}",
"qemu_free(VAR_6);",
"VAR_6 = NULL;",
"}",
"while (qemu_isspace(*VAR_0))\nVAR_0++;",
"if (*VAR_0 != '\\0') {",
"monitor_printf(mon, \"%s: extraneous characters at the end of line\\n\",\nVAR_4);",
"goto fail;",
"}",
"return VAR_3;",
"fail:\nqemu_free(VAR_6);",
"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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
33
],
[
35,
37
],
[
43
],
[
45,
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81,
83,
85,
87
],
[
89
],
[
93,
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117,
119,
121
],
[
123
],
[
125,
127,
129
],
[
131
],
[
133,
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151,
153
],
[
155
],
[
159,
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193,
195,
197,
199,
201,
203,
205
],
[
207
],
[
209,
211
],
[
213
],
[
215
],
[
217,
219
],
[
221
],
[
223
],
[
225,
227
],
[
229
],
[
231
],
[
233,
235,
237
],
[
239
],
[
241
],
[
243,
245
],
[
247
],
[
249
],
[
251,
253
],
[
255,
257
],
[
259
],
[
261
],
[
263,
265
],
[
267
],
[
271,
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309,
311,
313
],
[
315
],
[
319,
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341,
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359,
361
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381,
383
],
[
385
],
[
387
],
[
393
],
[
395,
397
],
[
399,
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411
],
[
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
],
[
467,
469
],
[
471
],
[
473,
475
],
[
477
],
[
479
],
[
483
],
[
487,
489
],
[
491
],
[
493
]
] |
26,016 | static coroutine_fn int qcow_co_writev(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, QEMUIOVector *qiov)
{
BDRVQcowState *s = bs->opaque;
int index_in_cluster;
uint64_t cluster_offset;
int ret = 0, n;
struct iovec hd_iov;
QEMUIOVector hd_qiov;
uint8_t *buf;
void *orig_buf;
s->cluster_cache_offset = -1; /* disable compressed cache */
/* We must always copy the iov when encrypting, so we
* don't modify the original data buffer during encryption */
if (bs->encrypted || qiov->niov > 1) {
buf = orig_buf = qemu_try_blockalign(bs, qiov->size);
if (buf == NULL) {
return -ENOMEM;
}
qemu_iovec_to_buf(qiov, 0, buf, qiov->size);
} else {
orig_buf = NULL;
buf = (uint8_t *)qiov->iov->iov_base;
}
qemu_co_mutex_lock(&s->lock);
while (nb_sectors != 0) {
index_in_cluster = sector_num & (s->cluster_sectors - 1);
n = s->cluster_sectors - index_in_cluster;
if (n > nb_sectors) {
n = nb_sectors;
}
cluster_offset = get_cluster_offset(bs, sector_num << 9, 1, 0,
index_in_cluster,
index_in_cluster + n);
if (!cluster_offset || (cluster_offset & 511) != 0) {
ret = -EIO;
break;
}
if (bs->encrypted) {
Error *err = NULL;
assert(s->cipher);
if (encrypt_sectors(s, sector_num, buf, n, true, &err) < 0) {
error_free(err);
ret = -EIO;
break;
}
}
hd_iov.iov_base = (void *)buf;
hd_iov.iov_len = n * 512;
qemu_iovec_init_external(&hd_qiov, &hd_iov, 1);
qemu_co_mutex_unlock(&s->lock);
ret = bdrv_co_writev(bs->file,
(cluster_offset >> 9) + index_in_cluster,
n, &hd_qiov);
qemu_co_mutex_lock(&s->lock);
if (ret < 0) {
break;
}
ret = 0;
nb_sectors -= n;
sector_num += n;
buf += n * 512;
}
qemu_co_mutex_unlock(&s->lock);
qemu_vfree(orig_buf);
return ret;
}
| false | qemu | d85f4222b4681da7ebf8a90b26e085a68fa2c55a | static coroutine_fn int qcow_co_writev(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, QEMUIOVector *qiov)
{
BDRVQcowState *s = bs->opaque;
int index_in_cluster;
uint64_t cluster_offset;
int ret = 0, n;
struct iovec hd_iov;
QEMUIOVector hd_qiov;
uint8_t *buf;
void *orig_buf;
s->cluster_cache_offset = -1;
if (bs->encrypted || qiov->niov > 1) {
buf = orig_buf = qemu_try_blockalign(bs, qiov->size);
if (buf == NULL) {
return -ENOMEM;
}
qemu_iovec_to_buf(qiov, 0, buf, qiov->size);
} else {
orig_buf = NULL;
buf = (uint8_t *)qiov->iov->iov_base;
}
qemu_co_mutex_lock(&s->lock);
while (nb_sectors != 0) {
index_in_cluster = sector_num & (s->cluster_sectors - 1);
n = s->cluster_sectors - index_in_cluster;
if (n > nb_sectors) {
n = nb_sectors;
}
cluster_offset = get_cluster_offset(bs, sector_num << 9, 1, 0,
index_in_cluster,
index_in_cluster + n);
if (!cluster_offset || (cluster_offset & 511) != 0) {
ret = -EIO;
break;
}
if (bs->encrypted) {
Error *err = NULL;
assert(s->cipher);
if (encrypt_sectors(s, sector_num, buf, n, true, &err) < 0) {
error_free(err);
ret = -EIO;
break;
}
}
hd_iov.iov_base = (void *)buf;
hd_iov.iov_len = n * 512;
qemu_iovec_init_external(&hd_qiov, &hd_iov, 1);
qemu_co_mutex_unlock(&s->lock);
ret = bdrv_co_writev(bs->file,
(cluster_offset >> 9) + index_in_cluster,
n, &hd_qiov);
qemu_co_mutex_lock(&s->lock);
if (ret < 0) {
break;
}
ret = 0;
nb_sectors -= n;
sector_num += n;
buf += n * 512;
}
qemu_co_mutex_unlock(&s->lock);
qemu_vfree(orig_buf);
return ret;
}
| {
"code": [],
"line_no": []
} | static coroutine_fn int FUNC_0(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, QEMUIOVector *qiov)
{
BDRVQcowState *s = bs->opaque;
int VAR_0;
uint64_t cluster_offset;
int VAR_1 = 0, VAR_2;
struct iovec VAR_3;
QEMUIOVector hd_qiov;
uint8_t *buf;
void *VAR_4;
s->cluster_cache_offset = -1;
if (bs->encrypted || qiov->niov > 1) {
buf = VAR_4 = qemu_try_blockalign(bs, qiov->size);
if (buf == NULL) {
return -ENOMEM;
}
qemu_iovec_to_buf(qiov, 0, buf, qiov->size);
} else {
VAR_4 = NULL;
buf = (uint8_t *)qiov->iov->iov_base;
}
qemu_co_mutex_lock(&s->lock);
while (nb_sectors != 0) {
VAR_0 = sector_num & (s->cluster_sectors - 1);
VAR_2 = s->cluster_sectors - VAR_0;
if (VAR_2 > nb_sectors) {
VAR_2 = nb_sectors;
}
cluster_offset = get_cluster_offset(bs, sector_num << 9, 1, 0,
VAR_0,
VAR_0 + VAR_2);
if (!cluster_offset || (cluster_offset & 511) != 0) {
VAR_1 = -EIO;
break;
}
if (bs->encrypted) {
Error *err = NULL;
assert(s->cipher);
if (encrypt_sectors(s, sector_num, buf, VAR_2, true, &err) < 0) {
error_free(err);
VAR_1 = -EIO;
break;
}
}
VAR_3.iov_base = (void *)buf;
VAR_3.iov_len = VAR_2 * 512;
qemu_iovec_init_external(&hd_qiov, &VAR_3, 1);
qemu_co_mutex_unlock(&s->lock);
VAR_1 = bdrv_co_writev(bs->file,
(cluster_offset >> 9) + VAR_0,
VAR_2, &hd_qiov);
qemu_co_mutex_lock(&s->lock);
if (VAR_1 < 0) {
break;
}
VAR_1 = 0;
nb_sectors -= VAR_2;
sector_num += VAR_2;
buf += VAR_2 * 512;
}
qemu_co_mutex_unlock(&s->lock);
qemu_vfree(VAR_4);
return VAR_1;
}
| [
"static coroutine_fn int FUNC_0(BlockDriverState *bs, int64_t sector_num,\nint nb_sectors, QEMUIOVector *qiov)\n{",
"BDRVQcowState *s = bs->opaque;",
"int VAR_0;",
"uint64_t cluster_offset;",
"int VAR_1 = 0, VAR_2;",
"struct iovec VAR_3;",
"QEMUIOVector hd_qiov;",
"uint8_t *buf;",
"void *VAR_4;",
"s->cluster_cache_offset = -1;",
"if (bs->encrypted || qiov->niov > 1) {",
"buf = VAR_4 = qemu_try_blockalign(bs, qiov->size);",
"if (buf == NULL) {",
"return -ENOMEM;",
"}",
"qemu_iovec_to_buf(qiov, 0, buf, qiov->size);",
"} else {",
"VAR_4 = NULL;",
"buf = (uint8_t *)qiov->iov->iov_base;",
"}",
"qemu_co_mutex_lock(&s->lock);",
"while (nb_sectors != 0) {",
"VAR_0 = sector_num & (s->cluster_sectors - 1);",
"VAR_2 = s->cluster_sectors - VAR_0;",
"if (VAR_2 > nb_sectors) {",
"VAR_2 = nb_sectors;",
"}",
"cluster_offset = get_cluster_offset(bs, sector_num << 9, 1, 0,\nVAR_0,\nVAR_0 + VAR_2);",
"if (!cluster_offset || (cluster_offset & 511) != 0) {",
"VAR_1 = -EIO;",
"break;",
"}",
"if (bs->encrypted) {",
"Error *err = NULL;",
"assert(s->cipher);",
"if (encrypt_sectors(s, sector_num, buf, VAR_2, true, &err) < 0) {",
"error_free(err);",
"VAR_1 = -EIO;",
"break;",
"}",
"}",
"VAR_3.iov_base = (void *)buf;",
"VAR_3.iov_len = VAR_2 * 512;",
"qemu_iovec_init_external(&hd_qiov, &VAR_3, 1);",
"qemu_co_mutex_unlock(&s->lock);",
"VAR_1 = bdrv_co_writev(bs->file,\n(cluster_offset >> 9) + VAR_0,\nVAR_2, &hd_qiov);",
"qemu_co_mutex_lock(&s->lock);",
"if (VAR_1 < 0) {",
"break;",
"}",
"VAR_1 = 0;",
"nb_sectors -= VAR_2;",
"sector_num += VAR_2;",
"buf += VAR_2 * 512;",
"}",
"qemu_co_mutex_unlock(&s->lock);",
"qemu_vfree(VAR_4);",
"return VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73,
75,
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115,
117,
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
145
],
[
149
],
[
151
]
] |
26,017 | static void start_auth_vencrypt_subauth(VncState *vs)
{
switch (vs->vd->subauth) {
case VNC_AUTH_VENCRYPT_TLSNONE:
case VNC_AUTH_VENCRYPT_X509NONE:
VNC_DEBUG("Accept TLS auth none\n");
vnc_write_u32(vs, 0); /* Accept auth completion */
start_client_init(vs);
break;
case VNC_AUTH_VENCRYPT_TLSVNC:
case VNC_AUTH_VENCRYPT_X509VNC:
VNC_DEBUG("Start TLS auth VNC\n");
start_auth_vnc(vs);
break;
#ifdef CONFIG_VNC_SASL
case VNC_AUTH_VENCRYPT_TLSSASL:
case VNC_AUTH_VENCRYPT_X509SASL:
VNC_DEBUG("Start TLS auth SASL\n");
return start_auth_sasl(vs);
#endif /* CONFIG_VNC_SASL */
default: /* Should not be possible, but just in case */
VNC_DEBUG("Reject subauth %d server bug\n", vs->vd->auth);
vnc_write_u8(vs, 1);
if (vs->minor >= 8) {
static const char err[] = "Unsupported authentication type";
vnc_write_u32(vs, sizeof(err));
vnc_write(vs, err, sizeof(err));
}
vnc_client_error(vs);
}
}
| false | qemu | 7e7e2ebc942da8285931ceabf12823e165dced8b | static void start_auth_vencrypt_subauth(VncState *vs)
{
switch (vs->vd->subauth) {
case VNC_AUTH_VENCRYPT_TLSNONE:
case VNC_AUTH_VENCRYPT_X509NONE:
VNC_DEBUG("Accept TLS auth none\n");
vnc_write_u32(vs, 0);
start_client_init(vs);
break;
case VNC_AUTH_VENCRYPT_TLSVNC:
case VNC_AUTH_VENCRYPT_X509VNC:
VNC_DEBUG("Start TLS auth VNC\n");
start_auth_vnc(vs);
break;
#ifdef CONFIG_VNC_SASL
case VNC_AUTH_VENCRYPT_TLSSASL:
case VNC_AUTH_VENCRYPT_X509SASL:
VNC_DEBUG("Start TLS auth SASL\n");
return start_auth_sasl(vs);
#endif
default:
VNC_DEBUG("Reject subauth %d server bug\n", vs->vd->auth);
vnc_write_u8(vs, 1);
if (vs->minor >= 8) {
static const char err[] = "Unsupported authentication type";
vnc_write_u32(vs, sizeof(err));
vnc_write(vs, err, sizeof(err));
}
vnc_client_error(vs);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(VncState *VAR_0)
{
switch (VAR_0->vd->subauth) {
case VNC_AUTH_VENCRYPT_TLSNONE:
case VNC_AUTH_VENCRYPT_X509NONE:
VNC_DEBUG("Accept TLS auth none\n");
vnc_write_u32(VAR_0, 0);
start_client_init(VAR_0);
break;
case VNC_AUTH_VENCRYPT_TLSVNC:
case VNC_AUTH_VENCRYPT_X509VNC:
VNC_DEBUG("Start TLS auth VNC\n");
start_auth_vnc(VAR_0);
break;
#ifdef CONFIG_VNC_SASL
case VNC_AUTH_VENCRYPT_TLSSASL:
case VNC_AUTH_VENCRYPT_X509SASL:
VNC_DEBUG("Start TLS auth SASL\n");
return start_auth_sasl(VAR_0);
#endif
default:
VNC_DEBUG("Reject subauth %d server bug\n", VAR_0->vd->auth);
vnc_write_u8(VAR_0, 1);
if (VAR_0->minor >= 8) {
static const char VAR_1[] = "Unsupported authentication type";
vnc_write_u32(VAR_0, sizeof(VAR_1));
vnc_write(VAR_0, VAR_1, sizeof(VAR_1));
}
vnc_client_error(VAR_0);
}
}
| [
"static void FUNC_0(VncState *VAR_0)\n{",
"switch (VAR_0->vd->subauth) {",
"case VNC_AUTH_VENCRYPT_TLSNONE:\ncase VNC_AUTH_VENCRYPT_X509NONE:\nVNC_DEBUG(\"Accept TLS auth none\\n\");",
"vnc_write_u32(VAR_0, 0);",
"start_client_init(VAR_0);",
"break;",
"case VNC_AUTH_VENCRYPT_TLSVNC:\ncase VNC_AUTH_VENCRYPT_X509VNC:\nVNC_DEBUG(\"Start TLS auth VNC\\n\");",
"start_auth_vnc(VAR_0);",
"break;",
"#ifdef CONFIG_VNC_SASL\ncase VNC_AUTH_VENCRYPT_TLSSASL:\ncase VNC_AUTH_VENCRYPT_X509SASL:\nVNC_DEBUG(\"Start TLS auth SASL\\n\");",
"return start_auth_sasl(VAR_0);",
"#endif\ndefault:\nVNC_DEBUG(\"Reject subauth %d server bug\\n\", VAR_0->vd->auth);",
"vnc_write_u8(VAR_0, 1);",
"if (VAR_0->minor >= 8) {",
"static const char VAR_1[] = \"Unsupported authentication type\";",
"vnc_write_u32(VAR_0, sizeof(VAR_1));",
"vnc_write(VAR_0, VAR_1, sizeof(VAR_1));",
"}",
"vnc_client_error(VAR_0);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9,
11
],
[
13
],
[
15
],
[
17
],
[
21,
23,
25
],
[
27
],
[
29
],
[
33,
35,
37,
39
],
[
41
],
[
43,
47,
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
]
] |
26,019 | static void disas_test_b_imm(DisasContext *s, uint32_t insn)
{
unsigned int bit_pos, op, rt;
uint64_t addr;
int label_match;
TCGv_i64 tcg_cmp;
bit_pos = (extract32(insn, 31, 1) << 5) | extract32(insn, 19, 5);
op = extract32(insn, 24, 1); /* 0: TBZ; 1: TBNZ */
addr = s->pc + sextract32(insn, 5, 14) * 4 - 4;
rt = extract32(insn, 0, 5);
tcg_cmp = tcg_temp_new_i64();
tcg_gen_andi_i64(tcg_cmp, cpu_reg(s, rt), (1ULL << bit_pos));
label_match = gen_new_label();
tcg_gen_brcondi_i64(op ? TCG_COND_NE : TCG_COND_EQ,
tcg_cmp, 0, label_match);
tcg_temp_free_i64(tcg_cmp);
gen_goto_tb(s, 0, s->pc);
gen_set_label(label_match);
gen_goto_tb(s, 1, addr);
}
| false | qemu | 42a268c241183877192c376d03bd9b6d527407c7 | static void disas_test_b_imm(DisasContext *s, uint32_t insn)
{
unsigned int bit_pos, op, rt;
uint64_t addr;
int label_match;
TCGv_i64 tcg_cmp;
bit_pos = (extract32(insn, 31, 1) << 5) | extract32(insn, 19, 5);
op = extract32(insn, 24, 1);
addr = s->pc + sextract32(insn, 5, 14) * 4 - 4;
rt = extract32(insn, 0, 5);
tcg_cmp = tcg_temp_new_i64();
tcg_gen_andi_i64(tcg_cmp, cpu_reg(s, rt), (1ULL << bit_pos));
label_match = gen_new_label();
tcg_gen_brcondi_i64(op ? TCG_COND_NE : TCG_COND_EQ,
tcg_cmp, 0, label_match);
tcg_temp_free_i64(tcg_cmp);
gen_goto_tb(s, 0, s->pc);
gen_set_label(label_match);
gen_goto_tb(s, 1, addr);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1)
{
unsigned int VAR_2, VAR_3, VAR_4;
uint64_t addr;
int VAR_5;
TCGv_i64 tcg_cmp;
VAR_2 = (extract32(VAR_1, 31, 1) << 5) | extract32(VAR_1, 19, 5);
VAR_3 = extract32(VAR_1, 24, 1);
addr = VAR_0->pc + sextract32(VAR_1, 5, 14) * 4 - 4;
VAR_4 = extract32(VAR_1, 0, 5);
tcg_cmp = tcg_temp_new_i64();
tcg_gen_andi_i64(tcg_cmp, cpu_reg(VAR_0, VAR_4), (1ULL << VAR_2));
VAR_5 = gen_new_label();
tcg_gen_brcondi_i64(VAR_3 ? TCG_COND_NE : TCG_COND_EQ,
tcg_cmp, 0, VAR_5);
tcg_temp_free_i64(tcg_cmp);
gen_goto_tb(VAR_0, 0, VAR_0->pc);
gen_set_label(VAR_5);
gen_goto_tb(VAR_0, 1, addr);
}
| [
"static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1)\n{",
"unsigned int VAR_2, VAR_3, VAR_4;",
"uint64_t addr;",
"int VAR_5;",
"TCGv_i64 tcg_cmp;",
"VAR_2 = (extract32(VAR_1, 31, 1) << 5) | extract32(VAR_1, 19, 5);",
"VAR_3 = extract32(VAR_1, 24, 1);",
"addr = VAR_0->pc + sextract32(VAR_1, 5, 14) * 4 - 4;",
"VAR_4 = extract32(VAR_1, 0, 5);",
"tcg_cmp = tcg_temp_new_i64();",
"tcg_gen_andi_i64(tcg_cmp, cpu_reg(VAR_0, VAR_4), (1ULL << VAR_2));",
"VAR_5 = gen_new_label();",
"tcg_gen_brcondi_i64(VAR_3 ? TCG_COND_NE : TCG_COND_EQ,\ntcg_cmp, 0, VAR_5);",
"tcg_temp_free_i64(tcg_cmp);",
"gen_goto_tb(VAR_0, 0, VAR_0->pc);",
"gen_set_label(VAR_5);",
"gen_goto_tb(VAR_0, 1, addr);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
]
] |
26,020 | static QObject *parse_escape(JSONParserContext *ctxt, QList **tokens, va_list *ap)
{
QObject *token = NULL, *obj;
QList *working = qlist_copy(*tokens);
if (ap == NULL) {
goto out;
}
token = qlist_pop(working);
if (token == NULL) {
goto out;
}
if (token_is_escape(token, "%p")) {
obj = va_arg(*ap, QObject *);
} else if (token_is_escape(token, "%i")) {
obj = QOBJECT(qbool_from_int(va_arg(*ap, int)));
} else if (token_is_escape(token, "%d")) {
obj = QOBJECT(qint_from_int(va_arg(*ap, int)));
} else if (token_is_escape(token, "%ld")) {
obj = QOBJECT(qint_from_int(va_arg(*ap, long)));
} else if (token_is_escape(token, "%lld") ||
token_is_escape(token, "%I64d")) {
obj = QOBJECT(qint_from_int(va_arg(*ap, long long)));
} else if (token_is_escape(token, "%s")) {
obj = QOBJECT(qstring_from_str(va_arg(*ap, const char *)));
} else if (token_is_escape(token, "%f")) {
obj = QOBJECT(qfloat_from_double(va_arg(*ap, double)));
} else {
goto out;
}
qobject_decref(token);
QDECREF(*tokens);
*tokens = working;
return obj;
out:
qobject_decref(token);
QDECREF(working);
return NULL;
}
| false | qemu | 65c0f1e9558c7c762cdb333406243fff1d687117 | static QObject *parse_escape(JSONParserContext *ctxt, QList **tokens, va_list *ap)
{
QObject *token = NULL, *obj;
QList *working = qlist_copy(*tokens);
if (ap == NULL) {
goto out;
}
token = qlist_pop(working);
if (token == NULL) {
goto out;
}
if (token_is_escape(token, "%p")) {
obj = va_arg(*ap, QObject *);
} else if (token_is_escape(token, "%i")) {
obj = QOBJECT(qbool_from_int(va_arg(*ap, int)));
} else if (token_is_escape(token, "%d")) {
obj = QOBJECT(qint_from_int(va_arg(*ap, int)));
} else if (token_is_escape(token, "%ld")) {
obj = QOBJECT(qint_from_int(va_arg(*ap, long)));
} else if (token_is_escape(token, "%lld") ||
token_is_escape(token, "%I64d")) {
obj = QOBJECT(qint_from_int(va_arg(*ap, long long)));
} else if (token_is_escape(token, "%s")) {
obj = QOBJECT(qstring_from_str(va_arg(*ap, const char *)));
} else if (token_is_escape(token, "%f")) {
obj = QOBJECT(qfloat_from_double(va_arg(*ap, double)));
} else {
goto out;
}
qobject_decref(token);
QDECREF(*tokens);
*tokens = working;
return obj;
out:
qobject_decref(token);
QDECREF(working);
return NULL;
}
| {
"code": [],
"line_no": []
} | static QObject *FUNC_0(JSONParserContext *ctxt, QList **tokens, va_list *ap)
{
QObject *token = NULL, *obj;
QList *working = qlist_copy(*tokens);
if (ap == NULL) {
goto out;
}
token = qlist_pop(working);
if (token == NULL) {
goto out;
}
if (token_is_escape(token, "%p")) {
obj = va_arg(*ap, QObject *);
} else if (token_is_escape(token, "%i")) {
obj = QOBJECT(qbool_from_int(va_arg(*ap, int)));
} else if (token_is_escape(token, "%d")) {
obj = QOBJECT(qint_from_int(va_arg(*ap, int)));
} else if (token_is_escape(token, "%ld")) {
obj = QOBJECT(qint_from_int(va_arg(*ap, long)));
} else if (token_is_escape(token, "%lld") ||
token_is_escape(token, "%I64d")) {
obj = QOBJECT(qint_from_int(va_arg(*ap, long long)));
} else if (token_is_escape(token, "%s")) {
obj = QOBJECT(qstring_from_str(va_arg(*ap, const char *)));
} else if (token_is_escape(token, "%f")) {
obj = QOBJECT(qfloat_from_double(va_arg(*ap, double)));
} else {
goto out;
}
qobject_decref(token);
QDECREF(*tokens);
*tokens = working;
return obj;
out:
qobject_decref(token);
QDECREF(working);
return NULL;
}
| [
"static QObject *FUNC_0(JSONParserContext *ctxt, QList **tokens, va_list *ap)\n{",
"QObject *token = NULL, *obj;",
"QList *working = qlist_copy(*tokens);",
"if (ap == NULL) {",
"goto out;",
"}",
"token = qlist_pop(working);",
"if (token == NULL) {",
"goto out;",
"}",
"if (token_is_escape(token, \"%p\")) {",
"obj = va_arg(*ap, QObject *);",
"} else if (token_is_escape(token, \"%i\")) {",
"obj = QOBJECT(qbool_from_int(va_arg(*ap, int)));",
"} else if (token_is_escape(token, \"%d\")) {",
"obj = QOBJECT(qint_from_int(va_arg(*ap, int)));",
"} else if (token_is_escape(token, \"%ld\")) {",
"obj = QOBJECT(qint_from_int(va_arg(*ap, long)));",
"} else if (token_is_escape(token, \"%lld\") ||",
"token_is_escape(token, \"%I64d\")) {",
"obj = QOBJECT(qint_from_int(va_arg(*ap, long long)));",
"} else if (token_is_escape(token, \"%s\")) {",
"obj = QOBJECT(qstring_from_str(va_arg(*ap, const char *)));",
"} else if (token_is_escape(token, \"%f\")) {",
"obj = QOBJECT(qfloat_from_double(va_arg(*ap, double)));",
"} else {",
"goto out;",
"}",
"qobject_decref(token);",
"QDECREF(*tokens);",
"*tokens = working;",
"return obj;",
"out:\nqobject_decref(token);",
"QDECREF(working);",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
75
],
[
79,
81
],
[
83
],
[
87
],
[
89
]
] |
26,021 | ParallelState *parallel_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq, CharDriverState *chr)
{
ParallelState *s;
int io_sw;
s = qemu_mallocz(sizeof(ParallelState));
s->irq = irq;
s->chr = chr;
s->it_shift = it_shift;
qemu_register_reset(parallel_reset, s);
io_sw = cpu_register_io_memory(parallel_mm_read_sw, parallel_mm_write_sw,
s, DEVICE_NATIVE_ENDIAN);
cpu_register_physical_memory(base, 8 << it_shift, io_sw);
return s;
}
| false | qemu | defdb20e1a8ac3a7200aaf190d7fb20a5ac8bcea | ParallelState *parallel_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq, CharDriverState *chr)
{
ParallelState *s;
int io_sw;
s = qemu_mallocz(sizeof(ParallelState));
s->irq = irq;
s->chr = chr;
s->it_shift = it_shift;
qemu_register_reset(parallel_reset, s);
io_sw = cpu_register_io_memory(parallel_mm_read_sw, parallel_mm_write_sw,
s, DEVICE_NATIVE_ENDIAN);
cpu_register_physical_memory(base, 8 << it_shift, io_sw);
return s;
}
| {
"code": [],
"line_no": []
} | ParallelState *FUNC_0(target_phys_addr_t base, int it_shift, qemu_irq irq, CharDriverState *chr)
{
ParallelState *s;
int VAR_0;
s = qemu_mallocz(sizeof(ParallelState));
s->irq = irq;
s->chr = chr;
s->it_shift = it_shift;
qemu_register_reset(parallel_reset, s);
VAR_0 = cpu_register_io_memory(parallel_mm_read_sw, parallel_mm_write_sw,
s, DEVICE_NATIVE_ENDIAN);
cpu_register_physical_memory(base, 8 << it_shift, VAR_0);
return s;
}
| [
"ParallelState *FUNC_0(target_phys_addr_t base, int it_shift, qemu_irq irq, CharDriverState *chr)\n{",
"ParallelState *s;",
"int VAR_0;",
"s = qemu_mallocz(sizeof(ParallelState));",
"s->irq = irq;",
"s->chr = chr;",
"s->it_shift = it_shift;",
"qemu_register_reset(parallel_reset, s);",
"VAR_0 = cpu_register_io_memory(parallel_mm_read_sw, parallel_mm_write_sw,\ns, DEVICE_NATIVE_ENDIAN);",
"cpu_register_physical_memory(base, 8 << it_shift, VAR_0);",
"return s;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23,
25
],
[
27
],
[
29
],
[
31
]
] |
26,022 | int float32_le( float32 a, float32 b STATUS_PARAM )
{
flag aSign, bSign;
if ( ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) )
|| ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) )
) {
float_raise( float_flag_invalid STATUS_VAR);
return 0;
}
aSign = extractFloat32Sign( a );
bSign = extractFloat32Sign( b );
if ( aSign != bSign ) return aSign || ( (bits32) ( ( a | b )<<1 ) == 0 );
return ( a == b ) || ( aSign ^ ( a < b ) );
}
| false | qemu | f090c9d4ad5812fb92843d6470a1111c15190c4c | int float32_le( float32 a, float32 b STATUS_PARAM )
{
flag aSign, bSign;
if ( ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) )
|| ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) )
) {
float_raise( float_flag_invalid STATUS_VAR);
return 0;
}
aSign = extractFloat32Sign( a );
bSign = extractFloat32Sign( b );
if ( aSign != bSign ) return aSign || ( (bits32) ( ( a | b )<<1 ) == 0 );
return ( a == b ) || ( aSign ^ ( a < b ) );
}
| {
"code": [],
"line_no": []
} | int FUNC_0( float32 VAR_0, float32 VAR_1 STATUS_PARAM )
{
flag aSign, bSign;
if ( ( ( extractFloat32Exp( VAR_0 ) == 0xFF ) && extractFloat32Frac( VAR_0 ) )
|| ( ( extractFloat32Exp( VAR_1 ) == 0xFF ) && extractFloat32Frac( VAR_1 ) )
) {
float_raise( float_flag_invalid STATUS_VAR);
return 0;
}
aSign = extractFloat32Sign( VAR_0 );
bSign = extractFloat32Sign( VAR_1 );
if ( aSign != bSign ) return aSign || ( (bits32) ( ( VAR_0 | VAR_1 )<<1 ) == 0 );
return ( VAR_0 == VAR_1 ) || ( aSign ^ ( VAR_0 < VAR_1 ) );
}
| [
"int FUNC_0( float32 VAR_0, float32 VAR_1 STATUS_PARAM )\n{",
"flag aSign, bSign;",
"if ( ( ( extractFloat32Exp( VAR_0 ) == 0xFF ) && extractFloat32Frac( VAR_0 ) )\n|| ( ( extractFloat32Exp( VAR_1 ) == 0xFF ) && extractFloat32Frac( VAR_1 ) )\n) {",
"float_raise( float_flag_invalid STATUS_VAR);",
"return 0;",
"}",
"aSign = extractFloat32Sign( VAR_0 );",
"bSign = extractFloat32Sign( VAR_1 );",
"if ( aSign != bSign ) return aSign || ( (bits32) ( ( VAR_0 | VAR_1 )<<1 ) == 0 );",
"return ( VAR_0 == VAR_1 ) || ( aSign ^ ( VAR_0 < VAR_1 ) );",
"}"
] | [
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
]
] |
26,023 | static void ttafilter_init(TTAContext *s, TTAFilter *c, int32_t shift) {
memset(c, 0, sizeof(TTAFilter));
if (s->pass) {
int i;
for (i = 0; i < 8; i++)
c->qm[i] = sign_extend(s->crc_pass[i], 8);
}
c->shift = shift;
c->round = shift_1[shift-1];
// c->round = 1 << (shift - 1);
}
| false | FFmpeg | 2e988fd689642899927707a084bf40dc1326dc90 | static void ttafilter_init(TTAContext *s, TTAFilter *c, int32_t shift) {
memset(c, 0, sizeof(TTAFilter));
if (s->pass) {
int i;
for (i = 0; i < 8; i++)
c->qm[i] = sign_extend(s->crc_pass[i], 8);
}
c->shift = shift;
c->round = shift_1[shift-1];
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TTAContext *VAR_0, TTAFilter *VAR_1, int32_t VAR_2) {
memset(VAR_1, 0, sizeof(TTAFilter));
if (VAR_0->pass) {
int VAR_3;
for (VAR_3 = 0; VAR_3 < 8; VAR_3++)
VAR_1->qm[VAR_3] = sign_extend(VAR_0->crc_pass[VAR_3], 8);
}
VAR_1->VAR_2 = VAR_2;
VAR_1->round = shift_1[VAR_2-1];
}
| [
"static void FUNC_0(TTAContext *VAR_0, TTAFilter *VAR_1, int32_t VAR_2) {",
"memset(VAR_1, 0, sizeof(TTAFilter));",
"if (VAR_0->pass) {",
"int VAR_3;",
"for (VAR_3 = 0; VAR_3 < 8; VAR_3++)",
"VAR_1->qm[VAR_3] = sign_extend(VAR_0->crc_pass[VAR_3], 8);",
"}",
"VAR_1->VAR_2 = VAR_2;",
"VAR_1->round = shift_1[VAR_2-1];",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
]
] |
26,024 | USBDevice *usb_msd_init(const char *filename, BlockDriverState **pbs)
{
MSDState *s;
BlockDriverState *bdrv;
BlockDriver *drv = NULL;
const char *p1;
char fmt[32];
p1 = strchr(filename, ':');
if (p1++) {
const char *p2;
if (strstart(filename, "format=", &p2)) {
int len = MIN(p1 - p2, sizeof(fmt));
pstrcpy(fmt, len, p2);
drv = bdrv_find_format(fmt);
if (!drv) {
printf("invalid format %s\n", fmt);
return NULL;
}
} else if (*filename != ':') {
printf("unrecognized USB mass-storage option %s\n", filename);
return NULL;
}
filename = p1;
}
if (!*filename) {
printf("block device specification needed\n");
return NULL;
}
s = qemu_mallocz(sizeof(MSDState));
bdrv = bdrv_new("usb");
if (bdrv_open2(bdrv, filename, 0, drv) < 0)
goto fail;
s->bs = bdrv;
*pbs = bdrv;
s->dev.speed = USB_SPEED_FULL;
s->dev.handle_packet = usb_generic_handle_packet;
s->dev.handle_reset = usb_msd_handle_reset;
s->dev.handle_control = usb_msd_handle_control;
s->dev.handle_data = usb_msd_handle_data;
s->dev.handle_destroy = usb_msd_handle_destroy;
snprintf(s->dev.devname, sizeof(s->dev.devname), "QEMU USB MSD(%.16s)",
filename);
s->scsi_dev = scsi_disk_init(bdrv, 0, usb_msd_command_complete, s);
usb_msd_handle_reset((USBDevice *)s);
return (USBDevice *)s;
fail:
qemu_free(s);
return NULL;
}
| false | qemu | bb5fc20f7c1c65e95030da3629dd0d7a0cce38cd | USBDevice *usb_msd_init(const char *filename, BlockDriverState **pbs)
{
MSDState *s;
BlockDriverState *bdrv;
BlockDriver *drv = NULL;
const char *p1;
char fmt[32];
p1 = strchr(filename, ':');
if (p1++) {
const char *p2;
if (strstart(filename, "format=", &p2)) {
int len = MIN(p1 - p2, sizeof(fmt));
pstrcpy(fmt, len, p2);
drv = bdrv_find_format(fmt);
if (!drv) {
printf("invalid format %s\n", fmt);
return NULL;
}
} else if (*filename != ':') {
printf("unrecognized USB mass-storage option %s\n", filename);
return NULL;
}
filename = p1;
}
if (!*filename) {
printf("block device specification needed\n");
return NULL;
}
s = qemu_mallocz(sizeof(MSDState));
bdrv = bdrv_new("usb");
if (bdrv_open2(bdrv, filename, 0, drv) < 0)
goto fail;
s->bs = bdrv;
*pbs = bdrv;
s->dev.speed = USB_SPEED_FULL;
s->dev.handle_packet = usb_generic_handle_packet;
s->dev.handle_reset = usb_msd_handle_reset;
s->dev.handle_control = usb_msd_handle_control;
s->dev.handle_data = usb_msd_handle_data;
s->dev.handle_destroy = usb_msd_handle_destroy;
snprintf(s->dev.devname, sizeof(s->dev.devname), "QEMU USB MSD(%.16s)",
filename);
s->scsi_dev = scsi_disk_init(bdrv, 0, usb_msd_command_complete, s);
usb_msd_handle_reset((USBDevice *)s);
return (USBDevice *)s;
fail:
qemu_free(s);
return NULL;
}
| {
"code": [],
"line_no": []
} | USBDevice *FUNC_0(const char *filename, BlockDriverState **pbs)
{
MSDState *s;
BlockDriverState *bdrv;
BlockDriver *drv = NULL;
const char *VAR_0;
char VAR_1[32];
VAR_0 = strchr(filename, ':');
if (VAR_0++) {
const char *VAR_2;
if (strstart(filename, "format=", &VAR_2)) {
int VAR_3 = MIN(VAR_0 - VAR_2, sizeof(VAR_1));
pstrcpy(VAR_1, VAR_3, VAR_2);
drv = bdrv_find_format(VAR_1);
if (!drv) {
printf("invalid format %s\n", VAR_1);
return NULL;
}
} else if (*filename != ':') {
printf("unrecognized USB mass-storage option %s\n", filename);
return NULL;
}
filename = VAR_0;
}
if (!*filename) {
printf("block device specification needed\n");
return NULL;
}
s = qemu_mallocz(sizeof(MSDState));
bdrv = bdrv_new("usb");
if (bdrv_open2(bdrv, filename, 0, drv) < 0)
goto fail;
s->bs = bdrv;
*pbs = bdrv;
s->dev.speed = USB_SPEED_FULL;
s->dev.handle_packet = usb_generic_handle_packet;
s->dev.handle_reset = usb_msd_handle_reset;
s->dev.handle_control = usb_msd_handle_control;
s->dev.handle_data = usb_msd_handle_data;
s->dev.handle_destroy = usb_msd_handle_destroy;
snprintf(s->dev.devname, sizeof(s->dev.devname), "QEMU USB MSD(%.16s)",
filename);
s->scsi_dev = scsi_disk_init(bdrv, 0, usb_msd_command_complete, s);
usb_msd_handle_reset((USBDevice *)s);
return (USBDevice *)s;
fail:
qemu_free(s);
return NULL;
}
| [
"USBDevice *FUNC_0(const char *filename, BlockDriverState **pbs)\n{",
"MSDState *s;",
"BlockDriverState *bdrv;",
"BlockDriver *drv = NULL;",
"const char *VAR_0;",
"char VAR_1[32];",
"VAR_0 = strchr(filename, ':');",
"if (VAR_0++) {",
"const char *VAR_2;",
"if (strstart(filename, \"format=\", &VAR_2)) {",
"int VAR_3 = MIN(VAR_0 - VAR_2, sizeof(VAR_1));",
"pstrcpy(VAR_1, VAR_3, VAR_2);",
"drv = bdrv_find_format(VAR_1);",
"if (!drv) {",
"printf(\"invalid format %s\\n\", VAR_1);",
"return NULL;",
"}",
"} else if (*filename != ':') {",
"printf(\"unrecognized USB mass-storage option %s\\n\", filename);",
"return NULL;",
"}",
"filename = VAR_0;",
"}",
"if (!*filename) {",
"printf(\"block device specification needed\\n\");",
"return NULL;",
"}",
"s = qemu_mallocz(sizeof(MSDState));",
"bdrv = bdrv_new(\"usb\");",
"if (bdrv_open2(bdrv, filename, 0, drv) < 0)\ngoto fail;",
"s->bs = bdrv;",
"*pbs = bdrv;",
"s->dev.speed = USB_SPEED_FULL;",
"s->dev.handle_packet = usb_generic_handle_packet;",
"s->dev.handle_reset = usb_msd_handle_reset;",
"s->dev.handle_control = usb_msd_handle_control;",
"s->dev.handle_data = usb_msd_handle_data;",
"s->dev.handle_destroy = usb_msd_handle_destroy;",
"snprintf(s->dev.devname, sizeof(s->dev.devname), \"QEMU USB MSD(%.16s)\",\nfilename);",
"s->scsi_dev = scsi_disk_init(bdrv, 0, usb_msd_command_complete, s);",
"usb_msd_handle_reset((USBDevice *)s);",
"return (USBDevice *)s;",
"fail:\nqemu_free(s);",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101,
103
],
[
107
],
[
109
],
[
111
],
[
113,
115
],
[
117
],
[
119
]
] |
26,025 | static int buffered_rate_limit(void *opaque)
{
QEMUFileBuffered *s = opaque;
int ret;
ret = qemu_file_get_error(s->file);
if (ret) {
return ret;
}
if (s->bytes_xfer > s->xfer_limit)
return 1;
return 0;
}
| false | qemu | 0d82d0e8b98cf0ea03a45f8542d835ebd3a84cd3 | static int buffered_rate_limit(void *opaque)
{
QEMUFileBuffered *s = opaque;
int ret;
ret = qemu_file_get_error(s->file);
if (ret) {
return ret;
}
if (s->bytes_xfer > s->xfer_limit)
return 1;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(void *VAR_0)
{
QEMUFileBuffered *s = VAR_0;
int VAR_1;
VAR_1 = qemu_file_get_error(s->file);
if (VAR_1) {
return VAR_1;
}
if (s->bytes_xfer > s->xfer_limit)
return 1;
return 0;
}
| [
"static int FUNC_0(void *VAR_0)\n{",
"QEMUFileBuffered *s = VAR_0;",
"int VAR_1;",
"VAR_1 = qemu_file_get_error(s->file);",
"if (VAR_1) {",
"return VAR_1;",
"}",
"if (s->bytes_xfer > s->xfer_limit)\nreturn 1;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21,
23
],
[
27
],
[
29
]
] |
26,026 | static int alloc_refcount_block(BlockDriverState *bs,
int64_t cluster_index, void **refcount_block)
{
BDRVQcowState *s = bs->opaque;
unsigned int refcount_table_index;
int ret;
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC);
/* Find the refcount block for the given cluster */
refcount_table_index = cluster_index >> s->refcount_block_bits;
if (refcount_table_index < s->refcount_table_size) {
uint64_t refcount_block_offset =
s->refcount_table[refcount_table_index] & REFT_OFFSET_MASK;
/* If it's already there, we're done */
if (refcount_block_offset) {
if (offset_into_cluster(s, refcount_block_offset)) {
qcow2_signal_corruption(bs, true, -1, -1, "Refblock offset %#"
PRIx64 " unaligned (reftable index: "
"%#x)", refcount_block_offset,
refcount_table_index);
return -EIO;
}
return load_refcount_block(bs, refcount_block_offset,
refcount_block);
}
}
/*
* If we came here, we need to allocate something. Something is at least
* a cluster for the new refcount block. It may also include a new refcount
* table if the old refcount table is too small.
*
* Note that allocating clusters here needs some special care:
*
* - We can't use the normal qcow2_alloc_clusters(), it would try to
* increase the refcount and very likely we would end up with an endless
* recursion. Instead we must place the refcount blocks in a way that
* they can describe them themselves.
*
* - We need to consider that at this point we are inside update_refcounts
* and potentially doing an initial refcount increase. This means that
* some clusters have already been allocated by the caller, but their
* refcount isn't accurate yet. If we allocate clusters for metadata, we
* need to return -EAGAIN to signal the caller that it needs to restart
* the search for free clusters.
*
* - alloc_clusters_noref and qcow2_free_clusters may load a different
* refcount block into the cache
*/
*refcount_block = NULL;
/* We write to the refcount table, so we might depend on L2 tables */
ret = qcow2_cache_flush(bs, s->l2_table_cache);
if (ret < 0) {
return ret;
}
/* Allocate the refcount block itself and mark it as used */
int64_t new_block = alloc_clusters_noref(bs, s->cluster_size);
if (new_block < 0) {
return new_block;
}
#ifdef DEBUG_ALLOC2
fprintf(stderr, "qcow2: Allocate refcount block %d for %" PRIx64
" at %" PRIx64 "\n",
refcount_table_index, cluster_index << s->cluster_bits, new_block);
#endif
if (in_same_refcount_block(s, new_block, cluster_index << s->cluster_bits)) {
/* Zero the new refcount block before updating it */
ret = qcow2_cache_get_empty(bs, s->refcount_block_cache, new_block,
refcount_block);
if (ret < 0) {
goto fail_block;
}
memset(*refcount_block, 0, s->cluster_size);
/* The block describes itself, need to update the cache */
int block_index = (new_block >> s->cluster_bits) &
(s->refcount_block_size - 1);
s->set_refcount(*refcount_block, block_index, 1);
} else {
/* Described somewhere else. This can recurse at most twice before we
* arrive at a block that describes itself. */
ret = update_refcount(bs, new_block, s->cluster_size, 1, false,
QCOW2_DISCARD_NEVER);
if (ret < 0) {
goto fail_block;
}
ret = qcow2_cache_flush(bs, s->refcount_block_cache);
if (ret < 0) {
goto fail_block;
}
/* Initialize the new refcount block only after updating its refcount,
* update_refcount uses the refcount cache itself */
ret = qcow2_cache_get_empty(bs, s->refcount_block_cache, new_block,
refcount_block);
if (ret < 0) {
goto fail_block;
}
memset(*refcount_block, 0, s->cluster_size);
}
/* Now the new refcount block needs to be written to disk */
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE);
qcow2_cache_entry_mark_dirty(bs, s->refcount_block_cache, *refcount_block);
ret = qcow2_cache_flush(bs, s->refcount_block_cache);
if (ret < 0) {
goto fail_block;
}
/* If the refcount table is big enough, just hook the block up there */
if (refcount_table_index < s->refcount_table_size) {
uint64_t data64 = cpu_to_be64(new_block);
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_HOOKUP);
ret = bdrv_pwrite_sync(bs->file,
s->refcount_table_offset + refcount_table_index * sizeof(uint64_t),
&data64, sizeof(data64));
if (ret < 0) {
goto fail_block;
}
s->refcount_table[refcount_table_index] = new_block;
/* The new refcount block may be where the caller intended to put its
* data, so let it restart the search. */
return -EAGAIN;
}
ret = qcow2_cache_put(bs, s->refcount_block_cache, refcount_block);
if (ret < 0) {
goto fail_block;
}
/*
* If we come here, we need to grow the refcount table. Again, a new
* refcount table needs some space and we can't simply allocate to avoid
* endless recursion.
*
* Therefore let's grab new refcount blocks at the end of the image, which
* will describe themselves and the new refcount table. This way we can
* reference them only in the new table and do the switch to the new
* refcount table at once without producing an inconsistent state in
* between.
*/
BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_GROW);
/* Calculate the number of refcount blocks needed so far; this will be the
* basis for calculating the index of the first cluster used for the
* self-describing refcount structures which we are about to create.
*
* Because we reached this point, there cannot be any refcount entries for
* cluster_index or higher indices yet. However, because new_block has been
* allocated to describe that cluster (and it will assume this role later
* on), we cannot use that index; also, new_block may actually have a higher
* cluster index than cluster_index, so it needs to be taken into account
* here (and 1 needs to be added to its value because that cluster is used).
*/
uint64_t blocks_used = DIV_ROUND_UP(MAX(cluster_index + 1,
(new_block >> s->cluster_bits) + 1),
s->refcount_block_size);
if (blocks_used > QCOW_MAX_REFTABLE_SIZE / sizeof(uint64_t)) {
return -EFBIG;
}
/* And now we need at least one block more for the new metadata */
uint64_t table_size = next_refcount_table_size(s, blocks_used + 1);
uint64_t last_table_size;
uint64_t blocks_clusters;
do {
uint64_t table_clusters =
size_to_clusters(s, table_size * sizeof(uint64_t));
blocks_clusters = 1 +
((table_clusters + s->refcount_block_size - 1)
/ s->refcount_block_size);
uint64_t meta_clusters = table_clusters + blocks_clusters;
last_table_size = table_size;
table_size = next_refcount_table_size(s, blocks_used +
((meta_clusters + s->refcount_block_size - 1)
/ s->refcount_block_size));
} while (last_table_size != table_size);
#ifdef DEBUG_ALLOC2
fprintf(stderr, "qcow2: Grow refcount table %" PRId32 " => %" PRId64 "\n",
s->refcount_table_size, table_size);
#endif
/* Create the new refcount table and blocks */
uint64_t meta_offset = (blocks_used * s->refcount_block_size) *
s->cluster_size;
uint64_t table_offset = meta_offset + blocks_clusters * s->cluster_size;
uint64_t *new_table = g_try_new0(uint64_t, table_size);
void *new_blocks = g_try_malloc0(blocks_clusters * s->cluster_size);
assert(table_size > 0 && blocks_clusters > 0);
if (new_table == NULL || new_blocks == NULL) {
ret = -ENOMEM;
goto fail_table;
}
/* Fill the new refcount table */
memcpy(new_table, s->refcount_table,
s->refcount_table_size * sizeof(uint64_t));
new_table[refcount_table_index] = new_block;
int i;
for (i = 0; i < blocks_clusters; i++) {
new_table[blocks_used + i] = meta_offset + (i * s->cluster_size);
}
/* Fill the refcount blocks */
uint64_t table_clusters = size_to_clusters(s, table_size * sizeof(uint64_t));
int block = 0;
for (i = 0; i < table_clusters + blocks_clusters; i++) {
s->set_refcount(new_blocks, block++, 1);
}
/* Write refcount blocks to disk */
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_BLOCKS);
ret = bdrv_pwrite_sync(bs->file, meta_offset, new_blocks,
blocks_clusters * s->cluster_size);
g_free(new_blocks);
new_blocks = NULL;
if (ret < 0) {
goto fail_table;
}
/* Write refcount table to disk */
for(i = 0; i < table_size; i++) {
cpu_to_be64s(&new_table[i]);
}
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_TABLE);
ret = bdrv_pwrite_sync(bs->file, table_offset, new_table,
table_size * sizeof(uint64_t));
if (ret < 0) {
goto fail_table;
}
for(i = 0; i < table_size; i++) {
be64_to_cpus(&new_table[i]);
}
/* Hook up the new refcount table in the qcow2 header */
uint8_t data[12];
cpu_to_be64w((uint64_t*)data, table_offset);
cpu_to_be32w((uint32_t*)(data + 8), table_clusters);
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE);
ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, refcount_table_offset),
data, sizeof(data));
if (ret < 0) {
goto fail_table;
}
/* And switch it in memory */
uint64_t old_table_offset = s->refcount_table_offset;
uint64_t old_table_size = s->refcount_table_size;
g_free(s->refcount_table);
s->refcount_table = new_table;
s->refcount_table_size = table_size;
s->refcount_table_offset = table_offset;
/* Free old table. */
qcow2_free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t),
QCOW2_DISCARD_OTHER);
ret = load_refcount_block(bs, new_block, refcount_block);
if (ret < 0) {
return ret;
}
/* If we were trying to do the initial refcount update for some cluster
* allocation, we might have used the same clusters to store newly
* allocated metadata. Make the caller search some new space. */
return -EAGAIN;
fail_table:
g_free(new_blocks);
g_free(new_table);
fail_block:
if (*refcount_block != NULL) {
qcow2_cache_put(bs, s->refcount_block_cache, refcount_block);
}
return ret;
}
| false | qemu | a3f1afb43a09e4577571c044c48f2ba9e6e4ad06 | static int alloc_refcount_block(BlockDriverState *bs,
int64_t cluster_index, void **refcount_block)
{
BDRVQcowState *s = bs->opaque;
unsigned int refcount_table_index;
int ret;
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC);
refcount_table_index = cluster_index >> s->refcount_block_bits;
if (refcount_table_index < s->refcount_table_size) {
uint64_t refcount_block_offset =
s->refcount_table[refcount_table_index] & REFT_OFFSET_MASK;
if (refcount_block_offset) {
if (offset_into_cluster(s, refcount_block_offset)) {
qcow2_signal_corruption(bs, true, -1, -1, "Refblock offset %#"
PRIx64 " unaligned (reftable index: "
"%#x)", refcount_block_offset,
refcount_table_index);
return -EIO;
}
return load_refcount_block(bs, refcount_block_offset,
refcount_block);
}
}
*refcount_block = NULL;
ret = qcow2_cache_flush(bs, s->l2_table_cache);
if (ret < 0) {
return ret;
}
int64_t new_block = alloc_clusters_noref(bs, s->cluster_size);
if (new_block < 0) {
return new_block;
}
#ifdef DEBUG_ALLOC2
fprintf(stderr, "qcow2: Allocate refcount block %d for %" PRIx64
" at %" PRIx64 "\n",
refcount_table_index, cluster_index << s->cluster_bits, new_block);
#endif
if (in_same_refcount_block(s, new_block, cluster_index << s->cluster_bits)) {
ret = qcow2_cache_get_empty(bs, s->refcount_block_cache, new_block,
refcount_block);
if (ret < 0) {
goto fail_block;
}
memset(*refcount_block, 0, s->cluster_size);
int block_index = (new_block >> s->cluster_bits) &
(s->refcount_block_size - 1);
s->set_refcount(*refcount_block, block_index, 1);
} else {
ret = update_refcount(bs, new_block, s->cluster_size, 1, false,
QCOW2_DISCARD_NEVER);
if (ret < 0) {
goto fail_block;
}
ret = qcow2_cache_flush(bs, s->refcount_block_cache);
if (ret < 0) {
goto fail_block;
}
ret = qcow2_cache_get_empty(bs, s->refcount_block_cache, new_block,
refcount_block);
if (ret < 0) {
goto fail_block;
}
memset(*refcount_block, 0, s->cluster_size);
}
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE);
qcow2_cache_entry_mark_dirty(bs, s->refcount_block_cache, *refcount_block);
ret = qcow2_cache_flush(bs, s->refcount_block_cache);
if (ret < 0) {
goto fail_block;
}
if (refcount_table_index < s->refcount_table_size) {
uint64_t data64 = cpu_to_be64(new_block);
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_HOOKUP);
ret = bdrv_pwrite_sync(bs->file,
s->refcount_table_offset + refcount_table_index * sizeof(uint64_t),
&data64, sizeof(data64));
if (ret < 0) {
goto fail_block;
}
s->refcount_table[refcount_table_index] = new_block;
return -EAGAIN;
}
ret = qcow2_cache_put(bs, s->refcount_block_cache, refcount_block);
if (ret < 0) {
goto fail_block;
}
BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_GROW);
uint64_t blocks_used = DIV_ROUND_UP(MAX(cluster_index + 1,
(new_block >> s->cluster_bits) + 1),
s->refcount_block_size);
if (blocks_used > QCOW_MAX_REFTABLE_SIZE / sizeof(uint64_t)) {
return -EFBIG;
}
uint64_t table_size = next_refcount_table_size(s, blocks_used + 1);
uint64_t last_table_size;
uint64_t blocks_clusters;
do {
uint64_t table_clusters =
size_to_clusters(s, table_size * sizeof(uint64_t));
blocks_clusters = 1 +
((table_clusters + s->refcount_block_size - 1)
/ s->refcount_block_size);
uint64_t meta_clusters = table_clusters + blocks_clusters;
last_table_size = table_size;
table_size = next_refcount_table_size(s, blocks_used +
((meta_clusters + s->refcount_block_size - 1)
/ s->refcount_block_size));
} while (last_table_size != table_size);
#ifdef DEBUG_ALLOC2
fprintf(stderr, "qcow2: Grow refcount table %" PRId32 " => %" PRId64 "\n",
s->refcount_table_size, table_size);
#endif
uint64_t meta_offset = (blocks_used * s->refcount_block_size) *
s->cluster_size;
uint64_t table_offset = meta_offset + blocks_clusters * s->cluster_size;
uint64_t *new_table = g_try_new0(uint64_t, table_size);
void *new_blocks = g_try_malloc0(blocks_clusters * s->cluster_size);
assert(table_size > 0 && blocks_clusters > 0);
if (new_table == NULL || new_blocks == NULL) {
ret = -ENOMEM;
goto fail_table;
}
memcpy(new_table, s->refcount_table,
s->refcount_table_size * sizeof(uint64_t));
new_table[refcount_table_index] = new_block;
int i;
for (i = 0; i < blocks_clusters; i++) {
new_table[blocks_used + i] = meta_offset + (i * s->cluster_size);
}
uint64_t table_clusters = size_to_clusters(s, table_size * sizeof(uint64_t));
int block = 0;
for (i = 0; i < table_clusters + blocks_clusters; i++) {
s->set_refcount(new_blocks, block++, 1);
}
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_BLOCKS);
ret = bdrv_pwrite_sync(bs->file, meta_offset, new_blocks,
blocks_clusters * s->cluster_size);
g_free(new_blocks);
new_blocks = NULL;
if (ret < 0) {
goto fail_table;
}
for(i = 0; i < table_size; i++) {
cpu_to_be64s(&new_table[i]);
}
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_TABLE);
ret = bdrv_pwrite_sync(bs->file, table_offset, new_table,
table_size * sizeof(uint64_t));
if (ret < 0) {
goto fail_table;
}
for(i = 0; i < table_size; i++) {
be64_to_cpus(&new_table[i]);
}
uint8_t data[12];
cpu_to_be64w((uint64_t*)data, table_offset);
cpu_to_be32w((uint32_t*)(data + 8), table_clusters);
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE);
ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, refcount_table_offset),
data, sizeof(data));
if (ret < 0) {
goto fail_table;
}
uint64_t old_table_offset = s->refcount_table_offset;
uint64_t old_table_size = s->refcount_table_size;
g_free(s->refcount_table);
s->refcount_table = new_table;
s->refcount_table_size = table_size;
s->refcount_table_offset = table_offset;
qcow2_free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t),
QCOW2_DISCARD_OTHER);
ret = load_refcount_block(bs, new_block, refcount_block);
if (ret < 0) {
return ret;
}
return -EAGAIN;
fail_table:
g_free(new_blocks);
g_free(new_table);
fail_block:
if (*refcount_block != NULL) {
qcow2_cache_put(bs, s->refcount_block_cache, refcount_block);
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0,
int64_t VAR_1, void **VAR_2)
{
BDRVQcowState *s = VAR_0->opaque;
unsigned int VAR_3;
int VAR_4;
BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_ALLOC);
VAR_3 = VAR_1 >> s->refcount_block_bits;
if (VAR_3 < s->refcount_table_size) {
uint64_t refcount_block_offset =
s->refcount_table[VAR_3] & REFT_OFFSET_MASK;
if (refcount_block_offset) {
if (offset_into_cluster(s, refcount_block_offset)) {
qcow2_signal_corruption(VAR_0, true, -1, -1, "Refblock offset %#"
PRIx64 " unaligned (reftable index: "
"%#x)", refcount_block_offset,
VAR_3);
return -EIO;
}
return load_refcount_block(VAR_0, refcount_block_offset,
VAR_2);
}
}
*VAR_2 = NULL;
VAR_4 = qcow2_cache_flush(VAR_0, s->l2_table_cache);
if (VAR_4 < 0) {
return VAR_4;
}
int64_t new_block = alloc_clusters_noref(VAR_0, s->cluster_size);
if (new_block < 0) {
return new_block;
}
#ifdef DEBUG_ALLOC2
fprintf(stderr, "qcow2: Allocate refcount VAR_8 %d for %" PRIx64
" at %" PRIx64 "\n",
VAR_3, VAR_1 << s->cluster_bits, new_block);
#endif
if (in_same_refcount_block(s, new_block, VAR_1 << s->cluster_bits)) {
VAR_4 = qcow2_cache_get_empty(VAR_0, s->refcount_block_cache, new_block,
VAR_2);
if (VAR_4 < 0) {
goto fail_block;
}
memset(*VAR_2, 0, s->cluster_size);
int VAR_5 = (new_block >> s->cluster_bits) &
(s->refcount_block_size - 1);
s->set_refcount(*VAR_2, VAR_5, 1);
} else {
VAR_4 = update_refcount(VAR_0, new_block, s->cluster_size, 1, false,
QCOW2_DISCARD_NEVER);
if (VAR_4 < 0) {
goto fail_block;
}
VAR_4 = qcow2_cache_flush(VAR_0, s->refcount_block_cache);
if (VAR_4 < 0) {
goto fail_block;
}
VAR_4 = qcow2_cache_get_empty(VAR_0, s->refcount_block_cache, new_block,
VAR_2);
if (VAR_4 < 0) {
goto fail_block;
}
memset(*VAR_2, 0, s->cluster_size);
}
BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_ALLOC_WRITE);
qcow2_cache_entry_mark_dirty(VAR_0, s->refcount_block_cache, *VAR_2);
VAR_4 = qcow2_cache_flush(VAR_0, s->refcount_block_cache);
if (VAR_4 < 0) {
goto fail_block;
}
if (VAR_3 < s->refcount_table_size) {
uint64_t data64 = cpu_to_be64(new_block);
BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_ALLOC_HOOKUP);
VAR_4 = bdrv_pwrite_sync(VAR_0->file,
s->refcount_table_offset + VAR_3 * sizeof(uint64_t),
&data64, sizeof(data64));
if (VAR_4 < 0) {
goto fail_block;
}
s->refcount_table[VAR_3] = new_block;
return -EAGAIN;
}
VAR_4 = qcow2_cache_put(VAR_0, s->refcount_block_cache, VAR_2);
if (VAR_4 < 0) {
goto fail_block;
}
BLKDBG_EVENT(VAR_0->file, BLKDBG_REFTABLE_GROW);
uint64_t blocks_used = DIV_ROUND_UP(MAX(VAR_1 + 1,
(new_block >> s->cluster_bits) + 1),
s->refcount_block_size);
if (blocks_used > QCOW_MAX_REFTABLE_SIZE / sizeof(uint64_t)) {
return -EFBIG;
}
uint64_t table_size = next_refcount_table_size(s, blocks_used + 1);
uint64_t last_table_size;
uint64_t blocks_clusters;
do {
uint64_t table_clusters =
size_to_clusters(s, table_size * sizeof(uint64_t));
blocks_clusters = 1 +
((table_clusters + s->refcount_block_size - 1)
/ s->refcount_block_size);
uint64_t meta_clusters = table_clusters + blocks_clusters;
last_table_size = table_size;
table_size = next_refcount_table_size(s, blocks_used +
((meta_clusters + s->refcount_block_size - 1)
/ s->refcount_block_size));
} while (last_table_size != table_size);
#ifdef DEBUG_ALLOC2
fprintf(stderr, "qcow2: Grow refcount table %" PRId32 " => %" PRId64 "\n",
s->refcount_table_size, table_size);
#endif
uint64_t meta_offset = (blocks_used * s->refcount_block_size) *
s->cluster_size;
uint64_t table_offset = meta_offset + blocks_clusters * s->cluster_size;
uint64_t *new_table = g_try_new0(uint64_t, table_size);
void *VAR_6 = g_try_malloc0(blocks_clusters * s->cluster_size);
assert(table_size > 0 && blocks_clusters > 0);
if (new_table == NULL || VAR_6 == NULL) {
VAR_4 = -ENOMEM;
goto fail_table;
}
memcpy(new_table, s->refcount_table,
s->refcount_table_size * sizeof(uint64_t));
new_table[VAR_3] = new_block;
int VAR_7;
for (VAR_7 = 0; VAR_7 < blocks_clusters; VAR_7++) {
new_table[blocks_used + VAR_7] = meta_offset + (VAR_7 * s->cluster_size);
}
uint64_t table_clusters = size_to_clusters(s, table_size * sizeof(uint64_t));
int VAR_8 = 0;
for (VAR_7 = 0; VAR_7 < table_clusters + blocks_clusters; VAR_7++) {
s->set_refcount(VAR_6, VAR_8++, 1);
}
BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_ALLOC_WRITE_BLOCKS);
VAR_4 = bdrv_pwrite_sync(VAR_0->file, meta_offset, VAR_6,
blocks_clusters * s->cluster_size);
g_free(VAR_6);
VAR_6 = NULL;
if (VAR_4 < 0) {
goto fail_table;
}
for(VAR_7 = 0; VAR_7 < table_size; VAR_7++) {
cpu_to_be64s(&new_table[VAR_7]);
}
BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_ALLOC_WRITE_TABLE);
VAR_4 = bdrv_pwrite_sync(VAR_0->file, table_offset, new_table,
table_size * sizeof(uint64_t));
if (VAR_4 < 0) {
goto fail_table;
}
for(VAR_7 = 0; VAR_7 < table_size; VAR_7++) {
be64_to_cpus(&new_table[VAR_7]);
}
uint8_t data[12];
cpu_to_be64w((uint64_t*)data, table_offset);
cpu_to_be32w((uint32_t*)(data + 8), table_clusters);
BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE);
VAR_4 = bdrv_pwrite_sync(VAR_0->file, offsetof(QCowHeader, refcount_table_offset),
data, sizeof(data));
if (VAR_4 < 0) {
goto fail_table;
}
uint64_t old_table_offset = s->refcount_table_offset;
uint64_t old_table_size = s->refcount_table_size;
g_free(s->refcount_table);
s->refcount_table = new_table;
s->refcount_table_size = table_size;
s->refcount_table_offset = table_offset;
qcow2_free_clusters(VAR_0, old_table_offset, old_table_size * sizeof(uint64_t),
QCOW2_DISCARD_OTHER);
VAR_4 = load_refcount_block(VAR_0, new_block, VAR_2);
if (VAR_4 < 0) {
return VAR_4;
}
return -EAGAIN;
fail_table:
g_free(VAR_6);
g_free(new_table);
fail_block:
if (*VAR_2 != NULL) {
qcow2_cache_put(VAR_0, s->refcount_block_cache, VAR_2);
}
return VAR_4;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0,\nint64_t VAR_1, void **VAR_2)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"unsigned int VAR_3;",
"int VAR_4;",
"BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_ALLOC);",
"VAR_3 = VAR_1 >> s->refcount_block_bits;",
"if (VAR_3 < s->refcount_table_size) {",
"uint64_t refcount_block_offset =\ns->refcount_table[VAR_3] & REFT_OFFSET_MASK;",
"if (refcount_block_offset) {",
"if (offset_into_cluster(s, refcount_block_offset)) {",
"qcow2_signal_corruption(VAR_0, true, -1, -1, \"Refblock offset %#\"\nPRIx64 \" unaligned (reftable index: \"\n\"%#x)\", refcount_block_offset,\nVAR_3);",
"return -EIO;",
"}",
"return load_refcount_block(VAR_0, refcount_block_offset,\nVAR_2);",
"}",
"}",
"*VAR_2 = NULL;",
"VAR_4 = qcow2_cache_flush(VAR_0, s->l2_table_cache);",
"if (VAR_4 < 0) {",
"return VAR_4;",
"}",
"int64_t new_block = alloc_clusters_noref(VAR_0, s->cluster_size);",
"if (new_block < 0) {",
"return new_block;",
"}",
"#ifdef DEBUG_ALLOC2\nfprintf(stderr, \"qcow2: Allocate refcount VAR_8 %d for %\" PRIx64\n\" at %\" PRIx64 \"\\n\",\nVAR_3, VAR_1 << s->cluster_bits, new_block);",
"#endif\nif (in_same_refcount_block(s, new_block, VAR_1 << s->cluster_bits)) {",
"VAR_4 = qcow2_cache_get_empty(VAR_0, s->refcount_block_cache, new_block,\nVAR_2);",
"if (VAR_4 < 0) {",
"goto fail_block;",
"}",
"memset(*VAR_2, 0, s->cluster_size);",
"int VAR_5 = (new_block >> s->cluster_bits) &\n(s->refcount_block_size - 1);",
"s->set_refcount(*VAR_2, VAR_5, 1);",
"} else {",
"VAR_4 = update_refcount(VAR_0, new_block, s->cluster_size, 1, false,\nQCOW2_DISCARD_NEVER);",
"if (VAR_4 < 0) {",
"goto fail_block;",
"}",
"VAR_4 = qcow2_cache_flush(VAR_0, s->refcount_block_cache);",
"if (VAR_4 < 0) {",
"goto fail_block;",
"}",
"VAR_4 = qcow2_cache_get_empty(VAR_0, s->refcount_block_cache, new_block,\nVAR_2);",
"if (VAR_4 < 0) {",
"goto fail_block;",
"}",
"memset(*VAR_2, 0, s->cluster_size);",
"}",
"BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_ALLOC_WRITE);",
"qcow2_cache_entry_mark_dirty(VAR_0, s->refcount_block_cache, *VAR_2);",
"VAR_4 = qcow2_cache_flush(VAR_0, s->refcount_block_cache);",
"if (VAR_4 < 0) {",
"goto fail_block;",
"}",
"if (VAR_3 < s->refcount_table_size) {",
"uint64_t data64 = cpu_to_be64(new_block);",
"BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_ALLOC_HOOKUP);",
"VAR_4 = bdrv_pwrite_sync(VAR_0->file,\ns->refcount_table_offset + VAR_3 * sizeof(uint64_t),\n&data64, sizeof(data64));",
"if (VAR_4 < 0) {",
"goto fail_block;",
"}",
"s->refcount_table[VAR_3] = new_block;",
"return -EAGAIN;",
"}",
"VAR_4 = qcow2_cache_put(VAR_0, s->refcount_block_cache, VAR_2);",
"if (VAR_4 < 0) {",
"goto fail_block;",
"}",
"BLKDBG_EVENT(VAR_0->file, BLKDBG_REFTABLE_GROW);",
"uint64_t blocks_used = DIV_ROUND_UP(MAX(VAR_1 + 1,\n(new_block >> s->cluster_bits) + 1),\ns->refcount_block_size);",
"if (blocks_used > QCOW_MAX_REFTABLE_SIZE / sizeof(uint64_t)) {",
"return -EFBIG;",
"}",
"uint64_t table_size = next_refcount_table_size(s, blocks_used + 1);",
"uint64_t last_table_size;",
"uint64_t blocks_clusters;",
"do {",
"uint64_t table_clusters =\nsize_to_clusters(s, table_size * sizeof(uint64_t));",
"blocks_clusters = 1 +\n((table_clusters + s->refcount_block_size - 1)\n/ s->refcount_block_size);",
"uint64_t meta_clusters = table_clusters + blocks_clusters;",
"last_table_size = table_size;",
"table_size = next_refcount_table_size(s, blocks_used +\n((meta_clusters + s->refcount_block_size - 1)\n/ s->refcount_block_size));",
"} while (last_table_size != table_size);",
"#ifdef DEBUG_ALLOC2\nfprintf(stderr, \"qcow2: Grow refcount table %\" PRId32 \" => %\" PRId64 \"\\n\",\ns->refcount_table_size, table_size);",
"#endif\nuint64_t meta_offset = (blocks_used * s->refcount_block_size) *\ns->cluster_size;",
"uint64_t table_offset = meta_offset + blocks_clusters * s->cluster_size;",
"uint64_t *new_table = g_try_new0(uint64_t, table_size);",
"void *VAR_6 = g_try_malloc0(blocks_clusters * s->cluster_size);",
"assert(table_size > 0 && blocks_clusters > 0);",
"if (new_table == NULL || VAR_6 == NULL) {",
"VAR_4 = -ENOMEM;",
"goto fail_table;",
"}",
"memcpy(new_table, s->refcount_table,\ns->refcount_table_size * sizeof(uint64_t));",
"new_table[VAR_3] = new_block;",
"int VAR_7;",
"for (VAR_7 = 0; VAR_7 < blocks_clusters; VAR_7++) {",
"new_table[blocks_used + VAR_7] = meta_offset + (VAR_7 * s->cluster_size);",
"}",
"uint64_t table_clusters = size_to_clusters(s, table_size * sizeof(uint64_t));",
"int VAR_8 = 0;",
"for (VAR_7 = 0; VAR_7 < table_clusters + blocks_clusters; VAR_7++) {",
"s->set_refcount(VAR_6, VAR_8++, 1);",
"}",
"BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_ALLOC_WRITE_BLOCKS);",
"VAR_4 = bdrv_pwrite_sync(VAR_0->file, meta_offset, VAR_6,\nblocks_clusters * s->cluster_size);",
"g_free(VAR_6);",
"VAR_6 = NULL;",
"if (VAR_4 < 0) {",
"goto fail_table;",
"}",
"for(VAR_7 = 0; VAR_7 < table_size; VAR_7++) {",
"cpu_to_be64s(&new_table[VAR_7]);",
"}",
"BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_ALLOC_WRITE_TABLE);",
"VAR_4 = bdrv_pwrite_sync(VAR_0->file, table_offset, new_table,\ntable_size * sizeof(uint64_t));",
"if (VAR_4 < 0) {",
"goto fail_table;",
"}",
"for(VAR_7 = 0; VAR_7 < table_size; VAR_7++) {",
"be64_to_cpus(&new_table[VAR_7]);",
"}",
"uint8_t data[12];",
"cpu_to_be64w((uint64_t*)data, table_offset);",
"cpu_to_be32w((uint32_t*)(data + 8), table_clusters);",
"BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE);",
"VAR_4 = bdrv_pwrite_sync(VAR_0->file, offsetof(QCowHeader, refcount_table_offset),\ndata, sizeof(data));",
"if (VAR_4 < 0) {",
"goto fail_table;",
"}",
"uint64_t old_table_offset = s->refcount_table_offset;",
"uint64_t old_table_size = s->refcount_table_size;",
"g_free(s->refcount_table);",
"s->refcount_table = new_table;",
"s->refcount_table_size = table_size;",
"s->refcount_table_offset = table_offset;",
"qcow2_free_clusters(VAR_0, old_table_offset, old_table_size * sizeof(uint64_t),\nQCOW2_DISCARD_OTHER);",
"VAR_4 = load_refcount_block(VAR_0, new_block, VAR_2);",
"if (VAR_4 < 0) {",
"return VAR_4;",
"}",
"return -EAGAIN;",
"fail_table:\ng_free(VAR_6);",
"g_free(new_table);",
"fail_block:\nif (*VAR_2 != NULL) {",
"qcow2_cache_put(VAR_0, s->refcount_block_cache, VAR_2);",
"}",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
21
],
[
25
],
[
29,
31
],
[
37
],
[
39
],
[
41,
43,
45,
47
],
[
49
],
[
51
],
[
55,
57
],
[
59
],
[
61
],
[
111
],
[
117
],
[
119
],
[
121
],
[
123
],
[
129
],
[
131
],
[
133
],
[
135
],
[
139,
141,
143,
145
],
[
147,
151
],
[
155,
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
173,
175
],
[
177
],
[
179
],
[
185,
187
],
[
189
],
[
191
],
[
193
],
[
197
],
[
199
],
[
201
],
[
203
],
[
211,
213
],
[
215
],
[
217
],
[
219
],
[
223
],
[
225
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
247
],
[
249
],
[
251
],
[
253,
255,
257
],
[
259
],
[
261
],
[
263
],
[
267
],
[
275
],
[
277
],
[
281
],
[
283
],
[
285
],
[
287
],
[
313
],
[
339,
341,
343
],
[
347
],
[
349
],
[
351
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365,
367
],
[
369,
371,
373
],
[
375
],
[
379
],
[
381,
383,
385
],
[
389
],
[
393,
395,
397
],
[
399,
405,
407
],
[
409
],
[
411
],
[
413
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
431,
433
],
[
435
],
[
439
],
[
441
],
[
443
],
[
445
],
[
451
],
[
453
],
[
455
],
[
457
],
[
459
],
[
465
],
[
467,
469
],
[
471
],
[
473
],
[
475
],
[
477
],
[
479
],
[
485
],
[
487
],
[
489
],
[
493
],
[
495,
497
],
[
499
],
[
501
],
[
503
],
[
507
],
[
509
],
[
511
],
[
517
],
[
519
],
[
521
],
[
523
],
[
525,
527
],
[
529
],
[
531
],
[
533
],
[
539
],
[
541
],
[
545
],
[
547
],
[
549
],
[
551
],
[
557,
559
],
[
563
],
[
565
],
[
567
],
[
569
],
[
579
],
[
583,
585
],
[
587
],
[
589,
591
],
[
593
],
[
595
],
[
597
],
[
599
]
] |
26,028 | static inline int vc1_pred_dc(MpegEncContext *s, int overlap, int pq, int n,
int a_avail, int c_avail,
int16_t **dc_val_ptr, int *dir_ptr)
{
int a, b, c, wrap, pred;
int16_t *dc_val;
int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
int q1, q2 = 0;
wrap = s->block_wrap[n];
dc_val = s->dc_val[0] + s->block_index[n];
/* B A
* C X
*/
c = dc_val[ - 1];
b = dc_val[ - 1 - wrap];
a = dc_val[ - wrap];
/* scale predictors if needed */
q1 = s->current_picture.f.qscale_table[mb_pos];
if (c_avail && (n != 1 && n != 3)) {
q2 = s->current_picture.f.qscale_table[mb_pos - 1];
if (q2 && q2 != q1)
c = (c * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18;
}
if (a_avail && (n != 2 && n != 3)) {
q2 = s->current_picture.f.qscale_table[mb_pos - s->mb_stride];
if (q2 && q2 != q1)
a = (a * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18;
}
if (a_avail && c_avail && (n != 3)) {
int off = mb_pos;
if (n != 1)
off--;
if (n != 2)
off -= s->mb_stride;
q2 = s->current_picture.f.qscale_table[off];
if (q2 && q2 != q1)
b = (b * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18;
}
if (a_avail && c_avail) {
if (abs(a - b) <= abs(b - c)) {
pred = c;
*dir_ptr = 1; // left
} else {
pred = a;
*dir_ptr = 0; // top
}
} else if (a_avail) {
pred = a;
*dir_ptr = 0; // top
} else if (c_avail) {
pred = c;
*dir_ptr = 1; // left
} else {
pred = 0;
*dir_ptr = 1; // left
}
/* update predictor */
*dc_val_ptr = &dc_val[0];
return pred;
}
| false | FFmpeg | 95b192de5d05f3e1542e7b2378cdefbc195f5185 | static inline int vc1_pred_dc(MpegEncContext *s, int overlap, int pq, int n,
int a_avail, int c_avail,
int16_t **dc_val_ptr, int *dir_ptr)
{
int a, b, c, wrap, pred;
int16_t *dc_val;
int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
int q1, q2 = 0;
wrap = s->block_wrap[n];
dc_val = s->dc_val[0] + s->block_index[n];
c = dc_val[ - 1];
b = dc_val[ - 1 - wrap];
a = dc_val[ - wrap];
q1 = s->current_picture.f.qscale_table[mb_pos];
if (c_avail && (n != 1 && n != 3)) {
q2 = s->current_picture.f.qscale_table[mb_pos - 1];
if (q2 && q2 != q1)
c = (c * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18;
}
if (a_avail && (n != 2 && n != 3)) {
q2 = s->current_picture.f.qscale_table[mb_pos - s->mb_stride];
if (q2 && q2 != q1)
a = (a * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18;
}
if (a_avail && c_avail && (n != 3)) {
int off = mb_pos;
if (n != 1)
off--;
if (n != 2)
off -= s->mb_stride;
q2 = s->current_picture.f.qscale_table[off];
if (q2 && q2 != q1)
b = (b * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18;
}
if (a_avail && c_avail) {
if (abs(a - b) <= abs(b - c)) {
pred = c;
*dir_ptr = 1;
} else {
pred = a;
*dir_ptr = 0;
}
} else if (a_avail) {
pred = a;
*dir_ptr = 0;
} else if (c_avail) {
pred = c;
*dir_ptr = 1;
} else {
pred = 0;
*dir_ptr = 1;
}
*dc_val_ptr = &dc_val[0];
return pred;
}
| {
"code": [],
"line_no": []
} | static inline int FUNC_0(MpegEncContext *VAR_0, int VAR_1, int VAR_2, int VAR_3,
int VAR_4, int VAR_5,
int16_t **VAR_6, int *VAR_7)
{
int VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;
int16_t *dc_val;
int VAR_13 = VAR_0->mb_x + VAR_0->mb_y * VAR_0->mb_stride;
int VAR_14, VAR_15 = 0;
VAR_11 = VAR_0->block_wrap[VAR_3];
dc_val = VAR_0->dc_val[0] + VAR_0->block_index[VAR_3];
VAR_10 = dc_val[ - 1];
VAR_9 = dc_val[ - 1 - VAR_11];
VAR_8 = dc_val[ - VAR_11];
VAR_14 = VAR_0->current_picture.f.qscale_table[VAR_13];
if (VAR_5 && (VAR_3 != 1 && VAR_3 != 3)) {
VAR_15 = VAR_0->current_picture.f.qscale_table[VAR_13 - 1];
if (VAR_15 && VAR_15 != VAR_14)
VAR_10 = (VAR_10 * VAR_0->y_dc_scale_table[VAR_15] * ff_vc1_dqscale[VAR_0->y_dc_scale_table[VAR_14] - 1] + 0x20000) >> 18;
}
if (VAR_4 && (VAR_3 != 2 && VAR_3 != 3)) {
VAR_15 = VAR_0->current_picture.f.qscale_table[VAR_13 - VAR_0->mb_stride];
if (VAR_15 && VAR_15 != VAR_14)
VAR_8 = (VAR_8 * VAR_0->y_dc_scale_table[VAR_15] * ff_vc1_dqscale[VAR_0->y_dc_scale_table[VAR_14] - 1] + 0x20000) >> 18;
}
if (VAR_4 && VAR_5 && (VAR_3 != 3)) {
int VAR_16 = VAR_13;
if (VAR_3 != 1)
VAR_16--;
if (VAR_3 != 2)
VAR_16 -= VAR_0->mb_stride;
VAR_15 = VAR_0->current_picture.f.qscale_table[VAR_16];
if (VAR_15 && VAR_15 != VAR_14)
VAR_9 = (VAR_9 * VAR_0->y_dc_scale_table[VAR_15] * ff_vc1_dqscale[VAR_0->y_dc_scale_table[VAR_14] - 1] + 0x20000) >> 18;
}
if (VAR_4 && VAR_5) {
if (abs(VAR_8 - VAR_9) <= abs(VAR_9 - VAR_10)) {
VAR_12 = VAR_10;
*VAR_7 = 1;
} else {
VAR_12 = VAR_8;
*VAR_7 = 0;
}
} else if (VAR_4) {
VAR_12 = VAR_8;
*VAR_7 = 0;
} else if (VAR_5) {
VAR_12 = VAR_10;
*VAR_7 = 1;
} else {
VAR_12 = 0;
*VAR_7 = 1;
}
*VAR_6 = &dc_val[0];
return VAR_12;
}
| [
"static inline int FUNC_0(MpegEncContext *VAR_0, int VAR_1, int VAR_2, int VAR_3,\nint VAR_4, int VAR_5,\nint16_t **VAR_6, int *VAR_7)\n{",
"int VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;",
"int16_t *dc_val;",
"int VAR_13 = VAR_0->mb_x + VAR_0->mb_y * VAR_0->mb_stride;",
"int VAR_14, VAR_15 = 0;",
"VAR_11 = VAR_0->block_wrap[VAR_3];",
"dc_val = VAR_0->dc_val[0] + VAR_0->block_index[VAR_3];",
"VAR_10 = dc_val[ - 1];",
"VAR_9 = dc_val[ - 1 - VAR_11];",
"VAR_8 = dc_val[ - VAR_11];",
"VAR_14 = VAR_0->current_picture.f.qscale_table[VAR_13];",
"if (VAR_5 && (VAR_3 != 1 && VAR_3 != 3)) {",
"VAR_15 = VAR_0->current_picture.f.qscale_table[VAR_13 - 1];",
"if (VAR_15 && VAR_15 != VAR_14)\nVAR_10 = (VAR_10 * VAR_0->y_dc_scale_table[VAR_15] * ff_vc1_dqscale[VAR_0->y_dc_scale_table[VAR_14] - 1] + 0x20000) >> 18;",
"}",
"if (VAR_4 && (VAR_3 != 2 && VAR_3 != 3)) {",
"VAR_15 = VAR_0->current_picture.f.qscale_table[VAR_13 - VAR_0->mb_stride];",
"if (VAR_15 && VAR_15 != VAR_14)\nVAR_8 = (VAR_8 * VAR_0->y_dc_scale_table[VAR_15] * ff_vc1_dqscale[VAR_0->y_dc_scale_table[VAR_14] - 1] + 0x20000) >> 18;",
"}",
"if (VAR_4 && VAR_5 && (VAR_3 != 3)) {",
"int VAR_16 = VAR_13;",
"if (VAR_3 != 1)\nVAR_16--;",
"if (VAR_3 != 2)\nVAR_16 -= VAR_0->mb_stride;",
"VAR_15 = VAR_0->current_picture.f.qscale_table[VAR_16];",
"if (VAR_15 && VAR_15 != VAR_14)\nVAR_9 = (VAR_9 * VAR_0->y_dc_scale_table[VAR_15] * ff_vc1_dqscale[VAR_0->y_dc_scale_table[VAR_14] - 1] + 0x20000) >> 18;",
"}",
"if (VAR_4 && VAR_5) {",
"if (abs(VAR_8 - VAR_9) <= abs(VAR_9 - VAR_10)) {",
"VAR_12 = VAR_10;",
"*VAR_7 = 1;",
"} else {",
"VAR_12 = VAR_8;",
"*VAR_7 = 0;",
"}",
"} else if (VAR_4) {",
"VAR_12 = VAR_8;",
"*VAR_7 = 0;",
"} else if (VAR_5) {",
"VAR_12 = VAR_10;",
"*VAR_7 = 1;",
"} else {",
"VAR_12 = 0;",
"*VAR_7 = 1;",
"}",
"*VAR_6 = &dc_val[0];",
"return VAR_12;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69,
71
],
[
73
],
[
75,
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
123
],
[
125
],
[
127
]
] |
26,029 | static void external_snapshot_prepare(BlkTransactionState *common,
Error **errp)
{
BlockDriver *drv;
int flags, ret;
QDict *options = NULL;
Error *local_err = NULL;
bool has_device = false;
const char *device;
bool has_node_name = false;
const char *node_name;
bool has_snapshot_node_name = false;
const char *snapshot_node_name;
const char *new_image_file;
const char *format = "qcow2";
enum NewImageMode mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
ExternalSnapshotState *state =
DO_UPCAST(ExternalSnapshotState, common, common);
TransactionAction *action = common->action;
/* get parameters */
g_assert(action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC);
has_device = action->blockdev_snapshot_sync->has_device;
device = action->blockdev_snapshot_sync->device;
has_node_name = action->blockdev_snapshot_sync->has_node_name;
node_name = action->blockdev_snapshot_sync->node_name;
has_snapshot_node_name =
action->blockdev_snapshot_sync->has_snapshot_node_name;
snapshot_node_name = action->blockdev_snapshot_sync->snapshot_node_name;
new_image_file = action->blockdev_snapshot_sync->snapshot_file;
if (action->blockdev_snapshot_sync->has_format) {
format = action->blockdev_snapshot_sync->format;
}
if (action->blockdev_snapshot_sync->has_mode) {
mode = action->blockdev_snapshot_sync->mode;
}
/* start processing */
drv = bdrv_find_format(format);
if (!drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
return;
}
state->old_bs = bdrv_lookup_bs(has_device ? device : NULL,
has_node_name ? node_name : NULL,
&local_err);
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
return;
}
if (has_node_name && !has_snapshot_node_name) {
error_setg(errp, "New snapshot node name missing");
return;
}
if (has_snapshot_node_name && bdrv_find_node(snapshot_node_name)) {
error_setg(errp, "New snapshot node name already existing");
return;
}
if (!bdrv_is_inserted(state->old_bs)) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
return;
}
if (bdrv_in_use(state->old_bs)) {
error_set(errp, QERR_DEVICE_IN_USE, device);
return;
}
if (!bdrv_is_read_only(state->old_bs)) {
if (bdrv_flush(state->old_bs)) {
error_set(errp, QERR_IO_ERROR);
return;
}
}
if (!bdrv_is_first_non_filter(state->old_bs)) {
error_set(errp, QERR_FEATURE_DISABLED, "snapshot");
return;
}
flags = state->old_bs->open_flags;
/* create new image w/backing file */
if (mode != NEW_IMAGE_MODE_EXISTING) {
bdrv_img_create(new_image_file, format,
state->old_bs->filename,
state->old_bs->drv->format_name,
NULL, -1, flags, &local_err, false);
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
return;
}
}
if (has_snapshot_node_name) {
options = qdict_new();
qdict_put(options, "node-name",
qstring_from_str(snapshot_node_name));
}
/* We will manually add the backing_hd field to the bs later */
state->new_bs = bdrv_new("");
/* TODO Inherit bs->options or only take explicit options with an
* extended QMP command? */
ret = bdrv_open(state->new_bs, new_image_file, options,
flags | BDRV_O_NO_BACKING, drv, &local_err);
if (ret != 0) {
error_propagate(errp, local_err);
}
QDECREF(options);
}
| true | qemu | 57b6bdf37c64985cf02b8737c550d52759059c9d | static void external_snapshot_prepare(BlkTransactionState *common,
Error **errp)
{
BlockDriver *drv;
int flags, ret;
QDict *options = NULL;
Error *local_err = NULL;
bool has_device = false;
const char *device;
bool has_node_name = false;
const char *node_name;
bool has_snapshot_node_name = false;
const char *snapshot_node_name;
const char *new_image_file;
const char *format = "qcow2";
enum NewImageMode mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
ExternalSnapshotState *state =
DO_UPCAST(ExternalSnapshotState, common, common);
TransactionAction *action = common->action;
g_assert(action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC);
has_device = action->blockdev_snapshot_sync->has_device;
device = action->blockdev_snapshot_sync->device;
has_node_name = action->blockdev_snapshot_sync->has_node_name;
node_name = action->blockdev_snapshot_sync->node_name;
has_snapshot_node_name =
action->blockdev_snapshot_sync->has_snapshot_node_name;
snapshot_node_name = action->blockdev_snapshot_sync->snapshot_node_name;
new_image_file = action->blockdev_snapshot_sync->snapshot_file;
if (action->blockdev_snapshot_sync->has_format) {
format = action->blockdev_snapshot_sync->format;
}
if (action->blockdev_snapshot_sync->has_mode) {
mode = action->blockdev_snapshot_sync->mode;
}
drv = bdrv_find_format(format);
if (!drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
return;
}
state->old_bs = bdrv_lookup_bs(has_device ? device : NULL,
has_node_name ? node_name : NULL,
&local_err);
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
return;
}
if (has_node_name && !has_snapshot_node_name) {
error_setg(errp, "New snapshot node name missing");
return;
}
if (has_snapshot_node_name && bdrv_find_node(snapshot_node_name)) {
error_setg(errp, "New snapshot node name already existing");
return;
}
if (!bdrv_is_inserted(state->old_bs)) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
return;
}
if (bdrv_in_use(state->old_bs)) {
error_set(errp, QERR_DEVICE_IN_USE, device);
return;
}
if (!bdrv_is_read_only(state->old_bs)) {
if (bdrv_flush(state->old_bs)) {
error_set(errp, QERR_IO_ERROR);
return;
}
}
if (!bdrv_is_first_non_filter(state->old_bs)) {
error_set(errp, QERR_FEATURE_DISABLED, "snapshot");
return;
}
flags = state->old_bs->open_flags;
if (mode != NEW_IMAGE_MODE_EXISTING) {
bdrv_img_create(new_image_file, format,
state->old_bs->filename,
state->old_bs->drv->format_name,
NULL, -1, flags, &local_err, false);
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
return;
}
}
if (has_snapshot_node_name) {
options = qdict_new();
qdict_put(options, "node-name",
qstring_from_str(snapshot_node_name));
}
state->new_bs = bdrv_new("");
ret = bdrv_open(state->new_bs, new_image_file, options,
flags | BDRV_O_NO_BACKING, drv, &local_err);
if (ret != 0) {
error_propagate(errp, local_err);
}
QDECREF(options);
}
| {
"code": [
" QDECREF(options);"
],
"line_no": [
233
]
} | static void FUNC_0(BlkTransactionState *VAR_0,
Error **VAR_1)
{
BlockDriver *drv;
int VAR_2, VAR_3;
QDict *options = NULL;
Error *local_err = NULL;
bool has_device = false;
const char *VAR_4;
bool has_node_name = false;
const char *VAR_5;
bool has_snapshot_node_name = false;
const char *VAR_6;
const char *VAR_7;
const char *VAR_8 = "qcow2";
enum NewImageMode VAR_9 = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
ExternalSnapshotState *state =
DO_UPCAST(ExternalSnapshotState, VAR_0, VAR_0);
TransactionAction *action = VAR_0->action;
g_assert(action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC);
has_device = action->blockdev_snapshot_sync->has_device;
VAR_4 = action->blockdev_snapshot_sync->VAR_4;
has_node_name = action->blockdev_snapshot_sync->has_node_name;
VAR_5 = action->blockdev_snapshot_sync->VAR_5;
has_snapshot_node_name =
action->blockdev_snapshot_sync->has_snapshot_node_name;
VAR_6 = action->blockdev_snapshot_sync->VAR_6;
VAR_7 = action->blockdev_snapshot_sync->snapshot_file;
if (action->blockdev_snapshot_sync->has_format) {
VAR_8 = action->blockdev_snapshot_sync->VAR_8;
}
if (action->blockdev_snapshot_sync->has_mode) {
VAR_9 = action->blockdev_snapshot_sync->VAR_9;
}
drv = bdrv_find_format(VAR_8);
if (!drv) {
error_set(VAR_1, QERR_INVALID_BLOCK_FORMAT, VAR_8);
return;
}
state->old_bs = bdrv_lookup_bs(has_device ? VAR_4 : NULL,
has_node_name ? VAR_5 : NULL,
&local_err);
if (error_is_set(&local_err)) {
error_propagate(VAR_1, local_err);
return;
}
if (has_node_name && !has_snapshot_node_name) {
error_setg(VAR_1, "New snapshot node name missing");
return;
}
if (has_snapshot_node_name && bdrv_find_node(VAR_6)) {
error_setg(VAR_1, "New snapshot node name already existing");
return;
}
if (!bdrv_is_inserted(state->old_bs)) {
error_set(VAR_1, QERR_DEVICE_HAS_NO_MEDIUM, VAR_4);
return;
}
if (bdrv_in_use(state->old_bs)) {
error_set(VAR_1, QERR_DEVICE_IN_USE, VAR_4);
return;
}
if (!bdrv_is_read_only(state->old_bs)) {
if (bdrv_flush(state->old_bs)) {
error_set(VAR_1, QERR_IO_ERROR);
return;
}
}
if (!bdrv_is_first_non_filter(state->old_bs)) {
error_set(VAR_1, QERR_FEATURE_DISABLED, "snapshot");
return;
}
VAR_2 = state->old_bs->open_flags;
if (VAR_9 != NEW_IMAGE_MODE_EXISTING) {
bdrv_img_create(VAR_7, VAR_8,
state->old_bs->filename,
state->old_bs->drv->format_name,
NULL, -1, VAR_2, &local_err, false);
if (error_is_set(&local_err)) {
error_propagate(VAR_1, local_err);
return;
}
}
if (has_snapshot_node_name) {
options = qdict_new();
qdict_put(options, "node-name",
qstring_from_str(VAR_6));
}
state->new_bs = bdrv_new("");
VAR_3 = bdrv_open(state->new_bs, VAR_7, options,
VAR_2 | BDRV_O_NO_BACKING, drv, &local_err);
if (VAR_3 != 0) {
error_propagate(VAR_1, local_err);
}
QDECREF(options);
}
| [
"static void FUNC_0(BlkTransactionState *VAR_0,\nError **VAR_1)\n{",
"BlockDriver *drv;",
"int VAR_2, VAR_3;",
"QDict *options = NULL;",
"Error *local_err = NULL;",
"bool has_device = false;",
"const char *VAR_4;",
"bool has_node_name = false;",
"const char *VAR_5;",
"bool has_snapshot_node_name = false;",
"const char *VAR_6;",
"const char *VAR_7;",
"const char *VAR_8 = \"qcow2\";",
"enum NewImageMode VAR_9 = NEW_IMAGE_MODE_ABSOLUTE_PATHS;",
"ExternalSnapshotState *state =\nDO_UPCAST(ExternalSnapshotState, VAR_0, VAR_0);",
"TransactionAction *action = VAR_0->action;",
"g_assert(action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC);",
"has_device = action->blockdev_snapshot_sync->has_device;",
"VAR_4 = action->blockdev_snapshot_sync->VAR_4;",
"has_node_name = action->blockdev_snapshot_sync->has_node_name;",
"VAR_5 = action->blockdev_snapshot_sync->VAR_5;",
"has_snapshot_node_name =\naction->blockdev_snapshot_sync->has_snapshot_node_name;",
"VAR_6 = action->blockdev_snapshot_sync->VAR_6;",
"VAR_7 = action->blockdev_snapshot_sync->snapshot_file;",
"if (action->blockdev_snapshot_sync->has_format) {",
"VAR_8 = action->blockdev_snapshot_sync->VAR_8;",
"}",
"if (action->blockdev_snapshot_sync->has_mode) {",
"VAR_9 = action->blockdev_snapshot_sync->VAR_9;",
"}",
"drv = bdrv_find_format(VAR_8);",
"if (!drv) {",
"error_set(VAR_1, QERR_INVALID_BLOCK_FORMAT, VAR_8);",
"return;",
"}",
"state->old_bs = bdrv_lookup_bs(has_device ? VAR_4 : NULL,\nhas_node_name ? VAR_5 : NULL,\n&local_err);",
"if (error_is_set(&local_err)) {",
"error_propagate(VAR_1, local_err);",
"return;",
"}",
"if (has_node_name && !has_snapshot_node_name) {",
"error_setg(VAR_1, \"New snapshot node name missing\");",
"return;",
"}",
"if (has_snapshot_node_name && bdrv_find_node(VAR_6)) {",
"error_setg(VAR_1, \"New snapshot node name already existing\");",
"return;",
"}",
"if (!bdrv_is_inserted(state->old_bs)) {",
"error_set(VAR_1, QERR_DEVICE_HAS_NO_MEDIUM, VAR_4);",
"return;",
"}",
"if (bdrv_in_use(state->old_bs)) {",
"error_set(VAR_1, QERR_DEVICE_IN_USE, VAR_4);",
"return;",
"}",
"if (!bdrv_is_read_only(state->old_bs)) {",
"if (bdrv_flush(state->old_bs)) {",
"error_set(VAR_1, QERR_IO_ERROR);",
"return;",
"}",
"}",
"if (!bdrv_is_first_non_filter(state->old_bs)) {",
"error_set(VAR_1, QERR_FEATURE_DISABLED, \"snapshot\");",
"return;",
"}",
"VAR_2 = state->old_bs->open_flags;",
"if (VAR_9 != NEW_IMAGE_MODE_EXISTING) {",
"bdrv_img_create(VAR_7, VAR_8,\nstate->old_bs->filename,\nstate->old_bs->drv->format_name,\nNULL, -1, VAR_2, &local_err, false);",
"if (error_is_set(&local_err)) {",
"error_propagate(VAR_1, local_err);",
"return;",
"}",
"}",
"if (has_snapshot_node_name) {",
"options = qdict_new();",
"qdict_put(options, \"node-name\",\nqstring_from_str(VAR_6));",
"}",
"state->new_bs = bdrv_new(\"\");",
"VAR_3 = bdrv_open(state->new_bs, VAR_7, options,\nVAR_2 | BDRV_O_NO_BACKING, drv, &local_err);",
"if (VAR_3 != 0) {",
"error_propagate(VAR_1, local_err);",
"}",
"QDECREF(options);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93,
95,
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173
],
[
179
],
[
181,
183,
185,
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
201
],
[
203
],
[
205,
207
],
[
209
],
[
215
],
[
221,
223
],
[
225
],
[
227
],
[
229
],
[
233
],
[
235
]
] |
26,032 | int avio_get_str(AVIOContext *s, int maxlen, char *buf, int buflen)
{
int i;
// reserve 1 byte for terminating 0
buflen = FFMIN(buflen - 1, maxlen);
for (i = 0; i < buflen; i++)
if (!(buf[i] = avio_r8(s)))
return i + 1;
if (buflen)
buf[i] = 0;
for (; i < maxlen; i++)
if (!avio_r8(s))
return i + 1;
return maxlen;
}
| false | FFmpeg | ab2940691ba76e1a9b0ce608db0dfc45021d741e | int avio_get_str(AVIOContext *s, int maxlen, char *buf, int buflen)
{
int i;
buflen = FFMIN(buflen - 1, maxlen);
for (i = 0; i < buflen; i++)
if (!(buf[i] = avio_r8(s)))
return i + 1;
if (buflen)
buf[i] = 0;
for (; i < maxlen; i++)
if (!avio_r8(s))
return i + 1;
return maxlen;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVIOContext *VAR_0, int VAR_1, char *VAR_2, int VAR_3)
{
int VAR_4;
VAR_3 = FFMIN(VAR_3 - 1, VAR_1);
for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++)
if (!(VAR_2[VAR_4] = avio_r8(VAR_0)))
return VAR_4 + 1;
if (VAR_3)
VAR_2[VAR_4] = 0;
for (; VAR_4 < VAR_1; VAR_4++)
if (!avio_r8(VAR_0))
return VAR_4 + 1;
return VAR_1;
}
| [
"int FUNC_0(AVIOContext *VAR_0, int VAR_1, char *VAR_2, int VAR_3)\n{",
"int VAR_4;",
"VAR_3 = FFMIN(VAR_3 - 1, VAR_1);",
"for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++)",
"if (!(VAR_2[VAR_4] = avio_r8(VAR_0)))\nreturn VAR_4 + 1;",
"if (VAR_3)\nVAR_2[VAR_4] = 0;",
"for (; VAR_4 < VAR_1; VAR_4++)",
"if (!avio_r8(VAR_0))\nreturn VAR_4 + 1;",
"return VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
11
],
[
13
],
[
15,
17
],
[
19,
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
]
] |
26,033 | static int RENAME(swScale)(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[])
{
/* load a few things into local vars to make the code more readable? and faster */
const int srcW= c->srcW;
const int dstW= c->dstW;
const int dstH= c->dstH;
const int chrDstW= c->chrDstW;
const int chrSrcW= c->chrSrcW;
const int lumXInc= c->lumXInc;
const int chrXInc= c->chrXInc;
const enum PixelFormat dstFormat= c->dstFormat;
const int flags= c->flags;
int16_t *vLumFilterPos= c->vLumFilterPos;
int16_t *vChrFilterPos= c->vChrFilterPos;
int16_t *hLumFilterPos= c->hLumFilterPos;
int16_t *hChrFilterPos= c->hChrFilterPos;
int16_t *vLumFilter= c->vLumFilter;
int16_t *vChrFilter= c->vChrFilter;
int16_t *hLumFilter= c->hLumFilter;
int16_t *hChrFilter= c->hChrFilter;
int32_t *lumMmxFilter= c->lumMmxFilter;
int32_t *chrMmxFilter= c->chrMmxFilter;
int32_t av_unused *alpMmxFilter= c->alpMmxFilter;
const int vLumFilterSize= c->vLumFilterSize;
const int vChrFilterSize= c->vChrFilterSize;
const int hLumFilterSize= c->hLumFilterSize;
const int hChrFilterSize= c->hChrFilterSize;
int16_t **lumPixBuf= c->lumPixBuf;
int16_t **chrPixBuf= c->chrPixBuf;
int16_t **alpPixBuf= c->alpPixBuf;
const int vLumBufSize= c->vLumBufSize;
const int vChrBufSize= c->vChrBufSize;
uint8_t *formatConvBuffer= c->formatConvBuffer;
const int chrSrcSliceY= srcSliceY >> c->chrSrcVSubSample;
const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample);
int lastDstY;
uint32_t *pal=c->pal_yuv;
/* vars which will change and which we need to store back in the context */
int dstY= c->dstY;
int lumBufIndex= c->lumBufIndex;
int chrBufIndex= c->chrBufIndex;
int lastInLumBuf= c->lastInLumBuf;
int lastInChrBuf= c->lastInChrBuf;
if (isPacked(c->srcFormat)) {
src[0]=
src[1]=
src[2]=
src[3]= src[0];
srcStride[0]=
srcStride[1]=
srcStride[2]=
srcStride[3]= srcStride[0];
}
srcStride[1]<<= c->vChrDrop;
srcStride[2]<<= c->vChrDrop;
DEBUG_BUFFERS("swScale() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d] %p[%d] %p[%d] %p[%d]\n",
src[0], srcStride[0], src[1], srcStride[1], src[2], srcStride[2], src[3], srcStride[3],
dst[0], dstStride[0], dst[1], dstStride[1], dst[2], dstStride[2], dst[3], dstStride[3]);
DEBUG_BUFFERS("srcSliceY: %d srcSliceH: %d dstY: %d dstH: %d\n",
srcSliceY, srcSliceH, dstY, dstH);
DEBUG_BUFFERS("vLumFilterSize: %d vLumBufSize: %d vChrFilterSize: %d vChrBufSize: %d\n",
vLumFilterSize, vLumBufSize, vChrFilterSize, vChrBufSize);
if (dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0 || dstStride[3]%8 != 0) {
static int warnedAlready=0; //FIXME move this into the context perhaps
if (flags & SWS_PRINT_INFO && !warnedAlready) {
av_log(c, AV_LOG_WARNING, "Warning: dstStride is not aligned!\n"
" ->cannot do aligned memory accesses anymore\n");
warnedAlready=1;
}
}
/* Note the user might start scaling the picture in the middle so this
will not get executed. This is not really intended but works
currently, so people might do it. */
if (srcSliceY ==0) {
lumBufIndex=-1;
chrBufIndex=-1;
dstY=0;
lastInLumBuf= -1;
lastInChrBuf= -1;
}
lastDstY= dstY;
for (;dstY < dstH; dstY++) {
unsigned char *dest =dst[0]+dstStride[0]*dstY;
const int chrDstY= dstY>>c->chrDstVSubSample;
unsigned char *uDest=dst[1]+dstStride[1]*chrDstY;
unsigned char *vDest=dst[2]+dstStride[2]*chrDstY;
unsigned char *aDest=(CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3]+dstStride[3]*dstY : NULL;
const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input
const int firstLumSrcY2= vLumFilterPos[FFMIN(dstY | ((1<<c->chrDstVSubSample) - 1), dstH-1)];
const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as input
int lastLumSrcY= firstLumSrcY + vLumFilterSize -1; // Last line needed as input
int lastLumSrcY2=firstLumSrcY2+ vLumFilterSize -1; // Last line needed as input
int lastChrSrcY= firstChrSrcY + vChrFilterSize -1; // Last line needed as input
int enough_lines;
//handle holes (FAST_BILINEAR & weird filters)
if (firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1;
if (firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1;
assert(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1);
assert(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1);
DEBUG_BUFFERS("dstY: %d\n", dstY);
DEBUG_BUFFERS("\tfirstLumSrcY: %d lastLumSrcY: %d lastInLumBuf: %d\n",
firstLumSrcY, lastLumSrcY, lastInLumBuf);
DEBUG_BUFFERS("\tfirstChrSrcY: %d lastChrSrcY: %d lastInChrBuf: %d\n",
firstChrSrcY, lastChrSrcY, lastInChrBuf);
// Do we have enough lines in this slice to output the dstY line
enough_lines = lastLumSrcY2 < srcSliceY + srcSliceH && lastChrSrcY < -((-srcSliceY - srcSliceH)>>c->chrSrcVSubSample);
if (!enough_lines) {
lastLumSrcY = srcSliceY + srcSliceH - 1;
lastChrSrcY = chrSrcSliceY + chrSrcSliceH - 1;
DEBUG_BUFFERS("buffering slice: lastLumSrcY %d lastChrSrcY %d\n",
lastLumSrcY, lastChrSrcY);
}
//Do horizontal scaling
while(lastInLumBuf < lastLumSrcY) {
const uint8_t *src1= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0];
const uint8_t *src2= src[3]+(lastInLumBuf + 1 - srcSliceY)*srcStride[3];
lumBufIndex++;
assert(lumBufIndex < 2*vLumBufSize);
assert(lastInLumBuf + 1 - srcSliceY < srcSliceH);
assert(lastInLumBuf + 1 - srcSliceY >= 0);
RENAME(hyscale)(c, lumPixBuf[ lumBufIndex ], dstW, src1, srcW, lumXInc,
hLumFilter, hLumFilterPos, hLumFilterSize,
formatConvBuffer,
pal, 0);
if (CONFIG_SWSCALE_ALPHA && alpPixBuf)
RENAME(hyscale)(c, alpPixBuf[ lumBufIndex ], dstW, src2, srcW, lumXInc,
hLumFilter, hLumFilterPos, hLumFilterSize,
formatConvBuffer,
pal, 1);
lastInLumBuf++;
DEBUG_BUFFERS("\t\tlumBufIndex %d: lastInLumBuf: %d\n",
lumBufIndex, lastInLumBuf);
}
while(lastInChrBuf < lastChrSrcY) {
const uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[1];
const uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2];
chrBufIndex++;
assert(chrBufIndex < 2*vChrBufSize);
assert(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH));
assert(lastInChrBuf + 1 - chrSrcSliceY >= 0);
//FIXME replace parameters through context struct (some at least)
if (c->needs_hcscale)
RENAME(hcscale)(c, chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc,
hChrFilter, hChrFilterPos, hChrFilterSize,
formatConvBuffer,
pal);
lastInChrBuf++;
DEBUG_BUFFERS("\t\tchrBufIndex %d: lastInChrBuf: %d\n",
chrBufIndex, lastInChrBuf);
}
//wrap buf index around to stay inside the ring buffer
if (lumBufIndex >= vLumBufSize) lumBufIndex-= vLumBufSize;
if (chrBufIndex >= vChrBufSize) chrBufIndex-= vChrBufSize;
if (!enough_lines)
break; //we can't output a dstY line so let's try with the next slice
#if COMPILE_TEMPLATE_MMX
c->blueDither= ff_dither8[dstY&1];
if (c->dstFormat == PIX_FMT_RGB555 || c->dstFormat == PIX_FMT_BGR555)
c->greenDither= ff_dither8[dstY&1];
else
c->greenDither= ff_dither4[dstY&1];
c->redDither= ff_dither8[(dstY+1)&1];
#endif
if (dstY < dstH-2) {
const int16_t **lumSrcPtr= (const int16_t **) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
const int16_t **chrSrcPtr= (const int16_t **) chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
#if COMPILE_TEMPLATE_MMX
int i;
if (flags & SWS_ACCURATE_RND) {
int s= APCK_SIZE / 8;
for (i=0; i<vLumFilterSize; i+=2) {
*(const void**)&lumMmxFilter[s*i ]= lumSrcPtr[i ];
*(const void**)&lumMmxFilter[s*i+APCK_PTR2/4 ]= lumSrcPtr[i+(vLumFilterSize>1)];
lumMmxFilter[s*i+APCK_COEF/4 ]=
lumMmxFilter[s*i+APCK_COEF/4+1]= vLumFilter[dstY*vLumFilterSize + i ]
+ (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize + i + 1]<<16 : 0);
if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
*(const void**)&alpMmxFilter[s*i ]= alpSrcPtr[i ];
*(const void**)&alpMmxFilter[s*i+APCK_PTR2/4 ]= alpSrcPtr[i+(vLumFilterSize>1)];
alpMmxFilter[s*i+APCK_COEF/4 ]=
alpMmxFilter[s*i+APCK_COEF/4+1]= lumMmxFilter[s*i+APCK_COEF/4 ];
}
}
for (i=0; i<vChrFilterSize; i+=2) {
*(const void**)&chrMmxFilter[s*i ]= chrSrcPtr[i ];
*(const void**)&chrMmxFilter[s*i+APCK_PTR2/4 ]= chrSrcPtr[i+(vChrFilterSize>1)];
chrMmxFilter[s*i+APCK_COEF/4 ]=
chrMmxFilter[s*i+APCK_COEF/4+1]= vChrFilter[chrDstY*vChrFilterSize + i ]
+ (vChrFilterSize>1 ? vChrFilter[chrDstY*vChrFilterSize + i + 1]<<16 : 0);
}
} else {
for (i=0; i<vLumFilterSize; i++) {
lumMmxFilter[4*i+0]= (int32_t)lumSrcPtr[i];
lumMmxFilter[4*i+1]= (uint64_t)lumSrcPtr[i] >> 32;
lumMmxFilter[4*i+2]=
lumMmxFilter[4*i+3]=
((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001;
if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
alpMmxFilter[4*i+0]= (int32_t)alpSrcPtr[i];
alpMmxFilter[4*i+1]= (uint64_t)alpSrcPtr[i] >> 32;
alpMmxFilter[4*i+2]=
alpMmxFilter[4*i+3]= lumMmxFilter[4*i+2];
}
}
for (i=0; i<vChrFilterSize; i++) {
chrMmxFilter[4*i+0]= (int32_t)chrSrcPtr[i];
chrMmxFilter[4*i+1]= (uint64_t)chrSrcPtr[i] >> 32;
chrMmxFilter[4*i+2]=
chrMmxFilter[4*i+3]=
((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001;
}
}
#endif
if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21) {
const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
if (dstY&chrSkipMask) uDest= NULL; //FIXME split functions in lumi / chromi
c->yuv2nv12X(c,
vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
dest, uDest, dstW, chrDstW, dstFormat);
} else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 like
const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi
if (is16BPS(dstFormat) || isNBPS(dstFormat)) {
yuv2yuvX16inC(
vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
alpSrcPtr, (uint16_t *) dest, (uint16_t *) uDest, (uint16_t *) vDest, (uint16_t *) aDest, dstW, chrDstW,
dstFormat);
} else if (vLumFilterSize == 1 && vChrFilterSize == 1) { // unscaled YV12
const int16_t *lumBuf = lumSrcPtr[0];
const int16_t *chrBuf= chrSrcPtr[0];
const int16_t *alpBuf= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? alpSrcPtr[0] : NULL;
c->yuv2yuv1(c, lumBuf, chrBuf, alpBuf, dest, uDest, vDest, aDest, dstW, chrDstW);
} else { //General YV12
c->yuv2yuvX(c,
vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
alpSrcPtr, dest, uDest, vDest, aDest, dstW, chrDstW);
}
} else {
assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2);
assert(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2);
if (vLumFilterSize == 1 && vChrFilterSize == 2) { //unscaled RGB
int chrAlpha= vChrFilter[2*dstY+1];
if(flags & SWS_FULL_CHR_H_INT) {
yuv2rgbXinC_full(c, //FIXME write a packed1_full function
vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
alpSrcPtr, dest, dstW, dstY);
} else {
c->yuv2packed1(c, *lumSrcPtr, *chrSrcPtr, *(chrSrcPtr+1),
alpPixBuf ? *alpSrcPtr : NULL,
dest, dstW, chrAlpha, dstFormat, flags, dstY);
}
} else if (vLumFilterSize == 2 && vChrFilterSize == 2) { //bilinear upscale RGB
int lumAlpha= vLumFilter[2*dstY+1];
int chrAlpha= vChrFilter[2*dstY+1];
lumMmxFilter[2]=
lumMmxFilter[3]= vLumFilter[2*dstY ]*0x10001;
chrMmxFilter[2]=
chrMmxFilter[3]= vChrFilter[2*chrDstY]*0x10001;
if(flags & SWS_FULL_CHR_H_INT) {
yuv2rgbXinC_full(c, //FIXME write a packed2_full function
vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
alpSrcPtr, dest, dstW, dstY);
} else {
c->yuv2packed2(c, *lumSrcPtr, *(lumSrcPtr+1), *chrSrcPtr, *(chrSrcPtr+1),
alpPixBuf ? *alpSrcPtr : NULL, alpPixBuf ? *(alpSrcPtr+1) : NULL,
dest, dstW, lumAlpha, chrAlpha, dstY);
}
} else { //general RGB
if(flags & SWS_FULL_CHR_H_INT) {
yuv2rgbXinC_full(c,
vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
alpSrcPtr, dest, dstW, dstY);
} else {
c->yuv2packedX(c,
vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
alpSrcPtr, dest, dstW, dstY);
}
}
}
} else { // hmm looks like we can't use MMX here without overwriting this array's tail
const int16_t **lumSrcPtr= (const int16_t **)lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
const int16_t **chrSrcPtr= (const int16_t **)chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **)alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21) {
const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
if (dstY&chrSkipMask) uDest= NULL; //FIXME split functions in lumi / chromi
yuv2nv12XinC(
vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
dest, uDest, dstW, chrDstW, dstFormat);
} else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12
const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi
if (is16BPS(dstFormat) || isNBPS(dstFormat)) {
yuv2yuvX16inC(
vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
alpSrcPtr, (uint16_t *) dest, (uint16_t *) uDest, (uint16_t *) vDest, (uint16_t *) aDest, dstW, chrDstW,
dstFormat);
} else {
yuv2yuvXinC(
vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
alpSrcPtr, dest, uDest, vDest, aDest, dstW, chrDstW);
}
} else {
assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2);
assert(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2);
if(flags & SWS_FULL_CHR_H_INT) {
yuv2rgbXinC_full(c,
vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
alpSrcPtr, dest, dstW, dstY);
} else {
yuv2packedXinC(c,
vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
alpSrcPtr, dest, dstW, dstY);
}
}
}
}
if ((dstFormat == PIX_FMT_YUVA420P) && !alpPixBuf)
fillPlane(dst[3], dstStride[3], dstW, dstY-lastDstY, lastDstY, 255);
#if COMPILE_TEMPLATE_MMX
if (flags & SWS_CPU_CAPS_MMX2 ) __asm__ volatile("sfence":::"memory");
/* On K6 femms is faster than emms. On K7 femms is directly mapped to emms. */
if (flags & SWS_CPU_CAPS_3DNOW) __asm__ volatile("femms" :::"memory");
else __asm__ volatile("emms" :::"memory");
#endif
/* store changed local vars back in the context */
c->dstY= dstY;
c->lumBufIndex= lumBufIndex;
c->chrBufIndex= chrBufIndex;
c->lastInLumBuf= lastInLumBuf;
c->lastInChrBuf= lastInChrBuf;
return dstY - lastDstY;
}
| false | FFmpeg | d1adad3cca407f493c3637e20ecd4f7124e69212 | static int RENAME(swScale)(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[])
{
const int srcW= c->srcW;
const int dstW= c->dstW;
const int dstH= c->dstH;
const int chrDstW= c->chrDstW;
const int chrSrcW= c->chrSrcW;
const int lumXInc= c->lumXInc;
const int chrXInc= c->chrXInc;
const enum PixelFormat dstFormat= c->dstFormat;
const int flags= c->flags;
int16_t *vLumFilterPos= c->vLumFilterPos;
int16_t *vChrFilterPos= c->vChrFilterPos;
int16_t *hLumFilterPos= c->hLumFilterPos;
int16_t *hChrFilterPos= c->hChrFilterPos;
int16_t *vLumFilter= c->vLumFilter;
int16_t *vChrFilter= c->vChrFilter;
int16_t *hLumFilter= c->hLumFilter;
int16_t *hChrFilter= c->hChrFilter;
int32_t *lumMmxFilter= c->lumMmxFilter;
int32_t *chrMmxFilter= c->chrMmxFilter;
int32_t av_unused *alpMmxFilter= c->alpMmxFilter;
const int vLumFilterSize= c->vLumFilterSize;
const int vChrFilterSize= c->vChrFilterSize;
const int hLumFilterSize= c->hLumFilterSize;
const int hChrFilterSize= c->hChrFilterSize;
int16_t **lumPixBuf= c->lumPixBuf;
int16_t **chrPixBuf= c->chrPixBuf;
int16_t **alpPixBuf= c->alpPixBuf;
const int vLumBufSize= c->vLumBufSize;
const int vChrBufSize= c->vChrBufSize;
uint8_t *formatConvBuffer= c->formatConvBuffer;
const int chrSrcSliceY= srcSliceY >> c->chrSrcVSubSample;
const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample);
int lastDstY;
uint32_t *pal=c->pal_yuv;
int dstY= c->dstY;
int lumBufIndex= c->lumBufIndex;
int chrBufIndex= c->chrBufIndex;
int lastInLumBuf= c->lastInLumBuf;
int lastInChrBuf= c->lastInChrBuf;
if (isPacked(c->srcFormat)) {
src[0]=
src[1]=
src[2]=
src[3]= src[0];
srcStride[0]=
srcStride[1]=
srcStride[2]=
srcStride[3]= srcStride[0];
}
srcStride[1]<<= c->vChrDrop;
srcStride[2]<<= c->vChrDrop;
DEBUG_BUFFERS("swScale() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d] %p[%d] %p[%d] %p[%d]\n",
src[0], srcStride[0], src[1], srcStride[1], src[2], srcStride[2], src[3], srcStride[3],
dst[0], dstStride[0], dst[1], dstStride[1], dst[2], dstStride[2], dst[3], dstStride[3]);
DEBUG_BUFFERS("srcSliceY: %d srcSliceH: %d dstY: %d dstH: %d\n",
srcSliceY, srcSliceH, dstY, dstH);
DEBUG_BUFFERS("vLumFilterSize: %d vLumBufSize: %d vChrFilterSize: %d vChrBufSize: %d\n",
vLumFilterSize, vLumBufSize, vChrFilterSize, vChrBufSize);
if (dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0 || dstStride[3]%8 != 0) {
static int warnedAlready=0;
if (flags & SWS_PRINT_INFO && !warnedAlready) {
av_log(c, AV_LOG_WARNING, "Warning: dstStride is not aligned!\n"
" ->cannot do aligned memory accesses anymore\n");
warnedAlready=1;
}
}
if (srcSliceY ==0) {
lumBufIndex=-1;
chrBufIndex=-1;
dstY=0;
lastInLumBuf= -1;
lastInChrBuf= -1;
}
lastDstY= dstY;
for (;dstY < dstH; dstY++) {
unsigned char *dest =dst[0]+dstStride[0]*dstY;
const int chrDstY= dstY>>c->chrDstVSubSample;
unsigned char *uDest=dst[1]+dstStride[1]*chrDstY;
unsigned char *vDest=dst[2]+dstStride[2]*chrDstY;
unsigned char *aDest=(CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3]+dstStride[3]*dstY : NULL;
const int firstLumSrcY= vLumFilterPos[dstY];
const int firstLumSrcY2= vLumFilterPos[FFMIN(dstY | ((1<<c->chrDstVSubSample) - 1), dstH-1)];
const int firstChrSrcY= vChrFilterPos[chrDstY];
int lastLumSrcY= firstLumSrcY + vLumFilterSize -1;
int lastLumSrcY2=firstLumSrcY2+ vLumFilterSize -1;
int lastChrSrcY= firstChrSrcY + vChrFilterSize -1;
int enough_lines;
if (firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1;
if (firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1;
assert(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1);
assert(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1);
DEBUG_BUFFERS("dstY: %d\n", dstY);
DEBUG_BUFFERS("\tfirstLumSrcY: %d lastLumSrcY: %d lastInLumBuf: %d\n",
firstLumSrcY, lastLumSrcY, lastInLumBuf);
DEBUG_BUFFERS("\tfirstChrSrcY: %d lastChrSrcY: %d lastInChrBuf: %d\n",
firstChrSrcY, lastChrSrcY, lastInChrBuf);
enough_lines = lastLumSrcY2 < srcSliceY + srcSliceH && lastChrSrcY < -((-srcSliceY - srcSliceH)>>c->chrSrcVSubSample);
if (!enough_lines) {
lastLumSrcY = srcSliceY + srcSliceH - 1;
lastChrSrcY = chrSrcSliceY + chrSrcSliceH - 1;
DEBUG_BUFFERS("buffering slice: lastLumSrcY %d lastChrSrcY %d\n",
lastLumSrcY, lastChrSrcY);
}
while(lastInLumBuf < lastLumSrcY) {
const uint8_t *src1= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0];
const uint8_t *src2= src[3]+(lastInLumBuf + 1 - srcSliceY)*srcStride[3];
lumBufIndex++;
assert(lumBufIndex < 2*vLumBufSize);
assert(lastInLumBuf + 1 - srcSliceY < srcSliceH);
assert(lastInLumBuf + 1 - srcSliceY >= 0);
RENAME(hyscale)(c, lumPixBuf[ lumBufIndex ], dstW, src1, srcW, lumXInc,
hLumFilter, hLumFilterPos, hLumFilterSize,
formatConvBuffer,
pal, 0);
if (CONFIG_SWSCALE_ALPHA && alpPixBuf)
RENAME(hyscale)(c, alpPixBuf[ lumBufIndex ], dstW, src2, srcW, lumXInc,
hLumFilter, hLumFilterPos, hLumFilterSize,
formatConvBuffer,
pal, 1);
lastInLumBuf++;
DEBUG_BUFFERS("\t\tlumBufIndex %d: lastInLumBuf: %d\n",
lumBufIndex, lastInLumBuf);
}
while(lastInChrBuf < lastChrSrcY) {
const uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[1];
const uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2];
chrBufIndex++;
assert(chrBufIndex < 2*vChrBufSize);
assert(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH));
assert(lastInChrBuf + 1 - chrSrcSliceY >= 0);
if (c->needs_hcscale)
RENAME(hcscale)(c, chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc,
hChrFilter, hChrFilterPos, hChrFilterSize,
formatConvBuffer,
pal);
lastInChrBuf++;
DEBUG_BUFFERS("\t\tchrBufIndex %d: lastInChrBuf: %d\n",
chrBufIndex, lastInChrBuf);
}
if (lumBufIndex >= vLumBufSize) lumBufIndex-= vLumBufSize;
if (chrBufIndex >= vChrBufSize) chrBufIndex-= vChrBufSize;
if (!enough_lines)
break;
#if COMPILE_TEMPLATE_MMX
c->blueDither= ff_dither8[dstY&1];
if (c->dstFormat == PIX_FMT_RGB555 || c->dstFormat == PIX_FMT_BGR555)
c->greenDither= ff_dither8[dstY&1];
else
c->greenDither= ff_dither4[dstY&1];
c->redDither= ff_dither8[(dstY+1)&1];
#endif
if (dstY < dstH-2) {
const int16_t **lumSrcPtr= (const int16_t **) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
const int16_t **chrSrcPtr= (const int16_t **) chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
#if COMPILE_TEMPLATE_MMX
int i;
if (flags & SWS_ACCURATE_RND) {
int s= APCK_SIZE / 8;
for (i=0; i<vLumFilterSize; i+=2) {
*(const void**)&lumMmxFilter[s*i ]= lumSrcPtr[i ];
*(const void**)&lumMmxFilter[s*i+APCK_PTR2/4 ]= lumSrcPtr[i+(vLumFilterSize>1)];
lumMmxFilter[s*i+APCK_COEF/4 ]=
lumMmxFilter[s*i+APCK_COEF/4+1]= vLumFilter[dstY*vLumFilterSize + i ]
+ (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize + i + 1]<<16 : 0);
if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
*(const void**)&alpMmxFilter[s*i ]= alpSrcPtr[i ];
*(const void**)&alpMmxFilter[s*i+APCK_PTR2/4 ]= alpSrcPtr[i+(vLumFilterSize>1)];
alpMmxFilter[s*i+APCK_COEF/4 ]=
alpMmxFilter[s*i+APCK_COEF/4+1]= lumMmxFilter[s*i+APCK_COEF/4 ];
}
}
for (i=0; i<vChrFilterSize; i+=2) {
*(const void**)&chrMmxFilter[s*i ]= chrSrcPtr[i ];
*(const void**)&chrMmxFilter[s*i+APCK_PTR2/4 ]= chrSrcPtr[i+(vChrFilterSize>1)];
chrMmxFilter[s*i+APCK_COEF/4 ]=
chrMmxFilter[s*i+APCK_COEF/4+1]= vChrFilter[chrDstY*vChrFilterSize + i ]
+ (vChrFilterSize>1 ? vChrFilter[chrDstY*vChrFilterSize + i + 1]<<16 : 0);
}
} else {
for (i=0; i<vLumFilterSize; i++) {
lumMmxFilter[4*i+0]= (int32_t)lumSrcPtr[i];
lumMmxFilter[4*i+1]= (uint64_t)lumSrcPtr[i] >> 32;
lumMmxFilter[4*i+2]=
lumMmxFilter[4*i+3]=
((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001;
if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
alpMmxFilter[4*i+0]= (int32_t)alpSrcPtr[i];
alpMmxFilter[4*i+1]= (uint64_t)alpSrcPtr[i] >> 32;
alpMmxFilter[4*i+2]=
alpMmxFilter[4*i+3]= lumMmxFilter[4*i+2];
}
}
for (i=0; i<vChrFilterSize; i++) {
chrMmxFilter[4*i+0]= (int32_t)chrSrcPtr[i];
chrMmxFilter[4*i+1]= (uint64_t)chrSrcPtr[i] >> 32;
chrMmxFilter[4*i+2]=
chrMmxFilter[4*i+3]=
((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001;
}
}
#endif
if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21) {
const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
if (dstY&chrSkipMask) uDest= NULL;
c->yuv2nv12X(c,
vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
dest, uDest, dstW, chrDstW, dstFormat);
} else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) {
const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL;
if (is16BPS(dstFormat) || isNBPS(dstFormat)) {
yuv2yuvX16inC(
vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
alpSrcPtr, (uint16_t *) dest, (uint16_t *) uDest, (uint16_t *) vDest, (uint16_t *) aDest, dstW, chrDstW,
dstFormat);
} else if (vLumFilterSize == 1 && vChrFilterSize == 1) {
const int16_t *lumBuf = lumSrcPtr[0];
const int16_t *chrBuf= chrSrcPtr[0];
const int16_t *alpBuf= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? alpSrcPtr[0] : NULL;
c->yuv2yuv1(c, lumBuf, chrBuf, alpBuf, dest, uDest, vDest, aDest, dstW, chrDstW);
} else {
c->yuv2yuvX(c,
vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
alpSrcPtr, dest, uDest, vDest, aDest, dstW, chrDstW);
}
} else {
assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2);
assert(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2);
if (vLumFilterSize == 1 && vChrFilterSize == 2) {
int chrAlpha= vChrFilter[2*dstY+1];
if(flags & SWS_FULL_CHR_H_INT) {
yuv2rgbXinC_full(c,
vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
alpSrcPtr, dest, dstW, dstY);
} else {
c->yuv2packed1(c, *lumSrcPtr, *chrSrcPtr, *(chrSrcPtr+1),
alpPixBuf ? *alpSrcPtr : NULL,
dest, dstW, chrAlpha, dstFormat, flags, dstY);
}
} else if (vLumFilterSize == 2 && vChrFilterSize == 2) {
int lumAlpha= vLumFilter[2*dstY+1];
int chrAlpha= vChrFilter[2*dstY+1];
lumMmxFilter[2]=
lumMmxFilter[3]= vLumFilter[2*dstY ]*0x10001;
chrMmxFilter[2]=
chrMmxFilter[3]= vChrFilter[2*chrDstY]*0x10001;
if(flags & SWS_FULL_CHR_H_INT) {
yuv2rgbXinC_full(c,
vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
alpSrcPtr, dest, dstW, dstY);
} else {
c->yuv2packed2(c, *lumSrcPtr, *(lumSrcPtr+1), *chrSrcPtr, *(chrSrcPtr+1),
alpPixBuf ? *alpSrcPtr : NULL, alpPixBuf ? *(alpSrcPtr+1) : NULL,
dest, dstW, lumAlpha, chrAlpha, dstY);
}
} else {
if(flags & SWS_FULL_CHR_H_INT) {
yuv2rgbXinC_full(c,
vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
alpSrcPtr, dest, dstW, dstY);
} else {
c->yuv2packedX(c,
vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
alpSrcPtr, dest, dstW, dstY);
}
}
}
} else {
const int16_t **lumSrcPtr= (const int16_t **)lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
const int16_t **chrSrcPtr= (const int16_t **)chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **)alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21) {
const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
if (dstY&chrSkipMask) uDest= NULL;
yuv2nv12XinC(
vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
dest, uDest, dstW, chrDstW, dstFormat);
} else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) {
const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL;
if (is16BPS(dstFormat) || isNBPS(dstFormat)) {
yuv2yuvX16inC(
vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
alpSrcPtr, (uint16_t *) dest, (uint16_t *) uDest, (uint16_t *) vDest, (uint16_t *) aDest, dstW, chrDstW,
dstFormat);
} else {
yuv2yuvXinC(
vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
alpSrcPtr, dest, uDest, vDest, aDest, dstW, chrDstW);
}
} else {
assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2);
assert(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2);
if(flags & SWS_FULL_CHR_H_INT) {
yuv2rgbXinC_full(c,
vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
alpSrcPtr, dest, dstW, dstY);
} else {
yuv2packedXinC(c,
vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
alpSrcPtr, dest, dstW, dstY);
}
}
}
}
if ((dstFormat == PIX_FMT_YUVA420P) && !alpPixBuf)
fillPlane(dst[3], dstStride[3], dstW, dstY-lastDstY, lastDstY, 255);
#if COMPILE_TEMPLATE_MMX
if (flags & SWS_CPU_CAPS_MMX2 ) __asm__ volatile("sfence":::"memory");
if (flags & SWS_CPU_CAPS_3DNOW) __asm__ volatile("femms" :::"memory");
else __asm__ volatile("emms" :::"memory");
#endif
c->dstY= dstY;
c->lumBufIndex= lumBufIndex;
c->chrBufIndex= chrBufIndex;
c->lastInLumBuf= lastInLumBuf;
c->lastInChrBuf= lastInChrBuf;
return dstY - lastDstY;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(swScale)(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[])
{
const int VAR_0= c->VAR_0;
const int VAR_1= c->VAR_1;
const int VAR_2= c->VAR_2;
const int VAR_3= c->VAR_3;
const int VAR_4= c->VAR_4;
const int VAR_5= c->VAR_5;
const int VAR_6= c->VAR_6;
const enum PixelFormat VAR_7= c->VAR_7;
const int VAR_8= c->VAR_8;
int16_t *vLumFilterPos= c->vLumFilterPos;
int16_t *vChrFilterPos= c->vChrFilterPos;
int16_t *hLumFilterPos= c->hLumFilterPos;
int16_t *hChrFilterPos= c->hChrFilterPos;
int16_t *vLumFilter= c->vLumFilter;
int16_t *vChrFilter= c->vChrFilter;
int16_t *hLumFilter= c->hLumFilter;
int16_t *hChrFilter= c->hChrFilter;
int32_t *lumMmxFilter= c->lumMmxFilter;
int32_t *chrMmxFilter= c->chrMmxFilter;
int32_t av_unused *alpMmxFilter= c->alpMmxFilter;
const int VAR_9= c->VAR_9;
const int VAR_10= c->VAR_10;
const int VAR_11= c->VAR_11;
const int VAR_12= c->VAR_12;
int16_t **lumPixBuf= c->lumPixBuf;
int16_t **chrPixBuf= c->chrPixBuf;
int16_t **alpPixBuf= c->alpPixBuf;
const int VAR_13= c->VAR_13;
const int VAR_14= c->VAR_14;
uint8_t *formatConvBuffer= c->formatConvBuffer;
const int VAR_15= srcSliceY >> c->chrSrcVSubSample;
const int VAR_16= -((-srcSliceH) >> c->chrSrcVSubSample);
int VAR_17;
uint32_t *pal=c->pal_yuv;
int VAR_18= c->VAR_18;
int VAR_19= c->VAR_19;
int VAR_20= c->VAR_20;
int VAR_21= c->VAR_21;
int VAR_22= c->VAR_22;
if (isPacked(c->srcFormat)) {
src[0]=
src[1]=
src[2]=
src[3]= src[0];
srcStride[0]=
srcStride[1]=
srcStride[2]=
srcStride[3]= srcStride[0];
}
srcStride[1]<<= c->vChrDrop;
srcStride[2]<<= c->vChrDrop;
DEBUG_BUFFERS("swScale() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d] %p[%d] %p[%d] %p[%d]\n",
src[0], srcStride[0], src[1], srcStride[1], src[2], srcStride[2], src[3], srcStride[3],
dst[0], dstStride[0], dst[1], dstStride[1], dst[2], dstStride[2], dst[3], dstStride[3]);
DEBUG_BUFFERS("srcSliceY: %d srcSliceH: %d VAR_18: %d VAR_2: %d\n",
srcSliceY, srcSliceH, VAR_18, VAR_2);
DEBUG_BUFFERS("VAR_9: %d VAR_13: %d VAR_10: %d VAR_14: %d\n",
VAR_9, VAR_13, VAR_10, VAR_14);
if (dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0 || dstStride[3]%8 != 0) {
static int VAR_23=0;
if (VAR_8 & SWS_PRINT_INFO && !VAR_23) {
av_log(c, AV_LOG_WARNING, "Warning: dstStride is not aligned!\n"
" ->cannot do aligned memory accesses anymore\n");
VAR_23=1;
}
}
if (srcSliceY ==0) {
VAR_19=-1;
VAR_20=-1;
VAR_18=0;
VAR_21= -1;
VAR_22= -1;
}
VAR_17= VAR_18;
for (;VAR_18 < VAR_2; VAR_18++) {
unsigned char *VAR_24 =dst[0]+dstStride[0]*VAR_18;
const int VAR_25= VAR_18>>c->chrDstVSubSample;
unsigned char *VAR_26=dst[1]+dstStride[1]*VAR_25;
unsigned char *VAR_27=dst[2]+dstStride[2]*VAR_25;
unsigned char *VAR_28=(CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3]+dstStride[3]*VAR_18 : NULL;
const int VAR_29= vLumFilterPos[VAR_18];
const int VAR_30= vLumFilterPos[FFMIN(VAR_18 | ((1<<c->chrDstVSubSample) - 1), VAR_2-1)];
const int VAR_31= vChrFilterPos[VAR_25];
int VAR_32= VAR_29 + VAR_9 -1;
int VAR_33=VAR_30+ VAR_9 -1;
int VAR_34= VAR_31 + VAR_10 -1;
int VAR_35;
if (VAR_29 > VAR_21) VAR_21= VAR_29-1;
if (VAR_31 > VAR_22) VAR_22= VAR_31-1;
assert(VAR_29 >= VAR_21 - VAR_13 + 1);
assert(VAR_31 >= VAR_22 - VAR_14 + 1);
DEBUG_BUFFERS("VAR_18: %d\n", VAR_18);
DEBUG_BUFFERS("\tfirstLumSrcY: %d VAR_32: %d VAR_21: %d\n",
VAR_29, VAR_32, VAR_21);
DEBUG_BUFFERS("\tfirstChrSrcY: %d VAR_34: %d VAR_22: %d\n",
VAR_31, VAR_34, VAR_22);
VAR_35 = VAR_33 < srcSliceY + srcSliceH && VAR_34 < -((-srcSliceY - srcSliceH)>>c->chrSrcVSubSample);
if (!VAR_35) {
VAR_32 = srcSliceY + srcSliceH - 1;
VAR_34 = VAR_15 + VAR_16 - 1;
DEBUG_BUFFERS("buffering slice: VAR_32 %d VAR_34 %d\n",
VAR_32, VAR_34);
}
while(VAR_21 < VAR_32) {
const uint8_t *VAR_38= src[0]+(VAR_21 + 1 - srcSliceY)*srcStride[0];
const uint8_t *VAR_38= src[3]+(VAR_21 + 1 - srcSliceY)*srcStride[3];
VAR_19++;
assert(VAR_19 < 2*VAR_13);
assert(VAR_21 + 1 - srcSliceY < srcSliceH);
assert(VAR_21 + 1 - srcSliceY >= 0);
FUNC_0(hyscale)(c, lumPixBuf[ VAR_19 ], VAR_1, VAR_38, VAR_0, VAR_5,
hLumFilter, hLumFilterPos, VAR_11,
formatConvBuffer,
pal, 0);
if (CONFIG_SWSCALE_ALPHA && alpPixBuf)
FUNC_0(hyscale)(c, alpPixBuf[ VAR_19 ], VAR_1, VAR_38, VAR_0, VAR_5,
hLumFilter, hLumFilterPos, VAR_11,
formatConvBuffer,
pal, 1);
VAR_21++;
DEBUG_BUFFERS("\t\tlumBufIndex %d: VAR_21: %d\n",
VAR_19, VAR_21);
}
while(VAR_22 < VAR_34) {
const uint8_t *VAR_38= src[1]+(VAR_22 + 1 - VAR_15)*srcStride[1];
const uint8_t *VAR_38= src[2]+(VAR_22 + 1 - VAR_15)*srcStride[2];
VAR_20++;
assert(VAR_20 < 2*VAR_14);
assert(VAR_22 + 1 - VAR_15 < (VAR_16));
assert(VAR_22 + 1 - VAR_15 >= 0);
if (c->needs_hcscale)
FUNC_0(hcscale)(c, chrPixBuf[ VAR_20 ], VAR_3, VAR_38, VAR_38, VAR_4, VAR_6,
hChrFilter, hChrFilterPos, VAR_12,
formatConvBuffer,
pal);
VAR_22++;
DEBUG_BUFFERS("\t\tchrBufIndex %d: VAR_22: %d\n",
VAR_20, VAR_22);
}
if (VAR_19 >= VAR_13) VAR_19-= VAR_13;
if (VAR_20 >= VAR_14) VAR_20-= VAR_14;
if (!VAR_35)
break;
#if COMPILE_TEMPLATE_MMX
c->blueDither= ff_dither8[VAR_18&1];
if (c->VAR_7 == PIX_FMT_RGB555 || c->VAR_7 == PIX_FMT_BGR555)
c->greenDither= ff_dither8[VAR_18&1];
else
c->greenDither= ff_dither4[VAR_18&1];
c->redDither= ff_dither8[(VAR_18+1)&1];
#endif
if (VAR_18 < VAR_2-2) {
const int16_t **VAR_47= (const int16_t **) lumPixBuf + VAR_19 + VAR_29 - VAR_21 + VAR_13;
const int16_t **VAR_47= (const int16_t **) chrPixBuf + VAR_20 + VAR_31 - VAR_22 + VAR_14;
const int16_t **VAR_47= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + VAR_19 + VAR_29 - VAR_21 + VAR_13 : NULL;
#if COMPILE_TEMPLATE_MMX
int i;
if (VAR_8 & SWS_ACCURATE_RND) {
int s= APCK_SIZE / 8;
for (i=0; i<VAR_9; i+=2) {
*(const void**)&lumMmxFilter[s*i ]= VAR_47[i ];
*(const void**)&lumMmxFilter[s*i+APCK_PTR2/4 ]= VAR_47[i+(VAR_9>1)];
lumMmxFilter[s*i+APCK_COEF/4 ]=
lumMmxFilter[s*i+APCK_COEF/4+1]= vLumFilter[VAR_18*VAR_9 + i ]
+ (VAR_9>1 ? vLumFilter[VAR_18*VAR_9 + i + 1]<<16 : 0);
if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
*(const void**)&alpMmxFilter[s*i ]= VAR_47[i ];
*(const void**)&alpMmxFilter[s*i+APCK_PTR2/4 ]= VAR_47[i+(VAR_9>1)];
alpMmxFilter[s*i+APCK_COEF/4 ]=
alpMmxFilter[s*i+APCK_COEF/4+1]= lumMmxFilter[s*i+APCK_COEF/4 ];
}
}
for (i=0; i<VAR_10; i+=2) {
*(const void**)&chrMmxFilter[s*i ]= VAR_47[i ];
*(const void**)&chrMmxFilter[s*i+APCK_PTR2/4 ]= VAR_47[i+(VAR_10>1)];
chrMmxFilter[s*i+APCK_COEF/4 ]=
chrMmxFilter[s*i+APCK_COEF/4+1]= vChrFilter[VAR_25*VAR_10 + i ]
+ (VAR_10>1 ? vChrFilter[VAR_25*VAR_10 + i + 1]<<16 : 0);
}
} else {
for (i=0; i<VAR_9; i++) {
lumMmxFilter[4*i+0]= (int32_t)VAR_47[i];
lumMmxFilter[4*i+1]= (uint64_t)VAR_47[i] >> 32;
lumMmxFilter[4*i+2]=
lumMmxFilter[4*i+3]=
((uint16_t)vLumFilter[VAR_18*VAR_9 + i])*0x10001;
if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
alpMmxFilter[4*i+0]= (int32_t)VAR_47[i];
alpMmxFilter[4*i+1]= (uint64_t)VAR_47[i] >> 32;
alpMmxFilter[4*i+2]=
alpMmxFilter[4*i+3]= lumMmxFilter[4*i+2];
}
}
for (i=0; i<VAR_10; i++) {
chrMmxFilter[4*i+0]= (int32_t)VAR_47[i];
chrMmxFilter[4*i+1]= (uint64_t)VAR_47[i] >> 32;
chrMmxFilter[4*i+2]=
chrMmxFilter[4*i+3]=
((uint16_t)vChrFilter[VAR_25*VAR_10 + i])*0x10001;
}
}
#endif
if (VAR_7 == PIX_FMT_NV12 || VAR_7 == PIX_FMT_NV21) {
const int VAR_47= (1<<c->chrDstVSubSample)-1;
if (VAR_18&VAR_47) VAR_26= NULL;
c->yuv2nv12X(c,
vLumFilter+VAR_18*VAR_9 , VAR_47, VAR_9,
vChrFilter+VAR_25*VAR_10, VAR_47, VAR_10,
VAR_24, VAR_26, VAR_1, VAR_3, VAR_7);
} else if (isPlanarYUV(VAR_7) || VAR_7==PIX_FMT_GRAY8) {
const int VAR_47= (1<<c->chrDstVSubSample)-1;
if ((VAR_18&VAR_47) || isGray(VAR_7)) VAR_26=VAR_27= NULL;
if (is16BPS(VAR_7) || isNBPS(VAR_7)) {
yuv2yuvX16inC(
vLumFilter+VAR_18*VAR_9 , VAR_47, VAR_9,
vChrFilter+VAR_25*VAR_10, VAR_47, VAR_10,
VAR_47, (uint16_t *) VAR_24, (uint16_t *) VAR_26, (uint16_t *) VAR_27, (uint16_t *) VAR_28, VAR_1, VAR_3,
VAR_7);
} else if (VAR_9 == 1 && VAR_10 == 1) {
const int16_t *VAR_42 = VAR_47[0];
const int16_t *VAR_43= VAR_47[0];
const int16_t *VAR_44= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? VAR_47[0] : NULL;
c->yuv2yuv1(c, VAR_42, VAR_43, VAR_44, VAR_24, VAR_26, VAR_27, VAR_28, VAR_1, VAR_3);
} else {
c->yuv2yuvX(c,
vLumFilter+VAR_18*VAR_9 , VAR_47, VAR_9,
vChrFilter+VAR_25*VAR_10, VAR_47, VAR_10,
VAR_47, VAR_24, VAR_26, VAR_27, VAR_28, VAR_1, VAR_3);
}
} else {
assert(VAR_47 + VAR_9 - 1 < lumPixBuf + VAR_13*2);
assert(VAR_47 + VAR_10 - 1 < chrPixBuf + VAR_14*2);
if (VAR_9 == 1 && VAR_10 == 2) {
int VAR_47= vChrFilter[2*VAR_18+1];
if(VAR_8 & SWS_FULL_CHR_H_INT) {
yuv2rgbXinC_full(c,
vLumFilter+VAR_18*VAR_9, VAR_47, VAR_9,
vChrFilter+VAR_18*VAR_10, VAR_47, VAR_10,
VAR_47, VAR_24, VAR_1, VAR_18);
} else {
c->yuv2packed1(c, *VAR_47, *VAR_47, *(VAR_47+1),
alpPixBuf ? *VAR_47 : NULL,
VAR_24, VAR_1, VAR_47, VAR_7, VAR_8, VAR_18);
}
} else if (VAR_9 == 2 && VAR_10 == 2) {
int VAR_46= vLumFilter[2*VAR_18+1];
int VAR_47= vChrFilter[2*VAR_18+1];
lumMmxFilter[2]=
lumMmxFilter[3]= vLumFilter[2*VAR_18 ]*0x10001;
chrMmxFilter[2]=
chrMmxFilter[3]= vChrFilter[2*VAR_25]*0x10001;
if(VAR_8 & SWS_FULL_CHR_H_INT) {
yuv2rgbXinC_full(c,
vLumFilter+VAR_18*VAR_9, VAR_47, VAR_9,
vChrFilter+VAR_18*VAR_10, VAR_47, VAR_10,
VAR_47, VAR_24, VAR_1, VAR_18);
} else {
c->yuv2packed2(c, *VAR_47, *(VAR_47+1), *VAR_47, *(VAR_47+1),
alpPixBuf ? *VAR_47 : NULL, alpPixBuf ? *(VAR_47+1) : NULL,
VAR_24, VAR_1, VAR_46, VAR_47, VAR_18);
}
} else {
if(VAR_8 & SWS_FULL_CHR_H_INT) {
yuv2rgbXinC_full(c,
vLumFilter+VAR_18*VAR_9, VAR_47, VAR_9,
vChrFilter+VAR_18*VAR_10, VAR_47, VAR_10,
VAR_47, VAR_24, VAR_1, VAR_18);
} else {
c->yuv2packedX(c,
vLumFilter+VAR_18*VAR_9, VAR_47, VAR_9,
vChrFilter+VAR_18*VAR_10, VAR_47, VAR_10,
VAR_47, VAR_24, VAR_1, VAR_18);
}
}
}
} else {
const int16_t **VAR_47= (const int16_t **)lumPixBuf + VAR_19 + VAR_29 - VAR_21 + VAR_13;
const int16_t **VAR_47= (const int16_t **)chrPixBuf + VAR_20 + VAR_31 - VAR_22 + VAR_14;
const int16_t **VAR_47= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **)alpPixBuf + VAR_19 + VAR_29 - VAR_21 + VAR_13 : NULL;
if (VAR_7 == PIX_FMT_NV12 || VAR_7 == PIX_FMT_NV21) {
const int VAR_47= (1<<c->chrDstVSubSample)-1;
if (VAR_18&VAR_47) VAR_26= NULL;
yuv2nv12XinC(
vLumFilter+VAR_18*VAR_9 , VAR_47, VAR_9,
vChrFilter+VAR_25*VAR_10, VAR_47, VAR_10,
VAR_24, VAR_26, VAR_1, VAR_3, VAR_7);
} else if (isPlanarYUV(VAR_7) || VAR_7==PIX_FMT_GRAY8) {
const int VAR_47= (1<<c->chrDstVSubSample)-1;
if ((VAR_18&VAR_47) || isGray(VAR_7)) VAR_26=VAR_27= NULL;
if (is16BPS(VAR_7) || isNBPS(VAR_7)) {
yuv2yuvX16inC(
vLumFilter+VAR_18*VAR_9 , VAR_47, VAR_9,
vChrFilter+VAR_25*VAR_10, VAR_47, VAR_10,
VAR_47, (uint16_t *) VAR_24, (uint16_t *) VAR_26, (uint16_t *) VAR_27, (uint16_t *) VAR_28, VAR_1, VAR_3,
VAR_7);
} else {
yuv2yuvXinC(
vLumFilter+VAR_18*VAR_9 , VAR_47, VAR_9,
vChrFilter+VAR_25*VAR_10, VAR_47, VAR_10,
VAR_47, VAR_24, VAR_26, VAR_27, VAR_28, VAR_1, VAR_3);
}
} else {
assert(VAR_47 + VAR_9 - 1 < lumPixBuf + VAR_13*2);
assert(VAR_47 + VAR_10 - 1 < chrPixBuf + VAR_14*2);
if(VAR_8 & SWS_FULL_CHR_H_INT) {
yuv2rgbXinC_full(c,
vLumFilter+VAR_18*VAR_9, VAR_47, VAR_9,
vChrFilter+VAR_18*VAR_10, VAR_47, VAR_10,
VAR_47, VAR_24, VAR_1, VAR_18);
} else {
yuv2packedXinC(c,
vLumFilter+VAR_18*VAR_9, VAR_47, VAR_9,
vChrFilter+VAR_18*VAR_10, VAR_47, VAR_10,
VAR_47, VAR_24, VAR_1, VAR_18);
}
}
}
}
if ((VAR_7 == PIX_FMT_YUVA420P) && !alpPixBuf)
fillPlane(dst[3], dstStride[3], VAR_1, VAR_18-VAR_17, VAR_17, 255);
#if COMPILE_TEMPLATE_MMX
if (VAR_8 & SWS_CPU_CAPS_MMX2 ) __asm__ volatile("sfence":::"memory");
if (VAR_8 & SWS_CPU_CAPS_3DNOW) __asm__ volatile("femms" :::"memory");
else __asm__ volatile("emms" :::"memory");
#endif
c->VAR_18= VAR_18;
c->VAR_19= VAR_19;
c->VAR_20= VAR_20;
c->VAR_21= VAR_21;
c->VAR_22= VAR_22;
return VAR_18 - VAR_17;
}
| [
"static int FUNC_0(swScale)(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,\nint srcSliceH, uint8_t* dst[], int dstStride[])\n{",
"const int VAR_0= c->VAR_0;",
"const int VAR_1= c->VAR_1;",
"const int VAR_2= c->VAR_2;",
"const int VAR_3= c->VAR_3;",
"const int VAR_4= c->VAR_4;",
"const int VAR_5= c->VAR_5;",
"const int VAR_6= c->VAR_6;",
"const enum PixelFormat VAR_7= c->VAR_7;",
"const int VAR_8= c->VAR_8;",
"int16_t *vLumFilterPos= c->vLumFilterPos;",
"int16_t *vChrFilterPos= c->vChrFilterPos;",
"int16_t *hLumFilterPos= c->hLumFilterPos;",
"int16_t *hChrFilterPos= c->hChrFilterPos;",
"int16_t *vLumFilter= c->vLumFilter;",
"int16_t *vChrFilter= c->vChrFilter;",
"int16_t *hLumFilter= c->hLumFilter;",
"int16_t *hChrFilter= c->hChrFilter;",
"int32_t *lumMmxFilter= c->lumMmxFilter;",
"int32_t *chrMmxFilter= c->chrMmxFilter;",
"int32_t av_unused *alpMmxFilter= c->alpMmxFilter;",
"const int VAR_9= c->VAR_9;",
"const int VAR_10= c->VAR_10;",
"const int VAR_11= c->VAR_11;",
"const int VAR_12= c->VAR_12;",
"int16_t **lumPixBuf= c->lumPixBuf;",
"int16_t **chrPixBuf= c->chrPixBuf;",
"int16_t **alpPixBuf= c->alpPixBuf;",
"const int VAR_13= c->VAR_13;",
"const int VAR_14= c->VAR_14;",
"uint8_t *formatConvBuffer= c->formatConvBuffer;",
"const int VAR_15= srcSliceY >> c->chrSrcVSubSample;",
"const int VAR_16= -((-srcSliceH) >> c->chrSrcVSubSample);",
"int VAR_17;",
"uint32_t *pal=c->pal_yuv;",
"int VAR_18= c->VAR_18;",
"int VAR_19= c->VAR_19;",
"int VAR_20= c->VAR_20;",
"int VAR_21= c->VAR_21;",
"int VAR_22= c->VAR_22;",
"if (isPacked(c->srcFormat)) {",
"src[0]=\nsrc[1]=\nsrc[2]=\nsrc[3]= src[0];",
"srcStride[0]=\nsrcStride[1]=\nsrcStride[2]=\nsrcStride[3]= srcStride[0];",
"}",
"srcStride[1]<<= c->vChrDrop;",
"srcStride[2]<<= c->vChrDrop;",
"DEBUG_BUFFERS(\"swScale() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d] %p[%d] %p[%d] %p[%d]\\n\",\nsrc[0], srcStride[0], src[1], srcStride[1], src[2], srcStride[2], src[3], srcStride[3],\ndst[0], dstStride[0], dst[1], dstStride[1], dst[2], dstStride[2], dst[3], dstStride[3]);",
"DEBUG_BUFFERS(\"srcSliceY: %d srcSliceH: %d VAR_18: %d VAR_2: %d\\n\",\nsrcSliceY, srcSliceH, VAR_18, VAR_2);",
"DEBUG_BUFFERS(\"VAR_9: %d VAR_13: %d VAR_10: %d VAR_14: %d\\n\",\nVAR_9, VAR_13, VAR_10, VAR_14);",
"if (dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0 || dstStride[3]%8 != 0) {",
"static int VAR_23=0;",
"if (VAR_8 & SWS_PRINT_INFO && !VAR_23) {",
"av_log(c, AV_LOG_WARNING, \"Warning: dstStride is not aligned!\\n\"\n\" ->cannot do aligned memory accesses anymore\\n\");",
"VAR_23=1;",
"}",
"}",
"if (srcSliceY ==0) {",
"VAR_19=-1;",
"VAR_20=-1;",
"VAR_18=0;",
"VAR_21= -1;",
"VAR_22= -1;",
"}",
"VAR_17= VAR_18;",
"for (;VAR_18 < VAR_2; VAR_18++) {",
"unsigned char *VAR_24 =dst[0]+dstStride[0]*VAR_18;",
"const int VAR_25= VAR_18>>c->chrDstVSubSample;",
"unsigned char *VAR_26=dst[1]+dstStride[1]*VAR_25;",
"unsigned char *VAR_27=dst[2]+dstStride[2]*VAR_25;",
"unsigned char *VAR_28=(CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3]+dstStride[3]*VAR_18 : NULL;",
"const int VAR_29= vLumFilterPos[VAR_18];",
"const int VAR_30= vLumFilterPos[FFMIN(VAR_18 | ((1<<c->chrDstVSubSample) - 1), VAR_2-1)];",
"const int VAR_31= vChrFilterPos[VAR_25];",
"int VAR_32= VAR_29 + VAR_9 -1;",
"int VAR_33=VAR_30+ VAR_9 -1;",
"int VAR_34= VAR_31 + VAR_10 -1;",
"int VAR_35;",
"if (VAR_29 > VAR_21) VAR_21= VAR_29-1;",
"if (VAR_31 > VAR_22) VAR_22= VAR_31-1;",
"assert(VAR_29 >= VAR_21 - VAR_13 + 1);",
"assert(VAR_31 >= VAR_22 - VAR_14 + 1);",
"DEBUG_BUFFERS(\"VAR_18: %d\\n\", VAR_18);",
"DEBUG_BUFFERS(\"\\tfirstLumSrcY: %d VAR_32: %d VAR_21: %d\\n\",\nVAR_29, VAR_32, VAR_21);",
"DEBUG_BUFFERS(\"\\tfirstChrSrcY: %d VAR_34: %d VAR_22: %d\\n\",\nVAR_31, VAR_34, VAR_22);",
"VAR_35 = VAR_33 < srcSliceY + srcSliceH && VAR_34 < -((-srcSliceY - srcSliceH)>>c->chrSrcVSubSample);",
"if (!VAR_35) {",
"VAR_32 = srcSliceY + srcSliceH - 1;",
"VAR_34 = VAR_15 + VAR_16 - 1;",
"DEBUG_BUFFERS(\"buffering slice: VAR_32 %d VAR_34 %d\\n\",\nVAR_32, VAR_34);",
"}",
"while(VAR_21 < VAR_32) {",
"const uint8_t *VAR_38= src[0]+(VAR_21 + 1 - srcSliceY)*srcStride[0];",
"const uint8_t *VAR_38= src[3]+(VAR_21 + 1 - srcSliceY)*srcStride[3];",
"VAR_19++;",
"assert(VAR_19 < 2*VAR_13);",
"assert(VAR_21 + 1 - srcSliceY < srcSliceH);",
"assert(VAR_21 + 1 - srcSliceY >= 0);",
"FUNC_0(hyscale)(c, lumPixBuf[ VAR_19 ], VAR_1, VAR_38, VAR_0, VAR_5,\nhLumFilter, hLumFilterPos, VAR_11,\nformatConvBuffer,\npal, 0);",
"if (CONFIG_SWSCALE_ALPHA && alpPixBuf)\nFUNC_0(hyscale)(c, alpPixBuf[ VAR_19 ], VAR_1, VAR_38, VAR_0, VAR_5,\nhLumFilter, hLumFilterPos, VAR_11,\nformatConvBuffer,\npal, 1);",
"VAR_21++;",
"DEBUG_BUFFERS(\"\\t\\tlumBufIndex %d: VAR_21: %d\\n\",\nVAR_19, VAR_21);",
"}",
"while(VAR_22 < VAR_34) {",
"const uint8_t *VAR_38= src[1]+(VAR_22 + 1 - VAR_15)*srcStride[1];",
"const uint8_t *VAR_38= src[2]+(VAR_22 + 1 - VAR_15)*srcStride[2];",
"VAR_20++;",
"assert(VAR_20 < 2*VAR_14);",
"assert(VAR_22 + 1 - VAR_15 < (VAR_16));",
"assert(VAR_22 + 1 - VAR_15 >= 0);",
"if (c->needs_hcscale)\nFUNC_0(hcscale)(c, chrPixBuf[ VAR_20 ], VAR_3, VAR_38, VAR_38, VAR_4, VAR_6,\nhChrFilter, hChrFilterPos, VAR_12,\nformatConvBuffer,\npal);",
"VAR_22++;",
"DEBUG_BUFFERS(\"\\t\\tchrBufIndex %d: VAR_22: %d\\n\",\nVAR_20, VAR_22);",
"}",
"if (VAR_19 >= VAR_13) VAR_19-= VAR_13;",
"if (VAR_20 >= VAR_14) VAR_20-= VAR_14;",
"if (!VAR_35)\nbreak;",
"#if COMPILE_TEMPLATE_MMX\nc->blueDither= ff_dither8[VAR_18&1];",
"if (c->VAR_7 == PIX_FMT_RGB555 || c->VAR_7 == PIX_FMT_BGR555)\nc->greenDither= ff_dither8[VAR_18&1];",
"else\nc->greenDither= ff_dither4[VAR_18&1];",
"c->redDither= ff_dither8[(VAR_18+1)&1];",
"#endif\nif (VAR_18 < VAR_2-2) {",
"const int16_t **VAR_47= (const int16_t **) lumPixBuf + VAR_19 + VAR_29 - VAR_21 + VAR_13;",
"const int16_t **VAR_47= (const int16_t **) chrPixBuf + VAR_20 + VAR_31 - VAR_22 + VAR_14;",
"const int16_t **VAR_47= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + VAR_19 + VAR_29 - VAR_21 + VAR_13 : NULL;",
"#if COMPILE_TEMPLATE_MMX\nint i;",
"if (VAR_8 & SWS_ACCURATE_RND) {",
"int s= APCK_SIZE / 8;",
"for (i=0; i<VAR_9; i+=2) {",
"*(const void**)&lumMmxFilter[s*i ]= VAR_47[i ];",
"*(const void**)&lumMmxFilter[s*i+APCK_PTR2/4 ]= VAR_47[i+(VAR_9>1)];",
"lumMmxFilter[s*i+APCK_COEF/4 ]=\nlumMmxFilter[s*i+APCK_COEF/4+1]= vLumFilter[VAR_18*VAR_9 + i ]\n+ (VAR_9>1 ? vLumFilter[VAR_18*VAR_9 + i + 1]<<16 : 0);",
"if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {",
"*(const void**)&alpMmxFilter[s*i ]= VAR_47[i ];",
"*(const void**)&alpMmxFilter[s*i+APCK_PTR2/4 ]= VAR_47[i+(VAR_9>1)];",
"alpMmxFilter[s*i+APCK_COEF/4 ]=\nalpMmxFilter[s*i+APCK_COEF/4+1]= lumMmxFilter[s*i+APCK_COEF/4 ];",
"}",
"}",
"for (i=0; i<VAR_10; i+=2) {",
"*(const void**)&chrMmxFilter[s*i ]= VAR_47[i ];",
"*(const void**)&chrMmxFilter[s*i+APCK_PTR2/4 ]= VAR_47[i+(VAR_10>1)];",
"chrMmxFilter[s*i+APCK_COEF/4 ]=\nchrMmxFilter[s*i+APCK_COEF/4+1]= vChrFilter[VAR_25*VAR_10 + i ]\n+ (VAR_10>1 ? vChrFilter[VAR_25*VAR_10 + i + 1]<<16 : 0);",
"}",
"} else {",
"for (i=0; i<VAR_9; i++) {",
"lumMmxFilter[4*i+0]= (int32_t)VAR_47[i];",
"lumMmxFilter[4*i+1]= (uint64_t)VAR_47[i] >> 32;",
"lumMmxFilter[4*i+2]=\nlumMmxFilter[4*i+3]=\n((uint16_t)vLumFilter[VAR_18*VAR_9 + i])*0x10001;",
"if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {",
"alpMmxFilter[4*i+0]= (int32_t)VAR_47[i];",
"alpMmxFilter[4*i+1]= (uint64_t)VAR_47[i] >> 32;",
"alpMmxFilter[4*i+2]=\nalpMmxFilter[4*i+3]= lumMmxFilter[4*i+2];",
"}",
"}",
"for (i=0; i<VAR_10; i++) {",
"chrMmxFilter[4*i+0]= (int32_t)VAR_47[i];",
"chrMmxFilter[4*i+1]= (uint64_t)VAR_47[i] >> 32;",
"chrMmxFilter[4*i+2]=\nchrMmxFilter[4*i+3]=\n((uint16_t)vChrFilter[VAR_25*VAR_10 + i])*0x10001;",
"}",
"}",
"#endif\nif (VAR_7 == PIX_FMT_NV12 || VAR_7 == PIX_FMT_NV21) {",
"const int VAR_47= (1<<c->chrDstVSubSample)-1;",
"if (VAR_18&VAR_47) VAR_26= NULL;",
"c->yuv2nv12X(c,\nvLumFilter+VAR_18*VAR_9 , VAR_47, VAR_9,\nvChrFilter+VAR_25*VAR_10, VAR_47, VAR_10,\nVAR_24, VAR_26, VAR_1, VAR_3, VAR_7);",
"} else if (isPlanarYUV(VAR_7) || VAR_7==PIX_FMT_GRAY8) {",
"const int VAR_47= (1<<c->chrDstVSubSample)-1;",
"if ((VAR_18&VAR_47) || isGray(VAR_7)) VAR_26=VAR_27= NULL;",
"if (is16BPS(VAR_7) || isNBPS(VAR_7)) {",
"yuv2yuvX16inC(\nvLumFilter+VAR_18*VAR_9 , VAR_47, VAR_9,\nvChrFilter+VAR_25*VAR_10, VAR_47, VAR_10,\nVAR_47, (uint16_t *) VAR_24, (uint16_t *) VAR_26, (uint16_t *) VAR_27, (uint16_t *) VAR_28, VAR_1, VAR_3,\nVAR_7);",
"} else if (VAR_9 == 1 && VAR_10 == 1) {",
"const int16_t *VAR_42 = VAR_47[0];",
"const int16_t *VAR_43= VAR_47[0];",
"const int16_t *VAR_44= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? VAR_47[0] : NULL;",
"c->yuv2yuv1(c, VAR_42, VAR_43, VAR_44, VAR_24, VAR_26, VAR_27, VAR_28, VAR_1, VAR_3);",
"} else {",
"c->yuv2yuvX(c,\nvLumFilter+VAR_18*VAR_9 , VAR_47, VAR_9,\nvChrFilter+VAR_25*VAR_10, VAR_47, VAR_10,\nVAR_47, VAR_24, VAR_26, VAR_27, VAR_28, VAR_1, VAR_3);",
"}",
"} else {",
"assert(VAR_47 + VAR_9 - 1 < lumPixBuf + VAR_13*2);",
"assert(VAR_47 + VAR_10 - 1 < chrPixBuf + VAR_14*2);",
"if (VAR_9 == 1 && VAR_10 == 2) {",
"int VAR_47= vChrFilter[2*VAR_18+1];",
"if(VAR_8 & SWS_FULL_CHR_H_INT) {",
"yuv2rgbXinC_full(c,\nvLumFilter+VAR_18*VAR_9, VAR_47, VAR_9,\nvChrFilter+VAR_18*VAR_10, VAR_47, VAR_10,\nVAR_47, VAR_24, VAR_1, VAR_18);",
"} else {",
"c->yuv2packed1(c, *VAR_47, *VAR_47, *(VAR_47+1),\nalpPixBuf ? *VAR_47 : NULL,\nVAR_24, VAR_1, VAR_47, VAR_7, VAR_8, VAR_18);",
"}",
"} else if (VAR_9 == 2 && VAR_10 == 2) {",
"int VAR_46= vLumFilter[2*VAR_18+1];",
"int VAR_47= vChrFilter[2*VAR_18+1];",
"lumMmxFilter[2]=\nlumMmxFilter[3]= vLumFilter[2*VAR_18 ]*0x10001;",
"chrMmxFilter[2]=\nchrMmxFilter[3]= vChrFilter[2*VAR_25]*0x10001;",
"if(VAR_8 & SWS_FULL_CHR_H_INT) {",
"yuv2rgbXinC_full(c,\nvLumFilter+VAR_18*VAR_9, VAR_47, VAR_9,\nvChrFilter+VAR_18*VAR_10, VAR_47, VAR_10,\nVAR_47, VAR_24, VAR_1, VAR_18);",
"} else {",
"c->yuv2packed2(c, *VAR_47, *(VAR_47+1), *VAR_47, *(VAR_47+1),\nalpPixBuf ? *VAR_47 : NULL, alpPixBuf ? *(VAR_47+1) : NULL,\nVAR_24, VAR_1, VAR_46, VAR_47, VAR_18);",
"}",
"} else {",
"if(VAR_8 & SWS_FULL_CHR_H_INT) {",
"yuv2rgbXinC_full(c,\nvLumFilter+VAR_18*VAR_9, VAR_47, VAR_9,\nvChrFilter+VAR_18*VAR_10, VAR_47, VAR_10,\nVAR_47, VAR_24, VAR_1, VAR_18);",
"} else {",
"c->yuv2packedX(c,\nvLumFilter+VAR_18*VAR_9, VAR_47, VAR_9,\nvChrFilter+VAR_18*VAR_10, VAR_47, VAR_10,\nVAR_47, VAR_24, VAR_1, VAR_18);",
"}",
"}",
"}",
"} else {",
"const int16_t **VAR_47= (const int16_t **)lumPixBuf + VAR_19 + VAR_29 - VAR_21 + VAR_13;",
"const int16_t **VAR_47= (const int16_t **)chrPixBuf + VAR_20 + VAR_31 - VAR_22 + VAR_14;",
"const int16_t **VAR_47= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **)alpPixBuf + VAR_19 + VAR_29 - VAR_21 + VAR_13 : NULL;",
"if (VAR_7 == PIX_FMT_NV12 || VAR_7 == PIX_FMT_NV21) {",
"const int VAR_47= (1<<c->chrDstVSubSample)-1;",
"if (VAR_18&VAR_47) VAR_26= NULL;",
"yuv2nv12XinC(\nvLumFilter+VAR_18*VAR_9 , VAR_47, VAR_9,\nvChrFilter+VAR_25*VAR_10, VAR_47, VAR_10,\nVAR_24, VAR_26, VAR_1, VAR_3, VAR_7);",
"} else if (isPlanarYUV(VAR_7) || VAR_7==PIX_FMT_GRAY8) {",
"const int VAR_47= (1<<c->chrDstVSubSample)-1;",
"if ((VAR_18&VAR_47) || isGray(VAR_7)) VAR_26=VAR_27= NULL;",
"if (is16BPS(VAR_7) || isNBPS(VAR_7)) {",
"yuv2yuvX16inC(\nvLumFilter+VAR_18*VAR_9 , VAR_47, VAR_9,\nvChrFilter+VAR_25*VAR_10, VAR_47, VAR_10,\nVAR_47, (uint16_t *) VAR_24, (uint16_t *) VAR_26, (uint16_t *) VAR_27, (uint16_t *) VAR_28, VAR_1, VAR_3,\nVAR_7);",
"} else {",
"yuv2yuvXinC(\nvLumFilter+VAR_18*VAR_9 , VAR_47, VAR_9,\nvChrFilter+VAR_25*VAR_10, VAR_47, VAR_10,\nVAR_47, VAR_24, VAR_26, VAR_27, VAR_28, VAR_1, VAR_3);",
"}",
"} else {",
"assert(VAR_47 + VAR_9 - 1 < lumPixBuf + VAR_13*2);",
"assert(VAR_47 + VAR_10 - 1 < chrPixBuf + VAR_14*2);",
"if(VAR_8 & SWS_FULL_CHR_H_INT) {",
"yuv2rgbXinC_full(c,\nvLumFilter+VAR_18*VAR_9, VAR_47, VAR_9,\nvChrFilter+VAR_18*VAR_10, VAR_47, VAR_10,\nVAR_47, VAR_24, VAR_1, VAR_18);",
"} else {",
"yuv2packedXinC(c,\nvLumFilter+VAR_18*VAR_9, VAR_47, VAR_9,\nvChrFilter+VAR_18*VAR_10, VAR_47, VAR_10,\nVAR_47, VAR_24, VAR_1, VAR_18);",
"}",
"}",
"}",
"}",
"if ((VAR_7 == PIX_FMT_YUVA420P) && !alpPixBuf)\nfillPlane(dst[3], dstStride[3], VAR_1, VAR_18-VAR_17, VAR_17, 255);",
"#if COMPILE_TEMPLATE_MMX\nif (VAR_8 & SWS_CPU_CAPS_MMX2 ) __asm__ volatile(\"sfence\":::\"memory\");",
"if (VAR_8 & SWS_CPU_CAPS_3DNOW) __asm__ volatile(\"femms\" :::\"memory\");",
"else __asm__ volatile(\"emms\" :::\"memory\");",
"#endif\nc->VAR_18= VAR_18;",
"c->VAR_19= VAR_19;",
"c->VAR_20= VAR_20;",
"c->VAR_21= VAR_21;",
"c->VAR_22= VAR_22;",
"return VAR_18 - VAR_17;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95,
97,
99,
101
],
[
103,
105,
107,
109
],
[
111
],
[
113
],
[
115
],
[
119,
121,
123
],
[
125,
127
],
[
129,
131
],
[
135
],
[
137
],
[
139
],
[
141,
143
],
[
145
],
[
147
],
[
149
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
211
],
[
213
],
[
215
],
[
217
],
[
221
],
[
223,
225
],
[
227,
229
],
[
235
],
[
239
],
[
241
],
[
243
],
[
245,
247
],
[
249
],
[
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
],
[
313,
315,
317,
319,
321
],
[
323
],
[
325,
327
],
[
329
],
[
333
],
[
335
],
[
337,
339
],
[
343,
345
],
[
347,
349
],
[
351,
353
],
[
355
],
[
357,
359
],
[
361
],
[
363
],
[
365
],
[
367,
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381,
383,
385
],
[
387
],
[
389
],
[
391
],
[
393,
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407,
409,
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
423,
425,
427
],
[
429
],
[
431
],
[
433
],
[
435,
437
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
449,
451,
453
],
[
455
],
[
457
],
[
459,
461
],
[
463
],
[
465
],
[
467,
469,
471,
473
],
[
475
],
[
477
],
[
479
],
[
481
],
[
483,
485,
487,
489,
491
],
[
493
],
[
495
],
[
497
],
[
499
],
[
501
],
[
503
],
[
505,
507,
509,
511
],
[
513
],
[
515
],
[
517
],
[
519
],
[
521
],
[
523
],
[
525
],
[
527,
529,
531,
533
],
[
535
],
[
537,
539,
541
],
[
543
],
[
545
],
[
547
],
[
549
],
[
551,
553
],
[
555,
557
],
[
559
],
[
561,
563,
565,
567
],
[
569
],
[
571,
573,
575
],
[
577
],
[
579
],
[
581
],
[
583,
585,
587,
589
],
[
591
],
[
593,
595,
597,
599
],
[
601
],
[
603
],
[
605
],
[
607
],
[
609
],
[
611
],
[
613
],
[
615
],
[
617
],
[
619
],
[
621,
623,
625,
627
],
[
629
],
[
631
],
[
633
],
[
635
],
[
637,
639,
641,
643,
645
],
[
647
],
[
649,
651,
653,
655
],
[
657
],
[
659
],
[
661
],
[
663
],
[
665
],
[
667,
669,
671,
673
],
[
675
],
[
677,
679,
681,
683
],
[
685
],
[
687
],
[
689
],
[
691
],
[
695,
697
],
[
701,
703
],
[
707
],
[
709
],
[
711,
715
],
[
717
],
[
719
],
[
721
],
[
723
],
[
727
],
[
729
]
] |
26,034 | static inline int wv_unpack_mono(WavpackFrameContext *s, GetBitContext *gb,
void *dst, const int type)
{
int i, j, count = 0;
int last, t;
int A, S, T;
int pos = s->pos;
uint32_t crc = s->sc.crc;
uint32_t crc_extra_bits = s->extra_sc.crc;
int16_t *dst16 = dst;
int32_t *dst32 = dst;
float *dstfl = dst;
s->one = s->zero = s->zeroes = 0;
do {
T = wv_get_value(s, gb, 0, &last);
S = 0;
if (last)
break;
for (i = 0; i < s->terms; i++) {
t = s->decorr[i].value;
if (t > 8) {
if (t & 1)
A = 2U * s->decorr[i].samplesA[0] - s->decorr[i].samplesA[1];
else
A = (int)(3U * s->decorr[i].samplesA[0] - s->decorr[i].samplesA[1]) >> 1;
s->decorr[i].samplesA[1] = s->decorr[i].samplesA[0];
j = 0;
} else {
A = s->decorr[i].samplesA[pos];
j = (pos + t) & 7;
}
if (type != AV_SAMPLE_FMT_S16P)
S = T + ((s->decorr[i].weightA * (int64_t)A + 512) >> 10);
else
S = T + ((s->decorr[i].weightA * A + 512) >> 10);
if (A && T)
s->decorr[i].weightA -= ((((T ^ A) >> 30) & 2) - 1) * s->decorr[i].delta;
s->decorr[i].samplesA[j] = T = S;
}
pos = (pos + 1) & 7;
crc = crc * 3 + S;
if (type == AV_SAMPLE_FMT_FLTP) {
*dstfl++ = wv_get_value_float(s, &crc_extra_bits, S);
} else if (type == AV_SAMPLE_FMT_S32P) {
*dst32++ = wv_get_value_integer(s, &crc_extra_bits, S);
} else {
*dst16++ = wv_get_value_integer(s, &crc_extra_bits, S);
}
count++;
} while (!last && count < s->samples);
wv_reset_saved_context(s);
if (last && count < s->samples) {
int size = av_get_bytes_per_sample(type);
memset((uint8_t*)dst + count*size, 0, (s->samples-count)*size);
}
if (s->avctx->err_recognition & AV_EF_CRCCHECK) {
int ret = wv_check_crc(s, crc, crc_extra_bits);
if (ret < 0 && s->avctx->err_recognition & AV_EF_EXPLODE)
return ret;
}
return 0;
}
| true | FFmpeg | d90c5bf10559554d6f9cd1dfb90767b991b76d5d | static inline int wv_unpack_mono(WavpackFrameContext *s, GetBitContext *gb,
void *dst, const int type)
{
int i, j, count = 0;
int last, t;
int A, S, T;
int pos = s->pos;
uint32_t crc = s->sc.crc;
uint32_t crc_extra_bits = s->extra_sc.crc;
int16_t *dst16 = dst;
int32_t *dst32 = dst;
float *dstfl = dst;
s->one = s->zero = s->zeroes = 0;
do {
T = wv_get_value(s, gb, 0, &last);
S = 0;
if (last)
break;
for (i = 0; i < s->terms; i++) {
t = s->decorr[i].value;
if (t > 8) {
if (t & 1)
A = 2U * s->decorr[i].samplesA[0] - s->decorr[i].samplesA[1];
else
A = (int)(3U * s->decorr[i].samplesA[0] - s->decorr[i].samplesA[1]) >> 1;
s->decorr[i].samplesA[1] = s->decorr[i].samplesA[0];
j = 0;
} else {
A = s->decorr[i].samplesA[pos];
j = (pos + t) & 7;
}
if (type != AV_SAMPLE_FMT_S16P)
S = T + ((s->decorr[i].weightA * (int64_t)A + 512) >> 10);
else
S = T + ((s->decorr[i].weightA * A + 512) >> 10);
if (A && T)
s->decorr[i].weightA -= ((((T ^ A) >> 30) & 2) - 1) * s->decorr[i].delta;
s->decorr[i].samplesA[j] = T = S;
}
pos = (pos + 1) & 7;
crc = crc * 3 + S;
if (type == AV_SAMPLE_FMT_FLTP) {
*dstfl++ = wv_get_value_float(s, &crc_extra_bits, S);
} else if (type == AV_SAMPLE_FMT_S32P) {
*dst32++ = wv_get_value_integer(s, &crc_extra_bits, S);
} else {
*dst16++ = wv_get_value_integer(s, &crc_extra_bits, S);
}
count++;
} while (!last && count < s->samples);
wv_reset_saved_context(s);
if (last && count < s->samples) {
int size = av_get_bytes_per_sample(type);
memset((uint8_t*)dst + count*size, 0, (s->samples-count)*size);
}
if (s->avctx->err_recognition & AV_EF_CRCCHECK) {
int ret = wv_check_crc(s, crc, crc_extra_bits);
if (ret < 0 && s->avctx->err_recognition & AV_EF_EXPLODE)
return ret;
}
return 0;
}
| {
"code": [
" S = T + ((s->decorr[i].weightA * A + 512) >> 10);"
],
"line_no": [
71
]
} | static inline int FUNC_0(WavpackFrameContext *VAR_0, GetBitContext *VAR_1,
void *VAR_2, const int VAR_3)
{
int VAR_4, VAR_5, VAR_6 = 0;
int VAR_7, VAR_8;
int VAR_9, VAR_10, VAR_11;
int VAR_12 = VAR_0->VAR_12;
uint32_t crc = VAR_0->sc.crc;
uint32_t crc_extra_bits = VAR_0->extra_sc.crc;
int16_t *dst16 = VAR_2;
int32_t *dst32 = VAR_2;
float *VAR_13 = VAR_2;
VAR_0->one = VAR_0->zero = VAR_0->zeroes = 0;
do {
VAR_11 = wv_get_value(VAR_0, VAR_1, 0, &VAR_7);
VAR_10 = 0;
if (VAR_7)
break;
for (VAR_4 = 0; VAR_4 < VAR_0->terms; VAR_4++) {
VAR_8 = VAR_0->decorr[VAR_4].value;
if (VAR_8 > 8) {
if (VAR_8 & 1)
VAR_9 = 2U * VAR_0->decorr[VAR_4].samplesA[0] - VAR_0->decorr[VAR_4].samplesA[1];
else
VAR_9 = (int)(3U * VAR_0->decorr[VAR_4].samplesA[0] - VAR_0->decorr[VAR_4].samplesA[1]) >> 1;
VAR_0->decorr[VAR_4].samplesA[1] = VAR_0->decorr[VAR_4].samplesA[0];
VAR_5 = 0;
} else {
VAR_9 = VAR_0->decorr[VAR_4].samplesA[VAR_12];
VAR_5 = (VAR_12 + VAR_8) & 7;
}
if (VAR_3 != AV_SAMPLE_FMT_S16P)
VAR_10 = VAR_11 + ((VAR_0->decorr[VAR_4].weightA * (int64_t)VAR_9 + 512) >> 10);
else
VAR_10 = VAR_11 + ((VAR_0->decorr[VAR_4].weightA * VAR_9 + 512) >> 10);
if (VAR_9 && VAR_11)
VAR_0->decorr[VAR_4].weightA -= ((((VAR_11 ^ VAR_9) >> 30) & 2) - 1) * VAR_0->decorr[VAR_4].delta;
VAR_0->decorr[VAR_4].samplesA[VAR_5] = VAR_11 = VAR_10;
}
VAR_12 = (VAR_12 + 1) & 7;
crc = crc * 3 + VAR_10;
if (VAR_3 == AV_SAMPLE_FMT_FLTP) {
*VAR_13++ = wv_get_value_float(VAR_0, &crc_extra_bits, VAR_10);
} else if (VAR_3 == AV_SAMPLE_FMT_S32P) {
*dst32++ = wv_get_value_integer(VAR_0, &crc_extra_bits, VAR_10);
} else {
*dst16++ = wv_get_value_integer(VAR_0, &crc_extra_bits, VAR_10);
}
VAR_6++;
} while (!VAR_7 && VAR_6 < VAR_0->samples);
wv_reset_saved_context(VAR_0);
if (VAR_7 && VAR_6 < VAR_0->samples) {
int VAR_14 = av_get_bytes_per_sample(VAR_3);
memset((uint8_t*)VAR_2 + VAR_6*VAR_14, 0, (VAR_0->samples-VAR_6)*VAR_14);
}
if (VAR_0->avctx->err_recognition & AV_EF_CRCCHECK) {
int VAR_15 = wv_check_crc(VAR_0, crc, crc_extra_bits);
if (VAR_15 < 0 && VAR_0->avctx->err_recognition & AV_EF_EXPLODE)
return VAR_15;
}
return 0;
}
| [
"static inline int FUNC_0(WavpackFrameContext *VAR_0, GetBitContext *VAR_1,\nvoid *VAR_2, const int VAR_3)\n{",
"int VAR_4, VAR_5, VAR_6 = 0;",
"int VAR_7, VAR_8;",
"int VAR_9, VAR_10, VAR_11;",
"int VAR_12 = VAR_0->VAR_12;",
"uint32_t crc = VAR_0->sc.crc;",
"uint32_t crc_extra_bits = VAR_0->extra_sc.crc;",
"int16_t *dst16 = VAR_2;",
"int32_t *dst32 = VAR_2;",
"float *VAR_13 = VAR_2;",
"VAR_0->one = VAR_0->zero = VAR_0->zeroes = 0;",
"do {",
"VAR_11 = wv_get_value(VAR_0, VAR_1, 0, &VAR_7);",
"VAR_10 = 0;",
"if (VAR_7)\nbreak;",
"for (VAR_4 = 0; VAR_4 < VAR_0->terms; VAR_4++) {",
"VAR_8 = VAR_0->decorr[VAR_4].value;",
"if (VAR_8 > 8) {",
"if (VAR_8 & 1)\nVAR_9 = 2U * VAR_0->decorr[VAR_4].samplesA[0] - VAR_0->decorr[VAR_4].samplesA[1];",
"else\nVAR_9 = (int)(3U * VAR_0->decorr[VAR_4].samplesA[0] - VAR_0->decorr[VAR_4].samplesA[1]) >> 1;",
"VAR_0->decorr[VAR_4].samplesA[1] = VAR_0->decorr[VAR_4].samplesA[0];",
"VAR_5 = 0;",
"} else {",
"VAR_9 = VAR_0->decorr[VAR_4].samplesA[VAR_12];",
"VAR_5 = (VAR_12 + VAR_8) & 7;",
"}",
"if (VAR_3 != AV_SAMPLE_FMT_S16P)\nVAR_10 = VAR_11 + ((VAR_0->decorr[VAR_4].weightA * (int64_t)VAR_9 + 512) >> 10);",
"else\nVAR_10 = VAR_11 + ((VAR_0->decorr[VAR_4].weightA * VAR_9 + 512) >> 10);",
"if (VAR_9 && VAR_11)\nVAR_0->decorr[VAR_4].weightA -= ((((VAR_11 ^ VAR_9) >> 30) & 2) - 1) * VAR_0->decorr[VAR_4].delta;",
"VAR_0->decorr[VAR_4].samplesA[VAR_5] = VAR_11 = VAR_10;",
"}",
"VAR_12 = (VAR_12 + 1) & 7;",
"crc = crc * 3 + VAR_10;",
"if (VAR_3 == AV_SAMPLE_FMT_FLTP) {",
"*VAR_13++ = wv_get_value_float(VAR_0, &crc_extra_bits, VAR_10);",
"} else if (VAR_3 == AV_SAMPLE_FMT_S32P) {",
"*dst32++ = wv_get_value_integer(VAR_0, &crc_extra_bits, VAR_10);",
"} else {",
"*dst16++ = wv_get_value_integer(VAR_0, &crc_extra_bits, VAR_10);",
"}",
"VAR_6++;",
"} while (!VAR_7 && VAR_6 < VAR_0->samples);",
"wv_reset_saved_context(VAR_0);",
"if (VAR_7 && VAR_6 < VAR_0->samples) {",
"int VAR_14 = av_get_bytes_per_sample(VAR_3);",
"memset((uint8_t*)VAR_2 + VAR_6*VAR_14, 0, (VAR_0->samples-VAR_6)*VAR_14);",
"}",
"if (VAR_0->avctx->err_recognition & AV_EF_CRCCHECK) {",
"int VAR_15 = wv_check_crc(VAR_0, crc, crc_extra_bits);",
"if (VAR_15 < 0 && VAR_0->avctx->err_recognition & AV_EF_EXPLODE)\nreturn VAR_15;",
"}",
"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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49,
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69,
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125,
127
],
[
129
],
[
133
],
[
135
]
] |
26,035 | static void mmu_init (CPUMIPSState *env, const mips_def_t *def)
{
env->tlb = qemu_mallocz(sizeof(CPUMIPSTLBContext));
switch (def->mmu_type) {
case MMU_TYPE_NONE:
no_mmu_init(env, def);
break;
case MMU_TYPE_R4000:
r4k_mmu_init(env, def);
break;
case MMU_TYPE_FMT:
fixed_mmu_init(env, def);
break;
case MMU_TYPE_R3000:
case MMU_TYPE_R6000:
case MMU_TYPE_R8000:
default:
cpu_abort(env, "MMU type not supported\n");
}
env->CP0_Random = env->tlb->nb_tlb - 1;
env->tlb->tlb_in_use = env->tlb->nb_tlb;
}
| true | qemu | 51cc2e783af5586b2e742ce9e5b2762dc50ad325 | static void mmu_init (CPUMIPSState *env, const mips_def_t *def)
{
env->tlb = qemu_mallocz(sizeof(CPUMIPSTLBContext));
switch (def->mmu_type) {
case MMU_TYPE_NONE:
no_mmu_init(env, def);
break;
case MMU_TYPE_R4000:
r4k_mmu_init(env, def);
break;
case MMU_TYPE_FMT:
fixed_mmu_init(env, def);
break;
case MMU_TYPE_R3000:
case MMU_TYPE_R6000:
case MMU_TYPE_R8000:
default:
cpu_abort(env, "MMU type not supported\n");
}
env->CP0_Random = env->tlb->nb_tlb - 1;
env->tlb->tlb_in_use = env->tlb->nb_tlb;
}
| {
"code": [
" env->CP0_Random = env->tlb->nb_tlb - 1;",
" env->tlb->tlb_in_use = env->tlb->nb_tlb;"
],
"line_no": [
41,
43
]
} | static void FUNC_0 (CPUMIPSState *VAR_0, const mips_def_t *VAR_1)
{
VAR_0->tlb = qemu_mallocz(sizeof(CPUMIPSTLBContext));
switch (VAR_1->mmu_type) {
case MMU_TYPE_NONE:
no_mmu_init(VAR_0, VAR_1);
break;
case MMU_TYPE_R4000:
r4k_mmu_init(VAR_0, VAR_1);
break;
case MMU_TYPE_FMT:
fixed_mmu_init(VAR_0, VAR_1);
break;
case MMU_TYPE_R3000:
case MMU_TYPE_R6000:
case MMU_TYPE_R8000:
default:
cpu_abort(VAR_0, "MMU type not supported\n");
}
VAR_0->CP0_Random = VAR_0->tlb->nb_tlb - 1;
VAR_0->tlb->tlb_in_use = VAR_0->tlb->nb_tlb;
}
| [
"static void FUNC_0 (CPUMIPSState *VAR_0, const mips_def_t *VAR_1)\n{",
"VAR_0->tlb = qemu_mallocz(sizeof(CPUMIPSTLBContext));",
"switch (VAR_1->mmu_type) {",
"case MMU_TYPE_NONE:\nno_mmu_init(VAR_0, VAR_1);",
"break;",
"case MMU_TYPE_R4000:\nr4k_mmu_init(VAR_0, VAR_1);",
"break;",
"case MMU_TYPE_FMT:\nfixed_mmu_init(VAR_0, VAR_1);",
"break;",
"case MMU_TYPE_R3000:\ncase MMU_TYPE_R6000:\ncase MMU_TYPE_R8000:\ndefault:\ncpu_abort(VAR_0, \"MMU type not supported\\n\");",
"}",
"VAR_0->CP0_Random = VAR_0->tlb->nb_tlb - 1;",
"VAR_0->tlb->tlb_in_use = VAR_0->tlb->nb_tlb;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
15
],
[
17,
19
],
[
21
],
[
23,
25
],
[
27
],
[
29,
31,
33,
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
]
] |
26,036 | static void sample_queue_push(HintSampleQueue *queue, uint8_t *data, int size,
int sample)
{
/* No need to keep track of smaller samples, since describing them
* with immediates is more efficient. */
if (size <= 14)
return;
if (!queue->samples || queue->len >= queue->size) {
HintSample *samples;
samples = av_realloc(queue->samples, sizeof(HintSample) * (queue->size + 10));
if (!samples)
return;
queue->size += 10;
queue->samples = samples;
}
queue->samples[queue->len].data = data;
queue->samples[queue->len].size = size;
queue->samples[queue->len].sample_number = sample;
queue->samples[queue->len].offset = 0;
queue->samples[queue->len].own_data = 0;
queue->len++;
}
| true | FFmpeg | 05b7a635dc1e5266fb367ce8b0019a0830317879 | static void sample_queue_push(HintSampleQueue *queue, uint8_t *data, int size,
int sample)
{
if (size <= 14)
return;
if (!queue->samples || queue->len >= queue->size) {
HintSample *samples;
samples = av_realloc(queue->samples, sizeof(HintSample) * (queue->size + 10));
if (!samples)
return;
queue->size += 10;
queue->samples = samples;
}
queue->samples[queue->len].data = data;
queue->samples[queue->len].size = size;
queue->samples[queue->len].sample_number = sample;
queue->samples[queue->len].offset = 0;
queue->samples[queue->len].own_data = 0;
queue->len++;
}
| {
"code": [
" samples = av_realloc(queue->samples, sizeof(HintSample) * (queue->size + 10));"
],
"line_no": [
19
]
} | static void FUNC_0(HintSampleQueue *VAR_0, uint8_t *VAR_1, int VAR_2,
int VAR_3)
{
if (VAR_2 <= 14)
return;
if (!VAR_0->samples || VAR_0->len >= VAR_0->VAR_2) {
HintSample *samples;
samples = av_realloc(VAR_0->samples, sizeof(HintSample) * (VAR_0->VAR_2 + 10));
if (!samples)
return;
VAR_0->VAR_2 += 10;
VAR_0->samples = samples;
}
VAR_0->samples[VAR_0->len].VAR_1 = VAR_1;
VAR_0->samples[VAR_0->len].VAR_2 = VAR_2;
VAR_0->samples[VAR_0->len].sample_number = VAR_3;
VAR_0->samples[VAR_0->len].offset = 0;
VAR_0->samples[VAR_0->len].own_data = 0;
VAR_0->len++;
}
| [
"static void FUNC_0(HintSampleQueue *VAR_0, uint8_t *VAR_1, int VAR_2,\nint VAR_3)\n{",
"if (VAR_2 <= 14)\nreturn;",
"if (!VAR_0->samples || VAR_0->len >= VAR_0->VAR_2) {",
"HintSample *samples;",
"samples = av_realloc(VAR_0->samples, sizeof(HintSample) * (VAR_0->VAR_2 + 10));",
"if (!samples)\nreturn;",
"VAR_0->VAR_2 += 10;",
"VAR_0->samples = samples;",
"}",
"VAR_0->samples[VAR_0->len].VAR_1 = VAR_1;",
"VAR_0->samples[VAR_0->len].VAR_2 = VAR_2;",
"VAR_0->samples[VAR_0->len].sample_number = VAR_3;",
"VAR_0->samples[VAR_0->len].offset = 0;",
"VAR_0->samples[VAR_0->len].own_data = 0;",
"VAR_0->len++;",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
11,
13
],
[
15
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
]
] |
26,039 | static void gen_spr_power8_tce_address_control(CPUPPCState *env)
{
spr_register(env, SPR_TAR, "TAR",
&spr_read_generic, &spr_write_generic,
&spr_read_generic, &spr_write_generic,
0x00000000);
}
| true | qemu | 45ed0be146b7433d1123f09eb1a984210a311625 | static void gen_spr_power8_tce_address_control(CPUPPCState *env)
{
spr_register(env, SPR_TAR, "TAR",
&spr_read_generic, &spr_write_generic,
&spr_read_generic, &spr_write_generic,
0x00000000);
}
| {
"code": [
" &spr_read_generic, &spr_write_generic,"
],
"line_no": [
7
]
} | static void FUNC_0(CPUPPCState *VAR_0)
{
spr_register(VAR_0, SPR_TAR, "TAR",
&spr_read_generic, &spr_write_generic,
&spr_read_generic, &spr_write_generic,
0x00000000);
}
| [
"static void FUNC_0(CPUPPCState *VAR_0)\n{",
"spr_register(VAR_0, SPR_TAR, \"TAR\",\n&spr_read_generic, &spr_write_generic,\n&spr_read_generic, &spr_write_generic,\n0x00000000);",
"}"
] | [
0,
1,
0
] | [
[
1,
3
],
[
5,
7,
9,
11
],
[
13
]
] |
26,040 | static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
int n, int coded, int intra)
{
int level, i, last, run;
int dc_pred_dir;
RLTable * rl;
RL_VLC_ELEM * rl_vlc;
const UINT8 * scan_table;
int qmul, qadd;
if(intra) {
/* DC coef */
if(s->partitioned_frame){
level = s->dc_val[0][ s->block_index[n] ];
if(n<4) level= (level + (s->y_dc_scale>>1))/s->y_dc_scale; //FIXME optimizs
else level= (level + (s->c_dc_scale>>1))/s->c_dc_scale;
dc_pred_dir= (s->pred_dir_table[s->mb_x + s->mb_y*s->mb_width]<<n)&32;
}else{
level = mpeg4_decode_dc(s, n, &dc_pred_dir);
if (level < 0)
return -1;
}
block[0] = level;
i = 0;
if (!coded)
goto not_coded;
rl = &rl_intra;
rl_vlc = rl_intra.rl_vlc[0];
if (s->ac_pred) {
if (dc_pred_dir == 0)
scan_table = s->intra_v_scantable.permutated; /* left */
else
scan_table = s->intra_h_scantable.permutated; /* top */
} else {
scan_table = s->intra_scantable.permutated;
}
qmul=1;
qadd=0;
} else {
i = -1;
if (!coded) {
s->block_last_index[n] = i;
return 0;
}
rl = &rl_inter;
scan_table = s->intra_scantable.permutated;
if(s->mpeg_quant){
qmul=1;
qadd=0;
rl_vlc = rl_inter.rl_vlc[0];
}else{
qmul = s->qscale << 1;
qadd = (s->qscale - 1) | 1;
rl_vlc = rl_inter.rl_vlc[s->qscale];
}
}
{
OPEN_READER(re, &s->gb);
for(;;) {
UPDATE_CACHE(re, &s->gb);
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2);
if (level==0) {
int cache;
cache= GET_CACHE(re, &s->gb);
/* escape */
if (cache&0x80000000) {
if (cache&0x40000000) {
/* third escape */
SKIP_CACHE(re, &s->gb, 2);
last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
run= SHOW_UBITS(re, &s->gb, 6); LAST_SKIP_CACHE(re, &s->gb, 6);
SKIP_COUNTER(re, &s->gb, 2+1+6);
UPDATE_CACHE(re, &s->gb);
if(SHOW_UBITS(re, &s->gb, 1)==0){
fprintf(stderr, "1. marker bit missing in 3. esc\n");
return -1;
}; SKIP_CACHE(re, &s->gb, 1);
level= SHOW_SBITS(re, &s->gb, 12); SKIP_CACHE(re, &s->gb, 12);
if(SHOW_UBITS(re, &s->gb, 1)==0){
fprintf(stderr, "2. marker bit missing in 3. esc\n");
return -1;
}; LAST_SKIP_CACHE(re, &s->gb, 1);
SKIP_COUNTER(re, &s->gb, 1+12+1);
if(level*s->qscale>1024 || level*s->qscale<-1024){
fprintf(stderr, "|level| overflow in 3. esc, qp=%d\n", s->qscale);
return -1;
}
#if 1
{
const int abs_level= ABS(level);
if(abs_level<=MAX_LEVEL && run<=MAX_RUN && ((s->workaround_bugs&FF_BUG_AC_VLC)==0)){
const int run1= run - rl->max_run[last][abs_level] - 1;
if(abs_level <= rl->max_level[last][run]){
fprintf(stderr, "illegal 3. esc, vlc encoding possible\n");
return -1;
}
if(abs_level <= rl->max_level[last][run]*2){
fprintf(stderr, "illegal 3. esc, esc 1 encoding possible\n");
return -1;
}
if(run1 >= 0 && abs_level <= rl->max_level[last][run1]){
fprintf(stderr, "illegal 3. esc, esc 2 encoding possible\n");
return -1;
}
}
}
#endif
if (level>0) level= level * qmul + qadd;
else level= level * qmul - qadd;
i+= run + 1;
if(last) i+=192;
} else {
/* second escape */
#if MIN_CACHE_BITS < 20
LAST_SKIP_BITS(re, &s->gb, 2);
UPDATE_CACHE(re, &s->gb);
#else
SKIP_BITS(re, &s->gb, 2);
#endif
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2);
i+= run + rl->max_run[run>>7][level/qmul] +1; //FIXME opt indexing
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
}
} else {
/* first escape */
#if MIN_CACHE_BITS < 19
LAST_SKIP_BITS(re, &s->gb, 1);
UPDATE_CACHE(re, &s->gb);
#else
SKIP_BITS(re, &s->gb, 1);
#endif
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2);
i+= run;
level = level + rl->max_level[run>>7][(run-1)&63] * qmul;//FIXME opt indexing
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
}
} else {
i+= run;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
}
if (i > 62){
i-= 192;
if(i&(~63)){
fprintf(stderr, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
block[scan_table[i]] = level;
break;
}
block[scan_table[i]] = level;
}
CLOSE_READER(re, &s->gb);
}
not_coded:
if (s->mb_intra) {
mpeg4_pred_ac(s, block, n, dc_pred_dir);
if (s->ac_pred) {
i = 63; /* XXX: not optimal */
}
}
s->block_last_index[n] = i;
return 0;
}
| true | FFmpeg | ce3bcaeda1dec8bdc25d4daf5a8358feafe5d124 | static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
int n, int coded, int intra)
{
int level, i, last, run;
int dc_pred_dir;
RLTable * rl;
RL_VLC_ELEM * rl_vlc;
const UINT8 * scan_table;
int qmul, qadd;
if(intra) {
if(s->partitioned_frame){
level = s->dc_val[0][ s->block_index[n] ];
if(n<4) level= (level + (s->y_dc_scale>>1))/s->y_dc_scale;
else level= (level + (s->c_dc_scale>>1))/s->c_dc_scale;
dc_pred_dir= (s->pred_dir_table[s->mb_x + s->mb_y*s->mb_width]<<n)&32;
}else{
level = mpeg4_decode_dc(s, n, &dc_pred_dir);
if (level < 0)
return -1;
}
block[0] = level;
i = 0;
if (!coded)
goto not_coded;
rl = &rl_intra;
rl_vlc = rl_intra.rl_vlc[0];
if (s->ac_pred) {
if (dc_pred_dir == 0)
scan_table = s->intra_v_scantable.permutated;
else
scan_table = s->intra_h_scantable.permutated;
} else {
scan_table = s->intra_scantable.permutated;
}
qmul=1;
qadd=0;
} else {
i = -1;
if (!coded) {
s->block_last_index[n] = i;
return 0;
}
rl = &rl_inter;
scan_table = s->intra_scantable.permutated;
if(s->mpeg_quant){
qmul=1;
qadd=0;
rl_vlc = rl_inter.rl_vlc[0];
}else{
qmul = s->qscale << 1;
qadd = (s->qscale - 1) | 1;
rl_vlc = rl_inter.rl_vlc[s->qscale];
}
}
{
OPEN_READER(re, &s->gb);
for(;;) {
UPDATE_CACHE(re, &s->gb);
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2);
if (level==0) {
int cache;
cache= GET_CACHE(re, &s->gb);
if (cache&0x80000000) {
if (cache&0x40000000) {
SKIP_CACHE(re, &s->gb, 2);
last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
run= SHOW_UBITS(re, &s->gb, 6); LAST_SKIP_CACHE(re, &s->gb, 6);
SKIP_COUNTER(re, &s->gb, 2+1+6);
UPDATE_CACHE(re, &s->gb);
if(SHOW_UBITS(re, &s->gb, 1)==0){
fprintf(stderr, "1. marker bit missing in 3. esc\n");
return -1;
}; SKIP_CACHE(re, &s->gb, 1);
level= SHOW_SBITS(re, &s->gb, 12); SKIP_CACHE(re, &s->gb, 12);
if(SHOW_UBITS(re, &s->gb, 1)==0){
fprintf(stderr, "2. marker bit missing in 3. esc\n");
return -1;
}; LAST_SKIP_CACHE(re, &s->gb, 1);
SKIP_COUNTER(re, &s->gb, 1+12+1);
if(level*s->qscale>1024 || level*s->qscale<-1024){
fprintf(stderr, "|level| overflow in 3. esc, qp=%d\n", s->qscale);
return -1;
}
#if 1
{
const int abs_level= ABS(level);
if(abs_level<=MAX_LEVEL && run<=MAX_RUN && ((s->workaround_bugs&FF_BUG_AC_VLC)==0)){
const int run1= run - rl->max_run[last][abs_level] - 1;
if(abs_level <= rl->max_level[last][run]){
fprintf(stderr, "illegal 3. esc, vlc encoding possible\n");
return -1;
}
if(abs_level <= rl->max_level[last][run]*2){
fprintf(stderr, "illegal 3. esc, esc 1 encoding possible\n");
return -1;
}
if(run1 >= 0 && abs_level <= rl->max_level[last][run1]){
fprintf(stderr, "illegal 3. esc, esc 2 encoding possible\n");
return -1;
}
}
}
#endif
if (level>0) level= level * qmul + qadd;
else level= level * qmul - qadd;
i+= run + 1;
if(last) i+=192;
} else {
#if MIN_CACHE_BITS < 20
LAST_SKIP_BITS(re, &s->gb, 2);
UPDATE_CACHE(re, &s->gb);
#else
SKIP_BITS(re, &s->gb, 2);
#endif
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2);
i+= run + rl->max_run[run>>7][level/qmul] +1;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
}
} else {
#if MIN_CACHE_BITS < 19
LAST_SKIP_BITS(re, &s->gb, 1);
UPDATE_CACHE(re, &s->gb);
#else
SKIP_BITS(re, &s->gb, 1);
#endif
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2);
i+= run;
level = level + rl->max_level[run>>7][(run-1)&63] * qmul;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
}
} else {
i+= run;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
}
if (i > 62){
i-= 192;
if(i&(~63)){
fprintf(stderr, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
block[scan_table[i]] = level;
break;
}
block[scan_table[i]] = level;
}
CLOSE_READER(re, &s->gb);
}
not_coded:
if (s->mb_intra) {
mpeg4_pred_ac(s, block, n, dc_pred_dir);
if (s->ac_pred) {
i = 63;
}
}
s->block_last_index[n] = i;
return 0;
}
| {
"code": [
" if(abs_level<=MAX_LEVEL && run<=MAX_RUN && ((s->workaround_bugs&FF_BUG_AC_VLC)==0)){",
" if(abs_level <= rl->max_level[last][run]*2){",
" fprintf(stderr, \"illegal 3. esc, esc 1 encoding possible\\n\");",
" return -1;",
" if(run1 >= 0 && abs_level <= rl->max_level[last][run1]){",
" fprintf(stderr, \"illegal 3. esc, esc 2 encoding possible\\n\");",
" return -1;"
],
"line_no": [
195,
207,
209,
203,
215,
217,
203
]
} | static inline int FUNC_0(MpegEncContext * VAR_0, DCTELEM * VAR_1,
int VAR_2, int VAR_3, int VAR_4)
{
int VAR_5, VAR_6, VAR_7, VAR_8;
int VAR_9;
RLTable * rl;
RL_VLC_ELEM * rl_vlc;
const UINT8 * VAR_10;
int VAR_11, VAR_12;
if(VAR_4) {
if(VAR_0->partitioned_frame){
VAR_5 = VAR_0->dc_val[0][ VAR_0->block_index[VAR_2] ];
if(VAR_2<4) VAR_5= (VAR_5 + (VAR_0->y_dc_scale>>1))/VAR_0->y_dc_scale;
else VAR_5= (VAR_5 + (VAR_0->c_dc_scale>>1))/VAR_0->c_dc_scale;
VAR_9= (VAR_0->pred_dir_table[VAR_0->mb_x + VAR_0->mb_y*VAR_0->mb_width]<<VAR_2)&32;
}else{
VAR_5 = mpeg4_decode_dc(VAR_0, VAR_2, &VAR_9);
if (VAR_5 < 0)
return -1;
}
VAR_1[0] = VAR_5;
VAR_6 = 0;
if (!VAR_3)
goto not_coded;
rl = &rl_intra;
rl_vlc = rl_intra.rl_vlc[0];
if (VAR_0->ac_pred) {
if (VAR_9 == 0)
VAR_10 = VAR_0->intra_v_scantable.permutated;
else
VAR_10 = VAR_0->intra_h_scantable.permutated;
} else {
VAR_10 = VAR_0->intra_scantable.permutated;
}
VAR_11=1;
VAR_12=0;
} else {
VAR_6 = -1;
if (!VAR_3) {
VAR_0->block_last_index[VAR_2] = VAR_6;
return 0;
}
rl = &rl_inter;
VAR_10 = VAR_0->intra_scantable.permutated;
if(VAR_0->mpeg_quant){
VAR_11=1;
VAR_12=0;
rl_vlc = rl_inter.rl_vlc[0];
}else{
VAR_11 = VAR_0->qscale << 1;
VAR_12 = (VAR_0->qscale - 1) | 1;
rl_vlc = rl_inter.rl_vlc[VAR_0->qscale];
}
}
{
OPEN_READER(re, &VAR_0->gb);
for(;;) {
UPDATE_CACHE(re, &VAR_0->gb);
GET_RL_VLC(VAR_5, VAR_8, re, &VAR_0->gb, rl_vlc, TEX_VLC_BITS, 2);
if (VAR_5==0) {
int VAR_13;
VAR_13= GET_CACHE(re, &VAR_0->gb);
if (VAR_13&0x80000000) {
if (VAR_13&0x40000000) {
SKIP_CACHE(re, &VAR_0->gb, 2);
VAR_7= SHOW_UBITS(re, &VAR_0->gb, 1); SKIP_CACHE(re, &VAR_0->gb, 1);
VAR_8= SHOW_UBITS(re, &VAR_0->gb, 6); LAST_SKIP_CACHE(re, &VAR_0->gb, 6);
SKIP_COUNTER(re, &VAR_0->gb, 2+1+6);
UPDATE_CACHE(re, &VAR_0->gb);
if(SHOW_UBITS(re, &VAR_0->gb, 1)==0){
fprintf(stderr, "1. marker bit missing in 3. esc\VAR_2");
return -1;
}; SKIP_CACHE(re, &VAR_0->gb, 1);
VAR_5= SHOW_SBITS(re, &VAR_0->gb, 12); SKIP_CACHE(re, &VAR_0->gb, 12);
if(SHOW_UBITS(re, &VAR_0->gb, 1)==0){
fprintf(stderr, "2. marker bit missing in 3. esc\VAR_2");
return -1;
}; LAST_SKIP_CACHE(re, &VAR_0->gb, 1);
SKIP_COUNTER(re, &VAR_0->gb, 1+12+1);
if(VAR_5*VAR_0->qscale>1024 || VAR_5*VAR_0->qscale<-1024){
fprintf(stderr, "|VAR_5| overflow in 3. esc, qp=%d\VAR_2", VAR_0->qscale);
return -1;
}
#if 1
{
const int VAR_14= ABS(VAR_5);
if(VAR_14<=MAX_LEVEL && VAR_8<=MAX_RUN && ((VAR_0->workaround_bugs&FF_BUG_AC_VLC)==0)){
const int VAR_15= VAR_8 - rl->max_run[VAR_7][VAR_14] - 1;
if(VAR_14 <= rl->max_level[VAR_7][VAR_8]){
fprintf(stderr, "illegal 3. esc, vlc encoding possible\VAR_2");
return -1;
}
if(VAR_14 <= rl->max_level[VAR_7][VAR_8]*2){
fprintf(stderr, "illegal 3. esc, esc 1 encoding possible\VAR_2");
return -1;
}
if(VAR_15 >= 0 && VAR_14 <= rl->max_level[VAR_7][VAR_15]){
fprintf(stderr, "illegal 3. esc, esc 2 encoding possible\VAR_2");
return -1;
}
}
}
#endif
if (VAR_5>0) VAR_5= VAR_5 * VAR_11 + VAR_12;
else VAR_5= VAR_5 * VAR_11 - VAR_12;
VAR_6+= VAR_8 + 1;
if(VAR_7) VAR_6+=192;
} else {
#if MIN_CACHE_BITS < 20
LAST_SKIP_BITS(re, &VAR_0->gb, 2);
UPDATE_CACHE(re, &VAR_0->gb);
#else
SKIP_BITS(re, &VAR_0->gb, 2);
#endif
GET_RL_VLC(VAR_5, VAR_8, re, &VAR_0->gb, rl_vlc, TEX_VLC_BITS, 2);
VAR_6+= VAR_8 + rl->max_run[VAR_8>>7][VAR_5/VAR_11] +1;
VAR_5 = (VAR_5 ^ SHOW_SBITS(re, &VAR_0->gb, 1)) - SHOW_SBITS(re, &VAR_0->gb, 1);
LAST_SKIP_BITS(re, &VAR_0->gb, 1);
}
} else {
#if MIN_CACHE_BITS < 19
LAST_SKIP_BITS(re, &VAR_0->gb, 1);
UPDATE_CACHE(re, &VAR_0->gb);
#else
SKIP_BITS(re, &VAR_0->gb, 1);
#endif
GET_RL_VLC(VAR_5, VAR_8, re, &VAR_0->gb, rl_vlc, TEX_VLC_BITS, 2);
VAR_6+= VAR_8;
VAR_5 = VAR_5 + rl->max_level[VAR_8>>7][(VAR_8-1)&63] * VAR_11;
VAR_5 = (VAR_5 ^ SHOW_SBITS(re, &VAR_0->gb, 1)) - SHOW_SBITS(re, &VAR_0->gb, 1);
LAST_SKIP_BITS(re, &VAR_0->gb, 1);
}
} else {
VAR_6+= VAR_8;
VAR_5 = (VAR_5 ^ SHOW_SBITS(re, &VAR_0->gb, 1)) - SHOW_SBITS(re, &VAR_0->gb, 1);
LAST_SKIP_BITS(re, &VAR_0->gb, 1);
}
if (VAR_6 > 62){
VAR_6-= 192;
if(VAR_6&(~63)){
fprintf(stderr, "ac-tex damaged at %d %d\VAR_2", VAR_0->mb_x, VAR_0->mb_y);
return -1;
}
VAR_1[VAR_10[VAR_6]] = VAR_5;
break;
}
VAR_1[VAR_10[VAR_6]] = VAR_5;
}
CLOSE_READER(re, &VAR_0->gb);
}
not_coded:
if (VAR_0->mb_intra) {
mpeg4_pred_ac(VAR_0, VAR_1, VAR_2, VAR_9);
if (VAR_0->ac_pred) {
VAR_6 = 63;
}
}
VAR_0->block_last_index[VAR_2] = VAR_6;
return 0;
}
| [
"static inline int FUNC_0(MpegEncContext * VAR_0, DCTELEM * VAR_1,\nint VAR_2, int VAR_3, int VAR_4)\n{",
"int VAR_5, VAR_6, VAR_7, VAR_8;",
"int VAR_9;",
"RLTable * rl;",
"RL_VLC_ELEM * rl_vlc;",
"const UINT8 * VAR_10;",
"int VAR_11, VAR_12;",
"if(VAR_4) {",
"if(VAR_0->partitioned_frame){",
"VAR_5 = VAR_0->dc_val[0][ VAR_0->block_index[VAR_2] ];",
"if(VAR_2<4) VAR_5= (VAR_5 + (VAR_0->y_dc_scale>>1))/VAR_0->y_dc_scale;",
"else VAR_5= (VAR_5 + (VAR_0->c_dc_scale>>1))/VAR_0->c_dc_scale;",
"VAR_9= (VAR_0->pred_dir_table[VAR_0->mb_x + VAR_0->mb_y*VAR_0->mb_width]<<VAR_2)&32;",
"}else{",
"VAR_5 = mpeg4_decode_dc(VAR_0, VAR_2, &VAR_9);",
"if (VAR_5 < 0)\nreturn -1;",
"}",
"VAR_1[0] = VAR_5;",
"VAR_6 = 0;",
"if (!VAR_3)\ngoto not_coded;",
"rl = &rl_intra;",
"rl_vlc = rl_intra.rl_vlc[0];",
"if (VAR_0->ac_pred) {",
"if (VAR_9 == 0)\nVAR_10 = VAR_0->intra_v_scantable.permutated;",
"else\nVAR_10 = VAR_0->intra_h_scantable.permutated;",
"} else {",
"VAR_10 = VAR_0->intra_scantable.permutated;",
"}",
"VAR_11=1;",
"VAR_12=0;",
"} else {",
"VAR_6 = -1;",
"if (!VAR_3) {",
"VAR_0->block_last_index[VAR_2] = VAR_6;",
"return 0;",
"}",
"rl = &rl_inter;",
"VAR_10 = VAR_0->intra_scantable.permutated;",
"if(VAR_0->mpeg_quant){",
"VAR_11=1;",
"VAR_12=0;",
"rl_vlc = rl_inter.rl_vlc[0];",
"}else{",
"VAR_11 = VAR_0->qscale << 1;",
"VAR_12 = (VAR_0->qscale - 1) | 1;",
"rl_vlc = rl_inter.rl_vlc[VAR_0->qscale];",
"}",
"}",
"{",
"OPEN_READER(re, &VAR_0->gb);",
"for(;;) {",
"UPDATE_CACHE(re, &VAR_0->gb);",
"GET_RL_VLC(VAR_5, VAR_8, re, &VAR_0->gb, rl_vlc, TEX_VLC_BITS, 2);",
"if (VAR_5==0) {",
"int VAR_13;",
"VAR_13= GET_CACHE(re, &VAR_0->gb);",
"if (VAR_13&0x80000000) {",
"if (VAR_13&0x40000000) {",
"SKIP_CACHE(re, &VAR_0->gb, 2);",
"VAR_7= SHOW_UBITS(re, &VAR_0->gb, 1); SKIP_CACHE(re, &VAR_0->gb, 1);",
"VAR_8= SHOW_UBITS(re, &VAR_0->gb, 6); LAST_SKIP_CACHE(re, &VAR_0->gb, 6);",
"SKIP_COUNTER(re, &VAR_0->gb, 2+1+6);",
"UPDATE_CACHE(re, &VAR_0->gb);",
"if(SHOW_UBITS(re, &VAR_0->gb, 1)==0){",
"fprintf(stderr, \"1. marker bit missing in 3. esc\\VAR_2\");",
"return -1;",
"}; SKIP_CACHE(re, &VAR_0->gb, 1);",
"VAR_5= SHOW_SBITS(re, &VAR_0->gb, 12); SKIP_CACHE(re, &VAR_0->gb, 12);",
"if(SHOW_UBITS(re, &VAR_0->gb, 1)==0){",
"fprintf(stderr, \"2. marker bit missing in 3. esc\\VAR_2\");",
"return -1;",
"}; LAST_SKIP_CACHE(re, &VAR_0->gb, 1);",
"SKIP_COUNTER(re, &VAR_0->gb, 1+12+1);",
"if(VAR_5*VAR_0->qscale>1024 || VAR_5*VAR_0->qscale<-1024){",
"fprintf(stderr, \"|VAR_5| overflow in 3. esc, qp=%d\\VAR_2\", VAR_0->qscale);",
"return -1;",
"}",
"#if 1\n{",
"const int VAR_14= ABS(VAR_5);",
"if(VAR_14<=MAX_LEVEL && VAR_8<=MAX_RUN && ((VAR_0->workaround_bugs&FF_BUG_AC_VLC)==0)){",
"const int VAR_15= VAR_8 - rl->max_run[VAR_7][VAR_14] - 1;",
"if(VAR_14 <= rl->max_level[VAR_7][VAR_8]){",
"fprintf(stderr, \"illegal 3. esc, vlc encoding possible\\VAR_2\");",
"return -1;",
"}",
"if(VAR_14 <= rl->max_level[VAR_7][VAR_8]*2){",
"fprintf(stderr, \"illegal 3. esc, esc 1 encoding possible\\VAR_2\");",
"return -1;",
"}",
"if(VAR_15 >= 0 && VAR_14 <= rl->max_level[VAR_7][VAR_15]){",
"fprintf(stderr, \"illegal 3. esc, esc 2 encoding possible\\VAR_2\");",
"return -1;",
"}",
"}",
"}",
"#endif\nif (VAR_5>0) VAR_5= VAR_5 * VAR_11 + VAR_12;",
"else VAR_5= VAR_5 * VAR_11 - VAR_12;",
"VAR_6+= VAR_8 + 1;",
"if(VAR_7) VAR_6+=192;",
"} else {",
"#if MIN_CACHE_BITS < 20\nLAST_SKIP_BITS(re, &VAR_0->gb, 2);",
"UPDATE_CACHE(re, &VAR_0->gb);",
"#else\nSKIP_BITS(re, &VAR_0->gb, 2);",
"#endif\nGET_RL_VLC(VAR_5, VAR_8, re, &VAR_0->gb, rl_vlc, TEX_VLC_BITS, 2);",
"VAR_6+= VAR_8 + rl->max_run[VAR_8>>7][VAR_5/VAR_11] +1;",
"VAR_5 = (VAR_5 ^ SHOW_SBITS(re, &VAR_0->gb, 1)) - SHOW_SBITS(re, &VAR_0->gb, 1);",
"LAST_SKIP_BITS(re, &VAR_0->gb, 1);",
"}",
"} else {",
"#if MIN_CACHE_BITS < 19\nLAST_SKIP_BITS(re, &VAR_0->gb, 1);",
"UPDATE_CACHE(re, &VAR_0->gb);",
"#else\nSKIP_BITS(re, &VAR_0->gb, 1);",
"#endif\nGET_RL_VLC(VAR_5, VAR_8, re, &VAR_0->gb, rl_vlc, TEX_VLC_BITS, 2);",
"VAR_6+= VAR_8;",
"VAR_5 = VAR_5 + rl->max_level[VAR_8>>7][(VAR_8-1)&63] * VAR_11;",
"VAR_5 = (VAR_5 ^ SHOW_SBITS(re, &VAR_0->gb, 1)) - SHOW_SBITS(re, &VAR_0->gb, 1);",
"LAST_SKIP_BITS(re, &VAR_0->gb, 1);",
"}",
"} else {",
"VAR_6+= VAR_8;",
"VAR_5 = (VAR_5 ^ SHOW_SBITS(re, &VAR_0->gb, 1)) - SHOW_SBITS(re, &VAR_0->gb, 1);",
"LAST_SKIP_BITS(re, &VAR_0->gb, 1);",
"}",
"if (VAR_6 > 62){",
"VAR_6-= 192;",
"if(VAR_6&(~63)){",
"fprintf(stderr, \"ac-tex damaged at %d %d\\VAR_2\", VAR_0->mb_x, VAR_0->mb_y);",
"return -1;",
"}",
"VAR_1[VAR_10[VAR_6]] = VAR_5;",
"break;",
"}",
"VAR_1[VAR_10[VAR_6]] = VAR_5;",
"}",
"CLOSE_READER(re, &VAR_0->gb);",
"}",
"not_coded:\nif (VAR_0->mb_intra) {",
"mpeg4_pred_ac(VAR_0, VAR_1, VAR_2, VAR_9);",
"if (VAR_0->ac_pred) {",
"VAR_6 = 63;",
"}",
"}",
"VAR_0->block_last_index[VAR_2] = VAR_6;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
1,
0,
1,
1,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
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
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
157
],
[
159
],
[
163
],
[
167
],
[
169
],
[
171
],
[
173
],
[
177
],
[
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
],
[
243,
245
],
[
247
],
[
249,
251
],
[
253,
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
269,
271
],
[
273
],
[
275,
277
],
[
279,
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
317
],
[
319
],
[
321
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333,
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
]
] |
26,041 | int load_uboot(const char *filename, target_ulong *ep, int *is_linux)
{
int fd;
int size;
uboot_image_header_t h;
uboot_image_header_t *hdr = &h;
uint8_t *data = NULL;
fd = open(filename, O_RDONLY | O_BINARY);
if (fd < 0)
return -1;
size = read(fd, hdr, sizeof(uboot_image_header_t));
if (size < 0)
goto fail;
bswap_uboot_header(hdr);
if (hdr->ih_magic != IH_MAGIC)
goto fail;
/* TODO: Implement Multi-File images. */
if (hdr->ih_type == IH_TYPE_MULTI) {
fprintf(stderr, "Unable to load multi-file u-boot images\n");
goto fail;
}
/* TODO: Implement compressed images. */
if (hdr->ih_comp != IH_COMP_NONE) {
fprintf(stderr, "Unable to load compressed u-boot images\n");
goto fail;
}
/* TODO: Check CPU type. */
if (is_linux) {
if (hdr->ih_type == IH_TYPE_KERNEL && hdr->ih_os == IH_OS_LINUX)
*is_linux = 1;
else
*is_linux = 0;
}
*ep = hdr->ih_ep;
data = qemu_malloc(hdr->ih_size);
if (!data)
goto fail;
if (read(fd, data, hdr->ih_size) != hdr->ih_size) {
fprintf(stderr, "Error reading file\n");
goto fail;
}
cpu_physical_memory_write_rom(hdr->ih_load, data, hdr->ih_size);
return hdr->ih_size;
fail:
if (data)
qemu_free(data);
close(fd);
return -1;
}
| true | qemu | 265ca29a7162a9437efabdb3b133237eef49ab7b | int load_uboot(const char *filename, target_ulong *ep, int *is_linux)
{
int fd;
int size;
uboot_image_header_t h;
uboot_image_header_t *hdr = &h;
uint8_t *data = NULL;
fd = open(filename, O_RDONLY | O_BINARY);
if (fd < 0)
return -1;
size = read(fd, hdr, sizeof(uboot_image_header_t));
if (size < 0)
goto fail;
bswap_uboot_header(hdr);
if (hdr->ih_magic != IH_MAGIC)
goto fail;
if (hdr->ih_type == IH_TYPE_MULTI) {
fprintf(stderr, "Unable to load multi-file u-boot images\n");
goto fail;
}
if (hdr->ih_comp != IH_COMP_NONE) {
fprintf(stderr, "Unable to load compressed u-boot images\n");
goto fail;
}
if (is_linux) {
if (hdr->ih_type == IH_TYPE_KERNEL && hdr->ih_os == IH_OS_LINUX)
*is_linux = 1;
else
*is_linux = 0;
}
*ep = hdr->ih_ep;
data = qemu_malloc(hdr->ih_size);
if (!data)
goto fail;
if (read(fd, data, hdr->ih_size) != hdr->ih_size) {
fprintf(stderr, "Error reading file\n");
goto fail;
}
cpu_physical_memory_write_rom(hdr->ih_load, data, hdr->ih_size);
return hdr->ih_size;
fail:
if (data)
qemu_free(data);
close(fd);
return -1;
}
| {
"code": [
" goto fail;",
" goto fail;",
" goto fail;",
" goto fail;",
" goto fail;",
" goto fail;",
" return hdr->ih_size;",
"fail:",
" return -1;"
],
"line_no": [
31,
31,
31,
31,
31,
31,
109,
113,
121
]
} | int FUNC_0(const char *VAR_0, target_ulong *VAR_1, int *VAR_2)
{
int VAR_3;
int VAR_4;
uboot_image_header_t h;
uboot_image_header_t *hdr = &h;
uint8_t *data = NULL;
VAR_3 = open(VAR_0, O_RDONLY | O_BINARY);
if (VAR_3 < 0)
return -1;
VAR_4 = read(VAR_3, hdr, sizeof(uboot_image_header_t));
if (VAR_4 < 0)
goto fail;
bswap_uboot_header(hdr);
if (hdr->ih_magic != IH_MAGIC)
goto fail;
if (hdr->ih_type == IH_TYPE_MULTI) {
fprintf(stderr, "Unable to load multi-file u-boot images\n");
goto fail;
}
if (hdr->ih_comp != IH_COMP_NONE) {
fprintf(stderr, "Unable to load compressed u-boot images\n");
goto fail;
}
if (VAR_2) {
if (hdr->ih_type == IH_TYPE_KERNEL && hdr->ih_os == IH_OS_LINUX)
*VAR_2 = 1;
else
*VAR_2 = 0;
}
*VAR_1 = hdr->ih_ep;
data = qemu_malloc(hdr->ih_size);
if (!data)
goto fail;
if (read(VAR_3, data, hdr->ih_size) != hdr->ih_size) {
fprintf(stderr, "Error reading file\n");
goto fail;
}
cpu_physical_memory_write_rom(hdr->ih_load, data, hdr->ih_size);
return hdr->ih_size;
fail:
if (data)
qemu_free(data);
close(VAR_3);
return -1;
}
| [
"int FUNC_0(const char *VAR_0, target_ulong *VAR_1, int *VAR_2)\n{",
"int VAR_3;",
"int VAR_4;",
"uboot_image_header_t h;",
"uboot_image_header_t *hdr = &h;",
"uint8_t *data = NULL;",
"VAR_3 = open(VAR_0, O_RDONLY | O_BINARY);",
"if (VAR_3 < 0)\nreturn -1;",
"VAR_4 = read(VAR_3, hdr, sizeof(uboot_image_header_t));",
"if (VAR_4 < 0)\ngoto fail;",
"bswap_uboot_header(hdr);",
"if (hdr->ih_magic != IH_MAGIC)\ngoto fail;",
"if (hdr->ih_type == IH_TYPE_MULTI) {",
"fprintf(stderr, \"Unable to load multi-file u-boot images\\n\");",
"goto fail;",
"}",
"if (hdr->ih_comp != IH_COMP_NONE) {",
"fprintf(stderr, \"Unable to load compressed u-boot images\\n\");",
"goto fail;",
"}",
"if (VAR_2) {",
"if (hdr->ih_type == IH_TYPE_KERNEL && hdr->ih_os == IH_OS_LINUX)\n*VAR_2 = 1;",
"else\n*VAR_2 = 0;",
"}",
"*VAR_1 = hdr->ih_ep;",
"data = qemu_malloc(hdr->ih_size);",
"if (!data)\ngoto fail;",
"if (read(VAR_3, data, hdr->ih_size) != hdr->ih_size) {",
"fprintf(stderr, \"Error reading file\\n\");",
"goto fail;",
"}",
"cpu_physical_memory_write_rom(hdr->ih_load, data, hdr->ih_size);",
"return hdr->ih_size;",
"fail:\nif (data)\nqemu_free(data);",
"close(VAR_3);",
"return -1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
1,
0
] | [
[
1,
3
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21,
23
],
[
27
],
[
29,
31
],
[
35
],
[
39,
41
],
[
47
],
[
49
],
[
51
],
[
53
],
[
59
],
[
61
],
[
63
],
[
65
],
[
71
],
[
73,
75
],
[
77,
79
],
[
81
],
[
85
],
[
87
],
[
89,
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
109
],
[
113,
115,
117
],
[
119
],
[
121
],
[
123
]
] |
26,042 | static int64_t alloc_refcount_block(BlockDriverState *bs, int64_t cluster_index)
{
BDRVQcowState *s = bs->opaque;
unsigned int refcount_table_index;
int ret;
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC);
/* Find the refcount block for the given cluster */
refcount_table_index = cluster_index >> (s->cluster_bits - REFCOUNT_SHIFT);
if (refcount_table_index < s->refcount_table_size) {
uint64_t refcount_block_offset =
s->refcount_table[refcount_table_index];
/* If it's already there, we're done */
if (refcount_block_offset) {
if (refcount_block_offset != s->refcount_block_cache_offset) {
ret = load_refcount_block(bs, refcount_block_offset);
if (ret < 0) {
return ret;
}
}
return refcount_block_offset;
}
}
/*
* If we came here, we need to allocate something. Something is at least
* a cluster for the new refcount block. It may also include a new refcount
* table if the old refcount table is too small.
*
* Note that allocating clusters here needs some special care:
*
* - We can't use the normal qcow2_alloc_clusters(), it would try to
* increase the refcount and very likely we would end up with an endless
* recursion. Instead we must place the refcount blocks in a way that
* they can describe them themselves.
*
* - We need to consider that at this point we are inside update_refcounts
* and doing the initial refcount increase. This means that some clusters
* have already been allocated by the caller, but their refcount isn't
* accurate yet. free_cluster_index tells us where this allocation ends
* as long as we don't overwrite it by freeing clusters.
*
* - alloc_clusters_noref and qcow2_free_clusters may load a different
* refcount block into the cache
*/
if (cache_refcount_updates) {
ret = write_refcount_block(bs);
if (ret < 0) {
return ret;
}
}
/* Allocate the refcount block itself and mark it as used */
uint64_t new_block = alloc_clusters_noref(bs, s->cluster_size);
memset(s->refcount_block_cache, 0, s->cluster_size);
s->refcount_block_cache_offset = new_block;
#ifdef DEBUG_ALLOC2
fprintf(stderr, "qcow2: Allocate refcount block %d for %" PRIx64
" at %" PRIx64 "\n",
refcount_table_index, cluster_index << s->cluster_bits, new_block);
#endif
if (in_same_refcount_block(s, new_block, cluster_index << s->cluster_bits)) {
/* The block describes itself, need to update the cache */
int block_index = (new_block >> s->cluster_bits) &
((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1);
s->refcount_block_cache[block_index] = cpu_to_be16(1);
} else {
/* Described somewhere else. This can recurse at most twice before we
* arrive at a block that describes itself. */
ret = update_refcount(bs, new_block, s->cluster_size, 1);
if (ret < 0) {
goto fail_block;
}
}
/* Now the new refcount block needs to be written to disk */
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE);
ret = bdrv_pwrite(bs->file, new_block, s->refcount_block_cache,
s->cluster_size);
if (ret < 0) {
goto fail_block;
}
/* If the refcount table is big enough, just hook the block up there */
if (refcount_table_index < s->refcount_table_size) {
uint64_t data64 = cpu_to_be64(new_block);
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_HOOKUP);
ret = bdrv_pwrite(bs->file,
s->refcount_table_offset + refcount_table_index * sizeof(uint64_t),
&data64, sizeof(data64));
if (ret < 0) {
goto fail_block;
}
s->refcount_table[refcount_table_index] = new_block;
return new_block;
}
/*
* If we come here, we need to grow the refcount table. Again, a new
* refcount table needs some space and we can't simply allocate to avoid
* endless recursion.
*
* Therefore let's grab new refcount blocks at the end of the image, which
* will describe themselves and the new refcount table. This way we can
* reference them only in the new table and do the switch to the new
* refcount table at once without producing an inconsistent state in
* between.
*/
BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_GROW);
/* Calculate the number of refcount blocks needed so far */
uint64_t refcount_block_clusters = 1 << (s->cluster_bits - REFCOUNT_SHIFT);
uint64_t blocks_used = (s->free_cluster_index +
refcount_block_clusters - 1) / refcount_block_clusters;
/* And now we need at least one block more for the new metadata */
uint64_t table_size = next_refcount_table_size(s, blocks_used + 1);
uint64_t last_table_size;
uint64_t blocks_clusters;
do {
uint64_t table_clusters = size_to_clusters(s, table_size);
blocks_clusters = 1 +
((table_clusters + refcount_block_clusters - 1)
/ refcount_block_clusters);
uint64_t meta_clusters = table_clusters + blocks_clusters;
last_table_size = table_size;
table_size = next_refcount_table_size(s, blocks_used +
((meta_clusters + refcount_block_clusters - 1)
/ refcount_block_clusters));
} while (last_table_size != table_size);
#ifdef DEBUG_ALLOC2
fprintf(stderr, "qcow2: Grow refcount table %" PRId32 " => %" PRId64 "\n",
s->refcount_table_size, table_size);
#endif
/* Create the new refcount table and blocks */
uint64_t meta_offset = (blocks_used * refcount_block_clusters) *
s->cluster_size;
uint64_t table_offset = meta_offset + blocks_clusters * s->cluster_size;
uint16_t *new_blocks = qemu_mallocz(blocks_clusters * s->cluster_size);
uint64_t *new_table = qemu_mallocz(table_size * sizeof(uint64_t));
assert(meta_offset >= (s->free_cluster_index * s->cluster_size));
/* Fill the new refcount table */
memcpy(new_table, s->refcount_table,
s->refcount_table_size * sizeof(uint64_t));
new_table[refcount_table_index] = new_block;
int i;
for (i = 0; i < blocks_clusters; i++) {
new_table[blocks_used + i] = meta_offset + (i * s->cluster_size);
}
/* Fill the refcount blocks */
uint64_t table_clusters = size_to_clusters(s, table_size * sizeof(uint64_t));
int block = 0;
for (i = 0; i < table_clusters + blocks_clusters; i++) {
new_blocks[block++] = cpu_to_be16(1);
}
/* Write refcount blocks to disk */
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_BLOCKS);
ret = bdrv_pwrite(bs->file, meta_offset, new_blocks,
blocks_clusters * s->cluster_size);
qemu_free(new_blocks);
if (ret < 0) {
goto fail_table;
}
/* Write refcount table to disk */
for(i = 0; i < table_size; i++) {
cpu_to_be64s(&new_table[i]);
}
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_TABLE);
ret = bdrv_pwrite(bs->file, table_offset, new_table,
table_size * sizeof(uint64_t));
if (ret < 0) {
goto fail_table;
}
for(i = 0; i < table_size; i++) {
cpu_to_be64s(&new_table[i]);
}
/* Hook up the new refcount table in the qcow2 header */
uint8_t data[12];
cpu_to_be64w((uint64_t*)data, table_offset);
cpu_to_be32w((uint32_t*)(data + 8), table_clusters);
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE);
ret = bdrv_pwrite(bs->file, offsetof(QCowHeader, refcount_table_offset),
data, sizeof(data));
if (ret < 0) {
goto fail_table;
}
/* And switch it in memory */
uint64_t old_table_offset = s->refcount_table_offset;
uint64_t old_table_size = s->refcount_table_size;
qemu_free(s->refcount_table);
s->refcount_table = new_table;
s->refcount_table_size = table_size;
s->refcount_table_offset = table_offset;
/* Free old table. Remember, we must not change free_cluster_index */
uint64_t old_free_cluster_index = s->free_cluster_index;
qcow2_free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t));
s->free_cluster_index = old_free_cluster_index;
ret = load_refcount_block(bs, new_block);
if (ret < 0) {
goto fail_block;
}
return new_block;
fail_table:
qemu_free(new_table);
fail_block:
s->refcount_block_cache_offset = 0;
return ret;
}
| true | qemu | 25408c09502be036e5575754fe54019ed4ed5dfa | static int64_t alloc_refcount_block(BlockDriverState *bs, int64_t cluster_index)
{
BDRVQcowState *s = bs->opaque;
unsigned int refcount_table_index;
int ret;
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC);
refcount_table_index = cluster_index >> (s->cluster_bits - REFCOUNT_SHIFT);
if (refcount_table_index < s->refcount_table_size) {
uint64_t refcount_block_offset =
s->refcount_table[refcount_table_index];
if (refcount_block_offset) {
if (refcount_block_offset != s->refcount_block_cache_offset) {
ret = load_refcount_block(bs, refcount_block_offset);
if (ret < 0) {
return ret;
}
}
return refcount_block_offset;
}
}
if (cache_refcount_updates) {
ret = write_refcount_block(bs);
if (ret < 0) {
return ret;
}
}
uint64_t new_block = alloc_clusters_noref(bs, s->cluster_size);
memset(s->refcount_block_cache, 0, s->cluster_size);
s->refcount_block_cache_offset = new_block;
#ifdef DEBUG_ALLOC2
fprintf(stderr, "qcow2: Allocate refcount block %d for %" PRIx64
" at %" PRIx64 "\n",
refcount_table_index, cluster_index << s->cluster_bits, new_block);
#endif
if (in_same_refcount_block(s, new_block, cluster_index << s->cluster_bits)) {
int block_index = (new_block >> s->cluster_bits) &
((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1);
s->refcount_block_cache[block_index] = cpu_to_be16(1);
} else {
ret = update_refcount(bs, new_block, s->cluster_size, 1);
if (ret < 0) {
goto fail_block;
}
}
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE);
ret = bdrv_pwrite(bs->file, new_block, s->refcount_block_cache,
s->cluster_size);
if (ret < 0) {
goto fail_block;
}
if (refcount_table_index < s->refcount_table_size) {
uint64_t data64 = cpu_to_be64(new_block);
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_HOOKUP);
ret = bdrv_pwrite(bs->file,
s->refcount_table_offset + refcount_table_index * sizeof(uint64_t),
&data64, sizeof(data64));
if (ret < 0) {
goto fail_block;
}
s->refcount_table[refcount_table_index] = new_block;
return new_block;
}
BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_GROW);
uint64_t refcount_block_clusters = 1 << (s->cluster_bits - REFCOUNT_SHIFT);
uint64_t blocks_used = (s->free_cluster_index +
refcount_block_clusters - 1) / refcount_block_clusters;
uint64_t table_size = next_refcount_table_size(s, blocks_used + 1);
uint64_t last_table_size;
uint64_t blocks_clusters;
do {
uint64_t table_clusters = size_to_clusters(s, table_size);
blocks_clusters = 1 +
((table_clusters + refcount_block_clusters - 1)
/ refcount_block_clusters);
uint64_t meta_clusters = table_clusters + blocks_clusters;
last_table_size = table_size;
table_size = next_refcount_table_size(s, blocks_used +
((meta_clusters + refcount_block_clusters - 1)
/ refcount_block_clusters));
} while (last_table_size != table_size);
#ifdef DEBUG_ALLOC2
fprintf(stderr, "qcow2: Grow refcount table %" PRId32 " => %" PRId64 "\n",
s->refcount_table_size, table_size);
#endif
uint64_t meta_offset = (blocks_used * refcount_block_clusters) *
s->cluster_size;
uint64_t table_offset = meta_offset + blocks_clusters * s->cluster_size;
uint16_t *new_blocks = qemu_mallocz(blocks_clusters * s->cluster_size);
uint64_t *new_table = qemu_mallocz(table_size * sizeof(uint64_t));
assert(meta_offset >= (s->free_cluster_index * s->cluster_size));
memcpy(new_table, s->refcount_table,
s->refcount_table_size * sizeof(uint64_t));
new_table[refcount_table_index] = new_block;
int i;
for (i = 0; i < blocks_clusters; i++) {
new_table[blocks_used + i] = meta_offset + (i * s->cluster_size);
}
uint64_t table_clusters = size_to_clusters(s, table_size * sizeof(uint64_t));
int block = 0;
for (i = 0; i < table_clusters + blocks_clusters; i++) {
new_blocks[block++] = cpu_to_be16(1);
}
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_BLOCKS);
ret = bdrv_pwrite(bs->file, meta_offset, new_blocks,
blocks_clusters * s->cluster_size);
qemu_free(new_blocks);
if (ret < 0) {
goto fail_table;
}
for(i = 0; i < table_size; i++) {
cpu_to_be64s(&new_table[i]);
}
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_TABLE);
ret = bdrv_pwrite(bs->file, table_offset, new_table,
table_size * sizeof(uint64_t));
if (ret < 0) {
goto fail_table;
}
for(i = 0; i < table_size; i++) {
cpu_to_be64s(&new_table[i]);
}
uint8_t data[12];
cpu_to_be64w((uint64_t*)data, table_offset);
cpu_to_be32w((uint32_t*)(data + 8), table_clusters);
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE);
ret = bdrv_pwrite(bs->file, offsetof(QCowHeader, refcount_table_offset),
data, sizeof(data));
if (ret < 0) {
goto fail_table;
}
uint64_t old_table_offset = s->refcount_table_offset;
uint64_t old_table_size = s->refcount_table_size;
qemu_free(s->refcount_table);
s->refcount_table = new_table;
s->refcount_table_size = table_size;
s->refcount_table_offset = table_offset;
uint64_t old_free_cluster_index = s->free_cluster_index;
qcow2_free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t));
s->free_cluster_index = old_free_cluster_index;
ret = load_refcount_block(bs, new_block);
if (ret < 0) {
goto fail_block;
}
return new_block;
fail_table:
qemu_free(new_table);
fail_block:
s->refcount_block_cache_offset = 0;
return ret;
}
| {
"code": [
" memset(s->refcount_block_cache, 0, s->cluster_size);",
" s->refcount_block_cache_offset = new_block;"
],
"line_no": [
119,
121
]
} | static int64_t FUNC_0(BlockDriverState *bs, int64_t cluster_index)
{
BDRVQcowState *s = bs->opaque;
unsigned int VAR_0;
int VAR_1;
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC);
VAR_0 = cluster_index >> (s->cluster_bits - REFCOUNT_SHIFT);
if (VAR_0 < s->refcount_table_size) {
uint64_t refcount_block_offset =
s->refcount_table[VAR_0];
if (refcount_block_offset) {
if (refcount_block_offset != s->refcount_block_cache_offset) {
VAR_1 = load_refcount_block(bs, refcount_block_offset);
if (VAR_1 < 0) {
return VAR_1;
}
}
return refcount_block_offset;
}
}
if (cache_refcount_updates) {
VAR_1 = write_refcount_block(bs);
if (VAR_1 < 0) {
return VAR_1;
}
}
uint64_t new_block = alloc_clusters_noref(bs, s->cluster_size);
memset(s->refcount_block_cache, 0, s->cluster_size);
s->refcount_block_cache_offset = new_block;
#ifdef DEBUG_ALLOC2
fprintf(stderr, "qcow2: Allocate refcount VAR_4 %d for %" PRIx64
" at %" PRIx64 "\n",
VAR_0, cluster_index << s->cluster_bits, new_block);
#endif
if (in_same_refcount_block(s, new_block, cluster_index << s->cluster_bits)) {
int VAR_2 = (new_block >> s->cluster_bits) &
((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1);
s->refcount_block_cache[VAR_2] = cpu_to_be16(1);
} else {
VAR_1 = update_refcount(bs, new_block, s->cluster_size, 1);
if (VAR_1 < 0) {
goto fail_block;
}
}
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE);
VAR_1 = bdrv_pwrite(bs->file, new_block, s->refcount_block_cache,
s->cluster_size);
if (VAR_1 < 0) {
goto fail_block;
}
if (VAR_0 < s->refcount_table_size) {
uint64_t data64 = cpu_to_be64(new_block);
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_HOOKUP);
VAR_1 = bdrv_pwrite(bs->file,
s->refcount_table_offset + VAR_0 * sizeof(uint64_t),
&data64, sizeof(data64));
if (VAR_1 < 0) {
goto fail_block;
}
s->refcount_table[VAR_0] = new_block;
return new_block;
}
BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_GROW);
uint64_t refcount_block_clusters = 1 << (s->cluster_bits - REFCOUNT_SHIFT);
uint64_t blocks_used = (s->free_cluster_index +
refcount_block_clusters - 1) / refcount_block_clusters;
uint64_t table_size = next_refcount_table_size(s, blocks_used + 1);
uint64_t last_table_size;
uint64_t blocks_clusters;
do {
uint64_t table_clusters = size_to_clusters(s, table_size);
blocks_clusters = 1 +
((table_clusters + refcount_block_clusters - 1)
/ refcount_block_clusters);
uint64_t meta_clusters = table_clusters + blocks_clusters;
last_table_size = table_size;
table_size = next_refcount_table_size(s, blocks_used +
((meta_clusters + refcount_block_clusters - 1)
/ refcount_block_clusters));
} while (last_table_size != table_size);
#ifdef DEBUG_ALLOC2
fprintf(stderr, "qcow2: Grow refcount table %" PRId32 " => %" PRId64 "\n",
s->refcount_table_size, table_size);
#endif
uint64_t meta_offset = (blocks_used * refcount_block_clusters) *
s->cluster_size;
uint64_t table_offset = meta_offset + blocks_clusters * s->cluster_size;
uint16_t *new_blocks = qemu_mallocz(blocks_clusters * s->cluster_size);
uint64_t *new_table = qemu_mallocz(table_size * sizeof(uint64_t));
assert(meta_offset >= (s->free_cluster_index * s->cluster_size));
memcpy(new_table, s->refcount_table,
s->refcount_table_size * sizeof(uint64_t));
new_table[VAR_0] = new_block;
int VAR_3;
for (VAR_3 = 0; VAR_3 < blocks_clusters; VAR_3++) {
new_table[blocks_used + VAR_3] = meta_offset + (VAR_3 * s->cluster_size);
}
uint64_t table_clusters = size_to_clusters(s, table_size * sizeof(uint64_t));
int VAR_4 = 0;
for (VAR_3 = 0; VAR_3 < table_clusters + blocks_clusters; VAR_3++) {
new_blocks[VAR_4++] = cpu_to_be16(1);
}
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_BLOCKS);
VAR_1 = bdrv_pwrite(bs->file, meta_offset, new_blocks,
blocks_clusters * s->cluster_size);
qemu_free(new_blocks);
if (VAR_1 < 0) {
goto fail_table;
}
for(VAR_3 = 0; VAR_3 < table_size; VAR_3++) {
cpu_to_be64s(&new_table[VAR_3]);
}
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_TABLE);
VAR_1 = bdrv_pwrite(bs->file, table_offset, new_table,
table_size * sizeof(uint64_t));
if (VAR_1 < 0) {
goto fail_table;
}
for(VAR_3 = 0; VAR_3 < table_size; VAR_3++) {
cpu_to_be64s(&new_table[VAR_3]);
}
uint8_t data[12];
cpu_to_be64w((uint64_t*)data, table_offset);
cpu_to_be32w((uint32_t*)(data + 8), table_clusters);
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE);
VAR_1 = bdrv_pwrite(bs->file, offsetof(QCowHeader, refcount_table_offset),
data, sizeof(data));
if (VAR_1 < 0) {
goto fail_table;
}
uint64_t old_table_offset = s->refcount_table_offset;
uint64_t old_table_size = s->refcount_table_size;
qemu_free(s->refcount_table);
s->refcount_table = new_table;
s->refcount_table_size = table_size;
s->refcount_table_offset = table_offset;
uint64_t old_free_cluster_index = s->free_cluster_index;
qcow2_free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t));
s->free_cluster_index = old_free_cluster_index;
VAR_1 = load_refcount_block(bs, new_block);
if (VAR_1 < 0) {
goto fail_block;
}
return new_block;
fail_table:
qemu_free(new_table);
fail_block:
s->refcount_block_cache_offset = 0;
return VAR_1;
}
| [
"static int64_t FUNC_0(BlockDriverState *bs, int64_t cluster_index)\n{",
"BDRVQcowState *s = bs->opaque;",
"unsigned int VAR_0;",
"int VAR_1;",
"BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC);",
"VAR_0 = cluster_index >> (s->cluster_bits - REFCOUNT_SHIFT);",
"if (VAR_0 < s->refcount_table_size) {",
"uint64_t refcount_block_offset =\ns->refcount_table[VAR_0];",
"if (refcount_block_offset) {",
"if (refcount_block_offset != s->refcount_block_cache_offset) {",
"VAR_1 = load_refcount_block(bs, refcount_block_offset);",
"if (VAR_1 < 0) {",
"return VAR_1;",
"}",
"}",
"return refcount_block_offset;",
"}",
"}",
"if (cache_refcount_updates) {",
"VAR_1 = write_refcount_block(bs);",
"if (VAR_1 < 0) {",
"return VAR_1;",
"}",
"}",
"uint64_t new_block = alloc_clusters_noref(bs, s->cluster_size);",
"memset(s->refcount_block_cache, 0, s->cluster_size);",
"s->refcount_block_cache_offset = new_block;",
"#ifdef DEBUG_ALLOC2\nfprintf(stderr, \"qcow2: Allocate refcount VAR_4 %d for %\" PRIx64\n\" at %\" PRIx64 \"\\n\",\nVAR_0, cluster_index << s->cluster_bits, new_block);",
"#endif\nif (in_same_refcount_block(s, new_block, cluster_index << s->cluster_bits)) {",
"int VAR_2 = (new_block >> s->cluster_bits) &\n((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1);",
"s->refcount_block_cache[VAR_2] = cpu_to_be16(1);",
"} else {",
"VAR_1 = update_refcount(bs, new_block, s->cluster_size, 1);",
"if (VAR_1 < 0) {",
"goto fail_block;",
"}",
"}",
"BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE);",
"VAR_1 = bdrv_pwrite(bs->file, new_block, s->refcount_block_cache,\ns->cluster_size);",
"if (VAR_1 < 0) {",
"goto fail_block;",
"}",
"if (VAR_0 < s->refcount_table_size) {",
"uint64_t data64 = cpu_to_be64(new_block);",
"BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_HOOKUP);",
"VAR_1 = bdrv_pwrite(bs->file,\ns->refcount_table_offset + VAR_0 * sizeof(uint64_t),\n&data64, sizeof(data64));",
"if (VAR_1 < 0) {",
"goto fail_block;",
"}",
"s->refcount_table[VAR_0] = new_block;",
"return new_block;",
"}",
"BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_GROW);",
"uint64_t refcount_block_clusters = 1 << (s->cluster_bits - REFCOUNT_SHIFT);",
"uint64_t blocks_used = (s->free_cluster_index +\nrefcount_block_clusters - 1) / refcount_block_clusters;",
"uint64_t table_size = next_refcount_table_size(s, blocks_used + 1);",
"uint64_t last_table_size;",
"uint64_t blocks_clusters;",
"do {",
"uint64_t table_clusters = size_to_clusters(s, table_size);",
"blocks_clusters = 1 +\n((table_clusters + refcount_block_clusters - 1)\n/ refcount_block_clusters);",
"uint64_t meta_clusters = table_clusters + blocks_clusters;",
"last_table_size = table_size;",
"table_size = next_refcount_table_size(s, blocks_used +\n((meta_clusters + refcount_block_clusters - 1)\n/ refcount_block_clusters));",
"} while (last_table_size != table_size);",
"#ifdef DEBUG_ALLOC2\nfprintf(stderr, \"qcow2: Grow refcount table %\" PRId32 \" => %\" PRId64 \"\\n\",\ns->refcount_table_size, table_size);",
"#endif\nuint64_t meta_offset = (blocks_used * refcount_block_clusters) *\ns->cluster_size;",
"uint64_t table_offset = meta_offset + blocks_clusters * s->cluster_size;",
"uint16_t *new_blocks = qemu_mallocz(blocks_clusters * s->cluster_size);",
"uint64_t *new_table = qemu_mallocz(table_size * sizeof(uint64_t));",
"assert(meta_offset >= (s->free_cluster_index * s->cluster_size));",
"memcpy(new_table, s->refcount_table,\ns->refcount_table_size * sizeof(uint64_t));",
"new_table[VAR_0] = new_block;",
"int VAR_3;",
"for (VAR_3 = 0; VAR_3 < blocks_clusters; VAR_3++) {",
"new_table[blocks_used + VAR_3] = meta_offset + (VAR_3 * s->cluster_size);",
"}",
"uint64_t table_clusters = size_to_clusters(s, table_size * sizeof(uint64_t));",
"int VAR_4 = 0;",
"for (VAR_3 = 0; VAR_3 < table_clusters + blocks_clusters; VAR_3++) {",
"new_blocks[VAR_4++] = cpu_to_be16(1);",
"}",
"BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_BLOCKS);",
"VAR_1 = bdrv_pwrite(bs->file, meta_offset, new_blocks,\nblocks_clusters * s->cluster_size);",
"qemu_free(new_blocks);",
"if (VAR_1 < 0) {",
"goto fail_table;",
"}",
"for(VAR_3 = 0; VAR_3 < table_size; VAR_3++) {",
"cpu_to_be64s(&new_table[VAR_3]);",
"}",
"BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_TABLE);",
"VAR_1 = bdrv_pwrite(bs->file, table_offset, new_table,\ntable_size * sizeof(uint64_t));",
"if (VAR_1 < 0) {",
"goto fail_table;",
"}",
"for(VAR_3 = 0; VAR_3 < table_size; VAR_3++) {",
"cpu_to_be64s(&new_table[VAR_3]);",
"}",
"uint8_t data[12];",
"cpu_to_be64w((uint64_t*)data, table_offset);",
"cpu_to_be32w((uint32_t*)(data + 8), table_clusters);",
"BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE);",
"VAR_1 = bdrv_pwrite(bs->file, offsetof(QCowHeader, refcount_table_offset),\ndata, sizeof(data));",
"if (VAR_1 < 0) {",
"goto fail_table;",
"}",
"uint64_t old_table_offset = s->refcount_table_offset;",
"uint64_t old_table_size = s->refcount_table_size;",
"qemu_free(s->refcount_table);",
"s->refcount_table = new_table;",
"s->refcount_table_size = table_size;",
"s->refcount_table_offset = table_offset;",
"uint64_t old_free_cluster_index = s->free_cluster_index;",
"qcow2_free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t));",
"s->free_cluster_index = old_free_cluster_index;",
"VAR_1 = load_refcount_block(bs, new_block);",
"if (VAR_1 < 0) {",
"goto fail_block;",
"}",
"return new_block;",
"fail_table:\nqemu_free(new_table);",
"fail_block:\ns->refcount_block_cache_offset = 0;",
"return VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
19
],
[
23
],
[
27,
29
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
117
],
[
119
],
[
121
],
[
125,
127,
129,
131
],
[
133,
137
],
[
141,
143
],
[
145
],
[
147
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
167
],
[
169,
171
],
[
173
],
[
175
],
[
177
],
[
183
],
[
185
],
[
187
],
[
189,
191,
193
],
[
195
],
[
197
],
[
199
],
[
203
],
[
205
],
[
207
],
[
233
],
[
239
],
[
241,
243
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259,
261,
263
],
[
265
],
[
269
],
[
271,
273,
275
],
[
279
],
[
283,
285,
287
],
[
289,
295,
297
],
[
299
],
[
301
],
[
303
],
[
307
],
[
313,
315
],
[
317
],
[
321
],
[
323
],
[
325
],
[
327
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
347
],
[
349,
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
365
],
[
367
],
[
369
],
[
373
],
[
375,
377
],
[
379
],
[
381
],
[
383
],
[
387
],
[
389
],
[
391
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405,
407
],
[
409
],
[
411
],
[
413
],
[
419
],
[
421
],
[
425
],
[
427
],
[
429
],
[
431
],
[
437
],
[
439
],
[
441
],
[
445
],
[
447
],
[
449
],
[
451
],
[
455
],
[
459,
461
],
[
463,
465
],
[
467
],
[
469
]
] |
26,043 | static int parse_vtrk(AVFormatContext *s,
FourxmDemuxContext *fourxm, uint8_t *buf, int size)
{
AVStream *st;
/* check that there is enough data */
if (size != vtrk_SIZE) {
return AVERROR_INVALIDDATA;
}
/* allocate a new AVStream */
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 60, 1, fourxm->fps);
fourxm->video_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_4XM;
st->codec->extradata_size = 4;
st->codec->extradata = av_malloc(4);
AV_WL32(st->codec->extradata, AV_RL32(buf + 16));
st->codec->width = AV_RL32(buf + 36);
st->codec->height = AV_RL32(buf + 40);
return 0;
}
| true | FFmpeg | 42d73f7f6bea0ee0f64a3ad4882860ce5b923a11 | static int parse_vtrk(AVFormatContext *s,
FourxmDemuxContext *fourxm, uint8_t *buf, int size)
{
AVStream *st;
if (size != vtrk_SIZE) {
return AVERROR_INVALIDDATA;
}
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 60, 1, fourxm->fps);
fourxm->video_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_4XM;
st->codec->extradata_size = 4;
st->codec->extradata = av_malloc(4);
AV_WL32(st->codec->extradata, AV_RL32(buf + 16));
st->codec->width = AV_RL32(buf + 36);
st->codec->height = AV_RL32(buf + 40);
return 0;
}
| {
"code": [
" FourxmDemuxContext *fourxm, uint8_t *buf, int size)",
" if (size != vtrk_SIZE) {",
" FourxmDemuxContext *fourxm, uint8_t *buf, int size)"
],
"line_no": [
3,
11,
3
]
} | static int FUNC_0(AVFormatContext *VAR_0,
FourxmDemuxContext *VAR_1, uint8_t *VAR_2, int VAR_3)
{
AVStream *st;
if (VAR_3 != vtrk_SIZE) {
return AVERROR_INVALIDDATA;
}
st = avformat_new_stream(VAR_0, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 60, 1, VAR_1->fps);
VAR_1->video_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_4XM;
st->codec->extradata_size = 4;
st->codec->extradata = av_malloc(4);
AV_WL32(st->codec->extradata, AV_RL32(VAR_2 + 16));
st->codec->width = AV_RL32(VAR_2 + 36);
st->codec->height = AV_RL32(VAR_2 + 40);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0,\nFourxmDemuxContext *VAR_1, uint8_t *VAR_2, int VAR_3)\n{",
"AVStream *st;",
"if (VAR_3 != vtrk_SIZE) {",
"return AVERROR_INVALIDDATA;",
"}",
"st = avformat_new_stream(VAR_0, NULL);",
"if (!st)\nreturn AVERROR(ENOMEM);",
"avpriv_set_pts_info(st, 60, 1, VAR_1->fps);",
"VAR_1->video_stream_index = st->index;",
"st->codec->codec_type = AVMEDIA_TYPE_VIDEO;",
"st->codec->codec_id = AV_CODEC_ID_4XM;",
"st->codec->extradata_size = 4;",
"st->codec->extradata = av_malloc(4);",
"AV_WL32(st->codec->extradata, AV_RL32(VAR_2 + 16));",
"st->codec->width = AV_RL32(VAR_2 + 36);",
"st->codec->height = AV_RL32(VAR_2 + 40);",
"return 0;",
"}"
] | [
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
21
],
[
23,
25
],
[
29
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
]
] |
26,044 | void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd)
{
if (bs->backing_hd) {
assert(bs->backing_blocker);
bdrv_op_unblock_all(bs->backing_hd, bs->backing_blocker);
} else if (backing_hd) {
error_setg(&bs->backing_blocker,
"device is used as backing hd of '%s'",
bdrv_get_device_name(bs));
}
bs->backing_hd = backing_hd;
if (!backing_hd) {
error_free(bs->backing_blocker);
bs->backing_blocker = NULL;
goto out;
}
bs->open_flags &= ~BDRV_O_NO_BACKING;
pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_hd->filename);
pstrcpy(bs->backing_format, sizeof(bs->backing_format),
backing_hd->drv ? backing_hd->drv->format_name : "");
bdrv_op_block_all(bs->backing_hd, bs->backing_blocker);
/* Otherwise we won't be able to commit due to check in bdrv_commit */
bdrv_op_unblock(bs->backing_hd, BLOCK_OP_TYPE_COMMIT,
bs->backing_blocker);
out:
bdrv_refresh_limits(bs, NULL);
}
| true | qemu | bb00021de0b5908bc2c3ca467ad9a2b0c9c36459 | void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd)
{
if (bs->backing_hd) {
assert(bs->backing_blocker);
bdrv_op_unblock_all(bs->backing_hd, bs->backing_blocker);
} else if (backing_hd) {
error_setg(&bs->backing_blocker,
"device is used as backing hd of '%s'",
bdrv_get_device_name(bs));
}
bs->backing_hd = backing_hd;
if (!backing_hd) {
error_free(bs->backing_blocker);
bs->backing_blocker = NULL;
goto out;
}
bs->open_flags &= ~BDRV_O_NO_BACKING;
pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_hd->filename);
pstrcpy(bs->backing_format, sizeof(bs->backing_format),
backing_hd->drv ? backing_hd->drv->format_name : "");
bdrv_op_block_all(bs->backing_hd, bs->backing_blocker);
bdrv_op_unblock(bs->backing_hd, BLOCK_OP_TYPE_COMMIT,
bs->backing_blocker);
out:
bdrv_refresh_limits(bs, NULL);
}
| {
"code": [
" bdrv_op_unblock(bs->backing_hd, BLOCK_OP_TYPE_COMMIT,"
],
"line_no": [
51
]
} | void FUNC_0(BlockDriverState *VAR_0, BlockDriverState *VAR_1)
{
if (VAR_0->VAR_1) {
assert(VAR_0->backing_blocker);
bdrv_op_unblock_all(VAR_0->VAR_1, VAR_0->backing_blocker);
} else if (VAR_1) {
error_setg(&VAR_0->backing_blocker,
"device is used as backing hd of '%s'",
bdrv_get_device_name(VAR_0));
}
VAR_0->VAR_1 = VAR_1;
if (!VAR_1) {
error_free(VAR_0->backing_blocker);
VAR_0->backing_blocker = NULL;
goto out;
}
VAR_0->open_flags &= ~BDRV_O_NO_BACKING;
pstrcpy(VAR_0->backing_file, sizeof(VAR_0->backing_file), VAR_1->filename);
pstrcpy(VAR_0->backing_format, sizeof(VAR_0->backing_format),
VAR_1->drv ? VAR_1->drv->format_name : "");
bdrv_op_block_all(VAR_0->VAR_1, VAR_0->backing_blocker);
bdrv_op_unblock(VAR_0->VAR_1, BLOCK_OP_TYPE_COMMIT,
VAR_0->backing_blocker);
out:
bdrv_refresh_limits(VAR_0, NULL);
}
| [
"void FUNC_0(BlockDriverState *VAR_0, BlockDriverState *VAR_1)\n{",
"if (VAR_0->VAR_1) {",
"assert(VAR_0->backing_blocker);",
"bdrv_op_unblock_all(VAR_0->VAR_1, VAR_0->backing_blocker);",
"} else if (VAR_1) {",
"error_setg(&VAR_0->backing_blocker,\n\"device is used as backing hd of '%s'\",\nbdrv_get_device_name(VAR_0));",
"}",
"VAR_0->VAR_1 = VAR_1;",
"if (!VAR_1) {",
"error_free(VAR_0->backing_blocker);",
"VAR_0->backing_blocker = NULL;",
"goto out;",
"}",
"VAR_0->open_flags &= ~BDRV_O_NO_BACKING;",
"pstrcpy(VAR_0->backing_file, sizeof(VAR_0->backing_file), VAR_1->filename);",
"pstrcpy(VAR_0->backing_format, sizeof(VAR_0->backing_format),\nVAR_1->drv ? VAR_1->drv->format_name : \"\");",
"bdrv_op_block_all(VAR_0->VAR_1, VAR_0->backing_blocker);",
"bdrv_op_unblock(VAR_0->VAR_1, BLOCK_OP_TYPE_COMMIT,\nVAR_0->backing_blocker);",
"out:\nbdrv_refresh_limits(VAR_0, NULL);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15,
17,
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
47
],
[
51,
53
],
[
55,
57
],
[
59
]
] |
26,045 | static void scsi_command_complete(void *opaque, int ret)
{
SCSIGenericReq *r = (SCSIGenericReq *)opaque;
SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, r->req.dev);
r->req.aiocb = NULL;
s->driver_status = r->io_header.driver_status;
if (s->driver_status & SG_ERR_DRIVER_SENSE)
s->senselen = r->io_header.sb_len_wr;
if (ret != 0)
r->req.status = BUSY;
else {
if (s->driver_status & SG_ERR_DRIVER_TIMEOUT) {
r->req.status = BUSY;
BADF("Driver Timeout\n");
} else if (r->io_header.status)
r->req.status = r->io_header.status;
else if (s->driver_status & SG_ERR_DRIVER_SENSE)
r->req.status = CHECK_CONDITION;
else
r->req.status = GOOD;
}
DPRINTF("Command complete 0x%p tag=0x%x status=%d\n",
r, r->req.tag, r->req.status);
scsi_req_complete(&r->req);
}
| true | qemu | a1f0cce2ac0243572ff72aa561da67fe3766a395 | static void scsi_command_complete(void *opaque, int ret)
{
SCSIGenericReq *r = (SCSIGenericReq *)opaque;
SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, r->req.dev);
r->req.aiocb = NULL;
s->driver_status = r->io_header.driver_status;
if (s->driver_status & SG_ERR_DRIVER_SENSE)
s->senselen = r->io_header.sb_len_wr;
if (ret != 0)
r->req.status = BUSY;
else {
if (s->driver_status & SG_ERR_DRIVER_TIMEOUT) {
r->req.status = BUSY;
BADF("Driver Timeout\n");
} else if (r->io_header.status)
r->req.status = r->io_header.status;
else if (s->driver_status & SG_ERR_DRIVER_SENSE)
r->req.status = CHECK_CONDITION;
else
r->req.status = GOOD;
}
DPRINTF("Command complete 0x%p tag=0x%x status=%d\n",
r, r->req.tag, r->req.status);
scsi_req_complete(&r->req);
}
| {
"code": [
" if (ret != 0)",
" r->req.status = BUSY;",
" else {"
],
"line_no": [
21,
23,
25
]
} | static void FUNC_0(void *VAR_0, int VAR_1)
{
SCSIGenericReq *r = (SCSIGenericReq *)VAR_0;
SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, r->req.dev);
r->req.aiocb = NULL;
s->driver_status = r->io_header.driver_status;
if (s->driver_status & SG_ERR_DRIVER_SENSE)
s->senselen = r->io_header.sb_len_wr;
if (VAR_1 != 0)
r->req.status = BUSY;
else {
if (s->driver_status & SG_ERR_DRIVER_TIMEOUT) {
r->req.status = BUSY;
BADF("Driver Timeout\n");
} else if (r->io_header.status)
r->req.status = r->io_header.status;
else if (s->driver_status & SG_ERR_DRIVER_SENSE)
r->req.status = CHECK_CONDITION;
else
r->req.status = GOOD;
}
DPRINTF("Command complete 0x%p tag=0x%x status=%d\n",
r, r->req.tag, r->req.status);
scsi_req_complete(&r->req);
}
| [
"static void FUNC_0(void *VAR_0, int VAR_1)\n{",
"SCSIGenericReq *r = (SCSIGenericReq *)VAR_0;",
"SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, r->req.dev);",
"r->req.aiocb = NULL;",
"s->driver_status = r->io_header.driver_status;",
"if (s->driver_status & SG_ERR_DRIVER_SENSE)\ns->senselen = r->io_header.sb_len_wr;",
"if (VAR_1 != 0)\nr->req.status = BUSY;",
"else {",
"if (s->driver_status & SG_ERR_DRIVER_TIMEOUT) {",
"r->req.status = BUSY;",
"BADF(\"Driver Timeout\\n\");",
"} else if (r->io_header.status)",
"r->req.status = r->io_header.status;",
"else if (s->driver_status & SG_ERR_DRIVER_SENSE)\nr->req.status = CHECK_CONDITION;",
"else\nr->req.status = GOOD;",
"}",
"DPRINTF(\"Command complete 0x%p tag=0x%x status=%d\\n\",\nr, r->req.tag, r->req.status);",
"scsi_req_complete(&r->req);",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15,
17
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41,
43
],
[
45
],
[
47,
49
],
[
53
],
[
55
]
] |
26,046 | static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs,
int64_t offset,
int64_t length,
uint64_t addend,
bool decrease,
enum qcow2_discard_type type)
{
BDRVQcowState *s = bs->opaque;
int64_t start, last, cluster_offset;
uint16_t *refcount_block = NULL;
int64_t old_table_index = -1;
int ret;
#ifdef DEBUG_ALLOC2
fprintf(stderr, "update_refcount: offset=%" PRId64 " size=%" PRId64
" addend=%s%" PRIu64 "\n", offset, length, decrease ? "-" : "",
addend);
#endif
if (length < 0) {
return -EINVAL;
} else if (length == 0) {
return 0;
}
if (decrease) {
qcow2_cache_set_dependency(bs, s->refcount_block_cache,
s->l2_table_cache);
}
start = start_of_cluster(s, offset);
last = start_of_cluster(s, offset + length - 1);
for(cluster_offset = start; cluster_offset <= last;
cluster_offset += s->cluster_size)
{
int block_index;
uint64_t refcount;
int64_t cluster_index = cluster_offset >> s->cluster_bits;
int64_t table_index = cluster_index >> s->refcount_block_bits;
/* Load the refcount block and allocate it if needed */
if (table_index != old_table_index) {
if (refcount_block) {
ret = qcow2_cache_put(bs, s->refcount_block_cache,
(void**) &refcount_block);
if (ret < 0) {
goto fail;
}
}
ret = alloc_refcount_block(bs, cluster_index, &refcount_block);
if (ret < 0) {
goto fail;
}
}
old_table_index = table_index;
qcow2_cache_entry_mark_dirty(s->refcount_block_cache, refcount_block);
/* we can update the count and save it */
block_index = cluster_index & (s->refcount_block_size - 1);
refcount = be16_to_cpu(refcount_block[block_index]);
if (decrease ? (refcount - addend > refcount)
: (refcount + addend < refcount ||
refcount + addend > s->refcount_max))
{
ret = -EINVAL;
goto fail;
}
if (decrease) {
refcount -= addend;
} else {
refcount += addend;
}
if (refcount == 0 && cluster_index < s->free_cluster_index) {
s->free_cluster_index = cluster_index;
}
refcount_block[block_index] = cpu_to_be16(refcount);
if (refcount == 0 && s->discard_passthrough[type]) {
update_refcount_discard(bs, cluster_offset, s->cluster_size);
}
}
ret = 0;
fail:
if (!s->cache_discards) {
qcow2_process_discards(bs, ret);
}
/* Write last changed block to disk */
if (refcount_block) {
int wret;
wret = qcow2_cache_put(bs, s->refcount_block_cache,
(void**) &refcount_block);
if (wret < 0) {
return ret < 0 ? ret : wret;
}
}
/*
* Try do undo any updates if an error is returned (This may succeed in
* some cases like ENOSPC for allocating a new refcount block)
*/
if (ret < 0) {
int dummy;
dummy = update_refcount(bs, offset, cluster_offset - offset, addend,
!decrease, QCOW2_DISCARD_NEVER);
(void)dummy;
}
return ret;
}
| true | qemu | 7453c96b78c2b09aa72924f933bb9616e5474194 | static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs,
int64_t offset,
int64_t length,
uint64_t addend,
bool decrease,
enum qcow2_discard_type type)
{
BDRVQcowState *s = bs->opaque;
int64_t start, last, cluster_offset;
uint16_t *refcount_block = NULL;
int64_t old_table_index = -1;
int ret;
#ifdef DEBUG_ALLOC2
fprintf(stderr, "update_refcount: offset=%" PRId64 " size=%" PRId64
" addend=%s%" PRIu64 "\n", offset, length, decrease ? "-" : "",
addend);
#endif
if (length < 0) {
return -EINVAL;
} else if (length == 0) {
return 0;
}
if (decrease) {
qcow2_cache_set_dependency(bs, s->refcount_block_cache,
s->l2_table_cache);
}
start = start_of_cluster(s, offset);
last = start_of_cluster(s, offset + length - 1);
for(cluster_offset = start; cluster_offset <= last;
cluster_offset += s->cluster_size)
{
int block_index;
uint64_t refcount;
int64_t cluster_index = cluster_offset >> s->cluster_bits;
int64_t table_index = cluster_index >> s->refcount_block_bits;
if (table_index != old_table_index) {
if (refcount_block) {
ret = qcow2_cache_put(bs, s->refcount_block_cache,
(void**) &refcount_block);
if (ret < 0) {
goto fail;
}
}
ret = alloc_refcount_block(bs, cluster_index, &refcount_block);
if (ret < 0) {
goto fail;
}
}
old_table_index = table_index;
qcow2_cache_entry_mark_dirty(s->refcount_block_cache, refcount_block);
block_index = cluster_index & (s->refcount_block_size - 1);
refcount = be16_to_cpu(refcount_block[block_index]);
if (decrease ? (refcount - addend > refcount)
: (refcount + addend < refcount ||
refcount + addend > s->refcount_max))
{
ret = -EINVAL;
goto fail;
}
if (decrease) {
refcount -= addend;
} else {
refcount += addend;
}
if (refcount == 0 && cluster_index < s->free_cluster_index) {
s->free_cluster_index = cluster_index;
}
refcount_block[block_index] = cpu_to_be16(refcount);
if (refcount == 0 && s->discard_passthrough[type]) {
update_refcount_discard(bs, cluster_offset, s->cluster_size);
}
}
ret = 0;
fail:
if (!s->cache_discards) {
qcow2_process_discards(bs, ret);
}
if (refcount_block) {
int wret;
wret = qcow2_cache_put(bs, s->refcount_block_cache,
(void**) &refcount_block);
if (wret < 0) {
return ret < 0 ? ret : wret;
}
}
if (ret < 0) {
int dummy;
dummy = update_refcount(bs, offset, cluster_offset - offset, addend,
!decrease, QCOW2_DISCARD_NEVER);
(void)dummy;
}
return ret;
}
| {
"code": [
" uint16_t *refcount_block = NULL;",
" (void**) &refcount_block);",
" refcount = be16_to_cpu(refcount_block[block_index]);",
" refcount_block[block_index] = cpu_to_be16(refcount);",
" wret = qcow2_cache_put(bs, s->refcount_block_cache,",
" (void**) &refcount_block);"
],
"line_no": [
19,
87,
123,
155,
187,
189
]
} | static int VAR_0 update_refcount(BlockDriverState *bs,
int64_t offset,
int64_t length,
uint64_t addend,
bool decrease,
enum qcow2_discard_type type)
{
BDRVQcowState *s = bs->opaque;
int64_t start, last, cluster_offset;
uint16_t *refcount_block = NULL;
int64_t old_table_index = -1;
int ret;
#ifdef DEBUG_ALLOC2
fprintf(stderr, "update_refcount: offset=%" PRId64 " size=%" PRId64
" addend=%s%" PRIu64 "\n", offset, length, decrease ? "-" : "",
addend);
#endif
if (length < 0) {
return -EINVAL;
} else if (length == 0) {
return 0;
}
if (decrease) {
qcow2_cache_set_dependency(bs, s->refcount_block_cache,
s->l2_table_cache);
}
start = start_of_cluster(s, offset);
last = start_of_cluster(s, offset + length - 1);
for(cluster_offset = start; cluster_offset <= last;
cluster_offset += s->cluster_size)
{
int block_index;
uint64_t refcount;
int64_t cluster_index = cluster_offset >> s->cluster_bits;
int64_t table_index = cluster_index >> s->refcount_block_bits;
if (table_index != old_table_index) {
if (refcount_block) {
ret = qcow2_cache_put(bs, s->refcount_block_cache,
(void**) &refcount_block);
if (ret < 0) {
goto fail;
}
}
ret = alloc_refcount_block(bs, cluster_index, &refcount_block);
if (ret < 0) {
goto fail;
}
}
old_table_index = table_index;
qcow2_cache_entry_mark_dirty(s->refcount_block_cache, refcount_block);
block_index = cluster_index & (s->refcount_block_size - 1);
refcount = be16_to_cpu(refcount_block[block_index]);
if (decrease ? (refcount - addend > refcount)
: (refcount + addend < refcount ||
refcount + addend > s->refcount_max))
{
ret = -EINVAL;
goto fail;
}
if (decrease) {
refcount -= addend;
} else {
refcount += addend;
}
if (refcount == 0 && cluster_index < s->free_cluster_index) {
s->free_cluster_index = cluster_index;
}
refcount_block[block_index] = cpu_to_be16(refcount);
if (refcount == 0 && s->discard_passthrough[type]) {
update_refcount_discard(bs, cluster_offset, s->cluster_size);
}
}
ret = 0;
fail:
if (!s->cache_discards) {
qcow2_process_discards(bs, ret);
}
if (refcount_block) {
int wret;
wret = qcow2_cache_put(bs, s->refcount_block_cache,
(void**) &refcount_block);
if (wret < 0) {
return ret < 0 ? ret : wret;
}
}
if (ret < 0) {
int dummy;
dummy = update_refcount(bs, offset, cluster_offset - offset, addend,
!decrease, QCOW2_DISCARD_NEVER);
(void)dummy;
}
return ret;
}
| [
"static int VAR_0 update_refcount(BlockDriverState *bs,\nint64_t offset,\nint64_t length,\nuint64_t addend,\nbool decrease,\nenum qcow2_discard_type type)\n{",
"BDRVQcowState *s = bs->opaque;",
"int64_t start, last, cluster_offset;",
"uint16_t *refcount_block = NULL;",
"int64_t old_table_index = -1;",
"int ret;",
"#ifdef DEBUG_ALLOC2\nfprintf(stderr, \"update_refcount: offset=%\" PRId64 \" size=%\" PRId64\n\" addend=%s%\" PRIu64 \"\\n\", offset, length, decrease ? \"-\" : \"\",\naddend);",
"#endif\nif (length < 0) {",
"return -EINVAL;",
"} else if (length == 0) {",
"return 0;",
"}",
"if (decrease) {",
"qcow2_cache_set_dependency(bs, s->refcount_block_cache,\ns->l2_table_cache);",
"}",
"start = start_of_cluster(s, offset);",
"last = start_of_cluster(s, offset + length - 1);",
"for(cluster_offset = start; cluster_offset <= last;",
"cluster_offset += s->cluster_size)\n{",
"int block_index;",
"uint64_t refcount;",
"int64_t cluster_index = cluster_offset >> s->cluster_bits;",
"int64_t table_index = cluster_index >> s->refcount_block_bits;",
"if (table_index != old_table_index) {",
"if (refcount_block) {",
"ret = qcow2_cache_put(bs, s->refcount_block_cache,\n(void**) &refcount_block);",
"if (ret < 0) {",
"goto fail;",
"}",
"}",
"ret = alloc_refcount_block(bs, cluster_index, &refcount_block);",
"if (ret < 0) {",
"goto fail;",
"}",
"}",
"old_table_index = table_index;",
"qcow2_cache_entry_mark_dirty(s->refcount_block_cache, refcount_block);",
"block_index = cluster_index & (s->refcount_block_size - 1);",
"refcount = be16_to_cpu(refcount_block[block_index]);",
"if (decrease ? (refcount - addend > refcount)\n: (refcount + addend < refcount ||\nrefcount + addend > s->refcount_max))\n{",
"ret = -EINVAL;",
"goto fail;",
"}",
"if (decrease) {",
"refcount -= addend;",
"} else {",
"refcount += addend;",
"}",
"if (refcount == 0 && cluster_index < s->free_cluster_index) {",
"s->free_cluster_index = cluster_index;",
"}",
"refcount_block[block_index] = cpu_to_be16(refcount);",
"if (refcount == 0 && s->discard_passthrough[type]) {",
"update_refcount_discard(bs, cluster_offset, s->cluster_size);",
"}",
"}",
"ret = 0;",
"fail:\nif (!s->cache_discards) {",
"qcow2_process_discards(bs, ret);",
"}",
"if (refcount_block) {",
"int wret;",
"wret = qcow2_cache_put(bs, s->refcount_block_cache,\n(void**) &refcount_block);",
"if (wret < 0) {",
"return ret < 0 ? ret : wret;",
"}",
"}",
"if (ret < 0) {",
"int dummy;",
"dummy = update_refcount(bs, offset, cluster_offset - offset, addend,\n!decrease, QCOW2_DISCARD_NEVER);",
"(void)dummy;",
"}",
"return ret;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
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,
1,
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,
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27,
29,
31,
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51,
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
81
],
[
83
],
[
85,
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
119
],
[
123
],
[
125,
127,
129,
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169
],
[
171,
173
],
[
175
],
[
177
],
[
183
],
[
185
],
[
187,
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
209
],
[
211
],
[
213,
215
],
[
217
],
[
219
],
[
223
],
[
225
]
] |
26,047 | int ff_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size)
{
GetBitContext gb;
int specific_config_bitindex;
init_get_bits(&gb, buf, buf_size*8);
c->object_type = get_object_type(&gb);
c->sample_rate = get_sample_rate(&gb, &c->sampling_index);
c->chan_config = get_bits(&gb, 4);
if (c->chan_config < FF_ARRAY_ELEMS(ff_mpeg4audio_channels))
c->channels = ff_mpeg4audio_channels[c->chan_config];
c->sbr = -1;
if (c->object_type == AOT_SBR || (c->object_type == AOT_PS &&
// check for W6132 Annex YYYY draft MP3onMP4
!(show_bits(&gb, 3) & 0x03 && !(show_bits(&gb, 9) & 0x3F)))) {
c->ext_object_type = AOT_SBR;
c->sbr = 1;
c->ext_sample_rate = get_sample_rate(&gb, &c->ext_sampling_index);
c->object_type = get_object_type(&gb);
if (c->object_type == AOT_ER_BSAC)
c->ext_chan_config = get_bits(&gb, 4);
} else {
c->ext_object_type = AOT_NULL;
c->ext_sample_rate = 0;
}
specific_config_bitindex = get_bits_count(&gb);
if (c->object_type == AOT_ALS) {
skip_bits(&gb, 5);
if (show_bits_long(&gb, 24) != MKBETAG('\0','A','L','S'))
skip_bits_long(&gb, 24);
specific_config_bitindex = get_bits_count(&gb);
if (parse_config_ALS(&gb, c))
return -1;
}
if (c->ext_object_type != AOT_SBR) {
int bits_left = buf_size*8 - get_bits_count(&gb);
for (; bits_left > 15; bits_left--) {
if (show_bits(&gb, 11) == 0x2b7) { // sync extension
get_bits(&gb, 11);
c->ext_object_type = get_object_type(&gb);
if (c->ext_object_type == AOT_SBR && (c->sbr = get_bits1(&gb)) == 1)
c->ext_sample_rate = get_sample_rate(&gb, &c->ext_sampling_index);
break;
} else
get_bits1(&gb); // skip 1 bit
}
}
return specific_config_bitindex;
}
| false | FFmpeg | 37216b99e090a88d98be57a8aab14a8316b96a71 | int ff_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size)
{
GetBitContext gb;
int specific_config_bitindex;
init_get_bits(&gb, buf, buf_size*8);
c->object_type = get_object_type(&gb);
c->sample_rate = get_sample_rate(&gb, &c->sampling_index);
c->chan_config = get_bits(&gb, 4);
if (c->chan_config < FF_ARRAY_ELEMS(ff_mpeg4audio_channels))
c->channels = ff_mpeg4audio_channels[c->chan_config];
c->sbr = -1;
if (c->object_type == AOT_SBR || (c->object_type == AOT_PS &&
!(show_bits(&gb, 3) & 0x03 && !(show_bits(&gb, 9) & 0x3F)))) {
c->ext_object_type = AOT_SBR;
c->sbr = 1;
c->ext_sample_rate = get_sample_rate(&gb, &c->ext_sampling_index);
c->object_type = get_object_type(&gb);
if (c->object_type == AOT_ER_BSAC)
c->ext_chan_config = get_bits(&gb, 4);
} else {
c->ext_object_type = AOT_NULL;
c->ext_sample_rate = 0;
}
specific_config_bitindex = get_bits_count(&gb);
if (c->object_type == AOT_ALS) {
skip_bits(&gb, 5);
if (show_bits_long(&gb, 24) != MKBETAG('\0','A','L','S'))
skip_bits_long(&gb, 24);
specific_config_bitindex = get_bits_count(&gb);
if (parse_config_ALS(&gb, c))
return -1;
}
if (c->ext_object_type != AOT_SBR) {
int bits_left = buf_size*8 - get_bits_count(&gb);
for (; bits_left > 15; bits_left--) {
if (show_bits(&gb, 11) == 0x2b7) {
get_bits(&gb, 11);
c->ext_object_type = get_object_type(&gb);
if (c->ext_object_type == AOT_SBR && (c->sbr = get_bits1(&gb)) == 1)
c->ext_sample_rate = get_sample_rate(&gb, &c->ext_sampling_index);
break;
} else
get_bits1(&gb);
}
}
return specific_config_bitindex;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(MPEG4AudioConfig *VAR_0, const uint8_t *VAR_1, int VAR_2)
{
GetBitContext gb;
int VAR_3;
init_get_bits(&gb, VAR_1, VAR_2*8);
VAR_0->object_type = get_object_type(&gb);
VAR_0->sample_rate = get_sample_rate(&gb, &VAR_0->sampling_index);
VAR_0->chan_config = get_bits(&gb, 4);
if (VAR_0->chan_config < FF_ARRAY_ELEMS(ff_mpeg4audio_channels))
VAR_0->channels = ff_mpeg4audio_channels[VAR_0->chan_config];
VAR_0->sbr = -1;
if (VAR_0->object_type == AOT_SBR || (VAR_0->object_type == AOT_PS &&
!(show_bits(&gb, 3) & 0x03 && !(show_bits(&gb, 9) & 0x3F)))) {
VAR_0->ext_object_type = AOT_SBR;
VAR_0->sbr = 1;
VAR_0->ext_sample_rate = get_sample_rate(&gb, &VAR_0->ext_sampling_index);
VAR_0->object_type = get_object_type(&gb);
if (VAR_0->object_type == AOT_ER_BSAC)
VAR_0->ext_chan_config = get_bits(&gb, 4);
} else {
VAR_0->ext_object_type = AOT_NULL;
VAR_0->ext_sample_rate = 0;
}
VAR_3 = get_bits_count(&gb);
if (VAR_0->object_type == AOT_ALS) {
skip_bits(&gb, 5);
if (show_bits_long(&gb, 24) != MKBETAG('\0','A','L','S'))
skip_bits_long(&gb, 24);
VAR_3 = get_bits_count(&gb);
if (parse_config_ALS(&gb, VAR_0))
return -1;
}
if (VAR_0->ext_object_type != AOT_SBR) {
int VAR_4 = VAR_2*8 - get_bits_count(&gb);
for (; VAR_4 > 15; VAR_4--) {
if (show_bits(&gb, 11) == 0x2b7) {
get_bits(&gb, 11);
VAR_0->ext_object_type = get_object_type(&gb);
if (VAR_0->ext_object_type == AOT_SBR && (VAR_0->sbr = get_bits1(&gb)) == 1)
VAR_0->ext_sample_rate = get_sample_rate(&gb, &VAR_0->ext_sampling_index);
break;
} else
get_bits1(&gb);
}
}
return VAR_3;
}
| [
"int FUNC_0(MPEG4AudioConfig *VAR_0, const uint8_t *VAR_1, int VAR_2)\n{",
"GetBitContext gb;",
"int VAR_3;",
"init_get_bits(&gb, VAR_1, VAR_2*8);",
"VAR_0->object_type = get_object_type(&gb);",
"VAR_0->sample_rate = get_sample_rate(&gb, &VAR_0->sampling_index);",
"VAR_0->chan_config = get_bits(&gb, 4);",
"if (VAR_0->chan_config < FF_ARRAY_ELEMS(ff_mpeg4audio_channels))\nVAR_0->channels = ff_mpeg4audio_channels[VAR_0->chan_config];",
"VAR_0->sbr = -1;",
"if (VAR_0->object_type == AOT_SBR || (VAR_0->object_type == AOT_PS &&\n!(show_bits(&gb, 3) & 0x03 && !(show_bits(&gb, 9) & 0x3F)))) {",
"VAR_0->ext_object_type = AOT_SBR;",
"VAR_0->sbr = 1;",
"VAR_0->ext_sample_rate = get_sample_rate(&gb, &VAR_0->ext_sampling_index);",
"VAR_0->object_type = get_object_type(&gb);",
"if (VAR_0->object_type == AOT_ER_BSAC)\nVAR_0->ext_chan_config = get_bits(&gb, 4);",
"} else {",
"VAR_0->ext_object_type = AOT_NULL;",
"VAR_0->ext_sample_rate = 0;",
"}",
"VAR_3 = get_bits_count(&gb);",
"if (VAR_0->object_type == AOT_ALS) {",
"skip_bits(&gb, 5);",
"if (show_bits_long(&gb, 24) != MKBETAG('\\0','A','L','S'))\nskip_bits_long(&gb, 24);",
"VAR_3 = get_bits_count(&gb);",
"if (parse_config_ALS(&gb, VAR_0))\nreturn -1;",
"}",
"if (VAR_0->ext_object_type != AOT_SBR) {",
"int VAR_4 = VAR_2*8 - get_bits_count(&gb);",
"for (; VAR_4 > 15; VAR_4--) {",
"if (show_bits(&gb, 11) == 0x2b7) {",
"get_bits(&gb, 11);",
"VAR_0->ext_object_type = get_object_type(&gb);",
"if (VAR_0->ext_object_type == AOT_SBR && (VAR_0->sbr = get_bits1(&gb)) == 1)\nVAR_0->ext_sample_rate = get_sample_rate(&gb, &VAR_0->ext_sampling_index);",
"break;",
"} else",
"get_bits1(&gb);",
"}",
"}",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59,
61
],
[
65
],
[
69,
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89,
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
]
] |
26,048 | void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW,
int nPbH, int log2_cb_size, int part_idx,
int merge_idx, MvField *mv,
int mvp_lx_flag, int LX)
{
HEVCLocalContext *lc = s->HEVClc;
MvField *tab_mvf = s->ref->tab_mvf;
int isScaledFlag_L0 = 0;
int availableFlagLXA0 = 1;
int availableFlagLXB0 = 1;
int numMVPCandLX = 0;
int min_pu_width = s->sps->min_pu_width;
int xA0, yA0;
int is_available_a0;
int xA1, yA1;
int is_available_a1;
int xB0, yB0;
int is_available_b0;
int xB1, yB1;
int is_available_b1;
int xB2, yB2;
int is_available_b2;
Mv mvpcand_list[2] = { { 0 } };
Mv mxA;
Mv mxB;
int ref_idx_curr = 0;
int ref_idx = 0;
int pred_flag_index_l0;
int pred_flag_index_l1;
const int cand_bottom_left = lc->na.cand_bottom_left;
const int cand_left = lc->na.cand_left;
const int cand_up_left = lc->na.cand_up_left;
const int cand_up = lc->na.cand_up;
const int cand_up_right = lc->na.cand_up_right_sap;
ref_idx_curr = LX;
ref_idx = mv->ref_idx[LX];
pred_flag_index_l0 = LX;
pred_flag_index_l1 = !LX;
// left bottom spatial candidate
xA0 = x0 - 1;
yA0 = y0 + nPbH;
is_available_a0 = AVAILABLE(cand_bottom_left, A0) &&
yA0 < s->sps->height &&
PRED_BLOCK_AVAILABLE(A0);
//left spatial merge candidate
xA1 = x0 - 1;
yA1 = y0 + nPbH - 1;
is_available_a1 = AVAILABLE(cand_left, A1);
if (is_available_a0 || is_available_a1)
isScaledFlag_L0 = 1;
if (is_available_a0) {
if (MP_MX(A0, pred_flag_index_l0, mxA)) {
goto b_candidates;
}
if (MP_MX(A0, pred_flag_index_l1, mxA)) {
goto b_candidates;
}
}
if (is_available_a1) {
if (MP_MX(A1, pred_flag_index_l0, mxA)) {
goto b_candidates;
}
if (MP_MX(A1, pred_flag_index_l1, mxA)) {
goto b_candidates;
}
}
if (is_available_a0) {
if (MP_MX_LT(A0, pred_flag_index_l0, mxA)) {
goto b_candidates;
}
if (MP_MX_LT(A0, pred_flag_index_l1, mxA)) {
goto b_candidates;
}
}
if (is_available_a1) {
if (MP_MX_LT(A1, pred_flag_index_l0, mxA)) {
goto b_candidates;
}
if (MP_MX_LT(A1, pred_flag_index_l1, mxA)) {
goto b_candidates;
}
}
availableFlagLXA0 = 0;
b_candidates:
// B candidates
// above right spatial merge candidate
xB0 = x0 + nPbW;
yB0 = y0 - 1;
is_available_b0 = AVAILABLE(cand_up_right, B0) &&
xB0 < s->sps->width &&
PRED_BLOCK_AVAILABLE(B0);
// above spatial merge candidate
xB1 = x0 + nPbW - 1;
yB1 = y0 - 1;
is_available_b1 = AVAILABLE(cand_up, B1);
// above left spatial merge candidate
xB2 = x0 - 1;
yB2 = y0 - 1;
is_available_b2 = AVAILABLE(cand_up_left, B2);
// above right spatial merge candidate
if (is_available_b0) {
if (MP_MX(B0, pred_flag_index_l0, mxB)) {
goto scalef;
}
if (MP_MX(B0, pred_flag_index_l1, mxB)) {
goto scalef;
}
}
// above spatial merge candidate
if (is_available_b1) {
if (MP_MX(B1, pred_flag_index_l0, mxB)) {
goto scalef;
}
if (MP_MX(B1, pred_flag_index_l1, mxB)) {
goto scalef;
}
}
// above left spatial merge candidate
if (is_available_b2) {
if (MP_MX(B2, pred_flag_index_l0, mxB)) {
goto scalef;
}
if (MP_MX(B2, pred_flag_index_l1, mxB)) {
goto scalef;
}
}
availableFlagLXB0 = 0;
scalef:
if (!isScaledFlag_L0) {
if (availableFlagLXB0) {
availableFlagLXA0 = 1;
mxA = mxB;
}
availableFlagLXB0 = 0;
// XB0 and L1
if (is_available_b0) {
availableFlagLXB0 = MP_MX_LT(B0, pred_flag_index_l0, mxB);
if (!availableFlagLXB0)
availableFlagLXB0 = MP_MX_LT(B0, pred_flag_index_l1, mxB);
}
if (is_available_b1 && !availableFlagLXB0) {
availableFlagLXB0 = MP_MX_LT(B1, pred_flag_index_l0, mxB);
if (!availableFlagLXB0)
availableFlagLXB0 = MP_MX_LT(B1, pred_flag_index_l1, mxB);
}
if (is_available_b2 && !availableFlagLXB0) {
availableFlagLXB0 = MP_MX_LT(B2, pred_flag_index_l0, mxB);
if (!availableFlagLXB0)
availableFlagLXB0 = MP_MX_LT(B2, pred_flag_index_l1, mxB);
}
}
if (availableFlagLXA0)
mvpcand_list[numMVPCandLX++] = mxA;
if (availableFlagLXB0 && (!availableFlagLXA0 || mxA.x != mxB.x || mxA.y != mxB.y))
mvpcand_list[numMVPCandLX++] = mxB;
//temporal motion vector prediction candidate
if (numMVPCandLX < 2 && s->sh.slice_temporal_mvp_enabled_flag &&
mvp_lx_flag == numMVPCandLX) {
Mv mv_col;
int available_col = temporal_luma_motion_vector(s, x0, y0, nPbW,
nPbH, ref_idx,
&mv_col, LX);
if (available_col)
mvpcand_list[numMVPCandLX++] = mv_col;
}
mv->mv[LX] = mvpcand_list[mvp_lx_flag];
}
| false | FFmpeg | 97bb456b6b787bb36e2785072e604ba0db9a43df | void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW,
int nPbH, int log2_cb_size, int part_idx,
int merge_idx, MvField *mv,
int mvp_lx_flag, int LX)
{
HEVCLocalContext *lc = s->HEVClc;
MvField *tab_mvf = s->ref->tab_mvf;
int isScaledFlag_L0 = 0;
int availableFlagLXA0 = 1;
int availableFlagLXB0 = 1;
int numMVPCandLX = 0;
int min_pu_width = s->sps->min_pu_width;
int xA0, yA0;
int is_available_a0;
int xA1, yA1;
int is_available_a1;
int xB0, yB0;
int is_available_b0;
int xB1, yB1;
int is_available_b1;
int xB2, yB2;
int is_available_b2;
Mv mvpcand_list[2] = { { 0 } };
Mv mxA;
Mv mxB;
int ref_idx_curr = 0;
int ref_idx = 0;
int pred_flag_index_l0;
int pred_flag_index_l1;
const int cand_bottom_left = lc->na.cand_bottom_left;
const int cand_left = lc->na.cand_left;
const int cand_up_left = lc->na.cand_up_left;
const int cand_up = lc->na.cand_up;
const int cand_up_right = lc->na.cand_up_right_sap;
ref_idx_curr = LX;
ref_idx = mv->ref_idx[LX];
pred_flag_index_l0 = LX;
pred_flag_index_l1 = !LX;
xA0 = x0 - 1;
yA0 = y0 + nPbH;
is_available_a0 = AVAILABLE(cand_bottom_left, A0) &&
yA0 < s->sps->height &&
PRED_BLOCK_AVAILABLE(A0);
xA1 = x0 - 1;
yA1 = y0 + nPbH - 1;
is_available_a1 = AVAILABLE(cand_left, A1);
if (is_available_a0 || is_available_a1)
isScaledFlag_L0 = 1;
if (is_available_a0) {
if (MP_MX(A0, pred_flag_index_l0, mxA)) {
goto b_candidates;
}
if (MP_MX(A0, pred_flag_index_l1, mxA)) {
goto b_candidates;
}
}
if (is_available_a1) {
if (MP_MX(A1, pred_flag_index_l0, mxA)) {
goto b_candidates;
}
if (MP_MX(A1, pred_flag_index_l1, mxA)) {
goto b_candidates;
}
}
if (is_available_a0) {
if (MP_MX_LT(A0, pred_flag_index_l0, mxA)) {
goto b_candidates;
}
if (MP_MX_LT(A0, pred_flag_index_l1, mxA)) {
goto b_candidates;
}
}
if (is_available_a1) {
if (MP_MX_LT(A1, pred_flag_index_l0, mxA)) {
goto b_candidates;
}
if (MP_MX_LT(A1, pred_flag_index_l1, mxA)) {
goto b_candidates;
}
}
availableFlagLXA0 = 0;
b_candidates:
xB0 = x0 + nPbW;
yB0 = y0 - 1;
is_available_b0 = AVAILABLE(cand_up_right, B0) &&
xB0 < s->sps->width &&
PRED_BLOCK_AVAILABLE(B0);
xB1 = x0 + nPbW - 1;
yB1 = y0 - 1;
is_available_b1 = AVAILABLE(cand_up, B1);
xB2 = x0 - 1;
yB2 = y0 - 1;
is_available_b2 = AVAILABLE(cand_up_left, B2);
if (is_available_b0) {
if (MP_MX(B0, pred_flag_index_l0, mxB)) {
goto scalef;
}
if (MP_MX(B0, pred_flag_index_l1, mxB)) {
goto scalef;
}
}
if (is_available_b1) {
if (MP_MX(B1, pred_flag_index_l0, mxB)) {
goto scalef;
}
if (MP_MX(B1, pred_flag_index_l1, mxB)) {
goto scalef;
}
}
if (is_available_b2) {
if (MP_MX(B2, pred_flag_index_l0, mxB)) {
goto scalef;
}
if (MP_MX(B2, pred_flag_index_l1, mxB)) {
goto scalef;
}
}
availableFlagLXB0 = 0;
scalef:
if (!isScaledFlag_L0) {
if (availableFlagLXB0) {
availableFlagLXA0 = 1;
mxA = mxB;
}
availableFlagLXB0 = 0;
if (is_available_b0) {
availableFlagLXB0 = MP_MX_LT(B0, pred_flag_index_l0, mxB);
if (!availableFlagLXB0)
availableFlagLXB0 = MP_MX_LT(B0, pred_flag_index_l1, mxB);
}
if (is_available_b1 && !availableFlagLXB0) {
availableFlagLXB0 = MP_MX_LT(B1, pred_flag_index_l0, mxB);
if (!availableFlagLXB0)
availableFlagLXB0 = MP_MX_LT(B1, pred_flag_index_l1, mxB);
}
if (is_available_b2 && !availableFlagLXB0) {
availableFlagLXB0 = MP_MX_LT(B2, pred_flag_index_l0, mxB);
if (!availableFlagLXB0)
availableFlagLXB0 = MP_MX_LT(B2, pred_flag_index_l1, mxB);
}
}
if (availableFlagLXA0)
mvpcand_list[numMVPCandLX++] = mxA;
if (availableFlagLXB0 && (!availableFlagLXA0 || mxA.x != mxB.x || mxA.y != mxB.y))
mvpcand_list[numMVPCandLX++] = mxB;
if (numMVPCandLX < 2 && s->sh.slice_temporal_mvp_enabled_flag &&
mvp_lx_flag == numMVPCandLX) {
Mv mv_col;
int available_col = temporal_luma_motion_vector(s, x0, y0, nPbW,
nPbH, ref_idx,
&mv_col, LX);
if (available_col)
mvpcand_list[numMVPCandLX++] = mv_col;
}
mv->mv[LX] = mvpcand_list[mvp_lx_flag];
}
| {
"code": [],
"line_no": []
} | void FUNC_0(HEVCContext *VAR_0, int VAR_1, int VAR_2, int VAR_3,
int VAR_4, int VAR_5, int VAR_6,
int VAR_7, MvField *VAR_8,
int VAR_9, int VAR_10)
{
HEVCLocalContext *lc = VAR_0->HEVClc;
MvField *tab_mvf = VAR_0->ref->tab_mvf;
int VAR_11 = 0;
int VAR_12 = 1;
int VAR_13 = 1;
int VAR_14 = 0;
int VAR_15 = VAR_0->sps->VAR_15;
int VAR_16, VAR_17;
int VAR_18;
int VAR_19, VAR_20;
int VAR_21;
int VAR_22, VAR_23;
int VAR_24;
int VAR_25, VAR_26;
int VAR_27;
int VAR_28, VAR_29;
int VAR_30;
Mv mvpcand_list[2] = { { 0 } };
Mv mxA;
Mv mxB;
int VAR_31 = 0;
int VAR_32 = 0;
int VAR_33;
int VAR_34;
const int VAR_35 = lc->na.VAR_35;
const int VAR_36 = lc->na.VAR_36;
const int VAR_37 = lc->na.VAR_37;
const int VAR_38 = lc->na.VAR_38;
const int VAR_39 = lc->na.cand_up_right_sap;
VAR_31 = VAR_10;
VAR_32 = VAR_8->VAR_32[VAR_10];
VAR_33 = VAR_10;
VAR_34 = !VAR_10;
VAR_16 = VAR_1 - 1;
VAR_17 = VAR_2 + VAR_4;
VAR_18 = AVAILABLE(VAR_35, A0) &&
VAR_17 < VAR_0->sps->height &&
PRED_BLOCK_AVAILABLE(A0);
VAR_19 = VAR_1 - 1;
VAR_20 = VAR_2 + VAR_4 - 1;
VAR_21 = AVAILABLE(VAR_36, A1);
if (VAR_18 || VAR_21)
VAR_11 = 1;
if (VAR_18) {
if (MP_MX(A0, VAR_33, mxA)) {
goto b_candidates;
}
if (MP_MX(A0, VAR_34, mxA)) {
goto b_candidates;
}
}
if (VAR_21) {
if (MP_MX(A1, VAR_33, mxA)) {
goto b_candidates;
}
if (MP_MX(A1, VAR_34, mxA)) {
goto b_candidates;
}
}
if (VAR_18) {
if (MP_MX_LT(A0, VAR_33, mxA)) {
goto b_candidates;
}
if (MP_MX_LT(A0, VAR_34, mxA)) {
goto b_candidates;
}
}
if (VAR_21) {
if (MP_MX_LT(A1, VAR_33, mxA)) {
goto b_candidates;
}
if (MP_MX_LT(A1, VAR_34, mxA)) {
goto b_candidates;
}
}
VAR_12 = 0;
b_candidates:
VAR_22 = VAR_1 + VAR_3;
VAR_23 = VAR_2 - 1;
VAR_24 = AVAILABLE(VAR_39, B0) &&
VAR_22 < VAR_0->sps->width &&
PRED_BLOCK_AVAILABLE(B0);
VAR_25 = VAR_1 + VAR_3 - 1;
VAR_26 = VAR_2 - 1;
VAR_27 = AVAILABLE(VAR_38, B1);
VAR_28 = VAR_1 - 1;
VAR_29 = VAR_2 - 1;
VAR_30 = AVAILABLE(VAR_37, B2);
if (VAR_24) {
if (MP_MX(B0, VAR_33, mxB)) {
goto scalef;
}
if (MP_MX(B0, VAR_34, mxB)) {
goto scalef;
}
}
if (VAR_27) {
if (MP_MX(B1, VAR_33, mxB)) {
goto scalef;
}
if (MP_MX(B1, VAR_34, mxB)) {
goto scalef;
}
}
if (VAR_30) {
if (MP_MX(B2, VAR_33, mxB)) {
goto scalef;
}
if (MP_MX(B2, VAR_34, mxB)) {
goto scalef;
}
}
VAR_13 = 0;
scalef:
if (!VAR_11) {
if (VAR_13) {
VAR_12 = 1;
mxA = mxB;
}
VAR_13 = 0;
if (VAR_24) {
VAR_13 = MP_MX_LT(B0, VAR_33, mxB);
if (!VAR_13)
VAR_13 = MP_MX_LT(B0, VAR_34, mxB);
}
if (VAR_27 && !VAR_13) {
VAR_13 = MP_MX_LT(B1, VAR_33, mxB);
if (!VAR_13)
VAR_13 = MP_MX_LT(B1, VAR_34, mxB);
}
if (VAR_30 && !VAR_13) {
VAR_13 = MP_MX_LT(B2, VAR_33, mxB);
if (!VAR_13)
VAR_13 = MP_MX_LT(B2, VAR_34, mxB);
}
}
if (VAR_12)
mvpcand_list[VAR_14++] = mxA;
if (VAR_13 && (!VAR_12 || mxA.x != mxB.x || mxA.y != mxB.y))
mvpcand_list[VAR_14++] = mxB;
if (VAR_14 < 2 && VAR_0->sh.slice_temporal_mvp_enabled_flag &&
VAR_9 == VAR_14) {
Mv mv_col;
int VAR_40 = temporal_luma_motion_vector(VAR_0, VAR_1, VAR_2, VAR_3,
VAR_4, VAR_32,
&mv_col, VAR_10);
if (VAR_40)
mvpcand_list[VAR_14++] = mv_col;
}
VAR_8->VAR_8[VAR_10] = mvpcand_list[VAR_9];
}
| [
"void FUNC_0(HEVCContext *VAR_0, int VAR_1, int VAR_2, int VAR_3,\nint VAR_4, int VAR_5, int VAR_6,\nint VAR_7, MvField *VAR_8,\nint VAR_9, int VAR_10)\n{",
"HEVCLocalContext *lc = VAR_0->HEVClc;",
"MvField *tab_mvf = VAR_0->ref->tab_mvf;",
"int VAR_11 = 0;",
"int VAR_12 = 1;",
"int VAR_13 = 1;",
"int VAR_14 = 0;",
"int VAR_15 = VAR_0->sps->VAR_15;",
"int VAR_16, VAR_17;",
"int VAR_18;",
"int VAR_19, VAR_20;",
"int VAR_21;",
"int VAR_22, VAR_23;",
"int VAR_24;",
"int VAR_25, VAR_26;",
"int VAR_27;",
"int VAR_28, VAR_29;",
"int VAR_30;",
"Mv mvpcand_list[2] = { { 0 } };",
"Mv mxA;",
"Mv mxB;",
"int VAR_31 = 0;",
"int VAR_32 = 0;",
"int VAR_33;",
"int VAR_34;",
"const int VAR_35 = lc->na.VAR_35;",
"const int VAR_36 = lc->na.VAR_36;",
"const int VAR_37 = lc->na.VAR_37;",
"const int VAR_38 = lc->na.VAR_38;",
"const int VAR_39 = lc->na.cand_up_right_sap;",
"VAR_31 = VAR_10;",
"VAR_32 = VAR_8->VAR_32[VAR_10];",
"VAR_33 = VAR_10;",
"VAR_34 = !VAR_10;",
"VAR_16 = VAR_1 - 1;",
"VAR_17 = VAR_2 + VAR_4;",
"VAR_18 = AVAILABLE(VAR_35, A0) &&\nVAR_17 < VAR_0->sps->height &&\nPRED_BLOCK_AVAILABLE(A0);",
"VAR_19 = VAR_1 - 1;",
"VAR_20 = VAR_2 + VAR_4 - 1;",
"VAR_21 = AVAILABLE(VAR_36, A1);",
"if (VAR_18 || VAR_21)\nVAR_11 = 1;",
"if (VAR_18) {",
"if (MP_MX(A0, VAR_33, mxA)) {",
"goto b_candidates;",
"}",
"if (MP_MX(A0, VAR_34, mxA)) {",
"goto b_candidates;",
"}",
"}",
"if (VAR_21) {",
"if (MP_MX(A1, VAR_33, mxA)) {",
"goto b_candidates;",
"}",
"if (MP_MX(A1, VAR_34, mxA)) {",
"goto b_candidates;",
"}",
"}",
"if (VAR_18) {",
"if (MP_MX_LT(A0, VAR_33, mxA)) {",
"goto b_candidates;",
"}",
"if (MP_MX_LT(A0, VAR_34, mxA)) {",
"goto b_candidates;",
"}",
"}",
"if (VAR_21) {",
"if (MP_MX_LT(A1, VAR_33, mxA)) {",
"goto b_candidates;",
"}",
"if (MP_MX_LT(A1, VAR_34, mxA)) {",
"goto b_candidates;",
"}",
"}",
"VAR_12 = 0;",
"b_candidates:\nVAR_22 = VAR_1 + VAR_3;",
"VAR_23 = VAR_2 - 1;",
"VAR_24 = AVAILABLE(VAR_39, B0) &&\nVAR_22 < VAR_0->sps->width &&\nPRED_BLOCK_AVAILABLE(B0);",
"VAR_25 = VAR_1 + VAR_3 - 1;",
"VAR_26 = VAR_2 - 1;",
"VAR_27 = AVAILABLE(VAR_38, B1);",
"VAR_28 = VAR_1 - 1;",
"VAR_29 = VAR_2 - 1;",
"VAR_30 = AVAILABLE(VAR_37, B2);",
"if (VAR_24) {",
"if (MP_MX(B0, VAR_33, mxB)) {",
"goto scalef;",
"}",
"if (MP_MX(B0, VAR_34, mxB)) {",
"goto scalef;",
"}",
"}",
"if (VAR_27) {",
"if (MP_MX(B1, VAR_33, mxB)) {",
"goto scalef;",
"}",
"if (MP_MX(B1, VAR_34, mxB)) {",
"goto scalef;",
"}",
"}",
"if (VAR_30) {",
"if (MP_MX(B2, VAR_33, mxB)) {",
"goto scalef;",
"}",
"if (MP_MX(B2, VAR_34, mxB)) {",
"goto scalef;",
"}",
"}",
"VAR_13 = 0;",
"scalef:\nif (!VAR_11) {",
"if (VAR_13) {",
"VAR_12 = 1;",
"mxA = mxB;",
"}",
"VAR_13 = 0;",
"if (VAR_24) {",
"VAR_13 = MP_MX_LT(B0, VAR_33, mxB);",
"if (!VAR_13)\nVAR_13 = MP_MX_LT(B0, VAR_34, mxB);",
"}",
"if (VAR_27 && !VAR_13) {",
"VAR_13 = MP_MX_LT(B1, VAR_33, mxB);",
"if (!VAR_13)\nVAR_13 = MP_MX_LT(B1, VAR_34, mxB);",
"}",
"if (VAR_30 && !VAR_13) {",
"VAR_13 = MP_MX_LT(B2, VAR_33, mxB);",
"if (!VAR_13)\nVAR_13 = MP_MX_LT(B2, VAR_34, mxB);",
"}",
"}",
"if (VAR_12)\nmvpcand_list[VAR_14++] = mxA;",
"if (VAR_13 && (!VAR_12 || mxA.x != mxB.x || mxA.y != mxB.y))\nmvpcand_list[VAR_14++] = mxB;",
"if (VAR_14 < 2 && VAR_0->sh.slice_temporal_mvp_enabled_flag &&\nVAR_9 == VAR_14) {",
"Mv mv_col;",
"int VAR_40 = temporal_luma_motion_vector(VAR_0, VAR_1, VAR_2, VAR_3,\nVAR_4, VAR_32,\n&mv_col, VAR_10);",
"if (VAR_40)\nmvpcand_list[VAR_14++] = mv_col;",
"}",
"VAR_8->VAR_8[VAR_10] = mvpcand_list[VAR_9];",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
87
],
[
89
],
[
93,
95,
97
],
[
103
],
[
105
],
[
109
],
[
111,
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191,
197
],
[
199
],
[
203,
205,
207
],
[
213
],
[
215
],
[
217
],
[
223
],
[
225
],
[
227
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
293,
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
311
],
[
313
],
[
315,
317
],
[
319
],
[
323
],
[
325
],
[
327,
329
],
[
331
],
[
335
],
[
337
],
[
339,
341
],
[
343
],
[
345
],
[
349,
351
],
[
355,
357
],
[
363,
365
],
[
367
],
[
369,
371,
373
],
[
375,
377
],
[
379
],
[
383
],
[
385
]
] |
26,050 | static void pc_compat_2_0(MachineState *machine)
{
smbios_legacy_mode = true;
has_reserved_memory = false;
} | true | qemu | 07fb61760cdea7c3f1b9c897513986945bca8e89 | static void pc_compat_2_0(MachineState *machine)
{
smbios_legacy_mode = true;
has_reserved_memory = false;
} | {
"code": [],
"line_no": []
} | static void FUNC_0(MachineState *VAR_0)
{
smbios_legacy_mode = true;
has_reserved_memory = false;
} | [
"static void FUNC_0(MachineState *VAR_0)\n{",
"smbios_legacy_mode = true;",
"has_reserved_memory = false;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
22
],
[
24
],
[
26
]
] |
26,051 | static CharDriverState *qemu_chr_open_msmouse(const char *id,
ChardevBackend *backend,
ChardevReturn *ret,
Error **errp)
{
ChardevCommon *common = backend->u.msmouse.data;
MouseState *mouse;
CharDriverState *chr;
chr = qemu_chr_alloc(common, errp);
chr->chr_write = msmouse_chr_write;
chr->chr_close = msmouse_chr_close;
chr->chr_accept_input = msmouse_chr_accept_input;
chr->explicit_be_open = true;
mouse = g_new0(MouseState, 1);
mouse->hs = qemu_input_handler_register((DeviceState *)mouse,
&msmouse_handler);
mouse->chr = chr;
chr->opaque = mouse;
return chr;
| true | qemu | 71200fb9664c2967a1cdd22b68b0da3a8b2b3eb7 | static CharDriverState *qemu_chr_open_msmouse(const char *id,
ChardevBackend *backend,
ChardevReturn *ret,
Error **errp)
{
ChardevCommon *common = backend->u.msmouse.data;
MouseState *mouse;
CharDriverState *chr;
chr = qemu_chr_alloc(common, errp);
chr->chr_write = msmouse_chr_write;
chr->chr_close = msmouse_chr_close;
chr->chr_accept_input = msmouse_chr_accept_input;
chr->explicit_be_open = true;
mouse = g_new0(MouseState, 1);
mouse->hs = qemu_input_handler_register((DeviceState *)mouse,
&msmouse_handler);
mouse->chr = chr;
chr->opaque = mouse;
return chr;
| {
"code": [],
"line_no": []
} | static CharDriverState *FUNC_0(const char *id,
ChardevBackend *backend,
ChardevReturn *ret,
Error **errp)
{
ChardevCommon *common = backend->u.msmouse.data;
MouseState *mouse;
CharDriverState *chr;
chr = qemu_chr_alloc(common, errp);
chr->chr_write = msmouse_chr_write;
chr->chr_close = msmouse_chr_close;
chr->chr_accept_input = msmouse_chr_accept_input;
chr->explicit_be_open = true;
mouse = g_new0(MouseState, 1);
mouse->hs = qemu_input_handler_register((DeviceState *)mouse,
&msmouse_handler);
mouse->chr = chr;
chr->opaque = mouse;
return chr;
| [
"static CharDriverState *FUNC_0(const char *id,\nChardevBackend *backend,\nChardevReturn *ret,\nError **errp)\n{",
"ChardevCommon *common = backend->u.msmouse.data;",
"MouseState *mouse;",
"CharDriverState *chr;",
"chr = qemu_chr_alloc(common, errp);",
"chr->chr_write = msmouse_chr_write;",
"chr->chr_close = msmouse_chr_close;",
"chr->chr_accept_input = msmouse_chr_accept_input;",
"chr->explicit_be_open = true;",
"mouse = g_new0(MouseState, 1);",
"mouse->hs = qemu_input_handler_register((DeviceState *)mouse,\n&msmouse_handler);",
"mouse->chr = chr;",
"chr->opaque = mouse;",
"return chr;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
24
],
[
26
],
[
28
],
[
30
],
[
34
],
[
36,
38
],
[
42
],
[
44
],
[
48
]
] |
26,052 | int kvm_arch_on_sigbus_vcpu(CPUState *env, int code, void *addr)
{
#ifdef KVM_CAP_MCE
ram_addr_t ram_addr;
target_phys_addr_t paddr;
if ((env->mcg_cap & MCG_SER_P) && addr
&& (code == BUS_MCEERR_AR || code == BUS_MCEERR_AO)) {
if (qemu_ram_addr_from_host(addr, &ram_addr) ||
!kvm_physical_memory_addr_from_ram(env->kvm_state, ram_addr,
&paddr)) {
fprintf(stderr, "Hardware memory error for memory used by "
"QEMU itself instead of guest system!\n");
/* Hope we are lucky for AO MCE */
if (code == BUS_MCEERR_AO) {
return 0;
} else {
hardware_memory_error();
}
}
kvm_mce_inject(env, paddr, code);
} else
#endif /* KVM_CAP_MCE */
{
if (code == BUS_MCEERR_AO) {
return 0;
} else if (code == BUS_MCEERR_AR) {
hardware_memory_error();
} else {
return 1;
}
}
return 0;
} | true | qemu | 3c85e74fbf9e5a39d8d13ef91a5f3dd91f0bc8a8 | int kvm_arch_on_sigbus_vcpu(CPUState *env, int code, void *addr)
{
#ifdef KVM_CAP_MCE
ram_addr_t ram_addr;
target_phys_addr_t paddr;
if ((env->mcg_cap & MCG_SER_P) && addr
&& (code == BUS_MCEERR_AR || code == BUS_MCEERR_AO)) {
if (qemu_ram_addr_from_host(addr, &ram_addr) ||
!kvm_physical_memory_addr_from_ram(env->kvm_state, ram_addr,
&paddr)) {
fprintf(stderr, "Hardware memory error for memory used by "
"QEMU itself instead of guest system!\n");
if (code == BUS_MCEERR_AO) {
return 0;
} else {
hardware_memory_error();
}
}
kvm_mce_inject(env, paddr, code);
} else
#endif
{
if (code == BUS_MCEERR_AO) {
return 0;
} else if (code == BUS_MCEERR_AR) {
hardware_memory_error();
} else {
return 1;
}
}
return 0;
} | {
"code": [],
"line_no": []
} | int FUNC_0(CPUState *VAR_0, int VAR_1, void *VAR_2)
{
#ifdef KVM_CAP_MCE
ram_addr_t ram_addr;
target_phys_addr_t paddr;
if ((VAR_0->mcg_cap & MCG_SER_P) && VAR_2
&& (VAR_1 == BUS_MCEERR_AR || VAR_1 == BUS_MCEERR_AO)) {
if (qemu_ram_addr_from_host(VAR_2, &ram_addr) ||
!kvm_physical_memory_addr_from_ram(VAR_0->kvm_state, ram_addr,
&paddr)) {
fprintf(stderr, "Hardware memory error for memory used by "
"QEMU itself instead of guest system!\n");
if (VAR_1 == BUS_MCEERR_AO) {
return 0;
} else {
hardware_memory_error();
}
}
kvm_mce_inject(VAR_0, paddr, VAR_1);
} else
#endif
{
if (VAR_1 == BUS_MCEERR_AO) {
return 0;
} else if (VAR_1 == BUS_MCEERR_AR) {
hardware_memory_error();
} else {
return 1;
}
}
return 0;
} | [
"int FUNC_0(CPUState *VAR_0, int VAR_1, void *VAR_2)\n{",
"#ifdef KVM_CAP_MCE\nram_addr_t ram_addr;",
"target_phys_addr_t paddr;",
"if ((VAR_0->mcg_cap & MCG_SER_P) && VAR_2\n&& (VAR_1 == BUS_MCEERR_AR || VAR_1 == BUS_MCEERR_AO)) {",
"if (qemu_ram_addr_from_host(VAR_2, &ram_addr) ||\n!kvm_physical_memory_addr_from_ram(VAR_0->kvm_state, ram_addr,\n&paddr)) {",
"fprintf(stderr, \"Hardware memory error for memory used by \"\n\"QEMU itself instead of guest system!\\n\");",
"if (VAR_1 == BUS_MCEERR_AO) {",
"return 0;",
"} else {",
"hardware_memory_error();",
"}",
"}",
"kvm_mce_inject(VAR_0, paddr, VAR_1);",
"} else",
"#endif\n{",
"if (VAR_1 == BUS_MCEERR_AO) {",
"return 0;",
"} else if (VAR_1 == BUS_MCEERR_AR) {",
"hardware_memory_error();",
"} else {",
"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
] | [
[
1,
3
],
[
5,
7
],
[
9
],
[
13,
15
],
[
17,
19,
21
],
[
23,
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
42
],
[
44
],
[
46,
48
],
[
50
],
[
52
],
[
54
],
[
56
],
[
58
],
[
60
],
[
62
],
[
64
],
[
66
],
[
68
]
] |
26,053 | static int vc1_decode_intra_block(VC1Context *v, DCTELEM block[64], int n, int coded, int mquant, int codingset)
{
GetBitContext *gb = &v->s.gb;
MpegEncContext *s = &v->s;
int dc_pred_dir = 0; /* Direction of the DC prediction used */
int run_diff, i;
int16_t *dc_val;
int16_t *ac_val, *ac_val2;
int dcdiff;
int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
int a_avail = v->a_avail, c_avail = v->c_avail;
int use_pred = s->ac_pred;
int scale;
int q1, q2 = 0;
/* XXX: Guard against dumb values of mquant */
mquant = (mquant < 1) ? 0 : ( (mquant>31) ? 31 : mquant );
/* Set DC scale - y and c use the same */
s->y_dc_scale = s->y_dc_scale_table[mquant];
s->c_dc_scale = s->c_dc_scale_table[mquant];
/* Get DC differential */
if (n < 4) {
dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
} else {
dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
}
if (dcdiff < 0){
av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n");
return -1;
}
if (dcdiff)
{
if (dcdiff == 119 /* ESC index value */)
{
/* TODO: Optimize */
if (mquant == 1) dcdiff = get_bits(gb, 10);
else if (mquant == 2) dcdiff = get_bits(gb, 9);
else dcdiff = get_bits(gb, 8);
}
else
{
if (mquant == 1)
dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3;
else if (mquant == 2)
dcdiff = (dcdiff<<1) + get_bits(gb, 1) - 1;
}
if (get_bits(gb, 1))
dcdiff = -dcdiff;
}
/* Prediction */
dcdiff += vc1_pred_dc(&v->s, v->overlap, mquant, n, a_avail, c_avail, &dc_val, &dc_pred_dir);
*dc_val = dcdiff;
/* Store the quantized DC coeff, used for prediction */
if (n < 4) {
block[0] = dcdiff * s->y_dc_scale;
} else {
block[0] = dcdiff * s->c_dc_scale;
}
/* Skip ? */
run_diff = 0;
i = 0;
//AC Decoding
i = 1;
/* check if AC is needed at all and adjust direction if needed */
if(!a_avail) dc_pred_dir = 1;
if(!c_avail) dc_pred_dir = 0;
if(!a_avail && !c_avail) use_pred = 0;
ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
ac_val2 = ac_val;
scale = mquant * 2 + v->halfpq;
if(dc_pred_dir) //left
ac_val -= 16;
else //top
ac_val -= 16 * s->block_wrap[n];
q1 = s->current_picture.qscale_table[mb_pos];
if(dc_pred_dir && c_avail) q2 = s->current_picture.qscale_table[mb_pos - 1];
if(!dc_pred_dir && a_avail) q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride];
if(n && n<4) q2 = q1;
if(coded) {
int last = 0, skip, value;
const int8_t *zz_table;
int k;
zz_table = vc1_simple_progressive_8x8_zz;
while (!last) {
vc1_decode_ac_coeff(v, &last, &skip, &value, codingset);
i += skip;
if(i > 63)
break;
block[zz_table[i++]] = value;
}
/* apply AC prediction if needed */
if(use_pred) {
/* scale predictors if needed*/
if(q2 && q1!=q2) {
q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
if(dc_pred_dir) { //left
for(k = 1; k < 8; k++)
block[k << 3] += (ac_val[k] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18;
} else { //top
for(k = 1; k < 8; k++)
block[k] += (ac_val[k + 8] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
} else {
if(dc_pred_dir) { //left
for(k = 1; k < 8; k++)
block[k << 3] += ac_val[k];
} else { //top
for(k = 1; k < 8; k++)
block[k] += ac_val[k + 8];
}
}
}
/* save AC coeffs for further prediction */
for(k = 1; k < 8; k++) {
ac_val2[k] = block[k << 3];
ac_val2[k + 8] = block[k];
}
/* scale AC coeffs */
for(k = 1; k < 64; k++)
if(block[k]) {
block[k] *= scale;
if(!v->pquantizer)
block[k] += (block[k] < 0) ? -mquant : mquant;
}
if(use_pred) i = 63;
} else { // no AC coeffs
int k;
memset(ac_val2, 0, 16 * 2);
if(dc_pred_dir) {//left
if(use_pred) {
memcpy(ac_val2, ac_val, 8 * 2);
if(q2 && q1!=q2) {
q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
for(k = 1; k < 8; k++)
ac_val2[k] = (ac_val2[k] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
}
} else {//top
if(use_pred) {
memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
if(q2 && q1!=q2) {
q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
for(k = 1; k < 8; k++)
ac_val2[k + 8] = (ac_val2[k + 8] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
}
}
/* apply AC prediction if needed */
if(use_pred) {
if(dc_pred_dir) { //left
for(k = 1; k < 8; k++) {
block[k << 3] = ac_val2[k] * scale;
if(!v->pquantizer && block[k << 3])
block[k << 3] += (block[k << 3] < 0) ? -mquant : mquant;
}
} else { //top
for(k = 1; k < 8; k++) {
block[k] = ac_val2[k + 8] * scale;
if(!v->pquantizer && block[k])
block[k] += (block[k] < 0) ? -mquant : mquant;
}
}
i = 63;
}
}
s->block_last_index[n] = i;
return 0;
}
| true | FFmpeg | 6f3e4e1712260ef8c5b4754d781ccd80bcfa1d0c | static int vc1_decode_intra_block(VC1Context *v, DCTELEM block[64], int n, int coded, int mquant, int codingset)
{
GetBitContext *gb = &v->s.gb;
MpegEncContext *s = &v->s;
int dc_pred_dir = 0;
int run_diff, i;
int16_t *dc_val;
int16_t *ac_val, *ac_val2;
int dcdiff;
int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
int a_avail = v->a_avail, c_avail = v->c_avail;
int use_pred = s->ac_pred;
int scale;
int q1, q2 = 0;
mquant = (mquant < 1) ? 0 : ( (mquant>31) ? 31 : mquant );
s->y_dc_scale = s->y_dc_scale_table[mquant];
s->c_dc_scale = s->c_dc_scale_table[mquant];
if (n < 4) {
dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
} else {
dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
}
if (dcdiff < 0){
av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n");
return -1;
}
if (dcdiff)
{
if (dcdiff == 119 )
{
if (mquant == 1) dcdiff = get_bits(gb, 10);
else if (mquant == 2) dcdiff = get_bits(gb, 9);
else dcdiff = get_bits(gb, 8);
}
else
{
if (mquant == 1)
dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3;
else if (mquant == 2)
dcdiff = (dcdiff<<1) + get_bits(gb, 1) - 1;
}
if (get_bits(gb, 1))
dcdiff = -dcdiff;
}
dcdiff += vc1_pred_dc(&v->s, v->overlap, mquant, n, a_avail, c_avail, &dc_val, &dc_pred_dir);
*dc_val = dcdiff;
if (n < 4) {
block[0] = dcdiff * s->y_dc_scale;
} else {
block[0] = dcdiff * s->c_dc_scale;
}
run_diff = 0;
i = 0;
i = 1;
if(!a_avail) dc_pred_dir = 1;
if(!c_avail) dc_pred_dir = 0;
if(!a_avail && !c_avail) use_pred = 0;
ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
ac_val2 = ac_val;
scale = mquant * 2 + v->halfpq;
if(dc_pred_dir)
ac_val -= 16;
else
ac_val -= 16 * s->block_wrap[n];
q1 = s->current_picture.qscale_table[mb_pos];
if(dc_pred_dir && c_avail) q2 = s->current_picture.qscale_table[mb_pos - 1];
if(!dc_pred_dir && a_avail) q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride];
if(n && n<4) q2 = q1;
if(coded) {
int last = 0, skip, value;
const int8_t *zz_table;
int k;
zz_table = vc1_simple_progressive_8x8_zz;
while (!last) {
vc1_decode_ac_coeff(v, &last, &skip, &value, codingset);
i += skip;
if(i > 63)
break;
block[zz_table[i++]] = value;
}
if(use_pred) {
if(q2 && q1!=q2) {
q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
if(dc_pred_dir) {
for(k = 1; k < 8; k++)
block[k << 3] += (ac_val[k] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18;
} else {
for(k = 1; k < 8; k++)
block[k] += (ac_val[k + 8] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
} else {
if(dc_pred_dir) {
for(k = 1; k < 8; k++)
block[k << 3] += ac_val[k];
} else {
for(k = 1; k < 8; k++)
block[k] += ac_val[k + 8];
}
}
}
for(k = 1; k < 8; k++) {
ac_val2[k] = block[k << 3];
ac_val2[k + 8] = block[k];
}
for(k = 1; k < 64; k++)
if(block[k]) {
block[k] *= scale;
if(!v->pquantizer)
block[k] += (block[k] < 0) ? -mquant : mquant;
}
if(use_pred) i = 63;
} else {
int k;
memset(ac_val2, 0, 16 * 2);
if(dc_pred_dir) {
if(use_pred) {
memcpy(ac_val2, ac_val, 8 * 2);
if(q2 && q1!=q2) {
q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
for(k = 1; k < 8; k++)
ac_val2[k] = (ac_val2[k] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
}
} else {
if(use_pred) {
memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
if(q2 && q1!=q2) {
q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
for(k = 1; k < 8; k++)
ac_val2[k + 8] = (ac_val2[k + 8] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
}
}
if(use_pred) {
if(dc_pred_dir) {
for(k = 1; k < 8; k++) {
block[k << 3] = ac_val2[k] * scale;
if(!v->pquantizer && block[k << 3])
block[k << 3] += (block[k << 3] < 0) ? -mquant : mquant;
}
} else {
for(k = 1; k < 8; k++) {
block[k] = ac_val2[k + 8] * scale;
if(!v->pquantizer && block[k])
block[k] += (block[k] < 0) ? -mquant : mquant;
}
}
i = 63;
}
}
s->block_last_index[n] = i;
return 0;
}
| {
"code": [
" if(dc_pred_dir && c_avail) q2 = s->current_picture.qscale_table[mb_pos - 1];",
" if(!dc_pred_dir && a_avail) q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride];"
],
"line_no": [
171,
173
]
} | static int FUNC_0(VC1Context *VAR_0, DCTELEM VAR_1[64], int VAR_2, int VAR_3, int VAR_4, int VAR_5)
{
GetBitContext *gb = &VAR_0->s.gb;
MpegEncContext *s = &VAR_0->s;
int VAR_6 = 0;
int VAR_7, VAR_8;
int16_t *dc_val;
int16_t *ac_val, *ac_val2;
int VAR_9;
int VAR_10 = s->mb_x + s->mb_y * s->mb_stride;
int VAR_11 = VAR_0->VAR_11, VAR_12 = VAR_0->VAR_12;
int VAR_13 = s->ac_pred;
int VAR_14;
int VAR_15, VAR_16 = 0;
VAR_4 = (VAR_4 < 1) ? 0 : ( (VAR_4>31) ? 31 : VAR_4 );
s->y_dc_scale = s->y_dc_scale_table[VAR_4];
s->c_dc_scale = s->c_dc_scale_table[VAR_4];
if (VAR_2 < 4) {
VAR_9 = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
} else {
VAR_9 = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
}
if (VAR_9 < 0){
av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\VAR_2");
return -1;
}
if (VAR_9)
{
if (VAR_9 == 119 )
{
if (VAR_4 == 1) VAR_9 = get_bits(gb, 10);
else if (VAR_4 == 2) VAR_9 = get_bits(gb, 9);
else VAR_9 = get_bits(gb, 8);
}
else
{
if (VAR_4 == 1)
VAR_9 = (VAR_9<<2) + get_bits(gb, 2) - 3;
else if (VAR_4 == 2)
VAR_9 = (VAR_9<<1) + get_bits(gb, 1) - 1;
}
if (get_bits(gb, 1))
VAR_9 = -VAR_9;
}
VAR_9 += vc1_pred_dc(&VAR_0->s, VAR_0->overlap, VAR_4, VAR_2, VAR_11, VAR_12, &dc_val, &VAR_6);
*dc_val = VAR_9;
if (VAR_2 < 4) {
VAR_1[0] = VAR_9 * s->y_dc_scale;
} else {
VAR_1[0] = VAR_9 * s->c_dc_scale;
}
VAR_7 = 0;
VAR_8 = 0;
VAR_8 = 1;
if(!VAR_11) VAR_6 = 1;
if(!VAR_12) VAR_6 = 0;
if(!VAR_11 && !VAR_12) VAR_13 = 0;
ac_val = s->ac_val[0][0] + s->block_index[VAR_2] * 16;
ac_val2 = ac_val;
VAR_14 = VAR_4 * 2 + VAR_0->halfpq;
if(VAR_6)
ac_val -= 16;
else
ac_val -= 16 * s->block_wrap[VAR_2];
VAR_15 = s->current_picture.qscale_table[VAR_10];
if(VAR_6 && VAR_12) VAR_16 = s->current_picture.qscale_table[VAR_10 - 1];
if(!VAR_6 && VAR_11) VAR_16 = s->current_picture.qscale_table[VAR_10 - s->mb_stride];
if(VAR_2 && VAR_2<4) VAR_16 = VAR_15;
if(VAR_3) {
int VAR_17 = 0, VAR_18, VAR_19;
const int8_t *VAR_20;
int VAR_22;
VAR_20 = vc1_simple_progressive_8x8_zz;
while (!VAR_17) {
vc1_decode_ac_coeff(VAR_0, &VAR_17, &VAR_18, &VAR_19, VAR_5);
VAR_8 += VAR_18;
if(VAR_8 > 63)
break;
VAR_1[VAR_20[VAR_8++]] = VAR_19;
}
if(VAR_13) {
if(VAR_16 && VAR_15!=VAR_16) {
VAR_15 = VAR_15 * 2 + ((VAR_15 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;
VAR_16 = VAR_16 * 2 + ((VAR_16 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;
if(VAR_6) {
for(VAR_22 = 1; VAR_22 < 8; VAR_22++)
VAR_1[VAR_22 << 3] += (ac_val[VAR_22] * VAR_16 * vc1_dqscale[VAR_15 - 1] + 0x20000) >> 18;
} else {
for(VAR_22 = 1; VAR_22 < 8; VAR_22++)
VAR_1[VAR_22] += (ac_val[VAR_22 + 8] * VAR_16 * vc1_dqscale[VAR_15 - 1] + 0x20000) >> 18;
}
} else {
if(VAR_6) {
for(VAR_22 = 1; VAR_22 < 8; VAR_22++)
VAR_1[VAR_22 << 3] += ac_val[VAR_22];
} else {
for(VAR_22 = 1; VAR_22 < 8; VAR_22++)
VAR_1[VAR_22] += ac_val[VAR_22 + 8];
}
}
}
for(VAR_22 = 1; VAR_22 < 8; VAR_22++) {
ac_val2[VAR_22] = VAR_1[VAR_22 << 3];
ac_val2[VAR_22 + 8] = VAR_1[VAR_22];
}
for(VAR_22 = 1; VAR_22 < 64; VAR_22++)
if(VAR_1[VAR_22]) {
VAR_1[VAR_22] *= VAR_14;
if(!VAR_0->pquantizer)
VAR_1[VAR_22] += (VAR_1[VAR_22] < 0) ? -VAR_4 : VAR_4;
}
if(VAR_13) VAR_8 = 63;
} else {
int VAR_22;
memset(ac_val2, 0, 16 * 2);
if(VAR_6) {
if(VAR_13) {
memcpy(ac_val2, ac_val, 8 * 2);
if(VAR_16 && VAR_15!=VAR_16) {
VAR_15 = VAR_15 * 2 + ((VAR_15 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;
VAR_16 = VAR_16 * 2 + ((VAR_16 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;
for(VAR_22 = 1; VAR_22 < 8; VAR_22++)
ac_val2[VAR_22] = (ac_val2[VAR_22] * VAR_16 * vc1_dqscale[VAR_15 - 1] + 0x20000) >> 18;
}
}
} else {
if(VAR_13) {
memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
if(VAR_16 && VAR_15!=VAR_16) {
VAR_15 = VAR_15 * 2 + ((VAR_15 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;
VAR_16 = VAR_16 * 2 + ((VAR_16 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;
for(VAR_22 = 1; VAR_22 < 8; VAR_22++)
ac_val2[VAR_22 + 8] = (ac_val2[VAR_22 + 8] * VAR_16 * vc1_dqscale[VAR_15 - 1] + 0x20000) >> 18;
}
}
}
if(VAR_13) {
if(VAR_6) {
for(VAR_22 = 1; VAR_22 < 8; VAR_22++) {
VAR_1[VAR_22 << 3] = ac_val2[VAR_22] * VAR_14;
if(!VAR_0->pquantizer && VAR_1[VAR_22 << 3])
VAR_1[VAR_22 << 3] += (VAR_1[VAR_22 << 3] < 0) ? -VAR_4 : VAR_4;
}
} else {
for(VAR_22 = 1; VAR_22 < 8; VAR_22++) {
VAR_1[VAR_22] = ac_val2[VAR_22 + 8] * VAR_14;
if(!VAR_0->pquantizer && VAR_1[VAR_22])
VAR_1[VAR_22] += (VAR_1[VAR_22] < 0) ? -VAR_4 : VAR_4;
}
}
VAR_8 = 63;
}
}
s->block_last_index[VAR_2] = VAR_8;
return 0;
}
| [
"static int FUNC_0(VC1Context *VAR_0, DCTELEM VAR_1[64], int VAR_2, int VAR_3, int VAR_4, int VAR_5)\n{",
"GetBitContext *gb = &VAR_0->s.gb;",
"MpegEncContext *s = &VAR_0->s;",
"int VAR_6 = 0;",
"int VAR_7, VAR_8;",
"int16_t *dc_val;",
"int16_t *ac_val, *ac_val2;",
"int VAR_9;",
"int VAR_10 = s->mb_x + s->mb_y * s->mb_stride;",
"int VAR_11 = VAR_0->VAR_11, VAR_12 = VAR_0->VAR_12;",
"int VAR_13 = s->ac_pred;",
"int VAR_14;",
"int VAR_15, VAR_16 = 0;",
"VAR_4 = (VAR_4 < 1) ? 0 : ( (VAR_4>31) ? 31 : VAR_4 );",
"s->y_dc_scale = s->y_dc_scale_table[VAR_4];",
"s->c_dc_scale = s->c_dc_scale_table[VAR_4];",
"if (VAR_2 < 4) {",
"VAR_9 = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);",
"} else {",
"VAR_9 = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);",
"}",
"if (VAR_9 < 0){",
"av_log(s->avctx, AV_LOG_ERROR, \"Illegal DC VLC\\VAR_2\");",
"return -1;",
"}",
"if (VAR_9)\n{",
"if (VAR_9 == 119 )\n{",
"if (VAR_4 == 1) VAR_9 = get_bits(gb, 10);",
"else if (VAR_4 == 2) VAR_9 = get_bits(gb, 9);",
"else VAR_9 = get_bits(gb, 8);",
"}",
"else\n{",
"if (VAR_4 == 1)\nVAR_9 = (VAR_9<<2) + get_bits(gb, 2) - 3;",
"else if (VAR_4 == 2)\nVAR_9 = (VAR_9<<1) + get_bits(gb, 1) - 1;",
"}",
"if (get_bits(gb, 1))\nVAR_9 = -VAR_9;",
"}",
"VAR_9 += vc1_pred_dc(&VAR_0->s, VAR_0->overlap, VAR_4, VAR_2, VAR_11, VAR_12, &dc_val, &VAR_6);",
"*dc_val = VAR_9;",
"if (VAR_2 < 4) {",
"VAR_1[0] = VAR_9 * s->y_dc_scale;",
"} else {",
"VAR_1[0] = VAR_9 * s->c_dc_scale;",
"}",
"VAR_7 = 0;",
"VAR_8 = 0;",
"VAR_8 = 1;",
"if(!VAR_11) VAR_6 = 1;",
"if(!VAR_12) VAR_6 = 0;",
"if(!VAR_11 && !VAR_12) VAR_13 = 0;",
"ac_val = s->ac_val[0][0] + s->block_index[VAR_2] * 16;",
"ac_val2 = ac_val;",
"VAR_14 = VAR_4 * 2 + VAR_0->halfpq;",
"if(VAR_6)\nac_val -= 16;",
"else\nac_val -= 16 * s->block_wrap[VAR_2];",
"VAR_15 = s->current_picture.qscale_table[VAR_10];",
"if(VAR_6 && VAR_12) VAR_16 = s->current_picture.qscale_table[VAR_10 - 1];",
"if(!VAR_6 && VAR_11) VAR_16 = s->current_picture.qscale_table[VAR_10 - s->mb_stride];",
"if(VAR_2 && VAR_2<4) VAR_16 = VAR_15;",
"if(VAR_3) {",
"int VAR_17 = 0, VAR_18, VAR_19;",
"const int8_t *VAR_20;",
"int VAR_22;",
"VAR_20 = vc1_simple_progressive_8x8_zz;",
"while (!VAR_17) {",
"vc1_decode_ac_coeff(VAR_0, &VAR_17, &VAR_18, &VAR_19, VAR_5);",
"VAR_8 += VAR_18;",
"if(VAR_8 > 63)\nbreak;",
"VAR_1[VAR_20[VAR_8++]] = VAR_19;",
"}",
"if(VAR_13) {",
"if(VAR_16 && VAR_15!=VAR_16) {",
"VAR_15 = VAR_15 * 2 + ((VAR_15 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;",
"VAR_16 = VAR_16 * 2 + ((VAR_16 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;",
"if(VAR_6) {",
"for(VAR_22 = 1; VAR_22 < 8; VAR_22++)",
"VAR_1[VAR_22 << 3] += (ac_val[VAR_22] * VAR_16 * vc1_dqscale[VAR_15 - 1] + 0x20000) >> 18;",
"} else {",
"for(VAR_22 = 1; VAR_22 < 8; VAR_22++)",
"VAR_1[VAR_22] += (ac_val[VAR_22 + 8] * VAR_16 * vc1_dqscale[VAR_15 - 1] + 0x20000) >> 18;",
"}",
"} else {",
"if(VAR_6) {",
"for(VAR_22 = 1; VAR_22 < 8; VAR_22++)",
"VAR_1[VAR_22 << 3] += ac_val[VAR_22];",
"} else {",
"for(VAR_22 = 1; VAR_22 < 8; VAR_22++)",
"VAR_1[VAR_22] += ac_val[VAR_22 + 8];",
"}",
"}",
"}",
"for(VAR_22 = 1; VAR_22 < 8; VAR_22++) {",
"ac_val2[VAR_22] = VAR_1[VAR_22 << 3];",
"ac_val2[VAR_22 + 8] = VAR_1[VAR_22];",
"}",
"for(VAR_22 = 1; VAR_22 < 64; VAR_22++)",
"if(VAR_1[VAR_22]) {",
"VAR_1[VAR_22] *= VAR_14;",
"if(!VAR_0->pquantizer)\nVAR_1[VAR_22] += (VAR_1[VAR_22] < 0) ? -VAR_4 : VAR_4;",
"}",
"if(VAR_13) VAR_8 = 63;",
"} else {",
"int VAR_22;",
"memset(ac_val2, 0, 16 * 2);",
"if(VAR_6) {",
"if(VAR_13) {",
"memcpy(ac_val2, ac_val, 8 * 2);",
"if(VAR_16 && VAR_15!=VAR_16) {",
"VAR_15 = VAR_15 * 2 + ((VAR_15 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;",
"VAR_16 = VAR_16 * 2 + ((VAR_16 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;",
"for(VAR_22 = 1; VAR_22 < 8; VAR_22++)",
"ac_val2[VAR_22] = (ac_val2[VAR_22] * VAR_16 * vc1_dqscale[VAR_15 - 1] + 0x20000) >> 18;",
"}",
"}",
"} else {",
"if(VAR_13) {",
"memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);",
"if(VAR_16 && VAR_15!=VAR_16) {",
"VAR_15 = VAR_15 * 2 + ((VAR_15 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;",
"VAR_16 = VAR_16 * 2 + ((VAR_16 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;",
"for(VAR_22 = 1; VAR_22 < 8; VAR_22++)",
"ac_val2[VAR_22 + 8] = (ac_val2[VAR_22 + 8] * VAR_16 * vc1_dqscale[VAR_15 - 1] + 0x20000) >> 18;",
"}",
"}",
"}",
"if(VAR_13) {",
"if(VAR_6) {",
"for(VAR_22 = 1; VAR_22 < 8; VAR_22++) {",
"VAR_1[VAR_22 << 3] = ac_val2[VAR_22] * VAR_14;",
"if(!VAR_0->pquantizer && VAR_1[VAR_22 << 3])\nVAR_1[VAR_22 << 3] += (VAR_1[VAR_22 << 3] < 0) ? -VAR_4 : VAR_4;",
"}",
"} else {",
"for(VAR_22 = 1; VAR_22 < 8; VAR_22++) {",
"VAR_1[VAR_22] = ac_val2[VAR_22 + 8] * VAR_14;",
"if(!VAR_0->pquantizer && VAR_1[VAR_22])\nVAR_1[VAR_22] += (VAR_1[VAR_22] < 0) ? -VAR_4 : VAR_4;",
"}",
"}",
"VAR_8 = 63;",
"}",
"}",
"s->block_last_index[VAR_2] = VAR_8;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
33
],
[
39
],
[
41
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69,
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83,
85
],
[
87,
89
],
[
91,
93
],
[
95
],
[
97,
99
],
[
101
],
[
107
],
[
109
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
137
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
159,
161
],
[
163,
165
],
[
169
],
[
171
],
[
173
],
[
175
],
[
179
],
[
181
],
[
183
],
[
185
],
[
189
],
[
193
],
[
195
],
[
197
],
[
199,
201
],
[
203
],
[
205
],
[
211
],
[
215
],
[
217
],
[
219
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
259
],
[
261
],
[
263
],
[
265
],
[
271
],
[
273
],
[
275
],
[
277,
279
],
[
281
],
[
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
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349,
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361,
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
379
],
[
381
]
] |
26,054 | static int can_safely_read(GetBitContext* gb, uint64_t bits) {
return get_bits_left(gb) >= bits;
}
| false | FFmpeg | e494f44c051d7dccc038a603ab22532b87dd1705 | static int can_safely_read(GetBitContext* gb, uint64_t bits) {
return get_bits_left(gb) >= bits;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(GetBitContext* VAR_0, uint64_t VAR_1) {
return get_bits_left(VAR_0) >= VAR_1;
}
| [
"static int FUNC_0(GetBitContext* VAR_0, uint64_t VAR_1) {",
"return get_bits_left(VAR_0) >= VAR_1;",
"}"
] | [
0,
0,
0
] | [
[
1
],
[
3
],
[
5
]
] |
26,055 | static int tta_probe(AVProbeData *p)
{
const uint8_t *d = p->buf;
if (p->buf_size < 4)
return 0;
if (d[0] == 'T' && d[1] == 'T' && d[2] == 'A' && d[3] == '1')
return 80;
return 0;
}
| false | FFmpeg | 87e8788680e16c51f6048af26f3f7830c35207a5 | static int tta_probe(AVProbeData *p)
{
const uint8_t *d = p->buf;
if (p->buf_size < 4)
return 0;
if (d[0] == 'T' && d[1] == 'T' && d[2] == 'A' && d[3] == '1')
return 80;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVProbeData *VAR_0)
{
const uint8_t *VAR_1 = VAR_0->buf;
if (VAR_0->buf_size < 4)
return 0;
if (VAR_1[0] == 'T' && VAR_1[1] == 'T' && VAR_1[2] == 'A' && VAR_1[3] == '1')
return 80;
return 0;
}
| [
"static int FUNC_0(AVProbeData *VAR_0)\n{",
"const uint8_t *VAR_1 = VAR_0->buf;",
"if (VAR_0->buf_size < 4)\nreturn 0;",
"if (VAR_1[0] == 'T' && VAR_1[1] == 'T' && VAR_1[2] == 'A' && VAR_1[3] == '1')\nreturn 80;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11,
13
],
[
15
],
[
17
]
] |
26,056 | static void qcow2_cache_table_release(BlockDriverState *bs, Qcow2Cache *c,
int i, int num_tables)
{
/* Using MADV_DONTNEED to discard memory is a Linux-specific feature */
#ifdef CONFIG_LINUX
BDRVQcow2State *s = bs->opaque;
void *t = qcow2_cache_get_table_addr(bs, c, i);
int align = getpagesize();
size_t mem_size = (size_t) s->cluster_size * num_tables;
size_t offset = QEMU_ALIGN_UP((uintptr_t) t, align) - (uintptr_t) t;
size_t length = QEMU_ALIGN_DOWN(mem_size - offset, align);
if (length > 0) {
madvise((uint8_t *) t + offset, length, MADV_DONTNEED);
}
#endif
}
| false | qemu | 08546bcfb260c28141e27cf3367c443528602fc0 | static void qcow2_cache_table_release(BlockDriverState *bs, Qcow2Cache *c,
int i, int num_tables)
{
#ifdef CONFIG_LINUX
BDRVQcow2State *s = bs->opaque;
void *t = qcow2_cache_get_table_addr(bs, c, i);
int align = getpagesize();
size_t mem_size = (size_t) s->cluster_size * num_tables;
size_t offset = QEMU_ALIGN_UP((uintptr_t) t, align) - (uintptr_t) t;
size_t length = QEMU_ALIGN_DOWN(mem_size - offset, align);
if (length > 0) {
madvise((uint8_t *) t + offset, length, MADV_DONTNEED);
}
#endif
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(BlockDriverState *VAR_0, Qcow2Cache *VAR_1,
int VAR_2, int VAR_3)
{
#ifdef CONFIG_LINUX
BDRVQcow2State *s = VAR_0->opaque;
void *t = qcow2_cache_get_table_addr(VAR_0, VAR_1, VAR_2);
int align = getpagesize();
size_t mem_size = (size_t) s->cluster_size * VAR_3;
size_t offset = QEMU_ALIGN_UP((uintptr_t) t, align) - (uintptr_t) t;
size_t length = QEMU_ALIGN_DOWN(mem_size - offset, align);
if (length > 0) {
madvise((uint8_t *) t + offset, length, MADV_DONTNEED);
}
#endif
}
| [
"static void FUNC_0(BlockDriverState *VAR_0, Qcow2Cache *VAR_1,\nint VAR_2, int VAR_3)\n{",
"#ifdef CONFIG_LINUX\nBDRVQcow2State *s = VAR_0->opaque;",
"void *t = qcow2_cache_get_table_addr(VAR_0, VAR_1, VAR_2);",
"int align = getpagesize();",
"size_t mem_size = (size_t) s->cluster_size * VAR_3;",
"size_t offset = QEMU_ALIGN_UP((uintptr_t) t, align) - (uintptr_t) t;",
"size_t length = QEMU_ALIGN_DOWN(mem_size - offset, align);",
"if (length > 0) {",
"madvise((uint8_t *) t + offset, length, MADV_DONTNEED);",
"}",
"#endif\n}"
] | [
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
]
] |
26,057 | static void qpi_init(void)
{
kqemu_comm_base = 0xff000000 | 1;
qpi_io_memory = cpu_register_io_memory(
qpi_mem_read,
qpi_mem_write, NULL);
cpu_register_physical_memory(kqemu_comm_base & ~0xfff,
0x1000, qpi_io_memory);
}
| false | qemu | 4a1418e07bdcfaa3177739e04707ecaec75d89e1 | static void qpi_init(void)
{
kqemu_comm_base = 0xff000000 | 1;
qpi_io_memory = cpu_register_io_memory(
qpi_mem_read,
qpi_mem_write, NULL);
cpu_register_physical_memory(kqemu_comm_base & ~0xfff,
0x1000, qpi_io_memory);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
kqemu_comm_base = 0xff000000 | 1;
qpi_io_memory = cpu_register_io_memory(
qpi_mem_read,
qpi_mem_write, NULL);
cpu_register_physical_memory(kqemu_comm_base & ~0xfff,
0x1000, qpi_io_memory);
}
| [
"static void FUNC_0(void)\n{",
"kqemu_comm_base = 0xff000000 | 1;",
"qpi_io_memory = cpu_register_io_memory(\nqpi_mem_read,\nqpi_mem_write, NULL);",
"cpu_register_physical_memory(kqemu_comm_base & ~0xfff,\n0x1000, qpi_io_memory);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9,
11
],
[
13,
15
],
[
17
]
] |
26,058 | tight_detect_smooth_image(VncState *vs, int w, int h)
{
uint errors;
int compression = vs->tight.compression;
int quality = vs->tight.quality;
if (!vs->vd->lossy) {
return 0;
}
if (ds_get_bytes_per_pixel(vs->ds) == 1 ||
vs->clientds.pf.bytes_per_pixel == 1 ||
w < VNC_TIGHT_DETECT_MIN_WIDTH || h < VNC_TIGHT_DETECT_MIN_HEIGHT) {
return 0;
}
if (vs->tight.quality != -1) {
if (w * h < VNC_TIGHT_JPEG_MIN_RECT_SIZE) {
return 0;
}
} else {
if (w * h < tight_conf[compression].gradient_min_rect_size) {
return 0;
}
}
if (vs->clientds.pf.bytes_per_pixel == 4) {
if (vs->tight.pixel24) {
errors = tight_detect_smooth_image24(vs, w, h);
if (vs->tight.quality != -1) {
return (errors < tight_conf[quality].jpeg_threshold24);
}
return (errors < tight_conf[compression].gradient_threshold24);
} else {
errors = tight_detect_smooth_image32(vs, w, h);
}
} else {
errors = tight_detect_smooth_image16(vs, w, h);
}
if (quality != -1) {
return (errors < tight_conf[quality].jpeg_threshold);
}
return (errors < tight_conf[compression].gradient_threshold);
}
| false | qemu | 7bccf57383cca60a778d5c543ac80c9f62d89ef2 | tight_detect_smooth_image(VncState *vs, int w, int h)
{
uint errors;
int compression = vs->tight.compression;
int quality = vs->tight.quality;
if (!vs->vd->lossy) {
return 0;
}
if (ds_get_bytes_per_pixel(vs->ds) == 1 ||
vs->clientds.pf.bytes_per_pixel == 1 ||
w < VNC_TIGHT_DETECT_MIN_WIDTH || h < VNC_TIGHT_DETECT_MIN_HEIGHT) {
return 0;
}
if (vs->tight.quality != -1) {
if (w * h < VNC_TIGHT_JPEG_MIN_RECT_SIZE) {
return 0;
}
} else {
if (w * h < tight_conf[compression].gradient_min_rect_size) {
return 0;
}
}
if (vs->clientds.pf.bytes_per_pixel == 4) {
if (vs->tight.pixel24) {
errors = tight_detect_smooth_image24(vs, w, h);
if (vs->tight.quality != -1) {
return (errors < tight_conf[quality].jpeg_threshold24);
}
return (errors < tight_conf[compression].gradient_threshold24);
} else {
errors = tight_detect_smooth_image32(vs, w, h);
}
} else {
errors = tight_detect_smooth_image16(vs, w, h);
}
if (quality != -1) {
return (errors < tight_conf[quality].jpeg_threshold);
}
return (errors < tight_conf[compression].gradient_threshold);
}
| {
"code": [],
"line_no": []
} | FUNC_0(VncState *VAR_0, int VAR_1, int VAR_2)
{
uint errors;
int VAR_3 = VAR_0->tight.VAR_3;
int VAR_4 = VAR_0->tight.VAR_4;
if (!VAR_0->vd->lossy) {
return 0;
}
if (ds_get_bytes_per_pixel(VAR_0->ds) == 1 ||
VAR_0->clientds.pf.bytes_per_pixel == 1 ||
VAR_1 < VNC_TIGHT_DETECT_MIN_WIDTH || VAR_2 < VNC_TIGHT_DETECT_MIN_HEIGHT) {
return 0;
}
if (VAR_0->tight.VAR_4 != -1) {
if (VAR_1 * VAR_2 < VNC_TIGHT_JPEG_MIN_RECT_SIZE) {
return 0;
}
} else {
if (VAR_1 * VAR_2 < tight_conf[VAR_3].gradient_min_rect_size) {
return 0;
}
}
if (VAR_0->clientds.pf.bytes_per_pixel == 4) {
if (VAR_0->tight.pixel24) {
errors = tight_detect_smooth_image24(VAR_0, VAR_1, VAR_2);
if (VAR_0->tight.VAR_4 != -1) {
return (errors < tight_conf[VAR_4].jpeg_threshold24);
}
return (errors < tight_conf[VAR_3].gradient_threshold24);
} else {
errors = tight_detect_smooth_image32(VAR_0, VAR_1, VAR_2);
}
} else {
errors = tight_detect_smooth_image16(VAR_0, VAR_1, VAR_2);
}
if (VAR_4 != -1) {
return (errors < tight_conf[VAR_4].jpeg_threshold);
}
return (errors < tight_conf[VAR_3].gradient_threshold);
}
| [
"FUNC_0(VncState *VAR_0, int VAR_1, int VAR_2)\n{",
"uint errors;",
"int VAR_3 = VAR_0->tight.VAR_3;",
"int VAR_4 = VAR_0->tight.VAR_4;",
"if (!VAR_0->vd->lossy) {",
"return 0;",
"}",
"if (ds_get_bytes_per_pixel(VAR_0->ds) == 1 ||\nVAR_0->clientds.pf.bytes_per_pixel == 1 ||\nVAR_1 < VNC_TIGHT_DETECT_MIN_WIDTH || VAR_2 < VNC_TIGHT_DETECT_MIN_HEIGHT) {",
"return 0;",
"}",
"if (VAR_0->tight.VAR_4 != -1) {",
"if (VAR_1 * VAR_2 < VNC_TIGHT_JPEG_MIN_RECT_SIZE) {",
"return 0;",
"}",
"} else {",
"if (VAR_1 * VAR_2 < tight_conf[VAR_3].gradient_min_rect_size) {",
"return 0;",
"}",
"}",
"if (VAR_0->clientds.pf.bytes_per_pixel == 4) {",
"if (VAR_0->tight.pixel24) {",
"errors = tight_detect_smooth_image24(VAR_0, VAR_1, VAR_2);",
"if (VAR_0->tight.VAR_4 != -1) {",
"return (errors < tight_conf[VAR_4].jpeg_threshold24);",
"}",
"return (errors < tight_conf[VAR_3].gradient_threshold24);",
"} else {",
"errors = tight_detect_smooth_image32(VAR_0, VAR_1, VAR_2);",
"}",
"} else {",
"errors = tight_detect_smooth_image16(VAR_0, VAR_1, VAR_2);",
"}",
"if (VAR_4 != -1) {",
"return (errors < tight_conf[VAR_4].jpeg_threshold);",
"}",
"return (errors < tight_conf[VAR_3].gradient_threshold);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
]
] |
26,060 | static void list_formats(AVFormatContext *ctx, int type)
{
const struct video_data *s = ctx->priv_data;
struct v4l2_fmtdesc vfd = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE };
while(!v4l2_ioctl(s->fd, VIDIOC_ENUM_FMT, &vfd)) {
enum AVCodecID codec_id = avpriv_fmt_v4l2codec(vfd.pixelformat);
enum AVPixelFormat pix_fmt = avpriv_fmt_v4l2ff(vfd.pixelformat, codec_id);
vfd.index++;
if (!(vfd.flags & V4L2_FMT_FLAG_COMPRESSED) &&
type & V4L_RAWFORMATS) {
const char *fmt_name = av_get_pix_fmt_name(pix_fmt);
av_log(ctx, AV_LOG_INFO, "Raw : %9s : %20s :",
fmt_name ? fmt_name : "Unsupported",
vfd.description);
} else if (vfd.flags & V4L2_FMT_FLAG_COMPRESSED &&
type & V4L_COMPFORMATS) {
AVCodec *codec = avcodec_find_decoder(codec_id);
av_log(ctx, AV_LOG_INFO, "Compressed: %9s : %20s :",
codec ? codec->name : "Unsupported",
vfd.description);
} else {
continue;
}
#ifdef V4L2_FMT_FLAG_EMULATED
if (vfd.flags & V4L2_FMT_FLAG_EMULATED)
av_log(ctx, AV_LOG_INFO, " Emulated :");
#endif
#if HAVE_STRUCT_V4L2_FRMIVALENUM_DISCRETE
list_framesizes(ctx, vfd.pixelformat);
#endif
av_log(ctx, AV_LOG_INFO, "\n");
}
}
| false | FFmpeg | 931da6a5e9dd54563fe5d4d30b7bd4d0a0218c87 | static void list_formats(AVFormatContext *ctx, int type)
{
const struct video_data *s = ctx->priv_data;
struct v4l2_fmtdesc vfd = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE };
while(!v4l2_ioctl(s->fd, VIDIOC_ENUM_FMT, &vfd)) {
enum AVCodecID codec_id = avpriv_fmt_v4l2codec(vfd.pixelformat);
enum AVPixelFormat pix_fmt = avpriv_fmt_v4l2ff(vfd.pixelformat, codec_id);
vfd.index++;
if (!(vfd.flags & V4L2_FMT_FLAG_COMPRESSED) &&
type & V4L_RAWFORMATS) {
const char *fmt_name = av_get_pix_fmt_name(pix_fmt);
av_log(ctx, AV_LOG_INFO, "Raw : %9s : %20s :",
fmt_name ? fmt_name : "Unsupported",
vfd.description);
} else if (vfd.flags & V4L2_FMT_FLAG_COMPRESSED &&
type & V4L_COMPFORMATS) {
AVCodec *codec = avcodec_find_decoder(codec_id);
av_log(ctx, AV_LOG_INFO, "Compressed: %9s : %20s :",
codec ? codec->name : "Unsupported",
vfd.description);
} else {
continue;
}
#ifdef V4L2_FMT_FLAG_EMULATED
if (vfd.flags & V4L2_FMT_FLAG_EMULATED)
av_log(ctx, AV_LOG_INFO, " Emulated :");
#endif
#if HAVE_STRUCT_V4L2_FRMIVALENUM_DISCRETE
list_framesizes(ctx, vfd.pixelformat);
#endif
av_log(ctx, AV_LOG_INFO, "\n");
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVFormatContext *VAR_0, int VAR_1)
{
const struct video_data *VAR_2 = VAR_0->priv_data;
struct v4l2_fmtdesc VAR_3 = { .VAR_1 = V4L2_BUF_TYPE_VIDEO_CAPTURE };
while(!v4l2_ioctl(VAR_2->fd, VIDIOC_ENUM_FMT, &VAR_3)) {
enum AVCodecID VAR_4 = avpriv_fmt_v4l2codec(VAR_3.pixelformat);
enum AVPixelFormat VAR_5 = avpriv_fmt_v4l2ff(VAR_3.pixelformat, VAR_4);
VAR_3.index++;
if (!(VAR_3.flags & V4L2_FMT_FLAG_COMPRESSED) &&
VAR_1 & V4L_RAWFORMATS) {
const char *VAR_6 = av_get_pix_fmt_name(VAR_5);
av_log(VAR_0, AV_LOG_INFO, "Raw : %9s : %20s :",
VAR_6 ? VAR_6 : "Unsupported",
VAR_3.description);
} else if (VAR_3.flags & V4L2_FMT_FLAG_COMPRESSED &&
VAR_1 & V4L_COMPFORMATS) {
AVCodec *codec = avcodec_find_decoder(VAR_4);
av_log(VAR_0, AV_LOG_INFO, "Compressed: %9s : %20s :",
codec ? codec->name : "Unsupported",
VAR_3.description);
} else {
continue;
}
#ifdef V4L2_FMT_FLAG_EMULATED
if (VAR_3.flags & V4L2_FMT_FLAG_EMULATED)
av_log(VAR_0, AV_LOG_INFO, " Emulated :");
#endif
#if HAVE_STRUCT_V4L2_FRMIVALENUM_DISCRETE
list_framesizes(VAR_0, VAR_3.pixelformat);
#endif
av_log(VAR_0, AV_LOG_INFO, "\n");
}
}
| [
"static void FUNC_0(AVFormatContext *VAR_0, int VAR_1)\n{",
"const struct video_data *VAR_2 = VAR_0->priv_data;",
"struct v4l2_fmtdesc VAR_3 = { .VAR_1 = V4L2_BUF_TYPE_VIDEO_CAPTURE };",
"while(!v4l2_ioctl(VAR_2->fd, VIDIOC_ENUM_FMT, &VAR_3)) {",
"enum AVCodecID VAR_4 = avpriv_fmt_v4l2codec(VAR_3.pixelformat);",
"enum AVPixelFormat VAR_5 = avpriv_fmt_v4l2ff(VAR_3.pixelformat, VAR_4);",
"VAR_3.index++;",
"if (!(VAR_3.flags & V4L2_FMT_FLAG_COMPRESSED) &&\nVAR_1 & V4L_RAWFORMATS) {",
"const char *VAR_6 = av_get_pix_fmt_name(VAR_5);",
"av_log(VAR_0, AV_LOG_INFO, \"Raw : %9s : %20s :\",\nVAR_6 ? VAR_6 : \"Unsupported\",\nVAR_3.description);",
"} else if (VAR_3.flags & V4L2_FMT_FLAG_COMPRESSED &&",
"VAR_1 & V4L_COMPFORMATS) {",
"AVCodec *codec = avcodec_find_decoder(VAR_4);",
"av_log(VAR_0, AV_LOG_INFO, \"Compressed: %9s : %20s :\",\ncodec ? codec->name : \"Unsupported\",\nVAR_3.description);",
"} else {",
"continue;",
"}",
"#ifdef V4L2_FMT_FLAG_EMULATED\nif (VAR_3.flags & V4L2_FMT_FLAG_EMULATED)\nav_log(VAR_0, AV_LOG_INFO, \" Emulated :\");",
"#endif\n#if HAVE_STRUCT_V4L2_FRMIVALENUM_DISCRETE\nlist_framesizes(VAR_0, VAR_3.pixelformat);",
"#endif\nav_log(VAR_0, AV_LOG_INFO, \"\\n\");",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23,
25
],
[
27
],
[
29,
31,
33
],
[
35
],
[
37
],
[
39
],
[
41,
43,
45
],
[
47
],
[
49
],
[
51
],
[
55,
57,
59
],
[
61,
63,
65
],
[
67,
69
],
[
71
],
[
73
]
] |
26,062 | static CharDriverState *qemu_chr_open_pp_fd(int fd, Error **errp)
{
CharDriverState *chr;
ParallelCharDriver *drv;
if (ioctl(fd, PPCLAIM) < 0) {
error_setg_errno(errp, errno, "not a parallel port");
close(fd);
return NULL;
}
drv = g_new0(ParallelCharDriver, 1);
drv->fd = fd;
drv->mode = IEEE1284_MODE_COMPAT;
chr = qemu_chr_alloc();
chr->chr_write = null_chr_write;
chr->chr_ioctl = pp_ioctl;
chr->chr_close = pp_close;
chr->opaque = drv;
return chr;
}
| false | qemu | d0d7708ba29cbcc343364a46bff981e0ff88366f | static CharDriverState *qemu_chr_open_pp_fd(int fd, Error **errp)
{
CharDriverState *chr;
ParallelCharDriver *drv;
if (ioctl(fd, PPCLAIM) < 0) {
error_setg_errno(errp, errno, "not a parallel port");
close(fd);
return NULL;
}
drv = g_new0(ParallelCharDriver, 1);
drv->fd = fd;
drv->mode = IEEE1284_MODE_COMPAT;
chr = qemu_chr_alloc();
chr->chr_write = null_chr_write;
chr->chr_ioctl = pp_ioctl;
chr->chr_close = pp_close;
chr->opaque = drv;
return chr;
}
| {
"code": [],
"line_no": []
} | static CharDriverState *FUNC_0(int fd, Error **errp)
{
CharDriverState *chr;
ParallelCharDriver *drv;
if (ioctl(fd, PPCLAIM) < 0) {
error_setg_errno(errp, errno, "not a parallel port");
close(fd);
return NULL;
}
drv = g_new0(ParallelCharDriver, 1);
drv->fd = fd;
drv->mode = IEEE1284_MODE_COMPAT;
chr = qemu_chr_alloc();
chr->chr_write = null_chr_write;
chr->chr_ioctl = pp_ioctl;
chr->chr_close = pp_close;
chr->opaque = drv;
return chr;
}
| [
"static CharDriverState *FUNC_0(int fd, Error **errp)\n{",
"CharDriverState *chr;",
"ParallelCharDriver *drv;",
"if (ioctl(fd, PPCLAIM) < 0) {",
"error_setg_errno(errp, errno, \"not a parallel port\");",
"close(fd);",
"return NULL;",
"}",
"drv = g_new0(ParallelCharDriver, 1);",
"drv->fd = fd;",
"drv->mode = IEEE1284_MODE_COMPAT;",
"chr = qemu_chr_alloc();",
"chr->chr_write = null_chr_write;",
"chr->chr_ioctl = pp_ioctl;",
"chr->chr_close = pp_close;",
"chr->opaque = drv;",
"return chr;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
]
] |
26,063 | static QError *qerror_from_info(const char *fmt, va_list *va)
{
QError *qerr;
qerr = qerror_new();
loc_save(&qerr->loc);
qerr->error = error_obj_from_fmt_no_fail(fmt, va);
qerr->err_msg = qerror_format(fmt, qerr->error);
return qerr;
}
| false | qemu | 13f59ae8157e8ec238fa8aefe5309909a1eeb7e2 | static QError *qerror_from_info(const char *fmt, va_list *va)
{
QError *qerr;
qerr = qerror_new();
loc_save(&qerr->loc);
qerr->error = error_obj_from_fmt_no_fail(fmt, va);
qerr->err_msg = qerror_format(fmt, qerr->error);
return qerr;
}
| {
"code": [],
"line_no": []
} | static QError *FUNC_0(const char *fmt, va_list *va)
{
QError *qerr;
qerr = qerror_new();
loc_save(&qerr->loc);
qerr->error = error_obj_from_fmt_no_fail(fmt, va);
qerr->err_msg = qerror_format(fmt, qerr->error);
return qerr;
}
| [
"static QError *FUNC_0(const char *fmt, va_list *va)\n{",
"QError *qerr;",
"qerr = qerror_new();",
"loc_save(&qerr->loc);",
"qerr->error = error_obj_from_fmt_no_fail(fmt, va);",
"qerr->err_msg = qerror_format(fmt, qerr->error);",
"return qerr;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
]
] |
26,064 | static void unblock_io_signals(void)
{
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGUSR2);
sigaddset(&set, SIGIO);
sigaddset(&set, SIGALRM);
pthread_sigmask(SIG_UNBLOCK, &set, NULL);
sigemptyset(&set);
sigaddset(&set, SIGUSR1);
pthread_sigmask(SIG_BLOCK, &set, NULL);
}
| false | qemu | cc84de9570ffe01a9c3c169bd62ab9586a9a080c | static void unblock_io_signals(void)
{
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGUSR2);
sigaddset(&set, SIGIO);
sigaddset(&set, SIGALRM);
pthread_sigmask(SIG_UNBLOCK, &set, NULL);
sigemptyset(&set);
sigaddset(&set, SIGUSR1);
pthread_sigmask(SIG_BLOCK, &set, NULL);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGUSR2);
sigaddset(&set, SIGIO);
sigaddset(&set, SIGALRM);
pthread_sigmask(SIG_UNBLOCK, &set, NULL);
sigemptyset(&set);
sigaddset(&set, SIGUSR1);
pthread_sigmask(SIG_BLOCK, &set, NULL);
}
| [
"static void FUNC_0(void)\n{",
"sigset_t set;",
"sigemptyset(&set);",
"sigaddset(&set, SIGUSR2);",
"sigaddset(&set, SIGIO);",
"sigaddset(&set, SIGALRM);",
"pthread_sigmask(SIG_UNBLOCK, &set, NULL);",
"sigemptyset(&set);",
"sigaddset(&set, SIGUSR1);",
"pthread_sigmask(SIG_BLOCK, &set, NULL);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
26,065 | float32 helper_fqtos(CPUSPARCState *env)
{
float32 ret;
clear_float_exceptions(env);
ret = float128_to_float32(QT1, &env->fp_status);
check_ieee_exceptions(env);
return ret;
}
| false | qemu | 7385aed20db5d83979f683b9d0048674411e963c | float32 helper_fqtos(CPUSPARCState *env)
{
float32 ret;
clear_float_exceptions(env);
ret = float128_to_float32(QT1, &env->fp_status);
check_ieee_exceptions(env);
return ret;
}
| {
"code": [],
"line_no": []
} | float32 FUNC_0(CPUSPARCState *env)
{
float32 ret;
clear_float_exceptions(env);
ret = float128_to_float32(QT1, &env->fp_status);
check_ieee_exceptions(env);
return ret;
}
| [
"float32 FUNC_0(CPUSPARCState *env)\n{",
"float32 ret;",
"clear_float_exceptions(env);",
"ret = float128_to_float32(QT1, &env->fp_status);",
"check_ieee_exceptions(env);",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
26,066 | float32 float32_round_to_int( float32 a STATUS_PARAM)
{
flag aSign;
int16 aExp;
bits32 lastBitMask, roundBitsMask;
int8 roundingMode;
float32 z;
aExp = extractFloat32Exp( a );
if ( 0x96 <= aExp ) {
if ( ( aExp == 0xFF ) && extractFloat32Frac( a ) ) {
return propagateFloat32NaN( a, a STATUS_VAR );
}
return a;
}
if ( aExp <= 0x7E ) {
if ( (bits32) ( a<<1 ) == 0 ) return a;
STATUS(float_exception_flags) |= float_flag_inexact;
aSign = extractFloat32Sign( a );
switch ( STATUS(float_rounding_mode) ) {
case float_round_nearest_even:
if ( ( aExp == 0x7E ) && extractFloat32Frac( a ) ) {
return packFloat32( aSign, 0x7F, 0 );
}
break;
case float_round_down:
return aSign ? 0xBF800000 : 0;
case float_round_up:
return aSign ? 0x80000000 : 0x3F800000;
}
return packFloat32( aSign, 0, 0 );
}
lastBitMask = 1;
lastBitMask <<= 0x96 - aExp;
roundBitsMask = lastBitMask - 1;
z = a;
roundingMode = STATUS(float_rounding_mode);
if ( roundingMode == float_round_nearest_even ) {
z += lastBitMask>>1;
if ( ( z & roundBitsMask ) == 0 ) z &= ~ lastBitMask;
}
else if ( roundingMode != float_round_to_zero ) {
if ( extractFloat32Sign( z ) ^ ( roundingMode == float_round_up ) ) {
z += roundBitsMask;
}
}
z &= ~ roundBitsMask;
if ( z != a ) STATUS(float_exception_flags) |= float_flag_inexact;
return z;
}
| false | qemu | f090c9d4ad5812fb92843d6470a1111c15190c4c | float32 float32_round_to_int( float32 a STATUS_PARAM)
{
flag aSign;
int16 aExp;
bits32 lastBitMask, roundBitsMask;
int8 roundingMode;
float32 z;
aExp = extractFloat32Exp( a );
if ( 0x96 <= aExp ) {
if ( ( aExp == 0xFF ) && extractFloat32Frac( a ) ) {
return propagateFloat32NaN( a, a STATUS_VAR );
}
return a;
}
if ( aExp <= 0x7E ) {
if ( (bits32) ( a<<1 ) == 0 ) return a;
STATUS(float_exception_flags) |= float_flag_inexact;
aSign = extractFloat32Sign( a );
switch ( STATUS(float_rounding_mode) ) {
case float_round_nearest_even:
if ( ( aExp == 0x7E ) && extractFloat32Frac( a ) ) {
return packFloat32( aSign, 0x7F, 0 );
}
break;
case float_round_down:
return aSign ? 0xBF800000 : 0;
case float_round_up:
return aSign ? 0x80000000 : 0x3F800000;
}
return packFloat32( aSign, 0, 0 );
}
lastBitMask = 1;
lastBitMask <<= 0x96 - aExp;
roundBitsMask = lastBitMask - 1;
z = a;
roundingMode = STATUS(float_rounding_mode);
if ( roundingMode == float_round_nearest_even ) {
z += lastBitMask>>1;
if ( ( z & roundBitsMask ) == 0 ) z &= ~ lastBitMask;
}
else if ( roundingMode != float_round_to_zero ) {
if ( extractFloat32Sign( z ) ^ ( roundingMode == float_round_up ) ) {
z += roundBitsMask;
}
}
z &= ~ roundBitsMask;
if ( z != a ) STATUS(float_exception_flags) |= float_flag_inexact;
return z;
}
| {
"code": [],
"line_no": []
} | float32 FUNC_0( float32 a STATUS_PARAM)
{
flag aSign;
int16 aExp;
bits32 lastBitMask, roundBitsMask;
int8 roundingMode;
float32 z;
aExp = extractFloat32Exp( a );
if ( 0x96 <= aExp ) {
if ( ( aExp == 0xFF ) && extractFloat32Frac( a ) ) {
return propagateFloat32NaN( a, a STATUS_VAR );
}
return a;
}
if ( aExp <= 0x7E ) {
if ( (bits32) ( a<<1 ) == 0 ) return a;
STATUS(float_exception_flags) |= float_flag_inexact;
aSign = extractFloat32Sign( a );
switch ( STATUS(float_rounding_mode) ) {
case float_round_nearest_even:
if ( ( aExp == 0x7E ) && extractFloat32Frac( a ) ) {
return packFloat32( aSign, 0x7F, 0 );
}
break;
case float_round_down:
return aSign ? 0xBF800000 : 0;
case float_round_up:
return aSign ? 0x80000000 : 0x3F800000;
}
return packFloat32( aSign, 0, 0 );
}
lastBitMask = 1;
lastBitMask <<= 0x96 - aExp;
roundBitsMask = lastBitMask - 1;
z = a;
roundingMode = STATUS(float_rounding_mode);
if ( roundingMode == float_round_nearest_even ) {
z += lastBitMask>>1;
if ( ( z & roundBitsMask ) == 0 ) z &= ~ lastBitMask;
}
else if ( roundingMode != float_round_to_zero ) {
if ( extractFloat32Sign( z ) ^ ( roundingMode == float_round_up ) ) {
z += roundBitsMask;
}
}
z &= ~ roundBitsMask;
if ( z != a ) STATUS(float_exception_flags) |= float_flag_inexact;
return z;
}
| [
"float32 FUNC_0( float32 a STATUS_PARAM)\n{",
"flag aSign;",
"int16 aExp;",
"bits32 lastBitMask, roundBitsMask;",
"int8 roundingMode;",
"float32 z;",
"aExp = extractFloat32Exp( a );",
"if ( 0x96 <= aExp ) {",
"if ( ( aExp == 0xFF ) && extractFloat32Frac( a ) ) {",
"return propagateFloat32NaN( a, a STATUS_VAR );",
"}",
"return a;",
"}",
"if ( aExp <= 0x7E ) {",
"if ( (bits32) ( a<<1 ) == 0 ) return a;",
"STATUS(float_exception_flags) |= float_flag_inexact;",
"aSign = extractFloat32Sign( a );",
"switch ( STATUS(float_rounding_mode) ) {",
"case float_round_nearest_even:\nif ( ( aExp == 0x7E ) && extractFloat32Frac( a ) ) {",
"return packFloat32( aSign, 0x7F, 0 );",
"}",
"break;",
"case float_round_down:\nreturn aSign ? 0xBF800000 : 0;",
"case float_round_up:\nreturn aSign ? 0x80000000 : 0x3F800000;",
"}",
"return packFloat32( aSign, 0, 0 );",
"}",
"lastBitMask = 1;",
"lastBitMask <<= 0x96 - aExp;",
"roundBitsMask = lastBitMask - 1;",
"z = a;",
"roundingMode = STATUS(float_rounding_mode);",
"if ( roundingMode == float_round_nearest_even ) {",
"z += lastBitMask>>1;",
"if ( ( z & roundBitsMask ) == 0 ) z &= ~ lastBitMask;",
"}",
"else if ( roundingMode != float_round_to_zero ) {",
"if ( extractFloat32Sign( z ) ^ ( roundingMode == float_round_up ) ) {",
"z += roundBitsMask;",
"}",
"}",
"z &= ~ roundBitsMask;",
"if ( z != a ) STATUS(float_exception_flags) |= float_flag_inexact;",
"return z;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51,
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
]
] |
26,067 | static void do_drive_backup(DriveBackup *backup, BlockJobTxn *txn, Error **errp)
{
BlockDriverState *bs;
BlockDriverState *target_bs;
BlockDriverState *source = NULL;
BdrvDirtyBitmap *bmap = NULL;
AioContext *aio_context;
QDict *options = NULL;
Error *local_err = NULL;
int flags;
int64_t size;
if (!backup->has_speed) {
backup->speed = 0;
}
if (!backup->has_on_source_error) {
backup->on_source_error = BLOCKDEV_ON_ERROR_REPORT;
}
if (!backup->has_on_target_error) {
backup->on_target_error = BLOCKDEV_ON_ERROR_REPORT;
}
if (!backup->has_mode) {
backup->mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
}
if (!backup->has_job_id) {
backup->job_id = NULL;
}
bs = qmp_get_root_bs(backup->device, errp);
if (!bs) {
return;
}
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
if (!backup->has_format) {
backup->format = backup->mode == NEW_IMAGE_MODE_EXISTING ?
NULL : (char*) bs->drv->format_name;
}
/* Early check to avoid creating target */
if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_BACKUP_SOURCE, errp)) {
goto out;
}
flags = bs->open_flags | BDRV_O_RDWR;
/* See if we have a backing HD we can use to create our new image
* on top of. */
if (backup->sync == MIRROR_SYNC_MODE_TOP) {
source = backing_bs(bs);
if (!source) {
backup->sync = MIRROR_SYNC_MODE_FULL;
}
}
if (backup->sync == MIRROR_SYNC_MODE_NONE) {
source = bs;
}
size = bdrv_getlength(bs);
if (size < 0) {
error_setg_errno(errp, -size, "bdrv_getlength failed");
goto out;
}
if (backup->mode != NEW_IMAGE_MODE_EXISTING) {
assert(backup->format);
if (source) {
bdrv_img_create(backup->target, backup->format, source->filename,
source->drv->format_name, NULL,
size, flags, &local_err, false);
} else {
bdrv_img_create(backup->target, backup->format, NULL, NULL, NULL,
size, flags, &local_err, false);
}
}
if (local_err) {
error_propagate(errp, local_err);
goto out;
}
if (backup->format) {
options = qdict_new();
qdict_put(options, "driver", qstring_from_str(backup->format));
}
target_bs = bdrv_open(backup->target, NULL, options, flags, errp);
if (!target_bs) {
goto out;
}
bdrv_set_aio_context(target_bs, aio_context);
if (backup->has_bitmap) {
bmap = bdrv_find_dirty_bitmap(bs, backup->bitmap);
if (!bmap) {
error_setg(errp, "Bitmap '%s' could not be found", backup->bitmap);
bdrv_unref(target_bs);
goto out;
}
}
backup_start(backup->job_id, bs, target_bs, backup->speed, backup->sync,
bmap, backup->on_source_error, backup->on_target_error,
block_job_cb, bs, txn, &local_err);
bdrv_unref(target_bs);
if (local_err != NULL) {
error_propagate(errp, local_err);
goto out;
}
out:
aio_context_release(aio_context);
}
| false | qemu | 13b9414b5798539e2dbb87a570d96184fe21edf4 | static void do_drive_backup(DriveBackup *backup, BlockJobTxn *txn, Error **errp)
{
BlockDriverState *bs;
BlockDriverState *target_bs;
BlockDriverState *source = NULL;
BdrvDirtyBitmap *bmap = NULL;
AioContext *aio_context;
QDict *options = NULL;
Error *local_err = NULL;
int flags;
int64_t size;
if (!backup->has_speed) {
backup->speed = 0;
}
if (!backup->has_on_source_error) {
backup->on_source_error = BLOCKDEV_ON_ERROR_REPORT;
}
if (!backup->has_on_target_error) {
backup->on_target_error = BLOCKDEV_ON_ERROR_REPORT;
}
if (!backup->has_mode) {
backup->mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
}
if (!backup->has_job_id) {
backup->job_id = NULL;
}
bs = qmp_get_root_bs(backup->device, errp);
if (!bs) {
return;
}
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
if (!backup->has_format) {
backup->format = backup->mode == NEW_IMAGE_MODE_EXISTING ?
NULL : (char*) bs->drv->format_name;
}
if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_BACKUP_SOURCE, errp)) {
goto out;
}
flags = bs->open_flags | BDRV_O_RDWR;
if (backup->sync == MIRROR_SYNC_MODE_TOP) {
source = backing_bs(bs);
if (!source) {
backup->sync = MIRROR_SYNC_MODE_FULL;
}
}
if (backup->sync == MIRROR_SYNC_MODE_NONE) {
source = bs;
}
size = bdrv_getlength(bs);
if (size < 0) {
error_setg_errno(errp, -size, "bdrv_getlength failed");
goto out;
}
if (backup->mode != NEW_IMAGE_MODE_EXISTING) {
assert(backup->format);
if (source) {
bdrv_img_create(backup->target, backup->format, source->filename,
source->drv->format_name, NULL,
size, flags, &local_err, false);
} else {
bdrv_img_create(backup->target, backup->format, NULL, NULL, NULL,
size, flags, &local_err, false);
}
}
if (local_err) {
error_propagate(errp, local_err);
goto out;
}
if (backup->format) {
options = qdict_new();
qdict_put(options, "driver", qstring_from_str(backup->format));
}
target_bs = bdrv_open(backup->target, NULL, options, flags, errp);
if (!target_bs) {
goto out;
}
bdrv_set_aio_context(target_bs, aio_context);
if (backup->has_bitmap) {
bmap = bdrv_find_dirty_bitmap(bs, backup->bitmap);
if (!bmap) {
error_setg(errp, "Bitmap '%s' could not be found", backup->bitmap);
bdrv_unref(target_bs);
goto out;
}
}
backup_start(backup->job_id, bs, target_bs, backup->speed, backup->sync,
bmap, backup->on_source_error, backup->on_target_error,
block_job_cb, bs, txn, &local_err);
bdrv_unref(target_bs);
if (local_err != NULL) {
error_propagate(errp, local_err);
goto out;
}
out:
aio_context_release(aio_context);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DriveBackup *VAR_0, BlockJobTxn *VAR_1, Error **VAR_2)
{
BlockDriverState *bs;
BlockDriverState *target_bs;
BlockDriverState *source = NULL;
BdrvDirtyBitmap *bmap = NULL;
AioContext *aio_context;
QDict *options = NULL;
Error *local_err = NULL;
int VAR_3;
int64_t size;
if (!VAR_0->has_speed) {
VAR_0->speed = 0;
}
if (!VAR_0->has_on_source_error) {
VAR_0->on_source_error = BLOCKDEV_ON_ERROR_REPORT;
}
if (!VAR_0->has_on_target_error) {
VAR_0->on_target_error = BLOCKDEV_ON_ERROR_REPORT;
}
if (!VAR_0->has_mode) {
VAR_0->mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
}
if (!VAR_0->has_job_id) {
VAR_0->job_id = NULL;
}
bs = qmp_get_root_bs(VAR_0->device, VAR_2);
if (!bs) {
return;
}
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
if (!VAR_0->has_format) {
VAR_0->format = VAR_0->mode == NEW_IMAGE_MODE_EXISTING ?
NULL : (char*) bs->drv->format_name;
}
if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_BACKUP_SOURCE, VAR_2)) {
goto out;
}
VAR_3 = bs->open_flags | BDRV_O_RDWR;
if (VAR_0->sync == MIRROR_SYNC_MODE_TOP) {
source = backing_bs(bs);
if (!source) {
VAR_0->sync = MIRROR_SYNC_MODE_FULL;
}
}
if (VAR_0->sync == MIRROR_SYNC_MODE_NONE) {
source = bs;
}
size = bdrv_getlength(bs);
if (size < 0) {
error_setg_errno(VAR_2, -size, "bdrv_getlength failed");
goto out;
}
if (VAR_0->mode != NEW_IMAGE_MODE_EXISTING) {
assert(VAR_0->format);
if (source) {
bdrv_img_create(VAR_0->target, VAR_0->format, source->filename,
source->drv->format_name, NULL,
size, VAR_3, &local_err, false);
} else {
bdrv_img_create(VAR_0->target, VAR_0->format, NULL, NULL, NULL,
size, VAR_3, &local_err, false);
}
}
if (local_err) {
error_propagate(VAR_2, local_err);
goto out;
}
if (VAR_0->format) {
options = qdict_new();
qdict_put(options, "driver", qstring_from_str(VAR_0->format));
}
target_bs = bdrv_open(VAR_0->target, NULL, options, VAR_3, VAR_2);
if (!target_bs) {
goto out;
}
bdrv_set_aio_context(target_bs, aio_context);
if (VAR_0->has_bitmap) {
bmap = bdrv_find_dirty_bitmap(bs, VAR_0->bitmap);
if (!bmap) {
error_setg(VAR_2, "Bitmap '%s' could not be found", VAR_0->bitmap);
bdrv_unref(target_bs);
goto out;
}
}
backup_start(VAR_0->job_id, bs, target_bs, VAR_0->speed, VAR_0->sync,
bmap, VAR_0->on_source_error, VAR_0->on_target_error,
block_job_cb, bs, VAR_1, &local_err);
bdrv_unref(target_bs);
if (local_err != NULL) {
error_propagate(VAR_2, local_err);
goto out;
}
out:
aio_context_release(aio_context);
}
| [
"static void FUNC_0(DriveBackup *VAR_0, BlockJobTxn *VAR_1, Error **VAR_2)\n{",
"BlockDriverState *bs;",
"BlockDriverState *target_bs;",
"BlockDriverState *source = NULL;",
"BdrvDirtyBitmap *bmap = NULL;",
"AioContext *aio_context;",
"QDict *options = NULL;",
"Error *local_err = NULL;",
"int VAR_3;",
"int64_t size;",
"if (!VAR_0->has_speed) {",
"VAR_0->speed = 0;",
"}",
"if (!VAR_0->has_on_source_error) {",
"VAR_0->on_source_error = BLOCKDEV_ON_ERROR_REPORT;",
"}",
"if (!VAR_0->has_on_target_error) {",
"VAR_0->on_target_error = BLOCKDEV_ON_ERROR_REPORT;",
"}",
"if (!VAR_0->has_mode) {",
"VAR_0->mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;",
"}",
"if (!VAR_0->has_job_id) {",
"VAR_0->job_id = NULL;",
"}",
"bs = qmp_get_root_bs(VAR_0->device, VAR_2);",
"if (!bs) {",
"return;",
"}",
"aio_context = bdrv_get_aio_context(bs);",
"aio_context_acquire(aio_context);",
"if (!VAR_0->has_format) {",
"VAR_0->format = VAR_0->mode == NEW_IMAGE_MODE_EXISTING ?\nNULL : (char*) bs->drv->format_name;",
"}",
"if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_BACKUP_SOURCE, VAR_2)) {",
"goto out;",
"}",
"VAR_3 = bs->open_flags | BDRV_O_RDWR;",
"if (VAR_0->sync == MIRROR_SYNC_MODE_TOP) {",
"source = backing_bs(bs);",
"if (!source) {",
"VAR_0->sync = MIRROR_SYNC_MODE_FULL;",
"}",
"}",
"if (VAR_0->sync == MIRROR_SYNC_MODE_NONE) {",
"source = bs;",
"}",
"size = bdrv_getlength(bs);",
"if (size < 0) {",
"error_setg_errno(VAR_2, -size, \"bdrv_getlength failed\");",
"goto out;",
"}",
"if (VAR_0->mode != NEW_IMAGE_MODE_EXISTING) {",
"assert(VAR_0->format);",
"if (source) {",
"bdrv_img_create(VAR_0->target, VAR_0->format, source->filename,\nsource->drv->format_name, NULL,\nsize, VAR_3, &local_err, false);",
"} else {",
"bdrv_img_create(VAR_0->target, VAR_0->format, NULL, NULL, NULL,\nsize, VAR_3, &local_err, false);",
"}",
"}",
"if (local_err) {",
"error_propagate(VAR_2, local_err);",
"goto out;",
"}",
"if (VAR_0->format) {",
"options = qdict_new();",
"qdict_put(options, \"driver\", qstring_from_str(VAR_0->format));",
"}",
"target_bs = bdrv_open(VAR_0->target, NULL, options, VAR_3, VAR_2);",
"if (!target_bs) {",
"goto out;",
"}",
"bdrv_set_aio_context(target_bs, aio_context);",
"if (VAR_0->has_bitmap) {",
"bmap = bdrv_find_dirty_bitmap(bs, VAR_0->bitmap);",
"if (!bmap) {",
"error_setg(VAR_2, \"Bitmap '%s' could not be found\", VAR_0->bitmap);",
"bdrv_unref(target_bs);",
"goto out;",
"}",
"}",
"backup_start(VAR_0->job_id, bs, target_bs, VAR_0->speed, VAR_0->sync,\nbmap, VAR_0->on_source_error, VAR_0->on_target_error,\nblock_job_cb, bs, VAR_1, &local_err);",
"bdrv_unref(target_bs);",
"if (local_err != NULL) {",
"error_propagate(VAR_2, local_err);",
"goto out;",
"}",
"out:\naio_context_release(aio_context);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
73
],
[
75,
77
],
[
79
],
[
85
],
[
87
],
[
89
],
[
93
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133
],
[
135
],
[
137
],
[
139,
141,
143
],
[
145
],
[
147,
149
],
[
151
],
[
153
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
173
],
[
177
],
[
179
],
[
181
],
[
183
],
[
187
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
209,
211,
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
227,
229
],
[
231
]
] |
26,068 | static int encrypt_sectors(BDRVQcowState *s, int64_t sector_num,
uint8_t *buf, int nb_sectors, bool enc,
Error **errp)
{
union {
uint64_t ll[2];
uint8_t b[16];
} ivec;
int i;
int ret;
for(i = 0; i < nb_sectors; i++) {
ivec.ll[0] = cpu_to_le64(sector_num);
ivec.ll[1] = 0;
if (qcrypto_cipher_setiv(s->cipher,
ivec.b, G_N_ELEMENTS(ivec.b),
errp) < 0) {
return -1;
}
if (enc) {
ret = qcrypto_cipher_encrypt(s->cipher,
buf, buf,
512,
errp);
} else {
ret = qcrypto_cipher_decrypt(s->cipher,
buf, buf,
512,
errp);
}
if (ret < 0) {
return -1;
}
sector_num++;
buf += 512;
}
return 0;
}
| false | qemu | d85f4222b4681da7ebf8a90b26e085a68fa2c55a | static int encrypt_sectors(BDRVQcowState *s, int64_t sector_num,
uint8_t *buf, int nb_sectors, bool enc,
Error **errp)
{
union {
uint64_t ll[2];
uint8_t b[16];
} ivec;
int i;
int ret;
for(i = 0; i < nb_sectors; i++) {
ivec.ll[0] = cpu_to_le64(sector_num);
ivec.ll[1] = 0;
if (qcrypto_cipher_setiv(s->cipher,
ivec.b, G_N_ELEMENTS(ivec.b),
errp) < 0) {
return -1;
}
if (enc) {
ret = qcrypto_cipher_encrypt(s->cipher,
buf, buf,
512,
errp);
} else {
ret = qcrypto_cipher_decrypt(s->cipher,
buf, buf,
512,
errp);
}
if (ret < 0) {
return -1;
}
sector_num++;
buf += 512;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BDRVQcowState *VAR_0, int64_t VAR_1,
uint8_t *VAR_2, int VAR_3, bool VAR_4,
Error **VAR_5)
{
union {
uint64_t ll[2];
uint8_t b[16];
} VAR_6;
int VAR_7;
int VAR_8;
for(VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) {
VAR_6.ll[0] = cpu_to_le64(VAR_1);
VAR_6.ll[1] = 0;
if (qcrypto_cipher_setiv(VAR_0->cipher,
VAR_6.b, G_N_ELEMENTS(VAR_6.b),
VAR_5) < 0) {
return -1;
}
if (VAR_4) {
VAR_8 = qcrypto_cipher_encrypt(VAR_0->cipher,
VAR_2, VAR_2,
512,
VAR_5);
} else {
VAR_8 = qcrypto_cipher_decrypt(VAR_0->cipher,
VAR_2, VAR_2,
512,
VAR_5);
}
if (VAR_8 < 0) {
return -1;
}
VAR_1++;
VAR_2 += 512;
}
return 0;
}
| [
"static int FUNC_0(BDRVQcowState *VAR_0, int64_t VAR_1,\nuint8_t *VAR_2, int VAR_3, bool VAR_4,\nError **VAR_5)\n{",
"union {",
"uint64_t ll[2];",
"uint8_t b[16];",
"} VAR_6;",
"int VAR_7;",
"int VAR_8;",
"for(VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) {",
"VAR_6.ll[0] = cpu_to_le64(VAR_1);",
"VAR_6.ll[1] = 0;",
"if (qcrypto_cipher_setiv(VAR_0->cipher,\nVAR_6.b, G_N_ELEMENTS(VAR_6.b),\nVAR_5) < 0) {",
"return -1;",
"}",
"if (VAR_4) {",
"VAR_8 = qcrypto_cipher_encrypt(VAR_0->cipher,\nVAR_2, VAR_2,\n512,\nVAR_5);",
"} else {",
"VAR_8 = qcrypto_cipher_decrypt(VAR_0->cipher,\nVAR_2, VAR_2,\n512,\nVAR_5);",
"}",
"if (VAR_8 < 0) {",
"return -1;",
"}",
"VAR_1++;",
"VAR_2 += 512;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29,
31,
33
],
[
35
],
[
37
],
[
39
],
[
41,
43,
45,
47
],
[
49
],
[
51,
53,
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
]
] |
26,070 | static void nbd_teardown_connection(BlockDriverState *bs)
{
NBDClientSession *client = nbd_get_client_session(bs);
if (!client->ioc) { /* Already closed */
return;
}
/* finish any pending coroutines */
qio_channel_shutdown(client->ioc,
QIO_CHANNEL_SHUTDOWN_BOTH,
NULL);
nbd_recv_coroutines_enter_all(bs);
nbd_client_detach_aio_context(bs);
object_unref(OBJECT(client->sioc));
client->sioc = NULL;
object_unref(OBJECT(client->ioc));
client->ioc = NULL;
}
| false | qemu | a12a712a7dfbd2e2f4882ef2c90a9b2162166dd7 | static void nbd_teardown_connection(BlockDriverState *bs)
{
NBDClientSession *client = nbd_get_client_session(bs);
if (!client->ioc) {
return;
}
qio_channel_shutdown(client->ioc,
QIO_CHANNEL_SHUTDOWN_BOTH,
NULL);
nbd_recv_coroutines_enter_all(bs);
nbd_client_detach_aio_context(bs);
object_unref(OBJECT(client->sioc));
client->sioc = NULL;
object_unref(OBJECT(client->ioc));
client->ioc = NULL;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(BlockDriverState *VAR_0)
{
NBDClientSession *client = nbd_get_client_session(VAR_0);
if (!client->ioc) {
return;
}
qio_channel_shutdown(client->ioc,
QIO_CHANNEL_SHUTDOWN_BOTH,
NULL);
nbd_recv_coroutines_enter_all(VAR_0);
nbd_client_detach_aio_context(VAR_0);
object_unref(OBJECT(client->sioc));
client->sioc = NULL;
object_unref(OBJECT(client->ioc));
client->ioc = NULL;
}
| [
"static void FUNC_0(BlockDriverState *VAR_0)\n{",
"NBDClientSession *client = nbd_get_client_session(VAR_0);",
"if (!client->ioc) {",
"return;",
"}",
"qio_channel_shutdown(client->ioc,\nQIO_CHANNEL_SHUTDOWN_BOTH,\nNULL);",
"nbd_recv_coroutines_enter_all(VAR_0);",
"nbd_client_detach_aio_context(VAR_0);",
"object_unref(OBJECT(client->sioc));",
"client->sioc = NULL;",
"object_unref(OBJECT(client->ioc));",
"client->ioc = NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
19,
21,
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
]
] |
26,071 | static int cinepak_decode_strip (CinepakContext *s,
cvid_strip *strip, const uint8_t *data, int size)
{
const uint8_t *eod = (data + size);
int chunk_id, chunk_size;
/* coordinate sanity checks */
if (strip->x1 >= s->width || strip->x2 > s->width ||
strip->y1 >= s->height || strip->y2 > s->height ||
strip->x1 >= strip->x2 || strip->y1 >= strip->y2)
return -1;
while ((data + 4) <= eod) {
chunk_id = data[0];
chunk_size = AV_RB24 (&data[1]) - 4;
if(chunk_size < 0)
return -1;
data += 4;
chunk_size = ((data + chunk_size) > eod) ? (eod - data) : chunk_size;
switch (chunk_id) {
case 0x20:
case 0x21:
case 0x24:
case 0x25:
cinepak_decode_codebook (strip->v4_codebook, chunk_id,
chunk_size, data);
break;
case 0x22:
case 0x23:
case 0x26:
case 0x27:
cinepak_decode_codebook (strip->v1_codebook, chunk_id,
chunk_size, data);
break;
case 0x30:
case 0x31:
case 0x32:
return cinepak_decode_vectors (s, strip, chunk_id,
chunk_size, data);
}
data += chunk_size;
}
return -1;
}
| false | FFmpeg | 7056f13a89da1d1f4afd5c6342e7ca6824777125 | static int cinepak_decode_strip (CinepakContext *s,
cvid_strip *strip, const uint8_t *data, int size)
{
const uint8_t *eod = (data + size);
int chunk_id, chunk_size;
if (strip->x1 >= s->width || strip->x2 > s->width ||
strip->y1 >= s->height || strip->y2 > s->height ||
strip->x1 >= strip->x2 || strip->y1 >= strip->y2)
return -1;
while ((data + 4) <= eod) {
chunk_id = data[0];
chunk_size = AV_RB24 (&data[1]) - 4;
if(chunk_size < 0)
return -1;
data += 4;
chunk_size = ((data + chunk_size) > eod) ? (eod - data) : chunk_size;
switch (chunk_id) {
case 0x20:
case 0x21:
case 0x24:
case 0x25:
cinepak_decode_codebook (strip->v4_codebook, chunk_id,
chunk_size, data);
break;
case 0x22:
case 0x23:
case 0x26:
case 0x27:
cinepak_decode_codebook (strip->v1_codebook, chunk_id,
chunk_size, data);
break;
case 0x30:
case 0x31:
case 0x32:
return cinepak_decode_vectors (s, strip, chunk_id,
chunk_size, data);
}
data += chunk_size;
}
return -1;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0 (CinepakContext *VAR_0,
cvid_strip *VAR_1, const uint8_t *VAR_2, int VAR_3)
{
const uint8_t *VAR_4 = (VAR_2 + VAR_3);
int VAR_5, VAR_6;
if (VAR_1->x1 >= VAR_0->width || VAR_1->x2 > VAR_0->width ||
VAR_1->y1 >= VAR_0->height || VAR_1->y2 > VAR_0->height ||
VAR_1->x1 >= VAR_1->x2 || VAR_1->y1 >= VAR_1->y2)
return -1;
while ((VAR_2 + 4) <= VAR_4) {
VAR_5 = VAR_2[0];
VAR_6 = AV_RB24 (&VAR_2[1]) - 4;
if(VAR_6 < 0)
return -1;
VAR_2 += 4;
VAR_6 = ((VAR_2 + VAR_6) > VAR_4) ? (VAR_4 - VAR_2) : VAR_6;
switch (VAR_5) {
case 0x20:
case 0x21:
case 0x24:
case 0x25:
cinepak_decode_codebook (VAR_1->v4_codebook, VAR_5,
VAR_6, VAR_2);
break;
case 0x22:
case 0x23:
case 0x26:
case 0x27:
cinepak_decode_codebook (VAR_1->v1_codebook, VAR_5,
VAR_6, VAR_2);
break;
case 0x30:
case 0x31:
case 0x32:
return cinepak_decode_vectors (VAR_0, VAR_1, VAR_5,
VAR_6, VAR_2);
}
VAR_2 += VAR_6;
}
return -1;
}
| [
"static int FUNC_0 (CinepakContext *VAR_0,\ncvid_strip *VAR_1, const uint8_t *VAR_2, int VAR_3)\n{",
"const uint8_t *VAR_4 = (VAR_2 + VAR_3);",
"int VAR_5, VAR_6;",
"if (VAR_1->x1 >= VAR_0->width || VAR_1->x2 > VAR_0->width ||\nVAR_1->y1 >= VAR_0->height || VAR_1->y2 > VAR_0->height ||\nVAR_1->x1 >= VAR_1->x2 || VAR_1->y1 >= VAR_1->y2)\nreturn -1;",
"while ((VAR_2 + 4) <= VAR_4) {",
"VAR_5 = VAR_2[0];",
"VAR_6 = AV_RB24 (&VAR_2[1]) - 4;",
"if(VAR_6 < 0)\nreturn -1;",
"VAR_2 += 4;",
"VAR_6 = ((VAR_2 + VAR_6) > VAR_4) ? (VAR_4 - VAR_2) : VAR_6;",
"switch (VAR_5) {",
"case 0x20:\ncase 0x21:\ncase 0x24:\ncase 0x25:\ncinepak_decode_codebook (VAR_1->v4_codebook, VAR_5,\nVAR_6, VAR_2);",
"break;",
"case 0x22:\ncase 0x23:\ncase 0x26:\ncase 0x27:\ncinepak_decode_codebook (VAR_1->v1_codebook, VAR_5,\nVAR_6, VAR_2);",
"break;",
"case 0x30:\ncase 0x31:\ncase 0x32:\nreturn cinepak_decode_vectors (VAR_0, VAR_1, VAR_5,\nVAR_6, VAR_2);",
"}",
"VAR_2 += VAR_6;",
"}",
"return -1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
15,
17,
19,
21
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
37
],
[
39
],
[
43
],
[
47,
49,
51,
53,
55,
57
],
[
59
],
[
63,
65,
67,
69,
71,
73
],
[
75
],
[
79,
81,
83,
85,
87
],
[
89
],
[
93
],
[
95
],
[
99
],
[
101
]
] |
26,072 | static int coroutine_fn bdrv_driver_pwritev(BlockDriverState *bs,
uint64_t offset, uint64_t bytes,
QEMUIOVector *qiov, int flags)
{
BlockDriver *drv = bs->drv;
int64_t sector_num = offset >> BDRV_SECTOR_BITS;
unsigned int nb_sectors = bytes >> BDRV_SECTOR_BITS;
int ret;
assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);
assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
assert((bytes >> BDRV_SECTOR_BITS) <= BDRV_REQUEST_MAX_SECTORS);
if (drv->bdrv_co_writev_flags) {
ret = drv->bdrv_co_writev_flags(bs, sector_num, nb_sectors, qiov,
flags);
} else {
assert(drv->supported_write_flags == 0);
ret = drv->bdrv_co_writev(bs, sector_num, nb_sectors, qiov);
}
if (ret == 0 && (flags & BDRV_REQ_FUA) &&
!(drv->supported_write_flags & BDRV_REQ_FUA))
{
ret = bdrv_co_flush(bs);
}
return ret;
}
| false | qemu | 08844473820c93541fc47bdfeae0f2cc88cfab59 | static int coroutine_fn bdrv_driver_pwritev(BlockDriverState *bs,
uint64_t offset, uint64_t bytes,
QEMUIOVector *qiov, int flags)
{
BlockDriver *drv = bs->drv;
int64_t sector_num = offset >> BDRV_SECTOR_BITS;
unsigned int nb_sectors = bytes >> BDRV_SECTOR_BITS;
int ret;
assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);
assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
assert((bytes >> BDRV_SECTOR_BITS) <= BDRV_REQUEST_MAX_SECTORS);
if (drv->bdrv_co_writev_flags) {
ret = drv->bdrv_co_writev_flags(bs, sector_num, nb_sectors, qiov,
flags);
} else {
assert(drv->supported_write_flags == 0);
ret = drv->bdrv_co_writev(bs, sector_num, nb_sectors, qiov);
}
if (ret == 0 && (flags & BDRV_REQ_FUA) &&
!(drv->supported_write_flags & BDRV_REQ_FUA))
{
ret = bdrv_co_flush(bs);
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int VAR_0 bdrv_driver_pwritev(BlockDriverState *bs,
uint64_t offset, uint64_t bytes,
QEMUIOVector *qiov, int flags)
{
BlockDriver *drv = bs->drv;
int64_t sector_num = offset >> BDRV_SECTOR_BITS;
unsigned int nb_sectors = bytes >> BDRV_SECTOR_BITS;
int ret;
assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);
assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
assert((bytes >> BDRV_SECTOR_BITS) <= BDRV_REQUEST_MAX_SECTORS);
if (drv->bdrv_co_writev_flags) {
ret = drv->bdrv_co_writev_flags(bs, sector_num, nb_sectors, qiov,
flags);
} else {
assert(drv->supported_write_flags == 0);
ret = drv->bdrv_co_writev(bs, sector_num, nb_sectors, qiov);
}
if (ret == 0 && (flags & BDRV_REQ_FUA) &&
!(drv->supported_write_flags & BDRV_REQ_FUA))
{
ret = bdrv_co_flush(bs);
}
return ret;
}
| [
"static int VAR_0 bdrv_driver_pwritev(BlockDriverState *bs,\nuint64_t offset, uint64_t bytes,\nQEMUIOVector *qiov, int flags)\n{",
"BlockDriver *drv = bs->drv;",
"int64_t sector_num = offset >> BDRV_SECTOR_BITS;",
"unsigned int nb_sectors = bytes >> BDRV_SECTOR_BITS;",
"int ret;",
"assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);",
"assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);",
"assert((bytes >> BDRV_SECTOR_BITS) <= BDRV_REQUEST_MAX_SECTORS);",
"if (drv->bdrv_co_writev_flags) {",
"ret = drv->bdrv_co_writev_flags(bs, sector_num, nb_sectors, qiov,\nflags);",
"} else {",
"assert(drv->supported_write_flags == 0);",
"ret = drv->bdrv_co_writev(bs, sector_num, nb_sectors, qiov);",
"}",
"if (ret == 0 && (flags & BDRV_REQ_FUA) &&\n!(drv->supported_write_flags & BDRV_REQ_FUA))\n{",
"ret = bdrv_co_flush(bs);",
"}",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43,
45,
47
],
[
49
],
[
51
],
[
55
],
[
57
]
] |
26,073 | static void ss10_init(int ram_size, int vga_ram_size, int 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)
{
if (cpu_model == NULL)
cpu_model = "TI SuperSparc II";
sun4m_common_init(ram_size, boot_device, ds, kernel_filename,
kernel_cmdline, initrd_filename, cpu_model,
1, PROM_ADDR); // XXX prom overlap, actually first 4GB ok
}
| false | qemu | b3ceef24f4fee8d5ed96b8c4a5d3e80c0a651f0b | static void ss10_init(int ram_size, int vga_ram_size, int 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)
{
if (cpu_model == NULL)
cpu_model = "TI SuperSparc II";
sun4m_common_init(ram_size, boot_device, ds, kernel_filename,
kernel_cmdline, initrd_filename, cpu_model,
1, PROM_ADDR);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(int VAR_0, int VAR_1, int 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)
{
if (VAR_9 == NULL)
VAR_9 = "TI SuperSparc II";
sun4m_common_init(VAR_0, VAR_2, VAR_3, VAR_6,
VAR_7, VAR_8, VAR_9,
1, PROM_ADDR);
}
| [
"static void FUNC_0(int VAR_0, int VAR_1, int VAR_2,\nDisplayState *VAR_3, const char **VAR_4, int VAR_5,\nconst char *VAR_6, const char *VAR_7,\nconst char *VAR_8, const char *VAR_9)\n{",
"if (VAR_9 == NULL)\nVAR_9 = \"TI SuperSparc II\";",
"sun4m_common_init(VAR_0, VAR_2, VAR_3, VAR_6,\nVAR_7, VAR_8, VAR_9,\n1, PROM_ADDR);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11,
13
],
[
15,
17,
19
],
[
21
]
] |
26,074 | static uint64_t bonito_readl(void *opaque, target_phys_addr_t addr,
unsigned size)
{
PCIBonitoState *s = opaque;
uint32_t saddr;
saddr = (addr - BONITO_REGBASE) >> 2;
DPRINTF("bonito_readl "TARGET_FMT_plx"\n", addr);
switch (saddr) {
case BONITO_INTISR:
return s->regs[saddr];
default:
return s->regs[saddr];
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t bonito_readl(void *opaque, target_phys_addr_t addr,
unsigned size)
{
PCIBonitoState *s = opaque;
uint32_t saddr;
saddr = (addr - BONITO_REGBASE) >> 2;
DPRINTF("bonito_readl "TARGET_FMT_plx"\n", addr);
switch (saddr) {
case BONITO_INTISR:
return s->regs[saddr];
default:
return s->regs[saddr];
}
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,
unsigned size)
{
PCIBonitoState *s = opaque;
uint32_t saddr;
saddr = (addr - BONITO_REGBASE) >> 2;
DPRINTF("FUNC_0 "TARGET_FMT_plx"\n", addr);
switch (saddr) {
case BONITO_INTISR:
return s->regs[saddr];
default:
return s->regs[saddr];
}
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned size)\n{",
"PCIBonitoState *s = opaque;",
"uint32_t saddr;",
"saddr = (addr - BONITO_REGBASE) >> 2;",
"DPRINTF(\"FUNC_0 \"TARGET_FMT_plx\"\\n\", addr);",
"switch (saddr) {",
"case BONITO_INTISR:\nreturn s->regs[saddr];",
"default:\nreturn s->regs[saddr];",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21,
23
],
[
25,
27
],
[
29
],
[
31
]
] |
26,076 | static int ast_write_header(AVFormatContext *s)
{
ASTMuxContext *ast = s->priv_data;
AVIOContext *pb = s->pb;
AVCodecContext *enc;
unsigned int codec_tag;
if (s->nb_streams == 1) {
enc = s->streams[0]->codec;
} else {
av_log(s, AV_LOG_ERROR, "only one stream is supported\n");
return AVERROR(EINVAL);
}
if (enc->codec_id == AV_CODEC_ID_ADPCM_AFC) {
av_log(s, AV_LOG_ERROR, "muxing ADPCM AFC is not implemented\n");
return AVERROR_PATCHWELCOME;
}
codec_tag = ff_codec_get_tag(ff_codec_ast_tags, enc->codec_id);
if (!codec_tag) {
av_log(s, AV_LOG_ERROR, "unsupported codec\n");
return AVERROR(EINVAL);
}
if (ast->loopstart && ast->loopend && ast->loopstart >= ast->loopend) {
av_log(s, AV_LOG_ERROR, "loopend can't be less or equal to loopstart\n");
return AVERROR(EINVAL);
}
/* Convert milliseconds to samples */
CHECK_LOOP(start)
CHECK_LOOP(end)
ffio_wfourcc(pb, "STRM");
ast->size = avio_tell(pb);
avio_wb32(pb, 0); /* File size minus header */
avio_wb16(pb, codec_tag);
avio_wb16(pb, 16); /* Bit depth */
avio_wb16(pb, enc->channels);
avio_wb16(pb, 0xFFFF);
avio_wb32(pb, enc->sample_rate);
ast->samples = avio_tell(pb);
avio_wb32(pb, 0); /* Number of samples */
avio_wb32(pb, 0); /* Loopstart */
avio_wb32(pb, 0); /* Loopend */
avio_wb32(pb, 0); /* Size of first block */
/* Unknown */
avio_wb32(pb, 0);
avio_wl32(pb, 0x7F);
avio_wb64(pb, 0);
avio_wb64(pb, 0);
avio_wb32(pb, 0);
avio_flush(pb);
return 0;
}
| false | FFmpeg | b7d77f8e64d5e30982671e861f63654709111a8e | static int ast_write_header(AVFormatContext *s)
{
ASTMuxContext *ast = s->priv_data;
AVIOContext *pb = s->pb;
AVCodecContext *enc;
unsigned int codec_tag;
if (s->nb_streams == 1) {
enc = s->streams[0]->codec;
} else {
av_log(s, AV_LOG_ERROR, "only one stream is supported\n");
return AVERROR(EINVAL);
}
if (enc->codec_id == AV_CODEC_ID_ADPCM_AFC) {
av_log(s, AV_LOG_ERROR, "muxing ADPCM AFC is not implemented\n");
return AVERROR_PATCHWELCOME;
}
codec_tag = ff_codec_get_tag(ff_codec_ast_tags, enc->codec_id);
if (!codec_tag) {
av_log(s, AV_LOG_ERROR, "unsupported codec\n");
return AVERROR(EINVAL);
}
if (ast->loopstart && ast->loopend && ast->loopstart >= ast->loopend) {
av_log(s, AV_LOG_ERROR, "loopend can't be less or equal to loopstart\n");
return AVERROR(EINVAL);
}
CHECK_LOOP(start)
CHECK_LOOP(end)
ffio_wfourcc(pb, "STRM");
ast->size = avio_tell(pb);
avio_wb32(pb, 0);
avio_wb16(pb, codec_tag);
avio_wb16(pb, 16);
avio_wb16(pb, enc->channels);
avio_wb16(pb, 0xFFFF);
avio_wb32(pb, enc->sample_rate);
ast->samples = avio_tell(pb);
avio_wb32(pb, 0);
avio_wb32(pb, 0);
avio_wb32(pb, 0);
avio_wb32(pb, 0);
avio_wb32(pb, 0);
avio_wl32(pb, 0x7F);
avio_wb64(pb, 0);
avio_wb64(pb, 0);
avio_wb32(pb, 0);
avio_flush(pb);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0)
{
ASTMuxContext *ast = VAR_0->priv_data;
AVIOContext *pb = VAR_0->pb;
AVCodecContext *enc;
unsigned int VAR_1;
if (VAR_0->nb_streams == 1) {
enc = VAR_0->streams[0]->codec;
} else {
av_log(VAR_0, AV_LOG_ERROR, "only one stream is supported\n");
return AVERROR(EINVAL);
}
if (enc->codec_id == AV_CODEC_ID_ADPCM_AFC) {
av_log(VAR_0, AV_LOG_ERROR, "muxing ADPCM AFC is not implemented\n");
return AVERROR_PATCHWELCOME;
}
VAR_1 = ff_codec_get_tag(ff_codec_ast_tags, enc->codec_id);
if (!VAR_1) {
av_log(VAR_0, AV_LOG_ERROR, "unsupported codec\n");
return AVERROR(EINVAL);
}
if (ast->loopstart && ast->loopend && ast->loopstart >= ast->loopend) {
av_log(VAR_0, AV_LOG_ERROR, "loopend can't be less or equal to loopstart\n");
return AVERROR(EINVAL);
}
CHECK_LOOP(start)
CHECK_LOOP(end)
ffio_wfourcc(pb, "STRM");
ast->size = avio_tell(pb);
avio_wb32(pb, 0);
avio_wb16(pb, VAR_1);
avio_wb16(pb, 16);
avio_wb16(pb, enc->channels);
avio_wb16(pb, 0xFFFF);
avio_wb32(pb, enc->sample_rate);
ast->samples = avio_tell(pb);
avio_wb32(pb, 0);
avio_wb32(pb, 0);
avio_wb32(pb, 0);
avio_wb32(pb, 0);
avio_wb32(pb, 0);
avio_wl32(pb, 0x7F);
avio_wb64(pb, 0);
avio_wb64(pb, 0);
avio_wb32(pb, 0);
avio_flush(pb);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"ASTMuxContext *ast = VAR_0->priv_data;",
"AVIOContext *pb = VAR_0->pb;",
"AVCodecContext *enc;",
"unsigned int VAR_1;",
"if (VAR_0->nb_streams == 1) {",
"enc = VAR_0->streams[0]->codec;",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR, \"only one stream is supported\\n\");",
"return AVERROR(EINVAL);",
"}",
"if (enc->codec_id == AV_CODEC_ID_ADPCM_AFC) {",
"av_log(VAR_0, AV_LOG_ERROR, \"muxing ADPCM AFC is not implemented\\n\");",
"return AVERROR_PATCHWELCOME;",
"}",
"VAR_1 = ff_codec_get_tag(ff_codec_ast_tags, enc->codec_id);",
"if (!VAR_1) {",
"av_log(VAR_0, AV_LOG_ERROR, \"unsupported codec\\n\");",
"return AVERROR(EINVAL);",
"}",
"if (ast->loopstart && ast->loopend && ast->loopstart >= ast->loopend) {",
"av_log(VAR_0, AV_LOG_ERROR, \"loopend can't be less or equal to loopstart\\n\");",
"return AVERROR(EINVAL);",
"}",
"CHECK_LOOP(start)\nCHECK_LOOP(end)\nffio_wfourcc(pb, \"STRM\");",
"ast->size = avio_tell(pb);",
"avio_wb32(pb, 0);",
"avio_wb16(pb, VAR_1);",
"avio_wb16(pb, 16);",
"avio_wb16(pb, enc->channels);",
"avio_wb16(pb, 0xFFFF);",
"avio_wb32(pb, enc->sample_rate);",
"ast->samples = avio_tell(pb);",
"avio_wb32(pb, 0);",
"avio_wb32(pb, 0);",
"avio_wb32(pb, 0);",
"avio_wb32(pb, 0);",
"avio_wb32(pb, 0);",
"avio_wl32(pb, 0x7F);",
"avio_wb64(pb, 0);",
"avio_wb64(pb, 0);",
"avio_wb32(pb, 0);",
"avio_flush(pb);",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
63,
65,
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
119
],
[
121
]
] |
26,077 | static int read_old_huffman_tables(HYuvContext *s)
{
GetBitContext gb;
int i;
init_get_bits(&gb, classic_shift_luma,
classic_shift_luma_table_size * 8);
if (read_len_table(s->len[0], &gb) < 0)
return -1;
init_get_bits(&gb, classic_shift_chroma,
classic_shift_chroma_table_size * 8);
if (read_len_table(s->len[1], &gb) < 0)
return -1;
for(i=0; i<256; i++) s->bits[0][i] = classic_add_luma [i];
for(i=0; i<256; i++) s->bits[1][i] = classic_add_chroma[i];
if (s->bitstream_bpp >= 24) {
memcpy(s->bits[1], s->bits[0], 256 * sizeof(uint32_t));
memcpy(s->len[1] , s->len [0], 256 * sizeof(uint8_t));
}
memcpy(s->bits[2], s->bits[1], 256 * sizeof(uint32_t));
memcpy(s->len[2] , s->len [1], 256 * sizeof(uint8_t));
for (i = 0; i < 3; i++) {
ff_free_vlc(&s->vlc[i]);
init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1,
s->bits[i], 4, 4, 0);
}
generate_joint_tables(s);
return 0;
}
| false | FFmpeg | f67a0d115254461649470452058fa3c28c0df294 | static int read_old_huffman_tables(HYuvContext *s)
{
GetBitContext gb;
int i;
init_get_bits(&gb, classic_shift_luma,
classic_shift_luma_table_size * 8);
if (read_len_table(s->len[0], &gb) < 0)
return -1;
init_get_bits(&gb, classic_shift_chroma,
classic_shift_chroma_table_size * 8);
if (read_len_table(s->len[1], &gb) < 0)
return -1;
for(i=0; i<256; i++) s->bits[0][i] = classic_add_luma [i];
for(i=0; i<256; i++) s->bits[1][i] = classic_add_chroma[i];
if (s->bitstream_bpp >= 24) {
memcpy(s->bits[1], s->bits[0], 256 * sizeof(uint32_t));
memcpy(s->len[1] , s->len [0], 256 * sizeof(uint8_t));
}
memcpy(s->bits[2], s->bits[1], 256 * sizeof(uint32_t));
memcpy(s->len[2] , s->len [1], 256 * sizeof(uint8_t));
for (i = 0; i < 3; i++) {
ff_free_vlc(&s->vlc[i]);
init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1,
s->bits[i], 4, 4, 0);
}
generate_joint_tables(s);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(HYuvContext *VAR_0)
{
GetBitContext gb;
int VAR_1;
init_get_bits(&gb, classic_shift_luma,
classic_shift_luma_table_size * 8);
if (read_len_table(VAR_0->len[0], &gb) < 0)
return -1;
init_get_bits(&gb, classic_shift_chroma,
classic_shift_chroma_table_size * 8);
if (read_len_table(VAR_0->len[1], &gb) < 0)
return -1;
for(VAR_1=0; VAR_1<256; VAR_1++) VAR_0->bits[0][VAR_1] = classic_add_luma [VAR_1];
for(VAR_1=0; VAR_1<256; VAR_1++) VAR_0->bits[1][VAR_1] = classic_add_chroma[VAR_1];
if (VAR_0->bitstream_bpp >= 24) {
memcpy(VAR_0->bits[1], VAR_0->bits[0], 256 * sizeof(uint32_t));
memcpy(VAR_0->len[1] , VAR_0->len [0], 256 * sizeof(uint8_t));
}
memcpy(VAR_0->bits[2], VAR_0->bits[1], 256 * sizeof(uint32_t));
memcpy(VAR_0->len[2] , VAR_0->len [1], 256 * sizeof(uint8_t));
for (VAR_1 = 0; VAR_1 < 3; VAR_1++) {
ff_free_vlc(&VAR_0->vlc[VAR_1]);
init_vlc(&VAR_0->vlc[VAR_1], VLC_BITS, 256, VAR_0->len[VAR_1], 1, 1,
VAR_0->bits[VAR_1], 4, 4, 0);
}
generate_joint_tables(VAR_0);
return 0;
}
| [
"static int FUNC_0(HYuvContext *VAR_0)\n{",
"GetBitContext gb;",
"int VAR_1;",
"init_get_bits(&gb, classic_shift_luma,\nclassic_shift_luma_table_size * 8);",
"if (read_len_table(VAR_0->len[0], &gb) < 0)\nreturn -1;",
"init_get_bits(&gb, classic_shift_chroma,\nclassic_shift_chroma_table_size * 8);",
"if (read_len_table(VAR_0->len[1], &gb) < 0)\nreturn -1;",
"for(VAR_1=0; VAR_1<256; VAR_1++) VAR_0->bits[0][VAR_1] = classic_add_luma [VAR_1];",
"for(VAR_1=0; VAR_1<256; VAR_1++) VAR_0->bits[1][VAR_1] = classic_add_chroma[VAR_1];",
"if (VAR_0->bitstream_bpp >= 24) {",
"memcpy(VAR_0->bits[1], VAR_0->bits[0], 256 * sizeof(uint32_t));",
"memcpy(VAR_0->len[1] , VAR_0->len [0], 256 * sizeof(uint8_t));",
"}",
"memcpy(VAR_0->bits[2], VAR_0->bits[1], 256 * sizeof(uint32_t));",
"memcpy(VAR_0->len[2] , VAR_0->len [1], 256 * sizeof(uint8_t));",
"for (VAR_1 = 0; VAR_1 < 3; VAR_1++) {",
"ff_free_vlc(&VAR_0->vlc[VAR_1]);",
"init_vlc(&VAR_0->vlc[VAR_1], VLC_BITS, 256, VAR_0->len[VAR_1], 1, 1,\nVAR_0->bits[VAR_1], 4, 4, 0);",
"}",
"generate_joint_tables(VAR_0);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
15,
17
],
[
21,
23
],
[
25,
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
63
],
[
67
],
[
69
]
] |
26,078 | static void pc_init_isa(MachineState *machine)
{
has_pci_info = false;
has_acpi_build = false;
smbios_defaults = false;
if (!machine->cpu_model) {
machine->cpu_model = "486";
}
x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
enable_compat_apic_id_mode();
pc_init1(machine, 0, 1);
} | true | qemu | 5f8632d3c3d7bc5ef24166ba7cf90fcfb2adbf7d | static void pc_init_isa(MachineState *machine)
{
has_pci_info = false;
has_acpi_build = false;
smbios_defaults = false;
if (!machine->cpu_model) {
machine->cpu_model = "486";
}
x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
enable_compat_apic_id_mode();
pc_init1(machine, 0, 1);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(MachineState *VAR_0)
{
has_pci_info = false;
has_acpi_build = false;
smbios_defaults = false;
if (!VAR_0->cpu_model) {
VAR_0->cpu_model = "486";
}
x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
enable_compat_apic_id_mode();
pc_init1(VAR_0, 0, 1);
} | [
"static void FUNC_0(MachineState *VAR_0)\n{",
"has_pci_info = false;",
"has_acpi_build = false;",
"smbios_defaults = false;",
"if (!VAR_0->cpu_model) {",
"VAR_0->cpu_model = \"486\";",
"}",
"x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);",
"enable_compat_apic_id_mode();",
"pc_init1(VAR_0, 0, 1);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
16
],
[
18
],
[
20
],
[
22
],
[
24
],
[
26
],
[
28
]
] |
26,079 | static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics,
GetBitContext *gb)
{
const MPEG4AudioConfig *const m4ac = &ac->oc[1].m4ac;
const int aot = m4ac->object_type;
const int sampling_index = m4ac->sampling_index;
if (aot != AOT_ER_AAC_ELD) {
if (get_bits1(gb)) {
av_log(ac->avctx, AV_LOG_ERROR, "Reserved bit set.\n");
return AVERROR_INVALIDDATA;
}
ics->window_sequence[1] = ics->window_sequence[0];
ics->window_sequence[0] = get_bits(gb, 2);
if (aot == AOT_ER_AAC_LD &&
ics->window_sequence[0] != ONLY_LONG_SEQUENCE) {
av_log(ac->avctx, AV_LOG_ERROR,
"AAC LD is only defined for ONLY_LONG_SEQUENCE but "
"window sequence %d found.\n", ics->window_sequence[0]);
ics->window_sequence[0] = ONLY_LONG_SEQUENCE;
return AVERROR_INVALIDDATA;
}
ics->use_kb_window[1] = ics->use_kb_window[0];
ics->use_kb_window[0] = get_bits1(gb);
}
ics->num_window_groups = 1;
ics->group_len[0] = 1;
if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
int i;
ics->max_sfb = get_bits(gb, 4);
for (i = 0; i < 7; i++) {
if (get_bits1(gb)) {
ics->group_len[ics->num_window_groups - 1]++;
} else {
ics->num_window_groups++;
ics->group_len[ics->num_window_groups - 1] = 1;
}
}
ics->num_windows = 8;
ics->swb_offset = ff_swb_offset_128[sampling_index];
ics->num_swb = ff_aac_num_swb_128[sampling_index];
ics->tns_max_bands = ff_tns_max_bands_128[sampling_index];
ics->predictor_present = 0;
} else {
ics->max_sfb = get_bits(gb, 6);
ics->num_windows = 1;
if (aot == AOT_ER_AAC_LD || aot == AOT_ER_AAC_ELD) {
if (m4ac->frame_length_short) {
ics->swb_offset = ff_swb_offset_480[sampling_index];
ics->num_swb = ff_aac_num_swb_480[sampling_index];
ics->tns_max_bands = ff_tns_max_bands_480[sampling_index];
} else {
ics->swb_offset = ff_swb_offset_512[sampling_index];
ics->num_swb = ff_aac_num_swb_512[sampling_index];
ics->tns_max_bands = ff_tns_max_bands_512[sampling_index];
}
if (!ics->num_swb || !ics->swb_offset)
return AVERROR_BUG;
} else {
ics->swb_offset = ff_swb_offset_1024[sampling_index];
ics->num_swb = ff_aac_num_swb_1024[sampling_index];
ics->tns_max_bands = ff_tns_max_bands_1024[sampling_index];
}
if (aot != AOT_ER_AAC_ELD) {
ics->predictor_present = get_bits1(gb);
ics->predictor_reset_group = 0;
}
if (ics->predictor_present) {
if (aot == AOT_AAC_MAIN) {
if (decode_prediction(ac, ics, gb)) {
return AVERROR_INVALIDDATA;
}
} else if (aot == AOT_AAC_LC ||
aot == AOT_ER_AAC_LC) {
av_log(ac->avctx, AV_LOG_ERROR,
"Prediction is not allowed in AAC-LC.\n");
return AVERROR_INVALIDDATA;
} else {
if (aot == AOT_ER_AAC_LD) {
av_log(ac->avctx, AV_LOG_ERROR,
"LTP in ER AAC LD not yet implemented.\n");
return AVERROR_PATCHWELCOME;
}
if ((ics->ltp.present = get_bits(gb, 1)))
decode_ltp(&ics->ltp, gb, ics->max_sfb);
}
}
}
if (ics->max_sfb > ics->num_swb) {
av_log(ac->avctx, AV_LOG_ERROR,
"Number of scalefactor bands in group (%d) "
"exceeds limit (%d).\n",
ics->max_sfb, ics->num_swb);
return AVERROR_INVALIDDATA;
}
return 0;
}
| true | FFmpeg | 87e85a133f3ce2f037b90e9c7bbca99951df6c15 | static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics,
GetBitContext *gb)
{
const MPEG4AudioConfig *const m4ac = &ac->oc[1].m4ac;
const int aot = m4ac->object_type;
const int sampling_index = m4ac->sampling_index;
if (aot != AOT_ER_AAC_ELD) {
if (get_bits1(gb)) {
av_log(ac->avctx, AV_LOG_ERROR, "Reserved bit set.\n");
return AVERROR_INVALIDDATA;
}
ics->window_sequence[1] = ics->window_sequence[0];
ics->window_sequence[0] = get_bits(gb, 2);
if (aot == AOT_ER_AAC_LD &&
ics->window_sequence[0] != ONLY_LONG_SEQUENCE) {
av_log(ac->avctx, AV_LOG_ERROR,
"AAC LD is only defined for ONLY_LONG_SEQUENCE but "
"window sequence %d found.\n", ics->window_sequence[0]);
ics->window_sequence[0] = ONLY_LONG_SEQUENCE;
return AVERROR_INVALIDDATA;
}
ics->use_kb_window[1] = ics->use_kb_window[0];
ics->use_kb_window[0] = get_bits1(gb);
}
ics->num_window_groups = 1;
ics->group_len[0] = 1;
if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
int i;
ics->max_sfb = get_bits(gb, 4);
for (i = 0; i < 7; i++) {
if (get_bits1(gb)) {
ics->group_len[ics->num_window_groups - 1]++;
} else {
ics->num_window_groups++;
ics->group_len[ics->num_window_groups - 1] = 1;
}
}
ics->num_windows = 8;
ics->swb_offset = ff_swb_offset_128[sampling_index];
ics->num_swb = ff_aac_num_swb_128[sampling_index];
ics->tns_max_bands = ff_tns_max_bands_128[sampling_index];
ics->predictor_present = 0;
} else {
ics->max_sfb = get_bits(gb, 6);
ics->num_windows = 1;
if (aot == AOT_ER_AAC_LD || aot == AOT_ER_AAC_ELD) {
if (m4ac->frame_length_short) {
ics->swb_offset = ff_swb_offset_480[sampling_index];
ics->num_swb = ff_aac_num_swb_480[sampling_index];
ics->tns_max_bands = ff_tns_max_bands_480[sampling_index];
} else {
ics->swb_offset = ff_swb_offset_512[sampling_index];
ics->num_swb = ff_aac_num_swb_512[sampling_index];
ics->tns_max_bands = ff_tns_max_bands_512[sampling_index];
}
if (!ics->num_swb || !ics->swb_offset)
return AVERROR_BUG;
} else {
ics->swb_offset = ff_swb_offset_1024[sampling_index];
ics->num_swb = ff_aac_num_swb_1024[sampling_index];
ics->tns_max_bands = ff_tns_max_bands_1024[sampling_index];
}
if (aot != AOT_ER_AAC_ELD) {
ics->predictor_present = get_bits1(gb);
ics->predictor_reset_group = 0;
}
if (ics->predictor_present) {
if (aot == AOT_AAC_MAIN) {
if (decode_prediction(ac, ics, gb)) {
return AVERROR_INVALIDDATA;
}
} else if (aot == AOT_AAC_LC ||
aot == AOT_ER_AAC_LC) {
av_log(ac->avctx, AV_LOG_ERROR,
"Prediction is not allowed in AAC-LC.\n");
return AVERROR_INVALIDDATA;
} else {
if (aot == AOT_ER_AAC_LD) {
av_log(ac->avctx, AV_LOG_ERROR,
"LTP in ER AAC LD not yet implemented.\n");
return AVERROR_PATCHWELCOME;
}
if ((ics->ltp.present = get_bits(gb, 1)))
decode_ltp(&ics->ltp, gb, ics->max_sfb);
}
}
}
if (ics->max_sfb > ics->num_swb) {
av_log(ac->avctx, AV_LOG_ERROR,
"Number of scalefactor bands in group (%d) "
"exceeds limit (%d).\n",
ics->max_sfb, ics->num_swb);
return AVERROR_INVALIDDATA;
}
return 0;
}
| {
"code": [
" return AVERROR_INVALIDDATA;"
],
"line_no": [
19
]
} | static int FUNC_0(AACContext *VAR_0, IndividualChannelStream *VAR_1,
GetBitContext *VAR_2)
{
const MPEG4AudioConfig *const VAR_3 = &VAR_0->oc[1].VAR_3;
const int VAR_4 = VAR_3->object_type;
const int VAR_5 = VAR_3->VAR_5;
if (VAR_4 != AOT_ER_AAC_ELD) {
if (get_bits1(VAR_2)) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Reserved bit set.\n");
return AVERROR_INVALIDDATA;
}
VAR_1->window_sequence[1] = VAR_1->window_sequence[0];
VAR_1->window_sequence[0] = get_bits(VAR_2, 2);
if (VAR_4 == AOT_ER_AAC_LD &&
VAR_1->window_sequence[0] != ONLY_LONG_SEQUENCE) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"AAC LD is only defined for ONLY_LONG_SEQUENCE but "
"window sequence %d found.\n", VAR_1->window_sequence[0]);
VAR_1->window_sequence[0] = ONLY_LONG_SEQUENCE;
return AVERROR_INVALIDDATA;
}
VAR_1->use_kb_window[1] = VAR_1->use_kb_window[0];
VAR_1->use_kb_window[0] = get_bits1(VAR_2);
}
VAR_1->num_window_groups = 1;
VAR_1->group_len[0] = 1;
if (VAR_1->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
int VAR_6;
VAR_1->max_sfb = get_bits(VAR_2, 4);
for (VAR_6 = 0; VAR_6 < 7; VAR_6++) {
if (get_bits1(VAR_2)) {
VAR_1->group_len[VAR_1->num_window_groups - 1]++;
} else {
VAR_1->num_window_groups++;
VAR_1->group_len[VAR_1->num_window_groups - 1] = 1;
}
}
VAR_1->num_windows = 8;
VAR_1->swb_offset = ff_swb_offset_128[VAR_5];
VAR_1->num_swb = ff_aac_num_swb_128[VAR_5];
VAR_1->tns_max_bands = ff_tns_max_bands_128[VAR_5];
VAR_1->predictor_present = 0;
} else {
VAR_1->max_sfb = get_bits(VAR_2, 6);
VAR_1->num_windows = 1;
if (VAR_4 == AOT_ER_AAC_LD || VAR_4 == AOT_ER_AAC_ELD) {
if (VAR_3->frame_length_short) {
VAR_1->swb_offset = ff_swb_offset_480[VAR_5];
VAR_1->num_swb = ff_aac_num_swb_480[VAR_5];
VAR_1->tns_max_bands = ff_tns_max_bands_480[VAR_5];
} else {
VAR_1->swb_offset = ff_swb_offset_512[VAR_5];
VAR_1->num_swb = ff_aac_num_swb_512[VAR_5];
VAR_1->tns_max_bands = ff_tns_max_bands_512[VAR_5];
}
if (!VAR_1->num_swb || !VAR_1->swb_offset)
return AVERROR_BUG;
} else {
VAR_1->swb_offset = ff_swb_offset_1024[VAR_5];
VAR_1->num_swb = ff_aac_num_swb_1024[VAR_5];
VAR_1->tns_max_bands = ff_tns_max_bands_1024[VAR_5];
}
if (VAR_4 != AOT_ER_AAC_ELD) {
VAR_1->predictor_present = get_bits1(VAR_2);
VAR_1->predictor_reset_group = 0;
}
if (VAR_1->predictor_present) {
if (VAR_4 == AOT_AAC_MAIN) {
if (decode_prediction(VAR_0, VAR_1, VAR_2)) {
return AVERROR_INVALIDDATA;
}
} else if (VAR_4 == AOT_AAC_LC ||
VAR_4 == AOT_ER_AAC_LC) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Prediction is not allowed in AAC-LC.\n");
return AVERROR_INVALIDDATA;
} else {
if (VAR_4 == AOT_ER_AAC_LD) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"LTP in ER AAC LD not yet implemented.\n");
return AVERROR_PATCHWELCOME;
}
if ((VAR_1->ltp.present = get_bits(VAR_2, 1)))
decode_ltp(&VAR_1->ltp, VAR_2, VAR_1->max_sfb);
}
}
}
if (VAR_1->max_sfb > VAR_1->num_swb) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Number of scalefactor bands in group (%d) "
"exceeds limit (%d).\n",
VAR_1->max_sfb, VAR_1->num_swb);
return AVERROR_INVALIDDATA;
}
return 0;
}
| [
"static int FUNC_0(AACContext *VAR_0, IndividualChannelStream *VAR_1,\nGetBitContext *VAR_2)\n{",
"const MPEG4AudioConfig *const VAR_3 = &VAR_0->oc[1].VAR_3;",
"const int VAR_4 = VAR_3->object_type;",
"const int VAR_5 = VAR_3->VAR_5;",
"if (VAR_4 != AOT_ER_AAC_ELD) {",
"if (get_bits1(VAR_2)) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Reserved bit set.\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_1->window_sequence[1] = VAR_1->window_sequence[0];",
"VAR_1->window_sequence[0] = get_bits(VAR_2, 2);",
"if (VAR_4 == AOT_ER_AAC_LD &&\nVAR_1->window_sequence[0] != ONLY_LONG_SEQUENCE) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"AAC LD is only defined for ONLY_LONG_SEQUENCE but \"\n\"window sequence %d found.\\n\", VAR_1->window_sequence[0]);",
"VAR_1->window_sequence[0] = ONLY_LONG_SEQUENCE;",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_1->use_kb_window[1] = VAR_1->use_kb_window[0];",
"VAR_1->use_kb_window[0] = get_bits1(VAR_2);",
"}",
"VAR_1->num_window_groups = 1;",
"VAR_1->group_len[0] = 1;",
"if (VAR_1->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {",
"int VAR_6;",
"VAR_1->max_sfb = get_bits(VAR_2, 4);",
"for (VAR_6 = 0; VAR_6 < 7; VAR_6++) {",
"if (get_bits1(VAR_2)) {",
"VAR_1->group_len[VAR_1->num_window_groups - 1]++;",
"} else {",
"VAR_1->num_window_groups++;",
"VAR_1->group_len[VAR_1->num_window_groups - 1] = 1;",
"}",
"}",
"VAR_1->num_windows = 8;",
"VAR_1->swb_offset = ff_swb_offset_128[VAR_5];",
"VAR_1->num_swb = ff_aac_num_swb_128[VAR_5];",
"VAR_1->tns_max_bands = ff_tns_max_bands_128[VAR_5];",
"VAR_1->predictor_present = 0;",
"} else {",
"VAR_1->max_sfb = get_bits(VAR_2, 6);",
"VAR_1->num_windows = 1;",
"if (VAR_4 == AOT_ER_AAC_LD || VAR_4 == AOT_ER_AAC_ELD) {",
"if (VAR_3->frame_length_short) {",
"VAR_1->swb_offset = ff_swb_offset_480[VAR_5];",
"VAR_1->num_swb = ff_aac_num_swb_480[VAR_5];",
"VAR_1->tns_max_bands = ff_tns_max_bands_480[VAR_5];",
"} else {",
"VAR_1->swb_offset = ff_swb_offset_512[VAR_5];",
"VAR_1->num_swb = ff_aac_num_swb_512[VAR_5];",
"VAR_1->tns_max_bands = ff_tns_max_bands_512[VAR_5];",
"}",
"if (!VAR_1->num_swb || !VAR_1->swb_offset)\nreturn AVERROR_BUG;",
"} else {",
"VAR_1->swb_offset = ff_swb_offset_1024[VAR_5];",
"VAR_1->num_swb = ff_aac_num_swb_1024[VAR_5];",
"VAR_1->tns_max_bands = ff_tns_max_bands_1024[VAR_5];",
"}",
"if (VAR_4 != AOT_ER_AAC_ELD) {",
"VAR_1->predictor_present = get_bits1(VAR_2);",
"VAR_1->predictor_reset_group = 0;",
"}",
"if (VAR_1->predictor_present) {",
"if (VAR_4 == AOT_AAC_MAIN) {",
"if (decode_prediction(VAR_0, VAR_1, VAR_2)) {",
"return AVERROR_INVALIDDATA;",
"}",
"} else if (VAR_4 == AOT_AAC_LC ||",
"VAR_4 == AOT_ER_AAC_LC) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Prediction is not allowed in AAC-LC.\\n\");",
"return AVERROR_INVALIDDATA;",
"} else {",
"if (VAR_4 == AOT_ER_AAC_LD) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"LTP in ER AAC LD not yet implemented.\\n\");",
"return AVERROR_PATCHWELCOME;",
"}",
"if ((VAR_1->ltp.present = get_bits(VAR_2, 1)))\ndecode_ltp(&VAR_1->ltp, VAR_2, VAR_1->max_sfb);",
"}",
"}",
"}",
"if (VAR_1->max_sfb > VAR_1->num_swb) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Number of scalefactor bands in group (%d) \"\n\"exceeds limit (%d).\\n\",\nVAR_1->max_sfb, VAR_1->num_swb);",
"return AVERROR_INVALIDDATA;",
"}",
"return 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
] | [
[
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
],
[
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
],
[
177
],
[
179,
181,
183,
185
],
[
187
],
[
189
],
[
193
],
[
195
]
] |
26,080 | static void dvbsub_parse_region_segment(AVCodecContext *avctx,
uint8_t *buf, int buf_size)
{
DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data;
uint8_t *buf_end = buf + buf_size;
int region_id, object_id;
DVBSubRegion *region;
DVBSubObject *object;
DVBSubObjectDisplay *display;
int fill;
if (buf_size < 10)
return;
region_id = *buf++;
region = get_region(ctx, region_id);
if (region == NULL)
{
region = av_mallocz(sizeof(DVBSubRegion));
region->id = region_id;
region->next = ctx->region_list;
ctx->region_list = region;
fill = ((*buf++) >> 3) & 1;
region->width = AV_RB16(buf);
buf += 2;
region->height = AV_RB16(buf);
buf += 2;
if (region->width * region->height != region->buf_size) {
if (region->pbuf != 0)
av_free(region->pbuf);
region->buf_size = region->width * region->height;
region->pbuf = av_malloc(region->buf_size);
fill = 1;
region->depth = 1 << (((*buf++) >> 2) & 7);
region->clut = *buf++;
if (region->depth == 8)
region->bgcolour = *buf++;
else {
buf += 1;
if (region->depth == 4)
region->bgcolour = (((*buf++) >> 4) & 15);
else
region->bgcolour = (((*buf++) >> 2) & 3);
#ifdef DEBUG
av_log(avctx, AV_LOG_INFO, "Region %d, (%dx%d)\n", region_id, region->width, region->height);
#endif
if (fill) {
memset(region->pbuf, region->bgcolour, region->buf_size);
#ifdef DEBUG
av_log(avctx, AV_LOG_INFO, "Fill region (%d)\n", region->bgcolour);
#endif
delete_region_display_list(ctx, region);
while (buf + 5 < buf_end) {
object_id = AV_RB16(buf);
buf += 2;
object = get_object(ctx, object_id);
if (object == NULL) {
object = av_mallocz(sizeof(DVBSubObject));
object->id = object_id;
object->next = ctx->object_list;
ctx->object_list = object;
object->type = (*buf) >> 6;
display = av_mallocz(sizeof(DVBSubObjectDisplay));
display->object_id = object_id;
display->region_id = region_id;
display->x_pos = AV_RB16(buf) & 0xfff;
buf += 2;
display->y_pos = AV_RB16(buf) & 0xfff;
buf += 2;
if ((object->type == 1 || object->type == 2) && buf+1 < buf_end) {
display->fgcolour = *buf++;
display->bgcolour = *buf++;
display->region_list_next = region->display_list;
region->display_list = display;
display->object_list_next = object->display_list;
object->display_list = display;
| true | FFmpeg | 2867ed9b1c0561b0e50d9c4f73e09621333e2f1f | static void dvbsub_parse_region_segment(AVCodecContext *avctx,
uint8_t *buf, int buf_size)
{
DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data;
uint8_t *buf_end = buf + buf_size;
int region_id, object_id;
DVBSubRegion *region;
DVBSubObject *object;
DVBSubObjectDisplay *display;
int fill;
if (buf_size < 10)
return;
region_id = *buf++;
region = get_region(ctx, region_id);
if (region == NULL)
{
region = av_mallocz(sizeof(DVBSubRegion));
region->id = region_id;
region->next = ctx->region_list;
ctx->region_list = region;
fill = ((*buf++) >> 3) & 1;
region->width = AV_RB16(buf);
buf += 2;
region->height = AV_RB16(buf);
buf += 2;
if (region->width * region->height != region->buf_size) {
if (region->pbuf != 0)
av_free(region->pbuf);
region->buf_size = region->width * region->height;
region->pbuf = av_malloc(region->buf_size);
fill = 1;
region->depth = 1 << (((*buf++) >> 2) & 7);
region->clut = *buf++;
if (region->depth == 8)
region->bgcolour = *buf++;
else {
buf += 1;
if (region->depth == 4)
region->bgcolour = (((*buf++) >> 4) & 15);
else
region->bgcolour = (((*buf++) >> 2) & 3);
#ifdef DEBUG
av_log(avctx, AV_LOG_INFO, "Region %d, (%dx%d)\n", region_id, region->width, region->height);
#endif
if (fill) {
memset(region->pbuf, region->bgcolour, region->buf_size);
#ifdef DEBUG
av_log(avctx, AV_LOG_INFO, "Fill region (%d)\n", region->bgcolour);
#endif
delete_region_display_list(ctx, region);
while (buf + 5 < buf_end) {
object_id = AV_RB16(buf);
buf += 2;
object = get_object(ctx, object_id);
if (object == NULL) {
object = av_mallocz(sizeof(DVBSubObject));
object->id = object_id;
object->next = ctx->object_list;
ctx->object_list = object;
object->type = (*buf) >> 6;
display = av_mallocz(sizeof(DVBSubObjectDisplay));
display->object_id = object_id;
display->region_id = region_id;
display->x_pos = AV_RB16(buf) & 0xfff;
buf += 2;
display->y_pos = AV_RB16(buf) & 0xfff;
buf += 2;
if ((object->type == 1 || object->type == 2) && buf+1 < buf_end) {
display->fgcolour = *buf++;
display->bgcolour = *buf++;
display->region_list_next = region->display_list;
region->display_list = display;
display->object_list_next = object->display_list;
object->display_list = display;
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVCodecContext *VAR_0,
uint8_t *VAR_1, int VAR_2)
{
DVBSubContext *ctx = (DVBSubContext*) VAR_0->priv_data;
uint8_t *buf_end = VAR_1 + VAR_2;
int VAR_3, VAR_4;
DVBSubRegion *region;
DVBSubObject *object;
DVBSubObjectDisplay *display;
int VAR_5;
if (VAR_2 < 10)
return;
VAR_3 = *VAR_1++;
region = get_region(ctx, VAR_3);
if (region == NULL)
{
region = av_mallocz(sizeof(DVBSubRegion));
region->id = VAR_3;
region->next = ctx->region_list;
ctx->region_list = region;
VAR_5 = ((*VAR_1++) >> 3) & 1;
region->width = AV_RB16(VAR_1);
VAR_1 += 2;
region->height = AV_RB16(VAR_1);
VAR_1 += 2;
if (region->width * region->height != region->VAR_2) {
if (region->pbuf != 0)
av_free(region->pbuf);
region->VAR_2 = region->width * region->height;
region->pbuf = av_malloc(region->VAR_2);
VAR_5 = 1;
region->depth = 1 << (((*VAR_1++) >> 2) & 7);
region->clut = *VAR_1++;
if (region->depth == 8)
region->bgcolour = *VAR_1++;
else {
VAR_1 += 1;
if (region->depth == 4)
region->bgcolour = (((*VAR_1++) >> 4) & 15);
else
region->bgcolour = (((*VAR_1++) >> 2) & 3);
#ifdef DEBUG
av_log(VAR_0, AV_LOG_INFO, "Region %d, (%dx%d)\n", VAR_3, region->width, region->height);
#endif
if (VAR_5) {
memset(region->pbuf, region->bgcolour, region->VAR_2);
#ifdef DEBUG
av_log(VAR_0, AV_LOG_INFO, "Fill region (%d)\n", region->bgcolour);
#endif
delete_region_display_list(ctx, region);
while (VAR_1 + 5 < buf_end) {
VAR_4 = AV_RB16(VAR_1);
VAR_1 += 2;
object = get_object(ctx, VAR_4);
if (object == NULL) {
object = av_mallocz(sizeof(DVBSubObject));
object->id = VAR_4;
object->next = ctx->object_list;
ctx->object_list = object;
object->type = (*VAR_1) >> 6;
display = av_mallocz(sizeof(DVBSubObjectDisplay));
display->VAR_4 = VAR_4;
display->VAR_3 = VAR_3;
display->x_pos = AV_RB16(VAR_1) & 0xfff;
VAR_1 += 2;
display->y_pos = AV_RB16(VAR_1) & 0xfff;
VAR_1 += 2;
if ((object->type == 1 || object->type == 2) && VAR_1+1 < buf_end) {
display->fgcolour = *VAR_1++;
display->bgcolour = *VAR_1++;
display->region_list_next = region->display_list;
region->display_list = display;
display->object_list_next = object->display_list;
object->display_list = display;
| [
"static void FUNC_0(AVCodecContext *VAR_0,\nuint8_t *VAR_1, int VAR_2)\n{",
"DVBSubContext *ctx = (DVBSubContext*) VAR_0->priv_data;",
"uint8_t *buf_end = VAR_1 + VAR_2;",
"int VAR_3, VAR_4;",
"DVBSubRegion *region;",
"DVBSubObject *object;",
"DVBSubObjectDisplay *display;",
"int VAR_5;",
"if (VAR_2 < 10)\nreturn;",
"VAR_3 = *VAR_1++;",
"region = get_region(ctx, VAR_3);",
"if (region == NULL)\n{",
"region = av_mallocz(sizeof(DVBSubRegion));",
"region->id = VAR_3;",
"region->next = ctx->region_list;",
"ctx->region_list = region;",
"VAR_5 = ((*VAR_1++) >> 3) & 1;",
"region->width = AV_RB16(VAR_1);",
"VAR_1 += 2;",
"region->height = AV_RB16(VAR_1);",
"VAR_1 += 2;",
"if (region->width * region->height != region->VAR_2) {",
"if (region->pbuf != 0)\nav_free(region->pbuf);",
"region->VAR_2 = region->width * region->height;",
"region->pbuf = av_malloc(region->VAR_2);",
"VAR_5 = 1;",
"region->depth = 1 << (((*VAR_1++) >> 2) & 7);",
"region->clut = *VAR_1++;",
"if (region->depth == 8)\nregion->bgcolour = *VAR_1++;",
"else {",
"VAR_1 += 1;",
"if (region->depth == 4)\nregion->bgcolour = (((*VAR_1++) >> 4) & 15);",
"else\nregion->bgcolour = (((*VAR_1++) >> 2) & 3);",
"#ifdef DEBUG\nav_log(VAR_0, AV_LOG_INFO, \"Region %d, (%dx%d)\\n\", VAR_3, region->width, region->height);",
"#endif\nif (VAR_5) {",
"memset(region->pbuf, region->bgcolour, region->VAR_2);",
"#ifdef DEBUG\nav_log(VAR_0, AV_LOG_INFO, \"Fill region (%d)\\n\", region->bgcolour);",
"#endif\ndelete_region_display_list(ctx, region);",
"while (VAR_1 + 5 < buf_end) {",
"VAR_4 = AV_RB16(VAR_1);",
"VAR_1 += 2;",
"object = get_object(ctx, VAR_4);",
"if (object == NULL) {",
"object = av_mallocz(sizeof(DVBSubObject));",
"object->id = VAR_4;",
"object->next = ctx->object_list;",
"ctx->object_list = object;",
"object->type = (*VAR_1) >> 6;",
"display = av_mallocz(sizeof(DVBSubObjectDisplay));",
"display->VAR_4 = VAR_4;",
"display->VAR_3 = VAR_3;",
"display->x_pos = AV_RB16(VAR_1) & 0xfff;",
"VAR_1 += 2;",
"display->y_pos = AV_RB16(VAR_1) & 0xfff;",
"VAR_1 += 2;",
"if ((object->type == 1 || object->type == 2) && VAR_1+1 < buf_end) {",
"display->fgcolour = *VAR_1++;",
"display->bgcolour = *VAR_1++;",
"display->region_list_next = region->display_list;",
"region->display_list = display;",
"display->object_list_next = object->display_list;",
"object->display_list = display;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25,
27
],
[
31
],
[
35
],
[
39,
41
],
[
43
],
[
47
],
[
51
],
[
53
],
[
58
],
[
62
],
[
64
],
[
66
],
[
68
],
[
72
],
[
74,
76
],
[
80
],
[
84
],
[
88
],
[
93
],
[
99
],
[
103,
105
],
[
107
],
[
109
],
[
113,
115
],
[
117,
119
],
[
124,
126
],
[
128,
132
],
[
134
],
[
136,
138
],
[
140,
145
],
[
149
],
[
151
],
[
153
],
[
157
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
176
],
[
180
],
[
184
],
[
186
],
[
190
],
[
192
],
[
194
],
[
196
],
[
200
],
[
202
],
[
204
],
[
209
],
[
211
],
[
215
],
[
217
]
] |
26,081 | int ff_unlock_avcodec(const AVCodec *codec)
{
if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !codec->init)
return 0;
av_assert0(ff_avcodec_locked);
ff_avcodec_locked = 0;
atomic_fetch_add(&entangled_thread_counter, -1);
if (lockmgr_cb) {
if ((*lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE))
return -1;
}
return 0;
}
| true | FFmpeg | a04c2c707de2ce850f79870e84ac9d7ec7aa9143 | int ff_unlock_avcodec(const AVCodec *codec)
{
if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !codec->init)
return 0;
av_assert0(ff_avcodec_locked);
ff_avcodec_locked = 0;
atomic_fetch_add(&entangled_thread_counter, -1);
if (lockmgr_cb) {
if ((*lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE))
return -1;
}
return 0;
}
| {
"code": [
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" if (lockmgr_cb) {",
" if (lockmgr_cb) {",
" return -1;",
" if (lockmgr_cb) {",
" if ((*lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE))",
" return -1;",
" if (lockmgr_cb) {",
" return -1;",
" return 0;",
" if (lockmgr_cb) {",
" return -1;",
" return 0;"
],
"line_no": [
7,
7,
7,
7,
17,
17,
21,
17,
19,
21,
17,
21,
27,
17,
21,
27
]
} | int FUNC_0(const AVCodec *VAR_0)
{
if (VAR_0->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !VAR_0->init)
return 0;
av_assert0(ff_avcodec_locked);
ff_avcodec_locked = 0;
atomic_fetch_add(&entangled_thread_counter, -1);
if (lockmgr_cb) {
if ((*lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE))
return -1;
}
return 0;
}
| [
"int FUNC_0(const AVCodec *VAR_0)\n{",
"if (VAR_0->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !VAR_0->init)\nreturn 0;",
"av_assert0(ff_avcodec_locked);",
"ff_avcodec_locked = 0;",
"atomic_fetch_add(&entangled_thread_counter, -1);",
"if (lockmgr_cb) {",
"if ((*lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE))\nreturn -1;",
"}",
"return 0;",
"}"
] | [
0,
1,
0,
0,
0,
1,
1,
0,
1,
0
] | [
[
1,
3
],
[
5,
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
27
],
[
29
]
] |
26,082 | static inline void copy(LZOContext *c, int cnt)
{
register const uint8_t *src = c->in;
register uint8_t *dst = c->out;
if (cnt > c->in_end - src) {
cnt = FFMAX(c->in_end - src, 0);
c->error |= AV_LZO_INPUT_DEPLETED;
}
if (cnt > c->out_end - dst) {
cnt = FFMAX(c->out_end - dst, 0);
c->error |= AV_LZO_OUTPUT_FULL;
}
#if defined(INBUF_PADDED) && defined(OUTBUF_PADDED)
AV_COPY32U(dst, src);
src += 4;
dst += 4;
cnt -= 4;
if (cnt > 0)
#endif
memcpy(dst, src, cnt);
c->in = src + cnt;
c->out = dst + cnt;
} | true | FFmpeg | cf2b7c01f81c1fb3283a1390c0ca9a2f81f4f4a8 | static inline void copy(LZOContext *c, int cnt)
{
register const uint8_t *src = c->in;
register uint8_t *dst = c->out;
if (cnt > c->in_end - src) {
cnt = FFMAX(c->in_end - src, 0);
c->error |= AV_LZO_INPUT_DEPLETED;
}
if (cnt > c->out_end - dst) {
cnt = FFMAX(c->out_end - dst, 0);
c->error |= AV_LZO_OUTPUT_FULL;
}
#if defined(INBUF_PADDED) && defined(OUTBUF_PADDED)
AV_COPY32U(dst, src);
src += 4;
dst += 4;
cnt -= 4;
if (cnt > 0)
#endif
memcpy(dst, src, cnt);
c->in = src + cnt;
c->out = dst + cnt;
} | {
"code": [],
"line_no": []
} | static inline void FUNC_0(LZOContext *VAR_0, int VAR_1)
{
register const uint8_t *VAR_2 = VAR_0->in;
register uint8_t *VAR_3 = VAR_0->out;
if (VAR_1 > VAR_0->in_end - VAR_2) {
VAR_1 = FFMAX(VAR_0->in_end - VAR_2, 0);
VAR_0->error |= AV_LZO_INPUT_DEPLETED;
}
if (VAR_1 > VAR_0->out_end - VAR_3) {
VAR_1 = FFMAX(VAR_0->out_end - VAR_3, 0);
VAR_0->error |= AV_LZO_OUTPUT_FULL;
}
#if defined(INBUF_PADDED) && defined(OUTBUF_PADDED)
AV_COPY32U(VAR_3, VAR_2);
VAR_2 += 4;
VAR_3 += 4;
VAR_1 -= 4;
if (VAR_1 > 0)
#endif
memcpy(VAR_3, VAR_2, VAR_1);
VAR_0->in = VAR_2 + VAR_1;
VAR_0->out = VAR_3 + VAR_1;
} | [
"static inline void FUNC_0(LZOContext *VAR_0, int VAR_1)\n{",
"register const uint8_t *VAR_2 = VAR_0->in;",
"register uint8_t *VAR_3 = VAR_0->out;",
"if (VAR_1 > VAR_0->in_end - VAR_2) {",
"VAR_1 = FFMAX(VAR_0->in_end - VAR_2, 0);",
"VAR_0->error |= AV_LZO_INPUT_DEPLETED;",
"}",
"if (VAR_1 > VAR_0->out_end - VAR_3) {",
"VAR_1 = FFMAX(VAR_0->out_end - VAR_3, 0);",
"VAR_0->error |= AV_LZO_OUTPUT_FULL;",
"}",
"#if defined(INBUF_PADDED) && defined(OUTBUF_PADDED)\nAV_COPY32U(VAR_3, VAR_2);",
"VAR_2 += 4;",
"VAR_3 += 4;",
"VAR_1 -= 4;",
"if (VAR_1 > 0)\n#endif\nmemcpy(VAR_3, VAR_2, VAR_1);",
"VAR_0->in = VAR_2 + VAR_1;",
"VAR_0->out = VAR_3 + 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
],
[
10
],
[
12
],
[
14
],
[
16
],
[
18
],
[
20
],
[
22
],
[
24
],
[
26,
28
],
[
30
],
[
32
],
[
34
],
[
36,
38,
40
],
[
42
],
[
44
],
[
46
]
] |
26,083 | static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int size, UID uid)
{
MXFDescriptor *descriptor = arg;
switch(tag) {
case 0x3F01:
descriptor->sub_descriptors_count = avio_rb32(pb);
if (descriptor->sub_descriptors_count >= UINT_MAX / sizeof(UID))
return -1;
descriptor->sub_descriptors_refs = av_malloc(descriptor->sub_descriptors_count * sizeof(UID));
if (!descriptor->sub_descriptors_refs)
return -1;
avio_skip(pb, 4); /* useless size of objects, always 16 according to specs */
avio_read(pb, (uint8_t *)descriptor->sub_descriptors_refs, descriptor->sub_descriptors_count * sizeof(UID));
break;
case 0x3004:
avio_read(pb, descriptor->essence_container_ul, 16);
break;
case 0x3006:
descriptor->linked_track_id = avio_rb32(pb);
break;
case 0x3201: /* PictureEssenceCoding */
avio_read(pb, descriptor->essence_codec_ul, 16);
break;
case 0x3203:
descriptor->width = avio_rb32(pb);
break;
case 0x3202:
descriptor->height = avio_rb32(pb);
break;
case 0x320E:
descriptor->aspect_ratio.num = avio_rb32(pb);
descriptor->aspect_ratio.den = avio_rb32(pb);
break;
case 0x3D03:
descriptor->sample_rate.num = avio_rb32(pb);
descriptor->sample_rate.den = avio_rb32(pb);
break;
case 0x3D06: /* SoundEssenceCompression */
avio_read(pb, descriptor->essence_codec_ul, 16);
break;
case 0x3D07:
descriptor->channels = avio_rb32(pb);
break;
case 0x3D01:
descriptor->bits_per_sample = avio_rb32(pb);
break;
case 0x3401:
mxf_read_pixel_layout(pb, descriptor);
break;
default:
/* Private uid used by SONY C0023S01.mxf */
if (IS_KLV_KEY(uid, mxf_sony_mpeg4_extradata)) {
descriptor->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!descriptor->extradata)
return -1;
descriptor->extradata_size = size;
avio_read(pb, descriptor->extradata, size);
}
break;
}
return 0;
}
| true | FFmpeg | fd34dbea58e097609ff09cf7dcc59f74930195d3 | static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int size, UID uid)
{
MXFDescriptor *descriptor = arg;
switch(tag) {
case 0x3F01:
descriptor->sub_descriptors_count = avio_rb32(pb);
if (descriptor->sub_descriptors_count >= UINT_MAX / sizeof(UID))
return -1;
descriptor->sub_descriptors_refs = av_malloc(descriptor->sub_descriptors_count * sizeof(UID));
if (!descriptor->sub_descriptors_refs)
return -1;
avio_skip(pb, 4);
avio_read(pb, (uint8_t *)descriptor->sub_descriptors_refs, descriptor->sub_descriptors_count * sizeof(UID));
break;
case 0x3004:
avio_read(pb, descriptor->essence_container_ul, 16);
break;
case 0x3006:
descriptor->linked_track_id = avio_rb32(pb);
break;
case 0x3201:
avio_read(pb, descriptor->essence_codec_ul, 16);
break;
case 0x3203:
descriptor->width = avio_rb32(pb);
break;
case 0x3202:
descriptor->height = avio_rb32(pb);
break;
case 0x320E:
descriptor->aspect_ratio.num = avio_rb32(pb);
descriptor->aspect_ratio.den = avio_rb32(pb);
break;
case 0x3D03:
descriptor->sample_rate.num = avio_rb32(pb);
descriptor->sample_rate.den = avio_rb32(pb);
break;
case 0x3D06:
avio_read(pb, descriptor->essence_codec_ul, 16);
break;
case 0x3D07:
descriptor->channels = avio_rb32(pb);
break;
case 0x3D01:
descriptor->bits_per_sample = avio_rb32(pb);
break;
case 0x3401:
mxf_read_pixel_layout(pb, descriptor);
break;
default:
if (IS_KLV_KEY(uid, mxf_sony_mpeg4_extradata)) {
descriptor->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!descriptor->extradata)
return -1;
descriptor->extradata_size = size;
avio_read(pb, descriptor->extradata, size);
}
break;
}
return 0;
}
| {
"code": [
"static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int size, UID uid)"
],
"line_no": [
1
]
} | static int FUNC_0(void *VAR_0, AVIOContext *VAR_1, int VAR_2, int VAR_3, UID VAR_4)
{
MXFDescriptor *descriptor = VAR_0;
switch(VAR_2) {
case 0x3F01:
descriptor->sub_descriptors_count = avio_rb32(VAR_1);
if (descriptor->sub_descriptors_count >= UINT_MAX / sizeof(UID))
return -1;
descriptor->sub_descriptors_refs = av_malloc(descriptor->sub_descriptors_count * sizeof(UID));
if (!descriptor->sub_descriptors_refs)
return -1;
avio_skip(VAR_1, 4);
avio_read(VAR_1, (uint8_t *)descriptor->sub_descriptors_refs, descriptor->sub_descriptors_count * sizeof(UID));
break;
case 0x3004:
avio_read(VAR_1, descriptor->essence_container_ul, 16);
break;
case 0x3006:
descriptor->linked_track_id = avio_rb32(VAR_1);
break;
case 0x3201:
avio_read(VAR_1, descriptor->essence_codec_ul, 16);
break;
case 0x3203:
descriptor->width = avio_rb32(VAR_1);
break;
case 0x3202:
descriptor->height = avio_rb32(VAR_1);
break;
case 0x320E:
descriptor->aspect_ratio.num = avio_rb32(VAR_1);
descriptor->aspect_ratio.den = avio_rb32(VAR_1);
break;
case 0x3D03:
descriptor->sample_rate.num = avio_rb32(VAR_1);
descriptor->sample_rate.den = avio_rb32(VAR_1);
break;
case 0x3D06:
avio_read(VAR_1, descriptor->essence_codec_ul, 16);
break;
case 0x3D07:
descriptor->channels = avio_rb32(VAR_1);
break;
case 0x3D01:
descriptor->bits_per_sample = avio_rb32(VAR_1);
break;
case 0x3401:
mxf_read_pixel_layout(VAR_1, descriptor);
break;
default:
if (IS_KLV_KEY(VAR_4, mxf_sony_mpeg4_extradata)) {
descriptor->extradata = av_malloc(VAR_3 + FF_INPUT_BUFFER_PADDING_SIZE);
if (!descriptor->extradata)
return -1;
descriptor->extradata_size = VAR_3;
avio_read(VAR_1, descriptor->extradata, VAR_3);
}
break;
}
return 0;
}
| [
"static int FUNC_0(void *VAR_0, AVIOContext *VAR_1, int VAR_2, int VAR_3, UID VAR_4)\n{",
"MXFDescriptor *descriptor = VAR_0;",
"switch(VAR_2) {",
"case 0x3F01:\ndescriptor->sub_descriptors_count = avio_rb32(VAR_1);",
"if (descriptor->sub_descriptors_count >= UINT_MAX / sizeof(UID))\nreturn -1;",
"descriptor->sub_descriptors_refs = av_malloc(descriptor->sub_descriptors_count * sizeof(UID));",
"if (!descriptor->sub_descriptors_refs)\nreturn -1;",
"avio_skip(VAR_1, 4);",
"avio_read(VAR_1, (uint8_t *)descriptor->sub_descriptors_refs, descriptor->sub_descriptors_count * sizeof(UID));",
"break;",
"case 0x3004:\navio_read(VAR_1, descriptor->essence_container_ul, 16);",
"break;",
"case 0x3006:\ndescriptor->linked_track_id = avio_rb32(VAR_1);",
"break;",
"case 0x3201:\navio_read(VAR_1, descriptor->essence_codec_ul, 16);",
"break;",
"case 0x3203:\ndescriptor->width = avio_rb32(VAR_1);",
"break;",
"case 0x3202:\ndescriptor->height = avio_rb32(VAR_1);",
"break;",
"case 0x320E:\ndescriptor->aspect_ratio.num = avio_rb32(VAR_1);",
"descriptor->aspect_ratio.den = avio_rb32(VAR_1);",
"break;",
"case 0x3D03:\ndescriptor->sample_rate.num = avio_rb32(VAR_1);",
"descriptor->sample_rate.den = avio_rb32(VAR_1);",
"break;",
"case 0x3D06:\navio_read(VAR_1, descriptor->essence_codec_ul, 16);",
"break;",
"case 0x3D07:\ndescriptor->channels = avio_rb32(VAR_1);",
"break;",
"case 0x3D01:\ndescriptor->bits_per_sample = avio_rb32(VAR_1);",
"break;",
"case 0x3401:\nmxf_read_pixel_layout(VAR_1, descriptor);",
"break;",
"default:\nif (IS_KLV_KEY(VAR_4, mxf_sony_mpeg4_extradata)) {",
"descriptor->extradata = av_malloc(VAR_3 + FF_INPUT_BUFFER_PADDING_SIZE);",
"if (!descriptor->extradata)\nreturn -1;",
"descriptor->extradata_size = VAR_3;",
"avio_read(VAR_1, descriptor->extradata, VAR_3);",
"}",
"break;",
"}",
"return 0;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
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,
103
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
]
] |
26,084 | static int fir_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs)
{
AudioFIRContext *s = ctx->priv;
const float *src = (const float *)s->in[0]->extended_data[ch];
int index1 = (s->index + 1) % 3;
int index2 = (s->index + 2) % 3;
float *sum = s->sum[ch];
AVFrame *out = arg;
float *block;
float *dst;
int n, i, j;
memset(sum, 0, sizeof(*sum) * s->fft_length);
block = s->block[ch] + s->part_index * s->block_size;
memset(block, 0, sizeof(*block) * s->fft_length);
s->fdsp->vector_fmul_scalar(block + s->part_size, src, s->dry_gain, s->nb_samples);
emms_c();
av_rdft_calc(s->rdft[ch], block);
block[2 * s->part_size] = block[1];
block[1] = 0;
j = s->part_index;
for (i = 0; i < s->nb_partitions; i++) {
const int coffset = i * s->coeff_size;
const FFTComplex *coeff = s->coeff[ch * !s->one2many] + coffset;
block = s->block[ch] + j * s->block_size;
s->fcmul_add(sum, block, (const float *)coeff, s->part_size);
if (j == 0)
j = s->nb_partitions;
j--;
}
sum[1] = sum[2 * s->part_size];
av_rdft_calc(s->irdft[ch], sum);
dst = (float *)s->buffer->extended_data[ch] + index1 * s->part_size;
for (n = 0; n < s->part_size; n++) {
dst[n] += sum[n];
}
dst = (float *)s->buffer->extended_data[ch] + index2 * s->part_size;
memcpy(dst, sum + s->part_size, s->part_size * sizeof(*dst));
dst = (float *)s->buffer->extended_data[ch] + s->index * s->part_size;
if (out) {
float *ptr = (float *)out->extended_data[ch];
s->fdsp->vector_fmul_scalar(ptr, dst, s->gain * s->wet_gain, out->nb_samples);
emms_c();
}
return 0;
}
| false | FFmpeg | bd404e3949b081788247e2e6e9df0581ef7cc190 | static int fir_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs)
{
AudioFIRContext *s = ctx->priv;
const float *src = (const float *)s->in[0]->extended_data[ch];
int index1 = (s->index + 1) % 3;
int index2 = (s->index + 2) % 3;
float *sum = s->sum[ch];
AVFrame *out = arg;
float *block;
float *dst;
int n, i, j;
memset(sum, 0, sizeof(*sum) * s->fft_length);
block = s->block[ch] + s->part_index * s->block_size;
memset(block, 0, sizeof(*block) * s->fft_length);
s->fdsp->vector_fmul_scalar(block + s->part_size, src, s->dry_gain, s->nb_samples);
emms_c();
av_rdft_calc(s->rdft[ch], block);
block[2 * s->part_size] = block[1];
block[1] = 0;
j = s->part_index;
for (i = 0; i < s->nb_partitions; i++) {
const int coffset = i * s->coeff_size;
const FFTComplex *coeff = s->coeff[ch * !s->one2many] + coffset;
block = s->block[ch] + j * s->block_size;
s->fcmul_add(sum, block, (const float *)coeff, s->part_size);
if (j == 0)
j = s->nb_partitions;
j--;
}
sum[1] = sum[2 * s->part_size];
av_rdft_calc(s->irdft[ch], sum);
dst = (float *)s->buffer->extended_data[ch] + index1 * s->part_size;
for (n = 0; n < s->part_size; n++) {
dst[n] += sum[n];
}
dst = (float *)s->buffer->extended_data[ch] + index2 * s->part_size;
memcpy(dst, sum + s->part_size, s->part_size * sizeof(*dst));
dst = (float *)s->buffer->extended_data[ch] + s->index * s->part_size;
if (out) {
float *ptr = (float *)out->extended_data[ch];
s->fdsp->vector_fmul_scalar(ptr, dst, s->gain * s->wet_gain, out->nb_samples);
emms_c();
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFilterContext *VAR_0, void *VAR_1, int VAR_2, int VAR_3)
{
AudioFIRContext *s = VAR_0->priv;
const float *VAR_4 = (const float *)s->in[0]->extended_data[VAR_2];
int VAR_5 = (s->index + 1) % 3;
int VAR_6 = (s->index + 2) % 3;
float *VAR_7 = s->VAR_7[VAR_2];
AVFrame *out = VAR_1;
float *VAR_8;
float *VAR_9;
int VAR_10, VAR_11, VAR_12;
memset(VAR_7, 0, sizeof(*VAR_7) * s->fft_length);
VAR_8 = s->VAR_8[VAR_2] + s->part_index * s->block_size;
memset(VAR_8, 0, sizeof(*VAR_8) * s->fft_length);
s->fdsp->vector_fmul_scalar(VAR_8 + s->part_size, VAR_4, s->dry_gain, s->nb_samples);
emms_c();
av_rdft_calc(s->rdft[VAR_2], VAR_8);
VAR_8[2 * s->part_size] = VAR_8[1];
VAR_8[1] = 0;
VAR_12 = s->part_index;
for (VAR_11 = 0; VAR_11 < s->nb_partitions; VAR_11++) {
const int coffset = VAR_11 * s->coeff_size;
const FFTComplex *coeff = s->coeff[VAR_2 * !s->one2many] + coffset;
VAR_8 = s->VAR_8[VAR_2] + VAR_12 * s->block_size;
s->fcmul_add(VAR_7, VAR_8, (const float *)coeff, s->part_size);
if (VAR_12 == 0)
VAR_12 = s->nb_partitions;
VAR_12--;
}
VAR_7[1] = VAR_7[2 * s->part_size];
av_rdft_calc(s->irdft[VAR_2], VAR_7);
VAR_9 = (float *)s->buffer->extended_data[VAR_2] + VAR_5 * s->part_size;
for (VAR_10 = 0; VAR_10 < s->part_size; VAR_10++) {
VAR_9[VAR_10] += VAR_7[VAR_10];
}
VAR_9 = (float *)s->buffer->extended_data[VAR_2] + VAR_6 * s->part_size;
memcpy(VAR_9, VAR_7 + s->part_size, s->part_size * sizeof(*VAR_9));
VAR_9 = (float *)s->buffer->extended_data[VAR_2] + s->index * s->part_size;
if (out) {
float *VAR_13 = (float *)out->extended_data[VAR_2];
s->fdsp->vector_fmul_scalar(VAR_13, VAR_9, s->gain * s->wet_gain, out->nb_samples);
emms_c();
}
return 0;
}
| [
"static int FUNC_0(AVFilterContext *VAR_0, void *VAR_1, int VAR_2, int VAR_3)\n{",
"AudioFIRContext *s = VAR_0->priv;",
"const float *VAR_4 = (const float *)s->in[0]->extended_data[VAR_2];",
"int VAR_5 = (s->index + 1) % 3;",
"int VAR_6 = (s->index + 2) % 3;",
"float *VAR_7 = s->VAR_7[VAR_2];",
"AVFrame *out = VAR_1;",
"float *VAR_8;",
"float *VAR_9;",
"int VAR_10, VAR_11, VAR_12;",
"memset(VAR_7, 0, sizeof(*VAR_7) * s->fft_length);",
"VAR_8 = s->VAR_8[VAR_2] + s->part_index * s->block_size;",
"memset(VAR_8, 0, sizeof(*VAR_8) * s->fft_length);",
"s->fdsp->vector_fmul_scalar(VAR_8 + s->part_size, VAR_4, s->dry_gain, s->nb_samples);",
"emms_c();",
"av_rdft_calc(s->rdft[VAR_2], VAR_8);",
"VAR_8[2 * s->part_size] = VAR_8[1];",
"VAR_8[1] = 0;",
"VAR_12 = s->part_index;",
"for (VAR_11 = 0; VAR_11 < s->nb_partitions; VAR_11++) {",
"const int coffset = VAR_11 * s->coeff_size;",
"const FFTComplex *coeff = s->coeff[VAR_2 * !s->one2many] + coffset;",
"VAR_8 = s->VAR_8[VAR_2] + VAR_12 * s->block_size;",
"s->fcmul_add(VAR_7, VAR_8, (const float *)coeff, s->part_size);",
"if (VAR_12 == 0)\nVAR_12 = s->nb_partitions;",
"VAR_12--;",
"}",
"VAR_7[1] = VAR_7[2 * s->part_size];",
"av_rdft_calc(s->irdft[VAR_2], VAR_7);",
"VAR_9 = (float *)s->buffer->extended_data[VAR_2] + VAR_5 * s->part_size;",
"for (VAR_10 = 0; VAR_10 < s->part_size; VAR_10++) {",
"VAR_9[VAR_10] += VAR_7[VAR_10];",
"}",
"VAR_9 = (float *)s->buffer->extended_data[VAR_2] + VAR_6 * s->part_size;",
"memcpy(VAR_9, VAR_7 + s->part_size, s->part_size * sizeof(*VAR_9));",
"VAR_9 = (float *)s->buffer->extended_data[VAR_2] + s->index * s->part_size;",
"if (out) {",
"float *VAR_13 = (float *)out->extended_data[VAR_2];",
"s->fdsp->vector_fmul_scalar(VAR_13, VAR_9, s->gain * s->wet_gain, out->nb_samples);",
"emms_c();",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
47
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
65,
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
95
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
]
] |
26,085 | static int aiff_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
AVStream *st = s->streams[0];
AIFFInputContext *aiff = s->priv_data;
int64_t max_size;
int res, size;
/* calculate size of remaining data */
max_size = aiff->data_end - avio_tell(s->pb);
if (max_size <= 0)
return AVERROR_EOF;
/* Now for that packet */
if (st->codec->block_align >= 17) // GSM, QCLP, IMA4
size = st->codec->block_align;
else
size = (MAX_SIZE / st->codec->block_align) * st->codec->block_align;
size = FFMIN(max_size, size);
res = av_get_packet(s->pb, pkt, size);
if (res < 0)
return res;
if (size >= st->codec->block_align)
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
/* Only one stream in an AIFF file */
pkt->stream_index = 0;
pkt->duration = (res / st->codec->block_align) * aiff->block_duration;
return 0;
}
| false | FFmpeg | 763e714442e07f6430b003c8a9f4b62deaa7b3a5 | static int aiff_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
AVStream *st = s->streams[0];
AIFFInputContext *aiff = s->priv_data;
int64_t max_size;
int res, size;
max_size = aiff->data_end - avio_tell(s->pb);
if (max_size <= 0)
return AVERROR_EOF;
if (st->codec->block_align >= 17)
size = st->codec->block_align;
else
size = (MAX_SIZE / st->codec->block_align) * st->codec->block_align;
size = FFMIN(max_size, size);
res = av_get_packet(s->pb, pkt, size);
if (res < 0)
return res;
if (size >= st->codec->block_align)
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
pkt->stream_index = 0;
pkt->duration = (res / st->codec->block_align) * aiff->block_duration;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0,
AVPacket *VAR_1)
{
AVStream *st = VAR_0->streams[0];
AIFFInputContext *aiff = VAR_0->priv_data;
int64_t max_size;
int VAR_2, VAR_3;
max_size = aiff->data_end - avio_tell(VAR_0->pb);
if (max_size <= 0)
return AVERROR_EOF;
if (st->codec->block_align >= 17)
VAR_3 = st->codec->block_align;
else
VAR_3 = (MAX_SIZE / st->codec->block_align) * st->codec->block_align;
VAR_3 = FFMIN(max_size, VAR_3);
VAR_2 = av_get_packet(VAR_0->pb, VAR_1, VAR_3);
if (VAR_2 < 0)
return VAR_2;
if (VAR_3 >= st->codec->block_align)
VAR_1->flags &= ~AV_PKT_FLAG_CORRUPT;
VAR_1->stream_index = 0;
VAR_1->duration = (VAR_2 / st->codec->block_align) * aiff->block_duration;
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0,\nAVPacket *VAR_1)\n{",
"AVStream *st = VAR_0->streams[0];",
"AIFFInputContext *aiff = VAR_0->priv_data;",
"int64_t max_size;",
"int VAR_2, VAR_3;",
"max_size = aiff->data_end - avio_tell(VAR_0->pb);",
"if (max_size <= 0)\nreturn AVERROR_EOF;",
"if (st->codec->block_align >= 17)\nVAR_3 = st->codec->block_align;",
"else\nVAR_3 = (MAX_SIZE / st->codec->block_align) * st->codec->block_align;",
"VAR_3 = FFMIN(max_size, VAR_3);",
"VAR_2 = av_get_packet(VAR_0->pb, VAR_1, VAR_3);",
"if (VAR_2 < 0)\nreturn VAR_2;",
"if (VAR_3 >= st->codec->block_align)\nVAR_1->flags &= ~AV_PKT_FLAG_CORRUPT;",
"VAR_1->stream_index = 0;",
"VAR_1->duration = (VAR_2 / st->codec->block_align) * aiff->block_duration;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
19
],
[
21,
23
],
[
29,
31
],
[
33,
35
],
[
37
],
[
39
],
[
41,
43
],
[
47,
49
],
[
53
],
[
55
],
[
57
],
[
59
]
] |
26,086 | static int get_riff(AVFormatContext *s, AVIOContext *pb)
{
AVIContext *avi = s->priv_data;
char header[8];
int i;
/* check RIFF header */
avio_read(pb, header, 4);
avi->riff_end = avio_rl32(pb); /* RIFF chunk size */
avi->riff_end += avio_tell(pb); /* RIFF chunk end */
avio_read(pb, header + 4, 4);
for (i = 0; avi_headers[i][0]; i++)
if (!memcmp(header, avi_headers[i], 8))
break;
if (!avi_headers[i][0])
return AVERROR_INVALIDDATA;
if (header[7] == 0x19)
av_log(s, AV_LOG_INFO,
"This file has been generated by a totally broken muxer.\n");
return 0;
}
| true | FFmpeg | 8a048fe6f8bf41de93c091a7a9b3132bedc1b41c | static int get_riff(AVFormatContext *s, AVIOContext *pb)
{
AVIContext *avi = s->priv_data;
char header[8];
int i;
avio_read(pb, header, 4);
avi->riff_end = avio_rl32(pb);
avi->riff_end += avio_tell(pb);
avio_read(pb, header + 4, 4);
for (i = 0; avi_headers[i][0]; i++)
if (!memcmp(header, avi_headers[i], 8))
break;
if (!avi_headers[i][0])
return AVERROR_INVALIDDATA;
if (header[7] == 0x19)
av_log(s, AV_LOG_INFO,
"This file has been generated by a totally broken muxer.\n");
return 0;
}
| {
"code": [
" char header[8];"
],
"line_no": [
7
]
} | static int FUNC_0(AVFormatContext *VAR_0, AVIOContext *VAR_1)
{
AVIContext *avi = VAR_0->priv_data;
char VAR_2[8];
int VAR_3;
avio_read(VAR_1, VAR_2, 4);
avi->riff_end = avio_rl32(VAR_1);
avi->riff_end += avio_tell(VAR_1);
avio_read(VAR_1, VAR_2 + 4, 4);
for (VAR_3 = 0; avi_headers[VAR_3][0]; VAR_3++)
if (!memcmp(VAR_2, avi_headers[VAR_3], 8))
break;
if (!avi_headers[VAR_3][0])
return AVERROR_INVALIDDATA;
if (VAR_2[7] == 0x19)
av_log(VAR_0, AV_LOG_INFO,
"This file has been generated by a totally broken muxer.\n");
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVIOContext *VAR_1)\n{",
"AVIContext *avi = VAR_0->priv_data;",
"char VAR_2[8];",
"int VAR_3;",
"avio_read(VAR_1, VAR_2, 4);",
"avi->riff_end = avio_rl32(VAR_1);",
"avi->riff_end += avio_tell(VAR_1);",
"avio_read(VAR_1, VAR_2 + 4, 4);",
"for (VAR_3 = 0; avi_headers[VAR_3][0]; VAR_3++)",
"if (!memcmp(VAR_2, avi_headers[VAR_3], 8))\nbreak;",
"if (!avi_headers[VAR_3][0])\nreturn AVERROR_INVALIDDATA;",
"if (VAR_2[7] == 0x19)\nav_log(VAR_0, AV_LOG_INFO,\n\"This file has been generated by a totally broken muxer.\\n\");",
"return 0;",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27,
29
],
[
31,
33
],
[
37,
39,
41
],
[
45
],
[
47
]
] |
26,088 | static int decode_segment(TAKDecContext *s, int8_t mode, int32_t *decoded, int len)
{
struct CParam code;
GetBitContext *gb = &s->gb;
int i;
if (!mode) {
memset(decoded, 0, len * sizeof(*decoded));
return 0;
}
if (mode > FF_ARRAY_ELEMS(xcodes))
return AVERROR_INVALIDDATA;
code = xcodes[mode - 1];
for (i = 0; i < len; i++) {
int x = get_bits_long(gb, code.init);
if (x >= code.escape && get_bits1(gb)) {
x |= 1 << code.init;
if (x >= code.aescape) {
int scale = get_unary(gb, 1, 9);
if (scale == 9) {
int scale_bits = get_bits(gb, 3);
if (scale_bits > 0) {
if (scale_bits == 7) {
scale_bits += get_bits(gb, 5);
if (scale_bits > 29)
return AVERROR_INVALIDDATA;
}
scale = get_bits_long(gb, scale_bits) + 1;
x += code.scale * scale;
}
x += code.bias;
} else
x += code.scale * scale - code.escape;
} else
x -= code.escape;
}
decoded[i] = (x >> 1) ^ -(x & 1);
}
return 0;
}
| true | FFmpeg | 955db411929a9876d3cd016fbbb9c49b6362feba | static int decode_segment(TAKDecContext *s, int8_t mode, int32_t *decoded, int len)
{
struct CParam code;
GetBitContext *gb = &s->gb;
int i;
if (!mode) {
memset(decoded, 0, len * sizeof(*decoded));
return 0;
}
if (mode > FF_ARRAY_ELEMS(xcodes))
return AVERROR_INVALIDDATA;
code = xcodes[mode - 1];
for (i = 0; i < len; i++) {
int x = get_bits_long(gb, code.init);
if (x >= code.escape && get_bits1(gb)) {
x |= 1 << code.init;
if (x >= code.aescape) {
int scale = get_unary(gb, 1, 9);
if (scale == 9) {
int scale_bits = get_bits(gb, 3);
if (scale_bits > 0) {
if (scale_bits == 7) {
scale_bits += get_bits(gb, 5);
if (scale_bits > 29)
return AVERROR_INVALIDDATA;
}
scale = get_bits_long(gb, scale_bits) + 1;
x += code.scale * scale;
}
x += code.bias;
} else
x += code.scale * scale - code.escape;
} else
x -= code.escape;
}
decoded[i] = (x >> 1) ^ -(x & 1);
}
return 0;
}
| {
"code": [
" int x = get_bits_long(gb, code.init);",
" int scale = get_unary(gb, 1, 9);"
],
"line_no": [
33,
41
]
} | static int FUNC_0(TAKDecContext *VAR_0, int8_t VAR_1, int32_t *VAR_2, int VAR_3)
{
struct CParam VAR_4;
GetBitContext *gb = &VAR_0->gb;
int VAR_5;
if (!VAR_1) {
memset(VAR_2, 0, VAR_3 * sizeof(*VAR_2));
return 0;
}
if (VAR_1 > FF_ARRAY_ELEMS(xcodes))
return AVERROR_INVALIDDATA;
VAR_4 = xcodes[VAR_1 - 1];
for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++) {
int VAR_6 = get_bits_long(gb, VAR_4.init);
if (VAR_6 >= VAR_4.escape && get_bits1(gb)) {
VAR_6 |= 1 << VAR_4.init;
if (VAR_6 >= VAR_4.aescape) {
int VAR_7 = get_unary(gb, 1, 9);
if (VAR_7 == 9) {
int VAR_8 = get_bits(gb, 3);
if (VAR_8 > 0) {
if (VAR_8 == 7) {
VAR_8 += get_bits(gb, 5);
if (VAR_8 > 29)
return AVERROR_INVALIDDATA;
}
VAR_7 = get_bits_long(gb, VAR_8) + 1;
VAR_6 += VAR_4.VAR_7 * VAR_7;
}
VAR_6 += VAR_4.bias;
} else
VAR_6 += VAR_4.VAR_7 * VAR_7 - VAR_4.escape;
} else
VAR_6 -= VAR_4.escape;
}
VAR_2[VAR_5] = (VAR_6 >> 1) ^ -(VAR_6 & 1);
}
return 0;
}
| [
"static int FUNC_0(TAKDecContext *VAR_0, int8_t VAR_1, int32_t *VAR_2, int VAR_3)\n{",
"struct CParam VAR_4;",
"GetBitContext *gb = &VAR_0->gb;",
"int VAR_5;",
"if (!VAR_1) {",
"memset(VAR_2, 0, VAR_3 * sizeof(*VAR_2));",
"return 0;",
"}",
"if (VAR_1 > FF_ARRAY_ELEMS(xcodes))\nreturn AVERROR_INVALIDDATA;",
"VAR_4 = xcodes[VAR_1 - 1];",
"for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++) {",
"int VAR_6 = get_bits_long(gb, VAR_4.init);",
"if (VAR_6 >= VAR_4.escape && get_bits1(gb)) {",
"VAR_6 |= 1 << VAR_4.init;",
"if (VAR_6 >= VAR_4.aescape) {",
"int VAR_7 = get_unary(gb, 1, 9);",
"if (VAR_7 == 9) {",
"int VAR_8 = get_bits(gb, 3);",
"if (VAR_8 > 0) {",
"if (VAR_8 == 7) {",
"VAR_8 += get_bits(gb, 5);",
"if (VAR_8 > 29)\nreturn AVERROR_INVALIDDATA;",
"}",
"VAR_7 = get_bits_long(gb, VAR_8) + 1;",
"VAR_6 += VAR_4.VAR_7 * VAR_7;",
"}",
"VAR_6 += VAR_4.bias;",
"} else",
"VAR_6 += VAR_4.VAR_7 * VAR_7 - VAR_4.escape;",
"} else",
"VAR_6 -= VAR_4.escape;",
"}",
"VAR_2[VAR_5] = (VAR_6 >> 1) ^ -(VAR_6 & 1);",
"}",
"return 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,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23,
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
]
] |
26,089 | static int paf_video_decode(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *pkt)
{
PAFVideoDecContext *c = avctx->priv_data;
uint8_t code, *dst, *end;
int i, frame, ret;
if (pkt->size < 2)
return AVERROR_INVALIDDATA;
bytestream2_init(&c->gb, pkt->data, pkt->size);
code = bytestream2_get_byte(&c->gb);
if ((code & 0xF) > 4) {
avpriv_request_sample(avctx, "unknown/invalid code");
return AVERROR_INVALIDDATA;
}
if ((ret = ff_reget_buffer(avctx, c->pic)) < 0)
return ret;
if (code & 0x20) { // frame is keyframe
for (i = 0; i < 4; i++)
memset(c->frame[i], 0, c->frame_size);
memset(c->pic->data[1], 0, AVPALETTE_SIZE);
c->current_frame = 0;
c->pic->key_frame = 1;
c->pic->pict_type = AV_PICTURE_TYPE_I;
} else {
c->pic->key_frame = 0;
c->pic->pict_type = AV_PICTURE_TYPE_P;
}
if (code & 0x40) { // palette update
uint32_t *out = (uint32_t *)c->pic->data[1];
int index, count;
index = bytestream2_get_byte(&c->gb);
count = bytestream2_get_byte(&c->gb) + 1;
if (index + count > 256)
return AVERROR_INVALIDDATA;
if (bytestream2_get_bytes_left(&c->gb) < 3 * count)
return AVERROR_INVALIDDATA;
out += index;
for (i = 0; i < count; i++) {
unsigned r, g, b;
r = bytestream2_get_byteu(&c->gb);
r = r << 2 | r >> 4;
g = bytestream2_get_byteu(&c->gb);
g = g << 2 | g >> 4;
b = bytestream2_get_byteu(&c->gb);
b = b << 2 | b >> 4;
*out++ = (0xFFU << 24) | (r << 16) | (g << 8) | b;
}
c->pic->palette_has_changed = 1;
}
switch (code & 0x0F) {
case 0:
/* Block-based motion compensation using 4x4 blocks with either
* horizontal or vertical vectors; might incorporate VQ as well. */
if ((ret = decode_0(c, pkt->data, code)) < 0)
return ret;
break;
case 1:
/* Uncompressed data. This mode specifies that (width * height) bytes
* should be copied directly from the encoded buffer into the output. */
dst = c->frame[c->current_frame];
// possibly chunk length data
bytestream2_skip(&c->gb, 2);
if (bytestream2_get_bytes_left(&c->gb) < c->video_size)
return AVERROR_INVALIDDATA;
bytestream2_get_bufferu(&c->gb, dst, c->video_size);
break;
case 2:
/* Copy reference frame: Consume the next byte in the stream as the
* reference frame (which should be 0, 1, 2, or 3, and should not be
* the same as the current frame number). */
frame = bytestream2_get_byte(&c->gb);
if (frame > 3)
return AVERROR_INVALIDDATA;
if (frame != c->current_frame)
memcpy(c->frame[c->current_frame], c->frame[frame], c->frame_size);
break;
case 4:
/* Run length encoding.*/
dst = c->frame[c->current_frame];
end = dst + c->video_size;
bytestream2_skip(&c->gb, 2);
while (dst < end) {
int8_t code;
int count;
if (bytestream2_get_bytes_left(&c->gb) < 2)
return AVERROR_INVALIDDATA;
code = bytestream2_get_byteu(&c->gb);
count = FFABS(code) + 1;
if (dst + count > end)
return AVERROR_INVALIDDATA;
if (code < 0)
memset(dst, bytestream2_get_byteu(&c->gb), count);
else
bytestream2_get_buffer(&c->gb, dst, count);
dst += count;
}
break;
default:
av_assert0(0);
}
av_image_copy_plane(c->pic->data[0], c->pic->linesize[0],
c->frame[c->current_frame], c->width,
c->width, c->height);
c->current_frame = (c->current_frame + 1) & 3;
if ((ret = av_frame_ref(data, c->pic)) < 0)
return ret;
*got_frame = 1;
return pkt->size;
}
| true | FFmpeg | c4360559ee2a6c8c624f24fc7e2a1cf00972ba68 | static int paf_video_decode(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *pkt)
{
PAFVideoDecContext *c = avctx->priv_data;
uint8_t code, *dst, *end;
int i, frame, ret;
if (pkt->size < 2)
return AVERROR_INVALIDDATA;
bytestream2_init(&c->gb, pkt->data, pkt->size);
code = bytestream2_get_byte(&c->gb);
if ((code & 0xF) > 4) {
avpriv_request_sample(avctx, "unknown/invalid code");
return AVERROR_INVALIDDATA;
}
if ((ret = ff_reget_buffer(avctx, c->pic)) < 0)
return ret;
if (code & 0x20) {
for (i = 0; i < 4; i++)
memset(c->frame[i], 0, c->frame_size);
memset(c->pic->data[1], 0, AVPALETTE_SIZE);
c->current_frame = 0;
c->pic->key_frame = 1;
c->pic->pict_type = AV_PICTURE_TYPE_I;
} else {
c->pic->key_frame = 0;
c->pic->pict_type = AV_PICTURE_TYPE_P;
}
if (code & 0x40) {
uint32_t *out = (uint32_t *)c->pic->data[1];
int index, count;
index = bytestream2_get_byte(&c->gb);
count = bytestream2_get_byte(&c->gb) + 1;
if (index + count > 256)
return AVERROR_INVALIDDATA;
if (bytestream2_get_bytes_left(&c->gb) < 3 * count)
return AVERROR_INVALIDDATA;
out += index;
for (i = 0; i < count; i++) {
unsigned r, g, b;
r = bytestream2_get_byteu(&c->gb);
r = r << 2 | r >> 4;
g = bytestream2_get_byteu(&c->gb);
g = g << 2 | g >> 4;
b = bytestream2_get_byteu(&c->gb);
b = b << 2 | b >> 4;
*out++ = (0xFFU << 24) | (r << 16) | (g << 8) | b;
}
c->pic->palette_has_changed = 1;
}
switch (code & 0x0F) {
case 0:
if ((ret = decode_0(c, pkt->data, code)) < 0)
return ret;
break;
case 1:
dst = c->frame[c->current_frame];
bytestream2_skip(&c->gb, 2);
if (bytestream2_get_bytes_left(&c->gb) < c->video_size)
return AVERROR_INVALIDDATA;
bytestream2_get_bufferu(&c->gb, dst, c->video_size);
break;
case 2:
frame = bytestream2_get_byte(&c->gb);
if (frame > 3)
return AVERROR_INVALIDDATA;
if (frame != c->current_frame)
memcpy(c->frame[c->current_frame], c->frame[frame], c->frame_size);
break;
case 4:
dst = c->frame[c->current_frame];
end = dst + c->video_size;
bytestream2_skip(&c->gb, 2);
while (dst < end) {
int8_t code;
int count;
if (bytestream2_get_bytes_left(&c->gb) < 2)
return AVERROR_INVALIDDATA;
code = bytestream2_get_byteu(&c->gb);
count = FFABS(code) + 1;
if (dst + count > end)
return AVERROR_INVALIDDATA;
if (code < 0)
memset(dst, bytestream2_get_byteu(&c->gb), count);
else
bytestream2_get_buffer(&c->gb, dst, count);
dst += count;
}
break;
default:
av_assert0(0);
}
av_image_copy_plane(c->pic->data[0], c->pic->linesize[0],
c->frame[c->current_frame], c->width,
c->width, c->height);
c->current_frame = (c->current_frame + 1) & 3;
if ((ret = av_frame_ref(data, c->pic)) < 0)
return ret;
*got_frame = 1;
return pkt->size;
}
| {
"code": [
" if ((code & 0xF) > 4) {"
],
"line_no": [
27
]
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{
PAFVideoDecContext *c = VAR_0->priv_data;
uint8_t code, *dst, *end;
int VAR_4, VAR_5, VAR_6;
if (VAR_3->size < 2)
return AVERROR_INVALIDDATA;
bytestream2_init(&c->gb, VAR_3->VAR_1, VAR_3->size);
code = bytestream2_get_byte(&c->gb);
if ((code & 0xF) > 4) {
avpriv_request_sample(VAR_0, "unknown/invalid code");
return AVERROR_INVALIDDATA;
}
if ((VAR_6 = ff_reget_buffer(VAR_0, c->pic)) < 0)
return VAR_6;
if (code & 0x20) {
for (VAR_4 = 0; VAR_4 < 4; VAR_4++)
memset(c->VAR_5[VAR_4], 0, c->frame_size);
memset(c->pic->VAR_1[1], 0, AVPALETTE_SIZE);
c->current_frame = 0;
c->pic->key_frame = 1;
c->pic->pict_type = AV_PICTURE_TYPE_I;
} else {
c->pic->key_frame = 0;
c->pic->pict_type = AV_PICTURE_TYPE_P;
}
if (code & 0x40) {
uint32_t *out = (uint32_t *)c->pic->VAR_1[1];
int VAR_7, VAR_12;
VAR_7 = bytestream2_get_byte(&c->gb);
VAR_12 = bytestream2_get_byte(&c->gb) + 1;
if (VAR_7 + VAR_12 > 256)
return AVERROR_INVALIDDATA;
if (bytestream2_get_bytes_left(&c->gb) < 3 * VAR_12)
return AVERROR_INVALIDDATA;
out += VAR_7;
for (VAR_4 = 0; VAR_4 < VAR_12; VAR_4++) {
unsigned VAR_9, VAR_10, VAR_11;
VAR_9 = bytestream2_get_byteu(&c->gb);
VAR_9 = VAR_9 << 2 | VAR_9 >> 4;
VAR_10 = bytestream2_get_byteu(&c->gb);
VAR_10 = VAR_10 << 2 | VAR_10 >> 4;
VAR_11 = bytestream2_get_byteu(&c->gb);
VAR_11 = VAR_11 << 2 | VAR_11 >> 4;
*out++ = (0xFFU << 24) | (VAR_9 << 16) | (VAR_10 << 8) | VAR_11;
}
c->pic->palette_has_changed = 1;
}
switch (code & 0x0F) {
case 0:
if ((VAR_6 = decode_0(c, VAR_3->VAR_1, code)) < 0)
return VAR_6;
break;
case 1:
dst = c->VAR_5[c->current_frame];
bytestream2_skip(&c->gb, 2);
if (bytestream2_get_bytes_left(&c->gb) < c->video_size)
return AVERROR_INVALIDDATA;
bytestream2_get_bufferu(&c->gb, dst, c->video_size);
break;
case 2:
VAR_5 = bytestream2_get_byte(&c->gb);
if (VAR_5 > 3)
return AVERROR_INVALIDDATA;
if (VAR_5 != c->current_frame)
memcpy(c->VAR_5[c->current_frame], c->VAR_5[VAR_5], c->frame_size);
break;
case 4:
dst = c->VAR_5[c->current_frame];
end = dst + c->video_size;
bytestream2_skip(&c->gb, 2);
while (dst < end) {
int8_t code;
int VAR_12;
if (bytestream2_get_bytes_left(&c->gb) < 2)
return AVERROR_INVALIDDATA;
code = bytestream2_get_byteu(&c->gb);
VAR_12 = FFABS(code) + 1;
if (dst + VAR_12 > end)
return AVERROR_INVALIDDATA;
if (code < 0)
memset(dst, bytestream2_get_byteu(&c->gb), VAR_12);
else
bytestream2_get_buffer(&c->gb, dst, VAR_12);
dst += VAR_12;
}
break;
default:
av_assert0(0);
}
av_image_copy_plane(c->pic->VAR_1[0], c->pic->linesize[0],
c->VAR_5[c->current_frame], c->width,
c->width, c->height);
c->current_frame = (c->current_frame + 1) & 3;
if ((VAR_6 = av_frame_ref(VAR_1, c->pic)) < 0)
return VAR_6;
*VAR_2 = 1;
return VAR_3->size;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{",
"PAFVideoDecContext *c = VAR_0->priv_data;",
"uint8_t code, *dst, *end;",
"int VAR_4, VAR_5, VAR_6;",
"if (VAR_3->size < 2)\nreturn AVERROR_INVALIDDATA;",
"bytestream2_init(&c->gb, VAR_3->VAR_1, VAR_3->size);",
"code = bytestream2_get_byte(&c->gb);",
"if ((code & 0xF) > 4) {",
"avpriv_request_sample(VAR_0, \"unknown/invalid code\");",
"return AVERROR_INVALIDDATA;",
"}",
"if ((VAR_6 = ff_reget_buffer(VAR_0, c->pic)) < 0)\nreturn VAR_6;",
"if (code & 0x20) {",
"for (VAR_4 = 0; VAR_4 < 4; VAR_4++)",
"memset(c->VAR_5[VAR_4], 0, c->frame_size);",
"memset(c->pic->VAR_1[1], 0, AVPALETTE_SIZE);",
"c->current_frame = 0;",
"c->pic->key_frame = 1;",
"c->pic->pict_type = AV_PICTURE_TYPE_I;",
"} else {",
"c->pic->key_frame = 0;",
"c->pic->pict_type = AV_PICTURE_TYPE_P;",
"}",
"if (code & 0x40) {",
"uint32_t *out = (uint32_t *)c->pic->VAR_1[1];",
"int VAR_7, VAR_12;",
"VAR_7 = bytestream2_get_byte(&c->gb);",
"VAR_12 = bytestream2_get_byte(&c->gb) + 1;",
"if (VAR_7 + VAR_12 > 256)\nreturn AVERROR_INVALIDDATA;",
"if (bytestream2_get_bytes_left(&c->gb) < 3 * VAR_12)\nreturn AVERROR_INVALIDDATA;",
"out += VAR_7;",
"for (VAR_4 = 0; VAR_4 < VAR_12; VAR_4++) {",
"unsigned VAR_9, VAR_10, VAR_11;",
"VAR_9 = bytestream2_get_byteu(&c->gb);",
"VAR_9 = VAR_9 << 2 | VAR_9 >> 4;",
"VAR_10 = bytestream2_get_byteu(&c->gb);",
"VAR_10 = VAR_10 << 2 | VAR_10 >> 4;",
"VAR_11 = bytestream2_get_byteu(&c->gb);",
"VAR_11 = VAR_11 << 2 | VAR_11 >> 4;",
"*out++ = (0xFFU << 24) | (VAR_9 << 16) | (VAR_10 << 8) | VAR_11;",
"}",
"c->pic->palette_has_changed = 1;",
"}",
"switch (code & 0x0F) {",
"case 0:\nif ((VAR_6 = decode_0(c, VAR_3->VAR_1, code)) < 0)\nreturn VAR_6;",
"break;",
"case 1:\ndst = c->VAR_5[c->current_frame];",
"bytestream2_skip(&c->gb, 2);",
"if (bytestream2_get_bytes_left(&c->gb) < c->video_size)\nreturn AVERROR_INVALIDDATA;",
"bytestream2_get_bufferu(&c->gb, dst, c->video_size);",
"break;",
"case 2:\nVAR_5 = bytestream2_get_byte(&c->gb);",
"if (VAR_5 > 3)\nreturn AVERROR_INVALIDDATA;",
"if (VAR_5 != c->current_frame)\nmemcpy(c->VAR_5[c->current_frame], c->VAR_5[VAR_5], c->frame_size);",
"break;",
"case 4:\ndst = c->VAR_5[c->current_frame];",
"end = dst + c->video_size;",
"bytestream2_skip(&c->gb, 2);",
"while (dst < end) {",
"int8_t code;",
"int VAR_12;",
"if (bytestream2_get_bytes_left(&c->gb) < 2)\nreturn AVERROR_INVALIDDATA;",
"code = bytestream2_get_byteu(&c->gb);",
"VAR_12 = FFABS(code) + 1;",
"if (dst + VAR_12 > end)\nreturn AVERROR_INVALIDDATA;",
"if (code < 0)\nmemset(dst, bytestream2_get_byteu(&c->gb), VAR_12);",
"else\nbytestream2_get_buffer(&c->gb, dst, VAR_12);",
"dst += VAR_12;",
"}",
"break;",
"default:\nav_assert0(0);",
"}",
"av_image_copy_plane(c->pic->VAR_1[0], c->pic->linesize[0],\nc->VAR_5[c->current_frame], c->width,\nc->width, c->height);",
"c->current_frame = (c->current_frame + 1) & 3;",
"if ((VAR_6 = av_frame_ref(VAR_1, c->pic)) < 0)\nreturn VAR_6;",
"*VAR_2 = 1;",
"return VAR_3->size;",
"}"
] | [
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37,
39
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
83,
85
],
[
87,
89
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125,
131,
133
],
[
135
],
[
137,
143
],
[
147
],
[
149,
151
],
[
153
],
[
155
],
[
157,
165
],
[
167,
169
],
[
171,
173
],
[
175
],
[
177,
181
],
[
183
],
[
187
],
[
191
],
[
193
],
[
195
],
[
199,
201
],
[
205
],
[
207
],
[
211,
213
],
[
215,
217
],
[
219,
221
],
[
223
],
[
225
],
[
227
],
[
229,
231
],
[
233
],
[
237,
239,
241
],
[
245
],
[
247,
249
],
[
253
],
[
257
],
[
259
]
] |
26,091 | int avresample_get_matrix(AVAudioResampleContext *avr, double *matrix,
int stride)
{
int in_channels, out_channels, i, o;
in_channels = av_get_channel_layout_nb_channels(avr->in_channel_layout);
out_channels = av_get_channel_layout_nb_channels(avr->out_channel_layout);
if ( in_channels < 0 || in_channels > AVRESAMPLE_MAX_CHANNELS ||
out_channels < 0 || out_channels > AVRESAMPLE_MAX_CHANNELS) {
av_log(avr, AV_LOG_ERROR, "Invalid channel layouts\n");
return AVERROR(EINVAL);
}
switch (avr->mix_coeff_type) {
case AV_MIX_COEFF_TYPE_Q8:
if (!avr->am->matrix_q8[0]) {
av_log(avr, AV_LOG_ERROR, "matrix is not set\n");
return AVERROR(EINVAL);
}
for (o = 0; o < out_channels; o++)
for (i = 0; i < in_channels; i++)
matrix[o * stride + i] = avr->am->matrix_q8[o][i] / 256.0;
break;
case AV_MIX_COEFF_TYPE_Q15:
if (!avr->am->matrix_q15[0]) {
av_log(avr, AV_LOG_ERROR, "matrix is not set\n");
return AVERROR(EINVAL);
}
for (o = 0; o < out_channels; o++)
for (i = 0; i < in_channels; i++)
matrix[o * stride + i] = avr->am->matrix_q15[o][i] / 32768.0;
break;
case AV_MIX_COEFF_TYPE_FLT:
if (!avr->am->matrix_flt[0]) {
av_log(avr, AV_LOG_ERROR, "matrix is not set\n");
return AVERROR(EINVAL);
}
for (o = 0; o < out_channels; o++)
for (i = 0; i < in_channels; i++)
matrix[o * stride + i] = avr->am->matrix_flt[o][i];
break;
default:
av_log(avr, AV_LOG_ERROR, "Invalid mix coeff type\n");
return AVERROR(EINVAL);
}
return 0;
}
| true | FFmpeg | 8821ae649e61097ec57ca58472c3e4239c82913c | int avresample_get_matrix(AVAudioResampleContext *avr, double *matrix,
int stride)
{
int in_channels, out_channels, i, o;
in_channels = av_get_channel_layout_nb_channels(avr->in_channel_layout);
out_channels = av_get_channel_layout_nb_channels(avr->out_channel_layout);
if ( in_channels < 0 || in_channels > AVRESAMPLE_MAX_CHANNELS ||
out_channels < 0 || out_channels > AVRESAMPLE_MAX_CHANNELS) {
av_log(avr, AV_LOG_ERROR, "Invalid channel layouts\n");
return AVERROR(EINVAL);
}
switch (avr->mix_coeff_type) {
case AV_MIX_COEFF_TYPE_Q8:
if (!avr->am->matrix_q8[0]) {
av_log(avr, AV_LOG_ERROR, "matrix is not set\n");
return AVERROR(EINVAL);
}
for (o = 0; o < out_channels; o++)
for (i = 0; i < in_channels; i++)
matrix[o * stride + i] = avr->am->matrix_q8[o][i] / 256.0;
break;
case AV_MIX_COEFF_TYPE_Q15:
if (!avr->am->matrix_q15[0]) {
av_log(avr, AV_LOG_ERROR, "matrix is not set\n");
return AVERROR(EINVAL);
}
for (o = 0; o < out_channels; o++)
for (i = 0; i < in_channels; i++)
matrix[o * stride + i] = avr->am->matrix_q15[o][i] / 32768.0;
break;
case AV_MIX_COEFF_TYPE_FLT:
if (!avr->am->matrix_flt[0]) {
av_log(avr, AV_LOG_ERROR, "matrix is not set\n");
return AVERROR(EINVAL);
}
for (o = 0; o < out_channels; o++)
for (i = 0; i < in_channels; i++)
matrix[o * stride + i] = avr->am->matrix_flt[o][i];
break;
default:
av_log(avr, AV_LOG_ERROR, "Invalid mix coeff type\n");
return AVERROR(EINVAL);
}
return 0;
}
| {
"code": [
" if ( in_channels < 0 || in_channels > AVRESAMPLE_MAX_CHANNELS ||",
" out_channels < 0 || out_channels > AVRESAMPLE_MAX_CHANNELS) {",
" if ( in_channels < 0 || in_channels > AVRESAMPLE_MAX_CHANNELS ||",
" out_channels < 0 || out_channels > AVRESAMPLE_MAX_CHANNELS) {"
],
"line_no": [
17,
19,
17,
19
]
} | int FUNC_0(AVAudioResampleContext *VAR_0, double *VAR_1,
int VAR_2)
{
int VAR_3, VAR_4, VAR_5, VAR_6;
VAR_3 = av_get_channel_layout_nb_channels(VAR_0->in_channel_layout);
VAR_4 = av_get_channel_layout_nb_channels(VAR_0->out_channel_layout);
if ( VAR_3 < 0 || VAR_3 > AVRESAMPLE_MAX_CHANNELS ||
VAR_4 < 0 || VAR_4 > AVRESAMPLE_MAX_CHANNELS) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid channel layouts\n");
return AVERROR(EINVAL);
}
switch (VAR_0->mix_coeff_type) {
case AV_MIX_COEFF_TYPE_Q8:
if (!VAR_0->am->matrix_q8[0]) {
av_log(VAR_0, AV_LOG_ERROR, "VAR_1 is not set\n");
return AVERROR(EINVAL);
}
for (VAR_6 = 0; VAR_6 < VAR_4; VAR_6++)
for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++)
VAR_1[VAR_6 * VAR_2 + VAR_5] = VAR_0->am->matrix_q8[VAR_6][VAR_5] / 256.0;
break;
case AV_MIX_COEFF_TYPE_Q15:
if (!VAR_0->am->matrix_q15[0]) {
av_log(VAR_0, AV_LOG_ERROR, "VAR_1 is not set\n");
return AVERROR(EINVAL);
}
for (VAR_6 = 0; VAR_6 < VAR_4; VAR_6++)
for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++)
VAR_1[VAR_6 * VAR_2 + VAR_5] = VAR_0->am->matrix_q15[VAR_6][VAR_5] / 32768.0;
break;
case AV_MIX_COEFF_TYPE_FLT:
if (!VAR_0->am->matrix_flt[0]) {
av_log(VAR_0, AV_LOG_ERROR, "VAR_1 is not set\n");
return AVERROR(EINVAL);
}
for (VAR_6 = 0; VAR_6 < VAR_4; VAR_6++)
for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++)
VAR_1[VAR_6 * VAR_2 + VAR_5] = VAR_0->am->matrix_flt[VAR_6][VAR_5];
break;
default:
av_log(VAR_0, AV_LOG_ERROR, "Invalid mix coeff type\n");
return AVERROR(EINVAL);
}
return 0;
}
| [
"int FUNC_0(AVAudioResampleContext *VAR_0, double *VAR_1,\nint VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5, VAR_6;",
"VAR_3 = av_get_channel_layout_nb_channels(VAR_0->in_channel_layout);",
"VAR_4 = av_get_channel_layout_nb_channels(VAR_0->out_channel_layout);",
"if ( VAR_3 < 0 || VAR_3 > AVRESAMPLE_MAX_CHANNELS ||\nVAR_4 < 0 || VAR_4 > AVRESAMPLE_MAX_CHANNELS) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid channel layouts\\n\");",
"return AVERROR(EINVAL);",
"}",
"switch (VAR_0->mix_coeff_type) {",
"case AV_MIX_COEFF_TYPE_Q8:\nif (!VAR_0->am->matrix_q8[0]) {",
"av_log(VAR_0, AV_LOG_ERROR, \"VAR_1 is not set\\n\");",
"return AVERROR(EINVAL);",
"}",
"for (VAR_6 = 0; VAR_6 < VAR_4; VAR_6++)",
"for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++)",
"VAR_1[VAR_6 * VAR_2 + VAR_5] = VAR_0->am->matrix_q8[VAR_6][VAR_5] / 256.0;",
"break;",
"case AV_MIX_COEFF_TYPE_Q15:\nif (!VAR_0->am->matrix_q15[0]) {",
"av_log(VAR_0, AV_LOG_ERROR, \"VAR_1 is not set\\n\");",
"return AVERROR(EINVAL);",
"}",
"for (VAR_6 = 0; VAR_6 < VAR_4; VAR_6++)",
"for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++)",
"VAR_1[VAR_6 * VAR_2 + VAR_5] = VAR_0->am->matrix_q15[VAR_6][VAR_5] / 32768.0;",
"break;",
"case AV_MIX_COEFF_TYPE_FLT:\nif (!VAR_0->am->matrix_flt[0]) {",
"av_log(VAR_0, AV_LOG_ERROR, \"VAR_1 is not set\\n\");",
"return AVERROR(EINVAL);",
"}",
"for (VAR_6 = 0; VAR_6 < VAR_4; VAR_6++)",
"for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++)",
"VAR_1[VAR_6 * VAR_2 + VAR_5] = VAR_0->am->matrix_flt[VAR_6][VAR_5];",
"break;",
"default:\nav_log(VAR_0, AV_LOG_ERROR, \"Invalid mix coeff type\\n\");",
"return AVERROR(EINVAL);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
17,
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85,
87
],
[
89
],
[
91
],
[
93
],
[
95
]
] |
26,092 | static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index)
{
AVPacket out_pkt = { 0 }, flush_pkt = { 0 };
AVStream *st = s->streams[stream_index];
uint8_t *data = pkt ? pkt->data : NULL;
int size = pkt ? pkt->size : 0;
int ret = 0, got_output = 0;
if (!pkt) {
av_init_packet(&flush_pkt);
pkt = &flush_pkt;
got_output = 1;
}
while (size > 0 || (pkt == &flush_pkt && got_output)) {
int len;
av_init_packet(&out_pkt);
len = av_parser_parse2(st->parser, st->codec,
&out_pkt.data, &out_pkt.size, data, size,
pkt->pts, pkt->dts, pkt->pos);
pkt->pts = pkt->dts = AV_NOPTS_VALUE;
/* increment read pointer */
data += len;
size -= len;
got_output = !!out_pkt.size;
if (!out_pkt.size)
continue;
if (pkt->side_data) {
out_pkt.side_data = pkt->side_data;
out_pkt.side_data_elems = pkt->side_data_elems;
pkt->side_data = NULL;
pkt->side_data_elems = 0;
}
/* set the duration */
out_pkt.duration = 0;
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if (st->codec->sample_rate > 0) {
out_pkt.duration =
av_rescale_q_rnd(st->parser->duration,
(AVRational) { 1, st->codec->sample_rate },
st->time_base,
AV_ROUND_DOWN);
}
}
out_pkt.stream_index = st->index;
out_pkt.pts = st->parser->pts;
out_pkt.dts = st->parser->dts;
out_pkt.pos = st->parser->pos;
if (st->parser->key_frame == 1 ||
(st->parser->key_frame == -1 &&
st->parser->pict_type == AV_PICTURE_TYPE_I))
out_pkt.flags |= AV_PKT_FLAG_KEY;
compute_pkt_fields(s, st, st->parser, &out_pkt);
if ((s->iformat->flags & AVFMT_GENERIC_INDEX) &&
out_pkt.flags & AV_PKT_FLAG_KEY) {
ff_reduce_index(s, st->index);
av_add_index_entry(st, st->parser->frame_offset, out_pkt.dts,
0, 0, AVINDEX_KEYFRAME);
}
if (out_pkt.data == pkt->data && out_pkt.size == pkt->size) {
out_pkt.buf = pkt->buf;
pkt->buf = NULL;
}
if ((ret = av_dup_packet(&out_pkt)) < 0)
goto fail;
if (!add_to_pktbuf(&s->internal->parse_queue, &out_pkt, &s->internal->parse_queue_end)) {
av_packet_unref(&out_pkt);
ret = AVERROR(ENOMEM);
goto fail;
}
}
/* end of the stream => close and free the parser */
if (pkt == &flush_pkt) {
av_parser_close(st->parser);
st->parser = NULL;
}
fail:
av_packet_unref(pkt);
return ret;
}
| false | FFmpeg | d584533cf38141172e20bae5436629ee17c8ce50 | static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index)
{
AVPacket out_pkt = { 0 }, flush_pkt = { 0 };
AVStream *st = s->streams[stream_index];
uint8_t *data = pkt ? pkt->data : NULL;
int size = pkt ? pkt->size : 0;
int ret = 0, got_output = 0;
if (!pkt) {
av_init_packet(&flush_pkt);
pkt = &flush_pkt;
got_output = 1;
}
while (size > 0 || (pkt == &flush_pkt && got_output)) {
int len;
av_init_packet(&out_pkt);
len = av_parser_parse2(st->parser, st->codec,
&out_pkt.data, &out_pkt.size, data, size,
pkt->pts, pkt->dts, pkt->pos);
pkt->pts = pkt->dts = AV_NOPTS_VALUE;
data += len;
size -= len;
got_output = !!out_pkt.size;
if (!out_pkt.size)
continue;
if (pkt->side_data) {
out_pkt.side_data = pkt->side_data;
out_pkt.side_data_elems = pkt->side_data_elems;
pkt->side_data = NULL;
pkt->side_data_elems = 0;
}
out_pkt.duration = 0;
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if (st->codec->sample_rate > 0) {
out_pkt.duration =
av_rescale_q_rnd(st->parser->duration,
(AVRational) { 1, st->codec->sample_rate },
st->time_base,
AV_ROUND_DOWN);
}
}
out_pkt.stream_index = st->index;
out_pkt.pts = st->parser->pts;
out_pkt.dts = st->parser->dts;
out_pkt.pos = st->parser->pos;
if (st->parser->key_frame == 1 ||
(st->parser->key_frame == -1 &&
st->parser->pict_type == AV_PICTURE_TYPE_I))
out_pkt.flags |= AV_PKT_FLAG_KEY;
compute_pkt_fields(s, st, st->parser, &out_pkt);
if ((s->iformat->flags & AVFMT_GENERIC_INDEX) &&
out_pkt.flags & AV_PKT_FLAG_KEY) {
ff_reduce_index(s, st->index);
av_add_index_entry(st, st->parser->frame_offset, out_pkt.dts,
0, 0, AVINDEX_KEYFRAME);
}
if (out_pkt.data == pkt->data && out_pkt.size == pkt->size) {
out_pkt.buf = pkt->buf;
pkt->buf = NULL;
}
if ((ret = av_dup_packet(&out_pkt)) < 0)
goto fail;
if (!add_to_pktbuf(&s->internal->parse_queue, &out_pkt, &s->internal->parse_queue_end)) {
av_packet_unref(&out_pkt);
ret = AVERROR(ENOMEM);
goto fail;
}
}
if (pkt == &flush_pkt) {
av_parser_close(st->parser);
st->parser = NULL;
}
fail:
av_packet_unref(pkt);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1, int VAR_2)
{
AVPacket out_pkt = { 0 }, flush_pkt = { 0 };
AVStream *st = VAR_0->streams[VAR_2];
uint8_t *data = VAR_1 ? VAR_1->data : NULL;
int VAR_3 = VAR_1 ? VAR_1->VAR_3 : 0;
int VAR_4 = 0, VAR_5 = 0;
if (!VAR_1) {
av_init_packet(&flush_pkt);
VAR_1 = &flush_pkt;
VAR_5 = 1;
}
while (VAR_3 > 0 || (VAR_1 == &flush_pkt && VAR_5)) {
int VAR_6;
av_init_packet(&out_pkt);
VAR_6 = av_parser_parse2(st->parser, st->codec,
&out_pkt.data, &out_pkt.VAR_3, data, VAR_3,
VAR_1->pts, VAR_1->dts, VAR_1->pos);
VAR_1->pts = VAR_1->dts = AV_NOPTS_VALUE;
data += VAR_6;
VAR_3 -= VAR_6;
VAR_5 = !!out_pkt.VAR_3;
if (!out_pkt.VAR_3)
continue;
if (VAR_1->side_data) {
out_pkt.side_data = VAR_1->side_data;
out_pkt.side_data_elems = VAR_1->side_data_elems;
VAR_1->side_data = NULL;
VAR_1->side_data_elems = 0;
}
out_pkt.duration = 0;
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if (st->codec->sample_rate > 0) {
out_pkt.duration =
av_rescale_q_rnd(st->parser->duration,
(AVRational) { 1, st->codec->sample_rate },
st->time_base,
AV_ROUND_DOWN);
}
}
out_pkt.VAR_2 = st->index;
out_pkt.pts = st->parser->pts;
out_pkt.dts = st->parser->dts;
out_pkt.pos = st->parser->pos;
if (st->parser->key_frame == 1 ||
(st->parser->key_frame == -1 &&
st->parser->pict_type == AV_PICTURE_TYPE_I))
out_pkt.flags |= AV_PKT_FLAG_KEY;
compute_pkt_fields(VAR_0, st, st->parser, &out_pkt);
if ((VAR_0->iformat->flags & AVFMT_GENERIC_INDEX) &&
out_pkt.flags & AV_PKT_FLAG_KEY) {
ff_reduce_index(VAR_0, st->index);
av_add_index_entry(st, st->parser->frame_offset, out_pkt.dts,
0, 0, AVINDEX_KEYFRAME);
}
if (out_pkt.data == VAR_1->data && out_pkt.VAR_3 == VAR_1->VAR_3) {
out_pkt.buf = VAR_1->buf;
VAR_1->buf = NULL;
}
if ((VAR_4 = av_dup_packet(&out_pkt)) < 0)
goto fail;
if (!add_to_pktbuf(&VAR_0->internal->parse_queue, &out_pkt, &VAR_0->internal->parse_queue_end)) {
av_packet_unref(&out_pkt);
VAR_4 = AVERROR(ENOMEM);
goto fail;
}
}
if (VAR_1 == &flush_pkt) {
av_parser_close(st->parser);
st->parser = NULL;
}
fail:
av_packet_unref(VAR_1);
return VAR_4;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1, int VAR_2)\n{",
"AVPacket out_pkt = { 0 }, flush_pkt = { 0 };",
"AVStream *st = VAR_0->streams[VAR_2];",
"uint8_t *data = VAR_1 ? VAR_1->data : NULL;",
"int VAR_3 = VAR_1 ? VAR_1->VAR_3 : 0;",
"int VAR_4 = 0, VAR_5 = 0;",
"if (!VAR_1) {",
"av_init_packet(&flush_pkt);",
"VAR_1 = &flush_pkt;",
"VAR_5 = 1;",
"}",
"while (VAR_3 > 0 || (VAR_1 == &flush_pkt && VAR_5)) {",
"int VAR_6;",
"av_init_packet(&out_pkt);",
"VAR_6 = av_parser_parse2(st->parser, st->codec,\n&out_pkt.data, &out_pkt.VAR_3, data, VAR_3,\nVAR_1->pts, VAR_1->dts, VAR_1->pos);",
"VAR_1->pts = VAR_1->dts = AV_NOPTS_VALUE;",
"data += VAR_6;",
"VAR_3 -= VAR_6;",
"VAR_5 = !!out_pkt.VAR_3;",
"if (!out_pkt.VAR_3)\ncontinue;",
"if (VAR_1->side_data) {",
"out_pkt.side_data = VAR_1->side_data;",
"out_pkt.side_data_elems = VAR_1->side_data_elems;",
"VAR_1->side_data = NULL;",
"VAR_1->side_data_elems = 0;",
"}",
"out_pkt.duration = 0;",
"if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {",
"if (st->codec->sample_rate > 0) {",
"out_pkt.duration =\nav_rescale_q_rnd(st->parser->duration,\n(AVRational) { 1, st->codec->sample_rate },",
"st->time_base,\nAV_ROUND_DOWN);",
"}",
"}",
"out_pkt.VAR_2 = st->index;",
"out_pkt.pts = st->parser->pts;",
"out_pkt.dts = st->parser->dts;",
"out_pkt.pos = st->parser->pos;",
"if (st->parser->key_frame == 1 ||\n(st->parser->key_frame == -1 &&\nst->parser->pict_type == AV_PICTURE_TYPE_I))\nout_pkt.flags |= AV_PKT_FLAG_KEY;",
"compute_pkt_fields(VAR_0, st, st->parser, &out_pkt);",
"if ((VAR_0->iformat->flags & AVFMT_GENERIC_INDEX) &&\nout_pkt.flags & AV_PKT_FLAG_KEY) {",
"ff_reduce_index(VAR_0, st->index);",
"av_add_index_entry(st, st->parser->frame_offset, out_pkt.dts,\n0, 0, AVINDEX_KEYFRAME);",
"}",
"if (out_pkt.data == VAR_1->data && out_pkt.VAR_3 == VAR_1->VAR_3) {",
"out_pkt.buf = VAR_1->buf;",
"VAR_1->buf = NULL;",
"}",
"if ((VAR_4 = av_dup_packet(&out_pkt)) < 0)\ngoto fail;",
"if (!add_to_pktbuf(&VAR_0->internal->parse_queue, &out_pkt, &VAR_0->internal->parse_queue_end)) {",
"av_packet_unref(&out_pkt);",
"VAR_4 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"}",
"if (VAR_1 == &flush_pkt) {",
"av_parser_close(st->parser);",
"st->parser = NULL;",
"}",
"fail:\nav_packet_unref(VAR_1);",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
35
],
[
37,
39,
41
],
[
45
],
[
49
],
[
51
],
[
55
],
[
59,
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
81
],
[
83
],
[
85
],
[
87,
89,
91
],
[
93,
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113,
115,
117,
119
],
[
123
],
[
127,
129
],
[
131
],
[
133,
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149,
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
171
],
[
173
],
[
175
],
[
177
],
[
181,
183
],
[
185
],
[
187
]
] |
26,093 | int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
uint8_t* buf, int buf_size, int64_t pos)
{
int size, i;
uint8_t *ppcm[4] = {0};
if (buf_size < DV_PROFILE_BYTES ||
!(c->sys = avpriv_dv_frame_profile(c->sys, buf, buf_size)) ||
buf_size < c->sys->frame_size) {
return -1; /* Broken frame, or not enough data */
}
/* Queueing audio packet */
/* FIXME: in case of no audio/bad audio we have to do something */
size = dv_extract_audio_info(c, buf);
for (i = 0; i < c->ach; i++) {
c->audio_pkt[i].pos = pos;
c->audio_pkt[i].size = size;
c->audio_pkt[i].pts = c->abytes * 30000*8 / c->ast[i]->codec->bit_rate;
ppcm[i] = c->audio_buf[i];
}
dv_extract_audio(buf, ppcm, c->sys);
/* We work with 720p frames split in half, thus even frames have
* channels 0,1 and odd 2,3. */
if (c->sys->height == 720) {
if (buf[1] & 0x0C) {
c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
} else {
c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
c->abytes += size;
}
} else {
c->abytes += size;
}
/* Now it's time to return video packet */
size = dv_extract_video_info(c, buf);
av_init_packet(pkt);
pkt->data = buf;
pkt->pos = pos;
pkt->size = size;
pkt->flags |= AV_PKT_FLAG_KEY;
pkt->stream_index = c->vst->id;
pkt->pts = c->frames;
c->frames++;
return size;
}
| true | FFmpeg | 5cb57a16ede71d913384a0b3036a2c6df5da5e43 | int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
uint8_t* buf, int buf_size, int64_t pos)
{
int size, i;
uint8_t *ppcm[4] = {0};
if (buf_size < DV_PROFILE_BYTES ||
!(c->sys = avpriv_dv_frame_profile(c->sys, buf, buf_size)) ||
buf_size < c->sys->frame_size) {
return -1;
}
size = dv_extract_audio_info(c, buf);
for (i = 0; i < c->ach; i++) {
c->audio_pkt[i].pos = pos;
c->audio_pkt[i].size = size;
c->audio_pkt[i].pts = c->abytes * 30000*8 / c->ast[i]->codec->bit_rate;
ppcm[i] = c->audio_buf[i];
}
dv_extract_audio(buf, ppcm, c->sys);
if (c->sys->height == 720) {
if (buf[1] & 0x0C) {
c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
} else {
c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
c->abytes += size;
}
} else {
c->abytes += size;
}
size = dv_extract_video_info(c, buf);
av_init_packet(pkt);
pkt->data = buf;
pkt->pos = pos;
pkt->size = size;
pkt->flags |= AV_PKT_FLAG_KEY;
pkt->stream_index = c->vst->id;
pkt->pts = c->frames;
c->frames++;
return size;
}
| {
"code": [
" dv_extract_audio(buf, ppcm, c->sys);"
],
"line_no": [
43
]
} | int FUNC_0(DVDemuxContext *VAR_0, AVPacket *VAR_1,
uint8_t* VAR_2, int VAR_3, int64_t VAR_4)
{
int VAR_5, VAR_6;
uint8_t *ppcm[4] = {0};
if (VAR_3 < DV_PROFILE_BYTES ||
!(VAR_0->sys = avpriv_dv_frame_profile(VAR_0->sys, VAR_2, VAR_3)) ||
VAR_3 < VAR_0->sys->frame_size) {
return -1;
}
VAR_5 = dv_extract_audio_info(VAR_0, VAR_2);
for (VAR_6 = 0; VAR_6 < VAR_0->ach; VAR_6++) {
VAR_0->audio_pkt[VAR_6].VAR_4 = VAR_4;
VAR_0->audio_pkt[VAR_6].VAR_5 = VAR_5;
VAR_0->audio_pkt[VAR_6].pts = VAR_0->abytes * 30000*8 / VAR_0->ast[VAR_6]->codec->bit_rate;
ppcm[VAR_6] = VAR_0->audio_buf[VAR_6];
}
dv_extract_audio(VAR_2, ppcm, VAR_0->sys);
if (VAR_0->sys->height == 720) {
if (VAR_2[1] & 0x0C) {
VAR_0->audio_pkt[2].VAR_5 = VAR_0->audio_pkt[3].VAR_5 = 0;
} else {
VAR_0->audio_pkt[0].VAR_5 = VAR_0->audio_pkt[1].VAR_5 = 0;
VAR_0->abytes += VAR_5;
}
} else {
VAR_0->abytes += VAR_5;
}
VAR_5 = dv_extract_video_info(VAR_0, VAR_2);
av_init_packet(VAR_1);
VAR_1->data = VAR_2;
VAR_1->VAR_4 = VAR_4;
VAR_1->VAR_5 = VAR_5;
VAR_1->flags |= AV_PKT_FLAG_KEY;
VAR_1->stream_index = VAR_0->vst->id;
VAR_1->pts = VAR_0->frames;
VAR_0->frames++;
return VAR_5;
}
| [
"int FUNC_0(DVDemuxContext *VAR_0, AVPacket *VAR_1,\nuint8_t* VAR_2, int VAR_3, int64_t VAR_4)\n{",
"int VAR_5, VAR_6;",
"uint8_t *ppcm[4] = {0};",
"if (VAR_3 < DV_PROFILE_BYTES ||\n!(VAR_0->sys = avpriv_dv_frame_profile(VAR_0->sys, VAR_2, VAR_3)) ||\nVAR_3 < VAR_0->sys->frame_size) {",
"return -1;",
"}",
"VAR_5 = dv_extract_audio_info(VAR_0, VAR_2);",
"for (VAR_6 = 0; VAR_6 < VAR_0->ach; VAR_6++) {",
"VAR_0->audio_pkt[VAR_6].VAR_4 = VAR_4;",
"VAR_0->audio_pkt[VAR_6].VAR_5 = VAR_5;",
"VAR_0->audio_pkt[VAR_6].pts = VAR_0->abytes * 30000*8 / VAR_0->ast[VAR_6]->codec->bit_rate;",
"ppcm[VAR_6] = VAR_0->audio_buf[VAR_6];",
"}",
"dv_extract_audio(VAR_2, ppcm, VAR_0->sys);",
"if (VAR_0->sys->height == 720) {",
"if (VAR_2[1] & 0x0C) {",
"VAR_0->audio_pkt[2].VAR_5 = VAR_0->audio_pkt[3].VAR_5 = 0;",
"} else {",
"VAR_0->audio_pkt[0].VAR_5 = VAR_0->audio_pkt[1].VAR_5 = 0;",
"VAR_0->abytes += VAR_5;",
"}",
"} else {",
"VAR_0->abytes += VAR_5;",
"}",
"VAR_5 = dv_extract_video_info(VAR_0, VAR_2);",
"av_init_packet(VAR_1);",
"VAR_1->data = VAR_2;",
"VAR_1->VAR_4 = VAR_4;",
"VAR_1->VAR_5 = VAR_5;",
"VAR_1->flags |= AV_PKT_FLAG_KEY;",
"VAR_1->stream_index = VAR_0->vst->id;",
"VAR_1->pts = VAR_0->frames;",
"VAR_0->frames++;",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13,
15,
17
],
[
19
],
[
21
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
97
],
[
99
]
] |
26,094 | int mmu40x_get_physical_address (CPUState *env, mmu_ctx_t *ctx,
target_ulong address, int rw, int access_type)
{
ppcemb_tlb_t *tlb;
target_phys_addr_t raddr;
int i, ret, zsel, zpr, pr;
ret = -1;
raddr = -1;
pr = msr_pr;
for (i = 0; i < env->nb_tlb; i++) {
tlb = &env->tlb[i].tlbe;
if (ppcemb_tlb_check(env, tlb, &raddr, address,
env->spr[SPR_40x_PID], 0, i) < 0)
continue;
zsel = (tlb->attr >> 4) & 0xF;
zpr = (env->spr[SPR_40x_ZPR] >> (28 - (2 * zsel))) & 0x3;
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
fprintf(logfile, "%s: TLB %d zsel %d zpr %d rw %d attr %08x\n",
__func__, i, zsel, zpr, rw, tlb->attr);
}
#endif
/* Check execute enable bit */
switch (zpr) {
case 0x2:
if (pr != 0)
goto check_perms;
/* No break here */
case 0x3:
/* All accesses granted */
ctx->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
ret = 0;
break;
case 0x0:
if (pr != 0) {
ctx->prot = 0;
ret = -2;
break;
}
/* No break here */
case 0x1:
check_perms:
/* Check from TLB entry */
/* XXX: there is a problem here or in the TLB fill code... */
ctx->prot = tlb->prot;
ctx->prot |= PAGE_EXEC;
ret = check_prot(ctx->prot, rw, access_type);
break;
}
if (ret >= 0) {
ctx->raddr = raddr;
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
fprintf(logfile, "%s: access granted " ADDRX " => " REGX
" %d %d\n", __func__, address, ctx->raddr, ctx->prot,
ret);
}
#endif
return 0;
}
}
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
fprintf(logfile, "%s: access refused " ADDRX " => " REGX
" %d %d\n", __func__, address, raddr, ctx->prot,
ret);
}
#endif
return ret;
}
| true | qemu | 6f2d8978728c48ca46f5c01835438508aace5c64 | int mmu40x_get_physical_address (CPUState *env, mmu_ctx_t *ctx,
target_ulong address, int rw, int access_type)
{
ppcemb_tlb_t *tlb;
target_phys_addr_t raddr;
int i, ret, zsel, zpr, pr;
ret = -1;
raddr = -1;
pr = msr_pr;
for (i = 0; i < env->nb_tlb; i++) {
tlb = &env->tlb[i].tlbe;
if (ppcemb_tlb_check(env, tlb, &raddr, address,
env->spr[SPR_40x_PID], 0, i) < 0)
continue;
zsel = (tlb->attr >> 4) & 0xF;
zpr = (env->spr[SPR_40x_ZPR] >> (28 - (2 * zsel))) & 0x3;
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
fprintf(logfile, "%s: TLB %d zsel %d zpr %d rw %d attr %08x\n",
__func__, i, zsel, zpr, rw, tlb->attr);
}
#endif
switch (zpr) {
case 0x2:
if (pr != 0)
goto check_perms;
case 0x3:
ctx->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
ret = 0;
break;
case 0x0:
if (pr != 0) {
ctx->prot = 0;
ret = -2;
break;
}
case 0x1:
check_perms:
ctx->prot = tlb->prot;
ctx->prot |= PAGE_EXEC;
ret = check_prot(ctx->prot, rw, access_type);
break;
}
if (ret >= 0) {
ctx->raddr = raddr;
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
fprintf(logfile, "%s: access granted " ADDRX " => " REGX
" %d %d\n", __func__, address, ctx->raddr, ctx->prot,
ret);
}
#endif
return 0;
}
}
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
fprintf(logfile, "%s: access refused " ADDRX " => " REGX
" %d %d\n", __func__, address, raddr, ctx->prot,
ret);
}
#endif
return ret;
}
| {
"code": [
" raddr = -1;",
" raddr = -1;"
],
"line_no": [
17,
17
]
} | int FUNC_0 (CPUState *VAR_0, mmu_ctx_t *VAR_1,
target_ulong VAR_2, int VAR_3, int VAR_4)
{
ppcemb_tlb_t *tlb;
target_phys_addr_t raddr;
int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;
VAR_6 = -1;
raddr = -1;
VAR_9 = msr_pr;
for (VAR_5 = 0; VAR_5 < VAR_0->nb_tlb; VAR_5++) {
tlb = &VAR_0->tlb[VAR_5].tlbe;
if (ppcemb_tlb_check(VAR_0, tlb, &raddr, VAR_2,
VAR_0->spr[SPR_40x_PID], 0, VAR_5) < 0)
continue;
VAR_7 = (tlb->attr >> 4) & 0xF;
VAR_8 = (VAR_0->spr[SPR_40x_ZPR] >> (28 - (2 * VAR_7))) & 0x3;
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
fprintf(logfile, "%s: TLB %d VAR_7 %d VAR_8 %d VAR_3 %d attr %08x\n",
__func__, VAR_5, VAR_7, VAR_8, VAR_3, tlb->attr);
}
#endif
switch (VAR_8) {
case 0x2:
if (VAR_9 != 0)
goto check_perms;
case 0x3:
VAR_1->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
VAR_6 = 0;
break;
case 0x0:
if (VAR_9 != 0) {
VAR_1->prot = 0;
VAR_6 = -2;
break;
}
case 0x1:
check_perms:
VAR_1->prot = tlb->prot;
VAR_1->prot |= PAGE_EXEC;
VAR_6 = check_prot(VAR_1->prot, VAR_3, VAR_4);
break;
}
if (VAR_6 >= 0) {
VAR_1->raddr = raddr;
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
fprintf(logfile, "%s: access granted " ADDRX " => " REGX
" %d %d\n", __func__, VAR_2, VAR_1->raddr, VAR_1->prot,
VAR_6);
}
#endif
return 0;
}
}
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
fprintf(logfile, "%s: access refused " ADDRX " => " REGX
" %d %d\n", __func__, VAR_2, raddr, VAR_1->prot,
VAR_6);
}
#endif
return VAR_6;
}
| [
"int FUNC_0 (CPUState *VAR_0, mmu_ctx_t *VAR_1,\ntarget_ulong VAR_2, int VAR_3, int VAR_4)\n{",
"ppcemb_tlb_t *tlb;",
"target_phys_addr_t raddr;",
"int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;",
"VAR_6 = -1;",
"raddr = -1;",
"VAR_9 = msr_pr;",
"for (VAR_5 = 0; VAR_5 < VAR_0->nb_tlb; VAR_5++) {",
"tlb = &VAR_0->tlb[VAR_5].tlbe;",
"if (ppcemb_tlb_check(VAR_0, tlb, &raddr, VAR_2,\nVAR_0->spr[SPR_40x_PID], 0, VAR_5) < 0)\ncontinue;",
"VAR_7 = (tlb->attr >> 4) & 0xF;",
"VAR_8 = (VAR_0->spr[SPR_40x_ZPR] >> (28 - (2 * VAR_7))) & 0x3;",
"#if defined (DEBUG_SOFTWARE_TLB)\nif (loglevel != 0) {",
"fprintf(logfile, \"%s: TLB %d VAR_7 %d VAR_8 %d VAR_3 %d attr %08x\\n\",\n__func__, VAR_5, VAR_7, VAR_8, VAR_3, tlb->attr);",
"}",
"#endif\nswitch (VAR_8) {",
"case 0x2:\nif (VAR_9 != 0)\ngoto check_perms;",
"case 0x3:\nVAR_1->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;",
"VAR_6 = 0;",
"break;",
"case 0x0:\nif (VAR_9 != 0) {",
"VAR_1->prot = 0;",
"VAR_6 = -2;",
"break;",
"}",
"case 0x1:\ncheck_perms:\nVAR_1->prot = tlb->prot;",
"VAR_1->prot |= PAGE_EXEC;",
"VAR_6 = check_prot(VAR_1->prot, VAR_3, VAR_4);",
"break;",
"}",
"if (VAR_6 >= 0) {",
"VAR_1->raddr = raddr;",
"#if defined (DEBUG_SOFTWARE_TLB)\nif (loglevel != 0) {",
"fprintf(logfile, \"%s: access granted \" ADDRX \" => \" REGX\n\" %d %d\\n\", __func__, VAR_2, VAR_1->raddr, VAR_1->prot,\nVAR_6);",
"}",
"#endif\nreturn 0;",
"}",
"}",
"#if defined (DEBUG_SOFTWARE_TLB)\nif (loglevel != 0) {",
"fprintf(logfile, \"%s: access refused \" ADDRX \" => \" REGX\n\" %d %d\\n\", __func__, VAR_2, raddr, VAR_1->prot,\nVAR_6);",
"}",
"#endif\nreturn VAR_6;",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27,
29
],
[
31
],
[
33
],
[
35,
37
],
[
39,
41
],
[
43
],
[
45,
49
],
[
51,
53,
55
],
[
59,
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83,
85,
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105,
107
],
[
109,
111,
113
],
[
115
],
[
117,
119
],
[
121
],
[
123
],
[
125,
127
],
[
129,
131,
133
],
[
135
],
[
137,
141
],
[
143
]
] |
26,095 | int bdrv_get_dirty(BlockDriverState *bs, int64_t sector)
{
int64_t chunk = sector / (int64_t)BDRV_SECTORS_PER_DIRTY_CHUNK;
if (bs->dirty_bitmap != NULL &&
(sector << BDRV_SECTOR_BITS) <= bdrv_getlength(bs)) {
return bs->dirty_bitmap[chunk];
} else {
return 0;
}
}
| true | qemu | c6d2283068026035a6468aae9dcde953bd7521ac | int bdrv_get_dirty(BlockDriverState *bs, int64_t sector)
{
int64_t chunk = sector / (int64_t)BDRV_SECTORS_PER_DIRTY_CHUNK;
if (bs->dirty_bitmap != NULL &&
(sector << BDRV_SECTOR_BITS) <= bdrv_getlength(bs)) {
return bs->dirty_bitmap[chunk];
} else {
return 0;
}
}
| {
"code": [
" if (bs->dirty_bitmap != NULL &&",
" (sector << BDRV_SECTOR_BITS) <= bdrv_getlength(bs)) {",
" return bs->dirty_bitmap[chunk];"
],
"line_no": [
9,
11,
13
]
} | int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1)
{
int64_t chunk = VAR_1 / (int64_t)BDRV_SECTORS_PER_DIRTY_CHUNK;
if (VAR_0->dirty_bitmap != NULL &&
(VAR_1 << BDRV_SECTOR_BITS) <= bdrv_getlength(VAR_0)) {
return VAR_0->dirty_bitmap[chunk];
} else {
return 0;
}
}
| [
"int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1)\n{",
"int64_t chunk = VAR_1 / (int64_t)BDRV_SECTORS_PER_DIRTY_CHUNK;",
"if (VAR_0->dirty_bitmap != NULL &&\n(VAR_1 << BDRV_SECTOR_BITS) <= bdrv_getlength(VAR_0)) {",
"return VAR_0->dirty_bitmap[chunk];",
"} else {",
"return 0;",
"}",
"}"
] | [
0,
0,
1,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
26,096 | static int gdv_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
GDVContext *gdv = avctx->priv_data;
GetByteContext *gb = &gdv->gb;
PutByteContext *pb = &gdv->pb;
AVFrame *frame = data;
int ret, i, pal_size;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size);
int compression;
unsigned flags;
uint8_t *dst;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
if (pal && pal_size == AVPALETTE_SIZE)
memcpy(gdv->pal, pal, AVPALETTE_SIZE);
bytestream2_init(gb, avpkt->data, avpkt->size);
bytestream2_init_writer(pb, gdv->frame, gdv->frame_size);
flags = bytestream2_get_le32(gb);
compression = flags & 0xF;
rescale(gdv, gdv->frame, avctx->width, avctx->height,
!!(flags & 0x10), !!(flags & 0x20));
switch (compression) {
case 1:
memset(gdv->frame + PREAMBLE_SIZE, 0, gdv->frame_size - PREAMBLE_SIZE);
case 0:
if (bytestream2_get_bytes_left(gb) < 256*3)
return AVERROR_INVALIDDATA;
for (i = 0; i < 256; i++) {
unsigned r = bytestream2_get_byte(gb);
unsigned g = bytestream2_get_byte(gb);
unsigned b = bytestream2_get_byte(gb);
gdv->pal[i] = 0xFFU << 24 | r << 18 | g << 10 | b << 2;
}
break;
case 2:
ret = decompress_2(avctx);
break;
case 3:
break;
case 5:
ret = decompress_5(avctx, flags >> 8);
break;
case 6:
ret = decompress_68(avctx, flags >> 8, 0);
break;
case 8:
ret = decompress_68(avctx, flags >> 8, 1);
break;
default:
return AVERROR_INVALIDDATA;
}
memcpy(frame->data[1], gdv->pal, AVPALETTE_SIZE);
dst = frame->data[0];
if (!gdv->scale_v && !gdv->scale_h) {
int sidx = PREAMBLE_SIZE, didx = 0;
int y, x;
for (y = 0; y < avctx->height; y++) {
for (x = 0; x < avctx->width; x++) {
dst[x+didx] = gdv->frame[x+sidx];
}
sidx += avctx->width;
didx += frame->linesize[0];
}
} else {
int sidx = PREAMBLE_SIZE, didx = 0;
int y, x;
for (y = 0; y < avctx->height; y++) {
if (!gdv->scale_v) {
for (x = 0; x < avctx->width; x++) {
dst[didx + x] = gdv->frame[sidx + x];
}
} else {
for (x = 0; x < avctx->width; x++) {
dst[didx + x] = gdv->frame[sidx + x/2];
}
}
if (!gdv->scale_h || ((y & 1) == 1)) {
sidx += !gdv->scale_v ? avctx->width : avctx->width/2;
}
didx += frame->linesize[0];
}
}
*got_frame = 1;
return ret < 0 ? ret : avpkt->size;
}
| true | FFmpeg | cf5a6c754aa3b67062b8cc60fa244e9c7d82010f | static int gdv_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
GDVContext *gdv = avctx->priv_data;
GetByteContext *gb = &gdv->gb;
PutByteContext *pb = &gdv->pb;
AVFrame *frame = data;
int ret, i, pal_size;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size);
int compression;
unsigned flags;
uint8_t *dst;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
if (pal && pal_size == AVPALETTE_SIZE)
memcpy(gdv->pal, pal, AVPALETTE_SIZE);
bytestream2_init(gb, avpkt->data, avpkt->size);
bytestream2_init_writer(pb, gdv->frame, gdv->frame_size);
flags = bytestream2_get_le32(gb);
compression = flags & 0xF;
rescale(gdv, gdv->frame, avctx->width, avctx->height,
!!(flags & 0x10), !!(flags & 0x20));
switch (compression) {
case 1:
memset(gdv->frame + PREAMBLE_SIZE, 0, gdv->frame_size - PREAMBLE_SIZE);
case 0:
if (bytestream2_get_bytes_left(gb) < 256*3)
return AVERROR_INVALIDDATA;
for (i = 0; i < 256; i++) {
unsigned r = bytestream2_get_byte(gb);
unsigned g = bytestream2_get_byte(gb);
unsigned b = bytestream2_get_byte(gb);
gdv->pal[i] = 0xFFU << 24 | r << 18 | g << 10 | b << 2;
}
break;
case 2:
ret = decompress_2(avctx);
break;
case 3:
break;
case 5:
ret = decompress_5(avctx, flags >> 8);
break;
case 6:
ret = decompress_68(avctx, flags >> 8, 0);
break;
case 8:
ret = decompress_68(avctx, flags >> 8, 1);
break;
default:
return AVERROR_INVALIDDATA;
}
memcpy(frame->data[1], gdv->pal, AVPALETTE_SIZE);
dst = frame->data[0];
if (!gdv->scale_v && !gdv->scale_h) {
int sidx = PREAMBLE_SIZE, didx = 0;
int y, x;
for (y = 0; y < avctx->height; y++) {
for (x = 0; x < avctx->width; x++) {
dst[x+didx] = gdv->frame[x+sidx];
}
sidx += avctx->width;
didx += frame->linesize[0];
}
} else {
int sidx = PREAMBLE_SIZE, didx = 0;
int y, x;
for (y = 0; y < avctx->height; y++) {
if (!gdv->scale_v) {
for (x = 0; x < avctx->width; x++) {
dst[didx + x] = gdv->frame[sidx + x];
}
} else {
for (x = 0; x < avctx->width; x++) {
dst[didx + x] = gdv->frame[sidx + x/2];
}
}
if (!gdv->scale_h || ((y & 1) == 1)) {
sidx += !gdv->scale_v ? avctx->width : avctx->width/2;
}
didx += frame->linesize[0];
}
}
*got_frame = 1;
return ret < 0 ? ret : avpkt->size;
}
| {
"code": [
" if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)",
" return ret;",
" if (pal && pal_size == AVPALETTE_SIZE)",
" memcpy(gdv->pal, pal, AVPALETTE_SIZE);",
" return AVERROR_INVALIDDATA;"
],
"line_no": [
27,
29,
31,
33,
111
]
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{
GDVContext *gdv = VAR_0->priv_data;
GetByteContext *gb = &gdv->gb;
PutByteContext *pb = &gdv->pb;
AVFrame *frame = VAR_1;
int VAR_4, VAR_5, VAR_6;
const uint8_t *VAR_7 = av_packet_get_side_data(VAR_3, AV_PKT_DATA_PALETTE, &VAR_6);
int VAR_8;
unsigned VAR_9;
uint8_t *dst;
if ((VAR_4 = ff_get_buffer(VAR_0, frame, 0)) < 0)
return VAR_4;
if (VAR_7 && VAR_6 == AVPALETTE_SIZE)
memcpy(gdv->VAR_7, VAR_7, AVPALETTE_SIZE);
bytestream2_init(gb, VAR_3->VAR_1, VAR_3->size);
bytestream2_init_writer(pb, gdv->frame, gdv->frame_size);
VAR_9 = bytestream2_get_le32(gb);
VAR_8 = VAR_9 & 0xF;
rescale(gdv, gdv->frame, VAR_0->width, VAR_0->height,
!!(VAR_9 & 0x10), !!(VAR_9 & 0x20));
switch (VAR_8) {
case 1:
memset(gdv->frame + PREAMBLE_SIZE, 0, gdv->frame_size - PREAMBLE_SIZE);
case 0:
if (bytestream2_get_bytes_left(gb) < 256*3)
return AVERROR_INVALIDDATA;
for (VAR_5 = 0; VAR_5 < 256; VAR_5++) {
unsigned VAR_10 = bytestream2_get_byte(gb);
unsigned VAR_11 = bytestream2_get_byte(gb);
unsigned VAR_12 = bytestream2_get_byte(gb);
gdv->VAR_7[VAR_5] = 0xFFU << 24 | VAR_10 << 18 | VAR_11 << 10 | VAR_12 << 2;
}
break;
case 2:
VAR_4 = decompress_2(VAR_0);
break;
case 3:
break;
case 5:
VAR_4 = decompress_5(VAR_0, VAR_9 >> 8);
break;
case 6:
VAR_4 = decompress_68(VAR_0, VAR_9 >> 8, 0);
break;
case 8:
VAR_4 = decompress_68(VAR_0, VAR_9 >> 8, 1);
break;
default:
return AVERROR_INVALIDDATA;
}
memcpy(frame->VAR_1[1], gdv->VAR_7, AVPALETTE_SIZE);
dst = frame->VAR_1[0];
if (!gdv->scale_v && !gdv->scale_h) {
int VAR_17 = PREAMBLE_SIZE, VAR_17 = 0;
int VAR_17, VAR_17;
for (VAR_17 = 0; VAR_17 < VAR_0->height; VAR_17++) {
for (VAR_17 = 0; VAR_17 < VAR_0->width; VAR_17++) {
dst[VAR_17+VAR_17] = gdv->frame[VAR_17+VAR_17];
}
VAR_17 += VAR_0->width;
VAR_17 += frame->linesize[0];
}
} else {
int VAR_17 = PREAMBLE_SIZE, VAR_17 = 0;
int VAR_17, VAR_17;
for (VAR_17 = 0; VAR_17 < VAR_0->height; VAR_17++) {
if (!gdv->scale_v) {
for (VAR_17 = 0; VAR_17 < VAR_0->width; VAR_17++) {
dst[VAR_17 + VAR_17] = gdv->frame[VAR_17 + VAR_17];
}
} else {
for (VAR_17 = 0; VAR_17 < VAR_0->width; VAR_17++) {
dst[VAR_17 + VAR_17] = gdv->frame[VAR_17 + VAR_17/2];
}
}
if (!gdv->scale_h || ((VAR_17 & 1) == 1)) {
VAR_17 += !gdv->scale_v ? VAR_0->width : VAR_0->width/2;
}
VAR_17 += frame->linesize[0];
}
}
*VAR_2 = 1;
return VAR_4 < 0 ? VAR_4 : VAR_3->size;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{",
"GDVContext *gdv = VAR_0->priv_data;",
"GetByteContext *gb = &gdv->gb;",
"PutByteContext *pb = &gdv->pb;",
"AVFrame *frame = VAR_1;",
"int VAR_4, VAR_5, VAR_6;",
"const uint8_t *VAR_7 = av_packet_get_side_data(VAR_3, AV_PKT_DATA_PALETTE, &VAR_6);",
"int VAR_8;",
"unsigned VAR_9;",
"uint8_t *dst;",
"if ((VAR_4 = ff_get_buffer(VAR_0, frame, 0)) < 0)\nreturn VAR_4;",
"if (VAR_7 && VAR_6 == AVPALETTE_SIZE)\nmemcpy(gdv->VAR_7, VAR_7, AVPALETTE_SIZE);",
"bytestream2_init(gb, VAR_3->VAR_1, VAR_3->size);",
"bytestream2_init_writer(pb, gdv->frame, gdv->frame_size);",
"VAR_9 = bytestream2_get_le32(gb);",
"VAR_8 = VAR_9 & 0xF;",
"rescale(gdv, gdv->frame, VAR_0->width, VAR_0->height,\n!!(VAR_9 & 0x10), !!(VAR_9 & 0x20));",
"switch (VAR_8) {",
"case 1:\nmemset(gdv->frame + PREAMBLE_SIZE, 0, gdv->frame_size - PREAMBLE_SIZE);",
"case 0:\nif (bytestream2_get_bytes_left(gb) < 256*3)\nreturn AVERROR_INVALIDDATA;",
"for (VAR_5 = 0; VAR_5 < 256; VAR_5++) {",
"unsigned VAR_10 = bytestream2_get_byte(gb);",
"unsigned VAR_11 = bytestream2_get_byte(gb);",
"unsigned VAR_12 = bytestream2_get_byte(gb);",
"gdv->VAR_7[VAR_5] = 0xFFU << 24 | VAR_10 << 18 | VAR_11 << 10 | VAR_12 << 2;",
"}",
"break;",
"case 2:\nVAR_4 = decompress_2(VAR_0);",
"break;",
"case 3:\nbreak;",
"case 5:\nVAR_4 = decompress_5(VAR_0, VAR_9 >> 8);",
"break;",
"case 6:\nVAR_4 = decompress_68(VAR_0, VAR_9 >> 8, 0);",
"break;",
"case 8:\nVAR_4 = decompress_68(VAR_0, VAR_9 >> 8, 1);",
"break;",
"default:\nreturn AVERROR_INVALIDDATA;",
"}",
"memcpy(frame->VAR_1[1], gdv->VAR_7, AVPALETTE_SIZE);",
"dst = frame->VAR_1[0];",
"if (!gdv->scale_v && !gdv->scale_h) {",
"int VAR_17 = PREAMBLE_SIZE, VAR_17 = 0;",
"int VAR_17, VAR_17;",
"for (VAR_17 = 0; VAR_17 < VAR_0->height; VAR_17++) {",
"for (VAR_17 = 0; VAR_17 < VAR_0->width; VAR_17++) {",
"dst[VAR_17+VAR_17] = gdv->frame[VAR_17+VAR_17];",
"}",
"VAR_17 += VAR_0->width;",
"VAR_17 += frame->linesize[0];",
"}",
"} else {",
"int VAR_17 = PREAMBLE_SIZE, VAR_17 = 0;",
"int VAR_17, VAR_17;",
"for (VAR_17 = 0; VAR_17 < VAR_0->height; VAR_17++) {",
"if (!gdv->scale_v) {",
"for (VAR_17 = 0; VAR_17 < VAR_0->width; VAR_17++) {",
"dst[VAR_17 + VAR_17] = gdv->frame[VAR_17 + VAR_17];",
"}",
"} else {",
"for (VAR_17 = 0; VAR_17 < VAR_0->width; VAR_17++) {",
"dst[VAR_17 + VAR_17] = gdv->frame[VAR_17 + VAR_17/2];",
"}",
"}",
"if (!gdv->scale_h || ((VAR_17 & 1) == 1)) {",
"VAR_17 += !gdv->scale_v ? VAR_0->width : VAR_0->width/2;",
"}",
"VAR_17 += frame->linesize[0];",
"}",
"}",
"*VAR_2 = 1;",
"return VAR_4 < 0 ? VAR_4 : VAR_3->size;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27,
29
],
[
31,
33
],
[
37
],
[
39
],
[
43
],
[
45
],
[
49,
51
],
[
55
],
[
57,
59
],
[
61,
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81,
83
],
[
85
],
[
87,
89
],
[
91,
93
],
[
95
],
[
97,
99
],
[
101
],
[
103,
105
],
[
107
],
[
109,
111
],
[
113
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
187
],
[
191
],
[
193
]
] |
26,097 | int ff_rle_encode(uint8_t *outbuf, int out_size, const uint8_t *ptr , int bpp, int w,
int add_rep, int xor_rep, int add_raw, int xor_raw)
{
int count, x;
uint8_t *out = outbuf;
for(x = 0; x < w; x += count) {
/* see if we can encode the next set of pixels with RLE */
if((count = count_pixels(ptr, w-x, bpp, 1)) > 1) {
if(out + bpp + 1 > outbuf + out_size) return -1;
*out++ = (count ^ xor_rep) + add_rep;
memcpy(out, ptr, bpp);
out += bpp;
} else {
/* fall back on uncompressed */
count = count_pixels(ptr, w-x, bpp, 0);
*out++ = (count ^ xor_raw) + add_raw;
if(out + bpp*count > outbuf + out_size) return -1;
memcpy(out, ptr, bpp * count);
out += bpp * count;
}
ptr += count * bpp;
}
return out - outbuf;
}
| false | FFmpeg | 0afdedcafb4d524abfe2c958f17aafe4f1ab8d9a | int ff_rle_encode(uint8_t *outbuf, int out_size, const uint8_t *ptr , int bpp, int w,
int add_rep, int xor_rep, int add_raw, int xor_raw)
{
int count, x;
uint8_t *out = outbuf;
for(x = 0; x < w; x += count) {
if((count = count_pixels(ptr, w-x, bpp, 1)) > 1) {
if(out + bpp + 1 > outbuf + out_size) return -1;
*out++ = (count ^ xor_rep) + add_rep;
memcpy(out, ptr, bpp);
out += bpp;
} else {
count = count_pixels(ptr, w-x, bpp, 0);
*out++ = (count ^ xor_raw) + add_raw;
if(out + bpp*count > outbuf + out_size) return -1;
memcpy(out, ptr, bpp * count);
out += bpp * count;
}
ptr += count * bpp;
}
return out - outbuf;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(uint8_t *VAR_0, int VAR_1, const uint8_t *VAR_2 , int VAR_3, int VAR_4,
int VAR_5, int VAR_6, int VAR_7, int VAR_8)
{
int VAR_9, VAR_10;
uint8_t *out = VAR_0;
for(VAR_10 = 0; VAR_10 < VAR_4; VAR_10 += VAR_9) {
if((VAR_9 = count_pixels(VAR_2, VAR_4-VAR_10, VAR_3, 1)) > 1) {
if(out + VAR_3 + 1 > VAR_0 + VAR_1) return -1;
*out++ = (VAR_9 ^ VAR_6) + VAR_5;
memcpy(out, VAR_2, VAR_3);
out += VAR_3;
} else {
VAR_9 = count_pixels(VAR_2, VAR_4-VAR_10, VAR_3, 0);
*out++ = (VAR_9 ^ VAR_8) + VAR_7;
if(out + VAR_3*VAR_9 > VAR_0 + VAR_1) return -1;
memcpy(out, VAR_2, VAR_3 * VAR_9);
out += VAR_3 * VAR_9;
}
VAR_2 += VAR_9 * VAR_3;
}
return out - VAR_0;
}
| [
"int FUNC_0(uint8_t *VAR_0, int VAR_1, const uint8_t *VAR_2 , int VAR_3, int VAR_4,\nint VAR_5, int VAR_6, int VAR_7, int VAR_8)\n{",
"int VAR_9, VAR_10;",
"uint8_t *out = VAR_0;",
"for(VAR_10 = 0; VAR_10 < VAR_4; VAR_10 += VAR_9) {",
"if((VAR_9 = count_pixels(VAR_2, VAR_4-VAR_10, VAR_3, 1)) > 1) {",
"if(out + VAR_3 + 1 > VAR_0 + VAR_1) return -1;",
"*out++ = (VAR_9 ^ VAR_6) + VAR_5;",
"memcpy(out, VAR_2, VAR_3);",
"out += VAR_3;",
"} else {",
"VAR_9 = count_pixels(VAR_2, VAR_4-VAR_10, VAR_3, 0);",
"*out++ = (VAR_9 ^ VAR_8) + VAR_7;",
"if(out + VAR_3*VAR_9 > VAR_0 + VAR_1) return -1;",
"memcpy(out, VAR_2, VAR_3 * VAR_9);",
"out += VAR_3 * VAR_9;",
"}",
"VAR_2 += VAR_9 * VAR_3;",
"}",
"return out - 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
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
53
],
[
55
]
] |
26,098 | static void stream_component_close(VideoState *is, int stream_index)
{
AVFormatContext *ic = is->ic;
AVCodecContext *avctx;
if (stream_index < 0 || stream_index >= ic->nb_streams)
return;
avctx = ic->streams[stream_index]->codec;
switch (avctx->codec_type) {
case AVMEDIA_TYPE_AUDIO:
packet_queue_abort(&is->audioq);
SDL_CloseAudio();
packet_queue_flush(&is->audioq);
av_free_packet(&is->audio_pkt);
if (is->swr_ctx)
swr_free(&is->swr_ctx);
av_freep(&is->audio_buf1);
is->audio_buf = NULL;
av_freep(&is->frame);
if (is->rdft) {
av_rdft_end(is->rdft);
av_freep(&is->rdft_data);
is->rdft = NULL;
is->rdft_bits = 0;
}
break;
case AVMEDIA_TYPE_VIDEO:
packet_queue_abort(&is->videoq);
/* note: we also signal this mutex to make sure we deblock the
video thread in all cases */
SDL_LockMutex(is->pictq_mutex);
SDL_CondSignal(is->pictq_cond);
SDL_UnlockMutex(is->pictq_mutex);
SDL_WaitThread(is->video_tid, NULL);
packet_queue_flush(&is->videoq);
break;
case AVMEDIA_TYPE_SUBTITLE:
packet_queue_abort(&is->subtitleq);
/* note: we also signal this mutex to make sure we deblock the
video thread in all cases */
SDL_LockMutex(is->subpq_mutex);
is->subtitle_stream_changed = 1;
SDL_CondSignal(is->subpq_cond);
SDL_UnlockMutex(is->subpq_mutex);
SDL_WaitThread(is->subtitle_tid, NULL);
packet_queue_flush(&is->subtitleq);
break;
default:
break;
}
ic->streams[stream_index]->discard = AVDISCARD_ALL;
avcodec_close(avctx);
#if CONFIG_AVFILTER
free_buffer_pool(&is->buffer_pool);
#endif
switch (avctx->codec_type) {
case AVMEDIA_TYPE_AUDIO:
is->audio_st = NULL;
is->audio_stream = -1;
break;
case AVMEDIA_TYPE_VIDEO:
is->video_st = NULL;
is->video_stream = -1;
break;
case AVMEDIA_TYPE_SUBTITLE:
is->subtitle_st = NULL;
is->subtitle_stream = -1;
break;
default:
break;
}
}
| false | FFmpeg | 4fd07b9366fb2f74b6af0dea8092d6bafa38f131 | static void stream_component_close(VideoState *is, int stream_index)
{
AVFormatContext *ic = is->ic;
AVCodecContext *avctx;
if (stream_index < 0 || stream_index >= ic->nb_streams)
return;
avctx = ic->streams[stream_index]->codec;
switch (avctx->codec_type) {
case AVMEDIA_TYPE_AUDIO:
packet_queue_abort(&is->audioq);
SDL_CloseAudio();
packet_queue_flush(&is->audioq);
av_free_packet(&is->audio_pkt);
if (is->swr_ctx)
swr_free(&is->swr_ctx);
av_freep(&is->audio_buf1);
is->audio_buf = NULL;
av_freep(&is->frame);
if (is->rdft) {
av_rdft_end(is->rdft);
av_freep(&is->rdft_data);
is->rdft = NULL;
is->rdft_bits = 0;
}
break;
case AVMEDIA_TYPE_VIDEO:
packet_queue_abort(&is->videoq);
SDL_LockMutex(is->pictq_mutex);
SDL_CondSignal(is->pictq_cond);
SDL_UnlockMutex(is->pictq_mutex);
SDL_WaitThread(is->video_tid, NULL);
packet_queue_flush(&is->videoq);
break;
case AVMEDIA_TYPE_SUBTITLE:
packet_queue_abort(&is->subtitleq);
SDL_LockMutex(is->subpq_mutex);
is->subtitle_stream_changed = 1;
SDL_CondSignal(is->subpq_cond);
SDL_UnlockMutex(is->subpq_mutex);
SDL_WaitThread(is->subtitle_tid, NULL);
packet_queue_flush(&is->subtitleq);
break;
default:
break;
}
ic->streams[stream_index]->discard = AVDISCARD_ALL;
avcodec_close(avctx);
#if CONFIG_AVFILTER
free_buffer_pool(&is->buffer_pool);
#endif
switch (avctx->codec_type) {
case AVMEDIA_TYPE_AUDIO:
is->audio_st = NULL;
is->audio_stream = -1;
break;
case AVMEDIA_TYPE_VIDEO:
is->video_st = NULL;
is->video_stream = -1;
break;
case AVMEDIA_TYPE_SUBTITLE:
is->subtitle_st = NULL;
is->subtitle_stream = -1;
break;
default:
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(VideoState *VAR_0, int VAR_1)
{
AVFormatContext *ic = VAR_0->ic;
AVCodecContext *avctx;
if (VAR_1 < 0 || VAR_1 >= ic->nb_streams)
return;
avctx = ic->streams[VAR_1]->codec;
switch (avctx->codec_type) {
case AVMEDIA_TYPE_AUDIO:
packet_queue_abort(&VAR_0->audioq);
SDL_CloseAudio();
packet_queue_flush(&VAR_0->audioq);
av_free_packet(&VAR_0->audio_pkt);
if (VAR_0->swr_ctx)
swr_free(&VAR_0->swr_ctx);
av_freep(&VAR_0->audio_buf1);
VAR_0->audio_buf = NULL;
av_freep(&VAR_0->frame);
if (VAR_0->rdft) {
av_rdft_end(VAR_0->rdft);
av_freep(&VAR_0->rdft_data);
VAR_0->rdft = NULL;
VAR_0->rdft_bits = 0;
}
break;
case AVMEDIA_TYPE_VIDEO:
packet_queue_abort(&VAR_0->videoq);
SDL_LockMutex(VAR_0->pictq_mutex);
SDL_CondSignal(VAR_0->pictq_cond);
SDL_UnlockMutex(VAR_0->pictq_mutex);
SDL_WaitThread(VAR_0->video_tid, NULL);
packet_queue_flush(&VAR_0->videoq);
break;
case AVMEDIA_TYPE_SUBTITLE:
packet_queue_abort(&VAR_0->subtitleq);
SDL_LockMutex(VAR_0->subpq_mutex);
VAR_0->subtitle_stream_changed = 1;
SDL_CondSignal(VAR_0->subpq_cond);
SDL_UnlockMutex(VAR_0->subpq_mutex);
SDL_WaitThread(VAR_0->subtitle_tid, NULL);
packet_queue_flush(&VAR_0->subtitleq);
break;
default:
break;
}
ic->streams[VAR_1]->discard = AVDISCARD_ALL;
avcodec_close(avctx);
#if CONFIG_AVFILTER
free_buffer_pool(&VAR_0->buffer_pool);
#endif
switch (avctx->codec_type) {
case AVMEDIA_TYPE_AUDIO:
VAR_0->audio_st = NULL;
VAR_0->audio_stream = -1;
break;
case AVMEDIA_TYPE_VIDEO:
VAR_0->video_st = NULL;
VAR_0->video_stream = -1;
break;
case AVMEDIA_TYPE_SUBTITLE:
VAR_0->subtitle_st = NULL;
VAR_0->subtitle_stream = -1;
break;
default:
break;
}
}
| [
"static void FUNC_0(VideoState *VAR_0, int VAR_1)\n{",
"AVFormatContext *ic = VAR_0->ic;",
"AVCodecContext *avctx;",
"if (VAR_1 < 0 || VAR_1 >= ic->nb_streams)\nreturn;",
"avctx = ic->streams[VAR_1]->codec;",
"switch (avctx->codec_type) {",
"case AVMEDIA_TYPE_AUDIO:\npacket_queue_abort(&VAR_0->audioq);",
"SDL_CloseAudio();",
"packet_queue_flush(&VAR_0->audioq);",
"av_free_packet(&VAR_0->audio_pkt);",
"if (VAR_0->swr_ctx)\nswr_free(&VAR_0->swr_ctx);",
"av_freep(&VAR_0->audio_buf1);",
"VAR_0->audio_buf = NULL;",
"av_freep(&VAR_0->frame);",
"if (VAR_0->rdft) {",
"av_rdft_end(VAR_0->rdft);",
"av_freep(&VAR_0->rdft_data);",
"VAR_0->rdft = NULL;",
"VAR_0->rdft_bits = 0;",
"}",
"break;",
"case AVMEDIA_TYPE_VIDEO:\npacket_queue_abort(&VAR_0->videoq);",
"SDL_LockMutex(VAR_0->pictq_mutex);",
"SDL_CondSignal(VAR_0->pictq_cond);",
"SDL_UnlockMutex(VAR_0->pictq_mutex);",
"SDL_WaitThread(VAR_0->video_tid, NULL);",
"packet_queue_flush(&VAR_0->videoq);",
"break;",
"case AVMEDIA_TYPE_SUBTITLE:\npacket_queue_abort(&VAR_0->subtitleq);",
"SDL_LockMutex(VAR_0->subpq_mutex);",
"VAR_0->subtitle_stream_changed = 1;",
"SDL_CondSignal(VAR_0->subpq_cond);",
"SDL_UnlockMutex(VAR_0->subpq_mutex);",
"SDL_WaitThread(VAR_0->subtitle_tid, NULL);",
"packet_queue_flush(&VAR_0->subtitleq);",
"break;",
"default:\nbreak;",
"}",
"ic->streams[VAR_1]->discard = AVDISCARD_ALL;",
"avcodec_close(avctx);",
"#if CONFIG_AVFILTER\nfree_buffer_pool(&VAR_0->buffer_pool);",
"#endif\nswitch (avctx->codec_type) {",
"case AVMEDIA_TYPE_AUDIO:\nVAR_0->audio_st = NULL;",
"VAR_0->audio_stream = -1;",
"break;",
"case AVMEDIA_TYPE_VIDEO:\nVAR_0->video_st = NULL;",
"VAR_0->video_stream = -1;",
"break;",
"case AVMEDIA_TYPE_SUBTITLE:\nVAR_0->subtitle_st = NULL;",
"VAR_0->subtitle_stream = -1;",
"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,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
15
],
[
19
],
[
21,
23
],
[
27
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[
71
],
[
73
],
[
75
],
[
79
],
[
83
],
[
85
],
[
87,
89
],
[
97
],
[
99
],
[
103
],
[
105
],
[
109
],
[
113
],
[
115
],
[
117,
119
],
[
121
],
[
125
],
[
127
],
[
129,
131
],
[
133,
135
],
[
137,
139
],
[
141
],
[
143
],
[
145,
147
],
[
149
],
[
151
],
[
153,
155
],
[
157
],
[
159
],
[
161,
163
],
[
165
],
[
167
]
] |
26,099 | static inline int mpeg1_decode_block_inter(MpegEncContext *s, int16_t *block, int n)
{
int level, i, j, run;
RLTable *rl = &ff_rl_mpeg1;
uint8_t * const scantable = s->intra_scantable.permutated;
const uint16_t *quant_matrix = s->inter_matrix;
const int qscale = s->qscale;
{
OPEN_READER(re, &s->gb);
i = -1;
// special case for first coefficient, no need to add second VLC table
UPDATE_CACHE(re, &s->gb);
if (((int32_t)GET_CACHE(re, &s->gb)) < 0) {
level = (3 * qscale * quant_matrix[0]) >> 5;
level = (level - 1) | 1;
if (GET_CACHE(re, &s->gb) & 0x40000000)
level = -level;
block[0] = level;
i++;
SKIP_BITS(re, &s->gb, 2);
if (((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
goto end;
}
/* now quantify & encode AC coefficients */
for (;;) {
GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
if (level != 0) {
i += run;
j = scantable[i];
level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
level = (level - 1) | 1;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
SKIP_BITS(re, &s->gb, 1);
} else {
/* escape */
run = SHOW_UBITS(re, &s->gb, 6) + 1; LAST_SKIP_BITS(re, &s->gb, 6);
UPDATE_CACHE(re, &s->gb);
level = SHOW_SBITS(re, &s->gb, 8); SKIP_BITS(re, &s->gb, 8);
if (level == -128) {
level = SHOW_UBITS(re, &s->gb, 8) - 256; SKIP_BITS(re, &s->gb, 8);
} else if (level == 0) {
level = SHOW_UBITS(re, &s->gb, 8) ; SKIP_BITS(re, &s->gb, 8);
}
i += run;
j = scantable[i];
if (level < 0) {
level = -level;
level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
level = (level - 1) | 1;
level = -level;
} else {
level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
level = (level - 1) | 1;
}
}
if (i > 63) {
av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
block[j] = level;
if (((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
break;
UPDATE_CACHE(re, &s->gb);
}
end:
LAST_SKIP_BITS(re, &s->gb, 2);
CLOSE_READER(re, &s->gb);
}
s->block_last_index[n] = i;
return 0;
}
| true | FFmpeg | 6d93307f8df81808f0dcdbc064b848054a6e83b3 | static inline int mpeg1_decode_block_inter(MpegEncContext *s, int16_t *block, int n)
{
int level, i, j, run;
RLTable *rl = &ff_rl_mpeg1;
uint8_t * const scantable = s->intra_scantable.permutated;
const uint16_t *quant_matrix = s->inter_matrix;
const int qscale = s->qscale;
{
OPEN_READER(re, &s->gb);
i = -1;
UPDATE_CACHE(re, &s->gb);
if (((int32_t)GET_CACHE(re, &s->gb)) < 0) {
level = (3 * qscale * quant_matrix[0]) >> 5;
level = (level - 1) | 1;
if (GET_CACHE(re, &s->gb) & 0x40000000)
level = -level;
block[0] = level;
i++;
SKIP_BITS(re, &s->gb, 2);
if (((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
goto end;
}
for (;;) {
GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
if (level != 0) {
i += run;
j = scantable[i];
level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
level = (level - 1) | 1;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
SKIP_BITS(re, &s->gb, 1);
} else {
run = SHOW_UBITS(re, &s->gb, 6) + 1; LAST_SKIP_BITS(re, &s->gb, 6);
UPDATE_CACHE(re, &s->gb);
level = SHOW_SBITS(re, &s->gb, 8); SKIP_BITS(re, &s->gb, 8);
if (level == -128) {
level = SHOW_UBITS(re, &s->gb, 8) - 256; SKIP_BITS(re, &s->gb, 8);
} else if (level == 0) {
level = SHOW_UBITS(re, &s->gb, 8) ; SKIP_BITS(re, &s->gb, 8);
}
i += run;
j = scantable[i];
if (level < 0) {
level = -level;
level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
level = (level - 1) | 1;
level = -level;
} else {
level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
level = (level - 1) | 1;
}
}
if (i > 63) {
av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
block[j] = level;
if (((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
break;
UPDATE_CACHE(re, &s->gb);
}
end:
LAST_SKIP_BITS(re, &s->gb, 2);
CLOSE_READER(re, &s->gb);
}
s->block_last_index[n] = i;
return 0;
}
| {
"code": [
" if (i > 63) {",
" av_log(s->avctx, AV_LOG_ERROR, \"ac-tex damaged at %d %d\\n\", s->mb_x, s->mb_y);",
" return -1;",
" if (i > 63) {",
" av_log(s->avctx, AV_LOG_ERROR, \"ac-tex damaged at %d %d\\n\", s->mb_x, s->mb_y);",
" return -1;",
" if (i > 63) {",
" av_log(s->avctx, AV_LOG_ERROR, \"ac-tex damaged at %d %d\\n\", s->mb_x, s->mb_y);",
" return -1;",
" if (i > 63) {",
" av_log(s->avctx, AV_LOG_ERROR, \"ac-tex damaged at %d %d\\n\", s->mb_x, s->mb_y);",
" return -1;"
],
"line_no": [
115,
117,
119,
115,
117,
119,
115,
117,
119,
115,
117,
119
]
} | static inline int FUNC_0(MpegEncContext *VAR_0, int16_t *VAR_1, int VAR_2)
{
int VAR_3, VAR_4, VAR_5, VAR_6;
RLTable *rl = &ff_rl_mpeg1;
uint8_t * const scantable = VAR_0->intra_scantable.permutated;
const uint16_t *VAR_7 = VAR_0->inter_matrix;
const int VAR_8 = VAR_0->VAR_8;
{
OPEN_READER(re, &VAR_0->gb);
VAR_4 = -1;
UPDATE_CACHE(re, &VAR_0->gb);
if (((int32_t)GET_CACHE(re, &VAR_0->gb)) < 0) {
VAR_3 = (3 * VAR_8 * VAR_7[0]) >> 5;
VAR_3 = (VAR_3 - 1) | 1;
if (GET_CACHE(re, &VAR_0->gb) & 0x40000000)
VAR_3 = -VAR_3;
VAR_1[0] = VAR_3;
VAR_4++;
SKIP_BITS(re, &VAR_0->gb, 2);
if (((int32_t)GET_CACHE(re, &VAR_0->gb)) <= (int32_t)0xBFFFFFFF)
goto end;
}
for (;;) {
GET_RL_VLC(VAR_3, VAR_6, re, &VAR_0->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
if (VAR_3 != 0) {
VAR_4 += VAR_6;
VAR_5 = scantable[VAR_4];
VAR_3 = ((VAR_3 * 2 + 1) * VAR_8 * VAR_7[VAR_5]) >> 5;
VAR_3 = (VAR_3 - 1) | 1;
VAR_3 = (VAR_3 ^ SHOW_SBITS(re, &VAR_0->gb, 1)) - SHOW_SBITS(re, &VAR_0->gb, 1);
SKIP_BITS(re, &VAR_0->gb, 1);
} else {
VAR_6 = SHOW_UBITS(re, &VAR_0->gb, 6) + 1; LAST_SKIP_BITS(re, &VAR_0->gb, 6);
UPDATE_CACHE(re, &VAR_0->gb);
VAR_3 = SHOW_SBITS(re, &VAR_0->gb, 8); SKIP_BITS(re, &VAR_0->gb, 8);
if (VAR_3 == -128) {
VAR_3 = SHOW_UBITS(re, &VAR_0->gb, 8) - 256; SKIP_BITS(re, &VAR_0->gb, 8);
} else if (VAR_3 == 0) {
VAR_3 = SHOW_UBITS(re, &VAR_0->gb, 8) ; SKIP_BITS(re, &VAR_0->gb, 8);
}
VAR_4 += VAR_6;
VAR_5 = scantable[VAR_4];
if (VAR_3 < 0) {
VAR_3 = -VAR_3;
VAR_3 = ((VAR_3 * 2 + 1) * VAR_8 * VAR_7[VAR_5]) >> 5;
VAR_3 = (VAR_3 - 1) | 1;
VAR_3 = -VAR_3;
} else {
VAR_3 = ((VAR_3 * 2 + 1) * VAR_8 * VAR_7[VAR_5]) >> 5;
VAR_3 = (VAR_3 - 1) | 1;
}
}
if (VAR_4 > 63) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\VAR_2", VAR_0->mb_x, VAR_0->mb_y);
return -1;
}
VAR_1[VAR_5] = VAR_3;
if (((int32_t)GET_CACHE(re, &VAR_0->gb)) <= (int32_t)0xBFFFFFFF)
break;
UPDATE_CACHE(re, &VAR_0->gb);
}
end:
LAST_SKIP_BITS(re, &VAR_0->gb, 2);
CLOSE_READER(re, &VAR_0->gb);
}
VAR_0->block_last_index[VAR_2] = VAR_4;
return 0;
}
| [
"static inline int FUNC_0(MpegEncContext *VAR_0, int16_t *VAR_1, int VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5, VAR_6;",
"RLTable *rl = &ff_rl_mpeg1;",
"uint8_t * const scantable = VAR_0->intra_scantable.permutated;",
"const uint16_t *VAR_7 = VAR_0->inter_matrix;",
"const int VAR_8 = VAR_0->VAR_8;",
"{",
"OPEN_READER(re, &VAR_0->gb);",
"VAR_4 = -1;",
"UPDATE_CACHE(re, &VAR_0->gb);",
"if (((int32_t)GET_CACHE(re, &VAR_0->gb)) < 0) {",
"VAR_3 = (3 * VAR_8 * VAR_7[0]) >> 5;",
"VAR_3 = (VAR_3 - 1) | 1;",
"if (GET_CACHE(re, &VAR_0->gb) & 0x40000000)\nVAR_3 = -VAR_3;",
"VAR_1[0] = VAR_3;",
"VAR_4++;",
"SKIP_BITS(re, &VAR_0->gb, 2);",
"if (((int32_t)GET_CACHE(re, &VAR_0->gb)) <= (int32_t)0xBFFFFFFF)\ngoto end;",
"}",
"for (;;) {",
"GET_RL_VLC(VAR_3, VAR_6, re, &VAR_0->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);",
"if (VAR_3 != 0) {",
"VAR_4 += VAR_6;",
"VAR_5 = scantable[VAR_4];",
"VAR_3 = ((VAR_3 * 2 + 1) * VAR_8 * VAR_7[VAR_5]) >> 5;",
"VAR_3 = (VAR_3 - 1) | 1;",
"VAR_3 = (VAR_3 ^ SHOW_SBITS(re, &VAR_0->gb, 1)) - SHOW_SBITS(re, &VAR_0->gb, 1);",
"SKIP_BITS(re, &VAR_0->gb, 1);",
"} else {",
"VAR_6 = SHOW_UBITS(re, &VAR_0->gb, 6) + 1; LAST_SKIP_BITS(re, &VAR_0->gb, 6);",
"UPDATE_CACHE(re, &VAR_0->gb);",
"VAR_3 = SHOW_SBITS(re, &VAR_0->gb, 8); SKIP_BITS(re, &VAR_0->gb, 8);",
"if (VAR_3 == -128) {",
"VAR_3 = SHOW_UBITS(re, &VAR_0->gb, 8) - 256; SKIP_BITS(re, &VAR_0->gb, 8);",
"} else if (VAR_3 == 0) {",
"VAR_3 = SHOW_UBITS(re, &VAR_0->gb, 8) ; SKIP_BITS(re, &VAR_0->gb, 8);",
"}",
"VAR_4 += VAR_6;",
"VAR_5 = scantable[VAR_4];",
"if (VAR_3 < 0) {",
"VAR_3 = -VAR_3;",
"VAR_3 = ((VAR_3 * 2 + 1) * VAR_8 * VAR_7[VAR_5]) >> 5;",
"VAR_3 = (VAR_3 - 1) | 1;",
"VAR_3 = -VAR_3;",
"} else {",
"VAR_3 = ((VAR_3 * 2 + 1) * VAR_8 * VAR_7[VAR_5]) >> 5;",
"VAR_3 = (VAR_3 - 1) | 1;",
"}",
"}",
"if (VAR_4 > 63) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"ac-tex damaged at %d %d\\VAR_2\", VAR_0->mb_x, VAR_0->mb_y);",
"return -1;",
"}",
"VAR_1[VAR_5] = VAR_3;",
"if (((int32_t)GET_CACHE(re, &VAR_0->gb)) <= (int32_t)0xBFFFFFFF)\nbreak;",
"UPDATE_CACHE(re, &VAR_0->gb);",
"}",
"end:\nLAST_SKIP_BITS(re, &VAR_0->gb, 2);",
"CLOSE_READER(re, &VAR_0->gb);",
"}",
"VAR_0->block_last_index[VAR_2] = VAR_4;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127,
129
],
[
131
],
[
133
],
[
135,
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
]
] |
26,101 | static void vp8_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *curframe,
VP8Frame *prev_frame)
{
VP8Context *s = avctx->priv_data;
int mb_x, mb_y;
s->mv_min.y = -MARGIN;
s->mv_max.y = ((s->mb_height - 1) << 6) + MARGIN;
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
VP8Macroblock *mb = s->macroblocks_base +
((s->mb_width + 1) * (mb_y + 1) + 1);
int mb_xy = mb_y * s->mb_width;
AV_WN32A(s->intra4x4_pred_mode_left, DC_PRED * 0x01010101);
s->mv_min.x = -MARGIN;
s->mv_max.x = ((s->mb_width - 1) << 6) + MARGIN;
for (mb_x = 0; mb_x < s->mb_width; mb_x++, mb_xy++, mb++) {
if (mb_y == 0)
AV_WN32A((mb - s->mb_width - 1)->intra4x4_pred_mode_top,
DC_PRED * 0x01010101);
decode_mb_mode(s, mb, mb_x, mb_y, curframe->seg_map->data + mb_xy,
prev_frame && prev_frame->seg_map ?
prev_frame->seg_map->data + mb_xy : NULL, 1);
s->mv_min.x -= 64;
s->mv_max.x -= 64;
}
s->mv_min.y -= 64;
s->mv_max.y -= 64;
}
}
| true | FFmpeg | ac4b32df71bd932838043a4838b86d11e169707f | static void vp8_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *curframe,
VP8Frame *prev_frame)
{
VP8Context *s = avctx->priv_data;
int mb_x, mb_y;
s->mv_min.y = -MARGIN;
s->mv_max.y = ((s->mb_height - 1) << 6) + MARGIN;
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
VP8Macroblock *mb = s->macroblocks_base +
((s->mb_width + 1) * (mb_y + 1) + 1);
int mb_xy = mb_y * s->mb_width;
AV_WN32A(s->intra4x4_pred_mode_left, DC_PRED * 0x01010101);
s->mv_min.x = -MARGIN;
s->mv_max.x = ((s->mb_width - 1) << 6) + MARGIN;
for (mb_x = 0; mb_x < s->mb_width; mb_x++, mb_xy++, mb++) {
if (mb_y == 0)
AV_WN32A((mb - s->mb_width - 1)->intra4x4_pred_mode_top,
DC_PRED * 0x01010101);
decode_mb_mode(s, mb, mb_x, mb_y, curframe->seg_map->data + mb_xy,
prev_frame && prev_frame->seg_map ?
prev_frame->seg_map->data + mb_xy : NULL, 1);
s->mv_min.x -= 64;
s->mv_max.x -= 64;
}
s->mv_min.y -= 64;
s->mv_max.y -= 64;
}
}
| {
"code": [
"static void vp8_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *curframe,",
" VP8Frame *prev_frame)",
" prev_frame->seg_map->data + mb_xy : NULL, 1);"
],
"line_no": [
1,
3,
47
]
} | static void FUNC_0(AVCodecContext *VAR_0, VP8Frame *VAR_1,
VP8Frame *VAR_2)
{
VP8Context *s = VAR_0->priv_data;
int VAR_3, VAR_4;
s->mv_min.y = -MARGIN;
s->mv_max.y = ((s->mb_height - 1) << 6) + MARGIN;
for (VAR_4 = 0; VAR_4 < s->mb_height; VAR_4++) {
VP8Macroblock *mb = s->macroblocks_base +
((s->mb_width + 1) * (VAR_4 + 1) + 1);
int mb_xy = VAR_4 * s->mb_width;
AV_WN32A(s->intra4x4_pred_mode_left, DC_PRED * 0x01010101);
s->mv_min.x = -MARGIN;
s->mv_max.x = ((s->mb_width - 1) << 6) + MARGIN;
for (VAR_3 = 0; VAR_3 < s->mb_width; VAR_3++, mb_xy++, mb++) {
if (VAR_4 == 0)
AV_WN32A((mb - s->mb_width - 1)->intra4x4_pred_mode_top,
DC_PRED * 0x01010101);
decode_mb_mode(s, mb, VAR_3, VAR_4, VAR_1->seg_map->data + mb_xy,
VAR_2 && VAR_2->seg_map ?
VAR_2->seg_map->data + mb_xy : NULL, 1);
s->mv_min.x -= 64;
s->mv_max.x -= 64;
}
s->mv_min.y -= 64;
s->mv_max.y -= 64;
}
}
| [
"static void FUNC_0(AVCodecContext *VAR_0, VP8Frame *VAR_1,\nVP8Frame *VAR_2)\n{",
"VP8Context *s = VAR_0->priv_data;",
"int VAR_3, VAR_4;",
"s->mv_min.y = -MARGIN;",
"s->mv_max.y = ((s->mb_height - 1) << 6) + MARGIN;",
"for (VAR_4 = 0; VAR_4 < s->mb_height; VAR_4++) {",
"VP8Macroblock *mb = s->macroblocks_base +\n((s->mb_width + 1) * (VAR_4 + 1) + 1);",
"int mb_xy = VAR_4 * s->mb_width;",
"AV_WN32A(s->intra4x4_pred_mode_left, DC_PRED * 0x01010101);",
"s->mv_min.x = -MARGIN;",
"s->mv_max.x = ((s->mb_width - 1) << 6) + MARGIN;",
"for (VAR_3 = 0; VAR_3 < s->mb_width; VAR_3++, mb_xy++, mb++) {",
"if (VAR_4 == 0)\nAV_WN32A((mb - s->mb_width - 1)->intra4x4_pred_mode_top,\nDC_PRED * 0x01010101);",
"decode_mb_mode(s, mb, VAR_3, VAR_4, VAR_1->seg_map->data + mb_xy,\nVAR_2 && VAR_2->seg_map ?\nVAR_2->seg_map->data + mb_xy : NULL, 1);",
"s->mv_min.x -= 64;",
"s->mv_max.x -= 64;",
"}",
"s->mv_min.y -= 64;",
"s->mv_max.y -= 64;",
"}",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37,
39,
41
],
[
43,
45,
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
]
] |
26,102 | static struct omap_eac_s *omap_eac_init(struct omap_target_agent_s *ta,
qemu_irq irq, qemu_irq *drq, omap_clk fclk, omap_clk iclk)
{
struct omap_eac_s *s = (struct omap_eac_s *)
g_malloc0(sizeof(struct omap_eac_s));
s->irq = irq;
s->codec.rxdrq = *drq ++;
s->codec.txdrq = *drq;
omap_eac_reset(s);
AUD_register_card("OMAP EAC", &s->codec.card);
memory_region_init_io(&s->iomem, NULL, &omap_eac_ops, s, "omap.eac",
omap_l4_region_size(ta, 0));
omap_l4_attach(ta, 0, &s->iomem);
return s;
}
| true | qemu | b45c03f585ea9bb1af76c73e82195418c294919d | static struct omap_eac_s *omap_eac_init(struct omap_target_agent_s *ta,
qemu_irq irq, qemu_irq *drq, omap_clk fclk, omap_clk iclk)
{
struct omap_eac_s *s = (struct omap_eac_s *)
g_malloc0(sizeof(struct omap_eac_s));
s->irq = irq;
s->codec.rxdrq = *drq ++;
s->codec.txdrq = *drq;
omap_eac_reset(s);
AUD_register_card("OMAP EAC", &s->codec.card);
memory_region_init_io(&s->iomem, NULL, &omap_eac_ops, s, "omap.eac",
omap_l4_region_size(ta, 0));
omap_l4_attach(ta, 0, &s->iomem);
return s;
}
| {
"code": [
" struct omap_eac_s *s = (struct omap_eac_s *)",
" g_malloc0(sizeof(struct omap_eac_s));"
],
"line_no": [
7,
9
]
} | static struct omap_eac_s *FUNC_0(struct omap_target_agent_s *VAR_0,
qemu_irq VAR_1, qemu_irq *VAR_2, omap_clk VAR_3, omap_clk VAR_4)
{
struct omap_eac_s *VAR_5 = (struct omap_eac_s *)
g_malloc0(sizeof(struct omap_eac_s));
VAR_5->VAR_1 = VAR_1;
VAR_5->codec.rxdrq = *VAR_2 ++;
VAR_5->codec.txdrq = *VAR_2;
omap_eac_reset(VAR_5);
AUD_register_card("OMAP EAC", &VAR_5->codec.card);
memory_region_init_io(&VAR_5->iomem, NULL, &omap_eac_ops, VAR_5, "omap.eac",
omap_l4_region_size(VAR_0, 0));
omap_l4_attach(VAR_0, 0, &VAR_5->iomem);
return VAR_5;
}
| [
"static struct omap_eac_s *FUNC_0(struct omap_target_agent_s *VAR_0,\nqemu_irq VAR_1, qemu_irq *VAR_2, omap_clk VAR_3, omap_clk VAR_4)\n{",
"struct omap_eac_s *VAR_5 = (struct omap_eac_s *)\ng_malloc0(sizeof(struct omap_eac_s));",
"VAR_5->VAR_1 = VAR_1;",
"VAR_5->codec.rxdrq = *VAR_2 ++;",
"VAR_5->codec.txdrq = *VAR_2;",
"omap_eac_reset(VAR_5);",
"AUD_register_card(\"OMAP EAC\", &VAR_5->codec.card);",
"memory_region_init_io(&VAR_5->iomem, NULL, &omap_eac_ops, VAR_5, \"omap.eac\",\nomap_l4_region_size(VAR_0, 0));",
"omap_l4_attach(VAR_0, 0, &VAR_5->iomem);",
"return VAR_5;",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7,
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
27,
29
],
[
31
],
[
35
],
[
37
]
] |
26,103 | bool runstate_needs_reset(void)
{
return runstate_check(RUN_STATE_INTERNAL_ERROR) ||
runstate_check(RUN_STATE_SHUTDOWN) ||
runstate_check(RUN_STATE_GUEST_PANICKED);
}
| true | qemu | df39076850958b842ac9e414dc3ab2895f1877bf | bool runstate_needs_reset(void)
{
return runstate_check(RUN_STATE_INTERNAL_ERROR) ||
runstate_check(RUN_STATE_SHUTDOWN) ||
runstate_check(RUN_STATE_GUEST_PANICKED);
}
| {
"code": [
" runstate_check(RUN_STATE_SHUTDOWN) ||",
" runstate_check(RUN_STATE_GUEST_PANICKED);"
],
"line_no": [
7,
9
]
} | bool FUNC_0(void)
{
return runstate_check(RUN_STATE_INTERNAL_ERROR) ||
runstate_check(RUN_STATE_SHUTDOWN) ||
runstate_check(RUN_STATE_GUEST_PANICKED);
}
| [
"bool FUNC_0(void)\n{",
"return runstate_check(RUN_STATE_INTERNAL_ERROR) ||\nrunstate_check(RUN_STATE_SHUTDOWN) ||\nrunstate_check(RUN_STATE_GUEST_PANICKED);",
"}"
] | [
0,
1,
0
] | [
[
1,
3
],
[
5,
7,
9
],
[
11
]
] |
26,104 | int64_t bdrv_getlength(BlockDriverState *bs)
{
int64_t ret = bdrv_nb_sectors(bs);
return ret < 0 ? ret : ret * BDRV_SECTOR_SIZE;
} | true | qemu | 4a9c9ea0d318bec2f67848c5ceaf4ad5bcb91d09 | int64_t bdrv_getlength(BlockDriverState *bs)
{
int64_t ret = bdrv_nb_sectors(bs);
return ret < 0 ? ret : ret * BDRV_SECTOR_SIZE;
} | {
"code": [],
"line_no": []
} | int64_t FUNC_0(BlockDriverState *bs)
{
int64_t ret = bdrv_nb_sectors(bs);
return ret < 0 ? ret : ret * BDRV_SECTOR_SIZE;
} | [
"int64_t FUNC_0(BlockDriverState *bs)\n{",
"int64_t ret = bdrv_nb_sectors(bs);",
"return ret < 0 ? ret : ret * BDRV_SECTOR_SIZE;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
10
],
[
12
]
] |
26,105 | static av_always_inline void mc_luma_scaled(VP9Context *s, vp9_scaled_mc_func smc,
vp9_mc_func (*mc)[2],
uint8_t *dst, ptrdiff_t dst_stride,
const uint8_t *ref, ptrdiff_t ref_stride,
ThreadFrame *ref_frame,
ptrdiff_t y, ptrdiff_t x, const VP56mv *in_mv,
int px, int py, int pw, int ph,
int bw, int bh, int w, int h, int bytesperpixel,
const uint16_t *scale, const uint8_t *step)
{
if (s->s.frames[CUR_FRAME].tf.f->width == ref_frame->f->width &&
s->s.frames[CUR_FRAME].tf.f->height == ref_frame->f->height) {
mc_luma_unscaled(s, mc, dst, dst_stride, ref, ref_stride, ref_frame,
y, x, in_mv, bw, bh, w, h, bytesperpixel);
} else {
#define scale_mv(n, dim) (((int64_t)(n) * scale[dim]) >> 14)
int mx, my;
int refbw_m1, refbh_m1;
int th;
VP56mv mv;
mv.x = av_clip(in_mv->x, -(x + pw - px + 4) * 8, (s->cols * 8 - x + px + 3) * 8);
mv.y = av_clip(in_mv->y, -(y + ph - py + 4) * 8, (s->rows * 8 - y + py + 3) * 8);
// BUG libvpx seems to scale the two components separately. This introduces
// rounding errors but we have to reproduce them to be exactly compatible
// with the output from libvpx...
mx = scale_mv(mv.x * 2, 0) + scale_mv(x * 16, 0);
my = scale_mv(mv.y * 2, 1) + scale_mv(y * 16, 1);
y = my >> 4;
x = mx >> 4;
ref += y * ref_stride + x * bytesperpixel;
mx &= 15;
my &= 15;
refbw_m1 = ((bw - 1) * step[0] + mx) >> 4;
refbh_m1 = ((bh - 1) * step[1] + my) >> 4;
// FIXME bilinear filter only needs 0/1 pixels, not 3/4
// we use +7 because the last 7 pixels of each sbrow can be changed in
// the longest loopfilter of the next sbrow
th = (y + refbh_m1 + 4 + 7) >> 6;
ff_thread_await_progress(ref_frame, FFMAX(th, 0), 0);
if (x < 3 || y < 3 || x + 4 >= w - refbw_m1 || y + 4 >= h - refbh_m1) {
s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
ref - 3 * ref_stride - 3 * bytesperpixel,
288, ref_stride,
refbw_m1 + 8, refbh_m1 + 8,
x - 3, y - 3, w, h);
ref = s->edge_emu_buffer + 3 * 288 + 3 * bytesperpixel;
ref_stride = 288;
}
smc(dst, dst_stride, ref, ref_stride, bh, mx, my, step[0], step[1]);
}
}
| true | FFmpeg | 68caef9d48c4f1540b1b3181ebe7062a3417c62a | static av_always_inline void mc_luma_scaled(VP9Context *s, vp9_scaled_mc_func smc,
vp9_mc_func (*mc)[2],
uint8_t *dst, ptrdiff_t dst_stride,
const uint8_t *ref, ptrdiff_t ref_stride,
ThreadFrame *ref_frame,
ptrdiff_t y, ptrdiff_t x, const VP56mv *in_mv,
int px, int py, int pw, int ph,
int bw, int bh, int w, int h, int bytesperpixel,
const uint16_t *scale, const uint8_t *step)
{
if (s->s.frames[CUR_FRAME].tf.f->width == ref_frame->f->width &&
s->s.frames[CUR_FRAME].tf.f->height == ref_frame->f->height) {
mc_luma_unscaled(s, mc, dst, dst_stride, ref, ref_stride, ref_frame,
y, x, in_mv, bw, bh, w, h, bytesperpixel);
} else {
#define scale_mv(n, dim) (((int64_t)(n) * scale[dim]) >> 14)
int mx, my;
int refbw_m1, refbh_m1;
int th;
VP56mv mv;
mv.x = av_clip(in_mv->x, -(x + pw - px + 4) * 8, (s->cols * 8 - x + px + 3) * 8);
mv.y = av_clip(in_mv->y, -(y + ph - py + 4) * 8, (s->rows * 8 - y + py + 3) * 8);
mx = scale_mv(mv.x * 2, 0) + scale_mv(x * 16, 0);
my = scale_mv(mv.y * 2, 1) + scale_mv(y * 16, 1);
y = my >> 4;
x = mx >> 4;
ref += y * ref_stride + x * bytesperpixel;
mx &= 15;
my &= 15;
refbw_m1 = ((bw - 1) * step[0] + mx) >> 4;
refbh_m1 = ((bh - 1) * step[1] + my) >> 4;
th = (y + refbh_m1 + 4 + 7) >> 6;
ff_thread_await_progress(ref_frame, FFMAX(th, 0), 0);
if (x < 3 || y < 3 || x + 4 >= w - refbw_m1 || y + 4 >= h - refbh_m1) {
s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
ref - 3 * ref_stride - 3 * bytesperpixel,
288, ref_stride,
refbw_m1 + 8, refbh_m1 + 8,
x - 3, y - 3, w, h);
ref = s->edge_emu_buffer + 3 * 288 + 3 * bytesperpixel;
ref_stride = 288;
}
smc(dst, dst_stride, ref, ref_stride, bh, mx, my, step[0], step[1]);
}
}
| {
"code": [
" if (x < 3 || y < 3 || x + 4 >= w - refbw_m1 || y + 4 >= h - refbh_m1) {",
" if (x < 3 || y < 3 || x + 4 >= w - refbw_m1 || y + 4 >= h - refbh_m1) {"
],
"line_no": [
83,
83
]
} | static av_always_inline void FUNC_0(VP9Context *s, vp9_scaled_mc_func smc,
vp9_mc_func (*mc)[2],
uint8_t *dst, ptrdiff_t dst_stride,
const uint8_t *ref, ptrdiff_t ref_stride,
ThreadFrame *ref_frame,
ptrdiff_t y, ptrdiff_t x, const VP56mv *in_mv,
int px, int py, int pw, int ph,
int bw, int bh, int w, int h, int bytesperpixel,
const uint16_t *scale, const uint8_t *step)
{
if (s->s.frames[CUR_FRAME].tf.f->width == ref_frame->f->width &&
s->s.frames[CUR_FRAME].tf.f->height == ref_frame->f->height) {
mc_luma_unscaled(s, mc, dst, dst_stride, ref, ref_stride, ref_frame,
y, x, in_mv, bw, bh, w, h, bytesperpixel);
} else {
#define scale_mv(n, dim) (((int64_t)(n) * scale[dim]) >> 14)
int VAR_0, VAR_1;
int VAR_2, VAR_3;
int VAR_4;
VP56mv mv;
mv.x = av_clip(in_mv->x, -(x + pw - px + 4) * 8, (s->cols * 8 - x + px + 3) * 8);
mv.y = av_clip(in_mv->y, -(y + ph - py + 4) * 8, (s->rows * 8 - y + py + 3) * 8);
VAR_0 = scale_mv(mv.x * 2, 0) + scale_mv(x * 16, 0);
VAR_1 = scale_mv(mv.y * 2, 1) + scale_mv(y * 16, 1);
y = VAR_1 >> 4;
x = VAR_0 >> 4;
ref += y * ref_stride + x * bytesperpixel;
VAR_0 &= 15;
VAR_1 &= 15;
VAR_2 = ((bw - 1) * step[0] + VAR_0) >> 4;
VAR_3 = ((bh - 1) * step[1] + VAR_1) >> 4;
VAR_4 = (y + VAR_3 + 4 + 7) >> 6;
ff_thread_await_progress(ref_frame, FFMAX(VAR_4, 0), 0);
if (x < 3 || y < 3 || x + 4 >= w - VAR_2 || y + 4 >= h - VAR_3) {
s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
ref - 3 * ref_stride - 3 * bytesperpixel,
288, ref_stride,
VAR_2 + 8, VAR_3 + 8,
x - 3, y - 3, w, h);
ref = s->edge_emu_buffer + 3 * 288 + 3 * bytesperpixel;
ref_stride = 288;
}
smc(dst, dst_stride, ref, ref_stride, bh, VAR_0, VAR_1, step[0], step[1]);
}
}
| [
"static av_always_inline void FUNC_0(VP9Context *s, vp9_scaled_mc_func smc,\nvp9_mc_func (*mc)[2],\nuint8_t *dst, ptrdiff_t dst_stride,\nconst uint8_t *ref, ptrdiff_t ref_stride,\nThreadFrame *ref_frame,\nptrdiff_t y, ptrdiff_t x, const VP56mv *in_mv,\nint px, int py, int pw, int ph,\nint bw, int bh, int w, int h, int bytesperpixel,\nconst uint16_t *scale, const uint8_t *step)\n{",
"if (s->s.frames[CUR_FRAME].tf.f->width == ref_frame->f->width &&\ns->s.frames[CUR_FRAME].tf.f->height == ref_frame->f->height) {",
"mc_luma_unscaled(s, mc, dst, dst_stride, ref, ref_stride, ref_frame,\ny, x, in_mv, bw, bh, w, h, bytesperpixel);",
"} else {",
"#define scale_mv(n, dim) (((int64_t)(n) * scale[dim]) >> 14)\nint VAR_0, VAR_1;",
"int VAR_2, VAR_3;",
"int VAR_4;",
"VP56mv mv;",
"mv.x = av_clip(in_mv->x, -(x + pw - px + 4) * 8, (s->cols * 8 - x + px + 3) * 8);",
"mv.y = av_clip(in_mv->y, -(y + ph - py + 4) * 8, (s->rows * 8 - y + py + 3) * 8);",
"VAR_0 = scale_mv(mv.x * 2, 0) + scale_mv(x * 16, 0);",
"VAR_1 = scale_mv(mv.y * 2, 1) + scale_mv(y * 16, 1);",
"y = VAR_1 >> 4;",
"x = VAR_0 >> 4;",
"ref += y * ref_stride + x * bytesperpixel;",
"VAR_0 &= 15;",
"VAR_1 &= 15;",
"VAR_2 = ((bw - 1) * step[0] + VAR_0) >> 4;",
"VAR_3 = ((bh - 1) * step[1] + VAR_1) >> 4;",
"VAR_4 = (y + VAR_3 + 4 + 7) >> 6;",
"ff_thread_await_progress(ref_frame, FFMAX(VAR_4, 0), 0);",
"if (x < 3 || y < 3 || x + 4 >= w - VAR_2 || y + 4 >= h - VAR_3) {",
"s->vdsp.emulated_edge_mc(s->edge_emu_buffer,\nref - 3 * ref_stride - 3 * bytesperpixel,\n288, ref_stride,\nVAR_2 + 8, VAR_3 + 8,\nx - 3, y - 3, w, h);",
"ref = s->edge_emu_buffer + 3 * 288 + 3 * bytesperpixel;",
"ref_stride = 288;",
"}",
"smc(dst, dst_stride, ref, ref_stride, bh, VAR_0, VAR_1, step[0], step[1]);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13,
15,
17,
19
],
[
21,
23
],
[
25,
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
79
],
[
81
],
[
83
],
[
85,
87,
89,
91,
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
]
] |
26,106 | static void vc1_inv_trans_4x4_c(uint8_t *dest, int linesize, DCTELEM *block)
{
int i;
register int t1,t2,t3,t4;
DCTELEM *src, *dst;
const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
src = block;
dst = block;
for(i = 0; i < 4; i++){
t1 = 17 * (src[0] + src[2]) + 4;
t2 = 17 * (src[0] - src[2]) + 4;
t3 = 22 * src[1] + 10 * src[3];
t4 = 22 * src[3] - 10 * src[1];
dst[0] = (t1 + t3) >> 3;
dst[1] = (t2 - t4) >> 3;
dst[2] = (t2 + t4) >> 3;
dst[3] = (t1 - t3) >> 3;
src += 8;
dst += 8;
}
src = block;
for(i = 0; i < 4; i++){
t1 = 17 * (src[ 0] + src[16]) + 64;
t2 = 17 * (src[ 0] - src[16]) + 64;
t3 = 22 * src[ 8] + 10 * src[24];
t4 = 22 * src[24] - 10 * src[ 8];
dest[0*linesize] = cm[dest[0*linesize] + ((t1 + t3) >> 7)];
dest[1*linesize] = cm[dest[1*linesize] + ((t2 - t4) >> 7)];
dest[2*linesize] = cm[dest[2*linesize] + ((t2 + t4) >> 7)];
dest[3*linesize] = cm[dest[3*linesize] + ((t1 - t3) >> 7)];
src ++;
dest++;
}
}
| true | FFmpeg | c23acbaed40101c677dfcfbbfe0d2c230a8e8f44 | static void vc1_inv_trans_4x4_c(uint8_t *dest, int linesize, DCTELEM *block)
{
int i;
register int t1,t2,t3,t4;
DCTELEM *src, *dst;
const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
src = block;
dst = block;
for(i = 0; i < 4; i++){
t1 = 17 * (src[0] + src[2]) + 4;
t2 = 17 * (src[0] - src[2]) + 4;
t3 = 22 * src[1] + 10 * src[3];
t4 = 22 * src[3] - 10 * src[1];
dst[0] = (t1 + t3) >> 3;
dst[1] = (t2 - t4) >> 3;
dst[2] = (t2 + t4) >> 3;
dst[3] = (t1 - t3) >> 3;
src += 8;
dst += 8;
}
src = block;
for(i = 0; i < 4; i++){
t1 = 17 * (src[ 0] + src[16]) + 64;
t2 = 17 * (src[ 0] - src[16]) + 64;
t3 = 22 * src[ 8] + 10 * src[24];
t4 = 22 * src[24] - 10 * src[ 8];
dest[0*linesize] = cm[dest[0*linesize] + ((t1 + t3) >> 7)];
dest[1*linesize] = cm[dest[1*linesize] + ((t2 - t4) >> 7)];
dest[2*linesize] = cm[dest[2*linesize] + ((t2 + t4) >> 7)];
dest[3*linesize] = cm[dest[3*linesize] + ((t1 - t3) >> 7)];
src ++;
dest++;
}
}
| {
"code": [
" const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" dest[0*linesize] = cm[dest[0*linesize] + ((t1 + t3) >> 7)];",
" dest[1*linesize] = cm[dest[1*linesize] + ((t2 - t4) >> 7)];",
" dest[2*linesize] = cm[dest[2*linesize] + ((t2 + t4) >> 7)];",
" dest[3*linesize] = cm[dest[3*linesize] + ((t1 - t3) >> 7)];",
" const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" dest[0*linesize] = cm[dest[0*linesize] + ((t1 + t3) >> 7)];",
" dest[1*linesize] = cm[dest[1*linesize] + ((t2 - t4) >> 7)];",
" dest[2*linesize] = cm[dest[2*linesize] + ((t2 + t4) >> 7)];",
" dest[3*linesize] = cm[dest[3*linesize] + ((t1 - t3) >> 7)];"
],
"line_no": [
11,
11,
11,
11,
63,
65,
67,
69,
11,
11,
63,
65,
67,
69
]
} | static void FUNC_0(uint8_t *VAR_0, int VAR_1, DCTELEM *VAR_2)
{
int VAR_3;
register int VAR_4,VAR_5,VAR_6,VAR_7;
DCTELEM *src, *dst;
const uint8_t *VAR_8 = ff_cropTbl + MAX_NEG_CROP;
src = VAR_2;
dst = VAR_2;
for(VAR_3 = 0; VAR_3 < 4; VAR_3++){
VAR_4 = 17 * (src[0] + src[2]) + 4;
VAR_5 = 17 * (src[0] - src[2]) + 4;
VAR_6 = 22 * src[1] + 10 * src[3];
VAR_7 = 22 * src[3] - 10 * src[1];
dst[0] = (VAR_4 + VAR_6) >> 3;
dst[1] = (VAR_5 - VAR_7) >> 3;
dst[2] = (VAR_5 + VAR_7) >> 3;
dst[3] = (VAR_4 - VAR_6) >> 3;
src += 8;
dst += 8;
}
src = VAR_2;
for(VAR_3 = 0; VAR_3 < 4; VAR_3++){
VAR_4 = 17 * (src[ 0] + src[16]) + 64;
VAR_5 = 17 * (src[ 0] - src[16]) + 64;
VAR_6 = 22 * src[ 8] + 10 * src[24];
VAR_7 = 22 * src[24] - 10 * src[ 8];
VAR_0[0*VAR_1] = VAR_8[VAR_0[0*VAR_1] + ((VAR_4 + VAR_6) >> 7)];
VAR_0[1*VAR_1] = VAR_8[VAR_0[1*VAR_1] + ((VAR_5 - VAR_7) >> 7)];
VAR_0[2*VAR_1] = VAR_8[VAR_0[2*VAR_1] + ((VAR_5 + VAR_7) >> 7)];
VAR_0[3*VAR_1] = VAR_8[VAR_0[3*VAR_1] + ((VAR_4 - VAR_6) >> 7)];
src ++;
VAR_0++;
}
}
| [
"static void FUNC_0(uint8_t *VAR_0, int VAR_1, DCTELEM *VAR_2)\n{",
"int VAR_3;",
"register int VAR_4,VAR_5,VAR_6,VAR_7;",
"DCTELEM *src, *dst;",
"const uint8_t *VAR_8 = ff_cropTbl + MAX_NEG_CROP;",
"src = VAR_2;",
"dst = VAR_2;",
"for(VAR_3 = 0; VAR_3 < 4; VAR_3++){",
"VAR_4 = 17 * (src[0] + src[2]) + 4;",
"VAR_5 = 17 * (src[0] - src[2]) + 4;",
"VAR_6 = 22 * src[1] + 10 * src[3];",
"VAR_7 = 22 * src[3] - 10 * src[1];",
"dst[0] = (VAR_4 + VAR_6) >> 3;",
"dst[1] = (VAR_5 - VAR_7) >> 3;",
"dst[2] = (VAR_5 + VAR_7) >> 3;",
"dst[3] = (VAR_4 - VAR_6) >> 3;",
"src += 8;",
"dst += 8;",
"}",
"src = VAR_2;",
"for(VAR_3 = 0; VAR_3 < 4; VAR_3++){",
"VAR_4 = 17 * (src[ 0] + src[16]) + 64;",
"VAR_5 = 17 * (src[ 0] - src[16]) + 64;",
"VAR_6 = 22 * src[ 8] + 10 * src[24];",
"VAR_7 = 22 * src[24] - 10 * src[ 8];",
"VAR_0[0*VAR_1] = VAR_8[VAR_0[0*VAR_1] + ((VAR_4 + VAR_6) >> 7)];",
"VAR_0[1*VAR_1] = VAR_8[VAR_0[1*VAR_1] + ((VAR_5 - VAR_7) >> 7)];",
"VAR_0[2*VAR_1] = VAR_8[VAR_0[2*VAR_1] + ((VAR_5 + VAR_7) >> 7)];",
"VAR_0[3*VAR_1] = VAR_8[VAR_0[3*VAR_1] + ((VAR_4 - VAR_6) >> 7)];",
"src ++;",
"VAR_0++;",
"}",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
]
] |
26,107 | long do_rt_sigreturn(CPUSH4State *regs)
{
struct target_rt_sigframe *frame;
abi_ulong frame_addr;
sigset_t blocked;
target_ulong r0;
#if defined(DEBUG_SIGNAL)
fprintf(stderr, "do_rt_sigreturn\n");
#endif
frame_addr = regs->gregs[15];
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
goto badframe;
target_to_host_sigset(&blocked, &frame->uc.tuc_sigmask);
do_sigprocmask(SIG_SETMASK, &blocked, NULL);
if (restore_sigcontext(regs, &frame->uc.tuc_mcontext, &r0))
goto badframe;
if (do_sigaltstack(frame_addr +
offsetof(struct target_rt_sigframe, uc.tuc_stack),
0, get_sp_from_cpustate(regs)) == -EFAULT)
goto badframe;
unlock_user_struct(frame, frame_addr, 0);
return r0;
badframe:
unlock_user_struct(frame, frame_addr, 0);
force_sig(TARGET_SIGSEGV);
return 0;
}
| true | qemu | 016d2e1dfa21b64a524d3629fdd317d4c25bc3b8 | long do_rt_sigreturn(CPUSH4State *regs)
{
struct target_rt_sigframe *frame;
abi_ulong frame_addr;
sigset_t blocked;
target_ulong r0;
#if defined(DEBUG_SIGNAL)
fprintf(stderr, "do_rt_sigreturn\n");
#endif
frame_addr = regs->gregs[15];
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
goto badframe;
target_to_host_sigset(&blocked, &frame->uc.tuc_sigmask);
do_sigprocmask(SIG_SETMASK, &blocked, NULL);
if (restore_sigcontext(regs, &frame->uc.tuc_mcontext, &r0))
goto badframe;
if (do_sigaltstack(frame_addr +
offsetof(struct target_rt_sigframe, uc.tuc_stack),
0, get_sp_from_cpustate(regs)) == -EFAULT)
goto badframe;
unlock_user_struct(frame, frame_addr, 0);
return r0;
badframe:
unlock_user_struct(frame, frame_addr, 0);
force_sig(TARGET_SIGSEGV);
return 0;
}
| {
"code": [
" \tgoto badframe;",
" goto badframe;",
" goto badframe;",
" if (restore_sigcontext(regs, &frame->uc.tuc_mcontext, &r0))",
" goto badframe;",
" goto badframe;",
" goto badframe;",
" goto badframe;"
],
"line_no": [
25,
37,
37,
35,
37,
37,
37,
37
]
} | long FUNC_0(CPUSH4State *VAR_0)
{
struct target_rt_sigframe *VAR_1;
abi_ulong frame_addr;
sigset_t blocked;
target_ulong r0;
#if defined(DEBUG_SIGNAL)
fprintf(stderr, "FUNC_0\n");
#endif
frame_addr = VAR_0->gregs[15];
if (!lock_user_struct(VERIFY_READ, VAR_1, frame_addr, 1))
goto badframe;
target_to_host_sigset(&blocked, &VAR_1->uc.tuc_sigmask);
do_sigprocmask(SIG_SETMASK, &blocked, NULL);
if (restore_sigcontext(VAR_0, &VAR_1->uc.tuc_mcontext, &r0))
goto badframe;
if (do_sigaltstack(frame_addr +
offsetof(struct target_rt_sigframe, uc.tuc_stack),
0, get_sp_from_cpustate(VAR_0)) == -EFAULT)
goto badframe;
unlock_user_struct(VAR_1, frame_addr, 0);
return r0;
badframe:
unlock_user_struct(VAR_1, frame_addr, 0);
force_sig(TARGET_SIGSEGV);
return 0;
}
| [
"long FUNC_0(CPUSH4State *VAR_0)\n{",
"struct target_rt_sigframe *VAR_1;",
"abi_ulong frame_addr;",
"sigset_t blocked;",
"target_ulong r0;",
"#if defined(DEBUG_SIGNAL)\nfprintf(stderr, \"FUNC_0\\n\");",
"#endif\nframe_addr = VAR_0->gregs[15];",
"if (!lock_user_struct(VERIFY_READ, VAR_1, frame_addr, 1))\ngoto badframe;",
"target_to_host_sigset(&blocked, &VAR_1->uc.tuc_sigmask);",
"do_sigprocmask(SIG_SETMASK, &blocked, NULL);",
"if (restore_sigcontext(VAR_0, &VAR_1->uc.tuc_mcontext, &r0))\ngoto badframe;",
"if (do_sigaltstack(frame_addr +\noffsetof(struct target_rt_sigframe, uc.tuc_stack),\n0, get_sp_from_cpustate(VAR_0)) == -EFAULT)\ngoto badframe;",
"unlock_user_struct(VAR_1, frame_addr, 0);",
"return r0;",
"badframe:\nunlock_user_struct(VAR_1, frame_addr, 0);",
"force_sig(TARGET_SIGSEGV);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
19,
21
],
[
23,
25
],
[
29
],
[
31
],
[
35,
37
],
[
41,
43,
45,
47
],
[
51
],
[
53
],
[
57,
59
],
[
61
],
[
63
],
[
65
]
] |
26,108 | int ff_draw_init(FFDrawContext *draw, enum PixelFormat format, unsigned flags)
{
const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[format];
const AVComponentDescriptor *c;
unsigned i, nb_planes = 0;
int pixelstep[MAX_PLANES] = { 0 };
if (!desc->name)
return AVERROR(EINVAL);
if (desc->flags & ~(PIX_FMT_PLANAR | PIX_FMT_RGB))
return AVERROR(ENOSYS);
for (i = 0; i < desc->nb_components; i++) {
c = &desc->comp[i];
/* for now, only 8-bits formats */
if (c->depth_minus1 != 8 - 1)
return AVERROR(ENOSYS);
if (c->plane >= MAX_PLANES)
return AVERROR(ENOSYS);
/* strange interleaving */
if (pixelstep[c->plane] != 0 &&
pixelstep[c->plane] != c->step_minus1 + 1)
return AVERROR(ENOSYS);
pixelstep[c->plane] = c->step_minus1 + 1;
if (pixelstep[c->plane] >= 8)
return AVERROR(ENOSYS);
nb_planes = FFMAX(nb_planes, c->plane + 1);
}
if ((desc->log2_chroma_w || desc->log2_chroma_h) && nb_planes < 3)
return AVERROR(ENOSYS); /* exclude NV12 and NV21 */
memset(draw, 0, sizeof(*draw));
draw->desc = desc;
draw->format = format;
draw->nb_planes = nb_planes;
memcpy(draw->pixelstep, pixelstep, sizeof(draw->pixelstep));
if (nb_planes >= 3 && !(desc->flags & PIX_FMT_RGB)) {
draw->hsub[1] = draw->hsub[2] = draw->hsub_max = desc->log2_chroma_w;
draw->vsub[1] = draw->vsub[2] = draw->vsub_max = desc->log2_chroma_h;
}
for (i = 0; i < ((desc->nb_components - 1) | 1); i++)
draw->comp_mask[desc->comp[i].plane] |=
1 << (desc->comp[i].offset_plus1 - 1);
return 0;
}
| true | FFmpeg | 24eac3cff54a5828ba76bc1ad93b99724cde45c1 | int ff_draw_init(FFDrawContext *draw, enum PixelFormat format, unsigned flags)
{
const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[format];
const AVComponentDescriptor *c;
unsigned i, nb_planes = 0;
int pixelstep[MAX_PLANES] = { 0 };
if (!desc->name)
return AVERROR(EINVAL);
if (desc->flags & ~(PIX_FMT_PLANAR | PIX_FMT_RGB))
return AVERROR(ENOSYS);
for (i = 0; i < desc->nb_components; i++) {
c = &desc->comp[i];
if (c->depth_minus1 != 8 - 1)
return AVERROR(ENOSYS);
if (c->plane >= MAX_PLANES)
return AVERROR(ENOSYS);
if (pixelstep[c->plane] != 0 &&
pixelstep[c->plane] != c->step_minus1 + 1)
return AVERROR(ENOSYS);
pixelstep[c->plane] = c->step_minus1 + 1;
if (pixelstep[c->plane] >= 8)
return AVERROR(ENOSYS);
nb_planes = FFMAX(nb_planes, c->plane + 1);
}
if ((desc->log2_chroma_w || desc->log2_chroma_h) && nb_planes < 3)
return AVERROR(ENOSYS);
memset(draw, 0, sizeof(*draw));
draw->desc = desc;
draw->format = format;
draw->nb_planes = nb_planes;
memcpy(draw->pixelstep, pixelstep, sizeof(draw->pixelstep));
if (nb_planes >= 3 && !(desc->flags & PIX_FMT_RGB)) {
draw->hsub[1] = draw->hsub[2] = draw->hsub_max = desc->log2_chroma_w;
draw->vsub[1] = draw->vsub[2] = draw->vsub_max = desc->log2_chroma_h;
}
for (i = 0; i < ((desc->nb_components - 1) | 1); i++)
draw->comp_mask[desc->comp[i].plane] |=
1 << (desc->comp[i].offset_plus1 - 1);
return 0;
}
| {
"code": [
" if (desc->flags & ~(PIX_FMT_PLANAR | PIX_FMT_RGB))"
],
"line_no": [
19
]
} | int FUNC_0(FFDrawContext *VAR_0, enum PixelFormat VAR_1, unsigned VAR_2)
{
const AVPixFmtDescriptor *VAR_3 = &av_pix_fmt_descriptors[VAR_1];
const AVComponentDescriptor *VAR_4;
unsigned VAR_5, VAR_6 = 0;
int VAR_7[MAX_PLANES] = { 0 };
if (!VAR_3->name)
return AVERROR(EINVAL);
if (VAR_3->VAR_2 & ~(PIX_FMT_PLANAR | PIX_FMT_RGB))
return AVERROR(ENOSYS);
for (VAR_5 = 0; VAR_5 < VAR_3->nb_components; VAR_5++) {
VAR_4 = &VAR_3->comp[VAR_5];
if (VAR_4->depth_minus1 != 8 - 1)
return AVERROR(ENOSYS);
if (VAR_4->plane >= MAX_PLANES)
return AVERROR(ENOSYS);
if (VAR_7[VAR_4->plane] != 0 &&
VAR_7[VAR_4->plane] != VAR_4->step_minus1 + 1)
return AVERROR(ENOSYS);
VAR_7[VAR_4->plane] = VAR_4->step_minus1 + 1;
if (VAR_7[VAR_4->plane] >= 8)
return AVERROR(ENOSYS);
VAR_6 = FFMAX(VAR_6, VAR_4->plane + 1);
}
if ((VAR_3->log2_chroma_w || VAR_3->log2_chroma_h) && VAR_6 < 3)
return AVERROR(ENOSYS);
memset(VAR_0, 0, sizeof(*VAR_0));
VAR_0->VAR_3 = VAR_3;
VAR_0->VAR_1 = VAR_1;
VAR_0->VAR_6 = VAR_6;
memcpy(VAR_0->VAR_7, VAR_7, sizeof(VAR_0->VAR_7));
if (VAR_6 >= 3 && !(VAR_3->VAR_2 & PIX_FMT_RGB)) {
VAR_0->hsub[1] = VAR_0->hsub[2] = VAR_0->hsub_max = VAR_3->log2_chroma_w;
VAR_0->vsub[1] = VAR_0->vsub[2] = VAR_0->vsub_max = VAR_3->log2_chroma_h;
}
for (VAR_5 = 0; VAR_5 < ((VAR_3->nb_components - 1) | 1); VAR_5++)
VAR_0->comp_mask[VAR_3->comp[VAR_5].plane] |=
1 << (VAR_3->comp[VAR_5].offset_plus1 - 1);
return 0;
}
| [
"int FUNC_0(FFDrawContext *VAR_0, enum PixelFormat VAR_1, unsigned VAR_2)\n{",
"const AVPixFmtDescriptor *VAR_3 = &av_pix_fmt_descriptors[VAR_1];",
"const AVComponentDescriptor *VAR_4;",
"unsigned VAR_5, VAR_6 = 0;",
"int VAR_7[MAX_PLANES] = { 0 };",
"if (!VAR_3->name)\nreturn AVERROR(EINVAL);",
"if (VAR_3->VAR_2 & ~(PIX_FMT_PLANAR | PIX_FMT_RGB))\nreturn AVERROR(ENOSYS);",
"for (VAR_5 = 0; VAR_5 < VAR_3->nb_components; VAR_5++) {",
"VAR_4 = &VAR_3->comp[VAR_5];",
"if (VAR_4->depth_minus1 != 8 - 1)\nreturn AVERROR(ENOSYS);",
"if (VAR_4->plane >= MAX_PLANES)\nreturn AVERROR(ENOSYS);",
"if (VAR_7[VAR_4->plane] != 0 &&\nVAR_7[VAR_4->plane] != VAR_4->step_minus1 + 1)\nreturn AVERROR(ENOSYS);",
"VAR_7[VAR_4->plane] = VAR_4->step_minus1 + 1;",
"if (VAR_7[VAR_4->plane] >= 8)\nreturn AVERROR(ENOSYS);",
"VAR_6 = FFMAX(VAR_6, VAR_4->plane + 1);",
"}",
"if ((VAR_3->log2_chroma_w || VAR_3->log2_chroma_h) && VAR_6 < 3)\nreturn AVERROR(ENOSYS);",
"memset(VAR_0, 0, sizeof(*VAR_0));",
"VAR_0->VAR_3 = VAR_3;",
"VAR_0->VAR_1 = VAR_1;",
"VAR_0->VAR_6 = VAR_6;",
"memcpy(VAR_0->VAR_7, VAR_7, sizeof(VAR_0->VAR_7));",
"if (VAR_6 >= 3 && !(VAR_3->VAR_2 & PIX_FMT_RGB)) {",
"VAR_0->hsub[1] = VAR_0->hsub[2] = VAR_0->hsub_max = VAR_3->log2_chroma_w;",
"VAR_0->vsub[1] = VAR_0->vsub[2] = VAR_0->vsub_max = VAR_3->log2_chroma_h;",
"}",
"for (VAR_5 = 0; VAR_5 < ((VAR_3->nb_components - 1) | 1); VAR_5++)",
"VAR_0->comp_mask[VAR_3->comp[VAR_5].plane] |=\n1 << (VAR_3->comp[VAR_5].offset_plus1 - 1);",
"return 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
19,
21
],
[
23
],
[
25
],
[
29,
31
],
[
33,
35
],
[
39,
41,
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79,
81
],
[
83
],
[
85
]
] |
26,109 | static void pty_chr_close(struct CharDriverState *chr)
{
PtyCharDriver *s = chr->opaque;
int fd;
remove_fd_in_watch(chr);
fd = g_io_channel_unix_get_fd(s->fd);
g_io_channel_unref(s->fd);
close(fd);
if (s->timer_tag) {
g_source_remove(s->timer_tag);
s->timer_tag = 0;
}
g_free(s);
qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
}
| true | qemu | 7b3621f47a990c5099c6385728347f69a8d0e55c | static void pty_chr_close(struct CharDriverState *chr)
{
PtyCharDriver *s = chr->opaque;
int fd;
remove_fd_in_watch(chr);
fd = g_io_channel_unix_get_fd(s->fd);
g_io_channel_unref(s->fd);
close(fd);
if (s->timer_tag) {
g_source_remove(s->timer_tag);
s->timer_tag = 0;
}
g_free(s);
qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
}
| {
"code": [
" remove_fd_in_watch(chr);"
],
"line_no": [
11
]
} | static void FUNC_0(struct CharDriverState *VAR_0)
{
PtyCharDriver *s = VAR_0->opaque;
int VAR_1;
remove_fd_in_watch(VAR_0);
VAR_1 = g_io_channel_unix_get_fd(s->VAR_1);
g_io_channel_unref(s->VAR_1);
close(VAR_1);
if (s->timer_tag) {
g_source_remove(s->timer_tag);
s->timer_tag = 0;
}
g_free(s);
qemu_chr_be_event(VAR_0, CHR_EVENT_CLOSED);
}
| [
"static void FUNC_0(struct CharDriverState *VAR_0)\n{",
"PtyCharDriver *s = VAR_0->opaque;",
"int VAR_1;",
"remove_fd_in_watch(VAR_0);",
"VAR_1 = g_io_channel_unix_get_fd(s->VAR_1);",
"g_io_channel_unref(s->VAR_1);",
"close(VAR_1);",
"if (s->timer_tag) {",
"g_source_remove(s->timer_tag);",
"s->timer_tag = 0;",
"}",
"g_free(s);",
"qemu_chr_be_event(VAR_0, CHR_EVENT_CLOSED);",
"}"
] | [
0,
0,
0,
1,
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
]
] |
26,111 | av_cold void ff_dct_init_mmx(DCTContext *s)
{
#if HAVE_YASM
int has_vectors = av_get_cpu_flags();
if (has_vectors & AV_CPU_FLAG_SSE && HAVE_SSE)
s->dct32 = ff_dct32_float_sse;
if (has_vectors & AV_CPU_FLAG_SSE2 && HAVE_SSE)
s->dct32 = ff_dct32_float_sse2;
if (has_vectors & AV_CPU_FLAG_AVX && HAVE_AVX)
s->dct32 = ff_dct32_float_avx;
#endif
}
| false | FFmpeg | e0c6cce44729d94e2a5507a4b6d031f23e8bd7b6 | av_cold void ff_dct_init_mmx(DCTContext *s)
{
#if HAVE_YASM
int has_vectors = av_get_cpu_flags();
if (has_vectors & AV_CPU_FLAG_SSE && HAVE_SSE)
s->dct32 = ff_dct32_float_sse;
if (has_vectors & AV_CPU_FLAG_SSE2 && HAVE_SSE)
s->dct32 = ff_dct32_float_sse2;
if (has_vectors & AV_CPU_FLAG_AVX && HAVE_AVX)
s->dct32 = ff_dct32_float_avx;
#endif
}
| {
"code": [],
"line_no": []
} | av_cold void FUNC_0(DCTContext *s)
{
#if HAVE_YASM
int has_vectors = av_get_cpu_flags();
if (has_vectors & AV_CPU_FLAG_SSE && HAVE_SSE)
s->dct32 = ff_dct32_float_sse;
if (has_vectors & AV_CPU_FLAG_SSE2 && HAVE_SSE)
s->dct32 = ff_dct32_float_sse2;
if (has_vectors & AV_CPU_FLAG_AVX && HAVE_AVX)
s->dct32 = ff_dct32_float_avx;
#endif
}
| [
"av_cold void FUNC_0(DCTContext *s)\n{",
"#if HAVE_YASM\nint has_vectors = av_get_cpu_flags();",
"if (has_vectors & AV_CPU_FLAG_SSE && HAVE_SSE)\ns->dct32 = ff_dct32_float_sse;",
"if (has_vectors & AV_CPU_FLAG_SSE2 && HAVE_SSE)\ns->dct32 = ff_dct32_float_sse2;",
"if (has_vectors & AV_CPU_FLAG_AVX && HAVE_AVX)\ns->dct32 = ff_dct32_float_avx;",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9,
11
],
[
13,
15
],
[
17,
19
],
[
21,
23
]
] |
26,112 | int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
{
AVFrame *tmp;
int ret;
av_assert0(avctx->codec_type == AVMEDIA_TYPE_VIDEO);
if (!frame->data[0])
return ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF);
if (av_frame_is_writable(frame)) {
frame->pkt_pts = avctx->internal->pkt ? avctx->internal->pkt->pts : AV_NOPTS_VALUE;
frame->reordered_opaque = avctx->reordered_opaque;
return 0;
}
tmp = av_frame_alloc();
if (!tmp)
return AVERROR(ENOMEM);
av_frame_move_ref(tmp, frame);
ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF);
if (ret < 0) {
av_frame_free(&tmp);
return ret;
}
av_frame_copy(frame, tmp);
av_frame_free(&tmp);
return 0;
}
| false | FFmpeg | 4a0f6651434c6f213d830140f575b4ec7858519f | int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
{
AVFrame *tmp;
int ret;
av_assert0(avctx->codec_type == AVMEDIA_TYPE_VIDEO);
if (!frame->data[0])
return ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF);
if (av_frame_is_writable(frame)) {
frame->pkt_pts = avctx->internal->pkt ? avctx->internal->pkt->pts : AV_NOPTS_VALUE;
frame->reordered_opaque = avctx->reordered_opaque;
return 0;
}
tmp = av_frame_alloc();
if (!tmp)
return AVERROR(ENOMEM);
av_frame_move_ref(tmp, frame);
ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF);
if (ret < 0) {
av_frame_free(&tmp);
return ret;
}
av_frame_copy(frame, tmp);
av_frame_free(&tmp);
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1)
{
AVFrame *tmp;
int VAR_2;
av_assert0(VAR_0->codec_type == AVMEDIA_TYPE_VIDEO);
if (!VAR_1->data[0])
return ff_get_buffer(VAR_0, VAR_1, AV_GET_BUFFER_FLAG_REF);
if (av_frame_is_writable(VAR_1)) {
VAR_1->pkt_pts = VAR_0->internal->pkt ? VAR_0->internal->pkt->pts : AV_NOPTS_VALUE;
VAR_1->reordered_opaque = VAR_0->reordered_opaque;
return 0;
}
tmp = av_frame_alloc();
if (!tmp)
return AVERROR(ENOMEM);
av_frame_move_ref(tmp, VAR_1);
VAR_2 = ff_get_buffer(VAR_0, VAR_1, AV_GET_BUFFER_FLAG_REF);
if (VAR_2 < 0) {
av_frame_free(&tmp);
return VAR_2;
}
av_frame_copy(VAR_1, tmp);
av_frame_free(&tmp);
return 0;
}
| [
"int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1)\n{",
"AVFrame *tmp;",
"int VAR_2;",
"av_assert0(VAR_0->codec_type == AVMEDIA_TYPE_VIDEO);",
"if (!VAR_1->data[0])\nreturn ff_get_buffer(VAR_0, VAR_1, AV_GET_BUFFER_FLAG_REF);",
"if (av_frame_is_writable(VAR_1)) {",
"VAR_1->pkt_pts = VAR_0->internal->pkt ? VAR_0->internal->pkt->pts : AV_NOPTS_VALUE;",
"VAR_1->reordered_opaque = VAR_0->reordered_opaque;",
"return 0;",
"}",
"tmp = av_frame_alloc();",
"if (!tmp)\nreturn AVERROR(ENOMEM);",
"av_frame_move_ref(tmp, VAR_1);",
"VAR_2 = ff_get_buffer(VAR_0, VAR_1, AV_GET_BUFFER_FLAG_REF);",
"if (VAR_2 < 0) {",
"av_frame_free(&tmp);",
"return VAR_2;",
"}",
"av_frame_copy(VAR_1, tmp);",
"av_frame_free(&tmp);",
"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
],
[
11
],
[
15,
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35,
37
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
63
],
[
65
]
] |
26,115 | static void block_dirty_bitmap_add_abort(BlkActionState *common)
{
BlockDirtyBitmapAdd *action;
BlockDirtyBitmapState *state = DO_UPCAST(BlockDirtyBitmapState,
common, common);
action = common->action->u.block_dirty_bitmap_add;
/* Should not be able to fail: IF the bitmap was added via .prepare(),
* then the node reference and bitmap name must have been valid.
*/
if (state->prepared) {
qmp_block_dirty_bitmap_remove(action->node, action->name, &error_abort);
}
}
| false | qemu | 32bafa8fdd098d52fbf1102d5a5e48d29398c0aa | static void block_dirty_bitmap_add_abort(BlkActionState *common)
{
BlockDirtyBitmapAdd *action;
BlockDirtyBitmapState *state = DO_UPCAST(BlockDirtyBitmapState,
common, common);
action = common->action->u.block_dirty_bitmap_add;
if (state->prepared) {
qmp_block_dirty_bitmap_remove(action->node, action->name, &error_abort);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(BlkActionState *VAR_0)
{
BlockDirtyBitmapAdd *action;
BlockDirtyBitmapState *state = DO_UPCAST(BlockDirtyBitmapState,
VAR_0, VAR_0);
action = VAR_0->action->u.block_dirty_bitmap_add;
if (state->prepared) {
qmp_block_dirty_bitmap_remove(action->node, action->name, &error_abort);
}
}
| [
"static void FUNC_0(BlkActionState *VAR_0)\n{",
"BlockDirtyBitmapAdd *action;",
"BlockDirtyBitmapState *state = DO_UPCAST(BlockDirtyBitmapState,\nVAR_0, VAR_0);",
"action = VAR_0->action->u.block_dirty_bitmap_add;",
"if (state->prepared) {",
"qmp_block_dirty_bitmap_remove(action->node, action->name, &error_abort);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
13
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
26,116 | static int cirrus_bitblt_common_patterncopy(CirrusVGAState *s, bool videosrc)
{
uint32_t patternsize;
uint8_t *dst;
uint8_t *src;
dst = s->vga.vram_ptr + s->cirrus_blt_dstaddr;
if (videosrc) {
switch (s->vga.get_bpp(&s->vga)) {
case 8:
patternsize = 64;
break;
case 15:
case 16:
patternsize = 128;
break;
case 24:
case 32:
default:
patternsize = 256;
break;
}
s->cirrus_blt_srcaddr &= ~(patternsize - 1);
if (s->cirrus_blt_srcaddr + patternsize > s->vga.vram_size) {
return 0;
}
src = s->vga.vram_ptr + s->cirrus_blt_srcaddr;
} else {
src = s->cirrus_bltbuf;
}
if (blit_is_unsafe(s, true)) {
return 0;
}
(*s->cirrus_rop) (s, dst, src,
s->cirrus_blt_dstpitch, 0,
s->cirrus_blt_width, s->cirrus_blt_height);
cirrus_invalidate_region(s, s->cirrus_blt_dstaddr,
s->cirrus_blt_dstpitch, s->cirrus_blt_width,
s->cirrus_blt_height);
return 1;
}
| false | qemu | 026aeffcb4752054830ba203020ed6eb05bcaba8 | static int cirrus_bitblt_common_patterncopy(CirrusVGAState *s, bool videosrc)
{
uint32_t patternsize;
uint8_t *dst;
uint8_t *src;
dst = s->vga.vram_ptr + s->cirrus_blt_dstaddr;
if (videosrc) {
switch (s->vga.get_bpp(&s->vga)) {
case 8:
patternsize = 64;
break;
case 15:
case 16:
patternsize = 128;
break;
case 24:
case 32:
default:
patternsize = 256;
break;
}
s->cirrus_blt_srcaddr &= ~(patternsize - 1);
if (s->cirrus_blt_srcaddr + patternsize > s->vga.vram_size) {
return 0;
}
src = s->vga.vram_ptr + s->cirrus_blt_srcaddr;
} else {
src = s->cirrus_bltbuf;
}
if (blit_is_unsafe(s, true)) {
return 0;
}
(*s->cirrus_rop) (s, dst, src,
s->cirrus_blt_dstpitch, 0,
s->cirrus_blt_width, s->cirrus_blt_height);
cirrus_invalidate_region(s, s->cirrus_blt_dstaddr,
s->cirrus_blt_dstpitch, s->cirrus_blt_width,
s->cirrus_blt_height);
return 1;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(CirrusVGAState *VAR_0, bool VAR_1)
{
uint32_t patternsize;
uint8_t *dst;
uint8_t *src;
dst = VAR_0->vga.vram_ptr + VAR_0->cirrus_blt_dstaddr;
if (VAR_1) {
switch (VAR_0->vga.get_bpp(&VAR_0->vga)) {
case 8:
patternsize = 64;
break;
case 15:
case 16:
patternsize = 128;
break;
case 24:
case 32:
default:
patternsize = 256;
break;
}
VAR_0->cirrus_blt_srcaddr &= ~(patternsize - 1);
if (VAR_0->cirrus_blt_srcaddr + patternsize > VAR_0->vga.vram_size) {
return 0;
}
src = VAR_0->vga.vram_ptr + VAR_0->cirrus_blt_srcaddr;
} else {
src = VAR_0->cirrus_bltbuf;
}
if (blit_is_unsafe(VAR_0, true)) {
return 0;
}
(*VAR_0->cirrus_rop) (VAR_0, dst, src,
VAR_0->cirrus_blt_dstpitch, 0,
VAR_0->cirrus_blt_width, VAR_0->cirrus_blt_height);
cirrus_invalidate_region(VAR_0, VAR_0->cirrus_blt_dstaddr,
VAR_0->cirrus_blt_dstpitch, VAR_0->cirrus_blt_width,
VAR_0->cirrus_blt_height);
return 1;
}
| [
"static int FUNC_0(CirrusVGAState *VAR_0, bool VAR_1)\n{",
"uint32_t patternsize;",
"uint8_t *dst;",
"uint8_t *src;",
"dst = VAR_0->vga.vram_ptr + VAR_0->cirrus_blt_dstaddr;",
"if (VAR_1) {",
"switch (VAR_0->vga.get_bpp(&VAR_0->vga)) {",
"case 8:\npatternsize = 64;",
"break;",
"case 15:\ncase 16:\npatternsize = 128;",
"break;",
"case 24:\ncase 32:\ndefault:\npatternsize = 256;",
"break;",
"}",
"VAR_0->cirrus_blt_srcaddr &= ~(patternsize - 1);",
"if (VAR_0->cirrus_blt_srcaddr + patternsize > VAR_0->vga.vram_size) {",
"return 0;",
"}",
"src = VAR_0->vga.vram_ptr + VAR_0->cirrus_blt_srcaddr;",
"} else {",
"src = VAR_0->cirrus_bltbuf;",
"}",
"if (blit_is_unsafe(VAR_0, true)) {",
"return 0;",
"}",
"(*VAR_0->cirrus_rop) (VAR_0, dst, src,\nVAR_0->cirrus_blt_dstpitch, 0,\nVAR_0->cirrus_blt_width, VAR_0->cirrus_blt_height);",
"cirrus_invalidate_region(VAR_0, VAR_0->cirrus_blt_dstaddr,\nVAR_0->cirrus_blt_dstpitch, VAR_0->cirrus_blt_width,\nVAR_0->cirrus_blt_height);",
"return 1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27,
29,
31
],
[
33
],
[
35,
37,
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
73,
75,
77
],
[
79,
81,
83
],
[
85
],
[
87
]
] |
26,119 | static int nbd_handle_export_name(NBDClient *client, uint32_t length)
{
int rc = -EINVAL, csock = client->sock;
char name[256];
/* Client sends:
[20 .. xx] export name (length bytes)
*/
TRACE("Checking length");
if (length > 255) {
LOG("Bad length received");
goto fail;
}
if (read_sync(csock, name, length) != length) {
LOG("read failed");
goto fail;
}
name[length] = '\0';
client->exp = nbd_export_find(name);
if (!client->exp) {
LOG("export not found");
goto fail;
}
QTAILQ_INSERT_TAIL(&client->exp->clients, client, next);
nbd_export_get(client->exp);
rc = 0;
fail:
return rc;
}
| false | qemu | 1a6245a5b0b4e8d822c739b403fc67c8a7bc8d12 | static int nbd_handle_export_name(NBDClient *client, uint32_t length)
{
int rc = -EINVAL, csock = client->sock;
char name[256];
TRACE("Checking length");
if (length > 255) {
LOG("Bad length received");
goto fail;
}
if (read_sync(csock, name, length) != length) {
LOG("read failed");
goto fail;
}
name[length] = '\0';
client->exp = nbd_export_find(name);
if (!client->exp) {
LOG("export not found");
goto fail;
}
QTAILQ_INSERT_TAIL(&client->exp->clients, client, next);
nbd_export_get(client->exp);
rc = 0;
fail:
return rc;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(NBDClient *VAR_0, uint32_t VAR_1)
{
int VAR_2 = -EINVAL, VAR_3 = VAR_0->sock;
char VAR_4[256];
TRACE("Checking VAR_1");
if (VAR_1 > 255) {
LOG("Bad VAR_1 received");
goto fail;
}
if (read_sync(VAR_3, VAR_4, VAR_1) != VAR_1) {
LOG("read failed");
goto fail;
}
VAR_4[VAR_1] = '\0';
VAR_0->exp = nbd_export_find(VAR_4);
if (!VAR_0->exp) {
LOG("export not found");
goto fail;
}
QTAILQ_INSERT_TAIL(&VAR_0->exp->clients, VAR_0, next);
nbd_export_get(VAR_0->exp);
VAR_2 = 0;
fail:
return VAR_2;
}
| [
"static int FUNC_0(NBDClient *VAR_0, uint32_t VAR_1)\n{",
"int VAR_2 = -EINVAL, VAR_3 = VAR_0->sock;",
"char VAR_4[256];",
"TRACE(\"Checking VAR_1\");",
"if (VAR_1 > 255) {",
"LOG(\"Bad VAR_1 received\");",
"goto fail;",
"}",
"if (read_sync(VAR_3, VAR_4, VAR_1) != VAR_1) {",
"LOG(\"read failed\");",
"goto fail;",
"}",
"VAR_4[VAR_1] = '\\0';",
"VAR_0->exp = nbd_export_find(VAR_4);",
"if (!VAR_0->exp) {",
"LOG(\"export not found\");",
"goto fail;",
"}",
"QTAILQ_INSERT_TAIL(&VAR_0->exp->clients, VAR_0, next);",
"nbd_export_get(VAR_0->exp);",
"VAR_2 = 0;",
"fail:\nreturn 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
]
] |
26,120 | static void tcg_out_insn_3401(TCGContext *s, AArch64Insn insn, TCGType ext,
TCGReg rd, TCGReg rn, uint64_t aimm)
{
if (aimm > 0xfff) {
assert((aimm & 0xfff) == 0);
aimm >>= 12;
assert(aimm <= 0xfff);
aimm |= 1 << 12; /* apply LSL 12 */
}
tcg_out32(s, insn | ext << 31 | aimm << 10 | rn << 5 | rd);
}
| false | qemu | eabb7b91b36b202b4dac2df2d59d698e3aff197a | static void tcg_out_insn_3401(TCGContext *s, AArch64Insn insn, TCGType ext,
TCGReg rd, TCGReg rn, uint64_t aimm)
{
if (aimm > 0xfff) {
assert((aimm & 0xfff) == 0);
aimm >>= 12;
assert(aimm <= 0xfff);
aimm |= 1 << 12;
}
tcg_out32(s, insn | ext << 31 | aimm << 10 | rn << 5 | rd);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TCGContext *VAR_0, AArch64Insn VAR_1, TCGType VAR_2,
TCGReg VAR_3, TCGReg VAR_4, uint64_t VAR_5)
{
if (VAR_5 > 0xfff) {
assert((VAR_5 & 0xfff) == 0);
VAR_5 >>= 12;
assert(VAR_5 <= 0xfff);
VAR_5 |= 1 << 12;
}
tcg_out32(VAR_0, VAR_1 | VAR_2 << 31 | VAR_5 << 10 | VAR_4 << 5 | VAR_3);
}
| [
"static void FUNC_0(TCGContext *VAR_0, AArch64Insn VAR_1, TCGType VAR_2,\nTCGReg VAR_3, TCGReg VAR_4, uint64_t VAR_5)\n{",
"if (VAR_5 > 0xfff) {",
"assert((VAR_5 & 0xfff) == 0);",
"VAR_5 >>= 12;",
"assert(VAR_5 <= 0xfff);",
"VAR_5 |= 1 << 12;",
"}",
"tcg_out32(VAR_0, VAR_1 | VAR_2 << 31 | VAR_5 << 10 | VAR_4 << 5 | VAR_3);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
26,121 | static int proxy_mkdir(FsContext *fs_ctx, V9fsPath *dir_path,
const char *name, FsCred *credp)
{
int retval;
V9fsString fullname;
v9fs_string_init(&fullname);
v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name);
retval = v9fs_request(fs_ctx->private, T_MKDIR, NULL, "sddd", &fullname,
credp->fc_mode, credp->fc_uid, credp->fc_gid);
v9fs_string_free(&fullname);
if (retval < 0) {
errno = -retval;
retval = -1;
}
v9fs_string_free(&fullname);
return retval;
}
| false | qemu | 494a8ebe713055d3946183f4b395f85a18b43e9e | static int proxy_mkdir(FsContext *fs_ctx, V9fsPath *dir_path,
const char *name, FsCred *credp)
{
int retval;
V9fsString fullname;
v9fs_string_init(&fullname);
v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name);
retval = v9fs_request(fs_ctx->private, T_MKDIR, NULL, "sddd", &fullname,
credp->fc_mode, credp->fc_uid, credp->fc_gid);
v9fs_string_free(&fullname);
if (retval < 0) {
errno = -retval;
retval = -1;
}
v9fs_string_free(&fullname);
return retval;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1,
const char *VAR_2, FsCred *VAR_3)
{
int VAR_4;
V9fsString fullname;
v9fs_string_init(&fullname);
v9fs_string_sprintf(&fullname, "%s/%s", VAR_1->data, VAR_2);
VAR_4 = v9fs_request(VAR_0->private, T_MKDIR, NULL, "sddd", &fullname,
VAR_3->fc_mode, VAR_3->fc_uid, VAR_3->fc_gid);
v9fs_string_free(&fullname);
if (VAR_4 < 0) {
errno = -VAR_4;
VAR_4 = -1;
}
v9fs_string_free(&fullname);
return VAR_4;
}
| [
"static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1,\nconst char *VAR_2, FsCred *VAR_3)\n{",
"int VAR_4;",
"V9fsString fullname;",
"v9fs_string_init(&fullname);",
"v9fs_string_sprintf(&fullname, \"%s/%s\", VAR_1->data, VAR_2);",
"VAR_4 = v9fs_request(VAR_0->private, T_MKDIR, NULL, \"sddd\", &fullname,\nVAR_3->fc_mode, VAR_3->fc_uid, VAR_3->fc_gid);",
"v9fs_string_free(&fullname);",
"if (VAR_4 < 0) {",
"errno = -VAR_4;",
"VAR_4 = -1;",
"}",
"v9fs_string_free(&fullname);",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
]
] |
26,123 | static always_inline uint64_t float_zero_divide_excp (uint64_t arg1, uint64_t arg2)
{
env->fpscr |= 1 << FPSCR_ZX;
env->fpscr &= ~((1 << FPSCR_FR) | (1 << FPSCR_FI));
/* Update the floating-point exception summary */
env->fpscr |= 1 << FPSCR_FX;
if (fpscr_ze != 0) {
/* Update the floating-point enabled exception summary */
env->fpscr |= 1 << FPSCR_FEX;
if (msr_fe0 != 0 || msr_fe1 != 0) {
helper_raise_exception_err(POWERPC_EXCP_PROGRAM,
POWERPC_EXCP_FP | POWERPC_EXCP_FP_ZX);
}
} else {
/* Set the result to infinity */
arg1 = ((arg1 ^ arg2) & 0x8000000000000000ULL);
arg1 |= 0x7FFULL << 52;
}
return arg1;
}
| false | qemu | e33e94f92298c96e0928cefab00ea5bae0a1cd19 | static always_inline uint64_t float_zero_divide_excp (uint64_t arg1, uint64_t arg2)
{
env->fpscr |= 1 << FPSCR_ZX;
env->fpscr &= ~((1 << FPSCR_FR) | (1 << FPSCR_FI));
env->fpscr |= 1 << FPSCR_FX;
if (fpscr_ze != 0) {
env->fpscr |= 1 << FPSCR_FEX;
if (msr_fe0 != 0 || msr_fe1 != 0) {
helper_raise_exception_err(POWERPC_EXCP_PROGRAM,
POWERPC_EXCP_FP | POWERPC_EXCP_FP_ZX);
}
} else {
arg1 = ((arg1 ^ arg2) & 0x8000000000000000ULL);
arg1 |= 0x7FFULL << 52;
}
return arg1;
}
| {
"code": [],
"line_no": []
} | static always_inline VAR_0 float_zero_divide_excp (VAR_0 arg1, VAR_0 arg2)
{
env->fpscr |= 1 << FPSCR_ZX;
env->fpscr &= ~((1 << FPSCR_FR) | (1 << FPSCR_FI));
env->fpscr |= 1 << FPSCR_FX;
if (fpscr_ze != 0) {
env->fpscr |= 1 << FPSCR_FEX;
if (msr_fe0 != 0 || msr_fe1 != 0) {
helper_raise_exception_err(POWERPC_EXCP_PROGRAM,
POWERPC_EXCP_FP | POWERPC_EXCP_FP_ZX);
}
} else {
arg1 = ((arg1 ^ arg2) & 0x8000000000000000ULL);
arg1 |= 0x7FFULL << 52;
}
return arg1;
}
| [
"static always_inline VAR_0 float_zero_divide_excp (VAR_0 arg1, VAR_0 arg2)\n{",
"env->fpscr |= 1 << FPSCR_ZX;",
"env->fpscr &= ~((1 << FPSCR_FR) | (1 << FPSCR_FI));",
"env->fpscr |= 1 << FPSCR_FX;",
"if (fpscr_ze != 0) {",
"env->fpscr |= 1 << FPSCR_FEX;",
"if (msr_fe0 != 0 || msr_fe1 != 0) {",
"helper_raise_exception_err(POWERPC_EXCP_PROGRAM,\nPOWERPC_EXCP_FP | POWERPC_EXCP_FP_ZX);",
"}",
"} else {",
"arg1 = ((arg1 ^ arg2) & 0x8000000000000000ULL);",
"arg1 |= 0x7FFULL << 52;",
"}",
"return arg1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
]
] |
26,124 | void *s1d13745_init(qemu_irq gpio_int)
{
BlizzardState *s = (BlizzardState *) g_malloc0(sizeof(*s));
DisplaySurface *surface;
s->fb = g_malloc(0x180000);
s->con = graphic_console_init(blizzard_update_display,
blizzard_invalidate_display,
blizzard_screen_dump, NULL, s);
surface = qemu_console_surface(s->con);
switch (surface_bits_per_pixel(surface)) {
case 0:
s->line_fn_tab[0] = s->line_fn_tab[1] =
g_malloc0(sizeof(blizzard_fn_t) * 0x10);
break;
case 8:
s->line_fn_tab[0] = blizzard_draw_fn_8;
s->line_fn_tab[1] = blizzard_draw_fn_r_8;
break;
case 15:
s->line_fn_tab[0] = blizzard_draw_fn_15;
s->line_fn_tab[1] = blizzard_draw_fn_r_15;
break;
case 16:
s->line_fn_tab[0] = blizzard_draw_fn_16;
s->line_fn_tab[1] = blizzard_draw_fn_r_16;
break;
case 24:
s->line_fn_tab[0] = blizzard_draw_fn_24;
s->line_fn_tab[1] = blizzard_draw_fn_r_24;
break;
case 32:
s->line_fn_tab[0] = blizzard_draw_fn_32;
s->line_fn_tab[1] = blizzard_draw_fn_r_32;
break;
default:
fprintf(stderr, "%s: Bad color depth\n", __FUNCTION__);
exit(1);
}
blizzard_reset(s);
return s;
}
| false | qemu | 2c62f08ddbf3fa80dc7202eb9a2ea60ae44e2cc5 | void *s1d13745_init(qemu_irq gpio_int)
{
BlizzardState *s = (BlizzardState *) g_malloc0(sizeof(*s));
DisplaySurface *surface;
s->fb = g_malloc(0x180000);
s->con = graphic_console_init(blizzard_update_display,
blizzard_invalidate_display,
blizzard_screen_dump, NULL, s);
surface = qemu_console_surface(s->con);
switch (surface_bits_per_pixel(surface)) {
case 0:
s->line_fn_tab[0] = s->line_fn_tab[1] =
g_malloc0(sizeof(blizzard_fn_t) * 0x10);
break;
case 8:
s->line_fn_tab[0] = blizzard_draw_fn_8;
s->line_fn_tab[1] = blizzard_draw_fn_r_8;
break;
case 15:
s->line_fn_tab[0] = blizzard_draw_fn_15;
s->line_fn_tab[1] = blizzard_draw_fn_r_15;
break;
case 16:
s->line_fn_tab[0] = blizzard_draw_fn_16;
s->line_fn_tab[1] = blizzard_draw_fn_r_16;
break;
case 24:
s->line_fn_tab[0] = blizzard_draw_fn_24;
s->line_fn_tab[1] = blizzard_draw_fn_r_24;
break;
case 32:
s->line_fn_tab[0] = blizzard_draw_fn_32;
s->line_fn_tab[1] = blizzard_draw_fn_r_32;
break;
default:
fprintf(stderr, "%s: Bad color depth\n", __FUNCTION__);
exit(1);
}
blizzard_reset(s);
return s;
}
| {
"code": [],
"line_no": []
} | void *FUNC_0(qemu_irq VAR_0)
{
BlizzardState *s = (BlizzardState *) g_malloc0(sizeof(*s));
DisplaySurface *surface;
s->fb = g_malloc(0x180000);
s->con = graphic_console_init(blizzard_update_display,
blizzard_invalidate_display,
blizzard_screen_dump, NULL, s);
surface = qemu_console_surface(s->con);
switch (surface_bits_per_pixel(surface)) {
case 0:
s->line_fn_tab[0] = s->line_fn_tab[1] =
g_malloc0(sizeof(blizzard_fn_t) * 0x10);
break;
case 8:
s->line_fn_tab[0] = blizzard_draw_fn_8;
s->line_fn_tab[1] = blizzard_draw_fn_r_8;
break;
case 15:
s->line_fn_tab[0] = blizzard_draw_fn_15;
s->line_fn_tab[1] = blizzard_draw_fn_r_15;
break;
case 16:
s->line_fn_tab[0] = blizzard_draw_fn_16;
s->line_fn_tab[1] = blizzard_draw_fn_r_16;
break;
case 24:
s->line_fn_tab[0] = blizzard_draw_fn_24;
s->line_fn_tab[1] = blizzard_draw_fn_r_24;
break;
case 32:
s->line_fn_tab[0] = blizzard_draw_fn_32;
s->line_fn_tab[1] = blizzard_draw_fn_r_32;
break;
default:
fprintf(stderr, "%s: Bad color depth\n", __FUNCTION__);
exit(1);
}
blizzard_reset(s);
return s;
}
| [
"void *FUNC_0(qemu_irq VAR_0)\n{",
"BlizzardState *s = (BlizzardState *) g_malloc0(sizeof(*s));",
"DisplaySurface *surface;",
"s->fb = g_malloc(0x180000);",
"s->con = graphic_console_init(blizzard_update_display,\nblizzard_invalidate_display,\nblizzard_screen_dump, NULL, s);",
"surface = qemu_console_surface(s->con);",
"switch (surface_bits_per_pixel(surface)) {",
"case 0:\ns->line_fn_tab[0] = s->line_fn_tab[1] =\ng_malloc0(sizeof(blizzard_fn_t) * 0x10);",
"break;",
"case 8:\ns->line_fn_tab[0] = blizzard_draw_fn_8;",
"s->line_fn_tab[1] = blizzard_draw_fn_r_8;",
"break;",
"case 15:\ns->line_fn_tab[0] = blizzard_draw_fn_15;",
"s->line_fn_tab[1] = blizzard_draw_fn_r_15;",
"break;",
"case 16:\ns->line_fn_tab[0] = blizzard_draw_fn_16;",
"s->line_fn_tab[1] = blizzard_draw_fn_r_16;",
"break;",
"case 24:\ns->line_fn_tab[0] = blizzard_draw_fn_24;",
"s->line_fn_tab[1] = blizzard_draw_fn_r_24;",
"break;",
"case 32:\ns->line_fn_tab[0] = blizzard_draw_fn_32;",
"s->line_fn_tab[1] = blizzard_draw_fn_r_32;",
"break;",
"default:\nfprintf(stderr, \"%s: Bad color depth\\n\", __FUNCTION__);",
"exit(1);",
"}",
"blizzard_reset(s);",
"return s;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15,
17,
19
],
[
21
],
[
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
],
[
89
],
[
91
]
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.