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
|
---|---|---|---|---|---|---|---|---|---|---|
24,493 | static void qcow2_invalidate_cache(BlockDriverState *bs, Error **errp)
{
BDRVQcowState *s = bs->opaque;
int flags = s->flags;
AES_KEY aes_encrypt_key;
AES_KEY aes_decrypt_key;
uint32_t crypt_method = 0;
QDict *options;
Error *local_err = NULL;
int ret;
/*
* Backing files are read-only which makes all of their metadata immutable,
* that means we don't have to worry about reopening them here.
*/
if (s->crypt_method) {
crypt_method = s->crypt_method;
memcpy(&aes_encrypt_key, &s->aes_encrypt_key, sizeof(aes_encrypt_key));
memcpy(&aes_decrypt_key, &s->aes_decrypt_key, sizeof(aes_decrypt_key));
}
qcow2_close(bs);
bdrv_invalidate_cache(bs->file, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
memset(s, 0, sizeof(BDRVQcowState));
options = qdict_clone_shallow(bs->options);
ret = qcow2_open(bs, options, flags, &local_err);
QDECREF(options);
if (local_err) {
error_setg(errp, "Could not reopen qcow2 layer: %s",
error_get_pretty(local_err));
error_free(local_err);
return;
} else if (ret < 0) {
error_setg_errno(errp, -ret, "Could not reopen qcow2 layer");
return;
}
if (crypt_method) {
s->crypt_method = crypt_method;
memcpy(&s->aes_encrypt_key, &aes_encrypt_key, sizeof(aes_encrypt_key));
memcpy(&s->aes_decrypt_key, &aes_decrypt_key, sizeof(aes_decrypt_key));
}
}
| true | qemu | 8336aafae1451d54c81dd2b187b45f7c45d2428e | static void qcow2_invalidate_cache(BlockDriverState *bs, Error **errp)
{
BDRVQcowState *s = bs->opaque;
int flags = s->flags;
AES_KEY aes_encrypt_key;
AES_KEY aes_decrypt_key;
uint32_t crypt_method = 0;
QDict *options;
Error *local_err = NULL;
int ret;
if (s->crypt_method) {
crypt_method = s->crypt_method;
memcpy(&aes_encrypt_key, &s->aes_encrypt_key, sizeof(aes_encrypt_key));
memcpy(&aes_decrypt_key, &s->aes_decrypt_key, sizeof(aes_decrypt_key));
}
qcow2_close(bs);
bdrv_invalidate_cache(bs->file, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
memset(s, 0, sizeof(BDRVQcowState));
options = qdict_clone_shallow(bs->options);
ret = qcow2_open(bs, options, flags, &local_err);
QDECREF(options);
if (local_err) {
error_setg(errp, "Could not reopen qcow2 layer: %s",
error_get_pretty(local_err));
error_free(local_err);
return;
} else if (ret < 0) {
error_setg_errno(errp, -ret, "Could not reopen qcow2 layer");
return;
}
if (crypt_method) {
s->crypt_method = crypt_method;
memcpy(&s->aes_encrypt_key, &aes_encrypt_key, sizeof(aes_encrypt_key));
memcpy(&s->aes_decrypt_key, &aes_decrypt_key, sizeof(aes_decrypt_key));
}
}
| {
"code": [
" if (s->crypt_method) {",
" if (s->crypt_method) {",
" if (crypt_method) {"
],
"line_no": [
33,
33,
91
]
} | static void FUNC_0(BlockDriverState *VAR_0, Error **VAR_1)
{
BDRVQcowState *s = VAR_0->opaque;
int VAR_2 = s->VAR_2;
AES_KEY aes_encrypt_key;
AES_KEY aes_decrypt_key;
uint32_t crypt_method = 0;
QDict *options;
Error *local_err = NULL;
int VAR_3;
if (s->crypt_method) {
crypt_method = s->crypt_method;
memcpy(&aes_encrypt_key, &s->aes_encrypt_key, sizeof(aes_encrypt_key));
memcpy(&aes_decrypt_key, &s->aes_decrypt_key, sizeof(aes_decrypt_key));
}
qcow2_close(VAR_0);
bdrv_invalidate_cache(VAR_0->file, &local_err);
if (local_err) {
error_propagate(VAR_1, local_err);
return;
}
memset(s, 0, sizeof(BDRVQcowState));
options = qdict_clone_shallow(VAR_0->options);
VAR_3 = qcow2_open(VAR_0, options, VAR_2, &local_err);
QDECREF(options);
if (local_err) {
error_setg(VAR_1, "Could not reopen qcow2 layer: %s",
error_get_pretty(local_err));
error_free(local_err);
return;
} else if (VAR_3 < 0) {
error_setg_errno(VAR_1, -VAR_3, "Could not reopen qcow2 layer");
return;
}
if (crypt_method) {
s->crypt_method = crypt_method;
memcpy(&s->aes_encrypt_key, &aes_encrypt_key, sizeof(aes_encrypt_key));
memcpy(&s->aes_decrypt_key, &aes_decrypt_key, sizeof(aes_decrypt_key));
}
}
| [
"static void FUNC_0(BlockDriverState *VAR_0, Error **VAR_1)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"int VAR_2 = s->VAR_2;",
"AES_KEY aes_encrypt_key;",
"AES_KEY aes_decrypt_key;",
"uint32_t crypt_method = 0;",
"QDict *options;",
"Error *local_err = NULL;",
"int VAR_3;",
"if (s->crypt_method) {",
"crypt_method = s->crypt_method;",
"memcpy(&aes_encrypt_key, &s->aes_encrypt_key, sizeof(aes_encrypt_key));",
"memcpy(&aes_decrypt_key, &s->aes_decrypt_key, sizeof(aes_decrypt_key));",
"}",
"qcow2_close(VAR_0);",
"bdrv_invalidate_cache(VAR_0->file, &local_err);",
"if (local_err) {",
"error_propagate(VAR_1, local_err);",
"return;",
"}",
"memset(s, 0, sizeof(BDRVQcowState));",
"options = qdict_clone_shallow(VAR_0->options);",
"VAR_3 = qcow2_open(VAR_0, options, VAR_2, &local_err);",
"QDECREF(options);",
"if (local_err) {",
"error_setg(VAR_1, \"Could not reopen qcow2 layer: %s\",\nerror_get_pretty(local_err));",
"error_free(local_err);",
"return;",
"} else if (VAR_3 < 0) {",
"error_setg_errno(VAR_1, -VAR_3, \"Could not reopen qcow2 layer\");",
"return;",
"}",
"if (crypt_method) {",
"s->crypt_method = crypt_method;",
"memcpy(&s->aes_encrypt_key, &aes_encrypt_key, sizeof(aes_encrypt_key));",
"memcpy(&s->aes_decrypt_key, &aes_decrypt_key, sizeof(aes_decrypt_key));",
"}",
"}"
] | [
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,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
]
] |
24,494 | static void ppc_prep_init (ram_addr_t ram_size,
const char *boot_device,
const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename,
const char *cpu_model)
{
CPUState *env = NULL, *envs[MAX_CPUS];
char *filename;
nvram_t nvram;
m48t59_t *m48t59;
int PPC_io_memory;
int linux_boot, i, nb_nics1, bios_size;
ram_addr_t ram_offset, bios_offset;
uint32_t kernel_base, kernel_size, initrd_base, initrd_size;
PCIBus *pci_bus;
qemu_irq *i8259;
int ppc_boot_device;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
DriveInfo *fd[MAX_FD];
sysctrl = qemu_mallocz(sizeof(sysctrl_t));
linux_boot = (kernel_filename != NULL);
/* init CPUs */
if (cpu_model == NULL)
cpu_model = "602";
for (i = 0; i < smp_cpus; i++) {
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to find PowerPC CPU definition\n");
exit(1);
}
if (env->flags & POWERPC_FLAG_RTC_CLK) {
/* POWER / PowerPC 601 RTC clock frequency is 7.8125 MHz */
cpu_ppc_tb_init(env, 7812500UL);
} else {
/* Set time-base frequency to 100 Mhz */
cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);
}
qemu_register_reset(&cpu_ppc_reset, env);
envs[i] = env;
}
/* allocate RAM */
ram_offset = qemu_ram_alloc(ram_size);
cpu_register_physical_memory(0, ram_size, ram_offset);
/* allocate and load BIOS */
bios_offset = qemu_ram_alloc(BIOS_SIZE);
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = get_image_size(filename);
} else {
bios_size = -1;
}
if (bios_size > 0 && bios_size <= BIOS_SIZE) {
target_phys_addr_t bios_addr;
bios_size = (bios_size + 0xfff) & ~0xfff;
bios_addr = (uint32_t)(-bios_size);
cpu_register_physical_memory(bios_addr, bios_size,
bios_offset | IO_MEM_ROM);
bios_size = load_image_targphys(filename, bios_addr, bios_size);
}
if (bios_size < 0 || bios_size > BIOS_SIZE) {
hw_error("qemu: could not load PPC PREP bios '%s'\n", bios_name);
}
if (filename) {
qemu_free(filename);
}
if (env->nip < 0xFFF80000 && bios_size < 0x00100000) {
hw_error("PowerPC 601 / 620 / 970 need a 1MB BIOS\n");
}
if (linux_boot) {
kernel_base = KERNEL_LOAD_ADDR;
/* now we can load the kernel */
kernel_size = load_image_targphys(kernel_filename, kernel_base,
ram_size - kernel_base);
if (kernel_size < 0) {
hw_error("qemu: could not load kernel '%s'\n", kernel_filename);
exit(1);
}
/* load initrd */
if (initrd_filename) {
initrd_base = INITRD_LOAD_ADDR;
initrd_size = load_image_targphys(initrd_filename, initrd_base,
ram_size - initrd_base);
if (initrd_size < 0) {
hw_error("qemu: could not load initial ram disk '%s'\n",
initrd_filename);
}
} else {
initrd_base = 0;
initrd_size = 0;
}
ppc_boot_device = 'm';
} else {
kernel_base = 0;
kernel_size = 0;
initrd_base = 0;
initrd_size = 0;
ppc_boot_device = '\0';
/* For now, OHW cannot boot from the network. */
for (i = 0; boot_device[i] != '\0'; i++) {
if (boot_device[i] >= 'a' && boot_device[i] <= 'f') {
ppc_boot_device = boot_device[i];
break;
}
}
if (ppc_boot_device == '\0') {
fprintf(stderr, "No valid boot device for Mac99 machine\n");
exit(1);
}
}
isa_mem_base = 0xc0000000;
if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
hw_error("Only 6xx bus is supported on PREP machine\n");
}
i8259 = i8259_init(first_cpu->irq_inputs[PPC6xx_INPUT_INT]);
pci_bus = pci_prep_init(i8259);
/* Hmm, prep has no pci-isa bridge ??? */
isa_bus_new(NULL);
isa_bus_irqs(i8259);
// pci_bus = i440fx_init();
/* Register 8 MB of ISA IO space (needed for non-contiguous map) */
PPC_io_memory = cpu_register_io_memory(PPC_prep_io_read,
PPC_prep_io_write, sysctrl);
cpu_register_physical_memory(0x80000000, 0x00800000, PPC_io_memory);
/* init basic PC hardware */
pci_vga_init(pci_bus, 0, 0);
// openpic = openpic_init(0x00000000, 0xF0000000, 1);
// pit = pit_init(0x40, i8259[0]);
rtc_init(2000);
if (serial_hds[0])
serial_isa_init(0, serial_hds[0]);
nb_nics1 = nb_nics;
if (nb_nics1 > NE2000_NB_MAX)
nb_nics1 = NE2000_NB_MAX;
for(i = 0; i < nb_nics1; i++) {
if (nd_table[i].model == NULL) {
nd_table[i].model = "ne2k_isa";
}
if (strcmp(nd_table[i].model, "ne2k_isa") == 0) {
isa_ne2000_init(ne2000_io[i], ne2000_irq[i], &nd_table[i]);
} else {
pci_nic_init(&nd_table[i], "ne2k_pci", NULL);
}
}
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
fprintf(stderr, "qemu: too many IDE bus\n");
exit(1);
}
for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) {
hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS);
}
for(i = 0; i < MAX_IDE_BUS; i++) {
isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i],
hd[2 * i],
hd[2 * i + 1]);
}
isa_create_simple("i8042");
DMA_init(1);
// SB16_init();
for(i = 0; i < MAX_FD; i++) {
fd[i] = drive_get(IF_FLOPPY, 0, i);
}
fdctrl_init_isa(fd);
/* Register speaker port */
register_ioport_read(0x61, 1, 1, speaker_ioport_read, NULL);
register_ioport_write(0x61, 1, 1, speaker_ioport_write, NULL);
/* Register fake IO ports for PREP */
sysctrl->reset_irq = first_cpu->irq_inputs[PPC6xx_INPUT_HRESET];
register_ioport_read(0x398, 2, 1, &PREP_io_read, sysctrl);
register_ioport_write(0x398, 2, 1, &PREP_io_write, sysctrl);
/* System control ports */
register_ioport_read(0x0092, 0x01, 1, &PREP_io_800_readb, sysctrl);
register_ioport_write(0x0092, 0x01, 1, &PREP_io_800_writeb, sysctrl);
register_ioport_read(0x0800, 0x52, 1, &PREP_io_800_readb, sysctrl);
register_ioport_write(0x0800, 0x52, 1, &PREP_io_800_writeb, sysctrl);
/* PCI intack location */
PPC_io_memory = cpu_register_io_memory(PPC_intack_read,
PPC_intack_write, NULL);
cpu_register_physical_memory(0xBFFFFFF0, 0x4, PPC_io_memory);
/* PowerPC control and status register group */
#if 0
PPC_io_memory = cpu_register_io_memory(PPC_XCSR_read, PPC_XCSR_write,
NULL);
cpu_register_physical_memory(0xFEFF0000, 0x1000, PPC_io_memory);
#endif
if (usb_enabled) {
usb_ohci_init_pci(pci_bus, -1);
}
m48t59 = m48t59_init(i8259[8], 0, 0x0074, NVRAM_SIZE, 59);
if (m48t59 == NULL)
return;
sysctrl->nvram = m48t59;
/* Initialise NVRAM */
nvram.opaque = m48t59;
nvram.read_fn = &m48t59_read;
nvram.write_fn = &m48t59_write;
PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "PREP", ram_size, ppc_boot_device,
kernel_base, kernel_size,
kernel_cmdline,
initrd_base, initrd_size,
/* XXX: need an option to load a NVRAM image */
0,
graphic_width, graphic_height, graphic_depth);
/* Special port to get debug messages from Open-Firmware */
register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL);
}
| true | qemu | 07caea315a85ebfe90851f9c2e4ef3fdd24117b5 | static void ppc_prep_init (ram_addr_t ram_size,
const char *boot_device,
const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename,
const char *cpu_model)
{
CPUState *env = NULL, *envs[MAX_CPUS];
char *filename;
nvram_t nvram;
m48t59_t *m48t59;
int PPC_io_memory;
int linux_boot, i, nb_nics1, bios_size;
ram_addr_t ram_offset, bios_offset;
uint32_t kernel_base, kernel_size, initrd_base, initrd_size;
PCIBus *pci_bus;
qemu_irq *i8259;
int ppc_boot_device;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
DriveInfo *fd[MAX_FD];
sysctrl = qemu_mallocz(sizeof(sysctrl_t));
linux_boot = (kernel_filename != NULL);
if (cpu_model == NULL)
cpu_model = "602";
for (i = 0; i < smp_cpus; i++) {
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to find PowerPC CPU definition\n");
exit(1);
}
if (env->flags & POWERPC_FLAG_RTC_CLK) {
cpu_ppc_tb_init(env, 7812500UL);
} else {
cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);
}
qemu_register_reset(&cpu_ppc_reset, env);
envs[i] = env;
}
ram_offset = qemu_ram_alloc(ram_size);
cpu_register_physical_memory(0, ram_size, ram_offset);
bios_offset = qemu_ram_alloc(BIOS_SIZE);
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = get_image_size(filename);
} else {
bios_size = -1;
}
if (bios_size > 0 && bios_size <= BIOS_SIZE) {
target_phys_addr_t bios_addr;
bios_size = (bios_size + 0xfff) & ~0xfff;
bios_addr = (uint32_t)(-bios_size);
cpu_register_physical_memory(bios_addr, bios_size,
bios_offset | IO_MEM_ROM);
bios_size = load_image_targphys(filename, bios_addr, bios_size);
}
if (bios_size < 0 || bios_size > BIOS_SIZE) {
hw_error("qemu: could not load PPC PREP bios '%s'\n", bios_name);
}
if (filename) {
qemu_free(filename);
}
if (env->nip < 0xFFF80000 && bios_size < 0x00100000) {
hw_error("PowerPC 601 / 620 / 970 need a 1MB BIOS\n");
}
if (linux_boot) {
kernel_base = KERNEL_LOAD_ADDR;
kernel_size = load_image_targphys(kernel_filename, kernel_base,
ram_size - kernel_base);
if (kernel_size < 0) {
hw_error("qemu: could not load kernel '%s'\n", kernel_filename);
exit(1);
}
if (initrd_filename) {
initrd_base = INITRD_LOAD_ADDR;
initrd_size = load_image_targphys(initrd_filename, initrd_base,
ram_size - initrd_base);
if (initrd_size < 0) {
hw_error("qemu: could not load initial ram disk '%s'\n",
initrd_filename);
}
} else {
initrd_base = 0;
initrd_size = 0;
}
ppc_boot_device = 'm';
} else {
kernel_base = 0;
kernel_size = 0;
initrd_base = 0;
initrd_size = 0;
ppc_boot_device = '\0';
for (i = 0; boot_device[i] != '\0'; i++) {
if (boot_device[i] >= 'a' && boot_device[i] <= 'f') {
ppc_boot_device = boot_device[i];
break;
}
}
if (ppc_boot_device == '\0') {
fprintf(stderr, "No valid boot device for Mac99 machine\n");
exit(1);
}
}
isa_mem_base = 0xc0000000;
if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
hw_error("Only 6xx bus is supported on PREP machine\n");
}
i8259 = i8259_init(first_cpu->irq_inputs[PPC6xx_INPUT_INT]);
pci_bus = pci_prep_init(i8259);
isa_bus_new(NULL);
isa_bus_irqs(i8259);
PPC_io_memory = cpu_register_io_memory(PPC_prep_io_read,
PPC_prep_io_write, sysctrl);
cpu_register_physical_memory(0x80000000, 0x00800000, PPC_io_memory);
pci_vga_init(pci_bus, 0, 0);
rtc_init(2000);
if (serial_hds[0])
serial_isa_init(0, serial_hds[0]);
nb_nics1 = nb_nics;
if (nb_nics1 > NE2000_NB_MAX)
nb_nics1 = NE2000_NB_MAX;
for(i = 0; i < nb_nics1; i++) {
if (nd_table[i].model == NULL) {
nd_table[i].model = "ne2k_isa";
}
if (strcmp(nd_table[i].model, "ne2k_isa") == 0) {
isa_ne2000_init(ne2000_io[i], ne2000_irq[i], &nd_table[i]);
} else {
pci_nic_init(&nd_table[i], "ne2k_pci", NULL);
}
}
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
fprintf(stderr, "qemu: too many IDE bus\n");
exit(1);
}
for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) {
hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS);
}
for(i = 0; i < MAX_IDE_BUS; i++) {
isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i],
hd[2 * i],
hd[2 * i + 1]);
}
isa_create_simple("i8042");
DMA_init(1);
for(i = 0; i < MAX_FD; i++) {
fd[i] = drive_get(IF_FLOPPY, 0, i);
}
fdctrl_init_isa(fd);
register_ioport_read(0x61, 1, 1, speaker_ioport_read, NULL);
register_ioport_write(0x61, 1, 1, speaker_ioport_write, NULL);
sysctrl->reset_irq = first_cpu->irq_inputs[PPC6xx_INPUT_HRESET];
register_ioport_read(0x398, 2, 1, &PREP_io_read, sysctrl);
register_ioport_write(0x398, 2, 1, &PREP_io_write, sysctrl);
register_ioport_read(0x0092, 0x01, 1, &PREP_io_800_readb, sysctrl);
register_ioport_write(0x0092, 0x01, 1, &PREP_io_800_writeb, sysctrl);
register_ioport_read(0x0800, 0x52, 1, &PREP_io_800_readb, sysctrl);
register_ioport_write(0x0800, 0x52, 1, &PREP_io_800_writeb, sysctrl);
PPC_io_memory = cpu_register_io_memory(PPC_intack_read,
PPC_intack_write, NULL);
cpu_register_physical_memory(0xBFFFFFF0, 0x4, PPC_io_memory);
#if 0
PPC_io_memory = cpu_register_io_memory(PPC_XCSR_read, PPC_XCSR_write,
NULL);
cpu_register_physical_memory(0xFEFF0000, 0x1000, PPC_io_memory);
#endif
if (usb_enabled) {
usb_ohci_init_pci(pci_bus, -1);
}
m48t59 = m48t59_init(i8259[8], 0, 0x0074, NVRAM_SIZE, 59);
if (m48t59 == NULL)
return;
sysctrl->nvram = m48t59;
nvram.opaque = m48t59;
nvram.read_fn = &m48t59_read;
nvram.write_fn = &m48t59_write;
PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "PREP", ram_size, ppc_boot_device,
kernel_base, kernel_size,
kernel_cmdline,
initrd_base, initrd_size,
0,
graphic_width, graphic_height, graphic_depth);
register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL);
}
| {
"code": [
" pci_nic_init(&nd_table[i], \"ne2k_pci\", NULL);"
],
"line_no": [
305
]
} | static void FUNC_0 (ram_addr_t VAR_0,
const char *VAR_1,
const char *VAR_2,
const char *VAR_3,
const char *VAR_4,
const char *VAR_5)
{
CPUState *env = NULL, *envs[MAX_CPUS];
char *VAR_6;
nvram_t nvram;
m48t59_t *m48t59;
int VAR_7;
int VAR_8, VAR_9, VAR_10, VAR_11;
ram_addr_t ram_offset, bios_offset;
uint32_t kernel_base, kernel_size, initrd_base, initrd_size;
PCIBus *pci_bus;
qemu_irq *i8259;
int VAR_12;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
DriveInfo *fd[MAX_FD];
sysctrl = qemu_mallocz(sizeof(sysctrl_t));
VAR_8 = (VAR_2 != NULL);
if (VAR_5 == NULL)
VAR_5 = "602";
for (VAR_9 = 0; VAR_9 < smp_cpus; VAR_9++) {
env = cpu_init(VAR_5);
if (!env) {
fprintf(stderr, "Unable to find PowerPC CPU definition\n");
exit(1);
}
if (env->flags & POWERPC_FLAG_RTC_CLK) {
cpu_ppc_tb_init(env, 7812500UL);
} else {
cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);
}
qemu_register_reset(&cpu_ppc_reset, env);
envs[VAR_9] = env;
}
ram_offset = qemu_ram_alloc(VAR_0);
cpu_register_physical_memory(0, VAR_0, ram_offset);
bios_offset = qemu_ram_alloc(BIOS_SIZE);
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
VAR_6 = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (VAR_6) {
VAR_11 = get_image_size(VAR_6);
} else {
VAR_11 = -1;
}
if (VAR_11 > 0 && VAR_11 <= BIOS_SIZE) {
target_phys_addr_t bios_addr;
VAR_11 = (VAR_11 + 0xfff) & ~0xfff;
bios_addr = (uint32_t)(-VAR_11);
cpu_register_physical_memory(bios_addr, VAR_11,
bios_offset | IO_MEM_ROM);
VAR_11 = load_image_targphys(VAR_6, bios_addr, VAR_11);
}
if (VAR_11 < 0 || VAR_11 > BIOS_SIZE) {
hw_error("qemu: could not load PPC PREP bios '%s'\n", bios_name);
}
if (VAR_6) {
qemu_free(VAR_6);
}
if (env->nip < 0xFFF80000 && VAR_11 < 0x00100000) {
hw_error("PowerPC 601 / 620 / 970 need a 1MB BIOS\n");
}
if (VAR_8) {
kernel_base = KERNEL_LOAD_ADDR;
kernel_size = load_image_targphys(VAR_2, kernel_base,
VAR_0 - kernel_base);
if (kernel_size < 0) {
hw_error("qemu: could not load kernel '%s'\n", VAR_2);
exit(1);
}
if (VAR_4) {
initrd_base = INITRD_LOAD_ADDR;
initrd_size = load_image_targphys(VAR_4, initrd_base,
VAR_0 - initrd_base);
if (initrd_size < 0) {
hw_error("qemu: could not load initial ram disk '%s'\n",
VAR_4);
}
} else {
initrd_base = 0;
initrd_size = 0;
}
VAR_12 = 'm';
} else {
kernel_base = 0;
kernel_size = 0;
initrd_base = 0;
initrd_size = 0;
VAR_12 = '\0';
for (VAR_9 = 0; VAR_1[VAR_9] != '\0'; VAR_9++) {
if (VAR_1[VAR_9] >= 'a' && VAR_1[VAR_9] <= 'f') {
VAR_12 = VAR_1[VAR_9];
break;
}
}
if (VAR_12 == '\0') {
fprintf(stderr, "No valid boot device for Mac99 machine\n");
exit(1);
}
}
isa_mem_base = 0xc0000000;
if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
hw_error("Only 6xx bus is supported on PREP machine\n");
}
i8259 = i8259_init(first_cpu->irq_inputs[PPC6xx_INPUT_INT]);
pci_bus = pci_prep_init(i8259);
isa_bus_new(NULL);
isa_bus_irqs(i8259);
VAR_7 = cpu_register_io_memory(PPC_prep_io_read,
PPC_prep_io_write, sysctrl);
cpu_register_physical_memory(0x80000000, 0x00800000, VAR_7);
pci_vga_init(pci_bus, 0, 0);
rtc_init(2000);
if (serial_hds[0])
serial_isa_init(0, serial_hds[0]);
VAR_10 = nb_nics;
if (VAR_10 > NE2000_NB_MAX)
VAR_10 = NE2000_NB_MAX;
for(VAR_9 = 0; VAR_9 < VAR_10; VAR_9++) {
if (nd_table[VAR_9].model == NULL) {
nd_table[VAR_9].model = "ne2k_isa";
}
if (strcmp(nd_table[VAR_9].model, "ne2k_isa") == 0) {
isa_ne2000_init(ne2000_io[VAR_9], ne2000_irq[VAR_9], &nd_table[VAR_9]);
} else {
pci_nic_init(&nd_table[VAR_9], "ne2k_pci", NULL);
}
}
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
fprintf(stderr, "qemu: too many IDE bus\n");
exit(1);
}
for(VAR_9 = 0; VAR_9 < MAX_IDE_BUS * MAX_IDE_DEVS; VAR_9++) {
hd[VAR_9] = drive_get(IF_IDE, VAR_9 / MAX_IDE_DEVS, VAR_9 % MAX_IDE_DEVS);
}
for(VAR_9 = 0; VAR_9 < MAX_IDE_BUS; VAR_9++) {
isa_ide_init(ide_iobase[VAR_9], ide_iobase2[VAR_9], ide_irq[VAR_9],
hd[2 * VAR_9],
hd[2 * VAR_9 + 1]);
}
isa_create_simple("i8042");
DMA_init(1);
for(VAR_9 = 0; VAR_9 < MAX_FD; VAR_9++) {
fd[VAR_9] = drive_get(IF_FLOPPY, 0, VAR_9);
}
fdctrl_init_isa(fd);
register_ioport_read(0x61, 1, 1, speaker_ioport_read, NULL);
register_ioport_write(0x61, 1, 1, speaker_ioport_write, NULL);
sysctrl->reset_irq = first_cpu->irq_inputs[PPC6xx_INPUT_HRESET];
register_ioport_read(0x398, 2, 1, &PREP_io_read, sysctrl);
register_ioport_write(0x398, 2, 1, &PREP_io_write, sysctrl);
register_ioport_read(0x0092, 0x01, 1, &PREP_io_800_readb, sysctrl);
register_ioport_write(0x0092, 0x01, 1, &PREP_io_800_writeb, sysctrl);
register_ioport_read(0x0800, 0x52, 1, &PREP_io_800_readb, sysctrl);
register_ioport_write(0x0800, 0x52, 1, &PREP_io_800_writeb, sysctrl);
VAR_7 = cpu_register_io_memory(PPC_intack_read,
PPC_intack_write, NULL);
cpu_register_physical_memory(0xBFFFFFF0, 0x4, VAR_7);
#if 0
VAR_7 = cpu_register_io_memory(PPC_XCSR_read, PPC_XCSR_write,
NULL);
cpu_register_physical_memory(0xFEFF0000, 0x1000, VAR_7);
#endif
if (usb_enabled) {
usb_ohci_init_pci(pci_bus, -1);
}
m48t59 = m48t59_init(i8259[8], 0, 0x0074, NVRAM_SIZE, 59);
if (m48t59 == NULL)
return;
sysctrl->nvram = m48t59;
nvram.opaque = m48t59;
nvram.read_fn = &m48t59_read;
nvram.write_fn = &m48t59_write;
PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "PREP", VAR_0, VAR_12,
kernel_base, kernel_size,
VAR_3,
initrd_base, initrd_size,
0,
graphic_width, graphic_height, graphic_depth);
register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL);
}
| [
"static void FUNC_0 (ram_addr_t VAR_0,\nconst char *VAR_1,\nconst char *VAR_2,\nconst char *VAR_3,\nconst char *VAR_4,\nconst char *VAR_5)\n{",
"CPUState *env = NULL, *envs[MAX_CPUS];",
"char *VAR_6;",
"nvram_t nvram;",
"m48t59_t *m48t59;",
"int VAR_7;",
"int VAR_8, VAR_9, VAR_10, VAR_11;",
"ram_addr_t ram_offset, bios_offset;",
"uint32_t kernel_base, kernel_size, initrd_base, initrd_size;",
"PCIBus *pci_bus;",
"qemu_irq *i8259;",
"int VAR_12;",
"DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];",
"DriveInfo *fd[MAX_FD];",
"sysctrl = qemu_mallocz(sizeof(sysctrl_t));",
"VAR_8 = (VAR_2 != NULL);",
"if (VAR_5 == NULL)\nVAR_5 = \"602\";",
"for (VAR_9 = 0; VAR_9 < smp_cpus; VAR_9++) {",
"env = cpu_init(VAR_5);",
"if (!env) {",
"fprintf(stderr, \"Unable to find PowerPC CPU definition\\n\");",
"exit(1);",
"}",
"if (env->flags & POWERPC_FLAG_RTC_CLK) {",
"cpu_ppc_tb_init(env, 7812500UL);",
"} else {",
"cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);",
"}",
"qemu_register_reset(&cpu_ppc_reset, env);",
"envs[VAR_9] = env;",
"}",
"ram_offset = qemu_ram_alloc(VAR_0);",
"cpu_register_physical_memory(0, VAR_0, ram_offset);",
"bios_offset = qemu_ram_alloc(BIOS_SIZE);",
"if (bios_name == NULL)\nbios_name = BIOS_FILENAME;",
"VAR_6 = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);",
"if (VAR_6) {",
"VAR_11 = get_image_size(VAR_6);",
"} else {",
"VAR_11 = -1;",
"}",
"if (VAR_11 > 0 && VAR_11 <= BIOS_SIZE) {",
"target_phys_addr_t bios_addr;",
"VAR_11 = (VAR_11 + 0xfff) & ~0xfff;",
"bios_addr = (uint32_t)(-VAR_11);",
"cpu_register_physical_memory(bios_addr, VAR_11,\nbios_offset | IO_MEM_ROM);",
"VAR_11 = load_image_targphys(VAR_6, bios_addr, VAR_11);",
"}",
"if (VAR_11 < 0 || VAR_11 > BIOS_SIZE) {",
"hw_error(\"qemu: could not load PPC PREP bios '%s'\\n\", bios_name);",
"}",
"if (VAR_6) {",
"qemu_free(VAR_6);",
"}",
"if (env->nip < 0xFFF80000 && VAR_11 < 0x00100000) {",
"hw_error(\"PowerPC 601 / 620 / 970 need a 1MB BIOS\\n\");",
"}",
"if (VAR_8) {",
"kernel_base = KERNEL_LOAD_ADDR;",
"kernel_size = load_image_targphys(VAR_2, kernel_base,\nVAR_0 - kernel_base);",
"if (kernel_size < 0) {",
"hw_error(\"qemu: could not load kernel '%s'\\n\", VAR_2);",
"exit(1);",
"}",
"if (VAR_4) {",
"initrd_base = INITRD_LOAD_ADDR;",
"initrd_size = load_image_targphys(VAR_4, initrd_base,\nVAR_0 - initrd_base);",
"if (initrd_size < 0) {",
"hw_error(\"qemu: could not load initial ram disk '%s'\\n\",\nVAR_4);",
"}",
"} else {",
"initrd_base = 0;",
"initrd_size = 0;",
"}",
"VAR_12 = 'm';",
"} else {",
"kernel_base = 0;",
"kernel_size = 0;",
"initrd_base = 0;",
"initrd_size = 0;",
"VAR_12 = '\\0';",
"for (VAR_9 = 0; VAR_1[VAR_9] != '\\0'; VAR_9++) {",
"if (VAR_1[VAR_9] >= 'a' && VAR_1[VAR_9] <= 'f') {",
"VAR_12 = VAR_1[VAR_9];",
"break;",
"}",
"}",
"if (VAR_12 == '\\0') {",
"fprintf(stderr, \"No valid boot device for Mac99 machine\\n\");",
"exit(1);",
"}",
"}",
"isa_mem_base = 0xc0000000;",
"if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {",
"hw_error(\"Only 6xx bus is supported on PREP machine\\n\");",
"}",
"i8259 = i8259_init(first_cpu->irq_inputs[PPC6xx_INPUT_INT]);",
"pci_bus = pci_prep_init(i8259);",
"isa_bus_new(NULL);",
"isa_bus_irqs(i8259);",
"VAR_7 = cpu_register_io_memory(PPC_prep_io_read,\nPPC_prep_io_write, sysctrl);",
"cpu_register_physical_memory(0x80000000, 0x00800000, VAR_7);",
"pci_vga_init(pci_bus, 0, 0);",
"rtc_init(2000);",
"if (serial_hds[0])\nserial_isa_init(0, serial_hds[0]);",
"VAR_10 = nb_nics;",
"if (VAR_10 > NE2000_NB_MAX)\nVAR_10 = NE2000_NB_MAX;",
"for(VAR_9 = 0; VAR_9 < VAR_10; VAR_9++) {",
"if (nd_table[VAR_9].model == NULL) {",
"nd_table[VAR_9].model = \"ne2k_isa\";",
"}",
"if (strcmp(nd_table[VAR_9].model, \"ne2k_isa\") == 0) {",
"isa_ne2000_init(ne2000_io[VAR_9], ne2000_irq[VAR_9], &nd_table[VAR_9]);",
"} else {",
"pci_nic_init(&nd_table[VAR_9], \"ne2k_pci\", NULL);",
"}",
"}",
"if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {",
"fprintf(stderr, \"qemu: too many IDE bus\\n\");",
"exit(1);",
"}",
"for(VAR_9 = 0; VAR_9 < MAX_IDE_BUS * MAX_IDE_DEVS; VAR_9++) {",
"hd[VAR_9] = drive_get(IF_IDE, VAR_9 / MAX_IDE_DEVS, VAR_9 % MAX_IDE_DEVS);",
"}",
"for(VAR_9 = 0; VAR_9 < MAX_IDE_BUS; VAR_9++) {",
"isa_ide_init(ide_iobase[VAR_9], ide_iobase2[VAR_9], ide_irq[VAR_9],\nhd[2 * VAR_9],\nhd[2 * VAR_9 + 1]);",
"}",
"isa_create_simple(\"i8042\");",
"DMA_init(1);",
"for(VAR_9 = 0; VAR_9 < MAX_FD; VAR_9++) {",
"fd[VAR_9] = drive_get(IF_FLOPPY, 0, VAR_9);",
"}",
"fdctrl_init_isa(fd);",
"register_ioport_read(0x61, 1, 1, speaker_ioport_read, NULL);",
"register_ioport_write(0x61, 1, 1, speaker_ioport_write, NULL);",
"sysctrl->reset_irq = first_cpu->irq_inputs[PPC6xx_INPUT_HRESET];",
"register_ioport_read(0x398, 2, 1, &PREP_io_read, sysctrl);",
"register_ioport_write(0x398, 2, 1, &PREP_io_write, sysctrl);",
"register_ioport_read(0x0092, 0x01, 1, &PREP_io_800_readb, sysctrl);",
"register_ioport_write(0x0092, 0x01, 1, &PREP_io_800_writeb, sysctrl);",
"register_ioport_read(0x0800, 0x52, 1, &PREP_io_800_readb, sysctrl);",
"register_ioport_write(0x0800, 0x52, 1, &PREP_io_800_writeb, sysctrl);",
"VAR_7 = cpu_register_io_memory(PPC_intack_read,\nPPC_intack_write, NULL);",
"cpu_register_physical_memory(0xBFFFFFF0, 0x4, VAR_7);",
"#if 0\nVAR_7 = cpu_register_io_memory(PPC_XCSR_read, PPC_XCSR_write,\nNULL);",
"cpu_register_physical_memory(0xFEFF0000, 0x1000, VAR_7);",
"#endif\nif (usb_enabled) {",
"usb_ohci_init_pci(pci_bus, -1);",
"}",
"m48t59 = m48t59_init(i8259[8], 0, 0x0074, NVRAM_SIZE, 59);",
"if (m48t59 == NULL)\nreturn;",
"sysctrl->nvram = m48t59;",
"nvram.opaque = m48t59;",
"nvram.read_fn = &m48t59_read;",
"nvram.write_fn = &m48t59_write;",
"PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, \"PREP\", VAR_0, VAR_12,\nkernel_base, kernel_size,\nVAR_3,\ninitrd_base, initrd_size,\n0,\ngraphic_width, graphic_height, graphic_depth);",
"register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
43
],
[
47
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
93
],
[
95
],
[
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
],
[
155
],
[
157
],
[
161,
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
179,
181
],
[
183
],
[
185,
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
253
],
[
255
],
[
261,
263
],
[
265
],
[
271
],
[
277
],
[
281,
283
],
[
285
],
[
287,
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
313
],
[
315
],
[
317
],
[
319
],
[
323
],
[
325
],
[
327
],
[
331
],
[
333,
335,
337
],
[
339
],
[
341
],
[
343
],
[
349
],
[
351
],
[
353
],
[
355
],
[
361
],
[
363
],
[
367
],
[
369
],
[
371
],
[
375
],
[
377
],
[
379
],
[
381
],
[
385,
387
],
[
389
],
[
393,
395,
397
],
[
399
],
[
401,
405
],
[
407
],
[
409
],
[
413
],
[
415,
417
],
[
419
],
[
425
],
[
427
],
[
429
],
[
431,
433,
435,
437,
441,
443
],
[
449
],
[
451
]
] |
24,495 | static int execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
MpegEncContext * const s = &h->s;
int i, j;
int current_ref_assigned=0;
Picture *pic;
if((s->avctx->debug&FF_DEBUG_MMCO) && mmco_count==0)
av_log(h->s.avctx, AV_LOG_DEBUG, "no mmco here\n");
for(i=0; i<mmco_count; i++){
int structure, frame_num, unref_pic;
if(s->avctx->debug&FF_DEBUG_MMCO)
av_log(h->s.avctx, AV_LOG_DEBUG, "mmco:%d %d %d\n", h->mmco[i].opcode, h->mmco[i].short_pic_num, h->mmco[i].long_arg);
switch(mmco[i].opcode){
case MMCO_SHORT2UNUSED:
if(s->avctx->debug&FF_DEBUG_MMCO)
av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref short %d count %d\n", h->mmco[i].short_pic_num, h->short_ref_count);
frame_num = pic_num_extract(h, mmco[i].short_pic_num, &structure);
pic = find_short(h, frame_num, &j);
if (pic) {
if (unreference_pic(h, pic, structure ^ PICT_FRAME))
remove_short_at_index(h, j);
} else if(s->avctx->debug&FF_DEBUG_MMCO)
av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref short failure\n");
case MMCO_SHORT2LONG:
if (FIELD_PICTURE && mmco[i].long_arg < h->long_ref_count &&
h->long_ref[mmco[i].long_arg]->frame_num ==
mmco[i].short_pic_num / 2) {
/* do nothing, we've already moved this field pair. */
int frame_num = mmco[i].short_pic_num >> FIELD_PICTURE;
pic= remove_long(h, mmco[i].long_arg);
if(pic) unreference_pic(h, pic, 0);
h->long_ref[ mmco[i].long_arg ]= remove_short(h, frame_num);
if (h->long_ref[ mmco[i].long_arg ]){
h->long_ref[ mmco[i].long_arg ]->long_ref=1;
h->long_ref_count++;
case MMCO_LONG2UNUSED:
j = pic_num_extract(h, mmco[i].long_arg, &structure);
pic = h->long_ref[j];
if (pic) {
if (unreference_pic(h, pic, structure ^ PICT_FRAME))
remove_long_at_index(h, j);
} else if(s->avctx->debug&FF_DEBUG_MMCO)
av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref long failure\n");
case MMCO_LONG:
unref_pic = 1;
if (FIELD_PICTURE && !s->first_field) {
if (h->long_ref[mmco[i].long_arg] == s->current_picture_ptr) {
/* Just mark second field as referenced */
unref_pic = 0;
} else if (s->current_picture_ptr->reference) {
/* First field in pair is in short term list or
* at a different long term index.
* This is not allowed; see 7.4.3, notes 2 and 3.
* Report the problem and keep the pair where it is,
* and mark this field valid.
"illegal long term reference assignment for second "
"field in complementary field pair (first field is "
"short term or has non-matching long index)\n");
unref_pic = 0;
if (unref_pic) {
pic= remove_long(h, mmco[i].long_arg);
if(pic) unreference_pic(h, pic, 0);
h->long_ref[ mmco[i].long_arg ]= s->current_picture_ptr;
h->long_ref[ mmco[i].long_arg ]->long_ref=1;
h->long_ref_count++;
s->current_picture_ptr->reference |= s->picture_structure;
current_ref_assigned=1;
case MMCO_SET_MAX_LONG:
assert(mmco[i].long_arg <= 16);
// just remove the long term which index is greater than new max
for(j = mmco[i].long_arg; j<16; j++){
pic = remove_long(h, j);
if (pic) unreference_pic(h, pic, 0);
case MMCO_RESET:
while(h->short_ref_count){
pic= remove_short(h, h->short_ref[0]->frame_num);
if(pic) unreference_pic(h, pic, 0);
for(j = 0; j < 16; j++) {
pic= remove_long(h, j);
if(pic) unreference_pic(h, pic, 0);
default: assert(0);
if (!current_ref_assigned && FIELD_PICTURE &&
!s->first_field && s->current_picture_ptr->reference) {
/* Second field of complementary field pair; the first field of
* which is already referenced. If short referenced, it
* should be first entry in short_ref. If not, it must exist
* in long_ref; trying to put it on the short list here is an
* error in the encoded bit stream (ref: 7.4.3, NOTE 2 and 3).
if (h->short_ref_count && h->short_ref[0] == s->current_picture_ptr) {
/* Just mark the second field valid */
s->current_picture_ptr->reference = PICT_FRAME;
} else if (s->current_picture_ptr->long_ref) {
av_log(h->s.avctx, AV_LOG_ERROR, "illegal short term reference "
"assignment for second field "
"in complementary field pair "
"(first field is long term)\n");
/*
* First field in reference, but not in any sensible place on our
* reference lists. This shouldn't happen unless reference
* handling somewhere else is wrong.
assert(0);
current_ref_assigned = 1;
if(!current_ref_assigned){
pic= remove_short(h, s->current_picture_ptr->frame_num);
if(pic){
unreference_pic(h, pic, 0);
av_log(h->s.avctx, AV_LOG_ERROR, "illegal short term buffer state detected\n");
if(h->short_ref_count)
memmove(&h->short_ref[1], &h->short_ref[0], h->short_ref_count*sizeof(Picture*));
h->short_ref[0]= s->current_picture_ptr;
h->short_ref[0]->long_ref=0;
h->short_ref_count++;
s->current_picture_ptr->reference |= s->picture_structure;
print_short_term(h);
print_long_term(h);
return 0; | true | FFmpeg | aeb59e839f97e88dd0b5f0b2a4422a9ee75321e5 | static int execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
MpegEncContext * const s = &h->s;
int i, j;
int current_ref_assigned=0;
Picture *pic;
if((s->avctx->debug&FF_DEBUG_MMCO) && mmco_count==0)
av_log(h->s.avctx, AV_LOG_DEBUG, "no mmco here\n");
for(i=0; i<mmco_count; i++){
int structure, frame_num, unref_pic;
if(s->avctx->debug&FF_DEBUG_MMCO)
av_log(h->s.avctx, AV_LOG_DEBUG, "mmco:%d %d %d\n", h->mmco[i].opcode, h->mmco[i].short_pic_num, h->mmco[i].long_arg);
switch(mmco[i].opcode){
case MMCO_SHORT2UNUSED:
if(s->avctx->debug&FF_DEBUG_MMCO)
av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref short %d count %d\n", h->mmco[i].short_pic_num, h->short_ref_count);
frame_num = pic_num_extract(h, mmco[i].short_pic_num, &structure);
pic = find_short(h, frame_num, &j);
if (pic) {
if (unreference_pic(h, pic, structure ^ PICT_FRAME))
remove_short_at_index(h, j);
} else if(s->avctx->debug&FF_DEBUG_MMCO)
av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref short failure\n");
case MMCO_SHORT2LONG:
if (FIELD_PICTURE && mmco[i].long_arg < h->long_ref_count &&
h->long_ref[mmco[i].long_arg]->frame_num ==
mmco[i].short_pic_num / 2) {
int frame_num = mmco[i].short_pic_num >> FIELD_PICTURE;
pic= remove_long(h, mmco[i].long_arg);
if(pic) unreference_pic(h, pic, 0);
h->long_ref[ mmco[i].long_arg ]= remove_short(h, frame_num);
if (h->long_ref[ mmco[i].long_arg ]){
h->long_ref[ mmco[i].long_arg ]->long_ref=1;
h->long_ref_count++;
case MMCO_LONG2UNUSED:
j = pic_num_extract(h, mmco[i].long_arg, &structure);
pic = h->long_ref[j];
if (pic) {
if (unreference_pic(h, pic, structure ^ PICT_FRAME))
remove_long_at_index(h, j);
} else if(s->avctx->debug&FF_DEBUG_MMCO)
av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref long failure\n");
case MMCO_LONG:
unref_pic = 1;
if (FIELD_PICTURE && !s->first_field) {
if (h->long_ref[mmco[i].long_arg] == s->current_picture_ptr) {
unref_pic = 0;
} else if (s->current_picture_ptr->reference) {
s->current_picture_ptr->reference = PICT_FRAME;
} else if (s->current_picture_ptr->long_ref) {
av_log(h->s.avctx, AV_LOG_ERROR, "illegal short term reference "
"assignment for second field "
"in complementary field pair "
"(first field is long term)\n");
/*
* First field in reference, but not in any sensible place on our
* reference lists. This shouldn't happen unless reference
* handling somewhere else is wrong.
assert(0);
current_ref_assigned = 1;
if(!current_ref_assigned){
pic= remove_short(h, s->current_picture_ptr->frame_num);
if(pic){
unreference_pic(h, pic, 0);
av_log(h->s.avctx, AV_LOG_ERROR, "illegal short term buffer state detected\n");
if(h->short_ref_count)
memmove(&h->short_ref[1], &h->short_ref[0], h->short_ref_count*sizeof(Picture*));
h->short_ref[0]= s->current_picture_ptr;
h->short_ref[0]->long_ref=0;
h->short_ref_count++;
s->current_picture_ptr->reference |= s->picture_structure;
print_short_term(h);
print_long_term(h);
return 0; | {
"code": [],
"line_no": []
} | static int FUNC_0(H264Context *VAR_0, MMCO *VAR_1, int VAR_2){
MpegEncContext * const s = &VAR_0->s;
int VAR_3, VAR_4;
int VAR_5=0;
Picture *pic;
if((s->avctx->debug&FF_DEBUG_MMCO) && VAR_2==0)
av_log(VAR_0->s.avctx, AV_LOG_DEBUG, "no VAR_1 here\n");
for(VAR_3=0; VAR_3<VAR_2; VAR_3++){
int VAR_6, VAR_9, VAR_8;
if(s->avctx->debug&FF_DEBUG_MMCO)
av_log(VAR_0->s.avctx, AV_LOG_DEBUG, "VAR_1:%d %d %d\n", VAR_0->VAR_1[VAR_3].opcode, VAR_0->VAR_1[VAR_3].short_pic_num, VAR_0->VAR_1[VAR_3].long_arg);
switch(VAR_1[VAR_3].opcode){
case MMCO_SHORT2UNUSED:
if(s->avctx->debug&FF_DEBUG_MMCO)
av_log(VAR_0->s.avctx, AV_LOG_DEBUG, "VAR_1: unref short %d count %d\n", VAR_0->VAR_1[VAR_3].short_pic_num, VAR_0->short_ref_count);
VAR_9 = pic_num_extract(VAR_0, VAR_1[VAR_3].short_pic_num, &VAR_6);
pic = find_short(VAR_0, VAR_9, &VAR_4);
if (pic) {
if (unreference_pic(VAR_0, pic, VAR_6 ^ PICT_FRAME))
remove_short_at_index(VAR_0, VAR_4);
} else if(s->avctx->debug&FF_DEBUG_MMCO)
av_log(VAR_0->s.avctx, AV_LOG_DEBUG, "VAR_1: unref short failure\n");
case MMCO_SHORT2LONG:
if (FIELD_PICTURE && VAR_1[VAR_3].long_arg < VAR_0->long_ref_count &&
VAR_0->long_ref[VAR_1[VAR_3].long_arg]->VAR_9 ==
VAR_1[VAR_3].short_pic_num / 2) {
int VAR_9 = VAR_1[VAR_3].short_pic_num >> FIELD_PICTURE;
pic= remove_long(VAR_0, VAR_1[VAR_3].long_arg);
if(pic) unreference_pic(VAR_0, pic, 0);
VAR_0->long_ref[ VAR_1[VAR_3].long_arg ]= remove_short(VAR_0, VAR_9);
if (VAR_0->long_ref[ VAR_1[VAR_3].long_arg ]){
VAR_0->long_ref[ VAR_1[VAR_3].long_arg ]->long_ref=1;
VAR_0->long_ref_count++;
case MMCO_LONG2UNUSED:
VAR_4 = pic_num_extract(VAR_0, VAR_1[VAR_3].long_arg, &VAR_6);
pic = VAR_0->long_ref[VAR_4];
if (pic) {
if (unreference_pic(VAR_0, pic, VAR_6 ^ PICT_FRAME))
remove_long_at_index(VAR_0, VAR_4);
} else if(s->avctx->debug&FF_DEBUG_MMCO)
av_log(VAR_0->s.avctx, AV_LOG_DEBUG, "VAR_1: unref long failure\n");
case MMCO_LONG:
VAR_8 = 1;
if (FIELD_PICTURE && !s->first_field) {
if (VAR_0->long_ref[VAR_1[VAR_3].long_arg] == s->current_picture_ptr) {
VAR_8 = 0;
} else if (s->current_picture_ptr->reference) {
s->current_picture_ptr->reference = PICT_FRAME;
} else if (s->current_picture_ptr->long_ref) {
av_log(VAR_0->s.avctx, AV_LOG_ERROR, "illegal short term reference "
"assignment for second field "
"in complementary field pair "
"(first field is long term)\n");
/*
* First field in reference, but not in any sensible place on our
* reference lists. This shouldn't happen unless reference
* handling somewhere else is wrong.
assert(0);
VAR_5 = 1;
if(!VAR_5){
pic= remove_short(VAR_0, s->current_picture_ptr->VAR_9);
if(pic){
unreference_pic(VAR_0, pic, 0);
av_log(VAR_0->s.avctx, AV_LOG_ERROR, "illegal short term buffer state detected\n");
if(VAR_0->short_ref_count)
memmove(&VAR_0->short_ref[1], &VAR_0->short_ref[0], VAR_0->short_ref_count*sizeof(Picture*));
VAR_0->short_ref[0]= s->current_picture_ptr;
VAR_0->short_ref[0]->long_ref=0;
VAR_0->short_ref_count++;
s->current_picture_ptr->reference |= s->picture_structure;
print_short_term(VAR_0);
print_long_term(VAR_0);
return 0; | [
"static int FUNC_0(H264Context *VAR_0, MMCO *VAR_1, int VAR_2){",
"MpegEncContext * const s = &VAR_0->s;",
"int VAR_3, VAR_4;",
"int VAR_5=0;",
"Picture *pic;",
"if((s->avctx->debug&FF_DEBUG_MMCO) && VAR_2==0)\nav_log(VAR_0->s.avctx, AV_LOG_DEBUG, \"no VAR_1 here\\n\");",
"for(VAR_3=0; VAR_3<VAR_2; VAR_3++){",
"int VAR_6, VAR_9, VAR_8;",
"if(s->avctx->debug&FF_DEBUG_MMCO)\nav_log(VAR_0->s.avctx, AV_LOG_DEBUG, \"VAR_1:%d %d %d\\n\", VAR_0->VAR_1[VAR_3].opcode, VAR_0->VAR_1[VAR_3].short_pic_num, VAR_0->VAR_1[VAR_3].long_arg);",
"switch(VAR_1[VAR_3].opcode){",
"case MMCO_SHORT2UNUSED:\nif(s->avctx->debug&FF_DEBUG_MMCO)\nav_log(VAR_0->s.avctx, AV_LOG_DEBUG, \"VAR_1: unref short %d count %d\\n\", VAR_0->VAR_1[VAR_3].short_pic_num, VAR_0->short_ref_count);",
"VAR_9 = pic_num_extract(VAR_0, VAR_1[VAR_3].short_pic_num, &VAR_6);",
"pic = find_short(VAR_0, VAR_9, &VAR_4);",
"if (pic) {",
"if (unreference_pic(VAR_0, pic, VAR_6 ^ PICT_FRAME))\nremove_short_at_index(VAR_0, VAR_4);",
"} else if(s->avctx->debug&FF_DEBUG_MMCO)",
"av_log(VAR_0->s.avctx, AV_LOG_DEBUG, \"VAR_1: unref short failure\\n\");",
"case MMCO_SHORT2LONG:\nif (FIELD_PICTURE && VAR_1[VAR_3].long_arg < VAR_0->long_ref_count &&\nVAR_0->long_ref[VAR_1[VAR_3].long_arg]->VAR_9 ==\nVAR_1[VAR_3].short_pic_num / 2) {",
"int VAR_9 = VAR_1[VAR_3].short_pic_num >> FIELD_PICTURE;",
"pic= remove_long(VAR_0, VAR_1[VAR_3].long_arg);",
"if(pic) unreference_pic(VAR_0, pic, 0);",
"VAR_0->long_ref[ VAR_1[VAR_3].long_arg ]= remove_short(VAR_0, VAR_9);",
"if (VAR_0->long_ref[ VAR_1[VAR_3].long_arg ]){",
"VAR_0->long_ref[ VAR_1[VAR_3].long_arg ]->long_ref=1;",
"VAR_0->long_ref_count++;",
"case MMCO_LONG2UNUSED:\nVAR_4 = pic_num_extract(VAR_0, VAR_1[VAR_3].long_arg, &VAR_6);",
"pic = VAR_0->long_ref[VAR_4];",
"if (pic) {",
"if (unreference_pic(VAR_0, pic, VAR_6 ^ PICT_FRAME))\nremove_long_at_index(VAR_0, VAR_4);",
"} else if(s->avctx->debug&FF_DEBUG_MMCO)",
"av_log(VAR_0->s.avctx, AV_LOG_DEBUG, \"VAR_1: unref long failure\\n\");",
"case MMCO_LONG:\nVAR_8 = 1;",
"if (FIELD_PICTURE && !s->first_field) {",
"if (VAR_0->long_ref[VAR_1[VAR_3].long_arg] == s->current_picture_ptr) {",
"VAR_8 = 0;",
"} else if (s->current_picture_ptr->reference) {",
"s->current_picture_ptr->reference = PICT_FRAME;",
"} else if (s->current_picture_ptr->long_ref) {",
"av_log(VAR_0->s.avctx, AV_LOG_ERROR, \"illegal short term reference \"\n\"assignment for second field \"\n\"in complementary field pair \"\n\"(first field is long term)\\n\");",
"/*\n* First field in reference, but not in any sensible place on our\n* reference lists. This shouldn't happen unless reference\n* handling somewhere else is wrong.\nassert(0);",
"VAR_5 = 1;",
"if(!VAR_5){",
"pic= remove_short(VAR_0, s->current_picture_ptr->VAR_9);",
"if(pic){",
"unreference_pic(VAR_0, pic, 0);",
"av_log(VAR_0->s.avctx, AV_LOG_ERROR, \"illegal short term buffer state detected\\n\");",
"if(VAR_0->short_ref_count)\nmemmove(&VAR_0->short_ref[1], &VAR_0->short_ref[0], VAR_0->short_ref_count*sizeof(Picture*));",
"VAR_0->short_ref[0]= s->current_picture_ptr;",
"VAR_0->short_ref[0]->long_ref=0;",
"VAR_0->short_ref_count++;",
"s->current_picture_ptr->reference |= s->picture_structure;",
"print_short_term(VAR_0);",
"print_long_term(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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
2
],
[
3
],
[
4
],
[
5
],
[
6,
7
],
[
8
],
[
9
],
[
10,
11
],
[
12
],
[
13,
14,
15
],
[
16
],
[
17
],
[
18
],
[
19,
20
],
[
21
],
[
22
],
[
23,
24,
25,
26
],
[
28
],
[
29
],
[
30
],
[
31
],
[
32
],
[
33
],
[
34
],
[
35,
36
],
[
37
],
[
38
],
[
39,
40
],
[
41
],
[
42
],
[
43,
44
],
[
45
],
[
46
],
[
48
],
[
49
],
[
90
],
[
91
],
[
92,
93,
94,
95
],
[
96,
97,
98,
99,
100
],
[
101
],
[
102
],
[
103
],
[
104
],
[
105
],
[
106
],
[
107,
108
],
[
109
],
[
110
],
[
111
],
[
112
],
[
113
],
[
114
],
[
115
]
] |
24,496 | static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref)
{
AVFilterContext *ctx = inlink->dst;
ShowInfoContext *showinfo = ctx->priv;
uint32_t plane_checksum[8] = {0}, checksum = 0;
char chlayout_str[128];
int plane;
for (plane = 0; samplesref->data[plane] && plane < 8; plane++) {
uint8_t *data = samplesref->data[plane];
int linesize = samplesref->linesize[plane];
plane_checksum[plane] = av_adler32_update(plane_checksum[plane],
data, linesize);
checksum = av_adler32_update(checksum, data, linesize);
}
av_get_channel_layout_string(chlayout_str, sizeof(chlayout_str), -1,
samplesref->audio->channel_layout);
av_log(ctx, AV_LOG_INFO,
"n:%d pts:%"PRId64" pts_time:%f pos:%"PRId64" "
"fmt:%s chlayout:%s nb_samples:%d rate:%d planar:%d "
"checksum:%u plane_checksum[%u %u %u %u %u %u %u %u]\n",
showinfo->frame,
samplesref->pts, samplesref->pts * av_q2d(inlink->time_base),
samplesref->pos,
av_get_sample_fmt_name(samplesref->format),
chlayout_str,
samplesref->audio->nb_samples,
samplesref->audio->sample_rate,
samplesref->audio->planar,
checksum,
plane_checksum[0], plane_checksum[1], plane_checksum[2], plane_checksum[3],
plane_checksum[4], plane_checksum[5], plane_checksum[6], plane_checksum[7]);
showinfo->frame++;
avfilter_filter_samples(inlink->dst->outputs[0], samplesref);
}
| false | FFmpeg | cc6b8c4b612d239bef31a8115402b03453c2b4bc | static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref)
{
AVFilterContext *ctx = inlink->dst;
ShowInfoContext *showinfo = ctx->priv;
uint32_t plane_checksum[8] = {0}, checksum = 0;
char chlayout_str[128];
int plane;
for (plane = 0; samplesref->data[plane] && plane < 8; plane++) {
uint8_t *data = samplesref->data[plane];
int linesize = samplesref->linesize[plane];
plane_checksum[plane] = av_adler32_update(plane_checksum[plane],
data, linesize);
checksum = av_adler32_update(checksum, data, linesize);
}
av_get_channel_layout_string(chlayout_str, sizeof(chlayout_str), -1,
samplesref->audio->channel_layout);
av_log(ctx, AV_LOG_INFO,
"n:%d pts:%"PRId64" pts_time:%f pos:%"PRId64" "
"fmt:%s chlayout:%s nb_samples:%d rate:%d planar:%d "
"checksum:%u plane_checksum[%u %u %u %u %u %u %u %u]\n",
showinfo->frame,
samplesref->pts, samplesref->pts * av_q2d(inlink->time_base),
samplesref->pos,
av_get_sample_fmt_name(samplesref->format),
chlayout_str,
samplesref->audio->nb_samples,
samplesref->audio->sample_rate,
samplesref->audio->planar,
checksum,
plane_checksum[0], plane_checksum[1], plane_checksum[2], plane_checksum[3],
plane_checksum[4], plane_checksum[5], plane_checksum[6], plane_checksum[7]);
showinfo->frame++;
avfilter_filter_samples(inlink->dst->outputs[0], samplesref);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVFilterLink *VAR_0, AVFilterBufferRef *VAR_1)
{
AVFilterContext *ctx = VAR_0->dst;
ShowInfoContext *showinfo = ctx->priv;
uint32_t plane_checksum[8] = {0}, checksum = 0;
char VAR_2[128];
int VAR_3;
for (VAR_3 = 0; VAR_1->data[VAR_3] && VAR_3 < 8; VAR_3++) {
uint8_t *data = VAR_1->data[VAR_3];
int linesize = VAR_1->linesize[VAR_3];
plane_checksum[VAR_3] = av_adler32_update(plane_checksum[VAR_3],
data, linesize);
checksum = av_adler32_update(checksum, data, linesize);
}
av_get_channel_layout_string(VAR_2, sizeof(VAR_2), -1,
VAR_1->audio->channel_layout);
av_log(ctx, AV_LOG_INFO,
"n:%d pts:%"PRId64" pts_time:%f pos:%"PRId64" "
"fmt:%s chlayout:%s nb_samples:%d rate:%d planar:%d "
"checksum:%u plane_checksum[%u %u %u %u %u %u %u %u]\n",
showinfo->frame,
VAR_1->pts, VAR_1->pts * av_q2d(VAR_0->time_base),
VAR_1->pos,
av_get_sample_fmt_name(VAR_1->format),
VAR_2,
VAR_1->audio->nb_samples,
VAR_1->audio->sample_rate,
VAR_1->audio->planar,
checksum,
plane_checksum[0], plane_checksum[1], plane_checksum[2], plane_checksum[3],
plane_checksum[4], plane_checksum[5], plane_checksum[6], plane_checksum[7]);
showinfo->frame++;
avfilter_filter_samples(VAR_0->dst->outputs[0], VAR_1);
}
| [
"static void FUNC_0(AVFilterLink *VAR_0, AVFilterBufferRef *VAR_1)\n{",
"AVFilterContext *ctx = VAR_0->dst;",
"ShowInfoContext *showinfo = ctx->priv;",
"uint32_t plane_checksum[8] = {0}, checksum = 0;",
"char VAR_2[128];",
"int VAR_3;",
"for (VAR_3 = 0; VAR_1->data[VAR_3] && VAR_3 < 8; VAR_3++) {",
"uint8_t *data = VAR_1->data[VAR_3];",
"int linesize = VAR_1->linesize[VAR_3];",
"plane_checksum[VAR_3] = av_adler32_update(plane_checksum[VAR_3],\ndata, linesize);",
"checksum = av_adler32_update(checksum, data, linesize);",
"}",
"av_get_channel_layout_string(VAR_2, sizeof(VAR_2), -1,\nVAR_1->audio->channel_layout);",
"av_log(ctx, AV_LOG_INFO,\n\"n:%d pts:%\"PRId64\" pts_time:%f pos:%\"PRId64\" \"\n\"fmt:%s chlayout:%s nb_samples:%d rate:%d planar:%d \"\n\"checksum:%u plane_checksum[%u %u %u %u %u %u %u %u]\\n\",\nshowinfo->frame,\nVAR_1->pts, VAR_1->pts * av_q2d(VAR_0->time_base),\nVAR_1->pos,\nav_get_sample_fmt_name(VAR_1->format),\nVAR_2,\nVAR_1->audio->nb_samples,\nVAR_1->audio->sample_rate,\nVAR_1->audio->planar,\nchecksum,\nplane_checksum[0], plane_checksum[1], plane_checksum[2], plane_checksum[3],\nplane_checksum[4], plane_checksum[5], plane_checksum[6], plane_checksum[7]);",
"showinfo->frame++;",
"avfilter_filter_samples(VAR_0->dst->outputs[0], VAR_1);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25,
27
],
[
29
],
[
31
],
[
35,
37
],
[
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69
],
[
73
],
[
77
],
[
79
]
] |
24,497 | static av_cold int vaapi_encode_init_rate_control(AVCodecContext *avctx)
{
VAAPIEncodeContext *ctx = avctx->priv_data;
int hrd_buffer_size;
int hrd_initial_buffer_fullness;
if (avctx->rc_buffer_size)
hrd_buffer_size = avctx->rc_buffer_size;
else
hrd_buffer_size = avctx->bit_rate;
if (avctx->rc_initial_buffer_occupancy)
hrd_initial_buffer_fullness = avctx->rc_initial_buffer_occupancy;
else
hrd_initial_buffer_fullness = hrd_buffer_size * 3 / 4;
ctx->rc_params.misc.type = VAEncMiscParameterTypeRateControl;
ctx->rc_params.rc = (VAEncMiscParameterRateControl) {
.bits_per_second = avctx->bit_rate,
.target_percentage = 66,
.window_size = 1000,
.initial_qp = (avctx->qmax >= 0 ? avctx->qmax : 40),
.min_qp = (avctx->qmin >= 0 ? avctx->qmin : 18),
.basic_unit_size = 0,
};
ctx->global_params[ctx->nb_global_params] =
&ctx->rc_params.misc;
ctx->global_params_size[ctx->nb_global_params++] =
sizeof(ctx->rc_params);
ctx->hrd_params.misc.type = VAEncMiscParameterTypeHRD;
ctx->hrd_params.hrd = (VAEncMiscParameterHRD) {
.initial_buffer_fullness = hrd_initial_buffer_fullness,
.buffer_size = hrd_buffer_size,
};
ctx->global_params[ctx->nb_global_params] =
&ctx->hrd_params.misc;
ctx->global_params_size[ctx->nb_global_params++] =
sizeof(ctx->hrd_params);
return 0;
}
| false | FFmpeg | f033ba470fbab1ff6838666d4d86411effa97b27 | static av_cold int vaapi_encode_init_rate_control(AVCodecContext *avctx)
{
VAAPIEncodeContext *ctx = avctx->priv_data;
int hrd_buffer_size;
int hrd_initial_buffer_fullness;
if (avctx->rc_buffer_size)
hrd_buffer_size = avctx->rc_buffer_size;
else
hrd_buffer_size = avctx->bit_rate;
if (avctx->rc_initial_buffer_occupancy)
hrd_initial_buffer_fullness = avctx->rc_initial_buffer_occupancy;
else
hrd_initial_buffer_fullness = hrd_buffer_size * 3 / 4;
ctx->rc_params.misc.type = VAEncMiscParameterTypeRateControl;
ctx->rc_params.rc = (VAEncMiscParameterRateControl) {
.bits_per_second = avctx->bit_rate,
.target_percentage = 66,
.window_size = 1000,
.initial_qp = (avctx->qmax >= 0 ? avctx->qmax : 40),
.min_qp = (avctx->qmin >= 0 ? avctx->qmin : 18),
.basic_unit_size = 0,
};
ctx->global_params[ctx->nb_global_params] =
&ctx->rc_params.misc;
ctx->global_params_size[ctx->nb_global_params++] =
sizeof(ctx->rc_params);
ctx->hrd_params.misc.type = VAEncMiscParameterTypeHRD;
ctx->hrd_params.hrd = (VAEncMiscParameterHRD) {
.initial_buffer_fullness = hrd_initial_buffer_fullness,
.buffer_size = hrd_buffer_size,
};
ctx->global_params[ctx->nb_global_params] =
&ctx->hrd_params.misc;
ctx->global_params_size[ctx->nb_global_params++] =
sizeof(ctx->hrd_params);
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
VAAPIEncodeContext *ctx = avctx->priv_data;
int VAR_0;
int VAR_1;
if (avctx->rc_buffer_size)
VAR_0 = avctx->rc_buffer_size;
else
VAR_0 = avctx->bit_rate;
if (avctx->rc_initial_buffer_occupancy)
VAR_1 = avctx->rc_initial_buffer_occupancy;
else
VAR_1 = VAR_0 * 3 / 4;
ctx->rc_params.misc.type = VAEncMiscParameterTypeRateControl;
ctx->rc_params.rc = (VAEncMiscParameterRateControl) {
.bits_per_second = avctx->bit_rate,
.target_percentage = 66,
.window_size = 1000,
.initial_qp = (avctx->qmax >= 0 ? avctx->qmax : 40),
.min_qp = (avctx->qmin >= 0 ? avctx->qmin : 18),
.basic_unit_size = 0,
};
ctx->global_params[ctx->nb_global_params] =
&ctx->rc_params.misc;
ctx->global_params_size[ctx->nb_global_params++] =
sizeof(ctx->rc_params);
ctx->hrd_params.misc.type = VAEncMiscParameterTypeHRD;
ctx->hrd_params.hrd = (VAEncMiscParameterHRD) {
.initial_buffer_fullness = VAR_1,
.buffer_size = VAR_0,
};
ctx->global_params[ctx->nb_global_params] =
&ctx->hrd_params.misc;
ctx->global_params_size[ctx->nb_global_params++] =
sizeof(ctx->hrd_params);
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"VAAPIEncodeContext *ctx = avctx->priv_data;",
"int VAR_0;",
"int VAR_1;",
"if (avctx->rc_buffer_size)\nVAR_0 = avctx->rc_buffer_size;",
"else\nVAR_0 = avctx->bit_rate;",
"if (avctx->rc_initial_buffer_occupancy)\nVAR_1 = avctx->rc_initial_buffer_occupancy;",
"else\nVAR_1 = VAR_0 * 3 / 4;",
"ctx->rc_params.misc.type = VAEncMiscParameterTypeRateControl;",
"ctx->rc_params.rc = (VAEncMiscParameterRateControl) {",
".bits_per_second = avctx->bit_rate,\n.target_percentage = 66,\n.window_size = 1000,\n.initial_qp = (avctx->qmax >= 0 ? avctx->qmax : 40),\n.min_qp = (avctx->qmin >= 0 ? avctx->qmin : 18),\n.basic_unit_size = 0,\n};",
"ctx->global_params[ctx->nb_global_params] =\n&ctx->rc_params.misc;",
"ctx->global_params_size[ctx->nb_global_params++] =\nsizeof(ctx->rc_params);",
"ctx->hrd_params.misc.type = VAEncMiscParameterTypeHRD;",
"ctx->hrd_params.hrd = (VAEncMiscParameterHRD) {",
".initial_buffer_fullness = VAR_1,\n.buffer_size = VAR_0,\n};",
"ctx->global_params[ctx->nb_global_params] =\n&ctx->hrd_params.misc;",
"ctx->global_params_size[ctx->nb_global_params++] =\nsizeof(ctx->hrd_params);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
17,
19
],
[
21,
23
],
[
25,
27
],
[
31
],
[
33
],
[
35,
37,
39,
41,
43,
45,
47
],
[
49,
51
],
[
53,
55
],
[
59
],
[
61
],
[
63,
65,
67
],
[
69,
71
],
[
73,
75
],
[
79
],
[
81
]
] |
24,498 | static void glib_pollfds_poll(void)
{
GMainContext *context = g_main_context_default();
GPollFD *pfds = &g_array_index(gpollfds, GPollFD, glib_pollfds_idx);
if (g_main_context_check(context, max_priority, pfds, glib_n_poll_fds)) {
g_main_context_dispatch(context);
}
}
| false | qemu | c2b38b277a7882a592f4f2ec955084b2b756daaa | static void glib_pollfds_poll(void)
{
GMainContext *context = g_main_context_default();
GPollFD *pfds = &g_array_index(gpollfds, GPollFD, glib_pollfds_idx);
if (g_main_context_check(context, max_priority, pfds, glib_n_poll_fds)) {
g_main_context_dispatch(context);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
GMainContext *context = g_main_context_default();
GPollFD *pfds = &g_array_index(gpollfds, GPollFD, glib_pollfds_idx);
if (g_main_context_check(context, max_priority, pfds, glib_n_poll_fds)) {
g_main_context_dispatch(context);
}
}
| [
"static void FUNC_0(void)\n{",
"GMainContext *context = g_main_context_default();",
"GPollFD *pfds = &g_array_index(gpollfds, GPollFD, glib_pollfds_idx);",
"if (g_main_context_check(context, max_priority, pfds, glib_n_poll_fds)) {",
"g_main_context_dispatch(context);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
24,499 | static int parse_drive(DeviceState *dev, const char *str, void **ptr)
{
BlockDriverState *bs;
bs = bdrv_find(str);
if (bs == NULL) {
return -ENOENT;
}
if (bdrv_attach_dev(bs, dev) < 0) {
return -EEXIST;
}
*ptr = bs;
return 0;
}
| false | qemu | 4be746345f13e99e468c60acbd3a355e8183e3ce | static int parse_drive(DeviceState *dev, const char *str, void **ptr)
{
BlockDriverState *bs;
bs = bdrv_find(str);
if (bs == NULL) {
return -ENOENT;
}
if (bdrv_attach_dev(bs, dev) < 0) {
return -EEXIST;
}
*ptr = bs;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(DeviceState *VAR_0, const char *VAR_1, void **VAR_2)
{
BlockDriverState *bs;
bs = bdrv_find(VAR_1);
if (bs == NULL) {
return -ENOENT;
}
if (bdrv_attach_dev(bs, VAR_0) < 0) {
return -EEXIST;
}
*VAR_2 = bs;
return 0;
}
| [
"static int FUNC_0(DeviceState *VAR_0, const char *VAR_1, void **VAR_2)\n{",
"BlockDriverState *bs;",
"bs = bdrv_find(VAR_1);",
"if (bs == NULL) {",
"return -ENOENT;",
"}",
"if (bdrv_attach_dev(bs, VAR_0) < 0) {",
"return -EEXIST;",
"}",
"*VAR_2 = bs;",
"return 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
]
] |
24,500 | static void hda_audio_exit(HDACodecDevice *hda)
{
HDAAudioState *a = HDA_AUDIO(hda);
HDAAudioStream *st;
int i;
dprint(a, 1, "%s\n", __FUNCTION__);
for (i = 0; i < ARRAY_SIZE(a->st); i++) {
st = a->st + i;
if (st->node == NULL) {
continue;
}
if (st->output) {
AUD_close_out(&a->card, st->voice.out);
} else {
AUD_close_in(&a->card, st->voice.in);
}
}
AUD_remove_card(&a->card);
}
| false | qemu | a89f364ae8740dfc31b321eed9ee454e996dc3c1 | static void hda_audio_exit(HDACodecDevice *hda)
{
HDAAudioState *a = HDA_AUDIO(hda);
HDAAudioStream *st;
int i;
dprint(a, 1, "%s\n", __FUNCTION__);
for (i = 0; i < ARRAY_SIZE(a->st); i++) {
st = a->st + i;
if (st->node == NULL) {
continue;
}
if (st->output) {
AUD_close_out(&a->card, st->voice.out);
} else {
AUD_close_in(&a->card, st->voice.in);
}
}
AUD_remove_card(&a->card);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(HDACodecDevice *VAR_0)
{
HDAAudioState *a = HDA_AUDIO(VAR_0);
HDAAudioStream *st;
int VAR_1;
dprint(a, 1, "%s\n", __FUNCTION__);
for (VAR_1 = 0; VAR_1 < ARRAY_SIZE(a->st); VAR_1++) {
st = a->st + VAR_1;
if (st->node == NULL) {
continue;
}
if (st->output) {
AUD_close_out(&a->card, st->voice.out);
} else {
AUD_close_in(&a->card, st->voice.in);
}
}
AUD_remove_card(&a->card);
}
| [
"static void FUNC_0(HDACodecDevice *VAR_0)\n{",
"HDAAudioState *a = HDA_AUDIO(VAR_0);",
"HDAAudioStream *st;",
"int VAR_1;",
"dprint(a, 1, \"%s\\n\", __FUNCTION__);",
"for (VAR_1 = 0; VAR_1 < ARRAY_SIZE(a->st); VAR_1++) {",
"st = a->st + VAR_1;",
"if (st->node == NULL) {",
"continue;",
"}",
"if (st->output) {",
"AUD_close_out(&a->card, st->voice.out);",
"} else {",
"AUD_close_in(&a->card, st->voice.in);",
"}",
"}",
"AUD_remove_card(&a->card);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
]
] |
24,503 | static void curl_block_init(void)
{
bdrv_register(&bdrv_http);
bdrv_register(&bdrv_https);
bdrv_register(&bdrv_ftp);
bdrv_register(&bdrv_ftps);
bdrv_register(&bdrv_tftp);
}
| false | qemu | 23dce3873f3aee6ee7d4a1c17dd26fb5f453bc5a | static void curl_block_init(void)
{
bdrv_register(&bdrv_http);
bdrv_register(&bdrv_https);
bdrv_register(&bdrv_ftp);
bdrv_register(&bdrv_ftps);
bdrv_register(&bdrv_tftp);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
bdrv_register(&bdrv_http);
bdrv_register(&bdrv_https);
bdrv_register(&bdrv_ftp);
bdrv_register(&bdrv_ftps);
bdrv_register(&bdrv_tftp);
}
| [
"static void FUNC_0(void)\n{",
"bdrv_register(&bdrv_http);",
"bdrv_register(&bdrv_https);",
"bdrv_register(&bdrv_ftp);",
"bdrv_register(&bdrv_ftps);",
"bdrv_register(&bdrv_tftp);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
24,504 | static always_inline void gen_fcmov (void *func,
int ra, int rb, int rc)
{
int l1;
TCGv tmp;
if (unlikely(rc == 31))
return;
l1 = gen_new_label();
tmp = tcg_temp_new(TCG_TYPE_I64);
if (ra != 31) {
tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_helper_1_1(func, tmp, cpu_fir[ra]);
} else {
tmp = tcg_const_i64(0);
tcg_gen_helper_1_1(func, tmp, tmp);
}
tcg_gen_brcondi_i64(TCG_COND_EQ, tmp, 0, l1);
if (rb != 31)
tcg_gen_mov_i64(cpu_fir[rc], cpu_fir[ra]);
else
tcg_gen_movi_i64(cpu_fir[rc], 0);
gen_set_label(l1);
}
| false | qemu | a7812ae412311d7d47f8aa85656faadac9d64b56 | static always_inline void gen_fcmov (void *func,
int ra, int rb, int rc)
{
int l1;
TCGv tmp;
if (unlikely(rc == 31))
return;
l1 = gen_new_label();
tmp = tcg_temp_new(TCG_TYPE_I64);
if (ra != 31) {
tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_helper_1_1(func, tmp, cpu_fir[ra]);
} else {
tmp = tcg_const_i64(0);
tcg_gen_helper_1_1(func, tmp, tmp);
}
tcg_gen_brcondi_i64(TCG_COND_EQ, tmp, 0, l1);
if (rb != 31)
tcg_gen_mov_i64(cpu_fir[rc], cpu_fir[ra]);
else
tcg_gen_movi_i64(cpu_fir[rc], 0);
gen_set_label(l1);
}
| {
"code": [],
"line_no": []
} | static always_inline void FUNC_0 (void *func,
int ra, int rb, int rc)
{
int VAR_0;
TCGv tmp;
if (unlikely(rc == 31))
return;
VAR_0 = gen_new_label();
tmp = tcg_temp_new(TCG_TYPE_I64);
if (ra != 31) {
tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_helper_1_1(func, tmp, cpu_fir[ra]);
} else {
tmp = tcg_const_i64(0);
tcg_gen_helper_1_1(func, tmp, tmp);
}
tcg_gen_brcondi_i64(TCG_COND_EQ, tmp, 0, VAR_0);
if (rb != 31)
tcg_gen_mov_i64(cpu_fir[rc], cpu_fir[ra]);
else
tcg_gen_movi_i64(cpu_fir[rc], 0);
gen_set_label(VAR_0);
}
| [
"static always_inline void FUNC_0 (void *func,\nint ra, int rb, int rc)\n{",
"int VAR_0;",
"TCGv tmp;",
"if (unlikely(rc == 31))\nreturn;",
"VAR_0 = gen_new_label();",
"tmp = tcg_temp_new(TCG_TYPE_I64);",
"if (ra != 31) {",
"tmp = tcg_temp_new(TCG_TYPE_I64);",
"tcg_gen_helper_1_1(func, tmp, cpu_fir[ra]);",
"} else {",
"tmp = tcg_const_i64(0);",
"tcg_gen_helper_1_1(func, tmp, tmp);",
"}",
"tcg_gen_brcondi_i64(TCG_COND_EQ, tmp, 0, VAR_0);",
"if (rb != 31)\ntcg_gen_mov_i64(cpu_fir[rc], cpu_fir[ra]);",
"else\ntcg_gen_movi_i64(cpu_fir[rc], 0);",
"gen_set_label(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13,
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
43,
45
],
[
47
],
[
49
]
] |
24,505 | static inline void gen_outs(DisasContext *s, int ot)
{
gen_string_movl_A0_ESI(s);
gen_op_ld_T0_A0(ot + s->mem_index);
gen_op_mov_TN_reg(OT_WORD, 1, R_EDX);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[1]);
tcg_gen_andi_i32(cpu_tmp2_i32, cpu_tmp2_i32, 0xffff);
tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_T[0]);
tcg_gen_helper_0_2(helper_out_func[ot], cpu_tmp2_i32, cpu_tmp3_i32);
gen_op_movl_T0_Dshift[ot]();
#ifdef TARGET_X86_64
if (s->aflag == 2) {
gen_op_addq_ESI_T0();
} else
#endif
if (s->aflag) {
gen_op_addl_ESI_T0();
} else {
gen_op_addw_ESI_T0();
}
}
| false | qemu | 6e0d8677cb443e7408c0b7a25a93c6596d7fa380 | static inline void gen_outs(DisasContext *s, int ot)
{
gen_string_movl_A0_ESI(s);
gen_op_ld_T0_A0(ot + s->mem_index);
gen_op_mov_TN_reg(OT_WORD, 1, R_EDX);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[1]);
tcg_gen_andi_i32(cpu_tmp2_i32, cpu_tmp2_i32, 0xffff);
tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_T[0]);
tcg_gen_helper_0_2(helper_out_func[ot], cpu_tmp2_i32, cpu_tmp3_i32);
gen_op_movl_T0_Dshift[ot]();
#ifdef TARGET_X86_64
if (s->aflag == 2) {
gen_op_addq_ESI_T0();
} else
#endif
if (s->aflag) {
gen_op_addl_ESI_T0();
} else {
gen_op_addw_ESI_T0();
}
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(DisasContext *VAR_0, int VAR_1)
{
gen_string_movl_A0_ESI(VAR_0);
gen_op_ld_T0_A0(VAR_1 + VAR_0->mem_index);
gen_op_mov_TN_reg(OT_WORD, 1, R_EDX);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[1]);
tcg_gen_andi_i32(cpu_tmp2_i32, cpu_tmp2_i32, 0xffff);
tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_T[0]);
tcg_gen_helper_0_2(helper_out_func[VAR_1], cpu_tmp2_i32, cpu_tmp3_i32);
gen_op_movl_T0_Dshift[VAR_1]();
#ifdef TARGET_X86_64
if (VAR_0->aflag == 2) {
gen_op_addq_ESI_T0();
} else
#endif
if (VAR_0->aflag) {
gen_op_addl_ESI_T0();
} else {
gen_op_addw_ESI_T0();
}
}
| [
"static inline void FUNC_0(DisasContext *VAR_0, int VAR_1)\n{",
"gen_string_movl_A0_ESI(VAR_0);",
"gen_op_ld_T0_A0(VAR_1 + VAR_0->mem_index);",
"gen_op_mov_TN_reg(OT_WORD, 1, R_EDX);",
"tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[1]);",
"tcg_gen_andi_i32(cpu_tmp2_i32, cpu_tmp2_i32, 0xffff);",
"tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_T[0]);",
"tcg_gen_helper_0_2(helper_out_func[VAR_1], cpu_tmp2_i32, cpu_tmp3_i32);",
"gen_op_movl_T0_Dshift[VAR_1]();",
"#ifdef TARGET_X86_64\nif (VAR_0->aflag == 2) {",
"gen_op_addq_ESI_T0();",
"} else",
"#endif\nif (VAR_0->aflag) {",
"gen_op_addl_ESI_T0();",
"} else {",
"gen_op_addw_ESI_T0();",
"}",
"}"
] | [
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
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
]
] |
24,507 | static void vscsi_command_complete(SCSIRequest *sreq, uint32_t status)
{
VSCSIState *s = DO_UPCAST(VSCSIState, vdev.qdev, sreq->bus->qbus.parent);
vscsi_req *req = sreq->hba_private;
int32_t res_in = 0, res_out = 0;
dprintf("VSCSI: SCSI cmd complete, r=0x%x tag=0x%x status=0x%x, req=%p\n",
reason, sreq->tag, status, req);
if (req == NULL) {
fprintf(stderr, "VSCSI: Can't find request for tag 0x%x\n", sreq->tag);
return;
}
if (status == CHECK_CONDITION) {
req->senselen = scsi_req_get_sense(req->sreq, req->sense,
sizeof(req->sense));
status = 0;
dprintf("VSCSI: Sense data, %d bytes:\n", len);
dprintf(" %02x %02x %02x %02x %02x %02x %02x %02x\n",
req->sense[0], req->sense[1], req->sense[2], req->sense[3],
req->sense[4], req->sense[5], req->sense[6], req->sense[7]);
dprintf(" %02x %02x %02x %02x %02x %02x %02x %02x\n",
req->sense[8], req->sense[9], req->sense[10], req->sense[11],
req->sense[12], req->sense[13], req->sense[14], req->sense[15]);
}
dprintf("VSCSI: Command complete err=%d\n", status);
if (status == 0) {
/* We handle overflows, not underflows for normal commands,
* but hopefully nobody cares
*/
if (req->writing) {
res_out = req->data_len;
} else {
res_in = req->data_len;
}
}
vscsi_send_rsp(s, req, status, res_in, res_out);
vscsi_put_req(req);
}
| false | qemu | f5b6ffcf2a94337df31e801dd11b34896bd4fe2b | static void vscsi_command_complete(SCSIRequest *sreq, uint32_t status)
{
VSCSIState *s = DO_UPCAST(VSCSIState, vdev.qdev, sreq->bus->qbus.parent);
vscsi_req *req = sreq->hba_private;
int32_t res_in = 0, res_out = 0;
dprintf("VSCSI: SCSI cmd complete, r=0x%x tag=0x%x status=0x%x, req=%p\n",
reason, sreq->tag, status, req);
if (req == NULL) {
fprintf(stderr, "VSCSI: Can't find request for tag 0x%x\n", sreq->tag);
return;
}
if (status == CHECK_CONDITION) {
req->senselen = scsi_req_get_sense(req->sreq, req->sense,
sizeof(req->sense));
status = 0;
dprintf("VSCSI: Sense data, %d bytes:\n", len);
dprintf(" %02x %02x %02x %02x %02x %02x %02x %02x\n",
req->sense[0], req->sense[1], req->sense[2], req->sense[3],
req->sense[4], req->sense[5], req->sense[6], req->sense[7]);
dprintf(" %02x %02x %02x %02x %02x %02x %02x %02x\n",
req->sense[8], req->sense[9], req->sense[10], req->sense[11],
req->sense[12], req->sense[13], req->sense[14], req->sense[15]);
}
dprintf("VSCSI: Command complete err=%d\n", status);
if (status == 0) {
if (req->writing) {
res_out = req->data_len;
} else {
res_in = req->data_len;
}
}
vscsi_send_rsp(s, req, status, res_in, res_out);
vscsi_put_req(req);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(SCSIRequest *VAR_0, uint32_t VAR_1)
{
VSCSIState *s = DO_UPCAST(VSCSIState, vdev.qdev, VAR_0->bus->qbus.parent);
vscsi_req *req = VAR_0->hba_private;
int32_t res_in = 0, res_out = 0;
dprintf("VSCSI: SCSI cmd complete, r=0x%x tag=0x%x VAR_1=0x%x, req=%p\n",
reason, VAR_0->tag, VAR_1, req);
if (req == NULL) {
fprintf(stderr, "VSCSI: Can't find request for tag 0x%x\n", VAR_0->tag);
return;
}
if (VAR_1 == CHECK_CONDITION) {
req->senselen = scsi_req_get_sense(req->VAR_0, req->sense,
sizeof(req->sense));
VAR_1 = 0;
dprintf("VSCSI: Sense data, %d bytes:\n", len);
dprintf(" %02x %02x %02x %02x %02x %02x %02x %02x\n",
req->sense[0], req->sense[1], req->sense[2], req->sense[3],
req->sense[4], req->sense[5], req->sense[6], req->sense[7]);
dprintf(" %02x %02x %02x %02x %02x %02x %02x %02x\n",
req->sense[8], req->sense[9], req->sense[10], req->sense[11],
req->sense[12], req->sense[13], req->sense[14], req->sense[15]);
}
dprintf("VSCSI: Command complete err=%d\n", VAR_1);
if (VAR_1 == 0) {
if (req->writing) {
res_out = req->data_len;
} else {
res_in = req->data_len;
}
}
vscsi_send_rsp(s, req, VAR_1, res_in, res_out);
vscsi_put_req(req);
}
| [
"static void FUNC_0(SCSIRequest *VAR_0, uint32_t VAR_1)\n{",
"VSCSIState *s = DO_UPCAST(VSCSIState, vdev.qdev, VAR_0->bus->qbus.parent);",
"vscsi_req *req = VAR_0->hba_private;",
"int32_t res_in = 0, res_out = 0;",
"dprintf(\"VSCSI: SCSI cmd complete, r=0x%x tag=0x%x VAR_1=0x%x, req=%p\\n\",\nreason, VAR_0->tag, VAR_1, req);",
"if (req == NULL) {",
"fprintf(stderr, \"VSCSI: Can't find request for tag 0x%x\\n\", VAR_0->tag);",
"return;",
"}",
"if (VAR_1 == CHECK_CONDITION) {",
"req->senselen = scsi_req_get_sense(req->VAR_0, req->sense,\nsizeof(req->sense));",
"VAR_1 = 0;",
"dprintf(\"VSCSI: Sense data, %d bytes:\\n\", len);",
"dprintf(\" %02x %02x %02x %02x %02x %02x %02x %02x\\n\",\nreq->sense[0], req->sense[1], req->sense[2], req->sense[3],\nreq->sense[4], req->sense[5], req->sense[6], req->sense[7]);",
"dprintf(\" %02x %02x %02x %02x %02x %02x %02x %02x\\n\",\nreq->sense[8], req->sense[9], req->sense[10], req->sense[11],\nreq->sense[12], req->sense[13], req->sense[14], req->sense[15]);",
"}",
"dprintf(\"VSCSI: Command complete err=%d\\n\", VAR_1);",
"if (VAR_1 == 0) {",
"if (req->writing) {",
"res_out = req->data_len;",
"} else {",
"res_in = req->data_len;",
"}",
"}",
"vscsi_send_rsp(s, req, VAR_1, res_in, res_out);",
"vscsi_put_req(req);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37,
39,
41
],
[
43,
45,
47
],
[
49
],
[
53
],
[
55
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
]
] |
24,509 | static void virtio_blk_flush_complete(void *opaque, int ret)
{
VirtIOBlockReq *req = opaque;
if (ret) {
if (virtio_blk_handle_rw_error(req, -ret, 0)) {
return;
}
}
virtio_blk_req_complete(req, VIRTIO_BLK_S_OK);
block_acct_done(bdrv_get_stats(req->dev->bs), &req->acct);
virtio_blk_free_request(req);
}
| false | qemu | 4be746345f13e99e468c60acbd3a355e8183e3ce | static void virtio_blk_flush_complete(void *opaque, int ret)
{
VirtIOBlockReq *req = opaque;
if (ret) {
if (virtio_blk_handle_rw_error(req, -ret, 0)) {
return;
}
}
virtio_blk_req_complete(req, VIRTIO_BLK_S_OK);
block_acct_done(bdrv_get_stats(req->dev->bs), &req->acct);
virtio_blk_free_request(req);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, int VAR_1)
{
VirtIOBlockReq *req = VAR_0;
if (VAR_1) {
if (virtio_blk_handle_rw_error(req, -VAR_1, 0)) {
return;
}
}
virtio_blk_req_complete(req, VIRTIO_BLK_S_OK);
block_acct_done(bdrv_get_stats(req->dev->bs), &req->acct);
virtio_blk_free_request(req);
}
| [
"static void FUNC_0(void *VAR_0, int VAR_1)\n{",
"VirtIOBlockReq *req = VAR_0;",
"if (VAR_1) {",
"if (virtio_blk_handle_rw_error(req, -VAR_1, 0)) {",
"return;",
"}",
"}",
"virtio_blk_req_complete(req, VIRTIO_BLK_S_OK);",
"block_acct_done(bdrv_get_stats(req->dev->bs), &req->acct);",
"virtio_blk_free_request(req);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
24,510 | void ppc_hw_interrupt (CPUState *env)
{
env->exception_index = -1;
}
| false | qemu | e1833e1f96456fd8fc17463246fe0b2050e68efb | void ppc_hw_interrupt (CPUState *env)
{
env->exception_index = -1;
}
| {
"code": [],
"line_no": []
} | void FUNC_0 (CPUState *VAR_0)
{
VAR_0->exception_index = -1;
}
| [
"void FUNC_0 (CPUState *VAR_0)\n{",
"VAR_0->exception_index = -1;",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
24,512 | void qmp_ringbuf_write(const char *device, const char *data,
bool has_format, enum DataFormat format,
Error **errp)
{
CharDriverState *chr;
const uint8_t *write_data;
int ret;
gsize write_count;
chr = qemu_chr_find(device);
if (!chr) {
error_setg(errp, "Device '%s' not found", device);
return;
}
if (!chr_is_ringbuf(chr)) {
error_setg(errp,"%s is not a ringbuf device", device);
return;
}
if (has_format && (format == DATA_FORMAT_BASE64)) {
write_data = g_base64_decode(data, &write_count);
} else {
write_data = (uint8_t *)data;
write_count = strlen(data);
}
ret = ringbuf_chr_write(chr, write_data, write_count);
if (write_data != (uint8_t *)data) {
g_free((void *)write_data);
}
if (ret < 0) {
error_setg(errp, "Failed to write to device %s", device);
return;
}
}
| false | qemu | e9cf2fe07ff70e939f80c624b44c10a4442eef0b | void qmp_ringbuf_write(const char *device, const char *data,
bool has_format, enum DataFormat format,
Error **errp)
{
CharDriverState *chr;
const uint8_t *write_data;
int ret;
gsize write_count;
chr = qemu_chr_find(device);
if (!chr) {
error_setg(errp, "Device '%s' not found", device);
return;
}
if (!chr_is_ringbuf(chr)) {
error_setg(errp,"%s is not a ringbuf device", device);
return;
}
if (has_format && (format == DATA_FORMAT_BASE64)) {
write_data = g_base64_decode(data, &write_count);
} else {
write_data = (uint8_t *)data;
write_count = strlen(data);
}
ret = ringbuf_chr_write(chr, write_data, write_count);
if (write_data != (uint8_t *)data) {
g_free((void *)write_data);
}
if (ret < 0) {
error_setg(errp, "Failed to write to device %s", device);
return;
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(const char *VAR_0, const char *VAR_1,
bool VAR_2, enum DataFormat VAR_3,
Error **VAR_4)
{
CharDriverState *chr;
const uint8_t *VAR_5;
int VAR_6;
gsize write_count;
chr = qemu_chr_find(VAR_0);
if (!chr) {
error_setg(VAR_4, "Device '%s' not found", VAR_0);
return;
}
if (!chr_is_ringbuf(chr)) {
error_setg(VAR_4,"%s is not a ringbuf VAR_0", VAR_0);
return;
}
if (VAR_2 && (VAR_3 == DATA_FORMAT_BASE64)) {
VAR_5 = g_base64_decode(VAR_1, &write_count);
} else {
VAR_5 = (uint8_t *)VAR_1;
write_count = strlen(VAR_1);
}
VAR_6 = ringbuf_chr_write(chr, VAR_5, write_count);
if (VAR_5 != (uint8_t *)VAR_1) {
g_free((void *)VAR_5);
}
if (VAR_6 < 0) {
error_setg(VAR_4, "Failed to write to VAR_0 %s", VAR_0);
return;
}
}
| [
"void FUNC_0(const char *VAR_0, const char *VAR_1,\nbool VAR_2, enum DataFormat VAR_3,\nError **VAR_4)\n{",
"CharDriverState *chr;",
"const uint8_t *VAR_5;",
"int VAR_6;",
"gsize write_count;",
"chr = qemu_chr_find(VAR_0);",
"if (!chr) {",
"error_setg(VAR_4, \"Device '%s' not found\", VAR_0);",
"return;",
"}",
"if (!chr_is_ringbuf(chr)) {",
"error_setg(VAR_4,\"%s is not a ringbuf VAR_0\", VAR_0);",
"return;",
"}",
"if (VAR_2 && (VAR_3 == DATA_FORMAT_BASE64)) {",
"VAR_5 = g_base64_decode(VAR_1, &write_count);",
"} else {",
"VAR_5 = (uint8_t *)VAR_1;",
"write_count = strlen(VAR_1);",
"}",
"VAR_6 = ringbuf_chr_write(chr, VAR_5, write_count);",
"if (VAR_5 != (uint8_t *)VAR_1) {",
"g_free((void *)VAR_5);",
"}",
"if (VAR_6 < 0) {",
"error_setg(VAR_4, \"Failed to write to VAR_0 %s\", 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,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
]
] |
24,513 | int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
MigrationState *s = migrate_get_current();
const char *p;
int detach = qdict_get_try_bool(qdict, "detach", 0);
int blk = qdict_get_try_bool(qdict, "blk", 0);
int inc = qdict_get_try_bool(qdict, "inc", 0);
const char *uri = qdict_get_str(qdict, "uri");
int ret;
if (s->state == MIG_STATE_ACTIVE) {
monitor_printf(mon, "migration already in progress\n");
return -1;
}
if (qemu_savevm_state_blocked(mon)) {
return -1;
}
if (migration_blockers) {
Error *err = migration_blockers->data;
qerror_report_err(err);
return -1;
}
s = migrate_init(mon, detach, blk, inc);
if (strstart(uri, "tcp:", &p)) {
ret = tcp_start_outgoing_migration(s, p);
#if !defined(WIN32)
} else if (strstart(uri, "exec:", &p)) {
ret = exec_start_outgoing_migration(s, p);
} else if (strstart(uri, "unix:", &p)) {
ret = unix_start_outgoing_migration(s, p);
} else if (strstart(uri, "fd:", &p)) {
ret = fd_start_outgoing_migration(s, p);
#endif
} else {
monitor_printf(mon, "unknown migration protocol: %s\n", uri);
ret = -EINVAL;
}
if (ret < 0) {
monitor_printf(mon, "migration failed: %s\n", strerror(-ret));
return ret;
}
if (detach) {
s->mon = NULL;
}
notifier_list_notify(&migration_state_notifiers, s);
return 0;
}
| false | qemu | e1c37d0e94048502f9874e6356ce7136d4b05bdb | int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
MigrationState *s = migrate_get_current();
const char *p;
int detach = qdict_get_try_bool(qdict, "detach", 0);
int blk = qdict_get_try_bool(qdict, "blk", 0);
int inc = qdict_get_try_bool(qdict, "inc", 0);
const char *uri = qdict_get_str(qdict, "uri");
int ret;
if (s->state == MIG_STATE_ACTIVE) {
monitor_printf(mon, "migration already in progress\n");
return -1;
}
if (qemu_savevm_state_blocked(mon)) {
return -1;
}
if (migration_blockers) {
Error *err = migration_blockers->data;
qerror_report_err(err);
return -1;
}
s = migrate_init(mon, detach, blk, inc);
if (strstart(uri, "tcp:", &p)) {
ret = tcp_start_outgoing_migration(s, p);
#if !defined(WIN32)
} else if (strstart(uri, "exec:", &p)) {
ret = exec_start_outgoing_migration(s, p);
} else if (strstart(uri, "unix:", &p)) {
ret = unix_start_outgoing_migration(s, p);
} else if (strstart(uri, "fd:", &p)) {
ret = fd_start_outgoing_migration(s, p);
#endif
} else {
monitor_printf(mon, "unknown migration protocol: %s\n", uri);
ret = -EINVAL;
}
if (ret < 0) {
monitor_printf(mon, "migration failed: %s\n", strerror(-ret));
return ret;
}
if (detach) {
s->mon = NULL;
}
notifier_list_notify(&migration_state_notifiers, s);
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(Monitor *VAR_0, const QDict *VAR_1, QObject **VAR_2)
{
MigrationState *s = migrate_get_current();
const char *VAR_3;
int VAR_4 = qdict_get_try_bool(VAR_1, "VAR_4", 0);
int VAR_5 = qdict_get_try_bool(VAR_1, "VAR_5", 0);
int VAR_6 = qdict_get_try_bool(VAR_1, "VAR_6", 0);
const char *VAR_7 = qdict_get_str(VAR_1, "VAR_7");
int VAR_8;
if (s->state == MIG_STATE_ACTIVE) {
monitor_printf(VAR_0, "migration already in progress\n");
return -1;
}
if (qemu_savevm_state_blocked(VAR_0)) {
return -1;
}
if (migration_blockers) {
Error *err = migration_blockers->data;
qerror_report_err(err);
return -1;
}
s = migrate_init(VAR_0, VAR_4, VAR_5, VAR_6);
if (strstart(VAR_7, "tcp:", &VAR_3)) {
VAR_8 = tcp_start_outgoing_migration(s, VAR_3);
#if !defined(WIN32)
} else if (strstart(VAR_7, "exec:", &VAR_3)) {
VAR_8 = exec_start_outgoing_migration(s, VAR_3);
} else if (strstart(VAR_7, "unix:", &VAR_3)) {
VAR_8 = unix_start_outgoing_migration(s, VAR_3);
} else if (strstart(VAR_7, "fd:", &VAR_3)) {
VAR_8 = fd_start_outgoing_migration(s, VAR_3);
#endif
} else {
monitor_printf(VAR_0, "unknown migration protocol: %s\n", VAR_7);
VAR_8 = -EINVAL;
}
if (VAR_8 < 0) {
monitor_printf(VAR_0, "migration failed: %s\n", strerror(-VAR_8));
return VAR_8;
}
if (VAR_4) {
s->VAR_0 = NULL;
}
notifier_list_notify(&migration_state_notifiers, s);
return 0;
}
| [
"int FUNC_0(Monitor *VAR_0, const QDict *VAR_1, QObject **VAR_2)\n{",
"MigrationState *s = migrate_get_current();",
"const char *VAR_3;",
"int VAR_4 = qdict_get_try_bool(VAR_1, \"VAR_4\", 0);",
"int VAR_5 = qdict_get_try_bool(VAR_1, \"VAR_5\", 0);",
"int VAR_6 = qdict_get_try_bool(VAR_1, \"VAR_6\", 0);",
"const char *VAR_7 = qdict_get_str(VAR_1, \"VAR_7\");",
"int VAR_8;",
"if (s->state == MIG_STATE_ACTIVE) {",
"monitor_printf(VAR_0, \"migration already in progress\\n\");",
"return -1;",
"}",
"if (qemu_savevm_state_blocked(VAR_0)) {",
"return -1;",
"}",
"if (migration_blockers) {",
"Error *err = migration_blockers->data;",
"qerror_report_err(err);",
"return -1;",
"}",
"s = migrate_init(VAR_0, VAR_4, VAR_5, VAR_6);",
"if (strstart(VAR_7, \"tcp:\", &VAR_3)) {",
"VAR_8 = tcp_start_outgoing_migration(s, VAR_3);",
"#if !defined(WIN32)\n} else if (strstart(VAR_7, \"exec:\", &VAR_3)) {",
"VAR_8 = exec_start_outgoing_migration(s, VAR_3);",
"} else if (strstart(VAR_7, \"unix:\", &VAR_3)) {",
"VAR_8 = unix_start_outgoing_migration(s, VAR_3);",
"} else if (strstart(VAR_7, \"fd:\", &VAR_3)) {",
"VAR_8 = fd_start_outgoing_migration(s, VAR_3);",
"#endif\n} else {",
"monitor_printf(VAR_0, \"unknown migration protocol: %s\\n\", VAR_7);",
"VAR_8 = -EINVAL;",
"}",
"if (VAR_8 < 0) {",
"monitor_printf(VAR_0, \"migration failed: %s\\n\", strerror(-VAR_8));",
"return VAR_8;",
"}",
"if (VAR_4) {",
"s->VAR_0 = NULL;",
"}",
"notifier_list_notify(&migration_state_notifiers, s);",
"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
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
]
] |
24,515 | void *laio_init(void)
{
struct qemu_laio_state *s;
s = qemu_mallocz(sizeof(*s));
QLIST_INIT(&s->completed_reqs);
s->efd = eventfd(0, 0);
if (s->efd == -1)
goto out_free_state;
fcntl(s->efd, F_SETFL, O_NONBLOCK);
if (io_setup(MAX_EVENTS, &s->ctx) != 0)
goto out_close_efd;
qemu_aio_set_fd_handler(s->efd, qemu_laio_completion_cb, NULL,
qemu_laio_flush_cb, qemu_laio_process_requests, s);
return s;
out_close_efd:
close(s->efd);
out_free_state:
qemu_free(s);
return NULL;
}
| false | qemu | 384acbf46b70edf0d2c1648aa1a92a90bcf7057d | void *laio_init(void)
{
struct qemu_laio_state *s;
s = qemu_mallocz(sizeof(*s));
QLIST_INIT(&s->completed_reqs);
s->efd = eventfd(0, 0);
if (s->efd == -1)
goto out_free_state;
fcntl(s->efd, F_SETFL, O_NONBLOCK);
if (io_setup(MAX_EVENTS, &s->ctx) != 0)
goto out_close_efd;
qemu_aio_set_fd_handler(s->efd, qemu_laio_completion_cb, NULL,
qemu_laio_flush_cb, qemu_laio_process_requests, s);
return s;
out_close_efd:
close(s->efd);
out_free_state:
qemu_free(s);
return NULL;
}
| {
"code": [],
"line_no": []
} | void *FUNC_0(void)
{
struct qemu_laio_state *VAR_0;
VAR_0 = qemu_mallocz(sizeof(*VAR_0));
QLIST_INIT(&VAR_0->completed_reqs);
VAR_0->efd = eventfd(0, 0);
if (VAR_0->efd == -1)
goto out_free_state;
fcntl(VAR_0->efd, F_SETFL, O_NONBLOCK);
if (io_setup(MAX_EVENTS, &VAR_0->ctx) != 0)
goto out_close_efd;
qemu_aio_set_fd_handler(VAR_0->efd, qemu_laio_completion_cb, NULL,
qemu_laio_flush_cb, qemu_laio_process_requests, VAR_0);
return VAR_0;
out_close_efd:
close(VAR_0->efd);
out_free_state:
qemu_free(VAR_0);
return NULL;
}
| [
"void *FUNC_0(void)\n{",
"struct qemu_laio_state *VAR_0;",
"VAR_0 = qemu_mallocz(sizeof(*VAR_0));",
"QLIST_INIT(&VAR_0->completed_reqs);",
"VAR_0->efd = eventfd(0, 0);",
"if (VAR_0->efd == -1)\ngoto out_free_state;",
"fcntl(VAR_0->efd, F_SETFL, O_NONBLOCK);",
"if (io_setup(MAX_EVENTS, &VAR_0->ctx) != 0)\ngoto out_close_efd;",
"qemu_aio_set_fd_handler(VAR_0->efd, qemu_laio_completion_cb, NULL,\nqemu_laio_flush_cb, qemu_laio_process_requests, VAR_0);",
"return VAR_0;",
"out_close_efd:\nclose(VAR_0->efd);",
"out_free_state:\nqemu_free(VAR_0);",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
23,
25
],
[
29,
31
],
[
35
],
[
39,
41
],
[
43,
45
],
[
47
],
[
49
]
] |
24,516 | static TileExcp decode_x1(DisasContext *dc, tilegx_bundle_bits bundle)
{
unsigned opc = get_Opcode_X1(bundle);
unsigned dest = get_Dest_X1(bundle);
unsigned srca = get_SrcA_X1(bundle);
unsigned ext, srcb;
int imm;
switch (opc) {
case RRR_0_OPCODE_X1:
ext = get_RRROpcodeExtension_X1(bundle);
srcb = get_SrcB_X1(bundle);
switch (ext) {
case UNARY_RRR_0_OPCODE_X1:
ext = get_UnaryOpcodeExtension_X1(bundle);
return gen_rr_opcode(dc, OE(opc, ext, X1), dest, srca);
case ST1_RRR_0_OPCODE_X1:
return gen_st_opcode(dc, dest, srca, srcb, MO_UB, "st1");
case ST2_RRR_0_OPCODE_X1:
return gen_st_opcode(dc, dest, srca, srcb, MO_TEUW, "st2");
case ST4_RRR_0_OPCODE_X1:
return gen_st_opcode(dc, dest, srca, srcb, MO_TEUL, "st4");
case STNT1_RRR_0_OPCODE_X1:
return gen_st_opcode(dc, dest, srca, srcb, MO_UB, "stnt1");
case STNT2_RRR_0_OPCODE_X1:
return gen_st_opcode(dc, dest, srca, srcb, MO_TEUW, "stnt2");
case STNT4_RRR_0_OPCODE_X1:
return gen_st_opcode(dc, dest, srca, srcb, MO_TEUL, "stnt4");
case STNT_RRR_0_OPCODE_X1:
return gen_st_opcode(dc, dest, srca, srcb, MO_TEQ, "stnt");
case ST_RRR_0_OPCODE_X1:
return gen_st_opcode(dc, dest, srca, srcb, MO_TEQ, "st");
}
return gen_rrr_opcode(dc, OE(opc, ext, X1), dest, srca, srcb);
case SHIFT_OPCODE_X1:
ext = get_ShiftOpcodeExtension_X1(bundle);
imm = get_ShAmt_X1(bundle);
return gen_rri_opcode(dc, OE(opc, ext, X1), dest, srca, imm);
case IMM8_OPCODE_X1:
ext = get_Imm8OpcodeExtension_X1(bundle);
imm = (int8_t)get_Dest_Imm8_X1(bundle);
srcb = get_SrcB_X1(bundle);
switch (ext) {
case ST1_ADD_IMM8_OPCODE_X1:
return gen_st_add_opcode(dc, srca, srcb, imm, MO_UB, "st1_add");
case ST2_ADD_IMM8_OPCODE_X1:
return gen_st_add_opcode(dc, srca, srcb, imm, MO_TEUW, "st2_add");
case ST4_ADD_IMM8_OPCODE_X1:
return gen_st_add_opcode(dc, srca, srcb, imm, MO_TEUL, "st4_add");
case STNT1_ADD_IMM8_OPCODE_X1:
return gen_st_add_opcode(dc, srca, srcb, imm, MO_UB, "stnt1_add");
case STNT2_ADD_IMM8_OPCODE_X1:
return gen_st_add_opcode(dc, srca, srcb, imm, MO_TEUW, "stnt2_add");
case STNT4_ADD_IMM8_OPCODE_X1:
return gen_st_add_opcode(dc, srca, srcb, imm, MO_TEUL, "stnt4_add");
case STNT_ADD_IMM8_OPCODE_X1:
return gen_st_add_opcode(dc, srca, srcb, imm, MO_TEQ, "stnt_add");
case ST_ADD_IMM8_OPCODE_X1:
return gen_st_add_opcode(dc, srca, srcb, imm, MO_TEQ, "st_add");
case MFSPR_IMM8_OPCODE_X1:
return gen_mfspr_x1(dc, dest, get_MF_Imm14_X1(bundle));
case MTSPR_IMM8_OPCODE_X1:
return gen_mtspr_x1(dc, get_MT_Imm14_X1(bundle), srca);
}
imm = (int8_t)get_Imm8_X1(bundle);
return gen_rri_opcode(dc, OE(opc, ext, X1), dest, srca, imm);
case BRANCH_OPCODE_X1:
ext = get_BrType_X1(bundle);
imm = sextract32(get_BrOff_X1(bundle), 0, 17);
return gen_branch_opcode_x1(dc, ext, srca, imm);
case JUMP_OPCODE_X1:
ext = get_JumpOpcodeExtension_X1(bundle);
imm = sextract32(get_JumpOff_X1(bundle), 0, 27);
return gen_jump_opcode_x1(dc, ext, imm);
case ADDLI_OPCODE_X1:
case SHL16INSLI_OPCODE_X1:
case ADDXLI_OPCODE_X1:
imm = (int16_t)get_Imm16_X1(bundle);
return gen_rri_opcode(dc, OE(opc, 0, X1), dest, srca, imm);
default:
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
}
}
| false | qemu | dd8070d865ad1b32876931f812a80645f97112ff | static TileExcp decode_x1(DisasContext *dc, tilegx_bundle_bits bundle)
{
unsigned opc = get_Opcode_X1(bundle);
unsigned dest = get_Dest_X1(bundle);
unsigned srca = get_SrcA_X1(bundle);
unsigned ext, srcb;
int imm;
switch (opc) {
case RRR_0_OPCODE_X1:
ext = get_RRROpcodeExtension_X1(bundle);
srcb = get_SrcB_X1(bundle);
switch (ext) {
case UNARY_RRR_0_OPCODE_X1:
ext = get_UnaryOpcodeExtension_X1(bundle);
return gen_rr_opcode(dc, OE(opc, ext, X1), dest, srca);
case ST1_RRR_0_OPCODE_X1:
return gen_st_opcode(dc, dest, srca, srcb, MO_UB, "st1");
case ST2_RRR_0_OPCODE_X1:
return gen_st_opcode(dc, dest, srca, srcb, MO_TEUW, "st2");
case ST4_RRR_0_OPCODE_X1:
return gen_st_opcode(dc, dest, srca, srcb, MO_TEUL, "st4");
case STNT1_RRR_0_OPCODE_X1:
return gen_st_opcode(dc, dest, srca, srcb, MO_UB, "stnt1");
case STNT2_RRR_0_OPCODE_X1:
return gen_st_opcode(dc, dest, srca, srcb, MO_TEUW, "stnt2");
case STNT4_RRR_0_OPCODE_X1:
return gen_st_opcode(dc, dest, srca, srcb, MO_TEUL, "stnt4");
case STNT_RRR_0_OPCODE_X1:
return gen_st_opcode(dc, dest, srca, srcb, MO_TEQ, "stnt");
case ST_RRR_0_OPCODE_X1:
return gen_st_opcode(dc, dest, srca, srcb, MO_TEQ, "st");
}
return gen_rrr_opcode(dc, OE(opc, ext, X1), dest, srca, srcb);
case SHIFT_OPCODE_X1:
ext = get_ShiftOpcodeExtension_X1(bundle);
imm = get_ShAmt_X1(bundle);
return gen_rri_opcode(dc, OE(opc, ext, X1), dest, srca, imm);
case IMM8_OPCODE_X1:
ext = get_Imm8OpcodeExtension_X1(bundle);
imm = (int8_t)get_Dest_Imm8_X1(bundle);
srcb = get_SrcB_X1(bundle);
switch (ext) {
case ST1_ADD_IMM8_OPCODE_X1:
return gen_st_add_opcode(dc, srca, srcb, imm, MO_UB, "st1_add");
case ST2_ADD_IMM8_OPCODE_X1:
return gen_st_add_opcode(dc, srca, srcb, imm, MO_TEUW, "st2_add");
case ST4_ADD_IMM8_OPCODE_X1:
return gen_st_add_opcode(dc, srca, srcb, imm, MO_TEUL, "st4_add");
case STNT1_ADD_IMM8_OPCODE_X1:
return gen_st_add_opcode(dc, srca, srcb, imm, MO_UB, "stnt1_add");
case STNT2_ADD_IMM8_OPCODE_X1:
return gen_st_add_opcode(dc, srca, srcb, imm, MO_TEUW, "stnt2_add");
case STNT4_ADD_IMM8_OPCODE_X1:
return gen_st_add_opcode(dc, srca, srcb, imm, MO_TEUL, "stnt4_add");
case STNT_ADD_IMM8_OPCODE_X1:
return gen_st_add_opcode(dc, srca, srcb, imm, MO_TEQ, "stnt_add");
case ST_ADD_IMM8_OPCODE_X1:
return gen_st_add_opcode(dc, srca, srcb, imm, MO_TEQ, "st_add");
case MFSPR_IMM8_OPCODE_X1:
return gen_mfspr_x1(dc, dest, get_MF_Imm14_X1(bundle));
case MTSPR_IMM8_OPCODE_X1:
return gen_mtspr_x1(dc, get_MT_Imm14_X1(bundle), srca);
}
imm = (int8_t)get_Imm8_X1(bundle);
return gen_rri_opcode(dc, OE(opc, ext, X1), dest, srca, imm);
case BRANCH_OPCODE_X1:
ext = get_BrType_X1(bundle);
imm = sextract32(get_BrOff_X1(bundle), 0, 17);
return gen_branch_opcode_x1(dc, ext, srca, imm);
case JUMP_OPCODE_X1:
ext = get_JumpOpcodeExtension_X1(bundle);
imm = sextract32(get_JumpOff_X1(bundle), 0, 27);
return gen_jump_opcode_x1(dc, ext, imm);
case ADDLI_OPCODE_X1:
case SHL16INSLI_OPCODE_X1:
case ADDXLI_OPCODE_X1:
imm = (int16_t)get_Imm16_X1(bundle);
return gen_rri_opcode(dc, OE(opc, 0, X1), dest, srca, imm);
default:
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
}
}
| {
"code": [],
"line_no": []
} | static TileExcp FUNC_0(DisasContext *dc, tilegx_bundle_bits bundle)
{
unsigned VAR_0 = get_Opcode_X1(bundle);
unsigned VAR_1 = get_Dest_X1(bundle);
unsigned VAR_2 = get_SrcA_X1(bundle);
unsigned VAR_3, VAR_4;
int VAR_5;
switch (VAR_0) {
case RRR_0_OPCODE_X1:
VAR_3 = get_RRROpcodeExtension_X1(bundle);
VAR_4 = get_SrcB_X1(bundle);
switch (VAR_3) {
case UNARY_RRR_0_OPCODE_X1:
VAR_3 = get_UnaryOpcodeExtension_X1(bundle);
return gen_rr_opcode(dc, OE(VAR_0, VAR_3, X1), VAR_1, VAR_2);
case ST1_RRR_0_OPCODE_X1:
return gen_st_opcode(dc, VAR_1, VAR_2, VAR_4, MO_UB, "st1");
case ST2_RRR_0_OPCODE_X1:
return gen_st_opcode(dc, VAR_1, VAR_2, VAR_4, MO_TEUW, "st2");
case ST4_RRR_0_OPCODE_X1:
return gen_st_opcode(dc, VAR_1, VAR_2, VAR_4, MO_TEUL, "st4");
case STNT1_RRR_0_OPCODE_X1:
return gen_st_opcode(dc, VAR_1, VAR_2, VAR_4, MO_UB, "stnt1");
case STNT2_RRR_0_OPCODE_X1:
return gen_st_opcode(dc, VAR_1, VAR_2, VAR_4, MO_TEUW, "stnt2");
case STNT4_RRR_0_OPCODE_X1:
return gen_st_opcode(dc, VAR_1, VAR_2, VAR_4, MO_TEUL, "stnt4");
case STNT_RRR_0_OPCODE_X1:
return gen_st_opcode(dc, VAR_1, VAR_2, VAR_4, MO_TEQ, "stnt");
case ST_RRR_0_OPCODE_X1:
return gen_st_opcode(dc, VAR_1, VAR_2, VAR_4, MO_TEQ, "st");
}
return gen_rrr_opcode(dc, OE(VAR_0, VAR_3, X1), VAR_1, VAR_2, VAR_4);
case SHIFT_OPCODE_X1:
VAR_3 = get_ShiftOpcodeExtension_X1(bundle);
VAR_5 = get_ShAmt_X1(bundle);
return gen_rri_opcode(dc, OE(VAR_0, VAR_3, X1), VAR_1, VAR_2, VAR_5);
case IMM8_OPCODE_X1:
VAR_3 = get_Imm8OpcodeExtension_X1(bundle);
VAR_5 = (int8_t)get_Dest_Imm8_X1(bundle);
VAR_4 = get_SrcB_X1(bundle);
switch (VAR_3) {
case ST1_ADD_IMM8_OPCODE_X1:
return gen_st_add_opcode(dc, VAR_2, VAR_4, VAR_5, MO_UB, "st1_add");
case ST2_ADD_IMM8_OPCODE_X1:
return gen_st_add_opcode(dc, VAR_2, VAR_4, VAR_5, MO_TEUW, "st2_add");
case ST4_ADD_IMM8_OPCODE_X1:
return gen_st_add_opcode(dc, VAR_2, VAR_4, VAR_5, MO_TEUL, "st4_add");
case STNT1_ADD_IMM8_OPCODE_X1:
return gen_st_add_opcode(dc, VAR_2, VAR_4, VAR_5, MO_UB, "stnt1_add");
case STNT2_ADD_IMM8_OPCODE_X1:
return gen_st_add_opcode(dc, VAR_2, VAR_4, VAR_5, MO_TEUW, "stnt2_add");
case STNT4_ADD_IMM8_OPCODE_X1:
return gen_st_add_opcode(dc, VAR_2, VAR_4, VAR_5, MO_TEUL, "stnt4_add");
case STNT_ADD_IMM8_OPCODE_X1:
return gen_st_add_opcode(dc, VAR_2, VAR_4, VAR_5, MO_TEQ, "stnt_add");
case ST_ADD_IMM8_OPCODE_X1:
return gen_st_add_opcode(dc, VAR_2, VAR_4, VAR_5, MO_TEQ, "st_add");
case MFSPR_IMM8_OPCODE_X1:
return gen_mfspr_x1(dc, VAR_1, get_MF_Imm14_X1(bundle));
case MTSPR_IMM8_OPCODE_X1:
return gen_mtspr_x1(dc, get_MT_Imm14_X1(bundle), VAR_2);
}
VAR_5 = (int8_t)get_Imm8_X1(bundle);
return gen_rri_opcode(dc, OE(VAR_0, VAR_3, X1), VAR_1, VAR_2, VAR_5);
case BRANCH_OPCODE_X1:
VAR_3 = get_BrType_X1(bundle);
VAR_5 = sextract32(get_BrOff_X1(bundle), 0, 17);
return gen_branch_opcode_x1(dc, VAR_3, VAR_2, VAR_5);
case JUMP_OPCODE_X1:
VAR_3 = get_JumpOpcodeExtension_X1(bundle);
VAR_5 = sextract32(get_JumpOff_X1(bundle), 0, 27);
return gen_jump_opcode_x1(dc, VAR_3, VAR_5);
case ADDLI_OPCODE_X1:
case SHL16INSLI_OPCODE_X1:
case ADDXLI_OPCODE_X1:
VAR_5 = (int16_t)get_Imm16_X1(bundle);
return gen_rri_opcode(dc, OE(VAR_0, 0, X1), VAR_1, VAR_2, VAR_5);
default:
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
}
}
| [
"static TileExcp FUNC_0(DisasContext *dc, tilegx_bundle_bits bundle)\n{",
"unsigned VAR_0 = get_Opcode_X1(bundle);",
"unsigned VAR_1 = get_Dest_X1(bundle);",
"unsigned VAR_2 = get_SrcA_X1(bundle);",
"unsigned VAR_3, VAR_4;",
"int VAR_5;",
"switch (VAR_0) {",
"case RRR_0_OPCODE_X1:\nVAR_3 = get_RRROpcodeExtension_X1(bundle);",
"VAR_4 = get_SrcB_X1(bundle);",
"switch (VAR_3) {",
"case UNARY_RRR_0_OPCODE_X1:\nVAR_3 = get_UnaryOpcodeExtension_X1(bundle);",
"return gen_rr_opcode(dc, OE(VAR_0, VAR_3, X1), VAR_1, VAR_2);",
"case ST1_RRR_0_OPCODE_X1:\nreturn gen_st_opcode(dc, VAR_1, VAR_2, VAR_4, MO_UB, \"st1\");",
"case ST2_RRR_0_OPCODE_X1:\nreturn gen_st_opcode(dc, VAR_1, VAR_2, VAR_4, MO_TEUW, \"st2\");",
"case ST4_RRR_0_OPCODE_X1:\nreturn gen_st_opcode(dc, VAR_1, VAR_2, VAR_4, MO_TEUL, \"st4\");",
"case STNT1_RRR_0_OPCODE_X1:\nreturn gen_st_opcode(dc, VAR_1, VAR_2, VAR_4, MO_UB, \"stnt1\");",
"case STNT2_RRR_0_OPCODE_X1:\nreturn gen_st_opcode(dc, VAR_1, VAR_2, VAR_4, MO_TEUW, \"stnt2\");",
"case STNT4_RRR_0_OPCODE_X1:\nreturn gen_st_opcode(dc, VAR_1, VAR_2, VAR_4, MO_TEUL, \"stnt4\");",
"case STNT_RRR_0_OPCODE_X1:\nreturn gen_st_opcode(dc, VAR_1, VAR_2, VAR_4, MO_TEQ, \"stnt\");",
"case ST_RRR_0_OPCODE_X1:\nreturn gen_st_opcode(dc, VAR_1, VAR_2, VAR_4, MO_TEQ, \"st\");",
"}",
"return gen_rrr_opcode(dc, OE(VAR_0, VAR_3, X1), VAR_1, VAR_2, VAR_4);",
"case SHIFT_OPCODE_X1:\nVAR_3 = get_ShiftOpcodeExtension_X1(bundle);",
"VAR_5 = get_ShAmt_X1(bundle);",
"return gen_rri_opcode(dc, OE(VAR_0, VAR_3, X1), VAR_1, VAR_2, VAR_5);",
"case IMM8_OPCODE_X1:\nVAR_3 = get_Imm8OpcodeExtension_X1(bundle);",
"VAR_5 = (int8_t)get_Dest_Imm8_X1(bundle);",
"VAR_4 = get_SrcB_X1(bundle);",
"switch (VAR_3) {",
"case ST1_ADD_IMM8_OPCODE_X1:\nreturn gen_st_add_opcode(dc, VAR_2, VAR_4, VAR_5, MO_UB, \"st1_add\");",
"case ST2_ADD_IMM8_OPCODE_X1:\nreturn gen_st_add_opcode(dc, VAR_2, VAR_4, VAR_5, MO_TEUW, \"st2_add\");",
"case ST4_ADD_IMM8_OPCODE_X1:\nreturn gen_st_add_opcode(dc, VAR_2, VAR_4, VAR_5, MO_TEUL, \"st4_add\");",
"case STNT1_ADD_IMM8_OPCODE_X1:\nreturn gen_st_add_opcode(dc, VAR_2, VAR_4, VAR_5, MO_UB, \"stnt1_add\");",
"case STNT2_ADD_IMM8_OPCODE_X1:\nreturn gen_st_add_opcode(dc, VAR_2, VAR_4, VAR_5, MO_TEUW, \"stnt2_add\");",
"case STNT4_ADD_IMM8_OPCODE_X1:\nreturn gen_st_add_opcode(dc, VAR_2, VAR_4, VAR_5, MO_TEUL, \"stnt4_add\");",
"case STNT_ADD_IMM8_OPCODE_X1:\nreturn gen_st_add_opcode(dc, VAR_2, VAR_4, VAR_5, MO_TEQ, \"stnt_add\");",
"case ST_ADD_IMM8_OPCODE_X1:\nreturn gen_st_add_opcode(dc, VAR_2, VAR_4, VAR_5, MO_TEQ, \"st_add\");",
"case MFSPR_IMM8_OPCODE_X1:\nreturn gen_mfspr_x1(dc, VAR_1, get_MF_Imm14_X1(bundle));",
"case MTSPR_IMM8_OPCODE_X1:\nreturn gen_mtspr_x1(dc, get_MT_Imm14_X1(bundle), VAR_2);",
"}",
"VAR_5 = (int8_t)get_Imm8_X1(bundle);",
"return gen_rri_opcode(dc, OE(VAR_0, VAR_3, X1), VAR_1, VAR_2, VAR_5);",
"case BRANCH_OPCODE_X1:\nVAR_3 = get_BrType_X1(bundle);",
"VAR_5 = sextract32(get_BrOff_X1(bundle), 0, 17);",
"return gen_branch_opcode_x1(dc, VAR_3, VAR_2, VAR_5);",
"case JUMP_OPCODE_X1:\nVAR_3 = get_JumpOpcodeExtension_X1(bundle);",
"VAR_5 = sextract32(get_JumpOff_X1(bundle), 0, 27);",
"return gen_jump_opcode_x1(dc, VAR_3, VAR_5);",
"case ADDLI_OPCODE_X1:\ncase SHL16INSLI_OPCODE_X1:\ncase ADDXLI_OPCODE_X1:\nVAR_5 = (int16_t)get_Imm16_X1(bundle);",
"return gen_rri_opcode(dc, OE(VAR_0, 0, X1), VAR_1, VAR_2, VAR_5);",
"default:\nreturn TILEGX_EXCP_OPCODE_UNIMPLEMENTED;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
71,
73
],
[
75
],
[
77
],
[
81,
83
],
[
85
],
[
87
],
[
89
],
[
91,
93
],
[
95,
97
],
[
99,
101
],
[
103,
105
],
[
107,
109
],
[
111,
113
],
[
115,
117
],
[
119,
121
],
[
123,
125
],
[
127,
129
],
[
131
],
[
133
],
[
135
],
[
139,
141
],
[
143
],
[
145
],
[
149,
151
],
[
153
],
[
155
],
[
159,
161,
163,
165
],
[
167
],
[
171,
173
],
[
175
],
[
177
]
] |
24,517 | static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
AVCodecParserContext *pc, AVPacket *pkt)
{
int num, den, presentation_delayed;
/* handle wrapping */
if(st->cur_dts != AV_NOPTS_VALUE){
if(pkt->pts != AV_NOPTS_VALUE)
pkt->pts= lsb2full(pkt->pts, st->cur_dts, st->pts_wrap_bits);
if(pkt->dts != AV_NOPTS_VALUE)
pkt->dts= lsb2full(pkt->dts, st->cur_dts, st->pts_wrap_bits);
}
if (pkt->duration == 0) {
compute_frame_duration(&num, &den, s, st, pc, pkt);
if (den && num) {
pkt->duration = av_rescale(1, num * (int64_t)st->time_base.den, den * (int64_t)st->time_base.num);
}
}
/* do we have a video B frame ? */
presentation_delayed = 0;
if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
/* XXX: need has_b_frame, but cannot get it if the codec is
not initialized */
if ((st->codec.codec_id == CODEC_ID_MPEG1VIDEO ||
st->codec.codec_id == CODEC_ID_MPEG2VIDEO ||
st->codec.codec_id == CODEC_ID_MPEG4 ||
st->codec.codec_id == CODEC_ID_H264) &&
pc && pc->pict_type != FF_B_TYPE)
presentation_delayed = 1;
/* this may be redundant, but it shouldnt hurt */
if(pkt->dts != AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE && pkt->pts > pkt->dts)
presentation_delayed = 1;
}
if(st->cur_dts == AV_NOPTS_VALUE){
if(presentation_delayed) st->cur_dts = -pkt->duration;
else st->cur_dts = 0;
}
// av_log(NULL, AV_LOG_DEBUG, "IN delayed:%d pts:%lld, dts:%lld cur_dts:%lld\n", presentation_delayed, pkt->pts, pkt->dts, st->cur_dts);
/* interpolate PTS and DTS if they are not present */
if (presentation_delayed) {
/* DTS = decompression time stamp */
/* PTS = presentation time stamp */
if (pkt->dts == AV_NOPTS_VALUE) {
/* if we know the last pts, use it */
if(st->last_IP_pts != AV_NOPTS_VALUE)
st->cur_dts = pkt->dts = st->last_IP_pts;
else
pkt->dts = st->cur_dts;
} else {
st->cur_dts = pkt->dts;
}
/* this is tricky: the dts must be incremented by the duration
of the frame we are displaying, i.e. the last I or P frame */
if (st->last_IP_duration == 0)
st->cur_dts += pkt->duration;
else
st->cur_dts += st->last_IP_duration;
st->last_IP_duration = pkt->duration;
st->last_IP_pts= pkt->pts;
/* cannot compute PTS if not present (we can compute it only
by knowing the futur */
} else {
/* presentation is not delayed : PTS and DTS are the same */
if (pkt->pts == AV_NOPTS_VALUE) {
if (pkt->dts == AV_NOPTS_VALUE) {
pkt->pts = st->cur_dts;
pkt->dts = st->cur_dts;
}
else {
st->cur_dts = pkt->dts;
pkt->pts = pkt->dts;
}
} else {
st->cur_dts = pkt->pts;
pkt->dts = pkt->pts;
}
st->cur_dts += pkt->duration;
}
// av_log(NULL, AV_LOG_DEBUG, "OUTdelayed:%d pts:%lld, dts:%lld cur_dts:%lld\n", presentation_delayed, pkt->pts, pkt->dts, st->cur_dts);
/* update flags */
if (pc) {
pkt->flags = 0;
/* key frame computation */
switch(st->codec.codec_type) {
case CODEC_TYPE_VIDEO:
if (pc->pict_type == FF_I_TYPE)
pkt->flags |= PKT_FLAG_KEY;
break;
case CODEC_TYPE_AUDIO:
pkt->flags |= PKT_FLAG_KEY;
break;
default:
break;
}
}
/* convert the packet time stamp units */
if(pkt->pts != AV_NOPTS_VALUE)
pkt->pts = av_rescale(pkt->pts, AV_TIME_BASE * (int64_t)st->time_base.num, st->time_base.den);
if(pkt->dts != AV_NOPTS_VALUE)
pkt->dts = av_rescale(pkt->dts, AV_TIME_BASE * (int64_t)st->time_base.num, st->time_base.den);
/* duration field */
pkt->duration = av_rescale(pkt->duration, AV_TIME_BASE * (int64_t)st->time_base.num, st->time_base.den);
}
| false | FFmpeg | 3c895fc098f7637f6d5ec3a9d6766e724a8b9e41 | static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
AVCodecParserContext *pc, AVPacket *pkt)
{
int num, den, presentation_delayed;
if(st->cur_dts != AV_NOPTS_VALUE){
if(pkt->pts != AV_NOPTS_VALUE)
pkt->pts= lsb2full(pkt->pts, st->cur_dts, st->pts_wrap_bits);
if(pkt->dts != AV_NOPTS_VALUE)
pkt->dts= lsb2full(pkt->dts, st->cur_dts, st->pts_wrap_bits);
}
if (pkt->duration == 0) {
compute_frame_duration(&num, &den, s, st, pc, pkt);
if (den && num) {
pkt->duration = av_rescale(1, num * (int64_t)st->time_base.den, den * (int64_t)st->time_base.num);
}
}
presentation_delayed = 0;
if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
if ((st->codec.codec_id == CODEC_ID_MPEG1VIDEO ||
st->codec.codec_id == CODEC_ID_MPEG2VIDEO ||
st->codec.codec_id == CODEC_ID_MPEG4 ||
st->codec.codec_id == CODEC_ID_H264) &&
pc && pc->pict_type != FF_B_TYPE)
presentation_delayed = 1;
if(pkt->dts != AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE && pkt->pts > pkt->dts)
presentation_delayed = 1;
}
if(st->cur_dts == AV_NOPTS_VALUE){
if(presentation_delayed) st->cur_dts = -pkt->duration;
else st->cur_dts = 0;
}
if (presentation_delayed) {
if (pkt->dts == AV_NOPTS_VALUE) {
if(st->last_IP_pts != AV_NOPTS_VALUE)
st->cur_dts = pkt->dts = st->last_IP_pts;
else
pkt->dts = st->cur_dts;
} else {
st->cur_dts = pkt->dts;
}
if (st->last_IP_duration == 0)
st->cur_dts += pkt->duration;
else
st->cur_dts += st->last_IP_duration;
st->last_IP_duration = pkt->duration;
st->last_IP_pts= pkt->pts;
} else {
if (pkt->pts == AV_NOPTS_VALUE) {
if (pkt->dts == AV_NOPTS_VALUE) {
pkt->pts = st->cur_dts;
pkt->dts = st->cur_dts;
}
else {
st->cur_dts = pkt->dts;
pkt->pts = pkt->dts;
}
} else {
st->cur_dts = pkt->pts;
pkt->dts = pkt->pts;
}
st->cur_dts += pkt->duration;
}
if (pc) {
pkt->flags = 0;
switch(st->codec.codec_type) {
case CODEC_TYPE_VIDEO:
if (pc->pict_type == FF_I_TYPE)
pkt->flags |= PKT_FLAG_KEY;
break;
case CODEC_TYPE_AUDIO:
pkt->flags |= PKT_FLAG_KEY;
break;
default:
break;
}
}
if(pkt->pts != AV_NOPTS_VALUE)
pkt->pts = av_rescale(pkt->pts, AV_TIME_BASE * (int64_t)st->time_base.num, st->time_base.den);
if(pkt->dts != AV_NOPTS_VALUE)
pkt->dts = av_rescale(pkt->dts, AV_TIME_BASE * (int64_t)st->time_base.num, st->time_base.den);
pkt->duration = av_rescale(pkt->duration, AV_TIME_BASE * (int64_t)st->time_base.num, st->time_base.den);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1,
AVCodecParserContext *VAR_2, AVPacket *VAR_3)
{
int VAR_4, VAR_5, VAR_6;
if(VAR_1->cur_dts != AV_NOPTS_VALUE){
if(VAR_3->pts != AV_NOPTS_VALUE)
VAR_3->pts= lsb2full(VAR_3->pts, VAR_1->cur_dts, VAR_1->pts_wrap_bits);
if(VAR_3->dts != AV_NOPTS_VALUE)
VAR_3->dts= lsb2full(VAR_3->dts, VAR_1->cur_dts, VAR_1->pts_wrap_bits);
}
if (VAR_3->duration == 0) {
compute_frame_duration(&VAR_4, &VAR_5, VAR_0, VAR_1, VAR_2, VAR_3);
if (VAR_5 && VAR_4) {
VAR_3->duration = av_rescale(1, VAR_4 * (int64_t)VAR_1->time_base.VAR_5, VAR_5 * (int64_t)VAR_1->time_base.VAR_4);
}
}
VAR_6 = 0;
if (VAR_1->codec.codec_type == CODEC_TYPE_VIDEO) {
if ((VAR_1->codec.codec_id == CODEC_ID_MPEG1VIDEO ||
VAR_1->codec.codec_id == CODEC_ID_MPEG2VIDEO ||
VAR_1->codec.codec_id == CODEC_ID_MPEG4 ||
VAR_1->codec.codec_id == CODEC_ID_H264) &&
VAR_2 && VAR_2->pict_type != FF_B_TYPE)
VAR_6 = 1;
if(VAR_3->dts != AV_NOPTS_VALUE && VAR_3->pts != AV_NOPTS_VALUE && VAR_3->pts > VAR_3->dts)
VAR_6 = 1;
}
if(VAR_1->cur_dts == AV_NOPTS_VALUE){
if(VAR_6) VAR_1->cur_dts = -VAR_3->duration;
else VAR_1->cur_dts = 0;
}
if (VAR_6) {
if (VAR_3->dts == AV_NOPTS_VALUE) {
if(VAR_1->last_IP_pts != AV_NOPTS_VALUE)
VAR_1->cur_dts = VAR_3->dts = VAR_1->last_IP_pts;
else
VAR_3->dts = VAR_1->cur_dts;
} else {
VAR_1->cur_dts = VAR_3->dts;
}
if (VAR_1->last_IP_duration == 0)
VAR_1->cur_dts += VAR_3->duration;
else
VAR_1->cur_dts += VAR_1->last_IP_duration;
VAR_1->last_IP_duration = VAR_3->duration;
VAR_1->last_IP_pts= VAR_3->pts;
} else {
if (VAR_3->pts == AV_NOPTS_VALUE) {
if (VAR_3->dts == AV_NOPTS_VALUE) {
VAR_3->pts = VAR_1->cur_dts;
VAR_3->dts = VAR_1->cur_dts;
}
else {
VAR_1->cur_dts = VAR_3->dts;
VAR_3->pts = VAR_3->dts;
}
} else {
VAR_1->cur_dts = VAR_3->pts;
VAR_3->dts = VAR_3->pts;
}
VAR_1->cur_dts += VAR_3->duration;
}
if (VAR_2) {
VAR_3->flags = 0;
switch(VAR_1->codec.codec_type) {
case CODEC_TYPE_VIDEO:
if (VAR_2->pict_type == FF_I_TYPE)
VAR_3->flags |= PKT_FLAG_KEY;
break;
case CODEC_TYPE_AUDIO:
VAR_3->flags |= PKT_FLAG_KEY;
break;
default:
break;
}
}
if(VAR_3->pts != AV_NOPTS_VALUE)
VAR_3->pts = av_rescale(VAR_3->pts, AV_TIME_BASE * (int64_t)VAR_1->time_base.VAR_4, VAR_1->time_base.VAR_5);
if(VAR_3->dts != AV_NOPTS_VALUE)
VAR_3->dts = av_rescale(VAR_3->dts, AV_TIME_BASE * (int64_t)VAR_1->time_base.VAR_4, VAR_1->time_base.VAR_5);
VAR_3->duration = av_rescale(VAR_3->duration, AV_TIME_BASE * (int64_t)VAR_1->time_base.VAR_4, VAR_1->time_base.VAR_5);
}
| [
"static void FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1,\nAVCodecParserContext *VAR_2, AVPacket *VAR_3)\n{",
"int VAR_4, VAR_5, VAR_6;",
"if(VAR_1->cur_dts != AV_NOPTS_VALUE){",
"if(VAR_3->pts != AV_NOPTS_VALUE)\nVAR_3->pts= lsb2full(VAR_3->pts, VAR_1->cur_dts, VAR_1->pts_wrap_bits);",
"if(VAR_3->dts != AV_NOPTS_VALUE)\nVAR_3->dts= lsb2full(VAR_3->dts, VAR_1->cur_dts, VAR_1->pts_wrap_bits);",
"}",
"if (VAR_3->duration == 0) {",
"compute_frame_duration(&VAR_4, &VAR_5, VAR_0, VAR_1, VAR_2, VAR_3);",
"if (VAR_5 && VAR_4) {",
"VAR_3->duration = av_rescale(1, VAR_4 * (int64_t)VAR_1->time_base.VAR_5, VAR_5 * (int64_t)VAR_1->time_base.VAR_4);",
"}",
"}",
"VAR_6 = 0;",
"if (VAR_1->codec.codec_type == CODEC_TYPE_VIDEO) {",
"if ((VAR_1->codec.codec_id == CODEC_ID_MPEG1VIDEO ||\nVAR_1->codec.codec_id == CODEC_ID_MPEG2VIDEO ||\nVAR_1->codec.codec_id == CODEC_ID_MPEG4 ||\nVAR_1->codec.codec_id == CODEC_ID_H264) &&\nVAR_2 && VAR_2->pict_type != FF_B_TYPE)\nVAR_6 = 1;",
"if(VAR_3->dts != AV_NOPTS_VALUE && VAR_3->pts != AV_NOPTS_VALUE && VAR_3->pts > VAR_3->dts)\nVAR_6 = 1;",
"}",
"if(VAR_1->cur_dts == AV_NOPTS_VALUE){",
"if(VAR_6) VAR_1->cur_dts = -VAR_3->duration;",
"else VAR_1->cur_dts = 0;",
"}",
"if (VAR_6) {",
"if (VAR_3->dts == AV_NOPTS_VALUE) {",
"if(VAR_1->last_IP_pts != AV_NOPTS_VALUE)\nVAR_1->cur_dts = VAR_3->dts = VAR_1->last_IP_pts;",
"else\nVAR_3->dts = VAR_1->cur_dts;",
"} else {",
"VAR_1->cur_dts = VAR_3->dts;",
"}",
"if (VAR_1->last_IP_duration == 0)\nVAR_1->cur_dts += VAR_3->duration;",
"else\nVAR_1->cur_dts += VAR_1->last_IP_duration;",
"VAR_1->last_IP_duration = VAR_3->duration;",
"VAR_1->last_IP_pts= VAR_3->pts;",
"} else {",
"if (VAR_3->pts == AV_NOPTS_VALUE) {",
"if (VAR_3->dts == AV_NOPTS_VALUE) {",
"VAR_3->pts = VAR_1->cur_dts;",
"VAR_3->dts = VAR_1->cur_dts;",
"}",
"else {",
"VAR_1->cur_dts = VAR_3->dts;",
"VAR_3->pts = VAR_3->dts;",
"}",
"} else {",
"VAR_1->cur_dts = VAR_3->pts;",
"VAR_3->dts = VAR_3->pts;",
"}",
"VAR_1->cur_dts += VAR_3->duration;",
"}",
"if (VAR_2) {",
"VAR_3->flags = 0;",
"switch(VAR_1->codec.codec_type) {",
"case CODEC_TYPE_VIDEO:\nif (VAR_2->pict_type == FF_I_TYPE)\nVAR_3->flags |= PKT_FLAG_KEY;",
"break;",
"case CODEC_TYPE_AUDIO:\nVAR_3->flags |= PKT_FLAG_KEY;",
"break;",
"default:\nbreak;",
"}",
"}",
"if(VAR_3->pts != AV_NOPTS_VALUE)\nVAR_3->pts = av_rescale(VAR_3->pts, AV_TIME_BASE * (int64_t)VAR_1->time_base.VAR_4, VAR_1->time_base.VAR_5);",
"if(VAR_3->dts != AV_NOPTS_VALUE)\nVAR_3->dts = av_rescale(VAR_3->dts, AV_TIME_BASE * (int64_t)VAR_1->time_base.VAR_4, VAR_1->time_base.VAR_5);",
"VAR_3->duration = av_rescale(VAR_3->duration, AV_TIME_BASE * (int64_t)VAR_1->time_base.VAR_4, VAR_1->time_base.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
] | [
[
1,
3,
5
],
[
7
],
[
13
],
[
15,
17
],
[
19,
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
43
],
[
45
],
[
51,
53,
55,
57,
59,
61
],
[
65,
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
87
],
[
93
],
[
97,
99
],
[
101,
103
],
[
105
],
[
107
],
[
109
],
[
115,
117
],
[
119,
121
],
[
123
],
[
125
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
171
],
[
173
],
[
177
],
[
179,
181,
183
],
[
185
],
[
187,
189
],
[
191
],
[
193,
195
],
[
197
],
[
199
],
[
205,
207
],
[
209,
211
],
[
217
],
[
219
]
] |
24,518 | static int ffm_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int size;
FFMContext *ffm = s->priv_data;
int duration, ret;
switch(ffm->read_state) {
case READ_HEADER:
if ((ret = ffm_is_avail_data(s, FRAME_HEADER_SIZE+4)) < 0)
return ret;
av_dlog(s, "pos=%08"PRIx64" spos=%"PRIx64", write_index=%"PRIx64" size=%"PRIx64"\n",
avio_tell(s->pb), s->pb->pos, ffm->write_index, ffm->file_size);
if (ffm_read_data(s, ffm->header, FRAME_HEADER_SIZE, 1) !=
FRAME_HEADER_SIZE)
return -1;
if (ffm->header[1] & FLAG_DTS)
if (ffm_read_data(s, ffm->header+16, 4, 1) != 4)
return -1;
ffm->read_state = READ_DATA;
/* fall thru */
case READ_DATA:
size = AV_RB24(ffm->header + 2);
if ((ret = ffm_is_avail_data(s, size)) < 0)
return ret;
duration = AV_RB24(ffm->header + 5);
av_new_packet(pkt, size);
pkt->stream_index = ffm->header[0];
if ((unsigned)pkt->stream_index >= s->nb_streams) {
av_log(s, AV_LOG_ERROR, "invalid stream index %d\n", pkt->stream_index);
av_free_packet(pkt);
ffm->read_state = READ_HEADER;
return -1;
}
pkt->pos = avio_tell(s->pb);
if (ffm->header[1] & FLAG_KEY_FRAME)
pkt->flags |= AV_PKT_FLAG_KEY;
ffm->read_state = READ_HEADER;
if (ffm_read_data(s, pkt->data, size, 0) != size) {
/* bad case: desynchronized packet. we cancel all the packet loading */
av_free_packet(pkt);
return -1;
}
pkt->pts = AV_RB64(ffm->header+8);
if (ffm->header[1] & FLAG_DTS)
pkt->dts = pkt->pts - AV_RB32(ffm->header+16);
else
pkt->dts = pkt->pts;
pkt->duration = duration;
break;
}
return 0;
}
| false | FFmpeg | f03c0f6afcb1360c95e92cf9278a8f43ca5cdb9f | static int ffm_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int size;
FFMContext *ffm = s->priv_data;
int duration, ret;
switch(ffm->read_state) {
case READ_HEADER:
if ((ret = ffm_is_avail_data(s, FRAME_HEADER_SIZE+4)) < 0)
return ret;
av_dlog(s, "pos=%08"PRIx64" spos=%"PRIx64", write_index=%"PRIx64" size=%"PRIx64"\n",
avio_tell(s->pb), s->pb->pos, ffm->write_index, ffm->file_size);
if (ffm_read_data(s, ffm->header, FRAME_HEADER_SIZE, 1) !=
FRAME_HEADER_SIZE)
return -1;
if (ffm->header[1] & FLAG_DTS)
if (ffm_read_data(s, ffm->header+16, 4, 1) != 4)
return -1;
ffm->read_state = READ_DATA;
case READ_DATA:
size = AV_RB24(ffm->header + 2);
if ((ret = ffm_is_avail_data(s, size)) < 0)
return ret;
duration = AV_RB24(ffm->header + 5);
av_new_packet(pkt, size);
pkt->stream_index = ffm->header[0];
if ((unsigned)pkt->stream_index >= s->nb_streams) {
av_log(s, AV_LOG_ERROR, "invalid stream index %d\n", pkt->stream_index);
av_free_packet(pkt);
ffm->read_state = READ_HEADER;
return -1;
}
pkt->pos = avio_tell(s->pb);
if (ffm->header[1] & FLAG_KEY_FRAME)
pkt->flags |= AV_PKT_FLAG_KEY;
ffm->read_state = READ_HEADER;
if (ffm_read_data(s, pkt->data, size, 0) != size) {
av_free_packet(pkt);
return -1;
}
pkt->pts = AV_RB64(ffm->header+8);
if (ffm->header[1] & FLAG_DTS)
pkt->dts = pkt->pts - AV_RB32(ffm->header+16);
else
pkt->dts = pkt->pts;
pkt->duration = duration;
break;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{
int VAR_2;
FFMContext *ffm = VAR_0->priv_data;
int VAR_3, VAR_4;
switch(ffm->read_state) {
case READ_HEADER:
if ((VAR_4 = ffm_is_avail_data(VAR_0, FRAME_HEADER_SIZE+4)) < 0)
return VAR_4;
av_dlog(VAR_0, "pos=%08"PRIx64" spos=%"PRIx64", write_index=%"PRIx64" VAR_2=%"PRIx64"\n",
avio_tell(VAR_0->pb), VAR_0->pb->pos, ffm->write_index, ffm->file_size);
if (ffm_read_data(VAR_0, ffm->header, FRAME_HEADER_SIZE, 1) !=
FRAME_HEADER_SIZE)
return -1;
if (ffm->header[1] & FLAG_DTS)
if (ffm_read_data(VAR_0, ffm->header+16, 4, 1) != 4)
return -1;
ffm->read_state = READ_DATA;
case READ_DATA:
VAR_2 = AV_RB24(ffm->header + 2);
if ((VAR_4 = ffm_is_avail_data(VAR_0, VAR_2)) < 0)
return VAR_4;
VAR_3 = AV_RB24(ffm->header + 5);
av_new_packet(VAR_1, VAR_2);
VAR_1->stream_index = ffm->header[0];
if ((unsigned)VAR_1->stream_index >= VAR_0->nb_streams) {
av_log(VAR_0, AV_LOG_ERROR, "invalid stream index %d\n", VAR_1->stream_index);
av_free_packet(VAR_1);
ffm->read_state = READ_HEADER;
return -1;
}
VAR_1->pos = avio_tell(VAR_0->pb);
if (ffm->header[1] & FLAG_KEY_FRAME)
VAR_1->flags |= AV_PKT_FLAG_KEY;
ffm->read_state = READ_HEADER;
if (ffm_read_data(VAR_0, VAR_1->data, VAR_2, 0) != VAR_2) {
av_free_packet(VAR_1);
return -1;
}
VAR_1->pts = AV_RB64(ffm->header+8);
if (ffm->header[1] & FLAG_DTS)
VAR_1->dts = VAR_1->pts - AV_RB32(ffm->header+16);
else
VAR_1->dts = VAR_1->pts;
VAR_1->VAR_3 = VAR_3;
break;
}
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{",
"int VAR_2;",
"FFMContext *ffm = VAR_0->priv_data;",
"int VAR_3, VAR_4;",
"switch(ffm->read_state) {",
"case READ_HEADER:\nif ((VAR_4 = ffm_is_avail_data(VAR_0, FRAME_HEADER_SIZE+4)) < 0)\nreturn VAR_4;",
"av_dlog(VAR_0, \"pos=%08\"PRIx64\" spos=%\"PRIx64\", write_index=%\"PRIx64\" VAR_2=%\"PRIx64\"\\n\",\navio_tell(VAR_0->pb), VAR_0->pb->pos, ffm->write_index, ffm->file_size);",
"if (ffm_read_data(VAR_0, ffm->header, FRAME_HEADER_SIZE, 1) !=\nFRAME_HEADER_SIZE)\nreturn -1;",
"if (ffm->header[1] & FLAG_DTS)\nif (ffm_read_data(VAR_0, ffm->header+16, 4, 1) != 4)\nreturn -1;",
"ffm->read_state = READ_DATA;",
"case READ_DATA:\nVAR_2 = AV_RB24(ffm->header + 2);",
"if ((VAR_4 = ffm_is_avail_data(VAR_0, VAR_2)) < 0)\nreturn VAR_4;",
"VAR_3 = AV_RB24(ffm->header + 5);",
"av_new_packet(VAR_1, VAR_2);",
"VAR_1->stream_index = ffm->header[0];",
"if ((unsigned)VAR_1->stream_index >= VAR_0->nb_streams) {",
"av_log(VAR_0, AV_LOG_ERROR, \"invalid stream index %d\\n\", VAR_1->stream_index);",
"av_free_packet(VAR_1);",
"ffm->read_state = READ_HEADER;",
"return -1;",
"}",
"VAR_1->pos = avio_tell(VAR_0->pb);",
"if (ffm->header[1] & FLAG_KEY_FRAME)\nVAR_1->flags |= AV_PKT_FLAG_KEY;",
"ffm->read_state = READ_HEADER;",
"if (ffm_read_data(VAR_0, VAR_1->data, VAR_2, 0) != VAR_2) {",
"av_free_packet(VAR_1);",
"return -1;",
"}",
"VAR_1->pts = AV_RB64(ffm->header+8);",
"if (ffm->header[1] & FLAG_DTS)\nVAR_1->dts = VAR_1->pts - AV_RB32(ffm->header+16);",
"else\nVAR_1->dts = VAR_1->pts;",
"VAR_1->VAR_3 = VAR_3;",
"break;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15,
17,
19
],
[
23,
25
],
[
27,
29,
31
],
[
33,
35,
37
],
[
39
],
[
43,
45
],
[
47,
49
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95,
97
],
[
99,
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
]
] |
24,519 | static int vda_h264_start_frame(AVCodecContext *avctx,
av_unused const uint8_t *buffer,
av_unused uint32_t size)
{
VDAContext *vda = avctx->internal->hwaccel_priv_data;
struct vda_context *vda_ctx = avctx->hwaccel_context;
if (!vda_ctx->decoder)
return -1;
vda->bitstream_size = 0;
return 0;
}
| false | FFmpeg | 67afcefb35932b420998f6f3fda46c7c85848a3f | static int vda_h264_start_frame(AVCodecContext *avctx,
av_unused const uint8_t *buffer,
av_unused uint32_t size)
{
VDAContext *vda = avctx->internal->hwaccel_priv_data;
struct vda_context *vda_ctx = avctx->hwaccel_context;
if (!vda_ctx->decoder)
return -1;
vda->bitstream_size = 0;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
av_unused const VAR_1 *buffer,
av_unused uint32_t size)
{
VDAContext *vda = VAR_0->internal->hwaccel_priv_data;
struct vda_context *VAR_2 = VAR_0->hwaccel_context;
if (!VAR_2->decoder)
return -1;
vda->bitstream_size = 0;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nav_unused const VAR_1 *buffer,\nav_unused uint32_t size)\n{",
"VDAContext *vda = VAR_0->internal->hwaccel_priv_data;",
"struct vda_context *VAR_2 = VAR_0->hwaccel_context;",
"if (!VAR_2->decoder)\nreturn -1;",
"vda->bitstream_size = 0;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15,
17
],
[
21
],
[
25
],
[
27
]
] |
24,520 | static void colored_fputs(int level, int tint, const char *str)
{
if (!*str)
return;
if (use_color < 0)
check_color_terminal();
#if defined(_WIN32) && !defined(__MINGW32CE__) && HAVE_SETCONSOLETEXTATTRIBUTE
if (use_color && level != AV_LOG_INFO/8)
SetConsoleTextAttribute(con, background | color[level]);
fputs(str, stderr);
if (use_color && level != AV_LOG_INFO/8)
SetConsoleTextAttribute(con, attr_orig);
#else
if (use_color == 1 && level != AV_LOG_INFO/8) {
fprintf(stderr,
"\033[%d;3%dm%s\033[0m",
(color[level] >> 4) & 15,
color[level] & 15,
str);
} else if (tint && use_color == 256) {
fprintf(stderr,
"\033[48;5;%dm\033[38;5;%dm%s\033[0m",
(color[level] >> 16) & 0xff,
tint,
str);
} else if (use_color == 256 && level != AV_LOG_INFO/8) {
fprintf(stderr,
"\033[48;5;%dm\033[38;5;%dm%s\033[0m",
(color[level] >> 16) & 0xff,
(color[level] >> 8) & 0xff,
str);
} else
fputs(str, stderr);
#endif
}
| false | FFmpeg | 7ac2f7e413051aa6ff735a8b9c47ca06dc4607d9 | static void colored_fputs(int level, int tint, const char *str)
{
if (!*str)
return;
if (use_color < 0)
check_color_terminal();
#if defined(_WIN32) && !defined(__MINGW32CE__) && HAVE_SETCONSOLETEXTATTRIBUTE
if (use_color && level != AV_LOG_INFO/8)
SetConsoleTextAttribute(con, background | color[level]);
fputs(str, stderr);
if (use_color && level != AV_LOG_INFO/8)
SetConsoleTextAttribute(con, attr_orig);
#else
if (use_color == 1 && level != AV_LOG_INFO/8) {
fprintf(stderr,
"\033[%d;3%dm%s\033[0m",
(color[level] >> 4) & 15,
color[level] & 15,
str);
} else if (tint && use_color == 256) {
fprintf(stderr,
"\033[48;5;%dm\033[38;5;%dm%s\033[0m",
(color[level] >> 16) & 0xff,
tint,
str);
} else if (use_color == 256 && level != AV_LOG_INFO/8) {
fprintf(stderr,
"\033[48;5;%dm\033[38;5;%dm%s\033[0m",
(color[level] >> 16) & 0xff,
(color[level] >> 8) & 0xff,
str);
} else
fputs(str, stderr);
#endif
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(int VAR_0, int VAR_1, const char *VAR_2)
{
if (!*VAR_2)
return;
if (use_color < 0)
check_color_terminal();
#if defined(_WIN32) && !defined(__MINGW32CE__) && HAVE_SETCONSOLETEXTATTRIBUTE
if (use_color && VAR_0 != AV_LOG_INFO/8)
SetConsoleTextAttribute(con, background | color[VAR_0]);
fputs(VAR_2, stderr);
if (use_color && VAR_0 != AV_LOG_INFO/8)
SetConsoleTextAttribute(con, attr_orig);
#else
if (use_color == 1 && VAR_0 != AV_LOG_INFO/8) {
fprintf(stderr,
"\033[%d;3%dm%s\033[0m",
(color[VAR_0] >> 4) & 15,
color[VAR_0] & 15,
VAR_2);
} else if (VAR_1 && use_color == 256) {
fprintf(stderr,
"\033[48;5;%dm\033[38;5;%dm%s\033[0m",
(color[VAR_0] >> 16) & 0xff,
VAR_1,
VAR_2);
} else if (use_color == 256 && VAR_0 != AV_LOG_INFO/8) {
fprintf(stderr,
"\033[48;5;%dm\033[38;5;%dm%s\033[0m",
(color[VAR_0] >> 16) & 0xff,
(color[VAR_0] >> 8) & 0xff,
VAR_2);
} else
fputs(VAR_2, stderr);
#endif
}
| [
"static void FUNC_0(int VAR_0, int VAR_1, const char *VAR_2)\n{",
"if (!*VAR_2)\nreturn;",
"if (use_color < 0)\ncheck_color_terminal();",
"#if defined(_WIN32) && !defined(__MINGW32CE__) && HAVE_SETCONSOLETEXTATTRIBUTE\nif (use_color && VAR_0 != AV_LOG_INFO/8)\nSetConsoleTextAttribute(con, background | color[VAR_0]);",
"fputs(VAR_2, stderr);",
"if (use_color && VAR_0 != AV_LOG_INFO/8)\nSetConsoleTextAttribute(con, attr_orig);",
"#else\nif (use_color == 1 && VAR_0 != AV_LOG_INFO/8) {",
"fprintf(stderr,\n\"\\033[%d;3%dm%s\\033[0m\",",
"(color[VAR_0] >> 4) & 15,\ncolor[VAR_0] & 15,\nVAR_2);",
"} else if (VAR_1 && use_color == 256) {",
"fprintf(stderr,\n\"\\033[48;5;%dm\\033[38;5;%dm%s\\033[0m\",",
"(color[VAR_0] >> 16) & 0xff,\nVAR_1,\nVAR_2);",
"} else if (use_color == 256 && VAR_0 != AV_LOG_INFO/8) {",
"fprintf(stderr,\n\"\\033[48;5;%dm\\033[38;5;%dm%s\\033[0m\",",
"(color[VAR_0] >> 16) & 0xff,\n(color[VAR_0] >> 8) & 0xff,\nVAR_2);",
"} else",
"fputs(VAR_2, stderr);",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
11,
13
],
[
17,
19,
21
],
[
23
],
[
25,
27
],
[
29,
31
],
[
33,
35
],
[
37,
39,
41
],
[
43
],
[
45,
47
],
[
49,
51,
53
],
[
55
],
[
57,
59
],
[
61,
63,
65
],
[
67
],
[
69
],
[
71,
75
]
] |
24,521 | static int aasc_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AascContext *s = avctx->priv_data;
int compr, i, stride, ret;
s->frame.reference = 1;
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
if ((ret = avctx->reget_buffer(avctx, &s->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
return ret;
}
compr = AV_RL32(buf);
buf += 4;
buf_size -= 4;
switch (compr) {
case 0:
stride = (avctx->width * 3 + 3) & ~3;
for (i = avctx->height - 1; i >= 0; i--) {
memcpy(s->frame.data[0] + i * s->frame.linesize[0], buf, avctx->width * 3);
buf += stride;
}
break;
case 1:
bytestream2_init(&s->gb, buf - 4, buf_size + 4);
ff_msrle_decode(avctx, (AVPicture*)&s->frame, 8, &s->gb);
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown compression type %d\n", compr);
return AVERROR_INVALIDDATA;
}
*got_frame = 1;
*(AVFrame*)data = s->frame;
/* report that the buffer was completely consumed */
return buf_size;
}
| false | FFmpeg | da7baaaae79b4d7d715d35ea6bcfbdd149edc177 | static int aasc_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AascContext *s = avctx->priv_data;
int compr, i, stride, ret;
s->frame.reference = 1;
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
if ((ret = avctx->reget_buffer(avctx, &s->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
return ret;
}
compr = AV_RL32(buf);
buf += 4;
buf_size -= 4;
switch (compr) {
case 0:
stride = (avctx->width * 3 + 3) & ~3;
for (i = avctx->height - 1; i >= 0; i--) {
memcpy(s->frame.data[0] + i * s->frame.linesize[0], buf, avctx->width * 3);
buf += stride;
}
break;
case 1:
bytestream2_init(&s->gb, buf - 4, buf_size + 4);
ff_msrle_decode(avctx, (AVPicture*)&s->frame, 8, &s->gb);
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown compression type %d\n", compr);
return AVERROR_INVALIDDATA;
}
*got_frame = 1;
*(AVFrame*)data = s->frame;
return buf_size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
AascContext *s = VAR_0->priv_data;
int VAR_6, VAR_7, VAR_8, VAR_9;
s->frame.reference = 1;
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
if ((VAR_9 = VAR_0->reget_buffer(VAR_0, &s->frame)) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "reget_buffer() failed\n");
return VAR_9;
}
VAR_6 = AV_RL32(VAR_4);
VAR_4 += 4;
VAR_5 -= 4;
switch (VAR_6) {
case 0:
VAR_8 = (VAR_0->width * 3 + 3) & ~3;
for (VAR_7 = VAR_0->height - 1; VAR_7 >= 0; VAR_7--) {
memcpy(s->frame.VAR_1[0] + VAR_7 * s->frame.linesize[0], VAR_4, VAR_0->width * 3);
VAR_4 += VAR_8;
}
break;
case 1:
bytestream2_init(&s->gb, VAR_4 - 4, VAR_5 + 4);
ff_msrle_decode(VAR_0, (AVPicture*)&s->frame, 8, &s->gb);
break;
default:
av_log(VAR_0, AV_LOG_ERROR, "Unknown compression type %d\n", VAR_6);
return AVERROR_INVALIDDATA;
}
*VAR_2 = 1;
*(AVFrame*)VAR_1 = s->frame;
return VAR_5;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"AascContext *s = VAR_0->priv_data;",
"int VAR_6, VAR_7, VAR_8, VAR_9;",
"s->frame.reference = 1;",
"s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;",
"if ((VAR_9 = VAR_0->reget_buffer(VAR_0, &s->frame)) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"reget_buffer() failed\\n\");",
"return VAR_9;",
"}",
"VAR_6 = AV_RL32(VAR_4);",
"VAR_4 += 4;",
"VAR_5 -= 4;",
"switch (VAR_6) {",
"case 0:\nVAR_8 = (VAR_0->width * 3 + 3) & ~3;",
"for (VAR_7 = VAR_0->height - 1; VAR_7 >= 0; VAR_7--) {",
"memcpy(s->frame.VAR_1[0] + VAR_7 * s->frame.linesize[0], VAR_4, VAR_0->width * 3);",
"VAR_4 += VAR_8;",
"}",
"break;",
"case 1:\nbytestream2_init(&s->gb, VAR_4 - 4, VAR_5 + 4);",
"ff_msrle_decode(VAR_0, (AVPicture*)&s->frame, 8, &s->gb);",
"break;",
"default:\nav_log(VAR_0, AV_LOG_ERROR, \"Unknown compression type %d\\n\", VAR_6);",
"return AVERROR_INVALIDDATA;",
"}",
"*VAR_2 = 1;",
"*(AVFrame*)VAR_1 = s->frame;",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
81
],
[
83
]
] |
24,522 | static int rv10_decode_packet(AVCodecContext *avctx,
uint8_t *buf, int buf_size)
{
MpegEncContext *s = avctx->priv_data;
int i, mb_count, mb_pos, left;
init_get_bits(&s->gb, buf, buf_size*8);
#if 0
for(i=0; i<buf_size*8 && i<200; i++)
printf("%d", get_bits1(&s->gb));
printf("\n");
return 0;
#endif
if(s->codec_id ==CODEC_ID_RV10)
mb_count = rv10_decode_picture_header(s);
else
mb_count = rv20_decode_picture_header(s);
if (mb_count < 0) {
av_log(s->avctx, AV_LOG_ERROR, "HEADER ERROR\n");
return -1;
}
if (s->mb_x >= s->mb_width ||
s->mb_y >= s->mb_height) {
av_log(s->avctx, AV_LOG_ERROR, "POS ERROR %d %d\n", s->mb_x, s->mb_y);
return -1;
}
mb_pos = s->mb_y * s->mb_width + s->mb_x;
left = s->mb_width * s->mb_height - mb_pos;
if (mb_count > left) {
av_log(s->avctx, AV_LOG_ERROR, "COUNT ERROR\n");
return -1;
}
//if(s->pict_type == P_TYPE) return 0;
if (s->mb_x == 0 && s->mb_y == 0) {
if(MPV_frame_start(s, avctx) < 0)
return -1;
}
#ifdef DEBUG
printf("qscale=%d\n", s->qscale);
#endif
/* default quantization values */
if(s->codec_id== CODEC_ID_RV10){
if(s->mb_y==0) s->first_slice_line=1;
}else{
s->first_slice_line=1;
s->resync_mb_x= s->mb_x;
s->resync_mb_y= s->mb_y;
}
if(s->h263_aic){
s->y_dc_scale_table=
s->c_dc_scale_table= ff_aic_dc_scale_table;
}else{
s->y_dc_scale_table=
s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
}
if(s->modified_quant)
s->chroma_qscale_table= ff_h263_chroma_qscale_table;
ff_set_qscale(s, s->qscale);
s->rv10_first_dc_coded[0] = 0;
s->rv10_first_dc_coded[1] = 0;
s->rv10_first_dc_coded[2] = 0;
s->block_wrap[0]=
s->block_wrap[1]=
s->block_wrap[2]=
s->block_wrap[3]= s->mb_width*2 + 2;
s->block_wrap[4]=
s->block_wrap[5]= s->mb_width + 2;
ff_init_block_index(s);
/* decode each macroblock */
for(i=0;i<mb_count;i++) {
int ret;
ff_update_block_index(s);
#ifdef DEBUG
printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y);
#endif
s->dsp.clear_blocks(s->block[0]);
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
ret=ff_h263_decode_mb(s, s->block);
if (ret == SLICE_ERROR) {
av_log(s->avctx, AV_LOG_ERROR, "ERROR at MB %d %d\n", s->mb_x, s->mb_y);
return -1;
}
ff_h263_update_motion_val(s);
MPV_decode_mb(s, s->block);
if(s->loop_filter)
ff_h263_loop_filter(s);
if (++s->mb_x == s->mb_width) {
s->mb_x = 0;
s->mb_y++;
ff_init_block_index(s);
}
if(s->mb_x == s->resync_mb_x)
s->first_slice_line=0;
if(ret == SLICE_END) break;
}
return buf_size;
}
| true | FFmpeg | bed1707c9c274831173902542aaef1f8428e6331 | static int rv10_decode_packet(AVCodecContext *avctx,
uint8_t *buf, int buf_size)
{
MpegEncContext *s = avctx->priv_data;
int i, mb_count, mb_pos, left;
init_get_bits(&s->gb, buf, buf_size*8);
#if 0
for(i=0; i<buf_size*8 && i<200; i++)
printf("%d", get_bits1(&s->gb));
printf("\n");
return 0;
#endif
if(s->codec_id ==CODEC_ID_RV10)
mb_count = rv10_decode_picture_header(s);
else
mb_count = rv20_decode_picture_header(s);
if (mb_count < 0) {
av_log(s->avctx, AV_LOG_ERROR, "HEADER ERROR\n");
return -1;
}
if (s->mb_x >= s->mb_width ||
s->mb_y >= s->mb_height) {
av_log(s->avctx, AV_LOG_ERROR, "POS ERROR %d %d\n", s->mb_x, s->mb_y);
return -1;
}
mb_pos = s->mb_y * s->mb_width + s->mb_x;
left = s->mb_width * s->mb_height - mb_pos;
if (mb_count > left) {
av_log(s->avctx, AV_LOG_ERROR, "COUNT ERROR\n");
return -1;
}
if (s->mb_x == 0 && s->mb_y == 0) {
if(MPV_frame_start(s, avctx) < 0)
return -1;
}
#ifdef DEBUG
printf("qscale=%d\n", s->qscale);
#endif
if(s->codec_id== CODEC_ID_RV10){
if(s->mb_y==0) s->first_slice_line=1;
}else{
s->first_slice_line=1;
s->resync_mb_x= s->mb_x;
s->resync_mb_y= s->mb_y;
}
if(s->h263_aic){
s->y_dc_scale_table=
s->c_dc_scale_table= ff_aic_dc_scale_table;
}else{
s->y_dc_scale_table=
s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
}
if(s->modified_quant)
s->chroma_qscale_table= ff_h263_chroma_qscale_table;
ff_set_qscale(s, s->qscale);
s->rv10_first_dc_coded[0] = 0;
s->rv10_first_dc_coded[1] = 0;
s->rv10_first_dc_coded[2] = 0;
s->block_wrap[0]=
s->block_wrap[1]=
s->block_wrap[2]=
s->block_wrap[3]= s->mb_width*2 + 2;
s->block_wrap[4]=
s->block_wrap[5]= s->mb_width + 2;
ff_init_block_index(s);
for(i=0;i<mb_count;i++) {
int ret;
ff_update_block_index(s);
#ifdef DEBUG
printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y);
#endif
s->dsp.clear_blocks(s->block[0]);
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
ret=ff_h263_decode_mb(s, s->block);
if (ret == SLICE_ERROR) {
av_log(s->avctx, AV_LOG_ERROR, "ERROR at MB %d %d\n", s->mb_x, s->mb_y);
return -1;
}
ff_h263_update_motion_val(s);
MPV_decode_mb(s, s->block);
if(s->loop_filter)
ff_h263_loop_filter(s);
if (++s->mb_x == s->mb_width) {
s->mb_x = 0;
s->mb_y++;
ff_init_block_index(s);
}
if(s->mb_x == s->resync_mb_x)
s->first_slice_line=0;
if(ret == SLICE_END) break;
}
return buf_size;
}
| {
"code": [
" return -1;",
" if (s->mb_x == 0 && s->mb_y == 0) {"
],
"line_no": [
75,
71
]
} | static int FUNC_0(AVCodecContext *VAR_0,
uint8_t *VAR_1, int VAR_2)
{
MpegEncContext *s = VAR_0->priv_data;
int VAR_3, VAR_4, VAR_5, VAR_6;
init_get_bits(&s->gb, VAR_1, VAR_2*8);
#if 0
for(VAR_3=0; VAR_3<VAR_2*8 && VAR_3<200; VAR_3++)
printf("%d", get_bits1(&s->gb));
printf("\n");
return 0;
#endif
if(s->codec_id ==CODEC_ID_RV10)
VAR_4 = rv10_decode_picture_header(s);
else
VAR_4 = rv20_decode_picture_header(s);
if (VAR_4 < 0) {
av_log(s->VAR_0, AV_LOG_ERROR, "HEADER ERROR\n");
return -1;
}
if (s->mb_x >= s->mb_width ||
s->mb_y >= s->mb_height) {
av_log(s->VAR_0, AV_LOG_ERROR, "POS ERROR %d %d\n", s->mb_x, s->mb_y);
return -1;
}
VAR_5 = s->mb_y * s->mb_width + s->mb_x;
VAR_6 = s->mb_width * s->mb_height - VAR_5;
if (VAR_4 > VAR_6) {
av_log(s->VAR_0, AV_LOG_ERROR, "COUNT ERROR\n");
return -1;
}
if (s->mb_x == 0 && s->mb_y == 0) {
if(MPV_frame_start(s, VAR_0) < 0)
return -1;
}
#ifdef DEBUG
printf("qscale=%d\n", s->qscale);
#endif
if(s->codec_id== CODEC_ID_RV10){
if(s->mb_y==0) s->first_slice_line=1;
}else{
s->first_slice_line=1;
s->resync_mb_x= s->mb_x;
s->resync_mb_y= s->mb_y;
}
if(s->h263_aic){
s->y_dc_scale_table=
s->c_dc_scale_table= ff_aic_dc_scale_table;
}else{
s->y_dc_scale_table=
s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
}
if(s->modified_quant)
s->chroma_qscale_table= ff_h263_chroma_qscale_table;
ff_set_qscale(s, s->qscale);
s->rv10_first_dc_coded[0] = 0;
s->rv10_first_dc_coded[1] = 0;
s->rv10_first_dc_coded[2] = 0;
s->block_wrap[0]=
s->block_wrap[1]=
s->block_wrap[2]=
s->block_wrap[3]= s->mb_width*2 + 2;
s->block_wrap[4]=
s->block_wrap[5]= s->mb_width + 2;
ff_init_block_index(s);
for(VAR_3=0;VAR_3<VAR_4;VAR_3++) {
int VAR_7;
ff_update_block_index(s);
#ifdef DEBUG
printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y);
#endif
s->dsp.clear_blocks(s->block[0]);
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
VAR_7=ff_h263_decode_mb(s, s->block);
if (VAR_7 == SLICE_ERROR) {
av_log(s->VAR_0, AV_LOG_ERROR, "ERROR at MB %d %d\n", s->mb_x, s->mb_y);
return -1;
}
ff_h263_update_motion_val(s);
MPV_decode_mb(s, s->block);
if(s->loop_filter)
ff_h263_loop_filter(s);
if (++s->mb_x == s->mb_width) {
s->mb_x = 0;
s->mb_y++;
ff_init_block_index(s);
}
if(s->mb_x == s->resync_mb_x)
s->first_slice_line=0;
if(VAR_7 == SLICE_END) break;
}
return VAR_2;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nuint8_t *VAR_1, int VAR_2)\n{",
"MpegEncContext *s = VAR_0->priv_data;",
"int VAR_3, VAR_4, VAR_5, VAR_6;",
"init_get_bits(&s->gb, VAR_1, VAR_2*8);",
"#if 0\nfor(VAR_3=0; VAR_3<VAR_2*8 && VAR_3<200; VAR_3++)",
"printf(\"%d\", get_bits1(&s->gb));",
"printf(\"\\n\");",
"return 0;",
"#endif\nif(s->codec_id ==CODEC_ID_RV10)\nVAR_4 = rv10_decode_picture_header(s);",
"else\nVAR_4 = rv20_decode_picture_header(s);",
"if (VAR_4 < 0) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \"HEADER ERROR\\n\");",
"return -1;",
"}",
"if (s->mb_x >= s->mb_width ||\ns->mb_y >= s->mb_height) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \"POS ERROR %d %d\\n\", s->mb_x, s->mb_y);",
"return -1;",
"}",
"VAR_5 = s->mb_y * s->mb_width + s->mb_x;",
"VAR_6 = s->mb_width * s->mb_height - VAR_5;",
"if (VAR_4 > VAR_6) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \"COUNT ERROR\\n\");",
"return -1;",
"}",
"if (s->mb_x == 0 && s->mb_y == 0) {",
"if(MPV_frame_start(s, VAR_0) < 0)\nreturn -1;",
"}",
"#ifdef DEBUG\nprintf(\"qscale=%d\\n\", s->qscale);",
"#endif\nif(s->codec_id== CODEC_ID_RV10){",
"if(s->mb_y==0) s->first_slice_line=1;",
"}else{",
"s->first_slice_line=1;",
"s->resync_mb_x= s->mb_x;",
"s->resync_mb_y= s->mb_y;",
"}",
"if(s->h263_aic){",
"s->y_dc_scale_table=\ns->c_dc_scale_table= ff_aic_dc_scale_table;",
"}else{",
"s->y_dc_scale_table=\ns->c_dc_scale_table= ff_mpeg1_dc_scale_table;",
"}",
"if(s->modified_quant)\ns->chroma_qscale_table= ff_h263_chroma_qscale_table;",
"ff_set_qscale(s, s->qscale);",
"s->rv10_first_dc_coded[0] = 0;",
"s->rv10_first_dc_coded[1] = 0;",
"s->rv10_first_dc_coded[2] = 0;",
"s->block_wrap[0]=\ns->block_wrap[1]=\ns->block_wrap[2]=\ns->block_wrap[3]= s->mb_width*2 + 2;",
"s->block_wrap[4]=\ns->block_wrap[5]= s->mb_width + 2;",
"ff_init_block_index(s);",
"for(VAR_3=0;VAR_3<VAR_4;VAR_3++) {",
"int VAR_7;",
"ff_update_block_index(s);",
"#ifdef DEBUG\nprintf(\"**mb x=%d y=%d\\n\", s->mb_x, s->mb_y);",
"#endif\ns->dsp.clear_blocks(s->block[0]);",
"s->mv_dir = MV_DIR_FORWARD;",
"s->mv_type = MV_TYPE_16X16;",
"VAR_7=ff_h263_decode_mb(s, s->block);",
"if (VAR_7 == SLICE_ERROR) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \"ERROR at MB %d %d\\n\", s->mb_x, s->mb_y);",
"return -1;",
"}",
"ff_h263_update_motion_val(s);",
"MPV_decode_mb(s, s->block);",
"if(s->loop_filter)\nff_h263_loop_filter(s);",
"if (++s->mb_x == s->mb_width) {",
"s->mb_x = 0;",
"s->mb_y++;",
"ff_init_block_index(s);",
"}",
"if(s->mb_x == s->resync_mb_x)\ns->first_slice_line=0;",
"if(VAR_7 == SLICE_END) break;",
"}",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
25,
27,
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
71
],
[
73,
75
],
[
77
],
[
81,
83
],
[
85,
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107,
109
],
[
111
],
[
113,
115
],
[
117
],
[
121,
123
],
[
127
],
[
131
],
[
133
],
[
135
],
[
139,
141,
143,
145
],
[
147,
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161,
163
],
[
165,
169
],
[
171
],
[
173
],
[
175
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191,
193
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207,
209
],
[
211
],
[
213
],
[
217
],
[
219
]
] |
24,523 | static bool memory_region_dispatch_write(MemoryRegion *mr,
hwaddr addr,
uint64_t data,
unsigned size)
{
if (!memory_region_access_valid(mr, addr, size, true)) {
unassigned_mem_write(mr, addr, data, size);
return true;
}
adjust_endianness(mr, &data, size);
if (mr->ops->write) {
access_with_adjusted_size(addr, &data, size,
mr->ops->impl.min_access_size,
mr->ops->impl.max_access_size,
memory_region_write_accessor, mr);
} else {
access_with_adjusted_size(addr, &data, size, 1, 4,
memory_region_oldmmio_write_accessor, mr);
}
return false;
}
| true | qemu | cc05c43ad942165ecc6ffd39e41991bee43af044 | static bool memory_region_dispatch_write(MemoryRegion *mr,
hwaddr addr,
uint64_t data,
unsigned size)
{
if (!memory_region_access_valid(mr, addr, size, true)) {
unassigned_mem_write(mr, addr, data, size);
return true;
}
adjust_endianness(mr, &data, size);
if (mr->ops->write) {
access_with_adjusted_size(addr, &data, size,
mr->ops->impl.min_access_size,
mr->ops->impl.max_access_size,
memory_region_write_accessor, mr);
} else {
access_with_adjusted_size(addr, &data, size, 1, 4,
memory_region_oldmmio_write_accessor, mr);
}
return false;
}
| {
"code": [
" hwaddr addr,",
" access_with_adjusted_size(addr, &data, size,",
" mr->ops->impl.min_access_size,",
" mr->ops->impl.max_access_size,",
" access_with_adjusted_size(addr, &data, size, 1, 4,",
" return true;",
" return false;",
"static bool memory_region_dispatch_write(MemoryRegion *mr,",
" hwaddr addr,",
" uint64_t data,",
" unsigned size)",
" return true;",
" access_with_adjusted_size(addr, &data, size,",
" mr->ops->impl.min_access_size,",
" mr->ops->impl.max_access_size,",
" memory_region_write_accessor, mr);",
" access_with_adjusted_size(addr, &data, size, 1, 4,",
" memory_region_oldmmio_write_accessor, mr);",
" return false;"
],
"line_no": [
3,
27,
29,
31,
37,
15,
43,
1,
3,
5,
7,
15,
27,
29,
31,
33,
37,
39,
43
]
} | static bool FUNC_0(MemoryRegion *mr,
hwaddr addr,
uint64_t data,
unsigned size)
{
if (!memory_region_access_valid(mr, addr, size, true)) {
unassigned_mem_write(mr, addr, data, size);
return true;
}
adjust_endianness(mr, &data, size);
if (mr->ops->write) {
access_with_adjusted_size(addr, &data, size,
mr->ops->impl.min_access_size,
mr->ops->impl.max_access_size,
memory_region_write_accessor, mr);
} else {
access_with_adjusted_size(addr, &data, size, 1, 4,
memory_region_oldmmio_write_accessor, mr);
}
return false;
}
| [
"static bool FUNC_0(MemoryRegion *mr,\nhwaddr addr,\nuint64_t data,\nunsigned size)\n{",
"if (!memory_region_access_valid(mr, addr, size, true)) {",
"unassigned_mem_write(mr, addr, data, size);",
"return true;",
"}",
"adjust_endianness(mr, &data, size);",
"if (mr->ops->write) {",
"access_with_adjusted_size(addr, &data, size,\nmr->ops->impl.min_access_size,\nmr->ops->impl.max_access_size,\nmemory_region_write_accessor, mr);",
"} else {",
"access_with_adjusted_size(addr, &data, size, 1, 4,\nmemory_region_oldmmio_write_accessor, mr);",
"}",
"return false;",
"}"
] | [
1,
0,
0,
1,
0,
0,
0,
1,
0,
1,
0,
1,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
25
],
[
27,
29,
31,
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
]
] |
24,525 | static void complete_pdu(V9fsState *s, V9fsPDU *pdu, ssize_t len)
{
int8_t id = pdu->id + 1; /* Response */
if (len < 0) {
int err = -len;
len = 7;
if (s->proto_version != V9FS_PROTO_2000L) {
V9fsString str;
str.data = strerror(err);
str.size = strlen(str.data);
len += pdu_marshal(pdu, len, "s", &str);
id = P9_RERROR;
}
len += pdu_marshal(pdu, len, "d", err);
if (s->proto_version == V9FS_PROTO_2000L) {
id = P9_RLERROR;
}
}
/* fill out the header */
pdu_marshal(pdu, 0, "dbw", (int32_t)len, id, pdu->tag);
/* keep these in sync */
pdu->size = len;
pdu->id = id;
/* push onto queue and notify */
virtqueue_push(s->vq, &pdu->elem, len);
/* FIXME: we should batch these completions */
virtio_notify(&s->vdev, s->vq);
/* Now wakeup anybody waiting in flush for this request */
qemu_co_queue_next(&pdu->complete);
free_pdu(s, pdu);
} | true | qemu | c572f23a3e7180dbeab5e86583e43ea2afed6271 | static void complete_pdu(V9fsState *s, V9fsPDU *pdu, ssize_t len)
{
int8_t id = pdu->id + 1;
if (len < 0) {
int err = -len;
len = 7;
if (s->proto_version != V9FS_PROTO_2000L) {
V9fsString str;
str.data = strerror(err);
str.size = strlen(str.data);
len += pdu_marshal(pdu, len, "s", &str);
id = P9_RERROR;
}
len += pdu_marshal(pdu, len, "d", err);
if (s->proto_version == V9FS_PROTO_2000L) {
id = P9_RLERROR;
}
}
pdu_marshal(pdu, 0, "dbw", (int32_t)len, id, pdu->tag);
pdu->size = len;
pdu->id = id;
virtqueue_push(s->vq, &pdu->elem, len);
virtio_notify(&s->vdev, s->vq);
qemu_co_queue_next(&pdu->complete);
free_pdu(s, pdu);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(V9fsState *VAR_0, V9fsPDU *VAR_1, ssize_t VAR_2)
{
int8_t id = VAR_1->id + 1;
if (VAR_2 < 0) {
int VAR_3 = -VAR_2;
VAR_2 = 7;
if (VAR_0->proto_version != V9FS_PROTO_2000L) {
V9fsString str;
str.data = strerror(VAR_3);
str.size = strlen(str.data);
VAR_2 += pdu_marshal(VAR_1, VAR_2, "VAR_0", &str);
id = P9_RERROR;
}
VAR_2 += pdu_marshal(VAR_1, VAR_2, "d", VAR_3);
if (VAR_0->proto_version == V9FS_PROTO_2000L) {
id = P9_RLERROR;
}
}
pdu_marshal(VAR_1, 0, "dbw", (int32_t)VAR_2, id, VAR_1->tag);
VAR_1->size = VAR_2;
VAR_1->id = id;
virtqueue_push(VAR_0->vq, &VAR_1->elem, VAR_2);
virtio_notify(&VAR_0->vdev, VAR_0->vq);
qemu_co_queue_next(&VAR_1->complete);
free_pdu(VAR_0, VAR_1);
} | [
"static void FUNC_0(V9fsState *VAR_0, V9fsPDU *VAR_1, ssize_t VAR_2)\n{",
"int8_t id = VAR_1->id + 1;",
"if (VAR_2 < 0) {",
"int VAR_3 = -VAR_2;",
"VAR_2 = 7;",
"if (VAR_0->proto_version != V9FS_PROTO_2000L) {",
"V9fsString str;",
"str.data = strerror(VAR_3);",
"str.size = strlen(str.data);",
"VAR_2 += pdu_marshal(VAR_1, VAR_2, \"VAR_0\", &str);",
"id = P9_RERROR;",
"}",
"VAR_2 += pdu_marshal(VAR_1, VAR_2, \"d\", VAR_3);",
"if (VAR_0->proto_version == V9FS_PROTO_2000L) {",
"id = P9_RLERROR;",
"}",
"}",
"pdu_marshal(VAR_1, 0, \"dbw\", (int32_t)VAR_2, id, VAR_1->tag);",
"VAR_1->size = VAR_2;",
"VAR_1->id = id;",
"virtqueue_push(VAR_0->vq, &VAR_1->elem, VAR_2);",
"virtio_notify(&VAR_0->vdev, VAR_0->vq);",
"qemu_co_queue_next(&VAR_1->complete);",
"free_pdu(VAR_0, 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,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
41
],
[
43
],
[
45
],
[
48
],
[
54
],
[
60
],
[
62
],
[
68
],
[
74
],
[
80
],
[
84
],
[
86
]
] |
24,526 | static void gen_rsr(DisasContext *dc, TCGv_i32 d, uint32_t sr)
{
static void (* const rsr_handler[256])(DisasContext *dc,
TCGv_i32 d, uint32_t sr) = {
[CCOUNT] = gen_rsr_ccount,
[PTEVADDR] = gen_rsr_ptevaddr,
};
if (sregnames[sr]) {
if (rsr_handler[sr]) {
rsr_handler[sr](dc, d, sr);
} else {
tcg_gen_mov_i32(d, cpu_SR[sr]);
}
} else {
qemu_log("RSR %d not implemented, ", sr);
}
}
| true | qemu | fe0bd475aa31e60674f7f53b85dc293108026202 | static void gen_rsr(DisasContext *dc, TCGv_i32 d, uint32_t sr)
{
static void (* const rsr_handler[256])(DisasContext *dc,
TCGv_i32 d, uint32_t sr) = {
[CCOUNT] = gen_rsr_ccount,
[PTEVADDR] = gen_rsr_ptevaddr,
};
if (sregnames[sr]) {
if (rsr_handler[sr]) {
rsr_handler[sr](dc, d, sr);
} else {
tcg_gen_mov_i32(d, cpu_SR[sr]);
}
} else {
qemu_log("RSR %d not implemented, ", sr);
}
}
| {
"code": [
" if (sregnames[sr]) {",
" if (rsr_handler[sr]) {",
" rsr_handler[sr](dc, d, sr);",
" } else {",
" tcg_gen_mov_i32(d, cpu_SR[sr]);",
" qemu_log(\"RSR %d not implemented, \", sr);",
" if (sregnames[sr]) {",
" } else {"
],
"line_no": [
17,
19,
21,
23,
25,
31,
17,
23
]
} | static void FUNC_0(DisasContext *VAR_4, TCGv_i32 VAR_4, uint32_t VAR_4)
{
static void (* const VAR_3[256])(DisasContext *VAR_4,
TCGv_i32 VAR_4, uint32_t VAR_4) = {
[CCOUNT] = gen_rsr_ccount,
[PTEVADDR] = gen_rsr_ptevaddr,
};
if (sregnames[VAR_4]) {
if (VAR_3[VAR_4]) {
VAR_3[VAR_4](VAR_4, VAR_4, VAR_4);
} else {
tcg_gen_mov_i32(VAR_4, cpu_SR[VAR_4]);
}
} else {
qemu_log("RSR %VAR_4 not implemented, ", VAR_4);
}
}
| [
"static void FUNC_0(DisasContext *VAR_4, TCGv_i32 VAR_4, uint32_t VAR_4)\n{",
"static void (* const VAR_3[256])(DisasContext *VAR_4,\nTCGv_i32 VAR_4, uint32_t VAR_4) = {",
"[CCOUNT] = gen_rsr_ccount,\n[PTEVADDR] = gen_rsr_ptevaddr,\n};",
"if (sregnames[VAR_4]) {",
"if (VAR_3[VAR_4]) {",
"VAR_3[VAR_4](VAR_4, VAR_4, VAR_4);",
"} else {",
"tcg_gen_mov_i32(VAR_4, cpu_SR[VAR_4]);",
"}",
"} else {",
"qemu_log(\"RSR %VAR_4 not implemented, \", VAR_4);",
"}",
"}"
] | [
0,
0,
0,
1,
1,
1,
0,
1,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9,
11,
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
]
] |
24,527 | static inline uint64_t cksm_overflow(uint64_t cksm)
{
if (cksm > 0xffffffffULL) {
cksm &= 0xffffffffULL;
cksm++;
}
return cksm;
}
| true | qemu | 5b185639c5740998de403415c749ac98e13418fd | static inline uint64_t cksm_overflow(uint64_t cksm)
{
if (cksm > 0xffffffffULL) {
cksm &= 0xffffffffULL;
cksm++;
}
return cksm;
}
| {
"code": [
"static inline uint64_t cksm_overflow(uint64_t cksm)",
" if (cksm > 0xffffffffULL) {",
" cksm &= 0xffffffffULL;",
" cksm++;",
" return cksm;"
],
"line_no": [
1,
5,
7,
9,
13
]
} | static inline uint64_t FUNC_0(uint64_t cksm)
{
if (cksm > 0xffffffffULL) {
cksm &= 0xffffffffULL;
cksm++;
}
return cksm;
}
| [
"static inline uint64_t FUNC_0(uint64_t cksm)\n{",
"if (cksm > 0xffffffffULL) {",
"cksm &= 0xffffffffULL;",
"cksm++;",
"}",
"return cksm;",
"}"
] | [
1,
1,
1,
1,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
24,528 | int tcp_start_outgoing_migration(MigrationState *s, const char *host_port,
Error **errp)
{
s->get_error = socket_errno;
s->write = socket_write;
s->close = tcp_close;
s->fd = inet_connect(host_port, false, NULL, errp);
if (!error_is_set(errp)) {
migrate_fd_connect(s);
} else if (error_is_type(*errp, QERR_SOCKET_CONNECT_IN_PROGRESS)) {
DPRINTF("connect in progress\n");
qemu_set_fd_handler2(s->fd, NULL, NULL, tcp_wait_for_connect, s);
} else if (error_is_type(*errp, QERR_SOCKET_CREATE_FAILED)) {
DPRINTF("connect failed\n");
return -1;
} else if (error_is_type(*errp, QERR_SOCKET_CONNECT_FAILED)) {
DPRINTF("connect failed\n");
migrate_fd_error(s);
return -1;
} else {
DPRINTF("unknown error\n");
return -1;
}
return 0;
}
| true | qemu | 540c79fec9e8b6a6582ec4c65aa2c4c5366e4b89 | int tcp_start_outgoing_migration(MigrationState *s, const char *host_port,
Error **errp)
{
s->get_error = socket_errno;
s->write = socket_write;
s->close = tcp_close;
s->fd = inet_connect(host_port, false, NULL, errp);
if (!error_is_set(errp)) {
migrate_fd_connect(s);
} else if (error_is_type(*errp, QERR_SOCKET_CONNECT_IN_PROGRESS)) {
DPRINTF("connect in progress\n");
qemu_set_fd_handler2(s->fd, NULL, NULL, tcp_wait_for_connect, s);
} else if (error_is_type(*errp, QERR_SOCKET_CREATE_FAILED)) {
DPRINTF("connect failed\n");
return -1;
} else if (error_is_type(*errp, QERR_SOCKET_CONNECT_FAILED)) {
DPRINTF("connect failed\n");
migrate_fd_error(s);
return -1;
} else {
DPRINTF("unknown error\n");
return -1;
}
return 0;
}
| {
"code": [
" s->fd = inet_connect(host_port, false, NULL, errp);",
" if (!error_is_set(errp)) {",
" migrate_fd_connect(s);",
" } else if (error_is_type(*errp, QERR_SOCKET_CONNECT_IN_PROGRESS)) {",
" } else if (error_is_type(*errp, QERR_SOCKET_CREATE_FAILED)) {",
" DPRINTF(\"connect failed\\n\");",
" return -1;",
" } else if (error_is_type(*errp, QERR_SOCKET_CONNECT_FAILED)) {",
" DPRINTF(\"connect failed\\n\");",
" migrate_fd_error(s);",
" return -1;",
" DPRINTF(\"unknown error\\n\");",
" return -1;"
],
"line_no": [
15,
19,
21,
23,
29,
31,
33,
35,
31,
39,
33,
45,
33
]
} | int FUNC_0(MigrationState *VAR_0, const char *VAR_1,
Error **VAR_2)
{
VAR_0->get_error = socket_errno;
VAR_0->write = socket_write;
VAR_0->close = tcp_close;
VAR_0->fd = inet_connect(VAR_1, false, NULL, VAR_2);
if (!error_is_set(VAR_2)) {
migrate_fd_connect(VAR_0);
} else if (error_is_type(*VAR_2, QERR_SOCKET_CONNECT_IN_PROGRESS)) {
DPRINTF("connect in progress\n");
qemu_set_fd_handler2(VAR_0->fd, NULL, NULL, tcp_wait_for_connect, VAR_0);
} else if (error_is_type(*VAR_2, QERR_SOCKET_CREATE_FAILED)) {
DPRINTF("connect failed\n");
return -1;
} else if (error_is_type(*VAR_2, QERR_SOCKET_CONNECT_FAILED)) {
DPRINTF("connect failed\n");
migrate_fd_error(VAR_0);
return -1;
} else {
DPRINTF("unknown error\n");
return -1;
}
return 0;
}
| [
"int FUNC_0(MigrationState *VAR_0, const char *VAR_1,\nError **VAR_2)\n{",
"VAR_0->get_error = socket_errno;",
"VAR_0->write = socket_write;",
"VAR_0->close = tcp_close;",
"VAR_0->fd = inet_connect(VAR_1, false, NULL, VAR_2);",
"if (!error_is_set(VAR_2)) {",
"migrate_fd_connect(VAR_0);",
"} else if (error_is_type(*VAR_2, QERR_SOCKET_CONNECT_IN_PROGRESS)) {",
"DPRINTF(\"connect in progress\\n\");",
"qemu_set_fd_handler2(VAR_0->fd, NULL, NULL, tcp_wait_for_connect, VAR_0);",
"} else if (error_is_type(*VAR_2, QERR_SOCKET_CREATE_FAILED)) {",
"DPRINTF(\"connect failed\\n\");",
"return -1;",
"} else if (error_is_type(*VAR_2, QERR_SOCKET_CONNECT_FAILED)) {",
"DPRINTF(\"connect failed\\n\");",
"migrate_fd_error(VAR_0);",
"return -1;",
"} else {",
"DPRINTF(\"unknown error\\n\");",
"return -1;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
1,
1,
1,
1,
0,
1,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
]
] |
24,529 | static int asf_read_simple_index(AVFormatContext *s, const GUIDParseTable *g)
{
ASFContext *asf = s->priv_data;
AVIOContext *pb = s->pb;
AVStream *st = NULL;
uint64_t interval; // index entry time interval in 100 ns units, usually it's 1s
uint32_t pkt_num, nb_entries;
int32_t prev_pkt_num = -1;
int i, ret;
uint64_t size = avio_rl64(pb);
// simple index objects should be ordered by stream number, this loop tries to find
// the first not indexed video stream
for (i = 0; i < asf->nb_streams; i++) {
if ((asf->asf_st[i]->type == AVMEDIA_TYPE_VIDEO) && !asf->asf_st[i]->indexed) {
asf->asf_st[i]->indexed = 1;
st = s->streams[asf->asf_st[i]->index];
break;
}
}
if (!st) {
avio_skip(pb, size - 24); // if there's no video stream, skip index object
return 0;
}
avio_skip(pb, 16); // skip File ID
interval = avio_rl64(pb);
avio_skip(pb, 4);
nb_entries = avio_rl32(pb);
for (i = 0; i < nb_entries; i++) {
pkt_num = avio_rl32(pb);
ret = avio_skip(pb, 2);
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "Skipping failed in asf_read_simple_index.\n");
return ret;
}
if (prev_pkt_num != pkt_num) {
av_add_index_entry(st, asf->first_packet_offset + asf->packet_size *
pkt_num, av_rescale(interval, i, 10000),
asf->packet_size, 0, AVINDEX_KEYFRAME);
prev_pkt_num = pkt_num;
}
}
asf->is_simple_index = 1;
align_position(pb, asf->offset, size);
return 0;
}
| true | FFmpeg | cd7a2e1502f174c725c0de82711d2c7649057574 | static int asf_read_simple_index(AVFormatContext *s, const GUIDParseTable *g)
{
ASFContext *asf = s->priv_data;
AVIOContext *pb = s->pb;
AVStream *st = NULL;
uint64_t interval;
uint32_t pkt_num, nb_entries;
int32_t prev_pkt_num = -1;
int i, ret;
uint64_t size = avio_rl64(pb);
for (i = 0; i < asf->nb_streams; i++) {
if ((asf->asf_st[i]->type == AVMEDIA_TYPE_VIDEO) && !asf->asf_st[i]->indexed) {
asf->asf_st[i]->indexed = 1;
st = s->streams[asf->asf_st[i]->index];
break;
}
}
if (!st) {
avio_skip(pb, size - 24);
return 0;
}
avio_skip(pb, 16);
interval = avio_rl64(pb);
avio_skip(pb, 4);
nb_entries = avio_rl32(pb);
for (i = 0; i < nb_entries; i++) {
pkt_num = avio_rl32(pb);
ret = avio_skip(pb, 2);
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "Skipping failed in asf_read_simple_index.\n");
return ret;
}
if (prev_pkt_num != pkt_num) {
av_add_index_entry(st, asf->first_packet_offset + asf->packet_size *
pkt_num, av_rescale(interval, i, 10000),
asf->packet_size, 0, AVINDEX_KEYFRAME);
prev_pkt_num = pkt_num;
}
}
asf->is_simple_index = 1;
align_position(pb, asf->offset, size);
return 0;
}
| {
"code": [
" int i, ret;",
" ret = avio_skip(pb, 2);",
" if (ret < 0) {",
" return ret;"
],
"line_no": [
17,
61,
63,
67
]
} | static int FUNC_0(AVFormatContext *VAR_0, const GUIDParseTable *VAR_1)
{
ASFContext *asf = VAR_0->priv_data;
AVIOContext *pb = VAR_0->pb;
AVStream *st = NULL;
uint64_t interval;
uint32_t pkt_num, nb_entries;
int32_t prev_pkt_num = -1;
int VAR_2, VAR_3;
uint64_t size = avio_rl64(pb);
for (VAR_2 = 0; VAR_2 < asf->nb_streams; VAR_2++) {
if ((asf->asf_st[VAR_2]->type == AVMEDIA_TYPE_VIDEO) && !asf->asf_st[VAR_2]->indexed) {
asf->asf_st[VAR_2]->indexed = 1;
st = VAR_0->streams[asf->asf_st[VAR_2]->index];
break;
}
}
if (!st) {
avio_skip(pb, size - 24);
return 0;
}
avio_skip(pb, 16);
interval = avio_rl64(pb);
avio_skip(pb, 4);
nb_entries = avio_rl32(pb);
for (VAR_2 = 0; VAR_2 < nb_entries; VAR_2++) {
pkt_num = avio_rl32(pb);
VAR_3 = avio_skip(pb, 2);
if (VAR_3 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Skipping failed in FUNC_0.\n");
return VAR_3;
}
if (prev_pkt_num != pkt_num) {
av_add_index_entry(st, asf->first_packet_offset + asf->packet_size *
pkt_num, av_rescale(interval, VAR_2, 10000),
asf->packet_size, 0, AVINDEX_KEYFRAME);
prev_pkt_num = pkt_num;
}
}
asf->is_simple_index = 1;
align_position(pb, asf->offset, size);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, const GUIDParseTable *VAR_1)\n{",
"ASFContext *asf = VAR_0->priv_data;",
"AVIOContext *pb = VAR_0->pb;",
"AVStream *st = NULL;",
"uint64_t interval;",
"uint32_t pkt_num, nb_entries;",
"int32_t prev_pkt_num = -1;",
"int VAR_2, VAR_3;",
"uint64_t size = avio_rl64(pb);",
"for (VAR_2 = 0; VAR_2 < asf->nb_streams; VAR_2++) {",
"if ((asf->asf_st[VAR_2]->type == AVMEDIA_TYPE_VIDEO) && !asf->asf_st[VAR_2]->indexed) {",
"asf->asf_st[VAR_2]->indexed = 1;",
"st = VAR_0->streams[asf->asf_st[VAR_2]->index];",
"break;",
"}",
"}",
"if (!st) {",
"avio_skip(pb, size - 24);",
"return 0;",
"}",
"avio_skip(pb, 16);",
"interval = avio_rl64(pb);",
"avio_skip(pb, 4);",
"nb_entries = avio_rl32(pb);",
"for (VAR_2 = 0; VAR_2 < nb_entries; VAR_2++) {",
"pkt_num = avio_rl32(pb);",
"VAR_3 = avio_skip(pb, 2);",
"if (VAR_3 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Skipping failed in FUNC_0.\\n\");",
"return VAR_3;",
"}",
"if (prev_pkt_num != pkt_num) {",
"av_add_index_entry(st, asf->first_packet_offset + asf->packet_size *\npkt_num, av_rescale(interval, VAR_2, 10000),\nasf->packet_size, 0, AVINDEX_KEYFRAME);",
"prev_pkt_num = pkt_num;",
"}",
"}",
"asf->is_simple_index = 1;",
"align_position(pb, asf->offset, size);",
"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,
1,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73,
75,
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
]
] |
24,530 | static void ehci_advance_async_state(EHCIState *ehci)
{
const int async = 1;
switch(ehci_get_state(ehci, async)) {
case EST_INACTIVE:
if (!(ehci->usbcmd & USBCMD_ASE)) {
break;
}
ehci_set_usbsts(ehci, USBSTS_ASS);
ehci_set_state(ehci, async, EST_ACTIVE);
// No break, fall through to ACTIVE
case EST_ACTIVE:
if ( !(ehci->usbcmd & USBCMD_ASE)) {
ehci_clear_usbsts(ehci, USBSTS_ASS);
ehci_set_state(ehci, async, EST_INACTIVE);
break;
}
/* If the doorbell is set, the guest wants to make a change to the
* schedule. The host controller needs to release cached data.
* (section 4.8.2)
*/
if (ehci->usbcmd & USBCMD_IAAD) {
DPRINTF("ASYNC: doorbell request acknowledged\n");
ehci->usbcmd &= ~USBCMD_IAAD;
ehci_set_interrupt(ehci, USBSTS_IAA);
break;
}
/* make sure guest has acknowledged */
/* TO-DO: is this really needed? */
if (ehci->usbsts & USBSTS_IAA) {
DPRINTF("IAA status bit still set.\n");
break;
}
/* check that address register has been set */
if (ehci->asynclistaddr == 0) {
break;
}
ehci_set_state(ehci, async, EST_WAITLISTHEAD);
ehci_advance_state(ehci, async);
break;
default:
/* this should only be due to a developer mistake */
fprintf(stderr, "ehci: Bad asynchronous state %d. "
"Resetting to active\n", ehci->astate);
assert(0);
}
}
| true | qemu | 4be23939ab0d7019c7e59a37485b416fbbf0f073 | static void ehci_advance_async_state(EHCIState *ehci)
{
const int async = 1;
switch(ehci_get_state(ehci, async)) {
case EST_INACTIVE:
if (!(ehci->usbcmd & USBCMD_ASE)) {
break;
}
ehci_set_usbsts(ehci, USBSTS_ASS);
ehci_set_state(ehci, async, EST_ACTIVE);
case EST_ACTIVE:
if ( !(ehci->usbcmd & USBCMD_ASE)) {
ehci_clear_usbsts(ehci, USBSTS_ASS);
ehci_set_state(ehci, async, EST_INACTIVE);
break;
}
if (ehci->usbcmd & USBCMD_IAAD) {
DPRINTF("ASYNC: doorbell request acknowledged\n");
ehci->usbcmd &= ~USBCMD_IAAD;
ehci_set_interrupt(ehci, USBSTS_IAA);
break;
}
if (ehci->usbsts & USBSTS_IAA) {
DPRINTF("IAA status bit still set.\n");
break;
}
if (ehci->asynclistaddr == 0) {
break;
}
ehci_set_state(ehci, async, EST_WAITLISTHEAD);
ehci_advance_state(ehci, async);
break;
default:
fprintf(stderr, "ehci: Bad asynchronous state %d. "
"Resetting to active\n", ehci->astate);
assert(0);
}
}
| {
"code": [
" if (ehci->usbcmd & USBCMD_IAAD) {",
" DPRINTF(\"ASYNC: doorbell request acknowledged\\n\");",
" ehci->usbcmd &= ~USBCMD_IAAD;",
" ehci_set_interrupt(ehci, USBSTS_IAA);",
" break;"
],
"line_no": [
49,
51,
53,
55,
15
]
} | static void FUNC_0(EHCIState *VAR_0)
{
const int VAR_1 = 1;
switch(ehci_get_state(VAR_0, VAR_1)) {
case EST_INACTIVE:
if (!(VAR_0->usbcmd & USBCMD_ASE)) {
break;
}
ehci_set_usbsts(VAR_0, USBSTS_ASS);
ehci_set_state(VAR_0, VAR_1, EST_ACTIVE);
case EST_ACTIVE:
if ( !(VAR_0->usbcmd & USBCMD_ASE)) {
ehci_clear_usbsts(VAR_0, USBSTS_ASS);
ehci_set_state(VAR_0, VAR_1, EST_INACTIVE);
break;
}
if (VAR_0->usbcmd & USBCMD_IAAD) {
DPRINTF("ASYNC: doorbell request acknowledged\n");
VAR_0->usbcmd &= ~USBCMD_IAAD;
ehci_set_interrupt(VAR_0, USBSTS_IAA);
break;
}
if (VAR_0->usbsts & USBSTS_IAA) {
DPRINTF("IAA status bit still set.\n");
break;
}
if (VAR_0->asynclistaddr == 0) {
break;
}
ehci_set_state(VAR_0, VAR_1, EST_WAITLISTHEAD);
ehci_advance_state(VAR_0, VAR_1);
break;
default:
fprintf(stderr, "VAR_0: Bad asynchronous state %d. "
"Resetting to active\n", VAR_0->astate);
assert(0);
}
}
| [
"static void FUNC_0(EHCIState *VAR_0)\n{",
"const int VAR_1 = 1;",
"switch(ehci_get_state(VAR_0, VAR_1)) {",
"case EST_INACTIVE:\nif (!(VAR_0->usbcmd & USBCMD_ASE)) {",
"break;",
"}",
"ehci_set_usbsts(VAR_0, USBSTS_ASS);",
"ehci_set_state(VAR_0, VAR_1, EST_ACTIVE);",
"case EST_ACTIVE:\nif ( !(VAR_0->usbcmd & USBCMD_ASE)) {",
"ehci_clear_usbsts(VAR_0, USBSTS_ASS);",
"ehci_set_state(VAR_0, VAR_1, EST_INACTIVE);",
"break;",
"}",
"if (VAR_0->usbcmd & USBCMD_IAAD) {",
"DPRINTF(\"ASYNC: doorbell request acknowledged\\n\");",
"VAR_0->usbcmd &= ~USBCMD_IAAD;",
"ehci_set_interrupt(VAR_0, USBSTS_IAA);",
"break;",
"}",
"if (VAR_0->usbsts & USBSTS_IAA) {",
"DPRINTF(\"IAA status bit still set.\\n\");",
"break;",
"}",
"if (VAR_0->asynclistaddr == 0) {",
"break;",
"}",
"ehci_set_state(VAR_0, VAR_1, EST_WAITLISTHEAD);",
"ehci_advance_state(VAR_0, VAR_1);",
"break;",
"default:\nfprintf(stderr, \"VAR_0: Bad asynchronous state %d. \"\n\"Resetting to active\\n\", VAR_0->astate);",
"assert(0);",
"}",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
67
],
[
69
],
[
71
],
[
73
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
95,
99,
101
],
[
103
],
[
105
],
[
107
]
] |
24,531 | static uint32_t read_long(const unsigned char *p)
{
return (p[0]<<24)|(p[1]<<16)|(p[2]<<8)|p[3];
}
| true | FFmpeg | f19af812a32c1398d48c3550d11dbc6aafbb2bfc | static uint32_t read_long(const unsigned char *p)
{
return (p[0]<<24)|(p[1]<<16)|(p[2]<<8)|p[3];
}
| {
"code": [
"\treturn (p[0]<<24)|(p[1]<<16)|(p[2]<<8)|p[3];"
],
"line_no": [
5
]
} | static uint32_t FUNC_0(const unsigned char *p)
{
return (p[0]<<24)|(p[1]<<16)|(p[2]<<8)|p[3];
}
| [
"static uint32_t FUNC_0(const unsigned char *p)\n{",
"return (p[0]<<24)|(p[1]<<16)|(p[2]<<8)|p[3];",
"}"
] | [
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
24,532 | PPC_OP(subfeo)
{
do_subfeo();
RETURN();
}
| true | qemu | d9bce9d99f4656ae0b0127f7472db9067b8f84ab | PPC_OP(subfeo)
{
do_subfeo();
RETURN();
}
| {
"code": [
" RETURN();",
"PPC_OP(subfeo)",
" do_subfeo();",
" RETURN();"
],
"line_no": [
7,
1,
5,
7
]
} | FUNC_0(VAR_0)
{
do_subfeo();
RETURN();
}
| [
"FUNC_0(VAR_0)\n{",
"do_subfeo();",
"RETURN();",
"}"
] | [
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
24,534 | static void pci_bus_init(PCIBus *bus, DeviceState *parent,
const char *name,
MemoryRegion *address_space_mem,
MemoryRegion *address_space_io,
uint8_t devfn_min)
{
assert(PCI_FUNC(devfn_min) == 0);
bus->devfn_min = devfn_min;
bus->address_space_mem = address_space_mem;
bus->address_space_io = address_space_io;
memory_region_init_io(&bus->master_abort_mem, OBJECT(bus),
&master_abort_mem_ops, bus, "pci-master-abort",
memory_region_size(bus->address_space_mem));
memory_region_add_subregion_overlap(bus->address_space_mem,
0, &bus->master_abort_mem,
MASTER_ABORT_MEM_PRIORITY);
/* host bridge */
QLIST_INIT(&bus->child);
pci_host_bus_register(bus, parent);
vmstate_register(NULL, -1, &vmstate_pcibus, bus);
}
| true | qemu | 0fbf50b6ec126600dca115adb1563c657cc27695 | static void pci_bus_init(PCIBus *bus, DeviceState *parent,
const char *name,
MemoryRegion *address_space_mem,
MemoryRegion *address_space_io,
uint8_t devfn_min)
{
assert(PCI_FUNC(devfn_min) == 0);
bus->devfn_min = devfn_min;
bus->address_space_mem = address_space_mem;
bus->address_space_io = address_space_io;
memory_region_init_io(&bus->master_abort_mem, OBJECT(bus),
&master_abort_mem_ops, bus, "pci-master-abort",
memory_region_size(bus->address_space_mem));
memory_region_add_subregion_overlap(bus->address_space_mem,
0, &bus->master_abort_mem,
MASTER_ABORT_MEM_PRIORITY);
QLIST_INIT(&bus->child);
pci_host_bus_register(bus, parent);
vmstate_register(NULL, -1, &vmstate_pcibus, bus);
}
| {
"code": [
" memory_region_init_io(&bus->master_abort_mem, OBJECT(bus),",
" &master_abort_mem_ops, bus, \"pci-master-abort\",",
" memory_region_size(bus->address_space_mem));",
" memory_region_add_subregion_overlap(bus->address_space_mem,",
" 0, &bus->master_abort_mem,",
" MASTER_ABORT_MEM_PRIORITY);"
],
"line_no": [
25,
27,
29,
31,
33,
35
]
} | static void FUNC_0(PCIBus *VAR_0, DeviceState *VAR_1,
const char *VAR_2,
MemoryRegion *VAR_3,
MemoryRegion *VAR_4,
uint8_t VAR_5)
{
assert(PCI_FUNC(VAR_5) == 0);
VAR_0->VAR_5 = VAR_5;
VAR_0->VAR_3 = VAR_3;
VAR_0->VAR_4 = VAR_4;
memory_region_init_io(&VAR_0->master_abort_mem, OBJECT(VAR_0),
&master_abort_mem_ops, VAR_0, "pci-master-abort",
memory_region_size(VAR_0->VAR_3));
memory_region_add_subregion_overlap(VAR_0->VAR_3,
0, &VAR_0->master_abort_mem,
MASTER_ABORT_MEM_PRIORITY);
QLIST_INIT(&VAR_0->child);
pci_host_bus_register(VAR_0, VAR_1);
vmstate_register(NULL, -1, &vmstate_pcibus, VAR_0);
}
| [
"static void FUNC_0(PCIBus *VAR_0, DeviceState *VAR_1,\nconst char *VAR_2,\nMemoryRegion *VAR_3,\nMemoryRegion *VAR_4,\nuint8_t VAR_5)\n{",
"assert(PCI_FUNC(VAR_5) == 0);",
"VAR_0->VAR_5 = VAR_5;",
"VAR_0->VAR_3 = VAR_3;",
"VAR_0->VAR_4 = VAR_4;",
"memory_region_init_io(&VAR_0->master_abort_mem, OBJECT(VAR_0),\n&master_abort_mem_ops, VAR_0, \"pci-master-abort\",\nmemory_region_size(VAR_0->VAR_3));",
"memory_region_add_subregion_overlap(VAR_0->VAR_3,\n0, &VAR_0->master_abort_mem,\nMASTER_ABORT_MEM_PRIORITY);",
"QLIST_INIT(&VAR_0->child);",
"pci_host_bus_register(VAR_0, VAR_1);",
"vmstate_register(NULL, -1, &vmstate_pcibus, VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
25,
27,
29
],
[
31,
33,
35
],
[
41
],
[
45
],
[
49
],
[
51
]
] |
24,535 | void qmp_change_blockdev(const char *device, const char *filename,
const char *format, Error **errp)
{
BlockBackend *blk;
BlockDriverState *bs;
BlockDriver *drv = NULL;
int bdrv_flags;
Error *err = NULL;
blk = blk_by_name(device);
if (!blk) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
return;
}
bs = blk_bs(blk);
if (format) {
drv = bdrv_find_whitelisted_format(format, bs->read_only);
if (!drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
return;
}
}
eject_device(blk, 0, &err);
if (err) {
error_propagate(errp, err);
return;
}
bdrv_flags = bdrv_is_read_only(bs) ? 0 : BDRV_O_RDWR;
bdrv_flags |= bdrv_is_snapshot(bs) ? BDRV_O_SNAPSHOT : 0;
qmp_bdrv_open_encrypted(bs, filename, bdrv_flags, drv, NULL, errp);
}
| true | qemu | e3442099a2794925dfbe83711cd204caf80eae60 | void qmp_change_blockdev(const char *device, const char *filename,
const char *format, Error **errp)
{
BlockBackend *blk;
BlockDriverState *bs;
BlockDriver *drv = NULL;
int bdrv_flags;
Error *err = NULL;
blk = blk_by_name(device);
if (!blk) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
return;
}
bs = blk_bs(blk);
if (format) {
drv = bdrv_find_whitelisted_format(format, bs->read_only);
if (!drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
return;
}
}
eject_device(blk, 0, &err);
if (err) {
error_propagate(errp, err);
return;
}
bdrv_flags = bdrv_is_read_only(bs) ? 0 : BDRV_O_RDWR;
bdrv_flags |= bdrv_is_snapshot(bs) ? BDRV_O_SNAPSHOT : 0;
qmp_bdrv_open_encrypted(bs, filename, bdrv_flags, drv, NULL, errp);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(const char *VAR_0, const char *VAR_1,
const char *VAR_2, Error **VAR_3)
{
BlockBackend *blk;
BlockDriverState *bs;
BlockDriver *drv = NULL;
int VAR_4;
Error *err = NULL;
blk = blk_by_name(VAR_0);
if (!blk) {
error_set(VAR_3, QERR_DEVICE_NOT_FOUND, VAR_0);
return;
}
bs = blk_bs(blk);
if (VAR_2) {
drv = bdrv_find_whitelisted_format(VAR_2, bs->read_only);
if (!drv) {
error_set(VAR_3, QERR_INVALID_BLOCK_FORMAT, VAR_2);
return;
}
}
eject_device(blk, 0, &err);
if (err) {
error_propagate(VAR_3, err);
return;
}
VAR_4 = bdrv_is_read_only(bs) ? 0 : BDRV_O_RDWR;
VAR_4 |= bdrv_is_snapshot(bs) ? BDRV_O_SNAPSHOT : 0;
qmp_bdrv_open_encrypted(bs, VAR_1, VAR_4, drv, NULL, VAR_3);
}
| [
"void FUNC_0(const char *VAR_0, const char *VAR_1,\nconst char *VAR_2, Error **VAR_3)\n{",
"BlockBackend *blk;",
"BlockDriverState *bs;",
"BlockDriver *drv = NULL;",
"int VAR_4;",
"Error *err = NULL;",
"blk = blk_by_name(VAR_0);",
"if (!blk) {",
"error_set(VAR_3, QERR_DEVICE_NOT_FOUND, VAR_0);",
"return;",
"}",
"bs = blk_bs(blk);",
"if (VAR_2) {",
"drv = bdrv_find_whitelisted_format(VAR_2, bs->read_only);",
"if (!drv) {",
"error_set(VAR_3, QERR_INVALID_BLOCK_FORMAT, VAR_2);",
"return;",
"}",
"}",
"eject_device(blk, 0, &err);",
"if (err) {",
"error_propagate(VAR_3, err);",
"return;",
"}",
"VAR_4 = bdrv_is_read_only(bs) ? 0 : BDRV_O_RDWR;",
"VAR_4 |= bdrv_is_snapshot(bs) ? BDRV_O_SNAPSHOT : 0;",
"qmp_bdrv_open_encrypted(bs, VAR_1, VAR_4, drv, NULL, 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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
67
],
[
69
]
] |
24,536 | static void do_video_out(AVFormatContext *s,
OutputStream *ost,
AVFrame *next_picture,
double sync_ipts)
{
int ret, format_video_sync;
AVPacket pkt;
AVCodecContext *enc = ost->enc_ctx;
AVCodecContext *mux_enc = ost->st->codec;
int nb_frames, nb0_frames, i;
double delta, delta0;
double duration = 0;
int frame_size = 0;
InputStream *ist = NULL;
AVFilterContext *filter = ost->filter->filter;
if (ost->source_index >= 0)
ist = input_streams[ost->source_index];
if (filter->inputs[0]->frame_rate.num > 0 &&
filter->inputs[0]->frame_rate.den > 0)
duration = 1/(av_q2d(filter->inputs[0]->frame_rate) * av_q2d(enc->time_base));
if(ist && ist->st->start_time != AV_NOPTS_VALUE && ist->st->first_dts != AV_NOPTS_VALUE && ost->frame_rate.num)
duration = FFMIN(duration, 1/(av_q2d(ost->frame_rate) * av_q2d(enc->time_base)));
if (!ost->filters_script &&
!ost->filters &&
next_picture &&
ist &&
lrintf(av_frame_get_pkt_duration(next_picture) * av_q2d(ist->st->time_base) / av_q2d(enc->time_base)) > 0) {
duration = lrintf(av_frame_get_pkt_duration(next_picture) * av_q2d(ist->st->time_base) / av_q2d(enc->time_base));
}
if (!next_picture) {
//end, flushing
nb0_frames = nb_frames = mid_pred(ost->last_nb0_frames[0],
ost->last_nb0_frames[1],
ost->last_nb0_frames[2]);
} else {
delta0 = sync_ipts - ost->sync_opts;
delta = delta0 + duration;
/* by default, we output a single frame */
nb0_frames = 0;
nb_frames = 1;
format_video_sync = video_sync_method;
if (format_video_sync == VSYNC_AUTO) {
if(!strcmp(s->oformat->name, "avi")) {
format_video_sync = VSYNC_VFR;
} else
format_video_sync = (s->oformat->flags & AVFMT_VARIABLE_FPS) ? ((s->oformat->flags & AVFMT_NOTIMESTAMPS) ? VSYNC_PASSTHROUGH : VSYNC_VFR) : VSYNC_CFR;
if ( ist
&& format_video_sync == VSYNC_CFR
&& input_files[ist->file_index]->ctx->nb_streams == 1
&& input_files[ist->file_index]->input_ts_offset == 0) {
format_video_sync = VSYNC_VSCFR;
}
if (format_video_sync == VSYNC_CFR && copy_ts) {
format_video_sync = VSYNC_VSCFR;
}
}
if (delta0 < 0 &&
delta > 0 &&
format_video_sync != VSYNC_PASSTHROUGH &&
format_video_sync != VSYNC_DROP) {
double cor = FFMIN(-delta0, duration);
if (delta0 < -0.6) {
av_log(NULL, AV_LOG_WARNING, "Past duration %f too large\n", -delta0);
} else
av_log(NULL, AV_LOG_DEBUG, "Cliping frame in rate conversion by %f\n", -delta0);
sync_ipts += cor;
duration -= cor;
delta0 += cor;
}
switch (format_video_sync) {
case VSYNC_VSCFR:
if (ost->frame_number == 0 && delta - duration >= 0.5) {
av_log(NULL, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta - duration));
delta = duration;
delta0 = 0;
ost->sync_opts = lrint(sync_ipts);
}
case VSYNC_CFR:
// FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c
if (frame_drop_threshold && delta < frame_drop_threshold && ost->frame_number) {
nb_frames = 0;
} else if (delta < -1.1)
nb_frames = 0;
else if (delta > 1.1) {
nb_frames = lrintf(delta);
if (delta0 > 1.1)
nb0_frames = lrintf(delta0 - 0.6);
}
break;
case VSYNC_VFR:
if (delta <= -0.6)
nb_frames = 0;
else if (delta > 0.6)
ost->sync_opts = lrint(sync_ipts);
break;
case VSYNC_DROP:
case VSYNC_PASSTHROUGH:
ost->sync_opts = lrint(sync_ipts);
break;
default:
av_assert0(0);
}
}
nb_frames = FFMIN(nb_frames, ost->max_frames - ost->frame_number);
nb0_frames = FFMIN(nb0_frames, nb_frames);
memmove(ost->last_nb0_frames + 1,
ost->last_nb0_frames,
sizeof(ost->last_nb0_frames[0]) * (FF_ARRAY_ELEMS(ost->last_nb0_frames) - 1));
ost->last_nb0_frames[0] = nb0_frames;
if (nb0_frames == 0 && ost->last_droped) {
nb_frames_drop++;
av_log(NULL, AV_LOG_VERBOSE,
"*** dropping frame %d from stream %d at ts %"PRId64"\n",
ost->frame_number, ost->st->index, ost->last_frame->pts);
}
if (nb_frames > (nb0_frames && ost->last_droped) + (nb_frames > nb0_frames)) {
if (nb_frames > dts_error_threshold * 30) {
av_log(NULL, AV_LOG_ERROR, "%d frame duplication too large, skipping\n", nb_frames - 1);
nb_frames_drop++;
return;
}
nb_frames_dup += nb_frames - (nb0_frames && ost->last_droped) - (nb_frames > nb0_frames);
av_log(NULL, AV_LOG_VERBOSE, "*** %d dup!\n", nb_frames - 1);
}
ost->last_droped = nb_frames == nb0_frames && next_picture;
/* duplicates frame if needed */
for (i = 0; i < nb_frames; i++) {
AVFrame *in_picture;
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
if (i < nb0_frames && ost->last_frame) {
in_picture = ost->last_frame;
} else
in_picture = next_picture;
if (!in_picture)
return;
in_picture->pts = ost->sync_opts;
#if 1
if (!check_recording_time(ost))
#else
if (ost->frame_number >= ost->max_frames)
#endif
return;
if (s->oformat->flags & AVFMT_RAWPICTURE &&
enc->codec->id == AV_CODEC_ID_RAWVIDEO) {
/* raw pictures are written as AVPicture structure to
avoid any copies. We support temporarily the older
method. */
if (in_picture->interlaced_frame)
mux_enc->field_order = in_picture->top_field_first ? AV_FIELD_TB:AV_FIELD_BT;
else
mux_enc->field_order = AV_FIELD_PROGRESSIVE;
pkt.data = (uint8_t *)in_picture;
pkt.size = sizeof(AVPicture);
pkt.pts = av_rescale_q(in_picture->pts, enc->time_base, ost->st->time_base);
pkt.flags |= AV_PKT_FLAG_KEY;
write_frame(s, &pkt, ost);
} else {
int got_packet, forced_keyframe = 0;
double pts_time;
if (enc->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME) &&
ost->top_field_first >= 0)
in_picture->top_field_first = !!ost->top_field_first;
if (in_picture->interlaced_frame) {
if (enc->codec->id == AV_CODEC_ID_MJPEG)
mux_enc->field_order = in_picture->top_field_first ? AV_FIELD_TT:AV_FIELD_BB;
else
mux_enc->field_order = in_picture->top_field_first ? AV_FIELD_TB:AV_FIELD_BT;
} else
mux_enc->field_order = AV_FIELD_PROGRESSIVE;
in_picture->quality = enc->global_quality;
in_picture->pict_type = 0;
pts_time = in_picture->pts != AV_NOPTS_VALUE ?
in_picture->pts * av_q2d(enc->time_base) : NAN;
if (ost->forced_kf_index < ost->forced_kf_count &&
in_picture->pts >= ost->forced_kf_pts[ost->forced_kf_index]) {
ost->forced_kf_index++;
forced_keyframe = 1;
} else if (ost->forced_keyframes_pexpr) {
double res;
ost->forced_keyframes_expr_const_values[FKF_T] = pts_time;
res = av_expr_eval(ost->forced_keyframes_pexpr,
ost->forced_keyframes_expr_const_values, NULL);
av_dlog(NULL, "force_key_frame: n:%f n_forced:%f prev_forced_n:%f t:%f prev_forced_t:%f -> res:%f\n",
ost->forced_keyframes_expr_const_values[FKF_N],
ost->forced_keyframes_expr_const_values[FKF_N_FORCED],
ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N],
ost->forced_keyframes_expr_const_values[FKF_T],
ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T],
res);
if (res) {
forced_keyframe = 1;
ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N] =
ost->forced_keyframes_expr_const_values[FKF_N];
ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T] =
ost->forced_keyframes_expr_const_values[FKF_T];
ost->forced_keyframes_expr_const_values[FKF_N_FORCED] += 1;
}
ost->forced_keyframes_expr_const_values[FKF_N] += 1;
} else if ( ost->forced_keyframes
&& !strncmp(ost->forced_keyframes, "source", 6)
&& in_picture->key_frame==1) {
forced_keyframe = 1;
}
if (forced_keyframe) {
in_picture->pict_type = AV_PICTURE_TYPE_I;
av_log(NULL, AV_LOG_DEBUG, "Forced keyframe at time %f\n", pts_time);
}
update_benchmark(NULL);
if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "encoder <- type:video "
"frame_pts:%s frame_pts_time:%s time_base:%d/%d\n",
av_ts2str(in_picture->pts), av_ts2timestr(in_picture->pts, &enc->time_base),
enc->time_base.num, enc->time_base.den);
}
ost->frames_encoded++;
ret = avcodec_encode_video2(enc, &pkt, in_picture, &got_packet);
update_benchmark("encode_video %d.%d", ost->file_index, ost->index);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "Video encoding failed\n");
exit_program(1);
}
if (got_packet) {
if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "encoder -> type:video "
"pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &enc->time_base),
av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &enc->time_base));
}
if (pkt.pts == AV_NOPTS_VALUE && !(enc->codec->capabilities & CODEC_CAP_DELAY))
pkt.pts = ost->sync_opts;
av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base);
if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "encoder -> type:video "
"pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ost->st->time_base),
av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ost->st->time_base));
}
frame_size = pkt.size;
write_frame(s, &pkt, ost);
/* if two pass, output log */
if (ost->logfile && enc->stats_out) {
fprintf(ost->logfile, "%s", enc->stats_out);
}
}
}
ost->sync_opts++;
/*
* For video, number of frames in == number of packets out.
* But there may be reordering, so we can't throw away frames on encoder
* flush, we need to limit them here, before they go into encoder.
*/
ost->frame_number++;
if (vstats_filename && frame_size)
do_video_stats(ost, frame_size);
}
if (!ost->last_frame)
ost->last_frame = av_frame_alloc();
av_frame_unref(ost->last_frame);
if (next_picture)
av_frame_ref(ost->last_frame, next_picture);
else
av_frame_free(&ost->last_frame);
}
| true | FFmpeg | fd4c87fa3becaf8a6c480db915daf51e297b76c5 | static void do_video_out(AVFormatContext *s,
OutputStream *ost,
AVFrame *next_picture,
double sync_ipts)
{
int ret, format_video_sync;
AVPacket pkt;
AVCodecContext *enc = ost->enc_ctx;
AVCodecContext *mux_enc = ost->st->codec;
int nb_frames, nb0_frames, i;
double delta, delta0;
double duration = 0;
int frame_size = 0;
InputStream *ist = NULL;
AVFilterContext *filter = ost->filter->filter;
if (ost->source_index >= 0)
ist = input_streams[ost->source_index];
if (filter->inputs[0]->frame_rate.num > 0 &&
filter->inputs[0]->frame_rate.den > 0)
duration = 1/(av_q2d(filter->inputs[0]->frame_rate) * av_q2d(enc->time_base));
if(ist && ist->st->start_time != AV_NOPTS_VALUE && ist->st->first_dts != AV_NOPTS_VALUE && ost->frame_rate.num)
duration = FFMIN(duration, 1/(av_q2d(ost->frame_rate) * av_q2d(enc->time_base)));
if (!ost->filters_script &&
!ost->filters &&
next_picture &&
ist &&
lrintf(av_frame_get_pkt_duration(next_picture) * av_q2d(ist->st->time_base) / av_q2d(enc->time_base)) > 0) {
duration = lrintf(av_frame_get_pkt_duration(next_picture) * av_q2d(ist->st->time_base) / av_q2d(enc->time_base));
}
if (!next_picture) {
nb0_frames = nb_frames = mid_pred(ost->last_nb0_frames[0],
ost->last_nb0_frames[1],
ost->last_nb0_frames[2]);
} else {
delta0 = sync_ipts - ost->sync_opts;
delta = delta0 + duration;
nb0_frames = 0;
nb_frames = 1;
format_video_sync = video_sync_method;
if (format_video_sync == VSYNC_AUTO) {
if(!strcmp(s->oformat->name, "avi")) {
format_video_sync = VSYNC_VFR;
} else
format_video_sync = (s->oformat->flags & AVFMT_VARIABLE_FPS) ? ((s->oformat->flags & AVFMT_NOTIMESTAMPS) ? VSYNC_PASSTHROUGH : VSYNC_VFR) : VSYNC_CFR;
if ( ist
&& format_video_sync == VSYNC_CFR
&& input_files[ist->file_index]->ctx->nb_streams == 1
&& input_files[ist->file_index]->input_ts_offset == 0) {
format_video_sync = VSYNC_VSCFR;
}
if (format_video_sync == VSYNC_CFR && copy_ts) {
format_video_sync = VSYNC_VSCFR;
}
}
if (delta0 < 0 &&
delta > 0 &&
format_video_sync != VSYNC_PASSTHROUGH &&
format_video_sync != VSYNC_DROP) {
double cor = FFMIN(-delta0, duration);
if (delta0 < -0.6) {
av_log(NULL, AV_LOG_WARNING, "Past duration %f too large\n", -delta0);
} else
av_log(NULL, AV_LOG_DEBUG, "Cliping frame in rate conversion by %f\n", -delta0);
sync_ipts += cor;
duration -= cor;
delta0 += cor;
}
switch (format_video_sync) {
case VSYNC_VSCFR:
if (ost->frame_number == 0 && delta - duration >= 0.5) {
av_log(NULL, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta - duration));
delta = duration;
delta0 = 0;
ost->sync_opts = lrint(sync_ipts);
}
case VSYNC_CFR:
if (frame_drop_threshold && delta < frame_drop_threshold && ost->frame_number) {
nb_frames = 0;
} else if (delta < -1.1)
nb_frames = 0;
else if (delta > 1.1) {
nb_frames = lrintf(delta);
if (delta0 > 1.1)
nb0_frames = lrintf(delta0 - 0.6);
}
break;
case VSYNC_VFR:
if (delta <= -0.6)
nb_frames = 0;
else if (delta > 0.6)
ost->sync_opts = lrint(sync_ipts);
break;
case VSYNC_DROP:
case VSYNC_PASSTHROUGH:
ost->sync_opts = lrint(sync_ipts);
break;
default:
av_assert0(0);
}
}
nb_frames = FFMIN(nb_frames, ost->max_frames - ost->frame_number);
nb0_frames = FFMIN(nb0_frames, nb_frames);
memmove(ost->last_nb0_frames + 1,
ost->last_nb0_frames,
sizeof(ost->last_nb0_frames[0]) * (FF_ARRAY_ELEMS(ost->last_nb0_frames) - 1));
ost->last_nb0_frames[0] = nb0_frames;
if (nb0_frames == 0 && ost->last_droped) {
nb_frames_drop++;
av_log(NULL, AV_LOG_VERBOSE,
"*** dropping frame %d from stream %d at ts %"PRId64"\n",
ost->frame_number, ost->st->index, ost->last_frame->pts);
}
if (nb_frames > (nb0_frames && ost->last_droped) + (nb_frames > nb0_frames)) {
if (nb_frames > dts_error_threshold * 30) {
av_log(NULL, AV_LOG_ERROR, "%d frame duplication too large, skipping\n", nb_frames - 1);
nb_frames_drop++;
return;
}
nb_frames_dup += nb_frames - (nb0_frames && ost->last_droped) - (nb_frames > nb0_frames);
av_log(NULL, AV_LOG_VERBOSE, "*** %d dup!\n", nb_frames - 1);
}
ost->last_droped = nb_frames == nb0_frames && next_picture;
for (i = 0; i < nb_frames; i++) {
AVFrame *in_picture;
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
if (i < nb0_frames && ost->last_frame) {
in_picture = ost->last_frame;
} else
in_picture = next_picture;
if (!in_picture)
return;
in_picture->pts = ost->sync_opts;
#if 1
if (!check_recording_time(ost))
#else
if (ost->frame_number >= ost->max_frames)
#endif
return;
if (s->oformat->flags & AVFMT_RAWPICTURE &&
enc->codec->id == AV_CODEC_ID_RAWVIDEO) {
if (in_picture->interlaced_frame)
mux_enc->field_order = in_picture->top_field_first ? AV_FIELD_TB:AV_FIELD_BT;
else
mux_enc->field_order = AV_FIELD_PROGRESSIVE;
pkt.data = (uint8_t *)in_picture;
pkt.size = sizeof(AVPicture);
pkt.pts = av_rescale_q(in_picture->pts, enc->time_base, ost->st->time_base);
pkt.flags |= AV_PKT_FLAG_KEY;
write_frame(s, &pkt, ost);
} else {
int got_packet, forced_keyframe = 0;
double pts_time;
if (enc->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME) &&
ost->top_field_first >= 0)
in_picture->top_field_first = !!ost->top_field_first;
if (in_picture->interlaced_frame) {
if (enc->codec->id == AV_CODEC_ID_MJPEG)
mux_enc->field_order = in_picture->top_field_first ? AV_FIELD_TT:AV_FIELD_BB;
else
mux_enc->field_order = in_picture->top_field_first ? AV_FIELD_TB:AV_FIELD_BT;
} else
mux_enc->field_order = AV_FIELD_PROGRESSIVE;
in_picture->quality = enc->global_quality;
in_picture->pict_type = 0;
pts_time = in_picture->pts != AV_NOPTS_VALUE ?
in_picture->pts * av_q2d(enc->time_base) : NAN;
if (ost->forced_kf_index < ost->forced_kf_count &&
in_picture->pts >= ost->forced_kf_pts[ost->forced_kf_index]) {
ost->forced_kf_index++;
forced_keyframe = 1;
} else if (ost->forced_keyframes_pexpr) {
double res;
ost->forced_keyframes_expr_const_values[FKF_T] = pts_time;
res = av_expr_eval(ost->forced_keyframes_pexpr,
ost->forced_keyframes_expr_const_values, NULL);
av_dlog(NULL, "force_key_frame: n:%f n_forced:%f prev_forced_n:%f t:%f prev_forced_t:%f -> res:%f\n",
ost->forced_keyframes_expr_const_values[FKF_N],
ost->forced_keyframes_expr_const_values[FKF_N_FORCED],
ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N],
ost->forced_keyframes_expr_const_values[FKF_T],
ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T],
res);
if (res) {
forced_keyframe = 1;
ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N] =
ost->forced_keyframes_expr_const_values[FKF_N];
ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T] =
ost->forced_keyframes_expr_const_values[FKF_T];
ost->forced_keyframes_expr_const_values[FKF_N_FORCED] += 1;
}
ost->forced_keyframes_expr_const_values[FKF_N] += 1;
} else if ( ost->forced_keyframes
&& !strncmp(ost->forced_keyframes, "source", 6)
&& in_picture->key_frame==1) {
forced_keyframe = 1;
}
if (forced_keyframe) {
in_picture->pict_type = AV_PICTURE_TYPE_I;
av_log(NULL, AV_LOG_DEBUG, "Forced keyframe at time %f\n", pts_time);
}
update_benchmark(NULL);
if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "encoder <- type:video "
"frame_pts:%s frame_pts_time:%s time_base:%d/%d\n",
av_ts2str(in_picture->pts), av_ts2timestr(in_picture->pts, &enc->time_base),
enc->time_base.num, enc->time_base.den);
}
ost->frames_encoded++;
ret = avcodec_encode_video2(enc, &pkt, in_picture, &got_packet);
update_benchmark("encode_video %d.%d", ost->file_index, ost->index);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "Video encoding failed\n");
exit_program(1);
}
if (got_packet) {
if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "encoder -> type:video "
"pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &enc->time_base),
av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &enc->time_base));
}
if (pkt.pts == AV_NOPTS_VALUE && !(enc->codec->capabilities & CODEC_CAP_DELAY))
pkt.pts = ost->sync_opts;
av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base);
if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "encoder -> type:video "
"pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ost->st->time_base),
av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ost->st->time_base));
}
frame_size = pkt.size;
write_frame(s, &pkt, ost);
if (ost->logfile && enc->stats_out) {
fprintf(ost->logfile, "%s", enc->stats_out);
}
}
}
ost->sync_opts++;
ost->frame_number++;
if (vstats_filename && frame_size)
do_video_stats(ost, frame_size);
}
if (!ost->last_frame)
ost->last_frame = av_frame_alloc();
av_frame_unref(ost->last_frame);
if (next_picture)
av_frame_ref(ost->last_frame, next_picture);
else
av_frame_free(&ost->last_frame);
}
| {
"code": [
" if (next_picture)"
],
"line_no": [
593
]
} | static void FUNC_0(AVFormatContext *VAR_0,
OutputStream *VAR_1,
AVFrame *VAR_2,
double VAR_3)
{
int VAR_4, VAR_5;
AVPacket pkt;
AVCodecContext *enc = VAR_1->enc_ctx;
AVCodecContext *mux_enc = VAR_1->st->codec;
int VAR_6, VAR_7, VAR_8;
double VAR_9, VAR_10;
double VAR_11 = 0;
int VAR_12 = 0;
InputStream *ist = NULL;
AVFilterContext *filter = VAR_1->filter->filter;
if (VAR_1->source_index >= 0)
ist = input_streams[VAR_1->source_index];
if (filter->inputs[0]->frame_rate.num > 0 &&
filter->inputs[0]->frame_rate.den > 0)
VAR_11 = 1/(av_q2d(filter->inputs[0]->frame_rate) * av_q2d(enc->time_base));
if(ist && ist->st->start_time != AV_NOPTS_VALUE && ist->st->first_dts != AV_NOPTS_VALUE && VAR_1->frame_rate.num)
VAR_11 = FFMIN(VAR_11, 1/(av_q2d(VAR_1->frame_rate) * av_q2d(enc->time_base)));
if (!VAR_1->filters_script &&
!VAR_1->filters &&
VAR_2 &&
ist &&
lrintf(av_frame_get_pkt_duration(VAR_2) * av_q2d(ist->st->time_base) / av_q2d(enc->time_base)) > 0) {
VAR_11 = lrintf(av_frame_get_pkt_duration(VAR_2) * av_q2d(ist->st->time_base) / av_q2d(enc->time_base));
}
if (!VAR_2) {
VAR_7 = VAR_6 = mid_pred(VAR_1->last_nb0_frames[0],
VAR_1->last_nb0_frames[1],
VAR_1->last_nb0_frames[2]);
} else {
VAR_10 = VAR_3 - VAR_1->sync_opts;
VAR_9 = VAR_10 + VAR_11;
VAR_7 = 0;
VAR_6 = 1;
VAR_5 = video_sync_method;
if (VAR_5 == VSYNC_AUTO) {
if(!strcmp(VAR_0->oformat->name, "avi")) {
VAR_5 = VSYNC_VFR;
} else
VAR_5 = (VAR_0->oformat->flags & AVFMT_VARIABLE_FPS) ? ((VAR_0->oformat->flags & AVFMT_NOTIMESTAMPS) ? VSYNC_PASSTHROUGH : VSYNC_VFR) : VSYNC_CFR;
if ( ist
&& VAR_5 == VSYNC_CFR
&& input_files[ist->file_index]->ctx->nb_streams == 1
&& input_files[ist->file_index]->input_ts_offset == 0) {
VAR_5 = VSYNC_VSCFR;
}
if (VAR_5 == VSYNC_CFR && copy_ts) {
VAR_5 = VSYNC_VSCFR;
}
}
if (VAR_10 < 0 &&
VAR_9 > 0 &&
VAR_5 != VSYNC_PASSTHROUGH &&
VAR_5 != VSYNC_DROP) {
double VAR_13 = FFMIN(-VAR_10, VAR_11);
if (VAR_10 < -0.6) {
av_log(NULL, AV_LOG_WARNING, "Past VAR_11 %f too large\n", -VAR_10);
} else
av_log(NULL, AV_LOG_DEBUG, "Cliping frame in rate conversion by %f\n", -VAR_10);
VAR_3 += VAR_13;
VAR_11 -= VAR_13;
VAR_10 += VAR_13;
}
switch (VAR_5) {
case VSYNC_VSCFR:
if (VAR_1->frame_number == 0 && VAR_9 - VAR_11 >= 0.5) {
av_log(NULL, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(VAR_9 - VAR_11));
VAR_9 = VAR_11;
VAR_10 = 0;
VAR_1->sync_opts = lrint(VAR_3);
}
case VSYNC_CFR:
if (frame_drop_threshold && VAR_9 < frame_drop_threshold && VAR_1->frame_number) {
VAR_6 = 0;
} else if (VAR_9 < -1.1)
VAR_6 = 0;
else if (VAR_9 > 1.1) {
VAR_6 = lrintf(VAR_9);
if (VAR_10 > 1.1)
VAR_7 = lrintf(VAR_10 - 0.6);
}
break;
case VSYNC_VFR:
if (VAR_9 <= -0.6)
VAR_6 = 0;
else if (VAR_9 > 0.6)
VAR_1->sync_opts = lrint(VAR_3);
break;
case VSYNC_DROP:
case VSYNC_PASSTHROUGH:
VAR_1->sync_opts = lrint(VAR_3);
break;
default:
av_assert0(0);
}
}
VAR_6 = FFMIN(VAR_6, VAR_1->max_frames - VAR_1->frame_number);
VAR_7 = FFMIN(VAR_7, VAR_6);
memmove(VAR_1->last_nb0_frames + 1,
VAR_1->last_nb0_frames,
sizeof(VAR_1->last_nb0_frames[0]) * (FF_ARRAY_ELEMS(VAR_1->last_nb0_frames) - 1));
VAR_1->last_nb0_frames[0] = VAR_7;
if (VAR_7 == 0 && VAR_1->last_droped) {
nb_frames_drop++;
av_log(NULL, AV_LOG_VERBOSE,
"*** dropping frame %d from stream %d at ts %"PRId64"\n",
VAR_1->frame_number, VAR_1->st->index, VAR_1->last_frame->pts);
}
if (VAR_6 > (VAR_7 && VAR_1->last_droped) + (VAR_6 > VAR_7)) {
if (VAR_6 > dts_error_threshold * 30) {
av_log(NULL, AV_LOG_ERROR, "%d frame duplication too large, skipping\n", VAR_6 - 1);
nb_frames_drop++;
return;
}
nb_frames_dup += VAR_6 - (VAR_7 && VAR_1->last_droped) - (VAR_6 > VAR_7);
av_log(NULL, AV_LOG_VERBOSE, "*** %d dup!\n", VAR_6 - 1);
}
VAR_1->last_droped = VAR_6 == VAR_7 && VAR_2;
for (VAR_8 = 0; VAR_8 < VAR_6; VAR_8++) {
AVFrame *in_picture;
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
if (VAR_8 < VAR_7 && VAR_1->last_frame) {
in_picture = VAR_1->last_frame;
} else
in_picture = VAR_2;
if (!in_picture)
return;
in_picture->pts = VAR_1->sync_opts;
#if 1
if (!check_recording_time(VAR_1))
#else
if (VAR_1->frame_number >= VAR_1->max_frames)
#endif
return;
if (VAR_0->oformat->flags & AVFMT_RAWPICTURE &&
enc->codec->id == AV_CODEC_ID_RAWVIDEO) {
if (in_picture->interlaced_frame)
mux_enc->field_order = in_picture->top_field_first ? AV_FIELD_TB:AV_FIELD_BT;
else
mux_enc->field_order = AV_FIELD_PROGRESSIVE;
pkt.data = (uint8_t *)in_picture;
pkt.size = sizeof(AVPicture);
pkt.pts = av_rescale_q(in_picture->pts, enc->time_base, VAR_1->st->time_base);
pkt.flags |= AV_PKT_FLAG_KEY;
write_frame(VAR_0, &pkt, VAR_1);
} else {
int VAR_14, VAR_15 = 0;
double VAR_16;
if (enc->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME) &&
VAR_1->top_field_first >= 0)
in_picture->top_field_first = !!VAR_1->top_field_first;
if (in_picture->interlaced_frame) {
if (enc->codec->id == AV_CODEC_ID_MJPEG)
mux_enc->field_order = in_picture->top_field_first ? AV_FIELD_TT:AV_FIELD_BB;
else
mux_enc->field_order = in_picture->top_field_first ? AV_FIELD_TB:AV_FIELD_BT;
} else
mux_enc->field_order = AV_FIELD_PROGRESSIVE;
in_picture->quality = enc->global_quality;
in_picture->pict_type = 0;
VAR_16 = in_picture->pts != AV_NOPTS_VALUE ?
in_picture->pts * av_q2d(enc->time_base) : NAN;
if (VAR_1->forced_kf_index < VAR_1->forced_kf_count &&
in_picture->pts >= VAR_1->forced_kf_pts[VAR_1->forced_kf_index]) {
VAR_1->forced_kf_index++;
VAR_15 = 1;
} else if (VAR_1->forced_keyframes_pexpr) {
double VAR_17;
VAR_1->forced_keyframes_expr_const_values[FKF_T] = VAR_16;
VAR_17 = av_expr_eval(VAR_1->forced_keyframes_pexpr,
VAR_1->forced_keyframes_expr_const_values, NULL);
av_dlog(NULL, "force_key_frame: n:%f n_forced:%f prev_forced_n:%f t:%f prev_forced_t:%f -> VAR_17:%f\n",
VAR_1->forced_keyframes_expr_const_values[FKF_N],
VAR_1->forced_keyframes_expr_const_values[FKF_N_FORCED],
VAR_1->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N],
VAR_1->forced_keyframes_expr_const_values[FKF_T],
VAR_1->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T],
VAR_17);
if (VAR_17) {
VAR_15 = 1;
VAR_1->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N] =
VAR_1->forced_keyframes_expr_const_values[FKF_N];
VAR_1->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T] =
VAR_1->forced_keyframes_expr_const_values[FKF_T];
VAR_1->forced_keyframes_expr_const_values[FKF_N_FORCED] += 1;
}
VAR_1->forced_keyframes_expr_const_values[FKF_N] += 1;
} else if ( VAR_1->forced_keyframes
&& !strncmp(VAR_1->forced_keyframes, "source", 6)
&& in_picture->key_frame==1) {
VAR_15 = 1;
}
if (VAR_15) {
in_picture->pict_type = AV_PICTURE_TYPE_I;
av_log(NULL, AV_LOG_DEBUG, "Forced keyframe at time %f\n", VAR_16);
}
update_benchmark(NULL);
if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "encoder <- type:video "
"frame_pts:%VAR_0 frame_pts_time:%VAR_0 time_base:%d/%d\n",
av_ts2str(in_picture->pts), av_ts2timestr(in_picture->pts, &enc->time_base),
enc->time_base.num, enc->time_base.den);
}
VAR_1->frames_encoded++;
VAR_4 = avcodec_encode_video2(enc, &pkt, in_picture, &VAR_14);
update_benchmark("encode_video %d.%d", VAR_1->file_index, VAR_1->index);
if (VAR_4 < 0) {
av_log(NULL, AV_LOG_FATAL, "Video encoding failed\n");
exit_program(1);
}
if (VAR_14) {
if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "encoder -> type:video "
"pkt_pts:%VAR_0 pkt_pts_time:%VAR_0 pkt_dts:%VAR_0 pkt_dts_time:%VAR_0\n",
av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &enc->time_base),
av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &enc->time_base));
}
if (pkt.pts == AV_NOPTS_VALUE && !(enc->codec->capabilities & CODEC_CAP_DELAY))
pkt.pts = VAR_1->sync_opts;
av_packet_rescale_ts(&pkt, enc->time_base, VAR_1->st->time_base);
if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "encoder -> type:video "
"pkt_pts:%VAR_0 pkt_pts_time:%VAR_0 pkt_dts:%VAR_0 pkt_dts_time:%VAR_0\n",
av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &VAR_1->st->time_base),
av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &VAR_1->st->time_base));
}
VAR_12 = pkt.size;
write_frame(VAR_0, &pkt, VAR_1);
if (VAR_1->logfile && enc->stats_out) {
fprintf(VAR_1->logfile, "%VAR_0", enc->stats_out);
}
}
}
VAR_1->sync_opts++;
VAR_1->frame_number++;
if (vstats_filename && VAR_12)
do_video_stats(VAR_1, VAR_12);
}
if (!VAR_1->last_frame)
VAR_1->last_frame = av_frame_alloc();
av_frame_unref(VAR_1->last_frame);
if (VAR_2)
av_frame_ref(VAR_1->last_frame, VAR_2);
else
av_frame_free(&VAR_1->last_frame);
}
| [
"static void FUNC_0(AVFormatContext *VAR_0,\nOutputStream *VAR_1,\nAVFrame *VAR_2,\ndouble VAR_3)\n{",
"int VAR_4, VAR_5;",
"AVPacket pkt;",
"AVCodecContext *enc = VAR_1->enc_ctx;",
"AVCodecContext *mux_enc = VAR_1->st->codec;",
"int VAR_6, VAR_7, VAR_8;",
"double VAR_9, VAR_10;",
"double VAR_11 = 0;",
"int VAR_12 = 0;",
"InputStream *ist = NULL;",
"AVFilterContext *filter = VAR_1->filter->filter;",
"if (VAR_1->source_index >= 0)\nist = input_streams[VAR_1->source_index];",
"if (filter->inputs[0]->frame_rate.num > 0 &&\nfilter->inputs[0]->frame_rate.den > 0)\nVAR_11 = 1/(av_q2d(filter->inputs[0]->frame_rate) * av_q2d(enc->time_base));",
"if(ist && ist->st->start_time != AV_NOPTS_VALUE && ist->st->first_dts != AV_NOPTS_VALUE && VAR_1->frame_rate.num)\nVAR_11 = FFMIN(VAR_11, 1/(av_q2d(VAR_1->frame_rate) * av_q2d(enc->time_base)));",
"if (!VAR_1->filters_script &&\n!VAR_1->filters &&\nVAR_2 &&\nist &&\nlrintf(av_frame_get_pkt_duration(VAR_2) * av_q2d(ist->st->time_base) / av_q2d(enc->time_base)) > 0) {",
"VAR_11 = lrintf(av_frame_get_pkt_duration(VAR_2) * av_q2d(ist->st->time_base) / av_q2d(enc->time_base));",
"}",
"if (!VAR_2) {",
"VAR_7 = VAR_6 = mid_pred(VAR_1->last_nb0_frames[0],\nVAR_1->last_nb0_frames[1],\nVAR_1->last_nb0_frames[2]);",
"} else {",
"VAR_10 = VAR_3 - VAR_1->sync_opts;",
"VAR_9 = VAR_10 + VAR_11;",
"VAR_7 = 0;",
"VAR_6 = 1;",
"VAR_5 = video_sync_method;",
"if (VAR_5 == VSYNC_AUTO) {",
"if(!strcmp(VAR_0->oformat->name, \"avi\")) {",
"VAR_5 = VSYNC_VFR;",
"} else",
"VAR_5 = (VAR_0->oformat->flags & AVFMT_VARIABLE_FPS) ? ((VAR_0->oformat->flags & AVFMT_NOTIMESTAMPS) ? VSYNC_PASSTHROUGH : VSYNC_VFR) : VSYNC_CFR;",
"if ( ist\n&& VAR_5 == VSYNC_CFR\n&& input_files[ist->file_index]->ctx->nb_streams == 1\n&& input_files[ist->file_index]->input_ts_offset == 0) {",
"VAR_5 = VSYNC_VSCFR;",
"}",
"if (VAR_5 == VSYNC_CFR && copy_ts) {",
"VAR_5 = VSYNC_VSCFR;",
"}",
"}",
"if (VAR_10 < 0 &&\nVAR_9 > 0 &&\nVAR_5 != VSYNC_PASSTHROUGH &&\nVAR_5 != VSYNC_DROP) {",
"double VAR_13 = FFMIN(-VAR_10, VAR_11);",
"if (VAR_10 < -0.6) {",
"av_log(NULL, AV_LOG_WARNING, \"Past VAR_11 %f too large\\n\", -VAR_10);",
"} else",
"av_log(NULL, AV_LOG_DEBUG, \"Cliping frame in rate conversion by %f\\n\", -VAR_10);",
"VAR_3 += VAR_13;",
"VAR_11 -= VAR_13;",
"VAR_10 += VAR_13;",
"}",
"switch (VAR_5) {",
"case VSYNC_VSCFR:\nif (VAR_1->frame_number == 0 && VAR_9 - VAR_11 >= 0.5) {",
"av_log(NULL, AV_LOG_DEBUG, \"Not duplicating %d initial frames\\n\", (int)lrintf(VAR_9 - VAR_11));",
"VAR_9 = VAR_11;",
"VAR_10 = 0;",
"VAR_1->sync_opts = lrint(VAR_3);",
"}",
"case VSYNC_CFR:\nif (frame_drop_threshold && VAR_9 < frame_drop_threshold && VAR_1->frame_number) {",
"VAR_6 = 0;",
"} else if (VAR_9 < -1.1)",
"VAR_6 = 0;",
"else if (VAR_9 > 1.1) {",
"VAR_6 = lrintf(VAR_9);",
"if (VAR_10 > 1.1)\nVAR_7 = lrintf(VAR_10 - 0.6);",
"}",
"break;",
"case VSYNC_VFR:\nif (VAR_9 <= -0.6)\nVAR_6 = 0;",
"else if (VAR_9 > 0.6)\nVAR_1->sync_opts = lrint(VAR_3);",
"break;",
"case VSYNC_DROP:\ncase VSYNC_PASSTHROUGH:\nVAR_1->sync_opts = lrint(VAR_3);",
"break;",
"default:\nav_assert0(0);",
"}",
"}",
"VAR_6 = FFMIN(VAR_6, VAR_1->max_frames - VAR_1->frame_number);",
"VAR_7 = FFMIN(VAR_7, VAR_6);",
"memmove(VAR_1->last_nb0_frames + 1,\nVAR_1->last_nb0_frames,\nsizeof(VAR_1->last_nb0_frames[0]) * (FF_ARRAY_ELEMS(VAR_1->last_nb0_frames) - 1));",
"VAR_1->last_nb0_frames[0] = VAR_7;",
"if (VAR_7 == 0 && VAR_1->last_droped) {",
"nb_frames_drop++;",
"av_log(NULL, AV_LOG_VERBOSE,\n\"*** dropping frame %d from stream %d at ts %\"PRId64\"\\n\",\nVAR_1->frame_number, VAR_1->st->index, VAR_1->last_frame->pts);",
"}",
"if (VAR_6 > (VAR_7 && VAR_1->last_droped) + (VAR_6 > VAR_7)) {",
"if (VAR_6 > dts_error_threshold * 30) {",
"av_log(NULL, AV_LOG_ERROR, \"%d frame duplication too large, skipping\\n\", VAR_6 - 1);",
"nb_frames_drop++;",
"return;",
"}",
"nb_frames_dup += VAR_6 - (VAR_7 && VAR_1->last_droped) - (VAR_6 > VAR_7);",
"av_log(NULL, AV_LOG_VERBOSE, \"*** %d dup!\\n\", VAR_6 - 1);",
"}",
"VAR_1->last_droped = VAR_6 == VAR_7 && VAR_2;",
"for (VAR_8 = 0; VAR_8 < VAR_6; VAR_8++) {",
"AVFrame *in_picture;",
"av_init_packet(&pkt);",
"pkt.data = NULL;",
"pkt.size = 0;",
"if (VAR_8 < VAR_7 && VAR_1->last_frame) {",
"in_picture = VAR_1->last_frame;",
"} else",
"in_picture = VAR_2;",
"if (!in_picture)\nreturn;",
"in_picture->pts = VAR_1->sync_opts;",
"#if 1\nif (!check_recording_time(VAR_1))\n#else\nif (VAR_1->frame_number >= VAR_1->max_frames)\n#endif\nreturn;",
"if (VAR_0->oformat->flags & AVFMT_RAWPICTURE &&\nenc->codec->id == AV_CODEC_ID_RAWVIDEO) {",
"if (in_picture->interlaced_frame)\nmux_enc->field_order = in_picture->top_field_first ? AV_FIELD_TB:AV_FIELD_BT;",
"else\nmux_enc->field_order = AV_FIELD_PROGRESSIVE;",
"pkt.data = (uint8_t *)in_picture;",
"pkt.size = sizeof(AVPicture);",
"pkt.pts = av_rescale_q(in_picture->pts, enc->time_base, VAR_1->st->time_base);",
"pkt.flags |= AV_PKT_FLAG_KEY;",
"write_frame(VAR_0, &pkt, VAR_1);",
"} else {",
"int VAR_14, VAR_15 = 0;",
"double VAR_16;",
"if (enc->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME) &&\nVAR_1->top_field_first >= 0)\nin_picture->top_field_first = !!VAR_1->top_field_first;",
"if (in_picture->interlaced_frame) {",
"if (enc->codec->id == AV_CODEC_ID_MJPEG)\nmux_enc->field_order = in_picture->top_field_first ? AV_FIELD_TT:AV_FIELD_BB;",
"else\nmux_enc->field_order = in_picture->top_field_first ? AV_FIELD_TB:AV_FIELD_BT;",
"} else",
"mux_enc->field_order = AV_FIELD_PROGRESSIVE;",
"in_picture->quality = enc->global_quality;",
"in_picture->pict_type = 0;",
"VAR_16 = in_picture->pts != AV_NOPTS_VALUE ?\nin_picture->pts * av_q2d(enc->time_base) : NAN;",
"if (VAR_1->forced_kf_index < VAR_1->forced_kf_count &&\nin_picture->pts >= VAR_1->forced_kf_pts[VAR_1->forced_kf_index]) {",
"VAR_1->forced_kf_index++;",
"VAR_15 = 1;",
"} else if (VAR_1->forced_keyframes_pexpr) {",
"double VAR_17;",
"VAR_1->forced_keyframes_expr_const_values[FKF_T] = VAR_16;",
"VAR_17 = av_expr_eval(VAR_1->forced_keyframes_pexpr,\nVAR_1->forced_keyframes_expr_const_values, NULL);",
"av_dlog(NULL, \"force_key_frame: n:%f n_forced:%f prev_forced_n:%f t:%f prev_forced_t:%f -> VAR_17:%f\\n\",\nVAR_1->forced_keyframes_expr_const_values[FKF_N],\nVAR_1->forced_keyframes_expr_const_values[FKF_N_FORCED],\nVAR_1->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N],\nVAR_1->forced_keyframes_expr_const_values[FKF_T],\nVAR_1->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T],\nVAR_17);",
"if (VAR_17) {",
"VAR_15 = 1;",
"VAR_1->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N] =\nVAR_1->forced_keyframes_expr_const_values[FKF_N];",
"VAR_1->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T] =\nVAR_1->forced_keyframes_expr_const_values[FKF_T];",
"VAR_1->forced_keyframes_expr_const_values[FKF_N_FORCED] += 1;",
"}",
"VAR_1->forced_keyframes_expr_const_values[FKF_N] += 1;",
"} else if ( VAR_1->forced_keyframes",
"&& !strncmp(VAR_1->forced_keyframes, \"source\", 6)\n&& in_picture->key_frame==1) {",
"VAR_15 = 1;",
"}",
"if (VAR_15) {",
"in_picture->pict_type = AV_PICTURE_TYPE_I;",
"av_log(NULL, AV_LOG_DEBUG, \"Forced keyframe at time %f\\n\", VAR_16);",
"}",
"update_benchmark(NULL);",
"if (debug_ts) {",
"av_log(NULL, AV_LOG_INFO, \"encoder <- type:video \"\n\"frame_pts:%VAR_0 frame_pts_time:%VAR_0 time_base:%d/%d\\n\",\nav_ts2str(in_picture->pts), av_ts2timestr(in_picture->pts, &enc->time_base),\nenc->time_base.num, enc->time_base.den);",
"}",
"VAR_1->frames_encoded++;",
"VAR_4 = avcodec_encode_video2(enc, &pkt, in_picture, &VAR_14);",
"update_benchmark(\"encode_video %d.%d\", VAR_1->file_index, VAR_1->index);",
"if (VAR_4 < 0) {",
"av_log(NULL, AV_LOG_FATAL, \"Video encoding failed\\n\");",
"exit_program(1);",
"}",
"if (VAR_14) {",
"if (debug_ts) {",
"av_log(NULL, AV_LOG_INFO, \"encoder -> type:video \"\n\"pkt_pts:%VAR_0 pkt_pts_time:%VAR_0 pkt_dts:%VAR_0 pkt_dts_time:%VAR_0\\n\",\nav_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &enc->time_base),\nav_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &enc->time_base));",
"}",
"if (pkt.pts == AV_NOPTS_VALUE && !(enc->codec->capabilities & CODEC_CAP_DELAY))\npkt.pts = VAR_1->sync_opts;",
"av_packet_rescale_ts(&pkt, enc->time_base, VAR_1->st->time_base);",
"if (debug_ts) {",
"av_log(NULL, AV_LOG_INFO, \"encoder -> type:video \"\n\"pkt_pts:%VAR_0 pkt_pts_time:%VAR_0 pkt_dts:%VAR_0 pkt_dts_time:%VAR_0\\n\",\nav_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &VAR_1->st->time_base),\nav_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &VAR_1->st->time_base));",
"}",
"VAR_12 = pkt.size;",
"write_frame(VAR_0, &pkt, VAR_1);",
"if (VAR_1->logfile && enc->stats_out) {",
"fprintf(VAR_1->logfile, \"%VAR_0\", enc->stats_out);",
"}",
"}",
"}",
"VAR_1->sync_opts++;",
"VAR_1->frame_number++;",
"if (vstats_filename && VAR_12)\ndo_video_stats(VAR_1, VAR_12);",
"}",
"if (!VAR_1->last_frame)\nVAR_1->last_frame = av_frame_alloc();",
"av_frame_unref(VAR_1->last_frame);",
"if (VAR_2)\nav_frame_ref(VAR_1->last_frame, VAR_2);",
"else\nav_frame_free(&VAR_1->last_frame);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33,
35
],
[
39,
41,
43
],
[
47,
49
],
[
53,
55,
57,
59,
61
],
[
63
],
[
65
],
[
69
],
[
73,
75,
77
],
[
79
],
[
81
],
[
83
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107,
109,
111,
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129,
131,
133,
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
157
],
[
159,
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173,
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189,
191
],
[
193
],
[
195
],
[
197,
199,
201
],
[
203,
205
],
[
207
],
[
209,
211,
213
],
[
215
],
[
217,
219
],
[
221
],
[
223
],
[
227
],
[
229
],
[
233,
235,
237
],
[
239
],
[
243
],
[
245
],
[
247,
249,
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
291
],
[
293
],
[
295
],
[
297
],
[
301,
303
],
[
307
],
[
311,
313,
315,
317,
319,
321
],
[
325,
327
],
[
335,
337
],
[
339,
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
353
],
[
355
],
[
357
],
[
359
],
[
363,
365,
367
],
[
371
],
[
373,
375
],
[
377,
379
],
[
381
],
[
383
],
[
387
],
[
389
],
[
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
],
[
447
],
[
449
],
[
451,
453
],
[
455
],
[
457
],
[
461
],
[
463
],
[
465
],
[
467
],
[
471
],
[
473
],
[
475,
477,
479,
481
],
[
483
],
[
487
],
[
491
],
[
493
],
[
495
],
[
497
],
[
499
],
[
501
],
[
505
],
[
507
],
[
509,
511,
513,
515
],
[
517
],
[
521,
523
],
[
527
],
[
531
],
[
533,
535,
537,
539
],
[
541
],
[
545
],
[
547
],
[
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
563
],
[
575
],
[
579,
581
],
[
583
],
[
587,
589
],
[
591
],
[
593,
595
],
[
597,
599
],
[
601
]
] |
24,537 | static int read_header(AVFormatContext *s)
{
BRSTMDemuxContext *b = s->priv_data;
int bom, major, minor, codec, chunk;
int64_t h1offset, pos, toffset;
uint32_t size, asize, start = 0;
AVStream *st;
int ret = AVERROR_EOF;
int loop = 0;
int bfstm = !strcmp("bfstm", s->iformat->name);
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
avio_skip(s->pb, 4);
bom = avio_rb16(s->pb);
if (bom != 0xFEFF && bom != 0xFFFE) {
av_log(s, AV_LOG_ERROR, "invalid byte order: %X\n", bom);
return AVERROR_INVALIDDATA;
}
if (bom == 0xFFFE)
b->little_endian = 1;
if (!bfstm) {
major = avio_r8(s->pb);
minor = avio_r8(s->pb);
avio_skip(s->pb, 4); // size of file
size = read16(s);
if (size < 14)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, size - 14);
pos = avio_tell(s->pb);
if (avio_rl32(s->pb) != MKTAG('H','E','A','D'))
return AVERROR_INVALIDDATA;
} else {
uint32_t info_offset = 0;
uint16_t section_count, header_size, i;
header_size = read16(s); // 6
avio_skip(s->pb, 4); // Unknown constant 0x00030000
avio_skip(s->pb, 4); // size of file
section_count = read16(s);
avio_skip(s->pb, 2); // padding
for (i = 0; avio_tell(s->pb) < header_size
&& !(start && info_offset)
&& i < section_count; i++) {
uint16_t flag = read16(s);
avio_skip(s->pb, 2);
switch (flag) {
case 0x4000:
info_offset = read32(s);
/*info_size =*/ read32(s);
break;
case 0x4001:
avio_skip(s->pb, 4); // seek offset
avio_skip(s->pb, 4); // seek size
break;
case 0x4002:
start = read32(s) + 8;
avio_skip(s->pb, 4); //data_size = read32(s);
break;
case 0x4003:
avio_skip(s->pb, 4); // REGN offset
avio_skip(s->pb, 4); // REGN size
break;
}
}
if (!info_offset || !start)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, info_offset - avio_tell(s->pb));
pos = avio_tell(s->pb);
if (avio_rl32(s->pb) != MKTAG('I','N','F','O'))
return AVERROR_INVALIDDATA;
}
size = read32(s);
if (size < 192)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, 4); // unknown
h1offset = read32(s);
if (h1offset > size)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, 12);
toffset = read32(s) + 16LL;
if (toffset > size)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, pos + h1offset + 8 - avio_tell(s->pb));
codec = avio_r8(s->pb);
switch (codec) {
case 0: codec = AV_CODEC_ID_PCM_S8_PLANAR; break;
case 1: codec = b->little_endian ?
AV_CODEC_ID_PCM_S16LE_PLANAR :
AV_CODEC_ID_PCM_S16BE_PLANAR; break;
case 2: codec = b->little_endian ?
AV_CODEC_ID_ADPCM_THP_LE :
AV_CODEC_ID_ADPCM_THP; break;
default:
avpriv_request_sample(s, "codec %d", codec);
return AVERROR_PATCHWELCOME;
}
loop = avio_r8(s->pb); // loop flag
st->codec->codec_id = codec;
st->codec->channels = avio_r8(s->pb);
if (!st->codec->channels)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, 1); // padding
st->codec->sample_rate = bfstm ? read32(s) : read16(s);
if (!st->codec->sample_rate)
return AVERROR_INVALIDDATA;
if (!bfstm)
avio_skip(s->pb, 2); // padding
if (loop) {
if (av_dict_set_int(&s->metadata, "loop_start",
av_rescale(read32(s), AV_TIME_BASE,
st->codec->sample_rate),
0) < 0)
return AVERROR(ENOMEM);
} else {
avio_skip(s->pb, 4);
}
st->start_time = 0;
st->duration = read32(s);
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
if (!bfstm)
start = read32(s);
b->current_block = 0;
b->block_count = read32(s);
if (b->block_count > UINT16_MAX) {
av_log(s, AV_LOG_WARNING, "too many blocks: %u\n", b->block_count);
return AVERROR_INVALIDDATA;
}
b->block_size = read32(s);
if (b->block_size > UINT32_MAX / st->codec->channels)
return AVERROR_INVALIDDATA;
b->samples_per_block = read32(s);
b->last_block_used_bytes = read32(s);
b->last_block_samples = read32(s);
b->last_block_size = read32(s);
if (b->last_block_size > UINT32_MAX / st->codec->channels)
return AVERROR_INVALIDDATA;
if (b->last_block_used_bytes > b->last_block_size)
return AVERROR_INVALIDDATA;
if (codec == AV_CODEC_ID_ADPCM_THP || codec == AV_CODEC_ID_ADPCM_THP_LE) {
int ch;
avio_skip(s->pb, pos + toffset - avio_tell(s->pb));
if (!bfstm)
toffset = read32(s) + 16LL;
else
toffset = toffset + read32(s) + st->codec->channels * 8 - 8;
if (toffset > size)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, pos + toffset - avio_tell(s->pb));
b->table = av_mallocz(32 * st->codec->channels);
if (!b->table)
return AVERROR(ENOMEM);
for (ch = 0; ch < st->codec->channels; ch++) {
if (avio_read(s->pb, b->table + ch * 32, 32) != 32) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
avio_skip(s->pb, bfstm ? 14 : 24);
}
}
if (size < (avio_tell(s->pb) - pos)) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
avio_skip(s->pb, size - (avio_tell(s->pb) - pos));
while (!avio_feof(s->pb)) {
chunk = avio_rl32(s->pb);
size = read32(s);
if (size < 8) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
size -= 8;
switch (chunk) {
case MKTAG('S','E','E','K'):
case MKTAG('A','D','P','C'):
if (codec != AV_CODEC_ID_ADPCM_THP &&
codec != AV_CODEC_ID_ADPCM_THP_LE)
goto skip;
asize = b->block_count * st->codec->channels * 4;
if (size < asize) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
if (b->adpc) {
av_log(s, AV_LOG_WARNING, "skipping additional ADPC chunk\n");
goto skip;
} else {
b->adpc = av_mallocz(asize);
if (!b->adpc) {
ret = AVERROR(ENOMEM);
goto fail;
}
if (bfstm && codec != AV_CODEC_ID_ADPCM_THP_LE) {
// Big-endian BFSTMs have little-endian SEEK tables
// for some strange reason.
int i;
for (i = 0; i < asize; i += 2) {
b->adpc[i+1] = avio_r8(s->pb);
b->adpc[i] = avio_r8(s->pb);
}
} else {
avio_read(s->pb, b->adpc, asize);
}
avio_skip(s->pb, size - asize);
}
break;
case MKTAG('D','A','T','A'):
if ((start < avio_tell(s->pb)) ||
(!b->adpc && (codec == AV_CODEC_ID_ADPCM_THP ||
codec == AV_CODEC_ID_ADPCM_THP_LE))) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
avio_skip(s->pb, start - avio_tell(s->pb));
if (bfstm && (codec == AV_CODEC_ID_ADPCM_THP ||
codec == AV_CODEC_ID_ADPCM_THP_LE))
avio_skip(s->pb, 24);
b->data_start = avio_tell(s->pb);
if (!bfstm && (major != 1 || minor))
avpriv_request_sample(s, "Version %d.%d", major, minor);
return 0;
default:
av_log(s, AV_LOG_WARNING, "skipping unknown chunk: %X\n", chunk);
skip:
avio_skip(s->pb, size);
}
}
fail:
read_close(s);
return ret;
}
| true | FFmpeg | 7b67fe20f6c5ce21ed1cac01fdb1906e515bc87e | static int read_header(AVFormatContext *s)
{
BRSTMDemuxContext *b = s->priv_data;
int bom, major, minor, codec, chunk;
int64_t h1offset, pos, toffset;
uint32_t size, asize, start = 0;
AVStream *st;
int ret = AVERROR_EOF;
int loop = 0;
int bfstm = !strcmp("bfstm", s->iformat->name);
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
avio_skip(s->pb, 4);
bom = avio_rb16(s->pb);
if (bom != 0xFEFF && bom != 0xFFFE) {
av_log(s, AV_LOG_ERROR, "invalid byte order: %X\n", bom);
return AVERROR_INVALIDDATA;
}
if (bom == 0xFFFE)
b->little_endian = 1;
if (!bfstm) {
major = avio_r8(s->pb);
minor = avio_r8(s->pb);
avio_skip(s->pb, 4);
size = read16(s);
if (size < 14)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, size - 14);
pos = avio_tell(s->pb);
if (avio_rl32(s->pb) != MKTAG('H','E','A','D'))
return AVERROR_INVALIDDATA;
} else {
uint32_t info_offset = 0;
uint16_t section_count, header_size, i;
header_size = read16(s);
avio_skip(s->pb, 4);
avio_skip(s->pb, 4);
section_count = read16(s);
avio_skip(s->pb, 2);
for (i = 0; avio_tell(s->pb) < header_size
&& !(start && info_offset)
&& i < section_count; i++) {
uint16_t flag = read16(s);
avio_skip(s->pb, 2);
switch (flag) {
case 0x4000:
info_offset = read32(s);
read32(s);
break;
case 0x4001:
avio_skip(s->pb, 4);
avio_skip(s->pb, 4);
break;
case 0x4002:
start = read32(s) + 8;
avio_skip(s->pb, 4);
break;
case 0x4003:
avio_skip(s->pb, 4);
avio_skip(s->pb, 4);
break;
}
}
if (!info_offset || !start)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, info_offset - avio_tell(s->pb));
pos = avio_tell(s->pb);
if (avio_rl32(s->pb) != MKTAG('I','N','F','O'))
return AVERROR_INVALIDDATA;
}
size = read32(s);
if (size < 192)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, 4);
h1offset = read32(s);
if (h1offset > size)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, 12);
toffset = read32(s) + 16LL;
if (toffset > size)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, pos + h1offset + 8 - avio_tell(s->pb));
codec = avio_r8(s->pb);
switch (codec) {
case 0: codec = AV_CODEC_ID_PCM_S8_PLANAR; break;
case 1: codec = b->little_endian ?
AV_CODEC_ID_PCM_S16LE_PLANAR :
AV_CODEC_ID_PCM_S16BE_PLANAR; break;
case 2: codec = b->little_endian ?
AV_CODEC_ID_ADPCM_THP_LE :
AV_CODEC_ID_ADPCM_THP; break;
default:
avpriv_request_sample(s, "codec %d", codec);
return AVERROR_PATCHWELCOME;
}
loop = avio_r8(s->pb);
st->codec->codec_id = codec;
st->codec->channels = avio_r8(s->pb);
if (!st->codec->channels)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, 1);
st->codec->sample_rate = bfstm ? read32(s) : read16(s);
if (!st->codec->sample_rate)
return AVERROR_INVALIDDATA;
if (!bfstm)
avio_skip(s->pb, 2);
if (loop) {
if (av_dict_set_int(&s->metadata, "loop_start",
av_rescale(read32(s), AV_TIME_BASE,
st->codec->sample_rate),
0) < 0)
return AVERROR(ENOMEM);
} else {
avio_skip(s->pb, 4);
}
st->start_time = 0;
st->duration = read32(s);
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
if (!bfstm)
start = read32(s);
b->current_block = 0;
b->block_count = read32(s);
if (b->block_count > UINT16_MAX) {
av_log(s, AV_LOG_WARNING, "too many blocks: %u\n", b->block_count);
return AVERROR_INVALIDDATA;
}
b->block_size = read32(s);
if (b->block_size > UINT32_MAX / st->codec->channels)
return AVERROR_INVALIDDATA;
b->samples_per_block = read32(s);
b->last_block_used_bytes = read32(s);
b->last_block_samples = read32(s);
b->last_block_size = read32(s);
if (b->last_block_size > UINT32_MAX / st->codec->channels)
return AVERROR_INVALIDDATA;
if (b->last_block_used_bytes > b->last_block_size)
return AVERROR_INVALIDDATA;
if (codec == AV_CODEC_ID_ADPCM_THP || codec == AV_CODEC_ID_ADPCM_THP_LE) {
int ch;
avio_skip(s->pb, pos + toffset - avio_tell(s->pb));
if (!bfstm)
toffset = read32(s) + 16LL;
else
toffset = toffset + read32(s) + st->codec->channels * 8 - 8;
if (toffset > size)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, pos + toffset - avio_tell(s->pb));
b->table = av_mallocz(32 * st->codec->channels);
if (!b->table)
return AVERROR(ENOMEM);
for (ch = 0; ch < st->codec->channels; ch++) {
if (avio_read(s->pb, b->table + ch * 32, 32) != 32) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
avio_skip(s->pb, bfstm ? 14 : 24);
}
}
if (size < (avio_tell(s->pb) - pos)) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
avio_skip(s->pb, size - (avio_tell(s->pb) - pos));
while (!avio_feof(s->pb)) {
chunk = avio_rl32(s->pb);
size = read32(s);
if (size < 8) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
size -= 8;
switch (chunk) {
case MKTAG('S','E','E','K'):
case MKTAG('A','D','P','C'):
if (codec != AV_CODEC_ID_ADPCM_THP &&
codec != AV_CODEC_ID_ADPCM_THP_LE)
goto skip;
asize = b->block_count * st->codec->channels * 4;
if (size < asize) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
if (b->adpc) {
av_log(s, AV_LOG_WARNING, "skipping additional ADPC chunk\n");
goto skip;
} else {
b->adpc = av_mallocz(asize);
if (!b->adpc) {
ret = AVERROR(ENOMEM);
goto fail;
}
if (bfstm && codec != AV_CODEC_ID_ADPCM_THP_LE) {
int i;
for (i = 0; i < asize; i += 2) {
b->adpc[i+1] = avio_r8(s->pb);
b->adpc[i] = avio_r8(s->pb);
}
} else {
avio_read(s->pb, b->adpc, asize);
}
avio_skip(s->pb, size - asize);
}
break;
case MKTAG('D','A','T','A'):
if ((start < avio_tell(s->pb)) ||
(!b->adpc && (codec == AV_CODEC_ID_ADPCM_THP ||
codec == AV_CODEC_ID_ADPCM_THP_LE))) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
avio_skip(s->pb, start - avio_tell(s->pb));
if (bfstm && (codec == AV_CODEC_ID_ADPCM_THP ||
codec == AV_CODEC_ID_ADPCM_THP_LE))
avio_skip(s->pb, 24);
b->data_start = avio_tell(s->pb);
if (!bfstm && (major != 1 || minor))
avpriv_request_sample(s, "Version %d.%d", major, minor);
return 0;
default:
av_log(s, AV_LOG_WARNING, "skipping unknown chunk: %X\n", chunk);
skip:
avio_skip(s->pb, size);
}
}
fail:
read_close(s);
return ret;
}
| {
"code": [
" if (!st->codec->sample_rate)"
],
"line_no": [
241
]
} | static int FUNC_0(AVFormatContext *VAR_0)
{
BRSTMDemuxContext *b = VAR_0->priv_data;
int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5;
int64_t h1offset, pos, toffset;
uint32_t size, asize, start = 0;
AVStream *st;
int VAR_6 = AVERROR_EOF;
int VAR_7 = 0;
int VAR_8 = !strcmp("VAR_8", VAR_0->iformat->name);
st = avformat_new_stream(VAR_0, NULL);
if (!st)
return AVERROR(ENOMEM);
st->VAR_4->codec_type = AVMEDIA_TYPE_AUDIO;
avio_skip(VAR_0->pb, 4);
VAR_1 = avio_rb16(VAR_0->pb);
if (VAR_1 != 0xFEFF && VAR_1 != 0xFFFE) {
av_log(VAR_0, AV_LOG_ERROR, "invalid byte order: %X\n", VAR_1);
return AVERROR_INVALIDDATA;
}
if (VAR_1 == 0xFFFE)
b->little_endian = 1;
if (!VAR_8) {
VAR_2 = avio_r8(VAR_0->pb);
VAR_3 = avio_r8(VAR_0->pb);
avio_skip(VAR_0->pb, 4);
size = read16(VAR_0);
if (size < 14)
return AVERROR_INVALIDDATA;
avio_skip(VAR_0->pb, size - 14);
pos = avio_tell(VAR_0->pb);
if (avio_rl32(VAR_0->pb) != MKTAG('H','E','A','D'))
return AVERROR_INVALIDDATA;
} else {
uint32_t info_offset = 0;
uint16_t section_count, header_size, VAR_10;
header_size = read16(VAR_0);
avio_skip(VAR_0->pb, 4);
avio_skip(VAR_0->pb, 4);
section_count = read16(VAR_0);
avio_skip(VAR_0->pb, 2);
for (VAR_10 = 0; avio_tell(VAR_0->pb) < header_size
&& !(start && info_offset)
&& VAR_10 < section_count; VAR_10++) {
uint16_t flag = read16(VAR_0);
avio_skip(VAR_0->pb, 2);
switch (flag) {
case 0x4000:
info_offset = read32(VAR_0);
read32(VAR_0);
break;
case 0x4001:
avio_skip(VAR_0->pb, 4);
avio_skip(VAR_0->pb, 4);
break;
case 0x4002:
start = read32(VAR_0) + 8;
avio_skip(VAR_0->pb, 4);
break;
case 0x4003:
avio_skip(VAR_0->pb, 4);
avio_skip(VAR_0->pb, 4);
break;
}
}
if (!info_offset || !start)
return AVERROR_INVALIDDATA;
avio_skip(VAR_0->pb, info_offset - avio_tell(VAR_0->pb));
pos = avio_tell(VAR_0->pb);
if (avio_rl32(VAR_0->pb) != MKTAG('I','N','F','O'))
return AVERROR_INVALIDDATA;
}
size = read32(VAR_0);
if (size < 192)
return AVERROR_INVALIDDATA;
avio_skip(VAR_0->pb, 4);
h1offset = read32(VAR_0);
if (h1offset > size)
return AVERROR_INVALIDDATA;
avio_skip(VAR_0->pb, 12);
toffset = read32(VAR_0) + 16LL;
if (toffset > size)
return AVERROR_INVALIDDATA;
avio_skip(VAR_0->pb, pos + h1offset + 8 - avio_tell(VAR_0->pb));
VAR_4 = avio_r8(VAR_0->pb);
switch (VAR_4) {
case 0: VAR_4 = AV_CODEC_ID_PCM_S8_PLANAR; break;
case 1: VAR_4 = b->little_endian ?
AV_CODEC_ID_PCM_S16LE_PLANAR :
AV_CODEC_ID_PCM_S16BE_PLANAR; break;
case 2: VAR_4 = b->little_endian ?
AV_CODEC_ID_ADPCM_THP_LE :
AV_CODEC_ID_ADPCM_THP; break;
default:
avpriv_request_sample(VAR_0, "VAR_4 %d", VAR_4);
return AVERROR_PATCHWELCOME;
}
VAR_7 = avio_r8(VAR_0->pb);
st->VAR_4->codec_id = VAR_4;
st->VAR_4->channels = avio_r8(VAR_0->pb);
if (!st->VAR_4->channels)
return AVERROR_INVALIDDATA;
avio_skip(VAR_0->pb, 1);
st->VAR_4->sample_rate = VAR_8 ? read32(VAR_0) : read16(VAR_0);
if (!st->VAR_4->sample_rate)
return AVERROR_INVALIDDATA;
if (!VAR_8)
avio_skip(VAR_0->pb, 2);
if (VAR_7) {
if (av_dict_set_int(&VAR_0->metadata, "loop_start",
av_rescale(read32(VAR_0), AV_TIME_BASE,
st->VAR_4->sample_rate),
0) < 0)
return AVERROR(ENOMEM);
} else {
avio_skip(VAR_0->pb, 4);
}
st->start_time = 0;
st->duration = read32(VAR_0);
avpriv_set_pts_info(st, 64, 1, st->VAR_4->sample_rate);
if (!VAR_8)
start = read32(VAR_0);
b->current_block = 0;
b->block_count = read32(VAR_0);
if (b->block_count > UINT16_MAX) {
av_log(VAR_0, AV_LOG_WARNING, "too many blocks: %u\n", b->block_count);
return AVERROR_INVALIDDATA;
}
b->block_size = read32(VAR_0);
if (b->block_size > UINT32_MAX / st->VAR_4->channels)
return AVERROR_INVALIDDATA;
b->samples_per_block = read32(VAR_0);
b->last_block_used_bytes = read32(VAR_0);
b->last_block_samples = read32(VAR_0);
b->last_block_size = read32(VAR_0);
if (b->last_block_size > UINT32_MAX / st->VAR_4->channels)
return AVERROR_INVALIDDATA;
if (b->last_block_used_bytes > b->last_block_size)
return AVERROR_INVALIDDATA;
if (VAR_4 == AV_CODEC_ID_ADPCM_THP || VAR_4 == AV_CODEC_ID_ADPCM_THP_LE) {
int VAR_9;
avio_skip(VAR_0->pb, pos + toffset - avio_tell(VAR_0->pb));
if (!VAR_8)
toffset = read32(VAR_0) + 16LL;
else
toffset = toffset + read32(VAR_0) + st->VAR_4->channels * 8 - 8;
if (toffset > size)
return AVERROR_INVALIDDATA;
avio_skip(VAR_0->pb, pos + toffset - avio_tell(VAR_0->pb));
b->table = av_mallocz(32 * st->VAR_4->channels);
if (!b->table)
return AVERROR(ENOMEM);
for (VAR_9 = 0; VAR_9 < st->VAR_4->channels; VAR_9++) {
if (avio_read(VAR_0->pb, b->table + VAR_9 * 32, 32) != 32) {
VAR_6 = AVERROR_INVALIDDATA;
goto fail;
}
avio_skip(VAR_0->pb, VAR_8 ? 14 : 24);
}
}
if (size < (avio_tell(VAR_0->pb) - pos)) {
VAR_6 = AVERROR_INVALIDDATA;
goto fail;
}
avio_skip(VAR_0->pb, size - (avio_tell(VAR_0->pb) - pos));
while (!avio_feof(VAR_0->pb)) {
VAR_5 = avio_rl32(VAR_0->pb);
size = read32(VAR_0);
if (size < 8) {
VAR_6 = AVERROR_INVALIDDATA;
goto fail;
}
size -= 8;
switch (VAR_5) {
case MKTAG('S','E','E','K'):
case MKTAG('A','D','P','C'):
if (VAR_4 != AV_CODEC_ID_ADPCM_THP &&
VAR_4 != AV_CODEC_ID_ADPCM_THP_LE)
goto skip;
asize = b->block_count * st->VAR_4->channels * 4;
if (size < asize) {
VAR_6 = AVERROR_INVALIDDATA;
goto fail;
}
if (b->adpc) {
av_log(VAR_0, AV_LOG_WARNING, "skipping additional ADPC VAR_5\n");
goto skip;
} else {
b->adpc = av_mallocz(asize);
if (!b->adpc) {
VAR_6 = AVERROR(ENOMEM);
goto fail;
}
if (VAR_8 && VAR_4 != AV_CODEC_ID_ADPCM_THP_LE) {
int VAR_10;
for (VAR_10 = 0; VAR_10 < asize; VAR_10 += 2) {
b->adpc[VAR_10+1] = avio_r8(VAR_0->pb);
b->adpc[VAR_10] = avio_r8(VAR_0->pb);
}
} else {
avio_read(VAR_0->pb, b->adpc, asize);
}
avio_skip(VAR_0->pb, size - asize);
}
break;
case MKTAG('D','A','T','A'):
if ((start < avio_tell(VAR_0->pb)) ||
(!b->adpc && (VAR_4 == AV_CODEC_ID_ADPCM_THP ||
VAR_4 == AV_CODEC_ID_ADPCM_THP_LE))) {
VAR_6 = AVERROR_INVALIDDATA;
goto fail;
}
avio_skip(VAR_0->pb, start - avio_tell(VAR_0->pb));
if (VAR_8 && (VAR_4 == AV_CODEC_ID_ADPCM_THP ||
VAR_4 == AV_CODEC_ID_ADPCM_THP_LE))
avio_skip(VAR_0->pb, 24);
b->data_start = avio_tell(VAR_0->pb);
if (!VAR_8 && (VAR_2 != 1 || VAR_3))
avpriv_request_sample(VAR_0, "Version %d.%d", VAR_2, VAR_3);
return 0;
default:
av_log(VAR_0, AV_LOG_WARNING, "skipping unknown VAR_5: %X\n", VAR_5);
skip:
avio_skip(VAR_0->pb, size);
}
}
fail:
read_close(VAR_0);
return VAR_6;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"BRSTMDemuxContext *b = VAR_0->priv_data;",
"int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5;",
"int64_t h1offset, pos, toffset;",
"uint32_t size, asize, start = 0;",
"AVStream *st;",
"int VAR_6 = AVERROR_EOF;",
"int VAR_7 = 0;",
"int VAR_8 = !strcmp(\"VAR_8\", VAR_0->iformat->name);",
"st = avformat_new_stream(VAR_0, NULL);",
"if (!st)\nreturn AVERROR(ENOMEM);",
"st->VAR_4->codec_type = AVMEDIA_TYPE_AUDIO;",
"avio_skip(VAR_0->pb, 4);",
"VAR_1 = avio_rb16(VAR_0->pb);",
"if (VAR_1 != 0xFEFF && VAR_1 != 0xFFFE) {",
"av_log(VAR_0, AV_LOG_ERROR, \"invalid byte order: %X\\n\", VAR_1);",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_1 == 0xFFFE)\nb->little_endian = 1;",
"if (!VAR_8) {",
"VAR_2 = avio_r8(VAR_0->pb);",
"VAR_3 = avio_r8(VAR_0->pb);",
"avio_skip(VAR_0->pb, 4);",
"size = read16(VAR_0);",
"if (size < 14)\nreturn AVERROR_INVALIDDATA;",
"avio_skip(VAR_0->pb, size - 14);",
"pos = avio_tell(VAR_0->pb);",
"if (avio_rl32(VAR_0->pb) != MKTAG('H','E','A','D'))\nreturn AVERROR_INVALIDDATA;",
"} else {",
"uint32_t info_offset = 0;",
"uint16_t section_count, header_size, VAR_10;",
"header_size = read16(VAR_0);",
"avio_skip(VAR_0->pb, 4);",
"avio_skip(VAR_0->pb, 4);",
"section_count = read16(VAR_0);",
"avio_skip(VAR_0->pb, 2);",
"for (VAR_10 = 0; avio_tell(VAR_0->pb) < header_size",
"&& !(start && info_offset)\n&& VAR_10 < section_count; VAR_10++) {",
"uint16_t flag = read16(VAR_0);",
"avio_skip(VAR_0->pb, 2);",
"switch (flag) {",
"case 0x4000:\ninfo_offset = read32(VAR_0);",
"read32(VAR_0);",
"break;",
"case 0x4001:\navio_skip(VAR_0->pb, 4);",
"avio_skip(VAR_0->pb, 4);",
"break;",
"case 0x4002:\nstart = read32(VAR_0) + 8;",
"avio_skip(VAR_0->pb, 4);",
"break;",
"case 0x4003:\navio_skip(VAR_0->pb, 4);",
"avio_skip(VAR_0->pb, 4);",
"break;",
"}",
"}",
"if (!info_offset || !start)\nreturn AVERROR_INVALIDDATA;",
"avio_skip(VAR_0->pb, info_offset - avio_tell(VAR_0->pb));",
"pos = avio_tell(VAR_0->pb);",
"if (avio_rl32(VAR_0->pb) != MKTAG('I','N','F','O'))\nreturn AVERROR_INVALIDDATA;",
"}",
"size = read32(VAR_0);",
"if (size < 192)\nreturn AVERROR_INVALIDDATA;",
"avio_skip(VAR_0->pb, 4);",
"h1offset = read32(VAR_0);",
"if (h1offset > size)\nreturn AVERROR_INVALIDDATA;",
"avio_skip(VAR_0->pb, 12);",
"toffset = read32(VAR_0) + 16LL;",
"if (toffset > size)\nreturn AVERROR_INVALIDDATA;",
"avio_skip(VAR_0->pb, pos + h1offset + 8 - avio_tell(VAR_0->pb));",
"VAR_4 = avio_r8(VAR_0->pb);",
"switch (VAR_4) {",
"case 0: VAR_4 = AV_CODEC_ID_PCM_S8_PLANAR; break;",
"case 1: VAR_4 = b->little_endian ?\nAV_CODEC_ID_PCM_S16LE_PLANAR :\nAV_CODEC_ID_PCM_S16BE_PLANAR; break;",
"case 2: VAR_4 = b->little_endian ?\nAV_CODEC_ID_ADPCM_THP_LE :\nAV_CODEC_ID_ADPCM_THP; break;",
"default:\navpriv_request_sample(VAR_0, \"VAR_4 %d\", VAR_4);",
"return AVERROR_PATCHWELCOME;",
"}",
"VAR_7 = avio_r8(VAR_0->pb);",
"st->VAR_4->codec_id = VAR_4;",
"st->VAR_4->channels = avio_r8(VAR_0->pb);",
"if (!st->VAR_4->channels)\nreturn AVERROR_INVALIDDATA;",
"avio_skip(VAR_0->pb, 1);",
"st->VAR_4->sample_rate = VAR_8 ? read32(VAR_0) : read16(VAR_0);",
"if (!st->VAR_4->sample_rate)\nreturn AVERROR_INVALIDDATA;",
"if (!VAR_8)\navio_skip(VAR_0->pb, 2);",
"if (VAR_7) {",
"if (av_dict_set_int(&VAR_0->metadata, \"loop_start\",\nav_rescale(read32(VAR_0), AV_TIME_BASE,\nst->VAR_4->sample_rate),\n0) < 0)\nreturn AVERROR(ENOMEM);",
"} else {",
"avio_skip(VAR_0->pb, 4);",
"}",
"st->start_time = 0;",
"st->duration = read32(VAR_0);",
"avpriv_set_pts_info(st, 64, 1, st->VAR_4->sample_rate);",
"if (!VAR_8)\nstart = read32(VAR_0);",
"b->current_block = 0;",
"b->block_count = read32(VAR_0);",
"if (b->block_count > UINT16_MAX) {",
"av_log(VAR_0, AV_LOG_WARNING, \"too many blocks: %u\\n\", b->block_count);",
"return AVERROR_INVALIDDATA;",
"}",
"b->block_size = read32(VAR_0);",
"if (b->block_size > UINT32_MAX / st->VAR_4->channels)\nreturn AVERROR_INVALIDDATA;",
"b->samples_per_block = read32(VAR_0);",
"b->last_block_used_bytes = read32(VAR_0);",
"b->last_block_samples = read32(VAR_0);",
"b->last_block_size = read32(VAR_0);",
"if (b->last_block_size > UINT32_MAX / st->VAR_4->channels)\nreturn AVERROR_INVALIDDATA;",
"if (b->last_block_used_bytes > b->last_block_size)\nreturn AVERROR_INVALIDDATA;",
"if (VAR_4 == AV_CODEC_ID_ADPCM_THP || VAR_4 == AV_CODEC_ID_ADPCM_THP_LE) {",
"int VAR_9;",
"avio_skip(VAR_0->pb, pos + toffset - avio_tell(VAR_0->pb));",
"if (!VAR_8)\ntoffset = read32(VAR_0) + 16LL;",
"else\ntoffset = toffset + read32(VAR_0) + st->VAR_4->channels * 8 - 8;",
"if (toffset > size)\nreturn AVERROR_INVALIDDATA;",
"avio_skip(VAR_0->pb, pos + toffset - avio_tell(VAR_0->pb));",
"b->table = av_mallocz(32 * st->VAR_4->channels);",
"if (!b->table)\nreturn AVERROR(ENOMEM);",
"for (VAR_9 = 0; VAR_9 < st->VAR_4->channels; VAR_9++) {",
"if (avio_read(VAR_0->pb, b->table + VAR_9 * 32, 32) != 32) {",
"VAR_6 = AVERROR_INVALIDDATA;",
"goto fail;",
"}",
"avio_skip(VAR_0->pb, VAR_8 ? 14 : 24);",
"}",
"}",
"if (size < (avio_tell(VAR_0->pb) - pos)) {",
"VAR_6 = AVERROR_INVALIDDATA;",
"goto fail;",
"}",
"avio_skip(VAR_0->pb, size - (avio_tell(VAR_0->pb) - pos));",
"while (!avio_feof(VAR_0->pb)) {",
"VAR_5 = avio_rl32(VAR_0->pb);",
"size = read32(VAR_0);",
"if (size < 8) {",
"VAR_6 = AVERROR_INVALIDDATA;",
"goto fail;",
"}",
"size -= 8;",
"switch (VAR_5) {",
"case MKTAG('S','E','E','K'):\ncase MKTAG('A','D','P','C'):\nif (VAR_4 != AV_CODEC_ID_ADPCM_THP &&\nVAR_4 != AV_CODEC_ID_ADPCM_THP_LE)\ngoto skip;",
"asize = b->block_count * st->VAR_4->channels * 4;",
"if (size < asize) {",
"VAR_6 = AVERROR_INVALIDDATA;",
"goto fail;",
"}",
"if (b->adpc) {",
"av_log(VAR_0, AV_LOG_WARNING, \"skipping additional ADPC VAR_5\\n\");",
"goto skip;",
"} else {",
"b->adpc = av_mallocz(asize);",
"if (!b->adpc) {",
"VAR_6 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"if (VAR_8 && VAR_4 != AV_CODEC_ID_ADPCM_THP_LE) {",
"int VAR_10;",
"for (VAR_10 = 0; VAR_10 < asize; VAR_10 += 2) {",
"b->adpc[VAR_10+1] = avio_r8(VAR_0->pb);",
"b->adpc[VAR_10] = avio_r8(VAR_0->pb);",
"}",
"} else {",
"avio_read(VAR_0->pb, b->adpc, asize);",
"}",
"avio_skip(VAR_0->pb, size - asize);",
"}",
"break;",
"case MKTAG('D','A','T','A'):\nif ((start < avio_tell(VAR_0->pb)) ||\n(!b->adpc && (VAR_4 == AV_CODEC_ID_ADPCM_THP ||\nVAR_4 == AV_CODEC_ID_ADPCM_THP_LE))) {",
"VAR_6 = AVERROR_INVALIDDATA;",
"goto fail;",
"}",
"avio_skip(VAR_0->pb, start - avio_tell(VAR_0->pb));",
"if (VAR_8 && (VAR_4 == AV_CODEC_ID_ADPCM_THP ||\nVAR_4 == AV_CODEC_ID_ADPCM_THP_LE))\navio_skip(VAR_0->pb, 24);",
"b->data_start = avio_tell(VAR_0->pb);",
"if (!VAR_8 && (VAR_2 != 1 || VAR_3))\navpriv_request_sample(VAR_0, \"Version %d.%d\", VAR_2, VAR_3);",
"return 0;",
"default:\nav_log(VAR_0, AV_LOG_WARNING, \"skipping unknown VAR_5: %X\\n\", VAR_5);",
"skip:\navio_skip(VAR_0->pb, size);",
"}",
"}",
"fail:\nread_close(VAR_0);",
"return VAR_6;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25,
27
],
[
29
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49,
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101,
103
],
[
105
],
[
107
],
[
109
],
[
111,
113
],
[
115
],
[
117
],
[
119,
121
],
[
123
],
[
125
],
[
127,
129
],
[
131
],
[
133
],
[
135,
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149,
151
],
[
155
],
[
157
],
[
159,
161
],
[
163
],
[
167
],
[
169,
171
],
[
173
],
[
175
],
[
177,
179
],
[
181
],
[
183
],
[
185,
187
],
[
191
],
[
193
],
[
197
],
[
199
],
[
201,
203,
205
],
[
207,
209,
211
],
[
213,
215
],
[
217
],
[
219
],
[
223
],
[
225
],
[
227
],
[
229,
231
],
[
235
],
[
239
],
[
241,
243
],
[
247,
249
],
[
253
],
[
255,
257,
259,
261,
263
],
[
265
],
[
267
],
[
269
],
[
273
],
[
275
],
[
277
],
[
281,
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
299
],
[
301,
303
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315,
317
],
[
319,
321
],
[
327
],
[
329
],
[
333
],
[
335,
337
],
[
339,
341
],
[
343,
345
],
[
349
],
[
351
],
[
353,
355
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
377
],
[
379
],
[
381
],
[
383
],
[
387
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409,
411,
413,
415,
417
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
449
],
[
455
],
[
457
],
[
459
],
[
461
],
[
463
],
[
465
],
[
467
],
[
469
],
[
471
],
[
473
],
[
475
],
[
477,
479,
481,
483
],
[
485
],
[
487
],
[
489
],
[
491
],
[
495,
497,
499
],
[
503
],
[
507,
509
],
[
513
],
[
515,
517
],
[
519,
521
],
[
523
],
[
525
],
[
529,
531
],
[
535
],
[
537
]
] |
24,538 | static inline void RENAME(rgb15to16)(const uint8_t *src,uint8_t *dst,unsigned src_size)
{
register const uint8_t* s=src;
register uint8_t* d=dst;
register const uint8_t *end;
const uint8_t *mm_end;
end = s + src_size;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*s));
__asm __volatile("movq %0, %%mm4"::"m"(mask15s));
mm_end = end - 15;
while(s<mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movq %1, %%mm0\n\t"
"movq 8%1, %%mm2\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm2, %%mm3\n\t"
"pand %%mm4, %%mm0\n\t"
"pand %%mm4, %%mm2\n\t"
"paddw %%mm1, %%mm0\n\t"
"paddw %%mm3, %%mm2\n\t"
MOVNTQ" %%mm0, %0\n\t"
MOVNTQ" %%mm2, 8%0"
:"=m"(*d)
:"m"(*s)
);
d+=16;
s+=16;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
mm_end = end - 3;
while(s < mm_end)
{
register unsigned x= *((uint32_t *)s);
*((uint32_t *)d) = (x&0x7FFF7FFF) + (x&0x7FE07FE0);
d+=4;
s+=4;
}
if(s < end)
{
register unsigned short x= *((uint16_t *)s);
*((uint16_t *)d) = (x&0x7FFF) + (x&0x7FE0);
}
}
| true | FFmpeg | 7f526efd17973ec6d2204f7a47b6923e2be31363 | static inline void RENAME(rgb15to16)(const uint8_t *src,uint8_t *dst,unsigned src_size)
{
register const uint8_t* s=src;
register uint8_t* d=dst;
register const uint8_t *end;
const uint8_t *mm_end;
end = s + src_size;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*s));
__asm __volatile("movq %0, %%mm4"::"m"(mask15s));
mm_end = end - 15;
while(s<mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movq %1, %%mm0\n\t"
"movq 8%1, %%mm2\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm2, %%mm3\n\t"
"pand %%mm4, %%mm0\n\t"
"pand %%mm4, %%mm2\n\t"
"paddw %%mm1, %%mm0\n\t"
"paddw %%mm3, %%mm2\n\t"
MOVNTQ" %%mm0, %0\n\t"
MOVNTQ" %%mm2, 8%0"
:"=m"(*d)
:"m"(*s)
);
d+=16;
s+=16;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
mm_end = end - 3;
while(s < mm_end)
{
register unsigned x= *((uint32_t *)s);
*((uint32_t *)d) = (x&0x7FFF7FFF) + (x&0x7FE07FE0);
d+=4;
s+=4;
}
if(s < end)
{
register unsigned short x= *((uint16_t *)s);
*((uint16_t *)d) = (x&0x7FFF) + (x&0x7FE0);
}
}
| {
"code": [
"static inline void RENAME(rgb15to16)(const uint8_t *src,uint8_t *dst,unsigned src_size)"
],
"line_no": [
1
]
} | static inline void FUNC_0(rgb15to16)(const uint8_t *src,uint8_t *dst,unsigned src_size)
{
register const uint8_t* VAR_0=src;
register uint8_t* VAR_1=dst;
register const uint8_t *VAR_2;
const uint8_t *VAR_3;
VAR_2 = VAR_0 + src_size;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*VAR_0));
__asm __volatile("movq %0, %%mm4"::"m"(mask15s));
VAR_3 = VAR_2 - 15;
while(VAR_0<VAR_3)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movq %1, %%mm0\n\t"
"movq 8%1, %%mm2\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm2, %%mm3\n\t"
"pand %%mm4, %%mm0\n\t"
"pand %%mm4, %%mm2\n\t"
"paddw %%mm1, %%mm0\n\t"
"paddw %%mm3, %%mm2\n\t"
MOVNTQ" %%mm0, %0\n\t"
MOVNTQ" %%mm2, 8%0"
:"=m"(*VAR_1)
:"m"(*VAR_0)
);
VAR_1+=16;
VAR_0+=16;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
VAR_3 = VAR_2 - 3;
while(VAR_0 < VAR_3)
{
register unsigned VAR_5= *((uint32_t *)VAR_0);
*((uint32_t *)VAR_1) = (VAR_5&0x7FFF7FFF) + (VAR_5&0x7FE07FE0);
VAR_1+=4;
VAR_0+=4;
}
if(VAR_0 < VAR_2)
{
register unsigned short VAR_5= *((uint16_t *)VAR_0);
*((uint16_t *)VAR_1) = (VAR_5&0x7FFF) + (VAR_5&0x7FE0);
}
}
| [
"static inline void FUNC_0(rgb15to16)(const uint8_t *src,uint8_t *dst,unsigned src_size)\n{",
"register const uint8_t* VAR_0=src;",
"register uint8_t* VAR_1=dst;",
"register const uint8_t *VAR_2;",
"const uint8_t *VAR_3;",
"VAR_2 = VAR_0 + src_size;",
"#ifdef HAVE_MMX\n__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*VAR_0));",
"__asm __volatile(\"movq\t%0, %%mm4\"::\"m\"(mask15s));",
"VAR_3 = VAR_2 - 15;",
"while(VAR_0<VAR_3)\n{",
"__asm __volatile(\nPREFETCH\"\t32%1\\n\\t\"\n\"movq\t%1, %%mm0\\n\\t\"\n\"movq\t8%1, %%mm2\\n\\t\"\n\"movq\t%%mm0, %%mm1\\n\\t\"\n\"movq\t%%mm2, %%mm3\\n\\t\"\n\"pand\t%%mm4, %%mm0\\n\\t\"\n\"pand\t%%mm4, %%mm2\\n\\t\"\n\"paddw\t%%mm1, %%mm0\\n\\t\"\n\"paddw\t%%mm3, %%mm2\\n\\t\"\nMOVNTQ\"\t%%mm0, %0\\n\\t\"\nMOVNTQ\"\t%%mm2, 8%0\"\n:\"=m\"(*VAR_1)\n:\"m\"(*VAR_0)\n);",
"VAR_1+=16;",
"VAR_0+=16;",
"}",
"__asm __volatile(SFENCE:::\"memory\");",
"__asm __volatile(EMMS:::\"memory\");",
"#endif\nVAR_3 = VAR_2 - 3;",
"while(VAR_0 < VAR_3)\n{",
"register unsigned VAR_5= *((uint32_t *)VAR_0);",
"*((uint32_t *)VAR_1) = (VAR_5&0x7FFF7FFF) + (VAR_5&0x7FE07FE0);",
"VAR_1+=4;",
"VAR_0+=4;",
"}",
"if(VAR_0 < VAR_2)\n{",
"register unsigned short VAR_5= *((uint16_t *)VAR_0);",
"*((uint16_t *)VAR_1) = (VAR_5&0x7FFF) + (VAR_5&0x7FE0);",
"}",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23,
25
],
[
27,
29,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67,
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85,
87
],
[
89
],
[
91
],
[
93
],
[
95
]
] |
24,539 | static void dec_sexth(DisasContext *dc)
{
LOG_DIS("sexth r%d, r%d\n", dc->r2, dc->r0);
if (!(dc->env->features & LM32_FEATURE_SIGN_EXTEND)) {
cpu_abort(dc->env, "hardware sign extender is not available\n");
}
tcg_gen_ext16s_tl(cpu_R[dc->r2], cpu_R[dc->r0]);
}
| true | qemu | 3604a76fea6ff37738d4a8f596be38407be74a83 | static void dec_sexth(DisasContext *dc)
{
LOG_DIS("sexth r%d, r%d\n", dc->r2, dc->r0);
if (!(dc->env->features & LM32_FEATURE_SIGN_EXTEND)) {
cpu_abort(dc->env, "hardware sign extender is not available\n");
}
tcg_gen_ext16s_tl(cpu_R[dc->r2], cpu_R[dc->r0]);
}
| {
"code": [
" cpu_abort(dc->env, \"hardware sign extender is not available\\n\");",
" cpu_abort(dc->env, \"hardware sign extender is not available\\n\");"
],
"line_no": [
11,
11
]
} | static void FUNC_0(DisasContext *VAR_0)
{
LOG_DIS("sexth r%d, r%d\n", VAR_0->r2, VAR_0->r0);
if (!(VAR_0->env->features & LM32_FEATURE_SIGN_EXTEND)) {
cpu_abort(VAR_0->env, "hardware sign extender is not available\n");
}
tcg_gen_ext16s_tl(cpu_R[VAR_0->r2], cpu_R[VAR_0->r0]);
}
| [
"static void FUNC_0(DisasContext *VAR_0)\n{",
"LOG_DIS(\"sexth r%d, r%d\\n\", VAR_0->r2, VAR_0->r0);",
"if (!(VAR_0->env->features & LM32_FEATURE_SIGN_EXTEND)) {",
"cpu_abort(VAR_0->env, \"hardware sign extender is not available\\n\");",
"}",
"tcg_gen_ext16s_tl(cpu_R[VAR_0->r2], cpu_R[VAR_0->r0]);",
"}"
] | [
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
]
] |
24,541 | static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
int *got_packet)
{
X264Context *x4 = ctx->priv_data;
x264_nal_t *nal;
int nnal, i, ret;
x264_picture_t pic_out;
x264_picture_init( &x4->pic );
x4->pic.img.i_csp = x4->params.i_csp;
if (x264_bit_depth > 8)
x4->pic.img.i_csp |= X264_CSP_HIGH_DEPTH;
x4->pic.img.i_plane = avfmt2_num_planes(ctx->pix_fmt);
if (frame) {
for (i = 0; i < x4->pic.img.i_plane; i++) {
x4->pic.img.plane[i] = frame->data[i];
x4->pic.img.i_stride[i] = frame->linesize[i];
}
x4->pic.i_pts = frame->pts;
x4->pic.i_type =
frame->pict_type == AV_PICTURE_TYPE_I ? X264_TYPE_KEYFRAME :
frame->pict_type == AV_PICTURE_TYPE_P ? X264_TYPE_P :
frame->pict_type == AV_PICTURE_TYPE_B ? X264_TYPE_B :
X264_TYPE_AUTO;
if (x4->params.b_interlaced && x4->params.b_tff != frame->top_field_first) {
x4->params.b_tff = frame->top_field_first;
x264_encoder_reconfig(x4->enc, &x4->params);
}
if (x4->params.vui.i_sar_height != ctx->sample_aspect_ratio.den ||
x4->params.vui.i_sar_width != ctx->sample_aspect_ratio.num) {
x4->params.vui.i_sar_height = ctx->sample_aspect_ratio.den;
x4->params.vui.i_sar_width = ctx->sample_aspect_ratio.num;
x264_encoder_reconfig(x4->enc, &x4->params);
}
}
do {
if (x264_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL, &pic_out) < 0)
return -1;
ret = encode_nals(ctx, pkt, nal, nnal);
if (ret < 0)
return -1;
} while (!ret && !frame && x264_encoder_delayed_frames(x4->enc));
pkt->pts = pic_out.i_pts;
pkt->dts = pic_out.i_dts;
switch (pic_out.i_type) {
case X264_TYPE_IDR:
case X264_TYPE_I:
x4->out_pic.pict_type = AV_PICTURE_TYPE_I;
break;
case X264_TYPE_P:
x4->out_pic.pict_type = AV_PICTURE_TYPE_P;
break;
case X264_TYPE_B:
case X264_TYPE_BREF:
x4->out_pic.pict_type = AV_PICTURE_TYPE_B;
break;
}
pkt->flags |= AV_PKT_FLAG_KEY*pic_out.b_keyframe;
if (ret)
x4->out_pic.quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
*got_packet = ret;
return 0;
}
| true | FFmpeg | 5d22ac488b4a424fa8e71f01152b43070f3ef1be | static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
int *got_packet)
{
X264Context *x4 = ctx->priv_data;
x264_nal_t *nal;
int nnal, i, ret;
x264_picture_t pic_out;
x264_picture_init( &x4->pic );
x4->pic.img.i_csp = x4->params.i_csp;
if (x264_bit_depth > 8)
x4->pic.img.i_csp |= X264_CSP_HIGH_DEPTH;
x4->pic.img.i_plane = avfmt2_num_planes(ctx->pix_fmt);
if (frame) {
for (i = 0; i < x4->pic.img.i_plane; i++) {
x4->pic.img.plane[i] = frame->data[i];
x4->pic.img.i_stride[i] = frame->linesize[i];
}
x4->pic.i_pts = frame->pts;
x4->pic.i_type =
frame->pict_type == AV_PICTURE_TYPE_I ? X264_TYPE_KEYFRAME :
frame->pict_type == AV_PICTURE_TYPE_P ? X264_TYPE_P :
frame->pict_type == AV_PICTURE_TYPE_B ? X264_TYPE_B :
X264_TYPE_AUTO;
if (x4->params.b_interlaced && x4->params.b_tff != frame->top_field_first) {
x4->params.b_tff = frame->top_field_first;
x264_encoder_reconfig(x4->enc, &x4->params);
}
if (x4->params.vui.i_sar_height != ctx->sample_aspect_ratio.den ||
x4->params.vui.i_sar_width != ctx->sample_aspect_ratio.num) {
x4->params.vui.i_sar_height = ctx->sample_aspect_ratio.den;
x4->params.vui.i_sar_width = ctx->sample_aspect_ratio.num;
x264_encoder_reconfig(x4->enc, &x4->params);
}
}
do {
if (x264_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL, &pic_out) < 0)
return -1;
ret = encode_nals(ctx, pkt, nal, nnal);
if (ret < 0)
return -1;
} while (!ret && !frame && x264_encoder_delayed_frames(x4->enc));
pkt->pts = pic_out.i_pts;
pkt->dts = pic_out.i_dts;
switch (pic_out.i_type) {
case X264_TYPE_IDR:
case X264_TYPE_I:
x4->out_pic.pict_type = AV_PICTURE_TYPE_I;
break;
case X264_TYPE_P:
x4->out_pic.pict_type = AV_PICTURE_TYPE_P;
break;
case X264_TYPE_B:
case X264_TYPE_BREF:
x4->out_pic.pict_type = AV_PICTURE_TYPE_B;
break;
}
pkt->flags |= AV_PKT_FLAG_KEY*pic_out.b_keyframe;
if (ret)
x4->out_pic.quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
*got_packet = ret;
return 0;
}
| {
"code": [
" x264_picture_t pic_out;"
],
"line_no": [
13
]
} | static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1, const AVFrame *VAR_2,
int *VAR_3)
{
X264Context *x4 = VAR_0->priv_data;
x264_nal_t *nal;
int VAR_4, VAR_5, VAR_6;
x264_picture_t pic_out;
x264_picture_init( &x4->pic );
x4->pic.img.i_csp = x4->params.i_csp;
if (x264_bit_depth > 8)
x4->pic.img.i_csp |= X264_CSP_HIGH_DEPTH;
x4->pic.img.i_plane = avfmt2_num_planes(VAR_0->pix_fmt);
if (VAR_2) {
for (VAR_5 = 0; VAR_5 < x4->pic.img.i_plane; VAR_5++) {
x4->pic.img.plane[VAR_5] = VAR_2->data[VAR_5];
x4->pic.img.i_stride[VAR_5] = VAR_2->linesize[VAR_5];
}
x4->pic.i_pts = VAR_2->pts;
x4->pic.i_type =
VAR_2->pict_type == AV_PICTURE_TYPE_I ? X264_TYPE_KEYFRAME :
VAR_2->pict_type == AV_PICTURE_TYPE_P ? X264_TYPE_P :
VAR_2->pict_type == AV_PICTURE_TYPE_B ? X264_TYPE_B :
X264_TYPE_AUTO;
if (x4->params.b_interlaced && x4->params.b_tff != VAR_2->top_field_first) {
x4->params.b_tff = VAR_2->top_field_first;
x264_encoder_reconfig(x4->enc, &x4->params);
}
if (x4->params.vui.i_sar_height != VAR_0->sample_aspect_ratio.den ||
x4->params.vui.i_sar_width != VAR_0->sample_aspect_ratio.num) {
x4->params.vui.i_sar_height = VAR_0->sample_aspect_ratio.den;
x4->params.vui.i_sar_width = VAR_0->sample_aspect_ratio.num;
x264_encoder_reconfig(x4->enc, &x4->params);
}
}
do {
if (x264_encoder_encode(x4->enc, &nal, &VAR_4, VAR_2? &x4->pic: NULL, &pic_out) < 0)
return -1;
VAR_6 = encode_nals(VAR_0, VAR_1, nal, VAR_4);
if (VAR_6 < 0)
return -1;
} while (!VAR_6 && !VAR_2 && x264_encoder_delayed_frames(x4->enc));
VAR_1->pts = pic_out.i_pts;
VAR_1->dts = pic_out.i_dts;
switch (pic_out.i_type) {
case X264_TYPE_IDR:
case X264_TYPE_I:
x4->out_pic.pict_type = AV_PICTURE_TYPE_I;
break;
case X264_TYPE_P:
x4->out_pic.pict_type = AV_PICTURE_TYPE_P;
break;
case X264_TYPE_B:
case X264_TYPE_BREF:
x4->out_pic.pict_type = AV_PICTURE_TYPE_B;
break;
}
VAR_1->flags |= AV_PKT_FLAG_KEY*pic_out.b_keyframe;
if (VAR_6)
x4->out_pic.quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
*VAR_3 = VAR_6;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1, const AVFrame *VAR_2,\nint *VAR_3)\n{",
"X264Context *x4 = VAR_0->priv_data;",
"x264_nal_t *nal;",
"int VAR_4, VAR_5, VAR_6;",
"x264_picture_t pic_out;",
"x264_picture_init( &x4->pic );",
"x4->pic.img.i_csp = x4->params.i_csp;",
"if (x264_bit_depth > 8)\nx4->pic.img.i_csp |= X264_CSP_HIGH_DEPTH;",
"x4->pic.img.i_plane = avfmt2_num_planes(VAR_0->pix_fmt);",
"if (VAR_2) {",
"for (VAR_5 = 0; VAR_5 < x4->pic.img.i_plane; VAR_5++) {",
"x4->pic.img.plane[VAR_5] = VAR_2->data[VAR_5];",
"x4->pic.img.i_stride[VAR_5] = VAR_2->linesize[VAR_5];",
"}",
"x4->pic.i_pts = VAR_2->pts;",
"x4->pic.i_type =\nVAR_2->pict_type == AV_PICTURE_TYPE_I ? X264_TYPE_KEYFRAME :\nVAR_2->pict_type == AV_PICTURE_TYPE_P ? X264_TYPE_P :\nVAR_2->pict_type == AV_PICTURE_TYPE_B ? X264_TYPE_B :\nX264_TYPE_AUTO;",
"if (x4->params.b_interlaced && x4->params.b_tff != VAR_2->top_field_first) {",
"x4->params.b_tff = VAR_2->top_field_first;",
"x264_encoder_reconfig(x4->enc, &x4->params);",
"}",
"if (x4->params.vui.i_sar_height != VAR_0->sample_aspect_ratio.den ||\nx4->params.vui.i_sar_width != VAR_0->sample_aspect_ratio.num) {",
"x4->params.vui.i_sar_height = VAR_0->sample_aspect_ratio.den;",
"x4->params.vui.i_sar_width = VAR_0->sample_aspect_ratio.num;",
"x264_encoder_reconfig(x4->enc, &x4->params);",
"}",
"}",
"do {",
"if (x264_encoder_encode(x4->enc, &nal, &VAR_4, VAR_2? &x4->pic: NULL, &pic_out) < 0)\nreturn -1;",
"VAR_6 = encode_nals(VAR_0, VAR_1, nal, VAR_4);",
"if (VAR_6 < 0)\nreturn -1;",
"} while (!VAR_6 && !VAR_2 && x264_encoder_delayed_frames(x4->enc));",
"VAR_1->pts = pic_out.i_pts;",
"VAR_1->dts = pic_out.i_dts;",
"switch (pic_out.i_type) {",
"case X264_TYPE_IDR:\ncase X264_TYPE_I:\nx4->out_pic.pict_type = AV_PICTURE_TYPE_I;",
"break;",
"case X264_TYPE_P:\nx4->out_pic.pict_type = AV_PICTURE_TYPE_P;",
"break;",
"case X264_TYPE_B:\ncase X264_TYPE_BREF:\nx4->out_pic.pict_type = AV_PICTURE_TYPE_B;",
"break;",
"}",
"VAR_1->flags |= AV_PKT_FLAG_KEY*pic_out.b_keyframe;",
"if (VAR_6)\nx4->out_pic.quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;",
"*VAR_3 = VAR_6;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43,
45,
47,
49,
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79,
81
],
[
85
],
[
87,
89
],
[
91
],
[
95
],
[
97
],
[
101
],
[
103,
105,
107
],
[
109
],
[
111,
113
],
[
115
],
[
117,
119,
121
],
[
123
],
[
125
],
[
129
],
[
131,
133
],
[
137
],
[
139
],
[
141
]
] |
24,546 | QCryptoHmac *qcrypto_hmac_new(QCryptoHashAlgorithm alg,
const uint8_t *key, size_t nkey,
Error **errp)
{
QCryptoHmac *hmac;
void *ctx = NULL;
Error *err2 = NULL;
QCryptoHmacDriver *drv = NULL;
#ifdef CONFIG_AF_ALG
ctx = qcrypto_afalg_hmac_ctx_new(alg, key, nkey, &err2);
if (ctx) {
drv = &qcrypto_hmac_afalg_driver;
}
#endif
if (!ctx) {
ctx = qcrypto_hmac_ctx_new(alg, key, nkey, errp);
if (!ctx) {
return NULL;
}
drv = &qcrypto_hmac_lib_driver;
error_free(err2);
}
hmac = g_new0(QCryptoHmac, 1);
hmac->alg = alg;
hmac->opaque = ctx;
hmac->driver = (void *)drv;
return hmac;
}
| true | qemu | f1710638edb2e98008c2a733ffda63ef32b50411 | QCryptoHmac *qcrypto_hmac_new(QCryptoHashAlgorithm alg,
const uint8_t *key, size_t nkey,
Error **errp)
{
QCryptoHmac *hmac;
void *ctx = NULL;
Error *err2 = NULL;
QCryptoHmacDriver *drv = NULL;
#ifdef CONFIG_AF_ALG
ctx = qcrypto_afalg_hmac_ctx_new(alg, key, nkey, &err2);
if (ctx) {
drv = &qcrypto_hmac_afalg_driver;
}
#endif
if (!ctx) {
ctx = qcrypto_hmac_ctx_new(alg, key, nkey, errp);
if (!ctx) {
return NULL;
}
drv = &qcrypto_hmac_lib_driver;
error_free(err2);
}
hmac = g_new0(QCryptoHmac, 1);
hmac->alg = alg;
hmac->opaque = ctx;
hmac->driver = (void *)drv;
return hmac;
}
| {
"code": [
" Error *err2 = NULL;",
" error_free(err2);",
" Error *err2 = NULL;",
" ctx = qcrypto_afalg_hmac_ctx_new(alg, key, nkey, &err2);",
" error_free(err2);"
],
"line_no": [
13,
47,
13,
21,
47
]
} | QCryptoHmac *FUNC_0(QCryptoHashAlgorithm alg,
const uint8_t *key, size_t nkey,
Error **errp)
{
QCryptoHmac *hmac;
void *VAR_0 = NULL;
Error *err2 = NULL;
QCryptoHmacDriver *drv = NULL;
#ifdef CONFIG_AF_ALG
VAR_0 = qcrypto_afalg_hmac_ctx_new(alg, key, nkey, &err2);
if (VAR_0) {
drv = &qcrypto_hmac_afalg_driver;
}
#endif
if (!VAR_0) {
VAR_0 = qcrypto_hmac_ctx_new(alg, key, nkey, errp);
if (!VAR_0) {
return NULL;
}
drv = &qcrypto_hmac_lib_driver;
error_free(err2);
}
hmac = g_new0(QCryptoHmac, 1);
hmac->alg = alg;
hmac->opaque = VAR_0;
hmac->driver = (void *)drv;
return hmac;
}
| [
"QCryptoHmac *FUNC_0(QCryptoHashAlgorithm alg,\nconst uint8_t *key, size_t nkey,\nError **errp)\n{",
"QCryptoHmac *hmac;",
"void *VAR_0 = NULL;",
"Error *err2 = NULL;",
"QCryptoHmacDriver *drv = NULL;",
"#ifdef CONFIG_AF_ALG\nVAR_0 = qcrypto_afalg_hmac_ctx_new(alg, key, nkey, &err2);",
"if (VAR_0) {",
"drv = &qcrypto_hmac_afalg_driver;",
"}",
"#endif\nif (!VAR_0) {",
"VAR_0 = qcrypto_hmac_ctx_new(alg, key, nkey, errp);",
"if (!VAR_0) {",
"return NULL;",
"}",
"drv = &qcrypto_hmac_lib_driver;",
"error_free(err2);",
"}",
"hmac = g_new0(QCryptoHmac, 1);",
"hmac->alg = alg;",
"hmac->opaque = VAR_0;",
"hmac->driver = (void *)drv;",
"return hmac;",
"}"
] | [
0,
0,
0,
1,
0,
1,
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
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
]
] |
24,549 | target_ulong do_load_msr (CPUPPCState *env)
{
return
#if defined (TARGET_PPC64)
((target_ulong)msr_sf << MSR_SF) |
((target_ulong)msr_isf << MSR_ISF) |
((target_ulong)msr_hv << MSR_HV) |
#endif
((target_ulong)msr_ucle << MSR_UCLE) |
((target_ulong)msr_vr << MSR_VR) | /* VR / SPE */
((target_ulong)msr_ap << MSR_AP) |
((target_ulong)msr_sa << MSR_SA) |
((target_ulong)msr_key << MSR_KEY) |
((target_ulong)msr_pow << MSR_POW) | /* POW / WE */
((target_ulong)msr_tgpr << MSR_TGPR) | /* TGPR / CE */
((target_ulong)msr_ile << MSR_ILE) |
((target_ulong)msr_ee << MSR_EE) |
((target_ulong)msr_pr << MSR_PR) |
((target_ulong)msr_fp << MSR_FP) |
((target_ulong)msr_me << MSR_ME) |
((target_ulong)msr_fe0 << MSR_FE0) |
((target_ulong)msr_se << MSR_SE) | /* SE / DWE / UBLE */
((target_ulong)msr_be << MSR_BE) | /* BE / DE */
((target_ulong)msr_fe1 << MSR_FE1) |
((target_ulong)msr_al << MSR_AL) |
((target_ulong)msr_ip << MSR_IP) |
((target_ulong)msr_ir << MSR_IR) | /* IR / IS */
((target_ulong)msr_dr << MSR_DR) | /* DR / DS */
((target_ulong)msr_pe << MSR_PE) | /* PE / EP */
((target_ulong)msr_px << MSR_PX) | /* PX / PMM */
((target_ulong)msr_ri << MSR_RI) |
((target_ulong)msr_le << MSR_LE);
}
| true | qemu | 25ba3a681213390e9212dbc987d61843c3b41d5b | target_ulong do_load_msr (CPUPPCState *env)
{
return
#if defined (TARGET_PPC64)
((target_ulong)msr_sf << MSR_SF) |
((target_ulong)msr_isf << MSR_ISF) |
((target_ulong)msr_hv << MSR_HV) |
#endif
((target_ulong)msr_ucle << MSR_UCLE) |
((target_ulong)msr_vr << MSR_VR) |
((target_ulong)msr_ap << MSR_AP) |
((target_ulong)msr_sa << MSR_SA) |
((target_ulong)msr_key << MSR_KEY) |
((target_ulong)msr_pow << MSR_POW) |
((target_ulong)msr_tgpr << MSR_TGPR) |
((target_ulong)msr_ile << MSR_ILE) |
((target_ulong)msr_ee << MSR_EE) |
((target_ulong)msr_pr << MSR_PR) |
((target_ulong)msr_fp << MSR_FP) |
((target_ulong)msr_me << MSR_ME) |
((target_ulong)msr_fe0 << MSR_FE0) |
((target_ulong)msr_se << MSR_SE) |
((target_ulong)msr_be << MSR_BE) |
((target_ulong)msr_fe1 << MSR_FE1) |
((target_ulong)msr_al << MSR_AL) |
((target_ulong)msr_ip << MSR_IP) |
((target_ulong)msr_ir << MSR_IR) |
((target_ulong)msr_dr << MSR_DR) |
((target_ulong)msr_pe << MSR_PE) |
((target_ulong)msr_px << MSR_PX) |
((target_ulong)msr_ri << MSR_RI) |
((target_ulong)msr_le << MSR_LE);
}
| {
"code": [
" ((target_ulong)msr_ip << MSR_IP) |"
],
"line_no": [
51
]
} | target_ulong FUNC_0 (CPUPPCState *env)
{
return
#if defined (TARGET_PPC64)
((target_ulong)msr_sf << MSR_SF) |
((target_ulong)msr_isf << MSR_ISF) |
((target_ulong)msr_hv << MSR_HV) |
#endif
((target_ulong)msr_ucle << MSR_UCLE) |
((target_ulong)msr_vr << MSR_VR) |
((target_ulong)msr_ap << MSR_AP) |
((target_ulong)msr_sa << MSR_SA) |
((target_ulong)msr_key << MSR_KEY) |
((target_ulong)msr_pow << MSR_POW) |
((target_ulong)msr_tgpr << MSR_TGPR) |
((target_ulong)msr_ile << MSR_ILE) |
((target_ulong)msr_ee << MSR_EE) |
((target_ulong)msr_pr << MSR_PR) |
((target_ulong)msr_fp << MSR_FP) |
((target_ulong)msr_me << MSR_ME) |
((target_ulong)msr_fe0 << MSR_FE0) |
((target_ulong)msr_se << MSR_SE) |
((target_ulong)msr_be << MSR_BE) |
((target_ulong)msr_fe1 << MSR_FE1) |
((target_ulong)msr_al << MSR_AL) |
((target_ulong)msr_ip << MSR_IP) |
((target_ulong)msr_ir << MSR_IR) |
((target_ulong)msr_dr << MSR_DR) |
((target_ulong)msr_pe << MSR_PE) |
((target_ulong)msr_px << MSR_PX) |
((target_ulong)msr_ri << MSR_RI) |
((target_ulong)msr_le << MSR_LE);
}
| [
"target_ulong FUNC_0 (CPUPPCState *env)\n{",
"return\n#if defined (TARGET_PPC64)\n((target_ulong)msr_sf << MSR_SF) |\n((target_ulong)msr_isf << MSR_ISF) |\n((target_ulong)msr_hv << MSR_HV) |\n#endif\n((target_ulong)msr_ucle << MSR_UCLE) |\n((target_ulong)msr_vr << MSR_VR) |\n((target_ulong)msr_ap << MSR_AP) |\n((target_ulong)msr_sa << MSR_SA) |\n((target_ulong)msr_key << MSR_KEY) |\n((target_ulong)msr_pow << MSR_POW) |\n((target_ulong)msr_tgpr << MSR_TGPR) |\n((target_ulong)msr_ile << MSR_ILE) |\n((target_ulong)msr_ee << MSR_EE) |\n((target_ulong)msr_pr << MSR_PR) |\n((target_ulong)msr_fp << MSR_FP) |\n((target_ulong)msr_me << MSR_ME) |\n((target_ulong)msr_fe0 << MSR_FE0) |\n((target_ulong)msr_se << MSR_SE) |\n((target_ulong)msr_be << MSR_BE) |\n((target_ulong)msr_fe1 << MSR_FE1) |\n((target_ulong)msr_al << MSR_AL) |\n((target_ulong)msr_ip << MSR_IP) |\n((target_ulong)msr_ir << MSR_IR) |\n((target_ulong)msr_dr << MSR_DR) |\n((target_ulong)msr_pe << MSR_PE) |\n((target_ulong)msr_px << MSR_PX) |\n((target_ulong)msr_ri << MSR_RI) |\n((target_ulong)msr_le << MSR_LE);",
"}"
] | [
0,
1,
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
]
] |
24,550 | static void unpack_alpha(GetBitContext *gb, uint16_t *dst, int num_coeffs,
const int num_bits)
{
const int mask = (1 << num_bits) - 1;
int i, idx, val, alpha_val;
idx = 0;
alpha_val = mask;
do {
do {
if (get_bits1(gb))
val = get_bits(gb, num_bits);
else {
int sign;
val = get_bits(gb, num_bits == 16 ? 7 : 4);
sign = val & 1;
val = (val + 2) >> 1;
if (sign)
val = -val;
}
alpha_val = (alpha_val + val) & mask;
if (num_bits == 16)
dst[idx++] = alpha_val >> 6;
else
dst[idx++] = (alpha_val << 2) | (alpha_val >> 6);
if (idx == num_coeffs - 1)
break;
} while (get_bits1(gb));
val = get_bits(gb, 4);
if (!val)
val = get_bits(gb, 11);
if (idx + val > num_coeffs)
val = num_coeffs - idx;
if (num_bits == 16)
for (i = 0; i < val; i++)
dst[idx++] = alpha_val >> 6;
else
for (i = 0; i < val; i++)
dst[idx++] = (alpha_val << 2) | (alpha_val >> 6);
} while (idx < num_coeffs);
}
| true | FFmpeg | ac9d159015a88aa2721b271875d18482f713f354 | static void unpack_alpha(GetBitContext *gb, uint16_t *dst, int num_coeffs,
const int num_bits)
{
const int mask = (1 << num_bits) - 1;
int i, idx, val, alpha_val;
idx = 0;
alpha_val = mask;
do {
do {
if (get_bits1(gb))
val = get_bits(gb, num_bits);
else {
int sign;
val = get_bits(gb, num_bits == 16 ? 7 : 4);
sign = val & 1;
val = (val + 2) >> 1;
if (sign)
val = -val;
}
alpha_val = (alpha_val + val) & mask;
if (num_bits == 16)
dst[idx++] = alpha_val >> 6;
else
dst[idx++] = (alpha_val << 2) | (alpha_val >> 6);
if (idx == num_coeffs - 1)
break;
} while (get_bits1(gb));
val = get_bits(gb, 4);
if (!val)
val = get_bits(gb, 11);
if (idx + val > num_coeffs)
val = num_coeffs - idx;
if (num_bits == 16)
for (i = 0; i < val; i++)
dst[idx++] = alpha_val >> 6;
else
for (i = 0; i < val; i++)
dst[idx++] = (alpha_val << 2) | (alpha_val >> 6);
} while (idx < num_coeffs);
}
| {
"code": [
" if (idx == num_coeffs - 1)"
],
"line_no": [
51
]
} | static void FUNC_0(GetBitContext *VAR_0, uint16_t *VAR_1, int VAR_2,
const int VAR_3)
{
const int VAR_4 = (1 << VAR_3) - 1;
int VAR_5, VAR_6, VAR_7, VAR_8;
VAR_6 = 0;
VAR_8 = VAR_4;
do {
do {
if (get_bits1(VAR_0))
VAR_7 = get_bits(VAR_0, VAR_3);
else {
int VAR_9;
VAR_7 = get_bits(VAR_0, VAR_3 == 16 ? 7 : 4);
VAR_9 = VAR_7 & 1;
VAR_7 = (VAR_7 + 2) >> 1;
if (VAR_9)
VAR_7 = -VAR_7;
}
VAR_8 = (VAR_8 + VAR_7) & VAR_4;
if (VAR_3 == 16)
VAR_1[VAR_6++] = VAR_8 >> 6;
else
VAR_1[VAR_6++] = (VAR_8 << 2) | (VAR_8 >> 6);
if (VAR_6 == VAR_2 - 1)
break;
} while (get_bits1(VAR_0));
VAR_7 = get_bits(VAR_0, 4);
if (!VAR_7)
VAR_7 = get_bits(VAR_0, 11);
if (VAR_6 + VAR_7 > VAR_2)
VAR_7 = VAR_2 - VAR_6;
if (VAR_3 == 16)
for (VAR_5 = 0; VAR_5 < VAR_7; VAR_5++)
VAR_1[VAR_6++] = VAR_8 >> 6;
else
for (VAR_5 = 0; VAR_5 < VAR_7; VAR_5++)
VAR_1[VAR_6++] = (VAR_8 << 2) | (VAR_8 >> 6);
} while (VAR_6 < VAR_2);
}
| [
"static void FUNC_0(GetBitContext *VAR_0, uint16_t *VAR_1, int VAR_2,\nconst int VAR_3)\n{",
"const int VAR_4 = (1 << VAR_3) - 1;",
"int VAR_5, VAR_6, VAR_7, VAR_8;",
"VAR_6 = 0;",
"VAR_8 = VAR_4;",
"do {",
"do {",
"if (get_bits1(VAR_0))\nVAR_7 = get_bits(VAR_0, VAR_3);",
"else {",
"int VAR_9;",
"VAR_7 = get_bits(VAR_0, VAR_3 == 16 ? 7 : 4);",
"VAR_9 = VAR_7 & 1;",
"VAR_7 = (VAR_7 + 2) >> 1;",
"if (VAR_9)\nVAR_7 = -VAR_7;",
"}",
"VAR_8 = (VAR_8 + VAR_7) & VAR_4;",
"if (VAR_3 == 16)\nVAR_1[VAR_6++] = VAR_8 >> 6;",
"else\nVAR_1[VAR_6++] = (VAR_8 << 2) | (VAR_8 >> 6);",
"if (VAR_6 == VAR_2 - 1)\nbreak;",
"} while (get_bits1(VAR_0));",
"VAR_7 = get_bits(VAR_0, 4);",
"if (!VAR_7)\nVAR_7 = get_bits(VAR_0, 11);",
"if (VAR_6 + VAR_7 > VAR_2)\nVAR_7 = VAR_2 - VAR_6;",
"if (VAR_3 == 16)\nfor (VAR_5 = 0; VAR_5 < VAR_7; VAR_5++)",
"VAR_1[VAR_6++] = VAR_8 >> 6;",
"else\nfor (VAR_5 = 0; VAR_5 < VAR_7; VAR_5++)",
"VAR_1[VAR_6++] = (VAR_8 << 2) | (VAR_8 >> 6);",
"} while (VAR_6 < VAR_2);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
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
]
] |
24,551 | bool desc_ring_set_size(DescRing *ring, uint32_t size)
{
int i;
if (size < 2 || size > 0x10000 || (size & (size - 1))) {
DPRINTF("ERROR: ring[%d] size (%d) not a power of 2 "
"or in range [2, 64K]\n", ring->index, size);
return false;
}
for (i = 0; i < ring->size; i++) {
g_free(ring->info[i].buf);
}
ring->size = size;
ring->head = ring->tail = 0;
ring->info = g_realloc(ring->info, size * sizeof(DescInfo));
if (!ring->info) {
return false;
}
memset(ring->info, 0, size * sizeof(DescInfo));
for (i = 0; i < size; i++) {
ring->info[i].ring = ring;
}
return true;
}
| true | qemu | 778358d0a8f74a76488daea3c1b6fb327d8135b4 | bool desc_ring_set_size(DescRing *ring, uint32_t size)
{
int i;
if (size < 2 || size > 0x10000 || (size & (size - 1))) {
DPRINTF("ERROR: ring[%d] size (%d) not a power of 2 "
"or in range [2, 64K]\n", ring->index, size);
return false;
}
for (i = 0; i < ring->size; i++) {
g_free(ring->info[i].buf);
}
ring->size = size;
ring->head = ring->tail = 0;
ring->info = g_realloc(ring->info, size * sizeof(DescInfo));
if (!ring->info) {
return false;
}
memset(ring->info, 0, size * sizeof(DescInfo));
for (i = 0; i < size; i++) {
ring->info[i].ring = ring;
}
return true;
}
| {
"code": [
" ring->info = g_realloc(ring->info, size * sizeof(DescInfo));"
],
"line_no": [
35
]
} | bool FUNC_0(DescRing *ring, uint32_t size)
{
int VAR_0;
if (size < 2 || size > 0x10000 || (size & (size - 1))) {
DPRINTF("ERROR: ring[%d] size (%d) not a power of 2 "
"or in range [2, 64K]\n", ring->index, size);
return false;
}
for (VAR_0 = 0; VAR_0 < ring->size; VAR_0++) {
g_free(ring->info[VAR_0].buf);
}
ring->size = size;
ring->head = ring->tail = 0;
ring->info = g_realloc(ring->info, size * sizeof(DescInfo));
if (!ring->info) {
return false;
}
memset(ring->info, 0, size * sizeof(DescInfo));
for (VAR_0 = 0; VAR_0 < size; VAR_0++) {
ring->info[VAR_0].ring = ring;
}
return true;
}
| [
"bool FUNC_0(DescRing *ring, uint32_t size)\n{",
"int VAR_0;",
"if (size < 2 || size > 0x10000 || (size & (size - 1))) {",
"DPRINTF(\"ERROR: ring[%d] size (%d) not a power of 2 \"\n\"or in range [2, 64K]\\n\", ring->index, size);",
"return false;",
"}",
"for (VAR_0 = 0; VAR_0 < ring->size; VAR_0++) {",
"g_free(ring->info[VAR_0].buf);",
"}",
"ring->size = size;",
"ring->head = ring->tail = 0;",
"ring->info = g_realloc(ring->info, size * sizeof(DescInfo));",
"if (!ring->info) {",
"return false;",
"}",
"memset(ring->info, 0, size * sizeof(DescInfo));",
"for (VAR_0 = 0; VAR_0 < size; VAR_0++) {",
"ring->info[VAR_0].ring = ring;",
"}",
"return true;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
]
] |
24,552 | static void gen_wsr_windowstart(DisasContext *dc, uint32_t sr, TCGv_i32 v)
{
tcg_gen_andi_i32(cpu_SR[sr], v, (1 << dc->config->nareg / 4) - 1);
reset_used_window(dc);
}
| true | qemu | 2db59a76c421cdd1039d10e32a9798952d3ff5ba | static void gen_wsr_windowstart(DisasContext *dc, uint32_t sr, TCGv_i32 v)
{
tcg_gen_andi_i32(cpu_SR[sr], v, (1 << dc->config->nareg / 4) - 1);
reset_used_window(dc);
}
| {
"code": [
" reset_used_window(dc);",
" reset_used_window(dc);",
" reset_used_window(dc);"
],
"line_no": [
7,
7,
7
]
} | static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1, TCGv_i32 VAR_2)
{
tcg_gen_andi_i32(cpu_SR[VAR_1], VAR_2, (1 << VAR_0->config->nareg / 4) - 1);
reset_used_window(VAR_0);
}
| [
"static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1, TCGv_i32 VAR_2)\n{",
"tcg_gen_andi_i32(cpu_SR[VAR_1], VAR_2, (1 << VAR_0->config->nareg / 4) - 1);",
"reset_used_window(VAR_0);",
"}"
] | [
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
24,553 | static void qemu_laio_process_completion(struct qemu_laiocb *laiocb)
{
int ret;
ret = laiocb->ret;
if (ret != -ECANCELED) {
if (ret == laiocb->nbytes) {
ret = 0;
} else if (ret >= 0) {
/* Short reads mean EOF, pad with zeros. */
if (laiocb->is_read) {
qemu_iovec_memset(laiocb->qiov, ret, 0,
laiocb->qiov->size - ret);
} else {
ret = -ENOSPC;
}
}
}
laiocb->ret = ret;
if (laiocb->co) {
/* Jump and continue completion for foreign requests, don't do
* anything for current request, it will be completed shortly. */
if (laiocb->co != qemu_coroutine_self()) {
qemu_coroutine_enter(laiocb->co);
}
} else {
laiocb->common.cb(laiocb->common.opaque, ret);
qemu_aio_unref(laiocb);
}
}
| true | qemu | fe121b9d3c4258e41f7efa4976bf79151b2d5dbb | static void qemu_laio_process_completion(struct qemu_laiocb *laiocb)
{
int ret;
ret = laiocb->ret;
if (ret != -ECANCELED) {
if (ret == laiocb->nbytes) {
ret = 0;
} else if (ret >= 0) {
if (laiocb->is_read) {
qemu_iovec_memset(laiocb->qiov, ret, 0,
laiocb->qiov->size - ret);
} else {
ret = -ENOSPC;
}
}
}
laiocb->ret = ret;
if (laiocb->co) {
if (laiocb->co != qemu_coroutine_self()) {
qemu_coroutine_enter(laiocb->co);
}
} else {
laiocb->common.cb(laiocb->common.opaque, ret);
qemu_aio_unref(laiocb);
}
}
| {
"code": [
" if (laiocb->co != qemu_coroutine_self()) {"
],
"line_no": [
47
]
} | static void FUNC_0(struct qemu_laiocb *VAR_0)
{
int VAR_1;
VAR_1 = VAR_0->VAR_1;
if (VAR_1 != -ECANCELED) {
if (VAR_1 == VAR_0->nbytes) {
VAR_1 = 0;
} else if (VAR_1 >= 0) {
if (VAR_0->is_read) {
qemu_iovec_memset(VAR_0->qiov, VAR_1, 0,
VAR_0->qiov->size - VAR_1);
} else {
VAR_1 = -ENOSPC;
}
}
}
VAR_0->VAR_1 = VAR_1;
if (VAR_0->co) {
if (VAR_0->co != qemu_coroutine_self()) {
qemu_coroutine_enter(VAR_0->co);
}
} else {
VAR_0->common.cb(VAR_0->common.opaque, VAR_1);
qemu_aio_unref(VAR_0);
}
}
| [
"static void FUNC_0(struct qemu_laiocb *VAR_0)\n{",
"int VAR_1;",
"VAR_1 = VAR_0->VAR_1;",
"if (VAR_1 != -ECANCELED) {",
"if (VAR_1 == VAR_0->nbytes) {",
"VAR_1 = 0;",
"} else if (VAR_1 >= 0) {",
"if (VAR_0->is_read) {",
"qemu_iovec_memset(VAR_0->qiov, VAR_1, 0,\nVAR_0->qiov->size - VAR_1);",
"} else {",
"VAR_1 = -ENOSPC;",
"}",
"}",
"}",
"VAR_0->VAR_1 = VAR_1;",
"if (VAR_0->co) {",
"if (VAR_0->co != qemu_coroutine_self()) {",
"qemu_coroutine_enter(VAR_0->co);",
"}",
"} else {",
"VAR_0->common.cb(VAR_0->common.opaque, VAR_1);",
"qemu_aio_unref(VAR_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
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
]
] |
24,554 | static uint32_t msix_mmio_readl(void *opaque, target_phys_addr_t addr)
{
PCIDevice *dev = opaque;
unsigned int offset = addr & (MSIX_PAGE_SIZE - 1);
void *page = dev->msix_table_page;
uint32_t val = 0;
memcpy(&val, (void *)((char *)page + offset), 4);
return val;
}
| true | qemu | 76f5159d7fc4cdea9574dfbb54307735b280bc66 | static uint32_t msix_mmio_readl(void *opaque, target_phys_addr_t addr)
{
PCIDevice *dev = opaque;
unsigned int offset = addr & (MSIX_PAGE_SIZE - 1);
void *page = dev->msix_table_page;
uint32_t val = 0;
memcpy(&val, (void *)((char *)page + offset), 4);
return val;
}
| {
"code": [
" unsigned int offset = addr & (MSIX_PAGE_SIZE - 1);",
" uint32_t val = 0;",
" memcpy(&val, (void *)((char *)page + offset), 4);",
" return val;",
" unsigned int offset = addr & (MSIX_PAGE_SIZE - 1);"
],
"line_no": [
7,
11,
15,
19,
7
]
} | static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)
{
PCIDevice *dev = opaque;
unsigned int VAR_0 = addr & (MSIX_PAGE_SIZE - 1);
void *VAR_1 = dev->msix_table_page;
uint32_t val = 0;
memcpy(&val, (void *)((char *)VAR_1 + VAR_0), 4);
return val;
}
| [
"static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)\n{",
"PCIDevice *dev = opaque;",
"unsigned int VAR_0 = addr & (MSIX_PAGE_SIZE - 1);",
"void *VAR_1 = dev->msix_table_page;",
"uint32_t val = 0;",
"memcpy(&val, (void *)((char *)VAR_1 + VAR_0), 4);",
"return val;",
"}"
] | [
0,
0,
1,
0,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
]
] |
24,556 | int attribute_align_arg avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)
{
int ret;
if (!avcodec_is_open(avctx) || !av_codec_is_decoder(avctx->codec))
return AVERROR(EINVAL);
if (avctx->internal->draining)
return AVERROR_EOF;
if (!avpkt || !avpkt->size) {
avctx->internal->draining = 1;
avpkt = NULL;
if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY))
return 0;
}
if (avctx->codec->send_packet) {
if (avpkt) {
ret = apply_param_change(avctx, (AVPacket *)avpkt);
if (ret < 0)
return ret;
}
return avctx->codec->send_packet(avctx, avpkt);
}
// Emulation via old API. Assume avpkt is likely not refcounted, while
// decoder output is always refcounted, and avoid copying.
if (avctx->internal->buffer_pkt->size || avctx->internal->buffer_frame->buf[0])
return AVERROR(EAGAIN);
// The goal is decoding the first frame of the packet without using memcpy,
// because the common case is having only 1 frame per packet (especially
// with video, but audio too). In other cases, it can't be avoided, unless
// the user is feeding refcounted packets.
return do_decode(avctx, (AVPacket *)avpkt);
}
| true | FFmpeg | 66dd21d50be14a355e296b769d9d99090c0207f7 | int attribute_align_arg avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)
{
int ret;
if (!avcodec_is_open(avctx) || !av_codec_is_decoder(avctx->codec))
return AVERROR(EINVAL);
if (avctx->internal->draining)
return AVERROR_EOF;
if (!avpkt || !avpkt->size) {
avctx->internal->draining = 1;
avpkt = NULL;
if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY))
return 0;
}
if (avctx->codec->send_packet) {
if (avpkt) {
ret = apply_param_change(avctx, (AVPacket *)avpkt);
if (ret < 0)
return ret;
}
return avctx->codec->send_packet(avctx, avpkt);
}
if (avctx->internal->buffer_pkt->size || avctx->internal->buffer_frame->buf[0])
return AVERROR(EAGAIN);
return do_decode(avctx, (AVPacket *)avpkt);
}
| {
"code": [
" ret = apply_param_change(avctx, (AVPacket *)avpkt);",
" if (ret < 0)",
" return ret;",
" return avctx->codec->send_packet(avctx, avpkt);"
],
"line_no": [
41,
43,
45,
49
]
} | int VAR_0 avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)
{
int ret;
if (!avcodec_is_open(avctx) || !av_codec_is_decoder(avctx->codec))
return AVERROR(EINVAL);
if (avctx->internal->draining)
return AVERROR_EOF;
if (!avpkt || !avpkt->size) {
avctx->internal->draining = 1;
avpkt = NULL;
if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY))
return 0;
}
if (avctx->codec->send_packet) {
if (avpkt) {
ret = apply_param_change(avctx, (AVPacket *)avpkt);
if (ret < 0)
return ret;
}
return avctx->codec->send_packet(avctx, avpkt);
}
if (avctx->internal->buffer_pkt->size || avctx->internal->buffer_frame->buf[0])
return AVERROR(EAGAIN);
return do_decode(avctx, (AVPacket *)avpkt);
}
| [
"int VAR_0 avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)\n{",
"int ret;",
"if (!avcodec_is_open(avctx) || !av_codec_is_decoder(avctx->codec))\nreturn AVERROR(EINVAL);",
"if (avctx->internal->draining)\nreturn AVERROR_EOF;",
"if (!avpkt || !avpkt->size) {",
"avctx->internal->draining = 1;",
"avpkt = NULL;",
"if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY))\nreturn 0;",
"}",
"if (avctx->codec->send_packet) {",
"if (avpkt) {",
"ret = apply_param_change(avctx, (AVPacket *)avpkt);",
"if (ret < 0)\nreturn ret;",
"}",
"return avctx->codec->send_packet(avctx, avpkt);",
"}",
"if (avctx->internal->buffer_pkt->size || avctx->internal->buffer_frame->buf[0])\nreturn AVERROR(EAGAIN);",
"return do_decode(avctx, (AVPacket *)avpkt);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
15,
17
],
[
21
],
[
23
],
[
25
],
[
29,
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
61,
63
],
[
75
],
[
77
]
] |
24,557 | static int asf_read_stream_properties(AVFormatContext *s, const GUIDParseTable *g)
{
ASFContext *asf = s->priv_data;
AVIOContext *pb = s->pb;
uint64_t size;
uint32_t err_data_len, ts_data_len; // type specific data length
uint16_t flags;
ff_asf_guid stream_type;
enum AVMediaType type;
int i, ret;
uint8_t stream_index;
AVStream *st;
ASFStream *asf_st;
// ASF file must not contain more than 128 streams according to the specification
if (asf->nb_streams >= ASF_MAX_STREAMS)
return AVERROR_INVALIDDATA;
size = avio_rl64(pb);
ff_get_guid(pb, &stream_type);
if (!ff_guidcmp(&stream_type, &ff_asf_audio_stream))
type = AVMEDIA_TYPE_AUDIO;
else if (!ff_guidcmp(&stream_type, &ff_asf_video_stream))
type = AVMEDIA_TYPE_VIDEO;
else if (!ff_guidcmp(&stream_type, &ff_asf_jfif_media))
type = AVMEDIA_TYPE_VIDEO;
else if (!ff_guidcmp(&stream_type, &ff_asf_command_stream))
type = AVMEDIA_TYPE_DATA;
else if (!ff_guidcmp(&stream_type,
&ff_asf_ext_stream_embed_stream_header))
type = AVMEDIA_TYPE_UNKNOWN;
else
return AVERROR_INVALIDDATA;
ff_get_guid(pb, &stream_type); // error correction type
avio_skip(pb, 8); // skip the time offset
ts_data_len = avio_rl32(pb);
err_data_len = avio_rl32(pb);
flags = avio_rl16(pb); // bit 15 - Encrypted Content
stream_index = flags & ASF_STREAM_NUM;
for (i = 0; i < asf->nb_streams; i++)
if (stream_index == asf->asf_st[i]->stream_index) {
av_log(s, AV_LOG_WARNING,
"Duplicate stream found, this stream will be ignored.\n");
align_position(pb, asf->offset, size);
return 0;
}
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 32, 1, 1000); // pts should be dword, in milliseconds
st->codec->codec_type = type;
asf->asf_st[asf->nb_streams] = av_mallocz(sizeof(*asf_st));
if (!asf->asf_st[asf->nb_streams])
return AVERROR(ENOMEM);
asf_st = asf->asf_st[asf->nb_streams];
asf_st->stream_index = stream_index;
asf_st->index = st->index;
asf_st->indexed = 0;
st->id = flags & ASF_STREAM_NUM;
av_init_packet(&asf_st->pkt.avpkt);
asf_st->pkt.data_size = 0;
avio_skip(pb, 4); // skip reserved field
switch (type) {
case AVMEDIA_TYPE_AUDIO:
asf_st->type = AVMEDIA_TYPE_AUDIO;
if ((ret = ff_get_wav_header(s, pb, st->codec, ts_data_len)) < 0)
return ret;
break;
case AVMEDIA_TYPE_VIDEO:
asf_st->type = AVMEDIA_TYPE_VIDEO;
if ((ret = parse_video_info(pb, st)) < 0)
return ret;
break;
default:
avio_skip(pb, ts_data_len);
break;
}
if (err_data_len) {
if (type == AVMEDIA_TYPE_AUDIO) {
uint8_t span = avio_r8(pb);
if (span > 1) {
asf_st->span = span;
asf_st->virtual_pkt_len = avio_rl16(pb);
asf_st->virtual_chunk_len = avio_rl16(pb);
if (!asf_st->virtual_chunk_len || !asf_st->virtual_pkt_len)
return AVERROR_INVALIDDATA;
avio_skip(pb, err_data_len - 5);
} else
avio_skip(pb, err_data_len - 1);
} else
avio_skip(pb, err_data_len);
}
asf->nb_streams++;
align_position(pb, asf->offset, size);
return 0;
}
| true | FFmpeg | aed7715b8fa295980c221f1cd095d42cd3bd74a6 | static int asf_read_stream_properties(AVFormatContext *s, const GUIDParseTable *g)
{
ASFContext *asf = s->priv_data;
AVIOContext *pb = s->pb;
uint64_t size;
uint32_t err_data_len, ts_data_len;
uint16_t flags;
ff_asf_guid stream_type;
enum AVMediaType type;
int i, ret;
uint8_t stream_index;
AVStream *st;
ASFStream *asf_st;
if (asf->nb_streams >= ASF_MAX_STREAMS)
return AVERROR_INVALIDDATA;
size = avio_rl64(pb);
ff_get_guid(pb, &stream_type);
if (!ff_guidcmp(&stream_type, &ff_asf_audio_stream))
type = AVMEDIA_TYPE_AUDIO;
else if (!ff_guidcmp(&stream_type, &ff_asf_video_stream))
type = AVMEDIA_TYPE_VIDEO;
else if (!ff_guidcmp(&stream_type, &ff_asf_jfif_media))
type = AVMEDIA_TYPE_VIDEO;
else if (!ff_guidcmp(&stream_type, &ff_asf_command_stream))
type = AVMEDIA_TYPE_DATA;
else if (!ff_guidcmp(&stream_type,
&ff_asf_ext_stream_embed_stream_header))
type = AVMEDIA_TYPE_UNKNOWN;
else
return AVERROR_INVALIDDATA;
ff_get_guid(pb, &stream_type);
avio_skip(pb, 8);
ts_data_len = avio_rl32(pb);
err_data_len = avio_rl32(pb);
flags = avio_rl16(pb);
stream_index = flags & ASF_STREAM_NUM;
for (i = 0; i < asf->nb_streams; i++)
if (stream_index == asf->asf_st[i]->stream_index) {
av_log(s, AV_LOG_WARNING,
"Duplicate stream found, this stream will be ignored.\n");
align_position(pb, asf->offset, size);
return 0;
}
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 32, 1, 1000);
st->codec->codec_type = type;
asf->asf_st[asf->nb_streams] = av_mallocz(sizeof(*asf_st));
if (!asf->asf_st[asf->nb_streams])
return AVERROR(ENOMEM);
asf_st = asf->asf_st[asf->nb_streams];
asf_st->stream_index = stream_index;
asf_st->index = st->index;
asf_st->indexed = 0;
st->id = flags & ASF_STREAM_NUM;
av_init_packet(&asf_st->pkt.avpkt);
asf_st->pkt.data_size = 0;
avio_skip(pb, 4);
switch (type) {
case AVMEDIA_TYPE_AUDIO:
asf_st->type = AVMEDIA_TYPE_AUDIO;
if ((ret = ff_get_wav_header(s, pb, st->codec, ts_data_len)) < 0)
return ret;
break;
case AVMEDIA_TYPE_VIDEO:
asf_st->type = AVMEDIA_TYPE_VIDEO;
if ((ret = parse_video_info(pb, st)) < 0)
return ret;
break;
default:
avio_skip(pb, ts_data_len);
break;
}
if (err_data_len) {
if (type == AVMEDIA_TYPE_AUDIO) {
uint8_t span = avio_r8(pb);
if (span > 1) {
asf_st->span = span;
asf_st->virtual_pkt_len = avio_rl16(pb);
asf_st->virtual_chunk_len = avio_rl16(pb);
if (!asf_st->virtual_chunk_len || !asf_st->virtual_pkt_len)
return AVERROR_INVALIDDATA;
avio_skip(pb, err_data_len - 5);
} else
avio_skip(pb, err_data_len - 1);
} else
avio_skip(pb, err_data_len);
}
asf->nb_streams++;
align_position(pb, asf->offset, size);
return 0;
}
| {
"code": [
" asf->nb_streams++;"
],
"line_no": [
197
]
} | static int FUNC_0(AVFormatContext *VAR_0, const GUIDParseTable *VAR_1)
{
ASFContext *asf = VAR_0->priv_data;
AVIOContext *pb = VAR_0->pb;
uint64_t size;
uint32_t err_data_len, ts_data_len;
uint16_t flags;
ff_asf_guid stream_type;
enum AVMediaType VAR_2;
int VAR_3, VAR_4;
uint8_t stream_index;
AVStream *st;
ASFStream *asf_st;
if (asf->nb_streams >= ASF_MAX_STREAMS)
return AVERROR_INVALIDDATA;
size = avio_rl64(pb);
ff_get_guid(pb, &stream_type);
if (!ff_guidcmp(&stream_type, &ff_asf_audio_stream))
VAR_2 = AVMEDIA_TYPE_AUDIO;
else if (!ff_guidcmp(&stream_type, &ff_asf_video_stream))
VAR_2 = AVMEDIA_TYPE_VIDEO;
else if (!ff_guidcmp(&stream_type, &ff_asf_jfif_media))
VAR_2 = AVMEDIA_TYPE_VIDEO;
else if (!ff_guidcmp(&stream_type, &ff_asf_command_stream))
VAR_2 = AVMEDIA_TYPE_DATA;
else if (!ff_guidcmp(&stream_type,
&ff_asf_ext_stream_embed_stream_header))
VAR_2 = AVMEDIA_TYPE_UNKNOWN;
else
return AVERROR_INVALIDDATA;
ff_get_guid(pb, &stream_type);
avio_skip(pb, 8);
ts_data_len = avio_rl32(pb);
err_data_len = avio_rl32(pb);
flags = avio_rl16(pb);
stream_index = flags & ASF_STREAM_NUM;
for (VAR_3 = 0; VAR_3 < asf->nb_streams; VAR_3++)
if (stream_index == asf->asf_st[VAR_3]->stream_index) {
av_log(VAR_0, AV_LOG_WARNING,
"Duplicate stream found, this stream will be ignored.\n");
align_position(pb, asf->offset, size);
return 0;
}
st = avformat_new_stream(VAR_0, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 32, 1, 1000);
st->codec->codec_type = VAR_2;
asf->asf_st[asf->nb_streams] = av_mallocz(sizeof(*asf_st));
if (!asf->asf_st[asf->nb_streams])
return AVERROR(ENOMEM);
asf_st = asf->asf_st[asf->nb_streams];
asf_st->stream_index = stream_index;
asf_st->index = st->index;
asf_st->indexed = 0;
st->id = flags & ASF_STREAM_NUM;
av_init_packet(&asf_st->pkt.avpkt);
asf_st->pkt.data_size = 0;
avio_skip(pb, 4);
switch (VAR_2) {
case AVMEDIA_TYPE_AUDIO:
asf_st->VAR_2 = AVMEDIA_TYPE_AUDIO;
if ((VAR_4 = ff_get_wav_header(VAR_0, pb, st->codec, ts_data_len)) < 0)
return VAR_4;
break;
case AVMEDIA_TYPE_VIDEO:
asf_st->VAR_2 = AVMEDIA_TYPE_VIDEO;
if ((VAR_4 = parse_video_info(pb, st)) < 0)
return VAR_4;
break;
default:
avio_skip(pb, ts_data_len);
break;
}
if (err_data_len) {
if (VAR_2 == AVMEDIA_TYPE_AUDIO) {
uint8_t span = avio_r8(pb);
if (span > 1) {
asf_st->span = span;
asf_st->virtual_pkt_len = avio_rl16(pb);
asf_st->virtual_chunk_len = avio_rl16(pb);
if (!asf_st->virtual_chunk_len || !asf_st->virtual_pkt_len)
return AVERROR_INVALIDDATA;
avio_skip(pb, err_data_len - 5);
} else
avio_skip(pb, err_data_len - 1);
} else
avio_skip(pb, err_data_len);
}
asf->nb_streams++;
align_position(pb, asf->offset, size);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, const GUIDParseTable *VAR_1)\n{",
"ASFContext *asf = VAR_0->priv_data;",
"AVIOContext *pb = VAR_0->pb;",
"uint64_t size;",
"uint32_t err_data_len, ts_data_len;",
"uint16_t flags;",
"ff_asf_guid stream_type;",
"enum AVMediaType VAR_2;",
"int VAR_3, VAR_4;",
"uint8_t stream_index;",
"AVStream *st;",
"ASFStream *asf_st;",
"if (asf->nb_streams >= ASF_MAX_STREAMS)\nreturn AVERROR_INVALIDDATA;",
"size = avio_rl64(pb);",
"ff_get_guid(pb, &stream_type);",
"if (!ff_guidcmp(&stream_type, &ff_asf_audio_stream))\nVAR_2 = AVMEDIA_TYPE_AUDIO;",
"else if (!ff_guidcmp(&stream_type, &ff_asf_video_stream))\nVAR_2 = AVMEDIA_TYPE_VIDEO;",
"else if (!ff_guidcmp(&stream_type, &ff_asf_jfif_media))\nVAR_2 = AVMEDIA_TYPE_VIDEO;",
"else if (!ff_guidcmp(&stream_type, &ff_asf_command_stream))\nVAR_2 = AVMEDIA_TYPE_DATA;",
"else if (!ff_guidcmp(&stream_type,\n&ff_asf_ext_stream_embed_stream_header))\nVAR_2 = AVMEDIA_TYPE_UNKNOWN;",
"else\nreturn AVERROR_INVALIDDATA;",
"ff_get_guid(pb, &stream_type);",
"avio_skip(pb, 8);",
"ts_data_len = avio_rl32(pb);",
"err_data_len = avio_rl32(pb);",
"flags = avio_rl16(pb);",
"stream_index = flags & ASF_STREAM_NUM;",
"for (VAR_3 = 0; VAR_3 < asf->nb_streams; VAR_3++)",
"if (stream_index == asf->asf_st[VAR_3]->stream_index) {",
"av_log(VAR_0, AV_LOG_WARNING,\n\"Duplicate stream found, this stream will be ignored.\\n\");",
"align_position(pb, asf->offset, size);",
"return 0;",
"}",
"st = avformat_new_stream(VAR_0, NULL);",
"if (!st)\nreturn AVERROR(ENOMEM);",
"avpriv_set_pts_info(st, 32, 1, 1000);",
"st->codec->codec_type = VAR_2;",
"asf->asf_st[asf->nb_streams] = av_mallocz(sizeof(*asf_st));",
"if (!asf->asf_st[asf->nb_streams])\nreturn AVERROR(ENOMEM);",
"asf_st = asf->asf_st[asf->nb_streams];",
"asf_st->stream_index = stream_index;",
"asf_st->index = st->index;",
"asf_st->indexed = 0;",
"st->id = flags & ASF_STREAM_NUM;",
"av_init_packet(&asf_st->pkt.avpkt);",
"asf_st->pkt.data_size = 0;",
"avio_skip(pb, 4);",
"switch (VAR_2) {",
"case AVMEDIA_TYPE_AUDIO:\nasf_st->VAR_2 = AVMEDIA_TYPE_AUDIO;",
"if ((VAR_4 = ff_get_wav_header(VAR_0, pb, st->codec, ts_data_len)) < 0)\nreturn VAR_4;",
"break;",
"case AVMEDIA_TYPE_VIDEO:\nasf_st->VAR_2 = AVMEDIA_TYPE_VIDEO;",
"if ((VAR_4 = parse_video_info(pb, st)) < 0)\nreturn VAR_4;",
"break;",
"default:\navio_skip(pb, ts_data_len);",
"break;",
"}",
"if (err_data_len) {",
"if (VAR_2 == AVMEDIA_TYPE_AUDIO) {",
"uint8_t span = avio_r8(pb);",
"if (span > 1) {",
"asf_st->span = span;",
"asf_st->virtual_pkt_len = avio_rl16(pb);",
"asf_st->virtual_chunk_len = avio_rl16(pb);",
"if (!asf_st->virtual_chunk_len || !asf_st->virtual_pkt_len)\nreturn AVERROR_INVALIDDATA;",
"avio_skip(pb, err_data_len - 5);",
"} else",
"avio_skip(pb, err_data_len - 1);",
"} else",
"avio_skip(pb, err_data_len);",
"}",
"asf->nb_streams++;",
"align_position(pb, asf->offset, size);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
31,
33
],
[
37
],
[
39
],
[
41,
43
],
[
45,
47
],
[
49,
51
],
[
53,
55
],
[
57,
59,
61
],
[
63,
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87,
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101,
103
],
[
105
],
[
107
],
[
109
],
[
111,
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133
],
[
135,
137
],
[
139,
141
],
[
143
],
[
145,
147
],
[
149,
151
],
[
153
],
[
155,
157
],
[
159
],
[
161
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179,
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
197
],
[
199
],
[
203
],
[
205
]
] |
24,560 | static ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src,
size_t srclen)
{
z_stream s;
ssize_t dstbytes;
int r, i, flags;
/* skip header */
i = 10;
flags = src[3];
if (src[2] != DEFLATED || (flags & RESERVED) != 0) {
puts ("Error: Bad gzipped data\n");
return -1;
}
if ((flags & EXTRA_FIELD) != 0)
i = 12 + src[10] + (src[11] << 8);
if ((flags & ORIG_NAME) != 0)
while (src[i++] != 0)
;
if ((flags & COMMENT) != 0)
while (src[i++] != 0)
;
if ((flags & HEAD_CRC) != 0)
i += 2;
if (i >= srclen) {
puts ("Error: gunzip out of data in header\n");
return -1;
}
s.zalloc = zalloc;
s.zfree = zfree;
r = inflateInit2(&s, -MAX_WBITS);
if (r != Z_OK) {
printf ("Error: inflateInit2() returned %d\n", r);
return (-1);
}
s.next_in = src + i;
s.avail_in = srclen - i;
s.next_out = dst;
s.avail_out = dstlen;
r = inflate(&s, Z_FINISH);
if (r != Z_OK && r != Z_STREAM_END) {
printf ("Error: inflate() returned %d\n", r);
return -1;
}
dstbytes = s.next_out - (unsigned char *) dst;
inflateEnd(&s);
return dstbytes;
}
| true | qemu | 51b58561c1dacdb0ce999ada94912caaed157f83 | static ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src,
size_t srclen)
{
z_stream s;
ssize_t dstbytes;
int r, i, flags;
i = 10;
flags = src[3];
if (src[2] != DEFLATED || (flags & RESERVED) != 0) {
puts ("Error: Bad gzipped data\n");
return -1;
}
if ((flags & EXTRA_FIELD) != 0)
i = 12 + src[10] + (src[11] << 8);
if ((flags & ORIG_NAME) != 0)
while (src[i++] != 0)
;
if ((flags & COMMENT) != 0)
while (src[i++] != 0)
;
if ((flags & HEAD_CRC) != 0)
i += 2;
if (i >= srclen) {
puts ("Error: gunzip out of data in header\n");
return -1;
}
s.zalloc = zalloc;
s.zfree = zfree;
r = inflateInit2(&s, -MAX_WBITS);
if (r != Z_OK) {
printf ("Error: inflateInit2() returned %d\n", r);
return (-1);
}
s.next_in = src + i;
s.avail_in = srclen - i;
s.next_out = dst;
s.avail_out = dstlen;
r = inflate(&s, Z_FINISH);
if (r != Z_OK && r != Z_STREAM_END) {
printf ("Error: inflate() returned %d\n", r);
return -1;
}
dstbytes = s.next_out - (unsigned char *) dst;
inflateEnd(&s);
return dstbytes;
}
| {
"code": [
"static ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src,",
" size_t srclen)"
],
"line_no": [
1,
3
]
} | static ssize_t FUNC_0(void *dst, size_t dstlen, uint8_t *src,
size_t srclen)
{
z_stream s;
ssize_t dstbytes;
int VAR_0, VAR_1, VAR_2;
VAR_1 = 10;
VAR_2 = src[3];
if (src[2] != DEFLATED || (VAR_2 & RESERVED) != 0) {
puts ("Error: Bad gzipped data\n");
return -1;
}
if ((VAR_2 & EXTRA_FIELD) != 0)
VAR_1 = 12 + src[10] + (src[11] << 8);
if ((VAR_2 & ORIG_NAME) != 0)
while (src[VAR_1++] != 0)
;
if ((VAR_2 & COMMENT) != 0)
while (src[VAR_1++] != 0)
;
if ((VAR_2 & HEAD_CRC) != 0)
VAR_1 += 2;
if (VAR_1 >= srclen) {
puts ("Error: FUNC_0 out of data in header\n");
return -1;
}
s.zalloc = zalloc;
s.zfree = zfree;
VAR_0 = inflateInit2(&s, -MAX_WBITS);
if (VAR_0 != Z_OK) {
printf ("Error: inflateInit2() returned %d\n", VAR_0);
return (-1);
}
s.next_in = src + VAR_1;
s.avail_in = srclen - VAR_1;
s.next_out = dst;
s.avail_out = dstlen;
VAR_0 = inflate(&s, Z_FINISH);
if (VAR_0 != Z_OK && VAR_0 != Z_STREAM_END) {
printf ("Error: inflate() returned %d\n", VAR_0);
return -1;
}
dstbytes = s.next_out - (unsigned char *) dst;
inflateEnd(&s);
return dstbytes;
}
| [
"static ssize_t FUNC_0(void *dst, size_t dstlen, uint8_t *src,\nsize_t srclen)\n{",
"z_stream s;",
"ssize_t dstbytes;",
"int VAR_0, VAR_1, VAR_2;",
"VAR_1 = 10;",
"VAR_2 = src[3];",
"if (src[2] != DEFLATED || (VAR_2 & RESERVED) != 0) {",
"puts (\"Error: Bad gzipped data\\n\");",
"return -1;",
"}",
"if ((VAR_2 & EXTRA_FIELD) != 0)\nVAR_1 = 12 + src[10] + (src[11] << 8);",
"if ((VAR_2 & ORIG_NAME) != 0)\nwhile (src[VAR_1++] != 0)\n;",
"if ((VAR_2 & COMMENT) != 0)\nwhile (src[VAR_1++] != 0)\n;",
"if ((VAR_2 & HEAD_CRC) != 0)\nVAR_1 += 2;",
"if (VAR_1 >= srclen) {",
"puts (\"Error: FUNC_0 out of data in header\\n\");",
"return -1;",
"}",
"s.zalloc = zalloc;",
"s.zfree = zfree;",
"VAR_0 = inflateInit2(&s, -MAX_WBITS);",
"if (VAR_0 != Z_OK) {",
"printf (\"Error: inflateInit2() returned %d\\n\", VAR_0);",
"return (-1);",
"}",
"s.next_in = src + VAR_1;",
"s.avail_in = srclen - VAR_1;",
"s.next_out = dst;",
"s.avail_out = dstlen;",
"VAR_0 = inflate(&s, Z_FINISH);",
"if (VAR_0 != Z_OK && VAR_0 != Z_STREAM_END) {",
"printf (\"Error: inflate() returned %d\\n\", VAR_0);",
"return -1;",
"}",
"dstbytes = s.next_out - (unsigned char *) dst;",
"inflateEnd(&s);",
"return dstbytes;",
"}"
] | [
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
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29,
31
],
[
33,
35,
37
],
[
39,
41,
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
]
] |
24,561 | int check_tm_pred8x8_mode(int mode, int mb_x, int mb_y)
{
if (!mb_x)
return mb_y ? VERT_PRED8x8 : DC_129_PRED8x8;
else
return mb_y ? mode : HOR_PRED8x8;
}
| true | FFmpeg | ac4b32df71bd932838043a4838b86d11e169707f | int check_tm_pred8x8_mode(int mode, int mb_x, int mb_y)
{
if (!mb_x)
return mb_y ? VERT_PRED8x8 : DC_129_PRED8x8;
else
return mb_y ? mode : HOR_PRED8x8;
}
| {
"code": [
"int check_tm_pred8x8_mode(int mode, int mb_x, int mb_y)",
" return mb_y ? VERT_PRED8x8 : DC_129_PRED8x8;"
],
"line_no": [
1,
7
]
} | int FUNC_0(int VAR_0, int VAR_1, int VAR_2)
{
if (!VAR_1)
return VAR_2 ? VERT_PRED8x8 : DC_129_PRED8x8;
else
return VAR_2 ? VAR_0 : HOR_PRED8x8;
}
| [
"int FUNC_0(int VAR_0, int VAR_1, int VAR_2)\n{",
"if (!VAR_1)\nreturn VAR_2 ? VERT_PRED8x8 : DC_129_PRED8x8;",
"else\nreturn VAR_2 ? VAR_0 : HOR_PRED8x8;",
"}"
] | [
1,
1,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9,
11
],
[
13
]
] |
24,562 | static void omap_i2c_recv(I2CAdapter *i2c, uint8_t addr,
uint8_t *buf, uint16_t len)
{
OMAPI2C *s = (OMAPI2C *)i2c;
uint16_t data, stat;
omap_i2c_set_slave_addr(s, addr);
data = len;
memwrite(s->addr + OMAP_I2C_CNT, &data, 2);
data = OMAP_I2C_CON_I2C_EN |
OMAP_I2C_CON_MST |
OMAP_I2C_CON_STT |
OMAP_I2C_CON_STP;
memwrite(s->addr + OMAP_I2C_CON, &data, 2);
memread(s->addr + OMAP_I2C_CON, &data, 2);
g_assert((data & OMAP_I2C_CON_STP) == 0);
memread(s->addr + OMAP_I2C_STAT, &data, 2);
g_assert((data & OMAP_I2C_STAT_NACK) == 0);
memread(s->addr + OMAP_I2C_CNT, &data, 2);
g_assert_cmpuint(data, ==, len);
while (len > 0) {
memread(s->addr + OMAP_I2C_STAT, &data, 2);
g_assert((data & OMAP_I2C_STAT_RRDY) != 0);
g_assert((data & OMAP_I2C_STAT_ROVR) == 0);
memread(s->addr + OMAP_I2C_DATA, &data, 2);
memread(s->addr + OMAP_I2C_STAT, &stat, 2);
if (unlikely(len == 1)) {
*buf = data & 0xf;
buf++;
len--;
} else {
memcpy(buf, &data, 2);
buf += 2;
len -= 2;
}
}
memread(s->addr + OMAP_I2C_CON, &data, 2);
g_assert((data & OMAP_I2C_CON_STP) == 0);
}
| true | qemu | d0bce760e04b1658a3b4ac95be2839ae20fd86db | static void omap_i2c_recv(I2CAdapter *i2c, uint8_t addr,
uint8_t *buf, uint16_t len)
{
OMAPI2C *s = (OMAPI2C *)i2c;
uint16_t data, stat;
omap_i2c_set_slave_addr(s, addr);
data = len;
memwrite(s->addr + OMAP_I2C_CNT, &data, 2);
data = OMAP_I2C_CON_I2C_EN |
OMAP_I2C_CON_MST |
OMAP_I2C_CON_STT |
OMAP_I2C_CON_STP;
memwrite(s->addr + OMAP_I2C_CON, &data, 2);
memread(s->addr + OMAP_I2C_CON, &data, 2);
g_assert((data & OMAP_I2C_CON_STP) == 0);
memread(s->addr + OMAP_I2C_STAT, &data, 2);
g_assert((data & OMAP_I2C_STAT_NACK) == 0);
memread(s->addr + OMAP_I2C_CNT, &data, 2);
g_assert_cmpuint(data, ==, len);
while (len > 0) {
memread(s->addr + OMAP_I2C_STAT, &data, 2);
g_assert((data & OMAP_I2C_STAT_RRDY) != 0);
g_assert((data & OMAP_I2C_STAT_ROVR) == 0);
memread(s->addr + OMAP_I2C_DATA, &data, 2);
memread(s->addr + OMAP_I2C_STAT, &stat, 2);
if (unlikely(len == 1)) {
*buf = data & 0xf;
buf++;
len--;
} else {
memcpy(buf, &data, 2);
buf += 2;
len -= 2;
}
}
memread(s->addr + OMAP_I2C_CON, &data, 2);
g_assert((data & OMAP_I2C_CON_STP) == 0);
}
| {
"code": [
" memwrite(s->addr + OMAP_I2C_CNT, &data, 2);",
" memwrite(s->addr + OMAP_I2C_CON, &data, 2);",
" memread(s->addr + OMAP_I2C_CON, &data, 2);",
" memread(s->addr + OMAP_I2C_STAT, &data, 2);",
" memread(s->addr + OMAP_I2C_STAT, &data, 2);",
" memread(s->addr + OMAP_I2C_STAT, &data, 2);",
" memread(s->addr + OMAP_I2C_CON, &data, 2);",
" memwrite(s->addr + OMAP_I2C_CNT, &data, 2);",
" memwrite(s->addr + OMAP_I2C_CON, &data, 2);",
" memread(s->addr + OMAP_I2C_CON, &data, 2);",
" memread(s->addr + OMAP_I2C_STAT, &data, 2);",
" memread(s->addr + OMAP_I2C_CNT, &data, 2);",
" memread(s->addr + OMAP_I2C_STAT, &data, 2);",
" memread(s->addr + OMAP_I2C_DATA, &data, 2);",
" memread(s->addr + OMAP_I2C_STAT, &stat, 2);",
" *buf = data & 0xf;",
" memcpy(buf, &data, 2);",
" memread(s->addr + OMAP_I2C_CON, &data, 2);"
],
"line_no": [
19,
31,
33,
39,
53,
53,
33,
19,
31,
33,
39,
45,
53,
61,
65,
69,
77,
33
]
} | static void FUNC_0(I2CAdapter *VAR_0, uint8_t VAR_1,
uint8_t *VAR_2, uint16_t VAR_3)
{
OMAPI2C *s = (OMAPI2C *)VAR_0;
uint16_t data, stat;
omap_i2c_set_slave_addr(s, VAR_1);
data = VAR_3;
memwrite(s->VAR_1 + OMAP_I2C_CNT, &data, 2);
data = OMAP_I2C_CON_I2C_EN |
OMAP_I2C_CON_MST |
OMAP_I2C_CON_STT |
OMAP_I2C_CON_STP;
memwrite(s->VAR_1 + OMAP_I2C_CON, &data, 2);
memread(s->VAR_1 + OMAP_I2C_CON, &data, 2);
g_assert((data & OMAP_I2C_CON_STP) == 0);
memread(s->VAR_1 + OMAP_I2C_STAT, &data, 2);
g_assert((data & OMAP_I2C_STAT_NACK) == 0);
memread(s->VAR_1 + OMAP_I2C_CNT, &data, 2);
g_assert_cmpuint(data, ==, VAR_3);
while (VAR_3 > 0) {
memread(s->VAR_1 + OMAP_I2C_STAT, &data, 2);
g_assert((data & OMAP_I2C_STAT_RRDY) != 0);
g_assert((data & OMAP_I2C_STAT_ROVR) == 0);
memread(s->VAR_1 + OMAP_I2C_DATA, &data, 2);
memread(s->VAR_1 + OMAP_I2C_STAT, &stat, 2);
if (unlikely(VAR_3 == 1)) {
*VAR_2 = data & 0xf;
VAR_2++;
VAR_3--;
} else {
memcpy(VAR_2, &data, 2);
VAR_2 += 2;
VAR_3 -= 2;
}
}
memread(s->VAR_1 + OMAP_I2C_CON, &data, 2);
g_assert((data & OMAP_I2C_CON_STP) == 0);
}
| [
"static void FUNC_0(I2CAdapter *VAR_0, uint8_t VAR_1,\nuint8_t *VAR_2, uint16_t VAR_3)\n{",
"OMAPI2C *s = (OMAPI2C *)VAR_0;",
"uint16_t data, stat;",
"omap_i2c_set_slave_addr(s, VAR_1);",
"data = VAR_3;",
"memwrite(s->VAR_1 + OMAP_I2C_CNT, &data, 2);",
"data = OMAP_I2C_CON_I2C_EN |\nOMAP_I2C_CON_MST |\nOMAP_I2C_CON_STT |\nOMAP_I2C_CON_STP;",
"memwrite(s->VAR_1 + OMAP_I2C_CON, &data, 2);",
"memread(s->VAR_1 + OMAP_I2C_CON, &data, 2);",
"g_assert((data & OMAP_I2C_CON_STP) == 0);",
"memread(s->VAR_1 + OMAP_I2C_STAT, &data, 2);",
"g_assert((data & OMAP_I2C_STAT_NACK) == 0);",
"memread(s->VAR_1 + OMAP_I2C_CNT, &data, 2);",
"g_assert_cmpuint(data, ==, VAR_3);",
"while (VAR_3 > 0) {",
"memread(s->VAR_1 + OMAP_I2C_STAT, &data, 2);",
"g_assert((data & OMAP_I2C_STAT_RRDY) != 0);",
"g_assert((data & OMAP_I2C_STAT_ROVR) == 0);",
"memread(s->VAR_1 + OMAP_I2C_DATA, &data, 2);",
"memread(s->VAR_1 + OMAP_I2C_STAT, &stat, 2);",
"if (unlikely(VAR_3 == 1)) {",
"*VAR_2 = data & 0xf;",
"VAR_2++;",
"VAR_3--;",
"} else {",
"memcpy(VAR_2, &data, 2);",
"VAR_2 += 2;",
"VAR_3 -= 2;",
"}",
"}",
"memread(s->VAR_1 + OMAP_I2C_CON, &data, 2);",
"g_assert((data & OMAP_I2C_CON_STP) == 0);",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
1,
1,
0,
1,
0,
1,
0,
0,
1,
0,
0,
1,
1,
0,
1,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
23,
25,
27,
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
]
] |
24,563 | double parse_number_or_die(const char *context, const char *numstr, int type, double min, double max)
{
char *tail;
const char *error;
double d = av_strtod(numstr, &tail);
if (*tail)
error= "Expected number for %s but found: %s\n";
else if (d < min || d > max)
error= "The value for %s was %s which is not within %f - %f\n";
else if(type == OPT_INT64 && (int64_t)d != d)
error= "Expected int64 for %s but found %s\n";
else
return d;
fprintf(stderr, error, context, numstr, min, max);
exit(1);
} | true | FFmpeg | 584c2f1db82fbb8024ba2b6b4c48397efedcc125 | double parse_number_or_die(const char *context, const char *numstr, int type, double min, double max)
{
char *tail;
const char *error;
double d = av_strtod(numstr, &tail);
if (*tail)
error= "Expected number for %s but found: %s\n";
else if (d < min || d > max)
error= "The value for %s was %s which is not within %f - %f\n";
else if(type == OPT_INT64 && (int64_t)d != d)
error= "Expected int64 for %s but found %s\n";
else
return d;
fprintf(stderr, error, context, numstr, min, max);
exit(1);
} | {
"code": [],
"line_no": []
} | double FUNC_0(const char *VAR_0, const char *VAR_1, int VAR_2, double VAR_3, double VAR_4)
{
char *VAR_5;
const char *VAR_6;
double VAR_7 = av_strtod(VAR_1, &VAR_5);
if (*VAR_5)
VAR_6= "Expected number for %s but found: %s\n";
else if (VAR_7 < VAR_3 || VAR_7 > VAR_4)
VAR_6= "The value for %s was %s which is not within %f - %f\n";
else if(VAR_2 == OPT_INT64 && (int64_t)VAR_7 != VAR_7)
VAR_6= "Expected int64 for %s but found %s\n";
else
return VAR_7;
fprintf(stderr, VAR_6, VAR_0, VAR_1, VAR_3, VAR_4);
exit(1);
} | [
"double FUNC_0(const char *VAR_0, const char *VAR_1, int VAR_2, double VAR_3, double VAR_4)\n{",
"char *VAR_5;",
"const char *VAR_6;",
"double VAR_7 = av_strtod(VAR_1, &VAR_5);",
"if (*VAR_5)\nVAR_6= \"Expected number for %s but found: %s\\n\";",
"else if (VAR_7 < VAR_3 || VAR_7 > VAR_4)\nVAR_6= \"The value for %s was %s which is not within %f - %f\\n\";",
"else if(VAR_2 == OPT_INT64 && (int64_t)VAR_7 != VAR_7)\nVAR_6= \"Expected int64 for %s but found %s\\n\";",
"else\nreturn VAR_7;",
"fprintf(stderr, VAR_6, VAR_0, VAR_1, VAR_3, VAR_4);",
"exit(1);",
"}"
] | [
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
]
] |
24,564 | static void do_video_out(AVFormatContext *s,
AVOutputStream *ost,
AVInputStream *ist,
AVFrame *in_picture,
int *frame_size)
{
int nb_frames, i, ret;
int64_t topBand, bottomBand, leftBand, rightBand;
AVFrame *final_picture, *formatted_picture, *resampling_dst, *padding_src;
AVFrame picture_crop_temp, picture_pad_temp;
AVCodecContext *enc, *dec;
avcodec_get_frame_defaults(&picture_crop_temp);
avcodec_get_frame_defaults(&picture_pad_temp);
enc = ost->st->codec;
dec = ist->st->codec;
/* by default, we output a single frame */
nb_frames = 1;
*frame_size = 0;
if(video_sync_method){
double vdelta;
vdelta = get_sync_ipts(ost) / av_q2d(enc->time_base) - ost->sync_opts;
//FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c
if (vdelta < -1.1)
nb_frames = 0;
else if (video_sync_method == 2 || (video_sync_method<0 && (s->oformat->flags & AVFMT_VARIABLE_FPS))){
if(vdelta<=-0.6){
nb_frames=0;
}else if(vdelta>0.6)
ost->sync_opts= lrintf(get_sync_ipts(ost) / av_q2d(enc->time_base));
}else if (vdelta > 1.1)
nb_frames = lrintf(vdelta);
//fprintf(stderr, "vdelta:%f, ost->sync_opts:%"PRId64", ost->sync_ipts:%f nb_frames:%d\n", vdelta, ost->sync_opts, get_sync_ipts(ost), nb_frames);
if (nb_frames == 0){
++nb_frames_drop;
if (verbose>2)
fprintf(stderr, "*** drop!\n");
}else if (nb_frames > 1) {
nb_frames_dup += nb_frames;
if (verbose>2)
fprintf(stderr, "*** %d dup!\n", nb_frames-1);
}
}else
ost->sync_opts= lrintf(get_sync_ipts(ost) / av_q2d(enc->time_base));
nb_frames= FFMIN(nb_frames, max_frames[CODEC_TYPE_VIDEO] - ost->frame_number);
if (nb_frames <= 0)
return;
if (ost->video_crop) {
if (av_picture_crop((AVPicture *)&picture_crop_temp, (AVPicture *)in_picture, dec->pix_fmt, ost->topBand, ost->leftBand) < 0) {
fprintf(stderr, "error cropping picture\n");
if (exit_on_error)
av_exit(1);
return;
}
formatted_picture = &picture_crop_temp;
} else {
formatted_picture = in_picture;
}
final_picture = formatted_picture;
padding_src = formatted_picture;
resampling_dst = &ost->pict_tmp;
if (ost->video_pad) {
final_picture = &ost->pict_tmp;
if (ost->video_resample) {
if (av_picture_crop((AVPicture *)&picture_pad_temp, (AVPicture *)final_picture, enc->pix_fmt, ost->padtop, ost->padleft) < 0) {
fprintf(stderr, "error padding picture\n");
if (exit_on_error)
av_exit(1);
return;
}
resampling_dst = &picture_pad_temp;
}
}
if (ost->video_resample) {
padding_src = NULL;
final_picture = &ost->pict_tmp;
if( (ost->resample_height != (ist->st->codec->height - (ost->topBand + ost->bottomBand)))
|| (ost->resample_width != (ist->st->codec->width - (ost->leftBand + ost->rightBand)))
|| (ost->resample_pix_fmt!= ist->st->codec->pix_fmt) ) {
fprintf(stderr,"Input Stream #%d.%d frame size changed to %dx%d, %s\n", ist->file_index, ist->index, ist->st->codec->width, ist->st->codec->height,avcodec_get_pix_fmt_name(ist->st->codec->pix_fmt));
/* keep bands proportional to the frame size */
topBand = ((int64_t)ist->st->codec->height * ost->original_topBand / ost->original_height) & ~1;
bottomBand = ((int64_t)ist->st->codec->height * ost->original_bottomBand / ost->original_height) & ~1;
leftBand = ((int64_t)ist->st->codec->width * ost->original_leftBand / ost->original_width) & ~1;
rightBand = ((int64_t)ist->st->codec->width * ost->original_rightBand / ost->original_width) & ~1;
/* sanity check to ensure no bad band sizes sneak in */
assert(topBand <= INT_MAX && topBand >= 0);
assert(bottomBand <= INT_MAX && bottomBand >= 0);
assert(leftBand <= INT_MAX && leftBand >= 0);
assert(rightBand <= INT_MAX && rightBand >= 0);
ost->topBand = topBand;
ost->bottomBand = bottomBand;
ost->leftBand = leftBand;
ost->rightBand = rightBand;
ost->resample_height = ist->st->codec->height - (ost->topBand + ost->bottomBand);
ost->resample_width = ist->st->codec->width - (ost->leftBand + ost->rightBand);
ost->resample_pix_fmt= ist->st->codec->pix_fmt;
/* initialize a new scaler context */
sws_freeContext(ost->img_resample_ctx);
sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
ost->img_resample_ctx = sws_getContext(
ist->st->codec->width - (ost->leftBand + ost->rightBand),
ist->st->codec->height - (ost->topBand + ost->bottomBand),
ist->st->codec->pix_fmt,
ost->st->codec->width - (ost->padleft + ost->padright),
ost->st->codec->height - (ost->padtop + ost->padbottom),
ost->st->codec->pix_fmt,
sws_flags, NULL, NULL, NULL);
if (ost->img_resample_ctx == NULL) {
fprintf(stderr, "Cannot get resampling context\n");
av_exit(1);
}
}
sws_scale(ost->img_resample_ctx, formatted_picture->data, formatted_picture->linesize,
0, ost->resample_height, resampling_dst->data, resampling_dst->linesize);
}
if (ost->video_pad) {
av_picture_pad((AVPicture*)final_picture, (AVPicture *)padding_src,
enc->height, enc->width, enc->pix_fmt,
ost->padtop, ost->padbottom, ost->padleft, ost->padright, padcolor);
}
/* duplicates frame if needed */
for(i=0;i<nb_frames;i++) {
AVPacket pkt;
av_init_packet(&pkt);
pkt.stream_index= ost->index;
if (s->oformat->flags & AVFMT_RAWPICTURE) {
/* raw pictures are written as AVPicture structure to
avoid any copies. We support temorarily the older
method. */
AVFrame* old_frame = enc->coded_frame;
enc->coded_frame = dec->coded_frame; //FIXME/XXX remove this hack
pkt.data= (uint8_t *)final_picture;
pkt.size= sizeof(AVPicture);
pkt.pts= av_rescale_q(ost->sync_opts, enc->time_base, ost->st->time_base);
pkt.flags |= PKT_FLAG_KEY;
write_frame(s, &pkt, ost->st->codec, bitstream_filters[ost->file_index][pkt.stream_index]);
enc->coded_frame = old_frame;
} else {
AVFrame big_picture;
big_picture= *final_picture;
/* better than nothing: use input picture interlaced
settings */
big_picture.interlaced_frame = in_picture->interlaced_frame;
if(avcodec_opts[CODEC_TYPE_VIDEO]->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME)){
if(top_field_first == -1)
big_picture.top_field_first = in_picture->top_field_first;
else
big_picture.top_field_first = top_field_first;
}
/* handles sameq here. This is not correct because it may
not be a global option */
if (same_quality) {
big_picture.quality = ist->st->quality;
}else
big_picture.quality = ost->st->quality;
if(!me_threshold)
big_picture.pict_type = 0;
// big_picture.pts = AV_NOPTS_VALUE;
big_picture.pts= ost->sync_opts;
// big_picture.pts= av_rescale(ost->sync_opts, AV_TIME_BASE*(int64_t)enc->time_base.num, enc->time_base.den);
//av_log(NULL, AV_LOG_DEBUG, "%"PRId64" -> encoder\n", ost->sync_opts);
ret = avcodec_encode_video(enc,
bit_buffer, bit_buffer_size,
&big_picture);
if (ret < 0) {
fprintf(stderr, "Video encoding failed\n");
av_exit(1);
}
if(ret>0){
pkt.data= bit_buffer;
pkt.size= ret;
if(enc->coded_frame->pts != AV_NOPTS_VALUE)
pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
/*av_log(NULL, AV_LOG_DEBUG, "encoder -> %"PRId64"/%"PRId64"\n",
pkt.pts != AV_NOPTS_VALUE ? av_rescale(pkt.pts, enc->time_base.den, AV_TIME_BASE*(int64_t)enc->time_base.num) : -1,
pkt.dts != AV_NOPTS_VALUE ? av_rescale(pkt.dts, enc->time_base.den, AV_TIME_BASE*(int64_t)enc->time_base.num) : -1);*/
if(enc->coded_frame->key_frame)
pkt.flags |= PKT_FLAG_KEY;
write_frame(s, &pkt, ost->st->codec, bitstream_filters[ost->file_index][pkt.stream_index]);
*frame_size = ret;
video_size += ret;
//fprintf(stderr,"\nFrame: %3d size: %5d type: %d",
// enc->frame_number-1, ret, enc->pict_type);
/* if two pass, output log */
if (ost->logfile && enc->stats_out) {
fprintf(ost->logfile, "%s", enc->stats_out);
}
}
}
ost->sync_opts++;
ost->frame_number++;
}
}
| true | FFmpeg | b83ccbffe9b109fcd18dbd178d6b4f300e6d6799 | static void do_video_out(AVFormatContext *s,
AVOutputStream *ost,
AVInputStream *ist,
AVFrame *in_picture,
int *frame_size)
{
int nb_frames, i, ret;
int64_t topBand, bottomBand, leftBand, rightBand;
AVFrame *final_picture, *formatted_picture, *resampling_dst, *padding_src;
AVFrame picture_crop_temp, picture_pad_temp;
AVCodecContext *enc, *dec;
avcodec_get_frame_defaults(&picture_crop_temp);
avcodec_get_frame_defaults(&picture_pad_temp);
enc = ost->st->codec;
dec = ist->st->codec;
nb_frames = 1;
*frame_size = 0;
if(video_sync_method){
double vdelta;
vdelta = get_sync_ipts(ost) / av_q2d(enc->time_base) - ost->sync_opts;
if (vdelta < -1.1)
nb_frames = 0;
else if (video_sync_method == 2 || (video_sync_method<0 && (s->oformat->flags & AVFMT_VARIABLE_FPS))){
if(vdelta<=-0.6){
nb_frames=0;
}else if(vdelta>0.6)
ost->sync_opts= lrintf(get_sync_ipts(ost) / av_q2d(enc->time_base));
}else if (vdelta > 1.1)
nb_frames = lrintf(vdelta);
if (nb_frames == 0){
++nb_frames_drop;
if (verbose>2)
fprintf(stderr, "*** drop!\n");
}else if (nb_frames > 1) {
nb_frames_dup += nb_frames;
if (verbose>2)
fprintf(stderr, "*** %d dup!\n", nb_frames-1);
}
}else
ost->sync_opts= lrintf(get_sync_ipts(ost) / av_q2d(enc->time_base));
nb_frames= FFMIN(nb_frames, max_frames[CODEC_TYPE_VIDEO] - ost->frame_number);
if (nb_frames <= 0)
return;
if (ost->video_crop) {
if (av_picture_crop((AVPicture *)&picture_crop_temp, (AVPicture *)in_picture, dec->pix_fmt, ost->topBand, ost->leftBand) < 0) {
fprintf(stderr, "error cropping picture\n");
if (exit_on_error)
av_exit(1);
return;
}
formatted_picture = &picture_crop_temp;
} else {
formatted_picture = in_picture;
}
final_picture = formatted_picture;
padding_src = formatted_picture;
resampling_dst = &ost->pict_tmp;
if (ost->video_pad) {
final_picture = &ost->pict_tmp;
if (ost->video_resample) {
if (av_picture_crop((AVPicture *)&picture_pad_temp, (AVPicture *)final_picture, enc->pix_fmt, ost->padtop, ost->padleft) < 0) {
fprintf(stderr, "error padding picture\n");
if (exit_on_error)
av_exit(1);
return;
}
resampling_dst = &picture_pad_temp;
}
}
if (ost->video_resample) {
padding_src = NULL;
final_picture = &ost->pict_tmp;
if( (ost->resample_height != (ist->st->codec->height - (ost->topBand + ost->bottomBand)))
|| (ost->resample_width != (ist->st->codec->width - (ost->leftBand + ost->rightBand)))
|| (ost->resample_pix_fmt!= ist->st->codec->pix_fmt) ) {
fprintf(stderr,"Input Stream #%d.%d frame size changed to %dx%d, %s\n", ist->file_index, ist->index, ist->st->codec->width, ist->st->codec->height,avcodec_get_pix_fmt_name(ist->st->codec->pix_fmt));
topBand = ((int64_t)ist->st->codec->height * ost->original_topBand / ost->original_height) & ~1;
bottomBand = ((int64_t)ist->st->codec->height * ost->original_bottomBand / ost->original_height) & ~1;
leftBand = ((int64_t)ist->st->codec->width * ost->original_leftBand / ost->original_width) & ~1;
rightBand = ((int64_t)ist->st->codec->width * ost->original_rightBand / ost->original_width) & ~1;
assert(topBand <= INT_MAX && topBand >= 0);
assert(bottomBand <= INT_MAX && bottomBand >= 0);
assert(leftBand <= INT_MAX && leftBand >= 0);
assert(rightBand <= INT_MAX && rightBand >= 0);
ost->topBand = topBand;
ost->bottomBand = bottomBand;
ost->leftBand = leftBand;
ost->rightBand = rightBand;
ost->resample_height = ist->st->codec->height - (ost->topBand + ost->bottomBand);
ost->resample_width = ist->st->codec->width - (ost->leftBand + ost->rightBand);
ost->resample_pix_fmt= ist->st->codec->pix_fmt;
sws_freeContext(ost->img_resample_ctx);
sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
ost->img_resample_ctx = sws_getContext(
ist->st->codec->width - (ost->leftBand + ost->rightBand),
ist->st->codec->height - (ost->topBand + ost->bottomBand),
ist->st->codec->pix_fmt,
ost->st->codec->width - (ost->padleft + ost->padright),
ost->st->codec->height - (ost->padtop + ost->padbottom),
ost->st->codec->pix_fmt,
sws_flags, NULL, NULL, NULL);
if (ost->img_resample_ctx == NULL) {
fprintf(stderr, "Cannot get resampling context\n");
av_exit(1);
}
}
sws_scale(ost->img_resample_ctx, formatted_picture->data, formatted_picture->linesize,
0, ost->resample_height, resampling_dst->data, resampling_dst->linesize);
}
if (ost->video_pad) {
av_picture_pad((AVPicture*)final_picture, (AVPicture *)padding_src,
enc->height, enc->width, enc->pix_fmt,
ost->padtop, ost->padbottom, ost->padleft, ost->padright, padcolor);
}
for(i=0;i<nb_frames;i++) {
AVPacket pkt;
av_init_packet(&pkt);
pkt.stream_index= ost->index;
if (s->oformat->flags & AVFMT_RAWPICTURE) {
AVFrame* old_frame = enc->coded_frame;
enc->coded_frame = dec->coded_frame;
pkt.data= (uint8_t *)final_picture;
pkt.size= sizeof(AVPicture);
pkt.pts= av_rescale_q(ost->sync_opts, enc->time_base, ost->st->time_base);
pkt.flags |= PKT_FLAG_KEY;
write_frame(s, &pkt, ost->st->codec, bitstream_filters[ost->file_index][pkt.stream_index]);
enc->coded_frame = old_frame;
} else {
AVFrame big_picture;
big_picture= *final_picture;
big_picture.interlaced_frame = in_picture->interlaced_frame;
if(avcodec_opts[CODEC_TYPE_VIDEO]->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME)){
if(top_field_first == -1)
big_picture.top_field_first = in_picture->top_field_first;
else
big_picture.top_field_first = top_field_first;
}
if (same_quality) {
big_picture.quality = ist->st->quality;
}else
big_picture.quality = ost->st->quality;
if(!me_threshold)
big_picture.pict_type = 0;
big_picture.pts= ost->sync_opts;
ret = avcodec_encode_video(enc,
bit_buffer, bit_buffer_size,
&big_picture);
if (ret < 0) {
fprintf(stderr, "Video encoding failed\n");
av_exit(1);
}
if(ret>0){
pkt.data= bit_buffer;
pkt.size= ret;
if(enc->coded_frame->pts != AV_NOPTS_VALUE)
pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
if(enc->coded_frame->key_frame)
pkt.flags |= PKT_FLAG_KEY;
write_frame(s, &pkt, ost->st->codec, bitstream_filters[ost->file_index][pkt.stream_index]);
*frame_size = ret;
video_size += ret;
if (ost->logfile && enc->stats_out) {
fprintf(ost->logfile, "%s", enc->stats_out);
}
}
}
ost->sync_opts++;
ost->frame_number++;
}
}
| {
"code": [
" fprintf(stderr,\"Input Stream #%d.%d frame size changed to %dx%d, %s\\n\", ist->file_index, ist->index, ist->st->codec->width, ist->st->codec->height,avcodec_get_pix_fmt_name(ist->st->codec->pix_fmt));"
],
"line_no": [
177
]
} | static void FUNC_0(AVFormatContext *VAR_0,
AVOutputStream *VAR_1,
AVInputStream *VAR_2,
AVFrame *VAR_3,
int *VAR_4)
{
int VAR_5, VAR_6, VAR_7;
int64_t topBand, bottomBand, leftBand, rightBand;
AVFrame *final_picture, *formatted_picture, *resampling_dst, *padding_src;
AVFrame picture_crop_temp, picture_pad_temp;
AVCodecContext *enc, *dec;
avcodec_get_frame_defaults(&picture_crop_temp);
avcodec_get_frame_defaults(&picture_pad_temp);
enc = VAR_1->st->codec;
dec = VAR_2->st->codec;
VAR_5 = 1;
*VAR_4 = 0;
if(video_sync_method){
double VAR_8;
VAR_8 = get_sync_ipts(VAR_1) / av_q2d(enc->time_base) - VAR_1->sync_opts;
if (VAR_8 < -1.1)
VAR_5 = 0;
else if (video_sync_method == 2 || (video_sync_method<0 && (VAR_0->oformat->flags & AVFMT_VARIABLE_FPS))){
if(VAR_8<=-0.6){
VAR_5=0;
}else if(VAR_8>0.6)
VAR_1->sync_opts= lrintf(get_sync_ipts(VAR_1) / av_q2d(enc->time_base));
}else if (VAR_8 > 1.1)
VAR_5 = lrintf(VAR_8);
if (VAR_5 == 0){
++nb_frames_drop;
if (verbose>2)
fprintf(stderr, "*** drop!\n");
}else if (VAR_5 > 1) {
nb_frames_dup += VAR_5;
if (verbose>2)
fprintf(stderr, "*** %d dup!\n", VAR_5-1);
}
}else
VAR_1->sync_opts= lrintf(get_sync_ipts(VAR_1) / av_q2d(enc->time_base));
VAR_5= FFMIN(VAR_5, max_frames[CODEC_TYPE_VIDEO] - VAR_1->frame_number);
if (VAR_5 <= 0)
return;
if (VAR_1->video_crop) {
if (av_picture_crop((AVPicture *)&picture_crop_temp, (AVPicture *)VAR_3, dec->pix_fmt, VAR_1->topBand, VAR_1->leftBand) < 0) {
fprintf(stderr, "error cropping picture\n");
if (exit_on_error)
av_exit(1);
return;
}
formatted_picture = &picture_crop_temp;
} else {
formatted_picture = VAR_3;
}
final_picture = formatted_picture;
padding_src = formatted_picture;
resampling_dst = &VAR_1->pict_tmp;
if (VAR_1->video_pad) {
final_picture = &VAR_1->pict_tmp;
if (VAR_1->video_resample) {
if (av_picture_crop((AVPicture *)&picture_pad_temp, (AVPicture *)final_picture, enc->pix_fmt, VAR_1->padtop, VAR_1->padleft) < 0) {
fprintf(stderr, "error padding picture\n");
if (exit_on_error)
av_exit(1);
return;
}
resampling_dst = &picture_pad_temp;
}
}
if (VAR_1->video_resample) {
padding_src = NULL;
final_picture = &VAR_1->pict_tmp;
if( (VAR_1->resample_height != (VAR_2->st->codec->height - (VAR_1->topBand + VAR_1->bottomBand)))
|| (VAR_1->resample_width != (VAR_2->st->codec->width - (VAR_1->leftBand + VAR_1->rightBand)))
|| (VAR_1->resample_pix_fmt!= VAR_2->st->codec->pix_fmt) ) {
fprintf(stderr,"Input Stream #%d.%d frame size changed to %dx%d, %VAR_0\n", VAR_2->file_index, VAR_2->index, VAR_2->st->codec->width, VAR_2->st->codec->height,avcodec_get_pix_fmt_name(VAR_2->st->codec->pix_fmt));
topBand = ((int64_t)VAR_2->st->codec->height * VAR_1->original_topBand / VAR_1->original_height) & ~1;
bottomBand = ((int64_t)VAR_2->st->codec->height * VAR_1->original_bottomBand / VAR_1->original_height) & ~1;
leftBand = ((int64_t)VAR_2->st->codec->width * VAR_1->original_leftBand / VAR_1->original_width) & ~1;
rightBand = ((int64_t)VAR_2->st->codec->width * VAR_1->original_rightBand / VAR_1->original_width) & ~1;
assert(topBand <= INT_MAX && topBand >= 0);
assert(bottomBand <= INT_MAX && bottomBand >= 0);
assert(leftBand <= INT_MAX && leftBand >= 0);
assert(rightBand <= INT_MAX && rightBand >= 0);
VAR_1->topBand = topBand;
VAR_1->bottomBand = bottomBand;
VAR_1->leftBand = leftBand;
VAR_1->rightBand = rightBand;
VAR_1->resample_height = VAR_2->st->codec->height - (VAR_1->topBand + VAR_1->bottomBand);
VAR_1->resample_width = VAR_2->st->codec->width - (VAR_1->leftBand + VAR_1->rightBand);
VAR_1->resample_pix_fmt= VAR_2->st->codec->pix_fmt;
sws_freeContext(VAR_1->img_resample_ctx);
sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
VAR_1->img_resample_ctx = sws_getContext(
VAR_2->st->codec->width - (VAR_1->leftBand + VAR_1->rightBand),
VAR_2->st->codec->height - (VAR_1->topBand + VAR_1->bottomBand),
VAR_2->st->codec->pix_fmt,
VAR_1->st->codec->width - (VAR_1->padleft + VAR_1->padright),
VAR_1->st->codec->height - (VAR_1->padtop + VAR_1->padbottom),
VAR_1->st->codec->pix_fmt,
sws_flags, NULL, NULL, NULL);
if (VAR_1->img_resample_ctx == NULL) {
fprintf(stderr, "Cannot get resampling context\n");
av_exit(1);
}
}
sws_scale(VAR_1->img_resample_ctx, formatted_picture->data, formatted_picture->linesize,
0, VAR_1->resample_height, resampling_dst->data, resampling_dst->linesize);
}
if (VAR_1->video_pad) {
av_picture_pad((AVPicture*)final_picture, (AVPicture *)padding_src,
enc->height, enc->width, enc->pix_fmt,
VAR_1->padtop, VAR_1->padbottom, VAR_1->padleft, VAR_1->padright, padcolor);
}
for(VAR_6=0;VAR_6<VAR_5;VAR_6++) {
AVPacket pkt;
av_init_packet(&pkt);
pkt.stream_index= VAR_1->index;
if (VAR_0->oformat->flags & AVFMT_RAWPICTURE) {
AVFrame* old_frame = enc->coded_frame;
enc->coded_frame = dec->coded_frame;
pkt.data= (uint8_t *)final_picture;
pkt.size= sizeof(AVPicture);
pkt.pts= av_rescale_q(VAR_1->sync_opts, enc->time_base, VAR_1->st->time_base);
pkt.flags |= PKT_FLAG_KEY;
write_frame(VAR_0, &pkt, VAR_1->st->codec, bitstream_filters[VAR_1->file_index][pkt.stream_index]);
enc->coded_frame = old_frame;
} else {
AVFrame big_picture;
big_picture= *final_picture;
big_picture.interlaced_frame = VAR_3->interlaced_frame;
if(avcodec_opts[CODEC_TYPE_VIDEO]->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME)){
if(top_field_first == -1)
big_picture.top_field_first = VAR_3->top_field_first;
else
big_picture.top_field_first = top_field_first;
}
if (same_quality) {
big_picture.quality = VAR_2->st->quality;
}else
big_picture.quality = VAR_1->st->quality;
if(!me_threshold)
big_picture.pict_type = 0;
big_picture.pts= VAR_1->sync_opts;
VAR_7 = avcodec_encode_video(enc,
bit_buffer, bit_buffer_size,
&big_picture);
if (VAR_7 < 0) {
fprintf(stderr, "Video encoding failed\n");
av_exit(1);
}
if(VAR_7>0){
pkt.data= bit_buffer;
pkt.size= VAR_7;
if(enc->coded_frame->pts != AV_NOPTS_VALUE)
pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, VAR_1->st->time_base);
if(enc->coded_frame->key_frame)
pkt.flags |= PKT_FLAG_KEY;
write_frame(VAR_0, &pkt, VAR_1->st->codec, bitstream_filters[VAR_1->file_index][pkt.stream_index]);
*VAR_4 = VAR_7;
video_size += VAR_7;
if (VAR_1->logfile && enc->stats_out) {
fprintf(VAR_1->logfile, "%VAR_0", enc->stats_out);
}
}
}
VAR_1->sync_opts++;
VAR_1->frame_number++;
}
}
| [
"static void FUNC_0(AVFormatContext *VAR_0,\nAVOutputStream *VAR_1,\nAVInputStream *VAR_2,\nAVFrame *VAR_3,\nint *VAR_4)\n{",
"int VAR_5, VAR_6, VAR_7;",
"int64_t topBand, bottomBand, leftBand, rightBand;",
"AVFrame *final_picture, *formatted_picture, *resampling_dst, *padding_src;",
"AVFrame picture_crop_temp, picture_pad_temp;",
"AVCodecContext *enc, *dec;",
"avcodec_get_frame_defaults(&picture_crop_temp);",
"avcodec_get_frame_defaults(&picture_pad_temp);",
"enc = VAR_1->st->codec;",
"dec = VAR_2->st->codec;",
"VAR_5 = 1;",
"*VAR_4 = 0;",
"if(video_sync_method){",
"double VAR_8;",
"VAR_8 = get_sync_ipts(VAR_1) / av_q2d(enc->time_base) - VAR_1->sync_opts;",
"if (VAR_8 < -1.1)\nVAR_5 = 0;",
"else if (video_sync_method == 2 || (video_sync_method<0 && (VAR_0->oformat->flags & AVFMT_VARIABLE_FPS))){",
"if(VAR_8<=-0.6){",
"VAR_5=0;",
"}else if(VAR_8>0.6)",
"VAR_1->sync_opts= lrintf(get_sync_ipts(VAR_1) / av_q2d(enc->time_base));",
"}else if (VAR_8 > 1.1)",
"VAR_5 = lrintf(VAR_8);",
"if (VAR_5 == 0){",
"++nb_frames_drop;",
"if (verbose>2)\nfprintf(stderr, \"*** drop!\\n\");",
"}else if (VAR_5 > 1) {",
"nb_frames_dup += VAR_5;",
"if (verbose>2)\nfprintf(stderr, \"*** %d dup!\\n\", VAR_5-1);",
"}",
"}else",
"VAR_1->sync_opts= lrintf(get_sync_ipts(VAR_1) / av_q2d(enc->time_base));",
"VAR_5= FFMIN(VAR_5, max_frames[CODEC_TYPE_VIDEO] - VAR_1->frame_number);",
"if (VAR_5 <= 0)\nreturn;",
"if (VAR_1->video_crop) {",
"if (av_picture_crop((AVPicture *)&picture_crop_temp, (AVPicture *)VAR_3, dec->pix_fmt, VAR_1->topBand, VAR_1->leftBand) < 0) {",
"fprintf(stderr, \"error cropping picture\\n\");",
"if (exit_on_error)\nav_exit(1);",
"return;",
"}",
"formatted_picture = &picture_crop_temp;",
"} else {",
"formatted_picture = VAR_3;",
"}",
"final_picture = formatted_picture;",
"padding_src = formatted_picture;",
"resampling_dst = &VAR_1->pict_tmp;",
"if (VAR_1->video_pad) {",
"final_picture = &VAR_1->pict_tmp;",
"if (VAR_1->video_resample) {",
"if (av_picture_crop((AVPicture *)&picture_pad_temp, (AVPicture *)final_picture, enc->pix_fmt, VAR_1->padtop, VAR_1->padleft) < 0) {",
"fprintf(stderr, \"error padding picture\\n\");",
"if (exit_on_error)\nav_exit(1);",
"return;",
"}",
"resampling_dst = &picture_pad_temp;",
"}",
"}",
"if (VAR_1->video_resample) {",
"padding_src = NULL;",
"final_picture = &VAR_1->pict_tmp;",
"if( (VAR_1->resample_height != (VAR_2->st->codec->height - (VAR_1->topBand + VAR_1->bottomBand)))\n|| (VAR_1->resample_width != (VAR_2->st->codec->width - (VAR_1->leftBand + VAR_1->rightBand)))\n|| (VAR_1->resample_pix_fmt!= VAR_2->st->codec->pix_fmt) ) {",
"fprintf(stderr,\"Input Stream #%d.%d frame size changed to %dx%d, %VAR_0\\n\", VAR_2->file_index, VAR_2->index, VAR_2->st->codec->width, VAR_2->st->codec->height,avcodec_get_pix_fmt_name(VAR_2->st->codec->pix_fmt));",
"topBand = ((int64_t)VAR_2->st->codec->height * VAR_1->original_topBand / VAR_1->original_height) & ~1;",
"bottomBand = ((int64_t)VAR_2->st->codec->height * VAR_1->original_bottomBand / VAR_1->original_height) & ~1;",
"leftBand = ((int64_t)VAR_2->st->codec->width * VAR_1->original_leftBand / VAR_1->original_width) & ~1;",
"rightBand = ((int64_t)VAR_2->st->codec->width * VAR_1->original_rightBand / VAR_1->original_width) & ~1;",
"assert(topBand <= INT_MAX && topBand >= 0);",
"assert(bottomBand <= INT_MAX && bottomBand >= 0);",
"assert(leftBand <= INT_MAX && leftBand >= 0);",
"assert(rightBand <= INT_MAX && rightBand >= 0);",
"VAR_1->topBand = topBand;",
"VAR_1->bottomBand = bottomBand;",
"VAR_1->leftBand = leftBand;",
"VAR_1->rightBand = rightBand;",
"VAR_1->resample_height = VAR_2->st->codec->height - (VAR_1->topBand + VAR_1->bottomBand);",
"VAR_1->resample_width = VAR_2->st->codec->width - (VAR_1->leftBand + VAR_1->rightBand);",
"VAR_1->resample_pix_fmt= VAR_2->st->codec->pix_fmt;",
"sws_freeContext(VAR_1->img_resample_ctx);",
"sws_flags = av_get_int(sws_opts, \"sws_flags\", NULL);",
"VAR_1->img_resample_ctx = sws_getContext(\nVAR_2->st->codec->width - (VAR_1->leftBand + VAR_1->rightBand),\nVAR_2->st->codec->height - (VAR_1->topBand + VAR_1->bottomBand),\nVAR_2->st->codec->pix_fmt,\nVAR_1->st->codec->width - (VAR_1->padleft + VAR_1->padright),\nVAR_1->st->codec->height - (VAR_1->padtop + VAR_1->padbottom),\nVAR_1->st->codec->pix_fmt,\nsws_flags, NULL, NULL, NULL);",
"if (VAR_1->img_resample_ctx == NULL) {",
"fprintf(stderr, \"Cannot get resampling context\\n\");",
"av_exit(1);",
"}",
"}",
"sws_scale(VAR_1->img_resample_ctx, formatted_picture->data, formatted_picture->linesize,\n0, VAR_1->resample_height, resampling_dst->data, resampling_dst->linesize);",
"}",
"if (VAR_1->video_pad) {",
"av_picture_pad((AVPicture*)final_picture, (AVPicture *)padding_src,\nenc->height, enc->width, enc->pix_fmt,\nVAR_1->padtop, VAR_1->padbottom, VAR_1->padleft, VAR_1->padright, padcolor);",
"}",
"for(VAR_6=0;VAR_6<VAR_5;VAR_6++) {",
"AVPacket pkt;",
"av_init_packet(&pkt);",
"pkt.stream_index= VAR_1->index;",
"if (VAR_0->oformat->flags & AVFMT_RAWPICTURE) {",
"AVFrame* old_frame = enc->coded_frame;",
"enc->coded_frame = dec->coded_frame;",
"pkt.data= (uint8_t *)final_picture;",
"pkt.size= sizeof(AVPicture);",
"pkt.pts= av_rescale_q(VAR_1->sync_opts, enc->time_base, VAR_1->st->time_base);",
"pkt.flags |= PKT_FLAG_KEY;",
"write_frame(VAR_0, &pkt, VAR_1->st->codec, bitstream_filters[VAR_1->file_index][pkt.stream_index]);",
"enc->coded_frame = old_frame;",
"} else {",
"AVFrame big_picture;",
"big_picture= *final_picture;",
"big_picture.interlaced_frame = VAR_3->interlaced_frame;",
"if(avcodec_opts[CODEC_TYPE_VIDEO]->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME)){",
"if(top_field_first == -1)\nbig_picture.top_field_first = VAR_3->top_field_first;",
"else\nbig_picture.top_field_first = top_field_first;",
"}",
"if (same_quality) {",
"big_picture.quality = VAR_2->st->quality;",
"}else",
"big_picture.quality = VAR_1->st->quality;",
"if(!me_threshold)\nbig_picture.pict_type = 0;",
"big_picture.pts= VAR_1->sync_opts;",
"VAR_7 = avcodec_encode_video(enc,\nbit_buffer, bit_buffer_size,\n&big_picture);",
"if (VAR_7 < 0) {",
"fprintf(stderr, \"Video encoding failed\\n\");",
"av_exit(1);",
"}",
"if(VAR_7>0){",
"pkt.data= bit_buffer;",
"pkt.size= VAR_7;",
"if(enc->coded_frame->pts != AV_NOPTS_VALUE)\npkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, VAR_1->st->time_base);",
"if(enc->coded_frame->key_frame)\npkt.flags |= PKT_FLAG_KEY;",
"write_frame(VAR_0, &pkt, VAR_1->st->codec, bitstream_filters[VAR_1->file_index][pkt.stream_index]);",
"*VAR_4 = VAR_7;",
"video_size += VAR_7;",
"if (VAR_1->logfile && enc->stats_out) {",
"fprintf(VAR_1->logfile, \"%VAR_0\", enc->stats_out);",
"}",
"}",
"}",
"VAR_1->sync_opts++;",
"VAR_1->frame_number++;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
39
],
[
43
],
[
47
],
[
49
],
[
51
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79,
81
],
[
83
],
[
85
],
[
87,
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101,
103
],
[
107
],
[
109
],
[
111
],
[
113,
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147,
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
163
],
[
165
],
[
167
],
[
169,
171,
173
],
[
177
],
[
181
],
[
183
],
[
185
],
[
187
],
[
193
],
[
195
],
[
197
],
[
199
],
[
203
],
[
205
],
[
207
],
[
209
],
[
213
],
[
215
],
[
217
],
[
223
],
[
225
],
[
227,
229,
231,
233,
235,
237,
239,
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253,
255
],
[
257
],
[
261
],
[
263,
265,
267
],
[
269
],
[
275
],
[
277
],
[
279
],
[
281
],
[
285
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
307
],
[
309
],
[
311
],
[
313
],
[
317
],
[
323
],
[
325
],
[
327,
329
],
[
331,
333
],
[
335
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351,
353
],
[
357
],
[
363,
365,
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
379
],
[
381
],
[
383
],
[
385,
387
],
[
397,
399
],
[
401
],
[
403
],
[
405
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429
]
] |
24,565 | static void gen_ld(DisasContext *ctx, uint32_t opc,
int rt, int base, int16_t offset)
{
TCGv t0, t1, t2;
int mem_idx = ctx->mem_idx;
if (rt == 0 && ctx->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F)) {
/* Loongson CPU uses a load to zero register for prefetch.
We emulate it as a NOP. On other CPU we must perform the
actual memory access. */
return;
}
t0 = tcg_temp_new();
gen_base_offset_addr(ctx, t0, base, offset);
switch (opc) {
#if defined(TARGET_MIPS64)
case OPC_LWU:
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEUL |
ctx->default_tcg_memop_mask);
gen_store_gpr(t0, rt);
break;
case OPC_LD:
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEQ |
ctx->default_tcg_memop_mask);
gen_store_gpr(t0, rt);
break;
case OPC_LLD:
case R6_OPC_LLD:
op_ld_lld(t0, t0, mem_idx, ctx);
gen_store_gpr(t0, rt);
break;
case OPC_LDL:
t1 = tcg_temp_new();
/* Do a byte access to possibly trigger a page
fault with the unaligned address. */
tcg_gen_qemu_ld_tl(t1, t0, mem_idx, MO_UB);
tcg_gen_andi_tl(t1, t0, 7);
#ifndef TARGET_WORDS_BIGENDIAN
tcg_gen_xori_tl(t1, t1, 7);
#endif
tcg_gen_shli_tl(t1, t1, 3);
tcg_gen_andi_tl(t0, t0, ~7);
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEQ);
tcg_gen_shl_tl(t0, t0, t1);
t2 = tcg_const_tl(-1);
tcg_gen_shl_tl(t2, t2, t1);
gen_load_gpr(t1, rt);
tcg_gen_andc_tl(t1, t1, t2);
tcg_temp_free(t2);
tcg_gen_or_tl(t0, t0, t1);
tcg_temp_free(t1);
gen_store_gpr(t0, rt);
break;
case OPC_LDR:
t1 = tcg_temp_new();
/* Do a byte access to possibly trigger a page
fault with the unaligned address. */
tcg_gen_qemu_ld_tl(t1, t0, mem_idx, MO_UB);
tcg_gen_andi_tl(t1, t0, 7);
#ifdef TARGET_WORDS_BIGENDIAN
tcg_gen_xori_tl(t1, t1, 7);
#endif
tcg_gen_shli_tl(t1, t1, 3);
tcg_gen_andi_tl(t0, t0, ~7);
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEQ);
tcg_gen_shr_tl(t0, t0, t1);
tcg_gen_xori_tl(t1, t1, 63);
t2 = tcg_const_tl(0xfffffffffffffffeull);
tcg_gen_shl_tl(t2, t2, t1);
gen_load_gpr(t1, rt);
tcg_gen_and_tl(t1, t1, t2);
tcg_temp_free(t2);
tcg_gen_or_tl(t0, t0, t1);
tcg_temp_free(t1);
gen_store_gpr(t0, rt);
break;
case OPC_LDPC:
t1 = tcg_const_tl(pc_relative_pc(ctx));
gen_op_addr_add(ctx, t0, t0, t1);
tcg_temp_free(t1);
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEQ);
gen_store_gpr(t0, rt);
break;
#endif
case OPC_LWPC:
t1 = tcg_const_tl(pc_relative_pc(ctx));
gen_op_addr_add(ctx, t0, t0, t1);
tcg_temp_free(t1);
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TESL);
gen_store_gpr(t0, rt);
break;
case OPC_LWE:
case OPC_LW:
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TESL |
ctx->default_tcg_memop_mask);
gen_store_gpr(t0, rt);
break;
case OPC_LHE:
case OPC_LH:
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TESW |
ctx->default_tcg_memop_mask);
gen_store_gpr(t0, rt);
break;
case OPC_LHUE:
case OPC_LHU:
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEUW |
ctx->default_tcg_memop_mask);
gen_store_gpr(t0, rt);
break;
case OPC_LBE:
case OPC_LB:
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_SB);
gen_store_gpr(t0, rt);
break;
case OPC_LBUE:
case OPC_LBU:
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_UB);
gen_store_gpr(t0, rt);
break;
case OPC_LWLE:
case OPC_LWL:
t1 = tcg_temp_new();
/* Do a byte access to possibly trigger a page
fault with the unaligned address. */
tcg_gen_qemu_ld_tl(t1, t0, mem_idx, MO_UB);
tcg_gen_andi_tl(t1, t0, 3);
#ifndef TARGET_WORDS_BIGENDIAN
tcg_gen_xori_tl(t1, t1, 3);
#endif
tcg_gen_shli_tl(t1, t1, 3);
tcg_gen_andi_tl(t0, t0, ~3);
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEUL);
tcg_gen_shl_tl(t0, t0, t1);
t2 = tcg_const_tl(-1);
tcg_gen_shl_tl(t2, t2, t1);
gen_load_gpr(t1, rt);
tcg_gen_andc_tl(t1, t1, t2);
tcg_temp_free(t2);
tcg_gen_or_tl(t0, t0, t1);
tcg_temp_free(t1);
tcg_gen_ext32s_tl(t0, t0);
gen_store_gpr(t0, rt);
break;
case OPC_LWR:
t1 = tcg_temp_new();
/* Do a byte access to possibly trigger a page
fault with the unaligned address. */
tcg_gen_qemu_ld_tl(t1, t0, mem_idx, MO_UB);
tcg_gen_andi_tl(t1, t0, 3);
#ifdef TARGET_WORDS_BIGENDIAN
tcg_gen_xori_tl(t1, t1, 3);
#endif
tcg_gen_shli_tl(t1, t1, 3);
tcg_gen_andi_tl(t0, t0, ~3);
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEUL);
tcg_gen_shr_tl(t0, t0, t1);
tcg_gen_xori_tl(t1, t1, 31);
t2 = tcg_const_tl(0xfffffffeull);
tcg_gen_shl_tl(t2, t2, t1);
gen_load_gpr(t1, rt);
tcg_gen_and_tl(t1, t1, t2);
tcg_temp_free(t2);
tcg_gen_or_tl(t0, t0, t1);
tcg_temp_free(t1);
tcg_gen_ext32s_tl(t0, t0);
gen_store_gpr(t0, rt);
break;
case OPC_LLE:
case OPC_LL:
case R6_OPC_LL:
op_ld_ll(t0, t0, mem_idx, ctx);
gen_store_gpr(t0, rt);
break;
}
tcg_temp_free(t0);
} | true | qemu | 7696414729b2d0f870c80ad1dd637d854bc78847 | static void gen_ld(DisasContext *ctx, uint32_t opc,
int rt, int base, int16_t offset)
{
TCGv t0, t1, t2;
int mem_idx = ctx->mem_idx;
if (rt == 0 && ctx->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F)) {
return;
}
t0 = tcg_temp_new();
gen_base_offset_addr(ctx, t0, base, offset);
switch (opc) {
#if defined(TARGET_MIPS64)
case OPC_LWU:
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEUL |
ctx->default_tcg_memop_mask);
gen_store_gpr(t0, rt);
break;
case OPC_LD:
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEQ |
ctx->default_tcg_memop_mask);
gen_store_gpr(t0, rt);
break;
case OPC_LLD:
case R6_OPC_LLD:
op_ld_lld(t0, t0, mem_idx, ctx);
gen_store_gpr(t0, rt);
break;
case OPC_LDL:
t1 = tcg_temp_new();
tcg_gen_qemu_ld_tl(t1, t0, mem_idx, MO_UB);
tcg_gen_andi_tl(t1, t0, 7);
#ifndef TARGET_WORDS_BIGENDIAN
tcg_gen_xori_tl(t1, t1, 7);
#endif
tcg_gen_shli_tl(t1, t1, 3);
tcg_gen_andi_tl(t0, t0, ~7);
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEQ);
tcg_gen_shl_tl(t0, t0, t1);
t2 = tcg_const_tl(-1);
tcg_gen_shl_tl(t2, t2, t1);
gen_load_gpr(t1, rt);
tcg_gen_andc_tl(t1, t1, t2);
tcg_temp_free(t2);
tcg_gen_or_tl(t0, t0, t1);
tcg_temp_free(t1);
gen_store_gpr(t0, rt);
break;
case OPC_LDR:
t1 = tcg_temp_new();
tcg_gen_qemu_ld_tl(t1, t0, mem_idx, MO_UB);
tcg_gen_andi_tl(t1, t0, 7);
#ifdef TARGET_WORDS_BIGENDIAN
tcg_gen_xori_tl(t1, t1, 7);
#endif
tcg_gen_shli_tl(t1, t1, 3);
tcg_gen_andi_tl(t0, t0, ~7);
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEQ);
tcg_gen_shr_tl(t0, t0, t1);
tcg_gen_xori_tl(t1, t1, 63);
t2 = tcg_const_tl(0xfffffffffffffffeull);
tcg_gen_shl_tl(t2, t2, t1);
gen_load_gpr(t1, rt);
tcg_gen_and_tl(t1, t1, t2);
tcg_temp_free(t2);
tcg_gen_or_tl(t0, t0, t1);
tcg_temp_free(t1);
gen_store_gpr(t0, rt);
break;
case OPC_LDPC:
t1 = tcg_const_tl(pc_relative_pc(ctx));
gen_op_addr_add(ctx, t0, t0, t1);
tcg_temp_free(t1);
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEQ);
gen_store_gpr(t0, rt);
break;
#endif
case OPC_LWPC:
t1 = tcg_const_tl(pc_relative_pc(ctx));
gen_op_addr_add(ctx, t0, t0, t1);
tcg_temp_free(t1);
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TESL);
gen_store_gpr(t0, rt);
break;
case OPC_LWE:
case OPC_LW:
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TESL |
ctx->default_tcg_memop_mask);
gen_store_gpr(t0, rt);
break;
case OPC_LHE:
case OPC_LH:
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TESW |
ctx->default_tcg_memop_mask);
gen_store_gpr(t0, rt);
break;
case OPC_LHUE:
case OPC_LHU:
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEUW |
ctx->default_tcg_memop_mask);
gen_store_gpr(t0, rt);
break;
case OPC_LBE:
case OPC_LB:
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_SB);
gen_store_gpr(t0, rt);
break;
case OPC_LBUE:
case OPC_LBU:
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_UB);
gen_store_gpr(t0, rt);
break;
case OPC_LWLE:
case OPC_LWL:
t1 = tcg_temp_new();
tcg_gen_qemu_ld_tl(t1, t0, mem_idx, MO_UB);
tcg_gen_andi_tl(t1, t0, 3);
#ifndef TARGET_WORDS_BIGENDIAN
tcg_gen_xori_tl(t1, t1, 3);
#endif
tcg_gen_shli_tl(t1, t1, 3);
tcg_gen_andi_tl(t0, t0, ~3);
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEUL);
tcg_gen_shl_tl(t0, t0, t1);
t2 = tcg_const_tl(-1);
tcg_gen_shl_tl(t2, t2, t1);
gen_load_gpr(t1, rt);
tcg_gen_andc_tl(t1, t1, t2);
tcg_temp_free(t2);
tcg_gen_or_tl(t0, t0, t1);
tcg_temp_free(t1);
tcg_gen_ext32s_tl(t0, t0);
gen_store_gpr(t0, rt);
break;
case OPC_LWR:
t1 = tcg_temp_new();
tcg_gen_qemu_ld_tl(t1, t0, mem_idx, MO_UB);
tcg_gen_andi_tl(t1, t0, 3);
#ifdef TARGET_WORDS_BIGENDIAN
tcg_gen_xori_tl(t1, t1, 3);
#endif
tcg_gen_shli_tl(t1, t1, 3);
tcg_gen_andi_tl(t0, t0, ~3);
tcg_gen_qemu_ld_tl(t0, t0, mem_idx, MO_TEUL);
tcg_gen_shr_tl(t0, t0, t1);
tcg_gen_xori_tl(t1, t1, 31);
t2 = tcg_const_tl(0xfffffffeull);
tcg_gen_shl_tl(t2, t2, t1);
gen_load_gpr(t1, rt);
tcg_gen_and_tl(t1, t1, t2);
tcg_temp_free(t2);
tcg_gen_or_tl(t0, t0, t1);
tcg_temp_free(t1);
tcg_gen_ext32s_tl(t0, t0);
gen_store_gpr(t0, rt);
break;
case OPC_LLE:
case OPC_LL:
case R6_OPC_LL:
op_ld_ll(t0, t0, mem_idx, ctx);
gen_store_gpr(t0, rt);
break;
}
tcg_temp_free(t0);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1,
int VAR_2, int VAR_3, int16_t VAR_4)
{
TCGv t0, t1, t2;
int VAR_5 = VAR_0->VAR_5;
if (VAR_2 == 0 && VAR_0->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F)) {
return;
}
t0 = tcg_temp_new();
gen_base_offset_addr(VAR_0, t0, VAR_3, VAR_4);
switch (VAR_1) {
#if defined(TARGET_MIPS64)
case OPC_LWU:
tcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_TEUL |
VAR_0->default_tcg_memop_mask);
gen_store_gpr(t0, VAR_2);
break;
case OPC_LD:
tcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_TEQ |
VAR_0->default_tcg_memop_mask);
gen_store_gpr(t0, VAR_2);
break;
case OPC_LLD:
case R6_OPC_LLD:
op_ld_lld(t0, t0, VAR_5, VAR_0);
gen_store_gpr(t0, VAR_2);
break;
case OPC_LDL:
t1 = tcg_temp_new();
tcg_gen_qemu_ld_tl(t1, t0, VAR_5, MO_UB);
tcg_gen_andi_tl(t1, t0, 7);
#ifndef TARGET_WORDS_BIGENDIAN
tcg_gen_xori_tl(t1, t1, 7);
#endif
tcg_gen_shli_tl(t1, t1, 3);
tcg_gen_andi_tl(t0, t0, ~7);
tcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_TEQ);
tcg_gen_shl_tl(t0, t0, t1);
t2 = tcg_const_tl(-1);
tcg_gen_shl_tl(t2, t2, t1);
gen_load_gpr(t1, VAR_2);
tcg_gen_andc_tl(t1, t1, t2);
tcg_temp_free(t2);
tcg_gen_or_tl(t0, t0, t1);
tcg_temp_free(t1);
gen_store_gpr(t0, VAR_2);
break;
case OPC_LDR:
t1 = tcg_temp_new();
tcg_gen_qemu_ld_tl(t1, t0, VAR_5, MO_UB);
tcg_gen_andi_tl(t1, t0, 7);
#ifdef TARGET_WORDS_BIGENDIAN
tcg_gen_xori_tl(t1, t1, 7);
#endif
tcg_gen_shli_tl(t1, t1, 3);
tcg_gen_andi_tl(t0, t0, ~7);
tcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_TEQ);
tcg_gen_shr_tl(t0, t0, t1);
tcg_gen_xori_tl(t1, t1, 63);
t2 = tcg_const_tl(0xfffffffffffffffeull);
tcg_gen_shl_tl(t2, t2, t1);
gen_load_gpr(t1, VAR_2);
tcg_gen_and_tl(t1, t1, t2);
tcg_temp_free(t2);
tcg_gen_or_tl(t0, t0, t1);
tcg_temp_free(t1);
gen_store_gpr(t0, VAR_2);
break;
case OPC_LDPC:
t1 = tcg_const_tl(pc_relative_pc(VAR_0));
gen_op_addr_add(VAR_0, t0, t0, t1);
tcg_temp_free(t1);
tcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_TEQ);
gen_store_gpr(t0, VAR_2);
break;
#endif
case OPC_LWPC:
t1 = tcg_const_tl(pc_relative_pc(VAR_0));
gen_op_addr_add(VAR_0, t0, t0, t1);
tcg_temp_free(t1);
tcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_TESL);
gen_store_gpr(t0, VAR_2);
break;
case OPC_LWE:
case OPC_LW:
tcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_TESL |
VAR_0->default_tcg_memop_mask);
gen_store_gpr(t0, VAR_2);
break;
case OPC_LHE:
case OPC_LH:
tcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_TESW |
VAR_0->default_tcg_memop_mask);
gen_store_gpr(t0, VAR_2);
break;
case OPC_LHUE:
case OPC_LHU:
tcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_TEUW |
VAR_0->default_tcg_memop_mask);
gen_store_gpr(t0, VAR_2);
break;
case OPC_LBE:
case OPC_LB:
tcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_SB);
gen_store_gpr(t0, VAR_2);
break;
case OPC_LBUE:
case OPC_LBU:
tcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_UB);
gen_store_gpr(t0, VAR_2);
break;
case OPC_LWLE:
case OPC_LWL:
t1 = tcg_temp_new();
tcg_gen_qemu_ld_tl(t1, t0, VAR_5, MO_UB);
tcg_gen_andi_tl(t1, t0, 3);
#ifndef TARGET_WORDS_BIGENDIAN
tcg_gen_xori_tl(t1, t1, 3);
#endif
tcg_gen_shli_tl(t1, t1, 3);
tcg_gen_andi_tl(t0, t0, ~3);
tcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_TEUL);
tcg_gen_shl_tl(t0, t0, t1);
t2 = tcg_const_tl(-1);
tcg_gen_shl_tl(t2, t2, t1);
gen_load_gpr(t1, VAR_2);
tcg_gen_andc_tl(t1, t1, t2);
tcg_temp_free(t2);
tcg_gen_or_tl(t0, t0, t1);
tcg_temp_free(t1);
tcg_gen_ext32s_tl(t0, t0);
gen_store_gpr(t0, VAR_2);
break;
case OPC_LWR:
t1 = tcg_temp_new();
tcg_gen_qemu_ld_tl(t1, t0, VAR_5, MO_UB);
tcg_gen_andi_tl(t1, t0, 3);
#ifdef TARGET_WORDS_BIGENDIAN
tcg_gen_xori_tl(t1, t1, 3);
#endif
tcg_gen_shli_tl(t1, t1, 3);
tcg_gen_andi_tl(t0, t0, ~3);
tcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_TEUL);
tcg_gen_shr_tl(t0, t0, t1);
tcg_gen_xori_tl(t1, t1, 31);
t2 = tcg_const_tl(0xfffffffeull);
tcg_gen_shl_tl(t2, t2, t1);
gen_load_gpr(t1, VAR_2);
tcg_gen_and_tl(t1, t1, t2);
tcg_temp_free(t2);
tcg_gen_or_tl(t0, t0, t1);
tcg_temp_free(t1);
tcg_gen_ext32s_tl(t0, t0);
gen_store_gpr(t0, VAR_2);
break;
case OPC_LLE:
case OPC_LL:
case R6_OPC_LL:
op_ld_ll(t0, t0, VAR_5, VAR_0);
gen_store_gpr(t0, VAR_2);
break;
}
tcg_temp_free(t0);
} | [
"static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1,\nint VAR_2, int VAR_3, int16_t VAR_4)\n{",
"TCGv t0, t1, t2;",
"int VAR_5 = VAR_0->VAR_5;",
"if (VAR_2 == 0 && VAR_0->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F)) {",
"return;",
"}",
"t0 = tcg_temp_new();",
"gen_base_offset_addr(VAR_0, t0, VAR_3, VAR_4);",
"switch (VAR_1) {",
"#if defined(TARGET_MIPS64)\ncase OPC_LWU:\ntcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_TEUL |\nVAR_0->default_tcg_memop_mask);",
"gen_store_gpr(t0, VAR_2);",
"break;",
"case OPC_LD:\ntcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_TEQ |\nVAR_0->default_tcg_memop_mask);",
"gen_store_gpr(t0, VAR_2);",
"break;",
"case OPC_LLD:\ncase R6_OPC_LLD:\nop_ld_lld(t0, t0, VAR_5, VAR_0);",
"gen_store_gpr(t0, VAR_2);",
"break;",
"case OPC_LDL:\nt1 = tcg_temp_new();",
"tcg_gen_qemu_ld_tl(t1, t0, VAR_5, MO_UB);",
"tcg_gen_andi_tl(t1, t0, 7);",
"#ifndef TARGET_WORDS_BIGENDIAN\ntcg_gen_xori_tl(t1, t1, 7);",
"#endif\ntcg_gen_shli_tl(t1, t1, 3);",
"tcg_gen_andi_tl(t0, t0, ~7);",
"tcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_TEQ);",
"tcg_gen_shl_tl(t0, t0, t1);",
"t2 = tcg_const_tl(-1);",
"tcg_gen_shl_tl(t2, t2, t1);",
"gen_load_gpr(t1, VAR_2);",
"tcg_gen_andc_tl(t1, t1, t2);",
"tcg_temp_free(t2);",
"tcg_gen_or_tl(t0, t0, t1);",
"tcg_temp_free(t1);",
"gen_store_gpr(t0, VAR_2);",
"break;",
"case OPC_LDR:\nt1 = tcg_temp_new();",
"tcg_gen_qemu_ld_tl(t1, t0, VAR_5, MO_UB);",
"tcg_gen_andi_tl(t1, t0, 7);",
"#ifdef TARGET_WORDS_BIGENDIAN\ntcg_gen_xori_tl(t1, t1, 7);",
"#endif\ntcg_gen_shli_tl(t1, t1, 3);",
"tcg_gen_andi_tl(t0, t0, ~7);",
"tcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_TEQ);",
"tcg_gen_shr_tl(t0, t0, t1);",
"tcg_gen_xori_tl(t1, t1, 63);",
"t2 = tcg_const_tl(0xfffffffffffffffeull);",
"tcg_gen_shl_tl(t2, t2, t1);",
"gen_load_gpr(t1, VAR_2);",
"tcg_gen_and_tl(t1, t1, t2);",
"tcg_temp_free(t2);",
"tcg_gen_or_tl(t0, t0, t1);",
"tcg_temp_free(t1);",
"gen_store_gpr(t0, VAR_2);",
"break;",
"case OPC_LDPC:\nt1 = tcg_const_tl(pc_relative_pc(VAR_0));",
"gen_op_addr_add(VAR_0, t0, t0, t1);",
"tcg_temp_free(t1);",
"tcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_TEQ);",
"gen_store_gpr(t0, VAR_2);",
"break;",
"#endif\ncase OPC_LWPC:\nt1 = tcg_const_tl(pc_relative_pc(VAR_0));",
"gen_op_addr_add(VAR_0, t0, t0, t1);",
"tcg_temp_free(t1);",
"tcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_TESL);",
"gen_store_gpr(t0, VAR_2);",
"break;",
"case OPC_LWE:\ncase OPC_LW:\ntcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_TESL |\nVAR_0->default_tcg_memop_mask);",
"gen_store_gpr(t0, VAR_2);",
"break;",
"case OPC_LHE:\ncase OPC_LH:\ntcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_TESW |\nVAR_0->default_tcg_memop_mask);",
"gen_store_gpr(t0, VAR_2);",
"break;",
"case OPC_LHUE:\ncase OPC_LHU:\ntcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_TEUW |\nVAR_0->default_tcg_memop_mask);",
"gen_store_gpr(t0, VAR_2);",
"break;",
"case OPC_LBE:\ncase OPC_LB:\ntcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_SB);",
"gen_store_gpr(t0, VAR_2);",
"break;",
"case OPC_LBUE:\ncase OPC_LBU:\ntcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_UB);",
"gen_store_gpr(t0, VAR_2);",
"break;",
"case OPC_LWLE:\ncase OPC_LWL:\nt1 = tcg_temp_new();",
"tcg_gen_qemu_ld_tl(t1, t0, VAR_5, MO_UB);",
"tcg_gen_andi_tl(t1, t0, 3);",
"#ifndef TARGET_WORDS_BIGENDIAN\ntcg_gen_xori_tl(t1, t1, 3);",
"#endif\ntcg_gen_shli_tl(t1, t1, 3);",
"tcg_gen_andi_tl(t0, t0, ~3);",
"tcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_TEUL);",
"tcg_gen_shl_tl(t0, t0, t1);",
"t2 = tcg_const_tl(-1);",
"tcg_gen_shl_tl(t2, t2, t1);",
"gen_load_gpr(t1, VAR_2);",
"tcg_gen_andc_tl(t1, t1, t2);",
"tcg_temp_free(t2);",
"tcg_gen_or_tl(t0, t0, t1);",
"tcg_temp_free(t1);",
"tcg_gen_ext32s_tl(t0, t0);",
"gen_store_gpr(t0, VAR_2);",
"break;",
"case OPC_LWR:\nt1 = tcg_temp_new();",
"tcg_gen_qemu_ld_tl(t1, t0, VAR_5, MO_UB);",
"tcg_gen_andi_tl(t1, t0, 3);",
"#ifdef TARGET_WORDS_BIGENDIAN\ntcg_gen_xori_tl(t1, t1, 3);",
"#endif\ntcg_gen_shli_tl(t1, t1, 3);",
"tcg_gen_andi_tl(t0, t0, ~3);",
"tcg_gen_qemu_ld_tl(t0, t0, VAR_5, MO_TEUL);",
"tcg_gen_shr_tl(t0, t0, t1);",
"tcg_gen_xori_tl(t1, t1, 31);",
"t2 = tcg_const_tl(0xfffffffeull);",
"tcg_gen_shl_tl(t2, t2, t1);",
"gen_load_gpr(t1, VAR_2);",
"tcg_gen_and_tl(t1, t1, t2);",
"tcg_temp_free(t2);",
"tcg_gen_or_tl(t0, t0, t1);",
"tcg_temp_free(t1);",
"tcg_gen_ext32s_tl(t0, t0);",
"gen_store_gpr(t0, VAR_2);",
"break;",
"case OPC_LLE:\ncase OPC_LL:\ncase R6_OPC_LL:\nop_ld_ll(t0, t0, VAR_5, VAR_0);",
"gen_store_gpr(t0, VAR_2);",
"break;",
"}",
"tcg_temp_free(t0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
21
],
[
23
],
[
27
],
[
29
],
[
33
],
[
35,
37,
39,
41
],
[
43
],
[
45
],
[
47,
49,
51
],
[
53
],
[
55
],
[
57,
59,
61
],
[
63
],
[
65
],
[
67,
69
],
[
75
],
[
77
],
[
79,
81
],
[
83,
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111,
113
],
[
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,
191,
193,
195
],
[
197
],
[
199
],
[
201,
205,
207,
209
],
[
211
],
[
213
],
[
215,
219,
221,
223
],
[
225
],
[
227
],
[
229,
233,
235
],
[
237
],
[
239
],
[
241,
245,
247
],
[
249
],
[
251
],
[
253,
257,
259
],
[
265
],
[
267
],
[
269,
271
],
[
273,
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
306,
308
],
[
314
],
[
316
],
[
318,
320
],
[
322,
324
],
[
326
],
[
328
],
[
330
],
[
332
],
[
334
],
[
336
],
[
338
],
[
340
],
[
342
],
[
344
],
[
346
],
[
348
],
[
350
],
[
352
],
[
354,
358,
360,
362
],
[
364
],
[
366
],
[
368
],
[
370
],
[
372
]
] |
24,566 | static void libschroedinger_decode_frame_free(void *frame)
{
schro_frame_unref(frame);
}
| true | FFmpeg | 220b24c7c97dc033ceab1510549f66d0e7b52ef1 | static void libschroedinger_decode_frame_free(void *frame)
{
schro_frame_unref(frame);
}
| {
"code": [
"static void libschroedinger_decode_frame_free(void *frame)",
" schro_frame_unref(frame);"
],
"line_no": [
1,
5
]
} | static void FUNC_0(void *VAR_0)
{
schro_frame_unref(VAR_0);
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"schro_frame_unref(VAR_0);",
"}"
] | [
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
24,567 | static void network_to_caps(RDMACapabilities *cap)
{
cap->version = ntohl(cap->version);
cap->flags = ntohl(cap->flags);
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | static void network_to_caps(RDMACapabilities *cap)
{
cap->version = ntohl(cap->version);
cap->flags = ntohl(cap->flags);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(RDMACapabilities *VAR_0)
{
VAR_0->version = ntohl(VAR_0->version);
VAR_0->flags = ntohl(VAR_0->flags);
}
| [
"static void FUNC_0(RDMACapabilities *VAR_0)\n{",
"VAR_0->version = ntohl(VAR_0->version);",
"VAR_0->flags = ntohl(VAR_0->flags);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
24,568 | static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type, int source_index)
{
OutputStream *ost;
AVStream *st = avformat_new_stream(oc, NULL);
int idx = oc->nb_streams - 1, ret = 0;
char *bsf = NULL, *next, *codec_tag = NULL;
AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;
double qscale = -1;
int i;
if (!st) {
av_log(NULL, AV_LOG_FATAL, "Could not alloc stream.\n");
exit_program(1);
}
if (oc->nb_streams - 1 < o->nb_streamid_map)
st->id = o->streamid_map[oc->nb_streams - 1];
GROW_ARRAY(output_streams, nb_output_streams);
if (!(ost = av_mallocz(sizeof(*ost))))
exit_program(1);
output_streams[nb_output_streams - 1] = ost;
ost->file_index = nb_output_files - 1;
ost->index = idx;
ost->st = st;
st->codecpar->codec_type = type;
ret = choose_encoder(o, oc, ost);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "Error selecting an encoder for stream "
"%d:%d\n", ost->file_index, ost->index);
exit_program(1);
}
ost->enc_ctx = avcodec_alloc_context3(ost->enc);
if (!ost->enc_ctx) {
av_log(NULL, AV_LOG_ERROR, "Error allocating the encoding context.\n");
exit_program(1);
}
ost->enc_ctx->codec_type = type;
ost->ref_par = avcodec_parameters_alloc();
if (!ost->ref_par) {
av_log(NULL, AV_LOG_ERROR, "Error allocating the encoding parameters.\n");
exit_program(1);
}
if (ost->enc) {
AVIOContext *s = NULL;
char *buf = NULL, *arg = NULL, *preset = NULL;
ost->encoder_opts = filter_codec_opts(o->g->codec_opts, ost->enc->id, oc, st, ost->enc);
MATCH_PER_STREAM_OPT(presets, str, preset, oc, st);
if (preset && (!(ret = get_preset_file_2(preset, ost->enc->name, &s)))) {
do {
buf = get_line(s);
if (!buf[0] || buf[0] == '#') {
av_free(buf);
continue;
}
if (!(arg = strchr(buf, '='))) {
av_log(NULL, AV_LOG_FATAL, "Invalid line found in the preset file.\n");
exit_program(1);
}
*arg++ = 0;
av_dict_set(&ost->encoder_opts, buf, arg, AV_DICT_DONT_OVERWRITE);
av_free(buf);
} while (!s->eof_reached);
avio_closep(&s);
}
if (ret) {
av_log(NULL, AV_LOG_FATAL,
"Preset %s specified for stream %d:%d, but could not be opened.\n",
preset, ost->file_index, ost->index);
exit_program(1);
}
} else {
ost->encoder_opts = filter_codec_opts(o->g->codec_opts, AV_CODEC_ID_NONE, oc, st, NULL);
}
ost->max_frames = INT64_MAX;
MATCH_PER_STREAM_OPT(max_frames, i64, ost->max_frames, oc, st);
for (i = 0; i<o->nb_max_frames; i++) {
char *p = o->max_frames[i].specifier;
if (!*p && type != AVMEDIA_TYPE_VIDEO) {
av_log(NULL, AV_LOG_WARNING, "Applying unspecific -frames to non video streams, maybe you meant -vframes ?\n");
break;
}
}
ost->copy_prior_start = -1;
MATCH_PER_STREAM_OPT(copy_prior_start, i, ost->copy_prior_start, oc ,st);
MATCH_PER_STREAM_OPT(bitstream_filters, str, bsf, oc, st);
while (bsf) {
char *arg = NULL;
if (next = strchr(bsf, ','))
*next++ = 0;
if (arg = strchr(bsf, '='))
*arg++ = 0;
if (!(bsfc = av_bitstream_filter_init(bsf))) {
av_log(NULL, AV_LOG_FATAL, "Unknown bitstream filter %s\n", bsf);
exit_program(1);
}
if (bsfc_prev)
bsfc_prev->next = bsfc;
else
ost->bitstream_filters = bsfc;
if (arg)
if (!(bsfc->args = av_strdup(arg))) {
av_log(NULL, AV_LOG_FATAL, "Bitstream filter memory allocation failed\n");
exit_program(1);
}
bsfc_prev = bsfc;
bsf = next;
}
MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, oc, st);
if (codec_tag) {
uint32_t tag = strtol(codec_tag, &next, 0);
if (*next)
tag = AV_RL32(codec_tag);
ost->st->codecpar->codec_tag =
ost->enc_ctx->codec_tag = tag;
}
MATCH_PER_STREAM_OPT(qscale, dbl, qscale, oc, st);
if (qscale >= 0) {
ost->enc_ctx->flags |= AV_CODEC_FLAG_QSCALE;
ost->enc_ctx->global_quality = FF_QP2LAMBDA * qscale;
}
MATCH_PER_STREAM_OPT(disposition, str, ost->disposition, oc, st);
ost->disposition = av_strdup(ost->disposition);
if (oc->oformat->flags & AVFMT_GLOBALHEADER)
ost->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
av_dict_copy(&ost->sws_dict, o->g->sws_dict, 0);
av_dict_copy(&ost->swr_opts, o->g->swr_opts, 0);
if (ost->enc && av_get_exact_bits_per_sample(ost->enc->id) == 24)
av_dict_set(&ost->swr_opts, "output_sample_bits", "24", 0);
av_dict_copy(&ost->resample_opts, o->g->resample_opts, 0);
ost->source_index = source_index;
if (source_index >= 0) {
ost->sync_ist = input_streams[source_index];
input_streams[source_index]->discard = 0;
input_streams[source_index]->st->discard = input_streams[source_index]->user_set_discard;
}
ost->last_mux_dts = AV_NOPTS_VALUE;
return ost;
}
| true | FFmpeg | 5ef19590802f000299e418143fc2301e3f43affe | static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type, int source_index)
{
OutputStream *ost;
AVStream *st = avformat_new_stream(oc, NULL);
int idx = oc->nb_streams - 1, ret = 0;
char *bsf = NULL, *next, *codec_tag = NULL;
AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;
double qscale = -1;
int i;
if (!st) {
av_log(NULL, AV_LOG_FATAL, "Could not alloc stream.\n");
exit_program(1);
}
if (oc->nb_streams - 1 < o->nb_streamid_map)
st->id = o->streamid_map[oc->nb_streams - 1];
GROW_ARRAY(output_streams, nb_output_streams);
if (!(ost = av_mallocz(sizeof(*ost))))
exit_program(1);
output_streams[nb_output_streams - 1] = ost;
ost->file_index = nb_output_files - 1;
ost->index = idx;
ost->st = st;
st->codecpar->codec_type = type;
ret = choose_encoder(o, oc, ost);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "Error selecting an encoder for stream "
"%d:%d\n", ost->file_index, ost->index);
exit_program(1);
}
ost->enc_ctx = avcodec_alloc_context3(ost->enc);
if (!ost->enc_ctx) {
av_log(NULL, AV_LOG_ERROR, "Error allocating the encoding context.\n");
exit_program(1);
}
ost->enc_ctx->codec_type = type;
ost->ref_par = avcodec_parameters_alloc();
if (!ost->ref_par) {
av_log(NULL, AV_LOG_ERROR, "Error allocating the encoding parameters.\n");
exit_program(1);
}
if (ost->enc) {
AVIOContext *s = NULL;
char *buf = NULL, *arg = NULL, *preset = NULL;
ost->encoder_opts = filter_codec_opts(o->g->codec_opts, ost->enc->id, oc, st, ost->enc);
MATCH_PER_STREAM_OPT(presets, str, preset, oc, st);
if (preset && (!(ret = get_preset_file_2(preset, ost->enc->name, &s)))) {
do {
buf = get_line(s);
if (!buf[0] || buf[0] == '#') {
av_free(buf);
continue;
}
if (!(arg = strchr(buf, '='))) {
av_log(NULL, AV_LOG_FATAL, "Invalid line found in the preset file.\n");
exit_program(1);
}
*arg++ = 0;
av_dict_set(&ost->encoder_opts, buf, arg, AV_DICT_DONT_OVERWRITE);
av_free(buf);
} while (!s->eof_reached);
avio_closep(&s);
}
if (ret) {
av_log(NULL, AV_LOG_FATAL,
"Preset %s specified for stream %d:%d, but could not be opened.\n",
preset, ost->file_index, ost->index);
exit_program(1);
}
} else {
ost->encoder_opts = filter_codec_opts(o->g->codec_opts, AV_CODEC_ID_NONE, oc, st, NULL);
}
ost->max_frames = INT64_MAX;
MATCH_PER_STREAM_OPT(max_frames, i64, ost->max_frames, oc, st);
for (i = 0; i<o->nb_max_frames; i++) {
char *p = o->max_frames[i].specifier;
if (!*p && type != AVMEDIA_TYPE_VIDEO) {
av_log(NULL, AV_LOG_WARNING, "Applying unspecific -frames to non video streams, maybe you meant -vframes ?\n");
break;
}
}
ost->copy_prior_start = -1;
MATCH_PER_STREAM_OPT(copy_prior_start, i, ost->copy_prior_start, oc ,st);
MATCH_PER_STREAM_OPT(bitstream_filters, str, bsf, oc, st);
while (bsf) {
char *arg = NULL;
if (next = strchr(bsf, ','))
*next++ = 0;
if (arg = strchr(bsf, '='))
*arg++ = 0;
if (!(bsfc = av_bitstream_filter_init(bsf))) {
av_log(NULL, AV_LOG_FATAL, "Unknown bitstream filter %s\n", bsf);
exit_program(1);
}
if (bsfc_prev)
bsfc_prev->next = bsfc;
else
ost->bitstream_filters = bsfc;
if (arg)
if (!(bsfc->args = av_strdup(arg))) {
av_log(NULL, AV_LOG_FATAL, "Bitstream filter memory allocation failed\n");
exit_program(1);
}
bsfc_prev = bsfc;
bsf = next;
}
MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, oc, st);
if (codec_tag) {
uint32_t tag = strtol(codec_tag, &next, 0);
if (*next)
tag = AV_RL32(codec_tag);
ost->st->codecpar->codec_tag =
ost->enc_ctx->codec_tag = tag;
}
MATCH_PER_STREAM_OPT(qscale, dbl, qscale, oc, st);
if (qscale >= 0) {
ost->enc_ctx->flags |= AV_CODEC_FLAG_QSCALE;
ost->enc_ctx->global_quality = FF_QP2LAMBDA * qscale;
}
MATCH_PER_STREAM_OPT(disposition, str, ost->disposition, oc, st);
ost->disposition = av_strdup(ost->disposition);
if (oc->oformat->flags & AVFMT_GLOBALHEADER)
ost->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
av_dict_copy(&ost->sws_dict, o->g->sws_dict, 0);
av_dict_copy(&ost->swr_opts, o->g->swr_opts, 0);
if (ost->enc && av_get_exact_bits_per_sample(ost->enc->id) == 24)
av_dict_set(&ost->swr_opts, "output_sample_bits", "24", 0);
av_dict_copy(&ost->resample_opts, o->g->resample_opts, 0);
ost->source_index = source_index;
if (source_index >= 0) {
ost->sync_ist = input_streams[source_index];
input_streams[source_index]->discard = 0;
input_streams[source_index]->st->discard = input_streams[source_index]->user_set_discard;
}
ost->last_mux_dts = AV_NOPTS_VALUE;
return ost;
}
| {
"code": [
" exit_program(1);",
" exit_program(1);",
" char *bsf = NULL, *next, *codec_tag = NULL;",
" AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;",
" MATCH_PER_STREAM_OPT(bitstream_filters, str, bsf, oc, st);",
" while (bsf) {",
" char *arg = NULL;",
" if (next = strchr(bsf, ','))",
" *next++ = 0;",
" if (arg = strchr(bsf, '='))",
" *arg++ = 0;",
" if (!(bsfc = av_bitstream_filter_init(bsf))) {",
" av_log(NULL, AV_LOG_FATAL, \"Unknown bitstream filter %s\\n\", bsf);",
" if (bsfc_prev)",
" bsfc_prev->next = bsfc;",
" ost->bitstream_filters = bsfc;",
" if (arg)",
" if (!(bsfc->args = av_strdup(arg))) {",
" av_log(NULL, AV_LOG_FATAL, \"Bitstream filter memory allocation failed\\n\");",
" bsfc_prev = bsfc;",
" bsf = next;"
],
"line_no": [
153,
153,
11,
13,
191,
193,
195,
197,
199,
201,
203,
205,
207,
213,
215,
219,
221,
223,
225,
233,
235
]
} | static OutputStream *FUNC_0(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type, int source_index)
{
OutputStream *ost;
AVStream *st = avformat_new_stream(oc, NULL);
int VAR_0 = oc->nb_streams - 1, VAR_1 = 0;
char *VAR_2 = NULL, *VAR_3, *VAR_4 = NULL;
AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;
double VAR_5 = -1;
int VAR_6;
if (!st) {
av_log(NULL, AV_LOG_FATAL, "Could not alloc stream.\n");
exit_program(1);
}
if (oc->nb_streams - 1 < o->nb_streamid_map)
st->id = o->streamid_map[oc->nb_streams - 1];
GROW_ARRAY(output_streams, nb_output_streams);
if (!(ost = av_mallocz(sizeof(*ost))))
exit_program(1);
output_streams[nb_output_streams - 1] = ost;
ost->file_index = nb_output_files - 1;
ost->index = VAR_0;
ost->st = st;
st->codecpar->codec_type = type;
VAR_1 = choose_encoder(o, oc, ost);
if (VAR_1 < 0) {
av_log(NULL, AV_LOG_FATAL, "Error selecting an encoder for stream "
"%d:%d\n", ost->file_index, ost->index);
exit_program(1);
}
ost->enc_ctx = avcodec_alloc_context3(ost->enc);
if (!ost->enc_ctx) {
av_log(NULL, AV_LOG_ERROR, "Error allocating the encoding context.\n");
exit_program(1);
}
ost->enc_ctx->codec_type = type;
ost->ref_par = avcodec_parameters_alloc();
if (!ost->ref_par) {
av_log(NULL, AV_LOG_ERROR, "Error allocating the encoding parameters.\n");
exit_program(1);
}
if (ost->enc) {
AVIOContext *s = NULL;
char *VAR_7 = NULL, *VAR_10 = NULL, *VAR_9 = NULL;
ost->encoder_opts = filter_codec_opts(o->g->codec_opts, ost->enc->id, oc, st, ost->enc);
MATCH_PER_STREAM_OPT(presets, str, VAR_9, oc, st);
if (VAR_9 && (!(VAR_1 = get_preset_file_2(VAR_9, ost->enc->name, &s)))) {
do {
VAR_7 = get_line(s);
if (!VAR_7[0] || VAR_7[0] == '#') {
av_free(VAR_7);
continue;
}
if (!(VAR_10 = strchr(VAR_7, '='))) {
av_log(NULL, AV_LOG_FATAL, "Invalid line found in the VAR_9 file.\n");
exit_program(1);
}
*VAR_10++ = 0;
av_dict_set(&ost->encoder_opts, VAR_7, VAR_10, AV_DICT_DONT_OVERWRITE);
av_free(VAR_7);
} while (!s->eof_reached);
avio_closep(&s);
}
if (VAR_1) {
av_log(NULL, AV_LOG_FATAL,
"Preset %s specified for stream %d:%d, but could not be opened.\n",
VAR_9, ost->file_index, ost->index);
exit_program(1);
}
} else {
ost->encoder_opts = filter_codec_opts(o->g->codec_opts, AV_CODEC_ID_NONE, oc, st, NULL);
}
ost->max_frames = INT64_MAX;
MATCH_PER_STREAM_OPT(max_frames, i64, ost->max_frames, oc, st);
for (VAR_6 = 0; VAR_6<o->nb_max_frames; VAR_6++) {
char *p = o->max_frames[VAR_6].specifier;
if (!*p && type != AVMEDIA_TYPE_VIDEO) {
av_log(NULL, AV_LOG_WARNING, "Applying unspecific -frames to non video streams, maybe you meant -vframes ?\n");
break;
}
}
ost->copy_prior_start = -1;
MATCH_PER_STREAM_OPT(copy_prior_start, VAR_6, ost->copy_prior_start, oc ,st);
MATCH_PER_STREAM_OPT(bitstream_filters, str, VAR_2, oc, st);
while (VAR_2) {
char *VAR_10 = NULL;
if (VAR_3 = strchr(VAR_2, ','))
*VAR_3++ = 0;
if (VAR_10 = strchr(VAR_2, '='))
*VAR_10++ = 0;
if (!(bsfc = av_bitstream_filter_init(VAR_2))) {
av_log(NULL, AV_LOG_FATAL, "Unknown bitstream filter %s\n", VAR_2);
exit_program(1);
}
if (bsfc_prev)
bsfc_prev->VAR_3 = bsfc;
else
ost->bitstream_filters = bsfc;
if (VAR_10)
if (!(bsfc->args = av_strdup(VAR_10))) {
av_log(NULL, AV_LOG_FATAL, "Bitstream filter memory allocation failed\n");
exit_program(1);
}
bsfc_prev = bsfc;
VAR_2 = VAR_3;
}
MATCH_PER_STREAM_OPT(codec_tags, str, VAR_4, oc, st);
if (VAR_4) {
uint32_t tag = strtol(VAR_4, &VAR_3, 0);
if (*VAR_3)
tag = AV_RL32(VAR_4);
ost->st->codecpar->VAR_4 =
ost->enc_ctx->VAR_4 = tag;
}
MATCH_PER_STREAM_OPT(VAR_5, dbl, VAR_5, oc, st);
if (VAR_5 >= 0) {
ost->enc_ctx->flags |= AV_CODEC_FLAG_QSCALE;
ost->enc_ctx->global_quality = FF_QP2LAMBDA * VAR_5;
}
MATCH_PER_STREAM_OPT(disposition, str, ost->disposition, oc, st);
ost->disposition = av_strdup(ost->disposition);
if (oc->oformat->flags & AVFMT_GLOBALHEADER)
ost->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
av_dict_copy(&ost->sws_dict, o->g->sws_dict, 0);
av_dict_copy(&ost->swr_opts, o->g->swr_opts, 0);
if (ost->enc && av_get_exact_bits_per_sample(ost->enc->id) == 24)
av_dict_set(&ost->swr_opts, "output_sample_bits", "24", 0);
av_dict_copy(&ost->resample_opts, o->g->resample_opts, 0);
ost->source_index = source_index;
if (source_index >= 0) {
ost->sync_ist = input_streams[source_index];
input_streams[source_index]->discard = 0;
input_streams[source_index]->st->discard = input_streams[source_index]->user_set_discard;
}
ost->last_mux_dts = AV_NOPTS_VALUE;
return ost;
}
| [
"static OutputStream *FUNC_0(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type, int source_index)\n{",
"OutputStream *ost;",
"AVStream *st = avformat_new_stream(oc, NULL);",
"int VAR_0 = oc->nb_streams - 1, VAR_1 = 0;",
"char *VAR_2 = NULL, *VAR_3, *VAR_4 = NULL;",
"AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;",
"double VAR_5 = -1;",
"int VAR_6;",
"if (!st) {",
"av_log(NULL, AV_LOG_FATAL, \"Could not alloc stream.\\n\");",
"exit_program(1);",
"}",
"if (oc->nb_streams - 1 < o->nb_streamid_map)\nst->id = o->streamid_map[oc->nb_streams - 1];",
"GROW_ARRAY(output_streams, nb_output_streams);",
"if (!(ost = av_mallocz(sizeof(*ost))))\nexit_program(1);",
"output_streams[nb_output_streams - 1] = ost;",
"ost->file_index = nb_output_files - 1;",
"ost->index = VAR_0;",
"ost->st = st;",
"st->codecpar->codec_type = type;",
"VAR_1 = choose_encoder(o, oc, ost);",
"if (VAR_1 < 0) {",
"av_log(NULL, AV_LOG_FATAL, \"Error selecting an encoder for stream \"\n\"%d:%d\\n\", ost->file_index, ost->index);",
"exit_program(1);",
"}",
"ost->enc_ctx = avcodec_alloc_context3(ost->enc);",
"if (!ost->enc_ctx) {",
"av_log(NULL, AV_LOG_ERROR, \"Error allocating the encoding context.\\n\");",
"exit_program(1);",
"}",
"ost->enc_ctx->codec_type = type;",
"ost->ref_par = avcodec_parameters_alloc();",
"if (!ost->ref_par) {",
"av_log(NULL, AV_LOG_ERROR, \"Error allocating the encoding parameters.\\n\");",
"exit_program(1);",
"}",
"if (ost->enc) {",
"AVIOContext *s = NULL;",
"char *VAR_7 = NULL, *VAR_10 = NULL, *VAR_9 = NULL;",
"ost->encoder_opts = filter_codec_opts(o->g->codec_opts, ost->enc->id, oc, st, ost->enc);",
"MATCH_PER_STREAM_OPT(presets, str, VAR_9, oc, st);",
"if (VAR_9 && (!(VAR_1 = get_preset_file_2(VAR_9, ost->enc->name, &s)))) {",
"do {",
"VAR_7 = get_line(s);",
"if (!VAR_7[0] || VAR_7[0] == '#') {",
"av_free(VAR_7);",
"continue;",
"}",
"if (!(VAR_10 = strchr(VAR_7, '='))) {",
"av_log(NULL, AV_LOG_FATAL, \"Invalid line found in the VAR_9 file.\\n\");",
"exit_program(1);",
"}",
"*VAR_10++ = 0;",
"av_dict_set(&ost->encoder_opts, VAR_7, VAR_10, AV_DICT_DONT_OVERWRITE);",
"av_free(VAR_7);",
"} while (!s->eof_reached);",
"avio_closep(&s);",
"}",
"if (VAR_1) {",
"av_log(NULL, AV_LOG_FATAL,\n\"Preset %s specified for stream %d:%d, but could not be opened.\\n\",\nVAR_9, ost->file_index, ost->index);",
"exit_program(1);",
"}",
"} else {",
"ost->encoder_opts = filter_codec_opts(o->g->codec_opts, AV_CODEC_ID_NONE, oc, st, NULL);",
"}",
"ost->max_frames = INT64_MAX;",
"MATCH_PER_STREAM_OPT(max_frames, i64, ost->max_frames, oc, st);",
"for (VAR_6 = 0; VAR_6<o->nb_max_frames; VAR_6++) {",
"char *p = o->max_frames[VAR_6].specifier;",
"if (!*p && type != AVMEDIA_TYPE_VIDEO) {",
"av_log(NULL, AV_LOG_WARNING, \"Applying unspecific -frames to non video streams, maybe you meant -vframes ?\\n\");",
"break;",
"}",
"}",
"ost->copy_prior_start = -1;",
"MATCH_PER_STREAM_OPT(copy_prior_start, VAR_6, ost->copy_prior_start, oc ,st);",
"MATCH_PER_STREAM_OPT(bitstream_filters, str, VAR_2, oc, st);",
"while (VAR_2) {",
"char *VAR_10 = NULL;",
"if (VAR_3 = strchr(VAR_2, ','))\n*VAR_3++ = 0;",
"if (VAR_10 = strchr(VAR_2, '='))\n*VAR_10++ = 0;",
"if (!(bsfc = av_bitstream_filter_init(VAR_2))) {",
"av_log(NULL, AV_LOG_FATAL, \"Unknown bitstream filter %s\\n\", VAR_2);",
"exit_program(1);",
"}",
"if (bsfc_prev)\nbsfc_prev->VAR_3 = bsfc;",
"else\nost->bitstream_filters = bsfc;",
"if (VAR_10)\nif (!(bsfc->args = av_strdup(VAR_10))) {",
"av_log(NULL, AV_LOG_FATAL, \"Bitstream filter memory allocation failed\\n\");",
"exit_program(1);",
"}",
"bsfc_prev = bsfc;",
"VAR_2 = VAR_3;",
"}",
"MATCH_PER_STREAM_OPT(codec_tags, str, VAR_4, oc, st);",
"if (VAR_4) {",
"uint32_t tag = strtol(VAR_4, &VAR_3, 0);",
"if (*VAR_3)\ntag = AV_RL32(VAR_4);",
"ost->st->codecpar->VAR_4 =\nost->enc_ctx->VAR_4 = tag;",
"}",
"MATCH_PER_STREAM_OPT(VAR_5, dbl, VAR_5, oc, st);",
"if (VAR_5 >= 0) {",
"ost->enc_ctx->flags |= AV_CODEC_FLAG_QSCALE;",
"ost->enc_ctx->global_quality = FF_QP2LAMBDA * VAR_5;",
"}",
"MATCH_PER_STREAM_OPT(disposition, str, ost->disposition, oc, st);",
"ost->disposition = av_strdup(ost->disposition);",
"if (oc->oformat->flags & AVFMT_GLOBALHEADER)\nost->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;",
"av_dict_copy(&ost->sws_dict, o->g->sws_dict, 0);",
"av_dict_copy(&ost->swr_opts, o->g->swr_opts, 0);",
"if (ost->enc && av_get_exact_bits_per_sample(ost->enc->id) == 24)\nav_dict_set(&ost->swr_opts, \"output_sample_bits\", \"24\", 0);",
"av_dict_copy(&ost->resample_opts, o->g->resample_opts, 0);",
"ost->source_index = source_index;",
"if (source_index >= 0) {",
"ost->sync_ist = input_streams[source_index];",
"input_streams[source_index]->discard = 0;",
"input_streams[source_index]->st->discard = input_streams[source_index]->user_set_discard;",
"}",
"ost->last_mux_dts = AV_NOPTS_VALUE;",
"return ost;",
"}"
] | [
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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
0,
0,
1,
1,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31,
33
],
[
37
],
[
39,
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147,
149,
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
185
],
[
187
],
[
191
],
[
193
],
[
195
],
[
197,
199
],
[
201,
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213,
215
],
[
217,
219
],
[
221,
223
],
[
225
],
[
227
],
[
229
],
[
233
],
[
235
],
[
237
],
[
241
],
[
243
],
[
245
],
[
247,
249
],
[
251,
253
],
[
255
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
271
],
[
273
],
[
277,
279
],
[
283
],
[
287
],
[
289,
291
],
[
295
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
315
],
[
317
]
] |
24,569 | static void pcnet_common_init(PCNetState *d, NICInfo *nd)
{
d->poll_timer = qemu_new_timer(vm_clock, pcnet_poll_timer, d);
d->nd = nd;
if (nd && nd->vlan) {
d->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
pcnet_receive, pcnet_can_receive, d);
qemu_format_nic_info_str(d->vc, d->nd->macaddr);
} else {
d->vc = NULL;
}
pcnet_h_reset(d);
register_savevm("pcnet", -1, 2, pcnet_save, pcnet_load, d);
}
| true | qemu | b946a1533209f61a93e34898aebb5b43154b99c3 | static void pcnet_common_init(PCNetState *d, NICInfo *nd)
{
d->poll_timer = qemu_new_timer(vm_clock, pcnet_poll_timer, d);
d->nd = nd;
if (nd && nd->vlan) {
d->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
pcnet_receive, pcnet_can_receive, d);
qemu_format_nic_info_str(d->vc, d->nd->macaddr);
} else {
d->vc = NULL;
}
pcnet_h_reset(d);
register_savevm("pcnet", -1, 2, pcnet_save, pcnet_load, d);
}
| {
"code": [
"static void pcnet_common_init(PCNetState *d, NICInfo *nd)",
" pcnet_receive, pcnet_can_receive, d);"
],
"line_no": [
1,
17
]
} | static void FUNC_0(PCNetState *VAR_0, NICInfo *VAR_1)
{
VAR_0->poll_timer = qemu_new_timer(vm_clock, pcnet_poll_timer, VAR_0);
VAR_0->VAR_1 = VAR_1;
if (VAR_1 && VAR_1->vlan) {
VAR_0->vc = qemu_new_vlan_client(VAR_1->vlan, VAR_1->model, VAR_1->name,
pcnet_receive, pcnet_can_receive, VAR_0);
qemu_format_nic_info_str(VAR_0->vc, VAR_0->VAR_1->macaddr);
} else {
VAR_0->vc = NULL;
}
pcnet_h_reset(VAR_0);
register_savevm("pcnet", -1, 2, pcnet_save, pcnet_load, VAR_0);
}
| [
"static void FUNC_0(PCNetState *VAR_0, NICInfo *VAR_1)\n{",
"VAR_0->poll_timer = qemu_new_timer(vm_clock, pcnet_poll_timer, VAR_0);",
"VAR_0->VAR_1 = VAR_1;",
"if (VAR_1 && VAR_1->vlan) {",
"VAR_0->vc = qemu_new_vlan_client(VAR_1->vlan, VAR_1->model, VAR_1->name,\npcnet_receive, pcnet_can_receive, VAR_0);",
"qemu_format_nic_info_str(VAR_0->vc, VAR_0->VAR_1->macaddr);",
"} else {",
"VAR_0->vc = NULL;",
"}",
"pcnet_h_reset(VAR_0);",
"register_savevm(\"pcnet\", -1, 2, pcnet_save, pcnet_load, VAR_0);",
"}"
] | [
1,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15,
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
]
] |
24,571 | static int get_transform_coeffs(AC3DecodeContext * ctx)
{
int i;
ac3_audio_block *ab = &ctx->audio_block;
float *samples = ctx->samples;
int got_cplchan = 0;
int dithflag = 0;
samples += (ctx->bsi.flags & AC3_BSI_LFEON) ? 256 : 0;
for (i = 0; i < ctx->bsi.nfchans; i++) {
if ((ab->flags & AC3_AB_CPLINU) && (ab->chincpl & (1 << i)))
dithflag = 0; /* don't generate dither until channels are decoupled */
else
dithflag = ab->dithflag & (1 << i);
/* transform coefficients for individual channel */
if (_get_transform_coeffs(ab->dexps[i], ab->bap[i], ab->chcoeffs[i], samples + (i * 256),
0, ab->endmant[i], dithflag, &ctx->gb, &ctx->state))
return -1;
/* tranform coefficients for coupling channels */
if ((ab->flags & AC3_AB_CPLINU) && (ab->chincpl & (1 << i)) && !got_cplchan) {
if (_get_transform_coeffs(ab->dcplexps, ab->cplbap, 1.0f, ab->cplcoeffs,
ab->cplstrtmant, ab->cplendmant, 0, &ctx->gb, &ctx->state))
return -1;
got_cplchan = 1;
}
}
if (ctx->bsi.flags & AC3_BSI_LFEON)
if (_get_transform_coeffs(ab->lfeexps, ab->lfebap, 1.0f, samples - 256, 0, 7, 0, &ctx->gb, &ctx->state))
return -1;
/* uncouple the channels from the coupling channel */
if (ab->flags & AC3_AB_CPLINU)
if (uncouple_channels(ctx))
return -1;
return 0;
}
| false | FFmpeg | 0058584580b87feb47898e60e4b80c7f425882ad | static int get_transform_coeffs(AC3DecodeContext * ctx)
{
int i;
ac3_audio_block *ab = &ctx->audio_block;
float *samples = ctx->samples;
int got_cplchan = 0;
int dithflag = 0;
samples += (ctx->bsi.flags & AC3_BSI_LFEON) ? 256 : 0;
for (i = 0; i < ctx->bsi.nfchans; i++) {
if ((ab->flags & AC3_AB_CPLINU) && (ab->chincpl & (1 << i)))
dithflag = 0;
else
dithflag = ab->dithflag & (1 << i);
if (_get_transform_coeffs(ab->dexps[i], ab->bap[i], ab->chcoeffs[i], samples + (i * 256),
0, ab->endmant[i], dithflag, &ctx->gb, &ctx->state))
return -1;
if ((ab->flags & AC3_AB_CPLINU) && (ab->chincpl & (1 << i)) && !got_cplchan) {
if (_get_transform_coeffs(ab->dcplexps, ab->cplbap, 1.0f, ab->cplcoeffs,
ab->cplstrtmant, ab->cplendmant, 0, &ctx->gb, &ctx->state))
return -1;
got_cplchan = 1;
}
}
if (ctx->bsi.flags & AC3_BSI_LFEON)
if (_get_transform_coeffs(ab->lfeexps, ab->lfebap, 1.0f, samples - 256, 0, 7, 0, &ctx->gb, &ctx->state))
return -1;
if (ab->flags & AC3_AB_CPLINU)
if (uncouple_channels(ctx))
return -1;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AC3DecodeContext * VAR_0)
{
int VAR_1;
ac3_audio_block *ab = &VAR_0->audio_block;
float *VAR_2 = VAR_0->VAR_2;
int VAR_3 = 0;
int VAR_4 = 0;
VAR_2 += (VAR_0->bsi.flags & AC3_BSI_LFEON) ? 256 : 0;
for (VAR_1 = 0; VAR_1 < VAR_0->bsi.nfchans; VAR_1++) {
if ((ab->flags & AC3_AB_CPLINU) && (ab->chincpl & (1 << VAR_1)))
VAR_4 = 0;
else
VAR_4 = ab->VAR_4 & (1 << VAR_1);
if (_get_transform_coeffs(ab->dexps[VAR_1], ab->bap[VAR_1], ab->chcoeffs[VAR_1], VAR_2 + (VAR_1 * 256),
0, ab->endmant[VAR_1], VAR_4, &VAR_0->gb, &VAR_0->state))
return -1;
if ((ab->flags & AC3_AB_CPLINU) && (ab->chincpl & (1 << VAR_1)) && !VAR_3) {
if (_get_transform_coeffs(ab->dcplexps, ab->cplbap, 1.0f, ab->cplcoeffs,
ab->cplstrtmant, ab->cplendmant, 0, &VAR_0->gb, &VAR_0->state))
return -1;
VAR_3 = 1;
}
}
if (VAR_0->bsi.flags & AC3_BSI_LFEON)
if (_get_transform_coeffs(ab->lfeexps, ab->lfebap, 1.0f, VAR_2 - 256, 0, 7, 0, &VAR_0->gb, &VAR_0->state))
return -1;
if (ab->flags & AC3_AB_CPLINU)
if (uncouple_channels(VAR_0))
return -1;
return 0;
}
| [
"static int FUNC_0(AC3DecodeContext * VAR_0)\n{",
"int VAR_1;",
"ac3_audio_block *ab = &VAR_0->audio_block;",
"float *VAR_2 = VAR_0->VAR_2;",
"int VAR_3 = 0;",
"int VAR_4 = 0;",
"VAR_2 += (VAR_0->bsi.flags & AC3_BSI_LFEON) ? 256 : 0;",
"for (VAR_1 = 0; VAR_1 < VAR_0->bsi.nfchans; VAR_1++) {",
"if ((ab->flags & AC3_AB_CPLINU) && (ab->chincpl & (1 << VAR_1)))\nVAR_4 = 0;",
"else\nVAR_4 = ab->VAR_4 & (1 << VAR_1);",
"if (_get_transform_coeffs(ab->dexps[VAR_1], ab->bap[VAR_1], ab->chcoeffs[VAR_1], VAR_2 + (VAR_1 * 256),\n0, ab->endmant[VAR_1], VAR_4, &VAR_0->gb, &VAR_0->state))\nreturn -1;",
"if ((ab->flags & AC3_AB_CPLINU) && (ab->chincpl & (1 << VAR_1)) && !VAR_3) {",
"if (_get_transform_coeffs(ab->dcplexps, ab->cplbap, 1.0f, ab->cplcoeffs,\nab->cplstrtmant, ab->cplendmant, 0, &VAR_0->gb, &VAR_0->state))\nreturn -1;",
"VAR_3 = 1;",
"}",
"}",
"if (VAR_0->bsi.flags & AC3_BSI_LFEON)\nif (_get_transform_coeffs(ab->lfeexps, ab->lfebap, 1.0f, VAR_2 - 256, 0, 7, 0, &VAR_0->gb, &VAR_0->state))\nreturn -1;",
"if (ab->flags & AC3_AB_CPLINU)\nif (uncouple_channels(VAR_0))\nreturn -1;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21,
23
],
[
25,
27
],
[
31,
33,
35
],
[
39
],
[
41,
43,
45
],
[
47
],
[
49
],
[
51
],
[
53,
55,
57
],
[
63,
65,
67
],
[
71
],
[
73
]
] |
24,572 | static int mxf_add_metadata_set(MXFContext *mxf, void *metadata_set)
{
int err;
if (mxf->metadata_sets_count+1 >= UINT_MAX / sizeof(*mxf->metadata_sets))
return AVERROR(ENOMEM);
if ((err = av_reallocp_array(&mxf->metadata_sets, mxf->metadata_sets_count + 1,
sizeof(*mxf->metadata_sets))) < 0) {
mxf->metadata_sets_count = 0;
return err;
}
mxf->metadata_sets[mxf->metadata_sets_count] = metadata_set;
mxf->metadata_sets_count++;
return 0;
}
| false | FFmpeg | f5fbbbc022f723d3ccf99afd5d658a977b51c08a | static int mxf_add_metadata_set(MXFContext *mxf, void *metadata_set)
{
int err;
if (mxf->metadata_sets_count+1 >= UINT_MAX / sizeof(*mxf->metadata_sets))
return AVERROR(ENOMEM);
if ((err = av_reallocp_array(&mxf->metadata_sets, mxf->metadata_sets_count + 1,
sizeof(*mxf->metadata_sets))) < 0) {
mxf->metadata_sets_count = 0;
return err;
}
mxf->metadata_sets[mxf->metadata_sets_count] = metadata_set;
mxf->metadata_sets_count++;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MXFContext *VAR_0, void *VAR_1)
{
int VAR_2;
if (VAR_0->metadata_sets_count+1 >= UINT_MAX / sizeof(*VAR_0->metadata_sets))
return AVERROR(ENOMEM);
if ((VAR_2 = av_reallocp_array(&VAR_0->metadata_sets, VAR_0->metadata_sets_count + 1,
sizeof(*VAR_0->metadata_sets))) < 0) {
VAR_0->metadata_sets_count = 0;
return VAR_2;
}
VAR_0->metadata_sets[VAR_0->metadata_sets_count] = VAR_1;
VAR_0->metadata_sets_count++;
return 0;
}
| [
"static int FUNC_0(MXFContext *VAR_0, void *VAR_1)\n{",
"int VAR_2;",
"if (VAR_0->metadata_sets_count+1 >= UINT_MAX / sizeof(*VAR_0->metadata_sets))\nreturn AVERROR(ENOMEM);",
"if ((VAR_2 = av_reallocp_array(&VAR_0->metadata_sets, VAR_0->metadata_sets_count + 1,\nsizeof(*VAR_0->metadata_sets))) < 0) {",
"VAR_0->metadata_sets_count = 0;",
"return VAR_2;",
"}",
"VAR_0->metadata_sets[VAR_0->metadata_sets_count] = VAR_1;",
"VAR_0->metadata_sets_count++;",
"return 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
]
] |
24,573 | static int dvvideo_encode_frame(AVCodecContext *c, AVPacket *pkt,
const AVFrame *frame, int *got_packet)
{
DVVideoContext *s = c->priv_data;
int ret;
s->sys = avpriv_dv_codec_profile(c);
if (!s->sys || ff_dv_init_dynamic_tables(s->sys))
return -1;
if ((ret = ff_alloc_packet(pkt, s->sys->frame_size)) < 0) {
av_log(c, AV_LOG_ERROR, "Error getting output packet.\n");
return ret;
}
c->pix_fmt = s->sys->pix_fmt;
s->frame = frame;
c->coded_frame->key_frame = 1;
c->coded_frame->pict_type = AV_PICTURE_TYPE_I;
s->buf = pkt->data;
c->execute(c, dv_encode_video_segment, s->sys->work_chunks, NULL,
dv_work_pool_size(s->sys), sizeof(DVwork_chunk));
emms_c();
dv_format_frame(s, pkt->data);
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
| false | FFmpeg | 778111592bf5f38630858ee6dfcfd097cd6c6da9 | static int dvvideo_encode_frame(AVCodecContext *c, AVPacket *pkt,
const AVFrame *frame, int *got_packet)
{
DVVideoContext *s = c->priv_data;
int ret;
s->sys = avpriv_dv_codec_profile(c);
if (!s->sys || ff_dv_init_dynamic_tables(s->sys))
return -1;
if ((ret = ff_alloc_packet(pkt, s->sys->frame_size)) < 0) {
av_log(c, AV_LOG_ERROR, "Error getting output packet.\n");
return ret;
}
c->pix_fmt = s->sys->pix_fmt;
s->frame = frame;
c->coded_frame->key_frame = 1;
c->coded_frame->pict_type = AV_PICTURE_TYPE_I;
s->buf = pkt->data;
c->execute(c, dv_encode_video_segment, s->sys->work_chunks, NULL,
dv_work_pool_size(s->sys), sizeof(DVwork_chunk));
emms_c();
dv_format_frame(s, pkt->data);
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,
const AVFrame *VAR_2, int *VAR_3)
{
DVVideoContext *s = VAR_0->priv_data;
int VAR_4;
s->sys = avpriv_dv_codec_profile(VAR_0);
if (!s->sys || ff_dv_init_dynamic_tables(s->sys))
return -1;
if ((VAR_4 = ff_alloc_packet(VAR_1, s->sys->frame_size)) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Error getting output packet.\n");
return VAR_4;
}
VAR_0->pix_fmt = s->sys->pix_fmt;
s->VAR_2 = VAR_2;
VAR_0->coded_frame->key_frame = 1;
VAR_0->coded_frame->pict_type = AV_PICTURE_TYPE_I;
s->buf = VAR_1->data;
VAR_0->execute(VAR_0, dv_encode_video_segment, s->sys->work_chunks, NULL,
dv_work_pool_size(s->sys), sizeof(DVwork_chunk));
emms_c();
dv_format_frame(s, VAR_1->data);
VAR_1->flags |= AV_PKT_FLAG_KEY;
*VAR_3 = 1;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,\nconst AVFrame *VAR_2, int *VAR_3)\n{",
"DVVideoContext *s = VAR_0->priv_data;",
"int VAR_4;",
"s->sys = avpriv_dv_codec_profile(VAR_0);",
"if (!s->sys || ff_dv_init_dynamic_tables(s->sys))\nreturn -1;",
"if ((VAR_4 = ff_alloc_packet(VAR_1, s->sys->frame_size)) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error getting output packet.\\n\");",
"return VAR_4;",
"}",
"VAR_0->pix_fmt = s->sys->pix_fmt;",
"s->VAR_2 = VAR_2;",
"VAR_0->coded_frame->key_frame = 1;",
"VAR_0->coded_frame->pict_type = AV_PICTURE_TYPE_I;",
"s->buf = VAR_1->data;",
"VAR_0->execute(VAR_0, dv_encode_video_segment, s->sys->work_chunks, NULL,\ndv_work_pool_size(s->sys), sizeof(DVwork_chunk));",
"emms_c();",
"dv_format_frame(s, VAR_1->data);",
"VAR_1->flags |= AV_PKT_FLAG_KEY;",
"*VAR_3 = 1;",
"return 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
],
[
39
],
[
41,
43
],
[
47
],
[
51
],
[
55
],
[
57
],
[
61
],
[
63
]
] |
24,574 | static void mxf_write_partition(AVFormatContext *s, int bodysid,
int indexsid,
const uint8_t *key, int write_metadata)
{
MXFContext *mxf = s->priv_data;
ByteIOContext *pb = s->pb;
int64_t header_byte_count_offset;
unsigned index_byte_count = 0;
uint64_t partition_offset = url_ftell(pb);
if (mxf->edit_units_count) {
index_byte_count = 109 + (s->nb_streams+1)*6 +
mxf->edit_units_count*(11+mxf->slice_count*4);
// add encoded ber length
index_byte_count += 16 + klv_ber_length(index_byte_count);
index_byte_count += klv_fill_size(index_byte_count);
}
if (!memcmp(key, body_partition_key, 16)) {
mxf->body_partition_offset =
av_realloc(mxf->body_partition_offset,
(mxf->body_partitions_count+1)*
sizeof(*mxf->body_partition_offset));
mxf->body_partition_offset[mxf->body_partitions_count++] = partition_offset;
}
// write klv
put_buffer(pb, key, 16);
klv_encode_ber_length(pb, 88 + 16 * mxf->essence_container_count);
// write partition value
put_be16(pb, 1); // majorVersion
put_be16(pb, 2); // minorVersion
put_be32(pb, KAG_SIZE); // KAGSize
put_be64(pb, partition_offset); // ThisPartition
if (!memcmp(key, body_partition_key, 16) && mxf->body_partitions_count > 1)
put_be64(pb, mxf->body_partition_offset[mxf->body_partitions_count-2]); // PreviousPartition
else if (!memcmp(key, footer_partition_key, 16))
put_be64(pb, mxf->body_partition_offset[mxf->body_partitions_count-1]); // PreviousPartition
else
put_be64(pb, 0);
put_be64(pb, mxf->footer_partition_offset); // footerPartition
// set offset
header_byte_count_offset = url_ftell(pb);
put_be64(pb, 0); // headerByteCount, update later
// indexTable
put_be64(pb, index_byte_count); // indexByteCount
put_be32(pb, index_byte_count ? indexsid : 0); // indexSID
// BodyOffset
if (bodysid && mxf->edit_units_count) {
uint64_t partition_end = url_ftell(pb) + 8 + 4 + 16 + 8 +
16*mxf->essence_container_count;
put_be64(pb, partition_end + klv_fill_size(partition_end) +
index_byte_count - mxf->first_edit_unit_offset);
} else
put_be64(pb, 0);
put_be32(pb, bodysid); // bodySID
// operational pattern
if (s->nb_streams > 1) {
put_buffer(pb, op1a_ul, 14);
put_be16(pb, 0x0900); // multi track
} else {
put_buffer(pb, op1a_ul, 16);
}
// essence container
mxf_write_essence_container_refs(s);
if (write_metadata) {
// mark the start of the headermetadata and calculate metadata size
int64_t pos, start;
unsigned header_byte_count;
mxf_write_klv_fill(s);
start = url_ftell(s->pb);
mxf_write_primer_pack(s);
mxf_write_header_metadata_sets(s);
pos = url_ftell(s->pb);
header_byte_count = pos - start + klv_fill_size(pos);
// update header_byte_count
url_fseek(pb, header_byte_count_offset, SEEK_SET);
put_be64(pb, header_byte_count);
url_fseek(pb, pos, SEEK_SET);
}
put_flush_packet(pb);
}
| false | FFmpeg | cfa3caf81cd64485b80def8bb2552c2dafac5eb4 | static void mxf_write_partition(AVFormatContext *s, int bodysid,
int indexsid,
const uint8_t *key, int write_metadata)
{
MXFContext *mxf = s->priv_data;
ByteIOContext *pb = s->pb;
int64_t header_byte_count_offset;
unsigned index_byte_count = 0;
uint64_t partition_offset = url_ftell(pb);
if (mxf->edit_units_count) {
index_byte_count = 109 + (s->nb_streams+1)*6 +
mxf->edit_units_count*(11+mxf->slice_count*4);
index_byte_count += 16 + klv_ber_length(index_byte_count);
index_byte_count += klv_fill_size(index_byte_count);
}
if (!memcmp(key, body_partition_key, 16)) {
mxf->body_partition_offset =
av_realloc(mxf->body_partition_offset,
(mxf->body_partitions_count+1)*
sizeof(*mxf->body_partition_offset));
mxf->body_partition_offset[mxf->body_partitions_count++] = partition_offset;
}
put_buffer(pb, key, 16);
klv_encode_ber_length(pb, 88 + 16 * mxf->essence_container_count);
put_be16(pb, 1);
put_be16(pb, 2);
put_be32(pb, KAG_SIZE);
put_be64(pb, partition_offset);
if (!memcmp(key, body_partition_key, 16) && mxf->body_partitions_count > 1)
put_be64(pb, mxf->body_partition_offset[mxf->body_partitions_count-2]);
else if (!memcmp(key, footer_partition_key, 16))
put_be64(pb, mxf->body_partition_offset[mxf->body_partitions_count-1]);
else
put_be64(pb, 0);
put_be64(pb, mxf->footer_partition_offset);
header_byte_count_offset = url_ftell(pb);
put_be64(pb, 0);
put_be64(pb, index_byte_count);
put_be32(pb, index_byte_count ? indexsid : 0);
if (bodysid && mxf->edit_units_count) {
uint64_t partition_end = url_ftell(pb) + 8 + 4 + 16 + 8 +
16*mxf->essence_container_count;
put_be64(pb, partition_end + klv_fill_size(partition_end) +
index_byte_count - mxf->first_edit_unit_offset);
} else
put_be64(pb, 0);
put_be32(pb, bodysid);
if (s->nb_streams > 1) {
put_buffer(pb, op1a_ul, 14);
put_be16(pb, 0x0900);
} else {
put_buffer(pb, op1a_ul, 16);
}
mxf_write_essence_container_refs(s);
if (write_metadata) {
int64_t pos, start;
unsigned header_byte_count;
mxf_write_klv_fill(s);
start = url_ftell(s->pb);
mxf_write_primer_pack(s);
mxf_write_header_metadata_sets(s);
pos = url_ftell(s->pb);
header_byte_count = pos - start + klv_fill_size(pos);
url_fseek(pb, header_byte_count_offset, SEEK_SET);
put_be64(pb, header_byte_count);
url_fseek(pb, pos, SEEK_SET);
}
put_flush_packet(pb);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVFormatContext *VAR_0, int VAR_1,
int VAR_2,
const uint8_t *VAR_3, int VAR_4)
{
MXFContext *mxf = VAR_0->priv_data;
ByteIOContext *pb = VAR_0->pb;
int64_t header_byte_count_offset;
unsigned VAR_5 = 0;
uint64_t partition_offset = url_ftell(pb);
if (mxf->edit_units_count) {
VAR_5 = 109 + (VAR_0->nb_streams+1)*6 +
mxf->edit_units_count*(11+mxf->slice_count*4);
VAR_5 += 16 + klv_ber_length(VAR_5);
VAR_5 += klv_fill_size(VAR_5);
}
if (!memcmp(VAR_3, body_partition_key, 16)) {
mxf->body_partition_offset =
av_realloc(mxf->body_partition_offset,
(mxf->body_partitions_count+1)*
sizeof(*mxf->body_partition_offset));
mxf->body_partition_offset[mxf->body_partitions_count++] = partition_offset;
}
put_buffer(pb, VAR_3, 16);
klv_encode_ber_length(pb, 88 + 16 * mxf->essence_container_count);
put_be16(pb, 1);
put_be16(pb, 2);
put_be32(pb, KAG_SIZE);
put_be64(pb, partition_offset);
if (!memcmp(VAR_3, body_partition_key, 16) && mxf->body_partitions_count > 1)
put_be64(pb, mxf->body_partition_offset[mxf->body_partitions_count-2]);
else if (!memcmp(VAR_3, footer_partition_key, 16))
put_be64(pb, mxf->body_partition_offset[mxf->body_partitions_count-1]);
else
put_be64(pb, 0);
put_be64(pb, mxf->footer_partition_offset);
header_byte_count_offset = url_ftell(pb);
put_be64(pb, 0);
put_be64(pb, VAR_5);
put_be32(pb, VAR_5 ? VAR_2 : 0);
if (VAR_1 && mxf->edit_units_count) {
uint64_t partition_end = url_ftell(pb) + 8 + 4 + 16 + 8 +
16*mxf->essence_container_count;
put_be64(pb, partition_end + klv_fill_size(partition_end) +
VAR_5 - mxf->first_edit_unit_offset);
} else
put_be64(pb, 0);
put_be32(pb, VAR_1);
if (VAR_0->nb_streams > 1) {
put_buffer(pb, op1a_ul, 14);
put_be16(pb, 0x0900);
} else {
put_buffer(pb, op1a_ul, 16);
}
mxf_write_essence_container_refs(VAR_0);
if (VAR_4) {
int64_t pos, start;
unsigned VAR_6;
mxf_write_klv_fill(VAR_0);
start = url_ftell(VAR_0->pb);
mxf_write_primer_pack(VAR_0);
mxf_write_header_metadata_sets(VAR_0);
pos = url_ftell(VAR_0->pb);
VAR_6 = pos - start + klv_fill_size(pos);
url_fseek(pb, header_byte_count_offset, SEEK_SET);
put_be64(pb, VAR_6);
url_fseek(pb, pos, SEEK_SET);
}
put_flush_packet(pb);
}
| [
"static void FUNC_0(AVFormatContext *VAR_0, int VAR_1,\nint VAR_2,\nconst uint8_t *VAR_3, int VAR_4)\n{",
"MXFContext *mxf = VAR_0->priv_data;",
"ByteIOContext *pb = VAR_0->pb;",
"int64_t header_byte_count_offset;",
"unsigned VAR_5 = 0;",
"uint64_t partition_offset = url_ftell(pb);",
"if (mxf->edit_units_count) {",
"VAR_5 = 109 + (VAR_0->nb_streams+1)*6 +\nmxf->edit_units_count*(11+mxf->slice_count*4);",
"VAR_5 += 16 + klv_ber_length(VAR_5);",
"VAR_5 += klv_fill_size(VAR_5);",
"}",
"if (!memcmp(VAR_3, body_partition_key, 16)) {",
"mxf->body_partition_offset =\nav_realloc(mxf->body_partition_offset,\n(mxf->body_partitions_count+1)*\nsizeof(*mxf->body_partition_offset));",
"mxf->body_partition_offset[mxf->body_partitions_count++] = partition_offset;",
"}",
"put_buffer(pb, VAR_3, 16);",
"klv_encode_ber_length(pb, 88 + 16 * mxf->essence_container_count);",
"put_be16(pb, 1);",
"put_be16(pb, 2);",
"put_be32(pb, KAG_SIZE);",
"put_be64(pb, partition_offset);",
"if (!memcmp(VAR_3, body_partition_key, 16) && mxf->body_partitions_count > 1)\nput_be64(pb, mxf->body_partition_offset[mxf->body_partitions_count-2]);",
"else if (!memcmp(VAR_3, footer_partition_key, 16))\nput_be64(pb, mxf->body_partition_offset[mxf->body_partitions_count-1]);",
"else\nput_be64(pb, 0);",
"put_be64(pb, mxf->footer_partition_offset);",
"header_byte_count_offset = url_ftell(pb);",
"put_be64(pb, 0);",
"put_be64(pb, VAR_5);",
"put_be32(pb, VAR_5 ? VAR_2 : 0);",
"if (VAR_1 && mxf->edit_units_count) {",
"uint64_t partition_end = url_ftell(pb) + 8 + 4 + 16 + 8 +\n16*mxf->essence_container_count;",
"put_be64(pb, partition_end + klv_fill_size(partition_end) +\nVAR_5 - mxf->first_edit_unit_offset);",
"} else",
"put_be64(pb, 0);",
"put_be32(pb, VAR_1);",
"if (VAR_0->nb_streams > 1) {",
"put_buffer(pb, op1a_ul, 14);",
"put_be16(pb, 0x0900);",
"} else {",
"put_buffer(pb, op1a_ul, 16);",
"}",
"mxf_write_essence_container_refs(VAR_0);",
"if (VAR_4) {",
"int64_t pos, start;",
"unsigned VAR_6;",
"mxf_write_klv_fill(VAR_0);",
"start = url_ftell(VAR_0->pb);",
"mxf_write_primer_pack(VAR_0);",
"mxf_write_header_metadata_sets(VAR_0);",
"pos = url_ftell(VAR_0->pb);",
"VAR_6 = pos - start + klv_fill_size(pos);",
"url_fseek(pb, header_byte_count_offset, SEEK_SET);",
"put_be64(pb, VAR_6);",
"url_fseek(pb, pos, SEEK_SET);",
"}",
"put_flush_packet(pb);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39,
41,
43,
45
],
[
47
],
[
49
],
[
55
],
[
59
],
[
65
],
[
67
],
[
69
],
[
73
],
[
77,
79
],
[
81,
83
],
[
85,
87
],
[
91
],
[
97
],
[
99
],
[
105
],
[
107
],
[
113
],
[
115,
117
],
[
119,
121
],
[
123
],
[
125
],
[
129
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
151
],
[
155
],
[
159
],
[
161
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191
],
[
193
]
] |
24,576 | static void *spapr_create_fdt_skel(const char *cpu_model,
target_phys_addr_t rma_size,
target_phys_addr_t initrd_base,
target_phys_addr_t initrd_size,
target_phys_addr_t kernel_size,
const char *boot_device,
const char *kernel_cmdline,
long hash_shift)
{
void *fdt;
CPUPPCState *env;
uint64_t mem_reg_property[2];
uint32_t start_prop = cpu_to_be32(initrd_base);
uint32_t end_prop = cpu_to_be32(initrd_base + initrd_size);
uint32_t pft_size_prop[] = {0, cpu_to_be32(hash_shift)};
char hypertas_prop[] = "hcall-pft\0hcall-term\0hcall-dabr\0hcall-interrupt"
"\0hcall-tce\0hcall-vio\0hcall-splpar\0hcall-bulk";
char qemu_hypertas_prop[] = "hcall-memop1";
uint32_t interrupt_server_ranges_prop[] = {0, cpu_to_be32(smp_cpus)};
int i;
char *modelname;
int smt = kvmppc_smt_threads();
unsigned char vec5[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x80};
uint32_t refpoints[] = {cpu_to_be32(0x4), cpu_to_be32(0x4)};
uint32_t associativity[] = {cpu_to_be32(0x4), cpu_to_be32(0x0),
cpu_to_be32(0x0), cpu_to_be32(0x0),
cpu_to_be32(0x0)};
char mem_name[32];
target_phys_addr_t node0_size, mem_start;
#define _FDT(exp) \
do { \
int ret = (exp); \
if (ret < 0) { \
fprintf(stderr, "qemu: error creating device tree: %s: %s\n", \
#exp, fdt_strerror(ret)); \
exit(1); \
} \
} while (0)
fdt = g_malloc0(FDT_MAX_SIZE);
_FDT((fdt_create(fdt, FDT_MAX_SIZE)));
if (kernel_size) {
_FDT((fdt_add_reservemap_entry(fdt, KERNEL_LOAD_ADDR, kernel_size)));
}
if (initrd_size) {
_FDT((fdt_add_reservemap_entry(fdt, initrd_base, initrd_size)));
}
_FDT((fdt_finish_reservemap(fdt)));
/* Root node */
_FDT((fdt_begin_node(fdt, "")));
_FDT((fdt_property_string(fdt, "device_type", "chrp")));
_FDT((fdt_property_string(fdt, "model", "IBM pSeries (emulated by qemu)")));
_FDT((fdt_property_cell(fdt, "#address-cells", 0x2)));
_FDT((fdt_property_cell(fdt, "#size-cells", 0x2)));
/* /chosen */
_FDT((fdt_begin_node(fdt, "chosen")));
/* Set Form1_affinity */
_FDT((fdt_property(fdt, "ibm,architecture-vec-5", vec5, sizeof(vec5))));
_FDT((fdt_property_string(fdt, "bootargs", kernel_cmdline)));
_FDT((fdt_property(fdt, "linux,initrd-start",
&start_prop, sizeof(start_prop))));
_FDT((fdt_property(fdt, "linux,initrd-end",
&end_prop, sizeof(end_prop))));
if (kernel_size) {
uint64_t kprop[2] = { cpu_to_be64(KERNEL_LOAD_ADDR),
cpu_to_be64(kernel_size) };
_FDT((fdt_property(fdt, "qemu,boot-kernel", &kprop, sizeof(kprop))));
}
_FDT((fdt_property_string(fdt, "qemu,boot-device", boot_device)));
_FDT((fdt_property_cell(fdt, "qemu,graphic-width", graphic_width)));
_FDT((fdt_property_cell(fdt, "qemu,graphic-height", graphic_height)));
_FDT((fdt_property_cell(fdt, "qemu,graphic-depth", graphic_depth)));
_FDT((fdt_end_node(fdt)));
/* memory node(s) */
node0_size = (nb_numa_nodes > 1) ? node_mem[0] : ram_size;
if (rma_size > node0_size) {
rma_size = node0_size;
}
/* RMA */
mem_reg_property[0] = 0;
mem_reg_property[1] = cpu_to_be64(rma_size);
_FDT((fdt_begin_node(fdt, "memory@0")));
_FDT((fdt_property_string(fdt, "device_type", "memory")));
_FDT((fdt_property(fdt, "reg", mem_reg_property,
sizeof(mem_reg_property))));
_FDT((fdt_property(fdt, "ibm,associativity", associativity,
sizeof(associativity))));
_FDT((fdt_end_node(fdt)));
/* RAM: Node 0 */
if (node0_size > rma_size) {
mem_reg_property[0] = cpu_to_be64(rma_size);
mem_reg_property[1] = cpu_to_be64(node0_size - rma_size);
sprintf(mem_name, "memory@" TARGET_FMT_lx, rma_size);
_FDT((fdt_begin_node(fdt, mem_name)));
_FDT((fdt_property_string(fdt, "device_type", "memory")));
_FDT((fdt_property(fdt, "reg", mem_reg_property,
sizeof(mem_reg_property))));
_FDT((fdt_property(fdt, "ibm,associativity", associativity,
sizeof(associativity))));
_FDT((fdt_end_node(fdt)));
}
/* RAM: Node 1 and beyond */
mem_start = node0_size;
for (i = 1; i < nb_numa_nodes; i++) {
mem_reg_property[0] = cpu_to_be64(mem_start);
mem_reg_property[1] = cpu_to_be64(node_mem[i]);
associativity[3] = associativity[4] = cpu_to_be32(i);
sprintf(mem_name, "memory@" TARGET_FMT_lx, mem_start);
_FDT((fdt_begin_node(fdt, mem_name)));
_FDT((fdt_property_string(fdt, "device_type", "memory")));
_FDT((fdt_property(fdt, "reg", mem_reg_property,
sizeof(mem_reg_property))));
_FDT((fdt_property(fdt, "ibm,associativity", associativity,
sizeof(associativity))));
_FDT((fdt_end_node(fdt)));
mem_start += node_mem[i];
}
/* cpus */
_FDT((fdt_begin_node(fdt, "cpus")));
_FDT((fdt_property_cell(fdt, "#address-cells", 0x1)));
_FDT((fdt_property_cell(fdt, "#size-cells", 0x0)));
modelname = g_strdup(cpu_model);
for (i = 0; i < strlen(modelname); i++) {
modelname[i] = toupper(modelname[i]);
}
/* This is needed during FDT finalization */
spapr->cpu_model = g_strdup(modelname);
for (env = first_cpu; env != NULL; env = env->next_cpu) {
int index = env->cpu_index;
uint32_t servers_prop[smp_threads];
uint32_t gservers_prop[smp_threads * 2];
char *nodename;
uint32_t segs[] = {cpu_to_be32(28), cpu_to_be32(40),
0xffffffff, 0xffffffff};
uint32_t tbfreq = kvm_enabled() ? kvmppc_get_tbfreq() : TIMEBASE_FREQ;
uint32_t cpufreq = kvm_enabled() ? kvmppc_get_clockfreq() : 1000000000;
uint32_t page_sizes_prop[64];
size_t page_sizes_prop_size;
if ((index % smt) != 0) {
continue;
}
if (asprintf(&nodename, "%s@%x", modelname, index) < 0) {
fprintf(stderr, "Allocation failure\n");
exit(1);
}
_FDT((fdt_begin_node(fdt, nodename)));
free(nodename);
_FDT((fdt_property_cell(fdt, "reg", index)));
_FDT((fdt_property_string(fdt, "device_type", "cpu")));
_FDT((fdt_property_cell(fdt, "cpu-version", env->spr[SPR_PVR])));
_FDT((fdt_property_cell(fdt, "dcache-block-size",
env->dcache_line_size)));
_FDT((fdt_property_cell(fdt, "icache-block-size",
env->icache_line_size)));
_FDT((fdt_property_cell(fdt, "timebase-frequency", tbfreq)));
_FDT((fdt_property_cell(fdt, "clock-frequency", cpufreq)));
_FDT((fdt_property_cell(fdt, "ibm,slb-size", env->slb_nr)));
_FDT((fdt_property(fdt, "ibm,pft-size",
pft_size_prop, sizeof(pft_size_prop))));
_FDT((fdt_property_string(fdt, "status", "okay")));
_FDT((fdt_property(fdt, "64-bit", NULL, 0)));
/* Build interrupt servers and gservers properties */
for (i = 0; i < smp_threads; i++) {
servers_prop[i] = cpu_to_be32(index + i);
/* Hack, direct the group queues back to cpu 0 */
gservers_prop[i*2] = cpu_to_be32(index + i);
gservers_prop[i*2 + 1] = 0;
}
_FDT((fdt_property(fdt, "ibm,ppc-interrupt-server#s",
servers_prop, sizeof(servers_prop))));
_FDT((fdt_property(fdt, "ibm,ppc-interrupt-gserver#s",
gservers_prop, sizeof(gservers_prop))));
if (env->mmu_model & POWERPC_MMU_1TSEG) {
_FDT((fdt_property(fdt, "ibm,processor-segment-sizes",
segs, sizeof(segs))));
}
/* Advertise VMX/VSX (vector extensions) if available
* 0 / no property == no vector extensions
* 1 == VMX / Altivec available
* 2 == VSX available */
if (env->insns_flags & PPC_ALTIVEC) {
uint32_t vmx = (env->insns_flags2 & PPC2_VSX) ? 2 : 1;
_FDT((fdt_property_cell(fdt, "ibm,vmx", vmx)));
}
/* Advertise DFP (Decimal Floating Point) if available
* 0 / no property == no DFP
* 1 == DFP available */
if (env->insns_flags2 & PPC2_DFP) {
_FDT((fdt_property_cell(fdt, "ibm,dfp", 1)));
}
page_sizes_prop_size = create_page_sizes_prop(env, page_sizes_prop,
sizeof(page_sizes_prop));
if (page_sizes_prop_size) {
_FDT((fdt_property(fdt, "ibm,segment-page-sizes",
page_sizes_prop, page_sizes_prop_size)));
}
_FDT((fdt_end_node(fdt)));
}
g_free(modelname);
_FDT((fdt_end_node(fdt)));
/* RTAS */
_FDT((fdt_begin_node(fdt, "rtas")));
_FDT((fdt_property(fdt, "ibm,hypertas-functions", hypertas_prop,
sizeof(hypertas_prop))));
_FDT((fdt_property(fdt, "qemu,hypertas-functions", qemu_hypertas_prop,
sizeof(qemu_hypertas_prop))));
_FDT((fdt_property(fdt, "ibm,associativity-reference-points",
refpoints, sizeof(refpoints))));
_FDT((fdt_end_node(fdt)));
/* interrupt controller */
_FDT((fdt_begin_node(fdt, "interrupt-controller")));
_FDT((fdt_property_string(fdt, "device_type",
"PowerPC-External-Interrupt-Presentation")));
_FDT((fdt_property_string(fdt, "compatible", "IBM,ppc-xicp")));
_FDT((fdt_property(fdt, "interrupt-controller", NULL, 0)));
_FDT((fdt_property(fdt, "ibm,interrupt-server-ranges",
interrupt_server_ranges_prop,
sizeof(interrupt_server_ranges_prop))));
_FDT((fdt_property_cell(fdt, "#interrupt-cells", 2)));
_FDT((fdt_property_cell(fdt, "linux,phandle", PHANDLE_XICP)));
_FDT((fdt_property_cell(fdt, "phandle", PHANDLE_XICP)));
_FDT((fdt_end_node(fdt)));
/* vdevice */
_FDT((fdt_begin_node(fdt, "vdevice")));
_FDT((fdt_property_string(fdt, "device_type", "vdevice")));
_FDT((fdt_property_string(fdt, "compatible", "IBM,vdevice")));
_FDT((fdt_property_cell(fdt, "#address-cells", 0x1)));
_FDT((fdt_property_cell(fdt, "#size-cells", 0x0)));
_FDT((fdt_property_cell(fdt, "#interrupt-cells", 0x2)));
_FDT((fdt_property(fdt, "interrupt-controller", NULL, 0)));
_FDT((fdt_end_node(fdt)));
_FDT((fdt_end_node(fdt))); /* close root node */
_FDT((fdt_finish(fdt)));
return fdt;
}
| true | qemu | 7f763a5d994bbddb50705d2e50decdf52937521f | static void *spapr_create_fdt_skel(const char *cpu_model,
target_phys_addr_t rma_size,
target_phys_addr_t initrd_base,
target_phys_addr_t initrd_size,
target_phys_addr_t kernel_size,
const char *boot_device,
const char *kernel_cmdline,
long hash_shift)
{
void *fdt;
CPUPPCState *env;
uint64_t mem_reg_property[2];
uint32_t start_prop = cpu_to_be32(initrd_base);
uint32_t end_prop = cpu_to_be32(initrd_base + initrd_size);
uint32_t pft_size_prop[] = {0, cpu_to_be32(hash_shift)};
char hypertas_prop[] = "hcall-pft\0hcall-term\0hcall-dabr\0hcall-interrupt"
"\0hcall-tce\0hcall-vio\0hcall-splpar\0hcall-bulk";
char qemu_hypertas_prop[] = "hcall-memop1";
uint32_t interrupt_server_ranges_prop[] = {0, cpu_to_be32(smp_cpus)};
int i;
char *modelname;
int smt = kvmppc_smt_threads();
unsigned char vec5[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x80};
uint32_t refpoints[] = {cpu_to_be32(0x4), cpu_to_be32(0x4)};
uint32_t associativity[] = {cpu_to_be32(0x4), cpu_to_be32(0x0),
cpu_to_be32(0x0), cpu_to_be32(0x0),
cpu_to_be32(0x0)};
char mem_name[32];
target_phys_addr_t node0_size, mem_start;
#define _FDT(exp) \
do { \
int ret = (exp); \
if (ret < 0) { \
fprintf(stderr, "qemu: error creating device tree: %s: %s\n", \
#exp, fdt_strerror(ret)); \
exit(1); \
} \
} while (0)
fdt = g_malloc0(FDT_MAX_SIZE);
_FDT((fdt_create(fdt, FDT_MAX_SIZE)));
if (kernel_size) {
_FDT((fdt_add_reservemap_entry(fdt, KERNEL_LOAD_ADDR, kernel_size)));
}
if (initrd_size) {
_FDT((fdt_add_reservemap_entry(fdt, initrd_base, initrd_size)));
}
_FDT((fdt_finish_reservemap(fdt)));
_FDT((fdt_begin_node(fdt, "")));
_FDT((fdt_property_string(fdt, "device_type", "chrp")));
_FDT((fdt_property_string(fdt, "model", "IBM pSeries (emulated by qemu)")));
_FDT((fdt_property_cell(fdt, "#address-cells", 0x2)));
_FDT((fdt_property_cell(fdt, "#size-cells", 0x2)));
_FDT((fdt_begin_node(fdt, "chosen")));
_FDT((fdt_property(fdt, "ibm,architecture-vec-5", vec5, sizeof(vec5))));
_FDT((fdt_property_string(fdt, "bootargs", kernel_cmdline)));
_FDT((fdt_property(fdt, "linux,initrd-start",
&start_prop, sizeof(start_prop))));
_FDT((fdt_property(fdt, "linux,initrd-end",
&end_prop, sizeof(end_prop))));
if (kernel_size) {
uint64_t kprop[2] = { cpu_to_be64(KERNEL_LOAD_ADDR),
cpu_to_be64(kernel_size) };
_FDT((fdt_property(fdt, "qemu,boot-kernel", &kprop, sizeof(kprop))));
}
_FDT((fdt_property_string(fdt, "qemu,boot-device", boot_device)));
_FDT((fdt_property_cell(fdt, "qemu,graphic-width", graphic_width)));
_FDT((fdt_property_cell(fdt, "qemu,graphic-height", graphic_height)));
_FDT((fdt_property_cell(fdt, "qemu,graphic-depth", graphic_depth)));
_FDT((fdt_end_node(fdt)));
node0_size = (nb_numa_nodes > 1) ? node_mem[0] : ram_size;
if (rma_size > node0_size) {
rma_size = node0_size;
}
mem_reg_property[0] = 0;
mem_reg_property[1] = cpu_to_be64(rma_size);
_FDT((fdt_begin_node(fdt, "memory@0")));
_FDT((fdt_property_string(fdt, "device_type", "memory")));
_FDT((fdt_property(fdt, "reg", mem_reg_property,
sizeof(mem_reg_property))));
_FDT((fdt_property(fdt, "ibm,associativity", associativity,
sizeof(associativity))));
_FDT((fdt_end_node(fdt)));
if (node0_size > rma_size) {
mem_reg_property[0] = cpu_to_be64(rma_size);
mem_reg_property[1] = cpu_to_be64(node0_size - rma_size);
sprintf(mem_name, "memory@" TARGET_FMT_lx, rma_size);
_FDT((fdt_begin_node(fdt, mem_name)));
_FDT((fdt_property_string(fdt, "device_type", "memory")));
_FDT((fdt_property(fdt, "reg", mem_reg_property,
sizeof(mem_reg_property))));
_FDT((fdt_property(fdt, "ibm,associativity", associativity,
sizeof(associativity))));
_FDT((fdt_end_node(fdt)));
}
mem_start = node0_size;
for (i = 1; i < nb_numa_nodes; i++) {
mem_reg_property[0] = cpu_to_be64(mem_start);
mem_reg_property[1] = cpu_to_be64(node_mem[i]);
associativity[3] = associativity[4] = cpu_to_be32(i);
sprintf(mem_name, "memory@" TARGET_FMT_lx, mem_start);
_FDT((fdt_begin_node(fdt, mem_name)));
_FDT((fdt_property_string(fdt, "device_type", "memory")));
_FDT((fdt_property(fdt, "reg", mem_reg_property,
sizeof(mem_reg_property))));
_FDT((fdt_property(fdt, "ibm,associativity", associativity,
sizeof(associativity))));
_FDT((fdt_end_node(fdt)));
mem_start += node_mem[i];
}
_FDT((fdt_begin_node(fdt, "cpus")));
_FDT((fdt_property_cell(fdt, "#address-cells", 0x1)));
_FDT((fdt_property_cell(fdt, "#size-cells", 0x0)));
modelname = g_strdup(cpu_model);
for (i = 0; i < strlen(modelname); i++) {
modelname[i] = toupper(modelname[i]);
}
spapr->cpu_model = g_strdup(modelname);
for (env = first_cpu; env != NULL; env = env->next_cpu) {
int index = env->cpu_index;
uint32_t servers_prop[smp_threads];
uint32_t gservers_prop[smp_threads * 2];
char *nodename;
uint32_t segs[] = {cpu_to_be32(28), cpu_to_be32(40),
0xffffffff, 0xffffffff};
uint32_t tbfreq = kvm_enabled() ? kvmppc_get_tbfreq() : TIMEBASE_FREQ;
uint32_t cpufreq = kvm_enabled() ? kvmppc_get_clockfreq() : 1000000000;
uint32_t page_sizes_prop[64];
size_t page_sizes_prop_size;
if ((index % smt) != 0) {
continue;
}
if (asprintf(&nodename, "%s@%x", modelname, index) < 0) {
fprintf(stderr, "Allocation failure\n");
exit(1);
}
_FDT((fdt_begin_node(fdt, nodename)));
free(nodename);
_FDT((fdt_property_cell(fdt, "reg", index)));
_FDT((fdt_property_string(fdt, "device_type", "cpu")));
_FDT((fdt_property_cell(fdt, "cpu-version", env->spr[SPR_PVR])));
_FDT((fdt_property_cell(fdt, "dcache-block-size",
env->dcache_line_size)));
_FDT((fdt_property_cell(fdt, "icache-block-size",
env->icache_line_size)));
_FDT((fdt_property_cell(fdt, "timebase-frequency", tbfreq)));
_FDT((fdt_property_cell(fdt, "clock-frequency", cpufreq)));
_FDT((fdt_property_cell(fdt, "ibm,slb-size", env->slb_nr)));
_FDT((fdt_property(fdt, "ibm,pft-size",
pft_size_prop, sizeof(pft_size_prop))));
_FDT((fdt_property_string(fdt, "status", "okay")));
_FDT((fdt_property(fdt, "64-bit", NULL, 0)));
for (i = 0; i < smp_threads; i++) {
servers_prop[i] = cpu_to_be32(index + i);
gservers_prop[i*2] = cpu_to_be32(index + i);
gservers_prop[i*2 + 1] = 0;
}
_FDT((fdt_property(fdt, "ibm,ppc-interrupt-server#s",
servers_prop, sizeof(servers_prop))));
_FDT((fdt_property(fdt, "ibm,ppc-interrupt-gserver#s",
gservers_prop, sizeof(gservers_prop))));
if (env->mmu_model & POWERPC_MMU_1TSEG) {
_FDT((fdt_property(fdt, "ibm,processor-segment-sizes",
segs, sizeof(segs))));
}
if (env->insns_flags & PPC_ALTIVEC) {
uint32_t vmx = (env->insns_flags2 & PPC2_VSX) ? 2 : 1;
_FDT((fdt_property_cell(fdt, "ibm,vmx", vmx)));
}
if (env->insns_flags2 & PPC2_DFP) {
_FDT((fdt_property_cell(fdt, "ibm,dfp", 1)));
}
page_sizes_prop_size = create_page_sizes_prop(env, page_sizes_prop,
sizeof(page_sizes_prop));
if (page_sizes_prop_size) {
_FDT((fdt_property(fdt, "ibm,segment-page-sizes",
page_sizes_prop, page_sizes_prop_size)));
}
_FDT((fdt_end_node(fdt)));
}
g_free(modelname);
_FDT((fdt_end_node(fdt)));
_FDT((fdt_begin_node(fdt, "rtas")));
_FDT((fdt_property(fdt, "ibm,hypertas-functions", hypertas_prop,
sizeof(hypertas_prop))));
_FDT((fdt_property(fdt, "qemu,hypertas-functions", qemu_hypertas_prop,
sizeof(qemu_hypertas_prop))));
_FDT((fdt_property(fdt, "ibm,associativity-reference-points",
refpoints, sizeof(refpoints))));
_FDT((fdt_end_node(fdt)));
_FDT((fdt_begin_node(fdt, "interrupt-controller")));
_FDT((fdt_property_string(fdt, "device_type",
"PowerPC-External-Interrupt-Presentation")));
_FDT((fdt_property_string(fdt, "compatible", "IBM,ppc-xicp")));
_FDT((fdt_property(fdt, "interrupt-controller", NULL, 0)));
_FDT((fdt_property(fdt, "ibm,interrupt-server-ranges",
interrupt_server_ranges_prop,
sizeof(interrupt_server_ranges_prop))));
_FDT((fdt_property_cell(fdt, "#interrupt-cells", 2)));
_FDT((fdt_property_cell(fdt, "linux,phandle", PHANDLE_XICP)));
_FDT((fdt_property_cell(fdt, "phandle", PHANDLE_XICP)));
_FDT((fdt_end_node(fdt)));
_FDT((fdt_begin_node(fdt, "vdevice")));
_FDT((fdt_property_string(fdt, "device_type", "vdevice")));
_FDT((fdt_property_string(fdt, "compatible", "IBM,vdevice")));
_FDT((fdt_property_cell(fdt, "#address-cells", 0x1)));
_FDT((fdt_property_cell(fdt, "#size-cells", 0x0)));
_FDT((fdt_property_cell(fdt, "#interrupt-cells", 0x2)));
_FDT((fdt_property(fdt, "interrupt-controller", NULL, 0)));
_FDT((fdt_end_node(fdt)));
_FDT((fdt_end_node(fdt)));
_FDT((fdt_finish(fdt)));
return fdt;
}
| {
"code": [
" target_phys_addr_t rma_size,",
" const char *kernel_cmdline,",
" long hash_shift)",
" uint64_t mem_reg_property[2];",
" uint32_t pft_size_prop[] = {0, cpu_to_be32(hash_shift)};",
" int i;",
" int smt = kvmppc_smt_threads();",
" uint32_t refpoints[] = {cpu_to_be32(0x4), cpu_to_be32(0x4)};",
" uint32_t associativity[] = {cpu_to_be32(0x4), cpu_to_be32(0x0),",
" cpu_to_be32(0x0), cpu_to_be32(0x0),",
" cpu_to_be32(0x0)};",
" char mem_name[32];",
" target_phys_addr_t node0_size, mem_start;",
"#define _FDT(exp) \\",
" do { \\",
" int ret = (exp); \\",
" if (ret < 0) { \\",
" fprintf(stderr, \"qemu: error creating device tree: %s: %s\\n\", \\",
" #exp, fdt_strerror(ret)); \\",
" exit(1); \\",
" } \\",
" } while (0)",
" node0_size = (nb_numa_nodes > 1) ? node_mem[0] : ram_size;",
" if (rma_size > node0_size) {",
" rma_size = node0_size;",
" mem_reg_property[0] = 0;",
" mem_reg_property[1] = cpu_to_be64(rma_size);",
" _FDT((fdt_begin_node(fdt, \"memory@0\")));",
" _FDT((fdt_property_string(fdt, \"device_type\", \"memory\")));",
" _FDT((fdt_property(fdt, \"reg\", mem_reg_property,",
" sizeof(mem_reg_property))));",
" _FDT((fdt_property(fdt, \"ibm,associativity\", associativity,",
" sizeof(associativity))));",
" _FDT((fdt_end_node(fdt)));",
" if (node0_size > rma_size) {",
" mem_reg_property[0] = cpu_to_be64(rma_size);",
" mem_reg_property[1] = cpu_to_be64(node0_size - rma_size);",
" sprintf(mem_name, \"memory@\" TARGET_FMT_lx, rma_size);",
" _FDT((fdt_begin_node(fdt, mem_name)));",
" _FDT((fdt_property_string(fdt, \"device_type\", \"memory\")));",
" _FDT((fdt_property(fdt, \"reg\", mem_reg_property,",
" sizeof(mem_reg_property))));",
" _FDT((fdt_property(fdt, \"ibm,associativity\", associativity,",
" sizeof(associativity))));",
" _FDT((fdt_end_node(fdt)));",
" mem_start = node0_size;",
" for (i = 1; i < nb_numa_nodes; i++) {",
" mem_reg_property[0] = cpu_to_be64(mem_start);",
" mem_reg_property[1] = cpu_to_be64(node_mem[i]);",
" associativity[3] = associativity[4] = cpu_to_be32(i);",
" sprintf(mem_name, \"memory@\" TARGET_FMT_lx, mem_start);",
" _FDT((fdt_begin_node(fdt, mem_name)));",
" _FDT((fdt_property_string(fdt, \"device_type\", \"memory\")));",
" _FDT((fdt_property(fdt, \"reg\", mem_reg_property,",
" sizeof(mem_reg_property))));",
" _FDT((fdt_property(fdt, \"ibm,associativity\", associativity,",
" sizeof(associativity))));",
" _FDT((fdt_end_node(fdt)));",
" mem_start += node_mem[i];",
" _FDT((fdt_property(fdt, \"ibm,pft-size\",",
" pft_size_prop, sizeof(pft_size_prop))));",
" for (env = first_cpu; env != NULL; env = env->next_cpu) {"
],
"line_no": [
3,
13,
15,
23,
29,
39,
43,
47,
49,
51,
53,
55,
57,
61,
63,
65,
67,
69,
71,
73,
75,
77,
169,
171,
173,
181,
183,
185,
187,
189,
191,
193,
195,
163,
203,
205,
207,
211,
213,
215,
217,
219,
221,
223,
225,
233,
235,
237,
239,
241,
243,
213,
215,
217,
251,
221,
255,
225,
259,
367,
369,
295
]
} | static void *FUNC_0(const char *VAR_0,
target_phys_addr_t VAR_1,
target_phys_addr_t VAR_2,
target_phys_addr_t VAR_3,
target_phys_addr_t VAR_4,
const char *VAR_5,
const char *VAR_6,
long VAR_7)
{
void *VAR_8;
CPUPPCState *env;
uint64_t mem_reg_property[2];
uint32_t start_prop = cpu_to_be32(VAR_2);
uint32_t end_prop = cpu_to_be32(VAR_2 + VAR_3);
uint32_t pft_size_prop[] = {0, cpu_to_be32(VAR_7)};
char VAR_9[] = "hcall-pft\0hcall-term\0hcall-dabr\0hcall-interrupt"
"\0hcall-tce\0hcall-vio\0hcall-splpar\0hcall-bulk";
char VAR_10[] = "hcall-memop1";
uint32_t interrupt_server_ranges_prop[] = {0, cpu_to_be32(smp_cpus)};
int VAR_11;
char *VAR_12;
int VAR_13 = kvmppc_smt_threads();
unsigned char VAR_14[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x80};
uint32_t refpoints[] = {cpu_to_be32(0x4), cpu_to_be32(0x4)};
uint32_t associativity[] = {cpu_to_be32(0x4), cpu_to_be32(0x0),
cpu_to_be32(0x0), cpu_to_be32(0x0),
cpu_to_be32(0x0)};
char VAR_15[32];
target_phys_addr_t node0_size, mem_start;
#define _FDT(exp) \
do { \
int VAR_16 = (exp); \
if (VAR_16 < 0) { \
fprintf(stderr, "qemu: error creating device tree: %s: %s\n", \
#exp, fdt_strerror(VAR_16)); \
exit(1); \
} \
} while (0)
VAR_8 = g_malloc0(FDT_MAX_SIZE);
_FDT((fdt_create(VAR_8, FDT_MAX_SIZE)));
if (VAR_4) {
_FDT((fdt_add_reservemap_entry(VAR_8, KERNEL_LOAD_ADDR, VAR_4)));
}
if (VAR_3) {
_FDT((fdt_add_reservemap_entry(VAR_8, VAR_2, VAR_3)));
}
_FDT((fdt_finish_reservemap(VAR_8)));
_FDT((fdt_begin_node(VAR_8, "")));
_FDT((fdt_property_string(VAR_8, "device_type", "chrp")));
_FDT((fdt_property_string(VAR_8, "model", "IBM pSeries (emulated by qemu)")));
_FDT((fdt_property_cell(VAR_8, "#address-cells", 0x2)));
_FDT((fdt_property_cell(VAR_8, "#size-cells", 0x2)));
_FDT((fdt_begin_node(VAR_8, "chosen")));
_FDT((fdt_property(VAR_8, "ibm,architecture-vec-5", VAR_14, sizeof(VAR_14))));
_FDT((fdt_property_string(VAR_8, "bootargs", VAR_6)));
_FDT((fdt_property(VAR_8, "linux,initrd-start",
&start_prop, sizeof(start_prop))));
_FDT((fdt_property(VAR_8, "linux,initrd-end",
&end_prop, sizeof(end_prop))));
if (VAR_4) {
uint64_t kprop[2] = { cpu_to_be64(KERNEL_LOAD_ADDR),
cpu_to_be64(VAR_4) };
_FDT((fdt_property(VAR_8, "qemu,boot-kernel", &kprop, sizeof(kprop))));
}
_FDT((fdt_property_string(VAR_8, "qemu,boot-device", VAR_5)));
_FDT((fdt_property_cell(VAR_8, "qemu,graphic-width", graphic_width)));
_FDT((fdt_property_cell(VAR_8, "qemu,graphic-height", graphic_height)));
_FDT((fdt_property_cell(VAR_8, "qemu,graphic-depth", graphic_depth)));
_FDT((fdt_end_node(VAR_8)));
node0_size = (nb_numa_nodes > 1) ? node_mem[0] : ram_size;
if (VAR_1 > node0_size) {
VAR_1 = node0_size;
}
mem_reg_property[0] = 0;
mem_reg_property[1] = cpu_to_be64(VAR_1);
_FDT((fdt_begin_node(VAR_8, "memory@0")));
_FDT((fdt_property_string(VAR_8, "device_type", "memory")));
_FDT((fdt_property(VAR_8, "reg", mem_reg_property,
sizeof(mem_reg_property))));
_FDT((fdt_property(VAR_8, "ibm,associativity", associativity,
sizeof(associativity))));
_FDT((fdt_end_node(VAR_8)));
if (node0_size > VAR_1) {
mem_reg_property[0] = cpu_to_be64(VAR_1);
mem_reg_property[1] = cpu_to_be64(node0_size - VAR_1);
sprintf(VAR_15, "memory@" TARGET_FMT_lx, VAR_1);
_FDT((fdt_begin_node(VAR_8, VAR_15)));
_FDT((fdt_property_string(VAR_8, "device_type", "memory")));
_FDT((fdt_property(VAR_8, "reg", mem_reg_property,
sizeof(mem_reg_property))));
_FDT((fdt_property(VAR_8, "ibm,associativity", associativity,
sizeof(associativity))));
_FDT((fdt_end_node(VAR_8)));
}
mem_start = node0_size;
for (VAR_11 = 1; VAR_11 < nb_numa_nodes; VAR_11++) {
mem_reg_property[0] = cpu_to_be64(mem_start);
mem_reg_property[1] = cpu_to_be64(node_mem[VAR_11]);
associativity[3] = associativity[4] = cpu_to_be32(VAR_11);
sprintf(VAR_15, "memory@" TARGET_FMT_lx, mem_start);
_FDT((fdt_begin_node(VAR_8, VAR_15)));
_FDT((fdt_property_string(VAR_8, "device_type", "memory")));
_FDT((fdt_property(VAR_8, "reg", mem_reg_property,
sizeof(mem_reg_property))));
_FDT((fdt_property(VAR_8, "ibm,associativity", associativity,
sizeof(associativity))));
_FDT((fdt_end_node(VAR_8)));
mem_start += node_mem[VAR_11];
}
_FDT((fdt_begin_node(VAR_8, "cpus")));
_FDT((fdt_property_cell(VAR_8, "#address-cells", 0x1)));
_FDT((fdt_property_cell(VAR_8, "#size-cells", 0x0)));
VAR_12 = g_strdup(VAR_0);
for (VAR_11 = 0; VAR_11 < strlen(VAR_12); VAR_11++) {
VAR_12[VAR_11] = toupper(VAR_12[VAR_11]);
}
spapr->VAR_0 = g_strdup(VAR_12);
for (env = first_cpu; env != NULL; env = env->next_cpu) {
int index = env->cpu_index;
uint32_t servers_prop[smp_threads];
uint32_t gservers_prop[smp_threads * 2];
char *nodename;
uint32_t segs[] = {cpu_to_be32(28), cpu_to_be32(40),
0xffffffff, 0xffffffff};
uint32_t tbfreq = kvm_enabled() ? kvmppc_get_tbfreq() : TIMEBASE_FREQ;
uint32_t cpufreq = kvm_enabled() ? kvmppc_get_clockfreq() : 1000000000;
uint32_t page_sizes_prop[64];
size_t page_sizes_prop_size;
if ((index % VAR_13) != 0) {
continue;
}
if (asprintf(&nodename, "%s@%x", VAR_12, index) < 0) {
fprintf(stderr, "Allocation failure\n");
exit(1);
}
_FDT((fdt_begin_node(VAR_8, nodename)));
free(nodename);
_FDT((fdt_property_cell(VAR_8, "reg", index)));
_FDT((fdt_property_string(VAR_8, "device_type", "cpu")));
_FDT((fdt_property_cell(VAR_8, "cpu-version", env->spr[SPR_PVR])));
_FDT((fdt_property_cell(VAR_8, "dcache-block-size",
env->dcache_line_size)));
_FDT((fdt_property_cell(VAR_8, "icache-block-size",
env->icache_line_size)));
_FDT((fdt_property_cell(VAR_8, "timebase-frequency", tbfreq)));
_FDT((fdt_property_cell(VAR_8, "clock-frequency", cpufreq)));
_FDT((fdt_property_cell(VAR_8, "ibm,slb-size", env->slb_nr)));
_FDT((fdt_property(VAR_8, "ibm,pft-size",
pft_size_prop, sizeof(pft_size_prop))));
_FDT((fdt_property_string(VAR_8, "status", "okay")));
_FDT((fdt_property(VAR_8, "64-bit", NULL, 0)));
for (VAR_11 = 0; VAR_11 < smp_threads; VAR_11++) {
servers_prop[VAR_11] = cpu_to_be32(index + VAR_11);
gservers_prop[VAR_11*2] = cpu_to_be32(index + VAR_11);
gservers_prop[VAR_11*2 + 1] = 0;
}
_FDT((fdt_property(VAR_8, "ibm,ppc-interrupt-server#s",
servers_prop, sizeof(servers_prop))));
_FDT((fdt_property(VAR_8, "ibm,ppc-interrupt-gserver#s",
gservers_prop, sizeof(gservers_prop))));
if (env->mmu_model & POWERPC_MMU_1TSEG) {
_FDT((fdt_property(VAR_8, "ibm,processor-segment-sizes",
segs, sizeof(segs))));
}
if (env->insns_flags & PPC_ALTIVEC) {
uint32_t vmx = (env->insns_flags2 & PPC2_VSX) ? 2 : 1;
_FDT((fdt_property_cell(VAR_8, "ibm,vmx", vmx)));
}
if (env->insns_flags2 & PPC2_DFP) {
_FDT((fdt_property_cell(VAR_8, "ibm,dfp", 1)));
}
page_sizes_prop_size = create_page_sizes_prop(env, page_sizes_prop,
sizeof(page_sizes_prop));
if (page_sizes_prop_size) {
_FDT((fdt_property(VAR_8, "ibm,segment-page-sizes",
page_sizes_prop, page_sizes_prop_size)));
}
_FDT((fdt_end_node(VAR_8)));
}
g_free(VAR_12);
_FDT((fdt_end_node(VAR_8)));
_FDT((fdt_begin_node(VAR_8, "rtas")));
_FDT((fdt_property(VAR_8, "ibm,hypertas-functions", VAR_9,
sizeof(VAR_9))));
_FDT((fdt_property(VAR_8, "qemu,hypertas-functions", VAR_10,
sizeof(VAR_10))));
_FDT((fdt_property(VAR_8, "ibm,associativity-reference-points",
refpoints, sizeof(refpoints))));
_FDT((fdt_end_node(VAR_8)));
_FDT((fdt_begin_node(VAR_8, "interrupt-controller")));
_FDT((fdt_property_string(VAR_8, "device_type",
"PowerPC-External-Interrupt-Presentation")));
_FDT((fdt_property_string(VAR_8, "compatible", "IBM,ppc-xicp")));
_FDT((fdt_property(VAR_8, "interrupt-controller", NULL, 0)));
_FDT((fdt_property(VAR_8, "ibm,interrupt-server-ranges",
interrupt_server_ranges_prop,
sizeof(interrupt_server_ranges_prop))));
_FDT((fdt_property_cell(VAR_8, "#interrupt-cells", 2)));
_FDT((fdt_property_cell(VAR_8, "linux,phandle", PHANDLE_XICP)));
_FDT((fdt_property_cell(VAR_8, "phandle", PHANDLE_XICP)));
_FDT((fdt_end_node(VAR_8)));
_FDT((fdt_begin_node(VAR_8, "vdevice")));
_FDT((fdt_property_string(VAR_8, "device_type", "vdevice")));
_FDT((fdt_property_string(VAR_8, "compatible", "IBM,vdevice")));
_FDT((fdt_property_cell(VAR_8, "#address-cells", 0x1)));
_FDT((fdt_property_cell(VAR_8, "#size-cells", 0x0)));
_FDT((fdt_property_cell(VAR_8, "#interrupt-cells", 0x2)));
_FDT((fdt_property(VAR_8, "interrupt-controller", NULL, 0)));
_FDT((fdt_end_node(VAR_8)));
_FDT((fdt_end_node(VAR_8)));
_FDT((fdt_finish(VAR_8)));
return VAR_8;
}
| [
"static void *FUNC_0(const char *VAR_0,\ntarget_phys_addr_t VAR_1,\ntarget_phys_addr_t VAR_2,\ntarget_phys_addr_t VAR_3,\ntarget_phys_addr_t VAR_4,\nconst char *VAR_5,\nconst char *VAR_6,\nlong VAR_7)\n{",
"void *VAR_8;",
"CPUPPCState *env;",
"uint64_t mem_reg_property[2];",
"uint32_t start_prop = cpu_to_be32(VAR_2);",
"uint32_t end_prop = cpu_to_be32(VAR_2 + VAR_3);",
"uint32_t pft_size_prop[] = {0, cpu_to_be32(VAR_7)};",
"char VAR_9[] = \"hcall-pft\\0hcall-term\\0hcall-dabr\\0hcall-interrupt\"\n\"\\0hcall-tce\\0hcall-vio\\0hcall-splpar\\0hcall-bulk\";",
"char VAR_10[] = \"hcall-memop1\";",
"uint32_t interrupt_server_ranges_prop[] = {0, cpu_to_be32(smp_cpus)};",
"int VAR_11;",
"char *VAR_12;",
"int VAR_13 = kvmppc_smt_threads();",
"unsigned char VAR_14[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x80};",
"uint32_t refpoints[] = {cpu_to_be32(0x4), cpu_to_be32(0x4)};",
"uint32_t associativity[] = {cpu_to_be32(0x4), cpu_to_be32(0x0),",
"cpu_to_be32(0x0), cpu_to_be32(0x0),\ncpu_to_be32(0x0)};",
"char VAR_15[32];",
"target_phys_addr_t node0_size, mem_start;",
"#define _FDT(exp) \\\ndo { \\",
"int VAR_16 = (exp); \\",
"if (VAR_16 < 0) { \\",
"fprintf(stderr, \"qemu: error creating device tree: %s: %s\\n\", \\\n#exp, fdt_strerror(VAR_16)); \\",
"exit(1); \\",
"} \\",
"} while (0)",
"VAR_8 = g_malloc0(FDT_MAX_SIZE);",
"_FDT((fdt_create(VAR_8, FDT_MAX_SIZE)));",
"if (VAR_4) {",
"_FDT((fdt_add_reservemap_entry(VAR_8, KERNEL_LOAD_ADDR, VAR_4)));",
"}",
"if (VAR_3) {",
"_FDT((fdt_add_reservemap_entry(VAR_8, VAR_2, VAR_3)));",
"}",
"_FDT((fdt_finish_reservemap(VAR_8)));",
"_FDT((fdt_begin_node(VAR_8, \"\")));",
"_FDT((fdt_property_string(VAR_8, \"device_type\", \"chrp\")));",
"_FDT((fdt_property_string(VAR_8, \"model\", \"IBM pSeries (emulated by qemu)\")));",
"_FDT((fdt_property_cell(VAR_8, \"#address-cells\", 0x2)));",
"_FDT((fdt_property_cell(VAR_8, \"#size-cells\", 0x2)));",
"_FDT((fdt_begin_node(VAR_8, \"chosen\")));",
"_FDT((fdt_property(VAR_8, \"ibm,architecture-vec-5\", VAR_14, sizeof(VAR_14))));",
"_FDT((fdt_property_string(VAR_8, \"bootargs\", VAR_6)));",
"_FDT((fdt_property(VAR_8, \"linux,initrd-start\",\n&start_prop, sizeof(start_prop))));",
"_FDT((fdt_property(VAR_8, \"linux,initrd-end\",\n&end_prop, sizeof(end_prop))));",
"if (VAR_4) {",
"uint64_t kprop[2] = { cpu_to_be64(KERNEL_LOAD_ADDR),",
"cpu_to_be64(VAR_4) };",
"_FDT((fdt_property(VAR_8, \"qemu,boot-kernel\", &kprop, sizeof(kprop))));",
"}",
"_FDT((fdt_property_string(VAR_8, \"qemu,boot-device\", VAR_5)));",
"_FDT((fdt_property_cell(VAR_8, \"qemu,graphic-width\", graphic_width)));",
"_FDT((fdt_property_cell(VAR_8, \"qemu,graphic-height\", graphic_height)));",
"_FDT((fdt_property_cell(VAR_8, \"qemu,graphic-depth\", graphic_depth)));",
"_FDT((fdt_end_node(VAR_8)));",
"node0_size = (nb_numa_nodes > 1) ? node_mem[0] : ram_size;",
"if (VAR_1 > node0_size) {",
"VAR_1 = node0_size;",
"}",
"mem_reg_property[0] = 0;",
"mem_reg_property[1] = cpu_to_be64(VAR_1);",
"_FDT((fdt_begin_node(VAR_8, \"memory@0\")));",
"_FDT((fdt_property_string(VAR_8, \"device_type\", \"memory\")));",
"_FDT((fdt_property(VAR_8, \"reg\", mem_reg_property,\nsizeof(mem_reg_property))));",
"_FDT((fdt_property(VAR_8, \"ibm,associativity\", associativity,\nsizeof(associativity))));",
"_FDT((fdt_end_node(VAR_8)));",
"if (node0_size > VAR_1) {",
"mem_reg_property[0] = cpu_to_be64(VAR_1);",
"mem_reg_property[1] = cpu_to_be64(node0_size - VAR_1);",
"sprintf(VAR_15, \"memory@\" TARGET_FMT_lx, VAR_1);",
"_FDT((fdt_begin_node(VAR_8, VAR_15)));",
"_FDT((fdt_property_string(VAR_8, \"device_type\", \"memory\")));",
"_FDT((fdt_property(VAR_8, \"reg\", mem_reg_property,\nsizeof(mem_reg_property))));",
"_FDT((fdt_property(VAR_8, \"ibm,associativity\", associativity,\nsizeof(associativity))));",
"_FDT((fdt_end_node(VAR_8)));",
"}",
"mem_start = node0_size;",
"for (VAR_11 = 1; VAR_11 < nb_numa_nodes; VAR_11++) {",
"mem_reg_property[0] = cpu_to_be64(mem_start);",
"mem_reg_property[1] = cpu_to_be64(node_mem[VAR_11]);",
"associativity[3] = associativity[4] = cpu_to_be32(VAR_11);",
"sprintf(VAR_15, \"memory@\" TARGET_FMT_lx, mem_start);",
"_FDT((fdt_begin_node(VAR_8, VAR_15)));",
"_FDT((fdt_property_string(VAR_8, \"device_type\", \"memory\")));",
"_FDT((fdt_property(VAR_8, \"reg\", mem_reg_property,\nsizeof(mem_reg_property))));",
"_FDT((fdt_property(VAR_8, \"ibm,associativity\", associativity,\nsizeof(associativity))));",
"_FDT((fdt_end_node(VAR_8)));",
"mem_start += node_mem[VAR_11];",
"}",
"_FDT((fdt_begin_node(VAR_8, \"cpus\")));",
"_FDT((fdt_property_cell(VAR_8, \"#address-cells\", 0x1)));",
"_FDT((fdt_property_cell(VAR_8, \"#size-cells\", 0x0)));",
"VAR_12 = g_strdup(VAR_0);",
"for (VAR_11 = 0; VAR_11 < strlen(VAR_12); VAR_11++) {",
"VAR_12[VAR_11] = toupper(VAR_12[VAR_11]);",
"}",
"spapr->VAR_0 = g_strdup(VAR_12);",
"for (env = first_cpu; env != NULL; env = env->next_cpu) {",
"int index = env->cpu_index;",
"uint32_t servers_prop[smp_threads];",
"uint32_t gservers_prop[smp_threads * 2];",
"char *nodename;",
"uint32_t segs[] = {cpu_to_be32(28), cpu_to_be32(40),",
"0xffffffff, 0xffffffff};",
"uint32_t tbfreq = kvm_enabled() ? kvmppc_get_tbfreq() : TIMEBASE_FREQ;",
"uint32_t cpufreq = kvm_enabled() ? kvmppc_get_clockfreq() : 1000000000;",
"uint32_t page_sizes_prop[64];",
"size_t page_sizes_prop_size;",
"if ((index % VAR_13) != 0) {",
"continue;",
"}",
"if (asprintf(&nodename, \"%s@%x\", VAR_12, index) < 0) {",
"fprintf(stderr, \"Allocation failure\\n\");",
"exit(1);",
"}",
"_FDT((fdt_begin_node(VAR_8, nodename)));",
"free(nodename);",
"_FDT((fdt_property_cell(VAR_8, \"reg\", index)));",
"_FDT((fdt_property_string(VAR_8, \"device_type\", \"cpu\")));",
"_FDT((fdt_property_cell(VAR_8, \"cpu-version\", env->spr[SPR_PVR])));",
"_FDT((fdt_property_cell(VAR_8, \"dcache-block-size\",\nenv->dcache_line_size)));",
"_FDT((fdt_property_cell(VAR_8, \"icache-block-size\",\nenv->icache_line_size)));",
"_FDT((fdt_property_cell(VAR_8, \"timebase-frequency\", tbfreq)));",
"_FDT((fdt_property_cell(VAR_8, \"clock-frequency\", cpufreq)));",
"_FDT((fdt_property_cell(VAR_8, \"ibm,slb-size\", env->slb_nr)));",
"_FDT((fdt_property(VAR_8, \"ibm,pft-size\",\npft_size_prop, sizeof(pft_size_prop))));",
"_FDT((fdt_property_string(VAR_8, \"status\", \"okay\")));",
"_FDT((fdt_property(VAR_8, \"64-bit\", NULL, 0)));",
"for (VAR_11 = 0; VAR_11 < smp_threads; VAR_11++) {",
"servers_prop[VAR_11] = cpu_to_be32(index + VAR_11);",
"gservers_prop[VAR_11*2] = cpu_to_be32(index + VAR_11);",
"gservers_prop[VAR_11*2 + 1] = 0;",
"}",
"_FDT((fdt_property(VAR_8, \"ibm,ppc-interrupt-server#s\",\nservers_prop, sizeof(servers_prop))));",
"_FDT((fdt_property(VAR_8, \"ibm,ppc-interrupt-gserver#s\",\ngservers_prop, sizeof(gservers_prop))));",
"if (env->mmu_model & POWERPC_MMU_1TSEG) {",
"_FDT((fdt_property(VAR_8, \"ibm,processor-segment-sizes\",\nsegs, sizeof(segs))));",
"}",
"if (env->insns_flags & PPC_ALTIVEC) {",
"uint32_t vmx = (env->insns_flags2 & PPC2_VSX) ? 2 : 1;",
"_FDT((fdt_property_cell(VAR_8, \"ibm,vmx\", vmx)));",
"}",
"if (env->insns_flags2 & PPC2_DFP) {",
"_FDT((fdt_property_cell(VAR_8, \"ibm,dfp\", 1)));",
"}",
"page_sizes_prop_size = create_page_sizes_prop(env, page_sizes_prop,\nsizeof(page_sizes_prop));",
"if (page_sizes_prop_size) {",
"_FDT((fdt_property(VAR_8, \"ibm,segment-page-sizes\",\npage_sizes_prop, page_sizes_prop_size)));",
"}",
"_FDT((fdt_end_node(VAR_8)));",
"}",
"g_free(VAR_12);",
"_FDT((fdt_end_node(VAR_8)));",
"_FDT((fdt_begin_node(VAR_8, \"rtas\")));",
"_FDT((fdt_property(VAR_8, \"ibm,hypertas-functions\", VAR_9,\nsizeof(VAR_9))));",
"_FDT((fdt_property(VAR_8, \"qemu,hypertas-functions\", VAR_10,\nsizeof(VAR_10))));",
"_FDT((fdt_property(VAR_8, \"ibm,associativity-reference-points\",\nrefpoints, sizeof(refpoints))));",
"_FDT((fdt_end_node(VAR_8)));",
"_FDT((fdt_begin_node(VAR_8, \"interrupt-controller\")));",
"_FDT((fdt_property_string(VAR_8, \"device_type\",\n\"PowerPC-External-Interrupt-Presentation\")));",
"_FDT((fdt_property_string(VAR_8, \"compatible\", \"IBM,ppc-xicp\")));",
"_FDT((fdt_property(VAR_8, \"interrupt-controller\", NULL, 0)));",
"_FDT((fdt_property(VAR_8, \"ibm,interrupt-server-ranges\",\ninterrupt_server_ranges_prop,\nsizeof(interrupt_server_ranges_prop))));",
"_FDT((fdt_property_cell(VAR_8, \"#interrupt-cells\", 2)));",
"_FDT((fdt_property_cell(VAR_8, \"linux,phandle\", PHANDLE_XICP)));",
"_FDT((fdt_property_cell(VAR_8, \"phandle\", PHANDLE_XICP)));",
"_FDT((fdt_end_node(VAR_8)));",
"_FDT((fdt_begin_node(VAR_8, \"vdevice\")));",
"_FDT((fdt_property_string(VAR_8, \"device_type\", \"vdevice\")));",
"_FDT((fdt_property_string(VAR_8, \"compatible\", \"IBM,vdevice\")));",
"_FDT((fdt_property_cell(VAR_8, \"#address-cells\", 0x1)));",
"_FDT((fdt_property_cell(VAR_8, \"#size-cells\", 0x0)));",
"_FDT((fdt_property_cell(VAR_8, \"#interrupt-cells\", 0x2)));",
"_FDT((fdt_property(VAR_8, \"interrupt-controller\", NULL, 0)));",
"_FDT((fdt_end_node(VAR_8)));",
"_FDT((fdt_end_node(VAR_8)));",
"_FDT((fdt_finish(VAR_8)));",
"return VAR_8;",
"}"
] | [
1,
0,
0,
1,
0,
0,
1,
0,
0,
0,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
0,
0,
1,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13,
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
61,
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
121
],
[
127
],
[
131
],
[
133,
135
],
[
137,
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
163
],
[
169
],
[
171
],
[
173
],
[
175
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189,
191
],
[
193,
195
],
[
197
],
[
203
],
[
205
],
[
207
],
[
211
],
[
213
],
[
215
],
[
217,
219
],
[
221,
223
],
[
225
],
[
227
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249,
251
],
[
253,
255
],
[
257
],
[
259
],
[
261
],
[
267
],
[
271
],
[
273
],
[
277
],
[
281
],
[
283
],
[
285
],
[
291
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
319
],
[
321
],
[
323
],
[
327
],
[
329
],
[
331
],
[
333
],
[
337
],
[
341
],
[
345
],
[
347
],
[
351
],
[
353,
355
],
[
357,
359
],
[
361
],
[
363
],
[
365
],
[
367,
369
],
[
371
],
[
373
],
[
379
],
[
381
],
[
385
],
[
387
],
[
389
],
[
391,
393
],
[
395,
397
],
[
401
],
[
403,
405
],
[
407
],
[
419
],
[
421
],
[
425
],
[
427
],
[
437
],
[
439
],
[
441
],
[
445,
447
],
[
449
],
[
451,
453
],
[
455
],
[
459
],
[
461
],
[
465
],
[
469
],
[
475
],
[
479,
481
],
[
483,
485
],
[
489,
491
],
[
495
],
[
501
],
[
505,
507
],
[
509
],
[
511
],
[
513,
515,
517
],
[
519
],
[
521
],
[
523
],
[
527
],
[
533
],
[
537
],
[
539
],
[
541
],
[
543
],
[
545
],
[
547
],
[
551
],
[
555
],
[
557
],
[
561
],
[
563
]
] |
24,577 | void arm_sysctl_init(uint32_t base, uint32_t sys_id)
{
arm_sysctl_state *s;
int iomemtype;
s = (arm_sysctl_state *)qemu_mallocz(sizeof(arm_sysctl_state));
if (!s)
return;
s->base = base;
s->sys_id = sys_id;
iomemtype = cpu_register_io_memory(0, arm_sysctl_readfn,
arm_sysctl_writefn, s);
cpu_register_physical_memory(base, 0x00000fff, iomemtype);
/* ??? Save/restore. */
}
| true | qemu | 187337f8b0ec0813dd3876d1efe37d415fb81c2e | void arm_sysctl_init(uint32_t base, uint32_t sys_id)
{
arm_sysctl_state *s;
int iomemtype;
s = (arm_sysctl_state *)qemu_mallocz(sizeof(arm_sysctl_state));
if (!s)
return;
s->base = base;
s->sys_id = sys_id;
iomemtype = cpu_register_io_memory(0, arm_sysctl_readfn,
arm_sysctl_writefn, s);
cpu_register_physical_memory(base, 0x00000fff, iomemtype);
}
| {
"code": [
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);"
],
"line_no": [
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25
]
} | void FUNC_0(uint32_t VAR_0, uint32_t VAR_1)
{
arm_sysctl_state *s;
int VAR_2;
s = (arm_sysctl_state *)qemu_mallocz(sizeof(arm_sysctl_state));
if (!s)
return;
s->VAR_0 = VAR_0;
s->VAR_1 = VAR_1;
VAR_2 = cpu_register_io_memory(0, arm_sysctl_readfn,
arm_sysctl_writefn, s);
cpu_register_physical_memory(VAR_0, 0x00000fff, VAR_2);
}
| [
"void FUNC_0(uint32_t VAR_0, uint32_t VAR_1)\n{",
"arm_sysctl_state *s;",
"int VAR_2;",
"s = (arm_sysctl_state *)qemu_mallocz(sizeof(arm_sysctl_state));",
"if (!s)\nreturn;",
"s->VAR_0 = VAR_0;",
"s->VAR_1 = VAR_1;",
"VAR_2 = cpu_register_io_memory(0, arm_sysctl_readfn,\narm_sysctl_writefn, s);",
"cpu_register_physical_memory(VAR_0, 0x00000fff, VAR_2);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
29
]
] |
24,579 | static void qobject_input_type_uint64(Visitor *v, const char *name,
uint64_t *obj, Error **errp)
{
/* FIXME: qobject_to_qint mishandles values over INT64_MAX */
QObjectInputVisitor *qiv = to_qiv(v);
QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
QInt *qint;
if (!qobj) {
return;
}
qint = qobject_to_qint(qobj);
if (!qint) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"integer");
return;
}
*obj = qint_get_int(qint);
}
| true | qemu | a9fc37f6bc3f2ab90585cb16493da9f6dcfbfbcf | static void qobject_input_type_uint64(Visitor *v, const char *name,
uint64_t *obj, Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
QInt *qint;
if (!qobj) {
return;
}
qint = qobject_to_qint(qobj);
if (!qint) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"integer");
return;
}
*obj = qint_get_int(qint);
}
| {
"code": [
" error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",",
" error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",",
" error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",",
" \"integer\");",
" error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",",
" \"integer\");",
" error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",",
" error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",",
" error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\","
],
"line_no": [
27,
27,
27,
29,
27,
29,
27,
27,
27
]
} | static void FUNC_0(Visitor *VAR_0, const char *VAR_1,
uint64_t *VAR_2, Error **VAR_3)
{
QObjectInputVisitor *qiv = to_qiv(VAR_0);
QObject *qobj = qobject_input_get_object(qiv, VAR_1, true, VAR_3);
QInt *qint;
if (!qobj) {
return;
}
qint = qobject_to_qint(qobj);
if (!qint) {
error_setg(VAR_3, QERR_INVALID_PARAMETER_TYPE, VAR_1 ? VAR_1 : "null",
"integer");
return;
}
*VAR_2 = qint_get_int(qint);
}
| [
"static void FUNC_0(Visitor *VAR_0, const char *VAR_1,\nuint64_t *VAR_2, Error **VAR_3)\n{",
"QObjectInputVisitor *qiv = to_qiv(VAR_0);",
"QObject *qobj = qobject_input_get_object(qiv, VAR_1, true, VAR_3);",
"QInt *qint;",
"if (!qobj) {",
"return;",
"}",
"qint = qobject_to_qint(qobj);",
"if (!qint) {",
"error_setg(VAR_3, QERR_INVALID_PARAMETER_TYPE, VAR_1 ? VAR_1 : \"null\",\n\"integer\");",
"return;",
"}",
"*VAR_2 = qint_get_int(qint);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
37
],
[
39
]
] |
24,580 | void mulu64(uint64_t *phigh, uint64_t *plow, uint64_t a, uint64_t b)
{
#if defined(__x86_64__)
__asm__ ("mul %0\n\t"
: "=d" (*phigh), "=a" (*plow)
: "a" (a), "0" (b)
);
#else
uint64_t ph, pm1, pm2, pl;
pl = (uint64_t)((uint32_t)a) * (uint64_t)((uint32_t)b);
pm1 = (a >> 32) * (uint32_t)b;
pm2 = (uint32_t)a * (b >> 32);
ph = (a >> 32) * (b >> 32);
ph += pm1 >> 32;
pm1 = (uint64_t)((uint32_t)pm1) + pm2 + (pl >> 32);
*phigh = ph + (pm1 >> 32);
*plow = (pm1 << 32) + (uint32_t)pl;
#endif
}
| true | qemu | 67fc07d3fba681f3362f7644a69b7a581a2670e8 | void mulu64(uint64_t *phigh, uint64_t *plow, uint64_t a, uint64_t b)
{
#if defined(__x86_64__)
__asm__ ("mul %0\n\t"
: "=d" (*phigh), "=a" (*plow)
: "a" (a), "0" (b)
);
#else
uint64_t ph, pm1, pm2, pl;
pl = (uint64_t)((uint32_t)a) * (uint64_t)((uint32_t)b);
pm1 = (a >> 32) * (uint32_t)b;
pm2 = (uint32_t)a * (b >> 32);
ph = (a >> 32) * (b >> 32);
ph += pm1 >> 32;
pm1 = (uint64_t)((uint32_t)pm1) + pm2 + (pl >> 32);
*phigh = ph + (pm1 >> 32);
*plow = (pm1 << 32) + (uint32_t)pl;
#endif
}
| {
"code": [
" pm1 = (uint64_t)((uint32_t)pm1) + pm2 + (pl >> 32);",
" pm1 = (uint64_t)((uint32_t)pm1) + pm2 + (pl >> 32);"
],
"line_no": [
33,
33
]
} | void FUNC_0(uint64_t *VAR_0, uint64_t *VAR_1, uint64_t VAR_2, uint64_t VAR_3)
{
#if defined(__x86_64__)
__asm__ ("mul %0\n\t"
: "=d" (*VAR_0), "=VAR_2" (*VAR_1)
: "VAR_2" (VAR_2), "0" (VAR_3)
);
#else
uint64_t ph, pm1, pm2, pl;
pl = (uint64_t)((uint32_t)VAR_2) * (uint64_t)((uint32_t)VAR_3);
pm1 = (VAR_2 >> 32) * (uint32_t)VAR_3;
pm2 = (uint32_t)VAR_2 * (VAR_3 >> 32);
ph = (VAR_2 >> 32) * (VAR_3 >> 32);
ph += pm1 >> 32;
pm1 = (uint64_t)((uint32_t)pm1) + pm2 + (pl >> 32);
*VAR_0 = ph + (pm1 >> 32);
*VAR_1 = (pm1 << 32) + (uint32_t)pl;
#endif
}
| [
"void FUNC_0(uint64_t *VAR_0, uint64_t *VAR_1, uint64_t VAR_2, uint64_t VAR_3)\n{",
"#if defined(__x86_64__)\n__asm__ (\"mul %0\\n\\t\"\n: \"=d\" (*VAR_0), \"=VAR_2\" (*VAR_1)\n: \"VAR_2\" (VAR_2), \"0\" (VAR_3)\n);",
"#else\nuint64_t ph, pm1, pm2, pl;",
"pl = (uint64_t)((uint32_t)VAR_2) * (uint64_t)((uint32_t)VAR_3);",
"pm1 = (VAR_2 >> 32) * (uint32_t)VAR_3;",
"pm2 = (uint32_t)VAR_2 * (VAR_3 >> 32);",
"ph = (VAR_2 >> 32) * (VAR_3 >> 32);",
"ph += pm1 >> 32;",
"pm1 = (uint64_t)((uint32_t)pm1) + pm2 + (pl >> 32);",
"*VAR_0 = ph + (pm1 >> 32);",
"*VAR_1 = (pm1 << 32) + (uint32_t)pl;",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5,
7,
9,
11,
13
],
[
15,
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41,
43
]
] |
24,581 | static void av_update_stream_timings(AVFormatContext *ic)
{
int64_t start_time, start_time1, end_time, end_time1;
int64_t duration, duration1;
int i;
AVStream *st;
start_time = INT64_MAX;
end_time = INT64_MIN;
duration = INT64_MIN;
for(i = 0;i < ic->nb_streams; i++) {
st = ic->streams[i];
if (st->start_time != AV_NOPTS_VALUE) {
start_time1= av_rescale_q(st->start_time, st->time_base, AV_TIME_BASE_Q);
if (start_time1 < start_time)
start_time = start_time1;
if (st->duration != AV_NOPTS_VALUE) {
end_time1 = start_time1
+ av_rescale_q(st->duration, st->time_base, AV_TIME_BASE_Q);
if (end_time1 > end_time)
end_time = end_time1;
}
}
if (st->duration != AV_NOPTS_VALUE) {
duration1 = av_rescale_q(st->duration, st->time_base, AV_TIME_BASE_Q);
if (duration1 > duration)
duration = duration1;
}
}
if (start_time != INT64_MAX) {
ic->start_time = start_time;
if (end_time != INT64_MIN) {
if (end_time - start_time > duration)
duration = end_time - start_time;
}
}
if (duration != INT64_MIN) {
ic->duration = duration;
if (ic->file_size > 0) {
/* compute the bitrate */
ic->bit_rate = (double)ic->file_size * 8.0 * AV_TIME_BASE /
(double)ic->duration;
}
}
}
| true | FFmpeg | 7f938dd32bed373560e06a6f884f5d73415ed788 | static void av_update_stream_timings(AVFormatContext *ic)
{
int64_t start_time, start_time1, end_time, end_time1;
int64_t duration, duration1;
int i;
AVStream *st;
start_time = INT64_MAX;
end_time = INT64_MIN;
duration = INT64_MIN;
for(i = 0;i < ic->nb_streams; i++) {
st = ic->streams[i];
if (st->start_time != AV_NOPTS_VALUE) {
start_time1= av_rescale_q(st->start_time, st->time_base, AV_TIME_BASE_Q);
if (start_time1 < start_time)
start_time = start_time1;
if (st->duration != AV_NOPTS_VALUE) {
end_time1 = start_time1
+ av_rescale_q(st->duration, st->time_base, AV_TIME_BASE_Q);
if (end_time1 > end_time)
end_time = end_time1;
}
}
if (st->duration != AV_NOPTS_VALUE) {
duration1 = av_rescale_q(st->duration, st->time_base, AV_TIME_BASE_Q);
if (duration1 > duration)
duration = duration1;
}
}
if (start_time != INT64_MAX) {
ic->start_time = start_time;
if (end_time != INT64_MIN) {
if (end_time - start_time > duration)
duration = end_time - start_time;
}
}
if (duration != INT64_MIN) {
ic->duration = duration;
if (ic->file_size > 0) {
ic->bit_rate = (double)ic->file_size * 8.0 * AV_TIME_BASE /
(double)ic->duration;
}
}
}
| {
"code": [
" if (st->start_time != AV_NOPTS_VALUE) {"
],
"line_no": [
25
]
} | static void FUNC_0(AVFormatContext *VAR_0)
{
int64_t start_time, start_time1, end_time, end_time1;
int64_t duration, duration1;
int VAR_1;
AVStream *st;
start_time = INT64_MAX;
end_time = INT64_MIN;
duration = INT64_MIN;
for(VAR_1 = 0;VAR_1 < VAR_0->nb_streams; VAR_1++) {
st = VAR_0->streams[VAR_1];
if (st->start_time != AV_NOPTS_VALUE) {
start_time1= av_rescale_q(st->start_time, st->time_base, AV_TIME_BASE_Q);
if (start_time1 < start_time)
start_time = start_time1;
if (st->duration != AV_NOPTS_VALUE) {
end_time1 = start_time1
+ av_rescale_q(st->duration, st->time_base, AV_TIME_BASE_Q);
if (end_time1 > end_time)
end_time = end_time1;
}
}
if (st->duration != AV_NOPTS_VALUE) {
duration1 = av_rescale_q(st->duration, st->time_base, AV_TIME_BASE_Q);
if (duration1 > duration)
duration = duration1;
}
}
if (start_time != INT64_MAX) {
VAR_0->start_time = start_time;
if (end_time != INT64_MIN) {
if (end_time - start_time > duration)
duration = end_time - start_time;
}
}
if (duration != INT64_MIN) {
VAR_0->duration = duration;
if (VAR_0->file_size > 0) {
VAR_0->bit_rate = (double)VAR_0->file_size * 8.0 * AV_TIME_BASE /
(double)VAR_0->duration;
}
}
}
| [
"static void FUNC_0(AVFormatContext *VAR_0)\n{",
"int64_t start_time, start_time1, end_time, end_time1;",
"int64_t duration, duration1;",
"int VAR_1;",
"AVStream *st;",
"start_time = INT64_MAX;",
"end_time = INT64_MIN;",
"duration = INT64_MIN;",
"for(VAR_1 = 0;VAR_1 < VAR_0->nb_streams; VAR_1++) {",
"st = VAR_0->streams[VAR_1];",
"if (st->start_time != AV_NOPTS_VALUE) {",
"start_time1= av_rescale_q(st->start_time, st->time_base, AV_TIME_BASE_Q);",
"if (start_time1 < start_time)\nstart_time = start_time1;",
"if (st->duration != AV_NOPTS_VALUE) {",
"end_time1 = start_time1\n+ av_rescale_q(st->duration, st->time_base, AV_TIME_BASE_Q);",
"if (end_time1 > end_time)\nend_time = end_time1;",
"}",
"}",
"if (st->duration != AV_NOPTS_VALUE) {",
"duration1 = av_rescale_q(st->duration, st->time_base, AV_TIME_BASE_Q);",
"if (duration1 > duration)\nduration = duration1;",
"}",
"}",
"if (start_time != INT64_MAX) {",
"VAR_0->start_time = start_time;",
"if (end_time != INT64_MIN) {",
"if (end_time - start_time > duration)\nduration = end_time - start_time;",
"}",
"}",
"if (duration != INT64_MIN) {",
"VAR_0->duration = duration;",
"if (VAR_0->file_size > 0) {",
"VAR_0->bit_rate = (double)VAR_0->file_size * 8.0 * AV_TIME_BASE /\n(double)VAR_0->duration;",
"}",
"}",
"}"
] | [
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
],
[
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
],
[
81,
83
],
[
85
],
[
87
],
[
89
]
] |
24,582 | static inline int get_a32_user_mem_index(DisasContext *s)
{
/* Return the core mmu_idx to use for A32/T32 "unprivileged load/store"
* insns:
* if PL2, UNPREDICTABLE (we choose to implement as if PL0)
* otherwise, access as if at PL0.
*/
switch (s->mmu_idx) {
case ARMMMUIdx_S1E2: /* this one is UNPREDICTABLE */
case ARMMMUIdx_S12NSE0:
case ARMMMUIdx_S12NSE1:
return arm_to_core_mmu_idx(ARMMMUIdx_S12NSE0);
case ARMMMUIdx_S1E3:
case ARMMMUIdx_S1SE0:
case ARMMMUIdx_S1SE1:
return arm_to_core_mmu_idx(ARMMMUIdx_S1SE0);
case ARMMMUIdx_S2NS:
default:
g_assert_not_reached();
}
} | true | qemu | e7b921c2d9efc249f99b9feb0e7dca82c96aa5c4 | static inline int get_a32_user_mem_index(DisasContext *s)
{
switch (s->mmu_idx) {
case ARMMMUIdx_S1E2:
case ARMMMUIdx_S12NSE0:
case ARMMMUIdx_S12NSE1:
return arm_to_core_mmu_idx(ARMMMUIdx_S12NSE0);
case ARMMMUIdx_S1E3:
case ARMMMUIdx_S1SE0:
case ARMMMUIdx_S1SE1:
return arm_to_core_mmu_idx(ARMMMUIdx_S1SE0);
case ARMMMUIdx_S2NS:
default:
g_assert_not_reached();
}
} | {
"code": [],
"line_no": []
} | static inline int FUNC_0(DisasContext *VAR_0)
{
switch (VAR_0->mmu_idx) {
case ARMMMUIdx_S1E2:
case ARMMMUIdx_S12NSE0:
case ARMMMUIdx_S12NSE1:
return arm_to_core_mmu_idx(ARMMMUIdx_S12NSE0);
case ARMMMUIdx_S1E3:
case ARMMMUIdx_S1SE0:
case ARMMMUIdx_S1SE1:
return arm_to_core_mmu_idx(ARMMMUIdx_S1SE0);
case ARMMMUIdx_S2NS:
default:
g_assert_not_reached();
}
} | [
"static inline int FUNC_0(DisasContext *VAR_0)\n{",
"switch (VAR_0->mmu_idx) {",
"case ARMMMUIdx_S1E2:\ncase ARMMMUIdx_S12NSE0:\ncase ARMMMUIdx_S12NSE1:\nreturn arm_to_core_mmu_idx(ARMMMUIdx_S12NSE0);",
"case ARMMMUIdx_S1E3:\ncase ARMMMUIdx_S1SE0:\ncase ARMMMUIdx_S1SE1:\nreturn arm_to_core_mmu_idx(ARMMMUIdx_S1SE0);",
"case ARMMMUIdx_S2NS:\ndefault:\ng_assert_not_reached();",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
15
],
[
17,
19,
21,
23
],
[
25,
27,
29,
31
],
[
36,
38,
40
],
[
42
],
[
44
]
] |
24,583 | static uint32_t virtio_net_bad_features(VirtIODevice *vdev)
{
uint32_t features = 0;
/* Linux kernel 2.6.25. It understood MAC (as everyone must),
* but also these: */
features |= (1 << VIRTIO_NET_F_MAC);
features |= (1 << VIRTIO_NET_F_GUEST_CSUM);
features |= (1 << VIRTIO_NET_F_GUEST_TSO4);
features |= (1 << VIRTIO_NET_F_GUEST_TSO6);
features |= (1 << VIRTIO_NET_F_GUEST_ECN);
return features & virtio_net_get_features(vdev);
}
| true | qemu | 184bd0484533b725194fa517ddc271ffd74da7c9 | static uint32_t virtio_net_bad_features(VirtIODevice *vdev)
{
uint32_t features = 0;
features |= (1 << VIRTIO_NET_F_MAC);
features |= (1 << VIRTIO_NET_F_GUEST_CSUM);
features |= (1 << VIRTIO_NET_F_GUEST_TSO4);
features |= (1 << VIRTIO_NET_F_GUEST_TSO6);
features |= (1 << VIRTIO_NET_F_GUEST_ECN);
return features & virtio_net_get_features(vdev);
}
| {
"code": [
" features |= (1 << VIRTIO_NET_F_GUEST_CSUM);",
" features |= (1 << VIRTIO_NET_F_GUEST_TSO4);",
" features |= (1 << VIRTIO_NET_F_GUEST_TSO6);",
" features |= (1 << VIRTIO_NET_F_GUEST_ECN);"
],
"line_no": [
15,
17,
19,
21
]
} | static uint32_t FUNC_0(VirtIODevice *vdev)
{
uint32_t features = 0;
features |= (1 << VIRTIO_NET_F_MAC);
features |= (1 << VIRTIO_NET_F_GUEST_CSUM);
features |= (1 << VIRTIO_NET_F_GUEST_TSO4);
features |= (1 << VIRTIO_NET_F_GUEST_TSO6);
features |= (1 << VIRTIO_NET_F_GUEST_ECN);
return features & virtio_net_get_features(vdev);
}
| [
"static uint32_t FUNC_0(VirtIODevice *vdev)\n{",
"uint32_t features = 0;",
"features |= (1 << VIRTIO_NET_F_MAC);",
"features |= (1 << VIRTIO_NET_F_GUEST_CSUM);",
"features |= (1 << VIRTIO_NET_F_GUEST_TSO4);",
"features |= (1 << VIRTIO_NET_F_GUEST_TSO6);",
"features |= (1 << VIRTIO_NET_F_GUEST_ECN);",
"return features & virtio_net_get_features(vdev);",
"}"
] | [
0,
0,
0,
1,
1,
1,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
]
] |
24,584 | void qemu_get_timer(QEMUFile *f, QEMUTimer *ts)
{
uint64_t expire_time;
expire_time = qemu_get_be64(f);
if (expire_time != -1) {
qemu_mod_timer(ts, expire_time);
} else {
qemu_del_timer(ts);
}
}
| false | qemu | 4a998740b22aa673ea475060c787da7c545588cf | void qemu_get_timer(QEMUFile *f, QEMUTimer *ts)
{
uint64_t expire_time;
expire_time = qemu_get_be64(f);
if (expire_time != -1) {
qemu_mod_timer(ts, expire_time);
} else {
qemu_del_timer(ts);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(QEMUFile *VAR_0, QEMUTimer *VAR_1)
{
uint64_t expire_time;
expire_time = qemu_get_be64(VAR_0);
if (expire_time != -1) {
qemu_mod_timer(VAR_1, expire_time);
} else {
qemu_del_timer(VAR_1);
}
}
| [
"void FUNC_0(QEMUFile *VAR_0, QEMUTimer *VAR_1)\n{",
"uint64_t expire_time;",
"expire_time = qemu_get_be64(VAR_0);",
"if (expire_time != -1) {",
"qemu_mod_timer(VAR_1, expire_time);",
"} else {",
"qemu_del_timer(VAR_1);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
24,585 | static void qemu_co_queue_next_bh(void *opaque)
{
Coroutine *next;
trace_qemu_co_queue_next_bh();
while ((next = QTAILQ_FIRST(&unlock_bh_queue))) {
QTAILQ_REMOVE(&unlock_bh_queue, next, co_queue_next);
qemu_coroutine_enter(next, NULL);
}
}
| false | qemu | 28f082469650a0f4c0e37b4ccd6f9514b1a0698d | static void qemu_co_queue_next_bh(void *opaque)
{
Coroutine *next;
trace_qemu_co_queue_next_bh();
while ((next = QTAILQ_FIRST(&unlock_bh_queue))) {
QTAILQ_REMOVE(&unlock_bh_queue, next, co_queue_next);
qemu_coroutine_enter(next, NULL);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
Coroutine *next;
trace_qemu_co_queue_next_bh();
while ((next = QTAILQ_FIRST(&unlock_bh_queue))) {
QTAILQ_REMOVE(&unlock_bh_queue, next, co_queue_next);
qemu_coroutine_enter(next, NULL);
}
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"Coroutine *next;",
"trace_qemu_co_queue_next_bh();",
"while ((next = QTAILQ_FIRST(&unlock_bh_queue))) {",
"QTAILQ_REMOVE(&unlock_bh_queue, next, co_queue_next);",
"qemu_coroutine_enter(next, NULL);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
24,586 | static void test_to_from_buf_1(void)
{
unsigned niov;
struct iovec *iov;
size_t sz;
unsigned char *ibuf, *obuf;
unsigned i, j, n;
iov_random(&iov, &niov);
sz = iov_size(iov, niov);
ibuf = g_malloc(sz + 8) + 4;
memcpy(ibuf-4, "aaaa", 4); memcpy(ibuf + sz, "bbbb", 4);
obuf = g_malloc(sz + 8) + 4;
memcpy(obuf-4, "xxxx", 4); memcpy(obuf + sz, "yyyy", 4);
/* fill in ibuf with 0123456... */
for (i = 0; i < sz; ++i) {
ibuf[i] = i & 255;
}
for (i = 0; i <= sz; ++i) {
/* Test from/to buf for offset(i) in [0..sz] up to the end of buffer.
* For last iteration with offset == sz, the procedure should
* skip whole vector and process exactly 0 bytes */
/* first set bytes [i..sz) to some "random" value */
n = iov_memset(iov, niov, 0, 0xff, -1);
g_assert(n == sz);
/* next copy bytes [i..sz) from ibuf to iovec */
n = iov_from_buf(iov, niov, i, ibuf + i, -1);
g_assert(n == sz - i);
/* clear part of obuf */
memset(obuf + i, 0, sz - i);
/* and set this part of obuf to values from iovec */
n = iov_to_buf(iov, niov, i, obuf + i, -1);
g_assert(n == sz - i);
/* now compare resulting buffers */
g_assert(memcmp(ibuf, obuf, sz) == 0);
/* test just one char */
n = iov_to_buf(iov, niov, i, obuf + i, 1);
g_assert(n == (i < sz));
if (n) {
g_assert(obuf[i] == (i & 255));
}
for (j = i; j <= sz; ++j) {
/* now test num of bytes cap up to byte no. j,
* with j in [i..sz]. */
/* clear iovec */
n = iov_memset(iov, niov, 0, 0xff, -1);
g_assert(n == sz);
/* copy bytes [i..j) from ibuf to iovec */
n = iov_from_buf(iov, niov, i, ibuf + i, j - i);
g_assert(n == j - i);
/* clear part of obuf */
memset(obuf + i, 0, j - i);
/* copy bytes [i..j) from iovec to obuf */
n = iov_to_buf(iov, niov, i, obuf + i, j - i);
g_assert(n == j - i);
/* verify result */
g_assert(memcmp(ibuf, obuf, sz) == 0);
/* now actually check if the iovec contains the right data */
test_iov_bytes(iov, niov, i, j - i);
}
}
g_assert(!memcmp(ibuf-4, "aaaa", 4) && !memcmp(ibuf+sz, "bbbb", 4));
g_free(ibuf-4);
g_assert(!memcmp(obuf-4, "xxxx", 4) && !memcmp(obuf+sz, "yyyy", 4));
g_free(obuf-4);
iov_free(iov, niov);
}
| false | qemu | e3ff9f0e57472e6411dc446b41789cbd9e2cf887 | static void test_to_from_buf_1(void)
{
unsigned niov;
struct iovec *iov;
size_t sz;
unsigned char *ibuf, *obuf;
unsigned i, j, n;
iov_random(&iov, &niov);
sz = iov_size(iov, niov);
ibuf = g_malloc(sz + 8) + 4;
memcpy(ibuf-4, "aaaa", 4); memcpy(ibuf + sz, "bbbb", 4);
obuf = g_malloc(sz + 8) + 4;
memcpy(obuf-4, "xxxx", 4); memcpy(obuf + sz, "yyyy", 4);
for (i = 0; i < sz; ++i) {
ibuf[i] = i & 255;
}
for (i = 0; i <= sz; ++i) {
n = iov_memset(iov, niov, 0, 0xff, -1);
g_assert(n == sz);
n = iov_from_buf(iov, niov, i, ibuf + i, -1);
g_assert(n == sz - i);
memset(obuf + i, 0, sz - i);
n = iov_to_buf(iov, niov, i, obuf + i, -1);
g_assert(n == sz - i);
g_assert(memcmp(ibuf, obuf, sz) == 0);
n = iov_to_buf(iov, niov, i, obuf + i, 1);
g_assert(n == (i < sz));
if (n) {
g_assert(obuf[i] == (i & 255));
}
for (j = i; j <= sz; ++j) {
n = iov_memset(iov, niov, 0, 0xff, -1);
g_assert(n == sz);
n = iov_from_buf(iov, niov, i, ibuf + i, j - i);
g_assert(n == j - i);
memset(obuf + i, 0, j - i);
n = iov_to_buf(iov, niov, i, obuf + i, j - i);
g_assert(n == j - i);
g_assert(memcmp(ibuf, obuf, sz) == 0);
test_iov_bytes(iov, niov, i, j - i);
}
}
g_assert(!memcmp(ibuf-4, "aaaa", 4) && !memcmp(ibuf+sz, "bbbb", 4));
g_free(ibuf-4);
g_assert(!memcmp(obuf-4, "xxxx", 4) && !memcmp(obuf+sz, "yyyy", 4));
g_free(obuf-4);
iov_free(iov, niov);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
unsigned VAR_0;
struct iovec *VAR_1;
size_t sz;
unsigned char *VAR_2, *VAR_3;
unsigned VAR_4, VAR_5, VAR_6;
iov_random(&VAR_1, &VAR_0);
sz = iov_size(VAR_1, VAR_0);
VAR_2 = g_malloc(sz + 8) + 4;
memcpy(VAR_2-4, "aaaa", 4); memcpy(VAR_2 + sz, "bbbb", 4);
VAR_3 = g_malloc(sz + 8) + 4;
memcpy(VAR_3-4, "xxxx", 4); memcpy(VAR_3 + sz, "yyyy", 4);
for (VAR_4 = 0; VAR_4 < sz; ++VAR_4) {
VAR_2[VAR_4] = VAR_4 & 255;
}
for (VAR_4 = 0; VAR_4 <= sz; ++VAR_4) {
VAR_6 = iov_memset(VAR_1, VAR_0, 0, 0xff, -1);
g_assert(VAR_6 == sz);
VAR_6 = iov_from_buf(VAR_1, VAR_0, VAR_4, VAR_2 + VAR_4, -1);
g_assert(VAR_6 == sz - VAR_4);
memset(VAR_3 + VAR_4, 0, sz - VAR_4);
VAR_6 = iov_to_buf(VAR_1, VAR_0, VAR_4, VAR_3 + VAR_4, -1);
g_assert(VAR_6 == sz - VAR_4);
g_assert(memcmp(VAR_2, VAR_3, sz) == 0);
VAR_6 = iov_to_buf(VAR_1, VAR_0, VAR_4, VAR_3 + VAR_4, 1);
g_assert(VAR_6 == (VAR_4 < sz));
if (VAR_6) {
g_assert(VAR_3[VAR_4] == (VAR_4 & 255));
}
for (VAR_5 = VAR_4; VAR_5 <= sz; ++VAR_5) {
VAR_6 = iov_memset(VAR_1, VAR_0, 0, 0xff, -1);
g_assert(VAR_6 == sz);
VAR_6 = iov_from_buf(VAR_1, VAR_0, VAR_4, VAR_2 + VAR_4, VAR_5 - VAR_4);
g_assert(VAR_6 == VAR_5 - VAR_4);
memset(VAR_3 + VAR_4, 0, VAR_5 - VAR_4);
VAR_6 = iov_to_buf(VAR_1, VAR_0, VAR_4, VAR_3 + VAR_4, VAR_5 - VAR_4);
g_assert(VAR_6 == VAR_5 - VAR_4);
g_assert(memcmp(VAR_2, VAR_3, sz) == 0);
test_iov_bytes(VAR_1, VAR_0, VAR_4, VAR_5 - VAR_4);
}
}
g_assert(!memcmp(VAR_2-4, "aaaa", 4) && !memcmp(VAR_2+sz, "bbbb", 4));
g_free(VAR_2-4);
g_assert(!memcmp(VAR_3-4, "xxxx", 4) && !memcmp(VAR_3+sz, "yyyy", 4));
g_free(VAR_3-4);
iov_free(VAR_1, VAR_0);
}
| [
"static void FUNC_0(void)\n{",
"unsigned VAR_0;",
"struct iovec *VAR_1;",
"size_t sz;",
"unsigned char *VAR_2, *VAR_3;",
"unsigned VAR_4, VAR_5, VAR_6;",
"iov_random(&VAR_1, &VAR_0);",
"sz = iov_size(VAR_1, VAR_0);",
"VAR_2 = g_malloc(sz + 8) + 4;",
"memcpy(VAR_2-4, \"aaaa\", 4); memcpy(VAR_2 + sz, \"bbbb\", 4);",
"VAR_3 = g_malloc(sz + 8) + 4;",
"memcpy(VAR_3-4, \"xxxx\", 4); memcpy(VAR_3 + sz, \"yyyy\", 4);",
"for (VAR_4 = 0; VAR_4 < sz; ++VAR_4) {",
"VAR_2[VAR_4] = VAR_4 & 255;",
"}",
"for (VAR_4 = 0; VAR_4 <= sz; ++VAR_4) {",
"VAR_6 = iov_memset(VAR_1, VAR_0, 0, 0xff, -1);",
"g_assert(VAR_6 == sz);",
"VAR_6 = iov_from_buf(VAR_1, VAR_0, VAR_4, VAR_2 + VAR_4, -1);",
"g_assert(VAR_6 == sz - VAR_4);",
"memset(VAR_3 + VAR_4, 0, sz - VAR_4);",
"VAR_6 = iov_to_buf(VAR_1, VAR_0, VAR_4, VAR_3 + VAR_4, -1);",
"g_assert(VAR_6 == sz - VAR_4);",
"g_assert(memcmp(VAR_2, VAR_3, sz) == 0);",
"VAR_6 = iov_to_buf(VAR_1, VAR_0, VAR_4, VAR_3 + VAR_4, 1);",
"g_assert(VAR_6 == (VAR_4 < sz));",
"if (VAR_6) {",
"g_assert(VAR_3[VAR_4] == (VAR_4 & 255));",
"}",
"for (VAR_5 = VAR_4; VAR_5 <= sz; ++VAR_5) {",
"VAR_6 = iov_memset(VAR_1, VAR_0, 0, 0xff, -1);",
"g_assert(VAR_6 == sz);",
"VAR_6 = iov_from_buf(VAR_1, VAR_0, VAR_4, VAR_2 + VAR_4, VAR_5 - VAR_4);",
"g_assert(VAR_6 == VAR_5 - VAR_4);",
"memset(VAR_3 + VAR_4, 0, VAR_5 - VAR_4);",
"VAR_6 = iov_to_buf(VAR_1, VAR_0, VAR_4, VAR_3 + VAR_4, VAR_5 - VAR_4);",
"g_assert(VAR_6 == VAR_5 - VAR_4);",
"g_assert(memcmp(VAR_2, VAR_3, sz) == 0);",
"test_iov_bytes(VAR_1, VAR_0, VAR_4, VAR_5 - VAR_4);",
"}",
"}",
"g_assert(!memcmp(VAR_2-4, \"aaaa\", 4) && !memcmp(VAR_2+sz, \"bbbb\", 4));",
"g_free(VAR_2-4);",
"g_assert(!memcmp(VAR_3-4, \"xxxx\", 4) && !memcmp(VAR_3+sz, \"yyyy\", 4));",
"g_free(VAR_3-4);",
"iov_free(VAR_1, VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
37
],
[
39
],
[
41
],
[
45
],
[
59
],
[
61
],
[
67
],
[
69
],
[
75
],
[
79
],
[
81
],
[
87
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
115
],
[
117
],
[
123
],
[
125
],
[
131
],
[
137
],
[
139
],
[
145
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
]
] |
24,589 | static uint64_t exynos4210_i2c_read(void *opaque, target_phys_addr_t offset,
unsigned size)
{
Exynos4210I2CState *s = (Exynos4210I2CState *)opaque;
uint8_t value;
switch (offset) {
case I2CCON_ADDR:
value = s->i2ccon;
break;
case I2CSTAT_ADDR:
value = s->i2cstat;
break;
case I2CADD_ADDR:
value = s->i2cadd;
break;
case I2CDS_ADDR:
value = s->i2cds;
s->scl_free = true;
if (EXYNOS4_I2C_MODE(s->i2cstat) == I2CMODE_MASTER_Rx &&
(s->i2cstat & I2CSTAT_START_BUSY) &&
!(s->i2ccon & I2CCON_INT_PEND)) {
exynos4210_i2c_data_receive(s);
}
break;
case I2CLC_ADDR:
value = s->i2clc;
break;
default:
value = 0;
DPRINT("ERROR: Bad read offset 0x%x\n", (unsigned int)offset);
break;
}
DPRINT("read %s [0x%02x] -> 0x%02x\n", exynos4_i2c_get_regname(offset),
(unsigned int)offset, value);
return value;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t exynos4210_i2c_read(void *opaque, target_phys_addr_t offset,
unsigned size)
{
Exynos4210I2CState *s = (Exynos4210I2CState *)opaque;
uint8_t value;
switch (offset) {
case I2CCON_ADDR:
value = s->i2ccon;
break;
case I2CSTAT_ADDR:
value = s->i2cstat;
break;
case I2CADD_ADDR:
value = s->i2cadd;
break;
case I2CDS_ADDR:
value = s->i2cds;
s->scl_free = true;
if (EXYNOS4_I2C_MODE(s->i2cstat) == I2CMODE_MASTER_Rx &&
(s->i2cstat & I2CSTAT_START_BUSY) &&
!(s->i2ccon & I2CCON_INT_PEND)) {
exynos4210_i2c_data_receive(s);
}
break;
case I2CLC_ADDR:
value = s->i2clc;
break;
default:
value = 0;
DPRINT("ERROR: Bad read offset 0x%x\n", (unsigned int)offset);
break;
}
DPRINT("read %s [0x%02x] -> 0x%02x\n", exynos4_i2c_get_regname(offset),
(unsigned int)offset, value);
return value;
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t offset,
unsigned size)
{
Exynos4210I2CState *s = (Exynos4210I2CState *)opaque;
uint8_t value;
switch (offset) {
case I2CCON_ADDR:
value = s->i2ccon;
break;
case I2CSTAT_ADDR:
value = s->i2cstat;
break;
case I2CADD_ADDR:
value = s->i2cadd;
break;
case I2CDS_ADDR:
value = s->i2cds;
s->scl_free = true;
if (EXYNOS4_I2C_MODE(s->i2cstat) == I2CMODE_MASTER_Rx &&
(s->i2cstat & I2CSTAT_START_BUSY) &&
!(s->i2ccon & I2CCON_INT_PEND)) {
exynos4210_i2c_data_receive(s);
}
break;
case I2CLC_ADDR:
value = s->i2clc;
break;
default:
value = 0;
DPRINT("ERROR: Bad read offset 0x%x\n", (unsigned int)offset);
break;
}
DPRINT("read %s [0x%02x] -> 0x%02x\n", exynos4_i2c_get_regname(offset),
(unsigned int)offset, value);
return value;
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t offset,\nunsigned size)\n{",
"Exynos4210I2CState *s = (Exynos4210I2CState *)opaque;",
"uint8_t value;",
"switch (offset) {",
"case I2CCON_ADDR:\nvalue = s->i2ccon;",
"break;",
"case I2CSTAT_ADDR:\nvalue = s->i2cstat;",
"break;",
"case I2CADD_ADDR:\nvalue = s->i2cadd;",
"break;",
"case I2CDS_ADDR:\nvalue = s->i2cds;",
"s->scl_free = true;",
"if (EXYNOS4_I2C_MODE(s->i2cstat) == I2CMODE_MASTER_Rx &&\n(s->i2cstat & I2CSTAT_START_BUSY) &&\n!(s->i2ccon & I2CCON_INT_PEND)) {",
"exynos4210_i2c_data_receive(s);",
"}",
"break;",
"case I2CLC_ADDR:\nvalue = s->i2clc;",
"break;",
"default:\nvalue = 0;",
"DPRINT(\"ERROR: Bad read offset 0x%x\\n\", (unsigned int)offset);",
"break;",
"}",
"DPRINT(\"read %s [0x%02x] -> 0x%02x\\n\", exynos4_i2c_get_regname(offset),\n(unsigned int)offset, value);",
"return value;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
19
],
[
21,
23
],
[
25
],
[
27,
29
],
[
31
],
[
33,
35
],
[
37
],
[
39,
41,
43
],
[
45
],
[
47
],
[
49
],
[
51,
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
69,
71
],
[
73
],
[
75
]
] |
24,590 | int unix_socket_incoming(const char *path)
{
Error *local_err = NULL;
int fd = unix_listen(path, NULL, 0, &local_err);
if (local_err != NULL) {
qerror_report_err(local_err);
error_free(local_err);
}
return fd;
}
| false | qemu | 537b41f5013e1951fa15e8f18855b18d76124ce4 | int unix_socket_incoming(const char *path)
{
Error *local_err = NULL;
int fd = unix_listen(path, NULL, 0, &local_err);
if (local_err != NULL) {
qerror_report_err(local_err);
error_free(local_err);
}
return fd;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(const char *VAR_0)
{
Error *local_err = NULL;
int VAR_1 = unix_listen(VAR_0, NULL, 0, &local_err);
if (local_err != NULL) {
qerror_report_err(local_err);
error_free(local_err);
}
return VAR_1;
}
| [
"int FUNC_0(const char *VAR_0)\n{",
"Error *local_err = NULL;",
"int VAR_1 = unix_listen(VAR_0, NULL, 0, &local_err);",
"if (local_err != NULL) {",
"qerror_report_err(local_err);",
"error_free(local_err);",
"}",
"return VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
24,591 | static int iscsi_reopen_prepare(BDRVReopenState *state,
BlockReopenQueue *queue, Error **errp)
{
/* NOP */
return 0;
}
| false | qemu | 43ae8fb10c5f6ca78f242624c1f446e0050a9d43 | static int iscsi_reopen_prepare(BDRVReopenState *state,
BlockReopenQueue *queue, Error **errp)
{
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BDRVReopenState *VAR_0,
BlockReopenQueue *VAR_1, Error **VAR_2)
{
return 0;
}
| [
"static int FUNC_0(BDRVReopenState *VAR_0,\nBlockReopenQueue *VAR_1, Error **VAR_2)\n{",
"return 0;",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5
],
[
9
],
[
11
]
] |
24,592 | static void raw_probe_alignment(BlockDriverState *bs, Error **errp)
{
BDRVRawState *s = bs->opaque;
DWORD sectorsPerCluster, freeClusters, totalClusters, count;
DISK_GEOMETRY_EX dg;
BOOL status;
if (s->type == FTYPE_CD) {
bs->request_alignment = 2048;
return;
}
if (s->type == FTYPE_HARDDISK) {
status = DeviceIoControl(s->hfile, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX,
NULL, 0, &dg, sizeof(dg), &count, NULL);
if (status != 0) {
bs->request_alignment = dg.Geometry.BytesPerSector;
return;
}
/* try GetDiskFreeSpace too */
}
if (s->drive_path[0]) {
GetDiskFreeSpace(s->drive_path, §orsPerCluster,
&dg.Geometry.BytesPerSector,
&freeClusters, &totalClusters);
bs->request_alignment = dg.Geometry.BytesPerSector;
}
}
| false | qemu | a5b8dd2ce83208cd7d6eb4562339ecf5aae13574 | static void raw_probe_alignment(BlockDriverState *bs, Error **errp)
{
BDRVRawState *s = bs->opaque;
DWORD sectorsPerCluster, freeClusters, totalClusters, count;
DISK_GEOMETRY_EX dg;
BOOL status;
if (s->type == FTYPE_CD) {
bs->request_alignment = 2048;
return;
}
if (s->type == FTYPE_HARDDISK) {
status = DeviceIoControl(s->hfile, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX,
NULL, 0, &dg, sizeof(dg), &count, NULL);
if (status != 0) {
bs->request_alignment = dg.Geometry.BytesPerSector;
return;
}
}
if (s->drive_path[0]) {
GetDiskFreeSpace(s->drive_path, §orsPerCluster,
&dg.Geometry.BytesPerSector,
&freeClusters, &totalClusters);
bs->request_alignment = dg.Geometry.BytesPerSector;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(BlockDriverState *VAR_0, Error **VAR_1)
{
BDRVRawState *s = VAR_0->opaque;
DWORD sectorsPerCluster, freeClusters, totalClusters, count;
DISK_GEOMETRY_EX dg;
BOOL status;
if (s->type == FTYPE_CD) {
VAR_0->request_alignment = 2048;
return;
}
if (s->type == FTYPE_HARDDISK) {
status = DeviceIoControl(s->hfile, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX,
NULL, 0, &dg, sizeof(dg), &count, NULL);
if (status != 0) {
VAR_0->request_alignment = dg.Geometry.BytesPerSector;
return;
}
}
if (s->drive_path[0]) {
GetDiskFreeSpace(s->drive_path, §orsPerCluster,
&dg.Geometry.BytesPerSector,
&freeClusters, &totalClusters);
VAR_0->request_alignment = dg.Geometry.BytesPerSector;
}
}
| [
"static void FUNC_0(BlockDriverState *VAR_0, Error **VAR_1)\n{",
"BDRVRawState *s = VAR_0->opaque;",
"DWORD sectorsPerCluster, freeClusters, totalClusters, count;",
"DISK_GEOMETRY_EX dg;",
"BOOL status;",
"if (s->type == FTYPE_CD) {",
"VAR_0->request_alignment = 2048;",
"return;",
"}",
"if (s->type == FTYPE_HARDDISK) {",
"status = DeviceIoControl(s->hfile, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX,\nNULL, 0, &dg, sizeof(dg), &count, NULL);",
"if (status != 0) {",
"VAR_0->request_alignment = dg.Geometry.BytesPerSector;",
"return;",
"}",
"}",
"if (s->drive_path[0]) {",
"GetDiskFreeSpace(s->drive_path, §orsPerCluster,\n&dg.Geometry.BytesPerSector,\n&freeClusters, &totalClusters);",
"VAR_0->request_alignment = dg.Geometry.BytesPerSector;",
"}",
"}"
] | [
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
],
[
39
],
[
43
],
[
45,
47,
49
],
[
51
],
[
53
],
[
55
]
] |
24,593 | static int local_name_to_path(FsContext *ctx, V9fsPath *dir_path,
const char *name, V9fsPath *target)
{
if (ctx->export_flags & V9FS_SM_MAPPED_FILE &&
local_is_mapped_file_metadata(ctx, name)) {
errno = EINVAL;
return -1;
}
if (dir_path) {
v9fs_path_sprintf(target, "%s/%s", dir_path->data, name);
} else if (strcmp(name, "/")) {
v9fs_path_sprintf(target, "%s", name);
} else {
/* We want the path of the export root to be relative, otherwise
* "*at()" syscalls would treat it as "/" in the host.
*/
v9fs_path_sprintf(target, "%s", ".");
}
return 0;
}
| false | qemu | f57f5878578af19f72344439154234c6d6ba8ccc | static int local_name_to_path(FsContext *ctx, V9fsPath *dir_path,
const char *name, V9fsPath *target)
{
if (ctx->export_flags & V9FS_SM_MAPPED_FILE &&
local_is_mapped_file_metadata(ctx, name)) {
errno = EINVAL;
return -1;
}
if (dir_path) {
v9fs_path_sprintf(target, "%s/%s", dir_path->data, name);
} else if (strcmp(name, "/")) {
v9fs_path_sprintf(target, "%s", name);
} else {
v9fs_path_sprintf(target, "%s", ".");
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1,
const char *VAR_2, V9fsPath *VAR_3)
{
if (VAR_0->export_flags & V9FS_SM_MAPPED_FILE &&
local_is_mapped_file_metadata(VAR_0, VAR_2)) {
errno = EINVAL;
return -1;
}
if (VAR_1) {
v9fs_path_sprintf(VAR_3, "%s/%s", VAR_1->data, VAR_2);
} else if (strcmp(VAR_2, "/")) {
v9fs_path_sprintf(VAR_3, "%s", VAR_2);
} else {
v9fs_path_sprintf(VAR_3, "%s", ".");
}
return 0;
}
| [
"static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1,\nconst char *VAR_2, V9fsPath *VAR_3)\n{",
"if (VAR_0->export_flags & V9FS_SM_MAPPED_FILE &&\nlocal_is_mapped_file_metadata(VAR_0, VAR_2)) {",
"errno = EINVAL;",
"return -1;",
"}",
"if (VAR_1) {",
"v9fs_path_sprintf(VAR_3, \"%s/%s\", VAR_1->data, VAR_2);",
"} else if (strcmp(VAR_2, \"/\")) {",
"v9fs_path_sprintf(VAR_3, \"%s\", VAR_2);",
"} else {",
"v9fs_path_sprintf(VAR_3, \"%s\", \".\");",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7,
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
35
],
[
37
],
[
39
],
[
41
]
] |
24,594 | static inline void gen_op_fcmpes(int fccno, TCGv r_rs1, TCGv r_rs2)
{
gen_helper_fcmpes(cpu_env, r_rs1, r_rs2);
}
| false | qemu | 7385aed20db5d83979f683b9d0048674411e963c | static inline void gen_op_fcmpes(int fccno, TCGv r_rs1, TCGv r_rs2)
{
gen_helper_fcmpes(cpu_env, r_rs1, r_rs2);
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(int VAR_0, TCGv VAR_1, TCGv VAR_2)
{
gen_helper_fcmpes(cpu_env, VAR_1, VAR_2);
}
| [
"static inline void FUNC_0(int VAR_0, TCGv VAR_1, TCGv VAR_2)\n{",
"gen_helper_fcmpes(cpu_env, VAR_1, VAR_2);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
24,595 | long do_sigreturn(CPUMIPSState *regs)
{
struct sigframe *frame;
abi_ulong frame_addr;
sigset_t blocked;
target_sigset_t target_set;
int i;
#if defined(DEBUG_SIGNAL)
fprintf(stderr, "do_sigreturn\n");
#endif
frame_addr = regs->active_tc.gpr[29];
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
goto badframe;
for(i = 0; i < TARGET_NSIG_WORDS; i++) {
if(__get_user(target_set.sig[i], &frame->sf_mask.sig[i]))
goto badframe;
}
target_to_host_sigset_internal(&blocked, &target_set);
sigprocmask(SIG_SETMASK, &blocked, NULL);
if (restore_sigcontext(regs, &frame->sf_sc))
goto badframe;
#if 0
/*
* Don't let your children do this ...
*/
__asm__ __volatile__(
"move\t$29, %0\n\t"
"j\tsyscall_exit"
:/* no outputs */
:"r" (®s));
/* Unreached */
#endif
regs->active_tc.PC = regs->CP0_EPC;
mips_set_hflags_isa_mode_from_pc(regs);
/* I am not sure this is right, but it seems to work
* maybe a problem with nested signals ? */
regs->CP0_EPC = 0;
return -TARGET_QEMU_ESIGRETURN;
badframe:
force_sig(TARGET_SIGSEGV/*, current*/);
return 0;
}
| false | qemu | 1c275925bfbbc2de84a8f0e09d1dd70bbefb6da3 | long do_sigreturn(CPUMIPSState *regs)
{
struct sigframe *frame;
abi_ulong frame_addr;
sigset_t blocked;
target_sigset_t target_set;
int i;
#if defined(DEBUG_SIGNAL)
fprintf(stderr, "do_sigreturn\n");
#endif
frame_addr = regs->active_tc.gpr[29];
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
goto badframe;
for(i = 0; i < TARGET_NSIG_WORDS; i++) {
if(__get_user(target_set.sig[i], &frame->sf_mask.sig[i]))
goto badframe;
}
target_to_host_sigset_internal(&blocked, &target_set);
sigprocmask(SIG_SETMASK, &blocked, NULL);
if (restore_sigcontext(regs, &frame->sf_sc))
goto badframe;
#if 0
__asm__ __volatile__(
"move\t$29, %0\n\t"
"j\tsyscall_exit"
:
:"r" (®s));
#endif
regs->active_tc.PC = regs->CP0_EPC;
mips_set_hflags_isa_mode_from_pc(regs);
regs->CP0_EPC = 0;
return -TARGET_QEMU_ESIGRETURN;
badframe:
force_sig(TARGET_SIGSEGV);
return 0;
}
| {
"code": [],
"line_no": []
} | long FUNC_0(CPUMIPSState *VAR_0)
{
struct sigframe *VAR_1;
abi_ulong frame_addr;
sigset_t blocked;
target_sigset_t target_set;
int VAR_2;
#if defined(DEBUG_SIGNAL)
fprintf(stderr, "FUNC_0\n");
#endif
frame_addr = VAR_0->active_tc.gpr[29];
if (!lock_user_struct(VERIFY_READ, VAR_1, frame_addr, 1))
goto badframe;
for(VAR_2 = 0; VAR_2 < TARGET_NSIG_WORDS; VAR_2++) {
if(__get_user(target_set.sig[VAR_2], &VAR_1->sf_mask.sig[VAR_2]))
goto badframe;
}
target_to_host_sigset_internal(&blocked, &target_set);
sigprocmask(SIG_SETMASK, &blocked, NULL);
if (restore_sigcontext(VAR_0, &VAR_1->sf_sc))
goto badframe;
#if 0
__asm__ __volatile__(
"move\t$29, %0\n\t"
"j\tsyscall_exit"
:
:"r" (&VAR_0));
#endif
VAR_0->active_tc.PC = VAR_0->CP0_EPC;
mips_set_hflags_isa_mode_from_pc(VAR_0);
VAR_0->CP0_EPC = 0;
return -TARGET_QEMU_ESIGRETURN;
badframe:
force_sig(TARGET_SIGSEGV);
return 0;
}
| [
"long FUNC_0(CPUMIPSState *VAR_0)\n{",
"struct sigframe *VAR_1;",
"abi_ulong frame_addr;",
"sigset_t blocked;",
"target_sigset_t target_set;",
"int VAR_2;",
"#if defined(DEBUG_SIGNAL)\nfprintf(stderr, \"FUNC_0\\n\");",
"#endif\nframe_addr = VAR_0->active_tc.gpr[29];",
"if (!lock_user_struct(VERIFY_READ, VAR_1, frame_addr, 1))\ngoto badframe;",
"for(VAR_2 = 0; VAR_2 < TARGET_NSIG_WORDS; VAR_2++) {",
"if(__get_user(target_set.sig[VAR_2], &VAR_1->sf_mask.sig[VAR_2]))\ngoto badframe;",
"}",
"target_to_host_sigset_internal(&blocked, &target_set);",
"sigprocmask(SIG_SETMASK, &blocked, NULL);",
"if (restore_sigcontext(VAR_0, &VAR_1->sf_sc))\ngoto badframe;",
"#if 0\n__asm__ __volatile__(\n\"move\\t$29, %0\\n\\t\"\n\"j\\tsyscall_exit\"\n:\n:\"r\" (&VAR_0));",
"#endif\nVAR_0->active_tc.PC = VAR_0->CP0_EPC;",
"mips_set_hflags_isa_mode_from_pc(VAR_0);",
"VAR_0->CP0_EPC = 0;",
"return -TARGET_QEMU_ESIGRETURN;",
"badframe:\nforce_sig(TARGET_SIGSEGV);",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17,
19
],
[
21,
23
],
[
25,
27
],
[
31
],
[
33,
35
],
[
37
],
[
41
],
[
43
],
[
47,
49
],
[
53,
61,
63,
65,
67,
69
],
[
73,
77
],
[
79
],
[
85
],
[
87
],
[
91,
93
],
[
95
],
[
97
]
] |
24,596 | static int con_init(struct XenDevice *xendev)
{
struct XenConsole *con = container_of(xendev, struct XenConsole, xendev);
char *type, *dom;
int ret = 0;
/* setup */
dom = xs_get_domain_path(xenstore, con->xendev.dom);
snprintf(con->console, sizeof(con->console), "%s/console", dom);
free(dom);
type = xenstore_read_str(con->console, "type");
if (!type || strcmp(type, "ioemu") != 0) {
xen_be_printf(xendev, 1, "not for me (type=%s)\n", type);
ret = -1;
goto out;
}
if (!serial_hds[con->xendev.dev])
xen_be_printf(xendev, 1, "WARNING: serial line %d not configured\n",
con->xendev.dev);
else
con->chr = serial_hds[con->xendev.dev];
out:
qemu_free(type);
return ret;
}
| false | qemu | 0f51726adcdb620214405a88b2601d9edd059db4 | static int con_init(struct XenDevice *xendev)
{
struct XenConsole *con = container_of(xendev, struct XenConsole, xendev);
char *type, *dom;
int ret = 0;
dom = xs_get_domain_path(xenstore, con->xendev.dom);
snprintf(con->console, sizeof(con->console), "%s/console", dom);
free(dom);
type = xenstore_read_str(con->console, "type");
if (!type || strcmp(type, "ioemu") != 0) {
xen_be_printf(xendev, 1, "not for me (type=%s)\n", type);
ret = -1;
goto out;
}
if (!serial_hds[con->xendev.dev])
xen_be_printf(xendev, 1, "WARNING: serial line %d not configured\n",
con->xendev.dev);
else
con->chr = serial_hds[con->xendev.dev];
out:
qemu_free(type);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(struct XenDevice *VAR_0)
{
struct XenConsole *VAR_1 = container_of(VAR_0, struct XenConsole, VAR_0);
char *VAR_2, *VAR_3;
int VAR_4 = 0;
VAR_3 = xs_get_domain_path(xenstore, VAR_1->VAR_0.VAR_3);
snprintf(VAR_1->console, sizeof(VAR_1->console), "%s/console", VAR_3);
free(VAR_3);
VAR_2 = xenstore_read_str(VAR_1->console, "VAR_2");
if (!VAR_2 || strcmp(VAR_2, "ioemu") != 0) {
xen_be_printf(VAR_0, 1, "not for me (VAR_2=%s)\n", VAR_2);
VAR_4 = -1;
goto out;
}
if (!serial_hds[VAR_1->VAR_0.dev])
xen_be_printf(VAR_0, 1, "WARNING: serial line %d not configured\n",
VAR_1->VAR_0.dev);
else
VAR_1->chr = serial_hds[VAR_1->VAR_0.dev];
out:
qemu_free(VAR_2);
return VAR_4;
}
| [
"static int FUNC_0(struct XenDevice *VAR_0)\n{",
"struct XenConsole *VAR_1 = container_of(VAR_0, struct XenConsole, VAR_0);",
"char *VAR_2, *VAR_3;",
"int VAR_4 = 0;",
"VAR_3 = xs_get_domain_path(xenstore, VAR_1->VAR_0.VAR_3);",
"snprintf(VAR_1->console, sizeof(VAR_1->console), \"%s/console\", VAR_3);",
"free(VAR_3);",
"VAR_2 = xenstore_read_str(VAR_1->console, \"VAR_2\");",
"if (!VAR_2 || strcmp(VAR_2, \"ioemu\") != 0) {",
"xen_be_printf(VAR_0, 1, \"not for me (VAR_2=%s)\\n\", VAR_2);",
"VAR_4 = -1;",
"goto out;",
"}",
"if (!serial_hds[VAR_1->VAR_0.dev])\nxen_be_printf(VAR_0, 1, \"WARNING: serial line %d not configured\\n\",\nVAR_1->VAR_0.dev);",
"else\nVAR_1->chr = serial_hds[VAR_1->VAR_0.dev];",
"out:\nqemu_free(VAR_2);",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37,
39,
41
],
[
43,
45
],
[
49,
51
],
[
53
],
[
55
]
] |
24,598 | av_cold int ff_intrax8_common_init(AVCodecContext *avctx,
IntraX8Context *w, IDCTDSPContext *idsp,
int16_t (*block)[64],
int block_last_index[12],
int mb_width, int mb_height)
{
int ret = x8_vlc_init();
if (ret < 0)
return ret;
w->avctx = avctx;
w->idsp = *idsp;
w->mb_width = mb_width;
w->mb_height = mb_height;
w->block = block;
w->block_last_index = block_last_index;
// two rows, 2 blocks per cannon mb
w->prediction_table = av_mallocz(w->mb_width * 2 * 2);
if (!w->prediction_table)
return AVERROR(ENOMEM);
ff_init_scantable(w->idsp.idct_permutation, &w->scantable[0],
ff_wmv1_scantable[0]);
ff_init_scantable(w->idsp.idct_permutation, &w->scantable[1],
ff_wmv1_scantable[2]);
ff_init_scantable(w->idsp.idct_permutation, &w->scantable[2],
ff_wmv1_scantable[3]);
ff_intrax8dsp_init(&w->dsp);
ff_blockdsp_init(&w->bdsp, avctx);
return 0;
}
| false | FFmpeg | dcc39ee10e82833ce24aa57926c00ffeb1948198 | av_cold int ff_intrax8_common_init(AVCodecContext *avctx,
IntraX8Context *w, IDCTDSPContext *idsp,
int16_t (*block)[64],
int block_last_index[12],
int mb_width, int mb_height)
{
int ret = x8_vlc_init();
if (ret < 0)
return ret;
w->avctx = avctx;
w->idsp = *idsp;
w->mb_width = mb_width;
w->mb_height = mb_height;
w->block = block;
w->block_last_index = block_last_index;
w->prediction_table = av_mallocz(w->mb_width * 2 * 2);
if (!w->prediction_table)
return AVERROR(ENOMEM);
ff_init_scantable(w->idsp.idct_permutation, &w->scantable[0],
ff_wmv1_scantable[0]);
ff_init_scantable(w->idsp.idct_permutation, &w->scantable[1],
ff_wmv1_scantable[2]);
ff_init_scantable(w->idsp.idct_permutation, &w->scantable[2],
ff_wmv1_scantable[3]);
ff_intrax8dsp_init(&w->dsp);
ff_blockdsp_init(&w->bdsp, avctx);
return 0;
}
| {
"code": [],
"line_no": []
} | av_cold int FUNC_0(AVCodecContext *avctx,
IntraX8Context *w, IDCTDSPContext *idsp,
int16_t (*block)[64],
int block_last_index[12],
int mb_width, int mb_height)
{
int VAR_0 = x8_vlc_init();
if (VAR_0 < 0)
return VAR_0;
w->avctx = avctx;
w->idsp = *idsp;
w->mb_width = mb_width;
w->mb_height = mb_height;
w->block = block;
w->block_last_index = block_last_index;
w->prediction_table = av_mallocz(w->mb_width * 2 * 2);
if (!w->prediction_table)
return AVERROR(ENOMEM);
ff_init_scantable(w->idsp.idct_permutation, &w->scantable[0],
ff_wmv1_scantable[0]);
ff_init_scantable(w->idsp.idct_permutation, &w->scantable[1],
ff_wmv1_scantable[2]);
ff_init_scantable(w->idsp.idct_permutation, &w->scantable[2],
ff_wmv1_scantable[3]);
ff_intrax8dsp_init(&w->dsp);
ff_blockdsp_init(&w->bdsp, avctx);
return 0;
}
| [
"av_cold int FUNC_0(AVCodecContext *avctx,\nIntraX8Context *w, IDCTDSPContext *idsp,\nint16_t (*block)[64],\nint block_last_index[12],\nint mb_width, int mb_height)\n{",
"int VAR_0 = x8_vlc_init();",
"if (VAR_0 < 0)\nreturn VAR_0;",
"w->avctx = avctx;",
"w->idsp = *idsp;",
"w->mb_width = mb_width;",
"w->mb_height = mb_height;",
"w->block = block;",
"w->block_last_index = block_last_index;",
"w->prediction_table = av_mallocz(w->mb_width * 2 * 2);",
"if (!w->prediction_table)\nreturn AVERROR(ENOMEM);",
"ff_init_scantable(w->idsp.idct_permutation, &w->scantable[0],\nff_wmv1_scantable[0]);",
"ff_init_scantable(w->idsp.idct_permutation, &w->scantable[1],\nff_wmv1_scantable[2]);",
"ff_init_scantable(w->idsp.idct_permutation, &w->scantable[2],\nff_wmv1_scantable[3]);",
"ff_intrax8dsp_init(&w->dsp);",
"ff_blockdsp_init(&w->bdsp, avctx);",
"return 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
],
[
37
],
[
39,
41
],
[
45,
47
],
[
49,
51
],
[
53,
55
],
[
59
],
[
61
],
[
65
],
[
67
]
] |
24,599 | static void string_output_free(Visitor *v)
{
StringOutputVisitor *sov = to_sov(v);
string_output_visitor_cleanup(sov);
}
| false | qemu | e7ca56562990991bc614a43b9351ee0737f3045d | static void string_output_free(Visitor *v)
{
StringOutputVisitor *sov = to_sov(v);
string_output_visitor_cleanup(sov);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Visitor *VAR_0)
{
StringOutputVisitor *sov = to_sov(VAR_0);
string_output_visitor_cleanup(sov);
}
| [
"static void FUNC_0(Visitor *VAR_0)\n{",
"StringOutputVisitor *sov = to_sov(VAR_0);",
"string_output_visitor_cleanup(sov);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
]
] |
24,601 | static void external_snapshot_abort(BlkActionState *common)
{
ExternalSnapshotState *state =
DO_UPCAST(ExternalSnapshotState, common, common);
if (state->new_bs) {
if (state->new_bs->backing) {
bdrv_replace_in_backing_chain(state->new_bs, state->old_bs);
}
}
}
| false | qemu | 067acf28d1d726059f994356f25e054ce2926acf | static void external_snapshot_abort(BlkActionState *common)
{
ExternalSnapshotState *state =
DO_UPCAST(ExternalSnapshotState, common, common);
if (state->new_bs) {
if (state->new_bs->backing) {
bdrv_replace_in_backing_chain(state->new_bs, state->old_bs);
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(BlkActionState *VAR_0)
{
ExternalSnapshotState *state =
DO_UPCAST(ExternalSnapshotState, VAR_0, VAR_0);
if (state->new_bs) {
if (state->new_bs->backing) {
bdrv_replace_in_backing_chain(state->new_bs, state->old_bs);
}
}
}
| [
"static void FUNC_0(BlkActionState *VAR_0)\n{",
"ExternalSnapshotState *state =\nDO_UPCAST(ExternalSnapshotState, VAR_0, VAR_0);",
"if (state->new_bs) {",
"if (state->new_bs->backing) {",
"bdrv_replace_in_backing_chain(state->new_bs, state->old_bs);",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
24,604 | static void virtio_ccw_device_plugged(DeviceState *d, Error **errp)
{
VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
CcwDevice *ccw_dev = CCW_DEVICE(d);
SubchDev *sch = ccw_dev->sch;
int n = virtio_get_num_queues(vdev);
S390FLICState *flic = s390_get_flic();
if (!virtio_has_feature(vdev->host_features, VIRTIO_F_VERSION_1)) {
dev->max_rev = 0;
}
if (virtio_get_num_queues(vdev) > VIRTIO_CCW_QUEUE_MAX) {
error_setg(errp, "The number of virtqueues %d "
"exceeds ccw limit %d", n,
VIRTIO_CCW_QUEUE_MAX);
return;
}
if (virtio_get_num_queues(vdev) > flic->adapter_routes_max_batch) {
error_setg(errp, "The number of virtqueues %d "
"exceeds flic adapter route limit %d", n,
flic->adapter_routes_max_batch);
return;
}
sch->id.cu_model = virtio_bus_get_vdev_id(&dev->bus);
css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid,
d->hotplugged, 1);
}
| false | qemu | b1914b824ade1706847428e64ef5637ffc0ae238 | static void virtio_ccw_device_plugged(DeviceState *d, Error **errp)
{
VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
CcwDevice *ccw_dev = CCW_DEVICE(d);
SubchDev *sch = ccw_dev->sch;
int n = virtio_get_num_queues(vdev);
S390FLICState *flic = s390_get_flic();
if (!virtio_has_feature(vdev->host_features, VIRTIO_F_VERSION_1)) {
dev->max_rev = 0;
}
if (virtio_get_num_queues(vdev) > VIRTIO_CCW_QUEUE_MAX) {
error_setg(errp, "The number of virtqueues %d "
"exceeds ccw limit %d", n,
VIRTIO_CCW_QUEUE_MAX);
return;
}
if (virtio_get_num_queues(vdev) > flic->adapter_routes_max_batch) {
error_setg(errp, "The number of virtqueues %d "
"exceeds flic adapter route limit %d", n,
flic->adapter_routes_max_batch);
return;
}
sch->id.cu_model = virtio_bus_get_vdev_id(&dev->bus);
css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid,
d->hotplugged, 1);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(VAR_0);
VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
CcwDevice *ccw_dev = CCW_DEVICE(VAR_0);
SubchDev *sch = ccw_dev->sch;
int VAR_2 = virtio_get_num_queues(vdev);
S390FLICState *flic = s390_get_flic();
if (!virtio_has_feature(vdev->host_features, VIRTIO_F_VERSION_1)) {
dev->max_rev = 0;
}
if (virtio_get_num_queues(vdev) > VIRTIO_CCW_QUEUE_MAX) {
error_setg(VAR_1, "The number of virtqueues %VAR_0 "
"exceeds ccw limit %VAR_0", VAR_2,
VIRTIO_CCW_QUEUE_MAX);
return;
}
if (virtio_get_num_queues(vdev) > flic->adapter_routes_max_batch) {
error_setg(VAR_1, "The number of virtqueues %VAR_0 "
"exceeds flic adapter route limit %VAR_0", VAR_2,
flic->adapter_routes_max_batch);
return;
}
sch->id.cu_model = virtio_bus_get_vdev_id(&dev->bus);
css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid,
VAR_0->hotplugged, 1);
}
| [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(VAR_0);",
"VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);",
"CcwDevice *ccw_dev = CCW_DEVICE(VAR_0);",
"SubchDev *sch = ccw_dev->sch;",
"int VAR_2 = virtio_get_num_queues(vdev);",
"S390FLICState *flic = s390_get_flic();",
"if (!virtio_has_feature(vdev->host_features, VIRTIO_F_VERSION_1)) {",
"dev->max_rev = 0;",
"}",
"if (virtio_get_num_queues(vdev) > VIRTIO_CCW_QUEUE_MAX) {",
"error_setg(VAR_1, \"The number of virtqueues %VAR_0 \"\n\"exceeds ccw limit %VAR_0\", VAR_2,\nVIRTIO_CCW_QUEUE_MAX);",
"return;",
"}",
"if (virtio_get_num_queues(vdev) > flic->adapter_routes_max_batch) {",
"error_setg(VAR_1, \"The number of virtqueues %VAR_0 \"\n\"exceeds flic adapter route limit %VAR_0\", VAR_2,\nflic->adapter_routes_max_batch);",
"return;",
"}",
"sch->id.cu_model = virtio_bus_get_vdev_id(&dev->bus);",
"css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid,\nVAR_0->hotplugged, 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
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29,
31,
33
],
[
35
],
[
37
],
[
39
],
[
41,
43,
45
],
[
47
],
[
49
],
[
53
],
[
59,
61
],
[
63
]
] |
24,605 | HELPER_LD(lbu, ldub, uint8_t)
HELPER_LD(lhu, lduw, uint16_t)
HELPER_LD(lw, ldl, int32_t)
HELPER_LD(ld, ldq, int64_t)
#undef HELPER_LD
#if defined(CONFIG_USER_ONLY)
#define HELPER_ST(name, insn, type) \
static inline void do_##name(CPUMIPSState *env, target_ulong addr, \
type val, int mem_idx) \
{ \
cpu_##insn##_data(env, addr, val); \
}
#else
#define HELPER_ST(name, insn, type) \
static inline void do_##name(CPUMIPSState *env, target_ulong addr, \
type val, int mem_idx) \
{ \
switch (mem_idx) \
{ \
case 0: cpu_##insn##_kernel(env, addr, val); break; \
case 1: cpu_##insn##_super(env, addr, val); break; \
default: \
case 2: cpu_##insn##_user(env, addr, val); break; \
} \
}
#endif
HELPER_ST(sb, stb, uint8_t)
HELPER_ST(sh, stw, uint16_t)
HELPER_ST(sw, stl, uint32_t)
HELPER_ST(sd, stq, uint64_t)
#undef HELPER_ST
target_ulong helper_clo (target_ulong arg1)
{
return clo32(arg1);
}
| false | qemu | adc370a48fd26b92188fa4848dfb088578b1936c | HELPER_LD(lbu, ldub, uint8_t)
HELPER_LD(lhu, lduw, uint16_t)
HELPER_LD(lw, ldl, int32_t)
HELPER_LD(ld, ldq, int64_t)
#undef HELPER_LD
#if defined(CONFIG_USER_ONLY)
#define HELPER_ST(name, insn, type) \
static inline void do_##name(CPUMIPSState *env, target_ulong addr, \
type val, int mem_idx) \
{ \
cpu_##insn##_data(env, addr, val); \
}
#else
#define HELPER_ST(name, insn, type) \
static inline void do_##name(CPUMIPSState *env, target_ulong addr, \
type val, int mem_idx) \
{ \
switch (mem_idx) \
{ \
case 0: cpu_##insn##_kernel(env, addr, val); break; \
case 1: cpu_##insn##_super(env, addr, val); break; \
default: \
case 2: cpu_##insn##_user(env, addr, val); break; \
} \
}
#endif
HELPER_ST(sb, stb, uint8_t)
HELPER_ST(sh, stw, uint16_t)
HELPER_ST(sw, stl, uint32_t)
HELPER_ST(sd, stq, uint64_t)
#undef HELPER_ST
target_ulong helper_clo (target_ulong arg1)
{
return clo32(arg1);
}
| {
"code": [],
"line_no": []
} | HELPER_LD(lbu, ldub, uint8_t)
HELPER_LD(lhu, lduw, uint16_t)
HELPER_LD(lw, ldl, int32_t)
HELPER_LD(ld, ldq, int64_t)
#undef HELPER_LD
#if defined(CONFIG_USER_ONLY)
#define HELPER_ST(name, insn, type) \
static inline void do_##name(CPUMIPSState *env, target_ulong addr, \
type val, int mem_idx) \
{ \
cpu_##insn##_data(env, addr, val); \
}
#else
#define HELPER_ST(name, insn, type) \
static inline void do_##name(CPUMIPSState *env, target_ulong addr, \
type val, int mem_idx) \
{ \
switch (mem_idx) \
{ \
case 0: cpu_##insn##_kernel(env, addr, val); break; \
case 1: cpu_##insn##_super(env, addr, val); break; \
default: \
case 2: cpu_##insn##_user(env, addr, val); break; \
} \
}
#endif
HELPER_ST(sb, stb, uint8_t)
HELPER_ST(sh, stw, uint16_t)
HELPER_ST(sw, stl, uint32_t)
HELPER_ST(sd, stq, uint64_t)
#undef HELPER_ST
target_ulong helper_clo (target_ulong arg1)
{
return clo32(arg1);
}
| [
"HELPER_LD(lbu, ldub, uint8_t)\nHELPER_LD(lhu, lduw, uint16_t)\nHELPER_LD(lw, ldl, int32_t)\nHELPER_LD(ld, ldq, int64_t)\n#undef HELPER_LD\n#if defined(CONFIG_USER_ONLY)\n#define HELPER_ST(name, insn, type) \\\nstatic inline void do_##name(CPUMIPSState *env, target_ulong addr, \\\ntype val, int mem_idx) \\\n{ \\",
"cpu_##insn##_data(env, addr, val); \\",
"}",
"#else\n#define HELPER_ST(name, insn, type) \\\nstatic inline void do_##name(CPUMIPSState *env, target_ulong addr, \\\ntype val, int mem_idx) \\\n{ \\",
"switch (mem_idx) \\\n{ \\",
"case 0: cpu_##insn##_kernel(env, addr, val); break; \\",
"case 1: cpu_##insn##_super(env, addr, val); break; \\",
"default: \\\ncase 2: cpu_##insn##_user(env, addr, val); break; \\",
"} \\",
"}",
"#endif\nHELPER_ST(sb, stb, uint8_t)\nHELPER_ST(sh, stw, uint16_t)\nHELPER_ST(sw, stl, uint32_t)\nHELPER_ST(sd, stq, uint64_t)\n#undef HELPER_ST\ntarget_ulong helper_clo (target_ulong arg1)\n{",
"return clo32(arg1);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
13,
15,
17,
19,
21
],
[
23
],
[
25
],
[
27,
29,
31,
33,
35
],
[
37,
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53,
55,
57,
59,
61,
63,
67,
69
],
[
71
],
[
73
]
] |
24,607 | static void do_video_out(AVFormatContext *s,
OutputStream *ost,
InputStream *ist,
AVFrame *in_picture,
int *frame_size, float quality)
{
int nb_frames, i, ret, format_video_sync;
AVFrame *final_picture;
AVCodecContext *enc;
double sync_ipts;
enc = ost->st->codec;
sync_ipts = get_sync_ipts(ost) / av_q2d(enc->time_base);
/* by default, we output a single frame */
nb_frames = 1;
*frame_size = 0;
format_video_sync = video_sync_method;
if (format_video_sync < 0)
format_video_sync = (s->oformat->flags & AVFMT_NOTIMESTAMPS) ? 0 :
(s->oformat->flags & AVFMT_VARIABLE_FPS) ? 2 : 1;
if (format_video_sync) {
double vdelta = sync_ipts - ost->sync_opts;
//FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c
if (vdelta < -1.1)
nb_frames = 0;
else if (format_video_sync == 2) {
if(vdelta<=-0.6){
nb_frames=0;
}else if(vdelta>0.6)
ost->sync_opts= lrintf(sync_ipts);
}else if (vdelta > 1.1)
nb_frames = lrintf(vdelta);
//fprintf(stderr, "vdelta:%f, ost->sync_opts:%"PRId64", ost->sync_ipts:%f nb_frames:%d\n", vdelta, ost->sync_opts, get_sync_ipts(ost), nb_frames);
if (nb_frames == 0){
++nb_frames_drop;
av_log(NULL, AV_LOG_VERBOSE, "*** drop!\n");
}else if (nb_frames > 1) {
nb_frames_dup += nb_frames - 1;
av_log(NULL, AV_LOG_VERBOSE, "*** %d dup!\n", nb_frames-1);
}
}else
ost->sync_opts= lrintf(sync_ipts);
nb_frames = FFMIN(nb_frames, ost->max_frames - ost->frame_number);
if (nb_frames <= 0)
return;
do_video_resample(ost, ist, in_picture, &final_picture);
/* duplicates frame if needed */
for(i=0;i<nb_frames;i++) {
AVPacket pkt;
av_init_packet(&pkt);
pkt.stream_index= ost->index;
if (s->oformat->flags & AVFMT_RAWPICTURE) {
/* raw pictures are written as AVPicture structure to
avoid any copies. We support temporarily the older
method. */
enc->coded_frame->interlaced_frame = in_picture->interlaced_frame;
enc->coded_frame->top_field_first = in_picture->top_field_first;
pkt.data= (uint8_t *)final_picture;
pkt.size= sizeof(AVPicture);
pkt.pts= av_rescale_q(ost->sync_opts, enc->time_base, ost->st->time_base);
pkt.flags |= AV_PKT_FLAG_KEY;
write_frame(s, &pkt, ost->st->codec, ost->bitstream_filters);
} else {
AVFrame big_picture;
big_picture= *final_picture;
/* better than nothing: use input picture interlaced
settings */
big_picture.interlaced_frame = in_picture->interlaced_frame;
if (ost->st->codec->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME)) {
if (ost->top_field_first == -1)
big_picture.top_field_first = in_picture->top_field_first;
else
big_picture.top_field_first = !!ost->top_field_first;
}
/* handles same_quant here. This is not correct because it may
not be a global option */
big_picture.quality = quality;
if (!enc->me_threshold)
big_picture.pict_type = 0;
// big_picture.pts = AV_NOPTS_VALUE;
big_picture.pts= ost->sync_opts;
// big_picture.pts= av_rescale(ost->sync_opts, AV_TIME_BASE*(int64_t)enc->time_base.num, enc->time_base.den);
//av_log(NULL, AV_LOG_DEBUG, "%"PRId64" -> encoder\n", ost->sync_opts);
if (ost->forced_kf_index < ost->forced_kf_count &&
big_picture.pts >= ost->forced_kf_pts[ost->forced_kf_index]) {
big_picture.pict_type = AV_PICTURE_TYPE_I;
ost->forced_kf_index++;
}
ret = avcodec_encode_video(enc,
bit_buffer, bit_buffer_size,
&big_picture);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "Video encoding failed\n");
exit_program(1);
}
if(ret>0){
pkt.data= bit_buffer;
pkt.size= ret;
if(enc->coded_frame->pts != AV_NOPTS_VALUE)
pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
/*av_log(NULL, AV_LOG_DEBUG, "encoder -> %"PRId64"/%"PRId64"\n",
pkt.pts != AV_NOPTS_VALUE ? av_rescale(pkt.pts, enc->time_base.den, AV_TIME_BASE*(int64_t)enc->time_base.num) : -1,
pkt.dts != AV_NOPTS_VALUE ? av_rescale(pkt.dts, enc->time_base.den, AV_TIME_BASE*(int64_t)enc->time_base.num) : -1);*/
if(enc->coded_frame->key_frame)
pkt.flags |= AV_PKT_FLAG_KEY;
write_frame(s, &pkt, ost->st->codec, ost->bitstream_filters);
*frame_size = ret;
video_size += ret;
//fprintf(stderr,"\nFrame: %3d size: %5d type: %d",
// enc->frame_number-1, ret, enc->pict_type);
/* if two pass, output log */
if (ost->logfile && enc->stats_out) {
fprintf(ost->logfile, "%s", enc->stats_out);
}
}
}
ost->sync_opts++;
ost->frame_number++;
}
}
| false | FFmpeg | 150ddbc1482c65b9aac803f011d7fcd734f776ec | static void do_video_out(AVFormatContext *s,
OutputStream *ost,
InputStream *ist,
AVFrame *in_picture,
int *frame_size, float quality)
{
int nb_frames, i, ret, format_video_sync;
AVFrame *final_picture;
AVCodecContext *enc;
double sync_ipts;
enc = ost->st->codec;
sync_ipts = get_sync_ipts(ost) / av_q2d(enc->time_base);
nb_frames = 1;
*frame_size = 0;
format_video_sync = video_sync_method;
if (format_video_sync < 0)
format_video_sync = (s->oformat->flags & AVFMT_NOTIMESTAMPS) ? 0 :
(s->oformat->flags & AVFMT_VARIABLE_FPS) ? 2 : 1;
if (format_video_sync) {
double vdelta = sync_ipts - ost->sync_opts;
if (vdelta < -1.1)
nb_frames = 0;
else if (format_video_sync == 2) {
if(vdelta<=-0.6){
nb_frames=0;
}else if(vdelta>0.6)
ost->sync_opts= lrintf(sync_ipts);
}else if (vdelta > 1.1)
nb_frames = lrintf(vdelta);
if (nb_frames == 0){
++nb_frames_drop;
av_log(NULL, AV_LOG_VERBOSE, "*** drop!\n");
}else if (nb_frames > 1) {
nb_frames_dup += nb_frames - 1;
av_log(NULL, AV_LOG_VERBOSE, "*** %d dup!\n", nb_frames-1);
}
}else
ost->sync_opts= lrintf(sync_ipts);
nb_frames = FFMIN(nb_frames, ost->max_frames - ost->frame_number);
if (nb_frames <= 0)
return;
do_video_resample(ost, ist, in_picture, &final_picture);
for(i=0;i<nb_frames;i++) {
AVPacket pkt;
av_init_packet(&pkt);
pkt.stream_index= ost->index;
if (s->oformat->flags & AVFMT_RAWPICTURE) {
enc->coded_frame->interlaced_frame = in_picture->interlaced_frame;
enc->coded_frame->top_field_first = in_picture->top_field_first;
pkt.data= (uint8_t *)final_picture;
pkt.size= sizeof(AVPicture);
pkt.pts= av_rescale_q(ost->sync_opts, enc->time_base, ost->st->time_base);
pkt.flags |= AV_PKT_FLAG_KEY;
write_frame(s, &pkt, ost->st->codec, ost->bitstream_filters);
} else {
AVFrame big_picture;
big_picture= *final_picture;
big_picture.interlaced_frame = in_picture->interlaced_frame;
if (ost->st->codec->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME)) {
if (ost->top_field_first == -1)
big_picture.top_field_first = in_picture->top_field_first;
else
big_picture.top_field_first = !!ost->top_field_first;
}
big_picture.quality = quality;
if (!enc->me_threshold)
big_picture.pict_type = 0;
big_picture.pts= ost->sync_opts;
if (ost->forced_kf_index < ost->forced_kf_count &&
big_picture.pts >= ost->forced_kf_pts[ost->forced_kf_index]) {
big_picture.pict_type = AV_PICTURE_TYPE_I;
ost->forced_kf_index++;
}
ret = avcodec_encode_video(enc,
bit_buffer, bit_buffer_size,
&big_picture);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "Video encoding failed\n");
exit_program(1);
}
if(ret>0){
pkt.data= bit_buffer;
pkt.size= ret;
if(enc->coded_frame->pts != AV_NOPTS_VALUE)
pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
if(enc->coded_frame->key_frame)
pkt.flags |= AV_PKT_FLAG_KEY;
write_frame(s, &pkt, ost->st->codec, ost->bitstream_filters);
*frame_size = ret;
video_size += ret;
if (ost->logfile && enc->stats_out) {
fprintf(ost->logfile, "%s", enc->stats_out);
}
}
}
ost->sync_opts++;
ost->frame_number++;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVFormatContext *VAR_0,
OutputStream *VAR_1,
InputStream *VAR_2,
AVFrame *VAR_3,
int *VAR_4, float VAR_5)
{
int VAR_6, VAR_7, VAR_8, VAR_9;
AVFrame *final_picture;
AVCodecContext *enc;
double VAR_10;
enc = VAR_1->st->codec;
VAR_10 = get_sync_ipts(VAR_1) / av_q2d(enc->time_base);
VAR_6 = 1;
*VAR_4 = 0;
VAR_9 = video_sync_method;
if (VAR_9 < 0)
VAR_9 = (VAR_0->oformat->flags & AVFMT_NOTIMESTAMPS) ? 0 :
(VAR_0->oformat->flags & AVFMT_VARIABLE_FPS) ? 2 : 1;
if (VAR_9) {
double VAR_11 = VAR_10 - VAR_1->sync_opts;
if (VAR_11 < -1.1)
VAR_6 = 0;
else if (VAR_9 == 2) {
if(VAR_11<=-0.6){
VAR_6=0;
}else if(VAR_11>0.6)
VAR_1->sync_opts= lrintf(VAR_10);
}else if (VAR_11 > 1.1)
VAR_6 = lrintf(VAR_11);
if (VAR_6 == 0){
++nb_frames_drop;
av_log(NULL, AV_LOG_VERBOSE, "*** drop!\n");
}else if (VAR_6 > 1) {
nb_frames_dup += VAR_6 - 1;
av_log(NULL, AV_LOG_VERBOSE, "*** %d dup!\n", VAR_6-1);
}
}else
VAR_1->sync_opts= lrintf(VAR_10);
VAR_6 = FFMIN(VAR_6, VAR_1->max_frames - VAR_1->frame_number);
if (VAR_6 <= 0)
return;
do_video_resample(VAR_1, VAR_2, VAR_3, &final_picture);
for(VAR_7=0;VAR_7<VAR_6;VAR_7++) {
AVPacket pkt;
av_init_packet(&pkt);
pkt.stream_index= VAR_1->index;
if (VAR_0->oformat->flags & AVFMT_RAWPICTURE) {
enc->coded_frame->interlaced_frame = VAR_3->interlaced_frame;
enc->coded_frame->top_field_first = VAR_3->top_field_first;
pkt.data= (uint8_t *)final_picture;
pkt.size= sizeof(AVPicture);
pkt.pts= av_rescale_q(VAR_1->sync_opts, enc->time_base, VAR_1->st->time_base);
pkt.flags |= AV_PKT_FLAG_KEY;
write_frame(VAR_0, &pkt, VAR_1->st->codec, VAR_1->bitstream_filters);
} else {
AVFrame big_picture;
big_picture= *final_picture;
big_picture.interlaced_frame = VAR_3->interlaced_frame;
if (VAR_1->st->codec->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME)) {
if (VAR_1->top_field_first == -1)
big_picture.top_field_first = VAR_3->top_field_first;
else
big_picture.top_field_first = !!VAR_1->top_field_first;
}
big_picture.VAR_5 = VAR_5;
if (!enc->me_threshold)
big_picture.pict_type = 0;
big_picture.pts= VAR_1->sync_opts;
if (VAR_1->forced_kf_index < VAR_1->forced_kf_count &&
big_picture.pts >= VAR_1->forced_kf_pts[VAR_1->forced_kf_index]) {
big_picture.pict_type = AV_PICTURE_TYPE_I;
VAR_1->forced_kf_index++;
}
VAR_8 = avcodec_encode_video(enc,
bit_buffer, bit_buffer_size,
&big_picture);
if (VAR_8 < 0) {
av_log(NULL, AV_LOG_FATAL, "Video encoding failed\n");
exit_program(1);
}
if(VAR_8>0){
pkt.data= bit_buffer;
pkt.size= VAR_8;
if(enc->coded_frame->pts != AV_NOPTS_VALUE)
pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, VAR_1->st->time_base);
if(enc->coded_frame->key_frame)
pkt.flags |= AV_PKT_FLAG_KEY;
write_frame(VAR_0, &pkt, VAR_1->st->codec, VAR_1->bitstream_filters);
*VAR_4 = VAR_8;
video_size += VAR_8;
if (VAR_1->logfile && enc->stats_out) {
fprintf(VAR_1->logfile, "%VAR_0", enc->stats_out);
}
}
}
VAR_1->sync_opts++;
VAR_1->frame_number++;
}
}
| [
"static void FUNC_0(AVFormatContext *VAR_0,\nOutputStream *VAR_1,\nInputStream *VAR_2,\nAVFrame *VAR_3,\nint *VAR_4, float VAR_5)\n{",
"int VAR_6, VAR_7, VAR_8, VAR_9;",
"AVFrame *final_picture;",
"AVCodecContext *enc;",
"double VAR_10;",
"enc = VAR_1->st->codec;",
"VAR_10 = get_sync_ipts(VAR_1) / av_q2d(enc->time_base);",
"VAR_6 = 1;",
"*VAR_4 = 0;",
"VAR_9 = video_sync_method;",
"if (VAR_9 < 0)\nVAR_9 = (VAR_0->oformat->flags & AVFMT_NOTIMESTAMPS) ? 0 :\n(VAR_0->oformat->flags & AVFMT_VARIABLE_FPS) ? 2 : 1;",
"if (VAR_9) {",
"double VAR_11 = VAR_10 - VAR_1->sync_opts;",
"if (VAR_11 < -1.1)\nVAR_6 = 0;",
"else if (VAR_9 == 2) {",
"if(VAR_11<=-0.6){",
"VAR_6=0;",
"}else if(VAR_11>0.6)",
"VAR_1->sync_opts= lrintf(VAR_10);",
"}else if (VAR_11 > 1.1)",
"VAR_6 = lrintf(VAR_11);",
"if (VAR_6 == 0){",
"++nb_frames_drop;",
"av_log(NULL, AV_LOG_VERBOSE, \"*** drop!\\n\");",
"}else if (VAR_6 > 1) {",
"nb_frames_dup += VAR_6 - 1;",
"av_log(NULL, AV_LOG_VERBOSE, \"*** %d dup!\\n\", VAR_6-1);",
"}",
"}else",
"VAR_1->sync_opts= lrintf(VAR_10);",
"VAR_6 = FFMIN(VAR_6, VAR_1->max_frames - VAR_1->frame_number);",
"if (VAR_6 <= 0)\nreturn;",
"do_video_resample(VAR_1, VAR_2, VAR_3, &final_picture);",
"for(VAR_7=0;VAR_7<VAR_6;VAR_7++) {",
"AVPacket pkt;",
"av_init_packet(&pkt);",
"pkt.stream_index= VAR_1->index;",
"if (VAR_0->oformat->flags & AVFMT_RAWPICTURE) {",
"enc->coded_frame->interlaced_frame = VAR_3->interlaced_frame;",
"enc->coded_frame->top_field_first = VAR_3->top_field_first;",
"pkt.data= (uint8_t *)final_picture;",
"pkt.size= sizeof(AVPicture);",
"pkt.pts= av_rescale_q(VAR_1->sync_opts, enc->time_base, VAR_1->st->time_base);",
"pkt.flags |= AV_PKT_FLAG_KEY;",
"write_frame(VAR_0, &pkt, VAR_1->st->codec, VAR_1->bitstream_filters);",
"} else {",
"AVFrame big_picture;",
"big_picture= *final_picture;",
"big_picture.interlaced_frame = VAR_3->interlaced_frame;",
"if (VAR_1->st->codec->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME)) {",
"if (VAR_1->top_field_first == -1)\nbig_picture.top_field_first = VAR_3->top_field_first;",
"else\nbig_picture.top_field_first = !!VAR_1->top_field_first;",
"}",
"big_picture.VAR_5 = VAR_5;",
"if (!enc->me_threshold)\nbig_picture.pict_type = 0;",
"big_picture.pts= VAR_1->sync_opts;",
"if (VAR_1->forced_kf_index < VAR_1->forced_kf_count &&\nbig_picture.pts >= VAR_1->forced_kf_pts[VAR_1->forced_kf_index]) {",
"big_picture.pict_type = AV_PICTURE_TYPE_I;",
"VAR_1->forced_kf_index++;",
"}",
"VAR_8 = avcodec_encode_video(enc,\nbit_buffer, bit_buffer_size,\n&big_picture);",
"if (VAR_8 < 0) {",
"av_log(NULL, AV_LOG_FATAL, \"Video encoding failed\\n\");",
"exit_program(1);",
"}",
"if(VAR_8>0){",
"pkt.data= bit_buffer;",
"pkt.size= VAR_8;",
"if(enc->coded_frame->pts != AV_NOPTS_VALUE)\npkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, VAR_1->st->time_base);",
"if(enc->coded_frame->key_frame)\npkt.flags |= AV_PKT_FLAG_KEY;",
"write_frame(VAR_0, &pkt, VAR_1->st->codec, VAR_1->bitstream_filters);",
"*VAR_4 = VAR_8;",
"video_size += VAR_8;",
"if (VAR_1->logfile && enc->stats_out) {",
"fprintf(VAR_1->logfile, \"%VAR_0\", enc->stats_out);",
"}",
"}",
"}",
"VAR_1->sync_opts++;",
"VAR_1->frame_number++;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
27
],
[
33
],
[
37
],
[
41
],
[
43,
45,
47
],
[
51
],
[
53
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99,
101
],
[
105
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
151
],
[
157
],
[
159
],
[
161,
163
],
[
165,
167
],
[
169
],
[
177
],
[
179,
181
],
[
185
],
[
191,
193
],
[
195
],
[
197
],
[
199
],
[
201,
203,
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
217
],
[
219
],
[
221
],
[
223,
225
],
[
235,
237
],
[
239
],
[
241
],
[
243
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
]
] |
24,608 | static void vc1_decode_i_blocks_adv(VC1Context *v)
{
int k, j;
MpegEncContext *s = &v->s;
int cbp, val;
uint8_t *coded_val;
int mb_pos;
int mquant = v->pq;
int mqdiff;
int overlap;
GetBitContext *gb = &s->gb;
/* select codingmode used for VLC tables selection */
switch(v->y_ac_table_index){
case 0:
v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA;
break;
case 1:
v->codingset = CS_HIGH_MOT_INTRA;
break;
case 2:
v->codingset = CS_MID_RATE_INTRA;
break;
}
switch(v->c_ac_table_index){
case 0:
v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER;
break;
case 1:
v->codingset2 = CS_HIGH_MOT_INTER;
break;
case 2:
v->codingset2 = CS_MID_RATE_INTER;
break;
}
/* Set DC scale - y and c use the same */
s->y_dc_scale = s->y_dc_scale_table[v->pq];
s->c_dc_scale = s->c_dc_scale_table[v->pq];
//do frame decode
s->mb_x = s->mb_y = 0;
s->mb_intra = 1;
s->first_slice_line = 1;
ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, (AC_END|DC_END|MV_END));
for(s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) {
for(s->mb_x = 0; s->mb_x < s->mb_width; s->mb_x++) {
ff_init_block_index(s);
ff_update_block_index(s);
s->dsp.clear_blocks(s->block[0]);
mb_pos = s->mb_x + s->mb_y * s->mb_stride;
s->current_picture.mb_type[mb_pos] = MB_TYPE_INTRA;
s->current_picture.motion_val[1][s->block_index[0]][0] = 0;
s->current_picture.motion_val[1][s->block_index[0]][1] = 0;
// do actual MB decoding and displaying
cbp = get_vlc2(&v->s.gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);
if(v->acpred_is_raw)
v->s.ac_pred = get_bits(&v->s.gb, 1);
else
v->s.ac_pred = v->acpred_plane[mb_pos];
if(v->condover == CONDOVER_SELECT) {
if(v->overflg_is_raw)
overlap = get_bits(&v->s.gb, 1);
else
overlap = v->over_flags_plane[mb_pos];
} else
overlap = (v->condover == CONDOVER_ALL);
GET_MQUANT();
s->current_picture.qscale_table[mb_pos] = mquant;
for(k = 0; k < 6; k++) {
val = ((cbp >> (5 - k)) & 1);
if (k < 4) {
int pred = vc1_coded_block_pred(&v->s, k, &coded_val);
val = val ^ pred;
*coded_val = val;
}
cbp |= val << (5 - k);
v->a_avail = !s->first_slice_line || (k==2 || k==3);
v->c_avail = !!s->mb_x || (k==1 || k==3);
vc1_decode_i_block_adv(v, s->block[k], k, val, (k<4)? v->codingset : v->codingset2, mquant);
s->dsp.vc1_inv_trans_8x8(s->block[k]);
for(j = 0; j < 64; j++) s->block[k][j] += 128;
}
vc1_put_block(v, s->block);
if(overlap) {
if(s->mb_x) {
s->dsp.vc1_h_overlap(s->dest[0], s->linesize, 0);
s->dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize, s->linesize, 0);
if(!(s->flags & CODEC_FLAG_GRAY)) {
s->dsp.vc1_h_overlap(s->dest[1], s->uvlinesize, s->mb_x&1);
s->dsp.vc1_h_overlap(s->dest[2], s->uvlinesize, s->mb_x&1);
}
}
s->dsp.vc1_h_overlap(s->dest[0] + 8, s->linesize, 1);
s->dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize, 1);
if(!s->first_slice_line) {
s->dsp.vc1_v_overlap(s->dest[0], s->linesize, 0);
s->dsp.vc1_v_overlap(s->dest[0] + 8, s->linesize, 0);
if(!(s->flags & CODEC_FLAG_GRAY)) {
s->dsp.vc1_v_overlap(s->dest[1], s->uvlinesize, s->mb_y&1);
s->dsp.vc1_v_overlap(s->dest[2], s->uvlinesize, s->mb_y&1);
}
}
s->dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize, s->linesize, 1);
s->dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize, 1);
}
if(get_bits_count(&s->gb) > v->bits) {
av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i\n", get_bits_count(&s->gb), v->bits);
return;
}
}
ff_draw_horiz_band(s, s->mb_y * 16, 16);
s->first_slice_line = 0;
}
}
| false | FFmpeg | b8ce8f15a036780bd5ee655bcac881a8cd62f85a | static void vc1_decode_i_blocks_adv(VC1Context *v)
{
int k, j;
MpegEncContext *s = &v->s;
int cbp, val;
uint8_t *coded_val;
int mb_pos;
int mquant = v->pq;
int mqdiff;
int overlap;
GetBitContext *gb = &s->gb;
switch(v->y_ac_table_index){
case 0:
v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA;
break;
case 1:
v->codingset = CS_HIGH_MOT_INTRA;
break;
case 2:
v->codingset = CS_MID_RATE_INTRA;
break;
}
switch(v->c_ac_table_index){
case 0:
v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER;
break;
case 1:
v->codingset2 = CS_HIGH_MOT_INTER;
break;
case 2:
v->codingset2 = CS_MID_RATE_INTER;
break;
}
s->y_dc_scale = s->y_dc_scale_table[v->pq];
s->c_dc_scale = s->c_dc_scale_table[v->pq];
s->mb_x = s->mb_y = 0;
s->mb_intra = 1;
s->first_slice_line = 1;
ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, (AC_END|DC_END|MV_END));
for(s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) {
for(s->mb_x = 0; s->mb_x < s->mb_width; s->mb_x++) {
ff_init_block_index(s);
ff_update_block_index(s);
s->dsp.clear_blocks(s->block[0]);
mb_pos = s->mb_x + s->mb_y * s->mb_stride;
s->current_picture.mb_type[mb_pos] = MB_TYPE_INTRA;
s->current_picture.motion_val[1][s->block_index[0]][0] = 0;
s->current_picture.motion_val[1][s->block_index[0]][1] = 0;
cbp = get_vlc2(&v->s.gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);
if(v->acpred_is_raw)
v->s.ac_pred = get_bits(&v->s.gb, 1);
else
v->s.ac_pred = v->acpred_plane[mb_pos];
if(v->condover == CONDOVER_SELECT) {
if(v->overflg_is_raw)
overlap = get_bits(&v->s.gb, 1);
else
overlap = v->over_flags_plane[mb_pos];
} else
overlap = (v->condover == CONDOVER_ALL);
GET_MQUANT();
s->current_picture.qscale_table[mb_pos] = mquant;
for(k = 0; k < 6; k++) {
val = ((cbp >> (5 - k)) & 1);
if (k < 4) {
int pred = vc1_coded_block_pred(&v->s, k, &coded_val);
val = val ^ pred;
*coded_val = val;
}
cbp |= val << (5 - k);
v->a_avail = !s->first_slice_line || (k==2 || k==3);
v->c_avail = !!s->mb_x || (k==1 || k==3);
vc1_decode_i_block_adv(v, s->block[k], k, val, (k<4)? v->codingset : v->codingset2, mquant);
s->dsp.vc1_inv_trans_8x8(s->block[k]);
for(j = 0; j < 64; j++) s->block[k][j] += 128;
}
vc1_put_block(v, s->block);
if(overlap) {
if(s->mb_x) {
s->dsp.vc1_h_overlap(s->dest[0], s->linesize, 0);
s->dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize, s->linesize, 0);
if(!(s->flags & CODEC_FLAG_GRAY)) {
s->dsp.vc1_h_overlap(s->dest[1], s->uvlinesize, s->mb_x&1);
s->dsp.vc1_h_overlap(s->dest[2], s->uvlinesize, s->mb_x&1);
}
}
s->dsp.vc1_h_overlap(s->dest[0] + 8, s->linesize, 1);
s->dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize, 1);
if(!s->first_slice_line) {
s->dsp.vc1_v_overlap(s->dest[0], s->linesize, 0);
s->dsp.vc1_v_overlap(s->dest[0] + 8, s->linesize, 0);
if(!(s->flags & CODEC_FLAG_GRAY)) {
s->dsp.vc1_v_overlap(s->dest[1], s->uvlinesize, s->mb_y&1);
s->dsp.vc1_v_overlap(s->dest[2], s->uvlinesize, s->mb_y&1);
}
}
s->dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize, s->linesize, 1);
s->dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize, 1);
}
if(get_bits_count(&s->gb) > v->bits) {
av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i\n", get_bits_count(&s->gb), v->bits);
return;
}
}
ff_draw_horiz_band(s, s->mb_y * 16, 16);
s->first_slice_line = 0;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(VC1Context *VAR_0)
{
int VAR_1, VAR_2;
MpegEncContext *s = &VAR_0->s;
int VAR_3, VAR_4;
uint8_t *coded_val;
int VAR_5;
int VAR_6 = VAR_0->pq;
int VAR_7;
int VAR_8;
GetBitContext *gb = &s->gb;
switch(VAR_0->y_ac_table_index){
case 0:
VAR_0->codingset = (VAR_0->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA;
break;
case 1:
VAR_0->codingset = CS_HIGH_MOT_INTRA;
break;
case 2:
VAR_0->codingset = CS_MID_RATE_INTRA;
break;
}
switch(VAR_0->c_ac_table_index){
case 0:
VAR_0->codingset2 = (VAR_0->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER;
break;
case 1:
VAR_0->codingset2 = CS_HIGH_MOT_INTER;
break;
case 2:
VAR_0->codingset2 = CS_MID_RATE_INTER;
break;
}
s->y_dc_scale = s->y_dc_scale_table[VAR_0->pq];
s->c_dc_scale = s->c_dc_scale_table[VAR_0->pq];
s->mb_x = s->mb_y = 0;
s->mb_intra = 1;
s->first_slice_line = 1;
ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, (AC_END|DC_END|MV_END));
for(s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) {
for(s->mb_x = 0; s->mb_x < s->mb_width; s->mb_x++) {
ff_init_block_index(s);
ff_update_block_index(s);
s->dsp.clear_blocks(s->block[0]);
VAR_5 = s->mb_x + s->mb_y * s->mb_stride;
s->current_picture.mb_type[VAR_5] = MB_TYPE_INTRA;
s->current_picture.motion_val[1][s->block_index[0]][0] = 0;
s->current_picture.motion_val[1][s->block_index[0]][1] = 0;
VAR_3 = get_vlc2(&VAR_0->s.gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);
if(VAR_0->acpred_is_raw)
VAR_0->s.ac_pred = get_bits(&VAR_0->s.gb, 1);
else
VAR_0->s.ac_pred = VAR_0->acpred_plane[VAR_5];
if(VAR_0->condover == CONDOVER_SELECT) {
if(VAR_0->overflg_is_raw)
VAR_8 = get_bits(&VAR_0->s.gb, 1);
else
VAR_8 = VAR_0->over_flags_plane[VAR_5];
} else
VAR_8 = (VAR_0->condover == CONDOVER_ALL);
GET_MQUANT();
s->current_picture.qscale_table[VAR_5] = VAR_6;
for(VAR_1 = 0; VAR_1 < 6; VAR_1++) {
VAR_4 = ((VAR_3 >> (5 - VAR_1)) & 1);
if (VAR_1 < 4) {
int pred = vc1_coded_block_pred(&VAR_0->s, VAR_1, &coded_val);
VAR_4 = VAR_4 ^ pred;
*coded_val = VAR_4;
}
VAR_3 |= VAR_4 << (5 - VAR_1);
VAR_0->a_avail = !s->first_slice_line || (VAR_1==2 || VAR_1==3);
VAR_0->c_avail = !!s->mb_x || (VAR_1==1 || VAR_1==3);
vc1_decode_i_block_adv(VAR_0, s->block[VAR_1], VAR_1, VAR_4, (VAR_1<4)? VAR_0->codingset : VAR_0->codingset2, VAR_6);
s->dsp.vc1_inv_trans_8x8(s->block[VAR_1]);
for(VAR_2 = 0; VAR_2 < 64; VAR_2++) s->block[VAR_1][VAR_2] += 128;
}
vc1_put_block(VAR_0, s->block);
if(VAR_8) {
if(s->mb_x) {
s->dsp.vc1_h_overlap(s->dest[0], s->linesize, 0);
s->dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize, s->linesize, 0);
if(!(s->flags & CODEC_FLAG_GRAY)) {
s->dsp.vc1_h_overlap(s->dest[1], s->uvlinesize, s->mb_x&1);
s->dsp.vc1_h_overlap(s->dest[2], s->uvlinesize, s->mb_x&1);
}
}
s->dsp.vc1_h_overlap(s->dest[0] + 8, s->linesize, 1);
s->dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize, 1);
if(!s->first_slice_line) {
s->dsp.vc1_v_overlap(s->dest[0], s->linesize, 0);
s->dsp.vc1_v_overlap(s->dest[0] + 8, s->linesize, 0);
if(!(s->flags & CODEC_FLAG_GRAY)) {
s->dsp.vc1_v_overlap(s->dest[1], s->uvlinesize, s->mb_y&1);
s->dsp.vc1_v_overlap(s->dest[2], s->uvlinesize, s->mb_y&1);
}
}
s->dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize, s->linesize, 1);
s->dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize, 1);
}
if(get_bits_count(&s->gb) > VAR_0->bits) {
av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i\n", get_bits_count(&s->gb), VAR_0->bits);
return;
}
}
ff_draw_horiz_band(s, s->mb_y * 16, 16);
s->first_slice_line = 0;
}
}
| [
"static void FUNC_0(VC1Context *VAR_0)\n{",
"int VAR_1, VAR_2;",
"MpegEncContext *s = &VAR_0->s;",
"int VAR_3, VAR_4;",
"uint8_t *coded_val;",
"int VAR_5;",
"int VAR_6 = VAR_0->pq;",
"int VAR_7;",
"int VAR_8;",
"GetBitContext *gb = &s->gb;",
"switch(VAR_0->y_ac_table_index){",
"case 0:\nVAR_0->codingset = (VAR_0->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA;",
"break;",
"case 1:\nVAR_0->codingset = CS_HIGH_MOT_INTRA;",
"break;",
"case 2:\nVAR_0->codingset = CS_MID_RATE_INTRA;",
"break;",
"}",
"switch(VAR_0->c_ac_table_index){",
"case 0:\nVAR_0->codingset2 = (VAR_0->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER;",
"break;",
"case 1:\nVAR_0->codingset2 = CS_HIGH_MOT_INTER;",
"break;",
"case 2:\nVAR_0->codingset2 = CS_MID_RATE_INTER;",
"break;",
"}",
"s->y_dc_scale = s->y_dc_scale_table[VAR_0->pq];",
"s->c_dc_scale = s->c_dc_scale_table[VAR_0->pq];",
"s->mb_x = s->mb_y = 0;",
"s->mb_intra = 1;",
"s->first_slice_line = 1;",
"ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, (AC_END|DC_END|MV_END));",
"for(s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) {",
"for(s->mb_x = 0; s->mb_x < s->mb_width; s->mb_x++) {",
"ff_init_block_index(s);",
"ff_update_block_index(s);",
"s->dsp.clear_blocks(s->block[0]);",
"VAR_5 = s->mb_x + s->mb_y * s->mb_stride;",
"s->current_picture.mb_type[VAR_5] = MB_TYPE_INTRA;",
"s->current_picture.motion_val[1][s->block_index[0]][0] = 0;",
"s->current_picture.motion_val[1][s->block_index[0]][1] = 0;",
"VAR_3 = get_vlc2(&VAR_0->s.gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);",
"if(VAR_0->acpred_is_raw)\nVAR_0->s.ac_pred = get_bits(&VAR_0->s.gb, 1);",
"else\nVAR_0->s.ac_pred = VAR_0->acpred_plane[VAR_5];",
"if(VAR_0->condover == CONDOVER_SELECT) {",
"if(VAR_0->overflg_is_raw)\nVAR_8 = get_bits(&VAR_0->s.gb, 1);",
"else\nVAR_8 = VAR_0->over_flags_plane[VAR_5];",
"} else",
"VAR_8 = (VAR_0->condover == CONDOVER_ALL);",
"GET_MQUANT();",
"s->current_picture.qscale_table[VAR_5] = VAR_6;",
"for(VAR_1 = 0; VAR_1 < 6; VAR_1++) {",
"VAR_4 = ((VAR_3 >> (5 - VAR_1)) & 1);",
"if (VAR_1 < 4) {",
"int pred = vc1_coded_block_pred(&VAR_0->s, VAR_1, &coded_val);",
"VAR_4 = VAR_4 ^ pred;",
"*coded_val = VAR_4;",
"}",
"VAR_3 |= VAR_4 << (5 - VAR_1);",
"VAR_0->a_avail = !s->first_slice_line || (VAR_1==2 || VAR_1==3);",
"VAR_0->c_avail = !!s->mb_x || (VAR_1==1 || VAR_1==3);",
"vc1_decode_i_block_adv(VAR_0, s->block[VAR_1], VAR_1, VAR_4, (VAR_1<4)? VAR_0->codingset : VAR_0->codingset2, VAR_6);",
"s->dsp.vc1_inv_trans_8x8(s->block[VAR_1]);",
"for(VAR_2 = 0; VAR_2 < 64; VAR_2++) s->block[VAR_1][VAR_2] += 128;",
"}",
"vc1_put_block(VAR_0, s->block);",
"if(VAR_8) {",
"if(s->mb_x) {",
"s->dsp.vc1_h_overlap(s->dest[0], s->linesize, 0);",
"s->dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize, s->linesize, 0);",
"if(!(s->flags & CODEC_FLAG_GRAY)) {",
"s->dsp.vc1_h_overlap(s->dest[1], s->uvlinesize, s->mb_x&1);",
"s->dsp.vc1_h_overlap(s->dest[2], s->uvlinesize, s->mb_x&1);",
"}",
"}",
"s->dsp.vc1_h_overlap(s->dest[0] + 8, s->linesize, 1);",
"s->dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize, 1);",
"if(!s->first_slice_line) {",
"s->dsp.vc1_v_overlap(s->dest[0], s->linesize, 0);",
"s->dsp.vc1_v_overlap(s->dest[0] + 8, s->linesize, 0);",
"if(!(s->flags & CODEC_FLAG_GRAY)) {",
"s->dsp.vc1_v_overlap(s->dest[1], s->uvlinesize, s->mb_y&1);",
"s->dsp.vc1_v_overlap(s->dest[2], s->uvlinesize, s->mb_y&1);",
"}",
"}",
"s->dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize, s->linesize, 1);",
"s->dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize, 1);",
"}",
"if(get_bits_count(&s->gb) > VAR_0->bits) {",
"av_log(s->avctx, AV_LOG_ERROR, \"Bits overconsumption: %i > %i\\n\", get_bits_count(&s->gb), VAR_0->bits);",
"return;",
"}",
"}",
"ff_draw_horiz_band(s, s->mb_y * 16, 16);",
"s->first_slice_line = 0;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
27
],
[
29,
31
],
[
33
],
[
35,
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
51
],
[
53,
55
],
[
57
],
[
59,
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
77
],
[
79
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
115
],
[
117,
119
],
[
121,
123
],
[
127
],
[
129,
131
],
[
133,
135
],
[
137
],
[
139
],
[
143
],
[
147
],
[
151
],
[
153
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
171
],
[
173
],
[
177
],
[
181
],
[
183
],
[
185
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
]
] |
24,609 | static int parse_channel_name(char **arg, int *rchannel, int *rnamed)
{
char buf[8];
int len, i, channel_id = 0;
int64_t layout, layout0;
/* try to parse a channel name, e.g. "FL" */
if (sscanf(*arg, " %7[A-Z] %n", buf, &len)) {
layout0 = layout = av_get_channel_layout(buf);
/* channel_id <- first set bit in layout */
for (i = 32; i > 0; i >>= 1) {
if (layout >= (int64_t)1 << i) {
channel_id += i;
layout >>= i;
}
}
/* reject layouts that are not a single channel */
if (channel_id >= MAX_CHANNELS || layout0 != (int64_t)1 << channel_id)
return AVERROR(EINVAL);
*rchannel = channel_id;
*rnamed = 1;
*arg += len;
return 0;
}
/* try to parse a channel number, e.g. "c2" */
if (sscanf(*arg, " c%d %n", &channel_id, &len) &&
channel_id >= 0 && channel_id < MAX_CHANNELS) {
*rchannel = channel_id;
*rnamed = 0;
*arg += len;
return 0;
}
return AVERROR(EINVAL);
}
| true | FFmpeg | e3a1eb9edf65edda301f3a727f11e0224b9f5ae2 | static int parse_channel_name(char **arg, int *rchannel, int *rnamed)
{
char buf[8];
int len, i, channel_id = 0;
int64_t layout, layout0;
if (sscanf(*arg, " %7[A-Z] %n", buf, &len)) {
layout0 = layout = av_get_channel_layout(buf);
for (i = 32; i > 0; i >>= 1) {
if (layout >= (int64_t)1 << i) {
channel_id += i;
layout >>= i;
}
}
if (channel_id >= MAX_CHANNELS || layout0 != (int64_t)1 << channel_id)
return AVERROR(EINVAL);
*rchannel = channel_id;
*rnamed = 1;
*arg += len;
return 0;
}
if (sscanf(*arg, " c%d %n", &channel_id, &len) &&
channel_id >= 0 && channel_id < MAX_CHANNELS) {
*rchannel = channel_id;
*rnamed = 0;
*arg += len;
return 0;
}
return AVERROR(EINVAL);
}
| {
"code": [
" if (sscanf(*arg, \" %7[A-Z] %n\", buf, &len)) {",
" if (sscanf(*arg, \" c%d %n\", &channel_id, &len) &&"
],
"line_no": [
15,
51
]
} | static int FUNC_0(char **VAR_0, int *VAR_1, int *VAR_2)
{
char VAR_3[8];
int VAR_4, VAR_5, VAR_6 = 0;
int64_t layout, layout0;
if (sscanf(*VAR_0, " %7[A-Z] %n", VAR_3, &VAR_4)) {
layout0 = layout = av_get_channel_layout(VAR_3);
for (VAR_5 = 32; VAR_5 > 0; VAR_5 >>= 1) {
if (layout >= (int64_t)1 << VAR_5) {
VAR_6 += VAR_5;
layout >>= VAR_5;
}
}
if (VAR_6 >= MAX_CHANNELS || layout0 != (int64_t)1 << VAR_6)
return AVERROR(EINVAL);
*VAR_1 = VAR_6;
*VAR_2 = 1;
*VAR_0 += VAR_4;
return 0;
}
if (sscanf(*VAR_0, " c%d %n", &VAR_6, &VAR_4) &&
VAR_6 >= 0 && VAR_6 < MAX_CHANNELS) {
*VAR_1 = VAR_6;
*VAR_2 = 0;
*VAR_0 += VAR_4;
return 0;
}
return AVERROR(EINVAL);
}
| [
"static int FUNC_0(char **VAR_0, int *VAR_1, int *VAR_2)\n{",
"char VAR_3[8];",
"int VAR_4, VAR_5, VAR_6 = 0;",
"int64_t layout, layout0;",
"if (sscanf(*VAR_0, \" %7[A-Z] %n\", VAR_3, &VAR_4)) {",
"layout0 = layout = av_get_channel_layout(VAR_3);",
"for (VAR_5 = 32; VAR_5 > 0; VAR_5 >>= 1) {",
"if (layout >= (int64_t)1 << VAR_5) {",
"VAR_6 += VAR_5;",
"layout >>= VAR_5;",
"}",
"}",
"if (VAR_6 >= MAX_CHANNELS || layout0 != (int64_t)1 << VAR_6)\nreturn AVERROR(EINVAL);",
"*VAR_1 = VAR_6;",
"*VAR_2 = 1;",
"*VAR_0 += VAR_4;",
"return 0;",
"}",
"if (sscanf(*VAR_0, \" c%d %n\", &VAR_6, &VAR_4) &&\nVAR_6 >= 0 && VAR_6 < MAX_CHANNELS) {",
"*VAR_1 = VAR_6;",
"*VAR_2 = 0;",
"*VAR_0 += VAR_4;",
"return 0;",
"}",
"return AVERROR(EINVAL);",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
]
] |
24,610 | int qcow2_grow_l1_table(BlockDriverState *bs, int min_size)
{
BDRVQcowState *s = bs->opaque;
int new_l1_size, new_l1_size2, ret, i;
uint64_t *new_l1_table;
int64_t new_l1_table_offset;
uint8_t data[12];
new_l1_size = s->l1_size;
if (min_size <= new_l1_size)
return 0;
if (new_l1_size == 0) {
new_l1_size = 1;
}
while (min_size > new_l1_size) {
new_l1_size = (new_l1_size * 3 + 1) / 2;
}
#ifdef DEBUG_ALLOC2
printf("grow l1_table from %d to %d\n", s->l1_size, new_l1_size);
#endif
new_l1_size2 = sizeof(uint64_t) * new_l1_size;
new_l1_table = qemu_mallocz(align_offset(new_l1_size2, 512));
memcpy(new_l1_table, s->l1_table, s->l1_size * sizeof(uint64_t));
/* write new table (align to cluster) */
BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_ALLOC_TABLE);
new_l1_table_offset = qcow2_alloc_clusters(bs, new_l1_size2);
if (new_l1_table_offset < 0) {
qemu_free(new_l1_table);
return new_l1_table_offset;
}
BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_WRITE_TABLE);
for(i = 0; i < s->l1_size; i++)
new_l1_table[i] = cpu_to_be64(new_l1_table[i]);
ret = bdrv_pwrite(bs->file, new_l1_table_offset, new_l1_table, new_l1_size2);
if (ret != new_l1_size2)
goto fail;
for(i = 0; i < s->l1_size; i++)
new_l1_table[i] = be64_to_cpu(new_l1_table[i]);
/* set new table */
BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_ACTIVATE_TABLE);
cpu_to_be32w((uint32_t*)data, new_l1_size);
cpu_to_be64w((uint64_t*)(data + 4), new_l1_table_offset);
ret = bdrv_pwrite(bs->file, offsetof(QCowHeader, l1_size), data,sizeof(data));
if (ret != sizeof(data)) {
goto fail;
}
qemu_free(s->l1_table);
qcow2_free_clusters(bs, s->l1_table_offset, s->l1_size * sizeof(uint64_t));
s->l1_table_offset = new_l1_table_offset;
s->l1_table = new_l1_table;
s->l1_size = new_l1_size;
return 0;
fail:
qemu_free(new_l1_table);
qcow2_free_clusters(bs, new_l1_table_offset, new_l1_size2);
return ret < 0 ? ret : -EIO;
}
| true | qemu | 8b3b720620a1137a1b794fc3ed64734236f94e06 | int qcow2_grow_l1_table(BlockDriverState *bs, int min_size)
{
BDRVQcowState *s = bs->opaque;
int new_l1_size, new_l1_size2, ret, i;
uint64_t *new_l1_table;
int64_t new_l1_table_offset;
uint8_t data[12];
new_l1_size = s->l1_size;
if (min_size <= new_l1_size)
return 0;
if (new_l1_size == 0) {
new_l1_size = 1;
}
while (min_size > new_l1_size) {
new_l1_size = (new_l1_size * 3 + 1) / 2;
}
#ifdef DEBUG_ALLOC2
printf("grow l1_table from %d to %d\n", s->l1_size, new_l1_size);
#endif
new_l1_size2 = sizeof(uint64_t) * new_l1_size;
new_l1_table = qemu_mallocz(align_offset(new_l1_size2, 512));
memcpy(new_l1_table, s->l1_table, s->l1_size * sizeof(uint64_t));
BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_ALLOC_TABLE);
new_l1_table_offset = qcow2_alloc_clusters(bs, new_l1_size2);
if (new_l1_table_offset < 0) {
qemu_free(new_l1_table);
return new_l1_table_offset;
}
BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_WRITE_TABLE);
for(i = 0; i < s->l1_size; i++)
new_l1_table[i] = cpu_to_be64(new_l1_table[i]);
ret = bdrv_pwrite(bs->file, new_l1_table_offset, new_l1_table, new_l1_size2);
if (ret != new_l1_size2)
goto fail;
for(i = 0; i < s->l1_size; i++)
new_l1_table[i] = be64_to_cpu(new_l1_table[i]);
BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_ACTIVATE_TABLE);
cpu_to_be32w((uint32_t*)data, new_l1_size);
cpu_to_be64w((uint64_t*)(data + 4), new_l1_table_offset);
ret = bdrv_pwrite(bs->file, offsetof(QCowHeader, l1_size), data,sizeof(data));
if (ret != sizeof(data)) {
goto fail;
}
qemu_free(s->l1_table);
qcow2_free_clusters(bs, s->l1_table_offset, s->l1_size * sizeof(uint64_t));
s->l1_table_offset = new_l1_table_offset;
s->l1_table = new_l1_table;
s->l1_size = new_l1_size;
return 0;
fail:
qemu_free(new_l1_table);
qcow2_free_clusters(bs, new_l1_table_offset, new_l1_size2);
return ret < 0 ? ret : -EIO;
}
| {
"code": [
" ret = bdrv_pwrite(bs->file, new_l1_table_offset, new_l1_table, new_l1_size2);",
" if (ret != new_l1_size2)",
" ret = bdrv_pwrite(bs->file, offsetof(QCowHeader, l1_size), data,sizeof(data));",
" if (ret != sizeof(data)) {",
" return ret < 0 ? ret : -EIO;"
],
"line_no": [
73,
75,
93,
95,
119
]
} | int FUNC_0(BlockDriverState *VAR_0, int VAR_1)
{
BDRVQcowState *s = VAR_0->opaque;
int VAR_2, VAR_3, VAR_4, VAR_5;
uint64_t *new_l1_table;
int64_t new_l1_table_offset;
uint8_t data[12];
VAR_2 = s->l1_size;
if (VAR_1 <= VAR_2)
return 0;
if (VAR_2 == 0) {
VAR_2 = 1;
}
while (VAR_1 > VAR_2) {
VAR_2 = (VAR_2 * 3 + 1) / 2;
}
#ifdef DEBUG_ALLOC2
printf("grow l1_table from %d to %d\n", s->l1_size, VAR_2);
#endif
VAR_3 = sizeof(uint64_t) * VAR_2;
new_l1_table = qemu_mallocz(align_offset(VAR_3, 512));
memcpy(new_l1_table, s->l1_table, s->l1_size * sizeof(uint64_t));
BLKDBG_EVENT(VAR_0->file, BLKDBG_L1_GROW_ALLOC_TABLE);
new_l1_table_offset = qcow2_alloc_clusters(VAR_0, VAR_3);
if (new_l1_table_offset < 0) {
qemu_free(new_l1_table);
return new_l1_table_offset;
}
BLKDBG_EVENT(VAR_0->file, BLKDBG_L1_GROW_WRITE_TABLE);
for(VAR_5 = 0; VAR_5 < s->l1_size; VAR_5++)
new_l1_table[VAR_5] = cpu_to_be64(new_l1_table[VAR_5]);
VAR_4 = bdrv_pwrite(VAR_0->file, new_l1_table_offset, new_l1_table, VAR_3);
if (VAR_4 != VAR_3)
goto fail;
for(VAR_5 = 0; VAR_5 < s->l1_size; VAR_5++)
new_l1_table[VAR_5] = be64_to_cpu(new_l1_table[VAR_5]);
BLKDBG_EVENT(VAR_0->file, BLKDBG_L1_GROW_ACTIVATE_TABLE);
cpu_to_be32w((uint32_t*)data, VAR_2);
cpu_to_be64w((uint64_t*)(data + 4), new_l1_table_offset);
VAR_4 = bdrv_pwrite(VAR_0->file, offsetof(QCowHeader, l1_size), data,sizeof(data));
if (VAR_4 != sizeof(data)) {
goto fail;
}
qemu_free(s->l1_table);
qcow2_free_clusters(VAR_0, s->l1_table_offset, s->l1_size * sizeof(uint64_t));
s->l1_table_offset = new_l1_table_offset;
s->l1_table = new_l1_table;
s->l1_size = VAR_2;
return 0;
fail:
qemu_free(new_l1_table);
qcow2_free_clusters(VAR_0, new_l1_table_offset, VAR_3);
return VAR_4 < 0 ? VAR_4 : -EIO;
}
| [
"int FUNC_0(BlockDriverState *VAR_0, int VAR_1)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"int VAR_2, VAR_3, VAR_4, VAR_5;",
"uint64_t *new_l1_table;",
"int64_t new_l1_table_offset;",
"uint8_t data[12];",
"VAR_2 = s->l1_size;",
"if (VAR_1 <= VAR_2)\nreturn 0;",
"if (VAR_2 == 0) {",
"VAR_2 = 1;",
"}",
"while (VAR_1 > VAR_2) {",
"VAR_2 = (VAR_2 * 3 + 1) / 2;",
"}",
"#ifdef DEBUG_ALLOC2\nprintf(\"grow l1_table from %d to %d\\n\", s->l1_size, VAR_2);",
"#endif\nVAR_3 = sizeof(uint64_t) * VAR_2;",
"new_l1_table = qemu_mallocz(align_offset(VAR_3, 512));",
"memcpy(new_l1_table, s->l1_table, s->l1_size * sizeof(uint64_t));",
"BLKDBG_EVENT(VAR_0->file, BLKDBG_L1_GROW_ALLOC_TABLE);",
"new_l1_table_offset = qcow2_alloc_clusters(VAR_0, VAR_3);",
"if (new_l1_table_offset < 0) {",
"qemu_free(new_l1_table);",
"return new_l1_table_offset;",
"}",
"BLKDBG_EVENT(VAR_0->file, BLKDBG_L1_GROW_WRITE_TABLE);",
"for(VAR_5 = 0; VAR_5 < s->l1_size; VAR_5++)",
"new_l1_table[VAR_5] = cpu_to_be64(new_l1_table[VAR_5]);",
"VAR_4 = bdrv_pwrite(VAR_0->file, new_l1_table_offset, new_l1_table, VAR_3);",
"if (VAR_4 != VAR_3)\ngoto fail;",
"for(VAR_5 = 0; VAR_5 < s->l1_size; VAR_5++)",
"new_l1_table[VAR_5] = be64_to_cpu(new_l1_table[VAR_5]);",
"BLKDBG_EVENT(VAR_0->file, BLKDBG_L1_GROW_ACTIVATE_TABLE);",
"cpu_to_be32w((uint32_t*)data, VAR_2);",
"cpu_to_be64w((uint64_t*)(data + 4), new_l1_table_offset);",
"VAR_4 = bdrv_pwrite(VAR_0->file, offsetof(QCowHeader, l1_size), data,sizeof(data));",
"if (VAR_4 != sizeof(data)) {",
"goto fail;",
"}",
"qemu_free(s->l1_table);",
"qcow2_free_clusters(VAR_0, s->l1_table_offset, s->l1_size * sizeof(uint64_t));",
"s->l1_table_offset = new_l1_table_offset;",
"s->l1_table = new_l1_table;",
"s->l1_size = VAR_2;",
"return 0;",
"fail:\nqemu_free(new_l1_table);",
"qcow2_free_clusters(VAR_0, new_l1_table_offset, VAR_3);",
"return VAR_4 < 0 ? VAR_4 : -EIO;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39,
43
],
[
45
],
[
47
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113,
115
],
[
117
],
[
119
],
[
121
]
] |
24,613 | static void clr_msg_flags(IPMIBmcSim *ibs,
uint8_t *cmd, unsigned int cmd_len,
uint8_t *rsp, unsigned int *rsp_len,
unsigned int max_rsp_len)
{
IPMIInterface *s = ibs->parent.intf;
IPMIInterfaceClass *k = IPMI_INTERFACE_GET_CLASS(s);
IPMI_CHECK_CMD_LEN(3);
ibs->msg_flags &= ~cmd[2];
k->set_atn(s, attn_set(ibs), attn_irq_enabled(ibs));
}
| true | qemu | 4f298a4b2957b7833bc607c951ca27c458d98d88 | static void clr_msg_flags(IPMIBmcSim *ibs,
uint8_t *cmd, unsigned int cmd_len,
uint8_t *rsp, unsigned int *rsp_len,
unsigned int max_rsp_len)
{
IPMIInterface *s = ibs->parent.intf;
IPMIInterfaceClass *k = IPMI_INTERFACE_GET_CLASS(s);
IPMI_CHECK_CMD_LEN(3);
ibs->msg_flags &= ~cmd[2];
k->set_atn(s, attn_set(ibs), attn_irq_enabled(ibs));
}
| {
"code": [
" IPMI_CHECK_CMD_LEN(3);",
" IPMI_CHECK_CMD_LEN(3);",
" IPMI_CHECK_CMD_LEN(3);",
" IPMI_CHECK_CMD_LEN(3);",
" IPMI_CHECK_CMD_LEN(3);",
" IPMI_CHECK_CMD_LEN(3);",
" IPMI_CHECK_CMD_LEN(3);",
" IPMI_CHECK_CMD_LEN(3);"
],
"line_no": [
17,
17,
17,
17,
17,
17,
17,
17
]
} | static void FUNC_0(IPMIBmcSim *VAR_0,
uint8_t *VAR_1, unsigned int VAR_2,
uint8_t *VAR_3, unsigned int *VAR_4,
unsigned int VAR_5)
{
IPMIInterface *s = VAR_0->parent.intf;
IPMIInterfaceClass *k = IPMI_INTERFACE_GET_CLASS(s);
IPMI_CHECK_CMD_LEN(3);
VAR_0->msg_flags &= ~VAR_1[2];
k->set_atn(s, attn_set(VAR_0), attn_irq_enabled(VAR_0));
}
| [
"static void FUNC_0(IPMIBmcSim *VAR_0,\nuint8_t *VAR_1, unsigned int VAR_2,\nuint8_t *VAR_3, unsigned int *VAR_4,\nunsigned int VAR_5)\n{",
"IPMIInterface *s = VAR_0->parent.intf;",
"IPMIInterfaceClass *k = IPMI_INTERFACE_GET_CLASS(s);",
"IPMI_CHECK_CMD_LEN(3);",
"VAR_0->msg_flags &= ~VAR_1[2];",
"k->set_atn(s, attn_set(VAR_0), attn_irq_enabled(VAR_0));",
"}"
] | [
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
24,614 | static int pci_ich9_ahci_init(PCIDevice *dev)
{
struct AHCIPCIState *d;
d = DO_UPCAST(struct AHCIPCIState, card, dev);
pci_config_set_vendor_id(d->card.config, PCI_VENDOR_ID_INTEL);
pci_config_set_device_id(d->card.config, PCI_DEVICE_ID_INTEL_82801IR);
pci_config_set_class(d->card.config, PCI_CLASS_STORAGE_SATA);
pci_config_set_revision(d->card.config, 0x02);
pci_config_set_prog_interface(d->card.config, AHCI_PROGMODE_MAJOR_REV_1);
d->card.config[PCI_CACHE_LINE_SIZE] = 0x08; /* Cache line size */
d->card.config[PCI_LATENCY_TIMER] = 0x00; /* Latency timer */
pci_config_set_interrupt_pin(d->card.config, 1);
/* XXX Software should program this register */
d->card.config[0x90] = 1 << 6; /* Address Map Register - AHCI mode */
qemu_register_reset(ahci_reset, d);
/* XXX BAR size should be 1k, but that breaks, so bump it to 4k for now */
pci_register_bar_simple(&d->card, 5, 0x1000, 0, d->ahci.mem);
msi_init(dev, 0x50, 1, true, false);
ahci_init(&d->ahci, &dev->qdev, 6);
d->ahci.irq = d->card.irq[0];
return 0;
}
| true | qemu | 69c8944f17cb6c084567a16c080cfa7bc780e668 | static int pci_ich9_ahci_init(PCIDevice *dev)
{
struct AHCIPCIState *d;
d = DO_UPCAST(struct AHCIPCIState, card, dev);
pci_config_set_vendor_id(d->card.config, PCI_VENDOR_ID_INTEL);
pci_config_set_device_id(d->card.config, PCI_DEVICE_ID_INTEL_82801IR);
pci_config_set_class(d->card.config, PCI_CLASS_STORAGE_SATA);
pci_config_set_revision(d->card.config, 0x02);
pci_config_set_prog_interface(d->card.config, AHCI_PROGMODE_MAJOR_REV_1);
d->card.config[PCI_CACHE_LINE_SIZE] = 0x08;
d->card.config[PCI_LATENCY_TIMER] = 0x00;
pci_config_set_interrupt_pin(d->card.config, 1);
d->card.config[0x90] = 1 << 6;
qemu_register_reset(ahci_reset, d);
pci_register_bar_simple(&d->card, 5, 0x1000, 0, d->ahci.mem);
msi_init(dev, 0x50, 1, true, false);
ahci_init(&d->ahci, &dev->qdev, 6);
d->ahci.irq = d->card.irq[0];
return 0;
}
| {
"code": [
" ahci_init(&d->ahci, &dev->qdev, 6);"
],
"line_no": [
53
]
} | static int FUNC_0(PCIDevice *VAR_0)
{
struct AHCIPCIState *VAR_1;
VAR_1 = DO_UPCAST(struct AHCIPCIState, card, VAR_0);
pci_config_set_vendor_id(VAR_1->card.config, PCI_VENDOR_ID_INTEL);
pci_config_set_device_id(VAR_1->card.config, PCI_DEVICE_ID_INTEL_82801IR);
pci_config_set_class(VAR_1->card.config, PCI_CLASS_STORAGE_SATA);
pci_config_set_revision(VAR_1->card.config, 0x02);
pci_config_set_prog_interface(VAR_1->card.config, AHCI_PROGMODE_MAJOR_REV_1);
VAR_1->card.config[PCI_CACHE_LINE_SIZE] = 0x08;
VAR_1->card.config[PCI_LATENCY_TIMER] = 0x00;
pci_config_set_interrupt_pin(VAR_1->card.config, 1);
VAR_1->card.config[0x90] = 1 << 6;
qemu_register_reset(ahci_reset, VAR_1);
pci_register_bar_simple(&VAR_1->card, 5, 0x1000, 0, VAR_1->ahci.mem);
msi_init(VAR_0, 0x50, 1, true, false);
ahci_init(&VAR_1->ahci, &VAR_0->qdev, 6);
VAR_1->ahci.irq = VAR_1->card.irq[0];
return 0;
}
| [
"static int FUNC_0(PCIDevice *VAR_0)\n{",
"struct AHCIPCIState *VAR_1;",
"VAR_1 = DO_UPCAST(struct AHCIPCIState, card, VAR_0);",
"pci_config_set_vendor_id(VAR_1->card.config, PCI_VENDOR_ID_INTEL);",
"pci_config_set_device_id(VAR_1->card.config, PCI_DEVICE_ID_INTEL_82801IR);",
"pci_config_set_class(VAR_1->card.config, PCI_CLASS_STORAGE_SATA);",
"pci_config_set_revision(VAR_1->card.config, 0x02);",
"pci_config_set_prog_interface(VAR_1->card.config, AHCI_PROGMODE_MAJOR_REV_1);",
"VAR_1->card.config[PCI_CACHE_LINE_SIZE] = 0x08;",
"VAR_1->card.config[PCI_LATENCY_TIMER] = 0x00;",
"pci_config_set_interrupt_pin(VAR_1->card.config, 1);",
"VAR_1->card.config[0x90] = 1 << 6;",
"qemu_register_reset(ahci_reset, VAR_1);",
"pci_register_bar_simple(&VAR_1->card, 5, 0x1000, 0, VAR_1->ahci.mem);",
"msi_init(VAR_0, 0x50, 1, true, false);",
"ahci_init(&VAR_1->ahci, &VAR_0->qdev, 6);",
"VAR_1->ahci.irq = VAR_1->card.irq[0];",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
35
],
[
39
],
[
45
],
[
49
],
[
53
],
[
55
],
[
59
],
[
61
]
] |
24,616 | static void get_attachment(AVFormatContext *s, AVIOContext *pb, int length)
{
char mime[1024];
char description[1024];
unsigned int filesize;
AVStream *st;
int64_t pos = avio_tell(pb);
avio_get_str16le(pb, INT_MAX, mime, sizeof(mime));
if (strcmp(mime, "image/jpeg"))
goto done;
avio_r8(pb);
avio_get_str16le(pb, INT_MAX, description, sizeof(description));
filesize = avio_rl32(pb);
if (!filesize)
goto done;
st = avformat_new_stream(s, NULL);
if (!st)
goto done;
av_dict_set(&st->metadata, "title", description, 0);
st->codec->codec_id = AV_CODEC_ID_MJPEG;
st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT;
st->codec->extradata = av_mallocz(filesize);
if (!st->codec->extradata)
goto done;
st->codec->extradata_size = filesize;
avio_read(pb, st->codec->extradata, filesize);
done:
avio_seek(pb, pos + length, SEEK_SET);
} | true | FFmpeg | f5e646a00ac21e500dae4bcceded790a0fbc5246 | static void get_attachment(AVFormatContext *s, AVIOContext *pb, int length)
{
char mime[1024];
char description[1024];
unsigned int filesize;
AVStream *st;
int64_t pos = avio_tell(pb);
avio_get_str16le(pb, INT_MAX, mime, sizeof(mime));
if (strcmp(mime, "image/jpeg"))
goto done;
avio_r8(pb);
avio_get_str16le(pb, INT_MAX, description, sizeof(description));
filesize = avio_rl32(pb);
if (!filesize)
goto done;
st = avformat_new_stream(s, NULL);
if (!st)
goto done;
av_dict_set(&st->metadata, "title", description, 0);
st->codec->codec_id = AV_CODEC_ID_MJPEG;
st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT;
st->codec->extradata = av_mallocz(filesize);
if (!st->codec->extradata)
goto done;
st->codec->extradata_size = filesize;
avio_read(pb, st->codec->extradata, filesize);
done:
avio_seek(pb, pos + length, SEEK_SET);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(AVFormatContext *VAR_0, AVIOContext *VAR_1, int VAR_2)
{
char VAR_3[1024];
char VAR_4[1024];
unsigned int VAR_5;
AVStream *st;
int64_t pos = avio_tell(VAR_1);
avio_get_str16le(VAR_1, INT_MAX, VAR_3, sizeof(VAR_3));
if (strcmp(VAR_3, "image/jpeg"))
goto done;
avio_r8(VAR_1);
avio_get_str16le(VAR_1, INT_MAX, VAR_4, sizeof(VAR_4));
VAR_5 = avio_rl32(VAR_1);
if (!VAR_5)
goto done;
st = avformat_new_stream(VAR_0, NULL);
if (!st)
goto done;
av_dict_set(&st->metadata, "title", VAR_4, 0);
st->codec->codec_id = AV_CODEC_ID_MJPEG;
st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT;
st->codec->extradata = av_mallocz(VAR_5);
if (!st->codec->extradata)
goto done;
st->codec->extradata_size = VAR_5;
avio_read(VAR_1, st->codec->extradata, VAR_5);
done:
avio_seek(VAR_1, pos + VAR_2, SEEK_SET);
} | [
"static void FUNC_0(AVFormatContext *VAR_0, AVIOContext *VAR_1, int VAR_2)\n{",
"char VAR_3[1024];",
"char VAR_4[1024];",
"unsigned int VAR_5;",
"AVStream *st;",
"int64_t pos = avio_tell(VAR_1);",
"avio_get_str16le(VAR_1, INT_MAX, VAR_3, sizeof(VAR_3));",
"if (strcmp(VAR_3, \"image/jpeg\"))\ngoto done;",
"avio_r8(VAR_1);",
"avio_get_str16le(VAR_1, INT_MAX, VAR_4, sizeof(VAR_4));",
"VAR_5 = avio_rl32(VAR_1);",
"if (!VAR_5)\ngoto done;",
"st = avformat_new_stream(VAR_0, NULL);",
"if (!st)\ngoto done;",
"av_dict_set(&st->metadata, \"title\", VAR_4, 0);",
"st->codec->codec_id = AV_CODEC_ID_MJPEG;",
"st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT;",
"st->codec->extradata = av_mallocz(VAR_5);",
"if (!st->codec->extradata)\ngoto done;",
"st->codec->extradata_size = VAR_5;",
"avio_read(VAR_1, st->codec->extradata, VAR_5);",
"done:\navio_seek(VAR_1, pos + VAR_2, SEEK_SET);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19,
21
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
52,
54
],
[
56
],
[
58
],
[
60,
62
],
[
64
]
] |
24,617 | static int parse_filename(char *filename, char **representation_id,
char **initialization_pattern, char **media_pattern) {
char *underscore_pos = NULL;
char *period_pos = NULL;
char *temp_pos = NULL;
char *filename_str = av_strdup(filename);
if (!filename_str) return AVERROR(ENOMEM);
temp_pos = av_stristr(filename_str, "_");
while (temp_pos) {
underscore_pos = temp_pos + 1;
temp_pos = av_stristr(temp_pos + 1, "_");
}
if (!underscore_pos) return -1;
period_pos = av_stristr(underscore_pos, ".");
if (!period_pos) return -1;
*(underscore_pos - 1) = 0;
if (representation_id) {
*representation_id = av_malloc(period_pos - underscore_pos + 1);
if (!(*representation_id)) return AVERROR(ENOMEM);
av_strlcpy(*representation_id, underscore_pos, period_pos - underscore_pos + 1);
}
if (initialization_pattern) {
*initialization_pattern = av_asprintf("%s_$RepresentationID$.hdr",
filename_str);
if (!(*initialization_pattern)) return AVERROR(ENOMEM);
}
if (media_pattern) {
*media_pattern = av_asprintf("%s_$RepresentationID$_$Number$.chk",
filename_str);
if (!(*media_pattern)) return AVERROR(ENOMEM);
}
av_free(filename_str);
return 0;
}
| true | FFmpeg | 1c37848f9029985d1271da9a0d161c2ebf0aca81 | static int parse_filename(char *filename, char **representation_id,
char **initialization_pattern, char **media_pattern) {
char *underscore_pos = NULL;
char *period_pos = NULL;
char *temp_pos = NULL;
char *filename_str = av_strdup(filename);
if (!filename_str) return AVERROR(ENOMEM);
temp_pos = av_stristr(filename_str, "_");
while (temp_pos) {
underscore_pos = temp_pos + 1;
temp_pos = av_stristr(temp_pos + 1, "_");
}
if (!underscore_pos) return -1;
period_pos = av_stristr(underscore_pos, ".");
if (!period_pos) return -1;
*(underscore_pos - 1) = 0;
if (representation_id) {
*representation_id = av_malloc(period_pos - underscore_pos + 1);
if (!(*representation_id)) return AVERROR(ENOMEM);
av_strlcpy(*representation_id, underscore_pos, period_pos - underscore_pos + 1);
}
if (initialization_pattern) {
*initialization_pattern = av_asprintf("%s_$RepresentationID$.hdr",
filename_str);
if (!(*initialization_pattern)) return AVERROR(ENOMEM);
}
if (media_pattern) {
*media_pattern = av_asprintf("%s_$RepresentationID$_$Number$.chk",
filename_str);
if (!(*media_pattern)) return AVERROR(ENOMEM);
}
av_free(filename_str);
return 0;
}
| {
"code": [
" if (!underscore_pos) return -1;",
" if (!period_pos) return -1;"
],
"line_no": [
25,
29
]
} | static int FUNC_0(char *VAR_0, char **VAR_1,
char **VAR_2, char **VAR_3) {
char *VAR_4 = NULL;
char *VAR_5 = NULL;
char *VAR_6 = NULL;
char *VAR_7 = av_strdup(VAR_0);
if (!VAR_7) return AVERROR(ENOMEM);
VAR_6 = av_stristr(VAR_7, "_");
while (VAR_6) {
VAR_4 = VAR_6 + 1;
VAR_6 = av_stristr(VAR_6 + 1, "_");
}
if (!VAR_4) return -1;
VAR_5 = av_stristr(VAR_4, ".");
if (!VAR_5) return -1;
*(VAR_4 - 1) = 0;
if (VAR_1) {
*VAR_1 = av_malloc(VAR_5 - VAR_4 + 1);
if (!(*VAR_1)) return AVERROR(ENOMEM);
av_strlcpy(*VAR_1, VAR_4, VAR_5 - VAR_4 + 1);
}
if (VAR_2) {
*VAR_2 = av_asprintf("%s_$RepresentationID$.hdr",
VAR_7);
if (!(*VAR_2)) return AVERROR(ENOMEM);
}
if (VAR_3) {
*VAR_3 = av_asprintf("%s_$RepresentationID$_$Number$.chk",
VAR_7);
if (!(*VAR_3)) return AVERROR(ENOMEM);
}
av_free(VAR_7);
return 0;
}
| [
"static int FUNC_0(char *VAR_0, char **VAR_1,\nchar **VAR_2, char **VAR_3) {",
"char *VAR_4 = NULL;",
"char *VAR_5 = NULL;",
"char *VAR_6 = NULL;",
"char *VAR_7 = av_strdup(VAR_0);",
"if (!VAR_7) return AVERROR(ENOMEM);",
"VAR_6 = av_stristr(VAR_7, \"_\");",
"while (VAR_6) {",
"VAR_4 = VAR_6 + 1;",
"VAR_6 = av_stristr(VAR_6 + 1, \"_\");",
"}",
"if (!VAR_4) return -1;",
"VAR_5 = av_stristr(VAR_4, \".\");",
"if (!VAR_5) return -1;",
"*(VAR_4 - 1) = 0;",
"if (VAR_1) {",
"*VAR_1 = av_malloc(VAR_5 - VAR_4 + 1);",
"if (!(*VAR_1)) return AVERROR(ENOMEM);",
"av_strlcpy(*VAR_1, VAR_4, VAR_5 - VAR_4 + 1);",
"}",
"if (VAR_2) {",
"*VAR_2 = av_asprintf(\"%s_$RepresentationID$.hdr\",\nVAR_7);",
"if (!(*VAR_2)) return AVERROR(ENOMEM);",
"}",
"if (VAR_3) {",
"*VAR_3 = av_asprintf(\"%s_$RepresentationID$_$Number$.chk\",\nVAR_7);",
"if (!(*VAR_3)) return AVERROR(ENOMEM);",
"}",
"av_free(VAR_7);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
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
]
] |
24,618 | struct GuestFileSeek *qmp_guest_file_seek(int64_t handle, int64_t offset,
int64_t whence, Error **errp)
{
GuestFileHandle *gfh = guest_file_handle_find(handle, errp);
GuestFileSeek *seek_data = NULL;
FILE *fh;
int ret;
if (!gfh) {
return NULL;
fh = gfh->fh;
ret = fseek(fh, offset, whence);
if (ret == -1) {
error_setg_errno(errp, errno, "failed to seek file");
} else {
seek_data = g_new0(GuestFileSeek, 1);
seek_data->position = ftell(fh);
seek_data->eof = feof(fh);
clearerr(fh);
return seek_data;
| true | qemu | 895b00f62a7e86724dc7352d67c7808d37366130 | struct GuestFileSeek *qmp_guest_file_seek(int64_t handle, int64_t offset,
int64_t whence, Error **errp)
{
GuestFileHandle *gfh = guest_file_handle_find(handle, errp);
GuestFileSeek *seek_data = NULL;
FILE *fh;
int ret;
if (!gfh) {
return NULL;
fh = gfh->fh;
ret = fseek(fh, offset, whence);
if (ret == -1) {
error_setg_errno(errp, errno, "failed to seek file");
} else {
seek_data = g_new0(GuestFileSeek, 1);
seek_data->position = ftell(fh);
seek_data->eof = feof(fh);
clearerr(fh);
return seek_data;
| {
"code": [],
"line_no": []
} | struct GuestFileSeek *FUNC_0(int64_t VAR_0, int64_t VAR_1,
int64_t VAR_2, Error **VAR_3)
{
GuestFileHandle *gfh = guest_file_handle_find(VAR_0, VAR_3);
GuestFileSeek *VAR_4 = NULL;
FILE *fh;
int VAR_5;
if (!gfh) {
return NULL;
fh = gfh->fh;
VAR_5 = fseek(fh, VAR_1, VAR_2);
if (VAR_5 == -1) {
error_setg_errno(VAR_3, errno, "failed to seek file");
} else {
VAR_4 = g_new0(GuestFileSeek, 1);
VAR_4->position = ftell(fh);
VAR_4->eof = feof(fh);
clearerr(fh);
return VAR_4;
| [
"struct GuestFileSeek *FUNC_0(int64_t VAR_0, int64_t VAR_1,\nint64_t VAR_2, Error **VAR_3)\n{",
"GuestFileHandle *gfh = guest_file_handle_find(VAR_0, VAR_3);",
"GuestFileSeek *VAR_4 = NULL;",
"FILE *fh;",
"int VAR_5;",
"if (!gfh) {",
"return NULL;",
"fh = gfh->fh;",
"VAR_5 = fseek(fh, VAR_1, VAR_2);",
"if (VAR_5 == -1) {",
"error_setg_errno(VAR_3, errno, \"failed to seek file\");",
"} else {",
"VAR_4 = g_new0(GuestFileSeek, 1);",
"VAR_4->position = ftell(fh);",
"VAR_4->eof = feof(fh);",
"clearerr(fh);",
"return VAR_4;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
24
],
[
26
],
[
28
],
[
30
],
[
36
],
[
38
],
[
40
],
[
42
],
[
46
],
[
50
]
] |
24,619 | static void tpm_passthrough_cancel_cmd(TPMBackend *tb)
{
TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb);
int n;
/*
* As of Linux 3.7 the tpm_tis driver does not properly cancel
* commands on all TPM manufacturers' TPMs.
* Only cancel if we're busy so we don't cancel someone else's
* command, e.g., a command executed on the host.
*/
if (tpm_pt->tpm_executing) {
if (tpm_pt->cancel_fd >= 0) {
n = write(tpm_pt->cancel_fd, "-", 1);
if (n != 1) {
error_report("Canceling TPM command failed: %s",
strerror(errno));
} else {
tpm_pt->tpm_op_canceled = true;
}
} else {
error_report("Cannot cancel TPM command due to missing "
"TPM sysfs cancel entry");
}
}
}
| true | qemu | 21cb1e63a594e36ff350fba41600190fb0a1f42b | static void tpm_passthrough_cancel_cmd(TPMBackend *tb)
{
TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb);
int n;
if (tpm_pt->tpm_executing) {
if (tpm_pt->cancel_fd >= 0) {
n = write(tpm_pt->cancel_fd, "-", 1);
if (n != 1) {
error_report("Canceling TPM command failed: %s",
strerror(errno));
} else {
tpm_pt->tpm_op_canceled = true;
}
} else {
error_report("Cannot cancel TPM command due to missing "
"TPM sysfs cancel entry");
}
}
}
| {
"code": [
" } else {",
" tpm_pt->tpm_op_canceled = true;"
],
"line_no": [
35,
37
]
} | static void FUNC_0(TPMBackend *VAR_0)
{
TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(VAR_0);
int VAR_1;
if (tpm_pt->tpm_executing) {
if (tpm_pt->cancel_fd >= 0) {
VAR_1 = write(tpm_pt->cancel_fd, "-", 1);
if (VAR_1 != 1) {
error_report("Canceling TPM command failed: %s",
strerror(errno));
} else {
tpm_pt->tpm_op_canceled = true;
}
} else {
error_report("Cannot cancel TPM command due to missing "
"TPM sysfs cancel entry");
}
}
}
| [
"static void FUNC_0(TPMBackend *VAR_0)\n{",
"TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(VAR_0);",
"int VAR_1;",
"if (tpm_pt->tpm_executing) {",
"if (tpm_pt->cancel_fd >= 0) {",
"VAR_1 = write(tpm_pt->cancel_fd, \"-\", 1);",
"if (VAR_1 != 1) {",
"error_report(\"Canceling TPM command failed: %s\",\nstrerror(errno));",
"} else {",
"tpm_pt->tpm_op_canceled = true;",
"}",
"} else {",
"error_report(\"Cannot cancel TPM command due to missing \"\n\"TPM sysfs cancel entry\");",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
]
] |
24,622 | static void celt_denormalize(CeltFrame *f, CeltBlock *block, float *data)
{
int i, j;
for (i = f->start_band; i < f->end_band; i++) {
float *dst = data + (ff_celt_freq_bands[i] << f->size);
float norm = exp2f(block->energy[i] + ff_celt_mean_energy[i]);
for (j = 0; j < ff_celt_freq_range[i] << f->size; j++)
dst[j] *= norm;
}
}
| true | FFmpeg | de052ea454e06f2c1aab4e06cca0012cf80f2630 | static void celt_denormalize(CeltFrame *f, CeltBlock *block, float *data)
{
int i, j;
for (i = f->start_band; i < f->end_band; i++) {
float *dst = data + (ff_celt_freq_bands[i] << f->size);
float norm = exp2f(block->energy[i] + ff_celt_mean_energy[i]);
for (j = 0; j < ff_celt_freq_range[i] << f->size; j++)
dst[j] *= norm;
}
}
| {
"code": [
" float norm = exp2f(block->energy[i] + ff_celt_mean_energy[i]);"
],
"line_no": [
13
]
} | static void FUNC_0(CeltFrame *VAR_0, CeltBlock *VAR_1, float *VAR_2)
{
int VAR_3, VAR_4;
for (VAR_3 = VAR_0->start_band; VAR_3 < VAR_0->end_band; VAR_3++) {
float *dst = VAR_2 + (ff_celt_freq_bands[VAR_3] << VAR_0->size);
float norm = exp2f(VAR_1->energy[VAR_3] + ff_celt_mean_energy[VAR_3]);
for (VAR_4 = 0; VAR_4 < ff_celt_freq_range[VAR_3] << VAR_0->size; VAR_4++)
dst[VAR_4] *= norm;
}
}
| [
"static void FUNC_0(CeltFrame *VAR_0, CeltBlock *VAR_1, float *VAR_2)\n{",
"int VAR_3, VAR_4;",
"for (VAR_3 = VAR_0->start_band; VAR_3 < VAR_0->end_band; VAR_3++) {",
"float *dst = VAR_2 + (ff_celt_freq_bands[VAR_3] << VAR_0->size);",
"float norm = exp2f(VAR_1->energy[VAR_3] + ff_celt_mean_energy[VAR_3]);",
"for (VAR_4 = 0; VAR_4 < ff_celt_freq_range[VAR_3] << VAR_0->size; VAR_4++)",
"dst[VAR_4] *= norm;",
"}",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
24,623 | static int flac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr)
{
FlacEncodeContext *s;
const int16_t *samples;
int frame_bytes, out_bytes, ret;
s = avctx->priv_data;
/* when the last block is reached, update the header in extradata */
if (!frame) {
s->max_framesize = s->max_encoded_framesize;
av_md5_final(s->md5ctx, s->md5sum);
write_streaminfo(s, avctx->extradata);
return 0;
}
samples = (const int16_t *)frame->data[0];
/* change max_framesize for small final frame */
if (frame->nb_samples < s->frame.blocksize) {
s->max_framesize = ff_flac_get_max_frame_size(frame->nb_samples,
s->channels, 16);
}
init_frame(s, frame->nb_samples);
copy_samples(s, samples);
channel_decorrelation(s);
remove_wasted_bits(s);
frame_bytes = encode_frame(s);
/* fallback to verbatim mode if the compressed frame is larger than it
would be if encoded uncompressed. */
if (frame_bytes > s->max_framesize) {
s->frame.verbatim_only = 1;
frame_bytes = encode_frame(s);
}
if ((ret = ff_alloc_packet(avpkt, frame_bytes))) {
av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n");
return ret;
}
out_bytes = write_frame(s, avpkt);
s->frame_count++;
s->sample_count += frame->nb_samples;
if ((ret = update_md5_sum(s, samples)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error updating MD5 checksum\n");
return ret;
}
if (out_bytes > s->max_encoded_framesize)
s->max_encoded_framesize = out_bytes;
if (out_bytes < s->min_framesize)
s->min_framesize = out_bytes;
avpkt->pts = frame->pts;
avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples);
avpkt->size = out_bytes;
*got_packet_ptr = 1;
return 0;
}
| true | FFmpeg | 5ff998a233d759d0de83ea6f95c383d03d25d88e | static int flac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr)
{
FlacEncodeContext *s;
const int16_t *samples;
int frame_bytes, out_bytes, ret;
s = avctx->priv_data;
if (!frame) {
s->max_framesize = s->max_encoded_framesize;
av_md5_final(s->md5ctx, s->md5sum);
write_streaminfo(s, avctx->extradata);
return 0;
}
samples = (const int16_t *)frame->data[0];
if (frame->nb_samples < s->frame.blocksize) {
s->max_framesize = ff_flac_get_max_frame_size(frame->nb_samples,
s->channels, 16);
}
init_frame(s, frame->nb_samples);
copy_samples(s, samples);
channel_decorrelation(s);
remove_wasted_bits(s);
frame_bytes = encode_frame(s);
if (frame_bytes > s->max_framesize) {
s->frame.verbatim_only = 1;
frame_bytes = encode_frame(s);
}
if ((ret = ff_alloc_packet(avpkt, frame_bytes))) {
av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n");
return ret;
}
out_bytes = write_frame(s, avpkt);
s->frame_count++;
s->sample_count += frame->nb_samples;
if ((ret = update_md5_sum(s, samples)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error updating MD5 checksum\n");
return ret;
}
if (out_bytes > s->max_encoded_framesize)
s->max_encoded_framesize = out_bytes;
if (out_bytes < s->min_framesize)
s->min_framesize = out_bytes;
avpkt->pts = frame->pts;
avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples);
avpkt->size = out_bytes;
*got_packet_ptr = 1;
return 0;
}
| {
"code": [
" if (frame_bytes > s->max_framesize) {"
],
"line_no": [
73
]
} | static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,
const AVFrame *VAR_2, int *VAR_3)
{
FlacEncodeContext *s;
const int16_t *VAR_4;
int VAR_5, VAR_6, VAR_7;
s = VAR_0->priv_data;
if (!VAR_2) {
s->max_framesize = s->max_encoded_framesize;
av_md5_final(s->md5ctx, s->md5sum);
write_streaminfo(s, VAR_0->extradata);
return 0;
}
VAR_4 = (const int16_t *)VAR_2->data[0];
if (VAR_2->nb_samples < s->VAR_2.blocksize) {
s->max_framesize = ff_flac_get_max_frame_size(VAR_2->nb_samples,
s->channels, 16);
}
init_frame(s, VAR_2->nb_samples);
copy_samples(s, VAR_4);
channel_decorrelation(s);
remove_wasted_bits(s);
VAR_5 = encode_frame(s);
if (VAR_5 > s->max_framesize) {
s->VAR_2.verbatim_only = 1;
VAR_5 = encode_frame(s);
}
if ((VAR_7 = ff_alloc_packet(VAR_1, VAR_5))) {
av_log(VAR_0, AV_LOG_ERROR, "Error getting output packet\n");
return VAR_7;
}
VAR_6 = write_frame(s, VAR_1);
s->frame_count++;
s->sample_count += VAR_2->nb_samples;
if ((VAR_7 = update_md5_sum(s, VAR_4)) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Error updating MD5 checksum\n");
return VAR_7;
}
if (VAR_6 > s->max_encoded_framesize)
s->max_encoded_framesize = VAR_6;
if (VAR_6 < s->min_framesize)
s->min_framesize = VAR_6;
VAR_1->pts = VAR_2->pts;
VAR_1->duration = ff_samples_to_time_base(VAR_0, VAR_2->nb_samples);
VAR_1->size = VAR_6;
*VAR_3 = 1;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,\nconst AVFrame *VAR_2, int *VAR_3)\n{",
"FlacEncodeContext *s;",
"const int16_t *VAR_4;",
"int VAR_5, VAR_6, VAR_7;",
"s = VAR_0->priv_data;",
"if (!VAR_2) {",
"s->max_framesize = s->max_encoded_framesize;",
"av_md5_final(s->md5ctx, s->md5sum);",
"write_streaminfo(s, VAR_0->extradata);",
"return 0;",
"}",
"VAR_4 = (const int16_t *)VAR_2->data[0];",
"if (VAR_2->nb_samples < s->VAR_2.blocksize) {",
"s->max_framesize = ff_flac_get_max_frame_size(VAR_2->nb_samples,\ns->channels, 16);",
"}",
"init_frame(s, VAR_2->nb_samples);",
"copy_samples(s, VAR_4);",
"channel_decorrelation(s);",
"remove_wasted_bits(s);",
"VAR_5 = encode_frame(s);",
"if (VAR_5 > s->max_framesize) {",
"s->VAR_2.verbatim_only = 1;",
"VAR_5 = encode_frame(s);",
"}",
"if ((VAR_7 = ff_alloc_packet(VAR_1, VAR_5))) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error getting output packet\\n\");",
"return VAR_7;",
"}",
"VAR_6 = write_frame(s, VAR_1);",
"s->frame_count++;",
"s->sample_count += VAR_2->nb_samples;",
"if ((VAR_7 = update_md5_sum(s, VAR_4)) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error updating MD5 checksum\\n\");",
"return VAR_7;",
"}",
"if (VAR_6 > s->max_encoded_framesize)\ns->max_encoded_framesize = VAR_6;",
"if (VAR_6 < s->min_framesize)\ns->min_framesize = VAR_6;",
"VAR_1->pts = VAR_2->pts;",
"VAR_1->duration = ff_samples_to_time_base(VAR_0, VAR_2->nb_samples);",
"VAR_1->size = VAR_6;",
"*VAR_3 = 1;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
39
],
[
41,
43
],
[
45
],
[
49
],
[
53
],
[
57
],
[
61
],
[
65
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109,
111
],
[
113,
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
]
] |
24,624 | TC6393xbState *tc6393xb_init(MemoryRegion *sysmem, uint32_t base, qemu_irq irq)
{
TC6393xbState *s;
DriveInfo *nand;
static const MemoryRegionOps tc6393xb_ops = {
.read = tc6393xb_readb,
.write = tc6393xb_writeb,
.endianness = DEVICE_NATIVE_ENDIAN,
.impl = {
.min_access_size = 1,
.max_access_size = 1,
},
};
s = (TC6393xbState *) g_malloc0(sizeof(TC6393xbState));
s->irq = irq;
s->gpio_in = qemu_allocate_irqs(tc6393xb_gpio_set, s, TC6393XB_GPIOS);
s->l3v = qemu_allocate_irq(tc6393xb_l3v, s, 0);
s->blanked = 1;
s->sub_irqs = qemu_allocate_irqs(tc6393xb_sub_irq, s, TC6393XB_NR_IRQS);
nand = drive_get(IF_MTD, 0, 0);
s->flash = nand_init(nand ? blk_by_legacy_dinfo(nand) : NULL,
NAND_MFR_TOSHIBA, 0x76);
memory_region_init_io(&s->iomem, NULL, &tc6393xb_ops, s, "tc6393xb", 0x10000);
memory_region_add_subregion(sysmem, base, &s->iomem);
memory_region_init_ram(&s->vram, NULL, "tc6393xb.vram", 0x100000,
&error_abort);
vmstate_register_ram_global(&s->vram);
s->vram_ptr = memory_region_get_ram_ptr(&s->vram);
memory_region_add_subregion(sysmem, base + 0x100000, &s->vram);
s->scr_width = 480;
s->scr_height = 640;
s->con = graphic_console_init(NULL, 0, &tc6393xb_gfx_ops, s);
return s;
}
| true | qemu | f8ed85ac992c48814d916d5df4d44f9a971c5de4 | TC6393xbState *tc6393xb_init(MemoryRegion *sysmem, uint32_t base, qemu_irq irq)
{
TC6393xbState *s;
DriveInfo *nand;
static const MemoryRegionOps tc6393xb_ops = {
.read = tc6393xb_readb,
.write = tc6393xb_writeb,
.endianness = DEVICE_NATIVE_ENDIAN,
.impl = {
.min_access_size = 1,
.max_access_size = 1,
},
};
s = (TC6393xbState *) g_malloc0(sizeof(TC6393xbState));
s->irq = irq;
s->gpio_in = qemu_allocate_irqs(tc6393xb_gpio_set, s, TC6393XB_GPIOS);
s->l3v = qemu_allocate_irq(tc6393xb_l3v, s, 0);
s->blanked = 1;
s->sub_irqs = qemu_allocate_irqs(tc6393xb_sub_irq, s, TC6393XB_NR_IRQS);
nand = drive_get(IF_MTD, 0, 0);
s->flash = nand_init(nand ? blk_by_legacy_dinfo(nand) : NULL,
NAND_MFR_TOSHIBA, 0x76);
memory_region_init_io(&s->iomem, NULL, &tc6393xb_ops, s, "tc6393xb", 0x10000);
memory_region_add_subregion(sysmem, base, &s->iomem);
memory_region_init_ram(&s->vram, NULL, "tc6393xb.vram", 0x100000,
&error_abort);
vmstate_register_ram_global(&s->vram);
s->vram_ptr = memory_region_get_ram_ptr(&s->vram);
memory_region_add_subregion(sysmem, base + 0x100000, &s->vram);
s->scr_width = 480;
s->scr_height = 640;
s->con = graphic_console_init(NULL, 0, &tc6393xb_gfx_ops, s);
return s;
}
| {
"code": [
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);"
],
"line_no": [
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63
]
} | TC6393xbState *FUNC_0(MemoryRegion *sysmem, uint32_t base, qemu_irq irq)
{
TC6393xbState *s;
DriveInfo *nand;
static const MemoryRegionOps VAR_0 = {
.read = tc6393xb_readb,
.write = tc6393xb_writeb,
.endianness = DEVICE_NATIVE_ENDIAN,
.impl = {
.min_access_size = 1,
.max_access_size = 1,
},
};
s = (TC6393xbState *) g_malloc0(sizeof(TC6393xbState));
s->irq = irq;
s->gpio_in = qemu_allocate_irqs(tc6393xb_gpio_set, s, TC6393XB_GPIOS);
s->l3v = qemu_allocate_irq(tc6393xb_l3v, s, 0);
s->blanked = 1;
s->sub_irqs = qemu_allocate_irqs(tc6393xb_sub_irq, s, TC6393XB_NR_IRQS);
nand = drive_get(IF_MTD, 0, 0);
s->flash = nand_init(nand ? blk_by_legacy_dinfo(nand) : NULL,
NAND_MFR_TOSHIBA, 0x76);
memory_region_init_io(&s->iomem, NULL, &VAR_0, s, "tc6393xb", 0x10000);
memory_region_add_subregion(sysmem, base, &s->iomem);
memory_region_init_ram(&s->vram, NULL, "tc6393xb.vram", 0x100000,
&error_abort);
vmstate_register_ram_global(&s->vram);
s->vram_ptr = memory_region_get_ram_ptr(&s->vram);
memory_region_add_subregion(sysmem, base + 0x100000, &s->vram);
s->scr_width = 480;
s->scr_height = 640;
s->con = graphic_console_init(NULL, 0, &tc6393xb_gfx_ops, s);
return s;
}
| [
"TC6393xbState *FUNC_0(MemoryRegion *sysmem, uint32_t base, qemu_irq irq)\n{",
"TC6393xbState *s;",
"DriveInfo *nand;",
"static const MemoryRegionOps VAR_0 = {",
".read = tc6393xb_readb,\n.write = tc6393xb_writeb,\n.endianness = DEVICE_NATIVE_ENDIAN,\n.impl = {",
".min_access_size = 1,\n.max_access_size = 1,\n},",
"};",
"s = (TC6393xbState *) g_malloc0(sizeof(TC6393xbState));",
"s->irq = irq;",
"s->gpio_in = qemu_allocate_irqs(tc6393xb_gpio_set, s, TC6393XB_GPIOS);",
"s->l3v = qemu_allocate_irq(tc6393xb_l3v, s, 0);",
"s->blanked = 1;",
"s->sub_irqs = qemu_allocate_irqs(tc6393xb_sub_irq, s, TC6393XB_NR_IRQS);",
"nand = drive_get(IF_MTD, 0, 0);",
"s->flash = nand_init(nand ? blk_by_legacy_dinfo(nand) : NULL,\nNAND_MFR_TOSHIBA, 0x76);",
"memory_region_init_io(&s->iomem, NULL, &VAR_0, s, \"tc6393xb\", 0x10000);",
"memory_region_add_subregion(sysmem, base, &s->iomem);",
"memory_region_init_ram(&s->vram, NULL, \"tc6393xb.vram\", 0x100000,\n&error_abort);",
"vmstate_register_ram_global(&s->vram);",
"s->vram_ptr = memory_region_get_ram_ptr(&s->vram);",
"memory_region_add_subregion(sysmem, base + 0x100000, &s->vram);",
"s->scr_width = 480;",
"s->scr_height = 640;",
"s->con = graphic_console_init(NULL, 0, &tc6393xb_gfx_ops, s);",
"return s;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13,
15,
17
],
[
19,
21,
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
43
],
[
47
],
[
49,
51
],
[
55
],
[
57
],
[
61,
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
]
] |
24,627 | static int cdg_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame, AVPacket *avpkt)
{
GetByteContext gb;
int buf_size = avpkt->size;
int ret;
uint8_t command, inst;
uint8_t cdg_data[CDG_DATA_SIZE];
AVFrame *frame = data;
CDGraphicsContext *cc = avctx->priv_data;
bytestream2_init(&gb, avpkt->data, avpkt->size);
ret = ff_reget_buffer(avctx, cc->frame);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
return ret;
}
if (!avctx->frame_number)
memset(cc->frame->data[0], 0, cc->frame->linesize[0] * avctx->height);
command = bytestream2_get_byte(&gb);
inst = bytestream2_get_byte(&gb);
inst &= CDG_MASK;
bytestream2_skip(&gb, 2);
bytestream2_get_buffer(&gb, cdg_data, sizeof(cdg_data));
if ((command & CDG_MASK) == CDG_COMMAND) {
switch (inst) {
case CDG_INST_MEMORY_PRESET:
if (!(cdg_data[1] & 0x0F))
memset(cc->frame->data[0], cdg_data[0] & 0x0F,
cc->frame->linesize[0] * CDG_FULL_HEIGHT);
break;
case CDG_INST_LOAD_PAL_LO:
case CDG_INST_LOAD_PAL_HIGH:
if (buf_size - CDG_HEADER_SIZE < CDG_DATA_SIZE) {
av_log(avctx, AV_LOG_ERROR, "buffer too small for loading palette\n");
return AVERROR(EINVAL);
}
cdg_load_palette(cc, cdg_data, inst == CDG_INST_LOAD_PAL_LO);
break;
case CDG_INST_BORDER_PRESET:
cdg_border_preset(cc, cdg_data);
break;
case CDG_INST_TILE_BLOCK_XOR:
case CDG_INST_TILE_BLOCK:
if (buf_size - CDG_HEADER_SIZE < CDG_DATA_SIZE) {
av_log(avctx, AV_LOG_ERROR, "buffer too small for drawing tile\n");
return AVERROR(EINVAL);
}
ret = cdg_tile_block(cc, cdg_data, inst == CDG_INST_TILE_BLOCK_XOR);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "tile is out of range\n");
return ret;
}
break;
case CDG_INST_SCROLL_PRESET:
case CDG_INST_SCROLL_COPY:
if (buf_size - CDG_HEADER_SIZE < CDG_MINIMUM_SCROLL_SIZE) {
av_log(avctx, AV_LOG_ERROR, "buffer too small for scrolling\n");
return AVERROR(EINVAL);
}
ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
cdg_scroll(cc, cdg_data, frame, inst == CDG_INST_SCROLL_COPY);
av_frame_unref(cc->frame);
ret = av_frame_ref(cc->frame, frame);
if (ret < 0)
return ret;
break;
default:
break;
}
if (!frame->data[0]) {
ret = av_frame_ref(frame, cc->frame);
if (ret < 0)
return ret;
}
*got_frame = 1;
} else {
*got_frame = 0;
buf_size = 0;
}
return buf_size;
}
| false | FFmpeg | c7d9b473e28238d4a4ef1b7e8b42c1cca256da36 | static int cdg_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame, AVPacket *avpkt)
{
GetByteContext gb;
int buf_size = avpkt->size;
int ret;
uint8_t command, inst;
uint8_t cdg_data[CDG_DATA_SIZE];
AVFrame *frame = data;
CDGraphicsContext *cc = avctx->priv_data;
bytestream2_init(&gb, avpkt->data, avpkt->size);
ret = ff_reget_buffer(avctx, cc->frame);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
return ret;
}
if (!avctx->frame_number)
memset(cc->frame->data[0], 0, cc->frame->linesize[0] * avctx->height);
command = bytestream2_get_byte(&gb);
inst = bytestream2_get_byte(&gb);
inst &= CDG_MASK;
bytestream2_skip(&gb, 2);
bytestream2_get_buffer(&gb, cdg_data, sizeof(cdg_data));
if ((command & CDG_MASK) == CDG_COMMAND) {
switch (inst) {
case CDG_INST_MEMORY_PRESET:
if (!(cdg_data[1] & 0x0F))
memset(cc->frame->data[0], cdg_data[0] & 0x0F,
cc->frame->linesize[0] * CDG_FULL_HEIGHT);
break;
case CDG_INST_LOAD_PAL_LO:
case CDG_INST_LOAD_PAL_HIGH:
if (buf_size - CDG_HEADER_SIZE < CDG_DATA_SIZE) {
av_log(avctx, AV_LOG_ERROR, "buffer too small for loading palette\n");
return AVERROR(EINVAL);
}
cdg_load_palette(cc, cdg_data, inst == CDG_INST_LOAD_PAL_LO);
break;
case CDG_INST_BORDER_PRESET:
cdg_border_preset(cc, cdg_data);
break;
case CDG_INST_TILE_BLOCK_XOR:
case CDG_INST_TILE_BLOCK:
if (buf_size - CDG_HEADER_SIZE < CDG_DATA_SIZE) {
av_log(avctx, AV_LOG_ERROR, "buffer too small for drawing tile\n");
return AVERROR(EINVAL);
}
ret = cdg_tile_block(cc, cdg_data, inst == CDG_INST_TILE_BLOCK_XOR);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "tile is out of range\n");
return ret;
}
break;
case CDG_INST_SCROLL_PRESET:
case CDG_INST_SCROLL_COPY:
if (buf_size - CDG_HEADER_SIZE < CDG_MINIMUM_SCROLL_SIZE) {
av_log(avctx, AV_LOG_ERROR, "buffer too small for scrolling\n");
return AVERROR(EINVAL);
}
ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
cdg_scroll(cc, cdg_data, frame, inst == CDG_INST_SCROLL_COPY);
av_frame_unref(cc->frame);
ret = av_frame_ref(cc->frame, frame);
if (ret < 0)
return ret;
break;
default:
break;
}
if (!frame->data[0]) {
ret = av_frame_ref(frame, cc->frame);
if (ret < 0)
return ret;
}
*got_frame = 1;
} else {
*got_frame = 0;
buf_size = 0;
}
return buf_size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2, AVPacket *VAR_3)
{
GetByteContext gb;
int VAR_4 = VAR_3->size;
int VAR_5;
uint8_t command, inst;
uint8_t cdg_data[CDG_DATA_SIZE];
AVFrame *frame = VAR_1;
CDGraphicsContext *cc = VAR_0->priv_data;
bytestream2_init(&gb, VAR_3->VAR_1, VAR_3->size);
VAR_5 = ff_reget_buffer(VAR_0, cc->frame);
if (VAR_5) {
av_log(VAR_0, AV_LOG_ERROR, "reget_buffer() failed\n");
return VAR_5;
}
if (!VAR_0->frame_number)
memset(cc->frame->VAR_1[0], 0, cc->frame->linesize[0] * VAR_0->height);
command = bytestream2_get_byte(&gb);
inst = bytestream2_get_byte(&gb);
inst &= CDG_MASK;
bytestream2_skip(&gb, 2);
bytestream2_get_buffer(&gb, cdg_data, sizeof(cdg_data));
if ((command & CDG_MASK) == CDG_COMMAND) {
switch (inst) {
case CDG_INST_MEMORY_PRESET:
if (!(cdg_data[1] & 0x0F))
memset(cc->frame->VAR_1[0], cdg_data[0] & 0x0F,
cc->frame->linesize[0] * CDG_FULL_HEIGHT);
break;
case CDG_INST_LOAD_PAL_LO:
case CDG_INST_LOAD_PAL_HIGH:
if (VAR_4 - CDG_HEADER_SIZE < CDG_DATA_SIZE) {
av_log(VAR_0, AV_LOG_ERROR, "buffer too small for loading palette\n");
return AVERROR(EINVAL);
}
cdg_load_palette(cc, cdg_data, inst == CDG_INST_LOAD_PAL_LO);
break;
case CDG_INST_BORDER_PRESET:
cdg_border_preset(cc, cdg_data);
break;
case CDG_INST_TILE_BLOCK_XOR:
case CDG_INST_TILE_BLOCK:
if (VAR_4 - CDG_HEADER_SIZE < CDG_DATA_SIZE) {
av_log(VAR_0, AV_LOG_ERROR, "buffer too small for drawing tile\n");
return AVERROR(EINVAL);
}
VAR_5 = cdg_tile_block(cc, cdg_data, inst == CDG_INST_TILE_BLOCK_XOR);
if (VAR_5) {
av_log(VAR_0, AV_LOG_ERROR, "tile is out of range\n");
return VAR_5;
}
break;
case CDG_INST_SCROLL_PRESET:
case CDG_INST_SCROLL_COPY:
if (VAR_4 - CDG_HEADER_SIZE < CDG_MINIMUM_SCROLL_SIZE) {
av_log(VAR_0, AV_LOG_ERROR, "buffer too small for scrolling\n");
return AVERROR(EINVAL);
}
VAR_5 = ff_get_buffer(VAR_0, frame, AV_GET_BUFFER_FLAG_REF);
if (VAR_5) {
av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");
return VAR_5;
}
cdg_scroll(cc, cdg_data, frame, inst == CDG_INST_SCROLL_COPY);
av_frame_unref(cc->frame);
VAR_5 = av_frame_ref(cc->frame, frame);
if (VAR_5 < 0)
return VAR_5;
break;
default:
break;
}
if (!frame->VAR_1[0]) {
VAR_5 = av_frame_ref(frame, cc->frame);
if (VAR_5 < 0)
return VAR_5;
}
*VAR_2 = 1;
} else {
*VAR_2 = 0;
VAR_4 = 0;
}
return VAR_4;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2, AVPacket *VAR_3)\n{",
"GetByteContext gb;",
"int VAR_4 = VAR_3->size;",
"int VAR_5;",
"uint8_t command, inst;",
"uint8_t cdg_data[CDG_DATA_SIZE];",
"AVFrame *frame = VAR_1;",
"CDGraphicsContext *cc = VAR_0->priv_data;",
"bytestream2_init(&gb, VAR_3->VAR_1, VAR_3->size);",
"VAR_5 = ff_reget_buffer(VAR_0, cc->frame);",
"if (VAR_5) {",
"av_log(VAR_0, AV_LOG_ERROR, \"reget_buffer() failed\\n\");",
"return VAR_5;",
"}",
"if (!VAR_0->frame_number)\nmemset(cc->frame->VAR_1[0], 0, cc->frame->linesize[0] * VAR_0->height);",
"command = bytestream2_get_byte(&gb);",
"inst = bytestream2_get_byte(&gb);",
"inst &= CDG_MASK;",
"bytestream2_skip(&gb, 2);",
"bytestream2_get_buffer(&gb, cdg_data, sizeof(cdg_data));",
"if ((command & CDG_MASK) == CDG_COMMAND) {",
"switch (inst) {",
"case CDG_INST_MEMORY_PRESET:\nif (!(cdg_data[1] & 0x0F))\nmemset(cc->frame->VAR_1[0], cdg_data[0] & 0x0F,\ncc->frame->linesize[0] * CDG_FULL_HEIGHT);",
"break;",
"case CDG_INST_LOAD_PAL_LO:\ncase CDG_INST_LOAD_PAL_HIGH:\nif (VAR_4 - CDG_HEADER_SIZE < CDG_DATA_SIZE) {",
"av_log(VAR_0, AV_LOG_ERROR, \"buffer too small for loading palette\\n\");",
"return AVERROR(EINVAL);",
"}",
"cdg_load_palette(cc, cdg_data, inst == CDG_INST_LOAD_PAL_LO);",
"break;",
"case CDG_INST_BORDER_PRESET:\ncdg_border_preset(cc, cdg_data);",
"break;",
"case CDG_INST_TILE_BLOCK_XOR:\ncase CDG_INST_TILE_BLOCK:\nif (VAR_4 - CDG_HEADER_SIZE < CDG_DATA_SIZE) {",
"av_log(VAR_0, AV_LOG_ERROR, \"buffer too small for drawing tile\\n\");",
"return AVERROR(EINVAL);",
"}",
"VAR_5 = cdg_tile_block(cc, cdg_data, inst == CDG_INST_TILE_BLOCK_XOR);",
"if (VAR_5) {",
"av_log(VAR_0, AV_LOG_ERROR, \"tile is out of range\\n\");",
"return VAR_5;",
"}",
"break;",
"case CDG_INST_SCROLL_PRESET:\ncase CDG_INST_SCROLL_COPY:\nif (VAR_4 - CDG_HEADER_SIZE < CDG_MINIMUM_SCROLL_SIZE) {",
"av_log(VAR_0, AV_LOG_ERROR, \"buffer too small for scrolling\\n\");",
"return AVERROR(EINVAL);",
"}",
"VAR_5 = ff_get_buffer(VAR_0, frame, AV_GET_BUFFER_FLAG_REF);",
"if (VAR_5) {",
"av_log(VAR_0, AV_LOG_ERROR, \"get_buffer() failed\\n\");",
"return VAR_5;",
"}",
"cdg_scroll(cc, cdg_data, frame, inst == CDG_INST_SCROLL_COPY);",
"av_frame_unref(cc->frame);",
"VAR_5 = av_frame_ref(cc->frame, frame);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"break;",
"default:\nbreak;",
"}",
"if (!frame->VAR_1[0]) {",
"VAR_5 = av_frame_ref(frame, cc->frame);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"}",
"*VAR_2 = 1;",
"} else {",
"*VAR_2 = 0;",
"VAR_4 = 0;",
"}",
"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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61,
63,
65,
67
],
[
69
],
[
71,
73,
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89,
91
],
[
93
],
[
95,
97,
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121,
123,
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153,
155
],
[
157
],
[
159,
161
],
[
163
],
[
167
],
[
169
],
[
171,
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
189
],
[
191
]
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.