id
int32 0
27.3k
| func
stringlengths 26
142k
| target
bool 2
classes | project
stringclasses 2
values | commit_id
stringlengths 40
40
| func_clean
stringlengths 26
131k
| vul_lines
dict | normalized_func
stringlengths 24
132k
| lines
sequencelengths 1
2.8k
| label
sequencelengths 1
2.8k
| line_no
sequencelengths 1
2.8k
|
---|---|---|---|---|---|---|---|---|---|---|
27,005 | av_cold void ff_hpeldsp_vp3_init_x86(HpelDSPContext *c, int cpu_flags, int flags)
{
if (EXTERNAL_AMD3DNOW(cpu_flags)) {
if (flags & AV_CODEC_FLAG_BITEXACT) {
c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_exact_3dnow;
c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_exact_3dnow;
}
}
if (EXTERNAL_MMXEXT(cpu_flags)) {
if (flags & AV_CODEC_FLAG_BITEXACT) {
c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_exact_mmxext;
c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_exact_mmxext;
}
}
}
| false | FFmpeg | 0a39c9ac0bfd7345fe676b4e2707d9cec3cbb553 | av_cold void ff_hpeldsp_vp3_init_x86(HpelDSPContext *c, int cpu_flags, int flags)
{
if (EXTERNAL_AMD3DNOW(cpu_flags)) {
if (flags & AV_CODEC_FLAG_BITEXACT) {
c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_exact_3dnow;
c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_exact_3dnow;
}
}
if (EXTERNAL_MMXEXT(cpu_flags)) {
if (flags & AV_CODEC_FLAG_BITEXACT) {
c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_exact_mmxext;
c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_exact_mmxext;
}
}
}
| {
"code": [],
"line_no": []
} | av_cold void FUNC_0(HpelDSPContext *c, int cpu_flags, int flags)
{
if (EXTERNAL_AMD3DNOW(cpu_flags)) {
if (flags & AV_CODEC_FLAG_BITEXACT) {
c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_exact_3dnow;
c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_exact_3dnow;
}
}
if (EXTERNAL_MMXEXT(cpu_flags)) {
if (flags & AV_CODEC_FLAG_BITEXACT) {
c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_exact_mmxext;
c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_exact_mmxext;
}
}
}
| [
"av_cold void FUNC_0(HpelDSPContext *c, int cpu_flags, int flags)\n{",
"if (EXTERNAL_AMD3DNOW(cpu_flags)) {",
"if (flags & AV_CODEC_FLAG_BITEXACT) {",
"c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_exact_3dnow;",
"c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_exact_3dnow;",
"}",
"}",
"if (EXTERNAL_MMXEXT(cpu_flags)) {",
"if (flags & AV_CODEC_FLAG_BITEXACT) {",
"c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_exact_mmxext;",
"c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_exact_mmxext;",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
]
] |
27,006 | const char *bdrv_get_device_name(const BlockDriverState *bs)
{
return bs->blk ? blk_name(bs->blk) : "";
}
| false | qemu | 61007b316cd71ee7333ff7a0a749a8949527575f | const char *bdrv_get_device_name(const BlockDriverState *bs)
{
return bs->blk ? blk_name(bs->blk) : "";
}
| {
"code": [],
"line_no": []
} | const char *FUNC_0(const BlockDriverState *VAR_0)
{
return VAR_0->blk ? blk_name(VAR_0->blk) : "";
}
| [
"const char *FUNC_0(const BlockDriverState *VAR_0)\n{",
"return VAR_0->blk ? blk_name(VAR_0->blk) : \"\";",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
27,009 | static void mmu6xx_dump_mmu(FILE *f, fprintf_function cpu_fprintf,
CPUPPCState *env)
{
ppc6xx_tlb_t *tlb;
target_ulong sr;
int type, way, entry, i;
cpu_fprintf(f, "HTAB base = 0x%"HWADDR_PRIx"\n", env->htab_base);
cpu_fprintf(f, "HTAB mask = 0x%"HWADDR_PRIx"\n", env->htab_mask);
cpu_fprintf(f, "\nSegment registers:\n");
for (i = 0; i < 32; i++) {
sr = env->sr[i];
if (sr & 0x80000000) {
cpu_fprintf(f, "%02d T=%d Ks=%d Kp=%d BUID=0x%03x "
"CNTLR_SPEC=0x%05x\n", i,
sr & 0x80000000 ? 1 : 0, sr & 0x40000000 ? 1 : 0,
sr & 0x20000000 ? 1 : 0, (uint32_t)((sr >> 20) & 0x1FF),
(uint32_t)(sr & 0xFFFFF));
} else {
cpu_fprintf(f, "%02d T=%d Ks=%d Kp=%d N=%d VSID=0x%06x\n", i,
sr & 0x80000000 ? 1 : 0, sr & 0x40000000 ? 1 : 0,
sr & 0x20000000 ? 1 : 0, sr & 0x10000000 ? 1 : 0,
(uint32_t)(sr & 0x00FFFFFF));
}
}
cpu_fprintf(f, "\nBATs:\n");
mmu6xx_dump_BATs(f, cpu_fprintf, env, ACCESS_INT);
mmu6xx_dump_BATs(f, cpu_fprintf, env, ACCESS_CODE);
if (env->id_tlbs != 1) {
cpu_fprintf(f, "ERROR: 6xx MMU should have separated TLB"
" for code and data\n");
}
cpu_fprintf(f, "\nTLBs [EPN EPN + SIZE]\n");
for (type = 0; type < 2; type++) {
for (way = 0; way < env->nb_ways; way++) {
for (entry = env->nb_tlb * type + env->tlb_per_way * way;
entry < (env->nb_tlb * type + env->tlb_per_way * (way + 1));
entry++) {
tlb = &env->tlb.tlb6[entry];
cpu_fprintf(f, "%s TLB %02d/%02d way:%d %s ["
TARGET_FMT_lx " " TARGET_FMT_lx "]\n",
type ? "code" : "data", entry % env->nb_tlb,
env->nb_tlb, way,
pte_is_valid(tlb->pte0) ? "valid" : "inval",
tlb->EPN, tlb->EPN + TARGET_PAGE_SIZE);
}
}
}
}
| false | qemu | 36778660d7fd0748a6129916e47ecedd67bdb758 | static void mmu6xx_dump_mmu(FILE *f, fprintf_function cpu_fprintf,
CPUPPCState *env)
{
ppc6xx_tlb_t *tlb;
target_ulong sr;
int type, way, entry, i;
cpu_fprintf(f, "HTAB base = 0x%"HWADDR_PRIx"\n", env->htab_base);
cpu_fprintf(f, "HTAB mask = 0x%"HWADDR_PRIx"\n", env->htab_mask);
cpu_fprintf(f, "\nSegment registers:\n");
for (i = 0; i < 32; i++) {
sr = env->sr[i];
if (sr & 0x80000000) {
cpu_fprintf(f, "%02d T=%d Ks=%d Kp=%d BUID=0x%03x "
"CNTLR_SPEC=0x%05x\n", i,
sr & 0x80000000 ? 1 : 0, sr & 0x40000000 ? 1 : 0,
sr & 0x20000000 ? 1 : 0, (uint32_t)((sr >> 20) & 0x1FF),
(uint32_t)(sr & 0xFFFFF));
} else {
cpu_fprintf(f, "%02d T=%d Ks=%d Kp=%d N=%d VSID=0x%06x\n", i,
sr & 0x80000000 ? 1 : 0, sr & 0x40000000 ? 1 : 0,
sr & 0x20000000 ? 1 : 0, sr & 0x10000000 ? 1 : 0,
(uint32_t)(sr & 0x00FFFFFF));
}
}
cpu_fprintf(f, "\nBATs:\n");
mmu6xx_dump_BATs(f, cpu_fprintf, env, ACCESS_INT);
mmu6xx_dump_BATs(f, cpu_fprintf, env, ACCESS_CODE);
if (env->id_tlbs != 1) {
cpu_fprintf(f, "ERROR: 6xx MMU should have separated TLB"
" for code and data\n");
}
cpu_fprintf(f, "\nTLBs [EPN EPN + SIZE]\n");
for (type = 0; type < 2; type++) {
for (way = 0; way < env->nb_ways; way++) {
for (entry = env->nb_tlb * type + env->tlb_per_way * way;
entry < (env->nb_tlb * type + env->tlb_per_way * (way + 1));
entry++) {
tlb = &env->tlb.tlb6[entry];
cpu_fprintf(f, "%s TLB %02d/%02d way:%d %s ["
TARGET_FMT_lx " " TARGET_FMT_lx "]\n",
type ? "code" : "data", entry % env->nb_tlb,
env->nb_tlb, way,
pte_is_valid(tlb->pte0) ? "valid" : "inval",
tlb->EPN, tlb->EPN + TARGET_PAGE_SIZE);
}
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(FILE *VAR_0, fprintf_function VAR_1,
CPUPPCState *VAR_2)
{
ppc6xx_tlb_t *tlb;
target_ulong sr;
int VAR_3, VAR_4, VAR_5, VAR_6;
VAR_1(VAR_0, "HTAB base = 0x%"HWADDR_PRIx"\n", VAR_2->htab_base);
VAR_1(VAR_0, "HTAB mask = 0x%"HWADDR_PRIx"\n", VAR_2->htab_mask);
VAR_1(VAR_0, "\nSegment registers:\n");
for (VAR_6 = 0; VAR_6 < 32; VAR_6++) {
sr = VAR_2->sr[VAR_6];
if (sr & 0x80000000) {
VAR_1(VAR_0, "%02d T=%d Ks=%d Kp=%d BUID=0x%03x "
"CNTLR_SPEC=0x%05x\n", VAR_6,
sr & 0x80000000 ? 1 : 0, sr & 0x40000000 ? 1 : 0,
sr & 0x20000000 ? 1 : 0, (uint32_t)((sr >> 20) & 0x1FF),
(uint32_t)(sr & 0xFFFFF));
} else {
VAR_1(VAR_0, "%02d T=%d Ks=%d Kp=%d N=%d VSID=0x%06x\n", VAR_6,
sr & 0x80000000 ? 1 : 0, sr & 0x40000000 ? 1 : 0,
sr & 0x20000000 ? 1 : 0, sr & 0x10000000 ? 1 : 0,
(uint32_t)(sr & 0x00FFFFFF));
}
}
VAR_1(VAR_0, "\nBATs:\n");
mmu6xx_dump_BATs(VAR_0, VAR_1, VAR_2, ACCESS_INT);
mmu6xx_dump_BATs(VAR_0, VAR_1, VAR_2, ACCESS_CODE);
if (VAR_2->id_tlbs != 1) {
VAR_1(VAR_0, "ERROR: 6xx MMU should have separated TLB"
" for code and data\n");
}
VAR_1(VAR_0, "\nTLBs [EPN EPN + SIZE]\n");
for (VAR_3 = 0; VAR_3 < 2; VAR_3++) {
for (VAR_4 = 0; VAR_4 < VAR_2->nb_ways; VAR_4++) {
for (VAR_5 = VAR_2->nb_tlb * VAR_3 + VAR_2->tlb_per_way * VAR_4;
VAR_5 < (VAR_2->nb_tlb * VAR_3 + VAR_2->tlb_per_way * (VAR_4 + 1));
VAR_5++) {
tlb = &VAR_2->tlb.tlb6[VAR_5];
VAR_1(VAR_0, "%s TLB %02d/%02d VAR_4:%d %s ["
TARGET_FMT_lx " " TARGET_FMT_lx "]\n",
VAR_3 ? "code" : "data", VAR_5 % VAR_2->nb_tlb,
VAR_2->nb_tlb, VAR_4,
pte_is_valid(tlb->pte0) ? "valid" : "inval",
tlb->EPN, tlb->EPN + TARGET_PAGE_SIZE);
}
}
}
}
| [
"static void FUNC_0(FILE *VAR_0, fprintf_function VAR_1,\nCPUPPCState *VAR_2)\n{",
"ppc6xx_tlb_t *tlb;",
"target_ulong sr;",
"int VAR_3, VAR_4, VAR_5, VAR_6;",
"VAR_1(VAR_0, \"HTAB base = 0x%\"HWADDR_PRIx\"\\n\", VAR_2->htab_base);",
"VAR_1(VAR_0, \"HTAB mask = 0x%\"HWADDR_PRIx\"\\n\", VAR_2->htab_mask);",
"VAR_1(VAR_0, \"\\nSegment registers:\\n\");",
"for (VAR_6 = 0; VAR_6 < 32; VAR_6++) {",
"sr = VAR_2->sr[VAR_6];",
"if (sr & 0x80000000) {",
"VAR_1(VAR_0, \"%02d T=%d Ks=%d Kp=%d BUID=0x%03x \"\n\"CNTLR_SPEC=0x%05x\\n\", VAR_6,\nsr & 0x80000000 ? 1 : 0, sr & 0x40000000 ? 1 : 0,\nsr & 0x20000000 ? 1 : 0, (uint32_t)((sr >> 20) & 0x1FF),\n(uint32_t)(sr & 0xFFFFF));",
"} else {",
"VAR_1(VAR_0, \"%02d T=%d Ks=%d Kp=%d N=%d VSID=0x%06x\\n\", VAR_6,\nsr & 0x80000000 ? 1 : 0, sr & 0x40000000 ? 1 : 0,\nsr & 0x20000000 ? 1 : 0, sr & 0x10000000 ? 1 : 0,\n(uint32_t)(sr & 0x00FFFFFF));",
"}",
"}",
"VAR_1(VAR_0, \"\\nBATs:\\n\");",
"mmu6xx_dump_BATs(VAR_0, VAR_1, VAR_2, ACCESS_INT);",
"mmu6xx_dump_BATs(VAR_0, VAR_1, VAR_2, ACCESS_CODE);",
"if (VAR_2->id_tlbs != 1) {",
"VAR_1(VAR_0, \"ERROR: 6xx MMU should have separated TLB\"\n\" for code and data\\n\");",
"}",
"VAR_1(VAR_0, \"\\nTLBs [EPN EPN + SIZE]\\n\");",
"for (VAR_3 = 0; VAR_3 < 2; VAR_3++) {",
"for (VAR_4 = 0; VAR_4 < VAR_2->nb_ways; VAR_4++) {",
"for (VAR_5 = VAR_2->nb_tlb * VAR_3 + VAR_2->tlb_per_way * VAR_4;",
"VAR_5 < (VAR_2->nb_tlb * VAR_3 + VAR_2->tlb_per_way * (VAR_4 + 1));",
"VAR_5++) {",
"tlb = &VAR_2->tlb.tlb6[VAR_5];",
"VAR_1(VAR_0, \"%s TLB %02d/%02d VAR_4:%d %s [\"\nTARGET_FMT_lx \" \" TARGET_FMT_lx \"]\\n\",\nVAR_3 ? \"code\" : \"data\", VAR_5 % VAR_2->nb_tlb,\nVAR_2->nb_tlb, VAR_4,\npte_is_valid(tlb->pte0) ? \"valid\" : \"inval\",\ntlb->EPN, tlb->EPN + TARGET_PAGE_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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29,
31,
33,
35,
37
],
[
39
],
[
41,
43,
45,
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65,
67
],
[
69
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91,
93,
95,
97,
99,
101
],
[
103
],
[
105
],
[
107
],
[
109
]
] |
27,010 | static SocketAddress *nbd_build_socket_address(const char *sockpath,
const char *bindto,
const char *port)
{
SocketAddress *saddr;
saddr = g_new0(SocketAddress, 1);
if (sockpath) {
saddr->type = SOCKET_ADDRESS_KIND_UNIX;
saddr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
saddr->u.q_unix.data->path = g_strdup(sockpath);
} else {
InetSocketAddress *inet;
saddr->type = SOCKET_ADDRESS_KIND_INET;
inet = saddr->u.inet.data = g_new0(InetSocketAddress, 1);
inet->host = g_strdup(bindto);
if (port) {
inet->port = g_strdup(port);
} else {
inet->port = g_strdup_printf("%d", NBD_DEFAULT_PORT);
}
}
return saddr;
}
| false | qemu | dfd100f242370886bb6732f70f1f7cbd8eb9fedc | static SocketAddress *nbd_build_socket_address(const char *sockpath,
const char *bindto,
const char *port)
{
SocketAddress *saddr;
saddr = g_new0(SocketAddress, 1);
if (sockpath) {
saddr->type = SOCKET_ADDRESS_KIND_UNIX;
saddr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
saddr->u.q_unix.data->path = g_strdup(sockpath);
} else {
InetSocketAddress *inet;
saddr->type = SOCKET_ADDRESS_KIND_INET;
inet = saddr->u.inet.data = g_new0(InetSocketAddress, 1);
inet->host = g_strdup(bindto);
if (port) {
inet->port = g_strdup(port);
} else {
inet->port = g_strdup_printf("%d", NBD_DEFAULT_PORT);
}
}
return saddr;
}
| {
"code": [],
"line_no": []
} | static SocketAddress *FUNC_0(const char *sockpath,
const char *bindto,
const char *port)
{
SocketAddress *saddr;
saddr = g_new0(SocketAddress, 1);
if (sockpath) {
saddr->type = SOCKET_ADDRESS_KIND_UNIX;
saddr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
saddr->u.q_unix.data->path = g_strdup(sockpath);
} else {
InetSocketAddress *inet;
saddr->type = SOCKET_ADDRESS_KIND_INET;
inet = saddr->u.inet.data = g_new0(InetSocketAddress, 1);
inet->host = g_strdup(bindto);
if (port) {
inet->port = g_strdup(port);
} else {
inet->port = g_strdup_printf("%d", NBD_DEFAULT_PORT);
}
}
return saddr;
}
| [
"static SocketAddress *FUNC_0(const char *sockpath,\nconst char *bindto,\nconst char *port)\n{",
"SocketAddress *saddr;",
"saddr = g_new0(SocketAddress, 1);",
"if (sockpath) {",
"saddr->type = SOCKET_ADDRESS_KIND_UNIX;",
"saddr->u.q_unix.data = g_new0(UnixSocketAddress, 1);",
"saddr->u.q_unix.data->path = g_strdup(sockpath);",
"} else {",
"InetSocketAddress *inet;",
"saddr->type = SOCKET_ADDRESS_KIND_INET;",
"inet = saddr->u.inet.data = g_new0(InetSocketAddress, 1);",
"inet->host = g_strdup(bindto);",
"if (port) {",
"inet->port = g_strdup(port);",
"} else {",
"inet->port = g_strdup_printf(\"%d\", NBD_DEFAULT_PORT);",
"}",
"}",
"return saddr;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
]
] |
27,011 | static void select_vgahw (const char *p)
{
const char *opts;
assert(vga_interface_type == VGA_NONE);
if (strstart(p, "std", &opts)) {
if (vga_available()) {
vga_interface_type = VGA_STD;
} else {
error_report("standard VGA not available");
exit(1);
}
} else if (strstart(p, "cirrus", &opts)) {
if (cirrus_vga_available()) {
vga_interface_type = VGA_CIRRUS;
} else {
error_report("Cirrus VGA not available");
exit(1);
}
} else if (strstart(p, "vmware", &opts)) {
if (vmware_vga_available()) {
vga_interface_type = VGA_VMWARE;
} else {
error_report("VMWare SVGA not available");
exit(1);
}
} else if (strstart(p, "virtio", &opts)) {
if (virtio_vga_available()) {
vga_interface_type = VGA_VIRTIO;
} else {
error_report("Virtio VGA not available");
exit(1);
}
} else if (strstart(p, "xenfb", &opts)) {
vga_interface_type = VGA_XENFB;
} else if (strstart(p, "qxl", &opts)) {
if (qxl_vga_available()) {
vga_interface_type = VGA_QXL;
} else {
error_report("QXL VGA not available");
exit(1);
}
} else if (strstart(p, "tcx", &opts)) {
if (tcx_vga_available()) {
vga_interface_type = VGA_TCX;
} else {
error_report("TCX framebuffer not available");
exit(1);
}
} else if (strstart(p, "cg3", &opts)) {
if (cg3_vga_available()) {
vga_interface_type = VGA_CG3;
} else {
error_report("CG3 framebuffer not available");
exit(1);
}
} else if (!strstart(p, "none", &opts)) {
invalid_vga:
error_report("unknown vga type: %s", p);
exit(1);
}
while (*opts) {
const char *nextopt;
if (strstart(opts, ",retrace=", &nextopt)) {
opts = nextopt;
if (strstart(opts, "dumb", &nextopt))
vga_retrace_method = VGA_RETRACE_DUMB;
else if (strstart(opts, "precise", &nextopt))
vga_retrace_method = VGA_RETRACE_PRECISE;
else goto invalid_vga;
} else goto invalid_vga;
opts = nextopt;
}
}
| false | qemu | 8c9a2b71de67742b40870da22abeccab57c81924 | static void select_vgahw (const char *p)
{
const char *opts;
assert(vga_interface_type == VGA_NONE);
if (strstart(p, "std", &opts)) {
if (vga_available()) {
vga_interface_type = VGA_STD;
} else {
error_report("standard VGA not available");
exit(1);
}
} else if (strstart(p, "cirrus", &opts)) {
if (cirrus_vga_available()) {
vga_interface_type = VGA_CIRRUS;
} else {
error_report("Cirrus VGA not available");
exit(1);
}
} else if (strstart(p, "vmware", &opts)) {
if (vmware_vga_available()) {
vga_interface_type = VGA_VMWARE;
} else {
error_report("VMWare SVGA not available");
exit(1);
}
} else if (strstart(p, "virtio", &opts)) {
if (virtio_vga_available()) {
vga_interface_type = VGA_VIRTIO;
} else {
error_report("Virtio VGA not available");
exit(1);
}
} else if (strstart(p, "xenfb", &opts)) {
vga_interface_type = VGA_XENFB;
} else if (strstart(p, "qxl", &opts)) {
if (qxl_vga_available()) {
vga_interface_type = VGA_QXL;
} else {
error_report("QXL VGA not available");
exit(1);
}
} else if (strstart(p, "tcx", &opts)) {
if (tcx_vga_available()) {
vga_interface_type = VGA_TCX;
} else {
error_report("TCX framebuffer not available");
exit(1);
}
} else if (strstart(p, "cg3", &opts)) {
if (cg3_vga_available()) {
vga_interface_type = VGA_CG3;
} else {
error_report("CG3 framebuffer not available");
exit(1);
}
} else if (!strstart(p, "none", &opts)) {
invalid_vga:
error_report("unknown vga type: %s", p);
exit(1);
}
while (*opts) {
const char *nextopt;
if (strstart(opts, ",retrace=", &nextopt)) {
opts = nextopt;
if (strstart(opts, "dumb", &nextopt))
vga_retrace_method = VGA_RETRACE_DUMB;
else if (strstart(opts, "precise", &nextopt))
vga_retrace_method = VGA_RETRACE_PRECISE;
else goto invalid_vga;
} else goto invalid_vga;
opts = nextopt;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0 (const char *VAR_0)
{
const char *VAR_1;
assert(vga_interface_type == VGA_NONE);
if (strstart(VAR_0, "std", &VAR_1)) {
if (vga_available()) {
vga_interface_type = VGA_STD;
} else {
error_report("standard VGA not available");
exit(1);
}
} else if (strstart(VAR_0, "cirrus", &VAR_1)) {
if (cirrus_vga_available()) {
vga_interface_type = VGA_CIRRUS;
} else {
error_report("Cirrus VGA not available");
exit(1);
}
} else if (strstart(VAR_0, "vmware", &VAR_1)) {
if (vmware_vga_available()) {
vga_interface_type = VGA_VMWARE;
} else {
error_report("VMWare SVGA not available");
exit(1);
}
} else if (strstart(VAR_0, "virtio", &VAR_1)) {
if (virtio_vga_available()) {
vga_interface_type = VGA_VIRTIO;
} else {
error_report("Virtio VGA not available");
exit(1);
}
} else if (strstart(VAR_0, "xenfb", &VAR_1)) {
vga_interface_type = VGA_XENFB;
} else if (strstart(VAR_0, "qxl", &VAR_1)) {
if (qxl_vga_available()) {
vga_interface_type = VGA_QXL;
} else {
error_report("QXL VGA not available");
exit(1);
}
} else if (strstart(VAR_0, "tcx", &VAR_1)) {
if (tcx_vga_available()) {
vga_interface_type = VGA_TCX;
} else {
error_report("TCX framebuffer not available");
exit(1);
}
} else if (strstart(VAR_0, "cg3", &VAR_1)) {
if (cg3_vga_available()) {
vga_interface_type = VGA_CG3;
} else {
error_report("CG3 framebuffer not available");
exit(1);
}
} else if (!strstart(VAR_0, "none", &VAR_1)) {
invalid_vga:
error_report("unknown vga type: %s", VAR_0);
exit(1);
}
while (*VAR_1) {
const char *VAR_2;
if (strstart(VAR_1, ",retrace=", &VAR_2)) {
VAR_1 = VAR_2;
if (strstart(VAR_1, "dumb", &VAR_2))
vga_retrace_method = VGA_RETRACE_DUMB;
else if (strstart(VAR_1, "precise", &VAR_2))
vga_retrace_method = VGA_RETRACE_PRECISE;
else goto invalid_vga;
} else goto invalid_vga;
VAR_1 = VAR_2;
}
}
| [
"static void FUNC_0 (const char *VAR_0)\n{",
"const char *VAR_1;",
"assert(vga_interface_type == VGA_NONE);",
"if (strstart(VAR_0, \"std\", &VAR_1)) {",
"if (vga_available()) {",
"vga_interface_type = VGA_STD;",
"} else {",
"error_report(\"standard VGA not available\");",
"exit(1);",
"}",
"} else if (strstart(VAR_0, \"cirrus\", &VAR_1)) {",
"if (cirrus_vga_available()) {",
"vga_interface_type = VGA_CIRRUS;",
"} else {",
"error_report(\"Cirrus VGA not available\");",
"exit(1);",
"}",
"} else if (strstart(VAR_0, \"vmware\", &VAR_1)) {",
"if (vmware_vga_available()) {",
"vga_interface_type = VGA_VMWARE;",
"} else {",
"error_report(\"VMWare SVGA not available\");",
"exit(1);",
"}",
"} else if (strstart(VAR_0, \"virtio\", &VAR_1)) {",
"if (virtio_vga_available()) {",
"vga_interface_type = VGA_VIRTIO;",
"} else {",
"error_report(\"Virtio VGA not available\");",
"exit(1);",
"}",
"} else if (strstart(VAR_0, \"xenfb\", &VAR_1)) {",
"vga_interface_type = VGA_XENFB;",
"} else if (strstart(VAR_0, \"qxl\", &VAR_1)) {",
"if (qxl_vga_available()) {",
"vga_interface_type = VGA_QXL;",
"} else {",
"error_report(\"QXL VGA not available\");",
"exit(1);",
"}",
"} else if (strstart(VAR_0, \"tcx\", &VAR_1)) {",
"if (tcx_vga_available()) {",
"vga_interface_type = VGA_TCX;",
"} else {",
"error_report(\"TCX framebuffer not available\");",
"exit(1);",
"}",
"} else if (strstart(VAR_0, \"cg3\", &VAR_1)) {",
"if (cg3_vga_available()) {",
"vga_interface_type = VGA_CG3;",
"} else {",
"error_report(\"CG3 framebuffer not available\");",
"exit(1);",
"}",
"} else if (!strstart(VAR_0, \"none\", &VAR_1)) {",
"invalid_vga:\nerror_report(\"unknown vga type: %s\", VAR_0);",
"exit(1);",
"}",
"while (*VAR_1) {",
"const char *VAR_2;",
"if (strstart(VAR_1, \",retrace=\", &VAR_2)) {",
"VAR_1 = VAR_2;",
"if (strstart(VAR_1, \"dumb\", &VAR_2))\nvga_retrace_method = VGA_RETRACE_DUMB;",
"else if (strstart(VAR_1, \"precise\", &VAR_2))\nvga_retrace_method = VGA_RETRACE_PRECISE;",
"else goto invalid_vga;",
"} else goto invalid_vga;",
"VAR_1 = 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
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
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
],
[
137,
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
]
] |
27,012 | static target_ulong h_resize_hpt_commit(PowerPCCPU *cpu,
sPAPRMachineState *spapr,
target_ulong opcode,
target_ulong *args)
{
target_ulong flags = args[0];
target_ulong shift = args[1];
sPAPRPendingHPT *pending = spapr->pending_hpt;
int rc;
size_t newsize;
if (spapr->resize_hpt == SPAPR_RESIZE_HPT_DISABLED) {
return H_AUTHORITY;
}
trace_spapr_h_resize_hpt_commit(flags, shift);
rc = kvmppc_resize_hpt_commit(cpu, flags, shift);
if (rc != -ENOSYS) {
return resize_hpt_convert_rc(rc);
}
if (flags != 0) {
return H_PARAMETER;
}
if (!pending || (pending->shift != shift)) {
/* no matching prepare */
return H_CLOSED;
}
if (!pending->complete) {
/* prepare has not completed */
return H_BUSY;
}
/* Shouldn't have got past PREPARE without an HPT */
g_assert(spapr->htab_shift);
newsize = 1ULL << pending->shift;
rc = rehash_hpt(cpu, spapr->htab, HTAB_SIZE(spapr),
pending->hpt, newsize);
if (rc == H_SUCCESS) {
qemu_vfree(spapr->htab);
spapr->htab = pending->hpt;
spapr->htab_shift = pending->shift;
if (kvm_enabled()) {
/* For KVM PR, update the HPT pointer */
target_ulong sdr1 = (target_ulong)(uintptr_t)spapr->htab
| (spapr->htab_shift - 18);
kvmppc_update_sdr1(sdr1);
}
pending->hpt = NULL; /* so it's not free()d */
}
/* Clean up */
spapr->pending_hpt = NULL;
free_pending_hpt(pending);
return rc;
}
| false | qemu | 1ec26c757d5996468afcc0dced4fad04139574b3 | static target_ulong h_resize_hpt_commit(PowerPCCPU *cpu,
sPAPRMachineState *spapr,
target_ulong opcode,
target_ulong *args)
{
target_ulong flags = args[0];
target_ulong shift = args[1];
sPAPRPendingHPT *pending = spapr->pending_hpt;
int rc;
size_t newsize;
if (spapr->resize_hpt == SPAPR_RESIZE_HPT_DISABLED) {
return H_AUTHORITY;
}
trace_spapr_h_resize_hpt_commit(flags, shift);
rc = kvmppc_resize_hpt_commit(cpu, flags, shift);
if (rc != -ENOSYS) {
return resize_hpt_convert_rc(rc);
}
if (flags != 0) {
return H_PARAMETER;
}
if (!pending || (pending->shift != shift)) {
return H_CLOSED;
}
if (!pending->complete) {
return H_BUSY;
}
g_assert(spapr->htab_shift);
newsize = 1ULL << pending->shift;
rc = rehash_hpt(cpu, spapr->htab, HTAB_SIZE(spapr),
pending->hpt, newsize);
if (rc == H_SUCCESS) {
qemu_vfree(spapr->htab);
spapr->htab = pending->hpt;
spapr->htab_shift = pending->shift;
if (kvm_enabled()) {
target_ulong sdr1 = (target_ulong)(uintptr_t)spapr->htab
| (spapr->htab_shift - 18);
kvmppc_update_sdr1(sdr1);
}
pending->hpt = NULL;
}
spapr->pending_hpt = NULL;
free_pending_hpt(pending);
return rc;
}
| {
"code": [],
"line_no": []
} | static target_ulong FUNC_0(PowerPCCPU *cpu,
sPAPRMachineState *spapr,
target_ulong opcode,
target_ulong *args)
{
target_ulong flags = args[0];
target_ulong shift = args[1];
sPAPRPendingHPT *pending = spapr->pending_hpt;
int VAR_0;
size_t newsize;
if (spapr->resize_hpt == SPAPR_RESIZE_HPT_DISABLED) {
return H_AUTHORITY;
}
trace_spapr_h_resize_hpt_commit(flags, shift);
VAR_0 = kvmppc_resize_hpt_commit(cpu, flags, shift);
if (VAR_0 != -ENOSYS) {
return resize_hpt_convert_rc(VAR_0);
}
if (flags != 0) {
return H_PARAMETER;
}
if (!pending || (pending->shift != shift)) {
return H_CLOSED;
}
if (!pending->complete) {
return H_BUSY;
}
g_assert(spapr->htab_shift);
newsize = 1ULL << pending->shift;
VAR_0 = rehash_hpt(cpu, spapr->htab, HTAB_SIZE(spapr),
pending->hpt, newsize);
if (VAR_0 == H_SUCCESS) {
qemu_vfree(spapr->htab);
spapr->htab = pending->hpt;
spapr->htab_shift = pending->shift;
if (kvm_enabled()) {
target_ulong sdr1 = (target_ulong)(uintptr_t)spapr->htab
| (spapr->htab_shift - 18);
kvmppc_update_sdr1(sdr1);
}
pending->hpt = NULL;
}
spapr->pending_hpt = NULL;
free_pending_hpt(pending);
return VAR_0;
}
| [
"static target_ulong FUNC_0(PowerPCCPU *cpu,\nsPAPRMachineState *spapr,\ntarget_ulong opcode,\ntarget_ulong *args)\n{",
"target_ulong flags = args[0];",
"target_ulong shift = args[1];",
"sPAPRPendingHPT *pending = spapr->pending_hpt;",
"int VAR_0;",
"size_t newsize;",
"if (spapr->resize_hpt == SPAPR_RESIZE_HPT_DISABLED) {",
"return H_AUTHORITY;",
"}",
"trace_spapr_h_resize_hpt_commit(flags, shift);",
"VAR_0 = kvmppc_resize_hpt_commit(cpu, flags, shift);",
"if (VAR_0 != -ENOSYS) {",
"return resize_hpt_convert_rc(VAR_0);",
"}",
"if (flags != 0) {",
"return H_PARAMETER;",
"}",
"if (!pending || (pending->shift != shift)) {",
"return H_CLOSED;",
"}",
"if (!pending->complete) {",
"return H_BUSY;",
"}",
"g_assert(spapr->htab_shift);",
"newsize = 1ULL << pending->shift;",
"VAR_0 = rehash_hpt(cpu, spapr->htab, HTAB_SIZE(spapr),\npending->hpt, newsize);",
"if (VAR_0 == H_SUCCESS) {",
"qemu_vfree(spapr->htab);",
"spapr->htab = pending->hpt;",
"spapr->htab_shift = pending->shift;",
"if (kvm_enabled()) {",
"target_ulong sdr1 = (target_ulong)(uintptr_t)spapr->htab\n| (spapr->htab_shift - 18);",
"kvmppc_update_sdr1(sdr1);",
"}",
"pending->hpt = NULL;",
"}",
"spapr->pending_hpt = NULL;",
"free_pending_hpt(pending);",
"return VAR_0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
53
],
[
57
],
[
59
],
[
63
],
[
67
],
[
69
],
[
75
],
[
79
],
[
81,
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
99,
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
117
],
[
119
],
[
123
],
[
125
]
] |
27,013 | static inline void migration_bitmap_set_dirty(MemoryRegion *mr, int length)
{
ram_addr_t addr;
for (addr = 0; addr < length; addr += TARGET_PAGE_SIZE) {
if (!memory_region_get_dirty(mr, addr, TARGET_PAGE_SIZE,
DIRTY_MEMORY_MIGRATION)) {
memory_region_set_dirty(mr, addr, TARGET_PAGE_SIZE);
}
}
}
| false | qemu | c6bf8e0e0cf04b40a8a22426e00ebbd727331d8b | static inline void migration_bitmap_set_dirty(MemoryRegion *mr, int length)
{
ram_addr_t addr;
for (addr = 0; addr < length; addr += TARGET_PAGE_SIZE) {
if (!memory_region_get_dirty(mr, addr, TARGET_PAGE_SIZE,
DIRTY_MEMORY_MIGRATION)) {
memory_region_set_dirty(mr, addr, TARGET_PAGE_SIZE);
}
}
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(MemoryRegion *VAR_0, int VAR_1)
{
ram_addr_t addr;
for (addr = 0; addr < VAR_1; addr += TARGET_PAGE_SIZE) {
if (!memory_region_get_dirty(VAR_0, addr, TARGET_PAGE_SIZE,
DIRTY_MEMORY_MIGRATION)) {
memory_region_set_dirty(VAR_0, addr, TARGET_PAGE_SIZE);
}
}
}
| [
"static inline void FUNC_0(MemoryRegion *VAR_0, int VAR_1)\n{",
"ram_addr_t addr;",
"for (addr = 0; addr < VAR_1; addr += TARGET_PAGE_SIZE) {",
"if (!memory_region_get_dirty(VAR_0, addr, TARGET_PAGE_SIZE,\nDIRTY_MEMORY_MIGRATION)) {",
"memory_region_set_dirty(VAR_0, addr, TARGET_PAGE_SIZE);",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
27,014 | static int piix3_pre_save(void *opaque)
{
int i;
PIIX3State *piix3 = opaque;
for (i = 0; i < ARRAY_SIZE(piix3->pci_irq_levels_vmstate); i++) {
piix3->pci_irq_levels_vmstate[i] =
pci_bus_get_irq_level(piix3->dev.bus, i);
}
return 0;
}
| false | qemu | fd56e0612b6454a282fa6a953fdb09281a98c589 | static int piix3_pre_save(void *opaque)
{
int i;
PIIX3State *piix3 = opaque;
for (i = 0; i < ARRAY_SIZE(piix3->pci_irq_levels_vmstate); i++) {
piix3->pci_irq_levels_vmstate[i] =
pci_bus_get_irq_level(piix3->dev.bus, i);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(void *VAR_0)
{
int VAR_1;
PIIX3State *piix3 = VAR_0;
for (VAR_1 = 0; VAR_1 < ARRAY_SIZE(piix3->pci_irq_levels_vmstate); VAR_1++) {
piix3->pci_irq_levels_vmstate[VAR_1] =
pci_bus_get_irq_level(piix3->dev.bus, VAR_1);
}
return 0;
}
| [
"static int FUNC_0(void *VAR_0)\n{",
"int VAR_1;",
"PIIX3State *piix3 = VAR_0;",
"for (VAR_1 = 0; VAR_1 < ARRAY_SIZE(piix3->pci_irq_levels_vmstate); VAR_1++) {",
"piix3->pci_irq_levels_vmstate[VAR_1] =\npci_bus_get_irq_level(piix3->dev.bus, VAR_1);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
17
],
[
21
],
[
23
]
] |
27,015 | static void send_qmp_error_event(BlockDriverState *bs,
BlockErrorAction action,
bool is_read, int error)
{
IoOperationType optype;
optype = is_read ? IO_OPERATION_TYPE_READ : IO_OPERATION_TYPE_WRITE;
qapi_event_send_block_io_error(bdrv_get_device_name(bs), optype, action,
bdrv_iostatus_is_enabled(bs),
error == ENOSPC, strerror(error),
&error_abort);
}
| false | qemu | 61007b316cd71ee7333ff7a0a749a8949527575f | static void send_qmp_error_event(BlockDriverState *bs,
BlockErrorAction action,
bool is_read, int error)
{
IoOperationType optype;
optype = is_read ? IO_OPERATION_TYPE_READ : IO_OPERATION_TYPE_WRITE;
qapi_event_send_block_io_error(bdrv_get_device_name(bs), optype, action,
bdrv_iostatus_is_enabled(bs),
error == ENOSPC, strerror(error),
&error_abort);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(BlockDriverState *VAR_0,
BlockErrorAction VAR_1,
bool VAR_2, int VAR_3)
{
IoOperationType optype;
optype = VAR_2 ? IO_OPERATION_TYPE_READ : IO_OPERATION_TYPE_WRITE;
qapi_event_send_block_io_error(bdrv_get_device_name(VAR_0), optype, VAR_1,
bdrv_iostatus_is_enabled(VAR_0),
VAR_3 == ENOSPC, strerror(VAR_3),
&error_abort);
}
| [
"static void FUNC_0(BlockDriverState *VAR_0,\nBlockErrorAction VAR_1,\nbool VAR_2, int VAR_3)\n{",
"IoOperationType optype;",
"optype = VAR_2 ? IO_OPERATION_TYPE_READ : IO_OPERATION_TYPE_WRITE;",
"qapi_event_send_block_io_error(bdrv_get_device_name(VAR_0), optype, VAR_1,\nbdrv_iostatus_is_enabled(VAR_0),\nVAR_3 == ENOSPC, strerror(VAR_3),\n&error_abort);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
15,
17,
19,
21
],
[
23
]
] |
27,016 | static int expand(AVFilterContext *ctx, double *pz, int nb, double *coeffs)
{
int i;
coeffs[0] = 1.0;
coeffs[1] = 0.0;
for (i = 0; i < nb; i++) {
coeffs[2 * (i + 1) ] = 0.0;
coeffs[2 * (i + 1) + 1] = 0.0;
}
for (i = 0; i < nb; i++)
multiply(pz[2 * i], pz[2 * i + 1], nb, coeffs);
for (i = 0; i < nb + 1; i++) {
if (fabs(coeffs[2 * i + 1]) > DBL_EPSILON) {
av_log(ctx, AV_LOG_ERROR, "coeff: %lf of z^%d is not real; poles/zeros are not complex conjugates.\n",
coeffs[2 * i + i], i);
return AVERROR(EINVAL);
}
}
return 0;
}
| false | FFmpeg | 205046420d5a4d389adb705538df3d6158be1fdb | static int expand(AVFilterContext *ctx, double *pz, int nb, double *coeffs)
{
int i;
coeffs[0] = 1.0;
coeffs[1] = 0.0;
for (i = 0; i < nb; i++) {
coeffs[2 * (i + 1) ] = 0.0;
coeffs[2 * (i + 1) + 1] = 0.0;
}
for (i = 0; i < nb; i++)
multiply(pz[2 * i], pz[2 * i + 1], nb, coeffs);
for (i = 0; i < nb + 1; i++) {
if (fabs(coeffs[2 * i + 1]) > DBL_EPSILON) {
av_log(ctx, AV_LOG_ERROR, "coeff: %lf of z^%d is not real; poles/zeros are not complex conjugates.\n",
coeffs[2 * i + i], i);
return AVERROR(EINVAL);
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFilterContext *VAR_0, double *VAR_1, int VAR_2, double *VAR_3)
{
int VAR_4;
VAR_3[0] = 1.0;
VAR_3[1] = 0.0;
for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++) {
VAR_3[2 * (VAR_4 + 1) ] = 0.0;
VAR_3[2 * (VAR_4 + 1) + 1] = 0.0;
}
for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++)
multiply(VAR_1[2 * VAR_4], VAR_1[2 * VAR_4 + 1], VAR_2, VAR_3);
for (VAR_4 = 0; VAR_4 < VAR_2 + 1; VAR_4++) {
if (fabs(VAR_3[2 * VAR_4 + 1]) > DBL_EPSILON) {
av_log(VAR_0, AV_LOG_ERROR, "coeff: %lf of z^%d is not real; poles/zeros are not complex conjugates.\n",
VAR_3[2 * VAR_4 + VAR_4], VAR_4);
return AVERROR(EINVAL);
}
}
return 0;
}
| [
"static int FUNC_0(AVFilterContext *VAR_0, double *VAR_1, int VAR_2, double *VAR_3)\n{",
"int VAR_4;",
"VAR_3[0] = 1.0;",
"VAR_3[1] = 0.0;",
"for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++) {",
"VAR_3[2 * (VAR_4 + 1) ] = 0.0;",
"VAR_3[2 * (VAR_4 + 1) + 1] = 0.0;",
"}",
"for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++)",
"multiply(VAR_1[2 * VAR_4], VAR_1[2 * VAR_4 + 1], VAR_2, VAR_3);",
"for (VAR_4 = 0; VAR_4 < VAR_2 + 1; VAR_4++) {",
"if (fabs(VAR_3[2 * VAR_4 + 1]) > DBL_EPSILON) {",
"av_log(VAR_0, AV_LOG_ERROR, \"coeff: %lf of z^%d is not real; poles/zeros are not complex conjugates.\\n\",",
"VAR_3[2 * VAR_4 + VAR_4], VAR_4);",
"return AVERROR(EINVAL);",
"}",
"}",
"return 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
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
]
] |
27,017 | static int vnc_display_get_address(const char *addrstr,
bool websocket,
bool reverse,
int displaynum,
int to,
bool has_ipv4,
bool has_ipv6,
bool ipv4,
bool ipv6,
SocketAddressLegacy **retaddr,
Error **errp)
{
int ret = -1;
SocketAddressLegacy *addr = NULL;
addr = g_new0(SocketAddressLegacy, 1);
if (strncmp(addrstr, "unix:", 5) == 0) {
addr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;
addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
addr->u.q_unix.data->path = g_strdup(addrstr + 5);
if (websocket) {
error_setg(errp, "UNIX sockets not supported with websock");
goto cleanup;
}
if (to) {
error_setg(errp, "Port range not support with UNIX socket");
goto cleanup;
}
ret = 0;
} else {
const char *port;
size_t hostlen;
unsigned long long baseport = 0;
InetSocketAddress *inet;
port = strrchr(addrstr, ':');
if (!port) {
if (websocket) {
hostlen = 0;
port = addrstr;
} else {
error_setg(errp, "no vnc port specified");
goto cleanup;
}
} else {
hostlen = port - addrstr;
port++;
if (*port == '\0') {
error_setg(errp, "vnc port cannot be empty");
goto cleanup;
}
}
addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
inet = addr->u.inet.data = g_new0(InetSocketAddress, 1);
if (addrstr[0] == '[' && addrstr[hostlen - 1] == ']') {
inet->host = g_strndup(addrstr + 1, hostlen - 2);
} else {
inet->host = g_strndup(addrstr, hostlen);
}
/* plain VNC port is just an offset, for websocket
* port is absolute */
if (websocket) {
if (g_str_equal(addrstr, "") ||
g_str_equal(addrstr, "on")) {
if (displaynum == -1) {
error_setg(errp, "explicit websocket port is required");
goto cleanup;
}
inet->port = g_strdup_printf(
"%d", displaynum + 5700);
if (to) {
inet->has_to = true;
inet->to = to + 5700;
}
} else {
inet->port = g_strdup(port);
}
} else {
int offset = reverse ? 0 : 5900;
if (parse_uint_full(port, &baseport, 10) < 0) {
error_setg(errp, "can't convert to a number: %s", port);
goto cleanup;
}
if (baseport > 65535 ||
baseport + offset > 65535) {
error_setg(errp, "port %s out of range", port);
goto cleanup;
}
inet->port = g_strdup_printf(
"%d", (int)baseport + offset);
if (to) {
inet->has_to = true;
inet->to = to + offset;
}
}
inet->ipv4 = ipv4;
inet->has_ipv4 = has_ipv4;
inet->ipv6 = ipv6;
inet->has_ipv6 = has_ipv6;
ret = baseport;
}
*retaddr = addr;
cleanup:
if (ret < 0) {
qapi_free_SocketAddressLegacy(addr);
}
return ret;
}
| false | qemu | bd269ebc82fbaa5fe7ce5bc7c1770ac8acecd884 | static int vnc_display_get_address(const char *addrstr,
bool websocket,
bool reverse,
int displaynum,
int to,
bool has_ipv4,
bool has_ipv6,
bool ipv4,
bool ipv6,
SocketAddressLegacy **retaddr,
Error **errp)
{
int ret = -1;
SocketAddressLegacy *addr = NULL;
addr = g_new0(SocketAddressLegacy, 1);
if (strncmp(addrstr, "unix:", 5) == 0) {
addr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;
addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
addr->u.q_unix.data->path = g_strdup(addrstr + 5);
if (websocket) {
error_setg(errp, "UNIX sockets not supported with websock");
goto cleanup;
}
if (to) {
error_setg(errp, "Port range not support with UNIX socket");
goto cleanup;
}
ret = 0;
} else {
const char *port;
size_t hostlen;
unsigned long long baseport = 0;
InetSocketAddress *inet;
port = strrchr(addrstr, ':');
if (!port) {
if (websocket) {
hostlen = 0;
port = addrstr;
} else {
error_setg(errp, "no vnc port specified");
goto cleanup;
}
} else {
hostlen = port - addrstr;
port++;
if (*port == '\0') {
error_setg(errp, "vnc port cannot be empty");
goto cleanup;
}
}
addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
inet = addr->u.inet.data = g_new0(InetSocketAddress, 1);
if (addrstr[0] == '[' && addrstr[hostlen - 1] == ']') {
inet->host = g_strndup(addrstr + 1, hostlen - 2);
} else {
inet->host = g_strndup(addrstr, hostlen);
}
if (websocket) {
if (g_str_equal(addrstr, "") ||
g_str_equal(addrstr, "on")) {
if (displaynum == -1) {
error_setg(errp, "explicit websocket port is required");
goto cleanup;
}
inet->port = g_strdup_printf(
"%d", displaynum + 5700);
if (to) {
inet->has_to = true;
inet->to = to + 5700;
}
} else {
inet->port = g_strdup(port);
}
} else {
int offset = reverse ? 0 : 5900;
if (parse_uint_full(port, &baseport, 10) < 0) {
error_setg(errp, "can't convert to a number: %s", port);
goto cleanup;
}
if (baseport > 65535 ||
baseport + offset > 65535) {
error_setg(errp, "port %s out of range", port);
goto cleanup;
}
inet->port = g_strdup_printf(
"%d", (int)baseport + offset);
if (to) {
inet->has_to = true;
inet->to = to + offset;
}
}
inet->ipv4 = ipv4;
inet->has_ipv4 = has_ipv4;
inet->ipv6 = ipv6;
inet->has_ipv6 = has_ipv6;
ret = baseport;
}
*retaddr = addr;
cleanup:
if (ret < 0) {
qapi_free_SocketAddressLegacy(addr);
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(const char *VAR_0,
bool VAR_1,
bool VAR_2,
int VAR_3,
int VAR_4,
bool VAR_5,
bool VAR_6,
bool VAR_7,
bool VAR_8,
SocketAddressLegacy **VAR_9,
Error **VAR_10)
{
int VAR_11 = -1;
SocketAddressLegacy *addr = NULL;
addr = g_new0(SocketAddressLegacy, 1);
if (strncmp(VAR_0, "unix:", 5) == 0) {
addr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;
addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
addr->u.q_unix.data->path = g_strdup(VAR_0 + 5);
if (VAR_1) {
error_setg(VAR_10, "UNIX sockets not supported with websock");
goto cleanup;
}
if (VAR_4) {
error_setg(VAR_10, "Port range not support with UNIX socket");
goto cleanup;
}
VAR_11 = 0;
} else {
const char *VAR_12;
size_t hostlen;
unsigned long long VAR_13 = 0;
InetSocketAddress *inet;
VAR_12 = strrchr(VAR_0, ':');
if (!VAR_12) {
if (VAR_1) {
hostlen = 0;
VAR_12 = VAR_0;
} else {
error_setg(VAR_10, "no vnc VAR_12 specified");
goto cleanup;
}
} else {
hostlen = VAR_12 - VAR_0;
VAR_12++;
if (*VAR_12 == '\0') {
error_setg(VAR_10, "vnc VAR_12 cannot be empty");
goto cleanup;
}
}
addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
inet = addr->u.inet.data = g_new0(InetSocketAddress, 1);
if (VAR_0[0] == '[' && VAR_0[hostlen - 1] == ']') {
inet->host = g_strndup(VAR_0 + 1, hostlen - 2);
} else {
inet->host = g_strndup(VAR_0, hostlen);
}
if (VAR_1) {
if (g_str_equal(VAR_0, "") ||
g_str_equal(VAR_0, "on")) {
if (VAR_3 == -1) {
error_setg(VAR_10, "explicit VAR_1 VAR_12 is required");
goto cleanup;
}
inet->VAR_12 = g_strdup_printf(
"%d", VAR_3 + 5700);
if (VAR_4) {
inet->has_to = true;
inet->VAR_4 = VAR_4 + 5700;
}
} else {
inet->VAR_12 = g_strdup(VAR_12);
}
} else {
int VAR_14 = VAR_2 ? 0 : 5900;
if (parse_uint_full(VAR_12, &VAR_13, 10) < 0) {
error_setg(VAR_10, "can't convert VAR_4 a number: %s", VAR_12);
goto cleanup;
}
if (VAR_13 > 65535 ||
VAR_13 + VAR_14 > 65535) {
error_setg(VAR_10, "VAR_12 %s out of range", VAR_12);
goto cleanup;
}
inet->VAR_12 = g_strdup_printf(
"%d", (int)VAR_13 + VAR_14);
if (VAR_4) {
inet->has_to = true;
inet->VAR_4 = VAR_4 + VAR_14;
}
}
inet->VAR_7 = VAR_7;
inet->VAR_5 = VAR_5;
inet->VAR_8 = VAR_8;
inet->VAR_6 = VAR_6;
VAR_11 = VAR_13;
}
*VAR_9 = addr;
cleanup:
if (VAR_11 < 0) {
qapi_free_SocketAddressLegacy(addr);
}
return VAR_11;
}
| [
"static int FUNC_0(const char *VAR_0,\nbool VAR_1,\nbool VAR_2,\nint VAR_3,\nint VAR_4,\nbool VAR_5,\nbool VAR_6,\nbool VAR_7,\nbool VAR_8,\nSocketAddressLegacy **VAR_9,\nError **VAR_10)\n{",
"int VAR_11 = -1;",
"SocketAddressLegacy *addr = NULL;",
"addr = g_new0(SocketAddressLegacy, 1);",
"if (strncmp(VAR_0, \"unix:\", 5) == 0) {",
"addr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;",
"addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);",
"addr->u.q_unix.data->path = g_strdup(VAR_0 + 5);",
"if (VAR_1) {",
"error_setg(VAR_10, \"UNIX sockets not supported with websock\");",
"goto cleanup;",
"}",
"if (VAR_4) {",
"error_setg(VAR_10, \"Port range not support with UNIX socket\");",
"goto cleanup;",
"}",
"VAR_11 = 0;",
"} else {",
"const char *VAR_12;",
"size_t hostlen;",
"unsigned long long VAR_13 = 0;",
"InetSocketAddress *inet;",
"VAR_12 = strrchr(VAR_0, ':');",
"if (!VAR_12) {",
"if (VAR_1) {",
"hostlen = 0;",
"VAR_12 = VAR_0;",
"} else {",
"error_setg(VAR_10, \"no vnc VAR_12 specified\");",
"goto cleanup;",
"}",
"} else {",
"hostlen = VAR_12 - VAR_0;",
"VAR_12++;",
"if (*VAR_12 == '\\0') {",
"error_setg(VAR_10, \"vnc VAR_12 cannot be empty\");",
"goto cleanup;",
"}",
"}",
"addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;",
"inet = addr->u.inet.data = g_new0(InetSocketAddress, 1);",
"if (VAR_0[0] == '[' && VAR_0[hostlen - 1] == ']') {",
"inet->host = g_strndup(VAR_0 + 1, hostlen - 2);",
"} else {",
"inet->host = g_strndup(VAR_0, hostlen);",
"}",
"if (VAR_1) {",
"if (g_str_equal(VAR_0, \"\") ||\ng_str_equal(VAR_0, \"on\")) {",
"if (VAR_3 == -1) {",
"error_setg(VAR_10, \"explicit VAR_1 VAR_12 is required\");",
"goto cleanup;",
"}",
"inet->VAR_12 = g_strdup_printf(\n\"%d\", VAR_3 + 5700);",
"if (VAR_4) {",
"inet->has_to = true;",
"inet->VAR_4 = VAR_4 + 5700;",
"}",
"} else {",
"inet->VAR_12 = g_strdup(VAR_12);",
"}",
"} else {",
"int VAR_14 = VAR_2 ? 0 : 5900;",
"if (parse_uint_full(VAR_12, &VAR_13, 10) < 0) {",
"error_setg(VAR_10, \"can't convert VAR_4 a number: %s\", VAR_12);",
"goto cleanup;",
"}",
"if (VAR_13 > 65535 ||\nVAR_13 + VAR_14 > 65535) {",
"error_setg(VAR_10, \"VAR_12 %s out of range\", VAR_12);",
"goto cleanup;",
"}",
"inet->VAR_12 = g_strdup_printf(\n\"%d\", (int)VAR_13 + VAR_14);",
"if (VAR_4) {",
"inet->has_to = true;",
"inet->VAR_4 = VAR_4 + VAR_14;",
"}",
"}",
"inet->VAR_7 = VAR_7;",
"inet->VAR_5 = VAR_5;",
"inet->VAR_8 = VAR_8;",
"inet->VAR_6 = VAR_6;",
"VAR_11 = VAR_13;",
"}",
"*VAR_9 = addr;",
"cleanup:\nif (VAR_11 < 0) {",
"qapi_free_SocketAddressLegacy(addr);",
"}",
"return VAR_11;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
131
],
[
133,
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145,
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175,
177
],
[
179
],
[
181
],
[
183
],
[
185,
187
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
203
],
[
205
],
[
207
],
[
209
],
[
213
],
[
215
],
[
219
],
[
223,
225
],
[
227
],
[
229
],
[
231
],
[
233
]
] |
27,018 | static int64_t ffm_seek1(AVFormatContext *s, int64_t pos1)
{
FFMContext *ffm = s->priv_data;
AVIOContext *pb = s->pb;
int64_t pos;
pos = FFMIN(pos1, ffm->file_size - FFM_PACKET_SIZE);
pos = FFMAX(pos, FFM_PACKET_SIZE);
av_dlog(s, "seek to %"PRIx64" -> %"PRIx64"\n", pos1, pos);
return avio_seek(pb, pos, SEEK_SET);
}
| false | FFmpeg | 229843aa359ae0c9519977d7fa952688db63f559 | static int64_t ffm_seek1(AVFormatContext *s, int64_t pos1)
{
FFMContext *ffm = s->priv_data;
AVIOContext *pb = s->pb;
int64_t pos;
pos = FFMIN(pos1, ffm->file_size - FFM_PACKET_SIZE);
pos = FFMAX(pos, FFM_PACKET_SIZE);
av_dlog(s, "seek to %"PRIx64" -> %"PRIx64"\n", pos1, pos);
return avio_seek(pb, pos, SEEK_SET);
}
| {
"code": [],
"line_no": []
} | static int64_t FUNC_0(AVFormatContext *s, int64_t pos1)
{
FFMContext *ffm = s->priv_data;
AVIOContext *pb = s->pb;
int64_t pos;
pos = FFMIN(pos1, ffm->file_size - FFM_PACKET_SIZE);
pos = FFMAX(pos, FFM_PACKET_SIZE);
av_dlog(s, "seek to %"PRIx64" -> %"PRIx64"\n", pos1, pos);
return avio_seek(pb, pos, SEEK_SET);
}
| [
"static int64_t FUNC_0(AVFormatContext *s, int64_t pos1)\n{",
"FFMContext *ffm = s->priv_data;",
"AVIOContext *pb = s->pb;",
"int64_t pos;",
"pos = FFMIN(pos1, ffm->file_size - FFM_PACKET_SIZE);",
"pos = FFMAX(pos, FFM_PACKET_SIZE);",
"av_dlog(s, \"seek to %\"PRIx64\" -> %\"PRIx64\"\\n\", pos1, pos);",
"return avio_seek(pb, pos, SEEK_SET);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
27,019 | static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
AVStream *st;
int id;
st = av_new_stream(s, 0);
if (!st)
return AVERROR_NOMEM;
if (ap) {
id = s->iformat->value;
if (id == CODEC_ID_RAWVIDEO) {
st->codec->codec_type = CODEC_TYPE_VIDEO;
} else {
st->codec->codec_type = CODEC_TYPE_AUDIO;
}
st->codec->codec_id = id;
switch(st->codec->codec_type) {
case CODEC_TYPE_AUDIO:
st->codec->sample_rate = ap->sample_rate;
st->codec->channels = ap->channels;
av_set_pts_info(st, 64, 1, st->codec->sample_rate);
break;
case CODEC_TYPE_VIDEO:
av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
st->codec->width = ap->width;
st->codec->height = ap->height;
st->codec->pix_fmt = ap->pix_fmt;
if(st->codec->pix_fmt == PIX_FMT_NONE)
st->codec->pix_fmt= PIX_FMT_YUV420P;
break;
default:
return -1;
}
} else {
return -1;
}
return 0;
}
| false | FFmpeg | c04c3282b4334ff64cfd69d40fea010602e830fd | static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
AVStream *st;
int id;
st = av_new_stream(s, 0);
if (!st)
return AVERROR_NOMEM;
if (ap) {
id = s->iformat->value;
if (id == CODEC_ID_RAWVIDEO) {
st->codec->codec_type = CODEC_TYPE_VIDEO;
} else {
st->codec->codec_type = CODEC_TYPE_AUDIO;
}
st->codec->codec_id = id;
switch(st->codec->codec_type) {
case CODEC_TYPE_AUDIO:
st->codec->sample_rate = ap->sample_rate;
st->codec->channels = ap->channels;
av_set_pts_info(st, 64, 1, st->codec->sample_rate);
break;
case CODEC_TYPE_VIDEO:
av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
st->codec->width = ap->width;
st->codec->height = ap->height;
st->codec->pix_fmt = ap->pix_fmt;
if(st->codec->pix_fmt == PIX_FMT_NONE)
st->codec->pix_fmt= PIX_FMT_YUV420P;
break;
default:
return -1;
}
} else {
return -1;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVFormatParameters *VAR_1)
{
AVStream *st;
int VAR_2;
st = av_new_stream(VAR_0, 0);
if (!st)
return AVERROR_NOMEM;
if (VAR_1) {
VAR_2 = VAR_0->iformat->value;
if (VAR_2 == CODEC_ID_RAWVIDEO) {
st->codec->codec_type = CODEC_TYPE_VIDEO;
} else {
st->codec->codec_type = CODEC_TYPE_AUDIO;
}
st->codec->codec_id = VAR_2;
switch(st->codec->codec_type) {
case CODEC_TYPE_AUDIO:
st->codec->sample_rate = VAR_1->sample_rate;
st->codec->channels = VAR_1->channels;
av_set_pts_info(st, 64, 1, st->codec->sample_rate);
break;
case CODEC_TYPE_VIDEO:
av_set_pts_info(st, 64, VAR_1->time_base.num, VAR_1->time_base.den);
st->codec->width = VAR_1->width;
st->codec->height = VAR_1->height;
st->codec->pix_fmt = VAR_1->pix_fmt;
if(st->codec->pix_fmt == PIX_FMT_NONE)
st->codec->pix_fmt= PIX_FMT_YUV420P;
break;
default:
return -1;
}
} else {
return -1;
}
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVFormatParameters *VAR_1)\n{",
"AVStream *st;",
"int VAR_2;",
"st = av_new_stream(VAR_0, 0);",
"if (!st)\nreturn AVERROR_NOMEM;",
"if (VAR_1) {",
"VAR_2 = VAR_0->iformat->value;",
"if (VAR_2 == CODEC_ID_RAWVIDEO) {",
"st->codec->codec_type = CODEC_TYPE_VIDEO;",
"} else {",
"st->codec->codec_type = CODEC_TYPE_AUDIO;",
"}",
"st->codec->codec_id = VAR_2;",
"switch(st->codec->codec_type) {",
"case CODEC_TYPE_AUDIO:\nst->codec->sample_rate = VAR_1->sample_rate;",
"st->codec->channels = VAR_1->channels;",
"av_set_pts_info(st, 64, 1, st->codec->sample_rate);",
"break;",
"case CODEC_TYPE_VIDEO:\nav_set_pts_info(st, 64, VAR_1->time_base.num, VAR_1->time_base.den);",
"st->codec->width = VAR_1->width;",
"st->codec->height = VAR_1->height;",
"st->codec->pix_fmt = VAR_1->pix_fmt;",
"if(st->codec->pix_fmt == PIX_FMT_NONE)\nst->codec->pix_fmt= PIX_FMT_YUV420P;",
"break;",
"default:\nreturn -1;",
"}",
"} else {",
"return -1;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
]
] |
27,020 | static size_t curl_size_cb(void *ptr, size_t size, size_t nmemb, void *opaque)
{
CURLState *s = ((CURLState*)opaque);
size_t realsize = size * nmemb;
size_t fsize;
if(sscanf(ptr, "Content-Length: %zd", &fsize) == 1) {
s->s->len = fsize;
}
return realsize;
}
| true | qemu | 3494d650273e619606c6cb2c38aa9b8b7bed98e2 | static size_t curl_size_cb(void *ptr, size_t size, size_t nmemb, void *opaque)
{
CURLState *s = ((CURLState*)opaque);
size_t realsize = size * nmemb;
size_t fsize;
if(sscanf(ptr, "Content-Length: %zd", &fsize) == 1) {
s->s->len = fsize;
}
return realsize;
}
| {
"code": [
"static size_t curl_size_cb(void *ptr, size_t size, size_t nmemb, void *opaque)",
" CURLState *s = ((CURLState*)opaque);",
" size_t fsize;",
" if(sscanf(ptr, \"Content-Length: %zd\", &fsize) == 1) {",
" s->s->len = fsize;"
],
"line_no": [
1,
5,
9,
13,
15
]
} | static size_t FUNC_0(void *ptr, size_t size, size_t nmemb, void *opaque)
{
CURLState *s = ((CURLState*)opaque);
size_t realsize = size * nmemb;
size_t fsize;
if(sscanf(ptr, "Content-Length: %zd", &fsize) == 1) {
s->s->len = fsize;
}
return realsize;
}
| [
"static size_t FUNC_0(void *ptr, size_t size, size_t nmemb, void *opaque)\n{",
"CURLState *s = ((CURLState*)opaque);",
"size_t realsize = size * nmemb;",
"size_t fsize;",
"if(sscanf(ptr, \"Content-Length: %zd\", &fsize) == 1) {",
"s->s->len = fsize;",
"}",
"return realsize;",
"}"
] | [
1,
1,
0,
1,
1,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
]
] |
27,022 | static av_cold int twin_decode_close(AVCodecContext *avctx)
{
TwinContext *tctx = avctx->priv_data;
int i;
for (i = 0; i < 3; i++) {
ff_mdct_end(&tctx->mdct_ctx[i]);
av_free(tctx->cos_tabs[i]);
}
av_free(tctx->curr_frame);
av_free(tctx->spectrum);
av_free(tctx->prev_frame);
av_free(tctx->tmp_buf);
return 0;
}
| true | FFmpeg | a8a6da4a0e059b2aab66627a96b63c3632c477c2 | static av_cold int twin_decode_close(AVCodecContext *avctx)
{
TwinContext *tctx = avctx->priv_data;
int i;
for (i = 0; i < 3; i++) {
ff_mdct_end(&tctx->mdct_ctx[i]);
av_free(tctx->cos_tabs[i]);
}
av_free(tctx->curr_frame);
av_free(tctx->spectrum);
av_free(tctx->prev_frame);
av_free(tctx->tmp_buf);
return 0;
}
| {
"code": [
"static av_cold int twin_decode_close(AVCodecContext *avctx)",
" TwinContext *tctx = avctx->priv_data;",
" int i;",
" for (i = 0; i < 3; i++) {",
" ff_mdct_end(&tctx->mdct_ctx[i]);",
" av_free(tctx->cos_tabs[i]);",
" av_free(tctx->curr_frame);",
" av_free(tctx->spectrum);",
" av_free(tctx->prev_frame);",
" av_free(tctx->tmp_buf);",
" return 0;"
],
"line_no": [
1,
5,
7,
11,
13,
15,
23,
25,
27,
29,
33
]
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
TwinContext *tctx = avctx->priv_data;
int VAR_0;
for (VAR_0 = 0; VAR_0 < 3; VAR_0++) {
ff_mdct_end(&tctx->mdct_ctx[VAR_0]);
av_free(tctx->cos_tabs[VAR_0]);
}
av_free(tctx->curr_frame);
av_free(tctx->spectrum);
av_free(tctx->prev_frame);
av_free(tctx->tmp_buf);
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"TwinContext *tctx = avctx->priv_data;",
"int VAR_0;",
"for (VAR_0 = 0; VAR_0 < 3; VAR_0++) {",
"ff_mdct_end(&tctx->mdct_ctx[VAR_0]);",
"av_free(tctx->cos_tabs[VAR_0]);",
"}",
"av_free(tctx->curr_frame);",
"av_free(tctx->spectrum);",
"av_free(tctx->prev_frame);",
"av_free(tctx->tmp_buf);",
"return 0;",
"}"
] | [
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
]
] |
27,023 | static void fw_cfg_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->realize = fw_cfg_realize;
dc->no_user = 1;
dc->reset = fw_cfg_reset;
dc->vmsd = &vmstate_fw_cfg;
dc->props = fw_cfg_properties;
}
| true | qemu | efec3dd631d94160288392721a5f9c39e50fb2bc | static void fw_cfg_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->realize = fw_cfg_realize;
dc->no_user = 1;
dc->reset = fw_cfg_reset;
dc->vmsd = &vmstate_fw_cfg;
dc->props = fw_cfg_properties;
}
| {
"code": [
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;"
],
"line_no": [
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11
]
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
DeviceClass *dc = DEVICE_CLASS(VAR_0);
dc->realize = fw_cfg_realize;
dc->no_user = 1;
dc->reset = fw_cfg_reset;
dc->vmsd = &vmstate_fw_cfg;
dc->props = fw_cfg_properties;
}
| [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"DeviceClass *dc = DEVICE_CLASS(VAR_0);",
"dc->realize = fw_cfg_realize;",
"dc->no_user = 1;",
"dc->reset = fw_cfg_reset;",
"dc->vmsd = &vmstate_fw_cfg;",
"dc->props = fw_cfg_properties;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
27,024 | static target_ulong h_read(PowerPCCPU *cpu, sPAPREnvironment *spapr,
target_ulong opcode, target_ulong *args)
{
CPUPPCState *env = &cpu->env;
target_ulong flags = args[0];
target_ulong pte_index = args[1];
uint8_t *hpte;
int i, ridx, n_entries = 1;
if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {
return H_PARAMETER;
}
if (flags & H_READ_4) {
/* Clear the two low order bits */
pte_index &= ~(3ULL);
n_entries = 4;
}
hpte = env->external_htab + (pte_index * HASH_PTE_SIZE_64);
for (i = 0, ridx = 0; i < n_entries; i++) {
args[ridx++] = ldq_p(hpte);
args[ridx++] = ldq_p(hpte + (HASH_PTE_SIZE_64/2));
hpte += HASH_PTE_SIZE_64;
}
return H_SUCCESS;
}
| true | qemu | f3c75d42adbba553eaf218a832d4fbea32c8f7b8 | static target_ulong h_read(PowerPCCPU *cpu, sPAPREnvironment *spapr,
target_ulong opcode, target_ulong *args)
{
CPUPPCState *env = &cpu->env;
target_ulong flags = args[0];
target_ulong pte_index = args[1];
uint8_t *hpte;
int i, ridx, n_entries = 1;
if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {
return H_PARAMETER;
}
if (flags & H_READ_4) {
pte_index &= ~(3ULL);
n_entries = 4;
}
hpte = env->external_htab + (pte_index * HASH_PTE_SIZE_64);
for (i = 0, ridx = 0; i < n_entries; i++) {
args[ridx++] = ldq_p(hpte);
args[ridx++] = ldq_p(hpte + (HASH_PTE_SIZE_64/2));
hpte += HASH_PTE_SIZE_64;
}
return H_SUCCESS;
}
| {
"code": [
" if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {",
" if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {",
" if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {"
],
"line_no": [
19,
19,
19
]
} | static target_ulong FUNC_0(PowerPCCPU *cpu, sPAPREnvironment *spapr,
target_ulong opcode, target_ulong *args)
{
CPUPPCState *env = &cpu->env;
target_ulong flags = args[0];
target_ulong pte_index = args[1];
uint8_t *hpte;
int VAR_0, VAR_1, VAR_2 = 1;
if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {
return H_PARAMETER;
}
if (flags & H_READ_4) {
pte_index &= ~(3ULL);
VAR_2 = 4;
}
hpte = env->external_htab + (pte_index * HASH_PTE_SIZE_64);
for (VAR_0 = 0, VAR_1 = 0; VAR_0 < VAR_2; VAR_0++) {
args[VAR_1++] = ldq_p(hpte);
args[VAR_1++] = ldq_p(hpte + (HASH_PTE_SIZE_64/2));
hpte += HASH_PTE_SIZE_64;
}
return H_SUCCESS;
}
| [
"static target_ulong FUNC_0(PowerPCCPU *cpu, sPAPREnvironment *spapr,\ntarget_ulong opcode, target_ulong *args)\n{",
"CPUPPCState *env = &cpu->env;",
"target_ulong flags = args[0];",
"target_ulong pte_index = args[1];",
"uint8_t *hpte;",
"int VAR_0, VAR_1, VAR_2 = 1;",
"if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {",
"return H_PARAMETER;",
"}",
"if (flags & H_READ_4) {",
"pte_index &= ~(3ULL);",
"VAR_2 = 4;",
"}",
"hpte = env->external_htab + (pte_index * HASH_PTE_SIZE_64);",
"for (VAR_0 = 0, VAR_1 = 0; VAR_0 < VAR_2; VAR_0++) {",
"args[VAR_1++] = ldq_p(hpte);",
"args[VAR_1++] = ldq_p(hpte + (HASH_PTE_SIZE_64/2));",
"hpte += HASH_PTE_SIZE_64;",
"}",
"return H_SUCCESS;",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
27
],
[
31
],
[
33
],
[
35
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
]
] |
27,027 | static int bdrv_co_do_ioctl(BlockDriverState *bs, int req, void *buf)
{
BlockDriver *drv = bs->drv;
BdrvTrackedRequest tracked_req;
CoroutineIOCompletion co = {
.coroutine = qemu_coroutine_self(),
};
BlockAIOCB *acb;
tracked_request_begin(&tracked_req, bs, 0, 0, BDRV_TRACKED_IOCTL);
if (!drv || !drv->bdrv_aio_ioctl) {
co.ret = -ENOTSUP;
goto out;
}
acb = drv->bdrv_aio_ioctl(bs, req, buf, bdrv_co_io_em_complete, &co);
if (!acb) {
BdrvIoctlCompletionData *data = g_new(BdrvIoctlCompletionData, 1);
data->bh = aio_bh_new(bdrv_get_aio_context(bs),
bdrv_ioctl_bh_cb, data);
data->co = &co;
qemu_bh_schedule(data->bh);
}
qemu_coroutine_yield();
out:
tracked_request_end(&tracked_req);
return co.ret;
}
| true | qemu | c8a9fd80719e63615dac12e3625223fb54aa8430 | static int bdrv_co_do_ioctl(BlockDriverState *bs, int req, void *buf)
{
BlockDriver *drv = bs->drv;
BdrvTrackedRequest tracked_req;
CoroutineIOCompletion co = {
.coroutine = qemu_coroutine_self(),
};
BlockAIOCB *acb;
tracked_request_begin(&tracked_req, bs, 0, 0, BDRV_TRACKED_IOCTL);
if (!drv || !drv->bdrv_aio_ioctl) {
co.ret = -ENOTSUP;
goto out;
}
acb = drv->bdrv_aio_ioctl(bs, req, buf, bdrv_co_io_em_complete, &co);
if (!acb) {
BdrvIoctlCompletionData *data = g_new(BdrvIoctlCompletionData, 1);
data->bh = aio_bh_new(bdrv_get_aio_context(bs),
bdrv_ioctl_bh_cb, data);
data->co = &co;
qemu_bh_schedule(data->bh);
}
qemu_coroutine_yield();
out:
tracked_request_end(&tracked_req);
return co.ret;
}
| {
"code": [
" BdrvIoctlCompletionData *data = g_new(BdrvIoctlCompletionData, 1);",
" data->bh = aio_bh_new(bdrv_get_aio_context(bs),",
" bdrv_ioctl_bh_cb, data);",
" data->co = &co;",
" qemu_bh_schedule(data->bh);"
],
"line_no": [
35,
37,
39,
41,
43
]
} | static int FUNC_0(BlockDriverState *VAR_0, int VAR_1, void *VAR_2)
{
BlockDriver *drv = VAR_0->drv;
BdrvTrackedRequest tracked_req;
CoroutineIOCompletion co = {
.coroutine = qemu_coroutine_self(),
};
BlockAIOCB *acb;
tracked_request_begin(&tracked_req, VAR_0, 0, 0, BDRV_TRACKED_IOCTL);
if (!drv || !drv->bdrv_aio_ioctl) {
co.ret = -ENOTSUP;
goto out;
}
acb = drv->bdrv_aio_ioctl(VAR_0, VAR_1, VAR_2, bdrv_co_io_em_complete, &co);
if (!acb) {
BdrvIoctlCompletionData *data = g_new(BdrvIoctlCompletionData, 1);
data->bh = aio_bh_new(bdrv_get_aio_context(VAR_0),
bdrv_ioctl_bh_cb, data);
data->co = &co;
qemu_bh_schedule(data->bh);
}
qemu_coroutine_yield();
out:
tracked_request_end(&tracked_req);
return co.ret;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, int VAR_1, void *VAR_2)\n{",
"BlockDriver *drv = VAR_0->drv;",
"BdrvTrackedRequest tracked_req;",
"CoroutineIOCompletion co = {",
".coroutine = qemu_coroutine_self(),\n};",
"BlockAIOCB *acb;",
"tracked_request_begin(&tracked_req, VAR_0, 0, 0, BDRV_TRACKED_IOCTL);",
"if (!drv || !drv->bdrv_aio_ioctl) {",
"co.ret = -ENOTSUP;",
"goto out;",
"}",
"acb = drv->bdrv_aio_ioctl(VAR_0, VAR_1, VAR_2, bdrv_co_io_em_complete, &co);",
"if (!acb) {",
"BdrvIoctlCompletionData *data = g_new(BdrvIoctlCompletionData, 1);",
"data->bh = aio_bh_new(bdrv_get_aio_context(VAR_0),\nbdrv_ioctl_bh_cb, data);",
"data->co = &co;",
"qemu_bh_schedule(data->bh);",
"}",
"qemu_coroutine_yield();",
"out:\ntracked_request_end(&tracked_req);",
"return co.ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
53
],
[
55
]
] |
27,028 | static int asf_read_seek(AVFormatContext *s, int stream_index,
int64_t pts, int flags)
{
ASFContext *asf = s->priv_data;
AVStream *st = s->streams[stream_index];
int64_t pos;
int index;
if (s->packet_size <= 0)
return -1;
/* Try using the protocol's read_seek if available */
if (s->pb) {
int ret = avio_seek_time(s->pb, stream_index, pts, flags);
if (ret >= 0)
asf_reset_header(s);
if (ret != AVERROR(ENOSYS))
return ret;
}
if (!asf->index_read)
asf_build_simple_index(s, stream_index);
if ((asf->index_read && st->index_entries)) {
index = av_index_search_timestamp(st, pts, flags);
if (index >= 0) {
/* find the position */
pos = st->index_entries[index].pos;
/* do the seek */
av_log(s, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos);
avio_seek(s->pb, pos, SEEK_SET);
asf_reset_header(s);
return 0;
}
}
/* no index or seeking by index failed */
if (ff_seek_frame_binary(s, stream_index, pts, flags) < 0)
return -1;
asf_reset_header(s);
return 0;
}
| true | FFmpeg | 0ebb523f072322972ea446616676fff32e9603c6 | static int asf_read_seek(AVFormatContext *s, int stream_index,
int64_t pts, int flags)
{
ASFContext *asf = s->priv_data;
AVStream *st = s->streams[stream_index];
int64_t pos;
int index;
if (s->packet_size <= 0)
return -1;
if (s->pb) {
int ret = avio_seek_time(s->pb, stream_index, pts, flags);
if (ret >= 0)
asf_reset_header(s);
if (ret != AVERROR(ENOSYS))
return ret;
}
if (!asf->index_read)
asf_build_simple_index(s, stream_index);
if ((asf->index_read && st->index_entries)) {
index = av_index_search_timestamp(st, pts, flags);
if (index >= 0) {
pos = st->index_entries[index].pos;
av_log(s, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos);
avio_seek(s->pb, pos, SEEK_SET);
asf_reset_header(s);
return 0;
}
}
if (ff_seek_frame_binary(s, stream_index, pts, flags) < 0)
return -1;
asf_reset_header(s);
return 0;
}
| {
"code": [
" int index;",
" asf_build_simple_index(s, stream_index);",
" if ((asf->index_read && st->index_entries)) {"
],
"line_no": [
13,
43,
47
]
} | static int FUNC_0(AVFormatContext *VAR_0, int VAR_1,
int64_t VAR_2, int VAR_3)
{
ASFContext *asf = VAR_0->priv_data;
AVStream *st = VAR_0->streams[VAR_1];
int64_t pos;
int VAR_4;
if (VAR_0->packet_size <= 0)
return -1;
if (VAR_0->pb) {
int VAR_5 = avio_seek_time(VAR_0->pb, VAR_1, VAR_2, VAR_3);
if (VAR_5 >= 0)
asf_reset_header(VAR_0);
if (VAR_5 != AVERROR(ENOSYS))
return VAR_5;
}
if (!asf->index_read)
asf_build_simple_index(VAR_0, VAR_1);
if ((asf->index_read && st->index_entries)) {
VAR_4 = av_index_search_timestamp(st, VAR_2, VAR_3);
if (VAR_4 >= 0) {
pos = st->index_entries[VAR_4].pos;
av_log(VAR_0, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos);
avio_seek(VAR_0->pb, pos, SEEK_SET);
asf_reset_header(VAR_0);
return 0;
}
}
if (ff_seek_frame_binary(VAR_0, VAR_1, VAR_2, VAR_3) < 0)
return -1;
asf_reset_header(VAR_0);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, int VAR_1,\nint64_t VAR_2, int VAR_3)\n{",
"ASFContext *asf = VAR_0->priv_data;",
"AVStream *st = VAR_0->streams[VAR_1];",
"int64_t pos;",
"int VAR_4;",
"if (VAR_0->packet_size <= 0)\nreturn -1;",
"if (VAR_0->pb) {",
"int VAR_5 = avio_seek_time(VAR_0->pb, VAR_1, VAR_2, VAR_3);",
"if (VAR_5 >= 0)\nasf_reset_header(VAR_0);",
"if (VAR_5 != AVERROR(ENOSYS))\nreturn VAR_5;",
"}",
"if (!asf->index_read)\nasf_build_simple_index(VAR_0, VAR_1);",
"if ((asf->index_read && st->index_entries)) {",
"VAR_4 = av_index_search_timestamp(st, VAR_2, VAR_3);",
"if (VAR_4 >= 0) {",
"pos = st->index_entries[VAR_4].pos;",
"av_log(VAR_0, AV_LOG_DEBUG, \"SEEKTO: %\"PRId64\"\\n\", pos);",
"avio_seek(VAR_0->pb, pos, SEEK_SET);",
"asf_reset_header(VAR_0);",
"return 0;",
"}",
"}",
"if (ff_seek_frame_binary(VAR_0, VAR_1, VAR_2, VAR_3) < 0)\nreturn -1;",
"asf_reset_header(VAR_0);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17,
19
],
[
25
],
[
27
],
[
29,
31
],
[
33,
35
],
[
37
],
[
41,
43
],
[
47
],
[
49
],
[
51
],
[
55
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75,
77
],
[
79
],
[
81
],
[
83
]
] |
27,029 | void ff_mpeg_unref_picture(MpegEncContext *s, Picture *pic)
{
int off = offsetof(Picture, mb_mean) + sizeof(pic->mb_mean);
pic->tf.f = &pic->f;
/* WM Image / Screen codecs allocate internal buffers with different
* dimensions / colorspaces; ignore user-defined callbacks for these. */
if (s->codec_id != AV_CODEC_ID_WMV3IMAGE &&
s->codec_id != AV_CODEC_ID_VC1IMAGE &&
s->codec_id != AV_CODEC_ID_MSS2)
ff_thread_release_buffer(s->avctx, &pic->tf);
else
av_frame_unref(&pic->f);
av_buffer_unref(&pic->hwaccel_priv_buf);
if (pic->needs_realloc)
ff_free_picture_tables(pic);
memset((uint8_t*)pic + off, 0, sizeof(*pic) - off);
}
| true | FFmpeg | f6774f905fb3cfdc319523ac640be30b14c1bc55 | void ff_mpeg_unref_picture(MpegEncContext *s, Picture *pic)
{
int off = offsetof(Picture, mb_mean) + sizeof(pic->mb_mean);
pic->tf.f = &pic->f;
if (s->codec_id != AV_CODEC_ID_WMV3IMAGE &&
s->codec_id != AV_CODEC_ID_VC1IMAGE &&
s->codec_id != AV_CODEC_ID_MSS2)
ff_thread_release_buffer(s->avctx, &pic->tf);
else
av_frame_unref(&pic->f);
av_buffer_unref(&pic->hwaccel_priv_buf);
if (pic->needs_realloc)
ff_free_picture_tables(pic);
memset((uint8_t*)pic + off, 0, sizeof(*pic) - off);
}
| {
"code": [
" pic->tf.f = &pic->f;",
" pic->tf.f = &pic->f;",
" av_frame_unref(&pic->f);"
],
"line_no": [
9,
9,
25
]
} | void FUNC_0(MpegEncContext *VAR_0, Picture *VAR_1)
{
int VAR_2 = offsetof(Picture, mb_mean) + sizeof(VAR_1->mb_mean);
VAR_1->tf.f = &VAR_1->f;
if (VAR_0->codec_id != AV_CODEC_ID_WMV3IMAGE &&
VAR_0->codec_id != AV_CODEC_ID_VC1IMAGE &&
VAR_0->codec_id != AV_CODEC_ID_MSS2)
ff_thread_release_buffer(VAR_0->avctx, &VAR_1->tf);
else
av_frame_unref(&VAR_1->f);
av_buffer_unref(&VAR_1->hwaccel_priv_buf);
if (VAR_1->needs_realloc)
ff_free_picture_tables(VAR_1);
memset((uint8_t*)VAR_1 + VAR_2, 0, sizeof(*VAR_1) - VAR_2);
}
| [
"void FUNC_0(MpegEncContext *VAR_0, Picture *VAR_1)\n{",
"int VAR_2 = offsetof(Picture, mb_mean) + sizeof(VAR_1->mb_mean);",
"VAR_1->tf.f = &VAR_1->f;",
"if (VAR_0->codec_id != AV_CODEC_ID_WMV3IMAGE &&\nVAR_0->codec_id != AV_CODEC_ID_VC1IMAGE &&\nVAR_0->codec_id != AV_CODEC_ID_MSS2)\nff_thread_release_buffer(VAR_0->avctx, &VAR_1->tf);",
"else\nav_frame_unref(&VAR_1->f);",
"av_buffer_unref(&VAR_1->hwaccel_priv_buf);",
"if (VAR_1->needs_realloc)\nff_free_picture_tables(VAR_1);",
"memset((uint8_t*)VAR_1 + VAR_2, 0, sizeof(*VAR_1) - VAR_2);",
"}"
] | [
0,
0,
1,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
15,
17,
19,
21
],
[
23,
25
],
[
29
],
[
33,
35
],
[
39
],
[
41
]
] |
27,030 | void nbd_client_new(NBDExport *exp,
QIOChannelSocket *sioc,
QCryptoTLSCreds *tlscreds,
const char *tlsaclname,
void (*close_fn)(NBDClient *))
{
NBDClient *client;
NBDClientNewData *data = g_new(NBDClientNewData, 1);
client = g_malloc0(sizeof(NBDClient));
client->refcount = 1;
client->exp = exp;
client->tlscreds = tlscreds;
if (tlscreds) {
object_ref(OBJECT(client->tlscreds));
}
client->tlsaclname = g_strdup(tlsaclname);
client->sioc = sioc;
object_ref(OBJECT(client->sioc));
client->ioc = QIO_CHANNEL(sioc);
object_ref(OBJECT(client->ioc));
client->close = close_fn;
data->client = client;
data->co = qemu_coroutine_create(nbd_co_client_start, data);
qemu_coroutine_enter(data->co);
}
| true | qemu | 0c9390d978cbf61e8f16c9f580fa96b305c43568 | void nbd_client_new(NBDExport *exp,
QIOChannelSocket *sioc,
QCryptoTLSCreds *tlscreds,
const char *tlsaclname,
void (*close_fn)(NBDClient *))
{
NBDClient *client;
NBDClientNewData *data = g_new(NBDClientNewData, 1);
client = g_malloc0(sizeof(NBDClient));
client->refcount = 1;
client->exp = exp;
client->tlscreds = tlscreds;
if (tlscreds) {
object_ref(OBJECT(client->tlscreds));
}
client->tlsaclname = g_strdup(tlsaclname);
client->sioc = sioc;
object_ref(OBJECT(client->sioc));
client->ioc = QIO_CHANNEL(sioc);
object_ref(OBJECT(client->ioc));
client->close = close_fn;
data->client = client;
data->co = qemu_coroutine_create(nbd_co_client_start, data);
qemu_coroutine_enter(data->co);
}
| {
"code": [
" void (*close_fn)(NBDClient *))",
" client->close = close_fn;"
],
"line_no": [
9,
43
]
} | VAR_5voidVAR_5 VAR_5nbd_client_newVAR_5(VAR_5NBDExportVAR_5 *VAR_5VAR_0VAR_5,
VAR_5QIOChannelSocketVAR_5 *VAR_5VAR_1VAR_5,
VAR_5QCryptoTLSCredsVAR_5 *VAR_5VAR_2VAR_5,
VAR_5constVAR_5 VAR_5charVAR_5 *VAR_5VAR_3VAR_5,
VAR_5voidVAR_5 (*VAR_5VAR_4VAR_5)(VAR_5NBDClientVAR_5 *))
{
VAR_5NBDClientVAR_5 *VAR_5clientVAR_5;
VAR_5NBDClientNewDataVAR_5 *VAR_5dataVAR_5 = VAR_5g_newVAR_5(VAR_5NBDClientNewDataVAR_5, VAR_51VAR_5);
VAR_5clientVAR_5 = VAR_5g_malloc0VAR_5(VAR_5sizeofVAR_5(VAR_5NBDClientVAR_5));
VAR_5clientVAR_5->VAR_5refcountVAR_5 = VAR_51VAR_5;
VAR_5clientVAR_5->VAR_5VAR_0VAR_5 = VAR_5VAR_0VAR_5;
VAR_5clientVAR_5->VAR_5VAR_2VAR_5 = VAR_5VAR_2VAR_5;
VAR_5ifVAR_5 (VAR_5VAR_2VAR_5) {
VAR_5object_refVAR_5(VAR_5OBJECTVAR_5(VAR_5clientVAR_5->VAR_5VAR_2VAR_5));
}
VAR_5clientVAR_5->VAR_5VAR_3VAR_5 = VAR_5g_strdupVAR_5(VAR_5VAR_3VAR_5);
VAR_5clientVAR_5->VAR_5VAR_1VAR_5 = VAR_5VAR_1VAR_5;
VAR_5object_refVAR_5(VAR_5OBJECTVAR_5(VAR_5clientVAR_5->VAR_5VAR_1VAR_5));
VAR_5clientVAR_5->VAR_5iocVAR_5 = VAR_5QIO_CHANNELVAR_5(VAR_5VAR_1VAR_5);
VAR_5object_refVAR_5(VAR_5OBJECTVAR_5(VAR_5clientVAR_5->VAR_5iocVAR_5));
VAR_5clientVAR_5->VAR_5closeVAR_5 = VAR_5VAR_4VAR_5;
VAR_5dataVAR_5->VAR_5clientVAR_5 = VAR_5clientVAR_5;
VAR_5dataVAR_5->VAR_5coVAR_5 = VAR_5qemu_coroutine_createVAR_5(VAR_5nbd_co_client_startVAR_5, VAR_5dataVAR_5);
VAR_5qemu_coroutine_enterVAR_5(VAR_5dataVAR_5->VAR_5coVAR_5);
}
| [
"VAR_5voidVAR_5 VAR_5nbd_client_newVAR_5(VAR_5NBDExportVAR_5 *VAR_5VAR_0VAR_5,\nVAR_5QIOChannelSocketVAR_5 *VAR_5VAR_1VAR_5,\nVAR_5QCryptoTLSCredsVAR_5 *VAR_5VAR_2VAR_5,\nVAR_5constVAR_5 VAR_5charVAR_5 *VAR_5VAR_3VAR_5,\nVAR_5voidVAR_5 (*VAR_5VAR_4VAR_5)(VAR_5NBDClientVAR_5 *))\n{",
"VAR_5NBDClientVAR_5 *VAR_5clientVAR_5;",
"VAR_5NBDClientNewDataVAR_5 *VAR_5dataVAR_5 = VAR_5g_newVAR_5(VAR_5NBDClientNewDataVAR_5, VAR_51VAR_5);",
"VAR_5clientVAR_5 = VAR_5g_malloc0VAR_5(VAR_5sizeofVAR_5(VAR_5NBDClientVAR_5));",
"VAR_5clientVAR_5->VAR_5refcountVAR_5 = VAR_51VAR_5;",
"VAR_5clientVAR_5->VAR_5VAR_0VAR_5 = VAR_5VAR_0VAR_5;",
"VAR_5clientVAR_5->VAR_5VAR_2VAR_5 = VAR_5VAR_2VAR_5;",
"VAR_5ifVAR_5 (VAR_5VAR_2VAR_5) {",
"VAR_5object_refVAR_5(VAR_5OBJECTVAR_5(VAR_5clientVAR_5->VAR_5VAR_2VAR_5));",
"}",
"VAR_5clientVAR_5->VAR_5VAR_3VAR_5 = VAR_5g_strdupVAR_5(VAR_5VAR_3VAR_5);",
"VAR_5clientVAR_5->VAR_5VAR_1VAR_5 = VAR_5VAR_1VAR_5;",
"VAR_5object_refVAR_5(VAR_5OBJECTVAR_5(VAR_5clientVAR_5->VAR_5VAR_1VAR_5));",
"VAR_5clientVAR_5->VAR_5iocVAR_5 = VAR_5QIO_CHANNELVAR_5(VAR_5VAR_1VAR_5);",
"VAR_5object_refVAR_5(VAR_5OBJECTVAR_5(VAR_5clientVAR_5->VAR_5iocVAR_5));",
"VAR_5clientVAR_5->VAR_5closeVAR_5 = VAR_5VAR_4VAR_5;",
"VAR_5dataVAR_5->VAR_5clientVAR_5 = VAR_5clientVAR_5;",
"VAR_5dataVAR_5->VAR_5coVAR_5 = VAR_5qemu_coroutine_createVAR_5(VAR_5nbd_co_client_startVAR_5, VAR_5dataVAR_5);",
"VAR_5qemu_coroutine_enterVAR_5(VAR_5dataVAR_5->VAR_5coVAR_5);",
"}"
] | [
1,
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
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
]
] |
27,031 | void hbitmap_set(HBitmap *hb, uint64_t start, uint64_t count)
{
/* Compute range in the last layer. */
uint64_t last = start + count - 1;
trace_hbitmap_set(hb, start, count,
start >> hb->granularity, last >> hb->granularity);
start >>= hb->granularity;
last >>= hb->granularity;
count = last - start + 1;
hb->count += count - hb_count_between(hb, start, last);
hb_set_between(hb, HBITMAP_LEVELS - 1, start, last);
} | true | qemu | 0e321191224c8cd137eef41da3257e096965c3d6 | void hbitmap_set(HBitmap *hb, uint64_t start, uint64_t count)
{
uint64_t last = start + count - 1;
trace_hbitmap_set(hb, start, count,
start >> hb->granularity, last >> hb->granularity);
start >>= hb->granularity;
last >>= hb->granularity;
count = last - start + 1;
hb->count += count - hb_count_between(hb, start, last);
hb_set_between(hb, HBITMAP_LEVELS - 1, start, last);
} | {
"code": [],
"line_no": []
} | void FUNC_0(HBitmap *VAR_0, uint64_t VAR_1, uint64_t VAR_2)
{
uint64_t last = VAR_1 + VAR_2 - 1;
trace_hbitmap_set(VAR_0, VAR_1, VAR_2,
VAR_1 >> VAR_0->granularity, last >> VAR_0->granularity);
VAR_1 >>= VAR_0->granularity;
last >>= VAR_0->granularity;
VAR_2 = last - VAR_1 + 1;
VAR_0->VAR_2 += VAR_2 - hb_count_between(VAR_0, VAR_1, last);
hb_set_between(VAR_0, HBITMAP_LEVELS - 1, VAR_1, last);
} | [
"void FUNC_0(HBitmap *VAR_0, uint64_t VAR_1, uint64_t VAR_2)\n{",
"uint64_t last = VAR_1 + VAR_2 - 1;",
"trace_hbitmap_set(VAR_0, VAR_1, VAR_2,\nVAR_1 >> VAR_0->granularity, last >> VAR_0->granularity);",
"VAR_1 >>= VAR_0->granularity;",
"last >>= VAR_0->granularity;",
"VAR_2 = last - VAR_1 + 1;",
"VAR_0->VAR_2 += VAR_2 - hb_count_between(VAR_0, VAR_1, last);",
"hb_set_between(VAR_0, HBITMAP_LEVELS - 1, VAR_1, last);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
11,
13
],
[
17
],
[
19
],
[
21
],
[
26
],
[
28
],
[
30
]
] |
27,032 | static int shorten_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
ShortenContext *s = avctx->priv_data;
int i, input_buf_size = 0;
int ret;
/* allocate internal bitstream buffer */
if (s->max_framesize == 0) {
void *tmp_ptr;
s->max_framesize = 8192; // should hopefully be enough for the first header
tmp_ptr = av_fast_realloc(s->bitstream, &s->allocated_bitstream_size,
s->max_framesize + FF_INPUT_BUFFER_PADDING_SIZE);
if (!tmp_ptr) {
av_log(avctx, AV_LOG_ERROR, "error allocating bitstream buffer\n");
return AVERROR(ENOMEM);
}
s->bitstream = tmp_ptr;
}
/* append current packet data to bitstream buffer */
if (1 && s->max_framesize) { //FIXME truncated
buf_size = FFMIN(buf_size, s->max_framesize - s->bitstream_size);
input_buf_size = buf_size;
if (s->bitstream_index + s->bitstream_size + buf_size >
s->allocated_bitstream_size) {
memmove(s->bitstream, &s->bitstream[s->bitstream_index],
s->bitstream_size);
s->bitstream_index = 0;
}
if (buf)
memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], buf,
buf_size);
buf = &s->bitstream[s->bitstream_index];
buf_size += s->bitstream_size;
s->bitstream_size = buf_size;
/* do not decode until buffer has at least max_framesize bytes or
* the end of the file has been reached */
if (buf_size < s->max_framesize && avpkt->data) {
*got_frame_ptr = 0;
return input_buf_size;
}
}
/* init and position bitstream reader */
init_get_bits(&s->gb, buf, buf_size * 8);
skip_bits(&s->gb, s->bitindex);
/* process header or next subblock */
if (!s->got_header) {
if ((ret = read_header(s)) < 0)
return ret;
*got_frame_ptr = 0;
goto finish_frame;
}
/* if quit command was read previously, don't decode anything */
if (s->got_quit_command) {
*got_frame_ptr = 0;
return avpkt->size;
}
s->cur_chan = 0;
while (s->cur_chan < s->channels) {
unsigned cmd;
int len;
if (get_bits_left(&s->gb) < 3 + FNSIZE) {
*got_frame_ptr = 0;
break;
}
cmd = get_ur_golomb_shorten(&s->gb, FNSIZE);
if (cmd > FN_VERBATIM) {
av_log(avctx, AV_LOG_ERROR, "unknown shorten function %d\n", cmd);
*got_frame_ptr = 0;
break;
}
if (!is_audio_command[cmd]) {
/* process non-audio command */
switch (cmd) {
case FN_VERBATIM:
len = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE);
while (len--)
get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE);
break;
case FN_BITSHIFT:
s->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE);
break;
case FN_BLOCKSIZE: {
unsigned blocksize = get_uint(s, av_log2(s->blocksize));
if (blocksize > s->blocksize) {
av_log(avctx, AV_LOG_ERROR,
"Increasing block size is not supported\n");
return AVERROR_PATCHWELCOME;
}
if (!blocksize || blocksize > MAX_BLOCKSIZE) {
av_log(avctx, AV_LOG_ERROR, "invalid or unsupported "
"block size: %d\n", blocksize);
return AVERROR(EINVAL);
}
s->blocksize = blocksize;
break;
}
case FN_QUIT:
s->got_quit_command = 1;
break;
}
if (cmd == FN_BLOCKSIZE || cmd == FN_QUIT) {
*got_frame_ptr = 0;
break;
}
} else {
/* process audio command */
int residual_size = 0;
int channel = s->cur_chan;
int32_t coffset;
/* get Rice code for residual decoding */
if (cmd != FN_ZERO) {
residual_size = get_ur_golomb_shorten(&s->gb, ENERGYSIZE);
/* This is a hack as version 0 differed in the definition
* of get_sr_golomb_shorten(). */
if (s->version == 0)
residual_size--;
}
/* calculate sample offset using means from previous blocks */
if (s->nmean == 0)
coffset = s->offset[channel][0];
else {
int32_t sum = (s->version < 2) ? 0 : s->nmean / 2;
for (i = 0; i < s->nmean; i++)
sum += s->offset[channel][i];
coffset = sum / s->nmean;
if (s->version >= 2)
coffset = s->bitshift == 0 ? coffset : coffset >> s->bitshift - 1 >> 1;
}
/* decode samples for this channel */
if (cmd == FN_ZERO) {
for (i = 0; i < s->blocksize; i++)
s->decoded[channel][i] = 0;
} else {
if ((ret = decode_subframe_lpc(s, cmd, channel,
residual_size, coffset)) < 0)
return ret;
}
/* update means with info from the current block */
if (s->nmean > 0) {
int32_t sum = (s->version < 2) ? 0 : s->blocksize / 2;
for (i = 0; i < s->blocksize; i++)
sum += s->decoded[channel][i];
for (i = 1; i < s->nmean; i++)
s->offset[channel][i - 1] = s->offset[channel][i];
if (s->version < 2)
s->offset[channel][s->nmean - 1] = sum / s->blocksize;
else
s->offset[channel][s->nmean - 1] = (sum / s->blocksize) << s->bitshift;
}
/* copy wrap samples for use with next block */
for (i = -s->nwrap; i < 0; i++)
s->decoded[channel][i] = s->decoded[channel][i + s->blocksize];
/* shift samples to add in unused zero bits which were removed
* during encoding */
fix_bitshift(s, s->decoded[channel]);
/* if this is the last channel in the block, output the samples */
s->cur_chan++;
if (s->cur_chan == s->channels) {
uint8_t *samples_u8;
int16_t *samples_s16;
int chan;
/* get output buffer */
frame->nb_samples = s->blocksize;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
for (chan = 0; chan < s->channels; chan++) {
samples_u8 = ((uint8_t **)frame->extended_data)[chan];
samples_s16 = ((int16_t **)frame->extended_data)[chan];
for (i = 0; i < s->blocksize; i++) {
switch (s->internal_ftype) {
case TYPE_U8:
*samples_u8++ = av_clip_uint8(s->decoded[chan][i]);
break;
case TYPE_S16HL:
case TYPE_S16LH:
*samples_s16++ = av_clip_int16(s->decoded[chan][i]);
break;
}
}
}
*got_frame_ptr = 1;
}
}
}
if (s->cur_chan < s->channels)
*got_frame_ptr = 0;
finish_frame:
s->bitindex = get_bits_count(&s->gb) - 8 * (get_bits_count(&s->gb) / 8);
i = get_bits_count(&s->gb) / 8;
if (i > buf_size) {
av_log(s->avctx, AV_LOG_ERROR, "overread: %d\n", i - buf_size);
s->bitstream_size = 0;
s->bitstream_index = 0;
return AVERROR_INVALIDDATA;
}
if (s->bitstream_size) {
s->bitstream_index += i;
s->bitstream_size -= i;
return input_buf_size;
} else
return i;
}
| true | FFmpeg | ad22767cb61cdc75541b21154d65fd1ad6351025 | static int shorten_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
ShortenContext *s = avctx->priv_data;
int i, input_buf_size = 0;
int ret;
if (s->max_framesize == 0) {
void *tmp_ptr;
s->max_framesize = 8192;
tmp_ptr = av_fast_realloc(s->bitstream, &s->allocated_bitstream_size,
s->max_framesize + FF_INPUT_BUFFER_PADDING_SIZE);
if (!tmp_ptr) {
av_log(avctx, AV_LOG_ERROR, "error allocating bitstream buffer\n");
return AVERROR(ENOMEM);
}
s->bitstream = tmp_ptr;
}
if (1 && s->max_framesize) {
buf_size = FFMIN(buf_size, s->max_framesize - s->bitstream_size);
input_buf_size = buf_size;
if (s->bitstream_index + s->bitstream_size + buf_size >
s->allocated_bitstream_size) {
memmove(s->bitstream, &s->bitstream[s->bitstream_index],
s->bitstream_size);
s->bitstream_index = 0;
}
if (buf)
memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], buf,
buf_size);
buf = &s->bitstream[s->bitstream_index];
buf_size += s->bitstream_size;
s->bitstream_size = buf_size;
if (buf_size < s->max_framesize && avpkt->data) {
*got_frame_ptr = 0;
return input_buf_size;
}
}
init_get_bits(&s->gb, buf, buf_size * 8);
skip_bits(&s->gb, s->bitindex);
if (!s->got_header) {
if ((ret = read_header(s)) < 0)
return ret;
*got_frame_ptr = 0;
goto finish_frame;
}
if (s->got_quit_command) {
*got_frame_ptr = 0;
return avpkt->size;
}
s->cur_chan = 0;
while (s->cur_chan < s->channels) {
unsigned cmd;
int len;
if (get_bits_left(&s->gb) < 3 + FNSIZE) {
*got_frame_ptr = 0;
break;
}
cmd = get_ur_golomb_shorten(&s->gb, FNSIZE);
if (cmd > FN_VERBATIM) {
av_log(avctx, AV_LOG_ERROR, "unknown shorten function %d\n", cmd);
*got_frame_ptr = 0;
break;
}
if (!is_audio_command[cmd]) {
switch (cmd) {
case FN_VERBATIM:
len = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE);
while (len--)
get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE);
break;
case FN_BITSHIFT:
s->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE);
break;
case FN_BLOCKSIZE: {
unsigned blocksize = get_uint(s, av_log2(s->blocksize));
if (blocksize > s->blocksize) {
av_log(avctx, AV_LOG_ERROR,
"Increasing block size is not supported\n");
return AVERROR_PATCHWELCOME;
}
if (!blocksize || blocksize > MAX_BLOCKSIZE) {
av_log(avctx, AV_LOG_ERROR, "invalid or unsupported "
"block size: %d\n", blocksize);
return AVERROR(EINVAL);
}
s->blocksize = blocksize;
break;
}
case FN_QUIT:
s->got_quit_command = 1;
break;
}
if (cmd == FN_BLOCKSIZE || cmd == FN_QUIT) {
*got_frame_ptr = 0;
break;
}
} else {
int residual_size = 0;
int channel = s->cur_chan;
int32_t coffset;
if (cmd != FN_ZERO) {
residual_size = get_ur_golomb_shorten(&s->gb, ENERGYSIZE);
if (s->version == 0)
residual_size--;
}
if (s->nmean == 0)
coffset = s->offset[channel][0];
else {
int32_t sum = (s->version < 2) ? 0 : s->nmean / 2;
for (i = 0; i < s->nmean; i++)
sum += s->offset[channel][i];
coffset = sum / s->nmean;
if (s->version >= 2)
coffset = s->bitshift == 0 ? coffset : coffset >> s->bitshift - 1 >> 1;
}
if (cmd == FN_ZERO) {
for (i = 0; i < s->blocksize; i++)
s->decoded[channel][i] = 0;
} else {
if ((ret = decode_subframe_lpc(s, cmd, channel,
residual_size, coffset)) < 0)
return ret;
}
if (s->nmean > 0) {
int32_t sum = (s->version < 2) ? 0 : s->blocksize / 2;
for (i = 0; i < s->blocksize; i++)
sum += s->decoded[channel][i];
for (i = 1; i < s->nmean; i++)
s->offset[channel][i - 1] = s->offset[channel][i];
if (s->version < 2)
s->offset[channel][s->nmean - 1] = sum / s->blocksize;
else
s->offset[channel][s->nmean - 1] = (sum / s->blocksize) << s->bitshift;
}
for (i = -s->nwrap; i < 0; i++)
s->decoded[channel][i] = s->decoded[channel][i + s->blocksize];
fix_bitshift(s, s->decoded[channel]);
s->cur_chan++;
if (s->cur_chan == s->channels) {
uint8_t *samples_u8;
int16_t *samples_s16;
int chan;
frame->nb_samples = s->blocksize;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
for (chan = 0; chan < s->channels; chan++) {
samples_u8 = ((uint8_t **)frame->extended_data)[chan];
samples_s16 = ((int16_t **)frame->extended_data)[chan];
for (i = 0; i < s->blocksize; i++) {
switch (s->internal_ftype) {
case TYPE_U8:
*samples_u8++ = av_clip_uint8(s->decoded[chan][i]);
break;
case TYPE_S16HL:
case TYPE_S16LH:
*samples_s16++ = av_clip_int16(s->decoded[chan][i]);
break;
}
}
}
*got_frame_ptr = 1;
}
}
}
if (s->cur_chan < s->channels)
*got_frame_ptr = 0;
finish_frame:
s->bitindex = get_bits_count(&s->gb) - 8 * (get_bits_count(&s->gb) / 8);
i = get_bits_count(&s->gb) / 8;
if (i > buf_size) {
av_log(s->avctx, AV_LOG_ERROR, "overread: %d\n", i - buf_size);
s->bitstream_size = 0;
s->bitstream_index = 0;
return AVERROR_INVALIDDATA;
}
if (s->bitstream_size) {
s->bitstream_index += i;
s->bitstream_size -= i;
return input_buf_size;
} else
return i;
}
| {
"code": [
" if (s->bitstream_index + s->bitstream_size + buf_size >"
],
"line_no": [
57
]
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{
AVFrame *frame = VAR_1;
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
ShortenContext *s = VAR_0->priv_data;
int VAR_6, VAR_7 = 0;
int VAR_8;
if (s->max_framesize == 0) {
void *VAR_9;
s->max_framesize = 8192;
VAR_9 = av_fast_realloc(s->bitstream, &s->allocated_bitstream_size,
s->max_framesize + FF_INPUT_BUFFER_PADDING_SIZE);
if (!VAR_9) {
av_log(VAR_0, AV_LOG_ERROR, "error allocating bitstream buffer\n");
return AVERROR(ENOMEM);
}
s->bitstream = VAR_9;
}
if (1 && s->max_framesize) {
VAR_5 = FFMIN(VAR_5, s->max_framesize - s->bitstream_size);
VAR_7 = VAR_5;
if (s->bitstream_index + s->bitstream_size + VAR_5 >
s->allocated_bitstream_size) {
memmove(s->bitstream, &s->bitstream[s->bitstream_index],
s->bitstream_size);
s->bitstream_index = 0;
}
if (VAR_4)
memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], VAR_4,
VAR_5);
VAR_4 = &s->bitstream[s->bitstream_index];
VAR_5 += s->bitstream_size;
s->bitstream_size = VAR_5;
if (VAR_5 < s->max_framesize && VAR_3->VAR_1) {
*VAR_2 = 0;
return VAR_7;
}
}
init_get_bits(&s->gb, VAR_4, VAR_5 * 8);
skip_bits(&s->gb, s->bitindex);
if (!s->got_header) {
if ((VAR_8 = read_header(s)) < 0)
return VAR_8;
*VAR_2 = 0;
goto finish_frame;
}
if (s->got_quit_command) {
*VAR_2 = 0;
return VAR_3->size;
}
s->cur_chan = 0;
while (s->cur_chan < s->channels) {
unsigned VAR_10;
int VAR_11;
if (get_bits_left(&s->gb) < 3 + FNSIZE) {
*VAR_2 = 0;
break;
}
VAR_10 = get_ur_golomb_shorten(&s->gb, FNSIZE);
if (VAR_10 > FN_VERBATIM) {
av_log(VAR_0, AV_LOG_ERROR, "unknown shorten function %d\n", VAR_10);
*VAR_2 = 0;
break;
}
if (!is_audio_command[VAR_10]) {
switch (VAR_10) {
case FN_VERBATIM:
VAR_11 = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE);
while (VAR_11--)
get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE);
break;
case FN_BITSHIFT:
s->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE);
break;
case FN_BLOCKSIZE: {
unsigned VAR_12 = get_uint(s, av_log2(s->VAR_12));
if (VAR_12 > s->VAR_12) {
av_log(VAR_0, AV_LOG_ERROR,
"Increasing block size is not supported\n");
return AVERROR_PATCHWELCOME;
}
if (!VAR_12 || VAR_12 > MAX_BLOCKSIZE) {
av_log(VAR_0, AV_LOG_ERROR, "invalid or unsupported "
"block size: %d\n", VAR_12);
return AVERROR(EINVAL);
}
s->VAR_12 = VAR_12;
break;
}
case FN_QUIT:
s->got_quit_command = 1;
break;
}
if (VAR_10 == FN_BLOCKSIZE || VAR_10 == FN_QUIT) {
*VAR_2 = 0;
break;
}
} else {
int VAR_13 = 0;
int VAR_14 = s->cur_chan;
int32_t coffset;
if (VAR_10 != FN_ZERO) {
VAR_13 = get_ur_golomb_shorten(&s->gb, ENERGYSIZE);
if (s->version == 0)
VAR_13--;
}
if (s->nmean == 0)
coffset = s->offset[VAR_14][0];
else {
int32_t sum = (s->version < 2) ? 0 : s->nmean / 2;
for (VAR_6 = 0; VAR_6 < s->nmean; VAR_6++)
sum += s->offset[VAR_14][VAR_6];
coffset = sum / s->nmean;
if (s->version >= 2)
coffset = s->bitshift == 0 ? coffset : coffset >> s->bitshift - 1 >> 1;
}
if (VAR_10 == FN_ZERO) {
for (VAR_6 = 0; VAR_6 < s->VAR_12; VAR_6++)
s->decoded[VAR_14][VAR_6] = 0;
} else {
if ((VAR_8 = decode_subframe_lpc(s, VAR_10, VAR_14,
VAR_13, coffset)) < 0)
return VAR_8;
}
if (s->nmean > 0) {
int32_t sum = (s->version < 2) ? 0 : s->VAR_12 / 2;
for (VAR_6 = 0; VAR_6 < s->VAR_12; VAR_6++)
sum += s->decoded[VAR_14][VAR_6];
for (VAR_6 = 1; VAR_6 < s->nmean; VAR_6++)
s->offset[VAR_14][VAR_6 - 1] = s->offset[VAR_14][VAR_6];
if (s->version < 2)
s->offset[VAR_14][s->nmean - 1] = sum / s->VAR_12;
else
s->offset[VAR_14][s->nmean - 1] = (sum / s->VAR_12) << s->bitshift;
}
for (VAR_6 = -s->nwrap; VAR_6 < 0; VAR_6++)
s->decoded[VAR_14][VAR_6] = s->decoded[VAR_14][VAR_6 + s->VAR_12];
fix_bitshift(s, s->decoded[VAR_14]);
s->cur_chan++;
if (s->cur_chan == s->channels) {
uint8_t *samples_u8;
int16_t *samples_s16;
int VAR_15;
frame->nb_samples = s->VAR_12;
if ((VAR_8 = ff_get_buffer(VAR_0, frame, 0)) < 0)
return VAR_8;
for (VAR_15 = 0; VAR_15 < s->channels; VAR_15++) {
samples_u8 = ((uint8_t **)frame->extended_data)[VAR_15];
samples_s16 = ((int16_t **)frame->extended_data)[VAR_15];
for (VAR_6 = 0; VAR_6 < s->VAR_12; VAR_6++) {
switch (s->internal_ftype) {
case TYPE_U8:
*samples_u8++ = av_clip_uint8(s->decoded[VAR_15][VAR_6]);
break;
case TYPE_S16HL:
case TYPE_S16LH:
*samples_s16++ = av_clip_int16(s->decoded[VAR_15][VAR_6]);
break;
}
}
}
*VAR_2 = 1;
}
}
}
if (s->cur_chan < s->channels)
*VAR_2 = 0;
finish_frame:
s->bitindex = get_bits_count(&s->gb) - 8 * (get_bits_count(&s->gb) / 8);
VAR_6 = get_bits_count(&s->gb) / 8;
if (VAR_6 > VAR_5) {
av_log(s->VAR_0, AV_LOG_ERROR, "overread: %d\n", VAR_6 - VAR_5);
s->bitstream_size = 0;
s->bitstream_index = 0;
return AVERROR_INVALIDDATA;
}
if (s->bitstream_size) {
s->bitstream_index += VAR_6;
s->bitstream_size -= VAR_6;
return VAR_7;
} else
return VAR_6;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{",
"AVFrame *frame = VAR_1;",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"ShortenContext *s = VAR_0->priv_data;",
"int VAR_6, VAR_7 = 0;",
"int VAR_8;",
"if (s->max_framesize == 0) {",
"void *VAR_9;",
"s->max_framesize = 8192;",
"VAR_9 = av_fast_realloc(s->bitstream, &s->allocated_bitstream_size,\ns->max_framesize + FF_INPUT_BUFFER_PADDING_SIZE);",
"if (!VAR_9) {",
"av_log(VAR_0, AV_LOG_ERROR, \"error allocating bitstream buffer\\n\");",
"return AVERROR(ENOMEM);",
"}",
"s->bitstream = VAR_9;",
"}",
"if (1 && s->max_framesize) {",
"VAR_5 = FFMIN(VAR_5, s->max_framesize - s->bitstream_size);",
"VAR_7 = VAR_5;",
"if (s->bitstream_index + s->bitstream_size + VAR_5 >\ns->allocated_bitstream_size) {",
"memmove(s->bitstream, &s->bitstream[s->bitstream_index],\ns->bitstream_size);",
"s->bitstream_index = 0;",
"}",
"if (VAR_4)\nmemcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], VAR_4,\nVAR_5);",
"VAR_4 = &s->bitstream[s->bitstream_index];",
"VAR_5 += s->bitstream_size;",
"s->bitstream_size = VAR_5;",
"if (VAR_5 < s->max_framesize && VAR_3->VAR_1) {",
"*VAR_2 = 0;",
"return VAR_7;",
"}",
"}",
"init_get_bits(&s->gb, VAR_4, VAR_5 * 8);",
"skip_bits(&s->gb, s->bitindex);",
"if (!s->got_header) {",
"if ((VAR_8 = read_header(s)) < 0)\nreturn VAR_8;",
"*VAR_2 = 0;",
"goto finish_frame;",
"}",
"if (s->got_quit_command) {",
"*VAR_2 = 0;",
"return VAR_3->size;",
"}",
"s->cur_chan = 0;",
"while (s->cur_chan < s->channels) {",
"unsigned VAR_10;",
"int VAR_11;",
"if (get_bits_left(&s->gb) < 3 + FNSIZE) {",
"*VAR_2 = 0;",
"break;",
"}",
"VAR_10 = get_ur_golomb_shorten(&s->gb, FNSIZE);",
"if (VAR_10 > FN_VERBATIM) {",
"av_log(VAR_0, AV_LOG_ERROR, \"unknown shorten function %d\\n\", VAR_10);",
"*VAR_2 = 0;",
"break;",
"}",
"if (!is_audio_command[VAR_10]) {",
"switch (VAR_10) {",
"case FN_VERBATIM:\nVAR_11 = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE);",
"while (VAR_11--)\nget_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE);",
"break;",
"case FN_BITSHIFT:\ns->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE);",
"break;",
"case FN_BLOCKSIZE: {",
"unsigned VAR_12 = get_uint(s, av_log2(s->VAR_12));",
"if (VAR_12 > s->VAR_12) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Increasing block size is not supported\\n\");",
"return AVERROR_PATCHWELCOME;",
"}",
"if (!VAR_12 || VAR_12 > MAX_BLOCKSIZE) {",
"av_log(VAR_0, AV_LOG_ERROR, \"invalid or unsupported \"\n\"block size: %d\\n\", VAR_12);",
"return AVERROR(EINVAL);",
"}",
"s->VAR_12 = VAR_12;",
"break;",
"}",
"case FN_QUIT:\ns->got_quit_command = 1;",
"break;",
"}",
"if (VAR_10 == FN_BLOCKSIZE || VAR_10 == FN_QUIT) {",
"*VAR_2 = 0;",
"break;",
"}",
"} else {",
"int VAR_13 = 0;",
"int VAR_14 = s->cur_chan;",
"int32_t coffset;",
"if (VAR_10 != FN_ZERO) {",
"VAR_13 = get_ur_golomb_shorten(&s->gb, ENERGYSIZE);",
"if (s->version == 0)\nVAR_13--;",
"}",
"if (s->nmean == 0)\ncoffset = s->offset[VAR_14][0];",
"else {",
"int32_t sum = (s->version < 2) ? 0 : s->nmean / 2;",
"for (VAR_6 = 0; VAR_6 < s->nmean; VAR_6++)",
"sum += s->offset[VAR_14][VAR_6];",
"coffset = sum / s->nmean;",
"if (s->version >= 2)\ncoffset = s->bitshift == 0 ? coffset : coffset >> s->bitshift - 1 >> 1;",
"}",
"if (VAR_10 == FN_ZERO) {",
"for (VAR_6 = 0; VAR_6 < s->VAR_12; VAR_6++)",
"s->decoded[VAR_14][VAR_6] = 0;",
"} else {",
"if ((VAR_8 = decode_subframe_lpc(s, VAR_10, VAR_14,\nVAR_13, coffset)) < 0)\nreturn VAR_8;",
"}",
"if (s->nmean > 0) {",
"int32_t sum = (s->version < 2) ? 0 : s->VAR_12 / 2;",
"for (VAR_6 = 0; VAR_6 < s->VAR_12; VAR_6++)",
"sum += s->decoded[VAR_14][VAR_6];",
"for (VAR_6 = 1; VAR_6 < s->nmean; VAR_6++)",
"s->offset[VAR_14][VAR_6 - 1] = s->offset[VAR_14][VAR_6];",
"if (s->version < 2)\ns->offset[VAR_14][s->nmean - 1] = sum / s->VAR_12;",
"else\ns->offset[VAR_14][s->nmean - 1] = (sum / s->VAR_12) << s->bitshift;",
"}",
"for (VAR_6 = -s->nwrap; VAR_6 < 0; VAR_6++)",
"s->decoded[VAR_14][VAR_6] = s->decoded[VAR_14][VAR_6 + s->VAR_12];",
"fix_bitshift(s, s->decoded[VAR_14]);",
"s->cur_chan++;",
"if (s->cur_chan == s->channels) {",
"uint8_t *samples_u8;",
"int16_t *samples_s16;",
"int VAR_15;",
"frame->nb_samples = s->VAR_12;",
"if ((VAR_8 = ff_get_buffer(VAR_0, frame, 0)) < 0)\nreturn VAR_8;",
"for (VAR_15 = 0; VAR_15 < s->channels; VAR_15++) {",
"samples_u8 = ((uint8_t **)frame->extended_data)[VAR_15];",
"samples_s16 = ((int16_t **)frame->extended_data)[VAR_15];",
"for (VAR_6 = 0; VAR_6 < s->VAR_12; VAR_6++) {",
"switch (s->internal_ftype) {",
"case TYPE_U8:\n*samples_u8++ = av_clip_uint8(s->decoded[VAR_15][VAR_6]);",
"break;",
"case TYPE_S16HL:\ncase TYPE_S16LH:\n*samples_s16++ = av_clip_int16(s->decoded[VAR_15][VAR_6]);",
"break;",
"}",
"}",
"}",
"*VAR_2 = 1;",
"}",
"}",
"}",
"if (s->cur_chan < s->channels)\n*VAR_2 = 0;",
"finish_frame:\ns->bitindex = get_bits_count(&s->gb) - 8 * (get_bits_count(&s->gb) / 8);",
"VAR_6 = get_bits_count(&s->gb) / 8;",
"if (VAR_6 > VAR_5) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \"overread: %d\\n\", VAR_6 - VAR_5);",
"s->bitstream_size = 0;",
"s->bitstream_index = 0;",
"return AVERROR_INVALIDDATA;",
"}",
"if (s->bitstream_size) {",
"s->bitstream_index += VAR_6;",
"s->bitstream_size -= VAR_6;",
"return VAR_7;",
"} else",
"return VAR_6;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
49
],
[
51
],
[
53
],
[
57,
59
],
[
61,
63
],
[
65
],
[
67
],
[
69,
71,
73
],
[
75
],
[
77
],
[
79
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
107
],
[
109,
111
],
[
113
],
[
115
],
[
117
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169
],
[
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
],
[
241
],
[
243
],
[
245
],
[
251
],
[
253
],
[
259,
261
],
[
263
],
[
269,
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283,
285
],
[
287
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301,
303,
305
],
[
307
],
[
313
],
[
315
],
[
317
],
[
319
],
[
323
],
[
325
],
[
329,
331
],
[
333,
335
],
[
337
],
[
343
],
[
345
],
[
353
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
373
],
[
375,
377
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391,
393
],
[
395
],
[
397,
399,
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421,
423
],
[
427,
429
],
[
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
449
],
[
451
],
[
453
],
[
455
],
[
457
]
] |
27,033 | int64_t ff_lsb2full(StreamContext *stream, int64_t lsb){
int64_t mask = (1<<stream->msb_pts_shift)-1;
int64_t delta= stream->last_pts - mask/2;
return ((lsb - delta)&mask) + delta;
}
| true | FFmpeg | de6c150444159a26fe2555089d384ddd2d6459aa | int64_t ff_lsb2full(StreamContext *stream, int64_t lsb){
int64_t mask = (1<<stream->msb_pts_shift)-1;
int64_t delta= stream->last_pts - mask/2;
return ((lsb - delta)&mask) + delta;
}
| {
"code": [
" int64_t mask = (1<<stream->msb_pts_shift)-1;"
],
"line_no": [
3
]
} | int64_t FUNC_0(StreamContext *stream, int64_t lsb){
int64_t mask = (1<<stream->msb_pts_shift)-1;
int64_t delta= stream->last_pts - mask/2;
return ((lsb - delta)&mask) + delta;
}
| [
"int64_t FUNC_0(StreamContext *stream, int64_t lsb){",
"int64_t mask = (1<<stream->msb_pts_shift)-1;",
"int64_t delta= stream->last_pts - mask/2;",
"return ((lsb - delta)&mask) + delta;",
"}"
] | [
0,
1,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
]
] |
27,034 | long do_sigreturn(CPUAlphaState *env)
{
struct target_sigcontext *sc;
abi_ulong sc_addr = env->ir[IR_A0];
target_sigset_t target_set;
sigset_t set;
if (!lock_user_struct(VERIFY_READ, sc, sc_addr, 1)) {
goto badframe;
}
target_sigemptyset(&target_set);
if (__get_user(target_set.sig[0], &sc->sc_mask)) {
goto badframe;
}
target_to_host_sigset_internal(&set, &target_set);
do_sigprocmask(SIG_SETMASK, &set, NULL);
if (restore_sigcontext(env, sc)) {
goto badframe;
}
unlock_user_struct(sc, sc_addr, 0);
return env->ir[IR_V0];
badframe:
unlock_user_struct(sc, sc_addr, 0);
force_sig(TARGET_SIGSEGV);
}
| true | qemu | 016d2e1dfa21b64a524d3629fdd317d4c25bc3b8 | long do_sigreturn(CPUAlphaState *env)
{
struct target_sigcontext *sc;
abi_ulong sc_addr = env->ir[IR_A0];
target_sigset_t target_set;
sigset_t set;
if (!lock_user_struct(VERIFY_READ, sc, sc_addr, 1)) {
goto badframe;
}
target_sigemptyset(&target_set);
if (__get_user(target_set.sig[0], &sc->sc_mask)) {
goto badframe;
}
target_to_host_sigset_internal(&set, &target_set);
do_sigprocmask(SIG_SETMASK, &set, NULL);
if (restore_sigcontext(env, sc)) {
goto badframe;
}
unlock_user_struct(sc, sc_addr, 0);
return env->ir[IR_V0];
badframe:
unlock_user_struct(sc, sc_addr, 0);
force_sig(TARGET_SIGSEGV);
}
| {
"code": [
" goto badframe;",
" goto badframe;",
" goto badframe;",
" goto badframe;",
" if (restore_sigcontext(env, sc)) {",
" goto badframe;",
" goto badframe;"
],
"line_no": [
17,
17,
17,
17,
39,
17,
17
]
} | long FUNC_0(CPUAlphaState *VAR_0)
{
struct target_sigcontext *VAR_1;
abi_ulong sc_addr = VAR_0->ir[IR_A0];
target_sigset_t target_set;
sigset_t set;
if (!lock_user_struct(VERIFY_READ, VAR_1, sc_addr, 1)) {
goto badframe;
}
target_sigemptyset(&target_set);
if (__get_user(target_set.sig[0], &VAR_1->sc_mask)) {
goto badframe;
}
target_to_host_sigset_internal(&set, &target_set);
do_sigprocmask(SIG_SETMASK, &set, NULL);
if (restore_sigcontext(VAR_0, VAR_1)) {
goto badframe;
}
unlock_user_struct(VAR_1, sc_addr, 0);
return VAR_0->ir[IR_V0];
badframe:
unlock_user_struct(VAR_1, sc_addr, 0);
force_sig(TARGET_SIGSEGV);
}
| [
"long FUNC_0(CPUAlphaState *VAR_0)\n{",
"struct target_sigcontext *VAR_1;",
"abi_ulong sc_addr = VAR_0->ir[IR_A0];",
"target_sigset_t target_set;",
"sigset_t set;",
"if (!lock_user_struct(VERIFY_READ, VAR_1, sc_addr, 1)) {",
"goto badframe;",
"}",
"target_sigemptyset(&target_set);",
"if (__get_user(target_set.sig[0], &VAR_1->sc_mask)) {",
"goto badframe;",
"}",
"target_to_host_sigset_internal(&set, &target_set);",
"do_sigprocmask(SIG_SETMASK, &set, NULL);",
"if (restore_sigcontext(VAR_0, VAR_1)) {",
"goto badframe;",
"}",
"unlock_user_struct(VAR_1, sc_addr, 0);",
"return VAR_0->ir[IR_V0];",
"badframe:\nunlock_user_struct(VAR_1, sc_addr, 0);",
"force_sig(TARGET_SIGSEGV);",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51,
53
],
[
55
],
[
57
]
] |
27,035 | static void coroutine_fn wait_serialising_requests(BdrvTrackedRequest *self)
{
BlockDriverState *bs = self->bs;
BdrvTrackedRequest *req;
bool retry;
if (!bs->serialising_in_flight) {
return;
}
do {
retry = false;
QLIST_FOREACH(req, &bs->tracked_requests, list) {
if (req == self || (!req->serialising && !self->serialising)) {
continue;
}
if (tracked_request_overlaps(req, self->overlap_offset,
self->overlap_bytes))
{
/* Hitting this means there was a reentrant request, for
* example, a block driver issuing nested requests. This must
* never happen since it means deadlock.
*/
assert(qemu_coroutine_self() != req->co);
qemu_co_queue_wait(&req->wait_queue);
retry = true;
break;
}
}
} while (retry);
}
| true | qemu | 6460440f34c709461b84375cfd8a86b27d433225 | static void coroutine_fn wait_serialising_requests(BdrvTrackedRequest *self)
{
BlockDriverState *bs = self->bs;
BdrvTrackedRequest *req;
bool retry;
if (!bs->serialising_in_flight) {
return;
}
do {
retry = false;
QLIST_FOREACH(req, &bs->tracked_requests, list) {
if (req == self || (!req->serialising && !self->serialising)) {
continue;
}
if (tracked_request_overlaps(req, self->overlap_offset,
self->overlap_bytes))
{
assert(qemu_coroutine_self() != req->co);
qemu_co_queue_wait(&req->wait_queue);
retry = true;
break;
}
}
} while (retry);
}
| {
"code": [
" qemu_co_queue_wait(&req->wait_queue);",
" retry = true;",
" break;"
],
"line_no": [
51,
53,
55
]
} | static void VAR_0 wait_serialising_requests(BdrvTrackedRequest *self)
{
BlockDriverState *bs = self->bs;
BdrvTrackedRequest *req;
bool retry;
if (!bs->serialising_in_flight) {
return;
}
do {
retry = false;
QLIST_FOREACH(req, &bs->tracked_requests, list) {
if (req == self || (!req->serialising && !self->serialising)) {
continue;
}
if (tracked_request_overlaps(req, self->overlap_offset,
self->overlap_bytes))
{
assert(qemu_coroutine_self() != req->co);
qemu_co_queue_wait(&req->wait_queue);
retry = true;
break;
}
}
} while (retry);
}
| [
"static void VAR_0 wait_serialising_requests(BdrvTrackedRequest *self)\n{",
"BlockDriverState *bs = self->bs;",
"BdrvTrackedRequest *req;",
"bool retry;",
"if (!bs->serialising_in_flight) {",
"return;",
"}",
"do {",
"retry = false;",
"QLIST_FOREACH(req, &bs->tracked_requests, list) {",
"if (req == self || (!req->serialising && !self->serialising)) {",
"continue;",
"}",
"if (tracked_request_overlaps(req, self->overlap_offset,\nself->overlap_bytes))\n{",
"assert(qemu_coroutine_self() != req->co);",
"qemu_co_queue_wait(&req->wait_queue);",
"retry = true;",
"break;",
"}",
"}",
"} while (retry);",
"}"
] | [
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
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33,
35,
37
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
]
] |
27,037 | void qemu_spice_init(void)
{
QemuOpts *opts = QTAILQ_FIRST(&qemu_spice_opts.head);
const char *password, *str, *x509_dir, *addr,
*x509_key_password = NULL,
*x509_dh_file = NULL,
*tls_ciphers = NULL;
char *x509_key_file = NULL,
*x509_cert_file = NULL,
*x509_cacert_file = NULL;
int port, tls_port, len, addr_flags;
spice_image_compression_t compression;
spice_wan_compression_t wan_compr;
if (!opts) {
return;
port = qemu_opt_get_number(opts, "port", 0);
tls_port = qemu_opt_get_number(opts, "tls-port", 0);
if (!port && !tls_port) {
return;
password = qemu_opt_get(opts, "password");
if (tls_port) {
x509_dir = qemu_opt_get(opts, "x509-dir");
if (NULL == x509_dir) {
x509_dir = ".";
len = strlen(x509_dir) + 32;
str = qemu_opt_get(opts, "x509-key-file");
if (str) {
x509_key_file = qemu_strdup(str);
} else {
x509_key_file = qemu_malloc(len);
snprintf(x509_key_file, len, "%s/%s", x509_dir, X509_SERVER_KEY_FILE);
str = qemu_opt_get(opts, "x509-cert-file");
if (str) {
x509_cert_file = qemu_strdup(str);
} else {
x509_cert_file = qemu_malloc(len);
snprintf(x509_cert_file, len, "%s/%s", x509_dir, X509_SERVER_CERT_FILE);
str = qemu_opt_get(opts, "x509-cacert-file");
if (str) {
x509_cacert_file = qemu_strdup(str);
} else {
x509_cacert_file = qemu_malloc(len);
snprintf(x509_cacert_file, len, "%s/%s", x509_dir, X509_CA_CERT_FILE);
x509_key_password = qemu_opt_get(opts, "x509-key-password");
x509_dh_file = qemu_opt_get(opts, "x509-dh-file");
tls_ciphers = qemu_opt_get(opts, "tls-ciphers");
addr = qemu_opt_get(opts, "addr");
addr_flags = 0;
if (qemu_opt_get_bool(opts, "ipv4", 0)) {
addr_flags |= SPICE_ADDR_FLAG_IPV4_ONLY;
} else if (qemu_opt_get_bool(opts, "ipv6", 0)) {
addr_flags |= SPICE_ADDR_FLAG_IPV6_ONLY;
spice_server = spice_server_new();
spice_server_set_addr(spice_server, addr ? addr : "", addr_flags);
if (port) {
spice_server_set_port(spice_server, port);
if (tls_port) {
spice_server_set_tls(spice_server, tls_port,
x509_cacert_file,
x509_cert_file,
x509_key_file,
x509_key_password,
x509_dh_file,
tls_ciphers);
if (password) {
spice_server_set_ticket(spice_server, password, 0, 0, 0);
if (qemu_opt_get_bool(opts, "disable-ticketing", 0)) {
auth = "none";
spice_server_set_noauth(spice_server);
#if SPICE_SERVER_VERSION >= 0x000801
if (qemu_opt_get_bool(opts, "disable-copy-paste", 0)) {
spice_server_set_agent_copypaste(spice_server, false);
compression = SPICE_IMAGE_COMPRESS_AUTO_GLZ;
str = qemu_opt_get(opts, "image-compression");
if (str) {
compression = parse_compression(str);
spice_server_set_image_compression(spice_server, compression);
wan_compr = SPICE_WAN_COMPRESSION_AUTO;
str = qemu_opt_get(opts, "jpeg-wan-compression");
if (str) {
wan_compr = parse_wan_compression(str);
spice_server_set_jpeg_compression(spice_server, wan_compr);
wan_compr = SPICE_WAN_COMPRESSION_AUTO;
str = qemu_opt_get(opts, "zlib-glz-wan-compression");
if (str) {
wan_compr = parse_wan_compression(str);
spice_server_set_zlib_glz_compression(spice_server, wan_compr);
#if SPICE_SERVER_VERSION >= 0x000600 /* 0.6.0 */
str = qemu_opt_get(opts, "streaming-video");
if (str) {
int streaming_video = parse_stream_video(str);
spice_server_set_streaming_video(spice_server, streaming_video);
spice_server_set_agent_mouse
(spice_server, qemu_opt_get_bool(opts, "agent-mouse", 1));
spice_server_set_playback_compression
(spice_server, qemu_opt_get_bool(opts, "playback-compression", 1));
#endif /* >= 0.6.0 */
qemu_opt_foreach(opts, add_channel, NULL, 0);
spice_server_init(spice_server, &core_interface);
using_spice = 1;
migration_state.notify = migration_state_notifier;
add_migration_state_change_notifier(&migration_state);
qemu_spice_input_init();
qemu_spice_audio_init();
qemu_free(x509_key_file);
qemu_free(x509_cert_file);
qemu_free(x509_cacert_file);
| true | qemu | 48b3ed0a68b8c1b288b4e15743ea39b7b5b318c3 | void qemu_spice_init(void)
{
QemuOpts *opts = QTAILQ_FIRST(&qemu_spice_opts.head);
const char *password, *str, *x509_dir, *addr,
*x509_key_password = NULL,
*x509_dh_file = NULL,
*tls_ciphers = NULL;
char *x509_key_file = NULL,
*x509_cert_file = NULL,
*x509_cacert_file = NULL;
int port, tls_port, len, addr_flags;
spice_image_compression_t compression;
spice_wan_compression_t wan_compr;
if (!opts) {
return;
port = qemu_opt_get_number(opts, "port", 0);
tls_port = qemu_opt_get_number(opts, "tls-port", 0);
if (!port && !tls_port) {
return;
password = qemu_opt_get(opts, "password");
if (tls_port) {
x509_dir = qemu_opt_get(opts, "x509-dir");
if (NULL == x509_dir) {
x509_dir = ".";
len = strlen(x509_dir) + 32;
str = qemu_opt_get(opts, "x509-key-file");
if (str) {
x509_key_file = qemu_strdup(str);
} else {
x509_key_file = qemu_malloc(len);
snprintf(x509_key_file, len, "%s/%s", x509_dir, X509_SERVER_KEY_FILE);
str = qemu_opt_get(opts, "x509-cert-file");
if (str) {
x509_cert_file = qemu_strdup(str);
} else {
x509_cert_file = qemu_malloc(len);
snprintf(x509_cert_file, len, "%s/%s", x509_dir, X509_SERVER_CERT_FILE);
str = qemu_opt_get(opts, "x509-cacert-file");
if (str) {
x509_cacert_file = qemu_strdup(str);
} else {
x509_cacert_file = qemu_malloc(len);
snprintf(x509_cacert_file, len, "%s/%s", x509_dir, X509_CA_CERT_FILE);
x509_key_password = qemu_opt_get(opts, "x509-key-password");
x509_dh_file = qemu_opt_get(opts, "x509-dh-file");
tls_ciphers = qemu_opt_get(opts, "tls-ciphers");
addr = qemu_opt_get(opts, "addr");
addr_flags = 0;
if (qemu_opt_get_bool(opts, "ipv4", 0)) {
addr_flags |= SPICE_ADDR_FLAG_IPV4_ONLY;
} else if (qemu_opt_get_bool(opts, "ipv6", 0)) {
addr_flags |= SPICE_ADDR_FLAG_IPV6_ONLY;
spice_server = spice_server_new();
spice_server_set_addr(spice_server, addr ? addr : "", addr_flags);
if (port) {
spice_server_set_port(spice_server, port);
if (tls_port) {
spice_server_set_tls(spice_server, tls_port,
x509_cacert_file,
x509_cert_file,
x509_key_file,
x509_key_password,
x509_dh_file,
tls_ciphers);
if (password) {
spice_server_set_ticket(spice_server, password, 0, 0, 0);
if (qemu_opt_get_bool(opts, "disable-ticketing", 0)) {
auth = "none";
spice_server_set_noauth(spice_server);
#if SPICE_SERVER_VERSION >= 0x000801
if (qemu_opt_get_bool(opts, "disable-copy-paste", 0)) {
spice_server_set_agent_copypaste(spice_server, false);
compression = SPICE_IMAGE_COMPRESS_AUTO_GLZ;
str = qemu_opt_get(opts, "image-compression");
if (str) {
compression = parse_compression(str);
spice_server_set_image_compression(spice_server, compression);
wan_compr = SPICE_WAN_COMPRESSION_AUTO;
str = qemu_opt_get(opts, "jpeg-wan-compression");
if (str) {
wan_compr = parse_wan_compression(str);
spice_server_set_jpeg_compression(spice_server, wan_compr);
wan_compr = SPICE_WAN_COMPRESSION_AUTO;
str = qemu_opt_get(opts, "zlib-glz-wan-compression");
if (str) {
wan_compr = parse_wan_compression(str);
spice_server_set_zlib_glz_compression(spice_server, wan_compr);
#if SPICE_SERVER_VERSION >= 0x000600
str = qemu_opt_get(opts, "streaming-video");
if (str) {
int streaming_video = parse_stream_video(str);
spice_server_set_streaming_video(spice_server, streaming_video);
spice_server_set_agent_mouse
(spice_server, qemu_opt_get_bool(opts, "agent-mouse", 1));
spice_server_set_playback_compression
(spice_server, qemu_opt_get_bool(opts, "playback-compression", 1));
#endif
qemu_opt_foreach(opts, add_channel, NULL, 0);
spice_server_init(spice_server, &core_interface);
using_spice = 1;
migration_state.notify = migration_state_notifier;
add_migration_state_change_notifier(&migration_state);
qemu_spice_input_init();
qemu_spice_audio_init();
qemu_free(x509_key_file);
qemu_free(x509_cert_file);
qemu_free(x509_cacert_file);
| {
"code": [],
"line_no": []
} | void FUNC_0(void)
{
QemuOpts *opts = QTAILQ_FIRST(&qemu_spice_opts.head);
const char *VAR_0, *VAR_1, *VAR_2, *VAR_3,
*VAR_4 = NULL,
*VAR_5 = NULL,
*VAR_6 = NULL;
char *VAR_7 = NULL,
*VAR_8 = NULL,
*VAR_9 = NULL;
int VAR_10, VAR_11, VAR_12, VAR_13;
spice_image_compression_t compression;
spice_wan_compression_t wan_compr;
if (!opts) {
return;
VAR_10 = qemu_opt_get_number(opts, "VAR_10", 0);
VAR_11 = qemu_opt_get_number(opts, "tls-VAR_10", 0);
if (!VAR_10 && !VAR_11) {
return;
VAR_0 = qemu_opt_get(opts, "VAR_0");
if (VAR_11) {
VAR_2 = qemu_opt_get(opts, "x509-dir");
if (NULL == VAR_2) {
VAR_2 = ".";
VAR_12 = strlen(VAR_2) + 32;
VAR_1 = qemu_opt_get(opts, "x509-key-file");
if (VAR_1) {
VAR_7 = qemu_strdup(VAR_1);
} else {
VAR_7 = qemu_malloc(VAR_12);
snprintf(VAR_7, VAR_12, "%s/%s", VAR_2, X509_SERVER_KEY_FILE);
VAR_1 = qemu_opt_get(opts, "x509-cert-file");
if (VAR_1) {
VAR_8 = qemu_strdup(VAR_1);
} else {
VAR_8 = qemu_malloc(VAR_12);
snprintf(VAR_8, VAR_12, "%s/%s", VAR_2, X509_SERVER_CERT_FILE);
VAR_1 = qemu_opt_get(opts, "x509-cacert-file");
if (VAR_1) {
VAR_9 = qemu_strdup(VAR_1);
} else {
VAR_9 = qemu_malloc(VAR_12);
snprintf(VAR_9, VAR_12, "%s/%s", VAR_2, X509_CA_CERT_FILE);
VAR_4 = qemu_opt_get(opts, "x509-key-VAR_0");
VAR_5 = qemu_opt_get(opts, "x509-dh-file");
VAR_6 = qemu_opt_get(opts, "tls-ciphers");
VAR_3 = qemu_opt_get(opts, "VAR_3");
VAR_13 = 0;
if (qemu_opt_get_bool(opts, "ipv4", 0)) {
VAR_13 |= SPICE_ADDR_FLAG_IPV4_ONLY;
} else if (qemu_opt_get_bool(opts, "ipv6", 0)) {
VAR_13 |= SPICE_ADDR_FLAG_IPV6_ONLY;
spice_server = spice_server_new();
spice_server_set_addr(spice_server, VAR_3 ? VAR_3 : "", VAR_13);
if (VAR_10) {
spice_server_set_port(spice_server, VAR_10);
if (VAR_11) {
spice_server_set_tls(spice_server, VAR_11,
VAR_9,
VAR_8,
VAR_7,
VAR_4,
VAR_5,
VAR_6);
if (VAR_0) {
spice_server_set_ticket(spice_server, VAR_0, 0, 0, 0);
if (qemu_opt_get_bool(opts, "disable-ticketing", 0)) {
auth = "none";
spice_server_set_noauth(spice_server);
#if SPICE_SERVER_VERSION >= 0x000801
if (qemu_opt_get_bool(opts, "disable-copy-paste", 0)) {
spice_server_set_agent_copypaste(spice_server, false);
compression = SPICE_IMAGE_COMPRESS_AUTO_GLZ;
VAR_1 = qemu_opt_get(opts, "image-compression");
if (VAR_1) {
compression = parse_compression(VAR_1);
spice_server_set_image_compression(spice_server, compression);
wan_compr = SPICE_WAN_COMPRESSION_AUTO;
VAR_1 = qemu_opt_get(opts, "jpeg-wan-compression");
if (VAR_1) {
wan_compr = parse_wan_compression(VAR_1);
spice_server_set_jpeg_compression(spice_server, wan_compr);
wan_compr = SPICE_WAN_COMPRESSION_AUTO;
VAR_1 = qemu_opt_get(opts, "zlib-glz-wan-compression");
if (VAR_1) {
wan_compr = parse_wan_compression(VAR_1);
spice_server_set_zlib_glz_compression(spice_server, wan_compr);
#if SPICE_SERVER_VERSION >= 0x000600
VAR_1 = qemu_opt_get(opts, "streaming-video");
if (VAR_1) {
int streaming_video = parse_stream_video(VAR_1);
spice_server_set_streaming_video(spice_server, streaming_video);
spice_server_set_agent_mouse
(spice_server, qemu_opt_get_bool(opts, "agent-mouse", 1));
spice_server_set_playback_compression
(spice_server, qemu_opt_get_bool(opts, "playback-compression", 1));
#endif
qemu_opt_foreach(opts, add_channel, NULL, 0);
spice_server_init(spice_server, &core_interface);
using_spice = 1;
migration_state.notify = migration_state_notifier;
add_migration_state_change_notifier(&migration_state);
qemu_spice_input_init();
qemu_spice_audio_init();
qemu_free(VAR_7);
qemu_free(VAR_8);
qemu_free(VAR_9);
| [
"void FUNC_0(void)\n{",
"QemuOpts *opts = QTAILQ_FIRST(&qemu_spice_opts.head);",
"const char *VAR_0, *VAR_1, *VAR_2, *VAR_3,\n*VAR_4 = NULL,\n*VAR_5 = NULL,\n*VAR_6 = NULL;",
"char *VAR_7 = NULL,\n*VAR_8 = NULL,\n*VAR_9 = NULL;",
"int VAR_10, VAR_11, VAR_12, VAR_13;",
"spice_image_compression_t compression;",
"spice_wan_compression_t wan_compr;",
"if (!opts) {",
"return;",
"VAR_10 = qemu_opt_get_number(opts, \"VAR_10\", 0);",
"VAR_11 = qemu_opt_get_number(opts, \"tls-VAR_10\", 0);",
"if (!VAR_10 && !VAR_11) {",
"return;",
"VAR_0 = qemu_opt_get(opts, \"VAR_0\");",
"if (VAR_11) {",
"VAR_2 = qemu_opt_get(opts, \"x509-dir\");",
"if (NULL == VAR_2) {",
"VAR_2 = \".\";",
"VAR_12 = strlen(VAR_2) + 32;",
"VAR_1 = qemu_opt_get(opts, \"x509-key-file\");",
"if (VAR_1) {",
"VAR_7 = qemu_strdup(VAR_1);",
"} else {",
"VAR_7 = qemu_malloc(VAR_12);",
"snprintf(VAR_7, VAR_12, \"%s/%s\", VAR_2, X509_SERVER_KEY_FILE);",
"VAR_1 = qemu_opt_get(opts, \"x509-cert-file\");",
"if (VAR_1) {",
"VAR_8 = qemu_strdup(VAR_1);",
"} else {",
"VAR_8 = qemu_malloc(VAR_12);",
"snprintf(VAR_8, VAR_12, \"%s/%s\", VAR_2, X509_SERVER_CERT_FILE);",
"VAR_1 = qemu_opt_get(opts, \"x509-cacert-file\");",
"if (VAR_1) {",
"VAR_9 = qemu_strdup(VAR_1);",
"} else {",
"VAR_9 = qemu_malloc(VAR_12);",
"snprintf(VAR_9, VAR_12, \"%s/%s\", VAR_2, X509_CA_CERT_FILE);",
"VAR_4 = qemu_opt_get(opts, \"x509-key-VAR_0\");",
"VAR_5 = qemu_opt_get(opts, \"x509-dh-file\");",
"VAR_6 = qemu_opt_get(opts, \"tls-ciphers\");",
"VAR_3 = qemu_opt_get(opts, \"VAR_3\");",
"VAR_13 = 0;",
"if (qemu_opt_get_bool(opts, \"ipv4\", 0)) {",
"VAR_13 |= SPICE_ADDR_FLAG_IPV4_ONLY;",
"} else if (qemu_opt_get_bool(opts, \"ipv6\", 0)) {",
"VAR_13 |= SPICE_ADDR_FLAG_IPV6_ONLY;",
"spice_server = spice_server_new();",
"spice_server_set_addr(spice_server, VAR_3 ? VAR_3 : \"\", VAR_13);",
"if (VAR_10) {",
"spice_server_set_port(spice_server, VAR_10);",
"if (VAR_11) {",
"spice_server_set_tls(spice_server, VAR_11,\nVAR_9,\nVAR_8,\nVAR_7,\nVAR_4,\nVAR_5,\nVAR_6);",
"if (VAR_0) {",
"spice_server_set_ticket(spice_server, VAR_0, 0, 0, 0);",
"if (qemu_opt_get_bool(opts, \"disable-ticketing\", 0)) {",
"auth = \"none\";",
"spice_server_set_noauth(spice_server);",
"#if SPICE_SERVER_VERSION >= 0x000801\nif (qemu_opt_get_bool(opts, \"disable-copy-paste\", 0)) {",
"spice_server_set_agent_copypaste(spice_server, false);",
"compression = SPICE_IMAGE_COMPRESS_AUTO_GLZ;",
"VAR_1 = qemu_opt_get(opts, \"image-compression\");",
"if (VAR_1) {",
"compression = parse_compression(VAR_1);",
"spice_server_set_image_compression(spice_server, compression);",
"wan_compr = SPICE_WAN_COMPRESSION_AUTO;",
"VAR_1 = qemu_opt_get(opts, \"jpeg-wan-compression\");",
"if (VAR_1) {",
"wan_compr = parse_wan_compression(VAR_1);",
"spice_server_set_jpeg_compression(spice_server, wan_compr);",
"wan_compr = SPICE_WAN_COMPRESSION_AUTO;",
"VAR_1 = qemu_opt_get(opts, \"zlib-glz-wan-compression\");",
"if (VAR_1) {",
"wan_compr = parse_wan_compression(VAR_1);",
"spice_server_set_zlib_glz_compression(spice_server, wan_compr);",
"#if SPICE_SERVER_VERSION >= 0x000600\nVAR_1 = qemu_opt_get(opts, \"streaming-video\");",
"if (VAR_1) {",
"int streaming_video = parse_stream_video(VAR_1);",
"spice_server_set_streaming_video(spice_server, streaming_video);",
"spice_server_set_agent_mouse\n(spice_server, qemu_opt_get_bool(opts, \"agent-mouse\", 1));",
"spice_server_set_playback_compression\n(spice_server, qemu_opt_get_bool(opts, \"playback-compression\", 1));",
"#endif\nqemu_opt_foreach(opts, add_channel, NULL, 0);",
"spice_server_init(spice_server, &core_interface);",
"using_spice = 1;",
"migration_state.notify = migration_state_notifier;",
"add_migration_state_change_notifier(&migration_state);",
"qemu_spice_input_init();",
"qemu_spice_audio_init();",
"qemu_free(VAR_7);",
"qemu_free(VAR_8);",
"qemu_free(VAR_9);"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9,
11,
13
],
[
15,
17,
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
34
],
[
36
],
[
38
],
[
40
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
56
],
[
60
],
[
62
],
[
64
],
[
66
],
[
68
],
[
70
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
90
],
[
92
],
[
94
],
[
96
],
[
98
],
[
100
],
[
105
],
[
107
],
[
109
],
[
114
],
[
116
],
[
118
],
[
120
],
[
122
],
[
124
],
[
129
],
[
131
],
[
133
],
[
135
],
[
138
],
[
140,
142,
144,
146,
148,
150,
152
],
[
155
],
[
157
],
[
172
],
[
174
],
[
176
],
[
181,
183
],
[
185
],
[
191
],
[
193
],
[
195
],
[
197
],
[
200
],
[
204
],
[
206
],
[
208
],
[
210
],
[
213
],
[
217
],
[
219
],
[
221
],
[
223
],
[
226
],
[
230,
234
],
[
236
],
[
238
],
[
240
],
[
245,
247
],
[
249,
251
],
[
255,
259
],
[
263
],
[
265
],
[
269
],
[
271
],
[
275
],
[
277
],
[
281
],
[
283
],
[
285
]
] |
27,038 | void do_store_601_batu (int nr)
{
do_store_ibatu(env, nr, T0);
env->DBAT[0][nr] = env->IBAT[0][nr];
env->DBAT[1][nr] = env->IBAT[1][nr];
}
| true | qemu | d9bce9d99f4656ae0b0127f7472db9067b8f84ab | void do_store_601_batu (int nr)
{
do_store_ibatu(env, nr, T0);
env->DBAT[0][nr] = env->IBAT[0][nr];
env->DBAT[1][nr] = env->IBAT[1][nr];
}
| {
"code": [
" do_store_ibatu(env, nr, T0);"
],
"line_no": [
5
]
} | void FUNC_0 (int VAR_0)
{
do_store_ibatu(env, VAR_0, T0);
env->DBAT[0][VAR_0] = env->IBAT[0][VAR_0];
env->DBAT[1][VAR_0] = env->IBAT[1][VAR_0];
}
| [
"void FUNC_0 (int VAR_0)\n{",
"do_store_ibatu(env, VAR_0, T0);",
"env->DBAT[0][VAR_0] = env->IBAT[0][VAR_0];",
"env->DBAT[1][VAR_0] = env->IBAT[1][VAR_0];",
"}"
] | [
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
27,039 | static void dp8393x_realize(DeviceState *dev, Error **errp)
{
dp8393xState *s = DP8393X(dev);
int i, checksum;
uint8_t *prom;
address_space_init(&s->as, s->dma_mr, "dp8393x");
memory_region_init_io(&s->mmio, OBJECT(dev), &dp8393x_ops, s,
"dp8393x-regs", 0x40 << s->it_shift);
s->nic = qemu_new_nic(&net_dp83932_info, &s->conf,
object_get_typename(OBJECT(dev)), dev->id, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
s->watchdog = timer_new_ns(QEMU_CLOCK_VIRTUAL, dp8393x_watchdog, s);
s->regs[SONIC_SR] = 0x0004; /* only revision recognized by Linux */
memory_region_init_rom_device(&s->prom, OBJECT(dev), NULL, NULL,
"dp8393x-prom", SONIC_PROM_SIZE, NULL);
prom = memory_region_get_ram_ptr(&s->prom);
checksum = 0;
for (i = 0; i < 6; i++) {
prom[i] = s->conf.macaddr.a[i];
checksum += prom[i];
if (checksum > 0xff) {
checksum = (checksum + 1) & 0xff;
}
}
prom[7] = 0xff - checksum;
}
| true | qemu | 52579c681cb12bf64de793e85edc50d990f4d42f | static void dp8393x_realize(DeviceState *dev, Error **errp)
{
dp8393xState *s = DP8393X(dev);
int i, checksum;
uint8_t *prom;
address_space_init(&s->as, s->dma_mr, "dp8393x");
memory_region_init_io(&s->mmio, OBJECT(dev), &dp8393x_ops, s,
"dp8393x-regs", 0x40 << s->it_shift);
s->nic = qemu_new_nic(&net_dp83932_info, &s->conf,
object_get_typename(OBJECT(dev)), dev->id, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
s->watchdog = timer_new_ns(QEMU_CLOCK_VIRTUAL, dp8393x_watchdog, s);
s->regs[SONIC_SR] = 0x0004;
memory_region_init_rom_device(&s->prom, OBJECT(dev), NULL, NULL,
"dp8393x-prom", SONIC_PROM_SIZE, NULL);
prom = memory_region_get_ram_ptr(&s->prom);
checksum = 0;
for (i = 0; i < 6; i++) {
prom[i] = s->conf.macaddr.a[i];
checksum += prom[i];
if (checksum > 0xff) {
checksum = (checksum + 1) & 0xff;
}
}
prom[7] = 0xff - checksum;
}
| {
"code": [
" memory_region_init_rom_device(&s->prom, OBJECT(dev), NULL, NULL,",
" \"dp8393x-prom\", SONIC_PROM_SIZE, NULL);"
],
"line_no": [
35,
37
]
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
dp8393xState *s = DP8393X(VAR_0);
int VAR_2, VAR_3;
uint8_t *prom;
address_space_init(&s->as, s->dma_mr, "dp8393x");
memory_region_init_io(&s->mmio, OBJECT(VAR_0), &dp8393x_ops, s,
"dp8393x-regs", 0x40 << s->it_shift);
s->nic = qemu_new_nic(&net_dp83932_info, &s->conf,
object_get_typename(OBJECT(VAR_0)), VAR_0->id, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
s->watchdog = timer_new_ns(QEMU_CLOCK_VIRTUAL, dp8393x_watchdog, s);
s->regs[SONIC_SR] = 0x0004;
memory_region_init_rom_device(&s->prom, OBJECT(VAR_0), NULL, NULL,
"dp8393x-prom", SONIC_PROM_SIZE, NULL);
prom = memory_region_get_ram_ptr(&s->prom);
VAR_3 = 0;
for (VAR_2 = 0; VAR_2 < 6; VAR_2++) {
prom[VAR_2] = s->conf.macaddr.a[VAR_2];
VAR_3 += prom[VAR_2];
if (VAR_3 > 0xff) {
VAR_3 = (VAR_3 + 1) & 0xff;
}
}
prom[7] = 0xff - VAR_3;
}
| [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"dp8393xState *s = DP8393X(VAR_0);",
"int VAR_2, VAR_3;",
"uint8_t *prom;",
"address_space_init(&s->as, s->dma_mr, \"dp8393x\");",
"memory_region_init_io(&s->mmio, OBJECT(VAR_0), &dp8393x_ops, s,\n\"dp8393x-regs\", 0x40 << s->it_shift);",
"s->nic = qemu_new_nic(&net_dp83932_info, &s->conf,\nobject_get_typename(OBJECT(VAR_0)), VAR_0->id, s);",
"qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);",
"s->watchdog = timer_new_ns(QEMU_CLOCK_VIRTUAL, dp8393x_watchdog, s);",
"s->regs[SONIC_SR] = 0x0004;",
"memory_region_init_rom_device(&s->prom, OBJECT(VAR_0), NULL, NULL,\n\"dp8393x-prom\", SONIC_PROM_SIZE, NULL);",
"prom = memory_region_get_ram_ptr(&s->prom);",
"VAR_3 = 0;",
"for (VAR_2 = 0; VAR_2 < 6; VAR_2++) {",
"prom[VAR_2] = s->conf.macaddr.a[VAR_2];",
"VAR_3 += prom[VAR_2];",
"if (VAR_3 > 0xff) {",
"VAR_3 = (VAR_3 + 1) & 0xff;",
"}",
"}",
"prom[7] = 0xff - VAR_3;",
"}"
] | [
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
],
[
13
],
[
15,
17
],
[
21,
23
],
[
25
],
[
29
],
[
31
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
]
] |
27,040 | void bdrv_round_to_clusters(BlockDriverState *bs,
int64_t offset, unsigned int bytes,
int64_t *cluster_offset,
unsigned int *cluster_bytes)
{
BlockDriverInfo bdi;
if (bdrv_get_info(bs, &bdi) < 0 || bdi.cluster_size == 0) {
*cluster_offset = offset;
*cluster_bytes = bytes;
} else {
int64_t c = bdi.cluster_size;
*cluster_offset = QEMU_ALIGN_DOWN(offset, c);
*cluster_bytes = QEMU_ALIGN_UP(offset - *cluster_offset + bytes, c);
}
}
| true | qemu | 7cfd527525a7d6b1c904890a6b84c1227846415e | void bdrv_round_to_clusters(BlockDriverState *bs,
int64_t offset, unsigned int bytes,
int64_t *cluster_offset,
unsigned int *cluster_bytes)
{
BlockDriverInfo bdi;
if (bdrv_get_info(bs, &bdi) < 0 || bdi.cluster_size == 0) {
*cluster_offset = offset;
*cluster_bytes = bytes;
} else {
int64_t c = bdi.cluster_size;
*cluster_offset = QEMU_ALIGN_DOWN(offset, c);
*cluster_bytes = QEMU_ALIGN_UP(offset - *cluster_offset + bytes, c);
}
}
| {
"code": [
" int64_t offset, unsigned int bytes,",
" unsigned int *cluster_bytes)",
" int64_t offset, unsigned int bytes,"
],
"line_no": [
3,
7,
3
]
} | void FUNC_0(BlockDriverState *VAR_0,
int64_t VAR_1, unsigned int VAR_2,
int64_t *VAR_3,
unsigned int *VAR_4)
{
BlockDriverInfo bdi;
if (bdrv_get_info(VAR_0, &bdi) < 0 || bdi.cluster_size == 0) {
*VAR_3 = VAR_1;
*VAR_4 = VAR_2;
} else {
int64_t c = bdi.cluster_size;
*VAR_3 = QEMU_ALIGN_DOWN(VAR_1, c);
*VAR_4 = QEMU_ALIGN_UP(VAR_1 - *VAR_3 + VAR_2, c);
}
}
| [
"void FUNC_0(BlockDriverState *VAR_0,\nint64_t VAR_1, unsigned int VAR_2,\nint64_t *VAR_3,\nunsigned int *VAR_4)\n{",
"BlockDriverInfo bdi;",
"if (bdrv_get_info(VAR_0, &bdi) < 0 || bdi.cluster_size == 0) {",
"*VAR_3 = VAR_1;",
"*VAR_4 = VAR_2;",
"} else {",
"int64_t c = bdi.cluster_size;",
"*VAR_3 = QEMU_ALIGN_DOWN(VAR_1, c);",
"*VAR_4 = QEMU_ALIGN_UP(VAR_1 - *VAR_3 + VAR_2, c);",
"}",
"}"
] | [
1,
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
]
] |
27,041 | int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush,
int (*get_packet)(AVFormatContext *, AVPacket *, AVPacket *, int),
int (*compare_ts)(AVFormatContext *, AVPacket *, AVPacket *))
{
int i;
if (pkt) {
AVStream *st = s->streams[pkt->stream_index];
AudioInterleaveContext *aic = st->priv_data;
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
unsigned new_size = av_fifo_size(aic->fifo) + pkt->size;
if (new_size > aic->fifo_size) {
if (av_fifo_realloc2(aic->fifo, new_size) < 0)
return -1;
aic->fifo_size = new_size;
}
av_fifo_generic_write(aic->fifo, pkt->data, pkt->size, NULL);
} else {
// rewrite pts and dts to be decoded time line position
pkt->pts = pkt->dts = aic->dts;
aic->dts += pkt->duration;
ff_interleave_add_packet(s, pkt, compare_ts);
}
pkt = NULL;
}
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
AVPacket new_pkt;
while (interleave_new_audio_packet(s, &new_pkt, i, flush))
ff_interleave_add_packet(s, &new_pkt, compare_ts);
}
}
return get_packet(s, out, NULL, flush);
}
| false | FFmpeg | 324ff59444ff5470bb325ff1e2be7c4b054fc944 | int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush,
int (*get_packet)(AVFormatContext *, AVPacket *, AVPacket *, int),
int (*compare_ts)(AVFormatContext *, AVPacket *, AVPacket *))
{
int i;
if (pkt) {
AVStream *st = s->streams[pkt->stream_index];
AudioInterleaveContext *aic = st->priv_data;
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
unsigned new_size = av_fifo_size(aic->fifo) + pkt->size;
if (new_size > aic->fifo_size) {
if (av_fifo_realloc2(aic->fifo, new_size) < 0)
return -1;
aic->fifo_size = new_size;
}
av_fifo_generic_write(aic->fifo, pkt->data, pkt->size, NULL);
} else {
pkt->pts = pkt->dts = aic->dts;
aic->dts += pkt->duration;
ff_interleave_add_packet(s, pkt, compare_ts);
}
pkt = NULL;
}
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
AVPacket new_pkt;
while (interleave_new_audio_packet(s, &new_pkt, i, flush))
ff_interleave_add_packet(s, &new_pkt, compare_ts);
}
}
return get_packet(s, out, NULL, flush);
}
| {
"code": [],
"line_no": []
} | VAR_7intVAR_7 VAR_7ff_audio_rechunk_interleaveVAR_7(VAR_7AVFormatContextVAR_7 *VAR_7VAR_0VAR_7, VAR_7AVPacketVAR_7 *VAR_7VAR_1VAR_7, VAR_7AVPacketVAR_7 *VAR_7VAR_2VAR_7, VAR_7intVAR_7 VAR_7VAR_3VAR_7,
VAR_7intVAR_7 (*VAR_7VAR_4VAR_7)(VAR_7AVFormatContextVAR_7 *, VAR_7AVPacketVAR_7 *, VAR_7AVPacketVAR_7 *, VAR_7intVAR_7),
VAR_7intVAR_7 (*VAR_7compare_tsVAR_7)(VAR_7AVFormatContextVAR_7 *, VAR_7AVPacketVAR_7 *, VAR_7AVPacketVAR_7 *))
{
VAR_7intVAR_7 VAR_7iVAR_7;
VAR_7ifVAR_7 (VAR_7VAR_2VAR_7) {
VAR_7AVStreamVAR_7 *VAR_7stVAR_7 = VAR_7VAR_0VAR_7->VAR_7streamsVAR_7[VAR_7VAR_2VAR_7->VAR_7stream_indexVAR_7];
VAR_7AudioInterleaveContextVAR_7 *VAR_7aicVAR_7 = VAR_7stVAR_7->VAR_7priv_dataVAR_7;
VAR_7ifVAR_7 (VAR_7stVAR_7->VAR_7codecVAR_7->VAR_7codec_typeVAR_7 == VAR_7AVMEDIA_TYPE_AUDIOVAR_7) {
VAR_7unsignedVAR_7 VAR_7new_sizeVAR_7 = VAR_7av_fifo_sizeVAR_7(VAR_7aicVAR_7->VAR_7fifoVAR_7) + VAR_7VAR_2VAR_7->VAR_7sizeVAR_7;
VAR_7ifVAR_7 (VAR_7new_sizeVAR_7 > VAR_7aicVAR_7->VAR_7fifo_sizeVAR_7) {
VAR_7ifVAR_7 (VAR_7av_fifo_realloc2VAR_7(VAR_7aicVAR_7->VAR_7fifoVAR_7, VAR_7new_sizeVAR_7) < VAR_70VAR_7)
VAR_7returnVAR_7 -VAR_71VAR_7;
VAR_7aicVAR_7->VAR_7fifo_sizeVAR_7 = VAR_7new_sizeVAR_7;
}
VAR_7av_fifo_generic_writeVAR_7(VAR_7aicVAR_7->VAR_7fifoVAR_7, VAR_7VAR_2VAR_7->VAR_7dataVAR_7, VAR_7VAR_2VAR_7->VAR_7sizeVAR_7, VAR_7NULLVAR_7);
} VAR_7elseVAR_7 {
VAR_7VAR_2VAR_7->VAR_7ptsVAR_7 = VAR_7VAR_2VAR_7->VAR_7dtsVAR_7 = VAR_7aicVAR_7->VAR_7dtsVAR_7;
VAR_7aicVAR_7->VAR_7dtsVAR_7 += VAR_7VAR_2VAR_7->VAR_7durationVAR_7;
VAR_7ff_interleave_add_packetVAR_7(VAR_7VAR_0VAR_7, VAR_7VAR_2VAR_7, VAR_7compare_tsVAR_7);
}
VAR_7VAR_2VAR_7 = VAR_7NULLVAR_7;
}
VAR_7forVAR_7 (VAR_7iVAR_7 = VAR_70VAR_7; VAR_7iVAR_7 < VAR_7VAR_0VAR_7->VAR_7nb_streamsVAR_7; VAR_7iVAR_7++) {
VAR_7AVStreamVAR_7 *VAR_7stVAR_7 = VAR_7VAR_0VAR_7->VAR_7streamsVAR_7[VAR_7iVAR_7];
VAR_7ifVAR_7 (VAR_7stVAR_7->VAR_7codecVAR_7->VAR_7codec_typeVAR_7 == VAR_7AVMEDIA_TYPE_AUDIOVAR_7) {
VAR_7AVPacketVAR_7 VAR_7new_pktVAR_7;
VAR_7whileVAR_7 (VAR_7interleave_new_audio_packetVAR_7(VAR_7VAR_0VAR_7, &VAR_7new_pktVAR_7, VAR_7iVAR_7, VAR_7VAR_3VAR_7))
VAR_7ff_interleave_add_packetVAR_7(VAR_7VAR_0VAR_7, &VAR_7new_pktVAR_7, VAR_7compare_tsVAR_7);
}
}
VAR_7returnVAR_7 VAR_7VAR_4VAR_7(VAR_7VAR_0VAR_7, VAR_7VAR_1VAR_7, VAR_7NULLVAR_7, VAR_7VAR_3VAR_7);
}
| [
"VAR_7intVAR_7 VAR_7ff_audio_rechunk_interleaveVAR_7(VAR_7AVFormatContextVAR_7 *VAR_7VAR_0VAR_7, VAR_7AVPacketVAR_7 *VAR_7VAR_1VAR_7, VAR_7AVPacketVAR_7 *VAR_7VAR_2VAR_7, VAR_7intVAR_7 VAR_7VAR_3VAR_7,\nVAR_7intVAR_7 (*VAR_7VAR_4VAR_7)(VAR_7AVFormatContextVAR_7 *, VAR_7AVPacketVAR_7 *, VAR_7AVPacketVAR_7 *, VAR_7intVAR_7),\nVAR_7intVAR_7 (*VAR_7compare_tsVAR_7)(VAR_7AVFormatContextVAR_7 *, VAR_7AVPacketVAR_7 *, VAR_7AVPacketVAR_7 *))\n{",
"VAR_7intVAR_7 VAR_7iVAR_7;",
"VAR_7ifVAR_7 (VAR_7VAR_2VAR_7) {",
"VAR_7AVStreamVAR_7 *VAR_7stVAR_7 = VAR_7VAR_0VAR_7->VAR_7streamsVAR_7[VAR_7VAR_2VAR_7->VAR_7stream_indexVAR_7];",
"VAR_7AudioInterleaveContextVAR_7 *VAR_7aicVAR_7 = VAR_7stVAR_7->VAR_7priv_dataVAR_7;",
"VAR_7ifVAR_7 (VAR_7stVAR_7->VAR_7codecVAR_7->VAR_7codec_typeVAR_7 == VAR_7AVMEDIA_TYPE_AUDIOVAR_7) {",
"VAR_7unsignedVAR_7 VAR_7new_sizeVAR_7 = VAR_7av_fifo_sizeVAR_7(VAR_7aicVAR_7->VAR_7fifoVAR_7) + VAR_7VAR_2VAR_7->VAR_7sizeVAR_7;",
"VAR_7ifVAR_7 (VAR_7new_sizeVAR_7 > VAR_7aicVAR_7->VAR_7fifo_sizeVAR_7) {",
"VAR_7ifVAR_7 (VAR_7av_fifo_realloc2VAR_7(VAR_7aicVAR_7->VAR_7fifoVAR_7, VAR_7new_sizeVAR_7) < VAR_70VAR_7)\nVAR_7returnVAR_7 -VAR_71VAR_7;",
"VAR_7aicVAR_7->VAR_7fifo_sizeVAR_7 = VAR_7new_sizeVAR_7;",
"}",
"VAR_7av_fifo_generic_writeVAR_7(VAR_7aicVAR_7->VAR_7fifoVAR_7, VAR_7VAR_2VAR_7->VAR_7dataVAR_7, VAR_7VAR_2VAR_7->VAR_7sizeVAR_7, VAR_7NULLVAR_7);",
"} VAR_7elseVAR_7 {",
"VAR_7VAR_2VAR_7->VAR_7ptsVAR_7 = VAR_7VAR_2VAR_7->VAR_7dtsVAR_7 = VAR_7aicVAR_7->VAR_7dtsVAR_7;",
"VAR_7aicVAR_7->VAR_7dtsVAR_7 += VAR_7VAR_2VAR_7->VAR_7durationVAR_7;",
"VAR_7ff_interleave_add_packetVAR_7(VAR_7VAR_0VAR_7, VAR_7VAR_2VAR_7, VAR_7compare_tsVAR_7);",
"}",
"VAR_7VAR_2VAR_7 = VAR_7NULLVAR_7;",
"}",
"VAR_7forVAR_7 (VAR_7iVAR_7 = VAR_70VAR_7; VAR_7iVAR_7 < VAR_7VAR_0VAR_7->VAR_7nb_streamsVAR_7; VAR_7iVAR_7++) {",
"VAR_7AVStreamVAR_7 *VAR_7stVAR_7 = VAR_7VAR_0VAR_7->VAR_7streamsVAR_7[VAR_7iVAR_7];",
"VAR_7ifVAR_7 (VAR_7stVAR_7->VAR_7codecVAR_7->VAR_7codec_typeVAR_7 == VAR_7AVMEDIA_TYPE_AUDIOVAR_7) {",
"VAR_7AVPacketVAR_7 VAR_7new_pktVAR_7;",
"VAR_7whileVAR_7 (VAR_7interleave_new_audio_packetVAR_7(VAR_7VAR_0VAR_7, &VAR_7new_pktVAR_7, VAR_7iVAR_7, VAR_7VAR_3VAR_7))\nVAR_7ff_interleave_add_packetVAR_7(VAR_7VAR_0VAR_7, &VAR_7new_pktVAR_7, VAR_7compare_tsVAR_7);",
"}",
"}",
"VAR_7returnVAR_7 VAR_7VAR_4VAR_7(VAR_7VAR_0VAR_7, VAR_7VAR_1VAR_7, VAR_7NULLVAR_7, VAR_7VAR_3VAR_7);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
71
],
[
73
]
] |
27,042 | static av_cold int init_decoder(AVCodecContext *avctx)
{
avctx->pix_fmt = PIX_FMT_PAL8;
return 0;
}
| false | FFmpeg | d150a147dac67faeaf6b1f25a523ae330168ee1e | static av_cold int init_decoder(AVCodecContext *avctx)
{
avctx->pix_fmt = PIX_FMT_PAL8;
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
avctx->pix_fmt = PIX_FMT_PAL8;
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"avctx->pix_fmt = PIX_FMT_PAL8;",
"return 0;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
]
] |
27,043 | static void opt_output_file(const char *filename)
{
AVFormatContext *oc;
int err, use_video, use_audio, use_subtitle;
int input_has_video, input_has_audio, input_has_subtitle;
AVFormatParameters params, *ap = ¶ms;
AVOutputFormat *file_oformat;
if (!strcmp(filename, "-"))
filename = "pipe:";
oc = avformat_alloc_context();
if (!oc) {
print_error(filename, AVERROR(ENOMEM));
ffmpeg_exit(1);
}
if (last_asked_format) {
file_oformat = av_guess_format(last_asked_format, NULL, NULL);
if (!file_oformat) {
fprintf(stderr, "Requested output format '%s' is not a suitable output format\n", last_asked_format);
ffmpeg_exit(1);
}
last_asked_format = NULL;
} else {
file_oformat = av_guess_format(NULL, filename, NULL);
if (!file_oformat) {
fprintf(stderr, "Unable to find a suitable output format for '%s'\n",
filename);
ffmpeg_exit(1);
}
}
oc->oformat = file_oformat;
av_strlcpy(oc->filename, filename, sizeof(oc->filename));
if (!strcmp(file_oformat->name, "ffm") &&
av_strstart(filename, "http:", NULL)) {
/* special case for files sent to ffserver: we get the stream
parameters from ffserver */
int err = read_ffserver_streams(oc, filename);
if (err < 0) {
print_error(filename, err);
ffmpeg_exit(1);
}
} else {
use_video = file_oformat->video_codec != CODEC_ID_NONE || video_stream_copy || video_codec_name;
use_audio = file_oformat->audio_codec != CODEC_ID_NONE || audio_stream_copy || audio_codec_name;
use_subtitle = file_oformat->subtitle_codec != CODEC_ID_NONE || subtitle_stream_copy || subtitle_codec_name;
/* disable if no corresponding type found and at least one
input file */
if (nb_input_files > 0) {
check_audio_video_sub_inputs(&input_has_video, &input_has_audio,
&input_has_subtitle);
if (!input_has_video)
use_video = 0;
if (!input_has_audio)
use_audio = 0;
if (!input_has_subtitle)
use_subtitle = 0;
}
/* manual disable */
if (audio_disable) use_audio = 0;
if (video_disable) use_video = 0;
if (subtitle_disable) use_subtitle = 0;
if (use_video) new_video_stream(oc, nb_output_files);
if (use_audio) new_audio_stream(oc, nb_output_files);
if (use_subtitle) new_subtitle_stream(oc, nb_output_files);
oc->timestamp = recording_timestamp;
av_metadata_copy(&oc->metadata, metadata, 0);
av_metadata_free(&metadata);
}
output_files[nb_output_files++] = oc;
/* check filename in case of an image number is expected */
if (oc->oformat->flags & AVFMT_NEEDNUMBER) {
if (!av_filename_number_test(oc->filename)) {
print_error(oc->filename, AVERROR_NUMEXPECTED);
ffmpeg_exit(1);
}
}
if (!(oc->oformat->flags & AVFMT_NOFILE)) {
/* test if it already exists to avoid loosing precious files */
if (!file_overwrite &&
(strchr(filename, ':') == NULL ||
filename[1] == ':' ||
av_strstart(filename, "file:", NULL))) {
if (url_exist(filename)) {
if (!using_stdin) {
fprintf(stderr,"File '%s' already exists. Overwrite ? [y/N] ", filename);
fflush(stderr);
if (!read_yesno()) {
fprintf(stderr, "Not overwriting - exiting\n");
ffmpeg_exit(1);
}
}
else {
fprintf(stderr,"File '%s' already exists. Exiting.\n", filename);
ffmpeg_exit(1);
}
}
}
/* open the file */
if ((err = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE)) < 0) {
print_error(filename, err);
ffmpeg_exit(1);
}
}
memset(ap, 0, sizeof(*ap));
if (av_set_parameters(oc, ap) < 0) {
fprintf(stderr, "%s: Invalid encoding parameters\n",
oc->filename);
ffmpeg_exit(1);
}
oc->preload= (int)(mux_preload*AV_TIME_BASE);
oc->max_delay= (int)(mux_max_delay*AV_TIME_BASE);
oc->loop_output = loop_output;
oc->flags |= AVFMT_FLAG_NONBLOCK;
set_context_opts(oc, avformat_opts, AV_OPT_FLAG_ENCODING_PARAM, NULL);
av_freep(&forced_key_frames);
}
| false | FFmpeg | 55815edca038997ec283569a192a3eca7f2143bc | static void opt_output_file(const char *filename)
{
AVFormatContext *oc;
int err, use_video, use_audio, use_subtitle;
int input_has_video, input_has_audio, input_has_subtitle;
AVFormatParameters params, *ap = ¶ms;
AVOutputFormat *file_oformat;
if (!strcmp(filename, "-"))
filename = "pipe:";
oc = avformat_alloc_context();
if (!oc) {
print_error(filename, AVERROR(ENOMEM));
ffmpeg_exit(1);
}
if (last_asked_format) {
file_oformat = av_guess_format(last_asked_format, NULL, NULL);
if (!file_oformat) {
fprintf(stderr, "Requested output format '%s' is not a suitable output format\n", last_asked_format);
ffmpeg_exit(1);
}
last_asked_format = NULL;
} else {
file_oformat = av_guess_format(NULL, filename, NULL);
if (!file_oformat) {
fprintf(stderr, "Unable to find a suitable output format for '%s'\n",
filename);
ffmpeg_exit(1);
}
}
oc->oformat = file_oformat;
av_strlcpy(oc->filename, filename, sizeof(oc->filename));
if (!strcmp(file_oformat->name, "ffm") &&
av_strstart(filename, "http:", NULL)) {
int err = read_ffserver_streams(oc, filename);
if (err < 0) {
print_error(filename, err);
ffmpeg_exit(1);
}
} else {
use_video = file_oformat->video_codec != CODEC_ID_NONE || video_stream_copy || video_codec_name;
use_audio = file_oformat->audio_codec != CODEC_ID_NONE || audio_stream_copy || audio_codec_name;
use_subtitle = file_oformat->subtitle_codec != CODEC_ID_NONE || subtitle_stream_copy || subtitle_codec_name;
if (nb_input_files > 0) {
check_audio_video_sub_inputs(&input_has_video, &input_has_audio,
&input_has_subtitle);
if (!input_has_video)
use_video = 0;
if (!input_has_audio)
use_audio = 0;
if (!input_has_subtitle)
use_subtitle = 0;
}
if (audio_disable) use_audio = 0;
if (video_disable) use_video = 0;
if (subtitle_disable) use_subtitle = 0;
if (use_video) new_video_stream(oc, nb_output_files);
if (use_audio) new_audio_stream(oc, nb_output_files);
if (use_subtitle) new_subtitle_stream(oc, nb_output_files);
oc->timestamp = recording_timestamp;
av_metadata_copy(&oc->metadata, metadata, 0);
av_metadata_free(&metadata);
}
output_files[nb_output_files++] = oc;
if (oc->oformat->flags & AVFMT_NEEDNUMBER) {
if (!av_filename_number_test(oc->filename)) {
print_error(oc->filename, AVERROR_NUMEXPECTED);
ffmpeg_exit(1);
}
}
if (!(oc->oformat->flags & AVFMT_NOFILE)) {
if (!file_overwrite &&
(strchr(filename, ':') == NULL ||
filename[1] == ':' ||
av_strstart(filename, "file:", NULL))) {
if (url_exist(filename)) {
if (!using_stdin) {
fprintf(stderr,"File '%s' already exists. Overwrite ? [y/N] ", filename);
fflush(stderr);
if (!read_yesno()) {
fprintf(stderr, "Not overwriting - exiting\n");
ffmpeg_exit(1);
}
}
else {
fprintf(stderr,"File '%s' already exists. Exiting.\n", filename);
ffmpeg_exit(1);
}
}
}
if ((err = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE)) < 0) {
print_error(filename, err);
ffmpeg_exit(1);
}
}
memset(ap, 0, sizeof(*ap));
if (av_set_parameters(oc, ap) < 0) {
fprintf(stderr, "%s: Invalid encoding parameters\n",
oc->filename);
ffmpeg_exit(1);
}
oc->preload= (int)(mux_preload*AV_TIME_BASE);
oc->max_delay= (int)(mux_max_delay*AV_TIME_BASE);
oc->loop_output = loop_output;
oc->flags |= AVFMT_FLAG_NONBLOCK;
set_context_opts(oc, avformat_opts, AV_OPT_FLAG_ENCODING_PARAM, NULL);
av_freep(&forced_key_frames);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const char *VAR_0)
{
AVFormatContext *oc;
int VAR_8, VAR_2, VAR_3, VAR_4;
int VAR_5, VAR_6, VAR_7;
AVFormatParameters params, *ap = ¶ms;
AVOutputFormat *file_oformat;
if (!strcmp(VAR_0, "-"))
VAR_0 = "pipe:";
oc = avformat_alloc_context();
if (!oc) {
print_error(VAR_0, AVERROR(ENOMEM));
ffmpeg_exit(1);
}
if (last_asked_format) {
file_oformat = av_guess_format(last_asked_format, NULL, NULL);
if (!file_oformat) {
fprintf(stderr, "Requested output format '%s' is not a suitable output format\n", last_asked_format);
ffmpeg_exit(1);
}
last_asked_format = NULL;
} else {
file_oformat = av_guess_format(NULL, VAR_0, NULL);
if (!file_oformat) {
fprintf(stderr, "Unable to find a suitable output format for '%s'\n",
VAR_0);
ffmpeg_exit(1);
}
}
oc->oformat = file_oformat;
av_strlcpy(oc->VAR_0, VAR_0, sizeof(oc->VAR_0));
if (!strcmp(file_oformat->name, "ffm") &&
av_strstart(VAR_0, "http:", NULL)) {
int VAR_8 = read_ffserver_streams(oc, VAR_0);
if (VAR_8 < 0) {
print_error(VAR_0, VAR_8);
ffmpeg_exit(1);
}
} else {
VAR_2 = file_oformat->video_codec != CODEC_ID_NONE || video_stream_copy || video_codec_name;
VAR_3 = file_oformat->audio_codec != CODEC_ID_NONE || audio_stream_copy || audio_codec_name;
VAR_4 = file_oformat->subtitle_codec != CODEC_ID_NONE || subtitle_stream_copy || subtitle_codec_name;
if (nb_input_files > 0) {
check_audio_video_sub_inputs(&VAR_5, &VAR_6,
&VAR_7);
if (!VAR_5)
VAR_2 = 0;
if (!VAR_6)
VAR_3 = 0;
if (!VAR_7)
VAR_4 = 0;
}
if (audio_disable) VAR_3 = 0;
if (video_disable) VAR_2 = 0;
if (subtitle_disable) VAR_4 = 0;
if (VAR_2) new_video_stream(oc, nb_output_files);
if (VAR_3) new_audio_stream(oc, nb_output_files);
if (VAR_4) new_subtitle_stream(oc, nb_output_files);
oc->timestamp = recording_timestamp;
av_metadata_copy(&oc->metadata, metadata, 0);
av_metadata_free(&metadata);
}
output_files[nb_output_files++] = oc;
if (oc->oformat->flags & AVFMT_NEEDNUMBER) {
if (!av_filename_number_test(oc->VAR_0)) {
print_error(oc->VAR_0, AVERROR_NUMEXPECTED);
ffmpeg_exit(1);
}
}
if (!(oc->oformat->flags & AVFMT_NOFILE)) {
if (!file_overwrite &&
(strchr(VAR_0, ':') == NULL ||
VAR_0[1] == ':' ||
av_strstart(VAR_0, "file:", NULL))) {
if (url_exist(VAR_0)) {
if (!using_stdin) {
fprintf(stderr,"File '%s' already exists. Overwrite ? [y/N] ", VAR_0);
fflush(stderr);
if (!read_yesno()) {
fprintf(stderr, "Not overwriting - exiting\n");
ffmpeg_exit(1);
}
}
else {
fprintf(stderr,"File '%s' already exists. Exiting.\n", VAR_0);
ffmpeg_exit(1);
}
}
}
if ((VAR_8 = avio_open(&oc->pb, VAR_0, AVIO_FLAG_WRITE)) < 0) {
print_error(VAR_0, VAR_8);
ffmpeg_exit(1);
}
}
memset(ap, 0, sizeof(*ap));
if (av_set_parameters(oc, ap) < 0) {
fprintf(stderr, "%s: Invalid encoding parameters\n",
oc->VAR_0);
ffmpeg_exit(1);
}
oc->preload= (int)(mux_preload*AV_TIME_BASE);
oc->max_delay= (int)(mux_max_delay*AV_TIME_BASE);
oc->loop_output = loop_output;
oc->flags |= AVFMT_FLAG_NONBLOCK;
set_context_opts(oc, avformat_opts, AV_OPT_FLAG_ENCODING_PARAM, NULL);
av_freep(&forced_key_frames);
}
| [
"static void FUNC_0(const char *VAR_0)\n{",
"AVFormatContext *oc;",
"int VAR_8, VAR_2, VAR_3, VAR_4;",
"int VAR_5, VAR_6, VAR_7;",
"AVFormatParameters params, *ap = ¶ms;",
"AVOutputFormat *file_oformat;",
"if (!strcmp(VAR_0, \"-\"))\nVAR_0 = \"pipe:\";",
"oc = avformat_alloc_context();",
"if (!oc) {",
"print_error(VAR_0, AVERROR(ENOMEM));",
"ffmpeg_exit(1);",
"}",
"if (last_asked_format) {",
"file_oformat = av_guess_format(last_asked_format, NULL, NULL);",
"if (!file_oformat) {",
"fprintf(stderr, \"Requested output format '%s' is not a suitable output format\\n\", last_asked_format);",
"ffmpeg_exit(1);",
"}",
"last_asked_format = NULL;",
"} else {",
"file_oformat = av_guess_format(NULL, VAR_0, NULL);",
"if (!file_oformat) {",
"fprintf(stderr, \"Unable to find a suitable output format for '%s'\\n\",\nVAR_0);",
"ffmpeg_exit(1);",
"}",
"}",
"oc->oformat = file_oformat;",
"av_strlcpy(oc->VAR_0, VAR_0, sizeof(oc->VAR_0));",
"if (!strcmp(file_oformat->name, \"ffm\") &&\nav_strstart(VAR_0, \"http:\", NULL)) {",
"int VAR_8 = read_ffserver_streams(oc, VAR_0);",
"if (VAR_8 < 0) {",
"print_error(VAR_0, VAR_8);",
"ffmpeg_exit(1);",
"}",
"} else {",
"VAR_2 = file_oformat->video_codec != CODEC_ID_NONE || video_stream_copy || video_codec_name;",
"VAR_3 = file_oformat->audio_codec != CODEC_ID_NONE || audio_stream_copy || audio_codec_name;",
"VAR_4 = file_oformat->subtitle_codec != CODEC_ID_NONE || subtitle_stream_copy || subtitle_codec_name;",
"if (nb_input_files > 0) {",
"check_audio_video_sub_inputs(&VAR_5, &VAR_6,\n&VAR_7);",
"if (!VAR_5)\nVAR_2 = 0;",
"if (!VAR_6)\nVAR_3 = 0;",
"if (!VAR_7)\nVAR_4 = 0;",
"}",
"if (audio_disable) VAR_3 = 0;",
"if (video_disable) VAR_2 = 0;",
"if (subtitle_disable) VAR_4 = 0;",
"if (VAR_2) new_video_stream(oc, nb_output_files);",
"if (VAR_3) new_audio_stream(oc, nb_output_files);",
"if (VAR_4) new_subtitle_stream(oc, nb_output_files);",
"oc->timestamp = recording_timestamp;",
"av_metadata_copy(&oc->metadata, metadata, 0);",
"av_metadata_free(&metadata);",
"}",
"output_files[nb_output_files++] = oc;",
"if (oc->oformat->flags & AVFMT_NEEDNUMBER) {",
"if (!av_filename_number_test(oc->VAR_0)) {",
"print_error(oc->VAR_0, AVERROR_NUMEXPECTED);",
"ffmpeg_exit(1);",
"}",
"}",
"if (!(oc->oformat->flags & AVFMT_NOFILE)) {",
"if (!file_overwrite &&\n(strchr(VAR_0, ':') == NULL ||\nVAR_0[1] == ':' ||\nav_strstart(VAR_0, \"file:\", NULL))) {",
"if (url_exist(VAR_0)) {",
"if (!using_stdin) {",
"fprintf(stderr,\"File '%s' already exists. Overwrite ? [y/N] \", VAR_0);",
"fflush(stderr);",
"if (!read_yesno()) {",
"fprintf(stderr, \"Not overwriting - exiting\\n\");",
"ffmpeg_exit(1);",
"}",
"}",
"else {",
"fprintf(stderr,\"File '%s' already exists. Exiting.\\n\", VAR_0);",
"ffmpeg_exit(1);",
"}",
"}",
"}",
"if ((VAR_8 = avio_open(&oc->pb, VAR_0, AVIO_FLAG_WRITE)) < 0) {",
"print_error(VAR_0, VAR_8);",
"ffmpeg_exit(1);",
"}",
"}",
"memset(ap, 0, sizeof(*ap));",
"if (av_set_parameters(oc, ap) < 0) {",
"fprintf(stderr, \"%s: Invalid encoding parameters\\n\",\noc->VAR_0);",
"ffmpeg_exit(1);",
"}",
"oc->preload= (int)(mux_preload*AV_TIME_BASE);",
"oc->max_delay= (int)(mux_max_delay*AV_TIME_BASE);",
"oc->loop_output = loop_output;",
"oc->flags |= AVFMT_FLAG_NONBLOCK;",
"set_context_opts(oc, avformat_opts, AV_OPT_FLAG_ENCODING_PARAM, NULL);",
"av_freep(&forced_key_frames);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
73,
75
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
105
],
[
107,
109
],
[
111,
113
],
[
115,
117
],
[
119,
121
],
[
123
],
[
129
],
[
131
],
[
133
],
[
137
],
[
139
],
[
141
],
[
145
],
[
149
],
[
151
],
[
153
],
[
157
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
177
],
[
181,
183,
185,
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
235
],
[
237
],
[
239,
241
],
[
243
],
[
245
],
[
249
],
[
251
],
[
253
],
[
255
],
[
259
],
[
263
],
[
265
]
] |
27,044 | static uint32_t bonito_sbridge_pciaddr(void *opaque, hwaddr addr)
{
PCIBonitoState *s = opaque;
PCIHostState *phb = PCI_HOST_BRIDGE(s->pcihost);
uint32_t cfgaddr;
uint32_t idsel;
uint32_t devno;
uint32_t funno;
uint32_t regno;
uint32_t pciaddr;
/* support type0 pci config */
if ((s->regs[BONITO_PCIMAP_CFG] & 0x10000) != 0x0) {
return 0xffffffff;
}
cfgaddr = addr & 0xffff;
cfgaddr |= (s->regs[BONITO_PCIMAP_CFG] & 0xffff) << 16;
idsel = (cfgaddr & BONITO_PCICONF_IDSEL_MASK) >> BONITO_PCICONF_IDSEL_OFFSET;
devno = ffs(idsel) - 1;
funno = (cfgaddr & BONITO_PCICONF_FUN_MASK) >> BONITO_PCICONF_FUN_OFFSET;
regno = (cfgaddr & BONITO_PCICONF_REG_MASK) >> BONITO_PCICONF_REG_OFFSET;
if (idsel == 0) {
fprintf(stderr, "error in bonito pci config address " TARGET_FMT_plx
",pcimap_cfg=%x\n", addr, s->regs[BONITO_PCIMAP_CFG]);
exit(1);
}
pciaddr = PCI_ADDR(pci_bus_num(phb->bus), devno, funno, regno);
DPRINTF("cfgaddr %x pciaddr %x busno %x devno %d funno %d regno %d\n",
cfgaddr, pciaddr, pci_bus_num(phb->bus), devno, funno, regno);
return pciaddr;
}
| false | qemu | 786a4ea82ec9c87e3a895cf41081029b285a5fe5 | static uint32_t bonito_sbridge_pciaddr(void *opaque, hwaddr addr)
{
PCIBonitoState *s = opaque;
PCIHostState *phb = PCI_HOST_BRIDGE(s->pcihost);
uint32_t cfgaddr;
uint32_t idsel;
uint32_t devno;
uint32_t funno;
uint32_t regno;
uint32_t pciaddr;
if ((s->regs[BONITO_PCIMAP_CFG] & 0x10000) != 0x0) {
return 0xffffffff;
}
cfgaddr = addr & 0xffff;
cfgaddr |= (s->regs[BONITO_PCIMAP_CFG] & 0xffff) << 16;
idsel = (cfgaddr & BONITO_PCICONF_IDSEL_MASK) >> BONITO_PCICONF_IDSEL_OFFSET;
devno = ffs(idsel) - 1;
funno = (cfgaddr & BONITO_PCICONF_FUN_MASK) >> BONITO_PCICONF_FUN_OFFSET;
regno = (cfgaddr & BONITO_PCICONF_REG_MASK) >> BONITO_PCICONF_REG_OFFSET;
if (idsel == 0) {
fprintf(stderr, "error in bonito pci config address " TARGET_FMT_plx
",pcimap_cfg=%x\n", addr, s->regs[BONITO_PCIMAP_CFG]);
exit(1);
}
pciaddr = PCI_ADDR(pci_bus_num(phb->bus), devno, funno, regno);
DPRINTF("cfgaddr %x pciaddr %x busno %x devno %d funno %d regno %d\n",
cfgaddr, pciaddr, pci_bus_num(phb->bus), devno, funno, regno);
return pciaddr;
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0(void *opaque, hwaddr addr)
{
PCIBonitoState *s = opaque;
PCIHostState *phb = PCI_HOST_BRIDGE(s->pcihost);
uint32_t cfgaddr;
uint32_t idsel;
uint32_t devno;
uint32_t funno;
uint32_t regno;
uint32_t pciaddr;
if ((s->regs[BONITO_PCIMAP_CFG] & 0x10000) != 0x0) {
return 0xffffffff;
}
cfgaddr = addr & 0xffff;
cfgaddr |= (s->regs[BONITO_PCIMAP_CFG] & 0xffff) << 16;
idsel = (cfgaddr & BONITO_PCICONF_IDSEL_MASK) >> BONITO_PCICONF_IDSEL_OFFSET;
devno = ffs(idsel) - 1;
funno = (cfgaddr & BONITO_PCICONF_FUN_MASK) >> BONITO_PCICONF_FUN_OFFSET;
regno = (cfgaddr & BONITO_PCICONF_REG_MASK) >> BONITO_PCICONF_REG_OFFSET;
if (idsel == 0) {
fprintf(stderr, "error in bonito pci config address " TARGET_FMT_plx
",pcimap_cfg=%x\n", addr, s->regs[BONITO_PCIMAP_CFG]);
exit(1);
}
pciaddr = PCI_ADDR(pci_bus_num(phb->bus), devno, funno, regno);
DPRINTF("cfgaddr %x pciaddr %x busno %x devno %d funno %d regno %d\n",
cfgaddr, pciaddr, pci_bus_num(phb->bus), devno, funno, regno);
return pciaddr;
}
| [
"static uint32_t FUNC_0(void *opaque, hwaddr addr)\n{",
"PCIBonitoState *s = opaque;",
"PCIHostState *phb = PCI_HOST_BRIDGE(s->pcihost);",
"uint32_t cfgaddr;",
"uint32_t idsel;",
"uint32_t devno;",
"uint32_t funno;",
"uint32_t regno;",
"uint32_t pciaddr;",
"if ((s->regs[BONITO_PCIMAP_CFG] & 0x10000) != 0x0) {",
"return 0xffffffff;",
"}",
"cfgaddr = addr & 0xffff;",
"cfgaddr |= (s->regs[BONITO_PCIMAP_CFG] & 0xffff) << 16;",
"idsel = (cfgaddr & BONITO_PCICONF_IDSEL_MASK) >> BONITO_PCICONF_IDSEL_OFFSET;",
"devno = ffs(idsel) - 1;",
"funno = (cfgaddr & BONITO_PCICONF_FUN_MASK) >> BONITO_PCICONF_FUN_OFFSET;",
"regno = (cfgaddr & BONITO_PCICONF_REG_MASK) >> BONITO_PCICONF_REG_OFFSET;",
"if (idsel == 0) {",
"fprintf(stderr, \"error in bonito pci config address \" TARGET_FMT_plx\n\",pcimap_cfg=%x\\n\", addr, s->regs[BONITO_PCIMAP_CFG]);",
"exit(1);",
"}",
"pciaddr = PCI_ADDR(pci_bus_num(phb->bus), devno, funno, regno);",
"DPRINTF(\"cfgaddr %x pciaddr %x busno %x devno %d funno %d regno %d\\n\",\ncfgaddr, pciaddr, pci_bus_num(phb->bus), devno, funno, regno);",
"return pciaddr;",
"}"
] | [
0,
0,
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
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[
67
],
[
69
]
] |
27,047 | const char *drive_get_serial(BlockDriverState *bdrv)
{
DriveInfo *dinfo;
TAILQ_FOREACH(dinfo, &drives, next) {
if (dinfo->bdrv == bdrv)
return dinfo->serial;
}
return "\0";
}
| false | qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | const char *drive_get_serial(BlockDriverState *bdrv)
{
DriveInfo *dinfo;
TAILQ_FOREACH(dinfo, &drives, next) {
if (dinfo->bdrv == bdrv)
return dinfo->serial;
}
return "\0";
}
| {
"code": [],
"line_no": []
} | const char *FUNC_0(BlockDriverState *VAR_0)
{
DriveInfo *dinfo;
TAILQ_FOREACH(dinfo, &drives, next) {
if (dinfo->VAR_0 == VAR_0)
return dinfo->serial;
}
return "\0";
}
| [
"const char *FUNC_0(BlockDriverState *VAR_0)\n{",
"DriveInfo *dinfo;",
"TAILQ_FOREACH(dinfo, &drives, next) {",
"if (dinfo->VAR_0 == VAR_0)\nreturn dinfo->serial;",
"}",
"return \"\\0\";",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
15
],
[
19
],
[
21
]
] |
27,049 | static void vnc_read_when(VncState *vs, VncReadEvent *func, size_t expecting)
{
vs->read_handler = func;
vs->read_handler_expect = expecting;
}
| false | qemu | 5fb6c7a8b26eab1a22207d24b4784bd2b39ab54b | static void vnc_read_when(VncState *vs, VncReadEvent *func, size_t expecting)
{
vs->read_handler = func;
vs->read_handler_expect = expecting;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(VncState *VAR_0, VncReadEvent *VAR_1, size_t VAR_2)
{
VAR_0->read_handler = VAR_1;
VAR_0->read_handler_expect = VAR_2;
}
| [
"static void FUNC_0(VncState *VAR_0, VncReadEvent *VAR_1, size_t VAR_2)\n{",
"VAR_0->read_handler = VAR_1;",
"VAR_0->read_handler_expect = VAR_2;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
27,050 | static int decode_mips16_opc (CPUState *env, DisasContext *ctx,
int *is_branch)
{
int rx, ry;
int sa;
int op, cnvt_op, op1, offset;
int funct;
int n_bytes;
op = (ctx->opcode >> 11) & 0x1f;
sa = (ctx->opcode >> 2) & 0x7;
sa = sa == 0 ? 8 : sa;
rx = xlat((ctx->opcode >> 8) & 0x7);
cnvt_op = (ctx->opcode >> 5) & 0x7;
ry = xlat((ctx->opcode >> 5) & 0x7);
op1 = offset = ctx->opcode & 0x1f;
n_bytes = 2;
switch (op) {
case M16_OPC_ADDIUSP:
{
int16_t imm = ((uint8_t) ctx->opcode) << 2;
gen_arith_imm(env, ctx, OPC_ADDIU, rx, 29, imm);
}
break;
case M16_OPC_ADDIUPC:
gen_addiupc(ctx, rx, ((uint8_t) ctx->opcode) << 2, 0, 0);
break;
case M16_OPC_B:
offset = (ctx->opcode & 0x7ff) << 1;
offset = (int16_t)(offset << 4) >> 4;
gen_compute_branch(ctx, OPC_BEQ, 2, 0, 0, offset);
/* No delay slot, so just process as a normal instruction */
break;
case M16_OPC_JAL:
offset = lduw_code(ctx->pc + 2);
offset = (((ctx->opcode & 0x1f) << 21)
| ((ctx->opcode >> 5) & 0x1f) << 16
| offset) << 2;
op = ((ctx->opcode >> 10) & 0x1) ? OPC_JALX : OPC_JAL;
gen_compute_branch(ctx, op, 4, rx, ry, offset);
n_bytes = 4;
*is_branch = 1;
break;
case M16_OPC_BEQZ:
gen_compute_branch(ctx, OPC_BEQ, 2, rx, 0, ((int8_t)ctx->opcode) << 1);
/* No delay slot, so just process as a normal instruction */
break;
case M16_OPC_BNEQZ:
gen_compute_branch(ctx, OPC_BNE, 2, rx, 0, ((int8_t)ctx->opcode) << 1);
/* No delay slot, so just process as a normal instruction */
break;
case M16_OPC_SHIFT:
switch (ctx->opcode & 0x3) {
case 0x0:
gen_shift_imm(env, ctx, OPC_SLL, rx, ry, sa);
break;
case 0x1:
#if defined(TARGET_MIPS64)
check_mips_64(ctx);
gen_shift_imm(env, ctx, OPC_DSLL, rx, ry, sa);
#else
generate_exception(ctx, EXCP_RI);
#endif
break;
case 0x2:
gen_shift_imm(env, ctx, OPC_SRL, rx, ry, sa);
break;
case 0x3:
gen_shift_imm(env, ctx, OPC_SRA, rx, ry, sa);
break;
}
break;
#if defined(TARGET_MIPS64)
case M16_OPC_LD:
check_mips_64(ctx);
gen_ldst(ctx, OPC_LD, ry, rx, offset << 3);
break;
#endif
case M16_OPC_RRIA:
{
int16_t imm = (int8_t)((ctx->opcode & 0xf) << 4) >> 4;
if ((ctx->opcode >> 4) & 1) {
#if defined(TARGET_MIPS64)
check_mips_64(ctx);
gen_arith_imm(env, ctx, OPC_DADDIU, ry, rx, imm);
#else
generate_exception(ctx, EXCP_RI);
#endif
} else {
gen_arith_imm(env, ctx, OPC_ADDIU, ry, rx, imm);
}
}
break;
case M16_OPC_ADDIU8:
{
int16_t imm = (int8_t) ctx->opcode;
gen_arith_imm(env, ctx, OPC_ADDIU, rx, rx, imm);
}
break;
case M16_OPC_SLTI:
{
int16_t imm = (uint8_t) ctx->opcode;
gen_slt_imm(env, OPC_SLTI, 24, rx, imm);
}
break;
case M16_OPC_SLTIU:
{
int16_t imm = (uint8_t) ctx->opcode;
gen_slt_imm(env, OPC_SLTIU, 24, rx, imm);
}
break;
case M16_OPC_I8:
{
int reg32;
funct = (ctx->opcode >> 8) & 0x7;
switch (funct) {
case I8_BTEQZ:
gen_compute_branch(ctx, OPC_BEQ, 2, 24, 0,
((int8_t)ctx->opcode) << 1);
break;
case I8_BTNEZ:
gen_compute_branch(ctx, OPC_BNE, 2, 24, 0,
((int8_t)ctx->opcode) << 1);
break;
case I8_SWRASP:
gen_ldst(ctx, OPC_SW, 31, 29, (ctx->opcode & 0xff) << 2);
break;
case I8_ADJSP:
gen_arith_imm(env, ctx, OPC_ADDIU, 29, 29,
((int8_t)ctx->opcode) << 3);
break;
case I8_SVRS:
{
int do_ra = ctx->opcode & (1 << 6);
int do_s0 = ctx->opcode & (1 << 5);
int do_s1 = ctx->opcode & (1 << 4);
int framesize = ctx->opcode & 0xf;
if (framesize == 0) {
framesize = 128;
} else {
framesize = framesize << 3;
}
if (ctx->opcode & (1 << 7)) {
gen_mips16_save(ctx, 0, 0,
do_ra, do_s0, do_s1, framesize);
} else {
gen_mips16_restore(ctx, 0, 0,
do_ra, do_s0, do_s1, framesize);
}
}
break;
case I8_MOV32R:
{
int rz = xlat(ctx->opcode & 0x7);
reg32 = (((ctx->opcode >> 3) & 0x3) << 3) |
((ctx->opcode >> 5) & 0x7);
gen_arith(env, ctx, OPC_ADDU, reg32, rz, 0);
}
break;
case I8_MOVR32:
reg32 = ctx->opcode & 0x1f;
gen_arith(env, ctx, OPC_ADDU, ry, reg32, 0);
break;
default:
generate_exception(ctx, EXCP_RI);
break;
}
}
break;
case M16_OPC_LI:
{
int16_t imm = (uint8_t) ctx->opcode;
gen_arith_imm(env, ctx, OPC_ADDIU, rx, 0, imm);
}
break;
case M16_OPC_CMPI:
{
int16_t imm = (uint8_t) ctx->opcode;
gen_logic_imm(env, OPC_XORI, 24, rx, imm);
}
break;
#if defined(TARGET_MIPS64)
case M16_OPC_SD:
check_mips_64(ctx);
gen_ldst(ctx, OPC_SD, ry, rx, offset << 3);
break;
#endif
case M16_OPC_LB:
gen_ldst(ctx, OPC_LB, ry, rx, offset);
break;
case M16_OPC_LH:
gen_ldst(ctx, OPC_LH, ry, rx, offset << 1);
break;
case M16_OPC_LWSP:
gen_ldst(ctx, OPC_LW, rx, 29, ((uint8_t)ctx->opcode) << 2);
break;
case M16_OPC_LW:
gen_ldst(ctx, OPC_LW, ry, rx, offset << 2);
break;
case M16_OPC_LBU:
gen_ldst(ctx, OPC_LBU, ry, rx, offset);
break;
case M16_OPC_LHU:
gen_ldst(ctx, OPC_LHU, ry, rx, offset << 1);
break;
case M16_OPC_LWPC:
gen_ldst(ctx, OPC_LWPC, rx, 0, ((uint8_t)ctx->opcode) << 2);
break;
#if defined (TARGET_MIPS64)
case M16_OPC_LWU:
check_mips_64(ctx);
gen_ldst(ctx, OPC_LWU, ry, rx, offset << 2);
break;
#endif
case M16_OPC_SB:
gen_ldst(ctx, OPC_SB, ry, rx, offset);
break;
case M16_OPC_SH:
gen_ldst(ctx, OPC_SH, ry, rx, offset << 1);
break;
case M16_OPC_SWSP:
gen_ldst(ctx, OPC_SW, rx, 29, ((uint8_t)ctx->opcode) << 2);
break;
case M16_OPC_SW:
gen_ldst(ctx, OPC_SW, ry, rx, offset << 2);
break;
case M16_OPC_RRR:
{
int rz = xlat((ctx->opcode >> 2) & 0x7);
int mips32_op;
switch (ctx->opcode & 0x3) {
case RRR_ADDU:
mips32_op = OPC_ADDU;
break;
case RRR_SUBU:
mips32_op = OPC_SUBU;
break;
#if defined(TARGET_MIPS64)
case RRR_DADDU:
mips32_op = OPC_DADDU;
check_mips_64(ctx);
break;
case RRR_DSUBU:
mips32_op = OPC_DSUBU;
check_mips_64(ctx);
break;
#endif
default:
generate_exception(ctx, EXCP_RI);
goto done;
}
gen_arith(env, ctx, mips32_op, rz, rx, ry);
done:
;
}
break;
case M16_OPC_RR:
switch (op1) {
case RR_JR:
{
int nd = (ctx->opcode >> 7) & 0x1;
int link = (ctx->opcode >> 6) & 0x1;
int ra = (ctx->opcode >> 5) & 0x1;
if (link) {
op = nd ? OPC_JALRC : OPC_JALR;
} else {
op = OPC_JR;
}
gen_compute_branch(ctx, op, 2, ra ? 31 : rx, 31, 0);
if (!nd) {
*is_branch = 1;
}
}
break;
case RR_SDBBP:
/* XXX: not clear which exception should be raised
* when in debug mode...
*/
check_insn(env, ctx, ISA_MIPS32);
if (!(ctx->hflags & MIPS_HFLAG_DM)) {
generate_exception(ctx, EXCP_DBp);
} else {
generate_exception(ctx, EXCP_DBp);
}
break;
case RR_SLT:
gen_slt(env, OPC_SLT, 24, rx, ry);
break;
case RR_SLTU:
gen_slt(env, OPC_SLTU, 24, rx, ry);
break;
case RR_BREAK:
generate_exception(ctx, EXCP_BREAK);
break;
case RR_SLLV:
gen_shift(env, ctx, OPC_SLLV, ry, rx, ry);
break;
case RR_SRLV:
gen_shift(env, ctx, OPC_SRLV, ry, rx, ry);
break;
case RR_SRAV:
gen_shift(env, ctx, OPC_SRAV, ry, rx, ry);
break;
#if defined (TARGET_MIPS64)
case RR_DSRL:
check_mips_64(ctx);
gen_shift_imm(env, ctx, OPC_DSRL, ry, ry, sa);
break;
#endif
case RR_CMP:
gen_logic(env, OPC_XOR, 24, rx, ry);
break;
case RR_NEG:
gen_arith(env, ctx, OPC_SUBU, rx, 0, ry);
break;
case RR_AND:
gen_logic(env, OPC_AND, rx, rx, ry);
break;
case RR_OR:
gen_logic(env, OPC_OR, rx, rx, ry);
break;
case RR_XOR:
gen_logic(env, OPC_XOR, rx, rx, ry);
break;
case RR_NOT:
gen_logic(env, OPC_NOR, rx, ry, 0);
break;
case RR_MFHI:
gen_HILO(ctx, OPC_MFHI, rx);
break;
case RR_CNVT:
switch (cnvt_op) {
case RR_RY_CNVT_ZEB:
tcg_gen_ext8u_tl(cpu_gpr[rx], cpu_gpr[rx]);
break;
case RR_RY_CNVT_ZEH:
tcg_gen_ext16u_tl(cpu_gpr[rx], cpu_gpr[rx]);
break;
case RR_RY_CNVT_SEB:
tcg_gen_ext8s_tl(cpu_gpr[rx], cpu_gpr[rx]);
break;
case RR_RY_CNVT_SEH:
tcg_gen_ext16s_tl(cpu_gpr[rx], cpu_gpr[rx]);
break;
#if defined (TARGET_MIPS64)
case RR_RY_CNVT_ZEW:
check_mips_64(ctx);
tcg_gen_ext32u_tl(cpu_gpr[rx], cpu_gpr[rx]);
break;
case RR_RY_CNVT_SEW:
check_mips_64(ctx);
tcg_gen_ext32s_tl(cpu_gpr[rx], cpu_gpr[rx]);
break;
#endif
default:
generate_exception(ctx, EXCP_RI);
break;
}
break;
case RR_MFLO:
gen_HILO(ctx, OPC_MFLO, rx);
break;
#if defined (TARGET_MIPS64)
case RR_DSRA:
check_mips_64(ctx);
gen_shift_imm(env, ctx, OPC_DSRA, ry, ry, sa);
break;
case RR_DSLLV:
check_mips_64(ctx);
gen_shift(env, ctx, OPC_DSLLV, ry, rx, ry);
break;
case RR_DSRLV:
check_mips_64(ctx);
gen_shift(env, ctx, OPC_DSRLV, ry, rx, ry);
break;
case RR_DSRAV:
check_mips_64(ctx);
gen_shift(env, ctx, OPC_DSRAV, ry, rx, ry);
break;
#endif
case RR_MULT:
gen_muldiv(ctx, OPC_MULT, rx, ry);
break;
case RR_MULTU:
gen_muldiv(ctx, OPC_MULTU, rx, ry);
break;
case RR_DIV:
gen_muldiv(ctx, OPC_DIV, rx, ry);
break;
case RR_DIVU:
gen_muldiv(ctx, OPC_DIVU, rx, ry);
break;
#if defined (TARGET_MIPS64)
case RR_DMULT:
check_mips_64(ctx);
gen_muldiv(ctx, OPC_DMULT, rx, ry);
break;
case RR_DMULTU:
check_mips_64(ctx);
gen_muldiv(ctx, OPC_DMULTU, rx, ry);
break;
case RR_DDIV:
check_mips_64(ctx);
gen_muldiv(ctx, OPC_DDIV, rx, ry);
break;
case RR_DDIVU:
check_mips_64(ctx);
gen_muldiv(ctx, OPC_DDIVU, rx, ry);
break;
#endif
default:
generate_exception(ctx, EXCP_RI);
break;
}
break;
case M16_OPC_EXTEND:
decode_extended_mips16_opc(env, ctx, is_branch);
n_bytes = 4;
break;
#if defined(TARGET_MIPS64)
case M16_OPC_I64:
funct = (ctx->opcode >> 8) & 0x7;
decode_i64_mips16(env, ctx, ry, funct, offset, 0);
break;
#endif
default:
generate_exception(ctx, EXCP_RI);
break;
}
return n_bytes;
}
| false | qemu | 620e48f66350991918dd78e9a686a9b159fec111 | static int decode_mips16_opc (CPUState *env, DisasContext *ctx,
int *is_branch)
{
int rx, ry;
int sa;
int op, cnvt_op, op1, offset;
int funct;
int n_bytes;
op = (ctx->opcode >> 11) & 0x1f;
sa = (ctx->opcode >> 2) & 0x7;
sa = sa == 0 ? 8 : sa;
rx = xlat((ctx->opcode >> 8) & 0x7);
cnvt_op = (ctx->opcode >> 5) & 0x7;
ry = xlat((ctx->opcode >> 5) & 0x7);
op1 = offset = ctx->opcode & 0x1f;
n_bytes = 2;
switch (op) {
case M16_OPC_ADDIUSP:
{
int16_t imm = ((uint8_t) ctx->opcode) << 2;
gen_arith_imm(env, ctx, OPC_ADDIU, rx, 29, imm);
}
break;
case M16_OPC_ADDIUPC:
gen_addiupc(ctx, rx, ((uint8_t) ctx->opcode) << 2, 0, 0);
break;
case M16_OPC_B:
offset = (ctx->opcode & 0x7ff) << 1;
offset = (int16_t)(offset << 4) >> 4;
gen_compute_branch(ctx, OPC_BEQ, 2, 0, 0, offset);
break;
case M16_OPC_JAL:
offset = lduw_code(ctx->pc + 2);
offset = (((ctx->opcode & 0x1f) << 21)
| ((ctx->opcode >> 5) & 0x1f) << 16
| offset) << 2;
op = ((ctx->opcode >> 10) & 0x1) ? OPC_JALX : OPC_JAL;
gen_compute_branch(ctx, op, 4, rx, ry, offset);
n_bytes = 4;
*is_branch = 1;
break;
case M16_OPC_BEQZ:
gen_compute_branch(ctx, OPC_BEQ, 2, rx, 0, ((int8_t)ctx->opcode) << 1);
break;
case M16_OPC_BNEQZ:
gen_compute_branch(ctx, OPC_BNE, 2, rx, 0, ((int8_t)ctx->opcode) << 1);
break;
case M16_OPC_SHIFT:
switch (ctx->opcode & 0x3) {
case 0x0:
gen_shift_imm(env, ctx, OPC_SLL, rx, ry, sa);
break;
case 0x1:
#if defined(TARGET_MIPS64)
check_mips_64(ctx);
gen_shift_imm(env, ctx, OPC_DSLL, rx, ry, sa);
#else
generate_exception(ctx, EXCP_RI);
#endif
break;
case 0x2:
gen_shift_imm(env, ctx, OPC_SRL, rx, ry, sa);
break;
case 0x3:
gen_shift_imm(env, ctx, OPC_SRA, rx, ry, sa);
break;
}
break;
#if defined(TARGET_MIPS64)
case M16_OPC_LD:
check_mips_64(ctx);
gen_ldst(ctx, OPC_LD, ry, rx, offset << 3);
break;
#endif
case M16_OPC_RRIA:
{
int16_t imm = (int8_t)((ctx->opcode & 0xf) << 4) >> 4;
if ((ctx->opcode >> 4) & 1) {
#if defined(TARGET_MIPS64)
check_mips_64(ctx);
gen_arith_imm(env, ctx, OPC_DADDIU, ry, rx, imm);
#else
generate_exception(ctx, EXCP_RI);
#endif
} else {
gen_arith_imm(env, ctx, OPC_ADDIU, ry, rx, imm);
}
}
break;
case M16_OPC_ADDIU8:
{
int16_t imm = (int8_t) ctx->opcode;
gen_arith_imm(env, ctx, OPC_ADDIU, rx, rx, imm);
}
break;
case M16_OPC_SLTI:
{
int16_t imm = (uint8_t) ctx->opcode;
gen_slt_imm(env, OPC_SLTI, 24, rx, imm);
}
break;
case M16_OPC_SLTIU:
{
int16_t imm = (uint8_t) ctx->opcode;
gen_slt_imm(env, OPC_SLTIU, 24, rx, imm);
}
break;
case M16_OPC_I8:
{
int reg32;
funct = (ctx->opcode >> 8) & 0x7;
switch (funct) {
case I8_BTEQZ:
gen_compute_branch(ctx, OPC_BEQ, 2, 24, 0,
((int8_t)ctx->opcode) << 1);
break;
case I8_BTNEZ:
gen_compute_branch(ctx, OPC_BNE, 2, 24, 0,
((int8_t)ctx->opcode) << 1);
break;
case I8_SWRASP:
gen_ldst(ctx, OPC_SW, 31, 29, (ctx->opcode & 0xff) << 2);
break;
case I8_ADJSP:
gen_arith_imm(env, ctx, OPC_ADDIU, 29, 29,
((int8_t)ctx->opcode) << 3);
break;
case I8_SVRS:
{
int do_ra = ctx->opcode & (1 << 6);
int do_s0 = ctx->opcode & (1 << 5);
int do_s1 = ctx->opcode & (1 << 4);
int framesize = ctx->opcode & 0xf;
if (framesize == 0) {
framesize = 128;
} else {
framesize = framesize << 3;
}
if (ctx->opcode & (1 << 7)) {
gen_mips16_save(ctx, 0, 0,
do_ra, do_s0, do_s1, framesize);
} else {
gen_mips16_restore(ctx, 0, 0,
do_ra, do_s0, do_s1, framesize);
}
}
break;
case I8_MOV32R:
{
int rz = xlat(ctx->opcode & 0x7);
reg32 = (((ctx->opcode >> 3) & 0x3) << 3) |
((ctx->opcode >> 5) & 0x7);
gen_arith(env, ctx, OPC_ADDU, reg32, rz, 0);
}
break;
case I8_MOVR32:
reg32 = ctx->opcode & 0x1f;
gen_arith(env, ctx, OPC_ADDU, ry, reg32, 0);
break;
default:
generate_exception(ctx, EXCP_RI);
break;
}
}
break;
case M16_OPC_LI:
{
int16_t imm = (uint8_t) ctx->opcode;
gen_arith_imm(env, ctx, OPC_ADDIU, rx, 0, imm);
}
break;
case M16_OPC_CMPI:
{
int16_t imm = (uint8_t) ctx->opcode;
gen_logic_imm(env, OPC_XORI, 24, rx, imm);
}
break;
#if defined(TARGET_MIPS64)
case M16_OPC_SD:
check_mips_64(ctx);
gen_ldst(ctx, OPC_SD, ry, rx, offset << 3);
break;
#endif
case M16_OPC_LB:
gen_ldst(ctx, OPC_LB, ry, rx, offset);
break;
case M16_OPC_LH:
gen_ldst(ctx, OPC_LH, ry, rx, offset << 1);
break;
case M16_OPC_LWSP:
gen_ldst(ctx, OPC_LW, rx, 29, ((uint8_t)ctx->opcode) << 2);
break;
case M16_OPC_LW:
gen_ldst(ctx, OPC_LW, ry, rx, offset << 2);
break;
case M16_OPC_LBU:
gen_ldst(ctx, OPC_LBU, ry, rx, offset);
break;
case M16_OPC_LHU:
gen_ldst(ctx, OPC_LHU, ry, rx, offset << 1);
break;
case M16_OPC_LWPC:
gen_ldst(ctx, OPC_LWPC, rx, 0, ((uint8_t)ctx->opcode) << 2);
break;
#if defined (TARGET_MIPS64)
case M16_OPC_LWU:
check_mips_64(ctx);
gen_ldst(ctx, OPC_LWU, ry, rx, offset << 2);
break;
#endif
case M16_OPC_SB:
gen_ldst(ctx, OPC_SB, ry, rx, offset);
break;
case M16_OPC_SH:
gen_ldst(ctx, OPC_SH, ry, rx, offset << 1);
break;
case M16_OPC_SWSP:
gen_ldst(ctx, OPC_SW, rx, 29, ((uint8_t)ctx->opcode) << 2);
break;
case M16_OPC_SW:
gen_ldst(ctx, OPC_SW, ry, rx, offset << 2);
break;
case M16_OPC_RRR:
{
int rz = xlat((ctx->opcode >> 2) & 0x7);
int mips32_op;
switch (ctx->opcode & 0x3) {
case RRR_ADDU:
mips32_op = OPC_ADDU;
break;
case RRR_SUBU:
mips32_op = OPC_SUBU;
break;
#if defined(TARGET_MIPS64)
case RRR_DADDU:
mips32_op = OPC_DADDU;
check_mips_64(ctx);
break;
case RRR_DSUBU:
mips32_op = OPC_DSUBU;
check_mips_64(ctx);
break;
#endif
default:
generate_exception(ctx, EXCP_RI);
goto done;
}
gen_arith(env, ctx, mips32_op, rz, rx, ry);
done:
;
}
break;
case M16_OPC_RR:
switch (op1) {
case RR_JR:
{
int nd = (ctx->opcode >> 7) & 0x1;
int link = (ctx->opcode >> 6) & 0x1;
int ra = (ctx->opcode >> 5) & 0x1;
if (link) {
op = nd ? OPC_JALRC : OPC_JALR;
} else {
op = OPC_JR;
}
gen_compute_branch(ctx, op, 2, ra ? 31 : rx, 31, 0);
if (!nd) {
*is_branch = 1;
}
}
break;
case RR_SDBBP:
check_insn(env, ctx, ISA_MIPS32);
if (!(ctx->hflags & MIPS_HFLAG_DM)) {
generate_exception(ctx, EXCP_DBp);
} else {
generate_exception(ctx, EXCP_DBp);
}
break;
case RR_SLT:
gen_slt(env, OPC_SLT, 24, rx, ry);
break;
case RR_SLTU:
gen_slt(env, OPC_SLTU, 24, rx, ry);
break;
case RR_BREAK:
generate_exception(ctx, EXCP_BREAK);
break;
case RR_SLLV:
gen_shift(env, ctx, OPC_SLLV, ry, rx, ry);
break;
case RR_SRLV:
gen_shift(env, ctx, OPC_SRLV, ry, rx, ry);
break;
case RR_SRAV:
gen_shift(env, ctx, OPC_SRAV, ry, rx, ry);
break;
#if defined (TARGET_MIPS64)
case RR_DSRL:
check_mips_64(ctx);
gen_shift_imm(env, ctx, OPC_DSRL, ry, ry, sa);
break;
#endif
case RR_CMP:
gen_logic(env, OPC_XOR, 24, rx, ry);
break;
case RR_NEG:
gen_arith(env, ctx, OPC_SUBU, rx, 0, ry);
break;
case RR_AND:
gen_logic(env, OPC_AND, rx, rx, ry);
break;
case RR_OR:
gen_logic(env, OPC_OR, rx, rx, ry);
break;
case RR_XOR:
gen_logic(env, OPC_XOR, rx, rx, ry);
break;
case RR_NOT:
gen_logic(env, OPC_NOR, rx, ry, 0);
break;
case RR_MFHI:
gen_HILO(ctx, OPC_MFHI, rx);
break;
case RR_CNVT:
switch (cnvt_op) {
case RR_RY_CNVT_ZEB:
tcg_gen_ext8u_tl(cpu_gpr[rx], cpu_gpr[rx]);
break;
case RR_RY_CNVT_ZEH:
tcg_gen_ext16u_tl(cpu_gpr[rx], cpu_gpr[rx]);
break;
case RR_RY_CNVT_SEB:
tcg_gen_ext8s_tl(cpu_gpr[rx], cpu_gpr[rx]);
break;
case RR_RY_CNVT_SEH:
tcg_gen_ext16s_tl(cpu_gpr[rx], cpu_gpr[rx]);
break;
#if defined (TARGET_MIPS64)
case RR_RY_CNVT_ZEW:
check_mips_64(ctx);
tcg_gen_ext32u_tl(cpu_gpr[rx], cpu_gpr[rx]);
break;
case RR_RY_CNVT_SEW:
check_mips_64(ctx);
tcg_gen_ext32s_tl(cpu_gpr[rx], cpu_gpr[rx]);
break;
#endif
default:
generate_exception(ctx, EXCP_RI);
break;
}
break;
case RR_MFLO:
gen_HILO(ctx, OPC_MFLO, rx);
break;
#if defined (TARGET_MIPS64)
case RR_DSRA:
check_mips_64(ctx);
gen_shift_imm(env, ctx, OPC_DSRA, ry, ry, sa);
break;
case RR_DSLLV:
check_mips_64(ctx);
gen_shift(env, ctx, OPC_DSLLV, ry, rx, ry);
break;
case RR_DSRLV:
check_mips_64(ctx);
gen_shift(env, ctx, OPC_DSRLV, ry, rx, ry);
break;
case RR_DSRAV:
check_mips_64(ctx);
gen_shift(env, ctx, OPC_DSRAV, ry, rx, ry);
break;
#endif
case RR_MULT:
gen_muldiv(ctx, OPC_MULT, rx, ry);
break;
case RR_MULTU:
gen_muldiv(ctx, OPC_MULTU, rx, ry);
break;
case RR_DIV:
gen_muldiv(ctx, OPC_DIV, rx, ry);
break;
case RR_DIVU:
gen_muldiv(ctx, OPC_DIVU, rx, ry);
break;
#if defined (TARGET_MIPS64)
case RR_DMULT:
check_mips_64(ctx);
gen_muldiv(ctx, OPC_DMULT, rx, ry);
break;
case RR_DMULTU:
check_mips_64(ctx);
gen_muldiv(ctx, OPC_DMULTU, rx, ry);
break;
case RR_DDIV:
check_mips_64(ctx);
gen_muldiv(ctx, OPC_DDIV, rx, ry);
break;
case RR_DDIVU:
check_mips_64(ctx);
gen_muldiv(ctx, OPC_DDIVU, rx, ry);
break;
#endif
default:
generate_exception(ctx, EXCP_RI);
break;
}
break;
case M16_OPC_EXTEND:
decode_extended_mips16_opc(env, ctx, is_branch);
n_bytes = 4;
break;
#if defined(TARGET_MIPS64)
case M16_OPC_I64:
funct = (ctx->opcode >> 8) & 0x7;
decode_i64_mips16(env, ctx, ry, funct, offset, 0);
break;
#endif
default:
generate_exception(ctx, EXCP_RI);
break;
}
return n_bytes;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0 (CPUState *VAR_0, DisasContext *VAR_1,
int *VAR_2)
{
int VAR_3, VAR_4;
int VAR_5;
int VAR_6, VAR_7, VAR_8, VAR_9;
int VAR_10;
int VAR_11;
VAR_6 = (VAR_1->opcode >> 11) & 0x1f;
VAR_5 = (VAR_1->opcode >> 2) & 0x7;
VAR_5 = VAR_5 == 0 ? 8 : VAR_5;
VAR_3 = xlat((VAR_1->opcode >> 8) & 0x7);
VAR_7 = (VAR_1->opcode >> 5) & 0x7;
VAR_4 = xlat((VAR_1->opcode >> 5) & 0x7);
VAR_8 = VAR_9 = VAR_1->opcode & 0x1f;
VAR_11 = 2;
switch (VAR_6) {
case M16_OPC_ADDIUSP:
{
int16_t imm = ((uint8_t) VAR_1->opcode) << 2;
gen_arith_imm(VAR_0, VAR_1, OPC_ADDIU, VAR_3, 29, imm);
}
break;
case M16_OPC_ADDIUPC:
gen_addiupc(VAR_1, VAR_3, ((uint8_t) VAR_1->opcode) << 2, 0, 0);
break;
case M16_OPC_B:
VAR_9 = (VAR_1->opcode & 0x7ff) << 1;
VAR_9 = (int16_t)(VAR_9 << 4) >> 4;
gen_compute_branch(VAR_1, OPC_BEQ, 2, 0, 0, VAR_9);
break;
case M16_OPC_JAL:
VAR_9 = lduw_code(VAR_1->pc + 2);
VAR_9 = (((VAR_1->opcode & 0x1f) << 21)
| ((VAR_1->opcode >> 5) & 0x1f) << 16
| VAR_9) << 2;
VAR_6 = ((VAR_1->opcode >> 10) & 0x1) ? OPC_JALX : OPC_JAL;
gen_compute_branch(VAR_1, VAR_6, 4, VAR_3, VAR_4, VAR_9);
VAR_11 = 4;
*VAR_2 = 1;
break;
case M16_OPC_BEQZ:
gen_compute_branch(VAR_1, OPC_BEQ, 2, VAR_3, 0, ((int8_t)VAR_1->opcode) << 1);
break;
case M16_OPC_BNEQZ:
gen_compute_branch(VAR_1, OPC_BNE, 2, VAR_3, 0, ((int8_t)VAR_1->opcode) << 1);
break;
case M16_OPC_SHIFT:
switch (VAR_1->opcode & 0x3) {
case 0x0:
gen_shift_imm(VAR_0, VAR_1, OPC_SLL, VAR_3, VAR_4, VAR_5);
break;
case 0x1:
#if defined(TARGET_MIPS64)
check_mips_64(VAR_1);
gen_shift_imm(VAR_0, VAR_1, OPC_DSLL, VAR_3, VAR_4, VAR_5);
#else
generate_exception(VAR_1, EXCP_RI);
#endif
break;
case 0x2:
gen_shift_imm(VAR_0, VAR_1, OPC_SRL, VAR_3, VAR_4, VAR_5);
break;
case 0x3:
gen_shift_imm(VAR_0, VAR_1, OPC_SRA, VAR_3, VAR_4, VAR_5);
break;
}
break;
#if defined(TARGET_MIPS64)
case M16_OPC_LD:
check_mips_64(VAR_1);
gen_ldst(VAR_1, OPC_LD, VAR_4, VAR_3, VAR_9 << 3);
break;
#endif
case M16_OPC_RRIA:
{
int16_t imm = (int8_t)((VAR_1->opcode & 0xf) << 4) >> 4;
if ((VAR_1->opcode >> 4) & 1) {
#if defined(TARGET_MIPS64)
check_mips_64(VAR_1);
gen_arith_imm(VAR_0, VAR_1, OPC_DADDIU, VAR_4, VAR_3, imm);
#else
generate_exception(VAR_1, EXCP_RI);
#endif
} else {
gen_arith_imm(VAR_0, VAR_1, OPC_ADDIU, VAR_4, VAR_3, imm);
}
}
break;
case M16_OPC_ADDIU8:
{
int16_t imm = (int8_t) VAR_1->opcode;
gen_arith_imm(VAR_0, VAR_1, OPC_ADDIU, VAR_3, VAR_3, imm);
}
break;
case M16_OPC_SLTI:
{
int16_t imm = (uint8_t) VAR_1->opcode;
gen_slt_imm(VAR_0, OPC_SLTI, 24, VAR_3, imm);
}
break;
case M16_OPC_SLTIU:
{
int16_t imm = (uint8_t) VAR_1->opcode;
gen_slt_imm(VAR_0, OPC_SLTIU, 24, VAR_3, imm);
}
break;
case M16_OPC_I8:
{
int VAR_12;
VAR_10 = (VAR_1->opcode >> 8) & 0x7;
switch (VAR_10) {
case I8_BTEQZ:
gen_compute_branch(VAR_1, OPC_BEQ, 2, 24, 0,
((int8_t)VAR_1->opcode) << 1);
break;
case I8_BTNEZ:
gen_compute_branch(VAR_1, OPC_BNE, 2, 24, 0,
((int8_t)VAR_1->opcode) << 1);
break;
case I8_SWRASP:
gen_ldst(VAR_1, OPC_SW, 31, 29, (VAR_1->opcode & 0xff) << 2);
break;
case I8_ADJSP:
gen_arith_imm(VAR_0, VAR_1, OPC_ADDIU, 29, 29,
((int8_t)VAR_1->opcode) << 3);
break;
case I8_SVRS:
{
int VAR_13 = VAR_1->opcode & (1 << 6);
int VAR_14 = VAR_1->opcode & (1 << 5);
int VAR_15 = VAR_1->opcode & (1 << 4);
int VAR_16 = VAR_1->opcode & 0xf;
if (VAR_16 == 0) {
VAR_16 = 128;
} else {
VAR_16 = VAR_16 << 3;
}
if (VAR_1->opcode & (1 << 7)) {
gen_mips16_save(VAR_1, 0, 0,
VAR_13, VAR_14, VAR_15, VAR_16);
} else {
gen_mips16_restore(VAR_1, 0, 0,
VAR_13, VAR_14, VAR_15, VAR_16);
}
}
break;
case I8_MOV32R:
{
int VAR_18 = xlat(VAR_1->opcode & 0x7);
VAR_12 = (((VAR_1->opcode >> 3) & 0x3) << 3) |
((VAR_1->opcode >> 5) & 0x7);
gen_arith(VAR_0, VAR_1, OPC_ADDU, VAR_12, VAR_18, 0);
}
break;
case I8_MOVR32:
VAR_12 = VAR_1->opcode & 0x1f;
gen_arith(VAR_0, VAR_1, OPC_ADDU, VAR_4, VAR_12, 0);
break;
default:
generate_exception(VAR_1, EXCP_RI);
break;
}
}
break;
case M16_OPC_LI:
{
int16_t imm = (uint8_t) VAR_1->opcode;
gen_arith_imm(VAR_0, VAR_1, OPC_ADDIU, VAR_3, 0, imm);
}
break;
case M16_OPC_CMPI:
{
int16_t imm = (uint8_t) VAR_1->opcode;
gen_logic_imm(VAR_0, OPC_XORI, 24, VAR_3, imm);
}
break;
#if defined(TARGET_MIPS64)
case M16_OPC_SD:
check_mips_64(VAR_1);
gen_ldst(VAR_1, OPC_SD, VAR_4, VAR_3, VAR_9 << 3);
break;
#endif
case M16_OPC_LB:
gen_ldst(VAR_1, OPC_LB, VAR_4, VAR_3, VAR_9);
break;
case M16_OPC_LH:
gen_ldst(VAR_1, OPC_LH, VAR_4, VAR_3, VAR_9 << 1);
break;
case M16_OPC_LWSP:
gen_ldst(VAR_1, OPC_LW, VAR_3, 29, ((uint8_t)VAR_1->opcode) << 2);
break;
case M16_OPC_LW:
gen_ldst(VAR_1, OPC_LW, VAR_4, VAR_3, VAR_9 << 2);
break;
case M16_OPC_LBU:
gen_ldst(VAR_1, OPC_LBU, VAR_4, VAR_3, VAR_9);
break;
case M16_OPC_LHU:
gen_ldst(VAR_1, OPC_LHU, VAR_4, VAR_3, VAR_9 << 1);
break;
case M16_OPC_LWPC:
gen_ldst(VAR_1, OPC_LWPC, VAR_3, 0, ((uint8_t)VAR_1->opcode) << 2);
break;
#if defined (TARGET_MIPS64)
case M16_OPC_LWU:
check_mips_64(VAR_1);
gen_ldst(VAR_1, OPC_LWU, VAR_4, VAR_3, VAR_9 << 2);
break;
#endif
case M16_OPC_SB:
gen_ldst(VAR_1, OPC_SB, VAR_4, VAR_3, VAR_9);
break;
case M16_OPC_SH:
gen_ldst(VAR_1, OPC_SH, VAR_4, VAR_3, VAR_9 << 1);
break;
case M16_OPC_SWSP:
gen_ldst(VAR_1, OPC_SW, VAR_3, 29, ((uint8_t)VAR_1->opcode) << 2);
break;
case M16_OPC_SW:
gen_ldst(VAR_1, OPC_SW, VAR_4, VAR_3, VAR_9 << 2);
break;
case M16_OPC_RRR:
{
int VAR_18 = xlat((VAR_1->opcode >> 2) & 0x7);
int VAR_18;
switch (VAR_1->opcode & 0x3) {
case RRR_ADDU:
VAR_18 = OPC_ADDU;
break;
case RRR_SUBU:
VAR_18 = OPC_SUBU;
break;
#if defined(TARGET_MIPS64)
case RRR_DADDU:
VAR_18 = OPC_DADDU;
check_mips_64(VAR_1);
break;
case RRR_DSUBU:
VAR_18 = OPC_DSUBU;
check_mips_64(VAR_1);
break;
#endif
default:
generate_exception(VAR_1, EXCP_RI);
goto done;
}
gen_arith(VAR_0, VAR_1, VAR_18, VAR_18, VAR_3, VAR_4);
done:
;
}
break;
case M16_OPC_RR:
switch (VAR_8) {
case RR_JR:
{
int VAR_19 = (VAR_1->opcode >> 7) & 0x1;
int VAR_20 = (VAR_1->opcode >> 6) & 0x1;
int VAR_21 = (VAR_1->opcode >> 5) & 0x1;
if (VAR_20) {
VAR_6 = VAR_19 ? OPC_JALRC : OPC_JALR;
} else {
VAR_6 = OPC_JR;
}
gen_compute_branch(VAR_1, VAR_6, 2, VAR_21 ? 31 : VAR_3, 31, 0);
if (!VAR_19) {
*VAR_2 = 1;
}
}
break;
case RR_SDBBP:
check_insn(VAR_0, VAR_1, ISA_MIPS32);
if (!(VAR_1->hflags & MIPS_HFLAG_DM)) {
generate_exception(VAR_1, EXCP_DBp);
} else {
generate_exception(VAR_1, EXCP_DBp);
}
break;
case RR_SLT:
gen_slt(VAR_0, OPC_SLT, 24, VAR_3, VAR_4);
break;
case RR_SLTU:
gen_slt(VAR_0, OPC_SLTU, 24, VAR_3, VAR_4);
break;
case RR_BREAK:
generate_exception(VAR_1, EXCP_BREAK);
break;
case RR_SLLV:
gen_shift(VAR_0, VAR_1, OPC_SLLV, VAR_4, VAR_3, VAR_4);
break;
case RR_SRLV:
gen_shift(VAR_0, VAR_1, OPC_SRLV, VAR_4, VAR_3, VAR_4);
break;
case RR_SRAV:
gen_shift(VAR_0, VAR_1, OPC_SRAV, VAR_4, VAR_3, VAR_4);
break;
#if defined (TARGET_MIPS64)
case RR_DSRL:
check_mips_64(VAR_1);
gen_shift_imm(VAR_0, VAR_1, OPC_DSRL, VAR_4, VAR_4, VAR_5);
break;
#endif
case RR_CMP:
gen_logic(VAR_0, OPC_XOR, 24, VAR_3, VAR_4);
break;
case RR_NEG:
gen_arith(VAR_0, VAR_1, OPC_SUBU, VAR_3, 0, VAR_4);
break;
case RR_AND:
gen_logic(VAR_0, OPC_AND, VAR_3, VAR_3, VAR_4);
break;
case RR_OR:
gen_logic(VAR_0, OPC_OR, VAR_3, VAR_3, VAR_4);
break;
case RR_XOR:
gen_logic(VAR_0, OPC_XOR, VAR_3, VAR_3, VAR_4);
break;
case RR_NOT:
gen_logic(VAR_0, OPC_NOR, VAR_3, VAR_4, 0);
break;
case RR_MFHI:
gen_HILO(VAR_1, OPC_MFHI, VAR_3);
break;
case RR_CNVT:
switch (VAR_7) {
case RR_RY_CNVT_ZEB:
tcg_gen_ext8u_tl(cpu_gpr[VAR_3], cpu_gpr[VAR_3]);
break;
case RR_RY_CNVT_ZEH:
tcg_gen_ext16u_tl(cpu_gpr[VAR_3], cpu_gpr[VAR_3]);
break;
case RR_RY_CNVT_SEB:
tcg_gen_ext8s_tl(cpu_gpr[VAR_3], cpu_gpr[VAR_3]);
break;
case RR_RY_CNVT_SEH:
tcg_gen_ext16s_tl(cpu_gpr[VAR_3], cpu_gpr[VAR_3]);
break;
#if defined (TARGET_MIPS64)
case RR_RY_CNVT_ZEW:
check_mips_64(VAR_1);
tcg_gen_ext32u_tl(cpu_gpr[VAR_3], cpu_gpr[VAR_3]);
break;
case RR_RY_CNVT_SEW:
check_mips_64(VAR_1);
tcg_gen_ext32s_tl(cpu_gpr[VAR_3], cpu_gpr[VAR_3]);
break;
#endif
default:
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case RR_MFLO:
gen_HILO(VAR_1, OPC_MFLO, VAR_3);
break;
#if defined (TARGET_MIPS64)
case RR_DSRA:
check_mips_64(VAR_1);
gen_shift_imm(VAR_0, VAR_1, OPC_DSRA, VAR_4, VAR_4, VAR_5);
break;
case RR_DSLLV:
check_mips_64(VAR_1);
gen_shift(VAR_0, VAR_1, OPC_DSLLV, VAR_4, VAR_3, VAR_4);
break;
case RR_DSRLV:
check_mips_64(VAR_1);
gen_shift(VAR_0, VAR_1, OPC_DSRLV, VAR_4, VAR_3, VAR_4);
break;
case RR_DSRAV:
check_mips_64(VAR_1);
gen_shift(VAR_0, VAR_1, OPC_DSRAV, VAR_4, VAR_3, VAR_4);
break;
#endif
case RR_MULT:
gen_muldiv(VAR_1, OPC_MULT, VAR_3, VAR_4);
break;
case RR_MULTU:
gen_muldiv(VAR_1, OPC_MULTU, VAR_3, VAR_4);
break;
case RR_DIV:
gen_muldiv(VAR_1, OPC_DIV, VAR_3, VAR_4);
break;
case RR_DIVU:
gen_muldiv(VAR_1, OPC_DIVU, VAR_3, VAR_4);
break;
#if defined (TARGET_MIPS64)
case RR_DMULT:
check_mips_64(VAR_1);
gen_muldiv(VAR_1, OPC_DMULT, VAR_3, VAR_4);
break;
case RR_DMULTU:
check_mips_64(VAR_1);
gen_muldiv(VAR_1, OPC_DMULTU, VAR_3, VAR_4);
break;
case RR_DDIV:
check_mips_64(VAR_1);
gen_muldiv(VAR_1, OPC_DDIV, VAR_3, VAR_4);
break;
case RR_DDIVU:
check_mips_64(VAR_1);
gen_muldiv(VAR_1, OPC_DDIVU, VAR_3, VAR_4);
break;
#endif
default:
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case M16_OPC_EXTEND:
decode_extended_mips16_opc(VAR_0, VAR_1, VAR_2);
VAR_11 = 4;
break;
#if defined(TARGET_MIPS64)
case M16_OPC_I64:
VAR_10 = (VAR_1->opcode >> 8) & 0x7;
decode_i64_mips16(VAR_0, VAR_1, VAR_4, VAR_10, VAR_9, 0);
break;
#endif
default:
generate_exception(VAR_1, EXCP_RI);
break;
}
return VAR_11;
}
| [
"static int FUNC_0 (CPUState *VAR_0, DisasContext *VAR_1,\nint *VAR_2)\n{",
"int VAR_3, VAR_4;",
"int VAR_5;",
"int VAR_6, VAR_7, VAR_8, VAR_9;",
"int VAR_10;",
"int VAR_11;",
"VAR_6 = (VAR_1->opcode >> 11) & 0x1f;",
"VAR_5 = (VAR_1->opcode >> 2) & 0x7;",
"VAR_5 = VAR_5 == 0 ? 8 : VAR_5;",
"VAR_3 = xlat((VAR_1->opcode >> 8) & 0x7);",
"VAR_7 = (VAR_1->opcode >> 5) & 0x7;",
"VAR_4 = xlat((VAR_1->opcode >> 5) & 0x7);",
"VAR_8 = VAR_9 = VAR_1->opcode & 0x1f;",
"VAR_11 = 2;",
"switch (VAR_6) {",
"case M16_OPC_ADDIUSP:\n{",
"int16_t imm = ((uint8_t) VAR_1->opcode) << 2;",
"gen_arith_imm(VAR_0, VAR_1, OPC_ADDIU, VAR_3, 29, imm);",
"}",
"break;",
"case M16_OPC_ADDIUPC:\ngen_addiupc(VAR_1, VAR_3, ((uint8_t) VAR_1->opcode) << 2, 0, 0);",
"break;",
"case M16_OPC_B:\nVAR_9 = (VAR_1->opcode & 0x7ff) << 1;",
"VAR_9 = (int16_t)(VAR_9 << 4) >> 4;",
"gen_compute_branch(VAR_1, OPC_BEQ, 2, 0, 0, VAR_9);",
"break;",
"case M16_OPC_JAL:\nVAR_9 = lduw_code(VAR_1->pc + 2);",
"VAR_9 = (((VAR_1->opcode & 0x1f) << 21)\n| ((VAR_1->opcode >> 5) & 0x1f) << 16\n| VAR_9) << 2;",
"VAR_6 = ((VAR_1->opcode >> 10) & 0x1) ? OPC_JALX : OPC_JAL;",
"gen_compute_branch(VAR_1, VAR_6, 4, VAR_3, VAR_4, VAR_9);",
"VAR_11 = 4;",
"*VAR_2 = 1;",
"break;",
"case M16_OPC_BEQZ:\ngen_compute_branch(VAR_1, OPC_BEQ, 2, VAR_3, 0, ((int8_t)VAR_1->opcode) << 1);",
"break;",
"case M16_OPC_BNEQZ:\ngen_compute_branch(VAR_1, OPC_BNE, 2, VAR_3, 0, ((int8_t)VAR_1->opcode) << 1);",
"break;",
"case M16_OPC_SHIFT:\nswitch (VAR_1->opcode & 0x3) {",
"case 0x0:\ngen_shift_imm(VAR_0, VAR_1, OPC_SLL, VAR_3, VAR_4, VAR_5);",
"break;",
"case 0x1:\n#if defined(TARGET_MIPS64)\ncheck_mips_64(VAR_1);",
"gen_shift_imm(VAR_0, VAR_1, OPC_DSLL, VAR_3, VAR_4, VAR_5);",
"#else\ngenerate_exception(VAR_1, EXCP_RI);",
"#endif\nbreak;",
"case 0x2:\ngen_shift_imm(VAR_0, VAR_1, OPC_SRL, VAR_3, VAR_4, VAR_5);",
"break;",
"case 0x3:\ngen_shift_imm(VAR_0, VAR_1, OPC_SRA, VAR_3, VAR_4, VAR_5);",
"break;",
"}",
"break;",
"#if defined(TARGET_MIPS64)\ncase M16_OPC_LD:\ncheck_mips_64(VAR_1);",
"gen_ldst(VAR_1, OPC_LD, VAR_4, VAR_3, VAR_9 << 3);",
"break;",
"#endif\ncase M16_OPC_RRIA:\n{",
"int16_t imm = (int8_t)((VAR_1->opcode & 0xf) << 4) >> 4;",
"if ((VAR_1->opcode >> 4) & 1) {",
"#if defined(TARGET_MIPS64)\ncheck_mips_64(VAR_1);",
"gen_arith_imm(VAR_0, VAR_1, OPC_DADDIU, VAR_4, VAR_3, imm);",
"#else\ngenerate_exception(VAR_1, EXCP_RI);",
"#endif\n} else {",
"gen_arith_imm(VAR_0, VAR_1, OPC_ADDIU, VAR_4, VAR_3, imm);",
"}",
"}",
"break;",
"case M16_OPC_ADDIU8:\n{",
"int16_t imm = (int8_t) VAR_1->opcode;",
"gen_arith_imm(VAR_0, VAR_1, OPC_ADDIU, VAR_3, VAR_3, imm);",
"}",
"break;",
"case M16_OPC_SLTI:\n{",
"int16_t imm = (uint8_t) VAR_1->opcode;",
"gen_slt_imm(VAR_0, OPC_SLTI, 24, VAR_3, imm);",
"}",
"break;",
"case M16_OPC_SLTIU:\n{",
"int16_t imm = (uint8_t) VAR_1->opcode;",
"gen_slt_imm(VAR_0, OPC_SLTIU, 24, VAR_3, imm);",
"}",
"break;",
"case M16_OPC_I8:\n{",
"int VAR_12;",
"VAR_10 = (VAR_1->opcode >> 8) & 0x7;",
"switch (VAR_10) {",
"case I8_BTEQZ:\ngen_compute_branch(VAR_1, OPC_BEQ, 2, 24, 0,\n((int8_t)VAR_1->opcode) << 1);",
"break;",
"case I8_BTNEZ:\ngen_compute_branch(VAR_1, OPC_BNE, 2, 24, 0,\n((int8_t)VAR_1->opcode) << 1);",
"break;",
"case I8_SWRASP:\ngen_ldst(VAR_1, OPC_SW, 31, 29, (VAR_1->opcode & 0xff) << 2);",
"break;",
"case I8_ADJSP:\ngen_arith_imm(VAR_0, VAR_1, OPC_ADDIU, 29, 29,\n((int8_t)VAR_1->opcode) << 3);",
"break;",
"case I8_SVRS:\n{",
"int VAR_13 = VAR_1->opcode & (1 << 6);",
"int VAR_14 = VAR_1->opcode & (1 << 5);",
"int VAR_15 = VAR_1->opcode & (1 << 4);",
"int VAR_16 = VAR_1->opcode & 0xf;",
"if (VAR_16 == 0) {",
"VAR_16 = 128;",
"} else {",
"VAR_16 = VAR_16 << 3;",
"}",
"if (VAR_1->opcode & (1 << 7)) {",
"gen_mips16_save(VAR_1, 0, 0,\nVAR_13, VAR_14, VAR_15, VAR_16);",
"} else {",
"gen_mips16_restore(VAR_1, 0, 0,\nVAR_13, VAR_14, VAR_15, VAR_16);",
"}",
"}",
"break;",
"case I8_MOV32R:\n{",
"int VAR_18 = xlat(VAR_1->opcode & 0x7);",
"VAR_12 = (((VAR_1->opcode >> 3) & 0x3) << 3) |\n((VAR_1->opcode >> 5) & 0x7);",
"gen_arith(VAR_0, VAR_1, OPC_ADDU, VAR_12, VAR_18, 0);",
"}",
"break;",
"case I8_MOVR32:\nVAR_12 = VAR_1->opcode & 0x1f;",
"gen_arith(VAR_0, VAR_1, OPC_ADDU, VAR_4, VAR_12, 0);",
"break;",
"default:\ngenerate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"}",
"break;",
"case M16_OPC_LI:\n{",
"int16_t imm = (uint8_t) VAR_1->opcode;",
"gen_arith_imm(VAR_0, VAR_1, OPC_ADDIU, VAR_3, 0, imm);",
"}",
"break;",
"case M16_OPC_CMPI:\n{",
"int16_t imm = (uint8_t) VAR_1->opcode;",
"gen_logic_imm(VAR_0, OPC_XORI, 24, VAR_3, imm);",
"}",
"break;",
"#if defined(TARGET_MIPS64)\ncase M16_OPC_SD:\ncheck_mips_64(VAR_1);",
"gen_ldst(VAR_1, OPC_SD, VAR_4, VAR_3, VAR_9 << 3);",
"break;",
"#endif\ncase M16_OPC_LB:\ngen_ldst(VAR_1, OPC_LB, VAR_4, VAR_3, VAR_9);",
"break;",
"case M16_OPC_LH:\ngen_ldst(VAR_1, OPC_LH, VAR_4, VAR_3, VAR_9 << 1);",
"break;",
"case M16_OPC_LWSP:\ngen_ldst(VAR_1, OPC_LW, VAR_3, 29, ((uint8_t)VAR_1->opcode) << 2);",
"break;",
"case M16_OPC_LW:\ngen_ldst(VAR_1, OPC_LW, VAR_4, VAR_3, VAR_9 << 2);",
"break;",
"case M16_OPC_LBU:\ngen_ldst(VAR_1, OPC_LBU, VAR_4, VAR_3, VAR_9);",
"break;",
"case M16_OPC_LHU:\ngen_ldst(VAR_1, OPC_LHU, VAR_4, VAR_3, VAR_9 << 1);",
"break;",
"case M16_OPC_LWPC:\ngen_ldst(VAR_1, OPC_LWPC, VAR_3, 0, ((uint8_t)VAR_1->opcode) << 2);",
"break;",
"#if defined (TARGET_MIPS64)\ncase M16_OPC_LWU:\ncheck_mips_64(VAR_1);",
"gen_ldst(VAR_1, OPC_LWU, VAR_4, VAR_3, VAR_9 << 2);",
"break;",
"#endif\ncase M16_OPC_SB:\ngen_ldst(VAR_1, OPC_SB, VAR_4, VAR_3, VAR_9);",
"break;",
"case M16_OPC_SH:\ngen_ldst(VAR_1, OPC_SH, VAR_4, VAR_3, VAR_9 << 1);",
"break;",
"case M16_OPC_SWSP:\ngen_ldst(VAR_1, OPC_SW, VAR_3, 29, ((uint8_t)VAR_1->opcode) << 2);",
"break;",
"case M16_OPC_SW:\ngen_ldst(VAR_1, OPC_SW, VAR_4, VAR_3, VAR_9 << 2);",
"break;",
"case M16_OPC_RRR:\n{",
"int VAR_18 = xlat((VAR_1->opcode >> 2) & 0x7);",
"int VAR_18;",
"switch (VAR_1->opcode & 0x3) {",
"case RRR_ADDU:\nVAR_18 = OPC_ADDU;",
"break;",
"case RRR_SUBU:\nVAR_18 = OPC_SUBU;",
"break;",
"#if defined(TARGET_MIPS64)\ncase RRR_DADDU:\nVAR_18 = OPC_DADDU;",
"check_mips_64(VAR_1);",
"break;",
"case RRR_DSUBU:\nVAR_18 = OPC_DSUBU;",
"check_mips_64(VAR_1);",
"break;",
"#endif\ndefault:\ngenerate_exception(VAR_1, EXCP_RI);",
"goto done;",
"}",
"gen_arith(VAR_0, VAR_1, VAR_18, VAR_18, VAR_3, VAR_4);",
"done:\n;",
"}",
"break;",
"case M16_OPC_RR:\nswitch (VAR_8) {",
"case RR_JR:\n{",
"int VAR_19 = (VAR_1->opcode >> 7) & 0x1;",
"int VAR_20 = (VAR_1->opcode >> 6) & 0x1;",
"int VAR_21 = (VAR_1->opcode >> 5) & 0x1;",
"if (VAR_20) {",
"VAR_6 = VAR_19 ? OPC_JALRC : OPC_JALR;",
"} else {",
"VAR_6 = OPC_JR;",
"}",
"gen_compute_branch(VAR_1, VAR_6, 2, VAR_21 ? 31 : VAR_3, 31, 0);",
"if (!VAR_19) {",
"*VAR_2 = 1;",
"}",
"}",
"break;",
"case RR_SDBBP:\ncheck_insn(VAR_0, VAR_1, ISA_MIPS32);",
"if (!(VAR_1->hflags & MIPS_HFLAG_DM)) {",
"generate_exception(VAR_1, EXCP_DBp);",
"} else {",
"generate_exception(VAR_1, EXCP_DBp);",
"}",
"break;",
"case RR_SLT:\ngen_slt(VAR_0, OPC_SLT, 24, VAR_3, VAR_4);",
"break;",
"case RR_SLTU:\ngen_slt(VAR_0, OPC_SLTU, 24, VAR_3, VAR_4);",
"break;",
"case RR_BREAK:\ngenerate_exception(VAR_1, EXCP_BREAK);",
"break;",
"case RR_SLLV:\ngen_shift(VAR_0, VAR_1, OPC_SLLV, VAR_4, VAR_3, VAR_4);",
"break;",
"case RR_SRLV:\ngen_shift(VAR_0, VAR_1, OPC_SRLV, VAR_4, VAR_3, VAR_4);",
"break;",
"case RR_SRAV:\ngen_shift(VAR_0, VAR_1, OPC_SRAV, VAR_4, VAR_3, VAR_4);",
"break;",
"#if defined (TARGET_MIPS64)\ncase RR_DSRL:\ncheck_mips_64(VAR_1);",
"gen_shift_imm(VAR_0, VAR_1, OPC_DSRL, VAR_4, VAR_4, VAR_5);",
"break;",
"#endif\ncase RR_CMP:\ngen_logic(VAR_0, OPC_XOR, 24, VAR_3, VAR_4);",
"break;",
"case RR_NEG:\ngen_arith(VAR_0, VAR_1, OPC_SUBU, VAR_3, 0, VAR_4);",
"break;",
"case RR_AND:\ngen_logic(VAR_0, OPC_AND, VAR_3, VAR_3, VAR_4);",
"break;",
"case RR_OR:\ngen_logic(VAR_0, OPC_OR, VAR_3, VAR_3, VAR_4);",
"break;",
"case RR_XOR:\ngen_logic(VAR_0, OPC_XOR, VAR_3, VAR_3, VAR_4);",
"break;",
"case RR_NOT:\ngen_logic(VAR_0, OPC_NOR, VAR_3, VAR_4, 0);",
"break;",
"case RR_MFHI:\ngen_HILO(VAR_1, OPC_MFHI, VAR_3);",
"break;",
"case RR_CNVT:\nswitch (VAR_7) {",
"case RR_RY_CNVT_ZEB:\ntcg_gen_ext8u_tl(cpu_gpr[VAR_3], cpu_gpr[VAR_3]);",
"break;",
"case RR_RY_CNVT_ZEH:\ntcg_gen_ext16u_tl(cpu_gpr[VAR_3], cpu_gpr[VAR_3]);",
"break;",
"case RR_RY_CNVT_SEB:\ntcg_gen_ext8s_tl(cpu_gpr[VAR_3], cpu_gpr[VAR_3]);",
"break;",
"case RR_RY_CNVT_SEH:\ntcg_gen_ext16s_tl(cpu_gpr[VAR_3], cpu_gpr[VAR_3]);",
"break;",
"#if defined (TARGET_MIPS64)\ncase RR_RY_CNVT_ZEW:\ncheck_mips_64(VAR_1);",
"tcg_gen_ext32u_tl(cpu_gpr[VAR_3], cpu_gpr[VAR_3]);",
"break;",
"case RR_RY_CNVT_SEW:\ncheck_mips_64(VAR_1);",
"tcg_gen_ext32s_tl(cpu_gpr[VAR_3], cpu_gpr[VAR_3]);",
"break;",
"#endif\ndefault:\ngenerate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case RR_MFLO:\ngen_HILO(VAR_1, OPC_MFLO, VAR_3);",
"break;",
"#if defined (TARGET_MIPS64)\ncase RR_DSRA:\ncheck_mips_64(VAR_1);",
"gen_shift_imm(VAR_0, VAR_1, OPC_DSRA, VAR_4, VAR_4, VAR_5);",
"break;",
"case RR_DSLLV:\ncheck_mips_64(VAR_1);",
"gen_shift(VAR_0, VAR_1, OPC_DSLLV, VAR_4, VAR_3, VAR_4);",
"break;",
"case RR_DSRLV:\ncheck_mips_64(VAR_1);",
"gen_shift(VAR_0, VAR_1, OPC_DSRLV, VAR_4, VAR_3, VAR_4);",
"break;",
"case RR_DSRAV:\ncheck_mips_64(VAR_1);",
"gen_shift(VAR_0, VAR_1, OPC_DSRAV, VAR_4, VAR_3, VAR_4);",
"break;",
"#endif\ncase RR_MULT:\ngen_muldiv(VAR_1, OPC_MULT, VAR_3, VAR_4);",
"break;",
"case RR_MULTU:\ngen_muldiv(VAR_1, OPC_MULTU, VAR_3, VAR_4);",
"break;",
"case RR_DIV:\ngen_muldiv(VAR_1, OPC_DIV, VAR_3, VAR_4);",
"break;",
"case RR_DIVU:\ngen_muldiv(VAR_1, OPC_DIVU, VAR_3, VAR_4);",
"break;",
"#if defined (TARGET_MIPS64)\ncase RR_DMULT:\ncheck_mips_64(VAR_1);",
"gen_muldiv(VAR_1, OPC_DMULT, VAR_3, VAR_4);",
"break;",
"case RR_DMULTU:\ncheck_mips_64(VAR_1);",
"gen_muldiv(VAR_1, OPC_DMULTU, VAR_3, VAR_4);",
"break;",
"case RR_DDIV:\ncheck_mips_64(VAR_1);",
"gen_muldiv(VAR_1, OPC_DDIV, VAR_3, VAR_4);",
"break;",
"case RR_DDIVU:\ncheck_mips_64(VAR_1);",
"gen_muldiv(VAR_1, OPC_DDIVU, VAR_3, VAR_4);",
"break;",
"#endif\ndefault:\ngenerate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case M16_OPC_EXTEND:\ndecode_extended_mips16_opc(VAR_0, VAR_1, VAR_2);",
"VAR_11 = 4;",
"break;",
"#if defined(TARGET_MIPS64)\ncase M16_OPC_I64:\nVAR_10 = (VAR_1->opcode >> 8) & 0x7;",
"decode_i64_mips16(VAR_0, VAR_1, VAR_4, VAR_10, VAR_9, 0);",
"break;",
"#endif\ndefault:\ngenerate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"return VAR_11;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
39
],
[
41,
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
71
],
[
73,
75
],
[
77,
79,
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93,
95
],
[
99
],
[
101,
103
],
[
107
],
[
109,
111
],
[
113,
115
],
[
117
],
[
119,
121,
123
],
[
125
],
[
127,
129
],
[
131,
133
],
[
135,
137
],
[
139
],
[
141,
143
],
[
145
],
[
147
],
[
149
],
[
151,
153,
155
],
[
157
],
[
159
],
[
161,
163,
165
],
[
167
],
[
171
],
[
173,
175
],
[
177
],
[
179,
181
],
[
183,
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195,
197
],
[
199
],
[
203
],
[
205
],
[
207
],
[
209,
211
],
[
213
],
[
217
],
[
219
],
[
221
],
[
223,
225
],
[
227
],
[
231
],
[
233
],
[
235
],
[
237,
239
],
[
241
],
[
245
],
[
247
],
[
249,
251,
253
],
[
255
],
[
257,
259,
261
],
[
263
],
[
265,
267
],
[
269
],
[
271,
273,
275
],
[
277
],
[
279,
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
305
],
[
307,
309
],
[
311
],
[
313,
315
],
[
317
],
[
319
],
[
321
],
[
323,
325
],
[
327
],
[
331,
333
],
[
335
],
[
337
],
[
339
],
[
341,
343
],
[
345
],
[
347
],
[
349,
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361,
363
],
[
365
],
[
369
],
[
371
],
[
373
],
[
375,
377
],
[
379
],
[
383
],
[
385
],
[
387
],
[
389,
391,
393
],
[
395
],
[
397
],
[
399,
401,
403
],
[
405
],
[
407,
409
],
[
411
],
[
413,
415
],
[
417
],
[
419,
421
],
[
423
],
[
425,
427
],
[
429
],
[
431,
433
],
[
435
],
[
437,
439
],
[
441
],
[
443,
445,
447
],
[
449
],
[
451
],
[
453,
455,
457
],
[
459
],
[
461,
463
],
[
465
],
[
467,
469
],
[
471
],
[
473,
475
],
[
477
],
[
479,
481
],
[
483
],
[
485
],
[
489
],
[
491,
493
],
[
495
],
[
497,
499
],
[
501
],
[
503,
505,
507
],
[
509
],
[
511
],
[
513,
515
],
[
517
],
[
519
],
[
521,
523,
525
],
[
527
],
[
529
],
[
533
],
[
535,
537
],
[
539
],
[
541
],
[
543,
545
],
[
547,
549
],
[
551
],
[
553
],
[
555
],
[
559
],
[
561
],
[
563
],
[
565
],
[
567
],
[
571
],
[
573
],
[
575
],
[
577
],
[
579
],
[
581
],
[
583,
591
],
[
593
],
[
595
],
[
597
],
[
599
],
[
601
],
[
603
],
[
605,
607
],
[
609
],
[
611,
613
],
[
615
],
[
617,
619
],
[
621
],
[
623,
625
],
[
627
],
[
629,
631
],
[
633
],
[
635,
637
],
[
639
],
[
641,
643,
645
],
[
647
],
[
649
],
[
651,
653,
655
],
[
657
],
[
659,
661
],
[
663
],
[
665,
667
],
[
669
],
[
671,
673
],
[
675
],
[
677,
679
],
[
681
],
[
683,
685
],
[
687
],
[
689,
691
],
[
693
],
[
695,
697
],
[
699,
701
],
[
703
],
[
705,
707
],
[
709
],
[
711,
713
],
[
715
],
[
717,
719
],
[
721
],
[
723,
725,
727
],
[
729
],
[
731
],
[
733,
735
],
[
737
],
[
739
],
[
741,
743,
745
],
[
747
],
[
749
],
[
751
],
[
753,
755
],
[
757
],
[
759,
761,
763
],
[
765
],
[
767
],
[
769,
771
],
[
773
],
[
775
],
[
777,
779
],
[
781
],
[
783
],
[
785,
787
],
[
789
],
[
791
],
[
793,
795,
797
],
[
799
],
[
801,
803
],
[
805
],
[
807,
809
],
[
811
],
[
813,
815
],
[
817
],
[
819,
821,
823
],
[
825
],
[
827
],
[
829,
831
],
[
833
],
[
835
],
[
837,
839
],
[
841
],
[
843
],
[
845,
847
],
[
849
],
[
851
],
[
853,
855,
857
],
[
859
],
[
861
],
[
863
],
[
865,
867
],
[
869
],
[
871
],
[
873,
875,
877
],
[
879
],
[
881
],
[
883,
885,
887
],
[
889
],
[
891
],
[
895
],
[
897
]
] |
27,051 | static int smc_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
SmcContext *s = avctx->priv_data;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
int ret;
bytestream2_init(&s->gb, buf, buf_size);
if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
return ret;
if (pal) {
s->frame->palette_has_changed = 1;
memcpy(s->pal, pal, AVPALETTE_SIZE);
}
smc_decode_stream(s);
*got_frame = 1;
if ((ret = av_frame_ref(data, s->frame)) < 0)
return ret;
/* always report that the buffer was completely consumed */
return buf_size;
}
| false | FFmpeg | 140f48b90fbe32a88423aad473bccc72c3bb450e | static int smc_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
SmcContext *s = avctx->priv_data;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
int ret;
bytestream2_init(&s->gb, buf, buf_size);
if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
return ret;
if (pal) {
s->frame->palette_has_changed = 1;
memcpy(s->pal, pal, AVPALETTE_SIZE);
}
smc_decode_stream(s);
*got_frame = 1;
if ((ret = av_frame_ref(data, s->frame)) < 0)
return ret;
return buf_size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
SmcContext *s = VAR_0->priv_data;
const uint8_t *VAR_6 = av_packet_get_side_data(VAR_3, AV_PKT_DATA_PALETTE, NULL);
int VAR_7;
bytestream2_init(&s->gb, VAR_4, VAR_5);
if ((VAR_7 = ff_reget_buffer(VAR_0, s->frame)) < 0)
return VAR_7;
if (VAR_6) {
s->frame->palette_has_changed = 1;
memcpy(s->VAR_6, VAR_6, AVPALETTE_SIZE);
}
smc_decode_stream(s);
*VAR_2 = 1;
if ((VAR_7 = av_frame_ref(VAR_1, s->frame)) < 0)
return VAR_7;
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;",
"SmcContext *s = VAR_0->priv_data;",
"const uint8_t *VAR_6 = av_packet_get_side_data(VAR_3, AV_PKT_DATA_PALETTE, NULL);",
"int VAR_7;",
"bytestream2_init(&s->gb, VAR_4, VAR_5);",
"if ((VAR_7 = ff_reget_buffer(VAR_0, s->frame)) < 0)\nreturn VAR_7;",
"if (VAR_6) {",
"s->frame->palette_has_changed = 1;",
"memcpy(s->VAR_6, VAR_6, AVPALETTE_SIZE);",
"}",
"smc_decode_stream(s);",
"*VAR_2 = 1;",
"if ((VAR_7 = av_frame_ref(VAR_1, s->frame)) < 0)\nreturn VAR_7;",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
25,
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
45
],
[
47,
49
],
[
55
],
[
57
]
] |
27,052 | static void proxy_seekdir(FsContext *ctx, V9fsFidOpenState *fs, off_t off)
{
seekdir(fs->dir, off);
}
| false | qemu | 494a8ebe713055d3946183f4b395f85a18b43e9e | static void proxy_seekdir(FsContext *ctx, V9fsFidOpenState *fs, off_t off)
{
seekdir(fs->dir, off);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(FsContext *VAR_0, V9fsFidOpenState *VAR_1, off_t VAR_2)
{
seekdir(VAR_1->dir, VAR_2);
}
| [
"static void FUNC_0(FsContext *VAR_0, V9fsFidOpenState *VAR_1, off_t VAR_2)\n{",
"seekdir(VAR_1->dir, VAR_2);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
27,053 | void virtio_notify(VirtIODevice *vdev, VirtQueue *vq)
{
/* Always notify when queue is empty */
if ((vq->inuse || vring_avail_idx(vq) != vq->last_avail_idx) &&
(vring_avail_flags(vq) & VRING_AVAIL_F_NO_INTERRUPT))
return;
vdev->isr |= 0x01;
virtio_update_irq(vdev);
}
| false | qemu | 97b83deb557679c909465456acaa723c2ba34948 | void virtio_notify(VirtIODevice *vdev, VirtQueue *vq)
{
if ((vq->inuse || vring_avail_idx(vq) != vq->last_avail_idx) &&
(vring_avail_flags(vq) & VRING_AVAIL_F_NO_INTERRUPT))
return;
vdev->isr |= 0x01;
virtio_update_irq(vdev);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(VirtIODevice *VAR_0, VirtQueue *VAR_1)
{
if ((VAR_1->inuse || vring_avail_idx(VAR_1) != VAR_1->last_avail_idx) &&
(vring_avail_flags(VAR_1) & VRING_AVAIL_F_NO_INTERRUPT))
return;
VAR_0->isr |= 0x01;
virtio_update_irq(VAR_0);
}
| [
"void FUNC_0(VirtIODevice *VAR_0, VirtQueue *VAR_1)\n{",
"if ((VAR_1->inuse || vring_avail_idx(VAR_1) != VAR_1->last_avail_idx) &&\n(vring_avail_flags(VAR_1) & VRING_AVAIL_F_NO_INTERRUPT))\nreturn;",
"VAR_0->isr |= 0x01;",
"virtio_update_irq(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
7,
9,
11
],
[
15
],
[
17
],
[
19
]
] |
27,054 | static int64_t allocate_cluster(BlockDriverState *bs, int64_t sector_num)
{
BDRVParallelsState *s = bs->opaque;
uint32_t idx, offset, tmp;
int64_t pos;
int ret;
idx = sector_num / s->tracks;
offset = sector_num % s->tracks;
if (idx >= s->catalog_size) {
return -EINVAL;
}
if (s->catalog_bitmap[idx] != 0) {
return (uint64_t)s->catalog_bitmap[idx] * s->off_multiplier + offset;
}
pos = bdrv_getlength(bs->file) >> BDRV_SECTOR_BITS;
if (s->has_truncate) {
ret = bdrv_truncate(bs->file, (pos + s->tracks) << BDRV_SECTOR_BITS);
} else {
ret = bdrv_write_zeroes(bs->file, pos, s->tracks, 0);
}
if (ret < 0) {
return ret;
}
s->catalog_bitmap[idx] = pos / s->off_multiplier;
tmp = cpu_to_le32(s->catalog_bitmap[idx]);
ret = bdrv_pwrite(bs->file,
sizeof(ParallelsHeader) + idx * sizeof(tmp), &tmp, sizeof(tmp));
if (ret < 0) {
s->catalog_bitmap[idx] = 0;
return ret;
}
return (uint64_t)s->catalog_bitmap[idx] * s->off_multiplier + offset;
}
| false | qemu | 369f7de9d57e4dd2f312255fc12271d5749c0a4e | static int64_t allocate_cluster(BlockDriverState *bs, int64_t sector_num)
{
BDRVParallelsState *s = bs->opaque;
uint32_t idx, offset, tmp;
int64_t pos;
int ret;
idx = sector_num / s->tracks;
offset = sector_num % s->tracks;
if (idx >= s->catalog_size) {
return -EINVAL;
}
if (s->catalog_bitmap[idx] != 0) {
return (uint64_t)s->catalog_bitmap[idx] * s->off_multiplier + offset;
}
pos = bdrv_getlength(bs->file) >> BDRV_SECTOR_BITS;
if (s->has_truncate) {
ret = bdrv_truncate(bs->file, (pos + s->tracks) << BDRV_SECTOR_BITS);
} else {
ret = bdrv_write_zeroes(bs->file, pos, s->tracks, 0);
}
if (ret < 0) {
return ret;
}
s->catalog_bitmap[idx] = pos / s->off_multiplier;
tmp = cpu_to_le32(s->catalog_bitmap[idx]);
ret = bdrv_pwrite(bs->file,
sizeof(ParallelsHeader) + idx * sizeof(tmp), &tmp, sizeof(tmp));
if (ret < 0) {
s->catalog_bitmap[idx] = 0;
return ret;
}
return (uint64_t)s->catalog_bitmap[idx] * s->off_multiplier + offset;
}
| {
"code": [],
"line_no": []
} | static int64_t FUNC_0(BlockDriverState *bs, int64_t sector_num)
{
BDRVParallelsState *s = bs->opaque;
uint32_t idx, offset, tmp;
int64_t pos;
int VAR_0;
idx = sector_num / s->tracks;
offset = sector_num % s->tracks;
if (idx >= s->catalog_size) {
return -EINVAL;
}
if (s->catalog_bitmap[idx] != 0) {
return (uint64_t)s->catalog_bitmap[idx] * s->off_multiplier + offset;
}
pos = bdrv_getlength(bs->file) >> BDRV_SECTOR_BITS;
if (s->has_truncate) {
VAR_0 = bdrv_truncate(bs->file, (pos + s->tracks) << BDRV_SECTOR_BITS);
} else {
VAR_0 = bdrv_write_zeroes(bs->file, pos, s->tracks, 0);
}
if (VAR_0 < 0) {
return VAR_0;
}
s->catalog_bitmap[idx] = pos / s->off_multiplier;
tmp = cpu_to_le32(s->catalog_bitmap[idx]);
VAR_0 = bdrv_pwrite(bs->file,
sizeof(ParallelsHeader) + idx * sizeof(tmp), &tmp, sizeof(tmp));
if (VAR_0 < 0) {
s->catalog_bitmap[idx] = 0;
return VAR_0;
}
return (uint64_t)s->catalog_bitmap[idx] * s->off_multiplier + offset;
}
| [
"static int64_t FUNC_0(BlockDriverState *bs, int64_t sector_num)\n{",
"BDRVParallelsState *s = bs->opaque;",
"uint32_t idx, offset, tmp;",
"int64_t pos;",
"int VAR_0;",
"idx = sector_num / s->tracks;",
"offset = sector_num % s->tracks;",
"if (idx >= s->catalog_size) {",
"return -EINVAL;",
"}",
"if (s->catalog_bitmap[idx] != 0) {",
"return (uint64_t)s->catalog_bitmap[idx] * s->off_multiplier + offset;",
"}",
"pos = bdrv_getlength(bs->file) >> BDRV_SECTOR_BITS;",
"if (s->has_truncate) {",
"VAR_0 = bdrv_truncate(bs->file, (pos + s->tracks) << BDRV_SECTOR_BITS);",
"} else {",
"VAR_0 = bdrv_write_zeroes(bs->file, pos, s->tracks, 0);",
"}",
"if (VAR_0 < 0) {",
"return VAR_0;",
"}",
"s->catalog_bitmap[idx] = pos / s->off_multiplier;",
"tmp = cpu_to_le32(s->catalog_bitmap[idx]);",
"VAR_0 = bdrv_pwrite(bs->file,\nsizeof(ParallelsHeader) + idx * sizeof(tmp), &tmp, sizeof(tmp));",
"if (VAR_0 < 0) {",
"s->catalog_bitmap[idx] = 0;",
"return VAR_0;",
"}",
"return (uint64_t)s->catalog_bitmap[idx] * s->off_multiplier + offset;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
59
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
]
] |
27,055 | static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVVdiState *s = bs->opaque;
VdiHeader header;
size_t bmap_size;
int ret;
logout("\n");
ret = bdrv_read(bs->file, 0, (uint8_t *)&header, 1);
if (ret < 0) {
goto fail;
}
vdi_header_to_cpu(&header);
#if defined(CONFIG_VDI_DEBUG)
vdi_header_print(&header);
#endif
if (header.disk_size % SECTOR_SIZE != 0) {
/* 'VBoxManage convertfromraw' can create images with odd disk sizes.
We accept them but round the disk size to the next multiple of
SECTOR_SIZE. */
logout("odd disk size %" PRIu64 " B, round up\n", header.disk_size);
header.disk_size += SECTOR_SIZE - 1;
header.disk_size &= ~(SECTOR_SIZE - 1);
}
if (header.signature != VDI_SIGNATURE) {
logout("bad vdi signature %08x\n", header.signature);
ret = -EMEDIUMTYPE;
goto fail;
} else if (header.version != VDI_VERSION_1_1) {
logout("unsupported version %u.%u\n",
header.version >> 16, header.version & 0xffff);
ret = -ENOTSUP;
goto fail;
} else if (header.offset_bmap % SECTOR_SIZE != 0) {
/* We only support block maps which start on a sector boundary. */
logout("unsupported block map offset 0x%x B\n", header.offset_bmap);
ret = -ENOTSUP;
goto fail;
} else if (header.offset_data % SECTOR_SIZE != 0) {
/* We only support data blocks which start on a sector boundary. */
logout("unsupported data offset 0x%x B\n", header.offset_data);
ret = -ENOTSUP;
goto fail;
} else if (header.sector_size != SECTOR_SIZE) {
logout("unsupported sector size %u B\n", header.sector_size);
ret = -ENOTSUP;
goto fail;
} else if (header.block_size != 1 * MiB) {
logout("unsupported block size %u B\n", header.block_size);
ret = -ENOTSUP;
goto fail;
} else if (header.disk_size >
(uint64_t)header.blocks_in_image * header.block_size) {
logout("unsupported disk size %" PRIu64 " B\n", header.disk_size);
ret = -ENOTSUP;
goto fail;
} else if (!uuid_is_null(header.uuid_link)) {
logout("link uuid != 0, unsupported\n");
ret = -ENOTSUP;
goto fail;
} else if (!uuid_is_null(header.uuid_parent)) {
logout("parent uuid != 0, unsupported\n");
ret = -ENOTSUP;
goto fail;
}
bs->total_sectors = header.disk_size / SECTOR_SIZE;
s->block_size = header.block_size;
s->block_sectors = header.block_size / SECTOR_SIZE;
s->bmap_sector = header.offset_bmap / SECTOR_SIZE;
s->header = header;
bmap_size = header.blocks_in_image * sizeof(uint32_t);
bmap_size = (bmap_size + SECTOR_SIZE - 1) / SECTOR_SIZE;
s->bmap = g_malloc(bmap_size * SECTOR_SIZE);
ret = bdrv_read(bs->file, s->bmap_sector, (uint8_t *)s->bmap, bmap_size);
if (ret < 0) {
goto fail_free_bmap;
}
/* Disable migration when vdi images are used */
error_set(&s->migration_blocker,
QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED,
"vdi", bs->device_name, "live migration");
migrate_add_blocker(s->migration_blocker);
return 0;
fail_free_bmap:
g_free(s->bmap);
fail:
return ret;
}
| false | qemu | 76abe4071d111a9ca6dcc9b9689a831c39ffa718 | static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVVdiState *s = bs->opaque;
VdiHeader header;
size_t bmap_size;
int ret;
logout("\n");
ret = bdrv_read(bs->file, 0, (uint8_t *)&header, 1);
if (ret < 0) {
goto fail;
}
vdi_header_to_cpu(&header);
#if defined(CONFIG_VDI_DEBUG)
vdi_header_print(&header);
#endif
if (header.disk_size % SECTOR_SIZE != 0) {
logout("odd disk size %" PRIu64 " B, round up\n", header.disk_size);
header.disk_size += SECTOR_SIZE - 1;
header.disk_size &= ~(SECTOR_SIZE - 1);
}
if (header.signature != VDI_SIGNATURE) {
logout("bad vdi signature %08x\n", header.signature);
ret = -EMEDIUMTYPE;
goto fail;
} else if (header.version != VDI_VERSION_1_1) {
logout("unsupported version %u.%u\n",
header.version >> 16, header.version & 0xffff);
ret = -ENOTSUP;
goto fail;
} else if (header.offset_bmap % SECTOR_SIZE != 0) {
logout("unsupported block map offset 0x%x B\n", header.offset_bmap);
ret = -ENOTSUP;
goto fail;
} else if (header.offset_data % SECTOR_SIZE != 0) {
logout("unsupported data offset 0x%x B\n", header.offset_data);
ret = -ENOTSUP;
goto fail;
} else if (header.sector_size != SECTOR_SIZE) {
logout("unsupported sector size %u B\n", header.sector_size);
ret = -ENOTSUP;
goto fail;
} else if (header.block_size != 1 * MiB) {
logout("unsupported block size %u B\n", header.block_size);
ret = -ENOTSUP;
goto fail;
} else if (header.disk_size >
(uint64_t)header.blocks_in_image * header.block_size) {
logout("unsupported disk size %" PRIu64 " B\n", header.disk_size);
ret = -ENOTSUP;
goto fail;
} else if (!uuid_is_null(header.uuid_link)) {
logout("link uuid != 0, unsupported\n");
ret = -ENOTSUP;
goto fail;
} else if (!uuid_is_null(header.uuid_parent)) {
logout("parent uuid != 0, unsupported\n");
ret = -ENOTSUP;
goto fail;
}
bs->total_sectors = header.disk_size / SECTOR_SIZE;
s->block_size = header.block_size;
s->block_sectors = header.block_size / SECTOR_SIZE;
s->bmap_sector = header.offset_bmap / SECTOR_SIZE;
s->header = header;
bmap_size = header.blocks_in_image * sizeof(uint32_t);
bmap_size = (bmap_size + SECTOR_SIZE - 1) / SECTOR_SIZE;
s->bmap = g_malloc(bmap_size * SECTOR_SIZE);
ret = bdrv_read(bs->file, s->bmap_sector, (uint8_t *)s->bmap, bmap_size);
if (ret < 0) {
goto fail_free_bmap;
}
error_set(&s->migration_blocker,
QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED,
"vdi", bs->device_name, "live migration");
migrate_add_blocker(s->migration_blocker);
return 0;
fail_free_bmap:
g_free(s->bmap);
fail:
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,
Error **VAR_3)
{
BDRVVdiState *s = VAR_0->opaque;
VdiHeader header;
size_t bmap_size;
int VAR_4;
logout("\n");
VAR_4 = bdrv_read(VAR_0->file, 0, (uint8_t *)&header, 1);
if (VAR_4 < 0) {
goto fail;
}
vdi_header_to_cpu(&header);
#if defined(CONFIG_VDI_DEBUG)
vdi_header_print(&header);
#endif
if (header.disk_size % SECTOR_SIZE != 0) {
logout("odd disk size %" PRIu64 " B, round up\n", header.disk_size);
header.disk_size += SECTOR_SIZE - 1;
header.disk_size &= ~(SECTOR_SIZE - 1);
}
if (header.signature != VDI_SIGNATURE) {
logout("bad vdi signature %08x\n", header.signature);
VAR_4 = -EMEDIUMTYPE;
goto fail;
} else if (header.version != VDI_VERSION_1_1) {
logout("unsupported version %u.%u\n",
header.version >> 16, header.version & 0xffff);
VAR_4 = -ENOTSUP;
goto fail;
} else if (header.offset_bmap % SECTOR_SIZE != 0) {
logout("unsupported block map offset 0x%x B\n", header.offset_bmap);
VAR_4 = -ENOTSUP;
goto fail;
} else if (header.offset_data % SECTOR_SIZE != 0) {
logout("unsupported data offset 0x%x B\n", header.offset_data);
VAR_4 = -ENOTSUP;
goto fail;
} else if (header.sector_size != SECTOR_SIZE) {
logout("unsupported sector size %u B\n", header.sector_size);
VAR_4 = -ENOTSUP;
goto fail;
} else if (header.block_size != 1 * MiB) {
logout("unsupported block size %u B\n", header.block_size);
VAR_4 = -ENOTSUP;
goto fail;
} else if (header.disk_size >
(uint64_t)header.blocks_in_image * header.block_size) {
logout("unsupported disk size %" PRIu64 " B\n", header.disk_size);
VAR_4 = -ENOTSUP;
goto fail;
} else if (!uuid_is_null(header.uuid_link)) {
logout("link uuid != 0, unsupported\n");
VAR_4 = -ENOTSUP;
goto fail;
} else if (!uuid_is_null(header.uuid_parent)) {
logout("parent uuid != 0, unsupported\n");
VAR_4 = -ENOTSUP;
goto fail;
}
VAR_0->total_sectors = header.disk_size / SECTOR_SIZE;
s->block_size = header.block_size;
s->block_sectors = header.block_size / SECTOR_SIZE;
s->bmap_sector = header.offset_bmap / SECTOR_SIZE;
s->header = header;
bmap_size = header.blocks_in_image * sizeof(uint32_t);
bmap_size = (bmap_size + SECTOR_SIZE - 1) / SECTOR_SIZE;
s->bmap = g_malloc(bmap_size * SECTOR_SIZE);
VAR_4 = bdrv_read(VAR_0->file, s->bmap_sector, (uint8_t *)s->bmap, bmap_size);
if (VAR_4 < 0) {
goto fail_free_bmap;
}
error_set(&s->migration_blocker,
QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED,
"vdi", VAR_0->device_name, "live migration");
migrate_add_blocker(s->migration_blocker);
return 0;
fail_free_bmap:
g_free(s->bmap);
fail:
return VAR_4;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,\nError **VAR_3)\n{",
"BDRVVdiState *s = VAR_0->opaque;",
"VdiHeader header;",
"size_t bmap_size;",
"int VAR_4;",
"logout(\"\\n\");",
"VAR_4 = bdrv_read(VAR_0->file, 0, (uint8_t *)&header, 1);",
"if (VAR_4 < 0) {",
"goto fail;",
"}",
"vdi_header_to_cpu(&header);",
"#if defined(CONFIG_VDI_DEBUG)\nvdi_header_print(&header);",
"#endif\nif (header.disk_size % SECTOR_SIZE != 0) {",
"logout(\"odd disk size %\" PRIu64 \" B, round up\\n\", header.disk_size);",
"header.disk_size += SECTOR_SIZE - 1;",
"header.disk_size &= ~(SECTOR_SIZE - 1);",
"}",
"if (header.signature != VDI_SIGNATURE) {",
"logout(\"bad vdi signature %08x\\n\", header.signature);",
"VAR_4 = -EMEDIUMTYPE;",
"goto fail;",
"} else if (header.version != VDI_VERSION_1_1) {",
"logout(\"unsupported version %u.%u\\n\",\nheader.version >> 16, header.version & 0xffff);",
"VAR_4 = -ENOTSUP;",
"goto fail;",
"} else if (header.offset_bmap % SECTOR_SIZE != 0) {",
"logout(\"unsupported block map offset 0x%x B\\n\", header.offset_bmap);",
"VAR_4 = -ENOTSUP;",
"goto fail;",
"} else if (header.offset_data % SECTOR_SIZE != 0) {",
"logout(\"unsupported data offset 0x%x B\\n\", header.offset_data);",
"VAR_4 = -ENOTSUP;",
"goto fail;",
"} else if (header.sector_size != SECTOR_SIZE) {",
"logout(\"unsupported sector size %u B\\n\", header.sector_size);",
"VAR_4 = -ENOTSUP;",
"goto fail;",
"} else if (header.block_size != 1 * MiB) {",
"logout(\"unsupported block size %u B\\n\", header.block_size);",
"VAR_4 = -ENOTSUP;",
"goto fail;",
"} else if (header.disk_size >",
"(uint64_t)header.blocks_in_image * header.block_size) {",
"logout(\"unsupported disk size %\" PRIu64 \" B\\n\", header.disk_size);",
"VAR_4 = -ENOTSUP;",
"goto fail;",
"} else if (!uuid_is_null(header.uuid_link)) {",
"logout(\"link uuid != 0, unsupported\\n\");",
"VAR_4 = -ENOTSUP;",
"goto fail;",
"} else if (!uuid_is_null(header.uuid_parent)) {",
"logout(\"parent uuid != 0, unsupported\\n\");",
"VAR_4 = -ENOTSUP;",
"goto fail;",
"}",
"VAR_0->total_sectors = header.disk_size / SECTOR_SIZE;",
"s->block_size = header.block_size;",
"s->block_sectors = header.block_size / SECTOR_SIZE;",
"s->bmap_sector = header.offset_bmap / SECTOR_SIZE;",
"s->header = header;",
"bmap_size = header.blocks_in_image * sizeof(uint32_t);",
"bmap_size = (bmap_size + SECTOR_SIZE - 1) / SECTOR_SIZE;",
"s->bmap = g_malloc(bmap_size * SECTOR_SIZE);",
"VAR_4 = bdrv_read(VAR_0->file, s->bmap_sector, (uint8_t *)s->bmap, bmap_size);",
"if (VAR_4 < 0) {",
"goto fail_free_bmap;",
"}",
"error_set(&s->migration_blocker,\nQERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED,\n\"vdi\", VAR_0->device_name, \"live migration\");",
"migrate_add_blocker(s->migration_blocker);",
"return 0;",
"fail_free_bmap:\ng_free(s->bmap);",
"fail:\nreturn VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33,
35
],
[
37,
41
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
175,
177,
179
],
[
181
],
[
185
],
[
189,
191
],
[
195,
197
],
[
199
]
] |
27,057 | ThreadPool *aio_get_thread_pool(AioContext *ctx)
{
if (!ctx->thread_pool) {
ctx->thread_pool = thread_pool_new(ctx);
}
return ctx->thread_pool;
}
| false | qemu | c2b38b277a7882a592f4f2ec955084b2b756daaa | ThreadPool *aio_get_thread_pool(AioContext *ctx)
{
if (!ctx->thread_pool) {
ctx->thread_pool = thread_pool_new(ctx);
}
return ctx->thread_pool;
}
| {
"code": [],
"line_no": []
} | ThreadPool *FUNC_0(AioContext *ctx)
{
if (!ctx->thread_pool) {
ctx->thread_pool = thread_pool_new(ctx);
}
return ctx->thread_pool;
}
| [
"ThreadPool *FUNC_0(AioContext *ctx)\n{",
"if (!ctx->thread_pool) {",
"ctx->thread_pool = thread_pool_new(ctx);",
"}",
"return ctx->thread_pool;",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
27,059 | static void string_serialize(void *native_in, void **datap,
VisitorFunc visit, Error **errp)
{
StringSerializeData *d = g_malloc0(sizeof(*d));
d->sov = string_output_visitor_new(false);
visit(string_output_get_visitor(d->sov), &native_in, errp);
*datap = d;
}
| false | qemu | 3b098d56979d2f7fd707c5be85555d114353a28d | static void string_serialize(void *native_in, void **datap,
VisitorFunc visit, Error **errp)
{
StringSerializeData *d = g_malloc0(sizeof(*d));
d->sov = string_output_visitor_new(false);
visit(string_output_get_visitor(d->sov), &native_in, errp);
*datap = d;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, void **VAR_1,
VisitorFunc VAR_2, Error **VAR_3)
{
StringSerializeData *d = g_malloc0(sizeof(*d));
d->sov = string_output_visitor_new(false);
VAR_2(string_output_get_visitor(d->sov), &VAR_0, VAR_3);
*VAR_1 = d;
}
| [
"static void FUNC_0(void *VAR_0, void **VAR_1,\nVisitorFunc VAR_2, Error **VAR_3)\n{",
"StringSerializeData *d = g_malloc0(sizeof(*d));",
"d->sov = string_output_visitor_new(false);",
"VAR_2(string_output_get_visitor(d->sov), &VAR_0, VAR_3);",
"*VAR_1 = d;",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
27,061 | void cpu_x86_update_cr3(CPUX86State *env)
{
if (env->cr[0] & CR0_PG_MASK) {
#if defined(DEBUG_MMU)
printf("CR3 update: CR3=%08x\n", env->cr[3]);
#endif
tlb_flush(env);
}
}
| false | qemu | 1ac157da77c863b62b1d2f467626a440d57cf17d | void cpu_x86_update_cr3(CPUX86State *env)
{
if (env->cr[0] & CR0_PG_MASK) {
#if defined(DEBUG_MMU)
printf("CR3 update: CR3=%08x\n", env->cr[3]);
#endif
tlb_flush(env);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(CPUX86State *VAR_0)
{
if (VAR_0->cr[0] & CR0_PG_MASK) {
#if defined(DEBUG_MMU)
printf("CR3 update: CR3=%08x\n", VAR_0->cr[3]);
#endif
tlb_flush(VAR_0);
}
}
| [
"void FUNC_0(CPUX86State *VAR_0)\n{",
"if (VAR_0->cr[0] & CR0_PG_MASK) {",
"#if defined(DEBUG_MMU)\nprintf(\"CR3 update: CR3=%08x\\n\", VAR_0->cr[3]);",
"#endif\ntlb_flush(VAR_0);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11,
13
],
[
15
],
[
17
]
] |
27,062 | static inline void apply_8x8(MpegEncContext *s,
uint8_t *dest_y,
uint8_t *dest_cb,
uint8_t *dest_cr,
int dir,
uint8_t **ref_picture,
qpel_mc_func (*qpix_op)[16],
op_pixels_func (*pix_op)[4])
{
int dxy, mx, my, src_x, src_y;
int i;
int mb_x = s->mb_x;
int mb_y = s->mb_y;
uint8_t *ptr, *dest;
mx = 0;
my = 0;
if (s->quarter_sample) {
for (i = 0; i < 4; i++) {
int motion_x = s->mv[dir][i][0];
int motion_y = s->mv[dir][i][1];
dxy = ((motion_y & 3) << 2) | (motion_x & 3);
src_x = mb_x * 16 + (motion_x >> 2) + (i & 1) * 8;
src_y = mb_y * 16 + (motion_y >> 2) + (i >> 1) * 8;
/* WARNING: do no forget half pels */
src_x = av_clip(src_x, -16, s->width);
if (src_x == s->width)
dxy &= ~3;
src_y = av_clip(src_y, -16, s->height);
if (src_y == s->height)
dxy &= ~12;
ptr = ref_picture[0] + (src_y * s->linesize) + (src_x);
if ((unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x & 3) - 8, 0) ||
(unsigned)src_y > FFMAX(s->v_edge_pos - (motion_y & 3) - 8, 0)) {
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr,
s->linesize, s->linesize,
9, 9,
src_x, src_y,
s->h_edge_pos,
s->v_edge_pos);
ptr = s->edge_emu_buffer;
}
dest = dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize;
qpix_op[1][dxy](dest, ptr, s->linesize);
mx += s->mv[dir][i][0] / 2;
my += s->mv[dir][i][1] / 2;
}
} else {
for (i = 0; i < 4; i++) {
hpel_motion(s,
dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize,
ref_picture[0],
mb_x * 16 + (i & 1) * 8,
mb_y * 16 + (i >> 1) * 8,
pix_op[1],
s->mv[dir][i][0],
s->mv[dir][i][1]);
mx += s->mv[dir][i][0];
my += s->mv[dir][i][1];
}
}
if (!CONFIG_GRAY || !(s->flags & CODEC_FLAG_GRAY))
chroma_4mv_motion(s, dest_cb, dest_cr,
ref_picture, pix_op[1], mx, my);
}
| false | FFmpeg | 8849c4ceac0f35e88b2dc406bf5ffc4173a38ffe | static inline void apply_8x8(MpegEncContext *s,
uint8_t *dest_y,
uint8_t *dest_cb,
uint8_t *dest_cr,
int dir,
uint8_t **ref_picture,
qpel_mc_func (*qpix_op)[16],
op_pixels_func (*pix_op)[4])
{
int dxy, mx, my, src_x, src_y;
int i;
int mb_x = s->mb_x;
int mb_y = s->mb_y;
uint8_t *ptr, *dest;
mx = 0;
my = 0;
if (s->quarter_sample) {
for (i = 0; i < 4; i++) {
int motion_x = s->mv[dir][i][0];
int motion_y = s->mv[dir][i][1];
dxy = ((motion_y & 3) << 2) | (motion_x & 3);
src_x = mb_x * 16 + (motion_x >> 2) + (i & 1) * 8;
src_y = mb_y * 16 + (motion_y >> 2) + (i >> 1) * 8;
src_x = av_clip(src_x, -16, s->width);
if (src_x == s->width)
dxy &= ~3;
src_y = av_clip(src_y, -16, s->height);
if (src_y == s->height)
dxy &= ~12;
ptr = ref_picture[0] + (src_y * s->linesize) + (src_x);
if ((unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x & 3) - 8, 0) ||
(unsigned)src_y > FFMAX(s->v_edge_pos - (motion_y & 3) - 8, 0)) {
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr,
s->linesize, s->linesize,
9, 9,
src_x, src_y,
s->h_edge_pos,
s->v_edge_pos);
ptr = s->edge_emu_buffer;
}
dest = dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize;
qpix_op[1][dxy](dest, ptr, s->linesize);
mx += s->mv[dir][i][0] / 2;
my += s->mv[dir][i][1] / 2;
}
} else {
for (i = 0; i < 4; i++) {
hpel_motion(s,
dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize,
ref_picture[0],
mb_x * 16 + (i & 1) * 8,
mb_y * 16 + (i >> 1) * 8,
pix_op[1],
s->mv[dir][i][0],
s->mv[dir][i][1]);
mx += s->mv[dir][i][0];
my += s->mv[dir][i][1];
}
}
if (!CONFIG_GRAY || !(s->flags & CODEC_FLAG_GRAY))
chroma_4mv_motion(s, dest_cb, dest_cr,
ref_picture, pix_op[1], mx, my);
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(MpegEncContext *VAR_0,
uint8_t *VAR_1,
uint8_t *VAR_2,
uint8_t *VAR_3,
int VAR_4,
uint8_t **VAR_5,
VAR_6 (*qpix_op)[16],
VAR_7 (*pix_op)[4])
{
int VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;
int VAR_13;
int VAR_14 = VAR_0->VAR_14;
int VAR_15 = VAR_0->VAR_15;
uint8_t *ptr, *dest;
VAR_9 = 0;
VAR_10 = 0;
if (VAR_0->quarter_sample) {
for (VAR_13 = 0; VAR_13 < 4; VAR_13++) {
int VAR_16 = VAR_0->mv[VAR_4][VAR_13][0];
int VAR_17 = VAR_0->mv[VAR_4][VAR_13][1];
VAR_8 = ((VAR_17 & 3) << 2) | (VAR_16 & 3);
VAR_11 = VAR_14 * 16 + (VAR_16 >> 2) + (VAR_13 & 1) * 8;
VAR_12 = VAR_15 * 16 + (VAR_17 >> 2) + (VAR_13 >> 1) * 8;
VAR_11 = av_clip(VAR_11, -16, VAR_0->width);
if (VAR_11 == VAR_0->width)
VAR_8 &= ~3;
VAR_12 = av_clip(VAR_12, -16, VAR_0->height);
if (VAR_12 == VAR_0->height)
VAR_8 &= ~12;
ptr = VAR_5[0] + (VAR_12 * VAR_0->linesize) + (VAR_11);
if ((unsigned)VAR_11 > FFMAX(VAR_0->h_edge_pos - (VAR_16 & 3) - 8, 0) ||
(unsigned)VAR_12 > FFMAX(VAR_0->v_edge_pos - (VAR_17 & 3) - 8, 0)) {
VAR_0->vdsp.emulated_edge_mc(VAR_0->edge_emu_buffer, ptr,
VAR_0->linesize, VAR_0->linesize,
9, 9,
VAR_11, VAR_12,
VAR_0->h_edge_pos,
VAR_0->v_edge_pos);
ptr = VAR_0->edge_emu_buffer;
}
dest = VAR_1 + ((VAR_13 & 1) * 8) + (VAR_13 >> 1) * 8 * VAR_0->linesize;
qpix_op[1][VAR_8](dest, ptr, VAR_0->linesize);
VAR_9 += VAR_0->mv[VAR_4][VAR_13][0] / 2;
VAR_10 += VAR_0->mv[VAR_4][VAR_13][1] / 2;
}
} else {
for (VAR_13 = 0; VAR_13 < 4; VAR_13++) {
hpel_motion(VAR_0,
VAR_1 + ((VAR_13 & 1) * 8) + (VAR_13 >> 1) * 8 * VAR_0->linesize,
VAR_5[0],
VAR_14 * 16 + (VAR_13 & 1) * 8,
VAR_15 * 16 + (VAR_13 >> 1) * 8,
pix_op[1],
VAR_0->mv[VAR_4][VAR_13][0],
VAR_0->mv[VAR_4][VAR_13][1]);
VAR_9 += VAR_0->mv[VAR_4][VAR_13][0];
VAR_10 += VAR_0->mv[VAR_4][VAR_13][1];
}
}
if (!CONFIG_GRAY || !(VAR_0->flags & CODEC_FLAG_GRAY))
chroma_4mv_motion(VAR_0, VAR_2, VAR_3,
VAR_5, pix_op[1], VAR_9, VAR_10);
}
| [
"static inline void FUNC_0(MpegEncContext *VAR_0,\nuint8_t *VAR_1,\nuint8_t *VAR_2,\nuint8_t *VAR_3,\nint VAR_4,\nuint8_t **VAR_5,\nVAR_6 (*qpix_op)[16],\nVAR_7 (*pix_op)[4])\n{",
"int VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;",
"int VAR_13;",
"int VAR_14 = VAR_0->VAR_14;",
"int VAR_15 = VAR_0->VAR_15;",
"uint8_t *ptr, *dest;",
"VAR_9 = 0;",
"VAR_10 = 0;",
"if (VAR_0->quarter_sample) {",
"for (VAR_13 = 0; VAR_13 < 4; VAR_13++) {",
"int VAR_16 = VAR_0->mv[VAR_4][VAR_13][0];",
"int VAR_17 = VAR_0->mv[VAR_4][VAR_13][1];",
"VAR_8 = ((VAR_17 & 3) << 2) | (VAR_16 & 3);",
"VAR_11 = VAR_14 * 16 + (VAR_16 >> 2) + (VAR_13 & 1) * 8;",
"VAR_12 = VAR_15 * 16 + (VAR_17 >> 2) + (VAR_13 >> 1) * 8;",
"VAR_11 = av_clip(VAR_11, -16, VAR_0->width);",
"if (VAR_11 == VAR_0->width)\nVAR_8 &= ~3;",
"VAR_12 = av_clip(VAR_12, -16, VAR_0->height);",
"if (VAR_12 == VAR_0->height)\nVAR_8 &= ~12;",
"ptr = VAR_5[0] + (VAR_12 * VAR_0->linesize) + (VAR_11);",
"if ((unsigned)VAR_11 > FFMAX(VAR_0->h_edge_pos - (VAR_16 & 3) - 8, 0) ||\n(unsigned)VAR_12 > FFMAX(VAR_0->v_edge_pos - (VAR_17 & 3) - 8, 0)) {",
"VAR_0->vdsp.emulated_edge_mc(VAR_0->edge_emu_buffer, ptr,\nVAR_0->linesize, VAR_0->linesize,\n9, 9,\nVAR_11, VAR_12,\nVAR_0->h_edge_pos,\nVAR_0->v_edge_pos);",
"ptr = VAR_0->edge_emu_buffer;",
"}",
"dest = VAR_1 + ((VAR_13 & 1) * 8) + (VAR_13 >> 1) * 8 * VAR_0->linesize;",
"qpix_op[1][VAR_8](dest, ptr, VAR_0->linesize);",
"VAR_9 += VAR_0->mv[VAR_4][VAR_13][0] / 2;",
"VAR_10 += VAR_0->mv[VAR_4][VAR_13][1] / 2;",
"}",
"} else {",
"for (VAR_13 = 0; VAR_13 < 4; VAR_13++) {",
"hpel_motion(VAR_0,\nVAR_1 + ((VAR_13 & 1) * 8) + (VAR_13 >> 1) * 8 * VAR_0->linesize,\nVAR_5[0],\nVAR_14 * 16 + (VAR_13 & 1) * 8,\nVAR_15 * 16 + (VAR_13 >> 1) * 8,\npix_op[1],\nVAR_0->mv[VAR_4][VAR_13][0],\nVAR_0->mv[VAR_4][VAR_13][1]);",
"VAR_9 += VAR_0->mv[VAR_4][VAR_13][0];",
"VAR_10 += VAR_0->mv[VAR_4][VAR_13][1];",
"}",
"}",
"if (!CONFIG_GRAY || !(VAR_0->flags & CODEC_FLAG_GRAY))\nchroma_4mv_motion(VAR_0, VAR_2, VAR_3,\nVAR_5, pix_op[1], VAR_9, VAR_10);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
55
],
[
57,
59
],
[
61
],
[
63,
65
],
[
69
],
[
71,
73
],
[
75,
77,
79,
81,
83,
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107,
109,
111,
113,
115,
117,
119,
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135,
137,
139
],
[
141
]
] |
27,063 | void mpeg_motion_internal(MpegEncContext *s,
uint8_t *dest_y,
uint8_t *dest_cb,
uint8_t *dest_cr,
int field_based,
int bottom_field,
int field_select,
uint8_t **ref_picture,
op_pixels_func (*pix_op)[4],
int motion_x,
int motion_y,
int h,
int is_mpeg12,
int mb_y)
{
uint8_t *ptr_y, *ptr_cb, *ptr_cr;
int dxy, uvdxy, mx, my, src_x, src_y,
uvsrc_x, uvsrc_y, v_edge_pos;
ptrdiff_t uvlinesize, linesize;
#if 0
if (s->quarter_sample) {
motion_x >>= 1;
motion_y >>= 1;
}
#endif
v_edge_pos = s->v_edge_pos >> field_based;
linesize = s->current_picture.f->linesize[0] << field_based;
uvlinesize = s->current_picture.f->linesize[1] << field_based;
dxy = ((motion_y & 1) << 1) | (motion_x & 1);
src_x = s->mb_x * 16 + (motion_x >> 1);
src_y = (mb_y << (4 - field_based)) + (motion_y >> 1);
if (!is_mpeg12 && s->out_format == FMT_H263) {
if ((s->workaround_bugs & FF_BUG_HPEL_CHROMA) && field_based) {
mx = (motion_x >> 1) | (motion_x & 1);
my = motion_y >> 1;
uvdxy = ((my & 1) << 1) | (mx & 1);
uvsrc_x = s->mb_x * 8 + (mx >> 1);
uvsrc_y = (mb_y << (3 - field_based)) + (my >> 1);
} else {
uvdxy = dxy | (motion_y & 2) | ((motion_x & 2) >> 1);
uvsrc_x = src_x >> 1;
uvsrc_y = src_y >> 1;
}
// Even chroma mv's are full pel in H261
} else if (!is_mpeg12 && s->out_format == FMT_H261) {
mx = motion_x / 4;
my = motion_y / 4;
uvdxy = 0;
uvsrc_x = s->mb_x * 8 + mx;
uvsrc_y = mb_y * 8 + my;
} else {
if (s->chroma_y_shift) {
mx = motion_x / 2;
my = motion_y / 2;
uvdxy = ((my & 1) << 1) | (mx & 1);
uvsrc_x = s->mb_x * 8 + (mx >> 1);
uvsrc_y = (mb_y << (3 - field_based)) + (my >> 1);
} else {
if (s->chroma_x_shift) {
// Chroma422
mx = motion_x / 2;
uvdxy = ((motion_y & 1) << 1) | (mx & 1);
uvsrc_x = s->mb_x * 8 + (mx >> 1);
uvsrc_y = src_y;
} else {
// Chroma444
uvdxy = dxy;
uvsrc_x = src_x;
uvsrc_y = src_y;
}
}
}
ptr_y = ref_picture[0] + src_y * linesize + src_x;
ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
if ((unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x & 1) - 16, 0) ||
(unsigned)src_y > FFMAX(v_edge_pos - (motion_y & 1) - h, 0)) {
if (is_mpeg12 ||
s->codec_id == AV_CODEC_ID_MPEG2VIDEO ||
s->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
av_log(s->avctx, AV_LOG_DEBUG,
"MPEG motion vector out of boundary (%d %d)\n", src_x,
src_y);
return;
}
s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr_y,
s->linesize, s->linesize,
17, 17 + field_based,
src_x, src_y << field_based,
s->h_edge_pos, s->v_edge_pos);
ptr_y = s->sc.edge_emu_buffer;
if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
uint8_t *uvbuf = s->sc.edge_emu_buffer + 18 * s->linesize;
s->vdsp.emulated_edge_mc(uvbuf, ptr_cb,
s->uvlinesize, s->uvlinesize,
9, 9 + field_based,
uvsrc_x, uvsrc_y << field_based,
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
s->vdsp.emulated_edge_mc(uvbuf + 16, ptr_cr,
s->uvlinesize, s->uvlinesize,
9, 9 + field_based,
uvsrc_x, uvsrc_y << field_based,
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
ptr_cb = uvbuf;
ptr_cr = uvbuf + 16;
}
}
/* FIXME use this for field pix too instead of the obnoxious hack which
* changes picture.data */
if (bottom_field) {
dest_y += s->linesize;
dest_cb += s->uvlinesize;
dest_cr += s->uvlinesize;
}
if (field_select) {
ptr_y += s->linesize;
ptr_cb += s->uvlinesize;
ptr_cr += s->uvlinesize;
}
pix_op[0][dxy](dest_y, ptr_y, linesize, h);
if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
pix_op[s->chroma_x_shift][uvdxy]
(dest_cb, ptr_cb, uvlinesize, h >> s->chroma_y_shift);
pix_op[s->chroma_x_shift][uvdxy]
(dest_cr, ptr_cr, uvlinesize, h >> s->chroma_y_shift);
}
if (!is_mpeg12 && (CONFIG_H261_ENCODER || CONFIG_H261_DECODER) &&
s->out_format == FMT_H261) {
ff_h261_loop_filter(s);
}
}
| false | FFmpeg | 0242351390643d176b10600c2eb854414f9559e6 | void mpeg_motion_internal(MpegEncContext *s,
uint8_t *dest_y,
uint8_t *dest_cb,
uint8_t *dest_cr,
int field_based,
int bottom_field,
int field_select,
uint8_t **ref_picture,
op_pixels_func (*pix_op)[4],
int motion_x,
int motion_y,
int h,
int is_mpeg12,
int mb_y)
{
uint8_t *ptr_y, *ptr_cb, *ptr_cr;
int dxy, uvdxy, mx, my, src_x, src_y,
uvsrc_x, uvsrc_y, v_edge_pos;
ptrdiff_t uvlinesize, linesize;
#if 0
if (s->quarter_sample) {
motion_x >>= 1;
motion_y >>= 1;
}
#endif
v_edge_pos = s->v_edge_pos >> field_based;
linesize = s->current_picture.f->linesize[0] << field_based;
uvlinesize = s->current_picture.f->linesize[1] << field_based;
dxy = ((motion_y & 1) << 1) | (motion_x & 1);
src_x = s->mb_x * 16 + (motion_x >> 1);
src_y = (mb_y << (4 - field_based)) + (motion_y >> 1);
if (!is_mpeg12 && s->out_format == FMT_H263) {
if ((s->workaround_bugs & FF_BUG_HPEL_CHROMA) && field_based) {
mx = (motion_x >> 1) | (motion_x & 1);
my = motion_y >> 1;
uvdxy = ((my & 1) << 1) | (mx & 1);
uvsrc_x = s->mb_x * 8 + (mx >> 1);
uvsrc_y = (mb_y << (3 - field_based)) + (my >> 1);
} else {
uvdxy = dxy | (motion_y & 2) | ((motion_x & 2) >> 1);
uvsrc_x = src_x >> 1;
uvsrc_y = src_y >> 1;
}
} else if (!is_mpeg12 && s->out_format == FMT_H261) {
mx = motion_x / 4;
my = motion_y / 4;
uvdxy = 0;
uvsrc_x = s->mb_x * 8 + mx;
uvsrc_y = mb_y * 8 + my;
} else {
if (s->chroma_y_shift) {
mx = motion_x / 2;
my = motion_y / 2;
uvdxy = ((my & 1) << 1) | (mx & 1);
uvsrc_x = s->mb_x * 8 + (mx >> 1);
uvsrc_y = (mb_y << (3 - field_based)) + (my >> 1);
} else {
if (s->chroma_x_shift) {
mx = motion_x / 2;
uvdxy = ((motion_y & 1) << 1) | (mx & 1);
uvsrc_x = s->mb_x * 8 + (mx >> 1);
uvsrc_y = src_y;
} else {
uvdxy = dxy;
uvsrc_x = src_x;
uvsrc_y = src_y;
}
}
}
ptr_y = ref_picture[0] + src_y * linesize + src_x;
ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
if ((unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x & 1) - 16, 0) ||
(unsigned)src_y > FFMAX(v_edge_pos - (motion_y & 1) - h, 0)) {
if (is_mpeg12 ||
s->codec_id == AV_CODEC_ID_MPEG2VIDEO ||
s->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
av_log(s->avctx, AV_LOG_DEBUG,
"MPEG motion vector out of boundary (%d %d)\n", src_x,
src_y);
return;
}
s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr_y,
s->linesize, s->linesize,
17, 17 + field_based,
src_x, src_y << field_based,
s->h_edge_pos, s->v_edge_pos);
ptr_y = s->sc.edge_emu_buffer;
if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
uint8_t *uvbuf = s->sc.edge_emu_buffer + 18 * s->linesize;
s->vdsp.emulated_edge_mc(uvbuf, ptr_cb,
s->uvlinesize, s->uvlinesize,
9, 9 + field_based,
uvsrc_x, uvsrc_y << field_based,
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
s->vdsp.emulated_edge_mc(uvbuf + 16, ptr_cr,
s->uvlinesize, s->uvlinesize,
9, 9 + field_based,
uvsrc_x, uvsrc_y << field_based,
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
ptr_cb = uvbuf;
ptr_cr = uvbuf + 16;
}
}
if (bottom_field) {
dest_y += s->linesize;
dest_cb += s->uvlinesize;
dest_cr += s->uvlinesize;
}
if (field_select) {
ptr_y += s->linesize;
ptr_cb += s->uvlinesize;
ptr_cr += s->uvlinesize;
}
pix_op[0][dxy](dest_y, ptr_y, linesize, h);
if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
pix_op[s->chroma_x_shift][uvdxy]
(dest_cb, ptr_cb, uvlinesize, h >> s->chroma_y_shift);
pix_op[s->chroma_x_shift][uvdxy]
(dest_cr, ptr_cr, uvlinesize, h >> s->chroma_y_shift);
}
if (!is_mpeg12 && (CONFIG_H261_ENCODER || CONFIG_H261_DECODER) &&
s->out_format == FMT_H261) {
ff_h261_loop_filter(s);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(MpegEncContext *VAR_0,
uint8_t *VAR_1,
uint8_t *VAR_2,
uint8_t *VAR_3,
int VAR_4,
int VAR_5,
int VAR_6,
uint8_t **VAR_7,
VAR_8 (*pix_op)[4],
int VAR_9,
int VAR_10,
int VAR_11,
int VAR_12,
int VAR_13)
{
uint8_t *ptr_y, *ptr_cb, *ptr_cr;
int VAR_14, VAR_15, VAR_16, VAR_17, VAR_18, VAR_19,
VAR_20, VAR_21, VAR_22;
ptrdiff_t uvlinesize, linesize;
#if 0
if (VAR_0->quarter_sample) {
VAR_9 >>= 1;
VAR_10 >>= 1;
}
#endif
VAR_22 = VAR_0->VAR_22 >> VAR_4;
linesize = VAR_0->current_picture.f->linesize[0] << VAR_4;
uvlinesize = VAR_0->current_picture.f->linesize[1] << VAR_4;
VAR_14 = ((VAR_10 & 1) << 1) | (VAR_9 & 1);
VAR_18 = VAR_0->mb_x * 16 + (VAR_9 >> 1);
VAR_19 = (VAR_13 << (4 - VAR_4)) + (VAR_10 >> 1);
if (!VAR_12 && VAR_0->out_format == FMT_H263) {
if ((VAR_0->workaround_bugs & FF_BUG_HPEL_CHROMA) && VAR_4) {
VAR_16 = (VAR_9 >> 1) | (VAR_9 & 1);
VAR_17 = VAR_10 >> 1;
VAR_15 = ((VAR_17 & 1) << 1) | (VAR_16 & 1);
VAR_20 = VAR_0->mb_x * 8 + (VAR_16 >> 1);
VAR_21 = (VAR_13 << (3 - VAR_4)) + (VAR_17 >> 1);
} else {
VAR_15 = VAR_14 | (VAR_10 & 2) | ((VAR_9 & 2) >> 1);
VAR_20 = VAR_18 >> 1;
VAR_21 = VAR_19 >> 1;
}
} else if (!VAR_12 && VAR_0->out_format == FMT_H261) {
VAR_16 = VAR_9 / 4;
VAR_17 = VAR_10 / 4;
VAR_15 = 0;
VAR_20 = VAR_0->mb_x * 8 + VAR_16;
VAR_21 = VAR_13 * 8 + VAR_17;
} else {
if (VAR_0->chroma_y_shift) {
VAR_16 = VAR_9 / 2;
VAR_17 = VAR_10 / 2;
VAR_15 = ((VAR_17 & 1) << 1) | (VAR_16 & 1);
VAR_20 = VAR_0->mb_x * 8 + (VAR_16 >> 1);
VAR_21 = (VAR_13 << (3 - VAR_4)) + (VAR_17 >> 1);
} else {
if (VAR_0->chroma_x_shift) {
VAR_16 = VAR_9 / 2;
VAR_15 = ((VAR_10 & 1) << 1) | (VAR_16 & 1);
VAR_20 = VAR_0->mb_x * 8 + (VAR_16 >> 1);
VAR_21 = VAR_19;
} else {
VAR_15 = VAR_14;
VAR_20 = VAR_18;
VAR_21 = VAR_19;
}
}
}
ptr_y = VAR_7[0] + VAR_19 * linesize + VAR_18;
ptr_cb = VAR_7[1] + VAR_21 * uvlinesize + VAR_20;
ptr_cr = VAR_7[2] + VAR_21 * uvlinesize + VAR_20;
if ((unsigned)VAR_18 > FFMAX(VAR_0->h_edge_pos - (VAR_9 & 1) - 16, 0) ||
(unsigned)VAR_19 > FFMAX(VAR_22 - (VAR_10 & 1) - VAR_11, 0)) {
if (VAR_12 ||
VAR_0->codec_id == AV_CODEC_ID_MPEG2VIDEO ||
VAR_0->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
av_log(VAR_0->avctx, AV_LOG_DEBUG,
"MPEG motion vector out of boundary (%d %d)\n", VAR_18,
VAR_19);
return;
}
VAR_0->vdsp.emulated_edge_mc(VAR_0->sc.edge_emu_buffer, ptr_y,
VAR_0->linesize, VAR_0->linesize,
17, 17 + VAR_4,
VAR_18, VAR_19 << VAR_4,
VAR_0->h_edge_pos, VAR_0->VAR_22);
ptr_y = VAR_0->sc.edge_emu_buffer;
if (!CONFIG_GRAY || !(VAR_0->avctx->flags & AV_CODEC_FLAG_GRAY)) {
uint8_t *uvbuf = VAR_0->sc.edge_emu_buffer + 18 * VAR_0->linesize;
VAR_0->vdsp.emulated_edge_mc(uvbuf, ptr_cb,
VAR_0->uvlinesize, VAR_0->uvlinesize,
9, 9 + VAR_4,
VAR_20, VAR_21 << VAR_4,
VAR_0->h_edge_pos >> 1, VAR_0->VAR_22 >> 1);
VAR_0->vdsp.emulated_edge_mc(uvbuf + 16, ptr_cr,
VAR_0->uvlinesize, VAR_0->uvlinesize,
9, 9 + VAR_4,
VAR_20, VAR_21 << VAR_4,
VAR_0->h_edge_pos >> 1, VAR_0->VAR_22 >> 1);
ptr_cb = uvbuf;
ptr_cr = uvbuf + 16;
}
}
if (VAR_5) {
VAR_1 += VAR_0->linesize;
VAR_2 += VAR_0->uvlinesize;
VAR_3 += VAR_0->uvlinesize;
}
if (VAR_6) {
ptr_y += VAR_0->linesize;
ptr_cb += VAR_0->uvlinesize;
ptr_cr += VAR_0->uvlinesize;
}
pix_op[0][VAR_14](VAR_1, ptr_y, linesize, VAR_11);
if (!CONFIG_GRAY || !(VAR_0->avctx->flags & AV_CODEC_FLAG_GRAY)) {
pix_op[VAR_0->chroma_x_shift][VAR_15]
(VAR_2, ptr_cb, uvlinesize, VAR_11 >> VAR_0->chroma_y_shift);
pix_op[VAR_0->chroma_x_shift][VAR_15]
(VAR_3, ptr_cr, uvlinesize, VAR_11 >> VAR_0->chroma_y_shift);
}
if (!VAR_12 && (CONFIG_H261_ENCODER || CONFIG_H261_DECODER) &&
VAR_0->out_format == FMT_H261) {
ff_h261_loop_filter(VAR_0);
}
}
| [
"void FUNC_0(MpegEncContext *VAR_0,\nuint8_t *VAR_1,\nuint8_t *VAR_2,\nuint8_t *VAR_3,\nint VAR_4,\nint VAR_5,\nint VAR_6,\nuint8_t **VAR_7,\nVAR_8 (*pix_op)[4],\nint VAR_9,\nint VAR_10,\nint VAR_11,\nint VAR_12,\nint VAR_13)\n{",
"uint8_t *ptr_y, *ptr_cb, *ptr_cr;",
"int VAR_14, VAR_15, VAR_16, VAR_17, VAR_18, VAR_19,\nVAR_20, VAR_21, VAR_22;",
"ptrdiff_t uvlinesize, linesize;",
"#if 0\nif (VAR_0->quarter_sample) {",
"VAR_9 >>= 1;",
"VAR_10 >>= 1;",
"}",
"#endif\nVAR_22 = VAR_0->VAR_22 >> VAR_4;",
"linesize = VAR_0->current_picture.f->linesize[0] << VAR_4;",
"uvlinesize = VAR_0->current_picture.f->linesize[1] << VAR_4;",
"VAR_14 = ((VAR_10 & 1) << 1) | (VAR_9 & 1);",
"VAR_18 = VAR_0->mb_x * 16 + (VAR_9 >> 1);",
"VAR_19 = (VAR_13 << (4 - VAR_4)) + (VAR_10 >> 1);",
"if (!VAR_12 && VAR_0->out_format == FMT_H263) {",
"if ((VAR_0->workaround_bugs & FF_BUG_HPEL_CHROMA) && VAR_4) {",
"VAR_16 = (VAR_9 >> 1) | (VAR_9 & 1);",
"VAR_17 = VAR_10 >> 1;",
"VAR_15 = ((VAR_17 & 1) << 1) | (VAR_16 & 1);",
"VAR_20 = VAR_0->mb_x * 8 + (VAR_16 >> 1);",
"VAR_21 = (VAR_13 << (3 - VAR_4)) + (VAR_17 >> 1);",
"} else {",
"VAR_15 = VAR_14 | (VAR_10 & 2) | ((VAR_9 & 2) >> 1);",
"VAR_20 = VAR_18 >> 1;",
"VAR_21 = VAR_19 >> 1;",
"}",
"} else if (!VAR_12 && VAR_0->out_format == FMT_H261) {",
"VAR_16 = VAR_9 / 4;",
"VAR_17 = VAR_10 / 4;",
"VAR_15 = 0;",
"VAR_20 = VAR_0->mb_x * 8 + VAR_16;",
"VAR_21 = VAR_13 * 8 + VAR_17;",
"} else {",
"if (VAR_0->chroma_y_shift) {",
"VAR_16 = VAR_9 / 2;",
"VAR_17 = VAR_10 / 2;",
"VAR_15 = ((VAR_17 & 1) << 1) | (VAR_16 & 1);",
"VAR_20 = VAR_0->mb_x * 8 + (VAR_16 >> 1);",
"VAR_21 = (VAR_13 << (3 - VAR_4)) + (VAR_17 >> 1);",
"} else {",
"if (VAR_0->chroma_x_shift) {",
"VAR_16 = VAR_9 / 2;",
"VAR_15 = ((VAR_10 & 1) << 1) | (VAR_16 & 1);",
"VAR_20 = VAR_0->mb_x * 8 + (VAR_16 >> 1);",
"VAR_21 = VAR_19;",
"} else {",
"VAR_15 = VAR_14;",
"VAR_20 = VAR_18;",
"VAR_21 = VAR_19;",
"}",
"}",
"}",
"ptr_y = VAR_7[0] + VAR_19 * linesize + VAR_18;",
"ptr_cb = VAR_7[1] + VAR_21 * uvlinesize + VAR_20;",
"ptr_cr = VAR_7[2] + VAR_21 * uvlinesize + VAR_20;",
"if ((unsigned)VAR_18 > FFMAX(VAR_0->h_edge_pos - (VAR_9 & 1) - 16, 0) ||\n(unsigned)VAR_19 > FFMAX(VAR_22 - (VAR_10 & 1) - VAR_11, 0)) {",
"if (VAR_12 ||\nVAR_0->codec_id == AV_CODEC_ID_MPEG2VIDEO ||\nVAR_0->codec_id == AV_CODEC_ID_MPEG1VIDEO) {",
"av_log(VAR_0->avctx, AV_LOG_DEBUG,\n\"MPEG motion vector out of boundary (%d %d)\\n\", VAR_18,\nVAR_19);",
"return;",
"}",
"VAR_0->vdsp.emulated_edge_mc(VAR_0->sc.edge_emu_buffer, ptr_y,\nVAR_0->linesize, VAR_0->linesize,\n17, 17 + VAR_4,\nVAR_18, VAR_19 << VAR_4,\nVAR_0->h_edge_pos, VAR_0->VAR_22);",
"ptr_y = VAR_0->sc.edge_emu_buffer;",
"if (!CONFIG_GRAY || !(VAR_0->avctx->flags & AV_CODEC_FLAG_GRAY)) {",
"uint8_t *uvbuf = VAR_0->sc.edge_emu_buffer + 18 * VAR_0->linesize;",
"VAR_0->vdsp.emulated_edge_mc(uvbuf, ptr_cb,\nVAR_0->uvlinesize, VAR_0->uvlinesize,\n9, 9 + VAR_4,\nVAR_20, VAR_21 << VAR_4,\nVAR_0->h_edge_pos >> 1, VAR_0->VAR_22 >> 1);",
"VAR_0->vdsp.emulated_edge_mc(uvbuf + 16, ptr_cr,\nVAR_0->uvlinesize, VAR_0->uvlinesize,\n9, 9 + VAR_4,\nVAR_20, VAR_21 << VAR_4,\nVAR_0->h_edge_pos >> 1, VAR_0->VAR_22 >> 1);",
"ptr_cb = uvbuf;",
"ptr_cr = uvbuf + 16;",
"}",
"}",
"if (VAR_5) {",
"VAR_1 += VAR_0->linesize;",
"VAR_2 += VAR_0->uvlinesize;",
"VAR_3 += VAR_0->uvlinesize;",
"}",
"if (VAR_6) {",
"ptr_y += VAR_0->linesize;",
"ptr_cb += VAR_0->uvlinesize;",
"ptr_cr += VAR_0->uvlinesize;",
"}",
"pix_op[0][VAR_14](VAR_1, ptr_y, linesize, VAR_11);",
"if (!CONFIG_GRAY || !(VAR_0->avctx->flags & AV_CODEC_FLAG_GRAY)) {",
"pix_op[VAR_0->chroma_x_shift][VAR_15]\n(VAR_2, ptr_cb, uvlinesize, VAR_11 >> VAR_0->chroma_y_shift);",
"pix_op[VAR_0->chroma_x_shift][VAR_15]\n(VAR_3, ptr_cr, uvlinesize, VAR_11 >> VAR_0->chroma_y_shift);",
"}",
"if (!VAR_12 && (CONFIG_H261_ENCODER || CONFIG_H261_DECODER) &&\nVAR_0->out_format == FMT_H261) {",
"ff_h261_loop_filter(VAR_0);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51,
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
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,
215,
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
257
],
[
261
],
[
263,
265
],
[
267,
269
],
[
271
],
[
273,
275
],
[
277
],
[
279
],
[
281
]
] |
27,064 | static void parse_palette_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
PGSSubContext *ctx = avctx->priv_data;
const uint8_t *buf_end = buf + buf_size;
const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
int color_id;
int y, cb, cr, alpha;
int r, g, b, r_add, g_add, b_add;
/* Skip two null bytes */
buf += 2;
while (buf < buf_end) {
color_id = bytestream_get_byte(&buf);
y = bytestream_get_byte(&buf);
cr = bytestream_get_byte(&buf);
cb = bytestream_get_byte(&buf);
alpha = bytestream_get_byte(&buf);
YUV_TO_RGB1(cb, cr);
YUV_TO_RGB2(r, g, b, y);
av_dlog(avctx, "Color %d := (%d,%d,%d,%d)\n", color_id, r, g, b, alpha);
/* Store color in palette */
ctx->clut[color_id] = RGBA(r,g,b,alpha);
}
}
| false | FFmpeg | 253d0be6a1ecc343d29ff8e1df0ddf961ab9c772 | static void parse_palette_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
PGSSubContext *ctx = avctx->priv_data;
const uint8_t *buf_end = buf + buf_size;
const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
int color_id;
int y, cb, cr, alpha;
int r, g, b, r_add, g_add, b_add;
buf += 2;
while (buf < buf_end) {
color_id = bytestream_get_byte(&buf);
y = bytestream_get_byte(&buf);
cr = bytestream_get_byte(&buf);
cb = bytestream_get_byte(&buf);
alpha = bytestream_get_byte(&buf);
YUV_TO_RGB1(cb, cr);
YUV_TO_RGB2(r, g, b, y);
av_dlog(avctx, "Color %d := (%d,%d,%d,%d)\n", color_id, r, g, b, alpha);
ctx->clut[color_id] = RGBA(r,g,b,alpha);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVCodecContext *VAR_0,
const uint8_t *VAR_1, int VAR_2)
{
PGSSubContext *ctx = VAR_0->priv_data;
const uint8_t *VAR_3 = VAR_1 + VAR_2;
const uint8_t *VAR_4 = ff_crop_tab + MAX_NEG_CROP;
int VAR_5;
int VAR_6, VAR_7, VAR_8, VAR_9;
int VAR_10, VAR_11, VAR_12, VAR_13, VAR_14, VAR_15;
VAR_1 += 2;
while (VAR_1 < VAR_3) {
VAR_5 = bytestream_get_byte(&VAR_1);
VAR_6 = bytestream_get_byte(&VAR_1);
VAR_8 = bytestream_get_byte(&VAR_1);
VAR_7 = bytestream_get_byte(&VAR_1);
VAR_9 = bytestream_get_byte(&VAR_1);
YUV_TO_RGB1(VAR_7, VAR_8);
YUV_TO_RGB2(VAR_10, VAR_11, VAR_12, VAR_6);
av_dlog(VAR_0, "Color %d := (%d,%d,%d,%d)\n", VAR_5, VAR_10, VAR_11, VAR_12, VAR_9);
ctx->clut[VAR_5] = RGBA(VAR_10,VAR_11,VAR_12,VAR_9);
}
}
| [
"static void FUNC_0(AVCodecContext *VAR_0,\nconst uint8_t *VAR_1, int VAR_2)\n{",
"PGSSubContext *ctx = VAR_0->priv_data;",
"const uint8_t *VAR_3 = VAR_1 + VAR_2;",
"const uint8_t *VAR_4 = ff_crop_tab + MAX_NEG_CROP;",
"int VAR_5;",
"int VAR_6, VAR_7, VAR_8, VAR_9;",
"int VAR_10, VAR_11, VAR_12, VAR_13, VAR_14, VAR_15;",
"VAR_1 += 2;",
"while (VAR_1 < VAR_3) {",
"VAR_5 = bytestream_get_byte(&VAR_1);",
"VAR_6 = bytestream_get_byte(&VAR_1);",
"VAR_8 = bytestream_get_byte(&VAR_1);",
"VAR_7 = bytestream_get_byte(&VAR_1);",
"VAR_9 = bytestream_get_byte(&VAR_1);",
"YUV_TO_RGB1(VAR_7, VAR_8);",
"YUV_TO_RGB2(VAR_10, VAR_11, VAR_12, VAR_6);",
"av_dlog(VAR_0, \"Color %d := (%d,%d,%d,%d)\\n\", VAR_5, VAR_10, VAR_11, VAR_12, VAR_9);",
"ctx->clut[VAR_5] = RGBA(VAR_10,VAR_11,VAR_12,VAR_9);",
"}",
"}"
] | [
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
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
49
],
[
55
],
[
57
],
[
59
]
] |
27,065 | static int transcode(OutputFile *output_files, int nb_output_files,
InputFile *input_files, int nb_input_files)
{
int ret, i;
AVFormatContext *is, *os;
OutputStream *ost;
InputStream *ist;
uint8_t *no_packet;
int no_packet_count = 0;
int64_t timer_start;
int key;
if (!(no_packet = av_mallocz(nb_input_files)))
exit_program(1);
ret = transcode_init(output_files, nb_output_files, input_files, nb_input_files);
if (ret < 0)
goto fail;
if (!using_stdin) {
av_log(NULL, AV_LOG_INFO, "Press [q] to stop, [?] for help\n");
}
timer_start = av_gettime();
for (; received_sigterm == 0;) {
int file_index, ist_index;
AVPacket pkt;
int64_t ipts_min;
double opts_min;
int64_t cur_time= av_gettime();
ipts_min = INT64_MAX;
opts_min = 1e100;
/* if 'q' pressed, exits */
if (!using_stdin) {
static int64_t last_time;
if (received_nb_signals)
break;
/* read_key() returns 0 on EOF */
if(cur_time - last_time >= 100000 && !run_as_daemon){
key = read_key();
last_time = cur_time;
}else
key = -1;
if (key == 'q')
break;
if (key == '+') av_log_set_level(av_log_get_level()+10);
if (key == '-') av_log_set_level(av_log_get_level()-10);
if (key == 's') qp_hist ^= 1;
if (key == 'h'){
if (do_hex_dump){
do_hex_dump = do_pkt_dump = 0;
} else if(do_pkt_dump){
do_hex_dump = 1;
} else
do_pkt_dump = 1;
av_log_set_level(AV_LOG_DEBUG);
}
#if CONFIG_AVFILTER
if (key == 'c' || key == 'C'){
char buf[4096], target[64], command[256], arg[256] = {0};
double time;
int k, n = 0;
fprintf(stderr, "\nEnter command: <target> <time> <command>[ <argument>]\n");
i = 0;
while ((k = read_key()) != '\n' && k != '\r' && i < sizeof(buf)-1)
if (k > 0)
buf[i++] = k;
buf[i] = 0;
if (k > 0 &&
(n = sscanf(buf, "%63[^ ] %lf %255[^ ] %255[^\n]", target, &time, command, arg)) >= 3) {
av_log(NULL, AV_LOG_DEBUG, "Processing command target:%s time:%f command:%s arg:%s",
target, time, command, arg);
for (i = 0; i < nb_output_streams; i++) {
ost = &output_streams[i];
if (ost->graph) {
if (time < 0) {
ret = avfilter_graph_send_command(ost->graph, target, command, arg, buf, sizeof(buf),
key == 'c' ? AVFILTER_CMD_FLAG_ONE : 0);
fprintf(stderr, "Command reply for stream %d: ret:%d res:%s\n", i, ret, buf);
} else {
ret = avfilter_graph_queue_command(ost->graph, target, command, arg, 0, time);
}
}
}
} else {
av_log(NULL, AV_LOG_ERROR,
"Parse error, at least 3 arguments were expected, "
"only %d given in string '%s'\n", n, buf);
}
}
#endif
if (key == 'd' || key == 'D'){
int debug=0;
if(key == 'D') {
debug = input_streams[0].st->codec->debug<<1;
if(!debug) debug = 1;
while(debug & (FF_DEBUG_DCT_COEFF|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) //unsupported, would just crash
debug += debug;
}else
if(scanf("%d", &debug)!=1)
fprintf(stderr,"error parsing debug value\n");
for(i=0;i<nb_input_streams;i++) {
input_streams[i].st->codec->debug = debug;
}
for(i=0;i<nb_output_streams;i++) {
ost = &output_streams[i];
ost->st->codec->debug = debug;
}
if(debug) av_log_set_level(AV_LOG_DEBUG);
fprintf(stderr,"debug=%d\n", debug);
}
if (key == '?'){
fprintf(stderr, "key function\n"
"? show this help\n"
"+ increase verbosity\n"
"- decrease verbosity\n"
"c Send command to filtergraph\n"
"D cycle through available debug modes\n"
"h dump packets/hex press to cycle through the 3 states\n"
"q quit\n"
"s Show QP histogram\n"
);
}
}
/* select the stream that we must read now by looking at the
smallest output pts */
file_index = -1;
for (i = 0; i < nb_output_streams; i++) {
OutputFile *of;
int64_t ipts;
double opts;
ost = &output_streams[i];
of = &output_files[ost->file_index];
os = output_files[ost->file_index].ctx;
ist = &input_streams[ost->source_index];
if (ost->is_past_recording_time || no_packet[ist->file_index] ||
(os->pb && avio_tell(os->pb) >= of->limit_filesize))
continue;
opts = ost->st->pts.val * av_q2d(ost->st->time_base);
ipts = ist->pts;
if (!input_files[ist->file_index].eof_reached) {
if (ipts < ipts_min) {
ipts_min = ipts;
if (input_sync)
file_index = ist->file_index;
}
if (opts < opts_min) {
opts_min = opts;
if (!input_sync) file_index = ist->file_index;
}
}
if (ost->frame_number >= ost->max_frames) {
int j;
for (j = 0; j < of->ctx->nb_streams; j++)
output_streams[of->ost_index + j].is_past_recording_time = 1;
continue;
}
}
/* if none, if is finished */
if (file_index < 0) {
if (no_packet_count) {
no_packet_count = 0;
memset(no_packet, 0, nb_input_files);
usleep(10000);
continue;
}
break;
}
/* read a frame from it and output it in the fifo */
is = input_files[file_index].ctx;
ret = av_read_frame(is, &pkt);
if (ret == AVERROR(EAGAIN)) {
no_packet[file_index] = 1;
no_packet_count++;
continue;
}
if (ret < 0) {
input_files[file_index].eof_reached = 1;
if (opt_shortest)
break;
else
continue;
}
no_packet_count = 0;
memset(no_packet, 0, nb_input_files);
if (do_pkt_dump) {
av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump,
is->streams[pkt.stream_index]);
}
/* the following test is needed in case new streams appear
dynamically in stream : we ignore them */
if (pkt.stream_index >= input_files[file_index].nb_streams)
goto discard_packet;
ist_index = input_files[file_index].ist_index + pkt.stream_index;
ist = &input_streams[ist_index];
if (ist->discard)
goto discard_packet;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts += av_rescale_q(input_files[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts += av_rescale_q(input_files[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts *= ist->ts_scale;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts *= ist->ts_scale;
//fprintf(stderr, "next:%"PRId64" dts:%"PRId64"/%"PRId64" off:%"PRId64" %d\n",
// ist->next_dts,
// ist->dts, av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q), input_files[ist->file_index].ts_offset,
// ist->st->codec->codec_type);
if (pkt.dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE
&& (is->iformat->flags & AVFMT_TS_DISCONT)) {
int64_t pkt_dts = av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);
int64_t delta = pkt_dts - ist->next_dts;
if((delta < -1LL*dts_delta_threshold*AV_TIME_BASE ||
(delta > 1LL*dts_delta_threshold*AV_TIME_BASE &&
ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) ||
pkt_dts+1<ist->pts)&& !copy_ts){
input_files[ist->file_index].ts_offset -= delta;
av_log(NULL, AV_LOG_DEBUG,
"timestamp discontinuity %"PRId64", new offset= %"PRId64"\n",
delta, input_files[ist->file_index].ts_offset);
pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
}
}
// fprintf(stderr,"read #%d.%d size=%d\n", ist->file_index, ist->st->index, pkt.size);
if (output_packet(ist, output_streams, nb_output_streams, &pkt) < 0) {
av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d\n",
ist->file_index, ist->st->index);
if (exit_on_error)
exit_program(1);
av_free_packet(&pkt);
continue;
}
discard_packet:
av_free_packet(&pkt);
/* dump report by using the output first video and audio streams */
print_report(output_files, output_streams, nb_output_streams, 0, timer_start, cur_time);
}
/* at the end of stream, we must flush the decoder buffers */
for (i = 0; i < nb_input_streams; i++) {
ist = &input_streams[i];
if (ist->decoding_needed) {
output_packet(ist, output_streams, nb_output_streams, NULL);
}
}
flush_encoders(output_streams, nb_output_streams);
term_exit();
/* write the trailer if needed and close file */
for (i = 0; i < nb_output_files; i++) {
os = output_files[i].ctx;
av_write_trailer(os);
}
/* dump report by using the first video and audio streams */
print_report(output_files, output_streams, nb_output_streams, 1, timer_start, av_gettime());
/* close each encoder */
for (i = 0; i < nb_output_streams; i++) {
ost = &output_streams[i];
if (ost->encoding_needed) {
av_freep(&ost->st->codec->stats_in);
avcodec_close(ost->st->codec);
}
#if CONFIG_AVFILTER
avfilter_graph_free(&ost->graph);
#endif
}
/* close each decoder */
for (i = 0; i < nb_input_streams; i++) {
ist = &input_streams[i];
if (ist->decoding_needed) {
avcodec_close(ist->st->codec);
}
}
/* finished ! */
ret = 0;
fail:
av_freep(&no_packet);
if (output_streams) {
for (i = 0; i < nb_output_streams; i++) {
ost = &output_streams[i];
if (ost) {
if (ost->stream_copy)
av_freep(&ost->st->codec->extradata);
if (ost->logfile) {
fclose(ost->logfile);
ost->logfile = NULL;
}
av_fifo_free(ost->fifo); /* works even if fifo is not
initialized but set to zero */
av_freep(&ost->st->codec->subtitle_header);
av_free(ost->resample_frame.data[0]);
av_free(ost->forced_kf_pts);
if (ost->video_resample)
sws_freeContext(ost->img_resample_ctx);
swr_free(&ost->swr);
av_dict_free(&ost->opts);
}
}
}
return ret;
}
| false | FFmpeg | 29034e65039ef6b1854ceeb76ffe4092992d9fd5 | static int transcode(OutputFile *output_files, int nb_output_files,
InputFile *input_files, int nb_input_files)
{
int ret, i;
AVFormatContext *is, *os;
OutputStream *ost;
InputStream *ist;
uint8_t *no_packet;
int no_packet_count = 0;
int64_t timer_start;
int key;
if (!(no_packet = av_mallocz(nb_input_files)))
exit_program(1);
ret = transcode_init(output_files, nb_output_files, input_files, nb_input_files);
if (ret < 0)
goto fail;
if (!using_stdin) {
av_log(NULL, AV_LOG_INFO, "Press [q] to stop, [?] for help\n");
}
timer_start = av_gettime();
for (; received_sigterm == 0;) {
int file_index, ist_index;
AVPacket pkt;
int64_t ipts_min;
double opts_min;
int64_t cur_time= av_gettime();
ipts_min = INT64_MAX;
opts_min = 1e100;
if (!using_stdin) {
static int64_t last_time;
if (received_nb_signals)
break;
if(cur_time - last_time >= 100000 && !run_as_daemon){
key = read_key();
last_time = cur_time;
}else
key = -1;
if (key == 'q')
break;
if (key == '+') av_log_set_level(av_log_get_level()+10);
if (key == '-') av_log_set_level(av_log_get_level()-10);
if (key == 's') qp_hist ^= 1;
if (key == 'h'){
if (do_hex_dump){
do_hex_dump = do_pkt_dump = 0;
} else if(do_pkt_dump){
do_hex_dump = 1;
} else
do_pkt_dump = 1;
av_log_set_level(AV_LOG_DEBUG);
}
#if CONFIG_AVFILTER
if (key == 'c' || key == 'C'){
char buf[4096], target[64], command[256], arg[256] = {0};
double time;
int k, n = 0;
fprintf(stderr, "\nEnter command: <target> <time> <command>[ <argument>]\n");
i = 0;
while ((k = read_key()) != '\n' && k != '\r' && i < sizeof(buf)-1)
if (k > 0)
buf[i++] = k;
buf[i] = 0;
if (k > 0 &&
(n = sscanf(buf, "%63[^ ] %lf %255[^ ] %255[^\n]", target, &time, command, arg)) >= 3) {
av_log(NULL, AV_LOG_DEBUG, "Processing command target:%s time:%f command:%s arg:%s",
target, time, command, arg);
for (i = 0; i < nb_output_streams; i++) {
ost = &output_streams[i];
if (ost->graph) {
if (time < 0) {
ret = avfilter_graph_send_command(ost->graph, target, command, arg, buf, sizeof(buf),
key == 'c' ? AVFILTER_CMD_FLAG_ONE : 0);
fprintf(stderr, "Command reply for stream %d: ret:%d res:%s\n", i, ret, buf);
} else {
ret = avfilter_graph_queue_command(ost->graph, target, command, arg, 0, time);
}
}
}
} else {
av_log(NULL, AV_LOG_ERROR,
"Parse error, at least 3 arguments were expected, "
"only %d given in string '%s'\n", n, buf);
}
}
#endif
if (key == 'd' || key == 'D'){
int debug=0;
if(key == 'D') {
debug = input_streams[0].st->codec->debug<<1;
if(!debug) debug = 1;
while(debug & (FF_DEBUG_DCT_COEFF|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE))
debug += debug;
}else
if(scanf("%d", &debug)!=1)
fprintf(stderr,"error parsing debug value\n");
for(i=0;i<nb_input_streams;i++) {
input_streams[i].st->codec->debug = debug;
}
for(i=0;i<nb_output_streams;i++) {
ost = &output_streams[i];
ost->st->codec->debug = debug;
}
if(debug) av_log_set_level(AV_LOG_DEBUG);
fprintf(stderr,"debug=%d\n", debug);
}
if (key == '?'){
fprintf(stderr, "key function\n"
"? show this help\n"
"+ increase verbosity\n"
"- decrease verbosity\n"
"c Send command to filtergraph\n"
"D cycle through available debug modes\n"
"h dump packets/hex press to cycle through the 3 states\n"
"q quit\n"
"s Show QP histogram\n"
);
}
}
file_index = -1;
for (i = 0; i < nb_output_streams; i++) {
OutputFile *of;
int64_t ipts;
double opts;
ost = &output_streams[i];
of = &output_files[ost->file_index];
os = output_files[ost->file_index].ctx;
ist = &input_streams[ost->source_index];
if (ost->is_past_recording_time || no_packet[ist->file_index] ||
(os->pb && avio_tell(os->pb) >= of->limit_filesize))
continue;
opts = ost->st->pts.val * av_q2d(ost->st->time_base);
ipts = ist->pts;
if (!input_files[ist->file_index].eof_reached) {
if (ipts < ipts_min) {
ipts_min = ipts;
if (input_sync)
file_index = ist->file_index;
}
if (opts < opts_min) {
opts_min = opts;
if (!input_sync) file_index = ist->file_index;
}
}
if (ost->frame_number >= ost->max_frames) {
int j;
for (j = 0; j < of->ctx->nb_streams; j++)
output_streams[of->ost_index + j].is_past_recording_time = 1;
continue;
}
}
if (file_index < 0) {
if (no_packet_count) {
no_packet_count = 0;
memset(no_packet, 0, nb_input_files);
usleep(10000);
continue;
}
break;
}
is = input_files[file_index].ctx;
ret = av_read_frame(is, &pkt);
if (ret == AVERROR(EAGAIN)) {
no_packet[file_index] = 1;
no_packet_count++;
continue;
}
if (ret < 0) {
input_files[file_index].eof_reached = 1;
if (opt_shortest)
break;
else
continue;
}
no_packet_count = 0;
memset(no_packet, 0, nb_input_files);
if (do_pkt_dump) {
av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump,
is->streams[pkt.stream_index]);
}
if (pkt.stream_index >= input_files[file_index].nb_streams)
goto discard_packet;
ist_index = input_files[file_index].ist_index + pkt.stream_index;
ist = &input_streams[ist_index];
if (ist->discard)
goto discard_packet;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts += av_rescale_q(input_files[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts += av_rescale_q(input_files[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts *= ist->ts_scale;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts *= ist->ts_scale;
if (pkt.dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE
&& (is->iformat->flags & AVFMT_TS_DISCONT)) {
int64_t pkt_dts = av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);
int64_t delta = pkt_dts - ist->next_dts;
if((delta < -1LL*dts_delta_threshold*AV_TIME_BASE ||
(delta > 1LL*dts_delta_threshold*AV_TIME_BASE &&
ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) ||
pkt_dts+1<ist->pts)&& !copy_ts){
input_files[ist->file_index].ts_offset -= delta;
av_log(NULL, AV_LOG_DEBUG,
"timestamp discontinuity %"PRId64", new offset= %"PRId64"\n",
delta, input_files[ist->file_index].ts_offset);
pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
}
}
if (output_packet(ist, output_streams, nb_output_streams, &pkt) < 0) {
av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d\n",
ist->file_index, ist->st->index);
if (exit_on_error)
exit_program(1);
av_free_packet(&pkt);
continue;
}
discard_packet:
av_free_packet(&pkt);
print_report(output_files, output_streams, nb_output_streams, 0, timer_start, cur_time);
}
for (i = 0; i < nb_input_streams; i++) {
ist = &input_streams[i];
if (ist->decoding_needed) {
output_packet(ist, output_streams, nb_output_streams, NULL);
}
}
flush_encoders(output_streams, nb_output_streams);
term_exit();
for (i = 0; i < nb_output_files; i++) {
os = output_files[i].ctx;
av_write_trailer(os);
}
print_report(output_files, output_streams, nb_output_streams, 1, timer_start, av_gettime());
for (i = 0; i < nb_output_streams; i++) {
ost = &output_streams[i];
if (ost->encoding_needed) {
av_freep(&ost->st->codec->stats_in);
avcodec_close(ost->st->codec);
}
#if CONFIG_AVFILTER
avfilter_graph_free(&ost->graph);
#endif
}
for (i = 0; i < nb_input_streams; i++) {
ist = &input_streams[i];
if (ist->decoding_needed) {
avcodec_close(ist->st->codec);
}
}
ret = 0;
fail:
av_freep(&no_packet);
if (output_streams) {
for (i = 0; i < nb_output_streams; i++) {
ost = &output_streams[i];
if (ost) {
if (ost->stream_copy)
av_freep(&ost->st->codec->extradata);
if (ost->logfile) {
fclose(ost->logfile);
ost->logfile = NULL;
}
av_fifo_free(ost->fifo);
av_freep(&ost->st->codec->subtitle_header);
av_free(ost->resample_frame.data[0]);
av_free(ost->forced_kf_pts);
if (ost->video_resample)
sws_freeContext(ost->img_resample_ctx);
swr_free(&ost->swr);
av_dict_free(&ost->opts);
}
}
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(OutputFile *VAR_0, int VAR_1,
InputFile *VAR_2, int VAR_3)
{
int VAR_4, VAR_5;
AVFormatContext *is, *os;
OutputStream *ost;
InputStream *ist;
uint8_t *no_packet;
int VAR_6 = 0;
int64_t timer_start;
int VAR_7;
if (!(no_packet = av_mallocz(VAR_3)))
exit_program(1);
VAR_4 = transcode_init(VAR_0, VAR_1, VAR_2, VAR_3);
if (VAR_4 < 0)
goto fail;
if (!using_stdin) {
av_log(NULL, AV_LOG_INFO, "Press [q] to stop, [?] for help\n");
}
timer_start = av_gettime();
for (; received_sigterm == 0;) {
int file_index, ist_index;
AVPacket pkt;
int64_t ipts_min;
double opts_min;
int64_t cur_time= av_gettime();
ipts_min = INT64_MAX;
opts_min = 1e100;
if (!using_stdin) {
static int64_t last_time;
if (received_nb_signals)
break;
if(cur_time - last_time >= 100000 && !run_as_daemon){
VAR_7 = read_key();
last_time = cur_time;
}else
VAR_7 = -1;
if (VAR_7 == 'q')
break;
if (VAR_7 == '+') av_log_set_level(av_log_get_level()+10);
if (VAR_7 == '-') av_log_set_level(av_log_get_level()-10);
if (VAR_7 == 's') qp_hist ^= 1;
if (VAR_7 == 'h'){
if (do_hex_dump){
do_hex_dump = do_pkt_dump = 0;
} else if(do_pkt_dump){
do_hex_dump = 1;
} else
do_pkt_dump = 1;
av_log_set_level(AV_LOG_DEBUG);
}
#if CONFIG_AVFILTER
if (VAR_7 == 'c' || VAR_7 == 'C'){
char buf[4096], target[64], command[256], arg[256] = {0};
double time;
int k, n = 0;
fprintf(stderr, "\nEnter command: <target> <time> <command>[ <argument>]\n");
VAR_5 = 0;
while ((k = read_key()) != '\n' && k != '\r' && VAR_5 < sizeof(buf)-1)
if (k > 0)
buf[VAR_5++] = k;
buf[VAR_5] = 0;
if (k > 0 &&
(n = sscanf(buf, "%63[^ ] %lf %255[^ ] %255[^\n]", target, &time, command, arg)) >= 3) {
av_log(NULL, AV_LOG_DEBUG, "Processing command target:%s time:%f command:%s arg:%s",
target, time, command, arg);
for (VAR_5 = 0; VAR_5 < nb_output_streams; VAR_5++) {
ost = &output_streams[VAR_5];
if (ost->graph) {
if (time < 0) {
VAR_4 = avfilter_graph_send_command(ost->graph, target, command, arg, buf, sizeof(buf),
VAR_7 == 'c' ? AVFILTER_CMD_FLAG_ONE : 0);
fprintf(stderr, "Command reply for stream %d: VAR_4:%d res:%s\n", VAR_5, VAR_4, buf);
} else {
VAR_4 = avfilter_graph_queue_command(ost->graph, target, command, arg, 0, time);
}
}
}
} else {
av_log(NULL, AV_LOG_ERROR,
"Parse error, at least 3 arguments were expected, "
"only %d given in string '%s'\n", n, buf);
}
}
#endif
if (VAR_7 == 'd' || VAR_7 == 'D'){
int debug=0;
if(VAR_7 == 'D') {
debug = input_streams[0].st->codec->debug<<1;
if(!debug) debug = 1;
while(debug & (FF_DEBUG_DCT_COEFF|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE))
debug += debug;
}else
if(scanf("%d", &debug)!=1)
fprintf(stderr,"error parsing debug value\n");
for(VAR_5=0;VAR_5<nb_input_streams;VAR_5++) {
input_streams[VAR_5].st->codec->debug = debug;
}
for(VAR_5=0;VAR_5<nb_output_streams;VAR_5++) {
ost = &output_streams[VAR_5];
ost->st->codec->debug = debug;
}
if(debug) av_log_set_level(AV_LOG_DEBUG);
fprintf(stderr,"debug=%d\n", debug);
}
if (VAR_7 == '?'){
fprintf(stderr, "VAR_7 function\n"
"? show this help\n"
"+ increase verbosity\n"
"- decrease verbosity\n"
"c Send command to filtergraph\n"
"D cycle through available debug modes\n"
"h dump packets/hex press to cycle through the 3 states\n"
"q quit\n"
"s Show QP histogram\n"
);
}
}
file_index = -1;
for (VAR_5 = 0; VAR_5 < nb_output_streams; VAR_5++) {
OutputFile *of;
int64_t ipts;
double opts;
ost = &output_streams[VAR_5];
of = &VAR_0[ost->file_index];
os = VAR_0[ost->file_index].ctx;
ist = &input_streams[ost->source_index];
if (ost->is_past_recording_time || no_packet[ist->file_index] ||
(os->pb && avio_tell(os->pb) >= of->limit_filesize))
continue;
opts = ost->st->pts.val * av_q2d(ost->st->time_base);
ipts = ist->pts;
if (!VAR_2[ist->file_index].eof_reached) {
if (ipts < ipts_min) {
ipts_min = ipts;
if (input_sync)
file_index = ist->file_index;
}
if (opts < opts_min) {
opts_min = opts;
if (!input_sync) file_index = ist->file_index;
}
}
if (ost->frame_number >= ost->max_frames) {
int j;
for (j = 0; j < of->ctx->nb_streams; j++)
output_streams[of->ost_index + j].is_past_recording_time = 1;
continue;
}
}
if (file_index < 0) {
if (VAR_6) {
VAR_6 = 0;
memset(no_packet, 0, VAR_3);
usleep(10000);
continue;
}
break;
}
is = VAR_2[file_index].ctx;
VAR_4 = av_read_frame(is, &pkt);
if (VAR_4 == AVERROR(EAGAIN)) {
no_packet[file_index] = 1;
VAR_6++;
continue;
}
if (VAR_4 < 0) {
VAR_2[file_index].eof_reached = 1;
if (opt_shortest)
break;
else
continue;
}
VAR_6 = 0;
memset(no_packet, 0, VAR_3);
if (do_pkt_dump) {
av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump,
is->streams[pkt.stream_index]);
}
if (pkt.stream_index >= VAR_2[file_index].nb_streams)
goto discard_packet;
ist_index = VAR_2[file_index].ist_index + pkt.stream_index;
ist = &input_streams[ist_index];
if (ist->discard)
goto discard_packet;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts += av_rescale_q(VAR_2[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts += av_rescale_q(VAR_2[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts *= ist->ts_scale;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts *= ist->ts_scale;
if (pkt.dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE
&& (is->iformat->flags & AVFMT_TS_DISCONT)) {
int64_t pkt_dts = av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);
int64_t delta = pkt_dts - ist->next_dts;
if((delta < -1LL*dts_delta_threshold*AV_TIME_BASE ||
(delta > 1LL*dts_delta_threshold*AV_TIME_BASE &&
ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) ||
pkt_dts+1<ist->pts)&& !copy_ts){
VAR_2[ist->file_index].ts_offset -= delta;
av_log(NULL, AV_LOG_DEBUG,
"timestamp discontinuity %"PRId64", new offset= %"PRId64"\n",
delta, VAR_2[ist->file_index].ts_offset);
pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
}
}
if (output_packet(ist, output_streams, nb_output_streams, &pkt) < 0) {
av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d\n",
ist->file_index, ist->st->index);
if (exit_on_error)
exit_program(1);
av_free_packet(&pkt);
continue;
}
discard_packet:
av_free_packet(&pkt);
print_report(VAR_0, output_streams, nb_output_streams, 0, timer_start, cur_time);
}
for (VAR_5 = 0; VAR_5 < nb_input_streams; VAR_5++) {
ist = &input_streams[VAR_5];
if (ist->decoding_needed) {
output_packet(ist, output_streams, nb_output_streams, NULL);
}
}
flush_encoders(output_streams, nb_output_streams);
term_exit();
for (VAR_5 = 0; VAR_5 < VAR_1; VAR_5++) {
os = VAR_0[VAR_5].ctx;
av_write_trailer(os);
}
print_report(VAR_0, output_streams, nb_output_streams, 1, timer_start, av_gettime());
for (VAR_5 = 0; VAR_5 < nb_output_streams; VAR_5++) {
ost = &output_streams[VAR_5];
if (ost->encoding_needed) {
av_freep(&ost->st->codec->stats_in);
avcodec_close(ost->st->codec);
}
#if CONFIG_AVFILTER
avfilter_graph_free(&ost->graph);
#endif
}
for (VAR_5 = 0; VAR_5 < nb_input_streams; VAR_5++) {
ist = &input_streams[VAR_5];
if (ist->decoding_needed) {
avcodec_close(ist->st->codec);
}
}
VAR_4 = 0;
fail:
av_freep(&no_packet);
if (output_streams) {
for (VAR_5 = 0; VAR_5 < nb_output_streams; VAR_5++) {
ost = &output_streams[VAR_5];
if (ost) {
if (ost->stream_copy)
av_freep(&ost->st->codec->extradata);
if (ost->logfile) {
fclose(ost->logfile);
ost->logfile = NULL;
}
av_fifo_free(ost->fifo);
av_freep(&ost->st->codec->subtitle_header);
av_free(ost->resample_frame.data[0]);
av_free(ost->forced_kf_pts);
if (ost->video_resample)
sws_freeContext(ost->img_resample_ctx);
swr_free(&ost->swr);
av_dict_free(&ost->opts);
}
}
}
return VAR_4;
}
| [
"static int FUNC_0(OutputFile *VAR_0, int VAR_1,\nInputFile *VAR_2, int VAR_3)\n{",
"int VAR_4, VAR_5;",
"AVFormatContext *is, *os;",
"OutputStream *ost;",
"InputStream *ist;",
"uint8_t *no_packet;",
"int VAR_6 = 0;",
"int64_t timer_start;",
"int VAR_7;",
"if (!(no_packet = av_mallocz(VAR_3)))\nexit_program(1);",
"VAR_4 = transcode_init(VAR_0, VAR_1, VAR_2, VAR_3);",
"if (VAR_4 < 0)\ngoto fail;",
"if (!using_stdin) {",
"av_log(NULL, AV_LOG_INFO, \"Press [q] to stop, [?] for help\\n\");",
"}",
"timer_start = av_gettime();",
"for (; received_sigterm == 0;) {",
"int file_index, ist_index;",
"AVPacket pkt;",
"int64_t ipts_min;",
"double opts_min;",
"int64_t cur_time= av_gettime();",
"ipts_min = INT64_MAX;",
"opts_min = 1e100;",
"if (!using_stdin) {",
"static int64_t last_time;",
"if (received_nb_signals)\nbreak;",
"if(cur_time - last_time >= 100000 && !run_as_daemon){",
"VAR_7 = read_key();",
"last_time = cur_time;",
"}else",
"VAR_7 = -1;",
"if (VAR_7 == 'q')\nbreak;",
"if (VAR_7 == '+') av_log_set_level(av_log_get_level()+10);",
"if (VAR_7 == '-') av_log_set_level(av_log_get_level()-10);",
"if (VAR_7 == 's') qp_hist ^= 1;",
"if (VAR_7 == 'h'){",
"if (do_hex_dump){",
"do_hex_dump = do_pkt_dump = 0;",
"} else if(do_pkt_dump){",
"do_hex_dump = 1;",
"} else",
"do_pkt_dump = 1;",
"av_log_set_level(AV_LOG_DEBUG);",
"}",
"#if CONFIG_AVFILTER\nif (VAR_7 == 'c' || VAR_7 == 'C'){",
"char buf[4096], target[64], command[256], arg[256] = {0};",
"double time;",
"int k, n = 0;",
"fprintf(stderr, \"\\nEnter command: <target> <time> <command>[ <argument>]\\n\");",
"VAR_5 = 0;",
"while ((k = read_key()) != '\\n' && k != '\\r' && VAR_5 < sizeof(buf)-1)\nif (k > 0)\nbuf[VAR_5++] = k;",
"buf[VAR_5] = 0;",
"if (k > 0 &&\n(n = sscanf(buf, \"%63[^ ] %lf %255[^ ] %255[^\\n]\", target, &time, command, arg)) >= 3) {",
"av_log(NULL, AV_LOG_DEBUG, \"Processing command target:%s time:%f command:%s arg:%s\",\ntarget, time, command, arg);",
"for (VAR_5 = 0; VAR_5 < nb_output_streams; VAR_5++) {",
"ost = &output_streams[VAR_5];",
"if (ost->graph) {",
"if (time < 0) {",
"VAR_4 = avfilter_graph_send_command(ost->graph, target, command, arg, buf, sizeof(buf),\nVAR_7 == 'c' ? AVFILTER_CMD_FLAG_ONE : 0);",
"fprintf(stderr, \"Command reply for stream %d: VAR_4:%d res:%s\\n\", VAR_5, VAR_4, buf);",
"} else {",
"VAR_4 = avfilter_graph_queue_command(ost->graph, target, command, arg, 0, time);",
"}",
"}",
"}",
"} else {",
"av_log(NULL, AV_LOG_ERROR,\n\"Parse error, at least 3 arguments were expected, \"\n\"only %d given in string '%s'\\n\", n, buf);",
"}",
"}",
"#endif\nif (VAR_7 == 'd' || VAR_7 == 'D'){",
"int debug=0;",
"if(VAR_7 == 'D') {",
"debug = input_streams[0].st->codec->debug<<1;",
"if(!debug) debug = 1;",
"while(debug & (FF_DEBUG_DCT_COEFF|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE))\ndebug += debug;",
"}else",
"if(scanf(\"%d\", &debug)!=1)\nfprintf(stderr,\"error parsing debug value\\n\");",
"for(VAR_5=0;VAR_5<nb_input_streams;VAR_5++) {",
"input_streams[VAR_5].st->codec->debug = debug;",
"}",
"for(VAR_5=0;VAR_5<nb_output_streams;VAR_5++) {",
"ost = &output_streams[VAR_5];",
"ost->st->codec->debug = debug;",
"}",
"if(debug) av_log_set_level(AV_LOG_DEBUG);",
"fprintf(stderr,\"debug=%d\\n\", debug);",
"}",
"if (VAR_7 == '?'){",
"fprintf(stderr, \"VAR_7 function\\n\"\n\"? show this help\\n\"\n\"+ increase verbosity\\n\"\n\"- decrease verbosity\\n\"\n\"c Send command to filtergraph\\n\"\n\"D cycle through available debug modes\\n\"\n\"h dump packets/hex press to cycle through the 3 states\\n\"\n\"q quit\\n\"\n\"s Show QP histogram\\n\"\n);",
"}",
"}",
"file_index = -1;",
"for (VAR_5 = 0; VAR_5 < nb_output_streams; VAR_5++) {",
"OutputFile *of;",
"int64_t ipts;",
"double opts;",
"ost = &output_streams[VAR_5];",
"of = &VAR_0[ost->file_index];",
"os = VAR_0[ost->file_index].ctx;",
"ist = &input_streams[ost->source_index];",
"if (ost->is_past_recording_time || no_packet[ist->file_index] ||\n(os->pb && avio_tell(os->pb) >= of->limit_filesize))\ncontinue;",
"opts = ost->st->pts.val * av_q2d(ost->st->time_base);",
"ipts = ist->pts;",
"if (!VAR_2[ist->file_index].eof_reached) {",
"if (ipts < ipts_min) {",
"ipts_min = ipts;",
"if (input_sync)\nfile_index = ist->file_index;",
"}",
"if (opts < opts_min) {",
"opts_min = opts;",
"if (!input_sync) file_index = ist->file_index;",
"}",
"}",
"if (ost->frame_number >= ost->max_frames) {",
"int j;",
"for (j = 0; j < of->ctx->nb_streams; j++)",
"output_streams[of->ost_index + j].is_past_recording_time = 1;",
"continue;",
"}",
"}",
"if (file_index < 0) {",
"if (VAR_6) {",
"VAR_6 = 0;",
"memset(no_packet, 0, VAR_3);",
"usleep(10000);",
"continue;",
"}",
"break;",
"}",
"is = VAR_2[file_index].ctx;",
"VAR_4 = av_read_frame(is, &pkt);",
"if (VAR_4 == AVERROR(EAGAIN)) {",
"no_packet[file_index] = 1;",
"VAR_6++;",
"continue;",
"}",
"if (VAR_4 < 0) {",
"VAR_2[file_index].eof_reached = 1;",
"if (opt_shortest)\nbreak;",
"else\ncontinue;",
"}",
"VAR_6 = 0;",
"memset(no_packet, 0, VAR_3);",
"if (do_pkt_dump) {",
"av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump,\nis->streams[pkt.stream_index]);",
"}",
"if (pkt.stream_index >= VAR_2[file_index].nb_streams)\ngoto discard_packet;",
"ist_index = VAR_2[file_index].ist_index + pkt.stream_index;",
"ist = &input_streams[ist_index];",
"if (ist->discard)\ngoto discard_packet;",
"if (pkt.dts != AV_NOPTS_VALUE)\npkt.dts += av_rescale_q(VAR_2[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base);",
"if (pkt.pts != AV_NOPTS_VALUE)\npkt.pts += av_rescale_q(VAR_2[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base);",
"if (pkt.pts != AV_NOPTS_VALUE)\npkt.pts *= ist->ts_scale;",
"if (pkt.dts != AV_NOPTS_VALUE)\npkt.dts *= ist->ts_scale;",
"if (pkt.dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE\n&& (is->iformat->flags & AVFMT_TS_DISCONT)) {",
"int64_t pkt_dts = av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);",
"int64_t delta = pkt_dts - ist->next_dts;",
"if((delta < -1LL*dts_delta_threshold*AV_TIME_BASE ||\n(delta > 1LL*dts_delta_threshold*AV_TIME_BASE &&\nist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) ||\npkt_dts+1<ist->pts)&& !copy_ts){",
"VAR_2[ist->file_index].ts_offset -= delta;",
"av_log(NULL, AV_LOG_DEBUG,\n\"timestamp discontinuity %\"PRId64\", new offset= %\"PRId64\"\\n\",\ndelta, VAR_2[ist->file_index].ts_offset);",
"pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);",
"if (pkt.pts != AV_NOPTS_VALUE)\npkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);",
"}",
"}",
"if (output_packet(ist, output_streams, nb_output_streams, &pkt) < 0) {",
"av_log(NULL, AV_LOG_ERROR, \"Error while decoding stream #%d:%d\\n\",\nist->file_index, ist->st->index);",
"if (exit_on_error)\nexit_program(1);",
"av_free_packet(&pkt);",
"continue;",
"}",
"discard_packet:\nav_free_packet(&pkt);",
"print_report(VAR_0, output_streams, nb_output_streams, 0, timer_start, cur_time);",
"}",
"for (VAR_5 = 0; VAR_5 < nb_input_streams; VAR_5++) {",
"ist = &input_streams[VAR_5];",
"if (ist->decoding_needed) {",
"output_packet(ist, output_streams, nb_output_streams, NULL);",
"}",
"}",
"flush_encoders(output_streams, nb_output_streams);",
"term_exit();",
"for (VAR_5 = 0; VAR_5 < VAR_1; VAR_5++) {",
"os = VAR_0[VAR_5].ctx;",
"av_write_trailer(os);",
"}",
"print_report(VAR_0, output_streams, nb_output_streams, 1, timer_start, av_gettime());",
"for (VAR_5 = 0; VAR_5 < nb_output_streams; VAR_5++) {",
"ost = &output_streams[VAR_5];",
"if (ost->encoding_needed) {",
"av_freep(&ost->st->codec->stats_in);",
"avcodec_close(ost->st->codec);",
"}",
"#if CONFIG_AVFILTER\navfilter_graph_free(&ost->graph);",
"#endif\n}",
"for (VAR_5 = 0; VAR_5 < nb_input_streams; VAR_5++) {",
"ist = &input_streams[VAR_5];",
"if (ist->decoding_needed) {",
"avcodec_close(ist->st->codec);",
"}",
"}",
"VAR_4 = 0;",
"fail:\nav_freep(&no_packet);",
"if (output_streams) {",
"for (VAR_5 = 0; VAR_5 < nb_output_streams; VAR_5++) {",
"ost = &output_streams[VAR_5];",
"if (ost) {",
"if (ost->stream_copy)\nav_freep(&ost->st->codec->extradata);",
"if (ost->logfile) {",
"fclose(ost->logfile);",
"ost->logfile = NULL;",
"}",
"av_fifo_free(ost->fifo);",
"av_freep(&ost->st->codec->subtitle_header);",
"av_free(ost->resample_frame.data[0]);",
"av_free(ost->forced_kf_pts);",
"if (ost->video_resample)\nsws_freeContext(ost->img_resample_ctx);",
"swr_free(&ost->swr);",
"av_dict_free(&ost->opts);",
"}",
"}",
"}",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25,
27
],
[
31
],
[
33,
35
],
[
39
],
[
41
],
[
43
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75,
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91,
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119,
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133,
135,
137
],
[
139
],
[
141,
143
],
[
145,
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157,
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175,
177,
179
],
[
181
],
[
183
],
[
185,
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197,
199
],
[
201
],
[
203,
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229,
231,
233,
235,
237,
239,
241,
243,
245,
247
],
[
249
],
[
251
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277,
279,
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293,
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365,
367
],
[
369,
371
],
[
373
],
[
377
],
[
379
],
[
383
],
[
385,
387
],
[
389
],
[
395,
397
],
[
399
],
[
401
],
[
403,
405
],
[
409,
411
],
[
413,
415
],
[
419,
421
],
[
423,
425
],
[
437,
439
],
[
441
],
[
443
],
[
445,
447,
449,
451
],
[
453
],
[
455,
457,
459
],
[
461
],
[
463,
465
],
[
467
],
[
469
],
[
475
],
[
479,
481
],
[
483,
485
],
[
487
],
[
489
],
[
491
],
[
495,
497
],
[
503
],
[
505
],
[
511
],
[
513
],
[
515
],
[
517
],
[
519
],
[
521
],
[
523
],
[
527
],
[
533
],
[
535
],
[
537
],
[
539
],
[
545
],
[
551
],
[
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
563,
565
],
[
567,
569
],
[
575
],
[
577
],
[
579
],
[
581
],
[
583
],
[
585
],
[
591
],
[
595,
597
],
[
601
],
[
603
],
[
605
],
[
607
],
[
609,
611
],
[
613
],
[
615
],
[
617
],
[
619
],
[
621
],
[
625
],
[
627
],
[
629
],
[
631,
633
],
[
635
],
[
637
],
[
639
],
[
641
],
[
643
],
[
645
],
[
647
]
] |
27,066 | void *av_realloc(void *ptr, size_t size)
{
#if CONFIG_MEMALIGN_HACK
int diff;
#endif
/* let's disallow possible ambiguous cases */
if (size > (MAX_MALLOC_SIZE-16))
return NULL;
#if CONFIG_MEMALIGN_HACK
//FIXME this isn't aligned correctly, though it probably isn't needed
if(!ptr) return av_malloc(size);
diff= ((char*)ptr)[-1];
return (char*)realloc((char*)ptr - diff, size + diff) + diff;
#else
return realloc(ptr, size + !size);
#endif
}
| false | FFmpeg | fc11927890f38445a950b453d24928525da0e61a | void *av_realloc(void *ptr, size_t size)
{
#if CONFIG_MEMALIGN_HACK
int diff;
#endif
if (size > (MAX_MALLOC_SIZE-16))
return NULL;
#if CONFIG_MEMALIGN_HACK
if(!ptr) return av_malloc(size);
diff= ((char*)ptr)[-1];
return (char*)realloc((char*)ptr - diff, size + diff) + diff;
#else
return realloc(ptr, size + !size);
#endif
}
| {
"code": [],
"line_no": []
} | void *FUNC_0(void *VAR_0, size_t VAR_1)
{
#if CONFIG_MEMALIGN_HACK
int diff;
#endif
if (VAR_1 > (MAX_MALLOC_SIZE-16))
return NULL;
#if CONFIG_MEMALIGN_HACK
if(!VAR_0) return av_malloc(VAR_1);
diff= ((char*)VAR_0)[-1];
return (char*)realloc((char*)VAR_0 - diff, VAR_1 + diff) + diff;
#else
return realloc(VAR_0, VAR_1 + !VAR_1);
#endif
}
| [
"void *FUNC_0(void *VAR_0, size_t VAR_1)\n{",
"#if CONFIG_MEMALIGN_HACK\nint diff;",
"#endif\nif (VAR_1 > (MAX_MALLOC_SIZE-16))\nreturn NULL;",
"#if CONFIG_MEMALIGN_HACK\nif(!VAR_0) return av_malloc(VAR_1);",
"diff= ((char*)VAR_0)[-1];",
"return (char*)realloc((char*)VAR_0 - diff, VAR_1 + diff) + diff;",
"#else\nreturn realloc(VAR_0, VAR_1 + !VAR_1);",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9,
15,
17
],
[
21,
25
],
[
27
],
[
29
],
[
31,
33
],
[
35,
37
]
] |
27,068 | static av_cold int raw_close_decoder(AVCodecContext *avctx)
{
RawVideoContext *context = avctx->priv_data;
av_freep(&context->buffer);
return 0;
}
| false | FFmpeg | 6184fa2067ccf88e68a7009442cf01440e59d99c | static av_cold int raw_close_decoder(AVCodecContext *avctx)
{
RawVideoContext *context = avctx->priv_data;
av_freep(&context->buffer);
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
RawVideoContext *context = avctx->priv_data;
av_freep(&context->buffer);
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"RawVideoContext *context = avctx->priv_data;",
"av_freep(&context->buffer);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
]
] |
27,070 | static int mc_subpel(DiracContext *s, DiracBlock *block, const uint8_t *src[5],
int x, int y, int ref, int plane)
{
Plane *p = &s->plane[plane];
uint8_t **ref_hpel = s->ref_pics[ref]->hpel[plane];
int motion_x = block->u.mv[ref][0];
int motion_y = block->u.mv[ref][1];
int mx, my, i, epel, nplanes = 0;
if (plane) {
motion_x >>= s->chroma_x_shift;
motion_y >>= s->chroma_y_shift;
}
mx = motion_x & ~(-1 << s->mv_precision);
my = motion_y & ~(-1 << s->mv_precision);
motion_x >>= s->mv_precision;
motion_y >>= s->mv_precision;
/* normalize subpel coordinates to epel */
/* TODO: template this function? */
mx <<= 3 - s->mv_precision;
my <<= 3 - s->mv_precision;
x += motion_x;
y += motion_y;
epel = (mx|my)&1;
/* hpel position */
if (!((mx|my)&3)) {
nplanes = 1;
src[0] = ref_hpel[(my>>1)+(mx>>2)] + y*p->stride + x;
} else {
/* qpel or epel */
nplanes = 4;
for (i = 0; i < 4; i++)
src[i] = ref_hpel[i] + y*p->stride + x;
/* if we're interpolating in the right/bottom halves, adjust the planes as needed
we increment x/y because the edge changes for half of the pixels */
if (mx > 4) {
src[0] += 1;
src[2] += 1;
x++;
}
if (my > 4) {
src[0] += p->stride;
src[1] += p->stride;
y++;
}
/* hpel planes are:
[0]: F [1]: H
[2]: V [3]: C */
if (!epel) {
/* check if we really only need 2 planes since either mx or my is
a hpel position. (epel weights of 0 handle this there) */
if (!(mx&3)) {
/* mx == 0: average [0] and [2]
mx == 4: average [1] and [3] */
src[!mx] = src[2 + !!mx];
nplanes = 2;
} else if (!(my&3)) {
src[0] = src[(my>>1) ];
src[1] = src[(my>>1)+1];
nplanes = 2;
}
} else {
/* adjust the ordering if needed so the weights work */
if (mx > 4) {
FFSWAP(const uint8_t *, src[0], src[1]);
FFSWAP(const uint8_t *, src[2], src[3]);
}
if (my > 4) {
FFSWAP(const uint8_t *, src[0], src[2]);
FFSWAP(const uint8_t *, src[1], src[3]);
}
src[4] = epel_weights[my&3][mx&3];
}
}
/* fixme: v/h _edge_pos */
if (x + p->xblen > p->width +EDGE_WIDTH/2 ||
y + p->yblen > p->height+EDGE_WIDTH/2 ||
x < 0 || y < 0) {
for (i = 0; i < nplanes; i++) {
ff_emulated_edge_mc(s->edge_emu_buffer[i], src[i],
p->stride, p->stride,
p->xblen, p->yblen, x, y,
p->width+EDGE_WIDTH/2, p->height+EDGE_WIDTH/2);
src[i] = s->edge_emu_buffer[i];
}
}
return (nplanes>>1) + epel;
}
| true | FFmpeg | b8598f6ce61ccda3f2ff0c730b009fb650e42986 | static int mc_subpel(DiracContext *s, DiracBlock *block, const uint8_t *src[5],
int x, int y, int ref, int plane)
{
Plane *p = &s->plane[plane];
uint8_t **ref_hpel = s->ref_pics[ref]->hpel[plane];
int motion_x = block->u.mv[ref][0];
int motion_y = block->u.mv[ref][1];
int mx, my, i, epel, nplanes = 0;
if (plane) {
motion_x >>= s->chroma_x_shift;
motion_y >>= s->chroma_y_shift;
}
mx = motion_x & ~(-1 << s->mv_precision);
my = motion_y & ~(-1 << s->mv_precision);
motion_x >>= s->mv_precision;
motion_y >>= s->mv_precision;
mx <<= 3 - s->mv_precision;
my <<= 3 - s->mv_precision;
x += motion_x;
y += motion_y;
epel = (mx|my)&1;
if (!((mx|my)&3)) {
nplanes = 1;
src[0] = ref_hpel[(my>>1)+(mx>>2)] + y*p->stride + x;
} else {
nplanes = 4;
for (i = 0; i < 4; i++)
src[i] = ref_hpel[i] + y*p->stride + x;
if (mx > 4) {
src[0] += 1;
src[2] += 1;
x++;
}
if (my > 4) {
src[0] += p->stride;
src[1] += p->stride;
y++;
}
if (!epel) {
if (!(mx&3)) {
src[!mx] = src[2 + !!mx];
nplanes = 2;
} else if (!(my&3)) {
src[0] = src[(my>>1) ];
src[1] = src[(my>>1)+1];
nplanes = 2;
}
} else {
if (mx > 4) {
FFSWAP(const uint8_t *, src[0], src[1]);
FFSWAP(const uint8_t *, src[2], src[3]);
}
if (my > 4) {
FFSWAP(const uint8_t *, src[0], src[2]);
FFSWAP(const uint8_t *, src[1], src[3]);
}
src[4] = epel_weights[my&3][mx&3];
}
}
if (x + p->xblen > p->width +EDGE_WIDTH/2 ||
y + p->yblen > p->height+EDGE_WIDTH/2 ||
x < 0 || y < 0) {
for (i = 0; i < nplanes; i++) {
ff_emulated_edge_mc(s->edge_emu_buffer[i], src[i],
p->stride, p->stride,
p->xblen, p->yblen, x, y,
p->width+EDGE_WIDTH/2, p->height+EDGE_WIDTH/2);
src[i] = s->edge_emu_buffer[i];
}
}
return (nplanes>>1) + epel;
}
| {
"code": [
" mx = motion_x & ~(-1 << s->mv_precision);",
" my = motion_y & ~(-1 << s->mv_precision);"
],
"line_no": [
29,
31
]
} | static int FUNC_0(DiracContext *VAR_0, DiracBlock *VAR_1, const uint8_t *VAR_2[5],
int VAR_3, int VAR_4, int VAR_5, int VAR_6)
{
Plane *p = &VAR_0->VAR_6[VAR_6];
uint8_t **ref_hpel = VAR_0->ref_pics[VAR_5]->hpel[VAR_6];
int VAR_7 = VAR_1->u.mv[VAR_5][0];
int VAR_8 = VAR_1->u.mv[VAR_5][1];
int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13 = 0;
if (VAR_6) {
VAR_7 >>= VAR_0->chroma_x_shift;
VAR_8 >>= VAR_0->chroma_y_shift;
}
VAR_9 = VAR_7 & ~(-1 << VAR_0->mv_precision);
VAR_10 = VAR_8 & ~(-1 << VAR_0->mv_precision);
VAR_7 >>= VAR_0->mv_precision;
VAR_8 >>= VAR_0->mv_precision;
VAR_9 <<= 3 - VAR_0->mv_precision;
VAR_10 <<= 3 - VAR_0->mv_precision;
VAR_3 += VAR_7;
VAR_4 += VAR_8;
VAR_12 = (VAR_9|VAR_10)&1;
if (!((VAR_9|VAR_10)&3)) {
VAR_13 = 1;
VAR_2[0] = ref_hpel[(VAR_10>>1)+(VAR_9>>2)] + VAR_4*p->stride + VAR_3;
} else {
VAR_13 = 4;
for (VAR_11 = 0; VAR_11 < 4; VAR_11++)
VAR_2[VAR_11] = ref_hpel[VAR_11] + VAR_4*p->stride + VAR_3;
if (VAR_9 > 4) {
VAR_2[0] += 1;
VAR_2[2] += 1;
VAR_3++;
}
if (VAR_10 > 4) {
VAR_2[0] += p->stride;
VAR_2[1] += p->stride;
VAR_4++;
}
if (!VAR_12) {
if (!(VAR_9&3)) {
VAR_2[!VAR_9] = VAR_2[2 + !!VAR_9];
VAR_13 = 2;
} else if (!(VAR_10&3)) {
VAR_2[0] = VAR_2[(VAR_10>>1) ];
VAR_2[1] = VAR_2[(VAR_10>>1)+1];
VAR_13 = 2;
}
} else {
if (VAR_9 > 4) {
FFSWAP(const uint8_t *, VAR_2[0], VAR_2[1]);
FFSWAP(const uint8_t *, VAR_2[2], VAR_2[3]);
}
if (VAR_10 > 4) {
FFSWAP(const uint8_t *, VAR_2[0], VAR_2[2]);
FFSWAP(const uint8_t *, VAR_2[1], VAR_2[3]);
}
VAR_2[4] = epel_weights[VAR_10&3][VAR_9&3];
}
}
if (VAR_3 + p->xblen > p->width +EDGE_WIDTH/2 ||
VAR_4 + p->yblen > p->height+EDGE_WIDTH/2 ||
VAR_3 < 0 || VAR_4 < 0) {
for (VAR_11 = 0; VAR_11 < VAR_13; VAR_11++) {
ff_emulated_edge_mc(VAR_0->edge_emu_buffer[VAR_11], VAR_2[VAR_11],
p->stride, p->stride,
p->xblen, p->yblen, VAR_3, VAR_4,
p->width+EDGE_WIDTH/2, p->height+EDGE_WIDTH/2);
VAR_2[VAR_11] = VAR_0->edge_emu_buffer[VAR_11];
}
}
return (VAR_13>>1) + VAR_12;
}
| [
"static int FUNC_0(DiracContext *VAR_0, DiracBlock *VAR_1, const uint8_t *VAR_2[5],\nint VAR_3, int VAR_4, int VAR_5, int VAR_6)\n{",
"Plane *p = &VAR_0->VAR_6[VAR_6];",
"uint8_t **ref_hpel = VAR_0->ref_pics[VAR_5]->hpel[VAR_6];",
"int VAR_7 = VAR_1->u.mv[VAR_5][0];",
"int VAR_8 = VAR_1->u.mv[VAR_5][1];",
"int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13 = 0;",
"if (VAR_6) {",
"VAR_7 >>= VAR_0->chroma_x_shift;",
"VAR_8 >>= VAR_0->chroma_y_shift;",
"}",
"VAR_9 = VAR_7 & ~(-1 << VAR_0->mv_precision);",
"VAR_10 = VAR_8 & ~(-1 << VAR_0->mv_precision);",
"VAR_7 >>= VAR_0->mv_precision;",
"VAR_8 >>= VAR_0->mv_precision;",
"VAR_9 <<= 3 - VAR_0->mv_precision;",
"VAR_10 <<= 3 - VAR_0->mv_precision;",
"VAR_3 += VAR_7;",
"VAR_4 += VAR_8;",
"VAR_12 = (VAR_9|VAR_10)&1;",
"if (!((VAR_9|VAR_10)&3)) {",
"VAR_13 = 1;",
"VAR_2[0] = ref_hpel[(VAR_10>>1)+(VAR_9>>2)] + VAR_4*p->stride + VAR_3;",
"} else {",
"VAR_13 = 4;",
"for (VAR_11 = 0; VAR_11 < 4; VAR_11++)",
"VAR_2[VAR_11] = ref_hpel[VAR_11] + VAR_4*p->stride + VAR_3;",
"if (VAR_9 > 4) {",
"VAR_2[0] += 1;",
"VAR_2[2] += 1;",
"VAR_3++;",
"}",
"if (VAR_10 > 4) {",
"VAR_2[0] += p->stride;",
"VAR_2[1] += p->stride;",
"VAR_4++;",
"}",
"if (!VAR_12) {",
"if (!(VAR_9&3)) {",
"VAR_2[!VAR_9] = VAR_2[2 + !!VAR_9];",
"VAR_13 = 2;",
"} else if (!(VAR_10&3)) {",
"VAR_2[0] = VAR_2[(VAR_10>>1) ];",
"VAR_2[1] = VAR_2[(VAR_10>>1)+1];",
"VAR_13 = 2;",
"}",
"} else {",
"if (VAR_9 > 4) {",
"FFSWAP(const uint8_t *, VAR_2[0], VAR_2[1]);",
"FFSWAP(const uint8_t *, VAR_2[2], VAR_2[3]);",
"}",
"if (VAR_10 > 4) {",
"FFSWAP(const uint8_t *, VAR_2[0], VAR_2[2]);",
"FFSWAP(const uint8_t *, VAR_2[1], VAR_2[3]);",
"}",
"VAR_2[4] = epel_weights[VAR_10&3][VAR_9&3];",
"}",
"}",
"if (VAR_3 + p->xblen > p->width +EDGE_WIDTH/2 ||\nVAR_4 + p->yblen > p->height+EDGE_WIDTH/2 ||\nVAR_3 < 0 || VAR_4 < 0) {",
"for (VAR_11 = 0; VAR_11 < VAR_13; VAR_11++) {",
"ff_emulated_edge_mc(VAR_0->edge_emu_buffer[VAR_11], VAR_2[VAR_11],\np->stride, p->stride,\np->xblen, p->yblen, VAR_3, VAR_4,\np->width+EDGE_WIDTH/2, p->height+EDGE_WIDTH/2);",
"VAR_2[VAR_11] = VAR_0->edge_emu_buffer[VAR_11];",
"}",
"}",
"return (VAR_13>>1) + VAR_12;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
107
],
[
113
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
163,
165,
167
],
[
169
],
[
171,
173,
175,
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
]
] |
27,071 | int kvm_arch_init_vcpu(CPUState *cs)
{
struct {
struct kvm_cpuid2 cpuid;
struct kvm_cpuid_entry2 entries[KVM_MAX_CPUID_ENTRIES];
} QEMU_PACKED cpuid_data;
X86CPU *cpu = X86_CPU(cs);
CPUX86State *env = &cpu->env;
uint32_t limit, i, j, cpuid_i;
uint32_t unused;
struct kvm_cpuid_entry2 *c;
uint32_t signature[3];
int r;
cpuid_i = 0;
/* Paravirtualization CPUIDs */
c = &cpuid_data.entries[cpuid_i++];
memset(c, 0, sizeof(*c));
c->function = KVM_CPUID_SIGNATURE;
if (!hyperv_enabled(cpu)) {
memcpy(signature, "KVMKVMKVM\0\0\0", 12);
c->eax = 0;
} else {
memcpy(signature, "Microsoft Hv", 12);
c->eax = HYPERV_CPUID_MIN;
}
c->ebx = signature[0];
c->ecx = signature[1];
c->edx = signature[2];
c = &cpuid_data.entries[cpuid_i++];
memset(c, 0, sizeof(*c));
c->function = KVM_CPUID_FEATURES;
c->eax = env->features[FEAT_KVM];
if (hyperv_enabled(cpu)) {
memcpy(signature, "Hv#1\0\0\0\0\0\0\0\0", 12);
c->eax = signature[0];
c = &cpuid_data.entries[cpuid_i++];
memset(c, 0, sizeof(*c));
c->function = HYPERV_CPUID_VERSION;
c->eax = 0x00001bbc;
c->ebx = 0x00060001;
c = &cpuid_data.entries[cpuid_i++];
memset(c, 0, sizeof(*c));
c->function = HYPERV_CPUID_FEATURES;
if (cpu->hyperv_relaxed_timing) {
c->eax |= HV_X64_MSR_HYPERCALL_AVAILABLE;
}
if (cpu->hyperv_vapic) {
c->eax |= HV_X64_MSR_HYPERCALL_AVAILABLE;
c->eax |= HV_X64_MSR_APIC_ACCESS_AVAILABLE;
}
c = &cpuid_data.entries[cpuid_i++];
memset(c, 0, sizeof(*c));
c->function = HYPERV_CPUID_ENLIGHTMENT_INFO;
if (cpu->hyperv_relaxed_timing) {
c->eax |= HV_X64_RELAXED_TIMING_RECOMMENDED;
}
if (cpu->hyperv_vapic) {
c->eax |= HV_X64_APIC_ACCESS_RECOMMENDED;
}
c->ebx = cpu->hyperv_spinlock_attempts;
c = &cpuid_data.entries[cpuid_i++];
memset(c, 0, sizeof(*c));
c->function = HYPERV_CPUID_IMPLEMENT_LIMITS;
c->eax = 0x40;
c->ebx = 0x40;
c = &cpuid_data.entries[cpuid_i++];
memset(c, 0, sizeof(*c));
c->function = KVM_CPUID_SIGNATURE_NEXT;
memcpy(signature, "KVMKVMKVM\0\0\0", 12);
c->eax = 0;
c->ebx = signature[0];
c->ecx = signature[1];
c->edx = signature[2];
}
has_msr_async_pf_en = c->eax & (1 << KVM_FEATURE_ASYNC_PF);
has_msr_pv_eoi_en = c->eax & (1 << KVM_FEATURE_PV_EOI);
has_msr_kvm_steal_time = c->eax & (1 << KVM_FEATURE_STEAL_TIME);
cpu_x86_cpuid(env, 0, 0, &limit, &unused, &unused, &unused);
for (i = 0; i <= limit; i++) {
if (cpuid_i == KVM_MAX_CPUID_ENTRIES) {
fprintf(stderr, "unsupported level value: 0x%x\n", limit);
abort();
}
c = &cpuid_data.entries[cpuid_i++];
switch (i) {
case 2: {
/* Keep reading function 2 till all the input is received */
int times;
c->function = i;
c->flags = KVM_CPUID_FLAG_STATEFUL_FUNC |
KVM_CPUID_FLAG_STATE_READ_NEXT;
cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
times = c->eax & 0xff;
for (j = 1; j < times; ++j) {
if (cpuid_i == KVM_MAX_CPUID_ENTRIES) {
fprintf(stderr, "cpuid_data is full, no space for "
"cpuid(eax:2):eax & 0xf = 0x%x\n", times);
abort();
}
c = &cpuid_data.entries[cpuid_i++];
c->function = i;
c->flags = KVM_CPUID_FLAG_STATEFUL_FUNC;
cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
}
break;
}
case 4:
case 0xb:
case 0xd:
for (j = 0; ; j++) {
if (i == 0xd && j == 64) {
break;
}
c->function = i;
c->flags = KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
c->index = j;
cpu_x86_cpuid(env, i, j, &c->eax, &c->ebx, &c->ecx, &c->edx);
if (i == 4 && c->eax == 0) {
break;
}
if (i == 0xb && !(c->ecx & 0xff00)) {
break;
}
if (i == 0xd && c->eax == 0) {
continue;
}
if (cpuid_i == KVM_MAX_CPUID_ENTRIES) {
fprintf(stderr, "cpuid_data is full, no space for "
"cpuid(eax:0x%x,ecx:0x%x)\n", i, j);
abort();
}
c = &cpuid_data.entries[cpuid_i++];
}
break;
default:
c->function = i;
c->flags = 0;
cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
break;
}
}
if (limit >= 0x0a) {
uint32_t ver;
cpu_x86_cpuid(env, 0x0a, 0, &ver, &unused, &unused, &unused);
if ((ver & 0xff) > 0) {
has_msr_architectural_pmu = true;
num_architectural_pmu_counters = (ver & 0xff00) >> 8;
/* Shouldn't be more than 32, since that's the number of bits
* available in EBX to tell us _which_ counters are available.
* Play it safe.
*/
if (num_architectural_pmu_counters > MAX_GP_COUNTERS) {
num_architectural_pmu_counters = MAX_GP_COUNTERS;
}
}
}
cpu_x86_cpuid(env, 0x80000000, 0, &limit, &unused, &unused, &unused);
for (i = 0x80000000; i <= limit; i++) {
if (cpuid_i == KVM_MAX_CPUID_ENTRIES) {
fprintf(stderr, "unsupported xlevel value: 0x%x\n", limit);
abort();
}
c = &cpuid_data.entries[cpuid_i++];
c->function = i;
c->flags = 0;
cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
}
/* Call Centaur's CPUID instructions they are supported. */
if (env->cpuid_xlevel2 > 0) {
cpu_x86_cpuid(env, 0xC0000000, 0, &limit, &unused, &unused, &unused);
for (i = 0xC0000000; i <= limit; i++) {
if (cpuid_i == KVM_MAX_CPUID_ENTRIES) {
fprintf(stderr, "unsupported xlevel2 value: 0x%x\n", limit);
abort();
}
c = &cpuid_data.entries[cpuid_i++];
c->function = i;
c->flags = 0;
cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
}
}
cpuid_data.cpuid.nent = cpuid_i;
if (((env->cpuid_version >> 8)&0xF) >= 6
&& (env->features[FEAT_1_EDX] & (CPUID_MCE | CPUID_MCA)) ==
(CPUID_MCE | CPUID_MCA)
&& kvm_check_extension(cs->kvm_state, KVM_CAP_MCE) > 0) {
uint64_t mcg_cap;
int banks;
int ret;
ret = kvm_get_mce_cap_supported(cs->kvm_state, &mcg_cap, &banks);
if (ret < 0) {
fprintf(stderr, "kvm_get_mce_cap_supported: %s", strerror(-ret));
return ret;
}
if (banks > MCE_BANKS_DEF) {
banks = MCE_BANKS_DEF;
}
mcg_cap &= MCE_CAP_DEF;
mcg_cap |= banks;
ret = kvm_vcpu_ioctl(cs, KVM_X86_SETUP_MCE, &mcg_cap);
if (ret < 0) {
fprintf(stderr, "KVM_X86_SETUP_MCE: %s", strerror(-ret));
return ret;
}
env->mcg_cap = mcg_cap;
}
qemu_add_vm_change_state_handler(cpu_update_state, env);
c = cpuid_find_entry(&cpuid_data.cpuid, 1, 0);
if (c) {
has_msr_feature_control = !!(c->ecx & CPUID_EXT_VMX) ||
!!(c->ecx & CPUID_EXT_SMX);
}
cpuid_data.cpuid.padding = 0;
r = kvm_vcpu_ioctl(cs, KVM_SET_CPUID2, &cpuid_data);
if (r) {
return r;
}
r = kvm_check_extension(cs->kvm_state, KVM_CAP_TSC_CONTROL);
if (r && env->tsc_khz) {
r = kvm_vcpu_ioctl(cs, KVM_SET_TSC_KHZ, env->tsc_khz);
if (r < 0) {
fprintf(stderr, "KVM_SET_TSC_KHZ failed\n");
return r;
}
}
if (kvm_has_xsave()) {
env->kvm_xsave_buf = qemu_memalign(4096, sizeof(struct kvm_xsave));
}
return 0;
}
| true | qemu | ef4cbe14342c1f63b3c754e306218f004f4e26c4 | int kvm_arch_init_vcpu(CPUState *cs)
{
struct {
struct kvm_cpuid2 cpuid;
struct kvm_cpuid_entry2 entries[KVM_MAX_CPUID_ENTRIES];
} QEMU_PACKED cpuid_data;
X86CPU *cpu = X86_CPU(cs);
CPUX86State *env = &cpu->env;
uint32_t limit, i, j, cpuid_i;
uint32_t unused;
struct kvm_cpuid_entry2 *c;
uint32_t signature[3];
int r;
cpuid_i = 0;
c = &cpuid_data.entries[cpuid_i++];
memset(c, 0, sizeof(*c));
c->function = KVM_CPUID_SIGNATURE;
if (!hyperv_enabled(cpu)) {
memcpy(signature, "KVMKVMKVM\0\0\0", 12);
c->eax = 0;
} else {
memcpy(signature, "Microsoft Hv", 12);
c->eax = HYPERV_CPUID_MIN;
}
c->ebx = signature[0];
c->ecx = signature[1];
c->edx = signature[2];
c = &cpuid_data.entries[cpuid_i++];
memset(c, 0, sizeof(*c));
c->function = KVM_CPUID_FEATURES;
c->eax = env->features[FEAT_KVM];
if (hyperv_enabled(cpu)) {
memcpy(signature, "Hv#1\0\0\0\0\0\0\0\0", 12);
c->eax = signature[0];
c = &cpuid_data.entries[cpuid_i++];
memset(c, 0, sizeof(*c));
c->function = HYPERV_CPUID_VERSION;
c->eax = 0x00001bbc;
c->ebx = 0x00060001;
c = &cpuid_data.entries[cpuid_i++];
memset(c, 0, sizeof(*c));
c->function = HYPERV_CPUID_FEATURES;
if (cpu->hyperv_relaxed_timing) {
c->eax |= HV_X64_MSR_HYPERCALL_AVAILABLE;
}
if (cpu->hyperv_vapic) {
c->eax |= HV_X64_MSR_HYPERCALL_AVAILABLE;
c->eax |= HV_X64_MSR_APIC_ACCESS_AVAILABLE;
}
c = &cpuid_data.entries[cpuid_i++];
memset(c, 0, sizeof(*c));
c->function = HYPERV_CPUID_ENLIGHTMENT_INFO;
if (cpu->hyperv_relaxed_timing) {
c->eax |= HV_X64_RELAXED_TIMING_RECOMMENDED;
}
if (cpu->hyperv_vapic) {
c->eax |= HV_X64_APIC_ACCESS_RECOMMENDED;
}
c->ebx = cpu->hyperv_spinlock_attempts;
c = &cpuid_data.entries[cpuid_i++];
memset(c, 0, sizeof(*c));
c->function = HYPERV_CPUID_IMPLEMENT_LIMITS;
c->eax = 0x40;
c->ebx = 0x40;
c = &cpuid_data.entries[cpuid_i++];
memset(c, 0, sizeof(*c));
c->function = KVM_CPUID_SIGNATURE_NEXT;
memcpy(signature, "KVMKVMKVM\0\0\0", 12);
c->eax = 0;
c->ebx = signature[0];
c->ecx = signature[1];
c->edx = signature[2];
}
has_msr_async_pf_en = c->eax & (1 << KVM_FEATURE_ASYNC_PF);
has_msr_pv_eoi_en = c->eax & (1 << KVM_FEATURE_PV_EOI);
has_msr_kvm_steal_time = c->eax & (1 << KVM_FEATURE_STEAL_TIME);
cpu_x86_cpuid(env, 0, 0, &limit, &unused, &unused, &unused);
for (i = 0; i <= limit; i++) {
if (cpuid_i == KVM_MAX_CPUID_ENTRIES) {
fprintf(stderr, "unsupported level value: 0x%x\n", limit);
abort();
}
c = &cpuid_data.entries[cpuid_i++];
switch (i) {
case 2: {
int times;
c->function = i;
c->flags = KVM_CPUID_FLAG_STATEFUL_FUNC |
KVM_CPUID_FLAG_STATE_READ_NEXT;
cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
times = c->eax & 0xff;
for (j = 1; j < times; ++j) {
if (cpuid_i == KVM_MAX_CPUID_ENTRIES) {
fprintf(stderr, "cpuid_data is full, no space for "
"cpuid(eax:2):eax & 0xf = 0x%x\n", times);
abort();
}
c = &cpuid_data.entries[cpuid_i++];
c->function = i;
c->flags = KVM_CPUID_FLAG_STATEFUL_FUNC;
cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
}
break;
}
case 4:
case 0xb:
case 0xd:
for (j = 0; ; j++) {
if (i == 0xd && j == 64) {
break;
}
c->function = i;
c->flags = KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
c->index = j;
cpu_x86_cpuid(env, i, j, &c->eax, &c->ebx, &c->ecx, &c->edx);
if (i == 4 && c->eax == 0) {
break;
}
if (i == 0xb && !(c->ecx & 0xff00)) {
break;
}
if (i == 0xd && c->eax == 0) {
continue;
}
if (cpuid_i == KVM_MAX_CPUID_ENTRIES) {
fprintf(stderr, "cpuid_data is full, no space for "
"cpuid(eax:0x%x,ecx:0x%x)\n", i, j);
abort();
}
c = &cpuid_data.entries[cpuid_i++];
}
break;
default:
c->function = i;
c->flags = 0;
cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
break;
}
}
if (limit >= 0x0a) {
uint32_t ver;
cpu_x86_cpuid(env, 0x0a, 0, &ver, &unused, &unused, &unused);
if ((ver & 0xff) > 0) {
has_msr_architectural_pmu = true;
num_architectural_pmu_counters = (ver & 0xff00) >> 8;
if (num_architectural_pmu_counters > MAX_GP_COUNTERS) {
num_architectural_pmu_counters = MAX_GP_COUNTERS;
}
}
}
cpu_x86_cpuid(env, 0x80000000, 0, &limit, &unused, &unused, &unused);
for (i = 0x80000000; i <= limit; i++) {
if (cpuid_i == KVM_MAX_CPUID_ENTRIES) {
fprintf(stderr, "unsupported xlevel value: 0x%x\n", limit);
abort();
}
c = &cpuid_data.entries[cpuid_i++];
c->function = i;
c->flags = 0;
cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
}
if (env->cpuid_xlevel2 > 0) {
cpu_x86_cpuid(env, 0xC0000000, 0, &limit, &unused, &unused, &unused);
for (i = 0xC0000000; i <= limit; i++) {
if (cpuid_i == KVM_MAX_CPUID_ENTRIES) {
fprintf(stderr, "unsupported xlevel2 value: 0x%x\n", limit);
abort();
}
c = &cpuid_data.entries[cpuid_i++];
c->function = i;
c->flags = 0;
cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
}
}
cpuid_data.cpuid.nent = cpuid_i;
if (((env->cpuid_version >> 8)&0xF) >= 6
&& (env->features[FEAT_1_EDX] & (CPUID_MCE | CPUID_MCA)) ==
(CPUID_MCE | CPUID_MCA)
&& kvm_check_extension(cs->kvm_state, KVM_CAP_MCE) > 0) {
uint64_t mcg_cap;
int banks;
int ret;
ret = kvm_get_mce_cap_supported(cs->kvm_state, &mcg_cap, &banks);
if (ret < 0) {
fprintf(stderr, "kvm_get_mce_cap_supported: %s", strerror(-ret));
return ret;
}
if (banks > MCE_BANKS_DEF) {
banks = MCE_BANKS_DEF;
}
mcg_cap &= MCE_CAP_DEF;
mcg_cap |= banks;
ret = kvm_vcpu_ioctl(cs, KVM_X86_SETUP_MCE, &mcg_cap);
if (ret < 0) {
fprintf(stderr, "KVM_X86_SETUP_MCE: %s", strerror(-ret));
return ret;
}
env->mcg_cap = mcg_cap;
}
qemu_add_vm_change_state_handler(cpu_update_state, env);
c = cpuid_find_entry(&cpuid_data.cpuid, 1, 0);
if (c) {
has_msr_feature_control = !!(c->ecx & CPUID_EXT_VMX) ||
!!(c->ecx & CPUID_EXT_SMX);
}
cpuid_data.cpuid.padding = 0;
r = kvm_vcpu_ioctl(cs, KVM_SET_CPUID2, &cpuid_data);
if (r) {
return r;
}
r = kvm_check_extension(cs->kvm_state, KVM_CAP_TSC_CONTROL);
if (r && env->tsc_khz) {
r = kvm_vcpu_ioctl(cs, KVM_SET_TSC_KHZ, env->tsc_khz);
if (r < 0) {
fprintf(stderr, "KVM_SET_TSC_KHZ failed\n");
return r;
}
}
if (kvm_has_xsave()) {
env->kvm_xsave_buf = qemu_memalign(4096, sizeof(struct kvm_xsave));
}
return 0;
}
| {
"code": [
" memset(c, 0, sizeof(*c));",
" memset(c, 0, sizeof(*c));",
" memset(c, 0, sizeof(*c));",
" memset(c, 0, sizeof(*c));",
" memset(c, 0, sizeof(*c));",
" memset(c, 0, sizeof(*c));",
" memset(c, 0, sizeof(*c));"
],
"line_no": [
37,
37,
83,
83,
83,
83,
83
]
} | int FUNC_0(CPUState *VAR_0)
{
struct {
struct kvm_cpuid2 cpuid;
struct kvm_cpuid_entry2 entries[KVM_MAX_CPUID_ENTRIES];
} QEMU_PACKED VAR_1;
X86CPU *cpu = X86_CPU(VAR_0);
CPUX86State *env = &cpu->env;
uint32_t limit, i, j, cpuid_i;
uint32_t unused;
struct kvm_cpuid_entry2 *VAR_2;
uint32_t signature[3];
int VAR_3;
cpuid_i = 0;
VAR_2 = &VAR_1.entries[cpuid_i++];
memset(VAR_2, 0, sizeof(*VAR_2));
VAR_2->function = KVM_CPUID_SIGNATURE;
if (!hyperv_enabled(cpu)) {
memcpy(signature, "KVMKVMKVM\0\0\0", 12);
VAR_2->eax = 0;
} else {
memcpy(signature, "Microsoft Hv", 12);
VAR_2->eax = HYPERV_CPUID_MIN;
}
VAR_2->ebx = signature[0];
VAR_2->ecx = signature[1];
VAR_2->edx = signature[2];
VAR_2 = &VAR_1.entries[cpuid_i++];
memset(VAR_2, 0, sizeof(*VAR_2));
VAR_2->function = KVM_CPUID_FEATURES;
VAR_2->eax = env->features[FEAT_KVM];
if (hyperv_enabled(cpu)) {
memcpy(signature, "Hv#1\0\0\0\0\0\0\0\0", 12);
VAR_2->eax = signature[0];
VAR_2 = &VAR_1.entries[cpuid_i++];
memset(VAR_2, 0, sizeof(*VAR_2));
VAR_2->function = HYPERV_CPUID_VERSION;
VAR_2->eax = 0x00001bbc;
VAR_2->ebx = 0x00060001;
VAR_2 = &VAR_1.entries[cpuid_i++];
memset(VAR_2, 0, sizeof(*VAR_2));
VAR_2->function = HYPERV_CPUID_FEATURES;
if (cpu->hyperv_relaxed_timing) {
VAR_2->eax |= HV_X64_MSR_HYPERCALL_AVAILABLE;
}
if (cpu->hyperv_vapic) {
VAR_2->eax |= HV_X64_MSR_HYPERCALL_AVAILABLE;
VAR_2->eax |= HV_X64_MSR_APIC_ACCESS_AVAILABLE;
}
VAR_2 = &VAR_1.entries[cpuid_i++];
memset(VAR_2, 0, sizeof(*VAR_2));
VAR_2->function = HYPERV_CPUID_ENLIGHTMENT_INFO;
if (cpu->hyperv_relaxed_timing) {
VAR_2->eax |= HV_X64_RELAXED_TIMING_RECOMMENDED;
}
if (cpu->hyperv_vapic) {
VAR_2->eax |= HV_X64_APIC_ACCESS_RECOMMENDED;
}
VAR_2->ebx = cpu->hyperv_spinlock_attempts;
VAR_2 = &VAR_1.entries[cpuid_i++];
memset(VAR_2, 0, sizeof(*VAR_2));
VAR_2->function = HYPERV_CPUID_IMPLEMENT_LIMITS;
VAR_2->eax = 0x40;
VAR_2->ebx = 0x40;
VAR_2 = &VAR_1.entries[cpuid_i++];
memset(VAR_2, 0, sizeof(*VAR_2));
VAR_2->function = KVM_CPUID_SIGNATURE_NEXT;
memcpy(signature, "KVMKVMKVM\0\0\0", 12);
VAR_2->eax = 0;
VAR_2->ebx = signature[0];
VAR_2->ecx = signature[1];
VAR_2->edx = signature[2];
}
has_msr_async_pf_en = VAR_2->eax & (1 << KVM_FEATURE_ASYNC_PF);
has_msr_pv_eoi_en = VAR_2->eax & (1 << KVM_FEATURE_PV_EOI);
has_msr_kvm_steal_time = VAR_2->eax & (1 << KVM_FEATURE_STEAL_TIME);
cpu_x86_cpuid(env, 0, 0, &limit, &unused, &unused, &unused);
for (i = 0; i <= limit; i++) {
if (cpuid_i == KVM_MAX_CPUID_ENTRIES) {
fprintf(stderr, "unsupported level value: 0x%x\n", limit);
abort();
}
VAR_2 = &VAR_1.entries[cpuid_i++];
switch (i) {
case 2: {
int times;
VAR_2->function = i;
VAR_2->flags = KVM_CPUID_FLAG_STATEFUL_FUNC |
KVM_CPUID_FLAG_STATE_READ_NEXT;
cpu_x86_cpuid(env, i, 0, &VAR_2->eax, &VAR_2->ebx, &VAR_2->ecx, &VAR_2->edx);
times = VAR_2->eax & 0xff;
for (j = 1; j < times; ++j) {
if (cpuid_i == KVM_MAX_CPUID_ENTRIES) {
fprintf(stderr, "VAR_1 is full, no space for "
"cpuid(eax:2):eax & 0xf = 0x%x\n", times);
abort();
}
VAR_2 = &VAR_1.entries[cpuid_i++];
VAR_2->function = i;
VAR_2->flags = KVM_CPUID_FLAG_STATEFUL_FUNC;
cpu_x86_cpuid(env, i, 0, &VAR_2->eax, &VAR_2->ebx, &VAR_2->ecx, &VAR_2->edx);
}
break;
}
case 4:
case 0xb:
case 0xd:
for (j = 0; ; j++) {
if (i == 0xd && j == 64) {
break;
}
VAR_2->function = i;
VAR_2->flags = KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
VAR_2->index = j;
cpu_x86_cpuid(env, i, j, &VAR_2->eax, &VAR_2->ebx, &VAR_2->ecx, &VAR_2->edx);
if (i == 4 && VAR_2->eax == 0) {
break;
}
if (i == 0xb && !(VAR_2->ecx & 0xff00)) {
break;
}
if (i == 0xd && VAR_2->eax == 0) {
continue;
}
if (cpuid_i == KVM_MAX_CPUID_ENTRIES) {
fprintf(stderr, "VAR_1 is full, no space for "
"cpuid(eax:0x%x,ecx:0x%x)\n", i, j);
abort();
}
VAR_2 = &VAR_1.entries[cpuid_i++];
}
break;
default:
VAR_2->function = i;
VAR_2->flags = 0;
cpu_x86_cpuid(env, i, 0, &VAR_2->eax, &VAR_2->ebx, &VAR_2->ecx, &VAR_2->edx);
break;
}
}
if (limit >= 0x0a) {
uint32_t ver;
cpu_x86_cpuid(env, 0x0a, 0, &ver, &unused, &unused, &unused);
if ((ver & 0xff) > 0) {
has_msr_architectural_pmu = true;
num_architectural_pmu_counters = (ver & 0xff00) >> 8;
if (num_architectural_pmu_counters > MAX_GP_COUNTERS) {
num_architectural_pmu_counters = MAX_GP_COUNTERS;
}
}
}
cpu_x86_cpuid(env, 0x80000000, 0, &limit, &unused, &unused, &unused);
for (i = 0x80000000; i <= limit; i++) {
if (cpuid_i == KVM_MAX_CPUID_ENTRIES) {
fprintf(stderr, "unsupported xlevel value: 0x%x\n", limit);
abort();
}
VAR_2 = &VAR_1.entries[cpuid_i++];
VAR_2->function = i;
VAR_2->flags = 0;
cpu_x86_cpuid(env, i, 0, &VAR_2->eax, &VAR_2->ebx, &VAR_2->ecx, &VAR_2->edx);
}
if (env->cpuid_xlevel2 > 0) {
cpu_x86_cpuid(env, 0xC0000000, 0, &limit, &unused, &unused, &unused);
for (i = 0xC0000000; i <= limit; i++) {
if (cpuid_i == KVM_MAX_CPUID_ENTRIES) {
fprintf(stderr, "unsupported xlevel2 value: 0x%x\n", limit);
abort();
}
VAR_2 = &VAR_1.entries[cpuid_i++];
VAR_2->function = i;
VAR_2->flags = 0;
cpu_x86_cpuid(env, i, 0, &VAR_2->eax, &VAR_2->ebx, &VAR_2->ecx, &VAR_2->edx);
}
}
VAR_1.cpuid.nent = cpuid_i;
if (((env->cpuid_version >> 8)&0xF) >= 6
&& (env->features[FEAT_1_EDX] & (CPUID_MCE | CPUID_MCA)) ==
(CPUID_MCE | CPUID_MCA)
&& kvm_check_extension(VAR_0->kvm_state, KVM_CAP_MCE) > 0) {
uint64_t mcg_cap;
int VAR_4;
int VAR_5;
VAR_5 = kvm_get_mce_cap_supported(VAR_0->kvm_state, &mcg_cap, &VAR_4);
if (VAR_5 < 0) {
fprintf(stderr, "kvm_get_mce_cap_supported: %s", strerror(-VAR_5));
return VAR_5;
}
if (VAR_4 > MCE_BANKS_DEF) {
VAR_4 = MCE_BANKS_DEF;
}
mcg_cap &= MCE_CAP_DEF;
mcg_cap |= VAR_4;
VAR_5 = kvm_vcpu_ioctl(VAR_0, KVM_X86_SETUP_MCE, &mcg_cap);
if (VAR_5 < 0) {
fprintf(stderr, "KVM_X86_SETUP_MCE: %s", strerror(-VAR_5));
return VAR_5;
}
env->mcg_cap = mcg_cap;
}
qemu_add_vm_change_state_handler(cpu_update_state, env);
VAR_2 = cpuid_find_entry(&VAR_1.cpuid, 1, 0);
if (VAR_2) {
has_msr_feature_control = !!(VAR_2->ecx & CPUID_EXT_VMX) ||
!!(VAR_2->ecx & CPUID_EXT_SMX);
}
VAR_1.cpuid.padding = 0;
VAR_3 = kvm_vcpu_ioctl(VAR_0, KVM_SET_CPUID2, &VAR_1);
if (VAR_3) {
return VAR_3;
}
VAR_3 = kvm_check_extension(VAR_0->kvm_state, KVM_CAP_TSC_CONTROL);
if (VAR_3 && env->tsc_khz) {
VAR_3 = kvm_vcpu_ioctl(VAR_0, KVM_SET_TSC_KHZ, env->tsc_khz);
if (VAR_3 < 0) {
fprintf(stderr, "KVM_SET_TSC_KHZ failed\n");
return VAR_3;
}
}
if (kvm_has_xsave()) {
env->kvm_xsave_buf = qemu_memalign(4096, sizeof(struct kvm_xsave));
}
return 0;
}
| [
"int FUNC_0(CPUState *VAR_0)\n{",
"struct {",
"struct kvm_cpuid2 cpuid;",
"struct kvm_cpuid_entry2 entries[KVM_MAX_CPUID_ENTRIES];",
"} QEMU_PACKED VAR_1;",
"X86CPU *cpu = X86_CPU(VAR_0);",
"CPUX86State *env = &cpu->env;",
"uint32_t limit, i, j, cpuid_i;",
"uint32_t unused;",
"struct kvm_cpuid_entry2 *VAR_2;",
"uint32_t signature[3];",
"int VAR_3;",
"cpuid_i = 0;",
"VAR_2 = &VAR_1.entries[cpuid_i++];",
"memset(VAR_2, 0, sizeof(*VAR_2));",
"VAR_2->function = KVM_CPUID_SIGNATURE;",
"if (!hyperv_enabled(cpu)) {",
"memcpy(signature, \"KVMKVMKVM\\0\\0\\0\", 12);",
"VAR_2->eax = 0;",
"} else {",
"memcpy(signature, \"Microsoft Hv\", 12);",
"VAR_2->eax = HYPERV_CPUID_MIN;",
"}",
"VAR_2->ebx = signature[0];",
"VAR_2->ecx = signature[1];",
"VAR_2->edx = signature[2];",
"VAR_2 = &VAR_1.entries[cpuid_i++];",
"memset(VAR_2, 0, sizeof(*VAR_2));",
"VAR_2->function = KVM_CPUID_FEATURES;",
"VAR_2->eax = env->features[FEAT_KVM];",
"if (hyperv_enabled(cpu)) {",
"memcpy(signature, \"Hv#1\\0\\0\\0\\0\\0\\0\\0\\0\", 12);",
"VAR_2->eax = signature[0];",
"VAR_2 = &VAR_1.entries[cpuid_i++];",
"memset(VAR_2, 0, sizeof(*VAR_2));",
"VAR_2->function = HYPERV_CPUID_VERSION;",
"VAR_2->eax = 0x00001bbc;",
"VAR_2->ebx = 0x00060001;",
"VAR_2 = &VAR_1.entries[cpuid_i++];",
"memset(VAR_2, 0, sizeof(*VAR_2));",
"VAR_2->function = HYPERV_CPUID_FEATURES;",
"if (cpu->hyperv_relaxed_timing) {",
"VAR_2->eax |= HV_X64_MSR_HYPERCALL_AVAILABLE;",
"}",
"if (cpu->hyperv_vapic) {",
"VAR_2->eax |= HV_X64_MSR_HYPERCALL_AVAILABLE;",
"VAR_2->eax |= HV_X64_MSR_APIC_ACCESS_AVAILABLE;",
"}",
"VAR_2 = &VAR_1.entries[cpuid_i++];",
"memset(VAR_2, 0, sizeof(*VAR_2));",
"VAR_2->function = HYPERV_CPUID_ENLIGHTMENT_INFO;",
"if (cpu->hyperv_relaxed_timing) {",
"VAR_2->eax |= HV_X64_RELAXED_TIMING_RECOMMENDED;",
"}",
"if (cpu->hyperv_vapic) {",
"VAR_2->eax |= HV_X64_APIC_ACCESS_RECOMMENDED;",
"}",
"VAR_2->ebx = cpu->hyperv_spinlock_attempts;",
"VAR_2 = &VAR_1.entries[cpuid_i++];",
"memset(VAR_2, 0, sizeof(*VAR_2));",
"VAR_2->function = HYPERV_CPUID_IMPLEMENT_LIMITS;",
"VAR_2->eax = 0x40;",
"VAR_2->ebx = 0x40;",
"VAR_2 = &VAR_1.entries[cpuid_i++];",
"memset(VAR_2, 0, sizeof(*VAR_2));",
"VAR_2->function = KVM_CPUID_SIGNATURE_NEXT;",
"memcpy(signature, \"KVMKVMKVM\\0\\0\\0\", 12);",
"VAR_2->eax = 0;",
"VAR_2->ebx = signature[0];",
"VAR_2->ecx = signature[1];",
"VAR_2->edx = signature[2];",
"}",
"has_msr_async_pf_en = VAR_2->eax & (1 << KVM_FEATURE_ASYNC_PF);",
"has_msr_pv_eoi_en = VAR_2->eax & (1 << KVM_FEATURE_PV_EOI);",
"has_msr_kvm_steal_time = VAR_2->eax & (1 << KVM_FEATURE_STEAL_TIME);",
"cpu_x86_cpuid(env, 0, 0, &limit, &unused, &unused, &unused);",
"for (i = 0; i <= limit; i++) {",
"if (cpuid_i == KVM_MAX_CPUID_ENTRIES) {",
"fprintf(stderr, \"unsupported level value: 0x%x\\n\", limit);",
"abort();",
"}",
"VAR_2 = &VAR_1.entries[cpuid_i++];",
"switch (i) {",
"case 2: {",
"int times;",
"VAR_2->function = i;",
"VAR_2->flags = KVM_CPUID_FLAG_STATEFUL_FUNC |\nKVM_CPUID_FLAG_STATE_READ_NEXT;",
"cpu_x86_cpuid(env, i, 0, &VAR_2->eax, &VAR_2->ebx, &VAR_2->ecx, &VAR_2->edx);",
"times = VAR_2->eax & 0xff;",
"for (j = 1; j < times; ++j) {",
"if (cpuid_i == KVM_MAX_CPUID_ENTRIES) {",
"fprintf(stderr, \"VAR_1 is full, no space for \"\n\"cpuid(eax:2):eax & 0xf = 0x%x\\n\", times);",
"abort();",
"}",
"VAR_2 = &VAR_1.entries[cpuid_i++];",
"VAR_2->function = i;",
"VAR_2->flags = KVM_CPUID_FLAG_STATEFUL_FUNC;",
"cpu_x86_cpuid(env, i, 0, &VAR_2->eax, &VAR_2->ebx, &VAR_2->ecx, &VAR_2->edx);",
"}",
"break;",
"}",
"case 4:\ncase 0xb:\ncase 0xd:\nfor (j = 0; ; j++) {",
"if (i == 0xd && j == 64) {",
"break;",
"}",
"VAR_2->function = i;",
"VAR_2->flags = KVM_CPUID_FLAG_SIGNIFCANT_INDEX;",
"VAR_2->index = j;",
"cpu_x86_cpuid(env, i, j, &VAR_2->eax, &VAR_2->ebx, &VAR_2->ecx, &VAR_2->edx);",
"if (i == 4 && VAR_2->eax == 0) {",
"break;",
"}",
"if (i == 0xb && !(VAR_2->ecx & 0xff00)) {",
"break;",
"}",
"if (i == 0xd && VAR_2->eax == 0) {",
"continue;",
"}",
"if (cpuid_i == KVM_MAX_CPUID_ENTRIES) {",
"fprintf(stderr, \"VAR_1 is full, no space for \"\n\"cpuid(eax:0x%x,ecx:0x%x)\\n\", i, j);",
"abort();",
"}",
"VAR_2 = &VAR_1.entries[cpuid_i++];",
"}",
"break;",
"default:\nVAR_2->function = i;",
"VAR_2->flags = 0;",
"cpu_x86_cpuid(env, i, 0, &VAR_2->eax, &VAR_2->ebx, &VAR_2->ecx, &VAR_2->edx);",
"break;",
"}",
"}",
"if (limit >= 0x0a) {",
"uint32_t ver;",
"cpu_x86_cpuid(env, 0x0a, 0, &ver, &unused, &unused, &unused);",
"if ((ver & 0xff) > 0) {",
"has_msr_architectural_pmu = true;",
"num_architectural_pmu_counters = (ver & 0xff00) >> 8;",
"if (num_architectural_pmu_counters > MAX_GP_COUNTERS) {",
"num_architectural_pmu_counters = MAX_GP_COUNTERS;",
"}",
"}",
"}",
"cpu_x86_cpuid(env, 0x80000000, 0, &limit, &unused, &unused, &unused);",
"for (i = 0x80000000; i <= limit; i++) {",
"if (cpuid_i == KVM_MAX_CPUID_ENTRIES) {",
"fprintf(stderr, \"unsupported xlevel value: 0x%x\\n\", limit);",
"abort();",
"}",
"VAR_2 = &VAR_1.entries[cpuid_i++];",
"VAR_2->function = i;",
"VAR_2->flags = 0;",
"cpu_x86_cpuid(env, i, 0, &VAR_2->eax, &VAR_2->ebx, &VAR_2->ecx, &VAR_2->edx);",
"}",
"if (env->cpuid_xlevel2 > 0) {",
"cpu_x86_cpuid(env, 0xC0000000, 0, &limit, &unused, &unused, &unused);",
"for (i = 0xC0000000; i <= limit; i++) {",
"if (cpuid_i == KVM_MAX_CPUID_ENTRIES) {",
"fprintf(stderr, \"unsupported xlevel2 value: 0x%x\\n\", limit);",
"abort();",
"}",
"VAR_2 = &VAR_1.entries[cpuid_i++];",
"VAR_2->function = i;",
"VAR_2->flags = 0;",
"cpu_x86_cpuid(env, i, 0, &VAR_2->eax, &VAR_2->ebx, &VAR_2->ecx, &VAR_2->edx);",
"}",
"}",
"VAR_1.cpuid.nent = cpuid_i;",
"if (((env->cpuid_version >> 8)&0xF) >= 6\n&& (env->features[FEAT_1_EDX] & (CPUID_MCE | CPUID_MCA)) ==\n(CPUID_MCE | CPUID_MCA)\n&& kvm_check_extension(VAR_0->kvm_state, KVM_CAP_MCE) > 0) {",
"uint64_t mcg_cap;",
"int VAR_4;",
"int VAR_5;",
"VAR_5 = kvm_get_mce_cap_supported(VAR_0->kvm_state, &mcg_cap, &VAR_4);",
"if (VAR_5 < 0) {",
"fprintf(stderr, \"kvm_get_mce_cap_supported: %s\", strerror(-VAR_5));",
"return VAR_5;",
"}",
"if (VAR_4 > MCE_BANKS_DEF) {",
"VAR_4 = MCE_BANKS_DEF;",
"}",
"mcg_cap &= MCE_CAP_DEF;",
"mcg_cap |= VAR_4;",
"VAR_5 = kvm_vcpu_ioctl(VAR_0, KVM_X86_SETUP_MCE, &mcg_cap);",
"if (VAR_5 < 0) {",
"fprintf(stderr, \"KVM_X86_SETUP_MCE: %s\", strerror(-VAR_5));",
"return VAR_5;",
"}",
"env->mcg_cap = mcg_cap;",
"}",
"qemu_add_vm_change_state_handler(cpu_update_state, env);",
"VAR_2 = cpuid_find_entry(&VAR_1.cpuid, 1, 0);",
"if (VAR_2) {",
"has_msr_feature_control = !!(VAR_2->ecx & CPUID_EXT_VMX) ||\n!!(VAR_2->ecx & CPUID_EXT_SMX);",
"}",
"VAR_1.cpuid.padding = 0;",
"VAR_3 = kvm_vcpu_ioctl(VAR_0, KVM_SET_CPUID2, &VAR_1);",
"if (VAR_3) {",
"return VAR_3;",
"}",
"VAR_3 = kvm_check_extension(VAR_0->kvm_state, KVM_CAP_TSC_CONTROL);",
"if (VAR_3 && env->tsc_khz) {",
"VAR_3 = kvm_vcpu_ioctl(VAR_0, KVM_SET_TSC_KHZ, env->tsc_khz);",
"if (VAR_3 < 0) {",
"fprintf(stderr, \"KVM_SET_TSC_KHZ failed\\n\");",
"return VAR_3;",
"}",
"}",
"if (kvm_has_xsave()) {",
"env->kvm_xsave_buf = qemu_memalign(4096, sizeof(struct kvm_xsave));",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
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
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169
],
[
173
],
[
177
],
[
181
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
199
],
[
201
],
[
205
],
[
209
],
[
211,
213
],
[
215
],
[
217
],
[
221
],
[
223
],
[
225,
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247,
249,
251,
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291,
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305,
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
321
],
[
323
],
[
327
],
[
329
],
[
331
],
[
333
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
357
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
375
],
[
377
],
[
379
],
[
381
],
[
387
],
[
389
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
407
],
[
409
],
[
411
],
[
413
],
[
415
],
[
419
],
[
423,
425,
427,
429
],
[
431
],
[
433
],
[
435
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
451
],
[
453
],
[
455
],
[
457
],
[
459
],
[
461
],
[
463
],
[
465
],
[
467
],
[
469
],
[
473
],
[
475
],
[
479
],
[
483
],
[
485
],
[
487,
489
],
[
491
],
[
495
],
[
497
],
[
499
],
[
501
],
[
503
],
[
507
],
[
509
],
[
511
],
[
513
],
[
515
],
[
517
],
[
519
],
[
521
],
[
525
],
[
527
],
[
529
],
[
533
],
[
535
]
] |
27,073 | static QObject *pci_get_dev_dict(PCIDevice *dev, PCIBus *bus, int bus_num)
{
int class;
QObject *obj;
obj = qobject_from_jsonf("{ 'bus': %d, 'slot': %d, 'function': %d," "'class_info': %p, 'id': %p, 'regions': %p,"
" 'qdev_id': %s }",
bus_num,
PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn),
pci_get_dev_class(dev), pci_get_dev_id(dev),
pci_get_regions_list(dev),
dev->qdev.id ? dev->qdev.id : "");
if (dev->config[PCI_INTERRUPT_PIN] != 0) {
QDict *qdict = qobject_to_qdict(obj);
qdict_put(qdict, "irq", qint_from_int(dev->config[PCI_INTERRUPT_LINE]));
}
class = pci_get_word(dev->config + PCI_CLASS_DEVICE);
if (class == PCI_CLASS_BRIDGE_HOST || class == PCI_CLASS_BRIDGE_PCI) {
QDict *qdict;
QObject *pci_bridge;
pci_bridge = qobject_from_jsonf("{ 'bus': "
"{ 'number': %d, 'secondary': %d, 'subordinate': %d }, "
"'io_range': { 'base': %" PRId64 ", 'limit': %" PRId64 "}, "
"'memory_range': { 'base': %" PRId64 ", 'limit': %" PRId64 "}, "
"'prefetchable_range': { 'base': %" PRId64 ", 'limit': %" PRId64 "} }",
dev->config[PCI_PRIMARY_BUS], dev->config[PCI_SECONDARY_BUS],
dev->config[PCI_SUBORDINATE_BUS],
pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_IO),
pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_IO),
pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_MEMORY),
pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_MEMORY),
pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_MEMORY |
PCI_BASE_ADDRESS_MEM_PREFETCH),
pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_MEMORY |
PCI_BASE_ADDRESS_MEM_PREFETCH));
if (dev->config[PCI_SECONDARY_BUS] != 0) {
PCIBus *child_bus = pci_find_bus(bus, dev->config[PCI_SECONDARY_BUS]);
if (child_bus) {
qdict = qobject_to_qdict(pci_bridge);
qdict_put_obj(qdict, "devices",
pci_get_devices_list(child_bus,
dev->config[PCI_SECONDARY_BUS]));
}
}
qdict = qobject_to_qdict(obj);
qdict_put_obj(qdict, "pci_bridge", pci_bridge);
}
return obj;
}
| true | qemu | b5937f297819bec5bf704dda1df9807fc7f0a766 | static QObject *pci_get_dev_dict(PCIDevice *dev, PCIBus *bus, int bus_num)
{
int class;
QObject *obj;
obj = qobject_from_jsonf("{ 'bus': %d, 'slot': %d, 'function': %d," "'class_info': %p, 'id': %p, 'regions': %p,"
" 'qdev_id': %s }",
bus_num,
PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn),
pci_get_dev_class(dev), pci_get_dev_id(dev),
pci_get_regions_list(dev),
dev->qdev.id ? dev->qdev.id : "");
if (dev->config[PCI_INTERRUPT_PIN] != 0) {
QDict *qdict = qobject_to_qdict(obj);
qdict_put(qdict, "irq", qint_from_int(dev->config[PCI_INTERRUPT_LINE]));
}
class = pci_get_word(dev->config + PCI_CLASS_DEVICE);
if (class == PCI_CLASS_BRIDGE_HOST || class == PCI_CLASS_BRIDGE_PCI) {
QDict *qdict;
QObject *pci_bridge;
pci_bridge = qobject_from_jsonf("{ 'bus': "
"{ 'number': %d, 'secondary': %d, 'subordinate': %d }, "
"'io_range': { 'base': %" PRId64 ", 'limit': %" PRId64 "}, "
"'memory_range': { 'base': %" PRId64 ", 'limit': %" PRId64 "}, "
"'prefetchable_range': { 'base': %" PRId64 ", 'limit': %" PRId64 "} }",
dev->config[PCI_PRIMARY_BUS], dev->config[PCI_SECONDARY_BUS],
dev->config[PCI_SUBORDINATE_BUS],
pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_IO),
pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_IO),
pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_MEMORY),
pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_MEMORY),
pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_MEMORY |
PCI_BASE_ADDRESS_MEM_PREFETCH),
pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_MEMORY |
PCI_BASE_ADDRESS_MEM_PREFETCH));
if (dev->config[PCI_SECONDARY_BUS] != 0) {
PCIBus *child_bus = pci_find_bus(bus, dev->config[PCI_SECONDARY_BUS]);
if (child_bus) {
qdict = qobject_to_qdict(pci_bridge);
qdict_put_obj(qdict, "devices",
pci_get_devices_list(child_bus,
dev->config[PCI_SECONDARY_BUS]));
}
}
qdict = qobject_to_qdict(obj);
qdict_put_obj(qdict, "pci_bridge", pci_bridge);
}
return obj;
}
| {
"code": [
" int class;",
" class = pci_get_word(dev->config + PCI_CLASS_DEVICE);",
" if (class == PCI_CLASS_BRIDGE_HOST || class == PCI_CLASS_BRIDGE_PCI) {"
],
"line_no": [
5,
37,
39
]
} | static QObject *FUNC_0(PCIDevice *dev, PCIBus *bus, int bus_num)
{
int VAR_0;
QObject *obj;
obj = qobject_from_jsonf("{ 'bus': %d, 'slot': %d, 'function': %d," "'class_info': %p, 'id': %p, 'regions': %p,"
" 'qdev_id': %s }",
bus_num,
PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn),
pci_get_dev_class(dev), pci_get_dev_id(dev),
pci_get_regions_list(dev),
dev->qdev.id ? dev->qdev.id : "");
if (dev->config[PCI_INTERRUPT_PIN] != 0) {
QDict *qdict = qobject_to_qdict(obj);
qdict_put(qdict, "irq", qint_from_int(dev->config[PCI_INTERRUPT_LINE]));
}
VAR_0 = pci_get_word(dev->config + PCI_CLASS_DEVICE);
if (VAR_0 == PCI_CLASS_BRIDGE_HOST || VAR_0 == PCI_CLASS_BRIDGE_PCI) {
QDict *qdict;
QObject *pci_bridge;
pci_bridge = qobject_from_jsonf("{ 'bus': "
"{ 'number': %d, 'secondary': %d, 'subordinate': %d }, "
"'io_range': { 'base': %" PRId64 ", 'limit': %" PRId64 "}, "
"'memory_range': { 'base': %" PRId64 ", 'limit': %" PRId64 "}, "
"'prefetchable_range': { 'base': %" PRId64 ", 'limit': %" PRId64 "} }",
dev->config[PCI_PRIMARY_BUS], dev->config[PCI_SECONDARY_BUS],
dev->config[PCI_SUBORDINATE_BUS],
pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_IO),
pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_IO),
pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_MEMORY),
pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_MEMORY),
pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_MEMORY |
PCI_BASE_ADDRESS_MEM_PREFETCH),
pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_MEMORY |
PCI_BASE_ADDRESS_MEM_PREFETCH));
if (dev->config[PCI_SECONDARY_BUS] != 0) {
PCIBus *child_bus = pci_find_bus(bus, dev->config[PCI_SECONDARY_BUS]);
if (child_bus) {
qdict = qobject_to_qdict(pci_bridge);
qdict_put_obj(qdict, "devices",
pci_get_devices_list(child_bus,
dev->config[PCI_SECONDARY_BUS]));
}
}
qdict = qobject_to_qdict(obj);
qdict_put_obj(qdict, "pci_bridge", pci_bridge);
}
return obj;
}
| [
"static QObject *FUNC_0(PCIDevice *dev, PCIBus *bus, int bus_num)\n{",
"int VAR_0;",
"QObject *obj;",
"obj = qobject_from_jsonf(\"{ 'bus': %d, 'slot': %d, 'function': %d,\" \"'class_info': %p, 'id': %p, 'regions': %p,\"",
"\" 'qdev_id': %s }\",",
"bus_num,\nPCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn),\npci_get_dev_class(dev), pci_get_dev_id(dev),\npci_get_regions_list(dev),\ndev->qdev.id ? dev->qdev.id : \"\");",
"if (dev->config[PCI_INTERRUPT_PIN] != 0) {",
"QDict *qdict = qobject_to_qdict(obj);",
"qdict_put(qdict, \"irq\", qint_from_int(dev->config[PCI_INTERRUPT_LINE]));",
"}",
"VAR_0 = pci_get_word(dev->config + PCI_CLASS_DEVICE);",
"if (VAR_0 == PCI_CLASS_BRIDGE_HOST || VAR_0 == PCI_CLASS_BRIDGE_PCI) {",
"QDict *qdict;",
"QObject *pci_bridge;",
"pci_bridge = qobject_from_jsonf(\"{ 'bus': \"",
"\"{ 'number': %d, 'secondary': %d, 'subordinate': %d }, \"",
"\"'io_range': { 'base': %\" PRId64 \", 'limit': %\" PRId64 \"}, \"",
"\"'memory_range': { 'base': %\" PRId64 \", 'limit': %\" PRId64 \"}, \"",
"\"'prefetchable_range': { 'base': %\" PRId64 \", 'limit': %\" PRId64 \"} }\",",
"dev->config[PCI_PRIMARY_BUS], dev->config[PCI_SECONDARY_BUS],\ndev->config[PCI_SUBORDINATE_BUS],\npci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_IO),\npci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_IO),\npci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_MEMORY),\npci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_MEMORY),\npci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_MEMORY |\nPCI_BASE_ADDRESS_MEM_PREFETCH),\npci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_MEMORY |\nPCI_BASE_ADDRESS_MEM_PREFETCH));",
"if (dev->config[PCI_SECONDARY_BUS] != 0) {",
"PCIBus *child_bus = pci_find_bus(bus, dev->config[PCI_SECONDARY_BUS]);",
"if (child_bus) {",
"qdict = qobject_to_qdict(pci_bridge);",
"qdict_put_obj(qdict, \"devices\",\npci_get_devices_list(child_bus,\ndev->config[PCI_SECONDARY_BUS]));",
"}",
"}",
"qdict = qobject_to_qdict(obj);",
"qdict_put_obj(qdict, \"pci_bridge\", pci_bridge);",
"}",
"return obj;",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15,
17,
19,
21,
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57,
59,
61,
63,
65,
67,
69,
71,
73,
75
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89,
91,
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
]
] |
27,074 | static int decode_block_progressive(MJpegDecodeContext *s, int16_t *block,
uint8_t *last_nnz, int ac_index,
int16_t *quant_matrix,
int ss, int se, int Al, int *EOBRUN)
{
int code, i, j, level, val, run;
if (*EOBRUN) {
(*EOBRUN)--;
return 0;
}
{
OPEN_READER(re, &s->gb);
for (i = ss; ; i++) {
UPDATE_CACHE(re, &s->gb);
GET_VLC(code, re, &s->gb, s->vlcs[2][ac_index].table, 9, 2);
run = ((unsigned) code) >> 4;
code &= 0xF;
if (code) {
i += run;
if (code > MIN_CACHE_BITS - 16)
UPDATE_CACHE(re, &s->gb);
{
int cache = GET_CACHE(re, &s->gb);
int sign = (~cache) >> 31;
level = (NEG_USR32(sign ^ cache,code) ^ sign) - sign;
}
LAST_SKIP_BITS(re, &s->gb, code);
if (i >= se) {
if (i == se) {
j = s->scantable.permutated[se];
block[j] = level * quant_matrix[j] << Al;
break;
}
av_log(s->avctx, AV_LOG_ERROR, "error count: %d\n", i);
return AVERROR_INVALIDDATA;
}
j = s->scantable.permutated[i];
block[j] = level * quant_matrix[j] << Al;
} else {
if (run == 0xF) {// ZRL - skip 15 coefficients
i += 15;
if (i >= se) {
av_log(s->avctx, AV_LOG_ERROR, "ZRL overflow: %d\n", i);
return AVERROR_INVALIDDATA;
}
} else {
val = (1 << run);
if (run) {
UPDATE_CACHE(re, &s->gb);
val += NEG_USR32(GET_CACHE(re, &s->gb), run);
LAST_SKIP_BITS(re, &s->gb, run);
}
*EOBRUN = val - 1;
break;
}
}
}
CLOSE_READER(re, &s->gb);
}
if (i > *last_nnz)
*last_nnz = i;
return 0;
}
| true | FFmpeg | c9220d5b06536ac359166214b4131a1f15244617 | static int decode_block_progressive(MJpegDecodeContext *s, int16_t *block,
uint8_t *last_nnz, int ac_index,
int16_t *quant_matrix,
int ss, int se, int Al, int *EOBRUN)
{
int code, i, j, level, val, run;
if (*EOBRUN) {
(*EOBRUN)--;
return 0;
}
{
OPEN_READER(re, &s->gb);
for (i = ss; ; i++) {
UPDATE_CACHE(re, &s->gb);
GET_VLC(code, re, &s->gb, s->vlcs[2][ac_index].table, 9, 2);
run = ((unsigned) code) >> 4;
code &= 0xF;
if (code) {
i += run;
if (code > MIN_CACHE_BITS - 16)
UPDATE_CACHE(re, &s->gb);
{
int cache = GET_CACHE(re, &s->gb);
int sign = (~cache) >> 31;
level = (NEG_USR32(sign ^ cache,code) ^ sign) - sign;
}
LAST_SKIP_BITS(re, &s->gb, code);
if (i >= se) {
if (i == se) {
j = s->scantable.permutated[se];
block[j] = level * quant_matrix[j] << Al;
break;
}
av_log(s->avctx, AV_LOG_ERROR, "error count: %d\n", i);
return AVERROR_INVALIDDATA;
}
j = s->scantable.permutated[i];
block[j] = level * quant_matrix[j] << Al;
} else {
if (run == 0xF) {
i += 15;
if (i >= se) {
av_log(s->avctx, AV_LOG_ERROR, "ZRL overflow: %d\n", i);
return AVERROR_INVALIDDATA;
}
} else {
val = (1 << run);
if (run) {
UPDATE_CACHE(re, &s->gb);
val += NEG_USR32(GET_CACHE(re, &s->gb), run);
LAST_SKIP_BITS(re, &s->gb, run);
}
*EOBRUN = val - 1;
break;
}
}
}
CLOSE_READER(re, &s->gb);
}
if (i > *last_nnz)
*last_nnz = i;
return 0;
}
| {
"code": [
" block[j] = level * quant_matrix[j] << Al;",
" block[j] = level * quant_matrix[j] << Al;"
],
"line_no": [
73,
87
]
} | static int FUNC_0(MJpegDecodeContext *VAR_0, int16_t *VAR_1,
uint8_t *VAR_2, int VAR_3,
int16_t *VAR_4,
int VAR_5, int VAR_6, int VAR_7, int *VAR_8)
{
int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14;
if (*VAR_8) {
(*VAR_8)--;
return 0;
}
{
OPEN_READER(re, &VAR_0->gb);
for (VAR_10 = VAR_5; ; VAR_10++) {
UPDATE_CACHE(re, &VAR_0->gb);
GET_VLC(VAR_9, re, &VAR_0->gb, VAR_0->vlcs[2][VAR_3].table, 9, 2);
VAR_14 = ((unsigned) VAR_9) >> 4;
VAR_9 &= 0xF;
if (VAR_9) {
VAR_10 += VAR_14;
if (VAR_9 > MIN_CACHE_BITS - 16)
UPDATE_CACHE(re, &VAR_0->gb);
{
int VAR_15 = GET_CACHE(re, &VAR_0->gb);
int VAR_16 = (~VAR_15) >> 31;
VAR_12 = (NEG_USR32(VAR_16 ^ VAR_15,VAR_9) ^ VAR_16) - VAR_16;
}
LAST_SKIP_BITS(re, &VAR_0->gb, VAR_9);
if (VAR_10 >= VAR_6) {
if (VAR_10 == VAR_6) {
VAR_11 = VAR_0->scantable.permutated[VAR_6];
VAR_1[VAR_11] = VAR_12 * VAR_4[VAR_11] << VAR_7;
break;
}
av_log(VAR_0->avctx, AV_LOG_ERROR, "error count: %d\n", VAR_10);
return AVERROR_INVALIDDATA;
}
VAR_11 = VAR_0->scantable.permutated[VAR_10];
VAR_1[VAR_11] = VAR_12 * VAR_4[VAR_11] << VAR_7;
} else {
if (VAR_14 == 0xF) {
VAR_10 += 15;
if (VAR_10 >= VAR_6) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "ZRL overflow: %d\n", VAR_10);
return AVERROR_INVALIDDATA;
}
} else {
VAR_13 = (1 << VAR_14);
if (VAR_14) {
UPDATE_CACHE(re, &VAR_0->gb);
VAR_13 += NEG_USR32(GET_CACHE(re, &VAR_0->gb), VAR_14);
LAST_SKIP_BITS(re, &VAR_0->gb, VAR_14);
}
*VAR_8 = VAR_13 - 1;
break;
}
}
}
CLOSE_READER(re, &VAR_0->gb);
}
if (VAR_10 > *VAR_2)
*VAR_2 = VAR_10;
return 0;
}
| [
"static int FUNC_0(MJpegDecodeContext *VAR_0, int16_t *VAR_1,\nuint8_t *VAR_2, int VAR_3,\nint16_t *VAR_4,\nint VAR_5, int VAR_6, int VAR_7, int *VAR_8)\n{",
"int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14;",
"if (*VAR_8) {",
"(*VAR_8)--;",
"return 0;",
"}",
"{",
"OPEN_READER(re, &VAR_0->gb);",
"for (VAR_10 = VAR_5; ; VAR_10++) {",
"UPDATE_CACHE(re, &VAR_0->gb);",
"GET_VLC(VAR_9, re, &VAR_0->gb, VAR_0->vlcs[2][VAR_3].table, 9, 2);",
"VAR_14 = ((unsigned) VAR_9) >> 4;",
"VAR_9 &= 0xF;",
"if (VAR_9) {",
"VAR_10 += VAR_14;",
"if (VAR_9 > MIN_CACHE_BITS - 16)\nUPDATE_CACHE(re, &VAR_0->gb);",
"{",
"int VAR_15 = GET_CACHE(re, &VAR_0->gb);",
"int VAR_16 = (~VAR_15) >> 31;",
"VAR_12 = (NEG_USR32(VAR_16 ^ VAR_15,VAR_9) ^ VAR_16) - VAR_16;",
"}",
"LAST_SKIP_BITS(re, &VAR_0->gb, VAR_9);",
"if (VAR_10 >= VAR_6) {",
"if (VAR_10 == VAR_6) {",
"VAR_11 = VAR_0->scantable.permutated[VAR_6];",
"VAR_1[VAR_11] = VAR_12 * VAR_4[VAR_11] << VAR_7;",
"break;",
"}",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"error count: %d\\n\", VAR_10);",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_11 = VAR_0->scantable.permutated[VAR_10];",
"VAR_1[VAR_11] = VAR_12 * VAR_4[VAR_11] << VAR_7;",
"} else {",
"if (VAR_14 == 0xF) {",
"VAR_10 += 15;",
"if (VAR_10 >= VAR_6) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"ZRL overflow: %d\\n\", VAR_10);",
"return AVERROR_INVALIDDATA;",
"}",
"} else {",
"VAR_13 = (1 << VAR_14);",
"if (VAR_14) {",
"UPDATE_CACHE(re, &VAR_0->gb);",
"VAR_13 += NEG_USR32(GET_CACHE(re, &VAR_0->gb), VAR_14);",
"LAST_SKIP_BITS(re, &VAR_0->gb, VAR_14);",
"}",
"*VAR_8 = VAR_13 - 1;",
"break;",
"}",
"}",
"}",
"CLOSE_READER(re, &VAR_0->gb);",
"}",
"if (VAR_10 > *VAR_2)\n*VAR_2 = VAR_10;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
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,
7,
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133,
135
],
[
139
],
[
141
]
] |
27,075 | static void *bsd_vmalloc(size_t size)
{
void *p;
mmap_lock();
/* Use map and mark the pages as used. */
p = mmap(NULL, size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON, -1, 0);
if (h2g_valid(p)) {
/* Allocated region overlaps guest address space.
This may recurse. */
abi_ulong addr = h2g(p);
page_set_flags(addr & TARGET_PAGE_MASK, TARGET_PAGE_ALIGN(addr + size),
PAGE_RESERVED);
}
mmap_unlock();
return p;
}
| true | qemu | b7b5233ad7fdd9985bb6d05b7919f3a20723ff2c | static void *bsd_vmalloc(size_t size)
{
void *p;
mmap_lock();
p = mmap(NULL, size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON, -1, 0);
if (h2g_valid(p)) {
abi_ulong addr = h2g(p);
page_set_flags(addr & TARGET_PAGE_MASK, TARGET_PAGE_ALIGN(addr + size),
PAGE_RESERVED);
}
mmap_unlock();
return p;
}
| {
"code": [
"static void *bsd_vmalloc(size_t size)",
" void *p;",
" mmap_lock();",
" p = mmap(NULL, size, PROT_READ | PROT_WRITE,",
" MAP_PRIVATE | MAP_ANON, -1, 0);",
" if (h2g_valid(p)) {",
" abi_ulong addr = h2g(p);",
" page_set_flags(addr & TARGET_PAGE_MASK, TARGET_PAGE_ALIGN(addr + size),",
" PAGE_RESERVED);",
" mmap_unlock();",
" return p;"
],
"line_no": [
1,
5,
7,
11,
13,
17,
23,
25,
27,
33,
35
]
} | static void *FUNC_0(size_t VAR_0)
{
void *VAR_1;
mmap_lock();
VAR_1 = mmap(NULL, VAR_0, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON, -1, 0);
if (h2g_valid(VAR_1)) {
abi_ulong addr = h2g(VAR_1);
page_set_flags(addr & TARGET_PAGE_MASK, TARGET_PAGE_ALIGN(addr + VAR_0),
PAGE_RESERVED);
}
mmap_unlock();
return VAR_1;
}
| [
"static void *FUNC_0(size_t VAR_0)\n{",
"void *VAR_1;",
"mmap_lock();",
"VAR_1 = mmap(NULL, VAR_0, PROT_READ | PROT_WRITE,\nMAP_PRIVATE | MAP_ANON, -1, 0);",
"if (h2g_valid(VAR_1)) {",
"abi_ulong addr = h2g(VAR_1);",
"page_set_flags(addr & TARGET_PAGE_MASK, TARGET_PAGE_ALIGN(addr + VAR_0),\nPAGE_RESERVED);",
"}",
"mmap_unlock();",
"return VAR_1;",
"}"
] | [
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
17
],
[
23
],
[
25,
27
],
[
29
],
[
33
],
[
35
],
[
37
]
] |
27,076 | void rgb32tobgr24(const uint8_t *src, uint8_t *dst, long src_size)
{
long i;
long num_pixels = src_size >> 2;
for(i=0; i<num_pixels; i++)
{
#ifdef WORDS_BIGENDIAN
/* RGB32 (= A,B,G,R) -> BGR24 (= B,G,R) */
dst[3*i + 0] = src[4*i + 1];
dst[3*i + 1] = src[4*i + 2];
dst[3*i + 2] = src[4*i + 3];
#else
dst[3*i + 0] = src[4*i + 2];
dst[3*i + 1] = src[4*i + 1];
dst[3*i + 2] = src[4*i + 0];
#endif
}
}
| true | FFmpeg | 6e42e6c4b410dbef8b593c2d796a5dad95f89ee4 | void rgb32tobgr24(const uint8_t *src, uint8_t *dst, long src_size)
{
long i;
long num_pixels = src_size >> 2;
for(i=0; i<num_pixels; i++)
{
#ifdef WORDS_BIGENDIAN
dst[3*i + 0] = src[4*i + 1];
dst[3*i + 1] = src[4*i + 2];
dst[3*i + 2] = src[4*i + 3];
#else
dst[3*i + 0] = src[4*i + 2];
dst[3*i + 1] = src[4*i + 1];
dst[3*i + 2] = src[4*i + 0];
#endif
}
}
| {
"code": [
"\tlong i;",
"\tfor(i=0; i<num_pixels; i++)",
"\tfor(i=0; i<num_pixels; i++)",
"\t\t#ifdef WORDS_BIGENDIAN",
"\t\t#else",
"\t\t#endif",
"\tlong i;",
"\tfor(i=0; i<num_pixels; i++)",
"\t\t#ifdef WORDS_BIGENDIAN",
"\t\t#else",
"\t\t#endif",
"\tlong i;",
"\tfor(i=0; i<num_pixels; i++)",
"\tfor(i=0; i<num_pixels; i++)",
"\tlong i;",
"\tfor(i=0; i<num_pixels; i++)",
"\tfor(i=0; i<num_pixels; i++)",
"\tlong i;",
"\tfor(i=0; i<num_pixels; i++)",
"\tlong i;",
"\tfor(i=0; i<num_pixels; i++)",
"\tlong i;",
"\tfor(i=0; i<num_pixels; i++)",
"\tlong i;",
"\tfor(i=0; i<num_pixels; i++)",
"\tlong i;",
"\tlong num_pixels = src_size >> 2;",
"\tfor(i=0; i<num_pixels; i++)",
"\t\t#ifdef WORDS_BIGENDIAN",
"\t\t\tdst[3*i + 0] = src[4*i + 1];",
"\t\t\tdst[3*i + 1] = src[4*i + 2];",
"\t\t\tdst[3*i + 2] = src[4*i + 3];",
"\t\t#else",
"\t\t\tdst[3*i + 0] = src[4*i + 2];",
"\t\t\tdst[3*i + 1] = src[4*i + 1];",
"\t\t\tdst[3*i + 2] = src[4*i + 0];",
"\t\t#endif",
"\tlong i;",
"\t\t#ifdef WORDS_BIGENDIAN",
"\t\t#else",
"\t\t#endif",
"\t\t#ifdef WORDS_BIGENDIAN",
"\t\t#else",
"\t\t#endif",
"\tlong i;",
"\tfor(i=0; i<num_pixels; i++)",
"\tlong i;",
"\tfor(i=0; i<num_pixels; i++)",
"\t\t#ifdef WORDS_BIGENDIAN",
"\t\t#else",
"\t\t#endif",
"\tlong i;",
"\tfor(i=0; i<num_pixels; i++)",
"\tlong i;",
"\tfor(i=0; i<num_pixels; i++)",
"\tlong i;",
"\tfor(i=0; i<num_pixels; i++)"
],
"line_no": [
5,
9,
9,
13,
23,
31,
5,
9,
13,
23,
31,
5,
9,
9,
5,
9,
9,
5,
9,
5,
9,
5,
9,
5,
9,
5,
7,
9,
13,
17,
19,
21,
23,
25,
27,
29,
31,
5,
13,
23,
31,
13,
23,
31,
5,
9,
5,
9,
13,
23,
31,
5,
9,
5,
9,
5,
9
]
} | void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, long VAR_2)
{
long VAR_3;
long VAR_4 = VAR_2 >> 2;
for(VAR_3=0; VAR_3<VAR_4; VAR_3++)
{
#ifdef WORDS_BIGENDIAN
VAR_1[3*VAR_3 + 0] = VAR_0[4*VAR_3 + 1];
VAR_1[3*VAR_3 + 1] = VAR_0[4*VAR_3 + 2];
VAR_1[3*VAR_3 + 2] = VAR_0[4*VAR_3 + 3];
#else
VAR_1[3*VAR_3 + 0] = VAR_0[4*VAR_3 + 2];
VAR_1[3*VAR_3 + 1] = VAR_0[4*VAR_3 + 1];
VAR_1[3*VAR_3 + 2] = VAR_0[4*VAR_3 + 0];
#endif
}
}
| [
"void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, long VAR_2)\n{",
"long VAR_3;",
"long VAR_4 = VAR_2 >> 2;",
"for(VAR_3=0; VAR_3<VAR_4; VAR_3++)",
"{",
"#ifdef WORDS_BIGENDIAN\nVAR_1[3*VAR_3 + 0] = VAR_0[4*VAR_3 + 1];",
"VAR_1[3*VAR_3 + 1] = VAR_0[4*VAR_3 + 2];",
"VAR_1[3*VAR_3 + 2] = VAR_0[4*VAR_3 + 3];",
"#else\nVAR_1[3*VAR_3 + 0] = VAR_0[4*VAR_3 + 2];",
"VAR_1[3*VAR_3 + 1] = VAR_0[4*VAR_3 + 1];",
"VAR_1[3*VAR_3 + 2] = VAR_0[4*VAR_3 + 0];",
"#endif\n}",
"}"
] | [
0,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13,
17
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31,
33
],
[
35
]
] |
27,077 | static int initFilter(int16_t **outFilter, int16_t **filterPos, int *outFilterSize, int xInc,
int srcW, int dstW, int filterAlign, int one, int flags, int cpu_flags,
SwsVector *srcFilter, SwsVector *dstFilter, double param[2], int is_horizontal)
{
int i;
int filterSize;
int filter2Size;
int minFilterSize;
int64_t *filter=NULL;
int64_t *filter2=NULL;
const int64_t fone= 1LL<<54;
int ret= -1;
emms_c(); //FIXME this should not be required but it IS (even for non-MMX versions)
// NOTE: the +3 is for the MMX(+1)/SSE(+3) scaler which reads over the end
FF_ALLOC_OR_GOTO(NULL, *filterPos, (dstW+3)*sizeof(int16_t), fail);
if (FFABS(xInc - 0x10000) <10) { // unscaled
int i;
filterSize= 1;
FF_ALLOCZ_OR_GOTO(NULL, filter, dstW*sizeof(*filter)*filterSize, fail);
for (i=0; i<dstW; i++) {
filter[i*filterSize]= fone;
(*filterPos)[i]=i;
}
} else if (flags&SWS_POINT) { // lame looking point sampling mode
int i;
int xDstInSrc;
filterSize= 1;
FF_ALLOC_OR_GOTO(NULL, filter, dstW*sizeof(*filter)*filterSize, fail);
xDstInSrc= xInc/2 - 0x8000;
for (i=0; i<dstW; i++) {
int xx= (xDstInSrc - ((filterSize-1)<<15) + (1<<15))>>16;
(*filterPos)[i]= xx;
filter[i]= fone;
xDstInSrc+= xInc;
}
} else if ((xInc <= (1<<16) && (flags&SWS_AREA)) || (flags&SWS_FAST_BILINEAR)) { // bilinear upscale
int i;
int xDstInSrc;
filterSize= 2;
FF_ALLOC_OR_GOTO(NULL, filter, dstW*sizeof(*filter)*filterSize, fail);
xDstInSrc= xInc/2 - 0x8000;
for (i=0; i<dstW; i++) {
int xx= (xDstInSrc - ((filterSize-1)<<15) + (1<<15))>>16;
int j;
(*filterPos)[i]= xx;
//bilinear upscale / linear interpolate / area averaging
for (j=0; j<filterSize; j++) {
int64_t coeff= fone - FFABS((xx<<16) - xDstInSrc)*(fone>>16);
if (coeff<0) coeff=0;
filter[i*filterSize + j]= coeff;
xx++;
}
xDstInSrc+= xInc;
}
} else {
int xDstInSrc;
int sizeFactor;
if (flags&SWS_BICUBIC) sizeFactor= 4;
else if (flags&SWS_X) sizeFactor= 8;
else if (flags&SWS_AREA) sizeFactor= 1; //downscale only, for upscale it is bilinear
else if (flags&SWS_GAUSS) sizeFactor= 8; // infinite ;)
else if (flags&SWS_LANCZOS) sizeFactor= param[0] != SWS_PARAM_DEFAULT ? ceil(2*param[0]) : 6;
else if (flags&SWS_SINC) sizeFactor= 20; // infinite ;)
else if (flags&SWS_SPLINE) sizeFactor= 20; // infinite ;)
else if (flags&SWS_BILINEAR) sizeFactor= 2;
else {
sizeFactor= 0; //GCC warning killer
assert(0);
}
if (xInc <= 1<<16) filterSize= 1 + sizeFactor; // upscale
else filterSize= 1 + (sizeFactor*srcW + dstW - 1)/ dstW;
if (filterSize > srcW-2) filterSize=srcW-2;
FF_ALLOC_OR_GOTO(NULL, filter, dstW*sizeof(*filter)*filterSize, fail);
xDstInSrc= xInc - 0x10000;
for (i=0; i<dstW; i++) {
int xx= (xDstInSrc - ((filterSize-2)<<16)) / (1<<17);
int j;
(*filterPos)[i]= xx;
for (j=0; j<filterSize; j++) {
int64_t d= ((int64_t)FFABS((xx<<17) - xDstInSrc))<<13;
double floatd;
int64_t coeff;
if (xInc > 1<<16)
d= d*dstW/srcW;
floatd= d * (1.0/(1<<30));
if (flags & SWS_BICUBIC) {
int64_t B= (param[0] != SWS_PARAM_DEFAULT ? param[0] : 0) * (1<<24);
int64_t C= (param[1] != SWS_PARAM_DEFAULT ? param[1] : 0.6) * (1<<24);
if (d >= 1LL<<31) {
coeff = 0.0;
} else {
int64_t dd = (d * d) >> 30;
int64_t ddd = (dd * d) >> 30;
if (d < 1LL<<30)
coeff = (12*(1<<24)-9*B-6*C)*ddd + (-18*(1<<24)+12*B+6*C)*dd + (6*(1<<24)-2*B)*(1<<30);
else
coeff = (-B-6*C)*ddd + (6*B+30*C)*dd + (-12*B-48*C)*d + (8*B+24*C)*(1<<30);
}
coeff *= fone>>(30+24);
}
/* else if (flags & SWS_X) {
double p= param ? param*0.01 : 0.3;
coeff = d ? sin(d*M_PI)/(d*M_PI) : 1.0;
coeff*= pow(2.0, - p*d*d);
}*/
else if (flags & SWS_X) {
double A= param[0] != SWS_PARAM_DEFAULT ? param[0] : 1.0;
double c;
if (floatd<1.0)
c = cos(floatd*M_PI);
else
c=-1.0;
if (c<0.0) c= -pow(-c, A);
else c= pow( c, A);
coeff= (c*0.5 + 0.5)*fone;
} else if (flags & SWS_AREA) {
int64_t d2= d - (1<<29);
if (d2*xInc < -(1LL<<(29+16))) coeff= 1.0 * (1LL<<(30+16));
else if (d2*xInc < (1LL<<(29+16))) coeff= -d2*xInc + (1LL<<(29+16));
else coeff=0.0;
coeff *= fone>>(30+16);
} else if (flags & SWS_GAUSS) {
double p= param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0;
coeff = (pow(2.0, - p*floatd*floatd))*fone;
} else if (flags & SWS_SINC) {
coeff = (d ? sin(floatd*M_PI)/(floatd*M_PI) : 1.0)*fone;
} else if (flags & SWS_LANCZOS) {
double p= param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0;
coeff = (d ? sin(floatd*M_PI)*sin(floatd*M_PI/p)/(floatd*floatd*M_PI*M_PI/p) : 1.0)*fone;
if (floatd>p) coeff=0;
} else if (flags & SWS_BILINEAR) {
coeff= (1<<30) - d;
if (coeff<0) coeff=0;
coeff *= fone >> 30;
} else if (flags & SWS_SPLINE) {
double p=-2.196152422706632;
coeff = getSplineCoeff(1.0, 0.0, p, -p-1.0, floatd) * fone;
} else {
coeff= 0.0; //GCC warning killer
assert(0);
}
filter[i*filterSize + j]= coeff;
xx++;
}
xDstInSrc+= 2*xInc;
}
}
/* apply src & dst Filter to filter -> filter2
av_free(filter);
*/
assert(filterSize>0);
filter2Size= filterSize;
if (srcFilter) filter2Size+= srcFilter->length - 1;
if (dstFilter) filter2Size+= dstFilter->length - 1;
assert(filter2Size>0);
FF_ALLOCZ_OR_GOTO(NULL, filter2, filter2Size*dstW*sizeof(*filter2), fail);
for (i=0; i<dstW; i++) {
int j, k;
if(srcFilter) {
for (k=0; k<srcFilter->length; k++) {
for (j=0; j<filterSize; j++)
filter2[i*filter2Size + k + j] += srcFilter->coeff[k]*filter[i*filterSize + j];
}
} else {
for (j=0; j<filterSize; j++)
filter2[i*filter2Size + j]= filter[i*filterSize + j];
}
//FIXME dstFilter
(*filterPos)[i]+= (filterSize-1)/2 - (filter2Size-1)/2;
}
av_freep(&filter);
/* try to reduce the filter-size (step1 find size and shift left) */
// Assume it is near normalized (*0.5 or *2.0 is OK but * 0.001 is not).
minFilterSize= 0;
for (i=dstW-1; i>=0; i--) {
int min= filter2Size;
int j;
int64_t cutOff=0.0;
/* get rid of near zero elements on the left by shifting left */
for (j=0; j<filter2Size; j++) {
int k;
cutOff += FFABS(filter2[i*filter2Size]);
if (cutOff > SWS_MAX_REDUCE_CUTOFF*fone) break;
/* preserve monotonicity because the core can't handle the filter otherwise */
if (i<dstW-1 && (*filterPos)[i] >= (*filterPos)[i+1]) break;
// move filter coefficients left
for (k=1; k<filter2Size; k++)
filter2[i*filter2Size + k - 1]= filter2[i*filter2Size + k];
filter2[i*filter2Size + k - 1]= 0;
(*filterPos)[i]++;
}
cutOff=0;
/* count near zeros on the right */
for (j=filter2Size-1; j>0; j--) {
cutOff += FFABS(filter2[i*filter2Size + j]);
if (cutOff > SWS_MAX_REDUCE_CUTOFF*fone) break;
min--;
}
if (min>minFilterSize) minFilterSize= min;
}
if (HAVE_ALTIVEC && cpu_flags & AV_CPU_FLAG_ALTIVEC) {
// we can handle the special case 4,
// so we don't want to go to the full 8
if (minFilterSize < 5)
filterAlign = 4;
// We really don't want to waste our time
// doing useless computation, so fall back on
// the scalar C code for very small filters.
// Vectorizing is worth it only if you have a
// decent-sized vector.
if (minFilterSize < 3)
filterAlign = 1;
}
if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) {
// special case for unscaled vertical filtering
if (minFilterSize == 1 && filterAlign == 2)
filterAlign= 1;
}
assert(minFilterSize > 0);
filterSize= (minFilterSize +(filterAlign-1)) & (~(filterAlign-1));
assert(filterSize > 0);
filter= av_malloc(filterSize*dstW*sizeof(*filter));
if (filterSize >= MAX_FILTER_SIZE*16/((flags&SWS_ACCURATE_RND) ? APCK_SIZE : 16) || !filter)
goto fail;
*outFilterSize= filterSize;
if (flags&SWS_PRINT_INFO)
av_log(NULL, AV_LOG_VERBOSE, "SwScaler: reducing / aligning filtersize %d -> %d\n", filter2Size, filterSize);
/* try to reduce the filter-size (step2 reduce it) */
for (i=0; i<dstW; i++) {
int j;
for (j=0; j<filterSize; j++) {
if (j>=filter2Size) filter[i*filterSize + j]= 0;
else filter[i*filterSize + j]= filter2[i*filter2Size + j];
if((flags & SWS_BITEXACT) && j>=minFilterSize)
filter[i*filterSize + j]= 0;
}
}
//FIXME try to align filterPos if possible
//fix borders
if (is_horizontal) {
for (i = 0; i < dstW; i++) {
int j;
if ((*filterPos)[i] < 0) {
// move filter coefficients left to compensate for filterPos
for (j = 1; j < filterSize; j++) {
int left = FFMAX(j + (*filterPos)[i], 0);
filter[i * filterSize + left] += filter[i * filterSize + j];
filter[i * filterSize + j ] = 0;
}
(*filterPos)[i] = 0;
}
if ((*filterPos)[i] + filterSize > srcW) {
int shift = (*filterPos)[i] + filterSize - srcW;
// move filter coefficients right to compensate for filterPos
for (j = filterSize - 2; j >= 0; j--) {
int right = FFMIN(j + shift, filterSize - 1);
filter[i * filterSize + right] += filter[i * filterSize + j];
filter[i * filterSize + j ] = 0;
}
(*filterPos)[i] = srcW - filterSize;
}
}
}
// Note the +1 is for the MMX scaler which reads over the end
/* align at 16 for AltiVec (needed by hScale_altivec_real) */
FF_ALLOCZ_OR_GOTO(NULL, *outFilter, *outFilterSize*(dstW+3)*sizeof(int16_t), fail);
/* normalize & store in outFilter */
for (i=0; i<dstW; i++) {
int j;
int64_t error=0;
int64_t sum=0;
for (j=0; j<filterSize; j++) {
sum+= filter[i*filterSize + j];
}
sum= (sum + one/2)/ one;
for (j=0; j<*outFilterSize; j++) {
int64_t v= filter[i*filterSize + j] + error;
int intV= ROUNDED_DIV(v, sum);
(*outFilter)[i*(*outFilterSize) + j]= intV;
error= v - intV*sum;
}
}
(*filterPos)[dstW+0] =
(*filterPos)[dstW+1] =
(*filterPos)[dstW+2] = (*filterPos)[dstW-1]; // the MMX/SSE scaler will read over the end
for (i=0; i<*outFilterSize; i++) {
int k= (dstW - 1) * (*outFilterSize) + i;
(*outFilter)[k + 1 * (*outFilterSize)] =
(*outFilter)[k + 2 * (*outFilterSize)] =
(*outFilter)[k + 3 * (*outFilterSize)] = (*outFilter)[k];
}
ret=0;
fail:
av_free(filter);
av_free(filter2);
return ret;
}
| true | FFmpeg | dae2ce361a2b5fd9be1d43e5e8c00bdbc5f03e3d | static int initFilter(int16_t **outFilter, int16_t **filterPos, int *outFilterSize, int xInc,
int srcW, int dstW, int filterAlign, int one, int flags, int cpu_flags,
SwsVector *srcFilter, SwsVector *dstFilter, double param[2], int is_horizontal)
{
int i;
int filterSize;
int filter2Size;
int minFilterSize;
int64_t *filter=NULL;
int64_t *filter2=NULL;
const int64_t fone= 1LL<<54;
int ret= -1;
emms_c();
FF_ALLOC_OR_GOTO(NULL, *filterPos, (dstW+3)*sizeof(int16_t), fail);
if (FFABS(xInc - 0x10000) <10) {
int i;
filterSize= 1;
FF_ALLOCZ_OR_GOTO(NULL, filter, dstW*sizeof(*filter)*filterSize, fail);
for (i=0; i<dstW; i++) {
filter[i*filterSize]= fone;
(*filterPos)[i]=i;
}
} else if (flags&SWS_POINT) {
int i;
int xDstInSrc;
filterSize= 1;
FF_ALLOC_OR_GOTO(NULL, filter, dstW*sizeof(*filter)*filterSize, fail);
xDstInSrc= xInc/2 - 0x8000;
for (i=0; i<dstW; i++) {
int xx= (xDstInSrc - ((filterSize-1)<<15) + (1<<15))>>16;
(*filterPos)[i]= xx;
filter[i]= fone;
xDstInSrc+= xInc;
}
} else if ((xInc <= (1<<16) && (flags&SWS_AREA)) || (flags&SWS_FAST_BILINEAR)) {
int i;
int xDstInSrc;
filterSize= 2;
FF_ALLOC_OR_GOTO(NULL, filter, dstW*sizeof(*filter)*filterSize, fail);
xDstInSrc= xInc/2 - 0x8000;
for (i=0; i<dstW; i++) {
int xx= (xDstInSrc - ((filterSize-1)<<15) + (1<<15))>>16;
int j;
(*filterPos)[i]= xx;
for (j=0; j<filterSize; j++) {
int64_t coeff= fone - FFABS((xx<<16) - xDstInSrc)*(fone>>16);
if (coeff<0) coeff=0;
filter[i*filterSize + j]= coeff;
xx++;
}
xDstInSrc+= xInc;
}
} else {
int xDstInSrc;
int sizeFactor;
if (flags&SWS_BICUBIC) sizeFactor= 4;
else if (flags&SWS_X) sizeFactor= 8;
else if (flags&SWS_AREA) sizeFactor= 1;
else if (flags&SWS_GAUSS) sizeFactor= 8;
else if (flags&SWS_LANCZOS) sizeFactor= param[0] != SWS_PARAM_DEFAULT ? ceil(2*param[0]) : 6;
else if (flags&SWS_SINC) sizeFactor= 20;
else if (flags&SWS_SPLINE) sizeFactor= 20;
else if (flags&SWS_BILINEAR) sizeFactor= 2;
else {
sizeFactor= 0;
assert(0);
}
if (xInc <= 1<<16) filterSize= 1 + sizeFactor;
else filterSize= 1 + (sizeFactor*srcW + dstW - 1)/ dstW;
if (filterSize > srcW-2) filterSize=srcW-2;
FF_ALLOC_OR_GOTO(NULL, filter, dstW*sizeof(*filter)*filterSize, fail);
xDstInSrc= xInc - 0x10000;
for (i=0; i<dstW; i++) {
int xx= (xDstInSrc - ((filterSize-2)<<16)) / (1<<17);
int j;
(*filterPos)[i]= xx;
for (j=0; j<filterSize; j++) {
int64_t d= ((int64_t)FFABS((xx<<17) - xDstInSrc))<<13;
double floatd;
int64_t coeff;
if (xInc > 1<<16)
d= d*dstW/srcW;
floatd= d * (1.0/(1<<30));
if (flags & SWS_BICUBIC) {
int64_t B= (param[0] != SWS_PARAM_DEFAULT ? param[0] : 0) * (1<<24);
int64_t C= (param[1] != SWS_PARAM_DEFAULT ? param[1] : 0.6) * (1<<24);
if (d >= 1LL<<31) {
coeff = 0.0;
} else {
int64_t dd = (d * d) >> 30;
int64_t ddd = (dd * d) >> 30;
if (d < 1LL<<30)
coeff = (12*(1<<24)-9*B-6*C)*ddd + (-18*(1<<24)+12*B+6*C)*dd + (6*(1<<24)-2*B)*(1<<30);
else
coeff = (-B-6*C)*ddd + (6*B+30*C)*dd + (-12*B-48*C)*d + (8*B+24*C)*(1<<30);
}
coeff *= fone>>(30+24);
}
else if (flags & SWS_X) {
double A= param[0] != SWS_PARAM_DEFAULT ? param[0] : 1.0;
double c;
if (floatd<1.0)
c = cos(floatd*M_PI);
else
c=-1.0;
if (c<0.0) c= -pow(-c, A);
else c= pow( c, A);
coeff= (c*0.5 + 0.5)*fone;
} else if (flags & SWS_AREA) {
int64_t d2= d - (1<<29);
if (d2*xInc < -(1LL<<(29+16))) coeff= 1.0 * (1LL<<(30+16));
else if (d2*xInc < (1LL<<(29+16))) coeff= -d2*xInc + (1LL<<(29+16));
else coeff=0.0;
coeff *= fone>>(30+16);
} else if (flags & SWS_GAUSS) {
double p= param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0;
coeff = (pow(2.0, - p*floatd*floatd))*fone;
} else if (flags & SWS_SINC) {
coeff = (d ? sin(floatd*M_PI)/(floatd*M_PI) : 1.0)*fone;
} else if (flags & SWS_LANCZOS) {
double p= param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0;
coeff = (d ? sin(floatd*M_PI)*sin(floatd*M_PI/p)/(floatd*floatd*M_PI*M_PI/p) : 1.0)*fone;
if (floatd>p) coeff=0;
} else if (flags & SWS_BILINEAR) {
coeff= (1<<30) - d;
if (coeff<0) coeff=0;
coeff *= fone >> 30;
} else if (flags & SWS_SPLINE) {
double p=-2.196152422706632;
coeff = getSplineCoeff(1.0, 0.0, p, -p-1.0, floatd) * fone;
} else {
coeff= 0.0;
assert(0);
}
filter[i*filterSize + j]= coeff;
xx++;
}
xDstInSrc+= 2*xInc;
}
}
assert(filterSize>0);
filter2Size= filterSize;
if (srcFilter) filter2Size+= srcFilter->length - 1;
if (dstFilter) filter2Size+= dstFilter->length - 1;
assert(filter2Size>0);
FF_ALLOCZ_OR_GOTO(NULL, filter2, filter2Size*dstW*sizeof(*filter2), fail);
for (i=0; i<dstW; i++) {
int j, k;
if(srcFilter) {
for (k=0; k<srcFilter->length; k++) {
for (j=0; j<filterSize; j++)
filter2[i*filter2Size + k + j] += srcFilter->coeff[k]*filter[i*filterSize + j];
}
} else {
for (j=0; j<filterSize; j++)
filter2[i*filter2Size + j]= filter[i*filterSize + j];
}
(*filterPos)[i]+= (filterSize-1)/2 - (filter2Size-1)/2;
}
av_freep(&filter);
minFilterSize= 0;
for (i=dstW-1; i>=0; i--) {
int min= filter2Size;
int j;
int64_t cutOff=0.0;
for (j=0; j<filter2Size; j++) {
int k;
cutOff += FFABS(filter2[i*filter2Size]);
if (cutOff > SWS_MAX_REDUCE_CUTOFF*fone) break;
if (i<dstW-1 && (*filterPos)[i] >= (*filterPos)[i+1]) break;
for (k=1; k<filter2Size; k++)
filter2[i*filter2Size + k - 1]= filter2[i*filter2Size + k];
filter2[i*filter2Size + k - 1]= 0;
(*filterPos)[i]++;
}
cutOff=0;
for (j=filter2Size-1; j>0; j--) {
cutOff += FFABS(filter2[i*filter2Size + j]);
if (cutOff > SWS_MAX_REDUCE_CUTOFF*fone) break;
min--;
}
if (min>minFilterSize) minFilterSize= min;
}
if (HAVE_ALTIVEC && cpu_flags & AV_CPU_FLAG_ALTIVEC) {
if (minFilterSize < 5)
filterAlign = 4;
if (minFilterSize < 3)
filterAlign = 1;
}
if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) {
if (minFilterSize == 1 && filterAlign == 2)
filterAlign= 1;
}
assert(minFilterSize > 0);
filterSize= (minFilterSize +(filterAlign-1)) & (~(filterAlign-1));
assert(filterSize > 0);
filter= av_malloc(filterSize*dstW*sizeof(*filter));
if (filterSize >= MAX_FILTER_SIZE*16/((flags&SWS_ACCURATE_RND) ? APCK_SIZE : 16) || !filter)
goto fail;
*outFilterSize= filterSize;
if (flags&SWS_PRINT_INFO)
av_log(NULL, AV_LOG_VERBOSE, "SwScaler: reducing / aligning filtersize %d -> %d\n", filter2Size, filterSize);
for (i=0; i<dstW; i++) {
int j;
for (j=0; j<filterSize; j++) {
if (j>=filter2Size) filter[i*filterSize + j]= 0;
else filter[i*filterSize + j]= filter2[i*filter2Size + j];
if((flags & SWS_BITEXACT) && j>=minFilterSize)
filter[i*filterSize + j]= 0;
}
}
if (is_horizontal) {
for (i = 0; i < dstW; i++) {
int j;
if ((*filterPos)[i] < 0) {
to compensate for filterPos
for (j = 1; j < filterSize; j++) {
int left = FFMAX(j + (*filterPos)[i], 0);
filter[i * filterSize + left] += filter[i * filterSize + j];
filter[i * filterSize + j ] = 0;
}
(*filterPos)[i] = 0;
}
if ((*filterPos)[i] + filterSize > srcW) {
int shift = (*filterPos)[i] + filterSize - srcW;
for (j = filterSize - 2; j >= 0; j--) {
int right = FFMIN(j + shift, filterSize - 1);
filter[i * filterSize + right] += filter[i * filterSize + j];
filter[i * filterSize + j ] = 0;
}
(*filterPos)[i] = srcW - filterSize;
}
}
}
FF_ALLOCZ_OR_GOTO(NULL, *outFilter, *outFilterSize*(dstW+3)*sizeof(int16_t), fail);
for (i=0; i<dstW; i++) {
int j;
int64_t error=0;
int64_t sum=0;
for (j=0; j<filterSize; j++) {
sum+= filter[i*filterSize + j];
}
sum= (sum + one/2)/ one;
for (j=0; j<*outFilterSize; j++) {
int64_t v= filter[i*filterSize + j] + error;
int intV= ROUNDED_DIV(v, sum);
(*outFilter)[i*(*outFilterSize) + j]= intV;
error= v - intV*sum;
}
}
(*filterPos)[dstW+0] =
(*filterPos)[dstW+1] =
(*filterPos)[dstW+2] = (*filterPos)[dstW-1];
for (i=0; i<*outFilterSize; i++) {
int k= (dstW - 1) * (*outFilterSize) + i;
(*outFilter)[k + 1 * (*outFilterSize)] =
(*outFilter)[k + 2 * (*outFilterSize)] =
(*outFilter)[k + 3 * (*outFilterSize)] = (*outFilter)[k];
}
ret=0;
fail:
av_free(filter);
av_free(filter2);
return ret;
}
| {
"code": [
" if (filterSize > srcW-2) filterSize=srcW-2;"
],
"line_no": [
167
]
} | static int FUNC_0(int16_t **VAR_0, int16_t **VAR_1, int *VAR_2, int VAR_3,
int VAR_4, int VAR_5, int VAR_6, int VAR_7, int VAR_8, int VAR_9,
SwsVector *VAR_10, SwsVector *VAR_11, double VAR_12[2], int VAR_13)
{
int VAR_22;
int VAR_15;
int VAR_16;
int VAR_17;
int64_t *filter=NULL;
int64_t *filter2=NULL;
const int64_t VAR_18= 1LL<<54;
int VAR_19= -1;
emms_c();
FF_ALLOC_OR_GOTO(NULL, *VAR_1, (VAR_5+3)*sizeof(int16_t), fail);
if (FFABS(VAR_3 - 0x10000) <10) {
int VAR_22;
VAR_15= 1;
FF_ALLOCZ_OR_GOTO(NULL, filter, VAR_5*sizeof(*filter)*VAR_15, fail);
for (VAR_22=0; VAR_22<VAR_5; VAR_22++) {
filter[VAR_22*VAR_15]= VAR_18;
(*VAR_1)[VAR_22]=VAR_22;
}
} else if (VAR_8&SWS_POINT) {
int VAR_22;
int VAR_23;
VAR_15= 1;
FF_ALLOC_OR_GOTO(NULL, filter, VAR_5*sizeof(*filter)*VAR_15, fail);
VAR_23= VAR_3/2 - 0x8000;
for (VAR_22=0; VAR_22<VAR_5; VAR_22++) {
int VAR_24= (VAR_23 - ((VAR_15-1)<<15) + (1<<15))>>16;
(*VAR_1)[VAR_22]= VAR_24;
filter[VAR_22]= VAR_18;
VAR_23+= VAR_3;
}
} else if ((VAR_3 <= (1<<16) && (VAR_8&SWS_AREA)) || (VAR_8&SWS_FAST_BILINEAR)) {
int VAR_22;
int VAR_23;
VAR_15= 2;
FF_ALLOC_OR_GOTO(NULL, filter, VAR_5*sizeof(*filter)*VAR_15, fail);
VAR_23= VAR_3/2 - 0x8000;
for (VAR_22=0; VAR_22<VAR_5; VAR_22++) {
int VAR_24= (VAR_23 - ((VAR_15-1)<<15) + (1<<15))>>16;
int VAR_32;
(*VAR_1)[VAR_22]= VAR_24;
for (VAR_32=0; VAR_32<VAR_15; VAR_32++) {
int64_t coeff= VAR_18 - FFABS((VAR_24<<16) - VAR_23)*(VAR_18>>16);
if (coeff<0) coeff=0;
filter[VAR_22*VAR_15 + VAR_32]= coeff;
VAR_24++;
}
VAR_23+= VAR_3;
}
} else {
int VAR_23;
int VAR_23;
if (VAR_8&SWS_BICUBIC) VAR_23= 4;
else if (VAR_8&SWS_X) VAR_23= 8;
else if (VAR_8&SWS_AREA) VAR_23= 1;
else if (VAR_8&SWS_GAUSS) VAR_23= 8;
else if (VAR_8&SWS_LANCZOS) VAR_23= VAR_12[0] != SWS_PARAM_DEFAULT ? ceil(2*VAR_12[0]) : 6;
else if (VAR_8&SWS_SINC) VAR_23= 20;
else if (VAR_8&SWS_SPLINE) VAR_23= 20;
else if (VAR_8&SWS_BILINEAR) VAR_23= 2;
else {
VAR_23= 0;
assert(0);
}
if (VAR_3 <= 1<<16) VAR_15= 1 + VAR_23;
else VAR_15= 1 + (VAR_23*VAR_4 + VAR_5 - 1)/ VAR_5;
if (VAR_15 > VAR_4-2) VAR_15=VAR_4-2;
FF_ALLOC_OR_GOTO(NULL, filter, VAR_5*sizeof(*filter)*VAR_15, fail);
VAR_23= VAR_3 - 0x10000;
for (VAR_22=0; VAR_22<VAR_5; VAR_22++) {
int VAR_24= (VAR_23 - ((VAR_15-2)<<16)) / (1<<17);
int VAR_32;
(*VAR_1)[VAR_22]= VAR_24;
for (VAR_32=0; VAR_32<VAR_15; VAR_32++) {
int64_t d= ((int64_t)FFABS((VAR_24<<17) - VAR_23))<<13;
double VAR_24;
int64_t coeff;
if (VAR_3 > 1<<16)
d= d*VAR_5/VAR_4;
VAR_24= d * (1.0/(1<<30));
if (VAR_8 & SWS_BICUBIC) {
int64_t B= (VAR_12[0] != SWS_PARAM_DEFAULT ? VAR_12[0] : 0) * (1<<24);
int64_t C= (VAR_12[1] != SWS_PARAM_DEFAULT ? VAR_12[1] : 0.6) * (1<<24);
if (d >= 1LL<<31) {
coeff = 0.0;
} else {
int64_t dd = (d * d) >> 30;
int64_t ddd = (dd * d) >> 30;
if (d < 1LL<<30)
coeff = (12*(1<<24)-9*B-6*C)*ddd + (-18*(1<<24)+12*B+6*C)*dd + (6*(1<<24)-2*B)*(1<<30);
else
coeff = (-B-6*C)*ddd + (6*B+30*C)*dd + (-12*B-48*C)*d + (8*B+24*C)*(1<<30);
}
coeff *= VAR_18>>(30+24);
}
else if (VAR_8 & SWS_X) {
double VAR_25= VAR_12[0] != SWS_PARAM_DEFAULT ? VAR_12[0] : 1.0;
double VAR_26;
if (VAR_24<1.0)
VAR_26 = cos(VAR_24*M_PI);
else
VAR_26=-1.0;
if (VAR_26<0.0) VAR_26= -pow(-VAR_26, VAR_25);
else VAR_26= pow( VAR_26, VAR_25);
coeff= (VAR_26*0.5 + 0.5)*VAR_18;
} else if (VAR_8 & SWS_AREA) {
int64_t d2= d - (1<<29);
if (d2*VAR_3 < -(1LL<<(29+16))) coeff= 1.0 * (1LL<<(30+16));
else if (d2*VAR_3 < (1LL<<(29+16))) coeff= -d2*VAR_3 + (1LL<<(29+16));
else coeff=0.0;
coeff *= VAR_18>>(30+16);
} else if (VAR_8 & SWS_GAUSS) {
double VAR_28= VAR_12[0] != SWS_PARAM_DEFAULT ? VAR_12[0] : 3.0;
coeff = (pow(2.0, - VAR_28*VAR_24*VAR_24))*VAR_18;
} else if (VAR_8 & SWS_SINC) {
coeff = (d ? sin(VAR_24*M_PI)/(VAR_24*M_PI) : 1.0)*VAR_18;
} else if (VAR_8 & SWS_LANCZOS) {
double VAR_28= VAR_12[0] != SWS_PARAM_DEFAULT ? VAR_12[0] : 3.0;
coeff = (d ? sin(VAR_24*M_PI)*sin(VAR_24*M_PI/VAR_28)/(VAR_24*VAR_24*M_PI*M_PI/VAR_28) : 1.0)*VAR_18;
if (VAR_24>VAR_28) coeff=0;
} else if (VAR_8 & SWS_BILINEAR) {
coeff= (1<<30) - d;
if (coeff<0) coeff=0;
coeff *= VAR_18 >> 30;
} else if (VAR_8 & SWS_SPLINE) {
double VAR_28=-2.196152422706632;
coeff = getSplineCoeff(1.0, 0.0, VAR_28, -VAR_28-1.0, VAR_24) * VAR_18;
} else {
coeff= 0.0;
assert(0);
}
filter[VAR_22*VAR_15 + VAR_32]= coeff;
VAR_24++;
}
VAR_23+= 2*VAR_3;
}
}
assert(VAR_15>0);
VAR_16= VAR_15;
if (VAR_10) VAR_16+= VAR_10->length - 1;
if (VAR_11) VAR_16+= VAR_11->length - 1;
assert(VAR_16>0);
FF_ALLOCZ_OR_GOTO(NULL, filter2, VAR_16*VAR_5*sizeof(*filter2), fail);
for (VAR_22=0; VAR_22<VAR_5; VAR_22++) {
int VAR_32, VAR_33;
if(VAR_10) {
for (VAR_33=0; VAR_33<VAR_10->length; VAR_33++) {
for (VAR_32=0; VAR_32<VAR_15; VAR_32++)
filter2[VAR_22*VAR_16 + VAR_33 + VAR_32] += VAR_10->coeff[VAR_33]*filter[VAR_22*VAR_15 + VAR_32];
}
} else {
for (VAR_32=0; VAR_32<VAR_15; VAR_32++)
filter2[VAR_22*VAR_16 + VAR_32]= filter[VAR_22*VAR_15 + VAR_32];
}
(*VAR_1)[VAR_22]+= (VAR_15-1)/2 - (VAR_16-1)/2;
}
av_freep(&filter);
VAR_17= 0;
for (VAR_22=VAR_5-1; VAR_22>=0; VAR_22--) {
int VAR_29= VAR_16;
int VAR_32;
int64_t cutOff=0.0;
for (VAR_32=0; VAR_32<VAR_16; VAR_32++) {
int VAR_33;
cutOff += FFABS(filter2[VAR_22*VAR_16]);
if (cutOff > SWS_MAX_REDUCE_CUTOFF*VAR_18) break;
if (VAR_22<VAR_5-1 && (*VAR_1)[VAR_22] >= (*VAR_1)[VAR_22+1]) break;
for (VAR_33=1; VAR_33<VAR_16; VAR_33++)
filter2[VAR_22*VAR_16 + VAR_33 - 1]= filter2[VAR_22*VAR_16 + VAR_33];
filter2[VAR_22*VAR_16 + VAR_33 - 1]= 0;
(*VAR_1)[VAR_22]++;
}
cutOff=0;
for (VAR_32=VAR_16-1; VAR_32>0; VAR_32--) {
cutOff += FFABS(filter2[VAR_22*VAR_16 + VAR_32]);
if (cutOff > SWS_MAX_REDUCE_CUTOFF*VAR_18) break;
VAR_29--;
}
if (VAR_29>VAR_17) VAR_17= VAR_29;
}
if (HAVE_ALTIVEC && VAR_9 & AV_CPU_FLAG_ALTIVEC) {
if (VAR_17 < 5)
VAR_6 = 4;
if (VAR_17 < 3)
VAR_6 = 1;
}
if (HAVE_MMX && VAR_9 & AV_CPU_FLAG_MMX) {
if (VAR_17 == 1 && VAR_6 == 2)
VAR_6= 1;
}
assert(VAR_17 > 0);
VAR_15= (VAR_17 +(VAR_6-1)) & (~(VAR_6-1));
assert(VAR_15 > 0);
filter= av_malloc(VAR_15*VAR_5*sizeof(*filter));
if (VAR_15 >= MAX_FILTER_SIZE*16/((VAR_8&SWS_ACCURATE_RND) ? APCK_SIZE : 16) || !filter)
goto fail;
*VAR_2= VAR_15;
if (VAR_8&SWS_PRINT_INFO)
av_log(NULL, AV_LOG_VERBOSE, "SwScaler: reducing / aligning filtersize %d -> %d\n", VAR_16, VAR_15);
for (VAR_22=0; VAR_22<VAR_5; VAR_22++) {
int VAR_32;
for (VAR_32=0; VAR_32<VAR_15; VAR_32++) {
if (VAR_32>=VAR_16) filter[VAR_22*VAR_15 + VAR_32]= 0;
else filter[VAR_22*VAR_15 + VAR_32]= filter2[VAR_22*VAR_16 + VAR_32];
if((VAR_8 & SWS_BITEXACT) && VAR_32>=VAR_17)
filter[VAR_22*VAR_15 + VAR_32]= 0;
}
}
if (VAR_13) {
for (VAR_22 = 0; VAR_22 < VAR_5; VAR_22++) {
int VAR_32;
if ((*VAR_1)[VAR_22] < 0) {
to compensate for VAR_1
for (VAR_32 = 1; VAR_32 < VAR_15; VAR_32++) {
int left = FFMAX(VAR_32 + (*VAR_1)[VAR_22], 0);
filter[VAR_22 * VAR_15 + left] += filter[VAR_22 * VAR_15 + VAR_32];
filter[VAR_22 * VAR_15 + VAR_32 ] = 0;
}
(*VAR_1)[VAR_22] = 0;
}
if ((*VAR_1)[VAR_22] + VAR_15 > VAR_4) {
int VAR_30 = (*VAR_1)[VAR_22] + VAR_15 - VAR_4;
for (VAR_32 = VAR_15 - 2; VAR_32 >= 0; VAR_32--) {
int VAR_31 = FFMIN(VAR_32 + VAR_30, VAR_15 - 1);
filter[VAR_22 * VAR_15 + VAR_31] += filter[VAR_22 * VAR_15 + VAR_32];
filter[VAR_22 * VAR_15 + VAR_32 ] = 0;
}
(*VAR_1)[VAR_22] = VAR_4 - VAR_15;
}
}
}
FF_ALLOCZ_OR_GOTO(NULL, *VAR_0, *VAR_2*(VAR_5+3)*sizeof(int16_t), fail);
for (VAR_22=0; VAR_22<VAR_5; VAR_22++) {
int VAR_32;
int64_t error=0;
int64_t sum=0;
for (VAR_32=0; VAR_32<VAR_15; VAR_32++) {
sum+= filter[VAR_22*VAR_15 + VAR_32];
}
sum= (sum + VAR_7/2)/ VAR_7;
for (VAR_32=0; VAR_32<*VAR_2; VAR_32++) {
int64_t v= filter[VAR_22*VAR_15 + VAR_32] + error;
int VAR_32= ROUNDED_DIV(v, sum);
(*VAR_0)[VAR_22*(*VAR_2) + VAR_32]= VAR_32;
error= v - VAR_32*sum;
}
}
(*VAR_1)[VAR_5+0] =
(*VAR_1)[VAR_5+1] =
(*VAR_1)[VAR_5+2] = (*VAR_1)[VAR_5-1];
for (VAR_22=0; VAR_22<*VAR_2; VAR_22++) {
int VAR_33= (VAR_5 - 1) * (*VAR_2) + VAR_22;
(*VAR_0)[VAR_33 + 1 * (*VAR_2)] =
(*VAR_0)[VAR_33 + 2 * (*VAR_2)] =
(*VAR_0)[VAR_33 + 3 * (*VAR_2)] = (*VAR_0)[VAR_33];
}
VAR_19=0;
fail:
av_free(filter);
av_free(filter2);
return VAR_19;
}
| [
"static int FUNC_0(int16_t **VAR_0, int16_t **VAR_1, int *VAR_2, int VAR_3,\nint VAR_4, int VAR_5, int VAR_6, int VAR_7, int VAR_8, int VAR_9,\nSwsVector *VAR_10, SwsVector *VAR_11, double VAR_12[2], int VAR_13)\n{",
"int VAR_22;",
"int VAR_15;",
"int VAR_16;",
"int VAR_17;",
"int64_t *filter=NULL;",
"int64_t *filter2=NULL;",
"const int64_t VAR_18= 1LL<<54;",
"int VAR_19= -1;",
"emms_c();",
"FF_ALLOC_OR_GOTO(NULL, *VAR_1, (VAR_5+3)*sizeof(int16_t), fail);",
"if (FFABS(VAR_3 - 0x10000) <10) {",
"int VAR_22;",
"VAR_15= 1;",
"FF_ALLOCZ_OR_GOTO(NULL, filter, VAR_5*sizeof(*filter)*VAR_15, fail);",
"for (VAR_22=0; VAR_22<VAR_5; VAR_22++) {",
"filter[VAR_22*VAR_15]= VAR_18;",
"(*VAR_1)[VAR_22]=VAR_22;",
"}",
"} else if (VAR_8&SWS_POINT) {",
"int VAR_22;",
"int VAR_23;",
"VAR_15= 1;",
"FF_ALLOC_OR_GOTO(NULL, filter, VAR_5*sizeof(*filter)*VAR_15, fail);",
"VAR_23= VAR_3/2 - 0x8000;",
"for (VAR_22=0; VAR_22<VAR_5; VAR_22++) {",
"int VAR_24= (VAR_23 - ((VAR_15-1)<<15) + (1<<15))>>16;",
"(*VAR_1)[VAR_22]= VAR_24;",
"filter[VAR_22]= VAR_18;",
"VAR_23+= VAR_3;",
"}",
"} else if ((VAR_3 <= (1<<16) && (VAR_8&SWS_AREA)) || (VAR_8&SWS_FAST_BILINEAR)) {",
"int VAR_22;",
"int VAR_23;",
"VAR_15= 2;",
"FF_ALLOC_OR_GOTO(NULL, filter, VAR_5*sizeof(*filter)*VAR_15, fail);",
"VAR_23= VAR_3/2 - 0x8000;",
"for (VAR_22=0; VAR_22<VAR_5; VAR_22++) {",
"int VAR_24= (VAR_23 - ((VAR_15-1)<<15) + (1<<15))>>16;",
"int VAR_32;",
"(*VAR_1)[VAR_22]= VAR_24;",
"for (VAR_32=0; VAR_32<VAR_15; VAR_32++) {",
"int64_t coeff= VAR_18 - FFABS((VAR_24<<16) - VAR_23)*(VAR_18>>16);",
"if (coeff<0) coeff=0;",
"filter[VAR_22*VAR_15 + VAR_32]= coeff;",
"VAR_24++;",
"}",
"VAR_23+= VAR_3;",
"}",
"} else {",
"int VAR_23;",
"int VAR_23;",
"if (VAR_8&SWS_BICUBIC) VAR_23= 4;",
"else if (VAR_8&SWS_X) VAR_23= 8;",
"else if (VAR_8&SWS_AREA) VAR_23= 1;",
"else if (VAR_8&SWS_GAUSS) VAR_23= 8;",
"else if (VAR_8&SWS_LANCZOS) VAR_23= VAR_12[0] != SWS_PARAM_DEFAULT ? ceil(2*VAR_12[0]) : 6;",
"else if (VAR_8&SWS_SINC) VAR_23= 20;",
"else if (VAR_8&SWS_SPLINE) VAR_23= 20;",
"else if (VAR_8&SWS_BILINEAR) VAR_23= 2;",
"else {",
"VAR_23= 0;",
"assert(0);",
"}",
"if (VAR_3 <= 1<<16) VAR_15= 1 + VAR_23;",
"else VAR_15= 1 + (VAR_23*VAR_4 + VAR_5 - 1)/ VAR_5;",
"if (VAR_15 > VAR_4-2) VAR_15=VAR_4-2;",
"FF_ALLOC_OR_GOTO(NULL, filter, VAR_5*sizeof(*filter)*VAR_15, fail);",
"VAR_23= VAR_3 - 0x10000;",
"for (VAR_22=0; VAR_22<VAR_5; VAR_22++) {",
"int VAR_24= (VAR_23 - ((VAR_15-2)<<16)) / (1<<17);",
"int VAR_32;",
"(*VAR_1)[VAR_22]= VAR_24;",
"for (VAR_32=0; VAR_32<VAR_15; VAR_32++) {",
"int64_t d= ((int64_t)FFABS((VAR_24<<17) - VAR_23))<<13;",
"double VAR_24;",
"int64_t coeff;",
"if (VAR_3 > 1<<16)\nd= d*VAR_5/VAR_4;",
"VAR_24= d * (1.0/(1<<30));",
"if (VAR_8 & SWS_BICUBIC) {",
"int64_t B= (VAR_12[0] != SWS_PARAM_DEFAULT ? VAR_12[0] : 0) * (1<<24);",
"int64_t C= (VAR_12[1] != SWS_PARAM_DEFAULT ? VAR_12[1] : 0.6) * (1<<24);",
"if (d >= 1LL<<31) {",
"coeff = 0.0;",
"} else {",
"int64_t dd = (d * d) >> 30;",
"int64_t ddd = (dd * d) >> 30;",
"if (d < 1LL<<30)\ncoeff = (12*(1<<24)-9*B-6*C)*ddd + (-18*(1<<24)+12*B+6*C)*dd + (6*(1<<24)-2*B)*(1<<30);",
"else\ncoeff = (-B-6*C)*ddd + (6*B+30*C)*dd + (-12*B-48*C)*d + (8*B+24*C)*(1<<30);",
"}",
"coeff *= VAR_18>>(30+24);",
"}",
"else if (VAR_8 & SWS_X) {",
"double VAR_25= VAR_12[0] != SWS_PARAM_DEFAULT ? VAR_12[0] : 1.0;",
"double VAR_26;",
"if (VAR_24<1.0)\nVAR_26 = cos(VAR_24*M_PI);",
"else\nVAR_26=-1.0;",
"if (VAR_26<0.0) VAR_26= -pow(-VAR_26, VAR_25);",
"else VAR_26= pow( VAR_26, VAR_25);",
"coeff= (VAR_26*0.5 + 0.5)*VAR_18;",
"} else if (VAR_8 & SWS_AREA) {",
"int64_t d2= d - (1<<29);",
"if (d2*VAR_3 < -(1LL<<(29+16))) coeff= 1.0 * (1LL<<(30+16));",
"else if (d2*VAR_3 < (1LL<<(29+16))) coeff= -d2*VAR_3 + (1LL<<(29+16));",
"else coeff=0.0;",
"coeff *= VAR_18>>(30+16);",
"} else if (VAR_8 & SWS_GAUSS) {",
"double VAR_28= VAR_12[0] != SWS_PARAM_DEFAULT ? VAR_12[0] : 3.0;",
"coeff = (pow(2.0, - VAR_28*VAR_24*VAR_24))*VAR_18;",
"} else if (VAR_8 & SWS_SINC) {",
"coeff = (d ? sin(VAR_24*M_PI)/(VAR_24*M_PI) : 1.0)*VAR_18;",
"} else if (VAR_8 & SWS_LANCZOS) {",
"double VAR_28= VAR_12[0] != SWS_PARAM_DEFAULT ? VAR_12[0] : 3.0;",
"coeff = (d ? sin(VAR_24*M_PI)*sin(VAR_24*M_PI/VAR_28)/(VAR_24*VAR_24*M_PI*M_PI/VAR_28) : 1.0)*VAR_18;",
"if (VAR_24>VAR_28) coeff=0;",
"} else if (VAR_8 & SWS_BILINEAR) {",
"coeff= (1<<30) - d;",
"if (coeff<0) coeff=0;",
"coeff *= VAR_18 >> 30;",
"} else if (VAR_8 & SWS_SPLINE) {",
"double VAR_28=-2.196152422706632;",
"coeff = getSplineCoeff(1.0, 0.0, VAR_28, -VAR_28-1.0, VAR_24) * VAR_18;",
"} else {",
"coeff= 0.0;",
"assert(0);",
"}",
"filter[VAR_22*VAR_15 + VAR_32]= coeff;",
"VAR_24++;",
"}",
"VAR_23+= 2*VAR_3;",
"}",
"}",
"assert(VAR_15>0);",
"VAR_16= VAR_15;",
"if (VAR_10) VAR_16+= VAR_10->length - 1;",
"if (VAR_11) VAR_16+= VAR_11->length - 1;",
"assert(VAR_16>0);",
"FF_ALLOCZ_OR_GOTO(NULL, filter2, VAR_16*VAR_5*sizeof(*filter2), fail);",
"for (VAR_22=0; VAR_22<VAR_5; VAR_22++) {",
"int VAR_32, VAR_33;",
"if(VAR_10) {",
"for (VAR_33=0; VAR_33<VAR_10->length; VAR_33++) {",
"for (VAR_32=0; VAR_32<VAR_15; VAR_32++)",
"filter2[VAR_22*VAR_16 + VAR_33 + VAR_32] += VAR_10->coeff[VAR_33]*filter[VAR_22*VAR_15 + VAR_32];",
"}",
"} else {",
"for (VAR_32=0; VAR_32<VAR_15; VAR_32++)",
"filter2[VAR_22*VAR_16 + VAR_32]= filter[VAR_22*VAR_15 + VAR_32];",
"}",
"(*VAR_1)[VAR_22]+= (VAR_15-1)/2 - (VAR_16-1)/2;",
"}",
"av_freep(&filter);",
"VAR_17= 0;",
"for (VAR_22=VAR_5-1; VAR_22>=0; VAR_22--) {",
"int VAR_29= VAR_16;",
"int VAR_32;",
"int64_t cutOff=0.0;",
"for (VAR_32=0; VAR_32<VAR_16; VAR_32++) {",
"int VAR_33;",
"cutOff += FFABS(filter2[VAR_22*VAR_16]);",
"if (cutOff > SWS_MAX_REDUCE_CUTOFF*VAR_18) break;",
"if (VAR_22<VAR_5-1 && (*VAR_1)[VAR_22] >= (*VAR_1)[VAR_22+1]) break;",
"for (VAR_33=1; VAR_33<VAR_16; VAR_33++)",
"filter2[VAR_22*VAR_16 + VAR_33 - 1]= filter2[VAR_22*VAR_16 + VAR_33];",
"filter2[VAR_22*VAR_16 + VAR_33 - 1]= 0;",
"(*VAR_1)[VAR_22]++;",
"}",
"cutOff=0;",
"for (VAR_32=VAR_16-1; VAR_32>0; VAR_32--) {",
"cutOff += FFABS(filter2[VAR_22*VAR_16 + VAR_32]);",
"if (cutOff > SWS_MAX_REDUCE_CUTOFF*VAR_18) break;",
"VAR_29--;",
"}",
"if (VAR_29>VAR_17) VAR_17= VAR_29;",
"}",
"if (HAVE_ALTIVEC && VAR_9 & AV_CPU_FLAG_ALTIVEC) {",
"if (VAR_17 < 5)\nVAR_6 = 4;",
"if (VAR_17 < 3)\nVAR_6 = 1;",
"}",
"if (HAVE_MMX && VAR_9 & AV_CPU_FLAG_MMX) {",
"if (VAR_17 == 1 && VAR_6 == 2)\nVAR_6= 1;",
"}",
"assert(VAR_17 > 0);",
"VAR_15= (VAR_17 +(VAR_6-1)) & (~(VAR_6-1));",
"assert(VAR_15 > 0);",
"filter= av_malloc(VAR_15*VAR_5*sizeof(*filter));",
"if (VAR_15 >= MAX_FILTER_SIZE*16/((VAR_8&SWS_ACCURATE_RND) ? APCK_SIZE : 16) || !filter)\ngoto fail;",
"*VAR_2= VAR_15;",
"if (VAR_8&SWS_PRINT_INFO)\nav_log(NULL, AV_LOG_VERBOSE, \"SwScaler: reducing / aligning filtersize %d -> %d\\n\", VAR_16, VAR_15);",
"for (VAR_22=0; VAR_22<VAR_5; VAR_22++) {",
"int VAR_32;",
"for (VAR_32=0; VAR_32<VAR_15; VAR_32++) {",
"if (VAR_32>=VAR_16) filter[VAR_22*VAR_15 + VAR_32]= 0;",
"else filter[VAR_22*VAR_15 + VAR_32]= filter2[VAR_22*VAR_16 + VAR_32];",
"if((VAR_8 & SWS_BITEXACT) && VAR_32>=VAR_17)\nfilter[VAR_22*VAR_15 + VAR_32]= 0;",
"}",
"}",
"if (VAR_13) {",
"for (VAR_22 = 0; VAR_22 < VAR_5; VAR_22++) {",
"int VAR_32;",
"if ((*VAR_1)[VAR_22] < 0) {",
"to compensate for VAR_1\nfor (VAR_32 = 1; VAR_32 < VAR_15; VAR_32++) {",
"int left = FFMAX(VAR_32 + (*VAR_1)[VAR_22], 0);",
"filter[VAR_22 * VAR_15 + left] += filter[VAR_22 * VAR_15 + VAR_32];",
"filter[VAR_22 * VAR_15 + VAR_32 ] = 0;",
"}",
"(*VAR_1)[VAR_22] = 0;",
"}",
"if ((*VAR_1)[VAR_22] + VAR_15 > VAR_4) {",
"int VAR_30 = (*VAR_1)[VAR_22] + VAR_15 - VAR_4;",
"for (VAR_32 = VAR_15 - 2; VAR_32 >= 0; VAR_32--) {",
"int VAR_31 = FFMIN(VAR_32 + VAR_30, VAR_15 - 1);",
"filter[VAR_22 * VAR_15 + VAR_31] += filter[VAR_22 * VAR_15 + VAR_32];",
"filter[VAR_22 * VAR_15 + VAR_32 ] = 0;",
"}",
"(*VAR_1)[VAR_22] = VAR_4 - VAR_15;",
"}",
"}",
"}",
"FF_ALLOCZ_OR_GOTO(NULL, *VAR_0, *VAR_2*(VAR_5+3)*sizeof(int16_t), fail);",
"for (VAR_22=0; VAR_22<VAR_5; VAR_22++) {",
"int VAR_32;",
"int64_t error=0;",
"int64_t sum=0;",
"for (VAR_32=0; VAR_32<VAR_15; VAR_32++) {",
"sum+= filter[VAR_22*VAR_15 + VAR_32];",
"}",
"sum= (sum + VAR_7/2)/ VAR_7;",
"for (VAR_32=0; VAR_32<*VAR_2; VAR_32++) {",
"int64_t v= filter[VAR_22*VAR_15 + VAR_32] + error;",
"int VAR_32= ROUNDED_DIV(v, sum);",
"(*VAR_0)[VAR_22*(*VAR_2) + VAR_32]= VAR_32;",
"error= v - VAR_32*sum;",
"}",
"}",
"(*VAR_1)[VAR_5+0] =\n(*VAR_1)[VAR_5+1] =\n(*VAR_1)[VAR_5+2] = (*VAR_1)[VAR_5-1];",
"for (VAR_22=0; VAR_22<*VAR_2; VAR_22++) {",
"int VAR_33= (VAR_5 - 1) * (*VAR_2) + VAR_22;",
"(*VAR_0)[VAR_33 + 1 * (*VAR_2)] =\n(*VAR_0)[VAR_33 + 2 * (*VAR_2)] =\n(*VAR_0)[VAR_33 + 3 * (*VAR_2)] = (*VAR_0)[VAR_33];",
"}",
"VAR_19=0;",
"fail:\nav_free(filter);",
"av_free(filter2);",
"return VAR_19;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
161
],
[
163
],
[
167
],
[
171
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195,
197
],
[
199
],
[
203
],
[
205
],
[
207
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
223,
225
],
[
227,
229
],
[
231
],
[
233
],
[
235
],
[
247
],
[
249
],
[
251
],
[
255,
257
],
[
259,
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
357
],
[
359
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
385
],
[
387
],
[
389
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
411
],
[
413
],
[
415
],
[
419
],
[
425
],
[
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
443
],
[
447
],
[
449
],
[
453
],
[
455
],
[
457
],
[
461
],
[
463
],
[
467
],
[
473,
475
],
[
489,
491
],
[
493
],
[
497
],
[
501,
503
],
[
505
],
[
509
],
[
511
],
[
513
],
[
515
],
[
517,
519
],
[
521
],
[
525,
527
],
[
531
],
[
533
],
[
537
],
[
539
],
[
541
],
[
543,
545
],
[
547
],
[
549
],
[
559
],
[
561
],
[
563
],
[
565
],
[
567,
569
],
[
571
],
[
573
],
[
575
],
[
577
],
[
579
],
[
581
],
[
585
],
[
587
],
[
591
],
[
593
],
[
595
],
[
597
],
[
599
],
[
601
],
[
603
],
[
605
],
[
607
],
[
615
],
[
621
],
[
623
],
[
625
],
[
627
],
[
631
],
[
633
],
[
635
],
[
637
],
[
639
],
[
641
],
[
643
],
[
645
],
[
647
],
[
649
],
[
651
],
[
655,
657,
659
],
[
661
],
[
663
],
[
665,
667,
669
],
[
671
],
[
675
],
[
677,
679
],
[
681
],
[
683
],
[
685
]
] |
27,078 | static ssize_t usbnet_receive(VLANClientState *nc, const uint8_t *buf, size_t size)
{
USBNetState *s = DO_UPCAST(NICState, nc, nc)->opaque;
struct rndis_packet_msg_type *msg;
if (is_rndis(s)) {
msg = (struct rndis_packet_msg_type *) s->in_buf;
if (!s->rndis_state == RNDIS_DATA_INITIALIZED)
return -1;
if (size + sizeof(struct rndis_packet_msg_type) > sizeof(s->in_buf))
return -1;
memset(msg, 0, sizeof(struct rndis_packet_msg_type));
msg->MessageType = cpu_to_le32(RNDIS_PACKET_MSG);
msg->MessageLength = cpu_to_le32(size + sizeof(struct rndis_packet_msg_type));
msg->DataOffset = cpu_to_le32(sizeof(struct rndis_packet_msg_type) - 8);
msg->DataLength = cpu_to_le32(size);
/* msg->OOBDataOffset;
* msg->OOBDataLength;
* msg->NumOOBDataElements;
* msg->PerPacketInfoOffset;
* msg->PerPacketInfoLength;
* msg->VcHandle;
* msg->Reserved;
*/
memcpy(msg + 1, buf, size);
s->in_len = size + sizeof(struct rndis_packet_msg_type);
} else {
if (size > sizeof(s->in_buf))
return -1;
memcpy(s->in_buf, buf, size);
s->in_len = size;
}
s->in_ptr = 0;
return size;
}
| true | qemu | e7852674d5013bffd0bb8e822a7521f76677a60b | static ssize_t usbnet_receive(VLANClientState *nc, const uint8_t *buf, size_t size)
{
USBNetState *s = DO_UPCAST(NICState, nc, nc)->opaque;
struct rndis_packet_msg_type *msg;
if (is_rndis(s)) {
msg = (struct rndis_packet_msg_type *) s->in_buf;
if (!s->rndis_state == RNDIS_DATA_INITIALIZED)
return -1;
if (size + sizeof(struct rndis_packet_msg_type) > sizeof(s->in_buf))
return -1;
memset(msg, 0, sizeof(struct rndis_packet_msg_type));
msg->MessageType = cpu_to_le32(RNDIS_PACKET_MSG);
msg->MessageLength = cpu_to_le32(size + sizeof(struct rndis_packet_msg_type));
msg->DataOffset = cpu_to_le32(sizeof(struct rndis_packet_msg_type) - 8);
msg->DataLength = cpu_to_le32(size);
memcpy(msg + 1, buf, size);
s->in_len = size + sizeof(struct rndis_packet_msg_type);
} else {
if (size > sizeof(s->in_buf))
return -1;
memcpy(s->in_buf, buf, size);
s->in_len = size;
}
s->in_ptr = 0;
return size;
}
| {
"code": [
" if (!s->rndis_state == RNDIS_DATA_INITIALIZED)"
],
"line_no": [
15
]
} | static ssize_t FUNC_0(VLANClientState *nc, const uint8_t *buf, size_t size)
{
USBNetState *s = DO_UPCAST(NICState, nc, nc)->opaque;
struct rndis_packet_msg_type *VAR_0;
if (is_rndis(s)) {
VAR_0 = (struct rndis_packet_msg_type *) s->in_buf;
if (!s->rndis_state == RNDIS_DATA_INITIALIZED)
return -1;
if (size + sizeof(struct rndis_packet_msg_type) > sizeof(s->in_buf))
return -1;
memset(VAR_0, 0, sizeof(struct rndis_packet_msg_type));
VAR_0->MessageType = cpu_to_le32(RNDIS_PACKET_MSG);
VAR_0->MessageLength = cpu_to_le32(size + sizeof(struct rndis_packet_msg_type));
VAR_0->DataOffset = cpu_to_le32(sizeof(struct rndis_packet_msg_type) - 8);
VAR_0->DataLength = cpu_to_le32(size);
memcpy(VAR_0 + 1, buf, size);
s->in_len = size + sizeof(struct rndis_packet_msg_type);
} else {
if (size > sizeof(s->in_buf))
return -1;
memcpy(s->in_buf, buf, size);
s->in_len = size;
}
s->in_ptr = 0;
return size;
}
| [
"static ssize_t FUNC_0(VLANClientState *nc, const uint8_t *buf, size_t size)\n{",
"USBNetState *s = DO_UPCAST(NICState, nc, nc)->opaque;",
"struct rndis_packet_msg_type *VAR_0;",
"if (is_rndis(s)) {",
"VAR_0 = (struct rndis_packet_msg_type *) s->in_buf;",
"if (!s->rndis_state == RNDIS_DATA_INITIALIZED)\nreturn -1;",
"if (size + sizeof(struct rndis_packet_msg_type) > sizeof(s->in_buf))\nreturn -1;",
"memset(VAR_0, 0, sizeof(struct rndis_packet_msg_type));",
"VAR_0->MessageType = cpu_to_le32(RNDIS_PACKET_MSG);",
"VAR_0->MessageLength = cpu_to_le32(size + sizeof(struct rndis_packet_msg_type));",
"VAR_0->DataOffset = cpu_to_le32(sizeof(struct rndis_packet_msg_type) - 8);",
"VAR_0->DataLength = cpu_to_le32(size);",
"memcpy(VAR_0 + 1, buf, size);",
"s->in_len = size + sizeof(struct rndis_packet_msg_type);",
"} else {",
"if (size > sizeof(s->in_buf))\nreturn -1;",
"memcpy(s->in_buf, buf, size);",
"s->in_len = size;",
"}",
"s->in_ptr = 0;",
"return size;",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15,
17
],
[
19,
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
]
] |
27,079 | int unix_connect(const char *path)
{
QemuOpts *opts;
int sock;
opts = qemu_opts_create(&dummy_opts, NULL, 0);
qemu_opt_set(opts, "path", path);
sock = unix_connect_opts(opts);
qemu_opts_del(opts);
return sock;
}
| true | qemu | 8be7e7e4c72c048b90e3482557954a24bba43ba7 | int unix_connect(const char *path)
{
QemuOpts *opts;
int sock;
opts = qemu_opts_create(&dummy_opts, NULL, 0);
qemu_opt_set(opts, "path", path);
sock = unix_connect_opts(opts);
qemu_opts_del(opts);
return sock;
}
| {
"code": [
" opts = qemu_opts_create(&dummy_opts, NULL, 0);",
" opts = qemu_opts_create(&dummy_opts, NULL, 0);",
" opts = qemu_opts_create(&dummy_opts, NULL, 0);",
" opts = qemu_opts_create(&dummy_opts, NULL, 0);"
],
"line_no": [
11,
11,
11,
11
]
} | int FUNC_0(const char *VAR_0)
{
QemuOpts *opts;
int VAR_1;
opts = qemu_opts_create(&dummy_opts, NULL, 0);
qemu_opt_set(opts, "VAR_0", VAR_0);
VAR_1 = unix_connect_opts(opts);
qemu_opts_del(opts);
return VAR_1;
}
| [
"int FUNC_0(const char *VAR_0)\n{",
"QemuOpts *opts;",
"int VAR_1;",
"opts = qemu_opts_create(&dummy_opts, NULL, 0);",
"qemu_opt_set(opts, \"VAR_0\", VAR_0);",
"VAR_1 = unix_connect_opts(opts);",
"qemu_opts_del(opts);",
"return VAR_1;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
27,080 | static inline bool regime_translation_disabled(CPUARMState *env,
ARMMMUIdx mmu_idx)
{
if (arm_feature(env, ARM_FEATURE_M)) {
switch (env->v7m.mpu_ctrl[regime_is_secure(env, mmu_idx)] &
(R_V7M_MPU_CTRL_ENABLE_MASK | R_V7M_MPU_CTRL_HFNMIENA_MASK)) {
case R_V7M_MPU_CTRL_ENABLE_MASK:
/* Enabled, but not for HardFault and NMI */
return mmu_idx == ARMMMUIdx_MNegPri ||
mmu_idx == ARMMMUIdx_MSNegPri;
case R_V7M_MPU_CTRL_ENABLE_MASK | R_V7M_MPU_CTRL_HFNMIENA_MASK:
/* Enabled for all cases */
return false;
case 0:
default:
/* HFNMIENA set and ENABLE clear is UNPREDICTABLE, but
* we warned about that in armv7m_nvic.c when the guest set it.
*/
return true;
}
}
if (mmu_idx == ARMMMUIdx_S2NS) {
return (env->cp15.hcr_el2 & HCR_VM) == 0;
}
return (regime_sctlr(env, mmu_idx) & SCTLR_M) == 0;
}
| true | qemu | 62593718d77c06ad2b5e942727cead40775d2395 | static inline bool regime_translation_disabled(CPUARMState *env,
ARMMMUIdx mmu_idx)
{
if (arm_feature(env, ARM_FEATURE_M)) {
switch (env->v7m.mpu_ctrl[regime_is_secure(env, mmu_idx)] &
(R_V7M_MPU_CTRL_ENABLE_MASK | R_V7M_MPU_CTRL_HFNMIENA_MASK)) {
case R_V7M_MPU_CTRL_ENABLE_MASK:
return mmu_idx == ARMMMUIdx_MNegPri ||
mmu_idx == ARMMMUIdx_MSNegPri;
case R_V7M_MPU_CTRL_ENABLE_MASK | R_V7M_MPU_CTRL_HFNMIENA_MASK:
return false;
case 0:
default:
return true;
}
}
if (mmu_idx == ARMMMUIdx_S2NS) {
return (env->cp15.hcr_el2 & HCR_VM) == 0;
}
return (regime_sctlr(env, mmu_idx) & SCTLR_M) == 0;
}
| {
"code": [
" return mmu_idx == ARMMMUIdx_MNegPri ||",
" mmu_idx == ARMMMUIdx_MSNegPri;"
],
"line_no": [
17,
19
]
} | static inline bool FUNC_0(CPUARMState *env,
ARMMMUIdx mmu_idx)
{
if (arm_feature(env, ARM_FEATURE_M)) {
switch (env->v7m.mpu_ctrl[regime_is_secure(env, mmu_idx)] &
(R_V7M_MPU_CTRL_ENABLE_MASK | R_V7M_MPU_CTRL_HFNMIENA_MASK)) {
case R_V7M_MPU_CTRL_ENABLE_MASK:
return mmu_idx == ARMMMUIdx_MNegPri ||
mmu_idx == ARMMMUIdx_MSNegPri;
case R_V7M_MPU_CTRL_ENABLE_MASK | R_V7M_MPU_CTRL_HFNMIENA_MASK:
return false;
case 0:
default:
return true;
}
}
if (mmu_idx == ARMMMUIdx_S2NS) {
return (env->cp15.hcr_el2 & HCR_VM) == 0;
}
return (regime_sctlr(env, mmu_idx) & SCTLR_M) == 0;
}
| [
"static inline bool FUNC_0(CPUARMState *env,\nARMMMUIdx mmu_idx)\n{",
"if (arm_feature(env, ARM_FEATURE_M)) {",
"switch (env->v7m.mpu_ctrl[regime_is_secure(env, mmu_idx)] &\n(R_V7M_MPU_CTRL_ENABLE_MASK | R_V7M_MPU_CTRL_HFNMIENA_MASK)) {",
"case R_V7M_MPU_CTRL_ENABLE_MASK:\nreturn mmu_idx == ARMMMUIdx_MNegPri ||\nmmu_idx == ARMMMUIdx_MSNegPri;",
"case R_V7M_MPU_CTRL_ENABLE_MASK | R_V7M_MPU_CTRL_HFNMIENA_MASK:\nreturn false;",
"case 0:\ndefault:\nreturn true;",
"}",
"}",
"if (mmu_idx == ARMMMUIdx_S2NS) {",
"return (env->cp15.hcr_el2 & HCR_VM) == 0;",
"}",
"return (regime_sctlr(env, mmu_idx) & SCTLR_M) == 0;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9,
11
],
[
13,
17,
19
],
[
21,
25
],
[
27,
29,
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
]
] |
27,082 | static void migration_instance_init(Object *obj)
{
MigrationState *ms = MIGRATION_OBJ(obj);
ms->state = MIGRATION_STATUS_NONE;
ms->xbzrle_cache_size = DEFAULT_MIGRATE_CACHE_SIZE;
ms->mbps = -1;
ms->parameters.tls_creds = g_strdup("");
ms->parameters.tls_hostname = g_strdup("");
}
| false | qemu | 8b0b29dcec59730e6b21b253a6b43271cb3d831b | static void migration_instance_init(Object *obj)
{
MigrationState *ms = MIGRATION_OBJ(obj);
ms->state = MIGRATION_STATUS_NONE;
ms->xbzrle_cache_size = DEFAULT_MIGRATE_CACHE_SIZE;
ms->mbps = -1;
ms->parameters.tls_creds = g_strdup("");
ms->parameters.tls_hostname = g_strdup("");
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Object *VAR_0)
{
MigrationState *ms = MIGRATION_OBJ(VAR_0);
ms->state = MIGRATION_STATUS_NONE;
ms->xbzrle_cache_size = DEFAULT_MIGRATE_CACHE_SIZE;
ms->mbps = -1;
ms->parameters.tls_creds = g_strdup("");
ms->parameters.tls_hostname = g_strdup("");
}
| [
"static void FUNC_0(Object *VAR_0)\n{",
"MigrationState *ms = MIGRATION_OBJ(VAR_0);",
"ms->state = MIGRATION_STATUS_NONE;",
"ms->xbzrle_cache_size = DEFAULT_MIGRATE_CACHE_SIZE;",
"ms->mbps = -1;",
"ms->parameters.tls_creds = g_strdup(\"\");",
"ms->parameters.tls_hostname = g_strdup(\"\");",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
27,084 | static void do_stop_capture(Monitor *mon, const QDict *qdict)
{
int i;
int n = qdict_get_int(qdict, "n");
CaptureState *s;
for (s = capture_head.lh_first, i = 0; s; s = s->entries.le_next, ++i) {
if (i == n) {
s->ops.destroy (s->opaque);
LIST_REMOVE (s, entries);
qemu_free (s);
return;
}
}
}
| false | qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | static void do_stop_capture(Monitor *mon, const QDict *qdict)
{
int i;
int n = qdict_get_int(qdict, "n");
CaptureState *s;
for (s = capture_head.lh_first, i = 0; s; s = s->entries.le_next, ++i) {
if (i == n) {
s->ops.destroy (s->opaque);
LIST_REMOVE (s, entries);
qemu_free (s);
return;
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)
{
int VAR_2;
int VAR_3 = qdict_get_int(VAR_1, "VAR_3");
CaptureState *s;
for (s = capture_head.lh_first, VAR_2 = 0; s; s = s->entries.le_next, ++VAR_2) {
if (VAR_2 == VAR_3) {
s->ops.destroy (s->opaque);
LIST_REMOVE (s, entries);
qemu_free (s);
return;
}
}
}
| [
"static void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)\n{",
"int VAR_2;",
"int VAR_3 = qdict_get_int(VAR_1, \"VAR_3\");",
"CaptureState *s;",
"for (s = capture_head.lh_first, VAR_2 = 0; s; s = s->entries.le_next, ++VAR_2) {",
"if (VAR_2 == VAR_3) {",
"s->ops.destroy (s->opaque);",
"LIST_REMOVE (s, entries);",
"qemu_free (s);",
"return;",
"}",
"}",
"}"
] | [
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
]
] |
27,085 | static void nbd_refresh_filename(BlockDriverState *bs)
{
QDict *opts = qdict_new();
const char *path = qdict_get_try_str(bs->options, "path");
const char *host = qdict_get_try_str(bs->options, "host");
const char *port = qdict_get_try_str(bs->options, "port");
const char *export = qdict_get_try_str(bs->options, "export");
qdict_put_obj(opts, "driver", QOBJECT(qstring_from_str("nbd")));
if (path && export) {
snprintf(bs->exact_filename, sizeof(bs->exact_filename),
"nbd+unix:///%s?socket=%s", export, path);
} else if (path && !export) {
snprintf(bs->exact_filename, sizeof(bs->exact_filename),
"nbd+unix://?socket=%s", path);
} else if (!path && export && port) {
snprintf(bs->exact_filename, sizeof(bs->exact_filename),
"nbd://%s:%s/%s", host, port, export);
} else if (!path && export && !port) {
snprintf(bs->exact_filename, sizeof(bs->exact_filename),
"nbd://%s/%s", host, export);
} else if (!path && !export && port) {
snprintf(bs->exact_filename, sizeof(bs->exact_filename),
"nbd://%s:%s", host, port);
} else if (!path && !export && !port) {
snprintf(bs->exact_filename, sizeof(bs->exact_filename),
"nbd://%s", host);
}
if (path) {
qdict_put_obj(opts, "path", QOBJECT(qstring_from_str(path)));
} else if (port) {
qdict_put_obj(opts, "host", QOBJECT(qstring_from_str(host)));
qdict_put_obj(opts, "port", QOBJECT(qstring_from_str(port)));
} else {
qdict_put_obj(opts, "host", QOBJECT(qstring_from_str(host)));
}
if (export) {
qdict_put_obj(opts, "export", QOBJECT(qstring_from_str(export)));
}
bs->full_open_options = opts;
}
| false | qemu | 4cdd01d32ee6fe04f8d909bfd3708be6864873a2 | static void nbd_refresh_filename(BlockDriverState *bs)
{
QDict *opts = qdict_new();
const char *path = qdict_get_try_str(bs->options, "path");
const char *host = qdict_get_try_str(bs->options, "host");
const char *port = qdict_get_try_str(bs->options, "port");
const char *export = qdict_get_try_str(bs->options, "export");
qdict_put_obj(opts, "driver", QOBJECT(qstring_from_str("nbd")));
if (path && export) {
snprintf(bs->exact_filename, sizeof(bs->exact_filename),
"nbd+unix:
} else if (path && !export) {
snprintf(bs->exact_filename, sizeof(bs->exact_filename),
"nbd+unix:
} else if (!path && export && port) {
snprintf(bs->exact_filename, sizeof(bs->exact_filename),
"nbd:
} else if (!path && export && !port) {
snprintf(bs->exact_filename, sizeof(bs->exact_filename),
"nbd:
} else if (!path && !export && port) {
snprintf(bs->exact_filename, sizeof(bs->exact_filename),
"nbd:
} else if (!path && !export && !port) {
snprintf(bs->exact_filename, sizeof(bs->exact_filename),
"nbd:
}
if (path) {
qdict_put_obj(opts, "path", QOBJECT(qstring_from_str(path)));
} else if (port) {
qdict_put_obj(opts, "host", QOBJECT(qstring_from_str(host)));
qdict_put_obj(opts, "port", QOBJECT(qstring_from_str(port)));
} else {
qdict_put_obj(opts, "host", QOBJECT(qstring_from_str(host)));
}
if (export) {
qdict_put_obj(opts, "export", QOBJECT(qstring_from_str(export)));
}
bs->full_open_options = opts;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(BlockDriverState *VAR_0)
{
QDict *opts = qdict_new();
const char *VAR_1 = qdict_get_try_str(VAR_0->options, "VAR_1");
const char *VAR_2 = qdict_get_try_str(VAR_0->options, "VAR_2");
const char *VAR_3 = qdict_get_try_str(VAR_0->options, "VAR_3");
const char *VAR_4 = qdict_get_try_str(VAR_0->options, "VAR_4");
qdict_put_obj(opts, "driver", QOBJECT(qstring_from_str("nbd")));
if (VAR_1 && VAR_4) {
snprintf(VAR_0->exact_filename, sizeof(VAR_0->exact_filename),
"nbd+unix:
} else if (VAR_1 && !VAR_4) {
snprintf(VAR_0->exact_filename, sizeof(VAR_0->exact_filename),
"nbd+unix:
} else if (!VAR_1 && VAR_4 && VAR_3) {
snprintf(VAR_0->exact_filename, sizeof(VAR_0->exact_filename),
"nbd:
} else if (!VAR_1 && VAR_4 && !VAR_3) {
snprintf(VAR_0->exact_filename, sizeof(VAR_0->exact_filename),
"nbd:
} else if (!VAR_1 && !VAR_4 && VAR_3) {
snprintf(VAR_0->exact_filename, sizeof(VAR_0->exact_filename),
"nbd:
} else if (!VAR_1 && !VAR_4 && !VAR_3) {
snprintf(VAR_0->exact_filename, sizeof(VAR_0->exact_filename),
"nbd:
}
if (VAR_1) {
qdict_put_obj(opts, "VAR_1", QOBJECT(qstring_from_str(VAR_1)));
} else if (VAR_3) {
qdict_put_obj(opts, "VAR_2", QOBJECT(qstring_from_str(VAR_2)));
qdict_put_obj(opts, "VAR_3", QOBJECT(qstring_from_str(VAR_3)));
} else {
qdict_put_obj(opts, "VAR_2", QOBJECT(qstring_from_str(VAR_2)));
}
if (VAR_4) {
qdict_put_obj(opts, "VAR_4", QOBJECT(qstring_from_str(VAR_4)));
}
VAR_0->full_open_options = opts;
}
| [
"static void FUNC_0(BlockDriverState *VAR_0)\n{",
"QDict *opts = qdict_new();",
"const char *VAR_1 = qdict_get_try_str(VAR_0->options, \"VAR_1\");",
"const char *VAR_2 = qdict_get_try_str(VAR_0->options, \"VAR_2\");",
"const char *VAR_3 = qdict_get_try_str(VAR_0->options, \"VAR_3\");",
"const char *VAR_4 = qdict_get_try_str(VAR_0->options, \"VAR_4\");",
"qdict_put_obj(opts, \"driver\", QOBJECT(qstring_from_str(\"nbd\")));",
"if (VAR_1 && VAR_4) {",
"snprintf(VAR_0->exact_filename, sizeof(VAR_0->exact_filename),\n\"nbd+unix:\n} else if (VAR_1 && !VAR_4) {",
"snprintf(VAR_0->exact_filename, sizeof(VAR_0->exact_filename),\n\"nbd+unix:\n} else if (!VAR_1 && VAR_4 && VAR_3) {",
"snprintf(VAR_0->exact_filename, sizeof(VAR_0->exact_filename),\n\"nbd:\n} else if (!VAR_1 && VAR_4 && !VAR_3) {",
"snprintf(VAR_0->exact_filename, sizeof(VAR_0->exact_filename),\n\"nbd:\n} else if (!VAR_1 && !VAR_4 && VAR_3) {",
"snprintf(VAR_0->exact_filename, sizeof(VAR_0->exact_filename),\n\"nbd:\n} else if (!VAR_1 && !VAR_4 && !VAR_3) {",
"snprintf(VAR_0->exact_filename, sizeof(VAR_0->exact_filename),\n\"nbd:\n}",
"if (VAR_1) {",
"qdict_put_obj(opts, \"VAR_1\", QOBJECT(qstring_from_str(VAR_1)));",
"} else if (VAR_3) {",
"qdict_put_obj(opts, \"VAR_2\", QOBJECT(qstring_from_str(VAR_2)));",
"qdict_put_obj(opts, \"VAR_3\", QOBJECT(qstring_from_str(VAR_3)));",
"} else {",
"qdict_put_obj(opts, \"VAR_2\", QOBJECT(qstring_from_str(VAR_2)));",
"}",
"if (VAR_4) {",
"qdict_put_obj(opts, \"VAR_4\", QOBJECT(qstring_from_str(VAR_4)));",
"}",
"VAR_0->full_open_options = opts;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23,
25,
27
],
[
29,
31,
33
],
[
35,
37,
39
],
[
41,
43,
45
],
[
47,
49,
51
],
[
53,
55,
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
]
] |
27,086 | static int select_input_picture(MpegEncContext *s)
{
int i, ret;
for (i = 1; i < MAX_PICTURE_COUNT; i++)
s->reordered_input_picture[i - 1] = s->reordered_input_picture[i];
s->reordered_input_picture[MAX_PICTURE_COUNT - 1] = NULL;
/* set next picture type & ordering */
if (!s->reordered_input_picture[0] && s->input_picture[0]) {
if (/*s->picture_in_gop_number >= s->gop_size ||*/
!s->next_picture_ptr || s->intra_only) {
s->reordered_input_picture[0] = s->input_picture[0];
s->reordered_input_picture[0]->f->pict_type = AV_PICTURE_TYPE_I;
s->reordered_input_picture[0]->f->coded_picture_number =
s->coded_picture_number++;
} else {
int b_frames;
if (s->avctx->frame_skip_threshold || s->avctx->frame_skip_factor) {
if (s->picture_in_gop_number < s->gop_size &&
skip_check(s, s->input_picture[0], s->next_picture_ptr)) {
// FIXME check that te gop check above is +-1 correct
av_frame_unref(s->input_picture[0]->f);
emms_c();
ff_vbv_update(s, 0);
goto no_output_pic;
}
}
if (s->avctx->flags & AV_CODEC_FLAG_PASS2) {
for (i = 0; i < s->max_b_frames + 1; i++) {
int pict_num = s->input_picture[0]->f->display_picture_number + i;
if (pict_num >= s->rc_context.num_entries)
break;
if (!s->input_picture[i]) {
s->rc_context.entry[pict_num - 1].new_pict_type = AV_PICTURE_TYPE_P;
break;
}
s->input_picture[i]->f->pict_type =
s->rc_context.entry[pict_num].new_pict_type;
}
}
if (s->avctx->b_frame_strategy == 0) {
b_frames = s->max_b_frames;
while (b_frames && !s->input_picture[b_frames])
b_frames--;
} else if (s->avctx->b_frame_strategy == 1) {
for (i = 1; i < s->max_b_frames + 1; i++) {
if (s->input_picture[i] &&
s->input_picture[i]->b_frame_score == 0) {
s->input_picture[i]->b_frame_score =
get_intra_count(s,
s->input_picture[i ]->f->data[0],
s->input_picture[i - 1]->f->data[0],
s->linesize) + 1;
}
}
for (i = 0; i < s->max_b_frames + 1; i++) {
if (!s->input_picture[i] ||
s->input_picture[i]->b_frame_score - 1 >
s->mb_num / s->avctx->b_sensitivity)
break;
}
b_frames = FFMAX(0, i - 1);
/* reset scores */
for (i = 0; i < b_frames + 1; i++) {
s->input_picture[i]->b_frame_score = 0;
}
} else if (s->avctx->b_frame_strategy == 2) {
b_frames = estimate_best_b_count(s);
} else {
av_log(s->avctx, AV_LOG_ERROR, "illegal b frame strategy\n");
b_frames = 0;
}
emms_c();
for (i = b_frames - 1; i >= 0; i--) {
int type = s->input_picture[i]->f->pict_type;
if (type && type != AV_PICTURE_TYPE_B)
b_frames = i;
}
if (s->input_picture[b_frames]->f->pict_type == AV_PICTURE_TYPE_B &&
b_frames == s->max_b_frames) {
av_log(s->avctx, AV_LOG_ERROR,
"warning, too many b frames in a row\n");
}
if (s->picture_in_gop_number + b_frames >= s->gop_size) {
if ((s->mpv_flags & FF_MPV_FLAG_STRICT_GOP) &&
s->gop_size > s->picture_in_gop_number) {
b_frames = s->gop_size - s->picture_in_gop_number - 1;
} else {
if (s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP)
b_frames = 0;
s->input_picture[b_frames]->f->pict_type = AV_PICTURE_TYPE_I;
}
}
if ((s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP) && b_frames &&
s->input_picture[b_frames]->f->pict_type == AV_PICTURE_TYPE_I)
b_frames--;
s->reordered_input_picture[0] = s->input_picture[b_frames];
if (s->reordered_input_picture[0]->f->pict_type != AV_PICTURE_TYPE_I)
s->reordered_input_picture[0]->f->pict_type = AV_PICTURE_TYPE_P;
s->reordered_input_picture[0]->f->coded_picture_number =
s->coded_picture_number++;
for (i = 0; i < b_frames; i++) {
s->reordered_input_picture[i + 1] = s->input_picture[i];
s->reordered_input_picture[i + 1]->f->pict_type =
AV_PICTURE_TYPE_B;
s->reordered_input_picture[i + 1]->f->coded_picture_number =
s->coded_picture_number++;
}
}
}
no_output_pic:
ff_mpeg_unref_picture(s->avctx, &s->new_picture);
if (s->reordered_input_picture[0]) {
s->reordered_input_picture[0]->reference =
s->reordered_input_picture[0]->f->pict_type !=
AV_PICTURE_TYPE_B ? 3 : 0;
if ((ret = ff_mpeg_ref_picture(s->avctx, &s->new_picture, s->reordered_input_picture[0])))
return ret;
if (s->reordered_input_picture[0]->shared || s->avctx->rc_buffer_size) {
// input is a shared pix, so we can't modifiy it -> alloc a new
// one & ensure that the shared one is reuseable
Picture *pic;
int i = ff_find_unused_picture(s->avctx, s->picture, 0);
if (i < 0)
return i;
pic = &s->picture[i];
pic->reference = s->reordered_input_picture[0]->reference;
if (alloc_picture(s, pic, 0) < 0) {
return -1;
}
ret = av_frame_copy_props(pic->f, s->reordered_input_picture[0]->f);
if (ret < 0)
return ret;
/* mark us unused / free shared pic */
av_frame_unref(s->reordered_input_picture[0]->f);
s->reordered_input_picture[0]->shared = 0;
s->current_picture_ptr = pic;
} else {
// input is not a shared pix -> reuse buffer for current_pix
s->current_picture_ptr = s->reordered_input_picture[0];
for (i = 0; i < 4; i++) {
s->new_picture.f->data[i] += INPLACE_OFFSET;
}
}
ff_mpeg_unref_picture(s->avctx, &s->current_picture);
if ((ret = ff_mpeg_ref_picture(s->avctx, &s->current_picture,
s->current_picture_ptr)) < 0)
return ret;
s->picture_number = s->new_picture.f->display_picture_number;
}
return 0;
}
| false | FFmpeg | 0e6c8532215790bbe560a9eea4f3cc82bb55cf92 | static int select_input_picture(MpegEncContext *s)
{
int i, ret;
for (i = 1; i < MAX_PICTURE_COUNT; i++)
s->reordered_input_picture[i - 1] = s->reordered_input_picture[i];
s->reordered_input_picture[MAX_PICTURE_COUNT - 1] = NULL;
if (!s->reordered_input_picture[0] && s->input_picture[0]) {
if (
!s->next_picture_ptr || s->intra_only) {
s->reordered_input_picture[0] = s->input_picture[0];
s->reordered_input_picture[0]->f->pict_type = AV_PICTURE_TYPE_I;
s->reordered_input_picture[0]->f->coded_picture_number =
s->coded_picture_number++;
} else {
int b_frames;
if (s->avctx->frame_skip_threshold || s->avctx->frame_skip_factor) {
if (s->picture_in_gop_number < s->gop_size &&
skip_check(s, s->input_picture[0], s->next_picture_ptr)) {
av_frame_unref(s->input_picture[0]->f);
emms_c();
ff_vbv_update(s, 0);
goto no_output_pic;
}
}
if (s->avctx->flags & AV_CODEC_FLAG_PASS2) {
for (i = 0; i < s->max_b_frames + 1; i++) {
int pict_num = s->input_picture[0]->f->display_picture_number + i;
if (pict_num >= s->rc_context.num_entries)
break;
if (!s->input_picture[i]) {
s->rc_context.entry[pict_num - 1].new_pict_type = AV_PICTURE_TYPE_P;
break;
}
s->input_picture[i]->f->pict_type =
s->rc_context.entry[pict_num].new_pict_type;
}
}
if (s->avctx->b_frame_strategy == 0) {
b_frames = s->max_b_frames;
while (b_frames && !s->input_picture[b_frames])
b_frames--;
} else if (s->avctx->b_frame_strategy == 1) {
for (i = 1; i < s->max_b_frames + 1; i++) {
if (s->input_picture[i] &&
s->input_picture[i]->b_frame_score == 0) {
s->input_picture[i]->b_frame_score =
get_intra_count(s,
s->input_picture[i ]->f->data[0],
s->input_picture[i - 1]->f->data[0],
s->linesize) + 1;
}
}
for (i = 0; i < s->max_b_frames + 1; i++) {
if (!s->input_picture[i] ||
s->input_picture[i]->b_frame_score - 1 >
s->mb_num / s->avctx->b_sensitivity)
break;
}
b_frames = FFMAX(0, i - 1);
for (i = 0; i < b_frames + 1; i++) {
s->input_picture[i]->b_frame_score = 0;
}
} else if (s->avctx->b_frame_strategy == 2) {
b_frames = estimate_best_b_count(s);
} else {
av_log(s->avctx, AV_LOG_ERROR, "illegal b frame strategy\n");
b_frames = 0;
}
emms_c();
for (i = b_frames - 1; i >= 0; i--) {
int type = s->input_picture[i]->f->pict_type;
if (type && type != AV_PICTURE_TYPE_B)
b_frames = i;
}
if (s->input_picture[b_frames]->f->pict_type == AV_PICTURE_TYPE_B &&
b_frames == s->max_b_frames) {
av_log(s->avctx, AV_LOG_ERROR,
"warning, too many b frames in a row\n");
}
if (s->picture_in_gop_number + b_frames >= s->gop_size) {
if ((s->mpv_flags & FF_MPV_FLAG_STRICT_GOP) &&
s->gop_size > s->picture_in_gop_number) {
b_frames = s->gop_size - s->picture_in_gop_number - 1;
} else {
if (s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP)
b_frames = 0;
s->input_picture[b_frames]->f->pict_type = AV_PICTURE_TYPE_I;
}
}
if ((s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP) && b_frames &&
s->input_picture[b_frames]->f->pict_type == AV_PICTURE_TYPE_I)
b_frames--;
s->reordered_input_picture[0] = s->input_picture[b_frames];
if (s->reordered_input_picture[0]->f->pict_type != AV_PICTURE_TYPE_I)
s->reordered_input_picture[0]->f->pict_type = AV_PICTURE_TYPE_P;
s->reordered_input_picture[0]->f->coded_picture_number =
s->coded_picture_number++;
for (i = 0; i < b_frames; i++) {
s->reordered_input_picture[i + 1] = s->input_picture[i];
s->reordered_input_picture[i + 1]->f->pict_type =
AV_PICTURE_TYPE_B;
s->reordered_input_picture[i + 1]->f->coded_picture_number =
s->coded_picture_number++;
}
}
}
no_output_pic:
ff_mpeg_unref_picture(s->avctx, &s->new_picture);
if (s->reordered_input_picture[0]) {
s->reordered_input_picture[0]->reference =
s->reordered_input_picture[0]->f->pict_type !=
AV_PICTURE_TYPE_B ? 3 : 0;
if ((ret = ff_mpeg_ref_picture(s->avctx, &s->new_picture, s->reordered_input_picture[0])))
return ret;
if (s->reordered_input_picture[0]->shared || s->avctx->rc_buffer_size) {
Picture *pic;
int i = ff_find_unused_picture(s->avctx, s->picture, 0);
if (i < 0)
return i;
pic = &s->picture[i];
pic->reference = s->reordered_input_picture[0]->reference;
if (alloc_picture(s, pic, 0) < 0) {
return -1;
}
ret = av_frame_copy_props(pic->f, s->reordered_input_picture[0]->f);
if (ret < 0)
return ret;
av_frame_unref(s->reordered_input_picture[0]->f);
s->reordered_input_picture[0]->shared = 0;
s->current_picture_ptr = pic;
} else {
s->current_picture_ptr = s->reordered_input_picture[0];
for (i = 0; i < 4; i++) {
s->new_picture.f->data[i] += INPLACE_OFFSET;
}
}
ff_mpeg_unref_picture(s->avctx, &s->current_picture);
if ((ret = ff_mpeg_ref_picture(s->avctx, &s->current_picture,
s->current_picture_ptr)) < 0)
return ret;
s->picture_number = s->new_picture.f->display_picture_number;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MpegEncContext *VAR_0)
{
int VAR_5, VAR_2;
for (VAR_5 = 1; VAR_5 < MAX_PICTURE_COUNT; VAR_5++)
VAR_0->reordered_input_picture[VAR_5 - 1] = VAR_0->reordered_input_picture[VAR_5];
VAR_0->reordered_input_picture[MAX_PICTURE_COUNT - 1] = NULL;
if (!VAR_0->reordered_input_picture[0] && VAR_0->input_picture[0]) {
if (
!VAR_0->next_picture_ptr || VAR_0->intra_only) {
VAR_0->reordered_input_picture[0] = VAR_0->input_picture[0];
VAR_0->reordered_input_picture[0]->f->pict_type = AV_PICTURE_TYPE_I;
VAR_0->reordered_input_picture[0]->f->coded_picture_number =
VAR_0->coded_picture_number++;
} else {
int VAR_3;
if (VAR_0->avctx->frame_skip_threshold || VAR_0->avctx->frame_skip_factor) {
if (VAR_0->picture_in_gop_number < VAR_0->gop_size &&
skip_check(VAR_0, VAR_0->input_picture[0], VAR_0->next_picture_ptr)) {
av_frame_unref(VAR_0->input_picture[0]->f);
emms_c();
ff_vbv_update(VAR_0, 0);
goto no_output_pic;
}
}
if (VAR_0->avctx->flags & AV_CODEC_FLAG_PASS2) {
for (VAR_5 = 0; VAR_5 < VAR_0->max_b_frames + 1; VAR_5++) {
int pict_num = VAR_0->input_picture[0]->f->display_picture_number + VAR_5;
if (pict_num >= VAR_0->rc_context.num_entries)
break;
if (!VAR_0->input_picture[VAR_5]) {
VAR_0->rc_context.entry[pict_num - 1].new_pict_type = AV_PICTURE_TYPE_P;
break;
}
VAR_0->input_picture[VAR_5]->f->pict_type =
VAR_0->rc_context.entry[pict_num].new_pict_type;
}
}
if (VAR_0->avctx->b_frame_strategy == 0) {
VAR_3 = VAR_0->max_b_frames;
while (VAR_3 && !VAR_0->input_picture[VAR_3])
VAR_3--;
} else if (VAR_0->avctx->b_frame_strategy == 1) {
for (VAR_5 = 1; VAR_5 < VAR_0->max_b_frames + 1; VAR_5++) {
if (VAR_0->input_picture[VAR_5] &&
VAR_0->input_picture[VAR_5]->b_frame_score == 0) {
VAR_0->input_picture[VAR_5]->b_frame_score =
get_intra_count(VAR_0,
VAR_0->input_picture[VAR_5 ]->f->data[0],
VAR_0->input_picture[VAR_5 - 1]->f->data[0],
VAR_0->linesize) + 1;
}
}
for (VAR_5 = 0; VAR_5 < VAR_0->max_b_frames + 1; VAR_5++) {
if (!VAR_0->input_picture[VAR_5] ||
VAR_0->input_picture[VAR_5]->b_frame_score - 1 >
VAR_0->mb_num / VAR_0->avctx->b_sensitivity)
break;
}
VAR_3 = FFMAX(0, VAR_5 - 1);
for (VAR_5 = 0; VAR_5 < VAR_3 + 1; VAR_5++) {
VAR_0->input_picture[VAR_5]->b_frame_score = 0;
}
} else if (VAR_0->avctx->b_frame_strategy == 2) {
VAR_3 = estimate_best_b_count(VAR_0);
} else {
av_log(VAR_0->avctx, AV_LOG_ERROR, "illegal b frame strategy\n");
VAR_3 = 0;
}
emms_c();
for (VAR_5 = VAR_3 - 1; VAR_5 >= 0; VAR_5--) {
int VAR_4 = VAR_0->input_picture[VAR_5]->f->pict_type;
if (VAR_4 && VAR_4 != AV_PICTURE_TYPE_B)
VAR_3 = VAR_5;
}
if (VAR_0->input_picture[VAR_3]->f->pict_type == AV_PICTURE_TYPE_B &&
VAR_3 == VAR_0->max_b_frames) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"warning, too many b frames in a row\n");
}
if (VAR_0->picture_in_gop_number + VAR_3 >= VAR_0->gop_size) {
if ((VAR_0->mpv_flags & FF_MPV_FLAG_STRICT_GOP) &&
VAR_0->gop_size > VAR_0->picture_in_gop_number) {
VAR_3 = VAR_0->gop_size - VAR_0->picture_in_gop_number - 1;
} else {
if (VAR_0->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP)
VAR_3 = 0;
VAR_0->input_picture[VAR_3]->f->pict_type = AV_PICTURE_TYPE_I;
}
}
if ((VAR_0->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP) && VAR_3 &&
VAR_0->input_picture[VAR_3]->f->pict_type == AV_PICTURE_TYPE_I)
VAR_3--;
VAR_0->reordered_input_picture[0] = VAR_0->input_picture[VAR_3];
if (VAR_0->reordered_input_picture[0]->f->pict_type != AV_PICTURE_TYPE_I)
VAR_0->reordered_input_picture[0]->f->pict_type = AV_PICTURE_TYPE_P;
VAR_0->reordered_input_picture[0]->f->coded_picture_number =
VAR_0->coded_picture_number++;
for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++) {
VAR_0->reordered_input_picture[VAR_5 + 1] = VAR_0->input_picture[VAR_5];
VAR_0->reordered_input_picture[VAR_5 + 1]->f->pict_type =
AV_PICTURE_TYPE_B;
VAR_0->reordered_input_picture[VAR_5 + 1]->f->coded_picture_number =
VAR_0->coded_picture_number++;
}
}
}
no_output_pic:
ff_mpeg_unref_picture(VAR_0->avctx, &VAR_0->new_picture);
if (VAR_0->reordered_input_picture[0]) {
VAR_0->reordered_input_picture[0]->reference =
VAR_0->reordered_input_picture[0]->f->pict_type !=
AV_PICTURE_TYPE_B ? 3 : 0;
if ((VAR_2 = ff_mpeg_ref_picture(VAR_0->avctx, &VAR_0->new_picture, VAR_0->reordered_input_picture[0])))
return VAR_2;
if (VAR_0->reordered_input_picture[0]->shared || VAR_0->avctx->rc_buffer_size) {
Picture *pic;
int VAR_5 = ff_find_unused_picture(VAR_0->avctx, VAR_0->picture, 0);
if (VAR_5 < 0)
return VAR_5;
pic = &VAR_0->picture[VAR_5];
pic->reference = VAR_0->reordered_input_picture[0]->reference;
if (alloc_picture(VAR_0, pic, 0) < 0) {
return -1;
}
VAR_2 = av_frame_copy_props(pic->f, VAR_0->reordered_input_picture[0]->f);
if (VAR_2 < 0)
return VAR_2;
av_frame_unref(VAR_0->reordered_input_picture[0]->f);
VAR_0->reordered_input_picture[0]->shared = 0;
VAR_0->current_picture_ptr = pic;
} else {
VAR_0->current_picture_ptr = VAR_0->reordered_input_picture[0];
for (VAR_5 = 0; VAR_5 < 4; VAR_5++) {
VAR_0->new_picture.f->data[VAR_5] += INPLACE_OFFSET;
}
}
ff_mpeg_unref_picture(VAR_0->avctx, &VAR_0->current_picture);
if ((VAR_2 = ff_mpeg_ref_picture(VAR_0->avctx, &VAR_0->current_picture,
VAR_0->current_picture_ptr)) < 0)
return VAR_2;
VAR_0->picture_number = VAR_0->new_picture.f->display_picture_number;
}
return 0;
}
| [
"static int FUNC_0(MpegEncContext *VAR_0)\n{",
"int VAR_5, VAR_2;",
"for (VAR_5 = 1; VAR_5 < MAX_PICTURE_COUNT; VAR_5++)",
"VAR_0->reordered_input_picture[VAR_5 - 1] = VAR_0->reordered_input_picture[VAR_5];",
"VAR_0->reordered_input_picture[MAX_PICTURE_COUNT - 1] = NULL;",
"if (!VAR_0->reordered_input_picture[0] && VAR_0->input_picture[0]) {",
"if (\n!VAR_0->next_picture_ptr || VAR_0->intra_only) {",
"VAR_0->reordered_input_picture[0] = VAR_0->input_picture[0];",
"VAR_0->reordered_input_picture[0]->f->pict_type = AV_PICTURE_TYPE_I;",
"VAR_0->reordered_input_picture[0]->f->coded_picture_number =\nVAR_0->coded_picture_number++;",
"} else {",
"int VAR_3;",
"if (VAR_0->avctx->frame_skip_threshold || VAR_0->avctx->frame_skip_factor) {",
"if (VAR_0->picture_in_gop_number < VAR_0->gop_size &&\nskip_check(VAR_0, VAR_0->input_picture[0], VAR_0->next_picture_ptr)) {",
"av_frame_unref(VAR_0->input_picture[0]->f);",
"emms_c();",
"ff_vbv_update(VAR_0, 0);",
"goto no_output_pic;",
"}",
"}",
"if (VAR_0->avctx->flags & AV_CODEC_FLAG_PASS2) {",
"for (VAR_5 = 0; VAR_5 < VAR_0->max_b_frames + 1; VAR_5++) {",
"int pict_num = VAR_0->input_picture[0]->f->display_picture_number + VAR_5;",
"if (pict_num >= VAR_0->rc_context.num_entries)\nbreak;",
"if (!VAR_0->input_picture[VAR_5]) {",
"VAR_0->rc_context.entry[pict_num - 1].new_pict_type = AV_PICTURE_TYPE_P;",
"break;",
"}",
"VAR_0->input_picture[VAR_5]->f->pict_type =\nVAR_0->rc_context.entry[pict_num].new_pict_type;",
"}",
"}",
"if (VAR_0->avctx->b_frame_strategy == 0) {",
"VAR_3 = VAR_0->max_b_frames;",
"while (VAR_3 && !VAR_0->input_picture[VAR_3])\nVAR_3--;",
"} else if (VAR_0->avctx->b_frame_strategy == 1) {",
"for (VAR_5 = 1; VAR_5 < VAR_0->max_b_frames + 1; VAR_5++) {",
"if (VAR_0->input_picture[VAR_5] &&\nVAR_0->input_picture[VAR_5]->b_frame_score == 0) {",
"VAR_0->input_picture[VAR_5]->b_frame_score =\nget_intra_count(VAR_0,\nVAR_0->input_picture[VAR_5 ]->f->data[0],\nVAR_0->input_picture[VAR_5 - 1]->f->data[0],\nVAR_0->linesize) + 1;",
"}",
"}",
"for (VAR_5 = 0; VAR_5 < VAR_0->max_b_frames + 1; VAR_5++) {",
"if (!VAR_0->input_picture[VAR_5] ||\nVAR_0->input_picture[VAR_5]->b_frame_score - 1 >\nVAR_0->mb_num / VAR_0->avctx->b_sensitivity)\nbreak;",
"}",
"VAR_3 = FFMAX(0, VAR_5 - 1);",
"for (VAR_5 = 0; VAR_5 < VAR_3 + 1; VAR_5++) {",
"VAR_0->input_picture[VAR_5]->b_frame_score = 0;",
"}",
"} else if (VAR_0->avctx->b_frame_strategy == 2) {",
"VAR_3 = estimate_best_b_count(VAR_0);",
"} else {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"illegal b frame strategy\\n\");",
"VAR_3 = 0;",
"}",
"emms_c();",
"for (VAR_5 = VAR_3 - 1; VAR_5 >= 0; VAR_5--) {",
"int VAR_4 = VAR_0->input_picture[VAR_5]->f->pict_type;",
"if (VAR_4 && VAR_4 != AV_PICTURE_TYPE_B)\nVAR_3 = VAR_5;",
"}",
"if (VAR_0->input_picture[VAR_3]->f->pict_type == AV_PICTURE_TYPE_B &&\nVAR_3 == VAR_0->max_b_frames) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"warning, too many b frames in a row\\n\");",
"}",
"if (VAR_0->picture_in_gop_number + VAR_3 >= VAR_0->gop_size) {",
"if ((VAR_0->mpv_flags & FF_MPV_FLAG_STRICT_GOP) &&\nVAR_0->gop_size > VAR_0->picture_in_gop_number) {",
"VAR_3 = VAR_0->gop_size - VAR_0->picture_in_gop_number - 1;",
"} else {",
"if (VAR_0->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP)\nVAR_3 = 0;",
"VAR_0->input_picture[VAR_3]->f->pict_type = AV_PICTURE_TYPE_I;",
"}",
"}",
"if ((VAR_0->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP) && VAR_3 &&\nVAR_0->input_picture[VAR_3]->f->pict_type == AV_PICTURE_TYPE_I)\nVAR_3--;",
"VAR_0->reordered_input_picture[0] = VAR_0->input_picture[VAR_3];",
"if (VAR_0->reordered_input_picture[0]->f->pict_type != AV_PICTURE_TYPE_I)\nVAR_0->reordered_input_picture[0]->f->pict_type = AV_PICTURE_TYPE_P;",
"VAR_0->reordered_input_picture[0]->f->coded_picture_number =\nVAR_0->coded_picture_number++;",
"for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++) {",
"VAR_0->reordered_input_picture[VAR_5 + 1] = VAR_0->input_picture[VAR_5];",
"VAR_0->reordered_input_picture[VAR_5 + 1]->f->pict_type =\nAV_PICTURE_TYPE_B;",
"VAR_0->reordered_input_picture[VAR_5 + 1]->f->coded_picture_number =\nVAR_0->coded_picture_number++;",
"}",
"}",
"}",
"no_output_pic:\nff_mpeg_unref_picture(VAR_0->avctx, &VAR_0->new_picture);",
"if (VAR_0->reordered_input_picture[0]) {",
"VAR_0->reordered_input_picture[0]->reference =\nVAR_0->reordered_input_picture[0]->f->pict_type !=\nAV_PICTURE_TYPE_B ? 3 : 0;",
"if ((VAR_2 = ff_mpeg_ref_picture(VAR_0->avctx, &VAR_0->new_picture, VAR_0->reordered_input_picture[0])))\nreturn VAR_2;",
"if (VAR_0->reordered_input_picture[0]->shared || VAR_0->avctx->rc_buffer_size) {",
"Picture *pic;",
"int VAR_5 = ff_find_unused_picture(VAR_0->avctx, VAR_0->picture, 0);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"pic = &VAR_0->picture[VAR_5];",
"pic->reference = VAR_0->reordered_input_picture[0]->reference;",
"if (alloc_picture(VAR_0, pic, 0) < 0) {",
"return -1;",
"}",
"VAR_2 = av_frame_copy_props(pic->f, VAR_0->reordered_input_picture[0]->f);",
"if (VAR_2 < 0)\nreturn VAR_2;",
"av_frame_unref(VAR_0->reordered_input_picture[0]->f);",
"VAR_0->reordered_input_picture[0]->shared = 0;",
"VAR_0->current_picture_ptr = pic;",
"} else {",
"VAR_0->current_picture_ptr = VAR_0->reordered_input_picture[0];",
"for (VAR_5 = 0; VAR_5 < 4; VAR_5++) {",
"VAR_0->new_picture.f->data[VAR_5] += INPLACE_OFFSET;",
"}",
"}",
"ff_mpeg_unref_picture(VAR_0->avctx, &VAR_0->current_picture);",
"if ((VAR_2 = ff_mpeg_ref_picture(VAR_0->avctx, &VAR_0->current_picture,\nVAR_0->current_picture_ptr)) < 0)\nreturn VAR_2;",
"VAR_0->picture_number = VAR_0->new_picture.f->display_picture_number;",
"}",
"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
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
39
],
[
41,
43
],
[
47
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87,
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101,
103
],
[
105
],
[
107
],
[
109,
111
],
[
113,
115,
117,
119,
121
],
[
123
],
[
125
],
[
127
],
[
129,
131,
133,
135
],
[
137
],
[
141
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
171
],
[
173
],
[
175,
177
],
[
179
],
[
181,
183
],
[
185,
187
],
[
189
],
[
193
],
[
195,
197
],
[
199
],
[
201
],
[
203,
205
],
[
207
],
[
209
],
[
211
],
[
215,
217,
219
],
[
223
],
[
225,
227
],
[
229,
231
],
[
233
],
[
235
],
[
237,
239
],
[
241,
243
],
[
245
],
[
247
],
[
249
],
[
251,
253
],
[
257
],
[
259,
261,
263
],
[
267,
269
],
[
273
],
[
281
],
[
283
],
[
285,
287
],
[
289
],
[
293
],
[
295
],
[
297
],
[
299
],
[
303
],
[
305,
307
],
[
313
],
[
315
],
[
319
],
[
321
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337,
339,
341
],
[
345
],
[
347
],
[
349
],
[
351
]
] |
27,087 | static inline void iwmmxt_store_reg(TCGv var, int reg)
{
tcg_gen_st_i64(var, cpu_env, offsetof(CPUState, iwmmxt.regs[reg]));
}
| false | qemu | a7812ae412311d7d47f8aa85656faadac9d64b56 | static inline void iwmmxt_store_reg(TCGv var, int reg)
{
tcg_gen_st_i64(var, cpu_env, offsetof(CPUState, iwmmxt.regs[reg]));
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(TCGv VAR_0, int VAR_1)
{
tcg_gen_st_i64(VAR_0, cpu_env, offsetof(CPUState, iwmmxt.regs[VAR_1]));
}
| [
"static inline void FUNC_0(TCGv VAR_0, int VAR_1)\n{",
"tcg_gen_st_i64(VAR_0, cpu_env, offsetof(CPUState, iwmmxt.regs[VAR_1]));",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
27,089 | static int msix_is_masked(PCIDevice *dev, int vector)
{
unsigned offset = vector * MSIX_ENTRY_SIZE + MSIX_VECTOR_CTRL;
return dev->msix_table_page[offset] & MSIX_VECTOR_MASK;
}
| false | qemu | 5b5cb08683b6715a2aca5314168e68ff0665912b | static int msix_is_masked(PCIDevice *dev, int vector)
{
unsigned offset = vector * MSIX_ENTRY_SIZE + MSIX_VECTOR_CTRL;
return dev->msix_table_page[offset] & MSIX_VECTOR_MASK;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(PCIDevice *VAR_0, int VAR_1)
{
unsigned VAR_2 = VAR_1 * MSIX_ENTRY_SIZE + MSIX_VECTOR_CTRL;
return VAR_0->msix_table_page[VAR_2] & MSIX_VECTOR_MASK;
}
| [
"static int FUNC_0(PCIDevice *VAR_0, int VAR_1)\n{",
"unsigned VAR_2 = VAR_1 * MSIX_ENTRY_SIZE + MSIX_VECTOR_CTRL;",
"return VAR_0->msix_table_page[VAR_2] & MSIX_VECTOR_MASK;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
27,090 | static void qed_aio_next_io(QEDAIOCB *acb)
{
BDRVQEDState *s = acb_to_s(acb);
uint64_t offset;
size_t len;
int ret;
trace_qed_aio_next_io(s, acb, 0, acb->cur_pos + acb->cur_qiov.size);
if (acb->backing_qiov) {
qemu_iovec_destroy(acb->backing_qiov);
g_free(acb->backing_qiov);
acb->backing_qiov = NULL;
}
acb->qiov_offset += acb->cur_qiov.size;
acb->cur_pos += acb->cur_qiov.size;
qemu_iovec_reset(&acb->cur_qiov);
/* Complete request */
if (acb->cur_pos >= acb->end_pos) {
qed_aio_complete(acb, 0);
return;
}
/* Find next cluster and start I/O */
len = acb->end_pos - acb->cur_pos;
ret = qed_find_cluster(s, &acb->request, acb->cur_pos, &len, &offset);
if (ret < 0) {
qed_aio_complete(acb, ret);
return;
}
if (acb->flags & QED_AIOCB_WRITE) {
ret = qed_aio_write_data(acb, ret, offset, len);
} else {
ret = qed_aio_read_data(acb, ret, offset, len);
}
if (ret < 0) {
if (ret != -EINPROGRESS) {
qed_aio_complete(acb, ret);
}
return;
}
qed_aio_next_io(acb);
}
| false | qemu | 018598747c775394471ce4a341a1ce225a1738dc | static void qed_aio_next_io(QEDAIOCB *acb)
{
BDRVQEDState *s = acb_to_s(acb);
uint64_t offset;
size_t len;
int ret;
trace_qed_aio_next_io(s, acb, 0, acb->cur_pos + acb->cur_qiov.size);
if (acb->backing_qiov) {
qemu_iovec_destroy(acb->backing_qiov);
g_free(acb->backing_qiov);
acb->backing_qiov = NULL;
}
acb->qiov_offset += acb->cur_qiov.size;
acb->cur_pos += acb->cur_qiov.size;
qemu_iovec_reset(&acb->cur_qiov);
if (acb->cur_pos >= acb->end_pos) {
qed_aio_complete(acb, 0);
return;
}
len = acb->end_pos - acb->cur_pos;
ret = qed_find_cluster(s, &acb->request, acb->cur_pos, &len, &offset);
if (ret < 0) {
qed_aio_complete(acb, ret);
return;
}
if (acb->flags & QED_AIOCB_WRITE) {
ret = qed_aio_write_data(acb, ret, offset, len);
} else {
ret = qed_aio_read_data(acb, ret, offset, len);
}
if (ret < 0) {
if (ret != -EINPROGRESS) {
qed_aio_complete(acb, ret);
}
return;
}
qed_aio_next_io(acb);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(QEDAIOCB *VAR_0)
{
BDRVQEDState *s = acb_to_s(VAR_0);
uint64_t offset;
size_t len;
int VAR_1;
trace_qed_aio_next_io(s, VAR_0, 0, VAR_0->cur_pos + VAR_0->cur_qiov.size);
if (VAR_0->backing_qiov) {
qemu_iovec_destroy(VAR_0->backing_qiov);
g_free(VAR_0->backing_qiov);
VAR_0->backing_qiov = NULL;
}
VAR_0->qiov_offset += VAR_0->cur_qiov.size;
VAR_0->cur_pos += VAR_0->cur_qiov.size;
qemu_iovec_reset(&VAR_0->cur_qiov);
if (VAR_0->cur_pos >= VAR_0->end_pos) {
qed_aio_complete(VAR_0, 0);
return;
}
len = VAR_0->end_pos - VAR_0->cur_pos;
VAR_1 = qed_find_cluster(s, &VAR_0->request, VAR_0->cur_pos, &len, &offset);
if (VAR_1 < 0) {
qed_aio_complete(VAR_0, VAR_1);
return;
}
if (VAR_0->flags & QED_AIOCB_WRITE) {
VAR_1 = qed_aio_write_data(VAR_0, VAR_1, offset, len);
} else {
VAR_1 = qed_aio_read_data(VAR_0, VAR_1, offset, len);
}
if (VAR_1 < 0) {
if (VAR_1 != -EINPROGRESS) {
qed_aio_complete(VAR_0, VAR_1);
}
return;
}
FUNC_0(VAR_0);
}
| [
"static void FUNC_0(QEDAIOCB *VAR_0)\n{",
"BDRVQEDState *s = acb_to_s(VAR_0);",
"uint64_t offset;",
"size_t len;",
"int VAR_1;",
"trace_qed_aio_next_io(s, VAR_0, 0, VAR_0->cur_pos + VAR_0->cur_qiov.size);",
"if (VAR_0->backing_qiov) {",
"qemu_iovec_destroy(VAR_0->backing_qiov);",
"g_free(VAR_0->backing_qiov);",
"VAR_0->backing_qiov = NULL;",
"}",
"VAR_0->qiov_offset += VAR_0->cur_qiov.size;",
"VAR_0->cur_pos += VAR_0->cur_qiov.size;",
"qemu_iovec_reset(&VAR_0->cur_qiov);",
"if (VAR_0->cur_pos >= VAR_0->end_pos) {",
"qed_aio_complete(VAR_0, 0);",
"return;",
"}",
"len = VAR_0->end_pos - VAR_0->cur_pos;",
"VAR_1 = qed_find_cluster(s, &VAR_0->request, VAR_0->cur_pos, &len, &offset);",
"if (VAR_1 < 0) {",
"qed_aio_complete(VAR_0, VAR_1);",
"return;",
"}",
"if (VAR_0->flags & QED_AIOCB_WRITE) {",
"VAR_1 = qed_aio_write_data(VAR_0, VAR_1, offset, len);",
"} else {",
"VAR_1 = qed_aio_read_data(VAR_0, VAR_1, offset, len);",
"}",
"if (VAR_1 < 0) {",
"if (VAR_1 != -EINPROGRESS) {",
"qed_aio_complete(VAR_0, VAR_1);",
"}",
"return;",
"}",
"FUNC_0(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
41
],
[
43
],
[
45
],
[
47
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
]
] |
27,091 | writev_f(int argc, char **argv)
{
struct timeval t1, t2;
int Cflag = 0, qflag = 0;
int c, cnt;
char *buf;
int64_t offset;
int total;
int nr_iov;
int pattern = 0xcd;
QEMUIOVector qiov;
while ((c = getopt(argc, argv, "CqP:")) != EOF) {
switch (c) {
case 'C':
Cflag = 1;
break;
case 'q':
qflag = 1;
break;
case 'P':
pattern = atoi(optarg);
break;
default:
return command_usage(&writev_cmd);
}
}
if (optind > argc - 2)
return command_usage(&writev_cmd);
offset = cvtnum(argv[optind]);
if (offset < 0) {
printf("non-numeric length argument -- %s\n", argv[optind]);
return 0;
}
optind++;
if (offset & 0x1ff) {
printf("offset %lld is not sector aligned\n",
(long long)offset);
return 0;
}
nr_iov = argc - optind;
buf = create_iovec(&qiov, &argv[optind], nr_iov, pattern);
gettimeofday(&t1, NULL);
cnt = do_aio_writev(&qiov, offset, &total);
gettimeofday(&t2, NULL);
if (cnt < 0) {
printf("writev failed: %s\n", strerror(-cnt));
goto out;
}
if (qflag)
goto out;
/* Finally, report back -- -C gives a parsable format */
t2 = tsub(t2, t1);
print_report("wrote", &t2, offset, qiov.size, total, cnt, Cflag);
out:
qemu_io_free(buf);
return 0;
}
| false | qemu | cf070d7ec0b8fb21faa9a630ed5cc66f90844a08 | writev_f(int argc, char **argv)
{
struct timeval t1, t2;
int Cflag = 0, qflag = 0;
int c, cnt;
char *buf;
int64_t offset;
int total;
int nr_iov;
int pattern = 0xcd;
QEMUIOVector qiov;
while ((c = getopt(argc, argv, "CqP:")) != EOF) {
switch (c) {
case 'C':
Cflag = 1;
break;
case 'q':
qflag = 1;
break;
case 'P':
pattern = atoi(optarg);
break;
default:
return command_usage(&writev_cmd);
}
}
if (optind > argc - 2)
return command_usage(&writev_cmd);
offset = cvtnum(argv[optind]);
if (offset < 0) {
printf("non-numeric length argument -- %s\n", argv[optind]);
return 0;
}
optind++;
if (offset & 0x1ff) {
printf("offset %lld is not sector aligned\n",
(long long)offset);
return 0;
}
nr_iov = argc - optind;
buf = create_iovec(&qiov, &argv[optind], nr_iov, pattern);
gettimeofday(&t1, NULL);
cnt = do_aio_writev(&qiov, offset, &total);
gettimeofday(&t2, NULL);
if (cnt < 0) {
printf("writev failed: %s\n", strerror(-cnt));
goto out;
}
if (qflag)
goto out;
t2 = tsub(t2, t1);
print_report("wrote", &t2, offset, qiov.size, total, cnt, Cflag);
out:
qemu_io_free(buf);
return 0;
}
| {
"code": [],
"line_no": []
} | FUNC_0(int VAR_0, char **VAR_1)
{
struct timeval VAR_2, VAR_3;
int VAR_4 = 0, VAR_5 = 0;
int VAR_6, VAR_7;
char *VAR_8;
int64_t offset;
int VAR_9;
int VAR_10;
int VAR_11 = 0xcd;
QEMUIOVector qiov;
while ((VAR_6 = getopt(VAR_0, VAR_1, "CqP:")) != EOF) {
switch (VAR_6) {
case 'C':
VAR_4 = 1;
break;
case 'q':
VAR_5 = 1;
break;
case 'P':
VAR_11 = atoi(optarg);
break;
default:
return command_usage(&writev_cmd);
}
}
if (optind > VAR_0 - 2)
return command_usage(&writev_cmd);
offset = cvtnum(VAR_1[optind]);
if (offset < 0) {
printf("non-numeric length argument -- %s\n", VAR_1[optind]);
return 0;
}
optind++;
if (offset & 0x1ff) {
printf("offset %lld is not sector aligned\n",
(long long)offset);
return 0;
}
VAR_10 = VAR_0 - optind;
VAR_8 = create_iovec(&qiov, &VAR_1[optind], VAR_10, VAR_11);
gettimeofday(&VAR_2, NULL);
VAR_7 = do_aio_writev(&qiov, offset, &VAR_9);
gettimeofday(&VAR_3, NULL);
if (VAR_7 < 0) {
printf("writev failed: %s\n", strerror(-VAR_7));
goto out;
}
if (VAR_5)
goto out;
VAR_3 = tsub(VAR_3, VAR_2);
print_report("wrote", &VAR_3, offset, qiov.size, VAR_9, VAR_7, VAR_4);
out:
qemu_io_free(VAR_8);
return 0;
}
| [
"FUNC_0(int VAR_0, char **VAR_1)\n{",
"struct timeval VAR_2, VAR_3;",
"int VAR_4 = 0, VAR_5 = 0;",
"int VAR_6, VAR_7;",
"char *VAR_8;",
"int64_t offset;",
"int VAR_9;",
"int VAR_10;",
"int VAR_11 = 0xcd;",
"QEMUIOVector qiov;",
"while ((VAR_6 = getopt(VAR_0, VAR_1, \"CqP:\")) != EOF) {",
"switch (VAR_6) {",
"case 'C':\nVAR_4 = 1;",
"break;",
"case 'q':\nVAR_5 = 1;",
"break;",
"case 'P':\nVAR_11 = atoi(optarg);",
"break;",
"default:\nreturn command_usage(&writev_cmd);",
"}",
"}",
"if (optind > VAR_0 - 2)\nreturn command_usage(&writev_cmd);",
"offset = cvtnum(VAR_1[optind]);",
"if (offset < 0) {",
"printf(\"non-numeric length argument -- %s\\n\", VAR_1[optind]);",
"return 0;",
"}",
"optind++;",
"if (offset & 0x1ff) {",
"printf(\"offset %lld is not sector aligned\\n\",\n(long long)offset);",
"return 0;",
"}",
"VAR_10 = VAR_0 - optind;",
"VAR_8 = create_iovec(&qiov, &VAR_1[optind], VAR_10, VAR_11);",
"gettimeofday(&VAR_2, NULL);",
"VAR_7 = do_aio_writev(&qiov, offset, &VAR_9);",
"gettimeofday(&VAR_3, NULL);",
"if (VAR_7 < 0) {",
"printf(\"writev failed: %s\\n\", strerror(-VAR_7));",
"goto out;",
"}",
"if (VAR_5)\ngoto out;",
"VAR_3 = tsub(VAR_3, VAR_2);",
"print_report(\"wrote\", &VAR_3, offset, qiov.size, VAR_9, VAR_7, VAR_4);",
"out:\nqemu_io_free(VAR_8);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35,
37
],
[
39
],
[
41,
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
57,
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79,
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113,
115
],
[
121
],
[
123
],
[
125,
127
],
[
129
],
[
131
]
] |
27,092 | static void test_qemu_strtoull_decimal(void)
{
const char *str = "0123";
char f = 'X';
const char *endptr = &f;
uint64_t res = 999;
int err;
err = qemu_strtoull(str, &endptr, 10, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, 123);
g_assert(endptr == str + strlen(str));
str = "123";
endptr = &f;
res = 999;
err = qemu_strtoull(str, &endptr, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, 123);
g_assert(endptr == str + strlen(str));
}
| false | qemu | bc7c08a2c375acb7ae4d433054415588b176d34c | static void test_qemu_strtoull_decimal(void)
{
const char *str = "0123";
char f = 'X';
const char *endptr = &f;
uint64_t res = 999;
int err;
err = qemu_strtoull(str, &endptr, 10, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, 123);
g_assert(endptr == str + strlen(str));
str = "123";
endptr = &f;
res = 999;
err = qemu_strtoull(str, &endptr, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, 123);
g_assert(endptr == str + strlen(str));
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
const char *VAR_0 = "0123";
char VAR_1 = 'X';
const char *VAR_2 = &VAR_1;
uint64_t res = 999;
int VAR_3;
VAR_3 = qemu_strtoull(VAR_0, &VAR_2, 10, &res);
g_assert_cmpint(VAR_3, ==, 0);
g_assert_cmpint(res, ==, 123);
g_assert(VAR_2 == VAR_0 + strlen(VAR_0));
VAR_0 = "123";
VAR_2 = &VAR_1;
res = 999;
VAR_3 = qemu_strtoull(VAR_0, &VAR_2, 0, &res);
g_assert_cmpint(VAR_3, ==, 0);
g_assert_cmpint(res, ==, 123);
g_assert(VAR_2 == VAR_0 + strlen(VAR_0));
}
| [
"static void FUNC_0(void)\n{",
"const char *VAR_0 = \"0123\";",
"char VAR_1 = 'X';",
"const char *VAR_2 = &VAR_1;",
"uint64_t res = 999;",
"int VAR_3;",
"VAR_3 = qemu_strtoull(VAR_0, &VAR_2, 10, &res);",
"g_assert_cmpint(VAR_3, ==, 0);",
"g_assert_cmpint(res, ==, 123);",
"g_assert(VAR_2 == VAR_0 + strlen(VAR_0));",
"VAR_0 = \"123\";",
"VAR_2 = &VAR_1;",
"res = 999;",
"VAR_3 = qemu_strtoull(VAR_0, &VAR_2, 0, &res);",
"g_assert_cmpint(VAR_3, ==, 0);",
"g_assert_cmpint(res, ==, 123);",
"g_assert(VAR_2 == VAR_0 + strlen(VAR_0));",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
]
] |
27,093 | static uint64_t imx_timerp_read(void *opaque, target_phys_addr_t offset,
unsigned size)
{
IMXTimerPState *s = (IMXTimerPState *)opaque;
DPRINTF("p-read(offset=%x)", offset >> 2);
switch (offset >> 2) {
case 0: /* Control Register */
DPRINTF("cr %x\n", s->cr);
return s->cr;
case 1: /* Status Register */
DPRINTF("int_level %x\n", s->int_level);
return s->int_level;
case 2: /* LR - ticks*/
DPRINTF("lr %x\n", s->lr);
return s->lr;
case 3: /* CMP */
DPRINTF("cmp %x\n", s->cmp);
return s->cmp;
case 4: /* CNT */
return ptimer_get_count(s->timer);
}
IPRINTF("imx_timerp_read: Bad offset %x\n",
(int)offset >> 2);
return 0;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t imx_timerp_read(void *opaque, target_phys_addr_t offset,
unsigned size)
{
IMXTimerPState *s = (IMXTimerPState *)opaque;
DPRINTF("p-read(offset=%x)", offset >> 2);
switch (offset >> 2) {
case 0:
DPRINTF("cr %x\n", s->cr);
return s->cr;
case 1:
DPRINTF("int_level %x\n", s->int_level);
return s->int_level;
case 2:
DPRINTF("lr %x\n", s->lr);
return s->lr;
case 3:
DPRINTF("cmp %x\n", s->cmp);
return s->cmp;
case 4:
return ptimer_get_count(s->timer);
}
IPRINTF("imx_timerp_read: Bad offset %x\n",
(int)offset >> 2);
return 0;
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t offset,
unsigned size)
{
IMXTimerPState *s = (IMXTimerPState *)opaque;
DPRINTF("p-read(offset=%x)", offset >> 2);
switch (offset >> 2) {
case 0:
DPRINTF("cr %x\n", s->cr);
return s->cr;
case 1:
DPRINTF("int_level %x\n", s->int_level);
return s->int_level;
case 2:
DPRINTF("lr %x\n", s->lr);
return s->lr;
case 3:
DPRINTF("cmp %x\n", s->cmp);
return s->cmp;
case 4:
return ptimer_get_count(s->timer);
}
IPRINTF("FUNC_0: Bad offset %x\n",
(int)offset >> 2);
return 0;
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t offset,\nunsigned size)\n{",
"IMXTimerPState *s = (IMXTimerPState *)opaque;",
"DPRINTF(\"p-read(offset=%x)\", offset >> 2);",
"switch (offset >> 2) {",
"case 0:\nDPRINTF(\"cr %x\\n\", s->cr);",
"return s->cr;",
"case 1:\nDPRINTF(\"int_level %x\\n\", s->int_level);",
"return s->int_level;",
"case 2:\nDPRINTF(\"lr %x\\n\", s->lr);",
"return s->lr;",
"case 3:\nDPRINTF(\"cmp %x\\n\", s->cmp);",
"return s->cmp;",
"case 4:\nreturn ptimer_get_count(s->timer);",
"}",
"IPRINTF(\"FUNC_0: Bad offset %x\\n\",\n(int)offset >> 2);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
23,
25
],
[
27
],
[
31,
33
],
[
35
],
[
39,
41
],
[
43
],
[
47,
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
]
] |
27,094 | static void tcg_out_brcond2(TCGContext *s, TCGCond cond, TCGReg al, TCGReg ah,
TCGReg bl, TCGReg bh, int label_index)
{
TCGCond b_cond = TCG_COND_NE;
TCGReg tmp = TCG_TMP1;
/* With branches, we emit between 4 and 9 insns with 2 or 3 branches.
With setcond, we emit between 3 and 10 insns and only 1 branch,
which ought to get better branch prediction. */
switch (cond) {
case TCG_COND_EQ:
case TCG_COND_NE:
b_cond = cond;
tmp = tcg_out_reduce_eq2(s, TCG_TMP0, TCG_TMP1, al, ah, bl, bh);
break;
default:
/* Minimize code size by preferring a compare not requiring INV. */
if (mips_cmp_map[cond] & MIPS_CMP_INV) {
cond = tcg_invert_cond(cond);
b_cond = TCG_COND_EQ;
}
tcg_out_setcond2(s, cond, tmp, al, ah, bl, bh);
break;
}
tcg_out_brcond(s, b_cond, tmp, TCG_REG_ZERO, label_index);
}
| false | qemu | bec1631100323fac0900aea71043d5c4e22fc2fa | static void tcg_out_brcond2(TCGContext *s, TCGCond cond, TCGReg al, TCGReg ah,
TCGReg bl, TCGReg bh, int label_index)
{
TCGCond b_cond = TCG_COND_NE;
TCGReg tmp = TCG_TMP1;
switch (cond) {
case TCG_COND_EQ:
case TCG_COND_NE:
b_cond = cond;
tmp = tcg_out_reduce_eq2(s, TCG_TMP0, TCG_TMP1, al, ah, bl, bh);
break;
default:
if (mips_cmp_map[cond] & MIPS_CMP_INV) {
cond = tcg_invert_cond(cond);
b_cond = TCG_COND_EQ;
}
tcg_out_setcond2(s, cond, tmp, al, ah, bl, bh);
break;
}
tcg_out_brcond(s, b_cond, tmp, TCG_REG_ZERO, label_index);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TCGContext *VAR_0, TCGCond VAR_1, TCGReg VAR_2, TCGReg VAR_3,
TCGReg VAR_4, TCGReg VAR_5, int VAR_6)
{
TCGCond b_cond = TCG_COND_NE;
TCGReg tmp = TCG_TMP1;
switch (VAR_1) {
case TCG_COND_EQ:
case TCG_COND_NE:
b_cond = VAR_1;
tmp = tcg_out_reduce_eq2(VAR_0, TCG_TMP0, TCG_TMP1, VAR_2, VAR_3, VAR_4, VAR_5);
break;
default:
if (mips_cmp_map[VAR_1] & MIPS_CMP_INV) {
VAR_1 = tcg_invert_cond(VAR_1);
b_cond = TCG_COND_EQ;
}
tcg_out_setcond2(VAR_0, VAR_1, tmp, VAR_2, VAR_3, VAR_4, VAR_5);
break;
}
tcg_out_brcond(VAR_0, b_cond, tmp, TCG_REG_ZERO, VAR_6);
}
| [
"static void FUNC_0(TCGContext *VAR_0, TCGCond VAR_1, TCGReg VAR_2, TCGReg VAR_3,\nTCGReg VAR_4, TCGReg VAR_5, int VAR_6)\n{",
"TCGCond b_cond = TCG_COND_NE;",
"TCGReg tmp = TCG_TMP1;",
"switch (VAR_1) {",
"case TCG_COND_EQ:\ncase TCG_COND_NE:\nb_cond = VAR_1;",
"tmp = tcg_out_reduce_eq2(VAR_0, TCG_TMP0, TCG_TMP1, VAR_2, VAR_3, VAR_4, VAR_5);",
"break;",
"default:\nif (mips_cmp_map[VAR_1] & MIPS_CMP_INV) {",
"VAR_1 = tcg_invert_cond(VAR_1);",
"b_cond = TCG_COND_EQ;",
"}",
"tcg_out_setcond2(VAR_0, VAR_1, tmp, VAR_2, VAR_3, VAR_4, VAR_5);",
"break;",
"}",
"tcg_out_brcond(VAR_0, b_cond, tmp, TCG_REG_ZERO, VAR_6);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
19
],
[
21,
23,
25
],
[
27
],
[
29
],
[
33,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
]
] |
27,096 | static void legacy_mouse_event(DeviceState *dev, QemuConsole *src,
InputEvent *evt)
{
static const int bmap[INPUT_BUTTON__MAX] = {
[INPUT_BUTTON_LEFT] = MOUSE_EVENT_LBUTTON,
[INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON,
[INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON,
};
QEMUPutMouseEntry *s = (QEMUPutMouseEntry *)dev;
InputBtnEvent *btn;
InputMoveEvent *move;
switch (evt->type) {
case INPUT_EVENT_KIND_BTN:
btn = evt->u.btn;
if (btn->down) {
s->buttons |= bmap[btn->button];
} else {
s->buttons &= ~bmap[btn->button];
}
if (btn->down && btn->button == INPUT_BUTTON_WHEEL_UP) {
s->qemu_put_mouse_event(s->qemu_put_mouse_event_opaque,
s->axis[INPUT_AXIS_X],
s->axis[INPUT_AXIS_Y],
-1,
s->buttons);
}
if (btn->down && btn->button == INPUT_BUTTON_WHEEL_DOWN) {
s->qemu_put_mouse_event(s->qemu_put_mouse_event_opaque,
s->axis[INPUT_AXIS_X],
s->axis[INPUT_AXIS_Y],
1,
s->buttons);
}
break;
case INPUT_EVENT_KIND_ABS:
move = evt->u.abs;
s->axis[move->axis] = move->value;
break;
case INPUT_EVENT_KIND_REL:
move = evt->u.rel;
s->axis[move->axis] += move->value;
break;
default:
break;
}
}
| false | qemu | 32bafa8fdd098d52fbf1102d5a5e48d29398c0aa | static void legacy_mouse_event(DeviceState *dev, QemuConsole *src,
InputEvent *evt)
{
static const int bmap[INPUT_BUTTON__MAX] = {
[INPUT_BUTTON_LEFT] = MOUSE_EVENT_LBUTTON,
[INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON,
[INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON,
};
QEMUPutMouseEntry *s = (QEMUPutMouseEntry *)dev;
InputBtnEvent *btn;
InputMoveEvent *move;
switch (evt->type) {
case INPUT_EVENT_KIND_BTN:
btn = evt->u.btn;
if (btn->down) {
s->buttons |= bmap[btn->button];
} else {
s->buttons &= ~bmap[btn->button];
}
if (btn->down && btn->button == INPUT_BUTTON_WHEEL_UP) {
s->qemu_put_mouse_event(s->qemu_put_mouse_event_opaque,
s->axis[INPUT_AXIS_X],
s->axis[INPUT_AXIS_Y],
-1,
s->buttons);
}
if (btn->down && btn->button == INPUT_BUTTON_WHEEL_DOWN) {
s->qemu_put_mouse_event(s->qemu_put_mouse_event_opaque,
s->axis[INPUT_AXIS_X],
s->axis[INPUT_AXIS_Y],
1,
s->buttons);
}
break;
case INPUT_EVENT_KIND_ABS:
move = evt->u.abs;
s->axis[move->axis] = move->value;
break;
case INPUT_EVENT_KIND_REL:
move = evt->u.rel;
s->axis[move->axis] += move->value;
break;
default:
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0, QemuConsole *VAR_1,
InputEvent *VAR_2)
{
static const int VAR_3[INPUT_BUTTON__MAX] = {
[INPUT_BUTTON_LEFT] = MOUSE_EVENT_LBUTTON,
[INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON,
[INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON,
};
QEMUPutMouseEntry *s = (QEMUPutMouseEntry *)VAR_0;
InputBtnEvent *btn;
InputMoveEvent *move;
switch (VAR_2->type) {
case INPUT_EVENT_KIND_BTN:
btn = VAR_2->u.btn;
if (btn->down) {
s->buttons |= VAR_3[btn->button];
} else {
s->buttons &= ~VAR_3[btn->button];
}
if (btn->down && btn->button == INPUT_BUTTON_WHEEL_UP) {
s->qemu_put_mouse_event(s->qemu_put_mouse_event_opaque,
s->axis[INPUT_AXIS_X],
s->axis[INPUT_AXIS_Y],
-1,
s->buttons);
}
if (btn->down && btn->button == INPUT_BUTTON_WHEEL_DOWN) {
s->qemu_put_mouse_event(s->qemu_put_mouse_event_opaque,
s->axis[INPUT_AXIS_X],
s->axis[INPUT_AXIS_Y],
1,
s->buttons);
}
break;
case INPUT_EVENT_KIND_ABS:
move = VAR_2->u.abs;
s->axis[move->axis] = move->value;
break;
case INPUT_EVENT_KIND_REL:
move = VAR_2->u.rel;
s->axis[move->axis] += move->value;
break;
default:
break;
}
}
| [
"static void FUNC_0(DeviceState *VAR_0, QemuConsole *VAR_1,\nInputEvent *VAR_2)\n{",
"static const int VAR_3[INPUT_BUTTON__MAX] = {",
"[INPUT_BUTTON_LEFT] = MOUSE_EVENT_LBUTTON,\n[INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON,\n[INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON,\n};",
"QEMUPutMouseEntry *s = (QEMUPutMouseEntry *)VAR_0;",
"InputBtnEvent *btn;",
"InputMoveEvent *move;",
"switch (VAR_2->type) {",
"case INPUT_EVENT_KIND_BTN:\nbtn = VAR_2->u.btn;",
"if (btn->down) {",
"s->buttons |= VAR_3[btn->button];",
"} else {",
"s->buttons &= ~VAR_3[btn->button];",
"}",
"if (btn->down && btn->button == INPUT_BUTTON_WHEEL_UP) {",
"s->qemu_put_mouse_event(s->qemu_put_mouse_event_opaque,\ns->axis[INPUT_AXIS_X],\ns->axis[INPUT_AXIS_Y],\n-1,\ns->buttons);",
"}",
"if (btn->down && btn->button == INPUT_BUTTON_WHEEL_DOWN) {",
"s->qemu_put_mouse_event(s->qemu_put_mouse_event_opaque,\ns->axis[INPUT_AXIS_X],\ns->axis[INPUT_AXIS_Y],\n1,\ns->buttons);",
"}",
"break;",
"case INPUT_EVENT_KIND_ABS:\nmove = VAR_2->u.abs;",
"s->axis[move->axis] = move->value;",
"break;",
"case INPUT_EVENT_KIND_REL:\nmove = VAR_2->u.rel;",
"s->axis[move->axis] += move->value;",
"break;",
"default:\nbreak;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9,
11,
13,
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45,
47,
49,
51
],
[
53
],
[
55
],
[
57,
59,
61,
63,
65
],
[
67
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
79,
81
],
[
83
],
[
85
],
[
87,
89
],
[
91
],
[
93
]
] |
27,097 | static int h264_slice_header_init(H264Context *h)
{
int nb_slices = (HAVE_THREADS &&
h->avctx->active_thread_type & FF_THREAD_SLICE) ?
h->avctx->thread_count : 1;
int i, ret;
ff_set_sar(h->avctx, h->sps.sar);
av_pix_fmt_get_chroma_sub_sample(h->avctx->pix_fmt,
&h->chroma_x_shift, &h->chroma_y_shift);
if (h->sps.timing_info_present_flag) {
int64_t den = h->sps.time_scale;
if (h->x264_build < 44U)
den *= 2;
av_reduce(&h->avctx->framerate.den, &h->avctx->framerate.num,
h->sps.num_units_in_tick, den, 1 << 30);
}
ff_h264_free_tables(h);
h->first_field = 0;
h->prev_interlaced_frame = 1;
init_scan_tables(h);
ret = ff_h264_alloc_tables(h);
if (ret < 0) {
av_log(h->avctx, AV_LOG_ERROR, "Could not allocate memory\n");
return ret;
}
if (h->sps.bit_depth_luma < 8 || h->sps.bit_depth_luma > 10) {
av_log(h->avctx, AV_LOG_ERROR, "Unsupported bit depth %d\n",
h->sps.bit_depth_luma);
return AVERROR_INVALIDDATA;
}
h->avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
h->pixel_shift = h->sps.bit_depth_luma > 8;
h->chroma_format_idc = h->sps.chroma_format_idc;
h->bit_depth_luma = h->sps.bit_depth_luma;
ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma,
h->sps.chroma_format_idc);
ff_h264chroma_init(&h->h264chroma, h->sps.bit_depth_chroma);
ff_h264qpel_init(&h->h264qpel, h->sps.bit_depth_luma);
ff_h264_pred_init(&h->hpc, h->avctx->codec_id, h->sps.bit_depth_luma,
h->sps.chroma_format_idc);
ff_videodsp_init(&h->vdsp, h->sps.bit_depth_luma);
if (nb_slices > H264_MAX_THREADS || (nb_slices > h->mb_height && h->mb_height)) {
int max_slices;
if (h->mb_height)
max_slices = FFMIN(H264_MAX_THREADS, h->mb_height);
else
max_slices = H264_MAX_THREADS;
av_log(h->avctx, AV_LOG_WARNING, "too many threads/slices %d,"
" reducing to %d\n", nb_slices, max_slices);
nb_slices = max_slices;
}
h->slice_context_count = nb_slices;
if (!HAVE_THREADS || !(h->avctx->active_thread_type & FF_THREAD_SLICE)) {
ret = ff_h264_slice_context_init(h, &h->slice_ctx[0]);
if (ret < 0) {
av_log(h->avctx, AV_LOG_ERROR, "context_init() failed.\n");
return ret;
}
} else {
for (i = 0; i < h->slice_context_count; i++) {
H264SliceContext *sl = &h->slice_ctx[i];
sl->h264 = h;
sl->intra4x4_pred_mode = h->intra4x4_pred_mode + i * 8 * 2 * h->mb_stride;
sl->mvd_table[0] = h->mvd_table[0] + i * 8 * 2 * h->mb_stride;
sl->mvd_table[1] = h->mvd_table[1] + i * 8 * 2 * h->mb_stride;
if ((ret = ff_h264_slice_context_init(h, sl)) < 0) {
av_log(h->avctx, AV_LOG_ERROR, "context_init() failed.\n");
return ret;
}
}
}
h->context_initialized = 1;
return 0;
}
| false | FFmpeg | 3176217c60ca7828712985092d9102d331ea4f3d | static int h264_slice_header_init(H264Context *h)
{
int nb_slices = (HAVE_THREADS &&
h->avctx->active_thread_type & FF_THREAD_SLICE) ?
h->avctx->thread_count : 1;
int i, ret;
ff_set_sar(h->avctx, h->sps.sar);
av_pix_fmt_get_chroma_sub_sample(h->avctx->pix_fmt,
&h->chroma_x_shift, &h->chroma_y_shift);
if (h->sps.timing_info_present_flag) {
int64_t den = h->sps.time_scale;
if (h->x264_build < 44U)
den *= 2;
av_reduce(&h->avctx->framerate.den, &h->avctx->framerate.num,
h->sps.num_units_in_tick, den, 1 << 30);
}
ff_h264_free_tables(h);
h->first_field = 0;
h->prev_interlaced_frame = 1;
init_scan_tables(h);
ret = ff_h264_alloc_tables(h);
if (ret < 0) {
av_log(h->avctx, AV_LOG_ERROR, "Could not allocate memory\n");
return ret;
}
if (h->sps.bit_depth_luma < 8 || h->sps.bit_depth_luma > 10) {
av_log(h->avctx, AV_LOG_ERROR, "Unsupported bit depth %d\n",
h->sps.bit_depth_luma);
return AVERROR_INVALIDDATA;
}
h->avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
h->pixel_shift = h->sps.bit_depth_luma > 8;
h->chroma_format_idc = h->sps.chroma_format_idc;
h->bit_depth_luma = h->sps.bit_depth_luma;
ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma,
h->sps.chroma_format_idc);
ff_h264chroma_init(&h->h264chroma, h->sps.bit_depth_chroma);
ff_h264qpel_init(&h->h264qpel, h->sps.bit_depth_luma);
ff_h264_pred_init(&h->hpc, h->avctx->codec_id, h->sps.bit_depth_luma,
h->sps.chroma_format_idc);
ff_videodsp_init(&h->vdsp, h->sps.bit_depth_luma);
if (nb_slices > H264_MAX_THREADS || (nb_slices > h->mb_height && h->mb_height)) {
int max_slices;
if (h->mb_height)
max_slices = FFMIN(H264_MAX_THREADS, h->mb_height);
else
max_slices = H264_MAX_THREADS;
av_log(h->avctx, AV_LOG_WARNING, "too many threads/slices %d,"
" reducing to %d\n", nb_slices, max_slices);
nb_slices = max_slices;
}
h->slice_context_count = nb_slices;
if (!HAVE_THREADS || !(h->avctx->active_thread_type & FF_THREAD_SLICE)) {
ret = ff_h264_slice_context_init(h, &h->slice_ctx[0]);
if (ret < 0) {
av_log(h->avctx, AV_LOG_ERROR, "context_init() failed.\n");
return ret;
}
} else {
for (i = 0; i < h->slice_context_count; i++) {
H264SliceContext *sl = &h->slice_ctx[i];
sl->h264 = h;
sl->intra4x4_pred_mode = h->intra4x4_pred_mode + i * 8 * 2 * h->mb_stride;
sl->mvd_table[0] = h->mvd_table[0] + i * 8 * 2 * h->mb_stride;
sl->mvd_table[1] = h->mvd_table[1] + i * 8 * 2 * h->mb_stride;
if ((ret = ff_h264_slice_context_init(h, sl)) < 0) {
av_log(h->avctx, AV_LOG_ERROR, "context_init() failed.\n");
return ret;
}
}
}
h->context_initialized = 1;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(H264Context *VAR_0)
{
int VAR_1 = (HAVE_THREADS &&
VAR_0->avctx->active_thread_type & FF_THREAD_SLICE) ?
VAR_0->avctx->thread_count : 1;
int VAR_2, VAR_3;
ff_set_sar(VAR_0->avctx, VAR_0->sps.sar);
av_pix_fmt_get_chroma_sub_sample(VAR_0->avctx->pix_fmt,
&VAR_0->chroma_x_shift, &VAR_0->chroma_y_shift);
if (VAR_0->sps.timing_info_present_flag) {
int64_t den = VAR_0->sps.time_scale;
if (VAR_0->x264_build < 44U)
den *= 2;
av_reduce(&VAR_0->avctx->framerate.den, &VAR_0->avctx->framerate.num,
VAR_0->sps.num_units_in_tick, den, 1 << 30);
}
ff_h264_free_tables(VAR_0);
VAR_0->first_field = 0;
VAR_0->prev_interlaced_frame = 1;
init_scan_tables(VAR_0);
VAR_3 = ff_h264_alloc_tables(VAR_0);
if (VAR_3 < 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Could not allocate memory\n");
return VAR_3;
}
if (VAR_0->sps.bit_depth_luma < 8 || VAR_0->sps.bit_depth_luma > 10) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Unsupported bit depth %d\n",
VAR_0->sps.bit_depth_luma);
return AVERROR_INVALIDDATA;
}
VAR_0->avctx->bits_per_raw_sample = VAR_0->sps.bit_depth_luma;
VAR_0->pixel_shift = VAR_0->sps.bit_depth_luma > 8;
VAR_0->chroma_format_idc = VAR_0->sps.chroma_format_idc;
VAR_0->bit_depth_luma = VAR_0->sps.bit_depth_luma;
ff_h264dsp_init(&VAR_0->h264dsp, VAR_0->sps.bit_depth_luma,
VAR_0->sps.chroma_format_idc);
ff_h264chroma_init(&VAR_0->h264chroma, VAR_0->sps.bit_depth_chroma);
ff_h264qpel_init(&VAR_0->h264qpel, VAR_0->sps.bit_depth_luma);
ff_h264_pred_init(&VAR_0->hpc, VAR_0->avctx->codec_id, VAR_0->sps.bit_depth_luma,
VAR_0->sps.chroma_format_idc);
ff_videodsp_init(&VAR_0->vdsp, VAR_0->sps.bit_depth_luma);
if (VAR_1 > H264_MAX_THREADS || (VAR_1 > VAR_0->mb_height && VAR_0->mb_height)) {
int VAR_4;
if (VAR_0->mb_height)
VAR_4 = FFMIN(H264_MAX_THREADS, VAR_0->mb_height);
else
VAR_4 = H264_MAX_THREADS;
av_log(VAR_0->avctx, AV_LOG_WARNING, "too many threads/slices %d,"
" reducing to %d\n", VAR_1, VAR_4);
VAR_1 = VAR_4;
}
VAR_0->slice_context_count = VAR_1;
if (!HAVE_THREADS || !(VAR_0->avctx->active_thread_type & FF_THREAD_SLICE)) {
VAR_3 = ff_h264_slice_context_init(VAR_0, &VAR_0->slice_ctx[0]);
if (VAR_3 < 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "context_init() failed.\n");
return VAR_3;
}
} else {
for (VAR_2 = 0; VAR_2 < VAR_0->slice_context_count; VAR_2++) {
H264SliceContext *sl = &VAR_0->slice_ctx[VAR_2];
sl->h264 = VAR_0;
sl->intra4x4_pred_mode = VAR_0->intra4x4_pred_mode + VAR_2 * 8 * 2 * VAR_0->mb_stride;
sl->mvd_table[0] = VAR_0->mvd_table[0] + VAR_2 * 8 * 2 * VAR_0->mb_stride;
sl->mvd_table[1] = VAR_0->mvd_table[1] + VAR_2 * 8 * 2 * VAR_0->mb_stride;
if ((VAR_3 = ff_h264_slice_context_init(VAR_0, sl)) < 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "context_init() failed.\n");
return VAR_3;
}
}
}
VAR_0->context_initialized = 1;
return 0;
}
| [
"static int FUNC_0(H264Context *VAR_0)\n{",
"int VAR_1 = (HAVE_THREADS &&\nVAR_0->avctx->active_thread_type & FF_THREAD_SLICE) ?\nVAR_0->avctx->thread_count : 1;",
"int VAR_2, VAR_3;",
"ff_set_sar(VAR_0->avctx, VAR_0->sps.sar);",
"av_pix_fmt_get_chroma_sub_sample(VAR_0->avctx->pix_fmt,\n&VAR_0->chroma_x_shift, &VAR_0->chroma_y_shift);",
"if (VAR_0->sps.timing_info_present_flag) {",
"int64_t den = VAR_0->sps.time_scale;",
"if (VAR_0->x264_build < 44U)\nden *= 2;",
"av_reduce(&VAR_0->avctx->framerate.den, &VAR_0->avctx->framerate.num,\nVAR_0->sps.num_units_in_tick, den, 1 << 30);",
"}",
"ff_h264_free_tables(VAR_0);",
"VAR_0->first_field = 0;",
"VAR_0->prev_interlaced_frame = 1;",
"init_scan_tables(VAR_0);",
"VAR_3 = ff_h264_alloc_tables(VAR_0);",
"if (VAR_3 < 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Could not allocate memory\\n\");",
"return VAR_3;",
"}",
"if (VAR_0->sps.bit_depth_luma < 8 || VAR_0->sps.bit_depth_luma > 10) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Unsupported bit depth %d\\n\",\nVAR_0->sps.bit_depth_luma);",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_0->avctx->bits_per_raw_sample = VAR_0->sps.bit_depth_luma;",
"VAR_0->pixel_shift = VAR_0->sps.bit_depth_luma > 8;",
"VAR_0->chroma_format_idc = VAR_0->sps.chroma_format_idc;",
"VAR_0->bit_depth_luma = VAR_0->sps.bit_depth_luma;",
"ff_h264dsp_init(&VAR_0->h264dsp, VAR_0->sps.bit_depth_luma,\nVAR_0->sps.chroma_format_idc);",
"ff_h264chroma_init(&VAR_0->h264chroma, VAR_0->sps.bit_depth_chroma);",
"ff_h264qpel_init(&VAR_0->h264qpel, VAR_0->sps.bit_depth_luma);",
"ff_h264_pred_init(&VAR_0->hpc, VAR_0->avctx->codec_id, VAR_0->sps.bit_depth_luma,\nVAR_0->sps.chroma_format_idc);",
"ff_videodsp_init(&VAR_0->vdsp, VAR_0->sps.bit_depth_luma);",
"if (VAR_1 > H264_MAX_THREADS || (VAR_1 > VAR_0->mb_height && VAR_0->mb_height)) {",
"int VAR_4;",
"if (VAR_0->mb_height)\nVAR_4 = FFMIN(H264_MAX_THREADS, VAR_0->mb_height);",
"else\nVAR_4 = H264_MAX_THREADS;",
"av_log(VAR_0->avctx, AV_LOG_WARNING, \"too many threads/slices %d,\"\n\" reducing to %d\\n\", VAR_1, VAR_4);",
"VAR_1 = VAR_4;",
"}",
"VAR_0->slice_context_count = VAR_1;",
"if (!HAVE_THREADS || !(VAR_0->avctx->active_thread_type & FF_THREAD_SLICE)) {",
"VAR_3 = ff_h264_slice_context_init(VAR_0, &VAR_0->slice_ctx[0]);",
"if (VAR_3 < 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"context_init() failed.\\n\");",
"return VAR_3;",
"}",
"} else {",
"for (VAR_2 = 0; VAR_2 < VAR_0->slice_context_count; VAR_2++) {",
"H264SliceContext *sl = &VAR_0->slice_ctx[VAR_2];",
"sl->h264 = VAR_0;",
"sl->intra4x4_pred_mode = VAR_0->intra4x4_pred_mode + VAR_2 * 8 * 2 * VAR_0->mb_stride;",
"sl->mvd_table[0] = VAR_0->mvd_table[0] + VAR_2 * 8 * 2 * VAR_0->mb_stride;",
"sl->mvd_table[1] = VAR_0->mvd_table[1] + VAR_2 * 8 * 2 * VAR_0->mb_stride;",
"if ((VAR_3 = ff_h264_slice_context_init(VAR_0, sl)) < 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"context_init() failed.\\n\");",
"return VAR_3;",
"}",
"}",
"}",
"VAR_0->context_initialized = 1;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7,
9
],
[
11
],
[
15
],
[
17,
19
],
[
23
],
[
25
],
[
27,
29
],
[
31,
33
],
[
35
],
[
39
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85,
87
],
[
89
],
[
91
],
[
93,
95
],
[
97
],
[
101
],
[
103
],
[
105,
107
],
[
109,
111
],
[
113,
115
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169
],
[
173
],
[
175
]
] |
27,098 | int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx)
{
int i, ret;
Picture *pic;
s->mb_skipped = 0;
/* mark & release old frames */
if (s->pict_type != AV_PICTURE_TYPE_B && s->last_picture_ptr &&
s->last_picture_ptr != s->next_picture_ptr &&
s->last_picture_ptr->f->buf[0]) {
ff_mpeg_unref_picture(s->avctx, s->last_picture_ptr);
}
/* release forgotten pictures */
/* if (MPEG-124 / H.263) */
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
if (&s->picture[i] != s->last_picture_ptr &&
&s->picture[i] != s->next_picture_ptr &&
s->picture[i].reference && !s->picture[i].needs_realloc) {
ff_mpeg_unref_picture(s->avctx, &s->picture[i]);
}
}
ff_mpeg_unref_picture(s->avctx, &s->current_picture);
/* release non reference frames */
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
if (!s->picture[i].reference)
ff_mpeg_unref_picture(s->avctx, &s->picture[i]);
}
if (s->current_picture_ptr && !s->current_picture_ptr->f->buf[0]) {
// we already have a unused image
// (maybe it was set before reading the header)
pic = s->current_picture_ptr;
} else {
i = ff_find_unused_picture(s->avctx, s->picture, 0);
if (i < 0) {
av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n");
return i;
}
pic = &s->picture[i];
}
pic->reference = 0;
if (!s->droppable) {
if (s->pict_type != AV_PICTURE_TYPE_B)
pic->reference = 3;
}
pic->f->coded_picture_number = s->coded_picture_number++;
if (alloc_picture(s, pic, 0) < 0)
return -1;
s->current_picture_ptr = pic;
// FIXME use only the vars from current_pic
s->current_picture_ptr->f->top_field_first = s->top_field_first;
if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO ||
s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
if (s->picture_structure != PICT_FRAME)
s->current_picture_ptr->f->top_field_first =
(s->picture_structure == PICT_TOP_FIELD) == s->first_field;
}
s->current_picture_ptr->f->interlaced_frame = !s->progressive_frame &&
!s->progressive_sequence;
s->current_picture_ptr->field_picture = s->picture_structure != PICT_FRAME;
s->current_picture_ptr->f->pict_type = s->pict_type;
// if (s->avctx->flags && AV_CODEC_FLAG_QSCALE)
// s->current_picture_ptr->quality = s->new_picture_ptr->quality;
s->current_picture_ptr->f->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
if ((ret = ff_mpeg_ref_picture(s->avctx, &s->current_picture,
s->current_picture_ptr)) < 0)
return ret;
if (s->pict_type != AV_PICTURE_TYPE_B) {
s->last_picture_ptr = s->next_picture_ptr;
if (!s->droppable)
s->next_picture_ptr = s->current_picture_ptr;
}
ff_dlog(s->avctx, "L%p N%p C%p L%p N%p C%p type:%d drop:%d\n",
s->last_picture_ptr, s->next_picture_ptr,s->current_picture_ptr,
s->last_picture_ptr ? s->last_picture_ptr->f->data[0] : NULL,
s->next_picture_ptr ? s->next_picture_ptr->f->data[0] : NULL,
s->current_picture_ptr ? s->current_picture_ptr->f->data[0] : NULL,
s->pict_type, s->droppable);
if ((!s->last_picture_ptr || !s->last_picture_ptr->f->buf[0]) &&
(s->pict_type != AV_PICTURE_TYPE_I ||
s->picture_structure != PICT_FRAME)) {
int h_chroma_shift, v_chroma_shift;
av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt,
&h_chroma_shift, &v_chroma_shift);
if (s->pict_type != AV_PICTURE_TYPE_I)
av_log(avctx, AV_LOG_ERROR,
"warning: first frame is no keyframe\n");
else if (s->picture_structure != PICT_FRAME)
av_log(avctx, AV_LOG_INFO,
"allocate dummy last picture for field based first keyframe\n");
/* Allocate a dummy frame */
i = ff_find_unused_picture(s->avctx, s->picture, 0);
if (i < 0) {
av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n");
return i;
}
s->last_picture_ptr = &s->picture[i];
s->last_picture_ptr->reference = 3;
s->last_picture_ptr->f->pict_type = AV_PICTURE_TYPE_I;
if (alloc_picture(s, s->last_picture_ptr, 0) < 0) {
s->last_picture_ptr = NULL;
return -1;
}
memset(s->last_picture_ptr->f->data[0], 0,
avctx->height * s->last_picture_ptr->f->linesize[0]);
memset(s->last_picture_ptr->f->data[1], 0x80,
(avctx->height >> v_chroma_shift) *
s->last_picture_ptr->f->linesize[1]);
memset(s->last_picture_ptr->f->data[2], 0x80,
(avctx->height >> v_chroma_shift) *
s->last_picture_ptr->f->linesize[2]);
ff_thread_report_progress(&s->last_picture_ptr->tf, INT_MAX, 0);
ff_thread_report_progress(&s->last_picture_ptr->tf, INT_MAX, 1);
}
if ((!s->next_picture_ptr || !s->next_picture_ptr->f->buf[0]) &&
s->pict_type == AV_PICTURE_TYPE_B) {
/* Allocate a dummy frame */
i = ff_find_unused_picture(s->avctx, s->picture, 0);
if (i < 0) {
av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n");
return i;
}
s->next_picture_ptr = &s->picture[i];
s->next_picture_ptr->reference = 3;
s->next_picture_ptr->f->pict_type = AV_PICTURE_TYPE_I;
if (alloc_picture(s, s->next_picture_ptr, 0) < 0) {
s->next_picture_ptr = NULL;
return -1;
}
ff_thread_report_progress(&s->next_picture_ptr->tf, INT_MAX, 0);
ff_thread_report_progress(&s->next_picture_ptr->tf, INT_MAX, 1);
}
if (s->last_picture_ptr) {
ff_mpeg_unref_picture(s->avctx, &s->last_picture);
if (s->last_picture_ptr->f->buf[0] &&
(ret = ff_mpeg_ref_picture(s->avctx, &s->last_picture,
s->last_picture_ptr)) < 0)
return ret;
}
if (s->next_picture_ptr) {
ff_mpeg_unref_picture(s->avctx, &s->next_picture);
if (s->next_picture_ptr->f->buf[0] &&
(ret = ff_mpeg_ref_picture(s->avctx, &s->next_picture,
s->next_picture_ptr)) < 0)
return ret;
}
if (s->pict_type != AV_PICTURE_TYPE_I &&
!(s->last_picture_ptr && s->last_picture_ptr->f->buf[0])) {
av_log(s, AV_LOG_ERROR,
"Non-reference picture received and no reference available\n");
return AVERROR_INVALIDDATA;
}
if (s->picture_structure!= PICT_FRAME) {
int i;
for (i = 0; i < 4; i++) {
if (s->picture_structure == PICT_BOTTOM_FIELD) {
s->current_picture.f->data[i] +=
s->current_picture.f->linesize[i];
}
s->current_picture.f->linesize[i] *= 2;
s->last_picture.f->linesize[i] *= 2;
s->next_picture.f->linesize[i] *= 2;
}
}
/* set dequantizer, we can't do it during init as
* it might change for MPEG-4 and we can't do it in the header
* decode as init is not called for MPEG-4 there yet */
if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra;
s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter;
} else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) {
s->dct_unquantize_intra = s->dct_unquantize_h263_intra;
s->dct_unquantize_inter = s->dct_unquantize_h263_inter;
} else {
s->dct_unquantize_intra = s->dct_unquantize_mpeg1_intra;
s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter;
}
#if FF_API_XVMC
FF_DISABLE_DEPRECATION_WARNINGS
if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)
return ff_xvmc_field_start(s, avctx);
FF_ENABLE_DEPRECATION_WARNINGS
#endif /* FF_API_XVMC */
return 0;
}
| false | FFmpeg | dcc39ee10e82833ce24aa57926c00ffeb1948198 | int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx)
{
int i, ret;
Picture *pic;
s->mb_skipped = 0;
if (s->pict_type != AV_PICTURE_TYPE_B && s->last_picture_ptr &&
s->last_picture_ptr != s->next_picture_ptr &&
s->last_picture_ptr->f->buf[0]) {
ff_mpeg_unref_picture(s->avctx, s->last_picture_ptr);
}
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
if (&s->picture[i] != s->last_picture_ptr &&
&s->picture[i] != s->next_picture_ptr &&
s->picture[i].reference && !s->picture[i].needs_realloc) {
ff_mpeg_unref_picture(s->avctx, &s->picture[i]);
}
}
ff_mpeg_unref_picture(s->avctx, &s->current_picture);
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
if (!s->picture[i].reference)
ff_mpeg_unref_picture(s->avctx, &s->picture[i]);
}
if (s->current_picture_ptr && !s->current_picture_ptr->f->buf[0]) {
pic = s->current_picture_ptr;
} else {
i = ff_find_unused_picture(s->avctx, s->picture, 0);
if (i < 0) {
av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n");
return i;
}
pic = &s->picture[i];
}
pic->reference = 0;
if (!s->droppable) {
if (s->pict_type != AV_PICTURE_TYPE_B)
pic->reference = 3;
}
pic->f->coded_picture_number = s->coded_picture_number++;
if (alloc_picture(s, pic, 0) < 0)
return -1;
s->current_picture_ptr = pic;
s->current_picture_ptr->f->top_field_first = s->top_field_first;
if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO ||
s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
if (s->picture_structure != PICT_FRAME)
s->current_picture_ptr->f->top_field_first =
(s->picture_structure == PICT_TOP_FIELD) == s->first_field;
}
s->current_picture_ptr->f->interlaced_frame = !s->progressive_frame &&
!s->progressive_sequence;
s->current_picture_ptr->field_picture = s->picture_structure != PICT_FRAME;
s->current_picture_ptr->f->pict_type = s->pict_type;
s->current_picture_ptr->f->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
if ((ret = ff_mpeg_ref_picture(s->avctx, &s->current_picture,
s->current_picture_ptr)) < 0)
return ret;
if (s->pict_type != AV_PICTURE_TYPE_B) {
s->last_picture_ptr = s->next_picture_ptr;
if (!s->droppable)
s->next_picture_ptr = s->current_picture_ptr;
}
ff_dlog(s->avctx, "L%p N%p C%p L%p N%p C%p type:%d drop:%d\n",
s->last_picture_ptr, s->next_picture_ptr,s->current_picture_ptr,
s->last_picture_ptr ? s->last_picture_ptr->f->data[0] : NULL,
s->next_picture_ptr ? s->next_picture_ptr->f->data[0] : NULL,
s->current_picture_ptr ? s->current_picture_ptr->f->data[0] : NULL,
s->pict_type, s->droppable);
if ((!s->last_picture_ptr || !s->last_picture_ptr->f->buf[0]) &&
(s->pict_type != AV_PICTURE_TYPE_I ||
s->picture_structure != PICT_FRAME)) {
int h_chroma_shift, v_chroma_shift;
av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt,
&h_chroma_shift, &v_chroma_shift);
if (s->pict_type != AV_PICTURE_TYPE_I)
av_log(avctx, AV_LOG_ERROR,
"warning: first frame is no keyframe\n");
else if (s->picture_structure != PICT_FRAME)
av_log(avctx, AV_LOG_INFO,
"allocate dummy last picture for field based first keyframe\n");
i = ff_find_unused_picture(s->avctx, s->picture, 0);
if (i < 0) {
av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n");
return i;
}
s->last_picture_ptr = &s->picture[i];
s->last_picture_ptr->reference = 3;
s->last_picture_ptr->f->pict_type = AV_PICTURE_TYPE_I;
if (alloc_picture(s, s->last_picture_ptr, 0) < 0) {
s->last_picture_ptr = NULL;
return -1;
}
memset(s->last_picture_ptr->f->data[0], 0,
avctx->height * s->last_picture_ptr->f->linesize[0]);
memset(s->last_picture_ptr->f->data[1], 0x80,
(avctx->height >> v_chroma_shift) *
s->last_picture_ptr->f->linesize[1]);
memset(s->last_picture_ptr->f->data[2], 0x80,
(avctx->height >> v_chroma_shift) *
s->last_picture_ptr->f->linesize[2]);
ff_thread_report_progress(&s->last_picture_ptr->tf, INT_MAX, 0);
ff_thread_report_progress(&s->last_picture_ptr->tf, INT_MAX, 1);
}
if ((!s->next_picture_ptr || !s->next_picture_ptr->f->buf[0]) &&
s->pict_type == AV_PICTURE_TYPE_B) {
i = ff_find_unused_picture(s->avctx, s->picture, 0);
if (i < 0) {
av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n");
return i;
}
s->next_picture_ptr = &s->picture[i];
s->next_picture_ptr->reference = 3;
s->next_picture_ptr->f->pict_type = AV_PICTURE_TYPE_I;
if (alloc_picture(s, s->next_picture_ptr, 0) < 0) {
s->next_picture_ptr = NULL;
return -1;
}
ff_thread_report_progress(&s->next_picture_ptr->tf, INT_MAX, 0);
ff_thread_report_progress(&s->next_picture_ptr->tf, INT_MAX, 1);
}
if (s->last_picture_ptr) {
ff_mpeg_unref_picture(s->avctx, &s->last_picture);
if (s->last_picture_ptr->f->buf[0] &&
(ret = ff_mpeg_ref_picture(s->avctx, &s->last_picture,
s->last_picture_ptr)) < 0)
return ret;
}
if (s->next_picture_ptr) {
ff_mpeg_unref_picture(s->avctx, &s->next_picture);
if (s->next_picture_ptr->f->buf[0] &&
(ret = ff_mpeg_ref_picture(s->avctx, &s->next_picture,
s->next_picture_ptr)) < 0)
return ret;
}
if (s->pict_type != AV_PICTURE_TYPE_I &&
!(s->last_picture_ptr && s->last_picture_ptr->f->buf[0])) {
av_log(s, AV_LOG_ERROR,
"Non-reference picture received and no reference available\n");
return AVERROR_INVALIDDATA;
}
if (s->picture_structure!= PICT_FRAME) {
int i;
for (i = 0; i < 4; i++) {
if (s->picture_structure == PICT_BOTTOM_FIELD) {
s->current_picture.f->data[i] +=
s->current_picture.f->linesize[i];
}
s->current_picture.f->linesize[i] *= 2;
s->last_picture.f->linesize[i] *= 2;
s->next_picture.f->linesize[i] *= 2;
}
}
if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra;
s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter;
} else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) {
s->dct_unquantize_intra = s->dct_unquantize_h263_intra;
s->dct_unquantize_inter = s->dct_unquantize_h263_inter;
} else {
s->dct_unquantize_intra = s->dct_unquantize_mpeg1_intra;
s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter;
}
#if FF_API_XVMC
FF_DISABLE_DEPRECATION_WARNINGS
if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)
return ff_xvmc_field_start(s, avctx);
FF_ENABLE_DEPRECATION_WARNINGS
#endif
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(MpegEncContext *VAR_0, AVCodecContext *VAR_1)
{
int VAR_6, VAR_3;
Picture *pic;
VAR_0->mb_skipped = 0;
if (VAR_0->pict_type != AV_PICTURE_TYPE_B && VAR_0->last_picture_ptr &&
VAR_0->last_picture_ptr != VAR_0->next_picture_ptr &&
VAR_0->last_picture_ptr->f->buf[0]) {
ff_mpeg_unref_picture(VAR_0->VAR_1, VAR_0->last_picture_ptr);
}
for (VAR_6 = 0; VAR_6 < MAX_PICTURE_COUNT; VAR_6++) {
if (&VAR_0->picture[VAR_6] != VAR_0->last_picture_ptr &&
&VAR_0->picture[VAR_6] != VAR_0->next_picture_ptr &&
VAR_0->picture[VAR_6].reference && !VAR_0->picture[VAR_6].needs_realloc) {
ff_mpeg_unref_picture(VAR_0->VAR_1, &VAR_0->picture[VAR_6]);
}
}
ff_mpeg_unref_picture(VAR_0->VAR_1, &VAR_0->current_picture);
for (VAR_6 = 0; VAR_6 < MAX_PICTURE_COUNT; VAR_6++) {
if (!VAR_0->picture[VAR_6].reference)
ff_mpeg_unref_picture(VAR_0->VAR_1, &VAR_0->picture[VAR_6]);
}
if (VAR_0->current_picture_ptr && !VAR_0->current_picture_ptr->f->buf[0]) {
pic = VAR_0->current_picture_ptr;
} else {
VAR_6 = ff_find_unused_picture(VAR_0->VAR_1, VAR_0->picture, 0);
if (VAR_6 < 0) {
av_log(VAR_0->VAR_1, AV_LOG_ERROR, "no frame buffer available\n");
return VAR_6;
}
pic = &VAR_0->picture[VAR_6];
}
pic->reference = 0;
if (!VAR_0->droppable) {
if (VAR_0->pict_type != AV_PICTURE_TYPE_B)
pic->reference = 3;
}
pic->f->coded_picture_number = VAR_0->coded_picture_number++;
if (alloc_picture(VAR_0, pic, 0) < 0)
return -1;
VAR_0->current_picture_ptr = pic;
VAR_0->current_picture_ptr->f->top_field_first = VAR_0->top_field_first;
if (VAR_0->codec_id == AV_CODEC_ID_MPEG1VIDEO ||
VAR_0->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
if (VAR_0->picture_structure != PICT_FRAME)
VAR_0->current_picture_ptr->f->top_field_first =
(VAR_0->picture_structure == PICT_TOP_FIELD) == VAR_0->first_field;
}
VAR_0->current_picture_ptr->f->interlaced_frame = !VAR_0->progressive_frame &&
!VAR_0->progressive_sequence;
VAR_0->current_picture_ptr->field_picture = VAR_0->picture_structure != PICT_FRAME;
VAR_0->current_picture_ptr->f->pict_type = VAR_0->pict_type;
VAR_0->current_picture_ptr->f->key_frame = VAR_0->pict_type == AV_PICTURE_TYPE_I;
if ((VAR_3 = ff_mpeg_ref_picture(VAR_0->VAR_1, &VAR_0->current_picture,
VAR_0->current_picture_ptr)) < 0)
return VAR_3;
if (VAR_0->pict_type != AV_PICTURE_TYPE_B) {
VAR_0->last_picture_ptr = VAR_0->next_picture_ptr;
if (!VAR_0->droppable)
VAR_0->next_picture_ptr = VAR_0->current_picture_ptr;
}
ff_dlog(VAR_0->VAR_1, "L%p N%p C%p L%p N%p C%p type:%d drop:%d\n",
VAR_0->last_picture_ptr, VAR_0->next_picture_ptr,VAR_0->current_picture_ptr,
VAR_0->last_picture_ptr ? VAR_0->last_picture_ptr->f->data[0] : NULL,
VAR_0->next_picture_ptr ? VAR_0->next_picture_ptr->f->data[0] : NULL,
VAR_0->current_picture_ptr ? VAR_0->current_picture_ptr->f->data[0] : NULL,
VAR_0->pict_type, VAR_0->droppable);
if ((!VAR_0->last_picture_ptr || !VAR_0->last_picture_ptr->f->buf[0]) &&
(VAR_0->pict_type != AV_PICTURE_TYPE_I ||
VAR_0->picture_structure != PICT_FRAME)) {
int VAR_4, VAR_5;
av_pix_fmt_get_chroma_sub_sample(VAR_0->VAR_1->pix_fmt,
&VAR_4, &VAR_5);
if (VAR_0->pict_type != AV_PICTURE_TYPE_I)
av_log(VAR_1, AV_LOG_ERROR,
"warning: first frame is no keyframe\n");
else if (VAR_0->picture_structure != PICT_FRAME)
av_log(VAR_1, AV_LOG_INFO,
"allocate dummy last picture for field based first keyframe\n");
VAR_6 = ff_find_unused_picture(VAR_0->VAR_1, VAR_0->picture, 0);
if (VAR_6 < 0) {
av_log(VAR_0->VAR_1, AV_LOG_ERROR, "no frame buffer available\n");
return VAR_6;
}
VAR_0->last_picture_ptr = &VAR_0->picture[VAR_6];
VAR_0->last_picture_ptr->reference = 3;
VAR_0->last_picture_ptr->f->pict_type = AV_PICTURE_TYPE_I;
if (alloc_picture(VAR_0, VAR_0->last_picture_ptr, 0) < 0) {
VAR_0->last_picture_ptr = NULL;
return -1;
}
memset(VAR_0->last_picture_ptr->f->data[0], 0,
VAR_1->height * VAR_0->last_picture_ptr->f->linesize[0]);
memset(VAR_0->last_picture_ptr->f->data[1], 0x80,
(VAR_1->height >> VAR_5) *
VAR_0->last_picture_ptr->f->linesize[1]);
memset(VAR_0->last_picture_ptr->f->data[2], 0x80,
(VAR_1->height >> VAR_5) *
VAR_0->last_picture_ptr->f->linesize[2]);
ff_thread_report_progress(&VAR_0->last_picture_ptr->tf, INT_MAX, 0);
ff_thread_report_progress(&VAR_0->last_picture_ptr->tf, INT_MAX, 1);
}
if ((!VAR_0->next_picture_ptr || !VAR_0->next_picture_ptr->f->buf[0]) &&
VAR_0->pict_type == AV_PICTURE_TYPE_B) {
VAR_6 = ff_find_unused_picture(VAR_0->VAR_1, VAR_0->picture, 0);
if (VAR_6 < 0) {
av_log(VAR_0->VAR_1, AV_LOG_ERROR, "no frame buffer available\n");
return VAR_6;
}
VAR_0->next_picture_ptr = &VAR_0->picture[VAR_6];
VAR_0->next_picture_ptr->reference = 3;
VAR_0->next_picture_ptr->f->pict_type = AV_PICTURE_TYPE_I;
if (alloc_picture(VAR_0, VAR_0->next_picture_ptr, 0) < 0) {
VAR_0->next_picture_ptr = NULL;
return -1;
}
ff_thread_report_progress(&VAR_0->next_picture_ptr->tf, INT_MAX, 0);
ff_thread_report_progress(&VAR_0->next_picture_ptr->tf, INT_MAX, 1);
}
if (VAR_0->last_picture_ptr) {
ff_mpeg_unref_picture(VAR_0->VAR_1, &VAR_0->last_picture);
if (VAR_0->last_picture_ptr->f->buf[0] &&
(VAR_3 = ff_mpeg_ref_picture(VAR_0->VAR_1, &VAR_0->last_picture,
VAR_0->last_picture_ptr)) < 0)
return VAR_3;
}
if (VAR_0->next_picture_ptr) {
ff_mpeg_unref_picture(VAR_0->VAR_1, &VAR_0->next_picture);
if (VAR_0->next_picture_ptr->f->buf[0] &&
(VAR_3 = ff_mpeg_ref_picture(VAR_0->VAR_1, &VAR_0->next_picture,
VAR_0->next_picture_ptr)) < 0)
return VAR_3;
}
if (VAR_0->pict_type != AV_PICTURE_TYPE_I &&
!(VAR_0->last_picture_ptr && VAR_0->last_picture_ptr->f->buf[0])) {
av_log(VAR_0, AV_LOG_ERROR,
"Non-reference picture received and no reference available\n");
return AVERROR_INVALIDDATA;
}
if (VAR_0->picture_structure!= PICT_FRAME) {
int VAR_6;
for (VAR_6 = 0; VAR_6 < 4; VAR_6++) {
if (VAR_0->picture_structure == PICT_BOTTOM_FIELD) {
VAR_0->current_picture.f->data[VAR_6] +=
VAR_0->current_picture.f->linesize[VAR_6];
}
VAR_0->current_picture.f->linesize[VAR_6] *= 2;
VAR_0->last_picture.f->linesize[VAR_6] *= 2;
VAR_0->next_picture.f->linesize[VAR_6] *= 2;
}
}
if (VAR_0->mpeg_quant || VAR_0->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
VAR_0->dct_unquantize_intra = VAR_0->dct_unquantize_mpeg2_intra;
VAR_0->dct_unquantize_inter = VAR_0->dct_unquantize_mpeg2_inter;
} else if (VAR_0->out_format == FMT_H263 || VAR_0->out_format == FMT_H261) {
VAR_0->dct_unquantize_intra = VAR_0->dct_unquantize_h263_intra;
VAR_0->dct_unquantize_inter = VAR_0->dct_unquantize_h263_inter;
} else {
VAR_0->dct_unquantize_intra = VAR_0->dct_unquantize_mpeg1_intra;
VAR_0->dct_unquantize_inter = VAR_0->dct_unquantize_mpeg1_inter;
}
#if FF_API_XVMC
FF_DISABLE_DEPRECATION_WARNINGS
if (CONFIG_MPEG_XVMC_DECODER && VAR_0->VAR_1->xvmc_acceleration)
return ff_xvmc_field_start(VAR_0, VAR_1);
FF_ENABLE_DEPRECATION_WARNINGS
#endif
return 0;
}
| [
"int FUNC_0(MpegEncContext *VAR_0, AVCodecContext *VAR_1)\n{",
"int VAR_6, VAR_3;",
"Picture *pic;",
"VAR_0->mb_skipped = 0;",
"if (VAR_0->pict_type != AV_PICTURE_TYPE_B && VAR_0->last_picture_ptr &&\nVAR_0->last_picture_ptr != VAR_0->next_picture_ptr &&\nVAR_0->last_picture_ptr->f->buf[0]) {",
"ff_mpeg_unref_picture(VAR_0->VAR_1, VAR_0->last_picture_ptr);",
"}",
"for (VAR_6 = 0; VAR_6 < MAX_PICTURE_COUNT; VAR_6++) {",
"if (&VAR_0->picture[VAR_6] != VAR_0->last_picture_ptr &&\n&VAR_0->picture[VAR_6] != VAR_0->next_picture_ptr &&\nVAR_0->picture[VAR_6].reference && !VAR_0->picture[VAR_6].needs_realloc) {",
"ff_mpeg_unref_picture(VAR_0->VAR_1, &VAR_0->picture[VAR_6]);",
"}",
"}",
"ff_mpeg_unref_picture(VAR_0->VAR_1, &VAR_0->current_picture);",
"for (VAR_6 = 0; VAR_6 < MAX_PICTURE_COUNT; VAR_6++) {",
"if (!VAR_0->picture[VAR_6].reference)\nff_mpeg_unref_picture(VAR_0->VAR_1, &VAR_0->picture[VAR_6]);",
"}",
"if (VAR_0->current_picture_ptr && !VAR_0->current_picture_ptr->f->buf[0]) {",
"pic = VAR_0->current_picture_ptr;",
"} else {",
"VAR_6 = ff_find_unused_picture(VAR_0->VAR_1, VAR_0->picture, 0);",
"if (VAR_6 < 0) {",
"av_log(VAR_0->VAR_1, AV_LOG_ERROR, \"no frame buffer available\\n\");",
"return VAR_6;",
"}",
"pic = &VAR_0->picture[VAR_6];",
"}",
"pic->reference = 0;",
"if (!VAR_0->droppable) {",
"if (VAR_0->pict_type != AV_PICTURE_TYPE_B)\npic->reference = 3;",
"}",
"pic->f->coded_picture_number = VAR_0->coded_picture_number++;",
"if (alloc_picture(VAR_0, pic, 0) < 0)\nreturn -1;",
"VAR_0->current_picture_ptr = pic;",
"VAR_0->current_picture_ptr->f->top_field_first = VAR_0->top_field_first;",
"if (VAR_0->codec_id == AV_CODEC_ID_MPEG1VIDEO ||\nVAR_0->codec_id == AV_CODEC_ID_MPEG2VIDEO) {",
"if (VAR_0->picture_structure != PICT_FRAME)\nVAR_0->current_picture_ptr->f->top_field_first =\n(VAR_0->picture_structure == PICT_TOP_FIELD) == VAR_0->first_field;",
"}",
"VAR_0->current_picture_ptr->f->interlaced_frame = !VAR_0->progressive_frame &&\n!VAR_0->progressive_sequence;",
"VAR_0->current_picture_ptr->field_picture = VAR_0->picture_structure != PICT_FRAME;",
"VAR_0->current_picture_ptr->f->pict_type = VAR_0->pict_type;",
"VAR_0->current_picture_ptr->f->key_frame = VAR_0->pict_type == AV_PICTURE_TYPE_I;",
"if ((VAR_3 = ff_mpeg_ref_picture(VAR_0->VAR_1, &VAR_0->current_picture,\nVAR_0->current_picture_ptr)) < 0)\nreturn VAR_3;",
"if (VAR_0->pict_type != AV_PICTURE_TYPE_B) {",
"VAR_0->last_picture_ptr = VAR_0->next_picture_ptr;",
"if (!VAR_0->droppable)\nVAR_0->next_picture_ptr = VAR_0->current_picture_ptr;",
"}",
"ff_dlog(VAR_0->VAR_1, \"L%p N%p C%p L%p N%p C%p type:%d drop:%d\\n\",\nVAR_0->last_picture_ptr, VAR_0->next_picture_ptr,VAR_0->current_picture_ptr,\nVAR_0->last_picture_ptr ? VAR_0->last_picture_ptr->f->data[0] : NULL,\nVAR_0->next_picture_ptr ? VAR_0->next_picture_ptr->f->data[0] : NULL,\nVAR_0->current_picture_ptr ? VAR_0->current_picture_ptr->f->data[0] : NULL,\nVAR_0->pict_type, VAR_0->droppable);",
"if ((!VAR_0->last_picture_ptr || !VAR_0->last_picture_ptr->f->buf[0]) &&\n(VAR_0->pict_type != AV_PICTURE_TYPE_I ||\nVAR_0->picture_structure != PICT_FRAME)) {",
"int VAR_4, VAR_5;",
"av_pix_fmt_get_chroma_sub_sample(VAR_0->VAR_1->pix_fmt,\n&VAR_4, &VAR_5);",
"if (VAR_0->pict_type != AV_PICTURE_TYPE_I)\nav_log(VAR_1, AV_LOG_ERROR,\n\"warning: first frame is no keyframe\\n\");",
"else if (VAR_0->picture_structure != PICT_FRAME)\nav_log(VAR_1, AV_LOG_INFO,\n\"allocate dummy last picture for field based first keyframe\\n\");",
"VAR_6 = ff_find_unused_picture(VAR_0->VAR_1, VAR_0->picture, 0);",
"if (VAR_6 < 0) {",
"av_log(VAR_0->VAR_1, AV_LOG_ERROR, \"no frame buffer available\\n\");",
"return VAR_6;",
"}",
"VAR_0->last_picture_ptr = &VAR_0->picture[VAR_6];",
"VAR_0->last_picture_ptr->reference = 3;",
"VAR_0->last_picture_ptr->f->pict_type = AV_PICTURE_TYPE_I;",
"if (alloc_picture(VAR_0, VAR_0->last_picture_ptr, 0) < 0) {",
"VAR_0->last_picture_ptr = NULL;",
"return -1;",
"}",
"memset(VAR_0->last_picture_ptr->f->data[0], 0,\nVAR_1->height * VAR_0->last_picture_ptr->f->linesize[0]);",
"memset(VAR_0->last_picture_ptr->f->data[1], 0x80,\n(VAR_1->height >> VAR_5) *\nVAR_0->last_picture_ptr->f->linesize[1]);",
"memset(VAR_0->last_picture_ptr->f->data[2], 0x80,\n(VAR_1->height >> VAR_5) *\nVAR_0->last_picture_ptr->f->linesize[2]);",
"ff_thread_report_progress(&VAR_0->last_picture_ptr->tf, INT_MAX, 0);",
"ff_thread_report_progress(&VAR_0->last_picture_ptr->tf, INT_MAX, 1);",
"}",
"if ((!VAR_0->next_picture_ptr || !VAR_0->next_picture_ptr->f->buf[0]) &&\nVAR_0->pict_type == AV_PICTURE_TYPE_B) {",
"VAR_6 = ff_find_unused_picture(VAR_0->VAR_1, VAR_0->picture, 0);",
"if (VAR_6 < 0) {",
"av_log(VAR_0->VAR_1, AV_LOG_ERROR, \"no frame buffer available\\n\");",
"return VAR_6;",
"}",
"VAR_0->next_picture_ptr = &VAR_0->picture[VAR_6];",
"VAR_0->next_picture_ptr->reference = 3;",
"VAR_0->next_picture_ptr->f->pict_type = AV_PICTURE_TYPE_I;",
"if (alloc_picture(VAR_0, VAR_0->next_picture_ptr, 0) < 0) {",
"VAR_0->next_picture_ptr = NULL;",
"return -1;",
"}",
"ff_thread_report_progress(&VAR_0->next_picture_ptr->tf, INT_MAX, 0);",
"ff_thread_report_progress(&VAR_0->next_picture_ptr->tf, INT_MAX, 1);",
"}",
"if (VAR_0->last_picture_ptr) {",
"ff_mpeg_unref_picture(VAR_0->VAR_1, &VAR_0->last_picture);",
"if (VAR_0->last_picture_ptr->f->buf[0] &&\n(VAR_3 = ff_mpeg_ref_picture(VAR_0->VAR_1, &VAR_0->last_picture,\nVAR_0->last_picture_ptr)) < 0)\nreturn VAR_3;",
"}",
"if (VAR_0->next_picture_ptr) {",
"ff_mpeg_unref_picture(VAR_0->VAR_1, &VAR_0->next_picture);",
"if (VAR_0->next_picture_ptr->f->buf[0] &&\n(VAR_3 = ff_mpeg_ref_picture(VAR_0->VAR_1, &VAR_0->next_picture,\nVAR_0->next_picture_ptr)) < 0)\nreturn VAR_3;",
"}",
"if (VAR_0->pict_type != AV_PICTURE_TYPE_I &&\n!(VAR_0->last_picture_ptr && VAR_0->last_picture_ptr->f->buf[0])) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Non-reference picture received and no reference available\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_0->picture_structure!= PICT_FRAME) {",
"int VAR_6;",
"for (VAR_6 = 0; VAR_6 < 4; VAR_6++) {",
"if (VAR_0->picture_structure == PICT_BOTTOM_FIELD) {",
"VAR_0->current_picture.f->data[VAR_6] +=\nVAR_0->current_picture.f->linesize[VAR_6];",
"}",
"VAR_0->current_picture.f->linesize[VAR_6] *= 2;",
"VAR_0->last_picture.f->linesize[VAR_6] *= 2;",
"VAR_0->next_picture.f->linesize[VAR_6] *= 2;",
"}",
"}",
"if (VAR_0->mpeg_quant || VAR_0->codec_id == AV_CODEC_ID_MPEG2VIDEO) {",
"VAR_0->dct_unquantize_intra = VAR_0->dct_unquantize_mpeg2_intra;",
"VAR_0->dct_unquantize_inter = VAR_0->dct_unquantize_mpeg2_inter;",
"} else if (VAR_0->out_format == FMT_H263 || VAR_0->out_format == FMT_H261) {",
"VAR_0->dct_unquantize_intra = VAR_0->dct_unquantize_h263_intra;",
"VAR_0->dct_unquantize_inter = VAR_0->dct_unquantize_h263_inter;",
"} else {",
"VAR_0->dct_unquantize_intra = VAR_0->dct_unquantize_mpeg1_intra;",
"VAR_0->dct_unquantize_inter = VAR_0->dct_unquantize_mpeg1_inter;",
"}",
"#if FF_API_XVMC\nFF_DISABLE_DEPRECATION_WARNINGS\nif (CONFIG_MPEG_XVMC_DECODER && VAR_0->VAR_1->xvmc_acceleration)\nreturn ff_xvmc_field_start(VAR_0, VAR_1);",
"FF_ENABLE_DEPRECATION_WARNINGS\n#endif\nreturn 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
15,
17,
19
],
[
21
],
[
23
],
[
31
],
[
33,
35,
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
53
],
[
55,
57
],
[
59
],
[
63
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93,
95
],
[
97
],
[
101
],
[
105,
107
],
[
111
],
[
115
],
[
117,
119
],
[
121,
123,
125
],
[
127
],
[
129,
131
],
[
133
],
[
137
],
[
143
],
[
147,
149,
151
],
[
155
],
[
157
],
[
159,
161
],
[
163
],
[
165,
167,
169,
171,
173,
175
],
[
179,
181,
183
],
[
185
],
[
187,
189
],
[
191,
193,
195
],
[
197,
199,
201
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
221
],
[
223
],
[
227
],
[
229
],
[
231
],
[
233
],
[
237,
239
],
[
241,
243,
245
],
[
247,
249,
251
],
[
255
],
[
257
],
[
259
],
[
261,
263
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
281
],
[
283
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
303
],
[
305
],
[
307,
309,
311,
313
],
[
315
],
[
317
],
[
319
],
[
321,
323,
325,
327
],
[
329
],
[
333,
335
],
[
337,
339
],
[
341
],
[
343
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355,
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
401,
403,
405,
407
],
[
409,
411,
415
],
[
417
]
] |
27,099 | static guint io_add_watch_poll(GIOChannel *channel,
IOCanReadHandler *fd_can_read,
GIOFunc fd_read,
gpointer user_data)
{
IOWatchPoll *iwp;
iwp = (IOWatchPoll *) g_source_new(&io_watch_poll_funcs, sizeof(IOWatchPoll));
iwp->fd_can_read = fd_can_read;
iwp->opaque = user_data;
iwp->src = g_io_create_watch(channel, G_IO_IN | G_IO_ERR | G_IO_HUP);
g_source_set_callback(iwp->src, (GSourceFunc)fd_read, user_data, NULL);
return g_source_attach(&iwp->parent, NULL);
}
| false | qemu | 1e885b25275fb6763eb947b1e53b2d6911b967a8 | static guint io_add_watch_poll(GIOChannel *channel,
IOCanReadHandler *fd_can_read,
GIOFunc fd_read,
gpointer user_data)
{
IOWatchPoll *iwp;
iwp = (IOWatchPoll *) g_source_new(&io_watch_poll_funcs, sizeof(IOWatchPoll));
iwp->fd_can_read = fd_can_read;
iwp->opaque = user_data;
iwp->src = g_io_create_watch(channel, G_IO_IN | G_IO_ERR | G_IO_HUP);
g_source_set_callback(iwp->src, (GSourceFunc)fd_read, user_data, NULL);
return g_source_attach(&iwp->parent, NULL);
}
| {
"code": [],
"line_no": []
} | static guint FUNC_0(GIOChannel *channel,
IOCanReadHandler *fd_can_read,
GIOFunc fd_read,
gpointer user_data)
{
IOWatchPoll *iwp;
iwp = (IOWatchPoll *) g_source_new(&io_watch_poll_funcs, sizeof(IOWatchPoll));
iwp->fd_can_read = fd_can_read;
iwp->opaque = user_data;
iwp->src = g_io_create_watch(channel, G_IO_IN | G_IO_ERR | G_IO_HUP);
g_source_set_callback(iwp->src, (GSourceFunc)fd_read, user_data, NULL);
return g_source_attach(&iwp->parent, NULL);
}
| [
"static guint FUNC_0(GIOChannel *channel,\nIOCanReadHandler *fd_can_read,\nGIOFunc fd_read,\ngpointer user_data)\n{",
"IOWatchPoll *iwp;",
"iwp = (IOWatchPoll *) g_source_new(&io_watch_poll_funcs, sizeof(IOWatchPoll));",
"iwp->fd_can_read = fd_can_read;",
"iwp->opaque = user_data;",
"iwp->src = g_io_create_watch(channel, G_IO_IN | G_IO_ERR | G_IO_HUP);",
"g_source_set_callback(iwp->src, (GSourceFunc)fd_read, user_data, NULL);",
"return g_source_attach(&iwp->parent, NULL);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
]
] |
27,101 | int qio_channel_socket_dgram_sync(QIOChannelSocket *ioc,
SocketAddress *localAddr,
SocketAddress *remoteAddr,
Error **errp)
{
int fd;
trace_qio_channel_socket_dgram_sync(ioc, localAddr, remoteAddr);
fd = socket_dgram(remoteAddr, localAddr, errp);
if (fd < 0) {
trace_qio_channel_socket_dgram_fail(ioc);
return -1;
}
trace_qio_channel_socket_dgram_complete(ioc, fd);
if (qio_channel_socket_set_fd(ioc, fd, errp) < 0) {
close(fd);
return -1;
}
return 0;
}
| false | qemu | dfd100f242370886bb6732f70f1f7cbd8eb9fedc | int qio_channel_socket_dgram_sync(QIOChannelSocket *ioc,
SocketAddress *localAddr,
SocketAddress *remoteAddr,
Error **errp)
{
int fd;
trace_qio_channel_socket_dgram_sync(ioc, localAddr, remoteAddr);
fd = socket_dgram(remoteAddr, localAddr, errp);
if (fd < 0) {
trace_qio_channel_socket_dgram_fail(ioc);
return -1;
}
trace_qio_channel_socket_dgram_complete(ioc, fd);
if (qio_channel_socket_set_fd(ioc, fd, errp) < 0) {
close(fd);
return -1;
}
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(QIOChannelSocket *VAR_0,
SocketAddress *VAR_1,
SocketAddress *VAR_2,
Error **VAR_3)
{
int VAR_4;
trace_qio_channel_socket_dgram_sync(VAR_0, VAR_1, VAR_2);
VAR_4 = socket_dgram(VAR_2, VAR_1, VAR_3);
if (VAR_4 < 0) {
trace_qio_channel_socket_dgram_fail(VAR_0);
return -1;
}
trace_qio_channel_socket_dgram_complete(VAR_0, VAR_4);
if (qio_channel_socket_set_fd(VAR_0, VAR_4, VAR_3) < 0) {
close(VAR_4);
return -1;
}
return 0;
}
| [
"int FUNC_0(QIOChannelSocket *VAR_0,\nSocketAddress *VAR_1,\nSocketAddress *VAR_2,\nError **VAR_3)\n{",
"int VAR_4;",
"trace_qio_channel_socket_dgram_sync(VAR_0, VAR_1, VAR_2);",
"VAR_4 = socket_dgram(VAR_2, VAR_1, VAR_3);",
"if (VAR_4 < 0) {",
"trace_qio_channel_socket_dgram_fail(VAR_0);",
"return -1;",
"}",
"trace_qio_channel_socket_dgram_complete(VAR_0, VAR_4);",
"if (qio_channel_socket_set_fd(VAR_0, VAR_4, VAR_3) < 0) {",
"close(VAR_4);",
"return -1;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
]
] |
27,103 | int ff_init_me(MpegEncContext *s){
MotionEstContext * const c= &s->me;
int cache_size= FFMIN(ME_MAP_SIZE>>ME_MAP_SHIFT, 1<<ME_MAP_SHIFT);
int dia_size= FFMAX(FFABS(s->avctx->dia_size)&255, FFABS(s->avctx->pre_dia_size)&255);
if(FFMIN(s->avctx->dia_size, s->avctx->pre_dia_size) < -ME_MAP_SIZE){
av_log(s->avctx, AV_LOG_ERROR, "ME_MAP size is too small for SAB diamond\n");
return -1;
}
//special case of snow is needed because snow uses its own iterative ME code
if(s->me_method!=ME_ZERO && s->me_method!=ME_EPZS && s->me_method!=ME_X1 && s->avctx->codec_id != AV_CODEC_ID_SNOW){
av_log(s->avctx, AV_LOG_ERROR, "me_method is only allowed to be set to zero and epzs; for hex,umh,full and others see dia_size\n");
return -1;
}
c->avctx= s->avctx;
if(cache_size < 2*dia_size && !c->stride){
av_log(s->avctx, AV_LOG_INFO, "ME_MAP size may be a little small for the selected diamond size\n");
}
ff_set_cmp(&s->dsp, s->dsp.me_pre_cmp, c->avctx->me_pre_cmp);
ff_set_cmp(&s->dsp, s->dsp.me_cmp, c->avctx->me_cmp);
ff_set_cmp(&s->dsp, s->dsp.me_sub_cmp, c->avctx->me_sub_cmp);
ff_set_cmp(&s->dsp, s->dsp.mb_cmp, c->avctx->mb_cmp);
c->flags = get_flags(c, 0, c->avctx->me_cmp &FF_CMP_CHROMA);
c->sub_flags= get_flags(c, 0, c->avctx->me_sub_cmp&FF_CMP_CHROMA);
c->mb_flags = get_flags(c, 0, c->avctx->mb_cmp &FF_CMP_CHROMA);
/*FIXME s->no_rounding b_type*/
if(s->flags&CODEC_FLAG_QPEL){
c->sub_motion_search= qpel_motion_search;
c->qpel_avg= s->dsp.avg_qpel_pixels_tab;
if(s->no_rounding) c->qpel_put= s->dsp.put_no_rnd_qpel_pixels_tab;
else c->qpel_put= s->dsp.put_qpel_pixels_tab;
}else{
if(c->avctx->me_sub_cmp&FF_CMP_CHROMA)
c->sub_motion_search= hpel_motion_search;
else if( c->avctx->me_sub_cmp == FF_CMP_SAD
&& c->avctx-> me_cmp == FF_CMP_SAD
&& c->avctx-> mb_cmp == FF_CMP_SAD)
c->sub_motion_search= sad_hpel_motion_search; // 2050 vs. 2450 cycles
else
c->sub_motion_search= hpel_motion_search;
}
c->hpel_avg= s->dsp.avg_pixels_tab;
if(s->no_rounding) c->hpel_put= s->dsp.put_no_rnd_pixels_tab;
else c->hpel_put= s->dsp.put_pixels_tab;
if(s->linesize){
c->stride = s->linesize;
c->uvstride= s->uvlinesize;
}else{
c->stride = 16*s->mb_width + 32;
c->uvstride= 8*s->mb_width + 16;
}
/* 8x8 fullpel search would need a 4x4 chroma compare, which we do
* not have yet, and even if we had, the motion estimation code
* does not expect it. */
if(s->codec_id != AV_CODEC_ID_SNOW){
if((c->avctx->me_cmp&FF_CMP_CHROMA)/* && !s->dsp.me_cmp[2]*/){
s->dsp.me_cmp[2]= zero_cmp;
}
if((c->avctx->me_sub_cmp&FF_CMP_CHROMA) && !s->dsp.me_sub_cmp[2]){
s->dsp.me_sub_cmp[2]= zero_cmp;
}
c->hpel_put[2][0]= c->hpel_put[2][1]=
c->hpel_put[2][2]= c->hpel_put[2][3]= zero_hpel;
}
if(s->codec_id == AV_CODEC_ID_H261){
c->sub_motion_search= no_sub_motion_search;
}
return 0;
}
| false | FFmpeg | 3a48e38ad0e37d89065843548414d367e70593bf | int ff_init_me(MpegEncContext *s){
MotionEstContext * const c= &s->me;
int cache_size= FFMIN(ME_MAP_SIZE>>ME_MAP_SHIFT, 1<<ME_MAP_SHIFT);
int dia_size= FFMAX(FFABS(s->avctx->dia_size)&255, FFABS(s->avctx->pre_dia_size)&255);
if(FFMIN(s->avctx->dia_size, s->avctx->pre_dia_size) < -ME_MAP_SIZE){
av_log(s->avctx, AV_LOG_ERROR, "ME_MAP size is too small for SAB diamond\n");
return -1;
}
if(s->me_method!=ME_ZERO && s->me_method!=ME_EPZS && s->me_method!=ME_X1 && s->avctx->codec_id != AV_CODEC_ID_SNOW){
av_log(s->avctx, AV_LOG_ERROR, "me_method is only allowed to be set to zero and epzs; for hex,umh,full and others see dia_size\n");
return -1;
}
c->avctx= s->avctx;
if(cache_size < 2*dia_size && !c->stride){
av_log(s->avctx, AV_LOG_INFO, "ME_MAP size may be a little small for the selected diamond size\n");
}
ff_set_cmp(&s->dsp, s->dsp.me_pre_cmp, c->avctx->me_pre_cmp);
ff_set_cmp(&s->dsp, s->dsp.me_cmp, c->avctx->me_cmp);
ff_set_cmp(&s->dsp, s->dsp.me_sub_cmp, c->avctx->me_sub_cmp);
ff_set_cmp(&s->dsp, s->dsp.mb_cmp, c->avctx->mb_cmp);
c->flags = get_flags(c, 0, c->avctx->me_cmp &FF_CMP_CHROMA);
c->sub_flags= get_flags(c, 0, c->avctx->me_sub_cmp&FF_CMP_CHROMA);
c->mb_flags = get_flags(c, 0, c->avctx->mb_cmp &FF_CMP_CHROMA);
if(s->flags&CODEC_FLAG_QPEL){
c->sub_motion_search= qpel_motion_search;
c->qpel_avg= s->dsp.avg_qpel_pixels_tab;
if(s->no_rounding) c->qpel_put= s->dsp.put_no_rnd_qpel_pixels_tab;
else c->qpel_put= s->dsp.put_qpel_pixels_tab;
}else{
if(c->avctx->me_sub_cmp&FF_CMP_CHROMA)
c->sub_motion_search= hpel_motion_search;
else if( c->avctx->me_sub_cmp == FF_CMP_SAD
&& c->avctx-> me_cmp == FF_CMP_SAD
&& c->avctx-> mb_cmp == FF_CMP_SAD)
c->sub_motion_search= sad_hpel_motion_search;
else
c->sub_motion_search= hpel_motion_search;
}
c->hpel_avg= s->dsp.avg_pixels_tab;
if(s->no_rounding) c->hpel_put= s->dsp.put_no_rnd_pixels_tab;
else c->hpel_put= s->dsp.put_pixels_tab;
if(s->linesize){
c->stride = s->linesize;
c->uvstride= s->uvlinesize;
}else{
c->stride = 16*s->mb_width + 32;
c->uvstride= 8*s->mb_width + 16;
}
if(s->codec_id != AV_CODEC_ID_SNOW){
if((c->avctx->me_cmp&FF_CMP_CHROMA)){
s->dsp.me_cmp[2]= zero_cmp;
}
if((c->avctx->me_sub_cmp&FF_CMP_CHROMA) && !s->dsp.me_sub_cmp[2]){
s->dsp.me_sub_cmp[2]= zero_cmp;
}
c->hpel_put[2][0]= c->hpel_put[2][1]=
c->hpel_put[2][2]= c->hpel_put[2][3]= zero_hpel;
}
if(s->codec_id == AV_CODEC_ID_H261){
c->sub_motion_search= no_sub_motion_search;
}
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(MpegEncContext *VAR_0){
MotionEstContext * const c= &VAR_0->me;
int VAR_1= FFMIN(ME_MAP_SIZE>>ME_MAP_SHIFT, 1<<ME_MAP_SHIFT);
int VAR_2= FFMAX(FFABS(VAR_0->avctx->VAR_2)&255, FFABS(VAR_0->avctx->pre_dia_size)&255);
if(FFMIN(VAR_0->avctx->VAR_2, VAR_0->avctx->pre_dia_size) < -ME_MAP_SIZE){
av_log(VAR_0->avctx, AV_LOG_ERROR, "ME_MAP size is too small for SAB diamond\n");
return -1;
}
if(VAR_0->me_method!=ME_ZERO && VAR_0->me_method!=ME_EPZS && VAR_0->me_method!=ME_X1 && VAR_0->avctx->codec_id != AV_CODEC_ID_SNOW){
av_log(VAR_0->avctx, AV_LOG_ERROR, "me_method is only allowed to be set to zero and epzs; for hex,umh,full and others see VAR_2\n");
return -1;
}
c->avctx= VAR_0->avctx;
if(VAR_1 < 2*VAR_2 && !c->stride){
av_log(VAR_0->avctx, AV_LOG_INFO, "ME_MAP size may be a little small for the selected diamond size\n");
}
ff_set_cmp(&VAR_0->dsp, VAR_0->dsp.me_pre_cmp, c->avctx->me_pre_cmp);
ff_set_cmp(&VAR_0->dsp, VAR_0->dsp.me_cmp, c->avctx->me_cmp);
ff_set_cmp(&VAR_0->dsp, VAR_0->dsp.me_sub_cmp, c->avctx->me_sub_cmp);
ff_set_cmp(&VAR_0->dsp, VAR_0->dsp.mb_cmp, c->avctx->mb_cmp);
c->flags = get_flags(c, 0, c->avctx->me_cmp &FF_CMP_CHROMA);
c->sub_flags= get_flags(c, 0, c->avctx->me_sub_cmp&FF_CMP_CHROMA);
c->mb_flags = get_flags(c, 0, c->avctx->mb_cmp &FF_CMP_CHROMA);
if(VAR_0->flags&CODEC_FLAG_QPEL){
c->sub_motion_search= qpel_motion_search;
c->qpel_avg= VAR_0->dsp.avg_qpel_pixels_tab;
if(VAR_0->no_rounding) c->qpel_put= VAR_0->dsp.put_no_rnd_qpel_pixels_tab;
else c->qpel_put= VAR_0->dsp.put_qpel_pixels_tab;
}else{
if(c->avctx->me_sub_cmp&FF_CMP_CHROMA)
c->sub_motion_search= hpel_motion_search;
else if( c->avctx->me_sub_cmp == FF_CMP_SAD
&& c->avctx-> me_cmp == FF_CMP_SAD
&& c->avctx-> mb_cmp == FF_CMP_SAD)
c->sub_motion_search= sad_hpel_motion_search;
else
c->sub_motion_search= hpel_motion_search;
}
c->hpel_avg= VAR_0->dsp.avg_pixels_tab;
if(VAR_0->no_rounding) c->hpel_put= VAR_0->dsp.put_no_rnd_pixels_tab;
else c->hpel_put= VAR_0->dsp.put_pixels_tab;
if(VAR_0->linesize){
c->stride = VAR_0->linesize;
c->uvstride= VAR_0->uvlinesize;
}else{
c->stride = 16*VAR_0->mb_width + 32;
c->uvstride= 8*VAR_0->mb_width + 16;
}
if(VAR_0->codec_id != AV_CODEC_ID_SNOW){
if((c->avctx->me_cmp&FF_CMP_CHROMA)){
VAR_0->dsp.me_cmp[2]= zero_cmp;
}
if((c->avctx->me_sub_cmp&FF_CMP_CHROMA) && !VAR_0->dsp.me_sub_cmp[2]){
VAR_0->dsp.me_sub_cmp[2]= zero_cmp;
}
c->hpel_put[2][0]= c->hpel_put[2][1]=
c->hpel_put[2][2]= c->hpel_put[2][3]= zero_hpel;
}
if(VAR_0->codec_id == AV_CODEC_ID_H261){
c->sub_motion_search= no_sub_motion_search;
}
return 0;
}
| [
"int FUNC_0(MpegEncContext *VAR_0){",
"MotionEstContext * const c= &VAR_0->me;",
"int VAR_1= FFMIN(ME_MAP_SIZE>>ME_MAP_SHIFT, 1<<ME_MAP_SHIFT);",
"int VAR_2= FFMAX(FFABS(VAR_0->avctx->VAR_2)&255, FFABS(VAR_0->avctx->pre_dia_size)&255);",
"if(FFMIN(VAR_0->avctx->VAR_2, VAR_0->avctx->pre_dia_size) < -ME_MAP_SIZE){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"ME_MAP size is too small for SAB diamond\\n\");",
"return -1;",
"}",
"if(VAR_0->me_method!=ME_ZERO && VAR_0->me_method!=ME_EPZS && VAR_0->me_method!=ME_X1 && VAR_0->avctx->codec_id != AV_CODEC_ID_SNOW){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"me_method is only allowed to be set to zero and epzs; for hex,umh,full and others see VAR_2\\n\");",
"return -1;",
"}",
"c->avctx= VAR_0->avctx;",
"if(VAR_1 < 2*VAR_2 && !c->stride){",
"av_log(VAR_0->avctx, AV_LOG_INFO, \"ME_MAP size may be a little small for the selected diamond size\\n\");",
"}",
"ff_set_cmp(&VAR_0->dsp, VAR_0->dsp.me_pre_cmp, c->avctx->me_pre_cmp);",
"ff_set_cmp(&VAR_0->dsp, VAR_0->dsp.me_cmp, c->avctx->me_cmp);",
"ff_set_cmp(&VAR_0->dsp, VAR_0->dsp.me_sub_cmp, c->avctx->me_sub_cmp);",
"ff_set_cmp(&VAR_0->dsp, VAR_0->dsp.mb_cmp, c->avctx->mb_cmp);",
"c->flags = get_flags(c, 0, c->avctx->me_cmp &FF_CMP_CHROMA);",
"c->sub_flags= get_flags(c, 0, c->avctx->me_sub_cmp&FF_CMP_CHROMA);",
"c->mb_flags = get_flags(c, 0, c->avctx->mb_cmp &FF_CMP_CHROMA);",
"if(VAR_0->flags&CODEC_FLAG_QPEL){",
"c->sub_motion_search= qpel_motion_search;",
"c->qpel_avg= VAR_0->dsp.avg_qpel_pixels_tab;",
"if(VAR_0->no_rounding) c->qpel_put= VAR_0->dsp.put_no_rnd_qpel_pixels_tab;",
"else c->qpel_put= VAR_0->dsp.put_qpel_pixels_tab;",
"}else{",
"if(c->avctx->me_sub_cmp&FF_CMP_CHROMA)\nc->sub_motion_search= hpel_motion_search;",
"else if( c->avctx->me_sub_cmp == FF_CMP_SAD\n&& c->avctx-> me_cmp == FF_CMP_SAD\n&& c->avctx-> mb_cmp == FF_CMP_SAD)\nc->sub_motion_search= sad_hpel_motion_search;",
"else\nc->sub_motion_search= hpel_motion_search;",
"}",
"c->hpel_avg= VAR_0->dsp.avg_pixels_tab;",
"if(VAR_0->no_rounding) c->hpel_put= VAR_0->dsp.put_no_rnd_pixels_tab;",
"else c->hpel_put= VAR_0->dsp.put_pixels_tab;",
"if(VAR_0->linesize){",
"c->stride = VAR_0->linesize;",
"c->uvstride= VAR_0->uvlinesize;",
"}else{",
"c->stride = 16*VAR_0->mb_width + 32;",
"c->uvstride= 8*VAR_0->mb_width + 16;",
"}",
"if(VAR_0->codec_id != AV_CODEC_ID_SNOW){",
"if((c->avctx->me_cmp&FF_CMP_CHROMA)){",
"VAR_0->dsp.me_cmp[2]= zero_cmp;",
"}",
"if((c->avctx->me_sub_cmp&FF_CMP_CHROMA) && !VAR_0->dsp.me_sub_cmp[2]){",
"VAR_0->dsp.me_sub_cmp[2]= zero_cmp;",
"}",
"c->hpel_put[2][0]= c->hpel_put[2][1]=\nc->hpel_put[2][2]= c->hpel_put[2][3]= zero_hpel;",
"}",
"if(VAR_0->codec_id == AV_CODEC_ID_H261){",
"c->sub_motion_search= no_sub_motion_search;",
"}",
"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
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
79,
81,
83,
85
],
[
87,
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137,
139
],
[
141
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155
]
] |
27,105 | float32 float32_scalbn( float32 a, int n STATUS_PARAM )
{
flag aSign;
int16 aExp;
uint32_t aSig;
a = float32_squash_input_denormal(a STATUS_VAR);
aSig = extractFloat32Frac( a );
aExp = extractFloat32Exp( a );
aSign = extractFloat32Sign( a );
if ( aExp == 0xFF ) {
return a;
}
if ( aExp != 0 )
aSig |= 0x00800000;
else if ( aSig == 0 )
return a;
aExp += n - 1;
aSig <<= 7;
return normalizeRoundAndPackFloat32( aSign, aExp, aSig STATUS_VAR );
}
| true | qemu | 326b9e98a391d542cc33c4c91782ff4ba51edfc5 | float32 float32_scalbn( float32 a, int n STATUS_PARAM )
{
flag aSign;
int16 aExp;
uint32_t aSig;
a = float32_squash_input_denormal(a STATUS_VAR);
aSig = extractFloat32Frac( a );
aExp = extractFloat32Exp( a );
aSign = extractFloat32Sign( a );
if ( aExp == 0xFF ) {
return a;
}
if ( aExp != 0 )
aSig |= 0x00800000;
else if ( aSig == 0 )
return a;
aExp += n - 1;
aSig <<= 7;
return normalizeRoundAndPackFloat32( aSign, aExp, aSig STATUS_VAR );
}
| {
"code": [
" int16 aExp;",
" int16 aExp;",
" int16 aExp;"
],
"line_no": [
7,
7,
7
]
} | float32 FUNC_0( float32 a, int n STATUS_PARAM )
{
flag aSign;
int16 aExp;
uint32_t aSig;
a = float32_squash_input_denormal(a STATUS_VAR);
aSig = extractFloat32Frac( a );
aExp = extractFloat32Exp( a );
aSign = extractFloat32Sign( a );
if ( aExp == 0xFF ) {
return a;
}
if ( aExp != 0 )
aSig |= 0x00800000;
else if ( aSig == 0 )
return a;
aExp += n - 1;
aSig <<= 7;
return normalizeRoundAndPackFloat32( aSign, aExp, aSig STATUS_VAR );
}
| [
"float32 FUNC_0( float32 a, int n STATUS_PARAM )\n{",
"flag aSign;",
"int16 aExp;",
"uint32_t aSig;",
"a = float32_squash_input_denormal(a STATUS_VAR);",
"aSig = extractFloat32Frac( a );",
"aExp = extractFloat32Exp( a );",
"aSign = extractFloat32Sign( a );",
"if ( aExp == 0xFF ) {",
"return a;",
"}",
"if ( aExp != 0 )\naSig |= 0x00800000;",
"else if ( aSig == 0 )\nreturn a;",
"aExp += n - 1;",
"aSig <<= 7;",
"return normalizeRoundAndPackFloat32( aSign, aExp, aSig STATUS_VAR );",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29,
31
],
[
33,
35
],
[
39
],
[
41
],
[
43
],
[
45
]
] |
27,106 | void net_check_clients(void)
{
VLANState *vlan;
VLANClientState *vc;
int has_nic, has_host_dev;
QTAILQ_FOREACH(vlan, &vlans, next) {
QTAILQ_FOREACH(vc, &vlan->clients, next) {
switch (vc->info->type) {
case NET_CLIENT_TYPE_NIC:
has_nic = 1;
break;
case NET_CLIENT_TYPE_SLIRP:
case NET_CLIENT_TYPE_TAP:
case NET_CLIENT_TYPE_SOCKET:
case NET_CLIENT_TYPE_VDE:
has_host_dev = 1;
break;
default: ;
}
}
if (has_host_dev && !has_nic)
fprintf(stderr, "Warning: vlan %d with no nics\n", vlan->id);
if (has_nic && !has_host_dev)
fprintf(stderr,
"Warning: vlan %d is not connected to host network\n",
vlan->id);
}
QTAILQ_FOREACH(vc, &non_vlan_clients, next) {
if (!vc->peer) {
fprintf(stderr, "Warning: %s %s has no peer\n",
vc->info->type == NET_CLIENT_TYPE_NIC ? "nic" : "netdev",
vc->name);
}
}
}
| true | qemu | 64e69d50a394a48de7607f178d53c192443f9066 | void net_check_clients(void)
{
VLANState *vlan;
VLANClientState *vc;
int has_nic, has_host_dev;
QTAILQ_FOREACH(vlan, &vlans, next) {
QTAILQ_FOREACH(vc, &vlan->clients, next) {
switch (vc->info->type) {
case NET_CLIENT_TYPE_NIC:
has_nic = 1;
break;
case NET_CLIENT_TYPE_SLIRP:
case NET_CLIENT_TYPE_TAP:
case NET_CLIENT_TYPE_SOCKET:
case NET_CLIENT_TYPE_VDE:
has_host_dev = 1;
break;
default: ;
}
}
if (has_host_dev && !has_nic)
fprintf(stderr, "Warning: vlan %d with no nics\n", vlan->id);
if (has_nic && !has_host_dev)
fprintf(stderr,
"Warning: vlan %d is not connected to host network\n",
vlan->id);
}
QTAILQ_FOREACH(vc, &non_vlan_clients, next) {
if (!vc->peer) {
fprintf(stderr, "Warning: %s %s has no peer\n",
vc->info->type == NET_CLIENT_TYPE_NIC ? "nic" : "netdev",
vc->name);
}
}
}
| {
"code": [
" int has_nic, has_host_dev;"
],
"line_no": [
9
]
} | void FUNC_0(void)
{
VLANState *vlan;
VLANClientState *vc;
int VAR_0, VAR_1;
QTAILQ_FOREACH(vlan, &vlans, next) {
QTAILQ_FOREACH(vc, &vlan->clients, next) {
switch (vc->info->type) {
case NET_CLIENT_TYPE_NIC:
VAR_0 = 1;
break;
case NET_CLIENT_TYPE_SLIRP:
case NET_CLIENT_TYPE_TAP:
case NET_CLIENT_TYPE_SOCKET:
case NET_CLIENT_TYPE_VDE:
VAR_1 = 1;
break;
default: ;
}
}
if (VAR_1 && !VAR_0)
fprintf(stderr, "Warning: vlan %d with no nics\n", vlan->id);
if (VAR_0 && !VAR_1)
fprintf(stderr,
"Warning: vlan %d is not connected to host network\n",
vlan->id);
}
QTAILQ_FOREACH(vc, &non_vlan_clients, next) {
if (!vc->peer) {
fprintf(stderr, "Warning: %s %s has no peer\n",
vc->info->type == NET_CLIENT_TYPE_NIC ? "nic" : "netdev",
vc->name);
}
}
}
| [
"void FUNC_0(void)\n{",
"VLANState *vlan;",
"VLANClientState *vc;",
"int VAR_0, VAR_1;",
"QTAILQ_FOREACH(vlan, &vlans, next) {",
"QTAILQ_FOREACH(vc, &vlan->clients, next) {",
"switch (vc->info->type) {",
"case NET_CLIENT_TYPE_NIC:\nVAR_0 = 1;",
"break;",
"case NET_CLIENT_TYPE_SLIRP:\ncase NET_CLIENT_TYPE_TAP:\ncase NET_CLIENT_TYPE_SOCKET:\ncase NET_CLIENT_TYPE_VDE:\nVAR_1 = 1;",
"break;",
"default: ;",
"}",
"}",
"if (VAR_1 && !VAR_0)\nfprintf(stderr, \"Warning: vlan %d with no nics\\n\", vlan->id);",
"if (VAR_0 && !VAR_1)\nfprintf(stderr,\n\"Warning: vlan %d is not connected to host network\\n\",\nvlan->id);",
"}",
"QTAILQ_FOREACH(vc, &non_vlan_clients, next) {",
"if (!vc->peer) {",
"fprintf(stderr, \"Warning: %s %s has no peer\\n\",\nvc->info->type == NET_CLIENT_TYPE_NIC ? \"nic\" : \"netdev\",\nvc->name);",
"}",
"}",
"}"
] | [
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
],
[
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
]
] |
27,108 | static uint32_t hpet_time_after64(uint64_t a, uint64_t b)
{
return ((int64_t)(b) - (int64_t)(a) < 0);
}
| true | qemu | d17008bc2914d62fd0af6a8f313604ae9f9a102c | static uint32_t hpet_time_after64(uint64_t a, uint64_t b)
{
return ((int64_t)(b) - (int64_t)(a) < 0);
}
| {
"code": [
" return ((int64_t)(b) - (int64_t)(a) < 0);"
],
"line_no": [
5
]
} | static uint32_t FUNC_0(uint64_t a, uint64_t b)
{
return ((int64_t)(b) - (int64_t)(a) < 0);
}
| [
"static uint32_t FUNC_0(uint64_t a, uint64_t b)\n{",
"return ((int64_t)(b) - (int64_t)(a) < 0);",
"}"
] | [
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
27,109 | static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp)
{
GICv3State *s = KVM_ARM_GICV3(dev);
KVMARMGICv3Class *kgc = KVM_ARM_GICV3_GET_CLASS(s);
Error *local_err = NULL;
DPRINTF("kvm_arm_gicv3_realize\n");
kgc->parent_realize(dev, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
if (s->security_extn) {
error_setg(errp, "the in-kernel VGICv3 does not implement the "
"security extensions");
return;
}
gicv3_init_irqs_and_mmio(s, kvm_arm_gicv3_set_irq, NULL);
/* Try to create the device via the device control API */
s->dev_fd = kvm_create_device(kvm_state, KVM_DEV_TYPE_ARM_VGIC_V3, false);
if (s->dev_fd < 0) {
error_setg_errno(errp, -s->dev_fd, "error creating in-kernel VGIC");
return;
}
kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS,
0, &s->num_irq, true);
/* Tell the kernel to complete VGIC initialization now */
kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,
KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true);
kvm_arm_register_device(&s->iomem_dist, -1, KVM_DEV_ARM_VGIC_GRP_ADDR,
KVM_VGIC_V3_ADDR_TYPE_DIST, s->dev_fd);
kvm_arm_register_device(&s->iomem_redist, -1, KVM_DEV_ARM_VGIC_GRP_ADDR,
KVM_VGIC_V3_ADDR_TYPE_REDIST, s->dev_fd);
/* Block migration of a KVM GICv3 device: the API for saving and restoring
* the state in the kernel is not yet finalised in the kernel or
* implemented in QEMU.
*/
error_setg(&s->migration_blocker, "vGICv3 migration is not implemented");
migrate_add_blocker(s->migration_blocker);
if (kvm_has_gsi_routing()) {
/* set up irq routing */
kvm_init_irq_routing(kvm_state);
for (i = 0; i < s->num_irq - GIC_INTERNAL; ++i) {
kvm_irqchip_add_irq_route(kvm_state, i, 0, i);
}
kvm_gsi_routing_allowed = true;
kvm_irqchip_commit_routes(kvm_state);
}
} | true | qemu | d19a4d4ef448e736d341df47bd1adc78c8e40814 | static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp)
{
GICv3State *s = KVM_ARM_GICV3(dev);
KVMARMGICv3Class *kgc = KVM_ARM_GICV3_GET_CLASS(s);
Error *local_err = NULL;
DPRINTF("kvm_arm_gicv3_realize\n");
kgc->parent_realize(dev, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
if (s->security_extn) {
error_setg(errp, "the in-kernel VGICv3 does not implement the "
"security extensions");
return;
}
gicv3_init_irqs_and_mmio(s, kvm_arm_gicv3_set_irq, NULL);
s->dev_fd = kvm_create_device(kvm_state, KVM_DEV_TYPE_ARM_VGIC_V3, false);
if (s->dev_fd < 0) {
error_setg_errno(errp, -s->dev_fd, "error creating in-kernel VGIC");
return;
}
kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS,
0, &s->num_irq, true);
kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,
KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true);
kvm_arm_register_device(&s->iomem_dist, -1, KVM_DEV_ARM_VGIC_GRP_ADDR,
KVM_VGIC_V3_ADDR_TYPE_DIST, s->dev_fd);
kvm_arm_register_device(&s->iomem_redist, -1, KVM_DEV_ARM_VGIC_GRP_ADDR,
KVM_VGIC_V3_ADDR_TYPE_REDIST, s->dev_fd);
error_setg(&s->migration_blocker, "vGICv3 migration is not implemented");
migrate_add_blocker(s->migration_blocker);
if (kvm_has_gsi_routing()) {
kvm_init_irq_routing(kvm_state);
for (i = 0; i < s->num_irq - GIC_INTERNAL; ++i) {
kvm_irqchip_add_irq_route(kvm_state, i, 0, i);
}
kvm_gsi_routing_allowed = true;
kvm_irqchip_commit_routes(kvm_state);
}
} | {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
GICv3State *s = KVM_ARM_GICV3(VAR_0);
KVMARMGICv3Class *kgc = KVM_ARM_GICV3_GET_CLASS(s);
Error *local_err = NULL;
DPRINTF("FUNC_0\n");
kgc->parent_realize(VAR_0, &local_err);
if (local_err) {
error_propagate(VAR_1, local_err);
return;
}
if (s->security_extn) {
error_setg(VAR_1, "the in-kernel VGICv3 does not implement the "
"security extensions");
return;
}
gicv3_init_irqs_and_mmio(s, kvm_arm_gicv3_set_irq, NULL);
s->dev_fd = kvm_create_device(kvm_state, KVM_DEV_TYPE_ARM_VGIC_V3, false);
if (s->dev_fd < 0) {
error_setg_errno(VAR_1, -s->dev_fd, "error creating in-kernel VGIC");
return;
}
kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS,
0, &s->num_irq, true);
kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,
KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true);
kvm_arm_register_device(&s->iomem_dist, -1, KVM_DEV_ARM_VGIC_GRP_ADDR,
KVM_VGIC_V3_ADDR_TYPE_DIST, s->dev_fd);
kvm_arm_register_device(&s->iomem_redist, -1, KVM_DEV_ARM_VGIC_GRP_ADDR,
KVM_VGIC_V3_ADDR_TYPE_REDIST, s->dev_fd);
error_setg(&s->migration_blocker, "vGICv3 migration is not implemented");
migrate_add_blocker(s->migration_blocker);
if (kvm_has_gsi_routing()) {
kvm_init_irq_routing(kvm_state);
for (i = 0; i < s->num_irq - GIC_INTERNAL; ++i) {
kvm_irqchip_add_irq_route(kvm_state, i, 0, i);
}
kvm_gsi_routing_allowed = true;
kvm_irqchip_commit_routes(kvm_state);
}
} | [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"GICv3State *s = KVM_ARM_GICV3(VAR_0);",
"KVMARMGICv3Class *kgc = KVM_ARM_GICV3_GET_CLASS(s);",
"Error *local_err = NULL;",
"DPRINTF(\"FUNC_0\\n\");",
"kgc->parent_realize(VAR_0, &local_err);",
"if (local_err) {",
"error_propagate(VAR_1, local_err);",
"return;",
"}",
"if (s->security_extn) {",
"error_setg(VAR_1, \"the in-kernel VGICv3 does not implement the \"\n\"security extensions\");",
"return;",
"}",
"gicv3_init_irqs_and_mmio(s, kvm_arm_gicv3_set_irq, NULL);",
"s->dev_fd = kvm_create_device(kvm_state, KVM_DEV_TYPE_ARM_VGIC_V3, false);",
"if (s->dev_fd < 0) {",
"error_setg_errno(VAR_1, -s->dev_fd, \"error creating in-kernel VGIC\");",
"return;",
"}",
"kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS,\n0, &s->num_irq, true);",
"kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,\nKVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true);",
"kvm_arm_register_device(&s->iomem_dist, -1, KVM_DEV_ARM_VGIC_GRP_ADDR,\nKVM_VGIC_V3_ADDR_TYPE_DIST, s->dev_fd);",
"kvm_arm_register_device(&s->iomem_redist, -1, KVM_DEV_ARM_VGIC_GRP_ADDR,\nKVM_VGIC_V3_ADDR_TYPE_REDIST, s->dev_fd);",
"error_setg(&s->migration_blocker, \"vGICv3 migration is not implemented\");",
"migrate_add_blocker(s->migration_blocker);",
"if (kvm_has_gsi_routing()) {",
"kvm_init_irq_routing(kvm_state);",
"for (i = 0; i < s->num_irq - GIC_INTERNAL; ++i) {",
"kvm_irqchip_add_irq_route(kvm_state, i, 0, i);",
"}",
"kvm_gsi_routing_allowed = true;",
"kvm_irqchip_commit_routes(kvm_state);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
14
],
[
18
],
[
20
],
[
22
],
[
24
],
[
26
],
[
30
],
[
32,
34
],
[
36
],
[
38
],
[
42
],
[
48
],
[
50
],
[
52
],
[
54
],
[
56
],
[
60,
62
],
[
68,
70
],
[
74,
76
],
[
78,
80
],
[
92
],
[
94
],
[
98
],
[
102
],
[
104
],
[
106
],
[
108
],
[
112
],
[
116
],
[
118
],
[
120
]
] |
27,110 | static TypeImpl *type_register_internal(const TypeInfo *info)
{
TypeImpl *ti = g_malloc0(sizeof(*ti));
int i;
g_assert(info->name != NULL);
if (type_table_lookup(info->name) != NULL) {
fprintf(stderr, "Registering `%s' which already exists\n", info->name);
abort();
}
ti->name = g_strdup(info->name);
ti->parent = g_strdup(info->parent);
ti->class_size = info->class_size;
ti->instance_size = info->instance_size;
ti->class_init = info->class_init;
ti->class_base_init = info->class_base_init;
ti->class_finalize = info->class_finalize;
ti->class_data = info->class_data;
ti->instance_init = info->instance_init;
ti->instance_post_init = info->instance_post_init;
ti->instance_finalize = info->instance_finalize;
ti->abstract = info->abstract;
for (i = 0; info->interfaces && info->interfaces[i].type; i++) {
ti->interfaces[i].typename = g_strdup(info->interfaces[i].type);
}
ti->num_interfaces = i;
type_table_add(ti);
return ti;
}
| true | qemu | b061dc41f62048acd4a34c6570c0ea396cd9d0b4 | static TypeImpl *type_register_internal(const TypeInfo *info)
{
TypeImpl *ti = g_malloc0(sizeof(*ti));
int i;
g_assert(info->name != NULL);
if (type_table_lookup(info->name) != NULL) {
fprintf(stderr, "Registering `%s' which already exists\n", info->name);
abort();
}
ti->name = g_strdup(info->name);
ti->parent = g_strdup(info->parent);
ti->class_size = info->class_size;
ti->instance_size = info->instance_size;
ti->class_init = info->class_init;
ti->class_base_init = info->class_base_init;
ti->class_finalize = info->class_finalize;
ti->class_data = info->class_data;
ti->instance_init = info->instance_init;
ti->instance_post_init = info->instance_post_init;
ti->instance_finalize = info->instance_finalize;
ti->abstract = info->abstract;
for (i = 0; info->interfaces && info->interfaces[i].type; i++) {
ti->interfaces[i].typename = g_strdup(info->interfaces[i].type);
}
ti->num_interfaces = i;
type_table_add(ti);
return ti;
}
| {
"code": [
"static TypeImpl *type_register_internal(const TypeInfo *info)",
" type_table_add(ti);"
],
"line_no": [
1,
69
]
} | static TypeImpl *FUNC_0(const TypeInfo *info)
{
TypeImpl *ti = g_malloc0(sizeof(*ti));
int VAR_0;
g_assert(info->name != NULL);
if (type_table_lookup(info->name) != NULL) {
fprintf(stderr, "Registering `%s' which already exists\n", info->name);
abort();
}
ti->name = g_strdup(info->name);
ti->parent = g_strdup(info->parent);
ti->class_size = info->class_size;
ti->instance_size = info->instance_size;
ti->class_init = info->class_init;
ti->class_base_init = info->class_base_init;
ti->class_finalize = info->class_finalize;
ti->class_data = info->class_data;
ti->instance_init = info->instance_init;
ti->instance_post_init = info->instance_post_init;
ti->instance_finalize = info->instance_finalize;
ti->abstract = info->abstract;
for (VAR_0 = 0; info->interfaces && info->interfaces[VAR_0].type; VAR_0++) {
ti->interfaces[VAR_0].typename = g_strdup(info->interfaces[VAR_0].type);
}
ti->num_interfaces = VAR_0;
type_table_add(ti);
return ti;
}
| [
"static TypeImpl *FUNC_0(const TypeInfo *info)\n{",
"TypeImpl *ti = g_malloc0(sizeof(*ti));",
"int VAR_0;",
"g_assert(info->name != NULL);",
"if (type_table_lookup(info->name) != NULL) {",
"fprintf(stderr, \"Registering `%s' which already exists\\n\", info->name);",
"abort();",
"}",
"ti->name = g_strdup(info->name);",
"ti->parent = g_strdup(info->parent);",
"ti->class_size = info->class_size;",
"ti->instance_size = info->instance_size;",
"ti->class_init = info->class_init;",
"ti->class_base_init = info->class_base_init;",
"ti->class_finalize = info->class_finalize;",
"ti->class_data = info->class_data;",
"ti->instance_init = info->instance_init;",
"ti->instance_post_init = info->instance_post_init;",
"ti->instance_finalize = info->instance_finalize;",
"ti->abstract = info->abstract;",
"for (VAR_0 = 0; info->interfaces && info->interfaces[VAR_0].type; VAR_0++) {",
"ti->interfaces[VAR_0].typename = g_strdup(info->interfaces[VAR_0].type);",
"}",
"ti->num_interfaces = VAR_0;",
"type_table_add(ti);",
"return ti;",
"}"
] | [
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,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
73
],
[
75
]
] |
27,111 | static int disas_vfp_insn(CPUState * env, DisasContext *s, uint32_t insn)
{
uint32_t rd, rn, rm, op, i, n, offset, delta_d, delta_m, bank_mask;
int dp, veclen;
TCGv addr;
TCGv tmp;
TCGv tmp2;
if (!arm_feature(env, ARM_FEATURE_VFP))
return 1;
if (!vfp_enabled(env)) {
/* VFP disabled. Only allow fmxr/fmrx to/from some control regs. */
if ((insn & 0x0fe00fff) != 0x0ee00a10)
return 1;
rn = (insn >> 16) & 0xf;
if (rn != ARM_VFP_FPSID && rn != ARM_VFP_FPEXC
&& rn != ARM_VFP_MVFR1 && rn != ARM_VFP_MVFR0)
return 1;
}
dp = ((insn & 0xf00) == 0xb00);
switch ((insn >> 24) & 0xf) {
case 0xe:
if (insn & (1 << 4)) {
/* single register transfer */
rd = (insn >> 12) & 0xf;
if (dp) {
int size;
int pass;
VFP_DREG_N(rn, insn);
if (insn & 0xf)
return 1;
if (insn & 0x00c00060
&& !arm_feature(env, ARM_FEATURE_NEON))
return 1;
pass = (insn >> 21) & 1;
if (insn & (1 << 22)) {
size = 0;
offset = ((insn >> 5) & 3) * 8;
} else if (insn & (1 << 5)) {
size = 1;
offset = (insn & (1 << 6)) ? 16 : 0;
} else {
size = 2;
offset = 0;
}
if (insn & ARM_CP_RW_BIT) {
/* vfp->arm */
tmp = neon_load_reg(rn, pass);
switch (size) {
case 0:
if (offset)
tcg_gen_shri_i32(tmp, tmp, offset);
if (insn & (1 << 23))
gen_uxtb(tmp);
else
gen_sxtb(tmp);
break;
case 1:
if (insn & (1 << 23)) {
if (offset) {
tcg_gen_shri_i32(tmp, tmp, 16);
} else {
gen_uxth(tmp);
}
} else {
if (offset) {
tcg_gen_sari_i32(tmp, tmp, 16);
} else {
gen_sxth(tmp);
}
}
break;
case 2:
break;
}
store_reg(s, rd, tmp);
} else {
/* arm->vfp */
tmp = load_reg(s, rd);
if (insn & (1 << 23)) {
/* VDUP */
if (size == 0) {
gen_neon_dup_u8(tmp, 0);
} else if (size == 1) {
gen_neon_dup_low16(tmp);
}
for (n = 0; n <= pass * 2; n++) {
tmp2 = new_tmp();
tcg_gen_mov_i32(tmp2, tmp);
neon_store_reg(rn, n, tmp2);
}
neon_store_reg(rn, n, tmp);
} else {
/* VMOV */
switch (size) {
case 0:
tmp2 = neon_load_reg(rn, pass);
gen_bfi(tmp, tmp2, tmp, offset, 0xff);
dead_tmp(tmp2);
break;
case 1:
tmp2 = neon_load_reg(rn, pass);
gen_bfi(tmp, tmp2, tmp, offset, 0xffff);
dead_tmp(tmp2);
break;
case 2:
break;
}
neon_store_reg(rn, pass, tmp);
}
}
} else { /* !dp */
if ((insn & 0x6f) != 0x00)
return 1;
rn = VFP_SREG_N(insn);
if (insn & ARM_CP_RW_BIT) {
/* vfp->arm */
if (insn & (1 << 21)) {
/* system register */
rn >>= 1;
switch (rn) {
case ARM_VFP_FPSID:
/* VFP2 allows access to FSID from userspace.
VFP3 restricts all id registers to privileged
accesses. */
if (IS_USER(s)
&& arm_feature(env, ARM_FEATURE_VFP3))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
case ARM_VFP_FPEXC:
if (IS_USER(s))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
case ARM_VFP_FPINST:
case ARM_VFP_FPINST2:
/* Not present in VFP3. */
if (IS_USER(s)
|| arm_feature(env, ARM_FEATURE_VFP3))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
case ARM_VFP_FPSCR:
if (rd == 15) {
tmp = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]);
tcg_gen_andi_i32(tmp, tmp, 0xf0000000);
} else {
tmp = new_tmp();
gen_helper_vfp_get_fpscr(tmp, cpu_env);
}
break;
case ARM_VFP_MVFR0:
case ARM_VFP_MVFR1:
if (IS_USER(s)
|| !arm_feature(env, ARM_FEATURE_VFP3))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
default:
return 1;
}
} else {
gen_mov_F0_vreg(0, rn);
tmp = gen_vfp_mrs();
}
if (rd == 15) {
/* Set the 4 flag bits in the CPSR. */
gen_set_nzcv(tmp);
dead_tmp(tmp);
} else {
store_reg(s, rd, tmp);
}
} else {
/* arm->vfp */
tmp = load_reg(s, rd);
if (insn & (1 << 21)) {
rn >>= 1;
/* system register */
switch (rn) {
case ARM_VFP_FPSID:
case ARM_VFP_MVFR0:
case ARM_VFP_MVFR1:
/* Writes are ignored. */
break;
case ARM_VFP_FPSCR:
gen_helper_vfp_set_fpscr(cpu_env, tmp);
dead_tmp(tmp);
gen_lookup_tb(s);
break;
case ARM_VFP_FPEXC:
if (IS_USER(s))
return 1;
store_cpu_field(tmp, vfp.xregs[rn]);
gen_lookup_tb(s);
break;
case ARM_VFP_FPINST:
case ARM_VFP_FPINST2:
store_cpu_field(tmp, vfp.xregs[rn]);
break;
default:
return 1;
}
} else {
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rn);
}
}
}
} else {
/* data processing */
/* The opcode is in bits 23, 21, 20 and 6. */
op = ((insn >> 20) & 8) | ((insn >> 19) & 6) | ((insn >> 6) & 1);
if (dp) {
if (op == 15) {
/* rn is opcode */
rn = ((insn >> 15) & 0x1e) | ((insn >> 7) & 1);
} else {
/* rn is register number */
VFP_DREG_N(rn, insn);
}
if (op == 15 && (rn == 15 || rn > 17)) {
/* Integer or single precision destination. */
rd = VFP_SREG_D(insn);
} else {
VFP_DREG_D(rd, insn);
}
if (op == 15 && (rn == 16 || rn == 17)) {
/* Integer source. */
rm = ((insn << 1) & 0x1e) | ((insn >> 5) & 1);
} else {
VFP_DREG_M(rm, insn);
}
} else {
rn = VFP_SREG_N(insn);
if (op == 15 && rn == 15) {
/* Double precision destination. */
VFP_DREG_D(rd, insn);
} else {
rd = VFP_SREG_D(insn);
}
rm = VFP_SREG_M(insn);
}
veclen = env->vfp.vec_len;
if (op == 15 && rn > 3)
veclen = 0;
/* Shut up compiler warnings. */
delta_m = 0;
delta_d = 0;
bank_mask = 0;
if (veclen > 0) {
if (dp)
bank_mask = 0xc;
else
bank_mask = 0x18;
/* Figure out what type of vector operation this is. */
if ((rd & bank_mask) == 0) {
/* scalar */
veclen = 0;
} else {
if (dp)
delta_d = (env->vfp.vec_stride >> 1) + 1;
else
delta_d = env->vfp.vec_stride + 1;
if ((rm & bank_mask) == 0) {
/* mixed scalar/vector */
delta_m = 0;
} else {
/* vector */
delta_m = delta_d;
}
}
}
/* Load the initial operands. */
if (op == 15) {
switch (rn) {
case 16:
case 17:
/* Integer source */
gen_mov_F0_vreg(0, rm);
break;
case 8:
case 9:
/* Compare */
gen_mov_F0_vreg(dp, rd);
gen_mov_F1_vreg(dp, rm);
break;
case 10:
case 11:
/* Compare with zero */
gen_mov_F0_vreg(dp, rd);
gen_vfp_F1_ld0(dp);
break;
case 20:
case 21:
case 22:
case 23:
case 28:
case 29:
case 30:
case 31:
/* Source and destination the same. */
gen_mov_F0_vreg(dp, rd);
break;
default:
/* One source operand. */
gen_mov_F0_vreg(dp, rm);
break;
}
} else {
/* Two source operands. */
gen_mov_F0_vreg(dp, rn);
gen_mov_F1_vreg(dp, rm);
}
for (;;) {
/* Perform the calculation. */
switch (op) {
case 0: /* mac: fd + (fn * fm) */
gen_vfp_mul(dp);
gen_mov_F1_vreg(dp, rd);
gen_vfp_add(dp);
break;
case 1: /* nmac: fd - (fn * fm) */
gen_vfp_mul(dp);
gen_vfp_neg(dp);
gen_mov_F1_vreg(dp, rd);
gen_vfp_add(dp);
break;
case 2: /* msc: -fd + (fn * fm) */
gen_vfp_mul(dp);
gen_mov_F1_vreg(dp, rd);
gen_vfp_sub(dp);
break;
case 3: /* nmsc: -fd - (fn * fm) */
gen_vfp_mul(dp);
gen_vfp_neg(dp);
gen_mov_F1_vreg(dp, rd);
gen_vfp_sub(dp);
break;
case 4: /* mul: fn * fm */
gen_vfp_mul(dp);
break;
case 5: /* nmul: -(fn * fm) */
gen_vfp_mul(dp);
gen_vfp_neg(dp);
break;
case 6: /* add: fn + fm */
gen_vfp_add(dp);
break;
case 7: /* sub: fn - fm */
gen_vfp_sub(dp);
break;
case 8: /* div: fn / fm */
gen_vfp_div(dp);
break;
case 14: /* fconst */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
n = (insn << 12) & 0x80000000;
i = ((insn >> 12) & 0x70) | (insn & 0xf);
if (dp) {
if (i & 0x40)
i |= 0x3f80;
else
i |= 0x4000;
n |= i << 16;
tcg_gen_movi_i64(cpu_F0d, ((uint64_t)n) << 32);
} else {
if (i & 0x40)
i |= 0x780;
else
i |= 0x800;
n |= i << 19;
tcg_gen_movi_i32(cpu_F0s, n);
}
break;
case 15: /* extension space */
switch (rn) {
case 0: /* cpy */
/* no-op */
break;
case 1: /* abs */
gen_vfp_abs(dp);
break;
case 2: /* neg */
gen_vfp_neg(dp);
break;
case 3: /* sqrt */
gen_vfp_sqrt(dp);
break;
case 8: /* cmp */
gen_vfp_cmp(dp);
break;
case 9: /* cmpe */
gen_vfp_cmpe(dp);
break;
case 10: /* cmpz */
gen_vfp_cmp(dp);
break;
case 11: /* cmpez */
gen_vfp_F1_ld0(dp);
gen_vfp_cmpe(dp);
break;
case 15: /* single<->double conversion */
if (dp)
gen_helper_vfp_fcvtsd(cpu_F0s, cpu_F0d, cpu_env);
else
gen_helper_vfp_fcvtds(cpu_F0d, cpu_F0s, cpu_env);
break;
case 16: /* fuito */
gen_vfp_uito(dp);
break;
case 17: /* fsito */
gen_vfp_sito(dp);
break;
case 20: /* fshto */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_shto(dp, 16 - rm);
break;
case 21: /* fslto */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_slto(dp, 32 - rm);
break;
case 22: /* fuhto */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_uhto(dp, 16 - rm);
break;
case 23: /* fulto */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_ulto(dp, 32 - rm);
break;
case 24: /* ftoui */
gen_vfp_toui(dp);
break;
case 25: /* ftouiz */
gen_vfp_touiz(dp);
break;
case 26: /* ftosi */
gen_vfp_tosi(dp);
break;
case 27: /* ftosiz */
gen_vfp_tosiz(dp);
break;
case 28: /* ftosh */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_tosh(dp, 16 - rm);
break;
case 29: /* ftosl */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_tosl(dp, 32 - rm);
break;
case 30: /* ftouh */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_touh(dp, 16 - rm);
break;
case 31: /* ftoul */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_toul(dp, 32 - rm);
break;
default: /* undefined */
printf ("rn:%d\n", rn);
return 1;
}
break;
default: /* undefined */
printf ("op:%d\n", op);
return 1;
}
/* Write back the result. */
if (op == 15 && (rn >= 8 && rn <= 11))
; /* Comparison, do nothing. */
else if (op == 15 && rn > 17)
/* Integer result. */
gen_mov_vreg_F0(0, rd);
else if (op == 15 && rn == 15)
/* conversion */
gen_mov_vreg_F0(!dp, rd);
else
gen_mov_vreg_F0(dp, rd);
/* break out of the loop if we have finished */
if (veclen == 0)
break;
if (op == 15 && delta_m == 0) {
/* single source one-many */
while (veclen--) {
rd = ((rd + delta_d) & (bank_mask - 1))
| (rd & bank_mask);
gen_mov_vreg_F0(dp, rd);
}
break;
}
/* Setup the next operands. */
veclen--;
rd = ((rd + delta_d) & (bank_mask - 1))
| (rd & bank_mask);
if (op == 15) {
/* One source operand. */
rm = ((rm + delta_m) & (bank_mask - 1))
| (rm & bank_mask);
gen_mov_F0_vreg(dp, rm);
} else {
/* Two source operands. */
rn = ((rn + delta_d) & (bank_mask - 1))
| (rn & bank_mask);
gen_mov_F0_vreg(dp, rn);
if (delta_m) {
rm = ((rm + delta_m) & (bank_mask - 1))
| (rm & bank_mask);
gen_mov_F1_vreg(dp, rm);
}
}
}
}
break;
case 0xc:
case 0xd:
if (dp && (insn & 0x03e00000) == 0x00400000) {
/* two-register transfer */
rn = (insn >> 16) & 0xf;
rd = (insn >> 12) & 0xf;
if (dp) {
VFP_DREG_M(rm, insn);
} else {
rm = VFP_SREG_M(insn);
}
if (insn & ARM_CP_RW_BIT) {
/* vfp->arm */
if (dp) {
gen_mov_F0_vreg(0, rm * 2);
tmp = gen_vfp_mrs();
store_reg(s, rd, tmp);
gen_mov_F0_vreg(0, rm * 2 + 1);
tmp = gen_vfp_mrs();
store_reg(s, rn, tmp);
} else {
gen_mov_F0_vreg(0, rm);
tmp = gen_vfp_mrs();
store_reg(s, rn, tmp);
gen_mov_F0_vreg(0, rm + 1);
tmp = gen_vfp_mrs();
store_reg(s, rd, tmp);
}
} else {
/* arm->vfp */
if (dp) {
tmp = load_reg(s, rd);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm * 2);
tmp = load_reg(s, rn);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm * 2 + 1);
} else {
tmp = load_reg(s, rn);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm);
tmp = load_reg(s, rd);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm + 1);
}
}
} else {
/* Load/store */
rn = (insn >> 16) & 0xf;
if (dp)
VFP_DREG_D(rd, insn);
else
rd = VFP_SREG_D(insn);
if (s->thumb && rn == 15) {
addr = new_tmp();
tcg_gen_movi_i32(addr, s->pc & ~2);
} else {
addr = load_reg(s, rn);
}
if ((insn & 0x01200000) == 0x01000000) {
/* Single load/store */
offset = (insn & 0xff) << 2;
if ((insn & (1 << 23)) == 0)
offset = -offset;
tcg_gen_addi_i32(addr, addr, offset);
if (insn & (1 << 20)) {
gen_vfp_ld(s, dp, addr);
gen_mov_vreg_F0(dp, rd);
} else {
gen_mov_F0_vreg(dp, rd);
gen_vfp_st(s, dp, addr);
}
dead_tmp(addr);
} else {
/* load/store multiple */
if (dp)
n = (insn >> 1) & 0x7f;
else
n = insn & 0xff;
if (insn & (1 << 24)) /* pre-decrement */
tcg_gen_addi_i32(addr, addr, -((insn & 0xff) << 2));
if (dp)
offset = 8;
else
offset = 4;
for (i = 0; i < n; i++) {
if (insn & ARM_CP_RW_BIT) {
/* load */
gen_vfp_ld(s, dp, addr);
gen_mov_vreg_F0(dp, rd + i);
} else {
/* store */
gen_mov_F0_vreg(dp, rd + i);
gen_vfp_st(s, dp, addr);
}
tcg_gen_addi_i32(addr, addr, offset);
}
if (insn & (1 << 21)) {
/* writeback */
if (insn & (1 << 24))
offset = -offset * n;
else if (dp && (insn & 1))
offset = 4;
else
offset = 0;
if (offset != 0)
tcg_gen_addi_i32(addr, addr, offset);
store_reg(s, rn, addr);
} else {
dead_tmp(addr);
}
}
}
break;
default:
/* Should never happen. */
return 1;
}
return 0;
} | true | qemu | 71b3c3dea21a310c5df7406cdc1cffc64cf14c18 | static int disas_vfp_insn(CPUState * env, DisasContext *s, uint32_t insn)
{
uint32_t rd, rn, rm, op, i, n, offset, delta_d, delta_m, bank_mask;
int dp, veclen;
TCGv addr;
TCGv tmp;
TCGv tmp2;
if (!arm_feature(env, ARM_FEATURE_VFP))
return 1;
if (!vfp_enabled(env)) {
if ((insn & 0x0fe00fff) != 0x0ee00a10)
return 1;
rn = (insn >> 16) & 0xf;
if (rn != ARM_VFP_FPSID && rn != ARM_VFP_FPEXC
&& rn != ARM_VFP_MVFR1 && rn != ARM_VFP_MVFR0)
return 1;
}
dp = ((insn & 0xf00) == 0xb00);
switch ((insn >> 24) & 0xf) {
case 0xe:
if (insn & (1 << 4)) {
rd = (insn >> 12) & 0xf;
if (dp) {
int size;
int pass;
VFP_DREG_N(rn, insn);
if (insn & 0xf)
return 1;
if (insn & 0x00c00060
&& !arm_feature(env, ARM_FEATURE_NEON))
return 1;
pass = (insn >> 21) & 1;
if (insn & (1 << 22)) {
size = 0;
offset = ((insn >> 5) & 3) * 8;
} else if (insn & (1 << 5)) {
size = 1;
offset = (insn & (1 << 6)) ? 16 : 0;
} else {
size = 2;
offset = 0;
}
if (insn & ARM_CP_RW_BIT) {
tmp = neon_load_reg(rn, pass);
switch (size) {
case 0:
if (offset)
tcg_gen_shri_i32(tmp, tmp, offset);
if (insn & (1 << 23))
gen_uxtb(tmp);
else
gen_sxtb(tmp);
break;
case 1:
if (insn & (1 << 23)) {
if (offset) {
tcg_gen_shri_i32(tmp, tmp, 16);
} else {
gen_uxth(tmp);
}
} else {
if (offset) {
tcg_gen_sari_i32(tmp, tmp, 16);
} else {
gen_sxth(tmp);
}
}
break;
case 2:
break;
}
store_reg(s, rd, tmp);
} else {
tmp = load_reg(s, rd);
if (insn & (1 << 23)) {
if (size == 0) {
gen_neon_dup_u8(tmp, 0);
} else if (size == 1) {
gen_neon_dup_low16(tmp);
}
for (n = 0; n <= pass * 2; n++) {
tmp2 = new_tmp();
tcg_gen_mov_i32(tmp2, tmp);
neon_store_reg(rn, n, tmp2);
}
neon_store_reg(rn, n, tmp);
} else {
switch (size) {
case 0:
tmp2 = neon_load_reg(rn, pass);
gen_bfi(tmp, tmp2, tmp, offset, 0xff);
dead_tmp(tmp2);
break;
case 1:
tmp2 = neon_load_reg(rn, pass);
gen_bfi(tmp, tmp2, tmp, offset, 0xffff);
dead_tmp(tmp2);
break;
case 2:
break;
}
neon_store_reg(rn, pass, tmp);
}
}
} else {
if ((insn & 0x6f) != 0x00)
return 1;
rn = VFP_SREG_N(insn);
if (insn & ARM_CP_RW_BIT) {
if (insn & (1 << 21)) {
rn >>= 1;
switch (rn) {
case ARM_VFP_FPSID:
if (IS_USER(s)
&& arm_feature(env, ARM_FEATURE_VFP3))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
case ARM_VFP_FPEXC:
if (IS_USER(s))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
case ARM_VFP_FPINST:
case ARM_VFP_FPINST2:
if (IS_USER(s)
|| arm_feature(env, ARM_FEATURE_VFP3))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
case ARM_VFP_FPSCR:
if (rd == 15) {
tmp = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]);
tcg_gen_andi_i32(tmp, tmp, 0xf0000000);
} else {
tmp = new_tmp();
gen_helper_vfp_get_fpscr(tmp, cpu_env);
}
break;
case ARM_VFP_MVFR0:
case ARM_VFP_MVFR1:
if (IS_USER(s)
|| !arm_feature(env, ARM_FEATURE_VFP3))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
default:
return 1;
}
} else {
gen_mov_F0_vreg(0, rn);
tmp = gen_vfp_mrs();
}
if (rd == 15) {
gen_set_nzcv(tmp);
dead_tmp(tmp);
} else {
store_reg(s, rd, tmp);
}
} else {
tmp = load_reg(s, rd);
if (insn & (1 << 21)) {
rn >>= 1;
switch (rn) {
case ARM_VFP_FPSID:
case ARM_VFP_MVFR0:
case ARM_VFP_MVFR1:
break;
case ARM_VFP_FPSCR:
gen_helper_vfp_set_fpscr(cpu_env, tmp);
dead_tmp(tmp);
gen_lookup_tb(s);
break;
case ARM_VFP_FPEXC:
if (IS_USER(s))
return 1;
store_cpu_field(tmp, vfp.xregs[rn]);
gen_lookup_tb(s);
break;
case ARM_VFP_FPINST:
case ARM_VFP_FPINST2:
store_cpu_field(tmp, vfp.xregs[rn]);
break;
default:
return 1;
}
} else {
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rn);
}
}
}
} else {
op = ((insn >> 20) & 8) | ((insn >> 19) & 6) | ((insn >> 6) & 1);
if (dp) {
if (op == 15) {
rn = ((insn >> 15) & 0x1e) | ((insn >> 7) & 1);
} else {
VFP_DREG_N(rn, insn);
}
if (op == 15 && (rn == 15 || rn > 17)) {
rd = VFP_SREG_D(insn);
} else {
VFP_DREG_D(rd, insn);
}
if (op == 15 && (rn == 16 || rn == 17)) {
rm = ((insn << 1) & 0x1e) | ((insn >> 5) & 1);
} else {
VFP_DREG_M(rm, insn);
}
} else {
rn = VFP_SREG_N(insn);
if (op == 15 && rn == 15) {
VFP_DREG_D(rd, insn);
} else {
rd = VFP_SREG_D(insn);
}
rm = VFP_SREG_M(insn);
}
veclen = env->vfp.vec_len;
if (op == 15 && rn > 3)
veclen = 0;
delta_m = 0;
delta_d = 0;
bank_mask = 0;
if (veclen > 0) {
if (dp)
bank_mask = 0xc;
else
bank_mask = 0x18;
if ((rd & bank_mask) == 0) {
veclen = 0;
} else {
if (dp)
delta_d = (env->vfp.vec_stride >> 1) + 1;
else
delta_d = env->vfp.vec_stride + 1;
if ((rm & bank_mask) == 0) {
delta_m = 0;
} else {
delta_m = delta_d;
}
}
}
if (op == 15) {
switch (rn) {
case 16:
case 17:
gen_mov_F0_vreg(0, rm);
break;
case 8:
case 9:
gen_mov_F0_vreg(dp, rd);
gen_mov_F1_vreg(dp, rm);
break;
case 10:
case 11:
gen_mov_F0_vreg(dp, rd);
gen_vfp_F1_ld0(dp);
break;
case 20:
case 21:
case 22:
case 23:
case 28:
case 29:
case 30:
case 31:
gen_mov_F0_vreg(dp, rd);
break;
default:
gen_mov_F0_vreg(dp, rm);
break;
}
} else {
gen_mov_F0_vreg(dp, rn);
gen_mov_F1_vreg(dp, rm);
}
for (;;) {
switch (op) {
case 0:
gen_vfp_mul(dp);
gen_mov_F1_vreg(dp, rd);
gen_vfp_add(dp);
break;
case 1:
gen_vfp_mul(dp);
gen_vfp_neg(dp);
gen_mov_F1_vreg(dp, rd);
gen_vfp_add(dp);
break;
case 2:
gen_vfp_mul(dp);
gen_mov_F1_vreg(dp, rd);
gen_vfp_sub(dp);
break;
case 3:
gen_vfp_mul(dp);
gen_vfp_neg(dp);
gen_mov_F1_vreg(dp, rd);
gen_vfp_sub(dp);
break;
case 4:
gen_vfp_mul(dp);
break;
case 5:
gen_vfp_mul(dp);
gen_vfp_neg(dp);
break;
case 6:
gen_vfp_add(dp);
break;
case 7:
gen_vfp_sub(dp);
break;
case 8:
gen_vfp_div(dp);
break;
case 14:
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
n = (insn << 12) & 0x80000000;
i = ((insn >> 12) & 0x70) | (insn & 0xf);
if (dp) {
if (i & 0x40)
i |= 0x3f80;
else
i |= 0x4000;
n |= i << 16;
tcg_gen_movi_i64(cpu_F0d, ((uint64_t)n) << 32);
} else {
if (i & 0x40)
i |= 0x780;
else
i |= 0x800;
n |= i << 19;
tcg_gen_movi_i32(cpu_F0s, n);
}
break;
case 15:
switch (rn) {
case 0:
break;
case 1:
gen_vfp_abs(dp);
break;
case 2:
gen_vfp_neg(dp);
break;
case 3:
gen_vfp_sqrt(dp);
break;
case 8:
gen_vfp_cmp(dp);
break;
case 9:
gen_vfp_cmpe(dp);
break;
case 10:
gen_vfp_cmp(dp);
break;
case 11:
gen_vfp_F1_ld0(dp);
gen_vfp_cmpe(dp);
break;
case 15:
if (dp)
gen_helper_vfp_fcvtsd(cpu_F0s, cpu_F0d, cpu_env);
else
gen_helper_vfp_fcvtds(cpu_F0d, cpu_F0s, cpu_env);
break;
case 16:
gen_vfp_uito(dp);
break;
case 17:
gen_vfp_sito(dp);
break;
case 20:
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_shto(dp, 16 - rm);
break;
case 21:
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_slto(dp, 32 - rm);
break;
case 22:
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_uhto(dp, 16 - rm);
break;
case 23:
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_ulto(dp, 32 - rm);
break;
case 24:
gen_vfp_toui(dp);
break;
case 25:
gen_vfp_touiz(dp);
break;
case 26:
gen_vfp_tosi(dp);
break;
case 27:
gen_vfp_tosiz(dp);
break;
case 28:
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_tosh(dp, 16 - rm);
break;
case 29:
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_tosl(dp, 32 - rm);
break;
case 30:
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_touh(dp, 16 - rm);
break;
case 31:
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_toul(dp, 32 - rm);
break;
default:
printf ("rn:%d\n", rn);
return 1;
}
break;
default:
printf ("op:%d\n", op);
return 1;
}
if (op == 15 && (rn >= 8 && rn <= 11))
;
else if (op == 15 && rn > 17)
gen_mov_vreg_F0(0, rd);
else if (op == 15 && rn == 15)
gen_mov_vreg_F0(!dp, rd);
else
gen_mov_vreg_F0(dp, rd);
if (veclen == 0)
break;
if (op == 15 && delta_m == 0) {
while (veclen--) {
rd = ((rd + delta_d) & (bank_mask - 1))
| (rd & bank_mask);
gen_mov_vreg_F0(dp, rd);
}
break;
}
veclen--;
rd = ((rd + delta_d) & (bank_mask - 1))
| (rd & bank_mask);
if (op == 15) {
rm = ((rm + delta_m) & (bank_mask - 1))
| (rm & bank_mask);
gen_mov_F0_vreg(dp, rm);
} else {
rn = ((rn + delta_d) & (bank_mask - 1))
| (rn & bank_mask);
gen_mov_F0_vreg(dp, rn);
if (delta_m) {
rm = ((rm + delta_m) & (bank_mask - 1))
| (rm & bank_mask);
gen_mov_F1_vreg(dp, rm);
}
}
}
}
break;
case 0xc:
case 0xd:
if (dp && (insn & 0x03e00000) == 0x00400000) {
rn = (insn >> 16) & 0xf;
rd = (insn >> 12) & 0xf;
if (dp) {
VFP_DREG_M(rm, insn);
} else {
rm = VFP_SREG_M(insn);
}
if (insn & ARM_CP_RW_BIT) {
if (dp) {
gen_mov_F0_vreg(0, rm * 2);
tmp = gen_vfp_mrs();
store_reg(s, rd, tmp);
gen_mov_F0_vreg(0, rm * 2 + 1);
tmp = gen_vfp_mrs();
store_reg(s, rn, tmp);
} else {
gen_mov_F0_vreg(0, rm);
tmp = gen_vfp_mrs();
store_reg(s, rn, tmp);
gen_mov_F0_vreg(0, rm + 1);
tmp = gen_vfp_mrs();
store_reg(s, rd, tmp);
}
} else {
if (dp) {
tmp = load_reg(s, rd);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm * 2);
tmp = load_reg(s, rn);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm * 2 + 1);
} else {
tmp = load_reg(s, rn);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm);
tmp = load_reg(s, rd);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm + 1);
}
}
} else {
rn = (insn >> 16) & 0xf;
if (dp)
VFP_DREG_D(rd, insn);
else
rd = VFP_SREG_D(insn);
if (s->thumb && rn == 15) {
addr = new_tmp();
tcg_gen_movi_i32(addr, s->pc & ~2);
} else {
addr = load_reg(s, rn);
}
if ((insn & 0x01200000) == 0x01000000) {
offset = (insn & 0xff) << 2;
if ((insn & (1 << 23)) == 0)
offset = -offset;
tcg_gen_addi_i32(addr, addr, offset);
if (insn & (1 << 20)) {
gen_vfp_ld(s, dp, addr);
gen_mov_vreg_F0(dp, rd);
} else {
gen_mov_F0_vreg(dp, rd);
gen_vfp_st(s, dp, addr);
}
dead_tmp(addr);
} else {
if (dp)
n = (insn >> 1) & 0x7f;
else
n = insn & 0xff;
if (insn & (1 << 24))
tcg_gen_addi_i32(addr, addr, -((insn & 0xff) << 2));
if (dp)
offset = 8;
else
offset = 4;
for (i = 0; i < n; i++) {
if (insn & ARM_CP_RW_BIT) {
gen_vfp_ld(s, dp, addr);
gen_mov_vreg_F0(dp, rd + i);
} else {
gen_mov_F0_vreg(dp, rd + i);
gen_vfp_st(s, dp, addr);
}
tcg_gen_addi_i32(addr, addr, offset);
}
if (insn & (1 << 21)) {
if (insn & (1 << 24))
offset = -offset * n;
else if (dp && (insn & 1))
offset = 4;
else
offset = 0;
if (offset != 0)
tcg_gen_addi_i32(addr, addr, offset);
store_reg(s, rn, addr);
} else {
dead_tmp(addr);
}
}
}
break;
default:
return 1;
}
return 0;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(CPUState * VAR_0, DisasContext *VAR_1, uint32_t VAR_2)
{
uint32_t rd, rn, rm, op, i, n, offset, delta_d, delta_m, bank_mask;
int VAR_3, VAR_4;
TCGv addr;
TCGv tmp;
TCGv tmp2;
if (!arm_feature(VAR_0, ARM_FEATURE_VFP))
return 1;
if (!vfp_enabled(VAR_0)) {
if ((VAR_2 & 0x0fe00fff) != 0x0ee00a10)
return 1;
rn = (VAR_2 >> 16) & 0xf;
if (rn != ARM_VFP_FPSID && rn != ARM_VFP_FPEXC
&& rn != ARM_VFP_MVFR1 && rn != ARM_VFP_MVFR0)
return 1;
}
VAR_3 = ((VAR_2 & 0xf00) == 0xb00);
switch ((VAR_2 >> 24) & 0xf) {
case 0xe:
if (VAR_2 & (1 << 4)) {
rd = (VAR_2 >> 12) & 0xf;
if (VAR_3) {
int VAR_5;
int VAR_6;
VFP_DREG_N(rn, VAR_2);
if (VAR_2 & 0xf)
return 1;
if (VAR_2 & 0x00c00060
&& !arm_feature(VAR_0, ARM_FEATURE_NEON))
return 1;
VAR_6 = (VAR_2 >> 21) & 1;
if (VAR_2 & (1 << 22)) {
VAR_5 = 0;
offset = ((VAR_2 >> 5) & 3) * 8;
} else if (VAR_2 & (1 << 5)) {
VAR_5 = 1;
offset = (VAR_2 & (1 << 6)) ? 16 : 0;
} else {
VAR_5 = 2;
offset = 0;
}
if (VAR_2 & ARM_CP_RW_BIT) {
tmp = neon_load_reg(rn, VAR_6);
switch (VAR_5) {
case 0:
if (offset)
tcg_gen_shri_i32(tmp, tmp, offset);
if (VAR_2 & (1 << 23))
gen_uxtb(tmp);
else
gen_sxtb(tmp);
break;
case 1:
if (VAR_2 & (1 << 23)) {
if (offset) {
tcg_gen_shri_i32(tmp, tmp, 16);
} else {
gen_uxth(tmp);
}
} else {
if (offset) {
tcg_gen_sari_i32(tmp, tmp, 16);
} else {
gen_sxth(tmp);
}
}
break;
case 2:
break;
}
store_reg(VAR_1, rd, tmp);
} else {
tmp = load_reg(VAR_1, rd);
if (VAR_2 & (1 << 23)) {
if (VAR_5 == 0) {
gen_neon_dup_u8(tmp, 0);
} else if (VAR_5 == 1) {
gen_neon_dup_low16(tmp);
}
for (n = 0; n <= VAR_6 * 2; n++) {
tmp2 = new_tmp();
tcg_gen_mov_i32(tmp2, tmp);
neon_store_reg(rn, n, tmp2);
}
neon_store_reg(rn, n, tmp);
} else {
switch (VAR_5) {
case 0:
tmp2 = neon_load_reg(rn, VAR_6);
gen_bfi(tmp, tmp2, tmp, offset, 0xff);
dead_tmp(tmp2);
break;
case 1:
tmp2 = neon_load_reg(rn, VAR_6);
gen_bfi(tmp, tmp2, tmp, offset, 0xffff);
dead_tmp(tmp2);
break;
case 2:
break;
}
neon_store_reg(rn, VAR_6, tmp);
}
}
} else {
if ((VAR_2 & 0x6f) != 0x00)
return 1;
rn = VFP_SREG_N(VAR_2);
if (VAR_2 & ARM_CP_RW_BIT) {
if (VAR_2 & (1 << 21)) {
rn >>= 1;
switch (rn) {
case ARM_VFP_FPSID:
if (IS_USER(VAR_1)
&& arm_feature(VAR_0, ARM_FEATURE_VFP3))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
case ARM_VFP_FPEXC:
if (IS_USER(VAR_1))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
case ARM_VFP_FPINST:
case ARM_VFP_FPINST2:
if (IS_USER(VAR_1)
|| arm_feature(VAR_0, ARM_FEATURE_VFP3))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
case ARM_VFP_FPSCR:
if (rd == 15) {
tmp = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]);
tcg_gen_andi_i32(tmp, tmp, 0xf0000000);
} else {
tmp = new_tmp();
gen_helper_vfp_get_fpscr(tmp, cpu_env);
}
break;
case ARM_VFP_MVFR0:
case ARM_VFP_MVFR1:
if (IS_USER(VAR_1)
|| !arm_feature(VAR_0, ARM_FEATURE_VFP3))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
default:
return 1;
}
} else {
gen_mov_F0_vreg(0, rn);
tmp = gen_vfp_mrs();
}
if (rd == 15) {
gen_set_nzcv(tmp);
dead_tmp(tmp);
} else {
store_reg(VAR_1, rd, tmp);
}
} else {
tmp = load_reg(VAR_1, rd);
if (VAR_2 & (1 << 21)) {
rn >>= 1;
switch (rn) {
case ARM_VFP_FPSID:
case ARM_VFP_MVFR0:
case ARM_VFP_MVFR1:
break;
case ARM_VFP_FPSCR:
gen_helper_vfp_set_fpscr(cpu_env, tmp);
dead_tmp(tmp);
gen_lookup_tb(VAR_1);
break;
case ARM_VFP_FPEXC:
if (IS_USER(VAR_1))
return 1;
store_cpu_field(tmp, vfp.xregs[rn]);
gen_lookup_tb(VAR_1);
break;
case ARM_VFP_FPINST:
case ARM_VFP_FPINST2:
store_cpu_field(tmp, vfp.xregs[rn]);
break;
default:
return 1;
}
} else {
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rn);
}
}
}
} else {
op = ((VAR_2 >> 20) & 8) | ((VAR_2 >> 19) & 6) | ((VAR_2 >> 6) & 1);
if (VAR_3) {
if (op == 15) {
rn = ((VAR_2 >> 15) & 0x1e) | ((VAR_2 >> 7) & 1);
} else {
VFP_DREG_N(rn, VAR_2);
}
if (op == 15 && (rn == 15 || rn > 17)) {
rd = VFP_SREG_D(VAR_2);
} else {
VFP_DREG_D(rd, VAR_2);
}
if (op == 15 && (rn == 16 || rn == 17)) {
rm = ((VAR_2 << 1) & 0x1e) | ((VAR_2 >> 5) & 1);
} else {
VFP_DREG_M(rm, VAR_2);
}
} else {
rn = VFP_SREG_N(VAR_2);
if (op == 15 && rn == 15) {
VFP_DREG_D(rd, VAR_2);
} else {
rd = VFP_SREG_D(VAR_2);
}
rm = VFP_SREG_M(VAR_2);
}
VAR_4 = VAR_0->vfp.vec_len;
if (op == 15 && rn > 3)
VAR_4 = 0;
delta_m = 0;
delta_d = 0;
bank_mask = 0;
if (VAR_4 > 0) {
if (VAR_3)
bank_mask = 0xc;
else
bank_mask = 0x18;
if ((rd & bank_mask) == 0) {
VAR_4 = 0;
} else {
if (VAR_3)
delta_d = (VAR_0->vfp.vec_stride >> 1) + 1;
else
delta_d = VAR_0->vfp.vec_stride + 1;
if ((rm & bank_mask) == 0) {
delta_m = 0;
} else {
delta_m = delta_d;
}
}
}
if (op == 15) {
switch (rn) {
case 16:
case 17:
gen_mov_F0_vreg(0, rm);
break;
case 8:
case 9:
gen_mov_F0_vreg(VAR_3, rd);
gen_mov_F1_vreg(VAR_3, rm);
break;
case 10:
case 11:
gen_mov_F0_vreg(VAR_3, rd);
gen_vfp_F1_ld0(VAR_3);
break;
case 20:
case 21:
case 22:
case 23:
case 28:
case 29:
case 30:
case 31:
gen_mov_F0_vreg(VAR_3, rd);
break;
default:
gen_mov_F0_vreg(VAR_3, rm);
break;
}
} else {
gen_mov_F0_vreg(VAR_3, rn);
gen_mov_F1_vreg(VAR_3, rm);
}
for (;;) {
switch (op) {
case 0:
gen_vfp_mul(VAR_3);
gen_mov_F1_vreg(VAR_3, rd);
gen_vfp_add(VAR_3);
break;
case 1:
gen_vfp_mul(VAR_3);
gen_vfp_neg(VAR_3);
gen_mov_F1_vreg(VAR_3, rd);
gen_vfp_add(VAR_3);
break;
case 2:
gen_vfp_mul(VAR_3);
gen_mov_F1_vreg(VAR_3, rd);
gen_vfp_sub(VAR_3);
break;
case 3:
gen_vfp_mul(VAR_3);
gen_vfp_neg(VAR_3);
gen_mov_F1_vreg(VAR_3, rd);
gen_vfp_sub(VAR_3);
break;
case 4:
gen_vfp_mul(VAR_3);
break;
case 5:
gen_vfp_mul(VAR_3);
gen_vfp_neg(VAR_3);
break;
case 6:
gen_vfp_add(VAR_3);
break;
case 7:
gen_vfp_sub(VAR_3);
break;
case 8:
gen_vfp_div(VAR_3);
break;
case 14:
if (!arm_feature(VAR_0, ARM_FEATURE_VFP3))
return 1;
n = (VAR_2 << 12) & 0x80000000;
i = ((VAR_2 >> 12) & 0x70) | (VAR_2 & 0xf);
if (VAR_3) {
if (i & 0x40)
i |= 0x3f80;
else
i |= 0x4000;
n |= i << 16;
tcg_gen_movi_i64(cpu_F0d, ((uint64_t)n) << 32);
} else {
if (i & 0x40)
i |= 0x780;
else
i |= 0x800;
n |= i << 19;
tcg_gen_movi_i32(cpu_F0s, n);
}
break;
case 15:
switch (rn) {
case 0:
break;
case 1:
gen_vfp_abs(VAR_3);
break;
case 2:
gen_vfp_neg(VAR_3);
break;
case 3:
gen_vfp_sqrt(VAR_3);
break;
case 8:
gen_vfp_cmp(VAR_3);
break;
case 9:
gen_vfp_cmpe(VAR_3);
break;
case 10:
gen_vfp_cmp(VAR_3);
break;
case 11:
gen_vfp_F1_ld0(VAR_3);
gen_vfp_cmpe(VAR_3);
break;
case 15:
if (VAR_3)
gen_helper_vfp_fcvtsd(cpu_F0s, cpu_F0d, cpu_env);
else
gen_helper_vfp_fcvtds(cpu_F0d, cpu_F0s, cpu_env);
break;
case 16:
gen_vfp_uito(VAR_3);
break;
case 17:
gen_vfp_sito(VAR_3);
break;
case 20:
if (!arm_feature(VAR_0, ARM_FEATURE_VFP3))
return 1;
gen_vfp_shto(VAR_3, 16 - rm);
break;
case 21:
if (!arm_feature(VAR_0, ARM_FEATURE_VFP3))
return 1;
gen_vfp_slto(VAR_3, 32 - rm);
break;
case 22:
if (!arm_feature(VAR_0, ARM_FEATURE_VFP3))
return 1;
gen_vfp_uhto(VAR_3, 16 - rm);
break;
case 23:
if (!arm_feature(VAR_0, ARM_FEATURE_VFP3))
return 1;
gen_vfp_ulto(VAR_3, 32 - rm);
break;
case 24:
gen_vfp_toui(VAR_3);
break;
case 25:
gen_vfp_touiz(VAR_3);
break;
case 26:
gen_vfp_tosi(VAR_3);
break;
case 27:
gen_vfp_tosiz(VAR_3);
break;
case 28:
if (!arm_feature(VAR_0, ARM_FEATURE_VFP3))
return 1;
gen_vfp_tosh(VAR_3, 16 - rm);
break;
case 29:
if (!arm_feature(VAR_0, ARM_FEATURE_VFP3))
return 1;
gen_vfp_tosl(VAR_3, 32 - rm);
break;
case 30:
if (!arm_feature(VAR_0, ARM_FEATURE_VFP3))
return 1;
gen_vfp_touh(VAR_3, 16 - rm);
break;
case 31:
if (!arm_feature(VAR_0, ARM_FEATURE_VFP3))
return 1;
gen_vfp_toul(VAR_3, 32 - rm);
break;
default:
printf ("rn:%d\n", rn);
return 1;
}
break;
default:
printf ("op:%d\n", op);
return 1;
}
if (op == 15 && (rn >= 8 && rn <= 11))
;
else if (op == 15 && rn > 17)
gen_mov_vreg_F0(0, rd);
else if (op == 15 && rn == 15)
gen_mov_vreg_F0(!VAR_3, rd);
else
gen_mov_vreg_F0(VAR_3, rd);
if (VAR_4 == 0)
break;
if (op == 15 && delta_m == 0) {
while (VAR_4--) {
rd = ((rd + delta_d) & (bank_mask - 1))
| (rd & bank_mask);
gen_mov_vreg_F0(VAR_3, rd);
}
break;
}
VAR_4--;
rd = ((rd + delta_d) & (bank_mask - 1))
| (rd & bank_mask);
if (op == 15) {
rm = ((rm + delta_m) & (bank_mask - 1))
| (rm & bank_mask);
gen_mov_F0_vreg(VAR_3, rm);
} else {
rn = ((rn + delta_d) & (bank_mask - 1))
| (rn & bank_mask);
gen_mov_F0_vreg(VAR_3, rn);
if (delta_m) {
rm = ((rm + delta_m) & (bank_mask - 1))
| (rm & bank_mask);
gen_mov_F1_vreg(VAR_3, rm);
}
}
}
}
break;
case 0xc:
case 0xd:
if (VAR_3 && (VAR_2 & 0x03e00000) == 0x00400000) {
rn = (VAR_2 >> 16) & 0xf;
rd = (VAR_2 >> 12) & 0xf;
if (VAR_3) {
VFP_DREG_M(rm, VAR_2);
} else {
rm = VFP_SREG_M(VAR_2);
}
if (VAR_2 & ARM_CP_RW_BIT) {
if (VAR_3) {
gen_mov_F0_vreg(0, rm * 2);
tmp = gen_vfp_mrs();
store_reg(VAR_1, rd, tmp);
gen_mov_F0_vreg(0, rm * 2 + 1);
tmp = gen_vfp_mrs();
store_reg(VAR_1, rn, tmp);
} else {
gen_mov_F0_vreg(0, rm);
tmp = gen_vfp_mrs();
store_reg(VAR_1, rn, tmp);
gen_mov_F0_vreg(0, rm + 1);
tmp = gen_vfp_mrs();
store_reg(VAR_1, rd, tmp);
}
} else {
if (VAR_3) {
tmp = load_reg(VAR_1, rd);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm * 2);
tmp = load_reg(VAR_1, rn);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm * 2 + 1);
} else {
tmp = load_reg(VAR_1, rn);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm);
tmp = load_reg(VAR_1, rd);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm + 1);
}
}
} else {
rn = (VAR_2 >> 16) & 0xf;
if (VAR_3)
VFP_DREG_D(rd, VAR_2);
else
rd = VFP_SREG_D(VAR_2);
if (VAR_1->thumb && rn == 15) {
addr = new_tmp();
tcg_gen_movi_i32(addr, VAR_1->pc & ~2);
} else {
addr = load_reg(VAR_1, rn);
}
if ((VAR_2 & 0x01200000) == 0x01000000) {
offset = (VAR_2 & 0xff) << 2;
if ((VAR_2 & (1 << 23)) == 0)
offset = -offset;
tcg_gen_addi_i32(addr, addr, offset);
if (VAR_2 & (1 << 20)) {
gen_vfp_ld(VAR_1, VAR_3, addr);
gen_mov_vreg_F0(VAR_3, rd);
} else {
gen_mov_F0_vreg(VAR_3, rd);
gen_vfp_st(VAR_1, VAR_3, addr);
}
dead_tmp(addr);
} else {
if (VAR_3)
n = (VAR_2 >> 1) & 0x7f;
else
n = VAR_2 & 0xff;
if (VAR_2 & (1 << 24))
tcg_gen_addi_i32(addr, addr, -((VAR_2 & 0xff) << 2));
if (VAR_3)
offset = 8;
else
offset = 4;
for (i = 0; i < n; i++) {
if (VAR_2 & ARM_CP_RW_BIT) {
gen_vfp_ld(VAR_1, VAR_3, addr);
gen_mov_vreg_F0(VAR_3, rd + i);
} else {
gen_mov_F0_vreg(VAR_3, rd + i);
gen_vfp_st(VAR_1, VAR_3, addr);
}
tcg_gen_addi_i32(addr, addr, offset);
}
if (VAR_2 & (1 << 21)) {
if (VAR_2 & (1 << 24))
offset = -offset * n;
else if (VAR_3 && (VAR_2 & 1))
offset = 4;
else
offset = 0;
if (offset != 0)
tcg_gen_addi_i32(addr, addr, offset);
store_reg(VAR_1, rn, addr);
} else {
dead_tmp(addr);
}
}
}
break;
default:
return 1;
}
return 0;
} | [
"static int FUNC_0(CPUState * VAR_0, DisasContext *VAR_1, uint32_t VAR_2)\n{",
"uint32_t rd, rn, rm, op, i, n, offset, delta_d, delta_m, bank_mask;",
"int VAR_3, VAR_4;",
"TCGv addr;",
"TCGv tmp;",
"TCGv tmp2;",
"if (!arm_feature(VAR_0, ARM_FEATURE_VFP))\nreturn 1;",
"if (!vfp_enabled(VAR_0)) {",
"if ((VAR_2 & 0x0fe00fff) != 0x0ee00a10)\nreturn 1;",
"rn = (VAR_2 >> 16) & 0xf;",
"if (rn != ARM_VFP_FPSID && rn != ARM_VFP_FPEXC\n&& rn != ARM_VFP_MVFR1 && rn != ARM_VFP_MVFR0)\nreturn 1;",
"}",
"VAR_3 = ((VAR_2 & 0xf00) == 0xb00);",
"switch ((VAR_2 >> 24) & 0xf) {",
"case 0xe:\nif (VAR_2 & (1 << 4)) {",
"rd = (VAR_2 >> 12) & 0xf;",
"if (VAR_3) {",
"int VAR_5;",
"int VAR_6;",
"VFP_DREG_N(rn, VAR_2);",
"if (VAR_2 & 0xf)\nreturn 1;",
"if (VAR_2 & 0x00c00060\n&& !arm_feature(VAR_0, ARM_FEATURE_NEON))\nreturn 1;",
"VAR_6 = (VAR_2 >> 21) & 1;",
"if (VAR_2 & (1 << 22)) {",
"VAR_5 = 0;",
"offset = ((VAR_2 >> 5) & 3) * 8;",
"} else if (VAR_2 & (1 << 5)) {",
"VAR_5 = 1;",
"offset = (VAR_2 & (1 << 6)) ? 16 : 0;",
"} else {",
"VAR_5 = 2;",
"offset = 0;",
"}",
"if (VAR_2 & ARM_CP_RW_BIT) {",
"tmp = neon_load_reg(rn, VAR_6);",
"switch (VAR_5) {",
"case 0:\nif (offset)\ntcg_gen_shri_i32(tmp, tmp, offset);",
"if (VAR_2 & (1 << 23))\ngen_uxtb(tmp);",
"else\ngen_sxtb(tmp);",
"break;",
"case 1:\nif (VAR_2 & (1 << 23)) {",
"if (offset) {",
"tcg_gen_shri_i32(tmp, tmp, 16);",
"} else {",
"gen_uxth(tmp);",
"}",
"} else {",
"if (offset) {",
"tcg_gen_sari_i32(tmp, tmp, 16);",
"} else {",
"gen_sxth(tmp);",
"}",
"}",
"break;",
"case 2:\nbreak;",
"}",
"store_reg(VAR_1, rd, tmp);",
"} else {",
"tmp = load_reg(VAR_1, rd);",
"if (VAR_2 & (1 << 23)) {",
"if (VAR_5 == 0) {",
"gen_neon_dup_u8(tmp, 0);",
"} else if (VAR_5 == 1) {",
"gen_neon_dup_low16(tmp);",
"}",
"for (n = 0; n <= VAR_6 * 2; n++) {",
"tmp2 = new_tmp();",
"tcg_gen_mov_i32(tmp2, tmp);",
"neon_store_reg(rn, n, tmp2);",
"}",
"neon_store_reg(rn, n, tmp);",
"} else {",
"switch (VAR_5) {",
"case 0:\ntmp2 = neon_load_reg(rn, VAR_6);",
"gen_bfi(tmp, tmp2, tmp, offset, 0xff);",
"dead_tmp(tmp2);",
"break;",
"case 1:\ntmp2 = neon_load_reg(rn, VAR_6);",
"gen_bfi(tmp, tmp2, tmp, offset, 0xffff);",
"dead_tmp(tmp2);",
"break;",
"case 2:\nbreak;",
"}",
"neon_store_reg(rn, VAR_6, tmp);",
"}",
"}",
"} else {",
"if ((VAR_2 & 0x6f) != 0x00)\nreturn 1;",
"rn = VFP_SREG_N(VAR_2);",
"if (VAR_2 & ARM_CP_RW_BIT) {",
"if (VAR_2 & (1 << 21)) {",
"rn >>= 1;",
"switch (rn) {",
"case ARM_VFP_FPSID:\nif (IS_USER(VAR_1)\n&& arm_feature(VAR_0, ARM_FEATURE_VFP3))\nreturn 1;",
"tmp = load_cpu_field(vfp.xregs[rn]);",
"break;",
"case ARM_VFP_FPEXC:\nif (IS_USER(VAR_1))\nreturn 1;",
"tmp = load_cpu_field(vfp.xregs[rn]);",
"break;",
"case ARM_VFP_FPINST:\ncase ARM_VFP_FPINST2:\nif (IS_USER(VAR_1)\n|| arm_feature(VAR_0, ARM_FEATURE_VFP3))\nreturn 1;",
"tmp = load_cpu_field(vfp.xregs[rn]);",
"break;",
"case ARM_VFP_FPSCR:\nif (rd == 15) {",
"tmp = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]);",
"tcg_gen_andi_i32(tmp, tmp, 0xf0000000);",
"} else {",
"tmp = new_tmp();",
"gen_helper_vfp_get_fpscr(tmp, cpu_env);",
"}",
"break;",
"case ARM_VFP_MVFR0:\ncase ARM_VFP_MVFR1:\nif (IS_USER(VAR_1)\n|| !arm_feature(VAR_0, ARM_FEATURE_VFP3))\nreturn 1;",
"tmp = load_cpu_field(vfp.xregs[rn]);",
"break;",
"default:\nreturn 1;",
"}",
"} else {",
"gen_mov_F0_vreg(0, rn);",
"tmp = gen_vfp_mrs();",
"}",
"if (rd == 15) {",
"gen_set_nzcv(tmp);",
"dead_tmp(tmp);",
"} else {",
"store_reg(VAR_1, rd, tmp);",
"}",
"} else {",
"tmp = load_reg(VAR_1, rd);",
"if (VAR_2 & (1 << 21)) {",
"rn >>= 1;",
"switch (rn) {",
"case ARM_VFP_FPSID:\ncase ARM_VFP_MVFR0:\ncase ARM_VFP_MVFR1:\nbreak;",
"case ARM_VFP_FPSCR:\ngen_helper_vfp_set_fpscr(cpu_env, tmp);",
"dead_tmp(tmp);",
"gen_lookup_tb(VAR_1);",
"break;",
"case ARM_VFP_FPEXC:\nif (IS_USER(VAR_1))\nreturn 1;",
"store_cpu_field(tmp, vfp.xregs[rn]);",
"gen_lookup_tb(VAR_1);",
"break;",
"case ARM_VFP_FPINST:\ncase ARM_VFP_FPINST2:\nstore_cpu_field(tmp, vfp.xregs[rn]);",
"break;",
"default:\nreturn 1;",
"}",
"} else {",
"gen_vfp_msr(tmp);",
"gen_mov_vreg_F0(0, rn);",
"}",
"}",
"}",
"} else {",
"op = ((VAR_2 >> 20) & 8) | ((VAR_2 >> 19) & 6) | ((VAR_2 >> 6) & 1);",
"if (VAR_3) {",
"if (op == 15) {",
"rn = ((VAR_2 >> 15) & 0x1e) | ((VAR_2 >> 7) & 1);",
"} else {",
"VFP_DREG_N(rn, VAR_2);",
"}",
"if (op == 15 && (rn == 15 || rn > 17)) {",
"rd = VFP_SREG_D(VAR_2);",
"} else {",
"VFP_DREG_D(rd, VAR_2);",
"}",
"if (op == 15 && (rn == 16 || rn == 17)) {",
"rm = ((VAR_2 << 1) & 0x1e) | ((VAR_2 >> 5) & 1);",
"} else {",
"VFP_DREG_M(rm, VAR_2);",
"}",
"} else {",
"rn = VFP_SREG_N(VAR_2);",
"if (op == 15 && rn == 15) {",
"VFP_DREG_D(rd, VAR_2);",
"} else {",
"rd = VFP_SREG_D(VAR_2);",
"}",
"rm = VFP_SREG_M(VAR_2);",
"}",
"VAR_4 = VAR_0->vfp.vec_len;",
"if (op == 15 && rn > 3)\nVAR_4 = 0;",
"delta_m = 0;",
"delta_d = 0;",
"bank_mask = 0;",
"if (VAR_4 > 0) {",
"if (VAR_3)\nbank_mask = 0xc;",
"else\nbank_mask = 0x18;",
"if ((rd & bank_mask) == 0) {",
"VAR_4 = 0;",
"} else {",
"if (VAR_3)\ndelta_d = (VAR_0->vfp.vec_stride >> 1) + 1;",
"else\ndelta_d = VAR_0->vfp.vec_stride + 1;",
"if ((rm & bank_mask) == 0) {",
"delta_m = 0;",
"} else {",
"delta_m = delta_d;",
"}",
"}",
"}",
"if (op == 15) {",
"switch (rn) {",
"case 16:\ncase 17:\ngen_mov_F0_vreg(0, rm);",
"break;",
"case 8:\ncase 9:\ngen_mov_F0_vreg(VAR_3, rd);",
"gen_mov_F1_vreg(VAR_3, rm);",
"break;",
"case 10:\ncase 11:\ngen_mov_F0_vreg(VAR_3, rd);",
"gen_vfp_F1_ld0(VAR_3);",
"break;",
"case 20:\ncase 21:\ncase 22:\ncase 23:\ncase 28:\ncase 29:\ncase 30:\ncase 31:\ngen_mov_F0_vreg(VAR_3, rd);",
"break;",
"default:\ngen_mov_F0_vreg(VAR_3, rm);",
"break;",
"}",
"} else {",
"gen_mov_F0_vreg(VAR_3, rn);",
"gen_mov_F1_vreg(VAR_3, rm);",
"}",
"for (;;) {",
"switch (op) {",
"case 0:\ngen_vfp_mul(VAR_3);",
"gen_mov_F1_vreg(VAR_3, rd);",
"gen_vfp_add(VAR_3);",
"break;",
"case 1:\ngen_vfp_mul(VAR_3);",
"gen_vfp_neg(VAR_3);",
"gen_mov_F1_vreg(VAR_3, rd);",
"gen_vfp_add(VAR_3);",
"break;",
"case 2:\ngen_vfp_mul(VAR_3);",
"gen_mov_F1_vreg(VAR_3, rd);",
"gen_vfp_sub(VAR_3);",
"break;",
"case 3:\ngen_vfp_mul(VAR_3);",
"gen_vfp_neg(VAR_3);",
"gen_mov_F1_vreg(VAR_3, rd);",
"gen_vfp_sub(VAR_3);",
"break;",
"case 4:\ngen_vfp_mul(VAR_3);",
"break;",
"case 5:\ngen_vfp_mul(VAR_3);",
"gen_vfp_neg(VAR_3);",
"break;",
"case 6:\ngen_vfp_add(VAR_3);",
"break;",
"case 7:\ngen_vfp_sub(VAR_3);",
"break;",
"case 8:\ngen_vfp_div(VAR_3);",
"break;",
"case 14:\nif (!arm_feature(VAR_0, ARM_FEATURE_VFP3))\nreturn 1;",
"n = (VAR_2 << 12) & 0x80000000;",
"i = ((VAR_2 >> 12) & 0x70) | (VAR_2 & 0xf);",
"if (VAR_3) {",
"if (i & 0x40)\ni |= 0x3f80;",
"else\ni |= 0x4000;",
"n |= i << 16;",
"tcg_gen_movi_i64(cpu_F0d, ((uint64_t)n) << 32);",
"} else {",
"if (i & 0x40)\ni |= 0x780;",
"else\ni |= 0x800;",
"n |= i << 19;",
"tcg_gen_movi_i32(cpu_F0s, n);",
"}",
"break;",
"case 15:\nswitch (rn) {",
"case 0:\nbreak;",
"case 1:\ngen_vfp_abs(VAR_3);",
"break;",
"case 2:\ngen_vfp_neg(VAR_3);",
"break;",
"case 3:\ngen_vfp_sqrt(VAR_3);",
"break;",
"case 8:\ngen_vfp_cmp(VAR_3);",
"break;",
"case 9:\ngen_vfp_cmpe(VAR_3);",
"break;",
"case 10:\ngen_vfp_cmp(VAR_3);",
"break;",
"case 11:\ngen_vfp_F1_ld0(VAR_3);",
"gen_vfp_cmpe(VAR_3);",
"break;",
"case 15:\nif (VAR_3)\ngen_helper_vfp_fcvtsd(cpu_F0s, cpu_F0d, cpu_env);",
"else\ngen_helper_vfp_fcvtds(cpu_F0d, cpu_F0s, cpu_env);",
"break;",
"case 16:\ngen_vfp_uito(VAR_3);",
"break;",
"case 17:\ngen_vfp_sito(VAR_3);",
"break;",
"case 20:\nif (!arm_feature(VAR_0, ARM_FEATURE_VFP3))\nreturn 1;",
"gen_vfp_shto(VAR_3, 16 - rm);",
"break;",
"case 21:\nif (!arm_feature(VAR_0, ARM_FEATURE_VFP3))\nreturn 1;",
"gen_vfp_slto(VAR_3, 32 - rm);",
"break;",
"case 22:\nif (!arm_feature(VAR_0, ARM_FEATURE_VFP3))\nreturn 1;",
"gen_vfp_uhto(VAR_3, 16 - rm);",
"break;",
"case 23:\nif (!arm_feature(VAR_0, ARM_FEATURE_VFP3))\nreturn 1;",
"gen_vfp_ulto(VAR_3, 32 - rm);",
"break;",
"case 24:\ngen_vfp_toui(VAR_3);",
"break;",
"case 25:\ngen_vfp_touiz(VAR_3);",
"break;",
"case 26:\ngen_vfp_tosi(VAR_3);",
"break;",
"case 27:\ngen_vfp_tosiz(VAR_3);",
"break;",
"case 28:\nif (!arm_feature(VAR_0, ARM_FEATURE_VFP3))\nreturn 1;",
"gen_vfp_tosh(VAR_3, 16 - rm);",
"break;",
"case 29:\nif (!arm_feature(VAR_0, ARM_FEATURE_VFP3))\nreturn 1;",
"gen_vfp_tosl(VAR_3, 32 - rm);",
"break;",
"case 30:\nif (!arm_feature(VAR_0, ARM_FEATURE_VFP3))\nreturn 1;",
"gen_vfp_touh(VAR_3, 16 - rm);",
"break;",
"case 31:\nif (!arm_feature(VAR_0, ARM_FEATURE_VFP3))\nreturn 1;",
"gen_vfp_toul(VAR_3, 32 - rm);",
"break;",
"default:\nprintf (\"rn:%d\\n\", rn);",
"return 1;",
"}",
"break;",
"default:\nprintf (\"op:%d\\n\", op);",
"return 1;",
"}",
"if (op == 15 && (rn >= 8 && rn <= 11))\n;",
"else if (op == 15 && rn > 17)\ngen_mov_vreg_F0(0, rd);",
"else if (op == 15 && rn == 15)\ngen_mov_vreg_F0(!VAR_3, rd);",
"else\ngen_mov_vreg_F0(VAR_3, rd);",
"if (VAR_4 == 0)\nbreak;",
"if (op == 15 && delta_m == 0) {",
"while (VAR_4--) {",
"rd = ((rd + delta_d) & (bank_mask - 1))\n| (rd & bank_mask);",
"gen_mov_vreg_F0(VAR_3, rd);",
"}",
"break;",
"}",
"VAR_4--;",
"rd = ((rd + delta_d) & (bank_mask - 1))\n| (rd & bank_mask);",
"if (op == 15) {",
"rm = ((rm + delta_m) & (bank_mask - 1))\n| (rm & bank_mask);",
"gen_mov_F0_vreg(VAR_3, rm);",
"} else {",
"rn = ((rn + delta_d) & (bank_mask - 1))\n| (rn & bank_mask);",
"gen_mov_F0_vreg(VAR_3, rn);",
"if (delta_m) {",
"rm = ((rm + delta_m) & (bank_mask - 1))\n| (rm & bank_mask);",
"gen_mov_F1_vreg(VAR_3, rm);",
"}",
"}",
"}",
"}",
"break;",
"case 0xc:\ncase 0xd:\nif (VAR_3 && (VAR_2 & 0x03e00000) == 0x00400000) {",
"rn = (VAR_2 >> 16) & 0xf;",
"rd = (VAR_2 >> 12) & 0xf;",
"if (VAR_3) {",
"VFP_DREG_M(rm, VAR_2);",
"} else {",
"rm = VFP_SREG_M(VAR_2);",
"}",
"if (VAR_2 & ARM_CP_RW_BIT) {",
"if (VAR_3) {",
"gen_mov_F0_vreg(0, rm * 2);",
"tmp = gen_vfp_mrs();",
"store_reg(VAR_1, rd, tmp);",
"gen_mov_F0_vreg(0, rm * 2 + 1);",
"tmp = gen_vfp_mrs();",
"store_reg(VAR_1, rn, tmp);",
"} else {",
"gen_mov_F0_vreg(0, rm);",
"tmp = gen_vfp_mrs();",
"store_reg(VAR_1, rn, tmp);",
"gen_mov_F0_vreg(0, rm + 1);",
"tmp = gen_vfp_mrs();",
"store_reg(VAR_1, rd, tmp);",
"}",
"} else {",
"if (VAR_3) {",
"tmp = load_reg(VAR_1, rd);",
"gen_vfp_msr(tmp);",
"gen_mov_vreg_F0(0, rm * 2);",
"tmp = load_reg(VAR_1, rn);",
"gen_vfp_msr(tmp);",
"gen_mov_vreg_F0(0, rm * 2 + 1);",
"} else {",
"tmp = load_reg(VAR_1, rn);",
"gen_vfp_msr(tmp);",
"gen_mov_vreg_F0(0, rm);",
"tmp = load_reg(VAR_1, rd);",
"gen_vfp_msr(tmp);",
"gen_mov_vreg_F0(0, rm + 1);",
"}",
"}",
"} else {",
"rn = (VAR_2 >> 16) & 0xf;",
"if (VAR_3)\nVFP_DREG_D(rd, VAR_2);",
"else\nrd = VFP_SREG_D(VAR_2);",
"if (VAR_1->thumb && rn == 15) {",
"addr = new_tmp();",
"tcg_gen_movi_i32(addr, VAR_1->pc & ~2);",
"} else {",
"addr = load_reg(VAR_1, rn);",
"}",
"if ((VAR_2 & 0x01200000) == 0x01000000) {",
"offset = (VAR_2 & 0xff) << 2;",
"if ((VAR_2 & (1 << 23)) == 0)\noffset = -offset;",
"tcg_gen_addi_i32(addr, addr, offset);",
"if (VAR_2 & (1 << 20)) {",
"gen_vfp_ld(VAR_1, VAR_3, addr);",
"gen_mov_vreg_F0(VAR_3, rd);",
"} else {",
"gen_mov_F0_vreg(VAR_3, rd);",
"gen_vfp_st(VAR_1, VAR_3, addr);",
"}",
"dead_tmp(addr);",
"} else {",
"if (VAR_3)\nn = (VAR_2 >> 1) & 0x7f;",
"else\nn = VAR_2 & 0xff;",
"if (VAR_2 & (1 << 24))\ntcg_gen_addi_i32(addr, addr, -((VAR_2 & 0xff) << 2));",
"if (VAR_3)\noffset = 8;",
"else\noffset = 4;",
"for (i = 0; i < n; i++) {",
"if (VAR_2 & ARM_CP_RW_BIT) {",
"gen_vfp_ld(VAR_1, VAR_3, addr);",
"gen_mov_vreg_F0(VAR_3, rd + i);",
"} else {",
"gen_mov_F0_vreg(VAR_3, rd + i);",
"gen_vfp_st(VAR_1, VAR_3, addr);",
"}",
"tcg_gen_addi_i32(addr, addr, offset);",
"}",
"if (VAR_2 & (1 << 21)) {",
"if (VAR_2 & (1 << 24))\noffset = -offset * n;",
"else if (VAR_3 && (VAR_2 & 1))\noffset = 4;",
"else\noffset = 0;",
"if (offset != 0)\ntcg_gen_addi_i32(addr, addr, offset);",
"store_reg(VAR_1, rn, addr);",
"} else {",
"dead_tmp(addr);",
"}",
"}",
"}",
"break;",
"default:\nreturn 1;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
29
],
[
31
],
[
33,
35,
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63,
65
],
[
67,
69,
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105,
107,
109
],
[
111,
113
],
[
115,
117
],
[
119
],
[
121,
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151,
153
],
[
155
],
[
157
],
[
159
],
[
163
],
[
165
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197,
199
],
[
201
],
[
203
],
[
205
],
[
207,
209
],
[
211
],
[
213
],
[
215
],
[
217,
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231,
233
],
[
235
],
[
237
],
[
241
],
[
245
],
[
249
],
[
251,
259,
261,
263
],
[
265
],
[
267
],
[
269,
271,
273
],
[
275
],
[
277
],
[
279,
281,
285,
287,
289
],
[
291
],
[
293
],
[
295,
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313,
315,
317,
319,
321
],
[
323
],
[
325
],
[
327,
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
359
],
[
361
],
[
363
],
[
367
],
[
369,
371,
373,
377
],
[
379,
381
],
[
383
],
[
385
],
[
387
],
[
389,
391,
393
],
[
398
],
[
400
],
[
402
],
[
404,
406,
408
],
[
410
],
[
412,
414
],
[
416
],
[
418
],
[
420
],
[
422
],
[
424
],
[
426
],
[
428
],
[
430
],
[
436
],
[
438
],
[
440
],
[
444
],
[
446
],
[
450
],
[
452
],
[
456
],
[
460
],
[
462
],
[
464
],
[
466
],
[
470
],
[
474
],
[
476
],
[
478
],
[
480
],
[
482
],
[
484
],
[
486
],
[
490
],
[
492
],
[
494
],
[
496
],
[
498
],
[
500
],
[
504
],
[
506,
508
],
[
514
],
[
516
],
[
518
],
[
522
],
[
524,
526
],
[
528,
530
],
[
536
],
[
540
],
[
542
],
[
544,
546
],
[
548,
550
],
[
554
],
[
558
],
[
560
],
[
564
],
[
566
],
[
568
],
[
570
],
[
576
],
[
578
],
[
580,
582,
586
],
[
588
],
[
590,
592,
596
],
[
598
],
[
600
],
[
602,
604,
608
],
[
610
],
[
612
],
[
614,
616,
618,
620,
622,
624,
626,
628,
632
],
[
634
],
[
636,
640
],
[
642
],
[
644
],
[
646
],
[
650
],
[
652
],
[
654
],
[
658
],
[
662
],
[
664,
666
],
[
668
],
[
670
],
[
672
],
[
674,
676
],
[
678
],
[
680
],
[
682
],
[
684
],
[
686,
688
],
[
690
],
[
692
],
[
694
],
[
696,
698
],
[
700
],
[
702
],
[
704
],
[
706
],
[
708,
710
],
[
712
],
[
714,
716
],
[
718
],
[
720
],
[
722,
724
],
[
726
],
[
728,
730
],
[
732
],
[
734,
736
],
[
738
],
[
740,
742,
744
],
[
748
],
[
750
],
[
752
],
[
754,
756
],
[
758,
760
],
[
762
],
[
764
],
[
766
],
[
768,
770
],
[
772,
774
],
[
776
],
[
778
],
[
780
],
[
782
],
[
784,
786
],
[
788,
792
],
[
794,
796
],
[
798
],
[
800,
802
],
[
804
],
[
806,
808
],
[
810
],
[
812,
814
],
[
816
],
[
818,
820
],
[
822
],
[
824,
826
],
[
828
],
[
830,
832
],
[
834
],
[
836
],
[
838,
840,
842
],
[
844,
846
],
[
848
],
[
850,
852
],
[
854
],
[
856,
858
],
[
860
],
[
862,
864,
866
],
[
868
],
[
870
],
[
872,
874,
876
],
[
878
],
[
880
],
[
882,
884,
886
],
[
888
],
[
890
],
[
892,
894,
896
],
[
898
],
[
900
],
[
902,
904
],
[
906
],
[
908,
910
],
[
912
],
[
914,
916
],
[
918
],
[
920,
922
],
[
924
],
[
926,
928,
930
],
[
932
],
[
934
],
[
936,
938,
940
],
[
942
],
[
944
],
[
946,
948,
950
],
[
952
],
[
954
],
[
956,
958,
960
],
[
962
],
[
964
],
[
966,
968
],
[
970
],
[
972
],
[
974
],
[
976,
978
],
[
980
],
[
982
],
[
988,
990
],
[
992,
996
],
[
998,
1002
],
[
1004,
1006
],
[
1012,
1014
],
[
1018
],
[
1022
],
[
1024,
1026
],
[
1028
],
[
1030
],
[
1032
],
[
1034
],
[
1038
],
[
1040,
1042
],
[
1046
],
[
1050,
1052
],
[
1054
],
[
1056
],
[
1060,
1062
],
[
1064
],
[
1066
],
[
1068,
1070
],
[
1072
],
[
1074
],
[
1076
],
[
1078
],
[
1080
],
[
1082
],
[
1084,
1086,
1088
],
[
1092
],
[
1094
],
[
1096
],
[
1098
],
[
1100
],
[
1102
],
[
1104
],
[
1108
],
[
1112
],
[
1114
],
[
1116
],
[
1118
],
[
1120
],
[
1122
],
[
1124
],
[
1126
],
[
1128
],
[
1130
],
[
1132
],
[
1134
],
[
1136
],
[
1138
],
[
1140
],
[
1142
],
[
1146
],
[
1148
],
[
1150
],
[
1152
],
[
1154
],
[
1156
],
[
1158
],
[
1160
],
[
1162
],
[
1164
],
[
1166
],
[
1168
],
[
1170
],
[
1172
],
[
1174
],
[
1176
],
[
1178
],
[
1182
],
[
1184,
1186
],
[
1188,
1190
],
[
1192
],
[
1194
],
[
1196
],
[
1198
],
[
1200
],
[
1202
],
[
1204
],
[
1208
],
[
1210,
1212
],
[
1214
],
[
1216
],
[
1218
],
[
1220
],
[
1222
],
[
1224
],
[
1226
],
[
1228
],
[
1230
],
[
1232
],
[
1236,
1238
],
[
1240,
1242
],
[
1246,
1248
],
[
1252,
1254
],
[
1256,
1258
],
[
1260
],
[
1262
],
[
1266
],
[
1268
],
[
1270
],
[
1274
],
[
1276
],
[
1278
],
[
1280
],
[
1282
],
[
1284
],
[
1288,
1290
],
[
1292,
1294
],
[
1296,
1298
],
[
1302,
1304
],
[
1306
],
[
1308
],
[
1310
],
[
1312
],
[
1314
],
[
1316
],
[
1318
],
[
1320,
1324
],
[
1326
],
[
1328
],
[
1330
]
] |
27,112 | void drive_hot_add(Monitor *mon, const QDict *qdict)
{
int dom, pci_bus;
unsigned slot;
int type, bus;
PCIDevice *dev;
DriveInfo *dinfo = NULL;
const char *pci_addr = qdict_get_str(qdict, "pci_addr");
const char *opts = qdict_get_str(qdict, "opts");
BusState *scsibus;
dinfo = add_init_drive(opts);
if (!dinfo)
goto err;
if (dinfo->devaddr) {
monitor_printf(mon, "Parameter addr not supported\n");
goto err;
}
type = dinfo->type;
bus = drive_get_max_bus (type);
switch (type) {
case IF_SCSI:
if (pci_read_devaddr(mon, pci_addr, &dom, &pci_bus, &slot)) {
goto err;
}
dev = pci_find_device(pci_bus, slot, 0);
if (!dev) {
monitor_printf(mon, "no pci device with address %s\n", pci_addr);
goto err;
}
scsibus = QLIST_FIRST(&dev->qdev.child_bus);
scsi_bus_legacy_add_drive(DO_UPCAST(SCSIBus, qbus, scsibus),
dinfo, dinfo->unit);
monitor_printf(mon, "OK bus %d, unit %d\n",
dinfo->bus,
dinfo->unit);
break;
case IF_NONE:
monitor_printf(mon, "OK\n");
break;
default:
monitor_printf(mon, "Can't hot-add drive to type %d\n", type);
goto err;
}
return;
err:
if (dinfo)
drive_uninit(dinfo);
return;
}
| true | qemu | 30d335d68d93705eb346387c03bb6aca0f52454a | void drive_hot_add(Monitor *mon, const QDict *qdict)
{
int dom, pci_bus;
unsigned slot;
int type, bus;
PCIDevice *dev;
DriveInfo *dinfo = NULL;
const char *pci_addr = qdict_get_str(qdict, "pci_addr");
const char *opts = qdict_get_str(qdict, "opts");
BusState *scsibus;
dinfo = add_init_drive(opts);
if (!dinfo)
goto err;
if (dinfo->devaddr) {
monitor_printf(mon, "Parameter addr not supported\n");
goto err;
}
type = dinfo->type;
bus = drive_get_max_bus (type);
switch (type) {
case IF_SCSI:
if (pci_read_devaddr(mon, pci_addr, &dom, &pci_bus, &slot)) {
goto err;
}
dev = pci_find_device(pci_bus, slot, 0);
if (!dev) {
monitor_printf(mon, "no pci device with address %s\n", pci_addr);
goto err;
}
scsibus = QLIST_FIRST(&dev->qdev.child_bus);
scsi_bus_legacy_add_drive(DO_UPCAST(SCSIBus, qbus, scsibus),
dinfo, dinfo->unit);
monitor_printf(mon, "OK bus %d, unit %d\n",
dinfo->bus,
dinfo->unit);
break;
case IF_NONE:
monitor_printf(mon, "OK\n");
break;
default:
monitor_printf(mon, "Can't hot-add drive to type %d\n", type);
goto err;
}
return;
err:
if (dinfo)
drive_uninit(dinfo);
return;
}
| {
"code": [
" BusState *scsibus;",
" scsibus = QLIST_FIRST(&dev->qdev.child_bus);",
" scsi_bus_legacy_add_drive(DO_UPCAST(SCSIBus, qbus, scsibus),",
" dinfo, dinfo->unit);",
" monitor_printf(mon, \"OK bus %d, unit %d\\n\",",
" dinfo->bus,",
" dinfo->unit);"
],
"line_no": [
19,
63,
65,
67,
69,
71,
73
]
} | void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)
{
int VAR_2, VAR_3;
unsigned VAR_4;
int VAR_5, VAR_6;
PCIDevice *dev;
DriveInfo *dinfo = NULL;
const char *VAR_7 = qdict_get_str(VAR_1, "VAR_7");
const char *VAR_8 = qdict_get_str(VAR_1, "VAR_8");
BusState *scsibus;
dinfo = add_init_drive(VAR_8);
if (!dinfo)
goto err;
if (dinfo->devaddr) {
monitor_printf(VAR_0, "Parameter addr not supported\n");
goto err;
}
VAR_5 = dinfo->VAR_5;
VAR_6 = drive_get_max_bus (VAR_5);
switch (VAR_5) {
case IF_SCSI:
if (pci_read_devaddr(VAR_0, VAR_7, &VAR_2, &VAR_3, &VAR_4)) {
goto err;
}
dev = pci_find_device(VAR_3, VAR_4, 0);
if (!dev) {
monitor_printf(VAR_0, "no pci device with address %s\n", VAR_7);
goto err;
}
scsibus = QLIST_FIRST(&dev->qdev.child_bus);
scsi_bus_legacy_add_drive(DO_UPCAST(SCSIBus, qbus, scsibus),
dinfo, dinfo->unit);
monitor_printf(VAR_0, "OK VAR_6 %d, unit %d\n",
dinfo->VAR_6,
dinfo->unit);
break;
case IF_NONE:
monitor_printf(VAR_0, "OK\n");
break;
default:
monitor_printf(VAR_0, "Can't hot-add drive to VAR_5 %d\n", VAR_5);
goto err;
}
return;
err:
if (dinfo)
drive_uninit(dinfo);
return;
}
| [
"void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)\n{",
"int VAR_2, VAR_3;",
"unsigned VAR_4;",
"int VAR_5, VAR_6;",
"PCIDevice *dev;",
"DriveInfo *dinfo = NULL;",
"const char *VAR_7 = qdict_get_str(VAR_1, \"VAR_7\");",
"const char *VAR_8 = qdict_get_str(VAR_1, \"VAR_8\");",
"BusState *scsibus;",
"dinfo = add_init_drive(VAR_8);",
"if (!dinfo)\ngoto err;",
"if (dinfo->devaddr) {",
"monitor_printf(VAR_0, \"Parameter addr not supported\\n\");",
"goto err;",
"}",
"VAR_5 = dinfo->VAR_5;",
"VAR_6 = drive_get_max_bus (VAR_5);",
"switch (VAR_5) {",
"case IF_SCSI:\nif (pci_read_devaddr(VAR_0, VAR_7, &VAR_2, &VAR_3, &VAR_4)) {",
"goto err;",
"}",
"dev = pci_find_device(VAR_3, VAR_4, 0);",
"if (!dev) {",
"monitor_printf(VAR_0, \"no pci device with address %s\\n\", VAR_7);",
"goto err;",
"}",
"scsibus = QLIST_FIRST(&dev->qdev.child_bus);",
"scsi_bus_legacy_add_drive(DO_UPCAST(SCSIBus, qbus, scsibus),\ndinfo, dinfo->unit);",
"monitor_printf(VAR_0, \"OK VAR_6 %d, unit %d\\n\",\ndinfo->VAR_6,\ndinfo->unit);",
"break;",
"case IF_NONE:\nmonitor_printf(VAR_0, \"OK\\n\");",
"break;",
"default:\nmonitor_printf(VAR_0, \"Can't hot-add drive to VAR_5 %d\\n\", VAR_5);",
"goto err;",
"}",
"return;",
"err:\nif (dinfo)\ndrive_uninit(dinfo);",
"return;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
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
],
[
95,
97,
99
],
[
101
],
[
103
]
] |
27,113 | static inline int msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
int n, int coded)
{
int level, i, last, run, run_diff;
int dc_pred_dir;
RLTable *rl;
RL_VLC_ELEM *rl_vlc;
const UINT8 *scan_table;
int qmul, qadd;
if (s->mb_intra) {
qmul=1;
qadd=0;
/* DC coef */
set_stat(ST_DC);
level = msmpeg4_decode_dc(s, n, &dc_pred_dir);
#ifdef PRINT_MB
{
static int c;
if(n==0) c=0;
if(n==4) printf("%X", c);
c+= c +dc_pred_dir;
}
#endif
if (level < 0){
fprintf(stderr, "dc overflow- block: %d qscale: %d//\n", n, s->qscale);
if(s->inter_intra_pred) level=0;
else return -1;
}
if (n < 4) {
rl = &rl_table[s->rl_table_index];
if(level > 256*s->y_dc_scale){
fprintf(stderr, "dc overflow+ L qscale: %d//\n", s->qscale);
if(!s->inter_intra_pred) return -1;
}
} else {
rl = &rl_table[3 + s->rl_chroma_table_index];
if(level > 256*s->c_dc_scale){
fprintf(stderr, "dc overflow+ C qscale: %d//\n", s->qscale);
if(!s->inter_intra_pred) return -1;
}
}
block[0] = level;
run_diff = 0;
i = 0;
if (!coded) {
goto not_coded;
}
if (s->ac_pred) {
if (dc_pred_dir == 0)
scan_table = s->intra_v_scantable; /* left */
else
scan_table = s->intra_h_scantable; /* top */
} else {
scan_table = s->intra_scantable;
}
set_stat(ST_INTRA_AC);
rl_vlc= rl->rl_vlc[0];
} else {
qmul = s->qscale << 1;
qadd = (s->qscale - 1) | 1;
i = -1;
rl = &rl_table[3 + s->rl_table_index];
if(s->msmpeg4_version==2)
run_diff = 0;
else
run_diff = 1;
if (!coded) {
s->block_last_index[n] = i;
return 0;
}
scan_table = s->inter_scantable;
set_stat(ST_INTER_AC);
rl_vlc= rl->rl_vlc[s->qscale];
}
{
OPEN_READER(re, &s->gb);
for(;;) {
UPDATE_CACHE(re, &s->gb);
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2);
if (level==0) {
int cache;
cache= GET_CACHE(re, &s->gb);
/* escape */
if (s->msmpeg4_version==1 || (cache&0x80000000)==0) {
if (s->msmpeg4_version==1 || (cache&0x40000000)==0) {
/* third escape */
if(s->msmpeg4_version!=1) LAST_SKIP_BITS(re, &s->gb, 2);
UPDATE_CACHE(re, &s->gb);
if(s->msmpeg4_version<=3){
last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
run= SHOW_UBITS(re, &s->gb, 6); SKIP_CACHE(re, &s->gb, 6);
level= SHOW_SBITS(re, &s->gb, 8); LAST_SKIP_CACHE(re, &s->gb, 8);
SKIP_COUNTER(re, &s->gb, 1+6+8);
}else{
int sign;
last= SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1);
if(!s->esc3_level_length){
int ll;
//printf("ESC-3 %X at %d %d\n", show_bits(&s->gb, 24), s->mb_x, s->mb_y);
if(s->qscale<8){
ll= SHOW_UBITS(re, &s->gb, 3); SKIP_BITS(re, &s->gb, 3);
if(ll==0){
if(SHOW_UBITS(re, &s->gb, 1)) printf("cool a new vlc code ,contact the ffmpeg developers and upload the file\n");
SKIP_BITS(re, &s->gb, 1);
ll=8;
}
}else{
ll=2;
while(ll<8 && SHOW_UBITS(re, &s->gb, 1)==0){
ll++;
SKIP_BITS(re, &s->gb, 1);
}
if(ll<8) SKIP_BITS(re, &s->gb, 1);
}
s->esc3_level_length= ll;
s->esc3_run_length= SHOW_UBITS(re, &s->gb, 2) + 3; SKIP_BITS(re, &s->gb, 2);
//printf("level length:%d, run length: %d\n", ll, s->esc3_run_length);
UPDATE_CACHE(re, &s->gb);
}
run= SHOW_UBITS(re, &s->gb, s->esc3_run_length);
SKIP_BITS(re, &s->gb, s->esc3_run_length);
sign= SHOW_UBITS(re, &s->gb, 1);
SKIP_BITS(re, &s->gb, 1);
level= SHOW_UBITS(re, &s->gb, s->esc3_level_length);
SKIP_BITS(re, &s->gb, s->esc3_level_length);
if(sign) level= -level;
}
//printf("level: %d, run: %d at %d %d\n", level, run, s->mb_x, s->mb_y);
#if 0 // waste of time / this will detect very few errors
{
const int abs_level= ABS(level);
const int run1= run - rl->max_run[last][abs_level] - run_diff;
if(abs_level<=MAX_LEVEL && run<=MAX_RUN){
if(abs_level <= rl->max_level[last][run]){
fprintf(stderr, "illegal 3. esc, vlc encoding possible\n");
return DECODING_AC_LOST;
}
if(abs_level <= rl->max_level[last][run]*2){
fprintf(stderr, "illegal 3. esc, esc 1 encoding possible\n");
return DECODING_AC_LOST;
}
if(run1>=0 && abs_level <= rl->max_level[last][run1]){
fprintf(stderr, "illegal 3. esc, esc 2 encoding possible\n");
return DECODING_AC_LOST;
}
}
}
#endif
//level = level * qmul + (level>0) * qadd - (level<=0) * qadd ;
if (level>0) level= level * qmul + qadd;
else level= level * qmul - qadd;
#if 0 // waste of time too :(
if(level>2048 || level<-2048){
fprintf(stderr, "|level| overflow in 3. esc\n");
return DECODING_AC_LOST;
}
#endif
i+= run + 1;
if(last) i+=192;
#ifdef ERROR_DETAILS
if(run==66)
fprintf(stderr, "illegal vlc code in ESC3 level=%d\n", level);
else if((i>62 && i<192) || i>192+63)
fprintf(stderr, "run overflow in ESC3 i=%d run=%d level=%d\n", i, run, level);
#endif
} else {
/* second escape */
#if MIN_CACHE_BITS < 23
LAST_SKIP_BITS(re, &s->gb, 2);
UPDATE_CACHE(re, &s->gb);
#else
SKIP_BITS(re, &s->gb, 2);
#endif
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2);
i+= run + rl->max_run[run>>7][level/qmul] + run_diff; //FIXME opt indexing
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
#ifdef ERROR_DETAILS
if(run==66)
fprintf(stderr, "illegal vlc code in ESC2 level=%d\n", level);
else if((i>62 && i<192) || i>192+63)
fprintf(stderr, "run overflow in ESC2 i=%d run=%d level=%d\n", i, run, level);
#endif
}
} else {
/* first escape */
#if MIN_CACHE_BITS < 22
LAST_SKIP_BITS(re, &s->gb, 1);
UPDATE_CACHE(re, &s->gb);
#else
SKIP_BITS(re, &s->gb, 1);
#endif
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2);
i+= run;
level = level + rl->max_level[run>>7][(run-1)&63] * qmul;//FIXME opt indexing
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
#ifdef ERROR_DETAILS
if(run==66)
fprintf(stderr, "illegal vlc code in ESC1 level=%d\n", level);
else if((i>62 && i<192) || i>192+63)
fprintf(stderr, "run overflow in ESC1 i=%d run=%d level=%d\n", i, run, level);
#endif
}
} else {
i+= run;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
#ifdef ERROR_DETAILS
if(run==66)
fprintf(stderr, "illegal vlc code level=%d\n", level);
else if((i>62 && i<192) || i>192+63)
fprintf(stderr, "run overflow i=%d run=%d level=%d\n", i, run, level);
#endif
}
if (i > 62){
i-= 192;
if(i&(~63)){
if(s->error_resilience<0){
fprintf(stderr, "ignoring overflow at %d %d\n", s->mb_x, s->mb_y);
break;
}else{
fprintf(stderr, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
}
block[scan_table[i]] = level;
break;
}
block[scan_table[i]] = level;
}
CLOSE_READER(re, &s->gb);
}
not_coded:
if (s->mb_intra) {
mpeg4_pred_ac(s, block, n, dc_pred_dir);
if (s->ac_pred) {
i = 63; /* XXX: not optimal */
}
}
if(s->msmpeg4_version==4 && i>0) i=63; //FIXME/XXX optimize
s->block_last_index[n] = i;
return 0;
}
| true | FFmpeg | 55078332495d879ad4aeb23ae2bada75130431c6 | static inline int msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
int n, int coded)
{
int level, i, last, run, run_diff;
int dc_pred_dir;
RLTable *rl;
RL_VLC_ELEM *rl_vlc;
const UINT8 *scan_table;
int qmul, qadd;
if (s->mb_intra) {
qmul=1;
qadd=0;
set_stat(ST_DC);
level = msmpeg4_decode_dc(s, n, &dc_pred_dir);
#ifdef PRINT_MB
{
static int c;
if(n==0) c=0;
if(n==4) printf("%X", c);
c+= c +dc_pred_dir;
}
#endif
if (level < 0){
fprintf(stderr, "dc overflow- block: %d qscale: %d
if(s->inter_intra_pred) level=0;
else return -1;
}
if (n < 4) {
rl = &rl_table[s->rl_table_index];
if(level > 256*s->y_dc_scale){
fprintf(stderr, "dc overflow+ L qscale: %d
if(!s->inter_intra_pred) return -1;
}
} else {
rl = &rl_table[3 + s->rl_chroma_table_index];
if(level > 256*s->c_dc_scale){
fprintf(stderr, "dc overflow+ C qscale: %d
if(!s->inter_intra_pred) return -1;
}
}
block[0] = level;
run_diff = 0;
i = 0;
if (!coded) {
goto not_coded;
}
if (s->ac_pred) {
if (dc_pred_dir == 0)
scan_table = s->intra_v_scantable;
else
scan_table = s->intra_h_scantable;
} else {
scan_table = s->intra_scantable;
}
set_stat(ST_INTRA_AC);
rl_vlc= rl->rl_vlc[0];
} else {
qmul = s->qscale << 1;
qadd = (s->qscale - 1) | 1;
i = -1;
rl = &rl_table[3 + s->rl_table_index];
if(s->msmpeg4_version==2)
run_diff = 0;
else
run_diff = 1;
if (!coded) {
s->block_last_index[n] = i;
return 0;
}
scan_table = s->inter_scantable;
set_stat(ST_INTER_AC);
rl_vlc= rl->rl_vlc[s->qscale];
}
{
OPEN_READER(re, &s->gb);
for(;;) {
UPDATE_CACHE(re, &s->gb);
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2);
if (level==0) {
int cache;
cache= GET_CACHE(re, &s->gb);
if (s->msmpeg4_version==1 || (cache&0x80000000)==0) {
if (s->msmpeg4_version==1 || (cache&0x40000000)==0) {
if(s->msmpeg4_version!=1) LAST_SKIP_BITS(re, &s->gb, 2);
UPDATE_CACHE(re, &s->gb);
if(s->msmpeg4_version<=3){
last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
run= SHOW_UBITS(re, &s->gb, 6); SKIP_CACHE(re, &s->gb, 6);
level= SHOW_SBITS(re, &s->gb, 8); LAST_SKIP_CACHE(re, &s->gb, 8);
SKIP_COUNTER(re, &s->gb, 1+6+8);
}else{
int sign;
last= SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1);
if(!s->esc3_level_length){
int ll;
if(s->qscale<8){
ll= SHOW_UBITS(re, &s->gb, 3); SKIP_BITS(re, &s->gb, 3);
if(ll==0){
if(SHOW_UBITS(re, &s->gb, 1)) printf("cool a new vlc code ,contact the ffmpeg developers and upload the file\n");
SKIP_BITS(re, &s->gb, 1);
ll=8;
}
}else{
ll=2;
while(ll<8 && SHOW_UBITS(re, &s->gb, 1)==0){
ll++;
SKIP_BITS(re, &s->gb, 1);
}
if(ll<8) SKIP_BITS(re, &s->gb, 1);
}
s->esc3_level_length= ll;
s->esc3_run_length= SHOW_UBITS(re, &s->gb, 2) + 3; SKIP_BITS(re, &s->gb, 2);
UPDATE_CACHE(re, &s->gb);
}
run= SHOW_UBITS(re, &s->gb, s->esc3_run_length);
SKIP_BITS(re, &s->gb, s->esc3_run_length);
sign= SHOW_UBITS(re, &s->gb, 1);
SKIP_BITS(re, &s->gb, 1);
level= SHOW_UBITS(re, &s->gb, s->esc3_level_length);
SKIP_BITS(re, &s->gb, s->esc3_level_length);
if(sign) level= -level;
}
#if 0
{
const int abs_level= ABS(level);
const int run1= run - rl->max_run[last][abs_level] - run_diff;
if(abs_level<=MAX_LEVEL && run<=MAX_RUN){
if(abs_level <= rl->max_level[last][run]){
fprintf(stderr, "illegal 3. esc, vlc encoding possible\n");
return DECODING_AC_LOST;
}
if(abs_level <= rl->max_level[last][run]*2){
fprintf(stderr, "illegal 3. esc, esc 1 encoding possible\n");
return DECODING_AC_LOST;
}
if(run1>=0 && abs_level <= rl->max_level[last][run1]){
fprintf(stderr, "illegal 3. esc, esc 2 encoding possible\n");
return DECODING_AC_LOST;
}
}
}
#endif
if (level>0) level= level * qmul + qadd;
else level= level * qmul - qadd;
#if 0
if(level>2048 || level<-2048){
fprintf(stderr, "|level| overflow in 3. esc\n");
return DECODING_AC_LOST;
}
#endif
i+= run + 1;
if(last) i+=192;
#ifdef ERROR_DETAILS
if(run==66)
fprintf(stderr, "illegal vlc code in ESC3 level=%d\n", level);
else if((i>62 && i<192) || i>192+63)
fprintf(stderr, "run overflow in ESC3 i=%d run=%d level=%d\n", i, run, level);
#endif
} else {
#if MIN_CACHE_BITS < 23
LAST_SKIP_BITS(re, &s->gb, 2);
UPDATE_CACHE(re, &s->gb);
#else
SKIP_BITS(re, &s->gb, 2);
#endif
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2);
i+= run + rl->max_run[run>>7][level/qmul] + run_diff;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
#ifdef ERROR_DETAILS
if(run==66)
fprintf(stderr, "illegal vlc code in ESC2 level=%d\n", level);
else if((i>62 && i<192) || i>192+63)
fprintf(stderr, "run overflow in ESC2 i=%d run=%d level=%d\n", i, run, level);
#endif
}
} else {
#if MIN_CACHE_BITS < 22
LAST_SKIP_BITS(re, &s->gb, 1);
UPDATE_CACHE(re, &s->gb);
#else
SKIP_BITS(re, &s->gb, 1);
#endif
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2);
i+= run;
level = level + rl->max_level[run>>7][(run-1)&63] * qmul;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
#ifdef ERROR_DETAILS
if(run==66)
fprintf(stderr, "illegal vlc code in ESC1 level=%d\n", level);
else if((i>62 && i<192) || i>192+63)
fprintf(stderr, "run overflow in ESC1 i=%d run=%d level=%d\n", i, run, level);
#endif
}
} else {
i+= run;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
#ifdef ERROR_DETAILS
if(run==66)
fprintf(stderr, "illegal vlc code level=%d\n", level);
else if((i>62 && i<192) || i>192+63)
fprintf(stderr, "run overflow i=%d run=%d level=%d\n", i, run, level);
#endif
}
if (i > 62){
i-= 192;
if(i&(~63)){
if(s->error_resilience<0){
fprintf(stderr, "ignoring overflow at %d %d\n", s->mb_x, s->mb_y);
break;
}else{
fprintf(stderr, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
}
block[scan_table[i]] = level;
break;
}
block[scan_table[i]] = level;
}
CLOSE_READER(re, &s->gb);
}
not_coded:
if (s->mb_intra) {
mpeg4_pred_ac(s, block, n, dc_pred_dir);
if (s->ac_pred) {
i = 63;
}
}
if(s->msmpeg4_version==4 && i>0) i=63;
s->block_last_index[n] = i;
return 0;
}
| {
"code": [
" if(s->error_resilience<0){"
],
"line_no": [
453
]
} | static inline int FUNC_0(MpegEncContext * VAR_0, DCTELEM * VAR_1,
int VAR_2, int VAR_3)
{
int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;
int VAR_9;
RLTable *rl;
RL_VLC_ELEM *rl_vlc;
const UINT8 *VAR_10;
int VAR_11, VAR_12;
if (VAR_0->mb_intra) {
VAR_11=1;
VAR_12=0;
set_stat(ST_DC);
VAR_4 = msmpeg4_decode_dc(VAR_0, VAR_2, &VAR_9);
#ifdef PRINT_MB
{
static int c;
if(VAR_2==0) c=0;
if(VAR_2==4) printf("%X", c);
c+= c +VAR_9;
}
#endif
if (VAR_4 < 0){
fprintf(stderr, "dc overflow- VAR_1: %d qscale: %d
if(VAR_0->inter_intra_pred) VAR_4=0;
else return -1;
}
if (VAR_2 < 4) {
rl = &rl_table[VAR_0->rl_table_index];
if(VAR_4 > 256*VAR_0->y_dc_scale){
fprintf(stderr, "dc overflow+ L qscale: %d
if(!VAR_0->inter_intra_pred) return -1;
}
} else {
rl = &rl_table[3 + VAR_0->rl_chroma_table_index];
if(VAR_4 > 256*VAR_0->c_dc_scale){
fprintf(stderr, "dc overflow+ C qscale: %d
if(!VAR_0->inter_intra_pred) return -1;
}
}
VAR_1[0] = VAR_4;
VAR_8 = 0;
VAR_5 = 0;
if (!VAR_3) {
goto not_coded;
}
if (VAR_0->ac_pred) {
if (VAR_9 == 0)
VAR_10 = VAR_0->intra_v_scantable;
else
VAR_10 = VAR_0->intra_h_scantable;
} else {
VAR_10 = VAR_0->intra_scantable;
}
set_stat(ST_INTRA_AC);
rl_vlc= rl->rl_vlc[0];
} else {
VAR_11 = VAR_0->qscale << 1;
VAR_12 = (VAR_0->qscale - 1) | 1;
VAR_5 = -1;
rl = &rl_table[3 + VAR_0->rl_table_index];
if(VAR_0->msmpeg4_version==2)
VAR_8 = 0;
else
VAR_8 = 1;
if (!VAR_3) {
VAR_0->block_last_index[VAR_2] = VAR_5;
return 0;
}
VAR_10 = VAR_0->inter_scantable;
set_stat(ST_INTER_AC);
rl_vlc= rl->rl_vlc[VAR_0->qscale];
}
{
OPEN_READER(re, &VAR_0->gb);
for(;;) {
UPDATE_CACHE(re, &VAR_0->gb);
GET_RL_VLC(VAR_4, VAR_7, re, &VAR_0->gb, rl_vlc, TEX_VLC_BITS, 2);
if (VAR_4==0) {
int VAR_13;
VAR_13= GET_CACHE(re, &VAR_0->gb);
if (VAR_0->msmpeg4_version==1 || (VAR_13&0x80000000)==0) {
if (VAR_0->msmpeg4_version==1 || (VAR_13&0x40000000)==0) {
if(VAR_0->msmpeg4_version!=1) LAST_SKIP_BITS(re, &VAR_0->gb, 2);
UPDATE_CACHE(re, &VAR_0->gb);
if(VAR_0->msmpeg4_version<=3){
VAR_6= SHOW_UBITS(re, &VAR_0->gb, 1); SKIP_CACHE(re, &VAR_0->gb, 1);
VAR_7= SHOW_UBITS(re, &VAR_0->gb, 6); SKIP_CACHE(re, &VAR_0->gb, 6);
VAR_4= SHOW_SBITS(re, &VAR_0->gb, 8); LAST_SKIP_CACHE(re, &VAR_0->gb, 8);
SKIP_COUNTER(re, &VAR_0->gb, 1+6+8);
}else{
int VAR_14;
VAR_6= SHOW_UBITS(re, &VAR_0->gb, 1); SKIP_BITS(re, &VAR_0->gb, 1);
if(!VAR_0->esc3_level_length){
int VAR_15;
if(VAR_0->qscale<8){
VAR_15= SHOW_UBITS(re, &VAR_0->gb, 3); SKIP_BITS(re, &VAR_0->gb, 3);
if(VAR_15==0){
if(SHOW_UBITS(re, &VAR_0->gb, 1)) printf("cool a new vlc code ,contact the ffmpeg developers and upload the file\VAR_2");
SKIP_BITS(re, &VAR_0->gb, 1);
VAR_15=8;
}
}else{
VAR_15=2;
while(VAR_15<8 && SHOW_UBITS(re, &VAR_0->gb, 1)==0){
VAR_15++;
SKIP_BITS(re, &VAR_0->gb, 1);
}
if(VAR_15<8) SKIP_BITS(re, &VAR_0->gb, 1);
}
VAR_0->esc3_level_length= VAR_15;
VAR_0->esc3_run_length= SHOW_UBITS(re, &VAR_0->gb, 2) + 3; SKIP_BITS(re, &VAR_0->gb, 2);
UPDATE_CACHE(re, &VAR_0->gb);
}
VAR_7= SHOW_UBITS(re, &VAR_0->gb, VAR_0->esc3_run_length);
SKIP_BITS(re, &VAR_0->gb, VAR_0->esc3_run_length);
VAR_14= SHOW_UBITS(re, &VAR_0->gb, 1);
SKIP_BITS(re, &VAR_0->gb, 1);
VAR_4= SHOW_UBITS(re, &VAR_0->gb, VAR_0->esc3_level_length);
SKIP_BITS(re, &VAR_0->gb, VAR_0->esc3_level_length);
if(VAR_14) VAR_4= -VAR_4;
}
#if 0
{
const int abs_level= ABS(VAR_4);
const int run1= VAR_7 - rl->max_run[VAR_6][abs_level] - VAR_8;
if(abs_level<=MAX_LEVEL && VAR_7<=MAX_RUN){
if(abs_level <= rl->max_level[VAR_6][VAR_7]){
fprintf(stderr, "illegal 3. esc, vlc encoding possible\VAR_2");
return DECODING_AC_LOST;
}
if(abs_level <= rl->max_level[VAR_6][VAR_7]*2){
fprintf(stderr, "illegal 3. esc, esc 1 encoding possible\VAR_2");
return DECODING_AC_LOST;
}
if(run1>=0 && abs_level <= rl->max_level[VAR_6][run1]){
fprintf(stderr, "illegal 3. esc, esc 2 encoding possible\VAR_2");
return DECODING_AC_LOST;
}
}
}
#endif
if (VAR_4>0) VAR_4= VAR_4 * VAR_11 + VAR_12;
else VAR_4= VAR_4 * VAR_11 - VAR_12;
#if 0
if(VAR_4>2048 || VAR_4<-2048){
fprintf(stderr, "|VAR_4| overflow in 3. esc\VAR_2");
return DECODING_AC_LOST;
}
#endif
VAR_5+= VAR_7 + 1;
if(VAR_6) VAR_5+=192;
#ifdef ERROR_DETAILS
if(VAR_7==66)
fprintf(stderr, "illegal vlc code in ESC3 VAR_4=%d\VAR_2", VAR_4);
else if((VAR_5>62 && VAR_5<192) || VAR_5>192+63)
fprintf(stderr, "VAR_7 overflow in ESC3 VAR_5=%d VAR_7=%d VAR_4=%d\VAR_2", VAR_5, VAR_7, VAR_4);
#endif
} else {
#if MIN_CACHE_BITS < 23
LAST_SKIP_BITS(re, &VAR_0->gb, 2);
UPDATE_CACHE(re, &VAR_0->gb);
#else
SKIP_BITS(re, &VAR_0->gb, 2);
#endif
GET_RL_VLC(VAR_4, VAR_7, re, &VAR_0->gb, rl_vlc, TEX_VLC_BITS, 2);
VAR_5+= VAR_7 + rl->max_run[VAR_7>>7][VAR_4/VAR_11] + VAR_8;
VAR_4 = (VAR_4 ^ SHOW_SBITS(re, &VAR_0->gb, 1)) - SHOW_SBITS(re, &VAR_0->gb, 1);
LAST_SKIP_BITS(re, &VAR_0->gb, 1);
#ifdef ERROR_DETAILS
if(VAR_7==66)
fprintf(stderr, "illegal vlc code in ESC2 VAR_4=%d\VAR_2", VAR_4);
else if((VAR_5>62 && VAR_5<192) || VAR_5>192+63)
fprintf(stderr, "VAR_7 overflow in ESC2 VAR_5=%d VAR_7=%d VAR_4=%d\VAR_2", VAR_5, VAR_7, VAR_4);
#endif
}
} else {
#if MIN_CACHE_BITS < 22
LAST_SKIP_BITS(re, &VAR_0->gb, 1);
UPDATE_CACHE(re, &VAR_0->gb);
#else
SKIP_BITS(re, &VAR_0->gb, 1);
#endif
GET_RL_VLC(VAR_4, VAR_7, re, &VAR_0->gb, rl_vlc, TEX_VLC_BITS, 2);
VAR_5+= VAR_7;
VAR_4 = VAR_4 + rl->max_level[VAR_7>>7][(VAR_7-1)&63] * VAR_11;
VAR_4 = (VAR_4 ^ SHOW_SBITS(re, &VAR_0->gb, 1)) - SHOW_SBITS(re, &VAR_0->gb, 1);
LAST_SKIP_BITS(re, &VAR_0->gb, 1);
#ifdef ERROR_DETAILS
if(VAR_7==66)
fprintf(stderr, "illegal vlc code in ESC1 VAR_4=%d\VAR_2", VAR_4);
else if((VAR_5>62 && VAR_5<192) || VAR_5>192+63)
fprintf(stderr, "VAR_7 overflow in ESC1 VAR_5=%d VAR_7=%d VAR_4=%d\VAR_2", VAR_5, VAR_7, VAR_4);
#endif
}
} else {
VAR_5+= VAR_7;
VAR_4 = (VAR_4 ^ SHOW_SBITS(re, &VAR_0->gb, 1)) - SHOW_SBITS(re, &VAR_0->gb, 1);
LAST_SKIP_BITS(re, &VAR_0->gb, 1);
#ifdef ERROR_DETAILS
if(VAR_7==66)
fprintf(stderr, "illegal vlc code VAR_4=%d\VAR_2", VAR_4);
else if((VAR_5>62 && VAR_5<192) || VAR_5>192+63)
fprintf(stderr, "VAR_7 overflow VAR_5=%d VAR_7=%d VAR_4=%d\VAR_2", VAR_5, VAR_7, VAR_4);
#endif
}
if (VAR_5 > 62){
VAR_5-= 192;
if(VAR_5&(~63)){
if(VAR_0->error_resilience<0){
fprintf(stderr, "ignoring overflow at %d %d\VAR_2", VAR_0->mb_x, VAR_0->mb_y);
break;
}else{
fprintf(stderr, "ac-tex damaged at %d %d\VAR_2", VAR_0->mb_x, VAR_0->mb_y);
return -1;
}
}
VAR_1[VAR_10[VAR_5]] = VAR_4;
break;
}
VAR_1[VAR_10[VAR_5]] = VAR_4;
}
CLOSE_READER(re, &VAR_0->gb);
}
not_coded:
if (VAR_0->mb_intra) {
mpeg4_pred_ac(VAR_0, VAR_1, VAR_2, VAR_9);
if (VAR_0->ac_pred) {
VAR_5 = 63;
}
}
if(VAR_0->msmpeg4_version==4 && VAR_5>0) VAR_5=63;
VAR_0->block_last_index[VAR_2] = VAR_5;
return 0;
}
| [
"static inline int FUNC_0(MpegEncContext * VAR_0, DCTELEM * VAR_1,\nint VAR_2, int VAR_3)\n{",
"int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;",
"int VAR_9;",
"RLTable *rl;",
"RL_VLC_ELEM *rl_vlc;",
"const UINT8 *VAR_10;",
"int VAR_11, VAR_12;",
"if (VAR_0->mb_intra) {",
"VAR_11=1;",
"VAR_12=0;",
"set_stat(ST_DC);",
"VAR_4 = msmpeg4_decode_dc(VAR_0, VAR_2, &VAR_9);",
"#ifdef PRINT_MB\n{",
"static int c;",
"if(VAR_2==0) c=0;",
"if(VAR_2==4) printf(\"%X\", c);",
"c+= c +VAR_9;",
"}",
"#endif\nif (VAR_4 < 0){",
"fprintf(stderr, \"dc overflow- VAR_1: %d qscale: %d\nif(VAR_0->inter_intra_pred) VAR_4=0;",
"else return -1;",
"}",
"if (VAR_2 < 4) {",
"rl = &rl_table[VAR_0->rl_table_index];",
"if(VAR_4 > 256*VAR_0->y_dc_scale){",
"fprintf(stderr, \"dc overflow+ L qscale: %d\nif(!VAR_0->inter_intra_pred) return -1;",
"}",
"} else {",
"rl = &rl_table[3 + VAR_0->rl_chroma_table_index];",
"if(VAR_4 > 256*VAR_0->c_dc_scale){",
"fprintf(stderr, \"dc overflow+ C qscale: %d\nif(!VAR_0->inter_intra_pred) return -1;",
"}",
"}",
"VAR_1[0] = VAR_4;",
"VAR_8 = 0;",
"VAR_5 = 0;",
"if (!VAR_3) {",
"goto not_coded;",
"}",
"if (VAR_0->ac_pred) {",
"if (VAR_9 == 0)\nVAR_10 = VAR_0->intra_v_scantable;",
"else\nVAR_10 = VAR_0->intra_h_scantable;",
"} else {",
"VAR_10 = VAR_0->intra_scantable;",
"}",
"set_stat(ST_INTRA_AC);",
"rl_vlc= rl->rl_vlc[0];",
"} else {",
"VAR_11 = VAR_0->qscale << 1;",
"VAR_12 = (VAR_0->qscale - 1) | 1;",
"VAR_5 = -1;",
"rl = &rl_table[3 + VAR_0->rl_table_index];",
"if(VAR_0->msmpeg4_version==2)\nVAR_8 = 0;",
"else\nVAR_8 = 1;",
"if (!VAR_3) {",
"VAR_0->block_last_index[VAR_2] = VAR_5;",
"return 0;",
"}",
"VAR_10 = VAR_0->inter_scantable;",
"set_stat(ST_INTER_AC);",
"rl_vlc= rl->rl_vlc[VAR_0->qscale];",
"}",
"{",
"OPEN_READER(re, &VAR_0->gb);",
"for(;;) {",
"UPDATE_CACHE(re, &VAR_0->gb);",
"GET_RL_VLC(VAR_4, VAR_7, re, &VAR_0->gb, rl_vlc, TEX_VLC_BITS, 2);",
"if (VAR_4==0) {",
"int VAR_13;",
"VAR_13= GET_CACHE(re, &VAR_0->gb);",
"if (VAR_0->msmpeg4_version==1 || (VAR_13&0x80000000)==0) {",
"if (VAR_0->msmpeg4_version==1 || (VAR_13&0x40000000)==0) {",
"if(VAR_0->msmpeg4_version!=1) LAST_SKIP_BITS(re, &VAR_0->gb, 2);",
"UPDATE_CACHE(re, &VAR_0->gb);",
"if(VAR_0->msmpeg4_version<=3){",
"VAR_6= SHOW_UBITS(re, &VAR_0->gb, 1); SKIP_CACHE(re, &VAR_0->gb, 1);",
"VAR_7= SHOW_UBITS(re, &VAR_0->gb, 6); SKIP_CACHE(re, &VAR_0->gb, 6);",
"VAR_4= SHOW_SBITS(re, &VAR_0->gb, 8); LAST_SKIP_CACHE(re, &VAR_0->gb, 8);",
"SKIP_COUNTER(re, &VAR_0->gb, 1+6+8);",
"}else{",
"int VAR_14;",
"VAR_6= SHOW_UBITS(re, &VAR_0->gb, 1); SKIP_BITS(re, &VAR_0->gb, 1);",
"if(!VAR_0->esc3_level_length){",
"int VAR_15;",
"if(VAR_0->qscale<8){",
"VAR_15= SHOW_UBITS(re, &VAR_0->gb, 3); SKIP_BITS(re, &VAR_0->gb, 3);",
"if(VAR_15==0){",
"if(SHOW_UBITS(re, &VAR_0->gb, 1)) printf(\"cool a new vlc code ,contact the ffmpeg developers and upload the file\\VAR_2\");",
"SKIP_BITS(re, &VAR_0->gb, 1);",
"VAR_15=8;",
"}",
"}else{",
"VAR_15=2;",
"while(VAR_15<8 && SHOW_UBITS(re, &VAR_0->gb, 1)==0){",
"VAR_15++;",
"SKIP_BITS(re, &VAR_0->gb, 1);",
"}",
"if(VAR_15<8) SKIP_BITS(re, &VAR_0->gb, 1);",
"}",
"VAR_0->esc3_level_length= VAR_15;",
"VAR_0->esc3_run_length= SHOW_UBITS(re, &VAR_0->gb, 2) + 3; SKIP_BITS(re, &VAR_0->gb, 2);",
"UPDATE_CACHE(re, &VAR_0->gb);",
"}",
"VAR_7= SHOW_UBITS(re, &VAR_0->gb, VAR_0->esc3_run_length);",
"SKIP_BITS(re, &VAR_0->gb, VAR_0->esc3_run_length);",
"VAR_14= SHOW_UBITS(re, &VAR_0->gb, 1);",
"SKIP_BITS(re, &VAR_0->gb, 1);",
"VAR_4= SHOW_UBITS(re, &VAR_0->gb, VAR_0->esc3_level_length);",
"SKIP_BITS(re, &VAR_0->gb, VAR_0->esc3_level_length);",
"if(VAR_14) VAR_4= -VAR_4;",
"}",
"#if 0\n{",
"const int abs_level= ABS(VAR_4);",
"const int run1= VAR_7 - rl->max_run[VAR_6][abs_level] - VAR_8;",
"if(abs_level<=MAX_LEVEL && VAR_7<=MAX_RUN){",
"if(abs_level <= rl->max_level[VAR_6][VAR_7]){",
"fprintf(stderr, \"illegal 3. esc, vlc encoding possible\\VAR_2\");",
"return DECODING_AC_LOST;",
"}",
"if(abs_level <= rl->max_level[VAR_6][VAR_7]*2){",
"fprintf(stderr, \"illegal 3. esc, esc 1 encoding possible\\VAR_2\");",
"return DECODING_AC_LOST;",
"}",
"if(run1>=0 && abs_level <= rl->max_level[VAR_6][run1]){",
"fprintf(stderr, \"illegal 3. esc, esc 2 encoding possible\\VAR_2\");",
"return DECODING_AC_LOST;",
"}",
"}",
"}",
"#endif\nif (VAR_4>0) VAR_4= VAR_4 * VAR_11 + VAR_12;",
"else VAR_4= VAR_4 * VAR_11 - VAR_12;",
"#if 0\nif(VAR_4>2048 || VAR_4<-2048){",
"fprintf(stderr, \"|VAR_4| overflow in 3. esc\\VAR_2\");",
"return DECODING_AC_LOST;",
"}",
"#endif\nVAR_5+= VAR_7 + 1;",
"if(VAR_6) VAR_5+=192;",
"#ifdef ERROR_DETAILS\nif(VAR_7==66)\nfprintf(stderr, \"illegal vlc code in ESC3 VAR_4=%d\\VAR_2\", VAR_4);",
"else if((VAR_5>62 && VAR_5<192) || VAR_5>192+63)\nfprintf(stderr, \"VAR_7 overflow in ESC3 VAR_5=%d VAR_7=%d VAR_4=%d\\VAR_2\", VAR_5, VAR_7, VAR_4);",
"#endif\n} else {",
"#if MIN_CACHE_BITS < 23\nLAST_SKIP_BITS(re, &VAR_0->gb, 2);",
"UPDATE_CACHE(re, &VAR_0->gb);",
"#else\nSKIP_BITS(re, &VAR_0->gb, 2);",
"#endif\nGET_RL_VLC(VAR_4, VAR_7, re, &VAR_0->gb, rl_vlc, TEX_VLC_BITS, 2);",
"VAR_5+= VAR_7 + rl->max_run[VAR_7>>7][VAR_4/VAR_11] + VAR_8;",
"VAR_4 = (VAR_4 ^ SHOW_SBITS(re, &VAR_0->gb, 1)) - SHOW_SBITS(re, &VAR_0->gb, 1);",
"LAST_SKIP_BITS(re, &VAR_0->gb, 1);",
"#ifdef ERROR_DETAILS\nif(VAR_7==66)\nfprintf(stderr, \"illegal vlc code in ESC2 VAR_4=%d\\VAR_2\", VAR_4);",
"else if((VAR_5>62 && VAR_5<192) || VAR_5>192+63)\nfprintf(stderr, \"VAR_7 overflow in ESC2 VAR_5=%d VAR_7=%d VAR_4=%d\\VAR_2\", VAR_5, VAR_7, VAR_4);",
"#endif\n}",
"} else {",
"#if MIN_CACHE_BITS < 22\nLAST_SKIP_BITS(re, &VAR_0->gb, 1);",
"UPDATE_CACHE(re, &VAR_0->gb);",
"#else\nSKIP_BITS(re, &VAR_0->gb, 1);",
"#endif\nGET_RL_VLC(VAR_4, VAR_7, re, &VAR_0->gb, rl_vlc, TEX_VLC_BITS, 2);",
"VAR_5+= VAR_7;",
"VAR_4 = VAR_4 + rl->max_level[VAR_7>>7][(VAR_7-1)&63] * VAR_11;",
"VAR_4 = (VAR_4 ^ SHOW_SBITS(re, &VAR_0->gb, 1)) - SHOW_SBITS(re, &VAR_0->gb, 1);",
"LAST_SKIP_BITS(re, &VAR_0->gb, 1);",
"#ifdef ERROR_DETAILS\nif(VAR_7==66)\nfprintf(stderr, \"illegal vlc code in ESC1 VAR_4=%d\\VAR_2\", VAR_4);",
"else if((VAR_5>62 && VAR_5<192) || VAR_5>192+63)\nfprintf(stderr, \"VAR_7 overflow in ESC1 VAR_5=%d VAR_7=%d VAR_4=%d\\VAR_2\", VAR_5, VAR_7, VAR_4);",
"#endif\n}",
"} else {",
"VAR_5+= VAR_7;",
"VAR_4 = (VAR_4 ^ SHOW_SBITS(re, &VAR_0->gb, 1)) - SHOW_SBITS(re, &VAR_0->gb, 1);",
"LAST_SKIP_BITS(re, &VAR_0->gb, 1);",
"#ifdef ERROR_DETAILS\nif(VAR_7==66)\nfprintf(stderr, \"illegal vlc code VAR_4=%d\\VAR_2\", VAR_4);",
"else if((VAR_5>62 && VAR_5<192) || VAR_5>192+63)\nfprintf(stderr, \"VAR_7 overflow VAR_5=%d VAR_7=%d VAR_4=%d\\VAR_2\", VAR_5, VAR_7, VAR_4);",
"#endif\n}",
"if (VAR_5 > 62){",
"VAR_5-= 192;",
"if(VAR_5&(~63)){",
"if(VAR_0->error_resilience<0){",
"fprintf(stderr, \"ignoring overflow at %d %d\\VAR_2\", VAR_0->mb_x, VAR_0->mb_y);",
"break;",
"}else{",
"fprintf(stderr, \"ac-tex damaged at %d %d\\VAR_2\", VAR_0->mb_x, VAR_0->mb_y);",
"return -1;",
"}",
"}",
"VAR_1[VAR_10[VAR_5]] = VAR_4;",
"break;",
"}",
"VAR_1[VAR_10[VAR_5]] = VAR_4;",
"}",
"CLOSE_READER(re, &VAR_0->gb);",
"}",
"not_coded:\nif (VAR_0->mb_intra) {",
"mpeg4_pred_ac(VAR_0, VAR_1, VAR_2, VAR_9);",
"if (VAR_0->ac_pred) {",
"VAR_5 = 63;",
"}",
"}",
"if(VAR_0->msmpeg4_version==4 && VAR_5>0) VAR_5=63;",
"VAR_0->block_last_index[VAR_2] = VAR_5;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
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
],
[
103,
105
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133,
135
],
[
137,
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
177
],
[
179
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
241
],
[
243
],
[
247
],
[
249
],
[
251
],
[
253
],
[
257
],
[
259
],
[
263
],
[
265
],
[
267
],
[
269
],
[
273,
275
],
[
277
],
[
279
],
[
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
],
[
351,
353
],
[
355
],
[
357,
359
],
[
361,
363
],
[
365
],
[
367
],
[
369
],
[
371,
373,
375
],
[
377,
379
],
[
381,
383
],
[
385
],
[
389,
391
],
[
393
],
[
395,
397
],
[
399,
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411,
413,
415
],
[
417,
419
],
[
421,
423
],
[
425
],
[
427
],
[
429
],
[
431
],
[
433,
435,
437
],
[
439,
441
],
[
443,
445
],
[
447
],
[
449
],
[
451
],
[
453
],
[
455
],
[
457
],
[
459
],
[
461
],
[
463
],
[
465
],
[
467
],
[
471
],
[
473
],
[
475
],
[
479
],
[
481
],
[
483
],
[
485
],
[
487,
489
],
[
491
],
[
493
],
[
495
],
[
497
],
[
499
],
[
501
],
[
503
],
[
507
],
[
509
]
] |
27,114 | static int usb_device_post_load(void *opaque, int version_id)
{
USBDevice *dev = opaque;
if (dev->state == USB_STATE_NOTATTACHED) {
dev->attached = 0;
} else {
dev->attached = 1;
return 0;
| true | qemu | c60174e847082ab9f70720f86509a3353f816fad | static int usb_device_post_load(void *opaque, int version_id)
{
USBDevice *dev = opaque;
if (dev->state == USB_STATE_NOTATTACHED) {
dev->attached = 0;
} else {
dev->attached = 1;
return 0;
| {
"code": [],
"line_no": []
} | static int FUNC_0(void *VAR_0, int VAR_1)
{
USBDevice *dev = VAR_0;
if (dev->state == USB_STATE_NOTATTACHED) {
dev->attached = 0;
} else {
dev->attached = 1;
return 0;
| [
"static int FUNC_0(void *VAR_0, int VAR_1)\n{",
"USBDevice *dev = VAR_0;",
"if (dev->state == USB_STATE_NOTATTACHED) {",
"dev->attached = 0;",
"} else {",
"dev->attached = 1;",
"return 0;"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
22
]
] |
27,116 | int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp)
{
struct addrinfo ai,*res,*e;
const char *addr;
char port[33];
char uaddr[INET6_ADDRSTRLEN+1];
char uport[33];
int slisten, rc, to, port_min, port_max, p;
memset(&ai,0, sizeof(ai));
ai.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
ai.ai_family = PF_UNSPEC;
ai.ai_socktype = SOCK_STREAM;
if ((qemu_opt_get(opts, "host") == NULL) ||
(qemu_opt_get(opts, "port") == NULL)) {
error_setg(errp, "host and/or port not specified");
return -1;
}
pstrcpy(port, sizeof(port), qemu_opt_get(opts, "port"));
addr = qemu_opt_get(opts, "host");
to = qemu_opt_get_number(opts, "to", 0);
if (qemu_opt_get_bool(opts, "ipv4", 0))
ai.ai_family = PF_INET;
if (qemu_opt_get_bool(opts, "ipv6", 0))
ai.ai_family = PF_INET6;
/* lookup */
if (port_offset) {
unsigned long long baseport;
if (parse_uint_full(port, &baseport, 10) < 0) {
error_setg(errp, "can't convert to a number: %s", port);
return -1;
}
if (baseport > 65535 ||
baseport + port_offset > 65535) {
error_setg(errp, "port %s out of range", port);
return -1;
}
snprintf(port, sizeof(port), "%d", (int)baseport + port_offset);
}
rc = getaddrinfo(strlen(addr) ? addr : NULL, port, &ai, &res);
if (rc != 0) {
error_setg(errp, "address resolution failed for %s:%s: %s", addr, port,
gai_strerror(rc));
return -1;
}
/* create socket + bind */
for (e = res; e != NULL; e = e->ai_next) {
getnameinfo((struct sockaddr*)e->ai_addr,e->ai_addrlen,
uaddr,INET6_ADDRSTRLEN,uport,32,
NI_NUMERICHOST | NI_NUMERICSERV);
slisten = qemu_socket(e->ai_family, e->ai_socktype, e->ai_protocol);
if (slisten < 0) {
if (!e->ai_next) {
error_setg_errno(errp, errno, "Failed to create socket");
}
continue;
}
socket_set_fast_reuse(slisten);
#ifdef IPV6_V6ONLY
if (e->ai_family == PF_INET6) {
/* listen on both ipv4 and ipv6 */
const int off = 0;
qemu_setsockopt(slisten, IPPROTO_IPV6, IPV6_V6ONLY, &off,
sizeof(off));
}
#endif
port_min = inet_getport(e);
port_max = to ? to + port_offset : port_min;
for (p = port_min; p <= port_max; p++) {
inet_setport(e, p);
if (bind(slisten, e->ai_addr, e->ai_addrlen) == 0) {
goto listen;
}
if (p == port_max) {
if (!e->ai_next) {
error_setg_errno(errp, errno, "Failed to bind socket");
}
}
}
closesocket(slisten);
}
freeaddrinfo(res);
return -1;
listen:
if (listen(slisten,1) != 0) {
error_setg_errno(errp, errno, "Failed to listen on socket");
closesocket(slisten);
freeaddrinfo(res);
return -1;
}
qemu_opt_set(opts, "host", uaddr, &error_abort);
qemu_opt_set_number(opts, "port", inet_getport(e) - port_offset,
&error_abort);
qemu_opt_set_bool(opts, "ipv6", e->ai_family == PF_INET6,
&error_abort);
qemu_opt_set_bool(opts, "ipv4", e->ai_family != PF_INET6,
&error_abort);
freeaddrinfo(res);
return slisten;
}
| true | qemu | 3de3d698d942d1116152417f882c897b26b44e41 | int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp)
{
struct addrinfo ai,*res,*e;
const char *addr;
char port[33];
char uaddr[INET6_ADDRSTRLEN+1];
char uport[33];
int slisten, rc, to, port_min, port_max, p;
memset(&ai,0, sizeof(ai));
ai.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
ai.ai_family = PF_UNSPEC;
ai.ai_socktype = SOCK_STREAM;
if ((qemu_opt_get(opts, "host") == NULL) ||
(qemu_opt_get(opts, "port") == NULL)) {
error_setg(errp, "host and/or port not specified");
return -1;
}
pstrcpy(port, sizeof(port), qemu_opt_get(opts, "port"));
addr = qemu_opt_get(opts, "host");
to = qemu_opt_get_number(opts, "to", 0);
if (qemu_opt_get_bool(opts, "ipv4", 0))
ai.ai_family = PF_INET;
if (qemu_opt_get_bool(opts, "ipv6", 0))
ai.ai_family = PF_INET6;
if (port_offset) {
unsigned long long baseport;
if (parse_uint_full(port, &baseport, 10) < 0) {
error_setg(errp, "can't convert to a number: %s", port);
return -1;
}
if (baseport > 65535 ||
baseport + port_offset > 65535) {
error_setg(errp, "port %s out of range", port);
return -1;
}
snprintf(port, sizeof(port), "%d", (int)baseport + port_offset);
}
rc = getaddrinfo(strlen(addr) ? addr : NULL, port, &ai, &res);
if (rc != 0) {
error_setg(errp, "address resolution failed for %s:%s: %s", addr, port,
gai_strerror(rc));
return -1;
}
for (e = res; e != NULL; e = e->ai_next) {
getnameinfo((struct sockaddr*)e->ai_addr,e->ai_addrlen,
uaddr,INET6_ADDRSTRLEN,uport,32,
NI_NUMERICHOST | NI_NUMERICSERV);
slisten = qemu_socket(e->ai_family, e->ai_socktype, e->ai_protocol);
if (slisten < 0) {
if (!e->ai_next) {
error_setg_errno(errp, errno, "Failed to create socket");
}
continue;
}
socket_set_fast_reuse(slisten);
#ifdef IPV6_V6ONLY
if (e->ai_family == PF_INET6) {
const int off = 0;
qemu_setsockopt(slisten, IPPROTO_IPV6, IPV6_V6ONLY, &off,
sizeof(off));
}
#endif
port_min = inet_getport(e);
port_max = to ? to + port_offset : port_min;
for (p = port_min; p <= port_max; p++) {
inet_setport(e, p);
if (bind(slisten, e->ai_addr, e->ai_addrlen) == 0) {
goto listen;
}
if (p == port_max) {
if (!e->ai_next) {
error_setg_errno(errp, errno, "Failed to bind socket");
}
}
}
closesocket(slisten);
}
freeaddrinfo(res);
return -1;
listen:
if (listen(slisten,1) != 0) {
error_setg_errno(errp, errno, "Failed to listen on socket");
closesocket(slisten);
freeaddrinfo(res);
return -1;
}
qemu_opt_set(opts, "host", uaddr, &error_abort);
qemu_opt_set_number(opts, "port", inet_getport(e) - port_offset,
&error_abort);
qemu_opt_set_bool(opts, "ipv6", e->ai_family == PF_INET6,
&error_abort);
qemu_opt_set_bool(opts, "ipv4", e->ai_family != PF_INET6,
&error_abort);
freeaddrinfo(res);
return slisten;
}
| {
"code": [
" ai.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;"
],
"line_no": [
21
]
} | int FUNC_0(QemuOpts *VAR_0, int VAR_1, Error **VAR_2)
{
struct addrinfo VAR_3,*VAR_4,*VAR_5;
const char *VAR_6;
char VAR_7[33];
char VAR_8[INET6_ADDRSTRLEN+1];
char VAR_9[33];
int VAR_10, VAR_11, VAR_12, VAR_13, VAR_14, VAR_15;
memset(&VAR_3,0, sizeof(VAR_3));
VAR_3.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
VAR_3.ai_family = PF_UNSPEC;
VAR_3.ai_socktype = SOCK_STREAM;
if ((qemu_opt_get(VAR_0, "host") == NULL) ||
(qemu_opt_get(VAR_0, "VAR_7") == NULL)) {
error_setg(VAR_2, "host and/or VAR_7 not specified");
return -1;
}
pstrcpy(VAR_7, sizeof(VAR_7), qemu_opt_get(VAR_0, "VAR_7"));
VAR_6 = qemu_opt_get(VAR_0, "host");
VAR_12 = qemu_opt_get_number(VAR_0, "VAR_12", 0);
if (qemu_opt_get_bool(VAR_0, "ipv4", 0))
VAR_3.ai_family = PF_INET;
if (qemu_opt_get_bool(VAR_0, "ipv6", 0))
VAR_3.ai_family = PF_INET6;
if (VAR_1) {
unsigned long long VAR_16;
if (parse_uint_full(VAR_7, &VAR_16, 10) < 0) {
error_setg(VAR_2, "can't convert VAR_12 a number: %s", VAR_7);
return -1;
}
if (VAR_16 > 65535 ||
VAR_16 + VAR_1 > 65535) {
error_setg(VAR_2, "VAR_7 %s out of range", VAR_7);
return -1;
}
snprintf(VAR_7, sizeof(VAR_7), "%d", (int)VAR_16 + VAR_1);
}
VAR_11 = getaddrinfo(strlen(VAR_6) ? VAR_6 : NULL, VAR_7, &VAR_3, &VAR_4);
if (VAR_11 != 0) {
error_setg(VAR_2, "address resolution failed for %s:%s: %s", VAR_6, VAR_7,
gai_strerror(VAR_11));
return -1;
}
for (VAR_5 = VAR_4; VAR_5 != NULL; VAR_5 = VAR_5->ai_next) {
getnameinfo((struct sockaddr*)VAR_5->ai_addr,VAR_5->ai_addrlen,
VAR_8,INET6_ADDRSTRLEN,VAR_9,32,
NI_NUMERICHOST | NI_NUMERICSERV);
VAR_10 = qemu_socket(VAR_5->ai_family, VAR_5->ai_socktype, VAR_5->ai_protocol);
if (VAR_10 < 0) {
if (!VAR_5->ai_next) {
error_setg_errno(VAR_2, errno, "Failed VAR_12 create socket");
}
continue;
}
socket_set_fast_reuse(VAR_10);
#ifdef IPV6_V6ONLY
if (VAR_5->ai_family == PF_INET6) {
const int off = 0;
qemu_setsockopt(VAR_10, IPPROTO_IPV6, IPV6_V6ONLY, &off,
sizeof(off));
}
#endif
VAR_13 = inet_getport(VAR_5);
VAR_14 = VAR_12 ? VAR_12 + VAR_1 : VAR_13;
for (VAR_15 = VAR_13; VAR_15 <= VAR_14; VAR_15++) {
inet_setport(VAR_5, VAR_15);
if (bind(VAR_10, VAR_5->ai_addr, VAR_5->ai_addrlen) == 0) {
goto listen;
}
if (VAR_15 == VAR_14) {
if (!VAR_5->ai_next) {
error_setg_errno(VAR_2, errno, "Failed VAR_12 bind socket");
}
}
}
closesocket(VAR_10);
}
freeaddrinfo(VAR_4);
return -1;
listen:
if (listen(VAR_10,1) != 0) {
error_setg_errno(VAR_2, errno, "Failed VAR_12 listen on socket");
closesocket(VAR_10);
freeaddrinfo(VAR_4);
return -1;
}
qemu_opt_set(VAR_0, "host", VAR_8, &error_abort);
qemu_opt_set_number(VAR_0, "VAR_7", inet_getport(VAR_5) - VAR_1,
&error_abort);
qemu_opt_set_bool(VAR_0, "ipv6", VAR_5->ai_family == PF_INET6,
&error_abort);
qemu_opt_set_bool(VAR_0, "ipv4", VAR_5->ai_family != PF_INET6,
&error_abort);
freeaddrinfo(VAR_4);
return VAR_10;
}
| [
"int FUNC_0(QemuOpts *VAR_0, int VAR_1, Error **VAR_2)\n{",
"struct addrinfo VAR_3,*VAR_4,*VAR_5;",
"const char *VAR_6;",
"char VAR_7[33];",
"char VAR_8[INET6_ADDRSTRLEN+1];",
"char VAR_9[33];",
"int VAR_10, VAR_11, VAR_12, VAR_13, VAR_14, VAR_15;",
"memset(&VAR_3,0, sizeof(VAR_3));",
"VAR_3.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;",
"VAR_3.ai_family = PF_UNSPEC;",
"VAR_3.ai_socktype = SOCK_STREAM;",
"if ((qemu_opt_get(VAR_0, \"host\") == NULL) ||\n(qemu_opt_get(VAR_0, \"VAR_7\") == NULL)) {",
"error_setg(VAR_2, \"host and/or VAR_7 not specified\");",
"return -1;",
"}",
"pstrcpy(VAR_7, sizeof(VAR_7), qemu_opt_get(VAR_0, \"VAR_7\"));",
"VAR_6 = qemu_opt_get(VAR_0, \"host\");",
"VAR_12 = qemu_opt_get_number(VAR_0, \"VAR_12\", 0);",
"if (qemu_opt_get_bool(VAR_0, \"ipv4\", 0))\nVAR_3.ai_family = PF_INET;",
"if (qemu_opt_get_bool(VAR_0, \"ipv6\", 0))\nVAR_3.ai_family = PF_INET6;",
"if (VAR_1) {",
"unsigned long long VAR_16;",
"if (parse_uint_full(VAR_7, &VAR_16, 10) < 0) {",
"error_setg(VAR_2, \"can't convert VAR_12 a number: %s\", VAR_7);",
"return -1;",
"}",
"if (VAR_16 > 65535 ||\nVAR_16 + VAR_1 > 65535) {",
"error_setg(VAR_2, \"VAR_7 %s out of range\", VAR_7);",
"return -1;",
"}",
"snprintf(VAR_7, sizeof(VAR_7), \"%d\", (int)VAR_16 + VAR_1);",
"}",
"VAR_11 = getaddrinfo(strlen(VAR_6) ? VAR_6 : NULL, VAR_7, &VAR_3, &VAR_4);",
"if (VAR_11 != 0) {",
"error_setg(VAR_2, \"address resolution failed for %s:%s: %s\", VAR_6, VAR_7,\ngai_strerror(VAR_11));",
"return -1;",
"}",
"for (VAR_5 = VAR_4; VAR_5 != NULL; VAR_5 = VAR_5->ai_next) {",
"getnameinfo((struct sockaddr*)VAR_5->ai_addr,VAR_5->ai_addrlen,\nVAR_8,INET6_ADDRSTRLEN,VAR_9,32,\nNI_NUMERICHOST | NI_NUMERICSERV);",
"VAR_10 = qemu_socket(VAR_5->ai_family, VAR_5->ai_socktype, VAR_5->ai_protocol);",
"if (VAR_10 < 0) {",
"if (!VAR_5->ai_next) {",
"error_setg_errno(VAR_2, errno, \"Failed VAR_12 create socket\");",
"}",
"continue;",
"}",
"socket_set_fast_reuse(VAR_10);",
"#ifdef IPV6_V6ONLY\nif (VAR_5->ai_family == PF_INET6) {",
"const int off = 0;",
"qemu_setsockopt(VAR_10, IPPROTO_IPV6, IPV6_V6ONLY, &off,\nsizeof(off));",
"}",
"#endif\nVAR_13 = inet_getport(VAR_5);",
"VAR_14 = VAR_12 ? VAR_12 + VAR_1 : VAR_13;",
"for (VAR_15 = VAR_13; VAR_15 <= VAR_14; VAR_15++) {",
"inet_setport(VAR_5, VAR_15);",
"if (bind(VAR_10, VAR_5->ai_addr, VAR_5->ai_addrlen) == 0) {",
"goto listen;",
"}",
"if (VAR_15 == VAR_14) {",
"if (!VAR_5->ai_next) {",
"error_setg_errno(VAR_2, errno, \"Failed VAR_12 bind socket\");",
"}",
"}",
"}",
"closesocket(VAR_10);",
"}",
"freeaddrinfo(VAR_4);",
"return -1;",
"listen:\nif (listen(VAR_10,1) != 0) {",
"error_setg_errno(VAR_2, errno, \"Failed VAR_12 listen on socket\");",
"closesocket(VAR_10);",
"freeaddrinfo(VAR_4);",
"return -1;",
"}",
"qemu_opt_set(VAR_0, \"host\", VAR_8, &error_abort);",
"qemu_opt_set_number(VAR_0, \"VAR_7\", inet_getport(VAR_5) - VAR_1,\n&error_abort);",
"qemu_opt_set_bool(VAR_0, \"ipv6\", VAR_5->ai_family == PF_INET6,\n&error_abort);",
"qemu_opt_set_bool(VAR_0, \"ipv4\", VAR_5->ai_family != PF_INET6,\n&error_abort);",
"freeaddrinfo(VAR_4);",
"return VAR_10;",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47,
49
],
[
51,
53
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89,
91
],
[
93
],
[
95
],
[
101
],
[
103,
105,
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127,
129
],
[
133
],
[
135,
137
],
[
139
],
[
141,
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
181,
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197,
199
],
[
201,
203
],
[
205,
207
],
[
209
],
[
211
],
[
213
]
] |
27,117 | static int oma_read_packet(AVFormatContext *s, AVPacket *pkt)
{
OMAContext *oc = s->priv_data;
AVStream *st = s->streams[0];
int packet_size = st->codec->block_align;
int byte_rate = st->codec->bit_rate >> 3;
int64_t pos = avio_tell(s->pb);
int ret = av_get_packet(s->pb, pkt, packet_size);
if (ret < packet_size)
pkt->flags |= AV_PKT_FLAG_CORRUPT;
if (ret < 0)
return ret;
if (!ret)
return AVERROR_EOF;
pkt->stream_index = 0;
if (pos > 0) {
pkt->pts =
pkt->dts = av_rescale(pos, st->time_base.den,
byte_rate * (int64_t)st->time_base.num);
}
if (oc->encrypted) {
/* previous unencrypted block saved in IV for
* the next packet (CBC mode) */
if (ret == packet_size)
av_des_crypt(&oc->av_des, pkt->data, pkt->data,
(packet_size >> 3), oc->iv, 1);
else
memset(oc->iv, 0, 8);
}
return ret;
}
| true | FFmpeg | 7c2fa13df9a6130b3f258c7513933cbdca2fe23b | static int oma_read_packet(AVFormatContext *s, AVPacket *pkt)
{
OMAContext *oc = s->priv_data;
AVStream *st = s->streams[0];
int packet_size = st->codec->block_align;
int byte_rate = st->codec->bit_rate >> 3;
int64_t pos = avio_tell(s->pb);
int ret = av_get_packet(s->pb, pkt, packet_size);
if (ret < packet_size)
pkt->flags |= AV_PKT_FLAG_CORRUPT;
if (ret < 0)
return ret;
if (!ret)
return AVERROR_EOF;
pkt->stream_index = 0;
if (pos > 0) {
pkt->pts =
pkt->dts = av_rescale(pos, st->time_base.den,
byte_rate * (int64_t)st->time_base.num);
}
if (oc->encrypted) {
if (ret == packet_size)
av_des_crypt(&oc->av_des, pkt->data, pkt->data,
(packet_size >> 3), oc->iv, 1);
else
memset(oc->iv, 0, 8);
}
return ret;
}
| {
"code": [
" if (pos > 0) {"
],
"line_no": [
39
]
} | static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{
OMAContext *oc = VAR_0->priv_data;
AVStream *st = VAR_0->streams[0];
int VAR_2 = st->codec->block_align;
int VAR_3 = st->codec->bit_rate >> 3;
int64_t pos = avio_tell(VAR_0->pb);
int VAR_4 = av_get_packet(VAR_0->pb, VAR_1, VAR_2);
if (VAR_4 < VAR_2)
VAR_1->flags |= AV_PKT_FLAG_CORRUPT;
if (VAR_4 < 0)
return VAR_4;
if (!VAR_4)
return AVERROR_EOF;
VAR_1->stream_index = 0;
if (pos > 0) {
VAR_1->pts =
VAR_1->dts = av_rescale(pos, st->time_base.den,
VAR_3 * (int64_t)st->time_base.num);
}
if (oc->encrypted) {
if (VAR_4 == VAR_2)
av_des_crypt(&oc->av_des, VAR_1->data, VAR_1->data,
(VAR_2 >> 3), oc->iv, 1);
else
memset(oc->iv, 0, 8);
}
return VAR_4;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{",
"OMAContext *oc = VAR_0->priv_data;",
"AVStream *st = VAR_0->streams[0];",
"int VAR_2 = st->codec->block_align;",
"int VAR_3 = st->codec->bit_rate >> 3;",
"int64_t pos = avio_tell(VAR_0->pb);",
"int VAR_4 = av_get_packet(VAR_0->pb, VAR_1, VAR_2);",
"if (VAR_4 < VAR_2)\nVAR_1->flags |= AV_PKT_FLAG_CORRUPT;",
"if (VAR_4 < 0)\nreturn VAR_4;",
"if (!VAR_4)\nreturn AVERROR_EOF;",
"VAR_1->stream_index = 0;",
"if (pos > 0) {",
"VAR_1->pts =\nVAR_1->dts = av_rescale(pos, st->time_base.den,\nVAR_3 * (int64_t)st->time_base.num);",
"}",
"if (oc->encrypted) {",
"if (VAR_4 == VAR_2)\nav_des_crypt(&oc->av_des, VAR_1->data, VAR_1->data,\n(VAR_2 >> 3), oc->iv, 1);",
"else\nmemset(oc->iv, 0, 8);",
"}",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
21
],
[
25,
27
],
[
29,
31
],
[
35
],
[
39
],
[
41,
43,
45
],
[
47
],
[
51
],
[
57,
59,
61
],
[
63,
65
],
[
67
],
[
71
],
[
73
]
] |
27,118 | void av_opt_set_defaults2(void *s, int mask, int flags)
{
#endif
const AVOption *opt = NULL;
while ((opt = av_opt_next(s, opt)) != NULL) {
#if FF_API_OLD_AVOPTIONS
if ((opt->flags & mask) != flags)
continue;
#endif
switch (opt->type) {
case AV_OPT_TYPE_CONST:
/* Nothing to be done here */
break;
case AV_OPT_TYPE_FLAGS:
case AV_OPT_TYPE_INT:
case AV_OPT_TYPE_INT64:
av_opt_set_int(s, opt->name, opt->default_val.i64, 0);
break;
case AV_OPT_TYPE_DOUBLE:
case AV_OPT_TYPE_FLOAT: {
double val;
val = opt->default_val.dbl;
av_opt_set_double(s, opt->name, val, 0);
}
break;
case AV_OPT_TYPE_RATIONAL: {
AVRational val;
val = av_d2q(opt->default_val.dbl, INT_MAX);
av_opt_set_q(s, opt->name, val, 0);
}
break;
case AV_OPT_TYPE_STRING:
case AV_OPT_TYPE_IMAGE_SIZE:
case AV_OPT_TYPE_PIXEL_FMT:
case AV_OPT_TYPE_SAMPLE_FMT:
av_opt_set(s, opt->name, opt->default_val.str, 0);
break;
case AV_OPT_TYPE_BINARY:
/* Cannot set default for binary */
break;
default:
av_log(s, AV_LOG_DEBUG, "AVOption type %d of option %s not implemented yet\n", opt->type, opt->name);
}
}
}
| false | FFmpeg | 08d0969c1402ccec4dce44bd430128fb59d7b790 | void av_opt_set_defaults2(void *s, int mask, int flags)
{
#endif
const AVOption *opt = NULL;
while ((opt = av_opt_next(s, opt)) != NULL) {
#if FF_API_OLD_AVOPTIONS
if ((opt->flags & mask) != flags)
continue;
#endif
switch (opt->type) {
case AV_OPT_TYPE_CONST:
break;
case AV_OPT_TYPE_FLAGS:
case AV_OPT_TYPE_INT:
case AV_OPT_TYPE_INT64:
av_opt_set_int(s, opt->name, opt->default_val.i64, 0);
break;
case AV_OPT_TYPE_DOUBLE:
case AV_OPT_TYPE_FLOAT: {
double val;
val = opt->default_val.dbl;
av_opt_set_double(s, opt->name, val, 0);
}
break;
case AV_OPT_TYPE_RATIONAL: {
AVRational val;
val = av_d2q(opt->default_val.dbl, INT_MAX);
av_opt_set_q(s, opt->name, val, 0);
}
break;
case AV_OPT_TYPE_STRING:
case AV_OPT_TYPE_IMAGE_SIZE:
case AV_OPT_TYPE_PIXEL_FMT:
case AV_OPT_TYPE_SAMPLE_FMT:
av_opt_set(s, opt->name, opt->default_val.str, 0);
break;
case AV_OPT_TYPE_BINARY:
break;
default:
av_log(s, AV_LOG_DEBUG, "AVOption type %d of option %s not implemented yet\n", opt->type, opt->name);
}
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(void *VAR_0, int VAR_1, int VAR_2)
{
#endif
const AVOption *VAR_3 = NULL;
while ((VAR_3 = av_opt_next(VAR_0, VAR_3)) != NULL) {
#if FF_API_OLD_AVOPTIONS
if ((VAR_3->VAR_2 & VAR_1) != VAR_2)
continue;
#endif
switch (VAR_3->type) {
case AV_OPT_TYPE_CONST:
break;
case AV_OPT_TYPE_FLAGS:
case AV_OPT_TYPE_INT:
case AV_OPT_TYPE_INT64:
av_opt_set_int(VAR_0, VAR_3->name, VAR_3->default_val.i64, 0);
break;
case AV_OPT_TYPE_DOUBLE:
case AV_OPT_TYPE_FLOAT: {
double VAR_4;
VAR_4 = VAR_3->default_val.dbl;
av_opt_set_double(VAR_0, VAR_3->name, VAR_4, 0);
}
break;
case AV_OPT_TYPE_RATIONAL: {
AVRational VAR_4;
VAR_4 = av_d2q(VAR_3->default_val.dbl, INT_MAX);
av_opt_set_q(VAR_0, VAR_3->name, VAR_4, 0);
}
break;
case AV_OPT_TYPE_STRING:
case AV_OPT_TYPE_IMAGE_SIZE:
case AV_OPT_TYPE_PIXEL_FMT:
case AV_OPT_TYPE_SAMPLE_FMT:
av_opt_set(VAR_0, VAR_3->name, VAR_3->default_val.str, 0);
break;
case AV_OPT_TYPE_BINARY:
break;
default:
av_log(VAR_0, AV_LOG_DEBUG, "AVOption type %d of option %VAR_0 not implemented yet\n", VAR_3->type, VAR_3->name);
}
}
}
| [
"void FUNC_0(void *VAR_0, int VAR_1, int VAR_2)\n{",
"#endif\nconst AVOption *VAR_3 = NULL;",
"while ((VAR_3 = av_opt_next(VAR_0, VAR_3)) != NULL) {",
"#if FF_API_OLD_AVOPTIONS\nif ((VAR_3->VAR_2 & VAR_1) != VAR_2)\ncontinue;",
"#endif\nswitch (VAR_3->type) {",
"case AV_OPT_TYPE_CONST:\nbreak;",
"case AV_OPT_TYPE_FLAGS:\ncase AV_OPT_TYPE_INT:\ncase AV_OPT_TYPE_INT64:\nav_opt_set_int(VAR_0, VAR_3->name, VAR_3->default_val.i64, 0);",
"break;",
"case AV_OPT_TYPE_DOUBLE:\ncase AV_OPT_TYPE_FLOAT: {",
"double VAR_4;",
"VAR_4 = VAR_3->default_val.dbl;",
"av_opt_set_double(VAR_0, VAR_3->name, VAR_4, 0);",
"}",
"break;",
"case AV_OPT_TYPE_RATIONAL: {",
"AVRational VAR_4;",
"VAR_4 = av_d2q(VAR_3->default_val.dbl, INT_MAX);",
"av_opt_set_q(VAR_0, VAR_3->name, VAR_4, 0);",
"}",
"break;",
"case AV_OPT_TYPE_STRING:\ncase AV_OPT_TYPE_IMAGE_SIZE:\ncase AV_OPT_TYPE_PIXEL_FMT:\ncase AV_OPT_TYPE_SAMPLE_FMT:\nav_opt_set(VAR_0, VAR_3->name, VAR_3->default_val.str, 0);",
"break;",
"case AV_OPT_TYPE_BINARY:\nbreak;",
"default:\nav_log(VAR_0, AV_LOG_DEBUG, \"AVOption type %d of option %VAR_0 not implemented yet\\n\", VAR_3->type, VAR_3->name);",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
],
[
11,
13,
15
],
[
17,
19
],
[
21,
25
],
[
27,
29,
31,
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63,
65,
67,
69,
71
],
[
73
],
[
75,
79
],
[
81,
83
],
[
85
],
[
87
],
[
89
]
] |
27,119 | static int RENAME(resample_common)(ResampleContext *c,
void *dest, const void *source,
int n, int update_ctx)
{
DELEM *dst = dest;
const DELEM *src = source;
int dst_index;
int index= c->index;
int frac= c->frac;
int sample_index = 0;
while (index >= c->phase_count) {
sample_index++;
index -= c->phase_count;
}
for (dst_index = 0; dst_index < n; dst_index++) {
FELEM *filter = ((FELEM *) c->filter_bank) + c->filter_alloc * index;
FELEM2 val= FOFFSET;
int i;
for (i = 0; i < c->filter_length; i++) {
val += src[sample_index + i] * (FELEM2)filter[i];
}
OUT(dst[dst_index], val);
frac += c->dst_incr_mod;
index += c->dst_incr_div;
if (frac >= c->src_incr) {
frac -= c->src_incr;
index++;
}
while (index >= c->phase_count) {
sample_index++;
index -= c->phase_count;
}
}
if(update_ctx){
c->frac= frac;
c->index= index;
}
return sample_index;
}
| true | FFmpeg | 65e33d8e23277bb96809842656482e0e3fe8746f | static int RENAME(resample_common)(ResampleContext *c,
void *dest, const void *source,
int n, int update_ctx)
{
DELEM *dst = dest;
const DELEM *src = source;
int dst_index;
int index= c->index;
int frac= c->frac;
int sample_index = 0;
while (index >= c->phase_count) {
sample_index++;
index -= c->phase_count;
}
for (dst_index = 0; dst_index < n; dst_index++) {
FELEM *filter = ((FELEM *) c->filter_bank) + c->filter_alloc * index;
FELEM2 val= FOFFSET;
int i;
for (i = 0; i < c->filter_length; i++) {
val += src[sample_index + i] * (FELEM2)filter[i];
}
OUT(dst[dst_index], val);
frac += c->dst_incr_mod;
index += c->dst_incr_div;
if (frac >= c->src_incr) {
frac -= c->src_incr;
index++;
}
while (index >= c->phase_count) {
sample_index++;
index -= c->phase_count;
}
}
if(update_ctx){
c->frac= frac;
c->index= index;
}
return sample_index;
}
| {
"code": [
" FELEM2 val= FOFFSET;",
" for (i = 0; i < c->filter_length; i++) {",
" val += src[sample_index + i] * (FELEM2)filter[i];",
" OUT(dst[dst_index], val);"
],
"line_no": [
39,
43,
45,
49
]
} | static int FUNC_0(resample_common)(ResampleContext *c,
void *dest, const void *source,
int n, int update_ctx)
{
DELEM *dst = dest;
const DELEM *VAR_0 = source;
int VAR_1;
int VAR_2= c->VAR_2;
int VAR_3= c->VAR_3;
int VAR_4 = 0;
while (VAR_2 >= c->phase_count) {
VAR_4++;
VAR_2 -= c->phase_count;
}
for (VAR_1 = 0; VAR_1 < n; VAR_1++) {
FELEM *filter = ((FELEM *) c->filter_bank) + c->filter_alloc * VAR_2;
FELEM2 val= FOFFSET;
int i;
for (i = 0; i < c->filter_length; i++) {
val += VAR_0[VAR_4 + i] * (FELEM2)filter[i];
}
OUT(dst[VAR_1], val);
VAR_3 += c->dst_incr_mod;
VAR_2 += c->dst_incr_div;
if (VAR_3 >= c->src_incr) {
VAR_3 -= c->src_incr;
VAR_2++;
}
while (VAR_2 >= c->phase_count) {
VAR_4++;
VAR_2 -= c->phase_count;
}
}
if(update_ctx){
c->VAR_3= VAR_3;
c->VAR_2= VAR_2;
}
return VAR_4;
}
| [
"static int FUNC_0(resample_common)(ResampleContext *c,\nvoid *dest, const void *source,\nint n, int update_ctx)\n{",
"DELEM *dst = dest;",
"const DELEM *VAR_0 = source;",
"int VAR_1;",
"int VAR_2= c->VAR_2;",
"int VAR_3= c->VAR_3;",
"int VAR_4 = 0;",
"while (VAR_2 >= c->phase_count) {",
"VAR_4++;",
"VAR_2 -= c->phase_count;",
"}",
"for (VAR_1 = 0; VAR_1 < n; VAR_1++) {",
"FELEM *filter = ((FELEM *) c->filter_bank) + c->filter_alloc * VAR_2;",
"FELEM2 val= FOFFSET;",
"int i;",
"for (i = 0; i < c->filter_length; i++) {",
"val += VAR_0[VAR_4 + i] * (FELEM2)filter[i];",
"}",
"OUT(dst[VAR_1], val);",
"VAR_3 += c->dst_incr_mod;",
"VAR_2 += c->dst_incr_div;",
"if (VAR_3 >= c->src_incr) {",
"VAR_3 -= c->src_incr;",
"VAR_2++;",
"}",
"while (VAR_2 >= c->phase_count) {",
"VAR_4++;",
"VAR_2 -= c->phase_count;",
"}",
"}",
"if(update_ctx){",
"c->VAR_3= VAR_3;",
"c->VAR_2= VAR_2;",
"}",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
]
] |
27,120 | BdrvNextIterator *bdrv_next(BdrvNextIterator *it, BlockDriverState **bs)
{
if (!it) {
it = g_new(BdrvNextIterator, 1);
*it = (BdrvNextIterator) {
.phase = BDRV_NEXT_BACKEND_ROOTS,
};
}
/* First, return all root nodes of BlockBackends. In order to avoid
* returning a BDS twice when multiple BBs refer to it, we only return it
* if the BB is the first one in the parent list of the BDS. */
if (it->phase == BDRV_NEXT_BACKEND_ROOTS) {
do {
it->blk = blk_all_next(it->blk);
*bs = it->blk ? blk_bs(it->blk) : NULL;
} while (it->blk && (*bs == NULL || bdrv_first_blk(*bs) != it->blk));
if (*bs) {
return it;
}
it->phase = BDRV_NEXT_MONITOR_OWNED;
}
/* Then return the monitor-owned BDSes without a BB attached. Ignore all
* BDSes that are attached to a BlockBackend here; they have been handled
* by the above block already */
do {
it->bs = bdrv_next_monitor_owned(it->bs);
*bs = it->bs;
} while (*bs && bdrv_has_blk(*bs));
return *bs ? it : NULL;
}
| true | qemu | 88be7b4be4aa17c88247e162bdd7577ea79db94f | BdrvNextIterator *bdrv_next(BdrvNextIterator *it, BlockDriverState **bs)
{
if (!it) {
it = g_new(BdrvNextIterator, 1);
*it = (BdrvNextIterator) {
.phase = BDRV_NEXT_BACKEND_ROOTS,
};
}
if (it->phase == BDRV_NEXT_BACKEND_ROOTS) {
do {
it->blk = blk_all_next(it->blk);
*bs = it->blk ? blk_bs(it->blk) : NULL;
} while (it->blk && (*bs == NULL || bdrv_first_blk(*bs) != it->blk));
if (*bs) {
return it;
}
it->phase = BDRV_NEXT_MONITOR_OWNED;
}
do {
it->bs = bdrv_next_monitor_owned(it->bs);
*bs = it->bs;
} while (*bs && bdrv_has_blk(*bs));
return *bs ? it : NULL;
}
| {
"code": [
"BdrvNextIterator *bdrv_next(BdrvNextIterator *it, BlockDriverState **bs)",
" if (!it) {",
" it = g_new(BdrvNextIterator, 1);",
" *it = (BdrvNextIterator) {",
" .phase = BDRV_NEXT_BACKEND_ROOTS,",
" };",
" *bs = it->blk ? blk_bs(it->blk) : NULL;",
" } while (it->blk && (*bs == NULL || bdrv_first_blk(*bs) != it->blk));",
" if (*bs) {",
" return it;",
" *bs = it->bs;",
" } while (*bs && bdrv_has_blk(*bs));",
" return *bs ? it : NULL;"
],
"line_no": [
1,
5,
7,
9,
11,
13,
31,
33,
37,
39,
59,
61,
65
]
} | BdrvNextIterator *FUNC_0(BdrvNextIterator *it, BlockDriverState **bs)
{
if (!it) {
it = g_new(BdrvNextIterator, 1);
*it = (BdrvNextIterator) {
.phase = BDRV_NEXT_BACKEND_ROOTS,
};
}
if (it->phase == BDRV_NEXT_BACKEND_ROOTS) {
do {
it->blk = blk_all_next(it->blk);
*bs = it->blk ? blk_bs(it->blk) : NULL;
} while (it->blk && (*bs == NULL || bdrv_first_blk(*bs) != it->blk));
if (*bs) {
return it;
}
it->phase = BDRV_NEXT_MONITOR_OWNED;
}
do {
it->bs = bdrv_next_monitor_owned(it->bs);
*bs = it->bs;
} while (*bs && bdrv_has_blk(*bs));
return *bs ? it : NULL;
}
| [
"BdrvNextIterator *FUNC_0(BdrvNextIterator *it, BlockDriverState **bs)\n{",
"if (!it) {",
"it = g_new(BdrvNextIterator, 1);",
"*it = (BdrvNextIterator) {",
".phase = BDRV_NEXT_BACKEND_ROOTS,\n};",
"}",
"if (it->phase == BDRV_NEXT_BACKEND_ROOTS) {",
"do {",
"it->blk = blk_all_next(it->blk);",
"*bs = it->blk ? blk_bs(it->blk) : NULL;",
"} while (it->blk && (*bs == NULL || bdrv_first_blk(*bs) != it->blk));",
"if (*bs) {",
"return it;",
"}",
"it->phase = BDRV_NEXT_MONITOR_OWNED;",
"}",
"do {",
"it->bs = bdrv_next_monitor_owned(it->bs);",
"*bs = it->bs;",
"} while (*bs && bdrv_has_blk(*bs));",
"return *bs ? it : NULL;",
"}"
] | [
1,
1,
1,
1,
1,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13
],
[
15
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
]
] |
27,121 | static int channelmap_filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
{
AVFilterContext *ctx = inlink->dst;
AVFilterLink *outlink = ctx->outputs[0];
const ChannelMapContext *s = ctx->priv;
const int nch_in = av_get_channel_layout_nb_channels(inlink->channel_layout);
const int nch_out = s->nch;
int ch;
uint8_t *source_planes[MAX_CH];
memcpy(source_planes, buf->extended_data,
nch_in * sizeof(source_planes[0]));
if (nch_out > nch_in) {
if (nch_out > FF_ARRAY_ELEMS(buf->data)) {
uint8_t **new_extended_data =
av_mallocz(nch_out * sizeof(*buf->extended_data));
if (!new_extended_data) {
avfilter_unref_buffer(buf);
return AVERROR(ENOMEM);
}
if (buf->extended_data == buf->data) {
buf->extended_data = new_extended_data;
} else {
buf->extended_data = new_extended_data;
av_free(buf->extended_data);
}
} else if (buf->extended_data != buf->data) {
av_free(buf->extended_data);
buf->extended_data = buf->data;
}
}
for (ch = 0; ch < nch_out; ch++) {
buf->extended_data[s->map[ch].out_channel_idx] =
source_planes[s->map[ch].in_channel_idx];
}
if (buf->data != buf->extended_data)
memcpy(buf->data, buf->extended_data,
FFMIN(FF_ARRAY_ELEMS(buf->data), nch_out) * sizeof(buf->data[0]));
return ff_filter_samples(outlink, buf);
}
| true | FFmpeg | 1afd7a118fd71536971f991b823c89f1c9e87509 | static int channelmap_filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
{
AVFilterContext *ctx = inlink->dst;
AVFilterLink *outlink = ctx->outputs[0];
const ChannelMapContext *s = ctx->priv;
const int nch_in = av_get_channel_layout_nb_channels(inlink->channel_layout);
const int nch_out = s->nch;
int ch;
uint8_t *source_planes[MAX_CH];
memcpy(source_planes, buf->extended_data,
nch_in * sizeof(source_planes[0]));
if (nch_out > nch_in) {
if (nch_out > FF_ARRAY_ELEMS(buf->data)) {
uint8_t **new_extended_data =
av_mallocz(nch_out * sizeof(*buf->extended_data));
if (!new_extended_data) {
avfilter_unref_buffer(buf);
return AVERROR(ENOMEM);
}
if (buf->extended_data == buf->data) {
buf->extended_data = new_extended_data;
} else {
buf->extended_data = new_extended_data;
av_free(buf->extended_data);
}
} else if (buf->extended_data != buf->data) {
av_free(buf->extended_data);
buf->extended_data = buf->data;
}
}
for (ch = 0; ch < nch_out; ch++) {
buf->extended_data[s->map[ch].out_channel_idx] =
source_planes[s->map[ch].in_channel_idx];
}
if (buf->data != buf->extended_data)
memcpy(buf->data, buf->extended_data,
FFMIN(FF_ARRAY_ELEMS(buf->data), nch_out) * sizeof(buf->data[0]));
return ff_filter_samples(outlink, buf);
}
| {
"code": [
" buf->extended_data = new_extended_data;"
],
"line_no": [
45
]
} | static int FUNC_0(AVFilterLink *VAR_0, AVFilterBufferRef *VAR_1)
{
AVFilterContext *ctx = VAR_0->dst;
AVFilterLink *outlink = ctx->outputs[0];
const ChannelMapContext *VAR_2 = ctx->priv;
const int VAR_3 = av_get_channel_layout_nb_channels(VAR_0->channel_layout);
const int VAR_4 = VAR_2->nch;
int VAR_5;
uint8_t *source_planes[MAX_CH];
memcpy(source_planes, VAR_1->extended_data,
VAR_3 * sizeof(source_planes[0]));
if (VAR_4 > VAR_3) {
if (VAR_4 > FF_ARRAY_ELEMS(VAR_1->data)) {
uint8_t **new_extended_data =
av_mallocz(VAR_4 * sizeof(*VAR_1->extended_data));
if (!new_extended_data) {
avfilter_unref_buffer(VAR_1);
return AVERROR(ENOMEM);
}
if (VAR_1->extended_data == VAR_1->data) {
VAR_1->extended_data = new_extended_data;
} else {
VAR_1->extended_data = new_extended_data;
av_free(VAR_1->extended_data);
}
} else if (VAR_1->extended_data != VAR_1->data) {
av_free(VAR_1->extended_data);
VAR_1->extended_data = VAR_1->data;
}
}
for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {
VAR_1->extended_data[VAR_2->map[VAR_5].out_channel_idx] =
source_planes[VAR_2->map[VAR_5].in_channel_idx];
}
if (VAR_1->data != VAR_1->extended_data)
memcpy(VAR_1->data, VAR_1->extended_data,
FFMIN(FF_ARRAY_ELEMS(VAR_1->data), VAR_4) * sizeof(VAR_1->data[0]));
return ff_filter_samples(outlink, VAR_1);
}
| [
"static int FUNC_0(AVFilterLink *VAR_0, AVFilterBufferRef *VAR_1)\n{",
"AVFilterContext *ctx = VAR_0->dst;",
"AVFilterLink *outlink = ctx->outputs[0];",
"const ChannelMapContext *VAR_2 = ctx->priv;",
"const int VAR_3 = av_get_channel_layout_nb_channels(VAR_0->channel_layout);",
"const int VAR_4 = VAR_2->nch;",
"int VAR_5;",
"uint8_t *source_planes[MAX_CH];",
"memcpy(source_planes, VAR_1->extended_data,\nVAR_3 * sizeof(source_planes[0]));",
"if (VAR_4 > VAR_3) {",
"if (VAR_4 > FF_ARRAY_ELEMS(VAR_1->data)) {",
"uint8_t **new_extended_data =\nav_mallocz(VAR_4 * sizeof(*VAR_1->extended_data));",
"if (!new_extended_data) {",
"avfilter_unref_buffer(VAR_1);",
"return AVERROR(ENOMEM);",
"}",
"if (VAR_1->extended_data == VAR_1->data) {",
"VAR_1->extended_data = new_extended_data;",
"} else {",
"VAR_1->extended_data = new_extended_data;",
"av_free(VAR_1->extended_data);",
"}",
"} else if (VAR_1->extended_data != VAR_1->data) {",
"av_free(VAR_1->extended_data);",
"VAR_1->extended_data = VAR_1->data;",
"}",
"}",
"for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {",
"VAR_1->extended_data[VAR_2->map[VAR_5].out_channel_idx] =\nsource_planes[VAR_2->map[VAR_5].in_channel_idx];",
"}",
"if (VAR_1->data != VAR_1->extended_data)\nmemcpy(VAR_1->data, VAR_1->extended_data,\nFFMIN(FF_ARRAY_ELEMS(VAR_1->data), VAR_4) * sizeof(VAR_1->data[0]));",
"return ff_filter_samples(outlink, 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21,
23
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69,
71
],
[
73
],
[
77,
79,
81
],
[
85
],
[
87
]
] |
27,122 | static int encode_thread(AVCodecContext *c, void *arg){
MpegEncContext *s= *(void**)arg;
int mb_x, mb_y, pdif = 0;
int chr_h= 16>>s->chroma_y_shift;
int i, j;
MpegEncContext best_s, backup_s;
uint8_t bit_buf[2][MAX_MB_BYTES];
uint8_t bit_buf2[2][MAX_MB_BYTES];
uint8_t bit_buf_tex[2][MAX_MB_BYTES];
PutBitContext pb[2], pb2[2], tex_pb[2];
//printf("%d->%d\n", s->resync_mb_y, s->end_mb_y);
ff_check_alignment();
for(i=0; i<2; i++){
init_put_bits(&pb [i], bit_buf [i], MAX_MB_BYTES);
init_put_bits(&pb2 [i], bit_buf2 [i], MAX_MB_BYTES);
init_put_bits(&tex_pb[i], bit_buf_tex[i], MAX_MB_BYTES);
}
s->last_bits= put_bits_count(&s->pb);
s->mv_bits=0;
s->misc_bits=0;
s->i_tex_bits=0;
s->p_tex_bits=0;
s->i_count=0;
s->f_count=0;
s->b_count=0;
s->skip_count=0;
for(i=0; i<3; i++){
/* init last dc values */
/* note: quant matrix value (8) is implied here */
s->last_dc[i] = 128 << s->intra_dc_precision;
s->current_picture.error[i] = 0;
}
s->mb_skip_run = 0;
memset(s->last_mv, 0, sizeof(s->last_mv));
s->last_mv_dir = 0;
switch(s->codec_id){
case CODEC_ID_H263:
case CODEC_ID_H263P:
case CODEC_ID_FLV1:
if (CONFIG_H263_ENCODER || CONFIG_FLV_ENCODER)
s->gob_index = ff_h263_get_gob_height(s);
break;
case CODEC_ID_MPEG4:
if(CONFIG_MPEG4_ENCODER && s->partitioned_frame)
ff_mpeg4_init_partitions(s);
break;
}
s->resync_mb_x=0;
s->resync_mb_y=0;
s->first_slice_line = 1;
s->ptr_lastgob = s->pb.buf;
for(mb_y= s->start_mb_y; mb_y < s->end_mb_y; mb_y++) {
// printf("row %d at %X\n", s->mb_y, (int)s);
s->mb_x=0;
s->mb_y= mb_y;
ff_set_qscale(s, s->qscale);
ff_init_block_index(s);
for(mb_x=0; mb_x < s->mb_width; mb_x++) {
int xy= mb_y*s->mb_stride + mb_x; // removed const, H261 needs to adjust this
int mb_type= s->mb_type[xy];
// int d;
int dmin= INT_MAX;
int dir;
if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < MAX_MB_BYTES){
av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
return -1;
}
if(s->data_partitioning){
if( s->pb2 .buf_end - s->pb2 .buf - (put_bits_count(&s-> pb2)>>3) < MAX_MB_BYTES
|| s->tex_pb.buf_end - s->tex_pb.buf - (put_bits_count(&s->tex_pb )>>3) < MAX_MB_BYTES){
av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
return -1;
}
}
s->mb_x = mb_x;
s->mb_y = mb_y; // moved into loop, can get changed by H.261
ff_update_block_index(s);
if(CONFIG_H261_ENCODER && s->codec_id == CODEC_ID_H261){
ff_h261_reorder_mb_index(s);
xy= s->mb_y*s->mb_stride + s->mb_x;
mb_type= s->mb_type[xy];
}
/* write gob / video packet header */
if(s->rtp_mode){
int current_packet_size, is_gob_start;
current_packet_size= ((put_bits_count(&s->pb)+7)>>3) - (s->ptr_lastgob - s->pb.buf);
is_gob_start= s->avctx->rtp_payload_size && current_packet_size >= s->avctx->rtp_payload_size && mb_y + mb_x>0;
if(s->start_mb_y == mb_y && mb_y > 0 && mb_x==0) is_gob_start=1;
switch(s->codec_id){
case CODEC_ID_H263:
case CODEC_ID_H263P:
if(!s->h263_slice_structured)
if(s->mb_x || s->mb_y%s->gob_index) is_gob_start=0;
break;
case CODEC_ID_MPEG2VIDEO:
if(s->mb_x==0 && s->mb_y!=0) is_gob_start=1;
case CODEC_ID_MPEG1VIDEO:
if(s->mb_skip_run) is_gob_start=0;
break;
}
if(is_gob_start){
if(s->start_mb_y != mb_y || mb_x!=0){
write_slice_end(s);
if(CONFIG_MPEG4_ENCODER && s->codec_id==CODEC_ID_MPEG4 && s->partitioned_frame){
ff_mpeg4_init_partitions(s);
}
}
assert((put_bits_count(&s->pb)&7) == 0);
current_packet_size= put_bits_ptr(&s->pb) - s->ptr_lastgob;
if(s->avctx->error_rate && s->resync_mb_x + s->resync_mb_y > 0){
int r= put_bits_count(&s->pb)/8 + s->picture_number + 16 + s->mb_x + s->mb_y;
int d= 100 / s->avctx->error_rate;
if(r % d == 0){
current_packet_size=0;
#ifndef ALT_BITSTREAM_WRITER
s->pb.buf_ptr= s->ptr_lastgob;
#endif
assert(put_bits_ptr(&s->pb) == s->ptr_lastgob);
}
}
if (s->avctx->rtp_callback){
int number_mb = (mb_y - s->resync_mb_y)*s->mb_width + mb_x - s->resync_mb_x;
s->avctx->rtp_callback(s->avctx, s->ptr_lastgob, current_packet_size, number_mb);
}
switch(s->codec_id){
case CODEC_ID_MPEG4:
if (CONFIG_MPEG4_ENCODER) {
ff_mpeg4_encode_video_packet_header(s);
ff_mpeg4_clean_buffers(s);
}
break;
case CODEC_ID_MPEG1VIDEO:
case CODEC_ID_MPEG2VIDEO:
if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER) {
ff_mpeg1_encode_slice_header(s);
ff_mpeg1_clean_buffers(s);
}
break;
case CODEC_ID_H263:
case CODEC_ID_H263P:
if (CONFIG_H263_ENCODER)
h263_encode_gob_header(s, mb_y);
break;
}
if(s->flags&CODEC_FLAG_PASS1){
int bits= put_bits_count(&s->pb);
s->misc_bits+= bits - s->last_bits;
s->last_bits= bits;
}
s->ptr_lastgob += current_packet_size;
s->first_slice_line=1;
s->resync_mb_x=mb_x;
s->resync_mb_y=mb_y;
}
}
if( (s->resync_mb_x == s->mb_x)
&& s->resync_mb_y+1 == s->mb_y){
s->first_slice_line=0;
}
s->mb_skipped=0;
s->dquant=0; //only for QP_RD
if(mb_type & (mb_type-1) || (s->flags & CODEC_FLAG_QP_RD)){ // more than 1 MB type possible or CODEC_FLAG_QP_RD
int next_block=0;
int pb_bits_count, pb2_bits_count, tex_pb_bits_count;
copy_context_before_encode(&backup_s, s, -1);
backup_s.pb= s->pb;
best_s.data_partitioning= s->data_partitioning;
best_s.partitioned_frame= s->partitioned_frame;
if(s->data_partitioning){
backup_s.pb2= s->pb2;
backup_s.tex_pb= s->tex_pb;
}
if(mb_type&CANDIDATE_MB_TYPE_INTER){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = s->p_mv_table[xy][0];
s->mv[0][0][1] = s->p_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
}
if(mb_type&CANDIDATE_MB_TYPE_INTER_I){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(i=0; i<2; i++){
j= s->field_select[0][i] = s->p_field_select_table[i][xy];
s->mv[0][i][0] = s->p_field_mv_table[i][j][xy][0];
s->mv[0][i][1] = s->p_field_mv_table[i][j][xy][1];
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER_I, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_SKIPPED){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_SKIPPED, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
}
if(mb_type&CANDIDATE_MB_TYPE_INTER4V){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_8X8;
s->mb_intra= 0;
for(i=0; i<4; i++){
s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0];
s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1];
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER4V, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_FORWARD){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = s->b_forw_mv_table[xy][0];
s->mv[0][0][1] = s->b_forw_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_FORWARD, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
}
if(mb_type&CANDIDATE_MB_TYPE_BACKWARD){
s->mv_dir = MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[1][0][0] = s->b_back_mv_table[xy][0];
s->mv[1][0][1] = s->b_back_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BACKWARD, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[1][0][0], s->mv[1][0][1]);
}
if(mb_type&CANDIDATE_MB_TYPE_BIDIR){
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = s->b_bidir_forw_mv_table[xy][0];
s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1];
s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0];
s->mv[1][0][1] = s->b_bidir_back_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BIDIR, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_FORWARD_I){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(i=0; i<2; i++){
j= s->field_select[0][i] = s->b_field_select_table[0][i][xy];
s->mv[0][i][0] = s->b_field_mv_table[0][i][j][xy][0];
s->mv[0][i][1] = s->b_field_mv_table[0][i][j][xy][1];
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_FORWARD_I, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_BACKWARD_I){
s->mv_dir = MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(i=0; i<2; i++){
j= s->field_select[1][i] = s->b_field_select_table[1][i][xy];
s->mv[1][i][0] = s->b_field_mv_table[1][i][j][xy][0];
s->mv[1][i][1] = s->b_field_mv_table[1][i][j][xy][1];
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BACKWARD_I, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_BIDIR_I){
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(dir=0; dir<2; dir++){
for(i=0; i<2; i++){
j= s->field_select[dir][i] = s->b_field_select_table[dir][i][xy];
s->mv[dir][i][0] = s->b_field_mv_table[dir][i][j][xy][0];
s->mv[dir][i][1] = s->b_field_mv_table[dir][i][j][xy][1];
}
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BIDIR_I, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_INTRA){
s->mv_dir = 0;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 1;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTRA, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
if(s->h263_pred || s->h263_aic){
if(best_s.mb_intra)
s->mbintra_table[mb_x + mb_y*s->mb_stride]=1;
else
ff_clean_intra_table_entries(s); //old mode?
}
}
if((s->flags & CODEC_FLAG_QP_RD) && dmin < INT_MAX){
if(best_s.mv_type==MV_TYPE_16X16){ //FIXME move 4mv after QPRD
const int last_qp= backup_s.qscale;
int qpi, qp, dc[6];
DCTELEM ac[6][16];
const int mvdir= (best_s.mv_dir&MV_DIR_BACKWARD) ? 1 : 0;
static const int dquant_tab[4]={-1,1,-2,2};
assert(backup_s.dquant == 0);
//FIXME intra
s->mv_dir= best_s.mv_dir;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= best_s.mb_intra;
s->mv[0][0][0] = best_s.mv[0][0][0];
s->mv[0][0][1] = best_s.mv[0][0][1];
s->mv[1][0][0] = best_s.mv[1][0][0];
s->mv[1][0][1] = best_s.mv[1][0][1];
qpi = s->pict_type == FF_B_TYPE ? 2 : 0;
for(; qpi<4; qpi++){
int dquant= dquant_tab[qpi];
qp= last_qp + dquant;
if(qp < s->avctx->qmin || qp > s->avctx->qmax)
continue;
backup_s.dquant= dquant;
if(s->mb_intra && s->dc_val[0]){
for(i=0; i<6; i++){
dc[i]= s->dc_val[0][ s->block_index[i] ];
memcpy(ac[i], s->ac_val[0][s->block_index[i]], sizeof(DCTELEM)*16);
}
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER /* wrong but unused */, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[mvdir][0][0], s->mv[mvdir][0][1]);
if(best_s.qscale != qp){
if(s->mb_intra && s->dc_val[0]){
for(i=0; i<6; i++){
s->dc_val[0][ s->block_index[i] ]= dc[i];
memcpy(s->ac_val[0][s->block_index[i]], ac[i], sizeof(DCTELEM)*16);
}
}
}
}
}
}
if(CONFIG_MPEG4_ENCODER && mb_type&CANDIDATE_MB_TYPE_DIRECT){
int mx= s->b_direct_mv_table[xy][0];
int my= s->b_direct_mv_table[xy][1];
backup_s.dquant = 0;
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
s->mb_intra= 0;
ff_mpeg4_set_direct_mv(s, mx, my);
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb,
&dmin, &next_block, mx, my);
}
if(CONFIG_MPEG4_ENCODER && mb_type&CANDIDATE_MB_TYPE_DIRECT0){
backup_s.dquant = 0;
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
s->mb_intra= 0;
ff_mpeg4_set_direct_mv(s, 0, 0);
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(!best_s.mb_intra && s->flags2&CODEC_FLAG2_SKIP_RD){
int coded=0;
for(i=0; i<6; i++)
coded |= s->block_last_index[i];
if(coded){
int mx,my;
memcpy(s->mv, best_s.mv, sizeof(s->mv));
if(CONFIG_MPEG4_ENCODER && best_s.mv_dir & MV_DIRECT){
mx=my=0; //FIXME find the one we actually used
ff_mpeg4_set_direct_mv(s, mx, my);
}else if(best_s.mv_dir&MV_DIR_BACKWARD){
mx= s->mv[1][0][0];
my= s->mv[1][0][1];
}else{
mx= s->mv[0][0][0];
my= s->mv[0][0][1];
}
s->mv_dir= best_s.mv_dir;
s->mv_type = best_s.mv_type;
s->mb_intra= 0;
/* s->mv[0][0][0] = best_s.mv[0][0][0];
s->mv[0][0][1] = best_s.mv[0][0][1];
s->mv[1][0][0] = best_s.mv[1][0][0];
s->mv[1][0][1] = best_s.mv[1][0][1];*/
backup_s.dquant= 0;
s->skipdct=1;
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER /* wrong but unused */, pb, pb2, tex_pb,
&dmin, &next_block, mx, my);
s->skipdct=0;
}
}
s->current_picture.qscale_table[xy]= best_s.qscale;
copy_context_after_encode(s, &best_s, -1);
pb_bits_count= put_bits_count(&s->pb);
flush_put_bits(&s->pb);
ff_copy_bits(&backup_s.pb, bit_buf[next_block^1], pb_bits_count);
s->pb= backup_s.pb;
if(s->data_partitioning){
pb2_bits_count= put_bits_count(&s->pb2);
flush_put_bits(&s->pb2);
ff_copy_bits(&backup_s.pb2, bit_buf2[next_block^1], pb2_bits_count);
s->pb2= backup_s.pb2;
tex_pb_bits_count= put_bits_count(&s->tex_pb);
flush_put_bits(&s->tex_pb);
ff_copy_bits(&backup_s.tex_pb, bit_buf_tex[next_block^1], tex_pb_bits_count);
s->tex_pb= backup_s.tex_pb;
}
s->last_bits= put_bits_count(&s->pb);
if (CONFIG_ANY_H263_ENCODER &&
s->out_format == FMT_H263 && s->pict_type!=FF_B_TYPE)
ff_h263_update_motion_val(s);
if(next_block==0){ //FIXME 16 vs linesize16
s->dsp.put_pixels_tab[0][0](s->dest[0], s->rd_scratchpad , s->linesize ,16);
s->dsp.put_pixels_tab[1][0](s->dest[1], s->rd_scratchpad + 16*s->linesize , s->uvlinesize, 8);
s->dsp.put_pixels_tab[1][0](s->dest[2], s->rd_scratchpad + 16*s->linesize + 8, s->uvlinesize, 8);
}
if(s->avctx->mb_decision == FF_MB_DECISION_BITS)
MPV_decode_mb(s, s->block);
} else {
int motion_x = 0, motion_y = 0;
s->mv_type=MV_TYPE_16X16;
// only one MB-Type possible
switch(mb_type){
case CANDIDATE_MB_TYPE_INTRA:
s->mv_dir = 0;
s->mb_intra= 1;
motion_x= s->mv[0][0][0] = 0;
motion_y= s->mv[0][0][1] = 0;
break;
case CANDIDATE_MB_TYPE_INTER:
s->mv_dir = MV_DIR_FORWARD;
s->mb_intra= 0;
motion_x= s->mv[0][0][0] = s->p_mv_table[xy][0];
motion_y= s->mv[0][0][1] = s->p_mv_table[xy][1];
break;
case CANDIDATE_MB_TYPE_INTER_I:
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(i=0; i<2; i++){
j= s->field_select[0][i] = s->p_field_select_table[i][xy];
s->mv[0][i][0] = s->p_field_mv_table[i][j][xy][0];
s->mv[0][i][1] = s->p_field_mv_table[i][j][xy][1];
}
break;
case CANDIDATE_MB_TYPE_INTER4V:
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_8X8;
s->mb_intra= 0;
for(i=0; i<4; i++){
s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0];
s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1];
}
break;
case CANDIDATE_MB_TYPE_DIRECT:
if (CONFIG_MPEG4_ENCODER) {
s->mv_dir = MV_DIR_FORWARD|MV_DIR_BACKWARD|MV_DIRECT;
s->mb_intra= 0;
motion_x=s->b_direct_mv_table[xy][0];
motion_y=s->b_direct_mv_table[xy][1];
ff_mpeg4_set_direct_mv(s, motion_x, motion_y);
}
break;
case CANDIDATE_MB_TYPE_DIRECT0:
if (CONFIG_MPEG4_ENCODER) {
s->mv_dir = MV_DIR_FORWARD|MV_DIR_BACKWARD|MV_DIRECT;
s->mb_intra= 0;
ff_mpeg4_set_direct_mv(s, 0, 0);
}
break;
case CANDIDATE_MB_TYPE_BIDIR:
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mb_intra= 0;
s->mv[0][0][0] = s->b_bidir_forw_mv_table[xy][0];
s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1];
s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0];
s->mv[1][0][1] = s->b_bidir_back_mv_table[xy][1];
break;
case CANDIDATE_MB_TYPE_BACKWARD:
s->mv_dir = MV_DIR_BACKWARD;
s->mb_intra= 0;
motion_x= s->mv[1][0][0] = s->b_back_mv_table[xy][0];
motion_y= s->mv[1][0][1] = s->b_back_mv_table[xy][1];
break;
case CANDIDATE_MB_TYPE_FORWARD:
s->mv_dir = MV_DIR_FORWARD;
s->mb_intra= 0;
motion_x= s->mv[0][0][0] = s->b_forw_mv_table[xy][0];
motion_y= s->mv[0][0][1] = s->b_forw_mv_table[xy][1];
// printf(" %d %d ", motion_x, motion_y);
break;
case CANDIDATE_MB_TYPE_FORWARD_I:
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(i=0; i<2; i++){
j= s->field_select[0][i] = s->b_field_select_table[0][i][xy];
s->mv[0][i][0] = s->b_field_mv_table[0][i][j][xy][0];
s->mv[0][i][1] = s->b_field_mv_table[0][i][j][xy][1];
}
break;
case CANDIDATE_MB_TYPE_BACKWARD_I:
s->mv_dir = MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(i=0; i<2; i++){
j= s->field_select[1][i] = s->b_field_select_table[1][i][xy];
s->mv[1][i][0] = s->b_field_mv_table[1][i][j][xy][0];
s->mv[1][i][1] = s->b_field_mv_table[1][i][j][xy][1];
}
break;
case CANDIDATE_MB_TYPE_BIDIR_I:
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(dir=0; dir<2; dir++){
for(i=0; i<2; i++){
j= s->field_select[dir][i] = s->b_field_select_table[dir][i][xy];
s->mv[dir][i][0] = s->b_field_mv_table[dir][i][j][xy][0];
s->mv[dir][i][1] = s->b_field_mv_table[dir][i][j][xy][1];
}
}
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "illegal MB type\n");
}
encode_mb(s, motion_x, motion_y);
// RAL: Update last macroblock type
s->last_mv_dir = s->mv_dir;
if (CONFIG_ANY_H263_ENCODER &&
s->out_format == FMT_H263 && s->pict_type!=FF_B_TYPE)
ff_h263_update_motion_val(s);
MPV_decode_mb(s, s->block);
}
/* clean the MV table in IPS frames for direct mode in B frames */
if(s->mb_intra /* && I,P,S_TYPE */){
s->p_mv_table[xy][0]=0;
s->p_mv_table[xy][1]=0;
}
if(s->flags&CODEC_FLAG_PSNR){
int w= 16;
int h= 16;
if(s->mb_x*16 + 16 > s->width ) w= s->width - s->mb_x*16;
if(s->mb_y*16 + 16 > s->height) h= s->height- s->mb_y*16;
s->current_picture.error[0] += sse(
s, s->new_picture.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16,
s->dest[0], w, h, s->linesize);
s->current_picture.error[1] += sse(
s, s->new_picture.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*chr_h,
s->dest[1], w>>1, h>>s->chroma_y_shift, s->uvlinesize);
s->current_picture.error[2] += sse(
s, s->new_picture.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*chr_h,
s->dest[2], w>>1, h>>s->chroma_y_shift, s->uvlinesize);
}
if(s->loop_filter){
if(CONFIG_ANY_H263_ENCODER && s->out_format == FMT_H263)
ff_h263_loop_filter(s);
}
//printf("MB %d %d bits\n", s->mb_x+s->mb_y*s->mb_stride, put_bits_count(&s->pb));
}
}
//not beautiful here but we must write it before flushing so it has to be here
if (CONFIG_MSMPEG4_ENCODER && s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type == FF_I_TYPE)
msmpeg4_encode_ext_header(s);
write_slice_end(s);
/* Send the last GOB if RTP */
if (s->avctx->rtp_callback) {
int number_mb = (mb_y - s->resync_mb_y)*s->mb_width - s->resync_mb_x;
pdif = put_bits_ptr(&s->pb) - s->ptr_lastgob;
/* Call the RTP callback to send the last GOB */
emms_c();
s->avctx->rtp_callback(s->avctx, s->ptr_lastgob, pdif, number_mb);
}
return 0;
}
| false | FFmpeg | 0bd485300e1a8bb0ba95df53da34562816120e31 | static int encode_thread(AVCodecContext *c, void *arg){
MpegEncContext *s= *(void**)arg;
int mb_x, mb_y, pdif = 0;
int chr_h= 16>>s->chroma_y_shift;
int i, j;
MpegEncContext best_s, backup_s;
uint8_t bit_buf[2][MAX_MB_BYTES];
uint8_t bit_buf2[2][MAX_MB_BYTES];
uint8_t bit_buf_tex[2][MAX_MB_BYTES];
PutBitContext pb[2], pb2[2], tex_pb[2];
ff_check_alignment();
for(i=0; i<2; i++){
init_put_bits(&pb [i], bit_buf [i], MAX_MB_BYTES);
init_put_bits(&pb2 [i], bit_buf2 [i], MAX_MB_BYTES);
init_put_bits(&tex_pb[i], bit_buf_tex[i], MAX_MB_BYTES);
}
s->last_bits= put_bits_count(&s->pb);
s->mv_bits=0;
s->misc_bits=0;
s->i_tex_bits=0;
s->p_tex_bits=0;
s->i_count=0;
s->f_count=0;
s->b_count=0;
s->skip_count=0;
for(i=0; i<3; i++){
s->last_dc[i] = 128 << s->intra_dc_precision;
s->current_picture.error[i] = 0;
}
s->mb_skip_run = 0;
memset(s->last_mv, 0, sizeof(s->last_mv));
s->last_mv_dir = 0;
switch(s->codec_id){
case CODEC_ID_H263:
case CODEC_ID_H263P:
case CODEC_ID_FLV1:
if (CONFIG_H263_ENCODER || CONFIG_FLV_ENCODER)
s->gob_index = ff_h263_get_gob_height(s);
break;
case CODEC_ID_MPEG4:
if(CONFIG_MPEG4_ENCODER && s->partitioned_frame)
ff_mpeg4_init_partitions(s);
break;
}
s->resync_mb_x=0;
s->resync_mb_y=0;
s->first_slice_line = 1;
s->ptr_lastgob = s->pb.buf;
for(mb_y= s->start_mb_y; mb_y < s->end_mb_y; mb_y++) {
s->mb_x=0;
s->mb_y= mb_y;
ff_set_qscale(s, s->qscale);
ff_init_block_index(s);
for(mb_x=0; mb_x < s->mb_width; mb_x++) {
int xy= mb_y*s->mb_stride + mb_x;
int mb_type= s->mb_type[xy];
int dmin= INT_MAX;
int dir;
if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < MAX_MB_BYTES){
av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
return -1;
}
if(s->data_partitioning){
if( s->pb2 .buf_end - s->pb2 .buf - (put_bits_count(&s-> pb2)>>3) < MAX_MB_BYTES
|| s->tex_pb.buf_end - s->tex_pb.buf - (put_bits_count(&s->tex_pb )>>3) < MAX_MB_BYTES){
av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
return -1;
}
}
s->mb_x = mb_x;
s->mb_y = mb_y;
ff_update_block_index(s);
if(CONFIG_H261_ENCODER && s->codec_id == CODEC_ID_H261){
ff_h261_reorder_mb_index(s);
xy= s->mb_y*s->mb_stride + s->mb_x;
mb_type= s->mb_type[xy];
}
if(s->rtp_mode){
int current_packet_size, is_gob_start;
current_packet_size= ((put_bits_count(&s->pb)+7)>>3) - (s->ptr_lastgob - s->pb.buf);
is_gob_start= s->avctx->rtp_payload_size && current_packet_size >= s->avctx->rtp_payload_size && mb_y + mb_x>0;
if(s->start_mb_y == mb_y && mb_y > 0 && mb_x==0) is_gob_start=1;
switch(s->codec_id){
case CODEC_ID_H263:
case CODEC_ID_H263P:
if(!s->h263_slice_structured)
if(s->mb_x || s->mb_y%s->gob_index) is_gob_start=0;
break;
case CODEC_ID_MPEG2VIDEO:
if(s->mb_x==0 && s->mb_y!=0) is_gob_start=1;
case CODEC_ID_MPEG1VIDEO:
if(s->mb_skip_run) is_gob_start=0;
break;
}
if(is_gob_start){
if(s->start_mb_y != mb_y || mb_x!=0){
write_slice_end(s);
if(CONFIG_MPEG4_ENCODER && s->codec_id==CODEC_ID_MPEG4 && s->partitioned_frame){
ff_mpeg4_init_partitions(s);
}
}
assert((put_bits_count(&s->pb)&7) == 0);
current_packet_size= put_bits_ptr(&s->pb) - s->ptr_lastgob;
if(s->avctx->error_rate && s->resync_mb_x + s->resync_mb_y > 0){
int r= put_bits_count(&s->pb)/8 + s->picture_number + 16 + s->mb_x + s->mb_y;
int d= 100 / s->avctx->error_rate;
if(r % d == 0){
current_packet_size=0;
#ifndef ALT_BITSTREAM_WRITER
s->pb.buf_ptr= s->ptr_lastgob;
#endif
assert(put_bits_ptr(&s->pb) == s->ptr_lastgob);
}
}
if (s->avctx->rtp_callback){
int number_mb = (mb_y - s->resync_mb_y)*s->mb_width + mb_x - s->resync_mb_x;
s->avctx->rtp_callback(s->avctx, s->ptr_lastgob, current_packet_size, number_mb);
}
switch(s->codec_id){
case CODEC_ID_MPEG4:
if (CONFIG_MPEG4_ENCODER) {
ff_mpeg4_encode_video_packet_header(s);
ff_mpeg4_clean_buffers(s);
}
break;
case CODEC_ID_MPEG1VIDEO:
case CODEC_ID_MPEG2VIDEO:
if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER) {
ff_mpeg1_encode_slice_header(s);
ff_mpeg1_clean_buffers(s);
}
break;
case CODEC_ID_H263:
case CODEC_ID_H263P:
if (CONFIG_H263_ENCODER)
h263_encode_gob_header(s, mb_y);
break;
}
if(s->flags&CODEC_FLAG_PASS1){
int bits= put_bits_count(&s->pb);
s->misc_bits+= bits - s->last_bits;
s->last_bits= bits;
}
s->ptr_lastgob += current_packet_size;
s->first_slice_line=1;
s->resync_mb_x=mb_x;
s->resync_mb_y=mb_y;
}
}
if( (s->resync_mb_x == s->mb_x)
&& s->resync_mb_y+1 == s->mb_y){
s->first_slice_line=0;
}
s->mb_skipped=0;
s->dquant=0;
if(mb_type & (mb_type-1) || (s->flags & CODEC_FLAG_QP_RD)){
int next_block=0;
int pb_bits_count, pb2_bits_count, tex_pb_bits_count;
copy_context_before_encode(&backup_s, s, -1);
backup_s.pb= s->pb;
best_s.data_partitioning= s->data_partitioning;
best_s.partitioned_frame= s->partitioned_frame;
if(s->data_partitioning){
backup_s.pb2= s->pb2;
backup_s.tex_pb= s->tex_pb;
}
if(mb_type&CANDIDATE_MB_TYPE_INTER){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = s->p_mv_table[xy][0];
s->mv[0][0][1] = s->p_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
}
if(mb_type&CANDIDATE_MB_TYPE_INTER_I){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(i=0; i<2; i++){
j= s->field_select[0][i] = s->p_field_select_table[i][xy];
s->mv[0][i][0] = s->p_field_mv_table[i][j][xy][0];
s->mv[0][i][1] = s->p_field_mv_table[i][j][xy][1];
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER_I, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_SKIPPED){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_SKIPPED, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
}
if(mb_type&CANDIDATE_MB_TYPE_INTER4V){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_8X8;
s->mb_intra= 0;
for(i=0; i<4; i++){
s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0];
s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1];
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER4V, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_FORWARD){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = s->b_forw_mv_table[xy][0];
s->mv[0][0][1] = s->b_forw_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_FORWARD, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
}
if(mb_type&CANDIDATE_MB_TYPE_BACKWARD){
s->mv_dir = MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[1][0][0] = s->b_back_mv_table[xy][0];
s->mv[1][0][1] = s->b_back_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BACKWARD, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[1][0][0], s->mv[1][0][1]);
}
if(mb_type&CANDIDATE_MB_TYPE_BIDIR){
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = s->b_bidir_forw_mv_table[xy][0];
s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1];
s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0];
s->mv[1][0][1] = s->b_bidir_back_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BIDIR, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_FORWARD_I){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(i=0; i<2; i++){
j= s->field_select[0][i] = s->b_field_select_table[0][i][xy];
s->mv[0][i][0] = s->b_field_mv_table[0][i][j][xy][0];
s->mv[0][i][1] = s->b_field_mv_table[0][i][j][xy][1];
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_FORWARD_I, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_BACKWARD_I){
s->mv_dir = MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(i=0; i<2; i++){
j= s->field_select[1][i] = s->b_field_select_table[1][i][xy];
s->mv[1][i][0] = s->b_field_mv_table[1][i][j][xy][0];
s->mv[1][i][1] = s->b_field_mv_table[1][i][j][xy][1];
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BACKWARD_I, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_BIDIR_I){
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(dir=0; dir<2; dir++){
for(i=0; i<2; i++){
j= s->field_select[dir][i] = s->b_field_select_table[dir][i][xy];
s->mv[dir][i][0] = s->b_field_mv_table[dir][i][j][xy][0];
s->mv[dir][i][1] = s->b_field_mv_table[dir][i][j][xy][1];
}
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BIDIR_I, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_INTRA){
s->mv_dir = 0;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 1;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTRA, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
if(s->h263_pred || s->h263_aic){
if(best_s.mb_intra)
s->mbintra_table[mb_x + mb_y*s->mb_stride]=1;
else
ff_clean_intra_table_entries(s);
}
}
if((s->flags & CODEC_FLAG_QP_RD) && dmin < INT_MAX){
if(best_s.mv_type==MV_TYPE_16X16){
const int last_qp= backup_s.qscale;
int qpi, qp, dc[6];
DCTELEM ac[6][16];
const int mvdir= (best_s.mv_dir&MV_DIR_BACKWARD) ? 1 : 0;
static const int dquant_tab[4]={-1,1,-2,2};
assert(backup_s.dquant == 0);
s->mv_dir= best_s.mv_dir;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= best_s.mb_intra;
s->mv[0][0][0] = best_s.mv[0][0][0];
s->mv[0][0][1] = best_s.mv[0][0][1];
s->mv[1][0][0] = best_s.mv[1][0][0];
s->mv[1][0][1] = best_s.mv[1][0][1];
qpi = s->pict_type == FF_B_TYPE ? 2 : 0;
for(; qpi<4; qpi++){
int dquant= dquant_tab[qpi];
qp= last_qp + dquant;
if(qp < s->avctx->qmin || qp > s->avctx->qmax)
continue;
backup_s.dquant= dquant;
if(s->mb_intra && s->dc_val[0]){
for(i=0; i<6; i++){
dc[i]= s->dc_val[0][ s->block_index[i] ];
memcpy(ac[i], s->ac_val[0][s->block_index[i]], sizeof(DCTELEM)*16);
}
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER , pb, pb2, tex_pb,
&dmin, &next_block, s->mv[mvdir][0][0], s->mv[mvdir][0][1]);
if(best_s.qscale != qp){
if(s->mb_intra && s->dc_val[0]){
for(i=0; i<6; i++){
s->dc_val[0][ s->block_index[i] ]= dc[i];
memcpy(s->ac_val[0][s->block_index[i]], ac[i], sizeof(DCTELEM)*16);
}
}
}
}
}
}
if(CONFIG_MPEG4_ENCODER && mb_type&CANDIDATE_MB_TYPE_DIRECT){
int mx= s->b_direct_mv_table[xy][0];
int my= s->b_direct_mv_table[xy][1];
backup_s.dquant = 0;
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
s->mb_intra= 0;
ff_mpeg4_set_direct_mv(s, mx, my);
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb,
&dmin, &next_block, mx, my);
}
if(CONFIG_MPEG4_ENCODER && mb_type&CANDIDATE_MB_TYPE_DIRECT0){
backup_s.dquant = 0;
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
s->mb_intra= 0;
ff_mpeg4_set_direct_mv(s, 0, 0);
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(!best_s.mb_intra && s->flags2&CODEC_FLAG2_SKIP_RD){
int coded=0;
for(i=0; i<6; i++)
coded |= s->block_last_index[i];
if(coded){
int mx,my;
memcpy(s->mv, best_s.mv, sizeof(s->mv));
if(CONFIG_MPEG4_ENCODER && best_s.mv_dir & MV_DIRECT){
mx=my=0;
ff_mpeg4_set_direct_mv(s, mx, my);
}else if(best_s.mv_dir&MV_DIR_BACKWARD){
mx= s->mv[1][0][0];
my= s->mv[1][0][1];
}else{
mx= s->mv[0][0][0];
my= s->mv[0][0][1];
}
s->mv_dir= best_s.mv_dir;
s->mv_type = best_s.mv_type;
s->mb_intra= 0;
backup_s.dquant= 0;
s->skipdct=1;
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER , pb, pb2, tex_pb,
&dmin, &next_block, mx, my);
s->skipdct=0;
}
}
s->current_picture.qscale_table[xy]= best_s.qscale;
copy_context_after_encode(s, &best_s, -1);
pb_bits_count= put_bits_count(&s->pb);
flush_put_bits(&s->pb);
ff_copy_bits(&backup_s.pb, bit_buf[next_block^1], pb_bits_count);
s->pb= backup_s.pb;
if(s->data_partitioning){
pb2_bits_count= put_bits_count(&s->pb2);
flush_put_bits(&s->pb2);
ff_copy_bits(&backup_s.pb2, bit_buf2[next_block^1], pb2_bits_count);
s->pb2= backup_s.pb2;
tex_pb_bits_count= put_bits_count(&s->tex_pb);
flush_put_bits(&s->tex_pb);
ff_copy_bits(&backup_s.tex_pb, bit_buf_tex[next_block^1], tex_pb_bits_count);
s->tex_pb= backup_s.tex_pb;
}
s->last_bits= put_bits_count(&s->pb);
if (CONFIG_ANY_H263_ENCODER &&
s->out_format == FMT_H263 && s->pict_type!=FF_B_TYPE)
ff_h263_update_motion_val(s);
if(next_block==0){
s->dsp.put_pixels_tab[0][0](s->dest[0], s->rd_scratchpad , s->linesize ,16);
s->dsp.put_pixels_tab[1][0](s->dest[1], s->rd_scratchpad + 16*s->linesize , s->uvlinesize, 8);
s->dsp.put_pixels_tab[1][0](s->dest[2], s->rd_scratchpad + 16*s->linesize + 8, s->uvlinesize, 8);
}
if(s->avctx->mb_decision == FF_MB_DECISION_BITS)
MPV_decode_mb(s, s->block);
} else {
int motion_x = 0, motion_y = 0;
s->mv_type=MV_TYPE_16X16;
switch(mb_type){
case CANDIDATE_MB_TYPE_INTRA:
s->mv_dir = 0;
s->mb_intra= 1;
motion_x= s->mv[0][0][0] = 0;
motion_y= s->mv[0][0][1] = 0;
break;
case CANDIDATE_MB_TYPE_INTER:
s->mv_dir = MV_DIR_FORWARD;
s->mb_intra= 0;
motion_x= s->mv[0][0][0] = s->p_mv_table[xy][0];
motion_y= s->mv[0][0][1] = s->p_mv_table[xy][1];
break;
case CANDIDATE_MB_TYPE_INTER_I:
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(i=0; i<2; i++){
j= s->field_select[0][i] = s->p_field_select_table[i][xy];
s->mv[0][i][0] = s->p_field_mv_table[i][j][xy][0];
s->mv[0][i][1] = s->p_field_mv_table[i][j][xy][1];
}
break;
case CANDIDATE_MB_TYPE_INTER4V:
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_8X8;
s->mb_intra= 0;
for(i=0; i<4; i++){
s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0];
s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1];
}
break;
case CANDIDATE_MB_TYPE_DIRECT:
if (CONFIG_MPEG4_ENCODER) {
s->mv_dir = MV_DIR_FORWARD|MV_DIR_BACKWARD|MV_DIRECT;
s->mb_intra= 0;
motion_x=s->b_direct_mv_table[xy][0];
motion_y=s->b_direct_mv_table[xy][1];
ff_mpeg4_set_direct_mv(s, motion_x, motion_y);
}
break;
case CANDIDATE_MB_TYPE_DIRECT0:
if (CONFIG_MPEG4_ENCODER) {
s->mv_dir = MV_DIR_FORWARD|MV_DIR_BACKWARD|MV_DIRECT;
s->mb_intra= 0;
ff_mpeg4_set_direct_mv(s, 0, 0);
}
break;
case CANDIDATE_MB_TYPE_BIDIR:
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mb_intra= 0;
s->mv[0][0][0] = s->b_bidir_forw_mv_table[xy][0];
s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1];
s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0];
s->mv[1][0][1] = s->b_bidir_back_mv_table[xy][1];
break;
case CANDIDATE_MB_TYPE_BACKWARD:
s->mv_dir = MV_DIR_BACKWARD;
s->mb_intra= 0;
motion_x= s->mv[1][0][0] = s->b_back_mv_table[xy][0];
motion_y= s->mv[1][0][1] = s->b_back_mv_table[xy][1];
break;
case CANDIDATE_MB_TYPE_FORWARD:
s->mv_dir = MV_DIR_FORWARD;
s->mb_intra= 0;
motion_x= s->mv[0][0][0] = s->b_forw_mv_table[xy][0];
motion_y= s->mv[0][0][1] = s->b_forw_mv_table[xy][1];
break;
case CANDIDATE_MB_TYPE_FORWARD_I:
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(i=0; i<2; i++){
j= s->field_select[0][i] = s->b_field_select_table[0][i][xy];
s->mv[0][i][0] = s->b_field_mv_table[0][i][j][xy][0];
s->mv[0][i][1] = s->b_field_mv_table[0][i][j][xy][1];
}
break;
case CANDIDATE_MB_TYPE_BACKWARD_I:
s->mv_dir = MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(i=0; i<2; i++){
j= s->field_select[1][i] = s->b_field_select_table[1][i][xy];
s->mv[1][i][0] = s->b_field_mv_table[1][i][j][xy][0];
s->mv[1][i][1] = s->b_field_mv_table[1][i][j][xy][1];
}
break;
case CANDIDATE_MB_TYPE_BIDIR_I:
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(dir=0; dir<2; dir++){
for(i=0; i<2; i++){
j= s->field_select[dir][i] = s->b_field_select_table[dir][i][xy];
s->mv[dir][i][0] = s->b_field_mv_table[dir][i][j][xy][0];
s->mv[dir][i][1] = s->b_field_mv_table[dir][i][j][xy][1];
}
}
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "illegal MB type\n");
}
encode_mb(s, motion_x, motion_y);
s->last_mv_dir = s->mv_dir;
if (CONFIG_ANY_H263_ENCODER &&
s->out_format == FMT_H263 && s->pict_type!=FF_B_TYPE)
ff_h263_update_motion_val(s);
MPV_decode_mb(s, s->block);
}
if(s->mb_intra ){
s->p_mv_table[xy][0]=0;
s->p_mv_table[xy][1]=0;
}
if(s->flags&CODEC_FLAG_PSNR){
int w= 16;
int h= 16;
if(s->mb_x*16 + 16 > s->width ) w= s->width - s->mb_x*16;
if(s->mb_y*16 + 16 > s->height) h= s->height- s->mb_y*16;
s->current_picture.error[0] += sse(
s, s->new_picture.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16,
s->dest[0], w, h, s->linesize);
s->current_picture.error[1] += sse(
s, s->new_picture.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*chr_h,
s->dest[1], w>>1, h>>s->chroma_y_shift, s->uvlinesize);
s->current_picture.error[2] += sse(
s, s->new_picture.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*chr_h,
s->dest[2], w>>1, h>>s->chroma_y_shift, s->uvlinesize);
}
if(s->loop_filter){
if(CONFIG_ANY_H263_ENCODER && s->out_format == FMT_H263)
ff_h263_loop_filter(s);
}
}
}
if (CONFIG_MSMPEG4_ENCODER && s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type == FF_I_TYPE)
msmpeg4_encode_ext_header(s);
write_slice_end(s);
if (s->avctx->rtp_callback) {
int number_mb = (mb_y - s->resync_mb_y)*s->mb_width - s->resync_mb_x;
pdif = put_bits_ptr(&s->pb) - s->ptr_lastgob;
emms_c();
s->avctx->rtp_callback(s->avctx, s->ptr_lastgob, pdif, number_mb);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1){
MpegEncContext *s= *(void**)VAR_1;
int VAR_2, VAR_3, VAR_4 = 0;
int VAR_5= 16>>s->chroma_y_shift;
int VAR_6, VAR_7;
MpegEncContext best_s, backup_s;
uint8_t bit_buf[2][MAX_MB_BYTES];
uint8_t bit_buf2[2][MAX_MB_BYTES];
uint8_t bit_buf_tex[2][MAX_MB_BYTES];
PutBitContext pb[2], pb2[2], tex_pb[2];
ff_check_alignment();
for(VAR_6=0; VAR_6<2; VAR_6++){
init_put_bits(&pb [VAR_6], bit_buf [VAR_6], MAX_MB_BYTES);
init_put_bits(&pb2 [VAR_6], bit_buf2 [VAR_6], MAX_MB_BYTES);
init_put_bits(&tex_pb[VAR_6], bit_buf_tex[VAR_6], MAX_MB_BYTES);
}
s->last_bits= put_bits_count(&s->pb);
s->mv_bits=0;
s->misc_bits=0;
s->i_tex_bits=0;
s->p_tex_bits=0;
s->i_count=0;
s->f_count=0;
s->b_count=0;
s->skip_count=0;
for(VAR_6=0; VAR_6<3; VAR_6++){
s->last_dc[VAR_6] = 128 << s->intra_dc_precision;
s->current_picture.error[VAR_6] = 0;
}
s->mb_skip_run = 0;
memset(s->last_mv, 0, sizeof(s->last_mv));
s->last_mv_dir = 0;
switch(s->codec_id){
case CODEC_ID_H263:
case CODEC_ID_H263P:
case CODEC_ID_FLV1:
if (CONFIG_H263_ENCODER || CONFIG_FLV_ENCODER)
s->gob_index = ff_h263_get_gob_height(s);
break;
case CODEC_ID_MPEG4:
if(CONFIG_MPEG4_ENCODER && s->partitioned_frame)
ff_mpeg4_init_partitions(s);
break;
}
s->resync_mb_x=0;
s->resync_mb_y=0;
s->first_slice_line = 1;
s->ptr_lastgob = s->pb.buf;
for(VAR_3= s->start_mb_y; VAR_3 < s->end_mb_y; VAR_3++) {
s->VAR_2=0;
s->VAR_3= VAR_3;
ff_set_qscale(s, s->qscale);
ff_init_block_index(s);
for(VAR_2=0; VAR_2 < s->mb_width; VAR_2++) {
int xy= VAR_3*s->mb_stride + VAR_2;
int mb_type= s->mb_type[xy];
int dmin= INT_MAX;
int dir;
if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < MAX_MB_BYTES){
av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
return -1;
}
if(s->data_partitioning){
if( s->pb2 .buf_end - s->pb2 .buf - (put_bits_count(&s-> pb2)>>3) < MAX_MB_BYTES
|| s->tex_pb.buf_end - s->tex_pb.buf - (put_bits_count(&s->tex_pb )>>3) < MAX_MB_BYTES){
av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
return -1;
}
}
s->VAR_2 = VAR_2;
s->VAR_3 = VAR_3;
ff_update_block_index(s);
if(CONFIG_H261_ENCODER && s->codec_id == CODEC_ID_H261){
ff_h261_reorder_mb_index(s);
xy= s->VAR_3*s->mb_stride + s->VAR_2;
mb_type= s->mb_type[xy];
}
if(s->rtp_mode){
int current_packet_size, is_gob_start;
current_packet_size= ((put_bits_count(&s->pb)+7)>>3) - (s->ptr_lastgob - s->pb.buf);
is_gob_start= s->avctx->rtp_payload_size && current_packet_size >= s->avctx->rtp_payload_size && VAR_3 + VAR_2>0;
if(s->start_mb_y == VAR_3 && VAR_3 > 0 && VAR_2==0) is_gob_start=1;
switch(s->codec_id){
case CODEC_ID_H263:
case CODEC_ID_H263P:
if(!s->h263_slice_structured)
if(s->VAR_2 || s->VAR_3%s->gob_index) is_gob_start=0;
break;
case CODEC_ID_MPEG2VIDEO:
if(s->VAR_2==0 && s->VAR_3!=0) is_gob_start=1;
case CODEC_ID_MPEG1VIDEO:
if(s->mb_skip_run) is_gob_start=0;
break;
}
if(is_gob_start){
if(s->start_mb_y != VAR_3 || VAR_2!=0){
write_slice_end(s);
if(CONFIG_MPEG4_ENCODER && s->codec_id==CODEC_ID_MPEG4 && s->partitioned_frame){
ff_mpeg4_init_partitions(s);
}
}
assert((put_bits_count(&s->pb)&7) == 0);
current_packet_size= put_bits_ptr(&s->pb) - s->ptr_lastgob;
if(s->avctx->error_rate && s->resync_mb_x + s->resync_mb_y > 0){
int r= put_bits_count(&s->pb)/8 + s->picture_number + 16 + s->VAR_2 + s->VAR_3;
int d= 100 / s->avctx->error_rate;
if(r % d == 0){
current_packet_size=0;
#ifndef ALT_BITSTREAM_WRITER
s->pb.buf_ptr= s->ptr_lastgob;
#endif
assert(put_bits_ptr(&s->pb) == s->ptr_lastgob);
}
}
if (s->avctx->rtp_callback){
int VAR_8 = (VAR_3 - s->resync_mb_y)*s->mb_width + VAR_2 - s->resync_mb_x;
s->avctx->rtp_callback(s->avctx, s->ptr_lastgob, current_packet_size, VAR_8);
}
switch(s->codec_id){
case CODEC_ID_MPEG4:
if (CONFIG_MPEG4_ENCODER) {
ff_mpeg4_encode_video_packet_header(s);
ff_mpeg4_clean_buffers(s);
}
break;
case CODEC_ID_MPEG1VIDEO:
case CODEC_ID_MPEG2VIDEO:
if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER) {
ff_mpeg1_encode_slice_header(s);
ff_mpeg1_clean_buffers(s);
}
break;
case CODEC_ID_H263:
case CODEC_ID_H263P:
if (CONFIG_H263_ENCODER)
h263_encode_gob_header(s, VAR_3);
break;
}
if(s->flags&CODEC_FLAG_PASS1){
int bits= put_bits_count(&s->pb);
s->misc_bits+= bits - s->last_bits;
s->last_bits= bits;
}
s->ptr_lastgob += current_packet_size;
s->first_slice_line=1;
s->resync_mb_x=VAR_2;
s->resync_mb_y=VAR_3;
}
}
if( (s->resync_mb_x == s->VAR_2)
&& s->resync_mb_y+1 == s->VAR_3){
s->first_slice_line=0;
}
s->mb_skipped=0;
s->dquant=0;
if(mb_type & (mb_type-1) || (s->flags & CODEC_FLAG_QP_RD)){
int next_block=0;
int pb_bits_count, pb2_bits_count, tex_pb_bits_count;
copy_context_before_encode(&backup_s, s, -1);
backup_s.pb= s->pb;
best_s.data_partitioning= s->data_partitioning;
best_s.partitioned_frame= s->partitioned_frame;
if(s->data_partitioning){
backup_s.pb2= s->pb2;
backup_s.tex_pb= s->tex_pb;
}
if(mb_type&CANDIDATE_MB_TYPE_INTER){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = s->p_mv_table[xy][0];
s->mv[0][0][1] = s->p_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
}
if(mb_type&CANDIDATE_MB_TYPE_INTER_I){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(VAR_6=0; VAR_6<2; VAR_6++){
VAR_7= s->field_select[0][VAR_6] = s->p_field_select_table[VAR_6][xy];
s->mv[0][VAR_6][0] = s->p_field_mv_table[VAR_6][VAR_7][xy][0];
s->mv[0][VAR_6][1] = s->p_field_mv_table[VAR_6][VAR_7][xy][1];
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER_I, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_SKIPPED){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_SKIPPED, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
}
if(mb_type&CANDIDATE_MB_TYPE_INTER4V){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_8X8;
s->mb_intra= 0;
for(VAR_6=0; VAR_6<4; VAR_6++){
s->mv[0][VAR_6][0] = s->current_picture.motion_val[0][s->block_index[VAR_6]][0];
s->mv[0][VAR_6][1] = s->current_picture.motion_val[0][s->block_index[VAR_6]][1];
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER4V, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_FORWARD){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = s->b_forw_mv_table[xy][0];
s->mv[0][0][1] = s->b_forw_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_FORWARD, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
}
if(mb_type&CANDIDATE_MB_TYPE_BACKWARD){
s->mv_dir = MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[1][0][0] = s->b_back_mv_table[xy][0];
s->mv[1][0][1] = s->b_back_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BACKWARD, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[1][0][0], s->mv[1][0][1]);
}
if(mb_type&CANDIDATE_MB_TYPE_BIDIR){
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = s->b_bidir_forw_mv_table[xy][0];
s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1];
s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0];
s->mv[1][0][1] = s->b_bidir_back_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BIDIR, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_FORWARD_I){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(VAR_6=0; VAR_6<2; VAR_6++){
VAR_7= s->field_select[0][VAR_6] = s->b_field_select_table[0][VAR_6][xy];
s->mv[0][VAR_6][0] = s->b_field_mv_table[0][VAR_6][VAR_7][xy][0];
s->mv[0][VAR_6][1] = s->b_field_mv_table[0][VAR_6][VAR_7][xy][1];
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_FORWARD_I, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_BACKWARD_I){
s->mv_dir = MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(VAR_6=0; VAR_6<2; VAR_6++){
VAR_7= s->field_select[1][VAR_6] = s->b_field_select_table[1][VAR_6][xy];
s->mv[1][VAR_6][0] = s->b_field_mv_table[1][VAR_6][VAR_7][xy][0];
s->mv[1][VAR_6][1] = s->b_field_mv_table[1][VAR_6][VAR_7][xy][1];
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BACKWARD_I, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_BIDIR_I){
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(dir=0; dir<2; dir++){
for(VAR_6=0; VAR_6<2; VAR_6++){
VAR_7= s->field_select[dir][VAR_6] = s->b_field_select_table[dir][VAR_6][xy];
s->mv[dir][VAR_6][0] = s->b_field_mv_table[dir][VAR_6][VAR_7][xy][0];
s->mv[dir][VAR_6][1] = s->b_field_mv_table[dir][VAR_6][VAR_7][xy][1];
}
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BIDIR_I, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_INTRA){
s->mv_dir = 0;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 1;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTRA, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
if(s->h263_pred || s->h263_aic){
if(best_s.mb_intra)
s->mbintra_table[VAR_2 + VAR_3*s->mb_stride]=1;
else
ff_clean_intra_table_entries(s);
}
}
if((s->flags & CODEC_FLAG_QP_RD) && dmin < INT_MAX){
if(best_s.mv_type==MV_TYPE_16X16){
const int last_qp= backup_s.qscale;
int qpi, qp, dc[6];
DCTELEM ac[6][16];
const int mvdir= (best_s.mv_dir&MV_DIR_BACKWARD) ? 1 : 0;
static const int dquant_tab[4]={-1,1,-2,2};
assert(backup_s.dquant == 0);
s->mv_dir= best_s.mv_dir;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= best_s.mb_intra;
s->mv[0][0][0] = best_s.mv[0][0][0];
s->mv[0][0][1] = best_s.mv[0][0][1];
s->mv[1][0][0] = best_s.mv[1][0][0];
s->mv[1][0][1] = best_s.mv[1][0][1];
qpi = s->pict_type == FF_B_TYPE ? 2 : 0;
for(; qpi<4; qpi++){
int dquant= dquant_tab[qpi];
qp= last_qp + dquant;
if(qp < s->avctx->qmin || qp > s->avctx->qmax)
continue;
backup_s.dquant= dquant;
if(s->mb_intra && s->dc_val[0]){
for(VAR_6=0; VAR_6<6; VAR_6++){
dc[VAR_6]= s->dc_val[0][ s->block_index[VAR_6] ];
memcpy(ac[VAR_6], s->ac_val[0][s->block_index[VAR_6]], sizeof(DCTELEM)*16);
}
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER , pb, pb2, tex_pb,
&dmin, &next_block, s->mv[mvdir][0][0], s->mv[mvdir][0][1]);
if(best_s.qscale != qp){
if(s->mb_intra && s->dc_val[0]){
for(VAR_6=0; VAR_6<6; VAR_6++){
s->dc_val[0][ s->block_index[VAR_6] ]= dc[VAR_6];
memcpy(s->ac_val[0][s->block_index[VAR_6]], ac[VAR_6], sizeof(DCTELEM)*16);
}
}
}
}
}
}
if(CONFIG_MPEG4_ENCODER && mb_type&CANDIDATE_MB_TYPE_DIRECT){
int mx= s->b_direct_mv_table[xy][0];
int my= s->b_direct_mv_table[xy][1];
backup_s.dquant = 0;
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
s->mb_intra= 0;
ff_mpeg4_set_direct_mv(s, mx, my);
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb,
&dmin, &next_block, mx, my);
}
if(CONFIG_MPEG4_ENCODER && mb_type&CANDIDATE_MB_TYPE_DIRECT0){
backup_s.dquant = 0;
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
s->mb_intra= 0;
ff_mpeg4_set_direct_mv(s, 0, 0);
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(!best_s.mb_intra && s->flags2&CODEC_FLAG2_SKIP_RD){
int coded=0;
for(VAR_6=0; VAR_6<6; VAR_6++)
coded |= s->block_last_index[VAR_6];
if(coded){
int mx,my;
memcpy(s->mv, best_s.mv, sizeof(s->mv));
if(CONFIG_MPEG4_ENCODER && best_s.mv_dir & MV_DIRECT){
mx=my=0;
ff_mpeg4_set_direct_mv(s, mx, my);
}else if(best_s.mv_dir&MV_DIR_BACKWARD){
mx= s->mv[1][0][0];
my= s->mv[1][0][1];
}else{
mx= s->mv[0][0][0];
my= s->mv[0][0][1];
}
s->mv_dir= best_s.mv_dir;
s->mv_type = best_s.mv_type;
s->mb_intra= 0;
backup_s.dquant= 0;
s->skipdct=1;
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER , pb, pb2, tex_pb,
&dmin, &next_block, mx, my);
s->skipdct=0;
}
}
s->current_picture.qscale_table[xy]= best_s.qscale;
copy_context_after_encode(s, &best_s, -1);
pb_bits_count= put_bits_count(&s->pb);
flush_put_bits(&s->pb);
ff_copy_bits(&backup_s.pb, bit_buf[next_block^1], pb_bits_count);
s->pb= backup_s.pb;
if(s->data_partitioning){
pb2_bits_count= put_bits_count(&s->pb2);
flush_put_bits(&s->pb2);
ff_copy_bits(&backup_s.pb2, bit_buf2[next_block^1], pb2_bits_count);
s->pb2= backup_s.pb2;
tex_pb_bits_count= put_bits_count(&s->tex_pb);
flush_put_bits(&s->tex_pb);
ff_copy_bits(&backup_s.tex_pb, bit_buf_tex[next_block^1], tex_pb_bits_count);
s->tex_pb= backup_s.tex_pb;
}
s->last_bits= put_bits_count(&s->pb);
if (CONFIG_ANY_H263_ENCODER &&
s->out_format == FMT_H263 && s->pict_type!=FF_B_TYPE)
ff_h263_update_motion_val(s);
if(next_block==0){
s->dsp.put_pixels_tab[0][0](s->dest[0], s->rd_scratchpad , s->linesize ,16);
s->dsp.put_pixels_tab[1][0](s->dest[1], s->rd_scratchpad + 16*s->linesize , s->uvlinesize, 8);
s->dsp.put_pixels_tab[1][0](s->dest[2], s->rd_scratchpad + 16*s->linesize + 8, s->uvlinesize, 8);
}
if(s->avctx->mb_decision == FF_MB_DECISION_BITS)
MPV_decode_mb(s, s->block);
} else {
int motion_x = 0, motion_y = 0;
s->mv_type=MV_TYPE_16X16;
switch(mb_type){
case CANDIDATE_MB_TYPE_INTRA:
s->mv_dir = 0;
s->mb_intra= 1;
motion_x= s->mv[0][0][0] = 0;
motion_y= s->mv[0][0][1] = 0;
break;
case CANDIDATE_MB_TYPE_INTER:
s->mv_dir = MV_DIR_FORWARD;
s->mb_intra= 0;
motion_x= s->mv[0][0][0] = s->p_mv_table[xy][0];
motion_y= s->mv[0][0][1] = s->p_mv_table[xy][1];
break;
case CANDIDATE_MB_TYPE_INTER_I:
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(VAR_6=0; VAR_6<2; VAR_6++){
VAR_7= s->field_select[0][VAR_6] = s->p_field_select_table[VAR_6][xy];
s->mv[0][VAR_6][0] = s->p_field_mv_table[VAR_6][VAR_7][xy][0];
s->mv[0][VAR_6][1] = s->p_field_mv_table[VAR_6][VAR_7][xy][1];
}
break;
case CANDIDATE_MB_TYPE_INTER4V:
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_8X8;
s->mb_intra= 0;
for(VAR_6=0; VAR_6<4; VAR_6++){
s->mv[0][VAR_6][0] = s->current_picture.motion_val[0][s->block_index[VAR_6]][0];
s->mv[0][VAR_6][1] = s->current_picture.motion_val[0][s->block_index[VAR_6]][1];
}
break;
case CANDIDATE_MB_TYPE_DIRECT:
if (CONFIG_MPEG4_ENCODER) {
s->mv_dir = MV_DIR_FORWARD|MV_DIR_BACKWARD|MV_DIRECT;
s->mb_intra= 0;
motion_x=s->b_direct_mv_table[xy][0];
motion_y=s->b_direct_mv_table[xy][1];
ff_mpeg4_set_direct_mv(s, motion_x, motion_y);
}
break;
case CANDIDATE_MB_TYPE_DIRECT0:
if (CONFIG_MPEG4_ENCODER) {
s->mv_dir = MV_DIR_FORWARD|MV_DIR_BACKWARD|MV_DIRECT;
s->mb_intra= 0;
ff_mpeg4_set_direct_mv(s, 0, 0);
}
break;
case CANDIDATE_MB_TYPE_BIDIR:
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mb_intra= 0;
s->mv[0][0][0] = s->b_bidir_forw_mv_table[xy][0];
s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1];
s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0];
s->mv[1][0][1] = s->b_bidir_back_mv_table[xy][1];
break;
case CANDIDATE_MB_TYPE_BACKWARD:
s->mv_dir = MV_DIR_BACKWARD;
s->mb_intra= 0;
motion_x= s->mv[1][0][0] = s->b_back_mv_table[xy][0];
motion_y= s->mv[1][0][1] = s->b_back_mv_table[xy][1];
break;
case CANDIDATE_MB_TYPE_FORWARD:
s->mv_dir = MV_DIR_FORWARD;
s->mb_intra= 0;
motion_x= s->mv[0][0][0] = s->b_forw_mv_table[xy][0];
motion_y= s->mv[0][0][1] = s->b_forw_mv_table[xy][1];
break;
case CANDIDATE_MB_TYPE_FORWARD_I:
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(VAR_6=0; VAR_6<2; VAR_6++){
VAR_7= s->field_select[0][VAR_6] = s->b_field_select_table[0][VAR_6][xy];
s->mv[0][VAR_6][0] = s->b_field_mv_table[0][VAR_6][VAR_7][xy][0];
s->mv[0][VAR_6][1] = s->b_field_mv_table[0][VAR_6][VAR_7][xy][1];
}
break;
case CANDIDATE_MB_TYPE_BACKWARD_I:
s->mv_dir = MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(VAR_6=0; VAR_6<2; VAR_6++){
VAR_7= s->field_select[1][VAR_6] = s->b_field_select_table[1][VAR_6][xy];
s->mv[1][VAR_6][0] = s->b_field_mv_table[1][VAR_6][VAR_7][xy][0];
s->mv[1][VAR_6][1] = s->b_field_mv_table[1][VAR_6][VAR_7][xy][1];
}
break;
case CANDIDATE_MB_TYPE_BIDIR_I:
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(dir=0; dir<2; dir++){
for(VAR_6=0; VAR_6<2; VAR_6++){
VAR_7= s->field_select[dir][VAR_6] = s->b_field_select_table[dir][VAR_6][xy];
s->mv[dir][VAR_6][0] = s->b_field_mv_table[dir][VAR_6][VAR_7][xy][0];
s->mv[dir][VAR_6][1] = s->b_field_mv_table[dir][VAR_6][VAR_7][xy][1];
}
}
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "illegal MB type\n");
}
encode_mb(s, motion_x, motion_y);
s->last_mv_dir = s->mv_dir;
if (CONFIG_ANY_H263_ENCODER &&
s->out_format == FMT_H263 && s->pict_type!=FF_B_TYPE)
ff_h263_update_motion_val(s);
MPV_decode_mb(s, s->block);
}
if(s->mb_intra ){
s->p_mv_table[xy][0]=0;
s->p_mv_table[xy][1]=0;
}
if(s->flags&CODEC_FLAG_PSNR){
int w= 16;
int h= 16;
if(s->VAR_2*16 + 16 > s->width ) w= s->width - s->VAR_2*16;
if(s->VAR_3*16 + 16 > s->height) h= s->height- s->VAR_3*16;
s->current_picture.error[0] += sse(
s, s->new_picture.data[0] + s->VAR_2*16 + s->VAR_3*s->linesize*16,
s->dest[0], w, h, s->linesize);
s->current_picture.error[1] += sse(
s, s->new_picture.data[1] + s->VAR_2*8 + s->VAR_3*s->uvlinesize*VAR_5,
s->dest[1], w>>1, h>>s->chroma_y_shift, s->uvlinesize);
s->current_picture.error[2] += sse(
s, s->new_picture.data[2] + s->VAR_2*8 + s->VAR_3*s->uvlinesize*VAR_5,
s->dest[2], w>>1, h>>s->chroma_y_shift, s->uvlinesize);
}
if(s->loop_filter){
if(CONFIG_ANY_H263_ENCODER && s->out_format == FMT_H263)
ff_h263_loop_filter(s);
}
}
}
if (CONFIG_MSMPEG4_ENCODER && s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type == FF_I_TYPE)
msmpeg4_encode_ext_header(s);
write_slice_end(s);
if (s->avctx->rtp_callback) {
int VAR_8 = (VAR_3 - s->resync_mb_y)*s->mb_width - s->resync_mb_x;
VAR_4 = put_bits_ptr(&s->pb) - s->ptr_lastgob;
emms_c();
s->avctx->rtp_callback(s->avctx, s->ptr_lastgob, VAR_4, VAR_8);
}
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1){",
"MpegEncContext *s= *(void**)VAR_1;",
"int VAR_2, VAR_3, VAR_4 = 0;",
"int VAR_5= 16>>s->chroma_y_shift;",
"int VAR_6, VAR_7;",
"MpegEncContext best_s, backup_s;",
"uint8_t bit_buf[2][MAX_MB_BYTES];",
"uint8_t bit_buf2[2][MAX_MB_BYTES];",
"uint8_t bit_buf_tex[2][MAX_MB_BYTES];",
"PutBitContext pb[2], pb2[2], tex_pb[2];",
"ff_check_alignment();",
"for(VAR_6=0; VAR_6<2; VAR_6++){",
"init_put_bits(&pb [VAR_6], bit_buf [VAR_6], MAX_MB_BYTES);",
"init_put_bits(&pb2 [VAR_6], bit_buf2 [VAR_6], MAX_MB_BYTES);",
"init_put_bits(&tex_pb[VAR_6], bit_buf_tex[VAR_6], MAX_MB_BYTES);",
"}",
"s->last_bits= put_bits_count(&s->pb);",
"s->mv_bits=0;",
"s->misc_bits=0;",
"s->i_tex_bits=0;",
"s->p_tex_bits=0;",
"s->i_count=0;",
"s->f_count=0;",
"s->b_count=0;",
"s->skip_count=0;",
"for(VAR_6=0; VAR_6<3; VAR_6++){",
"s->last_dc[VAR_6] = 128 << s->intra_dc_precision;",
"s->current_picture.error[VAR_6] = 0;",
"}",
"s->mb_skip_run = 0;",
"memset(s->last_mv, 0, sizeof(s->last_mv));",
"s->last_mv_dir = 0;",
"switch(s->codec_id){",
"case CODEC_ID_H263:\ncase CODEC_ID_H263P:\ncase CODEC_ID_FLV1:\nif (CONFIG_H263_ENCODER || CONFIG_FLV_ENCODER)\ns->gob_index = ff_h263_get_gob_height(s);",
"break;",
"case CODEC_ID_MPEG4:\nif(CONFIG_MPEG4_ENCODER && s->partitioned_frame)\nff_mpeg4_init_partitions(s);",
"break;",
"}",
"s->resync_mb_x=0;",
"s->resync_mb_y=0;",
"s->first_slice_line = 1;",
"s->ptr_lastgob = s->pb.buf;",
"for(VAR_3= s->start_mb_y; VAR_3 < s->end_mb_y; VAR_3++) {",
"s->VAR_2=0;",
"s->VAR_3= VAR_3;",
"ff_set_qscale(s, s->qscale);",
"ff_init_block_index(s);",
"for(VAR_2=0; VAR_2 < s->mb_width; VAR_2++) {",
"int xy= VAR_3*s->mb_stride + VAR_2;",
"int mb_type= s->mb_type[xy];",
"int dmin= INT_MAX;",
"int dir;",
"if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < MAX_MB_BYTES){",
"av_log(s->avctx, AV_LOG_ERROR, \"encoded frame too large\\n\");",
"return -1;",
"}",
"if(s->data_partitioning){",
"if( s->pb2 .buf_end - s->pb2 .buf - (put_bits_count(&s-> pb2)>>3) < MAX_MB_BYTES\n|| s->tex_pb.buf_end - s->tex_pb.buf - (put_bits_count(&s->tex_pb )>>3) < MAX_MB_BYTES){",
"av_log(s->avctx, AV_LOG_ERROR, \"encoded frame too large\\n\");",
"return -1;",
"}",
"}",
"s->VAR_2 = VAR_2;",
"s->VAR_3 = VAR_3;",
"ff_update_block_index(s);",
"if(CONFIG_H261_ENCODER && s->codec_id == CODEC_ID_H261){",
"ff_h261_reorder_mb_index(s);",
"xy= s->VAR_3*s->mb_stride + s->VAR_2;",
"mb_type= s->mb_type[xy];",
"}",
"if(s->rtp_mode){",
"int current_packet_size, is_gob_start;",
"current_packet_size= ((put_bits_count(&s->pb)+7)>>3) - (s->ptr_lastgob - s->pb.buf);",
"is_gob_start= s->avctx->rtp_payload_size && current_packet_size >= s->avctx->rtp_payload_size && VAR_3 + VAR_2>0;",
"if(s->start_mb_y == VAR_3 && VAR_3 > 0 && VAR_2==0) is_gob_start=1;",
"switch(s->codec_id){",
"case CODEC_ID_H263:\ncase CODEC_ID_H263P:\nif(!s->h263_slice_structured)\nif(s->VAR_2 || s->VAR_3%s->gob_index) is_gob_start=0;",
"break;",
"case CODEC_ID_MPEG2VIDEO:\nif(s->VAR_2==0 && s->VAR_3!=0) is_gob_start=1;",
"case CODEC_ID_MPEG1VIDEO:\nif(s->mb_skip_run) is_gob_start=0;",
"break;",
"}",
"if(is_gob_start){",
"if(s->start_mb_y != VAR_3 || VAR_2!=0){",
"write_slice_end(s);",
"if(CONFIG_MPEG4_ENCODER && s->codec_id==CODEC_ID_MPEG4 && s->partitioned_frame){",
"ff_mpeg4_init_partitions(s);",
"}",
"}",
"assert((put_bits_count(&s->pb)&7) == 0);",
"current_packet_size= put_bits_ptr(&s->pb) - s->ptr_lastgob;",
"if(s->avctx->error_rate && s->resync_mb_x + s->resync_mb_y > 0){",
"int r= put_bits_count(&s->pb)/8 + s->picture_number + 16 + s->VAR_2 + s->VAR_3;",
"int d= 100 / s->avctx->error_rate;",
"if(r % d == 0){",
"current_packet_size=0;",
"#ifndef ALT_BITSTREAM_WRITER\ns->pb.buf_ptr= s->ptr_lastgob;",
"#endif\nassert(put_bits_ptr(&s->pb) == s->ptr_lastgob);",
"}",
"}",
"if (s->avctx->rtp_callback){",
"int VAR_8 = (VAR_3 - s->resync_mb_y)*s->mb_width + VAR_2 - s->resync_mb_x;",
"s->avctx->rtp_callback(s->avctx, s->ptr_lastgob, current_packet_size, VAR_8);",
"}",
"switch(s->codec_id){",
"case CODEC_ID_MPEG4:\nif (CONFIG_MPEG4_ENCODER) {",
"ff_mpeg4_encode_video_packet_header(s);",
"ff_mpeg4_clean_buffers(s);",
"}",
"break;",
"case CODEC_ID_MPEG1VIDEO:\ncase CODEC_ID_MPEG2VIDEO:\nif (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER) {",
"ff_mpeg1_encode_slice_header(s);",
"ff_mpeg1_clean_buffers(s);",
"}",
"break;",
"case CODEC_ID_H263:\ncase CODEC_ID_H263P:\nif (CONFIG_H263_ENCODER)\nh263_encode_gob_header(s, VAR_3);",
"break;",
"}",
"if(s->flags&CODEC_FLAG_PASS1){",
"int bits= put_bits_count(&s->pb);",
"s->misc_bits+= bits - s->last_bits;",
"s->last_bits= bits;",
"}",
"s->ptr_lastgob += current_packet_size;",
"s->first_slice_line=1;",
"s->resync_mb_x=VAR_2;",
"s->resync_mb_y=VAR_3;",
"}",
"}",
"if( (s->resync_mb_x == s->VAR_2)\n&& s->resync_mb_y+1 == s->VAR_3){",
"s->first_slice_line=0;",
"}",
"s->mb_skipped=0;",
"s->dquant=0;",
"if(mb_type & (mb_type-1) || (s->flags & CODEC_FLAG_QP_RD)){",
"int next_block=0;",
"int pb_bits_count, pb2_bits_count, tex_pb_bits_count;",
"copy_context_before_encode(&backup_s, s, -1);",
"backup_s.pb= s->pb;",
"best_s.data_partitioning= s->data_partitioning;",
"best_s.partitioned_frame= s->partitioned_frame;",
"if(s->data_partitioning){",
"backup_s.pb2= s->pb2;",
"backup_s.tex_pb= s->tex_pb;",
"}",
"if(mb_type&CANDIDATE_MB_TYPE_INTER){",
"s->mv_dir = MV_DIR_FORWARD;",
"s->mv_type = MV_TYPE_16X16;",
"s->mb_intra= 0;",
"s->mv[0][0][0] = s->p_mv_table[xy][0];",
"s->mv[0][0][1] = s->p_mv_table[xy][1];",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER, pb, pb2, tex_pb,\n&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);",
"}",
"if(mb_type&CANDIDATE_MB_TYPE_INTER_I){",
"s->mv_dir = MV_DIR_FORWARD;",
"s->mv_type = MV_TYPE_FIELD;",
"s->mb_intra= 0;",
"for(VAR_6=0; VAR_6<2; VAR_6++){",
"VAR_7= s->field_select[0][VAR_6] = s->p_field_select_table[VAR_6][xy];",
"s->mv[0][VAR_6][0] = s->p_field_mv_table[VAR_6][VAR_7][xy][0];",
"s->mv[0][VAR_6][1] = s->p_field_mv_table[VAR_6][VAR_7][xy][1];",
"}",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER_I, pb, pb2, tex_pb,\n&dmin, &next_block, 0, 0);",
"}",
"if(mb_type&CANDIDATE_MB_TYPE_SKIPPED){",
"s->mv_dir = MV_DIR_FORWARD;",
"s->mv_type = MV_TYPE_16X16;",
"s->mb_intra= 0;",
"s->mv[0][0][0] = 0;",
"s->mv[0][0][1] = 0;",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_SKIPPED, pb, pb2, tex_pb,\n&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);",
"}",
"if(mb_type&CANDIDATE_MB_TYPE_INTER4V){",
"s->mv_dir = MV_DIR_FORWARD;",
"s->mv_type = MV_TYPE_8X8;",
"s->mb_intra= 0;",
"for(VAR_6=0; VAR_6<4; VAR_6++){",
"s->mv[0][VAR_6][0] = s->current_picture.motion_val[0][s->block_index[VAR_6]][0];",
"s->mv[0][VAR_6][1] = s->current_picture.motion_val[0][s->block_index[VAR_6]][1];",
"}",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER4V, pb, pb2, tex_pb,\n&dmin, &next_block, 0, 0);",
"}",
"if(mb_type&CANDIDATE_MB_TYPE_FORWARD){",
"s->mv_dir = MV_DIR_FORWARD;",
"s->mv_type = MV_TYPE_16X16;",
"s->mb_intra= 0;",
"s->mv[0][0][0] = s->b_forw_mv_table[xy][0];",
"s->mv[0][0][1] = s->b_forw_mv_table[xy][1];",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_FORWARD, pb, pb2, tex_pb,\n&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);",
"}",
"if(mb_type&CANDIDATE_MB_TYPE_BACKWARD){",
"s->mv_dir = MV_DIR_BACKWARD;",
"s->mv_type = MV_TYPE_16X16;",
"s->mb_intra= 0;",
"s->mv[1][0][0] = s->b_back_mv_table[xy][0];",
"s->mv[1][0][1] = s->b_back_mv_table[xy][1];",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BACKWARD, pb, pb2, tex_pb,\n&dmin, &next_block, s->mv[1][0][0], s->mv[1][0][1]);",
"}",
"if(mb_type&CANDIDATE_MB_TYPE_BIDIR){",
"s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;",
"s->mv_type = MV_TYPE_16X16;",
"s->mb_intra= 0;",
"s->mv[0][0][0] = s->b_bidir_forw_mv_table[xy][0];",
"s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1];",
"s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0];",
"s->mv[1][0][1] = s->b_bidir_back_mv_table[xy][1];",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BIDIR, pb, pb2, tex_pb,\n&dmin, &next_block, 0, 0);",
"}",
"if(mb_type&CANDIDATE_MB_TYPE_FORWARD_I){",
"s->mv_dir = MV_DIR_FORWARD;",
"s->mv_type = MV_TYPE_FIELD;",
"s->mb_intra= 0;",
"for(VAR_6=0; VAR_6<2; VAR_6++){",
"VAR_7= s->field_select[0][VAR_6] = s->b_field_select_table[0][VAR_6][xy];",
"s->mv[0][VAR_6][0] = s->b_field_mv_table[0][VAR_6][VAR_7][xy][0];",
"s->mv[0][VAR_6][1] = s->b_field_mv_table[0][VAR_6][VAR_7][xy][1];",
"}",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_FORWARD_I, pb, pb2, tex_pb,\n&dmin, &next_block, 0, 0);",
"}",
"if(mb_type&CANDIDATE_MB_TYPE_BACKWARD_I){",
"s->mv_dir = MV_DIR_BACKWARD;",
"s->mv_type = MV_TYPE_FIELD;",
"s->mb_intra= 0;",
"for(VAR_6=0; VAR_6<2; VAR_6++){",
"VAR_7= s->field_select[1][VAR_6] = s->b_field_select_table[1][VAR_6][xy];",
"s->mv[1][VAR_6][0] = s->b_field_mv_table[1][VAR_6][VAR_7][xy][0];",
"s->mv[1][VAR_6][1] = s->b_field_mv_table[1][VAR_6][VAR_7][xy][1];",
"}",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BACKWARD_I, pb, pb2, tex_pb,\n&dmin, &next_block, 0, 0);",
"}",
"if(mb_type&CANDIDATE_MB_TYPE_BIDIR_I){",
"s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;",
"s->mv_type = MV_TYPE_FIELD;",
"s->mb_intra= 0;",
"for(dir=0; dir<2; dir++){",
"for(VAR_6=0; VAR_6<2; VAR_6++){",
"VAR_7= s->field_select[dir][VAR_6] = s->b_field_select_table[dir][VAR_6][xy];",
"s->mv[dir][VAR_6][0] = s->b_field_mv_table[dir][VAR_6][VAR_7][xy][0];",
"s->mv[dir][VAR_6][1] = s->b_field_mv_table[dir][VAR_6][VAR_7][xy][1];",
"}",
"}",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BIDIR_I, pb, pb2, tex_pb,\n&dmin, &next_block, 0, 0);",
"}",
"if(mb_type&CANDIDATE_MB_TYPE_INTRA){",
"s->mv_dir = 0;",
"s->mv_type = MV_TYPE_16X16;",
"s->mb_intra= 1;",
"s->mv[0][0][0] = 0;",
"s->mv[0][0][1] = 0;",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTRA, pb, pb2, tex_pb,\n&dmin, &next_block, 0, 0);",
"if(s->h263_pred || s->h263_aic){",
"if(best_s.mb_intra)\ns->mbintra_table[VAR_2 + VAR_3*s->mb_stride]=1;",
"else\nff_clean_intra_table_entries(s);",
"}",
"}",
"if((s->flags & CODEC_FLAG_QP_RD) && dmin < INT_MAX){",
"if(best_s.mv_type==MV_TYPE_16X16){",
"const int last_qp= backup_s.qscale;",
"int qpi, qp, dc[6];",
"DCTELEM ac[6][16];",
"const int mvdir= (best_s.mv_dir&MV_DIR_BACKWARD) ? 1 : 0;",
"static const int dquant_tab[4]={-1,1,-2,2};",
"assert(backup_s.dquant == 0);",
"s->mv_dir= best_s.mv_dir;",
"s->mv_type = MV_TYPE_16X16;",
"s->mb_intra= best_s.mb_intra;",
"s->mv[0][0][0] = best_s.mv[0][0][0];",
"s->mv[0][0][1] = best_s.mv[0][0][1];",
"s->mv[1][0][0] = best_s.mv[1][0][0];",
"s->mv[1][0][1] = best_s.mv[1][0][1];",
"qpi = s->pict_type == FF_B_TYPE ? 2 : 0;",
"for(; qpi<4; qpi++){",
"int dquant= dquant_tab[qpi];",
"qp= last_qp + dquant;",
"if(qp < s->avctx->qmin || qp > s->avctx->qmax)\ncontinue;",
"backup_s.dquant= dquant;",
"if(s->mb_intra && s->dc_val[0]){",
"for(VAR_6=0; VAR_6<6; VAR_6++){",
"dc[VAR_6]= s->dc_val[0][ s->block_index[VAR_6] ];",
"memcpy(ac[VAR_6], s->ac_val[0][s->block_index[VAR_6]], sizeof(DCTELEM)*16);",
"}",
"}",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER , pb, pb2, tex_pb,\n&dmin, &next_block, s->mv[mvdir][0][0], s->mv[mvdir][0][1]);",
"if(best_s.qscale != qp){",
"if(s->mb_intra && s->dc_val[0]){",
"for(VAR_6=0; VAR_6<6; VAR_6++){",
"s->dc_val[0][ s->block_index[VAR_6] ]= dc[VAR_6];",
"memcpy(s->ac_val[0][s->block_index[VAR_6]], ac[VAR_6], sizeof(DCTELEM)*16);",
"}",
"}",
"}",
"}",
"}",
"}",
"if(CONFIG_MPEG4_ENCODER && mb_type&CANDIDATE_MB_TYPE_DIRECT){",
"int mx= s->b_direct_mv_table[xy][0];",
"int my= s->b_direct_mv_table[xy][1];",
"backup_s.dquant = 0;",
"s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;",
"s->mb_intra= 0;",
"ff_mpeg4_set_direct_mv(s, mx, my);",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb,\n&dmin, &next_block, mx, my);",
"}",
"if(CONFIG_MPEG4_ENCODER && mb_type&CANDIDATE_MB_TYPE_DIRECT0){",
"backup_s.dquant = 0;",
"s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;",
"s->mb_intra= 0;",
"ff_mpeg4_set_direct_mv(s, 0, 0);",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb,\n&dmin, &next_block, 0, 0);",
"}",
"if(!best_s.mb_intra && s->flags2&CODEC_FLAG2_SKIP_RD){",
"int coded=0;",
"for(VAR_6=0; VAR_6<6; VAR_6++)",
"coded |= s->block_last_index[VAR_6];",
"if(coded){",
"int mx,my;",
"memcpy(s->mv, best_s.mv, sizeof(s->mv));",
"if(CONFIG_MPEG4_ENCODER && best_s.mv_dir & MV_DIRECT){",
"mx=my=0;",
"ff_mpeg4_set_direct_mv(s, mx, my);",
"}else if(best_s.mv_dir&MV_DIR_BACKWARD){",
"mx= s->mv[1][0][0];",
"my= s->mv[1][0][1];",
"}else{",
"mx= s->mv[0][0][0];",
"my= s->mv[0][0][1];",
"}",
"s->mv_dir= best_s.mv_dir;",
"s->mv_type = best_s.mv_type;",
"s->mb_intra= 0;",
"backup_s.dquant= 0;",
"s->skipdct=1;",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER , pb, pb2, tex_pb,\n&dmin, &next_block, mx, my);",
"s->skipdct=0;",
"}",
"}",
"s->current_picture.qscale_table[xy]= best_s.qscale;",
"copy_context_after_encode(s, &best_s, -1);",
"pb_bits_count= put_bits_count(&s->pb);",
"flush_put_bits(&s->pb);",
"ff_copy_bits(&backup_s.pb, bit_buf[next_block^1], pb_bits_count);",
"s->pb= backup_s.pb;",
"if(s->data_partitioning){",
"pb2_bits_count= put_bits_count(&s->pb2);",
"flush_put_bits(&s->pb2);",
"ff_copy_bits(&backup_s.pb2, bit_buf2[next_block^1], pb2_bits_count);",
"s->pb2= backup_s.pb2;",
"tex_pb_bits_count= put_bits_count(&s->tex_pb);",
"flush_put_bits(&s->tex_pb);",
"ff_copy_bits(&backup_s.tex_pb, bit_buf_tex[next_block^1], tex_pb_bits_count);",
"s->tex_pb= backup_s.tex_pb;",
"}",
"s->last_bits= put_bits_count(&s->pb);",
"if (CONFIG_ANY_H263_ENCODER &&\ns->out_format == FMT_H263 && s->pict_type!=FF_B_TYPE)\nff_h263_update_motion_val(s);",
"if(next_block==0){",
"s->dsp.put_pixels_tab[0][0](s->dest[0], s->rd_scratchpad , s->linesize ,16);",
"s->dsp.put_pixels_tab[1][0](s->dest[1], s->rd_scratchpad + 16*s->linesize , s->uvlinesize, 8);",
"s->dsp.put_pixels_tab[1][0](s->dest[2], s->rd_scratchpad + 16*s->linesize + 8, s->uvlinesize, 8);",
"}",
"if(s->avctx->mb_decision == FF_MB_DECISION_BITS)\nMPV_decode_mb(s, s->block);",
"} else {",
"int motion_x = 0, motion_y = 0;",
"s->mv_type=MV_TYPE_16X16;",
"switch(mb_type){",
"case CANDIDATE_MB_TYPE_INTRA:\ns->mv_dir = 0;",
"s->mb_intra= 1;",
"motion_x= s->mv[0][0][0] = 0;",
"motion_y= s->mv[0][0][1] = 0;",
"break;",
"case CANDIDATE_MB_TYPE_INTER:\ns->mv_dir = MV_DIR_FORWARD;",
"s->mb_intra= 0;",
"motion_x= s->mv[0][0][0] = s->p_mv_table[xy][0];",
"motion_y= s->mv[0][0][1] = s->p_mv_table[xy][1];",
"break;",
"case CANDIDATE_MB_TYPE_INTER_I:\ns->mv_dir = MV_DIR_FORWARD;",
"s->mv_type = MV_TYPE_FIELD;",
"s->mb_intra= 0;",
"for(VAR_6=0; VAR_6<2; VAR_6++){",
"VAR_7= s->field_select[0][VAR_6] = s->p_field_select_table[VAR_6][xy];",
"s->mv[0][VAR_6][0] = s->p_field_mv_table[VAR_6][VAR_7][xy][0];",
"s->mv[0][VAR_6][1] = s->p_field_mv_table[VAR_6][VAR_7][xy][1];",
"}",
"break;",
"case CANDIDATE_MB_TYPE_INTER4V:\ns->mv_dir = MV_DIR_FORWARD;",
"s->mv_type = MV_TYPE_8X8;",
"s->mb_intra= 0;",
"for(VAR_6=0; VAR_6<4; VAR_6++){",
"s->mv[0][VAR_6][0] = s->current_picture.motion_val[0][s->block_index[VAR_6]][0];",
"s->mv[0][VAR_6][1] = s->current_picture.motion_val[0][s->block_index[VAR_6]][1];",
"}",
"break;",
"case CANDIDATE_MB_TYPE_DIRECT:\nif (CONFIG_MPEG4_ENCODER) {",
"s->mv_dir = MV_DIR_FORWARD|MV_DIR_BACKWARD|MV_DIRECT;",
"s->mb_intra= 0;",
"motion_x=s->b_direct_mv_table[xy][0];",
"motion_y=s->b_direct_mv_table[xy][1];",
"ff_mpeg4_set_direct_mv(s, motion_x, motion_y);",
"}",
"break;",
"case CANDIDATE_MB_TYPE_DIRECT0:\nif (CONFIG_MPEG4_ENCODER) {",
"s->mv_dir = MV_DIR_FORWARD|MV_DIR_BACKWARD|MV_DIRECT;",
"s->mb_intra= 0;",
"ff_mpeg4_set_direct_mv(s, 0, 0);",
"}",
"break;",
"case CANDIDATE_MB_TYPE_BIDIR:\ns->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;",
"s->mb_intra= 0;",
"s->mv[0][0][0] = s->b_bidir_forw_mv_table[xy][0];",
"s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1];",
"s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0];",
"s->mv[1][0][1] = s->b_bidir_back_mv_table[xy][1];",
"break;",
"case CANDIDATE_MB_TYPE_BACKWARD:\ns->mv_dir = MV_DIR_BACKWARD;",
"s->mb_intra= 0;",
"motion_x= s->mv[1][0][0] = s->b_back_mv_table[xy][0];",
"motion_y= s->mv[1][0][1] = s->b_back_mv_table[xy][1];",
"break;",
"case CANDIDATE_MB_TYPE_FORWARD:\ns->mv_dir = MV_DIR_FORWARD;",
"s->mb_intra= 0;",
"motion_x= s->mv[0][0][0] = s->b_forw_mv_table[xy][0];",
"motion_y= s->mv[0][0][1] = s->b_forw_mv_table[xy][1];",
"break;",
"case CANDIDATE_MB_TYPE_FORWARD_I:\ns->mv_dir = MV_DIR_FORWARD;",
"s->mv_type = MV_TYPE_FIELD;",
"s->mb_intra= 0;",
"for(VAR_6=0; VAR_6<2; VAR_6++){",
"VAR_7= s->field_select[0][VAR_6] = s->b_field_select_table[0][VAR_6][xy];",
"s->mv[0][VAR_6][0] = s->b_field_mv_table[0][VAR_6][VAR_7][xy][0];",
"s->mv[0][VAR_6][1] = s->b_field_mv_table[0][VAR_6][VAR_7][xy][1];",
"}",
"break;",
"case CANDIDATE_MB_TYPE_BACKWARD_I:\ns->mv_dir = MV_DIR_BACKWARD;",
"s->mv_type = MV_TYPE_FIELD;",
"s->mb_intra= 0;",
"for(VAR_6=0; VAR_6<2; VAR_6++){",
"VAR_7= s->field_select[1][VAR_6] = s->b_field_select_table[1][VAR_6][xy];",
"s->mv[1][VAR_6][0] = s->b_field_mv_table[1][VAR_6][VAR_7][xy][0];",
"s->mv[1][VAR_6][1] = s->b_field_mv_table[1][VAR_6][VAR_7][xy][1];",
"}",
"break;",
"case CANDIDATE_MB_TYPE_BIDIR_I:\ns->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;",
"s->mv_type = MV_TYPE_FIELD;",
"s->mb_intra= 0;",
"for(dir=0; dir<2; dir++){",
"for(VAR_6=0; VAR_6<2; VAR_6++){",
"VAR_7= s->field_select[dir][VAR_6] = s->b_field_select_table[dir][VAR_6][xy];",
"s->mv[dir][VAR_6][0] = s->b_field_mv_table[dir][VAR_6][VAR_7][xy][0];",
"s->mv[dir][VAR_6][1] = s->b_field_mv_table[dir][VAR_6][VAR_7][xy][1];",
"}",
"}",
"break;",
"default:\nav_log(s->avctx, AV_LOG_ERROR, \"illegal MB type\\n\");",
"}",
"encode_mb(s, motion_x, motion_y);",
"s->last_mv_dir = s->mv_dir;",
"if (CONFIG_ANY_H263_ENCODER &&\ns->out_format == FMT_H263 && s->pict_type!=FF_B_TYPE)\nff_h263_update_motion_val(s);",
"MPV_decode_mb(s, s->block);",
"}",
"if(s->mb_intra ){",
"s->p_mv_table[xy][0]=0;",
"s->p_mv_table[xy][1]=0;",
"}",
"if(s->flags&CODEC_FLAG_PSNR){",
"int w= 16;",
"int h= 16;",
"if(s->VAR_2*16 + 16 > s->width ) w= s->width - s->VAR_2*16;",
"if(s->VAR_3*16 + 16 > s->height) h= s->height- s->VAR_3*16;",
"s->current_picture.error[0] += sse(\ns, s->new_picture.data[0] + s->VAR_2*16 + s->VAR_3*s->linesize*16,\ns->dest[0], w, h, s->linesize);",
"s->current_picture.error[1] += sse(\ns, s->new_picture.data[1] + s->VAR_2*8 + s->VAR_3*s->uvlinesize*VAR_5,\ns->dest[1], w>>1, h>>s->chroma_y_shift, s->uvlinesize);",
"s->current_picture.error[2] += sse(\ns, s->new_picture.data[2] + s->VAR_2*8 + s->VAR_3*s->uvlinesize*VAR_5,\ns->dest[2], w>>1, h>>s->chroma_y_shift, s->uvlinesize);",
"}",
"if(s->loop_filter){",
"if(CONFIG_ANY_H263_ENCODER && s->out_format == FMT_H263)\nff_h263_loop_filter(s);",
"}",
"}",
"}",
"if (CONFIG_MSMPEG4_ENCODER && s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type == FF_I_TYPE)\nmsmpeg4_encode_ext_header(s);",
"write_slice_end(s);",
"if (s->avctx->rtp_callback) {",
"int VAR_8 = (VAR_3 - s->resync_mb_y)*s->mb_width - s->resync_mb_x;",
"VAR_4 = put_bits_ptr(&s->pb) - s->ptr_lastgob;",
"emms_c();",
"s->avctx->rtp_callback(s->avctx, s->ptr_lastgob, VAR_4, VAR_8);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
85
],
[
87,
89,
91,
93,
95
],
[
97
],
[
99,
101,
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159,
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173
],
[
175
],
[
177
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
195
],
[
197
],
[
201
],
[
205
],
[
209
],
[
213
],
[
215,
217,
219,
221
],
[
223
],
[
225,
227
],
[
229,
231
],
[
233
],
[
235
],
[
239
],
[
241
],
[
243
],
[
247
],
[
249
],
[
251
],
[
253
],
[
257
],
[
259
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273,
275
],
[
277,
279
],
[
281
],
[
283
],
[
287
],
[
289
],
[
291
],
[
293
],
[
297
],
[
299,
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311,
313,
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325,
327,
329,
331
],
[
333
],
[
335
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
365,
367
],
[
369
],
[
371
],
[
375
],
[
377
],
[
381
],
[
383
],
[
385
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
407
],
[
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419,
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
441
],
[
443,
445
],
[
447
],
[
449
],
[
451
],
[
453
],
[
455
],
[
457
],
[
459
],
[
461,
463
],
[
465
],
[
467
],
[
469
],
[
471
],
[
473
],
[
475
],
[
477
],
[
479
],
[
481
],
[
483,
485
],
[
487
],
[
489
],
[
491
],
[
493
],
[
495
],
[
497
],
[
499
],
[
501,
503
],
[
505
],
[
507
],
[
509
],
[
511
],
[
513
],
[
515
],
[
517
],
[
519,
521
],
[
523
],
[
525
],
[
527
],
[
529
],
[
531
],
[
533
],
[
535
],
[
537
],
[
539
],
[
541,
543
],
[
545
],
[
547
],
[
549
],
[
551
],
[
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
563
],
[
565,
567
],
[
569
],
[
571
],
[
573
],
[
575
],
[
577
],
[
579
],
[
581
],
[
583
],
[
585
],
[
587
],
[
589,
591
],
[
593
],
[
595
],
[
597
],
[
599
],
[
601
],
[
603
],
[
605
],
[
607
],
[
609
],
[
611
],
[
613
],
[
615
],
[
617,
619
],
[
621
],
[
623
],
[
625
],
[
627
],
[
629
],
[
631
],
[
633
],
[
635,
637
],
[
639
],
[
641,
643
],
[
645,
647
],
[
649
],
[
651
],
[
655
],
[
657
],
[
659
],
[
661
],
[
663
],
[
665
],
[
667
],
[
671
],
[
677
],
[
679
],
[
681
],
[
683
],
[
685
],
[
687
],
[
689
],
[
693
],
[
695
],
[
697
],
[
699
],
[
701,
703
],
[
705
],
[
707
],
[
709
],
[
711
],
[
713
],
[
715
],
[
717
],
[
721,
723
],
[
725
],
[
727
],
[
729
],
[
731
],
[
733
],
[
735
],
[
737
],
[
739
],
[
741
],
[
743
],
[
745
],
[
747
],
[
749
],
[
751
],
[
755
],
[
757
],
[
759
],
[
761
],
[
763,
765
],
[
767
],
[
769
],
[
771
],
[
773
],
[
775
],
[
777
],
[
779,
781
],
[
783
],
[
785
],
[
787
],
[
789
],
[
791
],
[
793
],
[
795
],
[
797
],
[
799
],
[
801
],
[
803
],
[
805
],
[
807
],
[
809
],
[
811
],
[
813
],
[
815
],
[
817
],
[
821
],
[
823
],
[
825
],
[
835
],
[
837
],
[
839,
841
],
[
843
],
[
845
],
[
847
],
[
851
],
[
855
],
[
859
],
[
861
],
[
863
],
[
865
],
[
869
],
[
871
],
[
873
],
[
875
],
[
877
],
[
881
],
[
883
],
[
885
],
[
887
],
[
889
],
[
891
],
[
895,
897,
899
],
[
903
],
[
905
],
[
907
],
[
909
],
[
911
],
[
915,
917
],
[
919
],
[
921
],
[
923
],
[
929
],
[
931,
933
],
[
935
],
[
937
],
[
939
],
[
941
],
[
943,
945
],
[
947
],
[
949
],
[
951
],
[
953
],
[
955,
957
],
[
959
],
[
961
],
[
963
],
[
965
],
[
967
],
[
969
],
[
971
],
[
973
],
[
975,
977
],
[
979
],
[
981
],
[
983
],
[
985
],
[
987
],
[
989
],
[
991
],
[
993,
995
],
[
997
],
[
999
],
[
1001
],
[
1003
],
[
1005
],
[
1007
],
[
1009
],
[
1011,
1013
],
[
1015
],
[
1017
],
[
1019
],
[
1021
],
[
1023
],
[
1025,
1027
],
[
1029
],
[
1031
],
[
1033
],
[
1035
],
[
1037
],
[
1039
],
[
1041,
1043
],
[
1045
],
[
1047
],
[
1049
],
[
1051
],
[
1053,
1055
],
[
1057
],
[
1059
],
[
1061
],
[
1065
],
[
1067,
1069
],
[
1071
],
[
1073
],
[
1075
],
[
1077
],
[
1079
],
[
1081
],
[
1083
],
[
1085
],
[
1087,
1089
],
[
1091
],
[
1093
],
[
1095
],
[
1097
],
[
1099
],
[
1101
],
[
1103
],
[
1105
],
[
1107,
1109
],
[
1111
],
[
1113
],
[
1115
],
[
1117
],
[
1119
],
[
1121
],
[
1123
],
[
1125
],
[
1127
],
[
1129
],
[
1131,
1133
],
[
1135
],
[
1139
],
[
1145
],
[
1149,
1151,
1153
],
[
1157
],
[
1159
],
[
1165
],
[
1167
],
[
1169
],
[
1171
],
[
1175
],
[
1177
],
[
1179
],
[
1183
],
[
1185
],
[
1189,
1191,
1193
],
[
1195,
1197,
1199
],
[
1201,
1203,
1205
],
[
1207
],
[
1209
],
[
1211,
1213
],
[
1215
],
[
1219
],
[
1221
],
[
1227,
1229
],
[
1233
],
[
1239
],
[
1241
],
[
1243
],
[
1247
],
[
1249
],
[
1251
],
[
1255
],
[
1257
]
] |
27,123 | static void new_audio_stream(AVFormatContext *oc, int file_idx)
{
AVStream *st;
OutputStream *ost;
AVCodec *codec= NULL;
AVCodecContext *audio_enc;
enum CodecID codec_id = CODEC_ID_NONE;
if(!audio_stream_copy){
if (audio_codec_name) {
codec_id = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1,
avcodec_opts[AVMEDIA_TYPE_AUDIO]->strict_std_compliance);
codec = avcodec_find_encoder_by_name(audio_codec_name);
} else {
codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_AUDIO);
codec = avcodec_find_encoder(codec_id);
}
}
ost = new_output_stream(oc, file_idx, codec);
st = ost->st;
ost->bitstream_filters = audio_bitstream_filters;
audio_bitstream_filters= NULL;
st->codec->thread_count= thread_count;
audio_enc = st->codec;
audio_enc->codec_type = AVMEDIA_TYPE_AUDIO;
if(audio_codec_tag)
audio_enc->codec_tag= audio_codec_tag;
if (oc->oformat->flags & AVFMT_GLOBALHEADER) {
audio_enc->flags |= CODEC_FLAG_GLOBAL_HEADER;
}
if (audio_stream_copy) {
st->stream_copy = 1;
} else {
audio_enc->codec_id = codec_id;
set_context_opts(audio_enc, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec);
if (audio_qscale > QSCALE_NONE) {
audio_enc->flags |= CODEC_FLAG_QSCALE;
audio_enc->global_quality = FF_QP2LAMBDA * audio_qscale;
}
if (audio_channels)
audio_enc->channels = audio_channels;
if (audio_sample_fmt != AV_SAMPLE_FMT_NONE)
audio_enc->sample_fmt = audio_sample_fmt;
if (audio_sample_rate)
audio_enc->sample_rate = audio_sample_rate;
}
if (audio_language) {
av_dict_set(&st->metadata, "language", audio_language, 0);
av_freep(&audio_language);
}
/* reset some key parameters */
audio_disable = 0;
av_freep(&audio_codec_name);
audio_stream_copy = 0;
}
| false | FFmpeg | a9eb4f0899de04a3093a04f461611c6f0664398e | static void new_audio_stream(AVFormatContext *oc, int file_idx)
{
AVStream *st;
OutputStream *ost;
AVCodec *codec= NULL;
AVCodecContext *audio_enc;
enum CodecID codec_id = CODEC_ID_NONE;
if(!audio_stream_copy){
if (audio_codec_name) {
codec_id = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1,
avcodec_opts[AVMEDIA_TYPE_AUDIO]->strict_std_compliance);
codec = avcodec_find_encoder_by_name(audio_codec_name);
} else {
codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_AUDIO);
codec = avcodec_find_encoder(codec_id);
}
}
ost = new_output_stream(oc, file_idx, codec);
st = ost->st;
ost->bitstream_filters = audio_bitstream_filters;
audio_bitstream_filters= NULL;
st->codec->thread_count= thread_count;
audio_enc = st->codec;
audio_enc->codec_type = AVMEDIA_TYPE_AUDIO;
if(audio_codec_tag)
audio_enc->codec_tag= audio_codec_tag;
if (oc->oformat->flags & AVFMT_GLOBALHEADER) {
audio_enc->flags |= CODEC_FLAG_GLOBAL_HEADER;
}
if (audio_stream_copy) {
st->stream_copy = 1;
} else {
audio_enc->codec_id = codec_id;
set_context_opts(audio_enc, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec);
if (audio_qscale > QSCALE_NONE) {
audio_enc->flags |= CODEC_FLAG_QSCALE;
audio_enc->global_quality = FF_QP2LAMBDA * audio_qscale;
}
if (audio_channels)
audio_enc->channels = audio_channels;
if (audio_sample_fmt != AV_SAMPLE_FMT_NONE)
audio_enc->sample_fmt = audio_sample_fmt;
if (audio_sample_rate)
audio_enc->sample_rate = audio_sample_rate;
}
if (audio_language) {
av_dict_set(&st->metadata, "language", audio_language, 0);
av_freep(&audio_language);
}
audio_disable = 0;
av_freep(&audio_codec_name);
audio_stream_copy = 0;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVFormatContext *VAR_0, int VAR_1)
{
AVStream *st;
OutputStream *ost;
AVCodec *codec= NULL;
AVCodecContext *audio_enc;
enum CodecID VAR_2 = CODEC_ID_NONE;
if(!audio_stream_copy){
if (audio_codec_name) {
VAR_2 = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1,
avcodec_opts[AVMEDIA_TYPE_AUDIO]->strict_std_compliance);
codec = avcodec_find_encoder_by_name(audio_codec_name);
} else {
VAR_2 = av_guess_codec(VAR_0->oformat, NULL, VAR_0->filename, NULL, AVMEDIA_TYPE_AUDIO);
codec = avcodec_find_encoder(VAR_2);
}
}
ost = new_output_stream(VAR_0, VAR_1, codec);
st = ost->st;
ost->bitstream_filters = audio_bitstream_filters;
audio_bitstream_filters= NULL;
st->codec->thread_count= thread_count;
audio_enc = st->codec;
audio_enc->codec_type = AVMEDIA_TYPE_AUDIO;
if(audio_codec_tag)
audio_enc->codec_tag= audio_codec_tag;
if (VAR_0->oformat->flags & AVFMT_GLOBALHEADER) {
audio_enc->flags |= CODEC_FLAG_GLOBAL_HEADER;
}
if (audio_stream_copy) {
st->stream_copy = 1;
} else {
audio_enc->VAR_2 = VAR_2;
set_context_opts(audio_enc, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec);
if (audio_qscale > QSCALE_NONE) {
audio_enc->flags |= CODEC_FLAG_QSCALE;
audio_enc->global_quality = FF_QP2LAMBDA * audio_qscale;
}
if (audio_channels)
audio_enc->channels = audio_channels;
if (audio_sample_fmt != AV_SAMPLE_FMT_NONE)
audio_enc->sample_fmt = audio_sample_fmt;
if (audio_sample_rate)
audio_enc->sample_rate = audio_sample_rate;
}
if (audio_language) {
av_dict_set(&st->metadata, "language", audio_language, 0);
av_freep(&audio_language);
}
audio_disable = 0;
av_freep(&audio_codec_name);
audio_stream_copy = 0;
}
| [
"static void FUNC_0(AVFormatContext *VAR_0, int VAR_1)\n{",
"AVStream *st;",
"OutputStream *ost;",
"AVCodec *codec= NULL;",
"AVCodecContext *audio_enc;",
"enum CodecID VAR_2 = CODEC_ID_NONE;",
"if(!audio_stream_copy){",
"if (audio_codec_name) {",
"VAR_2 = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1,\navcodec_opts[AVMEDIA_TYPE_AUDIO]->strict_std_compliance);",
"codec = avcodec_find_encoder_by_name(audio_codec_name);",
"} else {",
"VAR_2 = av_guess_codec(VAR_0->oformat, NULL, VAR_0->filename, NULL, AVMEDIA_TYPE_AUDIO);",
"codec = avcodec_find_encoder(VAR_2);",
"}",
"}",
"ost = new_output_stream(VAR_0, VAR_1, codec);",
"st = ost->st;",
"ost->bitstream_filters = audio_bitstream_filters;",
"audio_bitstream_filters= NULL;",
"st->codec->thread_count= thread_count;",
"audio_enc = st->codec;",
"audio_enc->codec_type = AVMEDIA_TYPE_AUDIO;",
"if(audio_codec_tag)\naudio_enc->codec_tag= audio_codec_tag;",
"if (VAR_0->oformat->flags & AVFMT_GLOBALHEADER) {",
"audio_enc->flags |= CODEC_FLAG_GLOBAL_HEADER;",
"}",
"if (audio_stream_copy) {",
"st->stream_copy = 1;",
"} else {",
"audio_enc->VAR_2 = VAR_2;",
"set_context_opts(audio_enc, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec);",
"if (audio_qscale > QSCALE_NONE) {",
"audio_enc->flags |= CODEC_FLAG_QSCALE;",
"audio_enc->global_quality = FF_QP2LAMBDA * audio_qscale;",
"}",
"if (audio_channels)\naudio_enc->channels = audio_channels;",
"if (audio_sample_fmt != AV_SAMPLE_FMT_NONE)\naudio_enc->sample_fmt = audio_sample_fmt;",
"if (audio_sample_rate)\naudio_enc->sample_rate = audio_sample_rate;",
"}",
"if (audio_language) {",
"av_dict_set(&st->metadata, \"language\", audio_language, 0);",
"av_freep(&audio_language);",
"}",
"audio_disable = 0;",
"av_freep(&audio_codec_name);",
"audio_stream_copy = 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
49
],
[
53
],
[
55
],
[
59,
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91,
93
],
[
95,
97
],
[
99,
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
117
],
[
119
],
[
121
],
[
123
]
] |
27,124 | static int virtio_net_handle_mac(VirtIONet *n, uint8_t cmd,
VirtQueueElement *elem)
{
struct virtio_net_ctrl_mac mac_data;
if (cmd != VIRTIO_NET_CTRL_MAC_TABLE_SET || elem->out_num != 3 ||
elem->out_sg[1].iov_len < sizeof(mac_data) ||
elem->out_sg[2].iov_len < sizeof(mac_data))
return VIRTIO_NET_ERR;
n->mac_table.in_use = 0;
memset(n->mac_table.macs, 0, MAC_TABLE_ENTRIES * ETH_ALEN);
mac_data.entries = ldl_le_p(elem->out_sg[1].iov_base);
if (sizeof(mac_data.entries) +
(mac_data.entries * ETH_ALEN) > elem->out_sg[1].iov_len)
return VIRTIO_NET_ERR;
if (mac_data.entries <= MAC_TABLE_ENTRIES) {
memcpy(n->mac_table.macs, elem->out_sg[1].iov_base + sizeof(mac_data),
mac_data.entries * ETH_ALEN);
n->mac_table.in_use += mac_data.entries;
} else {
n->promisc = 1;
return VIRTIO_NET_OK;
}
mac_data.entries = ldl_le_p(elem->out_sg[2].iov_base);
if (sizeof(mac_data.entries) +
(mac_data.entries * ETH_ALEN) > elem->out_sg[2].iov_len)
return VIRTIO_NET_ERR;
if (mac_data.entries) {
if (n->mac_table.in_use + mac_data.entries <= MAC_TABLE_ENTRIES) {
memcpy(n->mac_table.macs + (n->mac_table.in_use * ETH_ALEN),
elem->out_sg[2].iov_base + sizeof(mac_data),
mac_data.entries * ETH_ALEN);
n->mac_table.in_use += mac_data.entries;
} else
n->allmulti = 1;
}
return VIRTIO_NET_OK;
}
| true | qemu | 8fd2a2f1a9048b9e37a898c2a5e9ef59d0c1a095 | static int virtio_net_handle_mac(VirtIONet *n, uint8_t cmd,
VirtQueueElement *elem)
{
struct virtio_net_ctrl_mac mac_data;
if (cmd != VIRTIO_NET_CTRL_MAC_TABLE_SET || elem->out_num != 3 ||
elem->out_sg[1].iov_len < sizeof(mac_data) ||
elem->out_sg[2].iov_len < sizeof(mac_data))
return VIRTIO_NET_ERR;
n->mac_table.in_use = 0;
memset(n->mac_table.macs, 0, MAC_TABLE_ENTRIES * ETH_ALEN);
mac_data.entries = ldl_le_p(elem->out_sg[1].iov_base);
if (sizeof(mac_data.entries) +
(mac_data.entries * ETH_ALEN) > elem->out_sg[1].iov_len)
return VIRTIO_NET_ERR;
if (mac_data.entries <= MAC_TABLE_ENTRIES) {
memcpy(n->mac_table.macs, elem->out_sg[1].iov_base + sizeof(mac_data),
mac_data.entries * ETH_ALEN);
n->mac_table.in_use += mac_data.entries;
} else {
n->promisc = 1;
return VIRTIO_NET_OK;
}
mac_data.entries = ldl_le_p(elem->out_sg[2].iov_base);
if (sizeof(mac_data.entries) +
(mac_data.entries * ETH_ALEN) > elem->out_sg[2].iov_len)
return VIRTIO_NET_ERR;
if (mac_data.entries) {
if (n->mac_table.in_use + mac_data.entries <= MAC_TABLE_ENTRIES) {
memcpy(n->mac_table.macs + (n->mac_table.in_use * ETH_ALEN),
elem->out_sg[2].iov_base + sizeof(mac_data),
mac_data.entries * ETH_ALEN);
n->mac_table.in_use += mac_data.entries;
} else
n->allmulti = 1;
}
return VIRTIO_NET_OK;
}
| {
"code": [
" n->promisc = 1;",
" return VIRTIO_NET_OK;",
" } else",
" n->allmulti = 1;"
],
"line_no": [
49,
51,
81,
83
]
} | static int FUNC_0(VirtIONet *VAR_0, uint8_t VAR_1,
VirtQueueElement *VAR_2)
{
struct virtio_net_ctrl_mac VAR_3;
if (VAR_1 != VIRTIO_NET_CTRL_MAC_TABLE_SET || VAR_2->out_num != 3 ||
VAR_2->out_sg[1].iov_len < sizeof(VAR_3) ||
VAR_2->out_sg[2].iov_len < sizeof(VAR_3))
return VIRTIO_NET_ERR;
VAR_0->mac_table.in_use = 0;
memset(VAR_0->mac_table.macs, 0, MAC_TABLE_ENTRIES * ETH_ALEN);
VAR_3.entries = ldl_le_p(VAR_2->out_sg[1].iov_base);
if (sizeof(VAR_3.entries) +
(VAR_3.entries * ETH_ALEN) > VAR_2->out_sg[1].iov_len)
return VIRTIO_NET_ERR;
if (VAR_3.entries <= MAC_TABLE_ENTRIES) {
memcpy(VAR_0->mac_table.macs, VAR_2->out_sg[1].iov_base + sizeof(VAR_3),
VAR_3.entries * ETH_ALEN);
VAR_0->mac_table.in_use += VAR_3.entries;
} else {
VAR_0->promisc = 1;
return VIRTIO_NET_OK;
}
VAR_3.entries = ldl_le_p(VAR_2->out_sg[2].iov_base);
if (sizeof(VAR_3.entries) +
(VAR_3.entries * ETH_ALEN) > VAR_2->out_sg[2].iov_len)
return VIRTIO_NET_ERR;
if (VAR_3.entries) {
if (VAR_0->mac_table.in_use + VAR_3.entries <= MAC_TABLE_ENTRIES) {
memcpy(VAR_0->mac_table.macs + (VAR_0->mac_table.in_use * ETH_ALEN),
VAR_2->out_sg[2].iov_base + sizeof(VAR_3),
VAR_3.entries * ETH_ALEN);
VAR_0->mac_table.in_use += VAR_3.entries;
} else
VAR_0->allmulti = 1;
}
return VIRTIO_NET_OK;
}
| [
"static int FUNC_0(VirtIONet *VAR_0, uint8_t VAR_1,\nVirtQueueElement *VAR_2)\n{",
"struct virtio_net_ctrl_mac VAR_3;",
"if (VAR_1 != VIRTIO_NET_CTRL_MAC_TABLE_SET || VAR_2->out_num != 3 ||\nVAR_2->out_sg[1].iov_len < sizeof(VAR_3) ||\nVAR_2->out_sg[2].iov_len < sizeof(VAR_3))\nreturn VIRTIO_NET_ERR;",
"VAR_0->mac_table.in_use = 0;",
"memset(VAR_0->mac_table.macs, 0, MAC_TABLE_ENTRIES * ETH_ALEN);",
"VAR_3.entries = ldl_le_p(VAR_2->out_sg[1].iov_base);",
"if (sizeof(VAR_3.entries) +\n(VAR_3.entries * ETH_ALEN) > VAR_2->out_sg[1].iov_len)\nreturn VIRTIO_NET_ERR;",
"if (VAR_3.entries <= MAC_TABLE_ENTRIES) {",
"memcpy(VAR_0->mac_table.macs, VAR_2->out_sg[1].iov_base + sizeof(VAR_3),\nVAR_3.entries * ETH_ALEN);",
"VAR_0->mac_table.in_use += VAR_3.entries;",
"} else {",
"VAR_0->promisc = 1;",
"return VIRTIO_NET_OK;",
"}",
"VAR_3.entries = ldl_le_p(VAR_2->out_sg[2].iov_base);",
"if (sizeof(VAR_3.entries) +\n(VAR_3.entries * ETH_ALEN) > VAR_2->out_sg[2].iov_len)\nreturn VIRTIO_NET_ERR;",
"if (VAR_3.entries) {",
"if (VAR_0->mac_table.in_use + VAR_3.entries <= MAC_TABLE_ENTRIES) {",
"memcpy(VAR_0->mac_table.macs + (VAR_0->mac_table.in_use * ETH_ALEN),\nVAR_2->out_sg[2].iov_base + sizeof(VAR_3),\nVAR_3.entries * ETH_ALEN);",
"VAR_0->mac_table.in_use += VAR_3.entries;",
"} else",
"VAR_0->allmulti = 1;",
"}",
"return VIRTIO_NET_OK;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11,
13,
15,
17
],
[
21
],
[
23
],
[
27
],
[
31,
33,
35
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
61,
63,
65
],
[
69
],
[
71
],
[
73,
75,
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
]
] |
27,125 | static ssize_t vnc_tls_pull(gnutls_transport_ptr_t transport,
void *data,
size_t len) {
VncState *vs = (VncState *)transport;
int ret;
retry:
ret = qemu_recv(vs->csock, data, len, 0);
if (ret < 0) {
if (errno == EINTR)
goto retry;
return -1;
}
return ret;
}
| true | qemu | 3e305e4a4752f70c0b5c3cf5b43ec957881714f7 | static ssize_t vnc_tls_pull(gnutls_transport_ptr_t transport,
void *data,
size_t len) {
VncState *vs = (VncState *)transport;
int ret;
retry:
ret = qemu_recv(vs->csock, data, len, 0);
if (ret < 0) {
if (errno == EINTR)
goto retry;
return -1;
}
return ret;
}
| {
"code": [
" int ret;",
" size_t len) {",
" VncState *vs = (VncState *)transport;",
" int ret;",
" retry:",
" if (ret < 0) {",
" if (errno == EINTR)",
" goto retry;",
" return -1;",
" return ret;",
"static ssize_t vnc_tls_pull(gnutls_transport_ptr_t transport,",
" void *data,",
" size_t len) {",
" VncState *vs = (VncState *)transport;",
" int ret;",
" retry:",
" ret = qemu_recv(vs->csock, data, len, 0);",
" if (ret < 0) {",
" if (errno == EINTR)",
" goto retry;",
" return -1;",
" return ret;",
" int ret;",
" int ret;",
" int ret;",
" return -1;",
" return -1;",
" return -1;",
" return -1;",
" return -1;",
" return -1;",
" return -1;",
" return -1;",
" return -1;",
" return -1;",
" return -1;",
" if (ret < 0) {",
" return -1;",
" if (ret < 0) {",
" return ret;"
],
"line_no": [
9,
5,
7,
9,
13,
17,
19,
21,
23,
27,
1,
3,
5,
7,
9,
13,
15,
17,
19,
21,
23,
27,
9,
9,
9,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
17,
23,
17,
27
]
} | static ssize_t FUNC_0(gnutls_transport_ptr_t transport,
void *data,
size_t len) {
VncState *vs = (VncState *)transport;
int VAR_0;
retry:
VAR_0 = qemu_recv(vs->csock, data, len, 0);
if (VAR_0 < 0) {
if (errno == EINTR)
goto retry;
return -1;
}
return VAR_0;
}
| [
"static ssize_t FUNC_0(gnutls_transport_ptr_t transport,\nvoid *data,\nsize_t len) {",
"VncState *vs = (VncState *)transport;",
"int VAR_0;",
"retry:\nVAR_0 = qemu_recv(vs->csock, data, len, 0);",
"if (VAR_0 < 0) {",
"if (errno == EINTR)\ngoto retry;",
"return -1;",
"}",
"return VAR_0;",
"}"
] | [
1,
1,
1,
1,
1,
1,
1,
0,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13,
15
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
27,126 | file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
{
HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(backend);
if (!backend->size) {
error_setg(errp, "can't create backend with size 0");
return;
}
if (!fb->mem_path) {
error_setg(errp, "mem-path property not set");
return;
}
#ifndef CONFIG_LINUX
error_setg(errp, "-mem-path not supported on this host");
#else
if (!memory_region_size(&backend->mr)) {
backend->force_prealloc = mem_prealloc;
memory_region_init_ram_from_file(&backend->mr, OBJECT(backend),
object_get_canonical_path(OBJECT(backend)),
backend->size, fb->share,
fb->mem_path, errp);
}
#endif
}
| true | qemu | 696b55017d90b3237ca9d656aa4904d6b5c46c7a | file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
{
HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(backend);
if (!backend->size) {
error_setg(errp, "can't create backend with size 0");
return;
}
if (!fb->mem_path) {
error_setg(errp, "mem-path property not set");
return;
}
#ifndef CONFIG_LINUX
error_setg(errp, "-mem-path not supported on this host");
#else
if (!memory_region_size(&backend->mr)) {
backend->force_prealloc = mem_prealloc;
memory_region_init_ram_from_file(&backend->mr, OBJECT(backend),
object_get_canonical_path(OBJECT(backend)),
backend->size, fb->share,
fb->mem_path, errp);
}
#endif
}
| {
"code": [
" object_get_canonical_path(OBJECT(backend)),"
],
"line_no": [
37
]
} | FUNC_0(HostMemoryBackend *VAR_0, Error **VAR_1)
{
HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(VAR_0);
if (!VAR_0->size) {
error_setg(VAR_1, "can't create VAR_0 with size 0");
return;
}
if (!fb->mem_path) {
error_setg(VAR_1, "mem-path property not set");
return;
}
#ifndef CONFIG_LINUX
error_setg(VAR_1, "-mem-path not supported on this host");
#else
if (!memory_region_size(&VAR_0->mr)) {
VAR_0->force_prealloc = mem_prealloc;
memory_region_init_ram_from_file(&VAR_0->mr, OBJECT(VAR_0),
object_get_canonical_path(OBJECT(VAR_0)),
VAR_0->size, fb->share,
fb->mem_path, VAR_1);
}
#endif
}
| [
"FUNC_0(HostMemoryBackend *VAR_0, Error **VAR_1)\n{",
"HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(VAR_0);",
"if (!VAR_0->size) {",
"error_setg(VAR_1, \"can't create VAR_0 with size 0\");",
"return;",
"}",
"if (!fb->mem_path) {",
"error_setg(VAR_1, \"mem-path property not set\");",
"return;",
"}",
"#ifndef CONFIG_LINUX\nerror_setg(VAR_1, \"-mem-path not supported on this host\");",
"#else\nif (!memory_region_size(&VAR_0->mr)) {",
"VAR_0->force_prealloc = mem_prealloc;",
"memory_region_init_ram_from_file(&VAR_0->mr, OBJECT(VAR_0),\nobject_get_canonical_path(OBJECT(VAR_0)),\nVAR_0->size, fb->share,\nfb->mem_path, VAR_1);",
"}",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29,
31
],
[
33
],
[
35,
37,
39,
41
],
[
43
],
[
45,
47
]
] |
27,127 | sorecvoob(struct socket *so)
{
struct tcpcb *tp = sototcpcb(so);
DEBUG_CALL("sorecvoob");
DEBUG_ARG("so = %p", so);
/*
* We take a guess at how much urgent data has arrived.
* In most situations, when urgent data arrives, the next
* read() should get all the urgent data. This guess will
* be wrong however if more data arrives just after the
* urgent data, or the read() doesn't return all the
* urgent data.
*/
soread(so);
tp->snd_up = tp->snd_una + so->so_snd.sb_cc;
tp->t_force = 1;
tcp_output(tp);
tp->t_force = 0;
}
| true | qemu | bfb1ac14029ee72b19296109fba880c0551755d5 | sorecvoob(struct socket *so)
{
struct tcpcb *tp = sototcpcb(so);
DEBUG_CALL("sorecvoob");
DEBUG_ARG("so = %p", so);
soread(so);
tp->snd_up = tp->snd_una + so->so_snd.sb_cc;
tp->t_force = 1;
tcp_output(tp);
tp->t_force = 0;
}
| {
"code": [
"\tsoread(so);",
"\ttp->snd_up = tp->snd_una + so->so_snd.sb_cc;",
"\ttp->t_force = 1;",
"\ttcp_output(tp);",
"\ttp->t_force = 0;"
],
"line_no": [
31,
33,
35,
37,
39
]
} | FUNC_0(struct socket *VAR_0)
{
struct tcpcb *VAR_1 = sototcpcb(VAR_0);
DEBUG_CALL("FUNC_0");
DEBUG_ARG("VAR_0 = %p", VAR_0);
soread(VAR_0);
VAR_1->snd_up = VAR_1->snd_una + VAR_0->so_snd.sb_cc;
VAR_1->t_force = 1;
tcp_output(VAR_1);
VAR_1->t_force = 0;
}
| [
"FUNC_0(struct socket *VAR_0)\n{",
"struct tcpcb *VAR_1 = sototcpcb(VAR_0);",
"DEBUG_CALL(\"FUNC_0\");",
"DEBUG_ARG(\"VAR_0 = %p\", VAR_0);",
"soread(VAR_0);",
"VAR_1->snd_up = VAR_1->snd_una + VAR_0->so_snd.sb_cc;",
"VAR_1->t_force = 1;",
"tcp_output(VAR_1);",
"VAR_1->t_force = 0;",
"}"
] | [
0,
0,
0,
0,
1,
1,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
]
] |
27,128 | static uint32_t cmos_ioport_read(void *opaque, uint32_t addr)
{
RTCState *s = opaque;
int ret;
if ((addr & 1) == 0) {
return 0xff;
} else {
switch(s->cmos_index) {
case RTC_SECONDS:
case RTC_MINUTES:
case RTC_HOURS:
case RTC_DAY_OF_WEEK:
case RTC_DAY_OF_MONTH:
case RTC_MONTH:
case RTC_YEAR:
ret = s->cmos_data[s->cmos_index];
break;
case RTC_REG_A:
ret = s->cmos_data[s->cmos_index];
break;
case RTC_REG_C:
ret = s->cmos_data[s->cmos_index];
qemu_irq_lower(s->irq);
#ifdef TARGET_I386
if(s->irq_coalesced) {
apic_reset_irq_delivered();
qemu_irq_raise(s->irq);
if (apic_get_irq_delivered())
s->irq_coalesced--;
break;
}
#endif
s->cmos_data[RTC_REG_C] = 0x00;
break;
default:
ret = s->cmos_data[s->cmos_index];
break;
}
#ifdef DEBUG_CMOS
printf("cmos: read index=0x%02x val=0x%02x\n",
s->cmos_index, ret);
#endif
return ret;
}
}
| true | qemu | 93b665693dd4afd32c89b0d5ee2b407b26a7a3bc | static uint32_t cmos_ioport_read(void *opaque, uint32_t addr)
{
RTCState *s = opaque;
int ret;
if ((addr & 1) == 0) {
return 0xff;
} else {
switch(s->cmos_index) {
case RTC_SECONDS:
case RTC_MINUTES:
case RTC_HOURS:
case RTC_DAY_OF_WEEK:
case RTC_DAY_OF_MONTH:
case RTC_MONTH:
case RTC_YEAR:
ret = s->cmos_data[s->cmos_index];
break;
case RTC_REG_A:
ret = s->cmos_data[s->cmos_index];
break;
case RTC_REG_C:
ret = s->cmos_data[s->cmos_index];
qemu_irq_lower(s->irq);
#ifdef TARGET_I386
if(s->irq_coalesced) {
apic_reset_irq_delivered();
qemu_irq_raise(s->irq);
if (apic_get_irq_delivered())
s->irq_coalesced--;
break;
}
#endif
s->cmos_data[RTC_REG_C] = 0x00;
break;
default:
ret = s->cmos_data[s->cmos_index];
break;
}
#ifdef DEBUG_CMOS
printf("cmos: read index=0x%02x val=0x%02x\n",
s->cmos_index, ret);
#endif
return ret;
}
}
| {
"code": [
"#ifdef TARGET_I386",
"#endif",
"#ifdef TARGET_I386",
" if(s->irq_coalesced) {",
" apic_reset_irq_delivered();",
" qemu_irq_raise(s->irq);",
" if (apic_get_irq_delivered())",
" s->irq_coalesced--;",
" break;",
"#endif"
],
"line_no": [
47,
63,
47,
49,
51,
53,
55,
57,
59,
63
]
} | static uint32_t FUNC_0(void *opaque, uint32_t addr)
{
RTCState *s = opaque;
int VAR_0;
if ((addr & 1) == 0) {
return 0xff;
} else {
switch(s->cmos_index) {
case RTC_SECONDS:
case RTC_MINUTES:
case RTC_HOURS:
case RTC_DAY_OF_WEEK:
case RTC_DAY_OF_MONTH:
case RTC_MONTH:
case RTC_YEAR:
VAR_0 = s->cmos_data[s->cmos_index];
break;
case RTC_REG_A:
VAR_0 = s->cmos_data[s->cmos_index];
break;
case RTC_REG_C:
VAR_0 = s->cmos_data[s->cmos_index];
qemu_irq_lower(s->irq);
#ifdef TARGET_I386
if(s->irq_coalesced) {
apic_reset_irq_delivered();
qemu_irq_raise(s->irq);
if (apic_get_irq_delivered())
s->irq_coalesced--;
break;
}
#endif
s->cmos_data[RTC_REG_C] = 0x00;
break;
default:
VAR_0 = s->cmos_data[s->cmos_index];
break;
}
#ifdef DEBUG_CMOS
printf("cmos: read index=0x%02x val=0x%02x\n",
s->cmos_index, VAR_0);
#endif
return VAR_0;
}
}
| [
"static uint32_t FUNC_0(void *opaque, uint32_t addr)\n{",
"RTCState *s = opaque;",
"int VAR_0;",
"if ((addr & 1) == 0) {",
"return 0xff;",
"} else {",
"switch(s->cmos_index) {",
"case RTC_SECONDS:\ncase RTC_MINUTES:\ncase RTC_HOURS:\ncase RTC_DAY_OF_WEEK:\ncase RTC_DAY_OF_MONTH:\ncase RTC_MONTH:\ncase RTC_YEAR:\nVAR_0 = s->cmos_data[s->cmos_index];",
"break;",
"case RTC_REG_A:\nVAR_0 = s->cmos_data[s->cmos_index];",
"break;",
"case RTC_REG_C:\nVAR_0 = s->cmos_data[s->cmos_index];",
"qemu_irq_lower(s->irq);",
"#ifdef TARGET_I386\nif(s->irq_coalesced) {",
"apic_reset_irq_delivered();",
"qemu_irq_raise(s->irq);",
"if (apic_get_irq_delivered())\ns->irq_coalesced--;",
"break;",
"}",
"#endif\ns->cmos_data[RTC_REG_C] = 0x00;",
"break;",
"default:\nVAR_0 = s->cmos_data[s->cmos_index];",
"break;",
"}",
"#ifdef DEBUG_CMOS\nprintf(\"cmos: read index=0x%02x val=0x%02x\\n\",\ns->cmos_index, VAR_0);",
"#endif\nreturn VAR_0;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17,
19,
21,
23,
25,
27,
29,
31
],
[
33
],
[
35,
37
],
[
39
],
[
41,
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
69,
71
],
[
73
],
[
75
],
[
77,
79,
81
],
[
83,
85
],
[
87
],
[
89
]
] |
Subsets and Splits