id
int32 0
27.3k
| func
stringlengths 26
142k
| target
bool 2
classes | project
stringclasses 2
values | commit_id
stringlengths 40
40
| func_clean
stringlengths 26
131k
| vul_lines
dict | normalized_func
stringlengths 24
132k
| lines
listlengths 1
2.8k
| label
listlengths 1
2.8k
| line_no
listlengths 1
2.8k
|
---|---|---|---|---|---|---|---|---|---|---|
13,591 | static void do_help(int argc, const char **argv)
{
help_cmd(argv[1]);
}
| false | qemu | 9307c4c1d93939db9b04117b654253af5113dc21 | static void do_help(int argc, const char **argv)
{
help_cmd(argv[1]);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(int VAR_0, const char **VAR_1)
{
help_cmd(VAR_1[1]);
}
| [
"static void FUNC_0(int VAR_0, const char **VAR_1)\n{",
"help_cmd(VAR_1[1]);",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
13,593 | int main(int argc, char **argv, char **envp)
{
const char *gdbstub_dev = NULL;
int i;
int snapshot, linux_boot;
const char *icount_option = NULL;
const char *initrd_filename;
const char *kernel_filename, *kernel_cmdline;
char boot_devices[33] = "cad"; /* default to HD->floppy->CD-ROM */
DisplayState *ds;
DisplayChangeListener *dcl;
int cyls, heads, secs, translation;
QemuOpts *hda_opts = NULL, *opts;
QemuOptsList *olist;
int optind;
const char *optarg;
const char *loadvm = NULL;
QEMUMachine *machine;
const char *cpu_model;
const char *pid_file = NULL;
const char *incoming = NULL;
#ifdef CONFIG_VNC
int show_vnc_port = 0;
#endif
int defconfig = 1;
const char *log_mask = NULL;
const char *log_file = NULL;
GMemVTable mem_trace = {
.malloc = malloc_and_trace,
.realloc = realloc_and_trace,
.free = free_and_trace,
};
const char *trace_events = NULL;
const char *trace_file = NULL;
atexit(qemu_run_exit_notifiers);
error_set_progname(argv[0]);
g_mem_set_vtable(&mem_trace);
if (!g_thread_supported()) {
#if !GLIB_CHECK_VERSION(2, 31, 0)
g_thread_init(NULL);
#else
fprintf(stderr, "glib threading failed to initialize.\n");
exit(1);
#endif
}
runstate_init();
init_clocks();
rtc_clock = host_clock;
qemu_cache_utils_init(envp);
QLIST_INIT (&vm_change_state_head);
os_setup_early_signal_handling();
module_call_init(MODULE_INIT_MACHINE);
machine = find_default_machine();
cpu_model = NULL;
initrd_filename = NULL;
ram_size = 0;
snapshot = 0;
kernel_filename = NULL;
kernel_cmdline = "";
cyls = heads = secs = 0;
translation = BIOS_ATA_TRANSLATION_AUTO;
for (i = 0; i < MAX_NODES; i++) {
node_mem[i] = 0;
node_cpumask[i] = 0;
}
nb_numa_nodes = 0;
nb_nics = 0;
autostart= 1;
/* first pass of option parsing */
optind = 1;
while (optind < argc) {
if (argv[optind][0] != '-') {
/* disk image */
optind++;
continue;
} else {
const QEMUOption *popt;
popt = lookup_opt(argc, argv, &optarg, &optind);
switch (popt->index) {
case QEMU_OPTION_nodefconfig:
defconfig=0;
break;
}
}
}
if (defconfig) {
int ret;
ret = qemu_read_config_file(CONFIG_QEMU_CONFDIR "/qemu.conf");
if (ret < 0 && ret != -ENOENT) {
exit(1);
}
ret = qemu_read_config_file(arch_config_name);
if (ret < 0 && ret != -ENOENT) {
exit(1);
}
}
cpudef_init();
/* second pass of option parsing */
optind = 1;
for(;;) {
if (optind >= argc)
break;
if (argv[optind][0] != '-') {
hda_opts = drive_add(IF_DEFAULT, 0, argv[optind++], HD_OPTS);
} else {
const QEMUOption *popt;
popt = lookup_opt(argc, argv, &optarg, &optind);
if (!(popt->arch_mask & arch_type)) {
printf("Option %s not supported for this target\n", popt->name);
exit(1);
}
switch(popt->index) {
case QEMU_OPTION_M:
machine = machine_parse(optarg);
break;
case QEMU_OPTION_cpu:
/* hw initialization will check this */
if (*optarg == '?') {
list_cpus(stdout, &fprintf, optarg);
exit(0);
} else {
cpu_model = optarg;
}
break;
case QEMU_OPTION_initrd:
initrd_filename = optarg;
break;
case QEMU_OPTION_hda:
{
char buf[256];
if (cyls == 0)
snprintf(buf, sizeof(buf), "%s", HD_OPTS);
else
snprintf(buf, sizeof(buf),
"%s,cyls=%d,heads=%d,secs=%d%s",
HD_OPTS , cyls, heads, secs,
translation == BIOS_ATA_TRANSLATION_LBA ?
",trans=lba" :
translation == BIOS_ATA_TRANSLATION_NONE ?
",trans=none" : "");
drive_add(IF_DEFAULT, 0, optarg, buf);
break;
}
case QEMU_OPTION_hdb:
case QEMU_OPTION_hdc:
case QEMU_OPTION_hdd:
drive_add(IF_DEFAULT, popt->index - QEMU_OPTION_hda, optarg,
HD_OPTS);
break;
case QEMU_OPTION_drive:
if (drive_def(optarg) == NULL) {
exit(1);
}
break;
case QEMU_OPTION_set:
if (qemu_set_option(optarg) != 0)
exit(1);
break;
case QEMU_OPTION_global:
if (qemu_global_option(optarg) != 0)
exit(1);
break;
case QEMU_OPTION_mtdblock:
drive_add(IF_MTD, -1, optarg, MTD_OPTS);
break;
case QEMU_OPTION_sd:
drive_add(IF_SD, 0, optarg, SD_OPTS);
break;
case QEMU_OPTION_pflash:
drive_add(IF_PFLASH, -1, optarg, PFLASH_OPTS);
break;
case QEMU_OPTION_snapshot:
snapshot = 1;
break;
case QEMU_OPTION_hdachs:
{
const char *p;
p = optarg;
cyls = strtol(p, (char **)&p, 0);
if (cyls < 1 || cyls > 16383)
goto chs_fail;
if (*p != ',')
goto chs_fail;
p++;
heads = strtol(p, (char **)&p, 0);
if (heads < 1 || heads > 16)
goto chs_fail;
if (*p != ',')
goto chs_fail;
p++;
secs = strtol(p, (char **)&p, 0);
if (secs < 1 || secs > 63)
goto chs_fail;
if (*p == ',') {
p++;
if (!strcmp(p, "none"))
translation = BIOS_ATA_TRANSLATION_NONE;
else if (!strcmp(p, "lba"))
translation = BIOS_ATA_TRANSLATION_LBA;
else if (!strcmp(p, "auto"))
translation = BIOS_ATA_TRANSLATION_AUTO;
else
goto chs_fail;
} else if (*p != '\0') {
chs_fail:
fprintf(stderr, "qemu: invalid physical CHS format\n");
exit(1);
}
if (hda_opts != NULL) {
char num[16];
snprintf(num, sizeof(num), "%d", cyls);
qemu_opt_set(hda_opts, "cyls", num);
snprintf(num, sizeof(num), "%d", heads);
qemu_opt_set(hda_opts, "heads", num);
snprintf(num, sizeof(num), "%d", secs);
qemu_opt_set(hda_opts, "secs", num);
if (translation == BIOS_ATA_TRANSLATION_LBA)
qemu_opt_set(hda_opts, "trans", "lba");
if (translation == BIOS_ATA_TRANSLATION_NONE)
qemu_opt_set(hda_opts, "trans", "none");
}
}
break;
case QEMU_OPTION_numa:
if (nb_numa_nodes >= MAX_NODES) {
fprintf(stderr, "qemu: too many NUMA nodes\n");
exit(1);
}
numa_add(optarg);
break;
case QEMU_OPTION_display:
display_type = select_display(optarg);
break;
case QEMU_OPTION_nographic:
display_type = DT_NOGRAPHIC;
break;
case QEMU_OPTION_curses:
#ifdef CONFIG_CURSES
display_type = DT_CURSES;
#else
fprintf(stderr, "Curses support is disabled\n");
exit(1);
#endif
break;
case QEMU_OPTION_portrait:
graphic_rotate = 90;
break;
case QEMU_OPTION_rotate:
graphic_rotate = strtol(optarg, (char **) &optarg, 10);
if (graphic_rotate != 0 && graphic_rotate != 90 &&
graphic_rotate != 180 && graphic_rotate != 270) {
fprintf(stderr,
"qemu: only 90, 180, 270 deg rotation is available\n");
exit(1);
}
break;
case QEMU_OPTION_kernel:
kernel_filename = optarg;
break;
case QEMU_OPTION_append:
kernel_cmdline = optarg;
break;
case QEMU_OPTION_cdrom:
drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS);
break;
case QEMU_OPTION_boot:
{
static const char * const params[] = {
"order", "once", "menu",
"splash", "splash-time", NULL
};
char buf[sizeof(boot_devices)];
char *standard_boot_devices;
int legacy = 0;
if (!strchr(optarg, '=')) {
legacy = 1;
pstrcpy(buf, sizeof(buf), optarg);
} else if (check_params(buf, sizeof(buf), params, optarg) < 0) {
fprintf(stderr,
"qemu: unknown boot parameter '%s' in '%s'\n",
buf, optarg);
exit(1);
}
if (legacy ||
get_param_value(buf, sizeof(buf), "order", optarg)) {
validate_bootdevices(buf);
pstrcpy(boot_devices, sizeof(boot_devices), buf);
}
if (!legacy) {
if (get_param_value(buf, sizeof(buf),
"once", optarg)) {
validate_bootdevices(buf);
standard_boot_devices = g_strdup(boot_devices);
pstrcpy(boot_devices, sizeof(boot_devices), buf);
qemu_register_reset(restore_boot_devices,
standard_boot_devices);
}
if (get_param_value(buf, sizeof(buf),
"menu", optarg)) {
if (!strcmp(buf, "on")) {
boot_menu = 1;
} else if (!strcmp(buf, "off")) {
boot_menu = 0;
} else {
fprintf(stderr,
"qemu: invalid option value '%s'\n",
buf);
exit(1);
}
}
qemu_opts_parse(qemu_find_opts("boot-opts"),
optarg, 0);
}
}
break;
case QEMU_OPTION_fda:
case QEMU_OPTION_fdb:
drive_add(IF_FLOPPY, popt->index - QEMU_OPTION_fda,
optarg, FD_OPTS);
break;
case QEMU_OPTION_no_fd_bootchk:
fd_bootchk = 0;
break;
case QEMU_OPTION_netdev:
if (net_client_parse(qemu_find_opts("netdev"), optarg) == -1) {
exit(1);
}
break;
case QEMU_OPTION_net:
if (net_client_parse(qemu_find_opts("net"), optarg) == -1) {
exit(1);
}
break;
#ifdef CONFIG_SLIRP
case QEMU_OPTION_tftp:
legacy_tftp_prefix = optarg;
break;
case QEMU_OPTION_bootp:
legacy_bootp_filename = optarg;
break;
case QEMU_OPTION_redir:
if (net_slirp_redir(optarg) < 0)
exit(1);
break;
#endif
case QEMU_OPTION_bt:
add_device_config(DEV_BT, optarg);
break;
case QEMU_OPTION_audio_help:
if (!(audio_available())) {
printf("Option %s not supported for this target\n", popt->name);
exit(1);
}
AUD_help ();
exit (0);
break;
case QEMU_OPTION_soundhw:
if (!(audio_available())) {
printf("Option %s not supported for this target\n", popt->name);
exit(1);
}
select_soundhw (optarg);
break;
case QEMU_OPTION_h:
help(0);
break;
case QEMU_OPTION_version:
version();
exit(0);
break;
case QEMU_OPTION_m: {
int64_t value;
char *end;
value = strtosz(optarg, &end);
if (value < 0 || *end) {
fprintf(stderr, "qemu: invalid ram size: %s\n", optarg);
exit(1);
}
if (value != (uint64_t)(ram_addr_t)value) {
fprintf(stderr, "qemu: ram size too large\n");
exit(1);
}
ram_size = value;
break;
}
case QEMU_OPTION_mempath:
mem_path = optarg;
break;
#ifdef MAP_POPULATE
case QEMU_OPTION_mem_prealloc:
mem_prealloc = 1;
break;
#endif
case QEMU_OPTION_d:
log_mask = optarg;
break;
case QEMU_OPTION_D:
log_file = optarg;
break;
case QEMU_OPTION_s:
gdbstub_dev = "tcp::" DEFAULT_GDBSTUB_PORT;
break;
case QEMU_OPTION_gdb:
gdbstub_dev = optarg;
break;
case QEMU_OPTION_L:
data_dir = optarg;
break;
case QEMU_OPTION_bios:
bios_name = optarg;
break;
case QEMU_OPTION_singlestep:
singlestep = 1;
break;
case QEMU_OPTION_S:
autostart = 0;
break;
case QEMU_OPTION_k:
keyboard_layout = optarg;
break;
case QEMU_OPTION_localtime:
rtc_utc = 0;
break;
case QEMU_OPTION_vga:
select_vgahw (optarg);
break;
case QEMU_OPTION_g:
{
const char *p;
int w, h, depth;
p = optarg;
w = strtol(p, (char **)&p, 10);
if (w <= 0) {
graphic_error:
fprintf(stderr, "qemu: invalid resolution or depth\n");
exit(1);
}
if (*p != 'x')
goto graphic_error;
p++;
h = strtol(p, (char **)&p, 10);
if (h <= 0)
goto graphic_error;
if (*p == 'x') {
p++;
depth = strtol(p, (char **)&p, 10);
if (depth != 8 && depth != 15 && depth != 16 &&
depth != 24 && depth != 32)
goto graphic_error;
} else if (*p == '\0') {
depth = graphic_depth;
} else {
goto graphic_error;
}
graphic_width = w;
graphic_height = h;
graphic_depth = depth;
}
break;
case QEMU_OPTION_echr:
{
char *r;
term_escape_char = strtol(optarg, &r, 0);
if (r == optarg)
printf("Bad argument to echr\n");
break;
}
case QEMU_OPTION_monitor:
monitor_parse(optarg, "readline");
default_monitor = 0;
break;
case QEMU_OPTION_qmp:
monitor_parse(optarg, "control");
default_monitor = 0;
break;
case QEMU_OPTION_mon:
opts = qemu_opts_parse(qemu_find_opts("mon"), optarg, 1);
if (!opts) {
exit(1);
}
default_monitor = 0;
break;
case QEMU_OPTION_chardev:
opts = qemu_opts_parse(qemu_find_opts("chardev"), optarg, 1);
if (!opts) {
exit(1);
}
break;
case QEMU_OPTION_fsdev:
olist = qemu_find_opts("fsdev");
if (!olist) {
fprintf(stderr, "fsdev is not supported by this qemu build.\n");
exit(1);
}
opts = qemu_opts_parse(olist, optarg, 1);
if (!opts) {
fprintf(stderr, "parse error: %s\n", optarg);
exit(1);
}
break;
case QEMU_OPTION_virtfs: {
QemuOpts *fsdev;
QemuOpts *device;
const char *writeout;
olist = qemu_find_opts("virtfs");
if (!olist) {
fprintf(stderr, "virtfs is not supported by this qemu build.\n");
exit(1);
}
opts = qemu_opts_parse(olist, optarg, 1);
if (!opts) {
fprintf(stderr, "parse error: %s\n", optarg);
exit(1);
}
if (qemu_opt_get(opts, "fsdriver") == NULL ||
qemu_opt_get(opts, "mount_tag") == NULL ||
qemu_opt_get(opts, "path") == NULL) {
fprintf(stderr, "Usage: -virtfs fsdriver,path=/share_path/,"
"[security_model={mapped|passthrough|none}],"
"mount_tag=tag.\n");
exit(1);
}
fsdev = qemu_opts_create(qemu_find_opts("fsdev"),
qemu_opt_get(opts, "mount_tag"), 1);
if (!fsdev) {
fprintf(stderr, "duplicate fsdev id: %s\n",
qemu_opt_get(opts, "mount_tag"));
exit(1);
}
writeout = qemu_opt_get(opts, "writeout");
if (writeout) {
#ifdef CONFIG_SYNC_FILE_RANGE
qemu_opt_set(fsdev, "writeout", writeout);
#else
fprintf(stderr, "writeout=immediate not supported on "
"this platform\n");
exit(1);
#endif
}
qemu_opt_set(fsdev, "fsdriver", qemu_opt_get(opts, "fsdriver"));
qemu_opt_set(fsdev, "path", qemu_opt_get(opts, "path"));
qemu_opt_set(fsdev, "security_model",
qemu_opt_get(opts, "security_model"));
qemu_opt_set_bool(fsdev, "readonly",
qemu_opt_get_bool(opts, "readonly", 0));
device = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
qemu_opt_set(device, "driver", "virtio-9p-pci");
qemu_opt_set(device, "fsdev",
qemu_opt_get(opts, "mount_tag"));
qemu_opt_set(device, "mount_tag",
qemu_opt_get(opts, "mount_tag"));
break;
}
case QEMU_OPTION_virtfs_synth: {
QemuOpts *fsdev;
QemuOpts *device;
fsdev = qemu_opts_create(qemu_find_opts("fsdev"), "v_synth", 1);
if (!fsdev) {
fprintf(stderr, "duplicate option: %s\n", "virtfs_synth");
exit(1);
}
qemu_opt_set(fsdev, "fsdriver", "synth");
qemu_opt_set(fsdev, "path", "/"); /* ignored */
device = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
qemu_opt_set(device, "driver", "virtio-9p-pci");
qemu_opt_set(device, "fsdev", "v_synth");
qemu_opt_set(device, "mount_tag", "v_synth");
break;
}
case QEMU_OPTION_serial:
add_device_config(DEV_SERIAL, optarg);
default_serial = 0;
if (strncmp(optarg, "mon:", 4) == 0) {
default_monitor = 0;
}
break;
case QEMU_OPTION_watchdog:
if (watchdog) {
fprintf(stderr,
"qemu: only one watchdog option may be given\n");
return 1;
}
watchdog = optarg;
break;
case QEMU_OPTION_watchdog_action:
if (select_watchdog_action(optarg) == -1) {
fprintf(stderr, "Unknown -watchdog-action parameter\n");
exit(1);
}
break;
case QEMU_OPTION_virtiocon:
add_device_config(DEV_VIRTCON, optarg);
default_virtcon = 0;
if (strncmp(optarg, "mon:", 4) == 0) {
default_monitor = 0;
}
break;
case QEMU_OPTION_parallel:
add_device_config(DEV_PARALLEL, optarg);
default_parallel = 0;
if (strncmp(optarg, "mon:", 4) == 0) {
default_monitor = 0;
}
break;
case QEMU_OPTION_debugcon:
add_device_config(DEV_DEBUGCON, optarg);
break;
case QEMU_OPTION_loadvm:
loadvm = optarg;
break;
case QEMU_OPTION_full_screen:
full_screen = 1;
break;
#ifdef CONFIG_SDL
case QEMU_OPTION_no_frame:
no_frame = 1;
break;
case QEMU_OPTION_alt_grab:
alt_grab = 1;
break;
case QEMU_OPTION_ctrl_grab:
ctrl_grab = 1;
break;
case QEMU_OPTION_no_quit:
no_quit = 1;
break;
case QEMU_OPTION_sdl:
display_type = DT_SDL;
break;
#else
case QEMU_OPTION_no_frame:
case QEMU_OPTION_alt_grab:
case QEMU_OPTION_ctrl_grab:
case QEMU_OPTION_no_quit:
case QEMU_OPTION_sdl:
fprintf(stderr, "SDL support is disabled\n");
exit(1);
#endif
case QEMU_OPTION_pidfile:
pid_file = optarg;
break;
case QEMU_OPTION_win2k_hack:
win2k_install_hack = 1;
break;
case QEMU_OPTION_rtc_td_hack:
rtc_td_hack = 1;
break;
case QEMU_OPTION_acpitable:
do_acpitable_option(optarg);
break;
case QEMU_OPTION_smbios:
do_smbios_option(optarg);
break;
case QEMU_OPTION_enable_kvm:
olist = qemu_find_opts("machine");
qemu_opts_reset(olist);
qemu_opts_parse(olist, "accel=kvm", 0);
break;
case QEMU_OPTION_machine:
olist = qemu_find_opts("machine");
qemu_opts_reset(olist);
opts = qemu_opts_parse(olist, optarg, 1);
if (!opts) {
fprintf(stderr, "parse error: %s\n", optarg);
exit(1);
}
optarg = qemu_opt_get(opts, "type");
if (optarg) {
machine = machine_parse(optarg);
}
break;
case QEMU_OPTION_usb:
usb_enabled = 1;
break;
case QEMU_OPTION_usbdevice:
usb_enabled = 1;
add_device_config(DEV_USB, optarg);
break;
case QEMU_OPTION_device:
if (!qemu_opts_parse(qemu_find_opts("device"), optarg, 1)) {
exit(1);
}
break;
case QEMU_OPTION_smp:
smp_parse(optarg);
if (smp_cpus < 1) {
fprintf(stderr, "Invalid number of CPUs\n");
exit(1);
}
if (max_cpus < smp_cpus) {
fprintf(stderr, "maxcpus must be equal to or greater than "
"smp\n");
exit(1);
}
if (max_cpus > 255) {
fprintf(stderr, "Unsupported number of maxcpus\n");
exit(1);
}
break;
case QEMU_OPTION_vnc:
#ifdef CONFIG_VNC
display_remote++;
vnc_display = optarg;
#else
fprintf(stderr, "VNC support is disabled\n");
exit(1);
#endif
break;
case QEMU_OPTION_no_acpi:
acpi_enabled = 0;
break;
case QEMU_OPTION_no_hpet:
no_hpet = 1;
break;
case QEMU_OPTION_balloon:
if (balloon_parse(optarg) < 0) {
fprintf(stderr, "Unknown -balloon argument %s\n", optarg);
exit(1);
}
break;
case QEMU_OPTION_no_reboot:
no_reboot = 1;
break;
case QEMU_OPTION_no_shutdown:
no_shutdown = 1;
break;
case QEMU_OPTION_show_cursor:
cursor_hide = 0;
break;
case QEMU_OPTION_uuid:
if(qemu_uuid_parse(optarg, qemu_uuid) < 0) {
fprintf(stderr, "Fail to parse UUID string."
" Wrong format.\n");
exit(1);
}
break;
case QEMU_OPTION_option_rom:
if (nb_option_roms >= MAX_OPTION_ROMS) {
fprintf(stderr, "Too many option ROMs\n");
exit(1);
}
opts = qemu_opts_parse(qemu_find_opts("option-rom"), optarg, 1);
option_rom[nb_option_roms].name = qemu_opt_get(opts, "romfile");
option_rom[nb_option_roms].bootindex =
qemu_opt_get_number(opts, "bootindex", -1);
if (!option_rom[nb_option_roms].name) {
fprintf(stderr, "Option ROM file is not specified\n");
exit(1);
}
nb_option_roms++;
break;
case QEMU_OPTION_semihosting:
semihosting_enabled = 1;
break;
case QEMU_OPTION_name:
qemu_name = g_strdup(optarg);
{
char *p = strchr(qemu_name, ',');
if (p != NULL) {
*p++ = 0;
if (strncmp(p, "process=", 8)) {
fprintf(stderr, "Unknown subargument %s to -name\n", p);
exit(1);
}
p += 8;
os_set_proc_name(p);
}
}
break;
case QEMU_OPTION_prom_env:
if (nb_prom_envs >= MAX_PROM_ENVS) {
fprintf(stderr, "Too many prom variables\n");
exit(1);
}
prom_envs[nb_prom_envs] = optarg;
nb_prom_envs++;
break;
case QEMU_OPTION_old_param:
old_param = 1;
break;
case QEMU_OPTION_clock:
configure_alarms(optarg);
break;
case QEMU_OPTION_startdate:
configure_rtc_date_offset(optarg, 1);
break;
case QEMU_OPTION_rtc:
opts = qemu_opts_parse(qemu_find_opts("rtc"), optarg, 0);
if (!opts) {
exit(1);
}
configure_rtc(opts);
break;
case QEMU_OPTION_tb_size:
tcg_tb_size = strtol(optarg, NULL, 0);
if (tcg_tb_size < 0) {
tcg_tb_size = 0;
}
break;
case QEMU_OPTION_icount:
icount_option = optarg;
break;
case QEMU_OPTION_incoming:
incoming = optarg;
break;
case QEMU_OPTION_nodefaults:
default_serial = 0;
default_parallel = 0;
default_virtcon = 0;
default_monitor = 0;
default_vga = 0;
default_net = 0;
default_floppy = 0;
default_cdrom = 0;
default_sdcard = 0;
break;
case QEMU_OPTION_xen_domid:
if (!(xen_available())) {
printf("Option %s not supported for this target\n", popt->name);
exit(1);
}
xen_domid = atoi(optarg);
break;
case QEMU_OPTION_xen_create:
if (!(xen_available())) {
printf("Option %s not supported for this target\n", popt->name);
exit(1);
}
xen_mode = XEN_CREATE;
break;
case QEMU_OPTION_xen_attach:
if (!(xen_available())) {
printf("Option %s not supported for this target\n", popt->name);
exit(1);
}
xen_mode = XEN_ATTACH;
break;
case QEMU_OPTION_trace:
{
opts = qemu_opts_parse(qemu_find_opts("trace"), optarg, 0);
if (!opts) {
exit(1);
}
trace_events = qemu_opt_get(opts, "events");
trace_file = qemu_opt_get(opts, "file");
break;
}
case QEMU_OPTION_readconfig:
{
int ret = qemu_read_config_file(optarg);
if (ret < 0) {
fprintf(stderr, "read config %s: %s\n", optarg,
strerror(-ret));
exit(1);
}
break;
}
case QEMU_OPTION_spice:
olist = qemu_find_opts("spice");
if (!olist) {
fprintf(stderr, "spice is not supported by this qemu build.\n");
exit(1);
}
opts = qemu_opts_parse(olist, optarg, 0);
if (!opts) {
fprintf(stderr, "parse error: %s\n", optarg);
exit(1);
}
break;
case QEMU_OPTION_writeconfig:
{
FILE *fp;
if (strcmp(optarg, "-") == 0) {
fp = stdout;
} else {
fp = fopen(optarg, "w");
if (fp == NULL) {
fprintf(stderr, "open %s: %s\n", optarg, strerror(errno));
exit(1);
}
}
qemu_config_write(fp);
fclose(fp);
break;
}
default:
os_parse_cmd_args(popt->index, optarg);
}
}
}
loc_set_none();
/* Open the logfile at this point, if necessary. We can't open the logfile
* when encountering either of the logging options (-d or -D) because the
* other one may be encountered later on the command line, changing the
* location or level of logging.
*/
if (log_mask) {
if (log_file) {
set_cpu_log_filename(log_file);
}
set_cpu_log(log_mask);
}
if (!trace_backend_init(trace_events, trace_file)) {
exit(1);
}
/* If no data_dir is specified then try to find it relative to the
executable path. */
if (!data_dir) {
data_dir = os_find_datadir(argv[0]);
}
/* If all else fails use the install path specified when building. */
if (!data_dir) {
data_dir = CONFIG_QEMU_DATADIR;
}
if (machine == NULL) {
fprintf(stderr, "No machine found.\n");
exit(1);
}
/*
* Default to max_cpus = smp_cpus, in case the user doesn't
* specify a max_cpus value.
*/
if (!max_cpus)
max_cpus = smp_cpus;
machine->max_cpus = machine->max_cpus ?: 1; /* Default to UP */
if (smp_cpus > machine->max_cpus) {
fprintf(stderr, "Number of SMP cpus requested (%d), exceeds max cpus "
"supported by machine `%s' (%d)\n", smp_cpus, machine->name,
machine->max_cpus);
exit(1);
}
/*
* Get the default machine options from the machine if it is not already
* specified either by the configuration file or by the command line.
*/
if (machine->default_machine_opts) {
QemuOptsList *list = qemu_find_opts("machine");
const char *p = NULL;
if (!QTAILQ_EMPTY(&list->head)) {
p = qemu_opt_get(QTAILQ_FIRST(&list->head), "accel");
}
if (p == NULL) {
qemu_opts_reset(list);
opts = qemu_opts_parse(list, machine->default_machine_opts, 0);
if (!opts) {
fprintf(stderr, "parse error for machine %s: %s\n",
machine->name, machine->default_machine_opts);
exit(1);
}
}
}
qemu_opts_foreach(qemu_find_opts("device"), default_driver_check, NULL, 0);
qemu_opts_foreach(qemu_find_opts("global"), default_driver_check, NULL, 0);
if (machine->no_serial) {
default_serial = 0;
}
if (machine->no_parallel) {
default_parallel = 0;
}
if (!machine->use_virtcon) {
default_virtcon = 0;
}
if (machine->no_vga) {
default_vga = 0;
}
if (machine->no_floppy) {
default_floppy = 0;
}
if (machine->no_cdrom) {
default_cdrom = 0;
}
if (machine->no_sdcard) {
default_sdcard = 0;
}
if (display_type == DT_NOGRAPHIC) {
if (default_parallel)
add_device_config(DEV_PARALLEL, "null");
if (default_serial && default_monitor) {
add_device_config(DEV_SERIAL, "mon:stdio");
} else if (default_virtcon && default_monitor) {
add_device_config(DEV_VIRTCON, "mon:stdio");
} else {
if (default_serial)
add_device_config(DEV_SERIAL, "stdio");
if (default_virtcon)
add_device_config(DEV_VIRTCON, "stdio");
if (default_monitor)
monitor_parse("stdio", "readline");
}
} else {
if (default_serial)
add_device_config(DEV_SERIAL, "vc:80Cx24C");
if (default_parallel)
add_device_config(DEV_PARALLEL, "vc:80Cx24C");
if (default_monitor)
monitor_parse("vc:80Cx24C", "readline");
if (default_virtcon)
add_device_config(DEV_VIRTCON, "vc:80Cx24C");
}
if (default_vga)
vga_interface_type = VGA_CIRRUS;
socket_init();
if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func, NULL, 1) != 0)
exit(1);
#ifdef CONFIG_VIRTFS
if (qemu_opts_foreach(qemu_find_opts("fsdev"), fsdev_init_func, NULL, 1) != 0) {
exit(1);
}
#endif
os_daemonize();
if (pid_file && qemu_create_pidfile(pid_file) != 0) {
os_pidfile_error();
exit(1);
}
/* init the memory */
if (ram_size == 0) {
ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
}
configure_accelerator();
qemu_init_cpu_loop();
if (qemu_init_main_loop()) {
fprintf(stderr, "qemu_init_main_loop failed\n");
exit(1);
}
linux_boot = (kernel_filename != NULL);
if (!linux_boot && *kernel_cmdline != '\0') {
fprintf(stderr, "-append only allowed with -kernel option\n");
exit(1);
}
if (!linux_boot && initrd_filename != NULL) {
fprintf(stderr, "-initrd only allowed with -kernel option\n");
exit(1);
}
os_set_line_buffering();
if (init_timer_alarm() < 0) {
fprintf(stderr, "could not initialize alarm timer\n");
exit(1);
}
if (icount_option && (kvm_enabled() || xen_enabled())) {
fprintf(stderr, "-icount is not allowed with kvm or xen\n");
exit(1);
}
configure_icount(icount_option);
if (net_init_clients() < 0) {
exit(1);
}
/* init the bluetooth world */
if (foreach_device_config(DEV_BT, bt_parse))
exit(1);
if (!xen_enabled()) {
/* On 32-bit hosts, QEMU is limited by virtual address space */
if (ram_size > (2047 << 20) && HOST_LONG_BITS == 32) {
fprintf(stderr, "qemu: at most 2047 MB RAM can be simulated\n");
exit(1);
}
}
cpu_exec_init_all();
bdrv_init_with_whitelist();
blk_mig_init();
/* open the virtual block devices */
if (snapshot)
qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot, NULL, 0);
if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func, &machine->use_scsi, 1) != 0)
exit(1);
default_drive(default_cdrom, snapshot, machine->use_scsi,
IF_DEFAULT, 2, CDROM_OPTS);
default_drive(default_floppy, snapshot, machine->use_scsi,
IF_FLOPPY, 0, FD_OPTS);
default_drive(default_sdcard, snapshot, machine->use_scsi,
IF_SD, 0, SD_OPTS);
register_savevm_live(NULL, "ram", 0, 4, NULL, ram_save_live, NULL,
ram_load, NULL);
if (nb_numa_nodes > 0) {
int i;
if (nb_numa_nodes > MAX_NODES) {
nb_numa_nodes = MAX_NODES;
}
/* If no memory size if given for any node, assume the default case
* and distribute the available memory equally across all nodes
*/
for (i = 0; i < nb_numa_nodes; i++) {
if (node_mem[i] != 0)
break;
}
if (i == nb_numa_nodes) {
uint64_t usedmem = 0;
/* On Linux, the each node's border has to be 8MB aligned,
* the final node gets the rest.
*/
for (i = 0; i < nb_numa_nodes - 1; i++) {
node_mem[i] = (ram_size / nb_numa_nodes) & ~((1 << 23UL) - 1);
usedmem += node_mem[i];
}
node_mem[i] = ram_size - usedmem;
}
for (i = 0; i < nb_numa_nodes; i++) {
if (node_cpumask[i] != 0)
break;
}
/* assigning the VCPUs round-robin is easier to implement, guest OSes
* must cope with this anyway, because there are BIOSes out there in
* real machines which also use this scheme.
*/
if (i == nb_numa_nodes) {
for (i = 0; i < max_cpus; i++) {
node_cpumask[i % nb_numa_nodes] |= 1 << i;
}
}
}
if (qemu_opts_foreach(qemu_find_opts("mon"), mon_init_func, NULL, 1) != 0) {
exit(1);
}
if (foreach_device_config(DEV_SERIAL, serial_parse) < 0)
exit(1);
if (foreach_device_config(DEV_PARALLEL, parallel_parse) < 0)
exit(1);
if (foreach_device_config(DEV_VIRTCON, virtcon_parse) < 0)
exit(1);
if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0)
exit(1);
module_call_init(MODULE_INIT_DEVICE);
if (qemu_opts_foreach(qemu_find_opts("device"), device_help_func, NULL, 0) != 0)
exit(0);
if (watchdog) {
i = select_watchdog(watchdog);
if (i > 0)
exit (i == 1 ? 1 : 0);
}
if (machine->compat_props) {
qdev_prop_register_global_list(machine->compat_props);
}
qemu_add_globals();
qdev_machine_init();
machine->init(ram_size, boot_devices,
kernel_filename, kernel_cmdline, initrd_filename, cpu_model);
cpu_synchronize_all_post_init();
set_numa_modes();
current_machine = machine;
/* init USB devices */
if (usb_enabled) {
if (foreach_device_config(DEV_USB, usb_parse) < 0)
exit(1);
}
/* init generic devices */
if (qemu_opts_foreach(qemu_find_opts("device"), device_init_func, NULL, 1) != 0)
exit(1);
net_check_clients();
/* just use the first displaystate for the moment */
ds = get_displaystate();
if (using_spice)
display_remote++;
if (display_type == DT_DEFAULT && !display_remote) {
#if defined(CONFIG_SDL) || defined(CONFIG_COCOA)
display_type = DT_SDL;
#elif defined(CONFIG_VNC)
vnc_display = "localhost:0,to=99";
show_vnc_port = 1;
#else
display_type = DT_NONE;
#endif
}
/* init local displays */
switch (display_type) {
case DT_NOGRAPHIC:
break;
#if defined(CONFIG_CURSES)
case DT_CURSES:
curses_display_init(ds, full_screen);
break;
#endif
#if defined(CONFIG_SDL)
case DT_SDL:
sdl_display_init(ds, full_screen, no_frame);
break;
#elif defined(CONFIG_COCOA)
case DT_SDL:
cocoa_display_init(ds, full_screen);
break;
#endif
default:
break;
}
/* must be after terminal init, SDL library changes signal handlers */
os_setup_signal_handling();
#ifdef CONFIG_VNC
/* init remote displays */
if (vnc_display) {
vnc_display_init(ds);
if (vnc_display_open(ds, vnc_display) < 0)
exit(1);
if (show_vnc_port) {
printf("VNC server running on `%s'\n", vnc_display_local_addr(ds));
}
}
#endif
#ifdef CONFIG_SPICE
if (using_spice && !qxl_enabled) {
qemu_spice_display_init(ds);
}
#endif
/* display setup */
dpy_resize(ds);
dcl = ds->listeners;
while (dcl != NULL) {
if (dcl->dpy_refresh != NULL) {
ds->gui_timer = qemu_new_timer_ms(rt_clock, gui_update, ds);
qemu_mod_timer(ds->gui_timer, qemu_get_clock_ms(rt_clock));
break;
}
dcl = dcl->next;
}
text_consoles_set_display(ds);
if (gdbstub_dev && gdbserver_start(gdbstub_dev) < 0) {
fprintf(stderr, "qemu: could not open gdbserver on device '%s'\n",
gdbstub_dev);
exit(1);
}
qdev_machine_creation_done();
if (rom_load_all() != 0) {
fprintf(stderr, "rom loading failed\n");
exit(1);
}
/* TODO: once all bus devices are qdevified, this should be done
* when bus is created by qdev.c */
qemu_register_reset(qbus_reset_all_fn, sysbus_get_default());
qemu_run_machine_init_done_notifiers();
qemu_system_reset(VMRESET_SILENT);
if (loadvm) {
if (load_vmstate(loadvm) < 0) {
autostart = 0;
}
}
if (incoming) {
runstate_set(RUN_STATE_INMIGRATE);
int ret = qemu_start_incoming_migration(incoming);
if (ret < 0) {
fprintf(stderr, "Migration failed. Exit code %s(%d), exiting.\n",
incoming, ret);
exit(ret);
}
} else if (autostart) {
vm_start();
}
os_setup_post();
resume_all_vcpus();
main_loop();
bdrv_close_all();
pause_all_vcpus();
net_cleanup();
res_free();
return 0;
}
| false | qemu | 99519f0a776797db8fbdbf828240333e5181a612 | int main(int argc, char **argv, char **envp)
{
const char *gdbstub_dev = NULL;
int i;
int snapshot, linux_boot;
const char *icount_option = NULL;
const char *initrd_filename;
const char *kernel_filename, *kernel_cmdline;
char boot_devices[33] = "cad";
DisplayState *ds;
DisplayChangeListener *dcl;
int cyls, heads, secs, translation;
QemuOpts *hda_opts = NULL, *opts;
QemuOptsList *olist;
int optind;
const char *optarg;
const char *loadvm = NULL;
QEMUMachine *machine;
const char *cpu_model;
const char *pid_file = NULL;
const char *incoming = NULL;
#ifdef CONFIG_VNC
int show_vnc_port = 0;
#endif
int defconfig = 1;
const char *log_mask = NULL;
const char *log_file = NULL;
GMemVTable mem_trace = {
.malloc = malloc_and_trace,
.realloc = realloc_and_trace,
.free = free_and_trace,
};
const char *trace_events = NULL;
const char *trace_file = NULL;
atexit(qemu_run_exit_notifiers);
error_set_progname(argv[0]);
g_mem_set_vtable(&mem_trace);
if (!g_thread_supported()) {
#if !GLIB_CHECK_VERSION(2, 31, 0)
g_thread_init(NULL);
#else
fprintf(stderr, "glib threading failed to initialize.\n");
exit(1);
#endif
}
runstate_init();
init_clocks();
rtc_clock = host_clock;
qemu_cache_utils_init(envp);
QLIST_INIT (&vm_change_state_head);
os_setup_early_signal_handling();
module_call_init(MODULE_INIT_MACHINE);
machine = find_default_machine();
cpu_model = NULL;
initrd_filename = NULL;
ram_size = 0;
snapshot = 0;
kernel_filename = NULL;
kernel_cmdline = "";
cyls = heads = secs = 0;
translation = BIOS_ATA_TRANSLATION_AUTO;
for (i = 0; i < MAX_NODES; i++) {
node_mem[i] = 0;
node_cpumask[i] = 0;
}
nb_numa_nodes = 0;
nb_nics = 0;
autostart= 1;
optind = 1;
while (optind < argc) {
if (argv[optind][0] != '-') {
optind++;
continue;
} else {
const QEMUOption *popt;
popt = lookup_opt(argc, argv, &optarg, &optind);
switch (popt->index) {
case QEMU_OPTION_nodefconfig:
defconfig=0;
break;
}
}
}
if (defconfig) {
int ret;
ret = qemu_read_config_file(CONFIG_QEMU_CONFDIR "/qemu.conf");
if (ret < 0 && ret != -ENOENT) {
exit(1);
}
ret = qemu_read_config_file(arch_config_name);
if (ret < 0 && ret != -ENOENT) {
exit(1);
}
}
cpudef_init();
optind = 1;
for(;;) {
if (optind >= argc)
break;
if (argv[optind][0] != '-') {
hda_opts = drive_add(IF_DEFAULT, 0, argv[optind++], HD_OPTS);
} else {
const QEMUOption *popt;
popt = lookup_opt(argc, argv, &optarg, &optind);
if (!(popt->arch_mask & arch_type)) {
printf("Option %s not supported for this target\n", popt->name);
exit(1);
}
switch(popt->index) {
case QEMU_OPTION_M:
machine = machine_parse(optarg);
break;
case QEMU_OPTION_cpu:
if (*optarg == '?') {
list_cpus(stdout, &fprintf, optarg);
exit(0);
} else {
cpu_model = optarg;
}
break;
case QEMU_OPTION_initrd:
initrd_filename = optarg;
break;
case QEMU_OPTION_hda:
{
char buf[256];
if (cyls == 0)
snprintf(buf, sizeof(buf), "%s", HD_OPTS);
else
snprintf(buf, sizeof(buf),
"%s,cyls=%d,heads=%d,secs=%d%s",
HD_OPTS , cyls, heads, secs,
translation == BIOS_ATA_TRANSLATION_LBA ?
",trans=lba" :
translation == BIOS_ATA_TRANSLATION_NONE ?
",trans=none" : "");
drive_add(IF_DEFAULT, 0, optarg, buf);
break;
}
case QEMU_OPTION_hdb:
case QEMU_OPTION_hdc:
case QEMU_OPTION_hdd:
drive_add(IF_DEFAULT, popt->index - QEMU_OPTION_hda, optarg,
HD_OPTS);
break;
case QEMU_OPTION_drive:
if (drive_def(optarg) == NULL) {
exit(1);
}
break;
case QEMU_OPTION_set:
if (qemu_set_option(optarg) != 0)
exit(1);
break;
case QEMU_OPTION_global:
if (qemu_global_option(optarg) != 0)
exit(1);
break;
case QEMU_OPTION_mtdblock:
drive_add(IF_MTD, -1, optarg, MTD_OPTS);
break;
case QEMU_OPTION_sd:
drive_add(IF_SD, 0, optarg, SD_OPTS);
break;
case QEMU_OPTION_pflash:
drive_add(IF_PFLASH, -1, optarg, PFLASH_OPTS);
break;
case QEMU_OPTION_snapshot:
snapshot = 1;
break;
case QEMU_OPTION_hdachs:
{
const char *p;
p = optarg;
cyls = strtol(p, (char **)&p, 0);
if (cyls < 1 || cyls > 16383)
goto chs_fail;
if (*p != ',')
goto chs_fail;
p++;
heads = strtol(p, (char **)&p, 0);
if (heads < 1 || heads > 16)
goto chs_fail;
if (*p != ',')
goto chs_fail;
p++;
secs = strtol(p, (char **)&p, 0);
if (secs < 1 || secs > 63)
goto chs_fail;
if (*p == ',') {
p++;
if (!strcmp(p, "none"))
translation = BIOS_ATA_TRANSLATION_NONE;
else if (!strcmp(p, "lba"))
translation = BIOS_ATA_TRANSLATION_LBA;
else if (!strcmp(p, "auto"))
translation = BIOS_ATA_TRANSLATION_AUTO;
else
goto chs_fail;
} else if (*p != '\0') {
chs_fail:
fprintf(stderr, "qemu: invalid physical CHS format\n");
exit(1);
}
if (hda_opts != NULL) {
char num[16];
snprintf(num, sizeof(num), "%d", cyls);
qemu_opt_set(hda_opts, "cyls", num);
snprintf(num, sizeof(num), "%d", heads);
qemu_opt_set(hda_opts, "heads", num);
snprintf(num, sizeof(num), "%d", secs);
qemu_opt_set(hda_opts, "secs", num);
if (translation == BIOS_ATA_TRANSLATION_LBA)
qemu_opt_set(hda_opts, "trans", "lba");
if (translation == BIOS_ATA_TRANSLATION_NONE)
qemu_opt_set(hda_opts, "trans", "none");
}
}
break;
case QEMU_OPTION_numa:
if (nb_numa_nodes >= MAX_NODES) {
fprintf(stderr, "qemu: too many NUMA nodes\n");
exit(1);
}
numa_add(optarg);
break;
case QEMU_OPTION_display:
display_type = select_display(optarg);
break;
case QEMU_OPTION_nographic:
display_type = DT_NOGRAPHIC;
break;
case QEMU_OPTION_curses:
#ifdef CONFIG_CURSES
display_type = DT_CURSES;
#else
fprintf(stderr, "Curses support is disabled\n");
exit(1);
#endif
break;
case QEMU_OPTION_portrait:
graphic_rotate = 90;
break;
case QEMU_OPTION_rotate:
graphic_rotate = strtol(optarg, (char **) &optarg, 10);
if (graphic_rotate != 0 && graphic_rotate != 90 &&
graphic_rotate != 180 && graphic_rotate != 270) {
fprintf(stderr,
"qemu: only 90, 180, 270 deg rotation is available\n");
exit(1);
}
break;
case QEMU_OPTION_kernel:
kernel_filename = optarg;
break;
case QEMU_OPTION_append:
kernel_cmdline = optarg;
break;
case QEMU_OPTION_cdrom:
drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS);
break;
case QEMU_OPTION_boot:
{
static const char * const params[] = {
"order", "once", "menu",
"splash", "splash-time", NULL
};
char buf[sizeof(boot_devices)];
char *standard_boot_devices;
int legacy = 0;
if (!strchr(optarg, '=')) {
legacy = 1;
pstrcpy(buf, sizeof(buf), optarg);
} else if (check_params(buf, sizeof(buf), params, optarg) < 0) {
fprintf(stderr,
"qemu: unknown boot parameter '%s' in '%s'\n",
buf, optarg);
exit(1);
}
if (legacy ||
get_param_value(buf, sizeof(buf), "order", optarg)) {
validate_bootdevices(buf);
pstrcpy(boot_devices, sizeof(boot_devices), buf);
}
if (!legacy) {
if (get_param_value(buf, sizeof(buf),
"once", optarg)) {
validate_bootdevices(buf);
standard_boot_devices = g_strdup(boot_devices);
pstrcpy(boot_devices, sizeof(boot_devices), buf);
qemu_register_reset(restore_boot_devices,
standard_boot_devices);
}
if (get_param_value(buf, sizeof(buf),
"menu", optarg)) {
if (!strcmp(buf, "on")) {
boot_menu = 1;
} else if (!strcmp(buf, "off")) {
boot_menu = 0;
} else {
fprintf(stderr,
"qemu: invalid option value '%s'\n",
buf);
exit(1);
}
}
qemu_opts_parse(qemu_find_opts("boot-opts"),
optarg, 0);
}
}
break;
case QEMU_OPTION_fda:
case QEMU_OPTION_fdb:
drive_add(IF_FLOPPY, popt->index - QEMU_OPTION_fda,
optarg, FD_OPTS);
break;
case QEMU_OPTION_no_fd_bootchk:
fd_bootchk = 0;
break;
case QEMU_OPTION_netdev:
if (net_client_parse(qemu_find_opts("netdev"), optarg) == -1) {
exit(1);
}
break;
case QEMU_OPTION_net:
if (net_client_parse(qemu_find_opts("net"), optarg) == -1) {
exit(1);
}
break;
#ifdef CONFIG_SLIRP
case QEMU_OPTION_tftp:
legacy_tftp_prefix = optarg;
break;
case QEMU_OPTION_bootp:
legacy_bootp_filename = optarg;
break;
case QEMU_OPTION_redir:
if (net_slirp_redir(optarg) < 0)
exit(1);
break;
#endif
case QEMU_OPTION_bt:
add_device_config(DEV_BT, optarg);
break;
case QEMU_OPTION_audio_help:
if (!(audio_available())) {
printf("Option %s not supported for this target\n", popt->name);
exit(1);
}
AUD_help ();
exit (0);
break;
case QEMU_OPTION_soundhw:
if (!(audio_available())) {
printf("Option %s not supported for this target\n", popt->name);
exit(1);
}
select_soundhw (optarg);
break;
case QEMU_OPTION_h:
help(0);
break;
case QEMU_OPTION_version:
version();
exit(0);
break;
case QEMU_OPTION_m: {
int64_t value;
char *end;
value = strtosz(optarg, &end);
if (value < 0 || *end) {
fprintf(stderr, "qemu: invalid ram size: %s\n", optarg);
exit(1);
}
if (value != (uint64_t)(ram_addr_t)value) {
fprintf(stderr, "qemu: ram size too large\n");
exit(1);
}
ram_size = value;
break;
}
case QEMU_OPTION_mempath:
mem_path = optarg;
break;
#ifdef MAP_POPULATE
case QEMU_OPTION_mem_prealloc:
mem_prealloc = 1;
break;
#endif
case QEMU_OPTION_d:
log_mask = optarg;
break;
case QEMU_OPTION_D:
log_file = optarg;
break;
case QEMU_OPTION_s:
gdbstub_dev = "tcp::" DEFAULT_GDBSTUB_PORT;
break;
case QEMU_OPTION_gdb:
gdbstub_dev = optarg;
break;
case QEMU_OPTION_L:
data_dir = optarg;
break;
case QEMU_OPTION_bios:
bios_name = optarg;
break;
case QEMU_OPTION_singlestep:
singlestep = 1;
break;
case QEMU_OPTION_S:
autostart = 0;
break;
case QEMU_OPTION_k:
keyboard_layout = optarg;
break;
case QEMU_OPTION_localtime:
rtc_utc = 0;
break;
case QEMU_OPTION_vga:
select_vgahw (optarg);
break;
case QEMU_OPTION_g:
{
const char *p;
int w, h, depth;
p = optarg;
w = strtol(p, (char **)&p, 10);
if (w <= 0) {
graphic_error:
fprintf(stderr, "qemu: invalid resolution or depth\n");
exit(1);
}
if (*p != 'x')
goto graphic_error;
p++;
h = strtol(p, (char **)&p, 10);
if (h <= 0)
goto graphic_error;
if (*p == 'x') {
p++;
depth = strtol(p, (char **)&p, 10);
if (depth != 8 && depth != 15 && depth != 16 &&
depth != 24 && depth != 32)
goto graphic_error;
} else if (*p == '\0') {
depth = graphic_depth;
} else {
goto graphic_error;
}
graphic_width = w;
graphic_height = h;
graphic_depth = depth;
}
break;
case QEMU_OPTION_echr:
{
char *r;
term_escape_char = strtol(optarg, &r, 0);
if (r == optarg)
printf("Bad argument to echr\n");
break;
}
case QEMU_OPTION_monitor:
monitor_parse(optarg, "readline");
default_monitor = 0;
break;
case QEMU_OPTION_qmp:
monitor_parse(optarg, "control");
default_monitor = 0;
break;
case QEMU_OPTION_mon:
opts = qemu_opts_parse(qemu_find_opts("mon"), optarg, 1);
if (!opts) {
exit(1);
}
default_monitor = 0;
break;
case QEMU_OPTION_chardev:
opts = qemu_opts_parse(qemu_find_opts("chardev"), optarg, 1);
if (!opts) {
exit(1);
}
break;
case QEMU_OPTION_fsdev:
olist = qemu_find_opts("fsdev");
if (!olist) {
fprintf(stderr, "fsdev is not supported by this qemu build.\n");
exit(1);
}
opts = qemu_opts_parse(olist, optarg, 1);
if (!opts) {
fprintf(stderr, "parse error: %s\n", optarg);
exit(1);
}
break;
case QEMU_OPTION_virtfs: {
QemuOpts *fsdev;
QemuOpts *device;
const char *writeout;
olist = qemu_find_opts("virtfs");
if (!olist) {
fprintf(stderr, "virtfs is not supported by this qemu build.\n");
exit(1);
}
opts = qemu_opts_parse(olist, optarg, 1);
if (!opts) {
fprintf(stderr, "parse error: %s\n", optarg);
exit(1);
}
if (qemu_opt_get(opts, "fsdriver") == NULL ||
qemu_opt_get(opts, "mount_tag") == NULL ||
qemu_opt_get(opts, "path") == NULL) {
fprintf(stderr, "Usage: -virtfs fsdriver,path=/share_path/,"
"[security_model={mapped|passthrough|none}],"
"mount_tag=tag.\n");
exit(1);
}
fsdev = qemu_opts_create(qemu_find_opts("fsdev"),
qemu_opt_get(opts, "mount_tag"), 1);
if (!fsdev) {
fprintf(stderr, "duplicate fsdev id: %s\n",
qemu_opt_get(opts, "mount_tag"));
exit(1);
}
writeout = qemu_opt_get(opts, "writeout");
if (writeout) {
#ifdef CONFIG_SYNC_FILE_RANGE
qemu_opt_set(fsdev, "writeout", writeout);
#else
fprintf(stderr, "writeout=immediate not supported on "
"this platform\n");
exit(1);
#endif
}
qemu_opt_set(fsdev, "fsdriver", qemu_opt_get(opts, "fsdriver"));
qemu_opt_set(fsdev, "path", qemu_opt_get(opts, "path"));
qemu_opt_set(fsdev, "security_model",
qemu_opt_get(opts, "security_model"));
qemu_opt_set_bool(fsdev, "readonly",
qemu_opt_get_bool(opts, "readonly", 0));
device = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
qemu_opt_set(device, "driver", "virtio-9p-pci");
qemu_opt_set(device, "fsdev",
qemu_opt_get(opts, "mount_tag"));
qemu_opt_set(device, "mount_tag",
qemu_opt_get(opts, "mount_tag"));
break;
}
case QEMU_OPTION_virtfs_synth: {
QemuOpts *fsdev;
QemuOpts *device;
fsdev = qemu_opts_create(qemu_find_opts("fsdev"), "v_synth", 1);
if (!fsdev) {
fprintf(stderr, "duplicate option: %s\n", "virtfs_synth");
exit(1);
}
qemu_opt_set(fsdev, "fsdriver", "synth");
qemu_opt_set(fsdev, "path", "/");
device = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
qemu_opt_set(device, "driver", "virtio-9p-pci");
qemu_opt_set(device, "fsdev", "v_synth");
qemu_opt_set(device, "mount_tag", "v_synth");
break;
}
case QEMU_OPTION_serial:
add_device_config(DEV_SERIAL, optarg);
default_serial = 0;
if (strncmp(optarg, "mon:", 4) == 0) {
default_monitor = 0;
}
break;
case QEMU_OPTION_watchdog:
if (watchdog) {
fprintf(stderr,
"qemu: only one watchdog option may be given\n");
return 1;
}
watchdog = optarg;
break;
case QEMU_OPTION_watchdog_action:
if (select_watchdog_action(optarg) == -1) {
fprintf(stderr, "Unknown -watchdog-action parameter\n");
exit(1);
}
break;
case QEMU_OPTION_virtiocon:
add_device_config(DEV_VIRTCON, optarg);
default_virtcon = 0;
if (strncmp(optarg, "mon:", 4) == 0) {
default_monitor = 0;
}
break;
case QEMU_OPTION_parallel:
add_device_config(DEV_PARALLEL, optarg);
default_parallel = 0;
if (strncmp(optarg, "mon:", 4) == 0) {
default_monitor = 0;
}
break;
case QEMU_OPTION_debugcon:
add_device_config(DEV_DEBUGCON, optarg);
break;
case QEMU_OPTION_loadvm:
loadvm = optarg;
break;
case QEMU_OPTION_full_screen:
full_screen = 1;
break;
#ifdef CONFIG_SDL
case QEMU_OPTION_no_frame:
no_frame = 1;
break;
case QEMU_OPTION_alt_grab:
alt_grab = 1;
break;
case QEMU_OPTION_ctrl_grab:
ctrl_grab = 1;
break;
case QEMU_OPTION_no_quit:
no_quit = 1;
break;
case QEMU_OPTION_sdl:
display_type = DT_SDL;
break;
#else
case QEMU_OPTION_no_frame:
case QEMU_OPTION_alt_grab:
case QEMU_OPTION_ctrl_grab:
case QEMU_OPTION_no_quit:
case QEMU_OPTION_sdl:
fprintf(stderr, "SDL support is disabled\n");
exit(1);
#endif
case QEMU_OPTION_pidfile:
pid_file = optarg;
break;
case QEMU_OPTION_win2k_hack:
win2k_install_hack = 1;
break;
case QEMU_OPTION_rtc_td_hack:
rtc_td_hack = 1;
break;
case QEMU_OPTION_acpitable:
do_acpitable_option(optarg);
break;
case QEMU_OPTION_smbios:
do_smbios_option(optarg);
break;
case QEMU_OPTION_enable_kvm:
olist = qemu_find_opts("machine");
qemu_opts_reset(olist);
qemu_opts_parse(olist, "accel=kvm", 0);
break;
case QEMU_OPTION_machine:
olist = qemu_find_opts("machine");
qemu_opts_reset(olist);
opts = qemu_opts_parse(olist, optarg, 1);
if (!opts) {
fprintf(stderr, "parse error: %s\n", optarg);
exit(1);
}
optarg = qemu_opt_get(opts, "type");
if (optarg) {
machine = machine_parse(optarg);
}
break;
case QEMU_OPTION_usb:
usb_enabled = 1;
break;
case QEMU_OPTION_usbdevice:
usb_enabled = 1;
add_device_config(DEV_USB, optarg);
break;
case QEMU_OPTION_device:
if (!qemu_opts_parse(qemu_find_opts("device"), optarg, 1)) {
exit(1);
}
break;
case QEMU_OPTION_smp:
smp_parse(optarg);
if (smp_cpus < 1) {
fprintf(stderr, "Invalid number of CPUs\n");
exit(1);
}
if (max_cpus < smp_cpus) {
fprintf(stderr, "maxcpus must be equal to or greater than "
"smp\n");
exit(1);
}
if (max_cpus > 255) {
fprintf(stderr, "Unsupported number of maxcpus\n");
exit(1);
}
break;
case QEMU_OPTION_vnc:
#ifdef CONFIG_VNC
display_remote++;
vnc_display = optarg;
#else
fprintf(stderr, "VNC support is disabled\n");
exit(1);
#endif
break;
case QEMU_OPTION_no_acpi:
acpi_enabled = 0;
break;
case QEMU_OPTION_no_hpet:
no_hpet = 1;
break;
case QEMU_OPTION_balloon:
if (balloon_parse(optarg) < 0) {
fprintf(stderr, "Unknown -balloon argument %s\n", optarg);
exit(1);
}
break;
case QEMU_OPTION_no_reboot:
no_reboot = 1;
break;
case QEMU_OPTION_no_shutdown:
no_shutdown = 1;
break;
case QEMU_OPTION_show_cursor:
cursor_hide = 0;
break;
case QEMU_OPTION_uuid:
if(qemu_uuid_parse(optarg, qemu_uuid) < 0) {
fprintf(stderr, "Fail to parse UUID string."
" Wrong format.\n");
exit(1);
}
break;
case QEMU_OPTION_option_rom:
if (nb_option_roms >= MAX_OPTION_ROMS) {
fprintf(stderr, "Too many option ROMs\n");
exit(1);
}
opts = qemu_opts_parse(qemu_find_opts("option-rom"), optarg, 1);
option_rom[nb_option_roms].name = qemu_opt_get(opts, "romfile");
option_rom[nb_option_roms].bootindex =
qemu_opt_get_number(opts, "bootindex", -1);
if (!option_rom[nb_option_roms].name) {
fprintf(stderr, "Option ROM file is not specified\n");
exit(1);
}
nb_option_roms++;
break;
case QEMU_OPTION_semihosting:
semihosting_enabled = 1;
break;
case QEMU_OPTION_name:
qemu_name = g_strdup(optarg);
{
char *p = strchr(qemu_name, ',');
if (p != NULL) {
*p++ = 0;
if (strncmp(p, "process=", 8)) {
fprintf(stderr, "Unknown subargument %s to -name\n", p);
exit(1);
}
p += 8;
os_set_proc_name(p);
}
}
break;
case QEMU_OPTION_prom_env:
if (nb_prom_envs >= MAX_PROM_ENVS) {
fprintf(stderr, "Too many prom variables\n");
exit(1);
}
prom_envs[nb_prom_envs] = optarg;
nb_prom_envs++;
break;
case QEMU_OPTION_old_param:
old_param = 1;
break;
case QEMU_OPTION_clock:
configure_alarms(optarg);
break;
case QEMU_OPTION_startdate:
configure_rtc_date_offset(optarg, 1);
break;
case QEMU_OPTION_rtc:
opts = qemu_opts_parse(qemu_find_opts("rtc"), optarg, 0);
if (!opts) {
exit(1);
}
configure_rtc(opts);
break;
case QEMU_OPTION_tb_size:
tcg_tb_size = strtol(optarg, NULL, 0);
if (tcg_tb_size < 0) {
tcg_tb_size = 0;
}
break;
case QEMU_OPTION_icount:
icount_option = optarg;
break;
case QEMU_OPTION_incoming:
incoming = optarg;
break;
case QEMU_OPTION_nodefaults:
default_serial = 0;
default_parallel = 0;
default_virtcon = 0;
default_monitor = 0;
default_vga = 0;
default_net = 0;
default_floppy = 0;
default_cdrom = 0;
default_sdcard = 0;
break;
case QEMU_OPTION_xen_domid:
if (!(xen_available())) {
printf("Option %s not supported for this target\n", popt->name);
exit(1);
}
xen_domid = atoi(optarg);
break;
case QEMU_OPTION_xen_create:
if (!(xen_available())) {
printf("Option %s not supported for this target\n", popt->name);
exit(1);
}
xen_mode = XEN_CREATE;
break;
case QEMU_OPTION_xen_attach:
if (!(xen_available())) {
printf("Option %s not supported for this target\n", popt->name);
exit(1);
}
xen_mode = XEN_ATTACH;
break;
case QEMU_OPTION_trace:
{
opts = qemu_opts_parse(qemu_find_opts("trace"), optarg, 0);
if (!opts) {
exit(1);
}
trace_events = qemu_opt_get(opts, "events");
trace_file = qemu_opt_get(opts, "file");
break;
}
case QEMU_OPTION_readconfig:
{
int ret = qemu_read_config_file(optarg);
if (ret < 0) {
fprintf(stderr, "read config %s: %s\n", optarg,
strerror(-ret));
exit(1);
}
break;
}
case QEMU_OPTION_spice:
olist = qemu_find_opts("spice");
if (!olist) {
fprintf(stderr, "spice is not supported by this qemu build.\n");
exit(1);
}
opts = qemu_opts_parse(olist, optarg, 0);
if (!opts) {
fprintf(stderr, "parse error: %s\n", optarg);
exit(1);
}
break;
case QEMU_OPTION_writeconfig:
{
FILE *fp;
if (strcmp(optarg, "-") == 0) {
fp = stdout;
} else {
fp = fopen(optarg, "w");
if (fp == NULL) {
fprintf(stderr, "open %s: %s\n", optarg, strerror(errno));
exit(1);
}
}
qemu_config_write(fp);
fclose(fp);
break;
}
default:
os_parse_cmd_args(popt->index, optarg);
}
}
}
loc_set_none();
if (log_mask) {
if (log_file) {
set_cpu_log_filename(log_file);
}
set_cpu_log(log_mask);
}
if (!trace_backend_init(trace_events, trace_file)) {
exit(1);
}
if (!data_dir) {
data_dir = os_find_datadir(argv[0]);
}
if (!data_dir) {
data_dir = CONFIG_QEMU_DATADIR;
}
if (machine == NULL) {
fprintf(stderr, "No machine found.\n");
exit(1);
}
if (!max_cpus)
max_cpus = smp_cpus;
machine->max_cpus = machine->max_cpus ?: 1;
if (smp_cpus > machine->max_cpus) {
fprintf(stderr, "Number of SMP cpus requested (%d), exceeds max cpus "
"supported by machine `%s' (%d)\n", smp_cpus, machine->name,
machine->max_cpus);
exit(1);
}
if (machine->default_machine_opts) {
QemuOptsList *list = qemu_find_opts("machine");
const char *p = NULL;
if (!QTAILQ_EMPTY(&list->head)) {
p = qemu_opt_get(QTAILQ_FIRST(&list->head), "accel");
}
if (p == NULL) {
qemu_opts_reset(list);
opts = qemu_opts_parse(list, machine->default_machine_opts, 0);
if (!opts) {
fprintf(stderr, "parse error for machine %s: %s\n",
machine->name, machine->default_machine_opts);
exit(1);
}
}
}
qemu_opts_foreach(qemu_find_opts("device"), default_driver_check, NULL, 0);
qemu_opts_foreach(qemu_find_opts("global"), default_driver_check, NULL, 0);
if (machine->no_serial) {
default_serial = 0;
}
if (machine->no_parallel) {
default_parallel = 0;
}
if (!machine->use_virtcon) {
default_virtcon = 0;
}
if (machine->no_vga) {
default_vga = 0;
}
if (machine->no_floppy) {
default_floppy = 0;
}
if (machine->no_cdrom) {
default_cdrom = 0;
}
if (machine->no_sdcard) {
default_sdcard = 0;
}
if (display_type == DT_NOGRAPHIC) {
if (default_parallel)
add_device_config(DEV_PARALLEL, "null");
if (default_serial && default_monitor) {
add_device_config(DEV_SERIAL, "mon:stdio");
} else if (default_virtcon && default_monitor) {
add_device_config(DEV_VIRTCON, "mon:stdio");
} else {
if (default_serial)
add_device_config(DEV_SERIAL, "stdio");
if (default_virtcon)
add_device_config(DEV_VIRTCON, "stdio");
if (default_monitor)
monitor_parse("stdio", "readline");
}
} else {
if (default_serial)
add_device_config(DEV_SERIAL, "vc:80Cx24C");
if (default_parallel)
add_device_config(DEV_PARALLEL, "vc:80Cx24C");
if (default_monitor)
monitor_parse("vc:80Cx24C", "readline");
if (default_virtcon)
add_device_config(DEV_VIRTCON, "vc:80Cx24C");
}
if (default_vga)
vga_interface_type = VGA_CIRRUS;
socket_init();
if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func, NULL, 1) != 0)
exit(1);
#ifdef CONFIG_VIRTFS
if (qemu_opts_foreach(qemu_find_opts("fsdev"), fsdev_init_func, NULL, 1) != 0) {
exit(1);
}
#endif
os_daemonize();
if (pid_file && qemu_create_pidfile(pid_file) != 0) {
os_pidfile_error();
exit(1);
}
if (ram_size == 0) {
ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
}
configure_accelerator();
qemu_init_cpu_loop();
if (qemu_init_main_loop()) {
fprintf(stderr, "qemu_init_main_loop failed\n");
exit(1);
}
linux_boot = (kernel_filename != NULL);
if (!linux_boot && *kernel_cmdline != '\0') {
fprintf(stderr, "-append only allowed with -kernel option\n");
exit(1);
}
if (!linux_boot && initrd_filename != NULL) {
fprintf(stderr, "-initrd only allowed with -kernel option\n");
exit(1);
}
os_set_line_buffering();
if (init_timer_alarm() < 0) {
fprintf(stderr, "could not initialize alarm timer\n");
exit(1);
}
if (icount_option && (kvm_enabled() || xen_enabled())) {
fprintf(stderr, "-icount is not allowed with kvm or xen\n");
exit(1);
}
configure_icount(icount_option);
if (net_init_clients() < 0) {
exit(1);
}
if (foreach_device_config(DEV_BT, bt_parse))
exit(1);
if (!xen_enabled()) {
if (ram_size > (2047 << 20) && HOST_LONG_BITS == 32) {
fprintf(stderr, "qemu: at most 2047 MB RAM can be simulated\n");
exit(1);
}
}
cpu_exec_init_all();
bdrv_init_with_whitelist();
blk_mig_init();
if (snapshot)
qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot, NULL, 0);
if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func, &machine->use_scsi, 1) != 0)
exit(1);
default_drive(default_cdrom, snapshot, machine->use_scsi,
IF_DEFAULT, 2, CDROM_OPTS);
default_drive(default_floppy, snapshot, machine->use_scsi,
IF_FLOPPY, 0, FD_OPTS);
default_drive(default_sdcard, snapshot, machine->use_scsi,
IF_SD, 0, SD_OPTS);
register_savevm_live(NULL, "ram", 0, 4, NULL, ram_save_live, NULL,
ram_load, NULL);
if (nb_numa_nodes > 0) {
int i;
if (nb_numa_nodes > MAX_NODES) {
nb_numa_nodes = MAX_NODES;
}
for (i = 0; i < nb_numa_nodes; i++) {
if (node_mem[i] != 0)
break;
}
if (i == nb_numa_nodes) {
uint64_t usedmem = 0;
for (i = 0; i < nb_numa_nodes - 1; i++) {
node_mem[i] = (ram_size / nb_numa_nodes) & ~((1 << 23UL) - 1);
usedmem += node_mem[i];
}
node_mem[i] = ram_size - usedmem;
}
for (i = 0; i < nb_numa_nodes; i++) {
if (node_cpumask[i] != 0)
break;
}
if (i == nb_numa_nodes) {
for (i = 0; i < max_cpus; i++) {
node_cpumask[i % nb_numa_nodes] |= 1 << i;
}
}
}
if (qemu_opts_foreach(qemu_find_opts("mon"), mon_init_func, NULL, 1) != 0) {
exit(1);
}
if (foreach_device_config(DEV_SERIAL, serial_parse) < 0)
exit(1);
if (foreach_device_config(DEV_PARALLEL, parallel_parse) < 0)
exit(1);
if (foreach_device_config(DEV_VIRTCON, virtcon_parse) < 0)
exit(1);
if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0)
exit(1);
module_call_init(MODULE_INIT_DEVICE);
if (qemu_opts_foreach(qemu_find_opts("device"), device_help_func, NULL, 0) != 0)
exit(0);
if (watchdog) {
i = select_watchdog(watchdog);
if (i > 0)
exit (i == 1 ? 1 : 0);
}
if (machine->compat_props) {
qdev_prop_register_global_list(machine->compat_props);
}
qemu_add_globals();
qdev_machine_init();
machine->init(ram_size, boot_devices,
kernel_filename, kernel_cmdline, initrd_filename, cpu_model);
cpu_synchronize_all_post_init();
set_numa_modes();
current_machine = machine;
if (usb_enabled) {
if (foreach_device_config(DEV_USB, usb_parse) < 0)
exit(1);
}
if (qemu_opts_foreach(qemu_find_opts("device"), device_init_func, NULL, 1) != 0)
exit(1);
net_check_clients();
ds = get_displaystate();
if (using_spice)
display_remote++;
if (display_type == DT_DEFAULT && !display_remote) {
#if defined(CONFIG_SDL) || defined(CONFIG_COCOA)
display_type = DT_SDL;
#elif defined(CONFIG_VNC)
vnc_display = "localhost:0,to=99";
show_vnc_port = 1;
#else
display_type = DT_NONE;
#endif
}
switch (display_type) {
case DT_NOGRAPHIC:
break;
#if defined(CONFIG_CURSES)
case DT_CURSES:
curses_display_init(ds, full_screen);
break;
#endif
#if defined(CONFIG_SDL)
case DT_SDL:
sdl_display_init(ds, full_screen, no_frame);
break;
#elif defined(CONFIG_COCOA)
case DT_SDL:
cocoa_display_init(ds, full_screen);
break;
#endif
default:
break;
}
os_setup_signal_handling();
#ifdef CONFIG_VNC
if (vnc_display) {
vnc_display_init(ds);
if (vnc_display_open(ds, vnc_display) < 0)
exit(1);
if (show_vnc_port) {
printf("VNC server running on `%s'\n", vnc_display_local_addr(ds));
}
}
#endif
#ifdef CONFIG_SPICE
if (using_spice && !qxl_enabled) {
qemu_spice_display_init(ds);
}
#endif
dpy_resize(ds);
dcl = ds->listeners;
while (dcl != NULL) {
if (dcl->dpy_refresh != NULL) {
ds->gui_timer = qemu_new_timer_ms(rt_clock, gui_update, ds);
qemu_mod_timer(ds->gui_timer, qemu_get_clock_ms(rt_clock));
break;
}
dcl = dcl->next;
}
text_consoles_set_display(ds);
if (gdbstub_dev && gdbserver_start(gdbstub_dev) < 0) {
fprintf(stderr, "qemu: could not open gdbserver on device '%s'\n",
gdbstub_dev);
exit(1);
}
qdev_machine_creation_done();
if (rom_load_all() != 0) {
fprintf(stderr, "rom loading failed\n");
exit(1);
}
qemu_register_reset(qbus_reset_all_fn, sysbus_get_default());
qemu_run_machine_init_done_notifiers();
qemu_system_reset(VMRESET_SILENT);
if (loadvm) {
if (load_vmstate(loadvm) < 0) {
autostart = 0;
}
}
if (incoming) {
runstate_set(RUN_STATE_INMIGRATE);
int ret = qemu_start_incoming_migration(incoming);
if (ret < 0) {
fprintf(stderr, "Migration failed. Exit code %s(%d), exiting.\n",
incoming, ret);
exit(ret);
}
} else if (autostart) {
vm_start();
}
os_setup_post();
resume_all_vcpus();
main_loop();
bdrv_close_all();
pause_all_vcpus();
net_cleanup();
res_free();
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(int VAR_0, char **VAR_1, char **VAR_2)
{
const char *VAR_3 = NULL;
int VAR_41;
int VAR_5, VAR_6;
const char *VAR_7 = NULL;
const char *VAR_8;
const char *VAR_9, *VAR_10;
char VAR_11[33] = "cad";
DisplayState *ds;
DisplayChangeListener *dcl;
int VAR_12, VAR_13, VAR_14, VAR_15;
QemuOpts *hda_opts = NULL, *opts;
QemuOptsList *olist;
int VAR_16;
const char *VAR_17;
const char *VAR_18 = NULL;
QEMUMachine *machine;
const char *VAR_19;
const char *VAR_20 = NULL;
const char *VAR_21 = NULL;
#ifdef CONFIG_VNC
int show_vnc_port = 0;
#endif
int VAR_22 = 1;
const char *VAR_23 = NULL;
const char *VAR_24 = NULL;
GMemVTable mem_trace = {
.malloc = malloc_and_trace,
.realloc = realloc_and_trace,
.free = free_and_trace,
};
const char *VAR_25 = NULL;
const char *VAR_26 = NULL;
atexit(qemu_run_exit_notifiers);
error_set_progname(VAR_1[0]);
g_mem_set_vtable(&mem_trace);
if (!g_thread_supported()) {
#if !GLIB_CHECK_VERSION(2, 31, 0)
g_thread_init(NULL);
#else
fprintf(stderr, "glib threading failed to initialize.\n");
exit(1);
#endif
}
runstate_init();
init_clocks();
rtc_clock = host_clock;
qemu_cache_utils_init(VAR_2);
QLIST_INIT (&vm_change_state_head);
os_setup_early_signal_handling();
module_call_init(MODULE_INIT_MACHINE);
machine = find_default_machine();
VAR_19 = NULL;
VAR_8 = NULL;
ram_size = 0;
VAR_5 = 0;
VAR_9 = NULL;
VAR_10 = "";
VAR_12 = VAR_13 = VAR_14 = 0;
VAR_15 = BIOS_ATA_TRANSLATION_AUTO;
for (VAR_41 = 0; VAR_41 < MAX_NODES; VAR_41++) {
node_mem[VAR_41] = 0;
node_cpumask[VAR_41] = 0;
}
nb_numa_nodes = 0;
nb_nics = 0;
autostart= 1;
VAR_16 = 1;
while (VAR_16 < VAR_0) {
if (VAR_1[VAR_16][0] != '-') {
VAR_16++;
continue;
} else {
const QEMUOption *VAR_29;
VAR_29 = lookup_opt(VAR_0, VAR_1, &VAR_17, &VAR_16);
switch (VAR_29->index) {
case QEMU_OPTION_nodefconfig:
VAR_22=0;
break;
}
}
}
if (VAR_22) {
int VAR_41;
VAR_41 = qemu_read_config_file(CONFIG_QEMU_CONFDIR "/qemu.conf");
if (VAR_41 < 0 && VAR_41 != -ENOENT) {
exit(1);
}
VAR_41 = qemu_read_config_file(arch_config_name);
if (VAR_41 < 0 && VAR_41 != -ENOENT) {
exit(1);
}
}
cpudef_init();
VAR_16 = 1;
for(;;) {
if (VAR_16 >= VAR_0)
break;
if (VAR_1[VAR_16][0] != '-') {
hda_opts = drive_add(IF_DEFAULT, 0, VAR_1[VAR_16++], HD_OPTS);
} else {
const QEMUOption *VAR_29;
VAR_29 = lookup_opt(VAR_0, VAR_1, &VAR_17, &VAR_16);
if (!(VAR_29->arch_mask & arch_type)) {
printf("Option %s not supported for this target\n", VAR_29->name);
exit(1);
}
switch(VAR_29->index) {
case QEMU_OPTION_M:
machine = machine_parse(VAR_17);
break;
case QEMU_OPTION_cpu:
if (*VAR_17 == '?') {
list_cpus(stdout, &fprintf, VAR_17);
exit(0);
} else {
VAR_19 = VAR_17;
}
break;
case QEMU_OPTION_initrd:
VAR_8 = VAR_17;
break;
case QEMU_OPTION_hda:
{
char VAR_33[256];
if (VAR_12 == 0)
snprintf(VAR_33, sizeof(VAR_33), "%s", HD_OPTS);
else
snprintf(VAR_33, sizeof(VAR_33),
"%s,VAR_12=%d,VAR_13=%d,VAR_14=%d%s",
HD_OPTS , VAR_12, VAR_13, VAR_14,
VAR_15 == BIOS_ATA_TRANSLATION_LBA ?
",trans=lba" :
VAR_15 == BIOS_ATA_TRANSLATION_NONE ?
",trans=none" : "");
drive_add(IF_DEFAULT, 0, VAR_17, VAR_33);
break;
}
case QEMU_OPTION_hdb:
case QEMU_OPTION_hdc:
case QEMU_OPTION_hdd:
drive_add(IF_DEFAULT, VAR_29->index - QEMU_OPTION_hda, VAR_17,
HD_OPTS);
break;
case QEMU_OPTION_drive:
if (drive_def(VAR_17) == NULL) {
exit(1);
}
break;
case QEMU_OPTION_set:
if (qemu_set_option(VAR_17) != 0)
exit(1);
break;
case QEMU_OPTION_global:
if (qemu_global_option(VAR_17) != 0)
exit(1);
break;
case QEMU_OPTION_mtdblock:
drive_add(IF_MTD, -1, VAR_17, MTD_OPTS);
break;
case QEMU_OPTION_sd:
drive_add(IF_SD, 0, VAR_17, SD_OPTS);
break;
case QEMU_OPTION_pflash:
drive_add(IF_PFLASH, -1, VAR_17, PFLASH_OPTS);
break;
case QEMU_OPTION_snapshot:
VAR_5 = 1;
break;
case QEMU_OPTION_hdachs:
{
const char *VAR_41;
VAR_41 = VAR_17;
VAR_12 = strtol(VAR_41, (char **)&VAR_41, 0);
if (VAR_12 < 1 || VAR_12 > 16383)
goto chs_fail;
if (*VAR_41 != ',')
goto chs_fail;
VAR_41++;
VAR_13 = strtol(VAR_41, (char **)&VAR_41, 0);
if (VAR_13 < 1 || VAR_13 > 16)
goto chs_fail;
if (*VAR_41 != ',')
goto chs_fail;
VAR_41++;
VAR_14 = strtol(VAR_41, (char **)&VAR_41, 0);
if (VAR_14 < 1 || VAR_14 > 63)
goto chs_fail;
if (*VAR_41 == ',') {
VAR_41++;
if (!strcmp(VAR_41, "none"))
VAR_15 = BIOS_ATA_TRANSLATION_NONE;
else if (!strcmp(VAR_41, "lba"))
VAR_15 = BIOS_ATA_TRANSLATION_LBA;
else if (!strcmp(VAR_41, "auto"))
VAR_15 = BIOS_ATA_TRANSLATION_AUTO;
else
goto chs_fail;
} else if (*VAR_41 != '\0') {
chs_fail:
fprintf(stderr, "qemu: invalid physical CHS format\n");
exit(1);
}
if (hda_opts != NULL) {
char VAR_31[16];
snprintf(VAR_31, sizeof(VAR_31), "%d", VAR_12);
qemu_opt_set(hda_opts, "VAR_12", VAR_31);
snprintf(VAR_31, sizeof(VAR_31), "%d", VAR_13);
qemu_opt_set(hda_opts, "VAR_13", VAR_31);
snprintf(VAR_31, sizeof(VAR_31), "%d", VAR_14);
qemu_opt_set(hda_opts, "VAR_14", VAR_31);
if (VAR_15 == BIOS_ATA_TRANSLATION_LBA)
qemu_opt_set(hda_opts, "trans", "lba");
if (VAR_15 == BIOS_ATA_TRANSLATION_NONE)
qemu_opt_set(hda_opts, "trans", "none");
}
}
break;
case QEMU_OPTION_numa:
if (nb_numa_nodes >= MAX_NODES) {
fprintf(stderr, "qemu: too many NUMA nodes\n");
exit(1);
}
numa_add(VAR_17);
break;
case QEMU_OPTION_display:
display_type = select_display(VAR_17);
break;
case QEMU_OPTION_nographic:
display_type = DT_NOGRAPHIC;
break;
case QEMU_OPTION_curses:
#ifdef CONFIG_CURSES
display_type = DT_CURSES;
#else
fprintf(stderr, "Curses support is disabled\n");
exit(1);
#endif
break;
case QEMU_OPTION_portrait:
graphic_rotate = 90;
break;
case QEMU_OPTION_rotate:
graphic_rotate = strtol(VAR_17, (char **) &VAR_17, 10);
if (graphic_rotate != 0 && graphic_rotate != 90 &&
graphic_rotate != 180 && graphic_rotate != 270) {
fprintf(stderr,
"qemu: only 90, 180, 270 deg rotation is available\n");
exit(1);
}
break;
case QEMU_OPTION_kernel:
VAR_9 = VAR_17;
break;
case QEMU_OPTION_append:
VAR_10 = VAR_17;
break;
case QEMU_OPTION_cdrom:
drive_add(IF_DEFAULT, 2, VAR_17, CDROM_OPTS);
break;
case QEMU_OPTION_boot:
{
static const char * const VAR_32[] = {
"order", "once", "menu",
"splash", "splash-time", NULL
};
char VAR_33[sizeof(VAR_11)];
char *VAR_33;
int VAR_34 = 0;
if (!strchr(VAR_17, '=')) {
VAR_34 = 1;
pstrcpy(VAR_33, sizeof(VAR_33), VAR_17);
} else if (check_params(VAR_33, sizeof(VAR_33), VAR_32, VAR_17) < 0) {
fprintf(stderr,
"qemu: unknown boot parameter '%s' in '%s'\n",
VAR_33, VAR_17);
exit(1);
}
if (VAR_34 ||
get_param_value(VAR_33, sizeof(VAR_33), "order", VAR_17)) {
validate_bootdevices(VAR_33);
pstrcpy(VAR_11, sizeof(VAR_11), VAR_33);
}
if (!VAR_34) {
if (get_param_value(VAR_33, sizeof(VAR_33),
"once", VAR_17)) {
validate_bootdevices(VAR_33);
VAR_33 = g_strdup(VAR_11);
pstrcpy(VAR_11, sizeof(VAR_11), VAR_33);
qemu_register_reset(restore_boot_devices,
VAR_33);
}
if (get_param_value(VAR_33, sizeof(VAR_33),
"menu", VAR_17)) {
if (!strcmp(VAR_33, "on")) {
boot_menu = 1;
} else if (!strcmp(VAR_33, "off")) {
boot_menu = 0;
} else {
fprintf(stderr,
"qemu: invalid option value '%s'\n",
VAR_33);
exit(1);
}
}
qemu_opts_parse(qemu_find_opts("boot-opts"),
VAR_17, 0);
}
}
break;
case QEMU_OPTION_fda:
case QEMU_OPTION_fdb:
drive_add(IF_FLOPPY, VAR_29->index - QEMU_OPTION_fda,
VAR_17, FD_OPTS);
break;
case QEMU_OPTION_no_fd_bootchk:
fd_bootchk = 0;
break;
case QEMU_OPTION_netdev:
if (net_client_parse(qemu_find_opts("netdev"), VAR_17) == -1) {
exit(1);
}
break;
case QEMU_OPTION_net:
if (net_client_parse(qemu_find_opts("net"), VAR_17) == -1) {
exit(1);
}
break;
#ifdef CONFIG_SLIRP
case QEMU_OPTION_tftp:
legacy_tftp_prefix = VAR_17;
break;
case QEMU_OPTION_bootp:
legacy_bootp_filename = VAR_17;
break;
case QEMU_OPTION_redir:
if (net_slirp_redir(VAR_17) < 0)
exit(1);
break;
#endif
case QEMU_OPTION_bt:
add_device_config(DEV_BT, VAR_17);
break;
case QEMU_OPTION_audio_help:
if (!(audio_available())) {
printf("Option %s not supported for this target\n", VAR_29->name);
exit(1);
}
AUD_help ();
exit (0);
break;
case QEMU_OPTION_soundhw:
if (!(audio_available())) {
printf("Option %s not supported for this target\n", VAR_29->name);
exit(1);
}
select_soundhw (VAR_17);
break;
case QEMU_OPTION_h:
help(0);
break;
case QEMU_OPTION_version:
version();
exit(0);
break;
case QEMU_OPTION_m: {
int64_t value;
char *VAR_35;
value = strtosz(VAR_17, &VAR_35);
if (value < 0 || *VAR_35) {
fprintf(stderr, "qemu: invalid ram size: %s\n", VAR_17);
exit(1);
}
if (value != (uint64_t)(ram_addr_t)value) {
fprintf(stderr, "qemu: ram size too large\n");
exit(1);
}
ram_size = value;
break;
}
case QEMU_OPTION_mempath:
mem_path = VAR_17;
break;
#ifdef MAP_POPULATE
case QEMU_OPTION_mem_prealloc:
mem_prealloc = 1;
break;
#endif
case QEMU_OPTION_d:
VAR_23 = VAR_17;
break;
case QEMU_OPTION_D:
VAR_24 = VAR_17;
break;
case QEMU_OPTION_s:
VAR_3 = "tcp::" DEFAULT_GDBSTUB_PORT;
break;
case QEMU_OPTION_gdb:
VAR_3 = VAR_17;
break;
case QEMU_OPTION_L:
data_dir = VAR_17;
break;
case QEMU_OPTION_bios:
bios_name = VAR_17;
break;
case QEMU_OPTION_singlestep:
singlestep = 1;
break;
case QEMU_OPTION_S:
autostart = 0;
break;
case QEMU_OPTION_k:
keyboard_layout = VAR_17;
break;
case QEMU_OPTION_localtime:
rtc_utc = 0;
break;
case QEMU_OPTION_vga:
select_vgahw (VAR_17);
break;
case QEMU_OPTION_g:
{
const char *VAR_41;
int VAR_36, VAR_37, VAR_38;
VAR_41 = VAR_17;
VAR_36 = strtol(VAR_41, (char **)&VAR_41, 10);
if (VAR_36 <= 0) {
graphic_error:
fprintf(stderr, "qemu: invalid resolution or VAR_38\n");
exit(1);
}
if (*VAR_41 != 'x')
goto graphic_error;
VAR_41++;
VAR_37 = strtol(VAR_41, (char **)&VAR_41, 10);
if (VAR_37 <= 0)
goto graphic_error;
if (*VAR_41 == 'x') {
VAR_41++;
VAR_38 = strtol(VAR_41, (char **)&VAR_41, 10);
if (VAR_38 != 8 && VAR_38 != 15 && VAR_38 != 16 &&
VAR_38 != 24 && VAR_38 != 32)
goto graphic_error;
} else if (*VAR_41 == '\0') {
VAR_38 = graphic_depth;
} else {
goto graphic_error;
}
graphic_width = VAR_36;
graphic_height = VAR_37;
graphic_depth = VAR_38;
}
break;
case QEMU_OPTION_echr:
{
char *VAR_39;
term_escape_char = strtol(VAR_17, &VAR_39, 0);
if (VAR_39 == VAR_17)
printf("Bad argument to echr\n");
break;
}
case QEMU_OPTION_monitor:
monitor_parse(VAR_17, "readline");
default_monitor = 0;
break;
case QEMU_OPTION_qmp:
monitor_parse(VAR_17, "control");
default_monitor = 0;
break;
case QEMU_OPTION_mon:
opts = qemu_opts_parse(qemu_find_opts("mon"), VAR_17, 1);
if (!opts) {
exit(1);
}
default_monitor = 0;
break;
case QEMU_OPTION_chardev:
opts = qemu_opts_parse(qemu_find_opts("chardev"), VAR_17, 1);
if (!opts) {
exit(1);
}
break;
case QEMU_OPTION_fsdev:
olist = qemu_find_opts("fsdev");
if (!olist) {
fprintf(stderr, "fsdev is not supported by this qemu build.\n");
exit(1);
}
opts = qemu_opts_parse(olist, VAR_17, 1);
if (!opts) {
fprintf(stderr, "parse error: %s\n", VAR_17);
exit(1);
}
break;
case QEMU_OPTION_virtfs: {
QemuOpts *fsdev;
QemuOpts *device;
const char *VAR_40;
olist = qemu_find_opts("virtfs");
if (!olist) {
fprintf(stderr, "virtfs is not supported by this qemu build.\n");
exit(1);
}
opts = qemu_opts_parse(olist, VAR_17, 1);
if (!opts) {
fprintf(stderr, "parse error: %s\n", VAR_17);
exit(1);
}
if (qemu_opt_get(opts, "fsdriver") == NULL ||
qemu_opt_get(opts, "mount_tag") == NULL ||
qemu_opt_get(opts, "path") == NULL) {
fprintf(stderr, "Usage: -virtfs fsdriver,path=/share_path/,"
"[security_model={mapped|passthrough|none}],"
"mount_tag=tag.\n");
exit(1);
}
fsdev = qemu_opts_create(qemu_find_opts("fsdev"),
qemu_opt_get(opts, "mount_tag"), 1);
if (!fsdev) {
fprintf(stderr, "duplicate fsdev id: %s\n",
qemu_opt_get(opts, "mount_tag"));
exit(1);
}
VAR_40 = qemu_opt_get(opts, "VAR_40");
if (VAR_40) {
#ifdef CONFIG_SYNC_FILE_RANGE
qemu_opt_set(fsdev, "VAR_40", VAR_40);
#else
fprintf(stderr, "VAR_40=immediate not supported on "
"this platform\n");
exit(1);
#endif
}
qemu_opt_set(fsdev, "fsdriver", qemu_opt_get(opts, "fsdriver"));
qemu_opt_set(fsdev, "path", qemu_opt_get(opts, "path"));
qemu_opt_set(fsdev, "security_model",
qemu_opt_get(opts, "security_model"));
qemu_opt_set_bool(fsdev, "readonly",
qemu_opt_get_bool(opts, "readonly", 0));
device = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
qemu_opt_set(device, "driver", "virtio-9p-pci");
qemu_opt_set(device, "fsdev",
qemu_opt_get(opts, "mount_tag"));
qemu_opt_set(device, "mount_tag",
qemu_opt_get(opts, "mount_tag"));
break;
}
case QEMU_OPTION_virtfs_synth: {
QemuOpts *fsdev;
QemuOpts *device;
fsdev = qemu_opts_create(qemu_find_opts("fsdev"), "v_synth", 1);
if (!fsdev) {
fprintf(stderr, "duplicate option: %s\n", "virtfs_synth");
exit(1);
}
qemu_opt_set(fsdev, "fsdriver", "synth");
qemu_opt_set(fsdev, "path", "/");
device = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
qemu_opt_set(device, "driver", "virtio-9p-pci");
qemu_opt_set(device, "fsdev", "v_synth");
qemu_opt_set(device, "mount_tag", "v_synth");
break;
}
case QEMU_OPTION_serial:
add_device_config(DEV_SERIAL, VAR_17);
default_serial = 0;
if (strncmp(VAR_17, "mon:", 4) == 0) {
default_monitor = 0;
}
break;
case QEMU_OPTION_watchdog:
if (watchdog) {
fprintf(stderr,
"qemu: only one watchdog option may be given\n");
return 1;
}
watchdog = VAR_17;
break;
case QEMU_OPTION_watchdog_action:
if (select_watchdog_action(VAR_17) == -1) {
fprintf(stderr, "Unknown -watchdog-action parameter\n");
exit(1);
}
break;
case QEMU_OPTION_virtiocon:
add_device_config(DEV_VIRTCON, VAR_17);
default_virtcon = 0;
if (strncmp(VAR_17, "mon:", 4) == 0) {
default_monitor = 0;
}
break;
case QEMU_OPTION_parallel:
add_device_config(DEV_PARALLEL, VAR_17);
default_parallel = 0;
if (strncmp(VAR_17, "mon:", 4) == 0) {
default_monitor = 0;
}
break;
case QEMU_OPTION_debugcon:
add_device_config(DEV_DEBUGCON, VAR_17);
break;
case QEMU_OPTION_loadvm:
VAR_18 = VAR_17;
break;
case QEMU_OPTION_full_screen:
full_screen = 1;
break;
#ifdef CONFIG_SDL
case QEMU_OPTION_no_frame:
no_frame = 1;
break;
case QEMU_OPTION_alt_grab:
alt_grab = 1;
break;
case QEMU_OPTION_ctrl_grab:
ctrl_grab = 1;
break;
case QEMU_OPTION_no_quit:
no_quit = 1;
break;
case QEMU_OPTION_sdl:
display_type = DT_SDL;
break;
#else
case QEMU_OPTION_no_frame:
case QEMU_OPTION_alt_grab:
case QEMU_OPTION_ctrl_grab:
case QEMU_OPTION_no_quit:
case QEMU_OPTION_sdl:
fprintf(stderr, "SDL support is disabled\n");
exit(1);
#endif
case QEMU_OPTION_pidfile:
VAR_20 = VAR_17;
break;
case QEMU_OPTION_win2k_hack:
win2k_install_hack = 1;
break;
case QEMU_OPTION_rtc_td_hack:
rtc_td_hack = 1;
break;
case QEMU_OPTION_acpitable:
do_acpitable_option(VAR_17);
break;
case QEMU_OPTION_smbios:
do_smbios_option(VAR_17);
break;
case QEMU_OPTION_enable_kvm:
olist = qemu_find_opts("machine");
qemu_opts_reset(olist);
qemu_opts_parse(olist, "accel=kvm", 0);
break;
case QEMU_OPTION_machine:
olist = qemu_find_opts("machine");
qemu_opts_reset(olist);
opts = qemu_opts_parse(olist, VAR_17, 1);
if (!opts) {
fprintf(stderr, "parse error: %s\n", VAR_17);
exit(1);
}
VAR_17 = qemu_opt_get(opts, "type");
if (VAR_17) {
machine = machine_parse(VAR_17);
}
break;
case QEMU_OPTION_usb:
usb_enabled = 1;
break;
case QEMU_OPTION_usbdevice:
usb_enabled = 1;
add_device_config(DEV_USB, VAR_17);
break;
case QEMU_OPTION_device:
if (!qemu_opts_parse(qemu_find_opts("device"), VAR_17, 1)) {
exit(1);
}
break;
case QEMU_OPTION_smp:
smp_parse(VAR_17);
if (smp_cpus < 1) {
fprintf(stderr, "Invalid number of CPUs\n");
exit(1);
}
if (max_cpus < smp_cpus) {
fprintf(stderr, "maxcpus must be equal to or greater than "
"smp\n");
exit(1);
}
if (max_cpus > 255) {
fprintf(stderr, "Unsupported number of maxcpus\n");
exit(1);
}
break;
case QEMU_OPTION_vnc:
#ifdef CONFIG_VNC
display_remote++;
vnc_display = VAR_17;
#else
fprintf(stderr, "VNC support is disabled\n");
exit(1);
#endif
break;
case QEMU_OPTION_no_acpi:
acpi_enabled = 0;
break;
case QEMU_OPTION_no_hpet:
no_hpet = 1;
break;
case QEMU_OPTION_balloon:
if (balloon_parse(VAR_17) < 0) {
fprintf(stderr, "Unknown -balloon argument %s\n", VAR_17);
exit(1);
}
break;
case QEMU_OPTION_no_reboot:
no_reboot = 1;
break;
case QEMU_OPTION_no_shutdown:
no_shutdown = 1;
break;
case QEMU_OPTION_show_cursor:
cursor_hide = 0;
break;
case QEMU_OPTION_uuid:
if(qemu_uuid_parse(VAR_17, qemu_uuid) < 0) {
fprintf(stderr, "Fail to parse UUID string."
" Wrong format.\n");
exit(1);
}
break;
case QEMU_OPTION_option_rom:
if (nb_option_roms >= MAX_OPTION_ROMS) {
fprintf(stderr, "Too many option ROMs\n");
exit(1);
}
opts = qemu_opts_parse(qemu_find_opts("option-rom"), VAR_17, 1);
option_rom[nb_option_roms].name = qemu_opt_get(opts, "romfile");
option_rom[nb_option_roms].bootindex =
qemu_opt_get_number(opts, "bootindex", -1);
if (!option_rom[nb_option_roms].name) {
fprintf(stderr, "Option ROM file is not specified\n");
exit(1);
}
nb_option_roms++;
break;
case QEMU_OPTION_semihosting:
semihosting_enabled = 1;
break;
case QEMU_OPTION_name:
qemu_name = g_strdup(VAR_17);
{
char *VAR_41 = strchr(qemu_name, ',');
if (VAR_41 != NULL) {
*VAR_41++ = 0;
if (strncmp(VAR_41, "process=", 8)) {
fprintf(stderr, "Unknown subargument %s to -name\n", VAR_41);
exit(1);
}
VAR_41 += 8;
os_set_proc_name(VAR_41);
}
}
break;
case QEMU_OPTION_prom_env:
if (nb_prom_envs >= MAX_PROM_ENVS) {
fprintf(stderr, "Too many prom variables\n");
exit(1);
}
prom_envs[nb_prom_envs] = VAR_17;
nb_prom_envs++;
break;
case QEMU_OPTION_old_param:
old_param = 1;
break;
case QEMU_OPTION_clock:
configure_alarms(VAR_17);
break;
case QEMU_OPTION_startdate:
configure_rtc_date_offset(VAR_17, 1);
break;
case QEMU_OPTION_rtc:
opts = qemu_opts_parse(qemu_find_opts("rtc"), VAR_17, 0);
if (!opts) {
exit(1);
}
configure_rtc(opts);
break;
case QEMU_OPTION_tb_size:
tcg_tb_size = strtol(VAR_17, NULL, 0);
if (tcg_tb_size < 0) {
tcg_tb_size = 0;
}
break;
case QEMU_OPTION_icount:
VAR_7 = VAR_17;
break;
case QEMU_OPTION_incoming:
VAR_21 = VAR_17;
break;
case QEMU_OPTION_nodefaults:
default_serial = 0;
default_parallel = 0;
default_virtcon = 0;
default_monitor = 0;
default_vga = 0;
default_net = 0;
default_floppy = 0;
default_cdrom = 0;
default_sdcard = 0;
break;
case QEMU_OPTION_xen_domid:
if (!(xen_available())) {
printf("Option %s not supported for this target\n", VAR_29->name);
exit(1);
}
xen_domid = atoi(VAR_17);
break;
case QEMU_OPTION_xen_create:
if (!(xen_available())) {
printf("Option %s not supported for this target\n", VAR_29->name);
exit(1);
}
xen_mode = XEN_CREATE;
break;
case QEMU_OPTION_xen_attach:
if (!(xen_available())) {
printf("Option %s not supported for this target\n", VAR_29->name);
exit(1);
}
xen_mode = XEN_ATTACH;
break;
case QEMU_OPTION_trace:
{
opts = qemu_opts_parse(qemu_find_opts("trace"), VAR_17, 0);
if (!opts) {
exit(1);
}
VAR_25 = qemu_opt_get(opts, "events");
VAR_26 = qemu_opt_get(opts, "file");
break;
}
case QEMU_OPTION_readconfig:
{
int VAR_41 = qemu_read_config_file(VAR_17);
if (VAR_41 < 0) {
fprintf(stderr, "read config %s: %s\n", VAR_17,
strerror(-VAR_41));
exit(1);
}
break;
}
case QEMU_OPTION_spice:
olist = qemu_find_opts("spice");
if (!olist) {
fprintf(stderr, "spice is not supported by this qemu build.\n");
exit(1);
}
opts = qemu_opts_parse(olist, VAR_17, 0);
if (!opts) {
fprintf(stderr, "parse error: %s\n", VAR_17);
exit(1);
}
break;
case QEMU_OPTION_writeconfig:
{
FILE *fp;
if (strcmp(VAR_17, "-") == 0) {
fp = stdout;
} else {
fp = fopen(VAR_17, "VAR_36");
if (fp == NULL) {
fprintf(stderr, "open %s: %s\n", VAR_17, strerror(errno));
exit(1);
}
}
qemu_config_write(fp);
fclose(fp);
break;
}
default:
os_parse_cmd_args(VAR_29->index, VAR_17);
}
}
}
loc_set_none();
if (VAR_23) {
if (VAR_24) {
set_cpu_log_filename(VAR_24);
}
set_cpu_log(VAR_23);
}
if (!trace_backend_init(VAR_25, VAR_26)) {
exit(1);
}
if (!data_dir) {
data_dir = os_find_datadir(VAR_1[0]);
}
if (!data_dir) {
data_dir = CONFIG_QEMU_DATADIR;
}
if (machine == NULL) {
fprintf(stderr, "No machine found.\n");
exit(1);
}
if (!max_cpus)
max_cpus = smp_cpus;
machine->max_cpus = machine->max_cpus ?: 1;
if (smp_cpus > machine->max_cpus) {
fprintf(stderr, "Number of SMP cpus requested (%d), exceeds max cpus "
"supported by machine `%s' (%d)\n", smp_cpus, machine->name,
machine->max_cpus);
exit(1);
}
if (machine->default_machine_opts) {
QemuOptsList *list = qemu_find_opts("machine");
const char *VAR_41 = NULL;
if (!QTAILQ_EMPTY(&list->head)) {
VAR_41 = qemu_opt_get(QTAILQ_FIRST(&list->head), "accel");
}
if (VAR_41 == NULL) {
qemu_opts_reset(list);
opts = qemu_opts_parse(list, machine->default_machine_opts, 0);
if (!opts) {
fprintf(stderr, "parse error for machine %s: %s\n",
machine->name, machine->default_machine_opts);
exit(1);
}
}
}
qemu_opts_foreach(qemu_find_opts("device"), default_driver_check, NULL, 0);
qemu_opts_foreach(qemu_find_opts("global"), default_driver_check, NULL, 0);
if (machine->no_serial) {
default_serial = 0;
}
if (machine->no_parallel) {
default_parallel = 0;
}
if (!machine->use_virtcon) {
default_virtcon = 0;
}
if (machine->no_vga) {
default_vga = 0;
}
if (machine->no_floppy) {
default_floppy = 0;
}
if (machine->no_cdrom) {
default_cdrom = 0;
}
if (machine->no_sdcard) {
default_sdcard = 0;
}
if (display_type == DT_NOGRAPHIC) {
if (default_parallel)
add_device_config(DEV_PARALLEL, "null");
if (default_serial && default_monitor) {
add_device_config(DEV_SERIAL, "mon:stdio");
} else if (default_virtcon && default_monitor) {
add_device_config(DEV_VIRTCON, "mon:stdio");
} else {
if (default_serial)
add_device_config(DEV_SERIAL, "stdio");
if (default_virtcon)
add_device_config(DEV_VIRTCON, "stdio");
if (default_monitor)
monitor_parse("stdio", "readline");
}
} else {
if (default_serial)
add_device_config(DEV_SERIAL, "vc:80Cx24C");
if (default_parallel)
add_device_config(DEV_PARALLEL, "vc:80Cx24C");
if (default_monitor)
monitor_parse("vc:80Cx24C", "readline");
if (default_virtcon)
add_device_config(DEV_VIRTCON, "vc:80Cx24C");
}
if (default_vga)
vga_interface_type = VGA_CIRRUS;
socket_init();
if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func, NULL, 1) != 0)
exit(1);
#ifdef CONFIG_VIRTFS
if (qemu_opts_foreach(qemu_find_opts("fsdev"), fsdev_init_func, NULL, 1) != 0) {
exit(1);
}
#endif
os_daemonize();
if (VAR_20 && qemu_create_pidfile(VAR_20) != 0) {
os_pidfile_error();
exit(1);
}
if (ram_size == 0) {
ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
}
configure_accelerator();
qemu_init_cpu_loop();
if (qemu_init_main_loop()) {
fprintf(stderr, "qemu_init_main_loop failed\n");
exit(1);
}
VAR_6 = (VAR_9 != NULL);
if (!VAR_6 && *VAR_10 != '\0') {
fprintf(stderr, "-append only allowed with -kernel option\n");
exit(1);
}
if (!VAR_6 && VAR_8 != NULL) {
fprintf(stderr, "-initrd only allowed with -kernel option\n");
exit(1);
}
os_set_line_buffering();
if (init_timer_alarm() < 0) {
fprintf(stderr, "could not initialize alarm timer\n");
exit(1);
}
if (VAR_7 && (kvm_enabled() || xen_enabled())) {
fprintf(stderr, "-icount is not allowed with kvm or xen\n");
exit(1);
}
configure_icount(VAR_7);
if (net_init_clients() < 0) {
exit(1);
}
if (foreach_device_config(DEV_BT, bt_parse))
exit(1);
if (!xen_enabled()) {
if (ram_size > (2047 << 20) && HOST_LONG_BITS == 32) {
fprintf(stderr, "qemu: at most 2047 MB RAM can be simulated\n");
exit(1);
}
}
cpu_exec_init_all();
bdrv_init_with_whitelist();
blk_mig_init();
if (VAR_5)
qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot, NULL, 0);
if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func, &machine->use_scsi, 1) != 0)
exit(1);
default_drive(default_cdrom, VAR_5, machine->use_scsi,
IF_DEFAULT, 2, CDROM_OPTS);
default_drive(default_floppy, VAR_5, machine->use_scsi,
IF_FLOPPY, 0, FD_OPTS);
default_drive(default_sdcard, VAR_5, machine->use_scsi,
IF_SD, 0, SD_OPTS);
register_savevm_live(NULL, "ram", 0, 4, NULL, ram_save_live, NULL,
ram_load, NULL);
if (nb_numa_nodes > 0) {
int VAR_41;
if (nb_numa_nodes > MAX_NODES) {
nb_numa_nodes = MAX_NODES;
}
for (VAR_41 = 0; VAR_41 < nb_numa_nodes; VAR_41++) {
if (node_mem[VAR_41] != 0)
break;
}
if (VAR_41 == nb_numa_nodes) {
uint64_t usedmem = 0;
for (VAR_41 = 0; VAR_41 < nb_numa_nodes - 1; VAR_41++) {
node_mem[VAR_41] = (ram_size / nb_numa_nodes) & ~((1 << 23UL) - 1);
usedmem += node_mem[VAR_41];
}
node_mem[VAR_41] = ram_size - usedmem;
}
for (VAR_41 = 0; VAR_41 < nb_numa_nodes; VAR_41++) {
if (node_cpumask[VAR_41] != 0)
break;
}
if (VAR_41 == nb_numa_nodes) {
for (VAR_41 = 0; VAR_41 < max_cpus; VAR_41++) {
node_cpumask[VAR_41 % nb_numa_nodes] |= 1 << VAR_41;
}
}
}
if (qemu_opts_foreach(qemu_find_opts("mon"), mon_init_func, NULL, 1) != 0) {
exit(1);
}
if (foreach_device_config(DEV_SERIAL, serial_parse) < 0)
exit(1);
if (foreach_device_config(DEV_PARALLEL, parallel_parse) < 0)
exit(1);
if (foreach_device_config(DEV_VIRTCON, virtcon_parse) < 0)
exit(1);
if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0)
exit(1);
module_call_init(MODULE_INIT_DEVICE);
if (qemu_opts_foreach(qemu_find_opts("device"), device_help_func, NULL, 0) != 0)
exit(0);
if (watchdog) {
VAR_41 = select_watchdog(watchdog);
if (VAR_41 > 0)
exit (VAR_41 == 1 ? 1 : 0);
}
if (machine->compat_props) {
qdev_prop_register_global_list(machine->compat_props);
}
qemu_add_globals();
qdev_machine_init();
machine->init(ram_size, VAR_11,
VAR_9, VAR_10, VAR_8, VAR_19);
cpu_synchronize_all_post_init();
set_numa_modes();
current_machine = machine;
if (usb_enabled) {
if (foreach_device_config(DEV_USB, usb_parse) < 0)
exit(1);
}
if (qemu_opts_foreach(qemu_find_opts("device"), device_init_func, NULL, 1) != 0)
exit(1);
net_check_clients();
ds = get_displaystate();
if (using_spice)
display_remote++;
if (display_type == DT_DEFAULT && !display_remote) {
#if defined(CONFIG_SDL) || defined(CONFIG_COCOA)
display_type = DT_SDL;
#elif defined(CONFIG_VNC)
vnc_display = "localhost:0,to=99";
show_vnc_port = 1;
#else
display_type = DT_NONE;
#endif
}
switch (display_type) {
case DT_NOGRAPHIC:
break;
#if defined(CONFIG_CURSES)
case DT_CURSES:
curses_display_init(ds, full_screen);
break;
#endif
#if defined(CONFIG_SDL)
case DT_SDL:
sdl_display_init(ds, full_screen, no_frame);
break;
#elif defined(CONFIG_COCOA)
case DT_SDL:
cocoa_display_init(ds, full_screen);
break;
#endif
default:
break;
}
os_setup_signal_handling();
#ifdef CONFIG_VNC
if (vnc_display) {
vnc_display_init(ds);
if (vnc_display_open(ds, vnc_display) < 0)
exit(1);
if (show_vnc_port) {
printf("VNC server running on `%s'\n", vnc_display_local_addr(ds));
}
}
#endif
#ifdef CONFIG_SPICE
if (using_spice && !qxl_enabled) {
qemu_spice_display_init(ds);
}
#endif
dpy_resize(ds);
dcl = ds->listeners;
while (dcl != NULL) {
if (dcl->dpy_refresh != NULL) {
ds->gui_timer = qemu_new_timer_ms(rt_clock, gui_update, ds);
qemu_mod_timer(ds->gui_timer, qemu_get_clock_ms(rt_clock));
break;
}
dcl = dcl->next;
}
text_consoles_set_display(ds);
if (VAR_3 && gdbserver_start(VAR_3) < 0) {
fprintf(stderr, "qemu: could not open gdbserver on device '%s'\n",
VAR_3);
exit(1);
}
qdev_machine_creation_done();
if (rom_load_all() != 0) {
fprintf(stderr, "rom loading failed\n");
exit(1);
}
qemu_register_reset(qbus_reset_all_fn, sysbus_get_default());
qemu_run_machine_init_done_notifiers();
qemu_system_reset(VMRESET_SILENT);
if (VAR_18) {
if (load_vmstate(VAR_18) < 0) {
autostart = 0;
}
}
if (VAR_21) {
runstate_set(RUN_STATE_INMIGRATE);
int VAR_41 = qemu_start_incoming_migration(VAR_21);
if (VAR_41 < 0) {
fprintf(stderr, "Migration failed. Exit code %s(%d), exiting.\n",
VAR_21, VAR_41);
exit(VAR_41);
}
} else if (autostart) {
vm_start();
}
os_setup_post();
resume_all_vcpus();
main_loop();
bdrv_close_all();
pause_all_vcpus();
net_cleanup();
res_free();
return 0;
}
| [
"int FUNC_0(int VAR_0, char **VAR_1, char **VAR_2)\n{",
"const char *VAR_3 = NULL;",
"int VAR_41;",
"int VAR_5, VAR_6;",
"const char *VAR_7 = NULL;",
"const char *VAR_8;",
"const char *VAR_9, *VAR_10;",
"char VAR_11[33] = \"cad\";",
"DisplayState *ds;",
"DisplayChangeListener *dcl;",
"int VAR_12, VAR_13, VAR_14, VAR_15;",
"QemuOpts *hda_opts = NULL, *opts;",
"QemuOptsList *olist;",
"int VAR_16;",
"const char *VAR_17;",
"const char *VAR_18 = NULL;",
"QEMUMachine *machine;",
"const char *VAR_19;",
"const char *VAR_20 = NULL;",
"const char *VAR_21 = NULL;",
"#ifdef CONFIG_VNC\nint show_vnc_port = 0;",
"#endif\nint VAR_22 = 1;",
"const char *VAR_23 = NULL;",
"const char *VAR_24 = NULL;",
"GMemVTable mem_trace = {",
".malloc = malloc_and_trace,\n.realloc = realloc_and_trace,\n.free = free_and_trace,\n};",
"const char *VAR_25 = NULL;",
"const char *VAR_26 = NULL;",
"atexit(qemu_run_exit_notifiers);",
"error_set_progname(VAR_1[0]);",
"g_mem_set_vtable(&mem_trace);",
"if (!g_thread_supported()) {",
"#if !GLIB_CHECK_VERSION(2, 31, 0)\ng_thread_init(NULL);",
"#else\nfprintf(stderr, \"glib threading failed to initialize.\\n\");",
"exit(1);",
"#endif\n}",
"runstate_init();",
"init_clocks();",
"rtc_clock = host_clock;",
"qemu_cache_utils_init(VAR_2);",
"QLIST_INIT (&vm_change_state_head);",
"os_setup_early_signal_handling();",
"module_call_init(MODULE_INIT_MACHINE);",
"machine = find_default_machine();",
"VAR_19 = NULL;",
"VAR_8 = NULL;",
"ram_size = 0;",
"VAR_5 = 0;",
"VAR_9 = NULL;",
"VAR_10 = \"\";",
"VAR_12 = VAR_13 = VAR_14 = 0;",
"VAR_15 = BIOS_ATA_TRANSLATION_AUTO;",
"for (VAR_41 = 0; VAR_41 < MAX_NODES; VAR_41++) {",
"node_mem[VAR_41] = 0;",
"node_cpumask[VAR_41] = 0;",
"}",
"nb_numa_nodes = 0;",
"nb_nics = 0;",
"autostart= 1;",
"VAR_16 = 1;",
"while (VAR_16 < VAR_0) {",
"if (VAR_1[VAR_16][0] != '-') {",
"VAR_16++;",
"continue;",
"} else {",
"const QEMUOption *VAR_29;",
"VAR_29 = lookup_opt(VAR_0, VAR_1, &VAR_17, &VAR_16);",
"switch (VAR_29->index) {",
"case QEMU_OPTION_nodefconfig:\nVAR_22=0;",
"break;",
"}",
"}",
"}",
"if (VAR_22) {",
"int VAR_41;",
"VAR_41 = qemu_read_config_file(CONFIG_QEMU_CONFDIR \"/qemu.conf\");",
"if (VAR_41 < 0 && VAR_41 != -ENOENT) {",
"exit(1);",
"}",
"VAR_41 = qemu_read_config_file(arch_config_name);",
"if (VAR_41 < 0 && VAR_41 != -ENOENT) {",
"exit(1);",
"}",
"}",
"cpudef_init();",
"VAR_16 = 1;",
"for(;;) {",
"if (VAR_16 >= VAR_0)\nbreak;",
"if (VAR_1[VAR_16][0] != '-') {",
"hda_opts = drive_add(IF_DEFAULT, 0, VAR_1[VAR_16++], HD_OPTS);",
"} else {",
"const QEMUOption *VAR_29;",
"VAR_29 = lookup_opt(VAR_0, VAR_1, &VAR_17, &VAR_16);",
"if (!(VAR_29->arch_mask & arch_type)) {",
"printf(\"Option %s not supported for this target\\n\", VAR_29->name);",
"exit(1);",
"}",
"switch(VAR_29->index) {",
"case QEMU_OPTION_M:\nmachine = machine_parse(VAR_17);",
"break;",
"case QEMU_OPTION_cpu:\nif (*VAR_17 == '?') {",
"list_cpus(stdout, &fprintf, VAR_17);",
"exit(0);",
"} else {",
"VAR_19 = VAR_17;",
"}",
"break;",
"case QEMU_OPTION_initrd:\nVAR_8 = VAR_17;",
"break;",
"case QEMU_OPTION_hda:\n{",
"char VAR_33[256];",
"if (VAR_12 == 0)\nsnprintf(VAR_33, sizeof(VAR_33), \"%s\", HD_OPTS);",
"else\nsnprintf(VAR_33, sizeof(VAR_33),\n\"%s,VAR_12=%d,VAR_13=%d,VAR_14=%d%s\",\nHD_OPTS , VAR_12, VAR_13, VAR_14,\nVAR_15 == BIOS_ATA_TRANSLATION_LBA ?\n\",trans=lba\" :\nVAR_15 == BIOS_ATA_TRANSLATION_NONE ?\n\",trans=none\" : \"\");",
"drive_add(IF_DEFAULT, 0, VAR_17, VAR_33);",
"break;",
"}",
"case QEMU_OPTION_hdb:\ncase QEMU_OPTION_hdc:\ncase QEMU_OPTION_hdd:\ndrive_add(IF_DEFAULT, VAR_29->index - QEMU_OPTION_hda, VAR_17,\nHD_OPTS);",
"break;",
"case QEMU_OPTION_drive:\nif (drive_def(VAR_17) == NULL) {",
"exit(1);",
"}",
"break;",
"case QEMU_OPTION_set:\nif (qemu_set_option(VAR_17) != 0)\nexit(1);",
"break;",
"case QEMU_OPTION_global:\nif (qemu_global_option(VAR_17) != 0)\nexit(1);",
"break;",
"case QEMU_OPTION_mtdblock:\ndrive_add(IF_MTD, -1, VAR_17, MTD_OPTS);",
"break;",
"case QEMU_OPTION_sd:\ndrive_add(IF_SD, 0, VAR_17, SD_OPTS);",
"break;",
"case QEMU_OPTION_pflash:\ndrive_add(IF_PFLASH, -1, VAR_17, PFLASH_OPTS);",
"break;",
"case QEMU_OPTION_snapshot:\nVAR_5 = 1;",
"break;",
"case QEMU_OPTION_hdachs:\n{",
"const char *VAR_41;",
"VAR_41 = VAR_17;",
"VAR_12 = strtol(VAR_41, (char **)&VAR_41, 0);",
"if (VAR_12 < 1 || VAR_12 > 16383)\ngoto chs_fail;",
"if (*VAR_41 != ',')\ngoto chs_fail;",
"VAR_41++;",
"VAR_13 = strtol(VAR_41, (char **)&VAR_41, 0);",
"if (VAR_13 < 1 || VAR_13 > 16)\ngoto chs_fail;",
"if (*VAR_41 != ',')\ngoto chs_fail;",
"VAR_41++;",
"VAR_14 = strtol(VAR_41, (char **)&VAR_41, 0);",
"if (VAR_14 < 1 || VAR_14 > 63)\ngoto chs_fail;",
"if (*VAR_41 == ',') {",
"VAR_41++;",
"if (!strcmp(VAR_41, \"none\"))\nVAR_15 = BIOS_ATA_TRANSLATION_NONE;",
"else if (!strcmp(VAR_41, \"lba\"))\nVAR_15 = BIOS_ATA_TRANSLATION_LBA;",
"else if (!strcmp(VAR_41, \"auto\"))\nVAR_15 = BIOS_ATA_TRANSLATION_AUTO;",
"else\ngoto chs_fail;",
"} else if (*VAR_41 != '\\0') {",
"chs_fail:\nfprintf(stderr, \"qemu: invalid physical CHS format\\n\");",
"exit(1);",
"}",
"if (hda_opts != NULL) {",
"char VAR_31[16];",
"snprintf(VAR_31, sizeof(VAR_31), \"%d\", VAR_12);",
"qemu_opt_set(hda_opts, \"VAR_12\", VAR_31);",
"snprintf(VAR_31, sizeof(VAR_31), \"%d\", VAR_13);",
"qemu_opt_set(hda_opts, \"VAR_13\", VAR_31);",
"snprintf(VAR_31, sizeof(VAR_31), \"%d\", VAR_14);",
"qemu_opt_set(hda_opts, \"VAR_14\", VAR_31);",
"if (VAR_15 == BIOS_ATA_TRANSLATION_LBA)\nqemu_opt_set(hda_opts, \"trans\", \"lba\");",
"if (VAR_15 == BIOS_ATA_TRANSLATION_NONE)\nqemu_opt_set(hda_opts, \"trans\", \"none\");",
"}",
"}",
"break;",
"case QEMU_OPTION_numa:\nif (nb_numa_nodes >= MAX_NODES) {",
"fprintf(stderr, \"qemu: too many NUMA nodes\\n\");",
"exit(1);",
"}",
"numa_add(VAR_17);",
"break;",
"case QEMU_OPTION_display:\ndisplay_type = select_display(VAR_17);",
"break;",
"case QEMU_OPTION_nographic:\ndisplay_type = DT_NOGRAPHIC;",
"break;",
"case QEMU_OPTION_curses:\n#ifdef CONFIG_CURSES\ndisplay_type = DT_CURSES;",
"#else\nfprintf(stderr, \"Curses support is disabled\\n\");",
"exit(1);",
"#endif\nbreak;",
"case QEMU_OPTION_portrait:\ngraphic_rotate = 90;",
"break;",
"case QEMU_OPTION_rotate:\ngraphic_rotate = strtol(VAR_17, (char **) &VAR_17, 10);",
"if (graphic_rotate != 0 && graphic_rotate != 90 &&\ngraphic_rotate != 180 && graphic_rotate != 270) {",
"fprintf(stderr,\n\"qemu: only 90, 180, 270 deg rotation is available\\n\");",
"exit(1);",
"}",
"break;",
"case QEMU_OPTION_kernel:\nVAR_9 = VAR_17;",
"break;",
"case QEMU_OPTION_append:\nVAR_10 = VAR_17;",
"break;",
"case QEMU_OPTION_cdrom:\ndrive_add(IF_DEFAULT, 2, VAR_17, CDROM_OPTS);",
"break;",
"case QEMU_OPTION_boot:\n{",
"static const char * const VAR_32[] = {",
"\"order\", \"once\", \"menu\",\n\"splash\", \"splash-time\", NULL\n};",
"char VAR_33[sizeof(VAR_11)];",
"char *VAR_33;",
"int VAR_34 = 0;",
"if (!strchr(VAR_17, '=')) {",
"VAR_34 = 1;",
"pstrcpy(VAR_33, sizeof(VAR_33), VAR_17);",
"} else if (check_params(VAR_33, sizeof(VAR_33), VAR_32, VAR_17) < 0) {",
"fprintf(stderr,\n\"qemu: unknown boot parameter '%s' in '%s'\\n\",\nVAR_33, VAR_17);",
"exit(1);",
"}",
"if (VAR_34 ||\nget_param_value(VAR_33, sizeof(VAR_33), \"order\", VAR_17)) {",
"validate_bootdevices(VAR_33);",
"pstrcpy(VAR_11, sizeof(VAR_11), VAR_33);",
"}",
"if (!VAR_34) {",
"if (get_param_value(VAR_33, sizeof(VAR_33),\n\"once\", VAR_17)) {",
"validate_bootdevices(VAR_33);",
"VAR_33 = g_strdup(VAR_11);",
"pstrcpy(VAR_11, sizeof(VAR_11), VAR_33);",
"qemu_register_reset(restore_boot_devices,\nVAR_33);",
"}",
"if (get_param_value(VAR_33, sizeof(VAR_33),\n\"menu\", VAR_17)) {",
"if (!strcmp(VAR_33, \"on\")) {",
"boot_menu = 1;",
"} else if (!strcmp(VAR_33, \"off\")) {",
"boot_menu = 0;",
"} else {",
"fprintf(stderr,\n\"qemu: invalid option value '%s'\\n\",\nVAR_33);",
"exit(1);",
"}",
"}",
"qemu_opts_parse(qemu_find_opts(\"boot-opts\"),\nVAR_17, 0);",
"}",
"}",
"break;",
"case QEMU_OPTION_fda:\ncase QEMU_OPTION_fdb:\ndrive_add(IF_FLOPPY, VAR_29->index - QEMU_OPTION_fda,\nVAR_17, FD_OPTS);",
"break;",
"case QEMU_OPTION_no_fd_bootchk:\nfd_bootchk = 0;",
"break;",
"case QEMU_OPTION_netdev:\nif (net_client_parse(qemu_find_opts(\"netdev\"), VAR_17) == -1) {",
"exit(1);",
"}",
"break;",
"case QEMU_OPTION_net:\nif (net_client_parse(qemu_find_opts(\"net\"), VAR_17) == -1) {",
"exit(1);",
"}",
"break;",
"#ifdef CONFIG_SLIRP\ncase QEMU_OPTION_tftp:\nlegacy_tftp_prefix = VAR_17;",
"break;",
"case QEMU_OPTION_bootp:\nlegacy_bootp_filename = VAR_17;",
"break;",
"case QEMU_OPTION_redir:\nif (net_slirp_redir(VAR_17) < 0)\nexit(1);",
"break;",
"#endif\ncase QEMU_OPTION_bt:\nadd_device_config(DEV_BT, VAR_17);",
"break;",
"case QEMU_OPTION_audio_help:\nif (!(audio_available())) {",
"printf(\"Option %s not supported for this target\\n\", VAR_29->name);",
"exit(1);",
"}",
"AUD_help ();",
"exit (0);",
"break;",
"case QEMU_OPTION_soundhw:\nif (!(audio_available())) {",
"printf(\"Option %s not supported for this target\\n\", VAR_29->name);",
"exit(1);",
"}",
"select_soundhw (VAR_17);",
"break;",
"case QEMU_OPTION_h:\nhelp(0);",
"break;",
"case QEMU_OPTION_version:\nversion();",
"exit(0);",
"break;",
"case QEMU_OPTION_m: {",
"int64_t value;",
"char *VAR_35;",
"value = strtosz(VAR_17, &VAR_35);",
"if (value < 0 || *VAR_35) {",
"fprintf(stderr, \"qemu: invalid ram size: %s\\n\", VAR_17);",
"exit(1);",
"}",
"if (value != (uint64_t)(ram_addr_t)value) {",
"fprintf(stderr, \"qemu: ram size too large\\n\");",
"exit(1);",
"}",
"ram_size = value;",
"break;",
"}",
"case QEMU_OPTION_mempath:\nmem_path = VAR_17;",
"break;",
"#ifdef MAP_POPULATE\ncase QEMU_OPTION_mem_prealloc:\nmem_prealloc = 1;",
"break;",
"#endif\ncase QEMU_OPTION_d:\nVAR_23 = VAR_17;",
"break;",
"case QEMU_OPTION_D:\nVAR_24 = VAR_17;",
"break;",
"case QEMU_OPTION_s:\nVAR_3 = \"tcp::\" DEFAULT_GDBSTUB_PORT;",
"break;",
"case QEMU_OPTION_gdb:\nVAR_3 = VAR_17;",
"break;",
"case QEMU_OPTION_L:\ndata_dir = VAR_17;",
"break;",
"case QEMU_OPTION_bios:\nbios_name = VAR_17;",
"break;",
"case QEMU_OPTION_singlestep:\nsinglestep = 1;",
"break;",
"case QEMU_OPTION_S:\nautostart = 0;",
"break;",
"case QEMU_OPTION_k:\nkeyboard_layout = VAR_17;",
"break;",
"case QEMU_OPTION_localtime:\nrtc_utc = 0;",
"break;",
"case QEMU_OPTION_vga:\nselect_vgahw (VAR_17);",
"break;",
"case QEMU_OPTION_g:\n{",
"const char *VAR_41;",
"int VAR_36, VAR_37, VAR_38;",
"VAR_41 = VAR_17;",
"VAR_36 = strtol(VAR_41, (char **)&VAR_41, 10);",
"if (VAR_36 <= 0) {",
"graphic_error:\nfprintf(stderr, \"qemu: invalid resolution or VAR_38\\n\");",
"exit(1);",
"}",
"if (*VAR_41 != 'x')\ngoto graphic_error;",
"VAR_41++;",
"VAR_37 = strtol(VAR_41, (char **)&VAR_41, 10);",
"if (VAR_37 <= 0)\ngoto graphic_error;",
"if (*VAR_41 == 'x') {",
"VAR_41++;",
"VAR_38 = strtol(VAR_41, (char **)&VAR_41, 10);",
"if (VAR_38 != 8 && VAR_38 != 15 && VAR_38 != 16 &&\nVAR_38 != 24 && VAR_38 != 32)\ngoto graphic_error;",
"} else if (*VAR_41 == '\\0') {",
"VAR_38 = graphic_depth;",
"} else {",
"goto graphic_error;",
"}",
"graphic_width = VAR_36;",
"graphic_height = VAR_37;",
"graphic_depth = VAR_38;",
"}",
"break;",
"case QEMU_OPTION_echr:\n{",
"char *VAR_39;",
"term_escape_char = strtol(VAR_17, &VAR_39, 0);",
"if (VAR_39 == VAR_17)\nprintf(\"Bad argument to echr\\n\");",
"break;",
"}",
"case QEMU_OPTION_monitor:\nmonitor_parse(VAR_17, \"readline\");",
"default_monitor = 0;",
"break;",
"case QEMU_OPTION_qmp:\nmonitor_parse(VAR_17, \"control\");",
"default_monitor = 0;",
"break;",
"case QEMU_OPTION_mon:\nopts = qemu_opts_parse(qemu_find_opts(\"mon\"), VAR_17, 1);",
"if (!opts) {",
"exit(1);",
"}",
"default_monitor = 0;",
"break;",
"case QEMU_OPTION_chardev:\nopts = qemu_opts_parse(qemu_find_opts(\"chardev\"), VAR_17, 1);",
"if (!opts) {",
"exit(1);",
"}",
"break;",
"case QEMU_OPTION_fsdev:\nolist = qemu_find_opts(\"fsdev\");",
"if (!olist) {",
"fprintf(stderr, \"fsdev is not supported by this qemu build.\\n\");",
"exit(1);",
"}",
"opts = qemu_opts_parse(olist, VAR_17, 1);",
"if (!opts) {",
"fprintf(stderr, \"parse error: %s\\n\", VAR_17);",
"exit(1);",
"}",
"break;",
"case QEMU_OPTION_virtfs: {",
"QemuOpts *fsdev;",
"QemuOpts *device;",
"const char *VAR_40;",
"olist = qemu_find_opts(\"virtfs\");",
"if (!olist) {",
"fprintf(stderr, \"virtfs is not supported by this qemu build.\\n\");",
"exit(1);",
"}",
"opts = qemu_opts_parse(olist, VAR_17, 1);",
"if (!opts) {",
"fprintf(stderr, \"parse error: %s\\n\", VAR_17);",
"exit(1);",
"}",
"if (qemu_opt_get(opts, \"fsdriver\") == NULL ||\nqemu_opt_get(opts, \"mount_tag\") == NULL ||\nqemu_opt_get(opts, \"path\") == NULL) {",
"fprintf(stderr, \"Usage: -virtfs fsdriver,path=/share_path/,\"\n\"[security_model={mapped|passthrough|none}],\"",
"\"mount_tag=tag.\\n\");",
"exit(1);",
"}",
"fsdev = qemu_opts_create(qemu_find_opts(\"fsdev\"),\nqemu_opt_get(opts, \"mount_tag\"), 1);",
"if (!fsdev) {",
"fprintf(stderr, \"duplicate fsdev id: %s\\n\",\nqemu_opt_get(opts, \"mount_tag\"));",
"exit(1);",
"}",
"VAR_40 = qemu_opt_get(opts, \"VAR_40\");",
"if (VAR_40) {",
"#ifdef CONFIG_SYNC_FILE_RANGE\nqemu_opt_set(fsdev, \"VAR_40\", VAR_40);",
"#else\nfprintf(stderr, \"VAR_40=immediate not supported on \"\n\"this platform\\n\");",
"exit(1);",
"#endif\n}",
"qemu_opt_set(fsdev, \"fsdriver\", qemu_opt_get(opts, \"fsdriver\"));",
"qemu_opt_set(fsdev, \"path\", qemu_opt_get(opts, \"path\"));",
"qemu_opt_set(fsdev, \"security_model\",\nqemu_opt_get(opts, \"security_model\"));",
"qemu_opt_set_bool(fsdev, \"readonly\",\nqemu_opt_get_bool(opts, \"readonly\", 0));",
"device = qemu_opts_create(qemu_find_opts(\"device\"), NULL, 0);",
"qemu_opt_set(device, \"driver\", \"virtio-9p-pci\");",
"qemu_opt_set(device, \"fsdev\",\nqemu_opt_get(opts, \"mount_tag\"));",
"qemu_opt_set(device, \"mount_tag\",\nqemu_opt_get(opts, \"mount_tag\"));",
"break;",
"}",
"case QEMU_OPTION_virtfs_synth: {",
"QemuOpts *fsdev;",
"QemuOpts *device;",
"fsdev = qemu_opts_create(qemu_find_opts(\"fsdev\"), \"v_synth\", 1);",
"if (!fsdev) {",
"fprintf(stderr, \"duplicate option: %s\\n\", \"virtfs_synth\");",
"exit(1);",
"}",
"qemu_opt_set(fsdev, \"fsdriver\", \"synth\");",
"qemu_opt_set(fsdev, \"path\", \"/\");",
"device = qemu_opts_create(qemu_find_opts(\"device\"), NULL, 0);",
"qemu_opt_set(device, \"driver\", \"virtio-9p-pci\");",
"qemu_opt_set(device, \"fsdev\", \"v_synth\");",
"qemu_opt_set(device, \"mount_tag\", \"v_synth\");",
"break;",
"}",
"case QEMU_OPTION_serial:\nadd_device_config(DEV_SERIAL, VAR_17);",
"default_serial = 0;",
"if (strncmp(VAR_17, \"mon:\", 4) == 0) {",
"default_monitor = 0;",
"}",
"break;",
"case QEMU_OPTION_watchdog:\nif (watchdog) {",
"fprintf(stderr,\n\"qemu: only one watchdog option may be given\\n\");",
"return 1;",
"}",
"watchdog = VAR_17;",
"break;",
"case QEMU_OPTION_watchdog_action:\nif (select_watchdog_action(VAR_17) == -1) {",
"fprintf(stderr, \"Unknown -watchdog-action parameter\\n\");",
"exit(1);",
"}",
"break;",
"case QEMU_OPTION_virtiocon:\nadd_device_config(DEV_VIRTCON, VAR_17);",
"default_virtcon = 0;",
"if (strncmp(VAR_17, \"mon:\", 4) == 0) {",
"default_monitor = 0;",
"}",
"break;",
"case QEMU_OPTION_parallel:\nadd_device_config(DEV_PARALLEL, VAR_17);",
"default_parallel = 0;",
"if (strncmp(VAR_17, \"mon:\", 4) == 0) {",
"default_monitor = 0;",
"}",
"break;",
"case QEMU_OPTION_debugcon:\nadd_device_config(DEV_DEBUGCON, VAR_17);",
"break;",
"case QEMU_OPTION_loadvm:\nVAR_18 = VAR_17;",
"break;",
"case QEMU_OPTION_full_screen:\nfull_screen = 1;",
"break;",
"#ifdef CONFIG_SDL\ncase QEMU_OPTION_no_frame:\nno_frame = 1;",
"break;",
"case QEMU_OPTION_alt_grab:\nalt_grab = 1;",
"break;",
"case QEMU_OPTION_ctrl_grab:\nctrl_grab = 1;",
"break;",
"case QEMU_OPTION_no_quit:\nno_quit = 1;",
"break;",
"case QEMU_OPTION_sdl:\ndisplay_type = DT_SDL;",
"break;",
"#else\ncase QEMU_OPTION_no_frame:\ncase QEMU_OPTION_alt_grab:\ncase QEMU_OPTION_ctrl_grab:\ncase QEMU_OPTION_no_quit:\ncase QEMU_OPTION_sdl:\nfprintf(stderr, \"SDL support is disabled\\n\");",
"exit(1);",
"#endif\ncase QEMU_OPTION_pidfile:\nVAR_20 = VAR_17;",
"break;",
"case QEMU_OPTION_win2k_hack:\nwin2k_install_hack = 1;",
"break;",
"case QEMU_OPTION_rtc_td_hack:\nrtc_td_hack = 1;",
"break;",
"case QEMU_OPTION_acpitable:\ndo_acpitable_option(VAR_17);",
"break;",
"case QEMU_OPTION_smbios:\ndo_smbios_option(VAR_17);",
"break;",
"case QEMU_OPTION_enable_kvm:\nolist = qemu_find_opts(\"machine\");",
"qemu_opts_reset(olist);",
"qemu_opts_parse(olist, \"accel=kvm\", 0);",
"break;",
"case QEMU_OPTION_machine:\nolist = qemu_find_opts(\"machine\");",
"qemu_opts_reset(olist);",
"opts = qemu_opts_parse(olist, VAR_17, 1);",
"if (!opts) {",
"fprintf(stderr, \"parse error: %s\\n\", VAR_17);",
"exit(1);",
"}",
"VAR_17 = qemu_opt_get(opts, \"type\");",
"if (VAR_17) {",
"machine = machine_parse(VAR_17);",
"}",
"break;",
"case QEMU_OPTION_usb:\nusb_enabled = 1;",
"break;",
"case QEMU_OPTION_usbdevice:\nusb_enabled = 1;",
"add_device_config(DEV_USB, VAR_17);",
"break;",
"case QEMU_OPTION_device:\nif (!qemu_opts_parse(qemu_find_opts(\"device\"), VAR_17, 1)) {",
"exit(1);",
"}",
"break;",
"case QEMU_OPTION_smp:\nsmp_parse(VAR_17);",
"if (smp_cpus < 1) {",
"fprintf(stderr, \"Invalid number of CPUs\\n\");",
"exit(1);",
"}",
"if (max_cpus < smp_cpus) {",
"fprintf(stderr, \"maxcpus must be equal to or greater than \"\n\"smp\\n\");",
"exit(1);",
"}",
"if (max_cpus > 255) {",
"fprintf(stderr, \"Unsupported number of maxcpus\\n\");",
"exit(1);",
"}",
"break;",
"case QEMU_OPTION_vnc:\n#ifdef CONFIG_VNC\ndisplay_remote++;",
"vnc_display = VAR_17;",
"#else\nfprintf(stderr, \"VNC support is disabled\\n\");",
"exit(1);",
"#endif\nbreak;",
"case QEMU_OPTION_no_acpi:\nacpi_enabled = 0;",
"break;",
"case QEMU_OPTION_no_hpet:\nno_hpet = 1;",
"break;",
"case QEMU_OPTION_balloon:\nif (balloon_parse(VAR_17) < 0) {",
"fprintf(stderr, \"Unknown -balloon argument %s\\n\", VAR_17);",
"exit(1);",
"}",
"break;",
"case QEMU_OPTION_no_reboot:\nno_reboot = 1;",
"break;",
"case QEMU_OPTION_no_shutdown:\nno_shutdown = 1;",
"break;",
"case QEMU_OPTION_show_cursor:\ncursor_hide = 0;",
"break;",
"case QEMU_OPTION_uuid:\nif(qemu_uuid_parse(VAR_17, qemu_uuid) < 0) {",
"fprintf(stderr, \"Fail to parse UUID string.\"\n\" Wrong format.\\n\");",
"exit(1);",
"}",
"break;",
"case QEMU_OPTION_option_rom:\nif (nb_option_roms >= MAX_OPTION_ROMS) {",
"fprintf(stderr, \"Too many option ROMs\\n\");",
"exit(1);",
"}",
"opts = qemu_opts_parse(qemu_find_opts(\"option-rom\"), VAR_17, 1);",
"option_rom[nb_option_roms].name = qemu_opt_get(opts, \"romfile\");",
"option_rom[nb_option_roms].bootindex =\nqemu_opt_get_number(opts, \"bootindex\", -1);",
"if (!option_rom[nb_option_roms].name) {",
"fprintf(stderr, \"Option ROM file is not specified\\n\");",
"exit(1);",
"}",
"nb_option_roms++;",
"break;",
"case QEMU_OPTION_semihosting:\nsemihosting_enabled = 1;",
"break;",
"case QEMU_OPTION_name:\nqemu_name = g_strdup(VAR_17);",
"{",
"char *VAR_41 = strchr(qemu_name, ',');",
"if (VAR_41 != NULL) {",
"*VAR_41++ = 0;",
"if (strncmp(VAR_41, \"process=\", 8)) {",
"fprintf(stderr, \"Unknown subargument %s to -name\\n\", VAR_41);",
"exit(1);",
"}",
"VAR_41 += 8;",
"os_set_proc_name(VAR_41);",
"}",
"}",
"break;",
"case QEMU_OPTION_prom_env:\nif (nb_prom_envs >= MAX_PROM_ENVS) {",
"fprintf(stderr, \"Too many prom variables\\n\");",
"exit(1);",
"}",
"prom_envs[nb_prom_envs] = VAR_17;",
"nb_prom_envs++;",
"break;",
"case QEMU_OPTION_old_param:\nold_param = 1;",
"break;",
"case QEMU_OPTION_clock:\nconfigure_alarms(VAR_17);",
"break;",
"case QEMU_OPTION_startdate:\nconfigure_rtc_date_offset(VAR_17, 1);",
"break;",
"case QEMU_OPTION_rtc:\nopts = qemu_opts_parse(qemu_find_opts(\"rtc\"), VAR_17, 0);",
"if (!opts) {",
"exit(1);",
"}",
"configure_rtc(opts);",
"break;",
"case QEMU_OPTION_tb_size:\ntcg_tb_size = strtol(VAR_17, NULL, 0);",
"if (tcg_tb_size < 0) {",
"tcg_tb_size = 0;",
"}",
"break;",
"case QEMU_OPTION_icount:\nVAR_7 = VAR_17;",
"break;",
"case QEMU_OPTION_incoming:\nVAR_21 = VAR_17;",
"break;",
"case QEMU_OPTION_nodefaults:\ndefault_serial = 0;",
"default_parallel = 0;",
"default_virtcon = 0;",
"default_monitor = 0;",
"default_vga = 0;",
"default_net = 0;",
"default_floppy = 0;",
"default_cdrom = 0;",
"default_sdcard = 0;",
"break;",
"case QEMU_OPTION_xen_domid:\nif (!(xen_available())) {",
"printf(\"Option %s not supported for this target\\n\", VAR_29->name);",
"exit(1);",
"}",
"xen_domid = atoi(VAR_17);",
"break;",
"case QEMU_OPTION_xen_create:\nif (!(xen_available())) {",
"printf(\"Option %s not supported for this target\\n\", VAR_29->name);",
"exit(1);",
"}",
"xen_mode = XEN_CREATE;",
"break;",
"case QEMU_OPTION_xen_attach:\nif (!(xen_available())) {",
"printf(\"Option %s not supported for this target\\n\", VAR_29->name);",
"exit(1);",
"}",
"xen_mode = XEN_ATTACH;",
"break;",
"case QEMU_OPTION_trace:\n{",
"opts = qemu_opts_parse(qemu_find_opts(\"trace\"), VAR_17, 0);",
"if (!opts) {",
"exit(1);",
"}",
"VAR_25 = qemu_opt_get(opts, \"events\");",
"VAR_26 = qemu_opt_get(opts, \"file\");",
"break;",
"}",
"case QEMU_OPTION_readconfig:\n{",
"int VAR_41 = qemu_read_config_file(VAR_17);",
"if (VAR_41 < 0) {",
"fprintf(stderr, \"read config %s: %s\\n\", VAR_17,\nstrerror(-VAR_41));",
"exit(1);",
"}",
"break;",
"}",
"case QEMU_OPTION_spice:\nolist = qemu_find_opts(\"spice\");",
"if (!olist) {",
"fprintf(stderr, \"spice is not supported by this qemu build.\\n\");",
"exit(1);",
"}",
"opts = qemu_opts_parse(olist, VAR_17, 0);",
"if (!opts) {",
"fprintf(stderr, \"parse error: %s\\n\", VAR_17);",
"exit(1);",
"}",
"break;",
"case QEMU_OPTION_writeconfig:\n{",
"FILE *fp;",
"if (strcmp(VAR_17, \"-\") == 0) {",
"fp = stdout;",
"} else {",
"fp = fopen(VAR_17, \"VAR_36\");",
"if (fp == NULL) {",
"fprintf(stderr, \"open %s: %s\\n\", VAR_17, strerror(errno));",
"exit(1);",
"}",
"}",
"qemu_config_write(fp);",
"fclose(fp);",
"break;",
"}",
"default:\nos_parse_cmd_args(VAR_29->index, VAR_17);",
"}",
"}",
"}",
"loc_set_none();",
"if (VAR_23) {",
"if (VAR_24) {",
"set_cpu_log_filename(VAR_24);",
"}",
"set_cpu_log(VAR_23);",
"}",
"if (!trace_backend_init(VAR_25, VAR_26)) {",
"exit(1);",
"}",
"if (!data_dir) {",
"data_dir = os_find_datadir(VAR_1[0]);",
"}",
"if (!data_dir) {",
"data_dir = CONFIG_QEMU_DATADIR;",
"}",
"if (machine == NULL) {",
"fprintf(stderr, \"No machine found.\\n\");",
"exit(1);",
"}",
"if (!max_cpus)\nmax_cpus = smp_cpus;",
"machine->max_cpus = machine->max_cpus ?: 1;",
"if (smp_cpus > machine->max_cpus) {",
"fprintf(stderr, \"Number of SMP cpus requested (%d), exceeds max cpus \"\n\"supported by machine `%s' (%d)\\n\", smp_cpus, machine->name,\nmachine->max_cpus);",
"exit(1);",
"}",
"if (machine->default_machine_opts) {",
"QemuOptsList *list = qemu_find_opts(\"machine\");",
"const char *VAR_41 = NULL;",
"if (!QTAILQ_EMPTY(&list->head)) {",
"VAR_41 = qemu_opt_get(QTAILQ_FIRST(&list->head), \"accel\");",
"}",
"if (VAR_41 == NULL) {",
"qemu_opts_reset(list);",
"opts = qemu_opts_parse(list, machine->default_machine_opts, 0);",
"if (!opts) {",
"fprintf(stderr, \"parse error for machine %s: %s\\n\",\nmachine->name, machine->default_machine_opts);",
"exit(1);",
"}",
"}",
"}",
"qemu_opts_foreach(qemu_find_opts(\"device\"), default_driver_check, NULL, 0);",
"qemu_opts_foreach(qemu_find_opts(\"global\"), default_driver_check, NULL, 0);",
"if (machine->no_serial) {",
"default_serial = 0;",
"}",
"if (machine->no_parallel) {",
"default_parallel = 0;",
"}",
"if (!machine->use_virtcon) {",
"default_virtcon = 0;",
"}",
"if (machine->no_vga) {",
"default_vga = 0;",
"}",
"if (machine->no_floppy) {",
"default_floppy = 0;",
"}",
"if (machine->no_cdrom) {",
"default_cdrom = 0;",
"}",
"if (machine->no_sdcard) {",
"default_sdcard = 0;",
"}",
"if (display_type == DT_NOGRAPHIC) {",
"if (default_parallel)\nadd_device_config(DEV_PARALLEL, \"null\");",
"if (default_serial && default_monitor) {",
"add_device_config(DEV_SERIAL, \"mon:stdio\");",
"} else if (default_virtcon && default_monitor) {",
"add_device_config(DEV_VIRTCON, \"mon:stdio\");",
"} else {",
"if (default_serial)\nadd_device_config(DEV_SERIAL, \"stdio\");",
"if (default_virtcon)\nadd_device_config(DEV_VIRTCON, \"stdio\");",
"if (default_monitor)\nmonitor_parse(\"stdio\", \"readline\");",
"}",
"} else {",
"if (default_serial)\nadd_device_config(DEV_SERIAL, \"vc:80Cx24C\");",
"if (default_parallel)\nadd_device_config(DEV_PARALLEL, \"vc:80Cx24C\");",
"if (default_monitor)\nmonitor_parse(\"vc:80Cx24C\", \"readline\");",
"if (default_virtcon)\nadd_device_config(DEV_VIRTCON, \"vc:80Cx24C\");",
"}",
"if (default_vga)\nvga_interface_type = VGA_CIRRUS;",
"socket_init();",
"if (qemu_opts_foreach(qemu_find_opts(\"chardev\"), chardev_init_func, NULL, 1) != 0)\nexit(1);",
"#ifdef CONFIG_VIRTFS\nif (qemu_opts_foreach(qemu_find_opts(\"fsdev\"), fsdev_init_func, NULL, 1) != 0) {",
"exit(1);",
"}",
"#endif\nos_daemonize();",
"if (VAR_20 && qemu_create_pidfile(VAR_20) != 0) {",
"os_pidfile_error();",
"exit(1);",
"}",
"if (ram_size == 0) {",
"ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;",
"}",
"configure_accelerator();",
"qemu_init_cpu_loop();",
"if (qemu_init_main_loop()) {",
"fprintf(stderr, \"qemu_init_main_loop failed\\n\");",
"exit(1);",
"}",
"VAR_6 = (VAR_9 != NULL);",
"if (!VAR_6 && *VAR_10 != '\\0') {",
"fprintf(stderr, \"-append only allowed with -kernel option\\n\");",
"exit(1);",
"}",
"if (!VAR_6 && VAR_8 != NULL) {",
"fprintf(stderr, \"-initrd only allowed with -kernel option\\n\");",
"exit(1);",
"}",
"os_set_line_buffering();",
"if (init_timer_alarm() < 0) {",
"fprintf(stderr, \"could not initialize alarm timer\\n\");",
"exit(1);",
"}",
"if (VAR_7 && (kvm_enabled() || xen_enabled())) {",
"fprintf(stderr, \"-icount is not allowed with kvm or xen\\n\");",
"exit(1);",
"}",
"configure_icount(VAR_7);",
"if (net_init_clients() < 0) {",
"exit(1);",
"}",
"if (foreach_device_config(DEV_BT, bt_parse))\nexit(1);",
"if (!xen_enabled()) {",
"if (ram_size > (2047 << 20) && HOST_LONG_BITS == 32) {",
"fprintf(stderr, \"qemu: at most 2047 MB RAM can be simulated\\n\");",
"exit(1);",
"}",
"}",
"cpu_exec_init_all();",
"bdrv_init_with_whitelist();",
"blk_mig_init();",
"if (VAR_5)\nqemu_opts_foreach(qemu_find_opts(\"drive\"), drive_enable_snapshot, NULL, 0);",
"if (qemu_opts_foreach(qemu_find_opts(\"drive\"), drive_init_func, &machine->use_scsi, 1) != 0)\nexit(1);",
"default_drive(default_cdrom, VAR_5, machine->use_scsi,\nIF_DEFAULT, 2, CDROM_OPTS);",
"default_drive(default_floppy, VAR_5, machine->use_scsi,\nIF_FLOPPY, 0, FD_OPTS);",
"default_drive(default_sdcard, VAR_5, machine->use_scsi,\nIF_SD, 0, SD_OPTS);",
"register_savevm_live(NULL, \"ram\", 0, 4, NULL, ram_save_live, NULL,\nram_load, NULL);",
"if (nb_numa_nodes > 0) {",
"int VAR_41;",
"if (nb_numa_nodes > MAX_NODES) {",
"nb_numa_nodes = MAX_NODES;",
"}",
"for (VAR_41 = 0; VAR_41 < nb_numa_nodes; VAR_41++) {",
"if (node_mem[VAR_41] != 0)\nbreak;",
"}",
"if (VAR_41 == nb_numa_nodes) {",
"uint64_t usedmem = 0;",
"for (VAR_41 = 0; VAR_41 < nb_numa_nodes - 1; VAR_41++) {",
"node_mem[VAR_41] = (ram_size / nb_numa_nodes) & ~((1 << 23UL) - 1);",
"usedmem += node_mem[VAR_41];",
"}",
"node_mem[VAR_41] = ram_size - usedmem;",
"}",
"for (VAR_41 = 0; VAR_41 < nb_numa_nodes; VAR_41++) {",
"if (node_cpumask[VAR_41] != 0)\nbreak;",
"}",
"if (VAR_41 == nb_numa_nodes) {",
"for (VAR_41 = 0; VAR_41 < max_cpus; VAR_41++) {",
"node_cpumask[VAR_41 % nb_numa_nodes] |= 1 << VAR_41;",
"}",
"}",
"}",
"if (qemu_opts_foreach(qemu_find_opts(\"mon\"), mon_init_func, NULL, 1) != 0) {",
"exit(1);",
"}",
"if (foreach_device_config(DEV_SERIAL, serial_parse) < 0)\nexit(1);",
"if (foreach_device_config(DEV_PARALLEL, parallel_parse) < 0)\nexit(1);",
"if (foreach_device_config(DEV_VIRTCON, virtcon_parse) < 0)\nexit(1);",
"if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0)\nexit(1);",
"module_call_init(MODULE_INIT_DEVICE);",
"if (qemu_opts_foreach(qemu_find_opts(\"device\"), device_help_func, NULL, 0) != 0)\nexit(0);",
"if (watchdog) {",
"VAR_41 = select_watchdog(watchdog);",
"if (VAR_41 > 0)\nexit (VAR_41 == 1 ? 1 : 0);",
"}",
"if (machine->compat_props) {",
"qdev_prop_register_global_list(machine->compat_props);",
"}",
"qemu_add_globals();",
"qdev_machine_init();",
"machine->init(ram_size, VAR_11,\nVAR_9, VAR_10, VAR_8, VAR_19);",
"cpu_synchronize_all_post_init();",
"set_numa_modes();",
"current_machine = machine;",
"if (usb_enabled) {",
"if (foreach_device_config(DEV_USB, usb_parse) < 0)\nexit(1);",
"}",
"if (qemu_opts_foreach(qemu_find_opts(\"device\"), device_init_func, NULL, 1) != 0)\nexit(1);",
"net_check_clients();",
"ds = get_displaystate();",
"if (using_spice)\ndisplay_remote++;",
"if (display_type == DT_DEFAULT && !display_remote) {",
"#if defined(CONFIG_SDL) || defined(CONFIG_COCOA)\ndisplay_type = DT_SDL;",
"#elif defined(CONFIG_VNC)\nvnc_display = \"localhost:0,to=99\";",
"show_vnc_port = 1;",
"#else\ndisplay_type = DT_NONE;",
"#endif\n}",
"switch (display_type) {",
"case DT_NOGRAPHIC:\nbreak;",
"#if defined(CONFIG_CURSES)\ncase DT_CURSES:\ncurses_display_init(ds, full_screen);",
"break;",
"#endif\n#if defined(CONFIG_SDL)\ncase DT_SDL:\nsdl_display_init(ds, full_screen, no_frame);",
"break;",
"#elif defined(CONFIG_COCOA)\ncase DT_SDL:\ncocoa_display_init(ds, full_screen);",
"break;",
"#endif\ndefault:\nbreak;",
"}",
"os_setup_signal_handling();",
"#ifdef CONFIG_VNC\nif (vnc_display) {",
"vnc_display_init(ds);",
"if (vnc_display_open(ds, vnc_display) < 0)\nexit(1);",
"if (show_vnc_port) {",
"printf(\"VNC server running on `%s'\\n\", vnc_display_local_addr(ds));",
"}",
"}",
"#endif\n#ifdef CONFIG_SPICE\nif (using_spice && !qxl_enabled) {",
"qemu_spice_display_init(ds);",
"}",
"#endif\ndpy_resize(ds);",
"dcl = ds->listeners;",
"while (dcl != NULL) {",
"if (dcl->dpy_refresh != NULL) {",
"ds->gui_timer = qemu_new_timer_ms(rt_clock, gui_update, ds);",
"qemu_mod_timer(ds->gui_timer, qemu_get_clock_ms(rt_clock));",
"break;",
"}",
"dcl = dcl->next;",
"}",
"text_consoles_set_display(ds);",
"if (VAR_3 && gdbserver_start(VAR_3) < 0) {",
"fprintf(stderr, \"qemu: could not open gdbserver on device '%s'\\n\",\nVAR_3);",
"exit(1);",
"}",
"qdev_machine_creation_done();",
"if (rom_load_all() != 0) {",
"fprintf(stderr, \"rom loading failed\\n\");",
"exit(1);",
"}",
"qemu_register_reset(qbus_reset_all_fn, sysbus_get_default());",
"qemu_run_machine_init_done_notifiers();",
"qemu_system_reset(VMRESET_SILENT);",
"if (VAR_18) {",
"if (load_vmstate(VAR_18) < 0) {",
"autostart = 0;",
"}",
"}",
"if (VAR_21) {",
"runstate_set(RUN_STATE_INMIGRATE);",
"int VAR_41 = qemu_start_incoming_migration(VAR_21);",
"if (VAR_41 < 0) {",
"fprintf(stderr, \"Migration failed. Exit code %s(%d), exiting.\\n\",\nVAR_21, VAR_41);",
"exit(VAR_41);",
"}",
"} else if (autostart) {",
"vm_start();",
"}",
"os_setup_post();",
"resume_all_vcpus();",
"main_loop();",
"bdrv_close_all();",
"pause_all_vcpus();",
"net_cleanup();",
"res_free();",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81,
83
],
[
85,
87
],
[
89
],
[
91,
93
],
[
97
],
[
101
],
[
103
],
[
107
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
155
],
[
161
],
[
163
],
[
165
],
[
169
],
[
171
],
[
173
],
[
175
],
[
179
],
[
181
],
[
183,
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
197
],
[
199
],
[
203
],
[
205
],
[
207
],
[
209
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
229
],
[
231
],
[
233,
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259,
261
],
[
263
],
[
265,
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283,
285
],
[
287
],
[
289,
291
],
[
293
],
[
295,
297
],
[
299,
301,
303,
305,
307,
309,
311,
313
],
[
315
],
[
317
],
[
319
],
[
321,
323,
325,
327,
329
],
[
331
],
[
333,
335
],
[
337
],
[
339
],
[
341
],
[
343,
345,
347
],
[
349
],
[
351,
353,
355
],
[
357
],
[
359,
361
],
[
363
],
[
365,
367
],
[
369
],
[
371,
373
],
[
375
],
[
377,
379
],
[
381
],
[
383,
385
],
[
387
],
[
389
],
[
391
],
[
393,
395
],
[
397,
399
],
[
401
],
[
403
],
[
405,
407
],
[
409,
411
],
[
413
],
[
415
],
[
417,
419
],
[
421
],
[
423
],
[
425,
427
],
[
429,
431
],
[
433,
435
],
[
437,
439
],
[
441
],
[
443,
445
],
[
447
],
[
449
],
[
451
],
[
453
],
[
455
],
[
457
],
[
459
],
[
461
],
[
463
],
[
465
],
[
467,
469
],
[
471,
473
],
[
475
],
[
477
],
[
479
],
[
481,
483
],
[
485
],
[
487
],
[
489
],
[
491
],
[
493
],
[
495,
497
],
[
499
],
[
501,
503
],
[
505
],
[
507,
509,
511
],
[
513,
515
],
[
517
],
[
519,
521
],
[
523,
525
],
[
527
],
[
529,
531
],
[
533,
535
],
[
537,
539
],
[
541
],
[
543
],
[
545
],
[
547,
549
],
[
551
],
[
553,
555
],
[
557
],
[
559,
561
],
[
563
],
[
565,
567
],
[
569
],
[
571,
573,
575
],
[
577
],
[
579
],
[
581
],
[
585
],
[
587
],
[
589
],
[
591
],
[
593,
595,
597
],
[
599
],
[
601
],
[
605,
607
],
[
609
],
[
611
],
[
613
],
[
615
],
[
617,
619
],
[
621
],
[
623
],
[
625
],
[
627,
629
],
[
631
],
[
633,
635
],
[
637
],
[
639
],
[
641
],
[
643
],
[
645
],
[
647,
649,
651
],
[
653
],
[
655
],
[
657
],
[
659,
661
],
[
663
],
[
665
],
[
667
],
[
669,
671,
673,
675
],
[
677
],
[
679,
681
],
[
683
],
[
685,
687
],
[
689
],
[
691
],
[
693
],
[
695,
697
],
[
699
],
[
701
],
[
703
],
[
705,
707,
709
],
[
711
],
[
713,
715
],
[
717
],
[
719,
721,
723
],
[
725
],
[
727,
729,
731
],
[
733
],
[
735,
737
],
[
739
],
[
741
],
[
743
],
[
745
],
[
747
],
[
749
],
[
751,
753
],
[
755
],
[
757
],
[
759
],
[
761
],
[
763
],
[
765,
767
],
[
769
],
[
771,
773
],
[
775
],
[
777
],
[
779
],
[
781
],
[
783
],
[
787
],
[
789
],
[
791
],
[
793
],
[
795
],
[
799
],
[
801
],
[
803
],
[
805
],
[
807
],
[
809
],
[
811
],
[
813,
815
],
[
817
],
[
819,
821,
823
],
[
825
],
[
827,
829,
831
],
[
833
],
[
835,
837
],
[
839
],
[
841,
843
],
[
845
],
[
847,
849
],
[
851
],
[
853,
855
],
[
857
],
[
859,
861
],
[
863
],
[
865,
867
],
[
869
],
[
871,
873
],
[
875
],
[
877,
879
],
[
881
],
[
883,
885
],
[
887
],
[
889,
891
],
[
893
],
[
895,
897
],
[
899
],
[
901
],
[
903
],
[
905
],
[
907
],
[
909,
911
],
[
913
],
[
915
],
[
917,
919
],
[
921
],
[
923
],
[
925,
927
],
[
929
],
[
931
],
[
933
],
[
935,
937,
939
],
[
941
],
[
943
],
[
945
],
[
947
],
[
949
],
[
953
],
[
955
],
[
957
],
[
959
],
[
961
],
[
963,
965
],
[
967
],
[
969
],
[
971,
973
],
[
975
],
[
977
],
[
979,
981
],
[
983
],
[
985
],
[
987,
989
],
[
991
],
[
993
],
[
995,
997
],
[
999
],
[
1001
],
[
1003
],
[
1005
],
[
1007
],
[
1009,
1011
],
[
1013
],
[
1015
],
[
1017
],
[
1019
],
[
1021,
1023
],
[
1025
],
[
1027
],
[
1029
],
[
1031
],
[
1033
],
[
1035
],
[
1037
],
[
1039
],
[
1041
],
[
1043
],
[
1045
],
[
1047
],
[
1049
],
[
1051
],
[
1055
],
[
1057
],
[
1059
],
[
1061
],
[
1063
],
[
1065
],
[
1067
],
[
1069
],
[
1071
],
[
1073
],
[
1077,
1079,
1081
],
[
1083,
1085
],
[
1087
],
[
1089
],
[
1091
],
[
1093,
1095
],
[
1097
],
[
1099,
1101
],
[
1103
],
[
1105
],
[
1109
],
[
1111
],
[
1113,
1115
],
[
1117,
1119,
1121
],
[
1123
],
[
1125,
1127
],
[
1129
],
[
1131
],
[
1133,
1135
],
[
1139,
1141
],
[
1143
],
[
1145
],
[
1147,
1149
],
[
1151,
1153
],
[
1155
],
[
1157
],
[
1159
],
[
1161
],
[
1163
],
[
1167
],
[
1169
],
[
1171
],
[
1173
],
[
1175
],
[
1177
],
[
1179
],
[
1183
],
[
1185
],
[
1187
],
[
1189
],
[
1191
],
[
1193
],
[
1195,
1197
],
[
1199
],
[
1201
],
[
1203
],
[
1205
],
[
1207
],
[
1209,
1211
],
[
1213,
1215
],
[
1217
],
[
1219
],
[
1221
],
[
1223
],
[
1225,
1227
],
[
1229
],
[
1231
],
[
1233
],
[
1235
],
[
1237,
1239
],
[
1241
],
[
1243
],
[
1245
],
[
1247
],
[
1249
],
[
1251,
1253
],
[
1255
],
[
1257
],
[
1259
],
[
1261
],
[
1263
],
[
1265,
1267
],
[
1269
],
[
1271,
1273
],
[
1275
],
[
1277,
1279
],
[
1281
],
[
1283,
1285,
1287
],
[
1289
],
[
1291,
1293
],
[
1295
],
[
1297,
1299
],
[
1301
],
[
1303,
1305
],
[
1307
],
[
1309,
1311
],
[
1313
],
[
1315,
1317,
1319,
1321,
1323,
1325,
1327
],
[
1329
],
[
1331,
1333,
1335
],
[
1337
],
[
1339,
1341
],
[
1343
],
[
1345,
1347
],
[
1349
],
[
1351,
1353
],
[
1355
],
[
1357,
1359
],
[
1361
],
[
1363,
1365
],
[
1367
],
[
1369
],
[
1371
],
[
1373,
1375
],
[
1377
],
[
1379
],
[
1381
],
[
1383
],
[
1385
],
[
1387
],
[
1389
],
[
1391
],
[
1393
],
[
1395
],
[
1397
],
[
1399,
1401
],
[
1403
],
[
1405,
1407
],
[
1409
],
[
1411
],
[
1413,
1415
],
[
1417
],
[
1419
],
[
1421
],
[
1423,
1425
],
[
1427
],
[
1429
],
[
1431
],
[
1433
],
[
1435
],
[
1437,
1439
],
[
1441
],
[
1443
],
[
1445
],
[
1447
],
[
1449
],
[
1451
],
[
1453
],
[
1455,
1457,
1459
],
[
1461
],
[
1463,
1465
],
[
1467
],
[
1469,
1471
],
[
1473,
1475
],
[
1477
],
[
1479,
1481
],
[
1483
],
[
1485,
1487
],
[
1489
],
[
1491
],
[
1493
],
[
1495
],
[
1497,
1499
],
[
1501
],
[
1503,
1505
],
[
1507
],
[
1509,
1511
],
[
1513
],
[
1515,
1517
],
[
1519,
1521
],
[
1523
],
[
1525
],
[
1527
],
[
1529,
1531
],
[
1533
],
[
1535
],
[
1537
],
[
1539
],
[
1541
],
[
1543,
1545
],
[
1547
],
[
1549
],
[
1551
],
[
1553
],
[
1555
],
[
1557
],
[
1559,
1561
],
[
1563
],
[
1565,
1567
],
[
1569
],
[
1571
],
[
1573
],
[
1575
],
[
1577
],
[
1579
],
[
1581
],
[
1583
],
[
1585
],
[
1587
],
[
1589
],
[
1591
],
[
1593
],
[
1595,
1597
],
[
1599
],
[
1601
],
[
1603
],
[
1605
],
[
1607
],
[
1609
],
[
1611,
1613
],
[
1615
],
[
1617,
1619
],
[
1621
],
[
1623,
1625
],
[
1627
],
[
1629,
1631
],
[
1633
],
[
1635
],
[
1637
],
[
1639
],
[
1641
],
[
1643,
1645
],
[
1647
],
[
1649
],
[
1651
],
[
1653
],
[
1655,
1657
],
[
1659
],
[
1661,
1663
],
[
1665
],
[
1667,
1669
],
[
1671
],
[
1673
],
[
1675
],
[
1677
],
[
1679
],
[
1681
],
[
1683
],
[
1685
],
[
1687
],
[
1689,
1691
],
[
1693
],
[
1695
],
[
1697
],
[
1699
],
[
1701
],
[
1703,
1705
],
[
1707
],
[
1709
],
[
1711
],
[
1713
],
[
1715
],
[
1717,
1719
],
[
1721
],
[
1723
],
[
1725
],
[
1727
],
[
1729
],
[
1731,
1733
],
[
1735
],
[
1737
],
[
1739
],
[
1741
],
[
1743
],
[
1745
],
[
1747
],
[
1749
],
[
1751,
1753
],
[
1755
],
[
1757
],
[
1759,
1761
],
[
1763
],
[
1765
],
[
1767
],
[
1769
],
[
1771,
1773
],
[
1775
],
[
1777
],
[
1779
],
[
1781
],
[
1783
],
[
1785
],
[
1787
],
[
1789
],
[
1791
],
[
1793
],
[
1795,
1797
],
[
1799
],
[
1801
],
[
1803
],
[
1805
],
[
1807
],
[
1809
],
[
1811
],
[
1813
],
[
1815
],
[
1817
],
[
1819
],
[
1821
],
[
1823
],
[
1825
],
[
1827,
1829
],
[
1831
],
[
1833
],
[
1835
],
[
1837
],
[
1851
],
[
1853
],
[
1855
],
[
1857
],
[
1859
],
[
1861
],
[
1865
],
[
1867
],
[
1869
],
[
1877
],
[
1879
],
[
1881
],
[
1885
],
[
1887
],
[
1889
],
[
1893
],
[
1895
],
[
1897
],
[
1899
],
[
1911,
1913
],
[
1917
],
[
1919
],
[
1921,
1923,
1925
],
[
1927
],
[
1929
],
[
1941
],
[
1943
],
[
1945
],
[
1949
],
[
1951
],
[
1953
],
[
1955
],
[
1957
],
[
1959
],
[
1961
],
[
1963,
1965
],
[
1967
],
[
1969
],
[
1971
],
[
1973
],
[
1977
],
[
1979
],
[
1983
],
[
1985
],
[
1987
],
[
1989
],
[
1991
],
[
1993
],
[
1995
],
[
1997
],
[
1999
],
[
2001
],
[
2003
],
[
2005
],
[
2007
],
[
2009
],
[
2011
],
[
2013
],
[
2015
],
[
2017
],
[
2019
],
[
2021
],
[
2023
],
[
2027
],
[
2029,
2031
],
[
2033
],
[
2035
],
[
2037
],
[
2039
],
[
2041
],
[
2043,
2045
],
[
2047,
2049
],
[
2051,
2053
],
[
2055
],
[
2057
],
[
2059,
2061
],
[
2063,
2065
],
[
2067,
2069
],
[
2071,
2073
],
[
2075
],
[
2077,
2079
],
[
2083
],
[
2087,
2089
],
[
2091,
2093
],
[
2095
],
[
2097
],
[
2099,
2103
],
[
2107
],
[
2109
],
[
2111
],
[
2113
],
[
2119
],
[
2121
],
[
2123
],
[
2127
],
[
2131
],
[
2133
],
[
2135
],
[
2137
],
[
2139
],
[
2141
],
[
2145
],
[
2147
],
[
2149
],
[
2151
],
[
2155
],
[
2157
],
[
2159
],
[
2161
],
[
2165
],
[
2169
],
[
2171
],
[
2173
],
[
2175
],
[
2179
],
[
2181
],
[
2183
],
[
2185
],
[
2187
],
[
2191
],
[
2193
],
[
2195
],
[
2201,
2203
],
[
2207
],
[
2211
],
[
2213
],
[
2215
],
[
2217
],
[
2219
],
[
2223
],
[
2227
],
[
2231
],
[
2237,
2239
],
[
2241,
2243
],
[
2247,
2249
],
[
2251,
2253
],
[
2255,
2257
],
[
2261,
2263
],
[
2267
],
[
2269
],
[
2273
],
[
2275
],
[
2277
],
[
2287
],
[
2289,
2291
],
[
2293
],
[
2295
],
[
2297
],
[
2307
],
[
2309
],
[
2311
],
[
2313
],
[
2315
],
[
2317
],
[
2321
],
[
2323,
2325
],
[
2327
],
[
2337
],
[
2339
],
[
2341
],
[
2343
],
[
2345
],
[
2347
],
[
2351
],
[
2353
],
[
2355
],
[
2359,
2361
],
[
2363,
2365
],
[
2367,
2369
],
[
2371,
2373
],
[
2377
],
[
2381,
2383
],
[
2387
],
[
2389
],
[
2391,
2393
],
[
2395
],
[
2399
],
[
2401
],
[
2403
],
[
2405
],
[
2409
],
[
2413,
2415
],
[
2419
],
[
2423
],
[
2427
],
[
2433
],
[
2435,
2437
],
[
2439
],
[
2445,
2447
],
[
2451
],
[
2457
],
[
2461,
2463
],
[
2465
],
[
2467,
2469
],
[
2471,
2473
],
[
2475
],
[
2477,
2479
],
[
2481,
2483
],
[
2491
],
[
2493,
2495
],
[
2497,
2499,
2501
],
[
2503
],
[
2505,
2507,
2509,
2511
],
[
2513
],
[
2515,
2517,
2519
],
[
2521
],
[
2523,
2525,
2527
],
[
2529
],
[
2535
],
[
2539,
2543
],
[
2545
],
[
2547,
2549
],
[
2553
],
[
2555
],
[
2557
],
[
2559
],
[
2561,
2563,
2565
],
[
2567
],
[
2569
],
[
2571,
2577
],
[
2579
],
[
2581
],
[
2583
],
[
2585
],
[
2587
],
[
2589
],
[
2591
],
[
2593
],
[
2595
],
[
2597
],
[
2601
],
[
2603,
2605
],
[
2607
],
[
2609
],
[
2613
],
[
2617
],
[
2619
],
[
2621
],
[
2623
],
[
2631
],
[
2633
],
[
2637
],
[
2639
],
[
2641
],
[
2643
],
[
2645
],
[
2647
],
[
2651
],
[
2653
],
[
2655
],
[
2657
],
[
2659,
2661
],
[
2663
],
[
2665
],
[
2667
],
[
2669
],
[
2671
],
[
2675
],
[
2679
],
[
2681
],
[
2683
],
[
2685
],
[
2687
],
[
2689
],
[
2693
],
[
2695
]
]
|
13,594 | static int tcp_read(URLContext *h, uint8_t *buf, int size)
{
TCPContext *s = h->priv_data;
int size1, len, fd_max;
fd_set rfds;
struct timeval tv;
size1 = size;
while (size > 0) {
if (url_interrupt_cb())
return -EINTR;
fd_max = s->fd;
FD_ZERO(&rfds);
FD_SET(s->fd, &rfds);
tv.tv_sec = 0;
tv.tv_usec = 100 * 1000;
select(fd_max + 1, &rfds, NULL, NULL, &tv);
#ifdef __BEOS__
len = recv(s->fd, buf, size, 0);
#else
len = read(s->fd, buf, size);
#endif
if (len < 0) {
if (errno != EINTR && errno != EAGAIN)
#ifdef __BEOS__
return errno;
#else
return -errno;
#endif
else
continue;
} else if (len == 0) {
break;
}
size -= len;
buf += len;
}
return size1 - size;
}
| false | FFmpeg | 9eef2b77b29189606148e1fdf5d6c8d7b52b08b0 | static int tcp_read(URLContext *h, uint8_t *buf, int size)
{
TCPContext *s = h->priv_data;
int size1, len, fd_max;
fd_set rfds;
struct timeval tv;
size1 = size;
while (size > 0) {
if (url_interrupt_cb())
return -EINTR;
fd_max = s->fd;
FD_ZERO(&rfds);
FD_SET(s->fd, &rfds);
tv.tv_sec = 0;
tv.tv_usec = 100 * 1000;
select(fd_max + 1, &rfds, NULL, NULL, &tv);
#ifdef __BEOS__
len = recv(s->fd, buf, size, 0);
#else
len = read(s->fd, buf, size);
#endif
if (len < 0) {
if (errno != EINTR && errno != EAGAIN)
#ifdef __BEOS__
return errno;
#else
return -errno;
#endif
else
continue;
} else if (len == 0) {
break;
}
size -= len;
buf += len;
}
return size1 - size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(URLContext *VAR_0, uint8_t *VAR_1, int VAR_2)
{
TCPContext *s = VAR_0->priv_data;
int VAR_3, VAR_4, VAR_5;
fd_set rfds;
struct timeval VAR_6;
VAR_3 = VAR_2;
while (VAR_2 > 0) {
if (url_interrupt_cb())
return -EINTR;
VAR_5 = s->fd;
FD_ZERO(&rfds);
FD_SET(s->fd, &rfds);
VAR_6.tv_sec = 0;
VAR_6.tv_usec = 100 * 1000;
select(VAR_5 + 1, &rfds, NULL, NULL, &VAR_6);
#ifdef __BEOS__
VAR_4 = recv(s->fd, VAR_1, VAR_2, 0);
#else
VAR_4 = read(s->fd, VAR_1, VAR_2);
#endif
if (VAR_4 < 0) {
if (errno != EINTR && errno != EAGAIN)
#ifdef __BEOS__
return errno;
#else
return -errno;
#endif
else
continue;
} else if (VAR_4 == 0) {
break;
}
VAR_2 -= VAR_4;
VAR_1 += VAR_4;
}
return VAR_3 - VAR_2;
}
| [
"static int FUNC_0(URLContext *VAR_0, uint8_t *VAR_1, int VAR_2)\n{",
"TCPContext *s = VAR_0->priv_data;",
"int VAR_3, VAR_4, VAR_5;",
"fd_set rfds;",
"struct timeval VAR_6;",
"VAR_3 = VAR_2;",
"while (VAR_2 > 0) {",
"if (url_interrupt_cb())\nreturn -EINTR;",
"VAR_5 = s->fd;",
"FD_ZERO(&rfds);",
"FD_SET(s->fd, &rfds);",
"VAR_6.tv_sec = 0;",
"VAR_6.tv_usec = 100 * 1000;",
"select(VAR_5 + 1, &rfds, NULL, NULL, &VAR_6);",
"#ifdef __BEOS__\nVAR_4 = recv(s->fd, VAR_1, VAR_2, 0);",
"#else\nVAR_4 = read(s->fd, VAR_1, VAR_2);",
"#endif\nif (VAR_4 < 0) {",
"if (errno != EINTR && errno != EAGAIN)\n#ifdef __BEOS__\nreturn errno;",
"#else\nreturn -errno;",
"#endif\nelse\ncontinue;",
"} else if (VAR_4 == 0) {",
"break;",
"}",
"VAR_2 -= VAR_4;",
"VAR_1 += VAR_4;",
"}",
"return VAR_3 - VAR_2;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
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
]
]
|
13,596 | static int hda_codec_dev_exit(DeviceState *qdev)
{
HDACodecDevice *dev = HDA_CODEC_DEVICE(qdev);
HDACodecDeviceClass *cdc = HDA_CODEC_DEVICE_GET_CLASS(dev);
if (cdc->exit) {
cdc->exit(dev);
}
return 0;
}
| false | qemu | 8ac55351459055f2faee585d9ba2f84707741815 | static int hda_codec_dev_exit(DeviceState *qdev)
{
HDACodecDevice *dev = HDA_CODEC_DEVICE(qdev);
HDACodecDeviceClass *cdc = HDA_CODEC_DEVICE_GET_CLASS(dev);
if (cdc->exit) {
cdc->exit(dev);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(DeviceState *VAR_0)
{
HDACodecDevice *dev = HDA_CODEC_DEVICE(VAR_0);
HDACodecDeviceClass *cdc = HDA_CODEC_DEVICE_GET_CLASS(dev);
if (cdc->exit) {
cdc->exit(dev);
}
return 0;
}
| [
"static int FUNC_0(DeviceState *VAR_0)\n{",
"HDACodecDevice *dev = HDA_CODEC_DEVICE(VAR_0);",
"HDACodecDeviceClass *cdc = HDA_CODEC_DEVICE_GET_CLASS(dev);",
"if (cdc->exit) {",
"cdc->exit(dev);",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
]
|
13,597 | static bool virtqueue_map_desc(VirtIODevice *vdev, unsigned int *p_num_sg,
hwaddr *addr, struct iovec *iov,
unsigned int max_num_sg, bool is_write,
hwaddr pa, size_t sz)
{
bool ok = false;
unsigned num_sg = *p_num_sg;
assert(num_sg <= max_num_sg);
if (!sz) {
virtio_error(vdev, "virtio: zero sized buffers are not allowed");
goto out;
}
while (sz) {
hwaddr len = sz;
if (num_sg == max_num_sg) {
virtio_error(vdev, "virtio: too many write descriptors in "
"indirect table");
goto out;
}
iov[num_sg].iov_base = cpu_physical_memory_map(pa, &len, is_write);
if (!iov[num_sg].iov_base) {
virtio_error(vdev, "virtio: bogus descriptor or out of resources");
goto out;
}
iov[num_sg].iov_len = len;
addr[num_sg] = pa;
sz -= len;
pa += len;
num_sg++;
}
ok = true;
out:
*p_num_sg = num_sg;
return ok;
}
| false | qemu | 8607f5c3072caeebbe0217df28651fffd3a79fd9 | static bool virtqueue_map_desc(VirtIODevice *vdev, unsigned int *p_num_sg,
hwaddr *addr, struct iovec *iov,
unsigned int max_num_sg, bool is_write,
hwaddr pa, size_t sz)
{
bool ok = false;
unsigned num_sg = *p_num_sg;
assert(num_sg <= max_num_sg);
if (!sz) {
virtio_error(vdev, "virtio: zero sized buffers are not allowed");
goto out;
}
while (sz) {
hwaddr len = sz;
if (num_sg == max_num_sg) {
virtio_error(vdev, "virtio: too many write descriptors in "
"indirect table");
goto out;
}
iov[num_sg].iov_base = cpu_physical_memory_map(pa, &len, is_write);
if (!iov[num_sg].iov_base) {
virtio_error(vdev, "virtio: bogus descriptor or out of resources");
goto out;
}
iov[num_sg].iov_len = len;
addr[num_sg] = pa;
sz -= len;
pa += len;
num_sg++;
}
ok = true;
out:
*p_num_sg = num_sg;
return ok;
}
| {
"code": [],
"line_no": []
} | static bool FUNC_0(VirtIODevice *vdev, unsigned int *p_num_sg,
hwaddr *addr, struct iovec *iov,
unsigned int max_num_sg, bool is_write,
hwaddr pa, size_t sz)
{
bool ok = false;
unsigned VAR_0 = *p_num_sg;
assert(VAR_0 <= max_num_sg);
if (!sz) {
virtio_error(vdev, "virtio: zero sized buffers are not allowed");
goto out;
}
while (sz) {
hwaddr len = sz;
if (VAR_0 == max_num_sg) {
virtio_error(vdev, "virtio: too many write descriptors in "
"indirect table");
goto out;
}
iov[VAR_0].iov_base = cpu_physical_memory_map(pa, &len, is_write);
if (!iov[VAR_0].iov_base) {
virtio_error(vdev, "virtio: bogus descriptor or out of resources");
goto out;
}
iov[VAR_0].iov_len = len;
addr[VAR_0] = pa;
sz -= len;
pa += len;
VAR_0++;
}
ok = true;
out:
*p_num_sg = VAR_0;
return ok;
}
| [
"static bool FUNC_0(VirtIODevice *vdev, unsigned int *p_num_sg,\nhwaddr *addr, struct iovec *iov,\nunsigned int max_num_sg, bool is_write,\nhwaddr pa, size_t sz)\n{",
"bool ok = false;",
"unsigned VAR_0 = *p_num_sg;",
"assert(VAR_0 <= max_num_sg);",
"if (!sz) {",
"virtio_error(vdev, \"virtio: zero sized buffers are not allowed\");",
"goto out;",
"}",
"while (sz) {",
"hwaddr len = sz;",
"if (VAR_0 == max_num_sg) {",
"virtio_error(vdev, \"virtio: too many write descriptors in \"\n\"indirect table\");",
"goto out;",
"}",
"iov[VAR_0].iov_base = cpu_physical_memory_map(pa, &len, is_write);",
"if (!iov[VAR_0].iov_base) {",
"virtio_error(vdev, \"virtio: bogus descriptor or out of resources\");",
"goto out;",
"}",
"iov[VAR_0].iov_len = len;",
"addr[VAR_0] = pa;",
"sz -= len;",
"pa += len;",
"VAR_0++;",
"}",
"ok = true;",
"out:\n*p_num_sg = VAR_0;",
"return ok;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77,
79
],
[
81
],
[
83
]
]
|
13,598 | void i8042_setup_a20_line(ISADevice *dev, qemu_irq *a20_out)
{
ISAKBDState *isa = I8042(dev);
KBDState *s = &isa->kbd;
s->a20_out = a20_out;
}
| false | qemu | 3115b9e2d286188a54d6f415186ae556046b68a3 | void i8042_setup_a20_line(ISADevice *dev, qemu_irq *a20_out)
{
ISAKBDState *isa = I8042(dev);
KBDState *s = &isa->kbd;
s->a20_out = a20_out;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(ISADevice *VAR_0, qemu_irq *VAR_1)
{
ISAKBDState *isa = I8042(VAR_0);
KBDState *s = &isa->kbd;
s->VAR_1 = VAR_1;
}
| [
"void FUNC_0(ISADevice *VAR_0, qemu_irq *VAR_1)\n{",
"ISAKBDState *isa = I8042(VAR_0);",
"KBDState *s = &isa->kbd;",
"s->VAR_1 = VAR_1;",
"}"
]
| [
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
]
]
|
13,599 | static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
SWFContext *swf = 0;
ByteIOContext *pb = &s->pb;
int nbits, len, frame_rate, tag, v;
offset_t firstTagOff;
AVStream *ast = 0;
AVStream *vst = 0;
swf = av_malloc(sizeof(SWFContext));
if (!swf)
return -1;
s->priv_data = swf;
tag = get_be32(pb) & 0xffffff00;
if (tag == MKBETAG('C', 'W', 'S', 0))
{
av_log(s, AV_LOG_ERROR, "Compressed SWF format not supported\n");
return AVERROR_IO;
}
if (tag != MKBETAG('F', 'W', 'S', 0))
return AVERROR_IO;
get_le32(pb);
/* skip rectangle size */
nbits = get_byte(pb) >> 3;
len = (4 * nbits - 3 + 7) / 8;
url_fskip(pb, len);
frame_rate = get_le16(pb);
get_le16(pb); /* frame count */
/* The Flash Player converts 8.8 frame rates
to milliseconds internally. Do the same to get
a correct framerate */
swf->ms_per_frame = ( 1000 * 256 ) / frame_rate;
swf->samples_per_frame = 0;
swf->ch_id = -1;
firstTagOff = url_ftell(pb);
for(;;) {
tag = get_swf_tag(pb, &len);
if (tag < 0) {
if ( ast || vst ) {
if ( vst && ast ) {
vst->codec->time_base.den = ast->codec->sample_rate / swf->samples_per_frame;
vst->codec->time_base.num = 1;
}
break;
}
av_log(s, AV_LOG_ERROR, "No media found in SWF\n");
return AVERROR_IO;
}
if ( tag == TAG_VIDEOSTREAM && !vst) {
int codec_id;
swf->ch_id = get_le16(pb);
get_le16(pb);
get_le16(pb);
get_le16(pb);
get_byte(pb);
/* Check for FLV1 */
codec_id = codec_get_id(swf_codec_tags, get_byte(pb));
if ( codec_id ) {
vst = av_new_stream(s, 0);
av_set_pts_info(vst, 24, 1, 1000); /* 24 bit pts in ms */
vst->codec->codec_type = CODEC_TYPE_VIDEO;
vst->codec->codec_id = codec_id;
if ( swf->samples_per_frame ) {
vst->codec->time_base.den = 1000. / swf->ms_per_frame;
vst->codec->time_base.num = 1;
}
}
} else if ( ( tag == TAG_STREAMHEAD || tag == TAG_STREAMHEAD2 ) && !ast) {
/* streaming found */
get_byte(pb);
v = get_byte(pb);
swf->samples_per_frame = get_le16(pb);
if (len!=4)
url_fskip(pb,len-4);
/* if mp3 streaming found, OK */
if ((v & 0x20) != 0) {
if ( tag == TAG_STREAMHEAD2 ) {
get_le16(pb);
}
ast = av_new_stream(s, 1);
av_set_pts_info(ast, 24, 1, 1000); /* 24 bit pts in ms */
if (!ast)
return -ENOMEM;
if (v & 0x01)
ast->codec->channels = 2;
else
ast->codec->channels = 1;
switch((v>> 2) & 0x03) {
case 1:
ast->codec->sample_rate = 11025;
break;
case 2:
ast->codec->sample_rate = 22050;
break;
case 3:
ast->codec->sample_rate = 44100;
break;
default:
av_free(ast);
return AVERROR_IO;
}
ast->codec->codec_type = CODEC_TYPE_AUDIO;
ast->codec->codec_id = CODEC_ID_MP3;
}
} else {
url_fskip(pb, len);
}
}
url_fseek(pb, firstTagOff, SEEK_SET);
return 0;
}
| false | FFmpeg | fa73604f61e9f067feb24078128a4a3f915d628c | static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
SWFContext *swf = 0;
ByteIOContext *pb = &s->pb;
int nbits, len, frame_rate, tag, v;
offset_t firstTagOff;
AVStream *ast = 0;
AVStream *vst = 0;
swf = av_malloc(sizeof(SWFContext));
if (!swf)
return -1;
s->priv_data = swf;
tag = get_be32(pb) & 0xffffff00;
if (tag == MKBETAG('C', 'W', 'S', 0))
{
av_log(s, AV_LOG_ERROR, "Compressed SWF format not supported\n");
return AVERROR_IO;
}
if (tag != MKBETAG('F', 'W', 'S', 0))
return AVERROR_IO;
get_le32(pb);
nbits = get_byte(pb) >> 3;
len = (4 * nbits - 3 + 7) / 8;
url_fskip(pb, len);
frame_rate = get_le16(pb);
get_le16(pb);
swf->ms_per_frame = ( 1000 * 256 ) / frame_rate;
swf->samples_per_frame = 0;
swf->ch_id = -1;
firstTagOff = url_ftell(pb);
for(;;) {
tag = get_swf_tag(pb, &len);
if (tag < 0) {
if ( ast || vst ) {
if ( vst && ast ) {
vst->codec->time_base.den = ast->codec->sample_rate / swf->samples_per_frame;
vst->codec->time_base.num = 1;
}
break;
}
av_log(s, AV_LOG_ERROR, "No media found in SWF\n");
return AVERROR_IO;
}
if ( tag == TAG_VIDEOSTREAM && !vst) {
int codec_id;
swf->ch_id = get_le16(pb);
get_le16(pb);
get_le16(pb);
get_le16(pb);
get_byte(pb);
codec_id = codec_get_id(swf_codec_tags, get_byte(pb));
if ( codec_id ) {
vst = av_new_stream(s, 0);
av_set_pts_info(vst, 24, 1, 1000);
vst->codec->codec_type = CODEC_TYPE_VIDEO;
vst->codec->codec_id = codec_id;
if ( swf->samples_per_frame ) {
vst->codec->time_base.den = 1000. / swf->ms_per_frame;
vst->codec->time_base.num = 1;
}
}
} else if ( ( tag == TAG_STREAMHEAD || tag == TAG_STREAMHEAD2 ) && !ast) {
get_byte(pb);
v = get_byte(pb);
swf->samples_per_frame = get_le16(pb);
if (len!=4)
url_fskip(pb,len-4);
if ((v & 0x20) != 0) {
if ( tag == TAG_STREAMHEAD2 ) {
get_le16(pb);
}
ast = av_new_stream(s, 1);
av_set_pts_info(ast, 24, 1, 1000);
if (!ast)
return -ENOMEM;
if (v & 0x01)
ast->codec->channels = 2;
else
ast->codec->channels = 1;
switch((v>> 2) & 0x03) {
case 1:
ast->codec->sample_rate = 11025;
break;
case 2:
ast->codec->sample_rate = 22050;
break;
case 3:
ast->codec->sample_rate = 44100;
break;
default:
av_free(ast);
return AVERROR_IO;
}
ast->codec->codec_type = CODEC_TYPE_AUDIO;
ast->codec->codec_id = CODEC_ID_MP3;
}
} else {
url_fskip(pb, len);
}
}
url_fseek(pb, firstTagOff, SEEK_SET);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVFormatParameters *VAR_1)
{
SWFContext *swf = 0;
ByteIOContext *pb = &VAR_0->pb;
int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6;
offset_t firstTagOff;
AVStream *ast = 0;
AVStream *vst = 0;
swf = av_malloc(sizeof(SWFContext));
if (!swf)
return -1;
VAR_0->priv_data = swf;
VAR_5 = get_be32(pb) & 0xffffff00;
if (VAR_5 == MKBETAG('C', 'W', 'S', 0))
{
av_log(VAR_0, AV_LOG_ERROR, "Compressed SWF format not supported\n");
return AVERROR_IO;
}
if (VAR_5 != MKBETAG('F', 'W', 'S', 0))
return AVERROR_IO;
get_le32(pb);
VAR_2 = get_byte(pb) >> 3;
VAR_3 = (4 * VAR_2 - 3 + 7) / 8;
url_fskip(pb, VAR_3);
VAR_4 = get_le16(pb);
get_le16(pb);
swf->ms_per_frame = ( 1000 * 256 ) / VAR_4;
swf->samples_per_frame = 0;
swf->ch_id = -1;
firstTagOff = url_ftell(pb);
for(;;) {
VAR_5 = get_swf_tag(pb, &VAR_3);
if (VAR_5 < 0) {
if ( ast || vst ) {
if ( vst && ast ) {
vst->codec->time_base.den = ast->codec->sample_rate / swf->samples_per_frame;
vst->codec->time_base.num = 1;
}
break;
}
av_log(VAR_0, AV_LOG_ERROR, "No media found in SWF\n");
return AVERROR_IO;
}
if ( VAR_5 == TAG_VIDEOSTREAM && !vst) {
int VAR_7;
swf->ch_id = get_le16(pb);
get_le16(pb);
get_le16(pb);
get_le16(pb);
get_byte(pb);
VAR_7 = codec_get_id(swf_codec_tags, get_byte(pb));
if ( VAR_7 ) {
vst = av_new_stream(VAR_0, 0);
av_set_pts_info(vst, 24, 1, 1000);
vst->codec->codec_type = CODEC_TYPE_VIDEO;
vst->codec->VAR_7 = VAR_7;
if ( swf->samples_per_frame ) {
vst->codec->time_base.den = 1000. / swf->ms_per_frame;
vst->codec->time_base.num = 1;
}
}
} else if ( ( VAR_5 == TAG_STREAMHEAD || VAR_5 == TAG_STREAMHEAD2 ) && !ast) {
get_byte(pb);
VAR_6 = get_byte(pb);
swf->samples_per_frame = get_le16(pb);
if (VAR_3!=4)
url_fskip(pb,VAR_3-4);
if ((VAR_6 & 0x20) != 0) {
if ( VAR_5 == TAG_STREAMHEAD2 ) {
get_le16(pb);
}
ast = av_new_stream(VAR_0, 1);
av_set_pts_info(ast, 24, 1, 1000);
if (!ast)
return -ENOMEM;
if (VAR_6 & 0x01)
ast->codec->channels = 2;
else
ast->codec->channels = 1;
switch((VAR_6>> 2) & 0x03) {
case 1:
ast->codec->sample_rate = 11025;
break;
case 2:
ast->codec->sample_rate = 22050;
break;
case 3:
ast->codec->sample_rate = 44100;
break;
default:
av_free(ast);
return AVERROR_IO;
}
ast->codec->codec_type = CODEC_TYPE_AUDIO;
ast->codec->VAR_7 = CODEC_ID_MP3;
}
} else {
url_fskip(pb, VAR_3);
}
}
url_fseek(pb, firstTagOff, SEEK_SET);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVFormatParameters *VAR_1)\n{",
"SWFContext *swf = 0;",
"ByteIOContext *pb = &VAR_0->pb;",
"int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6;",
"offset_t firstTagOff;",
"AVStream *ast = 0;",
"AVStream *vst = 0;",
"swf = av_malloc(sizeof(SWFContext));",
"if (!swf)\nreturn -1;",
"VAR_0->priv_data = swf;",
"VAR_5 = get_be32(pb) & 0xffffff00;",
"if (VAR_5 == MKBETAG('C', 'W', 'S', 0))\n{",
"av_log(VAR_0, AV_LOG_ERROR, \"Compressed SWF format not supported\\n\");",
"return AVERROR_IO;",
"}",
"if (VAR_5 != MKBETAG('F', 'W', 'S', 0))\nreturn AVERROR_IO;",
"get_le32(pb);",
"VAR_2 = get_byte(pb) >> 3;",
"VAR_3 = (4 * VAR_2 - 3 + 7) / 8;",
"url_fskip(pb, VAR_3);",
"VAR_4 = get_le16(pb);",
"get_le16(pb);",
"swf->ms_per_frame = ( 1000 * 256 ) / VAR_4;",
"swf->samples_per_frame = 0;",
"swf->ch_id = -1;",
"firstTagOff = url_ftell(pb);",
"for(;;) {",
"VAR_5 = get_swf_tag(pb, &VAR_3);",
"if (VAR_5 < 0) {",
"if ( ast || vst ) {",
"if ( vst && ast ) {",
"vst->codec->time_base.den = ast->codec->sample_rate / swf->samples_per_frame;",
"vst->codec->time_base.num = 1;",
"}",
"break;",
"}",
"av_log(VAR_0, AV_LOG_ERROR, \"No media found in SWF\\n\");",
"return AVERROR_IO;",
"}",
"if ( VAR_5 == TAG_VIDEOSTREAM && !vst) {",
"int VAR_7;",
"swf->ch_id = get_le16(pb);",
"get_le16(pb);",
"get_le16(pb);",
"get_le16(pb);",
"get_byte(pb);",
"VAR_7 = codec_get_id(swf_codec_tags, get_byte(pb));",
"if ( VAR_7 ) {",
"vst = av_new_stream(VAR_0, 0);",
"av_set_pts_info(vst, 24, 1, 1000);",
"vst->codec->codec_type = CODEC_TYPE_VIDEO;",
"vst->codec->VAR_7 = VAR_7;",
"if ( swf->samples_per_frame ) {",
"vst->codec->time_base.den = 1000. / swf->ms_per_frame;",
"vst->codec->time_base.num = 1;",
"}",
"}",
"} else if ( ( VAR_5 == TAG_STREAMHEAD || VAR_5 == TAG_STREAMHEAD2 ) && !ast) {",
"get_byte(pb);",
"VAR_6 = get_byte(pb);",
"swf->samples_per_frame = get_le16(pb);",
"if (VAR_3!=4)\nurl_fskip(pb,VAR_3-4);",
"if ((VAR_6 & 0x20) != 0) {",
"if ( VAR_5 == TAG_STREAMHEAD2 ) {",
"get_le16(pb);",
"}",
"ast = av_new_stream(VAR_0, 1);",
"av_set_pts_info(ast, 24, 1, 1000);",
"if (!ast)\nreturn -ENOMEM;",
"if (VAR_6 & 0x01)\nast->codec->channels = 2;",
"else\nast->codec->channels = 1;",
"switch((VAR_6>> 2) & 0x03) {",
"case 1:\nast->codec->sample_rate = 11025;",
"break;",
"case 2:\nast->codec->sample_rate = 22050;",
"break;",
"case 3:\nast->codec->sample_rate = 44100;",
"break;",
"default:\nav_free(ast);",
"return AVERROR_IO;",
"}",
"ast->codec->codec_type = CODEC_TYPE_AUDIO;",
"ast->codec->VAR_7 = CODEC_ID_MP3;",
"}",
"} else {",
"url_fskip(pb, VAR_3);",
"}",
"}",
"url_fseek(pb, firstTagOff, SEEK_SET);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21,
23
],
[
25
],
[
29
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155,
157
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173,
175
],
[
179,
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
],
[
235
],
[
237
]
]
|
13,600 | void ff_weight_h264_pixels16_8_msa(uint8_t *src, int stride,
int height, int log2_denom,
int weight_src, int offset)
{
avc_wgt_16width_msa(src, stride,
height, log2_denom, weight_src, offset);
}
| false | FFmpeg | bcd7bf7eeb09a395cc01698842d1b8be9af483fc | void ff_weight_h264_pixels16_8_msa(uint8_t *src, int stride,
int height, int log2_denom,
int weight_src, int offset)
{
avc_wgt_16width_msa(src, stride,
height, log2_denom, weight_src, offset);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(uint8_t *VAR_0, int VAR_1,
int VAR_2, int VAR_3,
int VAR_4, int VAR_5)
{
avc_wgt_16width_msa(VAR_0, VAR_1,
VAR_2, VAR_3, VAR_4, VAR_5);
}
| [
"void FUNC_0(uint8_t *VAR_0, int VAR_1,\nint VAR_2, int VAR_3,\nint VAR_4, int VAR_5)\n{",
"avc_wgt_16width_msa(VAR_0, VAR_1,\nVAR_2, VAR_3, VAR_4, VAR_5);",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9,
11
],
[
13
]
]
|
13,601 | static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
const uint8_t *buf, int buf_size)
{
int cmd_pos, pos, cmd, x1, y1, x2, y2, offset1, offset2, next_cmd_pos;
int big_offsets, offset_size, is_8bit = 0;
const uint8_t *yuv_palette = 0;
uint8_t colormap[4] = { 0 }, alpha[256] = { 0 };
int date;
int i;
int is_menu = 0;
if (buf_size < 10)
return -1;
memset(sub_header, 0, sizeof(*sub_header));
if (AV_RB16(buf) == 0) { /* HD subpicture with 4-byte offsets */
big_offsets = 1;
offset_size = 4;
cmd_pos = 6;
} else {
big_offsets = 0;
offset_size = 2;
cmd_pos = 2;
}
cmd_pos = READ_OFFSET(buf + cmd_pos);
while (cmd_pos > 0 && cmd_pos < buf_size - 2 - offset_size) {
date = AV_RB16(buf + cmd_pos);
next_cmd_pos = READ_OFFSET(buf + cmd_pos + 2);
av_dlog(NULL, "cmd_pos=0x%04x next=0x%04x date=%d\n",
cmd_pos, next_cmd_pos, date);
pos = cmd_pos + 2 + offset_size;
offset1 = -1;
offset2 = -1;
x1 = y1 = x2 = y2 = 0;
while (pos < buf_size) {
cmd = buf[pos++];
av_dlog(NULL, "cmd=%02x\n", cmd);
switch(cmd) {
case 0x00:
/* menu subpicture */
is_menu = 1;
break;
case 0x01:
/* set start date */
sub_header->start_display_time = (date << 10) / 90;
break;
case 0x02:
/* set end date */
sub_header->end_display_time = (date << 10) / 90;
break;
case 0x03:
/* set colormap */
if ((buf_size - pos) < 2)
goto fail;
colormap[3] = buf[pos] >> 4;
colormap[2] = buf[pos] & 0x0f;
colormap[1] = buf[pos + 1] >> 4;
colormap[0] = buf[pos + 1] & 0x0f;
pos += 2;
break;
case 0x04:
/* set alpha */
if ((buf_size - pos) < 2)
goto fail;
alpha[3] = buf[pos] >> 4;
alpha[2] = buf[pos] & 0x0f;
alpha[1] = buf[pos + 1] >> 4;
alpha[0] = buf[pos + 1] & 0x0f;
pos += 2;
av_dlog(NULL, "alpha=%x%x%x%x\n", alpha[0],alpha[1],alpha[2],alpha[3]);
break;
case 0x05:
case 0x85:
if ((buf_size - pos) < 6)
goto fail;
x1 = (buf[pos] << 4) | (buf[pos + 1] >> 4);
x2 = ((buf[pos + 1] & 0x0f) << 8) | buf[pos + 2];
y1 = (buf[pos + 3] << 4) | (buf[pos + 4] >> 4);
y2 = ((buf[pos + 4] & 0x0f) << 8) | buf[pos + 5];
if (cmd & 0x80)
is_8bit = 1;
av_dlog(NULL, "x1=%d x2=%d y1=%d y2=%d\n", x1, x2, y1, y2);
pos += 6;
break;
case 0x06:
if ((buf_size - pos) < 4)
goto fail;
offset1 = AV_RB16(buf + pos);
offset2 = AV_RB16(buf + pos + 2);
av_dlog(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
pos += 4;
break;
case 0x86:
if ((buf_size - pos) < 8)
goto fail;
offset1 = AV_RB32(buf + pos);
offset2 = AV_RB32(buf + pos + 4);
av_dlog(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
pos += 8;
break;
case 0x83:
/* HD set palette */
if ((buf_size - pos) < 768)
goto fail;
yuv_palette = buf + pos;
pos += 768;
break;
case 0x84:
/* HD set contrast (alpha) */
if ((buf_size - pos) < 256)
goto fail;
for (i = 0; i < 256; i++)
alpha[i] = 0xFF - buf[pos+i];
pos += 256;
break;
case 0xff:
goto the_end;
default:
av_dlog(NULL, "unrecognised subpicture command 0x%x\n", cmd);
goto the_end;
}
}
the_end:
if (offset1 >= 0) {
int w, h;
uint8_t *bitmap;
/* decode the bitmap */
w = x2 - x1 + 1;
if (w < 0)
w = 0;
h = y2 - y1;
if (h < 0)
h = 0;
if (w > 0 && h > 0) {
if (sub_header->rects != NULL) {
for (i = 0; i < sub_header->num_rects; i++) {
av_freep(&sub_header->rects[i]->pict.data[0]);
av_freep(&sub_header->rects[i]->pict.data[1]);
av_freep(&sub_header->rects[i]);
}
av_freep(&sub_header->rects);
sub_header->num_rects = 0;
}
bitmap = av_malloc(w * h);
sub_header->rects = av_mallocz(sizeof(*sub_header->rects));
sub_header->rects[0] = av_mallocz(sizeof(AVSubtitleRect));
sub_header->num_rects = 1;
sub_header->rects[0]->pict.data[0] = bitmap;
decode_rle(bitmap, w * 2, w, (h + 1) / 2,
buf, offset1, buf_size, is_8bit);
decode_rle(bitmap + w, w * 2, w, h / 2,
buf, offset2, buf_size, is_8bit);
sub_header->rects[0]->pict.data[1] = av_mallocz(AVPALETTE_SIZE);
if (is_8bit) {
if (yuv_palette == 0)
goto fail;
sub_header->rects[0]->nb_colors = 256;
yuv_a_to_rgba(yuv_palette, alpha, (uint32_t*)sub_header->rects[0]->pict.data[1], 256);
} else {
sub_header->rects[0]->nb_colors = 4;
guess_palette(ctx,
(uint32_t*)sub_header->rects[0]->pict.data[1],
colormap, alpha, 0xffff00);
}
sub_header->rects[0]->x = x1;
sub_header->rects[0]->y = y1;
sub_header->rects[0]->w = w;
sub_header->rects[0]->h = h;
sub_header->rects[0]->type = SUBTITLE_BITMAP;
sub_header->rects[0]->pict.linesize[0] = w;
}
}
if (next_cmd_pos == cmd_pos)
break;
cmd_pos = next_cmd_pos;
}
if (sub_header->num_rects > 0)
return is_menu;
fail:
if (sub_header->rects != NULL) {
for (i = 0; i < sub_header->num_rects; i++) {
av_freep(&sub_header->rects[i]->pict.data[0]);
av_freep(&sub_header->rects[i]->pict.data[1]);
av_freep(&sub_header->rects[i]);
}
av_freep(&sub_header->rects);
sub_header->num_rects = 0;
}
return -1;
}
| false | FFmpeg | f929ab0569ff31ed5a59b0b0adb7ce09df3fca39 | static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
const uint8_t *buf, int buf_size)
{
int cmd_pos, pos, cmd, x1, y1, x2, y2, offset1, offset2, next_cmd_pos;
int big_offsets, offset_size, is_8bit = 0;
const uint8_t *yuv_palette = 0;
uint8_t colormap[4] = { 0 }, alpha[256] = { 0 };
int date;
int i;
int is_menu = 0;
if (buf_size < 10)
return -1;
memset(sub_header, 0, sizeof(*sub_header));
if (AV_RB16(buf) == 0) {
big_offsets = 1;
offset_size = 4;
cmd_pos = 6;
} else {
big_offsets = 0;
offset_size = 2;
cmd_pos = 2;
}
cmd_pos = READ_OFFSET(buf + cmd_pos);
while (cmd_pos > 0 && cmd_pos < buf_size - 2 - offset_size) {
date = AV_RB16(buf + cmd_pos);
next_cmd_pos = READ_OFFSET(buf + cmd_pos + 2);
av_dlog(NULL, "cmd_pos=0x%04x next=0x%04x date=%d\n",
cmd_pos, next_cmd_pos, date);
pos = cmd_pos + 2 + offset_size;
offset1 = -1;
offset2 = -1;
x1 = y1 = x2 = y2 = 0;
while (pos < buf_size) {
cmd = buf[pos++];
av_dlog(NULL, "cmd=%02x\n", cmd);
switch(cmd) {
case 0x00:
is_menu = 1;
break;
case 0x01:
sub_header->start_display_time = (date << 10) / 90;
break;
case 0x02:
sub_header->end_display_time = (date << 10) / 90;
break;
case 0x03:
if ((buf_size - pos) < 2)
goto fail;
colormap[3] = buf[pos] >> 4;
colormap[2] = buf[pos] & 0x0f;
colormap[1] = buf[pos + 1] >> 4;
colormap[0] = buf[pos + 1] & 0x0f;
pos += 2;
break;
case 0x04:
if ((buf_size - pos) < 2)
goto fail;
alpha[3] = buf[pos] >> 4;
alpha[2] = buf[pos] & 0x0f;
alpha[1] = buf[pos + 1] >> 4;
alpha[0] = buf[pos + 1] & 0x0f;
pos += 2;
av_dlog(NULL, "alpha=%x%x%x%x\n", alpha[0],alpha[1],alpha[2],alpha[3]);
break;
case 0x05:
case 0x85:
if ((buf_size - pos) < 6)
goto fail;
x1 = (buf[pos] << 4) | (buf[pos + 1] >> 4);
x2 = ((buf[pos + 1] & 0x0f) << 8) | buf[pos + 2];
y1 = (buf[pos + 3] << 4) | (buf[pos + 4] >> 4);
y2 = ((buf[pos + 4] & 0x0f) << 8) | buf[pos + 5];
if (cmd & 0x80)
is_8bit = 1;
av_dlog(NULL, "x1=%d x2=%d y1=%d y2=%d\n", x1, x2, y1, y2);
pos += 6;
break;
case 0x06:
if ((buf_size - pos) < 4)
goto fail;
offset1 = AV_RB16(buf + pos);
offset2 = AV_RB16(buf + pos + 2);
av_dlog(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
pos += 4;
break;
case 0x86:
if ((buf_size - pos) < 8)
goto fail;
offset1 = AV_RB32(buf + pos);
offset2 = AV_RB32(buf + pos + 4);
av_dlog(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
pos += 8;
break;
case 0x83:
if ((buf_size - pos) < 768)
goto fail;
yuv_palette = buf + pos;
pos += 768;
break;
case 0x84:
if ((buf_size - pos) < 256)
goto fail;
for (i = 0; i < 256; i++)
alpha[i] = 0xFF - buf[pos+i];
pos += 256;
break;
case 0xff:
goto the_end;
default:
av_dlog(NULL, "unrecognised subpicture command 0x%x\n", cmd);
goto the_end;
}
}
the_end:
if (offset1 >= 0) {
int w, h;
uint8_t *bitmap;
w = x2 - x1 + 1;
if (w < 0)
w = 0;
h = y2 - y1;
if (h < 0)
h = 0;
if (w > 0 && h > 0) {
if (sub_header->rects != NULL) {
for (i = 0; i < sub_header->num_rects; i++) {
av_freep(&sub_header->rects[i]->pict.data[0]);
av_freep(&sub_header->rects[i]->pict.data[1]);
av_freep(&sub_header->rects[i]);
}
av_freep(&sub_header->rects);
sub_header->num_rects = 0;
}
bitmap = av_malloc(w * h);
sub_header->rects = av_mallocz(sizeof(*sub_header->rects));
sub_header->rects[0] = av_mallocz(sizeof(AVSubtitleRect));
sub_header->num_rects = 1;
sub_header->rects[0]->pict.data[0] = bitmap;
decode_rle(bitmap, w * 2, w, (h + 1) / 2,
buf, offset1, buf_size, is_8bit);
decode_rle(bitmap + w, w * 2, w, h / 2,
buf, offset2, buf_size, is_8bit);
sub_header->rects[0]->pict.data[1] = av_mallocz(AVPALETTE_SIZE);
if (is_8bit) {
if (yuv_palette == 0)
goto fail;
sub_header->rects[0]->nb_colors = 256;
yuv_a_to_rgba(yuv_palette, alpha, (uint32_t*)sub_header->rects[0]->pict.data[1], 256);
} else {
sub_header->rects[0]->nb_colors = 4;
guess_palette(ctx,
(uint32_t*)sub_header->rects[0]->pict.data[1],
colormap, alpha, 0xffff00);
}
sub_header->rects[0]->x = x1;
sub_header->rects[0]->y = y1;
sub_header->rects[0]->w = w;
sub_header->rects[0]->h = h;
sub_header->rects[0]->type = SUBTITLE_BITMAP;
sub_header->rects[0]->pict.linesize[0] = w;
}
}
if (next_cmd_pos == cmd_pos)
break;
cmd_pos = next_cmd_pos;
}
if (sub_header->num_rects > 0)
return is_menu;
fail:
if (sub_header->rects != NULL) {
for (i = 0; i < sub_header->num_rects; i++) {
av_freep(&sub_header->rects[i]->pict.data[0]);
av_freep(&sub_header->rects[i]->pict.data[1]);
av_freep(&sub_header->rects[i]);
}
av_freep(&sub_header->rects);
sub_header->num_rects = 0;
}
return -1;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(DVDSubContext *VAR_0, AVSubtitle *VAR_1,
const uint8_t *VAR_2, int VAR_3)
{
int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13;
int VAR_14, VAR_15, VAR_16 = 0;
const uint8_t *VAR_17 = 0;
uint8_t colormap[4] = { 0 }, alpha[256] = { 0 };
int VAR_18;
int VAR_19;
int VAR_20 = 0;
if (VAR_3 < 10)
return -1;
memset(VAR_1, 0, sizeof(*VAR_1));
if (AV_RB16(VAR_2) == 0) {
VAR_14 = 1;
VAR_15 = 4;
VAR_4 = 6;
} else {
VAR_14 = 0;
VAR_15 = 2;
VAR_4 = 2;
}
VAR_4 = READ_OFFSET(VAR_2 + VAR_4);
while (VAR_4 > 0 && VAR_4 < VAR_3 - 2 - VAR_15) {
VAR_18 = AV_RB16(VAR_2 + VAR_4);
VAR_13 = READ_OFFSET(VAR_2 + VAR_4 + 2);
av_dlog(NULL, "VAR_4=0x%04x next=0x%04x VAR_18=%d\n",
VAR_4, VAR_13, VAR_18);
VAR_5 = VAR_4 + 2 + VAR_15;
VAR_11 = -1;
VAR_12 = -1;
VAR_7 = VAR_8 = VAR_9 = VAR_10 = 0;
while (VAR_5 < VAR_3) {
VAR_6 = VAR_2[VAR_5++];
av_dlog(NULL, "VAR_6=%02x\n", VAR_6);
switch(VAR_6) {
case 0x00:
VAR_20 = 1;
break;
case 0x01:
VAR_1->start_display_time = (VAR_18 << 10) / 90;
break;
case 0x02:
VAR_1->end_display_time = (VAR_18 << 10) / 90;
break;
case 0x03:
if ((VAR_3 - VAR_5) < 2)
goto fail;
colormap[3] = VAR_2[VAR_5] >> 4;
colormap[2] = VAR_2[VAR_5] & 0x0f;
colormap[1] = VAR_2[VAR_5 + 1] >> 4;
colormap[0] = VAR_2[VAR_5 + 1] & 0x0f;
VAR_5 += 2;
break;
case 0x04:
if ((VAR_3 - VAR_5) < 2)
goto fail;
alpha[3] = VAR_2[VAR_5] >> 4;
alpha[2] = VAR_2[VAR_5] & 0x0f;
alpha[1] = VAR_2[VAR_5 + 1] >> 4;
alpha[0] = VAR_2[VAR_5 + 1] & 0x0f;
VAR_5 += 2;
av_dlog(NULL, "alpha=%x%x%x%x\n", alpha[0],alpha[1],alpha[2],alpha[3]);
break;
case 0x05:
case 0x85:
if ((VAR_3 - VAR_5) < 6)
goto fail;
VAR_7 = (VAR_2[VAR_5] << 4) | (VAR_2[VAR_5 + 1] >> 4);
VAR_9 = ((VAR_2[VAR_5 + 1] & 0x0f) << 8) | VAR_2[VAR_5 + 2];
VAR_8 = (VAR_2[VAR_5 + 3] << 4) | (VAR_2[VAR_5 + 4] >> 4);
VAR_10 = ((VAR_2[VAR_5 + 4] & 0x0f) << 8) | VAR_2[VAR_5 + 5];
if (VAR_6 & 0x80)
VAR_16 = 1;
av_dlog(NULL, "VAR_7=%d VAR_9=%d VAR_8=%d VAR_10=%d\n", VAR_7, VAR_9, VAR_8, VAR_10);
VAR_5 += 6;
break;
case 0x06:
if ((VAR_3 - VAR_5) < 4)
goto fail;
VAR_11 = AV_RB16(VAR_2 + VAR_5);
VAR_12 = AV_RB16(VAR_2 + VAR_5 + 2);
av_dlog(NULL, "VAR_11=0x%04x VAR_12=0x%04x\n", VAR_11, VAR_12);
VAR_5 += 4;
break;
case 0x86:
if ((VAR_3 - VAR_5) < 8)
goto fail;
VAR_11 = AV_RB32(VAR_2 + VAR_5);
VAR_12 = AV_RB32(VAR_2 + VAR_5 + 4);
av_dlog(NULL, "VAR_11=0x%04x VAR_12=0x%04x\n", VAR_11, VAR_12);
VAR_5 += 8;
break;
case 0x83:
if ((VAR_3 - VAR_5) < 768)
goto fail;
VAR_17 = VAR_2 + VAR_5;
VAR_5 += 768;
break;
case 0x84:
if ((VAR_3 - VAR_5) < 256)
goto fail;
for (VAR_19 = 0; VAR_19 < 256; VAR_19++)
alpha[VAR_19] = 0xFF - VAR_2[VAR_5+VAR_19];
VAR_5 += 256;
break;
case 0xff:
goto the_end;
default:
av_dlog(NULL, "unrecognised subpicture command 0x%x\n", VAR_6);
goto the_end;
}
}
the_end:
if (VAR_11 >= 0) {
int VAR_21, VAR_22;
uint8_t *bitmap;
VAR_21 = VAR_9 - VAR_7 + 1;
if (VAR_21 < 0)
VAR_21 = 0;
VAR_22 = VAR_10 - VAR_8;
if (VAR_22 < 0)
VAR_22 = 0;
if (VAR_21 > 0 && VAR_22 > 0) {
if (VAR_1->rects != NULL) {
for (VAR_19 = 0; VAR_19 < VAR_1->num_rects; VAR_19++) {
av_freep(&VAR_1->rects[VAR_19]->pict.data[0]);
av_freep(&VAR_1->rects[VAR_19]->pict.data[1]);
av_freep(&VAR_1->rects[VAR_19]);
}
av_freep(&VAR_1->rects);
VAR_1->num_rects = 0;
}
bitmap = av_malloc(VAR_21 * VAR_22);
VAR_1->rects = av_mallocz(sizeof(*VAR_1->rects));
VAR_1->rects[0] = av_mallocz(sizeof(AVSubtitleRect));
VAR_1->num_rects = 1;
VAR_1->rects[0]->pict.data[0] = bitmap;
decode_rle(bitmap, VAR_21 * 2, VAR_21, (VAR_22 + 1) / 2,
VAR_2, VAR_11, VAR_3, VAR_16);
decode_rle(bitmap + VAR_21, VAR_21 * 2, VAR_21, VAR_22 / 2,
VAR_2, VAR_12, VAR_3, VAR_16);
VAR_1->rects[0]->pict.data[1] = av_mallocz(AVPALETTE_SIZE);
if (VAR_16) {
if (VAR_17 == 0)
goto fail;
VAR_1->rects[0]->nb_colors = 256;
yuv_a_to_rgba(VAR_17, alpha, (uint32_t*)VAR_1->rects[0]->pict.data[1], 256);
} else {
VAR_1->rects[0]->nb_colors = 4;
guess_palette(VAR_0,
(uint32_t*)VAR_1->rects[0]->pict.data[1],
colormap, alpha, 0xffff00);
}
VAR_1->rects[0]->x = VAR_7;
VAR_1->rects[0]->y = VAR_8;
VAR_1->rects[0]->VAR_21 = VAR_21;
VAR_1->rects[0]->VAR_22 = VAR_22;
VAR_1->rects[0]->type = SUBTITLE_BITMAP;
VAR_1->rects[0]->pict.linesize[0] = VAR_21;
}
}
if (VAR_13 == VAR_4)
break;
VAR_4 = VAR_13;
}
if (VAR_1->num_rects > 0)
return VAR_20;
fail:
if (VAR_1->rects != NULL) {
for (VAR_19 = 0; VAR_19 < VAR_1->num_rects; VAR_19++) {
av_freep(&VAR_1->rects[VAR_19]->pict.data[0]);
av_freep(&VAR_1->rects[VAR_19]->pict.data[1]);
av_freep(&VAR_1->rects[VAR_19]);
}
av_freep(&VAR_1->rects);
VAR_1->num_rects = 0;
}
return -1;
}
| [
"static int FUNC_0(DVDSubContext *VAR_0, AVSubtitle *VAR_1,\nconst uint8_t *VAR_2, int VAR_3)\n{",
"int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13;",
"int VAR_14, VAR_15, VAR_16 = 0;",
"const uint8_t *VAR_17 = 0;",
"uint8_t colormap[4] = { 0 }, alpha[256] = { 0 };",
"int VAR_18;",
"int VAR_19;",
"int VAR_20 = 0;",
"if (VAR_3 < 10)\nreturn -1;",
"memset(VAR_1, 0, sizeof(*VAR_1));",
"if (AV_RB16(VAR_2) == 0) {",
"VAR_14 = 1;",
"VAR_15 = 4;",
"VAR_4 = 6;",
"} else {",
"VAR_14 = 0;",
"VAR_15 = 2;",
"VAR_4 = 2;",
"}",
"VAR_4 = READ_OFFSET(VAR_2 + VAR_4);",
"while (VAR_4 > 0 && VAR_4 < VAR_3 - 2 - VAR_15) {",
"VAR_18 = AV_RB16(VAR_2 + VAR_4);",
"VAR_13 = READ_OFFSET(VAR_2 + VAR_4 + 2);",
"av_dlog(NULL, \"VAR_4=0x%04x next=0x%04x VAR_18=%d\\n\",\nVAR_4, VAR_13, VAR_18);",
"VAR_5 = VAR_4 + 2 + VAR_15;",
"VAR_11 = -1;",
"VAR_12 = -1;",
"VAR_7 = VAR_8 = VAR_9 = VAR_10 = 0;",
"while (VAR_5 < VAR_3) {",
"VAR_6 = VAR_2[VAR_5++];",
"av_dlog(NULL, \"VAR_6=%02x\\n\", VAR_6);",
"switch(VAR_6) {",
"case 0x00:\nVAR_20 = 1;",
"break;",
"case 0x01:\nVAR_1->start_display_time = (VAR_18 << 10) / 90;",
"break;",
"case 0x02:\nVAR_1->end_display_time = (VAR_18 << 10) / 90;",
"break;",
"case 0x03:\nif ((VAR_3 - VAR_5) < 2)\ngoto fail;",
"colormap[3] = VAR_2[VAR_5] >> 4;",
"colormap[2] = VAR_2[VAR_5] & 0x0f;",
"colormap[1] = VAR_2[VAR_5 + 1] >> 4;",
"colormap[0] = VAR_2[VAR_5 + 1] & 0x0f;",
"VAR_5 += 2;",
"break;",
"case 0x04:\nif ((VAR_3 - VAR_5) < 2)\ngoto fail;",
"alpha[3] = VAR_2[VAR_5] >> 4;",
"alpha[2] = VAR_2[VAR_5] & 0x0f;",
"alpha[1] = VAR_2[VAR_5 + 1] >> 4;",
"alpha[0] = VAR_2[VAR_5 + 1] & 0x0f;",
"VAR_5 += 2;",
"av_dlog(NULL, \"alpha=%x%x%x%x\\n\", alpha[0],alpha[1],alpha[2],alpha[3]);",
"break;",
"case 0x05:\ncase 0x85:\nif ((VAR_3 - VAR_5) < 6)\ngoto fail;",
"VAR_7 = (VAR_2[VAR_5] << 4) | (VAR_2[VAR_5 + 1] >> 4);",
"VAR_9 = ((VAR_2[VAR_5 + 1] & 0x0f) << 8) | VAR_2[VAR_5 + 2];",
"VAR_8 = (VAR_2[VAR_5 + 3] << 4) | (VAR_2[VAR_5 + 4] >> 4);",
"VAR_10 = ((VAR_2[VAR_5 + 4] & 0x0f) << 8) | VAR_2[VAR_5 + 5];",
"if (VAR_6 & 0x80)\nVAR_16 = 1;",
"av_dlog(NULL, \"VAR_7=%d VAR_9=%d VAR_8=%d VAR_10=%d\\n\", VAR_7, VAR_9, VAR_8, VAR_10);",
"VAR_5 += 6;",
"break;",
"case 0x06:\nif ((VAR_3 - VAR_5) < 4)\ngoto fail;",
"VAR_11 = AV_RB16(VAR_2 + VAR_5);",
"VAR_12 = AV_RB16(VAR_2 + VAR_5 + 2);",
"av_dlog(NULL, \"VAR_11=0x%04x VAR_12=0x%04x\\n\", VAR_11, VAR_12);",
"VAR_5 += 4;",
"break;",
"case 0x86:\nif ((VAR_3 - VAR_5) < 8)\ngoto fail;",
"VAR_11 = AV_RB32(VAR_2 + VAR_5);",
"VAR_12 = AV_RB32(VAR_2 + VAR_5 + 4);",
"av_dlog(NULL, \"VAR_11=0x%04x VAR_12=0x%04x\\n\", VAR_11, VAR_12);",
"VAR_5 += 8;",
"break;",
"case 0x83:\nif ((VAR_3 - VAR_5) < 768)\ngoto fail;",
"VAR_17 = VAR_2 + VAR_5;",
"VAR_5 += 768;",
"break;",
"case 0x84:\nif ((VAR_3 - VAR_5) < 256)\ngoto fail;",
"for (VAR_19 = 0; VAR_19 < 256; VAR_19++)",
"alpha[VAR_19] = 0xFF - VAR_2[VAR_5+VAR_19];",
"VAR_5 += 256;",
"break;",
"case 0xff:\ngoto the_end;",
"default:\nav_dlog(NULL, \"unrecognised subpicture command 0x%x\\n\", VAR_6);",
"goto the_end;",
"}",
"}",
"the_end:\nif (VAR_11 >= 0) {",
"int VAR_21, VAR_22;",
"uint8_t *bitmap;",
"VAR_21 = VAR_9 - VAR_7 + 1;",
"if (VAR_21 < 0)\nVAR_21 = 0;",
"VAR_22 = VAR_10 - VAR_8;",
"if (VAR_22 < 0)\nVAR_22 = 0;",
"if (VAR_21 > 0 && VAR_22 > 0) {",
"if (VAR_1->rects != NULL) {",
"for (VAR_19 = 0; VAR_19 < VAR_1->num_rects; VAR_19++) {",
"av_freep(&VAR_1->rects[VAR_19]->pict.data[0]);",
"av_freep(&VAR_1->rects[VAR_19]->pict.data[1]);",
"av_freep(&VAR_1->rects[VAR_19]);",
"}",
"av_freep(&VAR_1->rects);",
"VAR_1->num_rects = 0;",
"}",
"bitmap = av_malloc(VAR_21 * VAR_22);",
"VAR_1->rects = av_mallocz(sizeof(*VAR_1->rects));",
"VAR_1->rects[0] = av_mallocz(sizeof(AVSubtitleRect));",
"VAR_1->num_rects = 1;",
"VAR_1->rects[0]->pict.data[0] = bitmap;",
"decode_rle(bitmap, VAR_21 * 2, VAR_21, (VAR_22 + 1) / 2,\nVAR_2, VAR_11, VAR_3, VAR_16);",
"decode_rle(bitmap + VAR_21, VAR_21 * 2, VAR_21, VAR_22 / 2,\nVAR_2, VAR_12, VAR_3, VAR_16);",
"VAR_1->rects[0]->pict.data[1] = av_mallocz(AVPALETTE_SIZE);",
"if (VAR_16) {",
"if (VAR_17 == 0)\ngoto fail;",
"VAR_1->rects[0]->nb_colors = 256;",
"yuv_a_to_rgba(VAR_17, alpha, (uint32_t*)VAR_1->rects[0]->pict.data[1], 256);",
"} else {",
"VAR_1->rects[0]->nb_colors = 4;",
"guess_palette(VAR_0,\n(uint32_t*)VAR_1->rects[0]->pict.data[1],\ncolormap, alpha, 0xffff00);",
"}",
"VAR_1->rects[0]->x = VAR_7;",
"VAR_1->rects[0]->y = VAR_8;",
"VAR_1->rects[0]->VAR_21 = VAR_21;",
"VAR_1->rects[0]->VAR_22 = VAR_22;",
"VAR_1->rects[0]->type = SUBTITLE_BITMAP;",
"VAR_1->rects[0]->pict.linesize[0] = VAR_21;",
"}",
"}",
"if (VAR_13 == VAR_4)\nbreak;",
"VAR_4 = VAR_13;",
"}",
"if (VAR_1->num_rects > 0)\nreturn VAR_20;",
"fail:\nif (VAR_1->rects != NULL) {",
"for (VAR_19 = 0; VAR_19 < VAR_1->num_rects; VAR_19++) {",
"av_freep(&VAR_1->rects[VAR_19]->pict.data[0]);",
"av_freep(&VAR_1->rects[VAR_19]->pict.data[1]);",
"av_freep(&VAR_1->rects[VAR_19]);",
"}",
"av_freep(&VAR_1->rects);",
"VAR_1->num_rects = 0;",
"}",
"return -1;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81,
85
],
[
87
],
[
89,
93
],
[
95
],
[
97,
101
],
[
103
],
[
105,
109,
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125,
129,
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147,
149,
151,
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163,
165
],
[
167
],
[
169
],
[
171
],
[
173,
175,
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189,
191,
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
207,
211,
213
],
[
215
],
[
217
],
[
219
],
[
221,
225,
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
239,
241
],
[
243,
245
],
[
247
],
[
249
],
[
251
],
[
253,
255
],
[
257
],
[
259
],
[
265
],
[
267,
269
],
[
271
],
[
273,
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309,
311
],
[
313,
315
],
[
317
],
[
319
],
[
321,
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333,
335,
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357,
359
],
[
361
],
[
363
],
[
365,
367
],
[
369,
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
]
]
|
13,602 | static int format_name(char *buf, int buf_len, int index)
{
const char *proto, *dir;
char *orig_buf_dup = NULL, *mod_buf_dup = NULL;
int ret = 0;
if (!av_stristr(buf, "%v"))
return ret;
orig_buf_dup = av_strdup(buf);
if (!orig_buf_dup) {
ret = AVERROR(ENOMEM);
goto fail;
}
if (replace_int_data_in_filename(buf, buf_len, orig_buf_dup, 'v', index) < 1) {
ret = AVERROR(EINVAL);
goto fail;
}
proto = avio_find_protocol_name(orig_buf_dup);
dir = av_dirname(orig_buf_dup);
/* if %v is present in the file's directory, create sub-directory */
if (av_stristr(dir, "%v") && proto && !strcmp(proto, "file")) {
mod_buf_dup = av_strdup(buf);
if (!mod_buf_dup) {
ret = AVERROR(ENOMEM);
goto fail;
}
dir = av_dirname(mod_buf_dup);
if (mkdir_p(dir) == -1 && errno != EEXIST) {
ret = AVERROR(errno);
goto fail;
}
}
fail:
av_freep(&orig_buf_dup);
av_freep(&mod_buf_dup);
return ret;
}
| false | FFmpeg | dc5d1515681b57a257443ba72bb81fb3e6e6621b | static int format_name(char *buf, int buf_len, int index)
{
const char *proto, *dir;
char *orig_buf_dup = NULL, *mod_buf_dup = NULL;
int ret = 0;
if (!av_stristr(buf, "%v"))
return ret;
orig_buf_dup = av_strdup(buf);
if (!orig_buf_dup) {
ret = AVERROR(ENOMEM);
goto fail;
}
if (replace_int_data_in_filename(buf, buf_len, orig_buf_dup, 'v', index) < 1) {
ret = AVERROR(EINVAL);
goto fail;
}
proto = avio_find_protocol_name(orig_buf_dup);
dir = av_dirname(orig_buf_dup);
if (av_stristr(dir, "%v") && proto && !strcmp(proto, "file")) {
mod_buf_dup = av_strdup(buf);
if (!mod_buf_dup) {
ret = AVERROR(ENOMEM);
goto fail;
}
dir = av_dirname(mod_buf_dup);
if (mkdir_p(dir) == -1 && errno != EEXIST) {
ret = AVERROR(errno);
goto fail;
}
}
fail:
av_freep(&orig_buf_dup);
av_freep(&mod_buf_dup);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(char *VAR_0, int VAR_1, int VAR_2)
{
const char *VAR_3, *VAR_4;
char *VAR_5 = NULL, *VAR_6 = NULL;
int VAR_7 = 0;
if (!av_stristr(VAR_0, "%v"))
return VAR_7;
VAR_5 = av_strdup(VAR_0);
if (!VAR_5) {
VAR_7 = AVERROR(ENOMEM);
goto fail;
}
if (replace_int_data_in_filename(VAR_0, VAR_1, VAR_5, 'v', VAR_2) < 1) {
VAR_7 = AVERROR(EINVAL);
goto fail;
}
VAR_3 = avio_find_protocol_name(VAR_5);
VAR_4 = av_dirname(VAR_5);
if (av_stristr(VAR_4, "%v") && VAR_3 && !strcmp(VAR_3, "file")) {
VAR_6 = av_strdup(VAR_0);
if (!VAR_6) {
VAR_7 = AVERROR(ENOMEM);
goto fail;
}
VAR_4 = av_dirname(VAR_6);
if (mkdir_p(VAR_4) == -1 && errno != EEXIST) {
VAR_7 = AVERROR(errno);
goto fail;
}
}
fail:
av_freep(&VAR_5);
av_freep(&VAR_6);
return VAR_7;
}
| [
"static int FUNC_0(char *VAR_0, int VAR_1, int VAR_2)\n{",
"const char *VAR_3, *VAR_4;",
"char *VAR_5 = NULL, *VAR_6 = NULL;",
"int VAR_7 = 0;",
"if (!av_stristr(VAR_0, \"%v\"))\nreturn VAR_7;",
"VAR_5 = av_strdup(VAR_0);",
"if (!VAR_5) {",
"VAR_7 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"if (replace_int_data_in_filename(VAR_0, VAR_1, VAR_5, 'v', VAR_2) < 1) {",
"VAR_7 = AVERROR(EINVAL);",
"goto fail;",
"}",
"VAR_3 = avio_find_protocol_name(VAR_5);",
"VAR_4 = av_dirname(VAR_5);",
"if (av_stristr(VAR_4, \"%v\") && VAR_3 && !strcmp(VAR_3, \"file\")) {",
"VAR_6 = av_strdup(VAR_0);",
"if (!VAR_6) {",
"VAR_7 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"VAR_4 = av_dirname(VAR_6);",
"if (mkdir_p(VAR_4) == -1 && errno != EEXIST) {",
"VAR_7 = AVERROR(errno);",
"goto fail;",
"}",
"}",
"fail:\nav_freep(&VAR_5);",
"av_freep(&VAR_6);",
"return VAR_7;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77,
79
],
[
81
],
[
83
],
[
85
]
]
|
13,603 | void cpu_reset(CPUSPARCState *env)
{
if (qemu_loglevel_mask(CPU_LOG_RESET)) {
qemu_log("CPU Reset (CPU %d)\n", env->cpu_index);
log_cpu_state(env, 0);
}
tlb_flush(env, 1);
env->cwp = 0;
#ifndef TARGET_SPARC64
env->wim = 1;
#endif
env->regwptr = env->regbase + (env->cwp * 16);
#if defined(CONFIG_USER_ONLY)
#ifdef TARGET_SPARC64
env->cleanwin = env->nwindows - 2;
env->cansave = env->nwindows - 2;
env->pstate = PS_RMO | PS_PEF | PS_IE;
env->asi = 0x82; // Primary no-fault
#endif
#else
#if !defined(TARGET_SPARC64)
env->psret = 0;
#endif
env->psrs = 1;
env->psrps = 1;
CC_OP = CC_OP_FLAGS;
#ifdef TARGET_SPARC64
env->pstate = PS_PRIV;
env->hpstate = HS_PRIV;
env->tsptr = &env->ts[env->tl & MAXTL_MASK];
env->lsu = 0;
#else
env->mmuregs[0] &= ~(MMU_E | MMU_NF);
env->mmuregs[0] |= env->def->mmu_bm;
#endif
env->pc = 0;
env->npc = env->pc + 4;
#endif
}
| true | qemu | 8194f35a0c71a3bf169459bf715bea53b7bbc904 | void cpu_reset(CPUSPARCState *env)
{
if (qemu_loglevel_mask(CPU_LOG_RESET)) {
qemu_log("CPU Reset (CPU %d)\n", env->cpu_index);
log_cpu_state(env, 0);
}
tlb_flush(env, 1);
env->cwp = 0;
#ifndef TARGET_SPARC64
env->wim = 1;
#endif
env->regwptr = env->regbase + (env->cwp * 16);
#if defined(CONFIG_USER_ONLY)
#ifdef TARGET_SPARC64
env->cleanwin = env->nwindows - 2;
env->cansave = env->nwindows - 2;
env->pstate = PS_RMO | PS_PEF | PS_IE;
env->asi = 0x82;
#endif
#else
#if !defined(TARGET_SPARC64)
env->psret = 0;
#endif
env->psrs = 1;
env->psrps = 1;
CC_OP = CC_OP_FLAGS;
#ifdef TARGET_SPARC64
env->pstate = PS_PRIV;
env->hpstate = HS_PRIV;
env->tsptr = &env->ts[env->tl & MAXTL_MASK];
env->lsu = 0;
#else
env->mmuregs[0] &= ~(MMU_E | MMU_NF);
env->mmuregs[0] |= env->def->mmu_bm;
#endif
env->pc = 0;
env->npc = env->pc + 4;
#endif
}
| {
"code": [
" env->pstate = PS_PRIV;",
" env->tsptr = &env->ts[env->tl & MAXTL_MASK];",
" env->tsptr = &env->ts[env->tl & MAXTL_MASK];",
" env->tsptr = &env->ts[env->tl & MAXTL_MASK];",
" env->tsptr = &env->ts[env->tl & MAXTL_MASK];",
" env->tsptr = &env->ts[env->tl & MAXTL_MASK];"
],
"line_no": [
57,
61,
61,
61,
61,
61
]
} | void FUNC_0(CPUSPARCState *VAR_0)
{
if (qemu_loglevel_mask(CPU_LOG_RESET)) {
qemu_log("CPU Reset (CPU %d)\n", VAR_0->cpu_index);
log_cpu_state(VAR_0, 0);
}
tlb_flush(VAR_0, 1);
VAR_0->cwp = 0;
#ifndef TARGET_SPARC64
VAR_0->wim = 1;
#endif
VAR_0->regwptr = VAR_0->regbase + (VAR_0->cwp * 16);
#if defined(CONFIG_USER_ONLY)
#ifdef TARGET_SPARC64
VAR_0->cleanwin = VAR_0->nwindows - 2;
VAR_0->cansave = VAR_0->nwindows - 2;
VAR_0->pstate = PS_RMO | PS_PEF | PS_IE;
VAR_0->asi = 0x82;
#endif
#else
#if !defined(TARGET_SPARC64)
VAR_0->psret = 0;
#endif
VAR_0->psrs = 1;
VAR_0->psrps = 1;
CC_OP = CC_OP_FLAGS;
#ifdef TARGET_SPARC64
VAR_0->pstate = PS_PRIV;
VAR_0->hpstate = HS_PRIV;
VAR_0->tsptr = &VAR_0->ts[VAR_0->tl & MAXTL_MASK];
VAR_0->lsu = 0;
#else
VAR_0->mmuregs[0] &= ~(MMU_E | MMU_NF);
VAR_0->mmuregs[0] |= VAR_0->def->mmu_bm;
#endif
VAR_0->pc = 0;
VAR_0->npc = VAR_0->pc + 4;
#endif
}
| [
"void FUNC_0(CPUSPARCState *VAR_0)\n{",
"if (qemu_loglevel_mask(CPU_LOG_RESET)) {",
"qemu_log(\"CPU Reset (CPU %d)\\n\", VAR_0->cpu_index);",
"log_cpu_state(VAR_0, 0);",
"}",
"tlb_flush(VAR_0, 1);",
"VAR_0->cwp = 0;",
"#ifndef TARGET_SPARC64\nVAR_0->wim = 1;",
"#endif\nVAR_0->regwptr = VAR_0->regbase + (VAR_0->cwp * 16);",
"#if defined(CONFIG_USER_ONLY)\n#ifdef TARGET_SPARC64\nVAR_0->cleanwin = VAR_0->nwindows - 2;",
"VAR_0->cansave = VAR_0->nwindows - 2;",
"VAR_0->pstate = PS_RMO | PS_PEF | PS_IE;",
"VAR_0->asi = 0x82;",
"#endif\n#else\n#if !defined(TARGET_SPARC64)\nVAR_0->psret = 0;",
"#endif\nVAR_0->psrs = 1;",
"VAR_0->psrps = 1;",
"CC_OP = CC_OP_FLAGS;",
"#ifdef TARGET_SPARC64\nVAR_0->pstate = PS_PRIV;",
"VAR_0->hpstate = HS_PRIV;",
"VAR_0->tsptr = &VAR_0->ts[VAR_0->tl & MAXTL_MASK];",
"VAR_0->lsu = 0;",
"#else\nVAR_0->mmuregs[0] &= ~(MMU_E | MMU_NF);",
"VAR_0->mmuregs[0] |= VAR_0->def->mmu_bm;",
"#endif\nVAR_0->pc = 0;",
"VAR_0->npc = VAR_0->pc + 4;",
"#endif\n}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19,
21
],
[
23,
25
],
[
27,
29,
31
],
[
33
],
[
35
],
[
37
],
[
39,
41,
43,
45
],
[
47,
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71,
73
],
[
75
],
[
77,
79
]
]
|
13,606 | net_rx_pkt_pull_data(struct NetRxPkt *pkt,
const struct iovec *iov, int iovcnt,
size_t ploff)
{
if (pkt->vlan_stripped) {
net_rx_pkt_iovec_realloc(pkt, iovcnt + 1);
pkt->vec[0].iov_base = pkt->ehdr_buf;
pkt->vec[0].iov_len = sizeof(pkt->ehdr_buf);
pkt->tot_len =
iov_size(iov, iovcnt) - ploff + sizeof(struct eth_header);
pkt->vec_len = iov_copy(pkt->vec + 1, pkt->vec_len_total - 1,
iov, iovcnt, ploff, pkt->tot_len);
} else {
net_rx_pkt_iovec_realloc(pkt, iovcnt);
pkt->tot_len = iov_size(iov, iovcnt) - ploff;
pkt->vec_len = iov_copy(pkt->vec, pkt->vec_len_total,
iov, iovcnt, ploff, pkt->tot_len);
}
eth_get_protocols(pkt->vec, pkt->vec_len, &pkt->isip4, &pkt->isip6,
&pkt->isudp, &pkt->istcp,
&pkt->l3hdr_off, &pkt->l4hdr_off, &pkt->l5hdr_off,
&pkt->ip6hdr_info, &pkt->ip4hdr_info, &pkt->l4hdr_info);
trace_net_rx_pkt_parsed(pkt->isip4, pkt->isip6, pkt->isudp, pkt->istcp,
pkt->l3hdr_off, pkt->l4hdr_off, pkt->l5hdr_off);
}
| true | qemu | df8bf7a7fe75eb5d5caffa55f5cd4292b757aea6 | net_rx_pkt_pull_data(struct NetRxPkt *pkt,
const struct iovec *iov, int iovcnt,
size_t ploff)
{
if (pkt->vlan_stripped) {
net_rx_pkt_iovec_realloc(pkt, iovcnt + 1);
pkt->vec[0].iov_base = pkt->ehdr_buf;
pkt->vec[0].iov_len = sizeof(pkt->ehdr_buf);
pkt->tot_len =
iov_size(iov, iovcnt) - ploff + sizeof(struct eth_header);
pkt->vec_len = iov_copy(pkt->vec + 1, pkt->vec_len_total - 1,
iov, iovcnt, ploff, pkt->tot_len);
} else {
net_rx_pkt_iovec_realloc(pkt, iovcnt);
pkt->tot_len = iov_size(iov, iovcnt) - ploff;
pkt->vec_len = iov_copy(pkt->vec, pkt->vec_len_total,
iov, iovcnt, ploff, pkt->tot_len);
}
eth_get_protocols(pkt->vec, pkt->vec_len, &pkt->isip4, &pkt->isip6,
&pkt->isudp, &pkt->istcp,
&pkt->l3hdr_off, &pkt->l4hdr_off, &pkt->l5hdr_off,
&pkt->ip6hdr_info, &pkt->ip4hdr_info, &pkt->l4hdr_info);
trace_net_rx_pkt_parsed(pkt->isip4, pkt->isip6, pkt->isudp, pkt->istcp,
pkt->l3hdr_off, pkt->l4hdr_off, pkt->l5hdr_off);
}
| {
"code": [
" if (pkt->vlan_stripped) {",
" pkt->vec[0].iov_len = sizeof(pkt->ehdr_buf);",
" pkt->tot_len =",
" iov_size(iov, iovcnt) - ploff + sizeof(struct eth_header);"
],
"line_no": [
9,
17,
21,
23
]
} | FUNC_0(struct NetRxPkt *VAR_0,
const struct iovec *VAR_1, int VAR_2,
size_t VAR_3)
{
if (VAR_0->vlan_stripped) {
net_rx_pkt_iovec_realloc(VAR_0, VAR_2 + 1);
VAR_0->vec[0].iov_base = VAR_0->ehdr_buf;
VAR_0->vec[0].iov_len = sizeof(VAR_0->ehdr_buf);
VAR_0->tot_len =
iov_size(VAR_1, VAR_2) - VAR_3 + sizeof(struct eth_header);
VAR_0->vec_len = iov_copy(VAR_0->vec + 1, VAR_0->vec_len_total - 1,
VAR_1, VAR_2, VAR_3, VAR_0->tot_len);
} else {
net_rx_pkt_iovec_realloc(VAR_0, VAR_2);
VAR_0->tot_len = iov_size(VAR_1, VAR_2) - VAR_3;
VAR_0->vec_len = iov_copy(VAR_0->vec, VAR_0->vec_len_total,
VAR_1, VAR_2, VAR_3, VAR_0->tot_len);
}
eth_get_protocols(VAR_0->vec, VAR_0->vec_len, &VAR_0->isip4, &VAR_0->isip6,
&VAR_0->isudp, &VAR_0->istcp,
&VAR_0->l3hdr_off, &VAR_0->l4hdr_off, &VAR_0->l5hdr_off,
&VAR_0->ip6hdr_info, &VAR_0->ip4hdr_info, &VAR_0->l4hdr_info);
trace_net_rx_pkt_parsed(VAR_0->isip4, VAR_0->isip6, VAR_0->isudp, VAR_0->istcp,
VAR_0->l3hdr_off, VAR_0->l4hdr_off, VAR_0->l5hdr_off);
}
| [
"FUNC_0(struct NetRxPkt *VAR_0,\nconst struct iovec *VAR_1, int VAR_2,\nsize_t VAR_3)\n{",
"if (VAR_0->vlan_stripped) {",
"net_rx_pkt_iovec_realloc(VAR_0, VAR_2 + 1);",
"VAR_0->vec[0].iov_base = VAR_0->ehdr_buf;",
"VAR_0->vec[0].iov_len = sizeof(VAR_0->ehdr_buf);",
"VAR_0->tot_len =\niov_size(VAR_1, VAR_2) - VAR_3 + sizeof(struct eth_header);",
"VAR_0->vec_len = iov_copy(VAR_0->vec + 1, VAR_0->vec_len_total - 1,\nVAR_1, VAR_2, VAR_3, VAR_0->tot_len);",
"} else {",
"net_rx_pkt_iovec_realloc(VAR_0, VAR_2);",
"VAR_0->tot_len = iov_size(VAR_1, VAR_2) - VAR_3;",
"VAR_0->vec_len = iov_copy(VAR_0->vec, VAR_0->vec_len_total,\nVAR_1, VAR_2, VAR_3, VAR_0->tot_len);",
"}",
"eth_get_protocols(VAR_0->vec, VAR_0->vec_len, &VAR_0->isip4, &VAR_0->isip6,\n&VAR_0->isudp, &VAR_0->istcp,\n&VAR_0->l3hdr_off, &VAR_0->l4hdr_off, &VAR_0->l5hdr_off,\n&VAR_0->ip6hdr_info, &VAR_0->ip4hdr_info, &VAR_0->l4hdr_info);",
"trace_net_rx_pkt_parsed(VAR_0->isip4, VAR_0->isip6, VAR_0->isudp, VAR_0->istcp,\nVAR_0->l3hdr_off, VAR_0->l4hdr_off, VAR_0->l5hdr_off);",
"}"
]
| [
0,
1,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21,
23
],
[
27,
29
],
[
31
],
[
33
],
[
37
],
[
39,
41
],
[
43
],
[
47,
49,
51,
53
],
[
57,
59
],
[
61
]
]
|
13,607 | MigrationState *tcp_start_outgoing_migration(Monitor *mon,
const char *host_port,
int64_t bandwidth_limit,
int detach,
int blk,
int inc)
{
struct sockaddr_in addr;
FdMigrationState *s;
int ret;
if (parse_host_port(&addr, host_port) < 0)
return NULL;
s = qemu_mallocz(sizeof(*s));
s->get_error = socket_errno;
s->write = socket_write;
s->close = tcp_close;
s->mig_state.cancel = migrate_fd_cancel;
s->mig_state.get_status = migrate_fd_get_status;
s->mig_state.release = migrate_fd_release;
s->mig_state.blk = blk;
s->mig_state.shared = inc;
s->state = MIG_STATE_ACTIVE;
s->mon = NULL;
s->bandwidth_limit = bandwidth_limit;
s->fd = socket(PF_INET, SOCK_STREAM, 0);
if (s->fd == -1) {
qemu_free(s);
return NULL;
}
socket_set_nonblock(s->fd);
if (!detach) {
migrate_fd_monitor_suspend(s, mon);
}
do {
ret = connect(s->fd, (struct sockaddr *)&addr, sizeof(addr));
if (ret == -1)
ret = -(s->get_error(s));
if (ret == -EINPROGRESS || ret == -EWOULDBLOCK)
qemu_set_fd_handler2(s->fd, NULL, NULL, tcp_wait_for_connect, s);
} while (ret == -EINTR);
if (ret < 0 && ret != -EINPROGRESS && ret != -EWOULDBLOCK) {
dprintf("connect failed\n");
close(s->fd);
qemu_free(s);
return NULL;
} else if (ret >= 0)
migrate_fd_connect(s);
return &s->mig_state;
}
| true | qemu | 40ff6d7e8dceca227e7f8a3e8e0d58b2c66d19b4 | MigrationState *tcp_start_outgoing_migration(Monitor *mon,
const char *host_port,
int64_t bandwidth_limit,
int detach,
int blk,
int inc)
{
struct sockaddr_in addr;
FdMigrationState *s;
int ret;
if (parse_host_port(&addr, host_port) < 0)
return NULL;
s = qemu_mallocz(sizeof(*s));
s->get_error = socket_errno;
s->write = socket_write;
s->close = tcp_close;
s->mig_state.cancel = migrate_fd_cancel;
s->mig_state.get_status = migrate_fd_get_status;
s->mig_state.release = migrate_fd_release;
s->mig_state.blk = blk;
s->mig_state.shared = inc;
s->state = MIG_STATE_ACTIVE;
s->mon = NULL;
s->bandwidth_limit = bandwidth_limit;
s->fd = socket(PF_INET, SOCK_STREAM, 0);
if (s->fd == -1) {
qemu_free(s);
return NULL;
}
socket_set_nonblock(s->fd);
if (!detach) {
migrate_fd_monitor_suspend(s, mon);
}
do {
ret = connect(s->fd, (struct sockaddr *)&addr, sizeof(addr));
if (ret == -1)
ret = -(s->get_error(s));
if (ret == -EINPROGRESS || ret == -EWOULDBLOCK)
qemu_set_fd_handler2(s->fd, NULL, NULL, tcp_wait_for_connect, s);
} while (ret == -EINTR);
if (ret < 0 && ret != -EINPROGRESS && ret != -EWOULDBLOCK) {
dprintf("connect failed\n");
close(s->fd);
qemu_free(s);
return NULL;
} else if (ret >= 0)
migrate_fd_connect(s);
return &s->mig_state;
}
| {
"code": [
" s->fd = socket(PF_INET, SOCK_STREAM, 0);"
],
"line_no": [
59
]
} | MigrationState *FUNC_0(Monitor *mon,
const char *host_port,
int64_t bandwidth_limit,
int detach,
int blk,
int inc)
{
struct sockaddr_in VAR_0;
FdMigrationState *s;
int VAR_1;
if (parse_host_port(&VAR_0, host_port) < 0)
return NULL;
s = qemu_mallocz(sizeof(*s));
s->get_error = socket_errno;
s->write = socket_write;
s->close = tcp_close;
s->mig_state.cancel = migrate_fd_cancel;
s->mig_state.get_status = migrate_fd_get_status;
s->mig_state.release = migrate_fd_release;
s->mig_state.blk = blk;
s->mig_state.shared = inc;
s->state = MIG_STATE_ACTIVE;
s->mon = NULL;
s->bandwidth_limit = bandwidth_limit;
s->fd = socket(PF_INET, SOCK_STREAM, 0);
if (s->fd == -1) {
qemu_free(s);
return NULL;
}
socket_set_nonblock(s->fd);
if (!detach) {
migrate_fd_monitor_suspend(s, mon);
}
do {
VAR_1 = connect(s->fd, (struct sockaddr *)&VAR_0, sizeof(VAR_0));
if (VAR_1 == -1)
VAR_1 = -(s->get_error(s));
if (VAR_1 == -EINPROGRESS || VAR_1 == -EWOULDBLOCK)
qemu_set_fd_handler2(s->fd, NULL, NULL, tcp_wait_for_connect, s);
} while (VAR_1 == -EINTR);
if (VAR_1 < 0 && VAR_1 != -EINPROGRESS && VAR_1 != -EWOULDBLOCK) {
dprintf("connect failed\n");
close(s->fd);
qemu_free(s);
return NULL;
} else if (VAR_1 >= 0)
migrate_fd_connect(s);
return &s->mig_state;
}
| [
"MigrationState *FUNC_0(Monitor *mon,\nconst char *host_port,\nint64_t bandwidth_limit,\nint detach,\nint blk,\nint inc)\n{",
"struct sockaddr_in VAR_0;",
"FdMigrationState *s;",
"int VAR_1;",
"if (parse_host_port(&VAR_0, host_port) < 0)\nreturn NULL;",
"s = qemu_mallocz(sizeof(*s));",
"s->get_error = socket_errno;",
"s->write = socket_write;",
"s->close = tcp_close;",
"s->mig_state.cancel = migrate_fd_cancel;",
"s->mig_state.get_status = migrate_fd_get_status;",
"s->mig_state.release = migrate_fd_release;",
"s->mig_state.blk = blk;",
"s->mig_state.shared = inc;",
"s->state = MIG_STATE_ACTIVE;",
"s->mon = NULL;",
"s->bandwidth_limit = bandwidth_limit;",
"s->fd = socket(PF_INET, SOCK_STREAM, 0);",
"if (s->fd == -1) {",
"qemu_free(s);",
"return NULL;",
"}",
"socket_set_nonblock(s->fd);",
"if (!detach) {",
"migrate_fd_monitor_suspend(s, mon);",
"}",
"do {",
"VAR_1 = connect(s->fd, (struct sockaddr *)&VAR_0, sizeof(VAR_0));",
"if (VAR_1 == -1)\nVAR_1 = -(s->get_error(s));",
"if (VAR_1 == -EINPROGRESS || VAR_1 == -EWOULDBLOCK)\nqemu_set_fd_handler2(s->fd, NULL, NULL, tcp_wait_for_connect, s);",
"} while (VAR_1 == -EINTR);",
"if (VAR_1 < 0 && VAR_1 != -EINPROGRESS && VAR_1 != -EWOULDBLOCK) {",
"dprintf(\"connect failed\\n\");",
"close(s->fd);",
"qemu_free(s);",
"return NULL;",
"} else if (VAR_1 >= 0)",
"migrate_fd_connect(s);",
"return &s->mig_state;",
"}"
]
| [
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,
13
],
[
15
],
[
17
],
[
19
],
[
23,
25
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87,
89
],
[
93,
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
]
]
|
13,608 | int main_loop(void *opaque)
{
struct pollfd ufds[2], *pf, *serial_ufd, *net_ufd, *gdb_ufd;
int ret, n, timeout;
uint8_t ch;
CPUState *env = global_env;
if (!term_inited) {
/* initialize terminal only there so that the user has a
chance to stop QEMU with Ctrl-C before the gdb connection
is launched */
term_inited = 1;
term_init();
}
for(;;) {
ret = cpu_x86_exec(env);
if (reset_requested)
break;
if (ret == EXCP_DEBUG)
return EXCP_DEBUG;
/* if hlt instruction, we wait until the next IRQ */
if (ret == EXCP_HLT)
timeout = 10;
else
timeout = 0;
/* poll any events */
serial_ufd = NULL;
pf = ufds;
if (!(serial_ports[0].lsr & UART_LSR_DR)) {
serial_ufd = pf;
pf->fd = 0;
pf->events = POLLIN;
pf++;
}
net_ufd = NULL;
if (net_fd > 0 && ne2000_can_receive(&ne2000_state)) {
net_ufd = pf;
pf->fd = net_fd;
pf->events = POLLIN;
pf++;
}
gdb_ufd = NULL;
if (gdbstub_fd > 0) {
gdb_ufd = pf;
pf->fd = gdbstub_fd;
pf->events = POLLIN;
pf++;
}
ret = poll(ufds, pf - ufds, timeout);
if (ret > 0) {
if (serial_ufd && (serial_ufd->revents & POLLIN)) {
n = read(0, &ch, 1);
if (n == 1) {
serial_received_byte(&serial_ports[0], ch);
}
}
if (net_ufd && (net_ufd->revents & POLLIN)) {
uint8_t buf[MAX_ETH_FRAME_SIZE];
n = read(net_fd, buf, MAX_ETH_FRAME_SIZE);
if (n > 0) {
if (n < 60) {
memset(buf + n, 0, 60 - n);
n = 60;
}
ne2000_receive(&ne2000_state, buf, n);
}
}
if (gdb_ufd && (gdb_ufd->revents & POLLIN)) {
uint8_t buf[1];
/* stop emulation if requested by gdb */
n = read(gdbstub_fd, buf, 1);
if (n == 1)
break;
}
}
/* timer IRQ */
if (timer_irq_pending) {
pic_set_irq(0, 1);
pic_set_irq(0, 0);
timer_irq_pending = 0;
}
/* VGA */
if (gui_refresh_pending) {
display_state.dpy_refresh(&display_state);
gui_refresh_pending = 0;
}
}
return EXCP_INTERRUPT;
}
| true | qemu | 27c3f2cb9bf2112b82edac898094e0a39e6efca1 | int main_loop(void *opaque)
{
struct pollfd ufds[2], *pf, *serial_ufd, *net_ufd, *gdb_ufd;
int ret, n, timeout;
uint8_t ch;
CPUState *env = global_env;
if (!term_inited) {
term_inited = 1;
term_init();
}
for(;;) {
ret = cpu_x86_exec(env);
if (reset_requested)
break;
if (ret == EXCP_DEBUG)
return EXCP_DEBUG;
if (ret == EXCP_HLT)
timeout = 10;
else
timeout = 0;
serial_ufd = NULL;
pf = ufds;
if (!(serial_ports[0].lsr & UART_LSR_DR)) {
serial_ufd = pf;
pf->fd = 0;
pf->events = POLLIN;
pf++;
}
net_ufd = NULL;
if (net_fd > 0 && ne2000_can_receive(&ne2000_state)) {
net_ufd = pf;
pf->fd = net_fd;
pf->events = POLLIN;
pf++;
}
gdb_ufd = NULL;
if (gdbstub_fd > 0) {
gdb_ufd = pf;
pf->fd = gdbstub_fd;
pf->events = POLLIN;
pf++;
}
ret = poll(ufds, pf - ufds, timeout);
if (ret > 0) {
if (serial_ufd && (serial_ufd->revents & POLLIN)) {
n = read(0, &ch, 1);
if (n == 1) {
serial_received_byte(&serial_ports[0], ch);
}
}
if (net_ufd && (net_ufd->revents & POLLIN)) {
uint8_t buf[MAX_ETH_FRAME_SIZE];
n = read(net_fd, buf, MAX_ETH_FRAME_SIZE);
if (n > 0) {
if (n < 60) {
memset(buf + n, 0, 60 - n);
n = 60;
}
ne2000_receive(&ne2000_state, buf, n);
}
}
if (gdb_ufd && (gdb_ufd->revents & POLLIN)) {
uint8_t buf[1];
n = read(gdbstub_fd, buf, 1);
if (n == 1)
break;
}
}
if (timer_irq_pending) {
pic_set_irq(0, 1);
pic_set_irq(0, 0);
timer_irq_pending = 0;
}
if (gui_refresh_pending) {
display_state.dpy_refresh(&display_state);
gui_refresh_pending = 0;
}
}
return EXCP_INTERRUPT;
}
| {
"code": [
" struct pollfd ufds[2], *pf, *serial_ufd, *net_ufd, *gdb_ufd;",
" int ret, n, timeout;",
" if (!(serial_ports[0].lsr & UART_LSR_DR)) {"
],
"line_no": [
5,
7,
59
]
} | int FUNC_0(void *VAR_0)
{
struct pollfd VAR_1[2], *pf, *serial_ufd, *net_ufd, *gdb_ufd;
int VAR_2, VAR_3, VAR_4;
uint8_t ch;
CPUState *env = global_env;
if (!term_inited) {
term_inited = 1;
term_init();
}
for(;;) {
VAR_2 = cpu_x86_exec(env);
if (reset_requested)
break;
if (VAR_2 == EXCP_DEBUG)
return EXCP_DEBUG;
if (VAR_2 == EXCP_HLT)
VAR_4 = 10;
else
VAR_4 = 0;
serial_ufd = NULL;
pf = VAR_1;
if (!(serial_ports[0].lsr & UART_LSR_DR)) {
serial_ufd = pf;
pf->fd = 0;
pf->events = POLLIN;
pf++;
}
net_ufd = NULL;
if (net_fd > 0 && ne2000_can_receive(&ne2000_state)) {
net_ufd = pf;
pf->fd = net_fd;
pf->events = POLLIN;
pf++;
}
gdb_ufd = NULL;
if (gdbstub_fd > 0) {
gdb_ufd = pf;
pf->fd = gdbstub_fd;
pf->events = POLLIN;
pf++;
}
VAR_2 = poll(VAR_1, pf - VAR_1, VAR_4);
if (VAR_2 > 0) {
if (serial_ufd && (serial_ufd->revents & POLLIN)) {
VAR_3 = read(0, &ch, 1);
if (VAR_3 == 1) {
serial_received_byte(&serial_ports[0], ch);
}
}
if (net_ufd && (net_ufd->revents & POLLIN)) {
uint8_t buf[MAX_ETH_FRAME_SIZE];
VAR_3 = read(net_fd, buf, MAX_ETH_FRAME_SIZE);
if (VAR_3 > 0) {
if (VAR_3 < 60) {
memset(buf + VAR_3, 0, 60 - VAR_3);
VAR_3 = 60;
}
ne2000_receive(&ne2000_state, buf, VAR_3);
}
}
if (gdb_ufd && (gdb_ufd->revents & POLLIN)) {
uint8_t buf[1];
VAR_3 = read(gdbstub_fd, buf, 1);
if (VAR_3 == 1)
break;
}
}
if (timer_irq_pending) {
pic_set_irq(0, 1);
pic_set_irq(0, 0);
timer_irq_pending = 0;
}
if (gui_refresh_pending) {
display_state.dpy_refresh(&display_state);
gui_refresh_pending = 0;
}
}
return EXCP_INTERRUPT;
}
| [
"int FUNC_0(void *VAR_0)\n{",
"struct pollfd VAR_1[2], *pf, *serial_ufd, *net_ufd, *gdb_ufd;",
"int VAR_2, VAR_3, VAR_4;",
"uint8_t ch;",
"CPUState *env = global_env;",
"if (!term_inited) {",
"term_inited = 1;",
"term_init();",
"}",
"for(;;) {",
"VAR_2 = cpu_x86_exec(env);",
"if (reset_requested)\nbreak;",
"if (VAR_2 == EXCP_DEBUG)\nreturn EXCP_DEBUG;",
"if (VAR_2 == EXCP_HLT)\nVAR_4 = 10;",
"else\nVAR_4 = 0;",
"serial_ufd = NULL;",
"pf = VAR_1;",
"if (!(serial_ports[0].lsr & UART_LSR_DR)) {",
"serial_ufd = pf;",
"pf->fd = 0;",
"pf->events = POLLIN;",
"pf++;",
"}",
"net_ufd = NULL;",
"if (net_fd > 0 && ne2000_can_receive(&ne2000_state)) {",
"net_ufd = pf;",
"pf->fd = net_fd;",
"pf->events = POLLIN;",
"pf++;",
"}",
"gdb_ufd = NULL;",
"if (gdbstub_fd > 0) {",
"gdb_ufd = pf;",
"pf->fd = gdbstub_fd;",
"pf->events = POLLIN;",
"pf++;",
"}",
"VAR_2 = poll(VAR_1, pf - VAR_1, VAR_4);",
"if (VAR_2 > 0) {",
"if (serial_ufd && (serial_ufd->revents & POLLIN)) {",
"VAR_3 = read(0, &ch, 1);",
"if (VAR_3 == 1) {",
"serial_received_byte(&serial_ports[0], ch);",
"}",
"}",
"if (net_ufd && (net_ufd->revents & POLLIN)) {",
"uint8_t buf[MAX_ETH_FRAME_SIZE];",
"VAR_3 = read(net_fd, buf, MAX_ETH_FRAME_SIZE);",
"if (VAR_3 > 0) {",
"if (VAR_3 < 60) {",
"memset(buf + VAR_3, 0, 60 - VAR_3);",
"VAR_3 = 60;",
"}",
"ne2000_receive(&ne2000_state, buf, VAR_3);",
"}",
"}",
"if (gdb_ufd && (gdb_ufd->revents & POLLIN)) {",
"uint8_t buf[1];",
"VAR_3 = read(gdbstub_fd, buf, 1);",
"if (VAR_3 == 1)\nbreak;",
"}",
"}",
"if (timer_irq_pending) {",
"pic_set_irq(0, 1);",
"pic_set_irq(0, 0);",
"timer_irq_pending = 0;",
"}",
"if (gui_refresh_pending) {",
"display_state.dpy_refresh(&display_state);",
"gui_refresh_pending = 0;",
"}",
"}",
"return EXCP_INTERRUPT;",
"}"
]
| [
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35,
37
],
[
39,
41
],
[
45,
47
],
[
49,
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149,
151
],
[
153
],
[
155
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
]
]
|
13,609 | static int ehci_state_executing(EHCIQueue *q)
{
EHCIPacket *p = QTAILQ_FIRST(&q->packets);
assert(p != NULL);
assert(p->qtdaddr == q->qtdaddr);
ehci_execute_complete(q);
// 4.10.3
if (!q->async) {
int transactCtr = get_field(q->qh.epcap, QH_EPCAP_MULT);
transactCtr--;
set_field(&q->qh.epcap, transactCtr, QH_EPCAP_MULT);
// 4.10.3, bottom of page 82, should exit this state when transaction
// counter decrements to 0
}
/* 4.10.5 */
if (p->usb_status == USB_RET_NAK) {
ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH);
} else {
ehci_set_state(q->ehci, q->async, EST_WRITEBACK);
}
ehci_flush_qh(q);
return 1;
}
| true | qemu | cae5d3f4b3fbe9b681c0c4046008af424bd1d6a5 | static int ehci_state_executing(EHCIQueue *q)
{
EHCIPacket *p = QTAILQ_FIRST(&q->packets);
assert(p != NULL);
assert(p->qtdaddr == q->qtdaddr);
ehci_execute_complete(q);
if (!q->async) {
int transactCtr = get_field(q->qh.epcap, QH_EPCAP_MULT);
transactCtr--;
set_field(&q->qh.epcap, transactCtr, QH_EPCAP_MULT);
, bottom of page 82, should exit this state when transaction
}
if (p->usb_status == USB_RET_NAK) {
ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH);
} else {
ehci_set_state(q->ehci, q->async, EST_WRITEBACK);
}
ehci_flush_qh(q);
return 1;
}
| {
"code": [
" if (!q->async) {",
" int transactCtr = get_field(q->qh.epcap, QH_EPCAP_MULT);",
" if (!q->async) {",
" int transactCtr = get_field(q->qh.epcap, QH_EPCAP_MULT);",
" transactCtr--;",
" set_field(&q->qh.epcap, transactCtr, QH_EPCAP_MULT);"
],
"line_no": [
21,
23,
21,
23,
25,
27
]
} | static int FUNC_0(EHCIQueue *VAR_0)
{
EHCIPacket *p = QTAILQ_FIRST(&VAR_0->packets);
assert(p != NULL);
assert(p->qtdaddr == VAR_0->qtdaddr);
ehci_execute_complete(VAR_0);
if (!VAR_0->async) {
int VAR_1 = get_field(VAR_0->qh.epcap, QH_EPCAP_MULT);
VAR_1--;
set_field(&VAR_0->qh.epcap, VAR_1, QH_EPCAP_MULT);
, bottom of page 82, should exit this state when transaction
}
if (p->usb_status == USB_RET_NAK) {
ehci_set_state(VAR_0->ehci, VAR_0->async, EST_HORIZONTALQH);
} else {
ehci_set_state(VAR_0->ehci, VAR_0->async, EST_WRITEBACK);
}
ehci_flush_qh(VAR_0);
return 1;
}
| [
"static int FUNC_0(EHCIQueue *VAR_0)\n{",
"EHCIPacket *p = QTAILQ_FIRST(&VAR_0->packets);",
"assert(p != NULL);",
"assert(p->qtdaddr == VAR_0->qtdaddr);",
"ehci_execute_complete(VAR_0);",
"if (!VAR_0->async) {",
"int VAR_1 = get_field(VAR_0->qh.epcap, QH_EPCAP_MULT);",
"VAR_1--;",
"set_field(&VAR_0->qh.epcap, VAR_1, QH_EPCAP_MULT);",
", bottom of page 82, should exit this state when transaction\n}",
"if (p->usb_status == USB_RET_NAK) {",
"ehci_set_state(VAR_0->ehci, VAR_0->async, EST_HORIZONTALQH);",
"} else {",
"ehci_set_state(VAR_0->ehci, VAR_0->async, EST_WRITEBACK);",
"}",
"ehci_flush_qh(VAR_0);",
"return 1;",
"}"
]
| [
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
15
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29,
33
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
]
]
|
13,610 | static int decode(MimicContext *ctx, int quality, int num_coeffs,
int is_iframe)
{
int y, x, plane, cur_row = 0;
for(plane = 0; plane < 3; plane++) {
const int is_chroma = !!plane;
const int qscale = av_clip(10000-quality,is_chroma?1000:2000,10000)<<2;
const int stride = ctx->flipped_ptrs[ctx->cur_index].linesize[plane];
const uint8_t *src = ctx->flipped_ptrs[ctx->prev_index].data[plane];
uint8_t *dst = ctx->flipped_ptrs[ctx->cur_index ].data[plane];
for(y = 0; y < ctx->num_vblocks[plane]; y++) {
for(x = 0; x < ctx->num_hblocks[plane]; x++) {
/* Check for a change condition in the current block.
* - iframes always change.
* - Luma plane changes on get_bits1 == 0
* - Chroma planes change on get_bits1 == 1 */
if(is_iframe || get_bits1(&ctx->gb) == is_chroma) {
/* Luma planes may use a backreference from the 15 last
* frames preceding the previous. (get_bits1 == 1)
* Chroma planes don't use backreferences. */
if(is_chroma || is_iframe || !get_bits1(&ctx->gb)) {
if(!vlc_decode_block(ctx, num_coeffs, qscale))
return 0;
ctx->dsp.idct_put(dst, stride, ctx->dct_block);
} else {
unsigned int backref = get_bits(&ctx->gb, 4);
int index = (ctx->cur_index+backref)&15;
uint8_t *p = ctx->flipped_ptrs[index].data[0];
ff_thread_await_progress(&ctx->buf_ptrs[index], cur_row, 0);
if(p) {
p += src -
ctx->flipped_ptrs[ctx->prev_index].data[plane];
ctx->dsp.put_pixels_tab[1][0](dst, p, stride, 8);
} else {
av_log(ctx->avctx, AV_LOG_ERROR,
"No such backreference! Buggy sample.\n");
}
}
} else {
ff_thread_await_progress(&ctx->buf_ptrs[ctx->prev_index], cur_row, 0);
ctx->dsp.put_pixels_tab[1][0](dst, src, stride, 8);
}
src += 8;
dst += 8;
}
src += (stride - ctx->num_hblocks[plane])<<3;
dst += (stride - ctx->num_hblocks[plane])<<3;
ff_thread_report_progress(&ctx->buf_ptrs[ctx->cur_index], cur_row++, 0);
}
}
return 1;
}
| true | FFmpeg | 80387f0e2568746dce4a68e2217297029a053dae | static int decode(MimicContext *ctx, int quality, int num_coeffs,
int is_iframe)
{
int y, x, plane, cur_row = 0;
for(plane = 0; plane < 3; plane++) {
const int is_chroma = !!plane;
const int qscale = av_clip(10000-quality,is_chroma?1000:2000,10000)<<2;
const int stride = ctx->flipped_ptrs[ctx->cur_index].linesize[plane];
const uint8_t *src = ctx->flipped_ptrs[ctx->prev_index].data[plane];
uint8_t *dst = ctx->flipped_ptrs[ctx->cur_index ].data[plane];
for(y = 0; y < ctx->num_vblocks[plane]; y++) {
for(x = 0; x < ctx->num_hblocks[plane]; x++) {
if(is_iframe || get_bits1(&ctx->gb) == is_chroma) {
if(is_chroma || is_iframe || !get_bits1(&ctx->gb)) {
if(!vlc_decode_block(ctx, num_coeffs, qscale))
return 0;
ctx->dsp.idct_put(dst, stride, ctx->dct_block);
} else {
unsigned int backref = get_bits(&ctx->gb, 4);
int index = (ctx->cur_index+backref)&15;
uint8_t *p = ctx->flipped_ptrs[index].data[0];
ff_thread_await_progress(&ctx->buf_ptrs[index], cur_row, 0);
if(p) {
p += src -
ctx->flipped_ptrs[ctx->prev_index].data[plane];
ctx->dsp.put_pixels_tab[1][0](dst, p, stride, 8);
} else {
av_log(ctx->avctx, AV_LOG_ERROR,
"No such backreference! Buggy sample.\n");
}
}
} else {
ff_thread_await_progress(&ctx->buf_ptrs[ctx->prev_index], cur_row, 0);
ctx->dsp.put_pixels_tab[1][0](dst, src, stride, 8);
}
src += 8;
dst += 8;
}
src += (stride - ctx->num_hblocks[plane])<<3;
dst += (stride - ctx->num_hblocks[plane])<<3;
ff_thread_report_progress(&ctx->buf_ptrs[ctx->cur_index], cur_row++, 0);
}
}
return 1;
}
| {
"code": [
" ff_thread_await_progress(&ctx->buf_ptrs[index], cur_row, 0);",
" if(p) {"
],
"line_no": [
69,
71
]
} | static int FUNC_0(MimicContext *VAR_0, int VAR_1, int VAR_2,
int VAR_3)
{
int VAR_4, VAR_5, VAR_6, VAR_7 = 0;
for(VAR_6 = 0; VAR_6 < 3; VAR_6++) {
const int VAR_8 = !!VAR_6;
const int VAR_9 = av_clip(10000-VAR_1,VAR_8?1000:2000,10000)<<2;
const int VAR_10 = VAR_0->flipped_ptrs[VAR_0->cur_index].linesize[VAR_6];
const uint8_t *VAR_11 = VAR_0->flipped_ptrs[VAR_0->prev_index].data[VAR_6];
uint8_t *dst = VAR_0->flipped_ptrs[VAR_0->cur_index ].data[VAR_6];
for(VAR_4 = 0; VAR_4 < VAR_0->num_vblocks[VAR_6]; VAR_4++) {
for(VAR_5 = 0; VAR_5 < VAR_0->num_hblocks[VAR_6]; VAR_5++) {
if(VAR_3 || get_bits1(&VAR_0->gb) == VAR_8) {
if(VAR_8 || VAR_3 || !get_bits1(&VAR_0->gb)) {
if(!vlc_decode_block(VAR_0, VAR_2, VAR_9))
return 0;
VAR_0->dsp.idct_put(dst, VAR_10, VAR_0->dct_block);
} else {
unsigned int backref = get_bits(&VAR_0->gb, 4);
int index = (VAR_0->cur_index+backref)&15;
uint8_t *p = VAR_0->flipped_ptrs[index].data[0];
ff_thread_await_progress(&VAR_0->buf_ptrs[index], VAR_7, 0);
if(p) {
p += VAR_11 -
VAR_0->flipped_ptrs[VAR_0->prev_index].data[VAR_6];
VAR_0->dsp.put_pixels_tab[1][0](dst, p, VAR_10, 8);
} else {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"No such backreference! Buggy sample.\n");
}
}
} else {
ff_thread_await_progress(&VAR_0->buf_ptrs[VAR_0->prev_index], VAR_7, 0);
VAR_0->dsp.put_pixels_tab[1][0](dst, VAR_11, VAR_10, 8);
}
VAR_11 += 8;
dst += 8;
}
VAR_11 += (VAR_10 - VAR_0->num_hblocks[VAR_6])<<3;
dst += (VAR_10 - VAR_0->num_hblocks[VAR_6])<<3;
ff_thread_report_progress(&VAR_0->buf_ptrs[VAR_0->cur_index], VAR_7++, 0);
}
}
return 1;
}
| [
"static int FUNC_0(MimicContext *VAR_0, int VAR_1, int VAR_2,\nint VAR_3)\n{",
"int VAR_4, VAR_5, VAR_6, VAR_7 = 0;",
"for(VAR_6 = 0; VAR_6 < 3; VAR_6++) {",
"const int VAR_8 = !!VAR_6;",
"const int VAR_9 = av_clip(10000-VAR_1,VAR_8?1000:2000,10000)<<2;",
"const int VAR_10 = VAR_0->flipped_ptrs[VAR_0->cur_index].linesize[VAR_6];",
"const uint8_t *VAR_11 = VAR_0->flipped_ptrs[VAR_0->prev_index].data[VAR_6];",
"uint8_t *dst = VAR_0->flipped_ptrs[VAR_0->cur_index ].data[VAR_6];",
"for(VAR_4 = 0; VAR_4 < VAR_0->num_vblocks[VAR_6]; VAR_4++) {",
"for(VAR_5 = 0; VAR_5 < VAR_0->num_hblocks[VAR_6]; VAR_5++) {",
"if(VAR_3 || get_bits1(&VAR_0->gb) == VAR_8) {",
"if(VAR_8 || VAR_3 || !get_bits1(&VAR_0->gb)) {",
"if(!vlc_decode_block(VAR_0, VAR_2, VAR_9))\nreturn 0;",
"VAR_0->dsp.idct_put(dst, VAR_10, VAR_0->dct_block);",
"} else {",
"unsigned int backref = get_bits(&VAR_0->gb, 4);",
"int index = (VAR_0->cur_index+backref)&15;",
"uint8_t *p = VAR_0->flipped_ptrs[index].data[0];",
"ff_thread_await_progress(&VAR_0->buf_ptrs[index], VAR_7, 0);",
"if(p) {",
"p += VAR_11 -\nVAR_0->flipped_ptrs[VAR_0->prev_index].data[VAR_6];",
"VAR_0->dsp.put_pixels_tab[1][0](dst, p, VAR_10, 8);",
"} else {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"No such backreference! Buggy sample.\\n\");",
"}",
"}",
"} else {",
"ff_thread_await_progress(&VAR_0->buf_ptrs[VAR_0->prev_index], VAR_7, 0);",
"VAR_0->dsp.put_pixels_tab[1][0](dst, VAR_11, VAR_10, 8);",
"}",
"VAR_11 += 8;",
"dst += 8;",
"}",
"VAR_11 += (VAR_10 - VAR_0->num_hblocks[VAR_6])<<3;",
"dst += (VAR_10 - VAR_0->num_hblocks[VAR_6])<<3;",
"ff_thread_report_progress(&VAR_0->buf_ptrs[VAR_0->cur_index], VAR_7++, 0);",
"}",
"}",
"return 1;",
"}"
]
| [
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
]
| [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
39
],
[
49
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
81,
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
]
]
|
13,611 | static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
{
UnsharpContext *unsharp = ctx->priv;
int lmsize_x = 5, cmsize_x = 0;
int lmsize_y = 5, cmsize_y = 0;
double lamount = 1.0f, camount = 0.0f;
if (args)
sscanf(args, "%d:%d:%lf:%d:%d:%lf", &lmsize_x, &lmsize_y, &lamount,
&cmsize_x, &cmsize_y, &camount);
if (lmsize_x < 2 || lmsize_y < 2 || cmsize_x < 2 || cmsize_y < 2) {
av_log(ctx, AV_LOG_ERROR,
"Invalid value <2 for lmsize_x:%d or lmsize_y:%d or cmsize_x:%d or cmsize_y:%d\n",
lmsize_x, lmsize_y, cmsize_x, cmsize_y);
return AVERROR(EINVAL);
}
set_filter_param(&unsharp->luma, lmsize_x, lmsize_y, lamount);
set_filter_param(&unsharp->chroma, cmsize_x, cmsize_y, camount);
return 0;
}
| true | FFmpeg | 6fae8c5443d4fa40fe65f67138f4dbb731f23d72 | static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
{
UnsharpContext *unsharp = ctx->priv;
int lmsize_x = 5, cmsize_x = 0;
int lmsize_y = 5, cmsize_y = 0;
double lamount = 1.0f, camount = 0.0f;
if (args)
sscanf(args, "%d:%d:%lf:%d:%d:%lf", &lmsize_x, &lmsize_y, &lamount,
&cmsize_x, &cmsize_y, &camount);
if (lmsize_x < 2 || lmsize_y < 2 || cmsize_x < 2 || cmsize_y < 2) {
av_log(ctx, AV_LOG_ERROR,
"Invalid value <2 for lmsize_x:%d or lmsize_y:%d or cmsize_x:%d or cmsize_y:%d\n",
lmsize_x, lmsize_y, cmsize_x, cmsize_y);
return AVERROR(EINVAL);
}
set_filter_param(&unsharp->luma, lmsize_x, lmsize_y, lamount);
set_filter_param(&unsharp->chroma, cmsize_x, cmsize_y, camount);
return 0;
}
| {
"code": [
" if (lmsize_x < 2 || lmsize_y < 2 || cmsize_x < 2 || cmsize_y < 2) {"
],
"line_no": [
23
]
} | static av_cold int FUNC_0(AVFilterContext *ctx, const char *args, void *opaque)
{
UnsharpContext *unsharp = ctx->priv;
int VAR_0 = 5, VAR_1 = 0;
int VAR_2 = 5, VAR_3 = 0;
double VAR_4 = 1.0f, VAR_5 = 0.0f;
if (args)
sscanf(args, "%d:%d:%lf:%d:%d:%lf", &VAR_0, &VAR_2, &VAR_4,
&VAR_1, &VAR_3, &VAR_5);
if (VAR_0 < 2 || VAR_2 < 2 || VAR_1 < 2 || VAR_3 < 2) {
av_log(ctx, AV_LOG_ERROR,
"Invalid value <2 for VAR_0:%d or VAR_2:%d or VAR_1:%d or VAR_3:%d\n",
VAR_0, VAR_2, VAR_1, VAR_3);
return AVERROR(EINVAL);
}
set_filter_param(&unsharp->luma, VAR_0, VAR_2, VAR_4);
set_filter_param(&unsharp->chroma, VAR_1, VAR_3, VAR_5);
return 0;
}
| [
"static av_cold int FUNC_0(AVFilterContext *ctx, const char *args, void *opaque)\n{",
"UnsharpContext *unsharp = ctx->priv;",
"int VAR_0 = 5, VAR_1 = 0;",
"int VAR_2 = 5, VAR_3 = 0;",
"double VAR_4 = 1.0f, VAR_5 = 0.0f;",
"if (args)\nsscanf(args, \"%d:%d:%lf:%d:%d:%lf\", &VAR_0, &VAR_2, &VAR_4,\n&VAR_1, &VAR_3, &VAR_5);",
"if (VAR_0 < 2 || VAR_2 < 2 || VAR_1 < 2 || VAR_3 < 2) {",
"av_log(ctx, AV_LOG_ERROR,\n\"Invalid value <2 for VAR_0:%d or VAR_2:%d or VAR_1:%d or VAR_3:%d\\n\",\nVAR_0, VAR_2, VAR_1, VAR_3);",
"return AVERROR(EINVAL);",
"}",
"set_filter_param(&unsharp->luma, VAR_0, VAR_2, VAR_4);",
"set_filter_param(&unsharp->chroma, VAR_1, VAR_3, VAR_5);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15,
17,
19
],
[
23
],
[
25,
27,
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
43
],
[
45
]
]
|
13,613 | static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv)
{
static const uint8_t checkv[16] = {0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b};
MXFContext *mxf = s->priv_data;
AVIOContext *pb = s->pb;
int64_t end = avio_tell(pb) + klv->length;
uint64_t size;
uint64_t orig_size;
uint64_t plaintext_size;
uint8_t ivec[16];
uint8_t tmpbuf[16];
int index;
if (!mxf->aesc && s->key && s->keylen == 16) {
mxf->aesc = av_malloc(av_aes_size);
if (!mxf->aesc)
return -1;
av_aes_init(mxf->aesc, s->key, 128, 1);
}
// crypto context
avio_skip(pb, klv_decode_ber_length(pb));
// plaintext offset
klv_decode_ber_length(pb);
plaintext_size = avio_rb64(pb);
// source klv key
klv_decode_ber_length(pb);
avio_read(pb, klv->key, 16);
if (!IS_KLV_KEY(klv, mxf_essence_element_key))
return -1;
index = mxf_get_stream_index(s, klv);
if (index < 0)
return -1;
// source size
klv_decode_ber_length(pb);
orig_size = avio_rb64(pb);
if (orig_size < plaintext_size)
return -1;
// enc. code
size = klv_decode_ber_length(pb);
if (size < 32 || size - 32 < orig_size)
return -1;
avio_read(pb, ivec, 16);
avio_read(pb, tmpbuf, 16);
if (mxf->aesc)
av_aes_crypt(mxf->aesc, tmpbuf, tmpbuf, 1, ivec, 1);
if (memcmp(tmpbuf, checkv, 16))
av_log(s, AV_LOG_ERROR, "probably incorrect decryption key\n");
size -= 32;
size = av_get_packet(pb, pkt, size);
if (size < 0)
return size;
else if (size < plaintext_size)
return AVERROR_INVALIDDATA;
size -= plaintext_size;
if (mxf->aesc)
av_aes_crypt(mxf->aesc, &pkt->data[plaintext_size],
&pkt->data[plaintext_size], size >> 4, ivec, 1);
av_shrink_packet(pkt, orig_size);
pkt->stream_index = index;
avio_skip(pb, end - avio_tell(pb));
return 0;
}
| false | FFmpeg | 735e601be1b7731d256a41e942b31a96255a6bec | static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv)
{
static const uint8_t checkv[16] = {0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b};
MXFContext *mxf = s->priv_data;
AVIOContext *pb = s->pb;
int64_t end = avio_tell(pb) + klv->length;
uint64_t size;
uint64_t orig_size;
uint64_t plaintext_size;
uint8_t ivec[16];
uint8_t tmpbuf[16];
int index;
if (!mxf->aesc && s->key && s->keylen == 16) {
mxf->aesc = av_malloc(av_aes_size);
if (!mxf->aesc)
return -1;
av_aes_init(mxf->aesc, s->key, 128, 1);
}
avio_skip(pb, klv_decode_ber_length(pb));
klv_decode_ber_length(pb);
plaintext_size = avio_rb64(pb);
klv_decode_ber_length(pb);
avio_read(pb, klv->key, 16);
if (!IS_KLV_KEY(klv, mxf_essence_element_key))
return -1;
index = mxf_get_stream_index(s, klv);
if (index < 0)
return -1;
klv_decode_ber_length(pb);
orig_size = avio_rb64(pb);
if (orig_size < plaintext_size)
return -1;
size = klv_decode_ber_length(pb);
if (size < 32 || size - 32 < orig_size)
return -1;
avio_read(pb, ivec, 16);
avio_read(pb, tmpbuf, 16);
if (mxf->aesc)
av_aes_crypt(mxf->aesc, tmpbuf, tmpbuf, 1, ivec, 1);
if (memcmp(tmpbuf, checkv, 16))
av_log(s, AV_LOG_ERROR, "probably incorrect decryption key\n");
size -= 32;
size = av_get_packet(pb, pkt, size);
if (size < 0)
return size;
else if (size < plaintext_size)
return AVERROR_INVALIDDATA;
size -= plaintext_size;
if (mxf->aesc)
av_aes_crypt(mxf->aesc, &pkt->data[plaintext_size],
&pkt->data[plaintext_size], size >> 4, ivec, 1);
av_shrink_packet(pkt, orig_size);
pkt->stream_index = index;
avio_skip(pb, end - avio_tell(pb));
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1, KLVPacket *VAR_2)
{
static const uint8_t VAR_3[16] = {0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b};
MXFContext *mxf = VAR_0->priv_data;
AVIOContext *pb = VAR_0->pb;
int64_t end = avio_tell(pb) + VAR_2->length;
uint64_t size;
uint64_t orig_size;
uint64_t plaintext_size;
uint8_t ivec[16];
uint8_t tmpbuf[16];
int VAR_4;
if (!mxf->aesc && VAR_0->key && VAR_0->keylen == 16) {
mxf->aesc = av_malloc(av_aes_size);
if (!mxf->aesc)
return -1;
av_aes_init(mxf->aesc, VAR_0->key, 128, 1);
}
avio_skip(pb, klv_decode_ber_length(pb));
klv_decode_ber_length(pb);
plaintext_size = avio_rb64(pb);
klv_decode_ber_length(pb);
avio_read(pb, VAR_2->key, 16);
if (!IS_KLV_KEY(VAR_2, mxf_essence_element_key))
return -1;
VAR_4 = mxf_get_stream_index(VAR_0, VAR_2);
if (VAR_4 < 0)
return -1;
klv_decode_ber_length(pb);
orig_size = avio_rb64(pb);
if (orig_size < plaintext_size)
return -1;
size = klv_decode_ber_length(pb);
if (size < 32 || size - 32 < orig_size)
return -1;
avio_read(pb, ivec, 16);
avio_read(pb, tmpbuf, 16);
if (mxf->aesc)
av_aes_crypt(mxf->aesc, tmpbuf, tmpbuf, 1, ivec, 1);
if (memcmp(tmpbuf, VAR_3, 16))
av_log(VAR_0, AV_LOG_ERROR, "probably incorrect decryption key\n");
size -= 32;
size = av_get_packet(pb, VAR_1, size);
if (size < 0)
return size;
else if (size < plaintext_size)
return AVERROR_INVALIDDATA;
size -= plaintext_size;
if (mxf->aesc)
av_aes_crypt(mxf->aesc, &VAR_1->data[plaintext_size],
&VAR_1->data[plaintext_size], size >> 4, ivec, 1);
av_shrink_packet(VAR_1, orig_size);
VAR_1->stream_index = VAR_4;
avio_skip(pb, end - avio_tell(pb));
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1, KLVPacket *VAR_2)\n{",
"static const uint8_t VAR_3[16] = {0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b};",
"MXFContext *mxf = VAR_0->priv_data;",
"AVIOContext *pb = VAR_0->pb;",
"int64_t end = avio_tell(pb) + VAR_2->length;",
"uint64_t size;",
"uint64_t orig_size;",
"uint64_t plaintext_size;",
"uint8_t ivec[16];",
"uint8_t tmpbuf[16];",
"int VAR_4;",
"if (!mxf->aesc && VAR_0->key && VAR_0->keylen == 16) {",
"mxf->aesc = av_malloc(av_aes_size);",
"if (!mxf->aesc)\nreturn -1;",
"av_aes_init(mxf->aesc, VAR_0->key, 128, 1);",
"}",
"avio_skip(pb, klv_decode_ber_length(pb));",
"klv_decode_ber_length(pb);",
"plaintext_size = avio_rb64(pb);",
"klv_decode_ber_length(pb);",
"avio_read(pb, VAR_2->key, 16);",
"if (!IS_KLV_KEY(VAR_2, mxf_essence_element_key))\nreturn -1;",
"VAR_4 = mxf_get_stream_index(VAR_0, VAR_2);",
"if (VAR_4 < 0)\nreturn -1;",
"klv_decode_ber_length(pb);",
"orig_size = avio_rb64(pb);",
"if (orig_size < plaintext_size)\nreturn -1;",
"size = klv_decode_ber_length(pb);",
"if (size < 32 || size - 32 < orig_size)\nreturn -1;",
"avio_read(pb, ivec, 16);",
"avio_read(pb, tmpbuf, 16);",
"if (mxf->aesc)\nav_aes_crypt(mxf->aesc, tmpbuf, tmpbuf, 1, ivec, 1);",
"if (memcmp(tmpbuf, VAR_3, 16))\nav_log(VAR_0, AV_LOG_ERROR, \"probably incorrect decryption key\\n\");",
"size -= 32;",
"size = av_get_packet(pb, VAR_1, size);",
"if (size < 0)\nreturn size;",
"else if (size < plaintext_size)\nreturn AVERROR_INVALIDDATA;",
"size -= plaintext_size;",
"if (mxf->aesc)\nav_aes_crypt(mxf->aesc, &VAR_1->data[plaintext_size],\n&VAR_1->data[plaintext_size], size >> 4, ivec, 1);",
"av_shrink_packet(VAR_1, orig_size);",
"VAR_1->stream_index = VAR_4;",
"avio_skip(pb, end - avio_tell(pb));",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
41
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61,
63
],
[
67
],
[
69
],
[
71,
73
],
[
77
],
[
79,
81
],
[
83
],
[
85
],
[
87,
89
],
[
91,
93
],
[
95
],
[
97
],
[
99,
101
],
[
103,
105
],
[
107
],
[
109,
111,
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
]
]
|
13,614 | static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pic, int *got_packet)
{
libx265Context *ctx = avctx->priv_data;
x265_picture x265pic;
x265_picture x265pic_out = { { 0 } };
x265_nal *nal;
uint8_t *dst;
int payload = 0;
int nnal;
int ret;
int i;
if (pic) {
for (i = 0; i < 3; i++) {
x265pic.planes[i] = pic->data[i];
x265pic.stride[i] = pic->linesize[i];
}
x265pic.pts = pic->pts;
}
ret = x265_encoder_encode(ctx->encoder, &nal, &nnal,
pic ? &x265pic : NULL, &x265pic_out);
if (ret < 0)
return AVERROR_UNKNOWN;
if (!nnal)
return 0;
for (i = 0; i < nnal; i++)
payload += nal[i].sizeBytes;
payload += ctx->header_size;
ret = ff_alloc_packet(pkt, payload);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
return ret;
}
dst = pkt->data;
if (ctx->header) {
memcpy(dst, ctx->header, ctx->header_size);
dst += ctx->header_size;
av_freep(&ctx->header);
ctx->header_size = 0;
}
for (i = 0; i < nnal; i++) {
memcpy(dst, nal[i].payload, nal[i].sizeBytes);
dst += nal[i].sizeBytes;
if (is_keyframe(nal[i].type))
pkt->flags |= AV_PKT_FLAG_KEY;
}
pkt->pts = x265pic_out.pts;
pkt->dts = x265pic_out.dts;
*got_packet = 1;
return 0;
} | true | FFmpeg | 41836c4e306e572ecf80d5a714aaec532c7ece60 | static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pic, int *got_packet)
{
libx265Context *ctx = avctx->priv_data;
x265_picture x265pic;
x265_picture x265pic_out = { { 0 } };
x265_nal *nal;
uint8_t *dst;
int payload = 0;
int nnal;
int ret;
int i;
if (pic) {
for (i = 0; i < 3; i++) {
x265pic.planes[i] = pic->data[i];
x265pic.stride[i] = pic->linesize[i];
}
x265pic.pts = pic->pts;
}
ret = x265_encoder_encode(ctx->encoder, &nal, &nnal,
pic ? &x265pic : NULL, &x265pic_out);
if (ret < 0)
return AVERROR_UNKNOWN;
if (!nnal)
return 0;
for (i = 0; i < nnal; i++)
payload += nal[i].sizeBytes;
payload += ctx->header_size;
ret = ff_alloc_packet(pkt, payload);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
return ret;
}
dst = pkt->data;
if (ctx->header) {
memcpy(dst, ctx->header, ctx->header_size);
dst += ctx->header_size;
av_freep(&ctx->header);
ctx->header_size = 0;
}
for (i = 0; i < nnal; i++) {
memcpy(dst, nal[i].payload, nal[i].sizeBytes);
dst += nal[i].sizeBytes;
if (is_keyframe(nal[i].type))
pkt->flags |= AV_PKT_FLAG_KEY;
}
pkt->pts = x265pic_out.pts;
pkt->dts = x265pic_out.dts;
*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)
{
libx265Context *ctx = VAR_0->priv_data;
x265_picture x265pic;
x265_picture x265pic_out = { { 0 } };
x265_nal *nal;
uint8_t *dst;
int VAR_4 = 0;
int VAR_5;
int VAR_6;
int VAR_7;
if (VAR_2) {
for (VAR_7 = 0; VAR_7 < 3; VAR_7++) {
x265pic.planes[VAR_7] = VAR_2->data[VAR_7];
x265pic.stride[VAR_7] = VAR_2->linesize[VAR_7];
}
x265pic.pts = VAR_2->pts;
}
VAR_6 = x265_encoder_encode(ctx->encoder, &nal, &VAR_5,
VAR_2 ? &x265pic : NULL, &x265pic_out);
if (VAR_6 < 0)
return AVERROR_UNKNOWN;
if (!VAR_5)
return 0;
for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++)
VAR_4 += nal[VAR_7].sizeBytes;
VAR_4 += ctx->header_size;
VAR_6 = ff_alloc_packet(VAR_1, VAR_4);
if (VAR_6 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Error getting output packet.\n");
return VAR_6;
}
dst = VAR_1->data;
if (ctx->header) {
memcpy(dst, ctx->header, ctx->header_size);
dst += ctx->header_size;
av_freep(&ctx->header);
ctx->header_size = 0;
}
for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++) {
memcpy(dst, nal[VAR_7].VAR_4, nal[VAR_7].sizeBytes);
dst += nal[VAR_7].sizeBytes;
if (is_keyframe(nal[VAR_7].type))
VAR_1->flags |= AV_PKT_FLAG_KEY;
}
VAR_1->pts = x265pic_out.pts;
VAR_1->dts = x265pic_out.dts;
*VAR_3 = 1;
return 0;
} | [
"static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,\nconst AVFrame *VAR_2, int *VAR_3)\n{",
"libx265Context *ctx = VAR_0->priv_data;",
"x265_picture x265pic;",
"x265_picture x265pic_out = { { 0 } };",
"x265_nal *nal;",
"uint8_t *dst;",
"int VAR_4 = 0;",
"int VAR_5;",
"int VAR_6;",
"int VAR_7;",
"if (VAR_2) {",
"for (VAR_7 = 0; VAR_7 < 3; VAR_7++) {",
"x265pic.planes[VAR_7] = VAR_2->data[VAR_7];",
"x265pic.stride[VAR_7] = VAR_2->linesize[VAR_7];",
"}",
"x265pic.pts = VAR_2->pts;",
"}",
"VAR_6 = x265_encoder_encode(ctx->encoder, &nal, &VAR_5,\nVAR_2 ? &x265pic : NULL, &x265pic_out);",
"if (VAR_6 < 0)\nreturn AVERROR_UNKNOWN;",
"if (!VAR_5)\nreturn 0;",
"for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++)",
"VAR_4 += nal[VAR_7].sizeBytes;",
"VAR_4 += ctx->header_size;",
"VAR_6 = ff_alloc_packet(VAR_1, VAR_4);",
"if (VAR_6 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error getting output packet.\\n\");",
"return VAR_6;",
"}",
"dst = VAR_1->data;",
"if (ctx->header) {",
"memcpy(dst, ctx->header, ctx->header_size);",
"dst += ctx->header_size;",
"av_freep(&ctx->header);",
"ctx->header_size = 0;",
"}",
"for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++) {",
"memcpy(dst, nal[VAR_7].VAR_4, nal[VAR_7].sizeBytes);",
"dst += nal[VAR_7].sizeBytes;",
"if (is_keyframe(nal[VAR_7].type))\nVAR_1->flags |= AV_PKT_FLAG_KEY;",
"}",
"VAR_1->pts = x265pic_out.pts;",
"VAR_1->dts = x265pic_out.dts;",
"*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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
2,
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20,
21
],
[
22,
23
],
[
24,
25
],
[
26
],
[
27
],
[
28
],
[
29
],
[
30
],
[
31
],
[
32
],
[
33
],
[
34
],
[
35
],
[
36
],
[
37
],
[
38
],
[
39
],
[
40
],
[
41
],
[
42
],
[
43
],
[
44,
45
],
[
46
],
[
47
],
[
48
],
[
49
],
[
50
],
[
51
]
]
|
13,615 | static inline TCGv gen_ld16u(TCGv addr, int index)
{
TCGv tmp = new_tmp();
tcg_gen_qemu_ld16u(tmp, addr, index);
return tmp;
}
| true | qemu | 7d1b0095bff7157e856d1d0e6c4295641ced2752 | static inline TCGv gen_ld16u(TCGv addr, int index)
{
TCGv tmp = new_tmp();
tcg_gen_qemu_ld16u(tmp, addr, index);
return tmp;
}
| {
"code": [
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();"
],
"line_no": [
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
]
} | static inline TCGv FUNC_0(TCGv addr, int index)
{
TCGv tmp = new_tmp();
tcg_gen_qemu_ld16u(tmp, addr, index);
return tmp;
}
| [
"static inline TCGv FUNC_0(TCGv addr, int index)\n{",
"TCGv tmp = new_tmp();",
"tcg_gen_qemu_ld16u(tmp, addr, index);",
"return tmp;",
"}"
]
| [
0,
1,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
]
|
13,616 | static int opus_decode_packet(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
OpusContext *c = avctx->priv_data;
AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
int coded_samples = 0;
int decoded_samples = 0;
int i, ret;
/* decode the header of the first sub-packet to find out the sample count */
if (buf) {
OpusPacket *pkt = &c->streams[0].packet;
ret = ff_opus_parse_packet(pkt, buf, buf_size, c->nb_streams > 1);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Error parsing the packet header.\n");
return ret;
coded_samples += pkt->frame_count * pkt->frame_duration;
c->streams[0].silk_samplerate = get_silk_samplerate(pkt->config);
frame->nb_samples = coded_samples + c->streams[0].delayed_samples;
/* no input or buffered data => nothing to do */
if (!frame->nb_samples) {
*got_frame_ptr = 0;
return 0;
/* setup the data buffers */
ret = ff_get_buffer(avctx, frame, 0);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
frame->nb_samples = 0;
for (i = 0; i < avctx->channels; i++) {
ChannelMap *map = &c->channel_maps[i];
if (!map->copy)
c->streams[map->stream_idx].out[map->channel_idx] = (float*)frame->extended_data[i];
for (i = 0; i < c->nb_streams; i++)
c->streams[i].out_size = frame->linesize[0];
/* decode each sub-packet */
for (i = 0; i < c->nb_streams; i++) {
OpusStreamContext *s = &c->streams[i];
if (i && buf) {
ret = ff_opus_parse_packet(&s->packet, buf, buf_size, i != c->nb_streams - 1);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Error parsing the packet header.\n");
return ret;
s->silk_samplerate = get_silk_samplerate(s->packet.config);
ret = opus_decode_subpacket(&c->streams[i], buf,
s->packet.data_size, coded_samples);
if (ret < 0)
return ret;
if (decoded_samples && ret != decoded_samples) {
av_log(avctx, AV_LOG_ERROR, "Different numbers of decoded samples "
"in a multi-channel stream\n");
decoded_samples = ret;
buf += s->packet.packet_size;
buf_size -= s->packet.packet_size;
for (i = 0; i < avctx->channels; i++) {
ChannelMap *map = &c->channel_maps[i];
/* handle copied channels */
if (map->copy) {
memcpy(frame->extended_data[i],
frame->extended_data[map->copy_idx],
frame->linesize[0]);
} else if (map->silence) {
memset(frame->extended_data[i], 0, frame->linesize[0]);
if (c->gain_i) {
c->fdsp.vector_fmul_scalar((float*)frame->extended_data[i],
(float*)frame->extended_data[i],
c->gain, FFALIGN(decoded_samples, 8));
frame->nb_samples = decoded_samples;
*got_frame_ptr = !!decoded_samples;
return avpkt->size; | true | FFmpeg | 1973079417e8701b52ba810a72cb6c7c6f7f9a56 | static int opus_decode_packet(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
OpusContext *c = avctx->priv_data;
AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
int coded_samples = 0;
int decoded_samples = 0;
int i, ret;
if (buf) {
OpusPacket *pkt = &c->streams[0].packet;
ret = ff_opus_parse_packet(pkt, buf, buf_size, c->nb_streams > 1);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Error parsing the packet header.\n");
return ret;
coded_samples += pkt->frame_count * pkt->frame_duration;
c->streams[0].silk_samplerate = get_silk_samplerate(pkt->config);
frame->nb_samples = coded_samples + c->streams[0].delayed_samples;
if (!frame->nb_samples) {
*got_frame_ptr = 0;
return 0;
ret = ff_get_buffer(avctx, frame, 0);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
frame->nb_samples = 0;
for (i = 0; i < avctx->channels; i++) {
ChannelMap *map = &c->channel_maps[i];
if (!map->copy)
c->streams[map->stream_idx].out[map->channel_idx] = (float*)frame->extended_data[i];
for (i = 0; i < c->nb_streams; i++)
c->streams[i].out_size = frame->linesize[0];
for (i = 0; i < c->nb_streams; i++) {
OpusStreamContext *s = &c->streams[i];
if (i && buf) {
ret = ff_opus_parse_packet(&s->packet, buf, buf_size, i != c->nb_streams - 1);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Error parsing the packet header.\n");
return ret;
s->silk_samplerate = get_silk_samplerate(s->packet.config);
ret = opus_decode_subpacket(&c->streams[i], buf,
s->packet.data_size, coded_samples);
if (ret < 0)
return ret;
if (decoded_samples && ret != decoded_samples) {
av_log(avctx, AV_LOG_ERROR, "Different numbers of decoded samples "
"in a multi-channel stream\n");
decoded_samples = ret;
buf += s->packet.packet_size;
buf_size -= s->packet.packet_size;
for (i = 0; i < avctx->channels; i++) {
ChannelMap *map = &c->channel_maps[i];
if (map->copy) {
memcpy(frame->extended_data[i],
frame->extended_data[map->copy_idx],
frame->linesize[0]);
} else if (map->silence) {
memset(frame->extended_data[i], 0, frame->linesize[0]);
if (c->gain_i) {
c->fdsp.vector_fmul_scalar((float*)frame->extended_data[i],
(float*)frame->extended_data[i],
c->gain, FFALIGN(decoded_samples, 8));
frame->nb_samples = decoded_samples;
*got_frame_ptr = !!decoded_samples;
return avpkt->size; | {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{
OpusContext *c = VAR_0->priv_data;
AVFrame *frame = VAR_1;
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
int VAR_6 = 0;
int VAR_7 = 0;
int VAR_8, VAR_9;
if (VAR_4) {
OpusPacket *pkt = &c->streams[0].packet;
VAR_9 = ff_opus_parse_packet(pkt, VAR_4, VAR_5, c->nb_streams > 1);
if (VAR_9 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Error parsing the packet header.\n");
return VAR_9;
VAR_6 += pkt->frame_count * pkt->frame_duration;
c->streams[0].silk_samplerate = get_silk_samplerate(pkt->config);
frame->nb_samples = VAR_6 + c->streams[0].delayed_samples;
if (!frame->nb_samples) {
*VAR_2 = 0;
return 0;
VAR_9 = ff_get_buffer(VAR_0, frame, 0);
if (VAR_9 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");
return VAR_9;
frame->nb_samples = 0;
for (VAR_8 = 0; VAR_8 < VAR_0->channels; VAR_8++) {
ChannelMap *map = &c->channel_maps[VAR_8];
if (!map->copy)
c->streams[map->stream_idx].out[map->channel_idx] = (float*)frame->extended_data[VAR_8];
for (VAR_8 = 0; VAR_8 < c->nb_streams; VAR_8++)
c->streams[VAR_8].out_size = frame->linesize[0];
for (VAR_8 = 0; VAR_8 < c->nb_streams; VAR_8++) {
OpusStreamContext *s = &c->streams[VAR_8];
if (VAR_8 && VAR_4) {
VAR_9 = ff_opus_parse_packet(&s->packet, VAR_4, VAR_5, VAR_8 != c->nb_streams - 1);
if (VAR_9 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Error parsing the packet header.\n");
return VAR_9;
s->silk_samplerate = get_silk_samplerate(s->packet.config);
VAR_9 = opus_decode_subpacket(&c->streams[VAR_8], VAR_4,
s->packet.data_size, VAR_6);
if (VAR_9 < 0)
return VAR_9;
if (VAR_7 && VAR_9 != VAR_7) {
av_log(VAR_0, AV_LOG_ERROR, "Different numbers of decoded samples "
"in a multi-channel stream\n");
VAR_7 = VAR_9;
VAR_4 += s->packet.packet_size;
VAR_5 -= s->packet.packet_size;
for (VAR_8 = 0; VAR_8 < VAR_0->channels; VAR_8++) {
ChannelMap *map = &c->channel_maps[VAR_8];
if (map->copy) {
memcpy(frame->extended_data[VAR_8],
frame->extended_data[map->copy_idx],
frame->linesize[0]);
} else if (map->silence) {
memset(frame->extended_data[VAR_8], 0, frame->linesize[0]);
if (c->gain_i) {
c->fdsp.vector_fmul_scalar((float*)frame->extended_data[VAR_8],
(float*)frame->extended_data[VAR_8],
c->gain, FFALIGN(VAR_7, 8));
frame->nb_samples = VAR_7;
*VAR_2 = !!VAR_7;
return VAR_3->size; | [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{",
"OpusContext *c = VAR_0->priv_data;",
"AVFrame *frame = VAR_1;",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"int VAR_6 = 0;",
"int VAR_7 = 0;",
"int VAR_8, VAR_9;",
"if (VAR_4) {",
"OpusPacket *pkt = &c->streams[0].packet;",
"VAR_9 = ff_opus_parse_packet(pkt, VAR_4, VAR_5, c->nb_streams > 1);",
"if (VAR_9 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error parsing the packet header.\\n\");",
"return VAR_9;",
"VAR_6 += pkt->frame_count * pkt->frame_duration;",
"c->streams[0].silk_samplerate = get_silk_samplerate(pkt->config);",
"frame->nb_samples = VAR_6 + c->streams[0].delayed_samples;",
"if (!frame->nb_samples) {",
"*VAR_2 = 0;",
"return 0;",
"VAR_9 = ff_get_buffer(VAR_0, frame, 0);",
"if (VAR_9 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"get_buffer() failed\\n\");",
"return VAR_9;",
"frame->nb_samples = 0;",
"for (VAR_8 = 0; VAR_8 < VAR_0->channels; VAR_8++) {",
"ChannelMap *map = &c->channel_maps[VAR_8];",
"if (!map->copy)\nc->streams[map->stream_idx].out[map->channel_idx] = (float*)frame->extended_data[VAR_8];",
"for (VAR_8 = 0; VAR_8 < c->nb_streams; VAR_8++)",
"c->streams[VAR_8].out_size = frame->linesize[0];",
"for (VAR_8 = 0; VAR_8 < c->nb_streams; VAR_8++) {",
"OpusStreamContext *s = &c->streams[VAR_8];",
"if (VAR_8 && VAR_4) {",
"VAR_9 = ff_opus_parse_packet(&s->packet, VAR_4, VAR_5, VAR_8 != c->nb_streams - 1);",
"if (VAR_9 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error parsing the packet header.\\n\");",
"return VAR_9;",
"s->silk_samplerate = get_silk_samplerate(s->packet.config);",
"VAR_9 = opus_decode_subpacket(&c->streams[VAR_8], VAR_4,\ns->packet.data_size, VAR_6);",
"if (VAR_9 < 0)\nreturn VAR_9;",
"if (VAR_7 && VAR_9 != VAR_7) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Different numbers of decoded samples \"\n\"in a multi-channel stream\\n\");",
"VAR_7 = VAR_9;",
"VAR_4 += s->packet.packet_size;",
"VAR_5 -= s->packet.packet_size;",
"for (VAR_8 = 0; VAR_8 < VAR_0->channels; VAR_8++) {",
"ChannelMap *map = &c->channel_maps[VAR_8];",
"if (map->copy) {",
"memcpy(frame->extended_data[VAR_8],\nframe->extended_data[map->copy_idx],\nframe->linesize[0]);",
"} else if (map->silence) {",
"memset(frame->extended_data[VAR_8], 0, frame->linesize[0]);",
"if (c->gain_i) {",
"c->fdsp.vector_fmul_scalar((float*)frame->extended_data[VAR_8],\n(float*)frame->extended_data[VAR_8],\nc->gain, FFALIGN(VAR_7, 8));",
"frame->nb_samples = VAR_7;",
"*VAR_2 = !!VAR_7;",
"return VAR_3->size;"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20
],
[
22
],
[
23
],
[
24
],
[
26
],
[
27
],
[
28
],
[
29
],
[
30
],
[
31
],
[
32
],
[
33,
34
],
[
35
],
[
36
],
[
38
],
[
39
],
[
40
],
[
41
],
[
42
],
[
43
],
[
44
],
[
45
],
[
46,
47
],
[
48,
49
],
[
50
],
[
51,
52
],
[
53
],
[
54
],
[
55
],
[
56
],
[
57
],
[
59
],
[
60,
61,
62
],
[
63
],
[
64
],
[
65
],
[
66,
67,
68
],
[
69
],
[
70
],
[
71
]
]
|
13,617 | int page_check_range(target_ulong start, target_ulong len, int flags)
{
PageDesc *p;
target_ulong end;
target_ulong addr;
/* This function should never be called with addresses outside the
guest address space. If this assert fires, it probably indicates
a missing call to h2g_valid. */
#if TARGET_ABI_BITS > L1_MAP_ADDR_SPACE_BITS
assert(start < ((abi_ulong)1 << L1_MAP_ADDR_SPACE_BITS));
#endif
if (len == 0) {
return 0;
}
if (start + len - 1 < start) {
/* We've wrapped around. */
return -1;
}
/* must do before we loose bits in the next step */
end = TARGET_PAGE_ALIGN(start + len);
start = start & TARGET_PAGE_MASK;
for (addr = start, len = end - start;
len != 0;
len -= TARGET_PAGE_SIZE, addr += TARGET_PAGE_SIZE) {
p = page_find(addr >> TARGET_PAGE_BITS);
if (!p) {
return -1;
}
if (!(p->flags & PAGE_VALID)) {
return -1;
}
if ((flags & PAGE_READ) && !(p->flags & PAGE_READ)) {
return -1;
}
if (flags & PAGE_WRITE) {
if (!(p->flags & PAGE_WRITE_ORG)) {
return -1;
}
/* unprotect the page if it was put read-only because it
contains translated code */
if (!(p->flags & PAGE_WRITE)) {
if (!page_unprotect(addr, 0, NULL)) {
return -1;
}
}
return 0;
}
}
return 0;
}
| true | qemu | cd7ccc83512a0cba5aa0c778e7507f267cfb1b16 | int page_check_range(target_ulong start, target_ulong len, int flags)
{
PageDesc *p;
target_ulong end;
target_ulong addr;
#if TARGET_ABI_BITS > L1_MAP_ADDR_SPACE_BITS
assert(start < ((abi_ulong)1 << L1_MAP_ADDR_SPACE_BITS));
#endif
if (len == 0) {
return 0;
}
if (start + len - 1 < start) {
return -1;
}
end = TARGET_PAGE_ALIGN(start + len);
start = start & TARGET_PAGE_MASK;
for (addr = start, len = end - start;
len != 0;
len -= TARGET_PAGE_SIZE, addr += TARGET_PAGE_SIZE) {
p = page_find(addr >> TARGET_PAGE_BITS);
if (!p) {
return -1;
}
if (!(p->flags & PAGE_VALID)) {
return -1;
}
if ((flags & PAGE_READ) && !(p->flags & PAGE_READ)) {
return -1;
}
if (flags & PAGE_WRITE) {
if (!(p->flags & PAGE_WRITE_ORG)) {
return -1;
}
if (!(p->flags & PAGE_WRITE)) {
if (!page_unprotect(addr, 0, NULL)) {
return -1;
}
}
return 0;
}
}
return 0;
}
| {
"code": [
" return 0;"
],
"line_no": [
101
]
} | int FUNC_0(target_ulong VAR_0, target_ulong VAR_1, int VAR_2)
{
PageDesc *p;
target_ulong end;
target_ulong addr;
#if TARGET_ABI_BITS > L1_MAP_ADDR_SPACE_BITS
assert(VAR_0 < ((abi_ulong)1 << L1_MAP_ADDR_SPACE_BITS));
#endif
if (VAR_1 == 0) {
return 0;
}
if (VAR_0 + VAR_1 - 1 < VAR_0) {
return -1;
}
end = TARGET_PAGE_ALIGN(VAR_0 + VAR_1);
VAR_0 = VAR_0 & TARGET_PAGE_MASK;
for (addr = VAR_0, VAR_1 = end - VAR_0;
VAR_1 != 0;
VAR_1 -= TARGET_PAGE_SIZE, addr += TARGET_PAGE_SIZE) {
p = page_find(addr >> TARGET_PAGE_BITS);
if (!p) {
return -1;
}
if (!(p->VAR_2 & PAGE_VALID)) {
return -1;
}
if ((VAR_2 & PAGE_READ) && !(p->VAR_2 & PAGE_READ)) {
return -1;
}
if (VAR_2 & PAGE_WRITE) {
if (!(p->VAR_2 & PAGE_WRITE_ORG)) {
return -1;
}
if (!(p->VAR_2 & PAGE_WRITE)) {
if (!page_unprotect(addr, 0, NULL)) {
return -1;
}
}
return 0;
}
}
return 0;
}
| [
"int FUNC_0(target_ulong VAR_0, target_ulong VAR_1, int VAR_2)\n{",
"PageDesc *p;",
"target_ulong end;",
"target_ulong addr;",
"#if TARGET_ABI_BITS > L1_MAP_ADDR_SPACE_BITS\nassert(VAR_0 < ((abi_ulong)1 << L1_MAP_ADDR_SPACE_BITS));",
"#endif\nif (VAR_1 == 0) {",
"return 0;",
"}",
"if (VAR_0 + VAR_1 - 1 < VAR_0) {",
"return -1;",
"}",
"end = TARGET_PAGE_ALIGN(VAR_0 + VAR_1);",
"VAR_0 = VAR_0 & TARGET_PAGE_MASK;",
"for (addr = VAR_0, VAR_1 = end - VAR_0;",
"VAR_1 != 0;",
"VAR_1 -= TARGET_PAGE_SIZE, addr += TARGET_PAGE_SIZE) {",
"p = page_find(addr >> TARGET_PAGE_BITS);",
"if (!p) {",
"return -1;",
"}",
"if (!(p->VAR_2 & PAGE_VALID)) {",
"return -1;",
"}",
"if ((VAR_2 & PAGE_READ) && !(p->VAR_2 & PAGE_READ)) {",
"return -1;",
"}",
"if (VAR_2 & PAGE_WRITE) {",
"if (!(p->VAR_2 & PAGE_WRITE_ORG)) {",
"return -1;",
"}",
"if (!(p->VAR_2 & PAGE_WRITE)) {",
"if (!page_unprotect(addr, 0, NULL)) {",
"return -1;",
"}",
"}",
"return 0;",
"}",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
19,
21
],
[
23,
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
]
]
|
13,618 | static int add_file(AVFormatContext *avf, char *filename, ConcatFile **rfile,
unsigned *nb_files_alloc)
{
ConcatContext *cat = avf->priv_data;
ConcatFile *file;
char *url;
size_t url_len;
if (cat->safe > 0 && !safe_filename(filename)) {
av_log(avf, AV_LOG_ERROR, "Unsafe file name '%s'\n", filename);
return AVERROR(EPERM);
}
url_len = strlen(avf->filename) + strlen(filename) + 16;
if (!(url = av_malloc(url_len)))
return AVERROR(ENOMEM);
ff_make_absolute_url(url, url_len, avf->filename, filename);
av_free(filename);
if (cat->nb_files >= *nb_files_alloc) {
size_t n = FFMAX(*nb_files_alloc * 2, 16);
ConcatFile *new_files;
if (n <= cat->nb_files || n > SIZE_MAX / sizeof(*cat->files) ||
!(new_files = av_realloc(cat->files, n * sizeof(*cat->files))))
return AVERROR(ENOMEM);
cat->files = new_files;
*nb_files_alloc = n;
}
file = &cat->files[cat->nb_files++];
memset(file, 0, sizeof(*file));
*rfile = file;
file->url = url;
file->start_time = AV_NOPTS_VALUE;
file->duration = AV_NOPTS_VALUE;
return 0;
}
| true | FFmpeg | de1568a452d8348917fee533fe17517131dccf95 | static int add_file(AVFormatContext *avf, char *filename, ConcatFile **rfile,
unsigned *nb_files_alloc)
{
ConcatContext *cat = avf->priv_data;
ConcatFile *file;
char *url;
size_t url_len;
if (cat->safe > 0 && !safe_filename(filename)) {
av_log(avf, AV_LOG_ERROR, "Unsafe file name '%s'\n", filename);
return AVERROR(EPERM);
}
url_len = strlen(avf->filename) + strlen(filename) + 16;
if (!(url = av_malloc(url_len)))
return AVERROR(ENOMEM);
ff_make_absolute_url(url, url_len, avf->filename, filename);
av_free(filename);
if (cat->nb_files >= *nb_files_alloc) {
size_t n = FFMAX(*nb_files_alloc * 2, 16);
ConcatFile *new_files;
if (n <= cat->nb_files || n > SIZE_MAX / sizeof(*cat->files) ||
!(new_files = av_realloc(cat->files, n * sizeof(*cat->files))))
return AVERROR(ENOMEM);
cat->files = new_files;
*nb_files_alloc = n;
}
file = &cat->files[cat->nb_files++];
memset(file, 0, sizeof(*file));
*rfile = file;
file->url = url;
file->start_time = AV_NOPTS_VALUE;
file->duration = AV_NOPTS_VALUE;
return 0;
}
| {
"code": [
" char *url;",
" return AVERROR(EPERM);",
" return AVERROR(ENOMEM);",
" av_free(filename);",
" return AVERROR(ENOMEM);"
],
"line_no": [
11,
21,
29,
33,
47
]
} | static int FUNC_0(AVFormatContext *VAR_0, char *VAR_1, ConcatFile **VAR_2,
unsigned *VAR_3)
{
ConcatContext *cat = VAR_0->priv_data;
ConcatFile *file;
char *VAR_4;
size_t url_len;
if (cat->safe > 0 && !safe_filename(VAR_1)) {
av_log(VAR_0, AV_LOG_ERROR, "Unsafe file name '%s'\n", VAR_1);
return AVERROR(EPERM);
}
url_len = strlen(VAR_0->VAR_1) + strlen(VAR_1) + 16;
if (!(VAR_4 = av_malloc(url_len)))
return AVERROR(ENOMEM);
ff_make_absolute_url(VAR_4, url_len, VAR_0->VAR_1, VAR_1);
av_free(VAR_1);
if (cat->nb_files >= *VAR_3) {
size_t n = FFMAX(*VAR_3 * 2, 16);
ConcatFile *new_files;
if (n <= cat->nb_files || n > SIZE_MAX / sizeof(*cat->files) ||
!(new_files = av_realloc(cat->files, n * sizeof(*cat->files))))
return AVERROR(ENOMEM);
cat->files = new_files;
*VAR_3 = n;
}
file = &cat->files[cat->nb_files++];
memset(file, 0, sizeof(*file));
*VAR_2 = file;
file->VAR_4 = VAR_4;
file->start_time = AV_NOPTS_VALUE;
file->duration = AV_NOPTS_VALUE;
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, char *VAR_1, ConcatFile **VAR_2,\nunsigned *VAR_3)\n{",
"ConcatContext *cat = VAR_0->priv_data;",
"ConcatFile *file;",
"char *VAR_4;",
"size_t url_len;",
"if (cat->safe > 0 && !safe_filename(VAR_1)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Unsafe file name '%s'\\n\", VAR_1);",
"return AVERROR(EPERM);",
"}",
"url_len = strlen(VAR_0->VAR_1) + strlen(VAR_1) + 16;",
"if (!(VAR_4 = av_malloc(url_len)))\nreturn AVERROR(ENOMEM);",
"ff_make_absolute_url(VAR_4, url_len, VAR_0->VAR_1, VAR_1);",
"av_free(VAR_1);",
"if (cat->nb_files >= *VAR_3) {",
"size_t n = FFMAX(*VAR_3 * 2, 16);",
"ConcatFile *new_files;",
"if (n <= cat->nb_files || n > SIZE_MAX / sizeof(*cat->files) ||\n!(new_files = av_realloc(cat->files, n * sizeof(*cat->files))))\nreturn AVERROR(ENOMEM);",
"cat->files = new_files;",
"*VAR_3 = n;",
"}",
"file = &cat->files[cat->nb_files++];",
"memset(file, 0, sizeof(*file));",
"*VAR_2 = file;",
"file->VAR_4 = VAR_4;",
"file->start_time = AV_NOPTS_VALUE;",
"file->duration = AV_NOPTS_VALUE;",
"return 0;",
"}"
]
| [
0,
0,
0,
1,
0,
0,
0,
1,
0,
0,
1,
0,
1,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43,
45,
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
]
]
|
13,619 | void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src)
{
// copy common properties
dst->pts = src->pts;
dst->pos = src->pos;
switch (src->type) {
case AVMEDIA_TYPE_VIDEO: {
if (dst->video->qp_table)
av_freep(&dst->video->qp_table);
copy_video_props(dst->video, src->video);
break;
}
case AVMEDIA_TYPE_AUDIO: *dst->audio = *src->audio; break;
default: break;
}
} | true | FFmpeg | 6fb2fd895e858ab93f46e656a322778ee181c307 | void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src)
{
dst->pts = src->pts;
dst->pos = src->pos;
switch (src->type) {
case AVMEDIA_TYPE_VIDEO: {
if (dst->video->qp_table)
av_freep(&dst->video->qp_table);
copy_video_props(dst->video, src->video);
break;
}
case AVMEDIA_TYPE_AUDIO: *dst->audio = *src->audio; break;
default: break;
}
} | {
"code": [],
"line_no": []
} | void FUNC_0(AVFilterBufferRef *VAR_0, AVFilterBufferRef *VAR_1)
{
VAR_0->pts = VAR_1->pts;
VAR_0->pos = VAR_1->pos;
switch (VAR_1->type) {
case AVMEDIA_TYPE_VIDEO: {
if (VAR_0->video->qp_table)
av_freep(&VAR_0->video->qp_table);
copy_video_props(VAR_0->video, VAR_1->video);
break;
}
case AVMEDIA_TYPE_AUDIO: *VAR_0->audio = *VAR_1->audio; break;
default: break;
}
} | [
"void FUNC_0(AVFilterBufferRef *VAR_0, AVFilterBufferRef *VAR_1)\n{",
"VAR_0->pts = VAR_1->pts;",
"VAR_0->pos = VAR_1->pos;",
"switch (VAR_1->type) {",
"case AVMEDIA_TYPE_VIDEO: {",
"if (VAR_0->video->qp_table)\nav_freep(&VAR_0->video->qp_table);",
"copy_video_props(VAR_0->video, VAR_1->video);",
"break;",
"}",
"case AVMEDIA_TYPE_AUDIO: *VAR_0->audio = *VAR_1->audio; break;",
"default: break;",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
2
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8,
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
]
]
|
13,620 | static void test_validate_fail_list(TestInputVisitorData *data,
const void *unused)
{
UserDefOneList *head = NULL;
Error *err = NULL;
Visitor *v;
v = validate_test_init(data, "[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44, 'extra': 'ggg' } ]");
visit_type_UserDefOneList(v, &head, NULL, &err);
g_assert(err);
error_free(err);
qapi_free_UserDefOneList(head);
}
| true | qemu | a12a5a1a0132527afe87c079e4aae4aad372bd94 | static void test_validate_fail_list(TestInputVisitorData *data,
const void *unused)
{
UserDefOneList *head = NULL;
Error *err = NULL;
Visitor *v;
v = validate_test_init(data, "[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44, 'extra': 'ggg' } ]");
visit_type_UserDefOneList(v, &head, NULL, &err);
g_assert(err);
error_free(err);
qapi_free_UserDefOneList(head);
}
| {
"code": [
" error_free(err);",
" g_assert(err);",
" error_free(err);",
" g_assert(err);",
" error_free(err);",
" g_assert(err);",
" error_free(err);",
" g_assert(err);",
" error_free(err);",
" g_assert(err);",
" error_free(err);",
" g_assert(err);",
" error_free(err);",
" g_assert(err);",
" error_free(err);",
" g_assert(err);",
" error_free(err);",
" g_assert(err);",
" error_free(err);",
" g_assert(err);",
" error_free(err);",
" g_assert(err);",
" error_free(err);",
" g_assert(err);",
" error_free(err);",
" g_assert(err);",
" error_free(err);",
" g_assert(err);",
" error_free(err);"
],
"line_no": [
23,
21,
23,
21,
23,
21,
23,
21,
23,
21,
23,
21,
23,
21,
23,
21,
23,
21,
23,
21,
23,
21,
23,
21,
23,
21,
23,
21,
23
]
} | static void FUNC_0(TestInputVisitorData *VAR_0,
const void *VAR_1)
{
UserDefOneList *head = NULL;
Error *err = NULL;
Visitor *v;
v = validate_test_init(VAR_0, "[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44, 'extra': 'ggg' } ]");
visit_type_UserDefOneList(v, &head, NULL, &err);
g_assert(err);
error_free(err);
qapi_free_UserDefOneList(head);
}
| [
"static void FUNC_0(TestInputVisitorData *VAR_0,\nconst void *VAR_1)\n{",
"UserDefOneList *head = NULL;",
"Error *err = NULL;",
"Visitor *v;",
"v = validate_test_init(VAR_0, \"[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44, 'extra': 'ggg' } ]\");",
"visit_type_UserDefOneList(v, &head, NULL, &err);",
"g_assert(err);",
"error_free(err);",
"qapi_free_UserDefOneList(head);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
1,
1,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
]
|
13,621 | int ff_find_unused_picture(MpegEncContext *s, int shared){
int i;
if(shared){
for(i=0; i<MAX_PICTURE_COUNT; i++){
if(s->picture[i].data[0]==NULL && s->picture[i].type==0) return i;
}
}else{
for(i=0; i<MAX_PICTURE_COUNT; i++){
if(s->picture[i].data[0]==NULL && s->picture[i].type!=0) return i; //FIXME
}
for(i=0; i<MAX_PICTURE_COUNT; i++){
if(s->picture[i].data[0]==NULL) return i;
}
}
assert(0);
return -1;
}
| true | FFmpeg | 3c11a27b440e27c3796592aa8fb7fed966386a21 | int ff_find_unused_picture(MpegEncContext *s, int shared){
int i;
if(shared){
for(i=0; i<MAX_PICTURE_COUNT; i++){
if(s->picture[i].data[0]==NULL && s->picture[i].type==0) return i;
}
}else{
for(i=0; i<MAX_PICTURE_COUNT; i++){
if(s->picture[i].data[0]==NULL && s->picture[i].type!=0) return i;
}
for(i=0; i<MAX_PICTURE_COUNT; i++){
if(s->picture[i].data[0]==NULL) return i;
}
}
assert(0);
return -1;
}
| {
"code": [
" assert(0);"
],
"line_no": [
33
]
} | int FUNC_0(MpegEncContext *VAR_0, int VAR_1){
int VAR_2;
if(VAR_1){
for(VAR_2=0; VAR_2<MAX_PICTURE_COUNT; VAR_2++){
if(VAR_0->picture[VAR_2].data[0]==NULL && VAR_0->picture[VAR_2].type==0) return VAR_2;
}
}else{
for(VAR_2=0; VAR_2<MAX_PICTURE_COUNT; VAR_2++){
if(VAR_0->picture[VAR_2].data[0]==NULL && VAR_0->picture[VAR_2].type!=0) return VAR_2;
}
for(VAR_2=0; VAR_2<MAX_PICTURE_COUNT; VAR_2++){
if(VAR_0->picture[VAR_2].data[0]==NULL) return VAR_2;
}
}
assert(0);
return -1;
}
| [
"int FUNC_0(MpegEncContext *VAR_0, int VAR_1){",
"int VAR_2;",
"if(VAR_1){",
"for(VAR_2=0; VAR_2<MAX_PICTURE_COUNT; VAR_2++){",
"if(VAR_0->picture[VAR_2].data[0]==NULL && VAR_0->picture[VAR_2].type==0) return VAR_2;",
"}",
"}else{",
"for(VAR_2=0; VAR_2<MAX_PICTURE_COUNT; VAR_2++){",
"if(VAR_0->picture[VAR_2].data[0]==NULL && VAR_0->picture[VAR_2].type!=0) return VAR_2;",
"}",
"for(VAR_2=0; VAR_2<MAX_PICTURE_COUNT; VAR_2++){",
"if(VAR_0->picture[VAR_2].data[0]==NULL) return VAR_2;",
"}",
"}",
"assert(0);",
"return -1;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
]
| [
[
1
],
[
3
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
]
]
|
13,622 | static void audio_init (PCIBus *pci_bus, qemu_irq *pic)
{
struct soundhw *c;
int audio_enabled = 0;
for (c = soundhw; !audio_enabled && c->name; ++c) {
audio_enabled = c->enabled;
}
if (audio_enabled) {
AudioState *s;
s = AUD_init ();
if (s) {
for (c = soundhw; c->name; ++c) {
if (c->enabled) {
if (c->isa) {
c->init.init_isa (s, pic);
}
else {
if (pci_bus) {
c->init.init_pci (pci_bus, s);
}
}
}
}
}
}
}
| true | qemu | 0d9acba8fddbf970c7353083e6a60b47017ce3e4 | static void audio_init (PCIBus *pci_bus, qemu_irq *pic)
{
struct soundhw *c;
int audio_enabled = 0;
for (c = soundhw; !audio_enabled && c->name; ++c) {
audio_enabled = c->enabled;
}
if (audio_enabled) {
AudioState *s;
s = AUD_init ();
if (s) {
for (c = soundhw; c->name; ++c) {
if (c->enabled) {
if (c->isa) {
c->init.init_isa (s, pic);
}
else {
if (pci_bus) {
c->init.init_pci (pci_bus, s);
}
}
}
}
}
}
}
| {
"code": [
" if (s) {",
" for (c = soundhw; c->name; ++c) {",
" if (c->enabled) {",
" if (c->isa) {",
" if (s) {",
" for (c = soundhw; c->name; ++c) {",
" if (s) {",
" for (c = soundhw; c->name; ++c) {",
" if (c->enabled) {",
" if (c->isa) {",
" c->init.init_isa (s, pic);",
" else {",
" if (pci_bus) {",
" c->init.init_pci (pci_bus, s);"
],
"line_no": [
27,
29,
31,
33,
27,
29,
27,
29,
31,
33,
35,
39,
41,
43
]
} | static void FUNC_0 (PCIBus *VAR_0, qemu_irq *VAR_1)
{
struct soundhw *VAR_2;
int VAR_3 = 0;
for (VAR_2 = soundhw; !VAR_3 && VAR_2->name; ++VAR_2) {
VAR_3 = VAR_2->enabled;
}
if (VAR_3) {
AudioState *s;
s = AUD_init ();
if (s) {
for (VAR_2 = soundhw; VAR_2->name; ++VAR_2) {
if (VAR_2->enabled) {
if (VAR_2->isa) {
VAR_2->init.init_isa (s, VAR_1);
}
else {
if (VAR_0) {
VAR_2->init.init_pci (VAR_0, s);
}
}
}
}
}
}
}
| [
"static void FUNC_0 (PCIBus *VAR_0, qemu_irq *VAR_1)\n{",
"struct soundhw *VAR_2;",
"int VAR_3 = 0;",
"for (VAR_2 = soundhw; !VAR_3 && VAR_2->name; ++VAR_2) {",
"VAR_3 = VAR_2->enabled;",
"}",
"if (VAR_3) {",
"AudioState *s;",
"s = AUD_init ();",
"if (s) {",
"for (VAR_2 = soundhw; VAR_2->name; ++VAR_2) {",
"if (VAR_2->enabled) {",
"if (VAR_2->isa) {",
"VAR_2->init.init_isa (s, VAR_1);",
"}",
"else {",
"if (VAR_0) {",
"VAR_2->init.init_pci (VAR_0, s);",
"}",
"}",
"}",
"}",
"}",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
]
]
|
13,624 | static void destroy_buffers(VADisplay display, VABufferID *buffers, unsigned int n_buffers)
{
unsigned int i;
for (i = 0; i < n_buffers; i++) {
if (buffers[i]) {
vaDestroyBuffer(display, buffers[i]);
buffers[i] = 0;
}
}
}
| false | FFmpeg | 8813d55fa5978660d9f4e7dbe1f50da9922be08d | static void destroy_buffers(VADisplay display, VABufferID *buffers, unsigned int n_buffers)
{
unsigned int i;
for (i = 0; i < n_buffers; i++) {
if (buffers[i]) {
vaDestroyBuffer(display, buffers[i]);
buffers[i] = 0;
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(VADisplay VAR_0, VABufferID *VAR_1, unsigned int VAR_2)
{
unsigned int VAR_3;
for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) {
if (VAR_1[VAR_3]) {
vaDestroyBuffer(VAR_0, VAR_1[VAR_3]);
VAR_1[VAR_3] = 0;
}
}
}
| [
"static void FUNC_0(VADisplay VAR_0, VABufferID *VAR_1, unsigned int VAR_2)\n{",
"unsigned int VAR_3;",
"for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) {",
"if (VAR_1[VAR_3]) {",
"vaDestroyBuffer(VAR_0, VAR_1[VAR_3]);",
"VAR_1[VAR_3] = 0;",
"}",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
]
|
13,625 | static void vmxnet3_activate_device(VMXNET3State *s)
{
int i;
static const uint32_t VMXNET3_DEF_TX_THRESHOLD = 1;
hwaddr qdescr_table_pa;
uint64_t pa;
uint32_t size;
/* Verify configuration consistency */
if (!vmxnet3_verify_driver_magic(s->drv_shmem)) {
VMW_ERPRN("Device configuration received from driver is invalid");
return;
}
/* Verify if device is active */
if (s->device_active) {
VMW_CFPRN("Vmxnet3 device is active");
return;
}
vmxnet3_adjust_by_guest_type(s);
vmxnet3_update_features(s);
vmxnet3_update_pm_state(s);
vmxnet3_setup_rx_filtering(s);
/* Cache fields from shared memory */
s->mtu = VMXNET3_READ_DRV_SHARED32(s->drv_shmem, devRead.misc.mtu);
VMW_CFPRN("MTU is %u", s->mtu);
s->max_rx_frags =
VMXNET3_READ_DRV_SHARED16(s->drv_shmem, devRead.misc.maxNumRxSG);
if (s->max_rx_frags == 0) {
s->max_rx_frags = 1;
}
VMW_CFPRN("Max RX fragments is %u", s->max_rx_frags);
s->event_int_idx =
VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.intrConf.eventIntrIdx);
assert(vmxnet3_verify_intx(s, s->event_int_idx));
VMW_CFPRN("Events interrupt line is %u", s->event_int_idx);
s->auto_int_masking =
VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.intrConf.autoMask);
VMW_CFPRN("Automatic interrupt masking is %d", (int)s->auto_int_masking);
s->txq_num =
VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.misc.numTxQueues);
s->rxq_num =
VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.misc.numRxQueues);
VMW_CFPRN("Number of TX/RX queues %u/%u", s->txq_num, s->rxq_num);
vmxnet3_validate_queues(s);
qdescr_table_pa =
VMXNET3_READ_DRV_SHARED64(s->drv_shmem, devRead.misc.queueDescPA);
VMW_CFPRN("TX queues descriptors table is at 0x%" PRIx64, qdescr_table_pa);
/*
* Worst-case scenario is a packet that holds all TX rings space so
* we calculate total size of all TX rings for max TX fragments number
*/
s->max_tx_frags = 0;
/* TX queues */
for (i = 0; i < s->txq_num; i++) {
hwaddr qdescr_pa =
qdescr_table_pa + i * sizeof(struct Vmxnet3_TxQueueDesc);
/* Read interrupt number for this TX queue */
s->txq_descr[i].intr_idx =
VMXNET3_READ_TX_QUEUE_DESCR8(qdescr_pa, conf.intrIdx);
assert(vmxnet3_verify_intx(s, s->txq_descr[i].intr_idx));
VMW_CFPRN("TX Queue %d interrupt: %d", i, s->txq_descr[i].intr_idx);
/* Read rings memory locations for TX queues */
pa = VMXNET3_READ_TX_QUEUE_DESCR64(qdescr_pa, conf.txRingBasePA);
size = VMXNET3_READ_TX_QUEUE_DESCR32(qdescr_pa, conf.txRingSize);
vmxnet3_ring_init(&s->txq_descr[i].tx_ring, pa, size,
sizeof(struct Vmxnet3_TxDesc), false);
VMXNET3_RING_DUMP(VMW_CFPRN, "TX", i, &s->txq_descr[i].tx_ring);
s->max_tx_frags += size;
/* TXC ring */
pa = VMXNET3_READ_TX_QUEUE_DESCR64(qdescr_pa, conf.compRingBasePA);
size = VMXNET3_READ_TX_QUEUE_DESCR32(qdescr_pa, conf.compRingSize);
vmxnet3_ring_init(&s->txq_descr[i].comp_ring, pa, size,
sizeof(struct Vmxnet3_TxCompDesc), true);
VMXNET3_RING_DUMP(VMW_CFPRN, "TXC", i, &s->txq_descr[i].comp_ring);
s->txq_descr[i].tx_stats_pa =
qdescr_pa + offsetof(struct Vmxnet3_TxQueueDesc, stats);
memset(&s->txq_descr[i].txq_stats, 0,
sizeof(s->txq_descr[i].txq_stats));
/* Fill device-managed parameters for queues */
VMXNET3_WRITE_TX_QUEUE_DESCR32(qdescr_pa,
ctrl.txThreshold,
VMXNET3_DEF_TX_THRESHOLD);
}
/* Preallocate TX packet wrapper */
VMW_CFPRN("Max TX fragments is %u", s->max_tx_frags);
net_tx_pkt_init(&s->tx_pkt, PCI_DEVICE(s),
s->max_tx_frags, s->peer_has_vhdr);
net_rx_pkt_init(&s->rx_pkt, s->peer_has_vhdr);
/* Read rings memory locations for RX queues */
for (i = 0; i < s->rxq_num; i++) {
int j;
hwaddr qd_pa =
qdescr_table_pa + s->txq_num * sizeof(struct Vmxnet3_TxQueueDesc) +
i * sizeof(struct Vmxnet3_RxQueueDesc);
/* Read interrupt number for this RX queue */
s->rxq_descr[i].intr_idx =
VMXNET3_READ_TX_QUEUE_DESCR8(qd_pa, conf.intrIdx);
assert(vmxnet3_verify_intx(s, s->rxq_descr[i].intr_idx));
VMW_CFPRN("RX Queue %d interrupt: %d", i, s->rxq_descr[i].intr_idx);
/* Read rings memory locations */
for (j = 0; j < VMXNET3_RX_RINGS_PER_QUEUE; j++) {
/* RX rings */
pa = VMXNET3_READ_RX_QUEUE_DESCR64(qd_pa, conf.rxRingBasePA[j]);
size = VMXNET3_READ_RX_QUEUE_DESCR32(qd_pa, conf.rxRingSize[j]);
vmxnet3_ring_init(&s->rxq_descr[i].rx_ring[j], pa, size,
sizeof(struct Vmxnet3_RxDesc), false);
VMW_CFPRN("RX queue %d:%d: Base: %" PRIx64 ", Size: %d",
i, j, pa, size);
}
/* RXC ring */
pa = VMXNET3_READ_RX_QUEUE_DESCR64(qd_pa, conf.compRingBasePA);
size = VMXNET3_READ_RX_QUEUE_DESCR32(qd_pa, conf.compRingSize);
vmxnet3_ring_init(&s->rxq_descr[i].comp_ring, pa, size,
sizeof(struct Vmxnet3_RxCompDesc), true);
VMW_CFPRN("RXC queue %d: Base: %" PRIx64 ", Size: %d", i, pa, size);
s->rxq_descr[i].rx_stats_pa =
qd_pa + offsetof(struct Vmxnet3_RxQueueDesc, stats);
memset(&s->rxq_descr[i].rxq_stats, 0,
sizeof(s->rxq_descr[i].rxq_stats));
}
vmxnet3_validate_interrupts(s);
/* Make sure everything is in place before device activation */
smp_wmb();
vmxnet3_reset_mac(s);
s->device_active = true;
}
| true | qemu | c508277335e3b6b20cf18e6ea3a35c1fa835c64a | static void vmxnet3_activate_device(VMXNET3State *s)
{
int i;
static const uint32_t VMXNET3_DEF_TX_THRESHOLD = 1;
hwaddr qdescr_table_pa;
uint64_t pa;
uint32_t size;
if (!vmxnet3_verify_driver_magic(s->drv_shmem)) {
VMW_ERPRN("Device configuration received from driver is invalid");
return;
}
if (s->device_active) {
VMW_CFPRN("Vmxnet3 device is active");
return;
}
vmxnet3_adjust_by_guest_type(s);
vmxnet3_update_features(s);
vmxnet3_update_pm_state(s);
vmxnet3_setup_rx_filtering(s);
s->mtu = VMXNET3_READ_DRV_SHARED32(s->drv_shmem, devRead.misc.mtu);
VMW_CFPRN("MTU is %u", s->mtu);
s->max_rx_frags =
VMXNET3_READ_DRV_SHARED16(s->drv_shmem, devRead.misc.maxNumRxSG);
if (s->max_rx_frags == 0) {
s->max_rx_frags = 1;
}
VMW_CFPRN("Max RX fragments is %u", s->max_rx_frags);
s->event_int_idx =
VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.intrConf.eventIntrIdx);
assert(vmxnet3_verify_intx(s, s->event_int_idx));
VMW_CFPRN("Events interrupt line is %u", s->event_int_idx);
s->auto_int_masking =
VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.intrConf.autoMask);
VMW_CFPRN("Automatic interrupt masking is %d", (int)s->auto_int_masking);
s->txq_num =
VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.misc.numTxQueues);
s->rxq_num =
VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.misc.numRxQueues);
VMW_CFPRN("Number of TX/RX queues %u/%u", s->txq_num, s->rxq_num);
vmxnet3_validate_queues(s);
qdescr_table_pa =
VMXNET3_READ_DRV_SHARED64(s->drv_shmem, devRead.misc.queueDescPA);
VMW_CFPRN("TX queues descriptors table is at 0x%" PRIx64, qdescr_table_pa);
s->max_tx_frags = 0;
for (i = 0; i < s->txq_num; i++) {
hwaddr qdescr_pa =
qdescr_table_pa + i * sizeof(struct Vmxnet3_TxQueueDesc);
s->txq_descr[i].intr_idx =
VMXNET3_READ_TX_QUEUE_DESCR8(qdescr_pa, conf.intrIdx);
assert(vmxnet3_verify_intx(s, s->txq_descr[i].intr_idx));
VMW_CFPRN("TX Queue %d interrupt: %d", i, s->txq_descr[i].intr_idx);
pa = VMXNET3_READ_TX_QUEUE_DESCR64(qdescr_pa, conf.txRingBasePA);
size = VMXNET3_READ_TX_QUEUE_DESCR32(qdescr_pa, conf.txRingSize);
vmxnet3_ring_init(&s->txq_descr[i].tx_ring, pa, size,
sizeof(struct Vmxnet3_TxDesc), false);
VMXNET3_RING_DUMP(VMW_CFPRN, "TX", i, &s->txq_descr[i].tx_ring);
s->max_tx_frags += size;
pa = VMXNET3_READ_TX_QUEUE_DESCR64(qdescr_pa, conf.compRingBasePA);
size = VMXNET3_READ_TX_QUEUE_DESCR32(qdescr_pa, conf.compRingSize);
vmxnet3_ring_init(&s->txq_descr[i].comp_ring, pa, size,
sizeof(struct Vmxnet3_TxCompDesc), true);
VMXNET3_RING_DUMP(VMW_CFPRN, "TXC", i, &s->txq_descr[i].comp_ring);
s->txq_descr[i].tx_stats_pa =
qdescr_pa + offsetof(struct Vmxnet3_TxQueueDesc, stats);
memset(&s->txq_descr[i].txq_stats, 0,
sizeof(s->txq_descr[i].txq_stats));
VMXNET3_WRITE_TX_QUEUE_DESCR32(qdescr_pa,
ctrl.txThreshold,
VMXNET3_DEF_TX_THRESHOLD);
}
VMW_CFPRN("Max TX fragments is %u", s->max_tx_frags);
net_tx_pkt_init(&s->tx_pkt, PCI_DEVICE(s),
s->max_tx_frags, s->peer_has_vhdr);
net_rx_pkt_init(&s->rx_pkt, s->peer_has_vhdr);
for (i = 0; i < s->rxq_num; i++) {
int j;
hwaddr qd_pa =
qdescr_table_pa + s->txq_num * sizeof(struct Vmxnet3_TxQueueDesc) +
i * sizeof(struct Vmxnet3_RxQueueDesc);
s->rxq_descr[i].intr_idx =
VMXNET3_READ_TX_QUEUE_DESCR8(qd_pa, conf.intrIdx);
assert(vmxnet3_verify_intx(s, s->rxq_descr[i].intr_idx));
VMW_CFPRN("RX Queue %d interrupt: %d", i, s->rxq_descr[i].intr_idx);
for (j = 0; j < VMXNET3_RX_RINGS_PER_QUEUE; j++) {
pa = VMXNET3_READ_RX_QUEUE_DESCR64(qd_pa, conf.rxRingBasePA[j]);
size = VMXNET3_READ_RX_QUEUE_DESCR32(qd_pa, conf.rxRingSize[j]);
vmxnet3_ring_init(&s->rxq_descr[i].rx_ring[j], pa, size,
sizeof(struct Vmxnet3_RxDesc), false);
VMW_CFPRN("RX queue %d:%d: Base: %" PRIx64 ", Size: %d",
i, j, pa, size);
}
pa = VMXNET3_READ_RX_QUEUE_DESCR64(qd_pa, conf.compRingBasePA);
size = VMXNET3_READ_RX_QUEUE_DESCR32(qd_pa, conf.compRingSize);
vmxnet3_ring_init(&s->rxq_descr[i].comp_ring, pa, size,
sizeof(struct Vmxnet3_RxCompDesc), true);
VMW_CFPRN("RXC queue %d: Base: %" PRIx64 ", Size: %d", i, pa, size);
s->rxq_descr[i].rx_stats_pa =
qd_pa + offsetof(struct Vmxnet3_RxQueueDesc, stats);
memset(&s->rxq_descr[i].rxq_stats, 0,
sizeof(s->rxq_descr[i].rxq_stats));
}
vmxnet3_validate_interrupts(s);
smp_wmb();
vmxnet3_reset_mac(s);
s->device_active = true;
}
| {
"code": [
" if (!vmxnet3_verify_driver_magic(s->drv_shmem)) {",
" s->mtu = VMXNET3_READ_DRV_SHARED32(s->drv_shmem, devRead.misc.mtu);",
" VMXNET3_READ_DRV_SHARED16(s->drv_shmem, devRead.misc.maxNumRxSG);",
" VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.intrConf.eventIntrIdx);",
" VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.intrConf.autoMask);",
" VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.misc.numTxQueues);",
" VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.misc.numRxQueues);",
" VMXNET3_READ_DRV_SHARED64(s->drv_shmem, devRead.misc.queueDescPA);",
" VMXNET3_READ_TX_QUEUE_DESCR8(qdescr_pa, conf.intrIdx);",
" pa = VMXNET3_READ_TX_QUEUE_DESCR64(qdescr_pa, conf.txRingBasePA);",
" size = VMXNET3_READ_TX_QUEUE_DESCR32(qdescr_pa, conf.txRingSize);",
" vmxnet3_ring_init(&s->txq_descr[i].tx_ring, pa, size,",
" pa = VMXNET3_READ_TX_QUEUE_DESCR64(qdescr_pa, conf.compRingBasePA);",
" size = VMXNET3_READ_TX_QUEUE_DESCR32(qdescr_pa, conf.compRingSize);",
" vmxnet3_ring_init(&s->txq_descr[i].comp_ring, pa, size,",
" VMXNET3_WRITE_TX_QUEUE_DESCR32(qdescr_pa,",
" VMXNET3_READ_TX_QUEUE_DESCR8(qd_pa, conf.intrIdx);",
" pa = VMXNET3_READ_RX_QUEUE_DESCR64(qd_pa, conf.rxRingBasePA[j]);",
" size = VMXNET3_READ_RX_QUEUE_DESCR32(qd_pa, conf.rxRingSize[j]);",
" vmxnet3_ring_init(&s->rxq_descr[i].rx_ring[j], pa, size,",
" pa = VMXNET3_READ_RX_QUEUE_DESCR64(qd_pa, conf.compRingBasePA);",
" size = VMXNET3_READ_RX_QUEUE_DESCR32(qd_pa, conf.compRingSize);",
" vmxnet3_ring_init(&s->rxq_descr[i].comp_ring, pa, size,"
],
"line_no": [
19,
51,
59,
77,
87,
95,
99,
111,
143,
155,
157,
161,
175,
177,
179,
201,
241,
257,
259,
261,
275,
277,
279
]
} | static void FUNC_0(VMXNET3State *VAR_0)
{
int VAR_1;
static const uint32_t VAR_2 = 1;
hwaddr qdescr_table_pa;
uint64_t pa;
uint32_t size;
if (!vmxnet3_verify_driver_magic(VAR_0->drv_shmem)) {
VMW_ERPRN("Device configuration received from driver is invalid");
return;
}
if (VAR_0->device_active) {
VMW_CFPRN("Vmxnet3 device is active");
return;
}
vmxnet3_adjust_by_guest_type(VAR_0);
vmxnet3_update_features(VAR_0);
vmxnet3_update_pm_state(VAR_0);
vmxnet3_setup_rx_filtering(VAR_0);
VAR_0->mtu = VMXNET3_READ_DRV_SHARED32(VAR_0->drv_shmem, devRead.misc.mtu);
VMW_CFPRN("MTU is %u", VAR_0->mtu);
VAR_0->max_rx_frags =
VMXNET3_READ_DRV_SHARED16(VAR_0->drv_shmem, devRead.misc.maxNumRxSG);
if (VAR_0->max_rx_frags == 0) {
VAR_0->max_rx_frags = 1;
}
VMW_CFPRN("Max RX fragments is %u", VAR_0->max_rx_frags);
VAR_0->event_int_idx =
VMXNET3_READ_DRV_SHARED8(VAR_0->drv_shmem, devRead.intrConf.eventIntrIdx);
assert(vmxnet3_verify_intx(VAR_0, VAR_0->event_int_idx));
VMW_CFPRN("Events interrupt line is %u", VAR_0->event_int_idx);
VAR_0->auto_int_masking =
VMXNET3_READ_DRV_SHARED8(VAR_0->drv_shmem, devRead.intrConf.autoMask);
VMW_CFPRN("Automatic interrupt masking is %d", (int)VAR_0->auto_int_masking);
VAR_0->txq_num =
VMXNET3_READ_DRV_SHARED8(VAR_0->drv_shmem, devRead.misc.numTxQueues);
VAR_0->rxq_num =
VMXNET3_READ_DRV_SHARED8(VAR_0->drv_shmem, devRead.misc.numRxQueues);
VMW_CFPRN("Number of TX/RX queues %u/%u", VAR_0->txq_num, VAR_0->rxq_num);
vmxnet3_validate_queues(VAR_0);
qdescr_table_pa =
VMXNET3_READ_DRV_SHARED64(VAR_0->drv_shmem, devRead.misc.queueDescPA);
VMW_CFPRN("TX queues descriptors table is at 0x%" PRIx64, qdescr_table_pa);
VAR_0->max_tx_frags = 0;
for (VAR_1 = 0; VAR_1 < VAR_0->txq_num; VAR_1++) {
hwaddr qdescr_pa =
qdescr_table_pa + VAR_1 * sizeof(struct Vmxnet3_TxQueueDesc);
VAR_0->txq_descr[VAR_1].intr_idx =
VMXNET3_READ_TX_QUEUE_DESCR8(qdescr_pa, conf.intrIdx);
assert(vmxnet3_verify_intx(VAR_0, VAR_0->txq_descr[VAR_1].intr_idx));
VMW_CFPRN("TX Queue %d interrupt: %d", VAR_1, VAR_0->txq_descr[VAR_1].intr_idx);
pa = VMXNET3_READ_TX_QUEUE_DESCR64(qdescr_pa, conf.txRingBasePA);
size = VMXNET3_READ_TX_QUEUE_DESCR32(qdescr_pa, conf.txRingSize);
vmxnet3_ring_init(&VAR_0->txq_descr[VAR_1].tx_ring, pa, size,
sizeof(struct Vmxnet3_TxDesc), false);
VMXNET3_RING_DUMP(VMW_CFPRN, "TX", VAR_1, &VAR_0->txq_descr[VAR_1].tx_ring);
VAR_0->max_tx_frags += size;
pa = VMXNET3_READ_TX_QUEUE_DESCR64(qdescr_pa, conf.compRingBasePA);
size = VMXNET3_READ_TX_QUEUE_DESCR32(qdescr_pa, conf.compRingSize);
vmxnet3_ring_init(&VAR_0->txq_descr[VAR_1].comp_ring, pa, size,
sizeof(struct Vmxnet3_TxCompDesc), true);
VMXNET3_RING_DUMP(VMW_CFPRN, "TXC", VAR_1, &VAR_0->txq_descr[VAR_1].comp_ring);
VAR_0->txq_descr[VAR_1].tx_stats_pa =
qdescr_pa + offsetof(struct Vmxnet3_TxQueueDesc, stats);
memset(&VAR_0->txq_descr[VAR_1].txq_stats, 0,
sizeof(VAR_0->txq_descr[VAR_1].txq_stats));
VMXNET3_WRITE_TX_QUEUE_DESCR32(qdescr_pa,
ctrl.txThreshold,
VAR_2);
}
VMW_CFPRN("Max TX fragments is %u", VAR_0->max_tx_frags);
net_tx_pkt_init(&VAR_0->tx_pkt, PCI_DEVICE(VAR_0),
VAR_0->max_tx_frags, VAR_0->peer_has_vhdr);
net_rx_pkt_init(&VAR_0->rx_pkt, VAR_0->peer_has_vhdr);
for (VAR_1 = 0; VAR_1 < VAR_0->rxq_num; VAR_1++) {
int j;
hwaddr qd_pa =
qdescr_table_pa + VAR_0->txq_num * sizeof(struct Vmxnet3_TxQueueDesc) +
VAR_1 * sizeof(struct Vmxnet3_RxQueueDesc);
VAR_0->rxq_descr[VAR_1].intr_idx =
VMXNET3_READ_TX_QUEUE_DESCR8(qd_pa, conf.intrIdx);
assert(vmxnet3_verify_intx(VAR_0, VAR_0->rxq_descr[VAR_1].intr_idx));
VMW_CFPRN("RX Queue %d interrupt: %d", VAR_1, VAR_0->rxq_descr[VAR_1].intr_idx);
for (j = 0; j < VMXNET3_RX_RINGS_PER_QUEUE; j++) {
pa = VMXNET3_READ_RX_QUEUE_DESCR64(qd_pa, conf.rxRingBasePA[j]);
size = VMXNET3_READ_RX_QUEUE_DESCR32(qd_pa, conf.rxRingSize[j]);
vmxnet3_ring_init(&VAR_0->rxq_descr[VAR_1].rx_ring[j], pa, size,
sizeof(struct Vmxnet3_RxDesc), false);
VMW_CFPRN("RX queue %d:%d: Base: %" PRIx64 ", Size: %d",
VAR_1, j, pa, size);
}
pa = VMXNET3_READ_RX_QUEUE_DESCR64(qd_pa, conf.compRingBasePA);
size = VMXNET3_READ_RX_QUEUE_DESCR32(qd_pa, conf.compRingSize);
vmxnet3_ring_init(&VAR_0->rxq_descr[VAR_1].comp_ring, pa, size,
sizeof(struct Vmxnet3_RxCompDesc), true);
VMW_CFPRN("RXC queue %d: Base: %" PRIx64 ", Size: %d", VAR_1, pa, size);
VAR_0->rxq_descr[VAR_1].rx_stats_pa =
qd_pa + offsetof(struct Vmxnet3_RxQueueDesc, stats);
memset(&VAR_0->rxq_descr[VAR_1].rxq_stats, 0,
sizeof(VAR_0->rxq_descr[VAR_1].rxq_stats));
}
vmxnet3_validate_interrupts(VAR_0);
smp_wmb();
vmxnet3_reset_mac(VAR_0);
VAR_0->device_active = true;
}
| [
"static void FUNC_0(VMXNET3State *VAR_0)\n{",
"int VAR_1;",
"static const uint32_t VAR_2 = 1;",
"hwaddr qdescr_table_pa;",
"uint64_t pa;",
"uint32_t size;",
"if (!vmxnet3_verify_driver_magic(VAR_0->drv_shmem)) {",
"VMW_ERPRN(\"Device configuration received from driver is invalid\");",
"return;",
"}",
"if (VAR_0->device_active) {",
"VMW_CFPRN(\"Vmxnet3 device is active\");",
"return;",
"}",
"vmxnet3_adjust_by_guest_type(VAR_0);",
"vmxnet3_update_features(VAR_0);",
"vmxnet3_update_pm_state(VAR_0);",
"vmxnet3_setup_rx_filtering(VAR_0);",
"VAR_0->mtu = VMXNET3_READ_DRV_SHARED32(VAR_0->drv_shmem, devRead.misc.mtu);",
"VMW_CFPRN(\"MTU is %u\", VAR_0->mtu);",
"VAR_0->max_rx_frags =\nVMXNET3_READ_DRV_SHARED16(VAR_0->drv_shmem, devRead.misc.maxNumRxSG);",
"if (VAR_0->max_rx_frags == 0) {",
"VAR_0->max_rx_frags = 1;",
"}",
"VMW_CFPRN(\"Max RX fragments is %u\", VAR_0->max_rx_frags);",
"VAR_0->event_int_idx =\nVMXNET3_READ_DRV_SHARED8(VAR_0->drv_shmem, devRead.intrConf.eventIntrIdx);",
"assert(vmxnet3_verify_intx(VAR_0, VAR_0->event_int_idx));",
"VMW_CFPRN(\"Events interrupt line is %u\", VAR_0->event_int_idx);",
"VAR_0->auto_int_masking =\nVMXNET3_READ_DRV_SHARED8(VAR_0->drv_shmem, devRead.intrConf.autoMask);",
"VMW_CFPRN(\"Automatic interrupt masking is %d\", (int)VAR_0->auto_int_masking);",
"VAR_0->txq_num =\nVMXNET3_READ_DRV_SHARED8(VAR_0->drv_shmem, devRead.misc.numTxQueues);",
"VAR_0->rxq_num =\nVMXNET3_READ_DRV_SHARED8(VAR_0->drv_shmem, devRead.misc.numRxQueues);",
"VMW_CFPRN(\"Number of TX/RX queues %u/%u\", VAR_0->txq_num, VAR_0->rxq_num);",
"vmxnet3_validate_queues(VAR_0);",
"qdescr_table_pa =\nVMXNET3_READ_DRV_SHARED64(VAR_0->drv_shmem, devRead.misc.queueDescPA);",
"VMW_CFPRN(\"TX queues descriptors table is at 0x%\" PRIx64, qdescr_table_pa);",
"VAR_0->max_tx_frags = 0;",
"for (VAR_1 = 0; VAR_1 < VAR_0->txq_num; VAR_1++) {",
"hwaddr qdescr_pa =\nqdescr_table_pa + VAR_1 * sizeof(struct Vmxnet3_TxQueueDesc);",
"VAR_0->txq_descr[VAR_1].intr_idx =\nVMXNET3_READ_TX_QUEUE_DESCR8(qdescr_pa, conf.intrIdx);",
"assert(vmxnet3_verify_intx(VAR_0, VAR_0->txq_descr[VAR_1].intr_idx));",
"VMW_CFPRN(\"TX Queue %d interrupt: %d\", VAR_1, VAR_0->txq_descr[VAR_1].intr_idx);",
"pa = VMXNET3_READ_TX_QUEUE_DESCR64(qdescr_pa, conf.txRingBasePA);",
"size = VMXNET3_READ_TX_QUEUE_DESCR32(qdescr_pa, conf.txRingSize);",
"vmxnet3_ring_init(&VAR_0->txq_descr[VAR_1].tx_ring, pa, size,\nsizeof(struct Vmxnet3_TxDesc), false);",
"VMXNET3_RING_DUMP(VMW_CFPRN, \"TX\", VAR_1, &VAR_0->txq_descr[VAR_1].tx_ring);",
"VAR_0->max_tx_frags += size;",
"pa = VMXNET3_READ_TX_QUEUE_DESCR64(qdescr_pa, conf.compRingBasePA);",
"size = VMXNET3_READ_TX_QUEUE_DESCR32(qdescr_pa, conf.compRingSize);",
"vmxnet3_ring_init(&VAR_0->txq_descr[VAR_1].comp_ring, pa, size,\nsizeof(struct Vmxnet3_TxCompDesc), true);",
"VMXNET3_RING_DUMP(VMW_CFPRN, \"TXC\", VAR_1, &VAR_0->txq_descr[VAR_1].comp_ring);",
"VAR_0->txq_descr[VAR_1].tx_stats_pa =\nqdescr_pa + offsetof(struct Vmxnet3_TxQueueDesc, stats);",
"memset(&VAR_0->txq_descr[VAR_1].txq_stats, 0,\nsizeof(VAR_0->txq_descr[VAR_1].txq_stats));",
"VMXNET3_WRITE_TX_QUEUE_DESCR32(qdescr_pa,\nctrl.txThreshold,\nVAR_2);",
"}",
"VMW_CFPRN(\"Max TX fragments is %u\", VAR_0->max_tx_frags);",
"net_tx_pkt_init(&VAR_0->tx_pkt, PCI_DEVICE(VAR_0),\nVAR_0->max_tx_frags, VAR_0->peer_has_vhdr);",
"net_rx_pkt_init(&VAR_0->rx_pkt, VAR_0->peer_has_vhdr);",
"for (VAR_1 = 0; VAR_1 < VAR_0->rxq_num; VAR_1++) {",
"int j;",
"hwaddr qd_pa =\nqdescr_table_pa + VAR_0->txq_num * sizeof(struct Vmxnet3_TxQueueDesc) +\nVAR_1 * sizeof(struct Vmxnet3_RxQueueDesc);",
"VAR_0->rxq_descr[VAR_1].intr_idx =\nVMXNET3_READ_TX_QUEUE_DESCR8(qd_pa, conf.intrIdx);",
"assert(vmxnet3_verify_intx(VAR_0, VAR_0->rxq_descr[VAR_1].intr_idx));",
"VMW_CFPRN(\"RX Queue %d interrupt: %d\", VAR_1, VAR_0->rxq_descr[VAR_1].intr_idx);",
"for (j = 0; j < VMXNET3_RX_RINGS_PER_QUEUE; j++) {",
"pa = VMXNET3_READ_RX_QUEUE_DESCR64(qd_pa, conf.rxRingBasePA[j]);",
"size = VMXNET3_READ_RX_QUEUE_DESCR32(qd_pa, conf.rxRingSize[j]);",
"vmxnet3_ring_init(&VAR_0->rxq_descr[VAR_1].rx_ring[j], pa, size,\nsizeof(struct Vmxnet3_RxDesc), false);",
"VMW_CFPRN(\"RX queue %d:%d: Base: %\" PRIx64 \", Size: %d\",\nVAR_1, j, pa, size);",
"}",
"pa = VMXNET3_READ_RX_QUEUE_DESCR64(qd_pa, conf.compRingBasePA);",
"size = VMXNET3_READ_RX_QUEUE_DESCR32(qd_pa, conf.compRingSize);",
"vmxnet3_ring_init(&VAR_0->rxq_descr[VAR_1].comp_ring, pa, size,\nsizeof(struct Vmxnet3_RxCompDesc), true);",
"VMW_CFPRN(\"RXC queue %d: Base: %\" PRIx64 \", Size: %d\", VAR_1, pa, size);",
"VAR_0->rxq_descr[VAR_1].rx_stats_pa =\nqd_pa + offsetof(struct Vmxnet3_RxQueueDesc, stats);",
"memset(&VAR_0->rxq_descr[VAR_1].rxq_stats, 0,\nsizeof(VAR_0->rxq_descr[VAR_1].rxq_stats));",
"}",
"vmxnet3_validate_interrupts(VAR_0);",
"smp_wmb();",
"vmxnet3_reset_mac(VAR_0);",
"VAR_0->device_active = true;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
1,
0,
0,
1,
0,
1,
1,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
1,
1,
1,
0,
0,
1,
1,
1,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
1,
1,
1,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
19
],
[
21
],
[
23
],
[
25
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
57,
59
],
[
63
],
[
65
],
[
67
],
[
71
],
[
75,
77
],
[
79
],
[
81
],
[
85,
87
],
[
89
],
[
93,
95
],
[
97,
99
],
[
103
],
[
105
],
[
109,
111
],
[
113
],
[
125
],
[
131
],
[
133,
135
],
[
141,
143
],
[
145
],
[
149
],
[
155
],
[
157
],
[
161,
163
],
[
165
],
[
169
],
[
175
],
[
177
],
[
179,
181
],
[
183
],
[
187,
189
],
[
193,
195
],
[
201,
203,
205
],
[
207
],
[
213
],
[
215,
217
],
[
219
],
[
225
],
[
227
],
[
229,
231,
233
],
[
239,
241
],
[
243
],
[
247
],
[
253
],
[
257
],
[
259
],
[
261,
263
],
[
265,
267
],
[
269
],
[
275
],
[
277
],
[
279,
281
],
[
283
],
[
287,
289
],
[
291,
293
],
[
295
],
[
299
],
[
305
],
[
309
],
[
313
],
[
315
]
]
|
13,626 | bool object_property_get_bool(Object *obj, const char *name,
Error **errp)
{
QObject *ret = object_property_get_qobject(obj, name, errp);
QBool *qbool;
bool retval;
if (!ret) {
return false;
}
qbool = qobject_to_qbool(ret);
if (!qbool) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "boolean");
retval = false;
} else {
retval = qbool_get_bool(qbool);
}
QDECREF(qbool);
return retval;
}
| true | qemu | 560f19f162529d691619ac69ed032321c7f5f1fb | bool object_property_get_bool(Object *obj, const char *name,
Error **errp)
{
QObject *ret = object_property_get_qobject(obj, name, errp);
QBool *qbool;
bool retval;
if (!ret) {
return false;
}
qbool = qobject_to_qbool(ret);
if (!qbool) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "boolean");
retval = false;
} else {
retval = qbool_get_bool(qbool);
}
QDECREF(qbool);
return retval;
}
| {
"code": [
" QDECREF(qbool);"
],
"line_no": [
37
]
} | bool FUNC_0(Object *obj, const char *name,
Error **errp)
{
QObject *ret = object_property_get_qobject(obj, name, errp);
QBool *qbool;
bool retval;
if (!ret) {
return false;
}
qbool = qobject_to_qbool(ret);
if (!qbool) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "boolean");
retval = false;
} else {
retval = qbool_get_bool(qbool);
}
QDECREF(qbool);
return retval;
}
| [
"bool FUNC_0(Object *obj, const char *name,\nError **errp)\n{",
"QObject *ret = object_property_get_qobject(obj, name, errp);",
"QBool *qbool;",
"bool retval;",
"if (!ret) {",
"return false;",
"}",
"qbool = qobject_to_qbool(ret);",
"if (!qbool) {",
"error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, \"boolean\");",
"retval = false;",
"} else {",
"retval = qbool_get_bool(qbool);",
"}",
"QDECREF(qbool);",
"return retval;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
]
]
|
13,627 | static void mpegts_insert_pcr_only(AVFormatContext *s, AVStream *st)
{
MpegTSWrite *ts = s->priv_data;
MpegTSWriteStream *ts_st = st->priv_data;
uint8_t *q;
uint8_t buf[TS_PACKET_SIZE];
q = buf;
*q++ = 0x47;
*q++ = ts_st->pid >> 8;
*q++ = ts_st->pid;
*q++ = 0x20 | ts_st->cc; /* Adaptation only */
/* Continuity Count field does not increment (see 13818-1 section 2.4.3.3) */
*q++ = TS_PACKET_SIZE - 5; /* Adaptation Field Length */
*q++ = 0x10; /* Adaptation flags: PCR present */
/* PCR coded into 6 bytes */
q += write_pcr_bits(q, get_pcr(ts, s->pb));
/* stuffing bytes */
memset(q, 0xFF, TS_PACKET_SIZE - (q - buf));
mpegts_prefix_m2ts_header(s);
avio_write(s->pb, buf, TS_PACKET_SIZE);
| true | FFmpeg | a566c952f905639456966413fee0b5701867ddcd | static void mpegts_insert_pcr_only(AVFormatContext *s, AVStream *st)
{
MpegTSWrite *ts = s->priv_data;
MpegTSWriteStream *ts_st = st->priv_data;
uint8_t *q;
uint8_t buf[TS_PACKET_SIZE];
q = buf;
*q++ = 0x47;
*q++ = ts_st->pid >> 8;
*q++ = ts_st->pid;
*q++ = 0x20 | ts_st->cc;
*q++ = TS_PACKET_SIZE - 5;
*q++ = 0x10;
q += write_pcr_bits(q, get_pcr(ts, s->pb));
memset(q, 0xFF, TS_PACKET_SIZE - (q - buf));
mpegts_prefix_m2ts_header(s);
avio_write(s->pb, buf, TS_PACKET_SIZE);
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1)
{
MpegTSWrite *ts = VAR_0->priv_data;
MpegTSWriteStream *ts_st = VAR_1->priv_data;
uint8_t *q;
uint8_t buf[TS_PACKET_SIZE];
q = buf;
*q++ = 0x47;
*q++ = ts_st->pid >> 8;
*q++ = ts_st->pid;
*q++ = 0x20 | ts_st->cc;
*q++ = TS_PACKET_SIZE - 5;
*q++ = 0x10;
q += write_pcr_bits(q, get_pcr(ts, VAR_0->pb));
memset(q, 0xFF, TS_PACKET_SIZE - (q - buf));
mpegts_prefix_m2ts_header(VAR_0);
avio_write(VAR_0->pb, buf, TS_PACKET_SIZE);
| [
"static void FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1)\n{",
"MpegTSWrite *ts = VAR_0->priv_data;",
"MpegTSWriteStream *ts_st = VAR_1->priv_data;",
"uint8_t *q;",
"uint8_t buf[TS_PACKET_SIZE];",
"q = buf;",
"*q++ = 0x47;",
"*q++ = ts_st->pid >> 8;",
"*q++ = ts_st->pid;",
"*q++ = 0x20 | ts_st->cc;",
"*q++ = TS_PACKET_SIZE - 5;",
"*q++ = 0x10;",
"q += write_pcr_bits(q, get_pcr(ts, VAR_0->pb));",
"memset(q, 0xFF, TS_PACKET_SIZE - (q - buf));",
"mpegts_prefix_m2ts_header(VAR_0);",
"avio_write(VAR_0->pb, buf, TS_PACKET_SIZE);"
]
| [
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
],
[
27
],
[
29
],
[
39
],
[
45
],
[
47
],
[
49
]
]
|
13,628 | static void disas_extract(DisasContext *s, uint32_t insn)
{
unsupported_encoding(s, insn);
}
| true | qemu | e801de93d0155c0c14d6b4dea1b3577ca36e214b | static void disas_extract(DisasContext *s, uint32_t insn)
{
unsupported_encoding(s, insn);
}
| {
"code": [
" unsupported_encoding(s, insn);"
],
"line_no": [
5
]
} | static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1)
{
unsupported_encoding(VAR_0, VAR_1);
}
| [
"static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1)\n{",
"unsupported_encoding(VAR_0, VAR_1);",
"}"
]
| [
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
13,629 | static int dxva2_mpeg2_end_frame(AVCodecContext *avctx)
{
struct MpegEncContext *s = avctx->priv_data;
struct dxva2_picture_context *ctx_pic =
s->current_picture_ptr->hwaccel_picture_private;
int ret;
if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
return -1;
ret = ff_dxva2_common_end_frame(avctx, &s->current_picture_ptr->f,
&ctx_pic->pp, sizeof(ctx_pic->pp),
&ctx_pic->qm, sizeof(ctx_pic->qm),
commit_bitstream_and_slice_buffer);
if (!ret)
ff_mpeg_draw_horiz_band(s, 0, avctx->height);
return ret;
}
| true | FFmpeg | f6774f905fb3cfdc319523ac640be30b14c1bc55 | static int dxva2_mpeg2_end_frame(AVCodecContext *avctx)
{
struct MpegEncContext *s = avctx->priv_data;
struct dxva2_picture_context *ctx_pic =
s->current_picture_ptr->hwaccel_picture_private;
int ret;
if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
return -1;
ret = ff_dxva2_common_end_frame(avctx, &s->current_picture_ptr->f,
&ctx_pic->pp, sizeof(ctx_pic->pp),
&ctx_pic->qm, sizeof(ctx_pic->qm),
commit_bitstream_and_slice_buffer);
if (!ret)
ff_mpeg_draw_horiz_band(s, 0, avctx->height);
return ret;
}
| {
"code": [
" ret = ff_dxva2_common_end_frame(avctx, &s->current_picture_ptr->f,"
],
"line_no": [
19
]
} | static int FUNC_0(AVCodecContext *VAR_0)
{
struct MpegEncContext *VAR_1 = VAR_0->priv_data;
struct dxva2_picture_context *VAR_2 =
VAR_1->current_picture_ptr->hwaccel_picture_private;
int VAR_3;
if (VAR_2->slice_count <= 0 || VAR_2->bitstream_size <= 0)
return -1;
VAR_3 = ff_dxva2_common_end_frame(VAR_0, &VAR_1->current_picture_ptr->f,
&VAR_2->pp, sizeof(VAR_2->pp),
&VAR_2->qm, sizeof(VAR_2->qm),
commit_bitstream_and_slice_buffer);
if (!VAR_3)
ff_mpeg_draw_horiz_band(VAR_1, 0, VAR_0->height);
return VAR_3;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0)\n{",
"struct MpegEncContext *VAR_1 = VAR_0->priv_data;",
"struct dxva2_picture_context *VAR_2 =\nVAR_1->current_picture_ptr->hwaccel_picture_private;",
"int VAR_3;",
"if (VAR_2->slice_count <= 0 || VAR_2->bitstream_size <= 0)\nreturn -1;",
"VAR_3 = ff_dxva2_common_end_frame(VAR_0, &VAR_1->current_picture_ptr->f,\n&VAR_2->pp, sizeof(VAR_2->pp),\n&VAR_2->qm, sizeof(VAR_2->qm),\ncommit_bitstream_and_slice_buffer);",
"if (!VAR_3)\nff_mpeg_draw_horiz_band(VAR_1, 0, VAR_0->height);",
"return VAR_3;",
"}"
]
| [
0,
0,
0,
0,
0,
1,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7,
9
],
[
11
],
[
15,
17
],
[
19,
21,
23,
25
],
[
27,
29
],
[
31
],
[
33
]
]
|
13,630 | static int au_read_header(AVFormatContext *s)
{
int size;
unsigned int tag;
AVIOContext *pb = s->pb;
unsigned int id, channels, rate;
int bps;
enum AVCodecID codec;
AVStream *st;
/* check ".snd" header */
tag = avio_rl32(pb);
if (tag != MKTAG('.', 's', 'n', 'd'))
return -1;
size = avio_rb32(pb); /* header size */
avio_rb32(pb); /* data size */
id = avio_rb32(pb);
rate = avio_rb32(pb);
channels = avio_rb32(pb);
codec = ff_codec_get_id(codec_au_tags, id);
if (codec == AV_CODEC_ID_NONE) {
av_log_ask_for_sample(s, "unknown or unsupported codec tag: %d\n", id);
return AVERROR_PATCHWELCOME;
}
bps = av_get_bits_per_sample(codec);
if (!bps) {
av_log_ask_for_sample(s, "could not determine bits per sample\n");
return AVERROR_PATCHWELCOME;
}
if (channels == 0 || channels > 64) {
av_log(s, AV_LOG_ERROR, "Invalid number of channels %d\n", channels);
return AVERROR_INVALIDDATA;
}
if (size >= 24) {
/* skip unused data */
avio_skip(pb, size - 24);
}
/* now we are ready: build format streams */
st = avformat_new_stream(s, NULL);
if (!st)
return -1;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_tag = id;
st->codec->codec_id = codec;
st->codec->channels = channels;
st->codec->sample_rate = rate;
st->codec->bit_rate = channels * rate * bps;
st->codec->block_align = channels * bps >> 3;
avpriv_set_pts_info(st, 64, 1, rate);
return 0;
}
| true | FFmpeg | fb48f825e33c15146b8ce4e5258332ebc4a9b5ea | static int au_read_header(AVFormatContext *s)
{
int size;
unsigned int tag;
AVIOContext *pb = s->pb;
unsigned int id, channels, rate;
int bps;
enum AVCodecID codec;
AVStream *st;
tag = avio_rl32(pb);
if (tag != MKTAG('.', 's', 'n', 'd'))
return -1;
size = avio_rb32(pb);
avio_rb32(pb);
id = avio_rb32(pb);
rate = avio_rb32(pb);
channels = avio_rb32(pb);
codec = ff_codec_get_id(codec_au_tags, id);
if (codec == AV_CODEC_ID_NONE) {
av_log_ask_for_sample(s, "unknown or unsupported codec tag: %d\n", id);
return AVERROR_PATCHWELCOME;
}
bps = av_get_bits_per_sample(codec);
if (!bps) {
av_log_ask_for_sample(s, "could not determine bits per sample\n");
return AVERROR_PATCHWELCOME;
}
if (channels == 0 || channels > 64) {
av_log(s, AV_LOG_ERROR, "Invalid number of channels %d\n", channels);
return AVERROR_INVALIDDATA;
}
if (size >= 24) {
avio_skip(pb, size - 24);
}
st = avformat_new_stream(s, NULL);
if (!st)
return -1;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_tag = id;
st->codec->codec_id = codec;
st->codec->channels = channels;
st->codec->sample_rate = rate;
st->codec->bit_rate = channels * rate * bps;
st->codec->block_align = channels * bps >> 3;
avpriv_set_pts_info(st, 64, 1, rate);
return 0;
}
| {
"code": [
" if (channels == 0 || channels > 64) {"
],
"line_no": [
69
]
} | static int FUNC_0(AVFormatContext *VAR_0)
{
int VAR_1;
unsigned int VAR_2;
AVIOContext *pb = VAR_0->pb;
unsigned int VAR_3, VAR_4, VAR_5;
int VAR_6;
enum AVCodecID VAR_7;
AVStream *st;
VAR_2 = avio_rl32(pb);
if (VAR_2 != MKTAG('.', 'VAR_0', 'n', 'd'))
return -1;
VAR_1 = avio_rb32(pb);
avio_rb32(pb);
VAR_3 = avio_rb32(pb);
VAR_5 = avio_rb32(pb);
VAR_4 = avio_rb32(pb);
VAR_7 = ff_codec_get_id(codec_au_tags, VAR_3);
if (VAR_7 == AV_CODEC_ID_NONE) {
av_log_ask_for_sample(VAR_0, "unknown or unsupported VAR_7 VAR_2: %d\n", VAR_3);
return AVERROR_PATCHWELCOME;
}
VAR_6 = av_get_bits_per_sample(VAR_7);
if (!VAR_6) {
av_log_ask_for_sample(VAR_0, "could not determine bits per sample\n");
return AVERROR_PATCHWELCOME;
}
if (VAR_4 == 0 || VAR_4 > 64) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid number of VAR_4 %d\n", VAR_4);
return AVERROR_INVALIDDATA;
}
if (VAR_1 >= 24) {
avio_skip(pb, VAR_1 - 24);
}
st = avformat_new_stream(VAR_0, NULL);
if (!st)
return -1;
st->VAR_7->codec_type = AVMEDIA_TYPE_AUDIO;
st->VAR_7->codec_tag = VAR_3;
st->VAR_7->codec_id = VAR_7;
st->VAR_7->VAR_4 = VAR_4;
st->VAR_7->sample_rate = VAR_5;
st->VAR_7->bit_rate = VAR_4 * VAR_5 * VAR_6;
st->VAR_7->block_align = VAR_4 * VAR_6 >> 3;
avpriv_set_pts_info(st, 64, 1, VAR_5);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"int VAR_1;",
"unsigned int VAR_2;",
"AVIOContext *pb = VAR_0->pb;",
"unsigned int VAR_3, VAR_4, VAR_5;",
"int VAR_6;",
"enum AVCodecID VAR_7;",
"AVStream *st;",
"VAR_2 = avio_rl32(pb);",
"if (VAR_2 != MKTAG('.', 'VAR_0', 'n', 'd'))\nreturn -1;",
"VAR_1 = avio_rb32(pb);",
"avio_rb32(pb);",
"VAR_3 = avio_rb32(pb);",
"VAR_5 = avio_rb32(pb);",
"VAR_4 = avio_rb32(pb);",
"VAR_7 = ff_codec_get_id(codec_au_tags, VAR_3);",
"if (VAR_7 == AV_CODEC_ID_NONE) {",
"av_log_ask_for_sample(VAR_0, \"unknown or unsupported VAR_7 VAR_2: %d\\n\", VAR_3);",
"return AVERROR_PATCHWELCOME;",
"}",
"VAR_6 = av_get_bits_per_sample(VAR_7);",
"if (!VAR_6) {",
"av_log_ask_for_sample(VAR_0, \"could not determine bits per sample\\n\");",
"return AVERROR_PATCHWELCOME;",
"}",
"if (VAR_4 == 0 || VAR_4 > 64) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid number of VAR_4 %d\\n\", VAR_4);",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_1 >= 24) {",
"avio_skip(pb, VAR_1 - 24);",
"}",
"st = avformat_new_stream(VAR_0, NULL);",
"if (!st)\nreturn -1;",
"st->VAR_7->codec_type = AVMEDIA_TYPE_AUDIO;",
"st->VAR_7->codec_tag = VAR_3;",
"st->VAR_7->codec_id = VAR_7;",
"st->VAR_7->VAR_4 = VAR_4;",
"st->VAR_7->sample_rate = VAR_5;",
"st->VAR_7->bit_rate = VAR_4 * VAR_5 * VAR_6;",
"st->VAR_7->block_align = VAR_4 * VAR_6 >> 3;",
"avpriv_set_pts_info(st, 64, 1, VAR_5);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
83
],
[
85
],
[
91
],
[
93,
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
]
]
|
13,631 | static inline void bink_idct_col(DCTELEM *dest, const DCTELEM *src)
{
if ((src[8]|src[16]|src[24]|src[32]|src[40]|src[48]|src[56])==0) {
dest[0] =
dest[8] =
dest[16] =
dest[24] =
dest[32] =
dest[40] =
dest[48] =
dest[56] = src[0];
} else {
IDCT_COL(dest, src);
}
}
| true | FFmpeg | c3afa4db913668e50ac8ffc0bc66621664adc1f4 | static inline void bink_idct_col(DCTELEM *dest, const DCTELEM *src)
{
if ((src[8]|src[16]|src[24]|src[32]|src[40]|src[48]|src[56])==0) {
dest[0] =
dest[8] =
dest[16] =
dest[24] =
dest[32] =
dest[40] =
dest[48] =
dest[56] = src[0];
} else {
IDCT_COL(dest, src);
}
}
| {
"code": [
"static inline void bink_idct_col(DCTELEM *dest, const DCTELEM *src)"
],
"line_no": [
1
]
} | static inline void FUNC_0(DCTELEM *VAR_0, const DCTELEM *VAR_1)
{
if ((VAR_1[8]|VAR_1[16]|VAR_1[24]|VAR_1[32]|VAR_1[40]|VAR_1[48]|VAR_1[56])==0) {
VAR_0[0] =
VAR_0[8] =
VAR_0[16] =
VAR_0[24] =
VAR_0[32] =
VAR_0[40] =
VAR_0[48] =
VAR_0[56] = VAR_1[0];
} else {
IDCT_COL(VAR_0, VAR_1);
}
}
| [
"static inline void FUNC_0(DCTELEM *VAR_0, const DCTELEM *VAR_1)\n{",
"if ((VAR_1[8]|VAR_1[16]|VAR_1[24]|VAR_1[32]|VAR_1[40]|VAR_1[48]|VAR_1[56])==0) {",
"VAR_0[0] =\nVAR_0[8] =\nVAR_0[16] =\nVAR_0[24] =\nVAR_0[32] =\nVAR_0[40] =\nVAR_0[48] =\nVAR_0[56] = VAR_1[0];",
"} else {",
"IDCT_COL(VAR_0, VAR_1);",
"}",
"}"
]
| [
1,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7,
9,
11,
13,
15,
17,
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
]
]
|
13,632 | static int decode_info_header(NUTContext *nut)
{
AVFormatContext *s = nut->avf;
AVIOContext *bc = s->pb;
uint64_t tmp, chapter_start, chapter_len;
unsigned int stream_id_plus1, count;
int chapter_id, i;
int64_t value, end;
char name[256], str_value[1024], type_str[256];
const char *type;
int *event_flags;
AVChapter *chapter = NULL;
AVStream *st = NULL;
AVDictionary **metadata = NULL;
int metadata_flag = 0;
end = get_packetheader(nut, bc, 1, INFO_STARTCODE);
end += avio_tell(bc);
GET_V(stream_id_plus1, tmp <= s->nb_streams);
chapter_id = get_s(bc);
chapter_start = ffio_read_varlen(bc);
chapter_len = ffio_read_varlen(bc);
count = ffio_read_varlen(bc);
if (chapter_id && !stream_id_plus1) {
int64_t start = chapter_start / nut->time_base_count;
chapter = avpriv_new_chapter(s, chapter_id,
nut->time_base[chapter_start %
nut->time_base_count],
start, start + chapter_len, NULL);
metadata = &chapter->metadata;
} else if (stream_id_plus1) {
st = s->streams[stream_id_plus1 - 1];
metadata = &st->metadata;
event_flags = &st->event_flags;
metadata_flag = AVSTREAM_EVENT_FLAG_METADATA_UPDATED;
} else {
metadata = &s->metadata;
event_flags = &s->event_flags;
metadata_flag = AVFMT_EVENT_FLAG_METADATA_UPDATED;
}
for (i = 0; i < count; i++) {
get_str(bc, name, sizeof(name));
value = get_s(bc);
if (value == -1) {
type = "UTF-8";
get_str(bc, str_value, sizeof(str_value));
} else if (value == -2) {
get_str(bc, type_str, sizeof(type_str));
type = type_str;
get_str(bc, str_value, sizeof(str_value));
} else if (value == -3) {
type = "s";
value = get_s(bc);
} else if (value == -4) {
type = "t";
value = ffio_read_varlen(bc);
} else if (value < -4) {
type = "r";
get_s(bc);
} else {
type = "v";
}
if (stream_id_plus1 > s->nb_streams) {
av_log(s, AV_LOG_ERROR, "invalid stream id for info packet\n");
continue;
}
if (!strcmp(type, "UTF-8")) {
if (chapter_id == 0 && !strcmp(name, "Disposition")) {
set_disposition_bits(s, str_value, stream_id_plus1 - 1);
continue;
}
if (metadata && av_strcasecmp(name, "Uses") &&
av_strcasecmp(name, "Depends") && av_strcasecmp(name, "Replaces")) {
*event_flags |= metadata_flag;
av_dict_set(metadata, name, str_value, 0);
}
}
}
if (skip_reserved(bc, end) || ffio_get_checksum(bc)) {
av_log(s, AV_LOG_ERROR, "info header checksum mismatch\n");
return AVERROR_INVALIDDATA;
}
return 0;
}
| true | FFmpeg | 96bfb677478514db73d1b63b4213c97ad4269e8f | static int decode_info_header(NUTContext *nut)
{
AVFormatContext *s = nut->avf;
AVIOContext *bc = s->pb;
uint64_t tmp, chapter_start, chapter_len;
unsigned int stream_id_plus1, count;
int chapter_id, i;
int64_t value, end;
char name[256], str_value[1024], type_str[256];
const char *type;
int *event_flags;
AVChapter *chapter = NULL;
AVStream *st = NULL;
AVDictionary **metadata = NULL;
int metadata_flag = 0;
end = get_packetheader(nut, bc, 1, INFO_STARTCODE);
end += avio_tell(bc);
GET_V(stream_id_plus1, tmp <= s->nb_streams);
chapter_id = get_s(bc);
chapter_start = ffio_read_varlen(bc);
chapter_len = ffio_read_varlen(bc);
count = ffio_read_varlen(bc);
if (chapter_id && !stream_id_plus1) {
int64_t start = chapter_start / nut->time_base_count;
chapter = avpriv_new_chapter(s, chapter_id,
nut->time_base[chapter_start %
nut->time_base_count],
start, start + chapter_len, NULL);
metadata = &chapter->metadata;
} else if (stream_id_plus1) {
st = s->streams[stream_id_plus1 - 1];
metadata = &st->metadata;
event_flags = &st->event_flags;
metadata_flag = AVSTREAM_EVENT_FLAG_METADATA_UPDATED;
} else {
metadata = &s->metadata;
event_flags = &s->event_flags;
metadata_flag = AVFMT_EVENT_FLAG_METADATA_UPDATED;
}
for (i = 0; i < count; i++) {
get_str(bc, name, sizeof(name));
value = get_s(bc);
if (value == -1) {
type = "UTF-8";
get_str(bc, str_value, sizeof(str_value));
} else if (value == -2) {
get_str(bc, type_str, sizeof(type_str));
type = type_str;
get_str(bc, str_value, sizeof(str_value));
} else if (value == -3) {
type = "s";
value = get_s(bc);
} else if (value == -4) {
type = "t";
value = ffio_read_varlen(bc);
} else if (value < -4) {
type = "r";
get_s(bc);
} else {
type = "v";
}
if (stream_id_plus1 > s->nb_streams) {
av_log(s, AV_LOG_ERROR, "invalid stream id for info packet\n");
continue;
}
if (!strcmp(type, "UTF-8")) {
if (chapter_id == 0 && !strcmp(name, "Disposition")) {
set_disposition_bits(s, str_value, stream_id_plus1 - 1);
continue;
}
if (metadata && av_strcasecmp(name, "Uses") &&
av_strcasecmp(name, "Depends") && av_strcasecmp(name, "Replaces")) {
*event_flags |= metadata_flag;
av_dict_set(metadata, name, str_value, 0);
}
}
}
if (skip_reserved(bc, end) || ffio_get_checksum(bc)) {
av_log(s, AV_LOG_ERROR, "info header checksum mismatch\n");
return AVERROR_INVALIDDATA;
}
return 0;
}
| {
"code": [
" int *event_flags;",
" *event_flags |= metadata_flag;"
],
"line_no": [
21,
157
]
} | static int FUNC_0(NUTContext *VAR_0)
{
AVFormatContext *s = VAR_0->avf;
AVIOContext *bc = s->pb;
uint64_t tmp, chapter_start, chapter_len;
unsigned int VAR_1, VAR_2;
int VAR_3, VAR_4;
int64_t value, end;
char VAR_5[256], VAR_6[1024], VAR_7[256];
const char *VAR_8;
int *VAR_9;
AVChapter *chapter = NULL;
AVStream *st = NULL;
AVDictionary **metadata = NULL;
int VAR_10 = 0;
end = get_packetheader(VAR_0, bc, 1, INFO_STARTCODE);
end += avio_tell(bc);
GET_V(VAR_1, tmp <= s->nb_streams);
VAR_3 = get_s(bc);
chapter_start = ffio_read_varlen(bc);
chapter_len = ffio_read_varlen(bc);
VAR_2 = ffio_read_varlen(bc);
if (VAR_3 && !VAR_1) {
int64_t start = chapter_start / VAR_0->time_base_count;
chapter = avpriv_new_chapter(s, VAR_3,
VAR_0->time_base[chapter_start %
VAR_0->time_base_count],
start, start + chapter_len, NULL);
metadata = &chapter->metadata;
} else if (VAR_1) {
st = s->streams[VAR_1 - 1];
metadata = &st->metadata;
VAR_9 = &st->VAR_9;
VAR_10 = AVSTREAM_EVENT_FLAG_METADATA_UPDATED;
} else {
metadata = &s->metadata;
VAR_9 = &s->VAR_9;
VAR_10 = AVFMT_EVENT_FLAG_METADATA_UPDATED;
}
for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++) {
get_str(bc, VAR_5, sizeof(VAR_5));
value = get_s(bc);
if (value == -1) {
VAR_8 = "UTF-8";
get_str(bc, VAR_6, sizeof(VAR_6));
} else if (value == -2) {
get_str(bc, VAR_7, sizeof(VAR_7));
VAR_8 = VAR_7;
get_str(bc, VAR_6, sizeof(VAR_6));
} else if (value == -3) {
VAR_8 = "s";
value = get_s(bc);
} else if (value == -4) {
VAR_8 = "t";
value = ffio_read_varlen(bc);
} else if (value < -4) {
VAR_8 = "r";
get_s(bc);
} else {
VAR_8 = "v";
}
if (VAR_1 > s->nb_streams) {
av_log(s, AV_LOG_ERROR, "invalid stream id for info packet\n");
continue;
}
if (!strcmp(VAR_8, "UTF-8")) {
if (VAR_3 == 0 && !strcmp(VAR_5, "Disposition")) {
set_disposition_bits(s, VAR_6, VAR_1 - 1);
continue;
}
if (metadata && av_strcasecmp(VAR_5, "Uses") &&
av_strcasecmp(VAR_5, "Depends") && av_strcasecmp(VAR_5, "Replaces")) {
*VAR_9 |= VAR_10;
av_dict_set(metadata, VAR_5, VAR_6, 0);
}
}
}
if (skip_reserved(bc, end) || ffio_get_checksum(bc)) {
av_log(s, AV_LOG_ERROR, "info header checksum mismatch\n");
return AVERROR_INVALIDDATA;
}
return 0;
}
| [
"static int FUNC_0(NUTContext *VAR_0)\n{",
"AVFormatContext *s = VAR_0->avf;",
"AVIOContext *bc = s->pb;",
"uint64_t tmp, chapter_start, chapter_len;",
"unsigned int VAR_1, VAR_2;",
"int VAR_3, VAR_4;",
"int64_t value, end;",
"char VAR_5[256], VAR_6[1024], VAR_7[256];",
"const char *VAR_8;",
"int *VAR_9;",
"AVChapter *chapter = NULL;",
"AVStream *st = NULL;",
"AVDictionary **metadata = NULL;",
"int VAR_10 = 0;",
"end = get_packetheader(VAR_0, bc, 1, INFO_STARTCODE);",
"end += avio_tell(bc);",
"GET_V(VAR_1, tmp <= s->nb_streams);",
"VAR_3 = get_s(bc);",
"chapter_start = ffio_read_varlen(bc);",
"chapter_len = ffio_read_varlen(bc);",
"VAR_2 = ffio_read_varlen(bc);",
"if (VAR_3 && !VAR_1) {",
"int64_t start = chapter_start / VAR_0->time_base_count;",
"chapter = avpriv_new_chapter(s, VAR_3,\nVAR_0->time_base[chapter_start %\nVAR_0->time_base_count],\nstart, start + chapter_len, NULL);",
"metadata = &chapter->metadata;",
"} else if (VAR_1) {",
"st = s->streams[VAR_1 - 1];",
"metadata = &st->metadata;",
"VAR_9 = &st->VAR_9;",
"VAR_10 = AVSTREAM_EVENT_FLAG_METADATA_UPDATED;",
"} else {",
"metadata = &s->metadata;",
"VAR_9 = &s->VAR_9;",
"VAR_10 = AVFMT_EVENT_FLAG_METADATA_UPDATED;",
"}",
"for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++) {",
"get_str(bc, VAR_5, sizeof(VAR_5));",
"value = get_s(bc);",
"if (value == -1) {",
"VAR_8 = \"UTF-8\";",
"get_str(bc, VAR_6, sizeof(VAR_6));",
"} else if (value == -2) {",
"get_str(bc, VAR_7, sizeof(VAR_7));",
"VAR_8 = VAR_7;",
"get_str(bc, VAR_6, sizeof(VAR_6));",
"} else if (value == -3) {",
"VAR_8 = \"s\";",
"value = get_s(bc);",
"} else if (value == -4) {",
"VAR_8 = \"t\";",
"value = ffio_read_varlen(bc);",
"} else if (value < -4) {",
"VAR_8 = \"r\";",
"get_s(bc);",
"} else {",
"VAR_8 = \"v\";",
"}",
"if (VAR_1 > s->nb_streams) {",
"av_log(s, AV_LOG_ERROR, \"invalid stream id for info packet\\n\");",
"continue;",
"}",
"if (!strcmp(VAR_8, \"UTF-8\")) {",
"if (VAR_3 == 0 && !strcmp(VAR_5, \"Disposition\")) {",
"set_disposition_bits(s, VAR_6, VAR_1 - 1);",
"continue;",
"}",
"if (metadata && av_strcasecmp(VAR_5, \"Uses\") &&\nav_strcasecmp(VAR_5, \"Depends\") && av_strcasecmp(VAR_5, \"Replaces\")) {",
"*VAR_9 |= VAR_10;",
"av_dict_set(metadata, VAR_5, VAR_6, 0);",
"}",
"}",
"}",
"if (skip_reserved(bc, end) || ffio_get_checksum(bc)) {",
"av_log(s, AV_LOG_ERROR, \"info header checksum mismatch\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"return 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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55,
57,
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153,
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
]
]
|
13,633 | static void vhost_client_set_memory(CPUPhysMemoryClient *client,
target_phys_addr_t start_addr,
ram_addr_t size,
ram_addr_t phys_offset,
bool log_dirty)
{
struct vhost_dev *dev = container_of(client, struct vhost_dev, client);
ram_addr_t flags = phys_offset & ~TARGET_PAGE_MASK;
int s = offsetof(struct vhost_memory, regions) +
(dev->mem->nregions + 1) * sizeof dev->mem->regions[0];
uint64_t log_size;
int r;
dev->mem = g_realloc(dev->mem, s);
if (log_dirty) {
flags = IO_MEM_UNASSIGNED;
}
assert(size);
/* Optimize no-change case. At least cirrus_vga does this a lot at this time. */
if (flags == IO_MEM_RAM) {
if (!vhost_dev_cmp_memory(dev, start_addr, size,
(uintptr_t)qemu_get_ram_ptr(phys_offset))) {
/* Region exists with same address. Nothing to do. */
return;
}
} else {
if (!vhost_dev_find_reg(dev, start_addr, size)) {
/* Removing region that we don't access. Nothing to do. */
return;
}
}
vhost_dev_unassign_memory(dev, start_addr, size);
if (flags == IO_MEM_RAM) {
/* Add given mapping, merging adjacent regions if any */
vhost_dev_assign_memory(dev, start_addr, size,
(uintptr_t)qemu_get_ram_ptr(phys_offset));
} else {
/* Remove old mapping for this memory, if any. */
vhost_dev_unassign_memory(dev, start_addr, size);
}
if (!dev->started) {
return;
}
if (dev->started) {
r = vhost_verify_ring_mappings(dev, start_addr, size);
assert(r >= 0);
}
if (!dev->log_enabled) {
r = ioctl(dev->control, VHOST_SET_MEM_TABLE, dev->mem);
assert(r >= 0);
return;
}
log_size = vhost_get_log_size(dev);
/* We allocate an extra 4K bytes to log,
* to reduce the * number of reallocations. */
#define VHOST_LOG_BUFFER (0x1000 / sizeof *dev->log)
/* To log more, must increase log size before table update. */
if (dev->log_size < log_size) {
vhost_dev_log_resize(dev, log_size + VHOST_LOG_BUFFER);
}
r = ioctl(dev->control, VHOST_SET_MEM_TABLE, dev->mem);
assert(r >= 0);
/* To log less, can only decrease log size after table update. */
if (dev->log_size > log_size + VHOST_LOG_BUFFER) {
vhost_dev_log_resize(dev, log_size);
}
}
| true | qemu | 04097f7c5957273c578f72b9bd603ba6b1d69e33 | static void vhost_client_set_memory(CPUPhysMemoryClient *client,
target_phys_addr_t start_addr,
ram_addr_t size,
ram_addr_t phys_offset,
bool log_dirty)
{
struct vhost_dev *dev = container_of(client, struct vhost_dev, client);
ram_addr_t flags = phys_offset & ~TARGET_PAGE_MASK;
int s = offsetof(struct vhost_memory, regions) +
(dev->mem->nregions + 1) * sizeof dev->mem->regions[0];
uint64_t log_size;
int r;
dev->mem = g_realloc(dev->mem, s);
if (log_dirty) {
flags = IO_MEM_UNASSIGNED;
}
assert(size);
if (flags == IO_MEM_RAM) {
if (!vhost_dev_cmp_memory(dev, start_addr, size,
(uintptr_t)qemu_get_ram_ptr(phys_offset))) {
return;
}
} else {
if (!vhost_dev_find_reg(dev, start_addr, size)) {
return;
}
}
vhost_dev_unassign_memory(dev, start_addr, size);
if (flags == IO_MEM_RAM) {
vhost_dev_assign_memory(dev, start_addr, size,
(uintptr_t)qemu_get_ram_ptr(phys_offset));
} else {
vhost_dev_unassign_memory(dev, start_addr, size);
}
if (!dev->started) {
return;
}
if (dev->started) {
r = vhost_verify_ring_mappings(dev, start_addr, size);
assert(r >= 0);
}
if (!dev->log_enabled) {
r = ioctl(dev->control, VHOST_SET_MEM_TABLE, dev->mem);
assert(r >= 0);
return;
}
log_size = vhost_get_log_size(dev);
#define VHOST_LOG_BUFFER (0x1000 / sizeof *dev->log)
if (dev->log_size < log_size) {
vhost_dev_log_resize(dev, log_size + VHOST_LOG_BUFFER);
}
r = ioctl(dev->control, VHOST_SET_MEM_TABLE, dev->mem);
assert(r >= 0);
if (dev->log_size > log_size + VHOST_LOG_BUFFER) {
vhost_dev_log_resize(dev, log_size);
}
}
| {
"code": [
" struct vhost_dev *dev = container_of(client, struct vhost_dev, client);",
"static void vhost_client_set_memory(CPUPhysMemoryClient *client,",
" target_phys_addr_t start_addr,",
" ram_addr_t size,",
" ram_addr_t phys_offset,",
" bool log_dirty)",
" struct vhost_dev *dev = container_of(client, struct vhost_dev, client);",
" ram_addr_t flags = phys_offset & ~TARGET_PAGE_MASK;",
" flags = IO_MEM_UNASSIGNED;",
" if (flags == IO_MEM_RAM) {",
" if (!vhost_dev_cmp_memory(dev, start_addr, size,",
" (uintptr_t)qemu_get_ram_ptr(phys_offset))) {",
" if (flags == IO_MEM_RAM) {",
" vhost_dev_assign_memory(dev, start_addr, size,",
" (uintptr_t)qemu_get_ram_ptr(phys_offset));",
" struct vhost_dev *dev = container_of(client, struct vhost_dev, client);"
],
"line_no": [
13,
1,
3,
5,
7,
9,
13,
15,
33,
45,
47,
49,
45,
77,
79,
13
]
} | static void FUNC_0(CPUPhysMemoryClient *VAR_0,
target_phys_addr_t VAR_1,
ram_addr_t VAR_2,
ram_addr_t VAR_3,
bool VAR_4)
{
struct vhost_dev *VAR_5 = container_of(VAR_0, struct vhost_dev, VAR_0);
ram_addr_t flags = VAR_3 & ~TARGET_PAGE_MASK;
int VAR_6 = offsetof(struct vhost_memory, regions) +
(VAR_5->mem->nregions + 1) * sizeof VAR_5->mem->regions[0];
uint64_t log_size;
int VAR_7;
VAR_5->mem = g_realloc(VAR_5->mem, VAR_6);
if (VAR_4) {
flags = IO_MEM_UNASSIGNED;
}
assert(VAR_2);
if (flags == IO_MEM_RAM) {
if (!vhost_dev_cmp_memory(VAR_5, VAR_1, VAR_2,
(uintptr_t)qemu_get_ram_ptr(VAR_3))) {
return;
}
} else {
if (!vhost_dev_find_reg(VAR_5, VAR_1, VAR_2)) {
return;
}
}
vhost_dev_unassign_memory(VAR_5, VAR_1, VAR_2);
if (flags == IO_MEM_RAM) {
vhost_dev_assign_memory(VAR_5, VAR_1, VAR_2,
(uintptr_t)qemu_get_ram_ptr(VAR_3));
} else {
vhost_dev_unassign_memory(VAR_5, VAR_1, VAR_2);
}
if (!VAR_5->started) {
return;
}
if (VAR_5->started) {
VAR_7 = vhost_verify_ring_mappings(VAR_5, VAR_1, VAR_2);
assert(VAR_7 >= 0);
}
if (!VAR_5->log_enabled) {
VAR_7 = ioctl(VAR_5->control, VHOST_SET_MEM_TABLE, VAR_5->mem);
assert(VAR_7 >= 0);
return;
}
log_size = vhost_get_log_size(VAR_5);
#define VHOST_LOG_BUFFER (0x1000 / sizeof *VAR_5->log)
if (VAR_5->log_size < log_size) {
vhost_dev_log_resize(VAR_5, log_size + VHOST_LOG_BUFFER);
}
VAR_7 = ioctl(VAR_5->control, VHOST_SET_MEM_TABLE, VAR_5->mem);
assert(VAR_7 >= 0);
if (VAR_5->log_size > log_size + VHOST_LOG_BUFFER) {
vhost_dev_log_resize(VAR_5, log_size);
}
}
| [
"static void FUNC_0(CPUPhysMemoryClient *VAR_0,\ntarget_phys_addr_t VAR_1,\nram_addr_t VAR_2,\nram_addr_t VAR_3,\nbool VAR_4)\n{",
"struct vhost_dev *VAR_5 = container_of(VAR_0, struct vhost_dev, VAR_0);",
"ram_addr_t flags = VAR_3 & ~TARGET_PAGE_MASK;",
"int VAR_6 = offsetof(struct vhost_memory, regions) +\n(VAR_5->mem->nregions + 1) * sizeof VAR_5->mem->regions[0];",
"uint64_t log_size;",
"int VAR_7;",
"VAR_5->mem = g_realloc(VAR_5->mem, VAR_6);",
"if (VAR_4) {",
"flags = IO_MEM_UNASSIGNED;",
"}",
"assert(VAR_2);",
"if (flags == IO_MEM_RAM) {",
"if (!vhost_dev_cmp_memory(VAR_5, VAR_1, VAR_2,\n(uintptr_t)qemu_get_ram_ptr(VAR_3))) {",
"return;",
"}",
"} else {",
"if (!vhost_dev_find_reg(VAR_5, VAR_1, VAR_2)) {",
"return;",
"}",
"}",
"vhost_dev_unassign_memory(VAR_5, VAR_1, VAR_2);",
"if (flags == IO_MEM_RAM) {",
"vhost_dev_assign_memory(VAR_5, VAR_1, VAR_2,\n(uintptr_t)qemu_get_ram_ptr(VAR_3));",
"} else {",
"vhost_dev_unassign_memory(VAR_5, VAR_1, VAR_2);",
"}",
"if (!VAR_5->started) {",
"return;",
"}",
"if (VAR_5->started) {",
"VAR_7 = vhost_verify_ring_mappings(VAR_5, VAR_1, VAR_2);",
"assert(VAR_7 >= 0);",
"}",
"if (!VAR_5->log_enabled) {",
"VAR_7 = ioctl(VAR_5->control, VHOST_SET_MEM_TABLE, VAR_5->mem);",
"assert(VAR_7 >= 0);",
"return;",
"}",
"log_size = vhost_get_log_size(VAR_5);",
"#define VHOST_LOG_BUFFER (0x1000 / sizeof *VAR_5->log)\nif (VAR_5->log_size < log_size) {",
"vhost_dev_log_resize(VAR_5, log_size + VHOST_LOG_BUFFER);",
"}",
"VAR_7 = ioctl(VAR_5->control, VHOST_SET_MEM_TABLE, VAR_5->mem);",
"assert(VAR_7 >= 0);",
"if (VAR_5->log_size > log_size + VHOST_LOG_BUFFER) {",
"vhost_dev_log_resize(VAR_5, log_size);",
"}",
"}"
]
| [
1,
1,
1,
0,
0,
0,
0,
0,
1,
0,
0,
1,
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
]
| [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15
],
[
17,
19
],
[
21
],
[
23
],
[
27
],
[
31
],
[
33
],
[
35
],
[
39
],
[
45
],
[
47,
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
77,
79
],
[
81
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
125,
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
]
]
|
13,634 | static int quant_psnr8x8_c(MpegEncContext *s, uint8_t *src1,
uint8_t *src2, ptrdiff_t stride, int h)
{
LOCAL_ALIGNED_16(int16_t, temp, [64 * 2]);
int16_t *const bak = temp + 64;
int sum = 0, i;
av_assert2(h == 8);
s->mb_intra = 0;
s->pdsp.diff_pixels(temp, src1, src2, stride);
memcpy(bak, temp, 64 * sizeof(int16_t));
s->block_last_index[0 /* FIXME */] =
s->fast_dct_quantize(s, temp, 0 /* FIXME */, s->qscale, &i);
s->dct_unquantize_inter(s, temp, 0, s->qscale);
ff_simple_idct_8(temp); // FIXME
for (i = 0; i < 64; i++)
sum += (temp[i] - bak[i]) * (temp[i] - bak[i]);
return sum;
}
| true | FFmpeg | bc488ec28aec4bc91ba47283c49c9f7f25696eaa | static int quant_psnr8x8_c(MpegEncContext *s, uint8_t *src1,
uint8_t *src2, ptrdiff_t stride, int h)
{
LOCAL_ALIGNED_16(int16_t, temp, [64 * 2]);
int16_t *const bak = temp + 64;
int sum = 0, i;
av_assert2(h == 8);
s->mb_intra = 0;
s->pdsp.diff_pixels(temp, src1, src2, stride);
memcpy(bak, temp, 64 * sizeof(int16_t));
s->block_last_index[0 ] =
s->fast_dct_quantize(s, temp, 0 , s->qscale, &i);
s->dct_unquantize_inter(s, temp, 0, s->qscale);
ff_simple_idct_8(temp);
for (i = 0; i < 64; i++)
sum += (temp[i] - bak[i]) * (temp[i] - bak[i]);
return sum;
}
| {
"code": [
" s->pdsp.diff_pixels(temp, src1, src2, stride);",
" s->pdsp.diff_pixels(temp, src1, src2, stride);",
" s->pdsp.diff_pixels(temp, src1, src2, stride);",
" s->pdsp.diff_pixels(temp, src1, src2, stride);"
],
"line_no": [
21,
21,
21,
21
]
} | static int FUNC_0(MpegEncContext *VAR_0, uint8_t *VAR_1,
uint8_t *VAR_2, ptrdiff_t VAR_3, int VAR_4)
{
LOCAL_ALIGNED_16(int16_t, temp, [64 * 2]);
int16_t *const bak = temp + 64;
int VAR_5 = 0, VAR_6;
av_assert2(VAR_4 == 8);
VAR_0->mb_intra = 0;
VAR_0->pdsp.diff_pixels(temp, VAR_1, VAR_2, VAR_3);
memcpy(bak, temp, 64 * sizeof(int16_t));
VAR_0->block_last_index[0 ] =
VAR_0->fast_dct_quantize(VAR_0, temp, 0 , VAR_0->qscale, &VAR_6);
VAR_0->dct_unquantize_inter(VAR_0, temp, 0, VAR_0->qscale);
ff_simple_idct_8(temp);
for (VAR_6 = 0; VAR_6 < 64; VAR_6++)
VAR_5 += (temp[VAR_6] - bak[VAR_6]) * (temp[VAR_6] - bak[VAR_6]);
return VAR_5;
}
| [
"static int FUNC_0(MpegEncContext *VAR_0, uint8_t *VAR_1,\nuint8_t *VAR_2, ptrdiff_t VAR_3, int VAR_4)\n{",
"LOCAL_ALIGNED_16(int16_t, temp, [64 * 2]);",
"int16_t *const bak = temp + 64;",
"int VAR_5 = 0, VAR_6;",
"av_assert2(VAR_4 == 8);",
"VAR_0->mb_intra = 0;",
"VAR_0->pdsp.diff_pixels(temp, VAR_1, VAR_2, VAR_3);",
"memcpy(bak, temp, 64 * sizeof(int16_t));",
"VAR_0->block_last_index[0 ] =\nVAR_0->fast_dct_quantize(VAR_0, temp, 0 , VAR_0->qscale, &VAR_6);",
"VAR_0->dct_unquantize_inter(VAR_0, temp, 0, VAR_0->qscale);",
"ff_simple_idct_8(temp);",
"for (VAR_6 = 0; VAR_6 < 64; VAR_6++)",
"VAR_5 += (temp[VAR_6] - bak[VAR_6]) * (temp[VAR_6] - bak[VAR_6]);",
"return VAR_5;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
25
],
[
29,
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
45
],
[
47
]
]
|
13,637 | static int vhdx_parse_metadata(BlockDriverState *bs, BDRVVHDXState *s)
{
int ret = 0;
uint8_t *buffer;
int offset = 0;
uint32_t i = 0;
VHDXMetadataTableEntry md_entry;
buffer = qemu_blockalign(bs, VHDX_METADATA_TABLE_MAX_SIZE);
ret = bdrv_pread(bs->file, s->metadata_rt.file_offset, buffer,
VHDX_METADATA_TABLE_MAX_SIZE);
if (ret < 0) {
goto exit;
}
memcpy(&s->metadata_hdr, buffer, sizeof(s->metadata_hdr));
offset += sizeof(s->metadata_hdr);
vhdx_metadata_header_le_import(&s->metadata_hdr);
if (memcmp(&s->metadata_hdr.signature, "metadata", 8)) {
ret = -EINVAL;
goto exit;
}
s->metadata_entries.present = 0;
if ((s->metadata_hdr.entry_count * sizeof(md_entry)) >
(VHDX_METADATA_TABLE_MAX_SIZE - offset)) {
ret = -EINVAL;
goto exit;
}
for (i = 0; i < s->metadata_hdr.entry_count; i++) {
memcpy(&md_entry, buffer + offset, sizeof(md_entry));
offset += sizeof(md_entry);
vhdx_metadata_entry_le_import(&md_entry);
if (guid_eq(md_entry.item_id, file_param_guid)) {
if (s->metadata_entries.present & META_FILE_PARAMETER_PRESENT) {
ret = -EINVAL;
goto exit;
}
s->metadata_entries.file_parameters_entry = md_entry;
s->metadata_entries.present |= META_FILE_PARAMETER_PRESENT;
continue;
}
if (guid_eq(md_entry.item_id, virtual_size_guid)) {
if (s->metadata_entries.present & META_VIRTUAL_DISK_SIZE_PRESENT) {
ret = -EINVAL;
goto exit;
}
s->metadata_entries.virtual_disk_size_entry = md_entry;
s->metadata_entries.present |= META_VIRTUAL_DISK_SIZE_PRESENT;
continue;
}
if (guid_eq(md_entry.item_id, page83_guid)) {
if (s->metadata_entries.present & META_PAGE_83_PRESENT) {
ret = -EINVAL;
goto exit;
}
s->metadata_entries.page83_data_entry = md_entry;
s->metadata_entries.present |= META_PAGE_83_PRESENT;
continue;
}
if (guid_eq(md_entry.item_id, logical_sector_guid)) {
if (s->metadata_entries.present &
META_LOGICAL_SECTOR_SIZE_PRESENT) {
ret = -EINVAL;
goto exit;
}
s->metadata_entries.logical_sector_size_entry = md_entry;
s->metadata_entries.present |= META_LOGICAL_SECTOR_SIZE_PRESENT;
continue;
}
if (guid_eq(md_entry.item_id, phys_sector_guid)) {
if (s->metadata_entries.present & META_PHYS_SECTOR_SIZE_PRESENT) {
ret = -EINVAL;
goto exit;
}
s->metadata_entries.phys_sector_size_entry = md_entry;
s->metadata_entries.present |= META_PHYS_SECTOR_SIZE_PRESENT;
continue;
}
if (guid_eq(md_entry.item_id, parent_locator_guid)) {
if (s->metadata_entries.present & META_PARENT_LOCATOR_PRESENT) {
ret = -EINVAL;
goto exit;
}
s->metadata_entries.parent_locator_entry = md_entry;
s->metadata_entries.present |= META_PARENT_LOCATOR_PRESENT;
continue;
}
if (md_entry.data_bits & VHDX_META_FLAGS_IS_REQUIRED) {
/* cannot read vhdx file - required region table entry that
* we do not understand. per spec, we must fail to open */
ret = -ENOTSUP;
goto exit;
}
}
if (s->metadata_entries.present != META_ALL_PRESENT) {
ret = -ENOTSUP;
goto exit;
}
ret = bdrv_pread(bs->file,
s->metadata_entries.file_parameters_entry.offset
+ s->metadata_rt.file_offset,
&s->params,
sizeof(s->params));
if (ret < 0) {
goto exit;
}
le32_to_cpus(&s->params.block_size);
le32_to_cpus(&s->params.data_bits);
/* We now have the file parameters, so we can tell if this is a
* differencing file (i.e.. has_parent), is dynamic or fixed
* sized (leave_blocks_allocated), and the block size */
/* The parent locator required iff the file parameters has_parent set */
if (s->params.data_bits & VHDX_PARAMS_HAS_PARENT) {
if (s->metadata_entries.present & META_PARENT_LOCATOR_PRESENT) {
/* TODO: parse parent locator fields */
ret = -ENOTSUP; /* temp, until differencing files are supported */
goto exit;
} else {
/* if has_parent is set, but there is not parent locator present,
* then that is an invalid combination */
ret = -EINVAL;
goto exit;
}
}
/* determine virtual disk size, logical sector size,
* and phys sector size */
ret = bdrv_pread(bs->file,
s->metadata_entries.virtual_disk_size_entry.offset
+ s->metadata_rt.file_offset,
&s->virtual_disk_size,
sizeof(uint64_t));
if (ret < 0) {
goto exit;
}
ret = bdrv_pread(bs->file,
s->metadata_entries.logical_sector_size_entry.offset
+ s->metadata_rt.file_offset,
&s->logical_sector_size,
sizeof(uint32_t));
if (ret < 0) {
goto exit;
}
ret = bdrv_pread(bs->file,
s->metadata_entries.phys_sector_size_entry.offset
+ s->metadata_rt.file_offset,
&s->physical_sector_size,
sizeof(uint32_t));
if (ret < 0) {
goto exit;
}
le64_to_cpus(&s->virtual_disk_size);
le32_to_cpus(&s->logical_sector_size);
le32_to_cpus(&s->physical_sector_size);
if (s->logical_sector_size == 0 || s->params.block_size == 0) {
ret = -EINVAL;
goto exit;
}
/* both block_size and sector_size are guaranteed powers of 2 */
s->sectors_per_block = s->params.block_size / s->logical_sector_size;
s->chunk_ratio = (VHDX_MAX_SECTORS_PER_BLOCK) *
(uint64_t)s->logical_sector_size /
(uint64_t)s->params.block_size;
/* These values are ones we will want to use for division / multiplication
* later on, and they are all guaranteed (per the spec) to be powers of 2,
* so we can take advantage of that for shift operations during
* reads/writes */
if (s->logical_sector_size & (s->logical_sector_size - 1)) {
ret = -EINVAL;
goto exit;
}
if (s->sectors_per_block & (s->sectors_per_block - 1)) {
ret = -EINVAL;
goto exit;
}
if (s->chunk_ratio & (s->chunk_ratio - 1)) {
ret = -EINVAL;
goto exit;
}
s->block_size = s->params.block_size;
if (s->block_size & (s->block_size - 1)) {
ret = -EINVAL;
goto exit;
}
vhdx_set_shift_bits(s);
ret = 0;
exit:
qemu_vfree(buffer);
return ret;
}
| true | qemu | 1d7678dec4761acdc43439da6ceda41a703ba1a6 | static int vhdx_parse_metadata(BlockDriverState *bs, BDRVVHDXState *s)
{
int ret = 0;
uint8_t *buffer;
int offset = 0;
uint32_t i = 0;
VHDXMetadataTableEntry md_entry;
buffer = qemu_blockalign(bs, VHDX_METADATA_TABLE_MAX_SIZE);
ret = bdrv_pread(bs->file, s->metadata_rt.file_offset, buffer,
VHDX_METADATA_TABLE_MAX_SIZE);
if (ret < 0) {
goto exit;
}
memcpy(&s->metadata_hdr, buffer, sizeof(s->metadata_hdr));
offset += sizeof(s->metadata_hdr);
vhdx_metadata_header_le_import(&s->metadata_hdr);
if (memcmp(&s->metadata_hdr.signature, "metadata", 8)) {
ret = -EINVAL;
goto exit;
}
s->metadata_entries.present = 0;
if ((s->metadata_hdr.entry_count * sizeof(md_entry)) >
(VHDX_METADATA_TABLE_MAX_SIZE - offset)) {
ret = -EINVAL;
goto exit;
}
for (i = 0; i < s->metadata_hdr.entry_count; i++) {
memcpy(&md_entry, buffer + offset, sizeof(md_entry));
offset += sizeof(md_entry);
vhdx_metadata_entry_le_import(&md_entry);
if (guid_eq(md_entry.item_id, file_param_guid)) {
if (s->metadata_entries.present & META_FILE_PARAMETER_PRESENT) {
ret = -EINVAL;
goto exit;
}
s->metadata_entries.file_parameters_entry = md_entry;
s->metadata_entries.present |= META_FILE_PARAMETER_PRESENT;
continue;
}
if (guid_eq(md_entry.item_id, virtual_size_guid)) {
if (s->metadata_entries.present & META_VIRTUAL_DISK_SIZE_PRESENT) {
ret = -EINVAL;
goto exit;
}
s->metadata_entries.virtual_disk_size_entry = md_entry;
s->metadata_entries.present |= META_VIRTUAL_DISK_SIZE_PRESENT;
continue;
}
if (guid_eq(md_entry.item_id, page83_guid)) {
if (s->metadata_entries.present & META_PAGE_83_PRESENT) {
ret = -EINVAL;
goto exit;
}
s->metadata_entries.page83_data_entry = md_entry;
s->metadata_entries.present |= META_PAGE_83_PRESENT;
continue;
}
if (guid_eq(md_entry.item_id, logical_sector_guid)) {
if (s->metadata_entries.present &
META_LOGICAL_SECTOR_SIZE_PRESENT) {
ret = -EINVAL;
goto exit;
}
s->metadata_entries.logical_sector_size_entry = md_entry;
s->metadata_entries.present |= META_LOGICAL_SECTOR_SIZE_PRESENT;
continue;
}
if (guid_eq(md_entry.item_id, phys_sector_guid)) {
if (s->metadata_entries.present & META_PHYS_SECTOR_SIZE_PRESENT) {
ret = -EINVAL;
goto exit;
}
s->metadata_entries.phys_sector_size_entry = md_entry;
s->metadata_entries.present |= META_PHYS_SECTOR_SIZE_PRESENT;
continue;
}
if (guid_eq(md_entry.item_id, parent_locator_guid)) {
if (s->metadata_entries.present & META_PARENT_LOCATOR_PRESENT) {
ret = -EINVAL;
goto exit;
}
s->metadata_entries.parent_locator_entry = md_entry;
s->metadata_entries.present |= META_PARENT_LOCATOR_PRESENT;
continue;
}
if (md_entry.data_bits & VHDX_META_FLAGS_IS_REQUIRED) {
ret = -ENOTSUP;
goto exit;
}
}
if (s->metadata_entries.present != META_ALL_PRESENT) {
ret = -ENOTSUP;
goto exit;
}
ret = bdrv_pread(bs->file,
s->metadata_entries.file_parameters_entry.offset
+ s->metadata_rt.file_offset,
&s->params,
sizeof(s->params));
if (ret < 0) {
goto exit;
}
le32_to_cpus(&s->params.block_size);
le32_to_cpus(&s->params.data_bits);
if (s->params.data_bits & VHDX_PARAMS_HAS_PARENT) {
if (s->metadata_entries.present & META_PARENT_LOCATOR_PRESENT) {
ret = -ENOTSUP;
goto exit;
} else {
ret = -EINVAL;
goto exit;
}
}
ret = bdrv_pread(bs->file,
s->metadata_entries.virtual_disk_size_entry.offset
+ s->metadata_rt.file_offset,
&s->virtual_disk_size,
sizeof(uint64_t));
if (ret < 0) {
goto exit;
}
ret = bdrv_pread(bs->file,
s->metadata_entries.logical_sector_size_entry.offset
+ s->metadata_rt.file_offset,
&s->logical_sector_size,
sizeof(uint32_t));
if (ret < 0) {
goto exit;
}
ret = bdrv_pread(bs->file,
s->metadata_entries.phys_sector_size_entry.offset
+ s->metadata_rt.file_offset,
&s->physical_sector_size,
sizeof(uint32_t));
if (ret < 0) {
goto exit;
}
le64_to_cpus(&s->virtual_disk_size);
le32_to_cpus(&s->logical_sector_size);
le32_to_cpus(&s->physical_sector_size);
if (s->logical_sector_size == 0 || s->params.block_size == 0) {
ret = -EINVAL;
goto exit;
}
s->sectors_per_block = s->params.block_size / s->logical_sector_size;
s->chunk_ratio = (VHDX_MAX_SECTORS_PER_BLOCK) *
(uint64_t)s->logical_sector_size /
(uint64_t)s->params.block_size;
if (s->logical_sector_size & (s->logical_sector_size - 1)) {
ret = -EINVAL;
goto exit;
}
if (s->sectors_per_block & (s->sectors_per_block - 1)) {
ret = -EINVAL;
goto exit;
}
if (s->chunk_ratio & (s->chunk_ratio - 1)) {
ret = -EINVAL;
goto exit;
}
s->block_size = s->params.block_size;
if (s->block_size & (s->block_size - 1)) {
ret = -EINVAL;
goto exit;
}
vhdx_set_shift_bits(s);
ret = 0;
exit:
qemu_vfree(buffer);
return ret;
}
| {
"code": [
" if (s->logical_sector_size == 0 || s->params.block_size == 0) {"
],
"line_no": [
355
]
} | static int FUNC_0(BlockDriverState *VAR_0, BDRVVHDXState *VAR_1)
{
int VAR_2 = 0;
uint8_t *buffer;
int VAR_3 = 0;
uint32_t i = 0;
VHDXMetadataTableEntry md_entry;
buffer = qemu_blockalign(VAR_0, VHDX_METADATA_TABLE_MAX_SIZE);
VAR_2 = bdrv_pread(VAR_0->file, VAR_1->metadata_rt.file_offset, buffer,
VHDX_METADATA_TABLE_MAX_SIZE);
if (VAR_2 < 0) {
goto exit;
}
memcpy(&VAR_1->metadata_hdr, buffer, sizeof(VAR_1->metadata_hdr));
VAR_3 += sizeof(VAR_1->metadata_hdr);
vhdx_metadata_header_le_import(&VAR_1->metadata_hdr);
if (memcmp(&VAR_1->metadata_hdr.signature, "metadata", 8)) {
VAR_2 = -EINVAL;
goto exit;
}
VAR_1->metadata_entries.present = 0;
if ((VAR_1->metadata_hdr.entry_count * sizeof(md_entry)) >
(VHDX_METADATA_TABLE_MAX_SIZE - VAR_3)) {
VAR_2 = -EINVAL;
goto exit;
}
for (i = 0; i < VAR_1->metadata_hdr.entry_count; i++) {
memcpy(&md_entry, buffer + VAR_3, sizeof(md_entry));
VAR_3 += sizeof(md_entry);
vhdx_metadata_entry_le_import(&md_entry);
if (guid_eq(md_entry.item_id, file_param_guid)) {
if (VAR_1->metadata_entries.present & META_FILE_PARAMETER_PRESENT) {
VAR_2 = -EINVAL;
goto exit;
}
VAR_1->metadata_entries.file_parameters_entry = md_entry;
VAR_1->metadata_entries.present |= META_FILE_PARAMETER_PRESENT;
continue;
}
if (guid_eq(md_entry.item_id, virtual_size_guid)) {
if (VAR_1->metadata_entries.present & META_VIRTUAL_DISK_SIZE_PRESENT) {
VAR_2 = -EINVAL;
goto exit;
}
VAR_1->metadata_entries.virtual_disk_size_entry = md_entry;
VAR_1->metadata_entries.present |= META_VIRTUAL_DISK_SIZE_PRESENT;
continue;
}
if (guid_eq(md_entry.item_id, page83_guid)) {
if (VAR_1->metadata_entries.present & META_PAGE_83_PRESENT) {
VAR_2 = -EINVAL;
goto exit;
}
VAR_1->metadata_entries.page83_data_entry = md_entry;
VAR_1->metadata_entries.present |= META_PAGE_83_PRESENT;
continue;
}
if (guid_eq(md_entry.item_id, logical_sector_guid)) {
if (VAR_1->metadata_entries.present &
META_LOGICAL_SECTOR_SIZE_PRESENT) {
VAR_2 = -EINVAL;
goto exit;
}
VAR_1->metadata_entries.logical_sector_size_entry = md_entry;
VAR_1->metadata_entries.present |= META_LOGICAL_SECTOR_SIZE_PRESENT;
continue;
}
if (guid_eq(md_entry.item_id, phys_sector_guid)) {
if (VAR_1->metadata_entries.present & META_PHYS_SECTOR_SIZE_PRESENT) {
VAR_2 = -EINVAL;
goto exit;
}
VAR_1->metadata_entries.phys_sector_size_entry = md_entry;
VAR_1->metadata_entries.present |= META_PHYS_SECTOR_SIZE_PRESENT;
continue;
}
if (guid_eq(md_entry.item_id, parent_locator_guid)) {
if (VAR_1->metadata_entries.present & META_PARENT_LOCATOR_PRESENT) {
VAR_2 = -EINVAL;
goto exit;
}
VAR_1->metadata_entries.parent_locator_entry = md_entry;
VAR_1->metadata_entries.present |= META_PARENT_LOCATOR_PRESENT;
continue;
}
if (md_entry.data_bits & VHDX_META_FLAGS_IS_REQUIRED) {
VAR_2 = -ENOTSUP;
goto exit;
}
}
if (VAR_1->metadata_entries.present != META_ALL_PRESENT) {
VAR_2 = -ENOTSUP;
goto exit;
}
VAR_2 = bdrv_pread(VAR_0->file,
VAR_1->metadata_entries.file_parameters_entry.VAR_3
+ VAR_1->metadata_rt.file_offset,
&VAR_1->params,
sizeof(VAR_1->params));
if (VAR_2 < 0) {
goto exit;
}
le32_to_cpus(&VAR_1->params.block_size);
le32_to_cpus(&VAR_1->params.data_bits);
if (VAR_1->params.data_bits & VHDX_PARAMS_HAS_PARENT) {
if (VAR_1->metadata_entries.present & META_PARENT_LOCATOR_PRESENT) {
VAR_2 = -ENOTSUP;
goto exit;
} else {
VAR_2 = -EINVAL;
goto exit;
}
}
VAR_2 = bdrv_pread(VAR_0->file,
VAR_1->metadata_entries.virtual_disk_size_entry.VAR_3
+ VAR_1->metadata_rt.file_offset,
&VAR_1->virtual_disk_size,
sizeof(uint64_t));
if (VAR_2 < 0) {
goto exit;
}
VAR_2 = bdrv_pread(VAR_0->file,
VAR_1->metadata_entries.logical_sector_size_entry.VAR_3
+ VAR_1->metadata_rt.file_offset,
&VAR_1->logical_sector_size,
sizeof(uint32_t));
if (VAR_2 < 0) {
goto exit;
}
VAR_2 = bdrv_pread(VAR_0->file,
VAR_1->metadata_entries.phys_sector_size_entry.VAR_3
+ VAR_1->metadata_rt.file_offset,
&VAR_1->physical_sector_size,
sizeof(uint32_t));
if (VAR_2 < 0) {
goto exit;
}
le64_to_cpus(&VAR_1->virtual_disk_size);
le32_to_cpus(&VAR_1->logical_sector_size);
le32_to_cpus(&VAR_1->physical_sector_size);
if (VAR_1->logical_sector_size == 0 || VAR_1->params.block_size == 0) {
VAR_2 = -EINVAL;
goto exit;
}
VAR_1->sectors_per_block = VAR_1->params.block_size / VAR_1->logical_sector_size;
VAR_1->chunk_ratio = (VHDX_MAX_SECTORS_PER_BLOCK) *
(uint64_t)VAR_1->logical_sector_size /
(uint64_t)VAR_1->params.block_size;
if (VAR_1->logical_sector_size & (VAR_1->logical_sector_size - 1)) {
VAR_2 = -EINVAL;
goto exit;
}
if (VAR_1->sectors_per_block & (VAR_1->sectors_per_block - 1)) {
VAR_2 = -EINVAL;
goto exit;
}
if (VAR_1->chunk_ratio & (VAR_1->chunk_ratio - 1)) {
VAR_2 = -EINVAL;
goto exit;
}
VAR_1->block_size = VAR_1->params.block_size;
if (VAR_1->block_size & (VAR_1->block_size - 1)) {
VAR_2 = -EINVAL;
goto exit;
}
vhdx_set_shift_bits(VAR_1);
VAR_2 = 0;
exit:
qemu_vfree(buffer);
return VAR_2;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, BDRVVHDXState *VAR_1)\n{",
"int VAR_2 = 0;",
"uint8_t *buffer;",
"int VAR_3 = 0;",
"uint32_t i = 0;",
"VHDXMetadataTableEntry md_entry;",
"buffer = qemu_blockalign(VAR_0, VHDX_METADATA_TABLE_MAX_SIZE);",
"VAR_2 = bdrv_pread(VAR_0->file, VAR_1->metadata_rt.file_offset, buffer,\nVHDX_METADATA_TABLE_MAX_SIZE);",
"if (VAR_2 < 0) {",
"goto exit;",
"}",
"memcpy(&VAR_1->metadata_hdr, buffer, sizeof(VAR_1->metadata_hdr));",
"VAR_3 += sizeof(VAR_1->metadata_hdr);",
"vhdx_metadata_header_le_import(&VAR_1->metadata_hdr);",
"if (memcmp(&VAR_1->metadata_hdr.signature, \"metadata\", 8)) {",
"VAR_2 = -EINVAL;",
"goto exit;",
"}",
"VAR_1->metadata_entries.present = 0;",
"if ((VAR_1->metadata_hdr.entry_count * sizeof(md_entry)) >\n(VHDX_METADATA_TABLE_MAX_SIZE - VAR_3)) {",
"VAR_2 = -EINVAL;",
"goto exit;",
"}",
"for (i = 0; i < VAR_1->metadata_hdr.entry_count; i++) {",
"memcpy(&md_entry, buffer + VAR_3, sizeof(md_entry));",
"VAR_3 += sizeof(md_entry);",
"vhdx_metadata_entry_le_import(&md_entry);",
"if (guid_eq(md_entry.item_id, file_param_guid)) {",
"if (VAR_1->metadata_entries.present & META_FILE_PARAMETER_PRESENT) {",
"VAR_2 = -EINVAL;",
"goto exit;",
"}",
"VAR_1->metadata_entries.file_parameters_entry = md_entry;",
"VAR_1->metadata_entries.present |= META_FILE_PARAMETER_PRESENT;",
"continue;",
"}",
"if (guid_eq(md_entry.item_id, virtual_size_guid)) {",
"if (VAR_1->metadata_entries.present & META_VIRTUAL_DISK_SIZE_PRESENT) {",
"VAR_2 = -EINVAL;",
"goto exit;",
"}",
"VAR_1->metadata_entries.virtual_disk_size_entry = md_entry;",
"VAR_1->metadata_entries.present |= META_VIRTUAL_DISK_SIZE_PRESENT;",
"continue;",
"}",
"if (guid_eq(md_entry.item_id, page83_guid)) {",
"if (VAR_1->metadata_entries.present & META_PAGE_83_PRESENT) {",
"VAR_2 = -EINVAL;",
"goto exit;",
"}",
"VAR_1->metadata_entries.page83_data_entry = md_entry;",
"VAR_1->metadata_entries.present |= META_PAGE_83_PRESENT;",
"continue;",
"}",
"if (guid_eq(md_entry.item_id, logical_sector_guid)) {",
"if (VAR_1->metadata_entries.present &\nMETA_LOGICAL_SECTOR_SIZE_PRESENT) {",
"VAR_2 = -EINVAL;",
"goto exit;",
"}",
"VAR_1->metadata_entries.logical_sector_size_entry = md_entry;",
"VAR_1->metadata_entries.present |= META_LOGICAL_SECTOR_SIZE_PRESENT;",
"continue;",
"}",
"if (guid_eq(md_entry.item_id, phys_sector_guid)) {",
"if (VAR_1->metadata_entries.present & META_PHYS_SECTOR_SIZE_PRESENT) {",
"VAR_2 = -EINVAL;",
"goto exit;",
"}",
"VAR_1->metadata_entries.phys_sector_size_entry = md_entry;",
"VAR_1->metadata_entries.present |= META_PHYS_SECTOR_SIZE_PRESENT;",
"continue;",
"}",
"if (guid_eq(md_entry.item_id, parent_locator_guid)) {",
"if (VAR_1->metadata_entries.present & META_PARENT_LOCATOR_PRESENT) {",
"VAR_2 = -EINVAL;",
"goto exit;",
"}",
"VAR_1->metadata_entries.parent_locator_entry = md_entry;",
"VAR_1->metadata_entries.present |= META_PARENT_LOCATOR_PRESENT;",
"continue;",
"}",
"if (md_entry.data_bits & VHDX_META_FLAGS_IS_REQUIRED) {",
"VAR_2 = -ENOTSUP;",
"goto exit;",
"}",
"}",
"if (VAR_1->metadata_entries.present != META_ALL_PRESENT) {",
"VAR_2 = -ENOTSUP;",
"goto exit;",
"}",
"VAR_2 = bdrv_pread(VAR_0->file,\nVAR_1->metadata_entries.file_parameters_entry.VAR_3\n+ VAR_1->metadata_rt.file_offset,\n&VAR_1->params,\nsizeof(VAR_1->params));",
"if (VAR_2 < 0) {",
"goto exit;",
"}",
"le32_to_cpus(&VAR_1->params.block_size);",
"le32_to_cpus(&VAR_1->params.data_bits);",
"if (VAR_1->params.data_bits & VHDX_PARAMS_HAS_PARENT) {",
"if (VAR_1->metadata_entries.present & META_PARENT_LOCATOR_PRESENT) {",
"VAR_2 = -ENOTSUP;",
"goto exit;",
"} else {",
"VAR_2 = -EINVAL;",
"goto exit;",
"}",
"}",
"VAR_2 = bdrv_pread(VAR_0->file,\nVAR_1->metadata_entries.virtual_disk_size_entry.VAR_3\n+ VAR_1->metadata_rt.file_offset,\n&VAR_1->virtual_disk_size,\nsizeof(uint64_t));",
"if (VAR_2 < 0) {",
"goto exit;",
"}",
"VAR_2 = bdrv_pread(VAR_0->file,\nVAR_1->metadata_entries.logical_sector_size_entry.VAR_3\n+ VAR_1->metadata_rt.file_offset,\n&VAR_1->logical_sector_size,\nsizeof(uint32_t));",
"if (VAR_2 < 0) {",
"goto exit;",
"}",
"VAR_2 = bdrv_pread(VAR_0->file,\nVAR_1->metadata_entries.phys_sector_size_entry.VAR_3\n+ VAR_1->metadata_rt.file_offset,\n&VAR_1->physical_sector_size,\nsizeof(uint32_t));",
"if (VAR_2 < 0) {",
"goto exit;",
"}",
"le64_to_cpus(&VAR_1->virtual_disk_size);",
"le32_to_cpus(&VAR_1->logical_sector_size);",
"le32_to_cpus(&VAR_1->physical_sector_size);",
"if (VAR_1->logical_sector_size == 0 || VAR_1->params.block_size == 0) {",
"VAR_2 = -EINVAL;",
"goto exit;",
"}",
"VAR_1->sectors_per_block = VAR_1->params.block_size / VAR_1->logical_sector_size;",
"VAR_1->chunk_ratio = (VHDX_MAX_SECTORS_PER_BLOCK) *\n(uint64_t)VAR_1->logical_sector_size /\n(uint64_t)VAR_1->params.block_size;",
"if (VAR_1->logical_sector_size & (VAR_1->logical_sector_size - 1)) {",
"VAR_2 = -EINVAL;",
"goto exit;",
"}",
"if (VAR_1->sectors_per_block & (VAR_1->sectors_per_block - 1)) {",
"VAR_2 = -EINVAL;",
"goto exit;",
"}",
"if (VAR_1->chunk_ratio & (VAR_1->chunk_ratio - 1)) {",
"VAR_2 = -EINVAL;",
"goto exit;",
"}",
"VAR_1->block_size = VAR_1->params.block_size;",
"if (VAR_1->block_size & (VAR_1->block_size - 1)) {",
"VAR_2 = -EINVAL;",
"goto exit;",
"}",
"vhdx_set_shift_bits(VAR_1);",
"VAR_2 = 0;",
"exit:\nqemu_vfree(buffer);",
"return VAR_2;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
139
],
[
141,
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
201
],
[
207
],
[
209
],
[
211
],
[
213
],
[
217
],
[
219
],
[
221
],
[
223
],
[
227,
229,
231,
233,
235
],
[
239
],
[
241
],
[
243
],
[
247
],
[
249
],
[
265
],
[
267
],
[
271
],
[
273
],
[
275
],
[
281
],
[
283
],
[
285
],
[
287
],
[
297,
299,
301,
303,
305
],
[
307
],
[
309
],
[
311
],
[
313,
315,
317,
319,
321
],
[
323
],
[
325
],
[
327
],
[
329,
331,
333,
335,
337
],
[
339
],
[
341
],
[
343
],
[
347
],
[
349
],
[
351
],
[
355
],
[
357
],
[
359
],
[
361
],
[
367
],
[
369,
371,
373
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
421
],
[
425
],
[
429,
431
],
[
433
],
[
435
]
]
|
13,638 | void virtio_scsi_handle_cmd_vq(VirtIOSCSI *s, VirtQueue *vq)
{
VirtIOSCSIReq *req, *next;
QTAILQ_HEAD(, VirtIOSCSIReq) reqs = QTAILQ_HEAD_INITIALIZER(reqs);
while ((req = virtio_scsi_pop_req(s, vq))) {
if (virtio_scsi_handle_cmd_req_prepare(s, req)) {
QTAILQ_INSERT_TAIL(&reqs, req, next);
}
}
QTAILQ_FOREACH_SAFE(req, &reqs, next, next) {
virtio_scsi_handle_cmd_req_submit(s, req);
}
}
| true | qemu | 661e32fb3cb71c7e019daee375be4bb487b9917c | void virtio_scsi_handle_cmd_vq(VirtIOSCSI *s, VirtQueue *vq)
{
VirtIOSCSIReq *req, *next;
QTAILQ_HEAD(, VirtIOSCSIReq) reqs = QTAILQ_HEAD_INITIALIZER(reqs);
while ((req = virtio_scsi_pop_req(s, vq))) {
if (virtio_scsi_handle_cmd_req_prepare(s, req)) {
QTAILQ_INSERT_TAIL(&reqs, req, next);
}
}
QTAILQ_FOREACH_SAFE(req, &reqs, next, next) {
virtio_scsi_handle_cmd_req_submit(s, req);
}
}
| {
"code": [
" if (virtio_scsi_handle_cmd_req_prepare(s, req)) {"
],
"line_no": [
13
]
} | void FUNC_0(VirtIOSCSI *VAR_0, VirtQueue *VAR_1)
{
VirtIOSCSIReq *req, *next;
QTAILQ_HEAD(, VirtIOSCSIReq) reqs = QTAILQ_HEAD_INITIALIZER(reqs);
while ((req = virtio_scsi_pop_req(VAR_0, VAR_1))) {
if (virtio_scsi_handle_cmd_req_prepare(VAR_0, req)) {
QTAILQ_INSERT_TAIL(&reqs, req, next);
}
}
QTAILQ_FOREACH_SAFE(req, &reqs, next, next) {
virtio_scsi_handle_cmd_req_submit(VAR_0, req);
}
}
| [
"void FUNC_0(VirtIOSCSI *VAR_0, VirtQueue *VAR_1)\n{",
"VirtIOSCSIReq *req, *next;",
"QTAILQ_HEAD(, VirtIOSCSIReq) reqs = QTAILQ_HEAD_INITIALIZER(reqs);",
"while ((req = virtio_scsi_pop_req(VAR_0, VAR_1))) {",
"if (virtio_scsi_handle_cmd_req_prepare(VAR_0, req)) {",
"QTAILQ_INSERT_TAIL(&reqs, req, next);",
"}",
"}",
"QTAILQ_FOREACH_SAFE(req, &reqs, next, next) {",
"virtio_scsi_handle_cmd_req_submit(VAR_0, req);",
"}",
"}"
]
| [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
]
]
|
13,639 | static void mch_realize(PCIDevice *d, Error **errp)
{
int i;
MCHPCIState *mch = MCH_PCI_DEVICE(d);
/* setup pci memory mapping */
pc_pci_as_mapping_init(OBJECT(mch), mch->system_memory,
mch->pci_address_space);
/* smram */
cpu_smm_register(&mch_set_smm, mch);
memory_region_init_alias(&mch->smram_region, OBJECT(mch), "smram-region",
mch->pci_address_space, 0xa0000, 0x20000);
memory_region_add_subregion_overlap(mch->system_memory, 0xa0000,
&mch->smram_region, 1);
memory_region_set_enabled(&mch->smram_region, false);
init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory,
mch->pci_address_space, &mch->pam_regions[0],
PAM_BIOS_BASE, PAM_BIOS_SIZE);
for (i = 0; i < 12; ++i) {
init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory,
mch->pci_address_space, &mch->pam_regions[i+1],
PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE);
}
/* Intel IOMMU (VT-d) */
if (qemu_opt_get_bool(qemu_get_machine_opts(), "iommu", false)) {
mch_init_dmar(mch);
}
}
| true | qemu | 8caff63699a9bd6b82556bd527ff023c443ada2d | static void mch_realize(PCIDevice *d, Error **errp)
{
int i;
MCHPCIState *mch = MCH_PCI_DEVICE(d);
pc_pci_as_mapping_init(OBJECT(mch), mch->system_memory,
mch->pci_address_space);
cpu_smm_register(&mch_set_smm, mch);
memory_region_init_alias(&mch->smram_region, OBJECT(mch), "smram-region",
mch->pci_address_space, 0xa0000, 0x20000);
memory_region_add_subregion_overlap(mch->system_memory, 0xa0000,
&mch->smram_region, 1);
memory_region_set_enabled(&mch->smram_region, false);
init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory,
mch->pci_address_space, &mch->pam_regions[0],
PAM_BIOS_BASE, PAM_BIOS_SIZE);
for (i = 0; i < 12; ++i) {
init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory,
mch->pci_address_space, &mch->pam_regions[i+1],
PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE);
}
if (qemu_opt_get_bool(qemu_get_machine_opts(), "iommu", false)) {
mch_init_dmar(mch);
}
}
| {
"code": [
" if (qemu_opt_get_bool(qemu_get_machine_opts(), \"iommu\", false)) {"
],
"line_no": [
51
]
} | static void FUNC_0(PCIDevice *VAR_0, Error **VAR_1)
{
int VAR_2;
MCHPCIState *mch = MCH_PCI_DEVICE(VAR_0);
pc_pci_as_mapping_init(OBJECT(mch), mch->system_memory,
mch->pci_address_space);
cpu_smm_register(&mch_set_smm, mch);
memory_region_init_alias(&mch->smram_region, OBJECT(mch), "smram-region",
mch->pci_address_space, 0xa0000, 0x20000);
memory_region_add_subregion_overlap(mch->system_memory, 0xa0000,
&mch->smram_region, 1);
memory_region_set_enabled(&mch->smram_region, false);
init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory,
mch->pci_address_space, &mch->pam_regions[0],
PAM_BIOS_BASE, PAM_BIOS_SIZE);
for (VAR_2 = 0; VAR_2 < 12; ++VAR_2) {
init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory,
mch->pci_address_space, &mch->pam_regions[VAR_2+1],
PAM_EXPAN_BASE + VAR_2 * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE);
}
if (qemu_opt_get_bool(qemu_get_machine_opts(), "iommu", false)) {
mch_init_dmar(mch);
}
}
| [
"static void FUNC_0(PCIDevice *VAR_0, Error **VAR_1)\n{",
"int VAR_2;",
"MCHPCIState *mch = MCH_PCI_DEVICE(VAR_0);",
"pc_pci_as_mapping_init(OBJECT(mch), mch->system_memory,\nmch->pci_address_space);",
"cpu_smm_register(&mch_set_smm, mch);",
"memory_region_init_alias(&mch->smram_region, OBJECT(mch), \"smram-region\",\nmch->pci_address_space, 0xa0000, 0x20000);",
"memory_region_add_subregion_overlap(mch->system_memory, 0xa0000,\n&mch->smram_region, 1);",
"memory_region_set_enabled(&mch->smram_region, false);",
"init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory,\nmch->pci_address_space, &mch->pam_regions[0],\nPAM_BIOS_BASE, PAM_BIOS_SIZE);",
"for (VAR_2 = 0; VAR_2 < 12; ++VAR_2) {",
"init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory,\nmch->pci_address_space, &mch->pam_regions[VAR_2+1],\nPAM_EXPAN_BASE + VAR_2 * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE);",
"}",
"if (qemu_opt_get_bool(qemu_get_machine_opts(), \"iommu\", false)) {",
"mch_init_dmar(mch);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
13,
15
],
[
21
],
[
23,
25
],
[
27,
29
],
[
31
],
[
33,
35,
37
],
[
39
],
[
41,
43,
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
]
]
|
13,640 | static uint64_t calc_rice_params(RiceContext *rc, int pmin, int pmax,
int32_t *data, int n, int pred_order)
{
int i;
uint64_t bits[MAX_PARTITION_ORDER+1];
int opt_porder;
RiceContext tmp_rc;
uint32_t *udata;
uint64_t sums[MAX_PARTITION_ORDER + 1][MAX_PARTITIONS] = { { 0 } };
assert(pmin >= 0 && pmin <= MAX_PARTITION_ORDER);
assert(pmax >= 0 && pmax <= MAX_PARTITION_ORDER);
assert(pmin <= pmax);
tmp_rc.coding_mode = rc->coding_mode;
udata = av_malloc(n * sizeof(uint32_t));
for (i = 0; i < n; i++)
udata[i] = (2*data[i]) ^ (data[i]>>31);
calc_sums(pmin, pmax, udata, n, pred_order, sums);
opt_porder = pmin;
bits[pmin] = UINT32_MAX;
for (i = pmin; i <= pmax; i++) {
bits[i] = calc_optimal_rice_params(&tmp_rc, i, sums[i], n, pred_order);
if (bits[i] <= bits[opt_porder]) {
opt_porder = i;
*rc = tmp_rc;
}
}
av_freep(&udata);
return bits[opt_porder];
}
| false | FFmpeg | f5ba67ee1342b7741200ff637fc3ea3387b68a1b | static uint64_t calc_rice_params(RiceContext *rc, int pmin, int pmax,
int32_t *data, int n, int pred_order)
{
int i;
uint64_t bits[MAX_PARTITION_ORDER+1];
int opt_porder;
RiceContext tmp_rc;
uint32_t *udata;
uint64_t sums[MAX_PARTITION_ORDER + 1][MAX_PARTITIONS] = { { 0 } };
assert(pmin >= 0 && pmin <= MAX_PARTITION_ORDER);
assert(pmax >= 0 && pmax <= MAX_PARTITION_ORDER);
assert(pmin <= pmax);
tmp_rc.coding_mode = rc->coding_mode;
udata = av_malloc(n * sizeof(uint32_t));
for (i = 0; i < n; i++)
udata[i] = (2*data[i]) ^ (data[i]>>31);
calc_sums(pmin, pmax, udata, n, pred_order, sums);
opt_porder = pmin;
bits[pmin] = UINT32_MAX;
for (i = pmin; i <= pmax; i++) {
bits[i] = calc_optimal_rice_params(&tmp_rc, i, sums[i], n, pred_order);
if (bits[i] <= bits[opt_porder]) {
opt_porder = i;
*rc = tmp_rc;
}
}
av_freep(&udata);
return bits[opt_porder];
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(RiceContext *rc, int pmin, int pmax,
int32_t *data, int n, int pred_order)
{
int VAR_0;
uint64_t bits[MAX_PARTITION_ORDER+1];
int VAR_1;
RiceContext tmp_rc;
uint32_t *udata;
uint64_t sums[MAX_PARTITION_ORDER + 1][MAX_PARTITIONS] = { { 0 } };
assert(pmin >= 0 && pmin <= MAX_PARTITION_ORDER);
assert(pmax >= 0 && pmax <= MAX_PARTITION_ORDER);
assert(pmin <= pmax);
tmp_rc.coding_mode = rc->coding_mode;
udata = av_malloc(n * sizeof(uint32_t));
for (VAR_0 = 0; VAR_0 < n; VAR_0++)
udata[VAR_0] = (2*data[VAR_0]) ^ (data[VAR_0]>>31);
calc_sums(pmin, pmax, udata, n, pred_order, sums);
VAR_1 = pmin;
bits[pmin] = UINT32_MAX;
for (VAR_0 = pmin; VAR_0 <= pmax; VAR_0++) {
bits[VAR_0] = calc_optimal_rice_params(&tmp_rc, VAR_0, sums[VAR_0], n, pred_order);
if (bits[VAR_0] <= bits[VAR_1]) {
VAR_1 = VAR_0;
*rc = tmp_rc;
}
}
av_freep(&udata);
return bits[VAR_1];
}
| [
"static uint64_t FUNC_0(RiceContext *rc, int pmin, int pmax,\nint32_t *data, int n, int pred_order)\n{",
"int VAR_0;",
"uint64_t bits[MAX_PARTITION_ORDER+1];",
"int VAR_1;",
"RiceContext tmp_rc;",
"uint32_t *udata;",
"uint64_t sums[MAX_PARTITION_ORDER + 1][MAX_PARTITIONS] = { { 0 } };",
"assert(pmin >= 0 && pmin <= MAX_PARTITION_ORDER);",
"assert(pmax >= 0 && pmax <= MAX_PARTITION_ORDER);",
"assert(pmin <= pmax);",
"tmp_rc.coding_mode = rc->coding_mode;",
"udata = av_malloc(n * sizeof(uint32_t));",
"for (VAR_0 = 0; VAR_0 < n; VAR_0++)",
"udata[VAR_0] = (2*data[VAR_0]) ^ (data[VAR_0]>>31);",
"calc_sums(pmin, pmax, udata, n, pred_order, sums);",
"VAR_1 = pmin;",
"bits[pmin] = UINT32_MAX;",
"for (VAR_0 = pmin; VAR_0 <= pmax; VAR_0++) {",
"bits[VAR_0] = calc_optimal_rice_params(&tmp_rc, VAR_0, sums[VAR_0], n, pred_order);",
"if (bits[VAR_0] <= bits[VAR_1]) {",
"VAR_1 = VAR_0;",
"*rc = tmp_rc;",
"}",
"}",
"av_freep(&udata);",
"return bits[VAR_1];",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
33
],
[
35
],
[
37
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
]
]
|
13,641 | static int handle_http(HTTPContext *c, long cur_time)
{
int len;
switch(c->state) {
case HTTPSTATE_WAIT_REQUEST:
/* timeout ? */
if ((c->timeout - cur_time) < 0)
return -1;
if (c->poll_entry->revents & (POLLERR | POLLHUP))
return -1;
/* no need to read if no events */
if (!(c->poll_entry->revents & POLLIN))
return 0;
/* read the data */
len = read(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr);
if (len < 0) {
if (errno != EAGAIN && errno != EINTR)
return -1;
} else if (len == 0) {
return -1;
} else {
/* search for end of request. XXX: not fully correct since garbage could come after the end */
UINT8 *ptr;
c->buffer_ptr += len;
ptr = c->buffer_ptr;
if ((ptr >= c->buffer + 2 && !memcmp(ptr-2, "\n\n", 2)) ||
(ptr >= c->buffer + 4 && !memcmp(ptr-4, "\r\n\r\n", 4))) {
/* request found : parse it and reply */
if (http_parse_request(c) < 0)
return -1;
} else if (ptr >= c->buffer_end) {
/* request too long: cannot do anything */
return -1;
}
}
break;
case HTTPSTATE_SEND_HEADER:
if (c->poll_entry->revents & (POLLERR | POLLHUP))
return -1;
/* no need to read if no events */
if (!(c->poll_entry->revents & POLLOUT))
return 0;
len = write(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr);
if (len < 0) {
if (errno != EAGAIN && errno != EINTR) {
/* error : close connection */
return -1;
}
} else {
c->buffer_ptr += len;
if (c->stream)
c->stream->bytes_served += len;
c->data_count += len;
if (c->buffer_ptr >= c->buffer_end) {
/* if error, exit */
if (c->http_error)
return -1;
/* all the buffer was send : synchronize to the incoming stream */
c->state = HTTPSTATE_SEND_DATA_HEADER;
c->buffer_ptr = c->buffer_end = c->buffer;
}
}
break;
case HTTPSTATE_SEND_DATA:
case HTTPSTATE_SEND_DATA_HEADER:
case HTTPSTATE_SEND_DATA_TRAILER:
/* no need to read if no events */
if (c->poll_entry->revents & (POLLERR | POLLHUP))
return -1;
if (!(c->poll_entry->revents & POLLOUT))
return 0;
if (http_send_data(c, cur_time) < 0)
return -1;
break;
case HTTPSTATE_RECEIVE_DATA:
/* no need to read if no events */
if (c->poll_entry->revents & (POLLERR | POLLHUP))
return -1;
if (!(c->poll_entry->revents & POLLIN))
return 0;
if (http_receive_data(c) < 0)
return -1;
break;
case HTTPSTATE_WAIT_FEED:
/* no need to read if no events */
if (c->poll_entry->revents & (POLLIN | POLLERR | POLLHUP))
return -1;
/* nothing to do, we'll be waken up by incoming feed packets */
break;
default:
return -1;
}
return 0;
}
| true | FFmpeg | 5eb765ef341c3ec1bea31914c897750f88476ede | static int handle_http(HTTPContext *c, long cur_time)
{
int len;
switch(c->state) {
case HTTPSTATE_WAIT_REQUEST:
if ((c->timeout - cur_time) < 0)
return -1;
if (c->poll_entry->revents & (POLLERR | POLLHUP))
return -1;
if (!(c->poll_entry->revents & POLLIN))
return 0;
len = read(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr);
if (len < 0) {
if (errno != EAGAIN && errno != EINTR)
return -1;
} else if (len == 0) {
return -1;
} else {
UINT8 *ptr;
c->buffer_ptr += len;
ptr = c->buffer_ptr;
if ((ptr >= c->buffer + 2 && !memcmp(ptr-2, "\n\n", 2)) ||
(ptr >= c->buffer + 4 && !memcmp(ptr-4, "\r\n\r\n", 4))) {
if (http_parse_request(c) < 0)
return -1;
} else if (ptr >= c->buffer_end) {
return -1;
}
}
break;
case HTTPSTATE_SEND_HEADER:
if (c->poll_entry->revents & (POLLERR | POLLHUP))
return -1;
if (!(c->poll_entry->revents & POLLOUT))
return 0;
len = write(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr);
if (len < 0) {
if (errno != EAGAIN && errno != EINTR) {
return -1;
}
} else {
c->buffer_ptr += len;
if (c->stream)
c->stream->bytes_served += len;
c->data_count += len;
if (c->buffer_ptr >= c->buffer_end) {
if (c->http_error)
return -1;
c->state = HTTPSTATE_SEND_DATA_HEADER;
c->buffer_ptr = c->buffer_end = c->buffer;
}
}
break;
case HTTPSTATE_SEND_DATA:
case HTTPSTATE_SEND_DATA_HEADER:
case HTTPSTATE_SEND_DATA_TRAILER:
if (c->poll_entry->revents & (POLLERR | POLLHUP))
return -1;
if (!(c->poll_entry->revents & POLLOUT))
return 0;
if (http_send_data(c, cur_time) < 0)
return -1;
break;
case HTTPSTATE_RECEIVE_DATA:
if (c->poll_entry->revents & (POLLERR | POLLHUP))
return -1;
if (!(c->poll_entry->revents & POLLIN))
return 0;
if (http_receive_data(c) < 0)
return -1;
break;
case HTTPSTATE_WAIT_FEED:
if (c->poll_entry->revents & (POLLIN | POLLERR | POLLHUP))
return -1;
break;
default:
return -1;
}
return 0;
}
| {
"code": [
"static int handle_http(HTTPContext *c, long cur_time)",
" if (http_send_data(c, cur_time) < 0)"
],
"line_no": [
1,
155
]
} | static int FUNC_0(HTTPContext *VAR_0, long VAR_1)
{
int VAR_2;
switch(VAR_0->state) {
case HTTPSTATE_WAIT_REQUEST:
if ((VAR_0->timeout - VAR_1) < 0)
return -1;
if (VAR_0->poll_entry->revents & (POLLERR | POLLHUP))
return -1;
if (!(VAR_0->poll_entry->revents & POLLIN))
return 0;
VAR_2 = read(VAR_0->fd, VAR_0->buffer_ptr, VAR_0->buffer_end - VAR_0->buffer_ptr);
if (VAR_2 < 0) {
if (errno != EAGAIN && errno != EINTR)
return -1;
} else if (VAR_2 == 0) {
return -1;
} else {
UINT8 *ptr;
VAR_0->buffer_ptr += VAR_2;
ptr = VAR_0->buffer_ptr;
if ((ptr >= VAR_0->buffer + 2 && !memcmp(ptr-2, "\n\n", 2)) ||
(ptr >= VAR_0->buffer + 4 && !memcmp(ptr-4, "\r\n\r\n", 4))) {
if (http_parse_request(VAR_0) < 0)
return -1;
} else if (ptr >= VAR_0->buffer_end) {
return -1;
}
}
break;
case HTTPSTATE_SEND_HEADER:
if (VAR_0->poll_entry->revents & (POLLERR | POLLHUP))
return -1;
if (!(VAR_0->poll_entry->revents & POLLOUT))
return 0;
VAR_2 = write(VAR_0->fd, VAR_0->buffer_ptr, VAR_0->buffer_end - VAR_0->buffer_ptr);
if (VAR_2 < 0) {
if (errno != EAGAIN && errno != EINTR) {
return -1;
}
} else {
VAR_0->buffer_ptr += VAR_2;
if (VAR_0->stream)
VAR_0->stream->bytes_served += VAR_2;
VAR_0->data_count += VAR_2;
if (VAR_0->buffer_ptr >= VAR_0->buffer_end) {
if (VAR_0->http_error)
return -1;
VAR_0->state = HTTPSTATE_SEND_DATA_HEADER;
VAR_0->buffer_ptr = VAR_0->buffer_end = VAR_0->buffer;
}
}
break;
case HTTPSTATE_SEND_DATA:
case HTTPSTATE_SEND_DATA_HEADER:
case HTTPSTATE_SEND_DATA_TRAILER:
if (VAR_0->poll_entry->revents & (POLLERR | POLLHUP))
return -1;
if (!(VAR_0->poll_entry->revents & POLLOUT))
return 0;
if (http_send_data(VAR_0, VAR_1) < 0)
return -1;
break;
case HTTPSTATE_RECEIVE_DATA:
if (VAR_0->poll_entry->revents & (POLLERR | POLLHUP))
return -1;
if (!(VAR_0->poll_entry->revents & POLLIN))
return 0;
if (http_receive_data(VAR_0) < 0)
return -1;
break;
case HTTPSTATE_WAIT_FEED:
if (VAR_0->poll_entry->revents & (POLLIN | POLLERR | POLLHUP))
return -1;
break;
default:
return -1;
}
return 0;
}
| [
"static int FUNC_0(HTTPContext *VAR_0, long VAR_1)\n{",
"int VAR_2;",
"switch(VAR_0->state) {",
"case HTTPSTATE_WAIT_REQUEST:\nif ((VAR_0->timeout - VAR_1) < 0)\nreturn -1;",
"if (VAR_0->poll_entry->revents & (POLLERR | POLLHUP))\nreturn -1;",
"if (!(VAR_0->poll_entry->revents & POLLIN))\nreturn 0;",
"VAR_2 = read(VAR_0->fd, VAR_0->buffer_ptr, VAR_0->buffer_end - VAR_0->buffer_ptr);",
"if (VAR_2 < 0) {",
"if (errno != EAGAIN && errno != EINTR)\nreturn -1;",
"} else if (VAR_2 == 0) {",
"return -1;",
"} else {",
"UINT8 *ptr;",
"VAR_0->buffer_ptr += VAR_2;",
"ptr = VAR_0->buffer_ptr;",
"if ((ptr >= VAR_0->buffer + 2 && !memcmp(ptr-2, \"\\n\\n\", 2)) ||\n(ptr >= VAR_0->buffer + 4 && !memcmp(ptr-4, \"\\r\\n\\r\\n\", 4))) {",
"if (http_parse_request(VAR_0) < 0)\nreturn -1;",
"} else if (ptr >= VAR_0->buffer_end) {",
"return -1;",
"}",
"}",
"break;",
"case HTTPSTATE_SEND_HEADER:\nif (VAR_0->poll_entry->revents & (POLLERR | POLLHUP))\nreturn -1;",
"if (!(VAR_0->poll_entry->revents & POLLOUT))\nreturn 0;",
"VAR_2 = write(VAR_0->fd, VAR_0->buffer_ptr, VAR_0->buffer_end - VAR_0->buffer_ptr);",
"if (VAR_2 < 0) {",
"if (errno != EAGAIN && errno != EINTR) {",
"return -1;",
"}",
"} else {",
"VAR_0->buffer_ptr += VAR_2;",
"if (VAR_0->stream)\nVAR_0->stream->bytes_served += VAR_2;",
"VAR_0->data_count += VAR_2;",
"if (VAR_0->buffer_ptr >= VAR_0->buffer_end) {",
"if (VAR_0->http_error)\nreturn -1;",
"VAR_0->state = HTTPSTATE_SEND_DATA_HEADER;",
"VAR_0->buffer_ptr = VAR_0->buffer_end = VAR_0->buffer;",
"}",
"}",
"break;",
"case HTTPSTATE_SEND_DATA:\ncase HTTPSTATE_SEND_DATA_HEADER:\ncase HTTPSTATE_SEND_DATA_TRAILER:\nif (VAR_0->poll_entry->revents & (POLLERR | POLLHUP))\nreturn -1;",
"if (!(VAR_0->poll_entry->revents & POLLOUT))\nreturn 0;",
"if (http_send_data(VAR_0, VAR_1) < 0)\nreturn -1;",
"break;",
"case HTTPSTATE_RECEIVE_DATA:\nif (VAR_0->poll_entry->revents & (POLLERR | POLLHUP))\nreturn -1;",
"if (!(VAR_0->poll_entry->revents & POLLIN))\nreturn 0;",
"if (http_receive_data(VAR_0) < 0)\nreturn -1;",
"break;",
"case HTTPSTATE_WAIT_FEED:\nif (VAR_0->poll_entry->revents & (POLLIN | POLLERR | POLLHUP))\nreturn -1;",
"break;",
"default:\nreturn -1;",
"}",
"return 0;",
"}"
]
| [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11,
15,
17
],
[
19,
21
],
[
27,
29
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
61,
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79,
81,
83
],
[
89,
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109,
111
],
[
113
],
[
115
],
[
119,
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
137,
139,
141,
145,
147
],
[
151,
153
],
[
155,
157
],
[
159
],
[
161,
165,
167
],
[
169,
171
],
[
173,
175
],
[
177
],
[
179,
183,
185
],
[
191
],
[
193,
195
],
[
197
],
[
199
],
[
201
]
]
|
13,642 | static int bfi_read_header(AVFormatContext * s)
{
BFIContext *bfi = s->priv_data;
AVIOContext *pb = s->pb;
AVStream *vstream;
AVStream *astream;
int fps, chunk_header;
/* Initialize the video codec... */
vstream = avformat_new_stream(s, NULL);
if (!vstream)
return AVERROR(ENOMEM);
/* Initialize the audio codec... */
astream = avformat_new_stream(s, NULL);
if (!astream)
return AVERROR(ENOMEM);
/* Set the total number of frames. */
avio_skip(pb, 8);
chunk_header = avio_rl32(pb);
bfi->nframes = avio_rl32(pb);
avio_rl32(pb);
avio_rl32(pb);
avio_rl32(pb);
fps = avio_rl32(pb);
avio_skip(pb, 12);
vstream->codecpar->width = avio_rl32(pb);
vstream->codecpar->height = avio_rl32(pb);
/*Load the palette to extradata */
avio_skip(pb, 8);
vstream->codecpar->extradata = av_malloc(768);
if (!vstream->codecpar->extradata)
return AVERROR(ENOMEM);
vstream->codecpar->extradata_size = 768;
avio_read(pb, vstream->codecpar->extradata,
vstream->codecpar->extradata_size);
astream->codecpar->sample_rate = avio_rl32(pb);
if (astream->codecpar->sample_rate <= 0) {
av_log(s, AV_LOG_ERROR, "Invalid sample rate %d\n", astream->codecpar->sample_rate);
return AVERROR_INVALIDDATA;
}
/* Set up the video codec... */
avpriv_set_pts_info(vstream, 32, 1, fps);
vstream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
vstream->codecpar->codec_id = AV_CODEC_ID_BFI;
vstream->codecpar->format = AV_PIX_FMT_PAL8;
vstream->nb_frames =
vstream->duration = bfi->nframes;
/* Set up the audio codec now... */
astream->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
astream->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
astream->codecpar->channels = 1;
astream->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
astream->codecpar->bits_per_coded_sample = 8;
astream->codecpar->bit_rate =
astream->codecpar->sample_rate * astream->codecpar->bits_per_coded_sample;
avio_seek(pb, chunk_header - 3, SEEK_SET);
avpriv_set_pts_info(astream, 64, 1, astream->codecpar->sample_rate);
return 0;
}
| true | FFmpeg | ad5807f8aa883bee5431186dc1f24c5435d722d3 | static int bfi_read_header(AVFormatContext * s)
{
BFIContext *bfi = s->priv_data;
AVIOContext *pb = s->pb;
AVStream *vstream;
AVStream *astream;
int fps, chunk_header;
vstream = avformat_new_stream(s, NULL);
if (!vstream)
return AVERROR(ENOMEM);
astream = avformat_new_stream(s, NULL);
if (!astream)
return AVERROR(ENOMEM);
avio_skip(pb, 8);
chunk_header = avio_rl32(pb);
bfi->nframes = avio_rl32(pb);
avio_rl32(pb);
avio_rl32(pb);
avio_rl32(pb);
fps = avio_rl32(pb);
avio_skip(pb, 12);
vstream->codecpar->width = avio_rl32(pb);
vstream->codecpar->height = avio_rl32(pb);
avio_skip(pb, 8);
vstream->codecpar->extradata = av_malloc(768);
if (!vstream->codecpar->extradata)
return AVERROR(ENOMEM);
vstream->codecpar->extradata_size = 768;
avio_read(pb, vstream->codecpar->extradata,
vstream->codecpar->extradata_size);
astream->codecpar->sample_rate = avio_rl32(pb);
if (astream->codecpar->sample_rate <= 0) {
av_log(s, AV_LOG_ERROR, "Invalid sample rate %d\n", astream->codecpar->sample_rate);
return AVERROR_INVALIDDATA;
}
avpriv_set_pts_info(vstream, 32, 1, fps);
vstream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
vstream->codecpar->codec_id = AV_CODEC_ID_BFI;
vstream->codecpar->format = AV_PIX_FMT_PAL8;
vstream->nb_frames =
vstream->duration = bfi->nframes;
astream->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
astream->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
astream->codecpar->channels = 1;
astream->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
astream->codecpar->bits_per_coded_sample = 8;
astream->codecpar->bit_rate =
astream->codecpar->sample_rate * astream->codecpar->bits_per_coded_sample;
avio_seek(pb, chunk_header - 3, SEEK_SET);
avpriv_set_pts_info(astream, 64, 1, astream->codecpar->sample_rate);
return 0;
}
| {
"code": [
" astream->codecpar->sample_rate * astream->codecpar->bits_per_coded_sample;"
],
"line_no": [
121
]
} | static int FUNC_0(AVFormatContext * VAR_0)
{
BFIContext *bfi = VAR_0->priv_data;
AVIOContext *pb = VAR_0->pb;
AVStream *vstream;
AVStream *astream;
int VAR_1, VAR_2;
vstream = avformat_new_stream(VAR_0, NULL);
if (!vstream)
return AVERROR(ENOMEM);
astream = avformat_new_stream(VAR_0, NULL);
if (!astream)
return AVERROR(ENOMEM);
avio_skip(pb, 8);
VAR_2 = avio_rl32(pb);
bfi->nframes = avio_rl32(pb);
avio_rl32(pb);
avio_rl32(pb);
avio_rl32(pb);
VAR_1 = avio_rl32(pb);
avio_skip(pb, 12);
vstream->codecpar->width = avio_rl32(pb);
vstream->codecpar->height = avio_rl32(pb);
avio_skip(pb, 8);
vstream->codecpar->extradata = av_malloc(768);
if (!vstream->codecpar->extradata)
return AVERROR(ENOMEM);
vstream->codecpar->extradata_size = 768;
avio_read(pb, vstream->codecpar->extradata,
vstream->codecpar->extradata_size);
astream->codecpar->sample_rate = avio_rl32(pb);
if (astream->codecpar->sample_rate <= 0) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid sample rate %d\n", astream->codecpar->sample_rate);
return AVERROR_INVALIDDATA;
}
avpriv_set_pts_info(vstream, 32, 1, VAR_1);
vstream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
vstream->codecpar->codec_id = AV_CODEC_ID_BFI;
vstream->codecpar->format = AV_PIX_FMT_PAL8;
vstream->nb_frames =
vstream->duration = bfi->nframes;
astream->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
astream->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
astream->codecpar->channels = 1;
astream->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
astream->codecpar->bits_per_coded_sample = 8;
astream->codecpar->bit_rate =
astream->codecpar->sample_rate * astream->codecpar->bits_per_coded_sample;
avio_seek(pb, VAR_2 - 3, SEEK_SET);
avpriv_set_pts_info(astream, 64, 1, astream->codecpar->sample_rate);
return 0;
}
| [
"static int FUNC_0(AVFormatContext * VAR_0)\n{",
"BFIContext *bfi = VAR_0->priv_data;",
"AVIOContext *pb = VAR_0->pb;",
"AVStream *vstream;",
"AVStream *astream;",
"int VAR_1, VAR_2;",
"vstream = avformat_new_stream(VAR_0, NULL);",
"if (!vstream)\nreturn AVERROR(ENOMEM);",
"astream = avformat_new_stream(VAR_0, NULL);",
"if (!astream)\nreturn AVERROR(ENOMEM);",
"avio_skip(pb, 8);",
"VAR_2 = avio_rl32(pb);",
"bfi->nframes = avio_rl32(pb);",
"avio_rl32(pb);",
"avio_rl32(pb);",
"avio_rl32(pb);",
"VAR_1 = avio_rl32(pb);",
"avio_skip(pb, 12);",
"vstream->codecpar->width = avio_rl32(pb);",
"vstream->codecpar->height = avio_rl32(pb);",
"avio_skip(pb, 8);",
"vstream->codecpar->extradata = av_malloc(768);",
"if (!vstream->codecpar->extradata)\nreturn AVERROR(ENOMEM);",
"vstream->codecpar->extradata_size = 768;",
"avio_read(pb, vstream->codecpar->extradata,\nvstream->codecpar->extradata_size);",
"astream->codecpar->sample_rate = avio_rl32(pb);",
"if (astream->codecpar->sample_rate <= 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid sample rate %d\\n\", astream->codecpar->sample_rate);",
"return AVERROR_INVALIDDATA;",
"}",
"avpriv_set_pts_info(vstream, 32, 1, VAR_1);",
"vstream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;",
"vstream->codecpar->codec_id = AV_CODEC_ID_BFI;",
"vstream->codecpar->format = AV_PIX_FMT_PAL8;",
"vstream->nb_frames =\nvstream->duration = bfi->nframes;",
"astream->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;",
"astream->codecpar->codec_id = AV_CODEC_ID_PCM_U8;",
"astream->codecpar->channels = 1;",
"astream->codecpar->channel_layout = AV_CH_LAYOUT_MONO;",
"astream->codecpar->bits_per_coded_sample = 8;",
"astream->codecpar->bit_rate =\nastream->codecpar->sample_rate * astream->codecpar->bits_per_coded_sample;",
"avio_seek(pb, VAR_2 - 3, SEEK_SET);",
"avpriv_set_pts_info(astream, 64, 1, astream->codecpar->sample_rate);",
"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,
1,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
19
],
[
21,
23
],
[
29
],
[
31,
33
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73,
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101,
103
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119,
121
],
[
123
],
[
125
],
[
127
],
[
129
]
]
|
13,643 | static int event_qdev_init(DeviceState *qdev)
{
SCLPEvent *event = DO_UPCAST(SCLPEvent, qdev, qdev);
SCLPEventClass *child = SCLP_EVENT_GET_CLASS(event);
return child->init(event);
}
| true | qemu | c804c2a71752dd1e150cde768d8c54b02fa8bad9 | static int event_qdev_init(DeviceState *qdev)
{
SCLPEvent *event = DO_UPCAST(SCLPEvent, qdev, qdev);
SCLPEventClass *child = SCLP_EVENT_GET_CLASS(event);
return child->init(event);
}
| {
"code": [
"static int event_qdev_init(DeviceState *qdev)",
" SCLPEvent *event = DO_UPCAST(SCLPEvent, qdev, qdev);",
" return child->init(event);",
" SCLPEvent *event = DO_UPCAST(SCLPEvent, qdev, qdev);"
],
"line_no": [
1,
5,
11,
5
]
} | static int FUNC_0(DeviceState *VAR_0)
{
SCLPEvent *event = DO_UPCAST(SCLPEvent, VAR_0, VAR_0);
SCLPEventClass *child = SCLP_EVENT_GET_CLASS(event);
return child->init(event);
}
| [
"static int FUNC_0(DeviceState *VAR_0)\n{",
"SCLPEvent *event = DO_UPCAST(SCLPEvent, VAR_0, VAR_0);",
"SCLPEventClass *child = SCLP_EVENT_GET_CLASS(event);",
"return child->init(event);",
"}"
]
| [
1,
1,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
]
]
|
13,644 | static void gen_rfid(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
/* Restore CPU state */
if (unlikely(!ctx->mem_idx)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
gen_helper_rfid();
gen_sync_exception(ctx);
#endif
} | true | qemu | 697ab892786d47008807a49f57b2fd86adfcd098 | static void gen_rfid(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(!ctx->mem_idx)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
gen_helper_rfid();
gen_sync_exception(ctx);
#endif
} | {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(!VAR_0->mem_idx)) {
gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);
return;
}
gen_helper_rfid();
gen_sync_exception(VAR_0);
#endif
} | [
"static void FUNC_0(DisasContext *VAR_0)\n{",
"#if defined(CONFIG_USER_ONLY)\ngen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);",
"#else\nif (unlikely(!VAR_0->mem_idx)) {",
"gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);",
"return;",
"}",
"gen_helper_rfid();",
"gen_sync_exception(VAR_0);",
"#endif\n}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5,
7
],
[
9,
13
],
[
15
],
[
17
],
[
19
],
[
22
],
[
24
],
[
26,
28
]
]
|
13,645 | static void vga_update_text(void *opaque, console_ch_t *chardata)
{
VGACommonState *s = opaque;
int graphic_mode, i, cursor_offset, cursor_visible;
int cw, cheight, width, height, size, c_min, c_max;
uint32_t *src;
console_ch_t *dst, val;
char msg_buffer[80];
int full_update = 0;
if (!(s->ar_index & 0x20)) {
graphic_mode = GMODE_BLANK;
} else {
graphic_mode = s->gr[6] & 1;
}
if (graphic_mode != s->graphic_mode) {
s->graphic_mode = graphic_mode;
full_update = 1;
}
if (s->last_width == -1) {
s->last_width = 0;
full_update = 1;
}
switch (graphic_mode) {
case GMODE_TEXT:
/* TODO: update palette */
full_update |= update_basic_params(s);
/* total width & height */
cheight = (s->cr[9] & 0x1f) + 1;
cw = 8;
if (!(s->sr[1] & 0x01))
cw = 9;
if (s->sr[1] & 0x08)
cw = 16; /* NOTE: no 18 pixel wide */
width = (s->cr[0x01] + 1);
if (s->cr[0x06] == 100) {
/* ugly hack for CGA 160x100x16 - explain me the logic */
height = 100;
} else {
height = s->cr[0x12] |
((s->cr[0x07] & 0x02) << 7) |
((s->cr[0x07] & 0x40) << 3);
height = (height + 1) / cheight;
}
size = (height * width);
if (size > CH_ATTR_SIZE) {
if (!full_update)
return;
snprintf(msg_buffer, sizeof(msg_buffer), "%i x %i Text mode",
width, height);
break;
}
if (width != s->last_width || height != s->last_height ||
cw != s->last_cw || cheight != s->last_ch) {
s->last_scr_width = width * cw;
s->last_scr_height = height * cheight;
s->ds->surface->width = width;
s->ds->surface->height = height;
dpy_resize(s->ds);
s->last_width = width;
s->last_height = height;
s->last_ch = cheight;
s->last_cw = cw;
full_update = 1;
}
/* Update "hardware" cursor */
cursor_offset = ((s->cr[0x0e] << 8) | s->cr[0x0f]) - s->start_addr;
if (cursor_offset != s->cursor_offset ||
s->cr[0xa] != s->cursor_start ||
s->cr[0xb] != s->cursor_end || full_update) {
cursor_visible = !(s->cr[0xa] & 0x20);
if (cursor_visible && cursor_offset < size && cursor_offset >= 0)
dpy_cursor(s->ds,
TEXTMODE_X(cursor_offset),
TEXTMODE_Y(cursor_offset));
else
dpy_cursor(s->ds, -1, -1);
s->cursor_offset = cursor_offset;
s->cursor_start = s->cr[0xa];
s->cursor_end = s->cr[0xb];
}
src = (uint32_t *) s->vram_ptr + s->start_addr;
dst = chardata;
if (full_update) {
for (i = 0; i < size; src ++, dst ++, i ++)
console_write_ch(dst, VMEM2CHTYPE(le32_to_cpu(*src)));
dpy_update(s->ds, 0, 0, width, height);
} else {
c_max = 0;
for (i = 0; i < size; src ++, dst ++, i ++) {
console_write_ch(&val, VMEM2CHTYPE(le32_to_cpu(*src)));
if (*dst != val) {
*dst = val;
c_max = i;
break;
}
}
c_min = i;
for (; i < size; src ++, dst ++, i ++) {
console_write_ch(&val, VMEM2CHTYPE(le32_to_cpu(*src)));
if (*dst != val) {
*dst = val;
c_max = i;
}
}
if (c_min <= c_max) {
i = TEXTMODE_Y(c_min);
dpy_update(s->ds, 0, i, width, TEXTMODE_Y(c_max) - i + 1);
}
}
return;
case GMODE_GRAPH:
if (!full_update)
return;
s->get_resolution(s, &width, &height);
snprintf(msg_buffer, sizeof(msg_buffer), "%i x %i Graphic mode",
width, height);
break;
case GMODE_BLANK:
default:
if (!full_update)
return;
snprintf(msg_buffer, sizeof(msg_buffer), "VGA Blank mode");
break;
}
/* Display a message */
s->last_width = 60;
s->last_height = height = 3;
dpy_cursor(s->ds, -1, -1);
s->ds->surface->width = s->last_width;
s->ds->surface->height = height;
dpy_resize(s->ds);
for (dst = chardata, i = 0; i < s->last_width * height; i ++)
console_write_ch(dst ++, ' ');
size = strlen(msg_buffer);
width = (s->last_width - size) / 2;
dst = chardata + s->last_width + width;
for (i = 0; i < size; i ++)
console_write_ch(dst ++, 0x00200100 | msg_buffer[i]);
dpy_update(s->ds, 0, 0, s->last_width, height);
} | true | qemu | e9a07334fb6ee08ddd61787c102d36e7e781efef | static void vga_update_text(void *opaque, console_ch_t *chardata)
{
VGACommonState *s = opaque;
int graphic_mode, i, cursor_offset, cursor_visible;
int cw, cheight, width, height, size, c_min, c_max;
uint32_t *src;
console_ch_t *dst, val;
char msg_buffer[80];
int full_update = 0;
if (!(s->ar_index & 0x20)) {
graphic_mode = GMODE_BLANK;
} else {
graphic_mode = s->gr[6] & 1;
}
if (graphic_mode != s->graphic_mode) {
s->graphic_mode = graphic_mode;
full_update = 1;
}
if (s->last_width == -1) {
s->last_width = 0;
full_update = 1;
}
switch (graphic_mode) {
case GMODE_TEXT:
full_update |= update_basic_params(s);
cheight = (s->cr[9] & 0x1f) + 1;
cw = 8;
if (!(s->sr[1] & 0x01))
cw = 9;
if (s->sr[1] & 0x08)
cw = 16;
width = (s->cr[0x01] + 1);
if (s->cr[0x06] == 100) {
height = 100;
} else {
height = s->cr[0x12] |
((s->cr[0x07] & 0x02) << 7) |
((s->cr[0x07] & 0x40) << 3);
height = (height + 1) / cheight;
}
size = (height * width);
if (size > CH_ATTR_SIZE) {
if (!full_update)
return;
snprintf(msg_buffer, sizeof(msg_buffer), "%i x %i Text mode",
width, height);
break;
}
if (width != s->last_width || height != s->last_height ||
cw != s->last_cw || cheight != s->last_ch) {
s->last_scr_width = width * cw;
s->last_scr_height = height * cheight;
s->ds->surface->width = width;
s->ds->surface->height = height;
dpy_resize(s->ds);
s->last_width = width;
s->last_height = height;
s->last_ch = cheight;
s->last_cw = cw;
full_update = 1;
}
cursor_offset = ((s->cr[0x0e] << 8) | s->cr[0x0f]) - s->start_addr;
if (cursor_offset != s->cursor_offset ||
s->cr[0xa] != s->cursor_start ||
s->cr[0xb] != s->cursor_end || full_update) {
cursor_visible = !(s->cr[0xa] & 0x20);
if (cursor_visible && cursor_offset < size && cursor_offset >= 0)
dpy_cursor(s->ds,
TEXTMODE_X(cursor_offset),
TEXTMODE_Y(cursor_offset));
else
dpy_cursor(s->ds, -1, -1);
s->cursor_offset = cursor_offset;
s->cursor_start = s->cr[0xa];
s->cursor_end = s->cr[0xb];
}
src = (uint32_t *) s->vram_ptr + s->start_addr;
dst = chardata;
if (full_update) {
for (i = 0; i < size; src ++, dst ++, i ++)
console_write_ch(dst, VMEM2CHTYPE(le32_to_cpu(*src)));
dpy_update(s->ds, 0, 0, width, height);
} else {
c_max = 0;
for (i = 0; i < size; src ++, dst ++, i ++) {
console_write_ch(&val, VMEM2CHTYPE(le32_to_cpu(*src)));
if (*dst != val) {
*dst = val;
c_max = i;
break;
}
}
c_min = i;
for (; i < size; src ++, dst ++, i ++) {
console_write_ch(&val, VMEM2CHTYPE(le32_to_cpu(*src)));
if (*dst != val) {
*dst = val;
c_max = i;
}
}
if (c_min <= c_max) {
i = TEXTMODE_Y(c_min);
dpy_update(s->ds, 0, i, width, TEXTMODE_Y(c_max) - i + 1);
}
}
return;
case GMODE_GRAPH:
if (!full_update)
return;
s->get_resolution(s, &width, &height);
snprintf(msg_buffer, sizeof(msg_buffer), "%i x %i Graphic mode",
width, height);
break;
case GMODE_BLANK:
default:
if (!full_update)
return;
snprintf(msg_buffer, sizeof(msg_buffer), "VGA Blank mode");
break;
}
s->last_width = 60;
s->last_height = height = 3;
dpy_cursor(s->ds, -1, -1);
s->ds->surface->width = s->last_width;
s->ds->surface->height = height;
dpy_resize(s->ds);
for (dst = chardata, i = 0; i < s->last_width * height; i ++)
console_write_ch(dst ++, ' ');
size = strlen(msg_buffer);
width = (s->last_width - size) / 2;
dst = chardata + s->last_width + width;
for (i = 0; i < size; i ++)
console_write_ch(dst ++, 0x00200100 | msg_buffer[i]);
dpy_update(s->ds, 0, 0, s->last_width, height);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, console_ch_t *VAR_1)
{
VGACommonState *s = VAR_0;
int VAR_2, VAR_3, VAR_4, VAR_5;
int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;
uint32_t *src;
console_ch_t *dst, val;
char VAR_13[80];
int VAR_14 = 0;
if (!(s->ar_index & 0x20)) {
VAR_2 = GMODE_BLANK;
} else {
VAR_2 = s->gr[6] & 1;
}
if (VAR_2 != s->VAR_2) {
s->VAR_2 = VAR_2;
VAR_14 = 1;
}
if (s->last_width == -1) {
s->last_width = 0;
VAR_14 = 1;
}
switch (VAR_2) {
case GMODE_TEXT:
VAR_14 |= update_basic_params(s);
VAR_7 = (s->cr[9] & 0x1f) + 1;
VAR_6 = 8;
if (!(s->sr[1] & 0x01))
VAR_6 = 9;
if (s->sr[1] & 0x08)
VAR_6 = 16;
VAR_8 = (s->cr[0x01] + 1);
if (s->cr[0x06] == 100) {
VAR_9 = 100;
} else {
VAR_9 = s->cr[0x12] |
((s->cr[0x07] & 0x02) << 7) |
((s->cr[0x07] & 0x40) << 3);
VAR_9 = (VAR_9 + 1) / VAR_7;
}
VAR_10 = (VAR_9 * VAR_8);
if (VAR_10 > CH_ATTR_SIZE) {
if (!VAR_14)
return;
snprintf(VAR_13, sizeof(VAR_13), "%VAR_3 x %VAR_3 Text mode",
VAR_8, VAR_9);
break;
}
if (VAR_8 != s->last_width || VAR_9 != s->last_height ||
VAR_6 != s->last_cw || VAR_7 != s->last_ch) {
s->last_scr_width = VAR_8 * VAR_6;
s->last_scr_height = VAR_9 * VAR_7;
s->ds->surface->VAR_8 = VAR_8;
s->ds->surface->VAR_9 = VAR_9;
dpy_resize(s->ds);
s->last_width = VAR_8;
s->last_height = VAR_9;
s->last_ch = VAR_7;
s->last_cw = VAR_6;
VAR_14 = 1;
}
VAR_4 = ((s->cr[0x0e] << 8) | s->cr[0x0f]) - s->start_addr;
if (VAR_4 != s->VAR_4 ||
s->cr[0xa] != s->cursor_start ||
s->cr[0xb] != s->cursor_end || VAR_14) {
VAR_5 = !(s->cr[0xa] & 0x20);
if (VAR_5 && VAR_4 < VAR_10 && VAR_4 >= 0)
dpy_cursor(s->ds,
TEXTMODE_X(VAR_4),
TEXTMODE_Y(VAR_4));
else
dpy_cursor(s->ds, -1, -1);
s->VAR_4 = VAR_4;
s->cursor_start = s->cr[0xa];
s->cursor_end = s->cr[0xb];
}
src = (uint32_t *) s->vram_ptr + s->start_addr;
dst = VAR_1;
if (VAR_14) {
for (VAR_3 = 0; VAR_3 < VAR_10; src ++, dst ++, VAR_3 ++)
console_write_ch(dst, VMEM2CHTYPE(le32_to_cpu(*src)));
dpy_update(s->ds, 0, 0, VAR_8, VAR_9);
} else {
VAR_12 = 0;
for (VAR_3 = 0; VAR_3 < VAR_10; src ++, dst ++, VAR_3 ++) {
console_write_ch(&val, VMEM2CHTYPE(le32_to_cpu(*src)));
if (*dst != val) {
*dst = val;
VAR_12 = VAR_3;
break;
}
}
VAR_11 = VAR_3;
for (; VAR_3 < VAR_10; src ++, dst ++, VAR_3 ++) {
console_write_ch(&val, VMEM2CHTYPE(le32_to_cpu(*src)));
if (*dst != val) {
*dst = val;
VAR_12 = VAR_3;
}
}
if (VAR_11 <= VAR_12) {
VAR_3 = TEXTMODE_Y(VAR_11);
dpy_update(s->ds, 0, VAR_3, VAR_8, TEXTMODE_Y(VAR_12) - VAR_3 + 1);
}
}
return;
case GMODE_GRAPH:
if (!VAR_14)
return;
s->get_resolution(s, &VAR_8, &VAR_9);
snprintf(VAR_13, sizeof(VAR_13), "%VAR_3 x %VAR_3 Graphic mode",
VAR_8, VAR_9);
break;
case GMODE_BLANK:
default:
if (!VAR_14)
return;
snprintf(VAR_13, sizeof(VAR_13), "VGA Blank mode");
break;
}
s->last_width = 60;
s->last_height = VAR_9 = 3;
dpy_cursor(s->ds, -1, -1);
s->ds->surface->VAR_8 = s->last_width;
s->ds->surface->VAR_9 = VAR_9;
dpy_resize(s->ds);
for (dst = VAR_1, VAR_3 = 0; VAR_3 < s->last_width * VAR_9; VAR_3 ++)
console_write_ch(dst ++, ' ');
VAR_10 = strlen(VAR_13);
VAR_8 = (s->last_width - VAR_10) / 2;
dst = VAR_1 + s->last_width + VAR_8;
for (VAR_3 = 0; VAR_3 < VAR_10; VAR_3 ++)
console_write_ch(dst ++, 0x00200100 | VAR_13[VAR_3]);
dpy_update(s->ds, 0, 0, s->last_width, VAR_9);
} | [
"static void FUNC_0(void *VAR_0, console_ch_t *VAR_1)\n{",
"VGACommonState *s = VAR_0;",
"int VAR_2, VAR_3, VAR_4, VAR_5;",
"int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;",
"uint32_t *src;",
"console_ch_t *dst, val;",
"char VAR_13[80];",
"int VAR_14 = 0;",
"if (!(s->ar_index & 0x20)) {",
"VAR_2 = GMODE_BLANK;",
"} else {",
"VAR_2 = s->gr[6] & 1;",
"}",
"if (VAR_2 != s->VAR_2) {",
"s->VAR_2 = VAR_2;",
"VAR_14 = 1;",
"}",
"if (s->last_width == -1) {",
"s->last_width = 0;",
"VAR_14 = 1;",
"}",
"switch (VAR_2) {",
"case GMODE_TEXT:\nVAR_14 |= update_basic_params(s);",
"VAR_7 = (s->cr[9] & 0x1f) + 1;",
"VAR_6 = 8;",
"if (!(s->sr[1] & 0x01))\nVAR_6 = 9;",
"if (s->sr[1] & 0x08)\nVAR_6 = 16;",
"VAR_8 = (s->cr[0x01] + 1);",
"if (s->cr[0x06] == 100) {",
"VAR_9 = 100;",
"} else {",
"VAR_9 = s->cr[0x12] |\n((s->cr[0x07] & 0x02) << 7) |\n((s->cr[0x07] & 0x40) << 3);",
"VAR_9 = (VAR_9 + 1) / VAR_7;",
"}",
"VAR_10 = (VAR_9 * VAR_8);",
"if (VAR_10 > CH_ATTR_SIZE) {",
"if (!VAR_14)\nreturn;",
"snprintf(VAR_13, sizeof(VAR_13), \"%VAR_3 x %VAR_3 Text mode\",\nVAR_8, VAR_9);",
"break;",
"}",
"if (VAR_8 != s->last_width || VAR_9 != s->last_height ||\nVAR_6 != s->last_cw || VAR_7 != s->last_ch) {",
"s->last_scr_width = VAR_8 * VAR_6;",
"s->last_scr_height = VAR_9 * VAR_7;",
"s->ds->surface->VAR_8 = VAR_8;",
"s->ds->surface->VAR_9 = VAR_9;",
"dpy_resize(s->ds);",
"s->last_width = VAR_8;",
"s->last_height = VAR_9;",
"s->last_ch = VAR_7;",
"s->last_cw = VAR_6;",
"VAR_14 = 1;",
"}",
"VAR_4 = ((s->cr[0x0e] << 8) | s->cr[0x0f]) - s->start_addr;",
"if (VAR_4 != s->VAR_4 ||\ns->cr[0xa] != s->cursor_start ||\ns->cr[0xb] != s->cursor_end || VAR_14) {",
"VAR_5 = !(s->cr[0xa] & 0x20);",
"if (VAR_5 && VAR_4 < VAR_10 && VAR_4 >= 0)\ndpy_cursor(s->ds,\nTEXTMODE_X(VAR_4),\nTEXTMODE_Y(VAR_4));",
"else\ndpy_cursor(s->ds, -1, -1);",
"s->VAR_4 = VAR_4;",
"s->cursor_start = s->cr[0xa];",
"s->cursor_end = s->cr[0xb];",
"}",
"src = (uint32_t *) s->vram_ptr + s->start_addr;",
"dst = VAR_1;",
"if (VAR_14) {",
"for (VAR_3 = 0; VAR_3 < VAR_10; src ++, dst ++, VAR_3 ++)",
"console_write_ch(dst, VMEM2CHTYPE(le32_to_cpu(*src)));",
"dpy_update(s->ds, 0, 0, VAR_8, VAR_9);",
"} else {",
"VAR_12 = 0;",
"for (VAR_3 = 0; VAR_3 < VAR_10; src ++, dst ++, VAR_3 ++) {",
"console_write_ch(&val, VMEM2CHTYPE(le32_to_cpu(*src)));",
"if (*dst != val) {",
"*dst = val;",
"VAR_12 = VAR_3;",
"break;",
"}",
"}",
"VAR_11 = VAR_3;",
"for (; VAR_3 < VAR_10; src ++, dst ++, VAR_3 ++) {",
"console_write_ch(&val, VMEM2CHTYPE(le32_to_cpu(*src)));",
"if (*dst != val) {",
"*dst = val;",
"VAR_12 = VAR_3;",
"}",
"}",
"if (VAR_11 <= VAR_12) {",
"VAR_3 = TEXTMODE_Y(VAR_11);",
"dpy_update(s->ds, 0, VAR_3, VAR_8, TEXTMODE_Y(VAR_12) - VAR_3 + 1);",
"}",
"}",
"return;",
"case GMODE_GRAPH:\nif (!VAR_14)\nreturn;",
"s->get_resolution(s, &VAR_8, &VAR_9);",
"snprintf(VAR_13, sizeof(VAR_13), \"%VAR_3 x %VAR_3 Graphic mode\",\nVAR_8, VAR_9);",
"break;",
"case GMODE_BLANK:\ndefault:\nif (!VAR_14)\nreturn;",
"snprintf(VAR_13, sizeof(VAR_13), \"VGA Blank mode\");",
"break;",
"}",
"s->last_width = 60;",
"s->last_height = VAR_9 = 3;",
"dpy_cursor(s->ds, -1, -1);",
"s->ds->surface->VAR_8 = s->last_width;",
"s->ds->surface->VAR_9 = VAR_9;",
"dpy_resize(s->ds);",
"for (dst = VAR_1, VAR_3 = 0; VAR_3 < s->last_width * VAR_9; VAR_3 ++)",
"console_write_ch(dst ++, ' ');",
"VAR_10 = strlen(VAR_13);",
"VAR_8 = (s->last_width - VAR_10) / 2;",
"dst = VAR_1 + s->last_width + VAR_8;",
"for (VAR_3 = 0; VAR_3 < VAR_10; VAR_3 ++)",
"console_write_ch(dst ++, 0x00200100 | VAR_13[VAR_3]);",
"dpy_update(s->ds, 0, 0, s->last_width, VAR_9);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20
],
[
21
],
[
22
],
[
23
],
[
24,
26
],
[
28
],
[
29
],
[
30,
31
],
[
32,
33
],
[
34
],
[
35
],
[
37
],
[
38
],
[
39,
40,
41
],
[
42
],
[
43
],
[
44
],
[
45
],
[
46,
47
],
[
48,
49
],
[
50
],
[
51
],
[
52,
53
],
[
54
],
[
55
],
[
56
],
[
57
],
[
58
],
[
59
],
[
60
],
[
61
],
[
62
],
[
63
],
[
64
],
[
66
],
[
67,
68,
69
],
[
70
],
[
71,
72,
73,
74
],
[
75,
76
],
[
77
],
[
78
],
[
79
],
[
80
],
[
81
],
[
82
],
[
83
],
[
84
],
[
85
],
[
86
],
[
87
],
[
88
],
[
89
],
[
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,
116
],
[
117
],
[
118,
119,
120,
121
],
[
122
],
[
123
],
[
124
],
[
126
],
[
127
],
[
128
],
[
129
],
[
130
],
[
131
],
[
132
],
[
133
],
[
134
],
[
135
],
[
136
],
[
137
],
[
138
],
[
139
],
[
140
]
]
|
13,646 | static int decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *pkt)
{
SANMVideoContext *ctx = avctx->priv_data;
int i, ret;
bytestream2_init(&ctx->gb, pkt->data, pkt->size);
if (ctx->output->data[0])
avctx->release_buffer(avctx, ctx->output);
if (!ctx->version) {
int to_store = 0;
while (bytestream2_get_bytes_left(&ctx->gb) >= 8) {
uint32_t sig, size;
int pos;
sig = bytestream2_get_be32u(&ctx->gb);
size = bytestream2_get_be32u(&ctx->gb);
pos = bytestream2_tell(&ctx->gb);
if (bytestream2_get_bytes_left(&ctx->gb) < size) {
av_log(avctx, AV_LOG_ERROR, "incorrect chunk size %d\n", size);
break;
}
switch (sig) {
case MKBETAG('N', 'P', 'A', 'L'):
if (size != 256 * 3) {
av_log(avctx, AV_LOG_ERROR, "incorrect palette block size %d\n",
size);
return AVERROR_INVALIDDATA;
}
for (i = 0; i < 256; i++)
ctx->pal[i] = 0xFF << 24 | bytestream2_get_be24u(&ctx->gb);
break;
case MKBETAG('F', 'O', 'B', 'J'):
if (size < 16)
return AVERROR_INVALIDDATA;
if (ret = process_frame_obj(ctx))
return ret;
break;
case MKBETAG('X', 'P', 'A', 'L'):
if (size == 6 || size == 4) {
uint8_t tmp[3];
int j;
for (i = 0; i < 256; i++) {
for (j = 0; j < 3; j++) {
int t = (ctx->pal[i] >> (16 - j * 8)) & 0xFF;
tmp[j] = av_clip_uint8((t * 129 + ctx->delta_pal[i * 3 + j]) >> 7);
}
ctx->pal[i] = 0xFF << 24 | AV_RB24(tmp);
}
} else {
if (size < 768 * 2 + 4) {
av_log(avctx, AV_LOG_ERROR, "incorrect palette change block size %d\n",
size);
return AVERROR_INVALIDDATA;
}
bytestream2_skipu(&ctx->gb, 4);
for (i = 0; i < 768; i++)
ctx->delta_pal[i] = bytestream2_get_le16u(&ctx->gb);
if (size >= 768 * 5 + 4) {
for (i = 0; i < 256; i++)
ctx->pal[i] = 0xFF << 24 | bytestream2_get_be24u(&ctx->gb);
} else {
memset(ctx->pal, 0, sizeof(ctx->pal));
}
}
break;
case MKBETAG('S', 'T', 'O', 'R'):
to_store = 1;
break;
case MKBETAG('F', 'T', 'C', 'H'):
memcpy(ctx->frm0, ctx->stored_frame, ctx->buf_size);
break;
default:
bytestream2_skip(&ctx->gb, size);
av_log(avctx, AV_LOG_DEBUG, "unknown/unsupported chunk %x\n", sig);
break;
}
bytestream2_seek(&ctx->gb, pos + size, SEEK_SET);
if (size & 1)
bytestream2_skip(&ctx->gb, 1);
}
if (to_store)
memcpy(ctx->stored_frame, ctx->frm0, ctx->buf_size);
if ((ret = copy_output(ctx, NULL)))
return ret;
memcpy(ctx->output->data[1], ctx->pal, 1024);
} else {
SANMFrameHeader header;
if ((ret = read_frame_header(ctx, &header)))
return ret;
ctx->rotate_code = header.rotate_code;
if ((ctx->output->key_frame = !header.seq_num)) {
ctx->output->pict_type = AV_PICTURE_TYPE_I;
fill_frame(ctx->frm1, ctx->npixels, header.bg_color);
fill_frame(ctx->frm2, ctx->npixels, header.bg_color);
} else {
ctx->output->pict_type = AV_PICTURE_TYPE_P;
}
if (header.codec < FF_ARRAY_ELEMS(v1_decoders)) {
if ((ret = v1_decoders[header.codec](ctx))) {
av_log(avctx, AV_LOG_ERROR,
"subcodec %d: error decoding frame\n", header.codec);
return ret;
}
} else {
av_log_ask_for_sample(avctx, "subcodec %d is not implemented\n",
header.codec);
return AVERROR_PATCHWELCOME;
}
if ((ret = copy_output(ctx, &header)))
return ret;
}
if (ctx->rotate_code)
rotate_bufs(ctx, ctx->rotate_code);
*got_frame_ptr = 1;
*(AVFrame*)data = *ctx->output;
return pkt->size;
}
| true | FFmpeg | b12d92efd6c0d48665383a9baecc13e7ebbd8a22 | static int decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *pkt)
{
SANMVideoContext *ctx = avctx->priv_data;
int i, ret;
bytestream2_init(&ctx->gb, pkt->data, pkt->size);
if (ctx->output->data[0])
avctx->release_buffer(avctx, ctx->output);
if (!ctx->version) {
int to_store = 0;
while (bytestream2_get_bytes_left(&ctx->gb) >= 8) {
uint32_t sig, size;
int pos;
sig = bytestream2_get_be32u(&ctx->gb);
size = bytestream2_get_be32u(&ctx->gb);
pos = bytestream2_tell(&ctx->gb);
if (bytestream2_get_bytes_left(&ctx->gb) < size) {
av_log(avctx, AV_LOG_ERROR, "incorrect chunk size %d\n", size);
break;
}
switch (sig) {
case MKBETAG('N', 'P', 'A', 'L'):
if (size != 256 * 3) {
av_log(avctx, AV_LOG_ERROR, "incorrect palette block size %d\n",
size);
return AVERROR_INVALIDDATA;
}
for (i = 0; i < 256; i++)
ctx->pal[i] = 0xFF << 24 | bytestream2_get_be24u(&ctx->gb);
break;
case MKBETAG('F', 'O', 'B', 'J'):
if (size < 16)
return AVERROR_INVALIDDATA;
if (ret = process_frame_obj(ctx))
return ret;
break;
case MKBETAG('X', 'P', 'A', 'L'):
if (size == 6 || size == 4) {
uint8_t tmp[3];
int j;
for (i = 0; i < 256; i++) {
for (j = 0; j < 3; j++) {
int t = (ctx->pal[i] >> (16 - j * 8)) & 0xFF;
tmp[j] = av_clip_uint8((t * 129 + ctx->delta_pal[i * 3 + j]) >> 7);
}
ctx->pal[i] = 0xFF << 24 | AV_RB24(tmp);
}
} else {
if (size < 768 * 2 + 4) {
av_log(avctx, AV_LOG_ERROR, "incorrect palette change block size %d\n",
size);
return AVERROR_INVALIDDATA;
}
bytestream2_skipu(&ctx->gb, 4);
for (i = 0; i < 768; i++)
ctx->delta_pal[i] = bytestream2_get_le16u(&ctx->gb);
if (size >= 768 * 5 + 4) {
for (i = 0; i < 256; i++)
ctx->pal[i] = 0xFF << 24 | bytestream2_get_be24u(&ctx->gb);
} else {
memset(ctx->pal, 0, sizeof(ctx->pal));
}
}
break;
case MKBETAG('S', 'T', 'O', 'R'):
to_store = 1;
break;
case MKBETAG('F', 'T', 'C', 'H'):
memcpy(ctx->frm0, ctx->stored_frame, ctx->buf_size);
break;
default:
bytestream2_skip(&ctx->gb, size);
av_log(avctx, AV_LOG_DEBUG, "unknown/unsupported chunk %x\n", sig);
break;
}
bytestream2_seek(&ctx->gb, pos + size, SEEK_SET);
if (size & 1)
bytestream2_skip(&ctx->gb, 1);
}
if (to_store)
memcpy(ctx->stored_frame, ctx->frm0, ctx->buf_size);
if ((ret = copy_output(ctx, NULL)))
return ret;
memcpy(ctx->output->data[1], ctx->pal, 1024);
} else {
SANMFrameHeader header;
if ((ret = read_frame_header(ctx, &header)))
return ret;
ctx->rotate_code = header.rotate_code;
if ((ctx->output->key_frame = !header.seq_num)) {
ctx->output->pict_type = AV_PICTURE_TYPE_I;
fill_frame(ctx->frm1, ctx->npixels, header.bg_color);
fill_frame(ctx->frm2, ctx->npixels, header.bg_color);
} else {
ctx->output->pict_type = AV_PICTURE_TYPE_P;
}
if (header.codec < FF_ARRAY_ELEMS(v1_decoders)) {
if ((ret = v1_decoders[header.codec](ctx))) {
av_log(avctx, AV_LOG_ERROR,
"subcodec %d: error decoding frame\n", header.codec);
return ret;
}
} else {
av_log_ask_for_sample(avctx, "subcodec %d is not implemented\n",
header.codec);
return AVERROR_PATCHWELCOME;
}
if ((ret = copy_output(ctx, &header)))
return ret;
}
if (ctx->rotate_code)
rotate_bufs(ctx, ctx->rotate_code);
*got_frame_ptr = 1;
*(AVFrame*)data = *ctx->output;
return pkt->size;
}
| {
"code": [
" ctx->pal[i] = 0xFF << 24 | bytestream2_get_be24u(&ctx->gb);",
" ctx->pal[i] = 0xFF << 24 | AV_RB24(tmp);",
" ctx->pal[i] = 0xFF << 24 | bytestream2_get_be24u(&ctx->gb);"
],
"line_no": [
67,
103,
129
]
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{
SANMVideoContext *ctx = VAR_0->priv_data;
int VAR_4, VAR_5;
bytestream2_init(&ctx->gb, VAR_3->VAR_1, VAR_3->size);
if (ctx->output->VAR_1[0])
VAR_0->release_buffer(VAR_0, ctx->output);
if (!ctx->version) {
int VAR_6 = 0;
while (bytestream2_get_bytes_left(&ctx->gb) >= 8) {
uint32_t sig, size;
int VAR_7;
sig = bytestream2_get_be32u(&ctx->gb);
size = bytestream2_get_be32u(&ctx->gb);
VAR_7 = bytestream2_tell(&ctx->gb);
if (bytestream2_get_bytes_left(&ctx->gb) < size) {
av_log(VAR_0, AV_LOG_ERROR, "incorrect chunk size %d\n", size);
break;
}
switch (sig) {
case MKBETAG('N', 'P', 'A', 'L'):
if (size != 256 * 3) {
av_log(VAR_0, AV_LOG_ERROR, "incorrect palette block size %d\n",
size);
return AVERROR_INVALIDDATA;
}
for (VAR_4 = 0; VAR_4 < 256; VAR_4++)
ctx->pal[VAR_4] = 0xFF << 24 | bytestream2_get_be24u(&ctx->gb);
break;
case MKBETAG('F', 'O', 'B', 'J'):
if (size < 16)
return AVERROR_INVALIDDATA;
if (VAR_5 = process_frame_obj(ctx))
return VAR_5;
break;
case MKBETAG('X', 'P', 'A', 'L'):
if (size == 6 || size == 4) {
uint8_t tmp[3];
int VAR_8;
for (VAR_4 = 0; VAR_4 < 256; VAR_4++) {
for (VAR_8 = 0; VAR_8 < 3; VAR_8++) {
int VAR_9 = (ctx->pal[VAR_4] >> (16 - VAR_8 * 8)) & 0xFF;
tmp[VAR_8] = av_clip_uint8((VAR_9 * 129 + ctx->delta_pal[VAR_4 * 3 + VAR_8]) >> 7);
}
ctx->pal[VAR_4] = 0xFF << 24 | AV_RB24(tmp);
}
} else {
if (size < 768 * 2 + 4) {
av_log(VAR_0, AV_LOG_ERROR, "incorrect palette change block size %d\n",
size);
return AVERROR_INVALIDDATA;
}
bytestream2_skipu(&ctx->gb, 4);
for (VAR_4 = 0; VAR_4 < 768; VAR_4++)
ctx->delta_pal[VAR_4] = bytestream2_get_le16u(&ctx->gb);
if (size >= 768 * 5 + 4) {
for (VAR_4 = 0; VAR_4 < 256; VAR_4++)
ctx->pal[VAR_4] = 0xFF << 24 | bytestream2_get_be24u(&ctx->gb);
} else {
memset(ctx->pal, 0, sizeof(ctx->pal));
}
}
break;
case MKBETAG('S', 'T', 'O', 'R'):
VAR_6 = 1;
break;
case MKBETAG('F', 'T', 'C', 'H'):
memcpy(ctx->frm0, ctx->stored_frame, ctx->buf_size);
break;
default:
bytestream2_skip(&ctx->gb, size);
av_log(VAR_0, AV_LOG_DEBUG, "unknown/unsupported chunk %x\n", sig);
break;
}
bytestream2_seek(&ctx->gb, VAR_7 + size, SEEK_SET);
if (size & 1)
bytestream2_skip(&ctx->gb, 1);
}
if (VAR_6)
memcpy(ctx->stored_frame, ctx->frm0, ctx->buf_size);
if ((VAR_5 = copy_output(ctx, NULL)))
return VAR_5;
memcpy(ctx->output->VAR_1[1], ctx->pal, 1024);
} else {
SANMFrameHeader header;
if ((VAR_5 = read_frame_header(ctx, &header)))
return VAR_5;
ctx->rotate_code = header.rotate_code;
if ((ctx->output->key_frame = !header.seq_num)) {
ctx->output->pict_type = AV_PICTURE_TYPE_I;
fill_frame(ctx->frm1, ctx->npixels, header.bg_color);
fill_frame(ctx->frm2, ctx->npixels, header.bg_color);
} else {
ctx->output->pict_type = AV_PICTURE_TYPE_P;
}
if (header.codec < FF_ARRAY_ELEMS(v1_decoders)) {
if ((VAR_5 = v1_decoders[header.codec](ctx))) {
av_log(VAR_0, AV_LOG_ERROR,
"subcodec %d: error decoding frame\n", header.codec);
return VAR_5;
}
} else {
av_log_ask_for_sample(VAR_0, "subcodec %d is not implemented\n",
header.codec);
return AVERROR_PATCHWELCOME;
}
if ((VAR_5 = copy_output(ctx, &header)))
return VAR_5;
}
if (ctx->rotate_code)
rotate_bufs(ctx, ctx->rotate_code);
*VAR_2 = 1;
*(AVFrame*)VAR_1 = *ctx->output;
return VAR_3->size;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{",
"SANMVideoContext *ctx = VAR_0->priv_data;",
"int VAR_4, VAR_5;",
"bytestream2_init(&ctx->gb, VAR_3->VAR_1, VAR_3->size);",
"if (ctx->output->VAR_1[0])\nVAR_0->release_buffer(VAR_0, ctx->output);",
"if (!ctx->version) {",
"int VAR_6 = 0;",
"while (bytestream2_get_bytes_left(&ctx->gb) >= 8) {",
"uint32_t sig, size;",
"int VAR_7;",
"sig = bytestream2_get_be32u(&ctx->gb);",
"size = bytestream2_get_be32u(&ctx->gb);",
"VAR_7 = bytestream2_tell(&ctx->gb);",
"if (bytestream2_get_bytes_left(&ctx->gb) < size) {",
"av_log(VAR_0, AV_LOG_ERROR, \"incorrect chunk size %d\\n\", size);",
"break;",
"}",
"switch (sig) {",
"case MKBETAG('N', 'P', 'A', 'L'):\nif (size != 256 * 3) {",
"av_log(VAR_0, AV_LOG_ERROR, \"incorrect palette block size %d\\n\",\nsize);",
"return AVERROR_INVALIDDATA;",
"}",
"for (VAR_4 = 0; VAR_4 < 256; VAR_4++)",
"ctx->pal[VAR_4] = 0xFF << 24 | bytestream2_get_be24u(&ctx->gb);",
"break;",
"case MKBETAG('F', 'O', 'B', 'J'):\nif (size < 16)\nreturn AVERROR_INVALIDDATA;",
"if (VAR_5 = process_frame_obj(ctx))\nreturn VAR_5;",
"break;",
"case MKBETAG('X', 'P', 'A', 'L'):\nif (size == 6 || size == 4) {",
"uint8_t tmp[3];",
"int VAR_8;",
"for (VAR_4 = 0; VAR_4 < 256; VAR_4++) {",
"for (VAR_8 = 0; VAR_8 < 3; VAR_8++) {",
"int VAR_9 = (ctx->pal[VAR_4] >> (16 - VAR_8 * 8)) & 0xFF;",
"tmp[VAR_8] = av_clip_uint8((VAR_9 * 129 + ctx->delta_pal[VAR_4 * 3 + VAR_8]) >> 7);",
"}",
"ctx->pal[VAR_4] = 0xFF << 24 | AV_RB24(tmp);",
"}",
"} else {",
"if (size < 768 * 2 + 4) {",
"av_log(VAR_0, AV_LOG_ERROR, \"incorrect palette change block size %d\\n\",\nsize);",
"return AVERROR_INVALIDDATA;",
"}",
"bytestream2_skipu(&ctx->gb, 4);",
"for (VAR_4 = 0; VAR_4 < 768; VAR_4++)",
"ctx->delta_pal[VAR_4] = bytestream2_get_le16u(&ctx->gb);",
"if (size >= 768 * 5 + 4) {",
"for (VAR_4 = 0; VAR_4 < 256; VAR_4++)",
"ctx->pal[VAR_4] = 0xFF << 24 | bytestream2_get_be24u(&ctx->gb);",
"} else {",
"memset(ctx->pal, 0, sizeof(ctx->pal));",
"}",
"}",
"break;",
"case MKBETAG('S', 'T', 'O', 'R'):\nVAR_6 = 1;",
"break;",
"case MKBETAG('F', 'T', 'C', 'H'):\nmemcpy(ctx->frm0, ctx->stored_frame, ctx->buf_size);",
"break;",
"default:\nbytestream2_skip(&ctx->gb, size);",
"av_log(VAR_0, AV_LOG_DEBUG, \"unknown/unsupported chunk %x\\n\", sig);",
"break;",
"}",
"bytestream2_seek(&ctx->gb, VAR_7 + size, SEEK_SET);",
"if (size & 1)\nbytestream2_skip(&ctx->gb, 1);",
"}",
"if (VAR_6)\nmemcpy(ctx->stored_frame, ctx->frm0, ctx->buf_size);",
"if ((VAR_5 = copy_output(ctx, NULL)))\nreturn VAR_5;",
"memcpy(ctx->output->VAR_1[1], ctx->pal, 1024);",
"} else {",
"SANMFrameHeader header;",
"if ((VAR_5 = read_frame_header(ctx, &header)))\nreturn VAR_5;",
"ctx->rotate_code = header.rotate_code;",
"if ((ctx->output->key_frame = !header.seq_num)) {",
"ctx->output->pict_type = AV_PICTURE_TYPE_I;",
"fill_frame(ctx->frm1, ctx->npixels, header.bg_color);",
"fill_frame(ctx->frm2, ctx->npixels, header.bg_color);",
"} else {",
"ctx->output->pict_type = AV_PICTURE_TYPE_P;",
"}",
"if (header.codec < FF_ARRAY_ELEMS(v1_decoders)) {",
"if ((VAR_5 = v1_decoders[header.codec](ctx))) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"subcodec %d: error decoding frame\\n\", header.codec);",
"return VAR_5;",
"}",
"} else {",
"av_log_ask_for_sample(VAR_0, \"subcodec %d is not implemented\\n\",\nheader.codec);",
"return AVERROR_PATCHWELCOME;",
"}",
"if ((VAR_5 = copy_output(ctx, &header)))\nreturn VAR_5;",
"}",
"if (ctx->rotate_code)\nrotate_bufs(ctx, ctx->rotate_code);",
"*VAR_2 = 1;",
"*(AVFrame*)VAR_1 = *ctx->output;",
"return VAR_3->size;",
"}"
]
| [
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,
1,
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
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71,
73,
75
],
[
77,
79
],
[
81
],
[
83,
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111,
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141,
143
],
[
145
],
[
147,
149
],
[
151
],
[
153,
155
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167,
169
],
[
171
],
[
173,
175
],
[
177,
179
],
[
181
],
[
183
],
[
185
],
[
189,
191
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
213
],
[
215
],
[
217,
219
],
[
221
],
[
223
],
[
225
],
[
227,
229
],
[
231
],
[
233
],
[
237,
239
],
[
241
],
[
243,
245
],
[
249
],
[
251
],
[
255
],
[
257
]
]
|
13,647 | static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset,
ram_addr_t *ram_addr_abs)
{
RAMBlock *block = NULL;
qemu_mutex_lock(&rs->src_page_req_mutex);
if (!QSIMPLEQ_EMPTY(&rs->src_page_requests)) {
struct RAMSrcPageRequest *entry =
QSIMPLEQ_FIRST(&rs->src_page_requests);
block = entry->rb;
*offset = entry->offset;
*ram_addr_abs = (entry->offset + entry->rb->offset) &
TARGET_PAGE_MASK;
if (entry->len > TARGET_PAGE_SIZE) {
entry->len -= TARGET_PAGE_SIZE;
entry->offset += TARGET_PAGE_SIZE;
} else {
memory_region_unref(block->mr);
QSIMPLEQ_REMOVE_HEAD(&rs->src_page_requests, next_req);
g_free(entry);
}
}
qemu_mutex_unlock(&rs->src_page_req_mutex);
return block;
}
| true | qemu | 06b106889a09277617fc8c542397a9f595ee605a | static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset,
ram_addr_t *ram_addr_abs)
{
RAMBlock *block = NULL;
qemu_mutex_lock(&rs->src_page_req_mutex);
if (!QSIMPLEQ_EMPTY(&rs->src_page_requests)) {
struct RAMSrcPageRequest *entry =
QSIMPLEQ_FIRST(&rs->src_page_requests);
block = entry->rb;
*offset = entry->offset;
*ram_addr_abs = (entry->offset + entry->rb->offset) &
TARGET_PAGE_MASK;
if (entry->len > TARGET_PAGE_SIZE) {
entry->len -= TARGET_PAGE_SIZE;
entry->offset += TARGET_PAGE_SIZE;
} else {
memory_region_unref(block->mr);
QSIMPLEQ_REMOVE_HEAD(&rs->src_page_requests, next_req);
g_free(entry);
}
}
qemu_mutex_unlock(&rs->src_page_req_mutex);
return block;
}
| {
"code": [
" ram_addr_t *ram_addr_abs)",
" *ram_addr_abs = (entry->offset + entry->rb->offset) &",
" TARGET_PAGE_MASK;"
],
"line_no": [
3,
23,
25
]
} | static RAMBlock *FUNC_0(RAMState *rs, ram_addr_t *offset,
ram_addr_t *ram_addr_abs)
{
RAMBlock *block = NULL;
qemu_mutex_lock(&rs->src_page_req_mutex);
if (!QSIMPLEQ_EMPTY(&rs->src_page_requests)) {
struct RAMSrcPageRequest *VAR_0 =
QSIMPLEQ_FIRST(&rs->src_page_requests);
block = VAR_0->rb;
*offset = VAR_0->offset;
*ram_addr_abs = (VAR_0->offset + VAR_0->rb->offset) &
TARGET_PAGE_MASK;
if (VAR_0->len > TARGET_PAGE_SIZE) {
VAR_0->len -= TARGET_PAGE_SIZE;
VAR_0->offset += TARGET_PAGE_SIZE;
} else {
memory_region_unref(block->mr);
QSIMPLEQ_REMOVE_HEAD(&rs->src_page_requests, next_req);
g_free(VAR_0);
}
}
qemu_mutex_unlock(&rs->src_page_req_mutex);
return block;
}
| [
"static RAMBlock *FUNC_0(RAMState *rs, ram_addr_t *offset,\nram_addr_t *ram_addr_abs)\n{",
"RAMBlock *block = NULL;",
"qemu_mutex_lock(&rs->src_page_req_mutex);",
"if (!QSIMPLEQ_EMPTY(&rs->src_page_requests)) {",
"struct RAMSrcPageRequest *VAR_0 =\nQSIMPLEQ_FIRST(&rs->src_page_requests);",
"block = VAR_0->rb;",
"*offset = VAR_0->offset;",
"*ram_addr_abs = (VAR_0->offset + VAR_0->rb->offset) &\nTARGET_PAGE_MASK;",
"if (VAR_0->len > TARGET_PAGE_SIZE) {",
"VAR_0->len -= TARGET_PAGE_SIZE;",
"VAR_0->offset += TARGET_PAGE_SIZE;",
"} else {",
"memory_region_unref(block->mr);",
"QSIMPLEQ_REMOVE_HEAD(&rs->src_page_requests, next_req);",
"g_free(VAR_0);",
"}",
"}",
"qemu_mutex_unlock(&rs->src_page_req_mutex);",
"return block;",
"}"
]
| [
1,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23,
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
]
]
|
13,650 | static int bands_dist(OpusPsyContext *s, CeltFrame *f, float *total_dist)
{
int i, tdist = 0.0f;
OpusRangeCoder dump;
ff_opus_rc_enc_init(&dump);
ff_celt_enc_bitalloc(f, &dump);
for (i = 0; i < CELT_MAX_BANDS; i++) {
float bits = 0.0f;
float dist = f->pvq->band_cost(f->pvq, f, &dump, i, &bits, s->lambda);
tdist += dist;
}
*total_dist = tdist;
return 0;
}
| false | FFmpeg | 7b46add7257628bffac96d3002308d1f9e1ed172 | static int bands_dist(OpusPsyContext *s, CeltFrame *f, float *total_dist)
{
int i, tdist = 0.0f;
OpusRangeCoder dump;
ff_opus_rc_enc_init(&dump);
ff_celt_enc_bitalloc(f, &dump);
for (i = 0; i < CELT_MAX_BANDS; i++) {
float bits = 0.0f;
float dist = f->pvq->band_cost(f->pvq, f, &dump, i, &bits, s->lambda);
tdist += dist;
}
*total_dist = tdist;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(OpusPsyContext *VAR_0, CeltFrame *VAR_1, float *VAR_2)
{
int VAR_3, VAR_4 = 0.0f;
OpusRangeCoder dump;
ff_opus_rc_enc_init(&dump);
ff_celt_enc_bitalloc(VAR_1, &dump);
for (VAR_3 = 0; VAR_3 < CELT_MAX_BANDS; VAR_3++) {
float bits = 0.0f;
float dist = VAR_1->pvq->band_cost(VAR_1->pvq, VAR_1, &dump, VAR_3, &bits, VAR_0->lambda);
VAR_4 += dist;
}
*VAR_2 = VAR_4;
return 0;
}
| [
"static int FUNC_0(OpusPsyContext *VAR_0, CeltFrame *VAR_1, float *VAR_2)\n{",
"int VAR_3, VAR_4 = 0.0f;",
"OpusRangeCoder dump;",
"ff_opus_rc_enc_init(&dump);",
"ff_celt_enc_bitalloc(VAR_1, &dump);",
"for (VAR_3 = 0; VAR_3 < CELT_MAX_BANDS; VAR_3++) {",
"float bits = 0.0f;",
"float dist = VAR_1->pvq->band_cost(VAR_1->pvq, VAR_1, &dump, VAR_3, &bits, VAR_0->lambda);",
"VAR_4 += dist;",
"}",
"*VAR_2 = VAR_4;",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
33
],
[
35
]
]
|
13,651 | static inline void apply_motion_generic(RoqContext *ri, int x, int y, int deltax,
int deltay, int sz)
{
int mx, my, cp;
mx = x + deltax;
my = y + deltay;
/* check MV against frame boundaries */
if ((mx < 0) || (mx > ri->width - sz) ||
(my < 0) || (my > ri->height - sz)) {
av_log(ri->avctx, AV_LOG_ERROR, "motion vector out of bounds: MV = (%d, %d), boundaries = (0, 0, %d, %d)\n",
mx, my, ri->width, ri->height);
return;
}
if (ri->last_frame->data[0] == NULL) {
av_log(ri->avctx, AV_LOG_ERROR, "Invalid decode type. Invalid header?\n");
return;
}
for(cp = 0; cp < 3; cp++) {
int outstride = ri->current_frame->linesize[cp];
int instride = ri->last_frame ->linesize[cp];
block_copy(ri->current_frame->data[cp] + y*outstride + x,
ri->last_frame->data[cp] + my*instride + mx,
outstride, instride, sz);
}
}
| false | FFmpeg | f929ab0569ff31ed5a59b0b0adb7ce09df3fca39 | static inline void apply_motion_generic(RoqContext *ri, int x, int y, int deltax,
int deltay, int sz)
{
int mx, my, cp;
mx = x + deltax;
my = y + deltay;
if ((mx < 0) || (mx > ri->width - sz) ||
(my < 0) || (my > ri->height - sz)) {
av_log(ri->avctx, AV_LOG_ERROR, "motion vector out of bounds: MV = (%d, %d), boundaries = (0, 0, %d, %d)\n",
mx, my, ri->width, ri->height);
return;
}
if (ri->last_frame->data[0] == NULL) {
av_log(ri->avctx, AV_LOG_ERROR, "Invalid decode type. Invalid header?\n");
return;
}
for(cp = 0; cp < 3; cp++) {
int outstride = ri->current_frame->linesize[cp];
int instride = ri->last_frame ->linesize[cp];
block_copy(ri->current_frame->data[cp] + y*outstride + x,
ri->last_frame->data[cp] + my*instride + mx,
outstride, instride, sz);
}
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(RoqContext *VAR_0, int VAR_1, int VAR_2, int VAR_3,
int VAR_4, int VAR_5)
{
int VAR_6, VAR_7, VAR_8;
VAR_6 = VAR_1 + VAR_3;
VAR_7 = VAR_2 + VAR_4;
if ((VAR_6 < 0) || (VAR_6 > VAR_0->width - VAR_5) ||
(VAR_7 < 0) || (VAR_7 > VAR_0->height - VAR_5)) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "motion vector out of bounds: MV = (%d, %d), boundaries = (0, 0, %d, %d)\n",
VAR_6, VAR_7, VAR_0->width, VAR_0->height);
return;
}
if (VAR_0->last_frame->data[0] == NULL) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid decode type. Invalid header?\n");
return;
}
for(VAR_8 = 0; VAR_8 < 3; VAR_8++) {
int VAR_9 = VAR_0->current_frame->linesize[VAR_8];
int VAR_10 = VAR_0->last_frame ->linesize[VAR_8];
block_copy(VAR_0->current_frame->data[VAR_8] + VAR_2*VAR_9 + VAR_1,
VAR_0->last_frame->data[VAR_8] + VAR_7*VAR_10 + VAR_6,
VAR_9, VAR_10, VAR_5);
}
}
| [
"static inline void FUNC_0(RoqContext *VAR_0, int VAR_1, int VAR_2, int VAR_3,\nint VAR_4, int VAR_5)\n{",
"int VAR_6, VAR_7, VAR_8;",
"VAR_6 = VAR_1 + VAR_3;",
"VAR_7 = VAR_2 + VAR_4;",
"if ((VAR_6 < 0) || (VAR_6 > VAR_0->width - VAR_5) ||\n(VAR_7 < 0) || (VAR_7 > VAR_0->height - VAR_5)) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"motion vector out of bounds: MV = (%d, %d), boundaries = (0, 0, %d, %d)\\n\",\nVAR_6, VAR_7, VAR_0->width, VAR_0->height);",
"return;",
"}",
"if (VAR_0->last_frame->data[0] == NULL) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Invalid decode type. Invalid header?\\n\");",
"return;",
"}",
"for(VAR_8 = 0; VAR_8 < 3; VAR_8++) {",
"int VAR_9 = VAR_0->current_frame->linesize[VAR_8];",
"int VAR_10 = VAR_0->last_frame ->linesize[VAR_8];",
"block_copy(VAR_0->current_frame->data[VAR_8] + VAR_2*VAR_9 + VAR_1,\nVAR_0->last_frame->data[VAR_8] + VAR_7*VAR_10 + VAR_6,\nVAR_9, VAR_10, VAR_5);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
19,
21
],
[
23,
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49,
51,
53
],
[
55
],
[
57
]
]
|
13,652 | QGuestAllocator *pc_alloc_init(void)
{
PCAlloc *s = g_malloc0(sizeof(*s));
uint64_t ram_size;
QFWCFG *fw_cfg = pc_fw_cfg_init();
s->alloc.alloc = pc_alloc;
s->alloc.free = pc_free;
ram_size = qfw_cfg_get_u64(fw_cfg, FW_CFG_RAM_SIZE);
/* Start at 1MB */
s->start = 1 << 20;
/* Respect PCI hole */
s->end = MIN(ram_size, 0xE0000000);
return &s->alloc;
} | true | qemu | f3cdcbaee16d32b52d5015a8b1e8ddf5a27f7089 | QGuestAllocator *pc_alloc_init(void)
{
PCAlloc *s = g_malloc0(sizeof(*s));
uint64_t ram_size;
QFWCFG *fw_cfg = pc_fw_cfg_init();
s->alloc.alloc = pc_alloc;
s->alloc.free = pc_free;
ram_size = qfw_cfg_get_u64(fw_cfg, FW_CFG_RAM_SIZE);
s->start = 1 << 20;
s->end = MIN(ram_size, 0xE0000000);
return &s->alloc;
} | {
"code": [],
"line_no": []
} | QGuestAllocator *FUNC_0(void)
{
PCAlloc *s = g_malloc0(sizeof(*s));
uint64_t ram_size;
QFWCFG *fw_cfg = pc_fw_cfg_init();
s->alloc.alloc = pc_alloc;
s->alloc.free = pc_free;
ram_size = qfw_cfg_get_u64(fw_cfg, FW_CFG_RAM_SIZE);
s->start = 1 << 20;
s->end = MIN(ram_size, 0xE0000000);
return &s->alloc;
} | [
"QGuestAllocator *FUNC_0(void)\n{",
"PCAlloc *s = g_malloc0(sizeof(*s));",
"uint64_t ram_size;",
"QFWCFG *fw_cfg = pc_fw_cfg_init();",
"s->alloc.alloc = pc_alloc;",
"s->alloc.free = pc_free;",
"ram_size = qfw_cfg_get_u64(fw_cfg, FW_CFG_RAM_SIZE);",
"s->start = 1 << 20;",
"s->end = MIN(ram_size, 0xE0000000);",
"return &s->alloc;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
10
],
[
12
],
[
13
],
[
14
]
]
|
13,653 | static int update_error_limit(WavpackFrameContext *ctx)
{
int i, br[2], sl[2];
for (i = 0; i <= ctx->stereo_in; i++) {
if (ctx->ch[i].bitrate_acc > UINT_MAX - ctx->ch[i].bitrate_delta)
return AVERROR_INVALIDDATA;
ctx->ch[i].bitrate_acc += ctx->ch[i].bitrate_delta;
br[i] = ctx->ch[i].bitrate_acc >> 16;
sl[i] = LEVEL_DECAY(ctx->ch[i].slow_level);
}
if (ctx->stereo_in && ctx->hybrid_bitrate) {
int balance = (sl[1] - sl[0] + br[1] + 1) >> 1;
if (balance > br[0]) {
br[1] = br[0] << 1;
br[0] = 0;
} else if (-balance > br[0]) {
br[0] <<= 1;
br[1] = 0;
} else {
br[1] = br[0] + balance;
br[0] = br[0] - balance;
}
}
for (i = 0; i <= ctx->stereo_in; i++) {
if (ctx->hybrid_bitrate) {
if (sl[i] - br[i] > -0x100)
ctx->ch[i].error_limit = wp_exp2(sl[i] - br[i] + 0x100);
else
ctx->ch[i].error_limit = 0;
} else {
ctx->ch[i].error_limit = wp_exp2(br[i]);
}
}
return 0;
}
| true | FFmpeg | ea71a48c7e8a76ee447fa518cca087df9288288d | static int update_error_limit(WavpackFrameContext *ctx)
{
int i, br[2], sl[2];
for (i = 0; i <= ctx->stereo_in; i++) {
if (ctx->ch[i].bitrate_acc > UINT_MAX - ctx->ch[i].bitrate_delta)
return AVERROR_INVALIDDATA;
ctx->ch[i].bitrate_acc += ctx->ch[i].bitrate_delta;
br[i] = ctx->ch[i].bitrate_acc >> 16;
sl[i] = LEVEL_DECAY(ctx->ch[i].slow_level);
}
if (ctx->stereo_in && ctx->hybrid_bitrate) {
int balance = (sl[1] - sl[0] + br[1] + 1) >> 1;
if (balance > br[0]) {
br[1] = br[0] << 1;
br[0] = 0;
} else if (-balance > br[0]) {
br[0] <<= 1;
br[1] = 0;
} else {
br[1] = br[0] + balance;
br[0] = br[0] - balance;
}
}
for (i = 0; i <= ctx->stereo_in; i++) {
if (ctx->hybrid_bitrate) {
if (sl[i] - br[i] > -0x100)
ctx->ch[i].error_limit = wp_exp2(sl[i] - br[i] + 0x100);
else
ctx->ch[i].error_limit = 0;
} else {
ctx->ch[i].error_limit = wp_exp2(br[i]);
}
}
return 0;
}
| {
"code": [
" br[1] = br[0] << 1;",
" br[0] <<= 1;"
],
"line_no": [
29,
35
]
} | static int FUNC_0(WavpackFrameContext *VAR_0)
{
int VAR_1, VAR_2[2], VAR_3[2];
for (VAR_1 = 0; VAR_1 <= VAR_0->stereo_in; VAR_1++) {
if (VAR_0->ch[VAR_1].bitrate_acc > UINT_MAX - VAR_0->ch[VAR_1].bitrate_delta)
return AVERROR_INVALIDDATA;
VAR_0->ch[VAR_1].bitrate_acc += VAR_0->ch[VAR_1].bitrate_delta;
VAR_2[VAR_1] = VAR_0->ch[VAR_1].bitrate_acc >> 16;
VAR_3[VAR_1] = LEVEL_DECAY(VAR_0->ch[VAR_1].slow_level);
}
if (VAR_0->stereo_in && VAR_0->hybrid_bitrate) {
int VAR_4 = (VAR_3[1] - VAR_3[0] + VAR_2[1] + 1) >> 1;
if (VAR_4 > VAR_2[0]) {
VAR_2[1] = VAR_2[0] << 1;
VAR_2[0] = 0;
} else if (-VAR_4 > VAR_2[0]) {
VAR_2[0] <<= 1;
VAR_2[1] = 0;
} else {
VAR_2[1] = VAR_2[0] + VAR_4;
VAR_2[0] = VAR_2[0] - VAR_4;
}
}
for (VAR_1 = 0; VAR_1 <= VAR_0->stereo_in; VAR_1++) {
if (VAR_0->hybrid_bitrate) {
if (VAR_3[VAR_1] - VAR_2[VAR_1] > -0x100)
VAR_0->ch[VAR_1].error_limit = wp_exp2(VAR_3[VAR_1] - VAR_2[VAR_1] + 0x100);
else
VAR_0->ch[VAR_1].error_limit = 0;
} else {
VAR_0->ch[VAR_1].error_limit = wp_exp2(VAR_2[VAR_1]);
}
}
return 0;
}
| [
"static int FUNC_0(WavpackFrameContext *VAR_0)\n{",
"int VAR_1, VAR_2[2], VAR_3[2];",
"for (VAR_1 = 0; VAR_1 <= VAR_0->stereo_in; VAR_1++) {",
"if (VAR_0->ch[VAR_1].bitrate_acc > UINT_MAX - VAR_0->ch[VAR_1].bitrate_delta)\nreturn AVERROR_INVALIDDATA;",
"VAR_0->ch[VAR_1].bitrate_acc += VAR_0->ch[VAR_1].bitrate_delta;",
"VAR_2[VAR_1] = VAR_0->ch[VAR_1].bitrate_acc >> 16;",
"VAR_3[VAR_1] = LEVEL_DECAY(VAR_0->ch[VAR_1].slow_level);",
"}",
"if (VAR_0->stereo_in && VAR_0->hybrid_bitrate) {",
"int VAR_4 = (VAR_3[1] - VAR_3[0] + VAR_2[1] + 1) >> 1;",
"if (VAR_4 > VAR_2[0]) {",
"VAR_2[1] = VAR_2[0] << 1;",
"VAR_2[0] = 0;",
"} else if (-VAR_4 > VAR_2[0]) {",
"VAR_2[0] <<= 1;",
"VAR_2[1] = 0;",
"} else {",
"VAR_2[1] = VAR_2[0] + VAR_4;",
"VAR_2[0] = VAR_2[0] - VAR_4;",
"}",
"}",
"for (VAR_1 = 0; VAR_1 <= VAR_0->stereo_in; VAR_1++) {",
"if (VAR_0->hybrid_bitrate) {",
"if (VAR_3[VAR_1] - VAR_2[VAR_1] > -0x100)\nVAR_0->ch[VAR_1].error_limit = wp_exp2(VAR_3[VAR_1] - VAR_2[VAR_1] + 0x100);",
"else\nVAR_0->ch[VAR_1].error_limit = 0;",
"} else {",
"VAR_0->ch[VAR_1].error_limit = wp_exp2(VAR_2[VAR_1]);",
"}",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
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
],
[
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
]
]
|
13,654 | static void bdrv_co_io_em_complete(void *opaque, int ret)
{
CoroutineIOCompletion *co = opaque;
co->ret = ret;
qemu_coroutine_enter(co->coroutine, NULL);
}
| true | qemu | 0b8b8753e4d94901627b3e86431230f2319215c4 | static void bdrv_co_io_em_complete(void *opaque, int ret)
{
CoroutineIOCompletion *co = opaque;
co->ret = ret;
qemu_coroutine_enter(co->coroutine, NULL);
}
| {
"code": [
" qemu_coroutine_enter(co->coroutine, NULL);"
],
"line_no": [
11
]
} | static void FUNC_0(void *VAR_0, int VAR_1)
{
CoroutineIOCompletion *co = VAR_0;
co->VAR_1 = VAR_1;
qemu_coroutine_enter(co->coroutine, NULL);
}
| [
"static void FUNC_0(void *VAR_0, int VAR_1)\n{",
"CoroutineIOCompletion *co = VAR_0;",
"co->VAR_1 = VAR_1;",
"qemu_coroutine_enter(co->coroutine, NULL);",
"}"
]
| [
0,
0,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
]
]
|
13,655 | void HELPER(diag)(CPUS390XState *env, uint32_t r1, uint32_t r3, uint32_t num)
{
uint64_t r;
switch (num) {
case 0x500:
/* KVM hypercall */
r = s390_virtio_hypercall(env);
break;
case 0x44:
/* yield */
r = 0;
break;
case 0x308:
/* ipl */
handle_diag_308(env, r1, r3);
r = 0;
break;
case 0x288:
/* time bomb (watchdog) */
r = handle_diag_288(env, r1, r3);
break;
default:
r = -1;
break;
}
if (r) {
program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO);
}
} | true | qemu | 7337c6eb98786372cdbfe7ebe7affbd166fdc7ca | void HELPER(diag)(CPUS390XState *env, uint32_t r1, uint32_t r3, uint32_t num)
{
uint64_t r;
switch (num) {
case 0x500:
r = s390_virtio_hypercall(env);
break;
case 0x44:
r = 0;
break;
case 0x308:
handle_diag_308(env, r1, r3);
r = 0;
break;
case 0x288:
r = handle_diag_288(env, r1, r3);
break;
default:
r = -1;
break;
}
if (r) {
program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO);
}
} | {
"code": [],
"line_no": []
} | void FUNC_0(diag)(CPUS390XState *env, uint32_t r1, uint32_t r3, uint32_t num)
{
uint64_t r;
switch (num) {
case 0x500:
r = s390_virtio_hypercall(env);
break;
case 0x44:
r = 0;
break;
case 0x308:
handle_diag_308(env, r1, r3);
r = 0;
break;
case 0x288:
r = handle_diag_288(env, r1, r3);
break;
default:
r = -1;
break;
}
if (r) {
program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO);
}
} | [
"void FUNC_0(diag)(CPUS390XState *env, uint32_t r1, uint32_t r3, uint32_t num)\n{",
"uint64_t r;",
"switch (num) {",
"case 0x500:\nr = s390_virtio_hypercall(env);",
"break;",
"case 0x44:\nr = 0;",
"break;",
"case 0x308:\nhandle_diag_308(env, r1, r3);",
"r = 0;",
"break;",
"case 0x288:\nr = handle_diag_288(env, r1, r3);",
"break;",
"default:\nr = -1;",
"break;",
"}",
"if (r) {",
"program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11,
16
],
[
19
],
[
21,
25
],
[
27
],
[
29,
34
],
[
37
],
[
39
],
[
41,
45
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
]
]
|
13,656 | static uint32_t fdctrl_read_data (fdctrl_t *fdctrl)
{
fdrive_t *cur_drv;
uint32_t retval = 0;
int pos, len;
cur_drv = get_cur_drv(fdctrl);
fdctrl->state &= ~FD_CTRL_SLEEP;
if (FD_STATE(fdctrl->data_state) == FD_STATE_CMD) {
FLOPPY_ERROR("can't read data in CMD state\n");
return 0;
}
pos = fdctrl->data_pos;
if (FD_STATE(fdctrl->data_state) == FD_STATE_DATA) {
pos %= FD_SECTOR_LEN;
if (pos == 0) {
len = fdctrl->data_len - fdctrl->data_pos;
if (len > FD_SECTOR_LEN)
len = FD_SECTOR_LEN;
bdrv_read(cur_drv->bs, fd_sector(cur_drv),
fdctrl->fifo, len);
}
}
retval = fdctrl->fifo[pos];
if (++fdctrl->data_pos == fdctrl->data_len) {
fdctrl->data_pos = 0;
/* Switch from transfer mode to status mode
* then from status mode to command mode
*/
if (FD_STATE(fdctrl->data_state) == FD_STATE_DATA) {
fdctrl_stop_transfer(fdctrl, 0x20, 0x00, 0x00);
} else {
fdctrl_reset_fifo(fdctrl);
fdctrl_reset_irq(fdctrl);
}
}
FLOPPY_DPRINTF("data register: 0x%02x\n", retval);
return retval;
}
| true | qemu | d6c1a327a94437f0ed74ba970b97fd962462bc77 | static uint32_t fdctrl_read_data (fdctrl_t *fdctrl)
{
fdrive_t *cur_drv;
uint32_t retval = 0;
int pos, len;
cur_drv = get_cur_drv(fdctrl);
fdctrl->state &= ~FD_CTRL_SLEEP;
if (FD_STATE(fdctrl->data_state) == FD_STATE_CMD) {
FLOPPY_ERROR("can't read data in CMD state\n");
return 0;
}
pos = fdctrl->data_pos;
if (FD_STATE(fdctrl->data_state) == FD_STATE_DATA) {
pos %= FD_SECTOR_LEN;
if (pos == 0) {
len = fdctrl->data_len - fdctrl->data_pos;
if (len > FD_SECTOR_LEN)
len = FD_SECTOR_LEN;
bdrv_read(cur_drv->bs, fd_sector(cur_drv),
fdctrl->fifo, len);
}
}
retval = fdctrl->fifo[pos];
if (++fdctrl->data_pos == fdctrl->data_len) {
fdctrl->data_pos = 0;
if (FD_STATE(fdctrl->data_state) == FD_STATE_DATA) {
fdctrl_stop_transfer(fdctrl, 0x20, 0x00, 0x00);
} else {
fdctrl_reset_fifo(fdctrl);
fdctrl_reset_irq(fdctrl);
}
}
FLOPPY_DPRINTF("data register: 0x%02x\n", retval);
return retval;
}
| {
"code": [
" bdrv_read(cur_drv->bs, fd_sector(cur_drv),",
" fdctrl->fifo, len);"
],
"line_no": [
39,
41
]
} | static uint32_t FUNC_0 (fdctrl_t *fdctrl)
{
fdrive_t *cur_drv;
uint32_t retval = 0;
int VAR_0, VAR_1;
cur_drv = get_cur_drv(fdctrl);
fdctrl->state &= ~FD_CTRL_SLEEP;
if (FD_STATE(fdctrl->data_state) == FD_STATE_CMD) {
FLOPPY_ERROR("can't read data in CMD state\n");
return 0;
}
VAR_0 = fdctrl->data_pos;
if (FD_STATE(fdctrl->data_state) == FD_STATE_DATA) {
VAR_0 %= FD_SECTOR_LEN;
if (VAR_0 == 0) {
VAR_1 = fdctrl->data_len - fdctrl->data_pos;
if (VAR_1 > FD_SECTOR_LEN)
VAR_1 = FD_SECTOR_LEN;
bdrv_read(cur_drv->bs, fd_sector(cur_drv),
fdctrl->fifo, VAR_1);
}
}
retval = fdctrl->fifo[VAR_0];
if (++fdctrl->data_pos == fdctrl->data_len) {
fdctrl->data_pos = 0;
if (FD_STATE(fdctrl->data_state) == FD_STATE_DATA) {
fdctrl_stop_transfer(fdctrl, 0x20, 0x00, 0x00);
} else {
fdctrl_reset_fifo(fdctrl);
fdctrl_reset_irq(fdctrl);
}
}
FLOPPY_DPRINTF("data register: 0x%02x\n", retval);
return retval;
}
| [
"static uint32_t FUNC_0 (fdctrl_t *fdctrl)\n{",
"fdrive_t *cur_drv;",
"uint32_t retval = 0;",
"int VAR_0, VAR_1;",
"cur_drv = get_cur_drv(fdctrl);",
"fdctrl->state &= ~FD_CTRL_SLEEP;",
"if (FD_STATE(fdctrl->data_state) == FD_STATE_CMD) {",
"FLOPPY_ERROR(\"can't read data in CMD state\\n\");",
"return 0;",
"}",
"VAR_0 = fdctrl->data_pos;",
"if (FD_STATE(fdctrl->data_state) == FD_STATE_DATA) {",
"VAR_0 %= FD_SECTOR_LEN;",
"if (VAR_0 == 0) {",
"VAR_1 = fdctrl->data_len - fdctrl->data_pos;",
"if (VAR_1 > FD_SECTOR_LEN)\nVAR_1 = FD_SECTOR_LEN;",
"bdrv_read(cur_drv->bs, fd_sector(cur_drv),\nfdctrl->fifo, VAR_1);",
"}",
"}",
"retval = fdctrl->fifo[VAR_0];",
"if (++fdctrl->data_pos == fdctrl->data_len) {",
"fdctrl->data_pos = 0;",
"if (FD_STATE(fdctrl->data_state) == FD_STATE_DATA) {",
"fdctrl_stop_transfer(fdctrl, 0x20, 0x00, 0x00);",
"} else {",
"fdctrl_reset_fifo(fdctrl);",
"fdctrl_reset_irq(fdctrl);",
"}",
"}",
"FLOPPY_DPRINTF(\"data register: 0x%02x\\n\", retval);",
"return retval;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
]
]
|
13,657 | static void scsi_dma_complete(void *opaque, int ret)
{
SCSIDiskReq *r = (SCSIDiskReq *)opaque;
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
if (r->req.aiocb != NULL) {
r->req.aiocb = NULL;
bdrv_acct_done(s->qdev.conf.bs, &r->acct);
}
if (ret < 0) {
if (scsi_handle_rw_error(r, -ret)) {
goto done;
}
}
r->sector += r->sector_count;
r->sector_count = 0;
if (r->req.cmd.mode == SCSI_XFER_TO_DEV) {
scsi_write_do_fua(r);
return;
} else {
scsi_req_complete(&r->req, GOOD);
}
done:
if (!r->req.io_canceled) {
scsi_req_unref(&r->req);
}
}
| true | qemu | 46e3f30e3c81e23c07f16b2193dfb6928646c205 | static void scsi_dma_complete(void *opaque, int ret)
{
SCSIDiskReq *r = (SCSIDiskReq *)opaque;
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
if (r->req.aiocb != NULL) {
r->req.aiocb = NULL;
bdrv_acct_done(s->qdev.conf.bs, &r->acct);
}
if (ret < 0) {
if (scsi_handle_rw_error(r, -ret)) {
goto done;
}
}
r->sector += r->sector_count;
r->sector_count = 0;
if (r->req.cmd.mode == SCSI_XFER_TO_DEV) {
scsi_write_do_fua(r);
return;
} else {
scsi_req_complete(&r->req, GOOD);
}
done:
if (!r->req.io_canceled) {
scsi_req_unref(&r->req);
}
}
| {
"code": [
" if (r->req.aiocb != NULL) {",
" r->req.aiocb = NULL;",
" bdrv_acct_done(s->qdev.conf.bs, &r->acct);",
" if (r->req.aiocb != NULL) {",
" r->req.aiocb = NULL;",
" bdrv_acct_done(s->qdev.conf.bs, &r->acct);"
],
"line_no": [
11,
13,
15,
11,
13,
15
]
} | static void FUNC_0(void *VAR_0, int VAR_1)
{
SCSIDiskReq *r = (SCSIDiskReq *)VAR_0;
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
if (r->req.aiocb != NULL) {
r->req.aiocb = NULL;
bdrv_acct_done(s->qdev.conf.bs, &r->acct);
}
if (VAR_1 < 0) {
if (scsi_handle_rw_error(r, -VAR_1)) {
goto done;
}
}
r->sector += r->sector_count;
r->sector_count = 0;
if (r->req.cmd.mode == SCSI_XFER_TO_DEV) {
scsi_write_do_fua(r);
return;
} else {
scsi_req_complete(&r->req, GOOD);
}
done:
if (!r->req.io_canceled) {
scsi_req_unref(&r->req);
}
}
| [
"static void FUNC_0(void *VAR_0, int VAR_1)\n{",
"SCSIDiskReq *r = (SCSIDiskReq *)VAR_0;",
"SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);",
"if (r->req.aiocb != NULL) {",
"r->req.aiocb = NULL;",
"bdrv_acct_done(s->qdev.conf.bs, &r->acct);",
"}",
"if (VAR_1 < 0) {",
"if (scsi_handle_rw_error(r, -VAR_1)) {",
"goto done;",
"}",
"}",
"r->sector += r->sector_count;",
"r->sector_count = 0;",
"if (r->req.cmd.mode == SCSI_XFER_TO_DEV) {",
"scsi_write_do_fua(r);",
"return;",
"} else {",
"scsi_req_complete(&r->req, GOOD);",
"}",
"done:\nif (!r->req.io_canceled) {",
"scsi_req_unref(&r->req);",
"}",
"}"
]
| [
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51,
53
],
[
55
],
[
57
],
[
59
]
]
|
13,658 | static inline void validate_seg(int seg_reg, int cpl)
{
int dpl;
uint32_t e2;
e2 = env->segs[seg_reg].flags;
dpl = (e2 >> DESC_DPL_SHIFT) & 3;
if (!(e2 & DESC_CS_MASK) || !(e2 & DESC_C_MASK)) {
/* data or non conforming code segment */
if (dpl < cpl) {
cpu_x86_load_seg_cache(env, seg_reg, 0, 0, 0, 0);
}
}
}
| true | qemu | cd072e01d86b3d7adab35de03d242e3938e798df | static inline void validate_seg(int seg_reg, int cpl)
{
int dpl;
uint32_t e2;
e2 = env->segs[seg_reg].flags;
dpl = (e2 >> DESC_DPL_SHIFT) & 3;
if (!(e2 & DESC_CS_MASK) || !(e2 & DESC_C_MASK)) {
if (dpl < cpl) {
cpu_x86_load_seg_cache(env, seg_reg, 0, 0, 0, 0);
}
}
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(int VAR_0, int VAR_1)
{
int VAR_2;
uint32_t e2;
e2 = env->segs[VAR_0].flags;
VAR_2 = (e2 >> DESC_DPL_SHIFT) & 3;
if (!(e2 & DESC_CS_MASK) || !(e2 & DESC_C_MASK)) {
if (VAR_2 < VAR_1) {
cpu_x86_load_seg_cache(env, VAR_0, 0, 0, 0, 0);
}
}
}
| [
"static inline void FUNC_0(int VAR_0, int VAR_1)\n{",
"int VAR_2;",
"uint32_t e2;",
"e2 = env->segs[VAR_0].flags;",
"VAR_2 = (e2 >> DESC_DPL_SHIFT) & 3;",
"if (!(e2 & DESC_CS_MASK) || !(e2 & DESC_C_MASK)) {",
"if (VAR_2 < VAR_1) {",
"cpu_x86_load_seg_cache(env, VAR_0, 0, 0, 0, 0);",
"}",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
]
|
13,659 | static void realize(DeviceState *d, Error **errp)
{
sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(d);
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
Object *root_container;
char link_name[256];
gchar *child_name;
Error *err = NULL;
DPRINTFN("drc realize: %x", drck->get_index(drc));
/* NOTE: we do this as part of realize/unrealize due to the fact
* that the guest will communicate with the DRC via RTAS calls
* referencing the global DRC index. By unlinking the DRC
* from DRC_CONTAINER_PATH/<drc_index> we effectively make it
* inaccessible by the guest, since lookups rely on this path
* existing in the composition tree
*/
root_container = container_get(object_get_root(), DRC_CONTAINER_PATH);
snprintf(link_name, sizeof(link_name), "%x", drck->get_index(drc));
child_name = object_get_canonical_path_component(OBJECT(drc));
DPRINTFN("drc child name: %s", child_name);
object_property_add_alias(root_container, link_name,
drc->owner, child_name, &err);
if (err) {
error_report("%s", error_get_pretty(err));
error_free(err);
object_unref(OBJECT(drc));
}
DPRINTFN("drc realize complete");
} | true | qemu | 586d2142a9f1aa5a1dceb0941e7b3f0953974a8b | static void realize(DeviceState *d, Error **errp)
{
sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(d);
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
Object *root_container;
char link_name[256];
gchar *child_name;
Error *err = NULL;
DPRINTFN("drc realize: %x", drck->get_index(drc));
root_container = container_get(object_get_root(), DRC_CONTAINER_PATH);
snprintf(link_name, sizeof(link_name), "%x", drck->get_index(drc));
child_name = object_get_canonical_path_component(OBJECT(drc));
DPRINTFN("drc child name: %s", child_name);
object_property_add_alias(root_container, link_name,
drc->owner, child_name, &err);
if (err) {
error_report("%s", error_get_pretty(err));
error_free(err);
object_unref(OBJECT(drc));
}
DPRINTFN("drc realize complete");
} | {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(VAR_0);
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
Object *root_container;
char VAR_2[256];
gchar *child_name;
Error *err = NULL;
DPRINTFN("drc FUNC_0: %x", drck->get_index(drc));
root_container = container_get(object_get_root(), DRC_CONTAINER_PATH);
snprintf(VAR_2, sizeof(VAR_2), "%x", drck->get_index(drc));
child_name = object_get_canonical_path_component(OBJECT(drc));
DPRINTFN("drc child name: %s", child_name);
object_property_add_alias(root_container, VAR_2,
drc->owner, child_name, &err);
if (err) {
error_report("%s", error_get_pretty(err));
error_free(err);
object_unref(OBJECT(drc));
}
DPRINTFN("drc FUNC_0 complete");
} | [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(VAR_0);",
"sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);",
"Object *root_container;",
"char VAR_2[256];",
"gchar *child_name;",
"Error *err = NULL;",
"DPRINTFN(\"drc FUNC_0: %x\", drck->get_index(drc));",
"root_container = container_get(object_get_root(), DRC_CONTAINER_PATH);",
"snprintf(VAR_2, sizeof(VAR_2), \"%x\", drck->get_index(drc));",
"child_name = object_get_canonical_path_component(OBJECT(drc));",
"DPRINTFN(\"drc child name: %s\", child_name);",
"object_property_add_alias(root_container, VAR_2,\ndrc->owner, child_name, &err);",
"if (err) {",
"error_report(\"%s\", error_get_pretty(err));",
"error_free(err);",
"object_unref(OBJECT(drc));",
"}",
"DPRINTFN(\"drc FUNC_0 complete\");",
"}"
]
| [
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
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
58
],
[
60
]
]
|
13,661 | connect_to_qemu(
const char *host,
const char *port
) {
struct addrinfo hints;
struct addrinfo *server;
int ret, sock;
sock = qemu_socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0) {
/* Error */
fprintf(stderr, "Error opening socket!\n");
return -1;
}
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = 0;
hints.ai_protocol = 0; /* Any protocol */
ret = getaddrinfo(host, port, &hints, &server);
if (ret != 0) {
/* Error */
fprintf(stderr, "getaddrinfo failed\n");
return -1;
}
if (connect(sock, server->ai_addr, server->ai_addrlen) < 0) {
/* Error */
fprintf(stderr, "Could not connect\n");
return -1;
}
if (verbose) {
printf("Connected (sizeof Header=%zd)!\n", sizeof(VSCMsgHeader));
}
return sock;
}
| true | qemu | 581fe784c3adf85dc167a47a4a60fd1245a98217 | connect_to_qemu(
const char *host,
const char *port
) {
struct addrinfo hints;
struct addrinfo *server;
int ret, sock;
sock = qemu_socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0) {
fprintf(stderr, "Error opening socket!\n");
return -1;
}
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = 0;
hints.ai_protocol = 0;
ret = getaddrinfo(host, port, &hints, &server);
if (ret != 0) {
fprintf(stderr, "getaddrinfo failed\n");
return -1;
}
if (connect(sock, server->ai_addr, server->ai_addrlen) < 0) {
fprintf(stderr, "Could not connect\n");
return -1;
}
if (verbose) {
printf("Connected (sizeof Header=%zd)!\n", sizeof(VSCMsgHeader));
}
return sock;
}
| {
"code": [
" return -1;",
" return -1;"
],
"line_no": [
25,
25
]
} | FUNC_0(
const char *VAR_0,
const char *VAR_1
) {
struct addrinfo VAR_2;
struct addrinfo *VAR_3;
int VAR_4, VAR_5;
VAR_5 = qemu_socket(AF_INET, SOCK_STREAM, 0);
if (VAR_5 < 0) {
fprintf(stderr, "Error opening socket!\n");
return -1;
}
memset(&VAR_2, 0, sizeof(struct addrinfo));
VAR_2.ai_family = AF_UNSPEC;
VAR_2.ai_socktype = SOCK_STREAM;
VAR_2.ai_flags = 0;
VAR_2.ai_protocol = 0;
VAR_4 = getaddrinfo(VAR_0, VAR_1, &VAR_2, &VAR_3);
if (VAR_4 != 0) {
fprintf(stderr, "getaddrinfo failed\n");
return -1;
}
if (connect(VAR_5, VAR_3->ai_addr, VAR_3->ai_addrlen) < 0) {
fprintf(stderr, "Could not connect\n");
return -1;
}
if (verbose) {
printf("Connected (sizeof Header=%zd)!\n", sizeof(VSCMsgHeader));
}
return VAR_5;
}
| [
"FUNC_0(\nconst char *VAR_0,\nconst char *VAR_1\n) {",
"struct addrinfo VAR_2;",
"struct addrinfo *VAR_3;",
"int VAR_4, VAR_5;",
"VAR_5 = qemu_socket(AF_INET, SOCK_STREAM, 0);",
"if (VAR_5 < 0) {",
"fprintf(stderr, \"Error opening socket!\\n\");",
"return -1;",
"}",
"memset(&VAR_2, 0, sizeof(struct addrinfo));",
"VAR_2.ai_family = AF_UNSPEC;",
"VAR_2.ai_socktype = SOCK_STREAM;",
"VAR_2.ai_flags = 0;",
"VAR_2.ai_protocol = 0;",
"VAR_4 = getaddrinfo(VAR_0, VAR_1, &VAR_2, &VAR_3);",
"if (VAR_4 != 0) {",
"fprintf(stderr, \"getaddrinfo failed\\n\");",
"return -1;",
"}",
"if (connect(VAR_5, VAR_3->ai_addr, VAR_3->ai_addrlen) < 0) {",
"fprintf(stderr, \"Could not connect\\n\");",
"return -1;",
"}",
"if (verbose) {",
"printf(\"Connected (sizeof Header=%zd)!\\n\", sizeof(VSCMsgHeader));",
"}",
"return VAR_5;",
"}"
]
| [
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
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
47
],
[
51
],
[
53
],
[
55
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
]
]
|
13,662 | void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename
const int linesize = s->current_picture.f.linesize[0]; //not s->linesize as this would be wrong for field pics
const int uvlinesize = s->current_picture.f.linesize[1];
const int mb_size= 4;
s->block_index[0]= s->b8_stride*(s->mb_y*2 ) - 2 + s->mb_x*2;
s->block_index[1]= s->b8_stride*(s->mb_y*2 ) - 1 + s->mb_x*2;
s->block_index[2]= s->b8_stride*(s->mb_y*2 + 1) - 2 + s->mb_x*2;
s->block_index[3]= s->b8_stride*(s->mb_y*2 + 1) - 1 + s->mb_x*2;
s->block_index[4]= s->mb_stride*(s->mb_y + 1) + s->b8_stride*s->mb_height*2 + s->mb_x - 1;
s->block_index[5]= s->mb_stride*(s->mb_y + s->mb_height + 2) + s->b8_stride*s->mb_height*2 + s->mb_x - 1;
//block_index is not used by mpeg2, so it is not affected by chroma_format
s->dest[0] = s->current_picture.f.data[0] + ((s->mb_x - 1) << mb_size);
s->dest[1] = s->current_picture.f.data[1] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift));
s->dest[2] = s->current_picture.f.data[2] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift));
if(!(s->pict_type==AV_PICTURE_TYPE_B && s->avctx->draw_horiz_band && s->picture_structure==PICT_FRAME))
{
if(s->picture_structure==PICT_FRAME){
s->dest[0] += s->mb_y * linesize << mb_size;
s->dest[1] += s->mb_y * uvlinesize << (mb_size - s->chroma_y_shift);
s->dest[2] += s->mb_y * uvlinesize << (mb_size - s->chroma_y_shift);
}else{
s->dest[0] += (s->mb_y>>1) * linesize << mb_size;
s->dest[1] += (s->mb_y>>1) * uvlinesize << (mb_size - s->chroma_y_shift);
s->dest[2] += (s->mb_y>>1) * uvlinesize << (mb_size - s->chroma_y_shift);
assert((s->mb_y&1) == (s->picture_structure == PICT_BOTTOM_FIELD));
}
}
}
| true | FFmpeg | f6774f905fb3cfdc319523ac640be30b14c1bc55 | void ff_init_block_index(MpegEncContext *s){
const int linesize = s->current_picture.f.linesize[0];
const int uvlinesize = s->current_picture.f.linesize[1];
const int mb_size= 4;
s->block_index[0]= s->b8_stride*(s->mb_y*2 ) - 2 + s->mb_x*2;
s->block_index[1]= s->b8_stride*(s->mb_y*2 ) - 1 + s->mb_x*2;
s->block_index[2]= s->b8_stride*(s->mb_y*2 + 1) - 2 + s->mb_x*2;
s->block_index[3]= s->b8_stride*(s->mb_y*2 + 1) - 1 + s->mb_x*2;
s->block_index[4]= s->mb_stride*(s->mb_y + 1) + s->b8_stride*s->mb_height*2 + s->mb_x - 1;
s->block_index[5]= s->mb_stride*(s->mb_y + s->mb_height + 2) + s->b8_stride*s->mb_height*2 + s->mb_x - 1;
s->dest[0] = s->current_picture.f.data[0] + ((s->mb_x - 1) << mb_size);
s->dest[1] = s->current_picture.f.data[1] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift));
s->dest[2] = s->current_picture.f.data[2] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift));
if(!(s->pict_type==AV_PICTURE_TYPE_B && s->avctx->draw_horiz_band && s->picture_structure==PICT_FRAME))
{
if(s->picture_structure==PICT_FRAME){
s->dest[0] += s->mb_y * linesize << mb_size;
s->dest[1] += s->mb_y * uvlinesize << (mb_size - s->chroma_y_shift);
s->dest[2] += s->mb_y * uvlinesize << (mb_size - s->chroma_y_shift);
}else{
s->dest[0] += (s->mb_y>>1) * linesize << mb_size;
s->dest[1] += (s->mb_y>>1) * uvlinesize << (mb_size - s->chroma_y_shift);
s->dest[2] += (s->mb_y>>1) * uvlinesize << (mb_size - s->chroma_y_shift);
assert((s->mb_y&1) == (s->picture_structure == PICT_BOTTOM_FIELD));
}
}
}
| {
"code": [
" const int uvlinesize = s->current_picture.f.linesize[1];",
" const int uvlinesize = s->current_picture.f.linesize[1];",
" s->dest[0] = s->current_picture.f.data[0] + ((s->mb_x - 1) << mb_size);",
" s->dest[1] = s->current_picture.f.data[1] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift));",
" s->dest[2] = s->current_picture.f.data[2] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift));"
],
"line_no": [
5,
5,
27,
29,
31
]
} | void FUNC_0(MpegEncContext *VAR_0){
const int VAR_1 = VAR_0->current_picture.f.VAR_1[0];
const int VAR_2 = VAR_0->current_picture.f.VAR_1[1];
const int VAR_3= 4;
VAR_0->block_index[0]= VAR_0->b8_stride*(VAR_0->mb_y*2 ) - 2 + VAR_0->mb_x*2;
VAR_0->block_index[1]= VAR_0->b8_stride*(VAR_0->mb_y*2 ) - 1 + VAR_0->mb_x*2;
VAR_0->block_index[2]= VAR_0->b8_stride*(VAR_0->mb_y*2 + 1) - 2 + VAR_0->mb_x*2;
VAR_0->block_index[3]= VAR_0->b8_stride*(VAR_0->mb_y*2 + 1) - 1 + VAR_0->mb_x*2;
VAR_0->block_index[4]= VAR_0->mb_stride*(VAR_0->mb_y + 1) + VAR_0->b8_stride*VAR_0->mb_height*2 + VAR_0->mb_x - 1;
VAR_0->block_index[5]= VAR_0->mb_stride*(VAR_0->mb_y + VAR_0->mb_height + 2) + VAR_0->b8_stride*VAR_0->mb_height*2 + VAR_0->mb_x - 1;
VAR_0->dest[0] = VAR_0->current_picture.f.data[0] + ((VAR_0->mb_x - 1) << VAR_3);
VAR_0->dest[1] = VAR_0->current_picture.f.data[1] + ((VAR_0->mb_x - 1) << (VAR_3 - VAR_0->chroma_x_shift));
VAR_0->dest[2] = VAR_0->current_picture.f.data[2] + ((VAR_0->mb_x - 1) << (VAR_3 - VAR_0->chroma_x_shift));
if(!(VAR_0->pict_type==AV_PICTURE_TYPE_B && VAR_0->avctx->draw_horiz_band && VAR_0->picture_structure==PICT_FRAME))
{
if(VAR_0->picture_structure==PICT_FRAME){
VAR_0->dest[0] += VAR_0->mb_y * VAR_1 << VAR_3;
VAR_0->dest[1] += VAR_0->mb_y * VAR_2 << (VAR_3 - VAR_0->chroma_y_shift);
VAR_0->dest[2] += VAR_0->mb_y * VAR_2 << (VAR_3 - VAR_0->chroma_y_shift);
}else{
VAR_0->dest[0] += (VAR_0->mb_y>>1) * VAR_1 << VAR_3;
VAR_0->dest[1] += (VAR_0->mb_y>>1) * VAR_2 << (VAR_3 - VAR_0->chroma_y_shift);
VAR_0->dest[2] += (VAR_0->mb_y>>1) * VAR_2 << (VAR_3 - VAR_0->chroma_y_shift);
assert((VAR_0->mb_y&1) == (VAR_0->picture_structure == PICT_BOTTOM_FIELD));
}
}
}
| [
"void FUNC_0(MpegEncContext *VAR_0){",
"const int VAR_1 = VAR_0->current_picture.f.VAR_1[0];",
"const int VAR_2 = VAR_0->current_picture.f.VAR_1[1];",
"const int VAR_3= 4;",
"VAR_0->block_index[0]= VAR_0->b8_stride*(VAR_0->mb_y*2 ) - 2 + VAR_0->mb_x*2;",
"VAR_0->block_index[1]= VAR_0->b8_stride*(VAR_0->mb_y*2 ) - 1 + VAR_0->mb_x*2;",
"VAR_0->block_index[2]= VAR_0->b8_stride*(VAR_0->mb_y*2 + 1) - 2 + VAR_0->mb_x*2;",
"VAR_0->block_index[3]= VAR_0->b8_stride*(VAR_0->mb_y*2 + 1) - 1 + VAR_0->mb_x*2;",
"VAR_0->block_index[4]= VAR_0->mb_stride*(VAR_0->mb_y + 1) + VAR_0->b8_stride*VAR_0->mb_height*2 + VAR_0->mb_x - 1;",
"VAR_0->block_index[5]= VAR_0->mb_stride*(VAR_0->mb_y + VAR_0->mb_height + 2) + VAR_0->b8_stride*VAR_0->mb_height*2 + VAR_0->mb_x - 1;",
"VAR_0->dest[0] = VAR_0->current_picture.f.data[0] + ((VAR_0->mb_x - 1) << VAR_3);",
"VAR_0->dest[1] = VAR_0->current_picture.f.data[1] + ((VAR_0->mb_x - 1) << (VAR_3 - VAR_0->chroma_x_shift));",
"VAR_0->dest[2] = VAR_0->current_picture.f.data[2] + ((VAR_0->mb_x - 1) << (VAR_3 - VAR_0->chroma_x_shift));",
"if(!(VAR_0->pict_type==AV_PICTURE_TYPE_B && VAR_0->avctx->draw_horiz_band && VAR_0->picture_structure==PICT_FRAME))\n{",
"if(VAR_0->picture_structure==PICT_FRAME){",
"VAR_0->dest[0] += VAR_0->mb_y * VAR_1 << VAR_3;",
"VAR_0->dest[1] += VAR_0->mb_y * VAR_2 << (VAR_3 - VAR_0->chroma_y_shift);",
"VAR_0->dest[2] += VAR_0->mb_y * VAR_2 << (VAR_3 - VAR_0->chroma_y_shift);",
"}else{",
"VAR_0->dest[0] += (VAR_0->mb_y>>1) * VAR_1 << VAR_3;",
"VAR_0->dest[1] += (VAR_0->mb_y>>1) * VAR_2 << (VAR_3 - VAR_0->chroma_y_shift);",
"VAR_0->dest[2] += (VAR_0->mb_y>>1) * VAR_2 << (VAR_3 - VAR_0->chroma_y_shift);",
"assert((VAR_0->mb_y&1) == (VAR_0->picture_structure == PICT_BOTTOM_FIELD));",
"}",
"}",
"}"
]
| [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1
],
[
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
27
],
[
29
],
[
31
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
]
]
|
13,663 | static void virtio_net_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
dc->exit = virtio_net_device_exit;
dc->props = virtio_net_properties;
set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
vdc->init = virtio_net_device_init;
vdc->get_config = virtio_net_get_config;
vdc->set_config = virtio_net_set_config;
vdc->get_features = virtio_net_get_features;
vdc->set_features = virtio_net_set_features;
vdc->bad_features = virtio_net_bad_features;
vdc->reset = virtio_net_reset;
vdc->set_status = virtio_net_set_status;
vdc->guest_notifier_mask = virtio_net_guest_notifier_mask;
vdc->guest_notifier_pending = virtio_net_guest_notifier_pending;
}
| true | qemu | 3786cff5eb384d058395a2729af627fa3253d056 | static void virtio_net_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
dc->exit = virtio_net_device_exit;
dc->props = virtio_net_properties;
set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
vdc->init = virtio_net_device_init;
vdc->get_config = virtio_net_get_config;
vdc->set_config = virtio_net_set_config;
vdc->get_features = virtio_net_get_features;
vdc->set_features = virtio_net_set_features;
vdc->bad_features = virtio_net_bad_features;
vdc->reset = virtio_net_reset;
vdc->set_status = virtio_net_set_status;
vdc->guest_notifier_mask = virtio_net_guest_notifier_mask;
vdc->guest_notifier_pending = virtio_net_guest_notifier_pending;
}
| {
"code": [
" dc->exit = virtio_net_device_exit;"
],
"line_no": [
9
]
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
DeviceClass *dc = DEVICE_CLASS(VAR_0);
VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(VAR_0);
dc->exit = virtio_net_device_exit;
dc->props = virtio_net_properties;
set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
vdc->init = virtio_net_device_init;
vdc->get_config = virtio_net_get_config;
vdc->set_config = virtio_net_set_config;
vdc->get_features = virtio_net_get_features;
vdc->set_features = virtio_net_set_features;
vdc->bad_features = virtio_net_bad_features;
vdc->reset = virtio_net_reset;
vdc->set_status = virtio_net_set_status;
vdc->guest_notifier_mask = virtio_net_guest_notifier_mask;
vdc->guest_notifier_pending = virtio_net_guest_notifier_pending;
}
| [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"DeviceClass *dc = DEVICE_CLASS(VAR_0);",
"VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(VAR_0);",
"dc->exit = virtio_net_device_exit;",
"dc->props = virtio_net_properties;",
"set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);",
"vdc->init = virtio_net_device_init;",
"vdc->get_config = virtio_net_get_config;",
"vdc->set_config = virtio_net_set_config;",
"vdc->get_features = virtio_net_get_features;",
"vdc->set_features = virtio_net_set_features;",
"vdc->bad_features = virtio_net_bad_features;",
"vdc->reset = virtio_net_reset;",
"vdc->set_status = virtio_net_set_status;",
"vdc->guest_notifier_mask = virtio_net_guest_notifier_mask;",
"vdc->guest_notifier_pending = virtio_net_guest_notifier_pending;",
"}"
]
| [
0,
0,
0,
1,
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
]
]
|
13,664 | static int decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile)
{
int compno, reslevelno, bandno;
int x, y;
uint8_t *line;
Jpeg2000T1Context t1;
/* Loop on tile components */
for (compno = 0; compno < s->ncomponents; compno++) {
Jpeg2000Component *comp = tile->comp + compno;
Jpeg2000CodingStyle *codsty = tile->codsty + compno;
/* Loop on resolution levels */
for (reslevelno = 0; reslevelno < codsty->nreslevels2decode; reslevelno++) {
Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno;
/* Loop on bands */
for (bandno = 0; bandno < rlevel->nbands; bandno++) {
int nb_precincts, precno;
Jpeg2000Band *band = rlevel->band + bandno;
int cblkno=0, bandpos;
bandpos = bandno + (reslevelno > 0);
if (band->coord[0][0] == band->coord[0][1] || band->coord[1][0] == band->coord[1][1])
continue;
nb_precincts = rlevel->num_precincts_x * rlevel->num_precincts_y;
/* Loop on precincts */
for (precno = 0; precno < nb_precincts; precno++) {
Jpeg2000Prec *prec = band->prec + precno;
/* Loop on codeblocks */
for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) {
int x, y;
Jpeg2000Cblk *cblk = prec->cblk + cblkno;
decode_cblk(s, codsty, &t1, cblk,
cblk->coord[0][1] - cblk->coord[0][0],
cblk->coord[1][1] - cblk->coord[1][0],
bandpos);
/* Manage band offsets */
x = cblk->coord[0][0];
y = cblk->coord[1][0];
if (codsty->transform == FF_DWT97)
dequantization_float(x, y, cblk, comp, &t1, band);
else
dequantization_int(x, y, cblk, comp, &t1, band);
} /* end cblk */
} /*end prec */
} /* end band */
} /* end reslevel */
ff_dwt_decode(&comp->dwt, comp->data);
} /*end comp */
/* inverse MCT transformation */
if (tile->codsty[0].mct)
mct_decode(s, tile);
if (s->precision <= 8) {
for (compno = 0; compno < s->ncomponents; compno++) {
Jpeg2000Component *comp = tile->comp + compno;
float *datap = (float*)comp->data;
int32_t *i_datap = (int32_t *) comp->data;
y = tile->comp[compno].coord[1][0] - s->image_offset_y;
line = s->picture->data[0] + y * s->picture->linesize[0];
for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) {
uint8_t *dst;
x = tile->comp[compno].coord[0][0] - s->image_offset_x;
dst = line + x * s->ncomponents + compno;
for (; x < tile->comp[compno].coord[0][1] - s->image_offset_x; x += s->cdx[compno]) {
int val;
/* DC level shift and clip see ISO 15444-1:2002 G.1.2 */
if (tile->codsty->transform == FF_DWT97)
val = lrintf(*datap) + (1 << (s->cbps[compno] - 1));
else
val = *i_datap + (1 << (s->cbps[compno] - 1));
val = av_clip(val, 0, (1 << s->cbps[compno]) - 1);
*dst = val << (8 - s->cbps[compno]);
datap++;
i_datap++;
dst += s->ncomponents;
}
line += s->picture->linesize[0];
}
}
} else {
for (compno = 0; compno < s->ncomponents; compno++) {
Jpeg2000Component *comp = tile->comp + compno;
float *datap = (float*)comp->data;
int32_t *i_datap = (int32_t *) comp->data;
uint16_t *linel;
y = tile->comp[compno].coord[1][0] - s->image_offset_y;
linel = (uint16_t*)s->picture->data[0] + y * (s->picture->linesize[0] >> 1);
for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) {
uint16_t *dst;
x = tile->comp[compno].coord[0][0] - s->image_offset_x;
dst = linel + (x * s->ncomponents + compno);
for (; x < tile->comp[compno].coord[0][1] - s->image_offset_x; x += s-> cdx[compno]) {
int val;
/* DC level shift and clip see ISO 15444-1:2002 G.1.2 */
if (tile->codsty->transform == FF_DWT97)
val = lrintf(*datap) + (1 << (s->cbps[compno] - 1));
else
val = *i_datap + (1 << (s->cbps[compno] - 1));
val = av_clip(val, 0, (1 << s->cbps[compno]) - 1);
/* align 12 bit values in little-endian mode */
*dst = val << (16 - s->cbps[compno]);
datap++;
i_datap++;
dst += s->ncomponents;
}
linel += s->picture->linesize[0]>>1;
}
}
}
return 0;
}
| true | FFmpeg | 8bedbb82cee4463a43e60eb22674c8bf927280ef | static int decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile)
{
int compno, reslevelno, bandno;
int x, y;
uint8_t *line;
Jpeg2000T1Context t1;
for (compno = 0; compno < s->ncomponents; compno++) {
Jpeg2000Component *comp = tile->comp + compno;
Jpeg2000CodingStyle *codsty = tile->codsty + compno;
for (reslevelno = 0; reslevelno < codsty->nreslevels2decode; reslevelno++) {
Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno;
for (bandno = 0; bandno < rlevel->nbands; bandno++) {
int nb_precincts, precno;
Jpeg2000Band *band = rlevel->band + bandno;
int cblkno=0, bandpos;
bandpos = bandno + (reslevelno > 0);
if (band->coord[0][0] == band->coord[0][1] || band->coord[1][0] == band->coord[1][1])
continue;
nb_precincts = rlevel->num_precincts_x * rlevel->num_precincts_y;
for (precno = 0; precno < nb_precincts; precno++) {
Jpeg2000Prec *prec = band->prec + precno;
for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) {
int x, y;
Jpeg2000Cblk *cblk = prec->cblk + cblkno;
decode_cblk(s, codsty, &t1, cblk,
cblk->coord[0][1] - cblk->coord[0][0],
cblk->coord[1][1] - cblk->coord[1][0],
bandpos);
x = cblk->coord[0][0];
y = cblk->coord[1][0];
if (codsty->transform == FF_DWT97)
dequantization_float(x, y, cblk, comp, &t1, band);
else
dequantization_int(x, y, cblk, comp, &t1, band);
}
}
}
}
ff_dwt_decode(&comp->dwt, comp->data);
}
if (tile->codsty[0].mct)
mct_decode(s, tile);
if (s->precision <= 8) {
for (compno = 0; compno < s->ncomponents; compno++) {
Jpeg2000Component *comp = tile->comp + compno;
float *datap = (float*)comp->data;
int32_t *i_datap = (int32_t *) comp->data;
y = tile->comp[compno].coord[1][0] - s->image_offset_y;
line = s->picture->data[0] + y * s->picture->linesize[0];
for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) {
uint8_t *dst;
x = tile->comp[compno].coord[0][0] - s->image_offset_x;
dst = line + x * s->ncomponents + compno;
for (; x < tile->comp[compno].coord[0][1] - s->image_offset_x; x += s->cdx[compno]) {
int val;
if (tile->codsty->transform == FF_DWT97)
val = lrintf(*datap) + (1 << (s->cbps[compno] - 1));
else
val = *i_datap + (1 << (s->cbps[compno] - 1));
val = av_clip(val, 0, (1 << s->cbps[compno]) - 1);
*dst = val << (8 - s->cbps[compno]);
datap++;
i_datap++;
dst += s->ncomponents;
}
line += s->picture->linesize[0];
}
}
} else {
for (compno = 0; compno < s->ncomponents; compno++) {
Jpeg2000Component *comp = tile->comp + compno;
float *datap = (float*)comp->data;
int32_t *i_datap = (int32_t *) comp->data;
uint16_t *linel;
y = tile->comp[compno].coord[1][0] - s->image_offset_y;
linel = (uint16_t*)s->picture->data[0] + y * (s->picture->linesize[0] >> 1);
for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) {
uint16_t *dst;
x = tile->comp[compno].coord[0][0] - s->image_offset_x;
dst = linel + (x * s->ncomponents + compno);
for (; x < tile->comp[compno].coord[0][1] - s->image_offset_x; x += s-> cdx[compno]) {
int val;
if (tile->codsty->transform == FF_DWT97)
val = lrintf(*datap) + (1 << (s->cbps[compno] - 1));
else
val = *i_datap + (1 << (s->cbps[compno] - 1));
val = av_clip(val, 0, (1 << s->cbps[compno]) - 1);
*dst = val << (16 - s->cbps[compno]);
datap++;
i_datap++;
dst += s->ncomponents;
}
linel += s->picture->linesize[0]>>1;
}
}
}
return 0;
}
| {
"code": [
" ff_dwt_decode(&comp->dwt, comp->data);",
" float *datap = (float*)comp->data;",
" int32_t *i_datap = (int32_t *) comp->data;",
" float *datap = (float*)comp->data;",
" int32_t *i_datap = (int32_t *) comp->data;",
" ff_dwt_decode(&comp->dwt, comp->data);",
" int32_t *i_datap = (int32_t *) comp->data;",
" int32_t *i_datap = (int32_t *) comp->data;"
],
"line_no": [
107,
127,
129,
127,
129,
107,
129,
129
]
} | static int FUNC_0(Jpeg2000DecoderContext *VAR_0, Jpeg2000Tile *VAR_1)
{
int VAR_2, VAR_3, VAR_4;
int VAR_5, VAR_6;
uint8_t *line;
Jpeg2000T1Context t1;
for (VAR_2 = 0; VAR_2 < VAR_0->ncomponents; VAR_2++) {
Jpeg2000Component *comp = VAR_1->comp + VAR_2;
Jpeg2000CodingStyle *codsty = VAR_1->codsty + VAR_2;
for (VAR_3 = 0; VAR_3 < codsty->nreslevels2decode; VAR_3++) {
Jpeg2000ResLevel *rlevel = comp->reslevel + VAR_3;
for (VAR_4 = 0; VAR_4 < rlevel->nbands; VAR_4++) {
int nb_precincts, precno;
Jpeg2000Band *band = rlevel->band + VAR_4;
int cblkno=0, bandpos;
bandpos = VAR_4 + (VAR_3 > 0);
if (band->coord[0][0] == band->coord[0][1] || band->coord[1][0] == band->coord[1][1])
continue;
nb_precincts = rlevel->num_precincts_x * rlevel->num_precincts_y;
for (precno = 0; precno < nb_precincts; precno++) {
Jpeg2000Prec *prec = band->prec + precno;
for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) {
int VAR_5, VAR_6;
Jpeg2000Cblk *cblk = prec->cblk + cblkno;
decode_cblk(VAR_0, codsty, &t1, cblk,
cblk->coord[0][1] - cblk->coord[0][0],
cblk->coord[1][1] - cblk->coord[1][0],
bandpos);
VAR_5 = cblk->coord[0][0];
VAR_6 = cblk->coord[1][0];
if (codsty->transform == FF_DWT97)
dequantization_float(VAR_5, VAR_6, cblk, comp, &t1, band);
else
dequantization_int(VAR_5, VAR_6, cblk, comp, &t1, band);
}
}
}
}
ff_dwt_decode(&comp->dwt, comp->data);
}
if (VAR_1->codsty[0].mct)
mct_decode(VAR_0, VAR_1);
if (VAR_0->precision <= 8) {
for (VAR_2 = 0; VAR_2 < VAR_0->ncomponents; VAR_2++) {
Jpeg2000Component *comp = VAR_1->comp + VAR_2;
float *datap = (float*)comp->data;
int32_t *i_datap = (int32_t *) comp->data;
VAR_6 = VAR_1->comp[VAR_2].coord[1][0] - VAR_0->image_offset_y;
line = VAR_0->picture->data[0] + VAR_6 * VAR_0->picture->linesize[0];
for (; VAR_6 < VAR_1->comp[VAR_2].coord[1][1] - VAR_0->image_offset_y; VAR_6 += VAR_0->cdy[VAR_2]) {
uint8_t *dst;
VAR_5 = VAR_1->comp[VAR_2].coord[0][0] - VAR_0->image_offset_x;
dst = line + VAR_5 * VAR_0->ncomponents + VAR_2;
for (; VAR_5 < VAR_1->comp[VAR_2].coord[0][1] - VAR_0->image_offset_x; VAR_5 += VAR_0->cdx[VAR_2]) {
int val;
if (VAR_1->codsty->transform == FF_DWT97)
val = lrintf(*datap) + (1 << (VAR_0->cbps[VAR_2] - 1));
else
val = *i_datap + (1 << (VAR_0->cbps[VAR_2] - 1));
val = av_clip(val, 0, (1 << VAR_0->cbps[VAR_2]) - 1);
*dst = val << (8 - VAR_0->cbps[VAR_2]);
datap++;
i_datap++;
dst += VAR_0->ncomponents;
}
line += VAR_0->picture->linesize[0];
}
}
} else {
for (VAR_2 = 0; VAR_2 < VAR_0->ncomponents; VAR_2++) {
Jpeg2000Component *comp = VAR_1->comp + VAR_2;
float *datap = (float*)comp->data;
int32_t *i_datap = (int32_t *) comp->data;
uint16_t *linel;
VAR_6 = VAR_1->comp[VAR_2].coord[1][0] - VAR_0->image_offset_y;
linel = (uint16_t*)VAR_0->picture->data[0] + VAR_6 * (VAR_0->picture->linesize[0] >> 1);
for (; VAR_6 < VAR_1->comp[VAR_2].coord[1][1] - VAR_0->image_offset_y; VAR_6 += VAR_0->cdy[VAR_2]) {
uint16_t *dst;
VAR_5 = VAR_1->comp[VAR_2].coord[0][0] - VAR_0->image_offset_x;
dst = linel + (VAR_5 * VAR_0->ncomponents + VAR_2);
for (; VAR_5 < VAR_1->comp[VAR_2].coord[0][1] - VAR_0->image_offset_x; VAR_5 += VAR_0-> cdx[VAR_2]) {
int val;
if (VAR_1->codsty->transform == FF_DWT97)
val = lrintf(*datap) + (1 << (VAR_0->cbps[VAR_2] - 1));
else
val = *i_datap + (1 << (VAR_0->cbps[VAR_2] - 1));
val = av_clip(val, 0, (1 << VAR_0->cbps[VAR_2]) - 1);
*dst = val << (16 - VAR_0->cbps[VAR_2]);
datap++;
i_datap++;
dst += VAR_0->ncomponents;
}
linel += VAR_0->picture->linesize[0]>>1;
}
}
}
return 0;
}
| [
"static int FUNC_0(Jpeg2000DecoderContext *VAR_0, Jpeg2000Tile *VAR_1)\n{",
"int VAR_2, VAR_3, VAR_4;",
"int VAR_5, VAR_6;",
"uint8_t *line;",
"Jpeg2000T1Context t1;",
"for (VAR_2 = 0; VAR_2 < VAR_0->ncomponents; VAR_2++) {",
"Jpeg2000Component *comp = VAR_1->comp + VAR_2;",
"Jpeg2000CodingStyle *codsty = VAR_1->codsty + VAR_2;",
"for (VAR_3 = 0; VAR_3 < codsty->nreslevels2decode; VAR_3++) {",
"Jpeg2000ResLevel *rlevel = comp->reslevel + VAR_3;",
"for (VAR_4 = 0; VAR_4 < rlevel->nbands; VAR_4++) {",
"int nb_precincts, precno;",
"Jpeg2000Band *band = rlevel->band + VAR_4;",
"int cblkno=0, bandpos;",
"bandpos = VAR_4 + (VAR_3 > 0);",
"if (band->coord[0][0] == band->coord[0][1] || band->coord[1][0] == band->coord[1][1])\ncontinue;",
"nb_precincts = rlevel->num_precincts_x * rlevel->num_precincts_y;",
"for (precno = 0; precno < nb_precincts; precno++) {",
"Jpeg2000Prec *prec = band->prec + precno;",
"for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) {",
"int VAR_5, VAR_6;",
"Jpeg2000Cblk *cblk = prec->cblk + cblkno;",
"decode_cblk(VAR_0, codsty, &t1, cblk,\ncblk->coord[0][1] - cblk->coord[0][0],\ncblk->coord[1][1] - cblk->coord[1][0],\nbandpos);",
"VAR_5 = cblk->coord[0][0];",
"VAR_6 = cblk->coord[1][0];",
"if (codsty->transform == FF_DWT97)\ndequantization_float(VAR_5, VAR_6, cblk, comp, &t1, band);",
"else\ndequantization_int(VAR_5, VAR_6, cblk, comp, &t1, band);",
"}",
"}",
"}",
"}",
"ff_dwt_decode(&comp->dwt, comp->data);",
"}",
"if (VAR_1->codsty[0].mct)\nmct_decode(VAR_0, VAR_1);",
"if (VAR_0->precision <= 8) {",
"for (VAR_2 = 0; VAR_2 < VAR_0->ncomponents; VAR_2++) {",
"Jpeg2000Component *comp = VAR_1->comp + VAR_2;",
"float *datap = (float*)comp->data;",
"int32_t *i_datap = (int32_t *) comp->data;",
"VAR_6 = VAR_1->comp[VAR_2].coord[1][0] - VAR_0->image_offset_y;",
"line = VAR_0->picture->data[0] + VAR_6 * VAR_0->picture->linesize[0];",
"for (; VAR_6 < VAR_1->comp[VAR_2].coord[1][1] - VAR_0->image_offset_y; VAR_6 += VAR_0->cdy[VAR_2]) {",
"uint8_t *dst;",
"VAR_5 = VAR_1->comp[VAR_2].coord[0][0] - VAR_0->image_offset_x;",
"dst = line + VAR_5 * VAR_0->ncomponents + VAR_2;",
"for (; VAR_5 < VAR_1->comp[VAR_2].coord[0][1] - VAR_0->image_offset_x; VAR_5 += VAR_0->cdx[VAR_2]) {",
"int val;",
"if (VAR_1->codsty->transform == FF_DWT97)\nval = lrintf(*datap) + (1 << (VAR_0->cbps[VAR_2] - 1));",
"else\nval = *i_datap + (1 << (VAR_0->cbps[VAR_2] - 1));",
"val = av_clip(val, 0, (1 << VAR_0->cbps[VAR_2]) - 1);",
"*dst = val << (8 - VAR_0->cbps[VAR_2]);",
"datap++;",
"i_datap++;",
"dst += VAR_0->ncomponents;",
"}",
"line += VAR_0->picture->linesize[0];",
"}",
"}",
"} else {",
"for (VAR_2 = 0; VAR_2 < VAR_0->ncomponents; VAR_2++) {",
"Jpeg2000Component *comp = VAR_1->comp + VAR_2;",
"float *datap = (float*)comp->data;",
"int32_t *i_datap = (int32_t *) comp->data;",
"uint16_t *linel;",
"VAR_6 = VAR_1->comp[VAR_2].coord[1][0] - VAR_0->image_offset_y;",
"linel = (uint16_t*)VAR_0->picture->data[0] + VAR_6 * (VAR_0->picture->linesize[0] >> 1);",
"for (; VAR_6 < VAR_1->comp[VAR_2].coord[1][1] - VAR_0->image_offset_y; VAR_6 += VAR_0->cdy[VAR_2]) {",
"uint16_t *dst;",
"VAR_5 = VAR_1->comp[VAR_2].coord[0][0] - VAR_0->image_offset_x;",
"dst = linel + (VAR_5 * VAR_0->ncomponents + VAR_2);",
"for (; VAR_5 < VAR_1->comp[VAR_2].coord[0][1] - VAR_0->image_offset_x; VAR_5 += VAR_0-> cdx[VAR_2]) {",
"int val;",
"if (VAR_1->codsty->transform == FF_DWT97)\nval = lrintf(*datap) + (1 << (VAR_0->cbps[VAR_2] - 1));",
"else\nval = *i_datap + (1 << (VAR_0->cbps[VAR_2] - 1));",
"val = av_clip(val, 0, (1 << VAR_0->cbps[VAR_2]) - 1);",
"*dst = val << (16 - VAR_0->cbps[VAR_2]);",
"datap++;",
"i_datap++;",
"dst += VAR_0->ncomponents;",
"}",
"linel += VAR_0->picture->linesize[0]>>1;",
"}",
"}",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
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
],
[
11
],
[
17
],
[
19
],
[
21
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
47,
49
],
[
53
],
[
57
],
[
59
],
[
65
],
[
67
],
[
69
],
[
71,
73,
75,
77
],
[
83
],
[
85
],
[
89,
91
],
[
93,
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
115,
117
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
149
],
[
151
],
[
155,
157
],
[
159,
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197
],
[
199
],
[
201
],
[
205
],
[
207
],
[
209
],
[
211
],
[
215,
217
],
[
219,
221
],
[
223
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
]
]
|
13,665 | int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,
const uint8_t *buf, int nb_sectors)
{
BlockDriver *drv = bs->drv;
if (!drv)
return -ENOMEDIUM;
if (!drv->bdrv_write_compressed)
return -ENOTSUP;
if (bdrv_check_request(bs, sector_num, nb_sectors))
return -EIO;
if (bs->dirty_tracking) {
set_dirty_bitmap(bs, sector_num, nb_sectors, 1);
}
return drv->bdrv_write_compressed(bs, sector_num, buf, nb_sectors);
}
| true | qemu | c6d2283068026035a6468aae9dcde953bd7521ac | int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,
const uint8_t *buf, int nb_sectors)
{
BlockDriver *drv = bs->drv;
if (!drv)
return -ENOMEDIUM;
if (!drv->bdrv_write_compressed)
return -ENOTSUP;
if (bdrv_check_request(bs, sector_num, nb_sectors))
return -EIO;
if (bs->dirty_tracking) {
set_dirty_bitmap(bs, sector_num, nb_sectors, 1);
}
return drv->bdrv_write_compressed(bs, sector_num, buf, nb_sectors);
}
| {
"code": [
" if (bs->dirty_tracking) {",
" if (bs->dirty_tracking) {",
" if (bs->dirty_tracking) {"
],
"line_no": [
23,
23,
23
]
} | int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,
const uint8_t *VAR_2, int VAR_3)
{
BlockDriver *drv = VAR_0->drv;
if (!drv)
return -ENOMEDIUM;
if (!drv->FUNC_0)
return -ENOTSUP;
if (bdrv_check_request(VAR_0, VAR_1, VAR_3))
return -EIO;
if (VAR_0->dirty_tracking) {
set_dirty_bitmap(VAR_0, VAR_1, VAR_3, 1);
}
return drv->FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3);
}
| [
"int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,\nconst uint8_t *VAR_2, int VAR_3)\n{",
"BlockDriver *drv = VAR_0->drv;",
"if (!drv)\nreturn -ENOMEDIUM;",
"if (!drv->FUNC_0)\nreturn -ENOTSUP;",
"if (bdrv_check_request(VAR_0, VAR_1, VAR_3))\nreturn -EIO;",
"if (VAR_0->dirty_tracking) {",
"set_dirty_bitmap(VAR_0, VAR_1, VAR_3, 1);",
"}",
"return drv->FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3);",
"}"
]
| [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9,
11
],
[
13,
15
],
[
17,
19
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
]
]
|
13,666 | static void moxie_cpu_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
CPUClass *cc = CPU_CLASS(oc);
MoxieCPUClass *mcc = MOXIE_CPU_CLASS(oc);
mcc->parent_realize = dc->realize;
dc->realize = moxie_cpu_realizefn;
mcc->parent_reset = cc->reset;
cc->reset = moxie_cpu_reset;
cc->class_by_name = moxie_cpu_class_by_name;
cc->has_work = moxie_cpu_has_work;
cc->do_interrupt = moxie_cpu_do_interrupt;
cc->dump_state = moxie_cpu_dump_state;
cc->set_pc = moxie_cpu_set_pc;
#ifdef CONFIG_USER_ONLY
cc->handle_mmu_fault = moxie_cpu_handle_mmu_fault;
#else
cc->get_phys_page_debug = moxie_cpu_get_phys_page_debug;
cc->vmsd = &vmstate_moxie_cpu;
#endif
cc->disas_set_info = moxie_cpu_disas_set_info;
/*
* Reason: moxie_cpu_initfn() calls cpu_exec_init(), which saves
* the object in cpus -> dangling pointer after final
* object_unref().
*/
dc->cannot_destroy_with_object_finalize_yet = true;
}
| true | qemu | ce5b1bbf624b977a55ff7f85bb3871682d03baff | static void moxie_cpu_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
CPUClass *cc = CPU_CLASS(oc);
MoxieCPUClass *mcc = MOXIE_CPU_CLASS(oc);
mcc->parent_realize = dc->realize;
dc->realize = moxie_cpu_realizefn;
mcc->parent_reset = cc->reset;
cc->reset = moxie_cpu_reset;
cc->class_by_name = moxie_cpu_class_by_name;
cc->has_work = moxie_cpu_has_work;
cc->do_interrupt = moxie_cpu_do_interrupt;
cc->dump_state = moxie_cpu_dump_state;
cc->set_pc = moxie_cpu_set_pc;
#ifdef CONFIG_USER_ONLY
cc->handle_mmu_fault = moxie_cpu_handle_mmu_fault;
#else
cc->get_phys_page_debug = moxie_cpu_get_phys_page_debug;
cc->vmsd = &vmstate_moxie_cpu;
#endif
cc->disas_set_info = moxie_cpu_disas_set_info;
dc->cannot_destroy_with_object_finalize_yet = true;
}
| {
"code": [
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;"
],
"line_no": [
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63,
63
]
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
DeviceClass *dc = DEVICE_CLASS(VAR_0);
CPUClass *cc = CPU_CLASS(VAR_0);
MoxieCPUClass *mcc = MOXIE_CPU_CLASS(VAR_0);
mcc->parent_realize = dc->realize;
dc->realize = moxie_cpu_realizefn;
mcc->parent_reset = cc->reset;
cc->reset = moxie_cpu_reset;
cc->class_by_name = moxie_cpu_class_by_name;
cc->has_work = moxie_cpu_has_work;
cc->do_interrupt = moxie_cpu_do_interrupt;
cc->dump_state = moxie_cpu_dump_state;
cc->set_pc = moxie_cpu_set_pc;
#ifdef CONFIG_USER_ONLY
cc->handle_mmu_fault = moxie_cpu_handle_mmu_fault;
#else
cc->get_phys_page_debug = moxie_cpu_get_phys_page_debug;
cc->vmsd = &vmstate_moxie_cpu;
#endif
cc->disas_set_info = moxie_cpu_disas_set_info;
dc->cannot_destroy_with_object_finalize_yet = true;
}
| [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"DeviceClass *dc = DEVICE_CLASS(VAR_0);",
"CPUClass *cc = CPU_CLASS(VAR_0);",
"MoxieCPUClass *mcc = MOXIE_CPU_CLASS(VAR_0);",
"mcc->parent_realize = dc->realize;",
"dc->realize = moxie_cpu_realizefn;",
"mcc->parent_reset = cc->reset;",
"cc->reset = moxie_cpu_reset;",
"cc->class_by_name = moxie_cpu_class_by_name;",
"cc->has_work = moxie_cpu_has_work;",
"cc->do_interrupt = moxie_cpu_do_interrupt;",
"cc->dump_state = moxie_cpu_dump_state;",
"cc->set_pc = moxie_cpu_set_pc;",
"#ifdef CONFIG_USER_ONLY\ncc->handle_mmu_fault = moxie_cpu_handle_mmu_fault;",
"#else\ncc->get_phys_page_debug = moxie_cpu_get_phys_page_debug;",
"cc->vmsd = &vmstate_moxie_cpu;",
"#endif\ncc->disas_set_info = moxie_cpu_disas_set_info;",
"dc->cannot_destroy_with_object_finalize_yet = true;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41,
43
],
[
45
],
[
47,
49
],
[
63
],
[
65
]
]
|
13,668 | static int vc1_decode_sprites(VC1Context *v, GetBitContext* gb)
{
int ret;
MpegEncContext *s = &v->s;
AVCodecContext *avctx = s->avctx;
SpriteData sd;
memset(&sd, 0, sizeof(sd));
ret = vc1_parse_sprites(v, gb, &sd);
if (ret < 0)
return ret;
if (!s->current_picture.f->data[0]) {
av_log(avctx, AV_LOG_ERROR, "Got no sprites\n");
return -1;
}
if (v->two_sprites && (!s->last_picture_ptr || !s->last_picture.f->data[0])) {
av_log(avctx, AV_LOG_WARNING, "Need two sprites, only got one\n");
v->two_sprites = 0;
}
av_frame_unref(v->sprite_output_frame);
if ((ret = ff_get_buffer(avctx, v->sprite_output_frame, 0)) < 0)
return ret;
vc1_draw_sprites(v, &sd);
return 0;
}
| true | FFmpeg | 30f680ee0a2707af9a649a0aa3fd951d18a25c05 | static int vc1_decode_sprites(VC1Context *v, GetBitContext* gb)
{
int ret;
MpegEncContext *s = &v->s;
AVCodecContext *avctx = s->avctx;
SpriteData sd;
memset(&sd, 0, sizeof(sd));
ret = vc1_parse_sprites(v, gb, &sd);
if (ret < 0)
return ret;
if (!s->current_picture.f->data[0]) {
av_log(avctx, AV_LOG_ERROR, "Got no sprites\n");
return -1;
}
if (v->two_sprites && (!s->last_picture_ptr || !s->last_picture.f->data[0])) {
av_log(avctx, AV_LOG_WARNING, "Need two sprites, only got one\n");
v->two_sprites = 0;
}
av_frame_unref(v->sprite_output_frame);
if ((ret = ff_get_buffer(avctx, v->sprite_output_frame, 0)) < 0)
return ret;
vc1_draw_sprites(v, &sd);
return 0;
}
| {
"code": [
" if (!s->current_picture.f->data[0]) {"
],
"line_no": [
27
]
} | static int FUNC_0(VC1Context *VAR_0, GetBitContext* VAR_1)
{
int VAR_2;
MpegEncContext *s = &VAR_0->s;
AVCodecContext *avctx = s->avctx;
SpriteData sd;
memset(&sd, 0, sizeof(sd));
VAR_2 = vc1_parse_sprites(VAR_0, VAR_1, &sd);
if (VAR_2 < 0)
return VAR_2;
if (!s->current_picture.f->data[0]) {
av_log(avctx, AV_LOG_ERROR, "Got no sprites\n");
return -1;
}
if (VAR_0->two_sprites && (!s->last_picture_ptr || !s->last_picture.f->data[0])) {
av_log(avctx, AV_LOG_WARNING, "Need two sprites, only got one\n");
VAR_0->two_sprites = 0;
}
av_frame_unref(VAR_0->sprite_output_frame);
if ((VAR_2 = ff_get_buffer(avctx, VAR_0->sprite_output_frame, 0)) < 0)
return VAR_2;
vc1_draw_sprites(VAR_0, &sd);
return 0;
}
| [
"static int FUNC_0(VC1Context *VAR_0, GetBitContext* VAR_1)\n{",
"int VAR_2;",
"MpegEncContext *s = &VAR_0->s;",
"AVCodecContext *avctx = s->avctx;",
"SpriteData sd;",
"memset(&sd, 0, sizeof(sd));",
"VAR_2 = vc1_parse_sprites(VAR_0, VAR_1, &sd);",
"if (VAR_2 < 0)\nreturn VAR_2;",
"if (!s->current_picture.f->data[0]) {",
"av_log(avctx, AV_LOG_ERROR, \"Got no sprites\\n\");",
"return -1;",
"}",
"if (VAR_0->two_sprites && (!s->last_picture_ptr || !s->last_picture.f->data[0])) {",
"av_log(avctx, AV_LOG_WARNING, \"Need two sprites, only got one\\n\");",
"VAR_0->two_sprites = 0;",
"}",
"av_frame_unref(VAR_0->sprite_output_frame);",
"if ((VAR_2 = ff_get_buffer(avctx, VAR_0->sprite_output_frame, 0)) < 0)\nreturn VAR_2;",
"vc1_draw_sprites(VAR_0, &sd);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21,
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49,
51
],
[
55
],
[
59
],
[
61
]
]
|
13,669 | yuv2yuvX_altivec_real(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)
{
const vector signed int vini = {(1 << 18), (1 << 18), (1 << 18), (1 << 18)};
register int i, j;
{
int __attribute__ ((aligned (16))) val[dstW];
for (i = 0; i < (dstW -7); i+=4) {
vec_st(vini, i << 2, val);
}
for (; i < dstW; i++) {
val[i] = (1 << 18);
}
for (j = 0; j < lumFilterSize; j++) {
vector signed short l1, vLumFilter = vec_ld(j << 1, lumFilter);
vector unsigned char perm, perm0 = vec_lvsl(j << 1, lumFilter);
vLumFilter = vec_perm(vLumFilter, vLumFilter, perm0);
vLumFilter = vec_splat(vLumFilter, 0); // lumFilter[j] is loaded 8 times in vLumFilter
perm = vec_lvsl(0, lumSrc[j]);
l1 = vec_ld(0, lumSrc[j]);
for (i = 0; i < (dstW - 7); i+=8) {
int offset = i << 2;
vector signed short l2 = vec_ld((i << 1) + 16, lumSrc[j]);
vector signed int v1 = vec_ld(offset, val);
vector signed int v2 = vec_ld(offset + 16, val);
vector signed short ls = vec_perm(l1, l2, perm); // lumSrc[j][i] ... lumSrc[j][i+7]
vector signed int i1 = vec_mule(vLumFilter, ls);
vector signed int i2 = vec_mulo(vLumFilter, ls);
vector signed int vf1 = vec_mergeh(i1, i2);
vector signed int vf2 = vec_mergel(i1, i2); // lumSrc[j][i] * lumFilter[j] ... lumSrc[j][i+7] * lumFilter[j]
vector signed int vo1 = vec_add(v1, vf1);
vector signed int vo2 = vec_add(v2, vf2);
vec_st(vo1, offset, val);
vec_st(vo2, offset + 16, val);
l1 = l2;
}
for ( ; i < dstW; i++) {
val[i] += lumSrc[j][i] * lumFilter[j];
}
}
altivec_packIntArrayToCharArray(val,dest,dstW);
}
if (uDest != 0) {
int __attribute__ ((aligned (16))) u[chrDstW];
int __attribute__ ((aligned (16))) v[chrDstW];
for (i = 0; i < (chrDstW -7); i+=4) {
vec_st(vini, i << 2, u);
vec_st(vini, i << 2, v);
}
for (; i < chrDstW; i++) {
u[i] = (1 << 18);
v[i] = (1 << 18);
}
for (j = 0; j < chrFilterSize; j++) {
vector signed short l1, l1_V, vChrFilter = vec_ld(j << 1, chrFilter);
vector unsigned char perm, perm0 = vec_lvsl(j << 1, chrFilter);
vChrFilter = vec_perm(vChrFilter, vChrFilter, perm0);
vChrFilter = vec_splat(vChrFilter, 0); // chrFilter[j] is loaded 8 times in vChrFilter
perm = vec_lvsl(0, chrSrc[j]);
l1 = vec_ld(0, chrSrc[j]);
l1_V = vec_ld(2048 << 1, chrSrc[j]);
for (i = 0; i < (chrDstW - 7); i+=8) {
int offset = i << 2;
vector signed short l2 = vec_ld((i << 1) + 16, chrSrc[j]);
vector signed short l2_V = vec_ld(((i + 2048) << 1) + 16, chrSrc[j]);
vector signed int v1 = vec_ld(offset, u);
vector signed int v2 = vec_ld(offset + 16, u);
vector signed int v1_V = vec_ld(offset, v);
vector signed int v2_V = vec_ld(offset + 16, v);
vector signed short ls = vec_perm(l1, l2, perm); // chrSrc[j][i] ... chrSrc[j][i+7]
vector signed short ls_V = vec_perm(l1_V, l2_V, perm); // chrSrc[j][i+2048] ... chrSrc[j][i+2055]
vector signed int i1 = vec_mule(vChrFilter, ls);
vector signed int i2 = vec_mulo(vChrFilter, ls);
vector signed int i1_V = vec_mule(vChrFilter, ls_V);
vector signed int i2_V = vec_mulo(vChrFilter, ls_V);
vector signed int vf1 = vec_mergeh(i1, i2);
vector signed int vf2 = vec_mergel(i1, i2); // chrSrc[j][i] * chrFilter[j] ... chrSrc[j][i+7] * chrFilter[j]
vector signed int vf1_V = vec_mergeh(i1_V, i2_V);
vector signed int vf2_V = vec_mergel(i1_V, i2_V); // chrSrc[j][i] * chrFilter[j] ... chrSrc[j][i+7] * chrFilter[j]
vector signed int vo1 = vec_add(v1, vf1);
vector signed int vo2 = vec_add(v2, vf2);
vector signed int vo1_V = vec_add(v1_V, vf1_V);
vector signed int vo2_V = vec_add(v2_V, vf2_V);
vec_st(vo1, offset, u);
vec_st(vo2, offset + 16, u);
vec_st(vo1_V, offset, v);
vec_st(vo2_V, offset + 16, v);
l1 = l2;
l1_V = l2_V;
}
for ( ; i < chrDstW; i++) {
u[i] += chrSrc[j][i] * chrFilter[j];
v[i] += chrSrc[j][i + 2048] * chrFilter[j];
}
}
altivec_packIntArrayToCharArray(u,uDest,chrDstW);
altivec_packIntArrayToCharArray(v,vDest,chrDstW);
}
}
| true | FFmpeg | 6e42e6c4b410dbef8b593c2d796a5dad95f89ee4 | yuv2yuvX_altivec_real(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)
{
const vector signed int vini = {(1 << 18), (1 << 18), (1 << 18), (1 << 18)};
register int i, j;
{
int __attribute__ ((aligned (16))) val[dstW];
for (i = 0; i < (dstW -7); i+=4) {
vec_st(vini, i << 2, val);
}
for (; i < dstW; i++) {
val[i] = (1 << 18);
}
for (j = 0; j < lumFilterSize; j++) {
vector signed short l1, vLumFilter = vec_ld(j << 1, lumFilter);
vector unsigned char perm, perm0 = vec_lvsl(j << 1, lumFilter);
vLumFilter = vec_perm(vLumFilter, vLumFilter, perm0);
vLumFilter = vec_splat(vLumFilter, 0);
perm = vec_lvsl(0, lumSrc[j]);
l1 = vec_ld(0, lumSrc[j]);
for (i = 0; i < (dstW - 7); i+=8) {
int offset = i << 2;
vector signed short l2 = vec_ld((i << 1) + 16, lumSrc[j]);
vector signed int v1 = vec_ld(offset, val);
vector signed int v2 = vec_ld(offset + 16, val);
vector signed short ls = vec_perm(l1, l2, perm);
vector signed int i1 = vec_mule(vLumFilter, ls);
vector signed int i2 = vec_mulo(vLumFilter, ls);
vector signed int vf1 = vec_mergeh(i1, i2);
vector signed int vf2 = vec_mergel(i1, i2);
vector signed int vo1 = vec_add(v1, vf1);
vector signed int vo2 = vec_add(v2, vf2);
vec_st(vo1, offset, val);
vec_st(vo2, offset + 16, val);
l1 = l2;
}
for ( ; i < dstW; i++) {
val[i] += lumSrc[j][i] * lumFilter[j];
}
}
altivec_packIntArrayToCharArray(val,dest,dstW);
}
if (uDest != 0) {
int __attribute__ ((aligned (16))) u[chrDstW];
int __attribute__ ((aligned (16))) v[chrDstW];
for (i = 0; i < (chrDstW -7); i+=4) {
vec_st(vini, i << 2, u);
vec_st(vini, i << 2, v);
}
for (; i < chrDstW; i++) {
u[i] = (1 << 18);
v[i] = (1 << 18);
}
for (j = 0; j < chrFilterSize; j++) {
vector signed short l1, l1_V, vChrFilter = vec_ld(j << 1, chrFilter);
vector unsigned char perm, perm0 = vec_lvsl(j << 1, chrFilter);
vChrFilter = vec_perm(vChrFilter, vChrFilter, perm0);
vChrFilter = vec_splat(vChrFilter, 0);
perm = vec_lvsl(0, chrSrc[j]);
l1 = vec_ld(0, chrSrc[j]);
l1_V = vec_ld(2048 << 1, chrSrc[j]);
for (i = 0; i < (chrDstW - 7); i+=8) {
int offset = i << 2;
vector signed short l2 = vec_ld((i << 1) + 16, chrSrc[j]);
vector signed short l2_V = vec_ld(((i + 2048) << 1) + 16, chrSrc[j]);
vector signed int v1 = vec_ld(offset, u);
vector signed int v2 = vec_ld(offset + 16, u);
vector signed int v1_V = vec_ld(offset, v);
vector signed int v2_V = vec_ld(offset + 16, v);
vector signed short ls = vec_perm(l1, l2, perm);
vector signed short ls_V = vec_perm(l1_V, l2_V, perm);
vector signed int i1 = vec_mule(vChrFilter, ls);
vector signed int i2 = vec_mulo(vChrFilter, ls);
vector signed int i1_V = vec_mule(vChrFilter, ls_V);
vector signed int i2_V = vec_mulo(vChrFilter, ls_V);
vector signed int vf1 = vec_mergeh(i1, i2);
vector signed int vf2 = vec_mergel(i1, i2);
vector signed int vf1_V = vec_mergeh(i1_V, i2_V);
vector signed int vf2_V = vec_mergel(i1_V, i2_V);
vector signed int vo1 = vec_add(v1, vf1);
vector signed int vo2 = vec_add(v2, vf2);
vector signed int vo1_V = vec_add(v1_V, vf1_V);
vector signed int vo2_V = vec_add(v2_V, vf2_V);
vec_st(vo1, offset, u);
vec_st(vo2, offset + 16, u);
vec_st(vo1_V, offset, v);
vec_st(vo2_V, offset + 16, v);
l1 = l2;
l1_V = l2_V;
}
for ( ; i < chrDstW; i++) {
u[i] += chrSrc[j][i] * chrFilter[j];
v[i] += chrSrc[j][i + 2048] * chrFilter[j];
}
}
altivec_packIntArrayToCharArray(u,uDest,chrDstW);
altivec_packIntArrayToCharArray(v,vDest,chrDstW);
}
}
| {
"code": [
"\t\t int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,",
"\t\t uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)",
" const vector signed int vini = {(1 << 18), (1 << 18), (1 << 18), (1 << 18)};",
" register int i, j;",
" int __attribute__ ((aligned (16))) val[dstW];",
" for (i = 0; i < (dstW -7); i+=4) {",
" vec_st(vini, i << 2, val);",
" for (; i < dstW; i++) {",
" val[i] = (1 << 18);",
" for (j = 0; j < lumFilterSize; j++) {",
" vector signed short l1, vLumFilter = vec_ld(j << 1, lumFilter);",
" vector unsigned char perm, perm0 = vec_lvsl(j << 1, lumFilter);",
" vLumFilter = vec_perm(vLumFilter, vLumFilter, perm0);",
" perm = vec_lvsl(0, lumSrc[j]);",
" l1 = vec_ld(0, lumSrc[j]);",
" for (i = 0; i < (dstW - 7); i+=8) {",
"\tint offset = i << 2;",
"\tvector signed short l2 = vec_ld((i << 1) + 16, lumSrc[j]);",
"\tvector signed int v1 = vec_ld(offset, val);",
"\tvector signed int v2 = vec_ld(offset + 16, val);",
"\tvector signed int i1 = vec_mule(vLumFilter, ls);",
"\tvector signed int i2 = vec_mulo(vLumFilter, ls);",
"\tvector signed int vf1 = vec_mergeh(i1, i2);",
"\tvector signed int vo1 = vec_add(v1, vf1);",
"\tvector signed int vo2 = vec_add(v2, vf2);",
"\tvec_st(vo1, offset, val);",
"\tvec_st(vo2, offset + 16, val);",
"\tl1 = l2;",
" for ( ; i < dstW; i++) {",
"\tval[i] += lumSrc[j][i] * lumFilter[j];",
" altivec_packIntArrayToCharArray(val,dest,dstW);",
" if (uDest != 0) {",
" int __attribute__ ((aligned (16))) u[chrDstW];",
" int __attribute__ ((aligned (16))) v[chrDstW];",
" for (i = 0; i < (chrDstW -7); i+=4) {",
" vec_st(vini, i << 2, u);",
" vec_st(vini, i << 2, v);",
" for (; i < chrDstW; i++) {",
" u[i] = (1 << 18);",
" v[i] = (1 << 18);",
" for (j = 0; j < chrFilterSize; j++) {",
" vector signed short l1, l1_V, vChrFilter = vec_ld(j << 1, chrFilter);",
" vector unsigned char perm, perm0 = vec_lvsl(j << 1, chrFilter);",
" vChrFilter = vec_perm(vChrFilter, vChrFilter, perm0);",
" perm = vec_lvsl(0, chrSrc[j]);",
" l1 = vec_ld(0, chrSrc[j]);",
" l1_V = vec_ld(2048 << 1, chrSrc[j]);",
" for (i = 0; i < (chrDstW - 7); i+=8) {",
"\tint offset = i << 2;",
"\tvector signed short l2 = vec_ld((i << 1) + 16, chrSrc[j]);",
"\tvector signed short l2_V = vec_ld(((i + 2048) << 1) + 16, chrSrc[j]);",
"\tvector signed int v1 = vec_ld(offset, u);",
"\tvector signed int v2 = vec_ld(offset + 16, u);",
"\tvector signed int v1_V = vec_ld(offset, v);",
"\tvector signed int v2_V = vec_ld(offset + 16, v);",
"\tvector signed int i1 = vec_mule(vChrFilter, ls);",
"\tvector signed int i2 = vec_mulo(vChrFilter, ls);",
"\tvector signed int i1_V = vec_mule(vChrFilter, ls_V);",
"\tvector signed int i2_V = vec_mulo(vChrFilter, ls_V);",
"\tvector signed int vf1 = vec_mergeh(i1, i2);",
"\tvector signed int vf1_V = vec_mergeh(i1_V, i2_V);",
"\tvector signed int vo1 = vec_add(v1, vf1);",
"\tvector signed int vo2 = vec_add(v2, vf2);",
"\tvector signed int vo1_V = vec_add(v1_V, vf1_V);",
"\tvector signed int vo2_V = vec_add(v2_V, vf2_V);",
"\tvec_st(vo1, offset, u);",
"\tvec_st(vo2, offset + 16, u);",
"\tvec_st(vo1_V, offset, v);",
"\tvec_st(vo2_V, offset + 16, v);",
"\tl1 = l2;",
"\tl1_V = l2_V;",
" for ( ; i < chrDstW; i++) {",
"\tu[i] += chrSrc[j][i] * chrFilter[j];",
"\tv[i] += chrSrc[j][i + 2048] * chrFilter[j];",
" altivec_packIntArrayToCharArray(u,uDest,chrDstW);",
" altivec_packIntArrayToCharArray(v,vDest,chrDstW);"
],
"line_no": [
3,
5,
9,
11,
15,
19,
21,
25,
27,
33,
35,
37,
39,
45,
47,
51,
53,
55,
59,
61,
69,
71,
75,
81,
83,
87,
89,
93,
97,
99,
105,
109,
111,
113,
117,
119,
121,
125,
127,
129,
135,
137,
139,
141,
147,
149,
151,
155,
53,
159,
161,
165,
167,
169,
171,
181,
183,
185,
187,
75,
195,
81,
83,
205,
207,
211,
213,
215,
217,
93,
223,
227,
229,
231,
237,
239
]
} | FUNC_0(int16_t *VAR_0, int16_t **VAR_1, int VAR_2,
int16_t *VAR_3, int16_t **VAR_4, int VAR_5,
uint8_t *VAR_6, uint8_t *VAR_7, uint8_t *VAR_8, int VAR_9, int VAR_10)
{
const vector signed int VAR_11 = {(1 << 18), (1 << 18), (1 << 18), (1 << 18)};
register int VAR_12, VAR_13;
{
int __attribute__ ((aligned (16))) VAR_14[VAR_9];
for (VAR_12 = 0; VAR_12 < (VAR_9 -7); VAR_12+=4) {
vec_st(VAR_11, VAR_12 << 2, VAR_14);
}
for (; VAR_12 < VAR_9; VAR_12++) {
VAR_14[VAR_12] = (1 << 18);
}
for (VAR_13 = 0; VAR_13 < VAR_2; VAR_13++) {
vector signed short l1, vLumFilter = vec_ld(VAR_13 << 1, VAR_0);
vector unsigned char perm, perm0 = vec_lvsl(VAR_13 << 1, VAR_0);
vLumFilter = vec_perm(vLumFilter, vLumFilter, perm0);
vLumFilter = vec_splat(vLumFilter, 0);
perm = vec_lvsl(0, VAR_1[VAR_13]);
l1 = vec_ld(0, VAR_1[VAR_13]);
for (VAR_12 = 0; VAR_12 < (VAR_9 - 7); VAR_12+=8) {
int VAR_18 = VAR_12 << 2;
vector signed short l2 = vec_ld((VAR_12 << 1) + 16, VAR_1[VAR_13]);
vector signed int v1 = vec_ld(VAR_18, VAR_14);
vector signed int v2 = vec_ld(VAR_18 + 16, VAR_14);
vector signed short ls = vec_perm(l1, l2, perm);
vector signed int i1 = vec_mule(vLumFilter, ls);
vector signed int i2 = vec_mulo(vLumFilter, ls);
vector signed int vf1 = vec_mergeh(i1, i2);
vector signed int vf2 = vec_mergel(i1, i2);
vector signed int vo1 = vec_add(v1, vf1);
vector signed int vo2 = vec_add(v2, vf2);
vec_st(vo1, VAR_18, VAR_14);
vec_st(vo2, VAR_18 + 16, VAR_14);
l1 = l2;
}
for ( ; VAR_12 < VAR_9; VAR_12++) {
VAR_14[VAR_12] += VAR_1[VAR_13][VAR_12] * VAR_0[VAR_13];
}
}
altivec_packIntArrayToCharArray(VAR_14,VAR_6,VAR_9);
}
if (VAR_7 != 0) {
int __attribute__ ((aligned (16))) VAR_16[VAR_10];
int __attribute__ ((aligned (16))) VAR_17[VAR_10];
for (VAR_12 = 0; VAR_12 < (VAR_10 -7); VAR_12+=4) {
vec_st(VAR_11, VAR_12 << 2, VAR_16);
vec_st(VAR_11, VAR_12 << 2, VAR_17);
}
for (; VAR_12 < VAR_10; VAR_12++) {
VAR_16[VAR_12] = (1 << 18);
VAR_17[VAR_12] = (1 << 18);
}
for (VAR_13 = 0; VAR_13 < VAR_5; VAR_13++) {
vector signed short l1, l1_V, vChrFilter = vec_ld(VAR_13 << 1, VAR_3);
vector unsigned char perm, perm0 = vec_lvsl(VAR_13 << 1, VAR_3);
vChrFilter = vec_perm(vChrFilter, vChrFilter, perm0);
vChrFilter = vec_splat(vChrFilter, 0);
perm = vec_lvsl(0, VAR_4[VAR_13]);
l1 = vec_ld(0, VAR_4[VAR_13]);
l1_V = vec_ld(2048 << 1, VAR_4[VAR_13]);
for (VAR_12 = 0; VAR_12 < (VAR_10 - 7); VAR_12+=8) {
int VAR_18 = VAR_12 << 2;
vector signed short l2 = vec_ld((VAR_12 << 1) + 16, VAR_4[VAR_13]);
vector signed short l2_V = vec_ld(((VAR_12 + 2048) << 1) + 16, VAR_4[VAR_13]);
vector signed int v1 = vec_ld(VAR_18, VAR_16);
vector signed int v2 = vec_ld(VAR_18 + 16, VAR_16);
vector signed int v1_V = vec_ld(VAR_18, VAR_17);
vector signed int v2_V = vec_ld(VAR_18 + 16, VAR_17);
vector signed short ls = vec_perm(l1, l2, perm);
vector signed short ls_V = vec_perm(l1_V, l2_V, perm);
vector signed int i1 = vec_mule(vChrFilter, ls);
vector signed int i2 = vec_mulo(vChrFilter, ls);
vector signed int i1_V = vec_mule(vChrFilter, ls_V);
vector signed int i2_V = vec_mulo(vChrFilter, ls_V);
vector signed int vf1 = vec_mergeh(i1, i2);
vector signed int vf2 = vec_mergel(i1, i2);
vector signed int vf1_V = vec_mergeh(i1_V, i2_V);
vector signed int vf2_V = vec_mergel(i1_V, i2_V);
vector signed int vo1 = vec_add(v1, vf1);
vector signed int vo2 = vec_add(v2, vf2);
vector signed int vo1_V = vec_add(v1_V, vf1_V);
vector signed int vo2_V = vec_add(v2_V, vf2_V);
vec_st(vo1, VAR_18, VAR_16);
vec_st(vo2, VAR_18 + 16, VAR_16);
vec_st(vo1_V, VAR_18, VAR_17);
vec_st(vo2_V, VAR_18 + 16, VAR_17);
l1 = l2;
l1_V = l2_V;
}
for ( ; VAR_12 < VAR_10; VAR_12++) {
VAR_16[VAR_12] += VAR_4[VAR_13][VAR_12] * VAR_3[VAR_13];
VAR_17[VAR_12] += VAR_4[VAR_13][VAR_12 + 2048] * VAR_3[VAR_13];
}
}
altivec_packIntArrayToCharArray(VAR_16,VAR_7,VAR_10);
altivec_packIntArrayToCharArray(VAR_17,VAR_8,VAR_10);
}
}
| [
"FUNC_0(int16_t *VAR_0, int16_t **VAR_1, int VAR_2,\nint16_t *VAR_3, int16_t **VAR_4, int VAR_5,\nuint8_t *VAR_6, uint8_t *VAR_7, uint8_t *VAR_8, int VAR_9, int VAR_10)\n{",
"const vector signed int VAR_11 = {(1 << 18), (1 << 18), (1 << 18), (1 << 18)};",
"register int VAR_12, VAR_13;",
"{",
"int __attribute__ ((aligned (16))) VAR_14[VAR_9];",
"for (VAR_12 = 0; VAR_12 < (VAR_9 -7); VAR_12+=4) {",
"vec_st(VAR_11, VAR_12 << 2, VAR_14);",
"}",
"for (; VAR_12 < VAR_9; VAR_12++) {",
"VAR_14[VAR_12] = (1 << 18);",
"}",
"for (VAR_13 = 0; VAR_13 < VAR_2; VAR_13++) {",
"vector signed short l1, vLumFilter = vec_ld(VAR_13 << 1, VAR_0);",
"vector unsigned char perm, perm0 = vec_lvsl(VAR_13 << 1, VAR_0);",
"vLumFilter = vec_perm(vLumFilter, vLumFilter, perm0);",
"vLumFilter = vec_splat(vLumFilter, 0);",
"perm = vec_lvsl(0, VAR_1[VAR_13]);",
"l1 = vec_ld(0, VAR_1[VAR_13]);",
"for (VAR_12 = 0; VAR_12 < (VAR_9 - 7); VAR_12+=8) {",
"int VAR_18 = VAR_12 << 2;",
"vector signed short l2 = vec_ld((VAR_12 << 1) + 16, VAR_1[VAR_13]);",
"vector signed int v1 = vec_ld(VAR_18, VAR_14);",
"vector signed int v2 = vec_ld(VAR_18 + 16, VAR_14);",
"vector signed short ls = vec_perm(l1, l2, perm);",
"vector signed int i1 = vec_mule(vLumFilter, ls);",
"vector signed int i2 = vec_mulo(vLumFilter, ls);",
"vector signed int vf1 = vec_mergeh(i1, i2);",
"vector signed int vf2 = vec_mergel(i1, i2);",
"vector signed int vo1 = vec_add(v1, vf1);",
"vector signed int vo2 = vec_add(v2, vf2);",
"vec_st(vo1, VAR_18, VAR_14);",
"vec_st(vo2, VAR_18 + 16, VAR_14);",
"l1 = l2;",
"}",
"for ( ; VAR_12 < VAR_9; VAR_12++) {",
"VAR_14[VAR_12] += VAR_1[VAR_13][VAR_12] * VAR_0[VAR_13];",
"}",
"}",
"altivec_packIntArrayToCharArray(VAR_14,VAR_6,VAR_9);",
"}",
"if (VAR_7 != 0) {",
"int __attribute__ ((aligned (16))) VAR_16[VAR_10];",
"int __attribute__ ((aligned (16))) VAR_17[VAR_10];",
"for (VAR_12 = 0; VAR_12 < (VAR_10 -7); VAR_12+=4) {",
"vec_st(VAR_11, VAR_12 << 2, VAR_16);",
"vec_st(VAR_11, VAR_12 << 2, VAR_17);",
"}",
"for (; VAR_12 < VAR_10; VAR_12++) {",
"VAR_16[VAR_12] = (1 << 18);",
"VAR_17[VAR_12] = (1 << 18);",
"}",
"for (VAR_13 = 0; VAR_13 < VAR_5; VAR_13++) {",
"vector signed short l1, l1_V, vChrFilter = vec_ld(VAR_13 << 1, VAR_3);",
"vector unsigned char perm, perm0 = vec_lvsl(VAR_13 << 1, VAR_3);",
"vChrFilter = vec_perm(vChrFilter, vChrFilter, perm0);",
"vChrFilter = vec_splat(vChrFilter, 0);",
"perm = vec_lvsl(0, VAR_4[VAR_13]);",
"l1 = vec_ld(0, VAR_4[VAR_13]);",
"l1_V = vec_ld(2048 << 1, VAR_4[VAR_13]);",
"for (VAR_12 = 0; VAR_12 < (VAR_10 - 7); VAR_12+=8) {",
"int VAR_18 = VAR_12 << 2;",
"vector signed short l2 = vec_ld((VAR_12 << 1) + 16, VAR_4[VAR_13]);",
"vector signed short l2_V = vec_ld(((VAR_12 + 2048) << 1) + 16, VAR_4[VAR_13]);",
"vector signed int v1 = vec_ld(VAR_18, VAR_16);",
"vector signed int v2 = vec_ld(VAR_18 + 16, VAR_16);",
"vector signed int v1_V = vec_ld(VAR_18, VAR_17);",
"vector signed int v2_V = vec_ld(VAR_18 + 16, VAR_17);",
"vector signed short ls = vec_perm(l1, l2, perm);",
"vector signed short ls_V = vec_perm(l1_V, l2_V, perm);",
"vector signed int i1 = vec_mule(vChrFilter, ls);",
"vector signed int i2 = vec_mulo(vChrFilter, ls);",
"vector signed int i1_V = vec_mule(vChrFilter, ls_V);",
"vector signed int i2_V = vec_mulo(vChrFilter, ls_V);",
"vector signed int vf1 = vec_mergeh(i1, i2);",
"vector signed int vf2 = vec_mergel(i1, i2);",
"vector signed int vf1_V = vec_mergeh(i1_V, i2_V);",
"vector signed int vf2_V = vec_mergel(i1_V, i2_V);",
"vector signed int vo1 = vec_add(v1, vf1);",
"vector signed int vo2 = vec_add(v2, vf2);",
"vector signed int vo1_V = vec_add(v1_V, vf1_V);",
"vector signed int vo2_V = vec_add(v2_V, vf2_V);",
"vec_st(vo1, VAR_18, VAR_16);",
"vec_st(vo2, VAR_18 + 16, VAR_16);",
"vec_st(vo1_V, VAR_18, VAR_17);",
"vec_st(vo2_V, VAR_18 + 16, VAR_17);",
"l1 = l2;",
"l1_V = l2_V;",
"}",
"for ( ; VAR_12 < VAR_10; VAR_12++) {",
"VAR_16[VAR_12] += VAR_4[VAR_13][VAR_12] * VAR_3[VAR_13];",
"VAR_17[VAR_12] += VAR_4[VAR_13][VAR_12 + 2048] * VAR_3[VAR_13];",
"}",
"}",
"altivec_packIntArrayToCharArray(VAR_16,VAR_7,VAR_10);",
"altivec_packIntArrayToCharArray(VAR_17,VAR_8,VAR_10);",
"}",
"}"
]
| [
1,
1,
1,
0,
1,
1,
1,
0,
1,
1,
0,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
0,
1,
1,
1,
1,
1,
0,
1,
1,
0,
0,
1,
0,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
0,
1,
1,
1,
1,
0,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
0,
0,
1,
1,
1,
1,
0,
0,
1,
0,
0,
0,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
1,
1,
0,
0,
1,
1,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
65
],
[
69
],
[
71
],
[
75
],
[
77
],
[
81
],
[
83
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191
],
[
193
],
[
195
],
[
197
],
[
201
],
[
203
],
[
205
],
[
207
],
[
211
],
[
213
],
[
215
],
[
217
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
]
]
|
13,670 | static void m5206_mbar_writeb(void *opaque, target_phys_addr_t offset,
uint32_t value)
{
m5206_mbar_state *s = (m5206_mbar_state *)opaque;
int width;
offset &= 0x3ff;
if (offset > 0x200) {
hw_error("Bad MBAR write offset 0x%x", (int)offset);
}
width = m5206_mbar_width[offset >> 2];
if (width > 1) {
uint32_t tmp;
tmp = m5206_mbar_readw(opaque, offset & ~1);
if (offset & 1) {
tmp = (tmp & 0xff00) | value;
} else {
tmp = (tmp & 0x00ff) | (value << 8);
}
m5206_mbar_writew(opaque, offset & ~1, tmp);
return;
}
m5206_mbar_write(s, offset, value, 1);
}
| true | qemu | a32354e206895400d17c3de9a8df1de96d3df289 | static void m5206_mbar_writeb(void *opaque, target_phys_addr_t offset,
uint32_t value)
{
m5206_mbar_state *s = (m5206_mbar_state *)opaque;
int width;
offset &= 0x3ff;
if (offset > 0x200) {
hw_error("Bad MBAR write offset 0x%x", (int)offset);
}
width = m5206_mbar_width[offset >> 2];
if (width > 1) {
uint32_t tmp;
tmp = m5206_mbar_readw(opaque, offset & ~1);
if (offset & 1) {
tmp = (tmp & 0xff00) | value;
} else {
tmp = (tmp & 0x00ff) | (value << 8);
}
m5206_mbar_writew(opaque, offset & ~1, tmp);
return;
}
m5206_mbar_write(s, offset, value, 1);
}
| {
"code": [
" if (offset > 0x200) {",
" if (offset > 0x200) {",
" if (offset > 0x200) {",
" if (offset > 0x200) {",
" if (offset > 0x200) {",
" if (offset > 0x200) {"
],
"line_no": [
13,
13,
13,
13,
13,
13
]
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint32_t VAR_2)
{
m5206_mbar_state *s = (m5206_mbar_state *)VAR_0;
int VAR_3;
VAR_1 &= 0x3ff;
if (VAR_1 > 0x200) {
hw_error("Bad MBAR write VAR_1 0x%x", (int)VAR_1);
}
VAR_3 = m5206_mbar_width[VAR_1 >> 2];
if (VAR_3 > 1) {
uint32_t tmp;
tmp = m5206_mbar_readw(VAR_0, VAR_1 & ~1);
if (VAR_1 & 1) {
tmp = (tmp & 0xff00) | VAR_2;
} else {
tmp = (tmp & 0x00ff) | (VAR_2 << 8);
}
m5206_mbar_writew(VAR_0, VAR_1 & ~1, tmp);
return;
}
m5206_mbar_write(s, VAR_1, VAR_2, 1);
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint32_t VAR_2)\n{",
"m5206_mbar_state *s = (m5206_mbar_state *)VAR_0;",
"int VAR_3;",
"VAR_1 &= 0x3ff;",
"if (VAR_1 > 0x200) {",
"hw_error(\"Bad MBAR write VAR_1 0x%x\", (int)VAR_1);",
"}",
"VAR_3 = m5206_mbar_width[VAR_1 >> 2];",
"if (VAR_3 > 1) {",
"uint32_t tmp;",
"tmp = m5206_mbar_readw(VAR_0, VAR_1 & ~1);",
"if (VAR_1 & 1) {",
"tmp = (tmp & 0xff00) | VAR_2;",
"} else {",
"tmp = (tmp & 0x00ff) | (VAR_2 << 8);",
"}",
"m5206_mbar_writew(VAR_0, VAR_1 & ~1, tmp);",
"return;",
"}",
"m5206_mbar_write(s, VAR_1, VAR_2, 1);",
"}"
]
| [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
]
]
|
13,671 | static bool is_zero_sectors(BlockDriverState *bs, int64_t start,
uint32_t count)
{
int nr;
BlockDriverState *file;
int64_t res;
if (!count) {
return true;
res = bdrv_get_block_status_above(bs, NULL, start, count,
&nr, &file);
return res >= 0 && (res & BDRV_BLOCK_ZERO) && nr == count; | true | qemu | fbaa6bb3d3b4be71b7e234e908cb3c6bd280a222 | static bool is_zero_sectors(BlockDriverState *bs, int64_t start,
uint32_t count)
{
int nr;
BlockDriverState *file;
int64_t res;
if (!count) {
return true;
res = bdrv_get_block_status_above(bs, NULL, start, count,
&nr, &file);
return res >= 0 && (res & BDRV_BLOCK_ZERO) && nr == count; | {
"code": [],
"line_no": []
} | static bool FUNC_0(BlockDriverState *bs, int64_t start,
uint32_t count)
{
int VAR_0;
BlockDriverState *file;
int64_t res;
if (!count) {
return true;
res = bdrv_get_block_status_above(bs, NULL, start, count,
&VAR_0, &file);
return res >= 0 && (res & BDRV_BLOCK_ZERO) && VAR_0 == count; | [
"static bool FUNC_0(BlockDriverState *bs, int64_t start,\nuint32_t count)\n{",
"int VAR_0;",
"BlockDriverState *file;",
"int64_t res;",
"if (!count) {",
"return true;",
"res = bdrv_get_block_status_above(bs, NULL, start, count,\n&VAR_0, &file);",
"return res >= 0 && (res & BDRV_BLOCK_ZERO) && VAR_0 == count;"
]
| [
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
2,
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9,
10
],
[
11
]
]
|
13,674 | static void mxf_write_multi_descriptor(AVFormatContext *s)
{
MXFContext *mxf = s->priv_data;
AVIOContext *pb = s->pb;
const uint8_t *ul;
int i;
mxf_write_metadata_key(pb, 0x014400);
PRINT_KEY(s, "multiple descriptor key", pb->buf_ptr - 16);
klv_encode_ber_length(pb, 64 + 16 * s->nb_streams);
mxf_write_local_tag(pb, 16, 0x3C0A);
mxf_write_uuid(pb, MultipleDescriptor, 0);
PRINT_KEY(s, "multi_desc uid", pb->buf_ptr - 16);
// write sample rate
mxf_write_local_tag(pb, 8, 0x3001);
avio_wb32(pb, mxf->time_base.den);
avio_wb32(pb, mxf->time_base.num);
// write essence container ul
mxf_write_local_tag(pb, 16, 0x3004);
if (mxf->essence_container_count > 1)
ul = multiple_desc_ul;
else {
MXFStreamContext *sc = s->streams[0]->priv_data;
ul = mxf_essence_container_uls[sc->index].container_ul;
}
avio_write(pb, ul, 16);
// write sub descriptor refs
mxf_write_local_tag(pb, s->nb_streams * 16 + 8, 0x3F01);
mxf_write_refs_count(pb, s->nb_streams);
for (i = 0; i < s->nb_streams; i++)
mxf_write_uuid(pb, SubDescriptor, i);
}
| true | FFmpeg | e3ba817b95bbdc7c8aaf83b4a6804d1b49eb4de4 | static void mxf_write_multi_descriptor(AVFormatContext *s)
{
MXFContext *mxf = s->priv_data;
AVIOContext *pb = s->pb;
const uint8_t *ul;
int i;
mxf_write_metadata_key(pb, 0x014400);
PRINT_KEY(s, "multiple descriptor key", pb->buf_ptr - 16);
klv_encode_ber_length(pb, 64 + 16 * s->nb_streams);
mxf_write_local_tag(pb, 16, 0x3C0A);
mxf_write_uuid(pb, MultipleDescriptor, 0);
PRINT_KEY(s, "multi_desc uid", pb->buf_ptr - 16);
mxf_write_local_tag(pb, 8, 0x3001);
avio_wb32(pb, mxf->time_base.den);
avio_wb32(pb, mxf->time_base.num);
mxf_write_local_tag(pb, 16, 0x3004);
if (mxf->essence_container_count > 1)
ul = multiple_desc_ul;
else {
MXFStreamContext *sc = s->streams[0]->priv_data;
ul = mxf_essence_container_uls[sc->index].container_ul;
}
avio_write(pb, ul, 16);
mxf_write_local_tag(pb, s->nb_streams * 16 + 8, 0x3F01);
mxf_write_refs_count(pb, s->nb_streams);
for (i = 0; i < s->nb_streams; i++)
mxf_write_uuid(pb, SubDescriptor, i);
}
| {
"code": [
" klv_encode_ber_length(pb, 64 + 16 * s->nb_streams);"
],
"line_no": [
19
]
} | static void FUNC_0(AVFormatContext *VAR_0)
{
MXFContext *mxf = VAR_0->priv_data;
AVIOContext *pb = VAR_0->pb;
const uint8_t *VAR_1;
int VAR_2;
mxf_write_metadata_key(pb, 0x014400);
PRINT_KEY(VAR_0, "multiple descriptor key", pb->buf_ptr - 16);
klv_encode_ber_length(pb, 64 + 16 * VAR_0->nb_streams);
mxf_write_local_tag(pb, 16, 0x3C0A);
mxf_write_uuid(pb, MultipleDescriptor, 0);
PRINT_KEY(VAR_0, "multi_desc uid", pb->buf_ptr - 16);
mxf_write_local_tag(pb, 8, 0x3001);
avio_wb32(pb, mxf->time_base.den);
avio_wb32(pb, mxf->time_base.num);
mxf_write_local_tag(pb, 16, 0x3004);
if (mxf->essence_container_count > 1)
VAR_1 = multiple_desc_ul;
else {
MXFStreamContext *sc = VAR_0->streams[0]->priv_data;
VAR_1 = mxf_essence_container_uls[sc->index].container_ul;
}
avio_write(pb, VAR_1, 16);
mxf_write_local_tag(pb, VAR_0->nb_streams * 16 + 8, 0x3F01);
mxf_write_refs_count(pb, VAR_0->nb_streams);
for (VAR_2 = 0; VAR_2 < VAR_0->nb_streams; VAR_2++)
mxf_write_uuid(pb, SubDescriptor, VAR_2);
}
| [
"static void FUNC_0(AVFormatContext *VAR_0)\n{",
"MXFContext *mxf = VAR_0->priv_data;",
"AVIOContext *pb = VAR_0->pb;",
"const uint8_t *VAR_1;",
"int VAR_2;",
"mxf_write_metadata_key(pb, 0x014400);",
"PRINT_KEY(VAR_0, \"multiple descriptor key\", pb->buf_ptr - 16);",
"klv_encode_ber_length(pb, 64 + 16 * VAR_0->nb_streams);",
"mxf_write_local_tag(pb, 16, 0x3C0A);",
"mxf_write_uuid(pb, MultipleDescriptor, 0);",
"PRINT_KEY(VAR_0, \"multi_desc uid\", pb->buf_ptr - 16);",
"mxf_write_local_tag(pb, 8, 0x3001);",
"avio_wb32(pb, mxf->time_base.den);",
"avio_wb32(pb, mxf->time_base.num);",
"mxf_write_local_tag(pb, 16, 0x3004);",
"if (mxf->essence_container_count > 1)\nVAR_1 = multiple_desc_ul;",
"else {",
"MXFStreamContext *sc = VAR_0->streams[0]->priv_data;",
"VAR_1 = mxf_essence_container_uls[sc->index].container_ul;",
"}",
"avio_write(pb, VAR_1, 16);",
"mxf_write_local_tag(pb, VAR_0->nb_streams * 16 + 8, 0x3F01);",
"mxf_write_refs_count(pb, VAR_0->nb_streams);",
"for (VAR_2 = 0; VAR_2 < VAR_0->nb_streams; VAR_2++)",
"mxf_write_uuid(pb, SubDescriptor, VAR_2);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
33
],
[
35
],
[
37
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
]
]
|
13,675 | BlockDeviceInfo *bdrv_block_device_info(BlockDriverState *bs)
{
BlockDeviceInfo *info = g_malloc0(sizeof(*info));
info->file = g_strdup(bs->filename);
info->ro = bs->read_only;
info->drv = g_strdup(bs->drv->format_name);
info->encrypted = bs->encrypted;
info->encryption_key_missing = bdrv_key_required(bs);
info->cache = g_new(BlockdevCacheInfo, 1);
*info->cache = (BlockdevCacheInfo) {
.writeback = bdrv_enable_write_cache(bs),
.direct = !!(bs->open_flags & BDRV_O_NOCACHE),
.no_flush = !!(bs->open_flags & BDRV_O_NO_FLUSH),
};
if (bs->node_name[0]) {
info->has_node_name = true;
info->node_name = g_strdup(bs->node_name);
}
if (bs->backing_file[0]) {
info->has_backing_file = true;
info->backing_file = g_strdup(bs->backing_file);
}
info->backing_file_depth = bdrv_get_backing_file_depth(bs);
info->detect_zeroes = bs->detect_zeroes;
if (bs->io_limits_enabled) {
ThrottleConfig cfg;
throttle_get_config(&bs->throttle_state, &cfg);
info->bps = cfg.buckets[THROTTLE_BPS_TOTAL].avg;
info->bps_rd = cfg.buckets[THROTTLE_BPS_READ].avg;
info->bps_wr = cfg.buckets[THROTTLE_BPS_WRITE].avg;
info->iops = cfg.buckets[THROTTLE_OPS_TOTAL].avg;
info->iops_rd = cfg.buckets[THROTTLE_OPS_READ].avg;
info->iops_wr = cfg.buckets[THROTTLE_OPS_WRITE].avg;
info->has_bps_max = cfg.buckets[THROTTLE_BPS_TOTAL].max;
info->bps_max = cfg.buckets[THROTTLE_BPS_TOTAL].max;
info->has_bps_rd_max = cfg.buckets[THROTTLE_BPS_READ].max;
info->bps_rd_max = cfg.buckets[THROTTLE_BPS_READ].max;
info->has_bps_wr_max = cfg.buckets[THROTTLE_BPS_WRITE].max;
info->bps_wr_max = cfg.buckets[THROTTLE_BPS_WRITE].max;
info->has_iops_max = cfg.buckets[THROTTLE_OPS_TOTAL].max;
info->iops_max = cfg.buckets[THROTTLE_OPS_TOTAL].max;
info->has_iops_rd_max = cfg.buckets[THROTTLE_OPS_READ].max;
info->iops_rd_max = cfg.buckets[THROTTLE_OPS_READ].max;
info->has_iops_wr_max = cfg.buckets[THROTTLE_OPS_WRITE].max;
info->iops_wr_max = cfg.buckets[THROTTLE_OPS_WRITE].max;
info->has_iops_size = cfg.op_size;
info->iops_size = cfg.op_size;
}
info->write_threshold = bdrv_write_threshold_get(bs);
return info;
}
| true | qemu | d5a8ee60a0fbc20a2c2d02f3bda1bb1bd365f1ee | BlockDeviceInfo *bdrv_block_device_info(BlockDriverState *bs)
{
BlockDeviceInfo *info = g_malloc0(sizeof(*info));
info->file = g_strdup(bs->filename);
info->ro = bs->read_only;
info->drv = g_strdup(bs->drv->format_name);
info->encrypted = bs->encrypted;
info->encryption_key_missing = bdrv_key_required(bs);
info->cache = g_new(BlockdevCacheInfo, 1);
*info->cache = (BlockdevCacheInfo) {
.writeback = bdrv_enable_write_cache(bs),
.direct = !!(bs->open_flags & BDRV_O_NOCACHE),
.no_flush = !!(bs->open_flags & BDRV_O_NO_FLUSH),
};
if (bs->node_name[0]) {
info->has_node_name = true;
info->node_name = g_strdup(bs->node_name);
}
if (bs->backing_file[0]) {
info->has_backing_file = true;
info->backing_file = g_strdup(bs->backing_file);
}
info->backing_file_depth = bdrv_get_backing_file_depth(bs);
info->detect_zeroes = bs->detect_zeroes;
if (bs->io_limits_enabled) {
ThrottleConfig cfg;
throttle_get_config(&bs->throttle_state, &cfg);
info->bps = cfg.buckets[THROTTLE_BPS_TOTAL].avg;
info->bps_rd = cfg.buckets[THROTTLE_BPS_READ].avg;
info->bps_wr = cfg.buckets[THROTTLE_BPS_WRITE].avg;
info->iops = cfg.buckets[THROTTLE_OPS_TOTAL].avg;
info->iops_rd = cfg.buckets[THROTTLE_OPS_READ].avg;
info->iops_wr = cfg.buckets[THROTTLE_OPS_WRITE].avg;
info->has_bps_max = cfg.buckets[THROTTLE_BPS_TOTAL].max;
info->bps_max = cfg.buckets[THROTTLE_BPS_TOTAL].max;
info->has_bps_rd_max = cfg.buckets[THROTTLE_BPS_READ].max;
info->bps_rd_max = cfg.buckets[THROTTLE_BPS_READ].max;
info->has_bps_wr_max = cfg.buckets[THROTTLE_BPS_WRITE].max;
info->bps_wr_max = cfg.buckets[THROTTLE_BPS_WRITE].max;
info->has_iops_max = cfg.buckets[THROTTLE_OPS_TOTAL].max;
info->iops_max = cfg.buckets[THROTTLE_OPS_TOTAL].max;
info->has_iops_rd_max = cfg.buckets[THROTTLE_OPS_READ].max;
info->iops_rd_max = cfg.buckets[THROTTLE_OPS_READ].max;
info->has_iops_wr_max = cfg.buckets[THROTTLE_OPS_WRITE].max;
info->iops_wr_max = cfg.buckets[THROTTLE_OPS_WRITE].max;
info->has_iops_size = cfg.op_size;
info->iops_size = cfg.op_size;
}
info->write_threshold = bdrv_write_threshold_get(bs);
return info;
}
| {
"code": [
"BlockDeviceInfo *bdrv_block_device_info(BlockDriverState *bs)"
],
"line_no": [
1
]
} | BlockDeviceInfo *FUNC_0(BlockDriverState *bs)
{
BlockDeviceInfo *info = g_malloc0(sizeof(*info));
info->file = g_strdup(bs->filename);
info->ro = bs->read_only;
info->drv = g_strdup(bs->drv->format_name);
info->encrypted = bs->encrypted;
info->encryption_key_missing = bdrv_key_required(bs);
info->cache = g_new(BlockdevCacheInfo, 1);
*info->cache = (BlockdevCacheInfo) {
.writeback = bdrv_enable_write_cache(bs),
.direct = !!(bs->open_flags & BDRV_O_NOCACHE),
.no_flush = !!(bs->open_flags & BDRV_O_NO_FLUSH),
};
if (bs->node_name[0]) {
info->has_node_name = true;
info->node_name = g_strdup(bs->node_name);
}
if (bs->backing_file[0]) {
info->has_backing_file = true;
info->backing_file = g_strdup(bs->backing_file);
}
info->backing_file_depth = bdrv_get_backing_file_depth(bs);
info->detect_zeroes = bs->detect_zeroes;
if (bs->io_limits_enabled) {
ThrottleConfig cfg;
throttle_get_config(&bs->throttle_state, &cfg);
info->bps = cfg.buckets[THROTTLE_BPS_TOTAL].avg;
info->bps_rd = cfg.buckets[THROTTLE_BPS_READ].avg;
info->bps_wr = cfg.buckets[THROTTLE_BPS_WRITE].avg;
info->iops = cfg.buckets[THROTTLE_OPS_TOTAL].avg;
info->iops_rd = cfg.buckets[THROTTLE_OPS_READ].avg;
info->iops_wr = cfg.buckets[THROTTLE_OPS_WRITE].avg;
info->has_bps_max = cfg.buckets[THROTTLE_BPS_TOTAL].max;
info->bps_max = cfg.buckets[THROTTLE_BPS_TOTAL].max;
info->has_bps_rd_max = cfg.buckets[THROTTLE_BPS_READ].max;
info->bps_rd_max = cfg.buckets[THROTTLE_BPS_READ].max;
info->has_bps_wr_max = cfg.buckets[THROTTLE_BPS_WRITE].max;
info->bps_wr_max = cfg.buckets[THROTTLE_BPS_WRITE].max;
info->has_iops_max = cfg.buckets[THROTTLE_OPS_TOTAL].max;
info->iops_max = cfg.buckets[THROTTLE_OPS_TOTAL].max;
info->has_iops_rd_max = cfg.buckets[THROTTLE_OPS_READ].max;
info->iops_rd_max = cfg.buckets[THROTTLE_OPS_READ].max;
info->has_iops_wr_max = cfg.buckets[THROTTLE_OPS_WRITE].max;
info->iops_wr_max = cfg.buckets[THROTTLE_OPS_WRITE].max;
info->has_iops_size = cfg.op_size;
info->iops_size = cfg.op_size;
}
info->write_threshold = bdrv_write_threshold_get(bs);
return info;
}
| [
"BlockDeviceInfo *FUNC_0(BlockDriverState *bs)\n{",
"BlockDeviceInfo *info = g_malloc0(sizeof(*info));",
"info->file = g_strdup(bs->filename);",
"info->ro = bs->read_only;",
"info->drv = g_strdup(bs->drv->format_name);",
"info->encrypted = bs->encrypted;",
"info->encryption_key_missing = bdrv_key_required(bs);",
"info->cache = g_new(BlockdevCacheInfo, 1);",
"*info->cache = (BlockdevCacheInfo) {",
".writeback = bdrv_enable_write_cache(bs),\n.direct = !!(bs->open_flags & BDRV_O_NOCACHE),\n.no_flush = !!(bs->open_flags & BDRV_O_NO_FLUSH),\n};",
"if (bs->node_name[0]) {",
"info->has_node_name = true;",
"info->node_name = g_strdup(bs->node_name);",
"}",
"if (bs->backing_file[0]) {",
"info->has_backing_file = true;",
"info->backing_file = g_strdup(bs->backing_file);",
"}",
"info->backing_file_depth = bdrv_get_backing_file_depth(bs);",
"info->detect_zeroes = bs->detect_zeroes;",
"if (bs->io_limits_enabled) {",
"ThrottleConfig cfg;",
"throttle_get_config(&bs->throttle_state, &cfg);",
"info->bps = cfg.buckets[THROTTLE_BPS_TOTAL].avg;",
"info->bps_rd = cfg.buckets[THROTTLE_BPS_READ].avg;",
"info->bps_wr = cfg.buckets[THROTTLE_BPS_WRITE].avg;",
"info->iops = cfg.buckets[THROTTLE_OPS_TOTAL].avg;",
"info->iops_rd = cfg.buckets[THROTTLE_OPS_READ].avg;",
"info->iops_wr = cfg.buckets[THROTTLE_OPS_WRITE].avg;",
"info->has_bps_max = cfg.buckets[THROTTLE_BPS_TOTAL].max;",
"info->bps_max = cfg.buckets[THROTTLE_BPS_TOTAL].max;",
"info->has_bps_rd_max = cfg.buckets[THROTTLE_BPS_READ].max;",
"info->bps_rd_max = cfg.buckets[THROTTLE_BPS_READ].max;",
"info->has_bps_wr_max = cfg.buckets[THROTTLE_BPS_WRITE].max;",
"info->bps_wr_max = cfg.buckets[THROTTLE_BPS_WRITE].max;",
"info->has_iops_max = cfg.buckets[THROTTLE_OPS_TOTAL].max;",
"info->iops_max = cfg.buckets[THROTTLE_OPS_TOTAL].max;",
"info->has_iops_rd_max = cfg.buckets[THROTTLE_OPS_READ].max;",
"info->iops_rd_max = cfg.buckets[THROTTLE_OPS_READ].max;",
"info->has_iops_wr_max = cfg.buckets[THROTTLE_OPS_WRITE].max;",
"info->iops_wr_max = cfg.buckets[THROTTLE_OPS_WRITE].max;",
"info->has_iops_size = cfg.op_size;",
"info->iops_size = cfg.op_size;",
"}",
"info->write_threshold = bdrv_write_threshold_get(bs);",
"return info;",
"}"
]
| [
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
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25,
27,
29,
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
115
],
[
119
],
[
123
],
[
125
]
]
|
13,676 | void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)
{
GtkDisplayState *s = g_malloc0(sizeof(*s));
char *filename;
gtk_init(NULL, NULL);
s->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
#if GTK_CHECK_VERSION(3, 2, 0)
s->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
#else
s->vbox = gtk_vbox_new(FALSE, 0);
#endif
s->notebook = gtk_notebook_new();
s->menu_bar = gtk_menu_bar_new();
s->free_scale = FALSE;
setlocale(LC_ALL, "");
bindtextdomain("qemu", CONFIG_QEMU_LOCALEDIR);
textdomain("qemu");
s->null_cursor = gdk_cursor_new(GDK_BLANK_CURSOR);
s->mouse_mode_notifier.notify = gd_mouse_mode_change;
qemu_add_mouse_mode_change_notifier(&s->mouse_mode_notifier);
qemu_add_vm_change_state_handler(gd_change_runstate, s);
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "qemu_logo_no_text.svg");
if (filename) {
GError *error = NULL;
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename, &error);
if (pixbuf) {
gtk_window_set_icon(GTK_WINDOW(s->window), pixbuf);
} else {
g_error_free(error);
}
g_free(filename);
}
gd_create_menus(s);
gd_connect_signals(s);
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(s->notebook), FALSE);
gtk_notebook_set_show_border(GTK_NOTEBOOK(s->notebook), FALSE);
gd_update_caption(s);
gtk_box_pack_start(GTK_BOX(s->vbox), s->menu_bar, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(s->vbox), s->notebook, TRUE, TRUE, 0);
gtk_container_add(GTK_CONTAINER(s->window), s->vbox);
gtk_widget_show_all(s->window);
#ifdef VTE_RESIZE_HACK
{
VirtualConsole *cur = gd_vc_find_current(s);
int i;
for (i = 0; i < s->nb_vcs; i++) {
VirtualConsole *vc = &s->vc[i];
if (vc && vc->type == GD_VC_VTE && vc != cur) {
gtk_widget_hide(vc->vte.terminal);
}
}
gd_update_windowsize(cur);
}
#endif
if (full_screen) {
gtk_menu_item_activate(GTK_MENU_ITEM(s->full_screen_item));
}
if (grab_on_hover) {
gtk_menu_item_activate(GTK_MENU_ITEM(s->grab_on_hover_item));
}
gd_set_keycode_type(s);
}
| true | qemu | b310a2a6095ec927a42cc1aba520a316be0faf51 | void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)
{
GtkDisplayState *s = g_malloc0(sizeof(*s));
char *filename;
gtk_init(NULL, NULL);
s->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
#if GTK_CHECK_VERSION(3, 2, 0)
s->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
#else
s->vbox = gtk_vbox_new(FALSE, 0);
#endif
s->notebook = gtk_notebook_new();
s->menu_bar = gtk_menu_bar_new();
s->free_scale = FALSE;
setlocale(LC_ALL, "");
bindtextdomain("qemu", CONFIG_QEMU_LOCALEDIR);
textdomain("qemu");
s->null_cursor = gdk_cursor_new(GDK_BLANK_CURSOR);
s->mouse_mode_notifier.notify = gd_mouse_mode_change;
qemu_add_mouse_mode_change_notifier(&s->mouse_mode_notifier);
qemu_add_vm_change_state_handler(gd_change_runstate, s);
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "qemu_logo_no_text.svg");
if (filename) {
GError *error = NULL;
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename, &error);
if (pixbuf) {
gtk_window_set_icon(GTK_WINDOW(s->window), pixbuf);
} else {
g_error_free(error);
}
g_free(filename);
}
gd_create_menus(s);
gd_connect_signals(s);
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(s->notebook), FALSE);
gtk_notebook_set_show_border(GTK_NOTEBOOK(s->notebook), FALSE);
gd_update_caption(s);
gtk_box_pack_start(GTK_BOX(s->vbox), s->menu_bar, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(s->vbox), s->notebook, TRUE, TRUE, 0);
gtk_container_add(GTK_CONTAINER(s->window), s->vbox);
gtk_widget_show_all(s->window);
#ifdef VTE_RESIZE_HACK
{
VirtualConsole *cur = gd_vc_find_current(s);
int i;
for (i = 0; i < s->nb_vcs; i++) {
VirtualConsole *vc = &s->vc[i];
if (vc && vc->type == GD_VC_VTE && vc != cur) {
gtk_widget_hide(vc->vte.terminal);
}
}
gd_update_windowsize(cur);
}
#endif
if (full_screen) {
gtk_menu_item_activate(GTK_MENU_ITEM(s->full_screen_item));
}
if (grab_on_hover) {
gtk_menu_item_activate(GTK_MENU_ITEM(s->grab_on_hover_item));
}
gd_set_keycode_type(s);
}
| {
"code": [
" int i;",
" for (i = 0; i < s->nb_vcs; i++) {",
" VirtualConsole *vc = &s->vc[i];",
" if (vc && vc->type == GD_VC_VTE && vc != cur) {",
" gtk_widget_hide(vc->vte.terminal);",
" gd_update_windowsize(cur);"
],
"line_no": [
119,
123,
125,
127,
129,
135
]
} | void FUNC_0(DisplayState *VAR_0, bool VAR_1, bool VAR_2)
{
GtkDisplayState *s = g_malloc0(sizeof(*s));
char *VAR_3;
gtk_init(NULL, NULL);
s->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
#if GTK_CHECK_VERSION(3, 2, 0)
s->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
#else
s->vbox = gtk_vbox_new(FALSE, 0);
#endif
s->notebook = gtk_notebook_new();
s->menu_bar = gtk_menu_bar_new();
s->free_scale = FALSE;
setlocale(LC_ALL, "");
bindtextdomain("qemu", CONFIG_QEMU_LOCALEDIR);
textdomain("qemu");
s->null_cursor = gdk_cursor_new(GDK_BLANK_CURSOR);
s->mouse_mode_notifier.notify = gd_mouse_mode_change;
qemu_add_mouse_mode_change_notifier(&s->mouse_mode_notifier);
qemu_add_vm_change_state_handler(gd_change_runstate, s);
VAR_3 = qemu_find_file(QEMU_FILE_TYPE_BIOS, "qemu_logo_no_text.svg");
if (VAR_3) {
GError *error = NULL;
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(VAR_3, &error);
if (pixbuf) {
gtk_window_set_icon(GTK_WINDOW(s->window), pixbuf);
} else {
g_error_free(error);
}
g_free(VAR_3);
}
gd_create_menus(s);
gd_connect_signals(s);
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(s->notebook), FALSE);
gtk_notebook_set_show_border(GTK_NOTEBOOK(s->notebook), FALSE);
gd_update_caption(s);
gtk_box_pack_start(GTK_BOX(s->vbox), s->menu_bar, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(s->vbox), s->notebook, TRUE, TRUE, 0);
gtk_container_add(GTK_CONTAINER(s->window), s->vbox);
gtk_widget_show_all(s->window);
#ifdef VTE_RESIZE_HACK
{
VirtualConsole *cur = gd_vc_find_current(s);
int i;
for (i = 0; i < s->nb_vcs; i++) {
VirtualConsole *vc = &s->vc[i];
if (vc && vc->type == GD_VC_VTE && vc != cur) {
gtk_widget_hide(vc->vte.terminal);
}
}
gd_update_windowsize(cur);
}
#endif
if (VAR_1) {
gtk_menu_item_activate(GTK_MENU_ITEM(s->full_screen_item));
}
if (VAR_2) {
gtk_menu_item_activate(GTK_MENU_ITEM(s->grab_on_hover_item));
}
gd_set_keycode_type(s);
}
| [
"void FUNC_0(DisplayState *VAR_0, bool VAR_1, bool VAR_2)\n{",
"GtkDisplayState *s = g_malloc0(sizeof(*s));",
"char *VAR_3;",
"gtk_init(NULL, NULL);",
"s->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);",
"#if GTK_CHECK_VERSION(3, 2, 0)\ns->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);",
"#else\ns->vbox = gtk_vbox_new(FALSE, 0);",
"#endif\ns->notebook = gtk_notebook_new();",
"s->menu_bar = gtk_menu_bar_new();",
"s->free_scale = FALSE;",
"setlocale(LC_ALL, \"\");",
"bindtextdomain(\"qemu\", CONFIG_QEMU_LOCALEDIR);",
"textdomain(\"qemu\");",
"s->null_cursor = gdk_cursor_new(GDK_BLANK_CURSOR);",
"s->mouse_mode_notifier.notify = gd_mouse_mode_change;",
"qemu_add_mouse_mode_change_notifier(&s->mouse_mode_notifier);",
"qemu_add_vm_change_state_handler(gd_change_runstate, s);",
"VAR_3 = qemu_find_file(QEMU_FILE_TYPE_BIOS, \"qemu_logo_no_text.svg\");",
"if (VAR_3) {",
"GError *error = NULL;",
"GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(VAR_3, &error);",
"if (pixbuf) {",
"gtk_window_set_icon(GTK_WINDOW(s->window), pixbuf);",
"} else {",
"g_error_free(error);",
"}",
"g_free(VAR_3);",
"}",
"gd_create_menus(s);",
"gd_connect_signals(s);",
"gtk_notebook_set_show_tabs(GTK_NOTEBOOK(s->notebook), FALSE);",
"gtk_notebook_set_show_border(GTK_NOTEBOOK(s->notebook), FALSE);",
"gd_update_caption(s);",
"gtk_box_pack_start(GTK_BOX(s->vbox), s->menu_bar, FALSE, TRUE, 0);",
"gtk_box_pack_start(GTK_BOX(s->vbox), s->notebook, TRUE, TRUE, 0);",
"gtk_container_add(GTK_CONTAINER(s->window), s->vbox);",
"gtk_widget_show_all(s->window);",
"#ifdef VTE_RESIZE_HACK\n{",
"VirtualConsole *cur = gd_vc_find_current(s);",
"int i;",
"for (i = 0; i < s->nb_vcs; i++) {",
"VirtualConsole *vc = &s->vc[i];",
"if (vc && vc->type == GD_VC_VTE && vc != cur) {",
"gtk_widget_hide(vc->vte.terminal);",
"}",
"}",
"gd_update_windowsize(cur);",
"}",
"#endif\nif (VAR_1) {",
"gtk_menu_item_activate(GTK_MENU_ITEM(s->full_screen_item));",
"}",
"if (VAR_2) {",
"gtk_menu_item_activate(GTK_MENU_ITEM(s->grab_on_hover_item));",
"}",
"gd_set_keycode_type(s);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17,
19
],
[
21,
23
],
[
25,
27
],
[
29
],
[
33
],
[
37
],
[
39
],
[
41
],
[
45
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
85
],
[
89
],
[
91
],
[
95
],
[
99
],
[
101
],
[
105
],
[
109
],
[
113,
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139,
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
157
],
[
159
]
]
|
13,677 | static int analyze(const uint8_t *buf, int size, int packet_size,
int probe)
{
int stat[TS_MAX_PACKET_SIZE];
int stat_all = 0;
int i;
int best_score = 0;
memset(stat, 0, packet_size * sizeof(*stat));
for (i = 0; i < size - 3; i++) {
if (buf[i] == 0x47 &&
(!probe || (buf[i + 3] & 0x30))) {
int x = i % packet_size;
stat[x]++;
stat_all++;
if (stat[x] > best_score) {
best_score = stat[x];
}
}
}
return best_score - FFMAX(stat_all - 10*best_score, 0)/10;
}
| false | FFmpeg | e01b19deceaafa2b7a9d59717484d8831b00cd71 | static int analyze(const uint8_t *buf, int size, int packet_size,
int probe)
{
int stat[TS_MAX_PACKET_SIZE];
int stat_all = 0;
int i;
int best_score = 0;
memset(stat, 0, packet_size * sizeof(*stat));
for (i = 0; i < size - 3; i++) {
if (buf[i] == 0x47 &&
(!probe || (buf[i + 3] & 0x30))) {
int x = i % packet_size;
stat[x]++;
stat_all++;
if (stat[x] > best_score) {
best_score = stat[x];
}
}
}
return best_score - FFMAX(stat_all - 10*best_score, 0)/10;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(const uint8_t *VAR_0, int VAR_1, int VAR_2,
int VAR_3)
{
int VAR_4[TS_MAX_PACKET_SIZE];
int VAR_5 = 0;
int VAR_6;
int VAR_7 = 0;
memset(VAR_4, 0, VAR_2 * sizeof(*VAR_4));
for (VAR_6 = 0; VAR_6 < VAR_1 - 3; VAR_6++) {
if (VAR_0[VAR_6] == 0x47 &&
(!VAR_3 || (VAR_0[VAR_6 + 3] & 0x30))) {
int VAR_8 = VAR_6 % VAR_2;
VAR_4[VAR_8]++;
VAR_5++;
if (VAR_4[VAR_8] > VAR_7) {
VAR_7 = VAR_4[VAR_8];
}
}
}
return VAR_7 - FFMAX(VAR_5 - 10*VAR_7, 0)/10;
}
| [
"static int FUNC_0(const uint8_t *VAR_0, int VAR_1, int VAR_2,\nint VAR_3)\n{",
"int VAR_4[TS_MAX_PACKET_SIZE];",
"int VAR_5 = 0;",
"int VAR_6;",
"int VAR_7 = 0;",
"memset(VAR_4, 0, VAR_2 * sizeof(*VAR_4));",
"for (VAR_6 = 0; VAR_6 < VAR_1 - 3; VAR_6++) {",
"if (VAR_0[VAR_6] == 0x47 &&\n(!VAR_3 || (VAR_0[VAR_6 + 3] & 0x30))) {",
"int VAR_8 = VAR_6 % VAR_2;",
"VAR_4[VAR_8]++;",
"VAR_5++;",
"if (VAR_4[VAR_8] > VAR_7) {",
"VAR_7 = VAR_4[VAR_8];",
"}",
"}",
"}",
"return VAR_7 - FFMAX(VAR_5 - 10*VAR_7, 0)/10;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
]
]
|
13,679 | static void get_tree_codes(uint32_t *bits, int16_t *lens, uint8_t *xlat,
Node *nodes, int node,
uint32_t pfx, int pl, int *pos)
{
int s;
s = nodes[node].sym;
if (s != -1) {
bits[*pos] = (~pfx) & ((1U << FFMAX(pl, 1)) - 1);
lens[*pos] = FFMAX(pl, 1);
xlat[*pos] = s + (pl == 0);
(*pos)++;
} else {
pfx <<= 1;
pl++;
get_tree_codes(bits, lens, xlat, nodes, nodes[node].l, pfx, pl,
pos);
pfx |= 1;
get_tree_codes(bits, lens, xlat, nodes, nodes[node].r, pfx, pl,
pos);
}
}
| true | FFmpeg | 03a9e6ff303ad82e75b734edbe4917ca5fd60159 | static void get_tree_codes(uint32_t *bits, int16_t *lens, uint8_t *xlat,
Node *nodes, int node,
uint32_t pfx, int pl, int *pos)
{
int s;
s = nodes[node].sym;
if (s != -1) {
bits[*pos] = (~pfx) & ((1U << FFMAX(pl, 1)) - 1);
lens[*pos] = FFMAX(pl, 1);
xlat[*pos] = s + (pl == 0);
(*pos)++;
} else {
pfx <<= 1;
pl++;
get_tree_codes(bits, lens, xlat, nodes, nodes[node].l, pfx, pl,
pos);
pfx |= 1;
get_tree_codes(bits, lens, xlat, nodes, nodes[node].r, pfx, pl,
pos);
}
}
| {
"code": [
" bits[*pos] = (~pfx) & ((1U << FFMAX(pl, 1)) - 1);"
],
"line_no": [
17
]
} | static void FUNC_0(uint32_t *VAR_0, int16_t *VAR_1, uint8_t *VAR_2,
Node *VAR_3, int VAR_4,
uint32_t VAR_5, int VAR_6, int *VAR_7)
{
int VAR_8;
VAR_8 = VAR_3[VAR_4].sym;
if (VAR_8 != -1) {
VAR_0[*VAR_7] = (~VAR_5) & ((1U << FFMAX(VAR_6, 1)) - 1);
VAR_1[*VAR_7] = FFMAX(VAR_6, 1);
VAR_2[*VAR_7] = VAR_8 + (VAR_6 == 0);
(*VAR_7)++;
} else {
VAR_5 <<= 1;
VAR_6++;
FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3, VAR_3[VAR_4].l, VAR_5, VAR_6,
VAR_7);
VAR_5 |= 1;
FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3, VAR_3[VAR_4].r, VAR_5, VAR_6,
VAR_7);
}
}
| [
"static void FUNC_0(uint32_t *VAR_0, int16_t *VAR_1, uint8_t *VAR_2,\nNode *VAR_3, int VAR_4,\nuint32_t VAR_5, int VAR_6, int *VAR_7)\n{",
"int VAR_8;",
"VAR_8 = VAR_3[VAR_4].sym;",
"if (VAR_8 != -1) {",
"VAR_0[*VAR_7] = (~VAR_5) & ((1U << FFMAX(VAR_6, 1)) - 1);",
"VAR_1[*VAR_7] = FFMAX(VAR_6, 1);",
"VAR_2[*VAR_7] = VAR_8 + (VAR_6 == 0);",
"(*VAR_7)++;",
"} else {",
"VAR_5 <<= 1;",
"VAR_6++;",
"FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3, VAR_3[VAR_4].l, VAR_5, VAR_6,\nVAR_7);",
"VAR_5 |= 1;",
"FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3, VAR_3[VAR_4].r, VAR_5, VAR_6,\nVAR_7);",
"}",
"}"
]
| [
0,
0,
0,
0,
1,
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
]
]
|
13,680 | static int nprobe(AVFormatContext *s, uint8_t *enc_header, unsigned size,
const uint8_t *n_val)
{
OMAContext *oc = s->priv_data;
uint64_t pos;
uint32_t taglen, datalen;
struct AVDES av_des;
if (!enc_header || !n_val ||
size < OMA_ENC_HEADER_SIZE + oc->k_size + 4)
return -1;
pos = OMA_ENC_HEADER_SIZE + oc->k_size;
if (!memcmp(&enc_header[pos], "EKB ", 4))
pos += 32;
if (size < pos + 44)
return -1;
if (AV_RB32(&enc_header[pos]) != oc->rid)
av_log(s, AV_LOG_DEBUG, "Mismatching RID\n");
taglen = AV_RB32(&enc_header[pos + 32]);
datalen = AV_RB32(&enc_header[pos + 36]) >> 4;
pos += 44;
if (size - pos < taglen)
return -1;
pos += taglen;
if (pos + (((uint64_t)datalen) << 4) > size)
return -1;
av_des_init(&av_des, n_val, 192, 1);
while (datalen-- > 0) {
av_des_crypt(&av_des, oc->r_val, &enc_header[pos], 2, NULL, 1);
kset(s, oc->r_val, NULL, 16);
if (!rprobe(s, enc_header, size, oc->r_val))
return 0;
pos += 16;
}
return -1;
}
| false | FFmpeg | fb45de779c8db142b44bf7b00c535ea2eee4f148 | static int nprobe(AVFormatContext *s, uint8_t *enc_header, unsigned size,
const uint8_t *n_val)
{
OMAContext *oc = s->priv_data;
uint64_t pos;
uint32_t taglen, datalen;
struct AVDES av_des;
if (!enc_header || !n_val ||
size < OMA_ENC_HEADER_SIZE + oc->k_size + 4)
return -1;
pos = OMA_ENC_HEADER_SIZE + oc->k_size;
if (!memcmp(&enc_header[pos], "EKB ", 4))
pos += 32;
if (size < pos + 44)
return -1;
if (AV_RB32(&enc_header[pos]) != oc->rid)
av_log(s, AV_LOG_DEBUG, "Mismatching RID\n");
taglen = AV_RB32(&enc_header[pos + 32]);
datalen = AV_RB32(&enc_header[pos + 36]) >> 4;
pos += 44;
if (size - pos < taglen)
return -1;
pos += taglen;
if (pos + (((uint64_t)datalen) << 4) > size)
return -1;
av_des_init(&av_des, n_val, 192, 1);
while (datalen-- > 0) {
av_des_crypt(&av_des, oc->r_val, &enc_header[pos], 2, NULL, 1);
kset(s, oc->r_val, NULL, 16);
if (!rprobe(s, enc_header, size, oc->r_val))
return 0;
pos += 16;
}
return -1;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, uint8_t *VAR_1, unsigned VAR_2,
const uint8_t *VAR_3)
{
OMAContext *oc = VAR_0->priv_data;
uint64_t pos;
uint32_t taglen, datalen;
struct AVDES VAR_4;
if (!VAR_1 || !VAR_3 ||
VAR_2 < OMA_ENC_HEADER_SIZE + oc->k_size + 4)
return -1;
pos = OMA_ENC_HEADER_SIZE + oc->k_size;
if (!memcmp(&VAR_1[pos], "EKB ", 4))
pos += 32;
if (VAR_2 < pos + 44)
return -1;
if (AV_RB32(&VAR_1[pos]) != oc->rid)
av_log(VAR_0, AV_LOG_DEBUG, "Mismatching RID\n");
taglen = AV_RB32(&VAR_1[pos + 32]);
datalen = AV_RB32(&VAR_1[pos + 36]) >> 4;
pos += 44;
if (VAR_2 - pos < taglen)
return -1;
pos += taglen;
if (pos + (((uint64_t)datalen) << 4) > VAR_2)
return -1;
av_des_init(&VAR_4, VAR_3, 192, 1);
while (datalen-- > 0) {
av_des_crypt(&VAR_4, oc->r_val, &VAR_1[pos], 2, NULL, 1);
kset(VAR_0, oc->r_val, NULL, 16);
if (!rprobe(VAR_0, VAR_1, VAR_2, oc->r_val))
return 0;
pos += 16;
}
return -1;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, uint8_t *VAR_1, unsigned VAR_2,\nconst uint8_t *VAR_3)\n{",
"OMAContext *oc = VAR_0->priv_data;",
"uint64_t pos;",
"uint32_t taglen, datalen;",
"struct AVDES VAR_4;",
"if (!VAR_1 || !VAR_3 ||\nVAR_2 < OMA_ENC_HEADER_SIZE + oc->k_size + 4)\nreturn -1;",
"pos = OMA_ENC_HEADER_SIZE + oc->k_size;",
"if (!memcmp(&VAR_1[pos], \"EKB \", 4))\npos += 32;",
"if (VAR_2 < pos + 44)\nreturn -1;",
"if (AV_RB32(&VAR_1[pos]) != oc->rid)\nav_log(VAR_0, AV_LOG_DEBUG, \"Mismatching RID\\n\");",
"taglen = AV_RB32(&VAR_1[pos + 32]);",
"datalen = AV_RB32(&VAR_1[pos + 36]) >> 4;",
"pos += 44;",
"if (VAR_2 - pos < taglen)\nreturn -1;",
"pos += taglen;",
"if (pos + (((uint64_t)datalen) << 4) > VAR_2)\nreturn -1;",
"av_des_init(&VAR_4, VAR_3, 192, 1);",
"while (datalen-- > 0) {",
"av_des_crypt(&VAR_4, oc->r_val, &VAR_1[pos], 2, NULL, 1);",
"kset(VAR_0, oc->r_val, NULL, 16);",
"if (!rprobe(VAR_0, VAR_1, VAR_2, oc->r_val))\nreturn 0;",
"pos += 16;",
"}",
"return -1;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17,
19,
21
],
[
25
],
[
27,
29
],
[
33,
35
],
[
39,
41
],
[
45
],
[
47
],
[
51
],
[
53,
55
],
[
59
],
[
63,
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
87
],
[
89
]
]
|
13,681 | static void fill_block(uint16_t *pdest, uint16_t color, int block_size, int pitch)
{
int x, y;
pitch -= block_size;
for (y = 0; y != block_size; y++, pdest += pitch)
for (x = 0; x != block_size; x++)
*pdest++ = color;
}
| false | FFmpeg | 3b9dd906d18f4cd801ceedd20d800a7e53074be9 | static void fill_block(uint16_t *pdest, uint16_t color, int block_size, int pitch)
{
int x, y;
pitch -= block_size;
for (y = 0; y != block_size; y++, pdest += pitch)
for (x = 0; x != block_size; x++)
*pdest++ = color;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(uint16_t *VAR_0, uint16_t VAR_1, int VAR_2, int VAR_3)
{
int VAR_4, VAR_5;
VAR_3 -= VAR_2;
for (VAR_5 = 0; VAR_5 != VAR_2; VAR_5++, VAR_0 += VAR_3)
for (VAR_4 = 0; VAR_4 != VAR_2; VAR_4++)
*VAR_0++ = VAR_1;
}
| [
"static void FUNC_0(uint16_t *VAR_0, uint16_t VAR_1, int VAR_2, int VAR_3)\n{",
"int VAR_4, VAR_5;",
"VAR_3 -= VAR_2;",
"for (VAR_5 = 0; VAR_5 != VAR_2; VAR_5++, VAR_0 += VAR_3)",
"for (VAR_4 = 0; VAR_4 != VAR_2; VAR_4++)",
"*VAR_0++ = VAR_1;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
]
|
13,682 | static void ini_print_section_header(WriterContext *wctx)
{
INIContext *ini = wctx->priv;
AVBPrint buf;
int i;
const struct section *section = wctx->section[wctx->level];
const struct section *parent_section = wctx->level ?
wctx->section[wctx->level-1] : NULL;
av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
if (wctx->level == 0) {
printf("# ffprobe output\n\n");
return;
}
if (wctx->nb_item[wctx->level-1])
printf("\n");
for (i = 1; i <= wctx->level; i++) {
if (ini->hierarchical ||
!(section->flags & (SECTION_FLAG_IS_ARRAY|SECTION_FLAG_IS_WRAPPER)))
av_bprintf(&buf, "%s%s", i>1 ? "." : "", wctx->section[i]->name);
}
if (parent_section->flags & SECTION_FLAG_IS_ARRAY) {
int n = parent_section->id == SECTION_ID_PACKETS_AND_FRAMES ?
wctx->nb_section_packet_frame : wctx->nb_item[wctx->level-1];
av_bprintf(&buf, ".%d", n);
}
if (!(section->flags & (SECTION_FLAG_IS_ARRAY|SECTION_FLAG_IS_WRAPPER)))
printf("[%s]\n", buf.str);
av_bprint_finalize(&buf, NULL);
}
| false | FFmpeg | 74bd0cf49c9c0bee8d4f3d3a98a7343c2ff5b94c | static void ini_print_section_header(WriterContext *wctx)
{
INIContext *ini = wctx->priv;
AVBPrint buf;
int i;
const struct section *section = wctx->section[wctx->level];
const struct section *parent_section = wctx->level ?
wctx->section[wctx->level-1] : NULL;
av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
if (wctx->level == 0) {
printf("# ffprobe output\n\n");
return;
}
if (wctx->nb_item[wctx->level-1])
printf("\n");
for (i = 1; i <= wctx->level; i++) {
if (ini->hierarchical ||
!(section->flags & (SECTION_FLAG_IS_ARRAY|SECTION_FLAG_IS_WRAPPER)))
av_bprintf(&buf, "%s%s", i>1 ? "." : "", wctx->section[i]->name);
}
if (parent_section->flags & SECTION_FLAG_IS_ARRAY) {
int n = parent_section->id == SECTION_ID_PACKETS_AND_FRAMES ?
wctx->nb_section_packet_frame : wctx->nb_item[wctx->level-1];
av_bprintf(&buf, ".%d", n);
}
if (!(section->flags & (SECTION_FLAG_IS_ARRAY|SECTION_FLAG_IS_WRAPPER)))
printf("[%s]\n", buf.str);
av_bprint_finalize(&buf, NULL);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(WriterContext *VAR_0)
{
INIContext *ini = VAR_0->priv;
AVBPrint buf;
int VAR_1;
const struct VAR_2 *VAR_2 = VAR_0->VAR_2[VAR_0->level];
const struct VAR_2 *VAR_3 = VAR_0->level ?
VAR_0->VAR_2[VAR_0->level-1] : NULL;
av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
if (VAR_0->level == 0) {
printf("# ffprobe output\VAR_4\VAR_4");
return;
}
if (VAR_0->nb_item[VAR_0->level-1])
printf("\VAR_4");
for (VAR_1 = 1; VAR_1 <= VAR_0->level; VAR_1++) {
if (ini->hierarchical ||
!(VAR_2->flags & (SECTION_FLAG_IS_ARRAY|SECTION_FLAG_IS_WRAPPER)))
av_bprintf(&buf, "%s%s", VAR_1>1 ? "." : "", VAR_0->VAR_2[VAR_1]->name);
}
if (VAR_3->flags & SECTION_FLAG_IS_ARRAY) {
int VAR_4 = VAR_3->id == SECTION_ID_PACKETS_AND_FRAMES ?
VAR_0->nb_section_packet_frame : VAR_0->nb_item[VAR_0->level-1];
av_bprintf(&buf, ".%d", VAR_4);
}
if (!(VAR_2->flags & (SECTION_FLAG_IS_ARRAY|SECTION_FLAG_IS_WRAPPER)))
printf("[%s]\VAR_4", buf.str);
av_bprint_finalize(&buf, NULL);
}
| [
"static void FUNC_0(WriterContext *VAR_0)\n{",
"INIContext *ini = VAR_0->priv;",
"AVBPrint buf;",
"int VAR_1;",
"const struct VAR_2 *VAR_2 = VAR_0->VAR_2[VAR_0->level];",
"const struct VAR_2 *VAR_3 = VAR_0->level ?\nVAR_0->VAR_2[VAR_0->level-1] : NULL;",
"av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);",
"if (VAR_0->level == 0) {",
"printf(\"# ffprobe output\\VAR_4\\VAR_4\");",
"return;",
"}",
"if (VAR_0->nb_item[VAR_0->level-1])\nprintf(\"\\VAR_4\");",
"for (VAR_1 = 1; VAR_1 <= VAR_0->level; VAR_1++) {",
"if (ini->hierarchical ||\n!(VAR_2->flags & (SECTION_FLAG_IS_ARRAY|SECTION_FLAG_IS_WRAPPER)))\nav_bprintf(&buf, \"%s%s\", VAR_1>1 ? \".\" : \"\", VAR_0->VAR_2[VAR_1]->name);",
"}",
"if (VAR_3->flags & SECTION_FLAG_IS_ARRAY) {",
"int VAR_4 = VAR_3->id == SECTION_ID_PACKETS_AND_FRAMES ?\nVAR_0->nb_section_packet_frame : VAR_0->nb_item[VAR_0->level-1];",
"av_bprintf(&buf, \".%d\", VAR_4);",
"}",
"if (!(VAR_2->flags & (SECTION_FLAG_IS_ARRAY|SECTION_FLAG_IS_WRAPPER)))\nprintf(\"[%s]\\VAR_4\", buf.str);",
"av_bprint_finalize(&buf, NULL);",
"}"
]
| [
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
],
[
37
],
[
39,
41,
43
],
[
45
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
61,
63
],
[
65
],
[
67
]
]
|
13,684 | static int vtd_interrupt_remap_msi(IntelIOMMUState *iommu,
MSIMessage *origin,
MSIMessage *translated)
{
int ret = 0;
VTD_IR_MSIAddress addr;
uint16_t index;
VTDIrq irq = {0};
assert(origin && translated);
if (!iommu || !iommu->intr_enabled) {
goto do_not_translate;
}
if (origin->address & VTD_MSI_ADDR_HI_MASK) {
VTD_DPRINTF(GENERAL, "error: MSI addr high 32 bits nonzero"
" during interrupt remapping: 0x%"PRIx32,
(uint32_t)((origin->address & VTD_MSI_ADDR_HI_MASK) >> \
VTD_MSI_ADDR_HI_SHIFT));
return -VTD_FR_IR_REQ_RSVD;
}
addr.data = origin->address & VTD_MSI_ADDR_LO_MASK;
if (le16_to_cpu(addr.__head) != 0xfee) {
VTD_DPRINTF(GENERAL, "error: MSI addr low 32 bits invalid: "
"0x%"PRIx32, addr.data);
return -VTD_FR_IR_REQ_RSVD;
}
/* This is compatible mode. */
if (addr.int_mode != VTD_IR_INT_FORMAT_REMAP) {
goto do_not_translate;
}
index = addr.index_h << 15 | le16_to_cpu(addr.index_l);
#define VTD_IR_MSI_DATA_SUBHANDLE (0x0000ffff)
#define VTD_IR_MSI_DATA_RESERVED (0xffff0000)
if (addr.sub_valid) {
/* See VT-d spec 5.1.2.2 and 5.1.3 on subhandle */
index += origin->data & VTD_IR_MSI_DATA_SUBHANDLE;
}
ret = vtd_remap_irq_get(iommu, index, &irq);
if (ret) {
return ret;
}
if (addr.sub_valid) {
VTD_DPRINTF(IR, "received MSI interrupt");
if (origin->data & VTD_IR_MSI_DATA_RESERVED) {
VTD_DPRINTF(GENERAL, "error: MSI data bits non-zero for "
"interrupt remappable entry: 0x%"PRIx32,
origin->data);
return -VTD_FR_IR_REQ_RSVD;
}
} else {
uint8_t vector = origin->data & 0xff;
VTD_DPRINTF(IR, "received IOAPIC interrupt");
/* IOAPIC entry vector should be aligned with IRTE vector
* (see vt-d spec 5.1.5.1). */
if (vector != irq.vector) {
VTD_DPRINTF(GENERAL, "IOAPIC vector inconsistent: "
"entry: %d, IRTE: %d, index: %d",
vector, irq.vector, index);
}
}
/*
* We'd better keep the last two bits, assuming that guest OS
* might modify it. Keep it does not hurt after all.
*/
irq.msi_addr_last_bits = addr.__not_care;
/* Translate VTDIrq to MSI message */
vtd_generate_msi_message(&irq, translated);
VTD_DPRINTF(IR, "mapping MSI 0x%"PRIx64":0x%"PRIx32 " -> "
"0x%"PRIx64":0x%"PRIx32, origin->address, origin->data,
translated->address, translated->data);
return 0;
do_not_translate:
memcpy(translated, origin, sizeof(*origin));
return 0;
}
| true | qemu | 09cd058a2cf77bb7a3b10ff93c1f80ed88bca364 | static int vtd_interrupt_remap_msi(IntelIOMMUState *iommu,
MSIMessage *origin,
MSIMessage *translated)
{
int ret = 0;
VTD_IR_MSIAddress addr;
uint16_t index;
VTDIrq irq = {0};
assert(origin && translated);
if (!iommu || !iommu->intr_enabled) {
goto do_not_translate;
}
if (origin->address & VTD_MSI_ADDR_HI_MASK) {
VTD_DPRINTF(GENERAL, "error: MSI addr high 32 bits nonzero"
" during interrupt remapping: 0x%"PRIx32,
(uint32_t)((origin->address & VTD_MSI_ADDR_HI_MASK) >> \
VTD_MSI_ADDR_HI_SHIFT));
return -VTD_FR_IR_REQ_RSVD;
}
addr.data = origin->address & VTD_MSI_ADDR_LO_MASK;
if (le16_to_cpu(addr.__head) != 0xfee) {
VTD_DPRINTF(GENERAL, "error: MSI addr low 32 bits invalid: "
"0x%"PRIx32, addr.data);
return -VTD_FR_IR_REQ_RSVD;
}
if (addr.int_mode != VTD_IR_INT_FORMAT_REMAP) {
goto do_not_translate;
}
index = addr.index_h << 15 | le16_to_cpu(addr.index_l);
#define VTD_IR_MSI_DATA_SUBHANDLE (0x0000ffff)
#define VTD_IR_MSI_DATA_RESERVED (0xffff0000)
if (addr.sub_valid) {
index += origin->data & VTD_IR_MSI_DATA_SUBHANDLE;
}
ret = vtd_remap_irq_get(iommu, index, &irq);
if (ret) {
return ret;
}
if (addr.sub_valid) {
VTD_DPRINTF(IR, "received MSI interrupt");
if (origin->data & VTD_IR_MSI_DATA_RESERVED) {
VTD_DPRINTF(GENERAL, "error: MSI data bits non-zero for "
"interrupt remappable entry: 0x%"PRIx32,
origin->data);
return -VTD_FR_IR_REQ_RSVD;
}
} else {
uint8_t vector = origin->data & 0xff;
VTD_DPRINTF(IR, "received IOAPIC interrupt");
if (vector != irq.vector) {
VTD_DPRINTF(GENERAL, "IOAPIC vector inconsistent: "
"entry: %d, IRTE: %d, index: %d",
vector, irq.vector, index);
}
}
irq.msi_addr_last_bits = addr.__not_care;
vtd_generate_msi_message(&irq, translated);
VTD_DPRINTF(IR, "mapping MSI 0x%"PRIx64":0x%"PRIx32 " -> "
"0x%"PRIx64":0x%"PRIx32, origin->address, origin->data,
translated->address, translated->data);
return 0;
do_not_translate:
memcpy(translated, origin, sizeof(*origin));
return 0;
}
| {
"code": [
" VTDIrq irq = {0};"
],
"line_no": [
15
]
} | static int FUNC_0(IntelIOMMUState *VAR_0,
MSIMessage *VAR_1,
MSIMessage *VAR_2)
{
int VAR_3 = 0;
VTD_IR_MSIAddress addr;
uint16_t index;
VTDIrq irq = {0};
assert(VAR_1 && VAR_2);
if (!VAR_0 || !VAR_0->intr_enabled) {
goto do_not_translate;
}
if (VAR_1->address & VTD_MSI_ADDR_HI_MASK) {
VTD_DPRINTF(GENERAL, "error: MSI addr high 32 bits nonzero"
" during interrupt remapping: 0x%"PRIx32,
(uint32_t)((VAR_1->address & VTD_MSI_ADDR_HI_MASK) >> \
VTD_MSI_ADDR_HI_SHIFT));
return -VTD_FR_IR_REQ_RSVD;
}
addr.data = VAR_1->address & VTD_MSI_ADDR_LO_MASK;
if (le16_to_cpu(addr.__head) != 0xfee) {
VTD_DPRINTF(GENERAL, "error: MSI addr low 32 bits invalid: "
"0x%"PRIx32, addr.data);
return -VTD_FR_IR_REQ_RSVD;
}
if (addr.int_mode != VTD_IR_INT_FORMAT_REMAP) {
goto do_not_translate;
}
index = addr.index_h << 15 | le16_to_cpu(addr.index_l);
#define VTD_IR_MSI_DATA_SUBHANDLE (0x0000ffff)
#define VTD_IR_MSI_DATA_RESERVED (0xffff0000)
if (addr.sub_valid) {
index += VAR_1->data & VTD_IR_MSI_DATA_SUBHANDLE;
}
VAR_3 = vtd_remap_irq_get(VAR_0, index, &irq);
if (VAR_3) {
return VAR_3;
}
if (addr.sub_valid) {
VTD_DPRINTF(IR, "received MSI interrupt");
if (VAR_1->data & VTD_IR_MSI_DATA_RESERVED) {
VTD_DPRINTF(GENERAL, "error: MSI data bits non-zero for "
"interrupt remappable entry: 0x%"PRIx32,
VAR_1->data);
return -VTD_FR_IR_REQ_RSVD;
}
} else {
uint8_t vector = VAR_1->data & 0xff;
VTD_DPRINTF(IR, "received IOAPIC interrupt");
if (vector != irq.vector) {
VTD_DPRINTF(GENERAL, "IOAPIC vector inconsistent: "
"entry: %d, IRTE: %d, index: %d",
vector, irq.vector, index);
}
}
irq.msi_addr_last_bits = addr.__not_care;
vtd_generate_msi_message(&irq, VAR_2);
VTD_DPRINTF(IR, "mapping MSI 0x%"PRIx64":0x%"PRIx32 " -> "
"0x%"PRIx64":0x%"PRIx32, VAR_1->address, VAR_1->data,
VAR_2->address, VAR_2->data);
return 0;
do_not_translate:
memcpy(VAR_2, VAR_1, sizeof(*VAR_1));
return 0;
}
| [
"static int FUNC_0(IntelIOMMUState *VAR_0,\nMSIMessage *VAR_1,\nMSIMessage *VAR_2)\n{",
"int VAR_3 = 0;",
"VTD_IR_MSIAddress addr;",
"uint16_t index;",
"VTDIrq irq = {0};",
"assert(VAR_1 && VAR_2);",
"if (!VAR_0 || !VAR_0->intr_enabled) {",
"goto do_not_translate;",
"}",
"if (VAR_1->address & VTD_MSI_ADDR_HI_MASK) {",
"VTD_DPRINTF(GENERAL, \"error: MSI addr high 32 bits nonzero\"\n\" during interrupt remapping: 0x%\"PRIx32,\n(uint32_t)((VAR_1->address & VTD_MSI_ADDR_HI_MASK) >> \\\nVTD_MSI_ADDR_HI_SHIFT));",
"return -VTD_FR_IR_REQ_RSVD;",
"}",
"addr.data = VAR_1->address & VTD_MSI_ADDR_LO_MASK;",
"if (le16_to_cpu(addr.__head) != 0xfee) {",
"VTD_DPRINTF(GENERAL, \"error: MSI addr low 32 bits invalid: \"\n\"0x%\"PRIx32, addr.data);",
"return -VTD_FR_IR_REQ_RSVD;",
"}",
"if (addr.int_mode != VTD_IR_INT_FORMAT_REMAP) {",
"goto do_not_translate;",
"}",
"index = addr.index_h << 15 | le16_to_cpu(addr.index_l);",
"#define VTD_IR_MSI_DATA_SUBHANDLE (0x0000ffff)\n#define VTD_IR_MSI_DATA_RESERVED (0xffff0000)\nif (addr.sub_valid) {",
"index += VAR_1->data & VTD_IR_MSI_DATA_SUBHANDLE;",
"}",
"VAR_3 = vtd_remap_irq_get(VAR_0, index, &irq);",
"if (VAR_3) {",
"return VAR_3;",
"}",
"if (addr.sub_valid) {",
"VTD_DPRINTF(IR, \"received MSI interrupt\");",
"if (VAR_1->data & VTD_IR_MSI_DATA_RESERVED) {",
"VTD_DPRINTF(GENERAL, \"error: MSI data bits non-zero for \"\n\"interrupt remappable entry: 0x%\"PRIx32,\nVAR_1->data);",
"return -VTD_FR_IR_REQ_RSVD;",
"}",
"} else {",
"uint8_t vector = VAR_1->data & 0xff;",
"VTD_DPRINTF(IR, \"received IOAPIC interrupt\");",
"if (vector != irq.vector) {",
"VTD_DPRINTF(GENERAL, \"IOAPIC vector inconsistent: \"\n\"entry: %d, IRTE: %d, index: %d\",\nvector, irq.vector, index);",
"}",
"}",
"irq.msi_addr_last_bits = addr.__not_care;",
"vtd_generate_msi_message(&irq, VAR_2);",
"VTD_DPRINTF(IR, \"mapping MSI 0x%\"PRIx64\":0x%\"PRIx32 \" -> \"\n\"0x%\"PRIx64\":0x%\"PRIx32, VAR_1->address, VAR_1->data,\nVAR_2->address, VAR_2->data);",
"return 0;",
"do_not_translate:\nmemcpy(VAR_2, VAR_1, sizeof(*VAR_1));",
"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,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33,
35,
37,
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
63
],
[
65
],
[
67
],
[
71
],
[
75,
77,
81
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107,
109,
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
127
],
[
129,
131,
133
],
[
135
],
[
137
],
[
149
],
[
155
],
[
159,
161,
163
],
[
165
],
[
169,
171
],
[
173
],
[
175
]
]
|
13,685 | static int decode_mb_cabac(H264Context *h) {
MpegEncContext * const s = &h->s;
const int mb_xy= s->mb_x + s->mb_y*s->mb_stride;
int mb_type, partition_count, cbp = 0;
int dct8x8_allowed= h->pps.transform_8x8_mode;
s->dsp.clear_blocks(h->mb); //FIXME avoid if already clear (move after skip handlong?)
tprintf(s->avctx, "pic:%d mb:%d/%d\n", h->frame_num, s->mb_x, s->mb_y);
if( h->slice_type != I_TYPE && h->slice_type != SI_TYPE ) {
int skip;
/* a skipped mb needs the aff flag from the following mb */
if( FRAME_MBAFF && s->mb_x==0 && (s->mb_y&1)==0 )
predict_field_decoding_flag(h);
if( FRAME_MBAFF && (s->mb_y&1)==1 && h->prev_mb_skipped )
skip = h->next_mb_skipped;
else
skip = decode_cabac_mb_skip( h, s->mb_x, s->mb_y );
/* read skip flags */
if( skip ) {
if( FRAME_MBAFF && (s->mb_y&1)==0 ){
s->current_picture.mb_type[mb_xy] = MB_TYPE_SKIP;
h->next_mb_skipped = decode_cabac_mb_skip( h, s->mb_x, s->mb_y+1 );
if(h->next_mb_skipped)
predict_field_decoding_flag(h);
else
h->mb_mbaff = h->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h);
}
decode_mb_skip(h);
h->cbp_table[mb_xy] = 0;
h->chroma_pred_mode_table[mb_xy] = 0;
h->last_qscale_diff = 0;
return 0;
}
}
if(FRAME_MBAFF){
if( (s->mb_y&1) == 0 )
h->mb_mbaff =
h->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h);
}else
h->mb_field_decoding_flag= (s->picture_structure!=PICT_FRAME);
h->prev_mb_skipped = 0;
compute_mb_neighbors(h);
if( ( mb_type = decode_cabac_mb_type( h ) ) < 0 ) {
av_log( h->s.avctx, AV_LOG_ERROR, "decode_cabac_mb_type failed\n" );
return -1;
}
if( h->slice_type == B_TYPE ) {
if( mb_type < 23 ){
partition_count= b_mb_type_info[mb_type].partition_count;
mb_type= b_mb_type_info[mb_type].type;
}else{
mb_type -= 23;
goto decode_intra_mb;
}
} else if( h->slice_type == P_TYPE ) {
if( mb_type < 5) {
partition_count= p_mb_type_info[mb_type].partition_count;
mb_type= p_mb_type_info[mb_type].type;
} else {
mb_type -= 5;
goto decode_intra_mb;
}
} else {
assert(h->slice_type == I_TYPE);
decode_intra_mb:
partition_count = 0;
cbp= i_mb_type_info[mb_type].cbp;
h->intra16x16_pred_mode= i_mb_type_info[mb_type].pred_mode;
mb_type= i_mb_type_info[mb_type].type;
}
if(MB_FIELD)
mb_type |= MB_TYPE_INTERLACED;
h->slice_table[ mb_xy ]= h->slice_num;
if(IS_INTRA_PCM(mb_type)) {
const uint8_t *ptr;
unsigned int x, y;
// We assume these blocks are very rare so we do not optimize it.
// FIXME The two following lines get the bitstream position in the cabac
// decode, I think it should be done by a function in cabac.h (or cabac.c).
ptr= h->cabac.bytestream;
if(h->cabac.low&0x1) ptr--;
if(CABAC_BITS==16){
if(h->cabac.low&0x1FF) ptr--;
}
// The pixels are stored in the same order as levels in h->mb array.
for(y=0; y<16; y++){
const int index= 4*(y&3) + 32*((y>>2)&1) + 128*(y>>3);
for(x=0; x<16; x++){
tprintf(s->avctx, "LUMA ICPM LEVEL (%3d)\n", *ptr);
h->mb[index + (x&3) + 16*((x>>2)&1) + 64*(x>>3)]= *ptr++;
}
}
for(y=0; y<8; y++){
const int index= 256 + 4*(y&3) + 32*(y>>2);
for(x=0; x<8; x++){
tprintf(s->avctx, "CHROMA U ICPM LEVEL (%3d)\n", *ptr);
h->mb[index + (x&3) + 16*(x>>2)]= *ptr++;
}
}
for(y=0; y<8; y++){
const int index= 256 + 64 + 4*(y&3) + 32*(y>>2);
for(x=0; x<8; x++){
tprintf(s->avctx, "CHROMA V ICPM LEVEL (%3d)\n", *ptr);
h->mb[index + (x&3) + 16*(x>>2)]= *ptr++;
}
}
ff_init_cabac_decoder(&h->cabac, ptr, h->cabac.bytestream_end - ptr);
// All blocks are present
h->cbp_table[mb_xy] = 0x1ef;
h->chroma_pred_mode_table[mb_xy] = 0;
// In deblocking, the quantizer is 0
s->current_picture.qscale_table[mb_xy]= 0;
h->chroma_qp = get_chroma_qp(h->pps.chroma_qp_index_offset, 0);
// All coeffs are present
memset(h->non_zero_count[mb_xy], 16, 16);
s->current_picture.mb_type[mb_xy]= mb_type;
return 0;
}
if(MB_MBAFF){
h->ref_count[0] <<= 1;
h->ref_count[1] <<= 1;
}
fill_caches(h, mb_type, 0);
if( IS_INTRA( mb_type ) ) {
int i, pred_mode;
if( IS_INTRA4x4( mb_type ) ) {
if( dct8x8_allowed && decode_cabac_mb_transform_size( h ) ) {
mb_type |= MB_TYPE_8x8DCT;
for( i = 0; i < 16; i+=4 ) {
int pred = pred_intra_mode( h, i );
int mode = decode_cabac_mb_intra4x4_pred_mode( h, pred );
fill_rectangle( &h->intra4x4_pred_mode_cache[ scan8[i] ], 2, 2, 8, mode, 1 );
}
} else {
for( i = 0; i < 16; i++ ) {
int pred = pred_intra_mode( h, i );
h->intra4x4_pred_mode_cache[ scan8[i] ] = decode_cabac_mb_intra4x4_pred_mode( h, pred );
//av_log( s->avctx, AV_LOG_ERROR, "i4x4 pred=%d mode=%d\n", pred, h->intra4x4_pred_mode_cache[ scan8[i] ] );
}
}
write_back_intra_pred_mode(h);
if( check_intra4x4_pred_mode(h) < 0 ) return -1;
} else {
h->intra16x16_pred_mode= check_intra_pred_mode( h, h->intra16x16_pred_mode );
if( h->intra16x16_pred_mode < 0 ) return -1;
}
h->chroma_pred_mode_table[mb_xy] =
pred_mode = decode_cabac_mb_chroma_pre_mode( h );
pred_mode= check_intra_pred_mode( h, pred_mode );
if( pred_mode < 0 ) return -1;
h->chroma_pred_mode= pred_mode;
} else if( partition_count == 4 ) {
int i, j, sub_partition_count[4], list, ref[2][4];
if( h->slice_type == B_TYPE ) {
for( i = 0; i < 4; i++ ) {
h->sub_mb_type[i] = decode_cabac_b_mb_sub_type( h );
sub_partition_count[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
h->sub_mb_type[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].type;
}
if( IS_DIRECT(h->sub_mb_type[0] | h->sub_mb_type[1] |
h->sub_mb_type[2] | h->sub_mb_type[3]) ) {
pred_direct_motion(h, &mb_type);
if( h->ref_count[0] > 1 || h->ref_count[1] > 1 ) {
for( i = 0; i < 4; i++ )
if( IS_DIRECT(h->sub_mb_type[i]) )
fill_rectangle( &h->direct_cache[scan8[4*i]], 2, 2, 8, 1, 1 );
}
}
} else {
for( i = 0; i < 4; i++ ) {
h->sub_mb_type[i] = decode_cabac_p_mb_sub_type( h );
sub_partition_count[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
h->sub_mb_type[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].type;
}
}
for( list = 0; list < h->list_count; list++ ) {
for( i = 0; i < 4; i++ ) {
if(IS_DIRECT(h->sub_mb_type[i])) continue;
if(IS_DIR(h->sub_mb_type[i], 0, list)){
if( h->ref_count[list] > 1 )
ref[list][i] = decode_cabac_mb_ref( h, list, 4*i );
else
ref[list][i] = 0;
} else {
ref[list][i] = -1;
}
h->ref_cache[list][ scan8[4*i]+1 ]=
h->ref_cache[list][ scan8[4*i]+8 ]=h->ref_cache[list][ scan8[4*i]+9 ]= ref[list][i];
}
}
if(dct8x8_allowed)
dct8x8_allowed = get_dct8x8_allowed(h);
for(list=0; list<h->list_count; list++){
for(i=0; i<4; i++){
if(IS_DIRECT(h->sub_mb_type[i])){
fill_rectangle(h->mvd_cache[list][scan8[4*i]], 2, 2, 8, 0, 4);
continue;
}
h->ref_cache[list][ scan8[4*i] ]=h->ref_cache[list][ scan8[4*i]+1 ];
if(IS_DIR(h->sub_mb_type[i], 0, list) && !IS_DIRECT(h->sub_mb_type[i])){
const int sub_mb_type= h->sub_mb_type[i];
const int block_width= (sub_mb_type & (MB_TYPE_16x16|MB_TYPE_16x8)) ? 2 : 1;
for(j=0; j<sub_partition_count[i]; j++){
int mpx, mpy;
int mx, my;
const int index= 4*i + block_width*j;
int16_t (* mv_cache)[2]= &h->mv_cache[list][ scan8[index] ];
int16_t (* mvd_cache)[2]= &h->mvd_cache[list][ scan8[index] ];
pred_motion(h, index, block_width, list, h->ref_cache[list][ scan8[index] ], &mpx, &mpy);
mx = mpx + decode_cabac_mb_mvd( h, list, index, 0 );
my = mpy + decode_cabac_mb_mvd( h, list, index, 1 );
tprintf(s->avctx, "final mv:%d %d\n", mx, my);
if(IS_SUB_8X8(sub_mb_type)){
mv_cache[ 1 ][0]=
mv_cache[ 8 ][0]= mv_cache[ 9 ][0]= mx;
mv_cache[ 1 ][1]=
mv_cache[ 8 ][1]= mv_cache[ 9 ][1]= my;
mvd_cache[ 1 ][0]=
mvd_cache[ 8 ][0]= mvd_cache[ 9 ][0]= mx - mpx;
mvd_cache[ 1 ][1]=
mvd_cache[ 8 ][1]= mvd_cache[ 9 ][1]= my - mpy;
}else if(IS_SUB_8X4(sub_mb_type)){
mv_cache[ 1 ][0]= mx;
mv_cache[ 1 ][1]= my;
mvd_cache[ 1 ][0]= mx - mpx;
mvd_cache[ 1 ][1]= my - mpy;
}else if(IS_SUB_4X8(sub_mb_type)){
mv_cache[ 8 ][0]= mx;
mv_cache[ 8 ][1]= my;
mvd_cache[ 8 ][0]= mx - mpx;
mvd_cache[ 8 ][1]= my - mpy;
}
mv_cache[ 0 ][0]= mx;
mv_cache[ 0 ][1]= my;
mvd_cache[ 0 ][0]= mx - mpx;
mvd_cache[ 0 ][1]= my - mpy;
}
}else{
uint32_t *p= (uint32_t *)&h->mv_cache[list][ scan8[4*i] ][0];
uint32_t *pd= (uint32_t *)&h->mvd_cache[list][ scan8[4*i] ][0];
p[0] = p[1] = p[8] = p[9] = 0;
pd[0]= pd[1]= pd[8]= pd[9]= 0;
}
}
}
} else if( IS_DIRECT(mb_type) ) {
pred_direct_motion(h, &mb_type);
fill_rectangle(h->mvd_cache[0][scan8[0]], 4, 4, 8, 0, 4);
fill_rectangle(h->mvd_cache[1][scan8[0]], 4, 4, 8, 0, 4);
dct8x8_allowed &= h->sps.direct_8x8_inference_flag;
} else {
int list, mx, my, i, mpx, mpy;
if(IS_16X16(mb_type)){
for(list=0; list<h->list_count; list++){
if(IS_DIR(mb_type, 0, list)){
const int ref = h->ref_count[list] > 1 ? decode_cabac_mb_ref( h, list, 0 ) : 0;
fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, ref, 1);
}else
fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, (uint8_t)LIST_NOT_USED, 1); //FIXME factorize and the other fill_rect below too
}
for(list=0; list<h->list_count; list++){
if(IS_DIR(mb_type, 0, list)){
pred_motion(h, 0, 4, list, h->ref_cache[list][ scan8[0] ], &mpx, &mpy);
mx = mpx + decode_cabac_mb_mvd( h, list, 0, 0 );
my = mpy + decode_cabac_mb_mvd( h, list, 0, 1 );
tprintf(s->avctx, "final mv:%d %d\n", mx, my);
fill_rectangle(h->mvd_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx-mpx,my-mpy), 4);
fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx,my), 4);
}else
fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, 0, 4);
}
}
else if(IS_16X8(mb_type)){
for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){
const int ref= h->ref_count[list] > 1 ? decode_cabac_mb_ref( h, list, 8*i ) : 0;
fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, ref, 1);
}else
fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, (LIST_NOT_USED&0xFF), 1);
}
}
for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){
pred_16x8_motion(h, 8*i, list, h->ref_cache[list][scan8[0] + 16*i], &mpx, &mpy);
mx = mpx + decode_cabac_mb_mvd( h, list, 8*i, 0 );
my = mpy + decode_cabac_mb_mvd( h, list, 8*i, 1 );
tprintf(s->avctx, "final mv:%d %d\n", mx, my);
fill_rectangle(h->mvd_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack16to32(mx-mpx,my-mpy), 4);
fill_rectangle(h->mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack16to32(mx,my), 4);
}else{
fill_rectangle(h->mvd_cache[list][ scan8[0] + 16*i ], 4, 2, 8, 0, 4);
fill_rectangle(h-> mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, 0, 4);
}
}
}
}else{
assert(IS_8X16(mb_type));
for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){ //FIXME optimize
const int ref= h->ref_count[list] > 1 ? decode_cabac_mb_ref( h, list, 4*i ) : 0;
fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, ref, 1);
}else
fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, (LIST_NOT_USED&0xFF), 1);
}
}
for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){
pred_8x16_motion(h, i*4, list, h->ref_cache[list][ scan8[0] + 2*i ], &mpx, &mpy);
mx = mpx + decode_cabac_mb_mvd( h, list, 4*i, 0 );
my = mpy + decode_cabac_mb_mvd( h, list, 4*i, 1 );
tprintf(s->avctx, "final mv:%d %d\n", mx, my);
fill_rectangle(h->mvd_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack16to32(mx-mpx,my-mpy), 4);
fill_rectangle(h->mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack16to32(mx,my), 4);
}else{
fill_rectangle(h->mvd_cache[list][ scan8[0] + 2*i ], 2, 4, 8, 0, 4);
fill_rectangle(h-> mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, 0, 4);
}
}
}
}
}
if( IS_INTER( mb_type ) ) {
h->chroma_pred_mode_table[mb_xy] = 0;
write_back_motion( h, mb_type );
}
if( !IS_INTRA16x16( mb_type ) ) {
cbp = decode_cabac_mb_cbp_luma( h );
cbp |= decode_cabac_mb_cbp_chroma( h ) << 4;
}
h->cbp_table[mb_xy] = h->cbp = cbp;
if( dct8x8_allowed && (cbp&15) && !IS_INTRA( mb_type ) ) {
if( decode_cabac_mb_transform_size( h ) )
mb_type |= MB_TYPE_8x8DCT;
}
s->current_picture.mb_type[mb_xy]= mb_type;
if( cbp || IS_INTRA16x16( mb_type ) ) {
const uint8_t *scan, *scan8x8, *dc_scan;
int dqp;
if(IS_INTERLACED(mb_type)){
scan8x8= s->qscale ? h->field_scan8x8 : h->field_scan8x8_q0;
scan= s->qscale ? h->field_scan : h->field_scan_q0;
dc_scan= luma_dc_field_scan;
}else{
scan8x8= s->qscale ? h->zigzag_scan8x8 : h->zigzag_scan8x8_q0;
scan= s->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
dc_scan= luma_dc_zigzag_scan;
}
h->last_qscale_diff = dqp = decode_cabac_mb_dqp( h );
if( dqp == INT_MIN ){
av_log(h->s.avctx, AV_LOG_ERROR, "cabac decode of qscale diff failed at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
s->qscale += dqp;
if(((unsigned)s->qscale) > 51){
if(s->qscale<0) s->qscale+= 52;
else s->qscale-= 52;
}
h->chroma_qp = get_chroma_qp(h->pps.chroma_qp_index_offset, s->qscale);
if( IS_INTRA16x16( mb_type ) ) {
int i;
//av_log( s->avctx, AV_LOG_ERROR, "INTRA16x16 DC\n" );
if( decode_cabac_residual( h, h->mb, 0, 0, dc_scan, NULL, 16) < 0)
return -1;
if( cbp&15 ) {
for( i = 0; i < 16; i++ ) {
//av_log( s->avctx, AV_LOG_ERROR, "INTRA16x16 AC:%d\n", i );
if( decode_cabac_residual(h, h->mb + 16*i, 1, i, scan + 1, h->dequant4_coeff[0][s->qscale], 15) < 0 )
return -1;
}
} else {
fill_rectangle(&h->non_zero_count_cache[scan8[0]], 4, 4, 8, 0, 1);
}
} else {
int i8x8, i4x4;
for( i8x8 = 0; i8x8 < 4; i8x8++ ) {
if( cbp & (1<<i8x8) ) {
if( IS_8x8DCT(mb_type) ) {
if( decode_cabac_residual(h, h->mb + 64*i8x8, 5, 4*i8x8,
scan8x8, h->dequant8_coeff[IS_INTRA( mb_type ) ? 0:1][s->qscale], 64) < 0 )
return -1;
} else
for( i4x4 = 0; i4x4 < 4; i4x4++ ) {
const int index = 4*i8x8 + i4x4;
//av_log( s->avctx, AV_LOG_ERROR, "Luma4x4: %d\n", index );
//START_TIMER
if( decode_cabac_residual(h, h->mb + 16*index, 2, index, scan, h->dequant4_coeff[IS_INTRA( mb_type ) ? 0:3][s->qscale], 16) < 0 )
return -1;
//STOP_TIMER("decode_residual")
}
} else {
uint8_t * const nnz= &h->non_zero_count_cache[ scan8[4*i8x8] ];
nnz[0] = nnz[1] = nnz[8] = nnz[9] = 0;
}
}
}
if( cbp&0x30 ){
int c;
for( c = 0; c < 2; c++ ) {
//av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-DC\n",c );
if( decode_cabac_residual(h, h->mb + 256 + 16*4*c, 3, c, chroma_dc_scan, NULL, 4) < 0)
return -1;
}
}
if( cbp&0x20 ) {
int c, i;
for( c = 0; c < 2; c++ ) {
const uint32_t *qmul = h->dequant4_coeff[c+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp];
for( i = 0; i < 4; i++ ) {
const int index = 16 + 4 * c + i;
//av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-AC %d\n",c, index - 16 );
if( decode_cabac_residual(h, h->mb + 16*index, 4, index - 16, scan + 1, qmul, 15) < 0)
return -1;
}
}
} else {
uint8_t * const nnz= &h->non_zero_count_cache[0];
nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] =
nnz[ scan8[20]+0 ] = nnz[ scan8[20]+1 ] =nnz[ scan8[20]+8 ] =nnz[ scan8[20]+9 ] = 0;
}
} else {
uint8_t * const nnz= &h->non_zero_count_cache[0];
fill_rectangle(&nnz[scan8[0]], 4, 4, 8, 0, 1);
nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] =
nnz[ scan8[20]+0 ] = nnz[ scan8[20]+1 ] =nnz[ scan8[20]+8 ] =nnz[ scan8[20]+9 ] = 0;
h->last_qscale_diff = 0;
}
s->current_picture.qscale_table[mb_xy]= s->qscale;
write_back_non_zero_count(h);
if(MB_MBAFF){
h->ref_count[0] >>= 1;
h->ref_count[1] >>= 1;
}
return 0;
}
| true | FFmpeg | 042ef4b720f5d3321d9b7eeeb2067c671d5aeefd | static int decode_mb_cabac(H264Context *h) {
MpegEncContext * const s = &h->s;
const int mb_xy= s->mb_x + s->mb_y*s->mb_stride;
int mb_type, partition_count, cbp = 0;
int dct8x8_allowed= h->pps.transform_8x8_mode;
s->dsp.clear_blocks(h->mb);
tprintf(s->avctx, "pic:%d mb:%d/%d\n", h->frame_num, s->mb_x, s->mb_y);
if( h->slice_type != I_TYPE && h->slice_type != SI_TYPE ) {
int skip;
if( FRAME_MBAFF && s->mb_x==0 && (s->mb_y&1)==0 )
predict_field_decoding_flag(h);
if( FRAME_MBAFF && (s->mb_y&1)==1 && h->prev_mb_skipped )
skip = h->next_mb_skipped;
else
skip = decode_cabac_mb_skip( h, s->mb_x, s->mb_y );
if( skip ) {
if( FRAME_MBAFF && (s->mb_y&1)==0 ){
s->current_picture.mb_type[mb_xy] = MB_TYPE_SKIP;
h->next_mb_skipped = decode_cabac_mb_skip( h, s->mb_x, s->mb_y+1 );
if(h->next_mb_skipped)
predict_field_decoding_flag(h);
else
h->mb_mbaff = h->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h);
}
decode_mb_skip(h);
h->cbp_table[mb_xy] = 0;
h->chroma_pred_mode_table[mb_xy] = 0;
h->last_qscale_diff = 0;
return 0;
}
}
if(FRAME_MBAFF){
if( (s->mb_y&1) == 0 )
h->mb_mbaff =
h->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h);
}else
h->mb_field_decoding_flag= (s->picture_structure!=PICT_FRAME);
h->prev_mb_skipped = 0;
compute_mb_neighbors(h);
if( ( mb_type = decode_cabac_mb_type( h ) ) < 0 ) {
av_log( h->s.avctx, AV_LOG_ERROR, "decode_cabac_mb_type failed\n" );
return -1;
}
if( h->slice_type == B_TYPE ) {
if( mb_type < 23 ){
partition_count= b_mb_type_info[mb_type].partition_count;
mb_type= b_mb_type_info[mb_type].type;
}else{
mb_type -= 23;
goto decode_intra_mb;
}
} else if( h->slice_type == P_TYPE ) {
if( mb_type < 5) {
partition_count= p_mb_type_info[mb_type].partition_count;
mb_type= p_mb_type_info[mb_type].type;
} else {
mb_type -= 5;
goto decode_intra_mb;
}
} else {
assert(h->slice_type == I_TYPE);
decode_intra_mb:
partition_count = 0;
cbp= i_mb_type_info[mb_type].cbp;
h->intra16x16_pred_mode= i_mb_type_info[mb_type].pred_mode;
mb_type= i_mb_type_info[mb_type].type;
}
if(MB_FIELD)
mb_type |= MB_TYPE_INTERLACED;
h->slice_table[ mb_xy ]= h->slice_num;
if(IS_INTRA_PCM(mb_type)) {
const uint8_t *ptr;
unsigned int x, y;
ptr= h->cabac.bytestream;
if(h->cabac.low&0x1) ptr--;
if(CABAC_BITS==16){
if(h->cabac.low&0x1FF) ptr--;
}
for(y=0; y<16; y++){
const int index= 4*(y&3) + 32*((y>>2)&1) + 128*(y>>3);
for(x=0; x<16; x++){
tprintf(s->avctx, "LUMA ICPM LEVEL (%3d)\n", *ptr);
h->mb[index + (x&3) + 16*((x>>2)&1) + 64*(x>>3)]= *ptr++;
}
}
for(y=0; y<8; y++){
const int index= 256 + 4*(y&3) + 32*(y>>2);
for(x=0; x<8; x++){
tprintf(s->avctx, "CHROMA U ICPM LEVEL (%3d)\n", *ptr);
h->mb[index + (x&3) + 16*(x>>2)]= *ptr++;
}
}
for(y=0; y<8; y++){
const int index= 256 + 64 + 4*(y&3) + 32*(y>>2);
for(x=0; x<8; x++){
tprintf(s->avctx, "CHROMA V ICPM LEVEL (%3d)\n", *ptr);
h->mb[index + (x&3) + 16*(x>>2)]= *ptr++;
}
}
ff_init_cabac_decoder(&h->cabac, ptr, h->cabac.bytestream_end - ptr);
h->cbp_table[mb_xy] = 0x1ef;
h->chroma_pred_mode_table[mb_xy] = 0;
s->current_picture.qscale_table[mb_xy]= 0;
h->chroma_qp = get_chroma_qp(h->pps.chroma_qp_index_offset, 0);
memset(h->non_zero_count[mb_xy], 16, 16);
s->current_picture.mb_type[mb_xy]= mb_type;
return 0;
}
if(MB_MBAFF){
h->ref_count[0] <<= 1;
h->ref_count[1] <<= 1;
}
fill_caches(h, mb_type, 0);
if( IS_INTRA( mb_type ) ) {
int i, pred_mode;
if( IS_INTRA4x4( mb_type ) ) {
if( dct8x8_allowed && decode_cabac_mb_transform_size( h ) ) {
mb_type |= MB_TYPE_8x8DCT;
for( i = 0; i < 16; i+=4 ) {
int pred = pred_intra_mode( h, i );
int mode = decode_cabac_mb_intra4x4_pred_mode( h, pred );
fill_rectangle( &h->intra4x4_pred_mode_cache[ scan8[i] ], 2, 2, 8, mode, 1 );
}
} else {
for( i = 0; i < 16; i++ ) {
int pred = pred_intra_mode( h, i );
h->intra4x4_pred_mode_cache[ scan8[i] ] = decode_cabac_mb_intra4x4_pred_mode( h, pred );
}
}
write_back_intra_pred_mode(h);
if( check_intra4x4_pred_mode(h) < 0 ) return -1;
} else {
h->intra16x16_pred_mode= check_intra_pred_mode( h, h->intra16x16_pred_mode );
if( h->intra16x16_pred_mode < 0 ) return -1;
}
h->chroma_pred_mode_table[mb_xy] =
pred_mode = decode_cabac_mb_chroma_pre_mode( h );
pred_mode= check_intra_pred_mode( h, pred_mode );
if( pred_mode < 0 ) return -1;
h->chroma_pred_mode= pred_mode;
} else if( partition_count == 4 ) {
int i, j, sub_partition_count[4], list, ref[2][4];
if( h->slice_type == B_TYPE ) {
for( i = 0; i < 4; i++ ) {
h->sub_mb_type[i] = decode_cabac_b_mb_sub_type( h );
sub_partition_count[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
h->sub_mb_type[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].type;
}
if( IS_DIRECT(h->sub_mb_type[0] | h->sub_mb_type[1] |
h->sub_mb_type[2] | h->sub_mb_type[3]) ) {
pred_direct_motion(h, &mb_type);
if( h->ref_count[0] > 1 || h->ref_count[1] > 1 ) {
for( i = 0; i < 4; i++ )
if( IS_DIRECT(h->sub_mb_type[i]) )
fill_rectangle( &h->direct_cache[scan8[4*i]], 2, 2, 8, 1, 1 );
}
}
} else {
for( i = 0; i < 4; i++ ) {
h->sub_mb_type[i] = decode_cabac_p_mb_sub_type( h );
sub_partition_count[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
h->sub_mb_type[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].type;
}
}
for( list = 0; list < h->list_count; list++ ) {
for( i = 0; i < 4; i++ ) {
if(IS_DIRECT(h->sub_mb_type[i])) continue;
if(IS_DIR(h->sub_mb_type[i], 0, list)){
if( h->ref_count[list] > 1 )
ref[list][i] = decode_cabac_mb_ref( h, list, 4*i );
else
ref[list][i] = 0;
} else {
ref[list][i] = -1;
}
h->ref_cache[list][ scan8[4*i]+1 ]=
h->ref_cache[list][ scan8[4*i]+8 ]=h->ref_cache[list][ scan8[4*i]+9 ]= ref[list][i];
}
}
if(dct8x8_allowed)
dct8x8_allowed = get_dct8x8_allowed(h);
for(list=0; list<h->list_count; list++){
for(i=0; i<4; i++){
if(IS_DIRECT(h->sub_mb_type[i])){
fill_rectangle(h->mvd_cache[list][scan8[4*i]], 2, 2, 8, 0, 4);
continue;
}
h->ref_cache[list][ scan8[4*i] ]=h->ref_cache[list][ scan8[4*i]+1 ];
if(IS_DIR(h->sub_mb_type[i], 0, list) && !IS_DIRECT(h->sub_mb_type[i])){
const int sub_mb_type= h->sub_mb_type[i];
const int block_width= (sub_mb_type & (MB_TYPE_16x16|MB_TYPE_16x8)) ? 2 : 1;
for(j=0; j<sub_partition_count[i]; j++){
int mpx, mpy;
int mx, my;
const int index= 4*i + block_width*j;
int16_t (* mv_cache)[2]= &h->mv_cache[list][ scan8[index] ];
int16_t (* mvd_cache)[2]= &h->mvd_cache[list][ scan8[index] ];
pred_motion(h, index, block_width, list, h->ref_cache[list][ scan8[index] ], &mpx, &mpy);
mx = mpx + decode_cabac_mb_mvd( h, list, index, 0 );
my = mpy + decode_cabac_mb_mvd( h, list, index, 1 );
tprintf(s->avctx, "final mv:%d %d\n", mx, my);
if(IS_SUB_8X8(sub_mb_type)){
mv_cache[ 1 ][0]=
mv_cache[ 8 ][0]= mv_cache[ 9 ][0]= mx;
mv_cache[ 1 ][1]=
mv_cache[ 8 ][1]= mv_cache[ 9 ][1]= my;
mvd_cache[ 1 ][0]=
mvd_cache[ 8 ][0]= mvd_cache[ 9 ][0]= mx - mpx;
mvd_cache[ 1 ][1]=
mvd_cache[ 8 ][1]= mvd_cache[ 9 ][1]= my - mpy;
}else if(IS_SUB_8X4(sub_mb_type)){
mv_cache[ 1 ][0]= mx;
mv_cache[ 1 ][1]= my;
mvd_cache[ 1 ][0]= mx - mpx;
mvd_cache[ 1 ][1]= my - mpy;
}else if(IS_SUB_4X8(sub_mb_type)){
mv_cache[ 8 ][0]= mx;
mv_cache[ 8 ][1]= my;
mvd_cache[ 8 ][0]= mx - mpx;
mvd_cache[ 8 ][1]= my - mpy;
}
mv_cache[ 0 ][0]= mx;
mv_cache[ 0 ][1]= my;
mvd_cache[ 0 ][0]= mx - mpx;
mvd_cache[ 0 ][1]= my - mpy;
}
}else{
uint32_t *p= (uint32_t *)&h->mv_cache[list][ scan8[4*i] ][0];
uint32_t *pd= (uint32_t *)&h->mvd_cache[list][ scan8[4*i] ][0];
p[0] = p[1] = p[8] = p[9] = 0;
pd[0]= pd[1]= pd[8]= pd[9]= 0;
}
}
}
} else if( IS_DIRECT(mb_type) ) {
pred_direct_motion(h, &mb_type);
fill_rectangle(h->mvd_cache[0][scan8[0]], 4, 4, 8, 0, 4);
fill_rectangle(h->mvd_cache[1][scan8[0]], 4, 4, 8, 0, 4);
dct8x8_allowed &= h->sps.direct_8x8_inference_flag;
} else {
int list, mx, my, i, mpx, mpy;
if(IS_16X16(mb_type)){
for(list=0; list<h->list_count; list++){
if(IS_DIR(mb_type, 0, list)){
const int ref = h->ref_count[list] > 1 ? decode_cabac_mb_ref( h, list, 0 ) : 0;
fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, ref, 1);
}else
fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, (uint8_t)LIST_NOT_USED, 1);
}
for(list=0; list<h->list_count; list++){
if(IS_DIR(mb_type, 0, list)){
pred_motion(h, 0, 4, list, h->ref_cache[list][ scan8[0] ], &mpx, &mpy);
mx = mpx + decode_cabac_mb_mvd( h, list, 0, 0 );
my = mpy + decode_cabac_mb_mvd( h, list, 0, 1 );
tprintf(s->avctx, "final mv:%d %d\n", mx, my);
fill_rectangle(h->mvd_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx-mpx,my-mpy), 4);
fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx,my), 4);
}else
fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, 0, 4);
}
}
else if(IS_16X8(mb_type)){
for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){
const int ref= h->ref_count[list] > 1 ? decode_cabac_mb_ref( h, list, 8*i ) : 0;
fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, ref, 1);
}else
fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, (LIST_NOT_USED&0xFF), 1);
}
}
for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){
pred_16x8_motion(h, 8*i, list, h->ref_cache[list][scan8[0] + 16*i], &mpx, &mpy);
mx = mpx + decode_cabac_mb_mvd( h, list, 8*i, 0 );
my = mpy + decode_cabac_mb_mvd( h, list, 8*i, 1 );
tprintf(s->avctx, "final mv:%d %d\n", mx, my);
fill_rectangle(h->mvd_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack16to32(mx-mpx,my-mpy), 4);
fill_rectangle(h->mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack16to32(mx,my), 4);
}else{
fill_rectangle(h->mvd_cache[list][ scan8[0] + 16*i ], 4, 2, 8, 0, 4);
fill_rectangle(h-> mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, 0, 4);
}
}
}
}else{
assert(IS_8X16(mb_type));
for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){
const int ref= h->ref_count[list] > 1 ? decode_cabac_mb_ref( h, list, 4*i ) : 0;
fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, ref, 1);
}else
fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, (LIST_NOT_USED&0xFF), 1);
}
}
for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){
pred_8x16_motion(h, i*4, list, h->ref_cache[list][ scan8[0] + 2*i ], &mpx, &mpy);
mx = mpx + decode_cabac_mb_mvd( h, list, 4*i, 0 );
my = mpy + decode_cabac_mb_mvd( h, list, 4*i, 1 );
tprintf(s->avctx, "final mv:%d %d\n", mx, my);
fill_rectangle(h->mvd_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack16to32(mx-mpx,my-mpy), 4);
fill_rectangle(h->mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack16to32(mx,my), 4);
}else{
fill_rectangle(h->mvd_cache[list][ scan8[0] + 2*i ], 2, 4, 8, 0, 4);
fill_rectangle(h-> mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, 0, 4);
}
}
}
}
}
if( IS_INTER( mb_type ) ) {
h->chroma_pred_mode_table[mb_xy] = 0;
write_back_motion( h, mb_type );
}
if( !IS_INTRA16x16( mb_type ) ) {
cbp = decode_cabac_mb_cbp_luma( h );
cbp |= decode_cabac_mb_cbp_chroma( h ) << 4;
}
h->cbp_table[mb_xy] = h->cbp = cbp;
if( dct8x8_allowed && (cbp&15) && !IS_INTRA( mb_type ) ) {
if( decode_cabac_mb_transform_size( h ) )
mb_type |= MB_TYPE_8x8DCT;
}
s->current_picture.mb_type[mb_xy]= mb_type;
if( cbp || IS_INTRA16x16( mb_type ) ) {
const uint8_t *scan, *scan8x8, *dc_scan;
int dqp;
if(IS_INTERLACED(mb_type)){
scan8x8= s->qscale ? h->field_scan8x8 : h->field_scan8x8_q0;
scan= s->qscale ? h->field_scan : h->field_scan_q0;
dc_scan= luma_dc_field_scan;
}else{
scan8x8= s->qscale ? h->zigzag_scan8x8 : h->zigzag_scan8x8_q0;
scan= s->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
dc_scan= luma_dc_zigzag_scan;
}
h->last_qscale_diff = dqp = decode_cabac_mb_dqp( h );
if( dqp == INT_MIN ){
av_log(h->s.avctx, AV_LOG_ERROR, "cabac decode of qscale diff failed at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
s->qscale += dqp;
if(((unsigned)s->qscale) > 51){
if(s->qscale<0) s->qscale+= 52;
else s->qscale-= 52;
}
h->chroma_qp = get_chroma_qp(h->pps.chroma_qp_index_offset, s->qscale);
if( IS_INTRA16x16( mb_type ) ) {
int i;
if( decode_cabac_residual( h, h->mb, 0, 0, dc_scan, NULL, 16) < 0)
return -1;
if( cbp&15 ) {
for( i = 0; i < 16; i++ ) {
if( decode_cabac_residual(h, h->mb + 16*i, 1, i, scan + 1, h->dequant4_coeff[0][s->qscale], 15) < 0 )
return -1;
}
} else {
fill_rectangle(&h->non_zero_count_cache[scan8[0]], 4, 4, 8, 0, 1);
}
} else {
int i8x8, i4x4;
for( i8x8 = 0; i8x8 < 4; i8x8++ ) {
if( cbp & (1<<i8x8) ) {
if( IS_8x8DCT(mb_type) ) {
if( decode_cabac_residual(h, h->mb + 64*i8x8, 5, 4*i8x8,
scan8x8, h->dequant8_coeff[IS_INTRA( mb_type ) ? 0:1][s->qscale], 64) < 0 )
return -1;
} else
for( i4x4 = 0; i4x4 < 4; i4x4++ ) {
const int index = 4*i8x8 + i4x4;
if( decode_cabac_residual(h, h->mb + 16*index, 2, index, scan, h->dequant4_coeff[IS_INTRA( mb_type ) ? 0:3][s->qscale], 16) < 0 )
return -1;
}
} else {
uint8_t * const nnz= &h->non_zero_count_cache[ scan8[4*i8x8] ];
nnz[0] = nnz[1] = nnz[8] = nnz[9] = 0;
}
}
}
if( cbp&0x30 ){
int c;
for( c = 0; c < 2; c++ ) {
if( decode_cabac_residual(h, h->mb + 256 + 16*4*c, 3, c, chroma_dc_scan, NULL, 4) < 0)
return -1;
}
}
if( cbp&0x20 ) {
int c, i;
for( c = 0; c < 2; c++ ) {
const uint32_t *qmul = h->dequant4_coeff[c+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp];
for( i = 0; i < 4; i++ ) {
const int index = 16 + 4 * c + i;
if( decode_cabac_residual(h, h->mb + 16*index, 4, index - 16, scan + 1, qmul, 15) < 0)
return -1;
}
}
} else {
uint8_t * const nnz= &h->non_zero_count_cache[0];
nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] =
nnz[ scan8[20]+0 ] = nnz[ scan8[20]+1 ] =nnz[ scan8[20]+8 ] =nnz[ scan8[20]+9 ] = 0;
}
} else {
uint8_t * const nnz= &h->non_zero_count_cache[0];
fill_rectangle(&nnz[scan8[0]], 4, 4, 8, 0, 1);
nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] =
nnz[ scan8[20]+0 ] = nnz[ scan8[20]+1 ] =nnz[ scan8[20]+8 ] =nnz[ scan8[20]+9 ] = 0;
h->last_qscale_diff = 0;
}
s->current_picture.qscale_table[mb_xy]= s->qscale;
write_back_non_zero_count(h);
if(MB_MBAFF){
h->ref_count[0] >>= 1;
h->ref_count[1] >>= 1;
}
return 0;
}
| {
"code": [
" h->chroma_qp = get_chroma_qp(h->pps.chroma_qp_index_offset, 0);",
" h->chroma_qp = get_chroma_qp(h->pps.chroma_qp_index_offset, 0);",
" h->chroma_qp = get_chroma_qp(h->pps.chroma_qp_index_offset, s->qscale);"
],
"line_no": [
253,
253,
805
]
} | static int FUNC_0(H264Context *VAR_0) {
MpegEncContext * const s = &VAR_0->s;
const int VAR_1= s->mb_x + s->mb_y*s->mb_stride;
int VAR_2, VAR_3, VAR_4 = 0;
int VAR_5= VAR_0->pps.transform_8x8_mode;
s->dsp.clear_blocks(VAR_0->mb);
tprintf(s->avctx, "pic:%d mb:%d/%d\n", VAR_0->frame_num, s->mb_x, s->mb_y);
if( VAR_0->slice_type != I_TYPE && VAR_0->slice_type != SI_TYPE ) {
int VAR_6;
if( FRAME_MBAFF && s->mb_x==0 && (s->mb_y&1)==0 )
predict_field_decoding_flag(VAR_0);
if( FRAME_MBAFF && (s->mb_y&1)==1 && VAR_0->prev_mb_skipped )
VAR_6 = VAR_0->next_mb_skipped;
else
VAR_6 = decode_cabac_mb_skip( VAR_0, s->mb_x, s->mb_y );
if( VAR_6 ) {
if( FRAME_MBAFF && (s->mb_y&1)==0 ){
s->current_picture.VAR_2[VAR_1] = MB_TYPE_SKIP;
VAR_0->next_mb_skipped = decode_cabac_mb_skip( VAR_0, s->mb_x, s->mb_y+1 );
if(VAR_0->next_mb_skipped)
predict_field_decoding_flag(VAR_0);
else
VAR_0->mb_mbaff = VAR_0->mb_field_decoding_flag = decode_cabac_field_decoding_flag(VAR_0);
}
decode_mb_skip(VAR_0);
VAR_0->cbp_table[VAR_1] = 0;
VAR_0->chroma_pred_mode_table[VAR_1] = 0;
VAR_0->last_qscale_diff = 0;
return 0;
}
}
if(FRAME_MBAFF){
if( (s->mb_y&1) == 0 )
VAR_0->mb_mbaff =
VAR_0->mb_field_decoding_flag = decode_cabac_field_decoding_flag(VAR_0);
}else
VAR_0->mb_field_decoding_flag= (s->picture_structure!=PICT_FRAME);
VAR_0->prev_mb_skipped = 0;
compute_mb_neighbors(VAR_0);
if( ( VAR_2 = decode_cabac_mb_type( VAR_0 ) ) < 0 ) {
av_log( VAR_0->s.avctx, AV_LOG_ERROR, "decode_cabac_mb_type failed\n" );
return -1;
}
if( VAR_0->slice_type == B_TYPE ) {
if( VAR_2 < 23 ){
VAR_3= b_mb_type_info[VAR_2].VAR_3;
VAR_2= b_mb_type_info[VAR_2].type;
}else{
VAR_2 -= 23;
goto decode_intra_mb;
}
} else if( VAR_0->slice_type == P_TYPE ) {
if( VAR_2 < 5) {
VAR_3= p_mb_type_info[VAR_2].VAR_3;
VAR_2= p_mb_type_info[VAR_2].type;
} else {
VAR_2 -= 5;
goto decode_intra_mb;
}
} else {
assert(VAR_0->slice_type == I_TYPE);
decode_intra_mb:
VAR_3 = 0;
VAR_4= i_mb_type_info[VAR_2].VAR_4;
VAR_0->intra16x16_pred_mode= i_mb_type_info[VAR_2].VAR_12;
VAR_2= i_mb_type_info[VAR_2].type;
}
if(MB_FIELD)
VAR_2 |= MB_TYPE_INTERLACED;
VAR_0->slice_table[ VAR_1 ]= VAR_0->slice_num;
if(IS_INTRA_PCM(VAR_2)) {
const uint8_t *VAR_7;
unsigned int VAR_8, VAR_9;
VAR_7= VAR_0->cabac.bytestream;
if(VAR_0->cabac.low&0x1) VAR_7--;
if(CABAC_BITS==16){
if(VAR_0->cabac.low&0x1FF) VAR_7--;
}
for(VAR_9=0; VAR_9<16; VAR_9++){
const int VAR_29= 4*(VAR_9&3) + 32*((VAR_9>>2)&1) + 128*(VAR_9>>3);
for(VAR_8=0; VAR_8<16; VAR_8++){
tprintf(s->avctx, "LUMA ICPM LEVEL (%3d)\n", *VAR_7);
VAR_0->mb[VAR_29 + (VAR_8&3) + 16*((VAR_8>>2)&1) + 64*(VAR_8>>3)]= *VAR_7++;
}
}
for(VAR_9=0; VAR_9<8; VAR_9++){
const int VAR_29= 256 + 4*(VAR_9&3) + 32*(VAR_9>>2);
for(VAR_8=0; VAR_8<8; VAR_8++){
tprintf(s->avctx, "CHROMA U ICPM LEVEL (%3d)\n", *VAR_7);
VAR_0->mb[VAR_29 + (VAR_8&3) + 16*(VAR_8>>2)]= *VAR_7++;
}
}
for(VAR_9=0; VAR_9<8; VAR_9++){
const int VAR_29= 256 + 64 + 4*(VAR_9&3) + 32*(VAR_9>>2);
for(VAR_8=0; VAR_8<8; VAR_8++){
tprintf(s->avctx, "CHROMA V ICPM LEVEL (%3d)\n", *VAR_7);
VAR_0->mb[VAR_29 + (VAR_8&3) + 16*(VAR_8>>2)]= *VAR_7++;
}
}
ff_init_cabac_decoder(&VAR_0->cabac, VAR_7, VAR_0->cabac.bytestream_end - VAR_7);
VAR_0->cbp_table[VAR_1] = 0x1ef;
VAR_0->chroma_pred_mode_table[VAR_1] = 0;
s->current_picture.qscale_table[VAR_1]= 0;
VAR_0->chroma_qp = get_chroma_qp(VAR_0->pps.chroma_qp_index_offset, 0);
memset(VAR_0->non_zero_count[VAR_1], 16, 16);
s->current_picture.VAR_2[VAR_1]= VAR_2;
return 0;
}
if(MB_MBAFF){
VAR_0->ref_count[0] <<= 1;
VAR_0->ref_count[1] <<= 1;
}
fill_caches(VAR_0, VAR_2, 0);
if( IS_INTRA( VAR_2 ) ) {
int VAR_28, VAR_12;
if( IS_INTRA4x4( VAR_2 ) ) {
if( VAR_5 && decode_cabac_mb_transform_size( VAR_0 ) ) {
VAR_2 |= MB_TYPE_8x8DCT;
for( VAR_28 = 0; VAR_28 < 16; VAR_28+=4 ) {
int VAR_15 = pred_intra_mode( VAR_0, VAR_28 );
int VAR_14 = decode_cabac_mb_intra4x4_pred_mode( VAR_0, VAR_15 );
fill_rectangle( &VAR_0->intra4x4_pred_mode_cache[ scan8[VAR_28] ], 2, 2, 8, VAR_14, 1 );
}
} else {
for( VAR_28 = 0; VAR_28 < 16; VAR_28++ ) {
int VAR_15 = pred_intra_mode( VAR_0, VAR_28 );
VAR_0->intra4x4_pred_mode_cache[ scan8[VAR_28] ] = decode_cabac_mb_intra4x4_pred_mode( VAR_0, VAR_15 );
}
}
write_back_intra_pred_mode(VAR_0);
if( check_intra4x4_pred_mode(VAR_0) < 0 ) return -1;
} else {
VAR_0->intra16x16_pred_mode= check_intra_pred_mode( VAR_0, VAR_0->intra16x16_pred_mode );
if( VAR_0->intra16x16_pred_mode < 0 ) return -1;
}
VAR_0->chroma_pred_mode_table[VAR_1] =
VAR_12 = decode_cabac_mb_chroma_pre_mode( VAR_0 );
VAR_12= check_intra_pred_mode( VAR_0, VAR_12 );
if( VAR_12 < 0 ) return -1;
VAR_0->chroma_pred_mode= VAR_12;
} else if( VAR_3 == 4 ) {
int VAR_28, VAR_15, VAR_16[4], VAR_19, VAR_18[2][4];
if( VAR_0->slice_type == B_TYPE ) {
for( VAR_28 = 0; VAR_28 < 4; VAR_28++ ) {
VAR_0->sub_mb_type[VAR_28] = decode_cabac_b_mb_sub_type( VAR_0 );
VAR_16[VAR_28]= b_sub_mb_type_info[ VAR_0->sub_mb_type[VAR_28] ].VAR_3;
VAR_0->sub_mb_type[VAR_28]= b_sub_mb_type_info[ VAR_0->sub_mb_type[VAR_28] ].type;
}
if( IS_DIRECT(VAR_0->sub_mb_type[0] | VAR_0->sub_mb_type[1] |
VAR_0->sub_mb_type[2] | VAR_0->sub_mb_type[3]) ) {
pred_direct_motion(VAR_0, &VAR_2);
if( VAR_0->ref_count[0] > 1 || VAR_0->ref_count[1] > 1 ) {
for( VAR_28 = 0; VAR_28 < 4; VAR_28++ )
if( IS_DIRECT(VAR_0->sub_mb_type[VAR_28]) )
fill_rectangle( &VAR_0->direct_cache[scan8[4*VAR_28]], 2, 2, 8, 1, 1 );
}
}
} else {
for( VAR_28 = 0; VAR_28 < 4; VAR_28++ ) {
VAR_0->sub_mb_type[VAR_28] = decode_cabac_p_mb_sub_type( VAR_0 );
VAR_16[VAR_28]= p_sub_mb_type_info[ VAR_0->sub_mb_type[VAR_28] ].VAR_3;
VAR_0->sub_mb_type[VAR_28]= p_sub_mb_type_info[ VAR_0->sub_mb_type[VAR_28] ].type;
}
}
for( VAR_19 = 0; VAR_19 < VAR_0->list_count; VAR_19++ ) {
for( VAR_28 = 0; VAR_28 < 4; VAR_28++ ) {
if(IS_DIRECT(VAR_0->sub_mb_type[VAR_28])) continue;
if(IS_DIR(VAR_0->sub_mb_type[VAR_28], 0, VAR_19)){
if( VAR_0->ref_count[VAR_19] > 1 )
VAR_18[VAR_19][VAR_28] = decode_cabac_mb_ref( VAR_0, VAR_19, 4*VAR_28 );
else
VAR_18[VAR_19][VAR_28] = 0;
} else {
VAR_18[VAR_19][VAR_28] = -1;
}
VAR_0->ref_cache[VAR_19][ scan8[4*VAR_28]+1 ]=
VAR_0->ref_cache[VAR_19][ scan8[4*VAR_28]+8 ]=VAR_0->ref_cache[VAR_19][ scan8[4*VAR_28]+9 ]= VAR_18[VAR_19][VAR_28];
}
}
if(VAR_5)
VAR_5 = get_dct8x8_allowed(VAR_0);
for(VAR_19=0; VAR_19<VAR_0->list_count; VAR_19++){
for(VAR_28=0; VAR_28<4; VAR_28++){
if(IS_DIRECT(VAR_0->sub_mb_type[VAR_28])){
fill_rectangle(VAR_0->mvd_cache[VAR_19][scan8[4*VAR_28]], 2, 2, 8, 0, 4);
continue;
}
VAR_0->ref_cache[VAR_19][ scan8[4*VAR_28] ]=VAR_0->ref_cache[VAR_19][ scan8[4*VAR_28]+1 ];
if(IS_DIR(VAR_0->sub_mb_type[VAR_28], 0, VAR_19) && !IS_DIRECT(VAR_0->sub_mb_type[VAR_28])){
const int sub_mb_type= VAR_0->sub_mb_type[VAR_28];
const int block_width= (sub_mb_type & (MB_TYPE_16x16|MB_TYPE_16x8)) ? 2 : 1;
for(VAR_15=0; VAR_15<VAR_16[VAR_28]; VAR_15++){
int VAR_21, VAR_22;
int VAR_19, VAR_20;
const int VAR_29= 4*VAR_28 + block_width*VAR_15;
int16_t (* mv_cache)[2]= &VAR_0->mv_cache[VAR_19][ scan8[VAR_29] ];
int16_t (* mvd_cache)[2]= &VAR_0->mvd_cache[VAR_19][ scan8[VAR_29] ];
pred_motion(VAR_0, VAR_29, block_width, VAR_19, VAR_0->ref_cache[VAR_19][ scan8[VAR_29] ], &VAR_21, &VAR_22);
VAR_19 = VAR_21 + decode_cabac_mb_mvd( VAR_0, VAR_19, VAR_29, 0 );
VAR_20 = VAR_22 + decode_cabac_mb_mvd( VAR_0, VAR_19, VAR_29, 1 );
tprintf(s->avctx, "final mv:%d %d\n", VAR_19, VAR_20);
if(IS_SUB_8X8(sub_mb_type)){
mv_cache[ 1 ][0]=
mv_cache[ 8 ][0]= mv_cache[ 9 ][0]= VAR_19;
mv_cache[ 1 ][1]=
mv_cache[ 8 ][1]= mv_cache[ 9 ][1]= VAR_20;
mvd_cache[ 1 ][0]=
mvd_cache[ 8 ][0]= mvd_cache[ 9 ][0]= VAR_19 - VAR_21;
mvd_cache[ 1 ][1]=
mvd_cache[ 8 ][1]= mvd_cache[ 9 ][1]= VAR_20 - VAR_22;
}else if(IS_SUB_8X4(sub_mb_type)){
mv_cache[ 1 ][0]= VAR_19;
mv_cache[ 1 ][1]= VAR_20;
mvd_cache[ 1 ][0]= VAR_19 - VAR_21;
mvd_cache[ 1 ][1]= VAR_20 - VAR_22;
}else if(IS_SUB_4X8(sub_mb_type)){
mv_cache[ 8 ][0]= VAR_19;
mv_cache[ 8 ][1]= VAR_20;
mvd_cache[ 8 ][0]= VAR_19 - VAR_21;
mvd_cache[ 8 ][1]= VAR_20 - VAR_22;
}
mv_cache[ 0 ][0]= VAR_19;
mv_cache[ 0 ][1]= VAR_20;
mvd_cache[ 0 ][0]= VAR_19 - VAR_21;
mvd_cache[ 0 ][1]= VAR_20 - VAR_22;
}
}else{
uint32_t *p= (uint32_t *)&VAR_0->mv_cache[VAR_19][ scan8[4*VAR_28] ][0];
uint32_t *pd= (uint32_t *)&VAR_0->mvd_cache[VAR_19][ scan8[4*VAR_28] ][0];
p[0] = p[1] = p[8] = p[9] = 0;
pd[0]= pd[1]= pd[8]= pd[9]= 0;
}
}
}
} else if( IS_DIRECT(VAR_2) ) {
pred_direct_motion(VAR_0, &VAR_2);
fill_rectangle(VAR_0->mvd_cache[0][scan8[0]], 4, 4, 8, 0, 4);
fill_rectangle(VAR_0->mvd_cache[1][scan8[0]], 4, 4, 8, 0, 4);
VAR_5 &= VAR_0->sps.direct_8x8_inference_flag;
} else {
int VAR_19, VAR_19, VAR_20, VAR_28, VAR_21, VAR_22;
if(IS_16X16(VAR_2)){
for(VAR_19=0; VAR_19<VAR_0->list_count; VAR_19++){
if(IS_DIR(VAR_2, 0, VAR_19)){
const int VAR_18 = VAR_0->ref_count[VAR_19] > 1 ? decode_cabac_mb_ref( VAR_0, VAR_19, 0 ) : 0;
fill_rectangle(&VAR_0->ref_cache[VAR_19][ scan8[0] ], 4, 4, 8, VAR_18, 1);
}else
fill_rectangle(&VAR_0->ref_cache[VAR_19][ scan8[0] ], 4, 4, 8, (uint8_t)LIST_NOT_USED, 1);
}
for(VAR_19=0; VAR_19<VAR_0->list_count; VAR_19++){
if(IS_DIR(VAR_2, 0, VAR_19)){
pred_motion(VAR_0, 0, 4, VAR_19, VAR_0->ref_cache[VAR_19][ scan8[0] ], &VAR_21, &VAR_22);
VAR_19 = VAR_21 + decode_cabac_mb_mvd( VAR_0, VAR_19, 0, 0 );
VAR_20 = VAR_22 + decode_cabac_mb_mvd( VAR_0, VAR_19, 0, 1 );
tprintf(s->avctx, "final mv:%d %d\n", VAR_19, VAR_20);
fill_rectangle(VAR_0->mvd_cache[VAR_19][ scan8[0] ], 4, 4, 8, pack16to32(VAR_19-VAR_21,VAR_20-VAR_22), 4);
fill_rectangle(VAR_0->mv_cache[VAR_19][ scan8[0] ], 4, 4, 8, pack16to32(VAR_19,VAR_20), 4);
}else
fill_rectangle(VAR_0->mv_cache[VAR_19][ scan8[0] ], 4, 4, 8, 0, 4);
}
}
else if(IS_16X8(VAR_2)){
for(VAR_19=0; VAR_19<VAR_0->list_count; VAR_19++){
for(VAR_28=0; VAR_28<2; VAR_28++){
if(IS_DIR(VAR_2, VAR_28, VAR_19)){
const int VAR_18= VAR_0->ref_count[VAR_19] > 1 ? decode_cabac_mb_ref( VAR_0, VAR_19, 8*VAR_28 ) : 0;
fill_rectangle(&VAR_0->ref_cache[VAR_19][ scan8[0] + 16*VAR_28 ], 4, 2, 8, VAR_18, 1);
}else
fill_rectangle(&VAR_0->ref_cache[VAR_19][ scan8[0] + 16*VAR_28 ], 4, 2, 8, (LIST_NOT_USED&0xFF), 1);
}
}
for(VAR_19=0; VAR_19<VAR_0->list_count; VAR_19++){
for(VAR_28=0; VAR_28<2; VAR_28++){
if(IS_DIR(VAR_2, VAR_28, VAR_19)){
pred_16x8_motion(VAR_0, 8*VAR_28, VAR_19, VAR_0->ref_cache[VAR_19][scan8[0] + 16*VAR_28], &VAR_21, &VAR_22);
VAR_19 = VAR_21 + decode_cabac_mb_mvd( VAR_0, VAR_19, 8*VAR_28, 0 );
VAR_20 = VAR_22 + decode_cabac_mb_mvd( VAR_0, VAR_19, 8*VAR_28, 1 );
tprintf(s->avctx, "final mv:%d %d\n", VAR_19, VAR_20);
fill_rectangle(VAR_0->mvd_cache[VAR_19][ scan8[0] + 16*VAR_28 ], 4, 2, 8, pack16to32(VAR_19-VAR_21,VAR_20-VAR_22), 4);
fill_rectangle(VAR_0->mv_cache[VAR_19][ scan8[0] + 16*VAR_28 ], 4, 2, 8, pack16to32(VAR_19,VAR_20), 4);
}else{
fill_rectangle(VAR_0->mvd_cache[VAR_19][ scan8[0] + 16*VAR_28 ], 4, 2, 8, 0, 4);
fill_rectangle(VAR_0-> mv_cache[VAR_19][ scan8[0] + 16*VAR_28 ], 4, 2, 8, 0, 4);
}
}
}
}else{
assert(IS_8X16(VAR_2));
for(VAR_19=0; VAR_19<VAR_0->list_count; VAR_19++){
for(VAR_28=0; VAR_28<2; VAR_28++){
if(IS_DIR(VAR_2, VAR_28, VAR_19)){
const int VAR_18= VAR_0->ref_count[VAR_19] > 1 ? decode_cabac_mb_ref( VAR_0, VAR_19, 4*VAR_28 ) : 0;
fill_rectangle(&VAR_0->ref_cache[VAR_19][ scan8[0] + 2*VAR_28 ], 2, 4, 8, VAR_18, 1);
}else
fill_rectangle(&VAR_0->ref_cache[VAR_19][ scan8[0] + 2*VAR_28 ], 2, 4, 8, (LIST_NOT_USED&0xFF), 1);
}
}
for(VAR_19=0; VAR_19<VAR_0->list_count; VAR_19++){
for(VAR_28=0; VAR_28<2; VAR_28++){
if(IS_DIR(VAR_2, VAR_28, VAR_19)){
pred_8x16_motion(VAR_0, VAR_28*4, VAR_19, VAR_0->ref_cache[VAR_19][ scan8[0] + 2*VAR_28 ], &VAR_21, &VAR_22);
VAR_19 = VAR_21 + decode_cabac_mb_mvd( VAR_0, VAR_19, 4*VAR_28, 0 );
VAR_20 = VAR_22 + decode_cabac_mb_mvd( VAR_0, VAR_19, 4*VAR_28, 1 );
tprintf(s->avctx, "final mv:%d %d\n", VAR_19, VAR_20);
fill_rectangle(VAR_0->mvd_cache[VAR_19][ scan8[0] + 2*VAR_28 ], 2, 4, 8, pack16to32(VAR_19-VAR_21,VAR_20-VAR_22), 4);
fill_rectangle(VAR_0->mv_cache[VAR_19][ scan8[0] + 2*VAR_28 ], 2, 4, 8, pack16to32(VAR_19,VAR_20), 4);
}else{
fill_rectangle(VAR_0->mvd_cache[VAR_19][ scan8[0] + 2*VAR_28 ], 2, 4, 8, 0, 4);
fill_rectangle(VAR_0-> mv_cache[VAR_19][ scan8[0] + 2*VAR_28 ], 2, 4, 8, 0, 4);
}
}
}
}
}
if( IS_INTER( VAR_2 ) ) {
VAR_0->chroma_pred_mode_table[VAR_1] = 0;
write_back_motion( VAR_0, VAR_2 );
}
if( !IS_INTRA16x16( VAR_2 ) ) {
VAR_4 = decode_cabac_mb_cbp_luma( VAR_0 );
VAR_4 |= decode_cabac_mb_cbp_chroma( VAR_0 ) << 4;
}
VAR_0->cbp_table[VAR_1] = VAR_0->VAR_4 = VAR_4;
if( VAR_5 && (VAR_4&15) && !IS_INTRA( VAR_2 ) ) {
if( decode_cabac_mb_transform_size( VAR_0 ) )
VAR_2 |= MB_TYPE_8x8DCT;
}
s->current_picture.VAR_2[VAR_1]= VAR_2;
if( VAR_4 || IS_INTRA16x16( VAR_2 ) ) {
const uint8_t *VAR_23, *scan8x8, *dc_scan;
int VAR_24;
if(IS_INTERLACED(VAR_2)){
scan8x8= s->qscale ? VAR_0->field_scan8x8 : VAR_0->field_scan8x8_q0;
VAR_23= s->qscale ? VAR_0->field_scan : VAR_0->field_scan_q0;
dc_scan= luma_dc_field_scan;
}else{
scan8x8= s->qscale ? VAR_0->zigzag_scan8x8 : VAR_0->zigzag_scan8x8_q0;
VAR_23= s->qscale ? VAR_0->zigzag_scan : VAR_0->zigzag_scan_q0;
dc_scan= luma_dc_zigzag_scan;
}
VAR_0->last_qscale_diff = VAR_24 = decode_cabac_mb_dqp( VAR_0 );
if( VAR_24 == INT_MIN ){
av_log(VAR_0->s.avctx, AV_LOG_ERROR, "cabac decode of qscale diff failed at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
s->qscale += VAR_24;
if(((unsigned)s->qscale) > 51){
if(s->qscale<0) s->qscale+= 52;
else s->qscale-= 52;
}
VAR_0->chroma_qp = get_chroma_qp(VAR_0->pps.chroma_qp_index_offset, s->qscale);
if( IS_INTRA16x16( VAR_2 ) ) {
int VAR_28;
if( decode_cabac_residual( VAR_0, VAR_0->mb, 0, 0, dc_scan, NULL, 16) < 0)
return -1;
if( VAR_4&15 ) {
for( VAR_28 = 0; VAR_28 < 16; VAR_28++ ) {
if( decode_cabac_residual(VAR_0, VAR_0->mb + 16*VAR_28, 1, VAR_28, VAR_23 + 1, VAR_0->dequant4_coeff[0][s->qscale], 15) < 0 )
return -1;
}
} else {
fill_rectangle(&VAR_0->non_zero_count_cache[scan8[0]], 4, 4, 8, 0, 1);
}
} else {
int VAR_25, VAR_26;
for( VAR_25 = 0; VAR_25 < 4; VAR_25++ ) {
if( VAR_4 & (1<<VAR_25) ) {
if( IS_8x8DCT(VAR_2) ) {
if( decode_cabac_residual(VAR_0, VAR_0->mb + 64*VAR_25, 5, 4*VAR_25,
scan8x8, VAR_0->dequant8_coeff[IS_INTRA( VAR_2 ) ? 0:1][s->qscale], 64) < 0 )
return -1;
} else
for( VAR_26 = 0; VAR_26 < 4; VAR_26++ ) {
const int VAR_29 = 4*VAR_25 + VAR_26;
if( decode_cabac_residual(VAR_0, VAR_0->mb + 16*VAR_29, 2, VAR_29, VAR_23, VAR_0->dequant4_coeff[IS_INTRA( VAR_2 ) ? 0:3][s->qscale], 16) < 0 )
return -1;
}
} else {
uint8_t * const nnz= &VAR_0->non_zero_count_cache[ scan8[4*VAR_25] ];
nnz[0] = nnz[1] = nnz[8] = nnz[9] = 0;
}
}
}
if( VAR_4&0x30 ){
int VAR_28;
for( VAR_28 = 0; VAR_28 < 2; VAR_28++ ) {
if( decode_cabac_residual(VAR_0, VAR_0->mb + 256 + 16*4*VAR_28, 3, VAR_28, chroma_dc_scan, NULL, 4) < 0)
return -1;
}
}
if( VAR_4&0x20 ) {
int VAR_28, VAR_28;
for( VAR_28 = 0; VAR_28 < 2; VAR_28++ ) {
const uint32_t *VAR_28 = VAR_0->dequant4_coeff[VAR_28+1+(IS_INTRA( VAR_2 ) ? 0:3)][VAR_0->chroma_qp];
for( VAR_28 = 0; VAR_28 < 4; VAR_28++ ) {
const int VAR_29 = 16 + 4 * VAR_28 + VAR_28;
if( decode_cabac_residual(VAR_0, VAR_0->mb + 16*VAR_29, 4, VAR_29 - 16, VAR_23 + 1, VAR_28, 15) < 0)
return -1;
}
}
} else {
uint8_t * const nnz= &VAR_0->non_zero_count_cache[0];
nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] =
nnz[ scan8[20]+0 ] = nnz[ scan8[20]+1 ] =nnz[ scan8[20]+8 ] =nnz[ scan8[20]+9 ] = 0;
}
} else {
uint8_t * const nnz= &VAR_0->non_zero_count_cache[0];
fill_rectangle(&nnz[scan8[0]], 4, 4, 8, 0, 1);
nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] =
nnz[ scan8[20]+0 ] = nnz[ scan8[20]+1 ] =nnz[ scan8[20]+8 ] =nnz[ scan8[20]+9 ] = 0;
VAR_0->last_qscale_diff = 0;
}
s->current_picture.qscale_table[VAR_1]= s->qscale;
write_back_non_zero_count(VAR_0);
if(MB_MBAFF){
VAR_0->ref_count[0] >>= 1;
VAR_0->ref_count[1] >>= 1;
}
return 0;
}
| [
"static int FUNC_0(H264Context *VAR_0) {",
"MpegEncContext * const s = &VAR_0->s;",
"const int VAR_1= s->mb_x + s->mb_y*s->mb_stride;",
"int VAR_2, VAR_3, VAR_4 = 0;",
"int VAR_5= VAR_0->pps.transform_8x8_mode;",
"s->dsp.clear_blocks(VAR_0->mb);",
"tprintf(s->avctx, \"pic:%d mb:%d/%d\\n\", VAR_0->frame_num, s->mb_x, s->mb_y);",
"if( VAR_0->slice_type != I_TYPE && VAR_0->slice_type != SI_TYPE ) {",
"int VAR_6;",
"if( FRAME_MBAFF && s->mb_x==0 && (s->mb_y&1)==0 )\npredict_field_decoding_flag(VAR_0);",
"if( FRAME_MBAFF && (s->mb_y&1)==1 && VAR_0->prev_mb_skipped )\nVAR_6 = VAR_0->next_mb_skipped;",
"else\nVAR_6 = decode_cabac_mb_skip( VAR_0, s->mb_x, s->mb_y );",
"if( VAR_6 ) {",
"if( FRAME_MBAFF && (s->mb_y&1)==0 ){",
"s->current_picture.VAR_2[VAR_1] = MB_TYPE_SKIP;",
"VAR_0->next_mb_skipped = decode_cabac_mb_skip( VAR_0, s->mb_x, s->mb_y+1 );",
"if(VAR_0->next_mb_skipped)\npredict_field_decoding_flag(VAR_0);",
"else\nVAR_0->mb_mbaff = VAR_0->mb_field_decoding_flag = decode_cabac_field_decoding_flag(VAR_0);",
"}",
"decode_mb_skip(VAR_0);",
"VAR_0->cbp_table[VAR_1] = 0;",
"VAR_0->chroma_pred_mode_table[VAR_1] = 0;",
"VAR_0->last_qscale_diff = 0;",
"return 0;",
"}",
"}",
"if(FRAME_MBAFF){",
"if( (s->mb_y&1) == 0 )\nVAR_0->mb_mbaff =\nVAR_0->mb_field_decoding_flag = decode_cabac_field_decoding_flag(VAR_0);",
"}else",
"VAR_0->mb_field_decoding_flag= (s->picture_structure!=PICT_FRAME);",
"VAR_0->prev_mb_skipped = 0;",
"compute_mb_neighbors(VAR_0);",
"if( ( VAR_2 = decode_cabac_mb_type( VAR_0 ) ) < 0 ) {",
"av_log( VAR_0->s.avctx, AV_LOG_ERROR, \"decode_cabac_mb_type failed\\n\" );",
"return -1;",
"}",
"if( VAR_0->slice_type == B_TYPE ) {",
"if( VAR_2 < 23 ){",
"VAR_3= b_mb_type_info[VAR_2].VAR_3;",
"VAR_2= b_mb_type_info[VAR_2].type;",
"}else{",
"VAR_2 -= 23;",
"goto decode_intra_mb;",
"}",
"} else if( VAR_0->slice_type == P_TYPE ) {",
"if( VAR_2 < 5) {",
"VAR_3= p_mb_type_info[VAR_2].VAR_3;",
"VAR_2= p_mb_type_info[VAR_2].type;",
"} else {",
"VAR_2 -= 5;",
"goto decode_intra_mb;",
"}",
"} else {",
"assert(VAR_0->slice_type == I_TYPE);",
"decode_intra_mb:\nVAR_3 = 0;",
"VAR_4= i_mb_type_info[VAR_2].VAR_4;",
"VAR_0->intra16x16_pred_mode= i_mb_type_info[VAR_2].VAR_12;",
"VAR_2= i_mb_type_info[VAR_2].type;",
"}",
"if(MB_FIELD)\nVAR_2 |= MB_TYPE_INTERLACED;",
"VAR_0->slice_table[ VAR_1 ]= VAR_0->slice_num;",
"if(IS_INTRA_PCM(VAR_2)) {",
"const uint8_t *VAR_7;",
"unsigned int VAR_8, VAR_9;",
"VAR_7= VAR_0->cabac.bytestream;",
"if(VAR_0->cabac.low&0x1) VAR_7--;",
"if(CABAC_BITS==16){",
"if(VAR_0->cabac.low&0x1FF) VAR_7--;",
"}",
"for(VAR_9=0; VAR_9<16; VAR_9++){",
"const int VAR_29= 4*(VAR_9&3) + 32*((VAR_9>>2)&1) + 128*(VAR_9>>3);",
"for(VAR_8=0; VAR_8<16; VAR_8++){",
"tprintf(s->avctx, \"LUMA ICPM LEVEL (%3d)\\n\", *VAR_7);",
"VAR_0->mb[VAR_29 + (VAR_8&3) + 16*((VAR_8>>2)&1) + 64*(VAR_8>>3)]= *VAR_7++;",
"}",
"}",
"for(VAR_9=0; VAR_9<8; VAR_9++){",
"const int VAR_29= 256 + 4*(VAR_9&3) + 32*(VAR_9>>2);",
"for(VAR_8=0; VAR_8<8; VAR_8++){",
"tprintf(s->avctx, \"CHROMA U ICPM LEVEL (%3d)\\n\", *VAR_7);",
"VAR_0->mb[VAR_29 + (VAR_8&3) + 16*(VAR_8>>2)]= *VAR_7++;",
"}",
"}",
"for(VAR_9=0; VAR_9<8; VAR_9++){",
"const int VAR_29= 256 + 64 + 4*(VAR_9&3) + 32*(VAR_9>>2);",
"for(VAR_8=0; VAR_8<8; VAR_8++){",
"tprintf(s->avctx, \"CHROMA V ICPM LEVEL (%3d)\\n\", *VAR_7);",
"VAR_0->mb[VAR_29 + (VAR_8&3) + 16*(VAR_8>>2)]= *VAR_7++;",
"}",
"}",
"ff_init_cabac_decoder(&VAR_0->cabac, VAR_7, VAR_0->cabac.bytestream_end - VAR_7);",
"VAR_0->cbp_table[VAR_1] = 0x1ef;",
"VAR_0->chroma_pred_mode_table[VAR_1] = 0;",
"s->current_picture.qscale_table[VAR_1]= 0;",
"VAR_0->chroma_qp = get_chroma_qp(VAR_0->pps.chroma_qp_index_offset, 0);",
"memset(VAR_0->non_zero_count[VAR_1], 16, 16);",
"s->current_picture.VAR_2[VAR_1]= VAR_2;",
"return 0;",
"}",
"if(MB_MBAFF){",
"VAR_0->ref_count[0] <<= 1;",
"VAR_0->ref_count[1] <<= 1;",
"}",
"fill_caches(VAR_0, VAR_2, 0);",
"if( IS_INTRA( VAR_2 ) ) {",
"int VAR_28, VAR_12;",
"if( IS_INTRA4x4( VAR_2 ) ) {",
"if( VAR_5 && decode_cabac_mb_transform_size( VAR_0 ) ) {",
"VAR_2 |= MB_TYPE_8x8DCT;",
"for( VAR_28 = 0; VAR_28 < 16; VAR_28+=4 ) {",
"int VAR_15 = pred_intra_mode( VAR_0, VAR_28 );",
"int VAR_14 = decode_cabac_mb_intra4x4_pred_mode( VAR_0, VAR_15 );",
"fill_rectangle( &VAR_0->intra4x4_pred_mode_cache[ scan8[VAR_28] ], 2, 2, 8, VAR_14, 1 );",
"}",
"} else {",
"for( VAR_28 = 0; VAR_28 < 16; VAR_28++ ) {",
"int VAR_15 = pred_intra_mode( VAR_0, VAR_28 );",
"VAR_0->intra4x4_pred_mode_cache[ scan8[VAR_28] ] = decode_cabac_mb_intra4x4_pred_mode( VAR_0, VAR_15 );",
"}",
"}",
"write_back_intra_pred_mode(VAR_0);",
"if( check_intra4x4_pred_mode(VAR_0) < 0 ) return -1;",
"} else {",
"VAR_0->intra16x16_pred_mode= check_intra_pred_mode( VAR_0, VAR_0->intra16x16_pred_mode );",
"if( VAR_0->intra16x16_pred_mode < 0 ) return -1;",
"}",
"VAR_0->chroma_pred_mode_table[VAR_1] =\nVAR_12 = decode_cabac_mb_chroma_pre_mode( VAR_0 );",
"VAR_12= check_intra_pred_mode( VAR_0, VAR_12 );",
"if( VAR_12 < 0 ) return -1;",
"VAR_0->chroma_pred_mode= VAR_12;",
"} else if( VAR_3 == 4 ) {",
"int VAR_28, VAR_15, VAR_16[4], VAR_19, VAR_18[2][4];",
"if( VAR_0->slice_type == B_TYPE ) {",
"for( VAR_28 = 0; VAR_28 < 4; VAR_28++ ) {",
"VAR_0->sub_mb_type[VAR_28] = decode_cabac_b_mb_sub_type( VAR_0 );",
"VAR_16[VAR_28]= b_sub_mb_type_info[ VAR_0->sub_mb_type[VAR_28] ].VAR_3;",
"VAR_0->sub_mb_type[VAR_28]= b_sub_mb_type_info[ VAR_0->sub_mb_type[VAR_28] ].type;",
"}",
"if( IS_DIRECT(VAR_0->sub_mb_type[0] | VAR_0->sub_mb_type[1] |\nVAR_0->sub_mb_type[2] | VAR_0->sub_mb_type[3]) ) {",
"pred_direct_motion(VAR_0, &VAR_2);",
"if( VAR_0->ref_count[0] > 1 || VAR_0->ref_count[1] > 1 ) {",
"for( VAR_28 = 0; VAR_28 < 4; VAR_28++ )",
"if( IS_DIRECT(VAR_0->sub_mb_type[VAR_28]) )\nfill_rectangle( &VAR_0->direct_cache[scan8[4*VAR_28]], 2, 2, 8, 1, 1 );",
"}",
"}",
"} else {",
"for( VAR_28 = 0; VAR_28 < 4; VAR_28++ ) {",
"VAR_0->sub_mb_type[VAR_28] = decode_cabac_p_mb_sub_type( VAR_0 );",
"VAR_16[VAR_28]= p_sub_mb_type_info[ VAR_0->sub_mb_type[VAR_28] ].VAR_3;",
"VAR_0->sub_mb_type[VAR_28]= p_sub_mb_type_info[ VAR_0->sub_mb_type[VAR_28] ].type;",
"}",
"}",
"for( VAR_19 = 0; VAR_19 < VAR_0->list_count; VAR_19++ ) {",
"for( VAR_28 = 0; VAR_28 < 4; VAR_28++ ) {",
"if(IS_DIRECT(VAR_0->sub_mb_type[VAR_28])) continue;",
"if(IS_DIR(VAR_0->sub_mb_type[VAR_28], 0, VAR_19)){",
"if( VAR_0->ref_count[VAR_19] > 1 )\nVAR_18[VAR_19][VAR_28] = decode_cabac_mb_ref( VAR_0, VAR_19, 4*VAR_28 );",
"else\nVAR_18[VAR_19][VAR_28] = 0;",
"} else {",
"VAR_18[VAR_19][VAR_28] = -1;",
"}",
"VAR_0->ref_cache[VAR_19][ scan8[4*VAR_28]+1 ]=\nVAR_0->ref_cache[VAR_19][ scan8[4*VAR_28]+8 ]=VAR_0->ref_cache[VAR_19][ scan8[4*VAR_28]+9 ]= VAR_18[VAR_19][VAR_28];",
"}",
"}",
"if(VAR_5)\nVAR_5 = get_dct8x8_allowed(VAR_0);",
"for(VAR_19=0; VAR_19<VAR_0->list_count; VAR_19++){",
"for(VAR_28=0; VAR_28<4; VAR_28++){",
"if(IS_DIRECT(VAR_0->sub_mb_type[VAR_28])){",
"fill_rectangle(VAR_0->mvd_cache[VAR_19][scan8[4*VAR_28]], 2, 2, 8, 0, 4);",
"continue;",
"}",
"VAR_0->ref_cache[VAR_19][ scan8[4*VAR_28] ]=VAR_0->ref_cache[VAR_19][ scan8[4*VAR_28]+1 ];",
"if(IS_DIR(VAR_0->sub_mb_type[VAR_28], 0, VAR_19) && !IS_DIRECT(VAR_0->sub_mb_type[VAR_28])){",
"const int sub_mb_type= VAR_0->sub_mb_type[VAR_28];",
"const int block_width= (sub_mb_type & (MB_TYPE_16x16|MB_TYPE_16x8)) ? 2 : 1;",
"for(VAR_15=0; VAR_15<VAR_16[VAR_28]; VAR_15++){",
"int VAR_21, VAR_22;",
"int VAR_19, VAR_20;",
"const int VAR_29= 4*VAR_28 + block_width*VAR_15;",
"int16_t (* mv_cache)[2]= &VAR_0->mv_cache[VAR_19][ scan8[VAR_29] ];",
"int16_t (* mvd_cache)[2]= &VAR_0->mvd_cache[VAR_19][ scan8[VAR_29] ];",
"pred_motion(VAR_0, VAR_29, block_width, VAR_19, VAR_0->ref_cache[VAR_19][ scan8[VAR_29] ], &VAR_21, &VAR_22);",
"VAR_19 = VAR_21 + decode_cabac_mb_mvd( VAR_0, VAR_19, VAR_29, 0 );",
"VAR_20 = VAR_22 + decode_cabac_mb_mvd( VAR_0, VAR_19, VAR_29, 1 );",
"tprintf(s->avctx, \"final mv:%d %d\\n\", VAR_19, VAR_20);",
"if(IS_SUB_8X8(sub_mb_type)){",
"mv_cache[ 1 ][0]=\nmv_cache[ 8 ][0]= mv_cache[ 9 ][0]= VAR_19;",
"mv_cache[ 1 ][1]=\nmv_cache[ 8 ][1]= mv_cache[ 9 ][1]= VAR_20;",
"mvd_cache[ 1 ][0]=\nmvd_cache[ 8 ][0]= mvd_cache[ 9 ][0]= VAR_19 - VAR_21;",
"mvd_cache[ 1 ][1]=\nmvd_cache[ 8 ][1]= mvd_cache[ 9 ][1]= VAR_20 - VAR_22;",
"}else if(IS_SUB_8X4(sub_mb_type)){",
"mv_cache[ 1 ][0]= VAR_19;",
"mv_cache[ 1 ][1]= VAR_20;",
"mvd_cache[ 1 ][0]= VAR_19 - VAR_21;",
"mvd_cache[ 1 ][1]= VAR_20 - VAR_22;",
"}else if(IS_SUB_4X8(sub_mb_type)){",
"mv_cache[ 8 ][0]= VAR_19;",
"mv_cache[ 8 ][1]= VAR_20;",
"mvd_cache[ 8 ][0]= VAR_19 - VAR_21;",
"mvd_cache[ 8 ][1]= VAR_20 - VAR_22;",
"}",
"mv_cache[ 0 ][0]= VAR_19;",
"mv_cache[ 0 ][1]= VAR_20;",
"mvd_cache[ 0 ][0]= VAR_19 - VAR_21;",
"mvd_cache[ 0 ][1]= VAR_20 - VAR_22;",
"}",
"}else{",
"uint32_t *p= (uint32_t *)&VAR_0->mv_cache[VAR_19][ scan8[4*VAR_28] ][0];",
"uint32_t *pd= (uint32_t *)&VAR_0->mvd_cache[VAR_19][ scan8[4*VAR_28] ][0];",
"p[0] = p[1] = p[8] = p[9] = 0;",
"pd[0]= pd[1]= pd[8]= pd[9]= 0;",
"}",
"}",
"}",
"} else if( IS_DIRECT(VAR_2) ) {",
"pred_direct_motion(VAR_0, &VAR_2);",
"fill_rectangle(VAR_0->mvd_cache[0][scan8[0]], 4, 4, 8, 0, 4);",
"fill_rectangle(VAR_0->mvd_cache[1][scan8[0]], 4, 4, 8, 0, 4);",
"VAR_5 &= VAR_0->sps.direct_8x8_inference_flag;",
"} else {",
"int VAR_19, VAR_19, VAR_20, VAR_28, VAR_21, VAR_22;",
"if(IS_16X16(VAR_2)){",
"for(VAR_19=0; VAR_19<VAR_0->list_count; VAR_19++){",
"if(IS_DIR(VAR_2, 0, VAR_19)){",
"const int VAR_18 = VAR_0->ref_count[VAR_19] > 1 ? decode_cabac_mb_ref( VAR_0, VAR_19, 0 ) : 0;",
"fill_rectangle(&VAR_0->ref_cache[VAR_19][ scan8[0] ], 4, 4, 8, VAR_18, 1);",
"}else",
"fill_rectangle(&VAR_0->ref_cache[VAR_19][ scan8[0] ], 4, 4, 8, (uint8_t)LIST_NOT_USED, 1);",
"}",
"for(VAR_19=0; VAR_19<VAR_0->list_count; VAR_19++){",
"if(IS_DIR(VAR_2, 0, VAR_19)){",
"pred_motion(VAR_0, 0, 4, VAR_19, VAR_0->ref_cache[VAR_19][ scan8[0] ], &VAR_21, &VAR_22);",
"VAR_19 = VAR_21 + decode_cabac_mb_mvd( VAR_0, VAR_19, 0, 0 );",
"VAR_20 = VAR_22 + decode_cabac_mb_mvd( VAR_0, VAR_19, 0, 1 );",
"tprintf(s->avctx, \"final mv:%d %d\\n\", VAR_19, VAR_20);",
"fill_rectangle(VAR_0->mvd_cache[VAR_19][ scan8[0] ], 4, 4, 8, pack16to32(VAR_19-VAR_21,VAR_20-VAR_22), 4);",
"fill_rectangle(VAR_0->mv_cache[VAR_19][ scan8[0] ], 4, 4, 8, pack16to32(VAR_19,VAR_20), 4);",
"}else",
"fill_rectangle(VAR_0->mv_cache[VAR_19][ scan8[0] ], 4, 4, 8, 0, 4);",
"}",
"}",
"else if(IS_16X8(VAR_2)){",
"for(VAR_19=0; VAR_19<VAR_0->list_count; VAR_19++){",
"for(VAR_28=0; VAR_28<2; VAR_28++){",
"if(IS_DIR(VAR_2, VAR_28, VAR_19)){",
"const int VAR_18= VAR_0->ref_count[VAR_19] > 1 ? decode_cabac_mb_ref( VAR_0, VAR_19, 8*VAR_28 ) : 0;",
"fill_rectangle(&VAR_0->ref_cache[VAR_19][ scan8[0] + 16*VAR_28 ], 4, 2, 8, VAR_18, 1);",
"}else",
"fill_rectangle(&VAR_0->ref_cache[VAR_19][ scan8[0] + 16*VAR_28 ], 4, 2, 8, (LIST_NOT_USED&0xFF), 1);",
"}",
"}",
"for(VAR_19=0; VAR_19<VAR_0->list_count; VAR_19++){",
"for(VAR_28=0; VAR_28<2; VAR_28++){",
"if(IS_DIR(VAR_2, VAR_28, VAR_19)){",
"pred_16x8_motion(VAR_0, 8*VAR_28, VAR_19, VAR_0->ref_cache[VAR_19][scan8[0] + 16*VAR_28], &VAR_21, &VAR_22);",
"VAR_19 = VAR_21 + decode_cabac_mb_mvd( VAR_0, VAR_19, 8*VAR_28, 0 );",
"VAR_20 = VAR_22 + decode_cabac_mb_mvd( VAR_0, VAR_19, 8*VAR_28, 1 );",
"tprintf(s->avctx, \"final mv:%d %d\\n\", VAR_19, VAR_20);",
"fill_rectangle(VAR_0->mvd_cache[VAR_19][ scan8[0] + 16*VAR_28 ], 4, 2, 8, pack16to32(VAR_19-VAR_21,VAR_20-VAR_22), 4);",
"fill_rectangle(VAR_0->mv_cache[VAR_19][ scan8[0] + 16*VAR_28 ], 4, 2, 8, pack16to32(VAR_19,VAR_20), 4);",
"}else{",
"fill_rectangle(VAR_0->mvd_cache[VAR_19][ scan8[0] + 16*VAR_28 ], 4, 2, 8, 0, 4);",
"fill_rectangle(VAR_0-> mv_cache[VAR_19][ scan8[0] + 16*VAR_28 ], 4, 2, 8, 0, 4);",
"}",
"}",
"}",
"}else{",
"assert(IS_8X16(VAR_2));",
"for(VAR_19=0; VAR_19<VAR_0->list_count; VAR_19++){",
"for(VAR_28=0; VAR_28<2; VAR_28++){",
"if(IS_DIR(VAR_2, VAR_28, VAR_19)){",
"const int VAR_18= VAR_0->ref_count[VAR_19] > 1 ? decode_cabac_mb_ref( VAR_0, VAR_19, 4*VAR_28 ) : 0;",
"fill_rectangle(&VAR_0->ref_cache[VAR_19][ scan8[0] + 2*VAR_28 ], 2, 4, 8, VAR_18, 1);",
"}else",
"fill_rectangle(&VAR_0->ref_cache[VAR_19][ scan8[0] + 2*VAR_28 ], 2, 4, 8, (LIST_NOT_USED&0xFF), 1);",
"}",
"}",
"for(VAR_19=0; VAR_19<VAR_0->list_count; VAR_19++){",
"for(VAR_28=0; VAR_28<2; VAR_28++){",
"if(IS_DIR(VAR_2, VAR_28, VAR_19)){",
"pred_8x16_motion(VAR_0, VAR_28*4, VAR_19, VAR_0->ref_cache[VAR_19][ scan8[0] + 2*VAR_28 ], &VAR_21, &VAR_22);",
"VAR_19 = VAR_21 + decode_cabac_mb_mvd( VAR_0, VAR_19, 4*VAR_28, 0 );",
"VAR_20 = VAR_22 + decode_cabac_mb_mvd( VAR_0, VAR_19, 4*VAR_28, 1 );",
"tprintf(s->avctx, \"final mv:%d %d\\n\", VAR_19, VAR_20);",
"fill_rectangle(VAR_0->mvd_cache[VAR_19][ scan8[0] + 2*VAR_28 ], 2, 4, 8, pack16to32(VAR_19-VAR_21,VAR_20-VAR_22), 4);",
"fill_rectangle(VAR_0->mv_cache[VAR_19][ scan8[0] + 2*VAR_28 ], 2, 4, 8, pack16to32(VAR_19,VAR_20), 4);",
"}else{",
"fill_rectangle(VAR_0->mvd_cache[VAR_19][ scan8[0] + 2*VAR_28 ], 2, 4, 8, 0, 4);",
"fill_rectangle(VAR_0-> mv_cache[VAR_19][ scan8[0] + 2*VAR_28 ], 2, 4, 8, 0, 4);",
"}",
"}",
"}",
"}",
"}",
"if( IS_INTER( VAR_2 ) ) {",
"VAR_0->chroma_pred_mode_table[VAR_1] = 0;",
"write_back_motion( VAR_0, VAR_2 );",
"}",
"if( !IS_INTRA16x16( VAR_2 ) ) {",
"VAR_4 = decode_cabac_mb_cbp_luma( VAR_0 );",
"VAR_4 |= decode_cabac_mb_cbp_chroma( VAR_0 ) << 4;",
"}",
"VAR_0->cbp_table[VAR_1] = VAR_0->VAR_4 = VAR_4;",
"if( VAR_5 && (VAR_4&15) && !IS_INTRA( VAR_2 ) ) {",
"if( decode_cabac_mb_transform_size( VAR_0 ) )\nVAR_2 |= MB_TYPE_8x8DCT;",
"}",
"s->current_picture.VAR_2[VAR_1]= VAR_2;",
"if( VAR_4 || IS_INTRA16x16( VAR_2 ) ) {",
"const uint8_t *VAR_23, *scan8x8, *dc_scan;",
"int VAR_24;",
"if(IS_INTERLACED(VAR_2)){",
"scan8x8= s->qscale ? VAR_0->field_scan8x8 : VAR_0->field_scan8x8_q0;",
"VAR_23= s->qscale ? VAR_0->field_scan : VAR_0->field_scan_q0;",
"dc_scan= luma_dc_field_scan;",
"}else{",
"scan8x8= s->qscale ? VAR_0->zigzag_scan8x8 : VAR_0->zigzag_scan8x8_q0;",
"VAR_23= s->qscale ? VAR_0->zigzag_scan : VAR_0->zigzag_scan_q0;",
"dc_scan= luma_dc_zigzag_scan;",
"}",
"VAR_0->last_qscale_diff = VAR_24 = decode_cabac_mb_dqp( VAR_0 );",
"if( VAR_24 == INT_MIN ){",
"av_log(VAR_0->s.avctx, AV_LOG_ERROR, \"cabac decode of qscale diff failed at %d %d\\n\", s->mb_x, s->mb_y);",
"return -1;",
"}",
"s->qscale += VAR_24;",
"if(((unsigned)s->qscale) > 51){",
"if(s->qscale<0) s->qscale+= 52;",
"else s->qscale-= 52;",
"}",
"VAR_0->chroma_qp = get_chroma_qp(VAR_0->pps.chroma_qp_index_offset, s->qscale);",
"if( IS_INTRA16x16( VAR_2 ) ) {",
"int VAR_28;",
"if( decode_cabac_residual( VAR_0, VAR_0->mb, 0, 0, dc_scan, NULL, 16) < 0)\nreturn -1;",
"if( VAR_4&15 ) {",
"for( VAR_28 = 0; VAR_28 < 16; VAR_28++ ) {",
"if( decode_cabac_residual(VAR_0, VAR_0->mb + 16*VAR_28, 1, VAR_28, VAR_23 + 1, VAR_0->dequant4_coeff[0][s->qscale], 15) < 0 )\nreturn -1;",
"}",
"} else {",
"fill_rectangle(&VAR_0->non_zero_count_cache[scan8[0]], 4, 4, 8, 0, 1);",
"}",
"} else {",
"int VAR_25, VAR_26;",
"for( VAR_25 = 0; VAR_25 < 4; VAR_25++ ) {",
"if( VAR_4 & (1<<VAR_25) ) {",
"if( IS_8x8DCT(VAR_2) ) {",
"if( decode_cabac_residual(VAR_0, VAR_0->mb + 64*VAR_25, 5, 4*VAR_25,\nscan8x8, VAR_0->dequant8_coeff[IS_INTRA( VAR_2 ) ? 0:1][s->qscale], 64) < 0 )\nreturn -1;",
"} else",
"for( VAR_26 = 0; VAR_26 < 4; VAR_26++ ) {",
"const int VAR_29 = 4*VAR_25 + VAR_26;",
"if( decode_cabac_residual(VAR_0, VAR_0->mb + 16*VAR_29, 2, VAR_29, VAR_23, VAR_0->dequant4_coeff[IS_INTRA( VAR_2 ) ? 0:3][s->qscale], 16) < 0 )\nreturn -1;",
"}",
"} else {",
"uint8_t * const nnz= &VAR_0->non_zero_count_cache[ scan8[4*VAR_25] ];",
"nnz[0] = nnz[1] = nnz[8] = nnz[9] = 0;",
"}",
"}",
"}",
"if( VAR_4&0x30 ){",
"int VAR_28;",
"for( VAR_28 = 0; VAR_28 < 2; VAR_28++ ) {",
"if( decode_cabac_residual(VAR_0, VAR_0->mb + 256 + 16*4*VAR_28, 3, VAR_28, chroma_dc_scan, NULL, 4) < 0)\nreturn -1;",
"}",
"}",
"if( VAR_4&0x20 ) {",
"int VAR_28, VAR_28;",
"for( VAR_28 = 0; VAR_28 < 2; VAR_28++ ) {",
"const uint32_t *VAR_28 = VAR_0->dequant4_coeff[VAR_28+1+(IS_INTRA( VAR_2 ) ? 0:3)][VAR_0->chroma_qp];",
"for( VAR_28 = 0; VAR_28 < 4; VAR_28++ ) {",
"const int VAR_29 = 16 + 4 * VAR_28 + VAR_28;",
"if( decode_cabac_residual(VAR_0, VAR_0->mb + 16*VAR_29, 4, VAR_29 - 16, VAR_23 + 1, VAR_28, 15) < 0)\nreturn -1;",
"}",
"}",
"} else {",
"uint8_t * const nnz= &VAR_0->non_zero_count_cache[0];",
"nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] =\nnnz[ scan8[20]+0 ] = nnz[ scan8[20]+1 ] =nnz[ scan8[20]+8 ] =nnz[ scan8[20]+9 ] = 0;",
"}",
"} else {",
"uint8_t * const nnz= &VAR_0->non_zero_count_cache[0];",
"fill_rectangle(&nnz[scan8[0]], 4, 4, 8, 0, 1);",
"nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] =\nnnz[ scan8[20]+0 ] = nnz[ scan8[20]+1 ] =nnz[ scan8[20]+8 ] =nnz[ scan8[20]+9 ] = 0;",
"VAR_0->last_qscale_diff = 0;",
"}",
"s->current_picture.qscale_table[VAR_1]= s->qscale;",
"write_back_non_zero_count(VAR_0);",
"if(MB_MBAFF){",
"VAR_0->ref_count[0] >>= 1;",
"VAR_0->ref_count[1] >>= 1;",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
]
| [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25,
27
],
[
29,
31
],
[
33,
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47,
49
],
[
51,
53
],
[
55
],
[
59
],
[
63
],
[
65
],
[
67
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81,
83,
85
],
[
87
],
[
89
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
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
],
[
163
],
[
167
],
[
169
],
[
171
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
239
],
[
245
],
[
247
],
[
251
],
[
253
],
[
257
],
[
259
],
[
261
],
[
263
],
[
267
],
[
269
],
[
271
],
[
273
],
[
277
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329,
331
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359,
361
],
[
363
],
[
365
],
[
367
],
[
369,
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401,
403
],
[
405,
407
],
[
409
],
[
411
],
[
413
],
[
415,
417
],
[
419
],
[
421
],
[
425,
427
],
[
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
441
],
[
443
],
[
447
],
[
449
],
[
451
],
[
453
],
[
455
],
[
457
],
[
459
],
[
461
],
[
463
],
[
465
],
[
469
],
[
471
],
[
473
],
[
477
],
[
479,
481
],
[
483,
485
],
[
489,
491
],
[
493,
495
],
[
497
],
[
499
],
[
501
],
[
505
],
[
507
],
[
509
],
[
511
],
[
513
],
[
517
],
[
519
],
[
521
],
[
523
],
[
525
],
[
529
],
[
531
],
[
533
],
[
535
],
[
537
],
[
539
],
[
541
],
[
543
],
[
545
],
[
547
],
[
549
],
[
551
],
[
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
563
],
[
565
],
[
567
],
[
569
],
[
571
],
[
573
],
[
575
],
[
577
],
[
579
],
[
581
],
[
583
],
[
585
],
[
589
],
[
591
],
[
593
],
[
597
],
[
599
],
[
601
],
[
603
],
[
605
],
[
607
],
[
609
],
[
611
],
[
613
],
[
615
],
[
617
],
[
619
],
[
621
],
[
623
],
[
625
],
[
627
],
[
629
],
[
631
],
[
633
],
[
635
],
[
637
],
[
639
],
[
641
],
[
645
],
[
647
],
[
649
],
[
651
],
[
653
],
[
655
],
[
657
],
[
659
],
[
661
],
[
663
],
[
665
],
[
667
],
[
669
],
[
671
],
[
673
],
[
675
],
[
677
],
[
679
],
[
681
],
[
683
],
[
685
],
[
687
],
[
689
],
[
691
],
[
693
],
[
697
],
[
699
],
[
701
],
[
703
],
[
705
],
[
707
],
[
709
],
[
711
],
[
713
],
[
715
],
[
717
],
[
721
],
[
723
],
[
725
],
[
727
],
[
731
],
[
733
],
[
735
],
[
737
],
[
741
],
[
745
],
[
747,
749
],
[
751
],
[
753
],
[
757
],
[
759
],
[
761
],
[
765
],
[
767
],
[
769
],
[
771
],
[
773
],
[
775
],
[
777
],
[
779
],
[
781
],
[
785
],
[
787
],
[
789
],
[
791
],
[
793
],
[
795
],
[
797
],
[
799
],
[
801
],
[
803
],
[
805
],
[
809
],
[
811
],
[
815,
817
],
[
819
],
[
821
],
[
825,
827
],
[
829
],
[
831
],
[
833
],
[
835
],
[
837
],
[
839
],
[
841
],
[
843
],
[
845
],
[
847,
849,
851
],
[
853
],
[
855
],
[
857
],
[
863,
865
],
[
869
],
[
871
],
[
873
],
[
875
],
[
877
],
[
879
],
[
881
],
[
885
],
[
887
],
[
889
],
[
893,
895
],
[
897
],
[
899
],
[
903
],
[
905
],
[
907
],
[
909
],
[
911
],
[
913
],
[
917,
919
],
[
921
],
[
923
],
[
925
],
[
927
],
[
929,
931
],
[
933
],
[
935
],
[
937
],
[
939
],
[
941,
943
],
[
945
],
[
947
],
[
951
],
[
953
],
[
957
],
[
959
],
[
961
],
[
963
],
[
967
],
[
969
]
]
|
13,686 | static int mjpegb_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MJpegDecodeContext *s = avctx->priv_data;
const uint8_t *buf_end, *buf_ptr;
AVFrame *picture = data;
GetBitContext hgb; /* for the header */
uint32_t dqt_offs, dht_offs, sof_offs, sos_offs, second_field_offs;
uint32_t field_size, sod_offs;
buf_ptr = buf;
buf_end = buf + buf_size;
read_header:
/* reset on every SOI */
s->restart_interval = 0;
s->restart_count = 0;
s->mjpb_skiptosod = 0;
if (buf_end - buf_ptr >= 1 << 28)
return AVERROR_INVALIDDATA;
init_get_bits(&hgb, buf_ptr, /*buf_size*/(buf_end - buf_ptr)*8);
skip_bits(&hgb, 32); /* reserved zeros */
if (get_bits_long(&hgb, 32) != MKBETAG('m','j','p','g'))
{
av_log(avctx, AV_LOG_WARNING, "not mjpeg-b (bad fourcc)\n");
return 0;
}
field_size = get_bits_long(&hgb, 32); /* field size */
av_log(avctx, AV_LOG_DEBUG, "field size: 0x%x\n", field_size);
skip_bits(&hgb, 32); /* padded field size */
second_field_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "second_field_offs is %d and size is %d\n");
av_log(avctx, AV_LOG_DEBUG, "second field offs: 0x%x\n", second_field_offs);
dqt_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "dqt is %d and size is %d\n");
av_log(avctx, AV_LOG_DEBUG, "dqt offs: 0x%x\n", dqt_offs);
if (dqt_offs)
{
init_get_bits(&s->gb, buf_ptr+dqt_offs, (buf_end - (buf_ptr+dqt_offs))*8);
s->start_code = DQT;
if (ff_mjpeg_decode_dqt(s) < 0 &&
(avctx->err_recognition & AV_EF_EXPLODE))
return AVERROR_INVALIDDATA;
}
dht_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "dht is %d and size is %d\n");
av_log(avctx, AV_LOG_DEBUG, "dht offs: 0x%x\n", dht_offs);
if (dht_offs)
{
init_get_bits(&s->gb, buf_ptr+dht_offs, (buf_end - (buf_ptr+dht_offs))*8);
s->start_code = DHT;
ff_mjpeg_decode_dht(s);
}
sof_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "sof is %d and size is %d\n");
av_log(avctx, AV_LOG_DEBUG, "sof offs: 0x%x\n", sof_offs);
if (sof_offs)
{
init_get_bits(&s->gb, buf_ptr+sof_offs, (buf_end - (buf_ptr+sof_offs))*8);
s->start_code = SOF0;
if (ff_mjpeg_decode_sof(s) < 0)
return -1;
}
sos_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "sos is %d and size is %d\n");
av_log(avctx, AV_LOG_DEBUG, "sos offs: 0x%x\n", sos_offs);
sod_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "sof is %d and size is %d\n");
av_log(avctx, AV_LOG_DEBUG, "sod offs: 0x%x\n", sod_offs);
if (sos_offs)
{
init_get_bits(&s->gb, buf_ptr + sos_offs,
8 * FFMIN(field_size, buf_end - buf_ptr - sos_offs));
s->mjpb_skiptosod = (sod_offs - sos_offs - show_bits(&s->gb, 16));
s->start_code = SOS;
if (ff_mjpeg_decode_sos(s, NULL, NULL) < 0 &&
(avctx->err_recognition & AV_EF_EXPLODE))
return AVERROR_INVALIDDATA;
}
if (s->interlaced) {
s->bottom_field ^= 1;
/* if not bottom field, do not output image yet */
if (s->bottom_field != s->interlace_polarity && second_field_offs)
{
buf_ptr = buf + second_field_offs;
second_field_offs = 0;
goto read_header;
}
}
//XXX FIXME factorize, this looks very similar to the EOI code
*picture= *s->picture_ptr;
*data_size = sizeof(AVFrame);
if(!s->lossless){
picture->quality= FFMAX3(s->qscale[0], s->qscale[1], s->qscale[2]);
picture->qstride= 0;
picture->qscale_table= s->qscale_table;
memset(picture->qscale_table, picture->quality, (s->width+15)/16);
if(avctx->debug & FF_DEBUG_QP)
av_log(avctx, AV_LOG_DEBUG, "QP: %d\n", picture->quality);
picture->quality*= FF_QP2LAMBDA;
}
return buf_ptr - buf;
}
| false | FFmpeg | 74699ac8c8b562e9f8d26e21482b89585365774a | static int mjpegb_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MJpegDecodeContext *s = avctx->priv_data;
const uint8_t *buf_end, *buf_ptr;
AVFrame *picture = data;
GetBitContext hgb;
uint32_t dqt_offs, dht_offs, sof_offs, sos_offs, second_field_offs;
uint32_t field_size, sod_offs;
buf_ptr = buf;
buf_end = buf + buf_size;
read_header:
s->restart_interval = 0;
s->restart_count = 0;
s->mjpb_skiptosod = 0;
if (buf_end - buf_ptr >= 1 << 28)
return AVERROR_INVALIDDATA;
init_get_bits(&hgb, buf_ptr, (buf_end - buf_ptr)*8);
skip_bits(&hgb, 32);
if (get_bits_long(&hgb, 32) != MKBETAG('m','j','p','g'))
{
av_log(avctx, AV_LOG_WARNING, "not mjpeg-b (bad fourcc)\n");
return 0;
}
field_size = get_bits_long(&hgb, 32);
av_log(avctx, AV_LOG_DEBUG, "field size: 0x%x\n", field_size);
skip_bits(&hgb, 32);
second_field_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "second_field_offs is %d and size is %d\n");
av_log(avctx, AV_LOG_DEBUG, "second field offs: 0x%x\n", second_field_offs);
dqt_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "dqt is %d and size is %d\n");
av_log(avctx, AV_LOG_DEBUG, "dqt offs: 0x%x\n", dqt_offs);
if (dqt_offs)
{
init_get_bits(&s->gb, buf_ptr+dqt_offs, (buf_end - (buf_ptr+dqt_offs))*8);
s->start_code = DQT;
if (ff_mjpeg_decode_dqt(s) < 0 &&
(avctx->err_recognition & AV_EF_EXPLODE))
return AVERROR_INVALIDDATA;
}
dht_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "dht is %d and size is %d\n");
av_log(avctx, AV_LOG_DEBUG, "dht offs: 0x%x\n", dht_offs);
if (dht_offs)
{
init_get_bits(&s->gb, buf_ptr+dht_offs, (buf_end - (buf_ptr+dht_offs))*8);
s->start_code = DHT;
ff_mjpeg_decode_dht(s);
}
sof_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "sof is %d and size is %d\n");
av_log(avctx, AV_LOG_DEBUG, "sof offs: 0x%x\n", sof_offs);
if (sof_offs)
{
init_get_bits(&s->gb, buf_ptr+sof_offs, (buf_end - (buf_ptr+sof_offs))*8);
s->start_code = SOF0;
if (ff_mjpeg_decode_sof(s) < 0)
return -1;
}
sos_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "sos is %d and size is %d\n");
av_log(avctx, AV_LOG_DEBUG, "sos offs: 0x%x\n", sos_offs);
sod_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "sof is %d and size is %d\n");
av_log(avctx, AV_LOG_DEBUG, "sod offs: 0x%x\n", sod_offs);
if (sos_offs)
{
init_get_bits(&s->gb, buf_ptr + sos_offs,
8 * FFMIN(field_size, buf_end - buf_ptr - sos_offs));
s->mjpb_skiptosod = (sod_offs - sos_offs - show_bits(&s->gb, 16));
s->start_code = SOS;
if (ff_mjpeg_decode_sos(s, NULL, NULL) < 0 &&
(avctx->err_recognition & AV_EF_EXPLODE))
return AVERROR_INVALIDDATA;
}
if (s->interlaced) {
s->bottom_field ^= 1;
if (s->bottom_field != s->interlace_polarity && second_field_offs)
{
buf_ptr = buf + second_field_offs;
second_field_offs = 0;
goto read_header;
}
}
*picture= *s->picture_ptr;
*data_size = sizeof(AVFrame);
if(!s->lossless){
picture->quality= FFMAX3(s->qscale[0], s->qscale[1], s->qscale[2]);
picture->qstride= 0;
picture->qscale_table= s->qscale_table;
memset(picture->qscale_table, picture->quality, (s->width+15)/16);
if(avctx->debug & FF_DEBUG_QP)
av_log(avctx, AV_LOG_DEBUG, "QP: %d\n", picture->quality);
picture->quality*= FF_QP2LAMBDA;
}
return buf_ptr - buf;
}
| {
"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;
MJpegDecodeContext *s = VAR_0->priv_data;
const uint8_t *VAR_6, *buf_ptr;
AVFrame *picture = VAR_1;
GetBitContext hgb;
uint32_t dqt_offs, dht_offs, sof_offs, sos_offs, second_field_offs;
uint32_t field_size, sod_offs;
buf_ptr = VAR_4;
VAR_6 = VAR_4 + VAR_5;
read_header:
s->restart_interval = 0;
s->restart_count = 0;
s->mjpb_skiptosod = 0;
if (VAR_6 - buf_ptr >= 1 << 28)
return AVERROR_INVALIDDATA;
init_get_bits(&hgb, buf_ptr, (VAR_6 - buf_ptr)*8);
skip_bits(&hgb, 32);
if (get_bits_long(&hgb, 32) != MKBETAG('m','j','p','g'))
{
av_log(VAR_0, AV_LOG_WARNING, "not mjpeg-b (bad fourcc)\n");
return 0;
}
field_size = get_bits_long(&hgb, 32);
av_log(VAR_0, AV_LOG_DEBUG, "field size: 0x%x\n", field_size);
skip_bits(&hgb, 32);
second_field_offs = read_offs(VAR_0, &hgb, VAR_6 - buf_ptr, "second_field_offs is %d and size is %d\n");
av_log(VAR_0, AV_LOG_DEBUG, "second field offs: 0x%x\n", second_field_offs);
dqt_offs = read_offs(VAR_0, &hgb, VAR_6 - buf_ptr, "dqt is %d and size is %d\n");
av_log(VAR_0, AV_LOG_DEBUG, "dqt offs: 0x%x\n", dqt_offs);
if (dqt_offs)
{
init_get_bits(&s->gb, buf_ptr+dqt_offs, (VAR_6 - (buf_ptr+dqt_offs))*8);
s->start_code = DQT;
if (ff_mjpeg_decode_dqt(s) < 0 &&
(VAR_0->err_recognition & AV_EF_EXPLODE))
return AVERROR_INVALIDDATA;
}
dht_offs = read_offs(VAR_0, &hgb, VAR_6 - buf_ptr, "dht is %d and size is %d\n");
av_log(VAR_0, AV_LOG_DEBUG, "dht offs: 0x%x\n", dht_offs);
if (dht_offs)
{
init_get_bits(&s->gb, buf_ptr+dht_offs, (VAR_6 - (buf_ptr+dht_offs))*8);
s->start_code = DHT;
ff_mjpeg_decode_dht(s);
}
sof_offs = read_offs(VAR_0, &hgb, VAR_6 - buf_ptr, "sof is %d and size is %d\n");
av_log(VAR_0, AV_LOG_DEBUG, "sof offs: 0x%x\n", sof_offs);
if (sof_offs)
{
init_get_bits(&s->gb, buf_ptr+sof_offs, (VAR_6 - (buf_ptr+sof_offs))*8);
s->start_code = SOF0;
if (ff_mjpeg_decode_sof(s) < 0)
return -1;
}
sos_offs = read_offs(VAR_0, &hgb, VAR_6 - buf_ptr, "sos is %d and size is %d\n");
av_log(VAR_0, AV_LOG_DEBUG, "sos offs: 0x%x\n", sos_offs);
sod_offs = read_offs(VAR_0, &hgb, VAR_6 - buf_ptr, "sof is %d and size is %d\n");
av_log(VAR_0, AV_LOG_DEBUG, "sod offs: 0x%x\n", sod_offs);
if (sos_offs)
{
init_get_bits(&s->gb, buf_ptr + sos_offs,
8 * FFMIN(field_size, VAR_6 - buf_ptr - sos_offs));
s->mjpb_skiptosod = (sod_offs - sos_offs - show_bits(&s->gb, 16));
s->start_code = SOS;
if (ff_mjpeg_decode_sos(s, NULL, NULL) < 0 &&
(VAR_0->err_recognition & AV_EF_EXPLODE))
return AVERROR_INVALIDDATA;
}
if (s->interlaced) {
s->bottom_field ^= 1;
if (s->bottom_field != s->interlace_polarity && second_field_offs)
{
buf_ptr = VAR_4 + second_field_offs;
second_field_offs = 0;
goto read_header;
}
}
*picture= *s->picture_ptr;
*VAR_2 = sizeof(AVFrame);
if(!s->lossless){
picture->quality= FFMAX3(s->qscale[0], s->qscale[1], s->qscale[2]);
picture->qstride= 0;
picture->qscale_table= s->qscale_table;
memset(picture->qscale_table, picture->quality, (s->width+15)/16);
if(VAR_0->debug & FF_DEBUG_QP)
av_log(VAR_0, AV_LOG_DEBUG, "QP: %d\n", picture->quality);
picture->quality*= FF_QP2LAMBDA;
}
return buf_ptr - VAR_4;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"MJpegDecodeContext *s = VAR_0->priv_data;",
"const uint8_t *VAR_6, *buf_ptr;",
"AVFrame *picture = VAR_1;",
"GetBitContext hgb;",
"uint32_t dqt_offs, dht_offs, sof_offs, sos_offs, second_field_offs;",
"uint32_t field_size, sod_offs;",
"buf_ptr = VAR_4;",
"VAR_6 = VAR_4 + VAR_5;",
"read_header:\ns->restart_interval = 0;",
"s->restart_count = 0;",
"s->mjpb_skiptosod = 0;",
"if (VAR_6 - buf_ptr >= 1 << 28)\nreturn AVERROR_INVALIDDATA;",
"init_get_bits(&hgb, buf_ptr, (VAR_6 - buf_ptr)*8);",
"skip_bits(&hgb, 32);",
"if (get_bits_long(&hgb, 32) != MKBETAG('m','j','p','g'))\n{",
"av_log(VAR_0, AV_LOG_WARNING, \"not mjpeg-b (bad fourcc)\\n\");",
"return 0;",
"}",
"field_size = get_bits_long(&hgb, 32);",
"av_log(VAR_0, AV_LOG_DEBUG, \"field size: 0x%x\\n\", field_size);",
"skip_bits(&hgb, 32);",
"second_field_offs = read_offs(VAR_0, &hgb, VAR_6 - buf_ptr, \"second_field_offs is %d and size is %d\\n\");",
"av_log(VAR_0, AV_LOG_DEBUG, \"second field offs: 0x%x\\n\", second_field_offs);",
"dqt_offs = read_offs(VAR_0, &hgb, VAR_6 - buf_ptr, \"dqt is %d and size is %d\\n\");",
"av_log(VAR_0, AV_LOG_DEBUG, \"dqt offs: 0x%x\\n\", dqt_offs);",
"if (dqt_offs)\n{",
"init_get_bits(&s->gb, buf_ptr+dqt_offs, (VAR_6 - (buf_ptr+dqt_offs))*8);",
"s->start_code = DQT;",
"if (ff_mjpeg_decode_dqt(s) < 0 &&\n(VAR_0->err_recognition & AV_EF_EXPLODE))\nreturn AVERROR_INVALIDDATA;",
"}",
"dht_offs = read_offs(VAR_0, &hgb, VAR_6 - buf_ptr, \"dht is %d and size is %d\\n\");",
"av_log(VAR_0, AV_LOG_DEBUG, \"dht offs: 0x%x\\n\", dht_offs);",
"if (dht_offs)\n{",
"init_get_bits(&s->gb, buf_ptr+dht_offs, (VAR_6 - (buf_ptr+dht_offs))*8);",
"s->start_code = DHT;",
"ff_mjpeg_decode_dht(s);",
"}",
"sof_offs = read_offs(VAR_0, &hgb, VAR_6 - buf_ptr, \"sof is %d and size is %d\\n\");",
"av_log(VAR_0, AV_LOG_DEBUG, \"sof offs: 0x%x\\n\", sof_offs);",
"if (sof_offs)\n{",
"init_get_bits(&s->gb, buf_ptr+sof_offs, (VAR_6 - (buf_ptr+sof_offs))*8);",
"s->start_code = SOF0;",
"if (ff_mjpeg_decode_sof(s) < 0)\nreturn -1;",
"}",
"sos_offs = read_offs(VAR_0, &hgb, VAR_6 - buf_ptr, \"sos is %d and size is %d\\n\");",
"av_log(VAR_0, AV_LOG_DEBUG, \"sos offs: 0x%x\\n\", sos_offs);",
"sod_offs = read_offs(VAR_0, &hgb, VAR_6 - buf_ptr, \"sof is %d and size is %d\\n\");",
"av_log(VAR_0, AV_LOG_DEBUG, \"sod offs: 0x%x\\n\", sod_offs);",
"if (sos_offs)\n{",
"init_get_bits(&s->gb, buf_ptr + sos_offs,\n8 * FFMIN(field_size, VAR_6 - buf_ptr - sos_offs));",
"s->mjpb_skiptosod = (sod_offs - sos_offs - show_bits(&s->gb, 16));",
"s->start_code = SOS;",
"if (ff_mjpeg_decode_sos(s, NULL, NULL) < 0 &&\n(VAR_0->err_recognition & AV_EF_EXPLODE))\nreturn AVERROR_INVALIDDATA;",
"}",
"if (s->interlaced) {",
"s->bottom_field ^= 1;",
"if (s->bottom_field != s->interlace_polarity && second_field_offs)\n{",
"buf_ptr = VAR_4 + second_field_offs;",
"second_field_offs = 0;",
"goto read_header;",
"}",
"}",
"*picture= *s->picture_ptr;",
"*VAR_2 = sizeof(AVFrame);",
"if(!s->lossless){",
"picture->quality= FFMAX3(s->qscale[0], s->qscale[1], s->qscale[2]);",
"picture->qstride= 0;",
"picture->qscale_table= s->qscale_table;",
"memset(picture->qscale_table, picture->quality, (s->width+15)/16);",
"if(VAR_0->debug & FF_DEBUG_QP)\nav_log(VAR_0, AV_LOG_DEBUG, \"QP: %d\\n\", picture->quality);",
"picture->quality*= FF_QP2LAMBDA;",
"}",
"return buf_ptr - VAR_4;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
33,
37
],
[
39
],
[
41
],
[
45,
47
],
[
51
],
[
55
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87,
89
],
[
91
],
[
93
],
[
95,
97,
99
],
[
101
],
[
105
],
[
107
],
[
109,
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127,
129
],
[
131
],
[
133
],
[
135,
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151,
153
],
[
155,
157
],
[
159
],
[
161
],
[
163,
165,
167
],
[
169
],
[
173
],
[
175
],
[
179,
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
199
],
[
201
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215,
217
],
[
219
],
[
221
],
[
225
],
[
227
]
]
|
13,687 | static void test_ivshmem_single(void)
{
IVState state, *s;
uint32_t data[1024];
int i;
setup_vm(&state);
s = &state;
/* valid io */
out_reg(s, INTRMASK, 0);
in_reg(s, INTRSTATUS);
in_reg(s, IVPOSITION);
out_reg(s, INTRMASK, 0xffffffff);
g_assert_cmpuint(in_reg(s, INTRMASK), ==, 0xffffffff);
out_reg(s, INTRSTATUS, 1);
/* XXX: intercept IRQ, not seen in resp */
g_assert_cmpuint(in_reg(s, INTRSTATUS), ==, 1);
/* invalid io */
out_reg(s, IVPOSITION, 1);
out_reg(s, DOORBELL, 8 << 16);
for (i = 0; i < G_N_ELEMENTS(data); i++) {
data[i] = i;
}
qtest_memwrite(s->qtest, (uintptr_t)s->mem_base, data, sizeof(data));
for (i = 0; i < G_N_ELEMENTS(data); i++) {
g_assert_cmpuint(((uint32_t *)tmpshmem)[i], ==, i);
}
memset(data, 0, sizeof(data));
qtest_memread(s->qtest, (uintptr_t)s->mem_base, data, sizeof(data));
for (i = 0; i < G_N_ELEMENTS(data); i++) {
g_assert_cmpuint(data[i], ==, i);
}
qtest_quit(s->qtest);
}
| true | qemu | 1760048a5d21bacf0e4838da2f61b2d8db7d2866 | static void test_ivshmem_single(void)
{
IVState state, *s;
uint32_t data[1024];
int i;
setup_vm(&state);
s = &state;
out_reg(s, INTRMASK, 0);
in_reg(s, INTRSTATUS);
in_reg(s, IVPOSITION);
out_reg(s, INTRMASK, 0xffffffff);
g_assert_cmpuint(in_reg(s, INTRMASK), ==, 0xffffffff);
out_reg(s, INTRSTATUS, 1);
g_assert_cmpuint(in_reg(s, INTRSTATUS), ==, 1);
out_reg(s, IVPOSITION, 1);
out_reg(s, DOORBELL, 8 << 16);
for (i = 0; i < G_N_ELEMENTS(data); i++) {
data[i] = i;
}
qtest_memwrite(s->qtest, (uintptr_t)s->mem_base, data, sizeof(data));
for (i = 0; i < G_N_ELEMENTS(data); i++) {
g_assert_cmpuint(((uint32_t *)tmpshmem)[i], ==, i);
}
memset(data, 0, sizeof(data));
qtest_memread(s->qtest, (uintptr_t)s->mem_base, data, sizeof(data));
for (i = 0; i < G_N_ELEMENTS(data); i++) {
g_assert_cmpuint(data[i], ==, i);
}
qtest_quit(s->qtest);
}
| {
"code": [
" qtest_quit(s->qtest);"
],
"line_no": [
81
]
} | static void FUNC_0(void)
{
IVState state, *s;
uint32_t data[1024];
int VAR_0;
setup_vm(&state);
s = &state;
out_reg(s, INTRMASK, 0);
in_reg(s, INTRSTATUS);
in_reg(s, IVPOSITION);
out_reg(s, INTRMASK, 0xffffffff);
g_assert_cmpuint(in_reg(s, INTRMASK), ==, 0xffffffff);
out_reg(s, INTRSTATUS, 1);
g_assert_cmpuint(in_reg(s, INTRSTATUS), ==, 1);
out_reg(s, IVPOSITION, 1);
out_reg(s, DOORBELL, 8 << 16);
for (VAR_0 = 0; VAR_0 < G_N_ELEMENTS(data); VAR_0++) {
data[VAR_0] = VAR_0;
}
qtest_memwrite(s->qtest, (uintptr_t)s->mem_base, data, sizeof(data));
for (VAR_0 = 0; VAR_0 < G_N_ELEMENTS(data); VAR_0++) {
g_assert_cmpuint(((uint32_t *)tmpshmem)[VAR_0], ==, VAR_0);
}
memset(data, 0, sizeof(data));
qtest_memread(s->qtest, (uintptr_t)s->mem_base, data, sizeof(data));
for (VAR_0 = 0; VAR_0 < G_N_ELEMENTS(data); VAR_0++) {
g_assert_cmpuint(data[VAR_0], ==, VAR_0);
}
qtest_quit(s->qtest);
}
| [
"static void FUNC_0(void)\n{",
"IVState state, *s;",
"uint32_t data[1024];",
"int VAR_0;",
"setup_vm(&state);",
"s = &state;",
"out_reg(s, INTRMASK, 0);",
"in_reg(s, INTRSTATUS);",
"in_reg(s, IVPOSITION);",
"out_reg(s, INTRMASK, 0xffffffff);",
"g_assert_cmpuint(in_reg(s, INTRMASK), ==, 0xffffffff);",
"out_reg(s, INTRSTATUS, 1);",
"g_assert_cmpuint(in_reg(s, INTRSTATUS), ==, 1);",
"out_reg(s, IVPOSITION, 1);",
"out_reg(s, DOORBELL, 8 << 16);",
"for (VAR_0 = 0; VAR_0 < G_N_ELEMENTS(data); VAR_0++) {",
"data[VAR_0] = VAR_0;",
"}",
"qtest_memwrite(s->qtest, (uintptr_t)s->mem_base, data, sizeof(data));",
"for (VAR_0 = 0; VAR_0 < G_N_ELEMENTS(data); VAR_0++) {",
"g_assert_cmpuint(((uint32_t *)tmpshmem)[VAR_0], ==, VAR_0);",
"}",
"memset(data, 0, sizeof(data));",
"qtest_memread(s->qtest, (uintptr_t)s->mem_base, data, sizeof(data));",
"for (VAR_0 = 0; VAR_0 < G_N_ELEMENTS(data); VAR_0++) {",
"g_assert_cmpuint(data[VAR_0], ==, VAR_0);",
"}",
"qtest_quit(s->qtest);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
]
]
|
13,688 | static int mov_read_stsz(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
unsigned int i, entries, sample_size, field_size, num_bytes;
GetBitContext gb;
unsigned char* buf;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
get_byte(pb); /* version */
get_be24(pb); /* flags */
if (atom.type == MKTAG('s','t','s','z')) {
sample_size = get_be32(pb);
if (!sc->sample_size) /* do not overwrite value computed in stsd */
sc->sample_size = sample_size;
field_size = 32;
} else {
sample_size = 0;
get_be24(pb); /* reserved */
field_size = get_byte(pb);
}
entries = get_be32(pb);
dprintf(c->fc, "sample_size = %d sample_count = %d\n", sc->sample_size, entries);
sc->sample_count = entries;
if (sample_size)
return 0;
if (field_size != 4 && field_size != 8 && field_size != 16 && field_size != 32) {
av_log(c->fc, AV_LOG_ERROR, "Invalid sample field size %d\n", field_size);
return -1;
}
if(entries >= UINT_MAX / sizeof(int))
return -1;
sc->sample_sizes = av_malloc(entries * sizeof(int));
if (!sc->sample_sizes)
return AVERROR(ENOMEM);
num_bytes = (entries*field_size+4)>>3;
buf = av_malloc(num_bytes+FF_INPUT_BUFFER_PADDING_SIZE);
if (!buf) {
av_freep(&sc->sample_sizes);
return AVERROR(ENOMEM);
}
if (get_buffer(pb, buf, num_bytes) < num_bytes) {
av_freep(&sc->sample_sizes);
av_free(buf);
return -1;
}
init_get_bits(&gb, buf, 8*num_bytes);
for(i=0; i<entries; i++)
sc->sample_sizes[i] = get_bits_long(&gb, field_size);
av_free(buf);
return 0;
}
| true | FFmpeg | e4bc8af1e687efb2a2c41a469ac7b31f1c3d48cd | static int mov_read_stsz(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
unsigned int i, entries, sample_size, field_size, num_bytes;
GetBitContext gb;
unsigned char* buf;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
get_byte(pb);
get_be24(pb);
if (atom.type == MKTAG('s','t','s','z')) {
sample_size = get_be32(pb);
if (!sc->sample_size)
sc->sample_size = sample_size;
field_size = 32;
} else {
sample_size = 0;
get_be24(pb);
field_size = get_byte(pb);
}
entries = get_be32(pb);
dprintf(c->fc, "sample_size = %d sample_count = %d\n", sc->sample_size, entries);
sc->sample_count = entries;
if (sample_size)
return 0;
if (field_size != 4 && field_size != 8 && field_size != 16 && field_size != 32) {
av_log(c->fc, AV_LOG_ERROR, "Invalid sample field size %d\n", field_size);
return -1;
}
if(entries >= UINT_MAX / sizeof(int))
return -1;
sc->sample_sizes = av_malloc(entries * sizeof(int));
if (!sc->sample_sizes)
return AVERROR(ENOMEM);
num_bytes = (entries*field_size+4)>>3;
buf = av_malloc(num_bytes+FF_INPUT_BUFFER_PADDING_SIZE);
if (!buf) {
av_freep(&sc->sample_sizes);
return AVERROR(ENOMEM);
}
if (get_buffer(pb, buf, num_bytes) < num_bytes) {
av_freep(&sc->sample_sizes);
av_free(buf);
return -1;
}
init_get_bits(&gb, buf, 8*num_bytes);
for(i=0; i<entries; i++)
sc->sample_sizes[i] = get_bits_long(&gb, field_size);
av_free(buf);
return 0;
}
| {
"code": [
" if(entries >= UINT_MAX / sizeof(int))"
],
"line_no": [
79
]
} | static int FUNC_0(MOVContext *VAR_0, ByteIOContext *VAR_1, MOVAtom VAR_2)
{
AVStream *st;
MOVStreamContext *sc;
unsigned int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;
GetBitContext gb;
unsigned char* VAR_8;
if (VAR_0->fc->nb_streams < 1)
return 0;
st = VAR_0->fc->streams[VAR_0->fc->nb_streams-1];
sc = st->priv_data;
get_byte(VAR_1);
get_be24(VAR_1);
if (VAR_2.type == MKTAG('s','t','s','z')) {
VAR_5 = get_be32(VAR_1);
if (!sc->VAR_5)
sc->VAR_5 = VAR_5;
VAR_6 = 32;
} else {
VAR_5 = 0;
get_be24(VAR_1);
VAR_6 = get_byte(VAR_1);
}
VAR_4 = get_be32(VAR_1);
dprintf(VAR_0->fc, "VAR_5 = %d sample_count = %d\n", sc->VAR_5, VAR_4);
sc->sample_count = VAR_4;
if (VAR_5)
return 0;
if (VAR_6 != 4 && VAR_6 != 8 && VAR_6 != 16 && VAR_6 != 32) {
av_log(VAR_0->fc, AV_LOG_ERROR, "Invalid sample field size %d\n", VAR_6);
return -1;
}
if(VAR_4 >= UINT_MAX / sizeof(int))
return -1;
sc->sample_sizes = av_malloc(VAR_4 * sizeof(int));
if (!sc->sample_sizes)
return AVERROR(ENOMEM);
VAR_7 = (VAR_4*VAR_6+4)>>3;
VAR_8 = av_malloc(VAR_7+FF_INPUT_BUFFER_PADDING_SIZE);
if (!VAR_8) {
av_freep(&sc->sample_sizes);
return AVERROR(ENOMEM);
}
if (get_buffer(VAR_1, VAR_8, VAR_7) < VAR_7) {
av_freep(&sc->sample_sizes);
av_free(VAR_8);
return -1;
}
init_get_bits(&gb, VAR_8, 8*VAR_7);
for(VAR_3=0; VAR_3<VAR_4; VAR_3++)
sc->sample_sizes[VAR_3] = get_bits_long(&gb, VAR_6);
av_free(VAR_8);
return 0;
}
| [
"static int FUNC_0(MOVContext *VAR_0, ByteIOContext *VAR_1, MOVAtom VAR_2)\n{",
"AVStream *st;",
"MOVStreamContext *sc;",
"unsigned int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;",
"GetBitContext gb;",
"unsigned char* VAR_8;",
"if (VAR_0->fc->nb_streams < 1)\nreturn 0;",
"st = VAR_0->fc->streams[VAR_0->fc->nb_streams-1];",
"sc = st->priv_data;",
"get_byte(VAR_1);",
"get_be24(VAR_1);",
"if (VAR_2.type == MKTAG('s','t','s','z')) {",
"VAR_5 = get_be32(VAR_1);",
"if (!sc->VAR_5)\nsc->VAR_5 = VAR_5;",
"VAR_6 = 32;",
"} else {",
"VAR_5 = 0;",
"get_be24(VAR_1);",
"VAR_6 = get_byte(VAR_1);",
"}",
"VAR_4 = get_be32(VAR_1);",
"dprintf(VAR_0->fc, \"VAR_5 = %d sample_count = %d\\n\", sc->VAR_5, VAR_4);",
"sc->sample_count = VAR_4;",
"if (VAR_5)\nreturn 0;",
"if (VAR_6 != 4 && VAR_6 != 8 && VAR_6 != 16 && VAR_6 != 32) {",
"av_log(VAR_0->fc, AV_LOG_ERROR, \"Invalid sample field size %d\\n\", VAR_6);",
"return -1;",
"}",
"if(VAR_4 >= UINT_MAX / sizeof(int))\nreturn -1;",
"sc->sample_sizes = av_malloc(VAR_4 * sizeof(int));",
"if (!sc->sample_sizes)\nreturn AVERROR(ENOMEM);",
"VAR_7 = (VAR_4*VAR_6+4)>>3;",
"VAR_8 = av_malloc(VAR_7+FF_INPUT_BUFFER_PADDING_SIZE);",
"if (!VAR_8) {",
"av_freep(&sc->sample_sizes);",
"return AVERROR(ENOMEM);",
"}",
"if (get_buffer(VAR_1, VAR_8, VAR_7) < VAR_7) {",
"av_freep(&sc->sample_sizes);",
"av_free(VAR_8);",
"return -1;",
"}",
"init_get_bits(&gb, VAR_8, 8*VAR_7);",
"for(VAR_3=0; VAR_3<VAR_4; VAR_3++)",
"sc->sample_sizes[VAR_3] = get_bits_long(&gb, VAR_6);",
"av_free(VAR_8);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17,
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
61
],
[
63,
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79,
81
],
[
83
],
[
85,
87
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
]
]
|
13,689 | static void init_band_stepsize(AVCodecContext *avctx,
Jpeg2000Band *band,
Jpeg2000CodingStyle *codsty,
Jpeg2000QuantStyle *qntsty,
int bandno, int gbandno, int reslevelno,
int cbps)
{
/* TODO: Implementation of quantization step not finished,
* see ISO/IEC 15444-1:2002 E.1 and A.6.4. */
switch (qntsty->quantsty) {
uint8_t gain;
case JPEG2000_QSTY_NONE:
/* TODO: to verify. No quantization in this case */
band->f_stepsize = 1;
break;
case JPEG2000_QSTY_SI:
/*TODO: Compute formula to implement. */
// numbps = cbps +
// lut_gain[codsty->transform == FF_DWT53][bandno + (reslevelno > 0)];
// band->f_stepsize = SHL(2048 + qntsty->mant[gbandno],
// 2 + numbps - qntsty->expn[gbandno]);
// break;
case JPEG2000_QSTY_SE:
/* Exponent quantization step.
* Formula:
* delta_b = 2 ^ (R_b - expn_b) * (1 + (mant_b / 2 ^ 11))
* R_b = R_I + log2 (gain_b )
* see ISO/IEC 15444-1:2002 E.1.1 eqn. E-3 and E-4 */
gain = cbps;
band->f_stepsize = pow(2.0, gain - qntsty->expn[gbandno]);
band->f_stepsize *= qntsty->mant[gbandno] / 2048.0 + 1.0;
break;
default:
band->f_stepsize = 0;
av_log(avctx, AV_LOG_ERROR, "Unknown quantization format\n");
break;
}
if (codsty->transform != FF_DWT53) {
int lband = 0;
switch (bandno + (reslevelno > 0)) {
case 1:
case 2:
band->f_stepsize *= F_LFTG_X * 2;
lband = 1;
break;
case 3:
band->f_stepsize *= F_LFTG_X * F_LFTG_X * 4;
break;
}
if (codsty->transform == FF_DWT97) {
band->f_stepsize *= pow(F_LFTG_K, 2*(codsty->nreslevels2decode - reslevelno) + lband - 2);
}
}
band->i_stepsize = band->f_stepsize * (1 << 15);
/* FIXME: In openjepg code stespize = stepsize * 0.5. Why?
* If not set output of entropic decoder is not correct. */
if (!av_codec_is_encoder(avctx->codec))
band->f_stepsize *= 0.5;
}
| true | FFmpeg | 42868ca569f33b91b0e61ecc3065e7199e9ca58a | static void init_band_stepsize(AVCodecContext *avctx,
Jpeg2000Band *band,
Jpeg2000CodingStyle *codsty,
Jpeg2000QuantStyle *qntsty,
int bandno, int gbandno, int reslevelno,
int cbps)
{
switch (qntsty->quantsty) {
uint8_t gain;
case JPEG2000_QSTY_NONE:
band->f_stepsize = 1;
break;
case JPEG2000_QSTY_SI:
case JPEG2000_QSTY_SE:
gain = cbps;
band->f_stepsize = pow(2.0, gain - qntsty->expn[gbandno]);
band->f_stepsize *= qntsty->mant[gbandno] / 2048.0 + 1.0;
break;
default:
band->f_stepsize = 0;
av_log(avctx, AV_LOG_ERROR, "Unknown quantization format\n");
break;
}
if (codsty->transform != FF_DWT53) {
int lband = 0;
switch (bandno + (reslevelno > 0)) {
case 1:
case 2:
band->f_stepsize *= F_LFTG_X * 2;
lband = 1;
break;
case 3:
band->f_stepsize *= F_LFTG_X * F_LFTG_X * 4;
break;
}
if (codsty->transform == FF_DWT97) {
band->f_stepsize *= pow(F_LFTG_K, 2*(codsty->nreslevels2decode - reslevelno) + lband - 2);
}
}
band->i_stepsize = band->f_stepsize * (1 << 15);
if (!av_codec_is_encoder(avctx->codec))
band->f_stepsize *= 0.5;
}
| {
"code": [
" band->f_stepsize = pow(2.0, gain - qntsty->expn[gbandno]);"
],
"line_no": [
59
]
} | static void FUNC_0(AVCodecContext *VAR_0,
Jpeg2000Band *VAR_1,
Jpeg2000CodingStyle *VAR_2,
Jpeg2000QuantStyle *VAR_3,
int VAR_4, int VAR_5, int VAR_6,
int VAR_7)
{
switch (VAR_3->quantsty) {
uint8_t gain;
case JPEG2000_QSTY_NONE:
VAR_1->f_stepsize = 1;
break;
case JPEG2000_QSTY_SI:
case JPEG2000_QSTY_SE:
gain = VAR_7;
VAR_1->f_stepsize = pow(2.0, gain - VAR_3->expn[VAR_5]);
VAR_1->f_stepsize *= VAR_3->mant[VAR_5] / 2048.0 + 1.0;
break;
default:
VAR_1->f_stepsize = 0;
av_log(VAR_0, AV_LOG_ERROR, "Unknown quantization format\n");
break;
}
if (VAR_2->transform != FF_DWT53) {
int VAR_8 = 0;
switch (VAR_4 + (VAR_6 > 0)) {
case 1:
case 2:
VAR_1->f_stepsize *= F_LFTG_X * 2;
VAR_8 = 1;
break;
case 3:
VAR_1->f_stepsize *= F_LFTG_X * F_LFTG_X * 4;
break;
}
if (VAR_2->transform == FF_DWT97) {
VAR_1->f_stepsize *= pow(F_LFTG_K, 2*(VAR_2->nreslevels2decode - VAR_6) + VAR_8 - 2);
}
}
VAR_1->i_stepsize = VAR_1->f_stepsize * (1 << 15);
if (!av_codec_is_encoder(VAR_0->codec))
VAR_1->f_stepsize *= 0.5;
}
| [
"static void FUNC_0(AVCodecContext *VAR_0,\nJpeg2000Band *VAR_1,\nJpeg2000CodingStyle *VAR_2,\nJpeg2000QuantStyle *VAR_3,\nint VAR_4, int VAR_5, int VAR_6,\nint VAR_7)\n{",
"switch (VAR_3->quantsty) {",
"uint8_t gain;",
"case JPEG2000_QSTY_NONE:\nVAR_1->f_stepsize = 1;",
"break;",
"case JPEG2000_QSTY_SI:\ncase JPEG2000_QSTY_SE:\ngain = VAR_7;",
"VAR_1->f_stepsize = pow(2.0, gain - VAR_3->expn[VAR_5]);",
"VAR_1->f_stepsize *= VAR_3->mant[VAR_5] / 2048.0 + 1.0;",
"break;",
"default:\nVAR_1->f_stepsize = 0;",
"av_log(VAR_0, AV_LOG_ERROR, \"Unknown quantization format\\n\");",
"break;",
"}",
"if (VAR_2->transform != FF_DWT53) {",
"int VAR_8 = 0;",
"switch (VAR_4 + (VAR_6 > 0)) {",
"case 1:\ncase 2:\nVAR_1->f_stepsize *= F_LFTG_X * 2;",
"VAR_8 = 1;",
"break;",
"case 3:\nVAR_1->f_stepsize *= F_LFTG_X * F_LFTG_X * 4;",
"break;",
"}",
"if (VAR_2->transform == FF_DWT97) {",
"VAR_1->f_stepsize *= pow(F_LFTG_K, 2*(VAR_2->nreslevels2decode - VAR_6) + VAR_8 - 2);",
"}",
"}",
"VAR_1->i_stepsize = VAR_1->f_stepsize * (1 << 15);",
"if (!av_codec_is_encoder(VAR_0->codec))\nVAR_1->f_stepsize *= 0.5;",
"}"
]
| [
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,
13
],
[
19
],
[
21
],
[
23,
27
],
[
29
],
[
31,
45,
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81,
83,
85
],
[
87
],
[
89
],
[
91,
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
117,
119
],
[
121
]
]
|
13,690 | static int teletext_init_decoder(AVCodecContext *avctx)
{
TeletextContext *ctx = avctx->priv_data;
unsigned int maj, min, rev;
vbi_version(&maj, &min, &rev);
if (!(maj > 0 || min > 2 || min == 2 && rev >= 26)) {
av_log(avctx, AV_LOG_ERROR, "decoder needs zvbi version >= 0.2.26.\n");
return AVERROR_EXTERNAL;
}
if (ctx->format_id == 0) {
avctx->width = 41 * BITMAP_CHAR_WIDTH;
avctx->height = 25 * BITMAP_CHAR_HEIGHT;
}
ctx->dx = NULL;
ctx->vbi = NULL;
ctx->pts = AV_NOPTS_VALUE;
#ifdef DEBUG
{
char *t;
ctx->ex = vbi_export_new("text", &t);
}
#endif
av_log(avctx, AV_LOG_VERBOSE, "page filter: %s\n", ctx->pgno);
return (ctx->format_id == 1) ? ff_ass_subtitle_header_default(avctx) : 0;
}
| true | FFmpeg | 085ca7dcdbf9ab6c23e3a5397b1f6d4aa23f763d | static int teletext_init_decoder(AVCodecContext *avctx)
{
TeletextContext *ctx = avctx->priv_data;
unsigned int maj, min, rev;
vbi_version(&maj, &min, &rev);
if (!(maj > 0 || min > 2 || min == 2 && rev >= 26)) {
av_log(avctx, AV_LOG_ERROR, "decoder needs zvbi version >= 0.2.26.\n");
return AVERROR_EXTERNAL;
}
if (ctx->format_id == 0) {
avctx->width = 41 * BITMAP_CHAR_WIDTH;
avctx->height = 25 * BITMAP_CHAR_HEIGHT;
}
ctx->dx = NULL;
ctx->vbi = NULL;
ctx->pts = AV_NOPTS_VALUE;
#ifdef DEBUG
{
char *t;
ctx->ex = vbi_export_new("text", &t);
}
#endif
av_log(avctx, AV_LOG_VERBOSE, "page filter: %s\n", ctx->pgno);
return (ctx->format_id == 1) ? ff_ass_subtitle_header_default(avctx) : 0;
}
| {
"code": [
" ctx->dx = NULL;",
" ctx->dx = NULL;"
],
"line_no": [
33,
33
]
} | static int FUNC_0(AVCodecContext *VAR_0)
{
TeletextContext *ctx = VAR_0->priv_data;
unsigned int VAR_1, VAR_2, VAR_3;
vbi_version(&VAR_1, &VAR_2, &VAR_3);
if (!(VAR_1 > 0 || VAR_2 > 2 || VAR_2 == 2 && VAR_3 >= 26)) {
av_log(VAR_0, AV_LOG_ERROR, "decoder needs zvbi version >= 0.2.26.\n");
return AVERROR_EXTERNAL;
}
if (ctx->format_id == 0) {
VAR_0->width = 41 * BITMAP_CHAR_WIDTH;
VAR_0->height = 25 * BITMAP_CHAR_HEIGHT;
}
ctx->dx = NULL;
ctx->vbi = NULL;
ctx->pts = AV_NOPTS_VALUE;
#ifdef DEBUG
{
char *t;
ctx->ex = vbi_export_new("text", &t);
}
#endif
av_log(VAR_0, AV_LOG_VERBOSE, "page filter: %s\n", ctx->pgno);
return (ctx->format_id == 1) ? ff_ass_subtitle_header_default(VAR_0) : 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0)\n{",
"TeletextContext *ctx = VAR_0->priv_data;",
"unsigned int VAR_1, VAR_2, VAR_3;",
"vbi_version(&VAR_1, &VAR_2, &VAR_3);",
"if (!(VAR_1 > 0 || VAR_2 > 2 || VAR_2 == 2 && VAR_3 >= 26)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"decoder needs zvbi version >= 0.2.26.\\n\");",
"return AVERROR_EXTERNAL;",
"}",
"if (ctx->format_id == 0) {",
"VAR_0->width = 41 * BITMAP_CHAR_WIDTH;",
"VAR_0->height = 25 * BITMAP_CHAR_HEIGHT;",
"}",
"ctx->dx = NULL;",
"ctx->vbi = NULL;",
"ctx->pts = AV_NOPTS_VALUE;",
"#ifdef DEBUG\n{",
"char *t;",
"ctx->ex = vbi_export_new(\"text\", &t);",
"}",
"#endif\nav_log(VAR_0, AV_LOG_VERBOSE, \"page filter: %s\\n\", ctx->pgno);",
"return (ctx->format_id == 1) ? ff_ass_subtitle_header_default(VAR_0) : 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
]
]
|
13,691 | static void block_job_ref(BlockJob *job)
{
++job->refcnt;
}
| true | qemu | 4172a00373b2c81374293becc02b16b7f8c76659 | static void block_job_ref(BlockJob *job)
{
++job->refcnt;
}
| {
"code": [
"static void block_job_ref(BlockJob *job)"
],
"line_no": [
1
]
} | static void FUNC_0(BlockJob *VAR_0)
{
++VAR_0->refcnt;
}
| [
"static void FUNC_0(BlockJob *VAR_0)\n{",
"++VAR_0->refcnt;",
"}"
]
| [
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
13,692 | static void empty_input(void)
{
const char *empty = "";
QObject *obj = qobject_from_json(empty, NULL);
g_assert(obj == NULL);
}
| true | qemu | aec4b054ea36c53c8b887da99f20010133b84378 | static void empty_input(void)
{
const char *empty = "";
QObject *obj = qobject_from_json(empty, NULL);
g_assert(obj == NULL);
}
| {
"code": [
" QObject *obj = qobject_from_json(empty, NULL);"
],
"line_no": [
9
]
} | static void FUNC_0(void)
{
const char *VAR_0 = "";
QObject *obj = qobject_from_json(VAR_0, NULL);
g_assert(obj == NULL);
}
| [
"static void FUNC_0(void)\n{",
"const char *VAR_0 = \"\";",
"QObject *obj = qobject_from_json(VAR_0, NULL);",
"g_assert(obj == NULL);",
"}"
]
| [
0,
0,
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
]
]
|
13,693 | static FlatRange *address_space_lookup(AddressSpace *as, AddrRange addr)
{
return bsearch(&addr, as->current_map.ranges, as->current_map.nr,
sizeof(FlatRange), cmp_flatrange_addr);
}
| true | qemu | 8786db7cb96f8ce5c75c6e1e074319c9dca8d356 | static FlatRange *address_space_lookup(AddressSpace *as, AddrRange addr)
{
return bsearch(&addr, as->current_map.ranges, as->current_map.nr,
sizeof(FlatRange), cmp_flatrange_addr);
}
| {
"code": [
" return bsearch(&addr, as->current_map.ranges, as->current_map.nr,"
],
"line_no": [
5
]
} | static FlatRange *FUNC_0(AddressSpace *as, AddrRange addr)
{
return bsearch(&addr, as->current_map.ranges, as->current_map.nr,
sizeof(FlatRange), cmp_flatrange_addr);
}
| [
"static FlatRange *FUNC_0(AddressSpace *as, AddrRange addr)\n{",
"return bsearch(&addr, as->current_map.ranges, as->current_map.nr,\nsizeof(FlatRange), cmp_flatrange_addr);",
"}"
]
| [
0,
1,
0
]
| [
[
1,
3
],
[
5,
7
],
[
9
]
]
|
13,694 | void ff_get_guid(AVIOContext *s, ff_asf_guid *g)
{
assert(sizeof(*g) == 16);
avio_read(s, *g, sizeof(*g));
}
| true | FFmpeg | ea3abcd58f83673bf2fe28170339f19ddf683442 | void ff_get_guid(AVIOContext *s, ff_asf_guid *g)
{
assert(sizeof(*g) == 16);
avio_read(s, *g, sizeof(*g));
}
| {
"code": [
" avio_read(s, *g, sizeof(*g));"
],
"line_no": [
7
]
} | void FUNC_0(AVIOContext *VAR_0, ff_asf_guid *VAR_1)
{
assert(sizeof(*VAR_1) == 16);
avio_read(VAR_0, *VAR_1, sizeof(*VAR_1));
}
| [
"void FUNC_0(AVIOContext *VAR_0, ff_asf_guid *VAR_1)\n{",
"assert(sizeof(*VAR_1) == 16);",
"avio_read(VAR_0, *VAR_1, sizeof(*VAR_1));",
"}"
]
| [
0,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
]
]
|
13,695 | static int realloc_refcount_array(BDRVQcowState *s, uint16_t **array,
int64_t *size, int64_t new_size)
{
size_t old_byte_size, new_byte_size;
uint16_t *new_ptr;
/* Round to clusters so the array can be directly written to disk */
old_byte_size = size_to_clusters(s, refcount_array_byte_size(s, *size))
* s->cluster_size;
new_byte_size = size_to_clusters(s, refcount_array_byte_size(s, new_size))
* s->cluster_size;
if (new_byte_size == old_byte_size) {
*size = new_size;
return 0;
}
assert(new_byte_size > 0);
new_ptr = g_try_realloc(*array, new_byte_size);
if (!new_ptr) {
return -ENOMEM;
}
if (new_byte_size > old_byte_size) {
memset((void *)((uintptr_t)new_ptr + old_byte_size), 0,
new_byte_size - old_byte_size);
}
*array = new_ptr;
*size = new_size;
return 0;
}
| true | qemu | 7453c96b78c2b09aa72924f933bb9616e5474194 | static int realloc_refcount_array(BDRVQcowState *s, uint16_t **array,
int64_t *size, int64_t new_size)
{
size_t old_byte_size, new_byte_size;
uint16_t *new_ptr;
old_byte_size = size_to_clusters(s, refcount_array_byte_size(s, *size))
* s->cluster_size;
new_byte_size = size_to_clusters(s, refcount_array_byte_size(s, new_size))
* s->cluster_size;
if (new_byte_size == old_byte_size) {
*size = new_size;
return 0;
}
assert(new_byte_size > 0);
new_ptr = g_try_realloc(*array, new_byte_size);
if (!new_ptr) {
return -ENOMEM;
}
if (new_byte_size > old_byte_size) {
memset((void *)((uintptr_t)new_ptr + old_byte_size), 0,
new_byte_size - old_byte_size);
}
*array = new_ptr;
*size = new_size;
return 0;
}
| {
"code": [
"static int realloc_refcount_array(BDRVQcowState *s, uint16_t **array,",
" uint16_t *new_ptr;"
],
"line_no": [
1,
9
]
} | static int FUNC_0(BDRVQcowState *VAR_0, uint16_t **VAR_1,
int64_t *VAR_2, int64_t VAR_3)
{
size_t old_byte_size, new_byte_size;
uint16_t *new_ptr;
old_byte_size = size_to_clusters(VAR_0, refcount_array_byte_size(VAR_0, *VAR_2))
* VAR_0->cluster_size;
new_byte_size = size_to_clusters(VAR_0, refcount_array_byte_size(VAR_0, VAR_3))
* VAR_0->cluster_size;
if (new_byte_size == old_byte_size) {
*VAR_2 = VAR_3;
return 0;
}
assert(new_byte_size > 0);
new_ptr = g_try_realloc(*VAR_1, new_byte_size);
if (!new_ptr) {
return -ENOMEM;
}
if (new_byte_size > old_byte_size) {
memset((void *)((uintptr_t)new_ptr + old_byte_size), 0,
new_byte_size - old_byte_size);
}
*VAR_1 = new_ptr;
*VAR_2 = VAR_3;
return 0;
}
| [
"static int FUNC_0(BDRVQcowState *VAR_0, uint16_t **VAR_1,\nint64_t *VAR_2, int64_t VAR_3)\n{",
"size_t old_byte_size, new_byte_size;",
"uint16_t *new_ptr;",
"old_byte_size = size_to_clusters(VAR_0, refcount_array_byte_size(VAR_0, *VAR_2))\n* VAR_0->cluster_size;",
"new_byte_size = size_to_clusters(VAR_0, refcount_array_byte_size(VAR_0, VAR_3))\n* VAR_0->cluster_size;",
"if (new_byte_size == old_byte_size) {",
"*VAR_2 = VAR_3;",
"return 0;",
"}",
"assert(new_byte_size > 0);",
"new_ptr = g_try_realloc(*VAR_1, new_byte_size);",
"if (!new_ptr) {",
"return -ENOMEM;",
"}",
"if (new_byte_size > old_byte_size) {",
"memset((void *)((uintptr_t)new_ptr + old_byte_size), 0,\nnew_byte_size - old_byte_size);",
"}",
"*VAR_1 = new_ptr;",
"*VAR_2 = VAR_3;",
"return 0;",
"}"
]
| [
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
15,
17
],
[
19,
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51,
53
],
[
55
],
[
59
],
[
61
],
[
65
],
[
67
]
]
|
13,696 | static void imdct36(int *out, int *buf, int *in, int *win)
{
int i, j, t0, t1, t2, t3, s0, s1, s2, s3;
int tmp[18], *tmp1, *in1;
for(i=17;i>=1;i--)
in[i] += in[i-1];
for(i=17;i>=3;i-=2)
in[i] += in[i-2];
for(j=0;j<2;j++) {
tmp1 = tmp + j;
in1 = in + j;
#if 0
//more accurate but slower
int64_t t0, t1, t2, t3;
t2 = in1[2*4] + in1[2*8] - in1[2*2];
t3 = (in1[2*0] + (int64_t)(in1[2*6]>>1))<<32;
t1 = in1[2*0] - in1[2*6];
tmp1[ 6] = t1 - (t2>>1);
tmp1[16] = t1 + t2;
t0 = MUL64(2*(in1[2*2] + in1[2*4]), C2);
t1 = MUL64( in1[2*4] - in1[2*8] , -2*C8);
t2 = MUL64(2*(in1[2*2] + in1[2*8]), -C4);
tmp1[10] = (t3 - t0 - t2) >> 32;
tmp1[ 2] = (t3 + t0 + t1) >> 32;
tmp1[14] = (t3 + t2 - t1) >> 32;
tmp1[ 4] = MULH(2*(in1[2*5] + in1[2*7] - in1[2*1]), -C3);
t2 = MUL64(2*(in1[2*1] + in1[2*5]), C1);
t3 = MUL64( in1[2*5] - in1[2*7] , -2*C7);
t0 = MUL64(2*in1[2*3], C3);
t1 = MUL64(2*(in1[2*1] + in1[2*7]), -C5);
tmp1[ 0] = (t2 + t3 + t0) >> 32;
tmp1[12] = (t2 + t1 - t0) >> 32;
tmp1[ 8] = (t3 - t1 - t0) >> 32;
#else
t2 = in1[2*4] + in1[2*8] - in1[2*2];
t3 = in1[2*0] + (in1[2*6]>>1);
t1 = in1[2*0] - in1[2*6];
tmp1[ 6] = t1 - (t2>>1);
tmp1[16] = t1 + t2;
t0 = MULH(2*(in1[2*2] + in1[2*4]), C2);
t1 = MULH( in1[2*4] - in1[2*8] , -2*C8);
t2 = MULH(2*(in1[2*2] + in1[2*8]), -C4);
tmp1[10] = t3 - t0 - t2;
tmp1[ 2] = t3 + t0 + t1;
tmp1[14] = t3 + t2 - t1;
tmp1[ 4] = MULH(2*(in1[2*5] + in1[2*7] - in1[2*1]), -C3);
t2 = MULH(2*(in1[2*1] + in1[2*5]), C1);
t3 = MULH( in1[2*5] - in1[2*7] , -2*C7);
t0 = MULH(2*in1[2*3], C3);
t1 = MULH(2*(in1[2*1] + in1[2*7]), -C5);
tmp1[ 0] = t2 + t3 + t0;
tmp1[12] = t2 + t1 - t0;
tmp1[ 8] = t3 - t1 - t0;
#endif
}
i = 0;
for(j=0;j<4;j++) {
t0 = tmp[i];
t1 = tmp[i + 2];
s0 = t1 + t0;
s2 = t1 - t0;
t2 = tmp[i + 1];
t3 = tmp[i + 3];
s1 = MULL(t3 + t2, icos36[j]);
s3 = MULL(t3 - t2, icos36[8 - j]);
t0 = (s0 + s1) << 5;
t1 = (s0 - s1) << 5;
out[(9 + j)*SBLIMIT] = MULH(t1, win[9 + j]) + buf[9 + j];
out[(8 - j)*SBLIMIT] = MULH(t1, win[8 - j]) + buf[8 - j];
buf[9 + j] = MULH(t0, win[18 + 9 + j]);
buf[8 - j] = MULH(t0, win[18 + 8 - j]);
t0 = (s2 + s3) << 5;
t1 = (s2 - s3) << 5;
out[(9 + 8 - j)*SBLIMIT] = MULH(t1, win[9 + 8 - j]) + buf[9 + 8 - j];
out[( j)*SBLIMIT] = MULH(t1, win[ j]) + buf[ j];
buf[9 + 8 - j] = MULH(t0, win[18 + 9 + 8 - j]);
buf[ + j] = MULH(t0, win[18 + j]);
i += 4;
}
s0 = tmp[16];
s1 = MULL(tmp[17], icos36[4]);
t0 = (s0 + s1) << 5;
t1 = (s0 - s1) << 5;
out[(9 + 4)*SBLIMIT] = MULH(t1, win[9 + 4]) + buf[9 + 4];
out[(8 - 4)*SBLIMIT] = MULH(t1, win[8 - 4]) + buf[8 - 4];
buf[9 + 4] = MULH(t0, win[18 + 9 + 4]);
buf[8 - 4] = MULH(t0, win[18 + 8 - 4]);
}
| true | FFmpeg | 44f1698a3824836d32708ae93e78ac1f2310a07e | static void imdct36(int *out, int *buf, int *in, int *win)
{
int i, j, t0, t1, t2, t3, s0, s1, s2, s3;
int tmp[18], *tmp1, *in1;
for(i=17;i>=1;i--)
in[i] += in[i-1];
for(i=17;i>=3;i-=2)
in[i] += in[i-2];
for(j=0;j<2;j++) {
tmp1 = tmp + j;
in1 = in + j;
#if 0
int64_t t0, t1, t2, t3;
t2 = in1[2*4] + in1[2*8] - in1[2*2];
t3 = (in1[2*0] + (int64_t)(in1[2*6]>>1))<<32;
t1 = in1[2*0] - in1[2*6];
tmp1[ 6] = t1 - (t2>>1);
tmp1[16] = t1 + t2;
t0 = MUL64(2*(in1[2*2] + in1[2*4]), C2);
t1 = MUL64( in1[2*4] - in1[2*8] , -2*C8);
t2 = MUL64(2*(in1[2*2] + in1[2*8]), -C4);
tmp1[10] = (t3 - t0 - t2) >> 32;
tmp1[ 2] = (t3 + t0 + t1) >> 32;
tmp1[14] = (t3 + t2 - t1) >> 32;
tmp1[ 4] = MULH(2*(in1[2*5] + in1[2*7] - in1[2*1]), -C3);
t2 = MUL64(2*(in1[2*1] + in1[2*5]), C1);
t3 = MUL64( in1[2*5] - in1[2*7] , -2*C7);
t0 = MUL64(2*in1[2*3], C3);
t1 = MUL64(2*(in1[2*1] + in1[2*7]), -C5);
tmp1[ 0] = (t2 + t3 + t0) >> 32;
tmp1[12] = (t2 + t1 - t0) >> 32;
tmp1[ 8] = (t3 - t1 - t0) >> 32;
#else
t2 = in1[2*4] + in1[2*8] - in1[2*2];
t3 = in1[2*0] + (in1[2*6]>>1);
t1 = in1[2*0] - in1[2*6];
tmp1[ 6] = t1 - (t2>>1);
tmp1[16] = t1 + t2;
t0 = MULH(2*(in1[2*2] + in1[2*4]), C2);
t1 = MULH( in1[2*4] - in1[2*8] , -2*C8);
t2 = MULH(2*(in1[2*2] + in1[2*8]), -C4);
tmp1[10] = t3 - t0 - t2;
tmp1[ 2] = t3 + t0 + t1;
tmp1[14] = t3 + t2 - t1;
tmp1[ 4] = MULH(2*(in1[2*5] + in1[2*7] - in1[2*1]), -C3);
t2 = MULH(2*(in1[2*1] + in1[2*5]), C1);
t3 = MULH( in1[2*5] - in1[2*7] , -2*C7);
t0 = MULH(2*in1[2*3], C3);
t1 = MULH(2*(in1[2*1] + in1[2*7]), -C5);
tmp1[ 0] = t2 + t3 + t0;
tmp1[12] = t2 + t1 - t0;
tmp1[ 8] = t3 - t1 - t0;
#endif
}
i = 0;
for(j=0;j<4;j++) {
t0 = tmp[i];
t1 = tmp[i + 2];
s0 = t1 + t0;
s2 = t1 - t0;
t2 = tmp[i + 1];
t3 = tmp[i + 3];
s1 = MULL(t3 + t2, icos36[j]);
s3 = MULL(t3 - t2, icos36[8 - j]);
t0 = (s0 + s1) << 5;
t1 = (s0 - s1) << 5;
out[(9 + j)*SBLIMIT] = MULH(t1, win[9 + j]) + buf[9 + j];
out[(8 - j)*SBLIMIT] = MULH(t1, win[8 - j]) + buf[8 - j];
buf[9 + j] = MULH(t0, win[18 + 9 + j]);
buf[8 - j] = MULH(t0, win[18 + 8 - j]);
t0 = (s2 + s3) << 5;
t1 = (s2 - s3) << 5;
out[(9 + 8 - j)*SBLIMIT] = MULH(t1, win[9 + 8 - j]) + buf[9 + 8 - j];
out[( j)*SBLIMIT] = MULH(t1, win[ j]) + buf[ j];
buf[9 + 8 - j] = MULH(t0, win[18 + 9 + 8 - j]);
buf[ + j] = MULH(t0, win[18 + j]);
i += 4;
}
s0 = tmp[16];
s1 = MULL(tmp[17], icos36[4]);
t0 = (s0 + s1) << 5;
t1 = (s0 - s1) << 5;
out[(9 + 4)*SBLIMIT] = MULH(t1, win[9 + 4]) + buf[9 + 4];
out[(8 - 4)*SBLIMIT] = MULH(t1, win[8 - 4]) + buf[8 - 4];
buf[9 + 4] = MULH(t0, win[18 + 9 + 4]);
buf[8 - 4] = MULH(t0, win[18 + 8 - 4]);
}
| {
"code": [
" t0 = (s0 + s1) << 5;",
" t1 = (s0 - s1) << 5;",
" t0 = (s2 + s3) << 5;",
" t1 = (s2 - s3) << 5;",
" t0 = (s0 + s1) << 5;",
" t1 = (s0 - s1) << 5;"
],
"line_no": [
165,
167,
179,
181,
201,
203
]
} | static void FUNC_0(int *VAR_0, int *VAR_1, int *VAR_2, int *VAR_3)
{
int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13;
int VAR_14[18], *VAR_15, *VAR_16;
for(VAR_4=17;VAR_4>=1;VAR_4--)
VAR_2[VAR_4] += VAR_2[VAR_4-1];
for(VAR_4=17;VAR_4>=3;VAR_4-=2)
VAR_2[VAR_4] += VAR_2[VAR_4-2];
for(VAR_5=0;VAR_5<2;VAR_5++) {
VAR_15 = VAR_14 + VAR_5;
VAR_16 = VAR_2 + VAR_5;
#if 0
int64_t VAR_6, VAR_7, VAR_8, VAR_9;
VAR_8 = VAR_16[2*4] + VAR_16[2*8] - VAR_16[2*2];
VAR_9 = (VAR_16[2*0] + (int64_t)(VAR_16[2*6]>>1))<<32;
VAR_7 = VAR_16[2*0] - VAR_16[2*6];
VAR_15[ 6] = VAR_7 - (VAR_8>>1);
VAR_15[16] = VAR_7 + VAR_8;
VAR_6 = MUL64(2*(VAR_16[2*2] + VAR_16[2*4]), C2);
VAR_7 = MUL64( VAR_16[2*4] - VAR_16[2*8] , -2*C8);
VAR_8 = MUL64(2*(VAR_16[2*2] + VAR_16[2*8]), -C4);
VAR_15[10] = (VAR_9 - VAR_6 - VAR_8) >> 32;
VAR_15[ 2] = (VAR_9 + VAR_6 + VAR_7) >> 32;
VAR_15[14] = (VAR_9 + VAR_8 - VAR_7) >> 32;
VAR_15[ 4] = MULH(2*(VAR_16[2*5] + VAR_16[2*7] - VAR_16[2*1]), -C3);
VAR_8 = MUL64(2*(VAR_16[2*1] + VAR_16[2*5]), C1);
VAR_9 = MUL64( VAR_16[2*5] - VAR_16[2*7] , -2*C7);
VAR_6 = MUL64(2*VAR_16[2*3], C3);
VAR_7 = MUL64(2*(VAR_16[2*1] + VAR_16[2*7]), -C5);
VAR_15[ 0] = (VAR_8 + VAR_9 + VAR_6) >> 32;
VAR_15[12] = (VAR_8 + VAR_7 - VAR_6) >> 32;
VAR_15[ 8] = (VAR_9 - VAR_7 - VAR_6) >> 32;
#else
VAR_8 = VAR_16[2*4] + VAR_16[2*8] - VAR_16[2*2];
VAR_9 = VAR_16[2*0] + (VAR_16[2*6]>>1);
VAR_7 = VAR_16[2*0] - VAR_16[2*6];
VAR_15[ 6] = VAR_7 - (VAR_8>>1);
VAR_15[16] = VAR_7 + VAR_8;
VAR_6 = MULH(2*(VAR_16[2*2] + VAR_16[2*4]), C2);
VAR_7 = MULH( VAR_16[2*4] - VAR_16[2*8] , -2*C8);
VAR_8 = MULH(2*(VAR_16[2*2] + VAR_16[2*8]), -C4);
VAR_15[10] = VAR_9 - VAR_6 - VAR_8;
VAR_15[ 2] = VAR_9 + VAR_6 + VAR_7;
VAR_15[14] = VAR_9 + VAR_8 - VAR_7;
VAR_15[ 4] = MULH(2*(VAR_16[2*5] + VAR_16[2*7] - VAR_16[2*1]), -C3);
VAR_8 = MULH(2*(VAR_16[2*1] + VAR_16[2*5]), C1);
VAR_9 = MULH( VAR_16[2*5] - VAR_16[2*7] , -2*C7);
VAR_6 = MULH(2*VAR_16[2*3], C3);
VAR_7 = MULH(2*(VAR_16[2*1] + VAR_16[2*7]), -C5);
VAR_15[ 0] = VAR_8 + VAR_9 + VAR_6;
VAR_15[12] = VAR_8 + VAR_7 - VAR_6;
VAR_15[ 8] = VAR_9 - VAR_7 - VAR_6;
#endif
}
VAR_4 = 0;
for(VAR_5=0;VAR_5<4;VAR_5++) {
VAR_6 = VAR_14[VAR_4];
VAR_7 = VAR_14[VAR_4 + 2];
VAR_10 = VAR_7 + VAR_6;
VAR_12 = VAR_7 - VAR_6;
VAR_8 = VAR_14[VAR_4 + 1];
VAR_9 = VAR_14[VAR_4 + 3];
VAR_11 = MULL(VAR_9 + VAR_8, icos36[VAR_5]);
VAR_13 = MULL(VAR_9 - VAR_8, icos36[8 - VAR_5]);
VAR_6 = (VAR_10 + VAR_11) << 5;
VAR_7 = (VAR_10 - VAR_11) << 5;
VAR_0[(9 + VAR_5)*SBLIMIT] = MULH(VAR_7, VAR_3[9 + VAR_5]) + VAR_1[9 + VAR_5];
VAR_0[(8 - VAR_5)*SBLIMIT] = MULH(VAR_7, VAR_3[8 - VAR_5]) + VAR_1[8 - VAR_5];
VAR_1[9 + VAR_5] = MULH(VAR_6, VAR_3[18 + 9 + VAR_5]);
VAR_1[8 - VAR_5] = MULH(VAR_6, VAR_3[18 + 8 - VAR_5]);
VAR_6 = (VAR_12 + VAR_13) << 5;
VAR_7 = (VAR_12 - VAR_13) << 5;
VAR_0[(9 + 8 - VAR_5)*SBLIMIT] = MULH(VAR_7, VAR_3[9 + 8 - VAR_5]) + VAR_1[9 + 8 - VAR_5];
VAR_0[( VAR_5)*SBLIMIT] = MULH(VAR_7, VAR_3[ VAR_5]) + VAR_1[ VAR_5];
VAR_1[9 + 8 - VAR_5] = MULH(VAR_6, VAR_3[18 + 9 + 8 - VAR_5]);
VAR_1[ + VAR_5] = MULH(VAR_6, VAR_3[18 + VAR_5]);
VAR_4 += 4;
}
VAR_10 = VAR_14[16];
VAR_11 = MULL(VAR_14[17], icos36[4]);
VAR_6 = (VAR_10 + VAR_11) << 5;
VAR_7 = (VAR_10 - VAR_11) << 5;
VAR_0[(9 + 4)*SBLIMIT] = MULH(VAR_7, VAR_3[9 + 4]) + VAR_1[9 + 4];
VAR_0[(8 - 4)*SBLIMIT] = MULH(VAR_7, VAR_3[8 - 4]) + VAR_1[8 - 4];
VAR_1[9 + 4] = MULH(VAR_6, VAR_3[18 + 9 + 4]);
VAR_1[8 - 4] = MULH(VAR_6, VAR_3[18 + 8 - 4]);
}
| [
"static void FUNC_0(int *VAR_0, int *VAR_1, int *VAR_2, int *VAR_3)\n{",
"int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13;",
"int VAR_14[18], *VAR_15, *VAR_16;",
"for(VAR_4=17;VAR_4>=1;VAR_4--)",
"VAR_2[VAR_4] += VAR_2[VAR_4-1];",
"for(VAR_4=17;VAR_4>=3;VAR_4-=2)",
"VAR_2[VAR_4] += VAR_2[VAR_4-2];",
"for(VAR_5=0;VAR_5<2;VAR_5++) {",
"VAR_15 = VAR_14 + VAR_5;",
"VAR_16 = VAR_2 + VAR_5;",
"#if 0\nint64_t VAR_6, VAR_7, VAR_8, VAR_9;",
"VAR_8 = VAR_16[2*4] + VAR_16[2*8] - VAR_16[2*2];",
"VAR_9 = (VAR_16[2*0] + (int64_t)(VAR_16[2*6]>>1))<<32;",
"VAR_7 = VAR_16[2*0] - VAR_16[2*6];",
"VAR_15[ 6] = VAR_7 - (VAR_8>>1);",
"VAR_15[16] = VAR_7 + VAR_8;",
"VAR_6 = MUL64(2*(VAR_16[2*2] + VAR_16[2*4]), C2);",
"VAR_7 = MUL64( VAR_16[2*4] - VAR_16[2*8] , -2*C8);",
"VAR_8 = MUL64(2*(VAR_16[2*2] + VAR_16[2*8]), -C4);",
"VAR_15[10] = (VAR_9 - VAR_6 - VAR_8) >> 32;",
"VAR_15[ 2] = (VAR_9 + VAR_6 + VAR_7) >> 32;",
"VAR_15[14] = (VAR_9 + VAR_8 - VAR_7) >> 32;",
"VAR_15[ 4] = MULH(2*(VAR_16[2*5] + VAR_16[2*7] - VAR_16[2*1]), -C3);",
"VAR_8 = MUL64(2*(VAR_16[2*1] + VAR_16[2*5]), C1);",
"VAR_9 = MUL64( VAR_16[2*5] - VAR_16[2*7] , -2*C7);",
"VAR_6 = MUL64(2*VAR_16[2*3], C3);",
"VAR_7 = MUL64(2*(VAR_16[2*1] + VAR_16[2*7]), -C5);",
"VAR_15[ 0] = (VAR_8 + VAR_9 + VAR_6) >> 32;",
"VAR_15[12] = (VAR_8 + VAR_7 - VAR_6) >> 32;",
"VAR_15[ 8] = (VAR_9 - VAR_7 - VAR_6) >> 32;",
"#else\nVAR_8 = VAR_16[2*4] + VAR_16[2*8] - VAR_16[2*2];",
"VAR_9 = VAR_16[2*0] + (VAR_16[2*6]>>1);",
"VAR_7 = VAR_16[2*0] - VAR_16[2*6];",
"VAR_15[ 6] = VAR_7 - (VAR_8>>1);",
"VAR_15[16] = VAR_7 + VAR_8;",
"VAR_6 = MULH(2*(VAR_16[2*2] + VAR_16[2*4]), C2);",
"VAR_7 = MULH( VAR_16[2*4] - VAR_16[2*8] , -2*C8);",
"VAR_8 = MULH(2*(VAR_16[2*2] + VAR_16[2*8]), -C4);",
"VAR_15[10] = VAR_9 - VAR_6 - VAR_8;",
"VAR_15[ 2] = VAR_9 + VAR_6 + VAR_7;",
"VAR_15[14] = VAR_9 + VAR_8 - VAR_7;",
"VAR_15[ 4] = MULH(2*(VAR_16[2*5] + VAR_16[2*7] - VAR_16[2*1]), -C3);",
"VAR_8 = MULH(2*(VAR_16[2*1] + VAR_16[2*5]), C1);",
"VAR_9 = MULH( VAR_16[2*5] - VAR_16[2*7] , -2*C7);",
"VAR_6 = MULH(2*VAR_16[2*3], C3);",
"VAR_7 = MULH(2*(VAR_16[2*1] + VAR_16[2*7]), -C5);",
"VAR_15[ 0] = VAR_8 + VAR_9 + VAR_6;",
"VAR_15[12] = VAR_8 + VAR_7 - VAR_6;",
"VAR_15[ 8] = VAR_9 - VAR_7 - VAR_6;",
"#endif\n}",
"VAR_4 = 0;",
"for(VAR_5=0;VAR_5<4;VAR_5++) {",
"VAR_6 = VAR_14[VAR_4];",
"VAR_7 = VAR_14[VAR_4 + 2];",
"VAR_10 = VAR_7 + VAR_6;",
"VAR_12 = VAR_7 - VAR_6;",
"VAR_8 = VAR_14[VAR_4 + 1];",
"VAR_9 = VAR_14[VAR_4 + 3];",
"VAR_11 = MULL(VAR_9 + VAR_8, icos36[VAR_5]);",
"VAR_13 = MULL(VAR_9 - VAR_8, icos36[8 - VAR_5]);",
"VAR_6 = (VAR_10 + VAR_11) << 5;",
"VAR_7 = (VAR_10 - VAR_11) << 5;",
"VAR_0[(9 + VAR_5)*SBLIMIT] = MULH(VAR_7, VAR_3[9 + VAR_5]) + VAR_1[9 + VAR_5];",
"VAR_0[(8 - VAR_5)*SBLIMIT] = MULH(VAR_7, VAR_3[8 - VAR_5]) + VAR_1[8 - VAR_5];",
"VAR_1[9 + VAR_5] = MULH(VAR_6, VAR_3[18 + 9 + VAR_5]);",
"VAR_1[8 - VAR_5] = MULH(VAR_6, VAR_3[18 + 8 - VAR_5]);",
"VAR_6 = (VAR_12 + VAR_13) << 5;",
"VAR_7 = (VAR_12 - VAR_13) << 5;",
"VAR_0[(9 + 8 - VAR_5)*SBLIMIT] = MULH(VAR_7, VAR_3[9 + 8 - VAR_5]) + VAR_1[9 + 8 - VAR_5];",
"VAR_0[( VAR_5)*SBLIMIT] = MULH(VAR_7, VAR_3[ VAR_5]) + VAR_1[ VAR_5];",
"VAR_1[9 + 8 - VAR_5] = MULH(VAR_6, VAR_3[18 + 9 + 8 - VAR_5]);",
"VAR_1[ + VAR_5] = MULH(VAR_6, VAR_3[18 + VAR_5]);",
"VAR_4 += 4;",
"}",
"VAR_10 = VAR_14[16];",
"VAR_11 = MULL(VAR_14[17], icos36[4]);",
"VAR_6 = (VAR_10 + VAR_11) << 5;",
"VAR_7 = (VAR_10 - VAR_11) << 5;",
"VAR_0[(9 + 4)*SBLIMIT] = MULH(VAR_7, VAR_3[9 + 4]) + VAR_1[9 + 4];",
"VAR_0[(8 - 4)*SBLIMIT] = MULH(VAR_7, VAR_3[8 - 4]) + VAR_1[8 - 4];",
"VAR_1[9 + 4] = MULH(VAR_6, VAR_3[18 + 9 + 4]);",
"VAR_1[8 - 4] = MULH(VAR_6, VAR_3[18 + 8 - 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,
1,
1,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27,
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83,
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135,
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
]
]
|
13,697 | static void test_tco_second_timeout_none(void)
{
TestData td;
const uint16_t ticks = TCO_SECS_TO_TICKS(256);
QDict *ad;
td.args = "-watchdog-action none";
td.noreboot = false;
test_init(&td);
stop_tco(&td);
clear_tco_status(&td);
reset_on_second_timeout(true);
set_tco_timeout(&td, ticks);
load_tco(&td);
start_tco(&td);
clock_step(ticks * TCO_TICK_NSEC * 2);
ad = get_watchdog_action();
g_assert(!strcmp(qdict_get_str(ad, "action"), "none"));
QDECREF(ad);
stop_tco(&td);
qtest_end();
}
| true | qemu | 34779e8c3991f7fcd74b2045478abcef67dbeb15 | static void test_tco_second_timeout_none(void)
{
TestData td;
const uint16_t ticks = TCO_SECS_TO_TICKS(256);
QDict *ad;
td.args = "-watchdog-action none";
td.noreboot = false;
test_init(&td);
stop_tco(&td);
clear_tco_status(&td);
reset_on_second_timeout(true);
set_tco_timeout(&td, ticks);
load_tco(&td);
start_tco(&td);
clock_step(ticks * TCO_TICK_NSEC * 2);
ad = get_watchdog_action();
g_assert(!strcmp(qdict_get_str(ad, "action"), "none"));
QDECREF(ad);
stop_tco(&td);
qtest_end();
}
| {
"code": [
" qtest_end();",
" qtest_end();",
" qtest_end();",
" qtest_end();",
" qtest_end();",
" qtest_end();",
" qtest_end();",
" qtest_end();",
" qtest_end();",
" qtest_end();",
" qtest_end();"
],
"line_no": [
45,
45,
45,
45,
45,
45,
45,
45,
45,
45,
45
]
} | static void FUNC_0(void)
{
TestData td;
const uint16_t VAR_0 = TCO_SECS_TO_TICKS(256);
QDict *ad;
td.args = "-watchdog-action none";
td.noreboot = false;
test_init(&td);
stop_tco(&td);
clear_tco_status(&td);
reset_on_second_timeout(true);
set_tco_timeout(&td, VAR_0);
load_tco(&td);
start_tco(&td);
clock_step(VAR_0 * TCO_TICK_NSEC * 2);
ad = get_watchdog_action();
g_assert(!strcmp(qdict_get_str(ad, "action"), "none"));
QDECREF(ad);
stop_tco(&td);
qtest_end();
}
| [
"static void FUNC_0(void)\n{",
"TestData td;",
"const uint16_t VAR_0 = TCO_SECS_TO_TICKS(256);",
"QDict *ad;",
"td.args = \"-watchdog-action none\";",
"td.noreboot = false;",
"test_init(&td);",
"stop_tco(&td);",
"clear_tco_status(&td);",
"reset_on_second_timeout(true);",
"set_tco_timeout(&td, VAR_0);",
"load_tco(&td);",
"start_tco(&td);",
"clock_step(VAR_0 * TCO_TICK_NSEC * 2);",
"ad = get_watchdog_action();",
"g_assert(!strcmp(qdict_get_str(ad, \"action\"), \"none\"));",
"QDECREF(ad);",
"stop_tco(&td);",
"qtest_end();",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
]
]
|
13,698 | static void pcx_palette(const uint8_t **src, uint32_t *dst,
unsigned int pallen)
{
unsigned int i;
for (i = 0; i < pallen; i++)
*dst++ = bytestream_get_be24(src);
if (pallen < 256)
memset(dst, 0, (256 - pallen) * sizeof(*dst));
}
| true | FFmpeg | 09b23786b3986502ee88d4907356979127169bdd | static void pcx_palette(const uint8_t **src, uint32_t *dst,
unsigned int pallen)
{
unsigned int i;
for (i = 0; i < pallen; i++)
*dst++ = bytestream_get_be24(src);
if (pallen < 256)
memset(dst, 0, (256 - pallen) * sizeof(*dst));
}
| {
"code": [
"static void pcx_palette(const uint8_t **src, uint32_t *dst,",
" *dst++ = bytestream_get_be24(src);"
],
"line_no": [
1,
13
]
} | static void FUNC_0(const uint8_t **VAR_0, uint32_t *VAR_1,
unsigned int VAR_2)
{
unsigned int VAR_3;
for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++)
*VAR_1++ = bytestream_get_be24(VAR_0);
if (VAR_2 < 256)
memset(VAR_1, 0, (256 - VAR_2) * sizeof(*VAR_1));
}
| [
"static void FUNC_0(const uint8_t **VAR_0, uint32_t *VAR_1,\nunsigned int VAR_2)\n{",
"unsigned int VAR_3;",
"for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++)",
"*VAR_1++ = bytestream_get_be24(VAR_0);",
"if (VAR_2 < 256)\nmemset(VAR_1, 0, (256 - VAR_2) * sizeof(*VAR_1));",
"}"
]
| [
1,
0,
0,
1,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15,
17
],
[
19
]
]
|
13,699 | int qemu_set_fd_handler2(int fd,
IOCanReadHandler *fd_read_poll,
IOHandler *fd_read,
IOHandler *fd_write,
void *opaque)
{
IOHandlerRecord *ioh;
if (!fd_read && !fd_write) {
QLIST_FOREACH(ioh, &io_handlers, next) {
if (ioh->fd == fd) {
ioh->deleted = 1;
break;
}
}
} else {
QLIST_FOREACH(ioh, &io_handlers, next) {
if (ioh->fd == fd)
goto found;
}
ioh = g_malloc0(sizeof(IOHandlerRecord));
QLIST_INSERT_HEAD(&io_handlers, ioh, next);
found:
ioh->fd = fd;
ioh->fd_read_poll = fd_read_poll;
ioh->fd_read = fd_read;
ioh->fd_write = fd_write;
ioh->opaque = opaque;
ioh->deleted = 0;
qemu_notify_event();
}
return 0;
} | true | qemu | bbdd2ad0814ea0911076419ea21b7957505cf1cc | int qemu_set_fd_handler2(int fd,
IOCanReadHandler *fd_read_poll,
IOHandler *fd_read,
IOHandler *fd_write,
void *opaque)
{
IOHandlerRecord *ioh;
if (!fd_read && !fd_write) {
QLIST_FOREACH(ioh, &io_handlers, next) {
if (ioh->fd == fd) {
ioh->deleted = 1;
break;
}
}
} else {
QLIST_FOREACH(ioh, &io_handlers, next) {
if (ioh->fd == fd)
goto found;
}
ioh = g_malloc0(sizeof(IOHandlerRecord));
QLIST_INSERT_HEAD(&io_handlers, ioh, next);
found:
ioh->fd = fd;
ioh->fd_read_poll = fd_read_poll;
ioh->fd_read = fd_read;
ioh->fd_write = fd_write;
ioh->opaque = opaque;
ioh->deleted = 0;
qemu_notify_event();
}
return 0;
} | {
"code": [],
"line_no": []
} | int FUNC_0(int VAR_0,
IOCanReadHandler *VAR_1,
IOHandler *VAR_2,
IOHandler *VAR_3,
void *VAR_4)
{
IOHandlerRecord *ioh;
if (!VAR_2 && !VAR_3) {
QLIST_FOREACH(ioh, &io_handlers, next) {
if (ioh->VAR_0 == VAR_0) {
ioh->deleted = 1;
break;
}
}
} else {
QLIST_FOREACH(ioh, &io_handlers, next) {
if (ioh->VAR_0 == VAR_0)
goto found;
}
ioh = g_malloc0(sizeof(IOHandlerRecord));
QLIST_INSERT_HEAD(&io_handlers, ioh, next);
found:
ioh->VAR_0 = VAR_0;
ioh->VAR_1 = VAR_1;
ioh->VAR_2 = VAR_2;
ioh->VAR_3 = VAR_3;
ioh->VAR_4 = VAR_4;
ioh->deleted = 0;
qemu_notify_event();
}
return 0;
} | [
"int FUNC_0(int VAR_0,\nIOCanReadHandler *VAR_1,\nIOHandler *VAR_2,\nIOHandler *VAR_3,\nvoid *VAR_4)\n{",
"IOHandlerRecord *ioh;",
"if (!VAR_2 && !VAR_3) {",
"QLIST_FOREACH(ioh, &io_handlers, next) {",
"if (ioh->VAR_0 == VAR_0) {",
"ioh->deleted = 1;",
"break;",
"}",
"}",
"} else {",
"QLIST_FOREACH(ioh, &io_handlers, next) {",
"if (ioh->VAR_0 == VAR_0)\ngoto found;",
"}",
"ioh = g_malloc0(sizeof(IOHandlerRecord));",
"QLIST_INSERT_HEAD(&io_handlers, ioh, next);",
"found:\nioh->VAR_0 = VAR_0;",
"ioh->VAR_1 = VAR_1;",
"ioh->VAR_2 = VAR_2;",
"ioh->VAR_3 = VAR_3;",
"ioh->VAR_4 = VAR_4;",
"ioh->deleted = 0;",
"qemu_notify_event();",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
2,
3,
4,
5,
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
17,
18
],
[
19
],
[
20
],
[
21
],
[
22,
23
],
[
24
],
[
25
],
[
26
],
[
27
],
[
28
],
[
29
],
[
30
],
[
31
],
[
32
]
]
|
13,700 | static int bdrv_prwv_co(BdrvChild *child, int64_t offset,
QEMUIOVector *qiov, bool is_write,
BdrvRequestFlags flags)
{
Coroutine *co;
RwCo rwco = {
.child = child,
.offset = offset,
.qiov = qiov,
.is_write = is_write,
.ret = NOT_DONE,
.flags = flags,
};
if (qemu_in_coroutine()) {
/* Fast-path if already in coroutine context */
bdrv_rw_co_entry(&rwco);
} else {
AioContext *aio_context = bdrv_get_aio_context(child->bs);
co = qemu_coroutine_create(bdrv_rw_co_entry);
qemu_coroutine_enter(co, &rwco);
while (rwco.ret == NOT_DONE) {
aio_poll(aio_context, true);
}
}
return rwco.ret;
}
| true | qemu | 0b8b8753e4d94901627b3e86431230f2319215c4 | static int bdrv_prwv_co(BdrvChild *child, int64_t offset,
QEMUIOVector *qiov, bool is_write,
BdrvRequestFlags flags)
{
Coroutine *co;
RwCo rwco = {
.child = child,
.offset = offset,
.qiov = qiov,
.is_write = is_write,
.ret = NOT_DONE,
.flags = flags,
};
if (qemu_in_coroutine()) {
bdrv_rw_co_entry(&rwco);
} else {
AioContext *aio_context = bdrv_get_aio_context(child->bs);
co = qemu_coroutine_create(bdrv_rw_co_entry);
qemu_coroutine_enter(co, &rwco);
while (rwco.ret == NOT_DONE) {
aio_poll(aio_context, true);
}
}
return rwco.ret;
}
| {
"code": [
" co = qemu_coroutine_create(bdrv_rw_co_entry);",
" qemu_coroutine_enter(co, &rwco);",
" qemu_coroutine_enter(co, &rwco);"
],
"line_no": [
41,
43,
43
]
} | static int FUNC_0(BdrvChild *VAR_0, int64_t VAR_1,
QEMUIOVector *VAR_2, bool VAR_3,
BdrvRequestFlags VAR_4)
{
Coroutine *co;
RwCo rwco = {
.VAR_0 = VAR_0,
.VAR_1 = VAR_1,
.VAR_2 = VAR_2,
.VAR_3 = VAR_3,
.ret = NOT_DONE,
.VAR_4 = VAR_4,
};
if (qemu_in_coroutine()) {
bdrv_rw_co_entry(&rwco);
} else {
AioContext *aio_context = bdrv_get_aio_context(VAR_0->bs);
co = qemu_coroutine_create(bdrv_rw_co_entry);
qemu_coroutine_enter(co, &rwco);
while (rwco.ret == NOT_DONE) {
aio_poll(aio_context, true);
}
}
return rwco.ret;
}
| [
"static int FUNC_0(BdrvChild *VAR_0, int64_t VAR_1,\nQEMUIOVector *VAR_2, bool VAR_3,\nBdrvRequestFlags VAR_4)\n{",
"Coroutine *co;",
"RwCo rwco = {",
".VAR_0 = VAR_0,\n.VAR_1 = VAR_1,\n.VAR_2 = VAR_2,\n.VAR_3 = VAR_3,\n.ret = NOT_DONE,\n.VAR_4 = VAR_4,\n};",
"if (qemu_in_coroutine()) {",
"bdrv_rw_co_entry(&rwco);",
"} else {",
"AioContext *aio_context = bdrv_get_aio_context(VAR_0->bs);",
"co = qemu_coroutine_create(bdrv_rw_co_entry);",
"qemu_coroutine_enter(co, &rwco);",
"while (rwco.ret == NOT_DONE) {",
"aio_poll(aio_context, true);",
"}",
"}",
"return rwco.ret;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13,
15,
17,
19,
21,
23,
25
],
[
29
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
]
]
|
13,701 | static void setup_frame(int sig, struct target_sigaction *ka,
target_sigset_t *set, CPUM68KState *env)
{
struct target_sigframe *frame;
abi_ulong frame_addr;
abi_ulong retcode_addr;
abi_ulong sc_addr;
int err = 0;
int i;
frame_addr = get_sigframe(ka, env, sizeof *frame);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
goto give_sigsegv;
__put_user(sig, &frame->sig);
sc_addr = frame_addr + offsetof(struct target_sigframe, sc);
__put_user(sc_addr, &frame->psc);
setup_sigcontext(&frame->sc, env, set->sig[0]);
for(i = 1; i < TARGET_NSIG_WORDS; i++) {
if (__put_user(set->sig[i], &frame->extramask[i - 1]))
goto give_sigsegv;
}
/* Set up to return from userspace. */
retcode_addr = frame_addr + offsetof(struct target_sigframe, retcode);
__put_user(retcode_addr, &frame->pretcode);
/* moveq #,d0; trap #0 */
__put_user(0x70004e40 + (TARGET_NR_sigreturn << 16),
(long *)(frame->retcode));
if (err)
goto give_sigsegv;
/* Set up to return from userspace */
env->aregs[7] = frame_addr;
env->pc = ka->_sa_handler;
unlock_user_struct(frame, frame_addr, 1);
return;
give_sigsegv:
unlock_user_struct(frame, frame_addr, 1);
force_sig(TARGET_SIGSEGV);
}
| true | qemu | 0188fadb7fe460d8c4c743372b1f7b25773e183e | static void setup_frame(int sig, struct target_sigaction *ka,
target_sigset_t *set, CPUM68KState *env)
{
struct target_sigframe *frame;
abi_ulong frame_addr;
abi_ulong retcode_addr;
abi_ulong sc_addr;
int err = 0;
int i;
frame_addr = get_sigframe(ka, env, sizeof *frame);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
goto give_sigsegv;
__put_user(sig, &frame->sig);
sc_addr = frame_addr + offsetof(struct target_sigframe, sc);
__put_user(sc_addr, &frame->psc);
setup_sigcontext(&frame->sc, env, set->sig[0]);
for(i = 1; i < TARGET_NSIG_WORDS; i++) {
if (__put_user(set->sig[i], &frame->extramask[i - 1]))
goto give_sigsegv;
}
retcode_addr = frame_addr + offsetof(struct target_sigframe, retcode);
__put_user(retcode_addr, &frame->pretcode);
__put_user(0x70004e40 + (TARGET_NR_sigreturn << 16),
(long *)(frame->retcode));
if (err)
goto give_sigsegv;
env->aregs[7] = frame_addr;
env->pc = ka->_sa_handler;
unlock_user_struct(frame, frame_addr, 1);
return;
give_sigsegv:
unlock_user_struct(frame, frame_addr, 1);
force_sig(TARGET_SIGSEGV);
}
| {
"code": [
" unlock_user_struct(frame, frame_addr, 1);",
" int err = 0;",
" if (err)",
" if (__put_user(set->sig[i], &frame->extramask[i - 1]))",
" if (err)",
" unlock_user_struct(frame, frame_addr, 1);",
" goto give_sigsegv;",
" goto give_sigsegv;",
" unlock_user_struct(frame, frame_addr, 1);",
" goto give_sigsegv;",
" goto give_sigsegv;",
" unlock_user_struct(frame, frame_addr, 1);",
" int err = 0;",
" if (__put_user(set->sig[i], &frame->extramask[i - 1]))",
" goto give_sigsegv;",
" if (err)",
" goto give_sigsegv;",
" unlock_user_struct(frame, frame_addr, 1);",
" goto give_sigsegv;"
],
"line_no": [
89,
15,
73,
45,
73,
89,
47,
47,
89,
47,
75,
89,
15,
45,
47,
73,
75,
89,
47
]
} | static void FUNC_0(int VAR_0, struct target_sigaction *VAR_1,
target_sigset_t *VAR_2, CPUM68KState *VAR_3)
{
struct target_sigframe *VAR_4;
abi_ulong frame_addr;
abi_ulong retcode_addr;
abi_ulong sc_addr;
int VAR_5 = 0;
int VAR_6;
frame_addr = get_sigframe(VAR_1, VAR_3, sizeof *VAR_4);
if (!lock_user_struct(VERIFY_WRITE, VAR_4, frame_addr, 0))
goto give_sigsegv;
__put_user(VAR_0, &VAR_4->VAR_0);
sc_addr = frame_addr + offsetof(struct target_sigframe, sc);
__put_user(sc_addr, &VAR_4->psc);
setup_sigcontext(&VAR_4->sc, VAR_3, VAR_2->VAR_0[0]);
for(VAR_6 = 1; VAR_6 < TARGET_NSIG_WORDS; VAR_6++) {
if (__put_user(VAR_2->VAR_0[VAR_6], &VAR_4->extramask[VAR_6 - 1]))
goto give_sigsegv;
}
retcode_addr = frame_addr + offsetof(struct target_sigframe, retcode);
__put_user(retcode_addr, &VAR_4->pretcode);
__put_user(0x70004e40 + (TARGET_NR_sigreturn << 16),
(long *)(VAR_4->retcode));
if (VAR_5)
goto give_sigsegv;
VAR_3->aregs[7] = frame_addr;
VAR_3->pc = VAR_1->_sa_handler;
unlock_user_struct(VAR_4, frame_addr, 1);
return;
give_sigsegv:
unlock_user_struct(VAR_4, frame_addr, 1);
force_sig(TARGET_SIGSEGV);
}
| [
"static void FUNC_0(int VAR_0, struct target_sigaction *VAR_1,\ntarget_sigset_t *VAR_2, CPUM68KState *VAR_3)\n{",
"struct target_sigframe *VAR_4;",
"abi_ulong frame_addr;",
"abi_ulong retcode_addr;",
"abi_ulong sc_addr;",
"int VAR_5 = 0;",
"int VAR_6;",
"frame_addr = get_sigframe(VAR_1, VAR_3, sizeof *VAR_4);",
"if (!lock_user_struct(VERIFY_WRITE, VAR_4, frame_addr, 0))\ngoto give_sigsegv;",
"__put_user(VAR_0, &VAR_4->VAR_0);",
"sc_addr = frame_addr + offsetof(struct target_sigframe, sc);",
"__put_user(sc_addr, &VAR_4->psc);",
"setup_sigcontext(&VAR_4->sc, VAR_3, VAR_2->VAR_0[0]);",
"for(VAR_6 = 1; VAR_6 < TARGET_NSIG_WORDS; VAR_6++) {",
"if (__put_user(VAR_2->VAR_0[VAR_6], &VAR_4->extramask[VAR_6 - 1]))\ngoto give_sigsegv;",
"}",
"retcode_addr = frame_addr + offsetof(struct target_sigframe, retcode);",
"__put_user(retcode_addr, &VAR_4->pretcode);",
"__put_user(0x70004e40 + (TARGET_NR_sigreturn << 16),\n(long *)(VAR_4->retcode));",
"if (VAR_5)\ngoto give_sigsegv;",
"VAR_3->aregs[7] = frame_addr;",
"VAR_3->pc = VAR_1->_sa_handler;",
"unlock_user_struct(VAR_4, frame_addr, 1);",
"return;",
"give_sigsegv:\nunlock_user_struct(VAR_4, frame_addr, 1);",
"force_sig(TARGET_SIGSEGV);",
"}"
]
| [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23,
25
],
[
29
],
[
33
],
[
35
],
[
39
],
[
43
],
[
45,
47
],
[
49
],
[
57
],
[
59
],
[
67,
69
],
[
73,
75
],
[
83
],
[
85
],
[
89
],
[
91
],
[
95,
97
],
[
99
],
[
101
]
]
|
13,702 | static void openrisc_cpu_realizefn(DeviceState *dev, Error **errp)
{
OpenRISCCPU *cpu = OPENRISC_CPU(dev);
OpenRISCCPUClass *occ = OPENRISC_CPU_GET_CLASS(dev);
cpu_reset(CPU(cpu));
occ->parent_realize(dev, errp);
}
| true | qemu | 14a10fc39923b3af07c8c46d22cb20843bee3a72 | static void openrisc_cpu_realizefn(DeviceState *dev, Error **errp)
{
OpenRISCCPU *cpu = OPENRISC_CPU(dev);
OpenRISCCPUClass *occ = OPENRISC_CPU_GET_CLASS(dev);
cpu_reset(CPU(cpu));
occ->parent_realize(dev, errp);
}
| {
"code": [
" cpu_reset(CPU(cpu));",
" cpu_reset(CPU(cpu));",
" cpu_reset(CPU(cpu));",
" cpu_reset(CPU(cpu));",
" cpu_reset(CPU(cpu));",
" cpu_reset(CPU(cpu));",
" cpu_reset(CPU(cpu));",
" cpu_reset(CPU(cpu));",
" OpenRISCCPU *cpu = OPENRISC_CPU(dev);",
" cpu_reset(CPU(cpu));",
" cpu_reset(CPU(cpu));",
" cpu_reset(CPU(cpu));"
],
"line_no": [
11,
11,
11,
11,
11,
11,
11,
11,
5,
11,
11,
11
]
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
OpenRISCCPU *cpu = OPENRISC_CPU(VAR_0);
OpenRISCCPUClass *occ = OPENRISC_CPU_GET_CLASS(VAR_0);
cpu_reset(CPU(cpu));
occ->parent_realize(VAR_0, VAR_1);
}
| [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"OpenRISCCPU *cpu = OPENRISC_CPU(VAR_0);",
"OpenRISCCPUClass *occ = OPENRISC_CPU_GET_CLASS(VAR_0);",
"cpu_reset(CPU(cpu));",
"occ->parent_realize(VAR_0, VAR_1);",
"}"
]
| [
0,
1,
0,
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
]
]
|
13,703 | void net_rx_pkt_attach_iovec(struct NetRxPkt *pkt,
const struct iovec *iov, int iovcnt,
size_t iovoff, bool strip_vlan)
{
uint16_t tci = 0;
uint16_t ploff = iovoff;
assert(pkt);
pkt->vlan_stripped = false;
if (strip_vlan) {
pkt->vlan_stripped = eth_strip_vlan(iov, iovcnt, iovoff, pkt->ehdr_buf,
&ploff, &tci);
}
pkt->tci = tci;
net_rx_pkt_pull_data(pkt, iov, iovcnt, ploff);
}
| true | qemu | df8bf7a7fe75eb5d5caffa55f5cd4292b757aea6 | void net_rx_pkt_attach_iovec(struct NetRxPkt *pkt,
const struct iovec *iov, int iovcnt,
size_t iovoff, bool strip_vlan)
{
uint16_t tci = 0;
uint16_t ploff = iovoff;
assert(pkt);
pkt->vlan_stripped = false;
if (strip_vlan) {
pkt->vlan_stripped = eth_strip_vlan(iov, iovcnt, iovoff, pkt->ehdr_buf,
&ploff, &tci);
}
pkt->tci = tci;
net_rx_pkt_pull_data(pkt, iov, iovcnt, ploff);
}
| {
"code": [
" pkt->vlan_stripped = false;",
" pkt->vlan_stripped = eth_strip_vlan(iov, iovcnt, iovoff, pkt->ehdr_buf,",
" &ploff, &tci);",
" pkt->vlan_stripped = false;"
],
"line_no": [
15,
21,
23,
15
]
} | void FUNC_0(struct NetRxPkt *VAR_0,
const struct iovec *VAR_1, int VAR_2,
size_t VAR_3, bool VAR_4)
{
uint16_t tci = 0;
uint16_t ploff = VAR_3;
assert(VAR_0);
VAR_0->vlan_stripped = false;
if (VAR_4) {
VAR_0->vlan_stripped = eth_strip_vlan(VAR_1, VAR_2, VAR_3, VAR_0->ehdr_buf,
&ploff, &tci);
}
VAR_0->tci = tci;
net_rx_pkt_pull_data(VAR_0, VAR_1, VAR_2, ploff);
}
| [
"void FUNC_0(struct NetRxPkt *VAR_0,\nconst struct iovec *VAR_1, int VAR_2,\nsize_t VAR_3, bool VAR_4)\n{",
"uint16_t tci = 0;",
"uint16_t ploff = VAR_3;",
"assert(VAR_0);",
"VAR_0->vlan_stripped = false;",
"if (VAR_4) {",
"VAR_0->vlan_stripped = eth_strip_vlan(VAR_1, VAR_2, VAR_3, VAR_0->ehdr_buf,\n&ploff, &tci);",
"}",
"VAR_0->tci = tci;",
"net_rx_pkt_pull_data(VAR_0, VAR_1, VAR_2, ploff);",
"}"
]
| [
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21,
23
],
[
25
],
[
29
],
[
33
],
[
35
]
]
|
13,704 | static inline void RENAME(yuy2ToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused)
{
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(
"movq "MANGLE(bm01010101)", %%mm4 \n\t"
"mov %0, %%"REG_a" \n\t"
"1: \n\t"
"movq (%1, %%"REG_a",4), %%mm0 \n\t"
"movq 8(%1, %%"REG_a",4), %%mm1 \n\t"
"psrlw $8, %%mm0 \n\t"
"psrlw $8, %%mm1 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"movq %%mm0, %%mm1 \n\t"
"psrlw $8, %%mm0 \n\t"
"pand %%mm4, %%mm1 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"packuswb %%mm1, %%mm1 \n\t"
"movd %%mm0, (%3, %%"REG_a") \n\t"
"movd %%mm1, (%2, %%"REG_a") \n\t"
"add $4, %%"REG_a" \n\t"
" js 1b \n\t"
: : "g" ((x86_reg)-width), "r" (src1+width*4), "r" (dstU+width), "r" (dstV+width)
: "%"REG_a
);
#else
int i;
for (i=0; i<width; i++) {
dstU[i]= src1[4*i + 1];
dstV[i]= src1[4*i + 3];
}
#endif
assert(src1 == src2);
}
| true | FFmpeg | c3ab0004ae4dffc32494ae84dd15cfaa909a7884 | static inline void RENAME(yuy2ToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused)
{
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(
"movq "MANGLE(bm01010101)", %%mm4 \n\t"
"mov %0, %%"REG_a" \n\t"
"1: \n\t"
"movq (%1, %%"REG_a",4), %%mm0 \n\t"
"movq 8(%1, %%"REG_a",4), %%mm1 \n\t"
"psrlw $8, %%mm0 \n\t"
"psrlw $8, %%mm1 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"movq %%mm0, %%mm1 \n\t"
"psrlw $8, %%mm0 \n\t"
"pand %%mm4, %%mm1 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"packuswb %%mm1, %%mm1 \n\t"
"movd %%mm0, (%3, %%"REG_a") \n\t"
"movd %%mm1, (%2, %%"REG_a") \n\t"
"add $4, %%"REG_a" \n\t"
" js 1b \n\t"
: : "g" ((x86_reg)-width), "r" (src1+width*4), "r" (dstU+width), "r" (dstV+width)
: "%"REG_a
);
#else
int i;
for (i=0; i<width; i++) {
dstU[i]= src1[4*i + 1];
dstV[i]= src1[4*i + 3];
}
#endif
assert(src1 == src2);
}
| {
"code": [
"static inline void RENAME(yuy2ToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused)"
],
"line_no": [
1
]
} | static inline void FUNC_0(yuy2ToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused)
{
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(
"movq "MANGLE(bm01010101)", %%mm4 \n\t"
"mov %0, %%"REG_a" \n\t"
"1: \n\t"
"movq (%1, %%"REG_a",4), %%mm0 \n\t"
"movq 8(%1, %%"REG_a",4), %%mm1 \n\t"
"psrlw $8, %%mm0 \n\t"
"psrlw $8, %%mm1 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"movq %%mm0, %%mm1 \n\t"
"psrlw $8, %%mm0 \n\t"
"pand %%mm4, %%mm1 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"packuswb %%mm1, %%mm1 \n\t"
"movd %%mm0, (%3, %%"REG_a") \n\t"
"movd %%mm1, (%2, %%"REG_a") \n\t"
"add $4, %%"REG_a" \n\t"
" js 1b \n\t"
: : "g" ((x86_reg)-width), "r" (src1+width*4), "r" (dstU+width), "r" (dstV+width)
: "%"REG_a
);
#else
int VAR_0;
for (VAR_0=0; VAR_0<width; VAR_0++) {
dstU[VAR_0]= src1[4*VAR_0 + 1];
dstV[VAR_0]= src1[4*VAR_0 + 3];
}
#endif
assert(src1 == src2);
}
| [
"static inline void FUNC_0(yuy2ToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused)\n{",
"#if COMPILE_TEMPLATE_MMX\n__asm__ volatile(\n\"movq \"MANGLE(bm01010101)\", %%mm4 \\n\\t\"\n\"mov %0, %%\"REG_a\" \\n\\t\"\n\"1: \\n\\t\"\n\"movq (%1, %%\"REG_a\",4), %%mm0 \\n\\t\"\n\"movq 8(%1, %%\"REG_a\",4), %%mm1 \\n\\t\"\n\"psrlw $8, %%mm0 \\n\\t\"\n\"psrlw $8, %%mm1 \\n\\t\"\n\"packuswb %%mm1, %%mm0 \\n\\t\"\n\"movq %%mm0, %%mm1 \\n\\t\"\n\"psrlw $8, %%mm0 \\n\\t\"\n\"pand %%mm4, %%mm1 \\n\\t\"\n\"packuswb %%mm0, %%mm0 \\n\\t\"\n\"packuswb %%mm1, %%mm1 \\n\\t\"\n\"movd %%mm0, (%3, %%\"REG_a\") \\n\\t\"\n\"movd %%mm1, (%2, %%\"REG_a\") \\n\\t\"\n\"add $4, %%\"REG_a\" \\n\\t\"\n\" js 1b \\n\\t\"\n: : \"g\" ((x86_reg)-width), \"r\" (src1+width*4), \"r\" (dstU+width), \"r\" (dstV+width)\n: \"%\"REG_a\n);",
"#else\nint VAR_0;",
"for (VAR_0=0; VAR_0<width; VAR_0++) {",
"dstU[VAR_0]= src1[4*VAR_0 + 1];",
"dstV[VAR_0]= src1[4*VAR_0 + 3];",
"}",
"#endif\nassert(src1 == src2);",
"}"
]
| [
1,
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
]
]
|
13,705 | static void qemu_rbd_complete_aio(RADOSCB *rcb)
{
RBDAIOCB *acb = rcb->acb;
int64_t r;
r = rcb->ret;
if (acb->cmd != RBD_AIO_READ) {
if (r < 0) {
acb->ret = r;
acb->error = 1;
} else if (!acb->error) {
acb->ret = rcb->size;
}
} else {
if (r < 0) {
memset(rcb->buf, 0, rcb->size);
acb->ret = r;
acb->error = 1;
} else if (r < rcb->size) {
memset(rcb->buf + r, 0, rcb->size - r);
if (!acb->error) {
acb->ret = rcb->size;
}
} else if (!acb->error) {
acb->ret = r;
}
}
/* Note that acb->bh can be NULL in case where the aio was cancelled */
acb->bh = qemu_bh_new(rbd_aio_bh_cb, acb);
qemu_bh_schedule(acb->bh);
g_free(rcb);
}
| true | qemu | e04fb07fd1676e9facd7f3f878c1bbe03bccd26b | static void qemu_rbd_complete_aio(RADOSCB *rcb)
{
RBDAIOCB *acb = rcb->acb;
int64_t r;
r = rcb->ret;
if (acb->cmd != RBD_AIO_READ) {
if (r < 0) {
acb->ret = r;
acb->error = 1;
} else if (!acb->error) {
acb->ret = rcb->size;
}
} else {
if (r < 0) {
memset(rcb->buf, 0, rcb->size);
acb->ret = r;
acb->error = 1;
} else if (r < rcb->size) {
memset(rcb->buf + r, 0, rcb->size - r);
if (!acb->error) {
acb->ret = rcb->size;
}
} else if (!acb->error) {
acb->ret = r;
}
}
acb->bh = qemu_bh_new(rbd_aio_bh_cb, acb);
qemu_bh_schedule(acb->bh);
g_free(rcb);
}
| {
"code": [
" acb->bh = qemu_bh_new(rbd_aio_bh_cb, acb);",
" qemu_bh_schedule(acb->bh);",
" g_free(rcb);"
],
"line_no": [
59,
61,
63
]
} | static void FUNC_0(RADOSCB *VAR_0)
{
RBDAIOCB *acb = VAR_0->acb;
int64_t r;
r = VAR_0->ret;
if (acb->cmd != RBD_AIO_READ) {
if (r < 0) {
acb->ret = r;
acb->error = 1;
} else if (!acb->error) {
acb->ret = VAR_0->size;
}
} else {
if (r < 0) {
memset(VAR_0->buf, 0, VAR_0->size);
acb->ret = r;
acb->error = 1;
} else if (r < VAR_0->size) {
memset(VAR_0->buf + r, 0, VAR_0->size - r);
if (!acb->error) {
acb->ret = VAR_0->size;
}
} else if (!acb->error) {
acb->ret = r;
}
}
acb->bh = qemu_bh_new(rbd_aio_bh_cb, acb);
qemu_bh_schedule(acb->bh);
g_free(VAR_0);
}
| [
"static void FUNC_0(RADOSCB *VAR_0)\n{",
"RBDAIOCB *acb = VAR_0->acb;",
"int64_t r;",
"r = VAR_0->ret;",
"if (acb->cmd != RBD_AIO_READ) {",
"if (r < 0) {",
"acb->ret = r;",
"acb->error = 1;",
"} else if (!acb->error) {",
"acb->ret = VAR_0->size;",
"}",
"} else {",
"if (r < 0) {",
"memset(VAR_0->buf, 0, VAR_0->size);",
"acb->ret = r;",
"acb->error = 1;",
"} else if (r < VAR_0->size) {",
"memset(VAR_0->buf + r, 0, VAR_0->size - r);",
"if (!acb->error) {",
"acb->ret = VAR_0->size;",
"}",
"} else if (!acb->error) {",
"acb->ret = r;",
"}",
"}",
"acb->bh = qemu_bh_new(rbd_aio_bh_cb, acb);",
"qemu_bh_schedule(acb->bh);",
"g_free(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,
1,
1,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
]
]
|
13,707 | static void scsi_disk_set_sense(SCSIDiskState *s, uint8_t key)
{
s->sense.key = key;
}
| true | qemu | a1f0cce2ac0243572ff72aa561da67fe3766a395 | static void scsi_disk_set_sense(SCSIDiskState *s, uint8_t key)
{
s->sense.key = key;
}
| {
"code": [
"static void scsi_disk_set_sense(SCSIDiskState *s, uint8_t key)",
" s->sense.key = key;"
],
"line_no": [
1,
5
]
} | static void FUNC_0(SCSIDiskState *VAR_0, uint8_t VAR_1)
{
VAR_0->sense.VAR_1 = VAR_1;
}
| [
"static void FUNC_0(SCSIDiskState *VAR_0, uint8_t VAR_1)\n{",
"VAR_0->sense.VAR_1 = VAR_1;",
"}"
]
| [
1,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.