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
11,323
static void sysctl_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { MilkymistSysctlState *s = opaque; trace_milkymist_sysctl_memory_write(addr, value); addr >>= 2; switch (addr) { case R_GPIO_OUT: case R_GPIO_INTEN: case R_TIMER0_COUNTER: case R_TIMER1_COUNTER: case R_DBG_SCRATCHPAD: s->regs[addr] = value; break; case R_TIMER0_COMPARE: ptimer_set_limit(s->ptimer0, value, 0); s->regs[addr] = value; break; case R_TIMER1_COMPARE: ptimer_set_limit(s->ptimer1, value, 0); s->regs[addr] = value; break; case R_TIMER0_CONTROL: s->regs[addr] = value; if (s->regs[R_TIMER0_CONTROL] & CTRL_ENABLE) { trace_milkymist_sysctl_start_timer0(); ptimer_set_count(s->ptimer0, s->regs[R_TIMER0_COMPARE] - s->regs[R_TIMER0_COUNTER]); ptimer_run(s->ptimer0, 0); } else { trace_milkymist_sysctl_stop_timer0(); ptimer_stop(s->ptimer0); } break; case R_TIMER1_CONTROL: s->regs[addr] = value; if (s->regs[R_TIMER1_CONTROL] & CTRL_ENABLE) { trace_milkymist_sysctl_start_timer1(); ptimer_set_count(s->ptimer1, s->regs[R_TIMER1_COMPARE] - s->regs[R_TIMER1_COUNTER]); ptimer_run(s->ptimer1, 0); } else { trace_milkymist_sysctl_stop_timer1(); ptimer_stop(s->ptimer1); } break; case R_ICAP: sysctl_icap_write(s, value); break; case R_DBG_WRITE_LOCK: s->regs[addr] = 1; break; case R_SYSTEM_ID: qemu_system_reset_request(); break; case R_GPIO_IN: case R_CLK_FREQUENCY: case R_CAPABILITIES: error_report("milkymist_sysctl: write to read-only register 0x" TARGET_FMT_plx, addr << 2); break; default: error_report("milkymist_sysctl: write access to unknown register 0x" TARGET_FMT_plx, addr << 2); break; } }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
static void sysctl_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { MilkymistSysctlState *s = opaque; trace_milkymist_sysctl_memory_write(addr, value); addr >>= 2; switch (addr) { case R_GPIO_OUT: case R_GPIO_INTEN: case R_TIMER0_COUNTER: case R_TIMER1_COUNTER: case R_DBG_SCRATCHPAD: s->regs[addr] = value; break; case R_TIMER0_COMPARE: ptimer_set_limit(s->ptimer0, value, 0); s->regs[addr] = value; break; case R_TIMER1_COMPARE: ptimer_set_limit(s->ptimer1, value, 0); s->regs[addr] = value; break; case R_TIMER0_CONTROL: s->regs[addr] = value; if (s->regs[R_TIMER0_CONTROL] & CTRL_ENABLE) { trace_milkymist_sysctl_start_timer0(); ptimer_set_count(s->ptimer0, s->regs[R_TIMER0_COMPARE] - s->regs[R_TIMER0_COUNTER]); ptimer_run(s->ptimer0, 0); } else { trace_milkymist_sysctl_stop_timer0(); ptimer_stop(s->ptimer0); } break; case R_TIMER1_CONTROL: s->regs[addr] = value; if (s->regs[R_TIMER1_CONTROL] & CTRL_ENABLE) { trace_milkymist_sysctl_start_timer1(); ptimer_set_count(s->ptimer1, s->regs[R_TIMER1_COMPARE] - s->regs[R_TIMER1_COUNTER]); ptimer_run(s->ptimer1, 0); } else { trace_milkymist_sysctl_stop_timer1(); ptimer_stop(s->ptimer1); } break; case R_ICAP: sysctl_icap_write(s, value); break; case R_DBG_WRITE_LOCK: s->regs[addr] = 1; break; case R_SYSTEM_ID: qemu_system_reset_request(); break; case R_GPIO_IN: case R_CLK_FREQUENCY: case R_CAPABILITIES: error_report("milkymist_sysctl: write to read-only register 0x" TARGET_FMT_plx, addr << 2); break; default: error_report("milkymist_sysctl: write access to unknown register 0x" TARGET_FMT_plx, addr << 2); break; } }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint64_t VAR_2, unsigned VAR_3) { MilkymistSysctlState *s = VAR_0; trace_milkymist_sysctl_memory_write(VAR_1, VAR_2); VAR_1 >>= 2; switch (VAR_1) { case R_GPIO_OUT: case R_GPIO_INTEN: case R_TIMER0_COUNTER: case R_TIMER1_COUNTER: case R_DBG_SCRATCHPAD: s->regs[VAR_1] = VAR_2; break; case R_TIMER0_COMPARE: ptimer_set_limit(s->ptimer0, VAR_2, 0); s->regs[VAR_1] = VAR_2; break; case R_TIMER1_COMPARE: ptimer_set_limit(s->ptimer1, VAR_2, 0); s->regs[VAR_1] = VAR_2; break; case R_TIMER0_CONTROL: s->regs[VAR_1] = VAR_2; if (s->regs[R_TIMER0_CONTROL] & CTRL_ENABLE) { trace_milkymist_sysctl_start_timer0(); ptimer_set_count(s->ptimer0, s->regs[R_TIMER0_COMPARE] - s->regs[R_TIMER0_COUNTER]); ptimer_run(s->ptimer0, 0); } else { trace_milkymist_sysctl_stop_timer0(); ptimer_stop(s->ptimer0); } break; case R_TIMER1_CONTROL: s->regs[VAR_1] = VAR_2; if (s->regs[R_TIMER1_CONTROL] & CTRL_ENABLE) { trace_milkymist_sysctl_start_timer1(); ptimer_set_count(s->ptimer1, s->regs[R_TIMER1_COMPARE] - s->regs[R_TIMER1_COUNTER]); ptimer_run(s->ptimer1, 0); } else { trace_milkymist_sysctl_stop_timer1(); ptimer_stop(s->ptimer1); } break; case R_ICAP: sysctl_icap_write(s, VAR_2); break; case R_DBG_WRITE_LOCK: s->regs[VAR_1] = 1; break; case R_SYSTEM_ID: qemu_system_reset_request(); break; case R_GPIO_IN: case R_CLK_FREQUENCY: case R_CAPABILITIES: error_report("milkymist_sysctl: write to read-only register 0x" TARGET_FMT_plx, VAR_1 << 2); break; default: error_report("milkymist_sysctl: write access to unknown register 0x" TARGET_FMT_plx, VAR_1 << 2); break; } }
[ "static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint64_t VAR_2,\nunsigned VAR_3)\n{", "MilkymistSysctlState *s = VAR_0;", "trace_milkymist_sysctl_memory_write(VAR_1, VAR_2);", "VAR_1 >>= 2;", "switch (VAR_1) {", "case R_GPIO_OUT:\ncase R_GPIO_INTEN:\ncase R_TIMER0_COUNTER:\ncase R_TIMER1_COUNTER:\ncase R_DBG_SCRATCHPAD:\ns->regs[VAR_1] = VAR_2;", "break;", "case R_TIMER0_COMPARE:\nptimer_set_limit(s->ptimer0, VAR_2, 0);", "s->regs[VAR_1] = VAR_2;", "break;", "case R_TIMER1_COMPARE:\nptimer_set_limit(s->ptimer1, VAR_2, 0);", "s->regs[VAR_1] = VAR_2;", "break;", "case R_TIMER0_CONTROL:\ns->regs[VAR_1] = VAR_2;", "if (s->regs[R_TIMER0_CONTROL] & CTRL_ENABLE) {", "trace_milkymist_sysctl_start_timer0();", "ptimer_set_count(s->ptimer0,\ns->regs[R_TIMER0_COMPARE] - s->regs[R_TIMER0_COUNTER]);", "ptimer_run(s->ptimer0, 0);", "} else {", "trace_milkymist_sysctl_stop_timer0();", "ptimer_stop(s->ptimer0);", "}", "break;", "case R_TIMER1_CONTROL:\ns->regs[VAR_1] = VAR_2;", "if (s->regs[R_TIMER1_CONTROL] & CTRL_ENABLE) {", "trace_milkymist_sysctl_start_timer1();", "ptimer_set_count(s->ptimer1,\ns->regs[R_TIMER1_COMPARE] - s->regs[R_TIMER1_COUNTER]);", "ptimer_run(s->ptimer1, 0);", "} else {", "trace_milkymist_sysctl_stop_timer1();", "ptimer_stop(s->ptimer1);", "}", "break;", "case R_ICAP:\nsysctl_icap_write(s, VAR_2);", "break;", "case R_DBG_WRITE_LOCK:\ns->regs[VAR_1] = 1;", "break;", "case R_SYSTEM_ID:\nqemu_system_reset_request();", "break;", "case R_GPIO_IN:\ncase R_CLK_FREQUENCY:\ncase R_CAPABILITIES:\nerror_report(\"milkymist_sysctl: write to read-only register 0x\"\nTARGET_FMT_plx, VAR_1 << 2);", "break;", "default:\nerror_report(\"milkymist_sysctl: write access to unknown register 0x\"\nTARGET_FMT_plx, VAR_1 << 2);", "break;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 15 ], [ 17 ], [ 19, 21, 23, 25, 27, 29 ], [ 31 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 41, 43 ], [ 45 ], [ 47 ], [ 49, 51 ], [ 53 ], [ 55 ], [ 57, 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73, 75 ], [ 77 ], [ 79 ], [ 81, 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97, 99 ], [ 101 ], [ 103, 105 ], [ 107 ], [ 109, 111 ], [ 113 ], [ 117, 119, 121, 123, 125 ], [ 127 ], [ 131, 133, 135 ], [ 137 ], [ 139 ], [ 141 ] ]
11,324
static void parallels_close(BlockDriverState *bs) { BDRVParallelsState *s = bs->opaque; g_free(s->catalog_bitmap); }
false
qemu
369f7de9d57e4dd2f312255fc12271d5749c0a4e
static void parallels_close(BlockDriverState *bs) { BDRVParallelsState *s = bs->opaque; g_free(s->catalog_bitmap); }
{ "code": [], "line_no": [] }
static void FUNC_0(BlockDriverState *VAR_0) { BDRVParallelsState *s = VAR_0->opaque; g_free(s->catalog_bitmap); }
[ "static void FUNC_0(BlockDriverState *VAR_0)\n{", "BDRVParallelsState *s = VAR_0->opaque;", "g_free(s->catalog_bitmap);", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ] ]
11,325
static int img_resize(int argc, char **argv) { Error *err = NULL; int c, ret, relative; const char *filename, *fmt, *size; int64_t n, total_size; bool quiet = false; BlockBackend *blk = NULL; QemuOpts *param; static QemuOptsList resize_options = { .name = "resize_options", .head = QTAILQ_HEAD_INITIALIZER(resize_options.head), .desc = { { .name = BLOCK_OPT_SIZE, .type = QEMU_OPT_SIZE, .help = "Virtual disk size" }, { /* end of list */ } }, }; bool image_opts = false; /* Remove size from argv manually so that negative numbers are not treated * as options by getopt. */ if (argc < 3) { error_exit("Not enough arguments"); return 1; } size = argv[--argc]; /* Parse getopt arguments */ fmt = NULL; for(;;) { static const struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, {0, 0, 0, 0} }; c = getopt_long(argc, argv, "f:hq", long_options, NULL); if (c == -1) { break; } switch(c) { case '?': case 'h': help(); break; case 'f': fmt = optarg; break; case 'q': quiet = true; break; case OPTION_OBJECT: { QemuOpts *opts; opts = qemu_opts_parse_noisily(&qemu_object_opts, optarg, true); if (!opts) { return 1; } } break; case OPTION_IMAGE_OPTS: image_opts = true; break; } } if (optind != argc - 1) { error_exit("Expecting one image file name"); } filename = argv[optind++]; if (qemu_opts_foreach(&qemu_object_opts, user_creatable_add_opts_foreach, NULL, NULL)) { return 1; } /* Choose grow, shrink, or absolute resize mode */ switch (size[0]) { case '+': relative = 1; size++; break; case '-': relative = -1; size++; break; default: relative = 0; break; } /* Parse size */ param = qemu_opts_create(&resize_options, NULL, 0, &error_abort); qemu_opt_set(param, BLOCK_OPT_SIZE, size, &err); if (err) { error_report_err(err); ret = -1; qemu_opts_del(param); goto out; } n = qemu_opt_get_size(param, BLOCK_OPT_SIZE, 0); qemu_opts_del(param); blk = img_open(image_opts, filename, fmt, BDRV_O_RDWR | BDRV_O_RESIZE, false, quiet); if (!blk) { ret = -1; goto out; } if (relative) { total_size = blk_getlength(blk) + n * relative; } else { total_size = n; } if (total_size <= 0) { error_report("New image size must be positive"); ret = -1; goto out; } ret = blk_truncate(blk, total_size); switch (ret) { case 0: qprintf(quiet, "Image resized.\n"); break; case -ENOTSUP: error_report("This image does not support resize"); break; case -EACCES: error_report("Image is read-only"); break; default: error_report("Error resizing image: %s", strerror(-ret)); break; } out: blk_unref(blk); if (ret) { return 1; } return 0; }
true
qemu
c919297379e9980c2bcc4d2053addbc1fd6d762b
static int img_resize(int argc, char **argv) { Error *err = NULL; int c, ret, relative; const char *filename, *fmt, *size; int64_t n, total_size; bool quiet = false; BlockBackend *blk = NULL; QemuOpts *param; static QemuOptsList resize_options = { .name = "resize_options", .head = QTAILQ_HEAD_INITIALIZER(resize_options.head), .desc = { { .name = BLOCK_OPT_SIZE, .type = QEMU_OPT_SIZE, .help = "Virtual disk size" }, { } }, }; bool image_opts = false; if (argc < 3) { error_exit("Not enough arguments"); return 1; } size = argv[--argc]; fmt = NULL; for(;;) { static const struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, {0, 0, 0, 0} }; c = getopt_long(argc, argv, "f:hq", long_options, NULL); if (c == -1) { break; } switch(c) { case '?': case 'h': help(); break; case 'f': fmt = optarg; break; case 'q': quiet = true; break; case OPTION_OBJECT: { QemuOpts *opts; opts = qemu_opts_parse_noisily(&qemu_object_opts, optarg, true); if (!opts) { return 1; } } break; case OPTION_IMAGE_OPTS: image_opts = true; break; } } if (optind != argc - 1) { error_exit("Expecting one image file name"); } filename = argv[optind++]; if (qemu_opts_foreach(&qemu_object_opts, user_creatable_add_opts_foreach, NULL, NULL)) { return 1; } switch (size[0]) { case '+': relative = 1; size++; break; case '-': relative = -1; size++; break; default: relative = 0; break; } param = qemu_opts_create(&resize_options, NULL, 0, &error_abort); qemu_opt_set(param, BLOCK_OPT_SIZE, size, &err); if (err) { error_report_err(err); ret = -1; qemu_opts_del(param); goto out; } n = qemu_opt_get_size(param, BLOCK_OPT_SIZE, 0); qemu_opts_del(param); blk = img_open(image_opts, filename, fmt, BDRV_O_RDWR | BDRV_O_RESIZE, false, quiet); if (!blk) { ret = -1; goto out; } if (relative) { total_size = blk_getlength(blk) + n * relative; } else { total_size = n; } if (total_size <= 0) { error_report("New image size must be positive"); ret = -1; goto out; } ret = blk_truncate(blk, total_size); switch (ret) { case 0: qprintf(quiet, "Image resized.\n"); break; case -ENOTSUP: error_report("This image does not support resize"); break; case -EACCES: error_report("Image is read-only"); break; default: error_report("Error resizing image: %s", strerror(-ret)); break; } out: blk_unref(blk); if (ret) { return 1; } return 0; }
{ "code": [ " c = getopt_long(argc, argv, \"f:hq\",", " case 'h':", " case 'h':", " case 'h':" ], "line_no": [ 87, 101, 101, 101 ] }
static int FUNC_0(int VAR_0, char **VAR_1) { Error *err = NULL; int VAR_2, VAR_3, VAR_4; const char *VAR_5, *VAR_6, *VAR_7; int64_t n, total_size; bool quiet = false; BlockBackend *blk = NULL; QemuOpts *param; static QemuOptsList VAR_8 = { .name = "VAR_8", .head = QTAILQ_HEAD_INITIALIZER(VAR_8.head), .desc = { { .name = BLOCK_OPT_SIZE, .type = QEMU_OPT_SIZE, .help = "Virtual disk VAR_7" }, { } }, }; bool image_opts = false; if (VAR_0 < 3) { error_exit("Not enough arguments"); return 1; } VAR_7 = VAR_1[--VAR_0]; VAR_6 = NULL; for(;;) { static const struct option VAR_9[] = { {"help", no_argument, 0, 'h'}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, {0, 0, 0, 0} }; VAR_2 = getopt_long(VAR_0, VAR_1, "f:hq", VAR_9, NULL); if (VAR_2 == -1) { break; } switch(VAR_2) { case '?': case 'h': help(); break; case 'f': VAR_6 = optarg; break; case 'q': quiet = true; break; case OPTION_OBJECT: { QemuOpts *opts; opts = qemu_opts_parse_noisily(&qemu_object_opts, optarg, true); if (!opts) { return 1; } } break; case OPTION_IMAGE_OPTS: image_opts = true; break; } } if (optind != VAR_0 - 1) { error_exit("Expecting one image file name"); } VAR_5 = VAR_1[optind++]; if (qemu_opts_foreach(&qemu_object_opts, user_creatable_add_opts_foreach, NULL, NULL)) { return 1; } switch (VAR_7[0]) { case '+': VAR_4 = 1; VAR_7++; break; case '-': VAR_4 = -1; VAR_7++; break; default: VAR_4 = 0; break; } param = qemu_opts_create(&VAR_8, NULL, 0, &error_abort); qemu_opt_set(param, BLOCK_OPT_SIZE, VAR_7, &err); if (err) { error_report_err(err); VAR_3 = -1; qemu_opts_del(param); goto out; } n = qemu_opt_get_size(param, BLOCK_OPT_SIZE, 0); qemu_opts_del(param); blk = img_open(image_opts, VAR_5, VAR_6, BDRV_O_RDWR | BDRV_O_RESIZE, false, quiet); if (!blk) { VAR_3 = -1; goto out; } if (VAR_4) { total_size = blk_getlength(blk) + n * VAR_4; } else { total_size = n; } if (total_size <= 0) { error_report("New image VAR_7 must be positive"); VAR_3 = -1; goto out; } VAR_3 = blk_truncate(blk, total_size); switch (VAR_3) { case 0: qprintf(quiet, "Image resized.\n"); break; case -ENOTSUP: error_report("This image does not support resize"); break; case -EACCES: error_report("Image is read-only"); break; default: error_report("Error resizing image: %s", strerror(-VAR_3)); break; } out: blk_unref(blk); if (VAR_3) { return 1; } return 0; }
[ "static int FUNC_0(int VAR_0, char **VAR_1)\n{", "Error *err = NULL;", "int VAR_2, VAR_3, VAR_4;", "const char *VAR_5, *VAR_6, *VAR_7;", "int64_t n, total_size;", "bool quiet = false;", "BlockBackend *blk = NULL;", "QemuOpts *param;", "static QemuOptsList VAR_8 = {", ".name = \"VAR_8\",\n.head = QTAILQ_HEAD_INITIALIZER(VAR_8.head),\n.desc = {", "{", ".name = BLOCK_OPT_SIZE,\n.type = QEMU_OPT_SIZE,\n.help = \"Virtual disk VAR_7\"\n}, {", "}", "},", "};", "bool image_opts = false;", "if (VAR_0 < 3) {", "error_exit(\"Not enough arguments\");", "return 1;", "}", "VAR_7 = VAR_1[--VAR_0];", "VAR_6 = NULL;", "for(;;) {", "static const struct option VAR_9[] = {", "{\"help\", no_argument, 0, 'h'},", "{\"object\", required_argument, 0, OPTION_OBJECT},", "{\"image-opts\", no_argument, 0, OPTION_IMAGE_OPTS},", "{0, 0, 0, 0}", "};", "VAR_2 = getopt_long(VAR_0, VAR_1, \"f:hq\",\nVAR_9, NULL);", "if (VAR_2 == -1) {", "break;", "}", "switch(VAR_2) {", "case '?':\ncase 'h':\nhelp();", "break;", "case 'f':\nVAR_6 = optarg;", "break;", "case 'q':\nquiet = true;", "break;", "case OPTION_OBJECT: {", "QemuOpts *opts;", "opts = qemu_opts_parse_noisily(&qemu_object_opts,\noptarg, true);", "if (!opts) {", "return 1;", "}", "} break;", "case OPTION_IMAGE_OPTS:\nimage_opts = true;", "break;", "}", "}", "if (optind != VAR_0 - 1) {", "error_exit(\"Expecting one image file name\");", "}", "VAR_5 = VAR_1[optind++];", "if (qemu_opts_foreach(&qemu_object_opts,\nuser_creatable_add_opts_foreach,\nNULL, NULL)) {", "return 1;", "}", "switch (VAR_7[0]) {", "case '+':\nVAR_4 = 1;", "VAR_7++;", "break;", "case '-':\nVAR_4 = -1;", "VAR_7++;", "break;", "default:\nVAR_4 = 0;", "break;", "}", "param = qemu_opts_create(&VAR_8, NULL, 0, &error_abort);", "qemu_opt_set(param, BLOCK_OPT_SIZE, VAR_7, &err);", "if (err) {", "error_report_err(err);", "VAR_3 = -1;", "qemu_opts_del(param);", "goto out;", "}", "n = qemu_opt_get_size(param, BLOCK_OPT_SIZE, 0);", "qemu_opts_del(param);", "blk = img_open(image_opts, VAR_5, VAR_6,\nBDRV_O_RDWR | BDRV_O_RESIZE, false, quiet);", "if (!blk) {", "VAR_3 = -1;", "goto out;", "}", "if (VAR_4) {", "total_size = blk_getlength(blk) + n * VAR_4;", "} else {", "total_size = n;", "}", "if (total_size <= 0) {", "error_report(\"New image VAR_7 must be positive\");", "VAR_3 = -1;", "goto out;", "}", "VAR_3 = blk_truncate(blk, total_size);", "switch (VAR_3) {", "case 0:\nqprintf(quiet, \"Image resized.\\n\");", "break;", "case -ENOTSUP:\nerror_report(\"This image does not support resize\");", "break;", "case -EACCES:\nerror_report(\"Image is read-only\");", "break;", "default:\nerror_report(\"Error resizing image: %s\", strerror(-VAR_3));", "break;", "}", "out:\nblk_unref(blk);", "if (VAR_3) {", "return 1;", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23, 25, 27 ], [ 29 ], [ 31, 33, 35, 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 65 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87, 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99, 101, 103 ], [ 105 ], [ 107, 109 ], [ 111 ], [ 113, 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123, 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135, 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 155, 157, 159 ], [ 161 ], [ 163 ], [ 169 ], [ 171, 173 ], [ 175 ], [ 177 ], [ 179, 181 ], [ 183 ], [ 185 ], [ 187, 189 ], [ 191 ], [ 193 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 221, 223 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 235 ], [ 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 257 ], [ 259 ], [ 261, 263 ], [ 265 ], [ 267, 269 ], [ 271 ], [ 273, 275 ], [ 277 ], [ 279, 281 ], [ 283 ], [ 285 ], [ 287, 289 ], [ 291 ], [ 293 ], [ 295 ], [ 297 ], [ 299 ] ]
11,327
static void qtrle_decode_24bpp(QtrleContext *s, int stream_ptr, int row_ptr, int lines_to_change) { int rle_code; int pixel_ptr; int row_inc = s->frame.linesize[0]; unsigned char r, g, b; unsigned char *rgb = s->frame.data[0]; int pixel_limit = s->frame.linesize[0] * s->avctx->height; while (lines_to_change--) { CHECK_STREAM_PTR(2); pixel_ptr = row_ptr + (s->buf[stream_ptr++] - 1) * 3; while ((rle_code = (signed char)s->buf[stream_ptr++]) != -1) { if (rle_code == 0) { /* there's another skip code in the stream */ CHECK_STREAM_PTR(1); pixel_ptr += (s->buf[stream_ptr++] - 1) * 3; } else if (rle_code < 0) { /* decode the run length code */ rle_code = -rle_code; CHECK_STREAM_PTR(3); r = s->buf[stream_ptr++]; g = s->buf[stream_ptr++]; b = s->buf[stream_ptr++]; CHECK_PIXEL_PTR(rle_code * 3); while (rle_code--) { rgb[pixel_ptr++] = r; rgb[pixel_ptr++] = g; rgb[pixel_ptr++] = b; } } else { CHECK_STREAM_PTR(rle_code * 3); CHECK_PIXEL_PTR(rle_code * 3); /* copy pixels directly to output */ while (rle_code--) { rgb[pixel_ptr++] = s->buf[stream_ptr++]; rgb[pixel_ptr++] = s->buf[stream_ptr++]; rgb[pixel_ptr++] = s->buf[stream_ptr++]; } } } row_ptr += row_inc; } }
true
FFmpeg
7fb92be7e50ea4ba5712804326c6814ae02dd190
static void qtrle_decode_24bpp(QtrleContext *s, int stream_ptr, int row_ptr, int lines_to_change) { int rle_code; int pixel_ptr; int row_inc = s->frame.linesize[0]; unsigned char r, g, b; unsigned char *rgb = s->frame.data[0]; int pixel_limit = s->frame.linesize[0] * s->avctx->height; while (lines_to_change--) { CHECK_STREAM_PTR(2); pixel_ptr = row_ptr + (s->buf[stream_ptr++] - 1) * 3; while ((rle_code = (signed char)s->buf[stream_ptr++]) != -1) { if (rle_code == 0) { CHECK_STREAM_PTR(1); pixel_ptr += (s->buf[stream_ptr++] - 1) * 3; } else if (rle_code < 0) { rle_code = -rle_code; CHECK_STREAM_PTR(3); r = s->buf[stream_ptr++]; g = s->buf[stream_ptr++]; b = s->buf[stream_ptr++]; CHECK_PIXEL_PTR(rle_code * 3); while (rle_code--) { rgb[pixel_ptr++] = r; rgb[pixel_ptr++] = g; rgb[pixel_ptr++] = b; } } else { CHECK_STREAM_PTR(rle_code * 3); CHECK_PIXEL_PTR(rle_code * 3); while (rle_code--) { rgb[pixel_ptr++] = s->buf[stream_ptr++]; rgb[pixel_ptr++] = s->buf[stream_ptr++]; rgb[pixel_ptr++] = s->buf[stream_ptr++]; } } } row_ptr += row_inc; } }
{ "code": [], "line_no": [] }
static void FUNC_0(QtrleContext *VAR_0, int VAR_1, int VAR_2, int VAR_3) { int VAR_4; int VAR_5; int VAR_6 = VAR_0->frame.linesize[0]; unsigned char VAR_7, VAR_8, VAR_9; unsigned char *VAR_10 = VAR_0->frame.data[0]; int VAR_11 = VAR_0->frame.linesize[0] * VAR_0->avctx->height; while (VAR_3--) { CHECK_STREAM_PTR(2); VAR_5 = VAR_2 + (VAR_0->buf[VAR_1++] - 1) * 3; while ((VAR_4 = (signed char)VAR_0->buf[VAR_1++]) != -1) { if (VAR_4 == 0) { CHECK_STREAM_PTR(1); VAR_5 += (VAR_0->buf[VAR_1++] - 1) * 3; } else if (VAR_4 < 0) { VAR_4 = -VAR_4; CHECK_STREAM_PTR(3); VAR_7 = VAR_0->buf[VAR_1++]; VAR_8 = VAR_0->buf[VAR_1++]; VAR_9 = VAR_0->buf[VAR_1++]; CHECK_PIXEL_PTR(VAR_4 * 3); while (VAR_4--) { VAR_10[VAR_5++] = VAR_7; VAR_10[VAR_5++] = VAR_8; VAR_10[VAR_5++] = VAR_9; } } else { CHECK_STREAM_PTR(VAR_4 * 3); CHECK_PIXEL_PTR(VAR_4 * 3); while (VAR_4--) { VAR_10[VAR_5++] = VAR_0->buf[VAR_1++]; VAR_10[VAR_5++] = VAR_0->buf[VAR_1++]; VAR_10[VAR_5++] = VAR_0->buf[VAR_1++]; } } } VAR_2 += VAR_6; } }
[ "static void FUNC_0(QtrleContext *VAR_0, int VAR_1, int VAR_2, int VAR_3)\n{", "int VAR_4;", "int VAR_5;", "int VAR_6 = VAR_0->frame.linesize[0];", "unsigned char VAR_7, VAR_8, VAR_9;", "unsigned char *VAR_10 = VAR_0->frame.data[0];", "int VAR_11 = VAR_0->frame.linesize[0] * VAR_0->avctx->height;", "while (VAR_3--) {", "CHECK_STREAM_PTR(2);", "VAR_5 = VAR_2 + (VAR_0->buf[VAR_1++] - 1) * 3;", "while ((VAR_4 = (signed char)VAR_0->buf[VAR_1++]) != -1) {", "if (VAR_4 == 0) {", "CHECK_STREAM_PTR(1);", "VAR_5 += (VAR_0->buf[VAR_1++] - 1) * 3;", "} else if (VAR_4 < 0) {", "VAR_4 = -VAR_4;", "CHECK_STREAM_PTR(3);", "VAR_7 = VAR_0->buf[VAR_1++];", "VAR_8 = VAR_0->buf[VAR_1++];", "VAR_9 = VAR_0->buf[VAR_1++];", "CHECK_PIXEL_PTR(VAR_4 * 3);", "while (VAR_4--) {", "VAR_10[VAR_5++] = VAR_7;", "VAR_10[VAR_5++] = VAR_8;", "VAR_10[VAR_5++] = VAR_9;", "}", "} else {", "CHECK_STREAM_PTR(VAR_4 * 3);", "CHECK_PIXEL_PTR(VAR_4 * 3);", "while (VAR_4--) {", "VAR_10[VAR_5++] = VAR_0->buf[VAR_1++];", "VAR_10[VAR_5++] = VAR_0->buf[VAR_1++];", "VAR_10[VAR_5++] = VAR_0->buf[VAR_1++];", "}", "}", "}", "VAR_2 += VAR_6;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 28 ], [ 30 ], [ 34 ], [ 36 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ] ]
11,329
static int xiph_parse_sdp_line(AVFormatContext *s, int st_index, PayloadContext *data, const char *line) { const char *p; char *value; char attr[25]; int value_size = strlen(line), attr_size = sizeof(attr), res = 0; AVCodecContext* codec = s->streams[st_index]->codec; assert(codec->id == CODEC_ID_THEORA); assert(data); if (!(value = av_malloc(value_size))) { av_log(codec, AV_LOG_ERROR, "Out of memory\n"); return AVERROR(ENOMEM); } if (av_strstart(line, "fmtp:", &p)) { // remove protocol identifier while (*p && *p == ' ') p++; // strip spaces while (*p && *p != ' ') p++; // eat protocol identifier while (*p && *p == ' ') p++; // strip trailing spaces while (ff_rtsp_next_attr_and_value(&p, attr, attr_size, value, value_size)) { res = xiph_parse_fmtp_pair(codec, data, attr, value); if (res < 0 && res != AVERROR_PATCHWELCOME) return res; } } av_free(value); return 0; }
true
FFmpeg
e58c05bb3c8b7bd3b93d264facbf290aeae4c483
static int xiph_parse_sdp_line(AVFormatContext *s, int st_index, PayloadContext *data, const char *line) { const char *p; char *value; char attr[25]; int value_size = strlen(line), attr_size = sizeof(attr), res = 0; AVCodecContext* codec = s->streams[st_index]->codec; assert(codec->id == CODEC_ID_THEORA); assert(data); if (!(value = av_malloc(value_size))) { av_log(codec, AV_LOG_ERROR, "Out of memory\n"); return AVERROR(ENOMEM); } if (av_strstart(line, "fmtp:", &p)) { while (*p && *p == ' ') p++; while (*p && *p != ' ') p++; while (*p && *p == ' ') p++; while (ff_rtsp_next_attr_and_value(&p, attr, attr_size, value, value_size)) { res = xiph_parse_fmtp_pair(codec, data, attr, value); if (res < 0 && res != AVERROR_PATCHWELCOME) return res; } } av_free(value); return 0; }
{ "code": [ " assert(codec->id == CODEC_ID_THEORA);" ], "line_no": [ 19 ] }
static int FUNC_0(AVFormatContext *VAR_0, int VAR_1, PayloadContext *VAR_2, const char *VAR_3) { const char *VAR_4; char *VAR_5; char VAR_6[25]; int VAR_7 = strlen(VAR_3), VAR_8 = sizeof(VAR_6), VAR_9 = 0; AVCodecContext* codec = VAR_0->streams[VAR_1]->codec; assert(codec->id == CODEC_ID_THEORA); assert(VAR_2); if (!(VAR_5 = av_malloc(VAR_7))) { av_log(codec, AV_LOG_ERROR, "Out of memory\n"); return AVERROR(ENOMEM); } if (av_strstart(VAR_3, "fmtp:", &VAR_4)) { while (*VAR_4 && *VAR_4 == ' ') VAR_4++; while (*VAR_4 && *VAR_4 != ' ') VAR_4++; while (*VAR_4 && *VAR_4 == ' ') VAR_4++; while (ff_rtsp_next_attr_and_value(&VAR_4, VAR_6, VAR_8, VAR_5, VAR_7)) { VAR_9 = xiph_parse_fmtp_pair(codec, VAR_2, VAR_6, VAR_5); if (VAR_9 < 0 && VAR_9 != AVERROR_PATCHWELCOME) return VAR_9; } } av_free(VAR_5); return 0; }
[ "static int FUNC_0(AVFormatContext *VAR_0, int VAR_1,\nPayloadContext *VAR_2, const char *VAR_3)\n{", "const char *VAR_4;", "char *VAR_5;", "char VAR_6[25];", "int VAR_7 = strlen(VAR_3), VAR_8 = sizeof(VAR_6), VAR_9 = 0;", "AVCodecContext* codec = VAR_0->streams[VAR_1]->codec;", "assert(codec->id == CODEC_ID_THEORA);", "assert(VAR_2);", "if (!(VAR_5 = av_malloc(VAR_7))) {", "av_log(codec, AV_LOG_ERROR, \"Out of memory\\n\");", "return AVERROR(ENOMEM);", "}", "if (av_strstart(VAR_3, \"fmtp:\", &VAR_4)) {", "while (*VAR_4 && *VAR_4 == ' ') VAR_4++;", "while (*VAR_4 && *VAR_4 != ' ') VAR_4++;", "while (*VAR_4 && *VAR_4 == ' ') VAR_4++;", "while (ff_rtsp_next_attr_and_value(&VAR_4,\nVAR_6, VAR_8,\nVAR_5, VAR_7)) {", "VAR_9 = xiph_parse_fmtp_pair(codec, VAR_2, VAR_6, VAR_5);", "if (VAR_9 < 0 && VAR_9 != AVERROR_PATCHWELCOME)\nreturn VAR_9;", "}", "}", "av_free(VAR_5);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 47, 49, 51 ], [ 53 ], [ 55, 57 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ] ]
11,330
static int vp8_handle_packet(AVFormatContext *ctx, PayloadContext *vp8, AVStream *st, AVPacket *pkt, uint32_t *timestamp, const uint8_t *buf, int len, uint16_t seq, int flags) { int start_partition, end_packet; int extended_bits, part_id; int pictureid_present = 0, tl0picidx_present = 0, tid_present = 0, keyidx_present = 0; int pictureid = -1, pictureid_mask = 0; int returned_old_frame = 0; uint32_t old_timestamp; if (!buf) { if (vp8->data) { int ret = ff_rtp_finalize_packet(pkt, &vp8->data, st->index); if (ret < 0) return ret; *timestamp = vp8->timestamp; if (vp8->sequence_dirty) pkt->flags |= AV_PKT_FLAG_CORRUPT; return 0; } return AVERROR(EAGAIN); } if (len < 1) return AVERROR_INVALIDDATA; extended_bits = buf[0] & 0x80; start_partition = buf[0] & 0x10; part_id = buf[0] & 0x0f; end_packet = flags & RTP_FLAG_MARKER; buf++; len--; if (extended_bits) { if (len < 1) return AVERROR_INVALIDDATA; pictureid_present = buf[0] & 0x80; tl0picidx_present = buf[0] & 0x40; tid_present = buf[0] & 0x20; keyidx_present = buf[0] & 0x10; buf++; len--; } if (pictureid_present) { if (len < 1) return AVERROR_INVALIDDATA; if (buf[0] & 0x80) { if (len < 2) return AVERROR_INVALIDDATA; pictureid = AV_RB16(buf) & 0x7fff; pictureid_mask = 0x7fff; buf += 2; len -= 2; } else { pictureid = buf[0] & 0x7f; pictureid_mask = 0x7f; buf++; len--; } } if (tl0picidx_present) { // Ignoring temporal level zero index buf++; len--; } if (tid_present || keyidx_present) { // Ignoring temporal layer index, layer sync bit and keyframe index buf++; len--; } if (len < 1) return AVERROR_INVALIDDATA; if (start_partition && part_id == 0 && len >= 3) { int res; int non_key = buf[0] & 0x01; if (!non_key) { vp8_free_buffer(vp8); // Keyframe, decoding ok again vp8->sequence_ok = 1; vp8->sequence_dirty = 0; vp8->got_keyframe = 1; } else { int can_continue = vp8->data && !vp8->is_keyframe && avio_tell(vp8->data) >= vp8->first_part_size; if (!vp8->sequence_ok) return AVERROR(EAGAIN); if (!vp8->got_keyframe) return vp8_broken_sequence(ctx, vp8, "Keyframe missing\n"); if (pictureid >= 0) { if (pictureid != ((vp8->prev_pictureid + 1) & pictureid_mask)) { return vp8_broken_sequence(ctx, vp8, "Missed a picture, sequence broken\n"); } else { if (vp8->data && !can_continue) return vp8_broken_sequence(ctx, vp8, "Missed a picture, sequence broken\n"); } } else { uint16_t expected_seq = vp8->prev_seq + 1; int16_t diff = seq - expected_seq; if (vp8->data) { // No picture id, so we can't know if missed packets // contained any new frames. If diff == 0, we did get // later packets from the same frame (matching timestamp), // so we know we didn't miss any frame. If diff == 1 and // we still have data (not flushed by the end of frame // marker), the single missed packet must have been part // of the same frame. if ((diff == 0 || diff == 1) && can_continue) { // Proceed with what we have } else { return vp8_broken_sequence(ctx, vp8, "Missed too much, sequence broken\n"); } } else { if (diff != 0) return vp8_broken_sequence(ctx, vp8, "Missed unknown data, sequence broken\n"); } } if (vp8->data) { vp8->sequence_dirty = 1; if (avio_tell(vp8->data) >= vp8->first_part_size) { int ret = ff_rtp_finalize_packet(pkt, &vp8->data, st->index); if (ret < 0) return ret; pkt->flags |= AV_PKT_FLAG_CORRUPT; returned_old_frame = 1; old_timestamp = vp8->timestamp; } else { // Shouldn't happen vp8_free_buffer(vp8); } } } vp8->first_part_size = (AV_RL16(&buf[1]) << 3 | buf[0] >> 5) + 3; if ((res = avio_open_dyn_buf(&vp8->data)) < 0) return res; vp8->timestamp = *timestamp; vp8->broken_frame = 0; vp8->prev_pictureid = pictureid; vp8->is_keyframe = !non_key; } else { uint16_t expected_seq = vp8->prev_seq + 1; if (!vp8->sequence_ok) return AVERROR(EAGAIN); if (vp8->timestamp != *timestamp) { // Missed the start of the new frame, sequence broken return vp8_broken_sequence(ctx, vp8, "Received no start marker; dropping frame\n"); } if (seq != expected_seq) { if (vp8->is_keyframe) { return vp8_broken_sequence(ctx, vp8, "Missed part of a keyframe, sequence broken\n"); } else if (vp8->data && avio_tell(vp8->data) >= vp8->first_part_size) { vp8->broken_frame = 1; vp8->sequence_dirty = 1; } else { return vp8_broken_sequence(ctx, vp8, "Missed part of the first partition, sequence broken\n"); } } } if (!vp8->data) return vp8_broken_sequence(ctx, vp8, "Received no start marker\n"); vp8->prev_seq = seq; if (!vp8->broken_frame) avio_write(vp8->data, buf, len); if (returned_old_frame) { *timestamp = old_timestamp; return end_packet ? 1 : 0; } if (end_packet) { int ret; ret = ff_rtp_finalize_packet(pkt, &vp8->data, st->index); if (ret < 0) return ret; if (vp8->sequence_dirty) pkt->flags |= AV_PKT_FLAG_CORRUPT; return 0; } return AVERROR(EAGAIN); }
true
FFmpeg
8fbab7a6c84fd75de4f752b412cea8032604f75b
static int vp8_handle_packet(AVFormatContext *ctx, PayloadContext *vp8, AVStream *st, AVPacket *pkt, uint32_t *timestamp, const uint8_t *buf, int len, uint16_t seq, int flags) { int start_partition, end_packet; int extended_bits, part_id; int pictureid_present = 0, tl0picidx_present = 0, tid_present = 0, keyidx_present = 0; int pictureid = -1, pictureid_mask = 0; int returned_old_frame = 0; uint32_t old_timestamp; if (!buf) { if (vp8->data) { int ret = ff_rtp_finalize_packet(pkt, &vp8->data, st->index); if (ret < 0) return ret; *timestamp = vp8->timestamp; if (vp8->sequence_dirty) pkt->flags |= AV_PKT_FLAG_CORRUPT; return 0; } return AVERROR(EAGAIN); } if (len < 1) return AVERROR_INVALIDDATA; extended_bits = buf[0] & 0x80; start_partition = buf[0] & 0x10; part_id = buf[0] & 0x0f; end_packet = flags & RTP_FLAG_MARKER; buf++; len--; if (extended_bits) { if (len < 1) return AVERROR_INVALIDDATA; pictureid_present = buf[0] & 0x80; tl0picidx_present = buf[0] & 0x40; tid_present = buf[0] & 0x20; keyidx_present = buf[0] & 0x10; buf++; len--; } if (pictureid_present) { if (len < 1) return AVERROR_INVALIDDATA; if (buf[0] & 0x80) { if (len < 2) return AVERROR_INVALIDDATA; pictureid = AV_RB16(buf) & 0x7fff; pictureid_mask = 0x7fff; buf += 2; len -= 2; } else { pictureid = buf[0] & 0x7f; pictureid_mask = 0x7f; buf++; len--; } } if (tl0picidx_present) { buf++; len--; } if (tid_present || keyidx_present) { buf++; len--; } if (len < 1) return AVERROR_INVALIDDATA; if (start_partition && part_id == 0 && len >= 3) { int res; int non_key = buf[0] & 0x01; if (!non_key) { vp8_free_buffer(vp8); vp8->sequence_ok = 1; vp8->sequence_dirty = 0; vp8->got_keyframe = 1; } else { int can_continue = vp8->data && !vp8->is_keyframe && avio_tell(vp8->data) >= vp8->first_part_size; if (!vp8->sequence_ok) return AVERROR(EAGAIN); if (!vp8->got_keyframe) return vp8_broken_sequence(ctx, vp8, "Keyframe missing\n"); if (pictureid >= 0) { if (pictureid != ((vp8->prev_pictureid + 1) & pictureid_mask)) { return vp8_broken_sequence(ctx, vp8, "Missed a picture, sequence broken\n"); } else { if (vp8->data && !can_continue) return vp8_broken_sequence(ctx, vp8, "Missed a picture, sequence broken\n"); } } else { uint16_t expected_seq = vp8->prev_seq + 1; int16_t diff = seq - expected_seq; if (vp8->data) { if ((diff == 0 || diff == 1) && can_continue) { } else { return vp8_broken_sequence(ctx, vp8, "Missed too much, sequence broken\n"); } } else { if (diff != 0) return vp8_broken_sequence(ctx, vp8, "Missed unknown data, sequence broken\n"); } } if (vp8->data) { vp8->sequence_dirty = 1; if (avio_tell(vp8->data) >= vp8->first_part_size) { int ret = ff_rtp_finalize_packet(pkt, &vp8->data, st->index); if (ret < 0) return ret; pkt->flags |= AV_PKT_FLAG_CORRUPT; returned_old_frame = 1; old_timestamp = vp8->timestamp; } else { vp8_free_buffer(vp8); } } } vp8->first_part_size = (AV_RL16(&buf[1]) << 3 | buf[0] >> 5) + 3; if ((res = avio_open_dyn_buf(&vp8->data)) < 0) return res; vp8->timestamp = *timestamp; vp8->broken_frame = 0; vp8->prev_pictureid = pictureid; vp8->is_keyframe = !non_key; } else { uint16_t expected_seq = vp8->prev_seq + 1; if (!vp8->sequence_ok) return AVERROR(EAGAIN); if (vp8->timestamp != *timestamp) { return vp8_broken_sequence(ctx, vp8, "Received no start marker; dropping frame\n"); } if (seq != expected_seq) { if (vp8->is_keyframe) { return vp8_broken_sequence(ctx, vp8, "Missed part of a keyframe, sequence broken\n"); } else if (vp8->data && avio_tell(vp8->data) >= vp8->first_part_size) { vp8->broken_frame = 1; vp8->sequence_dirty = 1; } else { return vp8_broken_sequence(ctx, vp8, "Missed part of the first partition, sequence broken\n"); } } } if (!vp8->data) return vp8_broken_sequence(ctx, vp8, "Received no start marker\n"); vp8->prev_seq = seq; if (!vp8->broken_frame) avio_write(vp8->data, buf, len); if (returned_old_frame) { *timestamp = old_timestamp; return end_packet ? 1 : 0; } if (end_packet) { int ret; ret = ff_rtp_finalize_packet(pkt, &vp8->data, st->index); if (ret < 0) return ret; if (vp8->sequence_dirty) pkt->flags |= AV_PKT_FLAG_CORRUPT; return 0; } return AVERROR(EAGAIN); }
{ "code": [ " uint32_t old_timestamp;" ], "line_no": [ 23 ] }
static int FUNC_0(AVFormatContext *VAR_0, PayloadContext *VAR_1, AVStream *VAR_2, AVPacket *VAR_3, uint32_t *VAR_4, const uint8_t *VAR_5, int VAR_6, uint16_t VAR_7, int VAR_8) { int VAR_9, VAR_10; int VAR_11, VAR_12; int VAR_13 = 0, VAR_14 = 0, VAR_15 = 0, VAR_16 = 0; int VAR_17 = -1, VAR_18 = 0; int VAR_19 = 0; uint32_t old_timestamp; if (!VAR_5) { if (VAR_1->data) { int VAR_24 = ff_rtp_finalize_packet(VAR_3, &VAR_1->data, VAR_2->index); if (VAR_24 < 0) return VAR_24; *VAR_4 = VAR_1->VAR_4; if (VAR_1->sequence_dirty) VAR_3->VAR_8 |= AV_PKT_FLAG_CORRUPT; return 0; } return AVERROR(EAGAIN); } if (VAR_6 < 1) return AVERROR_INVALIDDATA; VAR_11 = VAR_5[0] & 0x80; VAR_9 = VAR_5[0] & 0x10; VAR_12 = VAR_5[0] & 0x0f; VAR_10 = VAR_8 & RTP_FLAG_MARKER; VAR_5++; VAR_6--; if (VAR_11) { if (VAR_6 < 1) return AVERROR_INVALIDDATA; VAR_13 = VAR_5[0] & 0x80; VAR_14 = VAR_5[0] & 0x40; VAR_15 = VAR_5[0] & 0x20; VAR_16 = VAR_5[0] & 0x10; VAR_5++; VAR_6--; } if (VAR_13) { if (VAR_6 < 1) return AVERROR_INVALIDDATA; if (VAR_5[0] & 0x80) { if (VAR_6 < 2) return AVERROR_INVALIDDATA; VAR_17 = AV_RB16(VAR_5) & 0x7fff; VAR_18 = 0x7fff; VAR_5 += 2; VAR_6 -= 2; } else { VAR_17 = VAR_5[0] & 0x7f; VAR_18 = 0x7f; VAR_5++; VAR_6--; } } if (VAR_14) { VAR_5++; VAR_6--; } if (VAR_15 || VAR_16) { VAR_5++; VAR_6--; } if (VAR_6 < 1) return AVERROR_INVALIDDATA; if (VAR_9 && VAR_12 == 0 && VAR_6 >= 3) { int VAR_21; int VAR_22 = VAR_5[0] & 0x01; if (!VAR_22) { vp8_free_buffer(VAR_1); VAR_1->sequence_ok = 1; VAR_1->sequence_dirty = 0; VAR_1->got_keyframe = 1; } else { int VAR_23 = VAR_1->data && !VAR_1->is_keyframe && avio_tell(VAR_1->data) >= VAR_1->first_part_size; if (!VAR_1->sequence_ok) return AVERROR(EAGAIN); if (!VAR_1->got_keyframe) return vp8_broken_sequence(VAR_0, VAR_1, "Keyframe missing\n"); if (VAR_17 >= 0) { if (VAR_17 != ((VAR_1->prev_pictureid + 1) & VAR_18)) { return vp8_broken_sequence(VAR_0, VAR_1, "Missed a picture, sequence broken\n"); } else { if (VAR_1->data && !VAR_23) return vp8_broken_sequence(VAR_0, VAR_1, "Missed a picture, sequence broken\n"); } } else { uint16_t expected_seq = VAR_1->prev_seq + 1; int16_t diff = VAR_7 - expected_seq; if (VAR_1->data) { if ((diff == 0 || diff == 1) && VAR_23) { } else { return vp8_broken_sequence(VAR_0, VAR_1, "Missed too much, sequence broken\n"); } } else { if (diff != 0) return vp8_broken_sequence(VAR_0, VAR_1, "Missed unknown data, sequence broken\n"); } } if (VAR_1->data) { VAR_1->sequence_dirty = 1; if (avio_tell(VAR_1->data) >= VAR_1->first_part_size) { int VAR_24 = ff_rtp_finalize_packet(VAR_3, &VAR_1->data, VAR_2->index); if (VAR_24 < 0) return VAR_24; VAR_3->VAR_8 |= AV_PKT_FLAG_CORRUPT; VAR_19 = 1; old_timestamp = VAR_1->VAR_4; } else { vp8_free_buffer(VAR_1); } } } VAR_1->first_part_size = (AV_RL16(&VAR_5[1]) << 3 | VAR_5[0] >> 5) + 3; if ((VAR_21 = avio_open_dyn_buf(&VAR_1->data)) < 0) return VAR_21; VAR_1->VAR_4 = *VAR_4; VAR_1->broken_frame = 0; VAR_1->prev_pictureid = VAR_17; VAR_1->is_keyframe = !VAR_22; } else { uint16_t expected_seq = VAR_1->prev_seq + 1; if (!VAR_1->sequence_ok) return AVERROR(EAGAIN); if (VAR_1->VAR_4 != *VAR_4) { return vp8_broken_sequence(VAR_0, VAR_1, "Received no start marker; dropping frame\n"); } if (VAR_7 != expected_seq) { if (VAR_1->is_keyframe) { return vp8_broken_sequence(VAR_0, VAR_1, "Missed part of a keyframe, sequence broken\n"); } else if (VAR_1->data && avio_tell(VAR_1->data) >= VAR_1->first_part_size) { VAR_1->broken_frame = 1; VAR_1->sequence_dirty = 1; } else { return vp8_broken_sequence(VAR_0, VAR_1, "Missed part of the first partition, sequence broken\n"); } } } if (!VAR_1->data) return vp8_broken_sequence(VAR_0, VAR_1, "Received no start marker\n"); VAR_1->prev_seq = VAR_7; if (!VAR_1->broken_frame) avio_write(VAR_1->data, VAR_5, VAR_6); if (VAR_19) { *VAR_4 = old_timestamp; return VAR_10 ? 1 : 0; } if (VAR_10) { int VAR_24; VAR_24 = ff_rtp_finalize_packet(VAR_3, &VAR_1->data, VAR_2->index); if (VAR_24 < 0) return VAR_24; if (VAR_1->sequence_dirty) VAR_3->VAR_8 |= AV_PKT_FLAG_CORRUPT; return 0; } return AVERROR(EAGAIN); }
[ "static int FUNC_0(AVFormatContext *VAR_0, PayloadContext *VAR_1,\nAVStream *VAR_2, AVPacket *VAR_3, uint32_t *VAR_4,\nconst uint8_t *VAR_5, int VAR_6, uint16_t VAR_7,\nint VAR_8)\n{", "int VAR_9, VAR_10;", "int VAR_11, VAR_12;", "int VAR_13 = 0, VAR_14 = 0, VAR_15 = 0,\nVAR_16 = 0;", "int VAR_17 = -1, VAR_18 = 0;", "int VAR_19 = 0;", "uint32_t old_timestamp;", "if (!VAR_5) {", "if (VAR_1->data) {", "int VAR_24 = ff_rtp_finalize_packet(VAR_3, &VAR_1->data, VAR_2->index);", "if (VAR_24 < 0)\nreturn VAR_24;", "*VAR_4 = VAR_1->VAR_4;", "if (VAR_1->sequence_dirty)\nVAR_3->VAR_8 |= AV_PKT_FLAG_CORRUPT;", "return 0;", "}", "return AVERROR(EAGAIN);", "}", "if (VAR_6 < 1)\nreturn AVERROR_INVALIDDATA;", "VAR_11 = VAR_5[0] & 0x80;", "VAR_9 = VAR_5[0] & 0x10;", "VAR_12 = VAR_5[0] & 0x0f;", "VAR_10 = VAR_8 & RTP_FLAG_MARKER;", "VAR_5++;", "VAR_6--;", "if (VAR_11) {", "if (VAR_6 < 1)\nreturn AVERROR_INVALIDDATA;", "VAR_13 = VAR_5[0] & 0x80;", "VAR_14 = VAR_5[0] & 0x40;", "VAR_15 = VAR_5[0] & 0x20;", "VAR_16 = VAR_5[0] & 0x10;", "VAR_5++;", "VAR_6--;", "}", "if (VAR_13) {", "if (VAR_6 < 1)\nreturn AVERROR_INVALIDDATA;", "if (VAR_5[0] & 0x80) {", "if (VAR_6 < 2)\nreturn AVERROR_INVALIDDATA;", "VAR_17 = AV_RB16(VAR_5) & 0x7fff;", "VAR_18 = 0x7fff;", "VAR_5 += 2;", "VAR_6 -= 2;", "} else {", "VAR_17 = VAR_5[0] & 0x7f;", "VAR_18 = 0x7f;", "VAR_5++;", "VAR_6--;", "}", "}", "if (VAR_14) {", "VAR_5++;", "VAR_6--;", "}", "if (VAR_15 || VAR_16) {", "VAR_5++;", "VAR_6--;", "}", "if (VAR_6 < 1)\nreturn AVERROR_INVALIDDATA;", "if (VAR_9 && VAR_12 == 0 && VAR_6 >= 3) {", "int VAR_21;", "int VAR_22 = VAR_5[0] & 0x01;", "if (!VAR_22) {", "vp8_free_buffer(VAR_1);", "VAR_1->sequence_ok = 1;", "VAR_1->sequence_dirty = 0;", "VAR_1->got_keyframe = 1;", "} else {", "int VAR_23 = VAR_1->data && !VAR_1->is_keyframe &&\navio_tell(VAR_1->data) >= VAR_1->first_part_size;", "if (!VAR_1->sequence_ok)\nreturn AVERROR(EAGAIN);", "if (!VAR_1->got_keyframe)\nreturn vp8_broken_sequence(VAR_0, VAR_1, \"Keyframe missing\\n\");", "if (VAR_17 >= 0) {", "if (VAR_17 != ((VAR_1->prev_pictureid + 1) & VAR_18)) {", "return vp8_broken_sequence(VAR_0, VAR_1,\n\"Missed a picture, sequence broken\\n\");", "} else {", "if (VAR_1->data && !VAR_23)\nreturn vp8_broken_sequence(VAR_0, VAR_1,\n\"Missed a picture, sequence broken\\n\");", "}", "} else {", "uint16_t expected_seq = VAR_1->prev_seq + 1;", "int16_t diff = VAR_7 - expected_seq;", "if (VAR_1->data) {", "if ((diff == 0 || diff == 1) && VAR_23) {", "} else {", "return vp8_broken_sequence(VAR_0, VAR_1,\n\"Missed too much, sequence broken\\n\");", "}", "} else {", "if (diff != 0)\nreturn vp8_broken_sequence(VAR_0, VAR_1,\n\"Missed unknown data, sequence broken\\n\");", "}", "}", "if (VAR_1->data) {", "VAR_1->sequence_dirty = 1;", "if (avio_tell(VAR_1->data) >= VAR_1->first_part_size) {", "int VAR_24 = ff_rtp_finalize_packet(VAR_3, &VAR_1->data, VAR_2->index);", "if (VAR_24 < 0)\nreturn VAR_24;", "VAR_3->VAR_8 |= AV_PKT_FLAG_CORRUPT;", "VAR_19 = 1;", "old_timestamp = VAR_1->VAR_4;", "} else {", "vp8_free_buffer(VAR_1);", "}", "}", "}", "VAR_1->first_part_size = (AV_RL16(&VAR_5[1]) << 3 | VAR_5[0] >> 5) + 3;", "if ((VAR_21 = avio_open_dyn_buf(&VAR_1->data)) < 0)\nreturn VAR_21;", "VAR_1->VAR_4 = *VAR_4;", "VAR_1->broken_frame = 0;", "VAR_1->prev_pictureid = VAR_17;", "VAR_1->is_keyframe = !VAR_22;", "} else {", "uint16_t expected_seq = VAR_1->prev_seq + 1;", "if (!VAR_1->sequence_ok)\nreturn AVERROR(EAGAIN);", "if (VAR_1->VAR_4 != *VAR_4) {", "return vp8_broken_sequence(VAR_0, VAR_1,\n\"Received no start marker; dropping frame\\n\");", "}", "if (VAR_7 != expected_seq) {", "if (VAR_1->is_keyframe) {", "return vp8_broken_sequence(VAR_0, VAR_1,\n\"Missed part of a keyframe, sequence broken\\n\");", "} else if (VAR_1->data && avio_tell(VAR_1->data) >= VAR_1->first_part_size) {", "VAR_1->broken_frame = 1;", "VAR_1->sequence_dirty = 1;", "} else {", "return vp8_broken_sequence(VAR_0, VAR_1,\n\"Missed part of the first partition, sequence broken\\n\");", "}", "}", "}", "if (!VAR_1->data)\nreturn vp8_broken_sequence(VAR_0, VAR_1, \"Received no start marker\\n\");", "VAR_1->prev_seq = VAR_7;", "if (!VAR_1->broken_frame)\navio_write(VAR_1->data, VAR_5, VAR_6);", "if (VAR_19) {", "*VAR_4 = old_timestamp;", "return VAR_10 ? 1 : 0;", "}", "if (VAR_10) {", "int VAR_24;", "VAR_24 = ff_rtp_finalize_packet(VAR_3, &VAR_1->data, VAR_2->index);", "if (VAR_24 < 0)\nreturn VAR_24;", "if (VAR_1->sequence_dirty)\nVAR_3->VAR_8 |= AV_PKT_FLAG_CORRUPT;", "return 0;", "}", "return AVERROR(EAGAIN);", "}" ]
[ 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 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 15, 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33, 35 ], [ 37 ], [ 39, 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53, 55 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73, 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93, 95 ], [ 97 ], [ 99, 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 139 ], [ 141 ], [ 143 ], [ 145, 147 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171, 173 ], [ 175, 177 ], [ 179, 181 ], [ 183 ], [ 185 ], [ 187, 189 ], [ 191 ], [ 193, 195, 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 223 ], [ 227 ], [ 229, 231 ], [ 233 ], [ 235 ], [ 237, 239, 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255, 257 ], [ 259 ], [ 261 ], [ 263 ], [ 265 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ], [ 277 ], [ 279, 281 ], [ 283 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 293 ], [ 297, 299 ], [ 303 ], [ 307, 309 ], [ 311 ], [ 315 ], [ 317 ], [ 319, 321 ], [ 323 ], [ 325 ], [ 327 ], [ 329 ], [ 331, 333 ], [ 335 ], [ 337 ], [ 339 ], [ 343, 345 ], [ 349 ], [ 351, 353 ], [ 357 ], [ 359 ], [ 361 ], [ 363 ], [ 367 ], [ 369 ], [ 371 ], [ 373, 375 ], [ 377, 379 ], [ 381 ], [ 383 ], [ 387 ], [ 389 ] ]
11,331
static int encode_picture_lossless(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ MpegEncContext * const s = avctx->priv_data; MJpegContext * const m = s->mjpeg_ctx; AVFrame *pict = data; const int width= s->width; const int height= s->height; AVFrame * const p= (AVFrame*)&s->current_picture; const int predictor= avctx->prediction_method+1; init_put_bits(&s->pb, buf, buf_size); *p = *pict; p->pict_type= FF_I_TYPE; p->key_frame= 1; mjpeg_picture_header(s); s->header_bits= put_bits_count(&s->pb); if(avctx->pix_fmt == PIX_FMT_RGBA32){ int x, y, i; const int linesize= p->linesize[0]; uint16_t buffer[2048][4]; int left[3], top[3], topleft[3]; for(i=0; i<3; i++){ buffer[0][i]= 1 << (9 - 1); } for(y = 0; y < height; y++) { const int modified_predictor= y ? predictor : 1; uint8_t *ptr = p->data[0] + (linesize * y); for(i=0; i<3; i++){ top[i]= left[i]= topleft[i]= buffer[0][i]; } for(x = 0; x < width; x++) { buffer[x][1] = ptr[4*x+0] - ptr[4*x+1] + 0x100; buffer[x][2] = ptr[4*x+2] - ptr[4*x+1] + 0x100; buffer[x][0] = (ptr[4*x+0] + 2*ptr[4*x+1] + ptr[4*x+2])>>2; for(i=0;i<3;i++) { int pred, diff; PREDICT(pred, topleft[i], top[i], left[i], modified_predictor); topleft[i]= top[i]; top[i]= buffer[x+1][i]; left[i]= buffer[x][i]; diff= ((left[i] - pred + 0x100)&0x1FF) - 0x100; if(i==0) mjpeg_encode_dc(s, diff, m->huff_size_dc_luminance, m->huff_code_dc_luminance); //FIXME ugly else mjpeg_encode_dc(s, diff, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance); } } } }else{ int mb_x, mb_y, i; const int mb_width = (width + s->mjpeg_hsample[0] - 1) / s->mjpeg_hsample[0]; const int mb_height = (height + s->mjpeg_vsample[0] - 1) / s->mjpeg_vsample[0]; for(mb_y = 0; mb_y < mb_height; mb_y++) { for(mb_x = 0; mb_x < mb_width; mb_x++) { if(mb_x==0 || mb_y==0){ for(i=0;i<3;i++) { uint8_t *ptr; int x, y, h, v, linesize; h = s->mjpeg_hsample[i]; v = s->mjpeg_vsample[i]; linesize= p->linesize[i]; for(y=0; y<v; y++){ for(x=0; x<h; x++){ int pred; ptr = p->data[i] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap if(y==0 && mb_y==0){ if(x==0 && mb_x==0){ pred= 128; }else{ pred= ptr[-1]; } }else{ if(x==0 && mb_x==0){ pred= ptr[-linesize]; }else{ PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor); } } if(i==0) mjpeg_encode_dc(s, (int8_t)(*ptr - pred), m->huff_size_dc_luminance, m->huff_code_dc_luminance); //FIXME ugly else mjpeg_encode_dc(s, (int8_t)(*ptr - pred), m->huff_size_dc_chrominance, m->huff_code_dc_chrominance); } } } }else{ for(i=0;i<3;i++) { uint8_t *ptr; int x, y, h, v, linesize; h = s->mjpeg_hsample[i]; v = s->mjpeg_vsample[i]; linesize= p->linesize[i]; for(y=0; y<v; y++){ for(x=0; x<h; x++){ int pred; ptr = p->data[i] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap //printf("%d %d %d %d %8X\n", mb_x, mb_y, x, y, ptr); PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor); if(i==0) mjpeg_encode_dc(s, (int8_t)(*ptr - pred), m->huff_size_dc_luminance, m->huff_code_dc_luminance); //FIXME ugly else mjpeg_encode_dc(s, (int8_t)(*ptr - pred), m->huff_size_dc_chrominance, m->huff_code_dc_chrominance); } } } } } } } emms_c(); mjpeg_picture_trailer(s); s->picture_number++; flush_put_bits(&s->pb); return pbBufPtr(&s->pb) - s->pb.buf; // return (put_bits_count(&f->pb)+7)/8; }
true
FFmpeg
0ecca7a49f8e254c12a3a1de048d738bfbb614c6
static int encode_picture_lossless(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ MpegEncContext * const s = avctx->priv_data; MJpegContext * const m = s->mjpeg_ctx; AVFrame *pict = data; const int width= s->width; const int height= s->height; AVFrame * const p= (AVFrame*)&s->current_picture; const int predictor= avctx->prediction_method+1; init_put_bits(&s->pb, buf, buf_size); *p = *pict; p->pict_type= FF_I_TYPE; p->key_frame= 1; mjpeg_picture_header(s); s->header_bits= put_bits_count(&s->pb); if(avctx->pix_fmt == PIX_FMT_RGBA32){ int x, y, i; const int linesize= p->linesize[0]; uint16_t buffer[2048][4]; int left[3], top[3], topleft[3]; for(i=0; i<3; i++){ buffer[0][i]= 1 << (9 - 1); } for(y = 0; y < height; y++) { const int modified_predictor= y ? predictor : 1; uint8_t *ptr = p->data[0] + (linesize * y); for(i=0; i<3; i++){ top[i]= left[i]= topleft[i]= buffer[0][i]; } for(x = 0; x < width; x++) { buffer[x][1] = ptr[4*x+0] - ptr[4*x+1] + 0x100; buffer[x][2] = ptr[4*x+2] - ptr[4*x+1] + 0x100; buffer[x][0] = (ptr[4*x+0] + 2*ptr[4*x+1] + ptr[4*x+2])>>2; for(i=0;i<3;i++) { int pred, diff; PREDICT(pred, topleft[i], top[i], left[i], modified_predictor); topleft[i]= top[i]; top[i]= buffer[x+1][i]; left[i]= buffer[x][i]; diff= ((left[i] - pred + 0x100)&0x1FF) - 0x100; if(i==0) mjpeg_encode_dc(s, diff, m->huff_size_dc_luminance, m->huff_code_dc_luminance); else mjpeg_encode_dc(s, diff, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance); } } } }else{ int mb_x, mb_y, i; const int mb_width = (width + s->mjpeg_hsample[0] - 1) / s->mjpeg_hsample[0]; const int mb_height = (height + s->mjpeg_vsample[0] - 1) / s->mjpeg_vsample[0]; for(mb_y = 0; mb_y < mb_height; mb_y++) { for(mb_x = 0; mb_x < mb_width; mb_x++) { if(mb_x==0 || mb_y==0){ for(i=0;i<3;i++) { uint8_t *ptr; int x, y, h, v, linesize; h = s->mjpeg_hsample[i]; v = s->mjpeg_vsample[i]; linesize= p->linesize[i]; for(y=0; y<v; y++){ for(x=0; x<h; x++){ int pred; ptr = p->data[i] + (linesize * (v * mb_y + y)) + (h * mb_x + x); if(y==0 && mb_y==0){ if(x==0 && mb_x==0){ pred= 128; }else{ pred= ptr[-1]; } }else{ if(x==0 && mb_x==0){ pred= ptr[-linesize]; }else{ PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor); } } if(i==0) mjpeg_encode_dc(s, (int8_t)(*ptr - pred), m->huff_size_dc_luminance, m->huff_code_dc_luminance); else mjpeg_encode_dc(s, (int8_t)(*ptr - pred), m->huff_size_dc_chrominance, m->huff_code_dc_chrominance); } } } }else{ for(i=0;i<3;i++) { uint8_t *ptr; int x, y, h, v, linesize; h = s->mjpeg_hsample[i]; v = s->mjpeg_vsample[i]; linesize= p->linesize[i]; for(y=0; y<v; y++){ for(x=0; x<h; x++){ int pred; ptr = p->data[i] + (linesize * (v * mb_y + y)) + (h * mb_x + x); PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor); if(i==0) mjpeg_encode_dc(s, (int8_t)(*ptr - pred), m->huff_size_dc_luminance, m->huff_code_dc_luminance); else mjpeg_encode_dc(s, (int8_t)(*ptr - pred), m->huff_size_dc_chrominance, m->huff_code_dc_chrominance); } } } } } } } emms_c(); mjpeg_picture_trailer(s); s->picture_number++; flush_put_bits(&s->pb); return pbBufPtr(&s->pb) - s->pb.buf; }
{ "code": [ " uint16_t buffer[2048][4];" ], "line_no": [ 45 ] }
static int FUNC_0(AVCodecContext *VAR_0, unsigned char *VAR_1, int VAR_2, void *VAR_3){ MpegEncContext * const s = VAR_0->priv_data; MJpegContext * const m = s->mjpeg_ctx; AVFrame *pict = VAR_3; const int VAR_4= s->VAR_4; const int VAR_5= s->VAR_5; AVFrame * const p= (AVFrame*)&s->current_picture; const int VAR_6= VAR_0->prediction_method+1; init_put_bits(&s->pb, VAR_1, VAR_2); *p = *pict; p->pict_type= FF_I_TYPE; p->key_frame= 1; mjpeg_picture_header(s); s->header_bits= put_bits_count(&s->pb); if(VAR_0->pix_fmt == PIX_FMT_RGBA32){ int VAR_23, VAR_23, VAR_19; const int VAR_23= p->VAR_23[0]; uint16_t buffer[2048][4]; int VAR_11[3], VAR_12[3], VAR_13[3]; for(VAR_19=0; VAR_19<3; VAR_19++){ buffer[0][VAR_19]= 1 << (9 - 1); } for(VAR_23 = 0; VAR_23 < VAR_5; VAR_23++) { const int VAR_14= VAR_23 ? VAR_6 : 1; uint8_t *ptr = p->VAR_3[0] + (VAR_23 * VAR_23); for(VAR_19=0; VAR_19<3; VAR_19++){ VAR_12[VAR_19]= VAR_11[VAR_19]= VAR_13[VAR_19]= buffer[0][VAR_19]; } for(VAR_23 = 0; VAR_23 < VAR_4; VAR_23++) { buffer[VAR_23][1] = ptr[4*VAR_23+0] - ptr[4*VAR_23+1] + 0x100; buffer[VAR_23][2] = ptr[4*VAR_23+2] - ptr[4*VAR_23+1] + 0x100; buffer[VAR_23][0] = (ptr[4*VAR_23+0] + 2*ptr[4*VAR_23+1] + ptr[4*VAR_23+2])>>2; for(VAR_19=0;VAR_19<3;VAR_19++) { int VAR_23, VAR_16; PREDICT(VAR_23, VAR_13[VAR_19], VAR_12[VAR_19], VAR_11[VAR_19], VAR_14); VAR_13[VAR_19]= VAR_12[VAR_19]; VAR_12[VAR_19]= buffer[VAR_23+1][VAR_19]; VAR_11[VAR_19]= buffer[VAR_23][VAR_19]; VAR_16= ((VAR_11[VAR_19] - VAR_23 + 0x100)&0x1FF) - 0x100; if(VAR_19==0) mjpeg_encode_dc(s, VAR_16, m->huff_size_dc_luminance, m->huff_code_dc_luminance); else mjpeg_encode_dc(s, VAR_16, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance); } } } }else{ int VAR_17, VAR_18, VAR_19; const int VAR_19 = (VAR_4 + s->mjpeg_hsample[0] - 1) / s->mjpeg_hsample[0]; const int VAR_20 = (VAR_5 + s->mjpeg_vsample[0] - 1) / s->mjpeg_vsample[0]; for(VAR_18 = 0; VAR_18 < VAR_20; VAR_18++) { for(VAR_17 = 0; VAR_17 < VAR_19; VAR_17++) { if(VAR_17==0 || VAR_18==0){ for(VAR_19=0;VAR_19<3;VAR_19++) { uint8_t *ptr; int VAR_23, VAR_23, VAR_23, VAR_23, VAR_23; VAR_23 = s->mjpeg_hsample[VAR_19]; VAR_23 = s->mjpeg_vsample[VAR_19]; VAR_23= p->VAR_23[VAR_19]; for(VAR_23=0; VAR_23<VAR_23; VAR_23++){ for(VAR_23=0; VAR_23<VAR_23; VAR_23++){ int VAR_23; ptr = p->VAR_3[VAR_19] + (VAR_23 * (VAR_23 * VAR_18 + VAR_23)) + (VAR_23 * VAR_17 + VAR_23); if(VAR_23==0 && VAR_18==0){ if(VAR_23==0 && VAR_17==0){ VAR_23= 128; }else{ VAR_23= ptr[-1]; } }else{ if(VAR_23==0 && VAR_17==0){ VAR_23= ptr[-VAR_23]; }else{ PREDICT(VAR_23, ptr[-VAR_23-1], ptr[-VAR_23], ptr[-1], VAR_6); } } if(VAR_19==0) mjpeg_encode_dc(s, (int8_t)(*ptr - VAR_23), m->huff_size_dc_luminance, m->huff_code_dc_luminance); else mjpeg_encode_dc(s, (int8_t)(*ptr - VAR_23), m->huff_size_dc_chrominance, m->huff_code_dc_chrominance); } } } }else{ for(VAR_19=0;VAR_19<3;VAR_19++) { uint8_t *ptr; int VAR_23, VAR_23, VAR_23, VAR_23, VAR_23; VAR_23 = s->mjpeg_hsample[VAR_19]; VAR_23 = s->mjpeg_vsample[VAR_19]; VAR_23= p->VAR_23[VAR_19]; for(VAR_23=0; VAR_23<VAR_23; VAR_23++){ for(VAR_23=0; VAR_23<VAR_23; VAR_23++){ int VAR_23; ptr = p->VAR_3[VAR_19] + (VAR_23 * (VAR_23 * VAR_18 + VAR_23)) + (VAR_23 * VAR_17 + VAR_23); PREDICT(VAR_23, ptr[-VAR_23-1], ptr[-VAR_23], ptr[-1], VAR_6); if(VAR_19==0) mjpeg_encode_dc(s, (int8_t)(*ptr - VAR_23), m->huff_size_dc_luminance, m->huff_code_dc_luminance); else mjpeg_encode_dc(s, (int8_t)(*ptr - VAR_23), m->huff_size_dc_chrominance, m->huff_code_dc_chrominance); } } } } } } } emms_c(); mjpeg_picture_trailer(s); s->picture_number++; flush_put_bits(&s->pb); return pbBufPtr(&s->pb) - s->pb.VAR_1; }
[ "static int FUNC_0(AVCodecContext *VAR_0, unsigned char *VAR_1, int VAR_2, void *VAR_3){", "MpegEncContext * const s = VAR_0->priv_data;", "MJpegContext * const m = s->mjpeg_ctx;", "AVFrame *pict = VAR_3;", "const int VAR_4= s->VAR_4;", "const int VAR_5= s->VAR_5;", "AVFrame * const p= (AVFrame*)&s->current_picture;", "const int VAR_6= VAR_0->prediction_method+1;", "init_put_bits(&s->pb, VAR_1, VAR_2);", "*p = *pict;", "p->pict_type= FF_I_TYPE;", "p->key_frame= 1;", "mjpeg_picture_header(s);", "s->header_bits= put_bits_count(&s->pb);", "if(VAR_0->pix_fmt == PIX_FMT_RGBA32){", "int VAR_23, VAR_23, VAR_19;", "const int VAR_23= p->VAR_23[0];", "uint16_t buffer[2048][4];", "int VAR_11[3], VAR_12[3], VAR_13[3];", "for(VAR_19=0; VAR_19<3; VAR_19++){", "buffer[0][VAR_19]= 1 << (9 - 1);", "}", "for(VAR_23 = 0; VAR_23 < VAR_5; VAR_23++) {", "const int VAR_14= VAR_23 ? VAR_6 : 1;", "uint8_t *ptr = p->VAR_3[0] + (VAR_23 * VAR_23);", "for(VAR_19=0; VAR_19<3; VAR_19++){", "VAR_12[VAR_19]= VAR_11[VAR_19]= VAR_13[VAR_19]= buffer[0][VAR_19];", "}", "for(VAR_23 = 0; VAR_23 < VAR_4; VAR_23++) {", "buffer[VAR_23][1] = ptr[4*VAR_23+0] - ptr[4*VAR_23+1] + 0x100;", "buffer[VAR_23][2] = ptr[4*VAR_23+2] - ptr[4*VAR_23+1] + 0x100;", "buffer[VAR_23][0] = (ptr[4*VAR_23+0] + 2*ptr[4*VAR_23+1] + ptr[4*VAR_23+2])>>2;", "for(VAR_19=0;VAR_19<3;VAR_19++) {", "int VAR_23, VAR_16;", "PREDICT(VAR_23, VAR_13[VAR_19], VAR_12[VAR_19], VAR_11[VAR_19], VAR_14);", "VAR_13[VAR_19]= VAR_12[VAR_19];", "VAR_12[VAR_19]= buffer[VAR_23+1][VAR_19];", "VAR_11[VAR_19]= buffer[VAR_23][VAR_19];", "VAR_16= ((VAR_11[VAR_19] - VAR_23 + 0x100)&0x1FF) - 0x100;", "if(VAR_19==0)\nmjpeg_encode_dc(s, VAR_16, m->huff_size_dc_luminance, m->huff_code_dc_luminance);", "else\nmjpeg_encode_dc(s, VAR_16, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);", "}", "}", "}", "}else{", "int VAR_17, VAR_18, VAR_19;", "const int VAR_19 = (VAR_4 + s->mjpeg_hsample[0] - 1) / s->mjpeg_hsample[0];", "const int VAR_20 = (VAR_5 + s->mjpeg_vsample[0] - 1) / s->mjpeg_vsample[0];", "for(VAR_18 = 0; VAR_18 < VAR_20; VAR_18++) {", "for(VAR_17 = 0; VAR_17 < VAR_19; VAR_17++) {", "if(VAR_17==0 || VAR_18==0){", "for(VAR_19=0;VAR_19<3;VAR_19++) {", "uint8_t *ptr;", "int VAR_23, VAR_23, VAR_23, VAR_23, VAR_23;", "VAR_23 = s->mjpeg_hsample[VAR_19];", "VAR_23 = s->mjpeg_vsample[VAR_19];", "VAR_23= p->VAR_23[VAR_19];", "for(VAR_23=0; VAR_23<VAR_23; VAR_23++){", "for(VAR_23=0; VAR_23<VAR_23; VAR_23++){", "int VAR_23;", "ptr = p->VAR_3[VAR_19] + (VAR_23 * (VAR_23 * VAR_18 + VAR_23)) + (VAR_23 * VAR_17 + VAR_23);", "if(VAR_23==0 && VAR_18==0){", "if(VAR_23==0 && VAR_17==0){", "VAR_23= 128;", "}else{", "VAR_23= ptr[-1];", "}", "}else{", "if(VAR_23==0 && VAR_17==0){", "VAR_23= ptr[-VAR_23];", "}else{", "PREDICT(VAR_23, ptr[-VAR_23-1], ptr[-VAR_23], ptr[-1], VAR_6);", "}", "}", "if(VAR_19==0)\nmjpeg_encode_dc(s, (int8_t)(*ptr - VAR_23), m->huff_size_dc_luminance, m->huff_code_dc_luminance);", "else\nmjpeg_encode_dc(s, (int8_t)(*ptr - VAR_23), m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);", "}", "}", "}", "}else{", "for(VAR_19=0;VAR_19<3;VAR_19++) {", "uint8_t *ptr;", "int VAR_23, VAR_23, VAR_23, VAR_23, VAR_23;", "VAR_23 = s->mjpeg_hsample[VAR_19];", "VAR_23 = s->mjpeg_vsample[VAR_19];", "VAR_23= p->VAR_23[VAR_19];", "for(VAR_23=0; VAR_23<VAR_23; VAR_23++){", "for(VAR_23=0; VAR_23<VAR_23; VAR_23++){", "int VAR_23;", "ptr = p->VAR_3[VAR_19] + (VAR_23 * (VAR_23 * VAR_18 + VAR_23)) + (VAR_23 * VAR_17 + VAR_23);", "PREDICT(VAR_23, ptr[-VAR_23-1], ptr[-VAR_23], ptr[-1], VAR_6);", "if(VAR_19==0)\nmjpeg_encode_dc(s, (int8_t)(*ptr - VAR_23), m->huff_size_dc_luminance, m->huff_code_dc_luminance);", "else\nmjpeg_encode_dc(s, (int8_t)(*ptr - VAR_23), m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);", "}", "}", "}", "}", "}", "}", "}", "emms_c();", "mjpeg_picture_trailer(s);", "s->picture_number++;", "flush_put_bits(&s->pb);", "return pbBufPtr(&s->pb) - s->pb.VAR_1;", "}" ]
[ 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 ]
[ [ 1 ], [ 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 83 ], [ 85 ], [ 89 ], [ 93 ], [ 95 ], [ 99 ], [ 103 ], [ 107, 109 ], [ 111, 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 151 ], [ 153 ], [ 155 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 189, 191 ], [ 193, 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 219 ], [ 221 ], [ 223 ], [ 227 ], [ 231 ], [ 235, 237 ], [ 239, 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 259 ], [ 263 ], [ 265 ], [ 269 ], [ 271 ], [ 275 ] ]
11,332
static VFIOGroup *vfio_get_group(int groupid) { VFIOGroup *group; char path[32]; struct vfio_group_status status = { .argsz = sizeof(status) }; QLIST_FOREACH(group, &group_list, next) { if (group->groupid == groupid) { return group; } } group = g_malloc0(sizeof(*group)); snprintf(path, sizeof(path), "/dev/vfio/%d", groupid); group->fd = qemu_open(path, O_RDWR); if (group->fd < 0) { error_report("vfio: error opening %s: %m", path); goto free_group_exit; } if (ioctl(group->fd, VFIO_GROUP_GET_STATUS, &status)) { error_report("vfio: error getting group status: %m"); goto close_fd_exit; } if (!(status.flags & VFIO_GROUP_FLAGS_VIABLE)) { error_report("vfio: error, group %d is not viable, please ensure " "all devices within the iommu_group are bound to their " "vfio bus driver.", groupid); goto close_fd_exit; } group->groupid = groupid; QLIST_INIT(&group->device_list); if (vfio_connect_container(group)) { error_report("vfio: failed to setup container for group %d", groupid); goto close_fd_exit; } if (QLIST_EMPTY(&group_list)) { qemu_register_reset(vfio_pci_reset_handler, NULL); } QLIST_INSERT_HEAD(&group_list, group, next); vfio_kvm_device_add_group(group); return group; close_fd_exit: close(group->fd); free_group_exit: g_free(group); return NULL; }
true
qemu
3df3e0a5872cbc8fcc55a0413416352eec68132e
static VFIOGroup *vfio_get_group(int groupid) { VFIOGroup *group; char path[32]; struct vfio_group_status status = { .argsz = sizeof(status) }; QLIST_FOREACH(group, &group_list, next) { if (group->groupid == groupid) { return group; } } group = g_malloc0(sizeof(*group)); snprintf(path, sizeof(path), "/dev/vfio/%d", groupid); group->fd = qemu_open(path, O_RDWR); if (group->fd < 0) { error_report("vfio: error opening %s: %m", path); goto free_group_exit; } if (ioctl(group->fd, VFIO_GROUP_GET_STATUS, &status)) { error_report("vfio: error getting group status: %m"); goto close_fd_exit; } if (!(status.flags & VFIO_GROUP_FLAGS_VIABLE)) { error_report("vfio: error, group %d is not viable, please ensure " "all devices within the iommu_group are bound to their " "vfio bus driver.", groupid); goto close_fd_exit; } group->groupid = groupid; QLIST_INIT(&group->device_list); if (vfio_connect_container(group)) { error_report("vfio: failed to setup container for group %d", groupid); goto close_fd_exit; } if (QLIST_EMPTY(&group_list)) { qemu_register_reset(vfio_pci_reset_handler, NULL); } QLIST_INSERT_HEAD(&group_list, group, next); vfio_kvm_device_add_group(group); return group; close_fd_exit: close(group->fd); free_group_exit: g_free(group); return NULL; }
{ "code": [ "static VFIOGroup *vfio_get_group(int groupid)", " return group;", " if (vfio_connect_container(group)) {" ], "line_no": [ 1, 17, 73 ] }
static VFIOGroup *FUNC_0(int groupid) { VFIOGroup *group; char VAR_0[32]; struct vfio_group_status VAR_1 = { .argsz = sizeof(VAR_1) }; QLIST_FOREACH(group, &group_list, next) { if (group->groupid == groupid) { return group; } } group = g_malloc0(sizeof(*group)); snprintf(VAR_0, sizeof(VAR_0), "/dev/vfio/%d", groupid); group->fd = qemu_open(VAR_0, O_RDWR); if (group->fd < 0) { error_report("vfio: error opening %s: %m", VAR_0); goto free_group_exit; } if (ioctl(group->fd, VFIO_GROUP_GET_STATUS, &VAR_1)) { error_report("vfio: error getting group VAR_1: %m"); goto close_fd_exit; } if (!(VAR_1.flags & VFIO_GROUP_FLAGS_VIABLE)) { error_report("vfio: error, group %d is not viable, please ensure " "all devices within the iommu_group are bound to their " "vfio bus driver.", groupid); goto close_fd_exit; } group->groupid = groupid; QLIST_INIT(&group->device_list); if (vfio_connect_container(group)) { error_report("vfio: failed to setup container for group %d", groupid); goto close_fd_exit; } if (QLIST_EMPTY(&group_list)) { qemu_register_reset(vfio_pci_reset_handler, NULL); } QLIST_INSERT_HEAD(&group_list, group, next); vfio_kvm_device_add_group(group); return group; close_fd_exit: close(group->fd); free_group_exit: g_free(group); return NULL; }
[ "static VFIOGroup *FUNC_0(int groupid)\n{", "VFIOGroup *group;", "char VAR_0[32];", "struct vfio_group_status VAR_1 = { .argsz = sizeof(VAR_1) };", "QLIST_FOREACH(group, &group_list, next) {", "if (group->groupid == groupid) {", "return group;", "}", "}", "group = g_malloc0(sizeof(*group));", "snprintf(VAR_0, sizeof(VAR_0), \"/dev/vfio/%d\", groupid);", "group->fd = qemu_open(VAR_0, O_RDWR);", "if (group->fd < 0) {", "error_report(\"vfio: error opening %s: %m\", VAR_0);", "goto free_group_exit;", "}", "if (ioctl(group->fd, VFIO_GROUP_GET_STATUS, &VAR_1)) {", "error_report(\"vfio: error getting group VAR_1: %m\");", "goto close_fd_exit;", "}", "if (!(VAR_1.flags & VFIO_GROUP_FLAGS_VIABLE)) {", "error_report(\"vfio: error, group %d is not viable, please ensure \"\n\"all devices within the iommu_group are bound to their \"\n\"vfio bus driver.\", groupid);", "goto close_fd_exit;", "}", "group->groupid = groupid;", "QLIST_INIT(&group->device_list);", "if (vfio_connect_container(group)) {", "error_report(\"vfio: failed to setup container for group %d\", groupid);", "goto close_fd_exit;", "}", "if (QLIST_EMPTY(&group_list)) {", "qemu_register_reset(vfio_pci_reset_handler, NULL);", "}", "QLIST_INSERT_HEAD(&group_list, group, next);", "vfio_kvm_device_add_group(group);", "return group;", "close_fd_exit:\nclose(group->fd);", "free_group_exit:\ng_free(group);", "return NULL;", "}" ]
[ 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55, 57, 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 83 ], [ 85 ], [ 87 ], [ 91 ], [ 95 ], [ 99 ], [ 103, 105 ], [ 109, 111 ], [ 115 ], [ 117 ] ]
11,333
static int webvtt_event_to_ass(AVBPrint *buf, const char *p) { int i, again, skip = 0; while (*p) { for (i = 0; i < FF_ARRAY_ELEMS(webvtt_tag_replace); i++) { const char *from = webvtt_tag_replace[i].from; const size_t len = strlen(from); if (!strncmp(p, from, len)) { av_bprintf(buf, "%s", webvtt_tag_replace[i].to); p += len; again = 1; break; } } if (!*p) break; if (again) { again = 0; skip = 0; continue; } if (*p == '<') skip = 1; else if (*p == '>') skip = 0; else if (p[0] == '\n' && p[1]) av_bprintf(buf, "\\N"); else if (!skip && *p != '\r') av_bprint_chars(buf, *p, 1); p++; } return 0; }
true
FFmpeg
4819446eae451a6e58d6ae41faefb5529af4e783
static int webvtt_event_to_ass(AVBPrint *buf, const char *p) { int i, again, skip = 0; while (*p) { for (i = 0; i < FF_ARRAY_ELEMS(webvtt_tag_replace); i++) { const char *from = webvtt_tag_replace[i].from; const size_t len = strlen(from); if (!strncmp(p, from, len)) { av_bprintf(buf, "%s", webvtt_tag_replace[i].to); p += len; again = 1; break; } } if (!*p) break; if (again) { again = 0; skip = 0; continue; } if (*p == '<') skip = 1; else if (*p == '>') skip = 0; else if (p[0] == '\n' && p[1]) av_bprintf(buf, "\\N"); else if (!skip && *p != '\r') av_bprint_chars(buf, *p, 1); p++; } return 0; }
{ "code": [ " int i, again, skip = 0;" ], "line_no": [ 5 ] }
static int FUNC_0(AVBPrint *VAR_0, const char *VAR_1) { int VAR_2, VAR_3, VAR_4 = 0; while (*VAR_1) { for (VAR_2 = 0; VAR_2 < FF_ARRAY_ELEMS(webvtt_tag_replace); VAR_2++) { const char *from = webvtt_tag_replace[VAR_2].from; const size_t len = strlen(from); if (!strncmp(VAR_1, from, len)) { av_bprintf(VAR_0, "%s", webvtt_tag_replace[VAR_2].to); VAR_1 += len; VAR_3 = 1; break; } } if (!*VAR_1) break; if (VAR_3) { VAR_3 = 0; VAR_4 = 0; continue; } if (*VAR_1 == '<') VAR_4 = 1; else if (*VAR_1 == '>') VAR_4 = 0; else if (VAR_1[0] == '\n' && VAR_1[1]) av_bprintf(VAR_0, "\\N"); else if (!VAR_4 && *VAR_1 != '\r') av_bprint_chars(VAR_0, *VAR_1, 1); VAR_1++; } return 0; }
[ "static int FUNC_0(AVBPrint *VAR_0, const char *VAR_1)\n{", "int VAR_2, VAR_3, VAR_4 = 0;", "while (*VAR_1) {", "for (VAR_2 = 0; VAR_2 < FF_ARRAY_ELEMS(webvtt_tag_replace); VAR_2++) {", "const char *from = webvtt_tag_replace[VAR_2].from;", "const size_t len = strlen(from);", "if (!strncmp(VAR_1, from, len)) {", "av_bprintf(VAR_0, \"%s\", webvtt_tag_replace[VAR_2].to);", "VAR_1 += len;", "VAR_3 = 1;", "break;", "}", "}", "if (!*VAR_1)\nbreak;", "if (VAR_3) {", "VAR_3 = 0;", "VAR_4 = 0;", "continue;", "}", "if (*VAR_1 == '<')\nVAR_4 = 1;", "else if (*VAR_1 == '>')\nVAR_4 = 0;", "else if (VAR_1[0] == '\\n' && VAR_1[1])\nav_bprintf(VAR_0, \"\\\\N\");", "else if (!VAR_4 && *VAR_1 != '\\r')\nav_bprint_chars(VAR_0, *VAR_1, 1);", "VAR_1++;", "}", "return 0;", "}" ]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33, 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49, 51 ], [ 53, 55 ], [ 57, 59 ], [ 61, 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ] ]
11,335
static int nuv_probe(AVProbeData *p) { if (p->buf_size < 12) return 0; if (!memcmp(p->buf, "NuppelVideo", 12)) return AVPROBE_SCORE_MAX; if (!memcmp(p->buf, "MythTVVideo", 12)) return AVPROBE_SCORE_MAX; return 0; }
false
FFmpeg
87e8788680e16c51f6048af26f3f7830c35207a5
static int nuv_probe(AVProbeData *p) { if (p->buf_size < 12) return 0; if (!memcmp(p->buf, "NuppelVideo", 12)) return AVPROBE_SCORE_MAX; if (!memcmp(p->buf, "MythTVVideo", 12)) return AVPROBE_SCORE_MAX; return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVProbeData *VAR_0) { if (VAR_0->buf_size < 12) return 0; if (!memcmp(VAR_0->buf, "NuppelVideo", 12)) return AVPROBE_SCORE_MAX; if (!memcmp(VAR_0->buf, "MythTVVideo", 12)) return AVPROBE_SCORE_MAX; return 0; }
[ "static int FUNC_0(AVProbeData *VAR_0) {", "if (VAR_0->buf_size < 12)\nreturn 0;", "if (!memcmp(VAR_0->buf, \"NuppelVideo\", 12))\nreturn AVPROBE_SCORE_MAX;", "if (!memcmp(VAR_0->buf, \"MythTVVideo\", 12))\nreturn AVPROBE_SCORE_MAX;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1 ], [ 3, 5 ], [ 7, 9 ], [ 11, 13 ], [ 15 ], [ 17 ] ]
11,336
void cache_fini(PageCache *cache) { int64_t i; g_assert(cache); g_assert(cache->page_cache); for (i = 0; i < cache->max_num_items; i++) { g_free(cache->page_cache[i].it_data); } g_free(cache->page_cache); cache->page_cache = NULL; }
true
qemu
4380be0e997284159e634100d2f5ec87f944d74d
void cache_fini(PageCache *cache) { int64_t i; g_assert(cache); g_assert(cache->page_cache); for (i = 0; i < cache->max_num_items; i++) { g_free(cache->page_cache[i].it_data); } g_free(cache->page_cache); cache->page_cache = NULL; }
{ "code": [], "line_no": [] }
void FUNC_0(PageCache *VAR_0) { int64_t i; g_assert(VAR_0); g_assert(VAR_0->page_cache); for (i = 0; i < VAR_0->max_num_items; i++) { g_free(VAR_0->page_cache[i].it_data); } g_free(VAR_0->page_cache); VAR_0->page_cache = NULL; }
[ "void FUNC_0(PageCache *VAR_0)\n{", "int64_t i;", "g_assert(VAR_0);", "g_assert(VAR_0->page_cache);", "for (i = 0; i < VAR_0->max_num_items; i++) {", "g_free(VAR_0->page_cache[i].it_data);", "}", "g_free(VAR_0->page_cache);", "VAR_0->page_cache = NULL;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 28 ] ]
11,337
int ff_rate_control_init(MpegEncContext *s) { RateControlContext *rcc= &s->rc_context; int i; const char *error = NULL; static const char * const const_names[]={ "PI", "E", "iTex", "pTex", "tex", "mv", "fCode", "iCount", "mcVar", "var", "isI", "isP", "isB", "avgQP", "qComp", /* "lastIQP", "lastPQP", "lastBQP", "nextNonBQP",*/ "avgIITex", "avgPITex", "avgPPTex", "avgBPTex", "avgTex", NULL }; static double (*func1[])(void *, double)={ (void *)bits2qp, (void *)qp2bits, NULL }; static const char * const func1_names[]={ "bits2qp", "qp2bits", NULL }; emms_c(); rcc->rc_eq_eval = ff_parse(s->avctx->rc_eq, const_names, func1, func1_names, NULL, NULL, &error); if (!rcc->rc_eq_eval) { av_log(s->avctx, AV_LOG_ERROR, "Error parsing rc_eq \"%s\": %s\n", s->avctx->rc_eq, error? error : ""); return -1; } for(i=0; i<5; i++){ rcc->pred[i].coeff= FF_QP2LAMBDA * 7.0; rcc->pred[i].count= 1.0; rcc->pred[i].decay= 0.4; rcc->i_cplx_sum [i]= rcc->p_cplx_sum [i]= rcc->mv_bits_sum[i]= rcc->qscale_sum [i]= rcc->frame_count[i]= 1; // 1 is better because of 1/0 and such rcc->last_qscale_for[i]=FF_QP2LAMBDA * 5; } rcc->buffer_index= s->avctx->rc_initial_buffer_occupancy; if(s->flags&CODEC_FLAG_PASS2){ int i; char *p; /* find number of pics */ p= s->avctx->stats_in; for(i=-1; p; i++){ p= strchr(p+1, ';'); } i+= s->max_b_frames; if(i<=0 || i>=INT_MAX / sizeof(RateControlEntry)) return -1; rcc->entry = av_mallocz(i*sizeof(RateControlEntry)); rcc->num_entries= i; /* init all to skipped p frames (with b frames we might have a not encoded frame at the end FIXME) */ for(i=0; i<rcc->num_entries; i++){ RateControlEntry *rce= &rcc->entry[i]; rce->pict_type= rce->new_pict_type=FF_P_TYPE; rce->qscale= rce->new_qscale=FF_QP2LAMBDA * 2; rce->misc_bits= s->mb_num + 10; rce->mb_var_sum= s->mb_num*100; } /* read stats */ p= s->avctx->stats_in; for(i=0; i<rcc->num_entries - s->max_b_frames; i++){ RateControlEntry *rce; int picture_number; int e; char *next; next= strchr(p, ';'); if(next){ (*next)=0; //sscanf in unbelievably slow on looong strings //FIXME copy / do not write next++; } e= sscanf(p, " in:%d ", &picture_number); assert(picture_number >= 0); assert(picture_number < rcc->num_entries); rce= &rcc->entry[picture_number]; e+=sscanf(p, " in:%*d out:%*d type:%d q:%f itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%d var:%d icount:%d skipcount:%d hbits:%d", &rce->pict_type, &rce->qscale, &rce->i_tex_bits, &rce->p_tex_bits, &rce->mv_bits, &rce->misc_bits, &rce->f_code, &rce->b_code, &rce->mc_mb_var_sum, &rce->mb_var_sum, &rce->i_count, &rce->skip_count, &rce->header_bits); if(e!=14){ av_log(s->avctx, AV_LOG_ERROR, "statistics are damaged at line %d, parser out=%d\n", i, e); return -1; } p= next; } if(init_pass2(s) < 0) return -1; //FIXME maybe move to end if((s->flags&CODEC_FLAG_PASS2) && s->avctx->rc_strategy == FF_RC_STRATEGY_XVID) { #ifdef CONFIG_LIBXVID return ff_xvid_rate_control_init(s); #else av_log(s->avctx, AV_LOG_ERROR, "Xvid ratecontrol requires libavcodec compiled with Xvid support.\n"); return -1; #endif } } if(!(s->flags&CODEC_FLAG_PASS2)){ rcc->short_term_qsum=0.001; rcc->short_term_qcount=0.001; rcc->pass1_rc_eq_output_sum= 0.001; rcc->pass1_wanted_bits=0.001; if(s->avctx->qblur > 1.0){ av_log(s->avctx, AV_LOG_ERROR, "qblur too large\n"); return -1; } /* init stuff with the user specified complexity */ if(s->avctx->rc_initial_cplx){ for(i=0; i<60*30; i++){ double bits= s->avctx->rc_initial_cplx * (i/10000.0 + 1.0)*s->mb_num; RateControlEntry rce; double q; if (i%((s->gop_size+3)/4)==0) rce.pict_type= FF_I_TYPE; else if(i%(s->max_b_frames+1)) rce.pict_type= FF_B_TYPE; else rce.pict_type= FF_P_TYPE; rce.new_pict_type= rce.pict_type; rce.mc_mb_var_sum= bits*s->mb_num/100000; rce.mb_var_sum = s->mb_num; rce.qscale = FF_QP2LAMBDA * 2; rce.f_code = 2; rce.b_code = 1; rce.misc_bits= 1; if(s->pict_type== FF_I_TYPE){ rce.i_count = s->mb_num; rce.i_tex_bits= bits; rce.p_tex_bits= 0; rce.mv_bits= 0; }else{ rce.i_count = 0; //FIXME we do know this approx rce.i_tex_bits= 0; rce.p_tex_bits= bits*0.9; rce.mv_bits= bits*0.1; } rcc->i_cplx_sum [rce.pict_type] += rce.i_tex_bits*rce.qscale; rcc->p_cplx_sum [rce.pict_type] += rce.p_tex_bits*rce.qscale; rcc->mv_bits_sum[rce.pict_type] += rce.mv_bits; rcc->frame_count[rce.pict_type] ++; bits= rce.i_tex_bits + rce.p_tex_bits; q= get_qscale(s, &rce, rcc->pass1_wanted_bits/rcc->pass1_rc_eq_output_sum, i); rcc->pass1_wanted_bits+= s->bit_rate/(1/av_q2d(s->avctx->time_base)); //FIXME misbehaves a little for variable fps } } } return 0; }
true
FFmpeg
3cffbe090a5168dcfe580de8d662a32e7ad1d911
int ff_rate_control_init(MpegEncContext *s) { RateControlContext *rcc= &s->rc_context; int i; const char *error = NULL; static const char * const const_names[]={ "PI", "E", "iTex", "pTex", "tex", "mv", "fCode", "iCount", "mcVar", "var", "isI", "isP", "isB", "avgQP", "qComp", "avgIITex", "avgPITex", "avgPPTex", "avgBPTex", "avgTex", NULL }; static double (*func1[])(void *, double)={ (void *)bits2qp, (void *)qp2bits, NULL }; static const char * const func1_names[]={ "bits2qp", "qp2bits", NULL }; emms_c(); rcc->rc_eq_eval = ff_parse(s->avctx->rc_eq, const_names, func1, func1_names, NULL, NULL, &error); if (!rcc->rc_eq_eval) { av_log(s->avctx, AV_LOG_ERROR, "Error parsing rc_eq \"%s\": %s\n", s->avctx->rc_eq, error? error : ""); return -1; } for(i=0; i<5; i++){ rcc->pred[i].coeff= FF_QP2LAMBDA * 7.0; rcc->pred[i].count= 1.0; rcc->pred[i].decay= 0.4; rcc->i_cplx_sum [i]= rcc->p_cplx_sum [i]= rcc->mv_bits_sum[i]= rcc->qscale_sum [i]= rcc->frame_count[i]= 1; rcc->last_qscale_for[i]=FF_QP2LAMBDA * 5; } rcc->buffer_index= s->avctx->rc_initial_buffer_occupancy; if(s->flags&CODEC_FLAG_PASS2){ int i; char *p; p= s->avctx->stats_in; for(i=-1; p; i++){ p= strchr(p+1, ';'); } i+= s->max_b_frames; if(i<=0 || i>=INT_MAX / sizeof(RateControlEntry)) return -1; rcc->entry = av_mallocz(i*sizeof(RateControlEntry)); rcc->num_entries= i; for(i=0; i<rcc->num_entries; i++){ RateControlEntry *rce= &rcc->entry[i]; rce->pict_type= rce->new_pict_type=FF_P_TYPE; rce->qscale= rce->new_qscale=FF_QP2LAMBDA * 2; rce->misc_bits= s->mb_num + 10; rce->mb_var_sum= s->mb_num*100; } p= s->avctx->stats_in; for(i=0; i<rcc->num_entries - s->max_b_frames; i++){ RateControlEntry *rce; int picture_number; int e; char *next; next= strchr(p, ';'); if(next){ (*next)=0; next++; } e= sscanf(p, " in:%d ", &picture_number); assert(picture_number >= 0); assert(picture_number < rcc->num_entries); rce= &rcc->entry[picture_number]; e+=sscanf(p, " in:%*d out:%*d type:%d q:%f itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%d var:%d icount:%d skipcount:%d hbits:%d", &rce->pict_type, &rce->qscale, &rce->i_tex_bits, &rce->p_tex_bits, &rce->mv_bits, &rce->misc_bits, &rce->f_code, &rce->b_code, &rce->mc_mb_var_sum, &rce->mb_var_sum, &rce->i_count, &rce->skip_count, &rce->header_bits); if(e!=14){ av_log(s->avctx, AV_LOG_ERROR, "statistics are damaged at line %d, parser out=%d\n", i, e); return -1; } p= next; } if(init_pass2(s) < 0) return -1; if((s->flags&CODEC_FLAG_PASS2) && s->avctx->rc_strategy == FF_RC_STRATEGY_XVID) { #ifdef CONFIG_LIBXVID return ff_xvid_rate_control_init(s); #else av_log(s->avctx, AV_LOG_ERROR, "Xvid ratecontrol requires libavcodec compiled with Xvid support.\n"); return -1; #endif } } if(!(s->flags&CODEC_FLAG_PASS2)){ rcc->short_term_qsum=0.001; rcc->short_term_qcount=0.001; rcc->pass1_rc_eq_output_sum= 0.001; rcc->pass1_wanted_bits=0.001; if(s->avctx->qblur > 1.0){ av_log(s->avctx, AV_LOG_ERROR, "qblur too large\n"); return -1; } if(s->avctx->rc_initial_cplx){ for(i=0; i<60*30; i++){ double bits= s->avctx->rc_initial_cplx * (i/10000.0 + 1.0)*s->mb_num; RateControlEntry rce; double q; if (i%((s->gop_size+3)/4)==0) rce.pict_type= FF_I_TYPE; else if(i%(s->max_b_frames+1)) rce.pict_type= FF_B_TYPE; else rce.pict_type= FF_P_TYPE; rce.new_pict_type= rce.pict_type; rce.mc_mb_var_sum= bits*s->mb_num/100000; rce.mb_var_sum = s->mb_num; rce.qscale = FF_QP2LAMBDA * 2; rce.f_code = 2; rce.b_code = 1; rce.misc_bits= 1; if(s->pict_type== FF_I_TYPE){ rce.i_count = s->mb_num; rce.i_tex_bits= bits; rce.p_tex_bits= 0; rce.mv_bits= 0; }else{ rce.i_count = 0; rce.i_tex_bits= 0; rce.p_tex_bits= bits*0.9; rce.mv_bits= bits*0.1; } rcc->i_cplx_sum [rce.pict_type] += rce.i_tex_bits*rce.qscale; rcc->p_cplx_sum [rce.pict_type] += rce.p_tex_bits*rce.qscale; rcc->mv_bits_sum[rce.pict_type] += rce.mv_bits; rcc->frame_count[rce.pict_type] ++; bits= rce.i_tex_bits + rce.p_tex_bits; q= get_qscale(s, &rce, rcc->pass1_wanted_bits/rcc->pass1_rc_eq_output_sum, i); rcc->pass1_wanted_bits+= s->bit_rate/(1/av_q2d(s->avctx->time_base)); } } } return 0; }
{ "code": [ " rcc->rc_eq_eval = ff_parse(s->avctx->rc_eq, const_names, func1, func1_names, NULL, NULL, &error);" ], "line_no": [ 89 ] }
VAR_6intVAR_6 VAR_6ff_rate_control_initVAR_6(VAR_6MpegEncContextVAR_6 *VAR_6VAR_0VAR_6) { VAR_6RateControlContextVAR_6 *VAR_6rccVAR_6= &VAR_6VAR_0VAR_6->VAR_6rc_contextVAR_6; VAR_6intVAR_6 VAR_6VAR_7VAR_6; VAR_6constVAR_6 VAR_6charVAR_6 *VAR_6VAR_2VAR_6 = VAR_6NULLVAR_6; VAR_6staticVAR_6 VAR_6constVAR_6 VAR_6charVAR_6 * VAR_6constVAR_6 VAR_6VAR_3VAR_6[]={ "VAR_6PIVAR_6", "VAR_6EVAR_6", "VAR_6iTexVAR_6", "VAR_6pTexVAR_6", "VAR_6texVAR_6", "VAR_6mvVAR_6", "VAR_6fCodeVAR_6", "VAR_6iCountVAR_6", "VAR_6mcVarVAR_6", "VAR_6varVAR_6", "VAR_6isIVAR_6", "VAR_6isPVAR_6", "VAR_6isBVAR_6", "VAR_6avgQPVAR_6", "VAR_6qCompVAR_6", "VAR_6avgIITexVAR_6", "VAR_6avgPITexVAR_6", "VAR_6avgPPTexVAR_6", "VAR_6avgBPTexVAR_6", "VAR_6avgTexVAR_6", VAR_6NULLVAR_6 }; VAR_6staticVAR_6 VAR_6doubleVAR_6 (*VAR_6VAR_4VAR_6[])(VAR_6voidVAR_6 *, VAR_6doubleVAR_6)={ (VAR_6voidVAR_6 *)VAR_6bits2qpVAR_6, (VAR_6voidVAR_6 *)VAR_6qp2bitsVAR_6, VAR_6NULLVAR_6 }; VAR_6staticVAR_6 VAR_6constVAR_6 VAR_6charVAR_6 * VAR_6constVAR_6 VAR_6func1_namesVAR_6[]={ "VAR_6bits2qpVAR_6", "VAR_6qp2bitsVAR_6", VAR_6NULLVAR_6 }; VAR_6emms_cVAR_6(); VAR_6rccVAR_6->VAR_6rc_eq_evalVAR_6 = VAR_6ff_parseVAR_6(VAR_6VAR_0VAR_6->VAR_6avctxVAR_6->VAR_6rc_eqVAR_6, VAR_6VAR_3VAR_6, VAR_6VAR_4VAR_6, VAR_6func1_namesVAR_6, VAR_6NULLVAR_6, VAR_6NULLVAR_6, &VAR_6VAR_2VAR_6); VAR_6ifVAR_6 (!VAR_6rccVAR_6->VAR_6rc_eq_evalVAR_6) { VAR_6av_logVAR_6(VAR_6VAR_0VAR_6->VAR_6avctxVAR_6, VAR_6AV_LOG_ERRORVAR_6, "VAR_6ErrorVAR_6 VAR_6parsingVAR_6 VAR_6rc_eqVAR_6 \"%VAR_6VAR_0VAR_6\": %VAR_6VAR_0VAR_6\VAR_6nVAR_6", VAR_6VAR_0VAR_6->VAR_6avctxVAR_6->VAR_6rc_eqVAR_6, VAR_6VAR_2VAR_6? VAR_6VAR_2VAR_6 : ""); VAR_6returnVAR_6 -VAR_61VAR_6; } VAR_6forVAR_6(VAR_6VAR_7VAR_6=VAR_60VAR_6; VAR_6VAR_7VAR_6<VAR_65VAR_6; VAR_6VAR_7VAR_6++){ VAR_6rccVAR_6->VAR_6predVAR_6[VAR_6VAR_7VAR_6].VAR_6coeffVAR_6= VAR_6FF_QP2LAMBDAVAR_6 * VAR_67VAR_6.VAR_60VAR_6; VAR_6rccVAR_6->VAR_6predVAR_6[VAR_6VAR_7VAR_6].VAR_6countVAR_6= VAR_61VAR_6.VAR_60VAR_6; VAR_6rccVAR_6->VAR_6predVAR_6[VAR_6VAR_7VAR_6].VAR_6decayVAR_6= VAR_60VAR_6.VAR_64VAR_6; VAR_6rccVAR_6->VAR_6i_cplx_sumVAR_6 [VAR_6VAR_7VAR_6]= VAR_6rccVAR_6->VAR_6p_cplx_sumVAR_6 [VAR_6VAR_7VAR_6]= VAR_6rccVAR_6->VAR_6mv_bits_sumVAR_6[VAR_6VAR_7VAR_6]= VAR_6rccVAR_6->VAR_6qscale_sumVAR_6 [VAR_6VAR_7VAR_6]= VAR_6rccVAR_6->VAR_6frame_countVAR_6[VAR_6VAR_7VAR_6]= VAR_61VAR_6; VAR_6rccVAR_6->VAR_6last_qscale_forVAR_6[VAR_6VAR_7VAR_6]=VAR_6FF_QP2LAMBDAVAR_6 * VAR_65VAR_6; } VAR_6rccVAR_6->VAR_6buffer_indexVAR_6= VAR_6VAR_0VAR_6->VAR_6avctxVAR_6->VAR_6rc_initial_buffer_occupancyVAR_6; VAR_6ifVAR_6(VAR_6VAR_0VAR_6->VAR_6flagsVAR_6&VAR_6CODEC_FLAG_PASS2VAR_6){ VAR_6intVAR_6 VAR_6VAR_7VAR_6; VAR_6charVAR_6 *VAR_6pVAR_6; VAR_6pVAR_6= VAR_6VAR_0VAR_6->VAR_6avctxVAR_6->VAR_6stats_inVAR_6; VAR_6forVAR_6(VAR_6VAR_7VAR_6=-VAR_61VAR_6; VAR_6pVAR_6; VAR_6VAR_7VAR_6++){ VAR_6pVAR_6= VAR_6strchrVAR_6(VAR_6pVAR_6+VAR_61VAR_6, ';'); } VAR_6VAR_7VAR_6+= VAR_6VAR_0VAR_6->VAR_6max_b_framesVAR_6; VAR_6ifVAR_6(VAR_6VAR_7VAR_6<=VAR_60VAR_6 || VAR_6VAR_7VAR_6>=VAR_6INT_MAXVAR_6 / VAR_6sizeofVAR_6(VAR_6RateControlEntryVAR_6)) VAR_6returnVAR_6 -VAR_61VAR_6; VAR_6rccVAR_6->VAR_6entryVAR_6 = VAR_6av_malloczVAR_6(VAR_6VAR_7VAR_6*VAR_6sizeofVAR_6(VAR_6RateControlEntryVAR_6)); VAR_6rccVAR_6->VAR_6num_entriesVAR_6= VAR_6VAR_7VAR_6; VAR_6forVAR_6(VAR_6VAR_7VAR_6=VAR_60VAR_6; VAR_6VAR_7VAR_6<VAR_6rccVAR_6->VAR_6num_entriesVAR_6; VAR_6VAR_7VAR_6++){ VAR_6RateControlEntryVAR_6 *VAR_6rceVAR_6= &VAR_6rccVAR_6->VAR_6entryVAR_6[VAR_6VAR_7VAR_6]; VAR_6rceVAR_6->VAR_6pict_typeVAR_6= VAR_6rceVAR_6->VAR_6new_pict_typeVAR_6=VAR_6FF_P_TYPEVAR_6; VAR_6rceVAR_6->VAR_6qscaleVAR_6= VAR_6rceVAR_6->VAR_6new_qscaleVAR_6=VAR_6FF_QP2LAMBDAVAR_6 * VAR_62VAR_6; VAR_6rceVAR_6->VAR_6misc_bitsVAR_6= VAR_6VAR_0VAR_6->VAR_6mb_numVAR_6 + VAR_610VAR_6; VAR_6rceVAR_6->VAR_6mb_var_sumVAR_6= VAR_6VAR_0VAR_6->VAR_6mb_numVAR_6*VAR_6100VAR_6; } VAR_6pVAR_6= VAR_6VAR_0VAR_6->VAR_6avctxVAR_6->VAR_6stats_inVAR_6; VAR_6forVAR_6(VAR_6VAR_7VAR_6=VAR_60VAR_6; VAR_6VAR_7VAR_6<VAR_6rccVAR_6->VAR_6num_entriesVAR_6 - VAR_6VAR_0VAR_6->VAR_6max_b_framesVAR_6; VAR_6VAR_7VAR_6++){ VAR_6RateControlEntryVAR_6 *VAR_6rceVAR_6; VAR_6intVAR_6 VAR_6picture_numberVAR_6; VAR_6intVAR_6 VAR_6eVAR_6; VAR_6charVAR_6 *VAR_6nextVAR_6; VAR_6nextVAR_6= VAR_6strchrVAR_6(VAR_6pVAR_6, ';'); VAR_6ifVAR_6(VAR_6nextVAR_6){ (*VAR_6nextVAR_6)=VAR_60VAR_6; VAR_6nextVAR_6++; } VAR_6eVAR_6= VAR_6sscanfVAR_6(VAR_6pVAR_6, " VAR_6inVAR_6:%VAR_6dVAR_6 ", &VAR_6picture_numberVAR_6); VAR_6assertVAR_6(VAR_6picture_numberVAR_6 >= VAR_60VAR_6); VAR_6assertVAR_6(VAR_6picture_numberVAR_6 < VAR_6rccVAR_6->VAR_6num_entriesVAR_6); VAR_6rceVAR_6= &VAR_6rccVAR_6->VAR_6entryVAR_6[VAR_6picture_numberVAR_6]; VAR_6eVAR_6+=VAR_6sscanfVAR_6(VAR_6pVAR_6, " VAR_6inVAR_6:%*VAR_6dVAR_6 VAR_6outVAR_6:%*VAR_6dVAR_6 VAR_6typeVAR_6:%VAR_6dVAR_6 VAR_6qVAR_6:%VAR_6fVAR_6 VAR_6itexVAR_6:%VAR_6dVAR_6 VAR_6ptexVAR_6:%VAR_6dVAR_6 VAR_6mvVAR_6:%VAR_6dVAR_6 VAR_6miscVAR_6:%VAR_6dVAR_6 VAR_6fcodeVAR_6:%VAR_6dVAR_6 VAR_6bcodeVAR_6:%VAR_6dVAR_6 VAR_6mcVAR_6-VAR_6varVAR_6:%VAR_6dVAR_6 VAR_6varVAR_6:%VAR_6dVAR_6 VAR_6icountVAR_6:%VAR_6dVAR_6 VAR_6skipcountVAR_6:%VAR_6dVAR_6 VAR_6hbitsVAR_6:%VAR_6dVAR_6", &VAR_6rceVAR_6->VAR_6pict_typeVAR_6, &VAR_6rceVAR_6->VAR_6qscaleVAR_6, &VAR_6rceVAR_6->VAR_6i_tex_bitsVAR_6, &VAR_6rceVAR_6->VAR_6p_tex_bitsVAR_6, &VAR_6rceVAR_6->VAR_6mv_bitsVAR_6, &VAR_6rceVAR_6->VAR_6misc_bitsVAR_6, &VAR_6rceVAR_6->VAR_6f_codeVAR_6, &VAR_6rceVAR_6->VAR_6b_codeVAR_6, &VAR_6rceVAR_6->VAR_6mc_mb_var_sumVAR_6, &VAR_6rceVAR_6->VAR_6mb_var_sumVAR_6, &VAR_6rceVAR_6->VAR_6i_countVAR_6, &VAR_6rceVAR_6->VAR_6skip_countVAR_6, &VAR_6rceVAR_6->VAR_6header_bitsVAR_6); VAR_6ifVAR_6(VAR_6eVAR_6!=VAR_614VAR_6){ VAR_6av_logVAR_6(VAR_6VAR_0VAR_6->VAR_6avctxVAR_6, VAR_6AV_LOG_ERRORVAR_6, "VAR_6statisticsVAR_6 VAR_6areVAR_6 VAR_6damagedVAR_6 VAR_6atVAR_6 VAR_6lineVAR_6 %VAR_6dVAR_6, VAR_6parserVAR_6 VAR_6outVAR_6=%VAR_6dVAR_6\VAR_6nVAR_6", VAR_6VAR_7VAR_6, VAR_6eVAR_6); VAR_6returnVAR_6 -VAR_61VAR_6; } VAR_6pVAR_6= VAR_6nextVAR_6; } VAR_6ifVAR_6(VAR_6init_pass2VAR_6(VAR_6VAR_0VAR_6) < VAR_60VAR_6) VAR_6returnVAR_6 -VAR_61VAR_6; VAR_6ifVAR_6((VAR_6VAR_0VAR_6->VAR_6flagsVAR_6&VAR_6CODEC_FLAG_PASS2VAR_6) && VAR_6VAR_0VAR_6->VAR_6avctxVAR_6->VAR_6rc_strategyVAR_6 == VAR_6FF_RC_STRATEGY_XVIDVAR_6) { #VAR_6ifdefVAR_6 VAR_6CONFIG_LIBXVIDVAR_6 VAR_6returnVAR_6 VAR_6ff_xvid_rate_control_initVAR_6(VAR_6VAR_0VAR_6); #VAR_6elseVAR_6 VAR_6av_logVAR_6(VAR_6VAR_0VAR_6->VAR_6avctxVAR_6, VAR_6AV_LOG_ERRORVAR_6, "VAR_6XvidVAR_6 VAR_6ratecontrolVAR_6 VAR_6requiresVAR_6 VAR_6libavcodecVAR_6 VAR_6compiledVAR_6 VAR_6withVAR_6 VAR_6XvidVAR_6 VAR_6supportVAR_6.\VAR_6nVAR_6"); VAR_6returnVAR_6 -VAR_61VAR_6; #VAR_6endifVAR_6 } } VAR_6ifVAR_6(!(VAR_6VAR_0VAR_6->VAR_6flagsVAR_6&VAR_6CODEC_FLAG_PASS2VAR_6)){ VAR_6rccVAR_6->VAR_6short_term_qsumVAR_6=VAR_60VAR_6.VAR_6001VAR_6; VAR_6rccVAR_6->VAR_6short_term_qcountVAR_6=VAR_60VAR_6.VAR_6001VAR_6; VAR_6rccVAR_6->VAR_6pass1_rc_eq_output_sumVAR_6= VAR_60VAR_6.VAR_6001VAR_6; VAR_6rccVAR_6->VAR_6pass1_wanted_bitsVAR_6=VAR_60VAR_6.VAR_6001VAR_6; VAR_6ifVAR_6(VAR_6VAR_0VAR_6->VAR_6avctxVAR_6->VAR_6qblurVAR_6 > VAR_61VAR_6.VAR_60VAR_6){ VAR_6av_logVAR_6(VAR_6VAR_0VAR_6->VAR_6avctxVAR_6, VAR_6AV_LOG_ERRORVAR_6, "VAR_6qblurVAR_6 VAR_6tooVAR_6 VAR_6largeVAR_6\VAR_6nVAR_6"); VAR_6returnVAR_6 -VAR_61VAR_6; } VAR_6ifVAR_6(VAR_6VAR_0VAR_6->VAR_6avctxVAR_6->VAR_6rc_initial_cplxVAR_6){ VAR_6forVAR_6(VAR_6VAR_7VAR_6=VAR_60VAR_6; VAR_6VAR_7VAR_6<VAR_660VAR_6*VAR_630VAR_6; VAR_6VAR_7VAR_6++){ VAR_6doubleVAR_6 VAR_6bitsVAR_6= VAR_6VAR_0VAR_6->VAR_6avctxVAR_6->VAR_6rc_initial_cplxVAR_6 * (VAR_6VAR_7VAR_6/VAR_610000VAR_6.VAR_60VAR_6 + VAR_61VAR_6.VAR_60VAR_6)*VAR_6VAR_0VAR_6->VAR_6mb_numVAR_6; VAR_6RateControlEntryVAR_6 VAR_6rceVAR_6; VAR_6doubleVAR_6 VAR_6qVAR_6; VAR_6ifVAR_6 (VAR_6VAR_7VAR_6%((VAR_6VAR_0VAR_6->VAR_6gop_sizeVAR_6+VAR_63VAR_6)/VAR_64VAR_6)==VAR_60VAR_6) VAR_6rceVAR_6.VAR_6pict_typeVAR_6= VAR_6FF_I_TYPEVAR_6; VAR_6elseVAR_6 VAR_6ifVAR_6(VAR_6VAR_7VAR_6%(VAR_6VAR_0VAR_6->VAR_6max_b_framesVAR_6+VAR_61VAR_6)) VAR_6rceVAR_6.VAR_6pict_typeVAR_6= VAR_6FF_B_TYPEVAR_6; VAR_6elseVAR_6 VAR_6rceVAR_6.VAR_6pict_typeVAR_6= VAR_6FF_P_TYPEVAR_6; VAR_6rceVAR_6.VAR_6new_pict_typeVAR_6= VAR_6rceVAR_6.VAR_6pict_typeVAR_6; VAR_6rceVAR_6.VAR_6mc_mb_var_sumVAR_6= VAR_6bitsVAR_6*VAR_6VAR_0VAR_6->VAR_6mb_numVAR_6/VAR_6100000VAR_6; VAR_6rceVAR_6.VAR_6mb_var_sumVAR_6 = VAR_6VAR_0VAR_6->VAR_6mb_numVAR_6; VAR_6rceVAR_6.VAR_6qscaleVAR_6 = VAR_6FF_QP2LAMBDAVAR_6 * VAR_62VAR_6; VAR_6rceVAR_6.VAR_6f_codeVAR_6 = VAR_62VAR_6; VAR_6rceVAR_6.VAR_6b_codeVAR_6 = VAR_61VAR_6; VAR_6rceVAR_6.VAR_6misc_bitsVAR_6= VAR_61VAR_6; VAR_6ifVAR_6(VAR_6VAR_0VAR_6->VAR_6pict_typeVAR_6== VAR_6FF_I_TYPEVAR_6){ VAR_6rceVAR_6.VAR_6i_countVAR_6 = VAR_6VAR_0VAR_6->VAR_6mb_numVAR_6; VAR_6rceVAR_6.VAR_6i_tex_bitsVAR_6= VAR_6bitsVAR_6; VAR_6rceVAR_6.VAR_6p_tex_bitsVAR_6= VAR_60VAR_6; VAR_6rceVAR_6.VAR_6mv_bitsVAR_6= VAR_60VAR_6; }VAR_6elseVAR_6{ VAR_6rceVAR_6.VAR_6i_countVAR_6 = VAR_60VAR_6; VAR_6rceVAR_6.VAR_6i_tex_bitsVAR_6= VAR_60VAR_6; VAR_6rceVAR_6.VAR_6p_tex_bitsVAR_6= VAR_6bitsVAR_6*VAR_60VAR_6.VAR_69VAR_6; VAR_6rceVAR_6.VAR_6mv_bitsVAR_6= VAR_6bitsVAR_6*VAR_60VAR_6.VAR_61VAR_6; } VAR_6rccVAR_6->VAR_6i_cplx_sumVAR_6 [VAR_6rceVAR_6.VAR_6pict_typeVAR_6] += VAR_6rceVAR_6.VAR_6i_tex_bitsVAR_6*VAR_6rceVAR_6.VAR_6qscaleVAR_6; VAR_6rccVAR_6->VAR_6p_cplx_sumVAR_6 [VAR_6rceVAR_6.VAR_6pict_typeVAR_6] += VAR_6rceVAR_6.VAR_6p_tex_bitsVAR_6*VAR_6rceVAR_6.VAR_6qscaleVAR_6; VAR_6rccVAR_6->VAR_6mv_bits_sumVAR_6[VAR_6rceVAR_6.VAR_6pict_typeVAR_6] += VAR_6rceVAR_6.VAR_6mv_bitsVAR_6; VAR_6rccVAR_6->VAR_6frame_countVAR_6[VAR_6rceVAR_6.VAR_6pict_typeVAR_6] ++; VAR_6bitsVAR_6= VAR_6rceVAR_6.VAR_6i_tex_bitsVAR_6 + VAR_6rceVAR_6.VAR_6p_tex_bitsVAR_6; VAR_6qVAR_6= VAR_6get_qscaleVAR_6(VAR_6VAR_0VAR_6, &VAR_6rceVAR_6, VAR_6rccVAR_6->VAR_6pass1_wanted_bitsVAR_6/VAR_6rccVAR_6->VAR_6pass1_rc_eq_output_sumVAR_6, VAR_6VAR_7VAR_6); VAR_6rccVAR_6->VAR_6pass1_wanted_bitsVAR_6+= VAR_6VAR_0VAR_6->VAR_6bit_rateVAR_6/(VAR_61VAR_6/VAR_6av_q2dVAR_6(VAR_6VAR_0VAR_6->VAR_6avctxVAR_6->VAR_6time_baseVAR_6)); } } } VAR_6returnVAR_6 VAR_60VAR_6; }
[ "VAR_6intVAR_6 VAR_6ff_rate_control_initVAR_6(VAR_6MpegEncContextVAR_6 *VAR_6VAR_0VAR_6)\n{", "VAR_6RateControlContextVAR_6 *VAR_6rccVAR_6= &VAR_6VAR_0VAR_6->VAR_6rc_contextVAR_6;", "VAR_6intVAR_6 VAR_6VAR_7VAR_6;", "VAR_6constVAR_6 VAR_6charVAR_6 *VAR_6VAR_2VAR_6 = VAR_6NULLVAR_6;", "VAR_6staticVAR_6 VAR_6constVAR_6 VAR_6charVAR_6 * VAR_6constVAR_6 VAR_6VAR_3VAR_6[]={", "\"VAR_6PIVAR_6\",\n\"VAR_6EVAR_6\",\n\"VAR_6iTexVAR_6\",\n\"VAR_6pTexVAR_6\",\n\"VAR_6texVAR_6\",\n\"VAR_6mvVAR_6\",\n\"VAR_6fCodeVAR_6\",\n\"VAR_6iCountVAR_6\",\n\"VAR_6mcVarVAR_6\",\n\"VAR_6varVAR_6\",\n\"VAR_6isIVAR_6\",\n\"VAR_6isPVAR_6\",\n\"VAR_6isBVAR_6\",\n\"VAR_6avgQPVAR_6\",\n\"VAR_6qCompVAR_6\",\n\"VAR_6avgIITexVAR_6\",\n\"VAR_6avgPITexVAR_6\",\n\"VAR_6avgPPTexVAR_6\",\n\"VAR_6avgBPTexVAR_6\",\n\"VAR_6avgTexVAR_6\",\nVAR_6NULLVAR_6\n};", "VAR_6staticVAR_6 VAR_6doubleVAR_6 (*VAR_6VAR_4VAR_6[])(VAR_6voidVAR_6 *, VAR_6doubleVAR_6)={", "(VAR_6voidVAR_6 *)VAR_6bits2qpVAR_6,\n(VAR_6voidVAR_6 *)VAR_6qp2bitsVAR_6,\nVAR_6NULLVAR_6\n};", "VAR_6staticVAR_6 VAR_6constVAR_6 VAR_6charVAR_6 * VAR_6constVAR_6 VAR_6func1_namesVAR_6[]={", "\"VAR_6bits2qpVAR_6\",\n\"VAR_6qp2bitsVAR_6\",\nVAR_6NULLVAR_6\n};", "VAR_6emms_cVAR_6();", "VAR_6rccVAR_6->VAR_6rc_eq_evalVAR_6 = VAR_6ff_parseVAR_6(VAR_6VAR_0VAR_6->VAR_6avctxVAR_6->VAR_6rc_eqVAR_6, VAR_6VAR_3VAR_6, VAR_6VAR_4VAR_6, VAR_6func1_namesVAR_6, VAR_6NULLVAR_6, VAR_6NULLVAR_6, &VAR_6VAR_2VAR_6);", "VAR_6ifVAR_6 (!VAR_6rccVAR_6->VAR_6rc_eq_evalVAR_6) {", "VAR_6av_logVAR_6(VAR_6VAR_0VAR_6->VAR_6avctxVAR_6, VAR_6AV_LOG_ERRORVAR_6, \"VAR_6ErrorVAR_6 VAR_6parsingVAR_6 VAR_6rc_eqVAR_6 \\\"%VAR_6VAR_0VAR_6\\\": %VAR_6VAR_0VAR_6\\VAR_6nVAR_6\", VAR_6VAR_0VAR_6->VAR_6avctxVAR_6->VAR_6rc_eqVAR_6, VAR_6VAR_2VAR_6? VAR_6VAR_2VAR_6 : \"\");", "VAR_6returnVAR_6 -VAR_61VAR_6;", "}", "VAR_6forVAR_6(VAR_6VAR_7VAR_6=VAR_60VAR_6; VAR_6VAR_7VAR_6<VAR_65VAR_6; VAR_6VAR_7VAR_6++){", "VAR_6rccVAR_6->VAR_6predVAR_6[VAR_6VAR_7VAR_6].VAR_6coeffVAR_6= VAR_6FF_QP2LAMBDAVAR_6 * VAR_67VAR_6.VAR_60VAR_6;", "VAR_6rccVAR_6->VAR_6predVAR_6[VAR_6VAR_7VAR_6].VAR_6countVAR_6= VAR_61VAR_6.VAR_60VAR_6;", "VAR_6rccVAR_6->VAR_6predVAR_6[VAR_6VAR_7VAR_6].VAR_6decayVAR_6= VAR_60VAR_6.VAR_64VAR_6;", "VAR_6rccVAR_6->VAR_6i_cplx_sumVAR_6 [VAR_6VAR_7VAR_6]=\nVAR_6rccVAR_6->VAR_6p_cplx_sumVAR_6 [VAR_6VAR_7VAR_6]=\nVAR_6rccVAR_6->VAR_6mv_bits_sumVAR_6[VAR_6VAR_7VAR_6]=\nVAR_6rccVAR_6->VAR_6qscale_sumVAR_6 [VAR_6VAR_7VAR_6]=\nVAR_6rccVAR_6->VAR_6frame_countVAR_6[VAR_6VAR_7VAR_6]= VAR_61VAR_6;", "VAR_6rccVAR_6->VAR_6last_qscale_forVAR_6[VAR_6VAR_7VAR_6]=VAR_6FF_QP2LAMBDAVAR_6 * VAR_65VAR_6;", "}", "VAR_6rccVAR_6->VAR_6buffer_indexVAR_6= VAR_6VAR_0VAR_6->VAR_6avctxVAR_6->VAR_6rc_initial_buffer_occupancyVAR_6;", "VAR_6ifVAR_6(VAR_6VAR_0VAR_6->VAR_6flagsVAR_6&VAR_6CODEC_FLAG_PASS2VAR_6){", "VAR_6intVAR_6 VAR_6VAR_7VAR_6;", "VAR_6charVAR_6 *VAR_6pVAR_6;", "VAR_6pVAR_6= VAR_6VAR_0VAR_6->VAR_6avctxVAR_6->VAR_6stats_inVAR_6;", "VAR_6forVAR_6(VAR_6VAR_7VAR_6=-VAR_61VAR_6; VAR_6pVAR_6; VAR_6VAR_7VAR_6++){", "VAR_6pVAR_6= VAR_6strchrVAR_6(VAR_6pVAR_6+VAR_61VAR_6, ';');", "}", "VAR_6VAR_7VAR_6+= VAR_6VAR_0VAR_6->VAR_6max_b_framesVAR_6;", "VAR_6ifVAR_6(VAR_6VAR_7VAR_6<=VAR_60VAR_6 || VAR_6VAR_7VAR_6>=VAR_6INT_MAXVAR_6 / VAR_6sizeofVAR_6(VAR_6RateControlEntryVAR_6))\nVAR_6returnVAR_6 -VAR_61VAR_6;", "VAR_6rccVAR_6->VAR_6entryVAR_6 = VAR_6av_malloczVAR_6(VAR_6VAR_7VAR_6*VAR_6sizeofVAR_6(VAR_6RateControlEntryVAR_6));", "VAR_6rccVAR_6->VAR_6num_entriesVAR_6= VAR_6VAR_7VAR_6;", "VAR_6forVAR_6(VAR_6VAR_7VAR_6=VAR_60VAR_6; VAR_6VAR_7VAR_6<VAR_6rccVAR_6->VAR_6num_entriesVAR_6; VAR_6VAR_7VAR_6++){", "VAR_6RateControlEntryVAR_6 *VAR_6rceVAR_6= &VAR_6rccVAR_6->VAR_6entryVAR_6[VAR_6VAR_7VAR_6];", "VAR_6rceVAR_6->VAR_6pict_typeVAR_6= VAR_6rceVAR_6->VAR_6new_pict_typeVAR_6=VAR_6FF_P_TYPEVAR_6;", "VAR_6rceVAR_6->VAR_6qscaleVAR_6= VAR_6rceVAR_6->VAR_6new_qscaleVAR_6=VAR_6FF_QP2LAMBDAVAR_6 * VAR_62VAR_6;", "VAR_6rceVAR_6->VAR_6misc_bitsVAR_6= VAR_6VAR_0VAR_6->VAR_6mb_numVAR_6 + VAR_610VAR_6;", "VAR_6rceVAR_6->VAR_6mb_var_sumVAR_6= VAR_6VAR_0VAR_6->VAR_6mb_numVAR_6*VAR_6100VAR_6;", "}", "VAR_6pVAR_6= VAR_6VAR_0VAR_6->VAR_6avctxVAR_6->VAR_6stats_inVAR_6;", "VAR_6forVAR_6(VAR_6VAR_7VAR_6=VAR_60VAR_6; VAR_6VAR_7VAR_6<VAR_6rccVAR_6->VAR_6num_entriesVAR_6 - VAR_6VAR_0VAR_6->VAR_6max_b_framesVAR_6; VAR_6VAR_7VAR_6++){", "VAR_6RateControlEntryVAR_6 *VAR_6rceVAR_6;", "VAR_6intVAR_6 VAR_6picture_numberVAR_6;", "VAR_6intVAR_6 VAR_6eVAR_6;", "VAR_6charVAR_6 *VAR_6nextVAR_6;", "VAR_6nextVAR_6= VAR_6strchrVAR_6(VAR_6pVAR_6, ';');", "VAR_6ifVAR_6(VAR_6nextVAR_6){", "(*VAR_6nextVAR_6)=VAR_60VAR_6;", "VAR_6nextVAR_6++;", "}", "VAR_6eVAR_6= VAR_6sscanfVAR_6(VAR_6pVAR_6, \" VAR_6inVAR_6:%VAR_6dVAR_6 \", &VAR_6picture_numberVAR_6);", "VAR_6assertVAR_6(VAR_6picture_numberVAR_6 >= VAR_60VAR_6);", "VAR_6assertVAR_6(VAR_6picture_numberVAR_6 < VAR_6rccVAR_6->VAR_6num_entriesVAR_6);", "VAR_6rceVAR_6= &VAR_6rccVAR_6->VAR_6entryVAR_6[VAR_6picture_numberVAR_6];", "VAR_6eVAR_6+=VAR_6sscanfVAR_6(VAR_6pVAR_6, \" VAR_6inVAR_6:%*VAR_6dVAR_6 VAR_6outVAR_6:%*VAR_6dVAR_6 VAR_6typeVAR_6:%VAR_6dVAR_6 VAR_6qVAR_6:%VAR_6fVAR_6 VAR_6itexVAR_6:%VAR_6dVAR_6 VAR_6ptexVAR_6:%VAR_6dVAR_6 VAR_6mvVAR_6:%VAR_6dVAR_6 VAR_6miscVAR_6:%VAR_6dVAR_6 VAR_6fcodeVAR_6:%VAR_6dVAR_6 VAR_6bcodeVAR_6:%VAR_6dVAR_6 VAR_6mcVAR_6-VAR_6varVAR_6:%VAR_6dVAR_6 VAR_6varVAR_6:%VAR_6dVAR_6 VAR_6icountVAR_6:%VAR_6dVAR_6 VAR_6skipcountVAR_6:%VAR_6dVAR_6 VAR_6hbitsVAR_6:%VAR_6dVAR_6\",\n&VAR_6rceVAR_6->VAR_6pict_typeVAR_6, &VAR_6rceVAR_6->VAR_6qscaleVAR_6, &VAR_6rceVAR_6->VAR_6i_tex_bitsVAR_6, &VAR_6rceVAR_6->VAR_6p_tex_bitsVAR_6, &VAR_6rceVAR_6->VAR_6mv_bitsVAR_6, &VAR_6rceVAR_6->VAR_6misc_bitsVAR_6,\n&VAR_6rceVAR_6->VAR_6f_codeVAR_6, &VAR_6rceVAR_6->VAR_6b_codeVAR_6, &VAR_6rceVAR_6->VAR_6mc_mb_var_sumVAR_6, &VAR_6rceVAR_6->VAR_6mb_var_sumVAR_6, &VAR_6rceVAR_6->VAR_6i_countVAR_6, &VAR_6rceVAR_6->VAR_6skip_countVAR_6, &VAR_6rceVAR_6->VAR_6header_bitsVAR_6);", "VAR_6ifVAR_6(VAR_6eVAR_6!=VAR_614VAR_6){", "VAR_6av_logVAR_6(VAR_6VAR_0VAR_6->VAR_6avctxVAR_6, VAR_6AV_LOG_ERRORVAR_6, \"VAR_6statisticsVAR_6 VAR_6areVAR_6 VAR_6damagedVAR_6 VAR_6atVAR_6 VAR_6lineVAR_6 %VAR_6dVAR_6, VAR_6parserVAR_6 VAR_6outVAR_6=%VAR_6dVAR_6\\VAR_6nVAR_6\", VAR_6VAR_7VAR_6, VAR_6eVAR_6);", "VAR_6returnVAR_6 -VAR_61VAR_6;", "}", "VAR_6pVAR_6= VAR_6nextVAR_6;", "}", "VAR_6ifVAR_6(VAR_6init_pass2VAR_6(VAR_6VAR_0VAR_6) < VAR_60VAR_6) VAR_6returnVAR_6 -VAR_61VAR_6;", "VAR_6ifVAR_6((VAR_6VAR_0VAR_6->VAR_6flagsVAR_6&VAR_6CODEC_FLAG_PASS2VAR_6) && VAR_6VAR_0VAR_6->VAR_6avctxVAR_6->VAR_6rc_strategyVAR_6 == VAR_6FF_RC_STRATEGY_XVIDVAR_6) {", "#VAR_6ifdefVAR_6 VAR_6CONFIG_LIBXVIDVAR_6\nVAR_6returnVAR_6 VAR_6ff_xvid_rate_control_initVAR_6(VAR_6VAR_0VAR_6);", "#VAR_6elseVAR_6\nVAR_6av_logVAR_6(VAR_6VAR_0VAR_6->VAR_6avctxVAR_6, VAR_6AV_LOG_ERRORVAR_6, \"VAR_6XvidVAR_6 VAR_6ratecontrolVAR_6 VAR_6requiresVAR_6 VAR_6libavcodecVAR_6 VAR_6compiledVAR_6 VAR_6withVAR_6 VAR_6XvidVAR_6 VAR_6supportVAR_6.\\VAR_6nVAR_6\");", "VAR_6returnVAR_6 -VAR_61VAR_6;", "#VAR_6endifVAR_6\n}", "}", "VAR_6ifVAR_6(!(VAR_6VAR_0VAR_6->VAR_6flagsVAR_6&VAR_6CODEC_FLAG_PASS2VAR_6)){", "VAR_6rccVAR_6->VAR_6short_term_qsumVAR_6=VAR_60VAR_6.VAR_6001VAR_6;", "VAR_6rccVAR_6->VAR_6short_term_qcountVAR_6=VAR_60VAR_6.VAR_6001VAR_6;", "VAR_6rccVAR_6->VAR_6pass1_rc_eq_output_sumVAR_6= VAR_60VAR_6.VAR_6001VAR_6;", "VAR_6rccVAR_6->VAR_6pass1_wanted_bitsVAR_6=VAR_60VAR_6.VAR_6001VAR_6;", "VAR_6ifVAR_6(VAR_6VAR_0VAR_6->VAR_6avctxVAR_6->VAR_6qblurVAR_6 > VAR_61VAR_6.VAR_60VAR_6){", "VAR_6av_logVAR_6(VAR_6VAR_0VAR_6->VAR_6avctxVAR_6, VAR_6AV_LOG_ERRORVAR_6, \"VAR_6qblurVAR_6 VAR_6tooVAR_6 VAR_6largeVAR_6\\VAR_6nVAR_6\");", "VAR_6returnVAR_6 -VAR_61VAR_6;", "}", "VAR_6ifVAR_6(VAR_6VAR_0VAR_6->VAR_6avctxVAR_6->VAR_6rc_initial_cplxVAR_6){", "VAR_6forVAR_6(VAR_6VAR_7VAR_6=VAR_60VAR_6; VAR_6VAR_7VAR_6<VAR_660VAR_6*VAR_630VAR_6; VAR_6VAR_7VAR_6++){", "VAR_6doubleVAR_6 VAR_6bitsVAR_6= VAR_6VAR_0VAR_6->VAR_6avctxVAR_6->VAR_6rc_initial_cplxVAR_6 * (VAR_6VAR_7VAR_6/VAR_610000VAR_6.VAR_60VAR_6 + VAR_61VAR_6.VAR_60VAR_6)*VAR_6VAR_0VAR_6->VAR_6mb_numVAR_6;", "VAR_6RateControlEntryVAR_6 VAR_6rceVAR_6;", "VAR_6doubleVAR_6 VAR_6qVAR_6;", "VAR_6ifVAR_6 (VAR_6VAR_7VAR_6%((VAR_6VAR_0VAR_6->VAR_6gop_sizeVAR_6+VAR_63VAR_6)/VAR_64VAR_6)==VAR_60VAR_6) VAR_6rceVAR_6.VAR_6pict_typeVAR_6= VAR_6FF_I_TYPEVAR_6;", "VAR_6elseVAR_6 VAR_6ifVAR_6(VAR_6VAR_7VAR_6%(VAR_6VAR_0VAR_6->VAR_6max_b_framesVAR_6+VAR_61VAR_6)) VAR_6rceVAR_6.VAR_6pict_typeVAR_6= VAR_6FF_B_TYPEVAR_6;", "VAR_6elseVAR_6 VAR_6rceVAR_6.VAR_6pict_typeVAR_6= VAR_6FF_P_TYPEVAR_6;", "VAR_6rceVAR_6.VAR_6new_pict_typeVAR_6= VAR_6rceVAR_6.VAR_6pict_typeVAR_6;", "VAR_6rceVAR_6.VAR_6mc_mb_var_sumVAR_6= VAR_6bitsVAR_6*VAR_6VAR_0VAR_6->VAR_6mb_numVAR_6/VAR_6100000VAR_6;", "VAR_6rceVAR_6.VAR_6mb_var_sumVAR_6 = VAR_6VAR_0VAR_6->VAR_6mb_numVAR_6;", "VAR_6rceVAR_6.VAR_6qscaleVAR_6 = VAR_6FF_QP2LAMBDAVAR_6 * VAR_62VAR_6;", "VAR_6rceVAR_6.VAR_6f_codeVAR_6 = VAR_62VAR_6;", "VAR_6rceVAR_6.VAR_6b_codeVAR_6 = VAR_61VAR_6;", "VAR_6rceVAR_6.VAR_6misc_bitsVAR_6= VAR_61VAR_6;", "VAR_6ifVAR_6(VAR_6VAR_0VAR_6->VAR_6pict_typeVAR_6== VAR_6FF_I_TYPEVAR_6){", "VAR_6rceVAR_6.VAR_6i_countVAR_6 = VAR_6VAR_0VAR_6->VAR_6mb_numVAR_6;", "VAR_6rceVAR_6.VAR_6i_tex_bitsVAR_6= VAR_6bitsVAR_6;", "VAR_6rceVAR_6.VAR_6p_tex_bitsVAR_6= VAR_60VAR_6;", "VAR_6rceVAR_6.VAR_6mv_bitsVAR_6= VAR_60VAR_6;", "}VAR_6elseVAR_6{", "VAR_6rceVAR_6.VAR_6i_countVAR_6 = VAR_60VAR_6;", "VAR_6rceVAR_6.VAR_6i_tex_bitsVAR_6= VAR_60VAR_6;", "VAR_6rceVAR_6.VAR_6p_tex_bitsVAR_6= VAR_6bitsVAR_6*VAR_60VAR_6.VAR_69VAR_6;", "VAR_6rceVAR_6.VAR_6mv_bitsVAR_6= VAR_6bitsVAR_6*VAR_60VAR_6.VAR_61VAR_6;", "}", "VAR_6rccVAR_6->VAR_6i_cplx_sumVAR_6 [VAR_6rceVAR_6.VAR_6pict_typeVAR_6] += VAR_6rceVAR_6.VAR_6i_tex_bitsVAR_6*VAR_6rceVAR_6.VAR_6qscaleVAR_6;", "VAR_6rccVAR_6->VAR_6p_cplx_sumVAR_6 [VAR_6rceVAR_6.VAR_6pict_typeVAR_6] += VAR_6rceVAR_6.VAR_6p_tex_bitsVAR_6*VAR_6rceVAR_6.VAR_6qscaleVAR_6;", "VAR_6rccVAR_6->VAR_6mv_bits_sumVAR_6[VAR_6rceVAR_6.VAR_6pict_typeVAR_6] += VAR_6rceVAR_6.VAR_6mv_bitsVAR_6;", "VAR_6rccVAR_6->VAR_6frame_countVAR_6[VAR_6rceVAR_6.VAR_6pict_typeVAR_6] ++;", "VAR_6bitsVAR_6= VAR_6rceVAR_6.VAR_6i_tex_bitsVAR_6 + VAR_6rceVAR_6.VAR_6p_tex_bitsVAR_6;", "VAR_6qVAR_6= VAR_6get_qscaleVAR_6(VAR_6VAR_0VAR_6, &VAR_6rceVAR_6, VAR_6rccVAR_6->VAR_6pass1_wanted_bitsVAR_6/VAR_6rccVAR_6->VAR_6pass1_rc_eq_output_sumVAR_6, VAR_6VAR_7VAR_6);", "VAR_6rccVAR_6->VAR_6pass1_wanted_bitsVAR_6+= VAR_6VAR_0VAR_6->VAR_6bit_rateVAR_6/(VAR_61VAR_6/VAR_6av_q2dVAR_6(VAR_6VAR_0VAR_6->VAR_6avctxVAR_6->VAR_6time_baseVAR_6));", "}", "}", "}", "VAR_6returnVAR_6 VAR_60VAR_6;", "}" ]
[ 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 51, 53, 55, 57, 59, 61, 63 ], [ 65 ], [ 67, 69, 71, 73 ], [ 75 ], [ 77, 79, 81, 83 ], [ 85 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 101 ], [ 103 ], [ 105 ], [ 109 ], [ 111, 113, 115, 117, 119 ], [ 121 ], [ 123 ], [ 125 ], [ 129 ], [ 131 ], [ 133 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149, 151 ], [ 153 ], [ 155 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 207 ], [ 209 ], [ 211 ], [ 215, 217, 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227 ], [ 231 ], [ 233 ], [ 237 ], [ 243 ], [ 245, 247 ], [ 249, 251 ], [ 253 ], [ 255, 257 ], [ 259 ], [ 263 ], [ 267 ], [ 269 ], [ 273 ], [ 275 ], [ 279 ], [ 281 ], [ 283 ], [ 285 ], [ 289 ], [ 291 ], [ 293 ], [ 295 ], [ 297 ], [ 301 ], [ 303 ], [ 305 ], [ 309 ], [ 311 ], [ 313 ], [ 315 ], [ 317 ], [ 319 ], [ 321 ], [ 325 ], [ 327 ], [ 329 ], [ 331 ], [ 333 ], [ 335 ], [ 337 ], [ 339 ], [ 341 ], [ 343 ], [ 345 ], [ 347 ], [ 349 ], [ 351 ], [ 353 ], [ 357 ], [ 361 ], [ 363 ], [ 365 ], [ 367 ], [ 371 ], [ 375 ], [ 377 ] ]
11,338
static int iec61883_read_header(AVFormatContext *context) { struct iec61883_data *dv = context->priv_data; struct raw1394_portinfo pinf[16]; rom1394_directory rom_dir; char *endptr; int inport; int nb_ports; int port = -1; int response; int i, j = 0; uint64_t guid = 0; dv->input_port = -1; dv->output_port = -1; dv->channel = -1; dv->raw1394 = raw1394_new_handle(); if (!dv->raw1394) { av_log(context, AV_LOG_ERROR, "Failed to open IEEE1394 interface.\n"); return AVERROR(EIO); } if ((nb_ports = raw1394_get_port_info(dv->raw1394, pinf, 16)) < 0) { av_log(context, AV_LOG_ERROR, "Failed to get number of IEEE1394 ports.\n"); goto fail; } inport = strtol(context->filename, &endptr, 10); if (endptr != context->filename && *endptr == '\0') { av_log(context, AV_LOG_INFO, "Selecting IEEE1394 port: %d\n", inport); j = inport; nb_ports = inport + 1; } else if (strcmp(context->filename, "auto")) { av_log(context, AV_LOG_ERROR, "Invalid input \"%s\", you should specify " "\"auto\" for auto-detection, or the port number.\n", context->filename); goto fail; } if (dv->device_guid) { if (sscanf(dv->device_guid, "%llx", (long long unsigned int *)&guid) != 1) { av_log(context, AV_LOG_INFO, "Invalid dvguid parameter: %s\n", dv->device_guid); goto fail; } } for (; j < nb_ports && port==-1; ++j) { raw1394_destroy_handle(dv->raw1394); if (!(dv->raw1394 = raw1394_new_handle_on_port(j))) { av_log(context, AV_LOG_ERROR, "Failed setting IEEE1394 port.\n"); goto fail; } for (i=0; i<raw1394_get_nodecount(dv->raw1394); ++i) { /* Select device explicitly by GUID */ if (guid > 1) { if (guid == rom1394_get_guid(dv->raw1394, i)) { dv->node = i; port = j; break; } } else { /* Select first AV/C tape recorder player node */ if (rom1394_get_directory(dv->raw1394, i, &rom_dir) < 0) continue; if (((rom1394_get_node_type(&rom_dir) == ROM1394_NODE_TYPE_AVC) && avc1394_check_subunit_type(dv->raw1394, i, AVC1394_SUBUNIT_TYPE_VCR)) || (rom_dir.unit_spec_id == MOTDCT_SPEC_ID)) { rom1394_free_directory(&rom_dir); dv->node = i; port = j; break; } rom1394_free_directory(&rom_dir); } } } if (port == -1) { av_log(context, AV_LOG_ERROR, "No AV/C devices found.\n"); goto fail; } /* Provide bus sanity for multiple connections */ iec61883_cmp_normalize_output(dv->raw1394, 0xffc0 | dv->node); /* Find out if device is DV or HDV */ if (dv->type == IEC61883_AUTO) { response = avc1394_transaction(dv->raw1394, dv->node, AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_TAPE_RECORDER | AVC1394_SUBUNIT_ID_0 | AVC1394_VCR_COMMAND_OUTPUT_SIGNAL_MODE | 0xFF, 2); response = AVC1394_GET_OPERAND0(response); dv->type = (response == 0x10 || response == 0x90 || response == 0x1A || response == 0x9A) ? IEC61883_HDV : IEC61883_DV; } /* Connect to device, and do initialization */ dv->channel = iec61883_cmp_connect(dv->raw1394, dv->node, &dv->output_port, raw1394_get_local_id(dv->raw1394), &dv->input_port, &dv->bandwidth); if (dv->channel < 0) dv->channel = 63; if (!dv->max_packets) dv->max_packets = 100; if (CONFIG_MPEGTS_DEMUXER && dv->type == IEC61883_HDV) { /* Init HDV receive */ avformat_new_stream(context, NULL); dv->mpeg_demux = avpriv_mpegts_parse_open(context); if (!dv->mpeg_demux) goto fail; dv->parse_queue = iec61883_parse_queue_hdv; dv->iec61883_mpeg2 = iec61883_mpeg2_recv_init(dv->raw1394, (iec61883_mpeg2_recv_t)iec61883_callback, dv); dv->max_packets *= 766; } else { /* Init DV receive */ dv->dv_demux = avpriv_dv_init_demux(context); if (!dv->dv_demux) goto fail; dv->parse_queue = iec61883_parse_queue_dv; dv->iec61883_dv = iec61883_dv_fb_init(dv->raw1394, iec61883_callback, dv); } dv->raw1394_poll.fd = raw1394_get_fd(dv->raw1394); dv->raw1394_poll.events = POLLIN | POLLERR | POLLHUP | POLLPRI; /* Actually start receiving */ if (dv->type == IEC61883_HDV) iec61883_mpeg2_recv_start(dv->iec61883_mpeg2, dv->channel); else iec61883_dv_fb_start(dv->iec61883_dv, dv->channel); #if THREADS dv->thread_loop = 1; pthread_mutex_init(&dv->mutex, NULL); pthread_cond_init(&dv->cond, NULL); pthread_create(&dv->receive_task_thread, NULL, iec61883_receive_task, dv); #endif return 0; fail: raw1394_destroy_handle(dv->raw1394); return AVERROR(EIO); }
true
FFmpeg
7c453277a399bc81553c6110efd81a0957117138
static int iec61883_read_header(AVFormatContext *context) { struct iec61883_data *dv = context->priv_data; struct raw1394_portinfo pinf[16]; rom1394_directory rom_dir; char *endptr; int inport; int nb_ports; int port = -1; int response; int i, j = 0; uint64_t guid = 0; dv->input_port = -1; dv->output_port = -1; dv->channel = -1; dv->raw1394 = raw1394_new_handle(); if (!dv->raw1394) { av_log(context, AV_LOG_ERROR, "Failed to open IEEE1394 interface.\n"); return AVERROR(EIO); } if ((nb_ports = raw1394_get_port_info(dv->raw1394, pinf, 16)) < 0) { av_log(context, AV_LOG_ERROR, "Failed to get number of IEEE1394 ports.\n"); goto fail; } inport = strtol(context->filename, &endptr, 10); if (endptr != context->filename && *endptr == '\0') { av_log(context, AV_LOG_INFO, "Selecting IEEE1394 port: %d\n", inport); j = inport; nb_ports = inport + 1; } else if (strcmp(context->filename, "auto")) { av_log(context, AV_LOG_ERROR, "Invalid input \"%s\", you should specify " "\"auto\" for auto-detection, or the port number.\n", context->filename); goto fail; } if (dv->device_guid) { if (sscanf(dv->device_guid, "%llx", (long long unsigned int *)&guid) != 1) { av_log(context, AV_LOG_INFO, "Invalid dvguid parameter: %s\n", dv->device_guid); goto fail; } } for (; j < nb_ports && port==-1; ++j) { raw1394_destroy_handle(dv->raw1394); if (!(dv->raw1394 = raw1394_new_handle_on_port(j))) { av_log(context, AV_LOG_ERROR, "Failed setting IEEE1394 port.\n"); goto fail; } for (i=0; i<raw1394_get_nodecount(dv->raw1394); ++i) { if (guid > 1) { if (guid == rom1394_get_guid(dv->raw1394, i)) { dv->node = i; port = j; break; } } else { if (rom1394_get_directory(dv->raw1394, i, &rom_dir) < 0) continue; if (((rom1394_get_node_type(&rom_dir) == ROM1394_NODE_TYPE_AVC) && avc1394_check_subunit_type(dv->raw1394, i, AVC1394_SUBUNIT_TYPE_VCR)) || (rom_dir.unit_spec_id == MOTDCT_SPEC_ID)) { rom1394_free_directory(&rom_dir); dv->node = i; port = j; break; } rom1394_free_directory(&rom_dir); } } } if (port == -1) { av_log(context, AV_LOG_ERROR, "No AV/C devices found.\n"); goto fail; } iec61883_cmp_normalize_output(dv->raw1394, 0xffc0 | dv->node); if (dv->type == IEC61883_AUTO) { response = avc1394_transaction(dv->raw1394, dv->node, AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_TAPE_RECORDER | AVC1394_SUBUNIT_ID_0 | AVC1394_VCR_COMMAND_OUTPUT_SIGNAL_MODE | 0xFF, 2); response = AVC1394_GET_OPERAND0(response); dv->type = (response == 0x10 || response == 0x90 || response == 0x1A || response == 0x9A) ? IEC61883_HDV : IEC61883_DV; } dv->channel = iec61883_cmp_connect(dv->raw1394, dv->node, &dv->output_port, raw1394_get_local_id(dv->raw1394), &dv->input_port, &dv->bandwidth); if (dv->channel < 0) dv->channel = 63; if (!dv->max_packets) dv->max_packets = 100; if (CONFIG_MPEGTS_DEMUXER && dv->type == IEC61883_HDV) { avformat_new_stream(context, NULL); dv->mpeg_demux = avpriv_mpegts_parse_open(context); if (!dv->mpeg_demux) goto fail; dv->parse_queue = iec61883_parse_queue_hdv; dv->iec61883_mpeg2 = iec61883_mpeg2_recv_init(dv->raw1394, (iec61883_mpeg2_recv_t)iec61883_callback, dv); dv->max_packets *= 766; } else { dv->dv_demux = avpriv_dv_init_demux(context); if (!dv->dv_demux) goto fail; dv->parse_queue = iec61883_parse_queue_dv; dv->iec61883_dv = iec61883_dv_fb_init(dv->raw1394, iec61883_callback, dv); } dv->raw1394_poll.fd = raw1394_get_fd(dv->raw1394); dv->raw1394_poll.events = POLLIN | POLLERR | POLLHUP | POLLPRI; if (dv->type == IEC61883_HDV) iec61883_mpeg2_recv_start(dv->iec61883_mpeg2, dv->channel); else iec61883_dv_fb_start(dv->iec61883_dv, dv->channel); #if THREADS dv->thread_loop = 1; pthread_mutex_init(&dv->mutex, NULL); pthread_cond_init(&dv->cond, NULL); pthread_create(&dv->receive_task_thread, NULL, iec61883_receive_task, dv); #endif return 0; fail: raw1394_destroy_handle(dv->raw1394); return AVERROR(EIO); }
{ "code": [ " pthread_mutex_init(&dv->mutex, NULL);", " pthread_cond_init(&dv->cond, NULL);", " pthread_create(&dv->receive_task_thread, NULL, iec61883_receive_task, dv);" ], "line_no": [ 325, 327, 329 ] }
static int FUNC_0(AVFormatContext *VAR_0) { struct iec61883_data *VAR_1 = VAR_0->priv_data; struct raw1394_portinfo VAR_2[16]; rom1394_directory rom_dir; char *VAR_3; int VAR_4; int VAR_5; int VAR_6 = -1; int VAR_7; int VAR_8, VAR_9 = 0; uint64_t guid = 0; VAR_1->input_port = -1; VAR_1->output_port = -1; VAR_1->channel = -1; VAR_1->raw1394 = raw1394_new_handle(); if (!VAR_1->raw1394) { av_log(VAR_0, AV_LOG_ERROR, "Failed to open IEEE1394 interface.\n"); return AVERROR(EIO); } if ((VAR_5 = raw1394_get_port_info(VAR_1->raw1394, VAR_2, 16)) < 0) { av_log(VAR_0, AV_LOG_ERROR, "Failed to get number of IEEE1394 ports.\n"); goto fail; } VAR_4 = strtol(VAR_0->filename, &VAR_3, 10); if (VAR_3 != VAR_0->filename && *VAR_3 == '\0') { av_log(VAR_0, AV_LOG_INFO, "Selecting IEEE1394 VAR_6: %d\n", VAR_4); VAR_9 = VAR_4; VAR_5 = VAR_4 + 1; } else if (strcmp(VAR_0->filename, "auto")) { av_log(VAR_0, AV_LOG_ERROR, "Invalid input \"%s\", you should specify " "\"auto\" for auto-detection, or the VAR_6 number.\n", VAR_0->filename); goto fail; } if (VAR_1->device_guid) { if (sscanf(VAR_1->device_guid, "%llx", (long long unsigned int *)&guid) != 1) { av_log(VAR_0, AV_LOG_INFO, "Invalid dvguid parameter: %s\n", VAR_1->device_guid); goto fail; } } for (; VAR_9 < VAR_5 && VAR_6==-1; ++VAR_9) { raw1394_destroy_handle(VAR_1->raw1394); if (!(VAR_1->raw1394 = raw1394_new_handle_on_port(VAR_9))) { av_log(VAR_0, AV_LOG_ERROR, "Failed setting IEEE1394 VAR_6.\n"); goto fail; } for (VAR_8=0; VAR_8<raw1394_get_nodecount(VAR_1->raw1394); ++VAR_8) { if (guid > 1) { if (guid == rom1394_get_guid(VAR_1->raw1394, VAR_8)) { VAR_1->node = VAR_8; VAR_6 = VAR_9; break; } } else { if (rom1394_get_directory(VAR_1->raw1394, VAR_8, &rom_dir) < 0) continue; if (((rom1394_get_node_type(&rom_dir) == ROM1394_NODE_TYPE_AVC) && avc1394_check_subunit_type(VAR_1->raw1394, VAR_8, AVC1394_SUBUNIT_TYPE_VCR)) || (rom_dir.unit_spec_id == MOTDCT_SPEC_ID)) { rom1394_free_directory(&rom_dir); VAR_1->node = VAR_8; VAR_6 = VAR_9; break; } rom1394_free_directory(&rom_dir); } } } if (VAR_6 == -1) { av_log(VAR_0, AV_LOG_ERROR, "No AV/C devices found.\n"); goto fail; } iec61883_cmp_normalize_output(VAR_1->raw1394, 0xffc0 | VAR_1->node); if (VAR_1->type == IEC61883_AUTO) { VAR_7 = avc1394_transaction(VAR_1->raw1394, VAR_1->node, AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_TAPE_RECORDER | AVC1394_SUBUNIT_ID_0 | AVC1394_VCR_COMMAND_OUTPUT_SIGNAL_MODE | 0xFF, 2); VAR_7 = AVC1394_GET_OPERAND0(VAR_7); VAR_1->type = (VAR_7 == 0x10 || VAR_7 == 0x90 || VAR_7 == 0x1A || VAR_7 == 0x9A) ? IEC61883_HDV : IEC61883_DV; } VAR_1->channel = iec61883_cmp_connect(VAR_1->raw1394, VAR_1->node, &VAR_1->output_port, raw1394_get_local_id(VAR_1->raw1394), &VAR_1->input_port, &VAR_1->bandwidth); if (VAR_1->channel < 0) VAR_1->channel = 63; if (!VAR_1->max_packets) VAR_1->max_packets = 100; if (CONFIG_MPEGTS_DEMUXER && VAR_1->type == IEC61883_HDV) { avformat_new_stream(VAR_0, NULL); VAR_1->mpeg_demux = avpriv_mpegts_parse_open(VAR_0); if (!VAR_1->mpeg_demux) goto fail; VAR_1->parse_queue = iec61883_parse_queue_hdv; VAR_1->iec61883_mpeg2 = iec61883_mpeg2_recv_init(VAR_1->raw1394, (iec61883_mpeg2_recv_t)iec61883_callback, VAR_1); VAR_1->max_packets *= 766; } else { VAR_1->dv_demux = avpriv_dv_init_demux(VAR_0); if (!VAR_1->dv_demux) goto fail; VAR_1->parse_queue = iec61883_parse_queue_dv; VAR_1->iec61883_dv = iec61883_dv_fb_init(VAR_1->raw1394, iec61883_callback, VAR_1); } VAR_1->raw1394_poll.fd = raw1394_get_fd(VAR_1->raw1394); VAR_1->raw1394_poll.events = POLLIN | POLLERR | POLLHUP | POLLPRI; if (VAR_1->type == IEC61883_HDV) iec61883_mpeg2_recv_start(VAR_1->iec61883_mpeg2, VAR_1->channel); else iec61883_dv_fb_start(VAR_1->iec61883_dv, VAR_1->channel); #if THREADS VAR_1->thread_loop = 1; pthread_mutex_init(&VAR_1->mutex, NULL); pthread_cond_init(&VAR_1->cond, NULL); pthread_create(&VAR_1->receive_task_thread, NULL, iec61883_receive_task, VAR_1); #endif return 0; fail: raw1394_destroy_handle(VAR_1->raw1394); return AVERROR(EIO); }
[ "static int FUNC_0(AVFormatContext *VAR_0)\n{", "struct iec61883_data *VAR_1 = VAR_0->priv_data;", "struct raw1394_portinfo VAR_2[16];", "rom1394_directory rom_dir;", "char *VAR_3;", "int VAR_4;", "int VAR_5;", "int VAR_6 = -1;", "int VAR_7;", "int VAR_8, VAR_9 = 0;", "uint64_t guid = 0;", "VAR_1->input_port = -1;", "VAR_1->output_port = -1;", "VAR_1->channel = -1;", "VAR_1->raw1394 = raw1394_new_handle();", "if (!VAR_1->raw1394) {", "av_log(VAR_0, AV_LOG_ERROR, \"Failed to open IEEE1394 interface.\\n\");", "return AVERROR(EIO);", "}", "if ((VAR_5 = raw1394_get_port_info(VAR_1->raw1394, VAR_2, 16)) < 0) {", "av_log(VAR_0, AV_LOG_ERROR, \"Failed to get number of IEEE1394 ports.\\n\");", "goto fail;", "}", "VAR_4 = strtol(VAR_0->filename, &VAR_3, 10);", "if (VAR_3 != VAR_0->filename && *VAR_3 == '\\0') {", "av_log(VAR_0, AV_LOG_INFO, \"Selecting IEEE1394 VAR_6: %d\\n\", VAR_4);", "VAR_9 = VAR_4;", "VAR_5 = VAR_4 + 1;", "} else if (strcmp(VAR_0->filename, \"auto\")) {", "av_log(VAR_0, AV_LOG_ERROR, \"Invalid input \\\"%s\\\", you should specify \"\n\"\\\"auto\\\" for auto-detection, or the VAR_6 number.\\n\", VAR_0->filename);", "goto fail;", "}", "if (VAR_1->device_guid) {", "if (sscanf(VAR_1->device_guid, \"%llx\", (long long unsigned int *)&guid) != 1) {", "av_log(VAR_0, AV_LOG_INFO, \"Invalid dvguid parameter: %s\\n\",\nVAR_1->device_guid);", "goto fail;", "}", "}", "for (; VAR_9 < VAR_5 && VAR_6==-1; ++VAR_9) {", "raw1394_destroy_handle(VAR_1->raw1394);", "if (!(VAR_1->raw1394 = raw1394_new_handle_on_port(VAR_9))) {", "av_log(VAR_0, AV_LOG_ERROR, \"Failed setting IEEE1394 VAR_6.\\n\");", "goto fail;", "}", "for (VAR_8=0; VAR_8<raw1394_get_nodecount(VAR_1->raw1394); ++VAR_8) {", "if (guid > 1) {", "if (guid == rom1394_get_guid(VAR_1->raw1394, VAR_8)) {", "VAR_1->node = VAR_8;", "VAR_6 = VAR_9;", "break;", "}", "} else {", "if (rom1394_get_directory(VAR_1->raw1394, VAR_8, &rom_dir) < 0)\ncontinue;", "if (((rom1394_get_node_type(&rom_dir) == ROM1394_NODE_TYPE_AVC) &&\navc1394_check_subunit_type(VAR_1->raw1394, VAR_8, AVC1394_SUBUNIT_TYPE_VCR)) ||\n(rom_dir.unit_spec_id == MOTDCT_SPEC_ID)) {", "rom1394_free_directory(&rom_dir);", "VAR_1->node = VAR_8;", "VAR_6 = VAR_9;", "break;", "}", "rom1394_free_directory(&rom_dir);", "}", "}", "}", "if (VAR_6 == -1) {", "av_log(VAR_0, AV_LOG_ERROR, \"No AV/C devices found.\\n\");", "goto fail;", "}", "iec61883_cmp_normalize_output(VAR_1->raw1394, 0xffc0 | VAR_1->node);", "if (VAR_1->type == IEC61883_AUTO) {", "VAR_7 = avc1394_transaction(VAR_1->raw1394, VAR_1->node,\nAVC1394_CTYPE_STATUS |\nAVC1394_SUBUNIT_TYPE_TAPE_RECORDER |\nAVC1394_SUBUNIT_ID_0 |\nAVC1394_VCR_COMMAND_OUTPUT_SIGNAL_MODE |\n0xFF, 2);", "VAR_7 = AVC1394_GET_OPERAND0(VAR_7);", "VAR_1->type = (VAR_7 == 0x10 || VAR_7 == 0x90 || VAR_7 == 0x1A || VAR_7 == 0x9A) ?\nIEC61883_HDV : IEC61883_DV;", "}", "VAR_1->channel = iec61883_cmp_connect(VAR_1->raw1394, VAR_1->node, &VAR_1->output_port,\nraw1394_get_local_id(VAR_1->raw1394),\n&VAR_1->input_port, &VAR_1->bandwidth);", "if (VAR_1->channel < 0)\nVAR_1->channel = 63;", "if (!VAR_1->max_packets)\nVAR_1->max_packets = 100;", "if (CONFIG_MPEGTS_DEMUXER && VAR_1->type == IEC61883_HDV) {", "avformat_new_stream(VAR_0, NULL);", "VAR_1->mpeg_demux = avpriv_mpegts_parse_open(VAR_0);", "if (!VAR_1->mpeg_demux)\ngoto fail;", "VAR_1->parse_queue = iec61883_parse_queue_hdv;", "VAR_1->iec61883_mpeg2 = iec61883_mpeg2_recv_init(VAR_1->raw1394,\n(iec61883_mpeg2_recv_t)iec61883_callback,\nVAR_1);", "VAR_1->max_packets *= 766;", "} else {", "VAR_1->dv_demux = avpriv_dv_init_demux(VAR_0);", "if (!VAR_1->dv_demux)\ngoto fail;", "VAR_1->parse_queue = iec61883_parse_queue_dv;", "VAR_1->iec61883_dv = iec61883_dv_fb_init(VAR_1->raw1394, iec61883_callback, VAR_1);", "}", "VAR_1->raw1394_poll.fd = raw1394_get_fd(VAR_1->raw1394);", "VAR_1->raw1394_poll.events = POLLIN | POLLERR | POLLHUP | POLLPRI;", "if (VAR_1->type == IEC61883_HDV)\niec61883_mpeg2_recv_start(VAR_1->iec61883_mpeg2, VAR_1->channel);", "else\niec61883_dv_fb_start(VAR_1->iec61883_dv, VAR_1->channel);", "#if THREADS\nVAR_1->thread_loop = 1;", "pthread_mutex_init(&VAR_1->mutex, NULL);", "pthread_cond_init(&VAR_1->cond, NULL);", "pthread_create(&VAR_1->receive_task_thread, NULL, iec61883_receive_task, VAR_1);", "#endif\nreturn 0;", "fail:\nraw1394_destroy_handle(VAR_1->raw1394);", "return AVERROR(EIO);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71, 73 ], [ 75 ], [ 77 ], [ 81 ], [ 83 ], [ 85, 87 ], [ 89 ], [ 91 ], [ 93 ], [ 97 ], [ 99 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 113 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 141, 143 ], [ 145, 147, 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 185 ], [ 193 ], [ 195, 197, 199, 201, 203, 205 ], [ 207 ], [ 209, 211 ], [ 213 ], [ 221, 223, 225 ], [ 229, 231 ], [ 235, 237 ], [ 241 ], [ 249 ], [ 253 ], [ 255, 257 ], [ 261 ], [ 265, 267, 269 ], [ 273 ], [ 275 ], [ 283 ], [ 285, 287 ], [ 291 ], [ 295 ], [ 297 ], [ 301 ], [ 303 ], [ 311, 313 ], [ 315, 317 ], [ 321, 323 ], [ 325 ], [ 327 ], [ 329 ], [ 331, 335 ], [ 339, 341 ], [ 343 ], [ 345 ] ]
11,339
static int aio_flush_f(BlockBackend *blk, int argc, char **argv) { blk_drain_all(); return 0; }
true
qemu
556c2b60714e7dae3ed0eb3488910435263dc09f
static int aio_flush_f(BlockBackend *blk, int argc, char **argv) { blk_drain_all(); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(BlockBackend *VAR_0, int VAR_1, char **VAR_2) { blk_drain_all(); return 0; }
[ "static int FUNC_0(BlockBackend *VAR_0, int VAR_1, char **VAR_2)\n{", "blk_drain_all();", "return 0;", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 7 ], [ 10 ], [ 12 ] ]
11,340
static int idcin_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; IdcinContext *s = avctx->priv_data; const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); s->buf = buf; s->size = buf_size; if (s->frame.data[0]) avctx->release_buffer(avctx, &s->frame); if (avctx->get_buffer(avctx, &s->frame)) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } idcin_decode_vlcs(s); if (pal) { s->frame.palette_has_changed = 1; memcpy(s->pal, pal, AVPALETTE_SIZE); } /* make the palette available on the way out */ memcpy(s->frame.data[1], s->pal, AVPALETTE_SIZE); *data_size = sizeof(AVFrame); *(AVFrame*)data = s->frame; /* report that the buffer was completely consumed */ return buf_size; }
true
FFmpeg
527224830aad6aaf5fc5ed9ff6c5f12c80ff906c
static int idcin_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; IdcinContext *s = avctx->priv_data; const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); s->buf = buf; s->size = buf_size; if (s->frame.data[0]) avctx->release_buffer(avctx, &s->frame); if (avctx->get_buffer(avctx, &s->frame)) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } idcin_decode_vlcs(s); if (pal) { s->frame.palette_has_changed = 1; memcpy(s->pal, pal, AVPALETTE_SIZE); } memcpy(s->frame.data[1], s->pal, AVPALETTE_SIZE); *data_size = sizeof(AVFrame); *(AVFrame*)data = s->frame; return buf_size; }
{ "code": [ " if (avctx->get_buffer(avctx, &s->frame)) {", " return -1;", " idcin_decode_vlcs(s);" ], "line_no": [ 31, 35, 41 ] }
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; IdcinContext *s = VAR_0->priv_data; const uint8_t *VAR_6 = av_packet_get_side_data(VAR_3, AV_PKT_DATA_PALETTE, NULL); s->VAR_4 = VAR_4; s->size = VAR_5; if (s->frame.VAR_1[0]) VAR_0->release_buffer(VAR_0, &s->frame); if (VAR_0->get_buffer(VAR_0, &s->frame)) { av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } idcin_decode_vlcs(s); if (VAR_6) { s->frame.palette_has_changed = 1; memcpy(s->VAR_6, VAR_6, AVPALETTE_SIZE); } memcpy(s->frame.VAR_1[1], s->VAR_6, AVPALETTE_SIZE); *VAR_2 = sizeof(AVFrame); *(AVFrame*)VAR_1 = s->frame; return VAR_5; }
[ "static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{", "const uint8_t *VAR_4 = VAR_3->VAR_1;", "int VAR_5 = VAR_3->size;", "IdcinContext *s = VAR_0->priv_data;", "const uint8_t *VAR_6 = av_packet_get_side_data(VAR_3, AV_PKT_DATA_PALETTE, NULL);", "s->VAR_4 = VAR_4;", "s->size = VAR_5;", "if (s->frame.VAR_1[0])\nVAR_0->release_buffer(VAR_0, &s->frame);", "if (VAR_0->get_buffer(VAR_0, &s->frame)) {", "av_log(VAR_0, AV_LOG_ERROR, \"get_buffer() failed\\n\");", "return -1;", "}", "idcin_decode_vlcs(s);", "if (VAR_6) {", "s->frame.palette_has_changed = 1;", "memcpy(s->VAR_6, VAR_6, AVPALETTE_SIZE);", "}", "memcpy(s->frame.VAR_1[1], s->VAR_6, AVPALETTE_SIZE);", "*VAR_2 = sizeof(AVFrame);", "*(AVFrame*)VAR_1 = s->frame;", "return VAR_5;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 25, 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 59 ], [ 61 ], [ 67 ], [ 69 ] ]
11,341
void vnc_display_open(DisplayState *ds, const char *display, Error **errp) { VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display; const char *options; int password = 0; int reverse = 0; #ifdef CONFIG_VNC_TLS int tls = 0, x509 = 0; #endif #ifdef CONFIG_VNC_SASL int sasl = 0; int saslErr; #endif #if defined(CONFIG_VNC_TLS) || defined(CONFIG_VNC_SASL) int acl = 0; #endif int lock_key_sync = 1; if (!vnc_display) { error_setg(errp, "VNC display not active"); return; } vnc_display_close(ds); if (strcmp(display, "none") == 0) return; vs->display = g_strdup(display); vs->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE; options = display; while ((options = strchr(options, ','))) { options++; if (strncmp(options, "password", 8) == 0) { if (fips_get_state()) { error_setg(errp, "VNC password auth disabled due to FIPS mode, " "consider using the VeNCrypt or SASL authentication " "methods as an alternative"); goto fail; } password = 1; /* Require password auth */ } else if (strncmp(options, "reverse", 7) == 0) { reverse = 1; } else if (strncmp(options, "no-lock-key-sync", 16) == 0) { lock_key_sync = 0; #ifdef CONFIG_VNC_SASL } else if (strncmp(options, "sasl", 4) == 0) { sasl = 1; /* Require SASL auth */ #endif #ifdef CONFIG_VNC_WS } else if (strncmp(options, "websocket", 9) == 0) { char *start, *end; vs->websocket = 1; /* Check for 'websocket=<port>' */ start = strchr(options, '='); end = strchr(options, ','); if (start && (!end || (start < end))) { int len = end ? end-(start+1) : strlen(start+1); if (len < 6) { /* extract the host specification from display */ char *host = NULL, *port = NULL, *host_end = NULL; port = g_strndup(start + 1, len); /* ipv6 hosts have colons */ end = strchr(display, ','); host_end = g_strrstr_len(display, end - display, ":"); if (host_end) { host = g_strndup(display, host_end - display + 1); } else { host = g_strndup(":", 1); } vs->ws_display = g_strconcat(host, port, NULL); g_free(host); g_free(port); } } #endif /* CONFIG_VNC_WS */ #ifdef CONFIG_VNC_TLS } else if (strncmp(options, "tls", 3) == 0) { tls = 1; /* Require TLS */ } else if (strncmp(options, "x509", 4) == 0) { char *start, *end; x509 = 1; /* Require x509 certificates */ if (strncmp(options, "x509verify", 10) == 0) vs->tls.x509verify = 1; /* ...and verify client certs */ /* Now check for 'x509=/some/path' postfix * and use that to setup x509 certificate/key paths */ start = strchr(options, '='); end = strchr(options, ','); if (start && (!end || (start < end))) { int len = end ? end-(start+1) : strlen(start+1); char *path = g_strndup(start + 1, len); VNC_DEBUG("Trying certificate path '%s'\n", path); if (vnc_tls_set_x509_creds_dir(vs, path) < 0) { error_setg(errp, "Failed to find x509 certificates/keys in %s", path); g_free(path); goto fail; } g_free(path); } else { error_setg(errp, "No certificate path provided"); goto fail; } #endif #if defined(CONFIG_VNC_TLS) || defined(CONFIG_VNC_SASL) } else if (strncmp(options, "acl", 3) == 0) { acl = 1; #endif } else if (strncmp(options, "lossy", 5) == 0) { vs->lossy = true; } else if (strncmp(options, "non-adaptive", 12) == 0) { vs->non_adaptive = true; } else if (strncmp(options, "share=", 6) == 0) { if (strncmp(options+6, "ignore", 6) == 0) { vs->share_policy = VNC_SHARE_POLICY_IGNORE; } else if (strncmp(options+6, "allow-exclusive", 15) == 0) { vs->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE; } else if (strncmp(options+6, "force-shared", 12) == 0) { vs->share_policy = VNC_SHARE_POLICY_FORCE_SHARED; } else { error_setg(errp, "unknown vnc share= option"); goto fail; } } } #ifdef CONFIG_VNC_TLS if (acl && x509 && vs->tls.x509verify) { if (!(vs->tls.acl = qemu_acl_init("vnc.x509dname"))) { fprintf(stderr, "Failed to create x509 dname ACL\n"); exit(1); } } #endif #ifdef CONFIG_VNC_SASL if (acl && sasl) { if (!(vs->sasl.acl = qemu_acl_init("vnc.username"))) { fprintf(stderr, "Failed to create username ACL\n"); exit(1); } } #endif /* * Combinations we support here: * * - no-auth (clear text, no auth) * - password (clear text, weak auth) * - sasl (encrypt, good auth *IF* using Kerberos via GSSAPI) * - tls (encrypt, weak anonymous creds, no auth) * - tls + password (encrypt, weak anonymous creds, weak auth) * - tls + sasl (encrypt, weak anonymous creds, good auth) * - tls + x509 (encrypt, good x509 creds, no auth) * - tls + x509 + password (encrypt, good x509 creds, weak auth) * - tls + x509 + sasl (encrypt, good x509 creds, good auth) * * NB1. TLS is a stackable auth scheme. * NB2. the x509 schemes have option to validate a client cert dname */ if (password) { #ifdef CONFIG_VNC_TLS if (tls) { vs->auth = VNC_AUTH_VENCRYPT; if (x509) { VNC_DEBUG("Initializing VNC server with x509 password auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_X509VNC; } else { VNC_DEBUG("Initializing VNC server with TLS password auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_TLSVNC; } } else { #endif /* CONFIG_VNC_TLS */ VNC_DEBUG("Initializing VNC server with password auth\n"); vs->auth = VNC_AUTH_VNC; #ifdef CONFIG_VNC_TLS vs->subauth = VNC_AUTH_INVALID; } #endif /* CONFIG_VNC_TLS */ #ifdef CONFIG_VNC_SASL } else if (sasl) { #ifdef CONFIG_VNC_TLS if (tls) { vs->auth = VNC_AUTH_VENCRYPT; if (x509) { VNC_DEBUG("Initializing VNC server with x509 SASL auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_X509SASL; } else { VNC_DEBUG("Initializing VNC server with TLS SASL auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_TLSSASL; } } else { #endif /* CONFIG_VNC_TLS */ VNC_DEBUG("Initializing VNC server with SASL auth\n"); vs->auth = VNC_AUTH_SASL; #ifdef CONFIG_VNC_TLS vs->subauth = VNC_AUTH_INVALID; } #endif /* CONFIG_VNC_TLS */ #endif /* CONFIG_VNC_SASL */ } else { #ifdef CONFIG_VNC_TLS if (tls) { vs->auth = VNC_AUTH_VENCRYPT; if (x509) { VNC_DEBUG("Initializing VNC server with x509 no auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_X509NONE; } else { VNC_DEBUG("Initializing VNC server with TLS no auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_TLSNONE; } } else { #endif VNC_DEBUG("Initializing VNC server with no auth\n"); vs->auth = VNC_AUTH_NONE; #ifdef CONFIG_VNC_TLS vs->subauth = VNC_AUTH_INVALID; } #endif } #ifdef CONFIG_VNC_SASL if ((saslErr = sasl_server_init(NULL, "qemu")) != SASL_OK) { error_setg(errp, "Failed to initialize SASL auth: %s", sasl_errstring(saslErr, NULL, NULL)); goto fail; } #endif vs->lock_key_sync = lock_key_sync; if (reverse) { /* connect to viewer */ int csock; vs->lsock = -1; #ifdef CONFIG_VNC_WS vs->lwebsock = -1; #endif if (strncmp(display, "unix:", 5) == 0) { csock = unix_connect(display+5, errp); } else { csock = inet_connect(display, errp); } if (csock < 0) { goto fail; } vnc_connect(vs, csock, 0, 0); } else { /* listen for connects */ char *dpy; dpy = g_malloc(256); if (strncmp(display, "unix:", 5) == 0) { pstrcpy(dpy, 256, "unix:"); vs->lsock = unix_listen(display+5, dpy+5, 256-5, errp); } else { vs->lsock = inet_listen(display, dpy, 256, SOCK_STREAM, 5900, errp); if (vs->lsock < 0) { g_free(dpy); goto fail; } #ifdef CONFIG_VNC_WS if (vs->websocket) { if (vs->ws_display) { vs->lwebsock = inet_listen(vs->ws_display, NULL, 256, SOCK_STREAM, 0, errp); } else { vs->lwebsock = inet_listen(vs->display, NULL, 256, SOCK_STREAM, 5700, errp); } if (vs->lwebsock < 0) { if (vs->lsock) { close(vs->lsock); vs->lsock = -1; } g_free(dpy); goto fail; } } #endif /* CONFIG_VNC_WS */ } g_free(vs->display); vs->display = dpy; qemu_set_fd_handler2(vs->lsock, NULL, vnc_listen_regular_read, NULL, vs); #ifdef CONFIG_VNC_WS if (vs->websocket) { qemu_set_fd_handler2(vs->lwebsock, NULL, vnc_listen_websocket_read, NULL, vs); } #endif /* CONFIG_VNC_WS */ } return; fail: g_free(vs->display); vs->display = NULL; #ifdef CONFIG_VNC_WS g_free(vs->ws_display); vs->ws_display = NULL; #endif /* CONFIG_VNC_WS */ }
true
qemu
21ef45d71221b4577330fe3aacfb06afad91ad46
void vnc_display_open(DisplayState *ds, const char *display, Error **errp) { VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display; const char *options; int password = 0; int reverse = 0; #ifdef CONFIG_VNC_TLS int tls = 0, x509 = 0; #endif #ifdef CONFIG_VNC_SASL int sasl = 0; int saslErr; #endif #if defined(CONFIG_VNC_TLS) || defined(CONFIG_VNC_SASL) int acl = 0; #endif int lock_key_sync = 1; if (!vnc_display) { error_setg(errp, "VNC display not active"); return; } vnc_display_close(ds); if (strcmp(display, "none") == 0) return; vs->display = g_strdup(display); vs->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE; options = display; while ((options = strchr(options, ','))) { options++; if (strncmp(options, "password", 8) == 0) { if (fips_get_state()) { error_setg(errp, "VNC password auth disabled due to FIPS mode, " "consider using the VeNCrypt or SASL authentication " "methods as an alternative"); goto fail; } password = 1; } else if (strncmp(options, "reverse", 7) == 0) { reverse = 1; } else if (strncmp(options, "no-lock-key-sync", 16) == 0) { lock_key_sync = 0; #ifdef CONFIG_VNC_SASL } else if (strncmp(options, "sasl", 4) == 0) { sasl = 1; #endif #ifdef CONFIG_VNC_WS } else if (strncmp(options, "websocket", 9) == 0) { char *start, *end; vs->websocket = 1; start = strchr(options, '='); end = strchr(options, ','); if (start && (!end || (start < end))) { int len = end ? end-(start+1) : strlen(start+1); if (len < 6) { char *host = NULL, *port = NULL, *host_end = NULL; port = g_strndup(start + 1, len); end = strchr(display, ','); host_end = g_strrstr_len(display, end - display, ":"); if (host_end) { host = g_strndup(display, host_end - display + 1); } else { host = g_strndup(":", 1); } vs->ws_display = g_strconcat(host, port, NULL); g_free(host); g_free(port); } } #endif #ifdef CONFIG_VNC_TLS } else if (strncmp(options, "tls", 3) == 0) { tls = 1; } else if (strncmp(options, "x509", 4) == 0) { char *start, *end; x509 = 1; if (strncmp(options, "x509verify", 10) == 0) vs->tls.x509verify = 1; start = strchr(options, '='); end = strchr(options, ','); if (start && (!end || (start < end))) { int len = end ? end-(start+1) : strlen(start+1); char *path = g_strndup(start + 1, len); VNC_DEBUG("Trying certificate path '%s'\n", path); if (vnc_tls_set_x509_creds_dir(vs, path) < 0) { error_setg(errp, "Failed to find x509 certificates/keys in %s", path); g_free(path); goto fail; } g_free(path); } else { error_setg(errp, "No certificate path provided"); goto fail; } #endif #if defined(CONFIG_VNC_TLS) || defined(CONFIG_VNC_SASL) } else if (strncmp(options, "acl", 3) == 0) { acl = 1; #endif } else if (strncmp(options, "lossy", 5) == 0) { vs->lossy = true; } else if (strncmp(options, "non-adaptive", 12) == 0) { vs->non_adaptive = true; } else if (strncmp(options, "share=", 6) == 0) { if (strncmp(options+6, "ignore", 6) == 0) { vs->share_policy = VNC_SHARE_POLICY_IGNORE; } else if (strncmp(options+6, "allow-exclusive", 15) == 0) { vs->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE; } else if (strncmp(options+6, "force-shared", 12) == 0) { vs->share_policy = VNC_SHARE_POLICY_FORCE_SHARED; } else { error_setg(errp, "unknown vnc share= option"); goto fail; } } } #ifdef CONFIG_VNC_TLS if (acl && x509 && vs->tls.x509verify) { if (!(vs->tls.acl = qemu_acl_init("vnc.x509dname"))) { fprintf(stderr, "Failed to create x509 dname ACL\n"); exit(1); } } #endif #ifdef CONFIG_VNC_SASL if (acl && sasl) { if (!(vs->sasl.acl = qemu_acl_init("vnc.username"))) { fprintf(stderr, "Failed to create username ACL\n"); exit(1); } } #endif if (password) { #ifdef CONFIG_VNC_TLS if (tls) { vs->auth = VNC_AUTH_VENCRYPT; if (x509) { VNC_DEBUG("Initializing VNC server with x509 password auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_X509VNC; } else { VNC_DEBUG("Initializing VNC server with TLS password auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_TLSVNC; } } else { #endif VNC_DEBUG("Initializing VNC server with password auth\n"); vs->auth = VNC_AUTH_VNC; #ifdef CONFIG_VNC_TLS vs->subauth = VNC_AUTH_INVALID; } #endif #ifdef CONFIG_VNC_SASL } else if (sasl) { #ifdef CONFIG_VNC_TLS if (tls) { vs->auth = VNC_AUTH_VENCRYPT; if (x509) { VNC_DEBUG("Initializing VNC server with x509 SASL auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_X509SASL; } else { VNC_DEBUG("Initializing VNC server with TLS SASL auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_TLSSASL; } } else { #endif VNC_DEBUG("Initializing VNC server with SASL auth\n"); vs->auth = VNC_AUTH_SASL; #ifdef CONFIG_VNC_TLS vs->subauth = VNC_AUTH_INVALID; } #endif #endif } else { #ifdef CONFIG_VNC_TLS if (tls) { vs->auth = VNC_AUTH_VENCRYPT; if (x509) { VNC_DEBUG("Initializing VNC server with x509 no auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_X509NONE; } else { VNC_DEBUG("Initializing VNC server with TLS no auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_TLSNONE; } } else { #endif VNC_DEBUG("Initializing VNC server with no auth\n"); vs->auth = VNC_AUTH_NONE; #ifdef CONFIG_VNC_TLS vs->subauth = VNC_AUTH_INVALID; } #endif } #ifdef CONFIG_VNC_SASL if ((saslErr = sasl_server_init(NULL, "qemu")) != SASL_OK) { error_setg(errp, "Failed to initialize SASL auth: %s", sasl_errstring(saslErr, NULL, NULL)); goto fail; } #endif vs->lock_key_sync = lock_key_sync; if (reverse) { int csock; vs->lsock = -1; #ifdef CONFIG_VNC_WS vs->lwebsock = -1; #endif if (strncmp(display, "unix:", 5) == 0) { csock = unix_connect(display+5, errp); } else { csock = inet_connect(display, errp); } if (csock < 0) { goto fail; } vnc_connect(vs, csock, 0, 0); } else { char *dpy; dpy = g_malloc(256); if (strncmp(display, "unix:", 5) == 0) { pstrcpy(dpy, 256, "unix:"); vs->lsock = unix_listen(display+5, dpy+5, 256-5, errp); } else { vs->lsock = inet_listen(display, dpy, 256, SOCK_STREAM, 5900, errp); if (vs->lsock < 0) { g_free(dpy); goto fail; } #ifdef CONFIG_VNC_WS if (vs->websocket) { if (vs->ws_display) { vs->lwebsock = inet_listen(vs->ws_display, NULL, 256, SOCK_STREAM, 0, errp); } else { vs->lwebsock = inet_listen(vs->display, NULL, 256, SOCK_STREAM, 5700, errp); } if (vs->lwebsock < 0) { if (vs->lsock) { close(vs->lsock); vs->lsock = -1; } g_free(dpy); goto fail; } } #endif } g_free(vs->display); vs->display = dpy; qemu_set_fd_handler2(vs->lsock, NULL, vnc_listen_regular_read, NULL, vs); #ifdef CONFIG_VNC_WS if (vs->websocket) { qemu_set_fd_handler2(vs->lwebsock, NULL, vnc_listen_websocket_read, NULL, vs); } #endif } return; fail: g_free(vs->display); vs->display = NULL; #ifdef CONFIG_VNC_WS g_free(vs->ws_display); vs->ws_display = NULL; #endif }
{ "code": [ " VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display;", " VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display;", " VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display;", " VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display;", " VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display;", " VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display;", " VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display;" ], "line_no": [ 5, 5, 5, 5, 5, 5, 5 ] }
void FUNC_0(DisplayState *VAR_0, const char *VAR_1, Error **VAR_2) { VncDisplay *vs = VAR_0 ? (VncDisplay *)VAR_0->opaque : vnc_display; const char *VAR_3; int VAR_4 = 0; int VAR_5 = 0; #ifdef CONFIG_VNC_TLS int tls = 0, x509 = 0; #endif #ifdef CONFIG_VNC_SASL int sasl = 0; int saslErr; #endif #if defined(CONFIG_VNC_TLS) || defined(CONFIG_VNC_SASL) int acl = 0; #endif int VAR_6 = 1; if (!vnc_display) { error_setg(VAR_2, "VNC VAR_1 not active"); return; } vnc_display_close(VAR_0); if (strcmp(VAR_1, "none") == 0) return; vs->VAR_1 = g_strdup(VAR_1); vs->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE; VAR_3 = VAR_1; while ((VAR_3 = strchr(VAR_3, ','))) { VAR_3++; if (strncmp(VAR_3, "VAR_4", 8) == 0) { if (fips_get_state()) { error_setg(VAR_2, "VNC VAR_4 auth disabled due to FIPS mode, " "consider using the VeNCrypt or SASL authentication " "methods as an alternative"); goto fail; } VAR_4 = 1; } else if (strncmp(VAR_3, "VAR_5", 7) == 0) { VAR_5 = 1; } else if (strncmp(VAR_3, "no-lock-key-sync", 16) == 0) { VAR_6 = 0; #ifdef CONFIG_VNC_SASL } else if (strncmp(VAR_3, "sasl", 4) == 0) { sasl = 1; #endif #ifdef CONFIG_VNC_WS } else if (strncmp(VAR_3, "websocket", 9) == 0) { char *start, *end; vs->websocket = 1; start = strchr(VAR_3, '='); end = strchr(VAR_3, ','); if (start && (!end || (start < end))) { int len = end ? end-(start+1) : strlen(start+1); if (len < 6) { char *host = NULL, *port = NULL, *host_end = NULL; port = g_strndup(start + 1, len); end = strchr(VAR_1, ','); host_end = g_strrstr_len(VAR_1, end - VAR_1, ":"); if (host_end) { host = g_strndup(VAR_1, host_end - VAR_1 + 1); } else { host = g_strndup(":", 1); } vs->ws_display = g_strconcat(host, port, NULL); g_free(host); g_free(port); } } #endif #ifdef CONFIG_VNC_TLS } else if (strncmp(VAR_3, "tls", 3) == 0) { tls = 1; } else if (strncmp(VAR_3, "x509", 4) == 0) { char *start, *end; x509 = 1; if (strncmp(VAR_3, "x509verify", 10) == 0) vs->tls.x509verify = 1; start = strchr(VAR_3, '='); end = strchr(VAR_3, ','); if (start && (!end || (start < end))) { int len = end ? end-(start+1) : strlen(start+1); char *path = g_strndup(start + 1, len); VNC_DEBUG("Trying certificate path '%s'\n", path); if (vnc_tls_set_x509_creds_dir(vs, path) < 0) { error_setg(VAR_2, "Failed to find x509 certificates/keys in %s", path); g_free(path); goto fail; } g_free(path); } else { error_setg(VAR_2, "No certificate path provided"); goto fail; } #endif #if defined(CONFIG_VNC_TLS) || defined(CONFIG_VNC_SASL) } else if (strncmp(VAR_3, "acl", 3) == 0) { acl = 1; #endif } else if (strncmp(VAR_3, "lossy", 5) == 0) { vs->lossy = true; } else if (strncmp(VAR_3, "non-adaptive", 12) == 0) { vs->non_adaptive = true; } else if (strncmp(VAR_3, "share=", 6) == 0) { if (strncmp(VAR_3+6, "ignore", 6) == 0) { vs->share_policy = VNC_SHARE_POLICY_IGNORE; } else if (strncmp(VAR_3+6, "allow-exclusive", 15) == 0) { vs->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE; } else if (strncmp(VAR_3+6, "force-shared", 12) == 0) { vs->share_policy = VNC_SHARE_POLICY_FORCE_SHARED; } else { error_setg(VAR_2, "unknown vnc share= option"); goto fail; } } } #ifdef CONFIG_VNC_TLS if (acl && x509 && vs->tls.x509verify) { if (!(vs->tls.acl = qemu_acl_init("vnc.x509dname"))) { fprintf(stderr, "Failed to create x509 dname ACL\n"); exit(1); } } #endif #ifdef CONFIG_VNC_SASL if (acl && sasl) { if (!(vs->sasl.acl = qemu_acl_init("vnc.username"))) { fprintf(stderr, "Failed to create username ACL\n"); exit(1); } } #endif if (VAR_4) { #ifdef CONFIG_VNC_TLS if (tls) { vs->auth = VNC_AUTH_VENCRYPT; if (x509) { VNC_DEBUG("Initializing VNC server with x509 VAR_4 auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_X509VNC; } else { VNC_DEBUG("Initializing VNC server with TLS VAR_4 auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_TLSVNC; } } else { #endif VNC_DEBUG("Initializing VNC server with VAR_4 auth\n"); vs->auth = VNC_AUTH_VNC; #ifdef CONFIG_VNC_TLS vs->subauth = VNC_AUTH_INVALID; } #endif #ifdef CONFIG_VNC_SASL } else if (sasl) { #ifdef CONFIG_VNC_TLS if (tls) { vs->auth = VNC_AUTH_VENCRYPT; if (x509) { VNC_DEBUG("Initializing VNC server with x509 SASL auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_X509SASL; } else { VNC_DEBUG("Initializing VNC server with TLS SASL auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_TLSSASL; } } else { #endif VNC_DEBUG("Initializing VNC server with SASL auth\n"); vs->auth = VNC_AUTH_SASL; #ifdef CONFIG_VNC_TLS vs->subauth = VNC_AUTH_INVALID; } #endif #endif } else { #ifdef CONFIG_VNC_TLS if (tls) { vs->auth = VNC_AUTH_VENCRYPT; if (x509) { VNC_DEBUG("Initializing VNC server with x509 no auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_X509NONE; } else { VNC_DEBUG("Initializing VNC server with TLS no auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_TLSNONE; } } else { #endif VNC_DEBUG("Initializing VNC server with no auth\n"); vs->auth = VNC_AUTH_NONE; #ifdef CONFIG_VNC_TLS vs->subauth = VNC_AUTH_INVALID; } #endif } #ifdef CONFIG_VNC_SASL if ((saslErr = sasl_server_init(NULL, "qemu")) != SASL_OK) { error_setg(VAR_2, "Failed to initialize SASL auth: %s", sasl_errstring(saslErr, NULL, NULL)); goto fail; } #endif vs->VAR_6 = VAR_6; if (VAR_5) { int VAR_7; vs->lsock = -1; #ifdef CONFIG_VNC_WS vs->lwebsock = -1; #endif if (strncmp(VAR_1, "unix:", 5) == 0) { VAR_7 = unix_connect(VAR_1+5, VAR_2); } else { VAR_7 = inet_connect(VAR_1, VAR_2); } if (VAR_7 < 0) { goto fail; } vnc_connect(vs, VAR_7, 0, 0); } else { char *VAR_8; VAR_8 = g_malloc(256); if (strncmp(VAR_1, "unix:", 5) == 0) { pstrcpy(VAR_8, 256, "unix:"); vs->lsock = unix_listen(VAR_1+5, VAR_8+5, 256-5, VAR_2); } else { vs->lsock = inet_listen(VAR_1, VAR_8, 256, SOCK_STREAM, 5900, VAR_2); if (vs->lsock < 0) { g_free(VAR_8); goto fail; } #ifdef CONFIG_VNC_WS if (vs->websocket) { if (vs->ws_display) { vs->lwebsock = inet_listen(vs->ws_display, NULL, 256, SOCK_STREAM, 0, VAR_2); } else { vs->lwebsock = inet_listen(vs->VAR_1, NULL, 256, SOCK_STREAM, 5700, VAR_2); } if (vs->lwebsock < 0) { if (vs->lsock) { close(vs->lsock); vs->lsock = -1; } g_free(VAR_8); goto fail; } } #endif } g_free(vs->VAR_1); vs->VAR_1 = VAR_8; qemu_set_fd_handler2(vs->lsock, NULL, vnc_listen_regular_read, NULL, vs); #ifdef CONFIG_VNC_WS if (vs->websocket) { qemu_set_fd_handler2(vs->lwebsock, NULL, vnc_listen_websocket_read, NULL, vs); } #endif } return; fail: g_free(vs->VAR_1); vs->VAR_1 = NULL; #ifdef CONFIG_VNC_WS g_free(vs->ws_display); vs->ws_display = NULL; #endif }
[ "void FUNC_0(DisplayState *VAR_0, const char *VAR_1, Error **VAR_2)\n{", "VncDisplay *vs = VAR_0 ? (VncDisplay *)VAR_0->opaque : vnc_display;", "const char *VAR_3;", "int VAR_4 = 0;", "int VAR_5 = 0;", "#ifdef CONFIG_VNC_TLS\nint tls = 0, x509 = 0;", "#endif\n#ifdef CONFIG_VNC_SASL\nint sasl = 0;", "int saslErr;", "#endif\n#if defined(CONFIG_VNC_TLS) || defined(CONFIG_VNC_SASL)\nint acl = 0;", "#endif\nint VAR_6 = 1;", "if (!vnc_display) {", "error_setg(VAR_2, \"VNC VAR_1 not active\");", "return;", "}", "vnc_display_close(VAR_0);", "if (strcmp(VAR_1, \"none\") == 0)\nreturn;", "vs->VAR_1 = g_strdup(VAR_1);", "vs->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE;", "VAR_3 = VAR_1;", "while ((VAR_3 = strchr(VAR_3, ','))) {", "VAR_3++;", "if (strncmp(VAR_3, \"VAR_4\", 8) == 0) {", "if (fips_get_state()) {", "error_setg(VAR_2,\n\"VNC VAR_4 auth disabled due to FIPS mode, \"\n\"consider using the VeNCrypt or SASL authentication \"\n\"methods as an alternative\");", "goto fail;", "}", "VAR_4 = 1;", "} else if (strncmp(VAR_3, \"VAR_5\", 7) == 0) {", "VAR_5 = 1;", "} else if (strncmp(VAR_3, \"no-lock-key-sync\", 16) == 0) {", "VAR_6 = 0;", "#ifdef CONFIG_VNC_SASL\n} else if (strncmp(VAR_3, \"sasl\", 4) == 0) {", "sasl = 1;", "#endif\n#ifdef CONFIG_VNC_WS\n} else if (strncmp(VAR_3, \"websocket\", 9) == 0) {", "char *start, *end;", "vs->websocket = 1;", "start = strchr(VAR_3, '=');", "end = strchr(VAR_3, ',');", "if (start && (!end || (start < end))) {", "int len = end ? end-(start+1) : strlen(start+1);", "if (len < 6) {", "char *host = NULL, *port = NULL, *host_end = NULL;", "port = g_strndup(start + 1, len);", "end = strchr(VAR_1, ',');", "host_end = g_strrstr_len(VAR_1, end - VAR_1, \":\");", "if (host_end) {", "host = g_strndup(VAR_1, host_end - VAR_1 + 1);", "} else {", "host = g_strndup(\":\", 1);", "}", "vs->ws_display = g_strconcat(host, port, NULL);", "g_free(host);", "g_free(port);", "}", "}", "#endif\n#ifdef CONFIG_VNC_TLS\n} else if (strncmp(VAR_3, \"tls\", 3) == 0) {", "tls = 1;", "} else if (strncmp(VAR_3, \"x509\", 4) == 0) {", "char *start, *end;", "x509 = 1;", "if (strncmp(VAR_3, \"x509verify\", 10) == 0)\nvs->tls.x509verify = 1;", "start = strchr(VAR_3, '=');", "end = strchr(VAR_3, ',');", "if (start && (!end || (start < end))) {", "int len = end ? end-(start+1) : strlen(start+1);", "char *path = g_strndup(start + 1, len);", "VNC_DEBUG(\"Trying certificate path '%s'\\n\", path);", "if (vnc_tls_set_x509_creds_dir(vs, path) < 0) {", "error_setg(VAR_2, \"Failed to find x509 certificates/keys in %s\", path);", "g_free(path);", "goto fail;", "}", "g_free(path);", "} else {", "error_setg(VAR_2, \"No certificate path provided\");", "goto fail;", "}", "#endif\n#if defined(CONFIG_VNC_TLS) || defined(CONFIG_VNC_SASL)\n} else if (strncmp(VAR_3, \"acl\", 3) == 0) {", "acl = 1;", "#endif\n} else if (strncmp(VAR_3, \"lossy\", 5) == 0) {", "vs->lossy = true;", "} else if (strncmp(VAR_3, \"non-adaptive\", 12) == 0) {", "vs->non_adaptive = true;", "} else if (strncmp(VAR_3, \"share=\", 6) == 0) {", "if (strncmp(VAR_3+6, \"ignore\", 6) == 0) {", "vs->share_policy = VNC_SHARE_POLICY_IGNORE;", "} else if (strncmp(VAR_3+6, \"allow-exclusive\", 15) == 0) {", "vs->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE;", "} else if (strncmp(VAR_3+6, \"force-shared\", 12) == 0) {", "vs->share_policy = VNC_SHARE_POLICY_FORCE_SHARED;", "} else {", "error_setg(VAR_2, \"unknown vnc share= option\");", "goto fail;", "}", "}", "}", "#ifdef CONFIG_VNC_TLS\nif (acl && x509 && vs->tls.x509verify) {", "if (!(vs->tls.acl = qemu_acl_init(\"vnc.x509dname\"))) {", "fprintf(stderr, \"Failed to create x509 dname ACL\\n\");", "exit(1);", "}", "}", "#endif\n#ifdef CONFIG_VNC_SASL\nif (acl && sasl) {", "if (!(vs->sasl.acl = qemu_acl_init(\"vnc.username\"))) {", "fprintf(stderr, \"Failed to create username ACL\\n\");", "exit(1);", "}", "}", "#endif\nif (VAR_4) {", "#ifdef CONFIG_VNC_TLS\nif (tls) {", "vs->auth = VNC_AUTH_VENCRYPT;", "if (x509) {", "VNC_DEBUG(\"Initializing VNC server with x509 VAR_4 auth\\n\");", "vs->subauth = VNC_AUTH_VENCRYPT_X509VNC;", "} else {", "VNC_DEBUG(\"Initializing VNC server with TLS VAR_4 auth\\n\");", "vs->subauth = VNC_AUTH_VENCRYPT_TLSVNC;", "}", "} else {", "#endif\nVNC_DEBUG(\"Initializing VNC server with VAR_4 auth\\n\");", "vs->auth = VNC_AUTH_VNC;", "#ifdef CONFIG_VNC_TLS\nvs->subauth = VNC_AUTH_INVALID;", "}", "#endif\n#ifdef CONFIG_VNC_SASL\n} else if (sasl) {", "#ifdef CONFIG_VNC_TLS\nif (tls) {", "vs->auth = VNC_AUTH_VENCRYPT;", "if (x509) {", "VNC_DEBUG(\"Initializing VNC server with x509 SASL auth\\n\");", "vs->subauth = VNC_AUTH_VENCRYPT_X509SASL;", "} else {", "VNC_DEBUG(\"Initializing VNC server with TLS SASL auth\\n\");", "vs->subauth = VNC_AUTH_VENCRYPT_TLSSASL;", "}", "} else {", "#endif\nVNC_DEBUG(\"Initializing VNC server with SASL auth\\n\");", "vs->auth = VNC_AUTH_SASL;", "#ifdef CONFIG_VNC_TLS\nvs->subauth = VNC_AUTH_INVALID;", "}", "#endif\n#endif\n} else {", "#ifdef CONFIG_VNC_TLS\nif (tls) {", "vs->auth = VNC_AUTH_VENCRYPT;", "if (x509) {", "VNC_DEBUG(\"Initializing VNC server with x509 no auth\\n\");", "vs->subauth = VNC_AUTH_VENCRYPT_X509NONE;", "} else {", "VNC_DEBUG(\"Initializing VNC server with TLS no auth\\n\");", "vs->subauth = VNC_AUTH_VENCRYPT_TLSNONE;", "}", "} else {", "#endif\nVNC_DEBUG(\"Initializing VNC server with no auth\\n\");", "vs->auth = VNC_AUTH_NONE;", "#ifdef CONFIG_VNC_TLS\nvs->subauth = VNC_AUTH_INVALID;", "}", "#endif\n}", "#ifdef CONFIG_VNC_SASL\nif ((saslErr = sasl_server_init(NULL, \"qemu\")) != SASL_OK) {", "error_setg(VAR_2, \"Failed to initialize SASL auth: %s\",\nsasl_errstring(saslErr, NULL, NULL));", "goto fail;", "}", "#endif\nvs->VAR_6 = VAR_6;", "if (VAR_5) {", "int VAR_7;", "vs->lsock = -1;", "#ifdef CONFIG_VNC_WS\nvs->lwebsock = -1;", "#endif\nif (strncmp(VAR_1, \"unix:\", 5) == 0) {", "VAR_7 = unix_connect(VAR_1+5, VAR_2);", "} else {", "VAR_7 = inet_connect(VAR_1, VAR_2);", "}", "if (VAR_7 < 0) {", "goto fail;", "}", "vnc_connect(vs, VAR_7, 0, 0);", "} else {", "char *VAR_8;", "VAR_8 = g_malloc(256);", "if (strncmp(VAR_1, \"unix:\", 5) == 0) {", "pstrcpy(VAR_8, 256, \"unix:\");", "vs->lsock = unix_listen(VAR_1+5, VAR_8+5, 256-5, VAR_2);", "} else {", "vs->lsock = inet_listen(VAR_1, VAR_8, 256,\nSOCK_STREAM, 5900, VAR_2);", "if (vs->lsock < 0) {", "g_free(VAR_8);", "goto fail;", "}", "#ifdef CONFIG_VNC_WS\nif (vs->websocket) {", "if (vs->ws_display) {", "vs->lwebsock = inet_listen(vs->ws_display, NULL, 256,\nSOCK_STREAM, 0, VAR_2);", "} else {", "vs->lwebsock = inet_listen(vs->VAR_1, NULL, 256,\nSOCK_STREAM, 5700, VAR_2);", "}", "if (vs->lwebsock < 0) {", "if (vs->lsock) {", "close(vs->lsock);", "vs->lsock = -1;", "}", "g_free(VAR_8);", "goto fail;", "}", "}", "#endif\n}", "g_free(vs->VAR_1);", "vs->VAR_1 = VAR_8;", "qemu_set_fd_handler2(vs->lsock, NULL,\nvnc_listen_regular_read, NULL, vs);", "#ifdef CONFIG_VNC_WS\nif (vs->websocket) {", "qemu_set_fd_handler2(vs->lwebsock, NULL,\nvnc_listen_websocket_read, NULL, vs);", "}", "#endif\n}", "return;", "fail:\ng_free(vs->VAR_1);", "vs->VAR_1 = NULL;", "#ifdef CONFIG_VNC_WS\ng_free(vs->ws_display);", "vs->ws_display = NULL;", "#endif\n}" ]
[ 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13, 15 ], [ 17, 19, 21 ], [ 23 ], [ 25, 27, 29 ], [ 31, 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47, 49 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69, 71, 73, 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91, 93 ], [ 95 ], [ 97, 99, 101 ], [ 103 ], [ 105 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 123 ], [ 125 ], [ 131 ], [ 133 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157, 159, 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171, 173 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215, 217, 219 ], [ 221 ], [ 223, 225 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 261, 263 ], [ 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275, 277, 279 ], [ 281 ], [ 283 ], [ 285 ], [ 287 ], [ 289 ], [ 291, 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 ], [ 449, 451 ], [ 453, 455 ], [ 457 ], [ 459 ], [ 461, 463 ], [ 467 ], [ 471 ], [ 473 ], [ 475, 477 ], [ 479, 481 ], [ 483 ], [ 485 ], [ 487 ], [ 489 ], [ 491 ], [ 493 ], [ 495 ], [ 497 ], [ 499 ], [ 503 ], [ 505 ], [ 507 ], [ 509 ], [ 511 ], [ 513 ], [ 515, 517 ], [ 519 ], [ 521 ], [ 523 ], [ 525 ], [ 527, 529 ], [ 531 ], [ 533, 535 ], [ 537 ], [ 539, 541 ], [ 543 ], [ 547 ], [ 549 ], [ 551 ], [ 553 ], [ 555 ], [ 557 ], [ 559 ], [ 561 ], [ 563 ], [ 565, 567 ], [ 569 ], [ 571 ], [ 573, 575 ], [ 577, 579 ], [ 581, 583 ], [ 585 ], [ 587, 589 ], [ 591 ], [ 595, 597 ], [ 599 ], [ 601, 603 ], [ 605 ], [ 607, 609 ] ]
11,342
bdrv_rw_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos, bool is_read) { if (qemu_in_coroutine()) { return bdrv_co_rw_vmstate(bs, qiov, pos, is_read); } else { BdrvVmstateCo data = { .bs = bs, .qiov = qiov, .pos = pos, .is_read = is_read, .ret = -EINPROGRESS, }; Coroutine *co = qemu_coroutine_create(bdrv_co_rw_vmstate_entry, &data); qemu_coroutine_enter(co); while (data.ret == -EINPROGRESS) { aio_poll(bdrv_get_aio_context(bs), true); } return data.ret; } }
true
qemu
e92f0e1910f0655a0edd8d87c5a7262d36517a89
bdrv_rw_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos, bool is_read) { if (qemu_in_coroutine()) { return bdrv_co_rw_vmstate(bs, qiov, pos, is_read); } else { BdrvVmstateCo data = { .bs = bs, .qiov = qiov, .pos = pos, .is_read = is_read, .ret = -EINPROGRESS, }; Coroutine *co = qemu_coroutine_create(bdrv_co_rw_vmstate_entry, &data); qemu_coroutine_enter(co); while (data.ret == -EINPROGRESS) { aio_poll(bdrv_get_aio_context(bs), true); } return data.ret; } }
{ "code": [ " qemu_coroutine_enter(co);", " qemu_coroutine_enter(co);", " qemu_coroutine_enter(co);", " qemu_coroutine_enter(co);", " qemu_coroutine_enter(co);", " qemu_coroutine_enter(co);" ], "line_no": [ 31, 31, 31, 31, 31, 31 ] }
FUNC_0(BlockDriverState *VAR_0, QEMUIOVector *VAR_1, int64_t VAR_2, bool VAR_3) { if (qemu_in_coroutine()) { return bdrv_co_rw_vmstate(VAR_0, VAR_1, VAR_2, VAR_3); } else { BdrvVmstateCo data = { .VAR_0 = VAR_0, .VAR_1 = VAR_1, .VAR_2 = VAR_2, .VAR_3 = VAR_3, .ret = -EINPROGRESS, }; Coroutine *co = qemu_coroutine_create(bdrv_co_rw_vmstate_entry, &data); qemu_coroutine_enter(co); while (data.ret == -EINPROGRESS) { aio_poll(bdrv_get_aio_context(VAR_0), true); } return data.ret; } }
[ "FUNC_0(BlockDriverState *VAR_0, QEMUIOVector *VAR_1, int64_t VAR_2,\nbool VAR_3)\n{", "if (qemu_in_coroutine()) {", "return bdrv_co_rw_vmstate(VAR_0, VAR_1, VAR_2, VAR_3);", "} else {", "BdrvVmstateCo data = {", ".VAR_0 = VAR_0,\n.VAR_1 = VAR_1,\n.VAR_2 = VAR_2,\n.VAR_3 = VAR_3,\n.ret = -EINPROGRESS,\n};", "Coroutine *co = qemu_coroutine_create(bdrv_co_rw_vmstate_entry, &data);", "qemu_coroutine_enter(co);", "while (data.ret == -EINPROGRESS) {", "aio_poll(bdrv_get_aio_context(VAR_0), true);", "}", "return data.ret;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15, 17, 19, 21, 23, 25 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ] ]
11,344
static void exit_program(void) { int i, j; for (i = 0; i < nb_filtergraphs; i++) { avfilter_graph_free(&filtergraphs[i]->graph); for (j = 0; j < filtergraphs[i]->nb_inputs; j++) { av_freep(&filtergraphs[i]->inputs[j]->name); av_freep(&filtergraphs[i]->inputs[j]); } av_freep(&filtergraphs[i]->inputs); for (j = 0; j < filtergraphs[i]->nb_outputs; j++) { av_freep(&filtergraphs[i]->outputs[j]->name); av_freep(&filtergraphs[i]->outputs[j]); } av_freep(&filtergraphs[i]->outputs); av_freep(&filtergraphs[i]->graph_desc); av_freep(&filtergraphs[i]); } av_freep(&filtergraphs); /* close files */ for (i = 0; i < nb_output_files; i++) { AVFormatContext *s = output_files[i]->ctx; if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE) && s->pb) avio_close(s->pb); avformat_free_context(s); av_dict_free(&output_files[i]->opts); av_freep(&output_files[i]); } for (i = 0; i < nb_output_streams; i++) { AVBitStreamFilterContext *bsfc = output_streams[i]->bitstream_filters; while (bsfc) { AVBitStreamFilterContext *next = bsfc->next; av_bitstream_filter_close(bsfc); bsfc = next; } output_streams[i]->bitstream_filters = NULL; avcodec_free_frame(&output_streams[i]->filtered_frame); av_freep(&output_streams[i]->forced_keyframes); av_freep(&output_streams[i]->avfilter); av_freep(&output_streams[i]->logfile_prefix); av_freep(&output_streams[i]); } for (i = 0; i < nb_input_files; i++) { avformat_close_input(&input_files[i]->ctx); av_freep(&input_files[i]); } for (i = 0; i < nb_input_streams; i++) { av_frame_free(&input_streams[i]->decoded_frame); av_frame_free(&input_streams[i]->filter_frame); av_dict_free(&input_streams[i]->opts); av_freep(&input_streams[i]->filters); av_freep(&input_streams[i]); } if (vstats_file) fclose(vstats_file); av_free(vstats_filename); av_freep(&input_streams); av_freep(&input_files); av_freep(&output_streams); av_freep(&output_files); uninit_opts(); avformat_network_deinit(); if (received_sigterm) { av_log(NULL, AV_LOG_INFO, "Received signal %d: terminating.\n", (int) received_sigterm); exit (255); } }
true
FFmpeg
636ced8e1dc8248a1353b416240b93d70ad03edb
static void exit_program(void) { int i, j; for (i = 0; i < nb_filtergraphs; i++) { avfilter_graph_free(&filtergraphs[i]->graph); for (j = 0; j < filtergraphs[i]->nb_inputs; j++) { av_freep(&filtergraphs[i]->inputs[j]->name); av_freep(&filtergraphs[i]->inputs[j]); } av_freep(&filtergraphs[i]->inputs); for (j = 0; j < filtergraphs[i]->nb_outputs; j++) { av_freep(&filtergraphs[i]->outputs[j]->name); av_freep(&filtergraphs[i]->outputs[j]); } av_freep(&filtergraphs[i]->outputs); av_freep(&filtergraphs[i]->graph_desc); av_freep(&filtergraphs[i]); } av_freep(&filtergraphs); for (i = 0; i < nb_output_files; i++) { AVFormatContext *s = output_files[i]->ctx; if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE) && s->pb) avio_close(s->pb); avformat_free_context(s); av_dict_free(&output_files[i]->opts); av_freep(&output_files[i]); } for (i = 0; i < nb_output_streams; i++) { AVBitStreamFilterContext *bsfc = output_streams[i]->bitstream_filters; while (bsfc) { AVBitStreamFilterContext *next = bsfc->next; av_bitstream_filter_close(bsfc); bsfc = next; } output_streams[i]->bitstream_filters = NULL; avcodec_free_frame(&output_streams[i]->filtered_frame); av_freep(&output_streams[i]->forced_keyframes); av_freep(&output_streams[i]->avfilter); av_freep(&output_streams[i]->logfile_prefix); av_freep(&output_streams[i]); } for (i = 0; i < nb_input_files; i++) { avformat_close_input(&input_files[i]->ctx); av_freep(&input_files[i]); } for (i = 0; i < nb_input_streams; i++) { av_frame_free(&input_streams[i]->decoded_frame); av_frame_free(&input_streams[i]->filter_frame); av_dict_free(&input_streams[i]->opts); av_freep(&input_streams[i]->filters); av_freep(&input_streams[i]); } if (vstats_file) fclose(vstats_file); av_free(vstats_filename); av_freep(&input_streams); av_freep(&input_files); av_freep(&output_streams); av_freep(&output_files); uninit_opts(); avformat_network_deinit(); if (received_sigterm) { av_log(NULL, AV_LOG_INFO, "Received signal %d: terminating.\n", (int) received_sigterm); exit (255); } }
{ "code": [ "static void exit_program(void)", "static void exit_program(void)" ], "line_no": [ 1, 1 ] }
static void FUNC_0(void) { int VAR_0, VAR_1; for (VAR_0 = 0; VAR_0 < nb_filtergraphs; VAR_0++) { avfilter_graph_free(&filtergraphs[VAR_0]->graph); for (VAR_1 = 0; VAR_1 < filtergraphs[VAR_0]->nb_inputs; VAR_1++) { av_freep(&filtergraphs[VAR_0]->inputs[VAR_1]->name); av_freep(&filtergraphs[VAR_0]->inputs[VAR_1]); } av_freep(&filtergraphs[VAR_0]->inputs); for (VAR_1 = 0; VAR_1 < filtergraphs[VAR_0]->nb_outputs; VAR_1++) { av_freep(&filtergraphs[VAR_0]->outputs[VAR_1]->name); av_freep(&filtergraphs[VAR_0]->outputs[VAR_1]); } av_freep(&filtergraphs[VAR_0]->outputs); av_freep(&filtergraphs[VAR_0]->graph_desc); av_freep(&filtergraphs[VAR_0]); } av_freep(&filtergraphs); for (VAR_0 = 0; VAR_0 < nb_output_files; VAR_0++) { AVFormatContext *s = output_files[VAR_0]->ctx; if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE) && s->pb) avio_close(s->pb); avformat_free_context(s); av_dict_free(&output_files[VAR_0]->opts); av_freep(&output_files[VAR_0]); } for (VAR_0 = 0; VAR_0 < nb_output_streams; VAR_0++) { AVBitStreamFilterContext *bsfc = output_streams[VAR_0]->bitstream_filters; while (bsfc) { AVBitStreamFilterContext *next = bsfc->next; av_bitstream_filter_close(bsfc); bsfc = next; } output_streams[VAR_0]->bitstream_filters = NULL; avcodec_free_frame(&output_streams[VAR_0]->filtered_frame); av_freep(&output_streams[VAR_0]->forced_keyframes); av_freep(&output_streams[VAR_0]->avfilter); av_freep(&output_streams[VAR_0]->logfile_prefix); av_freep(&output_streams[VAR_0]); } for (VAR_0 = 0; VAR_0 < nb_input_files; VAR_0++) { avformat_close_input(&input_files[VAR_0]->ctx); av_freep(&input_files[VAR_0]); } for (VAR_0 = 0; VAR_0 < nb_input_streams; VAR_0++) { av_frame_free(&input_streams[VAR_0]->decoded_frame); av_frame_free(&input_streams[VAR_0]->filter_frame); av_dict_free(&input_streams[VAR_0]->opts); av_freep(&input_streams[VAR_0]->filters); av_freep(&input_streams[VAR_0]); } if (vstats_file) fclose(vstats_file); av_free(vstats_filename); av_freep(&input_streams); av_freep(&input_files); av_freep(&output_streams); av_freep(&output_files); uninit_opts(); avformat_network_deinit(); if (received_sigterm) { av_log(NULL, AV_LOG_INFO, "Received signal %d: terminating.\n", (int) received_sigterm); exit (255); } }
[ "static void FUNC_0(void)\n{", "int VAR_0, VAR_1;", "for (VAR_0 = 0; VAR_0 < nb_filtergraphs; VAR_0++) {", "avfilter_graph_free(&filtergraphs[VAR_0]->graph);", "for (VAR_1 = 0; VAR_1 < filtergraphs[VAR_0]->nb_inputs; VAR_1++) {", "av_freep(&filtergraphs[VAR_0]->inputs[VAR_1]->name);", "av_freep(&filtergraphs[VAR_0]->inputs[VAR_1]);", "}", "av_freep(&filtergraphs[VAR_0]->inputs);", "for (VAR_1 = 0; VAR_1 < filtergraphs[VAR_0]->nb_outputs; VAR_1++) {", "av_freep(&filtergraphs[VAR_0]->outputs[VAR_1]->name);", "av_freep(&filtergraphs[VAR_0]->outputs[VAR_1]);", "}", "av_freep(&filtergraphs[VAR_0]->outputs);", "av_freep(&filtergraphs[VAR_0]->graph_desc);", "av_freep(&filtergraphs[VAR_0]);", "}", "av_freep(&filtergraphs);", "for (VAR_0 = 0; VAR_0 < nb_output_files; VAR_0++) {", "AVFormatContext *s = output_files[VAR_0]->ctx;", "if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE) && s->pb)\navio_close(s->pb);", "avformat_free_context(s);", "av_dict_free(&output_files[VAR_0]->opts);", "av_freep(&output_files[VAR_0]);", "}", "for (VAR_0 = 0; VAR_0 < nb_output_streams; VAR_0++) {", "AVBitStreamFilterContext *bsfc = output_streams[VAR_0]->bitstream_filters;", "while (bsfc) {", "AVBitStreamFilterContext *next = bsfc->next;", "av_bitstream_filter_close(bsfc);", "bsfc = next;", "}", "output_streams[VAR_0]->bitstream_filters = NULL;", "avcodec_free_frame(&output_streams[VAR_0]->filtered_frame);", "av_freep(&output_streams[VAR_0]->forced_keyframes);", "av_freep(&output_streams[VAR_0]->avfilter);", "av_freep(&output_streams[VAR_0]->logfile_prefix);", "av_freep(&output_streams[VAR_0]);", "}", "for (VAR_0 = 0; VAR_0 < nb_input_files; VAR_0++) {", "avformat_close_input(&input_files[VAR_0]->ctx);", "av_freep(&input_files[VAR_0]);", "}", "for (VAR_0 = 0; VAR_0 < nb_input_streams; VAR_0++) {", "av_frame_free(&input_streams[VAR_0]->decoded_frame);", "av_frame_free(&input_streams[VAR_0]->filter_frame);", "av_dict_free(&input_streams[VAR_0]->opts);", "av_freep(&input_streams[VAR_0]->filters);", "av_freep(&input_streams[VAR_0]);", "}", "if (vstats_file)\nfclose(vstats_file);", "av_free(vstats_filename);", "av_freep(&input_streams);", "av_freep(&input_files);", "av_freep(&output_streams);", "av_freep(&output_files);", "uninit_opts();", "avformat_network_deinit();", "if (received_sigterm) {", "av_log(NULL, AV_LOG_INFO, \"Received signal %d: terminating.\\n\",\n(int) received_sigterm);", "exit (255);", "}", "}" ]
[ 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 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 45 ], [ 47 ], [ 49, 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 115, 117 ], [ 119 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 133 ], [ 137 ], [ 141 ], [ 143, 145 ], [ 147 ], [ 149 ], [ 151 ] ]
11,345
static bool scsi_target_emulate_report_luns(SCSITargetReq *r) { BusChild *kid; int i, len, n; int channel, id; bool found_lun0; if (r->req.cmd.xfer < 16) { return false; } if (r->req.cmd.buf[2] > 2) { return false; } channel = r->req.dev->channel; id = r->req.dev->id; found_lun0 = false; n = 0; QTAILQ_FOREACH(kid, &r->req.bus->qbus.children, sibling) { DeviceState *qdev = kid->child; SCSIDevice *dev = SCSI_DEVICE(qdev); if (dev->channel == channel && dev->id == id) { if (dev->lun == 0) { found_lun0 = true; } n += 8; } } if (!found_lun0) { n += 8; } len = MIN(n + 8, r->req.cmd.xfer & ~7); if (len > sizeof(r->buf)) { /* TODO: > 256 LUNs? */ return false; } memset(r->buf, 0, len); stl_be_p(&r->buf, n); i = found_lun0 ? 8 : 16; QTAILQ_FOREACH(kid, &r->req.bus->qbus.children, sibling) { DeviceState *qdev = kid->child; SCSIDevice *dev = SCSI_DEVICE(qdev); if (dev->channel == channel && dev->id == id) { store_lun(&r->buf[i], dev->lun); i += 8; } } assert(i == n + 8); r->len = len; return true; }
true
qemu
846424350b292f16b732b573273a5c1f195cd7a3
static bool scsi_target_emulate_report_luns(SCSITargetReq *r) { BusChild *kid; int i, len, n; int channel, id; bool found_lun0; if (r->req.cmd.xfer < 16) { return false; } if (r->req.cmd.buf[2] > 2) { return false; } channel = r->req.dev->channel; id = r->req.dev->id; found_lun0 = false; n = 0; QTAILQ_FOREACH(kid, &r->req.bus->qbus.children, sibling) { DeviceState *qdev = kid->child; SCSIDevice *dev = SCSI_DEVICE(qdev); if (dev->channel == channel && dev->id == id) { if (dev->lun == 0) { found_lun0 = true; } n += 8; } } if (!found_lun0) { n += 8; } len = MIN(n + 8, r->req.cmd.xfer & ~7); if (len > sizeof(r->buf)) { return false; } memset(r->buf, 0, len); stl_be_p(&r->buf, n); i = found_lun0 ? 8 : 16; QTAILQ_FOREACH(kid, &r->req.bus->qbus.children, sibling) { DeviceState *qdev = kid->child; SCSIDevice *dev = SCSI_DEVICE(qdev); if (dev->channel == channel && dev->id == id) { store_lun(&r->buf[i], dev->lun); i += 8; } } assert(i == n + 8); r->len = len; return true; }
{ "code": [ " len = MIN(n + 8, r->req.cmd.xfer & ~7);", " if (len > sizeof(r->buf)) {", " return false;", " stl_be_p(&r->buf, n);" ], "line_no": [ 63, 65, 17, 77 ] }
static bool FUNC_0(SCSITargetReq *r) { BusChild *kid; int VAR_0, VAR_1, VAR_2; int VAR_3, VAR_4; bool found_lun0; if (r->req.cmd.xfer < 16) { return false; } if (r->req.cmd.buf[2] > 2) { return false; } VAR_3 = r->req.dev->VAR_3; VAR_4 = r->req.dev->VAR_4; found_lun0 = false; VAR_2 = 0; QTAILQ_FOREACH(kid, &r->req.bus->qbus.children, sibling) { DeviceState *qdev = kid->child; SCSIDevice *dev = SCSI_DEVICE(qdev); if (dev->VAR_3 == VAR_3 && dev->VAR_4 == VAR_4) { if (dev->lun == 0) { found_lun0 = true; } VAR_2 += 8; } } if (!found_lun0) { VAR_2 += 8; } VAR_1 = MIN(VAR_2 + 8, r->req.cmd.xfer & ~7); if (VAR_1 > sizeof(r->buf)) { return false; } memset(r->buf, 0, VAR_1); stl_be_p(&r->buf, VAR_2); VAR_0 = found_lun0 ? 8 : 16; QTAILQ_FOREACH(kid, &r->req.bus->qbus.children, sibling) { DeviceState *qdev = kid->child; SCSIDevice *dev = SCSI_DEVICE(qdev); if (dev->VAR_3 == VAR_3 && dev->VAR_4 == VAR_4) { store_lun(&r->buf[VAR_0], dev->lun); VAR_0 += 8; } } assert(VAR_0 == VAR_2 + 8); r->VAR_1 = VAR_1; return true; }
[ "static bool FUNC_0(SCSITargetReq *r)\n{", "BusChild *kid;", "int VAR_0, VAR_1, VAR_2;", "int VAR_3, VAR_4;", "bool found_lun0;", "if (r->req.cmd.xfer < 16) {", "return false;", "}", "if (r->req.cmd.buf[2] > 2) {", "return false;", "}", "VAR_3 = r->req.dev->VAR_3;", "VAR_4 = r->req.dev->VAR_4;", "found_lun0 = false;", "VAR_2 = 0;", "QTAILQ_FOREACH(kid, &r->req.bus->qbus.children, sibling) {", "DeviceState *qdev = kid->child;", "SCSIDevice *dev = SCSI_DEVICE(qdev);", "if (dev->VAR_3 == VAR_3 && dev->VAR_4 == VAR_4) {", "if (dev->lun == 0) {", "found_lun0 = true;", "}", "VAR_2 += 8;", "}", "}", "if (!found_lun0) {", "VAR_2 += 8;", "}", "VAR_1 = MIN(VAR_2 + 8, r->req.cmd.xfer & ~7);", "if (VAR_1 > sizeof(r->buf)) {", "return false;", "}", "memset(r->buf, 0, VAR_1);", "stl_be_p(&r->buf, VAR_2);", "VAR_0 = found_lun0 ? 8 : 16;", "QTAILQ_FOREACH(kid, &r->req.bus->qbus.children, sibling) {", "DeviceState *qdev = kid->child;", "SCSIDevice *dev = SCSI_DEVICE(qdev);", "if (dev->VAR_3 == VAR_3 && dev->VAR_4 == VAR_4) {", "store_lun(&r->buf[VAR_0], dev->lun);", "VAR_0 += 8;", "}", "}", "assert(VAR_0 == VAR_2 + 8);", "r->VAR_1 = VAR_1;", "return true;", "}" ]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 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 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ] ]
11,346
static int check_directory_consistency(BDRVVVFATState *s, int cluster_num, const char* path) { int ret = 0; unsigned char* cluster = qemu_malloc(s->cluster_size); direntry_t* direntries = (direntry_t*)cluster; mapping_t* mapping = find_mapping_for_cluster(s, cluster_num); long_file_name lfn; int path_len = strlen(path); char path2[PATH_MAX]; assert(path_len < PATH_MAX); /* len was tested before! */ pstrcpy(path2, sizeof(path2), path); path2[path_len] = '/'; path2[path_len + 1] = '\0'; if (mapping) { const char* basename = get_basename(mapping->path); const char* basename2 = get_basename(path); assert(mapping->mode & MODE_DIRECTORY); assert(mapping->mode & MODE_DELETED); mapping->mode &= ~MODE_DELETED; if (strcmp(basename, basename2)) schedule_rename(s, cluster_num, strdup(path)); } else /* new directory */ schedule_mkdir(s, cluster_num, strdup(path)); lfn_init(&lfn); do { int i; int subret = 0; ret++; if (s->used_clusters[cluster_num] & USED_ANY) { fprintf(stderr, "cluster %d used more than once\n", (int)cluster_num); return 0; } s->used_clusters[cluster_num] = USED_DIRECTORY; DLOG(fprintf(stderr, "read cluster %d (sector %d)\n", (int)cluster_num, (int)cluster2sector(s, cluster_num))); subret = vvfat_read(s->bs, cluster2sector(s, cluster_num), cluster, s->sectors_per_cluster); if (subret) { fprintf(stderr, "Error fetching direntries\n"); fail: free(cluster); return 0; } for (i = 0; i < 0x10 * s->sectors_per_cluster; i++) { int cluster_count = 0; DLOG(fprintf(stderr, "check direntry %d: \n", i); print_direntry(direntries + i)); if (is_volume_label(direntries + i) || is_dot(direntries + i) || is_free(direntries + i)) continue; subret = parse_long_name(&lfn, direntries + i); if (subret < 0) { fprintf(stderr, "Error in long name\n"); goto fail; } if (subret == 0 || is_free(direntries + i)) continue; if (fat_chksum(direntries+i) != lfn.checksum) { subret = parse_short_name(s, &lfn, direntries + i); if (subret < 0) { fprintf(stderr, "Error in short name (%d)\n", subret); goto fail; } if (subret > 0 || !strcmp((char*)lfn.name, ".") || !strcmp((char*)lfn.name, "..")) continue; } lfn.checksum = 0x100; /* cannot use long name twice */ if (path_len + 1 + lfn.len >= PATH_MAX) { fprintf(stderr, "Name too long: %s/%s\n", path, lfn.name); goto fail; } pstrcpy(path2 + path_len + 1, sizeof(path2) - path_len - 1, (char*)lfn.name); if (is_directory(direntries + i)) { if (begin_of_direntry(direntries + i) == 0) { DLOG(fprintf(stderr, "invalid begin for directory: %s\n", path2); print_direntry(direntries + i)); goto fail; } cluster_count = check_directory_consistency(s, begin_of_direntry(direntries + i), path2); if (cluster_count == 0) { DLOG(fprintf(stderr, "problem in directory %s:\n", path2); print_direntry(direntries + i)); goto fail; } } else if (is_file(direntries + i)) { /* check file size with FAT */ cluster_count = get_cluster_count_for_direntry(s, direntries + i, path2); if (cluster_count != (le32_to_cpu(direntries[i].size) + s->cluster_size - 1) / s->cluster_size) { DLOG(fprintf(stderr, "Cluster count mismatch\n")); goto fail; } } else assert(0); /* cluster_count = 0; */ ret += cluster_count; } cluster_num = modified_fat_get(s, cluster_num); } while(!fat_eof(s, cluster_num)); free(cluster); return ret; }
true
qemu
6265eb26a375179f193f792e4f0d49036d2cf052
static int check_directory_consistency(BDRVVVFATState *s, int cluster_num, const char* path) { int ret = 0; unsigned char* cluster = qemu_malloc(s->cluster_size); direntry_t* direntries = (direntry_t*)cluster; mapping_t* mapping = find_mapping_for_cluster(s, cluster_num); long_file_name lfn; int path_len = strlen(path); char path2[PATH_MAX]; assert(path_len < PATH_MAX); pstrcpy(path2, sizeof(path2), path); path2[path_len] = '/'; path2[path_len + 1] = '\0'; if (mapping) { const char* basename = get_basename(mapping->path); const char* basename2 = get_basename(path); assert(mapping->mode & MODE_DIRECTORY); assert(mapping->mode & MODE_DELETED); mapping->mode &= ~MODE_DELETED; if (strcmp(basename, basename2)) schedule_rename(s, cluster_num, strdup(path)); } else schedule_mkdir(s, cluster_num, strdup(path)); lfn_init(&lfn); do { int i; int subret = 0; ret++; if (s->used_clusters[cluster_num] & USED_ANY) { fprintf(stderr, "cluster %d used more than once\n", (int)cluster_num); return 0; } s->used_clusters[cluster_num] = USED_DIRECTORY; DLOG(fprintf(stderr, "read cluster %d (sector %d)\n", (int)cluster_num, (int)cluster2sector(s, cluster_num))); subret = vvfat_read(s->bs, cluster2sector(s, cluster_num), cluster, s->sectors_per_cluster); if (subret) { fprintf(stderr, "Error fetching direntries\n"); fail: free(cluster); return 0; } for (i = 0; i < 0x10 * s->sectors_per_cluster; i++) { int cluster_count = 0; DLOG(fprintf(stderr, "check direntry %d: \n", i); print_direntry(direntries + i)); if (is_volume_label(direntries + i) || is_dot(direntries + i) || is_free(direntries + i)) continue; subret = parse_long_name(&lfn, direntries + i); if (subret < 0) { fprintf(stderr, "Error in long name\n"); goto fail; } if (subret == 0 || is_free(direntries + i)) continue; if (fat_chksum(direntries+i) != lfn.checksum) { subret = parse_short_name(s, &lfn, direntries + i); if (subret < 0) { fprintf(stderr, "Error in short name (%d)\n", subret); goto fail; } if (subret > 0 || !strcmp((char*)lfn.name, ".") || !strcmp((char*)lfn.name, "..")) continue; } lfn.checksum = 0x100; if (path_len + 1 + lfn.len >= PATH_MAX) { fprintf(stderr, "Name too long: %s/%s\n", path, lfn.name); goto fail; } pstrcpy(path2 + path_len + 1, sizeof(path2) - path_len - 1, (char*)lfn.name); if (is_directory(direntries + i)) { if (begin_of_direntry(direntries + i) == 0) { DLOG(fprintf(stderr, "invalid begin for directory: %s\n", path2); print_direntry(direntries + i)); goto fail; } cluster_count = check_directory_consistency(s, begin_of_direntry(direntries + i), path2); if (cluster_count == 0) { DLOG(fprintf(stderr, "problem in directory %s:\n", path2); print_direntry(direntries + i)); goto fail; } } else if (is_file(direntries + i)) { cluster_count = get_cluster_count_for_direntry(s, direntries + i, path2); if (cluster_count != (le32_to_cpu(direntries[i].size) + s->cluster_size - 1) / s->cluster_size) { DLOG(fprintf(stderr, "Cluster count mismatch\n")); goto fail; } } else assert(0); ret += cluster_count; } cluster_num = modified_fat_get(s, cluster_num); } while(!fat_eof(s, cluster_num)); free(cluster); return ret; }
{ "code": [ "\t schedule_rename(s, cluster_num, strdup(path));", "\tschedule_mkdir(s, cluster_num, strdup(path));" ], "line_no": [ 55, 61 ] }
static int FUNC_0(BDRVVVFATState *VAR_0, int VAR_1, const char* VAR_2) { int VAR_3 = 0; unsigned char* VAR_4 = qemu_malloc(VAR_0->cluster_size); direntry_t* direntries = (direntry_t*)VAR_4; mapping_t* mapping = find_mapping_for_cluster(VAR_0, VAR_1); long_file_name lfn; int VAR_5 = strlen(VAR_2); char VAR_6[PATH_MAX]; assert(VAR_5 < PATH_MAX); pstrcpy(VAR_6, sizeof(VAR_6), VAR_2); VAR_6[VAR_5] = '/'; VAR_6[VAR_5 + 1] = '\0'; if (mapping) { const char* VAR_7 = get_basename(mapping->VAR_2); const char* VAR_8 = get_basename(VAR_2); assert(mapping->mode & MODE_DIRECTORY); assert(mapping->mode & MODE_DELETED); mapping->mode &= ~MODE_DELETED; if (strcmp(VAR_7, VAR_8)) schedule_rename(VAR_0, VAR_1, strdup(VAR_2)); } else schedule_mkdir(VAR_0, VAR_1, strdup(VAR_2)); lfn_init(&lfn); do { int VAR_9; int VAR_10 = 0; VAR_3++; if (VAR_0->used_clusters[VAR_1] & USED_ANY) { fprintf(stderr, "VAR_4 %d used more than once\n", (int)VAR_1); return 0; } VAR_0->used_clusters[VAR_1] = USED_DIRECTORY; DLOG(fprintf(stderr, "read VAR_4 %d (sector %d)\n", (int)VAR_1, (int)cluster2sector(VAR_0, VAR_1))); VAR_10 = vvfat_read(VAR_0->bs, cluster2sector(VAR_0, VAR_1), VAR_4, VAR_0->sectors_per_cluster); if (VAR_10) { fprintf(stderr, "Error fetching direntries\n"); fail: free(VAR_4); return 0; } for (VAR_9 = 0; VAR_9 < 0x10 * VAR_0->sectors_per_cluster; VAR_9++) { int cluster_count = 0; DLOG(fprintf(stderr, "check direntry %d: \n", VAR_9); print_direntry(direntries + VAR_9)); if (is_volume_label(direntries + VAR_9) || is_dot(direntries + VAR_9) || is_free(direntries + VAR_9)) continue; VAR_10 = parse_long_name(&lfn, direntries + VAR_9); if (VAR_10 < 0) { fprintf(stderr, "Error in long name\n"); goto fail; } if (VAR_10 == 0 || is_free(direntries + VAR_9)) continue; if (fat_chksum(direntries+VAR_9) != lfn.checksum) { VAR_10 = parse_short_name(VAR_0, &lfn, direntries + VAR_9); if (VAR_10 < 0) { fprintf(stderr, "Error in short name (%d)\n", VAR_10); goto fail; } if (VAR_10 > 0 || !strcmp((char*)lfn.name, ".") || !strcmp((char*)lfn.name, "..")) continue; } lfn.checksum = 0x100; if (VAR_5 + 1 + lfn.len >= PATH_MAX) { fprintf(stderr, "Name too long: %VAR_0/%VAR_0\n", VAR_2, lfn.name); goto fail; } pstrcpy(VAR_6 + VAR_5 + 1, sizeof(VAR_6) - VAR_5 - 1, (char*)lfn.name); if (is_directory(direntries + VAR_9)) { if (begin_of_direntry(direntries + VAR_9) == 0) { DLOG(fprintf(stderr, "invalid begin for directory: %VAR_0\n", VAR_6); print_direntry(direntries + VAR_9)); goto fail; } cluster_count = FUNC_0(VAR_0, begin_of_direntry(direntries + VAR_9), VAR_6); if (cluster_count == 0) { DLOG(fprintf(stderr, "problem in directory %VAR_0:\n", VAR_6); print_direntry(direntries + VAR_9)); goto fail; } } else if (is_file(direntries + VAR_9)) { cluster_count = get_cluster_count_for_direntry(VAR_0, direntries + VAR_9, VAR_6); if (cluster_count != (le32_to_cpu(direntries[VAR_9].size) + VAR_0->cluster_size - 1) / VAR_0->cluster_size) { DLOG(fprintf(stderr, "Cluster count mismatch\n")); goto fail; } } else assert(0); VAR_3 += cluster_count; } VAR_1 = modified_fat_get(VAR_0, VAR_1); } while(!fat_eof(VAR_0, VAR_1)); free(VAR_4); return VAR_3; }
[ "static int FUNC_0(BDRVVVFATState *VAR_0,\nint VAR_1, const char* VAR_2)\n{", "int VAR_3 = 0;", "unsigned char* VAR_4 = qemu_malloc(VAR_0->cluster_size);", "direntry_t* direntries = (direntry_t*)VAR_4;", "mapping_t* mapping = find_mapping_for_cluster(VAR_0, VAR_1);", "long_file_name lfn;", "int VAR_5 = strlen(VAR_2);", "char VAR_6[PATH_MAX];", "assert(VAR_5 < PATH_MAX);", "pstrcpy(VAR_6, sizeof(VAR_6), VAR_2);", "VAR_6[VAR_5] = '/';", "VAR_6[VAR_5 + 1] = '\\0';", "if (mapping) {", "const char* VAR_7 = get_basename(mapping->VAR_2);", "const char* VAR_8 = get_basename(VAR_2);", "assert(mapping->mode & MODE_DIRECTORY);", "assert(mapping->mode & MODE_DELETED);", "mapping->mode &= ~MODE_DELETED;", "if (strcmp(VAR_7, VAR_8))\nschedule_rename(VAR_0, VAR_1, strdup(VAR_2));", "} else", "schedule_mkdir(VAR_0, VAR_1, strdup(VAR_2));", "lfn_init(&lfn);", "do {", "int VAR_9;", "int VAR_10 = 0;", "VAR_3++;", "if (VAR_0->used_clusters[VAR_1] & USED_ANY) {", "fprintf(stderr, \"VAR_4 %d used more than once\\n\", (int)VAR_1);", "return 0;", "}", "VAR_0->used_clusters[VAR_1] = USED_DIRECTORY;", "DLOG(fprintf(stderr, \"read VAR_4 %d (sector %d)\\n\", (int)VAR_1, (int)cluster2sector(VAR_0, VAR_1)));", "VAR_10 = vvfat_read(VAR_0->bs, cluster2sector(VAR_0, VAR_1), VAR_4,\nVAR_0->sectors_per_cluster);", "if (VAR_10) {", "fprintf(stderr, \"Error fetching direntries\\n\");", "fail:\nfree(VAR_4);", "return 0;", "}", "for (VAR_9 = 0; VAR_9 < 0x10 * VAR_0->sectors_per_cluster; VAR_9++) {", "int cluster_count = 0;", "DLOG(fprintf(stderr, \"check direntry %d: \\n\", VAR_9); print_direntry(direntries + VAR_9));", "if (is_volume_label(direntries + VAR_9) || is_dot(direntries + VAR_9) ||\nis_free(direntries + VAR_9))\ncontinue;", "VAR_10 = parse_long_name(&lfn, direntries + VAR_9);", "if (VAR_10 < 0) {", "fprintf(stderr, \"Error in long name\\n\");", "goto fail;", "}", "if (VAR_10 == 0 || is_free(direntries + VAR_9))\ncontinue;", "if (fat_chksum(direntries+VAR_9) != lfn.checksum) {", "VAR_10 = parse_short_name(VAR_0, &lfn, direntries + VAR_9);", "if (VAR_10 < 0) {", "fprintf(stderr, \"Error in short name (%d)\\n\", VAR_10);", "goto fail;", "}", "if (VAR_10 > 0 || !strcmp((char*)lfn.name, \".\")\n|| !strcmp((char*)lfn.name, \"..\"))\ncontinue;", "}", "lfn.checksum = 0x100;", "if (VAR_5 + 1 + lfn.len >= PATH_MAX) {", "fprintf(stderr, \"Name too long: %VAR_0/%VAR_0\\n\", VAR_2, lfn.name);", "goto fail;", "}", "pstrcpy(VAR_6 + VAR_5 + 1, sizeof(VAR_6) - VAR_5 - 1,\n(char*)lfn.name);", "if (is_directory(direntries + VAR_9)) {", "if (begin_of_direntry(direntries + VAR_9) == 0) {", "DLOG(fprintf(stderr, \"invalid begin for directory: %VAR_0\\n\", VAR_6); print_direntry(direntries + VAR_9));", "goto fail;", "}", "cluster_count = FUNC_0(VAR_0,\nbegin_of_direntry(direntries + VAR_9), VAR_6);", "if (cluster_count == 0) {", "DLOG(fprintf(stderr, \"problem in directory %VAR_0:\\n\", VAR_6); print_direntry(direntries + VAR_9));", "goto fail;", "}", "} else if (is_file(direntries + VAR_9)) {", "cluster_count = get_cluster_count_for_direntry(VAR_0, direntries + VAR_9, VAR_6);", "if (cluster_count !=\n(le32_to_cpu(direntries[VAR_9].size) + VAR_0->cluster_size\n- 1) / VAR_0->cluster_size) {", "DLOG(fprintf(stderr, \"Cluster count mismatch\\n\"));", "goto fail;", "}", "} else", "assert(0);", "VAR_3 += cluster_count;", "}", "VAR_1 = modified_fat_get(VAR_0, VAR_1);", "} while(!fat_eof(VAR_0, VAR_1));", "free(VAR_4);", "return VAR_3;", "}" ]
[ 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 47 ], [ 49 ], [ 53, 55 ], [ 57 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 91 ], [ 93, 95 ], [ 97 ], [ 99 ], [ 101, 103 ], [ 105 ], [ 107 ], [ 111 ], [ 113 ], [ 117 ], [ 119, 121, 123 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137, 139 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155, 157, 159 ], [ 161 ], [ 163 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175, 177 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191, 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 207 ], [ 209, 211, 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 227 ], [ 229 ], [ 233 ], [ 235 ], [ 239 ], [ 241 ], [ 243 ] ]
11,347
static int rpl_read_header(AVFormatContext *s) { AVIOContext *pb = s->pb; RPLContext *rpl = s->priv_data; AVStream *vst = NULL, *ast = NULL; int total_audio_size; int error = 0; uint32_t i; int32_t audio_format, chunk_catalog_offset, number_of_chunks; AVRational fps; char line[RPL_LINE_LENGTH]; // The header for RPL/ARMovie files is 21 lines of text // containing the various header fields. The fields are always // in the same order, and other text besides the first // number usually isn't important. // (The spec says that there exists some significance // for the text in a few cases; samples needed.) error |= read_line(pb, line, sizeof(line)); // ARMovie error |= read_line(pb, line, sizeof(line)); // movie name av_dict_set(&s->metadata, "title" , line, 0); error |= read_line(pb, line, sizeof(line)); // date/copyright av_dict_set(&s->metadata, "copyright", line, 0); error |= read_line(pb, line, sizeof(line)); // author and other av_dict_set(&s->metadata, "author" , line, 0); // video headers vst = avformat_new_stream(s, NULL); if (!vst) return AVERROR(ENOMEM); vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_tag = read_line_and_int(pb, &error); // video format vst->codec->width = read_line_and_int(pb, &error); // video width vst->codec->height = read_line_and_int(pb, &error); // video height vst->codec->bits_per_coded_sample = read_line_and_int(pb, &error); // video bits per sample error |= read_line(pb, line, sizeof(line)); // video frames per second fps = read_fps(line, &error); avpriv_set_pts_info(vst, 32, fps.den, fps.num); // Figure out the video codec switch (vst->codec->codec_tag) { #if 0 case 122: vst->codec->codec_id = AV_CODEC_ID_ESCAPE122; break; #endif case 124: vst->codec->codec_id = AV_CODEC_ID_ESCAPE124; // The header is wrong here, at least sometimes vst->codec->bits_per_coded_sample = 16; break; case 130: vst->codec->codec_id = AV_CODEC_ID_ESCAPE130; break; default: avpriv_report_missing_feature(s, "Video format %i", vst->codec->codec_tag); vst->codec->codec_id = AV_CODEC_ID_NONE; } // Audio headers // ARMovie supports multiple audio tracks; I don't have any // samples, though. This code will ignore additional tracks. audio_format = read_line_and_int(pb, &error); // audio format ID if (audio_format) { ast = avformat_new_stream(s, NULL); if (!ast) return AVERROR(ENOMEM); ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; ast->codec->codec_tag = audio_format; ast->codec->sample_rate = read_line_and_int(pb, &error); // audio bitrate ast->codec->channels = read_line_and_int(pb, &error); // number of audio channels ast->codec->bits_per_coded_sample = read_line_and_int(pb, &error); // audio bits per sample // At least one sample uses 0 for ADPCM, which is really 4 bits // per sample. if (ast->codec->bits_per_coded_sample == 0) ast->codec->bits_per_coded_sample = 4; ast->codec->bit_rate = ast->codec->sample_rate * ast->codec->bits_per_coded_sample * ast->codec->channels; ast->codec->codec_id = AV_CODEC_ID_NONE; switch (audio_format) { case 1: if (ast->codec->bits_per_coded_sample == 16) { // 16-bit audio is always signed ast->codec->codec_id = AV_CODEC_ID_PCM_S16LE; break; } // There are some other formats listed as legal per the spec; // samples needed. break; case 101: if (ast->codec->bits_per_coded_sample == 8) { // The samples with this kind of audio that I have // are all unsigned. ast->codec->codec_id = AV_CODEC_ID_PCM_U8; break; } else if (ast->codec->bits_per_coded_sample == 4) { ast->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_EA_SEAD; break; } break; } if (ast->codec->codec_id == AV_CODEC_ID_NONE) avpriv_request_sample(s, "Audio format %i", audio_format); avpriv_set_pts_info(ast, 32, 1, ast->codec->bit_rate); } else { for (i = 0; i < 3; i++) error |= read_line(pb, line, sizeof(line)); } rpl->frames_per_chunk = read_line_and_int(pb, &error); // video frames per chunk if (rpl->frames_per_chunk > 1 && vst->codec->codec_tag != 124) av_log(s, AV_LOG_WARNING, "Don't know how to split frames for video format %i. " "Video stream will be broken!\n", vst->codec->codec_tag); number_of_chunks = read_line_and_int(pb, &error); // number of chunks in the file // The number in the header is actually the index of the last chunk. number_of_chunks++; error |= read_line(pb, line, sizeof(line)); // "even" chunk size in bytes error |= read_line(pb, line, sizeof(line)); // "odd" chunk size in bytes chunk_catalog_offset = // offset of the "chunk catalog" read_line_and_int(pb, &error); // (file index) error |= read_line(pb, line, sizeof(line)); // offset to "helpful" sprite error |= read_line(pb, line, sizeof(line)); // size of "helpful" sprite error |= read_line(pb, line, sizeof(line)); // offset to key frame list // Read the index avio_seek(pb, chunk_catalog_offset, SEEK_SET); total_audio_size = 0; for (i = 0; !error && i < number_of_chunks; i++) { int64_t offset, video_size, audio_size; error |= read_line(pb, line, sizeof(line)); if (3 != sscanf(line, "%"SCNd64" , %"SCNd64" ; %"SCNd64, &offset, &video_size, &audio_size)) error = -1; av_add_index_entry(vst, offset, i * rpl->frames_per_chunk, video_size, rpl->frames_per_chunk, 0); if (ast) av_add_index_entry(ast, offset + video_size, total_audio_size, audio_size, audio_size * 8, 0); total_audio_size += audio_size * 8; } if (error) return AVERROR(EIO); return 0; }
true
FFmpeg
5eeeb4abf9705891f4dd1a4499588428319dec24
static int rpl_read_header(AVFormatContext *s) { AVIOContext *pb = s->pb; RPLContext *rpl = s->priv_data; AVStream *vst = NULL, *ast = NULL; int total_audio_size; int error = 0; uint32_t i; int32_t audio_format, chunk_catalog_offset, number_of_chunks; AVRational fps; char line[RPL_LINE_LENGTH]; error |= read_line(pb, line, sizeof(line)); error |= read_line(pb, line, sizeof(line)); av_dict_set(&s->metadata, "title" , line, 0); error |= read_line(pb, line, sizeof(line)); av_dict_set(&s->metadata, "copyright", line, 0); error |= read_line(pb, line, sizeof(line)); av_dict_set(&s->metadata, "author" , line, 0); vst = avformat_new_stream(s, NULL); if (!vst) return AVERROR(ENOMEM); vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_tag = read_line_and_int(pb, &error); vst->codec->width = read_line_and_int(pb, &error); vst->codec->height = read_line_and_int(pb, &error); vst->codec->bits_per_coded_sample = read_line_and_int(pb, &error); error |= read_line(pb, line, sizeof(line)); fps = read_fps(line, &error); avpriv_set_pts_info(vst, 32, fps.den, fps.num); switch (vst->codec->codec_tag) { #if 0 case 122: vst->codec->codec_id = AV_CODEC_ID_ESCAPE122; break; #endif case 124: vst->codec->codec_id = AV_CODEC_ID_ESCAPE124; vst->codec->bits_per_coded_sample = 16; break; case 130: vst->codec->codec_id = AV_CODEC_ID_ESCAPE130; break; default: avpriv_report_missing_feature(s, "Video format %i", vst->codec->codec_tag); vst->codec->codec_id = AV_CODEC_ID_NONE; } supports multiple audio tracks; I don't have any audio_format = read_line_and_int(pb, &error); if (audio_format) { ast = avformat_new_stream(s, NULL); if (!ast) return AVERROR(ENOMEM); ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; ast->codec->codec_tag = audio_format; ast->codec->sample_rate = read_line_and_int(pb, &error); ast->codec->channels = read_line_and_int(pb, &error); ast->codec->bits_per_coded_sample = read_line_and_int(pb, &error); if (ast->codec->bits_per_coded_sample == 0) ast->codec->bits_per_coded_sample = 4; ast->codec->bit_rate = ast->codec->sample_rate * ast->codec->bits_per_coded_sample * ast->codec->channels; ast->codec->codec_id = AV_CODEC_ID_NONE; switch (audio_format) { case 1: if (ast->codec->bits_per_coded_sample == 16) { ast->codec->codec_id = AV_CODEC_ID_PCM_S16LE; break; } break; case 101: if (ast->codec->bits_per_coded_sample == 8) { ast->codec->codec_id = AV_CODEC_ID_PCM_U8; break; } else if (ast->codec->bits_per_coded_sample == 4) { ast->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_EA_SEAD; break; } break; } if (ast->codec->codec_id == AV_CODEC_ID_NONE) avpriv_request_sample(s, "Audio format %i", audio_format); avpriv_set_pts_info(ast, 32, 1, ast->codec->bit_rate); } else { for (i = 0; i < 3; i++) error |= read_line(pb, line, sizeof(line)); } rpl->frames_per_chunk = read_line_and_int(pb, &error); if (rpl->frames_per_chunk > 1 && vst->codec->codec_tag != 124) av_log(s, AV_LOG_WARNING, "Don't know how to split frames for video format %i. " "Video stream will be broken!\n", vst->codec->codec_tag); number_of_chunks = read_line_and_int(pb, &error); number_of_chunks++; error |= read_line(pb, line, sizeof(line)); error |= read_line(pb, line, sizeof(line)); chunk_catalog_offset = read_line_and_int(pb, &error); error |= read_line(pb, line, sizeof(line)); error |= read_line(pb, line, sizeof(line)); error |= read_line(pb, line, sizeof(line)); avio_seek(pb, chunk_catalog_offset, SEEK_SET); total_audio_size = 0; for (i = 0; !error && i < number_of_chunks; i++) { int64_t offset, video_size, audio_size; error |= read_line(pb, line, sizeof(line)); if (3 != sscanf(line, "%"SCNd64" , %"SCNd64" ; %"SCNd64, &offset, &video_size, &audio_size)) error = -1; av_add_index_entry(vst, offset, i * rpl->frames_per_chunk, video_size, rpl->frames_per_chunk, 0); if (ast) av_add_index_entry(ast, offset + video_size, total_audio_size, audio_size, audio_size * 8, 0); total_audio_size += audio_size * 8; } if (error) return AVERROR(EIO); return 0; }
{ "code": [ " &offset, &video_size, &audio_size))" ], "line_no": [ 285 ] }
static int FUNC_0(AVFormatContext *VAR_0) { AVIOContext *pb = VAR_0->pb; RPLContext *rpl = VAR_0->priv_data; AVStream *vst = NULL, *ast = NULL; int VAR_1; int VAR_2 = 0; uint32_t i; int32_t audio_format, chunk_catalog_offset, number_of_chunks; AVRational fps; char VAR_3[RPL_LINE_LENGTH]; VAR_2 |= read_line(pb, VAR_3, sizeof(VAR_3)); VAR_2 |= read_line(pb, VAR_3, sizeof(VAR_3)); av_dict_set(&VAR_0->metadata, "title" , VAR_3, 0); VAR_2 |= read_line(pb, VAR_3, sizeof(VAR_3)); av_dict_set(&VAR_0->metadata, "copyright", VAR_3, 0); VAR_2 |= read_line(pb, VAR_3, sizeof(VAR_3)); av_dict_set(&VAR_0->metadata, "author" , VAR_3, 0); vst = avformat_new_stream(VAR_0, NULL); if (!vst) return AVERROR(ENOMEM); vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_tag = read_line_and_int(pb, &VAR_2); vst->codec->width = read_line_and_int(pb, &VAR_2); vst->codec->height = read_line_and_int(pb, &VAR_2); vst->codec->bits_per_coded_sample = read_line_and_int(pb, &VAR_2); VAR_2 |= read_line(pb, VAR_3, sizeof(VAR_3)); fps = read_fps(VAR_3, &VAR_2); avpriv_set_pts_info(vst, 32, fps.den, fps.num); switch (vst->codec->codec_tag) { #if 0 case 122: vst->codec->codec_id = AV_CODEC_ID_ESCAPE122; break; #endif case 124: vst->codec->codec_id = AV_CODEC_ID_ESCAPE124; vst->codec->bits_per_coded_sample = 16; break; case 130: vst->codec->codec_id = AV_CODEC_ID_ESCAPE130; break; default: avpriv_report_missing_feature(VAR_0, "Video format %i", vst->codec->codec_tag); vst->codec->codec_id = AV_CODEC_ID_NONE; } supports multiple audio tracks; I don't have any audio_format = read_line_and_int(pb, &VAR_2); if (audio_format) { ast = avformat_new_stream(VAR_0, NULL); if (!ast) return AVERROR(ENOMEM); ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; ast->codec->codec_tag = audio_format; ast->codec->sample_rate = read_line_and_int(pb, &VAR_2); ast->codec->channels = read_line_and_int(pb, &VAR_2); ast->codec->bits_per_coded_sample = read_line_and_int(pb, &VAR_2); if (ast->codec->bits_per_coded_sample == 0) ast->codec->bits_per_coded_sample = 4; ast->codec->bit_rate = ast->codec->sample_rate * ast->codec->bits_per_coded_sample * ast->codec->channels; ast->codec->codec_id = AV_CODEC_ID_NONE; switch (audio_format) { case 1: if (ast->codec->bits_per_coded_sample == 16) { ast->codec->codec_id = AV_CODEC_ID_PCM_S16LE; break; } break; case 101: if (ast->codec->bits_per_coded_sample == 8) { ast->codec->codec_id = AV_CODEC_ID_PCM_U8; break; } else if (ast->codec->bits_per_coded_sample == 4) { ast->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_EA_SEAD; break; } break; } if (ast->codec->codec_id == AV_CODEC_ID_NONE) avpriv_request_sample(VAR_0, "Audio format %i", audio_format); avpriv_set_pts_info(ast, 32, 1, ast->codec->bit_rate); } else { for (i = 0; i < 3; i++) VAR_2 |= read_line(pb, VAR_3, sizeof(VAR_3)); } rpl->frames_per_chunk = read_line_and_int(pb, &VAR_2); if (rpl->frames_per_chunk > 1 && vst->codec->codec_tag != 124) av_log(VAR_0, AV_LOG_WARNING, "Don't know how to split frames for video format %i. " "Video stream will be broken!\n", vst->codec->codec_tag); number_of_chunks = read_line_and_int(pb, &VAR_2); number_of_chunks++; VAR_2 |= read_line(pb, VAR_3, sizeof(VAR_3)); VAR_2 |= read_line(pb, VAR_3, sizeof(VAR_3)); chunk_catalog_offset = read_line_and_int(pb, &VAR_2); VAR_2 |= read_line(pb, VAR_3, sizeof(VAR_3)); VAR_2 |= read_line(pb, VAR_3, sizeof(VAR_3)); VAR_2 |= read_line(pb, VAR_3, sizeof(VAR_3)); avio_seek(pb, chunk_catalog_offset, SEEK_SET); VAR_1 = 0; for (i = 0; !VAR_2 && i < number_of_chunks; i++) { int64_t offset, video_size, audio_size; VAR_2 |= read_line(pb, VAR_3, sizeof(VAR_3)); if (3 != sscanf(VAR_3, "%"SCNd64" , %"SCNd64" ; %"SCNd64, &offset, &video_size, &audio_size)) VAR_2 = -1; av_add_index_entry(vst, offset, i * rpl->frames_per_chunk, video_size, rpl->frames_per_chunk, 0); if (ast) av_add_index_entry(ast, offset + video_size, VAR_1, audio_size, audio_size * 8, 0); VAR_1 += audio_size * 8; } if (VAR_2) return AVERROR(EIO); return 0; }
[ "static int FUNC_0(AVFormatContext *VAR_0)\n{", "AVIOContext *pb = VAR_0->pb;", "RPLContext *rpl = VAR_0->priv_data;", "AVStream *vst = NULL, *ast = NULL;", "int VAR_1;", "int VAR_2 = 0;", "uint32_t i;", "int32_t audio_format, chunk_catalog_offset, number_of_chunks;", "AVRational fps;", "char VAR_3[RPL_LINE_LENGTH];", "VAR_2 |= read_line(pb, VAR_3, sizeof(VAR_3));", "VAR_2 |= read_line(pb, VAR_3, sizeof(VAR_3));", "av_dict_set(&VAR_0->metadata, \"title\" , VAR_3, 0);", "VAR_2 |= read_line(pb, VAR_3, sizeof(VAR_3));", "av_dict_set(&VAR_0->metadata, \"copyright\", VAR_3, 0);", "VAR_2 |= read_line(pb, VAR_3, sizeof(VAR_3));", "av_dict_set(&VAR_0->metadata, \"author\" , VAR_3, 0);", "vst = avformat_new_stream(VAR_0, NULL);", "if (!vst)\nreturn AVERROR(ENOMEM);", "vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;", "vst->codec->codec_tag = read_line_and_int(pb, &VAR_2);", "vst->codec->width = read_line_and_int(pb, &VAR_2);", "vst->codec->height = read_line_and_int(pb, &VAR_2);", "vst->codec->bits_per_coded_sample = read_line_and_int(pb, &VAR_2);", "VAR_2 |= read_line(pb, VAR_3, sizeof(VAR_3));", "fps = read_fps(VAR_3, &VAR_2);", "avpriv_set_pts_info(vst, 32, fps.den, fps.num);", "switch (vst->codec->codec_tag) {", "#if 0\ncase 122:\nvst->codec->codec_id = AV_CODEC_ID_ESCAPE122;", "break;", "#endif\ncase 124:\nvst->codec->codec_id = AV_CODEC_ID_ESCAPE124;", "vst->codec->bits_per_coded_sample = 16;", "break;", "case 130:\nvst->codec->codec_id = AV_CODEC_ID_ESCAPE130;", "break;", "default:\navpriv_report_missing_feature(VAR_0, \"Video format %i\",\nvst->codec->codec_tag);", "vst->codec->codec_id = AV_CODEC_ID_NONE;", "}", "supports multiple audio tracks; I don't have any", "audio_format = read_line_and_int(pb, &VAR_2);", "if (audio_format) {", "ast = avformat_new_stream(VAR_0, NULL);", "if (!ast)\nreturn AVERROR(ENOMEM);", "ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;", "ast->codec->codec_tag = audio_format;", "ast->codec->sample_rate = read_line_and_int(pb, &VAR_2);", "ast->codec->channels = read_line_and_int(pb, &VAR_2);", "ast->codec->bits_per_coded_sample = read_line_and_int(pb, &VAR_2);", "if (ast->codec->bits_per_coded_sample == 0)\nast->codec->bits_per_coded_sample = 4;", "ast->codec->bit_rate = ast->codec->sample_rate *\nast->codec->bits_per_coded_sample *\nast->codec->channels;", "ast->codec->codec_id = AV_CODEC_ID_NONE;", "switch (audio_format) {", "case 1:\nif (ast->codec->bits_per_coded_sample == 16) {", "ast->codec->codec_id = AV_CODEC_ID_PCM_S16LE;", "break;", "}", "break;", "case 101:\nif (ast->codec->bits_per_coded_sample == 8) {", "ast->codec->codec_id = AV_CODEC_ID_PCM_U8;", "break;", "} else if (ast->codec->bits_per_coded_sample == 4) {", "ast->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_EA_SEAD;", "break;", "}", "break;", "}", "if (ast->codec->codec_id == AV_CODEC_ID_NONE)\navpriv_request_sample(VAR_0, \"Audio format %i\", audio_format);", "avpriv_set_pts_info(ast, 32, 1, ast->codec->bit_rate);", "} else {", "for (i = 0; i < 3; i++)", "VAR_2 |= read_line(pb, VAR_3, sizeof(VAR_3));", "}", "rpl->frames_per_chunk = read_line_and_int(pb, &VAR_2);", "if (rpl->frames_per_chunk > 1 && vst->codec->codec_tag != 124)\nav_log(VAR_0, AV_LOG_WARNING,\n\"Don't know how to split frames for video format %i. \"\n\"Video stream will be broken!\\n\", vst->codec->codec_tag);", "number_of_chunks = read_line_and_int(pb, &VAR_2);", "number_of_chunks++;", "VAR_2 |= read_line(pb, VAR_3, sizeof(VAR_3));", "VAR_2 |= read_line(pb, VAR_3, sizeof(VAR_3));", "chunk_catalog_offset =\nread_line_and_int(pb, &VAR_2);", "VAR_2 |= read_line(pb, VAR_3, sizeof(VAR_3));", "VAR_2 |= read_line(pb, VAR_3, sizeof(VAR_3));", "VAR_2 |= read_line(pb, VAR_3, sizeof(VAR_3));", "avio_seek(pb, chunk_catalog_offset, SEEK_SET);", "VAR_1 = 0;", "for (i = 0; !VAR_2 && i < number_of_chunks; i++) {", "int64_t offset, video_size, audio_size;", "VAR_2 |= read_line(pb, VAR_3, sizeof(VAR_3));", "if (3 != sscanf(VAR_3, \"%\"SCNd64\" , %\"SCNd64\" ; %\"SCNd64,", "&offset, &video_size, &audio_size))\nVAR_2 = -1;", "av_add_index_entry(vst, offset, i * rpl->frames_per_chunk,\nvideo_size, rpl->frames_per_chunk, 0);", "if (ast)\nav_add_index_entry(ast, offset + video_size, VAR_1,\naudio_size, audio_size * 8, 0);", "VAR_1 += audio_size * 8;", "}", "if (VAR_2) return AVERROR(EIO);", "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, 1, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 21 ], [ 23 ], [ 27 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 61 ], [ 63, 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 87 ], [ 89, 91, 93 ], [ 95 ], [ 97, 99, 101 ], [ 105 ], [ 107 ], [ 109, 111 ], [ 113 ], [ 115, 117, 119 ], [ 121 ], [ 123 ], [ 131 ], [ 135 ], [ 137 ], [ 139 ], [ 141, 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 159, 161 ], [ 165, 167, 169 ], [ 173 ], [ 175 ], [ 177, 179 ], [ 183 ], [ 185 ], [ 187 ], [ 193 ], [ 195, 197 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219, 221 ], [ 223 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 235 ], [ 237, 239, 241, 243 ], [ 247 ], [ 251 ], [ 255 ], [ 257 ], [ 259, 261 ], [ 263 ], [ 265 ], [ 267 ], [ 273 ], [ 275 ], [ 277 ], [ 279 ], [ 281 ], [ 283 ], [ 285, 287 ], [ 289, 291 ], [ 293, 295, 297 ], [ 299 ], [ 301 ], [ 305 ], [ 309 ], [ 311 ] ]
11,348
static void h264_free_context(PayloadContext *data) { #ifdef DEBUG int ii; for (ii = 0; ii < 32; ii++) { if (data->packet_types_received[ii]) av_log(NULL, AV_LOG_DEBUG, "Received %d packets of type %d\n", data->packet_types_received[ii], ii); } #endif assert(data); assert(data->cookie == MAGIC_COOKIE); // avoid stale pointers (assert) data->cookie = DEAD_COOKIE; // and clear out this... av_free(data); }
true
FFmpeg
5a571d324129ce367584ad9d92aae1d286f389a2
static void h264_free_context(PayloadContext *data) { #ifdef DEBUG int ii; for (ii = 0; ii < 32; ii++) { if (data->packet_types_received[ii]) av_log(NULL, AV_LOG_DEBUG, "Received %d packets of type %d\n", data->packet_types_received[ii], ii); } #endif assert(data); assert(data->cookie == MAGIC_COOKIE); data->cookie = DEAD_COOKIE; av_free(data); }
{ "code": [ " assert(data->cookie == MAGIC_COOKIE);", " assert(data);", " assert(data->cookie == MAGIC_COOKIE);", " data->cookie = DEAD_COOKIE;" ], "line_no": [ 27, 25, 27, 33 ] }
static void FUNC_0(PayloadContext *VAR_0) { #ifdef DEBUG int ii; for (ii = 0; ii < 32; ii++) { if (VAR_0->packet_types_received[ii]) av_log(NULL, AV_LOG_DEBUG, "Received %d packets of type %d\n", VAR_0->packet_types_received[ii], ii); } #endif assert(VAR_0); assert(VAR_0->cookie == MAGIC_COOKIE); VAR_0->cookie = DEAD_COOKIE; av_free(VAR_0); }
[ "static void FUNC_0(PayloadContext *VAR_0)\n{", "#ifdef DEBUG\nint ii;", "for (ii = 0; ii < 32; ii++) {", "if (VAR_0->packet_types_received[ii])\nav_log(NULL, AV_LOG_DEBUG, \"Received %d packets of type %d\\n\",\nVAR_0->packet_types_received[ii], ii);", "}", "#endif\nassert(VAR_0);", "assert(VAR_0->cookie == MAGIC_COOKIE);", "VAR_0->cookie = DEAD_COOKIE;", "av_free(VAR_0);", "}" ]
[ 0, 0, 0, 0, 0, 1, 1, 1, 0, 0 ]
[ [ 1, 3 ], [ 5, 7 ], [ 11 ], [ 13, 15, 17 ], [ 19 ], [ 21, 25 ], [ 27 ], [ 33 ], [ 39 ], [ 41 ] ]
11,350
static void mirror_iteration_done(MirrorOp *op, int ret) { MirrorBlockJob *s = op->s; struct iovec *iov; int64_t chunk_num; int i, nb_chunks, sectors_per_chunk; trace_mirror_iteration_done(s, op->sector_num, op->nb_sectors, ret); s->in_flight--; s->sectors_in_flight -= op->nb_sectors; iov = op->qiov.iov; for (i = 0; i < op->qiov.niov; i++) { MirrorBuffer *buf = (MirrorBuffer *) iov[i].iov_base; QSIMPLEQ_INSERT_TAIL(&s->buf_free, buf, next); s->buf_free_count++; } sectors_per_chunk = s->granularity >> BDRV_SECTOR_BITS; chunk_num = op->sector_num / sectors_per_chunk; nb_chunks = DIV_ROUND_UP(op->nb_sectors, sectors_per_chunk); bitmap_clear(s->in_flight_bitmap, chunk_num, nb_chunks); if (ret >= 0) { if (s->cow_bitmap) { bitmap_set(s->cow_bitmap, chunk_num, nb_chunks); } s->common.offset += (uint64_t)op->nb_sectors * BDRV_SECTOR_SIZE; } qemu_iovec_destroy(&op->qiov); g_free(op); if (s->waiting_for_io) { qemu_coroutine_enter(s->common.co, NULL); } }
true
qemu
0b8b8753e4d94901627b3e86431230f2319215c4
static void mirror_iteration_done(MirrorOp *op, int ret) { MirrorBlockJob *s = op->s; struct iovec *iov; int64_t chunk_num; int i, nb_chunks, sectors_per_chunk; trace_mirror_iteration_done(s, op->sector_num, op->nb_sectors, ret); s->in_flight--; s->sectors_in_flight -= op->nb_sectors; iov = op->qiov.iov; for (i = 0; i < op->qiov.niov; i++) { MirrorBuffer *buf = (MirrorBuffer *) iov[i].iov_base; QSIMPLEQ_INSERT_TAIL(&s->buf_free, buf, next); s->buf_free_count++; } sectors_per_chunk = s->granularity >> BDRV_SECTOR_BITS; chunk_num = op->sector_num / sectors_per_chunk; nb_chunks = DIV_ROUND_UP(op->nb_sectors, sectors_per_chunk); bitmap_clear(s->in_flight_bitmap, chunk_num, nb_chunks); if (ret >= 0) { if (s->cow_bitmap) { bitmap_set(s->cow_bitmap, chunk_num, nb_chunks); } s->common.offset += (uint64_t)op->nb_sectors * BDRV_SECTOR_SIZE; } qemu_iovec_destroy(&op->qiov); g_free(op); if (s->waiting_for_io) { qemu_coroutine_enter(s->common.co, NULL); } }
{ "code": [ " qemu_coroutine_enter(s->common.co, NULL);" ], "line_no": [ 67 ] }
static void FUNC_0(MirrorOp *VAR_0, int VAR_1) { MirrorBlockJob *s = VAR_0->s; struct iovec *VAR_2; int64_t chunk_num; int VAR_3, VAR_4, VAR_5; trace_mirror_iteration_done(s, VAR_0->sector_num, VAR_0->nb_sectors, VAR_1); s->in_flight--; s->sectors_in_flight -= VAR_0->nb_sectors; VAR_2 = VAR_0->qiov.VAR_2; for (VAR_3 = 0; VAR_3 < VAR_0->qiov.niov; VAR_3++) { MirrorBuffer *buf = (MirrorBuffer *) VAR_2[VAR_3].iov_base; QSIMPLEQ_INSERT_TAIL(&s->buf_free, buf, next); s->buf_free_count++; } VAR_5 = s->granularity >> BDRV_SECTOR_BITS; chunk_num = VAR_0->sector_num / VAR_5; VAR_4 = DIV_ROUND_UP(VAR_0->nb_sectors, VAR_5); bitmap_clear(s->in_flight_bitmap, chunk_num, VAR_4); if (VAR_1 >= 0) { if (s->cow_bitmap) { bitmap_set(s->cow_bitmap, chunk_num, VAR_4); } s->common.offset += (uint64_t)VAR_0->nb_sectors * BDRV_SECTOR_SIZE; } qemu_iovec_destroy(&VAR_0->qiov); g_free(VAR_0); if (s->waiting_for_io) { qemu_coroutine_enter(s->common.co, NULL); } }
[ "static void FUNC_0(MirrorOp *VAR_0, int VAR_1)\n{", "MirrorBlockJob *s = VAR_0->s;", "struct iovec *VAR_2;", "int64_t chunk_num;", "int VAR_3, VAR_4, VAR_5;", "trace_mirror_iteration_done(s, VAR_0->sector_num, VAR_0->nb_sectors, VAR_1);", "s->in_flight--;", "s->sectors_in_flight -= VAR_0->nb_sectors;", "VAR_2 = VAR_0->qiov.VAR_2;", "for (VAR_3 = 0; VAR_3 < VAR_0->qiov.niov; VAR_3++) {", "MirrorBuffer *buf = (MirrorBuffer *) VAR_2[VAR_3].iov_base;", "QSIMPLEQ_INSERT_TAIL(&s->buf_free, buf, next);", "s->buf_free_count++;", "}", "VAR_5 = s->granularity >> BDRV_SECTOR_BITS;", "chunk_num = VAR_0->sector_num / VAR_5;", "VAR_4 = DIV_ROUND_UP(VAR_0->nb_sectors, VAR_5);", "bitmap_clear(s->in_flight_bitmap, chunk_num, VAR_4);", "if (VAR_1 >= 0) {", "if (s->cow_bitmap) {", "bitmap_set(s->cow_bitmap, chunk_num, VAR_4);", "}", "s->common.offset += (uint64_t)VAR_0->nb_sectors * BDRV_SECTOR_SIZE;", "}", "qemu_iovec_destroy(&VAR_0->qiov);", "g_free(VAR_0);", "if (s->waiting_for_io) {", "qemu_coroutine_enter(s->common.co, NULL);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ] ]
11,351
static int find_image_range(int *pfirst_index, int *plast_index, const char *path, int start_index) { char buf[1024]; int range, last_index, range1, first_index; /* find the first image */ for (first_index = start_index; first_index < start_index + 5; first_index++) { if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0){ *pfirst_index = *plast_index = 1; if (avio_check(buf, AVIO_FLAG_READ) > 0) return 0; return -1; } if (avio_check(buf, AVIO_FLAG_READ) > 0) break; } if (first_index == 5) goto fail; /* find the last image */ last_index = first_index; for(;;) { range = 0; for(;;) { if (!range) range1 = 1; else range1 = 2 * range; if (av_get_frame_filename(buf, sizeof(buf), path, last_index + range1) < 0) goto fail; if (avio_check(buf, AVIO_FLAG_READ) <= 0) break; range = range1; /* just in case... */ if (range >= (1 << 30)) goto fail; } /* we are sure than image last_index + range exists */ if (!range) break; last_index += range; } *pfirst_index = first_index; *plast_index = last_index; return 0; fail: return -1; }
true
FFmpeg
07ef7b1a303680b73fc4a014f74a6d5089725184
static int find_image_range(int *pfirst_index, int *plast_index, const char *path, int start_index) { char buf[1024]; int range, last_index, range1, first_index; for (first_index = start_index; first_index < start_index + 5; first_index++) { if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0){ *pfirst_index = *plast_index = 1; if (avio_check(buf, AVIO_FLAG_READ) > 0) return 0; return -1; } if (avio_check(buf, AVIO_FLAG_READ) > 0) break; } if (first_index == 5) goto fail; last_index = first_index; for(;;) { range = 0; for(;;) { if (!range) range1 = 1; else range1 = 2 * range; if (av_get_frame_filename(buf, sizeof(buf), path, last_index + range1) < 0) goto fail; if (avio_check(buf, AVIO_FLAG_READ) <= 0) break; range = range1; if (range >= (1 << 30)) goto fail; } if (!range) break; last_index += range; } *pfirst_index = first_index; *plast_index = last_index; return 0; fail: return -1; }
{ "code": [ " if (first_index == 5)" ], "line_no": [ 37 ] }
static int FUNC_0(int *VAR_0, int *VAR_1, const char *VAR_2, int VAR_3) { char VAR_4[1024]; int VAR_5, VAR_6, VAR_7, VAR_8; for (VAR_8 = VAR_3; VAR_8 < VAR_3 + 5; VAR_8++) { if (av_get_frame_filename(VAR_4, sizeof(VAR_4), VAR_2, VAR_8) < 0){ *VAR_0 = *VAR_1 = 1; if (avio_check(VAR_4, AVIO_FLAG_READ) > 0) return 0; return -1; } if (avio_check(VAR_4, AVIO_FLAG_READ) > 0) break; } if (VAR_8 == 5) goto fail; VAR_6 = VAR_8; for(;;) { VAR_5 = 0; for(;;) { if (!VAR_5) VAR_7 = 1; else VAR_7 = 2 * VAR_5; if (av_get_frame_filename(VAR_4, sizeof(VAR_4), VAR_2, VAR_6 + VAR_7) < 0) goto fail; if (avio_check(VAR_4, AVIO_FLAG_READ) <= 0) break; VAR_5 = VAR_7; if (VAR_5 >= (1 << 30)) goto fail; } if (!VAR_5) break; VAR_6 += VAR_5; } *VAR_0 = VAR_8; *VAR_1 = VAR_6; return 0; fail: return -1; }
[ "static int FUNC_0(int *VAR_0, int *VAR_1,\nconst char *VAR_2, int VAR_3)\n{", "char VAR_4[1024];", "int VAR_5, VAR_6, VAR_7, VAR_8;", "for (VAR_8 = VAR_3; VAR_8 < VAR_3 + 5; VAR_8++) {", "if (av_get_frame_filename(VAR_4, sizeof(VAR_4), VAR_2, VAR_8) < 0){", "*VAR_0 =\n*VAR_1 = 1;", "if (avio_check(VAR_4, AVIO_FLAG_READ) > 0)\nreturn 0;", "return -1;", "}", "if (avio_check(VAR_4, AVIO_FLAG_READ) > 0)\nbreak;", "}", "if (VAR_8 == 5)\ngoto fail;", "VAR_6 = VAR_8;", "for(;;) {", "VAR_5 = 0;", "for(;;) {", "if (!VAR_5)\nVAR_7 = 1;", "else\nVAR_7 = 2 * VAR_5;", "if (av_get_frame_filename(VAR_4, sizeof(VAR_4), VAR_2,\nVAR_6 + VAR_7) < 0)\ngoto fail;", "if (avio_check(VAR_4, AVIO_FLAG_READ) <= 0)\nbreak;", "VAR_5 = VAR_7;", "if (VAR_5 >= (1 << 30))\ngoto fail;", "}", "if (!VAR_5)\nbreak;", "VAR_6 += VAR_5;", "}", "*VAR_0 = VAR_8;", "*VAR_1 = VAR_6;", "return 0;", "fail:\nreturn -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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 15 ], [ 17 ], [ 19, 21 ], [ 23, 25 ], [ 27 ], [ 29 ], [ 31, 33 ], [ 35 ], [ 37, 39 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53, 55 ], [ 57, 59 ], [ 61, 63, 65 ], [ 67, 69 ], [ 71 ], [ 75, 77 ], [ 79 ], [ 83, 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97, 99 ], [ 101 ] ]
11,352
av_cold int ff_cavs_init(AVCodecContext *avctx) { AVSContext *h = avctx->priv_data; ff_blockdsp_init(&h->bdsp, avctx); ff_h264chroma_init(&h->h264chroma, 8); ff_idctdsp_init(&h->idsp, avctx); ff_videodsp_init(&h->vdsp, 8); ff_cavsdsp_init(&h->cdsp, avctx); ff_init_scantable_permutation(h->idsp.idct_permutation, h->cdsp.idct_perm); ff_init_scantable(h->idsp.idct_permutation, &h->scantable, ff_zigzag_direct); h->avctx = avctx; avctx->pix_fmt = AV_PIX_FMT_YUV420P; h->cur.f = av_frame_alloc(); h->DPB[0].f = av_frame_alloc(); h->DPB[1].f = av_frame_alloc(); if (!h->cur.f || !h->DPB[0].f || !h->DPB[1].f) { ff_cavs_end(avctx); return AVERROR(ENOMEM); } h->luma_scan[0] = 0; h->luma_scan[1] = 8; h->intra_pred_l[INTRA_L_VERT] = intra_pred_vert; h->intra_pred_l[INTRA_L_HORIZ] = intra_pred_horiz; h->intra_pred_l[INTRA_L_LP] = intra_pred_lp; h->intra_pred_l[INTRA_L_DOWN_LEFT] = intra_pred_down_left; h->intra_pred_l[INTRA_L_DOWN_RIGHT] = intra_pred_down_right; h->intra_pred_l[INTRA_L_LP_LEFT] = intra_pred_lp_left; h->intra_pred_l[INTRA_L_LP_TOP] = intra_pred_lp_top; h->intra_pred_l[INTRA_L_DC_128] = intra_pred_dc_128; h->intra_pred_c[INTRA_C_LP] = intra_pred_lp; h->intra_pred_c[INTRA_C_HORIZ] = intra_pred_horiz; h->intra_pred_c[INTRA_C_VERT] = intra_pred_vert; h->intra_pred_c[INTRA_C_PLANE] = intra_pred_plane; h->intra_pred_c[INTRA_C_LP_LEFT] = intra_pred_lp_left; h->intra_pred_c[INTRA_C_LP_TOP] = intra_pred_lp_top; h->intra_pred_c[INTRA_C_DC_128] = intra_pred_dc_128; h->mv[7] = un_mv; h->mv[19] = un_mv; return 0; }
false
FFmpeg
dcc39ee10e82833ce24aa57926c00ffeb1948198
av_cold int ff_cavs_init(AVCodecContext *avctx) { AVSContext *h = avctx->priv_data; ff_blockdsp_init(&h->bdsp, avctx); ff_h264chroma_init(&h->h264chroma, 8); ff_idctdsp_init(&h->idsp, avctx); ff_videodsp_init(&h->vdsp, 8); ff_cavsdsp_init(&h->cdsp, avctx); ff_init_scantable_permutation(h->idsp.idct_permutation, h->cdsp.idct_perm); ff_init_scantable(h->idsp.idct_permutation, &h->scantable, ff_zigzag_direct); h->avctx = avctx; avctx->pix_fmt = AV_PIX_FMT_YUV420P; h->cur.f = av_frame_alloc(); h->DPB[0].f = av_frame_alloc(); h->DPB[1].f = av_frame_alloc(); if (!h->cur.f || !h->DPB[0].f || !h->DPB[1].f) { ff_cavs_end(avctx); return AVERROR(ENOMEM); } h->luma_scan[0] = 0; h->luma_scan[1] = 8; h->intra_pred_l[INTRA_L_VERT] = intra_pred_vert; h->intra_pred_l[INTRA_L_HORIZ] = intra_pred_horiz; h->intra_pred_l[INTRA_L_LP] = intra_pred_lp; h->intra_pred_l[INTRA_L_DOWN_LEFT] = intra_pred_down_left; h->intra_pred_l[INTRA_L_DOWN_RIGHT] = intra_pred_down_right; h->intra_pred_l[INTRA_L_LP_LEFT] = intra_pred_lp_left; h->intra_pred_l[INTRA_L_LP_TOP] = intra_pred_lp_top; h->intra_pred_l[INTRA_L_DC_128] = intra_pred_dc_128; h->intra_pred_c[INTRA_C_LP] = intra_pred_lp; h->intra_pred_c[INTRA_C_HORIZ] = intra_pred_horiz; h->intra_pred_c[INTRA_C_VERT] = intra_pred_vert; h->intra_pred_c[INTRA_C_PLANE] = intra_pred_plane; h->intra_pred_c[INTRA_C_LP_LEFT] = intra_pred_lp_left; h->intra_pred_c[INTRA_C_LP_TOP] = intra_pred_lp_top; h->intra_pred_c[INTRA_C_DC_128] = intra_pred_dc_128; h->mv[7] = un_mv; h->mv[19] = un_mv; return 0; }
{ "code": [], "line_no": [] }
av_cold int FUNC_0(AVCodecContext *avctx) { AVSContext *h = avctx->priv_data; ff_blockdsp_init(&h->bdsp, avctx); ff_h264chroma_init(&h->h264chroma, 8); ff_idctdsp_init(&h->idsp, avctx); ff_videodsp_init(&h->vdsp, 8); ff_cavsdsp_init(&h->cdsp, avctx); ff_init_scantable_permutation(h->idsp.idct_permutation, h->cdsp.idct_perm); ff_init_scantable(h->idsp.idct_permutation, &h->scantable, ff_zigzag_direct); h->avctx = avctx; avctx->pix_fmt = AV_PIX_FMT_YUV420P; h->cur.f = av_frame_alloc(); h->DPB[0].f = av_frame_alloc(); h->DPB[1].f = av_frame_alloc(); if (!h->cur.f || !h->DPB[0].f || !h->DPB[1].f) { ff_cavs_end(avctx); return AVERROR(ENOMEM); } h->luma_scan[0] = 0; h->luma_scan[1] = 8; h->intra_pred_l[INTRA_L_VERT] = intra_pred_vert; h->intra_pred_l[INTRA_L_HORIZ] = intra_pred_horiz; h->intra_pred_l[INTRA_L_LP] = intra_pred_lp; h->intra_pred_l[INTRA_L_DOWN_LEFT] = intra_pred_down_left; h->intra_pred_l[INTRA_L_DOWN_RIGHT] = intra_pred_down_right; h->intra_pred_l[INTRA_L_LP_LEFT] = intra_pred_lp_left; h->intra_pred_l[INTRA_L_LP_TOP] = intra_pred_lp_top; h->intra_pred_l[INTRA_L_DC_128] = intra_pred_dc_128; h->intra_pred_c[INTRA_C_LP] = intra_pred_lp; h->intra_pred_c[INTRA_C_HORIZ] = intra_pred_horiz; h->intra_pred_c[INTRA_C_VERT] = intra_pred_vert; h->intra_pred_c[INTRA_C_PLANE] = intra_pred_plane; h->intra_pred_c[INTRA_C_LP_LEFT] = intra_pred_lp_left; h->intra_pred_c[INTRA_C_LP_TOP] = intra_pred_lp_top; h->intra_pred_c[INTRA_C_DC_128] = intra_pred_dc_128; h->mv[7] = un_mv; h->mv[19] = un_mv; return 0; }
[ "av_cold int FUNC_0(AVCodecContext *avctx)\n{", "AVSContext *h = avctx->priv_data;", "ff_blockdsp_init(&h->bdsp, avctx);", "ff_h264chroma_init(&h->h264chroma, 8);", "ff_idctdsp_init(&h->idsp, avctx);", "ff_videodsp_init(&h->vdsp, 8);", "ff_cavsdsp_init(&h->cdsp, avctx);", "ff_init_scantable_permutation(h->idsp.idct_permutation,\nh->cdsp.idct_perm);", "ff_init_scantable(h->idsp.idct_permutation, &h->scantable, ff_zigzag_direct);", "h->avctx = avctx;", "avctx->pix_fmt = AV_PIX_FMT_YUV420P;", "h->cur.f = av_frame_alloc();", "h->DPB[0].f = av_frame_alloc();", "h->DPB[1].f = av_frame_alloc();", "if (!h->cur.f || !h->DPB[0].f || !h->DPB[1].f) {", "ff_cavs_end(avctx);", "return AVERROR(ENOMEM);", "}", "h->luma_scan[0] = 0;", "h->luma_scan[1] = 8;", "h->intra_pred_l[INTRA_L_VERT] = intra_pred_vert;", "h->intra_pred_l[INTRA_L_HORIZ] = intra_pred_horiz;", "h->intra_pred_l[INTRA_L_LP] = intra_pred_lp;", "h->intra_pred_l[INTRA_L_DOWN_LEFT] = intra_pred_down_left;", "h->intra_pred_l[INTRA_L_DOWN_RIGHT] = intra_pred_down_right;", "h->intra_pred_l[INTRA_L_LP_LEFT] = intra_pred_lp_left;", "h->intra_pred_l[INTRA_L_LP_TOP] = intra_pred_lp_top;", "h->intra_pred_l[INTRA_L_DC_128] = intra_pred_dc_128;", "h->intra_pred_c[INTRA_C_LP] = intra_pred_lp;", "h->intra_pred_c[INTRA_C_HORIZ] = intra_pred_horiz;", "h->intra_pred_c[INTRA_C_VERT] = intra_pred_vert;", "h->intra_pred_c[INTRA_C_PLANE] = intra_pred_plane;", "h->intra_pred_c[INTRA_C_LP_LEFT] = intra_pred_lp_left;", "h->intra_pred_c[INTRA_C_LP_TOP] = intra_pred_lp_top;", "h->intra_pred_c[INTRA_C_DC_128] = intra_pred_dc_128;", "h->mv[7] = un_mv;", "h->mv[19] = un_mv;", "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 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19, 21 ], [ 23 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ] ]
11,353
static int filter_packet(void *log_ctx, AVPacket *pkt, AVFormatContext *fmt_ctx, AVBitStreamFilterContext *bsf_ctx) { AVCodecContext *enc_ctx = fmt_ctx->streams[pkt->stream_index]->codec; int ret = 0; while (bsf_ctx) { AVPacket new_pkt = *pkt; ret = av_bitstream_filter_filter(bsf_ctx, enc_ctx, NULL, &new_pkt.data, &new_pkt.size, pkt->data, pkt->size, pkt->flags & AV_PKT_FLAG_KEY); if (ret == 0 && new_pkt.data != pkt->data && new_pkt.destruct) { if ((ret = av_copy_packet(&new_pkt, pkt)) < 0) break; ret = 1; } if (ret > 0) { av_free_packet(pkt); new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size, av_buffer_default_free, NULL, 0); if (!new_pkt.buf) break; } if (ret < 0) { av_log(log_ctx, AV_LOG_ERROR, "Failed to filter bitstream with filter %s for stream %d in file '%s' with codec %s\n", bsf_ctx->filter->name, pkt->stream_index, fmt_ctx->filename, avcodec_get_name(enc_ctx->codec_id)); } *pkt = new_pkt; bsf_ctx = bsf_ctx->next; } return ret; }
false
FFmpeg
c363843a53553cbda6d42d98e8fbd165eda193fb
static int filter_packet(void *log_ctx, AVPacket *pkt, AVFormatContext *fmt_ctx, AVBitStreamFilterContext *bsf_ctx) { AVCodecContext *enc_ctx = fmt_ctx->streams[pkt->stream_index]->codec; int ret = 0; while (bsf_ctx) { AVPacket new_pkt = *pkt; ret = av_bitstream_filter_filter(bsf_ctx, enc_ctx, NULL, &new_pkt.data, &new_pkt.size, pkt->data, pkt->size, pkt->flags & AV_PKT_FLAG_KEY); if (ret == 0 && new_pkt.data != pkt->data && new_pkt.destruct) { if ((ret = av_copy_packet(&new_pkt, pkt)) < 0) break; ret = 1; } if (ret > 0) { av_free_packet(pkt); new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size, av_buffer_default_free, NULL, 0); if (!new_pkt.buf) break; } if (ret < 0) { av_log(log_ctx, AV_LOG_ERROR, "Failed to filter bitstream with filter %s for stream %d in file '%s' with codec %s\n", bsf_ctx->filter->name, pkt->stream_index, fmt_ctx->filename, avcodec_get_name(enc_ctx->codec_id)); } *pkt = new_pkt; bsf_ctx = bsf_ctx->next; } return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(void *VAR_0, AVPacket *VAR_1, AVFormatContext *VAR_2, AVBitStreamFilterContext *VAR_3) { AVCodecContext *enc_ctx = VAR_2->streams[VAR_1->stream_index]->codec; int VAR_4 = 0; while (VAR_3) { AVPacket new_pkt = *VAR_1; VAR_4 = av_bitstream_filter_filter(VAR_3, enc_ctx, NULL, &new_pkt.data, &new_pkt.size, VAR_1->data, VAR_1->size, VAR_1->flags & AV_PKT_FLAG_KEY); if (VAR_4 == 0 && new_pkt.data != VAR_1->data && new_pkt.destruct) { if ((VAR_4 = av_copy_packet(&new_pkt, VAR_1)) < 0) break; VAR_4 = 1; } if (VAR_4 > 0) { av_free_packet(VAR_1); new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size, av_buffer_default_free, NULL, 0); if (!new_pkt.buf) break; } if (VAR_4 < 0) { av_log(VAR_0, AV_LOG_ERROR, "Failed to filter bitstream with filter %s for stream %d in file '%s' with codec %s\n", VAR_3->filter->name, VAR_1->stream_index, VAR_2->filename, avcodec_get_name(enc_ctx->codec_id)); } *VAR_1 = new_pkt; VAR_3 = VAR_3->next; } return VAR_4; }
[ "static int FUNC_0(void *VAR_0, AVPacket *VAR_1,\nAVFormatContext *VAR_2, AVBitStreamFilterContext *VAR_3)\n{", "AVCodecContext *enc_ctx = VAR_2->streams[VAR_1->stream_index]->codec;", "int VAR_4 = 0;", "while (VAR_3) {", "AVPacket new_pkt = *VAR_1;", "VAR_4 = av_bitstream_filter_filter(VAR_3, enc_ctx, NULL,\n&new_pkt.data, &new_pkt.size,\nVAR_1->data, VAR_1->size,\nVAR_1->flags & AV_PKT_FLAG_KEY);", "if (VAR_4 == 0 && new_pkt.data != VAR_1->data && new_pkt.destruct) {", "if ((VAR_4 = av_copy_packet(&new_pkt, VAR_1)) < 0)\nbreak;", "VAR_4 = 1;", "}", "if (VAR_4 > 0) {", "av_free_packet(VAR_1);", "new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size,\nav_buffer_default_free, NULL, 0);", "if (!new_pkt.buf)\nbreak;", "}", "if (VAR_4 < 0) {", "av_log(VAR_0, AV_LOG_ERROR,\n\"Failed to filter bitstream with filter %s for stream %d in file '%s' with codec %s\\n\",\nVAR_3->filter->name, VAR_1->stream_index, VAR_2->filename,\navcodec_get_name(enc_ctx->codec_id));", "}", "*VAR_1 = new_pkt;", "VAR_3 = VAR_3->next;", "}", "return VAR_4;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17, 19, 21, 23 ], [ 25 ], [ 27, 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41, 43 ], [ 45, 47 ], [ 49 ], [ 51 ], [ 53, 55, 57, 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 73 ], [ 75 ] ]
11,355
static void nbd_client_close(NBDClient *client) { qemu_set_fd_handler2(client->sock, NULL, NULL, NULL, NULL); close(client->sock); client->sock = -1; if (client->close) { client->close(client); } nbd_client_put(client); }
true
qemu
ff2b68aa70d10b7eae813b04e9a23723dbd89ebd
static void nbd_client_close(NBDClient *client) { qemu_set_fd_handler2(client->sock, NULL, NULL, NULL, NULL); close(client->sock); client->sock = -1; if (client->close) { client->close(client); } nbd_client_put(client); }
{ "code": [ "static void nbd_client_close(NBDClient *client)", " qemu_set_fd_handler2(client->sock, NULL, NULL, NULL, NULL);", " close(client->sock);", " client->sock = -1;", " nbd_client_put(client);" ], "line_no": [ 1, 5, 7, 9, 17 ] }
static void FUNC_0(NBDClient *VAR_0) { qemu_set_fd_handler2(VAR_0->sock, NULL, NULL, NULL, NULL); close(VAR_0->sock); VAR_0->sock = -1; if (VAR_0->close) { VAR_0->close(VAR_0); } nbd_client_put(VAR_0); }
[ "static void FUNC_0(NBDClient *VAR_0)\n{", "qemu_set_fd_handler2(VAR_0->sock, NULL, NULL, NULL, NULL);", "close(VAR_0->sock);", "VAR_0->sock = -1;", "if (VAR_0->close) {", "VAR_0->close(VAR_0);", "}", "nbd_client_put(VAR_0);", "}" ]
[ 1, 1, 1, 1, 0, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ] ]
11,356
int avio_close(AVIOContext *s) { AVIOInternal *internal; URLContext *h; if (!s) return 0; avio_flush(s); internal = s->opaque; h = internal->h; av_opt_free(internal); av_freep(&internal->protocols); av_freep(&s->opaque); av_freep(&s->buffer); av_free(s); return ffurl_close(h); }
false
FFmpeg
99684f3ae752fc8bfb44a2dd1482f8d7a3d8536d
int avio_close(AVIOContext *s) { AVIOInternal *internal; URLContext *h; if (!s) return 0; avio_flush(s); internal = s->opaque; h = internal->h; av_opt_free(internal); av_freep(&internal->protocols); av_freep(&s->opaque); av_freep(&s->buffer); av_free(s); return ffurl_close(h); }
{ "code": [], "line_no": [] }
int FUNC_0(AVIOContext *VAR_0) { AVIOInternal *internal; URLContext *h; if (!VAR_0) return 0; avio_flush(VAR_0); internal = VAR_0->opaque; h = internal->h; av_opt_free(internal); av_freep(&internal->protocols); av_freep(&VAR_0->opaque); av_freep(&VAR_0->buffer); av_free(VAR_0); return ffurl_close(h); }
[ "int FUNC_0(AVIOContext *VAR_0)\n{", "AVIOInternal *internal;", "URLContext *h;", "if (!VAR_0)\nreturn 0;", "avio_flush(VAR_0);", "internal = VAR_0->opaque;", "h = internal->h;", "av_opt_free(internal);", "av_freep(&internal->protocols);", "av_freep(&VAR_0->opaque);", "av_freep(&VAR_0->buffer);", "av_free(VAR_0);", "return ffurl_close(h);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11, 13 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ] ]
11,358
int ff_jni_init_jfields(JNIEnv *env, void *jfields, const struct FFJniField *jfields_mapping, int global, void *log_ctx) { int i, ret = 0; jclass last_clazz = NULL; for (i = 0; jfields_mapping[i].name; i++) { int mandatory = jfields_mapping[i].mandatory; enum FFJniFieldType type = jfields_mapping[i].type; if (type == FF_JNI_CLASS) { jclass clazz; last_clazz = NULL; clazz = (*env)->FindClass(env, jfields_mapping[i].name); if ((ret = ff_jni_exception_check(env, mandatory, log_ctx)) < 0 && mandatory) { goto done; last_clazz = *(jclass*)((uint8_t*)jfields + jfields_mapping[i].offset) = global ? (*env)->NewGlobalRef(env, clazz) : clazz; } else { if (!last_clazz) { ret = AVERROR_EXTERNAL; break; switch(type) { case FF_JNI_FIELD: { jfieldID field_id = (*env)->GetFieldID(env, last_clazz, jfields_mapping[i].method, jfields_mapping[i].signature); if ((ret = ff_jni_exception_check(env, mandatory, log_ctx)) < 0 && mandatory) { goto done; *(jfieldID*)((uint8_t*)jfields + jfields_mapping[i].offset) = field_id; break; case FF_JNI_STATIC_FIELD: { jfieldID field_id = (*env)->GetStaticFieldID(env, last_clazz, jfields_mapping[i].method, jfields_mapping[i].signature); if ((ret = ff_jni_exception_check(env, mandatory, log_ctx)) < 0 && mandatory) { goto done; *(jfieldID*)((uint8_t*)jfields + jfields_mapping[i].offset) = field_id; break; case FF_JNI_METHOD: { jmethodID method_id = (*env)->GetMethodID(env, last_clazz, jfields_mapping[i].method, jfields_mapping[i].signature); if ((ret = ff_jni_exception_check(env, mandatory, log_ctx)) < 0 && mandatory) { goto done; *(jmethodID*)((uint8_t*)jfields + jfields_mapping[i].offset) = method_id; break; case FF_JNI_STATIC_METHOD: { jmethodID method_id = (*env)->GetStaticMethodID(env, last_clazz, jfields_mapping[i].method, jfields_mapping[i].signature); if ((ret = ff_jni_exception_check(env, mandatory, log_ctx)) < 0 && mandatory) { goto done; *(jmethodID*)((uint8_t*)jfields + jfields_mapping[i].offset) = method_id; break; default: av_log(log_ctx, AV_LOG_ERROR, "Unknown JNI field type\n"); ret = AVERROR(EINVAL); goto done; ret = 0; done: if (ret < 0) { /* reset jfields in case of failure so it does not leak references */ ff_jni_reset_jfields(env, jfields, jfields_mapping, global, log_ctx); return ret;
true
FFmpeg
2f43897f657974d8f94d0d075eb67dac1147ddde
int ff_jni_init_jfields(JNIEnv *env, void *jfields, const struct FFJniField *jfields_mapping, int global, void *log_ctx) { int i, ret = 0; jclass last_clazz = NULL; for (i = 0; jfields_mapping[i].name; i++) { int mandatory = jfields_mapping[i].mandatory; enum FFJniFieldType type = jfields_mapping[i].type; if (type == FF_JNI_CLASS) { jclass clazz; last_clazz = NULL; clazz = (*env)->FindClass(env, jfields_mapping[i].name); if ((ret = ff_jni_exception_check(env, mandatory, log_ctx)) < 0 && mandatory) { goto done; last_clazz = *(jclass*)((uint8_t*)jfields + jfields_mapping[i].offset) = global ? (*env)->NewGlobalRef(env, clazz) : clazz; } else { if (!last_clazz) { ret = AVERROR_EXTERNAL; break; switch(type) { case FF_JNI_FIELD: { jfieldID field_id = (*env)->GetFieldID(env, last_clazz, jfields_mapping[i].method, jfields_mapping[i].signature); if ((ret = ff_jni_exception_check(env, mandatory, log_ctx)) < 0 && mandatory) { goto done; *(jfieldID*)((uint8_t*)jfields + jfields_mapping[i].offset) = field_id; break; case FF_JNI_STATIC_FIELD: { jfieldID field_id = (*env)->GetStaticFieldID(env, last_clazz, jfields_mapping[i].method, jfields_mapping[i].signature); if ((ret = ff_jni_exception_check(env, mandatory, log_ctx)) < 0 && mandatory) { goto done; *(jfieldID*)((uint8_t*)jfields + jfields_mapping[i].offset) = field_id; break; case FF_JNI_METHOD: { jmethodID method_id = (*env)->GetMethodID(env, last_clazz, jfields_mapping[i].method, jfields_mapping[i].signature); if ((ret = ff_jni_exception_check(env, mandatory, log_ctx)) < 0 && mandatory) { goto done; *(jmethodID*)((uint8_t*)jfields + jfields_mapping[i].offset) = method_id; break; case FF_JNI_STATIC_METHOD: { jmethodID method_id = (*env)->GetStaticMethodID(env, last_clazz, jfields_mapping[i].method, jfields_mapping[i].signature); if ((ret = ff_jni_exception_check(env, mandatory, log_ctx)) < 0 && mandatory) { goto done; *(jmethodID*)((uint8_t*)jfields + jfields_mapping[i].offset) = method_id; break; default: av_log(log_ctx, AV_LOG_ERROR, "Unknown JNI field type\n"); ret = AVERROR(EINVAL); goto done; ret = 0; done: if (ret < 0) { ff_jni_reset_jfields(env, jfields, jfields_mapping, global, log_ctx); return ret;
{ "code": [], "line_no": [] }
int FUNC_0(JNIEnv *VAR_0, void *VAR_1, const struct FFJniField *VAR_2, int VAR_3, void *VAR_4) { int VAR_5, VAR_6 = 0; jclass last_clazz = NULL; for (VAR_5 = 0; VAR_2[VAR_5].name; VAR_5++) { int mandatory = VAR_2[VAR_5].mandatory; enum FFJniFieldType type = VAR_2[VAR_5].type; if (type == FF_JNI_CLASS) { jclass clazz; last_clazz = NULL; clazz = (*VAR_0)->FindClass(VAR_0, VAR_2[VAR_5].name); if ((VAR_6 = ff_jni_exception_check(VAR_0, mandatory, VAR_4)) < 0 && mandatory) { goto done; last_clazz = *(jclass*)((uint8_t*)VAR_1 + VAR_2[VAR_5].offset) = VAR_3 ? (*VAR_0)->NewGlobalRef(VAR_0, clazz) : clazz; } else { if (!last_clazz) { VAR_6 = AVERROR_EXTERNAL; break; switch(type) { case FF_JNI_FIELD: { jfieldID field_id = (*VAR_0)->GetFieldID(VAR_0, last_clazz, VAR_2[VAR_5].method, VAR_2[VAR_5].signature); if ((VAR_6 = ff_jni_exception_check(VAR_0, mandatory, VAR_4)) < 0 && mandatory) { goto done; *(jfieldID*)((uint8_t*)VAR_1 + VAR_2[VAR_5].offset) = field_id; break; case FF_JNI_STATIC_FIELD: { jfieldID field_id = (*VAR_0)->GetStaticFieldID(VAR_0, last_clazz, VAR_2[VAR_5].method, VAR_2[VAR_5].signature); if ((VAR_6 = ff_jni_exception_check(VAR_0, mandatory, VAR_4)) < 0 && mandatory) { goto done; *(jfieldID*)((uint8_t*)VAR_1 + VAR_2[VAR_5].offset) = field_id; break; case FF_JNI_METHOD: { jmethodID method_id = (*VAR_0)->GetMethodID(VAR_0, last_clazz, VAR_2[VAR_5].method, VAR_2[VAR_5].signature); if ((VAR_6 = ff_jni_exception_check(VAR_0, mandatory, VAR_4)) < 0 && mandatory) { goto done; *(jmethodID*)((uint8_t*)VAR_1 + VAR_2[VAR_5].offset) = method_id; break; case FF_JNI_STATIC_METHOD: { jmethodID method_id = (*VAR_0)->GetStaticMethodID(VAR_0, last_clazz, VAR_2[VAR_5].method, VAR_2[VAR_5].signature); if ((VAR_6 = ff_jni_exception_check(VAR_0, mandatory, VAR_4)) < 0 && mandatory) { goto done; *(jmethodID*)((uint8_t*)VAR_1 + VAR_2[VAR_5].offset) = method_id; break; default: av_log(VAR_4, AV_LOG_ERROR, "Unknown JNI field type\n"); VAR_6 = AVERROR(EINVAL); goto done; VAR_6 = 0; done: if (VAR_6 < 0) { ff_jni_reset_jfields(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4); return VAR_6;
[ "int FUNC_0(JNIEnv *VAR_0, void *VAR_1, const struct FFJniField *VAR_2, int VAR_3, void *VAR_4)\n{", "int VAR_5, VAR_6 = 0;", "jclass last_clazz = NULL;", "for (VAR_5 = 0; VAR_2[VAR_5].name; VAR_5++) {", "int mandatory = VAR_2[VAR_5].mandatory;", "enum FFJniFieldType type = VAR_2[VAR_5].type;", "if (type == FF_JNI_CLASS) {", "jclass clazz;", "last_clazz = NULL;", "clazz = (*VAR_0)->FindClass(VAR_0, VAR_2[VAR_5].name);", "if ((VAR_6 = ff_jni_exception_check(VAR_0, mandatory, VAR_4)) < 0 && mandatory) {", "goto done;", "last_clazz = *(jclass*)((uint8_t*)VAR_1 + VAR_2[VAR_5].offset) =\nVAR_3 ? (*VAR_0)->NewGlobalRef(VAR_0, clazz) : clazz;", "} else {", "if (!last_clazz) {", "VAR_6 = AVERROR_EXTERNAL;", "break;", "switch(type) {", "case FF_JNI_FIELD: {", "jfieldID field_id = (*VAR_0)->GetFieldID(VAR_0, last_clazz, VAR_2[VAR_5].method, VAR_2[VAR_5].signature);", "if ((VAR_6 = ff_jni_exception_check(VAR_0, mandatory, VAR_4)) < 0 && mandatory) {", "goto done;", "*(jfieldID*)((uint8_t*)VAR_1 + VAR_2[VAR_5].offset) = field_id;", "break;", "case FF_JNI_STATIC_FIELD: {", "jfieldID field_id = (*VAR_0)->GetStaticFieldID(VAR_0, last_clazz, VAR_2[VAR_5].method, VAR_2[VAR_5].signature);", "if ((VAR_6 = ff_jni_exception_check(VAR_0, mandatory, VAR_4)) < 0 && mandatory) {", "goto done;", "*(jfieldID*)((uint8_t*)VAR_1 + VAR_2[VAR_5].offset) = field_id;", "break;", "case FF_JNI_METHOD: {", "jmethodID method_id = (*VAR_0)->GetMethodID(VAR_0, last_clazz, VAR_2[VAR_5].method, VAR_2[VAR_5].signature);", "if ((VAR_6 = ff_jni_exception_check(VAR_0, mandatory, VAR_4)) < 0 && mandatory) {", "goto done;", "*(jmethodID*)((uint8_t*)VAR_1 + VAR_2[VAR_5].offset) = method_id;", "break;", "case FF_JNI_STATIC_METHOD: {", "jmethodID method_id = (*VAR_0)->GetStaticMethodID(VAR_0, last_clazz, VAR_2[VAR_5].method, VAR_2[VAR_5].signature);", "if ((VAR_6 = ff_jni_exception_check(VAR_0, mandatory, VAR_4)) < 0 && mandatory) {", "goto done;", "*(jmethodID*)((uint8_t*)VAR_1 + VAR_2[VAR_5].offset) = method_id;", "break;", "default:\nav_log(VAR_4, AV_LOG_ERROR, \"Unknown JNI field type\\n\");", "VAR_6 = AVERROR(EINVAL);", "goto done;", "VAR_6 = 0;", "done:\nif (VAR_6 < 0) {", "ff_jni_reset_jfields(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4);", "return VAR_6;" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 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 ], [ 53 ], [ 54 ] ]
11,360
static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child, int64_t offset, unsigned int bytes, QEMUIOVector *qiov) { BlockDriverState *bs = child->bs; /* Perform I/O through a temporary buffer so that users who scribble over * their read buffer while the operation is in progress do not end up * modifying the image file. This is critical for zero-copy guest I/O * where anything might happen inside guest memory. */ void *bounce_buffer; BlockDriver *drv = bs->drv; struct iovec iov; QEMUIOVector bounce_qiov; int64_t cluster_offset; unsigned int cluster_bytes; size_t skip_bytes; int ret; assert(child->perm & (BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE)); /* Cover entire cluster so no additional backing file I/O is required when * allocating cluster in the image file. */ bdrv_round_to_clusters(bs, offset, bytes, &cluster_offset, &cluster_bytes); trace_bdrv_co_do_copy_on_readv(bs, offset, bytes, cluster_offset, cluster_bytes); iov.iov_len = cluster_bytes; iov.iov_base = bounce_buffer = qemu_try_blockalign(bs, iov.iov_len); if (bounce_buffer == NULL) { ret = -ENOMEM; goto err; } qemu_iovec_init_external(&bounce_qiov, &iov, 1); ret = bdrv_driver_preadv(bs, cluster_offset, cluster_bytes, &bounce_qiov, 0); if (ret < 0) { goto err; } if (drv->bdrv_co_pwrite_zeroes && buffer_is_zero(bounce_buffer, iov.iov_len)) { /* FIXME: Should we (perhaps conditionally) be setting * BDRV_REQ_MAY_UNMAP, if it will allow for a sparser copy * that still correctly reads as zero? */ ret = bdrv_co_do_pwrite_zeroes(bs, cluster_offset, cluster_bytes, 0); } else { /* This does not change the data on the disk, it is not necessary * to flush even in cache=writethrough mode. */ ret = bdrv_driver_pwritev(bs, cluster_offset, cluster_bytes, &bounce_qiov, 0); } if (ret < 0) { /* It might be okay to ignore write errors for guest requests. If this * is a deliberate copy-on-read then we don't want to ignore the error. * Simply report it in all cases. */ goto err; } skip_bytes = offset - cluster_offset; qemu_iovec_from_buf(qiov, 0, bounce_buffer + skip_bytes, bytes); err: qemu_vfree(bounce_buffer); return ret; }
true
qemu
1bf03e66fd03af46ff0f98dd04b6e28f432ac1e3
static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child, int64_t offset, unsigned int bytes, QEMUIOVector *qiov) { BlockDriverState *bs = child->bs; void *bounce_buffer; BlockDriver *drv = bs->drv; struct iovec iov; QEMUIOVector bounce_qiov; int64_t cluster_offset; unsigned int cluster_bytes; size_t skip_bytes; int ret; assert(child->perm & (BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE)); bdrv_round_to_clusters(bs, offset, bytes, &cluster_offset, &cluster_bytes); trace_bdrv_co_do_copy_on_readv(bs, offset, bytes, cluster_offset, cluster_bytes); iov.iov_len = cluster_bytes; iov.iov_base = bounce_buffer = qemu_try_blockalign(bs, iov.iov_len); if (bounce_buffer == NULL) { ret = -ENOMEM; goto err; } qemu_iovec_init_external(&bounce_qiov, &iov, 1); ret = bdrv_driver_preadv(bs, cluster_offset, cluster_bytes, &bounce_qiov, 0); if (ret < 0) { goto err; } if (drv->bdrv_co_pwrite_zeroes && buffer_is_zero(bounce_buffer, iov.iov_len)) { ret = bdrv_co_do_pwrite_zeroes(bs, cluster_offset, cluster_bytes, 0); } else { ret = bdrv_driver_pwritev(bs, cluster_offset, cluster_bytes, &bounce_qiov, 0); } if (ret < 0) { goto err; } skip_bytes = offset - cluster_offset; qemu_iovec_from_buf(qiov, 0, bounce_buffer + skip_bytes, bytes); err: qemu_vfree(bounce_buffer); return ret; }
{ "code": [ " assert(child->perm & (BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE));" ], "line_no": [ 41 ] }
static int VAR_0 bdrv_co_do_copy_on_readv(BdrvChild *child, int64_t offset, unsigned int bytes, QEMUIOVector *qiov) { BlockDriverState *bs = child->bs; void *bounce_buffer; BlockDriver *drv = bs->drv; struct iovec iov; QEMUIOVector bounce_qiov; int64_t cluster_offset; unsigned int cluster_bytes; size_t skip_bytes; int ret; assert(child->perm & (BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE)); bdrv_round_to_clusters(bs, offset, bytes, &cluster_offset, &cluster_bytes); trace_bdrv_co_do_copy_on_readv(bs, offset, bytes, cluster_offset, cluster_bytes); iov.iov_len = cluster_bytes; iov.iov_base = bounce_buffer = qemu_try_blockalign(bs, iov.iov_len); if (bounce_buffer == NULL) { ret = -ENOMEM; goto err; } qemu_iovec_init_external(&bounce_qiov, &iov, 1); ret = bdrv_driver_preadv(bs, cluster_offset, cluster_bytes, &bounce_qiov, 0); if (ret < 0) { goto err; } if (drv->bdrv_co_pwrite_zeroes && buffer_is_zero(bounce_buffer, iov.iov_len)) { ret = bdrv_co_do_pwrite_zeroes(bs, cluster_offset, cluster_bytes, 0); } else { ret = bdrv_driver_pwritev(bs, cluster_offset, cluster_bytes, &bounce_qiov, 0); } if (ret < 0) { goto err; } skip_bytes = offset - cluster_offset; qemu_iovec_from_buf(qiov, 0, bounce_buffer + skip_bytes, bytes); err: qemu_vfree(bounce_buffer); return ret; }
[ "static int VAR_0 bdrv_co_do_copy_on_readv(BdrvChild *child,\nint64_t offset, unsigned int bytes, QEMUIOVector *qiov)\n{", "BlockDriverState *bs = child->bs;", "void *bounce_buffer;", "BlockDriver *drv = bs->drv;", "struct iovec iov;", "QEMUIOVector bounce_qiov;", "int64_t cluster_offset;", "unsigned int cluster_bytes;", "size_t skip_bytes;", "int ret;", "assert(child->perm & (BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE));", "bdrv_round_to_clusters(bs, offset, bytes, &cluster_offset, &cluster_bytes);", "trace_bdrv_co_do_copy_on_readv(bs, offset, bytes,\ncluster_offset, cluster_bytes);", "iov.iov_len = cluster_bytes;", "iov.iov_base = bounce_buffer = qemu_try_blockalign(bs, iov.iov_len);", "if (bounce_buffer == NULL) {", "ret = -ENOMEM;", "goto err;", "}", "qemu_iovec_init_external(&bounce_qiov, &iov, 1);", "ret = bdrv_driver_preadv(bs, cluster_offset, cluster_bytes,\n&bounce_qiov, 0);", "if (ret < 0) {", "goto err;", "}", "if (drv->bdrv_co_pwrite_zeroes &&\nbuffer_is_zero(bounce_buffer, iov.iov_len)) {", "ret = bdrv_co_do_pwrite_zeroes(bs, cluster_offset, cluster_bytes, 0);", "} else {", "ret = bdrv_driver_pwritev(bs, cluster_offset, cluster_bytes,\n&bounce_qiov, 0);", "}", "if (ret < 0) {", "goto err;", "}", "skip_bytes = offset - cluster_offset;", "qemu_iovec_from_buf(qiov, 0, bounce_buffer + skip_bytes, bytes);", "err:\nqemu_vfree(bounce_buffer);", "return ret;", "}" ]
[ 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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 51 ], [ 55, 57 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 79, 81 ], [ 83 ], [ 85 ], [ 87 ], [ 91, 93 ], [ 101 ], [ 103 ], [ 111, 113 ], [ 115 ], [ 119 ], [ 129 ], [ 131 ], [ 135 ], [ 137 ], [ 141, 143 ], [ 145 ], [ 147 ] ]
11,362
static int img_bench(int argc, char **argv) { int c, ret = 0; const char *fmt = NULL, *filename; bool quiet = false; bool image_opts = false; bool is_write = false; int count = 75000; int depth = 64; int64_t offset = 0; size_t bufsize = 4096; int pattern = 0; size_t step = 0; int flush_interval = 0; bool drain_on_flush = true; int64_t image_size; BlockBackend *blk = NULL; BenchData data = {}; int flags = 0; bool writethrough = false; struct timeval t1, t2; int i; for (;;) { static const struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"flush-interval", required_argument, 0, OPTION_FLUSH_INTERVAL}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, {"pattern", required_argument, 0, OPTION_PATTERN}, {"no-drain", no_argument, 0, OPTION_NO_DRAIN}, {0, 0, 0, 0} }; c = getopt_long(argc, argv, "hc:d:f:no:qs:S:t:w", long_options, NULL); if (c == -1) { break; } switch (c) { case 'h': case '?': help(); break; case 'c': { unsigned long res; if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > INT_MAX) { error_report("Invalid request count specified"); return 1; } count = res; break; } case 'd': { unsigned long res; if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > INT_MAX) { error_report("Invalid queue depth specified"); return 1; } depth = res; break; } case 'f': fmt = optarg; break; case 'n': flags |= BDRV_O_NATIVE_AIO; break; case 'o': { offset = cvtnum(optarg); if (offset < 0) { error_report("Invalid offset specified"); return 1; } break; } break; case 'q': quiet = true; break; case 's': { int64_t sval; sval = cvtnum(optarg); if (sval < 0 || sval > INT_MAX) { error_report("Invalid buffer size specified"); return 1; } bufsize = sval; break; } case 'S': { int64_t sval; sval = cvtnum(optarg); if (sval < 0 || sval > INT_MAX) { error_report("Invalid step size specified"); return 1; } step = sval; break; } case 't': ret = bdrv_parse_cache_mode(optarg, &flags, &writethrough); if (ret < 0) { error_report("Invalid cache mode"); ret = -1; goto out; } break; case 'w': flags |= BDRV_O_RDWR; is_write = true; break; case OPTION_PATTERN: { unsigned long res; if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > 0xff) { error_report("Invalid pattern byte specified"); return 1; } pattern = res; break; } case OPTION_FLUSH_INTERVAL: { unsigned long res; if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > INT_MAX) { error_report("Invalid flush interval specified"); return 1; } flush_interval = res; break; } case OPTION_NO_DRAIN: drain_on_flush = false; break; case OPTION_IMAGE_OPTS: image_opts = true; break; } } if (optind != argc - 1) { error_exit("Expecting one image file name"); } filename = argv[argc - 1]; if (!is_write && flush_interval) { error_report("--flush-interval is only available in write tests"); ret = -1; goto out; } if (flush_interval && flush_interval < depth) { error_report("Flush interval can't be smaller than depth"); ret = -1; goto out; } blk = img_open(image_opts, filename, fmt, flags, writethrough, quiet); if (!blk) { ret = -1; goto out; } image_size = blk_getlength(blk); if (image_size < 0) { ret = image_size; goto out; } data = (BenchData) { .blk = blk, .image_size = image_size, .bufsize = bufsize, .step = step ?: bufsize, .nrreq = depth, .n = count, .offset = offset, .write = is_write, .flush_interval = flush_interval, .drain_on_flush = drain_on_flush, }; printf("Sending %d %s requests, %d bytes each, %d in parallel " "(starting at offset %" PRId64 ", step size %d)\n", data.n, data.write ? "write" : "read", data.bufsize, data.nrreq, data.offset, data.step); if (flush_interval) { printf("Sending flush every %d requests\n", flush_interval); } data.buf = blk_blockalign(blk, data.nrreq * data.bufsize); memset(data.buf, pattern, data.nrreq * data.bufsize); data.qiov = g_new(QEMUIOVector, data.nrreq); for (i = 0; i < data.nrreq; i++) { qemu_iovec_init(&data.qiov[i], 1); qemu_iovec_add(&data.qiov[i], data.buf + i * data.bufsize, data.bufsize); } gettimeofday(&t1, NULL); bench_cb(&data, 0); while (data.n > 0) { main_loop_wait(false); } gettimeofday(&t2, NULL); printf("Run completed in %3.3f seconds.\n", (t2.tv_sec - t1.tv_sec) + ((double)(t2.tv_usec - t1.tv_usec) / 1000000)); out: qemu_vfree(data.buf); blk_unref(blk); if (ret) { return 1; } return 0; }
true
qemu
c919297379e9980c2bcc4d2053addbc1fd6d762b
static int img_bench(int argc, char **argv) { int c, ret = 0; const char *fmt = NULL, *filename; bool quiet = false; bool image_opts = false; bool is_write = false; int count = 75000; int depth = 64; int64_t offset = 0; size_t bufsize = 4096; int pattern = 0; size_t step = 0; int flush_interval = 0; bool drain_on_flush = true; int64_t image_size; BlockBackend *blk = NULL; BenchData data = {}; int flags = 0; bool writethrough = false; struct timeval t1, t2; int i; for (;;) { static const struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"flush-interval", required_argument, 0, OPTION_FLUSH_INTERVAL}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, {"pattern", required_argument, 0, OPTION_PATTERN}, {"no-drain", no_argument, 0, OPTION_NO_DRAIN}, {0, 0, 0, 0} }; c = getopt_long(argc, argv, "hc:d:f:no:qs:S:t:w", long_options, NULL); if (c == -1) { break; } switch (c) { case 'h': case '?': help(); break; case 'c': { unsigned long res; if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > INT_MAX) { error_report("Invalid request count specified"); return 1; } count = res; break; } case 'd': { unsigned long res; if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > INT_MAX) { error_report("Invalid queue depth specified"); return 1; } depth = res; break; } case 'f': fmt = optarg; break; case 'n': flags |= BDRV_O_NATIVE_AIO; break; case 'o': { offset = cvtnum(optarg); if (offset < 0) { error_report("Invalid offset specified"); return 1; } break; } break; case 'q': quiet = true; break; case 's': { int64_t sval; sval = cvtnum(optarg); if (sval < 0 || sval > INT_MAX) { error_report("Invalid buffer size specified"); return 1; } bufsize = sval; break; } case 'S': { int64_t sval; sval = cvtnum(optarg); if (sval < 0 || sval > INT_MAX) { error_report("Invalid step size specified"); return 1; } step = sval; break; } case 't': ret = bdrv_parse_cache_mode(optarg, &flags, &writethrough); if (ret < 0) { error_report("Invalid cache mode"); ret = -1; goto out; } break; case 'w': flags |= BDRV_O_RDWR; is_write = true; break; case OPTION_PATTERN: { unsigned long res; if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > 0xff) { error_report("Invalid pattern byte specified"); return 1; } pattern = res; break; } case OPTION_FLUSH_INTERVAL: { unsigned long res; if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > INT_MAX) { error_report("Invalid flush interval specified"); return 1; } flush_interval = res; break; } case OPTION_NO_DRAIN: drain_on_flush = false; break; case OPTION_IMAGE_OPTS: image_opts = true; break; } } if (optind != argc - 1) { error_exit("Expecting one image file name"); } filename = argv[argc - 1]; if (!is_write && flush_interval) { error_report("--flush-interval is only available in write tests"); ret = -1; goto out; } if (flush_interval && flush_interval < depth) { error_report("Flush interval can't be smaller than depth"); ret = -1; goto out; } blk = img_open(image_opts, filename, fmt, flags, writethrough, quiet); if (!blk) { ret = -1; goto out; } image_size = blk_getlength(blk); if (image_size < 0) { ret = image_size; goto out; } data = (BenchData) { .blk = blk, .image_size = image_size, .bufsize = bufsize, .step = step ?: bufsize, .nrreq = depth, .n = count, .offset = offset, .write = is_write, .flush_interval = flush_interval, .drain_on_flush = drain_on_flush, }; printf("Sending %d %s requests, %d bytes each, %d in parallel " "(starting at offset %" PRId64 ", step size %d)\n", data.n, data.write ? "write" : "read", data.bufsize, data.nrreq, data.offset, data.step); if (flush_interval) { printf("Sending flush every %d requests\n", flush_interval); } data.buf = blk_blockalign(blk, data.nrreq * data.bufsize); memset(data.buf, pattern, data.nrreq * data.bufsize); data.qiov = g_new(QEMUIOVector, data.nrreq); for (i = 0; i < data.nrreq; i++) { qemu_iovec_init(&data.qiov[i], 1); qemu_iovec_add(&data.qiov[i], data.buf + i * data.bufsize, data.bufsize); } gettimeofday(&t1, NULL); bench_cb(&data, 0); while (data.n > 0) { main_loop_wait(false); } gettimeofday(&t2, NULL); printf("Run completed in %3.3f seconds.\n", (t2.tv_sec - t1.tv_sec) + ((double)(t2.tv_usec - t1.tv_usec) / 1000000)); out: qemu_vfree(data.buf); blk_unref(blk); if (ret) { return 1; } return 0; }
{ "code": [ " case 'h':", " c = getopt_long(argc, argv, \"hc:d:f:no:qs:S:t:w\", long_options, NULL);", " case 'h':", " case 'h':" ], "line_no": [ 77, 65, 77, 77 ] }
static int FUNC_0(int VAR_0, char **VAR_1) { int VAR_2, VAR_3 = 0; const char *VAR_4 = NULL, *VAR_5; bool quiet = false; bool image_opts = false; bool is_write = false; int VAR_6 = 75000; int VAR_7 = 64; int64_t offset = 0; size_t bufsize = 4096; int VAR_8 = 0; size_t step = 0; int VAR_9 = 0; bool drain_on_flush = true; int64_t image_size; BlockBackend *blk = NULL; BenchData data = {}; int VAR_10 = 0; bool writethrough = false; struct timeval VAR_11, VAR_12; int VAR_13; for (;;) { static const struct option VAR_14[] = { {"help", no_argument, 0, 'h'}, {"flush-interval", required_argument, 0, OPTION_FLUSH_INTERVAL}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, {"VAR_8", required_argument, 0, OPTION_PATTERN}, {"no-drain", no_argument, 0, OPTION_NO_DRAIN}, {0, 0, 0, 0} }; VAR_2 = getopt_long(VAR_0, VAR_1, "hc:d:f:no:qs:S:t:w", VAR_14, NULL); if (VAR_2 == -1) { break; } switch (VAR_2) { case 'h': case '?': help(); break; case 'VAR_2': { unsigned long VAR_16; if (qemu_strtoul(optarg, NULL, 0, &VAR_16) < 0 || VAR_16 > INT_MAX) { error_report("Invalid request VAR_6 specified"); return 1; } VAR_6 = VAR_16; break; } case 'd': { unsigned long VAR_16; if (qemu_strtoul(optarg, NULL, 0, &VAR_16) < 0 || VAR_16 > INT_MAX) { error_report("Invalid queue VAR_7 specified"); return 1; } VAR_7 = VAR_16; break; } case 'f': VAR_4 = optarg; break; case 'n': VAR_10 |= BDRV_O_NATIVE_AIO; break; case 'o': { offset = cvtnum(optarg); if (offset < 0) { error_report("Invalid offset specified"); return 1; } break; } break; case 'q': quiet = true; break; case 's': { int64_t sval; sval = cvtnum(optarg); if (sval < 0 || sval > INT_MAX) { error_report("Invalid buffer size specified"); return 1; } bufsize = sval; break; } case 'S': { int64_t sval; sval = cvtnum(optarg); if (sval < 0 || sval > INT_MAX) { error_report("Invalid step size specified"); return 1; } step = sval; break; } case 't': VAR_3 = bdrv_parse_cache_mode(optarg, &VAR_10, &writethrough); if (VAR_3 < 0) { error_report("Invalid cache mode"); VAR_3 = -1; goto out; } break; case 'w': VAR_10 |= BDRV_O_RDWR; is_write = true; break; case OPTION_PATTERN: { unsigned long VAR_16; if (qemu_strtoul(optarg, NULL, 0, &VAR_16) < 0 || VAR_16 > 0xff) { error_report("Invalid VAR_8 byte specified"); return 1; } VAR_8 = VAR_16; break; } case OPTION_FLUSH_INTERVAL: { unsigned long VAR_16; if (qemu_strtoul(optarg, NULL, 0, &VAR_16) < 0 || VAR_16 > INT_MAX) { error_report("Invalid flush interval specified"); return 1; } VAR_9 = VAR_16; break; } case OPTION_NO_DRAIN: drain_on_flush = false; break; case OPTION_IMAGE_OPTS: image_opts = true; break; } } if (optind != VAR_0 - 1) { error_exit("Expecting one image file name"); } VAR_5 = VAR_1[VAR_0 - 1]; if (!is_write && VAR_9) { error_report("--flush-interval is only available in write tests"); VAR_3 = -1; goto out; } if (VAR_9 && VAR_9 < VAR_7) { error_report("Flush interval can't be smaller than VAR_7"); VAR_3 = -1; goto out; } blk = img_open(image_opts, VAR_5, VAR_4, VAR_10, writethrough, quiet); if (!blk) { VAR_3 = -1; goto out; } image_size = blk_getlength(blk); if (image_size < 0) { VAR_3 = image_size; goto out; } data = (BenchData) { .blk = blk, .image_size = image_size, .bufsize = bufsize, .step = step ?: bufsize, .nrreq = VAR_7, .n = VAR_6, .offset = offset, .write = is_write, .VAR_9 = VAR_9, .drain_on_flush = drain_on_flush, }; printf("Sending %d %s requests, %d bytes each, %d in parallel " "(starting at offset %" PRId64 ", step size %d)\n", data.n, data.write ? "write" : "read", data.bufsize, data.nrreq, data.offset, data.step); if (VAR_9) { printf("Sending flush every %d requests\n", VAR_9); } data.buf = blk_blockalign(blk, data.nrreq * data.bufsize); memset(data.buf, VAR_8, data.nrreq * data.bufsize); data.qiov = g_new(QEMUIOVector, data.nrreq); for (VAR_13 = 0; VAR_13 < data.nrreq; VAR_13++) { qemu_iovec_init(&data.qiov[VAR_13], 1); qemu_iovec_add(&data.qiov[VAR_13], data.buf + VAR_13 * data.bufsize, data.bufsize); } gettimeofday(&VAR_11, NULL); bench_cb(&data, 0); while (data.n > 0) { main_loop_wait(false); } gettimeofday(&VAR_12, NULL); printf("Run completed in %3.3f seconds.\n", (VAR_12.tv_sec - VAR_11.tv_sec) + ((double)(VAR_12.tv_usec - VAR_11.tv_usec) / 1000000)); out: qemu_vfree(data.buf); blk_unref(blk); if (VAR_3) { return 1; } return 0; }
[ "static int FUNC_0(int VAR_0, char **VAR_1)\n{", "int VAR_2, VAR_3 = 0;", "const char *VAR_4 = NULL, *VAR_5;", "bool quiet = false;", "bool image_opts = false;", "bool is_write = false;", "int VAR_6 = 75000;", "int VAR_7 = 64;", "int64_t offset = 0;", "size_t bufsize = 4096;", "int VAR_8 = 0;", "size_t step = 0;", "int VAR_9 = 0;", "bool drain_on_flush = true;", "int64_t image_size;", "BlockBackend *blk = NULL;", "BenchData data = {};", "int VAR_10 = 0;", "bool writethrough = false;", "struct timeval VAR_11, VAR_12;", "int VAR_13;", "for (;;) {", "static const struct option VAR_14[] = {", "{\"help\", no_argument, 0, 'h'},", "{\"flush-interval\", required_argument, 0, OPTION_FLUSH_INTERVAL},", "{\"image-opts\", no_argument, 0, OPTION_IMAGE_OPTS},", "{\"VAR_8\", required_argument, 0, OPTION_PATTERN},", "{\"no-drain\", no_argument, 0, OPTION_NO_DRAIN},", "{0, 0, 0, 0}", "};", "VAR_2 = getopt_long(VAR_0, VAR_1, \"hc:d:f:no:qs:S:t:w\", VAR_14, NULL);", "if (VAR_2 == -1) {", "break;", "}", "switch (VAR_2) {", "case 'h':\ncase '?':\nhelp();", "break;", "case 'VAR_2':\n{", "unsigned long VAR_16;", "if (qemu_strtoul(optarg, NULL, 0, &VAR_16) < 0 || VAR_16 > INT_MAX) {", "error_report(\"Invalid request VAR_6 specified\");", "return 1;", "}", "VAR_6 = VAR_16;", "break;", "}", "case 'd':\n{", "unsigned long VAR_16;", "if (qemu_strtoul(optarg, NULL, 0, &VAR_16) < 0 || VAR_16 > INT_MAX) {", "error_report(\"Invalid queue VAR_7 specified\");", "return 1;", "}", "VAR_7 = VAR_16;", "break;", "}", "case 'f':\nVAR_4 = optarg;", "break;", "case 'n':\nVAR_10 |= BDRV_O_NATIVE_AIO;", "break;", "case 'o':\n{", "offset = cvtnum(optarg);", "if (offset < 0) {", "error_report(\"Invalid offset specified\");", "return 1;", "}", "break;", "}", "break;", "case 'q':\nquiet = true;", "break;", "case 's':\n{", "int64_t sval;", "sval = cvtnum(optarg);", "if (sval < 0 || sval > INT_MAX) {", "error_report(\"Invalid buffer size specified\");", "return 1;", "}", "bufsize = sval;", "break;", "}", "case 'S':\n{", "int64_t sval;", "sval = cvtnum(optarg);", "if (sval < 0 || sval > INT_MAX) {", "error_report(\"Invalid step size specified\");", "return 1;", "}", "step = sval;", "break;", "}", "case 't':\nVAR_3 = bdrv_parse_cache_mode(optarg, &VAR_10, &writethrough);", "if (VAR_3 < 0) {", "error_report(\"Invalid cache mode\");", "VAR_3 = -1;", "goto out;", "}", "break;", "case 'w':\nVAR_10 |= BDRV_O_RDWR;", "is_write = true;", "break;", "case OPTION_PATTERN:\n{", "unsigned long VAR_16;", "if (qemu_strtoul(optarg, NULL, 0, &VAR_16) < 0 || VAR_16 > 0xff) {", "error_report(\"Invalid VAR_8 byte specified\");", "return 1;", "}", "VAR_8 = VAR_16;", "break;", "}", "case OPTION_FLUSH_INTERVAL:\n{", "unsigned long VAR_16;", "if (qemu_strtoul(optarg, NULL, 0, &VAR_16) < 0 || VAR_16 > INT_MAX) {", "error_report(\"Invalid flush interval specified\");", "return 1;", "}", "VAR_9 = VAR_16;", "break;", "}", "case OPTION_NO_DRAIN:\ndrain_on_flush = false;", "break;", "case OPTION_IMAGE_OPTS:\nimage_opts = true;", "break;", "}", "}", "if (optind != VAR_0 - 1) {", "error_exit(\"Expecting one image file name\");", "}", "VAR_5 = VAR_1[VAR_0 - 1];", "if (!is_write && VAR_9) {", "error_report(\"--flush-interval is only available in write tests\");", "VAR_3 = -1;", "goto out;", "}", "if (VAR_9 && VAR_9 < VAR_7) {", "error_report(\"Flush interval can't be smaller than VAR_7\");", "VAR_3 = -1;", "goto out;", "}", "blk = img_open(image_opts, VAR_5, VAR_4, VAR_10, writethrough, quiet);", "if (!blk) {", "VAR_3 = -1;", "goto out;", "}", "image_size = blk_getlength(blk);", "if (image_size < 0) {", "VAR_3 = image_size;", "goto out;", "}", "data = (BenchData) {", ".blk = blk,\n.image_size = image_size,\n.bufsize = bufsize,\n.step = step ?: bufsize,\n.nrreq = VAR_7,\n.n = VAR_6,\n.offset = offset,\n.write = is_write,\n.VAR_9 = VAR_9,\n.drain_on_flush = drain_on_flush,\n};", "printf(\"Sending %d %s requests, %d bytes each, %d in parallel \"\n\"(starting at offset %\" PRId64 \", step size %d)\\n\",\ndata.n, data.write ? \"write\" : \"read\", data.bufsize, data.nrreq,\ndata.offset, data.step);", "if (VAR_9) {", "printf(\"Sending flush every %d requests\\n\", VAR_9);", "}", "data.buf = blk_blockalign(blk, data.nrreq * data.bufsize);", "memset(data.buf, VAR_8, data.nrreq * data.bufsize);", "data.qiov = g_new(QEMUIOVector, data.nrreq);", "for (VAR_13 = 0; VAR_13 < data.nrreq; VAR_13++) {", "qemu_iovec_init(&data.qiov[VAR_13], 1);", "qemu_iovec_add(&data.qiov[VAR_13],\ndata.buf + VAR_13 * data.bufsize, data.bufsize);", "}", "gettimeofday(&VAR_11, NULL);", "bench_cb(&data, 0);", "while (data.n > 0) {", "main_loop_wait(false);", "}", "gettimeofday(&VAR_12, NULL);", "printf(\"Run completed in %3.3f seconds.\\n\",\n(VAR_12.tv_sec - VAR_11.tv_sec)\n+ ((double)(VAR_12.tv_usec - VAR_11.tv_usec) / 1000000));", "out:\nqemu_vfree(data.buf);", "blk_unref(blk);", "if (VAR_3) {", "return 1;", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77, 79, 81 ], [ 83 ], [ 85, 87 ], [ 89 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107, 109 ], [ 111 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129, 131 ], [ 133 ], [ 135, 137 ], [ 139 ], [ 141, 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161, 163 ], [ 165 ], [ 167, 169 ], [ 171 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 187 ], [ 189 ], [ 191 ], [ 193, 195 ], [ 197 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 213 ], [ 215 ], [ 217 ], [ 219, 221 ], [ 223 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235, 237 ], [ 239 ], [ 241 ], [ 243, 245 ], [ 247 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 265, 267 ], [ 269 ], [ 273 ], [ 275 ], [ 277 ], [ 279 ], [ 281 ], [ 283 ], [ 285 ], [ 287, 289 ], [ 291 ], [ 293, 295 ], [ 297 ], [ 299 ], [ 301 ], [ 305 ], [ 307 ], [ 309 ], [ 311 ], [ 315 ], [ 317 ], [ 319 ], [ 321 ], [ 323 ], [ 325 ], [ 327 ], [ 329 ], [ 331 ], [ 333 ], [ 337 ], [ 339 ], [ 341 ], [ 343 ], [ 345 ], [ 349 ], [ 351 ], [ 353 ], [ 355 ], [ 357 ], [ 361 ], [ 363, 365, 367, 369, 371, 373, 375, 377, 379, 381, 383 ], [ 385, 387, 389, 391 ], [ 393 ], [ 395 ], [ 397 ], [ 401 ], [ 403 ], [ 407 ], [ 409 ], [ 411 ], [ 413, 415 ], [ 417 ], [ 421 ], [ 423 ], [ 427 ], [ 429 ], [ 431 ], [ 433 ], [ 437, 439, 441 ], [ 445, 447 ], [ 449 ], [ 453 ], [ 455 ], [ 457 ], [ 459 ], [ 461 ] ]
11,363
void object_property_add_link(Object *obj, const char *name, const char *type, Object **child, Error **errp) { gchar *full_type; full_type = g_strdup_printf("link<%s>", type); object_property_add(obj, name, full_type, object_get_link_property, object_set_link_property, NULL, child, errp); g_free(full_type); }
true
qemu
9561fda8d90e176bef598ba87c42a1bd6ad03ef7
void object_property_add_link(Object *obj, const char *name, const char *type, Object **child, Error **errp) { gchar *full_type; full_type = g_strdup_printf("link<%s>", type); object_property_add(obj, name, full_type, object_get_link_property, object_set_link_property, NULL, child, errp); g_free(full_type); }
{ "code": [ " NULL, child, errp);" ], "line_no": [ 23 ] }
void FUNC_0(Object *VAR_0, const char *VAR_1, const char *VAR_2, Object **VAR_3, Error **VAR_4) { gchar *full_type; full_type = g_strdup_printf("link<%s>", VAR_2); object_property_add(VAR_0, VAR_1, full_type, object_get_link_property, object_set_link_property, NULL, VAR_3, VAR_4); g_free(full_type); }
[ "void FUNC_0(Object *VAR_0, const char *VAR_1,\nconst char *VAR_2, Object **VAR_3,\nError **VAR_4)\n{", "gchar *full_type;", "full_type = g_strdup_printf(\"link<%s>\", VAR_2);", "object_property_add(VAR_0, VAR_1, full_type,\nobject_get_link_property,\nobject_set_link_property,\nNULL, VAR_3, VAR_4);", "g_free(full_type);", "}" ]
[ 0, 0, 0, 1, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 13 ], [ 17, 19, 21, 23 ], [ 27 ], [ 29 ] ]
11,364
static void process_event(JSONMessageParser *parser, QList *tokens) { GAState *s = container_of(parser, GAState, parser); QObject *obj; QDict *qdict; Error *err = NULL; int ret; g_assert(s && parser); g_debug("process_event: called"); obj = json_parser_parse_err(tokens, NULL, &err); if (err || !obj || qobject_type(obj) != QTYPE_QDICT) { qobject_decref(obj); qdict = qdict_new(); if (!err) { g_warning("failed to parse event: unknown error"); error_setg(&err, QERR_JSON_PARSING); } else { g_warning("failed to parse event: %s", error_get_pretty(err)); } qdict_put_obj(qdict, "error", qmp_build_error_object(err)); error_free(err); } else { qdict = qobject_to_qdict(obj); } g_assert(qdict); /* handle host->guest commands */ if (qdict_haskey(qdict, "execute")) { process_command(s, qdict); } else { if (!qdict_haskey(qdict, "error")) { QDECREF(qdict); qdict = qdict_new(); g_warning("unrecognized payload format"); error_setg(&err, QERR_UNSUPPORTED); qdict_put_obj(qdict, "error", qmp_build_error_object(err)); error_free(err); } ret = send_response(s, QOBJECT(qdict)); if (ret < 0) { g_warning("error sending error response: %s", strerror(-ret)); } } QDECREF(qdict); }
true
qemu
89cad9f3ec6b30d7550fb5704475fc9c3393a066
static void process_event(JSONMessageParser *parser, QList *tokens) { GAState *s = container_of(parser, GAState, parser); QObject *obj; QDict *qdict; Error *err = NULL; int ret; g_assert(s && parser); g_debug("process_event: called"); obj = json_parser_parse_err(tokens, NULL, &err); if (err || !obj || qobject_type(obj) != QTYPE_QDICT) { qobject_decref(obj); qdict = qdict_new(); if (!err) { g_warning("failed to parse event: unknown error"); error_setg(&err, QERR_JSON_PARSING); } else { g_warning("failed to parse event: %s", error_get_pretty(err)); } qdict_put_obj(qdict, "error", qmp_build_error_object(err)); error_free(err); } else { qdict = qobject_to_qdict(obj); } g_assert(qdict); if (qdict_haskey(qdict, "execute")) { process_command(s, qdict); } else { if (!qdict_haskey(qdict, "error")) { QDECREF(qdict); qdict = qdict_new(); g_warning("unrecognized payload format"); error_setg(&err, QERR_UNSUPPORTED); qdict_put_obj(qdict, "error", qmp_build_error_object(err)); error_free(err); } ret = send_response(s, QOBJECT(qdict)); if (ret < 0) { g_warning("error sending error response: %s", strerror(-ret)); } } QDECREF(qdict); }
{ "code": [ " QObject *obj;", " obj = json_parser_parse_err(tokens, NULL, &err);", " if (err || !obj || qobject_type(obj) != QTYPE_QDICT) {", " qobject_decref(obj);", " } else {", " qdict = qobject_to_qdict(obj);", " g_assert(qdict);" ], "line_no": [ 7, 23, 25, 27, 47, 49, 55 ] }
static void FUNC_0(JSONMessageParser *VAR_0, QList *VAR_1) { GAState *s = container_of(VAR_0, GAState, VAR_0); QObject *obj; QDict *qdict; Error *err = NULL; int VAR_2; g_assert(s && VAR_0); g_debug("FUNC_0: called"); obj = json_parser_parse_err(VAR_1, NULL, &err); if (err || !obj || qobject_type(obj) != QTYPE_QDICT) { qobject_decref(obj); qdict = qdict_new(); if (!err) { g_warning("failed to parse event: unknown error"); error_setg(&err, QERR_JSON_PARSING); } else { g_warning("failed to parse event: %s", error_get_pretty(err)); } qdict_put_obj(qdict, "error", qmp_build_error_object(err)); error_free(err); } else { qdict = qobject_to_qdict(obj); } g_assert(qdict); if (qdict_haskey(qdict, "execute")) { process_command(s, qdict); } else { if (!qdict_haskey(qdict, "error")) { QDECREF(qdict); qdict = qdict_new(); g_warning("unrecognized payload format"); error_setg(&err, QERR_UNSUPPORTED); qdict_put_obj(qdict, "error", qmp_build_error_object(err)); error_free(err); } VAR_2 = send_response(s, QOBJECT(qdict)); if (VAR_2 < 0) { g_warning("error sending error response: %s", strerror(-VAR_2)); } } QDECREF(qdict); }
[ "static void FUNC_0(JSONMessageParser *VAR_0, QList *VAR_1)\n{", "GAState *s = container_of(VAR_0, GAState, VAR_0);", "QObject *obj;", "QDict *qdict;", "Error *err = NULL;", "int VAR_2;", "g_assert(s && VAR_0);", "g_debug(\"FUNC_0: called\");", "obj = json_parser_parse_err(VAR_1, NULL, &err);", "if (err || !obj || qobject_type(obj) != QTYPE_QDICT) {", "qobject_decref(obj);", "qdict = qdict_new();", "if (!err) {", "g_warning(\"failed to parse event: unknown error\");", "error_setg(&err, QERR_JSON_PARSING);", "} else {", "g_warning(\"failed to parse event: %s\", error_get_pretty(err));", "}", "qdict_put_obj(qdict, \"error\", qmp_build_error_object(err));", "error_free(err);", "} else {", "qdict = qobject_to_qdict(obj);", "}", "g_assert(qdict);", "if (qdict_haskey(qdict, \"execute\")) {", "process_command(s, qdict);", "} else {", "if (!qdict_haskey(qdict, \"error\")) {", "QDECREF(qdict);", "qdict = qdict_new();", "g_warning(\"unrecognized payload format\");", "error_setg(&err, QERR_UNSUPPORTED);", "qdict_put_obj(qdict, \"error\", qmp_build_error_object(err));", "error_free(err);", "}", "VAR_2 = send_response(s, QOBJECT(qdict));", "if (VAR_2 < 0) {", "g_warning(\"error sending error response: %s\", strerror(-VAR_2));", "}", "}", "QDECREF(qdict);", "}" ]
[ 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 95 ], [ 97 ] ]
11,365
static inline void RENAME(rgb32tobgr24)(const uint8_t *src, uint8_t *dst, int src_size) { uint8_t *dest = dst; const uint8_t *s = src; const uint8_t *end; const uint8_t *mm_end; end = s + src_size; __asm__ volatile(PREFETCH" %0"::"m"(*s):"memory"); mm_end = end - 31; while (s < mm_end) { __asm__ volatile( PREFETCH" 32%1 \n\t" "movq %1, %%mm0 \n\t" "movq 8%1, %%mm1 \n\t" "movq 16%1, %%mm4 \n\t" "movq 24%1, %%mm5 \n\t" "movq %%mm0, %%mm2 \n\t" "movq %%mm1, %%mm3 \n\t" "movq %%mm4, %%mm6 \n\t" "movq %%mm5, %%mm7 \n\t" STORE_BGR24_MMX :"=m"(*dest) :"m"(*s) :"memory"); dest += 24; s += 32; } __asm__ volatile(SFENCE:::"memory"); __asm__ volatile(EMMS:::"memory"); while (s < end) { *dest++ = *s++; *dest++ = *s++; *dest++ = *s++; s++; } }
true
FFmpeg
90540c2d5ace46a1e9789c75fde0b1f7dbb12a9b
static inline void RENAME(rgb32tobgr24)(const uint8_t *src, uint8_t *dst, int src_size) { uint8_t *dest = dst; const uint8_t *s = src; const uint8_t *end; const uint8_t *mm_end; end = s + src_size; __asm__ volatile(PREFETCH" %0"::"m"(*s):"memory"); mm_end = end - 31; while (s < mm_end) { __asm__ volatile( PREFETCH" 32%1 \n\t" "movq %1, %%mm0 \n\t" "movq 8%1, %%mm1 \n\t" "movq 16%1, %%mm4 \n\t" "movq 24%1, %%mm5 \n\t" "movq %%mm0, %%mm2 \n\t" "movq %%mm1, %%mm3 \n\t" "movq %%mm4, %%mm6 \n\t" "movq %%mm5, %%mm7 \n\t" STORE_BGR24_MMX :"=m"(*dest) :"m"(*s) :"memory"); dest += 24; s += 32; } __asm__ volatile(SFENCE:::"memory"); __asm__ volatile(EMMS:::"memory"); while (s < end) { *dest++ = *s++; *dest++ = *s++; *dest++ = *s++; s++; } }
{ "code": [ " PREFETCH\" 32%1 \\n\\t\"", " :\"=m\"(*dest)", " :\"m\"(*s)", " PREFETCH\" 32%1 \\n\\t\"", " \"movq %1, %%mm0 \\n\\t\"", " \"movq 8%1, %%mm1 \\n\\t\"", " \"movq 16%1, %%mm4 \\n\\t\"", " \"movq 24%1, %%mm5 \\n\\t\"", " :\"=m\"(*dest)", " :\"m\"(*s)", " :\"m\"(*s)", " :\"m\"(*s)", " PREFETCH\" 32%1 \\n\\t\"", " PREFETCH\" 32%1 \\n\\t\"", " PREFETCH\" 32%1 \\n\\t\"", " PREFETCH\" 32%1 \\n\\t\"", " PREFETCH\" 32%1 \\n\\t\"", " PREFETCH\" 32%1 \\n\\t\"", " \"movq %1, %%mm0 \\n\\t\"", " \"movq 8%1, %%mm1 \\n\\t\"", " :\"m\"(*s)", " PREFETCH\" 32%1 \\n\\t\"", " \"movq %1, %%mm0 \\n\\t\"", " \"movq 8%1, %%mm1 \\n\\t\"", " :\"m\"(*s)", " PREFETCH\" 32%1 \\n\\t\"", " \"movq %1, %%mm0 \\n\\t\"", " PREFETCH\" 32%1 \\n\\t\"", " \"movq %1, %%mm0 \\n\\t\"" ], "line_no": [ 23, 43, 45, 23, 25, 27, 29, 31, 43, 45, 45, 45, 23, 23, 23, 23, 23, 23, 25, 27, 45, 23, 25, 27, 45, 23, 25, 23, 25 ] }
static inline void FUNC_0(rgb32tobgr24)(const uint8_t *src, uint8_t *dst, int src_size) { uint8_t *dest = dst; const uint8_t *VAR_0 = src; const uint8_t *VAR_1; const uint8_t *VAR_2; VAR_1 = VAR_0 + src_size; __asm__ volatile(PREFETCH" %0"::"m"(*VAR_0):"memory"); VAR_2 = VAR_1 - 31; while (VAR_0 < VAR_2) { __asm__ volatile( PREFETCH" 32%1 \n\t" "movq %1, %%mm0 \n\t" "movq 8%1, %%mm1 \n\t" "movq 16%1, %%mm4 \n\t" "movq 24%1, %%mm5 \n\t" "movq %%mm0, %%mm2 \n\t" "movq %%mm1, %%mm3 \n\t" "movq %%mm4, %%mm6 \n\t" "movq %%mm5, %%mm7 \n\t" STORE_BGR24_MMX :"=m"(*dest) :"m"(*VAR_0) :"memory"); dest += 24; VAR_0 += 32; } __asm__ volatile(SFENCE:::"memory"); __asm__ volatile(EMMS:::"memory"); while (VAR_0 < VAR_1) { *dest++ = *VAR_0++; *dest++ = *VAR_0++; *dest++ = *VAR_0++; VAR_0++; } }
[ "static inline void FUNC_0(rgb32tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)\n{", "uint8_t *dest = dst;", "const uint8_t *VAR_0 = src;", "const uint8_t *VAR_1;", "const uint8_t *VAR_2;", "VAR_1 = VAR_0 + src_size;", "__asm__ volatile(PREFETCH\" %0\"::\"m\"(*VAR_0):\"memory\");", "VAR_2 = VAR_1 - 31;", "while (VAR_0 < VAR_2) {", "__asm__ volatile(\nPREFETCH\" 32%1 \\n\\t\"\n\"movq %1, %%mm0 \\n\\t\"\n\"movq 8%1, %%mm1 \\n\\t\"\n\"movq 16%1, %%mm4 \\n\\t\"\n\"movq 24%1, %%mm5 \\n\\t\"\n\"movq %%mm0, %%mm2 \\n\\t\"\n\"movq %%mm1, %%mm3 \\n\\t\"\n\"movq %%mm4, %%mm6 \\n\\t\"\n\"movq %%mm5, %%mm7 \\n\\t\"\nSTORE_BGR24_MMX\n:\"=m\"(*dest)\n:\"m\"(*VAR_0)\n:\"memory\");", "dest += 24;", "VAR_0 += 32;", "}", "__asm__ volatile(SFENCE:::\"memory\");", "__asm__ volatile(EMMS:::\"memory\");", "while (VAR_0 < VAR_1) {", "*dest++ = *VAR_0++;", "*dest++ = *VAR_0++;", "*dest++ = *VAR_0++;", "VAR_0++;", "}", "}" ]
[ 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 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ] ]
11,366
static void slice_thread_park_workers(ThreadContext *c) { pthread_cond_wait(&c->last_job_cond, &c->current_job_lock); pthread_mutex_unlock(&c->current_job_lock); }
true
FFmpeg
3511d4fc9784d5fbb024dce68ca7a0d7fdd74663
static void slice_thread_park_workers(ThreadContext *c) { pthread_cond_wait(&c->last_job_cond, &c->current_job_lock); pthread_mutex_unlock(&c->current_job_lock); }
{ "code": [ " pthread_cond_wait(&c->last_job_cond, &c->current_job_lock);" ], "line_no": [ 5 ] }
static void FUNC_0(ThreadContext *VAR_0) { pthread_cond_wait(&VAR_0->last_job_cond, &VAR_0->current_job_lock); pthread_mutex_unlock(&VAR_0->current_job_lock); }
[ "static void FUNC_0(ThreadContext *VAR_0)\n{", "pthread_cond_wait(&VAR_0->last_job_cond, &VAR_0->current_job_lock);", "pthread_mutex_unlock(&VAR_0->current_job_lock);", "}" ]
[ 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ] ]
11,367
static av_cold int ljpeg_encode_init(AVCodecContext *avctx) { LJpegEncContext *s = avctx->priv_data; int chroma_v_shift, chroma_h_shift; if ((avctx->pix_fmt == AV_PIX_FMT_YUV420P || avctx->pix_fmt == AV_PIX_FMT_YUV422P || avctx->pix_fmt == AV_PIX_FMT_YUV444P) && avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) { av_log(avctx, AV_LOG_ERROR, "Limited range YUV is non-standard, set strict_std_compliance to " "at least unofficial to use it.\n"); return AVERROR(EINVAL); } avctx->coded_frame = av_frame_alloc(); if (!avctx->coded_frame) return AVERROR(ENOMEM); avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; avctx->coded_frame->key_frame = 1; s->scratch = av_malloc_array(avctx->width + 1, sizeof(*s->scratch)); ff_dsputil_init(&s->dsp, avctx); ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct); av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift, &chroma_v_shift); if (avctx->pix_fmt == AV_PIX_FMT_BGR24) { s->vsample[0] = s->hsample[0] = s->vsample[1] = s->hsample[1] = s->vsample[2] = s->hsample[2] = 1; } else { s->vsample[0] = 2; s->vsample[1] = 2 >> chroma_v_shift; s->vsample[2] = 2 >> chroma_v_shift; s->hsample[0] = 2; s->hsample[1] = 2 >> chroma_h_shift; s->hsample[2] = 2 >> chroma_h_shift; } ff_mjpeg_build_huffman_codes(s->huff_size_dc_luminance, s->huff_code_dc_luminance, avpriv_mjpeg_bits_dc_luminance, avpriv_mjpeg_val_dc); ff_mjpeg_build_huffman_codes(s->huff_size_dc_chrominance, s->huff_code_dc_chrominance, avpriv_mjpeg_bits_dc_chrominance, avpriv_mjpeg_val_dc); return 0; }
false
FFmpeg
bf0d7da7cbbf869605086c2a47cdf87f0a533e24
static av_cold int ljpeg_encode_init(AVCodecContext *avctx) { LJpegEncContext *s = avctx->priv_data; int chroma_v_shift, chroma_h_shift; if ((avctx->pix_fmt == AV_PIX_FMT_YUV420P || avctx->pix_fmt == AV_PIX_FMT_YUV422P || avctx->pix_fmt == AV_PIX_FMT_YUV444P) && avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) { av_log(avctx, AV_LOG_ERROR, "Limited range YUV is non-standard, set strict_std_compliance to " "at least unofficial to use it.\n"); return AVERROR(EINVAL); } avctx->coded_frame = av_frame_alloc(); if (!avctx->coded_frame) return AVERROR(ENOMEM); avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; avctx->coded_frame->key_frame = 1; s->scratch = av_malloc_array(avctx->width + 1, sizeof(*s->scratch)); ff_dsputil_init(&s->dsp, avctx); ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct); av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift, &chroma_v_shift); if (avctx->pix_fmt == AV_PIX_FMT_BGR24) { s->vsample[0] = s->hsample[0] = s->vsample[1] = s->hsample[1] = s->vsample[2] = s->hsample[2] = 1; } else { s->vsample[0] = 2; s->vsample[1] = 2 >> chroma_v_shift; s->vsample[2] = 2 >> chroma_v_shift; s->hsample[0] = 2; s->hsample[1] = 2 >> chroma_h_shift; s->hsample[2] = 2 >> chroma_h_shift; } ff_mjpeg_build_huffman_codes(s->huff_size_dc_luminance, s->huff_code_dc_luminance, avpriv_mjpeg_bits_dc_luminance, avpriv_mjpeg_val_dc); ff_mjpeg_build_huffman_codes(s->huff_size_dc_chrominance, s->huff_code_dc_chrominance, avpriv_mjpeg_bits_dc_chrominance, avpriv_mjpeg_val_dc); return 0; }
{ "code": [], "line_no": [] }
static av_cold int FUNC_0(AVCodecContext *avctx) { LJpegEncContext *s = avctx->priv_data; int VAR_0, VAR_1; if ((avctx->pix_fmt == AV_PIX_FMT_YUV420P || avctx->pix_fmt == AV_PIX_FMT_YUV422P || avctx->pix_fmt == AV_PIX_FMT_YUV444P) && avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) { av_log(avctx, AV_LOG_ERROR, "Limited range YUV is non-standard, set strict_std_compliance to " "at least unofficial to use it.\n"); return AVERROR(EINVAL); } avctx->coded_frame = av_frame_alloc(); if (!avctx->coded_frame) return AVERROR(ENOMEM); avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; avctx->coded_frame->key_frame = 1; s->scratch = av_malloc_array(avctx->width + 1, sizeof(*s->scratch)); ff_dsputil_init(&s->dsp, avctx); ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct); av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &VAR_1, &VAR_0); if (avctx->pix_fmt == AV_PIX_FMT_BGR24) { s->vsample[0] = s->hsample[0] = s->vsample[1] = s->hsample[1] = s->vsample[2] = s->hsample[2] = 1; } else { s->vsample[0] = 2; s->vsample[1] = 2 >> VAR_0; s->vsample[2] = 2 >> VAR_0; s->hsample[0] = 2; s->hsample[1] = 2 >> VAR_1; s->hsample[2] = 2 >> VAR_1; } ff_mjpeg_build_huffman_codes(s->huff_size_dc_luminance, s->huff_code_dc_luminance, avpriv_mjpeg_bits_dc_luminance, avpriv_mjpeg_val_dc); ff_mjpeg_build_huffman_codes(s->huff_size_dc_chrominance, s->huff_code_dc_chrominance, avpriv_mjpeg_bits_dc_chrominance, avpriv_mjpeg_val_dc); return 0; }
[ "static av_cold int FUNC_0(AVCodecContext *avctx)\n{", "LJpegEncContext *s = avctx->priv_data;", "int VAR_0, VAR_1;", "if ((avctx->pix_fmt == AV_PIX_FMT_YUV420P ||\navctx->pix_fmt == AV_PIX_FMT_YUV422P ||\navctx->pix_fmt == AV_PIX_FMT_YUV444P) &&\navctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) {", "av_log(avctx, AV_LOG_ERROR,\n\"Limited range YUV is non-standard, set strict_std_compliance to \"\n\"at least unofficial to use it.\\n\");", "return AVERROR(EINVAL);", "}", "avctx->coded_frame = av_frame_alloc();", "if (!avctx->coded_frame)\nreturn AVERROR(ENOMEM);", "avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;", "avctx->coded_frame->key_frame = 1;", "s->scratch = av_malloc_array(avctx->width + 1, sizeof(*s->scratch));", "ff_dsputil_init(&s->dsp, avctx);", "ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct);", "av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &VAR_1,\n&VAR_0);", "if (avctx->pix_fmt == AV_PIX_FMT_BGR24) {", "s->vsample[0] = s->hsample[0] =\ns->vsample[1] = s->hsample[1] =\ns->vsample[2] = s->hsample[2] = 1;", "} else {", "s->vsample[0] = 2;", "s->vsample[1] = 2 >> VAR_0;", "s->vsample[2] = 2 >> VAR_0;", "s->hsample[0] = 2;", "s->hsample[1] = 2 >> VAR_1;", "s->hsample[2] = 2 >> VAR_1;", "}", "ff_mjpeg_build_huffman_codes(s->huff_size_dc_luminance,\ns->huff_code_dc_luminance,\navpriv_mjpeg_bits_dc_luminance,\navpriv_mjpeg_val_dc);", "ff_mjpeg_build_huffman_codes(s->huff_size_dc_chrominance,\ns->huff_code_dc_chrominance,\navpriv_mjpeg_bits_dc_chrominance,\navpriv_mjpeg_val_dc);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11, 13, 15, 17 ], [ 19, 21, 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33, 35 ], [ 39 ], [ 41 ], [ 45 ], [ 49 ], [ 51 ], [ 55, 57 ], [ 61 ], [ 63, 65, 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 87, 89, 91, 93 ], [ 95, 97, 99, 101 ], [ 105 ], [ 107 ] ]
11,369
static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, const char *name, int devfn, Error **errp) { PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev); PCIConfigReadFunc *config_read = pc->config_read; PCIConfigWriteFunc *config_write = pc->config_write; Error *local_err = NULL; AddressSpace *dma_as; DeviceState *dev = DEVICE(pci_dev); pci_dev->bus = bus; /* Only pci bridges can be attached to extra PCI root buses */ if (pci_bus_is_root(bus) && bus->parent_dev && !pc->is_bridge) { error_setg(errp, "PCI: Only PCI/PCIe bridges can be plugged into %s", bus->parent_dev->name); return NULL; } if (devfn < 0) { for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices); devfn += PCI_FUNC_MAX) { if (!bus->devices[devfn]) goto found; } error_setg(errp, "PCI: no slot/function available for %s, all in use", name); return NULL; found: ; } else if (bus->devices[devfn]) { error_setg(errp, "PCI: slot %d function %d not available for %s," " in use by %s", PCI_SLOT(devfn), PCI_FUNC(devfn), name, bus->devices[devfn]->name); return NULL; } else if (dev->hotplugged && pci_get_function_0(pci_dev)) { error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s," " new func %s cannot be exposed to guest.", PCI_SLOT(devfn), bus->devices[PCI_DEVFN(PCI_SLOT(devfn), 0)]->name, name); return NULL; } pci_dev->devfn = devfn; dma_as = pci_device_iommu_address_space(pci_dev); memory_region_init_alias(&pci_dev->bus_master_enable_region, OBJECT(pci_dev), "bus master", dma_as->root, 0, memory_region_size(dma_as->root)); memory_region_set_enabled(&pci_dev->bus_master_enable_region, false); address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region, name); pstrcpy(pci_dev->name, sizeof(pci_dev->name), name); pci_dev->irq_state = 0; pci_config_alloc(pci_dev); pci_config_set_vendor_id(pci_dev->config, pc->vendor_id); pci_config_set_device_id(pci_dev->config, pc->device_id); pci_config_set_revision(pci_dev->config, pc->revision); pci_config_set_class(pci_dev->config, pc->class_id); if (!pc->is_bridge) { if (pc->subsystem_vendor_id || pc->subsystem_id) { pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID, pc->subsystem_vendor_id); pci_set_word(pci_dev->config + PCI_SUBSYSTEM_ID, pc->subsystem_id); } else { pci_set_default_subsystem_id(pci_dev); } } else { /* subsystem_vendor_id/subsystem_id are only for header type 0 */ assert(!pc->subsystem_vendor_id); assert(!pc->subsystem_id); } pci_init_cmask(pci_dev); pci_init_wmask(pci_dev); pci_init_w1cmask(pci_dev); if (pc->is_bridge) { pci_init_mask_bridge(pci_dev); } pci_init_multifunction(bus, pci_dev, &local_err); if (local_err) { error_propagate(errp, local_err); do_pci_unregister_device(pci_dev); return NULL; } if (!config_read) config_read = pci_default_read_config; if (!config_write) config_write = pci_default_write_config; pci_dev->config_read = config_read; pci_dev->config_write = config_write; bus->devices[devfn] = pci_dev; pci_dev->version_id = 2; /* Current pci device vmstate version */ return pci_dev; }
true
qemu
4a94b3aa6d97dfa67a20c7a0315c9773352f0e8e
static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, const char *name, int devfn, Error **errp) { PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev); PCIConfigReadFunc *config_read = pc->config_read; PCIConfigWriteFunc *config_write = pc->config_write; Error *local_err = NULL; AddressSpace *dma_as; DeviceState *dev = DEVICE(pci_dev); pci_dev->bus = bus; if (pci_bus_is_root(bus) && bus->parent_dev && !pc->is_bridge) { error_setg(errp, "PCI: Only PCI/PCIe bridges can be plugged into %s", bus->parent_dev->name); return NULL; } if (devfn < 0) { for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices); devfn += PCI_FUNC_MAX) { if (!bus->devices[devfn]) goto found; } error_setg(errp, "PCI: no slot/function available for %s, all in use", name); return NULL; found: ; } else if (bus->devices[devfn]) { error_setg(errp, "PCI: slot %d function %d not available for %s," " in use by %s", PCI_SLOT(devfn), PCI_FUNC(devfn), name, bus->devices[devfn]->name); return NULL; } else if (dev->hotplugged && pci_get_function_0(pci_dev)) { error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s," " new func %s cannot be exposed to guest.", PCI_SLOT(devfn), bus->devices[PCI_DEVFN(PCI_SLOT(devfn), 0)]->name, name); return NULL; } pci_dev->devfn = devfn; dma_as = pci_device_iommu_address_space(pci_dev); memory_region_init_alias(&pci_dev->bus_master_enable_region, OBJECT(pci_dev), "bus master", dma_as->root, 0, memory_region_size(dma_as->root)); memory_region_set_enabled(&pci_dev->bus_master_enable_region, false); address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region, name); pstrcpy(pci_dev->name, sizeof(pci_dev->name), name); pci_dev->irq_state = 0; pci_config_alloc(pci_dev); pci_config_set_vendor_id(pci_dev->config, pc->vendor_id); pci_config_set_device_id(pci_dev->config, pc->device_id); pci_config_set_revision(pci_dev->config, pc->revision); pci_config_set_class(pci_dev->config, pc->class_id); if (!pc->is_bridge) { if (pc->subsystem_vendor_id || pc->subsystem_id) { pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID, pc->subsystem_vendor_id); pci_set_word(pci_dev->config + PCI_SUBSYSTEM_ID, pc->subsystem_id); } else { pci_set_default_subsystem_id(pci_dev); } } else { assert(!pc->subsystem_vendor_id); assert(!pc->subsystem_id); } pci_init_cmask(pci_dev); pci_init_wmask(pci_dev); pci_init_w1cmask(pci_dev); if (pc->is_bridge) { pci_init_mask_bridge(pci_dev); } pci_init_multifunction(bus, pci_dev, &local_err); if (local_err) { error_propagate(errp, local_err); do_pci_unregister_device(pci_dev); return NULL; } if (!config_read) config_read = pci_default_read_config; if (!config_write) config_write = pci_default_write_config; pci_dev->config_read = config_read; pci_dev->config_write = config_write; bus->devices[devfn] = pci_dev; pci_dev->version_id = 2; return pci_dev; }
{ "code": [], "line_no": [] }
static PCIDevice *FUNC_0(PCIDevice *pci_dev, PCIBus *bus, const char *name, int devfn, Error **errp) { PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev); PCIConfigReadFunc *config_read = pc->config_read; PCIConfigWriteFunc *config_write = pc->config_write; Error *local_err = NULL; AddressSpace *dma_as; DeviceState *dev = DEVICE(pci_dev); pci_dev->bus = bus; if (pci_bus_is_root(bus) && bus->parent_dev && !pc->is_bridge) { error_setg(errp, "PCI: Only PCI/PCIe bridges can be plugged into %s", bus->parent_dev->name); return NULL; } if (devfn < 0) { for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices); devfn += PCI_FUNC_MAX) { if (!bus->devices[devfn]) goto found; } error_setg(errp, "PCI: no slot/function available for %s, all in use", name); return NULL; found: ; } else if (bus->devices[devfn]) { error_setg(errp, "PCI: slot %d function %d not available for %s," " in use by %s", PCI_SLOT(devfn), PCI_FUNC(devfn), name, bus->devices[devfn]->name); return NULL; } else if (dev->hotplugged && pci_get_function_0(pci_dev)) { error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s," " new func %s cannot be exposed to guest.", PCI_SLOT(devfn), bus->devices[PCI_DEVFN(PCI_SLOT(devfn), 0)]->name, name); return NULL; } pci_dev->devfn = devfn; dma_as = pci_device_iommu_address_space(pci_dev); memory_region_init_alias(&pci_dev->bus_master_enable_region, OBJECT(pci_dev), "bus master", dma_as->root, 0, memory_region_size(dma_as->root)); memory_region_set_enabled(&pci_dev->bus_master_enable_region, false); address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region, name); pstrcpy(pci_dev->name, sizeof(pci_dev->name), name); pci_dev->irq_state = 0; pci_config_alloc(pci_dev); pci_config_set_vendor_id(pci_dev->config, pc->vendor_id); pci_config_set_device_id(pci_dev->config, pc->device_id); pci_config_set_revision(pci_dev->config, pc->revision); pci_config_set_class(pci_dev->config, pc->class_id); if (!pc->is_bridge) { if (pc->subsystem_vendor_id || pc->subsystem_id) { pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID, pc->subsystem_vendor_id); pci_set_word(pci_dev->config + PCI_SUBSYSTEM_ID, pc->subsystem_id); } else { pci_set_default_subsystem_id(pci_dev); } } else { assert(!pc->subsystem_vendor_id); assert(!pc->subsystem_id); } pci_init_cmask(pci_dev); pci_init_wmask(pci_dev); pci_init_w1cmask(pci_dev); if (pc->is_bridge) { pci_init_mask_bridge(pci_dev); } pci_init_multifunction(bus, pci_dev, &local_err); if (local_err) { error_propagate(errp, local_err); do_pci_unregister_device(pci_dev); return NULL; } if (!config_read) config_read = pci_default_read_config; if (!config_write) config_write = pci_default_write_config; pci_dev->config_read = config_read; pci_dev->config_write = config_write; bus->devices[devfn] = pci_dev; pci_dev->version_id = 2; return pci_dev; }
[ "static PCIDevice *FUNC_0(PCIDevice *pci_dev, PCIBus *bus,\nconst char *name, int devfn,\nError **errp)\n{", "PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);", "PCIConfigReadFunc *config_read = pc->config_read;", "PCIConfigWriteFunc *config_write = pc->config_write;", "Error *local_err = NULL;", "AddressSpace *dma_as;", "DeviceState *dev = DEVICE(pci_dev);", "pci_dev->bus = bus;", "if (pci_bus_is_root(bus) && bus->parent_dev && !pc->is_bridge) {", "error_setg(errp,\n\"PCI: Only PCI/PCIe bridges can be plugged into %s\",\nbus->parent_dev->name);", "return NULL;", "}", "if (devfn < 0) {", "for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices);", "devfn += PCI_FUNC_MAX) {", "if (!bus->devices[devfn])\ngoto found;", "}", "error_setg(errp, \"PCI: no slot/function available for %s, all in use\",\nname);", "return NULL;", "found: ;", "} else if (bus->devices[devfn]) {", "error_setg(errp, \"PCI: slot %d function %d not available for %s,\"\n\" in use by %s\",\nPCI_SLOT(devfn), PCI_FUNC(devfn), name,\nbus->devices[devfn]->name);", "return NULL;", "} else if (dev->hotplugged &&", "pci_get_function_0(pci_dev)) {", "error_setg(errp, \"PCI: slot %d function 0 already ocuppied by %s,\"\n\" new func %s cannot be exposed to guest.\",\nPCI_SLOT(devfn),\nbus->devices[PCI_DEVFN(PCI_SLOT(devfn), 0)]->name,\nname);", "return NULL;", "}", "pci_dev->devfn = devfn;", "dma_as = pci_device_iommu_address_space(pci_dev);", "memory_region_init_alias(&pci_dev->bus_master_enable_region,\nOBJECT(pci_dev), \"bus master\",\ndma_as->root, 0, memory_region_size(dma_as->root));", "memory_region_set_enabled(&pci_dev->bus_master_enable_region, false);", "address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region,\nname);", "pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);", "pci_dev->irq_state = 0;", "pci_config_alloc(pci_dev);", "pci_config_set_vendor_id(pci_dev->config, pc->vendor_id);", "pci_config_set_device_id(pci_dev->config, pc->device_id);", "pci_config_set_revision(pci_dev->config, pc->revision);", "pci_config_set_class(pci_dev->config, pc->class_id);", "if (!pc->is_bridge) {", "if (pc->subsystem_vendor_id || pc->subsystem_id) {", "pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID,\npc->subsystem_vendor_id);", "pci_set_word(pci_dev->config + PCI_SUBSYSTEM_ID,\npc->subsystem_id);", "} else {", "pci_set_default_subsystem_id(pci_dev);", "}", "} else {", "assert(!pc->subsystem_vendor_id);", "assert(!pc->subsystem_id);", "}", "pci_init_cmask(pci_dev);", "pci_init_wmask(pci_dev);", "pci_init_w1cmask(pci_dev);", "if (pc->is_bridge) {", "pci_init_mask_bridge(pci_dev);", "}", "pci_init_multifunction(bus, pci_dev, &local_err);", "if (local_err) {", "error_propagate(errp, local_err);", "do_pci_unregister_device(pci_dev);", "return NULL;", "}", "if (!config_read)\nconfig_read = pci_default_read_config;", "if (!config_write)\nconfig_write = pci_default_write_config;", "pci_dev->config_read = config_read;", "pci_dev->config_write = config_write;", "bus->devices[devfn] = pci_dev;", "pci_dev->version_id = 2;", "return pci_dev;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 27 ], [ 29, 31, 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47, 49 ], [ 51 ], [ 53, 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63, 65, 67, 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77, 79, 81, 83, 85 ], [ 89 ], [ 91 ], [ 95 ], [ 98 ], [ 102, 104, 106 ], [ 108 ], [ 110, 112 ], [ 116 ], [ 118 ], [ 120 ], [ 124 ], [ 126 ], [ 128 ], [ 130 ], [ 134 ], [ 136 ], [ 138, 140 ], [ 142, 144 ], [ 146 ], [ 148 ], [ 150 ], [ 152 ], [ 156 ], [ 158 ], [ 160 ], [ 162 ], [ 164 ], [ 166 ], [ 168 ], [ 170 ], [ 172 ], [ 174 ], [ 176 ], [ 178 ], [ 180 ], [ 182 ], [ 184 ], [ 188, 190 ], [ 192, 194 ], [ 196 ], [ 198 ], [ 200 ], [ 202 ], [ 204 ], [ 206 ] ]
11,370
static void multiwrite_cb(void *opaque, int ret) { MultiwriteCB *mcb = opaque; if (ret < 0) { mcb->error = ret; multiwrite_user_cb(mcb); } mcb->num_requests--; if (mcb->num_requests == 0) { if (mcb->error == 0) { multiwrite_user_cb(mcb); } qemu_free(mcb); } }
true
qemu
cb6d3ca07b8f62b47ef30c6a92caa3e8bd71248b
static void multiwrite_cb(void *opaque, int ret) { MultiwriteCB *mcb = opaque; if (ret < 0) { mcb->error = ret; multiwrite_user_cb(mcb); } mcb->num_requests--; if (mcb->num_requests == 0) { if (mcb->error == 0) { multiwrite_user_cb(mcb); } qemu_free(mcb); } }
{ "code": [ " if (ret < 0) {" ], "line_no": [ 9 ] }
static void FUNC_0(void *VAR_0, int VAR_1) { MultiwriteCB *mcb = VAR_0; if (VAR_1 < 0) { mcb->error = VAR_1; multiwrite_user_cb(mcb); } mcb->num_requests--; if (mcb->num_requests == 0) { if (mcb->error == 0) { multiwrite_user_cb(mcb); } qemu_free(mcb); } }
[ "static void FUNC_0(void *VAR_0, int VAR_1)\n{", "MultiwriteCB *mcb = VAR_0;", "if (VAR_1 < 0) {", "mcb->error = VAR_1;", "multiwrite_user_cb(mcb);", "}", "mcb->num_requests--;", "if (mcb->num_requests == 0) {", "if (mcb->error == 0) {", "multiwrite_user_cb(mcb);", "}", "qemu_free(mcb);", "}", "}" ]
[ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ] ]
11,371
qemu_irq *pl190_init(uint32_t base, qemu_irq irq, qemu_irq fiq) { pl190_state *s; qemu_irq *qi; int iomemtype; s = (pl190_state *)qemu_mallocz(sizeof(pl190_state)); iomemtype = cpu_register_io_memory(0, pl190_readfn, pl190_writefn, s); cpu_register_physical_memory(base, 0x00000fff, iomemtype); qi = qemu_allocate_irqs(pl190_set_irq, s, 32); s->base = base; s->irq = irq; s->fiq = fiq; pl190_reset(s); /* ??? Save/restore. */ return qi; }
true
qemu
187337f8b0ec0813dd3876d1efe37d415fb81c2e
qemu_irq *pl190_init(uint32_t base, qemu_irq irq, qemu_irq fiq) { pl190_state *s; qemu_irq *qi; int iomemtype; s = (pl190_state *)qemu_mallocz(sizeof(pl190_state)); iomemtype = cpu_register_io_memory(0, pl190_readfn, pl190_writefn, s); cpu_register_physical_memory(base, 0x00000fff, iomemtype); qi = qemu_allocate_irqs(pl190_set_irq, s, 32); s->base = base; s->irq = irq; s->fiq = fiq; pl190_reset(s); return qi; }
{ "code": [ " cpu_register_physical_memory(base, 0x00000fff, iomemtype);", " cpu_register_physical_memory(base, 0x00000fff, iomemtype);", " cpu_register_physical_memory(base, 0x00000fff, iomemtype);", " cpu_register_physical_memory(base, 0x00000fff, iomemtype);", " cpu_register_physical_memory(base, 0x00000fff, iomemtype);", " cpu_register_physical_memory(base, 0x00000fff, iomemtype);", " cpu_register_physical_memory(base, 0x00000fff, iomemtype);", " cpu_register_physical_memory(base, 0x00000fff, iomemtype);", " cpu_register_physical_memory(base, 0x00000fff, iomemtype);", " cpu_register_physical_memory(base, 0x00000fff, iomemtype);", " cpu_register_physical_memory(base, 0x00000fff, iomemtype);", " cpu_register_physical_memory(base, 0x00000fff, iomemtype);" ], "line_no": [ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19 ] }
qemu_irq *FUNC_0(uint32_t base, qemu_irq irq, qemu_irq fiq) { pl190_state *s; qemu_irq *qi; int VAR_0; s = (pl190_state *)qemu_mallocz(sizeof(pl190_state)); VAR_0 = cpu_register_io_memory(0, pl190_readfn, pl190_writefn, s); cpu_register_physical_memory(base, 0x00000fff, VAR_0); qi = qemu_allocate_irqs(pl190_set_irq, s, 32); s->base = base; s->irq = irq; s->fiq = fiq; pl190_reset(s); return qi; }
[ "qemu_irq *FUNC_0(uint32_t base, qemu_irq irq, qemu_irq fiq)\n{", "pl190_state *s;", "qemu_irq *qi;", "int VAR_0;", "s = (pl190_state *)qemu_mallocz(sizeof(pl190_state));", "VAR_0 = cpu_register_io_memory(0, pl190_readfn,\npl190_writefn, s);", "cpu_register_physical_memory(base, 0x00000fff, VAR_0);", "qi = qemu_allocate_irqs(pl190_set_irq, s, 32);", "s->base = base;", "s->irq = irq;", "s->fiq = fiq;", "pl190_reset(s);", "return qi;", "}" ]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15, 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ] ]
11,372
static void pci_reg_write4(void *opaque, target_phys_addr_t addr, uint32_t value) { PPCE500PCIState *pci = opaque; unsigned long win; win = addr & 0xfe0; pci_debug("%s: value:%x -> win:%lx(addr:" TARGET_FMT_plx ")\n", __func__, value, win, addr); switch (win) { case PPCE500_PCI_OW1: case PPCE500_PCI_OW2: case PPCE500_PCI_OW3: case PPCE500_PCI_OW4: switch (addr & 0xC) { case PCI_POTAR: pci->pob[(addr >> 5) & 0x7].potar = value; break; case PCI_POTEAR: pci->pob[(addr >> 5) & 0x7].potear = value; break; case PCI_POWBAR: pci->pob[(addr >> 5) & 0x7].powbar = value; break; case PCI_POWAR: pci->pob[(addr >> 5) & 0x7].powar = value; break; default: break; }; break; case PPCE500_PCI_IW3: case PPCE500_PCI_IW2: case PPCE500_PCI_IW1: switch (addr & 0xC) { case PCI_PITAR: pci->pib[(addr >> 5) & 0x3].pitar = value; break; case PCI_PIWBAR: pci->pib[(addr >> 5) & 0x3].piwbar = value; break; case PCI_PIWBEAR: pci->pib[(addr >> 5) & 0x3].piwbear = value; break; case PCI_PIWAR: pci->pib[(addr >> 5) & 0x3].piwar = value; break; default: break; }; break; case PPCE500_PCI_GASKET_TIMR: pci->gasket_time = value; break; default: break; }; }
true
qemu
eeae2e7b52255dae0976a027b6e11274990c708d
static void pci_reg_write4(void *opaque, target_phys_addr_t addr, uint32_t value) { PPCE500PCIState *pci = opaque; unsigned long win; win = addr & 0xfe0; pci_debug("%s: value:%x -> win:%lx(addr:" TARGET_FMT_plx ")\n", __func__, value, win, addr); switch (win) { case PPCE500_PCI_OW1: case PPCE500_PCI_OW2: case PPCE500_PCI_OW3: case PPCE500_PCI_OW4: switch (addr & 0xC) { case PCI_POTAR: pci->pob[(addr >> 5) & 0x7].potar = value; break; case PCI_POTEAR: pci->pob[(addr >> 5) & 0x7].potear = value; break; case PCI_POWBAR: pci->pob[(addr >> 5) & 0x7].powbar = value; break; case PCI_POWAR: pci->pob[(addr >> 5) & 0x7].powar = value; break; default: break; }; break; case PPCE500_PCI_IW3: case PPCE500_PCI_IW2: case PPCE500_PCI_IW1: switch (addr & 0xC) { case PCI_PITAR: pci->pib[(addr >> 5) & 0x3].pitar = value; break; case PCI_PIWBAR: pci->pib[(addr >> 5) & 0x3].piwbar = value; break; case PCI_PIWBEAR: pci->pib[(addr >> 5) & 0x3].piwbear = value; break; case PCI_PIWAR: pci->pib[(addr >> 5) & 0x3].piwar = value; break; default: break; }; break; case PPCE500_PCI_GASKET_TIMR: pci->gasket_time = value; break; default: break; }; }
{ "code": [ " pci->pob[(addr >> 5) & 0x7].potar = value;", " pci->pob[(addr >> 5) & 0x7].potear = value;", " pci->pob[(addr >> 5) & 0x7].powbar = value;", " pci->pob[(addr >> 5) & 0x7].powar = value;", " pci->pib[(addr >> 5) & 0x3].pitar = value;", " pci->pib[(addr >> 5) & 0x3].piwbar = value;", " pci->pib[(addr >> 5) & 0x3].piwbear = value;", " pci->pib[(addr >> 5) & 0x3].piwar = value;" ], "line_no": [ 37, 43, 49, 55, 79, 85, 91, 97 ] }
static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint32_t VAR_2) { PPCE500PCIState *pci = VAR_0; unsigned long VAR_3; VAR_3 = VAR_1 & 0xfe0; pci_debug("%s: VAR_2:%x -> VAR_3:%lx(VAR_1:" TARGET_FMT_plx ")\n", __func__, VAR_2, VAR_3, VAR_1); switch (VAR_3) { case PPCE500_PCI_OW1: case PPCE500_PCI_OW2: case PPCE500_PCI_OW3: case PPCE500_PCI_OW4: switch (VAR_1 & 0xC) { case PCI_POTAR: pci->pob[(VAR_1 >> 5) & 0x7].potar = VAR_2; break; case PCI_POTEAR: pci->pob[(VAR_1 >> 5) & 0x7].potear = VAR_2; break; case PCI_POWBAR: pci->pob[(VAR_1 >> 5) & 0x7].powbar = VAR_2; break; case PCI_POWAR: pci->pob[(VAR_1 >> 5) & 0x7].powar = VAR_2; break; default: break; }; break; case PPCE500_PCI_IW3: case PPCE500_PCI_IW2: case PPCE500_PCI_IW1: switch (VAR_1 & 0xC) { case PCI_PITAR: pci->pib[(VAR_1 >> 5) & 0x3].pitar = VAR_2; break; case PCI_PIWBAR: pci->pib[(VAR_1 >> 5) & 0x3].piwbar = VAR_2; break; case PCI_PIWBEAR: pci->pib[(VAR_1 >> 5) & 0x3].piwbear = VAR_2; break; case PCI_PIWAR: pci->pib[(VAR_1 >> 5) & 0x3].piwar = VAR_2; break; default: break; }; break; case PPCE500_PCI_GASKET_TIMR: pci->gasket_time = VAR_2; break; default: break; }; }
[ "static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint32_t VAR_2)\n{", "PPCE500PCIState *pci = VAR_0;", "unsigned long VAR_3;", "VAR_3 = VAR_1 & 0xfe0;", "pci_debug(\"%s: VAR_2:%x -> VAR_3:%lx(VAR_1:\" TARGET_FMT_plx \")\\n\",\n__func__, VAR_2, VAR_3, VAR_1);", "switch (VAR_3) {", "case PPCE500_PCI_OW1:\ncase PPCE500_PCI_OW2:\ncase PPCE500_PCI_OW3:\ncase PPCE500_PCI_OW4:\nswitch (VAR_1 & 0xC) {", "case PCI_POTAR:\npci->pob[(VAR_1 >> 5) & 0x7].potar = VAR_2;", "break;", "case PCI_POTEAR:\npci->pob[(VAR_1 >> 5) & 0x7].potear = VAR_2;", "break;", "case PCI_POWBAR:\npci->pob[(VAR_1 >> 5) & 0x7].powbar = VAR_2;", "break;", "case PCI_POWAR:\npci->pob[(VAR_1 >> 5) & 0x7].powar = VAR_2;", "break;", "default:\nbreak;", "};", "break;", "case PPCE500_PCI_IW3:\ncase PPCE500_PCI_IW2:\ncase PPCE500_PCI_IW1:\nswitch (VAR_1 & 0xC) {", "case PCI_PITAR:\npci->pib[(VAR_1 >> 5) & 0x3].pitar = VAR_2;", "break;", "case PCI_PIWBAR:\npci->pib[(VAR_1 >> 5) & 0x3].piwbar = VAR_2;", "break;", "case PCI_PIWBEAR:\npci->pib[(VAR_1 >> 5) & 0x3].piwbear = VAR_2;", "break;", "case PCI_PIWAR:\npci->pib[(VAR_1 >> 5) & 0x3].piwar = VAR_2;", "break;", "default:\nbreak;", "};", "break;", "case PPCE500_PCI_GASKET_TIMR:\npci->gasket_time = VAR_2;", "break;", "default:\nbreak;", "};", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 17, 19 ], [ 23 ], [ 25, 27, 29, 31, 33 ], [ 35, 37 ], [ 39 ], [ 41, 43 ], [ 45 ], [ 47, 49 ], [ 51 ], [ 53, 55 ], [ 57 ], [ 59, 61 ], [ 63 ], [ 65 ], [ 69, 71, 73, 75 ], [ 77, 79 ], [ 81 ], [ 83, 85 ], [ 87 ], [ 89, 91 ], [ 93 ], [ 95, 97 ], [ 99 ], [ 101, 103 ], [ 105 ], [ 107 ], [ 111, 113 ], [ 115 ], [ 119, 121 ], [ 123 ], [ 125 ] ]
11,374
static TRBCCode xhci_address_slot(XHCIState *xhci, unsigned int slotid, uint64_t pictx, bool bsr) { XHCISlot *slot; USBPort *uport; USBDevice *dev; dma_addr_t ictx, octx, dcbaap; uint64_t poctx; uint32_t ictl_ctx[2]; uint32_t slot_ctx[4]; uint32_t ep0_ctx[5]; int i; TRBCCode res; assert(slotid >= 1 && slotid <= xhci->numslots); dcbaap = xhci_addr64(xhci->dcbaap_low, xhci->dcbaap_high); poctx = ldq_le_pci_dma(PCI_DEVICE(xhci), dcbaap + 8 * slotid); ictx = xhci_mask64(pictx); octx = xhci_mask64(poctx); DPRINTF("xhci: input context at "DMA_ADDR_FMT"\n", ictx); DPRINTF("xhci: output context at "DMA_ADDR_FMT"\n", octx); xhci_dma_read_u32s(xhci, ictx, ictl_ctx, sizeof(ictl_ctx)); if (ictl_ctx[0] != 0x0 || ictl_ctx[1] != 0x3) { fprintf(stderr, "xhci: invalid input context control %08x %08x\n", ictl_ctx[0], ictl_ctx[1]); return CC_TRB_ERROR; } xhci_dma_read_u32s(xhci, ictx+32, slot_ctx, sizeof(slot_ctx)); xhci_dma_read_u32s(xhci, ictx+64, ep0_ctx, sizeof(ep0_ctx)); DPRINTF("xhci: input slot context: %08x %08x %08x %08x\n", slot_ctx[0], slot_ctx[1], slot_ctx[2], slot_ctx[3]); DPRINTF("xhci: input ep0 context: %08x %08x %08x %08x %08x\n", ep0_ctx[0], ep0_ctx[1], ep0_ctx[2], ep0_ctx[3], ep0_ctx[4]); uport = xhci_lookup_uport(xhci, slot_ctx); if (uport == NULL) { fprintf(stderr, "xhci: port not found\n"); return CC_TRB_ERROR; } trace_usb_xhci_slot_address(slotid, uport->path); dev = uport->dev; if (!dev) { fprintf(stderr, "xhci: port %s not connected\n", uport->path); return CC_USB_TRANSACTION_ERROR; } for (i = 0; i < xhci->numslots; i++) { if (i == slotid-1) { continue; } if (xhci->slots[i].uport == uport) { fprintf(stderr, "xhci: port %s already assigned to slot %d\n", uport->path, i+1); return CC_TRB_ERROR; } } slot = &xhci->slots[slotid-1]; slot->uport = uport; slot->ctx = octx; if (bsr) { slot_ctx[3] = SLOT_DEFAULT << SLOT_STATE_SHIFT; } else { USBPacket p; uint8_t buf[1]; slot_ctx[3] = (SLOT_ADDRESSED << SLOT_STATE_SHIFT) | slotid; usb_device_reset(dev); memset(&p, 0, sizeof(p)); usb_packet_addbuf(&p, buf, sizeof(buf)); usb_packet_setup(&p, USB_TOKEN_OUT, usb_ep_get(dev, USB_TOKEN_OUT, 0), 0, 0, false, false); usb_device_handle_control(dev, &p, DeviceOutRequest | USB_REQ_SET_ADDRESS, slotid, 0, 0, NULL); assert(p.status != USB_RET_ASYNC); } res = xhci_enable_ep(xhci, slotid, 1, octx+32, ep0_ctx); DPRINTF("xhci: output slot context: %08x %08x %08x %08x\n", slot_ctx[0], slot_ctx[1], slot_ctx[2], slot_ctx[3]); DPRINTF("xhci: output ep0 context: %08x %08x %08x %08x %08x\n", ep0_ctx[0], ep0_ctx[1], ep0_ctx[2], ep0_ctx[3], ep0_ctx[4]); xhci_dma_write_u32s(xhci, octx, slot_ctx, sizeof(slot_ctx)); xhci_dma_write_u32s(xhci, octx+32, ep0_ctx, sizeof(ep0_ctx)); xhci->slots[slotid-1].addressed = 1; return res; }
true
qemu
de9de157fbb9aa66380ab1973dd6ecf12fbd8b25
static TRBCCode xhci_address_slot(XHCIState *xhci, unsigned int slotid, uint64_t pictx, bool bsr) { XHCISlot *slot; USBPort *uport; USBDevice *dev; dma_addr_t ictx, octx, dcbaap; uint64_t poctx; uint32_t ictl_ctx[2]; uint32_t slot_ctx[4]; uint32_t ep0_ctx[5]; int i; TRBCCode res; assert(slotid >= 1 && slotid <= xhci->numslots); dcbaap = xhci_addr64(xhci->dcbaap_low, xhci->dcbaap_high); poctx = ldq_le_pci_dma(PCI_DEVICE(xhci), dcbaap + 8 * slotid); ictx = xhci_mask64(pictx); octx = xhci_mask64(poctx); DPRINTF("xhci: input context at "DMA_ADDR_FMT"\n", ictx); DPRINTF("xhci: output context at "DMA_ADDR_FMT"\n", octx); xhci_dma_read_u32s(xhci, ictx, ictl_ctx, sizeof(ictl_ctx)); if (ictl_ctx[0] != 0x0 || ictl_ctx[1] != 0x3) { fprintf(stderr, "xhci: invalid input context control %08x %08x\n", ictl_ctx[0], ictl_ctx[1]); return CC_TRB_ERROR; } xhci_dma_read_u32s(xhci, ictx+32, slot_ctx, sizeof(slot_ctx)); xhci_dma_read_u32s(xhci, ictx+64, ep0_ctx, sizeof(ep0_ctx)); DPRINTF("xhci: input slot context: %08x %08x %08x %08x\n", slot_ctx[0], slot_ctx[1], slot_ctx[2], slot_ctx[3]); DPRINTF("xhci: input ep0 context: %08x %08x %08x %08x %08x\n", ep0_ctx[0], ep0_ctx[1], ep0_ctx[2], ep0_ctx[3], ep0_ctx[4]); uport = xhci_lookup_uport(xhci, slot_ctx); if (uport == NULL) { fprintf(stderr, "xhci: port not found\n"); return CC_TRB_ERROR; } trace_usb_xhci_slot_address(slotid, uport->path); dev = uport->dev; if (!dev) { fprintf(stderr, "xhci: port %s not connected\n", uport->path); return CC_USB_TRANSACTION_ERROR; } for (i = 0; i < xhci->numslots; i++) { if (i == slotid-1) { continue; } if (xhci->slots[i].uport == uport) { fprintf(stderr, "xhci: port %s already assigned to slot %d\n", uport->path, i+1); return CC_TRB_ERROR; } } slot = &xhci->slots[slotid-1]; slot->uport = uport; slot->ctx = octx; if (bsr) { slot_ctx[3] = SLOT_DEFAULT << SLOT_STATE_SHIFT; } else { USBPacket p; uint8_t buf[1]; slot_ctx[3] = (SLOT_ADDRESSED << SLOT_STATE_SHIFT) | slotid; usb_device_reset(dev); memset(&p, 0, sizeof(p)); usb_packet_addbuf(&p, buf, sizeof(buf)); usb_packet_setup(&p, USB_TOKEN_OUT, usb_ep_get(dev, USB_TOKEN_OUT, 0), 0, 0, false, false); usb_device_handle_control(dev, &p, DeviceOutRequest | USB_REQ_SET_ADDRESS, slotid, 0, 0, NULL); assert(p.status != USB_RET_ASYNC); } res = xhci_enable_ep(xhci, slotid, 1, octx+32, ep0_ctx); DPRINTF("xhci: output slot context: %08x %08x %08x %08x\n", slot_ctx[0], slot_ctx[1], slot_ctx[2], slot_ctx[3]); DPRINTF("xhci: output ep0 context: %08x %08x %08x %08x %08x\n", ep0_ctx[0], ep0_ctx[1], ep0_ctx[2], ep0_ctx[3], ep0_ctx[4]); xhci_dma_write_u32s(xhci, octx, slot_ctx, sizeof(slot_ctx)); xhci_dma_write_u32s(xhci, octx+32, ep0_ctx, sizeof(ep0_ctx)); xhci->slots[slotid-1].addressed = 1; return res; }
{ "code": [ " if (!dev) {" ], "line_no": [ 99 ] }
static TRBCCode FUNC_0(XHCIState *xhci, unsigned int slotid, uint64_t pictx, bool bsr) { XHCISlot *slot; USBPort *uport; USBDevice *dev; dma_addr_t ictx, octx, dcbaap; uint64_t poctx; uint32_t ictl_ctx[2]; uint32_t slot_ctx[4]; uint32_t ep0_ctx[5]; int VAR_0; TRBCCode res; assert(slotid >= 1 && slotid <= xhci->numslots); dcbaap = xhci_addr64(xhci->dcbaap_low, xhci->dcbaap_high); poctx = ldq_le_pci_dma(PCI_DEVICE(xhci), dcbaap + 8 * slotid); ictx = xhci_mask64(pictx); octx = xhci_mask64(poctx); DPRINTF("xhci: input context at "DMA_ADDR_FMT"\n", ictx); DPRINTF("xhci: output context at "DMA_ADDR_FMT"\n", octx); xhci_dma_read_u32s(xhci, ictx, ictl_ctx, sizeof(ictl_ctx)); if (ictl_ctx[0] != 0x0 || ictl_ctx[1] != 0x3) { fprintf(stderr, "xhci: invalid input context control %08x %08x\n", ictl_ctx[0], ictl_ctx[1]); return CC_TRB_ERROR; } xhci_dma_read_u32s(xhci, ictx+32, slot_ctx, sizeof(slot_ctx)); xhci_dma_read_u32s(xhci, ictx+64, ep0_ctx, sizeof(ep0_ctx)); DPRINTF("xhci: input slot context: %08x %08x %08x %08x\n", slot_ctx[0], slot_ctx[1], slot_ctx[2], slot_ctx[3]); DPRINTF("xhci: input ep0 context: %08x %08x %08x %08x %08x\n", ep0_ctx[0], ep0_ctx[1], ep0_ctx[2], ep0_ctx[3], ep0_ctx[4]); uport = xhci_lookup_uport(xhci, slot_ctx); if (uport == NULL) { fprintf(stderr, "xhci: port not found\n"); return CC_TRB_ERROR; } trace_usb_xhci_slot_address(slotid, uport->path); dev = uport->dev; if (!dev) { fprintf(stderr, "xhci: port %s not connected\n", uport->path); return CC_USB_TRANSACTION_ERROR; } for (VAR_0 = 0; VAR_0 < xhci->numslots; VAR_0++) { if (VAR_0 == slotid-1) { continue; } if (xhci->slots[VAR_0].uport == uport) { fprintf(stderr, "xhci: port %s already assigned to slot %d\n", uport->path, VAR_0+1); return CC_TRB_ERROR; } } slot = &xhci->slots[slotid-1]; slot->uport = uport; slot->ctx = octx; if (bsr) { slot_ctx[3] = SLOT_DEFAULT << SLOT_STATE_SHIFT; } else { USBPacket p; uint8_t buf[1]; slot_ctx[3] = (SLOT_ADDRESSED << SLOT_STATE_SHIFT) | slotid; usb_device_reset(dev); memset(&p, 0, sizeof(p)); usb_packet_addbuf(&p, buf, sizeof(buf)); usb_packet_setup(&p, USB_TOKEN_OUT, usb_ep_get(dev, USB_TOKEN_OUT, 0), 0, 0, false, false); usb_device_handle_control(dev, &p, DeviceOutRequest | USB_REQ_SET_ADDRESS, slotid, 0, 0, NULL); assert(p.status != USB_RET_ASYNC); } res = xhci_enable_ep(xhci, slotid, 1, octx+32, ep0_ctx); DPRINTF("xhci: output slot context: %08x %08x %08x %08x\n", slot_ctx[0], slot_ctx[1], slot_ctx[2], slot_ctx[3]); DPRINTF("xhci: output ep0 context: %08x %08x %08x %08x %08x\n", ep0_ctx[0], ep0_ctx[1], ep0_ctx[2], ep0_ctx[3], ep0_ctx[4]); xhci_dma_write_u32s(xhci, octx, slot_ctx, sizeof(slot_ctx)); xhci_dma_write_u32s(xhci, octx+32, ep0_ctx, sizeof(ep0_ctx)); xhci->slots[slotid-1].addressed = 1; return res; }
[ "static TRBCCode FUNC_0(XHCIState *xhci, unsigned int slotid,\nuint64_t pictx, bool bsr)\n{", "XHCISlot *slot;", "USBPort *uport;", "USBDevice *dev;", "dma_addr_t ictx, octx, dcbaap;", "uint64_t poctx;", "uint32_t ictl_ctx[2];", "uint32_t slot_ctx[4];", "uint32_t ep0_ctx[5];", "int VAR_0;", "TRBCCode res;", "assert(slotid >= 1 && slotid <= xhci->numslots);", "dcbaap = xhci_addr64(xhci->dcbaap_low, xhci->dcbaap_high);", "poctx = ldq_le_pci_dma(PCI_DEVICE(xhci), dcbaap + 8 * slotid);", "ictx = xhci_mask64(pictx);", "octx = xhci_mask64(poctx);", "DPRINTF(\"xhci: input context at \"DMA_ADDR_FMT\"\\n\", ictx);", "DPRINTF(\"xhci: output context at \"DMA_ADDR_FMT\"\\n\", octx);", "xhci_dma_read_u32s(xhci, ictx, ictl_ctx, sizeof(ictl_ctx));", "if (ictl_ctx[0] != 0x0 || ictl_ctx[1] != 0x3) {", "fprintf(stderr, \"xhci: invalid input context control %08x %08x\\n\",\nictl_ctx[0], ictl_ctx[1]);", "return CC_TRB_ERROR;", "}", "xhci_dma_read_u32s(xhci, ictx+32, slot_ctx, sizeof(slot_ctx));", "xhci_dma_read_u32s(xhci, ictx+64, ep0_ctx, sizeof(ep0_ctx));", "DPRINTF(\"xhci: input slot context: %08x %08x %08x %08x\\n\",\nslot_ctx[0], slot_ctx[1], slot_ctx[2], slot_ctx[3]);", "DPRINTF(\"xhci: input ep0 context: %08x %08x %08x %08x %08x\\n\",\nep0_ctx[0], ep0_ctx[1], ep0_ctx[2], ep0_ctx[3], ep0_ctx[4]);", "uport = xhci_lookup_uport(xhci, slot_ctx);", "if (uport == NULL) {", "fprintf(stderr, \"xhci: port not found\\n\");", "return CC_TRB_ERROR;", "}", "trace_usb_xhci_slot_address(slotid, uport->path);", "dev = uport->dev;", "if (!dev) {", "fprintf(stderr, \"xhci: port %s not connected\\n\", uport->path);", "return CC_USB_TRANSACTION_ERROR;", "}", "for (VAR_0 = 0; VAR_0 < xhci->numslots; VAR_0++) {", "if (VAR_0 == slotid-1) {", "continue;", "}", "if (xhci->slots[VAR_0].uport == uport) {", "fprintf(stderr, \"xhci: port %s already assigned to slot %d\\n\",\nuport->path, VAR_0+1);", "return CC_TRB_ERROR;", "}", "}", "slot = &xhci->slots[slotid-1];", "slot->uport = uport;", "slot->ctx = octx;", "if (bsr) {", "slot_ctx[3] = SLOT_DEFAULT << SLOT_STATE_SHIFT;", "} else {", "USBPacket p;", "uint8_t buf[1];", "slot_ctx[3] = (SLOT_ADDRESSED << SLOT_STATE_SHIFT) | slotid;", "usb_device_reset(dev);", "memset(&p, 0, sizeof(p));", "usb_packet_addbuf(&p, buf, sizeof(buf));", "usb_packet_setup(&p, USB_TOKEN_OUT,\nusb_ep_get(dev, USB_TOKEN_OUT, 0), 0,\n0, false, false);", "usb_device_handle_control(dev, &p,\nDeviceOutRequest | USB_REQ_SET_ADDRESS,\nslotid, 0, 0, NULL);", "assert(p.status != USB_RET_ASYNC);", "}", "res = xhci_enable_ep(xhci, slotid, 1, octx+32, ep0_ctx);", "DPRINTF(\"xhci: output slot context: %08x %08x %08x %08x\\n\",\nslot_ctx[0], slot_ctx[1], slot_ctx[2], slot_ctx[3]);", "DPRINTF(\"xhci: output ep0 context: %08x %08x %08x %08x %08x\\n\",\nep0_ctx[0], ep0_ctx[1], ep0_ctx[2], ep0_ctx[3], ep0_ctx[4]);", "xhci_dma_write_u32s(xhci, octx, slot_ctx, sizeof(slot_ctx));", "xhci_dma_write_u32s(xhci, octx+32, ep0_ctx, sizeof(ep0_ctx));", "xhci->slots[slotid-1].addressed = 1;", "return res;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 49 ], [ 53 ], [ 55, 57 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 71, 73 ], [ 77, 79 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119, 121 ], [ 123 ], [ 125 ], [ 127 ], [ 131 ], [ 133 ], [ 135 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159, 161, 163 ], [ 165, 167, 169 ], [ 171 ], [ 173 ], [ 177 ], [ 181, 183 ], [ 185, 187 ], [ 191 ], [ 193 ], [ 197 ], [ 199 ], [ 201 ] ]
11,375
static void encode_frame(MpegAudioContext *s, unsigned char bit_alloc[MPA_MAX_CHANNELS][SBLIMIT], int padding) { int i, j, k, l, bit_alloc_bits, b, ch; unsigned char *sf; int q[3]; PutBitContext *p = &s->pb; /* header */ put_bits(p, 12, 0xfff); put_bits(p, 1, 1 - s->lsf); /* 1 = mpeg1 ID, 0 = mpeg2 lsf ID */ put_bits(p, 2, 4-2); /* layer 2 */ put_bits(p, 1, 1); /* no error protection */ put_bits(p, 4, s->bitrate_index); put_bits(p, 2, s->freq_index); put_bits(p, 1, s->do_padding); /* use padding */ put_bits(p, 1, 0); /* private_bit */ put_bits(p, 2, s->nb_channels == 2 ? MPA_STEREO : MPA_MONO); put_bits(p, 2, 0); /* mode_ext */ put_bits(p, 1, 0); /* no copyright */ put_bits(p, 1, 1); /* original */ put_bits(p, 2, 0); /* no emphasis */ /* bit allocation */ j = 0; for(i=0;i<s->sblimit;i++) { bit_alloc_bits = s->alloc_table[j]; for(ch=0;ch<s->nb_channels;ch++) { put_bits(p, bit_alloc_bits, bit_alloc[ch][i]); } j += 1 << bit_alloc_bits; } /* scale codes */ for(i=0;i<s->sblimit;i++) { for(ch=0;ch<s->nb_channels;ch++) { if (bit_alloc[ch][i]) put_bits(p, 2, s->scale_code[ch][i]); } } /* scale factors */ for(i=0;i<s->sblimit;i++) { for(ch=0;ch<s->nb_channels;ch++) { if (bit_alloc[ch][i]) { sf = &s->scale_factors[ch][i][0]; switch(s->scale_code[ch][i]) { case 0: put_bits(p, 6, sf[0]); put_bits(p, 6, sf[1]); put_bits(p, 6, sf[2]); break; case 3: case 1: put_bits(p, 6, sf[0]); put_bits(p, 6, sf[2]); break; case 2: put_bits(p, 6, sf[0]); break; } } } } /* quantization & write sub band samples */ for(k=0;k<3;k++) { for(l=0;l<12;l+=3) { j = 0; for(i=0;i<s->sblimit;i++) { bit_alloc_bits = s->alloc_table[j]; for(ch=0;ch<s->nb_channels;ch++) { b = bit_alloc[ch][i]; if (b) { int qindex, steps, m, sample, bits; /* we encode 3 sub band samples of the same sub band at a time */ qindex = s->alloc_table[j+b]; steps = ff_mpa_quant_steps[qindex]; for(m=0;m<3;m++) { sample = s->sb_samples[ch][k][l + m][i]; /* divide by scale factor */ #if USE_FLOATS { float a; a = (float)sample * s->scale_factor_inv_table[s->scale_factors[ch][i][k]]; q[m] = (int)((a + 1.0) * steps * 0.5); } #else { int q1, e, shift, mult; e = s->scale_factors[ch][i][k]; shift = s->scale_factor_shift[e]; mult = s->scale_factor_mult[e]; /* normalize to P bits */ if (shift < 0) q1 = sample << (-shift); else q1 = sample >> shift; q1 = (q1 * mult) >> P; q1 += 1 << P; if (q1 < 0) q1 = 0; q[m] = (unsigned)(q1 * steps) >> (P + 1); } #endif if (q[m] >= steps) q[m] = steps - 1; av_assert2(q[m] >= 0 && q[m] < steps); } bits = ff_mpa_quant_bits[qindex]; if (bits < 0) { /* group the 3 values to save bits */ put_bits(p, -bits, q[0] + steps * (q[1] + steps * q[2])); } else { put_bits(p, bits, q[0]); put_bits(p, bits, q[1]); put_bits(p, bits, q[2]); } } } /* next subband in alloc table */ j += 1 << bit_alloc_bits; } } } /* padding */ for(i=0;i<padding;i++) put_bits(p, 1, 0); /* flush */ flush_put_bits(p); }
true
FFmpeg
c6902f96d75b9786ddc1404c14349d6a22b7ed05
static void encode_frame(MpegAudioContext *s, unsigned char bit_alloc[MPA_MAX_CHANNELS][SBLIMIT], int padding) { int i, j, k, l, bit_alloc_bits, b, ch; unsigned char *sf; int q[3]; PutBitContext *p = &s->pb; put_bits(p, 12, 0xfff); put_bits(p, 1, 1 - s->lsf); put_bits(p, 2, 4-2); put_bits(p, 1, 1); put_bits(p, 4, s->bitrate_index); put_bits(p, 2, s->freq_index); put_bits(p, 1, s->do_padding); put_bits(p, 1, 0); put_bits(p, 2, s->nb_channels == 2 ? MPA_STEREO : MPA_MONO); put_bits(p, 2, 0); put_bits(p, 1, 0); put_bits(p, 1, 1); put_bits(p, 2, 0); j = 0; for(i=0;i<s->sblimit;i++) { bit_alloc_bits = s->alloc_table[j]; for(ch=0;ch<s->nb_channels;ch++) { put_bits(p, bit_alloc_bits, bit_alloc[ch][i]); } j += 1 << bit_alloc_bits; } for(i=0;i<s->sblimit;i++) { for(ch=0;ch<s->nb_channels;ch++) { if (bit_alloc[ch][i]) put_bits(p, 2, s->scale_code[ch][i]); } } for(i=0;i<s->sblimit;i++) { for(ch=0;ch<s->nb_channels;ch++) { if (bit_alloc[ch][i]) { sf = &s->scale_factors[ch][i][0]; switch(s->scale_code[ch][i]) { case 0: put_bits(p, 6, sf[0]); put_bits(p, 6, sf[1]); put_bits(p, 6, sf[2]); break; case 3: case 1: put_bits(p, 6, sf[0]); put_bits(p, 6, sf[2]); break; case 2: put_bits(p, 6, sf[0]); break; } } } } for(k=0;k<3;k++) { for(l=0;l<12;l+=3) { j = 0; for(i=0;i<s->sblimit;i++) { bit_alloc_bits = s->alloc_table[j]; for(ch=0;ch<s->nb_channels;ch++) { b = bit_alloc[ch][i]; if (b) { int qindex, steps, m, sample, bits; qindex = s->alloc_table[j+b]; steps = ff_mpa_quant_steps[qindex]; for(m=0;m<3;m++) { sample = s->sb_samples[ch][k][l + m][i]; #if USE_FLOATS { float a; a = (float)sample * s->scale_factor_inv_table[s->scale_factors[ch][i][k]]; q[m] = (int)((a + 1.0) * steps * 0.5); } #else { int q1, e, shift, mult; e = s->scale_factors[ch][i][k]; shift = s->scale_factor_shift[e]; mult = s->scale_factor_mult[e]; if (shift < 0) q1 = sample << (-shift); else q1 = sample >> shift; q1 = (q1 * mult) >> P; q1 += 1 << P; if (q1 < 0) q1 = 0; q[m] = (unsigned)(q1 * steps) >> (P + 1); } #endif if (q[m] >= steps) q[m] = steps - 1; av_assert2(q[m] >= 0 && q[m] < steps); } bits = ff_mpa_quant_bits[qindex]; if (bits < 0) { put_bits(p, -bits, q[0] + steps * (q[1] + steps * q[2])); } else { put_bits(p, bits, q[0]); put_bits(p, bits, q[1]); put_bits(p, bits, q[2]); } } } j += 1 << bit_alloc_bits; } } } for(i=0;i<padding;i++) put_bits(p, 1, 0); flush_put_bits(p); }
{ "code": [ " q[m] = (unsigned)(q1 * steps) >> (P + 1);" ], "line_no": [ 213 ] }
static void FUNC_0(MpegAudioContext *VAR_0, unsigned char VAR_1[MPA_MAX_CHANNELS][SBLIMIT], int VAR_2) { int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9; unsigned char *VAR_10; int VAR_11[3]; PutBitContext *p = &VAR_0->pb; put_bits(p, 12, 0xfff); put_bits(p, 1, 1 - VAR_0->lsf); put_bits(p, 2, 4-2); put_bits(p, 1, 1); put_bits(p, 4, VAR_0->bitrate_index); put_bits(p, 2, VAR_0->freq_index); put_bits(p, 1, VAR_0->do_padding); put_bits(p, 1, 0); put_bits(p, 2, VAR_0->nb_channels == 2 ? MPA_STEREO : MPA_MONO); put_bits(p, 2, 0); put_bits(p, 1, 0); put_bits(p, 1, 1); put_bits(p, 2, 0); VAR_4 = 0; for(VAR_3=0;VAR_3<VAR_0->sblimit;VAR_3++) { VAR_7 = VAR_0->alloc_table[VAR_4]; for(VAR_9=0;VAR_9<VAR_0->nb_channels;VAR_9++) { put_bits(p, VAR_7, VAR_1[VAR_9][VAR_3]); } VAR_4 += 1 << VAR_7; } for(VAR_3=0;VAR_3<VAR_0->sblimit;VAR_3++) { for(VAR_9=0;VAR_9<VAR_0->nb_channels;VAR_9++) { if (VAR_1[VAR_9][VAR_3]) put_bits(p, 2, VAR_0->scale_code[VAR_9][VAR_3]); } } for(VAR_3=0;VAR_3<VAR_0->sblimit;VAR_3++) { for(VAR_9=0;VAR_9<VAR_0->nb_channels;VAR_9++) { if (VAR_1[VAR_9][VAR_3]) { VAR_10 = &VAR_0->scale_factors[VAR_9][VAR_3][0]; switch(VAR_0->scale_code[VAR_9][VAR_3]) { case 0: put_bits(p, 6, VAR_10[0]); put_bits(p, 6, VAR_10[1]); put_bits(p, 6, VAR_10[2]); break; case 3: case 1: put_bits(p, 6, VAR_10[0]); put_bits(p, 6, VAR_10[2]); break; case 2: put_bits(p, 6, VAR_10[0]); break; } } } } for(VAR_5=0;VAR_5<3;VAR_5++) { for(VAR_6=0;VAR_6<12;VAR_6+=3) { VAR_4 = 0; for(VAR_3=0;VAR_3<VAR_0->sblimit;VAR_3++) { VAR_7 = VAR_0->alloc_table[VAR_4]; for(VAR_9=0;VAR_9<VAR_0->nb_channels;VAR_9++) { VAR_8 = VAR_1[VAR_9][VAR_3]; if (VAR_8) { int qindex, steps, m, sample, bits; qindex = VAR_0->alloc_table[VAR_4+VAR_8]; steps = ff_mpa_quant_steps[qindex]; for(m=0;m<3;m++) { sample = VAR_0->sb_samples[VAR_9][VAR_5][VAR_6 + m][VAR_3]; #if USE_FLOATS { float a; a = (float)sample * VAR_0->scale_factor_inv_table[VAR_0->scale_factors[VAR_9][VAR_3][VAR_5]]; VAR_11[m] = (int)((a + 1.0) * steps * 0.5); } #else { int q1, e, shift, mult; e = VAR_0->scale_factors[VAR_9][VAR_3][VAR_5]; shift = VAR_0->scale_factor_shift[e]; mult = VAR_0->scale_factor_mult[e]; if (shift < 0) q1 = sample << (-shift); else q1 = sample >> shift; q1 = (q1 * mult) >> P; q1 += 1 << P; if (q1 < 0) q1 = 0; VAR_11[m] = (unsigned)(q1 * steps) >> (P + 1); } #endif if (VAR_11[m] >= steps) VAR_11[m] = steps - 1; av_assert2(VAR_11[m] >= 0 && VAR_11[m] < steps); } bits = ff_mpa_quant_bits[qindex]; if (bits < 0) { put_bits(p, -bits, VAR_11[0] + steps * (VAR_11[1] + steps * VAR_11[2])); } else { put_bits(p, bits, VAR_11[0]); put_bits(p, bits, VAR_11[1]); put_bits(p, bits, VAR_11[2]); } } } VAR_4 += 1 << VAR_7; } } } for(VAR_3=0;VAR_3<VAR_2;VAR_3++) put_bits(p, 1, 0); flush_put_bits(p); }
[ "static void FUNC_0(MpegAudioContext *VAR_0,\nunsigned char VAR_1[MPA_MAX_CHANNELS][SBLIMIT],\nint VAR_2)\n{", "int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;", "unsigned char *VAR_10;", "int VAR_11[3];", "PutBitContext *p = &VAR_0->pb;", "put_bits(p, 12, 0xfff);", "put_bits(p, 1, 1 - VAR_0->lsf);", "put_bits(p, 2, 4-2);", "put_bits(p, 1, 1);", "put_bits(p, 4, VAR_0->bitrate_index);", "put_bits(p, 2, VAR_0->freq_index);", "put_bits(p, 1, VAR_0->do_padding);", "put_bits(p, 1, 0);", "put_bits(p, 2, VAR_0->nb_channels == 2 ? MPA_STEREO : MPA_MONO);", "put_bits(p, 2, 0);", "put_bits(p, 1, 0);", "put_bits(p, 1, 1);", "put_bits(p, 2, 0);", "VAR_4 = 0;", "for(VAR_3=0;VAR_3<VAR_0->sblimit;VAR_3++) {", "VAR_7 = VAR_0->alloc_table[VAR_4];", "for(VAR_9=0;VAR_9<VAR_0->nb_channels;VAR_9++) {", "put_bits(p, VAR_7, VAR_1[VAR_9][VAR_3]);", "}", "VAR_4 += 1 << VAR_7;", "}", "for(VAR_3=0;VAR_3<VAR_0->sblimit;VAR_3++) {", "for(VAR_9=0;VAR_9<VAR_0->nb_channels;VAR_9++) {", "if (VAR_1[VAR_9][VAR_3])\nput_bits(p, 2, VAR_0->scale_code[VAR_9][VAR_3]);", "}", "}", "for(VAR_3=0;VAR_3<VAR_0->sblimit;VAR_3++) {", "for(VAR_9=0;VAR_9<VAR_0->nb_channels;VAR_9++) {", "if (VAR_1[VAR_9][VAR_3]) {", "VAR_10 = &VAR_0->scale_factors[VAR_9][VAR_3][0];", "switch(VAR_0->scale_code[VAR_9][VAR_3]) {", "case 0:\nput_bits(p, 6, VAR_10[0]);", "put_bits(p, 6, VAR_10[1]);", "put_bits(p, 6, VAR_10[2]);", "break;", "case 3:\ncase 1:\nput_bits(p, 6, VAR_10[0]);", "put_bits(p, 6, VAR_10[2]);", "break;", "case 2:\nput_bits(p, 6, VAR_10[0]);", "break;", "}", "}", "}", "}", "for(VAR_5=0;VAR_5<3;VAR_5++) {", "for(VAR_6=0;VAR_6<12;VAR_6+=3) {", "VAR_4 = 0;", "for(VAR_3=0;VAR_3<VAR_0->sblimit;VAR_3++) {", "VAR_7 = VAR_0->alloc_table[VAR_4];", "for(VAR_9=0;VAR_9<VAR_0->nb_channels;VAR_9++) {", "VAR_8 = VAR_1[VAR_9][VAR_3];", "if (VAR_8) {", "int qindex, steps, m, sample, bits;", "qindex = VAR_0->alloc_table[VAR_4+VAR_8];", "steps = ff_mpa_quant_steps[qindex];", "for(m=0;m<3;m++) {", "sample = VAR_0->sb_samples[VAR_9][VAR_5][VAR_6 + m][VAR_3];", "#if USE_FLOATS\n{", "float a;", "a = (float)sample * VAR_0->scale_factor_inv_table[VAR_0->scale_factors[VAR_9][VAR_3][VAR_5]];", "VAR_11[m] = (int)((a + 1.0) * steps * 0.5);", "}", "#else\n{", "int q1, e, shift, mult;", "e = VAR_0->scale_factors[VAR_9][VAR_3][VAR_5];", "shift = VAR_0->scale_factor_shift[e];", "mult = VAR_0->scale_factor_mult[e];", "if (shift < 0)\nq1 = sample << (-shift);", "else\nq1 = sample >> shift;", "q1 = (q1 * mult) >> P;", "q1 += 1 << P;", "if (q1 < 0)\nq1 = 0;", "VAR_11[m] = (unsigned)(q1 * steps) >> (P + 1);", "}", "#endif\nif (VAR_11[m] >= steps)\nVAR_11[m] = steps - 1;", "av_assert2(VAR_11[m] >= 0 && VAR_11[m] < steps);", "}", "bits = ff_mpa_quant_bits[qindex];", "if (bits < 0) {", "put_bits(p, -bits,\nVAR_11[0] + steps * (VAR_11[1] + steps * VAR_11[2]));", "} else {", "put_bits(p, bits, VAR_11[0]);", "put_bits(p, bits, VAR_11[1]);", "put_bits(p, bits, VAR_11[2]);", "}", "}", "}", "VAR_4 += 1 << VAR_7;", "}", "}", "}", "for(VAR_3=0;VAR_3<VAR_2;VAR_3++)", "put_bits(p, 1, 0);", "flush_put_bits(p);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 73 ], [ 75 ], [ 77, 79 ], [ 81 ], [ 83 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99, 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109, 111, 113 ], [ 115 ], [ 117 ], [ 119, 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 169, 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181, 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 197, 199 ], [ 201, 203 ], [ 205 ], [ 207 ], [ 209, 211 ], [ 213 ], [ 215 ], [ 217, 219, 221 ], [ 223 ], [ 225 ], [ 227 ], [ 229 ], [ 233, 235 ], [ 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ], [ 265 ], [ 267 ], [ 273 ], [ 275 ] ]
11,376
static int quantize_coefs(double *coef, int *idx, float *lpc, int order) { int i; uint8_t u_coef; const float *quant_arr = tns_tmp2_map[TNS_Q_BITS == 4]; const double iqfac_p = ((1 << (TNS_Q_BITS-1)) - 0.5)/(M_PI/2.0); const double iqfac_m = ((1 << (TNS_Q_BITS-1)) + 0.5)/(M_PI/2.0); for (i = 0; i < order; i++) { idx[i] = ceilf(asin(coef[i])*((coef[i] >= 0) ? iqfac_p : iqfac_m)); u_coef = (idx[i])&(~(~0<<TNS_Q_BITS)); lpc[i] = quant_arr[u_coef]; } return order; }
false
FFmpeg
e3faad811e429002d549562db4e0fc30c08dc6a4
static int quantize_coefs(double *coef, int *idx, float *lpc, int order) { int i; uint8_t u_coef; const float *quant_arr = tns_tmp2_map[TNS_Q_BITS == 4]; const double iqfac_p = ((1 << (TNS_Q_BITS-1)) - 0.5)/(M_PI/2.0); const double iqfac_m = ((1 << (TNS_Q_BITS-1)) + 0.5)/(M_PI/2.0); for (i = 0; i < order; i++) { idx[i] = ceilf(asin(coef[i])*((coef[i] >= 0) ? iqfac_p : iqfac_m)); u_coef = (idx[i])&(~(~0<<TNS_Q_BITS)); lpc[i] = quant_arr[u_coef]; } return order; }
{ "code": [], "line_no": [] }
static int FUNC_0(double *VAR_0, int *VAR_1, float *VAR_2, int VAR_3) { int VAR_4; uint8_t u_coef; const float *VAR_5 = tns_tmp2_map[TNS_Q_BITS == 4]; const double VAR_6 = ((1 << (TNS_Q_BITS-1)) - 0.5)/(M_PI/2.0); const double VAR_7 = ((1 << (TNS_Q_BITS-1)) + 0.5)/(M_PI/2.0); for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) { VAR_1[VAR_4] = ceilf(asin(VAR_0[VAR_4])*((VAR_0[VAR_4] >= 0) ? VAR_6 : VAR_7)); u_coef = (VAR_1[VAR_4])&(~(~0<<TNS_Q_BITS)); VAR_2[VAR_4] = VAR_5[u_coef]; } return VAR_3; }
[ "static int FUNC_0(double *VAR_0, int *VAR_1, float *VAR_2, int VAR_3)\n{", "int VAR_4;", "uint8_t u_coef;", "const float *VAR_5 = tns_tmp2_map[TNS_Q_BITS == 4];", "const double VAR_6 = ((1 << (TNS_Q_BITS-1)) - 0.5)/(M_PI/2.0);", "const double VAR_7 = ((1 << (TNS_Q_BITS-1)) + 0.5)/(M_PI/2.0);", "for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) {", "VAR_1[VAR_4] = ceilf(asin(VAR_0[VAR_4])*((VAR_0[VAR_4] >= 0) ? VAR_6 : VAR_7));", "u_coef = (VAR_1[VAR_4])&(~(~0<<TNS_Q_BITS));", "VAR_2[VAR_4] = VAR_5[u_coef];", "}", "return VAR_3;", "}" ]
[ 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 ] ]
11,377
static int get_int16(QEMUFile *f, void *pv, size_t size) { int16_t *v = pv; qemu_get_sbe16s(f, v); return 0; }
true
qemu
60fe637bf0e4d7989e21e50f52526444765c63b4
static int get_int16(QEMUFile *f, void *pv, size_t size) { int16_t *v = pv; qemu_get_sbe16s(f, v); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2) { int16_t *v = VAR_1; qemu_get_sbe16s(VAR_0, v); return 0; }
[ "static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2)\n{", "int16_t *v = VAR_1;", "qemu_get_sbe16s(VAR_0, v);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ] ]
11,378
static void compress_to_network(RDMACompress *comp) { comp->value = htonl(comp->value); comp->block_idx = htonl(comp->block_idx); comp->offset = htonll(comp->offset); comp->length = htonll(comp->length); }
true
qemu
60fe637bf0e4d7989e21e50f52526444765c63b4
static void compress_to_network(RDMACompress *comp) { comp->value = htonl(comp->value); comp->block_idx = htonl(comp->block_idx); comp->offset = htonll(comp->offset); comp->length = htonll(comp->length); }
{ "code": [], "line_no": [] }
static void FUNC_0(RDMACompress *VAR_0) { VAR_0->value = htonl(VAR_0->value); VAR_0->block_idx = htonl(VAR_0->block_idx); VAR_0->offset = htonll(VAR_0->offset); VAR_0->length = htonll(VAR_0->length); }
[ "static void FUNC_0(RDMACompress *VAR_0)\n{", "VAR_0->value = htonl(VAR_0->value);", "VAR_0->block_idx = htonl(VAR_0->block_idx);", "VAR_0->offset = htonll(VAR_0->offset);", "VAR_0->length = htonll(VAR_0->length);", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ] ]
11,379
int avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter) { graph->filters = av_realloc(graph->filters, sizeof(AVFilterContext*) * ++graph->filter_count); if (!graph->filters) return AVERROR(ENOMEM); graph->filters[graph->filter_count - 1] = filter; return 0; }
true
FFmpeg
3748b2b8e8bcedba2de7fe826c4094169a885840
int avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter) { graph->filters = av_realloc(graph->filters, sizeof(AVFilterContext*) * ++graph->filter_count); if (!graph->filters) return AVERROR(ENOMEM); graph->filters[graph->filter_count - 1] = filter; return 0; }
{ "code": [ " graph->filters = av_realloc(graph->filters,", " sizeof(AVFilterContext*) * ++graph->filter_count);", " if (!graph->filters)", " graph->filters[graph->filter_count - 1] = filter;" ], "line_no": [ 5, 7, 11, 17 ] }
int FUNC_0(AVFilterGraph *VAR_0, AVFilterContext *VAR_1) { VAR_0->filters = av_realloc(VAR_0->filters, sizeof(AVFilterContext*) * ++VAR_0->filter_count); if (!VAR_0->filters) return AVERROR(ENOMEM); VAR_0->filters[VAR_0->filter_count - 1] = VAR_1; return 0; }
[ "int FUNC_0(AVFilterGraph *VAR_0, AVFilterContext *VAR_1)\n{", "VAR_0->filters = av_realloc(VAR_0->filters,\nsizeof(AVFilterContext*) * ++VAR_0->filter_count);", "if (!VAR_0->filters)\nreturn AVERROR(ENOMEM);", "VAR_0->filters[VAR_0->filter_count - 1] = VAR_1;", "return 0;", "}" ]
[ 0, 1, 1, 1, 0, 0 ]
[ [ 1, 3 ], [ 5, 7 ], [ 11, 13 ], [ 17 ], [ 21 ], [ 23 ] ]
11,380
av_cold int ff_rate_control_init(MpegEncContext *s) { RateControlContext *rcc = &s->rc_context; int i, res; static const char * const const_names[] = { "PI", "E", "iTex", "pTex", "tex", "mv", "fCode", "iCount", "mcVar", "var", "isI", "isP", "isB", "avgQP", "qComp", #if 0 "lastIQP", "lastPQP", "lastBQP", "nextNonBQP", #endif "avgIITex", "avgPITex", "avgPPTex", "avgBPTex", "avgTex", NULL }; static double (* const func1[])(void *, double) = { (void *)bits2qp, (void *)qp2bits, NULL }; static const char * const func1_names[] = { "bits2qp", "qp2bits", NULL }; emms_c(); if (!s->avctx->rc_max_available_vbv_use && s->avctx->rc_buffer_size) { if (s->avctx->rc_max_rate) { s->avctx->rc_max_available_vbv_use = av_clipf(s->avctx->rc_max_rate/(s->avctx->rc_buffer_size*get_fps(s->avctx)), 1.0/3, 1.0); } else s->avctx->rc_max_available_vbv_use = 1.0; } res = av_expr_parse(&rcc->rc_eq_eval, s->rc_eq ? s->rc_eq : "tex^qComp", const_names, func1_names, func1, NULL, NULL, 0, s->avctx); if (res < 0) { av_log(s->avctx, AV_LOG_ERROR, "Error parsing rc_eq \"%s\"\n", s->rc_eq); return res; } for (i = 0; i < 5; i++) { rcc->pred[i].coeff = FF_QP2LAMBDA * 7.0; rcc->pred[i].count = 1.0; rcc->pred[i].decay = 0.4; rcc->i_cplx_sum [i] = rcc->p_cplx_sum [i] = rcc->mv_bits_sum[i] = rcc->qscale_sum [i] = rcc->frame_count[i] = 1; // 1 is better because of 1/0 and such rcc->last_qscale_for[i] = FF_QP2LAMBDA * 5; } rcc->buffer_index = s->avctx->rc_initial_buffer_occupancy; if (!rcc->buffer_index) rcc->buffer_index = s->avctx->rc_buffer_size * 3 / 4; if (s->flags & CODEC_FLAG_PASS2) { int i; char *p; /* find number of pics */ p = s->avctx->stats_in; for (i = -1; p; i++) p = strchr(p + 1, ';'); i += s->max_b_frames; if (i <= 0 || i >= INT_MAX / sizeof(RateControlEntry)) return -1; rcc->entry = av_mallocz(i * sizeof(RateControlEntry)); rcc->num_entries = i; /* init all to skipped p frames * (with b frames we might have a not encoded frame at the end FIXME) */ for (i = 0; i < rcc->num_entries; i++) { RateControlEntry *rce = &rcc->entry[i]; rce->pict_type = rce->new_pict_type = AV_PICTURE_TYPE_P; rce->qscale = rce->new_qscale = FF_QP2LAMBDA * 2; rce->misc_bits = s->mb_num + 10; rce->mb_var_sum = s->mb_num * 100; } /* read stats */ p = s->avctx->stats_in; for (i = 0; i < rcc->num_entries - s->max_b_frames; i++) { RateControlEntry *rce; int picture_number; int e; char *next; next = strchr(p, ';'); if (next) { (*next) = 0; // sscanf in unbelievably slow on looong strings // FIXME copy / do not write next++; } e = sscanf(p, " in:%d ", &picture_number); assert(picture_number >= 0); assert(picture_number < rcc->num_entries); rce = &rcc->entry[picture_number]; e += sscanf(p, " in:%*d out:%*d type:%d q:%f itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%"SCNd64" var:%"SCNd64" icount:%d skipcount:%d hbits:%d", &rce->pict_type, &rce->qscale, &rce->i_tex_bits, &rce->p_tex_bits, &rce->mv_bits, &rce->misc_bits, &rce->f_code, &rce->b_code, &rce->mc_mb_var_sum, &rce->mb_var_sum, &rce->i_count, &rce->skip_count, &rce->header_bits); if (e != 14) { av_log(s->avctx, AV_LOG_ERROR, "statistics are damaged at line %d, parser out=%d\n", i, e); return -1; } p = next; } if (init_pass2(s) < 0) return -1; // FIXME maybe move to end if ((s->flags & CODEC_FLAG_PASS2) && s->avctx->rc_strategy == FF_RC_STRATEGY_XVID) { #if CONFIG_LIBXVID return ff_xvid_rate_control_init(s); #else av_log(s->avctx, AV_LOG_ERROR, "Xvid ratecontrol requires libavcodec compiled with Xvid support.\n"); return -1; #endif } } if (!(s->flags & CODEC_FLAG_PASS2)) { rcc->short_term_qsum = 0.001; rcc->short_term_qcount = 0.001; rcc->pass1_rc_eq_output_sum = 0.001; rcc->pass1_wanted_bits = 0.001; if (s->avctx->qblur > 1.0) { av_log(s->avctx, AV_LOG_ERROR, "qblur too large\n"); return -1; } /* init stuff with the user specified complexity */ if (s->rc_initial_cplx) { for (i = 0; i < 60 * 30; i++) { double bits = s->rc_initial_cplx * (i / 10000.0 + 1.0) * s->mb_num; RateControlEntry rce; if (i % ((s->gop_size + 3) / 4) == 0) rce.pict_type = AV_PICTURE_TYPE_I; else if (i % (s->max_b_frames + 1)) rce.pict_type = AV_PICTURE_TYPE_B; else rce.pict_type = AV_PICTURE_TYPE_P; rce.new_pict_type = rce.pict_type; rce.mc_mb_var_sum = bits * s->mb_num / 100000; rce.mb_var_sum = s->mb_num; rce.qscale = FF_QP2LAMBDA * 2; rce.f_code = 2; rce.b_code = 1; rce.misc_bits = 1; if (s->pict_type == AV_PICTURE_TYPE_I) { rce.i_count = s->mb_num; rce.i_tex_bits = bits; rce.p_tex_bits = 0; rce.mv_bits = 0; } else { rce.i_count = 0; // FIXME we do know this approx rce.i_tex_bits = 0; rce.p_tex_bits = bits * 0.9; rce.mv_bits = bits * 0.1; } rcc->i_cplx_sum[rce.pict_type] += rce.i_tex_bits * rce.qscale; rcc->p_cplx_sum[rce.pict_type] += rce.p_tex_bits * rce.qscale; rcc->mv_bits_sum[rce.pict_type] += rce.mv_bits; rcc->frame_count[rce.pict_type]++; get_qscale(s, &rce, rcc->pass1_wanted_bits / rcc->pass1_rc_eq_output_sum, i); // FIXME misbehaves a little for variable fps rcc->pass1_wanted_bits += s->bit_rate / get_fps(s->avctx); } } } return 0; }
true
FFmpeg
0898a6d4e4b669704fce663f610aa43dd7483fe9
av_cold int ff_rate_control_init(MpegEncContext *s) { RateControlContext *rcc = &s->rc_context; int i, res; static const char * const const_names[] = { "PI", "E", "iTex", "pTex", "tex", "mv", "fCode", "iCount", "mcVar", "var", "isI", "isP", "isB", "avgQP", "qComp", #if 0 "lastIQP", "lastPQP", "lastBQP", "nextNonBQP", #endif "avgIITex", "avgPITex", "avgPPTex", "avgBPTex", "avgTex", NULL }; static double (* const func1[])(void *, double) = { (void *)bits2qp, (void *)qp2bits, NULL }; static const char * const func1_names[] = { "bits2qp", "qp2bits", NULL }; emms_c(); if (!s->avctx->rc_max_available_vbv_use && s->avctx->rc_buffer_size) { if (s->avctx->rc_max_rate) { s->avctx->rc_max_available_vbv_use = av_clipf(s->avctx->rc_max_rate/(s->avctx->rc_buffer_size*get_fps(s->avctx)), 1.0/3, 1.0); } else s->avctx->rc_max_available_vbv_use = 1.0; } res = av_expr_parse(&rcc->rc_eq_eval, s->rc_eq ? s->rc_eq : "tex^qComp", const_names, func1_names, func1, NULL, NULL, 0, s->avctx); if (res < 0) { av_log(s->avctx, AV_LOG_ERROR, "Error parsing rc_eq \"%s\"\n", s->rc_eq); return res; } for (i = 0; i < 5; i++) { rcc->pred[i].coeff = FF_QP2LAMBDA * 7.0; rcc->pred[i].count = 1.0; rcc->pred[i].decay = 0.4; rcc->i_cplx_sum [i] = rcc->p_cplx_sum [i] = rcc->mv_bits_sum[i] = rcc->qscale_sum [i] = rcc->frame_count[i] = 1; rcc->last_qscale_for[i] = FF_QP2LAMBDA * 5; } rcc->buffer_index = s->avctx->rc_initial_buffer_occupancy; if (!rcc->buffer_index) rcc->buffer_index = s->avctx->rc_buffer_size * 3 / 4; if (s->flags & CODEC_FLAG_PASS2) { int i; char *p; p = s->avctx->stats_in; for (i = -1; p; i++) p = strchr(p + 1, ';'); i += s->max_b_frames; if (i <= 0 || i >= INT_MAX / sizeof(RateControlEntry)) return -1; rcc->entry = av_mallocz(i * sizeof(RateControlEntry)); rcc->num_entries = i; for (i = 0; i < rcc->num_entries; i++) { RateControlEntry *rce = &rcc->entry[i]; rce->pict_type = rce->new_pict_type = AV_PICTURE_TYPE_P; rce->qscale = rce->new_qscale = FF_QP2LAMBDA * 2; rce->misc_bits = s->mb_num + 10; rce->mb_var_sum = s->mb_num * 100; } p = s->avctx->stats_in; for (i = 0; i < rcc->num_entries - s->max_b_frames; i++) { RateControlEntry *rce; int picture_number; int e; char *next; next = strchr(p, ';'); if (next) { (*next) = 0; next++; } e = sscanf(p, " in:%d ", &picture_number); assert(picture_number >= 0); assert(picture_number < rcc->num_entries); rce = &rcc->entry[picture_number]; e += sscanf(p, " in:%*d out:%*d type:%d q:%f itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%"SCNd64" var:%"SCNd64" icount:%d skipcount:%d hbits:%d", &rce->pict_type, &rce->qscale, &rce->i_tex_bits, &rce->p_tex_bits, &rce->mv_bits, &rce->misc_bits, &rce->f_code, &rce->b_code, &rce->mc_mb_var_sum, &rce->mb_var_sum, &rce->i_count, &rce->skip_count, &rce->header_bits); if (e != 14) { av_log(s->avctx, AV_LOG_ERROR, "statistics are damaged at line %d, parser out=%d\n", i, e); return -1; } p = next; } if (init_pass2(s) < 0) return -1; if ((s->flags & CODEC_FLAG_PASS2) && s->avctx->rc_strategy == FF_RC_STRATEGY_XVID) { #if CONFIG_LIBXVID return ff_xvid_rate_control_init(s); #else av_log(s->avctx, AV_LOG_ERROR, "Xvid ratecontrol requires libavcodec compiled with Xvid support.\n"); return -1; #endif } } if (!(s->flags & CODEC_FLAG_PASS2)) { rcc->short_term_qsum = 0.001; rcc->short_term_qcount = 0.001; rcc->pass1_rc_eq_output_sum = 0.001; rcc->pass1_wanted_bits = 0.001; if (s->avctx->qblur > 1.0) { av_log(s->avctx, AV_LOG_ERROR, "qblur too large\n"); return -1; } if (s->rc_initial_cplx) { for (i = 0; i < 60 * 30; i++) { double bits = s->rc_initial_cplx * (i / 10000.0 + 1.0) * s->mb_num; RateControlEntry rce; if (i % ((s->gop_size + 3) / 4) == 0) rce.pict_type = AV_PICTURE_TYPE_I; else if (i % (s->max_b_frames + 1)) rce.pict_type = AV_PICTURE_TYPE_B; else rce.pict_type = AV_PICTURE_TYPE_P; rce.new_pict_type = rce.pict_type; rce.mc_mb_var_sum = bits * s->mb_num / 100000; rce.mb_var_sum = s->mb_num; rce.qscale = FF_QP2LAMBDA * 2; rce.f_code = 2; rce.b_code = 1; rce.misc_bits = 1; if (s->pict_type == AV_PICTURE_TYPE_I) { rce.i_count = s->mb_num; rce.i_tex_bits = bits; rce.p_tex_bits = 0; rce.mv_bits = 0; } else { rce.i_count = 0; rce.i_tex_bits = 0; rce.p_tex_bits = bits * 0.9; rce.mv_bits = bits * 0.1; } rcc->i_cplx_sum[rce.pict_type] += rce.i_tex_bits * rce.qscale; rcc->p_cplx_sum[rce.pict_type] += rce.p_tex_bits * rce.qscale; rcc->mv_bits_sum[rce.pict_type] += rce.mv_bits; rcc->frame_count[rce.pict_type]++; get_qscale(s, &rce, rcc->pass1_wanted_bits / rcc->pass1_rc_eq_output_sum, i); rcc->pass1_wanted_bits += s->bit_rate / get_fps(s->avctx); } } } return 0; }
{ "code": [], "line_no": [] }
VAR_5av_coldVAR_5 VAR_5intVAR_5 VAR_5ff_rate_control_initVAR_5(VAR_5MpegEncContextVAR_5 *VAR_5sVAR_5) { VAR_5RateControlContextVAR_5 *VAR_5rccVAR_5 = &VAR_5sVAR_5->VAR_5rc_contextVAR_5; VAR_5intVAR_5 VAR_5VAR_6VAR_5, VAR_5VAR_1VAR_5; VAR_5staticVAR_5 VAR_5constVAR_5 VAR_5charVAR_5 * VAR_5constVAR_5 VAR_5VAR_2VAR_5[] = { "VAR_5PIVAR_5", "VAR_5EVAR_5", "VAR_5iTexVAR_5", "VAR_5pTexVAR_5", "VAR_5texVAR_5", "VAR_5mvVAR_5", "VAR_5fCodeVAR_5", "VAR_5iCountVAR_5", "VAR_5mcVarVAR_5", "VAR_5varVAR_5", "VAR_5isIVAR_5", "VAR_5isPVAR_5", "VAR_5isBVAR_5", "VAR_5avgQPVAR_5", "VAR_5qCompVAR_5", #VAR_5ifVAR_5 VAR_50VAR_5 "VAR_5lastIQPVAR_5", "VAR_5lastPQPVAR_5", "VAR_5lastBQPVAR_5", "VAR_5nextNonBQPVAR_5", #VAR_5endifVAR_5 "VAR_5avgIITexVAR_5", "VAR_5avgPITexVAR_5", "VAR_5avgPPTexVAR_5", "VAR_5avgBPTexVAR_5", "VAR_5avgTexVAR_5", VAR_5NULLVAR_5 }; VAR_5staticVAR_5 VAR_5doubleVAR_5 (* VAR_5constVAR_5 VAR_5VAR_3VAR_5[])(VAR_5voidVAR_5 *, VAR_5doubleVAR_5) = { (VAR_5voidVAR_5 *)VAR_5bits2qpVAR_5, (VAR_5voidVAR_5 *)VAR_5qp2bitsVAR_5, VAR_5NULLVAR_5 }; VAR_5staticVAR_5 VAR_5constVAR_5 VAR_5charVAR_5 * VAR_5constVAR_5 VAR_5func1_namesVAR_5[] = { "VAR_5bits2qpVAR_5", "VAR_5qp2bitsVAR_5", VAR_5NULLVAR_5 }; VAR_5emms_cVAR_5(); VAR_5ifVAR_5 (!VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5rc_max_available_vbv_useVAR_5 && VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5rc_buffer_sizeVAR_5) { VAR_5ifVAR_5 (VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5rc_max_rateVAR_5) { VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5rc_max_available_vbv_useVAR_5 = VAR_5av_clipfVAR_5(VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5rc_max_rateVAR_5/(VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5rc_buffer_sizeVAR_5*VAR_5get_fpsVAR_5(VAR_5sVAR_5->VAR_5avctxVAR_5)), VAR_51VAR_5.VAR_50VAR_5/VAR_53VAR_5, VAR_51VAR_5.VAR_50VAR_5); } VAR_5elseVAR_5 VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5rc_max_available_vbv_useVAR_5 = VAR_51VAR_5.VAR_50VAR_5; } VAR_5VAR_1VAR_5 = VAR_5av_expr_parseVAR_5(&VAR_5rccVAR_5->VAR_5rc_eq_evalVAR_5, VAR_5sVAR_5->VAR_5rc_eqVAR_5 ? VAR_5sVAR_5->VAR_5rc_eqVAR_5 : "VAR_5texVAR_5^VAR_5qCompVAR_5", VAR_5VAR_2VAR_5, VAR_5func1_namesVAR_5, VAR_5VAR_3VAR_5, VAR_5NULLVAR_5, VAR_5NULLVAR_5, VAR_50VAR_5, VAR_5sVAR_5->VAR_5avctxVAR_5); VAR_5ifVAR_5 (VAR_5VAR_1VAR_5 < VAR_50VAR_5) { VAR_5av_logVAR_5(VAR_5sVAR_5->VAR_5avctxVAR_5, VAR_5AV_LOG_ERRORVAR_5, "VAR_5ErrorVAR_5 VAR_5parsingVAR_5 VAR_5rc_eqVAR_5 \"%VAR_5sVAR_5\"\VAR_5nVAR_5", VAR_5sVAR_5->VAR_5rc_eqVAR_5); VAR_5returnVAR_5 VAR_5VAR_1VAR_5; } VAR_5forVAR_5 (VAR_5VAR_6VAR_5 = VAR_50VAR_5; VAR_5VAR_6VAR_5 < VAR_55VAR_5; VAR_5VAR_6VAR_5++) { VAR_5rccVAR_5->VAR_5predVAR_5[VAR_5VAR_6VAR_5].VAR_5coeffVAR_5 = VAR_5FF_QP2LAMBDAVAR_5 * VAR_57VAR_5.VAR_50VAR_5; VAR_5rccVAR_5->VAR_5predVAR_5[VAR_5VAR_6VAR_5].VAR_5countVAR_5 = VAR_51VAR_5.VAR_50VAR_5; VAR_5rccVAR_5->VAR_5predVAR_5[VAR_5VAR_6VAR_5].VAR_5decayVAR_5 = VAR_50VAR_5.VAR_54VAR_5; VAR_5rccVAR_5->VAR_5i_cplx_sumVAR_5 [VAR_5VAR_6VAR_5] = VAR_5rccVAR_5->VAR_5p_cplx_sumVAR_5 [VAR_5VAR_6VAR_5] = VAR_5rccVAR_5->VAR_5mv_bits_sumVAR_5[VAR_5VAR_6VAR_5] = VAR_5rccVAR_5->VAR_5qscale_sumVAR_5 [VAR_5VAR_6VAR_5] = VAR_5rccVAR_5->VAR_5frame_countVAR_5[VAR_5VAR_6VAR_5] = VAR_51VAR_5; VAR_5rccVAR_5->VAR_5last_qscale_forVAR_5[VAR_5VAR_6VAR_5] = VAR_5FF_QP2LAMBDAVAR_5 * VAR_55VAR_5; } VAR_5rccVAR_5->VAR_5buffer_indexVAR_5 = VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5rc_initial_buffer_occupancyVAR_5; VAR_5ifVAR_5 (!VAR_5rccVAR_5->VAR_5buffer_indexVAR_5) VAR_5rccVAR_5->VAR_5buffer_indexVAR_5 = VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5rc_buffer_sizeVAR_5 * VAR_53VAR_5 / VAR_54VAR_5; VAR_5ifVAR_5 (VAR_5sVAR_5->VAR_5flagsVAR_5 & VAR_5CODEC_FLAG_PASS2VAR_5) { VAR_5intVAR_5 VAR_5VAR_6VAR_5; VAR_5charVAR_5 *VAR_5pVAR_5; VAR_5pVAR_5 = VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5stats_inVAR_5; VAR_5forVAR_5 (VAR_5VAR_6VAR_5 = -VAR_51VAR_5; VAR_5pVAR_5; VAR_5VAR_6VAR_5++) VAR_5pVAR_5 = VAR_5strchrVAR_5(VAR_5pVAR_5 + VAR_51VAR_5, ';'); VAR_5VAR_6VAR_5 += VAR_5sVAR_5->VAR_5max_b_framesVAR_5; VAR_5ifVAR_5 (VAR_5VAR_6VAR_5 <= VAR_50VAR_5 || VAR_5VAR_6VAR_5 >= VAR_5INT_MAXVAR_5 / VAR_5sizeofVAR_5(VAR_5RateControlEntryVAR_5)) VAR_5returnVAR_5 -VAR_51VAR_5; VAR_5rccVAR_5->VAR_5entryVAR_5 = VAR_5av_malloczVAR_5(VAR_5VAR_6VAR_5 * VAR_5sizeofVAR_5(VAR_5RateControlEntryVAR_5)); VAR_5rccVAR_5->VAR_5num_entriesVAR_5 = VAR_5VAR_6VAR_5; VAR_5forVAR_5 (VAR_5VAR_6VAR_5 = VAR_50VAR_5; VAR_5VAR_6VAR_5 < VAR_5rccVAR_5->VAR_5num_entriesVAR_5; VAR_5VAR_6VAR_5++) { VAR_5RateControlEntryVAR_5 *VAR_5rceVAR_5 = &VAR_5rccVAR_5->VAR_5entryVAR_5[VAR_5VAR_6VAR_5]; VAR_5rceVAR_5->VAR_5pict_typeVAR_5 = VAR_5rceVAR_5->VAR_5new_pict_typeVAR_5 = VAR_5AV_PICTURE_TYPE_PVAR_5; VAR_5rceVAR_5->VAR_5qscaleVAR_5 = VAR_5rceVAR_5->VAR_5new_qscaleVAR_5 = VAR_5FF_QP2LAMBDAVAR_5 * VAR_52VAR_5; VAR_5rceVAR_5->VAR_5misc_bitsVAR_5 = VAR_5sVAR_5->VAR_5mb_numVAR_5 + VAR_510VAR_5; VAR_5rceVAR_5->VAR_5mb_var_sumVAR_5 = VAR_5sVAR_5->VAR_5mb_numVAR_5 * VAR_5100VAR_5; } VAR_5pVAR_5 = VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5stats_inVAR_5; VAR_5forVAR_5 (VAR_5VAR_6VAR_5 = VAR_50VAR_5; VAR_5VAR_6VAR_5 < VAR_5rccVAR_5->VAR_5num_entriesVAR_5 - VAR_5sVAR_5->VAR_5max_b_framesVAR_5; VAR_5VAR_6VAR_5++) { VAR_5RateControlEntryVAR_5 *VAR_5rceVAR_5; VAR_5intVAR_5 VAR_5picture_numberVAR_5; VAR_5intVAR_5 VAR_5eVAR_5; VAR_5charVAR_5 *VAR_5nextVAR_5; VAR_5nextVAR_5 = VAR_5strchrVAR_5(VAR_5pVAR_5, ';'); VAR_5ifVAR_5 (VAR_5nextVAR_5) { (*VAR_5nextVAR_5) = VAR_50VAR_5; VAR_5nextVAR_5++; } VAR_5eVAR_5 = VAR_5sscanfVAR_5(VAR_5pVAR_5, " VAR_5inVAR_5:%VAR_5dVAR_5 ", &VAR_5picture_numberVAR_5); VAR_5assertVAR_5(VAR_5picture_numberVAR_5 >= VAR_50VAR_5); VAR_5assertVAR_5(VAR_5picture_numberVAR_5 < VAR_5rccVAR_5->VAR_5num_entriesVAR_5); VAR_5rceVAR_5 = &VAR_5rccVAR_5->VAR_5entryVAR_5[VAR_5picture_numberVAR_5]; VAR_5eVAR_5 += VAR_5sscanfVAR_5(VAR_5pVAR_5, " VAR_5inVAR_5:%*VAR_5dVAR_5 VAR_5outVAR_5:%*VAR_5dVAR_5 VAR_5typeVAR_5:%VAR_5dVAR_5 VAR_5qVAR_5:%VAR_5fVAR_5 VAR_5itexVAR_5:%VAR_5dVAR_5 VAR_5ptexVAR_5:%VAR_5dVAR_5 VAR_5mvVAR_5:%VAR_5dVAR_5 VAR_5miscVAR_5:%VAR_5dVAR_5 VAR_5fcodeVAR_5:%VAR_5dVAR_5 VAR_5bcodeVAR_5:%VAR_5dVAR_5 VAR_5mcVAR_5-VAR_5varVAR_5:%"VAR_5SCNd64VAR_5" VAR_5varVAR_5:%"VAR_5SCNd64VAR_5" VAR_5icountVAR_5:%VAR_5dVAR_5 VAR_5skipcountVAR_5:%VAR_5dVAR_5 VAR_5hbitsVAR_5:%VAR_5dVAR_5", &VAR_5rceVAR_5->VAR_5pict_typeVAR_5, &VAR_5rceVAR_5->VAR_5qscaleVAR_5, &VAR_5rceVAR_5->VAR_5i_tex_bitsVAR_5, &VAR_5rceVAR_5->VAR_5p_tex_bitsVAR_5, &VAR_5rceVAR_5->VAR_5mv_bitsVAR_5, &VAR_5rceVAR_5->VAR_5misc_bitsVAR_5, &VAR_5rceVAR_5->VAR_5f_codeVAR_5, &VAR_5rceVAR_5->VAR_5b_codeVAR_5, &VAR_5rceVAR_5->VAR_5mc_mb_var_sumVAR_5, &VAR_5rceVAR_5->VAR_5mb_var_sumVAR_5, &VAR_5rceVAR_5->VAR_5i_countVAR_5, &VAR_5rceVAR_5->VAR_5skip_countVAR_5, &VAR_5rceVAR_5->VAR_5header_bitsVAR_5); VAR_5ifVAR_5 (VAR_5eVAR_5 != VAR_514VAR_5) { VAR_5av_logVAR_5(VAR_5sVAR_5->VAR_5avctxVAR_5, VAR_5AV_LOG_ERRORVAR_5, "VAR_5statisticsVAR_5 VAR_5areVAR_5 VAR_5damagedVAR_5 VAR_5atVAR_5 VAR_5lineVAR_5 %VAR_5dVAR_5, VAR_5parserVAR_5 VAR_5outVAR_5=%VAR_5dVAR_5\VAR_5nVAR_5", VAR_5VAR_6VAR_5, VAR_5eVAR_5); VAR_5returnVAR_5 -VAR_51VAR_5; } VAR_5pVAR_5 = VAR_5nextVAR_5; } VAR_5ifVAR_5 (VAR_5init_pass2VAR_5(VAR_5sVAR_5) < VAR_50VAR_5) VAR_5returnVAR_5 -VAR_51VAR_5; VAR_5ifVAR_5 ((VAR_5sVAR_5->VAR_5flagsVAR_5 & VAR_5CODEC_FLAG_PASS2VAR_5) && VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5rc_strategyVAR_5 == VAR_5FF_RC_STRATEGY_XVIDVAR_5) { #VAR_5ifVAR_5 VAR_5CONFIG_LIBXVIDVAR_5 VAR_5returnVAR_5 VAR_5ff_xvid_rate_control_initVAR_5(VAR_5sVAR_5); #VAR_5elseVAR_5 VAR_5av_logVAR_5(VAR_5sVAR_5->VAR_5avctxVAR_5, VAR_5AV_LOG_ERRORVAR_5, "VAR_5XvidVAR_5 VAR_5ratecontrolVAR_5 VAR_5requiresVAR_5 VAR_5libavcodecVAR_5 VAR_5compiledVAR_5 VAR_5withVAR_5 VAR_5XvidVAR_5 VAR_5supportVAR_5.\VAR_5nVAR_5"); VAR_5returnVAR_5 -VAR_51VAR_5; #VAR_5endifVAR_5 } } VAR_5ifVAR_5 (!(VAR_5sVAR_5->VAR_5flagsVAR_5 & VAR_5CODEC_FLAG_PASS2VAR_5)) { VAR_5rccVAR_5->VAR_5short_term_qsumVAR_5 = VAR_50VAR_5.VAR_5001VAR_5; VAR_5rccVAR_5->VAR_5short_term_qcountVAR_5 = VAR_50VAR_5.VAR_5001VAR_5; VAR_5rccVAR_5->VAR_5pass1_rc_eq_output_sumVAR_5 = VAR_50VAR_5.VAR_5001VAR_5; VAR_5rccVAR_5->VAR_5pass1_wanted_bitsVAR_5 = VAR_50VAR_5.VAR_5001VAR_5; VAR_5ifVAR_5 (VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5qblurVAR_5 > VAR_51VAR_5.VAR_50VAR_5) { VAR_5av_logVAR_5(VAR_5sVAR_5->VAR_5avctxVAR_5, VAR_5AV_LOG_ERRORVAR_5, "VAR_5qblurVAR_5 VAR_5tooVAR_5 VAR_5largeVAR_5\VAR_5nVAR_5"); VAR_5returnVAR_5 -VAR_51VAR_5; } VAR_5ifVAR_5 (VAR_5sVAR_5->VAR_5rc_initial_cplxVAR_5) { VAR_5forVAR_5 (VAR_5VAR_6VAR_5 = VAR_50VAR_5; VAR_5VAR_6VAR_5 < VAR_560VAR_5 * VAR_530VAR_5; VAR_5VAR_6VAR_5++) { VAR_5doubleVAR_5 VAR_5bitsVAR_5 = VAR_5sVAR_5->VAR_5rc_initial_cplxVAR_5 * (VAR_5VAR_6VAR_5 / VAR_510000VAR_5.VAR_50VAR_5 + VAR_51VAR_5.VAR_50VAR_5) * VAR_5sVAR_5->VAR_5mb_numVAR_5; VAR_5RateControlEntryVAR_5 VAR_5rceVAR_5; VAR_5ifVAR_5 (VAR_5VAR_6VAR_5 % ((VAR_5sVAR_5->VAR_5gop_sizeVAR_5 + VAR_53VAR_5) / VAR_54VAR_5) == VAR_50VAR_5) VAR_5rceVAR_5.VAR_5pict_typeVAR_5 = VAR_5AV_PICTURE_TYPE_IVAR_5; VAR_5elseVAR_5 VAR_5ifVAR_5 (VAR_5VAR_6VAR_5 % (VAR_5sVAR_5->VAR_5max_b_framesVAR_5 + VAR_51VAR_5)) VAR_5rceVAR_5.VAR_5pict_typeVAR_5 = VAR_5AV_PICTURE_TYPE_BVAR_5; VAR_5elseVAR_5 VAR_5rceVAR_5.VAR_5pict_typeVAR_5 = VAR_5AV_PICTURE_TYPE_PVAR_5; VAR_5rceVAR_5.VAR_5new_pict_typeVAR_5 = VAR_5rceVAR_5.VAR_5pict_typeVAR_5; VAR_5rceVAR_5.VAR_5mc_mb_var_sumVAR_5 = VAR_5bitsVAR_5 * VAR_5sVAR_5->VAR_5mb_numVAR_5 / VAR_5100000VAR_5; VAR_5rceVAR_5.VAR_5mb_var_sumVAR_5 = VAR_5sVAR_5->VAR_5mb_numVAR_5; VAR_5rceVAR_5.VAR_5qscaleVAR_5 = VAR_5FF_QP2LAMBDAVAR_5 * VAR_52VAR_5; VAR_5rceVAR_5.VAR_5f_codeVAR_5 = VAR_52VAR_5; VAR_5rceVAR_5.VAR_5b_codeVAR_5 = VAR_51VAR_5; VAR_5rceVAR_5.VAR_5misc_bitsVAR_5 = VAR_51VAR_5; VAR_5ifVAR_5 (VAR_5sVAR_5->VAR_5pict_typeVAR_5 == VAR_5AV_PICTURE_TYPE_IVAR_5) { VAR_5rceVAR_5.VAR_5i_countVAR_5 = VAR_5sVAR_5->VAR_5mb_numVAR_5; VAR_5rceVAR_5.VAR_5i_tex_bitsVAR_5 = VAR_5bitsVAR_5; VAR_5rceVAR_5.VAR_5p_tex_bitsVAR_5 = VAR_50VAR_5; VAR_5rceVAR_5.VAR_5mv_bitsVAR_5 = VAR_50VAR_5; } VAR_5elseVAR_5 { VAR_5rceVAR_5.VAR_5i_countVAR_5 = VAR_50VAR_5; VAR_5rceVAR_5.VAR_5i_tex_bitsVAR_5 = VAR_50VAR_5; VAR_5rceVAR_5.VAR_5p_tex_bitsVAR_5 = VAR_5bitsVAR_5 * VAR_50VAR_5.VAR_59VAR_5; VAR_5rceVAR_5.VAR_5mv_bitsVAR_5 = VAR_5bitsVAR_5 * VAR_50VAR_5.VAR_51VAR_5; } VAR_5rccVAR_5->VAR_5i_cplx_sumVAR_5[VAR_5rceVAR_5.VAR_5pict_typeVAR_5] += VAR_5rceVAR_5.VAR_5i_tex_bitsVAR_5 * VAR_5rceVAR_5.VAR_5qscaleVAR_5; VAR_5rccVAR_5->VAR_5p_cplx_sumVAR_5[VAR_5rceVAR_5.VAR_5pict_typeVAR_5] += VAR_5rceVAR_5.VAR_5p_tex_bitsVAR_5 * VAR_5rceVAR_5.VAR_5qscaleVAR_5; VAR_5rccVAR_5->VAR_5mv_bits_sumVAR_5[VAR_5rceVAR_5.VAR_5pict_typeVAR_5] += VAR_5rceVAR_5.VAR_5mv_bitsVAR_5; VAR_5rccVAR_5->VAR_5frame_countVAR_5[VAR_5rceVAR_5.VAR_5pict_typeVAR_5]++; VAR_5get_qscaleVAR_5(VAR_5sVAR_5, &VAR_5rceVAR_5, VAR_5rccVAR_5->VAR_5pass1_wanted_bitsVAR_5 / VAR_5rccVAR_5->VAR_5pass1_rc_eq_output_sumVAR_5, VAR_5VAR_6VAR_5); VAR_5rccVAR_5->VAR_5pass1_wanted_bitsVAR_5 += VAR_5sVAR_5->VAR_5bit_rateVAR_5 / VAR_5get_fpsVAR_5(VAR_5sVAR_5->VAR_5avctxVAR_5); } } } VAR_5returnVAR_5 VAR_50VAR_5; }
[ "VAR_5av_coldVAR_5 VAR_5intVAR_5 VAR_5ff_rate_control_initVAR_5(VAR_5MpegEncContextVAR_5 *VAR_5sVAR_5)\n{", "VAR_5RateControlContextVAR_5 *VAR_5rccVAR_5 = &VAR_5sVAR_5->VAR_5rc_contextVAR_5;", "VAR_5intVAR_5 VAR_5VAR_6VAR_5, VAR_5VAR_1VAR_5;", "VAR_5staticVAR_5 VAR_5constVAR_5 VAR_5charVAR_5 * VAR_5constVAR_5 VAR_5VAR_2VAR_5[] = {", "\"VAR_5PIVAR_5\",\n\"VAR_5EVAR_5\",\n\"VAR_5iTexVAR_5\",\n\"VAR_5pTexVAR_5\",\n\"VAR_5texVAR_5\",\n\"VAR_5mvVAR_5\",\n\"VAR_5fCodeVAR_5\",\n\"VAR_5iCountVAR_5\",\n\"VAR_5mcVarVAR_5\",\n\"VAR_5varVAR_5\",\n\"VAR_5isIVAR_5\",\n\"VAR_5isPVAR_5\",\n\"VAR_5isBVAR_5\",\n\"VAR_5avgQPVAR_5\",\n\"VAR_5qCompVAR_5\",\n#VAR_5ifVAR_5 VAR_50VAR_5\n\"VAR_5lastIQPVAR_5\",\n\"VAR_5lastPQPVAR_5\",\n\"VAR_5lastBQPVAR_5\",\n\"VAR_5nextNonBQPVAR_5\",\n#VAR_5endifVAR_5\n\"VAR_5avgIITexVAR_5\",\n\"VAR_5avgPITexVAR_5\",\n\"VAR_5avgPPTexVAR_5\",\n\"VAR_5avgBPTexVAR_5\",\n\"VAR_5avgTexVAR_5\",\nVAR_5NULLVAR_5\n};", "VAR_5staticVAR_5 VAR_5doubleVAR_5 (* VAR_5constVAR_5 VAR_5VAR_3VAR_5[])(VAR_5voidVAR_5 *, VAR_5doubleVAR_5) = {", "(VAR_5voidVAR_5 *)VAR_5bits2qpVAR_5,\n(VAR_5voidVAR_5 *)VAR_5qp2bitsVAR_5,\nVAR_5NULLVAR_5\n};", "VAR_5staticVAR_5 VAR_5constVAR_5 VAR_5charVAR_5 * VAR_5constVAR_5 VAR_5func1_namesVAR_5[] = {", "\"VAR_5bits2qpVAR_5\",\n\"VAR_5qp2bitsVAR_5\",\nVAR_5NULLVAR_5\n};", "VAR_5emms_cVAR_5();", "VAR_5ifVAR_5 (!VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5rc_max_available_vbv_useVAR_5 && VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5rc_buffer_sizeVAR_5) {", "VAR_5ifVAR_5 (VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5rc_max_rateVAR_5) {", "VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5rc_max_available_vbv_useVAR_5 = VAR_5av_clipfVAR_5(VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5rc_max_rateVAR_5/(VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5rc_buffer_sizeVAR_5*VAR_5get_fpsVAR_5(VAR_5sVAR_5->VAR_5avctxVAR_5)), VAR_51VAR_5.VAR_50VAR_5/VAR_53VAR_5, VAR_51VAR_5.VAR_50VAR_5);", "} VAR_5elseVAR_5", "VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5rc_max_available_vbv_useVAR_5 = VAR_51VAR_5.VAR_50VAR_5;", "}", "VAR_5VAR_1VAR_5 = VAR_5av_expr_parseVAR_5(&VAR_5rccVAR_5->VAR_5rc_eq_evalVAR_5,\nVAR_5sVAR_5->VAR_5rc_eqVAR_5 ? VAR_5sVAR_5->VAR_5rc_eqVAR_5 : \"VAR_5texVAR_5^VAR_5qCompVAR_5\",\nVAR_5VAR_2VAR_5, VAR_5func1_namesVAR_5, VAR_5VAR_3VAR_5,\nVAR_5NULLVAR_5, VAR_5NULLVAR_5, VAR_50VAR_5, VAR_5sVAR_5->VAR_5avctxVAR_5);", "VAR_5ifVAR_5 (VAR_5VAR_1VAR_5 < VAR_50VAR_5) {", "VAR_5av_logVAR_5(VAR_5sVAR_5->VAR_5avctxVAR_5, VAR_5AV_LOG_ERRORVAR_5, \"VAR_5ErrorVAR_5 VAR_5parsingVAR_5 VAR_5rc_eqVAR_5 \\\"%VAR_5sVAR_5\\\"\\VAR_5nVAR_5\", VAR_5sVAR_5->VAR_5rc_eqVAR_5);", "VAR_5returnVAR_5 VAR_5VAR_1VAR_5;", "}", "VAR_5forVAR_5 (VAR_5VAR_6VAR_5 = VAR_50VAR_5; VAR_5VAR_6VAR_5 < VAR_55VAR_5; VAR_5VAR_6VAR_5++) {", "VAR_5rccVAR_5->VAR_5predVAR_5[VAR_5VAR_6VAR_5].VAR_5coeffVAR_5 = VAR_5FF_QP2LAMBDAVAR_5 * VAR_57VAR_5.VAR_50VAR_5;", "VAR_5rccVAR_5->VAR_5predVAR_5[VAR_5VAR_6VAR_5].VAR_5countVAR_5 = VAR_51VAR_5.VAR_50VAR_5;", "VAR_5rccVAR_5->VAR_5predVAR_5[VAR_5VAR_6VAR_5].VAR_5decayVAR_5 = VAR_50VAR_5.VAR_54VAR_5;", "VAR_5rccVAR_5->VAR_5i_cplx_sumVAR_5 [VAR_5VAR_6VAR_5] =\nVAR_5rccVAR_5->VAR_5p_cplx_sumVAR_5 [VAR_5VAR_6VAR_5] =\nVAR_5rccVAR_5->VAR_5mv_bits_sumVAR_5[VAR_5VAR_6VAR_5] =\nVAR_5rccVAR_5->VAR_5qscale_sumVAR_5 [VAR_5VAR_6VAR_5] =\nVAR_5rccVAR_5->VAR_5frame_countVAR_5[VAR_5VAR_6VAR_5] = VAR_51VAR_5;", "VAR_5rccVAR_5->VAR_5last_qscale_forVAR_5[VAR_5VAR_6VAR_5] = VAR_5FF_QP2LAMBDAVAR_5 * VAR_55VAR_5;", "}", "VAR_5rccVAR_5->VAR_5buffer_indexVAR_5 = VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5rc_initial_buffer_occupancyVAR_5;", "VAR_5ifVAR_5 (!VAR_5rccVAR_5->VAR_5buffer_indexVAR_5)\nVAR_5rccVAR_5->VAR_5buffer_indexVAR_5 = VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5rc_buffer_sizeVAR_5 * VAR_53VAR_5 / VAR_54VAR_5;", "VAR_5ifVAR_5 (VAR_5sVAR_5->VAR_5flagsVAR_5 & VAR_5CODEC_FLAG_PASS2VAR_5) {", "VAR_5intVAR_5 VAR_5VAR_6VAR_5;", "VAR_5charVAR_5 *VAR_5pVAR_5;", "VAR_5pVAR_5 = VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5stats_inVAR_5;", "VAR_5forVAR_5 (VAR_5VAR_6VAR_5 = -VAR_51VAR_5; VAR_5pVAR_5; VAR_5VAR_6VAR_5++)", "VAR_5pVAR_5 = VAR_5strchrVAR_5(VAR_5pVAR_5 + VAR_51VAR_5, ';');", "VAR_5VAR_6VAR_5 += VAR_5sVAR_5->VAR_5max_b_framesVAR_5;", "VAR_5ifVAR_5 (VAR_5VAR_6VAR_5 <= VAR_50VAR_5 || VAR_5VAR_6VAR_5 >= VAR_5INT_MAXVAR_5 / VAR_5sizeofVAR_5(VAR_5RateControlEntryVAR_5))\nVAR_5returnVAR_5 -VAR_51VAR_5;", "VAR_5rccVAR_5->VAR_5entryVAR_5 = VAR_5av_malloczVAR_5(VAR_5VAR_6VAR_5 * VAR_5sizeofVAR_5(VAR_5RateControlEntryVAR_5));", "VAR_5rccVAR_5->VAR_5num_entriesVAR_5 = VAR_5VAR_6VAR_5;", "VAR_5forVAR_5 (VAR_5VAR_6VAR_5 = VAR_50VAR_5; VAR_5VAR_6VAR_5 < VAR_5rccVAR_5->VAR_5num_entriesVAR_5; VAR_5VAR_6VAR_5++) {", "VAR_5RateControlEntryVAR_5 *VAR_5rceVAR_5 = &VAR_5rccVAR_5->VAR_5entryVAR_5[VAR_5VAR_6VAR_5];", "VAR_5rceVAR_5->VAR_5pict_typeVAR_5 = VAR_5rceVAR_5->VAR_5new_pict_typeVAR_5 = VAR_5AV_PICTURE_TYPE_PVAR_5;", "VAR_5rceVAR_5->VAR_5qscaleVAR_5 = VAR_5rceVAR_5->VAR_5new_qscaleVAR_5 = VAR_5FF_QP2LAMBDAVAR_5 * VAR_52VAR_5;", "VAR_5rceVAR_5->VAR_5misc_bitsVAR_5 = VAR_5sVAR_5->VAR_5mb_numVAR_5 + VAR_510VAR_5;", "VAR_5rceVAR_5->VAR_5mb_var_sumVAR_5 = VAR_5sVAR_5->VAR_5mb_numVAR_5 * VAR_5100VAR_5;", "}", "VAR_5pVAR_5 = VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5stats_inVAR_5;", "VAR_5forVAR_5 (VAR_5VAR_6VAR_5 = VAR_50VAR_5; VAR_5VAR_6VAR_5 < VAR_5rccVAR_5->VAR_5num_entriesVAR_5 - VAR_5sVAR_5->VAR_5max_b_framesVAR_5; VAR_5VAR_6VAR_5++) {", "VAR_5RateControlEntryVAR_5 *VAR_5rceVAR_5;", "VAR_5intVAR_5 VAR_5picture_numberVAR_5;", "VAR_5intVAR_5 VAR_5eVAR_5;", "VAR_5charVAR_5 *VAR_5nextVAR_5;", "VAR_5nextVAR_5 = VAR_5strchrVAR_5(VAR_5pVAR_5, ';');", "VAR_5ifVAR_5 (VAR_5nextVAR_5) {", "(*VAR_5nextVAR_5) = VAR_50VAR_5;", "VAR_5nextVAR_5++;", "}", "VAR_5eVAR_5 = VAR_5sscanfVAR_5(VAR_5pVAR_5, \" VAR_5inVAR_5:%VAR_5dVAR_5 \", &VAR_5picture_numberVAR_5);", "VAR_5assertVAR_5(VAR_5picture_numberVAR_5 >= VAR_50VAR_5);", "VAR_5assertVAR_5(VAR_5picture_numberVAR_5 < VAR_5rccVAR_5->VAR_5num_entriesVAR_5);", "VAR_5rceVAR_5 = &VAR_5rccVAR_5->VAR_5entryVAR_5[VAR_5picture_numberVAR_5];", "VAR_5eVAR_5 += VAR_5sscanfVAR_5(VAR_5pVAR_5, \" VAR_5inVAR_5:%*VAR_5dVAR_5 VAR_5outVAR_5:%*VAR_5dVAR_5 VAR_5typeVAR_5:%VAR_5dVAR_5 VAR_5qVAR_5:%VAR_5fVAR_5 VAR_5itexVAR_5:%VAR_5dVAR_5 VAR_5ptexVAR_5:%VAR_5dVAR_5 VAR_5mvVAR_5:%VAR_5dVAR_5 VAR_5miscVAR_5:%VAR_5dVAR_5 VAR_5fcodeVAR_5:%VAR_5dVAR_5 VAR_5bcodeVAR_5:%VAR_5dVAR_5 VAR_5mcVAR_5-VAR_5varVAR_5:%\"VAR_5SCNd64VAR_5\" VAR_5varVAR_5:%\"VAR_5SCNd64VAR_5\" VAR_5icountVAR_5:%VAR_5dVAR_5 VAR_5skipcountVAR_5:%VAR_5dVAR_5 VAR_5hbitsVAR_5:%VAR_5dVAR_5\",\n&VAR_5rceVAR_5->VAR_5pict_typeVAR_5, &VAR_5rceVAR_5->VAR_5qscaleVAR_5, &VAR_5rceVAR_5->VAR_5i_tex_bitsVAR_5, &VAR_5rceVAR_5->VAR_5p_tex_bitsVAR_5,\n&VAR_5rceVAR_5->VAR_5mv_bitsVAR_5, &VAR_5rceVAR_5->VAR_5misc_bitsVAR_5,\n&VAR_5rceVAR_5->VAR_5f_codeVAR_5, &VAR_5rceVAR_5->VAR_5b_codeVAR_5,\n&VAR_5rceVAR_5->VAR_5mc_mb_var_sumVAR_5, &VAR_5rceVAR_5->VAR_5mb_var_sumVAR_5,\n&VAR_5rceVAR_5->VAR_5i_countVAR_5, &VAR_5rceVAR_5->VAR_5skip_countVAR_5, &VAR_5rceVAR_5->VAR_5header_bitsVAR_5);", "VAR_5ifVAR_5 (VAR_5eVAR_5 != VAR_514VAR_5) {", "VAR_5av_logVAR_5(VAR_5sVAR_5->VAR_5avctxVAR_5, VAR_5AV_LOG_ERRORVAR_5,\n\"VAR_5statisticsVAR_5 VAR_5areVAR_5 VAR_5damagedVAR_5 VAR_5atVAR_5 VAR_5lineVAR_5 %VAR_5dVAR_5, VAR_5parserVAR_5 VAR_5outVAR_5=%VAR_5dVAR_5\\VAR_5nVAR_5\",\nVAR_5VAR_6VAR_5, VAR_5eVAR_5);", "VAR_5returnVAR_5 -VAR_51VAR_5;", "}", "VAR_5pVAR_5 = VAR_5nextVAR_5;", "}", "VAR_5ifVAR_5 (VAR_5init_pass2VAR_5(VAR_5sVAR_5) < VAR_50VAR_5)\nVAR_5returnVAR_5 -VAR_51VAR_5;", "VAR_5ifVAR_5 ((VAR_5sVAR_5->VAR_5flagsVAR_5 & VAR_5CODEC_FLAG_PASS2VAR_5) && VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5rc_strategyVAR_5 == VAR_5FF_RC_STRATEGY_XVIDVAR_5) {", "#VAR_5ifVAR_5 VAR_5CONFIG_LIBXVIDVAR_5\nVAR_5returnVAR_5 VAR_5ff_xvid_rate_control_initVAR_5(VAR_5sVAR_5);", "#VAR_5elseVAR_5\nVAR_5av_logVAR_5(VAR_5sVAR_5->VAR_5avctxVAR_5, VAR_5AV_LOG_ERRORVAR_5,\n\"VAR_5XvidVAR_5 VAR_5ratecontrolVAR_5 VAR_5requiresVAR_5 VAR_5libavcodecVAR_5 VAR_5compiledVAR_5 VAR_5withVAR_5 VAR_5XvidVAR_5 VAR_5supportVAR_5.\\VAR_5nVAR_5\");", "VAR_5returnVAR_5 -VAR_51VAR_5;", "#VAR_5endifVAR_5\n}", "}", "VAR_5ifVAR_5 (!(VAR_5sVAR_5->VAR_5flagsVAR_5 & VAR_5CODEC_FLAG_PASS2VAR_5)) {", "VAR_5rccVAR_5->VAR_5short_term_qsumVAR_5 = VAR_50VAR_5.VAR_5001VAR_5;", "VAR_5rccVAR_5->VAR_5short_term_qcountVAR_5 = VAR_50VAR_5.VAR_5001VAR_5;", "VAR_5rccVAR_5->VAR_5pass1_rc_eq_output_sumVAR_5 = VAR_50VAR_5.VAR_5001VAR_5;", "VAR_5rccVAR_5->VAR_5pass1_wanted_bitsVAR_5 = VAR_50VAR_5.VAR_5001VAR_5;", "VAR_5ifVAR_5 (VAR_5sVAR_5->VAR_5avctxVAR_5->VAR_5qblurVAR_5 > VAR_51VAR_5.VAR_50VAR_5) {", "VAR_5av_logVAR_5(VAR_5sVAR_5->VAR_5avctxVAR_5, VAR_5AV_LOG_ERRORVAR_5, \"VAR_5qblurVAR_5 VAR_5tooVAR_5 VAR_5largeVAR_5\\VAR_5nVAR_5\");", "VAR_5returnVAR_5 -VAR_51VAR_5;", "}", "VAR_5ifVAR_5 (VAR_5sVAR_5->VAR_5rc_initial_cplxVAR_5) {", "VAR_5forVAR_5 (VAR_5VAR_6VAR_5 = VAR_50VAR_5; VAR_5VAR_6VAR_5 < VAR_560VAR_5 * VAR_530VAR_5; VAR_5VAR_6VAR_5++) {", "VAR_5doubleVAR_5 VAR_5bitsVAR_5 = VAR_5sVAR_5->VAR_5rc_initial_cplxVAR_5 * (VAR_5VAR_6VAR_5 / VAR_510000VAR_5.VAR_50VAR_5 + VAR_51VAR_5.VAR_50VAR_5) * VAR_5sVAR_5->VAR_5mb_numVAR_5;", "VAR_5RateControlEntryVAR_5 VAR_5rceVAR_5;", "VAR_5ifVAR_5 (VAR_5VAR_6VAR_5 % ((VAR_5sVAR_5->VAR_5gop_sizeVAR_5 + VAR_53VAR_5) / VAR_54VAR_5) == VAR_50VAR_5)\nVAR_5rceVAR_5.VAR_5pict_typeVAR_5 = VAR_5AV_PICTURE_TYPE_IVAR_5;", "VAR_5elseVAR_5 VAR_5ifVAR_5 (VAR_5VAR_6VAR_5 % (VAR_5sVAR_5->VAR_5max_b_framesVAR_5 + VAR_51VAR_5))\nVAR_5rceVAR_5.VAR_5pict_typeVAR_5 = VAR_5AV_PICTURE_TYPE_BVAR_5;", "VAR_5elseVAR_5\nVAR_5rceVAR_5.VAR_5pict_typeVAR_5 = VAR_5AV_PICTURE_TYPE_PVAR_5;", "VAR_5rceVAR_5.VAR_5new_pict_typeVAR_5 = VAR_5rceVAR_5.VAR_5pict_typeVAR_5;", "VAR_5rceVAR_5.VAR_5mc_mb_var_sumVAR_5 = VAR_5bitsVAR_5 * VAR_5sVAR_5->VAR_5mb_numVAR_5 / VAR_5100000VAR_5;", "VAR_5rceVAR_5.VAR_5mb_var_sumVAR_5 = VAR_5sVAR_5->VAR_5mb_numVAR_5;", "VAR_5rceVAR_5.VAR_5qscaleVAR_5 = VAR_5FF_QP2LAMBDAVAR_5 * VAR_52VAR_5;", "VAR_5rceVAR_5.VAR_5f_codeVAR_5 = VAR_52VAR_5;", "VAR_5rceVAR_5.VAR_5b_codeVAR_5 = VAR_51VAR_5;", "VAR_5rceVAR_5.VAR_5misc_bitsVAR_5 = VAR_51VAR_5;", "VAR_5ifVAR_5 (VAR_5sVAR_5->VAR_5pict_typeVAR_5 == VAR_5AV_PICTURE_TYPE_IVAR_5) {", "VAR_5rceVAR_5.VAR_5i_countVAR_5 = VAR_5sVAR_5->VAR_5mb_numVAR_5;", "VAR_5rceVAR_5.VAR_5i_tex_bitsVAR_5 = VAR_5bitsVAR_5;", "VAR_5rceVAR_5.VAR_5p_tex_bitsVAR_5 = VAR_50VAR_5;", "VAR_5rceVAR_5.VAR_5mv_bitsVAR_5 = VAR_50VAR_5;", "} VAR_5elseVAR_5 {", "VAR_5rceVAR_5.VAR_5i_countVAR_5 = VAR_50VAR_5;", "VAR_5rceVAR_5.VAR_5i_tex_bitsVAR_5 = VAR_50VAR_5;", "VAR_5rceVAR_5.VAR_5p_tex_bitsVAR_5 = VAR_5bitsVAR_5 * VAR_50VAR_5.VAR_59VAR_5;", "VAR_5rceVAR_5.VAR_5mv_bitsVAR_5 = VAR_5bitsVAR_5 * VAR_50VAR_5.VAR_51VAR_5;", "}", "VAR_5rccVAR_5->VAR_5i_cplx_sumVAR_5[VAR_5rceVAR_5.VAR_5pict_typeVAR_5] += VAR_5rceVAR_5.VAR_5i_tex_bitsVAR_5 * VAR_5rceVAR_5.VAR_5qscaleVAR_5;", "VAR_5rccVAR_5->VAR_5p_cplx_sumVAR_5[VAR_5rceVAR_5.VAR_5pict_typeVAR_5] += VAR_5rceVAR_5.VAR_5p_tex_bitsVAR_5 * VAR_5rceVAR_5.VAR_5qscaleVAR_5;", "VAR_5rccVAR_5->VAR_5mv_bits_sumVAR_5[VAR_5rceVAR_5.VAR_5pict_typeVAR_5] += VAR_5rceVAR_5.VAR_5mv_bitsVAR_5;", "VAR_5rccVAR_5->VAR_5frame_countVAR_5[VAR_5rceVAR_5.VAR_5pict_typeVAR_5]++;", "VAR_5get_qscaleVAR_5(VAR_5sVAR_5, &VAR_5rceVAR_5, VAR_5rccVAR_5->VAR_5pass1_wanted_bitsVAR_5 / VAR_5rccVAR_5->VAR_5pass1_rc_eq_output_sumVAR_5, VAR_5VAR_6VAR_5);", "VAR_5rccVAR_5->VAR_5pass1_wanted_bitsVAR_5 += VAR_5sVAR_5->VAR_5bit_rateVAR_5 / VAR_5get_fpsVAR_5(VAR_5sVAR_5->VAR_5avctxVAR_5);", "}", "}", "}", "VAR_5returnVAR_5 VAR_50VAR_5;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65 ], [ 67 ], [ 69, 71, 73, 75 ], [ 77 ], [ 79, 81, 83, 85 ], [ 87 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 105, 107, 109, 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 133, 135, 137, 139, 141 ], [ 145 ], [ 147 ], [ 149 ], [ 151, 153 ], [ 157 ], [ 159 ], [ 161 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175, 177 ], [ 179 ], [ 183 ], [ 191 ], [ 193 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 239 ], [ 241 ], [ 243 ], [ 247, 249, 251, 253, 255, 257 ], [ 259 ], [ 261, 263, 265 ], [ 267 ], [ 269 ], [ 273 ], [ 275 ], [ 279, 281 ], [ 287 ], [ 289, 291 ], [ 293, 295, 297 ], [ 299 ], [ 301, 303 ], [ 305 ], [ 309 ], [ 311 ], [ 313 ], [ 317 ], [ 319 ], [ 323 ], [ 325 ], [ 327 ], [ 329 ], [ 333 ], [ 335 ], [ 337 ], [ 339 ], [ 343, 345 ], [ 347, 349 ], [ 351, 353 ], [ 357 ], [ 359 ], [ 361 ], [ 365 ], [ 367 ], [ 369 ], [ 371 ], [ 375 ], [ 377 ], [ 379 ], [ 381 ], [ 383 ], [ 385 ], [ 387 ], [ 389 ], [ 391 ], [ 393 ], [ 395 ], [ 397 ], [ 399 ], [ 401 ], [ 403 ], [ 407 ], [ 413 ], [ 415 ], [ 417 ], [ 419 ], [ 423 ], [ 425 ] ]
11,382
void trace_event_set_vcpu_state_dynamic(CPUState *vcpu, TraceEvent *ev, bool state) { TraceEventVCPUID vcpu_id; bool state_pre; assert(trace_event_get_state_static(ev)); assert(trace_event_is_vcpu(ev)); vcpu_id = trace_event_get_vcpu_id(ev); state_pre = test_bit(vcpu_id, vcpu->trace_dstate); if (state_pre != state) { if (state) { trace_events_enabled_count++; set_bit(vcpu_id, vcpu->trace_dstate); (*ev->dstate)++; } else { trace_events_enabled_count--; clear_bit(vcpu_id, vcpu->trace_dstate); (*ev->dstate)--; } } }
true
qemu
ef4c9fc8542e06b1d567172c04b0c0377c7ab0c5
void trace_event_set_vcpu_state_dynamic(CPUState *vcpu, TraceEvent *ev, bool state) { TraceEventVCPUID vcpu_id; bool state_pre; assert(trace_event_get_state_static(ev)); assert(trace_event_is_vcpu(ev)); vcpu_id = trace_event_get_vcpu_id(ev); state_pre = test_bit(vcpu_id, vcpu->trace_dstate); if (state_pre != state) { if (state) { trace_events_enabled_count++; set_bit(vcpu_id, vcpu->trace_dstate); (*ev->dstate)++; } else { trace_events_enabled_count--; clear_bit(vcpu_id, vcpu->trace_dstate); (*ev->dstate)--; } } }
{ "code": [ " TraceEventVCPUID vcpu_id;" ], "line_no": [ 7 ] }
void FUNC_0(CPUState *VAR_0, TraceEvent *VAR_1, bool VAR_2) { TraceEventVCPUID vcpu_id; bool state_pre; assert(trace_event_get_state_static(VAR_1)); assert(trace_event_is_vcpu(VAR_1)); vcpu_id = trace_event_get_vcpu_id(VAR_1); state_pre = test_bit(vcpu_id, VAR_0->trace_dstate); if (state_pre != VAR_2) { if (VAR_2) { trace_events_enabled_count++; set_bit(vcpu_id, VAR_0->trace_dstate); (*VAR_1->dstate)++; } else { trace_events_enabled_count--; clear_bit(vcpu_id, VAR_0->trace_dstate); (*VAR_1->dstate)--; } } }
[ "void FUNC_0(CPUState *VAR_0,\nTraceEvent *VAR_1, bool VAR_2)\n{", "TraceEventVCPUID vcpu_id;", "bool state_pre;", "assert(trace_event_get_state_static(VAR_1));", "assert(trace_event_is_vcpu(VAR_1));", "vcpu_id = trace_event_get_vcpu_id(VAR_1);", "state_pre = test_bit(vcpu_id, VAR_0->trace_dstate);", "if (state_pre != VAR_2) {", "if (VAR_2) {", "trace_events_enabled_count++;", "set_bit(vcpu_id, VAR_0->trace_dstate);", "(*VAR_1->dstate)++;", "} else {", "trace_events_enabled_count--;", "clear_bit(vcpu_id, VAR_0->trace_dstate);", "(*VAR_1->dstate)--;", "}", "}", "}" ]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ] ]
11,385
static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value) { struct vmsvga_state_s *s = opaque; if (s->index >= SVGA_SCRATCH_BASE) { trace_vmware_scratch_write(s->index, value); } else if (s->index >= SVGA_PALETTE_BASE) { trace_vmware_palette_write(s->index, value); } else { trace_vmware_value_write(s->index, value); } switch (s->index) { case SVGA_REG_ID: if (value == SVGA_ID_2 || value == SVGA_ID_1 || value == SVGA_ID_0) { s->svgaid = value; } break; case SVGA_REG_ENABLE: s->enable = !!value; s->invalidated = 1; s->vga.hw_ops->invalidate(&s->vga); if (s->enable && s->config) { vga_dirty_log_stop(&s->vga); } else { vga_dirty_log_start(&s->vga); } break; case SVGA_REG_WIDTH: if (value <= SVGA_MAX_WIDTH) { s->new_width = value; s->invalidated = 1; } else { printf("%s: Bad width: %i\n", __func__, value); } break; case SVGA_REG_HEIGHT: if (value <= SVGA_MAX_HEIGHT) { s->new_height = value; s->invalidated = 1; } else { printf("%s: Bad height: %i\n", __func__, value); } break; case SVGA_REG_BITS_PER_PIXEL: if (value != 32) { printf("%s: Bad bits per pixel: %i bits\n", __func__, value); s->config = 0; s->invalidated = 1; } break; case SVGA_REG_CONFIG_DONE: if (value) { s->fifo = (uint32_t *) s->fifo_ptr; /* Check range and alignment. */ if ((CMD(min) | CMD(max) | CMD(next_cmd) | CMD(stop)) & 3) { break; } if (CMD(min) < (uint8_t *) s->cmd->fifo - (uint8_t *) s->fifo) { break; } if (CMD(max) > SVGA_FIFO_SIZE) { break; } if (CMD(max) < CMD(min) + 10 * 1024) { break; } vga_dirty_log_stop(&s->vga); } s->config = !!value; break; case SVGA_REG_SYNC: s->syncing = 1; vmsvga_fifo_run(s); /* Or should we just wait for update_display? */ break; case SVGA_REG_GUEST_ID: s->guest = value; #ifdef VERBOSE if (value >= GUEST_OS_BASE && value < GUEST_OS_BASE + ARRAY_SIZE(vmsvga_guest_id)) { printf("%s: guest runs %s.\n", __func__, vmsvga_guest_id[value - GUEST_OS_BASE]); } #endif break; case SVGA_REG_CURSOR_ID: s->cursor.id = value; break; case SVGA_REG_CURSOR_X: s->cursor.x = value; break; case SVGA_REG_CURSOR_Y: s->cursor.y = value; break; case SVGA_REG_CURSOR_ON: s->cursor.on |= (value == SVGA_CURSOR_ON_SHOW); s->cursor.on &= (value != SVGA_CURSOR_ON_HIDE); #ifdef HW_MOUSE_ACCEL if (value <= SVGA_CURSOR_ON_SHOW) { dpy_mouse_set(s->vga.con, s->cursor.x, s->cursor.y, s->cursor.on); } #endif break; case SVGA_REG_DEPTH: case SVGA_REG_MEM_REGS: case SVGA_REG_NUM_DISPLAYS: case SVGA_REG_PITCHLOCK: case SVGA_PALETTE_BASE ... SVGA_PALETTE_END: break; default: if (s->index >= SVGA_SCRATCH_BASE && s->index < SVGA_SCRATCH_BASE + s->scratch_size) { s->scratch[s->index - SVGA_SCRATCH_BASE] = value; break; } printf("%s: Bad register %02x\n", __func__, s->index); } }
true
qemu
521360267876d3b6518b328051a2e56bca55bef8
static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value) { struct vmsvga_state_s *s = opaque; if (s->index >= SVGA_SCRATCH_BASE) { trace_vmware_scratch_write(s->index, value); } else if (s->index >= SVGA_PALETTE_BASE) { trace_vmware_palette_write(s->index, value); } else { trace_vmware_value_write(s->index, value); } switch (s->index) { case SVGA_REG_ID: if (value == SVGA_ID_2 || value == SVGA_ID_1 || value == SVGA_ID_0) { s->svgaid = value; } break; case SVGA_REG_ENABLE: s->enable = !!value; s->invalidated = 1; s->vga.hw_ops->invalidate(&s->vga); if (s->enable && s->config) { vga_dirty_log_stop(&s->vga); } else { vga_dirty_log_start(&s->vga); } break; case SVGA_REG_WIDTH: if (value <= SVGA_MAX_WIDTH) { s->new_width = value; s->invalidated = 1; } else { printf("%s: Bad width: %i\n", __func__, value); } break; case SVGA_REG_HEIGHT: if (value <= SVGA_MAX_HEIGHT) { s->new_height = value; s->invalidated = 1; } else { printf("%s: Bad height: %i\n", __func__, value); } break; case SVGA_REG_BITS_PER_PIXEL: if (value != 32) { printf("%s: Bad bits per pixel: %i bits\n", __func__, value); s->config = 0; s->invalidated = 1; } break; case SVGA_REG_CONFIG_DONE: if (value) { s->fifo = (uint32_t *) s->fifo_ptr; if ((CMD(min) | CMD(max) | CMD(next_cmd) | CMD(stop)) & 3) { break; } if (CMD(min) < (uint8_t *) s->cmd->fifo - (uint8_t *) s->fifo) { break; } if (CMD(max) > SVGA_FIFO_SIZE) { break; } if (CMD(max) < CMD(min) + 10 * 1024) { break; } vga_dirty_log_stop(&s->vga); } s->config = !!value; break; case SVGA_REG_SYNC: s->syncing = 1; vmsvga_fifo_run(s); break; case SVGA_REG_GUEST_ID: s->guest = value; #ifdef VERBOSE if (value >= GUEST_OS_BASE && value < GUEST_OS_BASE + ARRAY_SIZE(vmsvga_guest_id)) { printf("%s: guest runs %s.\n", __func__, vmsvga_guest_id[value - GUEST_OS_BASE]); } #endif break; case SVGA_REG_CURSOR_ID: s->cursor.id = value; break; case SVGA_REG_CURSOR_X: s->cursor.x = value; break; case SVGA_REG_CURSOR_Y: s->cursor.y = value; break; case SVGA_REG_CURSOR_ON: s->cursor.on |= (value == SVGA_CURSOR_ON_SHOW); s->cursor.on &= (value != SVGA_CURSOR_ON_HIDE); #ifdef HW_MOUSE_ACCEL if (value <= SVGA_CURSOR_ON_SHOW) { dpy_mouse_set(s->vga.con, s->cursor.x, s->cursor.y, s->cursor.on); } #endif break; case SVGA_REG_DEPTH: case SVGA_REG_MEM_REGS: case SVGA_REG_NUM_DISPLAYS: case SVGA_REG_PITCHLOCK: case SVGA_PALETTE_BASE ... SVGA_PALETTE_END: break; default: if (s->index >= SVGA_SCRATCH_BASE && s->index < SVGA_SCRATCH_BASE + s->scratch_size) { s->scratch[s->index - SVGA_SCRATCH_BASE] = value; break; } printf("%s: Bad register %02x\n", __func__, s->index); } }
{ "code": [ " if ((CMD(min) | CMD(max) | CMD(next_cmd) | CMD(stop)) & 3) {", " break;", " if (CMD(min) < (uint8_t *) s->cmd->fifo - (uint8_t *) s->fifo) {", " break;", " if (CMD(max) > SVGA_FIFO_SIZE) {", " break;", " if (CMD(max) < CMD(min) + 10 * 1024) {", " break;" ], "line_no": [ 119, 121, 125, 121, 131, 121, 137, 121 ] }
static void FUNC_0(void *VAR_0, uint32_t VAR_1, uint32_t VAR_2) { struct vmsvga_state_s *VAR_3 = VAR_0; if (VAR_3->index >= SVGA_SCRATCH_BASE) { trace_vmware_scratch_write(VAR_3->index, VAR_2); } else if (VAR_3->index >= SVGA_PALETTE_BASE) { trace_vmware_palette_write(VAR_3->index, VAR_2); } else { trace_vmware_value_write(VAR_3->index, VAR_2); } switch (VAR_3->index) { case SVGA_REG_ID: if (VAR_2 == SVGA_ID_2 || VAR_2 == SVGA_ID_1 || VAR_2 == SVGA_ID_0) { VAR_3->svgaid = VAR_2; } break; case SVGA_REG_ENABLE: VAR_3->enable = !!VAR_2; VAR_3->invalidated = 1; VAR_3->vga.hw_ops->invalidate(&VAR_3->vga); if (VAR_3->enable && VAR_3->config) { vga_dirty_log_stop(&VAR_3->vga); } else { vga_dirty_log_start(&VAR_3->vga); } break; case SVGA_REG_WIDTH: if (VAR_2 <= SVGA_MAX_WIDTH) { VAR_3->new_width = VAR_2; VAR_3->invalidated = 1; } else { printf("%VAR_3: Bad width: %i\n", __func__, VAR_2); } break; case SVGA_REG_HEIGHT: if (VAR_2 <= SVGA_MAX_HEIGHT) { VAR_3->new_height = VAR_2; VAR_3->invalidated = 1; } else { printf("%VAR_3: Bad height: %i\n", __func__, VAR_2); } break; case SVGA_REG_BITS_PER_PIXEL: if (VAR_2 != 32) { printf("%VAR_3: Bad bits per pixel: %i bits\n", __func__, VAR_2); VAR_3->config = 0; VAR_3->invalidated = 1; } break; case SVGA_REG_CONFIG_DONE: if (VAR_2) { VAR_3->fifo = (uint32_t *) VAR_3->fifo_ptr; if ((CMD(min) | CMD(max) | CMD(next_cmd) | CMD(stop)) & 3) { break; } if (CMD(min) < (uint8_t *) VAR_3->cmd->fifo - (uint8_t *) VAR_3->fifo) { break; } if (CMD(max) > SVGA_FIFO_SIZE) { break; } if (CMD(max) < CMD(min) + 10 * 1024) { break; } vga_dirty_log_stop(&VAR_3->vga); } VAR_3->config = !!VAR_2; break; case SVGA_REG_SYNC: VAR_3->syncing = 1; vmsvga_fifo_run(VAR_3); break; case SVGA_REG_GUEST_ID: VAR_3->guest = VAR_2; #ifdef VERBOSE if (VAR_2 >= GUEST_OS_BASE && VAR_2 < GUEST_OS_BASE + ARRAY_SIZE(vmsvga_guest_id)) { printf("%VAR_3: guest runs %VAR_3.\n", __func__, vmsvga_guest_id[VAR_2 - GUEST_OS_BASE]); } #endif break; case SVGA_REG_CURSOR_ID: VAR_3->cursor.id = VAR_2; break; case SVGA_REG_CURSOR_X: VAR_3->cursor.x = VAR_2; break; case SVGA_REG_CURSOR_Y: VAR_3->cursor.y = VAR_2; break; case SVGA_REG_CURSOR_ON: VAR_3->cursor.on |= (VAR_2 == SVGA_CURSOR_ON_SHOW); VAR_3->cursor.on &= (VAR_2 != SVGA_CURSOR_ON_HIDE); #ifdef HW_MOUSE_ACCEL if (VAR_2 <= SVGA_CURSOR_ON_SHOW) { dpy_mouse_set(VAR_3->vga.con, VAR_3->cursor.x, VAR_3->cursor.y, VAR_3->cursor.on); } #endif break; case SVGA_REG_DEPTH: case SVGA_REG_MEM_REGS: case SVGA_REG_NUM_DISPLAYS: case SVGA_REG_PITCHLOCK: case SVGA_PALETTE_BASE ... SVGA_PALETTE_END: break; default: if (VAR_3->index >= SVGA_SCRATCH_BASE && VAR_3->index < SVGA_SCRATCH_BASE + VAR_3->scratch_size) { VAR_3->scratch[VAR_3->index - SVGA_SCRATCH_BASE] = VAR_2; break; } printf("%VAR_3: Bad register %02x\n", __func__, VAR_3->index); } }
[ "static void FUNC_0(void *VAR_0, uint32_t VAR_1, uint32_t VAR_2)\n{", "struct vmsvga_state_s *VAR_3 = VAR_0;", "if (VAR_3->index >= SVGA_SCRATCH_BASE) {", "trace_vmware_scratch_write(VAR_3->index, VAR_2);", "} else if (VAR_3->index >= SVGA_PALETTE_BASE) {", "trace_vmware_palette_write(VAR_3->index, VAR_2);", "} else {", "trace_vmware_value_write(VAR_3->index, VAR_2);", "}", "switch (VAR_3->index) {", "case SVGA_REG_ID:\nif (VAR_2 == SVGA_ID_2 || VAR_2 == SVGA_ID_1 || VAR_2 == SVGA_ID_0) {", "VAR_3->svgaid = VAR_2;", "}", "break;", "case SVGA_REG_ENABLE:\nVAR_3->enable = !!VAR_2;", "VAR_3->invalidated = 1;", "VAR_3->vga.hw_ops->invalidate(&VAR_3->vga);", "if (VAR_3->enable && VAR_3->config) {", "vga_dirty_log_stop(&VAR_3->vga);", "} else {", "vga_dirty_log_start(&VAR_3->vga);", "}", "break;", "case SVGA_REG_WIDTH:\nif (VAR_2 <= SVGA_MAX_WIDTH) {", "VAR_3->new_width = VAR_2;", "VAR_3->invalidated = 1;", "} else {", "printf(\"%VAR_3: Bad width: %i\\n\", __func__, VAR_2);", "}", "break;", "case SVGA_REG_HEIGHT:\nif (VAR_2 <= SVGA_MAX_HEIGHT) {", "VAR_3->new_height = VAR_2;", "VAR_3->invalidated = 1;", "} else {", "printf(\"%VAR_3: Bad height: %i\\n\", __func__, VAR_2);", "}", "break;", "case SVGA_REG_BITS_PER_PIXEL:\nif (VAR_2 != 32) {", "printf(\"%VAR_3: Bad bits per pixel: %i bits\\n\", __func__, VAR_2);", "VAR_3->config = 0;", "VAR_3->invalidated = 1;", "}", "break;", "case SVGA_REG_CONFIG_DONE:\nif (VAR_2) {", "VAR_3->fifo = (uint32_t *) VAR_3->fifo_ptr;", "if ((CMD(min) | CMD(max) | CMD(next_cmd) | CMD(stop)) & 3) {", "break;", "}", "if (CMD(min) < (uint8_t *) VAR_3->cmd->fifo - (uint8_t *) VAR_3->fifo) {", "break;", "}", "if (CMD(max) > SVGA_FIFO_SIZE) {", "break;", "}", "if (CMD(max) < CMD(min) + 10 * 1024) {", "break;", "}", "vga_dirty_log_stop(&VAR_3->vga);", "}", "VAR_3->config = !!VAR_2;", "break;", "case SVGA_REG_SYNC:\nVAR_3->syncing = 1;", "vmsvga_fifo_run(VAR_3);", "break;", "case SVGA_REG_GUEST_ID:\nVAR_3->guest = VAR_2;", "#ifdef VERBOSE\nif (VAR_2 >= GUEST_OS_BASE && VAR_2 < GUEST_OS_BASE +\nARRAY_SIZE(vmsvga_guest_id)) {", "printf(\"%VAR_3: guest runs %VAR_3.\\n\", __func__,\nvmsvga_guest_id[VAR_2 - GUEST_OS_BASE]);", "}", "#endif\nbreak;", "case SVGA_REG_CURSOR_ID:\nVAR_3->cursor.id = VAR_2;", "break;", "case SVGA_REG_CURSOR_X:\nVAR_3->cursor.x = VAR_2;", "break;", "case SVGA_REG_CURSOR_Y:\nVAR_3->cursor.y = VAR_2;", "break;", "case SVGA_REG_CURSOR_ON:\nVAR_3->cursor.on |= (VAR_2 == SVGA_CURSOR_ON_SHOW);", "VAR_3->cursor.on &= (VAR_2 != SVGA_CURSOR_ON_HIDE);", "#ifdef HW_MOUSE_ACCEL\nif (VAR_2 <= SVGA_CURSOR_ON_SHOW) {", "dpy_mouse_set(VAR_3->vga.con, VAR_3->cursor.x, VAR_3->cursor.y, VAR_3->cursor.on);", "}", "#endif\nbreak;", "case SVGA_REG_DEPTH:\ncase SVGA_REG_MEM_REGS:\ncase SVGA_REG_NUM_DISPLAYS:\ncase SVGA_REG_PITCHLOCK:\ncase SVGA_PALETTE_BASE ... SVGA_PALETTE_END:\nbreak;", "default:\nif (VAR_3->index >= SVGA_SCRATCH_BASE &&\nVAR_3->index < SVGA_SCRATCH_BASE + VAR_3->scratch_size) {", "VAR_3->scratch[VAR_3->index - SVGA_SCRATCH_BASE] = VAR_2;", "break;", "}", "printf(\"%VAR_3: Bad register %02x\\n\", __func__, VAR_3->index);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1, 0, 0, 1, 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 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25, 27 ], [ 29 ], [ 31 ], [ 33 ], [ 37, 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 59, 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 77, 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 95, 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 111, 113 ], [ 115 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 153, 155 ], [ 157 ], [ 159 ], [ 163, 165 ], [ 167, 169, 171 ], [ 173, 175 ], [ 177 ], [ 179, 181 ], [ 185, 187 ], [ 189 ], [ 193, 195 ], [ 197 ], [ 201, 203 ], [ 205 ], [ 209, 211 ], [ 213 ], [ 215, 217 ], [ 219 ], [ 221 ], [ 223, 225 ], [ 229, 231, 233, 235, 237, 239 ], [ 243, 245, 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ] ]
11,386
int main (int argc, char **argv) { int ret = 0, got_frame; if (argc != 4) { fprintf(stderr, "usage: %s input_file video_output_file audio_output_file\n" "API example program to show how to read frames from an input file.\n" "This program reads frames from a file, decodes them, and writes decoded\n" "video frames to a rawvideo file named video_output_file, and decoded\n" "audio frames to a rawaudio file named audio_output_file.\n" "\n", argv[0]); exit(1); } src_filename = argv[1]; video_dst_filename = argv[2]; audio_dst_filename = argv[3]; /* register all formats and codecs */ av_register_all(); /* open input file, and allocate format context */ if (avformat_open_input(&fmt_ctx, src_filename, NULL, NULL) < 0) { fprintf(stderr, "Could not open source file %s\n", src_filename); exit(1); } /* retrieve stream information */ if (avformat_find_stream_info(fmt_ctx, NULL) < 0) { fprintf(stderr, "Could not find stream information\n"); exit(1); } if (open_codec_context(&video_stream_idx, fmt_ctx, AVMEDIA_TYPE_VIDEO) >= 0) { video_stream = fmt_ctx->streams[video_stream_idx]; video_dec_ctx = video_stream->codec; video_dst_file = fopen(video_dst_filename, "wb"); if (!video_dst_file) { fprintf(stderr, "Could not open destination file %s\n", video_dst_filename); ret = 1; goto end; } /* allocate image where the decoded image will be put */ ret = av_image_alloc(video_dst_data, video_dst_linesize, video_dec_ctx->width, video_dec_ctx->height, video_dec_ctx->pix_fmt, 1); if (ret < 0) { fprintf(stderr, "Could not allocate raw video buffer\n"); goto end; } video_dst_bufsize = ret; } if (open_codec_context(&audio_stream_idx, fmt_ctx, AVMEDIA_TYPE_AUDIO) >= 0) { int nb_planes; audio_stream = fmt_ctx->streams[audio_stream_idx]; audio_dec_ctx = audio_stream->codec; audio_dst_file = fopen(audio_dst_filename, "wb"); if (!audio_dst_file) { fprintf(stderr, "Could not open destination file %s\n", video_dst_filename); ret = 1; goto end; } nb_planes = av_sample_fmt_is_planar(audio_dec_ctx->sample_fmt) ? audio_dec_ctx->channels : 1; audio_dst_data = av_mallocz(sizeof(uint8_t *) * nb_planes); if (!audio_dst_data) { fprintf(stderr, "Could not allocate audio data buffers\n"); ret = AVERROR(ENOMEM); goto end; } } /* dump input information to stderr */ av_dump_format(fmt_ctx, 0, src_filename, 0); if (!audio_stream && !video_stream) { fprintf(stderr, "Could not find audio or video stream in the input, aborting\n"); ret = 1; goto end; } frame = avcodec_alloc_frame(); if (!frame) { fprintf(stderr, "Could not allocate frame\n"); ret = AVERROR(ENOMEM); goto end; } /* initialize packet, set data to NULL, let the demuxer fill it */ av_init_packet(&pkt); pkt.data = NULL; pkt.size = 0; if (video_stream) printf("Demuxing video from file '%s' into '%s'\n", src_filename, video_dst_filename); if (audio_stream) printf("Demuxing audio from file '%s' into '%s'\n", src_filename, audio_dst_filename); /* read frames from the file */ while (av_read_frame(fmt_ctx, &pkt) >= 0) decode_packet(&got_frame, 0); /* flush cached frames */ pkt.data = NULL; pkt.size = 0; do { decode_packet(&got_frame, 1); } while (got_frame); printf("Demuxing succeeded.\n"); if (video_stream) { printf("Play the output video file with the command:\n" "ffplay -f rawvideo -pix_fmt %s -video_size %dx%d %s\n", av_get_pix_fmt_name(video_dec_ctx->pix_fmt), video_dec_ctx->width, video_dec_ctx->height, video_dst_filename); } if (audio_stream) { const char *fmt; if ((ret = get_format_from_sample_fmt(&fmt, audio_dec_ctx->sample_fmt)) < 0) goto end; printf("Play the output audio file with the command:\n" "ffplay -f %s -ac %d -ar %d %s\n", fmt, audio_dec_ctx->channels, audio_dec_ctx->sample_rate, audio_dst_filename); } end: if (video_dec_ctx) avcodec_close(video_dec_ctx); if (audio_dec_ctx) avcodec_close(audio_dec_ctx); avformat_close_input(&fmt_ctx); if (video_dst_file) fclose(video_dst_file); if (audio_dst_file) fclose(audio_dst_file); av_free(frame); av_free(video_dst_data[0]); av_free(audio_dst_data); return ret < 0; }
true
FFmpeg
e7a39e163ddbde85f966132194143d0338445a0c
int main (int argc, char **argv) { int ret = 0, got_frame; if (argc != 4) { fprintf(stderr, "usage: %s input_file video_output_file audio_output_file\n" "API example program to show how to read frames from an input file.\n" "This program reads frames from a file, decodes them, and writes decoded\n" "video frames to a rawvideo file named video_output_file, and decoded\n" "audio frames to a rawaudio file named audio_output_file.\n" "\n", argv[0]); exit(1); } src_filename = argv[1]; video_dst_filename = argv[2]; audio_dst_filename = argv[3]; av_register_all(); if (avformat_open_input(&fmt_ctx, src_filename, NULL, NULL) < 0) { fprintf(stderr, "Could not open source file %s\n", src_filename); exit(1); } if (avformat_find_stream_info(fmt_ctx, NULL) < 0) { fprintf(stderr, "Could not find stream information\n"); exit(1); } if (open_codec_context(&video_stream_idx, fmt_ctx, AVMEDIA_TYPE_VIDEO) >= 0) { video_stream = fmt_ctx->streams[video_stream_idx]; video_dec_ctx = video_stream->codec; video_dst_file = fopen(video_dst_filename, "wb"); if (!video_dst_file) { fprintf(stderr, "Could not open destination file %s\n", video_dst_filename); ret = 1; goto end; } ret = av_image_alloc(video_dst_data, video_dst_linesize, video_dec_ctx->width, video_dec_ctx->height, video_dec_ctx->pix_fmt, 1); if (ret < 0) { fprintf(stderr, "Could not allocate raw video buffer\n"); goto end; } video_dst_bufsize = ret; } if (open_codec_context(&audio_stream_idx, fmt_ctx, AVMEDIA_TYPE_AUDIO) >= 0) { int nb_planes; audio_stream = fmt_ctx->streams[audio_stream_idx]; audio_dec_ctx = audio_stream->codec; audio_dst_file = fopen(audio_dst_filename, "wb"); if (!audio_dst_file) { fprintf(stderr, "Could not open destination file %s\n", video_dst_filename); ret = 1; goto end; } nb_planes = av_sample_fmt_is_planar(audio_dec_ctx->sample_fmt) ? audio_dec_ctx->channels : 1; audio_dst_data = av_mallocz(sizeof(uint8_t *) * nb_planes); if (!audio_dst_data) { fprintf(stderr, "Could not allocate audio data buffers\n"); ret = AVERROR(ENOMEM); goto end; } } av_dump_format(fmt_ctx, 0, src_filename, 0); if (!audio_stream && !video_stream) { fprintf(stderr, "Could not find audio or video stream in the input, aborting\n"); ret = 1; goto end; } frame = avcodec_alloc_frame(); if (!frame) { fprintf(stderr, "Could not allocate frame\n"); ret = AVERROR(ENOMEM); goto end; } av_init_packet(&pkt); pkt.data = NULL; pkt.size = 0; if (video_stream) printf("Demuxing video from file '%s' into '%s'\n", src_filename, video_dst_filename); if (audio_stream) printf("Demuxing audio from file '%s' into '%s'\n", src_filename, audio_dst_filename); while (av_read_frame(fmt_ctx, &pkt) >= 0) decode_packet(&got_frame, 0); pkt.data = NULL; pkt.size = 0; do { decode_packet(&got_frame, 1); } while (got_frame); printf("Demuxing succeeded.\n"); if (video_stream) { printf("Play the output video file with the command:\n" "ffplay -f rawvideo -pix_fmt %s -video_size %dx%d %s\n", av_get_pix_fmt_name(video_dec_ctx->pix_fmt), video_dec_ctx->width, video_dec_ctx->height, video_dst_filename); } if (audio_stream) { const char *fmt; if ((ret = get_format_from_sample_fmt(&fmt, audio_dec_ctx->sample_fmt)) < 0) goto end; printf("Play the output audio file with the command:\n" "ffplay -f %s -ac %d -ar %d %s\n", fmt, audio_dec_ctx->channels, audio_dec_ctx->sample_rate, audio_dst_filename); } end: if (video_dec_ctx) avcodec_close(video_dec_ctx); if (audio_dec_ctx) avcodec_close(audio_dec_ctx); avformat_close_input(&fmt_ctx); if (video_dst_file) fclose(video_dst_file); if (audio_dst_file) fclose(audio_dst_file); av_free(frame); av_free(video_dst_data[0]); av_free(audio_dst_data); return ret < 0; }
{ "code": [ " while (av_read_frame(fmt_ctx, &pkt) >= 0)" ], "line_no": [ 207 ] }
int FUNC_0 (int VAR_0, char **VAR_1) { int VAR_2 = 0, VAR_3; if (VAR_0 != 4) { fprintf(stderr, "usage: %s input_file video_output_file audio_output_file\n" "API example program to show how to read frames from an input file.\n" "This program reads frames from a file, decodes them, and writes decoded\n" "video frames to a rawvideo file named video_output_file, and decoded\n" "audio frames to a rawaudio file named audio_output_file.\n" "\n", VAR_1[0]); exit(1); } src_filename = VAR_1[1]; video_dst_filename = VAR_1[2]; audio_dst_filename = VAR_1[3]; av_register_all(); if (avformat_open_input(&fmt_ctx, src_filename, NULL, NULL) < 0) { fprintf(stderr, "Could not open source file %s\n", src_filename); exit(1); } if (avformat_find_stream_info(fmt_ctx, NULL) < 0) { fprintf(stderr, "Could not find stream information\n"); exit(1); } if (open_codec_context(&video_stream_idx, fmt_ctx, AVMEDIA_TYPE_VIDEO) >= 0) { video_stream = fmt_ctx->streams[video_stream_idx]; video_dec_ctx = video_stream->codec; video_dst_file = fopen(video_dst_filename, "wb"); if (!video_dst_file) { fprintf(stderr, "Could not open destination file %s\n", video_dst_filename); VAR_2 = 1; goto end; } VAR_2 = av_image_alloc(video_dst_data, video_dst_linesize, video_dec_ctx->width, video_dec_ctx->height, video_dec_ctx->pix_fmt, 1); if (VAR_2 < 0) { fprintf(stderr, "Could not allocate raw video buffer\n"); goto end; } video_dst_bufsize = VAR_2; } if (open_codec_context(&audio_stream_idx, fmt_ctx, AVMEDIA_TYPE_AUDIO) >= 0) { int VAR_4; audio_stream = fmt_ctx->streams[audio_stream_idx]; audio_dec_ctx = audio_stream->codec; audio_dst_file = fopen(audio_dst_filename, "wb"); if (!audio_dst_file) { fprintf(stderr, "Could not open destination file %s\n", video_dst_filename); VAR_2 = 1; goto end; } VAR_4 = av_sample_fmt_is_planar(audio_dec_ctx->sample_fmt) ? audio_dec_ctx->channels : 1; audio_dst_data = av_mallocz(sizeof(uint8_t *) * VAR_4); if (!audio_dst_data) { fprintf(stderr, "Could not allocate audio data buffers\n"); VAR_2 = AVERROR(ENOMEM); goto end; } } av_dump_format(fmt_ctx, 0, src_filename, 0); if (!audio_stream && !video_stream) { fprintf(stderr, "Could not find audio or video stream in the input, aborting\n"); VAR_2 = 1; goto end; } frame = avcodec_alloc_frame(); if (!frame) { fprintf(stderr, "Could not allocate frame\n"); VAR_2 = AVERROR(ENOMEM); goto end; } av_init_packet(&pkt); pkt.data = NULL; pkt.size = 0; if (video_stream) printf("Demuxing video from file '%s' into '%s'\n", src_filename, video_dst_filename); if (audio_stream) printf("Demuxing audio from file '%s' into '%s'\n", src_filename, audio_dst_filename); while (av_read_frame(fmt_ctx, &pkt) >= 0) decode_packet(&VAR_3, 0); pkt.data = NULL; pkt.size = 0; do { decode_packet(&VAR_3, 1); } while (VAR_3); printf("Demuxing succeeded.\n"); if (video_stream) { printf("Play the output video file with the command:\n" "ffplay -f rawvideo -pix_fmt %s -video_size %dx%d %s\n", av_get_pix_fmt_name(video_dec_ctx->pix_fmt), video_dec_ctx->width, video_dec_ctx->height, video_dst_filename); } if (audio_stream) { const char *VAR_5; if ((VAR_2 = get_format_from_sample_fmt(&VAR_5, audio_dec_ctx->sample_fmt)) < 0) goto end; printf("Play the output audio file with the command:\n" "ffplay -f %s -ac %d -ar %d %s\n", VAR_5, audio_dec_ctx->channels, audio_dec_ctx->sample_rate, audio_dst_filename); } end: if (video_dec_ctx) avcodec_close(video_dec_ctx); if (audio_dec_ctx) avcodec_close(audio_dec_ctx); avformat_close_input(&fmt_ctx); if (video_dst_file) fclose(video_dst_file); if (audio_dst_file) fclose(audio_dst_file); av_free(frame); av_free(video_dst_data[0]); av_free(audio_dst_data); return VAR_2 < 0; }
[ "int FUNC_0 (int VAR_0, char **VAR_1)\n{", "int VAR_2 = 0, VAR_3;", "if (VAR_0 != 4) {", "fprintf(stderr, \"usage: %s input_file video_output_file audio_output_file\\n\"\n\"API example program to show how to read frames from an input file.\\n\"\n\"This program reads frames from a file, decodes them, and writes decoded\\n\"\n\"video frames to a rawvideo file named video_output_file, and decoded\\n\"\n\"audio frames to a rawaudio file named audio_output_file.\\n\"\n\"\\n\", VAR_1[0]);", "exit(1);", "}", "src_filename = VAR_1[1];", "video_dst_filename = VAR_1[2];", "audio_dst_filename = VAR_1[3];", "av_register_all();", "if (avformat_open_input(&fmt_ctx, src_filename, NULL, NULL) < 0) {", "fprintf(stderr, \"Could not open source file %s\\n\", src_filename);", "exit(1);", "}", "if (avformat_find_stream_info(fmt_ctx, NULL) < 0) {", "fprintf(stderr, \"Could not find stream information\\n\");", "exit(1);", "}", "if (open_codec_context(&video_stream_idx, fmt_ctx, AVMEDIA_TYPE_VIDEO) >= 0) {", "video_stream = fmt_ctx->streams[video_stream_idx];", "video_dec_ctx = video_stream->codec;", "video_dst_file = fopen(video_dst_filename, \"wb\");", "if (!video_dst_file) {", "fprintf(stderr, \"Could not open destination file %s\\n\", video_dst_filename);", "VAR_2 = 1;", "goto end;", "}", "VAR_2 = av_image_alloc(video_dst_data, video_dst_linesize,\nvideo_dec_ctx->width, video_dec_ctx->height,\nvideo_dec_ctx->pix_fmt, 1);", "if (VAR_2 < 0) {", "fprintf(stderr, \"Could not allocate raw video buffer\\n\");", "goto end;", "}", "video_dst_bufsize = VAR_2;", "}", "if (open_codec_context(&audio_stream_idx, fmt_ctx, AVMEDIA_TYPE_AUDIO) >= 0) {", "int VAR_4;", "audio_stream = fmt_ctx->streams[audio_stream_idx];", "audio_dec_ctx = audio_stream->codec;", "audio_dst_file = fopen(audio_dst_filename, \"wb\");", "if (!audio_dst_file) {", "fprintf(stderr, \"Could not open destination file %s\\n\", video_dst_filename);", "VAR_2 = 1;", "goto end;", "}", "VAR_4 = av_sample_fmt_is_planar(audio_dec_ctx->sample_fmt) ?\naudio_dec_ctx->channels : 1;", "audio_dst_data = av_mallocz(sizeof(uint8_t *) * VAR_4);", "if (!audio_dst_data) {", "fprintf(stderr, \"Could not allocate audio data buffers\\n\");", "VAR_2 = AVERROR(ENOMEM);", "goto end;", "}", "}", "av_dump_format(fmt_ctx, 0, src_filename, 0);", "if (!audio_stream && !video_stream) {", "fprintf(stderr, \"Could not find audio or video stream in the input, aborting\\n\");", "VAR_2 = 1;", "goto end;", "}", "frame = avcodec_alloc_frame();", "if (!frame) {", "fprintf(stderr, \"Could not allocate frame\\n\");", "VAR_2 = AVERROR(ENOMEM);", "goto end;", "}", "av_init_packet(&pkt);", "pkt.data = NULL;", "pkt.size = 0;", "if (video_stream)\nprintf(\"Demuxing video from file '%s' into '%s'\\n\", src_filename, video_dst_filename);", "if (audio_stream)\nprintf(\"Demuxing audio from file '%s' into '%s'\\n\", src_filename, audio_dst_filename);", "while (av_read_frame(fmt_ctx, &pkt) >= 0)\ndecode_packet(&VAR_3, 0);", "pkt.data = NULL;", "pkt.size = 0;", "do {", "decode_packet(&VAR_3, 1);", "} while (VAR_3);", "printf(\"Demuxing succeeded.\\n\");", "if (video_stream) {", "printf(\"Play the output video file with the command:\\n\"\n\"ffplay -f rawvideo -pix_fmt %s -video_size %dx%d %s\\n\",\nav_get_pix_fmt_name(video_dec_ctx->pix_fmt), video_dec_ctx->width, video_dec_ctx->height,\nvideo_dst_filename);", "}", "if (audio_stream) {", "const char *VAR_5;", "if ((VAR_2 = get_format_from_sample_fmt(&VAR_5, audio_dec_ctx->sample_fmt)) < 0)\ngoto end;", "printf(\"Play the output audio file with the command:\\n\"\n\"ffplay -f %s -ac %d -ar %d %s\\n\",\nVAR_5, audio_dec_ctx->channels, audio_dec_ctx->sample_rate,\naudio_dst_filename);", "}", "end:\nif (video_dec_ctx)\navcodec_close(video_dec_ctx);", "if (audio_dec_ctx)\navcodec_close(audio_dec_ctx);", "avformat_close_input(&fmt_ctx);", "if (video_dst_file)\nfclose(video_dst_file);", "if (audio_dst_file)\nfclose(audio_dst_file);", "av_free(frame);", "av_free(video_dst_data[0]);", "av_free(audio_dst_data);", "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, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11, 13, 15, 17, 19, 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 37 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 89, 91, 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 109 ], [ 111 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 133, 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 155 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 187 ], [ 189 ], [ 191 ], [ 195, 197 ], [ 199, 201 ], [ 207, 209 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 227 ], [ 231 ], [ 233, 235, 237, 239 ], [ 241 ], [ 245 ], [ 247 ], [ 251, 253 ], [ 255, 257, 259, 261 ], [ 263 ], [ 267, 269, 271 ], [ 273, 275 ], [ 277 ], [ 279, 281 ], [ 283, 285 ], [ 287 ], [ 289 ], [ 291 ], [ 295 ], [ 297 ] ]
11,387
static av_cold int truemotion1_decode_init(AVCodecContext *avctx) { TrueMotion1Context *s = avctx->priv_data; s->avctx = avctx; // FIXME: it may change ? // if (avctx->bits_per_sample == 24) // avctx->pix_fmt = AV_PIX_FMT_RGB24; // else // avctx->pix_fmt = AV_PIX_FMT_RGB555; s->frame.data[0] = NULL; /* there is a vertical predictor for each pixel in a line; each vertical * predictor is 0 to start with */ av_fast_malloc(&s->vert_pred, &s->vert_pred_size, s->avctx->width * sizeof(unsigned int)); return 0; }
false
FFmpeg
3b199d29cd597a3518136d78860e172060b9e83d
static av_cold int truemotion1_decode_init(AVCodecContext *avctx) { TrueMotion1Context *s = avctx->priv_data; s->avctx = avctx; s->frame.data[0] = NULL; av_fast_malloc(&s->vert_pred, &s->vert_pred_size, s->avctx->width * sizeof(unsigned int)); return 0; }
{ "code": [], "line_no": [] }
static av_cold int FUNC_0(AVCodecContext *avctx) { TrueMotion1Context *s = avctx->priv_data; s->avctx = avctx; s->frame.data[0] = NULL; av_fast_malloc(&s->vert_pred, &s->vert_pred_size, s->avctx->width * sizeof(unsigned int)); return 0; }
[ "static av_cold int FUNC_0(AVCodecContext *avctx)\n{", "TrueMotion1Context *s = avctx->priv_data;", "s->avctx = avctx;", "s->frame.data[0] = NULL;", "av_fast_malloc(&s->vert_pred, &s->vert_pred_size, s->avctx->width * sizeof(unsigned int));", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 25 ], [ 33 ], [ 37 ], [ 39 ] ]
11,389
static int h264_export_frame_props(H264Context *h) { const SPS *sps = h->ps.sps; H264Picture *cur = h->cur_pic_ptr; cur->f->interlaced_frame = 0; cur->f->repeat_pict = 0; /* Signal interlacing information externally. */ /* Prioritize picture timing SEI information over used * decoding process if it exists. */ if (sps->pic_struct_present_flag) { H264SEIPictureTiming *pt = &h->sei.picture_timing; switch (pt->pic_struct) { case SEI_PIC_STRUCT_FRAME: break; case SEI_PIC_STRUCT_TOP_FIELD: case SEI_PIC_STRUCT_BOTTOM_FIELD: cur->f->interlaced_frame = 1; break; case SEI_PIC_STRUCT_TOP_BOTTOM: case SEI_PIC_STRUCT_BOTTOM_TOP: if (FIELD_OR_MBAFF_PICTURE(h)) cur->f->interlaced_frame = 1; else // try to flag soft telecine progressive cur->f->interlaced_frame = h->prev_interlaced_frame; break; case SEI_PIC_STRUCT_TOP_BOTTOM_TOP: case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM: /* Signal the possibility of telecined film externally * (pic_struct 5,6). From these hints, let the applications * decide if they apply deinterlacing. */ cur->f->repeat_pict = 1; break; case SEI_PIC_STRUCT_FRAME_DOUBLING: cur->f->repeat_pict = 2; break; case SEI_PIC_STRUCT_FRAME_TRIPLING: cur->f->repeat_pict = 4; break; } if ((pt->ct_type & 3) && pt->pic_struct <= SEI_PIC_STRUCT_BOTTOM_TOP) cur->f->interlaced_frame = (pt->ct_type & (1 << 1)) != 0; } else { /* Derive interlacing flag from used decoding process. */ cur->f->interlaced_frame = FIELD_OR_MBAFF_PICTURE(h); } h->prev_interlaced_frame = cur->f->interlaced_frame; if (cur->field_poc[0] != cur->field_poc[1]) { /* Derive top_field_first from field pocs. */ cur->f->top_field_first = cur->field_poc[0] < cur->field_poc[1]; } else { if (cur->f->interlaced_frame || sps->pic_struct_present_flag) { /* Use picture timing SEI information. Even if it is a * information of a past frame, better than nothing. */ if (h->sei.picture_timing.pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM || h->sei.picture_timing.pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP) cur->f->top_field_first = 1; else cur->f->top_field_first = 0; } else { /* Most likely progressive */ cur->f->top_field_first = 0; } } if (h->sei.frame_packing.present && h->sei.frame_packing.arrangement_type >= 0 && h->sei.frame_packing.arrangement_type <= 6 && h->sei.frame_packing.content_interpretation_type > 0 && h->sei.frame_packing.content_interpretation_type < 3) { H264SEIFramePacking *fp = &h->sei.frame_packing; AVStereo3D *stereo = av_stereo3d_create_side_data(cur->f); if (!stereo) return AVERROR(ENOMEM); switch (fp->arrangement_type) { case 0: stereo->type = AV_STEREO3D_CHECKERBOARD; break; case 1: stereo->type = AV_STEREO3D_COLUMNS; break; case 2: stereo->type = AV_STEREO3D_LINES; break; case 3: if (fp->quincunx_subsampling) stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX; else stereo->type = AV_STEREO3D_SIDEBYSIDE; break; case 4: stereo->type = AV_STEREO3D_TOPBOTTOM; break; case 5: stereo->type = AV_STEREO3D_FRAMESEQUENCE; break; case 6: stereo->type = AV_STEREO3D_2D; break; } if (fp->content_interpretation_type == 2) stereo->flags = AV_STEREO3D_FLAG_INVERT; } if (h->sei.display_orientation.present && (h->sei.display_orientation.anticlockwise_rotation || h->sei.display_orientation.hflip || h->sei.display_orientation.vflip)) { H264SEIDisplayOrientation *o = &h->sei.display_orientation; double angle = o->anticlockwise_rotation * 360 / (double) (1 << 16); AVFrameSideData *rotation = av_frame_new_side_data(cur->f, AV_FRAME_DATA_DISPLAYMATRIX, sizeof(int32_t) * 9); if (!rotation) return AVERROR(ENOMEM); av_display_rotation_set((int32_t *)rotation->data, angle); av_display_matrix_flip((int32_t *)rotation->data, o->hflip, o->vflip); } if (h->sei.afd.present) { AVFrameSideData *sd = av_frame_new_side_data(cur->f, AV_FRAME_DATA_AFD, sizeof(uint8_t)); if (!sd) return AVERROR(ENOMEM); *sd->data = h->sei.afd.active_format_description; h->sei.afd.present = 0; } if (h->sei.a53_caption.a53_caption) { H264SEIA53Caption *a53 = &h->sei.a53_caption; AVFrameSideData *sd = av_frame_new_side_data(cur->f, AV_FRAME_DATA_A53_CC, a53->a53_caption_size); if (!sd) return AVERROR(ENOMEM); memcpy(sd->data, a53->a53_caption, a53->a53_caption_size); av_freep(&a53->a53_caption); a53->a53_caption_size = 0; } return 0; }
false
FFmpeg
d7b2bb5391bf55e8f9421bff7feb4c1fddfac4bf
static int h264_export_frame_props(H264Context *h) { const SPS *sps = h->ps.sps; H264Picture *cur = h->cur_pic_ptr; cur->f->interlaced_frame = 0; cur->f->repeat_pict = 0; if (sps->pic_struct_present_flag) { H264SEIPictureTiming *pt = &h->sei.picture_timing; switch (pt->pic_struct) { case SEI_PIC_STRUCT_FRAME: break; case SEI_PIC_STRUCT_TOP_FIELD: case SEI_PIC_STRUCT_BOTTOM_FIELD: cur->f->interlaced_frame = 1; break; case SEI_PIC_STRUCT_TOP_BOTTOM: case SEI_PIC_STRUCT_BOTTOM_TOP: if (FIELD_OR_MBAFF_PICTURE(h)) cur->f->interlaced_frame = 1; else cur->f->interlaced_frame = h->prev_interlaced_frame; break; case SEI_PIC_STRUCT_TOP_BOTTOM_TOP: case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM: cur->f->repeat_pict = 1; break; case SEI_PIC_STRUCT_FRAME_DOUBLING: cur->f->repeat_pict = 2; break; case SEI_PIC_STRUCT_FRAME_TRIPLING: cur->f->repeat_pict = 4; break; } if ((pt->ct_type & 3) && pt->pic_struct <= SEI_PIC_STRUCT_BOTTOM_TOP) cur->f->interlaced_frame = (pt->ct_type & (1 << 1)) != 0; } else { cur->f->interlaced_frame = FIELD_OR_MBAFF_PICTURE(h); } h->prev_interlaced_frame = cur->f->interlaced_frame; if (cur->field_poc[0] != cur->field_poc[1]) { cur->f->top_field_first = cur->field_poc[0] < cur->field_poc[1]; } else { if (cur->f->interlaced_frame || sps->pic_struct_present_flag) { if (h->sei.picture_timing.pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM || h->sei.picture_timing.pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP) cur->f->top_field_first = 1; else cur->f->top_field_first = 0; } else { cur->f->top_field_first = 0; } } if (h->sei.frame_packing.present && h->sei.frame_packing.arrangement_type >= 0 && h->sei.frame_packing.arrangement_type <= 6 && h->sei.frame_packing.content_interpretation_type > 0 && h->sei.frame_packing.content_interpretation_type < 3) { H264SEIFramePacking *fp = &h->sei.frame_packing; AVStereo3D *stereo = av_stereo3d_create_side_data(cur->f); if (!stereo) return AVERROR(ENOMEM); switch (fp->arrangement_type) { case 0: stereo->type = AV_STEREO3D_CHECKERBOARD; break; case 1: stereo->type = AV_STEREO3D_COLUMNS; break; case 2: stereo->type = AV_STEREO3D_LINES; break; case 3: if (fp->quincunx_subsampling) stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX; else stereo->type = AV_STEREO3D_SIDEBYSIDE; break; case 4: stereo->type = AV_STEREO3D_TOPBOTTOM; break; case 5: stereo->type = AV_STEREO3D_FRAMESEQUENCE; break; case 6: stereo->type = AV_STEREO3D_2D; break; } if (fp->content_interpretation_type == 2) stereo->flags = AV_STEREO3D_FLAG_INVERT; } if (h->sei.display_orientation.present && (h->sei.display_orientation.anticlockwise_rotation || h->sei.display_orientation.hflip || h->sei.display_orientation.vflip)) { H264SEIDisplayOrientation *o = &h->sei.display_orientation; double angle = o->anticlockwise_rotation * 360 / (double) (1 << 16); AVFrameSideData *rotation = av_frame_new_side_data(cur->f, AV_FRAME_DATA_DISPLAYMATRIX, sizeof(int32_t) * 9); if (!rotation) return AVERROR(ENOMEM); av_display_rotation_set((int32_t *)rotation->data, angle); av_display_matrix_flip((int32_t *)rotation->data, o->hflip, o->vflip); } if (h->sei.afd.present) { AVFrameSideData *sd = av_frame_new_side_data(cur->f, AV_FRAME_DATA_AFD, sizeof(uint8_t)); if (!sd) return AVERROR(ENOMEM); *sd->data = h->sei.afd.active_format_description; h->sei.afd.present = 0; } if (h->sei.a53_caption.a53_caption) { H264SEIA53Caption *a53 = &h->sei.a53_caption; AVFrameSideData *sd = av_frame_new_side_data(cur->f, AV_FRAME_DATA_A53_CC, a53->a53_caption_size); if (!sd) return AVERROR(ENOMEM); memcpy(sd->data, a53->a53_caption, a53->a53_caption_size); av_freep(&a53->a53_caption); a53->a53_caption_size = 0; } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(H264Context *VAR_0) { const SPS *VAR_1 = VAR_0->ps.VAR_1; H264Picture *cur = VAR_0->cur_pic_ptr; cur->f->interlaced_frame = 0; cur->f->repeat_pict = 0; if (VAR_1->pic_struct_present_flag) { H264SEIPictureTiming *pt = &VAR_0->sei.picture_timing; switch (pt->pic_struct) { case SEI_PIC_STRUCT_FRAME: break; case SEI_PIC_STRUCT_TOP_FIELD: case SEI_PIC_STRUCT_BOTTOM_FIELD: cur->f->interlaced_frame = 1; break; case SEI_PIC_STRUCT_TOP_BOTTOM: case SEI_PIC_STRUCT_BOTTOM_TOP: if (FIELD_OR_MBAFF_PICTURE(VAR_0)) cur->f->interlaced_frame = 1; else cur->f->interlaced_frame = VAR_0->prev_interlaced_frame; break; case SEI_PIC_STRUCT_TOP_BOTTOM_TOP: case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM: cur->f->repeat_pict = 1; break; case SEI_PIC_STRUCT_FRAME_DOUBLING: cur->f->repeat_pict = 2; break; case SEI_PIC_STRUCT_FRAME_TRIPLING: cur->f->repeat_pict = 4; break; } if ((pt->ct_type & 3) && pt->pic_struct <= SEI_PIC_STRUCT_BOTTOM_TOP) cur->f->interlaced_frame = (pt->ct_type & (1 << 1)) != 0; } else { cur->f->interlaced_frame = FIELD_OR_MBAFF_PICTURE(VAR_0); } VAR_0->prev_interlaced_frame = cur->f->interlaced_frame; if (cur->field_poc[0] != cur->field_poc[1]) { cur->f->top_field_first = cur->field_poc[0] < cur->field_poc[1]; } else { if (cur->f->interlaced_frame || VAR_1->pic_struct_present_flag) { if (VAR_0->sei.picture_timing.pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM || VAR_0->sei.picture_timing.pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP) cur->f->top_field_first = 1; else cur->f->top_field_first = 0; } else { cur->f->top_field_first = 0; } } if (VAR_0->sei.frame_packing.present && VAR_0->sei.frame_packing.arrangement_type >= 0 && VAR_0->sei.frame_packing.arrangement_type <= 6 && VAR_0->sei.frame_packing.content_interpretation_type > 0 && VAR_0->sei.frame_packing.content_interpretation_type < 3) { H264SEIFramePacking *fp = &VAR_0->sei.frame_packing; AVStereo3D *stereo = av_stereo3d_create_side_data(cur->f); if (!stereo) return AVERROR(ENOMEM); switch (fp->arrangement_type) { case 0: stereo->type = AV_STEREO3D_CHECKERBOARD; break; case 1: stereo->type = AV_STEREO3D_COLUMNS; break; case 2: stereo->type = AV_STEREO3D_LINES; break; case 3: if (fp->quincunx_subsampling) stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX; else stereo->type = AV_STEREO3D_SIDEBYSIDE; break; case 4: stereo->type = AV_STEREO3D_TOPBOTTOM; break; case 5: stereo->type = AV_STEREO3D_FRAMESEQUENCE; break; case 6: stereo->type = AV_STEREO3D_2D; break; } if (fp->content_interpretation_type == 2) stereo->flags = AV_STEREO3D_FLAG_INVERT; } if (VAR_0->sei.display_orientation.present && (VAR_0->sei.display_orientation.anticlockwise_rotation || VAR_0->sei.display_orientation.hflip || VAR_0->sei.display_orientation.vflip)) { H264SEIDisplayOrientation *o = &VAR_0->sei.display_orientation; double VAR_2 = o->anticlockwise_rotation * 360 / (double) (1 << 16); AVFrameSideData *rotation = av_frame_new_side_data(cur->f, AV_FRAME_DATA_DISPLAYMATRIX, sizeof(int32_t) * 9); if (!rotation) return AVERROR(ENOMEM); av_display_rotation_set((int32_t *)rotation->data, VAR_2); av_display_matrix_flip((int32_t *)rotation->data, o->hflip, o->vflip); } if (VAR_0->sei.afd.present) { AVFrameSideData *sd = av_frame_new_side_data(cur->f, AV_FRAME_DATA_AFD, sizeof(uint8_t)); if (!sd) return AVERROR(ENOMEM); *sd->data = VAR_0->sei.afd.active_format_description; VAR_0->sei.afd.present = 0; } if (VAR_0->sei.a53_caption.a53_caption) { H264SEIA53Caption *a53 = &VAR_0->sei.a53_caption; AVFrameSideData *sd = av_frame_new_side_data(cur->f, AV_FRAME_DATA_A53_CC, a53->a53_caption_size); if (!sd) return AVERROR(ENOMEM); memcpy(sd->data, a53->a53_caption, a53->a53_caption_size); av_freep(&a53->a53_caption); a53->a53_caption_size = 0; } return 0; }
[ "static int FUNC_0(H264Context *VAR_0)\n{", "const SPS *VAR_1 = VAR_0->ps.VAR_1;", "H264Picture *cur = VAR_0->cur_pic_ptr;", "cur->f->interlaced_frame = 0;", "cur->f->repeat_pict = 0;", "if (VAR_1->pic_struct_present_flag) {", "H264SEIPictureTiming *pt = &VAR_0->sei.picture_timing;", "switch (pt->pic_struct) {", "case SEI_PIC_STRUCT_FRAME:\nbreak;", "case SEI_PIC_STRUCT_TOP_FIELD:\ncase SEI_PIC_STRUCT_BOTTOM_FIELD:\ncur->f->interlaced_frame = 1;", "break;", "case SEI_PIC_STRUCT_TOP_BOTTOM:\ncase SEI_PIC_STRUCT_BOTTOM_TOP:\nif (FIELD_OR_MBAFF_PICTURE(VAR_0))\ncur->f->interlaced_frame = 1;", "else\ncur->f->interlaced_frame = VAR_0->prev_interlaced_frame;", "break;", "case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:\ncase SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:\ncur->f->repeat_pict = 1;", "break;", "case SEI_PIC_STRUCT_FRAME_DOUBLING:\ncur->f->repeat_pict = 2;", "break;", "case SEI_PIC_STRUCT_FRAME_TRIPLING:\ncur->f->repeat_pict = 4;", "break;", "}", "if ((pt->ct_type & 3) &&\npt->pic_struct <= SEI_PIC_STRUCT_BOTTOM_TOP)\ncur->f->interlaced_frame = (pt->ct_type & (1 << 1)) != 0;", "} else {", "cur->f->interlaced_frame = FIELD_OR_MBAFF_PICTURE(VAR_0);", "}", "VAR_0->prev_interlaced_frame = cur->f->interlaced_frame;", "if (cur->field_poc[0] != cur->field_poc[1]) {", "cur->f->top_field_first = cur->field_poc[0] < cur->field_poc[1];", "} else {", "if (cur->f->interlaced_frame || VAR_1->pic_struct_present_flag) {", "if (VAR_0->sei.picture_timing.pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM ||\nVAR_0->sei.picture_timing.pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP)\ncur->f->top_field_first = 1;", "else\ncur->f->top_field_first = 0;", "} else {", "cur->f->top_field_first = 0;", "}", "}", "if (VAR_0->sei.frame_packing.present &&\nVAR_0->sei.frame_packing.arrangement_type >= 0 &&\nVAR_0->sei.frame_packing.arrangement_type <= 6 &&\nVAR_0->sei.frame_packing.content_interpretation_type > 0 &&\nVAR_0->sei.frame_packing.content_interpretation_type < 3) {", "H264SEIFramePacking *fp = &VAR_0->sei.frame_packing;", "AVStereo3D *stereo = av_stereo3d_create_side_data(cur->f);", "if (!stereo)\nreturn AVERROR(ENOMEM);", "switch (fp->arrangement_type) {", "case 0:\nstereo->type = AV_STEREO3D_CHECKERBOARD;", "break;", "case 1:\nstereo->type = AV_STEREO3D_COLUMNS;", "break;", "case 2:\nstereo->type = AV_STEREO3D_LINES;", "break;", "case 3:\nif (fp->quincunx_subsampling)\nstereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX;", "else\nstereo->type = AV_STEREO3D_SIDEBYSIDE;", "break;", "case 4:\nstereo->type = AV_STEREO3D_TOPBOTTOM;", "break;", "case 5:\nstereo->type = AV_STEREO3D_FRAMESEQUENCE;", "break;", "case 6:\nstereo->type = AV_STEREO3D_2D;", "break;", "}", "if (fp->content_interpretation_type == 2)\nstereo->flags = AV_STEREO3D_FLAG_INVERT;", "}", "if (VAR_0->sei.display_orientation.present &&\n(VAR_0->sei.display_orientation.anticlockwise_rotation ||\nVAR_0->sei.display_orientation.hflip ||\nVAR_0->sei.display_orientation.vflip)) {", "H264SEIDisplayOrientation *o = &VAR_0->sei.display_orientation;", "double VAR_2 = o->anticlockwise_rotation * 360 / (double) (1 << 16);", "AVFrameSideData *rotation = av_frame_new_side_data(cur->f,\nAV_FRAME_DATA_DISPLAYMATRIX,\nsizeof(int32_t) * 9);", "if (!rotation)\nreturn AVERROR(ENOMEM);", "av_display_rotation_set((int32_t *)rotation->data, VAR_2);", "av_display_matrix_flip((int32_t *)rotation->data,\no->hflip, o->vflip);", "}", "if (VAR_0->sei.afd.present) {", "AVFrameSideData *sd = av_frame_new_side_data(cur->f, AV_FRAME_DATA_AFD,\nsizeof(uint8_t));", "if (!sd)\nreturn AVERROR(ENOMEM);", "*sd->data = VAR_0->sei.afd.active_format_description;", "VAR_0->sei.afd.present = 0;", "}", "if (VAR_0->sei.a53_caption.a53_caption) {", "H264SEIA53Caption *a53 = &VAR_0->sei.a53_caption;", "AVFrameSideData *sd = av_frame_new_side_data(cur->f,\nAV_FRAME_DATA_A53_CC,\na53->a53_caption_size);", "if (!sd)\nreturn AVERROR(ENOMEM);", "memcpy(sd->data, a53->a53_caption, a53->a53_caption_size);", "av_freep(&a53->a53_caption);", "a53->a53_caption_size = 0;", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 25 ], [ 27 ], [ 29 ], [ 31, 33 ], [ 35, 37, 39 ], [ 41 ], [ 43, 45, 47, 49 ], [ 51, 55 ], [ 57 ], [ 59, 61, 69 ], [ 71 ], [ 73, 75 ], [ 77 ], [ 79, 81 ], [ 83 ], [ 85 ], [ 89, 91, 93 ], [ 95 ], [ 99 ], [ 101 ], [ 103 ], [ 107 ], [ 111 ], [ 113 ], [ 115 ], [ 121, 123, 125 ], [ 127, 129 ], [ 131 ], [ 135 ], [ 137 ], [ 139 ], [ 143, 145, 147, 149, 151 ], [ 153 ], [ 155 ], [ 157, 159 ], [ 163 ], [ 165, 167 ], [ 169 ], [ 171, 173 ], [ 175 ], [ 177, 179 ], [ 181 ], [ 183, 185, 187 ], [ 189, 191 ], [ 193 ], [ 195, 197 ], [ 199 ], [ 201, 203 ], [ 205 ], [ 207, 209 ], [ 211 ], [ 213 ], [ 217, 219 ], [ 221 ], [ 225, 227, 229, 231 ], [ 233 ], [ 235 ], [ 237, 239, 241 ], [ 243, 245 ], [ 249 ], [ 251, 253 ], [ 255 ], [ 259 ], [ 261, 263 ], [ 265, 267 ], [ 271 ], [ 273 ], [ 275 ], [ 279 ], [ 281 ], [ 283, 285, 287 ], [ 289, 291 ], [ 295 ], [ 297 ], [ 299 ], [ 301 ], [ 305 ], [ 307 ] ]
11,390
static int colo_packet_compare_icmp(Packet *spkt, Packet *ppkt) { int network_header_length = ppkt->ip->ip_hl * 4; trace_colo_compare_main("compare icmp"); /* * Because of ppkt and spkt are both in the same connection, * The ppkt's src ip, dst ip, src port, dst port, ip_proto all are * same with spkt. In addition, IP header's Identification is a random * field, we can handle it in IP fragmentation function later. * COLO just concern the response net packet payload from primary guest * and secondary guest are same or not, So we ignored all IP header include * other field like TOS,TTL,IP Checksum. we only need to compare * the ip payload here. */ if (colo_packet_compare_common(ppkt, spkt, network_header_length + ETH_HLEN)) { trace_colo_compare_icmp_miscompare("primary pkt size", ppkt->size); trace_colo_compare_icmp_miscompare("Secondary pkt size", spkt->size); if (trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) { qemu_hexdump((char *)ppkt->data, stderr, "colo-compare pri pkt", ppkt->size); qemu_hexdump((char *)spkt->data, stderr, "colo-compare sec pkt", spkt->size); } return -1; } else { return 0; } }
true
qemu
d87aa138039a4be6d705793fd3e397c69c52405a
static int colo_packet_compare_icmp(Packet *spkt, Packet *ppkt) { int network_header_length = ppkt->ip->ip_hl * 4; trace_colo_compare_main("compare icmp"); if (colo_packet_compare_common(ppkt, spkt, network_header_length + ETH_HLEN)) { trace_colo_compare_icmp_miscompare("primary pkt size", ppkt->size); trace_colo_compare_icmp_miscompare("Secondary pkt size", spkt->size); if (trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) { qemu_hexdump((char *)ppkt->data, stderr, "colo-compare pri pkt", ppkt->size); qemu_hexdump((char *)spkt->data, stderr, "colo-compare sec pkt", spkt->size); } return -1; } else { return 0; } }
{ "code": [ " if (trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {", " if (trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {" ], "line_no": [ 45, 45 ] }
static int FUNC_0(Packet *VAR_0, Packet *VAR_1) { int VAR_2 = VAR_1->ip->ip_hl * 4; trace_colo_compare_main("compare icmp"); if (colo_packet_compare_common(VAR_1, VAR_0, VAR_2 + ETH_HLEN)) { trace_colo_compare_icmp_miscompare("primary pkt size", VAR_1->size); trace_colo_compare_icmp_miscompare("Secondary pkt size", VAR_0->size); if (trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) { qemu_hexdump((char *)VAR_1->data, stderr, "colo-compare pri pkt", VAR_1->size); qemu_hexdump((char *)VAR_0->data, stderr, "colo-compare sec pkt", VAR_0->size); } return -1; } else { return 0; } }
[ "static int FUNC_0(Packet *VAR_0, Packet *VAR_1)\n{", "int VAR_2 = VAR_1->ip->ip_hl * 4;", "trace_colo_compare_main(\"compare icmp\");", "if (colo_packet_compare_common(VAR_1, VAR_0,\nVAR_2 + ETH_HLEN)) {", "trace_colo_compare_icmp_miscompare(\"primary pkt size\",\nVAR_1->size);", "trace_colo_compare_icmp_miscompare(\"Secondary pkt size\",\nVAR_0->size);", "if (trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {", "qemu_hexdump((char *)VAR_1->data, stderr, \"colo-compare pri pkt\",\nVAR_1->size);", "qemu_hexdump((char *)VAR_0->data, stderr, \"colo-compare sec pkt\",\nVAR_0->size);", "}", "return -1;", "} else {", "return 0;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 33, 35 ], [ 37, 39 ], [ 41, 43 ], [ 45 ], [ 47, 49 ], [ 51, 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ] ]
11,391
static int caca_write_header(AVFormatContext *s) { CACAContext *c = s->priv_data; AVStream *st = s->streams[0]; AVCodecContext *encctx = st->codec; int ret, bpp; c->ctx = s; if (c->list_drivers) { list_drivers(c); return AVERROR_EXIT; } if (c->list_dither) { if (!strcmp(c->list_dither, "colors")) { list_dither_color(c); } else if (!strcmp(c->list_dither, "charsets")) { list_dither_charset(c); } else if (!strcmp(c->list_dither, "algorithms")) { list_dither_algorithm(c); } else if (!strcmp(c->list_dither, "antialiases")) { list_dither_antialias(c); } else { av_log(s, AV_LOG_ERROR, "Invalid argument '%s', for 'list_dither' option\n" "Argument must be one of 'algorithms, 'antialiases', 'charsets', 'colors'\n", c->list_dither); return AVERROR(EINVAL); } return AVERROR_EXIT; } if ( s->nb_streams > 1 || encctx->codec_type != AVMEDIA_TYPE_VIDEO || encctx->codec_id != CODEC_ID_RAWVIDEO) { av_log(s, AV_LOG_ERROR, "Only supports one rawvideo stream\n"); return AVERROR(EINVAL); } if (encctx->pix_fmt != PIX_FMT_RGB24) { av_log(s, AV_LOG_ERROR, "Unsupported pixel format '%s', choose rgb24\n", av_get_pix_fmt_name(encctx->pix_fmt)); return AVERROR(EINVAL); } c->canvas = caca_create_canvas(c->window_width, c->window_height); if (!c->canvas) { av_log(s, AV_LOG_ERROR, "Failed to create canvas\n"); return AVERROR(errno); } c->display = caca_create_display_with_driver(c->canvas, c->driver); if (!c->display) { av_log(s, AV_LOG_ERROR, "Failed to create display\n"); list_drivers(c); caca_free_canvas(c->canvas); return AVERROR(errno); } if (!c->window_width || !c->window_height) { c->window_width = caca_get_canvas_width(c->canvas); c->window_height = caca_get_canvas_height(c->canvas); } bpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[encctx->pix_fmt]); c->dither = caca_create_dither(bpp, encctx->width, encctx->height, bpp / 8 * encctx->width, 0x0000ff, 0x00ff00, 0xff0000, 0); if (!c->dither) { av_log(s, AV_LOG_ERROR, "Failed to create dither\n"); ret = AVERROR(errno); goto fail; } #define CHECK_DITHER_OPT(opt) \ if (caca_set_dither_##opt(c->dither, c->opt) < 0) { \ ret = AVERROR(errno); \ av_log(s, AV_LOG_ERROR, "Failed to set value '%s' for option '%s'\n", \ c->opt, #opt); \ goto fail; \ } CHECK_DITHER_OPT(algorithm); CHECK_DITHER_OPT(antialias); CHECK_DITHER_OPT(charset); CHECK_DITHER_OPT(color); if (!c->window_title) c->window_title = av_strdup(s->filename); caca_set_display_title(c->display, c->window_title); caca_set_display_time(c->display, av_rescale_q(1, st->codec->time_base, AV_TIME_BASE_Q)); return 0; fail: caca_write_trailer(s); return ret; }
true
FFmpeg
c0b91348fe4aec7d2245d95ccabb460a6971e361
static int caca_write_header(AVFormatContext *s) { CACAContext *c = s->priv_data; AVStream *st = s->streams[0]; AVCodecContext *encctx = st->codec; int ret, bpp; c->ctx = s; if (c->list_drivers) { list_drivers(c); return AVERROR_EXIT; } if (c->list_dither) { if (!strcmp(c->list_dither, "colors")) { list_dither_color(c); } else if (!strcmp(c->list_dither, "charsets")) { list_dither_charset(c); } else if (!strcmp(c->list_dither, "algorithms")) { list_dither_algorithm(c); } else if (!strcmp(c->list_dither, "antialiases")) { list_dither_antialias(c); } else { av_log(s, AV_LOG_ERROR, "Invalid argument '%s', for 'list_dither' option\n" "Argument must be one of 'algorithms, 'antialiases', 'charsets', 'colors'\n", c->list_dither); return AVERROR(EINVAL); } return AVERROR_EXIT; } if ( s->nb_streams > 1 || encctx->codec_type != AVMEDIA_TYPE_VIDEO || encctx->codec_id != CODEC_ID_RAWVIDEO) { av_log(s, AV_LOG_ERROR, "Only supports one rawvideo stream\n"); return AVERROR(EINVAL); } if (encctx->pix_fmt != PIX_FMT_RGB24) { av_log(s, AV_LOG_ERROR, "Unsupported pixel format '%s', choose rgb24\n", av_get_pix_fmt_name(encctx->pix_fmt)); return AVERROR(EINVAL); } c->canvas = caca_create_canvas(c->window_width, c->window_height); if (!c->canvas) { av_log(s, AV_LOG_ERROR, "Failed to create canvas\n"); return AVERROR(errno); } c->display = caca_create_display_with_driver(c->canvas, c->driver); if (!c->display) { av_log(s, AV_LOG_ERROR, "Failed to create display\n"); list_drivers(c); caca_free_canvas(c->canvas); return AVERROR(errno); } if (!c->window_width || !c->window_height) { c->window_width = caca_get_canvas_width(c->canvas); c->window_height = caca_get_canvas_height(c->canvas); } bpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[encctx->pix_fmt]); c->dither = caca_create_dither(bpp, encctx->width, encctx->height, bpp / 8 * encctx->width, 0x0000ff, 0x00ff00, 0xff0000, 0); if (!c->dither) { av_log(s, AV_LOG_ERROR, "Failed to create dither\n"); ret = AVERROR(errno); goto fail; } #define CHECK_DITHER_OPT(opt) \ if (caca_set_dither_##opt(c->dither, c->opt) < 0) { \ ret = AVERROR(errno); \ av_log(s, AV_LOG_ERROR, "Failed to set value '%s' for option '%s'\n", \ c->opt, #opt); \ goto fail; \ } CHECK_DITHER_OPT(algorithm); CHECK_DITHER_OPT(antialias); CHECK_DITHER_OPT(charset); CHECK_DITHER_OPT(color); if (!c->window_title) c->window_title = av_strdup(s->filename); caca_set_display_title(c->display, c->window_title); caca_set_display_time(c->display, av_rescale_q(1, st->codec->time_base, AV_TIME_BASE_Q)); return 0; fail: caca_write_trailer(s); return ret; }
{ "code": [ " return AVERROR(errno);", " c->display = caca_create_display_with_driver(c->canvas, c->driver);", " if (!c->display) {", " av_log(s, AV_LOG_ERROR, \"Failed to create display\\n\");", " list_drivers(c);", " caca_free_canvas(c->canvas);", " return AVERROR(errno);", " if (!c->window_width || !c->window_height) {", " c->window_width = caca_get_canvas_width(c->canvas);", " c->window_height = caca_get_canvas_height(c->canvas);" ], "line_no": [ 97, 103, 105, 107, 19, 111, 97, 119, 121, 123 ] }
static int FUNC_0(AVFormatContext *VAR_0) { CACAContext *c = VAR_0->priv_data; AVStream *st = VAR_0->streams[0]; AVCodecContext *encctx = st->codec; int VAR_1, VAR_2; c->ctx = VAR_0; if (c->list_drivers) { list_drivers(c); return AVERROR_EXIT; } if (c->list_dither) { if (!strcmp(c->list_dither, "colors")) { list_dither_color(c); } else if (!strcmp(c->list_dither, "charsets")) { list_dither_charset(c); } else if (!strcmp(c->list_dither, "algorithms")) { list_dither_algorithm(c); } else if (!strcmp(c->list_dither, "antialiases")) { list_dither_antialias(c); } else { av_log(VAR_0, AV_LOG_ERROR, "Invalid argument '%VAR_0', for 'list_dither' option\n" "Argument must be one of 'algorithms, 'antialiases', 'charsets', 'colors'\n", c->list_dither); return AVERROR(EINVAL); } return AVERROR_EXIT; } if ( VAR_0->nb_streams > 1 || encctx->codec_type != AVMEDIA_TYPE_VIDEO || encctx->codec_id != CODEC_ID_RAWVIDEO) { av_log(VAR_0, AV_LOG_ERROR, "Only supports one rawvideo stream\n"); return AVERROR(EINVAL); } if (encctx->pix_fmt != PIX_FMT_RGB24) { av_log(VAR_0, AV_LOG_ERROR, "Unsupported pixel format '%VAR_0', choose rgb24\n", av_get_pix_fmt_name(encctx->pix_fmt)); return AVERROR(EINVAL); } c->canvas = caca_create_canvas(c->window_width, c->window_height); if (!c->canvas) { av_log(VAR_0, AV_LOG_ERROR, "Failed to create canvas\n"); return AVERROR(errno); } c->display = caca_create_display_with_driver(c->canvas, c->driver); if (!c->display) { av_log(VAR_0, AV_LOG_ERROR, "Failed to create display\n"); list_drivers(c); caca_free_canvas(c->canvas); return AVERROR(errno); } if (!c->window_width || !c->window_height) { c->window_width = caca_get_canvas_width(c->canvas); c->window_height = caca_get_canvas_height(c->canvas); } VAR_2 = av_get_bits_per_pixel(&av_pix_fmt_descriptors[encctx->pix_fmt]); c->dither = caca_create_dither(VAR_2, encctx->width, encctx->height, VAR_2 / 8 * encctx->width, 0x0000ff, 0x00ff00, 0xff0000, 0); if (!c->dither) { av_log(VAR_0, AV_LOG_ERROR, "Failed to create dither\n"); VAR_1 = AVERROR(errno); goto fail; } #define CHECK_DITHER_OPT(opt) \ if (caca_set_dither_##opt(c->dither, c->opt) < 0) { \ VAR_1 = AVERROR(errno); \ av_log(VAR_0, AV_LOG_ERROR, "Failed to set value '%VAR_0' for option '%VAR_0'\n", \ c->opt, #opt); \ goto fail; \ } CHECK_DITHER_OPT(algorithm); CHECK_DITHER_OPT(antialias); CHECK_DITHER_OPT(charset); CHECK_DITHER_OPT(color); if (!c->window_title) c->window_title = av_strdup(VAR_0->filename); caca_set_display_title(c->display, c->window_title); caca_set_display_time(c->display, av_rescale_q(1, st->codec->time_base, AV_TIME_BASE_Q)); return 0; fail: caca_write_trailer(VAR_0); return VAR_1; }
[ "static int FUNC_0(AVFormatContext *VAR_0)\n{", "CACAContext *c = VAR_0->priv_data;", "AVStream *st = VAR_0->streams[0];", "AVCodecContext *encctx = st->codec;", "int VAR_1, VAR_2;", "c->ctx = VAR_0;", "if (c->list_drivers) {", "list_drivers(c);", "return AVERROR_EXIT;", "}", "if (c->list_dither) {", "if (!strcmp(c->list_dither, \"colors\")) {", "list_dither_color(c);", "} else if (!strcmp(c->list_dither, \"charsets\")) {", "list_dither_charset(c);", "} else if (!strcmp(c->list_dither, \"algorithms\")) {", "list_dither_algorithm(c);", "} else if (!strcmp(c->list_dither, \"antialiases\")) {", "list_dither_antialias(c);", "} else {", "av_log(VAR_0, AV_LOG_ERROR,\n\"Invalid argument '%VAR_0', for 'list_dither' option\\n\"\n\"Argument must be one of 'algorithms, 'antialiases', 'charsets', 'colors'\\n\",\nc->list_dither);", "return AVERROR(EINVAL);", "}", "return AVERROR_EXIT;", "}", "if ( VAR_0->nb_streams > 1\n|| encctx->codec_type != AVMEDIA_TYPE_VIDEO\n|| encctx->codec_id != CODEC_ID_RAWVIDEO) {", "av_log(VAR_0, AV_LOG_ERROR, \"Only supports one rawvideo stream\\n\");", "return AVERROR(EINVAL);", "}", "if (encctx->pix_fmt != PIX_FMT_RGB24) {", "av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported pixel format '%VAR_0', choose rgb24\\n\",\nav_get_pix_fmt_name(encctx->pix_fmt));", "return AVERROR(EINVAL);", "}", "c->canvas = caca_create_canvas(c->window_width, c->window_height);", "if (!c->canvas) {", "av_log(VAR_0, AV_LOG_ERROR, \"Failed to create canvas\\n\");", "return AVERROR(errno);", "}", "c->display = caca_create_display_with_driver(c->canvas, c->driver);", "if (!c->display) {", "av_log(VAR_0, AV_LOG_ERROR, \"Failed to create display\\n\");", "list_drivers(c);", "caca_free_canvas(c->canvas);", "return AVERROR(errno);", "}", "if (!c->window_width || !c->window_height) {", "c->window_width = caca_get_canvas_width(c->canvas);", "c->window_height = caca_get_canvas_height(c->canvas);", "}", "VAR_2 = av_get_bits_per_pixel(&av_pix_fmt_descriptors[encctx->pix_fmt]);", "c->dither = caca_create_dither(VAR_2, encctx->width, encctx->height,\nVAR_2 / 8 * encctx->width,\n0x0000ff, 0x00ff00, 0xff0000, 0);", "if (!c->dither) {", "av_log(VAR_0, AV_LOG_ERROR, \"Failed to create dither\\n\");", "VAR_1 = AVERROR(errno);", "goto fail;", "}", "#define CHECK_DITHER_OPT(opt) \\\nif (caca_set_dither_##opt(c->dither, c->opt) < 0) { \\", "VAR_1 = AVERROR(errno); \\", "av_log(VAR_0, AV_LOG_ERROR, \"Failed to set value '%VAR_0' for option '%VAR_0'\\n\", \\\nc->opt, #opt); \\", "goto fail; \\", "}", "CHECK_DITHER_OPT(algorithm);", "CHECK_DITHER_OPT(antialias);", "CHECK_DITHER_OPT(charset);", "CHECK_DITHER_OPT(color);", "if (!c->window_title)\nc->window_title = av_strdup(VAR_0->filename);", "caca_set_display_title(c->display, c->window_title);", "caca_set_display_time(c->display, av_rescale_q(1, st->codec->time_base, AV_TIME_BASE_Q));", "return 0;", "fail:\ncaca_write_trailer(VAR_0);", "return VAR_1;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 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 ], [ 63, 65, 67 ], [ 69 ], [ 71 ], [ 73 ], [ 77 ], [ 79, 81, 83 ], [ 85 ], [ 87 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 129 ], [ 131, 133, 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 149, 151 ], [ 153 ], [ 155, 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 173, 175 ], [ 177 ], [ 179 ], [ 183 ], [ 187, 189 ], [ 191 ], [ 193 ] ]
11,392
static int mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *segment) { int i, length; segment->nb_index_entries = avio_rb32(pb); length = avio_rb32(pb); if (!(segment->temporal_offset_entries=av_calloc(segment->nb_index_entries, sizeof(*segment->temporal_offset_entries))) || !(segment->flag_entries = av_calloc(segment->nb_index_entries, sizeof(*segment->flag_entries))) || !(segment->stream_offset_entries = av_calloc(segment->nb_index_entries, sizeof(*segment->stream_offset_entries)))) { av_freep(&segment->temporal_offset_entries); av_freep(&segment->flag_entries); return AVERROR(ENOMEM); } for (i = 0; i < segment->nb_index_entries; i++) { if(avio_feof(pb)) segment->temporal_offset_entries[i] = avio_r8(pb); avio_r8(pb); /* KeyFrameOffset */ segment->flag_entries[i] = avio_r8(pb); segment->stream_offset_entries[i] = avio_rb64(pb); avio_skip(pb, length - 11); } return 0; }
true
FFmpeg
900f39692ca0337a98a7cf047e4e2611071810c2
static int mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *segment) { int i, length; segment->nb_index_entries = avio_rb32(pb); length = avio_rb32(pb); if (!(segment->temporal_offset_entries=av_calloc(segment->nb_index_entries, sizeof(*segment->temporal_offset_entries))) || !(segment->flag_entries = av_calloc(segment->nb_index_entries, sizeof(*segment->flag_entries))) || !(segment->stream_offset_entries = av_calloc(segment->nb_index_entries, sizeof(*segment->stream_offset_entries)))) { av_freep(&segment->temporal_offset_entries); av_freep(&segment->flag_entries); return AVERROR(ENOMEM); } for (i = 0; i < segment->nb_index_entries; i++) { if(avio_feof(pb)) segment->temporal_offset_entries[i] = avio_r8(pb); avio_r8(pb); segment->flag_entries[i] = avio_r8(pb); segment->stream_offset_entries[i] = avio_rb64(pb); avio_skip(pb, length - 11); } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVIOContext *VAR_0, MXFIndexTableSegment *VAR_1) { int VAR_2, VAR_3; VAR_1->nb_index_entries = avio_rb32(VAR_0); VAR_3 = avio_rb32(VAR_0); if (!(VAR_1->temporal_offset_entries=av_calloc(VAR_1->nb_index_entries, sizeof(*VAR_1->temporal_offset_entries))) || !(VAR_1->flag_entries = av_calloc(VAR_1->nb_index_entries, sizeof(*VAR_1->flag_entries))) || !(VAR_1->stream_offset_entries = av_calloc(VAR_1->nb_index_entries, sizeof(*VAR_1->stream_offset_entries)))) { av_freep(&VAR_1->temporal_offset_entries); av_freep(&VAR_1->flag_entries); return AVERROR(ENOMEM); } for (VAR_2 = 0; VAR_2 < VAR_1->nb_index_entries; VAR_2++) { if(avio_feof(VAR_0)) VAR_1->temporal_offset_entries[VAR_2] = avio_r8(VAR_0); avio_r8(VAR_0); VAR_1->flag_entries[VAR_2] = avio_r8(VAR_0); VAR_1->stream_offset_entries[VAR_2] = avio_rb64(VAR_0); avio_skip(VAR_0, VAR_3 - 11); } return 0; }
[ "static int FUNC_0(AVIOContext *VAR_0, MXFIndexTableSegment *VAR_1)\n{", "int VAR_2, VAR_3;", "VAR_1->nb_index_entries = avio_rb32(VAR_0);", "VAR_3 = avio_rb32(VAR_0);", "if (!(VAR_1->temporal_offset_entries=av_calloc(VAR_1->nb_index_entries, sizeof(*VAR_1->temporal_offset_entries))) ||\n!(VAR_1->flag_entries = av_calloc(VAR_1->nb_index_entries, sizeof(*VAR_1->flag_entries))) ||\n!(VAR_1->stream_offset_entries = av_calloc(VAR_1->nb_index_entries, sizeof(*VAR_1->stream_offset_entries)))) {", "av_freep(&VAR_1->temporal_offset_entries);", "av_freep(&VAR_1->flag_entries);", "return AVERROR(ENOMEM);", "}", "for (VAR_2 = 0; VAR_2 < VAR_1->nb_index_entries; VAR_2++) {", "if(avio_feof(VAR_0))\nVAR_1->temporal_offset_entries[VAR_2] = avio_r8(VAR_0);", "avio_r8(VAR_0);", "VAR_1->flag_entries[VAR_2] = avio_r8(VAR_0);", "VAR_1->stream_offset_entries[VAR_2] = avio_rb64(VAR_0);", "avio_skip(VAR_0, VAR_3 - 11);", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 13 ], [ 19, 21, 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37, 40 ], [ 42 ], [ 44 ], [ 46 ], [ 48 ], [ 50 ], [ 52 ], [ 54 ] ]
11,393
uint64_t hbitmap_serialization_granularity(const HBitmap *hb) { /* Must hold true so that the shift below is defined * (ld(64) == 6, i.e. 1 << 6 == 64) */ assert(hb->granularity < 64 - 6); /* Require at least 64 bit granularity to be safe on both 64 bit and 32 bit * hosts. */ return UINT64_C(64) << hb->granularity; }
true
qemu
20a579de8484096d18e65751ebe63fee31551f04
uint64_t hbitmap_serialization_granularity(const HBitmap *hb) { assert(hb->granularity < 64 - 6); return UINT64_C(64) << hb->granularity; }
{ "code": [ " assert(hb->granularity < 64 - 6);" ], "line_no": [ 9 ] }
uint64_t FUNC_0(const HBitmap *hb) { assert(hb->granularity < 64 - 6); return UINT64_C(64) << hb->granularity; }
[ "uint64_t FUNC_0(const HBitmap *hb)\n{", "assert(hb->granularity < 64 - 6);", "return UINT64_C(64) << hb->granularity;", "}" ]
[ 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 9 ], [ 17 ], [ 19 ] ]
11,394
void helper_store_sdr1(CPUPPCState *env, target_ulong val) { ppc_store_sdr1(env, val); }
true
qemu
f3c75d42adbba553eaf218a832d4fbea32c8f7b8
void helper_store_sdr1(CPUPPCState *env, target_ulong val) { ppc_store_sdr1(env, val); }
{ "code": [ " ppc_store_sdr1(env, val);" ], "line_no": [ 5 ] }
void FUNC_0(CPUPPCState *VAR_0, target_ulong VAR_1) { ppc_store_sdr1(VAR_0, VAR_1); }
[ "void FUNC_0(CPUPPCState *VAR_0, target_ulong VAR_1)\n{", "ppc_store_sdr1(VAR_0, VAR_1);", "}" ]
[ 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
11,395
static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size) { VP56RangeCoder *c = &s->c; int part1_size, hscale, vscale, i, j, ret; int width = s->avctx->width; int height = s->avctx->height; s->profile = (buf[0] >> 1) & 7; if (s->profile > 1) { avpriv_request_sample(s->avctx, "Unknown profile %d", s->profile); return AVERROR_INVALIDDATA; } s->keyframe = !(buf[0] & 1); s->invisible = 0; part1_size = AV_RL24(buf) >> 4; buf += 4 - s->profile; buf_size -= 4 - s->profile; memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_epel_pixels_tab, sizeof(s->put_pixels_tab)); ff_vp56_init_range_decoder(c, buf, part1_size); buf += part1_size; buf_size -= part1_size; /* A. Dimension information (keyframes only) */ if (s->keyframe) { width = vp8_rac_get_uint(c, 12); height = vp8_rac_get_uint(c, 12); hscale = vp8_rac_get_uint(c, 2); vscale = vp8_rac_get_uint(c, 2); if (hscale || vscale) avpriv_request_sample(s->avctx, "Upscaling"); s->update_golden = s->update_altref = VP56_FRAME_CURRENT; vp78_reset_probability_tables(s); memcpy(s->prob->pred16x16, vp8_pred16x16_prob_inter, sizeof(s->prob->pred16x16)); memcpy(s->prob->pred8x8c, vp8_pred8x8c_prob_inter, sizeof(s->prob->pred8x8c)); for (i = 0; i < 2; i++) memcpy(s->prob->mvc[i], vp7_mv_default_prob[i], sizeof(vp7_mv_default_prob[i])); memset(&s->segmentation, 0, sizeof(s->segmentation)); memset(&s->lf_delta, 0, sizeof(s->lf_delta)); memcpy(s->prob[0].scan, zigzag_scan, sizeof(s->prob[0].scan)); } if (s->keyframe || s->profile > 0) memset(s->inter_dc_pred, 0 , sizeof(s->inter_dc_pred)); /* B. Decoding information for all four macroblock-level features */ for (i = 0; i < 4; i++) { s->feature_enabled[i] = vp8_rac_get(c); if (s->feature_enabled[i]) { s->feature_present_prob[i] = vp8_rac_get_uint(c, 8); for (j = 0; j < 3; j++) s->feature_index_prob[i][j] = vp8_rac_get(c) ? vp8_rac_get_uint(c, 8) : 255; if (vp7_feature_value_size[i]) for (j = 0; j < 4; j++) s->feature_value[i][j] = vp8_rac_get(c) ? vp8_rac_get_uint(c, vp7_feature_value_size[s->profile][i]) : 0; } } s->segmentation.enabled = 0; s->segmentation.update_map = 0; s->lf_delta.enabled = 0; s->num_coeff_partitions = 1; ff_vp56_init_range_decoder(&s->coeff_partition[0], buf, buf_size); if (!s->macroblocks_base || /* first frame */ width != s->avctx->width || height != s->avctx->height || (width + 15) / 16 != s->mb_width || (height + 15) / 16 != s->mb_height) { if ((ret = vp7_update_dimensions(s, width, height)) < 0) return ret; } /* C. Dequantization indices */ vp7_get_quants(s); /* D. Golden frame update flag (a Flag) for interframes only */ if (!s->keyframe) { s->update_golden = vp8_rac_get(c) ? VP56_FRAME_CURRENT : VP56_FRAME_NONE; s->sign_bias[VP56_FRAME_GOLDEN] = 0; } s->update_last = 1; s->update_probabilities = 1; s->fade_present = 1; if (s->profile > 0) { s->update_probabilities = vp8_rac_get(c); if (!s->update_probabilities) s->prob[1] = s->prob[0]; if (!s->keyframe) s->fade_present = vp8_rac_get(c); } /* E. Fading information for previous frame */ if (s->fade_present && vp8_rac_get(c)) { if ((ret = vp7_fade_frame(s ,c)) < 0) return ret; } /* F. Loop filter type */ if (!s->profile) s->filter.simple = vp8_rac_get(c); /* G. DCT coefficient ordering specification */ if (vp8_rac_get(c)) for (i = 1; i < 16; i++) s->prob[0].scan[i] = zigzag_scan[vp8_rac_get_uint(c, 4)]; /* H. Loop filter levels */ if (s->profile > 0) s->filter.simple = vp8_rac_get(c); s->filter.level = vp8_rac_get_uint(c, 6); s->filter.sharpness = vp8_rac_get_uint(c, 3); /* I. DCT coefficient probability update; 13.3 Token Probability Updates */ vp78_update_probability_tables(s); s->mbskip_enabled = 0; /* J. The remaining frame header data occurs ONLY FOR INTERFRAMES */ if (!s->keyframe) { s->prob->intra = vp8_rac_get_uint(c, 8); s->prob->last = vp8_rac_get_uint(c, 8); vp78_update_pred16x16_pred8x8_mvc_probabilities(s, VP7_MVC_SIZE); } return 0; }
false
FFmpeg
29234f56818135faf2f1868ab324c073abd28fbd
static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size) { VP56RangeCoder *c = &s->c; int part1_size, hscale, vscale, i, j, ret; int width = s->avctx->width; int height = s->avctx->height; s->profile = (buf[0] >> 1) & 7; if (s->profile > 1) { avpriv_request_sample(s->avctx, "Unknown profile %d", s->profile); return AVERROR_INVALIDDATA; } s->keyframe = !(buf[0] & 1); s->invisible = 0; part1_size = AV_RL24(buf) >> 4; buf += 4 - s->profile; buf_size -= 4 - s->profile; memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_epel_pixels_tab, sizeof(s->put_pixels_tab)); ff_vp56_init_range_decoder(c, buf, part1_size); buf += part1_size; buf_size -= part1_size; if (s->keyframe) { width = vp8_rac_get_uint(c, 12); height = vp8_rac_get_uint(c, 12); hscale = vp8_rac_get_uint(c, 2); vscale = vp8_rac_get_uint(c, 2); if (hscale || vscale) avpriv_request_sample(s->avctx, "Upscaling"); s->update_golden = s->update_altref = VP56_FRAME_CURRENT; vp78_reset_probability_tables(s); memcpy(s->prob->pred16x16, vp8_pred16x16_prob_inter, sizeof(s->prob->pred16x16)); memcpy(s->prob->pred8x8c, vp8_pred8x8c_prob_inter, sizeof(s->prob->pred8x8c)); for (i = 0; i < 2; i++) memcpy(s->prob->mvc[i], vp7_mv_default_prob[i], sizeof(vp7_mv_default_prob[i])); memset(&s->segmentation, 0, sizeof(s->segmentation)); memset(&s->lf_delta, 0, sizeof(s->lf_delta)); memcpy(s->prob[0].scan, zigzag_scan, sizeof(s->prob[0].scan)); } if (s->keyframe || s->profile > 0) memset(s->inter_dc_pred, 0 , sizeof(s->inter_dc_pred)); for (i = 0; i < 4; i++) { s->feature_enabled[i] = vp8_rac_get(c); if (s->feature_enabled[i]) { s->feature_present_prob[i] = vp8_rac_get_uint(c, 8); for (j = 0; j < 3; j++) s->feature_index_prob[i][j] = vp8_rac_get(c) ? vp8_rac_get_uint(c, 8) : 255; if (vp7_feature_value_size[i]) for (j = 0; j < 4; j++) s->feature_value[i][j] = vp8_rac_get(c) ? vp8_rac_get_uint(c, vp7_feature_value_size[s->profile][i]) : 0; } } s->segmentation.enabled = 0; s->segmentation.update_map = 0; s->lf_delta.enabled = 0; s->num_coeff_partitions = 1; ff_vp56_init_range_decoder(&s->coeff_partition[0], buf, buf_size); if (!s->macroblocks_base || width != s->avctx->width || height != s->avctx->height || (width + 15) / 16 != s->mb_width || (height + 15) / 16 != s->mb_height) { if ((ret = vp7_update_dimensions(s, width, height)) < 0) return ret; } vp7_get_quants(s); if (!s->keyframe) { s->update_golden = vp8_rac_get(c) ? VP56_FRAME_CURRENT : VP56_FRAME_NONE; s->sign_bias[VP56_FRAME_GOLDEN] = 0; } s->update_last = 1; s->update_probabilities = 1; s->fade_present = 1; if (s->profile > 0) { s->update_probabilities = vp8_rac_get(c); if (!s->update_probabilities) s->prob[1] = s->prob[0]; if (!s->keyframe) s->fade_present = vp8_rac_get(c); } if (s->fade_present && vp8_rac_get(c)) { if ((ret = vp7_fade_frame(s ,c)) < 0) return ret; } if (!s->profile) s->filter.simple = vp8_rac_get(c); if (vp8_rac_get(c)) for (i = 1; i < 16; i++) s->prob[0].scan[i] = zigzag_scan[vp8_rac_get_uint(c, 4)]; if (s->profile > 0) s->filter.simple = vp8_rac_get(c); s->filter.level = vp8_rac_get_uint(c, 6); s->filter.sharpness = vp8_rac_get_uint(c, 3); vp78_update_probability_tables(s); s->mbskip_enabled = 0; if (!s->keyframe) { s->prob->intra = vp8_rac_get_uint(c, 8); s->prob->last = vp8_rac_get_uint(c, 8); vp78_update_pred16x16_pred8x8_mvc_probabilities(s, VP7_MVC_SIZE); } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(VP8Context *VAR_0, const uint8_t *VAR_1, int VAR_2) { VP56RangeCoder *c = &VAR_0->c; int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8; int VAR_9 = VAR_0->avctx->VAR_9; int VAR_10 = VAR_0->avctx->VAR_10; VAR_0->profile = (VAR_1[0] >> 1) & 7; if (VAR_0->profile > 1) { avpriv_request_sample(VAR_0->avctx, "Unknown profile %d", VAR_0->profile); return AVERROR_INVALIDDATA; } VAR_0->keyframe = !(VAR_1[0] & 1); VAR_0->invisible = 0; VAR_3 = AV_RL24(VAR_1) >> 4; VAR_1 += 4 - VAR_0->profile; VAR_2 -= 4 - VAR_0->profile; memcpy(VAR_0->put_pixels_tab, VAR_0->vp8dsp.put_vp8_epel_pixels_tab, sizeof(VAR_0->put_pixels_tab)); ff_vp56_init_range_decoder(c, VAR_1, VAR_3); VAR_1 += VAR_3; VAR_2 -= VAR_3; if (VAR_0->keyframe) { VAR_9 = vp8_rac_get_uint(c, 12); VAR_10 = vp8_rac_get_uint(c, 12); VAR_4 = vp8_rac_get_uint(c, 2); VAR_5 = vp8_rac_get_uint(c, 2); if (VAR_4 || VAR_5) avpriv_request_sample(VAR_0->avctx, "Upscaling"); VAR_0->update_golden = VAR_0->update_altref = VP56_FRAME_CURRENT; vp78_reset_probability_tables(VAR_0); memcpy(VAR_0->prob->pred16x16, vp8_pred16x16_prob_inter, sizeof(VAR_0->prob->pred16x16)); memcpy(VAR_0->prob->pred8x8c, vp8_pred8x8c_prob_inter, sizeof(VAR_0->prob->pred8x8c)); for (VAR_6 = 0; VAR_6 < 2; VAR_6++) memcpy(VAR_0->prob->mvc[VAR_6], vp7_mv_default_prob[VAR_6], sizeof(vp7_mv_default_prob[VAR_6])); memset(&VAR_0->segmentation, 0, sizeof(VAR_0->segmentation)); memset(&VAR_0->lf_delta, 0, sizeof(VAR_0->lf_delta)); memcpy(VAR_0->prob[0].scan, zigzag_scan, sizeof(VAR_0->prob[0].scan)); } if (VAR_0->keyframe || VAR_0->profile > 0) memset(VAR_0->inter_dc_pred, 0 , sizeof(VAR_0->inter_dc_pred)); for (VAR_6 = 0; VAR_6 < 4; VAR_6++) { VAR_0->feature_enabled[VAR_6] = vp8_rac_get(c); if (VAR_0->feature_enabled[VAR_6]) { VAR_0->feature_present_prob[VAR_6] = vp8_rac_get_uint(c, 8); for (VAR_7 = 0; VAR_7 < 3; VAR_7++) VAR_0->feature_index_prob[VAR_6][VAR_7] = vp8_rac_get(c) ? vp8_rac_get_uint(c, 8) : 255; if (vp7_feature_value_size[VAR_6]) for (VAR_7 = 0; VAR_7 < 4; VAR_7++) VAR_0->feature_value[VAR_6][VAR_7] = vp8_rac_get(c) ? vp8_rac_get_uint(c, vp7_feature_value_size[VAR_0->profile][VAR_6]) : 0; } } VAR_0->segmentation.enabled = 0; VAR_0->segmentation.update_map = 0; VAR_0->lf_delta.enabled = 0; VAR_0->num_coeff_partitions = 1; ff_vp56_init_range_decoder(&VAR_0->coeff_partition[0], VAR_1, VAR_2); if (!VAR_0->macroblocks_base || VAR_9 != VAR_0->avctx->VAR_9 || VAR_10 != VAR_0->avctx->VAR_10 || (VAR_9 + 15) / 16 != VAR_0->mb_width || (VAR_10 + 15) / 16 != VAR_0->mb_height) { if ((VAR_8 = vp7_update_dimensions(VAR_0, VAR_9, VAR_10)) < 0) return VAR_8; } vp7_get_quants(VAR_0); if (!VAR_0->keyframe) { VAR_0->update_golden = vp8_rac_get(c) ? VP56_FRAME_CURRENT : VP56_FRAME_NONE; VAR_0->sign_bias[VP56_FRAME_GOLDEN] = 0; } VAR_0->update_last = 1; VAR_0->update_probabilities = 1; VAR_0->fade_present = 1; if (VAR_0->profile > 0) { VAR_0->update_probabilities = vp8_rac_get(c); if (!VAR_0->update_probabilities) VAR_0->prob[1] = VAR_0->prob[0]; if (!VAR_0->keyframe) VAR_0->fade_present = vp8_rac_get(c); } if (VAR_0->fade_present && vp8_rac_get(c)) { if ((VAR_8 = vp7_fade_frame(VAR_0 ,c)) < 0) return VAR_8; } if (!VAR_0->profile) VAR_0->filter.simple = vp8_rac_get(c); if (vp8_rac_get(c)) for (VAR_6 = 1; VAR_6 < 16; VAR_6++) VAR_0->prob[0].scan[VAR_6] = zigzag_scan[vp8_rac_get_uint(c, 4)]; if (VAR_0->profile > 0) VAR_0->filter.simple = vp8_rac_get(c); VAR_0->filter.level = vp8_rac_get_uint(c, 6); VAR_0->filter.sharpness = vp8_rac_get_uint(c, 3); vp78_update_probability_tables(VAR_0); VAR_0->mbskip_enabled = 0; if (!VAR_0->keyframe) { VAR_0->prob->intra = vp8_rac_get_uint(c, 8); VAR_0->prob->last = vp8_rac_get_uint(c, 8); vp78_update_pred16x16_pred8x8_mvc_probabilities(VAR_0, VP7_MVC_SIZE); } return 0; }
[ "static int FUNC_0(VP8Context *VAR_0, const uint8_t *VAR_1, int VAR_2)\n{", "VP56RangeCoder *c = &VAR_0->c;", "int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;", "int VAR_9 = VAR_0->avctx->VAR_9;", "int VAR_10 = VAR_0->avctx->VAR_10;", "VAR_0->profile = (VAR_1[0] >> 1) & 7;", "if (VAR_0->profile > 1) {", "avpriv_request_sample(VAR_0->avctx, \"Unknown profile %d\", VAR_0->profile);", "return AVERROR_INVALIDDATA;", "}", "VAR_0->keyframe = !(VAR_1[0] & 1);", "VAR_0->invisible = 0;", "VAR_3 = AV_RL24(VAR_1) >> 4;", "VAR_1 += 4 - VAR_0->profile;", "VAR_2 -= 4 - VAR_0->profile;", "memcpy(VAR_0->put_pixels_tab, VAR_0->vp8dsp.put_vp8_epel_pixels_tab, sizeof(VAR_0->put_pixels_tab));", "ff_vp56_init_range_decoder(c, VAR_1, VAR_3);", "VAR_1 += VAR_3;", "VAR_2 -= VAR_3;", "if (VAR_0->keyframe) {", "VAR_9 = vp8_rac_get_uint(c, 12);", "VAR_10 = vp8_rac_get_uint(c, 12);", "VAR_4 = vp8_rac_get_uint(c, 2);", "VAR_5 = vp8_rac_get_uint(c, 2);", "if (VAR_4 || VAR_5)\navpriv_request_sample(VAR_0->avctx, \"Upscaling\");", "VAR_0->update_golden = VAR_0->update_altref = VP56_FRAME_CURRENT;", "vp78_reset_probability_tables(VAR_0);", "memcpy(VAR_0->prob->pred16x16, vp8_pred16x16_prob_inter,\nsizeof(VAR_0->prob->pred16x16));", "memcpy(VAR_0->prob->pred8x8c, vp8_pred8x8c_prob_inter,\nsizeof(VAR_0->prob->pred8x8c));", "for (VAR_6 = 0; VAR_6 < 2; VAR_6++)", "memcpy(VAR_0->prob->mvc[VAR_6], vp7_mv_default_prob[VAR_6],\nsizeof(vp7_mv_default_prob[VAR_6]));", "memset(&VAR_0->segmentation, 0, sizeof(VAR_0->segmentation));", "memset(&VAR_0->lf_delta, 0, sizeof(VAR_0->lf_delta));", "memcpy(VAR_0->prob[0].scan, zigzag_scan, sizeof(VAR_0->prob[0].scan));", "}", "if (VAR_0->keyframe || VAR_0->profile > 0)\nmemset(VAR_0->inter_dc_pred, 0 , sizeof(VAR_0->inter_dc_pred));", "for (VAR_6 = 0; VAR_6 < 4; VAR_6++) {", "VAR_0->feature_enabled[VAR_6] = vp8_rac_get(c);", "if (VAR_0->feature_enabled[VAR_6]) {", "VAR_0->feature_present_prob[VAR_6] = vp8_rac_get_uint(c, 8);", "for (VAR_7 = 0; VAR_7 < 3; VAR_7++)", "VAR_0->feature_index_prob[VAR_6][VAR_7] =\nvp8_rac_get(c) ? vp8_rac_get_uint(c, 8) : 255;", "if (vp7_feature_value_size[VAR_6])\nfor (VAR_7 = 0; VAR_7 < 4; VAR_7++)", "VAR_0->feature_value[VAR_6][VAR_7] =\nvp8_rac_get(c) ? vp8_rac_get_uint(c, vp7_feature_value_size[VAR_0->profile][VAR_6]) : 0;", "}", "}", "VAR_0->segmentation.enabled = 0;", "VAR_0->segmentation.update_map = 0;", "VAR_0->lf_delta.enabled = 0;", "VAR_0->num_coeff_partitions = 1;", "ff_vp56_init_range_decoder(&VAR_0->coeff_partition[0], VAR_1, VAR_2);", "if (!VAR_0->macroblocks_base ||\nVAR_9 != VAR_0->avctx->VAR_9 || VAR_10 != VAR_0->avctx->VAR_10 ||\n(VAR_9 + 15) / 16 != VAR_0->mb_width || (VAR_10 + 15) / 16 != VAR_0->mb_height) {", "if ((VAR_8 = vp7_update_dimensions(VAR_0, VAR_9, VAR_10)) < 0)\nreturn VAR_8;", "}", "vp7_get_quants(VAR_0);", "if (!VAR_0->keyframe) {", "VAR_0->update_golden = vp8_rac_get(c) ? VP56_FRAME_CURRENT : VP56_FRAME_NONE;", "VAR_0->sign_bias[VP56_FRAME_GOLDEN] = 0;", "}", "VAR_0->update_last = 1;", "VAR_0->update_probabilities = 1;", "VAR_0->fade_present = 1;", "if (VAR_0->profile > 0) {", "VAR_0->update_probabilities = vp8_rac_get(c);", "if (!VAR_0->update_probabilities)\nVAR_0->prob[1] = VAR_0->prob[0];", "if (!VAR_0->keyframe)\nVAR_0->fade_present = vp8_rac_get(c);", "}", "if (VAR_0->fade_present && vp8_rac_get(c)) {", "if ((VAR_8 = vp7_fade_frame(VAR_0 ,c)) < 0)\nreturn VAR_8;", "}", "if (!VAR_0->profile)\nVAR_0->filter.simple = vp8_rac_get(c);", "if (vp8_rac_get(c))\nfor (VAR_6 = 1; VAR_6 < 16; VAR_6++)", "VAR_0->prob[0].scan[VAR_6] = zigzag_scan[vp8_rac_get_uint(c, 4)];", "if (VAR_0->profile > 0)\nVAR_0->filter.simple = vp8_rac_get(c);", "VAR_0->filter.level = vp8_rac_get_uint(c, 6);", "VAR_0->filter.sharpness = vp8_rac_get_uint(c, 3);", "vp78_update_probability_tables(VAR_0);", "VAR_0->mbskip_enabled = 0;", "if (!VAR_0->keyframe) {", "VAR_0->prob->intra = vp8_rac_get_uint(c, 8);", "VAR_0->prob->last = vp8_rac_get_uint(c, 8);", "vp78_update_pred16x16_pred8x8_mvc_probabilities(VAR_0, VP7_MVC_SIZE);", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 31 ], [ 35 ], [ 37 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65, 67 ], [ 71 ], [ 73 ], [ 75, 77 ], [ 79, 81 ], [ 83 ], [ 85, 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 99, 101 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 117 ], [ 119, 121 ], [ 125, 127 ], [ 129, 131 ], [ 133 ], [ 135 ], [ 139 ], [ 141 ], [ 143 ], [ 147 ], [ 149 ], [ 153, 155, 157 ], [ 159, 161 ], [ 163 ], [ 169 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 185 ], [ 187 ], [ 189 ], [ 193 ], [ 195 ], [ 197, 199 ], [ 203, 205 ], [ 207 ], [ 213 ], [ 215, 217 ], [ 219 ], [ 225, 227 ], [ 233, 235 ], [ 237 ], [ 243, 245 ], [ 247 ], [ 249 ], [ 255 ], [ 259 ], [ 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 277 ], [ 279 ] ]
11,396
static inline void mc_dir_part(H264Context *h, Picture *pic, int n, int square, int chroma_height, int delta, int list, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int src_x_offset, int src_y_offset, qpel_mc_func *qpix_op, h264_chroma_mc_func chroma_op){ MpegEncContext * const s = &h->s; const int mx= h->mv_cache[list][ scan8[n] ][0] + src_x_offset*8; const int my= h->mv_cache[list][ scan8[n] ][1] + src_y_offset*8; const int luma_xy= (mx&3) + ((my&3)<<2); uint8_t * src_y = pic->data[0] + (mx>>2) + (my>>2)*s->linesize; uint8_t * src_cb= pic->data[1] + (mx>>3) + (my>>3)*s->uvlinesize; uint8_t * src_cr= pic->data[2] + (mx>>3) + (my>>3)*s->uvlinesize; int extra_width= (s->flags&CODEC_FLAG_EMU_EDGE) ? 0 : 16; //FIXME increase edge?, IMHO not worth it int extra_height= extra_width; int emu=0; const int full_mx= mx>>2; const int full_my= my>>2; const int pic_width = 16*s->mb_width; const int pic_height = 16*s->mb_height; assert(pic->data[0]); if(mx&7) extra_width -= 3; if(my&7) extra_height -= 3; if( full_mx < 0-extra_width || full_my < 0-extra_height || full_mx + 16/*FIXME*/ > pic_width + extra_width || full_my + 16/*FIXME*/ > pic_height + extra_height){ ff_emulated_edge_mc(s->edge_emu_buffer, src_y - 2 - 2*s->linesize, s->linesize, 16+5, 16+5/*FIXME*/, full_mx-2, full_my-2, pic_width, pic_height); src_y= s->edge_emu_buffer + 2 + 2*s->linesize; emu=1; } qpix_op[luma_xy](dest_y, src_y, s->linesize); //FIXME try variable height perhaps? if(!square){ qpix_op[luma_xy](dest_y + delta, src_y + delta, s->linesize); } if(s->flags&CODEC_FLAG_GRAY) return; if(emu){ ff_emulated_edge_mc(s->edge_emu_buffer, src_cb, s->uvlinesize, 9, 9/*FIXME*/, (mx>>3), (my>>3), pic_width>>1, pic_height>>1); src_cb= s->edge_emu_buffer; } chroma_op(dest_cb, src_cb, s->uvlinesize, chroma_height, mx&7, my&7); if(emu){ ff_emulated_edge_mc(s->edge_emu_buffer, src_cr, s->uvlinesize, 9, 9/*FIXME*/, (mx>>3), (my>>3), pic_width>>1, pic_height>>1); src_cr= s->edge_emu_buffer; } chroma_op(dest_cr, src_cr, s->uvlinesize, chroma_height, mx&7, my&7); }
true
FFmpeg
171c407621b7ff52a0cf128b31651ca927c2dd49
static inline void mc_dir_part(H264Context *h, Picture *pic, int n, int square, int chroma_height, int delta, int list, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int src_x_offset, int src_y_offset, qpel_mc_func *qpix_op, h264_chroma_mc_func chroma_op){ MpegEncContext * const s = &h->s; const int mx= h->mv_cache[list][ scan8[n] ][0] + src_x_offset*8; const int my= h->mv_cache[list][ scan8[n] ][1] + src_y_offset*8; const int luma_xy= (mx&3) + ((my&3)<<2); uint8_t * src_y = pic->data[0] + (mx>>2) + (my>>2)*s->linesize; uint8_t * src_cb= pic->data[1] + (mx>>3) + (my>>3)*s->uvlinesize; uint8_t * src_cr= pic->data[2] + (mx>>3) + (my>>3)*s->uvlinesize; int extra_width= (s->flags&CODEC_FLAG_EMU_EDGE) ? 0 : 16; int extra_height= extra_width; int emu=0; const int full_mx= mx>>2; const int full_my= my>>2; const int pic_width = 16*s->mb_width; const int pic_height = 16*s->mb_height; assert(pic->data[0]); if(mx&7) extra_width -= 3; if(my&7) extra_height -= 3; if( full_mx < 0-extra_width || full_my < 0-extra_height || full_mx + 16 > pic_width + extra_width || full_my + 16 > pic_height + extra_height){ ff_emulated_edge_mc(s->edge_emu_buffer, src_y - 2 - 2*s->linesize, s->linesize, 16+5, 16+5, full_mx-2, full_my-2, pic_width, pic_height); src_y= s->edge_emu_buffer + 2 + 2*s->linesize; emu=1; } qpix_op[luma_xy](dest_y, src_y, s->linesize); if(!square){ qpix_op[luma_xy](dest_y + delta, src_y + delta, s->linesize); } if(s->flags&CODEC_FLAG_GRAY) return; if(emu){ ff_emulated_edge_mc(s->edge_emu_buffer, src_cb, s->uvlinesize, 9, 9, (mx>>3), (my>>3), pic_width>>1, pic_height>>1); src_cb= s->edge_emu_buffer; } chroma_op(dest_cb, src_cb, s->uvlinesize, chroma_height, mx&7, my&7); if(emu){ ff_emulated_edge_mc(s->edge_emu_buffer, src_cr, s->uvlinesize, 9, 9, (mx>>3), (my>>3), pic_width>>1, pic_height>>1); src_cr= s->edge_emu_buffer; } chroma_op(dest_cr, src_cr, s->uvlinesize, chroma_height, mx&7, my&7); }
{ "code": [ " assert(pic->data[0]);" ], "line_no": [ 39 ] }
static inline void FUNC_0(H264Context *VAR_0, Picture *VAR_1, int VAR_2, int VAR_3, int VAR_4, int VAR_5, int VAR_6, uint8_t *VAR_7, uint8_t *VAR_8, uint8_t *VAR_9, int VAR_10, int VAR_11, qpel_mc_func *VAR_12, h264_chroma_mc_func VAR_13){ MpegEncContext * const s = &VAR_0->s; const int VAR_14= VAR_0->mv_cache[VAR_6][ scan8[VAR_2] ][0] + VAR_10*8; const int VAR_15= VAR_0->mv_cache[VAR_6][ scan8[VAR_2] ][1] + VAR_11*8; const int VAR_16= (VAR_14&3) + ((VAR_15&3)<<2); uint8_t * src_y = VAR_1->data[0] + (VAR_14>>2) + (VAR_15>>2)*s->linesize; uint8_t * src_cb= VAR_1->data[1] + (VAR_14>>3) + (VAR_15>>3)*s->uvlinesize; uint8_t * src_cr= VAR_1->data[2] + (VAR_14>>3) + (VAR_15>>3)*s->uvlinesize; int VAR_17= (s->flags&CODEC_FLAG_EMU_EDGE) ? 0 : 16; int VAR_18= VAR_17; int VAR_19=0; const int VAR_20= VAR_14>>2; const int VAR_21= VAR_15>>2; const int VAR_22 = 16*s->mb_width; const int VAR_23 = 16*s->mb_height; assert(VAR_1->data[0]); if(VAR_14&7) VAR_17 -= 3; if(VAR_15&7) VAR_18 -= 3; if( VAR_20 < 0-VAR_17 || VAR_21 < 0-VAR_18 || VAR_20 + 16 > VAR_22 + VAR_17 || VAR_21 + 16 > VAR_23 + VAR_18){ ff_emulated_edge_mc(s->edge_emu_buffer, src_y - 2 - 2*s->linesize, s->linesize, 16+5, 16+5, VAR_20-2, VAR_21-2, VAR_22, VAR_23); src_y= s->edge_emu_buffer + 2 + 2*s->linesize; VAR_19=1; } VAR_12[VAR_16](VAR_7, src_y, s->linesize); if(!VAR_3){ VAR_12[VAR_16](VAR_7 + VAR_5, src_y + VAR_5, s->linesize); } if(s->flags&CODEC_FLAG_GRAY) return; if(VAR_19){ ff_emulated_edge_mc(s->edge_emu_buffer, src_cb, s->uvlinesize, 9, 9, (VAR_14>>3), (VAR_15>>3), VAR_22>>1, VAR_23>>1); src_cb= s->edge_emu_buffer; } VAR_13(VAR_8, src_cb, s->uvlinesize, VAR_4, VAR_14&7, VAR_15&7); if(VAR_19){ ff_emulated_edge_mc(s->edge_emu_buffer, src_cr, s->uvlinesize, 9, 9, (VAR_14>>3), (VAR_15>>3), VAR_22>>1, VAR_23>>1); src_cr= s->edge_emu_buffer; } VAR_13(VAR_9, src_cr, s->uvlinesize, VAR_4, VAR_14&7, VAR_15&7); }
[ "static inline void FUNC_0(H264Context *VAR_0, Picture *VAR_1, int VAR_2, int VAR_3, int VAR_4, int VAR_5, int VAR_6,\nuint8_t *VAR_7, uint8_t *VAR_8, uint8_t *VAR_9,\nint VAR_10, int VAR_11,\nqpel_mc_func *VAR_12, h264_chroma_mc_func VAR_13){", "MpegEncContext * const s = &VAR_0->s;", "const int VAR_14= VAR_0->mv_cache[VAR_6][ scan8[VAR_2] ][0] + VAR_10*8;", "const int VAR_15= VAR_0->mv_cache[VAR_6][ scan8[VAR_2] ][1] + VAR_11*8;", "const int VAR_16= (VAR_14&3) + ((VAR_15&3)<<2);", "uint8_t * src_y = VAR_1->data[0] + (VAR_14>>2) + (VAR_15>>2)*s->linesize;", "uint8_t * src_cb= VAR_1->data[1] + (VAR_14>>3) + (VAR_15>>3)*s->uvlinesize;", "uint8_t * src_cr= VAR_1->data[2] + (VAR_14>>3) + (VAR_15>>3)*s->uvlinesize;", "int VAR_17= (s->flags&CODEC_FLAG_EMU_EDGE) ? 0 : 16;", "int VAR_18= VAR_17;", "int VAR_19=0;", "const int VAR_20= VAR_14>>2;", "const int VAR_21= VAR_15>>2;", "const int VAR_22 = 16*s->mb_width;", "const int VAR_23 = 16*s->mb_height;", "assert(VAR_1->data[0]);", "if(VAR_14&7) VAR_17 -= 3;", "if(VAR_15&7) VAR_18 -= 3;", "if( VAR_20 < 0-VAR_17\n|| VAR_21 < 0-VAR_18\n|| VAR_20 + 16 > VAR_22 + VAR_17\n|| VAR_21 + 16 > VAR_23 + VAR_18){", "ff_emulated_edge_mc(s->edge_emu_buffer, src_y - 2 - 2*s->linesize, s->linesize, 16+5, 16+5, VAR_20-2, VAR_21-2, VAR_22, VAR_23);", "src_y= s->edge_emu_buffer + 2 + 2*s->linesize;", "VAR_19=1;", "}", "VAR_12[VAR_16](VAR_7, src_y, s->linesize);", "if(!VAR_3){", "VAR_12[VAR_16](VAR_7 + VAR_5, src_y + VAR_5, s->linesize);", "}", "if(s->flags&CODEC_FLAG_GRAY) return;", "if(VAR_19){", "ff_emulated_edge_mc(s->edge_emu_buffer, src_cb, s->uvlinesize, 9, 9, (VAR_14>>3), (VAR_15>>3), VAR_22>>1, VAR_23>>1);", "src_cb= s->edge_emu_buffer;", "}", "VAR_13(VAR_8, src_cb, s->uvlinesize, VAR_4, VAR_14&7, VAR_15&7);", "if(VAR_19){", "ff_emulated_edge_mc(s->edge_emu_buffer, src_cr, s->uvlinesize, 9, 9, (VAR_14>>3), (VAR_15>>3), VAR_22>>1, VAR_23>>1);", "src_cr= s->edge_emu_buffer;", "}", "VAR_13(VAR_9, src_cr, s->uvlinesize, VAR_4, VAR_14&7, VAR_15&7);", "}" ]
[ 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 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 43 ], [ 45 ], [ 49, 51, 53, 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 77 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ] ]
11,397
static int encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_size, void *data) { AVFrame *pic = data; int i, j; int aligned_width = FFALIGN(avctx->width, 64); uint8_t *src_line; uint8_t *dst = buf; if (buf_size < 4 * aligned_width * avctx->height) { av_log(avctx, AV_LOG_ERROR, "output buffer too small\n"); return AVERROR(ENOMEM); } avctx->coded_frame->reference = 0; avctx->coded_frame->key_frame = 1; avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; src_line = pic->data[0]; for (i = 0; i < avctx->height; i++) { uint16_t *src = (uint16_t *)src_line; for (j = 0; j < avctx->width; j++) { uint32_t pixel; uint16_t r = *src++ >> 6; uint16_t g = *src++ >> 6; uint16_t b = *src++ >> 4; if (avctx->codec_id == CODEC_ID_R210) pixel = (r << 20) | (g << 10) | b >> 2; else pixel = (r << 22) | (g << 12) | b; if (avctx->codec_id == CODEC_ID_AVRP) bytestream_put_le32(&dst, pixel); else bytestream_put_be32(&dst, pixel); } dst += (aligned_width - avctx->width) * 4; src_line += pic->linesize[0]; } return 4 * aligned_width * avctx->height; }
true
FFmpeg
371946bc27bd1e874e0302699550ab9926249950
static int encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_size, void *data) { AVFrame *pic = data; int i, j; int aligned_width = FFALIGN(avctx->width, 64); uint8_t *src_line; uint8_t *dst = buf; if (buf_size < 4 * aligned_width * avctx->height) { av_log(avctx, AV_LOG_ERROR, "output buffer too small\n"); return AVERROR(ENOMEM); } avctx->coded_frame->reference = 0; avctx->coded_frame->key_frame = 1; avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; src_line = pic->data[0]; for (i = 0; i < avctx->height; i++) { uint16_t *src = (uint16_t *)src_line; for (j = 0; j < avctx->width; j++) { uint32_t pixel; uint16_t r = *src++ >> 6; uint16_t g = *src++ >> 6; uint16_t b = *src++ >> 4; if (avctx->codec_id == CODEC_ID_R210) pixel = (r << 20) | (g << 10) | b >> 2; else pixel = (r << 22) | (g << 12) | b; if (avctx->codec_id == CODEC_ID_AVRP) bytestream_put_le32(&dst, pixel); else bytestream_put_be32(&dst, pixel); } dst += (aligned_width - avctx->width) * 4; src_line += pic->linesize[0]; } return 4 * aligned_width * avctx->height; }
{ "code": [ " dst += (aligned_width - avctx->width) * 4;" ], "line_no": [ 71 ] }
static int FUNC_0(AVCodecContext *VAR_0, uint8_t *VAR_1, int VAR_2, void *VAR_3) { AVFrame *pic = VAR_3; int VAR_4, VAR_5; int VAR_6 = FFALIGN(VAR_0->width, 64); uint8_t *src_line; uint8_t *dst = VAR_1; if (VAR_2 < 4 * VAR_6 * VAR_0->height) { av_log(VAR_0, AV_LOG_ERROR, "output buffer too small\n"); return AVERROR(ENOMEM); } VAR_0->coded_frame->reference = 0; VAR_0->coded_frame->key_frame = 1; VAR_0->coded_frame->pict_type = AV_PICTURE_TYPE_I; src_line = pic->VAR_3[0]; for (VAR_4 = 0; VAR_4 < VAR_0->height; VAR_4++) { uint16_t *src = (uint16_t *)src_line; for (VAR_5 = 0; VAR_5 < VAR_0->width; VAR_5++) { uint32_t pixel; uint16_t r = *src++ >> 6; uint16_t g = *src++ >> 6; uint16_t b = *src++ >> 4; if (VAR_0->codec_id == CODEC_ID_R210) pixel = (r << 20) | (g << 10) | b >> 2; else pixel = (r << 22) | (g << 12) | b; if (VAR_0->codec_id == CODEC_ID_AVRP) bytestream_put_le32(&dst, pixel); else bytestream_put_be32(&dst, pixel); } dst += (VAR_6 - VAR_0->width) * 4; src_line += pic->linesize[0]; } return 4 * VAR_6 * VAR_0->height; }
[ "static int FUNC_0(AVCodecContext *VAR_0, uint8_t *VAR_1,\nint VAR_2, void *VAR_3)\n{", "AVFrame *pic = VAR_3;", "int VAR_4, VAR_5;", "int VAR_6 = FFALIGN(VAR_0->width, 64);", "uint8_t *src_line;", "uint8_t *dst = VAR_1;", "if (VAR_2 < 4 * VAR_6 * VAR_0->height) {", "av_log(VAR_0, AV_LOG_ERROR, \"output buffer too small\\n\");", "return AVERROR(ENOMEM);", "}", "VAR_0->coded_frame->reference = 0;", "VAR_0->coded_frame->key_frame = 1;", "VAR_0->coded_frame->pict_type = AV_PICTURE_TYPE_I;", "src_line = pic->VAR_3[0];", "for (VAR_4 = 0; VAR_4 < VAR_0->height; VAR_4++) {", "uint16_t *src = (uint16_t *)src_line;", "for (VAR_5 = 0; VAR_5 < VAR_0->width; VAR_5++) {", "uint32_t pixel;", "uint16_t r = *src++ >> 6;", "uint16_t g = *src++ >> 6;", "uint16_t b = *src++ >> 4;", "if (VAR_0->codec_id == CODEC_ID_R210)\npixel = (r << 20) | (g << 10) | b >> 2;", "else\npixel = (r << 22) | (g << 12) | b;", "if (VAR_0->codec_id == CODEC_ID_AVRP)\nbytestream_put_le32(&dst, pixel);", "else\nbytestream_put_be32(&dst, pixel);", "}", "dst += (VAR_6 - VAR_0->width) * 4;", "src_line += pic->linesize[0];", "}", "return 4 * VAR_6 * VAR_0->height;", "}" ]
[ 0, 0, 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 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53, 55 ], [ 57, 59 ], [ 61, 63 ], [ 65, 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ] ]
11,398
static inline void gen_st32(TCGv val, TCGv addr, int index) { tcg_gen_qemu_st32(val, addr, index); dead_tmp(val); }
true
qemu
7d1b0095bff7157e856d1d0e6c4295641ced2752
static inline void gen_st32(TCGv val, TCGv addr, int index) { tcg_gen_qemu_st32(val, addr, index); dead_tmp(val); }
{ "code": [ " dead_tmp(val);", " dead_tmp(val);", " dead_tmp(val);" ], "line_no": [ 7, 7, 7 ] }
static inline void FUNC_0(TCGv VAR_0, TCGv VAR_1, int VAR_2) { tcg_gen_qemu_st32(VAR_0, VAR_1, VAR_2); dead_tmp(VAR_0); }
[ "static inline void FUNC_0(TCGv VAR_0, TCGv VAR_1, int VAR_2)\n{", "tcg_gen_qemu_st32(VAR_0, VAR_1, VAR_2);", "dead_tmp(VAR_0);", "}" ]
[ 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ] ]
11,399
int uuid_is_null(const uuid_t uu) { uuid_t null_uuid = { 0 }; return memcmp(uu, null_uuid, sizeof(uuid_t)) == 0; }
false
qemu
8ba2aae32c40f544def6be7ae82be9bcb781e01d
int uuid_is_null(const uuid_t uu) { uuid_t null_uuid = { 0 }; return memcmp(uu, null_uuid, sizeof(uuid_t)) == 0; }
{ "code": [], "line_no": [] }
int FUNC_0(const uuid_t VAR_0) { uuid_t null_uuid = { 0 }; return memcmp(VAR_0, null_uuid, sizeof(uuid_t)) == 0; }
[ "int FUNC_0(const uuid_t VAR_0)\n{", "uuid_t null_uuid = { 0 };", "return memcmp(VAR_0, null_uuid, sizeof(uuid_t)) == 0;", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ] ]
11,401
static int e1000_post_load(void *opaque, int version_id) { E1000State *s = opaque; NetClientState *nc = qemu_get_queue(s->nic); if (!(s->compat_flags & E1000_FLAG_MIT)) { s->mac_reg[ITR] = s->mac_reg[RDTR] = s->mac_reg[RADV] = s->mac_reg[TADV] = 0; s->mit_irq_level = false; } s->mit_ide = 0; s->mit_timer_on = false; /* nc.link_down can't be migrated, so infer link_down according * to link status bit in mac_reg[STATUS]. * Alternatively, restart link negotiation if it was in progress. */ nc->link_down = (s->mac_reg[STATUS] & E1000_STATUS_LU) == 0; if (s->compat_flags & E1000_FLAG_AUTONEG && s->phy_reg[PHY_CTRL] & MII_CR_AUTO_NEG_EN && s->phy_reg[PHY_CTRL] & MII_CR_RESTART_AUTO_NEG && !(s->phy_reg[PHY_STATUS] & MII_SR_AUTONEG_COMPLETE)) { nc->link_down = false; timer_mod(s->autoneg_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 500); } return 0; }
false
qemu
d7a4155265416a1c8f3067b59e68bf5fda1d6215
static int e1000_post_load(void *opaque, int version_id) { E1000State *s = opaque; NetClientState *nc = qemu_get_queue(s->nic); if (!(s->compat_flags & E1000_FLAG_MIT)) { s->mac_reg[ITR] = s->mac_reg[RDTR] = s->mac_reg[RADV] = s->mac_reg[TADV] = 0; s->mit_irq_level = false; } s->mit_ide = 0; s->mit_timer_on = false; nc->link_down = (s->mac_reg[STATUS] & E1000_STATUS_LU) == 0; if (s->compat_flags & E1000_FLAG_AUTONEG && s->phy_reg[PHY_CTRL] & MII_CR_AUTO_NEG_EN && s->phy_reg[PHY_CTRL] & MII_CR_RESTART_AUTO_NEG && !(s->phy_reg[PHY_STATUS] & MII_SR_AUTONEG_COMPLETE)) { nc->link_down = false; timer_mod(s->autoneg_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 500); } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(void *VAR_0, int VAR_1) { E1000State *s = VAR_0; NetClientState *nc = qemu_get_queue(s->nic); if (!(s->compat_flags & E1000_FLAG_MIT)) { s->mac_reg[ITR] = s->mac_reg[RDTR] = s->mac_reg[RADV] = s->mac_reg[TADV] = 0; s->mit_irq_level = false; } s->mit_ide = 0; s->mit_timer_on = false; nc->link_down = (s->mac_reg[STATUS] & E1000_STATUS_LU) == 0; if (s->compat_flags & E1000_FLAG_AUTONEG && s->phy_reg[PHY_CTRL] & MII_CR_AUTO_NEG_EN && s->phy_reg[PHY_CTRL] & MII_CR_RESTART_AUTO_NEG && !(s->phy_reg[PHY_STATUS] & MII_SR_AUTONEG_COMPLETE)) { nc->link_down = false; timer_mod(s->autoneg_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 500); } return 0; }
[ "static int FUNC_0(void *VAR_0, int VAR_1)\n{", "E1000State *s = VAR_0;", "NetClientState *nc = qemu_get_queue(s->nic);", "if (!(s->compat_flags & E1000_FLAG_MIT)) {", "s->mac_reg[ITR] = s->mac_reg[RDTR] = s->mac_reg[RADV] =\ns->mac_reg[TADV] = 0;", "s->mit_irq_level = false;", "}", "s->mit_ide = 0;", "s->mit_timer_on = false;", "nc->link_down = (s->mac_reg[STATUS] & E1000_STATUS_LU) == 0;", "if (s->compat_flags & E1000_FLAG_AUTONEG &&\ns->phy_reg[PHY_CTRL] & MII_CR_AUTO_NEG_EN &&\ns->phy_reg[PHY_CTRL] & MII_CR_RESTART_AUTO_NEG &&\n!(s->phy_reg[PHY_STATUS] & MII_SR_AUTONEG_COMPLETE)) {", "nc->link_down = false;", "timer_mod(s->autoneg_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 500);", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13, 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 33 ], [ 37, 39, 41, 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ] ]
11,403
int qemu_opts_do_parse(QemuOpts *opts, const char *params, const char *firstname) { Error *err = NULL; opts_do_parse(opts, params, firstname, false, &err); if (err) { qerror_report_err(err); error_free(err); return -1; } return 0; }
false
qemu
dc523cd348c47372faa7271c9aab2030f94c290d
int qemu_opts_do_parse(QemuOpts *opts, const char *params, const char *firstname) { Error *err = NULL; opts_do_parse(opts, params, firstname, false, &err); if (err) { qerror_report_err(err); error_free(err); return -1; } return 0; }
{ "code": [], "line_no": [] }
int FUNC_0(QemuOpts *VAR_0, const char *VAR_1, const char *VAR_2) { Error *err = NULL; opts_do_parse(VAR_0, VAR_1, VAR_2, false, &err); if (err) { qerror_report_err(err); error_free(err); return -1; } return 0; }
[ "int FUNC_0(QemuOpts *VAR_0, const char *VAR_1, const char *VAR_2)\n{", "Error *err = NULL;", "opts_do_parse(VAR_0, VAR_1, VAR_2, false, &err);", "if (err) {", "qerror_report_err(err);", "error_free(err);", "return -1;", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ] ]
11,404
static int cris_mmu_enabled(uint32_t rw_gc_cfg) { return (rw_gc_cfg & 12) != 0; }
false
qemu
ef29a70d18c2d551cf4bb74b8aa9638caac3391b
static int cris_mmu_enabled(uint32_t rw_gc_cfg) { return (rw_gc_cfg & 12) != 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(uint32_t VAR_0) { return (VAR_0 & 12) != 0; }
[ "static int FUNC_0(uint32_t VAR_0)\n{", "return (VAR_0 & 12) != 0;", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
11,405
static int nut_read_packet(AVFormatContext *s, AVPacket *pkt) { NUTContext *nut = s->priv_data; StreamContext *stream; ByteIOContext *bc = &s->pb; int size, frame_code, flags, size_mul, size_lsb, stream_id; int key_frame = 0; int frame_type= 0; int64_t pts = 0; const int64_t frame_start= url_ftell(bc); if (url_feof(bc)) return -1; frame_code = get_byte(bc); if(frame_code == 'N'){ uint64_t tmp= frame_code; tmp<<=8 ; tmp |= get_byte(bc); tmp<<=16; tmp |= get_be16(bc); tmp<<=32; tmp |= get_be32(bc); if (tmp == KEYFRAME_STARTCODE) { frame_code = get_byte(bc); frame_type = 2; } else av_log(s, AV_LOG_ERROR, "error in zero bit / startcode %LX\n", tmp); } flags= nut->frame_code[frame_code].flags; size_mul= nut->frame_code[frame_code].size_mul; size_lsb= nut->frame_code[frame_code].size_lsb; stream_id= nut->frame_code[frame_code].stream_id_plus1 - 1; if(flags & FLAG_FRAME_TYPE){ reset(s); if(frame_type==2){ get_packetheader(nut, bc, 8+1, 0); }else{ get_packetheader(nut, bc, 1, 0); frame_type= 1; } } if(stream_id==-1) stream_id= get_v(bc); if(stream_id >= s->nb_streams){ av_log(s, AV_LOG_ERROR, "illegal stream_id\n"); return -1; } stream= &nut->stream[stream_id]; if(flags & FLAG_PRED_KEY_FRAME){ if(flags & FLAG_KEY_FRAME) key_frame= !stream->last_key_frame; else key_frame= stream->last_key_frame; }else{ key_frame= !!(flags & FLAG_KEY_FRAME); } if(flags & FLAG_PTS){ if(flags & FLAG_FULL_PTS){ pts= get_v(bc); }else{ int64_t mask = (1<<stream->msb_timestamp_shift)-1; int64_t delta= stream->last_pts - mask/2; pts= ((get_v(bc) - delta)&mask) + delta; } }else{ pts= stream->last_pts + stream->lru_pts_delta[(flags&12)>>2]; } if(size_mul <= size_lsb){ size= stream->lru_size[size_lsb - size_mul]; }else{ if(flags & FLAG_DATA_SIZE) size= size_mul*get_v(bc) + size_lsb; else size= size_lsb; } //av_log(s, AV_LOG_DEBUG, "fs:%lld fc:%d ft:%d kf:%d pts:%lld\n", frame_start, frame_code, frame_type, key_frame, pts); av_new_packet(pkt, size); get_buffer(bc, pkt->data, size); pkt->stream_index = stream_id; if (key_frame) pkt->flags |= PKT_FLAG_KEY; pkt->pts = pts * AV_TIME_BASE * stream->rate_den / stream->rate_num; update(nut, stream_id, frame_start, frame_type, frame_code, key_frame, size, pts); return 0; }
false
FFmpeg
465e1dadbef7596a3eb87089a66bb4ecdc26d3c4
static int nut_read_packet(AVFormatContext *s, AVPacket *pkt) { NUTContext *nut = s->priv_data; StreamContext *stream; ByteIOContext *bc = &s->pb; int size, frame_code, flags, size_mul, size_lsb, stream_id; int key_frame = 0; int frame_type= 0; int64_t pts = 0; const int64_t frame_start= url_ftell(bc); if (url_feof(bc)) return -1; frame_code = get_byte(bc); if(frame_code == 'N'){ uint64_t tmp= frame_code; tmp<<=8 ; tmp |= get_byte(bc); tmp<<=16; tmp |= get_be16(bc); tmp<<=32; tmp |= get_be32(bc); if (tmp == KEYFRAME_STARTCODE) { frame_code = get_byte(bc); frame_type = 2; } else av_log(s, AV_LOG_ERROR, "error in zero bit / startcode %LX\n", tmp); } flags= nut->frame_code[frame_code].flags; size_mul= nut->frame_code[frame_code].size_mul; size_lsb= nut->frame_code[frame_code].size_lsb; stream_id= nut->frame_code[frame_code].stream_id_plus1 - 1; if(flags & FLAG_FRAME_TYPE){ reset(s); if(frame_type==2){ get_packetheader(nut, bc, 8+1, 0); }else{ get_packetheader(nut, bc, 1, 0); frame_type= 1; } } if(stream_id==-1) stream_id= get_v(bc); if(stream_id >= s->nb_streams){ av_log(s, AV_LOG_ERROR, "illegal stream_id\n"); return -1; } stream= &nut->stream[stream_id]; if(flags & FLAG_PRED_KEY_FRAME){ if(flags & FLAG_KEY_FRAME) key_frame= !stream->last_key_frame; else key_frame= stream->last_key_frame; }else{ key_frame= !!(flags & FLAG_KEY_FRAME); } if(flags & FLAG_PTS){ if(flags & FLAG_FULL_PTS){ pts= get_v(bc); }else{ int64_t mask = (1<<stream->msb_timestamp_shift)-1; int64_t delta= stream->last_pts - mask/2; pts= ((get_v(bc) - delta)&mask) + delta; } }else{ pts= stream->last_pts + stream->lru_pts_delta[(flags&12)>>2]; } if(size_mul <= size_lsb){ size= stream->lru_size[size_lsb - size_mul]; }else{ if(flags & FLAG_DATA_SIZE) size= size_mul*get_v(bc) + size_lsb; else size= size_lsb; } av_new_packet(pkt, size); get_buffer(bc, pkt->data, size); pkt->stream_index = stream_id; if (key_frame) pkt->flags |= PKT_FLAG_KEY; pkt->pts = pts * AV_TIME_BASE * stream->rate_den / stream->rate_num; update(nut, stream_id, frame_start, frame_type, frame_code, key_frame, size, pts); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1) { NUTContext *nut = VAR_0->priv_data; StreamContext *stream; ByteIOContext *bc = &VAR_0->pb; int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7; int VAR_8 = 0; int VAR_9= 0; int64_t pts = 0; const int64_t VAR_10= url_ftell(bc); if (url_feof(bc)) return -1; VAR_3 = get_byte(bc); if(VAR_3 == 'N'){ uint64_t tmp= VAR_3; tmp<<=8 ; tmp |= get_byte(bc); tmp<<=16; tmp |= get_be16(bc); tmp<<=32; tmp |= get_be32(bc); if (tmp == KEYFRAME_STARTCODE) { VAR_3 = get_byte(bc); VAR_9 = 2; } else av_log(VAR_0, AV_LOG_ERROR, "error in zero bit / startcode %LX\n", tmp); } VAR_4= nut->VAR_3[VAR_3].VAR_4; VAR_5= nut->VAR_3[VAR_3].VAR_5; VAR_6= nut->VAR_3[VAR_3].VAR_6; VAR_7= nut->VAR_3[VAR_3].stream_id_plus1 - 1; if(VAR_4 & FLAG_FRAME_TYPE){ reset(VAR_0); if(VAR_9==2){ get_packetheader(nut, bc, 8+1, 0); }else{ get_packetheader(nut, bc, 1, 0); VAR_9= 1; } } if(VAR_7==-1) VAR_7= get_v(bc); if(VAR_7 >= VAR_0->nb_streams){ av_log(VAR_0, AV_LOG_ERROR, "illegal VAR_7\n"); return -1; } stream= &nut->stream[VAR_7]; if(VAR_4 & FLAG_PRED_KEY_FRAME){ if(VAR_4 & FLAG_KEY_FRAME) VAR_8= !stream->last_key_frame; else VAR_8= stream->last_key_frame; }else{ VAR_8= !!(VAR_4 & FLAG_KEY_FRAME); } if(VAR_4 & FLAG_PTS){ if(VAR_4 & FLAG_FULL_PTS){ pts= get_v(bc); }else{ int64_t mask = (1<<stream->msb_timestamp_shift)-1; int64_t delta= stream->last_pts - mask/2; pts= ((get_v(bc) - delta)&mask) + delta; } }else{ pts= stream->last_pts + stream->lru_pts_delta[(VAR_4&12)>>2]; } if(VAR_5 <= VAR_6){ VAR_2= stream->lru_size[VAR_6 - VAR_5]; }else{ if(VAR_4 & FLAG_DATA_SIZE) VAR_2= VAR_5*get_v(bc) + VAR_6; else VAR_2= VAR_6; } av_new_packet(VAR_1, VAR_2); get_buffer(bc, VAR_1->data, VAR_2); VAR_1->stream_index = VAR_7; if (VAR_8) VAR_1->VAR_4 |= PKT_FLAG_KEY; VAR_1->pts = pts * AV_TIME_BASE * stream->rate_den / stream->rate_num; update(nut, VAR_7, VAR_10, VAR_9, VAR_3, VAR_8, VAR_2, pts); return 0; }
[ "static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{", "NUTContext *nut = VAR_0->priv_data;", "StreamContext *stream;", "ByteIOContext *bc = &VAR_0->pb;", "int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;", "int VAR_8 = 0;", "int VAR_9= 0;", "int64_t pts = 0;", "const int64_t VAR_10= url_ftell(bc);", "if (url_feof(bc))\nreturn -1;", "VAR_3 = get_byte(bc);", "if(VAR_3 == 'N'){", "uint64_t tmp= VAR_3;", "tmp<<=8 ; tmp |= get_byte(bc);", "tmp<<=16; tmp |= get_be16(bc);", "tmp<<=32; tmp |= get_be32(bc);", "if (tmp == KEYFRAME_STARTCODE)\n{", "VAR_3 = get_byte(bc);", "VAR_9 = 2;", "}", "else\nav_log(VAR_0, AV_LOG_ERROR, \"error in zero bit / startcode %LX\\n\", tmp);", "}", "VAR_4= nut->VAR_3[VAR_3].VAR_4;", "VAR_5= nut->VAR_3[VAR_3].VAR_5;", "VAR_6= nut->VAR_3[VAR_3].VAR_6;", "VAR_7= nut->VAR_3[VAR_3].stream_id_plus1 - 1;", "if(VAR_4 & FLAG_FRAME_TYPE){", "reset(VAR_0);", "if(VAR_9==2){", "get_packetheader(nut, bc, 8+1, 0);", "}else{", "get_packetheader(nut, bc, 1, 0);", "VAR_9= 1;", "}", "}", "if(VAR_7==-1)\nVAR_7= get_v(bc);", "if(VAR_7 >= VAR_0->nb_streams){", "av_log(VAR_0, AV_LOG_ERROR, \"illegal VAR_7\\n\");", "return -1;", "}", "stream= &nut->stream[VAR_7];", "if(VAR_4 & FLAG_PRED_KEY_FRAME){", "if(VAR_4 & FLAG_KEY_FRAME)\nVAR_8= !stream->last_key_frame;", "else\nVAR_8= stream->last_key_frame;", "}else{", "VAR_8= !!(VAR_4 & FLAG_KEY_FRAME);", "}", "if(VAR_4 & FLAG_PTS){", "if(VAR_4 & FLAG_FULL_PTS){", "pts= get_v(bc);", "}else{", "int64_t mask = (1<<stream->msb_timestamp_shift)-1;", "int64_t delta= stream->last_pts - mask/2;", "pts= ((get_v(bc) - delta)&mask) + delta;", "}", "}else{", "pts= stream->last_pts + stream->lru_pts_delta[(VAR_4&12)>>2];", "}", "if(VAR_5 <= VAR_6){", "VAR_2= stream->lru_size[VAR_6 - VAR_5];", "}else{", "if(VAR_4 & FLAG_DATA_SIZE)\nVAR_2= VAR_5*get_v(bc) + VAR_6;", "else\nVAR_2= VAR_6;", "}", "av_new_packet(VAR_1, VAR_2);", "get_buffer(bc, VAR_1->data, VAR_2);", "VAR_1->stream_index = VAR_7;", "if (VAR_8)\nVAR_1->VAR_4 |= PKT_FLAG_KEY;", "VAR_1->pts = pts * AV_TIME_BASE * stream->rate_den / stream->rate_num;", "update(nut, VAR_7, VAR_10, VAR_9, VAR_3, VAR_8, VAR_2, pts);", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23, 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41, 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51, 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 87, 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 103 ], [ 105, 107 ], [ 109, 111 ], [ 113 ], [ 115 ], [ 117 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 145 ], [ 147 ], [ 149 ], [ 151, 153 ], [ 155, 157 ], [ 159 ], [ 167 ], [ 169 ], [ 171 ], [ 173, 175 ], [ 177 ], [ 181 ], [ 185 ], [ 187 ] ]
11,406
void block_job_user_resume(BlockJob *job) { if (job && job->user_paused && job->pause_count > 0) { job->user_paused = false; block_job_iostatus_reset(job); block_job_resume(job); } }
false
qemu
4c241cf5d6ca06c682e033cf8b327b63b1f4b784
void block_job_user_resume(BlockJob *job) { if (job && job->user_paused && job->pause_count > 0) { job->user_paused = false; block_job_iostatus_reset(job); block_job_resume(job); } }
{ "code": [], "line_no": [] }
void FUNC_0(BlockJob *VAR_0) { if (VAR_0 && VAR_0->user_paused && VAR_0->pause_count > 0) { VAR_0->user_paused = false; block_job_iostatus_reset(VAR_0); block_job_resume(VAR_0); } }
[ "void FUNC_0(BlockJob *VAR_0)\n{", "if (VAR_0 && VAR_0->user_paused && VAR_0->pause_count > 0) {", "VAR_0->user_paused = false;", "block_job_iostatus_reset(VAR_0);", "block_job_resume(VAR_0);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ] ]
11,407
static void pc_cpu_reset(void *opaque) { X86CPU *cpu = opaque; CPUX86State *env = &cpu->env; cpu_reset(CPU(cpu)); env->halted = !cpu_is_bsp(env); }
false
qemu
dd673288a8ff73ad77fcc1c255486d2466a772e1
static void pc_cpu_reset(void *opaque) { X86CPU *cpu = opaque; CPUX86State *env = &cpu->env; cpu_reset(CPU(cpu)); env->halted = !cpu_is_bsp(env); }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0) { X86CPU *cpu = VAR_0; CPUX86State *env = &cpu->env; cpu_reset(CPU(cpu)); env->halted = !cpu_is_bsp(env); }
[ "static void FUNC_0(void *VAR_0)\n{", "X86CPU *cpu = VAR_0;", "CPUX86State *env = &cpu->env;", "cpu_reset(CPU(cpu));", "env->halted = !cpu_is_bsp(env);", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ] ]
11,408
static pflash_t *ve_pflash_cfi01_register(hwaddr base, const char *name, DriveInfo *di) { DeviceState *dev = qdev_create(NULL, "cfi.pflash01"); if (di && qdev_prop_set_drive(dev, "drive", blk_bs(blk_by_legacy_dinfo(di)))) { abort(); } qdev_prop_set_uint32(dev, "num-blocks", VEXPRESS_FLASH_SIZE / VEXPRESS_FLASH_SECT_SIZE); qdev_prop_set_uint64(dev, "sector-length", VEXPRESS_FLASH_SECT_SIZE); qdev_prop_set_uint8(dev, "width", 4); qdev_prop_set_uint8(dev, "device-width", 2); qdev_prop_set_uint8(dev, "big-endian", 0); qdev_prop_set_uint16(dev, "id0", 0x89); qdev_prop_set_uint16(dev, "id1", 0x18); qdev_prop_set_uint16(dev, "id2", 0x00); qdev_prop_set_uint16(dev, "id3", 0x00); qdev_prop_set_string(dev, "name", name); qdev_init_nofail(dev); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); return OBJECT_CHECK(pflash_t, (dev), "cfi.pflash01"); }
false
qemu
4be746345f13e99e468c60acbd3a355e8183e3ce
static pflash_t *ve_pflash_cfi01_register(hwaddr base, const char *name, DriveInfo *di) { DeviceState *dev = qdev_create(NULL, "cfi.pflash01"); if (di && qdev_prop_set_drive(dev, "drive", blk_bs(blk_by_legacy_dinfo(di)))) { abort(); } qdev_prop_set_uint32(dev, "num-blocks", VEXPRESS_FLASH_SIZE / VEXPRESS_FLASH_SECT_SIZE); qdev_prop_set_uint64(dev, "sector-length", VEXPRESS_FLASH_SECT_SIZE); qdev_prop_set_uint8(dev, "width", 4); qdev_prop_set_uint8(dev, "device-width", 2); qdev_prop_set_uint8(dev, "big-endian", 0); qdev_prop_set_uint16(dev, "id0", 0x89); qdev_prop_set_uint16(dev, "id1", 0x18); qdev_prop_set_uint16(dev, "id2", 0x00); qdev_prop_set_uint16(dev, "id3", 0x00); qdev_prop_set_string(dev, "name", name); qdev_init_nofail(dev); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); return OBJECT_CHECK(pflash_t, (dev), "cfi.pflash01"); }
{ "code": [], "line_no": [] }
static pflash_t *FUNC_0(hwaddr base, const char *name, DriveInfo *di) { DeviceState *dev = qdev_create(NULL, "cfi.pflash01"); if (di && qdev_prop_set_drive(dev, "drive", blk_bs(blk_by_legacy_dinfo(di)))) { abort(); } qdev_prop_set_uint32(dev, "num-blocks", VEXPRESS_FLASH_SIZE / VEXPRESS_FLASH_SECT_SIZE); qdev_prop_set_uint64(dev, "sector-length", VEXPRESS_FLASH_SECT_SIZE); qdev_prop_set_uint8(dev, "width", 4); qdev_prop_set_uint8(dev, "device-width", 2); qdev_prop_set_uint8(dev, "big-endian", 0); qdev_prop_set_uint16(dev, "id0", 0x89); qdev_prop_set_uint16(dev, "id1", 0x18); qdev_prop_set_uint16(dev, "id2", 0x00); qdev_prop_set_uint16(dev, "id3", 0x00); qdev_prop_set_string(dev, "name", name); qdev_init_nofail(dev); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); return OBJECT_CHECK(pflash_t, (dev), "cfi.pflash01"); }
[ "static pflash_t *FUNC_0(hwaddr base, const char *name,\nDriveInfo *di)\n{", "DeviceState *dev = qdev_create(NULL, \"cfi.pflash01\");", "if (di && qdev_prop_set_drive(dev, \"drive\",\nblk_bs(blk_by_legacy_dinfo(di)))) {", "abort();", "}", "qdev_prop_set_uint32(dev, \"num-blocks\",\nVEXPRESS_FLASH_SIZE / VEXPRESS_FLASH_SECT_SIZE);", "qdev_prop_set_uint64(dev, \"sector-length\", VEXPRESS_FLASH_SECT_SIZE);", "qdev_prop_set_uint8(dev, \"width\", 4);", "qdev_prop_set_uint8(dev, \"device-width\", 2);", "qdev_prop_set_uint8(dev, \"big-endian\", 0);", "qdev_prop_set_uint16(dev, \"id0\", 0x89);", "qdev_prop_set_uint16(dev, \"id1\", 0x18);", "qdev_prop_set_uint16(dev, \"id2\", 0x00);", "qdev_prop_set_uint16(dev, \"id3\", 0x00);", "qdev_prop_set_string(dev, \"name\", name);", "qdev_init_nofail(dev);", "sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);", "return OBJECT_CHECK(pflash_t, (dev), \"cfi.pflash01\");", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11, 13 ], [ 15 ], [ 17 ], [ 21, 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ] ]
11,409
static bool virtio_queue_host_notifier_aio_poll(void *opaque) { EventNotifier *n = opaque; VirtQueue *vq = container_of(n, VirtQueue, host_notifier); bool progress; if (virtio_queue_empty(vq)) { return false; } progress = virtio_queue_notify_aio_vq(vq); /* In case the handler function re-enabled notifications */ virtio_queue_set_notification(vq, 0); return progress; }
false
qemu
dd3dd4ba7b949662d2c67a4c041549b3d79c4b0e
static bool virtio_queue_host_notifier_aio_poll(void *opaque) { EventNotifier *n = opaque; VirtQueue *vq = container_of(n, VirtQueue, host_notifier); bool progress; if (virtio_queue_empty(vq)) { return false; } progress = virtio_queue_notify_aio_vq(vq); virtio_queue_set_notification(vq, 0); return progress; }
{ "code": [], "line_no": [] }
static bool FUNC_0(void *opaque) { EventNotifier *n = opaque; VirtQueue *vq = container_of(n, VirtQueue, host_notifier); bool progress; if (virtio_queue_empty(vq)) { return false; } progress = virtio_queue_notify_aio_vq(vq); virtio_queue_set_notification(vq, 0); return progress; }
[ "static bool FUNC_0(void *opaque)\n{", "EventNotifier *n = opaque;", "VirtQueue *vq = container_of(n, VirtQueue, host_notifier);", "bool progress;", "if (virtio_queue_empty(vq)) {", "return false;", "}", "progress = virtio_queue_notify_aio_vq(vq);", "virtio_queue_set_notification(vq, 0);", "return progress;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 27 ], [ 29 ], [ 31 ] ]
11,410
static void qvirtio_9p_stop(void) { qtest_end(); rmdir(test_share); g_free(test_share); }
false
qemu
a980f7f2c2f4d7e9a1eba4f804cd66dbd458b6d4
static void qvirtio_9p_stop(void) { qtest_end(); rmdir(test_share); g_free(test_share); }
{ "code": [], "line_no": [] }
static void FUNC_0(void) { qtest_end(); rmdir(test_share); g_free(test_share); }
[ "static void FUNC_0(void)\n{", "qtest_end();", "rmdir(test_share);", "g_free(test_share);", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ] ]
11,411
do_kernel_trap(CPUARMState *env) { uint32_t addr; uint32_t cpsr; uint32_t val; switch (env->regs[15]) { case 0xffff0fa0: /* __kernel_memory_barrier */ /* ??? No-op. Will need to do better for SMP. */ break; case 0xffff0fc0: /* __kernel_cmpxchg */ /* XXX: This only works between threads, not between processes. It's probably possible to implement this with native host operations. However things like ldrex/strex are much harder so there's not much point trying. */ start_exclusive(); cpsr = cpsr_read(env); addr = env->regs[2]; /* FIXME: This should SEGV if the access fails. */ if (get_user_u32(val, addr)) val = ~env->regs[0]; if (val == env->regs[0]) { val = env->regs[1]; /* FIXME: Check for segfaults. */ put_user_u32(val, addr); env->regs[0] = 0; cpsr |= CPSR_C; } else { env->regs[0] = -1; cpsr &= ~CPSR_C; } cpsr_write(env, cpsr, CPSR_C); end_exclusive(); break; case 0xffff0fe0: /* __kernel_get_tls */ env->regs[0] = env->cp15.tpidrro_el0; break; case 0xffff0f60: /* __kernel_cmpxchg64 */ arm_kernel_cmpxchg64_helper(env); break; default: return 1; } /* Jump back to the caller. */ addr = env->regs[14]; if (addr & 1) { env->thumb = 1; addr &= ~1; } env->regs[15] = addr; return 0; }
false
qemu
54bf36ed351c526cde0c853079f9ff1ab7e2ff89
do_kernel_trap(CPUARMState *env) { uint32_t addr; uint32_t cpsr; uint32_t val; switch (env->regs[15]) { case 0xffff0fa0: break; case 0xffff0fc0: start_exclusive(); cpsr = cpsr_read(env); addr = env->regs[2]; if (get_user_u32(val, addr)) val = ~env->regs[0]; if (val == env->regs[0]) { val = env->regs[1]; put_user_u32(val, addr); env->regs[0] = 0; cpsr |= CPSR_C; } else { env->regs[0] = -1; cpsr &= ~CPSR_C; } cpsr_write(env, cpsr, CPSR_C); end_exclusive(); break; case 0xffff0fe0: env->regs[0] = env->cp15.tpidrro_el0; break; case 0xffff0f60: arm_kernel_cmpxchg64_helper(env); break; default: return 1; } addr = env->regs[14]; if (addr & 1) { env->thumb = 1; addr &= ~1; } env->regs[15] = addr; return 0; }
{ "code": [], "line_no": [] }
FUNC_0(CPUARMState *VAR_0) { uint32_t addr; uint32_t cpsr; uint32_t val; switch (VAR_0->regs[15]) { case 0xffff0fa0: break; case 0xffff0fc0: start_exclusive(); cpsr = cpsr_read(VAR_0); addr = VAR_0->regs[2]; if (get_user_u32(val, addr)) val = ~VAR_0->regs[0]; if (val == VAR_0->regs[0]) { val = VAR_0->regs[1]; put_user_u32(val, addr); VAR_0->regs[0] = 0; cpsr |= CPSR_C; } else { VAR_0->regs[0] = -1; cpsr &= ~CPSR_C; } cpsr_write(VAR_0, cpsr, CPSR_C); end_exclusive(); break; case 0xffff0fe0: VAR_0->regs[0] = VAR_0->cp15.tpidrro_el0; break; case 0xffff0f60: arm_kernel_cmpxchg64_helper(VAR_0); break; default: return 1; } addr = VAR_0->regs[14]; if (addr & 1) { VAR_0->thumb = 1; addr &= ~1; } VAR_0->regs[15] = addr; return 0; }
[ "FUNC_0(CPUARMState *VAR_0)\n{", "uint32_t addr;", "uint32_t cpsr;", "uint32_t val;", "switch (VAR_0->regs[15]) {", "case 0xffff0fa0:\nbreak;", "case 0xffff0fc0:\nstart_exclusive();", "cpsr = cpsr_read(VAR_0);", "addr = VAR_0->regs[2];", "if (get_user_u32(val, addr))\nval = ~VAR_0->regs[0];", "if (val == VAR_0->regs[0]) {", "val = VAR_0->regs[1];", "put_user_u32(val, addr);", "VAR_0->regs[0] = 0;", "cpsr |= CPSR_C;", "} else {", "VAR_0->regs[0] = -1;", "cpsr &= ~CPSR_C;", "}", "cpsr_write(VAR_0, cpsr, CPSR_C);", "end_exclusive();", "break;", "case 0xffff0fe0:\nVAR_0->regs[0] = VAR_0->cp15.tpidrro_el0;", "break;", "case 0xffff0f60:\narm_kernel_cmpxchg64_helper(VAR_0);", "break;", "default:\nreturn 1;", "}", "addr = VAR_0->regs[14];", "if (addr & 1) {", "VAR_0->thumb = 1;", "addr &= ~1;", "}", "VAR_0->regs[15] = addr;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15, 19 ], [ 21, 31 ], [ 33 ], [ 35 ], [ 39, 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69, 71 ], [ 73 ], [ 75, 77 ], [ 79 ], [ 83, 85 ], [ 87 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 105 ], [ 107 ] ]
11,412
static void event_notifier_dummy_cb(EventNotifier *e) { }
false
qemu
c2b38b277a7882a592f4f2ec955084b2b756daaa
static void event_notifier_dummy_cb(EventNotifier *e) { }
{ "code": [], "line_no": [] }
static void FUNC_0(EventNotifier *VAR_0) { }
[ "static void FUNC_0(EventNotifier *VAR_0)\n{", "}" ]
[ 0, 0 ]
[ [ 1, 3 ], [ 5 ] ]
11,413
uint16_t cpu_inw(CPUState *env, pio_addr_t addr) { uint16_t val; val = ioport_read(1, addr); LOG_IOPORT("inw : %04"FMT_pioaddr" %04"PRIx16"\n", addr, val); #ifdef CONFIG_KQEMU if (env) env->last_io_time = cpu_get_time_fast(); #endif return val; }
false
qemu
4a1418e07bdcfaa3177739e04707ecaec75d89e1
uint16_t cpu_inw(CPUState *env, pio_addr_t addr) { uint16_t val; val = ioport_read(1, addr); LOG_IOPORT("inw : %04"FMT_pioaddr" %04"PRIx16"\n", addr, val); #ifdef CONFIG_KQEMU if (env) env->last_io_time = cpu_get_time_fast(); #endif return val; }
{ "code": [], "line_no": [] }
uint16_t FUNC_0(CPUState *env, pio_addr_t addr) { uint16_t val; val = ioport_read(1, addr); LOG_IOPORT("inw : %04"FMT_pioaddr" %04"PRIx16"\n", addr, val); #ifdef CONFIG_KQEMU if (env) env->last_io_time = cpu_get_time_fast(); #endif return val; }
[ "uint16_t FUNC_0(CPUState *env, pio_addr_t addr)\n{", "uint16_t val;", "val = ioport_read(1, addr);", "LOG_IOPORT(\"inw : %04\"FMT_pioaddr\" %04\"PRIx16\"\\n\", addr, val);", "#ifdef CONFIG_KQEMU\nif (env)\nenv->last_io_time = cpu_get_time_fast();", "#endif\nreturn val;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11, 13, 15 ], [ 17, 19 ], [ 21 ] ]
11,415
static NVDIMMDevice *nvdimm_get_device_by_handle(uint32_t handle) { NVDIMMDevice *nvdimm = NULL; GSList *list, *device_list = nvdimm_get_plugged_device_list(); for (list = device_list; list; list = list->next) { NVDIMMDevice *nvd = list->data; int slot = object_property_get_int(OBJECT(nvd), PC_DIMM_SLOT_PROP, NULL); if (nvdimm_slot_to_handle(slot) == handle) { nvdimm = nvd; break; } } g_slist_free(device_list); return nvdimm; }
false
qemu
cf7c0ff521b0710079aa28f21937fb7dbb3f5224
static NVDIMMDevice *nvdimm_get_device_by_handle(uint32_t handle) { NVDIMMDevice *nvdimm = NULL; GSList *list, *device_list = nvdimm_get_plugged_device_list(); for (list = device_list; list; list = list->next) { NVDIMMDevice *nvd = list->data; int slot = object_property_get_int(OBJECT(nvd), PC_DIMM_SLOT_PROP, NULL); if (nvdimm_slot_to_handle(slot) == handle) { nvdimm = nvd; break; } } g_slist_free(device_list); return nvdimm; }
{ "code": [], "line_no": [] }
static NVDIMMDevice *FUNC_0(uint32_t handle) { NVDIMMDevice *nvdimm = NULL; GSList *list, *device_list = nvdimm_get_plugged_device_list(); for (list = device_list; list; list = list->next) { NVDIMMDevice *nvd = list->data; int slot = object_property_get_int(OBJECT(nvd), PC_DIMM_SLOT_PROP, NULL); if (nvdimm_slot_to_handle(slot) == handle) { nvdimm = nvd; break; } } g_slist_free(device_list); return nvdimm; }
[ "static NVDIMMDevice *FUNC_0(uint32_t handle)\n{", "NVDIMMDevice *nvdimm = NULL;", "GSList *list, *device_list = nvdimm_get_plugged_device_list();", "for (list = device_list; list; list = list->next) {", "NVDIMMDevice *nvd = list->data;", "int slot = object_property_get_int(OBJECT(nvd), PC_DIMM_SLOT_PROP,\nNULL);", "if (nvdimm_slot_to_handle(slot) == handle) {", "nvdimm = nvd;", "break;", "}", "}", "g_slist_free(device_list);", "return nvdimm;", "}" ]
[ 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 ] ]
11,416
int avio_check(const char *url, int flags) { URLContext *h; int ret = ffurl_alloc(&h, url, flags, NULL); if (ret) return ret; if (h->prot->url_check) { ret = h->prot->url_check(h, flags); } else { ret = ffurl_connect(h, NULL); if (ret >= 0) ret = flags; } ffurl_close(h); return ret; }
false
FFmpeg
f495fbe76a2665cdea092999ca2dbb603d13280c
int avio_check(const char *url, int flags) { URLContext *h; int ret = ffurl_alloc(&h, url, flags, NULL); if (ret) return ret; if (h->prot->url_check) { ret = h->prot->url_check(h, flags); } else { ret = ffurl_connect(h, NULL); if (ret >= 0) ret = flags; } ffurl_close(h); return ret; }
{ "code": [], "line_no": [] }
int FUNC_0(const char *VAR_0, int VAR_1) { URLContext *h; int VAR_2 = ffurl_alloc(&h, VAR_0, VAR_1, NULL); if (VAR_2) return VAR_2; if (h->prot->url_check) { VAR_2 = h->prot->url_check(h, VAR_1); } else { VAR_2 = ffurl_connect(h, NULL); if (VAR_2 >= 0) VAR_2 = VAR_1; } ffurl_close(h); return VAR_2; }
[ "int FUNC_0(const char *VAR_0, int VAR_1)\n{", "URLContext *h;", "int VAR_2 = ffurl_alloc(&h, VAR_0, VAR_1, NULL);", "if (VAR_2)\nreturn VAR_2;", "if (h->prot->url_check) {", "VAR_2 = h->prot->url_check(h, VAR_1);", "} else {", "VAR_2 = ffurl_connect(h, NULL);", "if (VAR_2 >= 0)\nVAR_2 = VAR_1;", "}", "ffurl_close(h);", "return VAR_2;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9, 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23, 25 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ] ]
11,417
int x86_cpu_handle_mmu_fault(CPUState *cs, vaddr addr, int is_write1, int mmu_idx) { X86CPU *cpu = X86_CPU(cs); CPUX86State *env = &cpu->env; uint64_t ptep, pte; target_ulong pde_addr, pte_addr; int error_code = 0; int is_dirty, prot, page_size, is_write, is_user; hwaddr paddr; uint64_t rsvd_mask = PG_HI_RSVD_MASK; uint32_t page_offset; target_ulong vaddr; is_user = mmu_idx == MMU_USER_IDX; #if defined(DEBUG_MMU) printf("MMU fault: addr=%" VADDR_PRIx " w=%d u=%d eip=" TARGET_FMT_lx "\n", addr, is_write1, is_user, env->eip); #endif is_write = is_write1 & 1; if (!(env->cr[0] & CR0_PG_MASK)) { pte = addr; #ifdef TARGET_X86_64 if (!(env->hflags & HF_LMA_MASK)) { /* Without long mode we can only address 32bits in real mode */ pte = (uint32_t)pte; } #endif prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; page_size = 4096; goto do_mapping; } if (env->cr[4] & CR4_PAE_MASK) { uint64_t pde, pdpe; target_ulong pdpe_addr; #ifdef TARGET_X86_64 if (env->hflags & HF_LMA_MASK) { uint64_t pml4e_addr, pml4e; int32_t sext; /* test virtual address sign extension */ sext = (int64_t)addr >> 47; if (sext != 0 && sext != -1) { env->error_code = 0; cs->exception_index = EXCP0D_GPF; return 1; } pml4e_addr = ((env->cr[3] & ~0xfff) + (((addr >> 39) & 0x1ff) << 3)) & env->a20_mask; pml4e = ldq_phys(cs->as, pml4e_addr); if (!(pml4e & PG_PRESENT_MASK)) { goto do_fault; } if (pml4e & (rsvd_mask | PG_PSE_MASK)) { goto do_fault_rsvd; } if (!(env->efer & MSR_EFER_NXE) && (pml4e & PG_NX_MASK)) { goto do_fault_rsvd; } if (!(pml4e & PG_ACCESSED_MASK)) { pml4e |= PG_ACCESSED_MASK; stl_phys_notdirty(cs->as, pml4e_addr, pml4e); } ptep = pml4e ^ PG_NX_MASK; pdpe_addr = ((pml4e & PG_ADDRESS_MASK) + (((addr >> 30) & 0x1ff) << 3)) & env->a20_mask; pdpe = ldq_phys(cs->as, pdpe_addr); if (!(pdpe & PG_PRESENT_MASK)) { goto do_fault; } if (pdpe & rsvd_mask) { goto do_fault_rsvd; } if (!(env->efer & MSR_EFER_NXE) && (pdpe & PG_NX_MASK)) { goto do_fault_rsvd; } ptep &= pdpe ^ PG_NX_MASK; if (!(pdpe & PG_ACCESSED_MASK)) { pdpe |= PG_ACCESSED_MASK; stl_phys_notdirty(cs->as, pdpe_addr, pdpe); } if (pdpe & PG_PSE_MASK) { /* 1 GB page */ page_size = 1024 * 1024 * 1024; pte_addr = pdpe_addr; pte = pdpe; goto do_check_protect; } } else #endif { /* XXX: load them when cr3 is loaded ? */ pdpe_addr = ((env->cr[3] & ~0x1f) + ((addr >> 27) & 0x18)) & env->a20_mask; pdpe = ldq_phys(cs->as, pdpe_addr); if (!(pdpe & PG_PRESENT_MASK)) { goto do_fault; } rsvd_mask |= PG_HI_USER_MASK | PG_NX_MASK; if (pdpe & rsvd_mask) { goto do_fault_rsvd; } ptep = PG_NX_MASK | PG_USER_MASK | PG_RW_MASK; } pde_addr = ((pdpe & PG_ADDRESS_MASK) + (((addr >> 21) & 0x1ff) << 3)) & env->a20_mask; pde = ldq_phys(cs->as, pde_addr); if (!(pde & PG_PRESENT_MASK)) { goto do_fault; } if (pde & rsvd_mask) { goto do_fault_rsvd; } if (!(env->efer & MSR_EFER_NXE) && (pde & PG_NX_MASK)) { goto do_fault_rsvd; } ptep &= pde ^ PG_NX_MASK; if (pde & PG_PSE_MASK) { /* 2 MB page */ page_size = 2048 * 1024; pte_addr = pde_addr; pte = pde; goto do_check_protect; } /* 4 KB page */ if (!(pde & PG_ACCESSED_MASK)) { pde |= PG_ACCESSED_MASK; stl_phys_notdirty(cs->as, pde_addr, pde); } pte_addr = ((pde & PG_ADDRESS_MASK) + (((addr >> 12) & 0x1ff) << 3)) & env->a20_mask; pte = ldq_phys(cs->as, pte_addr); if (!(pte & PG_PRESENT_MASK)) { goto do_fault; } if (pte & rsvd_mask) { goto do_fault_rsvd; } if (!(env->efer & MSR_EFER_NXE) && (pte & PG_NX_MASK)) { goto do_fault_rsvd; } /* combine pde and pte nx, user and rw protections */ ptep &= pte ^ PG_NX_MASK; page_size = 4096; } else { uint32_t pde; /* page directory entry */ pde_addr = ((env->cr[3] & ~0xfff) + ((addr >> 20) & 0xffc)) & env->a20_mask; pde = ldl_phys(cs->as, pde_addr); if (!(pde & PG_PRESENT_MASK)) { goto do_fault; } ptep = pde | PG_NX_MASK; /* if PSE bit is set, then we use a 4MB page */ if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) { page_size = 4096 * 1024; pte_addr = pde_addr; pte = pde; goto do_check_protect; } if (!(pde & PG_ACCESSED_MASK)) { pde |= PG_ACCESSED_MASK; stl_phys_notdirty(cs->as, pde_addr, pde); } /* page directory entry */ pte_addr = ((pde & ~0xfff) + ((addr >> 10) & 0xffc)) & env->a20_mask; pte = ldl_phys(cs->as, pte_addr); if (!(pte & PG_PRESENT_MASK)) { goto do_fault; } /* combine pde and pte user and rw protections */ ptep &= pte | PG_NX_MASK; page_size = 4096; rsvd_mask = 0; } do_check_protect: if (pte & rsvd_mask) { goto do_fault_rsvd; } ptep ^= PG_NX_MASK; if ((ptep & PG_NX_MASK) && is_write1 == 2) { goto do_fault_protect; } switch (mmu_idx) { case MMU_USER_IDX: if (!(ptep & PG_USER_MASK)) { goto do_fault_protect; } if (is_write && !(ptep & PG_RW_MASK)) { goto do_fault_protect; } break; case MMU_KSMAP_IDX: if (is_write1 != 2 && (ptep & PG_USER_MASK)) { goto do_fault_protect; } /* fall through */ case MMU_KNOSMAP_IDX: if (is_write1 == 2 && (env->cr[4] & CR4_SMEP_MASK) && (ptep & PG_USER_MASK)) { goto do_fault_protect; } if ((env->cr[0] & CR0_WP_MASK) && is_write && !(ptep & PG_RW_MASK)) { goto do_fault_protect; } break; default: /* cannot happen */ break; } is_dirty = is_write && !(pte & PG_DIRTY_MASK); if (!(pte & PG_ACCESSED_MASK) || is_dirty) { pte |= PG_ACCESSED_MASK; if (is_dirty) { pte |= PG_DIRTY_MASK; } stl_phys_notdirty(cs->as, pte_addr, pte); } /* the page can be put in the TLB */ prot = PAGE_READ; if (!(ptep & PG_NX_MASK)) prot |= PAGE_EXEC; if (pte & PG_DIRTY_MASK) { /* only set write access if already dirty... otherwise wait for dirty access */ if (is_user) { if (ptep & PG_RW_MASK) prot |= PAGE_WRITE; } else { if (!(env->cr[0] & CR0_WP_MASK) || (ptep & PG_RW_MASK)) prot |= PAGE_WRITE; } } do_mapping: pte = pte & env->a20_mask; /* align to page_size */ pte &= PG_ADDRESS_MASK & ~(page_size - 1); /* Even if 4MB pages, we map only one 4KB page in the cache to avoid filling it too fast */ vaddr = addr & TARGET_PAGE_MASK; page_offset = vaddr & (page_size - 1); paddr = pte + page_offset; tlb_set_page(cs, vaddr, paddr, prot, mmu_idx, page_size); return 0; do_fault_rsvd: error_code |= PG_ERROR_RSVD_MASK; do_fault_protect: error_code |= PG_ERROR_P_MASK; do_fault: error_code |= (is_write << PG_ERROR_W_BIT); if (is_user) error_code |= PG_ERROR_U_MASK; if (is_write1 == 2 && (((env->efer & MSR_EFER_NXE) && (env->cr[4] & CR4_PAE_MASK)) || (env->cr[4] & CR4_SMEP_MASK))) error_code |= PG_ERROR_I_D_MASK; if (env->intercept_exceptions & (1 << EXCP0E_PAGE)) { /* cr2 is not modified in case of exceptions */ stq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, control.exit_info_2), addr); } else { env->cr[2] = addr; } env->error_code = error_code; cs->exception_index = EXCP0E_PAGE; return 1; }
false
qemu
e2a32ebbfe899a32a6b063f0f9e7c2593267ea88
int x86_cpu_handle_mmu_fault(CPUState *cs, vaddr addr, int is_write1, int mmu_idx) { X86CPU *cpu = X86_CPU(cs); CPUX86State *env = &cpu->env; uint64_t ptep, pte; target_ulong pde_addr, pte_addr; int error_code = 0; int is_dirty, prot, page_size, is_write, is_user; hwaddr paddr; uint64_t rsvd_mask = PG_HI_RSVD_MASK; uint32_t page_offset; target_ulong vaddr; is_user = mmu_idx == MMU_USER_IDX; #if defined(DEBUG_MMU) printf("MMU fault: addr=%" VADDR_PRIx " w=%d u=%d eip=" TARGET_FMT_lx "\n", addr, is_write1, is_user, env->eip); #endif is_write = is_write1 & 1; if (!(env->cr[0] & CR0_PG_MASK)) { pte = addr; #ifdef TARGET_X86_64 if (!(env->hflags & HF_LMA_MASK)) { pte = (uint32_t)pte; } #endif prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; page_size = 4096; goto do_mapping; } if (env->cr[4] & CR4_PAE_MASK) { uint64_t pde, pdpe; target_ulong pdpe_addr; #ifdef TARGET_X86_64 if (env->hflags & HF_LMA_MASK) { uint64_t pml4e_addr, pml4e; int32_t sext; sext = (int64_t)addr >> 47; if (sext != 0 && sext != -1) { env->error_code = 0; cs->exception_index = EXCP0D_GPF; return 1; } pml4e_addr = ((env->cr[3] & ~0xfff) + (((addr >> 39) & 0x1ff) << 3)) & env->a20_mask; pml4e = ldq_phys(cs->as, pml4e_addr); if (!(pml4e & PG_PRESENT_MASK)) { goto do_fault; } if (pml4e & (rsvd_mask | PG_PSE_MASK)) { goto do_fault_rsvd; } if (!(env->efer & MSR_EFER_NXE) && (pml4e & PG_NX_MASK)) { goto do_fault_rsvd; } if (!(pml4e & PG_ACCESSED_MASK)) { pml4e |= PG_ACCESSED_MASK; stl_phys_notdirty(cs->as, pml4e_addr, pml4e); } ptep = pml4e ^ PG_NX_MASK; pdpe_addr = ((pml4e & PG_ADDRESS_MASK) + (((addr >> 30) & 0x1ff) << 3)) & env->a20_mask; pdpe = ldq_phys(cs->as, pdpe_addr); if (!(pdpe & PG_PRESENT_MASK)) { goto do_fault; } if (pdpe & rsvd_mask) { goto do_fault_rsvd; } if (!(env->efer & MSR_EFER_NXE) && (pdpe & PG_NX_MASK)) { goto do_fault_rsvd; } ptep &= pdpe ^ PG_NX_MASK; if (!(pdpe & PG_ACCESSED_MASK)) { pdpe |= PG_ACCESSED_MASK; stl_phys_notdirty(cs->as, pdpe_addr, pdpe); } if (pdpe & PG_PSE_MASK) { page_size = 1024 * 1024 * 1024; pte_addr = pdpe_addr; pte = pdpe; goto do_check_protect; } } else #endif { pdpe_addr = ((env->cr[3] & ~0x1f) + ((addr >> 27) & 0x18)) & env->a20_mask; pdpe = ldq_phys(cs->as, pdpe_addr); if (!(pdpe & PG_PRESENT_MASK)) { goto do_fault; } rsvd_mask |= PG_HI_USER_MASK | PG_NX_MASK; if (pdpe & rsvd_mask) { goto do_fault_rsvd; } ptep = PG_NX_MASK | PG_USER_MASK | PG_RW_MASK; } pde_addr = ((pdpe & PG_ADDRESS_MASK) + (((addr >> 21) & 0x1ff) << 3)) & env->a20_mask; pde = ldq_phys(cs->as, pde_addr); if (!(pde & PG_PRESENT_MASK)) { goto do_fault; } if (pde & rsvd_mask) { goto do_fault_rsvd; } if (!(env->efer & MSR_EFER_NXE) && (pde & PG_NX_MASK)) { goto do_fault_rsvd; } ptep &= pde ^ PG_NX_MASK; if (pde & PG_PSE_MASK) { page_size = 2048 * 1024; pte_addr = pde_addr; pte = pde; goto do_check_protect; } if (!(pde & PG_ACCESSED_MASK)) { pde |= PG_ACCESSED_MASK; stl_phys_notdirty(cs->as, pde_addr, pde); } pte_addr = ((pde & PG_ADDRESS_MASK) + (((addr >> 12) & 0x1ff) << 3)) & env->a20_mask; pte = ldq_phys(cs->as, pte_addr); if (!(pte & PG_PRESENT_MASK)) { goto do_fault; } if (pte & rsvd_mask) { goto do_fault_rsvd; } if (!(env->efer & MSR_EFER_NXE) && (pte & PG_NX_MASK)) { goto do_fault_rsvd; } ptep &= pte ^ PG_NX_MASK; page_size = 4096; } else { uint32_t pde; pde_addr = ((env->cr[3] & ~0xfff) + ((addr >> 20) & 0xffc)) & env->a20_mask; pde = ldl_phys(cs->as, pde_addr); if (!(pde & PG_PRESENT_MASK)) { goto do_fault; } ptep = pde | PG_NX_MASK; if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) { page_size = 4096 * 1024; pte_addr = pde_addr; pte = pde; goto do_check_protect; } if (!(pde & PG_ACCESSED_MASK)) { pde |= PG_ACCESSED_MASK; stl_phys_notdirty(cs->as, pde_addr, pde); } pte_addr = ((pde & ~0xfff) + ((addr >> 10) & 0xffc)) & env->a20_mask; pte = ldl_phys(cs->as, pte_addr); if (!(pte & PG_PRESENT_MASK)) { goto do_fault; } ptep &= pte | PG_NX_MASK; page_size = 4096; rsvd_mask = 0; } do_check_protect: if (pte & rsvd_mask) { goto do_fault_rsvd; } ptep ^= PG_NX_MASK; if ((ptep & PG_NX_MASK) && is_write1 == 2) { goto do_fault_protect; } switch (mmu_idx) { case MMU_USER_IDX: if (!(ptep & PG_USER_MASK)) { goto do_fault_protect; } if (is_write && !(ptep & PG_RW_MASK)) { goto do_fault_protect; } break; case MMU_KSMAP_IDX: if (is_write1 != 2 && (ptep & PG_USER_MASK)) { goto do_fault_protect; } case MMU_KNOSMAP_IDX: if (is_write1 == 2 && (env->cr[4] & CR4_SMEP_MASK) && (ptep & PG_USER_MASK)) { goto do_fault_protect; } if ((env->cr[0] & CR0_WP_MASK) && is_write && !(ptep & PG_RW_MASK)) { goto do_fault_protect; } break; default: break; } is_dirty = is_write && !(pte & PG_DIRTY_MASK); if (!(pte & PG_ACCESSED_MASK) || is_dirty) { pte |= PG_ACCESSED_MASK; if (is_dirty) { pte |= PG_DIRTY_MASK; } stl_phys_notdirty(cs->as, pte_addr, pte); } prot = PAGE_READ; if (!(ptep & PG_NX_MASK)) prot |= PAGE_EXEC; if (pte & PG_DIRTY_MASK) { if (is_user) { if (ptep & PG_RW_MASK) prot |= PAGE_WRITE; } else { if (!(env->cr[0] & CR0_WP_MASK) || (ptep & PG_RW_MASK)) prot |= PAGE_WRITE; } } do_mapping: pte = pte & env->a20_mask; pte &= PG_ADDRESS_MASK & ~(page_size - 1); vaddr = addr & TARGET_PAGE_MASK; page_offset = vaddr & (page_size - 1); paddr = pte + page_offset; tlb_set_page(cs, vaddr, paddr, prot, mmu_idx, page_size); return 0; do_fault_rsvd: error_code |= PG_ERROR_RSVD_MASK; do_fault_protect: error_code |= PG_ERROR_P_MASK; do_fault: error_code |= (is_write << PG_ERROR_W_BIT); if (is_user) error_code |= PG_ERROR_U_MASK; if (is_write1 == 2 && (((env->efer & MSR_EFER_NXE) && (env->cr[4] & CR4_PAE_MASK)) || (env->cr[4] & CR4_SMEP_MASK))) error_code |= PG_ERROR_I_D_MASK; if (env->intercept_exceptions & (1 << EXCP0E_PAGE)) { stq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, control.exit_info_2), addr); } else { env->cr[2] = addr; } env->error_code = error_code; cs->exception_index = EXCP0E_PAGE; return 1; }
{ "code": [], "line_no": [] }
int FUNC_0(CPUState *VAR_0, vaddr VAR_1, int VAR_2, int VAR_3) { X86CPU *cpu = X86_CPU(VAR_0); CPUX86State *env = &cpu->env; uint64_t ptep, pte; target_ulong pde_addr, pte_addr; int VAR_4 = 0; int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9; hwaddr paddr; uint64_t rsvd_mask = PG_HI_RSVD_MASK; uint32_t page_offset; target_ulong vaddr; VAR_9 = VAR_3 == MMU_USER_IDX; #if defined(DEBUG_MMU) printf("MMU fault: VAR_1=%" VADDR_PRIx " w=%d u=%d eip=" TARGET_FMT_lx "\n", VAR_1, VAR_2, VAR_9, env->eip); #endif VAR_8 = VAR_2 & 1; if (!(env->cr[0] & CR0_PG_MASK)) { pte = VAR_1; #ifdef TARGET_X86_64 if (!(env->hflags & HF_LMA_MASK)) { pte = (uint32_t)pte; } #endif VAR_6 = PAGE_READ | PAGE_WRITE | PAGE_EXEC; VAR_7 = 4096; goto do_mapping; } if (env->cr[4] & CR4_PAE_MASK) { uint64_t pde, pdpe; target_ulong pdpe_addr; #ifdef TARGET_X86_64 if (env->hflags & HF_LMA_MASK) { uint64_t pml4e_addr, pml4e; int32_t sext; sext = (int64_t)VAR_1 >> 47; if (sext != 0 && sext != -1) { env->VAR_4 = 0; VAR_0->exception_index = EXCP0D_GPF; return 1; } pml4e_addr = ((env->cr[3] & ~0xfff) + (((VAR_1 >> 39) & 0x1ff) << 3)) & env->a20_mask; pml4e = ldq_phys(VAR_0->as, pml4e_addr); if (!(pml4e & PG_PRESENT_MASK)) { goto do_fault; } if (pml4e & (rsvd_mask | PG_PSE_MASK)) { goto do_fault_rsvd; } if (!(env->efer & MSR_EFER_NXE) && (pml4e & PG_NX_MASK)) { goto do_fault_rsvd; } if (!(pml4e & PG_ACCESSED_MASK)) { pml4e |= PG_ACCESSED_MASK; stl_phys_notdirty(VAR_0->as, pml4e_addr, pml4e); } ptep = pml4e ^ PG_NX_MASK; pdpe_addr = ((pml4e & PG_ADDRESS_MASK) + (((VAR_1 >> 30) & 0x1ff) << 3)) & env->a20_mask; pdpe = ldq_phys(VAR_0->as, pdpe_addr); if (!(pdpe & PG_PRESENT_MASK)) { goto do_fault; } if (pdpe & rsvd_mask) { goto do_fault_rsvd; } if (!(env->efer & MSR_EFER_NXE) && (pdpe & PG_NX_MASK)) { goto do_fault_rsvd; } ptep &= pdpe ^ PG_NX_MASK; if (!(pdpe & PG_ACCESSED_MASK)) { pdpe |= PG_ACCESSED_MASK; stl_phys_notdirty(VAR_0->as, pdpe_addr, pdpe); } if (pdpe & PG_PSE_MASK) { VAR_7 = 1024 * 1024 * 1024; pte_addr = pdpe_addr; pte = pdpe; goto do_check_protect; } } else #endif { pdpe_addr = ((env->cr[3] & ~0x1f) + ((VAR_1 >> 27) & 0x18)) & env->a20_mask; pdpe = ldq_phys(VAR_0->as, pdpe_addr); if (!(pdpe & PG_PRESENT_MASK)) { goto do_fault; } rsvd_mask |= PG_HI_USER_MASK | PG_NX_MASK; if (pdpe & rsvd_mask) { goto do_fault_rsvd; } ptep = PG_NX_MASK | PG_USER_MASK | PG_RW_MASK; } pde_addr = ((pdpe & PG_ADDRESS_MASK) + (((VAR_1 >> 21) & 0x1ff) << 3)) & env->a20_mask; pde = ldq_phys(VAR_0->as, pde_addr); if (!(pde & PG_PRESENT_MASK)) { goto do_fault; } if (pde & rsvd_mask) { goto do_fault_rsvd; } if (!(env->efer & MSR_EFER_NXE) && (pde & PG_NX_MASK)) { goto do_fault_rsvd; } ptep &= pde ^ PG_NX_MASK; if (pde & PG_PSE_MASK) { VAR_7 = 2048 * 1024; pte_addr = pde_addr; pte = pde; goto do_check_protect; } if (!(pde & PG_ACCESSED_MASK)) { pde |= PG_ACCESSED_MASK; stl_phys_notdirty(VAR_0->as, pde_addr, pde); } pte_addr = ((pde & PG_ADDRESS_MASK) + (((VAR_1 >> 12) & 0x1ff) << 3)) & env->a20_mask; pte = ldq_phys(VAR_0->as, pte_addr); if (!(pte & PG_PRESENT_MASK)) { goto do_fault; } if (pte & rsvd_mask) { goto do_fault_rsvd; } if (!(env->efer & MSR_EFER_NXE) && (pte & PG_NX_MASK)) { goto do_fault_rsvd; } ptep &= pte ^ PG_NX_MASK; VAR_7 = 4096; } else { uint32_t pde; pde_addr = ((env->cr[3] & ~0xfff) + ((VAR_1 >> 20) & 0xffc)) & env->a20_mask; pde = ldl_phys(VAR_0->as, pde_addr); if (!(pde & PG_PRESENT_MASK)) { goto do_fault; } ptep = pde | PG_NX_MASK; if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) { VAR_7 = 4096 * 1024; pte_addr = pde_addr; pte = pde; goto do_check_protect; } if (!(pde & PG_ACCESSED_MASK)) { pde |= PG_ACCESSED_MASK; stl_phys_notdirty(VAR_0->as, pde_addr, pde); } pte_addr = ((pde & ~0xfff) + ((VAR_1 >> 10) & 0xffc)) & env->a20_mask; pte = ldl_phys(VAR_0->as, pte_addr); if (!(pte & PG_PRESENT_MASK)) { goto do_fault; } ptep &= pte | PG_NX_MASK; VAR_7 = 4096; rsvd_mask = 0; } do_check_protect: if (pte & rsvd_mask) { goto do_fault_rsvd; } ptep ^= PG_NX_MASK; if ((ptep & PG_NX_MASK) && VAR_2 == 2) { goto do_fault_protect; } switch (VAR_3) { case MMU_USER_IDX: if (!(ptep & PG_USER_MASK)) { goto do_fault_protect; } if (VAR_8 && !(ptep & PG_RW_MASK)) { goto do_fault_protect; } break; case MMU_KSMAP_IDX: if (VAR_2 != 2 && (ptep & PG_USER_MASK)) { goto do_fault_protect; } case MMU_KNOSMAP_IDX: if (VAR_2 == 2 && (env->cr[4] & CR4_SMEP_MASK) && (ptep & PG_USER_MASK)) { goto do_fault_protect; } if ((env->cr[0] & CR0_WP_MASK) && VAR_8 && !(ptep & PG_RW_MASK)) { goto do_fault_protect; } break; default: break; } VAR_5 = VAR_8 && !(pte & PG_DIRTY_MASK); if (!(pte & PG_ACCESSED_MASK) || VAR_5) { pte |= PG_ACCESSED_MASK; if (VAR_5) { pte |= PG_DIRTY_MASK; } stl_phys_notdirty(VAR_0->as, pte_addr, pte); } VAR_6 = PAGE_READ; if (!(ptep & PG_NX_MASK)) VAR_6 |= PAGE_EXEC; if (pte & PG_DIRTY_MASK) { if (VAR_9) { if (ptep & PG_RW_MASK) VAR_6 |= PAGE_WRITE; } else { if (!(env->cr[0] & CR0_WP_MASK) || (ptep & PG_RW_MASK)) VAR_6 |= PAGE_WRITE; } } do_mapping: pte = pte & env->a20_mask; pte &= PG_ADDRESS_MASK & ~(VAR_7 - 1); vaddr = VAR_1 & TARGET_PAGE_MASK; page_offset = vaddr & (VAR_7 - 1); paddr = pte + page_offset; tlb_set_page(VAR_0, vaddr, paddr, VAR_6, VAR_3, VAR_7); return 0; do_fault_rsvd: VAR_4 |= PG_ERROR_RSVD_MASK; do_fault_protect: VAR_4 |= PG_ERROR_P_MASK; do_fault: VAR_4 |= (VAR_8 << PG_ERROR_W_BIT); if (VAR_9) VAR_4 |= PG_ERROR_U_MASK; if (VAR_2 == 2 && (((env->efer & MSR_EFER_NXE) && (env->cr[4] & CR4_PAE_MASK)) || (env->cr[4] & CR4_SMEP_MASK))) VAR_4 |= PG_ERROR_I_D_MASK; if (env->intercept_exceptions & (1 << EXCP0E_PAGE)) { stq_phys(VAR_0->as, env->vm_vmcb + offsetof(struct vmcb, control.exit_info_2), VAR_1); } else { env->cr[2] = VAR_1; } env->VAR_4 = VAR_4; VAR_0->exception_index = EXCP0E_PAGE; return 1; }
[ "int FUNC_0(CPUState *VAR_0, vaddr VAR_1,\nint VAR_2, int VAR_3)\n{", "X86CPU *cpu = X86_CPU(VAR_0);", "CPUX86State *env = &cpu->env;", "uint64_t ptep, pte;", "target_ulong pde_addr, pte_addr;", "int VAR_4 = 0;", "int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;", "hwaddr paddr;", "uint64_t rsvd_mask = PG_HI_RSVD_MASK;", "uint32_t page_offset;", "target_ulong vaddr;", "VAR_9 = VAR_3 == MMU_USER_IDX;", "#if defined(DEBUG_MMU)\nprintf(\"MMU fault: VAR_1=%\" VADDR_PRIx \" w=%d u=%d eip=\" TARGET_FMT_lx \"\\n\",\nVAR_1, VAR_2, VAR_9, env->eip);", "#endif\nVAR_8 = VAR_2 & 1;", "if (!(env->cr[0] & CR0_PG_MASK)) {", "pte = VAR_1;", "#ifdef TARGET_X86_64\nif (!(env->hflags & HF_LMA_MASK)) {", "pte = (uint32_t)pte;", "}", "#endif\nVAR_6 = PAGE_READ | PAGE_WRITE | PAGE_EXEC;", "VAR_7 = 4096;", "goto do_mapping;", "}", "if (env->cr[4] & CR4_PAE_MASK) {", "uint64_t pde, pdpe;", "target_ulong pdpe_addr;", "#ifdef TARGET_X86_64\nif (env->hflags & HF_LMA_MASK) {", "uint64_t pml4e_addr, pml4e;", "int32_t sext;", "sext = (int64_t)VAR_1 >> 47;", "if (sext != 0 && sext != -1) {", "env->VAR_4 = 0;", "VAR_0->exception_index = EXCP0D_GPF;", "return 1;", "}", "pml4e_addr = ((env->cr[3] & ~0xfff) + (((VAR_1 >> 39) & 0x1ff) << 3)) &\nenv->a20_mask;", "pml4e = ldq_phys(VAR_0->as, pml4e_addr);", "if (!(pml4e & PG_PRESENT_MASK)) {", "goto do_fault;", "}", "if (pml4e & (rsvd_mask | PG_PSE_MASK)) {", "goto do_fault_rsvd;", "}", "if (!(env->efer & MSR_EFER_NXE) && (pml4e & PG_NX_MASK)) {", "goto do_fault_rsvd;", "}", "if (!(pml4e & PG_ACCESSED_MASK)) {", "pml4e |= PG_ACCESSED_MASK;", "stl_phys_notdirty(VAR_0->as, pml4e_addr, pml4e);", "}", "ptep = pml4e ^ PG_NX_MASK;", "pdpe_addr = ((pml4e & PG_ADDRESS_MASK) + (((VAR_1 >> 30) & 0x1ff) << 3)) &\nenv->a20_mask;", "pdpe = ldq_phys(VAR_0->as, pdpe_addr);", "if (!(pdpe & PG_PRESENT_MASK)) {", "goto do_fault;", "}", "if (pdpe & rsvd_mask) {", "goto do_fault_rsvd;", "}", "if (!(env->efer & MSR_EFER_NXE) && (pdpe & PG_NX_MASK)) {", "goto do_fault_rsvd;", "}", "ptep &= pdpe ^ PG_NX_MASK;", "if (!(pdpe & PG_ACCESSED_MASK)) {", "pdpe |= PG_ACCESSED_MASK;", "stl_phys_notdirty(VAR_0->as, pdpe_addr, pdpe);", "}", "if (pdpe & PG_PSE_MASK) {", "VAR_7 = 1024 * 1024 * 1024;", "pte_addr = pdpe_addr;", "pte = pdpe;", "goto do_check_protect;", "}", "} else", "#endif\n{", "pdpe_addr = ((env->cr[3] & ~0x1f) + ((VAR_1 >> 27) & 0x18)) &\nenv->a20_mask;", "pdpe = ldq_phys(VAR_0->as, pdpe_addr);", "if (!(pdpe & PG_PRESENT_MASK)) {", "goto do_fault;", "}", "rsvd_mask |= PG_HI_USER_MASK | PG_NX_MASK;", "if (pdpe & rsvd_mask) {", "goto do_fault_rsvd;", "}", "ptep = PG_NX_MASK | PG_USER_MASK | PG_RW_MASK;", "}", "pde_addr = ((pdpe & PG_ADDRESS_MASK) + (((VAR_1 >> 21) & 0x1ff) << 3)) &\nenv->a20_mask;", "pde = ldq_phys(VAR_0->as, pde_addr);", "if (!(pde & PG_PRESENT_MASK)) {", "goto do_fault;", "}", "if (pde & rsvd_mask) {", "goto do_fault_rsvd;", "}", "if (!(env->efer & MSR_EFER_NXE) && (pde & PG_NX_MASK)) {", "goto do_fault_rsvd;", "}", "ptep &= pde ^ PG_NX_MASK;", "if (pde & PG_PSE_MASK) {", "VAR_7 = 2048 * 1024;", "pte_addr = pde_addr;", "pte = pde;", "goto do_check_protect;", "}", "if (!(pde & PG_ACCESSED_MASK)) {", "pde |= PG_ACCESSED_MASK;", "stl_phys_notdirty(VAR_0->as, pde_addr, pde);", "}", "pte_addr = ((pde & PG_ADDRESS_MASK) + (((VAR_1 >> 12) & 0x1ff) << 3)) &\nenv->a20_mask;", "pte = ldq_phys(VAR_0->as, pte_addr);", "if (!(pte & PG_PRESENT_MASK)) {", "goto do_fault;", "}", "if (pte & rsvd_mask) {", "goto do_fault_rsvd;", "}", "if (!(env->efer & MSR_EFER_NXE) && (pte & PG_NX_MASK)) {", "goto do_fault_rsvd;", "}", "ptep &= pte ^ PG_NX_MASK;", "VAR_7 = 4096;", "} else {", "uint32_t pde;", "pde_addr = ((env->cr[3] & ~0xfff) + ((VAR_1 >> 20) & 0xffc)) &\nenv->a20_mask;", "pde = ldl_phys(VAR_0->as, pde_addr);", "if (!(pde & PG_PRESENT_MASK)) {", "goto do_fault;", "}", "ptep = pde | PG_NX_MASK;", "if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {", "VAR_7 = 4096 * 1024;", "pte_addr = pde_addr;", "pte = pde;", "goto do_check_protect;", "}", "if (!(pde & PG_ACCESSED_MASK)) {", "pde |= PG_ACCESSED_MASK;", "stl_phys_notdirty(VAR_0->as, pde_addr, pde);", "}", "pte_addr = ((pde & ~0xfff) + ((VAR_1 >> 10) & 0xffc)) &\nenv->a20_mask;", "pte = ldl_phys(VAR_0->as, pte_addr);", "if (!(pte & PG_PRESENT_MASK)) {", "goto do_fault;", "}", "ptep &= pte | PG_NX_MASK;", "VAR_7 = 4096;", "rsvd_mask = 0;", "}", "do_check_protect:\nif (pte & rsvd_mask) {", "goto do_fault_rsvd;", "}", "ptep ^= PG_NX_MASK;", "if ((ptep & PG_NX_MASK) && VAR_2 == 2) {", "goto do_fault_protect;", "}", "switch (VAR_3) {", "case MMU_USER_IDX:\nif (!(ptep & PG_USER_MASK)) {", "goto do_fault_protect;", "}", "if (VAR_8 && !(ptep & PG_RW_MASK)) {", "goto do_fault_protect;", "}", "break;", "case MMU_KSMAP_IDX:\nif (VAR_2 != 2 && (ptep & PG_USER_MASK)) {", "goto do_fault_protect;", "}", "case MMU_KNOSMAP_IDX:\nif (VAR_2 == 2 && (env->cr[4] & CR4_SMEP_MASK) &&\n(ptep & PG_USER_MASK)) {", "goto do_fault_protect;", "}", "if ((env->cr[0] & CR0_WP_MASK) &&\nVAR_8 && !(ptep & PG_RW_MASK)) {", "goto do_fault_protect;", "}", "break;", "default:\nbreak;", "}", "VAR_5 = VAR_8 && !(pte & PG_DIRTY_MASK);", "if (!(pte & PG_ACCESSED_MASK) || VAR_5) {", "pte |= PG_ACCESSED_MASK;", "if (VAR_5) {", "pte |= PG_DIRTY_MASK;", "}", "stl_phys_notdirty(VAR_0->as, pte_addr, pte);", "}", "VAR_6 = PAGE_READ;", "if (!(ptep & PG_NX_MASK))\nVAR_6 |= PAGE_EXEC;", "if (pte & PG_DIRTY_MASK) {", "if (VAR_9) {", "if (ptep & PG_RW_MASK)\nVAR_6 |= PAGE_WRITE;", "} else {", "if (!(env->cr[0] & CR0_WP_MASK) ||\n(ptep & PG_RW_MASK))\nVAR_6 |= PAGE_WRITE;", "}", "}", "do_mapping:\npte = pte & env->a20_mask;", "pte &= PG_ADDRESS_MASK & ~(VAR_7 - 1);", "vaddr = VAR_1 & TARGET_PAGE_MASK;", "page_offset = vaddr & (VAR_7 - 1);", "paddr = pte + page_offset;", "tlb_set_page(VAR_0, vaddr, paddr, VAR_6, VAR_3, VAR_7);", "return 0;", "do_fault_rsvd:\nVAR_4 |= PG_ERROR_RSVD_MASK;", "do_fault_protect:\nVAR_4 |= PG_ERROR_P_MASK;", "do_fault:\nVAR_4 |= (VAR_8 << PG_ERROR_W_BIT);", "if (VAR_9)\nVAR_4 |= PG_ERROR_U_MASK;", "if (VAR_2 == 2 &&\n(((env->efer & MSR_EFER_NXE) &&\n(env->cr[4] & CR4_PAE_MASK)) ||\n(env->cr[4] & CR4_SMEP_MASK)))\nVAR_4 |= PG_ERROR_I_D_MASK;", "if (env->intercept_exceptions & (1 << EXCP0E_PAGE)) {", "stq_phys(VAR_0->as,\nenv->vm_vmcb + offsetof(struct vmcb, control.exit_info_2),\nVAR_1);", "} else {", "env->cr[2] = VAR_1;", "}", "env->VAR_4 = VAR_4;", "VAR_0->exception_index = EXCP0E_PAGE;", "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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31, 33, 35 ], [ 37, 39 ], [ 43 ], [ 45 ], [ 47, 49 ], [ 53 ], [ 55 ], [ 57, 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69 ], [ 71 ], [ 73 ], [ 77, 79 ], [ 81 ], [ 83 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 103, 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137, 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187, 189 ], [ 193, 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 219, 221 ], [ 223 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 261 ], [ 263 ], [ 265 ], [ 267 ], [ 269, 271 ], [ 273 ], [ 275 ], [ 277 ], [ 279 ], [ 281 ], [ 283 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 295 ], [ 297 ], [ 299 ], [ 301 ], [ 307, 309 ], [ 311 ], [ 313 ], [ 315 ], [ 317 ], [ 319 ], [ 325 ], [ 327 ], [ 329 ], [ 331 ], [ 333 ], [ 335 ], [ 339 ], [ 341 ], [ 343 ], [ 345 ], [ 351, 353 ], [ 355 ], [ 357 ], [ 359 ], [ 361 ], [ 365 ], [ 367 ], [ 369 ], [ 371 ], [ 375, 377 ], [ 379 ], [ 381 ], [ 383 ], [ 385 ], [ 387 ], [ 389 ], [ 391 ], [ 393, 395 ], [ 397 ], [ 399 ], [ 401 ], [ 403 ], [ 405 ], [ 407 ], [ 411, 413 ], [ 415 ], [ 417 ], [ 421, 423, 425 ], [ 427 ], [ 429 ], [ 431, 433 ], [ 435 ], [ 437 ], [ 439 ], [ 443, 445 ], [ 447 ], [ 449 ], [ 451 ], [ 453 ], [ 455 ], [ 457 ], [ 459 ], [ 461 ], [ 463 ], [ 469 ], [ 471, 473 ], [ 475 ], [ 481 ], [ 483, 485 ], [ 487 ], [ 489, 491, 493 ], [ 495 ], [ 497 ], [ 499, 501 ], [ 507 ], [ 515 ], [ 517 ], [ 519 ], [ 523 ], [ 525 ], [ 527, 529 ], [ 531, 533 ], [ 535, 537 ], [ 539, 541 ], [ 543, 545, 547, 549, 551 ], [ 553 ], [ 557, 559, 561 ], [ 563 ], [ 565 ], [ 567 ], [ 569 ], [ 571 ], [ 573 ], [ 575 ] ]
11,418
int kvmppc_reset_htab(int shift_hint) { uint32_t shift = shift_hint; if (!kvm_enabled()) { /* Full emulation, tell caller to allocate htab itself */ return 0; } if (kvm_check_extension(kvm_state, KVM_CAP_PPC_ALLOC_HTAB)) { int ret; ret = kvm_vm_ioctl(kvm_state, KVM_PPC_ALLOCATE_HTAB, &shift); if (ret == -ENOTTY) { /* At least some versions of PR KVM advertise the * capability, but don't implement the ioctl(). Oops. * Return 0 so that we allocate the htab in qemu, as is * correct for PR. */ return 0; } else if (ret < 0) { return ret; } return shift; } /* We have a kernel that predates the htab reset calls. For PR * KVM, we need to allocate the htab ourselves, for an HV KVM of * this era, it has allocated a 16MB fixed size hash table * already. Kernels of this era have the GET_PVINFO capability * only on PR, so we use this hack to determine the right * answer */ if (kvm_check_extension(kvm_state, KVM_CAP_PPC_GET_PVINFO)) { /* PR - tell caller to allocate htab */ return 0; } else { /* HV - assume 16MB kernel allocated htab */ return 24; } }
false
qemu
96c9cff0ab986f3a0606e1a96c5b00e6a7c675c6
int kvmppc_reset_htab(int shift_hint) { uint32_t shift = shift_hint; if (!kvm_enabled()) { return 0; } if (kvm_check_extension(kvm_state, KVM_CAP_PPC_ALLOC_HTAB)) { int ret; ret = kvm_vm_ioctl(kvm_state, KVM_PPC_ALLOCATE_HTAB, &shift); if (ret == -ENOTTY) { return 0; } else if (ret < 0) { return ret; } return shift; } if (kvm_check_extension(kvm_state, KVM_CAP_PPC_GET_PVINFO)) { return 0; } else { return 24; } }
{ "code": [], "line_no": [] }
int FUNC_0(int VAR_0) { uint32_t shift = VAR_0; if (!kvm_enabled()) { return 0; } if (kvm_check_extension(kvm_state, KVM_CAP_PPC_ALLOC_HTAB)) { int VAR_1; VAR_1 = kvm_vm_ioctl(kvm_state, KVM_PPC_ALLOCATE_HTAB, &shift); if (VAR_1 == -ENOTTY) { return 0; } else if (VAR_1 < 0) { return VAR_1; } return shift; } if (kvm_check_extension(kvm_state, KVM_CAP_PPC_GET_PVINFO)) { return 0; } else { return 24; } }
[ "int FUNC_0(int VAR_0)\n{", "uint32_t shift = VAR_0;", "if (!kvm_enabled()) {", "return 0;", "}", "if (kvm_check_extension(kvm_state, KVM_CAP_PPC_ALLOC_HTAB)) {", "int VAR_1;", "VAR_1 = kvm_vm_ioctl(kvm_state, KVM_PPC_ALLOCATE_HTAB, &shift);", "if (VAR_1 == -ENOTTY) {", "return 0;", "} else if (VAR_1 < 0) {", "return VAR_1;", "}", "return shift;", "}", "if (kvm_check_extension(kvm_state, KVM_CAP_PPC_GET_PVINFO)) {", "return 0;", "} else {", "return 24;", "}", "}" ]
[ 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 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 59 ], [ 63 ], [ 65 ], [ 69 ], [ 71 ], [ 73 ] ]
11,419
static int mov_read_trak(MOVContext *c, ByteIOContext *pb, MOVAtom atom) { AVStream *st; MOVStreamContext *sc; int ret; st = av_new_stream(c->fc, c->fc->nb_streams); if (!st) return AVERROR(ENOMEM); sc = av_mallocz(sizeof(MOVStreamContext)); if (!sc) return AVERROR(ENOMEM); st->priv_data = sc; st->codec->codec_type = CODEC_TYPE_DATA; sc->ffindex = st->index; if ((ret = mov_read_default(c, pb, atom)) < 0) return ret; /* sanity checks */ if(sc->chunk_count && (!sc->stts_count || !sc->stsc_count || (!sc->sample_size && !sc->sample_count))){ av_log(c->fc, AV_LOG_ERROR, "stream %d, missing mandatory atoms, broken header\n", st->index); sc->sample_count = 0; //ignore track return 0; } if(!sc->time_rate) sc->time_rate=1; if(!sc->time_scale) sc->time_scale= c->time_scale; av_set_pts_info(st, 64, sc->time_rate, sc->time_scale); if (st->codec->codec_type == CODEC_TYPE_AUDIO && !st->codec->frame_size && sc->stts_count == 1) { st->codec->frame_size = av_rescale(sc->stts_data[0].duration, st->codec->sample_rate, sc->time_scale); dprintf(c->fc, "frame size %d\n", st->codec->frame_size); } if(st->duration != AV_NOPTS_VALUE){ assert(st->duration % sc->time_rate == 0); st->duration /= sc->time_rate; } mov_build_index(c, st); if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) { if (url_fopen(&sc->pb, sc->drefs[sc->dref_id-1].path, URL_RDONLY) < 0) av_log(c->fc, AV_LOG_ERROR, "stream %d, error opening file %s: %s\n", st->index, sc->drefs[sc->dref_id-1].path, strerror(errno)); } else sc->pb = c->fc->pb; switch (st->codec->codec_id) { #if CONFIG_H261_DECODER case CODEC_ID_H261: #endif #if CONFIG_H263_DECODER case CODEC_ID_H263: #endif #if CONFIG_MPEG4_DECODER case CODEC_ID_MPEG4: #endif st->codec->width= 0; /* let decoder init width/height */ st->codec->height= 0; break; } /* Do not need those anymore. */ av_freep(&sc->chunk_offsets); av_freep(&sc->stsc_data); av_freep(&sc->sample_sizes); av_freep(&sc->keyframes); av_freep(&sc->stts_data); return 0; }
false
FFmpeg
f0f2218dce194ff50d1fe7ed39011595660143ad
static int mov_read_trak(MOVContext *c, ByteIOContext *pb, MOVAtom atom) { AVStream *st; MOVStreamContext *sc; int ret; st = av_new_stream(c->fc, c->fc->nb_streams); if (!st) return AVERROR(ENOMEM); sc = av_mallocz(sizeof(MOVStreamContext)); if (!sc) return AVERROR(ENOMEM); st->priv_data = sc; st->codec->codec_type = CODEC_TYPE_DATA; sc->ffindex = st->index; if ((ret = mov_read_default(c, pb, atom)) < 0) return ret; if(sc->chunk_count && (!sc->stts_count || !sc->stsc_count || (!sc->sample_size && !sc->sample_count))){ av_log(c->fc, AV_LOG_ERROR, "stream %d, missing mandatory atoms, broken header\n", st->index); sc->sample_count = 0; return 0; } if(!sc->time_rate) sc->time_rate=1; if(!sc->time_scale) sc->time_scale= c->time_scale; av_set_pts_info(st, 64, sc->time_rate, sc->time_scale); if (st->codec->codec_type == CODEC_TYPE_AUDIO && !st->codec->frame_size && sc->stts_count == 1) { st->codec->frame_size = av_rescale(sc->stts_data[0].duration, st->codec->sample_rate, sc->time_scale); dprintf(c->fc, "frame size %d\n", st->codec->frame_size); } if(st->duration != AV_NOPTS_VALUE){ assert(st->duration % sc->time_rate == 0); st->duration /= sc->time_rate; } mov_build_index(c, st); if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) { if (url_fopen(&sc->pb, sc->drefs[sc->dref_id-1].path, URL_RDONLY) < 0) av_log(c->fc, AV_LOG_ERROR, "stream %d, error opening file %s: %s\n", st->index, sc->drefs[sc->dref_id-1].path, strerror(errno)); } else sc->pb = c->fc->pb; switch (st->codec->codec_id) { #if CONFIG_H261_DECODER case CODEC_ID_H261: #endif #if CONFIG_H263_DECODER case CODEC_ID_H263: #endif #if CONFIG_MPEG4_DECODER case CODEC_ID_MPEG4: #endif st->codec->width= 0; st->codec->height= 0; break; } av_freep(&sc->chunk_offsets); av_freep(&sc->stsc_data); av_freep(&sc->sample_sizes); av_freep(&sc->keyframes); av_freep(&sc->stts_data); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(MOVContext *VAR_0, ByteIOContext *VAR_1, MOVAtom VAR_2) { AVStream *st; MOVStreamContext *sc; int VAR_3; st = av_new_stream(VAR_0->fc, VAR_0->fc->nb_streams); if (!st) return AVERROR(ENOMEM); sc = av_mallocz(sizeof(MOVStreamContext)); if (!sc) return AVERROR(ENOMEM); st->priv_data = sc; st->codec->codec_type = CODEC_TYPE_DATA; sc->ffindex = st->index; if ((VAR_3 = mov_read_default(VAR_0, VAR_1, VAR_2)) < 0) return VAR_3; if(sc->chunk_count && (!sc->stts_count || !sc->stsc_count || (!sc->sample_size && !sc->sample_count))){ av_log(VAR_0->fc, AV_LOG_ERROR, "stream %d, missing mandatory atoms, broken header\n", st->index); sc->sample_count = 0; return 0; } if(!sc->time_rate) sc->time_rate=1; if(!sc->time_scale) sc->time_scale= VAR_0->time_scale; av_set_pts_info(st, 64, sc->time_rate, sc->time_scale); if (st->codec->codec_type == CODEC_TYPE_AUDIO && !st->codec->frame_size && sc->stts_count == 1) { st->codec->frame_size = av_rescale(sc->stts_data[0].duration, st->codec->sample_rate, sc->time_scale); dprintf(VAR_0->fc, "frame size %d\n", st->codec->frame_size); } if(st->duration != AV_NOPTS_VALUE){ assert(st->duration % sc->time_rate == 0); st->duration /= sc->time_rate; } mov_build_index(VAR_0, st); if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) { if (url_fopen(&sc->VAR_1, sc->drefs[sc->dref_id-1].path, URL_RDONLY) < 0) av_log(VAR_0->fc, AV_LOG_ERROR, "stream %d, error opening file %s: %s\n", st->index, sc->drefs[sc->dref_id-1].path, strerror(errno)); } else sc->VAR_1 = VAR_0->fc->VAR_1; switch (st->codec->codec_id) { #if CONFIG_H261_DECODER case CODEC_ID_H261: #endif #if CONFIG_H263_DECODER case CODEC_ID_H263: #endif #if CONFIG_MPEG4_DECODER case CODEC_ID_MPEG4: #endif st->codec->width= 0; st->codec->height= 0; break; } av_freep(&sc->chunk_offsets); av_freep(&sc->stsc_data); av_freep(&sc->sample_sizes); av_freep(&sc->keyframes); av_freep(&sc->stts_data); return 0; }
[ "static int FUNC_0(MOVContext *VAR_0, ByteIOContext *VAR_1, MOVAtom VAR_2)\n{", "AVStream *st;", "MOVStreamContext *sc;", "int VAR_3;", "st = av_new_stream(VAR_0->fc, VAR_0->fc->nb_streams);", "if (!st) return AVERROR(ENOMEM);", "sc = av_mallocz(sizeof(MOVStreamContext));", "if (!sc) return AVERROR(ENOMEM);", "st->priv_data = sc;", "st->codec->codec_type = CODEC_TYPE_DATA;", "sc->ffindex = st->index;", "if ((VAR_3 = mov_read_default(VAR_0, VAR_1, VAR_2)) < 0)\nreturn VAR_3;", "if(sc->chunk_count && (!sc->stts_count || !sc->stsc_count ||\n(!sc->sample_size && !sc->sample_count))){", "av_log(VAR_0->fc, AV_LOG_ERROR, \"stream %d, missing mandatory atoms, broken header\\n\",\nst->index);", "sc->sample_count = 0;", "return 0;", "}", "if(!sc->time_rate)\nsc->time_rate=1;", "if(!sc->time_scale)\nsc->time_scale= VAR_0->time_scale;", "av_set_pts_info(st, 64, sc->time_rate, sc->time_scale);", "if (st->codec->codec_type == CODEC_TYPE_AUDIO &&\n!st->codec->frame_size && sc->stts_count == 1) {", "st->codec->frame_size = av_rescale(sc->stts_data[0].duration,\nst->codec->sample_rate, sc->time_scale);", "dprintf(VAR_0->fc, \"frame size %d\\n\", st->codec->frame_size);", "}", "if(st->duration != AV_NOPTS_VALUE){", "assert(st->duration % sc->time_rate == 0);", "st->duration /= sc->time_rate;", "}", "mov_build_index(VAR_0, st);", "if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) {", "if (url_fopen(&sc->VAR_1, sc->drefs[sc->dref_id-1].path, URL_RDONLY) < 0)\nav_log(VAR_0->fc, AV_LOG_ERROR, \"stream %d, error opening file %s: %s\\n\",\nst->index, sc->drefs[sc->dref_id-1].path, strerror(errno));", "} else", "sc->VAR_1 = VAR_0->fc->VAR_1;", "switch (st->codec->codec_id) {", "#if CONFIG_H261_DECODER\ncase CODEC_ID_H261:\n#endif\n#if CONFIG_H263_DECODER\ncase CODEC_ID_H263:\n#endif\n#if CONFIG_MPEG4_DECODER\ncase CODEC_ID_MPEG4:\n#endif\nst->codec->width= 0;", "st->codec->height= 0;", "break;", "}", "av_freep(&sc->chunk_offsets);", "av_freep(&sc->stsc_data);", "av_freep(&sc->sample_sizes);", "av_freep(&sc->keyframes);", "av_freep(&sc->stts_data);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 31, 33 ], [ 39, 41 ], [ 43, 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53, 55 ], [ 57, 59 ], [ 61 ], [ 65, 67 ], [ 69, 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 89 ], [ 93 ], [ 95, 97, 99 ], [ 101 ], [ 103 ], [ 107 ], [ 109, 111, 113, 115, 117, 119, 121, 123, 125, 127 ], [ 129 ], [ 131 ], [ 133 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 151 ], [ 153 ] ]
11,420
static void FUNCC(pred8x8_horizontal_add)(uint8_t *pix, const int *block_offset, const int16_t *block, ptrdiff_t stride) { int i; for(i=0; i<4; i++) FUNCC(pred4x4_horizontal_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride); }
false
FFmpeg
1acd7d594c15aa491729c837ad3519d3469e620a
static void FUNCC(pred8x8_horizontal_add)(uint8_t *pix, const int *block_offset, const int16_t *block, ptrdiff_t stride) { int i; for(i=0; i<4; i++) FUNCC(pred4x4_horizontal_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride); }
{ "code": [], "line_no": [] }
static void FUNC_0(pred8x8_horizontal_add)(uint8_t *pix, const int *block_offset, const int16_t *block, ptrdiff_t stride) { int VAR_0; for(VAR_0=0; VAR_0<4; VAR_0++) FUNC_0(pred4x4_horizontal_add)(pix + block_offset[VAR_0], block + VAR_0*16*sizeof(pixel), stride); }
[ "static void FUNC_0(pred8x8_horizontal_add)(uint8_t *pix, const int *block_offset,\nconst int16_t *block,\nptrdiff_t stride)\n{", "int VAR_0;", "for(VAR_0=0; VAR_0<4; VAR_0++)", "FUNC_0(pred4x4_horizontal_add)(pix + block_offset[VAR_0], block + VAR_0*16*sizeof(pixel), stride);", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ] ]
11,421
void init_checksum(ByteIOContext *s, unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum){ s->update_checksum= update_checksum; s->checksum= s->update_checksum(checksum, NULL, 0); s->checksum_ptr= s->buf_ptr; }
false
FFmpeg
465e1dadbef7596a3eb87089a66bb4ecdc26d3c4
void init_checksum(ByteIOContext *s, unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum){ s->update_checksum= update_checksum; s->checksum= s->update_checksum(checksum, NULL, 0); s->checksum_ptr= s->buf_ptr; }
{ "code": [], "line_no": [] }
void FUNC_0(ByteIOContext *VAR_0, unsigned long (*VAR_1)(unsigned long VAR_2, const uint8_t *VAR_3, unsigned int VAR_4), unsigned long VAR_5){ VAR_0->VAR_1= VAR_1; VAR_0->VAR_5= VAR_0->VAR_1(VAR_5, NULL, 0); VAR_0->checksum_ptr= VAR_0->buf_ptr; }
[ "void FUNC_0(ByteIOContext *VAR_0, unsigned long (*VAR_1)(unsigned long VAR_2, const uint8_t *VAR_3, unsigned int VAR_4), unsigned long VAR_5){", "VAR_0->VAR_1= VAR_1;", "VAR_0->VAR_5= VAR_0->VAR_1(VAR_5, NULL, 0);", "VAR_0->checksum_ptr= VAR_0->buf_ptr;", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1 ], [ 3 ], [ 5 ], [ 7 ], [ 9 ] ]
11,422
static av_cold int hap_init(AVCodecContext *avctx) { HapContext *ctx = avctx->priv_data; int ratio; int corrected_chunk_count; int ret = av_image_check_size(avctx->width, avctx->height, 0, avctx); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Invalid video size %dx%d.\n", avctx->width, avctx->height); return ret; } if (avctx->width % 4 || avctx->height % 4) { av_log(avctx, AV_LOG_ERROR, "Video size %dx%d is not multiple of 4.\n", avctx->width, avctx->height); return AVERROR_INVALIDDATA; } ff_texturedspenc_init(&ctx->dxtc); switch (ctx->opt_tex_fmt) { case HAP_FMT_RGBDXT1: ratio = 8; avctx->codec_tag = MKTAG('H', 'a', 'p', '1'); avctx->bits_per_coded_sample = 24; ctx->tex_fun = ctx->dxtc.dxt1_block; break; case HAP_FMT_RGBADXT5: ratio = 4; avctx->codec_tag = MKTAG('H', 'a', 'p', '5'); avctx->bits_per_coded_sample = 32; ctx->tex_fun = ctx->dxtc.dxt5_block; break; case HAP_FMT_YCOCGDXT5: ratio = 4; avctx->codec_tag = MKTAG('H', 'a', 'p', 'Y'); avctx->bits_per_coded_sample = 24; ctx->tex_fun = ctx->dxtc.dxt5ys_block; break; default: av_log(avctx, AV_LOG_ERROR, "Invalid format %02X\n", ctx->opt_tex_fmt); return AVERROR_INVALIDDATA; } /* Texture compression ratio is constant, so can we computer * beforehand the final size of the uncompressed buffer. */ ctx->tex_size = FFALIGN(avctx->width, TEXTURE_BLOCK_W) * FFALIGN(avctx->height, TEXTURE_BLOCK_H) * 4 / ratio; /* Round the chunk count to divide evenly on DXT block edges */ corrected_chunk_count = av_clip(ctx->opt_chunk_count, 1, HAP_MAX_CHUNKS); while ((ctx->tex_size / (64 / ratio)) % corrected_chunk_count != 0) { corrected_chunk_count--; } if (corrected_chunk_count != ctx->opt_chunk_count) { av_log(avctx, AV_LOG_INFO, "%d chunks requested but %d used.\n", ctx->opt_chunk_count, corrected_chunk_count); } ret = ff_hap_set_chunk_count(ctx, corrected_chunk_count, 1); if (ret != 0) return ret; ctx->max_snappy = snappy_max_compressed_length(ctx->tex_size / corrected_chunk_count); ctx->tex_buf = av_malloc(ctx->tex_size); if (!ctx->tex_buf) return AVERROR(ENOMEM); return 0; }
false
FFmpeg
bd6fa80d56fcda385da1c8f21eb83282a7930899
static av_cold int hap_init(AVCodecContext *avctx) { HapContext *ctx = avctx->priv_data; int ratio; int corrected_chunk_count; int ret = av_image_check_size(avctx->width, avctx->height, 0, avctx); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Invalid video size %dx%d.\n", avctx->width, avctx->height); return ret; } if (avctx->width % 4 || avctx->height % 4) { av_log(avctx, AV_LOG_ERROR, "Video size %dx%d is not multiple of 4.\n", avctx->width, avctx->height); return AVERROR_INVALIDDATA; } ff_texturedspenc_init(&ctx->dxtc); switch (ctx->opt_tex_fmt) { case HAP_FMT_RGBDXT1: ratio = 8; avctx->codec_tag = MKTAG('H', 'a', 'p', '1'); avctx->bits_per_coded_sample = 24; ctx->tex_fun = ctx->dxtc.dxt1_block; break; case HAP_FMT_RGBADXT5: ratio = 4; avctx->codec_tag = MKTAG('H', 'a', 'p', '5'); avctx->bits_per_coded_sample = 32; ctx->tex_fun = ctx->dxtc.dxt5_block; break; case HAP_FMT_YCOCGDXT5: ratio = 4; avctx->codec_tag = MKTAG('H', 'a', 'p', 'Y'); avctx->bits_per_coded_sample = 24; ctx->tex_fun = ctx->dxtc.dxt5ys_block; break; default: av_log(avctx, AV_LOG_ERROR, "Invalid format %02X\n", ctx->opt_tex_fmt); return AVERROR_INVALIDDATA; } ctx->tex_size = FFALIGN(avctx->width, TEXTURE_BLOCK_W) * FFALIGN(avctx->height, TEXTURE_BLOCK_H) * 4 / ratio; corrected_chunk_count = av_clip(ctx->opt_chunk_count, 1, HAP_MAX_CHUNKS); while ((ctx->tex_size / (64 / ratio)) % corrected_chunk_count != 0) { corrected_chunk_count--; } if (corrected_chunk_count != ctx->opt_chunk_count) { av_log(avctx, AV_LOG_INFO, "%d chunks requested but %d used.\n", ctx->opt_chunk_count, corrected_chunk_count); } ret = ff_hap_set_chunk_count(ctx, corrected_chunk_count, 1); if (ret != 0) return ret; ctx->max_snappy = snappy_max_compressed_length(ctx->tex_size / corrected_chunk_count); ctx->tex_buf = av_malloc(ctx->tex_size); if (!ctx->tex_buf) return AVERROR(ENOMEM); return 0; }
{ "code": [], "line_no": [] }
static av_cold int FUNC_0(AVCodecContext *avctx) { HapContext *ctx = avctx->priv_data; int VAR_0; int VAR_1; int VAR_2 = av_image_check_size(avctx->width, avctx->height, 0, avctx); if (VAR_2 < 0) { av_log(avctx, AV_LOG_ERROR, "Invalid video size %dx%d.\n", avctx->width, avctx->height); return VAR_2; } if (avctx->width % 4 || avctx->height % 4) { av_log(avctx, AV_LOG_ERROR, "Video size %dx%d is not multiple of 4.\n", avctx->width, avctx->height); return AVERROR_INVALIDDATA; } ff_texturedspenc_init(&ctx->dxtc); switch (ctx->opt_tex_fmt) { case HAP_FMT_RGBDXT1: VAR_0 = 8; avctx->codec_tag = MKTAG('H', 'a', 'p', '1'); avctx->bits_per_coded_sample = 24; ctx->tex_fun = ctx->dxtc.dxt1_block; break; case HAP_FMT_RGBADXT5: VAR_0 = 4; avctx->codec_tag = MKTAG('H', 'a', 'p', '5'); avctx->bits_per_coded_sample = 32; ctx->tex_fun = ctx->dxtc.dxt5_block; break; case HAP_FMT_YCOCGDXT5: VAR_0 = 4; avctx->codec_tag = MKTAG('H', 'a', 'p', 'Y'); avctx->bits_per_coded_sample = 24; ctx->tex_fun = ctx->dxtc.dxt5ys_block; break; default: av_log(avctx, AV_LOG_ERROR, "Invalid format %02X\n", ctx->opt_tex_fmt); return AVERROR_INVALIDDATA; } ctx->tex_size = FFALIGN(avctx->width, TEXTURE_BLOCK_W) * FFALIGN(avctx->height, TEXTURE_BLOCK_H) * 4 / VAR_0; VAR_1 = av_clip(ctx->opt_chunk_count, 1, HAP_MAX_CHUNKS); while ((ctx->tex_size / (64 / VAR_0)) % VAR_1 != 0) { VAR_1--; } if (VAR_1 != ctx->opt_chunk_count) { av_log(avctx, AV_LOG_INFO, "%d chunks requested but %d used.\n", ctx->opt_chunk_count, VAR_1); } VAR_2 = ff_hap_set_chunk_count(ctx, VAR_1, 1); if (VAR_2 != 0) return VAR_2; ctx->max_snappy = snappy_max_compressed_length(ctx->tex_size / VAR_1); ctx->tex_buf = av_malloc(ctx->tex_size); if (!ctx->tex_buf) return AVERROR(ENOMEM); return 0; }
[ "static av_cold int FUNC_0(AVCodecContext *avctx)\n{", "HapContext *ctx = avctx->priv_data;", "int VAR_0;", "int VAR_1;", "int VAR_2 = av_image_check_size(avctx->width, avctx->height, 0, avctx);", "if (VAR_2 < 0) {", "av_log(avctx, AV_LOG_ERROR, \"Invalid video size %dx%d.\\n\",\navctx->width, avctx->height);", "return VAR_2;", "}", "if (avctx->width % 4 || avctx->height % 4) {", "av_log(avctx, AV_LOG_ERROR, \"Video size %dx%d is not multiple of 4.\\n\",\navctx->width, avctx->height);", "return AVERROR_INVALIDDATA;", "}", "ff_texturedspenc_init(&ctx->dxtc);", "switch (ctx->opt_tex_fmt) {", "case HAP_FMT_RGBDXT1:\nVAR_0 = 8;", "avctx->codec_tag = MKTAG('H', 'a', 'p', '1');", "avctx->bits_per_coded_sample = 24;", "ctx->tex_fun = ctx->dxtc.dxt1_block;", "break;", "case HAP_FMT_RGBADXT5:\nVAR_0 = 4;", "avctx->codec_tag = MKTAG('H', 'a', 'p', '5');", "avctx->bits_per_coded_sample = 32;", "ctx->tex_fun = ctx->dxtc.dxt5_block;", "break;", "case HAP_FMT_YCOCGDXT5:\nVAR_0 = 4;", "avctx->codec_tag = MKTAG('H', 'a', 'p', 'Y');", "avctx->bits_per_coded_sample = 24;", "ctx->tex_fun = ctx->dxtc.dxt5ys_block;", "break;", "default:\nav_log(avctx, AV_LOG_ERROR, \"Invalid format %02X\\n\", ctx->opt_tex_fmt);", "return AVERROR_INVALIDDATA;", "}", "ctx->tex_size = FFALIGN(avctx->width, TEXTURE_BLOCK_W) *\nFFALIGN(avctx->height, TEXTURE_BLOCK_H) * 4 / VAR_0;", "VAR_1 = av_clip(ctx->opt_chunk_count, 1, HAP_MAX_CHUNKS);", "while ((ctx->tex_size / (64 / VAR_0)) % VAR_1 != 0) {", "VAR_1--;", "}", "if (VAR_1 != ctx->opt_chunk_count) {", "av_log(avctx, AV_LOG_INFO, \"%d chunks requested but %d used.\\n\",\nctx->opt_chunk_count, VAR_1);", "}", "VAR_2 = ff_hap_set_chunk_count(ctx, VAR_1, 1);", "if (VAR_2 != 0)\nreturn VAR_2;", "ctx->max_snappy = snappy_max_compressed_length(ctx->tex_size / VAR_1);", "ctx->tex_buf = av_malloc(ctx->tex_size);", "if (!ctx->tex_buf)\nreturn AVERROR(ENOMEM);", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17, 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29, 31 ], [ 33 ], [ 35 ], [ 39 ], [ 43 ], [ 45, 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57, 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69, 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81, 83 ], [ 85 ], [ 87 ], [ 95, 97 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113, 115 ], [ 117 ], [ 119 ], [ 121, 123 ], [ 127 ], [ 131 ], [ 133, 135 ], [ 139 ], [ 141 ] ]
11,424
static int mpeg_mux_write_packet(AVFormatContext *ctx, int stream_index, const uint8_t *buf, int size, int64_t pts) { MpegMuxContext *s = ctx->priv_data; AVStream *st = ctx->streams[stream_index]; StreamInfo *stream = st->priv_data; int len; while (size > 0) { /* set pts */ if (stream->start_pts == -1) { stream->start_pts = pts; } len = s->packet_data_max_size - stream->buffer_ptr; if (len > size) len = size; memcpy(stream->buffer + stream->buffer_ptr, buf, len); stream->buffer_ptr += len; buf += len; size -= len; while (stream->buffer_ptr >= s->packet_data_max_size) { /* output the packet */ if (stream->start_pts == -1) stream->start_pts = pts; flush_packet(ctx, stream_index, 0); } } return 0; }
false
FFmpeg
fa0f62c37d90c0760bddccba2054578e2c61ae1a
static int mpeg_mux_write_packet(AVFormatContext *ctx, int stream_index, const uint8_t *buf, int size, int64_t pts) { MpegMuxContext *s = ctx->priv_data; AVStream *st = ctx->streams[stream_index]; StreamInfo *stream = st->priv_data; int len; while (size > 0) { if (stream->start_pts == -1) { stream->start_pts = pts; } len = s->packet_data_max_size - stream->buffer_ptr; if (len > size) len = size; memcpy(stream->buffer + stream->buffer_ptr, buf, len); stream->buffer_ptr += len; buf += len; size -= len; while (stream->buffer_ptr >= s->packet_data_max_size) { if (stream->start_pts == -1) stream->start_pts = pts; flush_packet(ctx, stream_index, 0); } } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFormatContext *VAR_0, int VAR_1, const uint8_t *VAR_2, int VAR_3, int64_t VAR_4) { MpegMuxContext *s = VAR_0->priv_data; AVStream *st = VAR_0->streams[VAR_1]; StreamInfo *stream = st->priv_data; int VAR_5; while (VAR_3 > 0) { if (stream->start_pts == -1) { stream->start_pts = VAR_4; } VAR_5 = s->packet_data_max_size - stream->buffer_ptr; if (VAR_5 > VAR_3) VAR_5 = VAR_3; memcpy(stream->buffer + stream->buffer_ptr, VAR_2, VAR_5); stream->buffer_ptr += VAR_5; VAR_2 += VAR_5; VAR_3 -= VAR_5; while (stream->buffer_ptr >= s->packet_data_max_size) { if (stream->start_pts == -1) stream->start_pts = VAR_4; flush_packet(VAR_0, VAR_1, 0); } } return 0; }
[ "static int FUNC_0(AVFormatContext *VAR_0, int VAR_1,\nconst uint8_t *VAR_2, int VAR_3, int64_t VAR_4)\n{", "MpegMuxContext *s = VAR_0->priv_data;", "AVStream *st = VAR_0->streams[VAR_1];", "StreamInfo *stream = st->priv_data;", "int VAR_5;", "while (VAR_3 > 0) {", "if (stream->start_pts == -1) {", "stream->start_pts = VAR_4;", "}", "VAR_5 = s->packet_data_max_size - stream->buffer_ptr;", "if (VAR_5 > VAR_3)\nVAR_5 = VAR_3;", "memcpy(stream->buffer + stream->buffer_ptr, VAR_2, VAR_5);", "stream->buffer_ptr += VAR_5;", "VAR_2 += VAR_5;", "VAR_3 -= VAR_5;", "while (stream->buffer_ptr >= s->packet_data_max_size) {", "if (stream->start_pts == -1)\nstream->start_pts = VAR_4;", "flush_packet(VAR_0, VAR_1, 0);", "}", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29, 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45, 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ] ]
11,425
static int decode_i_block(FourXContext *f, int16_t *block) { int code, i, j, level, val; if (get_bits_left(&f->gb) < 2){ av_log(f->avctx, AV_LOG_ERROR, "%d bits left before decode_i_block()\n", get_bits_left(&f->gb)); return -1; } /* DC coef */ val = get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3); if (val >> 4) av_log(f->avctx, AV_LOG_ERROR, "error dc run != 0\n"); if (val) val = get_xbits(&f->gb, val); val = val * dequant_table[0] + f->last_dc; f->last_dc = block[0] = val; /* AC coefs */ i = 1; for (;;) { code = get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3); /* EOB */ if (code == 0) break; if (code == 0xf0) { i += 16; } else { level = get_xbits(&f->gb, code & 0xf); i += code >> 4; if (i >= 64) { av_log(f->avctx, AV_LOG_ERROR, "run %d oveflow\n", i); return 0; } j = ff_zigzag_direct[i]; block[j] = level * dequant_table[j]; i++; if (i >= 64) break; } } return 0; }
false
FFmpeg
13c56e9a9cf18f33bcbc2dc1a5cf2a5f98ca9702
static int decode_i_block(FourXContext *f, int16_t *block) { int code, i, j, level, val; if (get_bits_left(&f->gb) < 2){ av_log(f->avctx, AV_LOG_ERROR, "%d bits left before decode_i_block()\n", get_bits_left(&f->gb)); return -1; } val = get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3); if (val >> 4) av_log(f->avctx, AV_LOG_ERROR, "error dc run != 0\n"); if (val) val = get_xbits(&f->gb, val); val = val * dequant_table[0] + f->last_dc; f->last_dc = block[0] = val; i = 1; for (;;) { code = get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3); if (code == 0) break; if (code == 0xf0) { i += 16; } else { level = get_xbits(&f->gb, code & 0xf); i += code >> 4; if (i >= 64) { av_log(f->avctx, AV_LOG_ERROR, "run %d oveflow\n", i); return 0; } j = ff_zigzag_direct[i]; block[j] = level * dequant_table[j]; i++; if (i >= 64) break; } } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(FourXContext *VAR_0, int16_t *VAR_1) { int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6; if (get_bits_left(&VAR_0->gb) < 2){ av_log(VAR_0->avctx, AV_LOG_ERROR, "%d bits left before FUNC_0()\n", get_bits_left(&VAR_0->gb)); return -1; } VAR_6 = get_vlc2(&VAR_0->pre_gb, VAR_0->pre_vlc.table, ACDC_VLC_BITS, 3); if (VAR_6 >> 4) av_log(VAR_0->avctx, AV_LOG_ERROR, "error dc run != 0\n"); if (VAR_6) VAR_6 = get_xbits(&VAR_0->gb, VAR_6); VAR_6 = VAR_6 * dequant_table[0] + VAR_0->last_dc; VAR_0->last_dc = VAR_1[0] = VAR_6; VAR_3 = 1; for (;;) { VAR_2 = get_vlc2(&VAR_0->pre_gb, VAR_0->pre_vlc.table, ACDC_VLC_BITS, 3); if (VAR_2 == 0) break; if (VAR_2 == 0xf0) { VAR_3 += 16; } else { VAR_5 = get_xbits(&VAR_0->gb, VAR_2 & 0xf); VAR_3 += VAR_2 >> 4; if (VAR_3 >= 64) { av_log(VAR_0->avctx, AV_LOG_ERROR, "run %d oveflow\n", VAR_3); return 0; } VAR_4 = ff_zigzag_direct[VAR_3]; VAR_1[VAR_4] = VAR_5 * dequant_table[VAR_4]; VAR_3++; if (VAR_3 >= 64) break; } } return 0; }
[ "static int FUNC_0(FourXContext *VAR_0, int16_t *VAR_1)\n{", "int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6;", "if (get_bits_left(&VAR_0->gb) < 2){", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"%d bits left before FUNC_0()\\n\", get_bits_left(&VAR_0->gb));", "return -1;", "}", "VAR_6 = get_vlc2(&VAR_0->pre_gb, VAR_0->pre_vlc.table, ACDC_VLC_BITS, 3);", "if (VAR_6 >> 4)\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"error dc run != 0\\n\");", "if (VAR_6)\nVAR_6 = get_xbits(&VAR_0->gb, VAR_6);", "VAR_6 = VAR_6 * dequant_table[0] + VAR_0->last_dc;", "VAR_0->last_dc = VAR_1[0] = VAR_6;", "VAR_3 = 1;", "for (;;) {", "VAR_2 = get_vlc2(&VAR_0->pre_gb, VAR_0->pre_vlc.table, ACDC_VLC_BITS, 3);", "if (VAR_2 == 0)\nbreak;", "if (VAR_2 == 0xf0) {", "VAR_3 += 16;", "} else {", "VAR_5 = get_xbits(&VAR_0->gb, VAR_2 & 0xf);", "VAR_3 += VAR_2 >> 4;", "if (VAR_3 >= 64) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"run %d oveflow\\n\", VAR_3);", "return 0;", "}", "VAR_4 = ff_zigzag_direct[VAR_3];", "VAR_1[VAR_4] = VAR_5 * dequant_table[VAR_4];", "VAR_3++;", "if (VAR_3 >= 64)\nbreak;", "}", "}", "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 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 21 ], [ 23, 25 ], [ 29, 31 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 51, 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 79 ], [ 81, 83 ], [ 85 ], [ 87 ], [ 91 ], [ 93 ] ]
11,426
static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y, const uint8_t **buf, int buf_size) { MpegEncContext *s = &s1->mpeg_enc_ctx; AVCodecContext *avctx= s->avctx; const int field_pic= s->picture_structure != PICT_FRAME; const int lowres= s->avctx->lowres; s->resync_mb_x= s->resync_mb_y= -1; if (mb_y >= s->mb_height){ av_log(s->avctx, AV_LOG_ERROR, "slice below image (%d >= %d)\n", mb_y, s->mb_height); return -1; } init_get_bits(&s->gb, *buf, buf_size*8); ff_mpeg1_clean_buffers(s); s->interlaced_dct = 0; s->qscale = get_qscale(s); if(s->qscale == 0){ av_log(s->avctx, AV_LOG_ERROR, "qscale == 0\n"); return -1; } /* extra slice info */ while (get_bits1(&s->gb) != 0) { skip_bits(&s->gb, 8); } s->mb_x=0; for(;;) { int code = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2); if (code < 0){ av_log(s->avctx, AV_LOG_ERROR, "first mb_incr damaged\n"); return -1; } if (code >= 33) { if (code == 33) { s->mb_x += 33; } /* otherwise, stuffing, nothing to do */ } else { s->mb_x += code; break; } } if(s->mb_x >= (unsigned)s->mb_width){ av_log(s->avctx, AV_LOG_ERROR, "initial skip overflow\n"); return -1; } if (avctx->hwaccel) { const uint8_t *buf_end, *buf_start = *buf - 4; /* include start_code */ int start_code = -1; buf_end = ff_find_start_code(buf_start + 2, *buf + buf_size, &start_code); if (buf_end < *buf + buf_size) buf_end -= 4; s->mb_y = mb_y; if (avctx->hwaccel->decode_slice(avctx, buf_start, buf_end - buf_start) < 0) return DECODE_SLICE_ERROR; *buf = buf_end; return DECODE_SLICE_OK; } s->resync_mb_x= s->mb_x; s->resync_mb_y= s->mb_y= mb_y; s->mb_skip_run= 0; ff_init_block_index(s); if (s->mb_y==0 && s->mb_x==0 && (s->first_field || s->picture_structure==PICT_FRAME)) { if(s->avctx->debug&FF_DEBUG_PICT_INFO){ av_log(s->avctx, AV_LOG_DEBUG, "qp:%d fc:%2d%2d%2d%2d %s %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n", s->qscale, s->mpeg_f_code[0][0],s->mpeg_f_code[0][1],s->mpeg_f_code[1][0],s->mpeg_f_code[1][1], s->pict_type == FF_I_TYPE ? "I" : (s->pict_type == FF_P_TYPE ? "P" : (s->pict_type == FF_B_TYPE ? "B" : "S")), s->progressive_sequence ? "ps" :"", s->progressive_frame ? "pf" : "", s->alternate_scan ? "alt" :"", s->top_field_first ? "top" :"", s->intra_dc_precision, s->picture_structure, s->frame_pred_frame_dct, s->concealment_motion_vectors, s->q_scale_type, s->intra_vlc_format, s->repeat_first_field, s->chroma_420_type ? "420" :""); } } for(;;) { //If 1, we memcpy blocks in xvmcvideo. if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration > 1) ff_xvmc_init_block(s);//set s->block if(mpeg_decode_mb(s, s->block) < 0) return -1; if(s->current_picture.motion_val[0] && !s->encoding){ //note motion_val is normally NULL unless we want to extract the MVs const int wrap = s->b8_stride; int xy = s->mb_x*2 + s->mb_y*2*wrap; int motion_x, motion_y, dir, i; for(i=0; i<2; i++){ for(dir=0; dir<2; dir++){ if (s->mb_intra || (dir==1 && s->pict_type != FF_B_TYPE)) { motion_x = motion_y = 0; }else if (s->mv_type == MV_TYPE_16X16 || (s->mv_type == MV_TYPE_FIELD && field_pic)){ motion_x = s->mv[dir][0][0]; motion_y = s->mv[dir][0][1]; } else /*if ((s->mv_type == MV_TYPE_FIELD) || (s->mv_type == MV_TYPE_16X8))*/ { motion_x = s->mv[dir][i][0]; motion_y = s->mv[dir][i][1]; } s->current_picture.motion_val[dir][xy ][0] = motion_x; s->current_picture.motion_val[dir][xy ][1] = motion_y; s->current_picture.motion_val[dir][xy + 1][0] = motion_x; s->current_picture.motion_val[dir][xy + 1][1] = motion_y; s->current_picture.ref_index [dir][xy ]= s->current_picture.ref_index [dir][xy + 1]= s->field_select[dir][i]; assert(s->field_select[dir][i]==0 || s->field_select[dir][i]==1); } xy += wrap; } } s->dest[0] += 16 >> lowres; s->dest[1] +=(16 >> lowres) >> s->chroma_x_shift; s->dest[2] +=(16 >> lowres) >> s->chroma_x_shift; MPV_decode_mb(s, s->block); if (++s->mb_x >= s->mb_width) { const int mb_size= 16>>s->avctx->lowres; ff_draw_horiz_band(s, mb_size*(s->mb_y>>field_pic), mb_size); s->mb_x = 0; s->mb_y += 1<<field_pic; if(s->mb_y >= s->mb_height){ int left= get_bits_left(&s->gb); int is_d10= s->chroma_format==2 && s->pict_type==FF_I_TYPE && avctx->profile==0 && avctx->level==5 && s->intra_dc_precision == 2 && s->q_scale_type == 1 && s->alternate_scan == 0 && s->progressive_frame == 0 /* vbv_delay == 0xBBB || 0xE10*/; if(left < 0 || (left && show_bits(&s->gb, FFMIN(left, 23)) && !is_d10) || (avctx->error_recognition >= FF_ER_AGGRESSIVE && left>8)){ av_log(avctx, AV_LOG_ERROR, "end mismatch left=%d %0X\n", left, show_bits(&s->gb, FFMIN(left, 23))); return -1; }else goto eos; } ff_init_block_index(s); } /* skip mb handling */ if (s->mb_skip_run == -1) { /* read increment again */ s->mb_skip_run = 0; for(;;) { int code = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2); if (code < 0){ av_log(s->avctx, AV_LOG_ERROR, "mb incr damaged\n"); return -1; } if (code >= 33) { if (code == 33) { s->mb_skip_run += 33; }else if(code == 35){ if(s->mb_skip_run != 0 || show_bits(&s->gb, 15) != 0){ av_log(s->avctx, AV_LOG_ERROR, "slice mismatch\n"); return -1; } goto eos; /* end of slice */ } /* otherwise, stuffing, nothing to do */ } else { s->mb_skip_run += code; break; } } if(s->mb_skip_run){ int i; if(s->pict_type == FF_I_TYPE){ av_log(s->avctx, AV_LOG_ERROR, "skipped MB in I frame at %d %d\n", s->mb_x, s->mb_y); return -1; } /* skip mb */ s->mb_intra = 0; for(i=0;i<12;i++) s->block_last_index[i] = -1; if(s->picture_structure == PICT_FRAME) s->mv_type = MV_TYPE_16X16; else s->mv_type = MV_TYPE_FIELD; if (s->pict_type == FF_P_TYPE) { /* if P type, zero motion vector is implied */ s->mv_dir = MV_DIR_FORWARD; s->mv[0][0][0] = s->mv[0][0][1] = 0; s->last_mv[0][0][0] = s->last_mv[0][0][1] = 0; s->last_mv[0][1][0] = s->last_mv[0][1][1] = 0; s->field_select[0][0]= (s->picture_structure - 1) & 1; } else { /* if B type, reuse previous vectors and directions */ s->mv[0][0][0] = s->last_mv[0][0][0]; s->mv[0][0][1] = s->last_mv[0][0][1]; s->mv[1][0][0] = s->last_mv[1][0][0]; s->mv[1][0][1] = s->last_mv[1][0][1]; } } } } eos: // end of slice *buf += (get_bits_count(&s->gb)-1)/8; //printf("y %d %d %d %d\n", s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y); return 0; }
false
FFmpeg
52069c4d3c92f68605fadf012ab0da594ee9bae4
static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y, const uint8_t **buf, int buf_size) { MpegEncContext *s = &s1->mpeg_enc_ctx; AVCodecContext *avctx= s->avctx; const int field_pic= s->picture_structure != PICT_FRAME; const int lowres= s->avctx->lowres; s->resync_mb_x= s->resync_mb_y= -1; if (mb_y >= s->mb_height){ av_log(s->avctx, AV_LOG_ERROR, "slice below image (%d >= %d)\n", mb_y, s->mb_height); return -1; } init_get_bits(&s->gb, *buf, buf_size*8); ff_mpeg1_clean_buffers(s); s->interlaced_dct = 0; s->qscale = get_qscale(s); if(s->qscale == 0){ av_log(s->avctx, AV_LOG_ERROR, "qscale == 0\n"); return -1; } while (get_bits1(&s->gb) != 0) { skip_bits(&s->gb, 8); } s->mb_x=0; for(;;) { int code = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2); if (code < 0){ av_log(s->avctx, AV_LOG_ERROR, "first mb_incr damaged\n"); return -1; } if (code >= 33) { if (code == 33) { s->mb_x += 33; } } else { s->mb_x += code; break; } } if(s->mb_x >= (unsigned)s->mb_width){ av_log(s->avctx, AV_LOG_ERROR, "initial skip overflow\n"); return -1; } if (avctx->hwaccel) { const uint8_t *buf_end, *buf_start = *buf - 4; int start_code = -1; buf_end = ff_find_start_code(buf_start + 2, *buf + buf_size, &start_code); if (buf_end < *buf + buf_size) buf_end -= 4; s->mb_y = mb_y; if (avctx->hwaccel->decode_slice(avctx, buf_start, buf_end - buf_start) < 0) return DECODE_SLICE_ERROR; *buf = buf_end; return DECODE_SLICE_OK; } s->resync_mb_x= s->mb_x; s->resync_mb_y= s->mb_y= mb_y; s->mb_skip_run= 0; ff_init_block_index(s); if (s->mb_y==0 && s->mb_x==0 && (s->first_field || s->picture_structure==PICT_FRAME)) { if(s->avctx->debug&FF_DEBUG_PICT_INFO){ av_log(s->avctx, AV_LOG_DEBUG, "qp:%d fc:%2d%2d%2d%2d %s %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n", s->qscale, s->mpeg_f_code[0][0],s->mpeg_f_code[0][1],s->mpeg_f_code[1][0],s->mpeg_f_code[1][1], s->pict_type == FF_I_TYPE ? "I" : (s->pict_type == FF_P_TYPE ? "P" : (s->pict_type == FF_B_TYPE ? "B" : "S")), s->progressive_sequence ? "ps" :"", s->progressive_frame ? "pf" : "", s->alternate_scan ? "alt" :"", s->top_field_first ? "top" :"", s->intra_dc_precision, s->picture_structure, s->frame_pred_frame_dct, s->concealment_motion_vectors, s->q_scale_type, s->intra_vlc_format, s->repeat_first_field, s->chroma_420_type ? "420" :""); } } for(;;) { if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration > 1) ff_xvmc_init_block(s); if(mpeg_decode_mb(s, s->block) < 0) return -1; if(s->current_picture.motion_val[0] && !s->encoding){ const int wrap = s->b8_stride; int xy = s->mb_x*2 + s->mb_y*2*wrap; int motion_x, motion_y, dir, i; for(i=0; i<2; i++){ for(dir=0; dir<2; dir++){ if (s->mb_intra || (dir==1 && s->pict_type != FF_B_TYPE)) { motion_x = motion_y = 0; }else if (s->mv_type == MV_TYPE_16X16 || (s->mv_type == MV_TYPE_FIELD && field_pic)){ motion_x = s->mv[dir][0][0]; motion_y = s->mv[dir][0][1]; } else { motion_x = s->mv[dir][i][0]; motion_y = s->mv[dir][i][1]; } s->current_picture.motion_val[dir][xy ][0] = motion_x; s->current_picture.motion_val[dir][xy ][1] = motion_y; s->current_picture.motion_val[dir][xy + 1][0] = motion_x; s->current_picture.motion_val[dir][xy + 1][1] = motion_y; s->current_picture.ref_index [dir][xy ]= s->current_picture.ref_index [dir][xy + 1]= s->field_select[dir][i]; assert(s->field_select[dir][i]==0 || s->field_select[dir][i]==1); } xy += wrap; } } s->dest[0] += 16 >> lowres; s->dest[1] +=(16 >> lowres) >> s->chroma_x_shift; s->dest[2] +=(16 >> lowres) >> s->chroma_x_shift; MPV_decode_mb(s, s->block); if (++s->mb_x >= s->mb_width) { const int mb_size= 16>>s->avctx->lowres; ff_draw_horiz_band(s, mb_size*(s->mb_y>>field_pic), mb_size); s->mb_x = 0; s->mb_y += 1<<field_pic; if(s->mb_y >= s->mb_height){ int left= get_bits_left(&s->gb); int is_d10= s->chroma_format==2 && s->pict_type==FF_I_TYPE && avctx->profile==0 && avctx->level==5 && s->intra_dc_precision == 2 && s->q_scale_type == 1 && s->alternate_scan == 0 && s->progressive_frame == 0 ; if(left < 0 || (left && show_bits(&s->gb, FFMIN(left, 23)) && !is_d10) || (avctx->error_recognition >= FF_ER_AGGRESSIVE && left>8)){ av_log(avctx, AV_LOG_ERROR, "end mismatch left=%d %0X\n", left, show_bits(&s->gb, FFMIN(left, 23))); return -1; }else goto eos; } ff_init_block_index(s); } if (s->mb_skip_run == -1) { s->mb_skip_run = 0; for(;;) { int code = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2); if (code < 0){ av_log(s->avctx, AV_LOG_ERROR, "mb incr damaged\n"); return -1; } if (code >= 33) { if (code == 33) { s->mb_skip_run += 33; }else if(code == 35){ if(s->mb_skip_run != 0 || show_bits(&s->gb, 15) != 0){ av_log(s->avctx, AV_LOG_ERROR, "slice mismatch\n"); return -1; } goto eos; } } else { s->mb_skip_run += code; break; } } if(s->mb_skip_run){ int i; if(s->pict_type == FF_I_TYPE){ av_log(s->avctx, AV_LOG_ERROR, "skipped MB in I frame at %d %d\n", s->mb_x, s->mb_y); return -1; } s->mb_intra = 0; for(i=0;i<12;i++) s->block_last_index[i] = -1; if(s->picture_structure == PICT_FRAME) s->mv_type = MV_TYPE_16X16; else s->mv_type = MV_TYPE_FIELD; if (s->pict_type == FF_P_TYPE) { s->mv_dir = MV_DIR_FORWARD; s->mv[0][0][0] = s->mv[0][0][1] = 0; s->last_mv[0][0][0] = s->last_mv[0][0][1] = 0; s->last_mv[0][1][0] = s->last_mv[0][1][1] = 0; s->field_select[0][0]= (s->picture_structure - 1) & 1; } else { s->mv[0][0][0] = s->last_mv[0][0][0]; s->mv[0][0][1] = s->last_mv[0][0][1]; s->mv[1][0][0] = s->last_mv[1][0][0]; s->mv[1][0][1] = s->last_mv[1][0][1]; } } } } eos: *buf += (get_bits_count(&s->gb)-1)/8; return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(Mpeg1Context *VAR_0, int VAR_1, const uint8_t **VAR_2, int VAR_3) { MpegEncContext *s = &VAR_0->mpeg_enc_ctx; AVCodecContext *avctx= s->avctx; const int VAR_4= s->picture_structure != PICT_FRAME; const int VAR_5= s->avctx->VAR_5; s->resync_mb_x= s->resync_mb_y= -1; if (VAR_1 >= s->mb_height){ av_log(s->avctx, AV_LOG_ERROR, "slice below image (%d >= %d)\n", VAR_1, s->mb_height); return -1; } init_get_bits(&s->gb, *VAR_2, VAR_3*8); ff_mpeg1_clean_buffers(s); s->interlaced_dct = 0; s->qscale = get_qscale(s); if(s->qscale == 0){ av_log(s->avctx, AV_LOG_ERROR, "qscale == 0\n"); return -1; } while (get_bits1(&s->gb) != 0) { skip_bits(&s->gb, 8); } s->mb_x=0; for(;;) { int VAR_18 = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2); if (VAR_18 < 0){ av_log(s->avctx, AV_LOG_ERROR, "first mb_incr damaged\n"); return -1; } if (VAR_18 >= 33) { if (VAR_18 == 33) { s->mb_x += 33; } } else { s->mb_x += VAR_18; break; } } if(s->mb_x >= (unsigned)s->mb_width){ av_log(s->avctx, AV_LOG_ERROR, "initial skip overflow\n"); return -1; } if (avctx->hwaccel) { const uint8_t *VAR_7, *buf_start = *VAR_2 - 4; int VAR_8 = -1; VAR_7 = ff_find_start_code(buf_start + 2, *VAR_2 + VAR_3, &VAR_8); if (VAR_7 < *VAR_2 + VAR_3) VAR_7 -= 4; s->VAR_1 = VAR_1; if (avctx->hwaccel->decode_slice(avctx, buf_start, VAR_7 - buf_start) < 0) return DECODE_SLICE_ERROR; *VAR_2 = VAR_7; return DECODE_SLICE_OK; } s->resync_mb_x= s->mb_x; s->resync_mb_y= s->VAR_1= VAR_1; s->mb_skip_run= 0; ff_init_block_index(s); if (s->VAR_1==0 && s->mb_x==0 && (s->first_field || s->picture_structure==PICT_FRAME)) { if(s->avctx->debug&FF_DEBUG_PICT_INFO){ av_log(s->avctx, AV_LOG_DEBUG, "qp:%d fc:%2d%2d%2d%2d %s %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n", s->qscale, s->mpeg_f_code[0][0],s->mpeg_f_code[0][1],s->mpeg_f_code[1][0],s->mpeg_f_code[1][1], s->pict_type == FF_I_TYPE ? "I" : (s->pict_type == FF_P_TYPE ? "P" : (s->pict_type == FF_B_TYPE ? "B" : "S")), s->progressive_sequence ? "ps" :"", s->progressive_frame ? "pf" : "", s->alternate_scan ? "alt" :"", s->top_field_first ? "top" :"", s->intra_dc_precision, s->picture_structure, s->frame_pred_frame_dct, s->concealment_motion_vectors, s->q_scale_type, s->intra_vlc_format, s->repeat_first_field, s->chroma_420_type ? "420" :""); } } for(;;) { if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration > 1) ff_xvmc_init_block(s); if(mpeg_decode_mb(s, s->block) < 0) return -1; if(s->current_picture.motion_val[0] && !s->encoding){ const int VAR_9 = s->b8_stride; int VAR_10 = s->mb_x*2 + s->VAR_1*2*VAR_9; int VAR_11, VAR_12, VAR_13, VAR_18; for(VAR_18=0; VAR_18<2; VAR_18++){ for(VAR_13=0; VAR_13<2; VAR_13++){ if (s->mb_intra || (VAR_13==1 && s->pict_type != FF_B_TYPE)) { VAR_11 = VAR_12 = 0; }else if (s->mv_type == MV_TYPE_16X16 || (s->mv_type == MV_TYPE_FIELD && VAR_4)){ VAR_11 = s->mv[VAR_13][0][0]; VAR_12 = s->mv[VAR_13][0][1]; } else { VAR_11 = s->mv[VAR_13][VAR_18][0]; VAR_12 = s->mv[VAR_13][VAR_18][1]; } s->current_picture.motion_val[VAR_13][VAR_10 ][0] = VAR_11; s->current_picture.motion_val[VAR_13][VAR_10 ][1] = VAR_12; s->current_picture.motion_val[VAR_13][VAR_10 + 1][0] = VAR_11; s->current_picture.motion_val[VAR_13][VAR_10 + 1][1] = VAR_12; s->current_picture.ref_index [VAR_13][VAR_10 ]= s->current_picture.ref_index [VAR_13][VAR_10 + 1]= s->field_select[VAR_13][VAR_18]; assert(s->field_select[VAR_13][VAR_18]==0 || s->field_select[VAR_13][VAR_18]==1); } VAR_10 += VAR_9; } } s->dest[0] += 16 >> VAR_5; s->dest[1] +=(16 >> VAR_5) >> s->chroma_x_shift; s->dest[2] +=(16 >> VAR_5) >> s->chroma_x_shift; MPV_decode_mb(s, s->block); if (++s->mb_x >= s->mb_width) { const int VAR_15= 16>>s->avctx->VAR_5; ff_draw_horiz_band(s, VAR_15*(s->VAR_1>>VAR_4), VAR_15); s->mb_x = 0; s->VAR_1 += 1<<VAR_4; if(s->VAR_1 >= s->mb_height){ int VAR_16= get_bits_left(&s->gb); int VAR_17= s->chroma_format==2 && s->pict_type==FF_I_TYPE && avctx->profile==0 && avctx->level==5 && s->intra_dc_precision == 2 && s->q_scale_type == 1 && s->alternate_scan == 0 && s->progressive_frame == 0 ; if(VAR_16 < 0 || (VAR_16 && show_bits(&s->gb, FFMIN(VAR_16, 23)) && !VAR_17) || (avctx->error_recognition >= FF_ER_AGGRESSIVE && VAR_16>8)){ av_log(avctx, AV_LOG_ERROR, "end mismatch VAR_16=%d %0X\n", VAR_16, show_bits(&s->gb, FFMIN(VAR_16, 23))); return -1; }else goto eos; } ff_init_block_index(s); } if (s->mb_skip_run == -1) { s->mb_skip_run = 0; for(;;) { int VAR_18 = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2); if (VAR_18 < 0){ av_log(s->avctx, AV_LOG_ERROR, "mb incr damaged\n"); return -1; } if (VAR_18 >= 33) { if (VAR_18 == 33) { s->mb_skip_run += 33; }else if(VAR_18 == 35){ if(s->mb_skip_run != 0 || show_bits(&s->gb, 15) != 0){ av_log(s->avctx, AV_LOG_ERROR, "slice mismatch\n"); return -1; } goto eos; } } else { s->mb_skip_run += VAR_18; break; } } if(s->mb_skip_run){ int VAR_18; if(s->pict_type == FF_I_TYPE){ av_log(s->avctx, AV_LOG_ERROR, "skipped MB in I frame at %d %d\n", s->mb_x, s->VAR_1); return -1; } s->mb_intra = 0; for(VAR_18=0;VAR_18<12;VAR_18++) s->block_last_index[VAR_18] = -1; if(s->picture_structure == PICT_FRAME) s->mv_type = MV_TYPE_16X16; else s->mv_type = MV_TYPE_FIELD; if (s->pict_type == FF_P_TYPE) { s->mv_dir = MV_DIR_FORWARD; s->mv[0][0][0] = s->mv[0][0][1] = 0; s->last_mv[0][0][0] = s->last_mv[0][0][1] = 0; s->last_mv[0][1][0] = s->last_mv[0][1][1] = 0; s->field_select[0][0]= (s->picture_structure - 1) & 1; } else { s->mv[0][0][0] = s->last_mv[0][0][0]; s->mv[0][0][1] = s->last_mv[0][0][1]; s->mv[1][0][0] = s->last_mv[1][0][0]; s->mv[1][0][1] = s->last_mv[1][0][1]; } } } } eos: *VAR_2 += (get_bits_count(&s->gb)-1)/8; return 0; }
[ "static int FUNC_0(Mpeg1Context *VAR_0, int VAR_1,\nconst uint8_t **VAR_2, int VAR_3)\n{", "MpegEncContext *s = &VAR_0->mpeg_enc_ctx;", "AVCodecContext *avctx= s->avctx;", "const int VAR_4= s->picture_structure != PICT_FRAME;", "const int VAR_5= s->avctx->VAR_5;", "s->resync_mb_x=\ns->resync_mb_y= -1;", "if (VAR_1 >= s->mb_height){", "av_log(s->avctx, AV_LOG_ERROR, \"slice below image (%d >= %d)\\n\", VAR_1, s->mb_height);", "return -1;", "}", "init_get_bits(&s->gb, *VAR_2, VAR_3*8);", "ff_mpeg1_clean_buffers(s);", "s->interlaced_dct = 0;", "s->qscale = get_qscale(s);", "if(s->qscale == 0){", "av_log(s->avctx, AV_LOG_ERROR, \"qscale == 0\\n\");", "return -1;", "}", "while (get_bits1(&s->gb) != 0) {", "skip_bits(&s->gb, 8);", "}", "s->mb_x=0;", "for(;;) {", "int VAR_18 = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2);", "if (VAR_18 < 0){", "av_log(s->avctx, AV_LOG_ERROR, \"first mb_incr damaged\\n\");", "return -1;", "}", "if (VAR_18 >= 33) {", "if (VAR_18 == 33) {", "s->mb_x += 33;", "}", "} else {", "s->mb_x += VAR_18;", "break;", "}", "}", "if(s->mb_x >= (unsigned)s->mb_width){", "av_log(s->avctx, AV_LOG_ERROR, \"initial skip overflow\\n\");", "return -1;", "}", "if (avctx->hwaccel) {", "const uint8_t *VAR_7, *buf_start = *VAR_2 - 4;", "int VAR_8 = -1;", "VAR_7 = ff_find_start_code(buf_start + 2, *VAR_2 + VAR_3, &VAR_8);", "if (VAR_7 < *VAR_2 + VAR_3)\nVAR_7 -= 4;", "s->VAR_1 = VAR_1;", "if (avctx->hwaccel->decode_slice(avctx, buf_start, VAR_7 - buf_start) < 0)\nreturn DECODE_SLICE_ERROR;", "*VAR_2 = VAR_7;", "return DECODE_SLICE_OK;", "}", "s->resync_mb_x= s->mb_x;", "s->resync_mb_y= s->VAR_1= VAR_1;", "s->mb_skip_run= 0;", "ff_init_block_index(s);", "if (s->VAR_1==0 && s->mb_x==0 && (s->first_field || s->picture_structure==PICT_FRAME)) {", "if(s->avctx->debug&FF_DEBUG_PICT_INFO){", "av_log(s->avctx, AV_LOG_DEBUG, \"qp:%d fc:%2d%2d%2d%2d %s %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\\n\",\ns->qscale, s->mpeg_f_code[0][0],s->mpeg_f_code[0][1],s->mpeg_f_code[1][0],s->mpeg_f_code[1][1],\ns->pict_type == FF_I_TYPE ? \"I\" : (s->pict_type == FF_P_TYPE ? \"P\" : (s->pict_type == FF_B_TYPE ? \"B\" : \"S\")),\ns->progressive_sequence ? \"ps\" :\"\", s->progressive_frame ? \"pf\" : \"\", s->alternate_scan ? \"alt\" :\"\", s->top_field_first ? \"top\" :\"\",\ns->intra_dc_precision, s->picture_structure, s->frame_pred_frame_dct, s->concealment_motion_vectors,\ns->q_scale_type, s->intra_vlc_format, s->repeat_first_field, s->chroma_420_type ? \"420\" :\"\");", "}", "}", "for(;;) {", "if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration > 1)\nff_xvmc_init_block(s);", "if(mpeg_decode_mb(s, s->block) < 0)\nreturn -1;", "if(s->current_picture.motion_val[0] && !s->encoding){", "const int VAR_9 = s->b8_stride;", "int VAR_10 = s->mb_x*2 + s->VAR_1*2*VAR_9;", "int VAR_11, VAR_12, VAR_13, VAR_18;", "for(VAR_18=0; VAR_18<2; VAR_18++){", "for(VAR_13=0; VAR_13<2; VAR_13++){", "if (s->mb_intra || (VAR_13==1 && s->pict_type != FF_B_TYPE)) {", "VAR_11 = VAR_12 = 0;", "}else if (s->mv_type == MV_TYPE_16X16 || (s->mv_type == MV_TYPE_FIELD && VAR_4)){", "VAR_11 = s->mv[VAR_13][0][0];", "VAR_12 = s->mv[VAR_13][0][1];", "} else {", "VAR_11 = s->mv[VAR_13][VAR_18][0];", "VAR_12 = s->mv[VAR_13][VAR_18][1];", "}", "s->current_picture.motion_val[VAR_13][VAR_10 ][0] = VAR_11;", "s->current_picture.motion_val[VAR_13][VAR_10 ][1] = VAR_12;", "s->current_picture.motion_val[VAR_13][VAR_10 + 1][0] = VAR_11;", "s->current_picture.motion_val[VAR_13][VAR_10 + 1][1] = VAR_12;", "s->current_picture.ref_index [VAR_13][VAR_10 ]=\ns->current_picture.ref_index [VAR_13][VAR_10 + 1]= s->field_select[VAR_13][VAR_18];", "assert(s->field_select[VAR_13][VAR_18]==0 || s->field_select[VAR_13][VAR_18]==1);", "}", "VAR_10 += VAR_9;", "}", "}", "s->dest[0] += 16 >> VAR_5;", "s->dest[1] +=(16 >> VAR_5) >> s->chroma_x_shift;", "s->dest[2] +=(16 >> VAR_5) >> s->chroma_x_shift;", "MPV_decode_mb(s, s->block);", "if (++s->mb_x >= s->mb_width) {", "const int VAR_15= 16>>s->avctx->VAR_5;", "ff_draw_horiz_band(s, VAR_15*(s->VAR_1>>VAR_4), VAR_15);", "s->mb_x = 0;", "s->VAR_1 += 1<<VAR_4;", "if(s->VAR_1 >= s->mb_height){", "int VAR_16= get_bits_left(&s->gb);", "int VAR_17= s->chroma_format==2 && s->pict_type==FF_I_TYPE && avctx->profile==0 && avctx->level==5\n&& s->intra_dc_precision == 2 && s->q_scale_type == 1 && s->alternate_scan == 0\n&& s->progressive_frame == 0 ;", "if(VAR_16 < 0 || (VAR_16 && show_bits(&s->gb, FFMIN(VAR_16, 23)) && !VAR_17)\n|| (avctx->error_recognition >= FF_ER_AGGRESSIVE && VAR_16>8)){", "av_log(avctx, AV_LOG_ERROR, \"end mismatch VAR_16=%d %0X\\n\", VAR_16, show_bits(&s->gb, FFMIN(VAR_16, 23)));", "return -1;", "}else", "goto eos;", "}", "ff_init_block_index(s);", "}", "if (s->mb_skip_run == -1) {", "s->mb_skip_run = 0;", "for(;;) {", "int VAR_18 = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2);", "if (VAR_18 < 0){", "av_log(s->avctx, AV_LOG_ERROR, \"mb incr damaged\\n\");", "return -1;", "}", "if (VAR_18 >= 33) {", "if (VAR_18 == 33) {", "s->mb_skip_run += 33;", "}else if(VAR_18 == 35){", "if(s->mb_skip_run != 0 || show_bits(&s->gb, 15) != 0){", "av_log(s->avctx, AV_LOG_ERROR, \"slice mismatch\\n\");", "return -1;", "}", "goto eos;", "}", "} else {", "s->mb_skip_run += VAR_18;", "break;", "}", "}", "if(s->mb_skip_run){", "int VAR_18;", "if(s->pict_type == FF_I_TYPE){", "av_log(s->avctx, AV_LOG_ERROR, \"skipped MB in I frame at %d %d\\n\", s->mb_x, s->VAR_1);", "return -1;", "}", "s->mb_intra = 0;", "for(VAR_18=0;VAR_18<12;VAR_18++)", "s->block_last_index[VAR_18] = -1;", "if(s->picture_structure == PICT_FRAME)\ns->mv_type = MV_TYPE_16X16;", "else\ns->mv_type = MV_TYPE_FIELD;", "if (s->pict_type == FF_P_TYPE) {", "s->mv_dir = MV_DIR_FORWARD;", "s->mv[0][0][0] = s->mv[0][0][1] = 0;", "s->last_mv[0][0][0] = s->last_mv[0][0][1] = 0;", "s->last_mv[0][1][0] = s->last_mv[0][1][1] = 0;", "s->field_select[0][0]= (s->picture_structure - 1) & 1;", "} else {", "s->mv[0][0][0] = s->last_mv[0][0][0];", "s->mv[0][0][1] = s->last_mv[0][0][1];", "s->mv[1][0][0] = s->last_mv[1][0][0];", "s->mv[1][0][1] = s->last_mv[1][0][1];", "}", "}", "}", "}", "eos:\n*VAR_2 += (get_bits_count(&s->gb)-1)/8;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17, 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 37 ], [ 39 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121, 123 ], [ 125 ], [ 127, 129 ], [ 131 ], [ 133 ], [ 135 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 149 ], [ 151 ], [ 153, 155, 157, 159, 161, 163 ], [ 165 ], [ 167 ], [ 171 ], [ 175, 177 ], [ 181, 183 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 221 ], [ 223 ], [ 225 ], [ 227 ], [ 229, 231 ], [ 233 ], [ 235 ], [ 237 ], [ 239 ], [ 241 ], [ 245 ], [ 247 ], [ 249 ], [ 253 ], [ 257 ], [ 259 ], [ 263 ], [ 267 ], [ 269 ], [ 273 ], [ 275 ], [ 277, 279, 281 ], [ 285, 287 ], [ 289 ], [ 291 ], [ 293 ], [ 295 ], [ 297 ], [ 301 ], [ 303 ], [ 309 ], [ 313 ], [ 315 ], [ 317 ], [ 319 ], [ 321 ], [ 323 ], [ 325 ], [ 327 ], [ 329 ], [ 331 ], [ 333 ], [ 335 ], [ 337 ], [ 339 ], [ 341 ], [ 343 ], [ 345 ], [ 349 ], [ 351 ], [ 353 ], [ 355 ], [ 357 ], [ 359 ], [ 361 ], [ 363 ], [ 365 ], [ 367 ], [ 369 ], [ 375 ], [ 377 ], [ 379 ], [ 381, 383 ], [ 385, 387 ], [ 389 ], [ 393 ], [ 395 ], [ 397 ], [ 399 ], [ 401 ], [ 403 ], [ 407 ], [ 409 ], [ 411 ], [ 413 ], [ 415 ], [ 417 ], [ 419 ], [ 421 ], [ 423, 425 ], [ 429 ], [ 431 ] ]
11,429
static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, long width, long height, long lumStride, long chromStride, long srcStride) { long y; const long chromWidth= width>>1; #ifdef HAVE_MMX for(y=0; y<height-2; y+=2) { long i; for(i=0; i<2; i++) { asm volatile( "mov %2, %%"REG_a" \n\t" "movq "MANGLE(bgr2YCoeff)", %%mm6 \n\t" "movq "MANGLE(w1111)", %%mm5 \n\t" "pxor %%mm7, %%mm7 \n\t" "lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t" ASMALIGN16 "1: \n\t" PREFETCH" 64(%0, %%"REG_b") \n\t" "movd (%0, %%"REG_b"), %%mm0 \n\t" "movd 3(%0, %%"REG_b"), %%mm1 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "movd 6(%0, %%"REG_b"), %%mm2 \n\t" "movd 9(%0, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "pmaddwd %%mm6, %%mm0 \n\t" "pmaddwd %%mm6, %%mm1 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" "pmaddwd %%mm6, %%mm3 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm0 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm1, %%mm0 \n\t" "packssdw %%mm3, %%mm2 \n\t" "pmaddwd %%mm5, %%mm0 \n\t" "pmaddwd %%mm5, %%mm2 \n\t" "packssdw %%mm2, %%mm0 \n\t" "psraw $7, %%mm0 \n\t" "movd 12(%0, %%"REG_b"), %%mm4 \n\t" "movd 15(%0, %%"REG_b"), %%mm1 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "movd 18(%0, %%"REG_b"), %%mm2 \n\t" "movd 21(%0, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "pmaddwd %%mm6, %%mm4 \n\t" "pmaddwd %%mm6, %%mm1 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" "pmaddwd %%mm6, %%mm3 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm4 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm1, %%mm4 \n\t" "packssdw %%mm3, %%mm2 \n\t" "pmaddwd %%mm5, %%mm4 \n\t" "pmaddwd %%mm5, %%mm2 \n\t" "add $24, %%"REG_b" \n\t" "packssdw %%mm2, %%mm4 \n\t" "psraw $7, %%mm4 \n\t" "packuswb %%mm4, %%mm0 \n\t" "paddusb "MANGLE(bgr2YOffset)", %%mm0 \n\t" MOVNTQ" %%mm0, (%1, %%"REG_a") \n\t" "add $8, %%"REG_a" \n\t" " js 1b \n\t" : : "r" (src+width*3), "r" (ydst+width), "g" (-width) : "%"REG_a, "%"REG_b ); ydst += lumStride; src += srcStride; } src -= srcStride*2; asm volatile( "mov %4, %%"REG_a" \n\t" "movq "MANGLE(w1111)", %%mm5 \n\t" "movq "MANGLE(bgr2UCoeff)", %%mm6 \n\t" "pxor %%mm7, %%mm7 \n\t" "lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t" "add %%"REG_b", %%"REG_b" \n\t" ASMALIGN16 "1: \n\t" PREFETCH" 64(%0, %%"REG_b") \n\t" PREFETCH" 64(%1, %%"REG_b") \n\t" #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) "movq (%0, %%"REG_b"), %%mm0 \n\t" "movq (%1, %%"REG_b"), %%mm1 \n\t" "movq 6(%0, %%"REG_b"), %%mm2 \n\t" "movq 6(%1, %%"REG_b"), %%mm3 \n\t" PAVGB" %%mm1, %%mm0 \n\t" PAVGB" %%mm3, %%mm2 \n\t" "movq %%mm0, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "psrlq $24, %%mm0 \n\t" "psrlq $24, %%mm2 \n\t" PAVGB" %%mm1, %%mm0 \n\t" PAVGB" %%mm3, %%mm2 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" #else "movd (%0, %%"REG_b"), %%mm0 \n\t" "movd (%1, %%"REG_b"), %%mm1 \n\t" "movd 3(%0, %%"REG_b"), %%mm2 \n\t" "movd 3(%1, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "paddw %%mm1, %%mm0 \n\t" "paddw %%mm3, %%mm2 \n\t" "paddw %%mm2, %%mm0 \n\t" "movd 6(%0, %%"REG_b"), %%mm4 \n\t" "movd 6(%1, %%"REG_b"), %%mm1 \n\t" "movd 9(%0, %%"REG_b"), %%mm2 \n\t" "movd 9(%1, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "paddw %%mm1, %%mm4 \n\t" "paddw %%mm3, %%mm2 \n\t" "paddw %%mm4, %%mm2 \n\t" "psrlw $2, %%mm0 \n\t" "psrlw $2, %%mm2 \n\t" #endif "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t" "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t" "pmaddwd %%mm0, %%mm1 \n\t" "pmaddwd %%mm2, %%mm3 \n\t" "pmaddwd %%mm6, %%mm0 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm0 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm2, %%mm0 \n\t" "packssdw %%mm3, %%mm1 \n\t" "pmaddwd %%mm5, %%mm0 \n\t" "pmaddwd %%mm5, %%mm1 \n\t" "packssdw %%mm1, %%mm0 \n\t" // V1 V0 U1 U0 "psraw $7, %%mm0 \n\t" #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) "movq 12(%0, %%"REG_b"), %%mm4 \n\t" "movq 12(%1, %%"REG_b"), %%mm1 \n\t" "movq 18(%0, %%"REG_b"), %%mm2 \n\t" "movq 18(%1, %%"REG_b"), %%mm3 \n\t" PAVGB" %%mm1, %%mm4 \n\t" PAVGB" %%mm3, %%mm2 \n\t" "movq %%mm4, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "psrlq $24, %%mm4 \n\t" "psrlq $24, %%mm2 \n\t" PAVGB" %%mm1, %%mm4 \n\t" PAVGB" %%mm3, %%mm2 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" #else "movd 12(%0, %%"REG_b"), %%mm4 \n\t" "movd 12(%1, %%"REG_b"), %%mm1 \n\t" "movd 15(%0, %%"REG_b"), %%mm2 \n\t" "movd 15(%1, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "paddw %%mm1, %%mm4 \n\t" "paddw %%mm3, %%mm2 \n\t" "paddw %%mm2, %%mm4 \n\t" "movd 18(%0, %%"REG_b"), %%mm5 \n\t" "movd 18(%1, %%"REG_b"), %%mm1 \n\t" "movd 21(%0, %%"REG_b"), %%mm2 \n\t" "movd 21(%1, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm5 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "paddw %%mm1, %%mm5 \n\t" "paddw %%mm3, %%mm2 \n\t" "paddw %%mm5, %%mm2 \n\t" "movq "MANGLE(w1111)", %%mm5 \n\t" "psrlw $2, %%mm4 \n\t" "psrlw $2, %%mm2 \n\t" #endif "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t" "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t" "pmaddwd %%mm4, %%mm1 \n\t" "pmaddwd %%mm2, %%mm3 \n\t" "pmaddwd %%mm6, %%mm4 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm4 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm2, %%mm4 \n\t" "packssdw %%mm3, %%mm1 \n\t" "pmaddwd %%mm5, %%mm4 \n\t" "pmaddwd %%mm5, %%mm1 \n\t" "add $24, %%"REG_b" \n\t" "packssdw %%mm1, %%mm4 \n\t" // V3 V2 U3 U2 "psraw $7, %%mm4 \n\t" "movq %%mm0, %%mm1 \n\t" "punpckldq %%mm4, %%mm0 \n\t" "punpckhdq %%mm4, %%mm1 \n\t" "packsswb %%mm1, %%mm0 \n\t" "paddb "MANGLE(bgr2UVOffset)", %%mm0 \n\t" "movd %%mm0, (%2, %%"REG_a") \n\t" "punpckhdq %%mm0, %%mm0 \n\t" "movd %%mm0, (%3, %%"REG_a") \n\t" "add $4, %%"REG_a" \n\t" " js 1b \n\t" : : "r" (src+chromWidth*6), "r" (src+srcStride+chromWidth*6), "r" (udst+chromWidth), "r" (vdst+chromWidth), "g" (-chromWidth) : "%"REG_a, "%"REG_b ); udst += chromStride; vdst += chromStride; src += srcStride*2; } asm volatile( EMMS" \n\t" SFENCE" \n\t" :::"memory"); #else y=0; #endif for(; y<height; y+=2) { long i; for(i=0; i<chromWidth; i++) { unsigned int b= src[6*i+0]; unsigned int g= src[6*i+1]; unsigned int r= src[6*i+2]; unsigned int Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; unsigned int V = ((RV*r + GV*g + BV*b)>>RGB2YUV_SHIFT) + 128; unsigned int U = ((RU*r + GU*g + BU*b)>>RGB2YUV_SHIFT) + 128; udst[i] = U; vdst[i] = V; ydst[2*i] = Y; b= src[6*i+3]; g= src[6*i+4]; r= src[6*i+5]; Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; ydst[2*i+1] = Y; } ydst += lumStride; src += srcStride; for(i=0; i<chromWidth; i++) { unsigned int b= src[6*i+0]; unsigned int g= src[6*i+1]; unsigned int r= src[6*i+2]; unsigned int Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; ydst[2*i] = Y; b= src[6*i+3]; g= src[6*i+4]; r= src[6*i+5]; Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; ydst[2*i+1] = Y; } udst += chromStride; vdst += chromStride; ydst += lumStride; src += srcStride; } }
false
FFmpeg
4bff9ef9d0781c4de228bf1f85634d2706fc589b
static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, long width, long height, long lumStride, long chromStride, long srcStride) { long y; const long chromWidth= width>>1; #ifdef HAVE_MMX for(y=0; y<height-2; y+=2) { long i; for(i=0; i<2; i++) { asm volatile( "mov %2, %%"REG_a" \n\t" "movq "MANGLE(bgr2YCoeff)", %%mm6 \n\t" "movq "MANGLE(w1111)", %%mm5 \n\t" "pxor %%mm7, %%mm7 \n\t" "lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t" ASMALIGN16 "1: \n\t" PREFETCH" 64(%0, %%"REG_b") \n\t" "movd (%0, %%"REG_b"), %%mm0 \n\t" "movd 3(%0, %%"REG_b"), %%mm1 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "movd 6(%0, %%"REG_b"), %%mm2 \n\t" "movd 9(%0, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "pmaddwd %%mm6, %%mm0 \n\t" "pmaddwd %%mm6, %%mm1 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" "pmaddwd %%mm6, %%mm3 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm0 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm1, %%mm0 \n\t" "packssdw %%mm3, %%mm2 \n\t" "pmaddwd %%mm5, %%mm0 \n\t" "pmaddwd %%mm5, %%mm2 \n\t" "packssdw %%mm2, %%mm0 \n\t" "psraw $7, %%mm0 \n\t" "movd 12(%0, %%"REG_b"), %%mm4 \n\t" "movd 15(%0, %%"REG_b"), %%mm1 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "movd 18(%0, %%"REG_b"), %%mm2 \n\t" "movd 21(%0, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "pmaddwd %%mm6, %%mm4 \n\t" "pmaddwd %%mm6, %%mm1 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" "pmaddwd %%mm6, %%mm3 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm4 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm1, %%mm4 \n\t" "packssdw %%mm3, %%mm2 \n\t" "pmaddwd %%mm5, %%mm4 \n\t" "pmaddwd %%mm5, %%mm2 \n\t" "add $24, %%"REG_b" \n\t" "packssdw %%mm2, %%mm4 \n\t" "psraw $7, %%mm4 \n\t" "packuswb %%mm4, %%mm0 \n\t" "paddusb "MANGLE(bgr2YOffset)", %%mm0 \n\t" MOVNTQ" %%mm0, (%1, %%"REG_a") \n\t" "add $8, %%"REG_a" \n\t" " js 1b \n\t" : : "r" (src+width*3), "r" (ydst+width), "g" (-width) : "%"REG_a, "%"REG_b ); ydst += lumStride; src += srcStride; } src -= srcStride*2; asm volatile( "mov %4, %%"REG_a" \n\t" "movq "MANGLE(w1111)", %%mm5 \n\t" "movq "MANGLE(bgr2UCoeff)", %%mm6 \n\t" "pxor %%mm7, %%mm7 \n\t" "lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t" "add %%"REG_b", %%"REG_b" \n\t" ASMALIGN16 "1: \n\t" PREFETCH" 64(%0, %%"REG_b") \n\t" PREFETCH" 64(%1, %%"REG_b") \n\t" #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) "movq (%0, %%"REG_b"), %%mm0 \n\t" "movq (%1, %%"REG_b"), %%mm1 \n\t" "movq 6(%0, %%"REG_b"), %%mm2 \n\t" "movq 6(%1, %%"REG_b"), %%mm3 \n\t" PAVGB" %%mm1, %%mm0 \n\t" PAVGB" %%mm3, %%mm2 \n\t" "movq %%mm0, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "psrlq $24, %%mm0 \n\t" "psrlq $24, %%mm2 \n\t" PAVGB" %%mm1, %%mm0 \n\t" PAVGB" %%mm3, %%mm2 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" #else "movd (%0, %%"REG_b"), %%mm0 \n\t" "movd (%1, %%"REG_b"), %%mm1 \n\t" "movd 3(%0, %%"REG_b"), %%mm2 \n\t" "movd 3(%1, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "paddw %%mm1, %%mm0 \n\t" "paddw %%mm3, %%mm2 \n\t" "paddw %%mm2, %%mm0 \n\t" "movd 6(%0, %%"REG_b"), %%mm4 \n\t" "movd 6(%1, %%"REG_b"), %%mm1 \n\t" "movd 9(%0, %%"REG_b"), %%mm2 \n\t" "movd 9(%1, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "paddw %%mm1, %%mm4 \n\t" "paddw %%mm3, %%mm2 \n\t" "paddw %%mm4, %%mm2 \n\t" "psrlw $2, %%mm0 \n\t" "psrlw $2, %%mm2 \n\t" #endif "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t" "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t" "pmaddwd %%mm0, %%mm1 \n\t" "pmaddwd %%mm2, %%mm3 \n\t" "pmaddwd %%mm6, %%mm0 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm0 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm2, %%mm0 \n\t" "packssdw %%mm3, %%mm1 \n\t" "pmaddwd %%mm5, %%mm0 \n\t" "pmaddwd %%mm5, %%mm1 \n\t" "packssdw %%mm1, %%mm0 \n\t" "psraw $7, %%mm0 \n\t" #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) "movq 12(%0, %%"REG_b"), %%mm4 \n\t" "movq 12(%1, %%"REG_b"), %%mm1 \n\t" "movq 18(%0, %%"REG_b"), %%mm2 \n\t" "movq 18(%1, %%"REG_b"), %%mm3 \n\t" PAVGB" %%mm1, %%mm4 \n\t" PAVGB" %%mm3, %%mm2 \n\t" "movq %%mm4, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "psrlq $24, %%mm4 \n\t" "psrlq $24, %%mm2 \n\t" PAVGB" %%mm1, %%mm4 \n\t" PAVGB" %%mm3, %%mm2 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" #else "movd 12(%0, %%"REG_b"), %%mm4 \n\t" "movd 12(%1, %%"REG_b"), %%mm1 \n\t" "movd 15(%0, %%"REG_b"), %%mm2 \n\t" "movd 15(%1, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "paddw %%mm1, %%mm4 \n\t" "paddw %%mm3, %%mm2 \n\t" "paddw %%mm2, %%mm4 \n\t" "movd 18(%0, %%"REG_b"), %%mm5 \n\t" "movd 18(%1, %%"REG_b"), %%mm1 \n\t" "movd 21(%0, %%"REG_b"), %%mm2 \n\t" "movd 21(%1, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm5 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "paddw %%mm1, %%mm5 \n\t" "paddw %%mm3, %%mm2 \n\t" "paddw %%mm5, %%mm2 \n\t" "movq "MANGLE(w1111)", %%mm5 \n\t" "psrlw $2, %%mm4 \n\t" "psrlw $2, %%mm2 \n\t" #endif "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t" "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t" "pmaddwd %%mm4, %%mm1 \n\t" "pmaddwd %%mm2, %%mm3 \n\t" "pmaddwd %%mm6, %%mm4 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm4 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm2, %%mm4 \n\t" "packssdw %%mm3, %%mm1 \n\t" "pmaddwd %%mm5, %%mm4 \n\t" "pmaddwd %%mm5, %%mm1 \n\t" "add $24, %%"REG_b" \n\t" "packssdw %%mm1, %%mm4 \n\t" "psraw $7, %%mm4 \n\t" "movq %%mm0, %%mm1 \n\t" "punpckldq %%mm4, %%mm0 \n\t" "punpckhdq %%mm4, %%mm1 \n\t" "packsswb %%mm1, %%mm0 \n\t" "paddb "MANGLE(bgr2UVOffset)", %%mm0 \n\t" "movd %%mm0, (%2, %%"REG_a") \n\t" "punpckhdq %%mm0, %%mm0 \n\t" "movd %%mm0, (%3, %%"REG_a") \n\t" "add $4, %%"REG_a" \n\t" " js 1b \n\t" : : "r" (src+chromWidth*6), "r" (src+srcStride+chromWidth*6), "r" (udst+chromWidth), "r" (vdst+chromWidth), "g" (-chromWidth) : "%"REG_a, "%"REG_b ); udst += chromStride; vdst += chromStride; src += srcStride*2; } asm volatile( EMMS" \n\t" SFENCE" \n\t" :::"memory"); #else y=0; #endif for(; y<height; y+=2) { long i; for(i=0; i<chromWidth; i++) { unsigned int b= src[6*i+0]; unsigned int g= src[6*i+1]; unsigned int r= src[6*i+2]; unsigned int Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; unsigned int V = ((RV*r + GV*g + BV*b)>>RGB2YUV_SHIFT) + 128; unsigned int U = ((RU*r + GU*g + BU*b)>>RGB2YUV_SHIFT) + 128; udst[i] = U; vdst[i] = V; ydst[2*i] = Y; b= src[6*i+3]; g= src[6*i+4]; r= src[6*i+5]; Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; ydst[2*i+1] = Y; } ydst += lumStride; src += srcStride; for(i=0; i<chromWidth; i++) { unsigned int b= src[6*i+0]; unsigned int g= src[6*i+1]; unsigned int r= src[6*i+2]; unsigned int Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; ydst[2*i] = Y; b= src[6*i+3]; g= src[6*i+4]; r= src[6*i+5]; Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; ydst[2*i+1] = Y; } udst += chromStride; vdst += chromStride; ydst += lumStride; src += srcStride; } }
{ "code": [], "line_no": [] }
static inline void FUNC_0(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, long width, long height, long lumStride, long chromStride, long srcStride) { long VAR_0; const long VAR_1= width>>1; #ifdef HAVE_MMX for(VAR_0=0; VAR_0<height-2; VAR_0+=2) { long i; for(i=0; i<2; i++) { asm volatile( "mov %2, %%"REG_a" \n\t" "movq "MANGLE(bgr2YCoeff)", %%mm6 \n\t" "movq "MANGLE(w1111)", %%mm5 \n\t" "pxor %%mm7, %%mm7 \n\t" "lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t" ASMALIGN16 "1: \n\t" PREFETCH" 64(%0, %%"REG_b") \n\t" "movd (%0, %%"REG_b"), %%mm0 \n\t" "movd 3(%0, %%"REG_b"), %%mm1 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "movd 6(%0, %%"REG_b"), %%mm2 \n\t" "movd 9(%0, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "pmaddwd %%mm6, %%mm0 \n\t" "pmaddwd %%mm6, %%mm1 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" "pmaddwd %%mm6, %%mm3 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm0 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm1, %%mm0 \n\t" "packssdw %%mm3, %%mm2 \n\t" "pmaddwd %%mm5, %%mm0 \n\t" "pmaddwd %%mm5, %%mm2 \n\t" "packssdw %%mm2, %%mm0 \n\t" "psraw $7, %%mm0 \n\t" "movd 12(%0, %%"REG_b"), %%mm4 \n\t" "movd 15(%0, %%"REG_b"), %%mm1 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "movd 18(%0, %%"REG_b"), %%mm2 \n\t" "movd 21(%0, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "pmaddwd %%mm6, %%mm4 \n\t" "pmaddwd %%mm6, %%mm1 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" "pmaddwd %%mm6, %%mm3 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm4 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm1, %%mm4 \n\t" "packssdw %%mm3, %%mm2 \n\t" "pmaddwd %%mm5, %%mm4 \n\t" "pmaddwd %%mm5, %%mm2 \n\t" "add $24, %%"REG_b" \n\t" "packssdw %%mm2, %%mm4 \n\t" "psraw $7, %%mm4 \n\t" "packuswb %%mm4, %%mm0 \n\t" "paddusb "MANGLE(bgr2YOffset)", %%mm0 \n\t" MOVNTQ" %%mm0, (%1, %%"REG_a") \n\t" "add $8, %%"REG_a" \n\t" " js 1b \n\t" : : "r" (src+width*3), "r" (ydst+width), "g" (-width) : "%"REG_a, "%"REG_b ); ydst += lumStride; src += srcStride; } src -= srcStride*2; asm volatile( "mov %4, %%"REG_a" \n\t" "movq "MANGLE(w1111)", %%mm5 \n\t" "movq "MANGLE(bgr2UCoeff)", %%mm6 \n\t" "pxor %%mm7, %%mm7 \n\t" "lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t" "add %%"REG_b", %%"REG_b" \n\t" ASMALIGN16 "1: \n\t" PREFETCH" 64(%0, %%"REG_b") \n\t" PREFETCH" 64(%1, %%"REG_b") \n\t" #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) "movq (%0, %%"REG_b"), %%mm0 \n\t" "movq (%1, %%"REG_b"), %%mm1 \n\t" "movq 6(%0, %%"REG_b"), %%mm2 \n\t" "movq 6(%1, %%"REG_b"), %%mm3 \n\t" PAVGB" %%mm1, %%mm0 \n\t" PAVGB" %%mm3, %%mm2 \n\t" "movq %%mm0, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "psrlq $24, %%mm0 \n\t" "psrlq $24, %%mm2 \n\t" PAVGB" %%mm1, %%mm0 \n\t" PAVGB" %%mm3, %%mm2 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" #else "movd (%0, %%"REG_b"), %%mm0 \n\t" "movd (%1, %%"REG_b"), %%mm1 \n\t" "movd 3(%0, %%"REG_b"), %%mm2 \n\t" "movd 3(%1, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "paddw %%mm1, %%mm0 \n\t" "paddw %%mm3, %%mm2 \n\t" "paddw %%mm2, %%mm0 \n\t" "movd 6(%0, %%"REG_b"), %%mm4 \n\t" "movd 6(%1, %%"REG_b"), %%mm1 \n\t" "movd 9(%0, %%"REG_b"), %%mm2 \n\t" "movd 9(%1, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "paddw %%mm1, %%mm4 \n\t" "paddw %%mm3, %%mm2 \n\t" "paddw %%mm4, %%mm2 \n\t" "psrlw $2, %%mm0 \n\t" "psrlw $2, %%mm2 \n\t" #endif "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t" "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t" "pmaddwd %%mm0, %%mm1 \n\t" "pmaddwd %%mm2, %%mm3 \n\t" "pmaddwd %%mm6, %%mm0 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm0 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm2, %%mm0 \n\t" "packssdw %%mm3, %%mm1 \n\t" "pmaddwd %%mm5, %%mm0 \n\t" "pmaddwd %%mm5, %%mm1 \n\t" "packssdw %%mm1, %%mm0 \n\t" "psraw $7, %%mm0 \n\t" #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) "movq 12(%0, %%"REG_b"), %%mm4 \n\t" "movq 12(%1, %%"REG_b"), %%mm1 \n\t" "movq 18(%0, %%"REG_b"), %%mm2 \n\t" "movq 18(%1, %%"REG_b"), %%mm3 \n\t" PAVGB" %%mm1, %%mm4 \n\t" PAVGB" %%mm3, %%mm2 \n\t" "movq %%mm4, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "psrlq $24, %%mm4 \n\t" "psrlq $24, %%mm2 \n\t" PAVGB" %%mm1, %%mm4 \n\t" PAVGB" %%mm3, %%mm2 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" #else "movd 12(%0, %%"REG_b"), %%mm4 \n\t" "movd 12(%1, %%"REG_b"), %%mm1 \n\t" "movd 15(%0, %%"REG_b"), %%mm2 \n\t" "movd 15(%1, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "paddw %%mm1, %%mm4 \n\t" "paddw %%mm3, %%mm2 \n\t" "paddw %%mm2, %%mm4 \n\t" "movd 18(%0, %%"REG_b"), %%mm5 \n\t" "movd 18(%1, %%"REG_b"), %%mm1 \n\t" "movd 21(%0, %%"REG_b"), %%mm2 \n\t" "movd 21(%1, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm5 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "paddw %%mm1, %%mm5 \n\t" "paddw %%mm3, %%mm2 \n\t" "paddw %%mm5, %%mm2 \n\t" "movq "MANGLE(w1111)", %%mm5 \n\t" "psrlw $2, %%mm4 \n\t" "psrlw $2, %%mm2 \n\t" #endif "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t" "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t" "pmaddwd %%mm4, %%mm1 \n\t" "pmaddwd %%mm2, %%mm3 \n\t" "pmaddwd %%mm6, %%mm4 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm4 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm2, %%mm4 \n\t" "packssdw %%mm3, %%mm1 \n\t" "pmaddwd %%mm5, %%mm4 \n\t" "pmaddwd %%mm5, %%mm1 \n\t" "add $24, %%"REG_b" \n\t" "packssdw %%mm1, %%mm4 \n\t" "psraw $7, %%mm4 \n\t" "movq %%mm0, %%mm1 \n\t" "punpckldq %%mm4, %%mm0 \n\t" "punpckhdq %%mm4, %%mm1 \n\t" "packsswb %%mm1, %%mm0 \n\t" "paddb "MANGLE(bgr2UVOffset)", %%mm0 \n\t" "movd %%mm0, (%2, %%"REG_a") \n\t" "punpckhdq %%mm0, %%mm0 \n\t" "movd %%mm0, (%3, %%"REG_a") \n\t" "add $4, %%"REG_a" \n\t" " js 1b \n\t" : : "r" (src+VAR_1*6), "r" (src+srcStride+VAR_1*6), "r" (udst+VAR_1), "r" (vdst+VAR_1), "g" (-VAR_1) : "%"REG_a, "%"REG_b ); udst += chromStride; vdst += chromStride; src += srcStride*2; } asm volatile( EMMS" \n\t" SFENCE" \n\t" :::"memory"); #else VAR_0=0; #endif for(; VAR_0<height; VAR_0+=2) { long i; for(i=0; i<VAR_1; i++) { unsigned int b= src[6*i+0]; unsigned int g= src[6*i+1]; unsigned int r= src[6*i+2]; unsigned int Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; unsigned int V = ((RV*r + GV*g + BV*b)>>RGB2YUV_SHIFT) + 128; unsigned int U = ((RU*r + GU*g + BU*b)>>RGB2YUV_SHIFT) + 128; udst[i] = U; vdst[i] = V; ydst[2*i] = Y; b= src[6*i+3]; g= src[6*i+4]; r= src[6*i+5]; Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; ydst[2*i+1] = Y; } ydst += lumStride; src += srcStride; for(i=0; i<VAR_1; i++) { unsigned int b= src[6*i+0]; unsigned int g= src[6*i+1]; unsigned int r= src[6*i+2]; unsigned int Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; ydst[2*i] = Y; b= src[6*i+3]; g= src[6*i+4]; r= src[6*i+5]; Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; ydst[2*i+1] = Y; } udst += chromStride; vdst += chromStride; ydst += lumStride; src += srcStride; } }
[ "static inline void FUNC_0(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,\nlong width, long height,\nlong lumStride, long chromStride, long srcStride)\n{", "long VAR_0;", "const long VAR_1= width>>1;", "#ifdef HAVE_MMX\nfor(VAR_0=0; VAR_0<height-2; VAR_0+=2)", "{", "long i;", "for(i=0; i<2; i++)", "{", "asm volatile(\n\"mov %2, %%\"REG_a\"\t\t\\n\\t\"\n\"movq \"MANGLE(bgr2YCoeff)\", %%mm6\t\t\\n\\t\"\n\"movq \"MANGLE(w1111)\", %%mm5\t\t\\n\\t\"\n\"pxor %%mm7, %%mm7\t\t\\n\\t\"\n\"lea (%%\"REG_a\", %%\"REG_a\", 2), %%\"REG_b\"\\n\\t\"\nASMALIGN16\n\"1:\t\t\t\t\\n\\t\"\nPREFETCH\" 64(%0, %%\"REG_b\")\t\\n\\t\"\n\"movd (%0, %%\"REG_b\"), %%mm0\t\\n\\t\"\n\"movd 3(%0, %%\"REG_b\"), %%mm1\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm0\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm1\t\t\\n\\t\"\n\"movd 6(%0, %%\"REG_b\"), %%mm2\t\\n\\t\"\n\"movd 9(%0, %%\"REG_b\"), %%mm3\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm2\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm3\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm0\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm1\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm2\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm3\t\t\\n\\t\"\n#ifndef FAST_BGR2YV12\n\"psrad $8, %%mm0\t\t\\n\\t\"\n\"psrad $8, %%mm1\t\t\\n\\t\"\n\"psrad $8, %%mm2\t\t\\n\\t\"\n\"psrad $8, %%mm3\t\t\\n\\t\"\n#endif\n\"packssdw %%mm1, %%mm0\t\t\\n\\t\"\n\"packssdw %%mm3, %%mm2\t\t\\n\\t\"\n\"pmaddwd %%mm5, %%mm0\t\t\\n\\t\"\n\"pmaddwd %%mm5, %%mm2\t\t\\n\\t\"\n\"packssdw %%mm2, %%mm0\t\t\\n\\t\"\n\"psraw $7, %%mm0\t\t\\n\\t\"\n\"movd 12(%0, %%\"REG_b\"), %%mm4\t\\n\\t\"\n\"movd 15(%0, %%\"REG_b\"), %%mm1\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm4\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm1\t\t\\n\\t\"\n\"movd 18(%0, %%\"REG_b\"), %%mm2\t\\n\\t\"\n\"movd 21(%0, %%\"REG_b\"), %%mm3\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm2\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm3\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm4\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm1\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm2\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm3\t\t\\n\\t\"\n#ifndef FAST_BGR2YV12\n\"psrad $8, %%mm4\t\t\\n\\t\"\n\"psrad $8, %%mm1\t\t\\n\\t\"\n\"psrad $8, %%mm2\t\t\\n\\t\"\n\"psrad $8, %%mm3\t\t\\n\\t\"\n#endif\n\"packssdw %%mm1, %%mm4\t\t\\n\\t\"\n\"packssdw %%mm3, %%mm2\t\t\\n\\t\"\n\"pmaddwd %%mm5, %%mm4\t\t\\n\\t\"\n\"pmaddwd %%mm5, %%mm2\t\t\\n\\t\"\n\"add $24, %%\"REG_b\"\t\t\\n\\t\"\n\"packssdw %%mm2, %%mm4\t\t\\n\\t\"\n\"psraw $7, %%mm4\t\t\\n\\t\"\n\"packuswb %%mm4, %%mm0\t\t\\n\\t\"\n\"paddusb \"MANGLE(bgr2YOffset)\", %%mm0\t\\n\\t\"\nMOVNTQ\" %%mm0, (%1, %%\"REG_a\")\t\\n\\t\"\n\"add $8, %%\"REG_a\"\t\t\\n\\t\"\n\" js 1b\t\t\t\t\\n\\t\"\n: : \"r\" (src+width*3), \"r\" (ydst+width), \"g\" (-width)\n: \"%\"REG_a, \"%\"REG_b\n);", "ydst += lumStride;", "src += srcStride;", "}", "src -= srcStride*2;", "asm volatile(\n\"mov %4, %%\"REG_a\"\t\t\\n\\t\"\n\"movq \"MANGLE(w1111)\", %%mm5\t\t\\n\\t\"\n\"movq \"MANGLE(bgr2UCoeff)\", %%mm6\t\t\\n\\t\"\n\"pxor %%mm7, %%mm7\t\t\\n\\t\"\n\"lea (%%\"REG_a\", %%\"REG_a\", 2), %%\"REG_b\"\\n\\t\"\n\"add %%\"REG_b\", %%\"REG_b\"\t\\n\\t\"\nASMALIGN16\n\"1:\t\t\t\t\\n\\t\"\nPREFETCH\" 64(%0, %%\"REG_b\")\t\\n\\t\"\nPREFETCH\" 64(%1, %%\"REG_b\")\t\\n\\t\"\n#if defined (HAVE_MMX2) || defined (HAVE_3DNOW)\n\"movq (%0, %%\"REG_b\"), %%mm0\t\\n\\t\"\n\"movq (%1, %%\"REG_b\"), %%mm1\t\\n\\t\"\n\"movq 6(%0, %%\"REG_b\"), %%mm2\t\\n\\t\"\n\"movq 6(%1, %%\"REG_b\"), %%mm3\t\\n\\t\"\nPAVGB\" %%mm1, %%mm0\t\t\\n\\t\"\nPAVGB\" %%mm3, %%mm2\t\t\\n\\t\"\n\"movq %%mm0, %%mm1\t\t\\n\\t\"\n\"movq %%mm2, %%mm3\t\t\\n\\t\"\n\"psrlq $24, %%mm0\t\t\\n\\t\"\n\"psrlq $24, %%mm2\t\t\\n\\t\"\nPAVGB\" %%mm1, %%mm0\t\t\\n\\t\"\nPAVGB\" %%mm3, %%mm2\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm0\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm2\t\t\\n\\t\"\n#else\n\"movd (%0, %%\"REG_b\"), %%mm0\t\\n\\t\"\n\"movd (%1, %%\"REG_b\"), %%mm1\t\\n\\t\"\n\"movd 3(%0, %%\"REG_b\"), %%mm2\t\\n\\t\"\n\"movd 3(%1, %%\"REG_b\"), %%mm3\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm0\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm1\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm2\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm3\t\t\\n\\t\"\n\"paddw %%mm1, %%mm0\t\t\\n\\t\"\n\"paddw %%mm3, %%mm2\t\t\\n\\t\"\n\"paddw %%mm2, %%mm0\t\t\\n\\t\"\n\"movd 6(%0, %%\"REG_b\"), %%mm4\t\\n\\t\"\n\"movd 6(%1, %%\"REG_b\"), %%mm1\t\\n\\t\"\n\"movd 9(%0, %%\"REG_b\"), %%mm2\t\\n\\t\"\n\"movd 9(%1, %%\"REG_b\"), %%mm3\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm4\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm1\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm2\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm3\t\t\\n\\t\"\n\"paddw %%mm1, %%mm4\t\t\\n\\t\"\n\"paddw %%mm3, %%mm2\t\t\\n\\t\"\n\"paddw %%mm4, %%mm2\t\t\\n\\t\"\n\"psrlw $2, %%mm0\t\t\\n\\t\"\n\"psrlw $2, %%mm2\t\t\\n\\t\"\n#endif\n\"movq \"MANGLE(bgr2VCoeff)\", %%mm1\t\t\\n\\t\"\n\"movq \"MANGLE(bgr2VCoeff)\", %%mm3\t\t\\n\\t\"\n\"pmaddwd %%mm0, %%mm1\t\t\\n\\t\"\n\"pmaddwd %%mm2, %%mm3\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm0\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm2\t\t\\n\\t\"\n#ifndef FAST_BGR2YV12\n\"psrad $8, %%mm0\t\t\\n\\t\"\n\"psrad $8, %%mm1\t\t\\n\\t\"\n\"psrad $8, %%mm2\t\t\\n\\t\"\n\"psrad $8, %%mm3\t\t\\n\\t\"\n#endif\n\"packssdw %%mm2, %%mm0\t\t\\n\\t\"\n\"packssdw %%mm3, %%mm1\t\t\\n\\t\"\n\"pmaddwd %%mm5, %%mm0\t\t\\n\\t\"\n\"pmaddwd %%mm5, %%mm1\t\t\\n\\t\"\n\"packssdw %%mm1, %%mm0\t\t\\n\\t\"\n\"psraw $7, %%mm0\t\t\\n\\t\"\n#if defined (HAVE_MMX2) || defined (HAVE_3DNOW)\n\"movq 12(%0, %%\"REG_b\"), %%mm4\t\\n\\t\"\n\"movq 12(%1, %%\"REG_b\"), %%mm1\t\\n\\t\"\n\"movq 18(%0, %%\"REG_b\"), %%mm2\t\\n\\t\"\n\"movq 18(%1, %%\"REG_b\"), %%mm3\t\\n\\t\"\nPAVGB\" %%mm1, %%mm4\t\t\\n\\t\"\nPAVGB\" %%mm3, %%mm2\t\t\\n\\t\"\n\"movq %%mm4, %%mm1\t\t\\n\\t\"\n\"movq %%mm2, %%mm3\t\t\\n\\t\"\n\"psrlq $24, %%mm4\t\t\\n\\t\"\n\"psrlq $24, %%mm2\t\t\\n\\t\"\nPAVGB\" %%mm1, %%mm4\t\t\\n\\t\"\nPAVGB\" %%mm3, %%mm2\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm4\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm2\t\t\\n\\t\"\n#else\n\"movd 12(%0, %%\"REG_b\"), %%mm4\t\\n\\t\"\n\"movd 12(%1, %%\"REG_b\"), %%mm1\t\\n\\t\"\n\"movd 15(%0, %%\"REG_b\"), %%mm2\t\\n\\t\"\n\"movd 15(%1, %%\"REG_b\"), %%mm3\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm4\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm1\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm2\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm3\t\t\\n\\t\"\n\"paddw %%mm1, %%mm4\t\t\\n\\t\"\n\"paddw %%mm3, %%mm2\t\t\\n\\t\"\n\"paddw %%mm2, %%mm4\t\t\\n\\t\"\n\"movd 18(%0, %%\"REG_b\"), %%mm5\t\\n\\t\"\n\"movd 18(%1, %%\"REG_b\"), %%mm1\t\\n\\t\"\n\"movd 21(%0, %%\"REG_b\"), %%mm2\t\\n\\t\"\n\"movd 21(%1, %%\"REG_b\"), %%mm3\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm5\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm1\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm2\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm3\t\t\\n\\t\"\n\"paddw %%mm1, %%mm5\t\t\\n\\t\"\n\"paddw %%mm3, %%mm2\t\t\\n\\t\"\n\"paddw %%mm5, %%mm2\t\t\\n\\t\"\n\"movq \"MANGLE(w1111)\", %%mm5\t\t\\n\\t\"\n\"psrlw $2, %%mm4\t\t\\n\\t\"\n\"psrlw $2, %%mm2\t\t\\n\\t\"\n#endif\n\"movq \"MANGLE(bgr2VCoeff)\", %%mm1\t\t\\n\\t\"\n\"movq \"MANGLE(bgr2VCoeff)\", %%mm3\t\t\\n\\t\"\n\"pmaddwd %%mm4, %%mm1\t\t\\n\\t\"\n\"pmaddwd %%mm2, %%mm3\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm4\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm2\t\t\\n\\t\"\n#ifndef FAST_BGR2YV12\n\"psrad $8, %%mm4\t\t\\n\\t\"\n\"psrad $8, %%mm1\t\t\\n\\t\"\n\"psrad $8, %%mm2\t\t\\n\\t\"\n\"psrad $8, %%mm3\t\t\\n\\t\"\n#endif\n\"packssdw %%mm2, %%mm4\t\t\\n\\t\"\n\"packssdw %%mm3, %%mm1\t\t\\n\\t\"\n\"pmaddwd %%mm5, %%mm4\t\t\\n\\t\"\n\"pmaddwd %%mm5, %%mm1\t\t\\n\\t\"\n\"add $24, %%\"REG_b\"\t\t\\n\\t\"\n\"packssdw %%mm1, %%mm4\t\t\\n\\t\"\n\"psraw $7, %%mm4\t\t\\n\\t\"\n\"movq %%mm0, %%mm1\t\t\\n\\t\"\n\"punpckldq %%mm4, %%mm0\t\t\\n\\t\"\n\"punpckhdq %%mm4, %%mm1\t\t\\n\\t\"\n\"packsswb %%mm1, %%mm0\t\t\\n\\t\"\n\"paddb \"MANGLE(bgr2UVOffset)\", %%mm0\t\\n\\t\"\n\"movd %%mm0, (%2, %%\"REG_a\")\t\\n\\t\"\n\"punpckhdq %%mm0, %%mm0\t\t\\n\\t\"\n\"movd %%mm0, (%3, %%\"REG_a\")\t\\n\\t\"\n\"add $4, %%\"REG_a\"\t\t\\n\\t\"\n\" js 1b\t\t\t\t\\n\\t\"\n: : \"r\" (src+VAR_1*6), \"r\" (src+srcStride+VAR_1*6), \"r\" (udst+VAR_1), \"r\" (vdst+VAR_1), \"g\" (-VAR_1)\n: \"%\"REG_a, \"%\"REG_b\n);", "udst += chromStride;", "vdst += chromStride;", "src += srcStride*2;", "}", "asm volatile( EMMS\" \\n\\t\"\nSFENCE\" \\n\\t\"\n:::\"memory\");", "#else\nVAR_0=0;", "#endif\nfor(; VAR_0<height; VAR_0+=2)", "{", "long i;", "for(i=0; i<VAR_1; i++)", "{", "unsigned int b= src[6*i+0];", "unsigned int g= src[6*i+1];", "unsigned int r= src[6*i+2];", "unsigned int Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16;", "unsigned int V = ((RV*r + GV*g + BV*b)>>RGB2YUV_SHIFT) + 128;", "unsigned int U = ((RU*r + GU*g + BU*b)>>RGB2YUV_SHIFT) + 128;", "udst[i] \t= U;", "vdst[i] \t= V;", "ydst[2*i] \t= Y;", "b= src[6*i+3];", "g= src[6*i+4];", "r= src[6*i+5];", "Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16;", "ydst[2*i+1] \t= Y;", "}", "ydst += lumStride;", "src += srcStride;", "for(i=0; i<VAR_1; i++)", "{", "unsigned int b= src[6*i+0];", "unsigned int g= src[6*i+1];", "unsigned int r= src[6*i+2];", "unsigned int Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16;", "ydst[2*i] \t= Y;", "b= src[6*i+3];", "g= src[6*i+4];", "r= src[6*i+5];", "Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16;", "ydst[2*i+1] \t= Y;", "}", "udst += chromStride;", "vdst += chromStride;", "ydst += lumStride;", "src += srcStride;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13, 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 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, 145, 147, 151, 153, 155, 157, 159, 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171, 173, 175, 177, 179, 181, 183, 185, 187, 189, 191, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 217, 219, 221, 223, 225, 227, 229, 231, 233, 235, 237, 239, 241, 243, 245, 247, 249, 251, 253, 255, 257, 259, 261, 263, 265, 267, 269, 271, 273, 275, 277, 281, 283, 285, 287, 289, 291, 293, 295, 297, 299, 301, 303, 305, 307, 309, 311, 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, 405, 407, 409, 411, 413, 415, 417, 419, 421, 423, 425, 427, 429, 431, 433, 435, 437, 441, 443, 445, 447, 449, 451, 453, 455, 457, 459, 461, 463, 465 ], [ 469 ], [ 471 ], [ 473 ], [ 475 ], [ 479, 481, 483 ], [ 485, 487 ], [ 489, 491 ], [ 493 ], [ 495 ], [ 497 ], [ 499 ], [ 501 ], [ 503 ], [ 505 ], [ 509 ], [ 511 ], [ 513 ], [ 517 ], [ 519 ], [ 521 ], [ 525 ], [ 527 ], [ 529 ], [ 533 ], [ 535 ], [ 537 ], [ 539 ], [ 541 ], [ 545 ], [ 547 ], [ 549 ], [ 551 ], [ 553 ], [ 557 ], [ 561 ], [ 565 ], [ 567 ], [ 569 ], [ 573 ], [ 575 ], [ 577 ], [ 579 ], [ 581 ], [ 583 ], [ 585 ], [ 587 ], [ 589 ] ]
11,430
static int paf_vid_decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *pkt) { PAFVideoDecContext *c = avctx->priv_data; uint8_t code, *dst, *src, *end; int i, frame, ret; c->pic.reference = 3; if ((ret = avctx->reget_buffer(avctx, &c->pic)) < 0) return ret; bytestream2_init(&c->gb, pkt->data, pkt->size); code = bytestream2_get_byte(&c->gb); if (code & 0x20) { for (i = 0; i < 4; i++) memset(c->frame[i], 0, c->frame_size); memset(c->pic.data[1], 0, AVPALETTE_SIZE); c->current_frame = 0; c->pic.key_frame = 1; c->pic.pict_type = AV_PICTURE_TYPE_I; } else { c->pic.key_frame = 0; c->pic.pict_type = AV_PICTURE_TYPE_P; } if (code & 0x40) { uint32_t *out = (uint32_t *)c->pic.data[1]; int index, count; index = bytestream2_get_byte(&c->gb); count = bytestream2_get_byte(&c->gb) + 1; if (index + count > AVPALETTE_SIZE) return AVERROR_INVALIDDATA; if (bytestream2_get_bytes_left(&c->gb) < 3 * AVPALETTE_SIZE) return AVERROR_INVALIDDATA; out += index; for (i = 0; i < count; i++) { unsigned r, g, b; r = bytestream2_get_byteu(&c->gb); r = r << 2 | r >> 4; g = bytestream2_get_byteu(&c->gb); g = g << 2 | g >> 4; b = bytestream2_get_byteu(&c->gb); b = b << 2 | b >> 4; *out++ = 0xFFU << 24 | r << 16 | g << 8 | b; } c->pic.palette_has_changed = 1; } switch (code & 0x0F) { case 0: if ((ret = decode_0(avctx, code, pkt->data)) < 0) return ret; break; case 1: dst = c->frame[c->current_frame]; bytestream2_skip(&c->gb, 2); if (bytestream2_get_bytes_left(&c->gb) < c->video_size) return AVERROR_INVALIDDATA; bytestream2_get_bufferu(&c->gb, dst, c->video_size); break; case 2: frame = bytestream2_get_byte(&c->gb); if (frame > 3) return AVERROR_INVALIDDATA; if (frame != c->current_frame) memcpy(c->frame[c->current_frame], c->frame[frame], c->frame_size); break; case 4: dst = c->frame[c->current_frame]; end = dst + c->video_size; bytestream2_skip(&c->gb, 2); while (dst < end) { int8_t code; int count; if (bytestream2_get_bytes_left(&c->gb) < 2) return AVERROR_INVALIDDATA; code = bytestream2_get_byteu(&c->gb); count = FFABS(code) + 1; if (dst + count > end) return AVERROR_INVALIDDATA; if (code < 0) memset(dst, bytestream2_get_byteu(&c->gb), count); else bytestream2_get_buffer(&c->gb, dst, count); dst += count; } break; default: av_log_ask_for_sample(avctx, "unknown/invalid code\n"); return AVERROR_INVALIDDATA; } dst = c->pic.data[0]; src = c->frame[c->current_frame]; for (i = 0; i < avctx->height; i++) { memcpy(dst, src, avctx->width); dst += c->pic.linesize[0]; src += avctx->width; } c->current_frame = (c->current_frame + 1) & 3; *data_size = sizeof(AVFrame); *(AVFrame *)data = c->pic; return pkt->size; }
false
FFmpeg
456f0c6477925611f1b45a434795f8bad4fb2a66
static int paf_vid_decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *pkt) { PAFVideoDecContext *c = avctx->priv_data; uint8_t code, *dst, *src, *end; int i, frame, ret; c->pic.reference = 3; if ((ret = avctx->reget_buffer(avctx, &c->pic)) < 0) return ret; bytestream2_init(&c->gb, pkt->data, pkt->size); code = bytestream2_get_byte(&c->gb); if (code & 0x20) { for (i = 0; i < 4; i++) memset(c->frame[i], 0, c->frame_size); memset(c->pic.data[1], 0, AVPALETTE_SIZE); c->current_frame = 0; c->pic.key_frame = 1; c->pic.pict_type = AV_PICTURE_TYPE_I; } else { c->pic.key_frame = 0; c->pic.pict_type = AV_PICTURE_TYPE_P; } if (code & 0x40) { uint32_t *out = (uint32_t *)c->pic.data[1]; int index, count; index = bytestream2_get_byte(&c->gb); count = bytestream2_get_byte(&c->gb) + 1; if (index + count > AVPALETTE_SIZE) return AVERROR_INVALIDDATA; if (bytestream2_get_bytes_left(&c->gb) < 3 * AVPALETTE_SIZE) return AVERROR_INVALIDDATA; out += index; for (i = 0; i < count; i++) { unsigned r, g, b; r = bytestream2_get_byteu(&c->gb); r = r << 2 | r >> 4; g = bytestream2_get_byteu(&c->gb); g = g << 2 | g >> 4; b = bytestream2_get_byteu(&c->gb); b = b << 2 | b >> 4; *out++ = 0xFFU << 24 | r << 16 | g << 8 | b; } c->pic.palette_has_changed = 1; } switch (code & 0x0F) { case 0: if ((ret = decode_0(avctx, code, pkt->data)) < 0) return ret; break; case 1: dst = c->frame[c->current_frame]; bytestream2_skip(&c->gb, 2); if (bytestream2_get_bytes_left(&c->gb) < c->video_size) return AVERROR_INVALIDDATA; bytestream2_get_bufferu(&c->gb, dst, c->video_size); break; case 2: frame = bytestream2_get_byte(&c->gb); if (frame > 3) return AVERROR_INVALIDDATA; if (frame != c->current_frame) memcpy(c->frame[c->current_frame], c->frame[frame], c->frame_size); break; case 4: dst = c->frame[c->current_frame]; end = dst + c->video_size; bytestream2_skip(&c->gb, 2); while (dst < end) { int8_t code; int count; if (bytestream2_get_bytes_left(&c->gb) < 2) return AVERROR_INVALIDDATA; code = bytestream2_get_byteu(&c->gb); count = FFABS(code) + 1; if (dst + count > end) return AVERROR_INVALIDDATA; if (code < 0) memset(dst, bytestream2_get_byteu(&c->gb), count); else bytestream2_get_buffer(&c->gb, dst, count); dst += count; } break; default: av_log_ask_for_sample(avctx, "unknown/invalid code\n"); return AVERROR_INVALIDDATA; } dst = c->pic.data[0]; src = c->frame[c->current_frame]; for (i = 0; i < avctx->height; i++) { memcpy(dst, src, avctx->width); dst += c->pic.linesize[0]; src += avctx->width; } c->current_frame = (c->current_frame + 1) & 3; *data_size = sizeof(AVFrame); *(AVFrame *)data = c->pic; return pkt->size; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, AVPacket *VAR_3) { PAFVideoDecContext *c = VAR_0->priv_data; uint8_t code, *dst, *src, *end; int VAR_4, VAR_5, VAR_6; c->pic.reference = 3; if ((VAR_6 = VAR_0->reget_buffer(VAR_0, &c->pic)) < 0) return VAR_6; bytestream2_init(&c->gb, VAR_3->VAR_1, VAR_3->size); code = bytestream2_get_byte(&c->gb); if (code & 0x20) { for (VAR_4 = 0; VAR_4 < 4; VAR_4++) memset(c->VAR_5[VAR_4], 0, c->frame_size); memset(c->pic.VAR_1[1], 0, AVPALETTE_SIZE); c->current_frame = 0; c->pic.key_frame = 1; c->pic.pict_type = AV_PICTURE_TYPE_I; } else { c->pic.key_frame = 0; c->pic.pict_type = AV_PICTURE_TYPE_P; } if (code & 0x40) { uint32_t *out = (uint32_t *)c->pic.VAR_1[1]; int VAR_7, VAR_12; VAR_7 = bytestream2_get_byte(&c->gb); VAR_12 = bytestream2_get_byte(&c->gb) + 1; if (VAR_7 + VAR_12 > AVPALETTE_SIZE) return AVERROR_INVALIDDATA; if (bytestream2_get_bytes_left(&c->gb) < 3 * AVPALETTE_SIZE) return AVERROR_INVALIDDATA; out += VAR_7; for (VAR_4 = 0; VAR_4 < VAR_12; VAR_4++) { unsigned VAR_9, VAR_10, VAR_11; VAR_9 = bytestream2_get_byteu(&c->gb); VAR_9 = VAR_9 << 2 | VAR_9 >> 4; VAR_10 = bytestream2_get_byteu(&c->gb); VAR_10 = VAR_10 << 2 | VAR_10 >> 4; VAR_11 = bytestream2_get_byteu(&c->gb); VAR_11 = VAR_11 << 2 | VAR_11 >> 4; *out++ = 0xFFU << 24 | VAR_9 << 16 | VAR_10 << 8 | VAR_11; } c->pic.palette_has_changed = 1; } switch (code & 0x0F) { case 0: if ((VAR_6 = decode_0(VAR_0, code, VAR_3->VAR_1)) < 0) return VAR_6; break; case 1: dst = c->VAR_5[c->current_frame]; bytestream2_skip(&c->gb, 2); if (bytestream2_get_bytes_left(&c->gb) < c->video_size) return AVERROR_INVALIDDATA; bytestream2_get_bufferu(&c->gb, dst, c->video_size); break; case 2: VAR_5 = bytestream2_get_byte(&c->gb); if (VAR_5 > 3) return AVERROR_INVALIDDATA; if (VAR_5 != c->current_frame) memcpy(c->VAR_5[c->current_frame], c->VAR_5[VAR_5], c->frame_size); break; case 4: dst = c->VAR_5[c->current_frame]; end = dst + c->video_size; bytestream2_skip(&c->gb, 2); while (dst < end) { int8_t code; int VAR_12; if (bytestream2_get_bytes_left(&c->gb) < 2) return AVERROR_INVALIDDATA; code = bytestream2_get_byteu(&c->gb); VAR_12 = FFABS(code) + 1; if (dst + VAR_12 > end) return AVERROR_INVALIDDATA; if (code < 0) memset(dst, bytestream2_get_byteu(&c->gb), VAR_12); else bytestream2_get_buffer(&c->gb, dst, VAR_12); dst += VAR_12; } break; default: av_log_ask_for_sample(VAR_0, "unknown/invalid code\n"); return AVERROR_INVALIDDATA; } dst = c->pic.VAR_1[0]; src = c->VAR_5[c->current_frame]; for (VAR_4 = 0; VAR_4 < VAR_0->height; VAR_4++) { memcpy(dst, src, VAR_0->width); dst += c->pic.linesize[0]; src += VAR_0->width; } c->current_frame = (c->current_frame + 1) & 3; *VAR_2 = sizeof(AVFrame); *(AVFrame *)VAR_1 = c->pic; return VAR_3->size; }
[ "static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{", "PAFVideoDecContext *c = VAR_0->priv_data;", "uint8_t code, *dst, *src, *end;", "int VAR_4, VAR_5, VAR_6;", "c->pic.reference = 3;", "if ((VAR_6 = VAR_0->reget_buffer(VAR_0, &c->pic)) < 0)\nreturn VAR_6;", "bytestream2_init(&c->gb, VAR_3->VAR_1, VAR_3->size);", "code = bytestream2_get_byte(&c->gb);", "if (code & 0x20) {", "for (VAR_4 = 0; VAR_4 < 4; VAR_4++)", "memset(c->VAR_5[VAR_4], 0, c->frame_size);", "memset(c->pic.VAR_1[1], 0, AVPALETTE_SIZE);", "c->current_frame = 0;", "c->pic.key_frame = 1;", "c->pic.pict_type = AV_PICTURE_TYPE_I;", "} else {", "c->pic.key_frame = 0;", "c->pic.pict_type = AV_PICTURE_TYPE_P;", "}", "if (code & 0x40) {", "uint32_t *out = (uint32_t *)c->pic.VAR_1[1];", "int VAR_7, VAR_12;", "VAR_7 = bytestream2_get_byte(&c->gb);", "VAR_12 = bytestream2_get_byte(&c->gb) + 1;", "if (VAR_7 + VAR_12 > AVPALETTE_SIZE)\nreturn AVERROR_INVALIDDATA;", "if (bytestream2_get_bytes_left(&c->gb) < 3 * AVPALETTE_SIZE)\nreturn AVERROR_INVALIDDATA;", "out += VAR_7;", "for (VAR_4 = 0; VAR_4 < VAR_12; VAR_4++) {", "unsigned VAR_9, VAR_10, VAR_11;", "VAR_9 = bytestream2_get_byteu(&c->gb);", "VAR_9 = VAR_9 << 2 | VAR_9 >> 4;", "VAR_10 = bytestream2_get_byteu(&c->gb);", "VAR_10 = VAR_10 << 2 | VAR_10 >> 4;", "VAR_11 = bytestream2_get_byteu(&c->gb);", "VAR_11 = VAR_11 << 2 | VAR_11 >> 4;", "*out++ = 0xFFU << 24 | VAR_9 << 16 | VAR_10 << 8 | VAR_11;", "}", "c->pic.palette_has_changed = 1;", "}", "switch (code & 0x0F) {", "case 0:\nif ((VAR_6 = decode_0(VAR_0, code, VAR_3->VAR_1)) < 0)\nreturn VAR_6;", "break;", "case 1:\ndst = c->VAR_5[c->current_frame];", "bytestream2_skip(&c->gb, 2);", "if (bytestream2_get_bytes_left(&c->gb) < c->video_size)\nreturn AVERROR_INVALIDDATA;", "bytestream2_get_bufferu(&c->gb, dst, c->video_size);", "break;", "case 2:\nVAR_5 = bytestream2_get_byte(&c->gb);", "if (VAR_5 > 3)\nreturn AVERROR_INVALIDDATA;", "if (VAR_5 != c->current_frame)\nmemcpy(c->VAR_5[c->current_frame], c->VAR_5[VAR_5], c->frame_size);", "break;", "case 4:\ndst = c->VAR_5[c->current_frame];", "end = dst + c->video_size;", "bytestream2_skip(&c->gb, 2);", "while (dst < end) {", "int8_t code;", "int VAR_12;", "if (bytestream2_get_bytes_left(&c->gb) < 2)\nreturn AVERROR_INVALIDDATA;", "code = bytestream2_get_byteu(&c->gb);", "VAR_12 = FFABS(code) + 1;", "if (dst + VAR_12 > end)\nreturn AVERROR_INVALIDDATA;", "if (code < 0)\nmemset(dst, bytestream2_get_byteu(&c->gb), VAR_12);", "else\nbytestream2_get_buffer(&c->gb, dst, VAR_12);", "dst += VAR_12;", "}", "break;", "default:\nav_log_ask_for_sample(VAR_0, \"unknown/invalid code\\n\");", "return AVERROR_INVALIDDATA;", "}", "dst = c->pic.VAR_1[0];", "src = c->VAR_5[c->current_frame];", "for (VAR_4 = 0; VAR_4 < VAR_0->height; VAR_4++) {", "memcpy(dst, src, VAR_0->width);", "dst += c->pic.linesize[0];", "src += VAR_0->width;", "}", "c->current_frame = (c->current_frame + 1) & 3;", "*VAR_2 = sizeof(AVFrame);", "*(AVFrame *)VAR_1 = c->pic;", "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, 0, 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 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 63 ], [ 65 ], [ 69, 71 ], [ 73, 75 ], [ 79 ], [ 81 ], [ 83 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 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 ], [ 155 ], [ 159 ], [ 161 ], [ 163 ], [ 167, 169 ], [ 173 ], [ 175 ], [ 179, 181 ], [ 183, 185 ], [ 187, 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197, 199 ], [ 201 ], [ 203 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 223 ], [ 227 ], [ 229 ], [ 233 ], [ 235 ] ]
11,431
static int file_read(URLContext *h, unsigned char *buf, int size) { FileContext *c = h->priv_data; int r = read(c->fd, buf, size); return (-1 == r)?AVERROR(errno):r; }
false
FFmpeg
a8f171151f0f027abb06f72e48c44929616a84cb
static int file_read(URLContext *h, unsigned char *buf, int size) { FileContext *c = h->priv_data; int r = read(c->fd, buf, size); return (-1 == r)?AVERROR(errno):r; }
{ "code": [], "line_no": [] }
static int FUNC_0(URLContext *VAR_0, unsigned char *VAR_1, int VAR_2) { FileContext *c = VAR_0->priv_data; int VAR_3 = read(c->fd, VAR_1, VAR_2); return (-1 == VAR_3)?AVERROR(errno):VAR_3; }
[ "static int FUNC_0(URLContext *VAR_0, unsigned char *VAR_1, int VAR_2)\n{", "FileContext *c = VAR_0->priv_data;", "int VAR_3 = read(c->fd, VAR_1, VAR_2);", "return (-1 == VAR_3)?AVERROR(errno):VAR_3;", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ] ]
11,432
static void realview_init(ram_addr_t ram_size, const char *boot_device, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { CPUState *env; ram_addr_t ram_offset; DeviceState *dev; qemu_irq *irqp; qemu_irq pic[64]; PCIBus *pci_bus; NICInfo *nd; int n; int done_smc = 0; qemu_irq cpu_irq[4]; int ncpu; if (!cpu_model) cpu_model = "arm926"; /* FIXME: obey smp_cpus. */ if (strcmp(cpu_model, "arm11mpcore") == 0) { ncpu = 4; } else { ncpu = 1; } for (n = 0; n < ncpu; n++) { env = cpu_init(cpu_model); if (!env) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } irqp = arm_pic_init_cpu(env); cpu_irq[n] = irqp[ARM_PIC_CPU_IRQ]; if (n > 0) { /* Set entry point for secondary CPUs. This assumes we're using the init code from arm_boot.c. Real hardware resets all CPUs the same. */ env->regs[15] = 0x80000000; } } ram_offset = qemu_ram_alloc(ram_size); /* ??? RAM should repeat to fill physical memory space. */ /* SDRAM at address zero. */ cpu_register_physical_memory(0, ram_size, ram_offset | IO_MEM_RAM); arm_sysctl_init(0x10000000, 0xc1400400); if (ncpu == 1) { /* ??? The documentation says GIC1 is nFIQ and either GIC2 or GIC3 is nIRQ (there are inconsistencies). However Linux 2.6.17 expects GIC1 to be nIRQ and ignores all the others, so do that for now. */ dev = sysbus_create_simple("realview_gic", 0x10040000, cpu_irq[0]); } else { dev = sysbus_create_varargs("realview_mpcore", -1, cpu_irq[0], cpu_irq[1], cpu_irq[2], cpu_irq[3], NULL); } for (n = 0; n < 64; n++) { pic[n] = qdev_get_gpio_in(dev, n); } sysbus_create_simple("pl050_keyboard", 0x10006000, pic[20]); sysbus_create_simple("pl050_mouse", 0x10007000, pic[21]); sysbus_create_simple("pl011", 0x10009000, pic[12]); sysbus_create_simple("pl011", 0x1000a000, pic[13]); sysbus_create_simple("pl011", 0x1000b000, pic[14]); sysbus_create_simple("pl011", 0x1000c000, pic[15]); /* DMA controller is optional, apparently. */ sysbus_create_simple("pl081", 0x10030000, pic[24]); sysbus_create_simple("sp804", 0x10011000, pic[4]); sysbus_create_simple("sp804", 0x10012000, pic[5]); sysbus_create_simple("pl110_versatile", 0x10020000, pic[23]); sysbus_create_varargs("pl181", 0x10005000, pic[17], pic[18], NULL); sysbus_create_simple("pl031", 0x10017000, pic[10]); dev = sysbus_create_varargs("realview_pci", 0x60000000, pic[48], pic[49], pic[50], pic[51], NULL); pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci"); if (usb_enabled) { usb_ohci_init_pci(pci_bus, -1); } n = drive_get_max_bus(IF_SCSI); while (n >= 0) { pci_create_simple(pci_bus, -1, "lsi53c895a"); n--; } for(n = 0; n < nb_nics; n++) { nd = &nd_table[n]; if ((!nd->model && !done_smc) || strcmp(nd->model, "smc91c111") == 0) { smc91c111_init(nd, 0x4e000000, pic[28]); done_smc = 1; } else { pci_nic_init(nd, "rtl8139", NULL); } } /* Memory map for RealView Emulation Baseboard: */ /* 0x10000000 System registers. */ /* 0x10001000 System controller. */ /* 0x10002000 Two-Wire Serial Bus. */ /* 0x10003000 Reserved. */ /* 0x10004000 AACI. */ /* 0x10005000 MCI. */ /* 0x10006000 KMI0. */ /* 0x10007000 KMI1. */ /* 0x10008000 Character LCD. */ /* 0x10009000 UART0. */ /* 0x1000a000 UART1. */ /* 0x1000b000 UART2. */ /* 0x1000c000 UART3. */ /* 0x1000d000 SSPI. */ /* 0x1000e000 SCI. */ /* 0x1000f000 Reserved. */ /* 0x10010000 Watchdog. */ /* 0x10011000 Timer 0+1. */ /* 0x10012000 Timer 2+3. */ /* 0x10013000 GPIO 0. */ /* 0x10014000 GPIO 1. */ /* 0x10015000 GPIO 2. */ /* 0x10016000 Reserved. */ /* 0x10017000 RTC. */ /* 0x10018000 DMC. */ /* 0x10019000 PCI controller config. */ /* 0x10020000 CLCD. */ /* 0x10030000 DMA Controller. */ /* 0x10040000 GIC1. */ /* 0x10050000 GIC2. */ /* 0x10060000 GIC3. */ /* 0x10070000 GIC4. */ /* 0x10080000 SMC. */ /* 0x40000000 NOR flash. */ /* 0x44000000 DoC flash. */ /* 0x48000000 SRAM. */ /* 0x4c000000 Configuration flash. */ /* 0x4e000000 Ethernet. */ /* 0x4f000000 USB. */ /* 0x50000000 PISMO. */ /* 0x54000000 PISMO. */ /* 0x58000000 PISMO. */ /* 0x5c000000 PISMO. */ /* 0x60000000 PCI. */ /* 0x61000000 PCI Self Config. */ /* 0x62000000 PCI Config. */ /* 0x63000000 PCI IO. */ /* 0x64000000 PCI mem 0. */ /* 0x68000000 PCI mem 1. */ /* 0x6c000000 PCI mem 2. */ /* ??? Hack to map an additional page of ram for the secondary CPU startup code. I guess this works on real hardware because the BootROM happens to be in ROM/flash or in memory that isn't clobbered until after Linux boots the secondary CPUs. */ ram_offset = qemu_ram_alloc(0x1000); cpu_register_physical_memory(0x80000000, 0x1000, ram_offset | IO_MEM_RAM); realview_binfo.ram_size = ram_size; realview_binfo.kernel_filename = kernel_filename; realview_binfo.kernel_cmdline = kernel_cmdline; realview_binfo.initrd_filename = initrd_filename; realview_binfo.nb_cpus = ncpu; arm_load_kernel(first_cpu, &realview_binfo); }
true
qemu
07caea315a85ebfe90851f9c2e4ef3fdd24117b5
static void realview_init(ram_addr_t ram_size, const char *boot_device, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { CPUState *env; ram_addr_t ram_offset; DeviceState *dev; qemu_irq *irqp; qemu_irq pic[64]; PCIBus *pci_bus; NICInfo *nd; int n; int done_smc = 0; qemu_irq cpu_irq[4]; int ncpu; if (!cpu_model) cpu_model = "arm926"; if (strcmp(cpu_model, "arm11mpcore") == 0) { ncpu = 4; } else { ncpu = 1; } for (n = 0; n < ncpu; n++) { env = cpu_init(cpu_model); if (!env) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } irqp = arm_pic_init_cpu(env); cpu_irq[n] = irqp[ARM_PIC_CPU_IRQ]; if (n > 0) { env->regs[15] = 0x80000000; } } ram_offset = qemu_ram_alloc(ram_size); cpu_register_physical_memory(0, ram_size, ram_offset | IO_MEM_RAM); arm_sysctl_init(0x10000000, 0xc1400400); if (ncpu == 1) { dev = sysbus_create_simple("realview_gic", 0x10040000, cpu_irq[0]); } else { dev = sysbus_create_varargs("realview_mpcore", -1, cpu_irq[0], cpu_irq[1], cpu_irq[2], cpu_irq[3], NULL); } for (n = 0; n < 64; n++) { pic[n] = qdev_get_gpio_in(dev, n); } sysbus_create_simple("pl050_keyboard", 0x10006000, pic[20]); sysbus_create_simple("pl050_mouse", 0x10007000, pic[21]); sysbus_create_simple("pl011", 0x10009000, pic[12]); sysbus_create_simple("pl011", 0x1000a000, pic[13]); sysbus_create_simple("pl011", 0x1000b000, pic[14]); sysbus_create_simple("pl011", 0x1000c000, pic[15]); sysbus_create_simple("pl081", 0x10030000, pic[24]); sysbus_create_simple("sp804", 0x10011000, pic[4]); sysbus_create_simple("sp804", 0x10012000, pic[5]); sysbus_create_simple("pl110_versatile", 0x10020000, pic[23]); sysbus_create_varargs("pl181", 0x10005000, pic[17], pic[18], NULL); sysbus_create_simple("pl031", 0x10017000, pic[10]); dev = sysbus_create_varargs("realview_pci", 0x60000000, pic[48], pic[49], pic[50], pic[51], NULL); pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci"); if (usb_enabled) { usb_ohci_init_pci(pci_bus, -1); } n = drive_get_max_bus(IF_SCSI); while (n >= 0) { pci_create_simple(pci_bus, -1, "lsi53c895a"); n--; } for(n = 0; n < nb_nics; n++) { nd = &nd_table[n]; if ((!nd->model && !done_smc) || strcmp(nd->model, "smc91c111") == 0) { smc91c111_init(nd, 0x4e000000, pic[28]); done_smc = 1; } else { pci_nic_init(nd, "rtl8139", NULL); } } ram_offset = qemu_ram_alloc(0x1000); cpu_register_physical_memory(0x80000000, 0x1000, ram_offset | IO_MEM_RAM); realview_binfo.ram_size = ram_size; realview_binfo.kernel_filename = kernel_filename; realview_binfo.kernel_cmdline = kernel_cmdline; realview_binfo.initrd_filename = initrd_filename; realview_binfo.nb_cpus = ncpu; arm_load_kernel(first_cpu, &realview_binfo); }
{ "code": [ " pci_nic_init(nd, \"rtl8139\", NULL);", " pci_nic_init(nd, \"rtl8139\", NULL);" ], "line_no": [ 203, 203 ] }
static void FUNC_0(ram_addr_t VAR_0, const char *VAR_1, const char *VAR_2, const char *VAR_3, const char *VAR_4, const char *VAR_5) { CPUState *env; ram_addr_t ram_offset; DeviceState *dev; qemu_irq *irqp; qemu_irq pic[64]; PCIBus *pci_bus; NICInfo *nd; int VAR_6; int VAR_7 = 0; qemu_irq cpu_irq[4]; int VAR_8; if (!VAR_5) VAR_5 = "arm926"; if (strcmp(VAR_5, "arm11mpcore") == 0) { VAR_8 = 4; } else { VAR_8 = 1; } for (VAR_6 = 0; VAR_6 < VAR_8; VAR_6++) { env = cpu_init(VAR_5); if (!env) { fprintf(stderr, "Unable to find CPU definition\VAR_6"); exit(1); } irqp = arm_pic_init_cpu(env); cpu_irq[VAR_6] = irqp[ARM_PIC_CPU_IRQ]; if (VAR_6 > 0) { env->regs[15] = 0x80000000; } } ram_offset = qemu_ram_alloc(VAR_0); cpu_register_physical_memory(0, VAR_0, ram_offset | IO_MEM_RAM); arm_sysctl_init(0x10000000, 0xc1400400); if (VAR_8 == 1) { dev = sysbus_create_simple("realview_gic", 0x10040000, cpu_irq[0]); } else { dev = sysbus_create_varargs("realview_mpcore", -1, cpu_irq[0], cpu_irq[1], cpu_irq[2], cpu_irq[3], NULL); } for (VAR_6 = 0; VAR_6 < 64; VAR_6++) { pic[VAR_6] = qdev_get_gpio_in(dev, VAR_6); } sysbus_create_simple("pl050_keyboard", 0x10006000, pic[20]); sysbus_create_simple("pl050_mouse", 0x10007000, pic[21]); sysbus_create_simple("pl011", 0x10009000, pic[12]); sysbus_create_simple("pl011", 0x1000a000, pic[13]); sysbus_create_simple("pl011", 0x1000b000, pic[14]); sysbus_create_simple("pl011", 0x1000c000, pic[15]); sysbus_create_simple("pl081", 0x10030000, pic[24]); sysbus_create_simple("sp804", 0x10011000, pic[4]); sysbus_create_simple("sp804", 0x10012000, pic[5]); sysbus_create_simple("pl110_versatile", 0x10020000, pic[23]); sysbus_create_varargs("pl181", 0x10005000, pic[17], pic[18], NULL); sysbus_create_simple("pl031", 0x10017000, pic[10]); dev = sysbus_create_varargs("realview_pci", 0x60000000, pic[48], pic[49], pic[50], pic[51], NULL); pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci"); if (usb_enabled) { usb_ohci_init_pci(pci_bus, -1); } VAR_6 = drive_get_max_bus(IF_SCSI); while (VAR_6 >= 0) { pci_create_simple(pci_bus, -1, "lsi53c895a"); VAR_6--; } for(VAR_6 = 0; VAR_6 < nb_nics; VAR_6++) { nd = &nd_table[VAR_6]; if ((!nd->model && !VAR_7) || strcmp(nd->model, "smc91c111") == 0) { smc91c111_init(nd, 0x4e000000, pic[28]); VAR_7 = 1; } else { pci_nic_init(nd, "rtl8139", NULL); } } ram_offset = qemu_ram_alloc(0x1000); cpu_register_physical_memory(0x80000000, 0x1000, ram_offset | IO_MEM_RAM); realview_binfo.VAR_0 = VAR_0; realview_binfo.VAR_2 = VAR_2; realview_binfo.VAR_3 = VAR_3; realview_binfo.VAR_4 = VAR_4; realview_binfo.nb_cpus = VAR_8; arm_load_kernel(first_cpu, &realview_binfo); }
[ "static void FUNC_0(ram_addr_t VAR_0,\nconst char *VAR_1,\nconst char *VAR_2, const char *VAR_3,\nconst char *VAR_4, const char *VAR_5)\n{", "CPUState *env;", "ram_addr_t ram_offset;", "DeviceState *dev;", "qemu_irq *irqp;", "qemu_irq pic[64];", "PCIBus *pci_bus;", "NICInfo *nd;", "int VAR_6;", "int VAR_7 = 0;", "qemu_irq cpu_irq[4];", "int VAR_8;", "if (!VAR_5)\nVAR_5 = \"arm926\";", "if (strcmp(VAR_5, \"arm11mpcore\") == 0) {", "VAR_8 = 4;", "} else {", "VAR_8 = 1;", "}", "for (VAR_6 = 0; VAR_6 < VAR_8; VAR_6++) {", "env = cpu_init(VAR_5);", "if (!env) {", "fprintf(stderr, \"Unable to find CPU definition\\VAR_6\");", "exit(1);", "}", "irqp = arm_pic_init_cpu(env);", "cpu_irq[VAR_6] = irqp[ARM_PIC_CPU_IRQ];", "if (VAR_6 > 0) {", "env->regs[15] = 0x80000000;", "}", "}", "ram_offset = qemu_ram_alloc(VAR_0);", "cpu_register_physical_memory(0, VAR_0, ram_offset | IO_MEM_RAM);", "arm_sysctl_init(0x10000000, 0xc1400400);", "if (VAR_8 == 1) {", "dev = sysbus_create_simple(\"realview_gic\", 0x10040000, cpu_irq[0]);", "} else {", "dev = sysbus_create_varargs(\"realview_mpcore\", -1,\ncpu_irq[0], cpu_irq[1], cpu_irq[2],\ncpu_irq[3], NULL);", "}", "for (VAR_6 = 0; VAR_6 < 64; VAR_6++) {", "pic[VAR_6] = qdev_get_gpio_in(dev, VAR_6);", "}", "sysbus_create_simple(\"pl050_keyboard\", 0x10006000, pic[20]);", "sysbus_create_simple(\"pl050_mouse\", 0x10007000, pic[21]);", "sysbus_create_simple(\"pl011\", 0x10009000, pic[12]);", "sysbus_create_simple(\"pl011\", 0x1000a000, pic[13]);", "sysbus_create_simple(\"pl011\", 0x1000b000, pic[14]);", "sysbus_create_simple(\"pl011\", 0x1000c000, pic[15]);", "sysbus_create_simple(\"pl081\", 0x10030000, pic[24]);", "sysbus_create_simple(\"sp804\", 0x10011000, pic[4]);", "sysbus_create_simple(\"sp804\", 0x10012000, pic[5]);", "sysbus_create_simple(\"pl110_versatile\", 0x10020000, pic[23]);", "sysbus_create_varargs(\"pl181\", 0x10005000, pic[17], pic[18], NULL);", "sysbus_create_simple(\"pl031\", 0x10017000, pic[10]);", "dev = sysbus_create_varargs(\"realview_pci\", 0x60000000,\npic[48], pic[49], pic[50], pic[51], NULL);", "pci_bus = (PCIBus *)qdev_get_child_bus(dev, \"pci\");", "if (usb_enabled) {", "usb_ohci_init_pci(pci_bus, -1);", "}", "VAR_6 = drive_get_max_bus(IF_SCSI);", "while (VAR_6 >= 0) {", "pci_create_simple(pci_bus, -1, \"lsi53c895a\");", "VAR_6--;", "}", "for(VAR_6 = 0; VAR_6 < nb_nics; VAR_6++) {", "nd = &nd_table[VAR_6];", "if ((!nd->model && !VAR_7) || strcmp(nd->model, \"smc91c111\") == 0) {", "smc91c111_init(nd, 0x4e000000, pic[28]);", "VAR_7 = 1;", "} else {", "pci_nic_init(nd, \"rtl8139\", NULL);", "}", "}", "ram_offset = qemu_ram_alloc(0x1000);", "cpu_register_physical_memory(0x80000000, 0x1000, ram_offset | IO_MEM_RAM);", "realview_binfo.VAR_0 = VAR_0;", "realview_binfo.VAR_2 = VAR_2;", "realview_binfo.VAR_3 = VAR_3;", "realview_binfo.VAR_4 = VAR_4;", "realview_binfo.nb_cpus = VAR_8;", "arm_load_kernel(first_cpu, &realview_binfo);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35, 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 77 ], [ 79 ], [ 81 ], [ 85 ], [ 91 ], [ 95 ], [ 99 ], [ 107 ], [ 109 ], [ 111, 113, 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 127 ], [ 129 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 145 ], [ 149 ], [ 151 ], [ 155 ], [ 159 ], [ 163 ], [ 167, 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 323 ], [ 325 ], [ 329 ], [ 331 ], [ 333 ], [ 335 ], [ 337 ], [ 339 ], [ 341 ] ]
11,434
int ff_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt, const uint8_t *buf, int len) { int len1; len1 = len; ts->pkt = pkt; ts->stop_parse = 0; for(;;) { if (ts->stop_parse>0) break; if (len < TS_PACKET_SIZE) return -1; if (buf[0] != 0x47) { buf++; len--; } else { handle_packet(ts, buf); buf += TS_PACKET_SIZE; len -= TS_PACKET_SIZE; } } return len1 - len; }
true
FFmpeg
bc38e83793be5f7a184c88be55e556453a25224b
int ff_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt, const uint8_t *buf, int len) { int len1; len1 = len; ts->pkt = pkt; ts->stop_parse = 0; for(;;) { if (ts->stop_parse>0) break; if (len < TS_PACKET_SIZE) return -1; if (buf[0] != 0x47) { buf++; len--; } else { handle_packet(ts, buf); buf += TS_PACKET_SIZE; len -= TS_PACKET_SIZE; } } return len1 - len; }
{ "code": [ " ts->stop_parse = 0;", " if (ts->stop_parse>0)", " break;" ], "line_no": [ 15, 19, 21 ] }
int FUNC_0(MpegTSContext *VAR_0, AVPacket *VAR_1, const uint8_t *VAR_2, int VAR_3) { int VAR_4; VAR_4 = VAR_3; VAR_0->VAR_1 = VAR_1; VAR_0->stop_parse = 0; for(;;) { if (VAR_0->stop_parse>0) break; if (VAR_3 < TS_PACKET_SIZE) return -1; if (VAR_2[0] != 0x47) { VAR_2++; VAR_3--; } else { handle_packet(VAR_0, VAR_2); VAR_2 += TS_PACKET_SIZE; VAR_3 -= TS_PACKET_SIZE; } } return VAR_4 - VAR_3; }
[ "int FUNC_0(MpegTSContext *VAR_0, AVPacket *VAR_1,\nconst uint8_t *VAR_2, int VAR_3)\n{", "int VAR_4;", "VAR_4 = VAR_3;", "VAR_0->VAR_1 = VAR_1;", "VAR_0->stop_parse = 0;", "for(;;) {", "if (VAR_0->stop_parse>0)\nbreak;", "if (VAR_3 < TS_PACKET_SIZE)\nreturn -1;", "if (VAR_2[0] != 0x47) {", "VAR_2++;", "VAR_3--;", "} else {", "handle_packet(VAR_0, VAR_2);", "VAR_2 += TS_PACKET_SIZE;", "VAR_3 -= TS_PACKET_SIZE;", "}", "}", "return VAR_4 - VAR_3;", "}" ]
[ 0, 0, 0, 0, 1, 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 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ] ]
11,435
static int mszh_decomp(unsigned char * srcptr, int srclen, unsigned char * destptr) { unsigned char *destptr_bak = destptr; unsigned char mask = 0; unsigned char maskbit = 0; unsigned int ofs, cnt; while (srclen > 0) { if (maskbit == 0) { mask = *(srcptr++); maskbit = 8; srclen--; continue; } if ((mask & (1 << (--maskbit))) == 0) { *(int*)destptr = *(int*)srcptr; srclen -= 4; destptr += 4; srcptr += 4; } else { ofs = *(srcptr++); cnt = *(srcptr++); ofs += cnt * 256;; cnt = ((cnt >> 3) & 0x1f) + 1; ofs &= 0x7ff; srclen -= 2; cnt *= 4; for (; cnt > 0; cnt--) { *(destptr) = *(destptr - ofs); destptr++; } } } return (destptr - destptr_bak); }
true
FFmpeg
c31b81216619e6b3d986ce63c82357993e10e8e9
static int mszh_decomp(unsigned char * srcptr, int srclen, unsigned char * destptr) { unsigned char *destptr_bak = destptr; unsigned char mask = 0; unsigned char maskbit = 0; unsigned int ofs, cnt; while (srclen > 0) { if (maskbit == 0) { mask = *(srcptr++); maskbit = 8; srclen--; continue; } if ((mask & (1 << (--maskbit))) == 0) { *(int*)destptr = *(int*)srcptr; srclen -= 4; destptr += 4; srcptr += 4; } else { ofs = *(srcptr++); cnt = *(srcptr++); ofs += cnt * 256;; cnt = ((cnt >> 3) & 0x1f) + 1; ofs &= 0x7ff; srclen -= 2; cnt *= 4; for (; cnt > 0; cnt--) { *(destptr) = *(destptr - ofs); destptr++; } } } return (destptr - destptr_bak); }
{ "code": [ "static int mszh_decomp(unsigned char * srcptr, int srclen, unsigned char * destptr)", " while (srclen > 0) {" ], "line_no": [ 1, 15 ] }
static int FUNC_0(unsigned char * VAR_0, int VAR_1, unsigned char * VAR_2) { unsigned char *VAR_3 = VAR_2; unsigned char VAR_4 = 0; unsigned char VAR_5 = 0; unsigned int VAR_6, VAR_7; while (VAR_1 > 0) { if (VAR_5 == 0) { VAR_4 = *(VAR_0++); VAR_5 = 8; VAR_1--; continue; } if ((VAR_4 & (1 << (--VAR_5))) == 0) { *(int*)VAR_2 = *(int*)VAR_0; VAR_1 -= 4; VAR_2 += 4; VAR_0 += 4; } else { VAR_6 = *(VAR_0++); VAR_7 = *(VAR_0++); VAR_6 += VAR_7 * 256;; VAR_7 = ((VAR_7 >> 3) & 0x1f) + 1; VAR_6 &= 0x7ff; VAR_1 -= 2; VAR_7 *= 4; for (; VAR_7 > 0; VAR_7--) { *(VAR_2) = *(VAR_2 - VAR_6); VAR_2++; } } } return (VAR_2 - VAR_3); }
[ "static int FUNC_0(unsigned char * VAR_0, int VAR_1, unsigned char * VAR_2)\n{", "unsigned char *VAR_3 = VAR_2;", "unsigned char VAR_4 = 0;", "unsigned char VAR_5 = 0;", "unsigned int VAR_6, VAR_7;", "while (VAR_1 > 0) {", "if (VAR_5 == 0) {", "VAR_4 = *(VAR_0++);", "VAR_5 = 8;", "VAR_1--;", "continue;", "}", "if ((VAR_4 & (1 << (--VAR_5))) == 0) {", "*(int*)VAR_2 = *(int*)VAR_0;", "VAR_1 -= 4;", "VAR_2 += 4;", "VAR_0 += 4;", "} else {", "VAR_6 = *(VAR_0++);", "VAR_7 = *(VAR_0++);", "VAR_6 += VAR_7 * 256;;", "VAR_7 = ((VAR_7 >> 3) & 0x1f) + 1;", "VAR_6 &= 0x7ff;", "VAR_1 -= 2;", "VAR_7 *= 4;", "for (; VAR_7 > 0; VAR_7--) {", "*(VAR_2) = *(VAR_2 - VAR_6);", "VAR_2++;", "}", "}", "}", "return (VAR_2 - VAR_3);", "}" ]
[ 1, 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 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69 ], [ 71 ] ]
11,436
int ff_split_xiph_headers(uint8_t *extradata, int extradata_size, int first_header_size, uint8_t *header_start[3], int header_len[3]) { int i, j; if (AV_RB16(extradata) == first_header_size) { for (i=0; i<3; i++) { header_len[i] = AV_RB16(extradata); extradata += 2; header_start[i] = extradata; extradata += header_len[i]; } } else if (extradata[0] == 2) { for (i=0,j=1; i<2; i++,j++) { header_len[i] = 0; for (; j<extradata_size && extradata[j]==0xff; j++) { header_len[i] += 0xff; } if (j >= extradata_size) return -1; header_len[i] += extradata[j]; } header_len[2] = extradata_size - header_len[0] - header_len[1] - j; extradata += j; header_start[0] = extradata; header_start[1] = header_start[0] + header_len[0]; header_start[2] = header_start[1] + header_len[1]; } else { return -1; } return 0; }
true
FFmpeg
58720ebd9e671f654d89d8e401d0b4dffb79122b
int ff_split_xiph_headers(uint8_t *extradata, int extradata_size, int first_header_size, uint8_t *header_start[3], int header_len[3]) { int i, j; if (AV_RB16(extradata) == first_header_size) { for (i=0; i<3; i++) { header_len[i] = AV_RB16(extradata); extradata += 2; header_start[i] = extradata; extradata += header_len[i]; } } else if (extradata[0] == 2) { for (i=0,j=1; i<2; i++,j++) { header_len[i] = 0; for (; j<extradata_size && extradata[j]==0xff; j++) { header_len[i] += 0xff; } if (j >= extradata_size) return -1; header_len[i] += extradata[j]; } header_len[2] = extradata_size - header_len[0] - header_len[1] - j; extradata += j; header_start[0] = extradata; header_start[1] = header_start[0] + header_len[0]; header_start[2] = header_start[1] + header_len[1]; } else { return -1; } return 0; }
{ "code": [ " if (AV_RB16(extradata) == first_header_size) {", " } else if (extradata[0] == 2) {", " for (; j<extradata_size && extradata[j]==0xff; j++) {", " if (j >= extradata_size)" ], "line_no": [ 13, 27, 33, 39 ] }
int FUNC_0(uint8_t *VAR_0, int VAR_1, int VAR_2, uint8_t *VAR_3[3], int VAR_4[3]) { int VAR_5, VAR_6; if (AV_RB16(VAR_0) == VAR_2) { for (VAR_5=0; VAR_5<3; VAR_5++) { VAR_4[VAR_5] = AV_RB16(VAR_0); VAR_0 += 2; VAR_3[VAR_5] = VAR_0; VAR_0 += VAR_4[VAR_5]; } } else if (VAR_0[0] == 2) { for (VAR_5=0,VAR_6=1; VAR_5<2; VAR_5++,VAR_6++) { VAR_4[VAR_5] = 0; for (; VAR_6<VAR_1 && VAR_0[VAR_6]==0xff; VAR_6++) { VAR_4[VAR_5] += 0xff; } if (VAR_6 >= VAR_1) return -1; VAR_4[VAR_5] += VAR_0[VAR_6]; } VAR_4[2] = VAR_1 - VAR_4[0] - VAR_4[1] - VAR_6; VAR_0 += VAR_6; VAR_3[0] = VAR_0; VAR_3[1] = VAR_3[0] + VAR_4[0]; VAR_3[2] = VAR_3[1] + VAR_4[1]; } else { return -1; } return 0; }
[ "int FUNC_0(uint8_t *VAR_0, int VAR_1,\nint VAR_2, uint8_t *VAR_3[3],\nint VAR_4[3])\n{", "int VAR_5, VAR_6;", "if (AV_RB16(VAR_0) == VAR_2) {", "for (VAR_5=0; VAR_5<3; VAR_5++) {", "VAR_4[VAR_5] = AV_RB16(VAR_0);", "VAR_0 += 2;", "VAR_3[VAR_5] = VAR_0;", "VAR_0 += VAR_4[VAR_5];", "}", "} else if (VAR_0[0] == 2) {", "for (VAR_5=0,VAR_6=1; VAR_5<2; VAR_5++,VAR_6++) {", "VAR_4[VAR_5] = 0;", "for (; VAR_6<VAR_1 && VAR_0[VAR_6]==0xff; VAR_6++) {", "VAR_4[VAR_5] += 0xff;", "}", "if (VAR_6 >= VAR_1)\nreturn -1;", "VAR_4[VAR_5] += VAR_0[VAR_6];", "}", "VAR_4[2] = VAR_1 - VAR_4[0] - VAR_4[1] - VAR_6;", "VAR_0 += VAR_6;", "VAR_3[0] = VAR_0;", "VAR_3[1] = VAR_3[0] + VAR_4[0];", "VAR_3[2] = VAR_3[1] + VAR_4[1];", "} else {", "return -1;", "}", "return 0;", "}" ]
[ 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39, 41 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ] ]
11,437
static int vp3_decode_init(AVCodecContext *avctx) { Vp3DecodeContext *s = avctx->priv_data; int i; s->avctx = avctx; s->width = avctx->width; s->height = avctx->height; avctx->pix_fmt = PIX_FMT_YUV420P; avctx->has_b_frames = 0; dsputil_init(&s->dsp, avctx); /* initialize to an impossible value which will force a recalculation * in the first frame decode */ s->quality_index = -1; s->superblock_width = (s->width + 31) / 32; s->superblock_height = (s->height + 31) / 32; s->superblock_count = s->superblock_width * s->superblock_height * 3 / 2; s->u_superblock_start = s->superblock_width * s->superblock_height; s->v_superblock_start = s->superblock_width * s->superblock_height * 5 / 4; s->superblock_coding = av_malloc(s->superblock_count); s->macroblock_width = (s->width + 15) / 16; s->macroblock_height = (s->height + 15) / 16; s->macroblock_count = s->macroblock_width * s->macroblock_height; s->fragment_width = s->width / FRAGMENT_PIXELS; s->fragment_height = s->height / FRAGMENT_PIXELS; /* fragment count covers all 8x8 blocks for all 3 planes */ s->fragment_count = s->fragment_width * s->fragment_height * 3 / 2; s->u_fragment_start = s->fragment_width * s->fragment_height; s->v_fragment_start = s->fragment_width * s->fragment_height * 5 / 4; debug_init(" width: %d x %d\n", s->width, s->height); debug_init(" superblocks: %d x %d, %d total\n", s->superblock_width, s->superblock_height, s->superblock_count); debug_init(" macroblocks: %d x %d, %d total\n", s->macroblock_width, s->macroblock_height, s->macroblock_count); debug_init(" %d fragments, %d x %d, u starts @ %d, v starts @ %d\n", s->fragment_count, s->fragment_width, s->fragment_height, s->u_fragment_start, s->v_fragment_start); s->all_fragments = av_malloc(s->fragment_count * sizeof(Vp3Fragment)); s->coded_fragment_list = av_malloc(s->fragment_count * sizeof(int)); s->pixel_addresses_inited = 0; /* init VLC tables */ for (i = 0; i < 16; i++) { /* Dc histograms */ init_vlc(&s->dc_vlc[i], 5, 32, &dc_bias[i][0][1], 4, 2, &dc_bias[i][0][0], 4, 2); /* level 1 AC histograms */ init_vlc(&s->ac_vlc_1[i], 5, 32, &ac_bias_0[i][0][1], 4, 2, &ac_bias_0[i][0][0], 4, 2); /* level 2 AC histograms */ init_vlc(&s->ac_vlc_2[i], 5, 32, &ac_bias_1[i][0][1], 4, 2, &ac_bias_1[i][0][0], 4, 2); /* level 3 AC histograms */ init_vlc(&s->ac_vlc_3[i], 5, 32, &ac_bias_2[i][0][1], 4, 2, &ac_bias_2[i][0][0], 4, 2); /* level 4 AC histograms */ init_vlc(&s->ac_vlc_4[i], 5, 32, &ac_bias_3[i][0][1], 4, 2, &ac_bias_3[i][0][0], 4, 2); } /* build quantization table */ for (i = 0; i < 64; i++) quant_index[dequant_index[i]] = i; /* work out the block mapping tables */ s->superblock_fragments = av_malloc(s->superblock_count * 16 * sizeof(int)); s->superblock_macroblocks = av_malloc(s->superblock_count * 4 * sizeof(int)); s->macroblock_fragments = av_malloc(s->macroblock_count * 6 * sizeof(int)); s->macroblock_coded = av_malloc(s->macroblock_count + 1); init_block_mapping(s); /* make sure that frames are available to be freed on the first decode */ if(avctx->get_buffer(avctx, &s->golden_frame) < 0) { printf("vp3: get_buffer() failed\n"); return -1; } return 0; }
true
FFmpeg
44ae98ddef565e03080012bb22467bc7ed1ca1d2
static int vp3_decode_init(AVCodecContext *avctx) { Vp3DecodeContext *s = avctx->priv_data; int i; s->avctx = avctx; s->width = avctx->width; s->height = avctx->height; avctx->pix_fmt = PIX_FMT_YUV420P; avctx->has_b_frames = 0; dsputil_init(&s->dsp, avctx); s->quality_index = -1; s->superblock_width = (s->width + 31) / 32; s->superblock_height = (s->height + 31) / 32; s->superblock_count = s->superblock_width * s->superblock_height * 3 / 2; s->u_superblock_start = s->superblock_width * s->superblock_height; s->v_superblock_start = s->superblock_width * s->superblock_height * 5 / 4; s->superblock_coding = av_malloc(s->superblock_count); s->macroblock_width = (s->width + 15) / 16; s->macroblock_height = (s->height + 15) / 16; s->macroblock_count = s->macroblock_width * s->macroblock_height; s->fragment_width = s->width / FRAGMENT_PIXELS; s->fragment_height = s->height / FRAGMENT_PIXELS; s->fragment_count = s->fragment_width * s->fragment_height * 3 / 2; s->u_fragment_start = s->fragment_width * s->fragment_height; s->v_fragment_start = s->fragment_width * s->fragment_height * 5 / 4; debug_init(" width: %d x %d\n", s->width, s->height); debug_init(" superblocks: %d x %d, %d total\n", s->superblock_width, s->superblock_height, s->superblock_count); debug_init(" macroblocks: %d x %d, %d total\n", s->macroblock_width, s->macroblock_height, s->macroblock_count); debug_init(" %d fragments, %d x %d, u starts @ %d, v starts @ %d\n", s->fragment_count, s->fragment_width, s->fragment_height, s->u_fragment_start, s->v_fragment_start); s->all_fragments = av_malloc(s->fragment_count * sizeof(Vp3Fragment)); s->coded_fragment_list = av_malloc(s->fragment_count * sizeof(int)); s->pixel_addresses_inited = 0; for (i = 0; i < 16; i++) { init_vlc(&s->dc_vlc[i], 5, 32, &dc_bias[i][0][1], 4, 2, &dc_bias[i][0][0], 4, 2); init_vlc(&s->ac_vlc_1[i], 5, 32, &ac_bias_0[i][0][1], 4, 2, &ac_bias_0[i][0][0], 4, 2); init_vlc(&s->ac_vlc_2[i], 5, 32, &ac_bias_1[i][0][1], 4, 2, &ac_bias_1[i][0][0], 4, 2); init_vlc(&s->ac_vlc_3[i], 5, 32, &ac_bias_2[i][0][1], 4, 2, &ac_bias_2[i][0][0], 4, 2); init_vlc(&s->ac_vlc_4[i], 5, 32, &ac_bias_3[i][0][1], 4, 2, &ac_bias_3[i][0][0], 4, 2); } for (i = 0; i < 64; i++) quant_index[dequant_index[i]] = i; s->superblock_fragments = av_malloc(s->superblock_count * 16 * sizeof(int)); s->superblock_macroblocks = av_malloc(s->superblock_count * 4 * sizeof(int)); s->macroblock_fragments = av_malloc(s->macroblock_count * 6 * sizeof(int)); s->macroblock_coded = av_malloc(s->macroblock_count + 1); init_block_mapping(s); if(avctx->get_buffer(avctx, &s->golden_frame) < 0) { printf("vp3: get_buffer() failed\n"); return -1; } return 0; }
{ "code": [ " if(avctx->get_buffer(avctx, &s->golden_frame) < 0) {", " printf(\"vp3: get_buffer() failed\\n\");", " return -1;" ], "line_no": [ 185, 187, 189 ] }
static int FUNC_0(AVCodecContext *VAR_0) { Vp3DecodeContext *s = VAR_0->priv_data; int VAR_1; s->VAR_0 = VAR_0; s->width = VAR_0->width; s->height = VAR_0->height; VAR_0->pix_fmt = PIX_FMT_YUV420P; VAR_0->has_b_frames = 0; dsputil_init(&s->dsp, VAR_0); s->quality_index = -1; s->superblock_width = (s->width + 31) / 32; s->superblock_height = (s->height + 31) / 32; s->superblock_count = s->superblock_width * s->superblock_height * 3 / 2; s->u_superblock_start = s->superblock_width * s->superblock_height; s->v_superblock_start = s->superblock_width * s->superblock_height * 5 / 4; s->superblock_coding = av_malloc(s->superblock_count); s->macroblock_width = (s->width + 15) / 16; s->macroblock_height = (s->height + 15) / 16; s->macroblock_count = s->macroblock_width * s->macroblock_height; s->fragment_width = s->width / FRAGMENT_PIXELS; s->fragment_height = s->height / FRAGMENT_PIXELS; s->fragment_count = s->fragment_width * s->fragment_height * 3 / 2; s->u_fragment_start = s->fragment_width * s->fragment_height; s->v_fragment_start = s->fragment_width * s->fragment_height * 5 / 4; debug_init(" width: %d x %d\n", s->width, s->height); debug_init(" superblocks: %d x %d, %d total\n", s->superblock_width, s->superblock_height, s->superblock_count); debug_init(" macroblocks: %d x %d, %d total\n", s->macroblock_width, s->macroblock_height, s->macroblock_count); debug_init(" %d fragments, %d x %d, u starts @ %d, v starts @ %d\n", s->fragment_count, s->fragment_width, s->fragment_height, s->u_fragment_start, s->v_fragment_start); s->all_fragments = av_malloc(s->fragment_count * sizeof(Vp3Fragment)); s->coded_fragment_list = av_malloc(s->fragment_count * sizeof(int)); s->pixel_addresses_inited = 0; for (VAR_1 = 0; VAR_1 < 16; VAR_1++) { init_vlc(&s->dc_vlc[VAR_1], 5, 32, &dc_bias[VAR_1][0][1], 4, 2, &dc_bias[VAR_1][0][0], 4, 2); init_vlc(&s->ac_vlc_1[VAR_1], 5, 32, &ac_bias_0[VAR_1][0][1], 4, 2, &ac_bias_0[VAR_1][0][0], 4, 2); init_vlc(&s->ac_vlc_2[VAR_1], 5, 32, &ac_bias_1[VAR_1][0][1], 4, 2, &ac_bias_1[VAR_1][0][0], 4, 2); init_vlc(&s->ac_vlc_3[VAR_1], 5, 32, &ac_bias_2[VAR_1][0][1], 4, 2, &ac_bias_2[VAR_1][0][0], 4, 2); init_vlc(&s->ac_vlc_4[VAR_1], 5, 32, &ac_bias_3[VAR_1][0][1], 4, 2, &ac_bias_3[VAR_1][0][0], 4, 2); } for (VAR_1 = 0; VAR_1 < 64; VAR_1++) quant_index[dequant_index[VAR_1]] = VAR_1; s->superblock_fragments = av_malloc(s->superblock_count * 16 * sizeof(int)); s->superblock_macroblocks = av_malloc(s->superblock_count * 4 * sizeof(int)); s->macroblock_fragments = av_malloc(s->macroblock_count * 6 * sizeof(int)); s->macroblock_coded = av_malloc(s->macroblock_count + 1); init_block_mapping(s); if(VAR_0->get_buffer(VAR_0, &s->golden_frame) < 0) { printf("vp3: get_buffer() failed\n"); return -1; } return 0; }
[ "static int FUNC_0(AVCodecContext *VAR_0)\n{", "Vp3DecodeContext *s = VAR_0->priv_data;", "int VAR_1;", "s->VAR_0 = VAR_0;", "s->width = VAR_0->width;", "s->height = VAR_0->height;", "VAR_0->pix_fmt = PIX_FMT_YUV420P;", "VAR_0->has_b_frames = 0;", "dsputil_init(&s->dsp, VAR_0);", "s->quality_index = -1;", "s->superblock_width = (s->width + 31) / 32;", "s->superblock_height = (s->height + 31) / 32;", "s->superblock_count = s->superblock_width * s->superblock_height * 3 / 2;", "s->u_superblock_start = s->superblock_width * s->superblock_height;", "s->v_superblock_start = s->superblock_width * s->superblock_height * 5 / 4;", "s->superblock_coding = av_malloc(s->superblock_count);", "s->macroblock_width = (s->width + 15) / 16;", "s->macroblock_height = (s->height + 15) / 16;", "s->macroblock_count = s->macroblock_width * s->macroblock_height;", "s->fragment_width = s->width / FRAGMENT_PIXELS;", "s->fragment_height = s->height / FRAGMENT_PIXELS;", "s->fragment_count = s->fragment_width * s->fragment_height * 3 / 2;", "s->u_fragment_start = s->fragment_width * s->fragment_height;", "s->v_fragment_start = s->fragment_width * s->fragment_height * 5 / 4;", "debug_init(\" width: %d x %d\\n\", s->width, s->height);", "debug_init(\" superblocks: %d x %d, %d total\\n\",\ns->superblock_width, s->superblock_height, s->superblock_count);", "debug_init(\" macroblocks: %d x %d, %d total\\n\",\ns->macroblock_width, s->macroblock_height, s->macroblock_count);", "debug_init(\" %d fragments, %d x %d, u starts @ %d, v starts @ %d\\n\",\ns->fragment_count,\ns->fragment_width,\ns->fragment_height,\ns->u_fragment_start,\ns->v_fragment_start);", "s->all_fragments = av_malloc(s->fragment_count * sizeof(Vp3Fragment));", "s->coded_fragment_list = av_malloc(s->fragment_count * sizeof(int));", "s->pixel_addresses_inited = 0;", "for (VAR_1 = 0; VAR_1 < 16; VAR_1++) {", "init_vlc(&s->dc_vlc[VAR_1], 5, 32,\n&dc_bias[VAR_1][0][1], 4, 2,\n&dc_bias[VAR_1][0][0], 4, 2);", "init_vlc(&s->ac_vlc_1[VAR_1], 5, 32,\n&ac_bias_0[VAR_1][0][1], 4, 2,\n&ac_bias_0[VAR_1][0][0], 4, 2);", "init_vlc(&s->ac_vlc_2[VAR_1], 5, 32,\n&ac_bias_1[VAR_1][0][1], 4, 2,\n&ac_bias_1[VAR_1][0][0], 4, 2);", "init_vlc(&s->ac_vlc_3[VAR_1], 5, 32,\n&ac_bias_2[VAR_1][0][1], 4, 2,\n&ac_bias_2[VAR_1][0][0], 4, 2);", "init_vlc(&s->ac_vlc_4[VAR_1], 5, 32,\n&ac_bias_3[VAR_1][0][1], 4, 2,\n&ac_bias_3[VAR_1][0][0], 4, 2);", "}", "for (VAR_1 = 0; VAR_1 < 64; VAR_1++)", "quant_index[dequant_index[VAR_1]] = VAR_1;", "s->superblock_fragments = av_malloc(s->superblock_count * 16 * sizeof(int));", "s->superblock_macroblocks = av_malloc(s->superblock_count * 4 * sizeof(int));", "s->macroblock_fragments = av_malloc(s->macroblock_count * 6 * sizeof(int));", "s->macroblock_coded = av_malloc(s->macroblock_count + 1);", "init_block_mapping(s);", "if(VAR_0->get_buffer(VAR_0, &s->golden_frame) < 0) {", "printf(\"vp3: get_buffer() failed\\n\");", "return -1;", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 63 ], [ 65 ], [ 67 ], [ 71 ], [ 73, 75 ], [ 77, 79 ], [ 81, 83, 85, 87, 89, 91 ], [ 95 ], [ 97 ], [ 99 ], [ 105 ], [ 111, 113, 115 ], [ 121, 123, 125 ], [ 131, 133, 135 ], [ 141, 143, 145 ], [ 151, 153, 155 ], [ 157 ], [ 163 ], [ 165 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 195 ], [ 197 ] ]
11,438
uint16_t qpci_io_readw(QPCIDevice *dev, void *data) { uintptr_t addr = (uintptr_t)data; if (addr < QPCI_PIO_LIMIT) { return dev->bus->pio_readw(dev->bus, addr); } else { uint16_t val; dev->bus->memread(dev->bus, addr, &val, sizeof(val)); return le16_to_cpu(val); } }
true
qemu
b4ba67d9a702507793c2724e56f98e9b0f7be02b
uint16_t qpci_io_readw(QPCIDevice *dev, void *data) { uintptr_t addr = (uintptr_t)data; if (addr < QPCI_PIO_LIMIT) { return dev->bus->pio_readw(dev->bus, addr); } else { uint16_t val; dev->bus->memread(dev->bus, addr, &val, sizeof(val)); return le16_to_cpu(val); } }
{ "code": [ " uintptr_t addr = (uintptr_t)data;", " if (addr < QPCI_PIO_LIMIT) {", " dev->bus->memread(dev->bus, addr, &val, sizeof(val));", "uint16_t qpci_io_readw(QPCIDevice *dev, void *data)", " uintptr_t addr = (uintptr_t)data;", " if (addr < QPCI_PIO_LIMIT) {", " return dev->bus->pio_readw(dev->bus, addr);", " dev->bus->memread(dev->bus, addr, &val, sizeof(val));", " uintptr_t addr = (uintptr_t)data;", " if (addr < QPCI_PIO_LIMIT) {", " dev->bus->memread(dev->bus, addr, &val, sizeof(val));", " uintptr_t addr = (uintptr_t)data;", " if (addr < QPCI_PIO_LIMIT) {", " dev->bus->memread(dev->bus, addr, &val, sizeof(val));", " uintptr_t addr = (uintptr_t)data;", " if (addr < QPCI_PIO_LIMIT) {", " uintptr_t addr = (uintptr_t)data;", " if (addr < QPCI_PIO_LIMIT) {", " uintptr_t addr = (uintptr_t)data;", " if (addr < QPCI_PIO_LIMIT) {", " uintptr_t addr = (uintptr_t)data;", " if (addr < QPCI_PIO_LIMIT) {", " uintptr_t addr = (uintptr_t)data;", " uintptr_t addr = (uintptr_t)data;" ], "line_no": [ 5, 9, 17, 1, 5, 9, 11, 17, 5, 9, 17, 5, 9, 17, 5, 9, 5, 9, 5, 9, 5, 9, 5, 5 ] }
uint16_t FUNC_0(QPCIDevice *dev, void *data) { uintptr_t addr = (uintptr_t)data; if (addr < QPCI_PIO_LIMIT) { return dev->bus->pio_readw(dev->bus, addr); } else { uint16_t val; dev->bus->memread(dev->bus, addr, &val, sizeof(val)); return le16_to_cpu(val); } }
[ "uint16_t FUNC_0(QPCIDevice *dev, void *data)\n{", "uintptr_t addr = (uintptr_t)data;", "if (addr < QPCI_PIO_LIMIT) {", "return dev->bus->pio_readw(dev->bus, addr);", "} else {", "uint16_t val;", "dev->bus->memread(dev->bus, addr, &val, sizeof(val));", "return le16_to_cpu(val);", "}", "}" ]
[ 1, 1, 1, 1, 0, 0, 1, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ] ]
11,440
int avfilter_config_links(AVFilterContext *filter) { int (*config_link)(AVFilterLink *); unsigned i; int ret; for (i = 0; i < filter->nb_inputs; i ++) { AVFilterLink *link = filter->inputs[i]; AVFilterLink *inlink = link->src->nb_inputs ? link->src->inputs[0] : NULL; if (!link) continue; link->current_pts = AV_NOPTS_VALUE; switch (link->init_state) { case AVLINK_INIT: continue; case AVLINK_STARTINIT: av_log(filter, AV_LOG_INFO, "circular filter chain detected\n"); return 0; case AVLINK_UNINIT: link->init_state = AVLINK_STARTINIT; if ((ret = avfilter_config_links(link->src)) < 0) return ret; if (!(config_link = link->srcpad->config_props)) { if (link->src->nb_inputs != 1) { av_log(link->src, AV_LOG_ERROR, "Source filters and filters " "with more than one input " "must set config_props() " "callbacks on all outputs\n"); return AVERROR(EINVAL); } } else if ((ret = config_link(link)) < 0) { av_log(link->src, AV_LOG_ERROR, "Failed to configure output pad on %s\n", link->src->name); return ret; } switch (link->type) { case AVMEDIA_TYPE_VIDEO: if (!link->time_base.num && !link->time_base.den) link->time_base = inlink ? inlink->time_base : AV_TIME_BASE_Q; if (!link->sample_aspect_ratio.num && !link->sample_aspect_ratio.den) link->sample_aspect_ratio = inlink ? inlink->sample_aspect_ratio : (AVRational){1,1}; if (inlink && !link->frame_rate.num && !link->frame_rate.den) link->frame_rate = inlink->frame_rate; if (inlink) { if (!link->w) link->w = inlink->w; if (!link->h) link->h = inlink->h; } else if (!link->w || !link->h) { av_log(link->src, AV_LOG_ERROR, "Video source filters must set their output link's " "width and height\n"); return AVERROR(EINVAL); } break; case AVMEDIA_TYPE_AUDIO: if (inlink) { if (!link->sample_rate) link->sample_rate = inlink->sample_rate; if (!link->time_base.num && !link->time_base.den) link->time_base = inlink->time_base; if (!link->channel_layout) link->channel_layout = inlink->channel_layout; } else if (!link->sample_rate) { av_log(link->src, AV_LOG_ERROR, "Audio source filters must set their output link's " "sample_rate\n"); return AVERROR(EINVAL); } if (!link->time_base.num && !link->time_base.den) link->time_base = (AVRational) {1, link->sample_rate}; } if ((config_link = link->dstpad->config_props)) if ((ret = config_link(link)) < 0) { av_log(link->src, AV_LOG_ERROR, "Failed to configure input pad on %s\n", link->dst->name); return ret; } link->init_state = AVLINK_INIT; } } return 0; }
false
FFmpeg
0146c1f0f173417b2b90f35a2fdf87604cf9227a
int avfilter_config_links(AVFilterContext *filter) { int (*config_link)(AVFilterLink *); unsigned i; int ret; for (i = 0; i < filter->nb_inputs; i ++) { AVFilterLink *link = filter->inputs[i]; AVFilterLink *inlink = link->src->nb_inputs ? link->src->inputs[0] : NULL; if (!link) continue; link->current_pts = AV_NOPTS_VALUE; switch (link->init_state) { case AVLINK_INIT: continue; case AVLINK_STARTINIT: av_log(filter, AV_LOG_INFO, "circular filter chain detected\n"); return 0; case AVLINK_UNINIT: link->init_state = AVLINK_STARTINIT; if ((ret = avfilter_config_links(link->src)) < 0) return ret; if (!(config_link = link->srcpad->config_props)) { if (link->src->nb_inputs != 1) { av_log(link->src, AV_LOG_ERROR, "Source filters and filters " "with more than one input " "must set config_props() " "callbacks on all outputs\n"); return AVERROR(EINVAL); } } else if ((ret = config_link(link)) < 0) { av_log(link->src, AV_LOG_ERROR, "Failed to configure output pad on %s\n", link->src->name); return ret; } switch (link->type) { case AVMEDIA_TYPE_VIDEO: if (!link->time_base.num && !link->time_base.den) link->time_base = inlink ? inlink->time_base : AV_TIME_BASE_Q; if (!link->sample_aspect_ratio.num && !link->sample_aspect_ratio.den) link->sample_aspect_ratio = inlink ? inlink->sample_aspect_ratio : (AVRational){1,1}; if (inlink && !link->frame_rate.num && !link->frame_rate.den) link->frame_rate = inlink->frame_rate; if (inlink) { if (!link->w) link->w = inlink->w; if (!link->h) link->h = inlink->h; } else if (!link->w || !link->h) { av_log(link->src, AV_LOG_ERROR, "Video source filters must set their output link's " "width and height\n"); return AVERROR(EINVAL); } break; case AVMEDIA_TYPE_AUDIO: if (inlink) { if (!link->sample_rate) link->sample_rate = inlink->sample_rate; if (!link->time_base.num && !link->time_base.den) link->time_base = inlink->time_base; if (!link->channel_layout) link->channel_layout = inlink->channel_layout; } else if (!link->sample_rate) { av_log(link->src, AV_LOG_ERROR, "Audio source filters must set their output link's " "sample_rate\n"); return AVERROR(EINVAL); } if (!link->time_base.num && !link->time_base.den) link->time_base = (AVRational) {1, link->sample_rate}; } if ((config_link = link->dstpad->config_props)) if ((ret = config_link(link)) < 0) { av_log(link->src, AV_LOG_ERROR, "Failed to configure input pad on %s\n", link->dst->name); return ret; } link->init_state = AVLINK_INIT; } } return 0; }
{ "code": [], "line_no": [] }
VAR_2intVAR_2 VAR_2avfilter_config_linksVAR_2(VAR_2AVFilterContextVAR_2 *VAR_2VAR_0VAR_2) { VAR_2intVAR_2 (*VAR_2VAR_1VAR_2)(VAR_2AVFilterLinkVAR_2 *); VAR_2unsignedVAR_2 VAR_2iVAR_2; VAR_2intVAR_2 VAR_2retVAR_2; VAR_2forVAR_2 (VAR_2iVAR_2 = VAR_20VAR_2; VAR_2iVAR_2 < VAR_2VAR_0VAR_2->VAR_2nb_inputsVAR_2; VAR_2iVAR_2 ++) { VAR_2AVFilterLinkVAR_2 *VAR_2linkVAR_2 = VAR_2VAR_0VAR_2->VAR_2inputsVAR_2[VAR_2iVAR_2]; VAR_2AVFilterLinkVAR_2 *VAR_2inlinkVAR_2 = VAR_2linkVAR_2->VAR_2srcVAR_2->VAR_2nb_inputsVAR_2 ? VAR_2linkVAR_2->VAR_2srcVAR_2->VAR_2inputsVAR_2[VAR_20VAR_2] : VAR_2NULLVAR_2; VAR_2ifVAR_2 (!VAR_2linkVAR_2) VAR_2continueVAR_2; VAR_2linkVAR_2->VAR_2current_ptsVAR_2 = VAR_2AV_NOPTS_VALUEVAR_2; VAR_2switchVAR_2 (VAR_2linkVAR_2->VAR_2init_stateVAR_2) { VAR_2caseVAR_2 VAR_2AVLINK_INITVAR_2: VAR_2continueVAR_2; VAR_2caseVAR_2 VAR_2AVLINK_STARTINITVAR_2: VAR_2av_logVAR_2(VAR_2VAR_0VAR_2, VAR_2AV_LOG_INFOVAR_2, "VAR_2circularVAR_2 VAR_2VAR_0VAR_2 VAR_2chainVAR_2 VAR_2detectedVAR_2\VAR_2nVAR_2"); VAR_2returnVAR_2 VAR_20VAR_2; VAR_2caseVAR_2 VAR_2AVLINK_UNINITVAR_2: VAR_2linkVAR_2->VAR_2init_stateVAR_2 = VAR_2AVLINK_STARTINITVAR_2; VAR_2ifVAR_2 ((VAR_2retVAR_2 = VAR_2avfilter_config_linksVAR_2(VAR_2linkVAR_2->VAR_2srcVAR_2)) < VAR_20VAR_2) VAR_2returnVAR_2 VAR_2retVAR_2; VAR_2ifVAR_2 (!(VAR_2VAR_1VAR_2 = VAR_2linkVAR_2->VAR_2srcpadVAR_2->VAR_2config_propsVAR_2)) { VAR_2ifVAR_2 (VAR_2linkVAR_2->VAR_2srcVAR_2->VAR_2nb_inputsVAR_2 != VAR_21VAR_2) { VAR_2av_logVAR_2(VAR_2linkVAR_2->VAR_2srcVAR_2, VAR_2AV_LOG_ERRORVAR_2, "VAR_2SourceVAR_2 VAR_2filtersVAR_2 VAR_2andVAR_2 VAR_2filtersVAR_2 " "VAR_2withVAR_2 VAR_2moreVAR_2 VAR_2thanVAR_2 VAR_2oneVAR_2 VAR_2inputVAR_2 " "VAR_2mustVAR_2 VAR_2setVAR_2 VAR_2config_propsVAR_2() " "VAR_2callbacksVAR_2 VAR_2onVAR_2 VAR_2allVAR_2 VAR_2outputsVAR_2\VAR_2nVAR_2"); VAR_2returnVAR_2 VAR_2AVERRORVAR_2(VAR_2EINVALVAR_2); } } VAR_2elseVAR_2 VAR_2ifVAR_2 ((VAR_2retVAR_2 = VAR_2VAR_1VAR_2(VAR_2linkVAR_2)) < VAR_20VAR_2) { VAR_2av_logVAR_2(VAR_2linkVAR_2->VAR_2srcVAR_2, VAR_2AV_LOG_ERRORVAR_2, "VAR_2FailedVAR_2 VAR_2toVAR_2 VAR_2configureVAR_2 VAR_2outputVAR_2 VAR_2padVAR_2 VAR_2onVAR_2 %VAR_2sVAR_2\VAR_2nVAR_2", VAR_2linkVAR_2->VAR_2srcVAR_2->VAR_2nameVAR_2); VAR_2returnVAR_2 VAR_2retVAR_2; } VAR_2switchVAR_2 (VAR_2linkVAR_2->VAR_2typeVAR_2) { VAR_2caseVAR_2 VAR_2AVMEDIA_TYPE_VIDEOVAR_2: VAR_2ifVAR_2 (!VAR_2linkVAR_2->VAR_2time_baseVAR_2.VAR_2numVAR_2 && !VAR_2linkVAR_2->VAR_2time_baseVAR_2.VAR_2denVAR_2) VAR_2linkVAR_2->VAR_2time_baseVAR_2 = VAR_2inlinkVAR_2 ? VAR_2inlinkVAR_2->VAR_2time_baseVAR_2 : VAR_2AV_TIME_BASE_QVAR_2; VAR_2ifVAR_2 (!VAR_2linkVAR_2->VAR_2sample_aspect_ratioVAR_2.VAR_2numVAR_2 && !VAR_2linkVAR_2->VAR_2sample_aspect_ratioVAR_2.VAR_2denVAR_2) VAR_2linkVAR_2->VAR_2sample_aspect_ratioVAR_2 = VAR_2inlinkVAR_2 ? VAR_2inlinkVAR_2->VAR_2sample_aspect_ratioVAR_2 : (VAR_2AVRationalVAR_2){VAR_21VAR_2,VAR_21VAR_2}; VAR_2ifVAR_2 (VAR_2inlinkVAR_2 && !VAR_2linkVAR_2->VAR_2frame_rateVAR_2.VAR_2numVAR_2 && !VAR_2linkVAR_2->VAR_2frame_rateVAR_2.VAR_2denVAR_2) VAR_2linkVAR_2->VAR_2frame_rateVAR_2 = VAR_2inlinkVAR_2->VAR_2frame_rateVAR_2; VAR_2ifVAR_2 (VAR_2inlinkVAR_2) { VAR_2ifVAR_2 (!VAR_2linkVAR_2->VAR_2wVAR_2) VAR_2linkVAR_2->VAR_2wVAR_2 = VAR_2inlinkVAR_2->VAR_2wVAR_2; VAR_2ifVAR_2 (!VAR_2linkVAR_2->VAR_2hVAR_2) VAR_2linkVAR_2->VAR_2hVAR_2 = VAR_2inlinkVAR_2->VAR_2hVAR_2; } VAR_2elseVAR_2 VAR_2ifVAR_2 (!VAR_2linkVAR_2->VAR_2wVAR_2 || !VAR_2linkVAR_2->VAR_2hVAR_2) { VAR_2av_logVAR_2(VAR_2linkVAR_2->VAR_2srcVAR_2, VAR_2AV_LOG_ERRORVAR_2, "VAR_2VideoVAR_2 VAR_2sourceVAR_2 VAR_2filtersVAR_2 VAR_2mustVAR_2 VAR_2setVAR_2 VAR_2theirVAR_2 VAR_2outputVAR_2 VAR_2linkVAR_2'VAR_2sVAR_2 " "VAR_2widthVAR_2 VAR_2andVAR_2 VAR_2heightVAR_2\VAR_2nVAR_2"); VAR_2returnVAR_2 VAR_2AVERRORVAR_2(VAR_2EINVALVAR_2); } VAR_2breakVAR_2; VAR_2caseVAR_2 VAR_2AVMEDIA_TYPE_AUDIOVAR_2: VAR_2ifVAR_2 (VAR_2inlinkVAR_2) { VAR_2ifVAR_2 (!VAR_2linkVAR_2->VAR_2sample_rateVAR_2) VAR_2linkVAR_2->VAR_2sample_rateVAR_2 = VAR_2inlinkVAR_2->VAR_2sample_rateVAR_2; VAR_2ifVAR_2 (!VAR_2linkVAR_2->VAR_2time_baseVAR_2.VAR_2numVAR_2 && !VAR_2linkVAR_2->VAR_2time_baseVAR_2.VAR_2denVAR_2) VAR_2linkVAR_2->VAR_2time_baseVAR_2 = VAR_2inlinkVAR_2->VAR_2time_baseVAR_2; VAR_2ifVAR_2 (!VAR_2linkVAR_2->VAR_2channel_layoutVAR_2) VAR_2linkVAR_2->VAR_2channel_layoutVAR_2 = VAR_2inlinkVAR_2->VAR_2channel_layoutVAR_2; } VAR_2elseVAR_2 VAR_2ifVAR_2 (!VAR_2linkVAR_2->VAR_2sample_rateVAR_2) { VAR_2av_logVAR_2(VAR_2linkVAR_2->VAR_2srcVAR_2, VAR_2AV_LOG_ERRORVAR_2, "VAR_2AudioVAR_2 VAR_2sourceVAR_2 VAR_2filtersVAR_2 VAR_2mustVAR_2 VAR_2setVAR_2 VAR_2theirVAR_2 VAR_2outputVAR_2 VAR_2linkVAR_2'VAR_2sVAR_2 " "VAR_2sample_rateVAR_2\VAR_2nVAR_2"); VAR_2returnVAR_2 VAR_2AVERRORVAR_2(VAR_2EINVALVAR_2); } VAR_2ifVAR_2 (!VAR_2linkVAR_2->VAR_2time_baseVAR_2.VAR_2numVAR_2 && !VAR_2linkVAR_2->VAR_2time_baseVAR_2.VAR_2denVAR_2) VAR_2linkVAR_2->VAR_2time_baseVAR_2 = (VAR_2AVRationalVAR_2) {VAR_21VAR_2, VAR_2linkVAR_2->VAR_2sample_rateVAR_2}; } VAR_2ifVAR_2 ((VAR_2VAR_1VAR_2 = VAR_2linkVAR_2->VAR_2dstpadVAR_2->VAR_2config_propsVAR_2)) VAR_2ifVAR_2 ((VAR_2retVAR_2 = VAR_2VAR_1VAR_2(VAR_2linkVAR_2)) < VAR_20VAR_2) { VAR_2av_logVAR_2(VAR_2linkVAR_2->VAR_2srcVAR_2, VAR_2AV_LOG_ERRORVAR_2, "VAR_2FailedVAR_2 VAR_2toVAR_2 VAR_2configureVAR_2 VAR_2inputVAR_2 VAR_2padVAR_2 VAR_2onVAR_2 %VAR_2sVAR_2\VAR_2nVAR_2", VAR_2linkVAR_2->VAR_2dstVAR_2->VAR_2nameVAR_2); VAR_2returnVAR_2 VAR_2retVAR_2; } VAR_2linkVAR_2->VAR_2init_stateVAR_2 = VAR_2AVLINK_INITVAR_2; } } VAR_2returnVAR_2 VAR_20VAR_2; }
[ "VAR_2intVAR_2 VAR_2avfilter_config_linksVAR_2(VAR_2AVFilterContextVAR_2 *VAR_2VAR_0VAR_2)\n{", "VAR_2intVAR_2 (*VAR_2VAR_1VAR_2)(VAR_2AVFilterLinkVAR_2 *);", "VAR_2unsignedVAR_2 VAR_2iVAR_2;", "VAR_2intVAR_2 VAR_2retVAR_2;", "VAR_2forVAR_2 (VAR_2iVAR_2 = VAR_20VAR_2; VAR_2iVAR_2 < VAR_2VAR_0VAR_2->VAR_2nb_inputsVAR_2; VAR_2iVAR_2 ++) {", "VAR_2AVFilterLinkVAR_2 *VAR_2linkVAR_2 = VAR_2VAR_0VAR_2->VAR_2inputsVAR_2[VAR_2iVAR_2];", "VAR_2AVFilterLinkVAR_2 *VAR_2inlinkVAR_2 = VAR_2linkVAR_2->VAR_2srcVAR_2->VAR_2nb_inputsVAR_2 ?\nVAR_2linkVAR_2->VAR_2srcVAR_2->VAR_2inputsVAR_2[VAR_20VAR_2] : VAR_2NULLVAR_2;", "VAR_2ifVAR_2 (!VAR_2linkVAR_2) VAR_2continueVAR_2;", "VAR_2linkVAR_2->VAR_2current_ptsVAR_2 = VAR_2AV_NOPTS_VALUEVAR_2;", "VAR_2switchVAR_2 (VAR_2linkVAR_2->VAR_2init_stateVAR_2) {", "VAR_2caseVAR_2 VAR_2AVLINK_INITVAR_2:\nVAR_2continueVAR_2;", "VAR_2caseVAR_2 VAR_2AVLINK_STARTINITVAR_2:\nVAR_2av_logVAR_2(VAR_2VAR_0VAR_2, VAR_2AV_LOG_INFOVAR_2, \"VAR_2circularVAR_2 VAR_2VAR_0VAR_2 VAR_2chainVAR_2 VAR_2detectedVAR_2\\VAR_2nVAR_2\");", "VAR_2returnVAR_2 VAR_20VAR_2;", "VAR_2caseVAR_2 VAR_2AVLINK_UNINITVAR_2:\nVAR_2linkVAR_2->VAR_2init_stateVAR_2 = VAR_2AVLINK_STARTINITVAR_2;", "VAR_2ifVAR_2 ((VAR_2retVAR_2 = VAR_2avfilter_config_linksVAR_2(VAR_2linkVAR_2->VAR_2srcVAR_2)) < VAR_20VAR_2)\nVAR_2returnVAR_2 VAR_2retVAR_2;", "VAR_2ifVAR_2 (!(VAR_2VAR_1VAR_2 = VAR_2linkVAR_2->VAR_2srcpadVAR_2->VAR_2config_propsVAR_2)) {", "VAR_2ifVAR_2 (VAR_2linkVAR_2->VAR_2srcVAR_2->VAR_2nb_inputsVAR_2 != VAR_21VAR_2) {", "VAR_2av_logVAR_2(VAR_2linkVAR_2->VAR_2srcVAR_2, VAR_2AV_LOG_ERRORVAR_2, \"VAR_2SourceVAR_2 VAR_2filtersVAR_2 VAR_2andVAR_2 VAR_2filtersVAR_2 \"\n\"VAR_2withVAR_2 VAR_2moreVAR_2 VAR_2thanVAR_2 VAR_2oneVAR_2 VAR_2inputVAR_2 \"\n\"VAR_2mustVAR_2 VAR_2setVAR_2 VAR_2config_propsVAR_2() \"\n\"VAR_2callbacksVAR_2 VAR_2onVAR_2 VAR_2allVAR_2 VAR_2outputsVAR_2\\VAR_2nVAR_2\");", "VAR_2returnVAR_2 VAR_2AVERRORVAR_2(VAR_2EINVALVAR_2);", "}", "} VAR_2elseVAR_2 VAR_2ifVAR_2 ((VAR_2retVAR_2 = VAR_2VAR_1VAR_2(VAR_2linkVAR_2)) < VAR_20VAR_2) {", "VAR_2av_logVAR_2(VAR_2linkVAR_2->VAR_2srcVAR_2, VAR_2AV_LOG_ERRORVAR_2,\n\"VAR_2FailedVAR_2 VAR_2toVAR_2 VAR_2configureVAR_2 VAR_2outputVAR_2 VAR_2padVAR_2 VAR_2onVAR_2 %VAR_2sVAR_2\\VAR_2nVAR_2\",\nVAR_2linkVAR_2->VAR_2srcVAR_2->VAR_2nameVAR_2);", "VAR_2returnVAR_2 VAR_2retVAR_2;", "}", "VAR_2switchVAR_2 (VAR_2linkVAR_2->VAR_2typeVAR_2) {", "VAR_2caseVAR_2 VAR_2AVMEDIA_TYPE_VIDEOVAR_2:\nVAR_2ifVAR_2 (!VAR_2linkVAR_2->VAR_2time_baseVAR_2.VAR_2numVAR_2 && !VAR_2linkVAR_2->VAR_2time_baseVAR_2.VAR_2denVAR_2)\nVAR_2linkVAR_2->VAR_2time_baseVAR_2 = VAR_2inlinkVAR_2 ? VAR_2inlinkVAR_2->VAR_2time_baseVAR_2 : VAR_2AV_TIME_BASE_QVAR_2;", "VAR_2ifVAR_2 (!VAR_2linkVAR_2->VAR_2sample_aspect_ratioVAR_2.VAR_2numVAR_2 && !VAR_2linkVAR_2->VAR_2sample_aspect_ratioVAR_2.VAR_2denVAR_2)\nVAR_2linkVAR_2->VAR_2sample_aspect_ratioVAR_2 = VAR_2inlinkVAR_2 ?\nVAR_2inlinkVAR_2->VAR_2sample_aspect_ratioVAR_2 : (VAR_2AVRationalVAR_2){VAR_21VAR_2,VAR_21VAR_2};", "VAR_2ifVAR_2 (VAR_2inlinkVAR_2 && !VAR_2linkVAR_2->VAR_2frame_rateVAR_2.VAR_2numVAR_2 && !VAR_2linkVAR_2->VAR_2frame_rateVAR_2.VAR_2denVAR_2)\nVAR_2linkVAR_2->VAR_2frame_rateVAR_2 = VAR_2inlinkVAR_2->VAR_2frame_rateVAR_2;", "VAR_2ifVAR_2 (VAR_2inlinkVAR_2) {", "VAR_2ifVAR_2 (!VAR_2linkVAR_2->VAR_2wVAR_2)\nVAR_2linkVAR_2->VAR_2wVAR_2 = VAR_2inlinkVAR_2->VAR_2wVAR_2;", "VAR_2ifVAR_2 (!VAR_2linkVAR_2->VAR_2hVAR_2)\nVAR_2linkVAR_2->VAR_2hVAR_2 = VAR_2inlinkVAR_2->VAR_2hVAR_2;", "} VAR_2elseVAR_2 VAR_2ifVAR_2 (!VAR_2linkVAR_2->VAR_2wVAR_2 || !VAR_2linkVAR_2->VAR_2hVAR_2) {", "VAR_2av_logVAR_2(VAR_2linkVAR_2->VAR_2srcVAR_2, VAR_2AV_LOG_ERRORVAR_2,\n\"VAR_2VideoVAR_2 VAR_2sourceVAR_2 VAR_2filtersVAR_2 VAR_2mustVAR_2 VAR_2setVAR_2 VAR_2theirVAR_2 VAR_2outputVAR_2 VAR_2linkVAR_2'VAR_2sVAR_2 \"\n\"VAR_2widthVAR_2 VAR_2andVAR_2 VAR_2heightVAR_2\\VAR_2nVAR_2\");", "VAR_2returnVAR_2 VAR_2AVERRORVAR_2(VAR_2EINVALVAR_2);", "}", "VAR_2breakVAR_2;", "VAR_2caseVAR_2 VAR_2AVMEDIA_TYPE_AUDIOVAR_2:\nVAR_2ifVAR_2 (VAR_2inlinkVAR_2) {", "VAR_2ifVAR_2 (!VAR_2linkVAR_2->VAR_2sample_rateVAR_2)\nVAR_2linkVAR_2->VAR_2sample_rateVAR_2 = VAR_2inlinkVAR_2->VAR_2sample_rateVAR_2;", "VAR_2ifVAR_2 (!VAR_2linkVAR_2->VAR_2time_baseVAR_2.VAR_2numVAR_2 && !VAR_2linkVAR_2->VAR_2time_baseVAR_2.VAR_2denVAR_2)\nVAR_2linkVAR_2->VAR_2time_baseVAR_2 = VAR_2inlinkVAR_2->VAR_2time_baseVAR_2;", "VAR_2ifVAR_2 (!VAR_2linkVAR_2->VAR_2channel_layoutVAR_2)\nVAR_2linkVAR_2->VAR_2channel_layoutVAR_2 = VAR_2inlinkVAR_2->VAR_2channel_layoutVAR_2;", "} VAR_2elseVAR_2 VAR_2ifVAR_2 (!VAR_2linkVAR_2->VAR_2sample_rateVAR_2) {", "VAR_2av_logVAR_2(VAR_2linkVAR_2->VAR_2srcVAR_2, VAR_2AV_LOG_ERRORVAR_2,\n\"VAR_2AudioVAR_2 VAR_2sourceVAR_2 VAR_2filtersVAR_2 VAR_2mustVAR_2 VAR_2setVAR_2 VAR_2theirVAR_2 VAR_2outputVAR_2 VAR_2linkVAR_2'VAR_2sVAR_2 \"\n\"VAR_2sample_rateVAR_2\\VAR_2nVAR_2\");", "VAR_2returnVAR_2 VAR_2AVERRORVAR_2(VAR_2EINVALVAR_2);", "}", "VAR_2ifVAR_2 (!VAR_2linkVAR_2->VAR_2time_baseVAR_2.VAR_2numVAR_2 && !VAR_2linkVAR_2->VAR_2time_baseVAR_2.VAR_2denVAR_2)\nVAR_2linkVAR_2->VAR_2time_baseVAR_2 = (VAR_2AVRationalVAR_2) {VAR_21VAR_2, VAR_2linkVAR_2->VAR_2sample_rateVAR_2};", "}", "VAR_2ifVAR_2 ((VAR_2VAR_1VAR_2 = VAR_2linkVAR_2->VAR_2dstpadVAR_2->VAR_2config_propsVAR_2))\nVAR_2ifVAR_2 ((VAR_2retVAR_2 = VAR_2VAR_1VAR_2(VAR_2linkVAR_2)) < VAR_20VAR_2) {", "VAR_2av_logVAR_2(VAR_2linkVAR_2->VAR_2srcVAR_2, VAR_2AV_LOG_ERRORVAR_2,\n\"VAR_2FailedVAR_2 VAR_2toVAR_2 VAR_2configureVAR_2 VAR_2inputVAR_2 VAR_2padVAR_2 VAR_2onVAR_2 %VAR_2sVAR_2\\VAR_2nVAR_2\",\nVAR_2linkVAR_2->VAR_2dstVAR_2->VAR_2nameVAR_2);", "VAR_2returnVAR_2 VAR_2retVAR_2;", "}", "VAR_2linkVAR_2->VAR_2init_stateVAR_2 = VAR_2AVLINK_INITVAR_2;", "}", "}", "VAR_2returnVAR_2 VAR_20VAR_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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17, 19 ], [ 23 ], [ 27 ], [ 31 ], [ 33, 35 ], [ 37, 39 ], [ 41 ], [ 43, 45 ], [ 49, 51 ], [ 55 ], [ 57 ], [ 59, 61, 63, 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73, 75, 77 ], [ 79 ], [ 81 ], [ 85 ], [ 87, 89, 91 ], [ 95, 97, 99 ], [ 103, 105 ], [ 109 ], [ 111, 113 ], [ 115, 117 ], [ 119 ], [ 121, 123, 125 ], [ 127 ], [ 129 ], [ 131 ], [ 135, 137 ], [ 139, 141 ], [ 143, 145 ], [ 147, 149 ], [ 151 ], [ 153, 155, 157 ], [ 159 ], [ 161 ], [ 165, 167 ], [ 169 ], [ 173, 175 ], [ 177, 179, 181 ], [ 183 ], [ 185 ], [ 189 ], [ 191 ], [ 193 ], [ 197 ], [ 199 ] ]
11,441
static inline void RENAME(bgr24ToY)(uint8_t *dst, uint8_t *src, long width) { #ifdef HAVE_MMX asm volatile( "mov %2, %%"REG_a" \n\t" "movq "MANGLE(bgr2YCoeff)", %%mm6 \n\t" "movq "MANGLE(w1111)", %%mm5 \n\t" "pxor %%mm7, %%mm7 \n\t" "lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t" ASMALIGN16 "1: \n\t" PREFETCH" 64(%0, %%"REG_b") \n\t" "movd (%0, %%"REG_b"), %%mm0 \n\t" "movd 3(%0, %%"REG_b"), %%mm1 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "movd 6(%0, %%"REG_b"), %%mm2 \n\t" "movd 9(%0, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "pmaddwd %%mm6, %%mm0 \n\t" "pmaddwd %%mm6, %%mm1 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" "pmaddwd %%mm6, %%mm3 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm0 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm1, %%mm0 \n\t" "packssdw %%mm3, %%mm2 \n\t" "pmaddwd %%mm5, %%mm0 \n\t" "pmaddwd %%mm5, %%mm2 \n\t" "packssdw %%mm2, %%mm0 \n\t" "psraw $7, %%mm0 \n\t" "movd 12(%0, %%"REG_b"), %%mm4 \n\t" "movd 15(%0, %%"REG_b"), %%mm1 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "movd 18(%0, %%"REG_b"), %%mm2 \n\t" "movd 21(%0, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "pmaddwd %%mm6, %%mm4 \n\t" "pmaddwd %%mm6, %%mm1 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" "pmaddwd %%mm6, %%mm3 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm4 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm1, %%mm4 \n\t" "packssdw %%mm3, %%mm2 \n\t" "pmaddwd %%mm5, %%mm4 \n\t" "pmaddwd %%mm5, %%mm2 \n\t" "add $24, %%"REG_b" \n\t" "packssdw %%mm2, %%mm4 \n\t" "psraw $7, %%mm4 \n\t" "packuswb %%mm4, %%mm0 \n\t" "paddusb "MANGLE(bgr2YOffset)", %%mm0 \n\t" "movq %%mm0, (%1, %%"REG_a") \n\t" "add $8, %%"REG_a" \n\t" " js 1b \n\t" : : "r" (src+width*3), "r" (dst+width), "g" (-width) : "%"REG_a, "%"REG_b ); #else int i; for(i=0; i<width; i++) { int b= src[i*3+0]; int g= src[i*3+1]; int r= src[i*3+2]; dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT); } #endif }
false
FFmpeg
4bff9ef9d0781c4de228bf1f85634d2706fc589b
static inline void RENAME(bgr24ToY)(uint8_t *dst, uint8_t *src, long width) { #ifdef HAVE_MMX asm volatile( "mov %2, %%"REG_a" \n\t" "movq "MANGLE(bgr2YCoeff)", %%mm6 \n\t" "movq "MANGLE(w1111)", %%mm5 \n\t" "pxor %%mm7, %%mm7 \n\t" "lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t" ASMALIGN16 "1: \n\t" PREFETCH" 64(%0, %%"REG_b") \n\t" "movd (%0, %%"REG_b"), %%mm0 \n\t" "movd 3(%0, %%"REG_b"), %%mm1 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "movd 6(%0, %%"REG_b"), %%mm2 \n\t" "movd 9(%0, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "pmaddwd %%mm6, %%mm0 \n\t" "pmaddwd %%mm6, %%mm1 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" "pmaddwd %%mm6, %%mm3 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm0 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm1, %%mm0 \n\t" "packssdw %%mm3, %%mm2 \n\t" "pmaddwd %%mm5, %%mm0 \n\t" "pmaddwd %%mm5, %%mm2 \n\t" "packssdw %%mm2, %%mm0 \n\t" "psraw $7, %%mm0 \n\t" "movd 12(%0, %%"REG_b"), %%mm4 \n\t" "movd 15(%0, %%"REG_b"), %%mm1 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "movd 18(%0, %%"REG_b"), %%mm2 \n\t" "movd 21(%0, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "pmaddwd %%mm6, %%mm4 \n\t" "pmaddwd %%mm6, %%mm1 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" "pmaddwd %%mm6, %%mm3 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm4 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm1, %%mm4 \n\t" "packssdw %%mm3, %%mm2 \n\t" "pmaddwd %%mm5, %%mm4 \n\t" "pmaddwd %%mm5, %%mm2 \n\t" "add $24, %%"REG_b" \n\t" "packssdw %%mm2, %%mm4 \n\t" "psraw $7, %%mm4 \n\t" "packuswb %%mm4, %%mm0 \n\t" "paddusb "MANGLE(bgr2YOffset)", %%mm0 \n\t" "movq %%mm0, (%1, %%"REG_a") \n\t" "add $8, %%"REG_a" \n\t" " js 1b \n\t" : : "r" (src+width*3), "r" (dst+width), "g" (-width) : "%"REG_a, "%"REG_b ); #else int i; for(i=0; i<width; i++) { int b= src[i*3+0]; int g= src[i*3+1]; int r= src[i*3+2]; dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT); } #endif }
{ "code": [], "line_no": [] }
static inline void FUNC_0(bgr24ToY)(uint8_t *dst, uint8_t *src, long width) { #ifdef HAVE_MMX asm volatile( "mov %2, %%"REG_a" \n\t" "movq "MANGLE(bgr2YCoeff)", %%mm6 \n\t" "movq "MANGLE(w1111)", %%mm5 \n\t" "pxor %%mm7, %%mm7 \n\t" "lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t" ASMALIGN16 "1: \n\t" PREFETCH" 64(%0, %%"REG_b") \n\t" "movd (%0, %%"REG_b"), %%mm0 \n\t" "movd 3(%0, %%"REG_b"), %%mm1 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "movd 6(%0, %%"REG_b"), %%mm2 \n\t" "movd 9(%0, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "pmaddwd %%mm6, %%mm0 \n\t" "pmaddwd %%mm6, %%mm1 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" "pmaddwd %%mm6, %%mm3 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm0 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm1, %%mm0 \n\t" "packssdw %%mm3, %%mm2 \n\t" "pmaddwd %%mm5, %%mm0 \n\t" "pmaddwd %%mm5, %%mm2 \n\t" "packssdw %%mm2, %%mm0 \n\t" "psraw $7, %%mm0 \n\t" "movd 12(%0, %%"REG_b"), %%mm4 \n\t" "movd 15(%0, %%"REG_b"), %%mm1 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "movd 18(%0, %%"REG_b"), %%mm2 \n\t" "movd 21(%0, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "pmaddwd %%mm6, %%mm4 \n\t" "pmaddwd %%mm6, %%mm1 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" "pmaddwd %%mm6, %%mm3 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm4 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm1, %%mm4 \n\t" "packssdw %%mm3, %%mm2 \n\t" "pmaddwd %%mm5, %%mm4 \n\t" "pmaddwd %%mm5, %%mm2 \n\t" "add $24, %%"REG_b" \n\t" "packssdw %%mm2, %%mm4 \n\t" "psraw $7, %%mm4 \n\t" "packuswb %%mm4, %%mm0 \n\t" "paddusb "MANGLE(bgr2YOffset)", %%mm0 \n\t" "movq %%mm0, (%1, %%"REG_a") \n\t" "add $8, %%"REG_a" \n\t" " js 1b \n\t" : : "r" (src+width*3), "r" (dst+width), "g" (-width) : "%"REG_a, "%"REG_b ); #else int VAR_0; for(VAR_0=0; VAR_0<width; VAR_0++) { int b= src[VAR_0*3+0]; int g= src[VAR_0*3+1]; int r= src[VAR_0*3+2]; dst[VAR_0]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT); } #endif }
[ "static inline void FUNC_0(bgr24ToY)(uint8_t *dst, uint8_t *src, long width)\n{", "#ifdef HAVE_MMX\nasm volatile(\n\"mov %2, %%\"REG_a\"\t\t\\n\\t\"\n\"movq \"MANGLE(bgr2YCoeff)\", %%mm6\t\t\\n\\t\"\n\"movq \"MANGLE(w1111)\", %%mm5\t\t\\n\\t\"\n\"pxor %%mm7, %%mm7\t\t\\n\\t\"\n\"lea (%%\"REG_a\", %%\"REG_a\", 2), %%\"REG_b\"\\n\\t\"\nASMALIGN16\n\"1:\t\t\t\t\\n\\t\"\nPREFETCH\" 64(%0, %%\"REG_b\")\t\\n\\t\"\n\"movd (%0, %%\"REG_b\"), %%mm0\t\\n\\t\"\n\"movd 3(%0, %%\"REG_b\"), %%mm1\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm0\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm1\t\t\\n\\t\"\n\"movd 6(%0, %%\"REG_b\"), %%mm2\t\\n\\t\"\n\"movd 9(%0, %%\"REG_b\"), %%mm3\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm2\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm3\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm0\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm1\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm2\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm3\t\t\\n\\t\"\n#ifndef FAST_BGR2YV12\n\"psrad $8, %%mm0\t\t\\n\\t\"\n\"psrad $8, %%mm1\t\t\\n\\t\"\n\"psrad $8, %%mm2\t\t\\n\\t\"\n\"psrad $8, %%mm3\t\t\\n\\t\"\n#endif\n\"packssdw %%mm1, %%mm0\t\t\\n\\t\"\n\"packssdw %%mm3, %%mm2\t\t\\n\\t\"\n\"pmaddwd %%mm5, %%mm0\t\t\\n\\t\"\n\"pmaddwd %%mm5, %%mm2\t\t\\n\\t\"\n\"packssdw %%mm2, %%mm0\t\t\\n\\t\"\n\"psraw $7, %%mm0\t\t\\n\\t\"\n\"movd 12(%0, %%\"REG_b\"), %%mm4\t\\n\\t\"\n\"movd 15(%0, %%\"REG_b\"), %%mm1\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm4\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm1\t\t\\n\\t\"\n\"movd 18(%0, %%\"REG_b\"), %%mm2\t\\n\\t\"\n\"movd 21(%0, %%\"REG_b\"), %%mm3\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm2\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm3\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm4\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm1\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm2\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm3\t\t\\n\\t\"\n#ifndef FAST_BGR2YV12\n\"psrad $8, %%mm4\t\t\\n\\t\"\n\"psrad $8, %%mm1\t\t\\n\\t\"\n\"psrad $8, %%mm2\t\t\\n\\t\"\n\"psrad $8, %%mm3\t\t\\n\\t\"\n#endif\n\"packssdw %%mm1, %%mm4\t\t\\n\\t\"\n\"packssdw %%mm3, %%mm2\t\t\\n\\t\"\n\"pmaddwd %%mm5, %%mm4\t\t\\n\\t\"\n\"pmaddwd %%mm5, %%mm2\t\t\\n\\t\"\n\"add $24, %%\"REG_b\"\t\t\\n\\t\"\n\"packssdw %%mm2, %%mm4\t\t\\n\\t\"\n\"psraw $7, %%mm4\t\t\\n\\t\"\n\"packuswb %%mm4, %%mm0\t\t\\n\\t\"\n\"paddusb \"MANGLE(bgr2YOffset)\", %%mm0\t\\n\\t\"\n\"movq %%mm0, (%1, %%\"REG_a\")\t\\n\\t\"\n\"add $8, %%\"REG_a\"\t\t\\n\\t\"\n\" js 1b\t\t\t\t\\n\\t\"\n: : \"r\" (src+width*3), \"r\" (dst+width), \"g\" (-width)\n: \"%\"REG_a, \"%\"REG_b\n);", "#else\nint VAR_0;", "for(VAR_0=0; VAR_0<width; VAR_0++)", "{", "int b= src[VAR_0*3+0];", "int g= src[VAR_0*3+1];", "int r= src[VAR_0*3+2];", "dst[VAR_0]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT);", "}", "#endif\n}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 127, 129, 133, 135, 137, 139, 141, 143 ], [ 145, 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 161 ], [ 163 ], [ 165, 167 ] ]
11,442
static inline int decode_subframe(FLACContext *s, int channel) { int type, wasted = 0; int i, tmp; s->curr_bps = s->bps; if (channel == 0) { if (s->decorrelation == RIGHT_SIDE) s->curr_bps++; } else { if (s->decorrelation == LEFT_SIDE || s->decorrelation == MID_SIDE) s->curr_bps++; } if (s->curr_bps > 32) { ff_log_missing_feature(s->avctx, "decorrelated bit depth > 32", 0); return -1; } if (get_bits1(&s->gb)) { av_log(s->avctx, AV_LOG_ERROR, "invalid subframe padding\n"); return -1; } type = get_bits(&s->gb, 6); if (get_bits1(&s->gb)) { wasted = 1; while (!get_bits1(&s->gb)) wasted++; s->curr_bps -= wasted; } //FIXME use av_log2 for types if (type == 0) { tmp = get_sbits_long(&s->gb, s->curr_bps); for (i = 0; i < s->blocksize; i++) s->decoded[channel][i] = tmp; } else if (type == 1) { for (i = 0; i < s->blocksize; i++) s->decoded[channel][i] = get_sbits_long(&s->gb, s->curr_bps); } else if ((type >= 8) && (type <= 12)) { if (decode_subframe_fixed(s, channel, type & ~0x8) < 0) return -1; } else if (type >= 32) { if (decode_subframe_lpc(s, channel, (type & ~0x20)+1) < 0) return -1; } else { av_log(s->avctx, AV_LOG_ERROR, "invalid coding type\n"); return -1; } if (wasted) { int i; for (i = 0; i < s->blocksize; i++) s->decoded[channel][i] <<= wasted; } return 0; }
false
FFmpeg
a3d2379bdd821eec60f20ee3945047d659894bda
static inline int decode_subframe(FLACContext *s, int channel) { int type, wasted = 0; int i, tmp; s->curr_bps = s->bps; if (channel == 0) { if (s->decorrelation == RIGHT_SIDE) s->curr_bps++; } else { if (s->decorrelation == LEFT_SIDE || s->decorrelation == MID_SIDE) s->curr_bps++; } if (s->curr_bps > 32) { ff_log_missing_feature(s->avctx, "decorrelated bit depth > 32", 0); return -1; } if (get_bits1(&s->gb)) { av_log(s->avctx, AV_LOG_ERROR, "invalid subframe padding\n"); return -1; } type = get_bits(&s->gb, 6); if (get_bits1(&s->gb)) { wasted = 1; while (!get_bits1(&s->gb)) wasted++; s->curr_bps -= wasted; } if (type == 0) { tmp = get_sbits_long(&s->gb, s->curr_bps); for (i = 0; i < s->blocksize; i++) s->decoded[channel][i] = tmp; } else if (type == 1) { for (i = 0; i < s->blocksize; i++) s->decoded[channel][i] = get_sbits_long(&s->gb, s->curr_bps); } else if ((type >= 8) && (type <= 12)) { if (decode_subframe_fixed(s, channel, type & ~0x8) < 0) return -1; } else if (type >= 32) { if (decode_subframe_lpc(s, channel, (type & ~0x20)+1) < 0) return -1; } else { av_log(s->avctx, AV_LOG_ERROR, "invalid coding type\n"); return -1; } if (wasted) { int i; for (i = 0; i < s->blocksize; i++) s->decoded[channel][i] <<= wasted; } return 0; }
{ "code": [], "line_no": [] }
static inline int FUNC_0(FLACContext *VAR_0, int VAR_1) { int VAR_2, VAR_3 = 0; int VAR_6, VAR_5; VAR_0->curr_bps = VAR_0->bps; if (VAR_1 == 0) { if (VAR_0->decorrelation == RIGHT_SIDE) VAR_0->curr_bps++; } else { if (VAR_0->decorrelation == LEFT_SIDE || VAR_0->decorrelation == MID_SIDE) VAR_0->curr_bps++; } if (VAR_0->curr_bps > 32) { ff_log_missing_feature(VAR_0->avctx, "decorrelated bit depth > 32", 0); return -1; } if (get_bits1(&VAR_0->gb)) { av_log(VAR_0->avctx, AV_LOG_ERROR, "invalid subframe padding\n"); return -1; } VAR_2 = get_bits(&VAR_0->gb, 6); if (get_bits1(&VAR_0->gb)) { VAR_3 = 1; while (!get_bits1(&VAR_0->gb)) VAR_3++; VAR_0->curr_bps -= VAR_3; } if (VAR_2 == 0) { VAR_5 = get_sbits_long(&VAR_0->gb, VAR_0->curr_bps); for (VAR_6 = 0; VAR_6 < VAR_0->blocksize; VAR_6++) VAR_0->decoded[VAR_1][VAR_6] = VAR_5; } else if (VAR_2 == 1) { for (VAR_6 = 0; VAR_6 < VAR_0->blocksize; VAR_6++) VAR_0->decoded[VAR_1][VAR_6] = get_sbits_long(&VAR_0->gb, VAR_0->curr_bps); } else if ((VAR_2 >= 8) && (VAR_2 <= 12)) { if (decode_subframe_fixed(VAR_0, VAR_1, VAR_2 & ~0x8) < 0) return -1; } else if (VAR_2 >= 32) { if (decode_subframe_lpc(VAR_0, VAR_1, (VAR_2 & ~0x20)+1) < 0) return -1; } else { av_log(VAR_0->avctx, AV_LOG_ERROR, "invalid coding VAR_2\n"); return -1; } if (VAR_3) { int VAR_6; for (VAR_6 = 0; VAR_6 < VAR_0->blocksize; VAR_6++) VAR_0->decoded[VAR_1][VAR_6] <<= VAR_3; } return 0; }
[ "static inline int FUNC_0(FLACContext *VAR_0, int VAR_1)\n{", "int VAR_2, VAR_3 = 0;", "int VAR_6, VAR_5;", "VAR_0->curr_bps = VAR_0->bps;", "if (VAR_1 == 0) {", "if (VAR_0->decorrelation == RIGHT_SIDE)\nVAR_0->curr_bps++;", "} else {", "if (VAR_0->decorrelation == LEFT_SIDE || VAR_0->decorrelation == MID_SIDE)\nVAR_0->curr_bps++;", "}", "if (VAR_0->curr_bps > 32) {", "ff_log_missing_feature(VAR_0->avctx, \"decorrelated bit depth > 32\", 0);", "return -1;", "}", "if (get_bits1(&VAR_0->gb)) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"invalid subframe padding\\n\");", "return -1;", "}", "VAR_2 = get_bits(&VAR_0->gb, 6);", "if (get_bits1(&VAR_0->gb)) {", "VAR_3 = 1;", "while (!get_bits1(&VAR_0->gb))\nVAR_3++;", "VAR_0->curr_bps -= VAR_3;", "}", "if (VAR_2 == 0) {", "VAR_5 = get_sbits_long(&VAR_0->gb, VAR_0->curr_bps);", "for (VAR_6 = 0; VAR_6 < VAR_0->blocksize; VAR_6++)", "VAR_0->decoded[VAR_1][VAR_6] = VAR_5;", "} else if (VAR_2 == 1) {", "for (VAR_6 = 0; VAR_6 < VAR_0->blocksize; VAR_6++)", "VAR_0->decoded[VAR_1][VAR_6] = get_sbits_long(&VAR_0->gb, VAR_0->curr_bps);", "} else if ((VAR_2 >= 8) && (VAR_2 <= 12)) {", "if (decode_subframe_fixed(VAR_0, VAR_1, VAR_2 & ~0x8) < 0)\nreturn -1;", "} else if (VAR_2 >= 32) {", "if (decode_subframe_lpc(VAR_0, VAR_1, (VAR_2 & ~0x20)+1) < 0)\nreturn -1;", "} else {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"invalid coding VAR_2\\n\");", "return -1;", "}", "if (VAR_3) {", "int VAR_6;", "for (VAR_6 = 0; VAR_6 < VAR_0->blocksize; VAR_6++)", "VAR_0->decoded[VAR_1][VAR_6] <<= VAR_3;", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15, 17 ], [ 19 ], [ 21, 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53, 55 ], [ 57 ], [ 59 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81, 83 ], [ 85 ], [ 87, 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 113 ], [ 115 ] ]
11,443
static void unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb) { int bit = 0; int current_superblock = 0; int current_run = 0; int decode_fully_flags = 0; int decode_partial_blocks = 0; int i, j; int current_fragment; debug_vp3(" vp3: unpacking superblock coding\n"); if (s->keyframe) { debug_vp3(" keyframe-- all superblocks are fully coded\n"); memset(s->superblock_coding, SB_FULLY_CODED, s->superblock_count); } else { /* unpack the list of partially-coded superblocks */ bit = get_bits(gb, 1); /* toggle the bit because as soon as the first run length is * fetched the bit will be toggled again */ bit ^= 1; while (current_superblock < s->superblock_count) { if (current_run == 0) { bit ^= 1; current_run = get_superblock_run_length(gb); debug_block_coding(" setting superblocks %d..%d to %s\n", current_superblock, current_superblock + current_run - 1, (bit) ? "partially coded" : "not coded"); /* if any of the superblocks are not partially coded, flag * a boolean to decode the list of fully-coded superblocks */ if (bit == 0) decode_fully_flags = 1; } else { /* make a note of the fact that there are partially coded * superblocks */ decode_partial_blocks = 1; } s->superblock_coding[current_superblock++] = (bit) ? SB_PARTIALLY_CODED : SB_NOT_CODED; current_run--; } /* unpack the list of fully coded superblocks if any of the blocks were * not marked as partially coded in the previous step */ if (decode_fully_flags) { current_superblock = 0; current_run = 0; bit = get_bits(gb, 1); /* toggle the bit because as soon as the first run length is * fetched the bit will be toggled again */ bit ^= 1; while (current_superblock < s->superblock_count) { /* skip any superblocks already marked as partially coded */ if (s->superblock_coding[current_superblock] == SB_NOT_CODED) { if (current_run == 0) { bit ^= 1; current_run = get_superblock_run_length(gb); } debug_block_coding(" setting superblock %d to %s\n", current_superblock, (bit) ? "fully coded" : "not coded"); s->superblock_coding[current_superblock] = (bit) ? SB_FULLY_CODED : SB_NOT_CODED; current_run--; } current_superblock++; } } /* if there were partial blocks, initialize bitstream for * unpacking fragment codings */ if (decode_partial_blocks) { current_run = 0; bit = get_bits(gb, 1); /* toggle the bit because as soon as the first run length is * fetched the bit will be toggled again */ bit ^= 1; } } /* figure out which fragments are coded; iterate through each * superblock (all planes) */ s->coded_fragment_list_index = 0; s->first_coded_y_fragment = s->first_coded_c_fragment = 0; s->last_coded_y_fragment = s->last_coded_c_fragment = -1; memset(s->macroblock_coded, 0, s->macroblock_count); for (i = 0; i < s->superblock_count; i++) { /* iterate through all 16 fragments in a superblock */ for (j = 0; j < 16; j++) { /* if the fragment is in bounds, check its coding status */ current_fragment = s->superblock_fragments[i * 16 + j]; if (current_fragment != -1) { if (s->superblock_coding[i] == SB_NOT_CODED) { /* copy all the fragments from the prior frame */ s->all_fragments[current_fragment].coding_method = MODE_COPY; } else if (s->superblock_coding[i] == SB_PARTIALLY_CODED) { /* fragment may or may not be coded; this is the case * that cares about the fragment coding runs */ if (current_run == 0) { bit ^= 1; current_run = get_fragment_run_length(gb); } if (bit) { /* mode will be decoded in the next phase */ s->all_fragments[current_fragment].coding_method = MODE_INTER_NO_MV; s->coded_fragment_list[s->coded_fragment_list_index] = current_fragment; if ((current_fragment >= s->u_fragment_start) && (s->last_coded_y_fragment == -1)) { s->first_coded_c_fragment = s->coded_fragment_list_index; s->last_coded_y_fragment = s->first_coded_c_fragment - 1; } s->coded_fragment_list_index++; s->macroblock_coded[s->all_fragments[current_fragment].macroblock] = 1; debug_block_coding(" superblock %d is partially coded, fragment %d is coded\n", i, current_fragment); } else { /* not coded; copy this fragment from the prior frame */ s->all_fragments[current_fragment].coding_method = MODE_COPY; debug_block_coding(" superblock %d is partially coded, fragment %d is not coded\n", i, current_fragment); } current_run--; } else { /* fragments are fully coded in this superblock; actual * coding will be determined in next step */ s->all_fragments[current_fragment].coding_method = MODE_INTER_NO_MV; s->coded_fragment_list[s->coded_fragment_list_index] = current_fragment; if ((current_fragment >= s->u_fragment_start) && (s->last_coded_y_fragment == -1)) { s->first_coded_c_fragment = s->coded_fragment_list_index; s->last_coded_y_fragment = s->first_coded_c_fragment - 1; } s->coded_fragment_list_index++; s->macroblock_coded[s->all_fragments[current_fragment].macroblock] = 1; debug_block_coding(" superblock %d is fully coded, fragment %d is coded\n", i, current_fragment); } } } } if (s->first_coded_c_fragment == 0) /* no C fragments coded */ s->last_coded_y_fragment = s->coded_fragment_list_index - 1; else s->last_coded_c_fragment = s->coded_fragment_list_index - 1; debug_block_coding(" %d total coded fragments, y: %d -> %d, c: %d -> %d\n", s->coded_fragment_list_index, s->first_coded_y_fragment, s->last_coded_y_fragment, s->first_coded_c_fragment, s->last_coded_c_fragment); }
false
FFmpeg
892fc83e88a20f9543c6c5be3626712be7a2e6f2
static void unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb) { int bit = 0; int current_superblock = 0; int current_run = 0; int decode_fully_flags = 0; int decode_partial_blocks = 0; int i, j; int current_fragment; debug_vp3(" vp3: unpacking superblock coding\n"); if (s->keyframe) { debug_vp3(" keyframe-- all superblocks are fully coded\n"); memset(s->superblock_coding, SB_FULLY_CODED, s->superblock_count); } else { bit = get_bits(gb, 1); bit ^= 1; while (current_superblock < s->superblock_count) { if (current_run == 0) { bit ^= 1; current_run = get_superblock_run_length(gb); debug_block_coding(" setting superblocks %d..%d to %s\n", current_superblock, current_superblock + current_run - 1, (bit) ? "partially coded" : "not coded"); if (bit == 0) decode_fully_flags = 1; } else { decode_partial_blocks = 1; } s->superblock_coding[current_superblock++] = (bit) ? SB_PARTIALLY_CODED : SB_NOT_CODED; current_run--; } if (decode_fully_flags) { current_superblock = 0; current_run = 0; bit = get_bits(gb, 1); bit ^= 1; while (current_superblock < s->superblock_count) { if (s->superblock_coding[current_superblock] == SB_NOT_CODED) { if (current_run == 0) { bit ^= 1; current_run = get_superblock_run_length(gb); } debug_block_coding(" setting superblock %d to %s\n", current_superblock, (bit) ? "fully coded" : "not coded"); s->superblock_coding[current_superblock] = (bit) ? SB_FULLY_CODED : SB_NOT_CODED; current_run--; } current_superblock++; } } if (decode_partial_blocks) { current_run = 0; bit = get_bits(gb, 1); bit ^= 1; } } s->coded_fragment_list_index = 0; s->first_coded_y_fragment = s->first_coded_c_fragment = 0; s->last_coded_y_fragment = s->last_coded_c_fragment = -1; memset(s->macroblock_coded, 0, s->macroblock_count); for (i = 0; i < s->superblock_count; i++) { for (j = 0; j < 16; j++) { current_fragment = s->superblock_fragments[i * 16 + j]; if (current_fragment != -1) { if (s->superblock_coding[i] == SB_NOT_CODED) { s->all_fragments[current_fragment].coding_method = MODE_COPY; } else if (s->superblock_coding[i] == SB_PARTIALLY_CODED) { if (current_run == 0) { bit ^= 1; current_run = get_fragment_run_length(gb); } if (bit) { s->all_fragments[current_fragment].coding_method = MODE_INTER_NO_MV; s->coded_fragment_list[s->coded_fragment_list_index] = current_fragment; if ((current_fragment >= s->u_fragment_start) && (s->last_coded_y_fragment == -1)) { s->first_coded_c_fragment = s->coded_fragment_list_index; s->last_coded_y_fragment = s->first_coded_c_fragment - 1; } s->coded_fragment_list_index++; s->macroblock_coded[s->all_fragments[current_fragment].macroblock] = 1; debug_block_coding(" superblock %d is partially coded, fragment %d is coded\n", i, current_fragment); } else { s->all_fragments[current_fragment].coding_method = MODE_COPY; debug_block_coding(" superblock %d is partially coded, fragment %d is not coded\n", i, current_fragment); } current_run--; } else { s->all_fragments[current_fragment].coding_method = MODE_INTER_NO_MV; s->coded_fragment_list[s->coded_fragment_list_index] = current_fragment; if ((current_fragment >= s->u_fragment_start) && (s->last_coded_y_fragment == -1)) { s->first_coded_c_fragment = s->coded_fragment_list_index; s->last_coded_y_fragment = s->first_coded_c_fragment - 1; } s->coded_fragment_list_index++; s->macroblock_coded[s->all_fragments[current_fragment].macroblock] = 1; debug_block_coding(" superblock %d is fully coded, fragment %d is coded\n", i, current_fragment); } } } } if (s->first_coded_c_fragment == 0) s->last_coded_y_fragment = s->coded_fragment_list_index - 1; else s->last_coded_c_fragment = s->coded_fragment_list_index - 1; debug_block_coding(" %d total coded fragments, y: %d -> %d, c: %d -> %d\n", s->coded_fragment_list_index, s->first_coded_y_fragment, s->last_coded_y_fragment, s->first_coded_c_fragment, s->last_coded_c_fragment); }
{ "code": [], "line_no": [] }
static void FUNC_0(Vp3DecodeContext *VAR_0, GetBitContext *VAR_1) { int VAR_2 = 0; int VAR_3 = 0; int VAR_4 = 0; int VAR_5 = 0; int VAR_6 = 0; int VAR_7, VAR_8; int VAR_9; debug_vp3(" vp3: unpacking superblock coding\n"); if (VAR_0->keyframe) { debug_vp3(" keyframe-- all superblocks are fully coded\n"); memset(VAR_0->superblock_coding, SB_FULLY_CODED, VAR_0->superblock_count); } else { VAR_2 = get_bits(VAR_1, 1); VAR_2 ^= 1; while (VAR_3 < VAR_0->superblock_count) { if (VAR_4 == 0) { VAR_2 ^= 1; VAR_4 = get_superblock_run_length(VAR_1); debug_block_coding(" setting superblocks %d..%d to %VAR_0\n", VAR_3, VAR_3 + VAR_4 - 1, (VAR_2) ? "partially coded" : "not coded"); if (VAR_2 == 0) VAR_5 = 1; } else { VAR_6 = 1; } VAR_0->superblock_coding[VAR_3++] = (VAR_2) ? SB_PARTIALLY_CODED : SB_NOT_CODED; VAR_4--; } if (VAR_5) { VAR_3 = 0; VAR_4 = 0; VAR_2 = get_bits(VAR_1, 1); VAR_2 ^= 1; while (VAR_3 < VAR_0->superblock_count) { if (VAR_0->superblock_coding[VAR_3] == SB_NOT_CODED) { if (VAR_4 == 0) { VAR_2 ^= 1; VAR_4 = get_superblock_run_length(VAR_1); } debug_block_coding(" setting superblock %d to %VAR_0\n", VAR_3, (VAR_2) ? "fully coded" : "not coded"); VAR_0->superblock_coding[VAR_3] = (VAR_2) ? SB_FULLY_CODED : SB_NOT_CODED; VAR_4--; } VAR_3++; } } if (VAR_6) { VAR_4 = 0; VAR_2 = get_bits(VAR_1, 1); VAR_2 ^= 1; } } VAR_0->coded_fragment_list_index = 0; VAR_0->first_coded_y_fragment = VAR_0->first_coded_c_fragment = 0; VAR_0->last_coded_y_fragment = VAR_0->last_coded_c_fragment = -1; memset(VAR_0->macroblock_coded, 0, VAR_0->macroblock_count); for (VAR_7 = 0; VAR_7 < VAR_0->superblock_count; VAR_7++) { for (VAR_8 = 0; VAR_8 < 16; VAR_8++) { VAR_9 = VAR_0->superblock_fragments[VAR_7 * 16 + VAR_8]; if (VAR_9 != -1) { if (VAR_0->superblock_coding[VAR_7] == SB_NOT_CODED) { VAR_0->all_fragments[VAR_9].coding_method = MODE_COPY; } else if (VAR_0->superblock_coding[VAR_7] == SB_PARTIALLY_CODED) { if (VAR_4 == 0) { VAR_2 ^= 1; VAR_4 = get_fragment_run_length(VAR_1); } if (VAR_2) { VAR_0->all_fragments[VAR_9].coding_method = MODE_INTER_NO_MV; VAR_0->coded_fragment_list[VAR_0->coded_fragment_list_index] = VAR_9; if ((VAR_9 >= VAR_0->u_fragment_start) && (VAR_0->last_coded_y_fragment == -1)) { VAR_0->first_coded_c_fragment = VAR_0->coded_fragment_list_index; VAR_0->last_coded_y_fragment = VAR_0->first_coded_c_fragment - 1; } VAR_0->coded_fragment_list_index++; VAR_0->macroblock_coded[VAR_0->all_fragments[VAR_9].macroblock] = 1; debug_block_coding(" superblock %d is partially coded, fragment %d is coded\n", VAR_7, VAR_9); } else { VAR_0->all_fragments[VAR_9].coding_method = MODE_COPY; debug_block_coding(" superblock %d is partially coded, fragment %d is not coded\n", VAR_7, VAR_9); } VAR_4--; } else { VAR_0->all_fragments[VAR_9].coding_method = MODE_INTER_NO_MV; VAR_0->coded_fragment_list[VAR_0->coded_fragment_list_index] = VAR_9; if ((VAR_9 >= VAR_0->u_fragment_start) && (VAR_0->last_coded_y_fragment == -1)) { VAR_0->first_coded_c_fragment = VAR_0->coded_fragment_list_index; VAR_0->last_coded_y_fragment = VAR_0->first_coded_c_fragment - 1; } VAR_0->coded_fragment_list_index++; VAR_0->macroblock_coded[VAR_0->all_fragments[VAR_9].macroblock] = 1; debug_block_coding(" superblock %d is fully coded, fragment %d is coded\n", VAR_7, VAR_9); } } } } if (VAR_0->first_coded_c_fragment == 0) VAR_0->last_coded_y_fragment = VAR_0->coded_fragment_list_index - 1; else VAR_0->last_coded_c_fragment = VAR_0->coded_fragment_list_index - 1; debug_block_coding(" %d total coded fragments, y: %d -> %d, c: %d -> %d\n", VAR_0->coded_fragment_list_index, VAR_0->first_coded_y_fragment, VAR_0->last_coded_y_fragment, VAR_0->first_coded_c_fragment, VAR_0->last_coded_c_fragment); }
[ "static void FUNC_0(Vp3DecodeContext *VAR_0, GetBitContext *VAR_1)\n{", "int VAR_2 = 0;", "int VAR_3 = 0;", "int VAR_4 = 0;", "int VAR_5 = 0;", "int VAR_6 = 0;", "int VAR_7, VAR_8;", "int VAR_9;", "debug_vp3(\" vp3: unpacking superblock coding\\n\");", "if (VAR_0->keyframe) {", "debug_vp3(\" keyframe-- all superblocks are fully coded\\n\");", "memset(VAR_0->superblock_coding, SB_FULLY_CODED, VAR_0->superblock_count);", "} else {", "VAR_2 = get_bits(VAR_1, 1);", "VAR_2 ^= 1;", "while (VAR_3 < VAR_0->superblock_count) {", "if (VAR_4 == 0) {", "VAR_2 ^= 1;", "VAR_4 = get_superblock_run_length(VAR_1);", "debug_block_coding(\" setting superblocks %d..%d to %VAR_0\\n\",\nVAR_3,\nVAR_3 + VAR_4 - 1,\n(VAR_2) ? \"partially coded\" : \"not coded\");", "if (VAR_2 == 0)\nVAR_5 = 1;", "} else {", "VAR_6 = 1;", "}", "VAR_0->superblock_coding[VAR_3++] =\n(VAR_2) ? SB_PARTIALLY_CODED : SB_NOT_CODED;", "VAR_4--;", "}", "if (VAR_5) {", "VAR_3 = 0;", "VAR_4 = 0;", "VAR_2 = get_bits(VAR_1, 1);", "VAR_2 ^= 1;", "while (VAR_3 < VAR_0->superblock_count) {", "if (VAR_0->superblock_coding[VAR_3] == SB_NOT_CODED) {", "if (VAR_4 == 0) {", "VAR_2 ^= 1;", "VAR_4 = get_superblock_run_length(VAR_1);", "}", "debug_block_coding(\" setting superblock %d to %VAR_0\\n\",\nVAR_3,\n(VAR_2) ? \"fully coded\" : \"not coded\");", "VAR_0->superblock_coding[VAR_3] =\n(VAR_2) ? SB_FULLY_CODED : SB_NOT_CODED;", "VAR_4--;", "}", "VAR_3++;", "}", "}", "if (VAR_6) {", "VAR_4 = 0;", "VAR_2 = get_bits(VAR_1, 1);", "VAR_2 ^= 1;", "}", "}", "VAR_0->coded_fragment_list_index = 0;", "VAR_0->first_coded_y_fragment = VAR_0->first_coded_c_fragment = 0;", "VAR_0->last_coded_y_fragment = VAR_0->last_coded_c_fragment = -1;", "memset(VAR_0->macroblock_coded, 0, VAR_0->macroblock_count);", "for (VAR_7 = 0; VAR_7 < VAR_0->superblock_count; VAR_7++) {", "for (VAR_8 = 0; VAR_8 < 16; VAR_8++) {", "VAR_9 = VAR_0->superblock_fragments[VAR_7 * 16 + VAR_8];", "if (VAR_9 != -1) {", "if (VAR_0->superblock_coding[VAR_7] == SB_NOT_CODED) {", "VAR_0->all_fragments[VAR_9].coding_method =\nMODE_COPY;", "} else if (VAR_0->superblock_coding[VAR_7] == SB_PARTIALLY_CODED) {", "if (VAR_4 == 0) {", "VAR_2 ^= 1;", "VAR_4 = get_fragment_run_length(VAR_1);", "}", "if (VAR_2) {", "VAR_0->all_fragments[VAR_9].coding_method =\nMODE_INTER_NO_MV;", "VAR_0->coded_fragment_list[VAR_0->coded_fragment_list_index] =\nVAR_9;", "if ((VAR_9 >= VAR_0->u_fragment_start) &&\n(VAR_0->last_coded_y_fragment == -1)) {", "VAR_0->first_coded_c_fragment = VAR_0->coded_fragment_list_index;", "VAR_0->last_coded_y_fragment = VAR_0->first_coded_c_fragment - 1;", "}", "VAR_0->coded_fragment_list_index++;", "VAR_0->macroblock_coded[VAR_0->all_fragments[VAR_9].macroblock] = 1;", "debug_block_coding(\" superblock %d is partially coded, fragment %d is coded\\n\",\nVAR_7, VAR_9);", "} else {", "VAR_0->all_fragments[VAR_9].coding_method =\nMODE_COPY;", "debug_block_coding(\" superblock %d is partially coded, fragment %d is not coded\\n\",\nVAR_7, VAR_9);", "}", "VAR_4--;", "} else {", "VAR_0->all_fragments[VAR_9].coding_method =\nMODE_INTER_NO_MV;", "VAR_0->coded_fragment_list[VAR_0->coded_fragment_list_index] =\nVAR_9;", "if ((VAR_9 >= VAR_0->u_fragment_start) &&\n(VAR_0->last_coded_y_fragment == -1)) {", "VAR_0->first_coded_c_fragment = VAR_0->coded_fragment_list_index;", "VAR_0->last_coded_y_fragment = VAR_0->first_coded_c_fragment - 1;", "}", "VAR_0->coded_fragment_list_index++;", "VAR_0->macroblock_coded[VAR_0->all_fragments[VAR_9].macroblock] = 1;", "debug_block_coding(\" superblock %d is fully coded, fragment %d is coded\\n\",\nVAR_7, VAR_9);", "}", "}", "}", "}", "if (VAR_0->first_coded_c_fragment == 0)\nVAR_0->last_coded_y_fragment = VAR_0->coded_fragment_list_index - 1;", "else\nVAR_0->last_coded_c_fragment = VAR_0->coded_fragment_list_index - 1;", "debug_block_coding(\" %d total coded fragments, y: %d -> %d, c: %d -> %d\\n\",\nVAR_0->coded_fragment_list_index,\nVAR_0->first_coded_y_fragment,\nVAR_0->last_coded_y_fragment,\nVAR_0->first_coded_c_fragment,\nVAR_0->last_coded_c_fragment);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 23 ], [ 27 ], [ 31 ], [ 33 ], [ 37 ], [ 43 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59, 61, 63, 65 ], [ 73, 75 ], [ 77 ], [ 85 ], [ 89 ], [ 91, 93 ], [ 95 ], [ 97 ], [ 105 ], [ 109 ], [ 111 ], [ 113 ], [ 119 ], [ 121 ], [ 127 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 141, 143, 145 ], [ 147, 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 167 ], [ 171 ], [ 173 ], [ 179 ], [ 181 ], [ 183 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 205 ], [ 211 ], [ 213 ], [ 215 ], [ 221, 223 ], [ 227 ], [ 235 ], [ 237 ], [ 239 ], [ 241 ], [ 245 ], [ 249, 251 ], [ 253, 255 ], [ 257, 259 ], [ 261 ], [ 263 ], [ 265 ], [ 267 ], [ 269 ], [ 271, 273 ], [ 275 ], [ 279, 281 ], [ 283, 285 ], [ 287 ], [ 291 ], [ 295 ], [ 303, 305 ], [ 307, 309 ], [ 311, 313 ], [ 315 ], [ 317 ], [ 319 ], [ 321 ], [ 323 ], [ 325, 327 ], [ 329 ], [ 331 ], [ 333 ], [ 335 ], [ 339, 343 ], [ 345, 347 ], [ 349, 351, 353, 355, 357, 359 ], [ 361 ] ]
11,445
static int svq1_decode_delta_block(MpegEncContext *s, GetBitContext *bitbuf, uint8_t *current, uint8_t *previous, int pitch, svq1_pmv *motion, int x, int y) { uint32_t block_type; int result = 0; /* get block type */ block_type = get_vlc2(bitbuf, svq1_block_type.table, 2, 2); /* reset motion vectors */ if (block_type == SVQ1_BLOCK_SKIP || block_type == SVQ1_BLOCK_INTRA) { motion[0].x = motion[0].y = motion[x / 8 + 2].x = motion[x / 8 + 2].y = motion[x / 8 + 3].x = motion[x / 8 + 3].y = 0; } switch (block_type) { case SVQ1_BLOCK_SKIP: svq1_skip_block(current, previous, pitch, x, y); break; case SVQ1_BLOCK_INTER: result = svq1_motion_inter_block(s, bitbuf, current, previous, pitch, motion, x, y); if (result != 0) { av_dlog(s->avctx, "Error in svq1_motion_inter_block %i\n", result); break; } result = svq1_decode_block_non_intra(bitbuf, current, pitch); break; case SVQ1_BLOCK_INTER_4V: result = svq1_motion_inter_4v_block(s, bitbuf, current, previous, pitch, motion, x, y); if (result != 0) { av_dlog(s->avctx, "Error in svq1_motion_inter_4v_block %i\n", result); break; } result = svq1_decode_block_non_intra(bitbuf, current, pitch); break; case SVQ1_BLOCK_INTRA: result = svq1_decode_block_intra(bitbuf, current, pitch); break; } return result; }
false
FFmpeg
7b9fc769e40a7709fa59a54e2a810f76364eee4b
static int svq1_decode_delta_block(MpegEncContext *s, GetBitContext *bitbuf, uint8_t *current, uint8_t *previous, int pitch, svq1_pmv *motion, int x, int y) { uint32_t block_type; int result = 0; block_type = get_vlc2(bitbuf, svq1_block_type.table, 2, 2); if (block_type == SVQ1_BLOCK_SKIP || block_type == SVQ1_BLOCK_INTRA) { motion[0].x = motion[0].y = motion[x / 8 + 2].x = motion[x / 8 + 2].y = motion[x / 8 + 3].x = motion[x / 8 + 3].y = 0; } switch (block_type) { case SVQ1_BLOCK_SKIP: svq1_skip_block(current, previous, pitch, x, y); break; case SVQ1_BLOCK_INTER: result = svq1_motion_inter_block(s, bitbuf, current, previous, pitch, motion, x, y); if (result != 0) { av_dlog(s->avctx, "Error in svq1_motion_inter_block %i\n", result); break; } result = svq1_decode_block_non_intra(bitbuf, current, pitch); break; case SVQ1_BLOCK_INTER_4V: result = svq1_motion_inter_4v_block(s, bitbuf, current, previous, pitch, motion, x, y); if (result != 0) { av_dlog(s->avctx, "Error in svq1_motion_inter_4v_block %i\n", result); break; } result = svq1_decode_block_non_intra(bitbuf, current, pitch); break; case SVQ1_BLOCK_INTRA: result = svq1_decode_block_intra(bitbuf, current, pitch); break; } return result; }
{ "code": [], "line_no": [] }
static int FUNC_0(MpegEncContext *VAR_0, GetBitContext *VAR_1, uint8_t *VAR_2, uint8_t *VAR_3, int VAR_4, svq1_pmv *VAR_5, int VAR_6, int VAR_7) { uint32_t block_type; int VAR_8 = 0; block_type = get_vlc2(VAR_1, svq1_block_type.table, 2, 2); if (block_type == SVQ1_BLOCK_SKIP || block_type == SVQ1_BLOCK_INTRA) { VAR_5[0].VAR_6 = VAR_5[0].VAR_7 = VAR_5[VAR_6 / 8 + 2].VAR_6 = VAR_5[VAR_6 / 8 + 2].VAR_7 = VAR_5[VAR_6 / 8 + 3].VAR_6 = VAR_5[VAR_6 / 8 + 3].VAR_7 = 0; } switch (block_type) { case SVQ1_BLOCK_SKIP: svq1_skip_block(VAR_2, VAR_3, VAR_4, VAR_6, VAR_7); break; case SVQ1_BLOCK_INTER: VAR_8 = svq1_motion_inter_block(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7); if (VAR_8 != 0) { av_dlog(VAR_0->avctx, "Error in svq1_motion_inter_block %i\n", VAR_8); break; } VAR_8 = svq1_decode_block_non_intra(VAR_1, VAR_2, VAR_4); break; case SVQ1_BLOCK_INTER_4V: VAR_8 = svq1_motion_inter_4v_block(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7); if (VAR_8 != 0) { av_dlog(VAR_0->avctx, "Error in svq1_motion_inter_4v_block %i\n", VAR_8); break; } VAR_8 = svq1_decode_block_non_intra(VAR_1, VAR_2, VAR_4); break; case SVQ1_BLOCK_INTRA: VAR_8 = svq1_decode_block_intra(VAR_1, VAR_2, VAR_4); break; } return VAR_8; }
[ "static int FUNC_0(MpegEncContext *VAR_0, GetBitContext *VAR_1,\nuint8_t *VAR_2, uint8_t *VAR_3,\nint VAR_4, svq1_pmv *VAR_5, int VAR_6, int VAR_7)\n{", "uint32_t block_type;", "int VAR_8 = 0;", "block_type = get_vlc2(VAR_1, svq1_block_type.table, 2, 2);", "if (block_type == SVQ1_BLOCK_SKIP || block_type == SVQ1_BLOCK_INTRA) {", "VAR_5[0].VAR_6 =\nVAR_5[0].VAR_7 =\nVAR_5[VAR_6 / 8 + 2].VAR_6 =\nVAR_5[VAR_6 / 8 + 2].VAR_7 =\nVAR_5[VAR_6 / 8 + 3].VAR_6 =\nVAR_5[VAR_6 / 8 + 3].VAR_7 = 0;", "}", "switch (block_type) {", "case SVQ1_BLOCK_SKIP:\nsvq1_skip_block(VAR_2, VAR_3, VAR_4, VAR_6, VAR_7);", "break;", "case SVQ1_BLOCK_INTER:\nVAR_8 = svq1_motion_inter_block(VAR_0, VAR_1, VAR_2, VAR_3,\nVAR_4, VAR_5, VAR_6, VAR_7);", "if (VAR_8 != 0) {", "av_dlog(VAR_0->avctx, \"Error in svq1_motion_inter_block %i\\n\", VAR_8);", "break;", "}", "VAR_8 = svq1_decode_block_non_intra(VAR_1, VAR_2, VAR_4);", "break;", "case SVQ1_BLOCK_INTER_4V:\nVAR_8 = svq1_motion_inter_4v_block(VAR_0, VAR_1, VAR_2, VAR_3,\nVAR_4, VAR_5, VAR_6, VAR_7);", "if (VAR_8 != 0) {", "av_dlog(VAR_0->avctx,\n\"Error in svq1_motion_inter_4v_block %i\\n\", VAR_8);", "break;", "}", "VAR_8 = svq1_decode_block_non_intra(VAR_1, VAR_2, VAR_4);", "break;", "case SVQ1_BLOCK_INTRA:\nVAR_8 = svq1_decode_block_intra(VAR_1, VAR_2, VAR_4);", "break;", "}", "return VAR_8;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 17 ], [ 23 ], [ 25, 27, 29, 31, 33, 35 ], [ 37 ], [ 41 ], [ 43, 45 ], [ 47 ], [ 51, 53, 55 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 73, 75, 77 ], [ 81 ], [ 83, 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 97, 99 ], [ 101 ], [ 103 ], [ 107 ], [ 109 ] ]
11,447
int ff_h263_decode_mb(MpegEncContext *s, DCTELEM block[6][64]) { int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant; INT16 *mot_val; static INT8 quant_tab[4] = { -1, -2, 1, 2 }; s->error_status_table[s->mb_x + s->mb_y*s->mb_width]= 0; if(s->mb_x==0) PRINT_MB_TYPE("\n"); if (s->pict_type == P_TYPE || s->pict_type==S_TYPE) { if (get_bits1(&s->gb)) { /* skip mb */ s->mb_intra = 0; for(i=0;i<6;i++) s->block_last_index[i] = -1; s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_16X16; if(s->pict_type==S_TYPE && s->vol_sprite_usage==GMC_SPRITE){ PRINT_MB_TYPE("G"); s->mcsel=1; s->mv[0][0][0]= get_amv(s, 0); s->mv[0][0][1]= get_amv(s, 1); s->mb_skiped = 0; }else{ PRINT_MB_TYPE("S"); s->mcsel=0; s->mv[0][0][0] = 0; s->mv[0][0][1] = 0; s->mb_skiped = 1; } goto end; } cbpc = get_vlc2(&s->gb, inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2); //fprintf(stderr, "\tCBPC: %d", cbpc); if (cbpc < 0) return -1; if (cbpc > 20) cbpc+=3; else if (cbpc == 20) fprintf(stderr, "Stuffing !"); dquant = cbpc & 8; s->mb_intra = ((cbpc & 4) != 0); if (s->mb_intra) goto intra; if(s->pict_type==S_TYPE && s->vol_sprite_usage==GMC_SPRITE && (cbpc & 16) == 0) s->mcsel= get_bits1(&s->gb); else s->mcsel= 0; cbpy = get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1); cbp = (cbpc & 3) | ((cbpy ^ 0xf) << 2); if (dquant) { change_qscale(s, quant_tab[get_bits(&s->gb, 2)]); } if((!s->progressive_sequence) && (cbp || (s->workaround_bugs&FF_BUG_XVID_ILACE))) s->interlaced_dct= get_bits1(&s->gb); s->mv_dir = MV_DIR_FORWARD; if ((cbpc & 16) == 0) { if(s->mcsel){ PRINT_MB_TYPE("G"); /* 16x16 global motion prediction */ s->mv_type = MV_TYPE_16X16; mx= get_amv(s, 0); my= get_amv(s, 1); s->mv[0][0][0] = mx; s->mv[0][0][1] = my; }else if((!s->progressive_sequence) && get_bits1(&s->gb)){ PRINT_MB_TYPE("f"); /* 16x8 field motion prediction */ s->mv_type= MV_TYPE_FIELD; s->field_select[0][0]= get_bits1(&s->gb); s->field_select[0][1]= get_bits1(&s->gb); h263_pred_motion(s, 0, &pred_x, &pred_y); for(i=0; i<2; i++){ mx = h263_decode_motion(s, pred_x, s->f_code); if (mx >= 0xffff) return -1; my = h263_decode_motion(s, pred_y/2, s->f_code); if (my >= 0xffff) return -1; s->mv[0][i][0] = mx; s->mv[0][i][1] = my; } }else{ PRINT_MB_TYPE("P"); /* 16x16 motion prediction */ s->mv_type = MV_TYPE_16X16; h263_pred_motion(s, 0, &pred_x, &pred_y); if (s->umvplus_dec) mx = h263p_decode_umotion(s, pred_x); else mx = h263_decode_motion(s, pred_x, s->f_code); if (mx >= 0xffff) return -1; if (s->umvplus_dec) my = h263p_decode_umotion(s, pred_y); else my = h263_decode_motion(s, pred_y, s->f_code); if (my >= 0xffff) return -1; s->mv[0][0][0] = mx; s->mv[0][0][1] = my; if (s->umvplus_dec && (mx - pred_x) == 1 && (my - pred_y) == 1) skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */ } } else { PRINT_MB_TYPE("4"); s->mv_type = MV_TYPE_8X8; for(i=0;i<4;i++) { mot_val = h263_pred_motion(s, i, &pred_x, &pred_y); if (s->umvplus_dec) mx = h263p_decode_umotion(s, pred_x); else mx = h263_decode_motion(s, pred_x, s->f_code); if (mx >= 0xffff) return -1; if (s->umvplus_dec) my = h263p_decode_umotion(s, pred_y); else my = h263_decode_motion(s, pred_y, s->f_code); if (my >= 0xffff) return -1; s->mv[0][i][0] = mx; s->mv[0][i][1] = my; if (s->umvplus_dec && (mx - pred_x) == 1 && (my - pred_y) == 1) skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */ mot_val[0] = mx; mot_val[1] = my; } } } else if(s->pict_type==B_TYPE) { int modb1; // first bit of modb int modb2; // second bit of modb int mb_type; int xy; s->mb_intra = 0; //B-frames never contain intra blocks s->mcsel=0; // ... true gmc blocks if(s->mb_x==0){ for(i=0; i<2; i++){ s->last_mv[i][0][0]= s->last_mv[i][0][1]= s->last_mv[i][1][0]= s->last_mv[i][1][1]= 0; } } /* if we skipped it in the future P Frame than skip it now too */ s->mb_skiped= s->next_picture.mbskip_table[s->mb_y * s->mb_width + s->mb_x]; // Note, skiptab=0 if last was GMC if(s->mb_skiped){ /* skip mb */ for(i=0;i<6;i++) s->block_last_index[i] = -1; s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_16X16; s->mv[0][0][0] = 0; s->mv[0][0][1] = 0; s->mv[1][0][0] = 0; s->mv[1][0][1] = 0; PRINT_MB_TYPE("s"); goto end; } modb1= get_bits1(&s->gb); if(modb1){ mb_type=4; //like MB_TYPE_B_DIRECT but no vectors coded cbp=0; }else{ int field_mv; modb2= get_bits1(&s->gb); mb_type= get_vlc2(&s->gb, mb_type_b_vlc.table, MB_TYPE_B_VLC_BITS, 1); if(modb2) cbp= 0; else cbp= get_bits(&s->gb, 6); if (mb_type!=MB_TYPE_B_DIRECT && cbp) { if(get_bits1(&s->gb)){ change_qscale(s, get_bits1(&s->gb)*4 - 2); } } field_mv=0; if(!s->progressive_sequence){ if(cbp) s->interlaced_dct= get_bits1(&s->gb); if(mb_type!=MB_TYPE_B_DIRECT && get_bits1(&s->gb)){ field_mv=1; if(mb_type!=MB_TYPE_B_BACKW){ s->field_select[0][0]= get_bits1(&s->gb); s->field_select[0][1]= get_bits1(&s->gb); } if(mb_type!=MB_TYPE_B_FORW){ s->field_select[1][0]= get_bits1(&s->gb); s->field_select[1][1]= get_bits1(&s->gb); } } } s->mv_dir = 0; if(mb_type!=MB_TYPE_B_DIRECT && !field_mv){ s->mv_type= MV_TYPE_16X16; if(mb_type!=MB_TYPE_B_BACKW){ s->mv_dir = MV_DIR_FORWARD; mx = h263_decode_motion(s, s->last_mv[0][0][0], s->f_code); my = h263_decode_motion(s, s->last_mv[0][0][1], s->f_code); s->last_mv[0][1][0]= s->last_mv[0][0][0]= s->mv[0][0][0] = mx; s->last_mv[0][1][1]= s->last_mv[0][0][1]= s->mv[0][0][1] = my; } if(mb_type!=MB_TYPE_B_FORW){ s->mv_dir |= MV_DIR_BACKWARD; mx = h263_decode_motion(s, s->last_mv[1][0][0], s->b_code); my = h263_decode_motion(s, s->last_mv[1][0][1], s->b_code); s->last_mv[1][1][0]= s->last_mv[1][0][0]= s->mv[1][0][0] = mx; s->last_mv[1][1][1]= s->last_mv[1][0][1]= s->mv[1][0][1] = my; } if(mb_type!=MB_TYPE_B_DIRECT) PRINT_MB_TYPE(mb_type==MB_TYPE_B_FORW ? "F" : (mb_type==MB_TYPE_B_BACKW ? "B" : "T")); }else if(mb_type!=MB_TYPE_B_DIRECT){ s->mv_type= MV_TYPE_FIELD; if(mb_type!=MB_TYPE_B_BACKW){ s->mv_dir = MV_DIR_FORWARD; for(i=0; i<2; i++){ mx = h263_decode_motion(s, s->last_mv[0][i][0] , s->f_code); my = h263_decode_motion(s, s->last_mv[0][i][1]/2, s->f_code); s->last_mv[0][i][0]= s->mv[0][i][0] = mx; s->last_mv[0][i][1]= (s->mv[0][i][1] = my)*2; } } if(mb_type!=MB_TYPE_B_FORW){ s->mv_dir |= MV_DIR_BACKWARD; for(i=0; i<2; i++){ mx = h263_decode_motion(s, s->last_mv[1][i][0] , s->b_code); my = h263_decode_motion(s, s->last_mv[1][i][1]/2, s->b_code); s->last_mv[1][i][0]= s->mv[1][i][0] = mx; s->last_mv[1][i][1]= (s->mv[1][i][1] = my)*2; } } if(mb_type!=MB_TYPE_B_DIRECT) PRINT_MB_TYPE(mb_type==MB_TYPE_B_FORW ? "f" : (mb_type==MB_TYPE_B_BACKW ? "b" : "t")); } } if(mb_type==4 || mb_type==MB_TYPE_B_DIRECT){ if(mb_type==4) mx=my=0; else{ mx = h263_decode_motion(s, 0, 1); my = h263_decode_motion(s, 0, 1); } s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT; ff_mpeg4_set_direct_mv(s, mx, my); } if(mb_type<0 || mb_type>4){ printf("illegal MB_type\n"); return -1; } } else { /* I-Frame */ cbpc = get_vlc2(&s->gb, intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 1); if (cbpc < 0) return -1; dquant = cbpc & 4; s->mb_intra = 1; intra: s->ac_pred = 0; if (s->h263_pred || s->h263_aic) { s->ac_pred = get_bits1(&s->gb); if (s->ac_pred && s->h263_aic) s->h263_aic_dir = get_bits1(&s->gb); } PRINT_MB_TYPE(s->ac_pred ? "A" : "I"); cbpy = get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1); if(cbpy<0) return -1; cbp = (cbpc & 3) | (cbpy << 2); if (dquant) { change_qscale(s, quant_tab[get_bits(&s->gb, 2)]); } if(!s->progressive_sequence) s->interlaced_dct= get_bits1(&s->gb); /* decode each block */ if (s->h263_pred) { for (i = 0; i < 6; i++) { if (mpeg4_decode_block(s, block[i], i, cbp&32, 1) < 0) return -1; cbp+=cbp; } } else { for (i = 0; i < 6; i++) { if (h263_decode_block(s, block[i], i, cbp&32) < 0) return -1; cbp+=cbp; } } goto end; } /* decode each block */ if (s->h263_pred) { for (i = 0; i < 6; i++) { if (mpeg4_decode_block(s, block[i], i, cbp&32, 0) < 0) return -1; cbp+=cbp; } } else { for (i = 0; i < 6; i++) { if (h263_decode_block(s, block[i], i, cbp&32) < 0) return -1; cbp+=cbp; } } end: /* per-MB end of slice check */ if(s->codec_id==CODEC_ID_MPEG4){ if(mpeg4_is_resync(s)){ if(s->pict_type==B_TYPE && s->next_picture.mbskip_table[s->mb_y * s->mb_width + s->mb_x+1]) return SLICE_OK; return SLICE_END; } }else{ int v= show_bits(&s->gb, 16); if(get_bits_count(&s->gb) + 16 > s->gb.size*8){ v>>= get_bits_count(&s->gb) + 16 - s->gb.size*8; } if(v==0) return SLICE_END; } return SLICE_OK; }
false
FFmpeg
68f593b48433842f3407586679fe07f3e5199ab9
int ff_h263_decode_mb(MpegEncContext *s, DCTELEM block[6][64]) { int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant; INT16 *mot_val; static INT8 quant_tab[4] = { -1, -2, 1, 2 }; s->error_status_table[s->mb_x + s->mb_y*s->mb_width]= 0; if(s->mb_x==0) PRINT_MB_TYPE("\n"); if (s->pict_type == P_TYPE || s->pict_type==S_TYPE) { if (get_bits1(&s->gb)) { s->mb_intra = 0; for(i=0;i<6;i++) s->block_last_index[i] = -1; s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_16X16; if(s->pict_type==S_TYPE && s->vol_sprite_usage==GMC_SPRITE){ PRINT_MB_TYPE("G"); s->mcsel=1; s->mv[0][0][0]= get_amv(s, 0); s->mv[0][0][1]= get_amv(s, 1); s->mb_skiped = 0; }else{ PRINT_MB_TYPE("S"); s->mcsel=0; s->mv[0][0][0] = 0; s->mv[0][0][1] = 0; s->mb_skiped = 1; } goto end; } cbpc = get_vlc2(&s->gb, inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2); if (cbpc < 0) return -1; if (cbpc > 20) cbpc+=3; else if (cbpc == 20) fprintf(stderr, "Stuffing !"); dquant = cbpc & 8; s->mb_intra = ((cbpc & 4) != 0); if (s->mb_intra) goto intra; if(s->pict_type==S_TYPE && s->vol_sprite_usage==GMC_SPRITE && (cbpc & 16) == 0) s->mcsel= get_bits1(&s->gb); else s->mcsel= 0; cbpy = get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1); cbp = (cbpc & 3) | ((cbpy ^ 0xf) << 2); if (dquant) { change_qscale(s, quant_tab[get_bits(&s->gb, 2)]); } if((!s->progressive_sequence) && (cbp || (s->workaround_bugs&FF_BUG_XVID_ILACE))) s->interlaced_dct= get_bits1(&s->gb); s->mv_dir = MV_DIR_FORWARD; if ((cbpc & 16) == 0) { if(s->mcsel){ PRINT_MB_TYPE("G"); s->mv_type = MV_TYPE_16X16; mx= get_amv(s, 0); my= get_amv(s, 1); s->mv[0][0][0] = mx; s->mv[0][0][1] = my; }else if((!s->progressive_sequence) && get_bits1(&s->gb)){ PRINT_MB_TYPE("f"); s->mv_type= MV_TYPE_FIELD; s->field_select[0][0]= get_bits1(&s->gb); s->field_select[0][1]= get_bits1(&s->gb); h263_pred_motion(s, 0, &pred_x, &pred_y); for(i=0; i<2; i++){ mx = h263_decode_motion(s, pred_x, s->f_code); if (mx >= 0xffff) return -1; my = h263_decode_motion(s, pred_y/2, s->f_code); if (my >= 0xffff) return -1; s->mv[0][i][0] = mx; s->mv[0][i][1] = my; } }else{ PRINT_MB_TYPE("P"); s->mv_type = MV_TYPE_16X16; h263_pred_motion(s, 0, &pred_x, &pred_y); if (s->umvplus_dec) mx = h263p_decode_umotion(s, pred_x); else mx = h263_decode_motion(s, pred_x, s->f_code); if (mx >= 0xffff) return -1; if (s->umvplus_dec) my = h263p_decode_umotion(s, pred_y); else my = h263_decode_motion(s, pred_y, s->f_code); if (my >= 0xffff) return -1; s->mv[0][0][0] = mx; s->mv[0][0][1] = my; if (s->umvplus_dec && (mx - pred_x) == 1 && (my - pred_y) == 1) skip_bits1(&s->gb); } } else { PRINT_MB_TYPE("4"); s->mv_type = MV_TYPE_8X8; for(i=0;i<4;i++) { mot_val = h263_pred_motion(s, i, &pred_x, &pred_y); if (s->umvplus_dec) mx = h263p_decode_umotion(s, pred_x); else mx = h263_decode_motion(s, pred_x, s->f_code); if (mx >= 0xffff) return -1; if (s->umvplus_dec) my = h263p_decode_umotion(s, pred_y); else my = h263_decode_motion(s, pred_y, s->f_code); if (my >= 0xffff) return -1; s->mv[0][i][0] = mx; s->mv[0][i][1] = my; if (s->umvplus_dec && (mx - pred_x) == 1 && (my - pred_y) == 1) skip_bits1(&s->gb); mot_val[0] = mx; mot_val[1] = my; } } } else if(s->pict_type==B_TYPE) { int modb1; int modb2; int mb_type; int xy; s->mb_intra = 0; s->mcsel=0; if(s->mb_x==0){ for(i=0; i<2; i++){ s->last_mv[i][0][0]= s->last_mv[i][0][1]= s->last_mv[i][1][0]= s->last_mv[i][1][1]= 0; } } s->mb_skiped= s->next_picture.mbskip_table[s->mb_y * s->mb_width + s->mb_x]; if(s->mb_skiped){ for(i=0;i<6;i++) s->block_last_index[i] = -1; s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_16X16; s->mv[0][0][0] = 0; s->mv[0][0][1] = 0; s->mv[1][0][0] = 0; s->mv[1][0][1] = 0; PRINT_MB_TYPE("s"); goto end; } modb1= get_bits1(&s->gb); if(modb1){ mb_type=4; cbp=0; }else{ int field_mv; modb2= get_bits1(&s->gb); mb_type= get_vlc2(&s->gb, mb_type_b_vlc.table, MB_TYPE_B_VLC_BITS, 1); if(modb2) cbp= 0; else cbp= get_bits(&s->gb, 6); if (mb_type!=MB_TYPE_B_DIRECT && cbp) { if(get_bits1(&s->gb)){ change_qscale(s, get_bits1(&s->gb)*4 - 2); } } field_mv=0; if(!s->progressive_sequence){ if(cbp) s->interlaced_dct= get_bits1(&s->gb); if(mb_type!=MB_TYPE_B_DIRECT && get_bits1(&s->gb)){ field_mv=1; if(mb_type!=MB_TYPE_B_BACKW){ s->field_select[0][0]= get_bits1(&s->gb); s->field_select[0][1]= get_bits1(&s->gb); } if(mb_type!=MB_TYPE_B_FORW){ s->field_select[1][0]= get_bits1(&s->gb); s->field_select[1][1]= get_bits1(&s->gb); } } } s->mv_dir = 0; if(mb_type!=MB_TYPE_B_DIRECT && !field_mv){ s->mv_type= MV_TYPE_16X16; if(mb_type!=MB_TYPE_B_BACKW){ s->mv_dir = MV_DIR_FORWARD; mx = h263_decode_motion(s, s->last_mv[0][0][0], s->f_code); my = h263_decode_motion(s, s->last_mv[0][0][1], s->f_code); s->last_mv[0][1][0]= s->last_mv[0][0][0]= s->mv[0][0][0] = mx; s->last_mv[0][1][1]= s->last_mv[0][0][1]= s->mv[0][0][1] = my; } if(mb_type!=MB_TYPE_B_FORW){ s->mv_dir |= MV_DIR_BACKWARD; mx = h263_decode_motion(s, s->last_mv[1][0][0], s->b_code); my = h263_decode_motion(s, s->last_mv[1][0][1], s->b_code); s->last_mv[1][1][0]= s->last_mv[1][0][0]= s->mv[1][0][0] = mx; s->last_mv[1][1][1]= s->last_mv[1][0][1]= s->mv[1][0][1] = my; } if(mb_type!=MB_TYPE_B_DIRECT) PRINT_MB_TYPE(mb_type==MB_TYPE_B_FORW ? "F" : (mb_type==MB_TYPE_B_BACKW ? "B" : "T")); }else if(mb_type!=MB_TYPE_B_DIRECT){ s->mv_type= MV_TYPE_FIELD; if(mb_type!=MB_TYPE_B_BACKW){ s->mv_dir = MV_DIR_FORWARD; for(i=0; i<2; i++){ mx = h263_decode_motion(s, s->last_mv[0][i][0] , s->f_code); my = h263_decode_motion(s, s->last_mv[0][i][1]/2, s->f_code); s->last_mv[0][i][0]= s->mv[0][i][0] = mx; s->last_mv[0][i][1]= (s->mv[0][i][1] = my)*2; } } if(mb_type!=MB_TYPE_B_FORW){ s->mv_dir |= MV_DIR_BACKWARD; for(i=0; i<2; i++){ mx = h263_decode_motion(s, s->last_mv[1][i][0] , s->b_code); my = h263_decode_motion(s, s->last_mv[1][i][1]/2, s->b_code); s->last_mv[1][i][0]= s->mv[1][i][0] = mx; s->last_mv[1][i][1]= (s->mv[1][i][1] = my)*2; } } if(mb_type!=MB_TYPE_B_DIRECT) PRINT_MB_TYPE(mb_type==MB_TYPE_B_FORW ? "f" : (mb_type==MB_TYPE_B_BACKW ? "b" : "t")); } } if(mb_type==4 || mb_type==MB_TYPE_B_DIRECT){ if(mb_type==4) mx=my=0; else{ mx = h263_decode_motion(s, 0, 1); my = h263_decode_motion(s, 0, 1); } s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT; ff_mpeg4_set_direct_mv(s, mx, my); } if(mb_type<0 || mb_type>4){ printf("illegal MB_type\n"); return -1; } } else { cbpc = get_vlc2(&s->gb, intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 1); if (cbpc < 0) return -1; dquant = cbpc & 4; s->mb_intra = 1; intra: s->ac_pred = 0; if (s->h263_pred || s->h263_aic) { s->ac_pred = get_bits1(&s->gb); if (s->ac_pred && s->h263_aic) s->h263_aic_dir = get_bits1(&s->gb); } PRINT_MB_TYPE(s->ac_pred ? "A" : "I"); cbpy = get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1); if(cbpy<0) return -1; cbp = (cbpc & 3) | (cbpy << 2); if (dquant) { change_qscale(s, quant_tab[get_bits(&s->gb, 2)]); } if(!s->progressive_sequence) s->interlaced_dct= get_bits1(&s->gb); if (s->h263_pred) { for (i = 0; i < 6; i++) { if (mpeg4_decode_block(s, block[i], i, cbp&32, 1) < 0) return -1; cbp+=cbp; } } else { for (i = 0; i < 6; i++) { if (h263_decode_block(s, block[i], i, cbp&32) < 0) return -1; cbp+=cbp; } } goto end; } if (s->h263_pred) { for (i = 0; i < 6; i++) { if (mpeg4_decode_block(s, block[i], i, cbp&32, 0) < 0) return -1; cbp+=cbp; } } else { for (i = 0; i < 6; i++) { if (h263_decode_block(s, block[i], i, cbp&32) < 0) return -1; cbp+=cbp; } } end: if(s->codec_id==CODEC_ID_MPEG4){ if(mpeg4_is_resync(s)){ if(s->pict_type==B_TYPE && s->next_picture.mbskip_table[s->mb_y * s->mb_width + s->mb_x+1]) return SLICE_OK; return SLICE_END; } }else{ int v= show_bits(&s->gb, 16); if(get_bits_count(&s->gb) + 16 > s->gb.size*8){ v>>= get_bits_count(&s->gb) + 16 - s->gb.size*8; } if(v==0) return SLICE_END; } return SLICE_OK; }
{ "code": [], "line_no": [] }
int FUNC_0(MpegEncContext *VAR_0, DCTELEM VAR_1[6][64]) { int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10; INT16 *mot_val; static INT8 VAR_11[4] = { -1, -2, 1, 2 }; VAR_0->error_status_table[VAR_0->mb_x + VAR_0->mb_y*VAR_0->mb_width]= 0; if(VAR_0->mb_x==0) PRINT_MB_TYPE("\n"); if (VAR_0->pict_type == P_TYPE || VAR_0->pict_type==S_TYPE) { if (get_bits1(&VAR_0->gb)) { VAR_0->mb_intra = 0; for(VAR_4=0;VAR_4<6;VAR_4++) VAR_0->block_last_index[VAR_4] = -1; VAR_0->mv_dir = MV_DIR_FORWARD; VAR_0->mv_type = MV_TYPE_16X16; if(VAR_0->pict_type==S_TYPE && VAR_0->vol_sprite_usage==GMC_SPRITE){ PRINT_MB_TYPE("G"); VAR_0->mcsel=1; VAR_0->mv[0][0][0]= get_amv(VAR_0, 0); VAR_0->mv[0][0][1]= get_amv(VAR_0, 1); VAR_0->mb_skiped = 0; }else{ PRINT_MB_TYPE("S"); VAR_0->mcsel=0; VAR_0->mv[0][0][0] = 0; VAR_0->mv[0][0][1] = 0; VAR_0->mb_skiped = 1; } goto end; } VAR_2 = get_vlc2(&VAR_0->gb, inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2); if (VAR_2 < 0) return -1; if (VAR_2 > 20) VAR_2+=3; else if (VAR_2 == 20) fprintf(stderr, "Stuffing !"); VAR_10 = VAR_2 & 8; VAR_0->mb_intra = ((VAR_2 & 4) != 0); if (VAR_0->mb_intra) goto intra; if(VAR_0->pict_type==S_TYPE && VAR_0->vol_sprite_usage==GMC_SPRITE && (VAR_2 & 16) == 0) VAR_0->mcsel= get_bits1(&VAR_0->gb); else VAR_0->mcsel= 0; VAR_3 = get_vlc2(&VAR_0->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1); VAR_5 = (VAR_2 & 3) | ((VAR_3 ^ 0xf) << 2); if (VAR_10) { change_qscale(VAR_0, VAR_11[get_bits(&VAR_0->gb, 2)]); } if((!VAR_0->progressive_sequence) && (VAR_5 || (VAR_0->workaround_bugs&FF_BUG_XVID_ILACE))) VAR_0->interlaced_dct= get_bits1(&VAR_0->gb); VAR_0->mv_dir = MV_DIR_FORWARD; if ((VAR_2 & 16) == 0) { if(VAR_0->mcsel){ PRINT_MB_TYPE("G"); VAR_0->mv_type = MV_TYPE_16X16; VAR_8= get_amv(VAR_0, 0); VAR_9= get_amv(VAR_0, 1); VAR_0->mv[0][0][0] = VAR_8; VAR_0->mv[0][0][1] = VAR_9; }else if((!VAR_0->progressive_sequence) && get_bits1(&VAR_0->gb)){ PRINT_MB_TYPE("f"); VAR_0->mv_type= MV_TYPE_FIELD; VAR_0->field_select[0][0]= get_bits1(&VAR_0->gb); VAR_0->field_select[0][1]= get_bits1(&VAR_0->gb); h263_pred_motion(VAR_0, 0, &VAR_6, &VAR_7); for(VAR_4=0; VAR_4<2; VAR_4++){ VAR_8 = h263_decode_motion(VAR_0, VAR_6, VAR_0->f_code); if (VAR_8 >= 0xffff) return -1; VAR_9 = h263_decode_motion(VAR_0, VAR_7/2, VAR_0->f_code); if (VAR_9 >= 0xffff) return -1; VAR_0->mv[0][VAR_4][0] = VAR_8; VAR_0->mv[0][VAR_4][1] = VAR_9; } }else{ PRINT_MB_TYPE("P"); VAR_0->mv_type = MV_TYPE_16X16; h263_pred_motion(VAR_0, 0, &VAR_6, &VAR_7); if (VAR_0->umvplus_dec) VAR_8 = h263p_decode_umotion(VAR_0, VAR_6); else VAR_8 = h263_decode_motion(VAR_0, VAR_6, VAR_0->f_code); if (VAR_8 >= 0xffff) return -1; if (VAR_0->umvplus_dec) VAR_9 = h263p_decode_umotion(VAR_0, VAR_7); else VAR_9 = h263_decode_motion(VAR_0, VAR_7, VAR_0->f_code); if (VAR_9 >= 0xffff) return -1; VAR_0->mv[0][0][0] = VAR_8; VAR_0->mv[0][0][1] = VAR_9; if (VAR_0->umvplus_dec && (VAR_8 - VAR_6) == 1 && (VAR_9 - VAR_7) == 1) skip_bits1(&VAR_0->gb); } } else { PRINT_MB_TYPE("4"); VAR_0->mv_type = MV_TYPE_8X8; for(VAR_4=0;VAR_4<4;VAR_4++) { mot_val = h263_pred_motion(VAR_0, VAR_4, &VAR_6, &VAR_7); if (VAR_0->umvplus_dec) VAR_8 = h263p_decode_umotion(VAR_0, VAR_6); else VAR_8 = h263_decode_motion(VAR_0, VAR_6, VAR_0->f_code); if (VAR_8 >= 0xffff) return -1; if (VAR_0->umvplus_dec) VAR_9 = h263p_decode_umotion(VAR_0, VAR_7); else VAR_9 = h263_decode_motion(VAR_0, VAR_7, VAR_0->f_code); if (VAR_9 >= 0xffff) return -1; VAR_0->mv[0][VAR_4][0] = VAR_8; VAR_0->mv[0][VAR_4][1] = VAR_9; if (VAR_0->umvplus_dec && (VAR_8 - VAR_6) == 1 && (VAR_9 - VAR_7) == 1) skip_bits1(&VAR_0->gb); mot_val[0] = VAR_8; mot_val[1] = VAR_9; } } } else if(VAR_0->pict_type==B_TYPE) { int VAR_12; int VAR_13; int VAR_14; int VAR_15; VAR_0->mb_intra = 0; VAR_0->mcsel=0; if(VAR_0->mb_x==0){ for(VAR_4=0; VAR_4<2; VAR_4++){ VAR_0->last_mv[VAR_4][0][0]= VAR_0->last_mv[VAR_4][0][1]= VAR_0->last_mv[VAR_4][1][0]= VAR_0->last_mv[VAR_4][1][1]= 0; } } VAR_0->mb_skiped= VAR_0->next_picture.mbskip_table[VAR_0->mb_y * VAR_0->mb_width + VAR_0->mb_x]; if(VAR_0->mb_skiped){ for(VAR_4=0;VAR_4<6;VAR_4++) VAR_0->block_last_index[VAR_4] = -1; VAR_0->mv_dir = MV_DIR_FORWARD; VAR_0->mv_type = MV_TYPE_16X16; VAR_0->mv[0][0][0] = 0; VAR_0->mv[0][0][1] = 0; VAR_0->mv[1][0][0] = 0; VAR_0->mv[1][0][1] = 0; PRINT_MB_TYPE("VAR_0"); goto end; } VAR_12= get_bits1(&VAR_0->gb); if(VAR_12){ VAR_14=4; VAR_5=0; }else{ int VAR_16; VAR_13= get_bits1(&VAR_0->gb); VAR_14= get_vlc2(&VAR_0->gb, mb_type_b_vlc.table, MB_TYPE_B_VLC_BITS, 1); if(VAR_13) VAR_5= 0; else VAR_5= get_bits(&VAR_0->gb, 6); if (VAR_14!=MB_TYPE_B_DIRECT && VAR_5) { if(get_bits1(&VAR_0->gb)){ change_qscale(VAR_0, get_bits1(&VAR_0->gb)*4 - 2); } } VAR_16=0; if(!VAR_0->progressive_sequence){ if(VAR_5) VAR_0->interlaced_dct= get_bits1(&VAR_0->gb); if(VAR_14!=MB_TYPE_B_DIRECT && get_bits1(&VAR_0->gb)){ VAR_16=1; if(VAR_14!=MB_TYPE_B_BACKW){ VAR_0->field_select[0][0]= get_bits1(&VAR_0->gb); VAR_0->field_select[0][1]= get_bits1(&VAR_0->gb); } if(VAR_14!=MB_TYPE_B_FORW){ VAR_0->field_select[1][0]= get_bits1(&VAR_0->gb); VAR_0->field_select[1][1]= get_bits1(&VAR_0->gb); } } } VAR_0->mv_dir = 0; if(VAR_14!=MB_TYPE_B_DIRECT && !VAR_16){ VAR_0->mv_type= MV_TYPE_16X16; if(VAR_14!=MB_TYPE_B_BACKW){ VAR_0->mv_dir = MV_DIR_FORWARD; VAR_8 = h263_decode_motion(VAR_0, VAR_0->last_mv[0][0][0], VAR_0->f_code); VAR_9 = h263_decode_motion(VAR_0, VAR_0->last_mv[0][0][1], VAR_0->f_code); VAR_0->last_mv[0][1][0]= VAR_0->last_mv[0][0][0]= VAR_0->mv[0][0][0] = VAR_8; VAR_0->last_mv[0][1][1]= VAR_0->last_mv[0][0][1]= VAR_0->mv[0][0][1] = VAR_9; } if(VAR_14!=MB_TYPE_B_FORW){ VAR_0->mv_dir |= MV_DIR_BACKWARD; VAR_8 = h263_decode_motion(VAR_0, VAR_0->last_mv[1][0][0], VAR_0->b_code); VAR_9 = h263_decode_motion(VAR_0, VAR_0->last_mv[1][0][1], VAR_0->b_code); VAR_0->last_mv[1][1][0]= VAR_0->last_mv[1][0][0]= VAR_0->mv[1][0][0] = VAR_8; VAR_0->last_mv[1][1][1]= VAR_0->last_mv[1][0][1]= VAR_0->mv[1][0][1] = VAR_9; } if(VAR_14!=MB_TYPE_B_DIRECT) PRINT_MB_TYPE(VAR_14==MB_TYPE_B_FORW ? "F" : (VAR_14==MB_TYPE_B_BACKW ? "B" : "T")); }else if(VAR_14!=MB_TYPE_B_DIRECT){ VAR_0->mv_type= MV_TYPE_FIELD; if(VAR_14!=MB_TYPE_B_BACKW){ VAR_0->mv_dir = MV_DIR_FORWARD; for(VAR_4=0; VAR_4<2; VAR_4++){ VAR_8 = h263_decode_motion(VAR_0, VAR_0->last_mv[0][VAR_4][0] , VAR_0->f_code); VAR_9 = h263_decode_motion(VAR_0, VAR_0->last_mv[0][VAR_4][1]/2, VAR_0->f_code); VAR_0->last_mv[0][VAR_4][0]= VAR_0->mv[0][VAR_4][0] = VAR_8; VAR_0->last_mv[0][VAR_4][1]= (VAR_0->mv[0][VAR_4][1] = VAR_9)*2; } } if(VAR_14!=MB_TYPE_B_FORW){ VAR_0->mv_dir |= MV_DIR_BACKWARD; for(VAR_4=0; VAR_4<2; VAR_4++){ VAR_8 = h263_decode_motion(VAR_0, VAR_0->last_mv[1][VAR_4][0] , VAR_0->b_code); VAR_9 = h263_decode_motion(VAR_0, VAR_0->last_mv[1][VAR_4][1]/2, VAR_0->b_code); VAR_0->last_mv[1][VAR_4][0]= VAR_0->mv[1][VAR_4][0] = VAR_8; VAR_0->last_mv[1][VAR_4][1]= (VAR_0->mv[1][VAR_4][1] = VAR_9)*2; } } if(VAR_14!=MB_TYPE_B_DIRECT) PRINT_MB_TYPE(VAR_14==MB_TYPE_B_FORW ? "f" : (VAR_14==MB_TYPE_B_BACKW ? "b" : "t")); } } if(VAR_14==4 || VAR_14==MB_TYPE_B_DIRECT){ if(VAR_14==4) VAR_8=VAR_9=0; else{ VAR_8 = h263_decode_motion(VAR_0, 0, 1); VAR_9 = h263_decode_motion(VAR_0, 0, 1); } VAR_0->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT; ff_mpeg4_set_direct_mv(VAR_0, VAR_8, VAR_9); } if(VAR_14<0 || VAR_14>4){ printf("illegal MB_type\n"); return -1; } } else { VAR_2 = get_vlc2(&VAR_0->gb, intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 1); if (VAR_2 < 0) return -1; VAR_10 = VAR_2 & 4; VAR_0->mb_intra = 1; intra: VAR_0->ac_pred = 0; if (VAR_0->h263_pred || VAR_0->h263_aic) { VAR_0->ac_pred = get_bits1(&VAR_0->gb); if (VAR_0->ac_pred && VAR_0->h263_aic) VAR_0->h263_aic_dir = get_bits1(&VAR_0->gb); } PRINT_MB_TYPE(VAR_0->ac_pred ? "A" : "I"); VAR_3 = get_vlc2(&VAR_0->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1); if(VAR_3<0) return -1; VAR_5 = (VAR_2 & 3) | (VAR_3 << 2); if (VAR_10) { change_qscale(VAR_0, VAR_11[get_bits(&VAR_0->gb, 2)]); } if(!VAR_0->progressive_sequence) VAR_0->interlaced_dct= get_bits1(&VAR_0->gb); if (VAR_0->h263_pred) { for (VAR_4 = 0; VAR_4 < 6; VAR_4++) { if (mpeg4_decode_block(VAR_0, VAR_1[VAR_4], VAR_4, VAR_5&32, 1) < 0) return -1; VAR_5+=VAR_5; } } else { for (VAR_4 = 0; VAR_4 < 6; VAR_4++) { if (h263_decode_block(VAR_0, VAR_1[VAR_4], VAR_4, VAR_5&32) < 0) return -1; VAR_5+=VAR_5; } } goto end; } if (VAR_0->h263_pred) { for (VAR_4 = 0; VAR_4 < 6; VAR_4++) { if (mpeg4_decode_block(VAR_0, VAR_1[VAR_4], VAR_4, VAR_5&32, 0) < 0) return -1; VAR_5+=VAR_5; } } else { for (VAR_4 = 0; VAR_4 < 6; VAR_4++) { if (h263_decode_block(VAR_0, VAR_1[VAR_4], VAR_4, VAR_5&32) < 0) return -1; VAR_5+=VAR_5; } } end: if(VAR_0->codec_id==CODEC_ID_MPEG4){ if(mpeg4_is_resync(VAR_0)){ if(VAR_0->pict_type==B_TYPE && VAR_0->next_picture.mbskip_table[VAR_0->mb_y * VAR_0->mb_width + VAR_0->mb_x+1]) return SLICE_OK; return SLICE_END; } }else{ int VAR_17= show_bits(&VAR_0->gb, 16); if(get_bits_count(&VAR_0->gb) + 16 > VAR_0->gb.size*8){ VAR_17>>= get_bits_count(&VAR_0->gb) + 16 - VAR_0->gb.size*8; } if(VAR_17==0) return SLICE_END; } return SLICE_OK; }
[ "int FUNC_0(MpegEncContext *VAR_0,\nDCTELEM VAR_1[6][64])\n{", "int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;", "INT16 *mot_val;", "static INT8 VAR_11[4] = { -1, -2, 1, 2 };", "VAR_0->error_status_table[VAR_0->mb_x + VAR_0->mb_y*VAR_0->mb_width]= 0;", "if(VAR_0->mb_x==0) PRINT_MB_TYPE(\"\\n\");", "if (VAR_0->pict_type == P_TYPE || VAR_0->pict_type==S_TYPE) {", "if (get_bits1(&VAR_0->gb)) {", "VAR_0->mb_intra = 0;", "for(VAR_4=0;VAR_4<6;VAR_4++)", "VAR_0->block_last_index[VAR_4] = -1;", "VAR_0->mv_dir = MV_DIR_FORWARD;", "VAR_0->mv_type = MV_TYPE_16X16;", "if(VAR_0->pict_type==S_TYPE && VAR_0->vol_sprite_usage==GMC_SPRITE){", "PRINT_MB_TYPE(\"G\");", "VAR_0->mcsel=1;", "VAR_0->mv[0][0][0]= get_amv(VAR_0, 0);", "VAR_0->mv[0][0][1]= get_amv(VAR_0, 1);", "VAR_0->mb_skiped = 0;", "}else{", "PRINT_MB_TYPE(\"S\");", "VAR_0->mcsel=0;", "VAR_0->mv[0][0][0] = 0;", "VAR_0->mv[0][0][1] = 0;", "VAR_0->mb_skiped = 1;", "}", "goto end;", "}", "VAR_2 = get_vlc2(&VAR_0->gb, inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);", "if (VAR_2 < 0)\nreturn -1;", "if (VAR_2 > 20)\nVAR_2+=3;", "else if (VAR_2 == 20)\nfprintf(stderr, \"Stuffing !\");", "VAR_10 = VAR_2 & 8;", "VAR_0->mb_intra = ((VAR_2 & 4) != 0);", "if (VAR_0->mb_intra) goto intra;", "if(VAR_0->pict_type==S_TYPE && VAR_0->vol_sprite_usage==GMC_SPRITE && (VAR_2 & 16) == 0)\nVAR_0->mcsel= get_bits1(&VAR_0->gb);", "else VAR_0->mcsel= 0;", "VAR_3 = get_vlc2(&VAR_0->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1);", "VAR_5 = (VAR_2 & 3) | ((VAR_3 ^ 0xf) << 2);", "if (VAR_10) {", "change_qscale(VAR_0, VAR_11[get_bits(&VAR_0->gb, 2)]);", "}", "if((!VAR_0->progressive_sequence) && (VAR_5 || (VAR_0->workaround_bugs&FF_BUG_XVID_ILACE)))\nVAR_0->interlaced_dct= get_bits1(&VAR_0->gb);", "VAR_0->mv_dir = MV_DIR_FORWARD;", "if ((VAR_2 & 16) == 0) {", "if(VAR_0->mcsel){", "PRINT_MB_TYPE(\"G\");", "VAR_0->mv_type = MV_TYPE_16X16;", "VAR_8= get_amv(VAR_0, 0);", "VAR_9= get_amv(VAR_0, 1);", "VAR_0->mv[0][0][0] = VAR_8;", "VAR_0->mv[0][0][1] = VAR_9;", "}else if((!VAR_0->progressive_sequence) && get_bits1(&VAR_0->gb)){", "PRINT_MB_TYPE(\"f\");", "VAR_0->mv_type= MV_TYPE_FIELD;", "VAR_0->field_select[0][0]= get_bits1(&VAR_0->gb);", "VAR_0->field_select[0][1]= get_bits1(&VAR_0->gb);", "h263_pred_motion(VAR_0, 0, &VAR_6, &VAR_7);", "for(VAR_4=0; VAR_4<2; VAR_4++){", "VAR_8 = h263_decode_motion(VAR_0, VAR_6, VAR_0->f_code);", "if (VAR_8 >= 0xffff)\nreturn -1;", "VAR_9 = h263_decode_motion(VAR_0, VAR_7/2, VAR_0->f_code);", "if (VAR_9 >= 0xffff)\nreturn -1;", "VAR_0->mv[0][VAR_4][0] = VAR_8;", "VAR_0->mv[0][VAR_4][1] = VAR_9;", "}", "}else{", "PRINT_MB_TYPE(\"P\");", "VAR_0->mv_type = MV_TYPE_16X16;", "h263_pred_motion(VAR_0, 0, &VAR_6, &VAR_7);", "if (VAR_0->umvplus_dec)\nVAR_8 = h263p_decode_umotion(VAR_0, VAR_6);", "else\nVAR_8 = h263_decode_motion(VAR_0, VAR_6, VAR_0->f_code);", "if (VAR_8 >= 0xffff)\nreturn -1;", "if (VAR_0->umvplus_dec)\nVAR_9 = h263p_decode_umotion(VAR_0, VAR_7);", "else\nVAR_9 = h263_decode_motion(VAR_0, VAR_7, VAR_0->f_code);", "if (VAR_9 >= 0xffff)\nreturn -1;", "VAR_0->mv[0][0][0] = VAR_8;", "VAR_0->mv[0][0][1] = VAR_9;", "if (VAR_0->umvplus_dec && (VAR_8 - VAR_6) == 1 && (VAR_9 - VAR_7) == 1)\nskip_bits1(&VAR_0->gb);", "}", "} else {", "PRINT_MB_TYPE(\"4\");", "VAR_0->mv_type = MV_TYPE_8X8;", "for(VAR_4=0;VAR_4<4;VAR_4++) {", "mot_val = h263_pred_motion(VAR_0, VAR_4, &VAR_6, &VAR_7);", "if (VAR_0->umvplus_dec)\nVAR_8 = h263p_decode_umotion(VAR_0, VAR_6);", "else\nVAR_8 = h263_decode_motion(VAR_0, VAR_6, VAR_0->f_code);", "if (VAR_8 >= 0xffff)\nreturn -1;", "if (VAR_0->umvplus_dec)\nVAR_9 = h263p_decode_umotion(VAR_0, VAR_7);", "else\nVAR_9 = h263_decode_motion(VAR_0, VAR_7, VAR_0->f_code);", "if (VAR_9 >= 0xffff)\nreturn -1;", "VAR_0->mv[0][VAR_4][0] = VAR_8;", "VAR_0->mv[0][VAR_4][1] = VAR_9;", "if (VAR_0->umvplus_dec && (VAR_8 - VAR_6) == 1 && (VAR_9 - VAR_7) == 1)\nskip_bits1(&VAR_0->gb);", "mot_val[0] = VAR_8;", "mot_val[1] = VAR_9;", "}", "}", "} else if(VAR_0->pict_type==B_TYPE) {", "int VAR_12;", "int VAR_13;", "int VAR_14;", "int VAR_15;", "VAR_0->mb_intra = 0;", "VAR_0->mcsel=0;", "if(VAR_0->mb_x==0){", "for(VAR_4=0; VAR_4<2; VAR_4++){", "VAR_0->last_mv[VAR_4][0][0]=\nVAR_0->last_mv[VAR_4][0][1]=\nVAR_0->last_mv[VAR_4][1][0]=\nVAR_0->last_mv[VAR_4][1][1]= 0;", "}", "}", "VAR_0->mb_skiped= VAR_0->next_picture.mbskip_table[VAR_0->mb_y * VAR_0->mb_width + VAR_0->mb_x];", "if(VAR_0->mb_skiped){", "for(VAR_4=0;VAR_4<6;VAR_4++)", "VAR_0->block_last_index[VAR_4] = -1;", "VAR_0->mv_dir = MV_DIR_FORWARD;", "VAR_0->mv_type = MV_TYPE_16X16;", "VAR_0->mv[0][0][0] = 0;", "VAR_0->mv[0][0][1] = 0;", "VAR_0->mv[1][0][0] = 0;", "VAR_0->mv[1][0][1] = 0;", "PRINT_MB_TYPE(\"VAR_0\");", "goto end;", "}", "VAR_12= get_bits1(&VAR_0->gb);", "if(VAR_12){", "VAR_14=4;", "VAR_5=0;", "}else{", "int VAR_16;", "VAR_13= get_bits1(&VAR_0->gb);", "VAR_14= get_vlc2(&VAR_0->gb, mb_type_b_vlc.table, MB_TYPE_B_VLC_BITS, 1);", "if(VAR_13) VAR_5= 0;", "else VAR_5= get_bits(&VAR_0->gb, 6);", "if (VAR_14!=MB_TYPE_B_DIRECT && VAR_5) {", "if(get_bits1(&VAR_0->gb)){", "change_qscale(VAR_0, get_bits1(&VAR_0->gb)*4 - 2);", "}", "}", "VAR_16=0;", "if(!VAR_0->progressive_sequence){", "if(VAR_5)\nVAR_0->interlaced_dct= get_bits1(&VAR_0->gb);", "if(VAR_14!=MB_TYPE_B_DIRECT && get_bits1(&VAR_0->gb)){", "VAR_16=1;", "if(VAR_14!=MB_TYPE_B_BACKW){", "VAR_0->field_select[0][0]= get_bits1(&VAR_0->gb);", "VAR_0->field_select[0][1]= get_bits1(&VAR_0->gb);", "}", "if(VAR_14!=MB_TYPE_B_FORW){", "VAR_0->field_select[1][0]= get_bits1(&VAR_0->gb);", "VAR_0->field_select[1][1]= get_bits1(&VAR_0->gb);", "}", "}", "}", "VAR_0->mv_dir = 0;", "if(VAR_14!=MB_TYPE_B_DIRECT && !VAR_16){", "VAR_0->mv_type= MV_TYPE_16X16;", "if(VAR_14!=MB_TYPE_B_BACKW){", "VAR_0->mv_dir = MV_DIR_FORWARD;", "VAR_8 = h263_decode_motion(VAR_0, VAR_0->last_mv[0][0][0], VAR_0->f_code);", "VAR_9 = h263_decode_motion(VAR_0, VAR_0->last_mv[0][0][1], VAR_0->f_code);", "VAR_0->last_mv[0][1][0]= VAR_0->last_mv[0][0][0]= VAR_0->mv[0][0][0] = VAR_8;", "VAR_0->last_mv[0][1][1]= VAR_0->last_mv[0][0][1]= VAR_0->mv[0][0][1] = VAR_9;", "}", "if(VAR_14!=MB_TYPE_B_FORW){", "VAR_0->mv_dir |= MV_DIR_BACKWARD;", "VAR_8 = h263_decode_motion(VAR_0, VAR_0->last_mv[1][0][0], VAR_0->b_code);", "VAR_9 = h263_decode_motion(VAR_0, VAR_0->last_mv[1][0][1], VAR_0->b_code);", "VAR_0->last_mv[1][1][0]= VAR_0->last_mv[1][0][0]= VAR_0->mv[1][0][0] = VAR_8;", "VAR_0->last_mv[1][1][1]= VAR_0->last_mv[1][0][1]= VAR_0->mv[1][0][1] = VAR_9;", "}", "if(VAR_14!=MB_TYPE_B_DIRECT)\nPRINT_MB_TYPE(VAR_14==MB_TYPE_B_FORW ? \"F\" : (VAR_14==MB_TYPE_B_BACKW ? \"B\" : \"T\"));", "}else if(VAR_14!=MB_TYPE_B_DIRECT){", "VAR_0->mv_type= MV_TYPE_FIELD;", "if(VAR_14!=MB_TYPE_B_BACKW){", "VAR_0->mv_dir = MV_DIR_FORWARD;", "for(VAR_4=0; VAR_4<2; VAR_4++){", "VAR_8 = h263_decode_motion(VAR_0, VAR_0->last_mv[0][VAR_4][0] , VAR_0->f_code);", "VAR_9 = h263_decode_motion(VAR_0, VAR_0->last_mv[0][VAR_4][1]/2, VAR_0->f_code);", "VAR_0->last_mv[0][VAR_4][0]= VAR_0->mv[0][VAR_4][0] = VAR_8;", "VAR_0->last_mv[0][VAR_4][1]= (VAR_0->mv[0][VAR_4][1] = VAR_9)*2;", "}", "}", "if(VAR_14!=MB_TYPE_B_FORW){", "VAR_0->mv_dir |= MV_DIR_BACKWARD;", "for(VAR_4=0; VAR_4<2; VAR_4++){", "VAR_8 = h263_decode_motion(VAR_0, VAR_0->last_mv[1][VAR_4][0] , VAR_0->b_code);", "VAR_9 = h263_decode_motion(VAR_0, VAR_0->last_mv[1][VAR_4][1]/2, VAR_0->b_code);", "VAR_0->last_mv[1][VAR_4][0]= VAR_0->mv[1][VAR_4][0] = VAR_8;", "VAR_0->last_mv[1][VAR_4][1]= (VAR_0->mv[1][VAR_4][1] = VAR_9)*2;", "}", "}", "if(VAR_14!=MB_TYPE_B_DIRECT)\nPRINT_MB_TYPE(VAR_14==MB_TYPE_B_FORW ? \"f\" : (VAR_14==MB_TYPE_B_BACKW ? \"b\" : \"t\"));", "}", "}", "if(VAR_14==4 || VAR_14==MB_TYPE_B_DIRECT){", "if(VAR_14==4)\nVAR_8=VAR_9=0;", "else{", "VAR_8 = h263_decode_motion(VAR_0, 0, 1);", "VAR_9 = h263_decode_motion(VAR_0, 0, 1);", "}", "VAR_0->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;", "ff_mpeg4_set_direct_mv(VAR_0, VAR_8, VAR_9);", "}", "if(VAR_14<0 || VAR_14>4){", "printf(\"illegal MB_type\\n\");", "return -1;", "}", "} else {", "VAR_2 = get_vlc2(&VAR_0->gb, intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 1);", "if (VAR_2 < 0)\nreturn -1;", "VAR_10 = VAR_2 & 4;", "VAR_0->mb_intra = 1;", "intra:\nVAR_0->ac_pred = 0;", "if (VAR_0->h263_pred || VAR_0->h263_aic) {", "VAR_0->ac_pred = get_bits1(&VAR_0->gb);", "if (VAR_0->ac_pred && VAR_0->h263_aic)\nVAR_0->h263_aic_dir = get_bits1(&VAR_0->gb);", "}", "PRINT_MB_TYPE(VAR_0->ac_pred ? \"A\" : \"I\");", "VAR_3 = get_vlc2(&VAR_0->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1);", "if(VAR_3<0) return -1;", "VAR_5 = (VAR_2 & 3) | (VAR_3 << 2);", "if (VAR_10) {", "change_qscale(VAR_0, VAR_11[get_bits(&VAR_0->gb, 2)]);", "}", "if(!VAR_0->progressive_sequence)\nVAR_0->interlaced_dct= get_bits1(&VAR_0->gb);", "if (VAR_0->h263_pred) {", "for (VAR_4 = 0; VAR_4 < 6; VAR_4++) {", "if (mpeg4_decode_block(VAR_0, VAR_1[VAR_4], VAR_4, VAR_5&32, 1) < 0)\nreturn -1;", "VAR_5+=VAR_5;", "}", "} else {", "for (VAR_4 = 0; VAR_4 < 6; VAR_4++) {", "if (h263_decode_block(VAR_0, VAR_1[VAR_4], VAR_4, VAR_5&32) < 0)\nreturn -1;", "VAR_5+=VAR_5;", "}", "}", "goto end;", "}", "if (VAR_0->h263_pred) {", "for (VAR_4 = 0; VAR_4 < 6; VAR_4++) {", "if (mpeg4_decode_block(VAR_0, VAR_1[VAR_4], VAR_4, VAR_5&32, 0) < 0)\nreturn -1;", "VAR_5+=VAR_5;", "}", "} else {", "for (VAR_4 = 0; VAR_4 < 6; VAR_4++) {", "if (h263_decode_block(VAR_0, VAR_1[VAR_4], VAR_4, VAR_5&32) < 0)\nreturn -1;", "VAR_5+=VAR_5;", "}", "}", "end:\nif(VAR_0->codec_id==CODEC_ID_MPEG4){", "if(mpeg4_is_resync(VAR_0)){", "if(VAR_0->pict_type==B_TYPE && VAR_0->next_picture.mbskip_table[VAR_0->mb_y * VAR_0->mb_width + VAR_0->mb_x+1])\nreturn SLICE_OK;", "return SLICE_END;", "}", "}else{", "int VAR_17= show_bits(&VAR_0->gb, 16);", "if(get_bits_count(&VAR_0->gb) + 16 > VAR_0->gb.size*8){", "VAR_17>>= get_bits_count(&VAR_0->gb) + 16 - VAR_0->gb.size*8;", "}", "if(VAR_17==0)\nreturn SLICE_END;", "}", "return SLICE_OK;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 19 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 75, 77 ], [ 79, 81 ], [ 83, 85 ], [ 89 ], [ 91 ], [ 93 ], [ 97, 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113, 115 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 145 ], [ 149 ], [ 151 ], [ 155 ], [ 159 ], [ 161 ], [ 163, 165 ], [ 169 ], [ 171, 173 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 189 ], [ 191 ], [ 193, 195 ], [ 197, 199 ], [ 203, 205 ], [ 209, 211 ], [ 213, 215 ], [ 219, 221 ], [ 223 ], [ 225 ], [ 229, 231 ], [ 233 ], [ 235 ], [ 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245, 247 ], [ 249, 251 ], [ 253, 255 ], [ 259, 261 ], [ 263, 265 ], [ 267, 269 ], [ 271 ], [ 273 ], [ 275, 277 ], [ 279 ], [ 281 ], [ 283 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 293 ], [ 295 ], [ 299 ], [ 301 ], [ 305 ], [ 307 ], [ 309, 311, 313, 315 ], [ 317 ], [ 319 ], [ 325 ], [ 329 ], [ 333 ], [ 335 ], [ 339 ], [ 341 ], [ 343 ], [ 345 ], [ 347 ], [ 349 ], [ 351 ], [ 353 ], [ 355 ], [ 359 ], [ 361 ], [ 363 ], [ 365 ], [ 367 ], [ 369 ], [ 373 ], [ 375 ], [ 377 ], [ 379 ], [ 383 ], [ 385 ], [ 387 ], [ 389 ], [ 391 ], [ 393 ], [ 397 ], [ 399, 401 ], [ 405 ], [ 407 ], [ 411 ], [ 413 ], [ 415 ], [ 417 ], [ 419 ], [ 421 ], [ 423 ], [ 425 ], [ 427 ], [ 429 ], [ 433 ], [ 435 ], [ 437 ], [ 439 ], [ 441 ], [ 445 ], [ 447 ], [ 449 ], [ 451 ], [ 453 ], [ 457 ], [ 459 ], [ 463 ], [ 465 ], [ 467 ], [ 469 ], [ 471 ], [ 473, 475 ], [ 477 ], [ 479 ], [ 483 ], [ 485 ], [ 489 ], [ 491 ], [ 493 ], [ 495 ], [ 497 ], [ 499 ], [ 501 ], [ 505 ], [ 507 ], [ 511 ], [ 513 ], [ 515 ], [ 517 ], [ 519 ], [ 521 ], [ 523 ], [ 525, 527 ], [ 529 ], [ 531 ], [ 535 ], [ 537, 539 ], [ 541 ], [ 543 ], [ 545 ], [ 547 ], [ 551 ], [ 553 ], [ 555 ], [ 559 ], [ 561 ], [ 563 ], [ 565 ], [ 567 ], [ 569 ], [ 571, 573 ], [ 575 ], [ 577 ], [ 579, 581 ], [ 583 ], [ 585 ], [ 587, 589 ], [ 591 ], [ 593 ], [ 597 ], [ 599 ], [ 601 ], [ 603 ], [ 605 ], [ 607 ], [ 611, 613 ], [ 619 ], [ 621 ], [ 623, 625 ], [ 627 ], [ 629 ], [ 631 ], [ 633 ], [ 635, 637 ], [ 639 ], [ 641 ], [ 643 ], [ 645 ], [ 647 ], [ 653 ], [ 655 ], [ 657, 659 ], [ 661 ], [ 663 ], [ 665 ], [ 667 ], [ 669, 671 ], [ 673 ], [ 675 ], [ 677 ], [ 679, 685 ], [ 687 ], [ 689, 691 ], [ 693 ], [ 695 ], [ 697 ], [ 699 ], [ 703 ], [ 705 ], [ 707 ], [ 711, 713 ], [ 715 ], [ 719 ], [ 721 ] ]