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
|
---|---|---|---|---|---|---|---|---|---|---|
25,883 | static void decode_array_0000(APEContext *ctx, GetBitContext *gb,
int32_t *out, APERice *rice, int blockstodecode)
{
int i;
int ksummax, ksummin;
rice->ksum = 0;
for (i = 0; i < 5; i++) {
out[i] = get_rice_ook(&ctx->gb, 10);
rice->ksum += out[i];
}
rice->k = av_log2(rice->ksum / 10) + 1;
for (; i < 64; i++) {
out[i] = get_rice_ook(&ctx->gb, rice->k);
rice->ksum += out[i];
rice->k = av_log2(rice->ksum / ((i + 1) * 2)) + 1;
}
ksummax = 1 << rice->k + 7;
ksummin = rice->k ? (1 << rice->k + 6) : 0;
for (; i < blockstodecode; i++) {
out[i] = get_rice_ook(&ctx->gb, rice->k);
rice->ksum += out[i] - out[i - 64];
while (rice->ksum < ksummin) {
rice->k--;
ksummin = rice->k ? ksummin >> 1 : 0;
ksummax >>= 1;
}
while (rice->ksum >= ksummax) {
rice->k++;
if (rice->k > 24)
ksummax <<= 1;
ksummin = ksummin ? ksummin << 1 : 128;
}
}
for (i = 0; i < blockstodecode; i++) {
if (out[i] & 1)
out[i] = (out[i] >> 1) + 1;
else
out[i] = -(out[i] >> 1);
}
} | true | FFmpeg | d5128fce38646d3f64c55feda42084888ba0e87e | static void decode_array_0000(APEContext *ctx, GetBitContext *gb,
int32_t *out, APERice *rice, int blockstodecode)
{
int i;
int ksummax, ksummin;
rice->ksum = 0;
for (i = 0; i < 5; i++) {
out[i] = get_rice_ook(&ctx->gb, 10);
rice->ksum += out[i];
}
rice->k = av_log2(rice->ksum / 10) + 1;
for (; i < 64; i++) {
out[i] = get_rice_ook(&ctx->gb, rice->k);
rice->ksum += out[i];
rice->k = av_log2(rice->ksum / ((i + 1) * 2)) + 1;
}
ksummax = 1 << rice->k + 7;
ksummin = rice->k ? (1 << rice->k + 6) : 0;
for (; i < blockstodecode; i++) {
out[i] = get_rice_ook(&ctx->gb, rice->k);
rice->ksum += out[i] - out[i - 64];
while (rice->ksum < ksummin) {
rice->k--;
ksummin = rice->k ? ksummin >> 1 : 0;
ksummax >>= 1;
}
while (rice->ksum >= ksummax) {
rice->k++;
if (rice->k > 24)
ksummax <<= 1;
ksummin = ksummin ? ksummin << 1 : 128;
}
}
for (i = 0; i < blockstodecode; i++) {
if (out[i] & 1)
out[i] = (out[i] >> 1) + 1;
else
out[i] = -(out[i] >> 1);
}
} | {
"code": [],
"line_no": []
} | static void FUNC_0(APEContext *VAR_0, GetBitContext *VAR_1,
int32_t *VAR_2, APERice *VAR_3, int VAR_4)
{
int VAR_5;
int VAR_6, VAR_7;
VAR_3->ksum = 0;
for (VAR_5 = 0; VAR_5 < 5; VAR_5++) {
VAR_2[VAR_5] = get_rice_ook(&VAR_0->VAR_1, 10);
VAR_3->ksum += VAR_2[VAR_5];
}
VAR_3->k = av_log2(VAR_3->ksum / 10) + 1;
for (; VAR_5 < 64; VAR_5++) {
VAR_2[VAR_5] = get_rice_ook(&VAR_0->VAR_1, VAR_3->k);
VAR_3->ksum += VAR_2[VAR_5];
VAR_3->k = av_log2(VAR_3->ksum / ((VAR_5 + 1) * 2)) + 1;
}
VAR_6 = 1 << VAR_3->k + 7;
VAR_7 = VAR_3->k ? (1 << VAR_3->k + 6) : 0;
for (; VAR_5 < VAR_4; VAR_5++) {
VAR_2[VAR_5] = get_rice_ook(&VAR_0->VAR_1, VAR_3->k);
VAR_3->ksum += VAR_2[VAR_5] - VAR_2[VAR_5 - 64];
while (VAR_3->ksum < VAR_7) {
VAR_3->k--;
VAR_7 = VAR_3->k ? VAR_7 >> 1 : 0;
VAR_6 >>= 1;
}
while (VAR_3->ksum >= VAR_6) {
VAR_3->k++;
if (VAR_3->k > 24)
VAR_6 <<= 1;
VAR_7 = VAR_7 ? VAR_7 << 1 : 128;
}
}
for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {
if (VAR_2[VAR_5] & 1)
VAR_2[VAR_5] = (VAR_2[VAR_5] >> 1) + 1;
else
VAR_2[VAR_5] = -(VAR_2[VAR_5] >> 1);
}
} | [
"static void FUNC_0(APEContext *VAR_0, GetBitContext *VAR_1,\nint32_t *VAR_2, APERice *VAR_3, int VAR_4)\n{",
"int VAR_5;",
"int VAR_6, VAR_7;",
"VAR_3->ksum = 0;",
"for (VAR_5 = 0; VAR_5 < 5; VAR_5++) {",
"VAR_2[VAR_5] = get_rice_ook(&VAR_0->VAR_1, 10);",
"VAR_3->ksum += VAR_2[VAR_5];",
"}",
"VAR_3->k = av_log2(VAR_3->ksum / 10) + 1;",
"for (; VAR_5 < 64; VAR_5++) {",
"VAR_2[VAR_5] = get_rice_ook(&VAR_0->VAR_1, VAR_3->k);",
"VAR_3->ksum += VAR_2[VAR_5];",
"VAR_3->k = av_log2(VAR_3->ksum / ((VAR_5 + 1) * 2)) + 1;",
"}",
"VAR_6 = 1 << VAR_3->k + 7;",
"VAR_7 = VAR_3->k ? (1 << VAR_3->k + 6) : 0;",
"for (; VAR_5 < VAR_4; VAR_5++) {",
"VAR_2[VAR_5] = get_rice_ook(&VAR_0->VAR_1, VAR_3->k);",
"VAR_3->ksum += VAR_2[VAR_5] - VAR_2[VAR_5 - 64];",
"while (VAR_3->ksum < VAR_7) {",
"VAR_3->k--;",
"VAR_7 = VAR_3->k ? VAR_7 >> 1 : 0;",
"VAR_6 >>= 1;",
"}",
"while (VAR_3->ksum >= VAR_6) {",
"VAR_3->k++;",
"if (VAR_3->k > 24)\nVAR_6 <<= 1;",
"VAR_7 = VAR_7 ? VAR_7 << 1 : 128;",
"}",
"}",
"for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {",
"if (VAR_2[VAR_5] & 1)\nVAR_2[VAR_5] = (VAR_2[VAR_5] >> 1) + 1;",
"else\nVAR_2[VAR_5] = -(VAR_2[VAR_5] >> 1);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63,
66
],
[
68
],
[
70
],
[
72
],
[
76
],
[
78,
80
],
[
82,
84
],
[
86
],
[
88
]
] |
25,884 | static void filter_mb_edgeh( H264Context *h, uint8_t *pix, int stride, int16_t bS[4], int qp ) {
int i, d;
const int index_a = qp + h->slice_alpha_c0_offset;
const int alpha = (alpha_table+52)[index_a];
const int beta = (beta_table+52)[qp + h->slice_beta_offset];
const int pix_next = stride;
if( bS[0] < 4 ) {
int8_t tc[4];
for(i=0; i<4; i++)
tc[i] = bS[i] ? (tc0_table+52)[index_a][bS[i] - 1] : -1;
h->s.dsp.h264_v_loop_filter_luma(pix, stride, alpha, beta, tc);
} else {
h->s.dsp.h264_v_loop_filter_luma_intra(pix, stride, alpha, beta);
}
}
| false | FFmpeg | aac8b76983e340bc744d3542d676f72efa3b474f | static void filter_mb_edgeh( H264Context *h, uint8_t *pix, int stride, int16_t bS[4], int qp ) {
int i, d;
const int index_a = qp + h->slice_alpha_c0_offset;
const int alpha = (alpha_table+52)[index_a];
const int beta = (beta_table+52)[qp + h->slice_beta_offset];
const int pix_next = stride;
if( bS[0] < 4 ) {
int8_t tc[4];
for(i=0; i<4; i++)
tc[i] = bS[i] ? (tc0_table+52)[index_a][bS[i] - 1] : -1;
h->s.dsp.h264_v_loop_filter_luma(pix, stride, alpha, beta, tc);
} else {
h->s.dsp.h264_v_loop_filter_luma_intra(pix, stride, alpha, beta);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0( H264Context *VAR_0, uint8_t *VAR_1, int VAR_2, int16_t VAR_3[4], int VAR_4 ) {
int VAR_5, VAR_6;
const int VAR_7 = VAR_4 + VAR_0->slice_alpha_c0_offset;
const int VAR_8 = (alpha_table+52)[VAR_7];
const int VAR_9 = (beta_table+52)[VAR_4 + VAR_0->slice_beta_offset];
const int VAR_10 = VAR_2;
if( VAR_3[0] < 4 ) {
int8_t tc[4];
for(VAR_5=0; VAR_5<4; VAR_5++)
tc[VAR_5] = VAR_3[VAR_5] ? (tc0_table+52)[VAR_7][VAR_3[VAR_5] - 1] : -1;
VAR_0->s.dsp.h264_v_loop_filter_luma(VAR_1, VAR_2, VAR_8, VAR_9, tc);
} else {
VAR_0->s.dsp.h264_v_loop_filter_luma_intra(VAR_1, VAR_2, VAR_8, VAR_9);
}
}
| [
"static void FUNC_0( H264Context *VAR_0, uint8_t *VAR_1, int VAR_2, int16_t VAR_3[4], int VAR_4 ) {",
"int VAR_5, VAR_6;",
"const int VAR_7 = VAR_4 + VAR_0->slice_alpha_c0_offset;",
"const int VAR_8 = (alpha_table+52)[VAR_7];",
"const int VAR_9 = (beta_table+52)[VAR_4 + VAR_0->slice_beta_offset];",
"const int VAR_10 = VAR_2;",
"if( VAR_3[0] < 4 ) {",
"int8_t tc[4];",
"for(VAR_5=0; VAR_5<4; VAR_5++)",
"tc[VAR_5] = VAR_3[VAR_5] ? (tc0_table+52)[VAR_7][VAR_3[VAR_5] - 1] : -1;",
"VAR_0->s.dsp.h264_v_loop_filter_luma(VAR_1, VAR_2, VAR_8, VAR_9, tc);",
"} else {",
"VAR_0->s.dsp.h264_v_loop_filter_luma_intra(VAR_1, VAR_2, VAR_8, VAR_9);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
]
] |
25,885 | int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg)
{
struct kvm_msi msi;
KVMMSIRoute *route;
if (s->direct_msi) {
msi.address_lo = (uint32_t)msg.address;
msi.address_hi = msg.address >> 32;
msi.data = le32_to_cpu(msg.data);
msi.flags = 0;
memset(msi.pad, 0, sizeof(msi.pad));
return kvm_vm_ioctl(s, KVM_SIGNAL_MSI, &msi);
}
route = kvm_lookup_msi_route(s, msg);
if (!route) {
int virq;
virq = kvm_irqchip_get_virq(s);
if (virq < 0) {
return virq;
}
route = g_malloc(sizeof(KVMMSIRoute));
route->kroute.gsi = virq;
route->kroute.type = KVM_IRQ_ROUTING_MSI;
route->kroute.flags = 0;
route->kroute.u.msi.address_lo = (uint32_t)msg.address;
route->kroute.u.msi.address_hi = msg.address >> 32;
route->kroute.u.msi.data = le32_to_cpu(msg.data);
kvm_add_routing_entry(s, &route->kroute);
kvm_irqchip_commit_routes(s);
QTAILQ_INSERT_TAIL(&s->msi_hashtab[kvm_hash_msi(msg.data)], route,
entry);
}
assert(route->kroute.type == KVM_IRQ_ROUTING_MSI);
return kvm_set_irq(s, route->kroute.gsi, 1);
}
| true | qemu | 0fbc20740342713f282b118b4a446c4c43df3f4a | int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg)
{
struct kvm_msi msi;
KVMMSIRoute *route;
if (s->direct_msi) {
msi.address_lo = (uint32_t)msg.address;
msi.address_hi = msg.address >> 32;
msi.data = le32_to_cpu(msg.data);
msi.flags = 0;
memset(msi.pad, 0, sizeof(msi.pad));
return kvm_vm_ioctl(s, KVM_SIGNAL_MSI, &msi);
}
route = kvm_lookup_msi_route(s, msg);
if (!route) {
int virq;
virq = kvm_irqchip_get_virq(s);
if (virq < 0) {
return virq;
}
route = g_malloc(sizeof(KVMMSIRoute));
route->kroute.gsi = virq;
route->kroute.type = KVM_IRQ_ROUTING_MSI;
route->kroute.flags = 0;
route->kroute.u.msi.address_lo = (uint32_t)msg.address;
route->kroute.u.msi.address_hi = msg.address >> 32;
route->kroute.u.msi.data = le32_to_cpu(msg.data);
kvm_add_routing_entry(s, &route->kroute);
kvm_irqchip_commit_routes(s);
QTAILQ_INSERT_TAIL(&s->msi_hashtab[kvm_hash_msi(msg.data)], route,
entry);
}
assert(route->kroute.type == KVM_IRQ_ROUTING_MSI);
return kvm_set_irq(s, route->kroute.gsi, 1);
}
| {
"code": [
" route = g_malloc(sizeof(KVMMSIRoute));"
],
"line_no": [
49
]
} | int FUNC_0(KVMState *VAR_0, MSIMessage VAR_1)
{
struct kvm_msi VAR_2;
KVMMSIRoute *route;
if (VAR_0->direct_msi) {
VAR_2.address_lo = (uint32_t)VAR_1.address;
VAR_2.address_hi = VAR_1.address >> 32;
VAR_2.data = le32_to_cpu(VAR_1.data);
VAR_2.flags = 0;
memset(VAR_2.pad, 0, sizeof(VAR_2.pad));
return kvm_vm_ioctl(VAR_0, KVM_SIGNAL_MSI, &VAR_2);
}
route = kvm_lookup_msi_route(VAR_0, VAR_1);
if (!route) {
int VAR_3;
VAR_3 = kvm_irqchip_get_virq(VAR_0);
if (VAR_3 < 0) {
return VAR_3;
}
route = g_malloc(sizeof(KVMMSIRoute));
route->kroute.gsi = VAR_3;
route->kroute.type = KVM_IRQ_ROUTING_MSI;
route->kroute.flags = 0;
route->kroute.u.VAR_2.address_lo = (uint32_t)VAR_1.address;
route->kroute.u.VAR_2.address_hi = VAR_1.address >> 32;
route->kroute.u.VAR_2.data = le32_to_cpu(VAR_1.data);
kvm_add_routing_entry(VAR_0, &route->kroute);
kvm_irqchip_commit_routes(VAR_0);
QTAILQ_INSERT_TAIL(&VAR_0->msi_hashtab[kvm_hash_msi(VAR_1.data)], route,
entry);
}
assert(route->kroute.type == KVM_IRQ_ROUTING_MSI);
return kvm_set_irq(VAR_0, route->kroute.gsi, 1);
}
| [
"int FUNC_0(KVMState *VAR_0, MSIMessage VAR_1)\n{",
"struct kvm_msi VAR_2;",
"KVMMSIRoute *route;",
"if (VAR_0->direct_msi) {",
"VAR_2.address_lo = (uint32_t)VAR_1.address;",
"VAR_2.address_hi = VAR_1.address >> 32;",
"VAR_2.data = le32_to_cpu(VAR_1.data);",
"VAR_2.flags = 0;",
"memset(VAR_2.pad, 0, sizeof(VAR_2.pad));",
"return kvm_vm_ioctl(VAR_0, KVM_SIGNAL_MSI, &VAR_2);",
"}",
"route = kvm_lookup_msi_route(VAR_0, VAR_1);",
"if (!route) {",
"int VAR_3;",
"VAR_3 = kvm_irqchip_get_virq(VAR_0);",
"if (VAR_3 < 0) {",
"return VAR_3;",
"}",
"route = g_malloc(sizeof(KVMMSIRoute));",
"route->kroute.gsi = VAR_3;",
"route->kroute.type = KVM_IRQ_ROUTING_MSI;",
"route->kroute.flags = 0;",
"route->kroute.u.VAR_2.address_lo = (uint32_t)VAR_1.address;",
"route->kroute.u.VAR_2.address_hi = VAR_1.address >> 32;",
"route->kroute.u.VAR_2.data = le32_to_cpu(VAR_1.data);",
"kvm_add_routing_entry(VAR_0, &route->kroute);",
"kvm_irqchip_commit_routes(VAR_0);",
"QTAILQ_INSERT_TAIL(&VAR_0->msi_hashtab[kvm_hash_msi(VAR_1.data)], route,\nentry);",
"}",
"assert(route->kroute.type == KVM_IRQ_ROUTING_MSI);",
"return kvm_set_irq(VAR_0, route->kroute.gsi, 1);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
71,
73
],
[
75
],
[
79
],
[
83
],
[
85
]
] |
25,886 | void sd_set_cb(SDState *sd, qemu_irq readonly, qemu_irq insert)
{
sd->readonly_cb = readonly;
sd->inserted_cb = insert;
qemu_set_irq(readonly, bdrv_is_read_only(sd->bdrv));
qemu_set_irq(insert, bdrv_is_inserted(sd->bdrv));
}
| true | qemu | 0d2e91c17829729812bf5d22d20dd0f5d2554ec2 | void sd_set_cb(SDState *sd, qemu_irq readonly, qemu_irq insert)
{
sd->readonly_cb = readonly;
sd->inserted_cb = insert;
qemu_set_irq(readonly, bdrv_is_read_only(sd->bdrv));
qemu_set_irq(insert, bdrv_is_inserted(sd->bdrv));
}
| {
"code": [
" qemu_set_irq(readonly, bdrv_is_read_only(sd->bdrv));",
" qemu_set_irq(insert, bdrv_is_inserted(sd->bdrv));"
],
"line_no": [
9,
11
]
} | void FUNC_0(SDState *VAR_0, qemu_irq VAR_1, qemu_irq VAR_2)
{
VAR_0->readonly_cb = VAR_1;
VAR_0->inserted_cb = VAR_2;
qemu_set_irq(VAR_1, bdrv_is_read_only(VAR_0->bdrv));
qemu_set_irq(VAR_2, bdrv_is_inserted(VAR_0->bdrv));
}
| [
"void FUNC_0(SDState *VAR_0, qemu_irq VAR_1, qemu_irq VAR_2)\n{",
"VAR_0->readonly_cb = VAR_1;",
"VAR_0->inserted_cb = VAR_2;",
"qemu_set_irq(VAR_1, bdrv_is_read_only(VAR_0->bdrv));",
"qemu_set_irq(VAR_2, bdrv_is_inserted(VAR_0->bdrv));",
"}"
] | [
0,
0,
0,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
25,887 | static int mov_seek_stream(AVFormatContext *s, AVStream *st, int64_t timestamp, int flags)
{
MOVStreamContext *sc = st->priv_data;
int sample, time_sample;
int i;
sample = av_index_search_timestamp(st, timestamp, flags);
av_log(s, AV_LOG_TRACE, "stream %d, timestamp %"PRId64", sample %d\n", st->index, timestamp, sample);
if (sample < 0 && st->nb_index_entries && timestamp < st->index_entries[0].timestamp)
sample = 0;
if (sample < 0) /* not sure what to do */
return AVERROR_INVALIDDATA;
sc->current_sample = sample;
av_log(s, AV_LOG_TRACE, "stream %d, found sample %d\n", st->index, sc->current_sample);
/* adjust ctts index */
if (sc->ctts_data) {
time_sample = 0;
for (i = 0; i < sc->ctts_count; i++) {
int next = time_sample + sc->ctts_data[i].count;
if (next > sc->current_sample) {
sc->ctts_index = i;
sc->ctts_sample = sc->current_sample - time_sample;
break;
}
time_sample = next;
}
}
/* adjust stsd index */
time_sample = 0;
for (i = 0; i < sc->stsc_count; i++) {
int next = time_sample + mov_get_stsc_samples(sc, i);
if (next > sc->current_sample) {
sc->stsc_index = i;
sc->stsc_sample = sc->current_sample - time_sample;
break;
}
time_sample = next;
}
return sample;
}
| true | FFmpeg | 53ea595eec984e3109310e8bb7ff4b5786d91057 | static int mov_seek_stream(AVFormatContext *s, AVStream *st, int64_t timestamp, int flags)
{
MOVStreamContext *sc = st->priv_data;
int sample, time_sample;
int i;
sample = av_index_search_timestamp(st, timestamp, flags);
av_log(s, AV_LOG_TRACE, "stream %d, timestamp %"PRId64", sample %d\n", st->index, timestamp, sample);
if (sample < 0 && st->nb_index_entries && timestamp < st->index_entries[0].timestamp)
sample = 0;
if (sample < 0)
return AVERROR_INVALIDDATA;
sc->current_sample = sample;
av_log(s, AV_LOG_TRACE, "stream %d, found sample %d\n", st->index, sc->current_sample);
if (sc->ctts_data) {
time_sample = 0;
for (i = 0; i < sc->ctts_count; i++) {
int next = time_sample + sc->ctts_data[i].count;
if (next > sc->current_sample) {
sc->ctts_index = i;
sc->ctts_sample = sc->current_sample - time_sample;
break;
}
time_sample = next;
}
}
time_sample = 0;
for (i = 0; i < sc->stsc_count; i++) {
int next = time_sample + mov_get_stsc_samples(sc, i);
if (next > sc->current_sample) {
sc->stsc_index = i;
sc->stsc_sample = sc->current_sample - time_sample;
break;
}
time_sample = next;
}
return sample;
}
| {
"code": [
" int i;"
],
"line_no": [
9
]
} | static int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, int64_t VAR_2, int VAR_3)
{
MOVStreamContext *sc = VAR_1->priv_data;
int VAR_4, VAR_5;
int VAR_6;
VAR_4 = av_index_search_timestamp(VAR_1, VAR_2, VAR_3);
av_log(VAR_0, AV_LOG_TRACE, "stream %d, VAR_2 %"PRId64", VAR_4 %d\n", VAR_1->index, VAR_2, VAR_4);
if (VAR_4 < 0 && VAR_1->nb_index_entries && VAR_2 < VAR_1->index_entries[0].VAR_2)
VAR_4 = 0;
if (VAR_4 < 0)
return AVERROR_INVALIDDATA;
sc->current_sample = VAR_4;
av_log(VAR_0, AV_LOG_TRACE, "stream %d, found VAR_4 %d\n", VAR_1->index, sc->current_sample);
if (sc->ctts_data) {
VAR_5 = 0;
for (VAR_6 = 0; VAR_6 < sc->ctts_count; VAR_6++) {
int next = VAR_5 + sc->ctts_data[VAR_6].count;
if (next > sc->current_sample) {
sc->ctts_index = VAR_6;
sc->ctts_sample = sc->current_sample - VAR_5;
break;
}
VAR_5 = next;
}
}
VAR_5 = 0;
for (VAR_6 = 0; VAR_6 < sc->stsc_count; VAR_6++) {
int next = VAR_5 + mov_get_stsc_samples(sc, VAR_6);
if (next > sc->current_sample) {
sc->stsc_index = VAR_6;
sc->stsc_sample = sc->current_sample - VAR_5;
break;
}
VAR_5 = next;
}
return VAR_4;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, int64_t VAR_2, int VAR_3)\n{",
"MOVStreamContext *sc = VAR_1->priv_data;",
"int VAR_4, VAR_5;",
"int VAR_6;",
"VAR_4 = av_index_search_timestamp(VAR_1, VAR_2, VAR_3);",
"av_log(VAR_0, AV_LOG_TRACE, \"stream %d, VAR_2 %\"PRId64\", VAR_4 %d\\n\", VAR_1->index, VAR_2, VAR_4);",
"if (VAR_4 < 0 && VAR_1->nb_index_entries && VAR_2 < VAR_1->index_entries[0].VAR_2)\nVAR_4 = 0;",
"if (VAR_4 < 0)\nreturn AVERROR_INVALIDDATA;",
"sc->current_sample = VAR_4;",
"av_log(VAR_0, AV_LOG_TRACE, \"stream %d, found VAR_4 %d\\n\", VAR_1->index, sc->current_sample);",
"if (sc->ctts_data) {",
"VAR_5 = 0;",
"for (VAR_6 = 0; VAR_6 < sc->ctts_count; VAR_6++) {",
"int next = VAR_5 + sc->ctts_data[VAR_6].count;",
"if (next > sc->current_sample) {",
"sc->ctts_index = VAR_6;",
"sc->ctts_sample = sc->current_sample - VAR_5;",
"break;",
"}",
"VAR_5 = next;",
"}",
"}",
"VAR_5 = 0;",
"for (VAR_6 = 0; VAR_6 < sc->stsc_count; VAR_6++) {",
"int next = VAR_5 + mov_get_stsc_samples(sc, VAR_6);",
"if (next > sc->current_sample) {",
"sc->stsc_index = VAR_6;",
"sc->stsc_sample = sc->current_sample - VAR_5;",
"break;",
"}",
"VAR_5 = next;",
"}",
"return VAR_4;",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17,
19
],
[
21,
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
]
] |
25,888 | static int advanced_decode_i_mbs(VC9Context *v)
{
MpegEncContext *s = &v->s;
GetBitContext *gb = &v->s.gb;
int mqdiff, mquant, current_mb = 0, over_flags_mb = 0;
for (s->mb_y=0; s->mb_y<s->mb_height; s->mb_y++)
{
for (s->mb_x=0; s->mb_x<s->mb_width; s->mb_x++)
{
if (v->ac_pred_plane.is_raw)
s->ac_pred = get_bits(gb, 1);
else
s->ac_pred = v->ac_pred_plane.data[current_mb];
if (v->condover == 3 && v->over_flags_plane.is_raw)
over_flags_mb = get_bits(gb, 1);
GET_MQUANT();
/* TODO: lots */
}
current_mb++;
}
return 0;
}
| true | FFmpeg | 7cc84d241ba6ef8e27e4d057176a4ad385ad3d59 | static int advanced_decode_i_mbs(VC9Context *v)
{
MpegEncContext *s = &v->s;
GetBitContext *gb = &v->s.gb;
int mqdiff, mquant, current_mb = 0, over_flags_mb = 0;
for (s->mb_y=0; s->mb_y<s->mb_height; s->mb_y++)
{
for (s->mb_x=0; s->mb_x<s->mb_width; s->mb_x++)
{
if (v->ac_pred_plane.is_raw)
s->ac_pred = get_bits(gb, 1);
else
s->ac_pred = v->ac_pred_plane.data[current_mb];
if (v->condover == 3 && v->over_flags_plane.is_raw)
over_flags_mb = get_bits(gb, 1);
GET_MQUANT();
}
current_mb++;
}
return 0;
}
| {
"code": [
" GetBitContext *gb = &v->s.gb;",
" GetBitContext *gb = &v->s.gb;",
" int mqdiff, mquant, current_mb = 0, over_flags_mb = 0;",
" s->ac_pred = v->ac_pred_plane.data[current_mb];",
" current_mb++;"
],
"line_no": [
7,
7,
9,
27,
41
]
} | static int FUNC_0(VC9Context *VAR_0)
{
MpegEncContext *s = &VAR_0->s;
GetBitContext *gb = &VAR_0->s.gb;
int VAR_1, VAR_2, VAR_3 = 0, VAR_4 = 0;
for (s->mb_y=0; s->mb_y<s->mb_height; s->mb_y++)
{
for (s->mb_x=0; s->mb_x<s->mb_width; s->mb_x++)
{
if (VAR_0->ac_pred_plane.is_raw)
s->ac_pred = get_bits(gb, 1);
else
s->ac_pred = VAR_0->ac_pred_plane.data[VAR_3];
if (VAR_0->condover == 3 && VAR_0->over_flags_plane.is_raw)
VAR_4 = get_bits(gb, 1);
GET_MQUANT();
}
VAR_3++;
}
return 0;
}
| [
"static int FUNC_0(VC9Context *VAR_0)\n{",
"MpegEncContext *s = &VAR_0->s;",
"GetBitContext *gb = &VAR_0->s.gb;",
"int VAR_1, VAR_2, VAR_3 = 0, VAR_4 = 0;",
"for (s->mb_y=0; s->mb_y<s->mb_height; s->mb_y++)",
"{",
"for (s->mb_x=0; s->mb_x<s->mb_width; s->mb_x++)",
"{",
"if (VAR_0->ac_pred_plane.is_raw)\ns->ac_pred = get_bits(gb, 1);",
"else\ns->ac_pred = VAR_0->ac_pred_plane.data[VAR_3];",
"if (VAR_0->condover == 3 && VAR_0->over_flags_plane.is_raw)\nVAR_4 = get_bits(gb, 1);",
"GET_MQUANT();",
"}",
"VAR_3++;",
"}",
"return 0;",
"}"
] | [
0,
0,
1,
1,
0,
0,
0,
0,
0,
1,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21,
23
],
[
25,
27
],
[
29,
31
],
[
33
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
]
] |
25,890 | static int altivec_uyvy_rgb32 (SwsContext *c,
unsigned char **in, int *instrides,
int srcSliceY, int srcSliceH,
unsigned char **oplanes, int *outstrides)
{
int w = c->srcW;
int h = srcSliceH;
int i,j;
vector unsigned char uyvy;
vector signed short Y,U,V;
vector signed short R0,G0,B0,R1,G1,B1;
vector unsigned char R,G,B;
vector unsigned char *out;
ubyte *img;
img = in[0];
out = (vector unsigned char *)(oplanes[0]+srcSliceY*outstrides[0]);
for (i=0;i<h;i++) {
for (j=0;j<w/16;j++) {
uyvy = vec_ld (0, img);
U = (vector signed short)
vec_perm (uyvy, (vector unsigned char)AVV(0), demux_u);
V = (vector signed short)
vec_perm (uyvy, (vector unsigned char)AVV(0), demux_v);
Y = (vector signed short)
vec_perm (uyvy, (vector unsigned char)AVV(0), demux_y);
cvtyuvtoRGB (c, Y,U,V,&R0,&G0,&B0);
uyvy = vec_ld (16, img);
U = (vector signed short)
vec_perm (uyvy, (vector unsigned char)AVV(0), demux_u);
V = (vector signed short)
vec_perm (uyvy, (vector unsigned char)AVV(0), demux_v);
Y = (vector signed short)
vec_perm (uyvy, (vector unsigned char)AVV(0), demux_y);
cvtyuvtoRGB (c, Y,U,V,&R1,&G1,&B1);
R = vec_packclp (R0,R1);
G = vec_packclp (G0,G1);
B = vec_packclp (B0,B1);
// vec_mstbgr24 (R,G,B, out);
out_rgba (R,G,B,out);
img += 32;
}
}
return srcSliceH;
}
| true | FFmpeg | 428098165de4c3edfe42c1b7f00627d287015863 | static int altivec_uyvy_rgb32 (SwsContext *c,
unsigned char **in, int *instrides,
int srcSliceY, int srcSliceH,
unsigned char **oplanes, int *outstrides)
{
int w = c->srcW;
int h = srcSliceH;
int i,j;
vector unsigned char uyvy;
vector signed short Y,U,V;
vector signed short R0,G0,B0,R1,G1,B1;
vector unsigned char R,G,B;
vector unsigned char *out;
ubyte *img;
img = in[0];
out = (vector unsigned char *)(oplanes[0]+srcSliceY*outstrides[0]);
for (i=0;i<h;i++) {
for (j=0;j<w/16;j++) {
uyvy = vec_ld (0, img);
U = (vector signed short)
vec_perm (uyvy, (vector unsigned char)AVV(0), demux_u);
V = (vector signed short)
vec_perm (uyvy, (vector unsigned char)AVV(0), demux_v);
Y = (vector signed short)
vec_perm (uyvy, (vector unsigned char)AVV(0), demux_y);
cvtyuvtoRGB (c, Y,U,V,&R0,&G0,&B0);
uyvy = vec_ld (16, img);
U = (vector signed short)
vec_perm (uyvy, (vector unsigned char)AVV(0), demux_u);
V = (vector signed short)
vec_perm (uyvy, (vector unsigned char)AVV(0), demux_v);
Y = (vector signed short)
vec_perm (uyvy, (vector unsigned char)AVV(0), demux_y);
cvtyuvtoRGB (c, Y,U,V,&R1,&G1,&B1);
R = vec_packclp (R0,R1);
G = vec_packclp (G0,G1);
B = vec_packclp (B0,B1);
out_rgba (R,G,B,out);
img += 32;
}
}
return srcSliceH;
}
| {
"code": [
" int w = c->srcW;",
" int h = srcSliceH;",
" int i,j;",
" for (j=0;j<w/16;j++) {",
" return srcSliceH;",
"\t\t\t unsigned char **in, int *instrides,",
"\t\t\t int srcSliceY,\tint srcSliceH,",
"\t\t\t unsigned char **oplanes, int *outstrides)",
" int w = c->srcW;",
" int h = srcSliceH;",
" int i,j;",
" vector unsigned char uyvy;",
" vector signed short Y,U,V;",
" vector signed short R0,G0,B0,R1,G1,B1;",
" vector unsigned char R,G,B;",
" vector unsigned char *out;",
" ubyte *img;",
" img = in[0];",
" out = (vector unsigned char *)(oplanes[0]+srcSliceY*outstrides[0]);",
" for (i=0;i<h;i++) {",
" for (j=0;j<w/16;j++) {",
" uyvy = vec_ld (0, img);",
" U = (vector signed short)",
"\tvec_perm (uyvy, (vector unsigned char)AVV(0), demux_u);",
" V = (vector signed short)",
"\tvec_perm (uyvy, (vector unsigned char)AVV(0), demux_v);",
" Y = (vector signed short)",
"\tvec_perm (uyvy, (vector unsigned char)AVV(0), demux_y);",
" cvtyuvtoRGB (c, Y,U,V,&R0,&G0,&B0);",
" uyvy = vec_ld (16, img);",
" U = (vector signed short)",
"\tvec_perm (uyvy, (vector unsigned char)AVV(0), demux_u);",
" V = (vector signed short)",
"\tvec_perm (uyvy, (vector unsigned char)AVV(0), demux_v);",
" Y = (vector signed short)",
"\tvec_perm (uyvy, (vector unsigned char)AVV(0), demux_y);",
" cvtyuvtoRGB (c, Y,U,V,&R1,&G1,&B1);",
" R = vec_packclp (R0,R1);",
" G = vec_packclp (G0,G1);",
" B = vec_packclp (B0,B1);",
" out_rgba (R,G,B,out);",
" img += 32;",
" return srcSliceH;",
" int i,j;"
],
"line_no": [
11,
13,
15,
39,
109,
3,
5,
7,
11,
13,
15,
17,
19,
21,
23,
25,
27,
31,
33,
37,
39,
41,
43,
45,
49,
51,
55,
57,
61,
65,
43,
45,
49,
51,
55,
57,
85,
89,
91,
93,
99,
103,
109,
15
]
} | static int FUNC_0 (SwsContext *VAR_0,
unsigned char **VAR_1, int *VAR_2,
int VAR_3, int VAR_4,
unsigned char **VAR_5, int *VAR_6)
{
int VAR_7 = VAR_0->srcW;
int VAR_8 = VAR_4;
int VAR_9,VAR_10;
vector unsigned char uyvy;
vector signed short Y,U,V;
vector signed short R0,G0,B0,R1,G1,B1;
vector unsigned char R,G,B;
vector unsigned char *out;
ubyte *img;
img = VAR_1[0];
out = (vector unsigned char *)(VAR_5[0]+VAR_3*VAR_6[0]);
for (VAR_9=0;VAR_9<VAR_8;VAR_9++) {
for (VAR_10=0;VAR_10<VAR_7/16;VAR_10++) {
uyvy = vec_ld (0, img);
U = (vector signed short)
vec_perm (uyvy, (vector unsigned char)AVV(0), demux_u);
V = (vector signed short)
vec_perm (uyvy, (vector unsigned char)AVV(0), demux_v);
Y = (vector signed short)
vec_perm (uyvy, (vector unsigned char)AVV(0), demux_y);
cvtyuvtoRGB (VAR_0, Y,U,V,&R0,&G0,&B0);
uyvy = vec_ld (16, img);
U = (vector signed short)
vec_perm (uyvy, (vector unsigned char)AVV(0), demux_u);
V = (vector signed short)
vec_perm (uyvy, (vector unsigned char)AVV(0), demux_v);
Y = (vector signed short)
vec_perm (uyvy, (vector unsigned char)AVV(0), demux_y);
cvtyuvtoRGB (VAR_0, Y,U,V,&R1,&G1,&B1);
R = vec_packclp (R0,R1);
G = vec_packclp (G0,G1);
B = vec_packclp (B0,B1);
out_rgba (R,G,B,out);
img += 32;
}
}
return VAR_4;
}
| [
"static int FUNC_0 (SwsContext *VAR_0,\nunsigned char **VAR_1, int *VAR_2,\nint VAR_3,\tint VAR_4,\nunsigned char **VAR_5, int *VAR_6)\n{",
"int VAR_7 = VAR_0->srcW;",
"int VAR_8 = VAR_4;",
"int VAR_9,VAR_10;",
"vector unsigned char uyvy;",
"vector signed short Y,U,V;",
"vector signed short R0,G0,B0,R1,G1,B1;",
"vector unsigned char R,G,B;",
"vector unsigned char *out;",
"ubyte *img;",
"img = VAR_1[0];",
"out = (vector unsigned char *)(VAR_5[0]+VAR_3*VAR_6[0]);",
"for (VAR_9=0;VAR_9<VAR_8;VAR_9++) {",
"for (VAR_10=0;VAR_10<VAR_7/16;VAR_10++) {",
"uyvy = vec_ld (0, img);",
"U = (vector signed short)\nvec_perm (uyvy, (vector unsigned char)AVV(0), demux_u);",
"V = (vector signed short)\nvec_perm (uyvy, (vector unsigned char)AVV(0), demux_v);",
"Y = (vector signed short)\nvec_perm (uyvy, (vector unsigned char)AVV(0), demux_y);",
"cvtyuvtoRGB (VAR_0, Y,U,V,&R0,&G0,&B0);",
"uyvy = vec_ld (16, img);",
"U = (vector signed short)\nvec_perm (uyvy, (vector unsigned char)AVV(0), demux_u);",
"V = (vector signed short)\nvec_perm (uyvy, (vector unsigned char)AVV(0), demux_v);",
"Y = (vector signed short)\nvec_perm (uyvy, (vector unsigned char)AVV(0), demux_y);",
"cvtyuvtoRGB (VAR_0, Y,U,V,&R1,&G1,&B1);",
"R = vec_packclp (R0,R1);",
"G = vec_packclp (G0,G1);",
"B = vec_packclp (B0,B1);",
"out_rgba (R,G,B,out);",
"img += 32;",
"}",
"}",
"return VAR_4;",
"}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
1,
1,
1,
1,
1,
1,
0,
0,
1,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
49,
51
],
[
55,
57
],
[
61
],
[
65
],
[
67,
69
],
[
73,
75
],
[
79,
81
],
[
85
],
[
89
],
[
91
],
[
93
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
]
] |
25,891 | static void test_primitives(gconstpointer opaque)
{
TestArgs *args = (TestArgs *) opaque;
const SerializeOps *ops = args->ops;
PrimitiveType *pt = args->test_data;
PrimitiveType *pt_copy = g_malloc0(sizeof(*pt_copy));
Error *err = NULL;
void *serialize_data;
char *double1, *double2;
pt_copy->type = pt->type;
ops->serialize(pt, &serialize_data, visit_primitive_type, &err);
ops->deserialize((void **)&pt_copy, serialize_data, visit_primitive_type, &err);
g_assert(err == NULL);
g_assert(pt_copy != NULL);
if (pt->type == PTYPE_STRING) {
g_assert_cmpstr(pt->value.string, ==, pt_copy->value.string);
g_free((char *)pt_copy->value.string);
} else if (pt->type == PTYPE_NUMBER) {
/* we serialize with %f for our reference visitors, so rather than fuzzy
* floating math to test "equality", just compare the formatted values
*/
double1 = g_malloc0(calc_float_string_storage(pt->value.number));
double2 = g_malloc0(calc_float_string_storage(pt_copy->value.number));
g_assert_cmpstr(double1, ==, double2);
g_free(double1);
g_free(double2);
} else if (pt->type == PTYPE_BOOLEAN) {
g_assert_cmpint(!!pt->value.max, ==, !!pt->value.max);
} else {
g_assert_cmpint(pt->value.max, ==, pt_copy->value.max);
}
ops->cleanup(serialize_data);
g_free(args);
g_free(pt_copy);
}
| true | qemu | 089f26bb735fb414b79f5fa3753910d5339d2a1d | static void test_primitives(gconstpointer opaque)
{
TestArgs *args = (TestArgs *) opaque;
const SerializeOps *ops = args->ops;
PrimitiveType *pt = args->test_data;
PrimitiveType *pt_copy = g_malloc0(sizeof(*pt_copy));
Error *err = NULL;
void *serialize_data;
char *double1, *double2;
pt_copy->type = pt->type;
ops->serialize(pt, &serialize_data, visit_primitive_type, &err);
ops->deserialize((void **)&pt_copy, serialize_data, visit_primitive_type, &err);
g_assert(err == NULL);
g_assert(pt_copy != NULL);
if (pt->type == PTYPE_STRING) {
g_assert_cmpstr(pt->value.string, ==, pt_copy->value.string);
g_free((char *)pt_copy->value.string);
} else if (pt->type == PTYPE_NUMBER) {
double1 = g_malloc0(calc_float_string_storage(pt->value.number));
double2 = g_malloc0(calc_float_string_storage(pt_copy->value.number));
g_assert_cmpstr(double1, ==, double2);
g_free(double1);
g_free(double2);
} else if (pt->type == PTYPE_BOOLEAN) {
g_assert_cmpint(!!pt->value.max, ==, !!pt->value.max);
} else {
g_assert_cmpint(pt->value.max, ==, pt_copy->value.max);
}
ops->cleanup(serialize_data);
g_free(args);
g_free(pt_copy);
}
| {
"code": [
" char *double1, *double2;",
" double1 = g_malloc0(calc_float_string_storage(pt->value.number));",
" double2 = g_malloc0(calc_float_string_storage(pt_copy->value.number));",
" g_assert_cmpstr(double1, ==, double2);",
" g_free(double1);",
" g_free(double2);"
],
"line_no": [
17,
47,
49,
51,
53,
55
]
} | static void FUNC_0(gconstpointer VAR_0)
{
TestArgs *args = (TestArgs *) VAR_0;
const SerializeOps *VAR_1 = args->VAR_1;
PrimitiveType *pt = args->test_data;
PrimitiveType *pt_copy = g_malloc0(sizeof(*pt_copy));
Error *err = NULL;
void *VAR_2;
char *VAR_3, *VAR_4;
pt_copy->type = pt->type;
VAR_1->serialize(pt, &VAR_2, visit_primitive_type, &err);
VAR_1->deserialize((void **)&pt_copy, VAR_2, visit_primitive_type, &err);
g_assert(err == NULL);
g_assert(pt_copy != NULL);
if (pt->type == PTYPE_STRING) {
g_assert_cmpstr(pt->value.string, ==, pt_copy->value.string);
g_free((char *)pt_copy->value.string);
} else if (pt->type == PTYPE_NUMBER) {
VAR_3 = g_malloc0(calc_float_string_storage(pt->value.number));
VAR_4 = g_malloc0(calc_float_string_storage(pt_copy->value.number));
g_assert_cmpstr(VAR_3, ==, VAR_4);
g_free(VAR_3);
g_free(VAR_4);
} else if (pt->type == PTYPE_BOOLEAN) {
g_assert_cmpint(!!pt->value.max, ==, !!pt->value.max);
} else {
g_assert_cmpint(pt->value.max, ==, pt_copy->value.max);
}
VAR_1->cleanup(VAR_2);
g_free(args);
g_free(pt_copy);
}
| [
"static void FUNC_0(gconstpointer VAR_0)\n{",
"TestArgs *args = (TestArgs *) VAR_0;",
"const SerializeOps *VAR_1 = args->VAR_1;",
"PrimitiveType *pt = args->test_data;",
"PrimitiveType *pt_copy = g_malloc0(sizeof(*pt_copy));",
"Error *err = NULL;",
"void *VAR_2;",
"char *VAR_3, *VAR_4;",
"pt_copy->type = pt->type;",
"VAR_1->serialize(pt, &VAR_2, visit_primitive_type, &err);",
"VAR_1->deserialize((void **)&pt_copy, VAR_2, visit_primitive_type, &err);",
"g_assert(err == NULL);",
"g_assert(pt_copy != NULL);",
"if (pt->type == PTYPE_STRING) {",
"g_assert_cmpstr(pt->value.string, ==, pt_copy->value.string);",
"g_free((char *)pt_copy->value.string);",
"} else if (pt->type == PTYPE_NUMBER) {",
"VAR_3 = g_malloc0(calc_float_string_storage(pt->value.number));",
"VAR_4 = g_malloc0(calc_float_string_storage(pt_copy->value.number));",
"g_assert_cmpstr(VAR_3, ==, VAR_4);",
"g_free(VAR_3);",
"g_free(VAR_4);",
"} else if (pt->type == PTYPE_BOOLEAN) {",
"g_assert_cmpint(!!pt->value.max, ==, !!pt->value.max);",
"} else {",
"g_assert_cmpint(pt->value.max, ==, pt_copy->value.max);",
"}",
"VAR_1->cleanup(VAR_2);",
"g_free(args);",
"g_free(pt_copy);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
]
] |
25,892 | static int qcow_write_snapshots(BlockDriverState *bs)
{
BDRVQcowState *s = bs->opaque;
QCowSnapshot *sn;
QCowSnapshotHeader h;
int i, name_size, id_str_size, snapshots_size;
uint64_t data64;
uint32_t data32;
int64_t offset, snapshots_offset;
/* compute the size of the snapshots */
offset = 0;
for(i = 0; i < s->nb_snapshots; i++) {
sn = s->snapshots + i;
offset = align_offset(offset, 8);
offset += sizeof(h);
offset += strlen(sn->id_str);
offset += strlen(sn->name);
}
snapshots_size = offset;
snapshots_offset = qcow2_alloc_clusters(bs, snapshots_size);
offset = snapshots_offset;
if (offset < 0) {
return offset;
}
for(i = 0; i < s->nb_snapshots; i++) {
sn = s->snapshots + i;
memset(&h, 0, sizeof(h));
h.l1_table_offset = cpu_to_be64(sn->l1_table_offset);
h.l1_size = cpu_to_be32(sn->l1_size);
h.vm_state_size = cpu_to_be32(sn->vm_state_size);
h.date_sec = cpu_to_be32(sn->date_sec);
h.date_nsec = cpu_to_be32(sn->date_nsec);
h.vm_clock_nsec = cpu_to_be64(sn->vm_clock_nsec);
id_str_size = strlen(sn->id_str);
name_size = strlen(sn->name);
h.id_str_size = cpu_to_be16(id_str_size);
h.name_size = cpu_to_be16(name_size);
offset = align_offset(offset, 8);
if (bdrv_pwrite(bs->file, offset, &h, sizeof(h)) != sizeof(h))
goto fail;
offset += sizeof(h);
if (bdrv_pwrite(bs->file, offset, sn->id_str, id_str_size) != id_str_size)
goto fail;
offset += id_str_size;
if (bdrv_pwrite(bs->file, offset, sn->name, name_size) != name_size)
goto fail;
offset += name_size;
}
/* update the various header fields */
data64 = cpu_to_be64(snapshots_offset);
if (bdrv_pwrite(bs->file, offsetof(QCowHeader, snapshots_offset),
&data64, sizeof(data64)) != sizeof(data64))
goto fail;
data32 = cpu_to_be32(s->nb_snapshots);
if (bdrv_pwrite(bs->file, offsetof(QCowHeader, nb_snapshots),
&data32, sizeof(data32)) != sizeof(data32))
goto fail;
/* free the old snapshot table */
qcow2_free_clusters(bs, s->snapshots_offset, s->snapshots_size);
s->snapshots_offset = snapshots_offset;
s->snapshots_size = snapshots_size;
return 0;
fail:
return -1;
}
| true | qemu | 8b3b720620a1137a1b794fc3ed64734236f94e06 | static int qcow_write_snapshots(BlockDriverState *bs)
{
BDRVQcowState *s = bs->opaque;
QCowSnapshot *sn;
QCowSnapshotHeader h;
int i, name_size, id_str_size, snapshots_size;
uint64_t data64;
uint32_t data32;
int64_t offset, snapshots_offset;
offset = 0;
for(i = 0; i < s->nb_snapshots; i++) {
sn = s->snapshots + i;
offset = align_offset(offset, 8);
offset += sizeof(h);
offset += strlen(sn->id_str);
offset += strlen(sn->name);
}
snapshots_size = offset;
snapshots_offset = qcow2_alloc_clusters(bs, snapshots_size);
offset = snapshots_offset;
if (offset < 0) {
return offset;
}
for(i = 0; i < s->nb_snapshots; i++) {
sn = s->snapshots + i;
memset(&h, 0, sizeof(h));
h.l1_table_offset = cpu_to_be64(sn->l1_table_offset);
h.l1_size = cpu_to_be32(sn->l1_size);
h.vm_state_size = cpu_to_be32(sn->vm_state_size);
h.date_sec = cpu_to_be32(sn->date_sec);
h.date_nsec = cpu_to_be32(sn->date_nsec);
h.vm_clock_nsec = cpu_to_be64(sn->vm_clock_nsec);
id_str_size = strlen(sn->id_str);
name_size = strlen(sn->name);
h.id_str_size = cpu_to_be16(id_str_size);
h.name_size = cpu_to_be16(name_size);
offset = align_offset(offset, 8);
if (bdrv_pwrite(bs->file, offset, &h, sizeof(h)) != sizeof(h))
goto fail;
offset += sizeof(h);
if (bdrv_pwrite(bs->file, offset, sn->id_str, id_str_size) != id_str_size)
goto fail;
offset += id_str_size;
if (bdrv_pwrite(bs->file, offset, sn->name, name_size) != name_size)
goto fail;
offset += name_size;
}
data64 = cpu_to_be64(snapshots_offset);
if (bdrv_pwrite(bs->file, offsetof(QCowHeader, snapshots_offset),
&data64, sizeof(data64)) != sizeof(data64))
goto fail;
data32 = cpu_to_be32(s->nb_snapshots);
if (bdrv_pwrite(bs->file, offsetof(QCowHeader, nb_snapshots),
&data32, sizeof(data32)) != sizeof(data32))
goto fail;
qcow2_free_clusters(bs, s->snapshots_offset, s->snapshots_size);
s->snapshots_offset = snapshots_offset;
s->snapshots_size = snapshots_size;
return 0;
fail:
return -1;
}
| {
"code": [
" if (bdrv_pwrite(bs->file, offset, &h, sizeof(h)) != sizeof(h))",
" if (bdrv_pwrite(bs->file, offset, sn->id_str, id_str_size) != id_str_size)",
" if (bdrv_pwrite(bs->file, offset, sn->name, name_size) != name_size)",
" if (bdrv_pwrite(bs->file, offsetof(QCowHeader, snapshots_offset),",
" &data64, sizeof(data64)) != sizeof(data64))",
" if (bdrv_pwrite(bs->file, offsetof(QCowHeader, nb_snapshots),",
" &data32, sizeof(data32)) != sizeof(data32))"
],
"line_no": [
85,
91,
97,
111,
113,
119,
121
]
} | static int FUNC_0(BlockDriverState *VAR_0)
{
BDRVQcowState *s = VAR_0->opaque;
QCowSnapshot *sn;
QCowSnapshotHeader h;
int VAR_1, VAR_2, VAR_3, VAR_4;
uint64_t data64;
uint32_t data32;
int64_t offset, snapshots_offset;
offset = 0;
for(VAR_1 = 0; VAR_1 < s->nb_snapshots; VAR_1++) {
sn = s->snapshots + VAR_1;
offset = align_offset(offset, 8);
offset += sizeof(h);
offset += strlen(sn->id_str);
offset += strlen(sn->name);
}
VAR_4 = offset;
snapshots_offset = qcow2_alloc_clusters(VAR_0, VAR_4);
offset = snapshots_offset;
if (offset < 0) {
return offset;
}
for(VAR_1 = 0; VAR_1 < s->nb_snapshots; VAR_1++) {
sn = s->snapshots + VAR_1;
memset(&h, 0, sizeof(h));
h.l1_table_offset = cpu_to_be64(sn->l1_table_offset);
h.l1_size = cpu_to_be32(sn->l1_size);
h.vm_state_size = cpu_to_be32(sn->vm_state_size);
h.date_sec = cpu_to_be32(sn->date_sec);
h.date_nsec = cpu_to_be32(sn->date_nsec);
h.vm_clock_nsec = cpu_to_be64(sn->vm_clock_nsec);
VAR_3 = strlen(sn->id_str);
VAR_2 = strlen(sn->name);
h.VAR_3 = cpu_to_be16(VAR_3);
h.VAR_2 = cpu_to_be16(VAR_2);
offset = align_offset(offset, 8);
if (bdrv_pwrite(VAR_0->file, offset, &h, sizeof(h)) != sizeof(h))
goto fail;
offset += sizeof(h);
if (bdrv_pwrite(VAR_0->file, offset, sn->id_str, VAR_3) != VAR_3)
goto fail;
offset += VAR_3;
if (bdrv_pwrite(VAR_0->file, offset, sn->name, VAR_2) != VAR_2)
goto fail;
offset += VAR_2;
}
data64 = cpu_to_be64(snapshots_offset);
if (bdrv_pwrite(VAR_0->file, offsetof(QCowHeader, snapshots_offset),
&data64, sizeof(data64)) != sizeof(data64))
goto fail;
data32 = cpu_to_be32(s->nb_snapshots);
if (bdrv_pwrite(VAR_0->file, offsetof(QCowHeader, nb_snapshots),
&data32, sizeof(data32)) != sizeof(data32))
goto fail;
qcow2_free_clusters(VAR_0, s->snapshots_offset, s->VAR_4);
s->snapshots_offset = snapshots_offset;
s->VAR_4 = VAR_4;
return 0;
fail:
return -1;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"QCowSnapshot *sn;",
"QCowSnapshotHeader h;",
"int VAR_1, VAR_2, VAR_3, VAR_4;",
"uint64_t data64;",
"uint32_t data32;",
"int64_t offset, snapshots_offset;",
"offset = 0;",
"for(VAR_1 = 0; VAR_1 < s->nb_snapshots; VAR_1++) {",
"sn = s->snapshots + VAR_1;",
"offset = align_offset(offset, 8);",
"offset += sizeof(h);",
"offset += strlen(sn->id_str);",
"offset += strlen(sn->name);",
"}",
"VAR_4 = offset;",
"snapshots_offset = qcow2_alloc_clusters(VAR_0, VAR_4);",
"offset = snapshots_offset;",
"if (offset < 0) {",
"return offset;",
"}",
"for(VAR_1 = 0; VAR_1 < s->nb_snapshots; VAR_1++) {",
"sn = s->snapshots + VAR_1;",
"memset(&h, 0, sizeof(h));",
"h.l1_table_offset = cpu_to_be64(sn->l1_table_offset);",
"h.l1_size = cpu_to_be32(sn->l1_size);",
"h.vm_state_size = cpu_to_be32(sn->vm_state_size);",
"h.date_sec = cpu_to_be32(sn->date_sec);",
"h.date_nsec = cpu_to_be32(sn->date_nsec);",
"h.vm_clock_nsec = cpu_to_be64(sn->vm_clock_nsec);",
"VAR_3 = strlen(sn->id_str);",
"VAR_2 = strlen(sn->name);",
"h.VAR_3 = cpu_to_be16(VAR_3);",
"h.VAR_2 = cpu_to_be16(VAR_2);",
"offset = align_offset(offset, 8);",
"if (bdrv_pwrite(VAR_0->file, offset, &h, sizeof(h)) != sizeof(h))\ngoto fail;",
"offset += sizeof(h);",
"if (bdrv_pwrite(VAR_0->file, offset, sn->id_str, VAR_3) != VAR_3)\ngoto fail;",
"offset += VAR_3;",
"if (bdrv_pwrite(VAR_0->file, offset, sn->name, VAR_2) != VAR_2)\ngoto fail;",
"offset += VAR_2;",
"}",
"data64 = cpu_to_be64(snapshots_offset);",
"if (bdrv_pwrite(VAR_0->file, offsetof(QCowHeader, snapshots_offset),\n&data64, sizeof(data64)) != sizeof(data64))\ngoto fail;",
"data32 = cpu_to_be32(s->nb_snapshots);",
"if (bdrv_pwrite(VAR_0->file, offsetof(QCowHeader, nb_snapshots),\n&data32, sizeof(data32)) != sizeof(data32))\ngoto fail;",
"qcow2_free_clusters(VAR_0, s->snapshots_offset, s->VAR_4);",
"s->snapshots_offset = snapshots_offset;",
"s->VAR_4 = VAR_4;",
"return 0;",
"fail:\nreturn -1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
1,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85,
87
],
[
89
],
[
91,
93
],
[
95
],
[
97,
99
],
[
101
],
[
103
],
[
109
],
[
111,
113,
115
],
[
117
],
[
119,
121,
123
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137,
139
],
[
141
]
] |
25,893 | void sigaction_invoke(struct sigaction *action,
struct qemu_signalfd_siginfo *info)
{
siginfo_t si = { 0 };
si.si_signo = info->ssi_signo;
si.si_errno = info->ssi_errno;
si.si_code = info->ssi_code;
/* Convert the minimal set of fields defined by POSIX.
* Positive si_code values are reserved for kernel-generated
* signals, where the valid siginfo fields are determined by
* the signal number. But according to POSIX, it is unspecified
* whether SI_USER and SI_QUEUE have values less than or equal to
* zero.
*/
if (info->ssi_code == SI_USER || info->ssi_code == SI_QUEUE ||
info->ssi_code <= 0) {
/* SIGTERM, etc. */
si.si_pid = info->ssi_pid;
si.si_uid = info->ssi_uid;
} else if (info->ssi_signo == SIGILL || info->ssi_signo == SIGFPE ||
info->ssi_signo == SIGSEGV || info->ssi_signo == SIGBUS) {
si.si_addr = (void *)(uintptr_t)info->ssi_addr;
} else if (info->ssi_signo == SIGCHLD) {
si.si_pid = info->ssi_pid;
si.si_status = info->ssi_status;
si.si_uid = info->ssi_uid;
}
action->sa_sigaction(info->ssi_signo, &si, NULL);
}
| true | qemu | 02ffa034fb747f09a4f5658ed64871dcee4aaca2 | void sigaction_invoke(struct sigaction *action,
struct qemu_signalfd_siginfo *info)
{
siginfo_t si = { 0 };
si.si_signo = info->ssi_signo;
si.si_errno = info->ssi_errno;
si.si_code = info->ssi_code;
if (info->ssi_code == SI_USER || info->ssi_code == SI_QUEUE ||
info->ssi_code <= 0) {
si.si_pid = info->ssi_pid;
si.si_uid = info->ssi_uid;
} else if (info->ssi_signo == SIGILL || info->ssi_signo == SIGFPE ||
info->ssi_signo == SIGSEGV || info->ssi_signo == SIGBUS) {
si.si_addr = (void *)(uintptr_t)info->ssi_addr;
} else if (info->ssi_signo == SIGCHLD) {
si.si_pid = info->ssi_pid;
si.si_status = info->ssi_status;
si.si_uid = info->ssi_uid;
}
action->sa_sigaction(info->ssi_signo, &si, NULL);
}
| {
"code": [
" siginfo_t si = { 0 };"
],
"line_no": [
7
]
} | void FUNC_0(struct sigaction *VAR_0,
struct qemu_signalfd_siginfo *VAR_1)
{
siginfo_t si = { 0 };
si.si_signo = VAR_1->ssi_signo;
si.si_errno = VAR_1->ssi_errno;
si.si_code = VAR_1->ssi_code;
if (VAR_1->ssi_code == SI_USER || VAR_1->ssi_code == SI_QUEUE ||
VAR_1->ssi_code <= 0) {
si.si_pid = VAR_1->ssi_pid;
si.si_uid = VAR_1->ssi_uid;
} else if (VAR_1->ssi_signo == SIGILL || VAR_1->ssi_signo == SIGFPE ||
VAR_1->ssi_signo == SIGSEGV || VAR_1->ssi_signo == SIGBUS) {
si.si_addr = (void *)(uintptr_t)VAR_1->ssi_addr;
} else if (VAR_1->ssi_signo == SIGCHLD) {
si.si_pid = VAR_1->ssi_pid;
si.si_status = VAR_1->ssi_status;
si.si_uid = VAR_1->ssi_uid;
}
VAR_0->sa_sigaction(VAR_1->ssi_signo, &si, NULL);
}
| [
"void FUNC_0(struct sigaction *VAR_0,\nstruct qemu_signalfd_siginfo *VAR_1)\n{",
"siginfo_t si = { 0 };",
"si.si_signo = VAR_1->ssi_signo;",
"si.si_errno = VAR_1->ssi_errno;",
"si.si_code = VAR_1->ssi_code;",
"if (VAR_1->ssi_code == SI_USER || VAR_1->ssi_code == SI_QUEUE ||\nVAR_1->ssi_code <= 0) {",
"si.si_pid = VAR_1->ssi_pid;",
"si.si_uid = VAR_1->ssi_uid;",
"} else if (VAR_1->ssi_signo == SIGILL || VAR_1->ssi_signo == SIGFPE ||",
"VAR_1->ssi_signo == SIGSEGV || VAR_1->ssi_signo == SIGBUS) {",
"si.si_addr = (void *)(uintptr_t)VAR_1->ssi_addr;",
"} else if (VAR_1->ssi_signo == SIGCHLD) {",
"si.si_pid = VAR_1->ssi_pid;",
"si.si_status = VAR_1->ssi_status;",
"si.si_uid = VAR_1->ssi_uid;",
"}",
"VAR_0->sa_sigaction(VAR_1->ssi_signo, &si, NULL);",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
31,
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
]
] |
25,894 | static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
{
PixdescTestContext *priv = inlink->dst->priv;
AVFilterLink *outlink = inlink->dst->outputs[0];
AVFilterBufferRef *outpicref;
int i;
outlink->out_buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,
outlink->w, outlink->h);
outpicref = outlink->out_buf;
avfilter_copy_buffer_ref_props(outpicref, picref);
for (i = 0; i < 4; i++) {
int h = outlink->h;
h = i == 1 || i == 2 ? h>>priv->pix_desc->log2_chroma_h : h;
if (outpicref->data[i]) {
uint8_t *data = outpicref->data[i] +
(outpicref->linesize[i] > 0 ? 0 : outpicref->linesize[i] * (h-1));
memset(data, 0, FFABS(outpicref->linesize[i]) * h);
}
}
/* copy palette */
if (priv->pix_desc->flags & PIX_FMT_PAL)
memcpy(outpicref->data[1], outpicref->data[1], 256*4);
avfilter_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0));
}
| true | FFmpeg | 38d553322891c8e47182f05199d19888422167dc | static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
{
PixdescTestContext *priv = inlink->dst->priv;
AVFilterLink *outlink = inlink->dst->outputs[0];
AVFilterBufferRef *outpicref;
int i;
outlink->out_buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,
outlink->w, outlink->h);
outpicref = outlink->out_buf;
avfilter_copy_buffer_ref_props(outpicref, picref);
for (i = 0; i < 4; i++) {
int h = outlink->h;
h = i == 1 || i == 2 ? h>>priv->pix_desc->log2_chroma_h : h;
if (outpicref->data[i]) {
uint8_t *data = outpicref->data[i] +
(outpicref->linesize[i] > 0 ? 0 : outpicref->linesize[i] * (h-1));
memset(data, 0, FFABS(outpicref->linesize[i]) * h);
}
}
if (priv->pix_desc->flags & PIX_FMT_PAL)
memcpy(outpicref->data[1], outpicref->data[1], 256*4);
avfilter_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0));
}
| {
"code": [
" if (priv->pix_desc->flags & PIX_FMT_PAL)"
],
"line_no": [
47
]
} | static void FUNC_0(AVFilterLink *VAR_0, AVFilterBufferRef *VAR_1)
{
PixdescTestContext *priv = VAR_0->dst->priv;
AVFilterLink *outlink = VAR_0->dst->outputs[0];
AVFilterBufferRef *outpicref;
int VAR_2;
outlink->out_buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,
outlink->w, outlink->VAR_3);
outpicref = outlink->out_buf;
avfilter_copy_buffer_ref_props(outpicref, VAR_1);
for (VAR_2 = 0; VAR_2 < 4; VAR_2++) {
int VAR_3 = outlink->VAR_3;
VAR_3 = VAR_2 == 1 || VAR_2 == 2 ? VAR_3>>priv->pix_desc->log2_chroma_h : VAR_3;
if (outpicref->data[VAR_2]) {
uint8_t *data = outpicref->data[VAR_2] +
(outpicref->linesize[VAR_2] > 0 ? 0 : outpicref->linesize[VAR_2] * (VAR_3-1));
memset(data, 0, FFABS(outpicref->linesize[VAR_2]) * VAR_3);
}
}
if (priv->pix_desc->flags & PIX_FMT_PAL)
memcpy(outpicref->data[1], outpicref->data[1], 256*4);
avfilter_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0));
}
| [
"static void FUNC_0(AVFilterLink *VAR_0, AVFilterBufferRef *VAR_1)\n{",
"PixdescTestContext *priv = VAR_0->dst->priv;",
"AVFilterLink *outlink = VAR_0->dst->outputs[0];",
"AVFilterBufferRef *outpicref;",
"int VAR_2;",
"outlink->out_buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,\noutlink->w, outlink->VAR_3);",
"outpicref = outlink->out_buf;",
"avfilter_copy_buffer_ref_props(outpicref, VAR_1);",
"for (VAR_2 = 0; VAR_2 < 4; VAR_2++) {",
"int VAR_3 = outlink->VAR_3;",
"VAR_3 = VAR_2 == 1 || VAR_2 == 2 ? VAR_3>>priv->pix_desc->log2_chroma_h : VAR_3;",
"if (outpicref->data[VAR_2]) {",
"uint8_t *data = outpicref->data[VAR_2] +\n(outpicref->linesize[VAR_2] > 0 ? 0 : outpicref->linesize[VAR_2] * (VAR_3-1));",
"memset(data, 0, FFABS(outpicref->linesize[VAR_2]) * VAR_3);",
"}",
"}",
"if (priv->pix_desc->flags & PIX_FMT_PAL)\nmemcpy(outpicref->data[1], outpicref->data[1], 256*4);",
"avfilter_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0));",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
47,
49
],
[
53
],
[
55
]
] |
25,895 | void av_noreturn exit_program(int ret)
{
int i, j;
for (i = 0; i < nb_filtergraphs; i++) {
avfilter_graph_free(&filtergraphs[i]->graph);
for (j = 0; j < filtergraphs[i]->nb_inputs; j++)
av_freep(&filtergraphs[i]->inputs[j]);
av_freep(&filtergraphs[i]->inputs);
for (j = 0; j < filtergraphs[i]->nb_outputs; j++)
av_freep(&filtergraphs[i]->outputs[j]);
av_freep(&filtergraphs[i]->outputs);
av_freep(&filtergraphs[i]);
}
av_freep(&filtergraphs);
/* close files */
for (i = 0; i < nb_output_files; i++) {
AVFormatContext *s = output_files[i]->ctx;
if (!(s->oformat->flags & AVFMT_NOFILE) && s->pb)
avio_close(s->pb);
avformat_free_context(s);
av_dict_free(&output_files[i]->opts);
av_freep(&output_files[i]);
}
for (i = 0; i < nb_output_streams; i++) {
AVBitStreamFilterContext *bsfc = output_streams[i]->bitstream_filters;
while (bsfc) {
AVBitStreamFilterContext *next = bsfc->next;
av_bitstream_filter_close(bsfc);
bsfc = next;
}
output_streams[i]->bitstream_filters = NULL;
if (output_streams[i]->output_frame) {
AVFrame *frame = output_streams[i]->output_frame;
if (frame->extended_data != frame->data)
av_freep(&frame->extended_data);
av_freep(&frame);
}
av_freep(&output_streams[i]->filtered_frame);
av_freep(&output_streams[i]);
}
for (i = 0; i < nb_input_files; i++) {
avformat_close_input(&input_files[i]->ctx);
av_freep(&input_files[i]);
}
for (i = 0; i < nb_input_streams; i++) {
av_freep(&input_streams[i]->decoded_frame);
av_dict_free(&input_streams[i]->opts);
free_buffer_pool(input_streams[i]);
av_freep(&input_streams[i]->filters);
av_freep(&input_streams[i]);
}
if (vstats_file)
fclose(vstats_file);
av_free(vstats_filename);
av_freep(&input_streams);
av_freep(&input_files);
av_freep(&output_streams);
av_freep(&output_files);
uninit_opts();
av_freep(&audio_buf);
allocated_audio_buf_size = 0;
av_freep(&async_buf);
allocated_async_buf_size = 0;
avfilter_uninit();
avformat_network_deinit();
if (received_sigterm) {
av_log(NULL, AV_LOG_INFO, "Received signal %d: terminating.\n",
(int) received_sigterm);
exit (255);
}
exit(ret); /* not all OS-es handle main() return value */
}
| true | FFmpeg | fc49f22c3b735db5aaac5f98e40b7124a2be13b8 | void av_noreturn exit_program(int ret)
{
int i, j;
for (i = 0; i < nb_filtergraphs; i++) {
avfilter_graph_free(&filtergraphs[i]->graph);
for (j = 0; j < filtergraphs[i]->nb_inputs; j++)
av_freep(&filtergraphs[i]->inputs[j]);
av_freep(&filtergraphs[i]->inputs);
for (j = 0; j < filtergraphs[i]->nb_outputs; j++)
av_freep(&filtergraphs[i]->outputs[j]);
av_freep(&filtergraphs[i]->outputs);
av_freep(&filtergraphs[i]);
}
av_freep(&filtergraphs);
for (i = 0; i < nb_output_files; i++) {
AVFormatContext *s = output_files[i]->ctx;
if (!(s->oformat->flags & AVFMT_NOFILE) && s->pb)
avio_close(s->pb);
avformat_free_context(s);
av_dict_free(&output_files[i]->opts);
av_freep(&output_files[i]);
}
for (i = 0; i < nb_output_streams; i++) {
AVBitStreamFilterContext *bsfc = output_streams[i]->bitstream_filters;
while (bsfc) {
AVBitStreamFilterContext *next = bsfc->next;
av_bitstream_filter_close(bsfc);
bsfc = next;
}
output_streams[i]->bitstream_filters = NULL;
if (output_streams[i]->output_frame) {
AVFrame *frame = output_streams[i]->output_frame;
if (frame->extended_data != frame->data)
av_freep(&frame->extended_data);
av_freep(&frame);
}
av_freep(&output_streams[i]->filtered_frame);
av_freep(&output_streams[i]);
}
for (i = 0; i < nb_input_files; i++) {
avformat_close_input(&input_files[i]->ctx);
av_freep(&input_files[i]);
}
for (i = 0; i < nb_input_streams; i++) {
av_freep(&input_streams[i]->decoded_frame);
av_dict_free(&input_streams[i]->opts);
free_buffer_pool(input_streams[i]);
av_freep(&input_streams[i]->filters);
av_freep(&input_streams[i]);
}
if (vstats_file)
fclose(vstats_file);
av_free(vstats_filename);
av_freep(&input_streams);
av_freep(&input_files);
av_freep(&output_streams);
av_freep(&output_files);
uninit_opts();
av_freep(&audio_buf);
allocated_audio_buf_size = 0;
av_freep(&async_buf);
allocated_async_buf_size = 0;
avfilter_uninit();
avformat_network_deinit();
if (received_sigterm) {
av_log(NULL, AV_LOG_INFO, "Received signal %d: terminating.\n",
(int) received_sigterm);
exit (255);
}
exit(ret);
}
| {
"code": [
" if (output_streams[i]->output_frame) {",
" AVFrame *frame = output_streams[i]->output_frame;",
" if (frame->extended_data != frame->data)",
" av_freep(&frame->extended_data);",
" av_freep(&frame);",
" av_freep(&audio_buf);",
" allocated_audio_buf_size = 0;",
" av_freep(&async_buf);",
" allocated_async_buf_size = 0;",
" for (i = 0; i < nb_output_streams; i++) {"
],
"line_no": [
69,
71,
73,
75,
77,
131,
133,
135,
137,
51
]
} | void VAR_0 exit_program(int ret)
{
int i, j;
for (i = 0; i < nb_filtergraphs; i++) {
avfilter_graph_free(&filtergraphs[i]->graph);
for (j = 0; j < filtergraphs[i]->nb_inputs; j++)
av_freep(&filtergraphs[i]->inputs[j]);
av_freep(&filtergraphs[i]->inputs);
for (j = 0; j < filtergraphs[i]->nb_outputs; j++)
av_freep(&filtergraphs[i]->outputs[j]);
av_freep(&filtergraphs[i]->outputs);
av_freep(&filtergraphs[i]);
}
av_freep(&filtergraphs);
for (i = 0; i < nb_output_files; i++) {
AVFormatContext *s = output_files[i]->ctx;
if (!(s->oformat->flags & AVFMT_NOFILE) && s->pb)
avio_close(s->pb);
avformat_free_context(s);
av_dict_free(&output_files[i]->opts);
av_freep(&output_files[i]);
}
for (i = 0; i < nb_output_streams; i++) {
AVBitStreamFilterContext *bsfc = output_streams[i]->bitstream_filters;
while (bsfc) {
AVBitStreamFilterContext *next = bsfc->next;
av_bitstream_filter_close(bsfc);
bsfc = next;
}
output_streams[i]->bitstream_filters = NULL;
if (output_streams[i]->output_frame) {
AVFrame *frame = output_streams[i]->output_frame;
if (frame->extended_data != frame->data)
av_freep(&frame->extended_data);
av_freep(&frame);
}
av_freep(&output_streams[i]->filtered_frame);
av_freep(&output_streams[i]);
}
for (i = 0; i < nb_input_files; i++) {
avformat_close_input(&input_files[i]->ctx);
av_freep(&input_files[i]);
}
for (i = 0; i < nb_input_streams; i++) {
av_freep(&input_streams[i]->decoded_frame);
av_dict_free(&input_streams[i]->opts);
free_buffer_pool(input_streams[i]);
av_freep(&input_streams[i]->filters);
av_freep(&input_streams[i]);
}
if (vstats_file)
fclose(vstats_file);
av_free(vstats_filename);
av_freep(&input_streams);
av_freep(&input_files);
av_freep(&output_streams);
av_freep(&output_files);
uninit_opts();
av_freep(&audio_buf);
allocated_audio_buf_size = 0;
av_freep(&async_buf);
allocated_async_buf_size = 0;
avfilter_uninit();
avformat_network_deinit();
if (received_sigterm) {
av_log(NULL, AV_LOG_INFO, "Received signal %d: terminating.\n",
(int) received_sigterm);
exit (255);
}
exit(ret);
}
| [
"void VAR_0 exit_program(int ret)\n{",
"int i, j;",
"for (i = 0; i < nb_filtergraphs; i++) {",
"avfilter_graph_free(&filtergraphs[i]->graph);",
"for (j = 0; j < filtergraphs[i]->nb_inputs; j++)",
"av_freep(&filtergraphs[i]->inputs[j]);",
"av_freep(&filtergraphs[i]->inputs);",
"for (j = 0; j < filtergraphs[i]->nb_outputs; j++)",
"av_freep(&filtergraphs[i]->outputs[j]);",
"av_freep(&filtergraphs[i]->outputs);",
"av_freep(&filtergraphs[i]);",
"}",
"av_freep(&filtergraphs);",
"for (i = 0; i < nb_output_files; i++) {",
"AVFormatContext *s = output_files[i]->ctx;",
"if (!(s->oformat->flags & AVFMT_NOFILE) && s->pb)\navio_close(s->pb);",
"avformat_free_context(s);",
"av_dict_free(&output_files[i]->opts);",
"av_freep(&output_files[i]);",
"}",
"for (i = 0; i < nb_output_streams; i++) {",
"AVBitStreamFilterContext *bsfc = output_streams[i]->bitstream_filters;",
"while (bsfc) {",
"AVBitStreamFilterContext *next = bsfc->next;",
"av_bitstream_filter_close(bsfc);",
"bsfc = next;",
"}",
"output_streams[i]->bitstream_filters = NULL;",
"if (output_streams[i]->output_frame) {",
"AVFrame *frame = output_streams[i]->output_frame;",
"if (frame->extended_data != frame->data)\nav_freep(&frame->extended_data);",
"av_freep(&frame);",
"}",
"av_freep(&output_streams[i]->filtered_frame);",
"av_freep(&output_streams[i]);",
"}",
"for (i = 0; i < nb_input_files; i++) {",
"avformat_close_input(&input_files[i]->ctx);",
"av_freep(&input_files[i]);",
"}",
"for (i = 0; i < nb_input_streams; i++) {",
"av_freep(&input_streams[i]->decoded_frame);",
"av_dict_free(&input_streams[i]->opts);",
"free_buffer_pool(input_streams[i]);",
"av_freep(&input_streams[i]->filters);",
"av_freep(&input_streams[i]);",
"}",
"if (vstats_file)\nfclose(vstats_file);",
"av_free(vstats_filename);",
"av_freep(&input_streams);",
"av_freep(&input_files);",
"av_freep(&output_streams);",
"av_freep(&output_files);",
"uninit_opts();",
"av_freep(&audio_buf);",
"allocated_audio_buf_size = 0;",
"av_freep(&async_buf);",
"allocated_async_buf_size = 0;",
"avfilter_uninit();",
"avformat_network_deinit();",
"if (received_sigterm) {",
"av_log(NULL, AV_LOG_INFO, \"Received signal %d: terminating.\\n\",\n(int) received_sigterm);",
"exit (255);",
"}",
"exit(ret);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111,
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
147
],
[
149,
151
],
[
153
],
[
155
],
[
159
],
[
161
]
] |
25,896 | static void openrisc_pic_cpu_handler(void *opaque, int irq, int level)
{
OpenRISCCPU *cpu = (OpenRISCCPU *)opaque;
CPUState *cs = CPU(cpu);
uint32_t irq_bit = 1 << irq;
if (irq > 31 || irq < 0) {
return;
}
if (level) {
cpu->env.picsr |= irq_bit;
} else {
cpu->env.picsr &= ~irq_bit;
}
if (cpu->env.picsr & cpu->env.picmr) {
cpu_interrupt(cs, CPU_INTERRUPT_HARD);
} else {
cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD);
cpu->env.picsr = 0;
}
}
| true | qemu | 7717f248eebdcfe6de400404d0cf65dcb3633308 | static void openrisc_pic_cpu_handler(void *opaque, int irq, int level)
{
OpenRISCCPU *cpu = (OpenRISCCPU *)opaque;
CPUState *cs = CPU(cpu);
uint32_t irq_bit = 1 << irq;
if (irq > 31 || irq < 0) {
return;
}
if (level) {
cpu->env.picsr |= irq_bit;
} else {
cpu->env.picsr &= ~irq_bit;
}
if (cpu->env.picsr & cpu->env.picmr) {
cpu_interrupt(cs, CPU_INTERRUPT_HARD);
} else {
cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD);
cpu->env.picsr = 0;
}
}
| {
"code": [
" uint32_t irq_bit = 1 << irq;"
],
"line_no": [
9
]
} | static void FUNC_0(void *VAR_0, int VAR_1, int VAR_2)
{
OpenRISCCPU *cpu = (OpenRISCCPU *)VAR_0;
CPUState *cs = CPU(cpu);
uint32_t irq_bit = 1 << VAR_1;
if (VAR_1 > 31 || VAR_1 < 0) {
return;
}
if (VAR_2) {
cpu->env.picsr |= irq_bit;
} else {
cpu->env.picsr &= ~irq_bit;
}
if (cpu->env.picsr & cpu->env.picmr) {
cpu_interrupt(cs, CPU_INTERRUPT_HARD);
} else {
cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD);
cpu->env.picsr = 0;
}
}
| [
"static void FUNC_0(void *VAR_0, int VAR_1, int VAR_2)\n{",
"OpenRISCCPU *cpu = (OpenRISCCPU *)VAR_0;",
"CPUState *cs = CPU(cpu);",
"uint32_t irq_bit = 1 << VAR_1;",
"if (VAR_1 > 31 || VAR_1 < 0) {",
"return;",
"}",
"if (VAR_2) {",
"cpu->env.picsr |= irq_bit;",
"} else {",
"cpu->env.picsr &= ~irq_bit;",
"}",
"if (cpu->env.picsr & cpu->env.picmr) {",
"cpu_interrupt(cs, CPU_INTERRUPT_HARD);",
"} else {",
"cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD);",
"cpu->env.picsr = 0;",
"}",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
]
] |
25,897 | static int mov_read_aclr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
int ret = 0;
int length = 0;
uint64_t original_size;
if (c->fc->nb_streams >= 1) {
AVCodecContext *codec = c->fc->streams[c->fc->nb_streams-1]->codec;
if (codec->codec_id == AV_CODEC_ID_H264)
return 0;
if (atom.size == 16) {
original_size = codec->extradata_size;
ret = mov_realloc_extradata(codec, atom);
if (!ret) {
length = mov_read_atom_into_extradata(c, pb, atom, codec, codec->extradata + original_size);
if (length == atom.size) {
const uint8_t range_value = codec->extradata[original_size + 19];
switch (range_value) {
case 1:
codec->color_range = AVCOL_RANGE_MPEG;
break;
case 2:
codec->color_range = AVCOL_RANGE_JPEG;
break;
default:
av_log(c, AV_LOG_WARNING, "ignored unknown aclr value (%d)\n", range_value);
break;
}
av_dlog(c, "color_range: %d\n", codec->color_range);
} else {
/* For some reason the whole atom was not added to the extradata */
av_log(c, AV_LOG_ERROR, "aclr not decoded - incomplete atom\n");
}
} else {
av_log(c, AV_LOG_ERROR, "aclr not decoded - unable to add atom to extradata\n");
}
} else {
av_log(c, AV_LOG_WARNING, "aclr not decoded - unexpected size %"PRId64"\n", atom.size);
}
}
return ret;
}
| false | FFmpeg | 229843aa359ae0c9519977d7fa952688db63f559 | static int mov_read_aclr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
int ret = 0;
int length = 0;
uint64_t original_size;
if (c->fc->nb_streams >= 1) {
AVCodecContext *codec = c->fc->streams[c->fc->nb_streams-1]->codec;
if (codec->codec_id == AV_CODEC_ID_H264)
return 0;
if (atom.size == 16) {
original_size = codec->extradata_size;
ret = mov_realloc_extradata(codec, atom);
if (!ret) {
length = mov_read_atom_into_extradata(c, pb, atom, codec, codec->extradata + original_size);
if (length == atom.size) {
const uint8_t range_value = codec->extradata[original_size + 19];
switch (range_value) {
case 1:
codec->color_range = AVCOL_RANGE_MPEG;
break;
case 2:
codec->color_range = AVCOL_RANGE_JPEG;
break;
default:
av_log(c, AV_LOG_WARNING, "ignored unknown aclr value (%d)\n", range_value);
break;
}
av_dlog(c, "color_range: %d\n", codec->color_range);
} else {
av_log(c, AV_LOG_ERROR, "aclr not decoded - incomplete atom\n");
}
} else {
av_log(c, AV_LOG_ERROR, "aclr not decoded - unable to add atom to extradata\n");
}
} else {
av_log(c, AV_LOG_WARNING, "aclr not decoded - unexpected size %"PRId64"\n", atom.size);
}
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MOVContext *VAR_0, AVIOContext *VAR_1, MOVAtom VAR_2)
{
int VAR_3 = 0;
int VAR_4 = 0;
uint64_t original_size;
if (VAR_0->fc->nb_streams >= 1) {
AVCodecContext *codec = VAR_0->fc->streams[VAR_0->fc->nb_streams-1]->codec;
if (codec->codec_id == AV_CODEC_ID_H264)
return 0;
if (VAR_2.size == 16) {
original_size = codec->extradata_size;
VAR_3 = mov_realloc_extradata(codec, VAR_2);
if (!VAR_3) {
VAR_4 = mov_read_atom_into_extradata(VAR_0, VAR_1, VAR_2, codec, codec->extradata + original_size);
if (VAR_4 == VAR_2.size) {
const uint8_t VAR_5 = codec->extradata[original_size + 19];
switch (VAR_5) {
case 1:
codec->color_range = AVCOL_RANGE_MPEG;
break;
case 2:
codec->color_range = AVCOL_RANGE_JPEG;
break;
default:
av_log(VAR_0, AV_LOG_WARNING, "ignored unknown aclr value (%d)\n", VAR_5);
break;
}
av_dlog(VAR_0, "color_range: %d\n", codec->color_range);
} else {
av_log(VAR_0, AV_LOG_ERROR, "aclr not decoded - incomplete VAR_2\n");
}
} else {
av_log(VAR_0, AV_LOG_ERROR, "aclr not decoded - unable to add VAR_2 to extradata\n");
}
} else {
av_log(VAR_0, AV_LOG_WARNING, "aclr not decoded - unexpected size %"PRId64"\n", VAR_2.size);
}
}
return VAR_3;
}
| [
"static int FUNC_0(MOVContext *VAR_0, AVIOContext *VAR_1, MOVAtom VAR_2)\n{",
"int VAR_3 = 0;",
"int VAR_4 = 0;",
"uint64_t original_size;",
"if (VAR_0->fc->nb_streams >= 1) {",
"AVCodecContext *codec = VAR_0->fc->streams[VAR_0->fc->nb_streams-1]->codec;",
"if (codec->codec_id == AV_CODEC_ID_H264)\nreturn 0;",
"if (VAR_2.size == 16) {",
"original_size = codec->extradata_size;",
"VAR_3 = mov_realloc_extradata(codec, VAR_2);",
"if (!VAR_3) {",
"VAR_4 = mov_read_atom_into_extradata(VAR_0, VAR_1, VAR_2, codec, codec->extradata + original_size);",
"if (VAR_4 == VAR_2.size) {",
"const uint8_t VAR_5 = codec->extradata[original_size + 19];",
"switch (VAR_5) {",
"case 1:\ncodec->color_range = AVCOL_RANGE_MPEG;",
"break;",
"case 2:\ncodec->color_range = AVCOL_RANGE_JPEG;",
"break;",
"default:\nav_log(VAR_0, AV_LOG_WARNING, \"ignored unknown aclr value (%d)\\n\", VAR_5);",
"break;",
"}",
"av_dlog(VAR_0, \"color_range: %d\\n\", codec->color_range);",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR, \"aclr not decoded - incomplete VAR_2\\n\");",
"}",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR, \"aclr not decoded - unable to add VAR_2 to extradata\\n\");",
"}",
"} else {",
"av_log(VAR_0, AV_LOG_WARNING, \"aclr not decoded - unexpected size %\"PRId64\"\\n\", VAR_2.size);",
"}",
"}",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41,
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
]
] |
25,898 | static av_always_inline void filter_level_for_mb(VP8Context *s, VP8Macroblock *mb, VP8FilterStrength *f )
{
int interior_limit, filter_level;
if (s->segmentation.enabled) {
filter_level = s->segmentation.filter_level[s->segment];
if (!s->segmentation.absolute_vals)
filter_level += s->filter.level;
} else
filter_level = s->filter.level;
if (s->lf_delta.enabled) {
filter_level += s->lf_delta.ref[mb->ref_frame];
filter_level += s->lf_delta.mode[mb->mode];
}
/* Like av_clip for inputs 0 and max, where max is equal to (2^n-1) */
#define POW2CLIP(x,max) (((x) & ~max) ? (-(x))>>31 & max : (x));
filter_level = POW2CLIP(filter_level, 63);
interior_limit = filter_level;
if (s->filter.sharpness) {
interior_limit >>= s->filter.sharpness > 4 ? 2 : 1;
interior_limit = FFMIN(interior_limit, 9 - s->filter.sharpness);
}
interior_limit = FFMAX(interior_limit, 1);
f->filter_level = filter_level;
f->inner_limit = interior_limit;
f->inner_filter = !mb->skip || mb->mode == MODE_I4x4 || mb->mode == VP8_MVMODE_SPLIT;
}
| false | FFmpeg | e9266a2be04ea505285e32e411ef6120e9cbeba4 | static av_always_inline void filter_level_for_mb(VP8Context *s, VP8Macroblock *mb, VP8FilterStrength *f )
{
int interior_limit, filter_level;
if (s->segmentation.enabled) {
filter_level = s->segmentation.filter_level[s->segment];
if (!s->segmentation.absolute_vals)
filter_level += s->filter.level;
} else
filter_level = s->filter.level;
if (s->lf_delta.enabled) {
filter_level += s->lf_delta.ref[mb->ref_frame];
filter_level += s->lf_delta.mode[mb->mode];
}
#define POW2CLIP(x,max) (((x) & ~max) ? (-(x))>>31 & max : (x));
filter_level = POW2CLIP(filter_level, 63);
interior_limit = filter_level;
if (s->filter.sharpness) {
interior_limit >>= s->filter.sharpness > 4 ? 2 : 1;
interior_limit = FFMIN(interior_limit, 9 - s->filter.sharpness);
}
interior_limit = FFMAX(interior_limit, 1);
f->filter_level = filter_level;
f->inner_limit = interior_limit;
f->inner_filter = !mb->skip || mb->mode == MODE_I4x4 || mb->mode == VP8_MVMODE_SPLIT;
}
| {
"code": [],
"line_no": []
} | static av_always_inline void FUNC_0(VP8Context *s, VP8Macroblock *mb, VP8FilterStrength *f )
{
int VAR_0, VAR_1;
if (s->segmentation.enabled) {
VAR_1 = s->segmentation.VAR_1[s->segment];
if (!s->segmentation.absolute_vals)
VAR_1 += s->filter.level;
} else
VAR_1 = s->filter.level;
if (s->lf_delta.enabled) {
VAR_1 += s->lf_delta.ref[mb->ref_frame];
VAR_1 += s->lf_delta.mode[mb->mode];
}
#define POW2CLIP(x,max) (((x) & ~max) ? (-(x))>>31 & max : (x));
VAR_1 = POW2CLIP(VAR_1, 63);
VAR_0 = VAR_1;
if (s->filter.sharpness) {
VAR_0 >>= s->filter.sharpness > 4 ? 2 : 1;
VAR_0 = FFMIN(VAR_0, 9 - s->filter.sharpness);
}
VAR_0 = FFMAX(VAR_0, 1);
f->VAR_1 = VAR_1;
f->inner_limit = VAR_0;
f->inner_filter = !mb->skip || mb->mode == MODE_I4x4 || mb->mode == VP8_MVMODE_SPLIT;
}
| [
"static av_always_inline void FUNC_0(VP8Context *s, VP8Macroblock *mb, VP8FilterStrength *f )\n{",
"int VAR_0, VAR_1;",
"if (s->segmentation.enabled) {",
"VAR_1 = s->segmentation.VAR_1[s->segment];",
"if (!s->segmentation.absolute_vals)\nVAR_1 += s->filter.level;",
"} else",
"VAR_1 = s->filter.level;",
"if (s->lf_delta.enabled) {",
"VAR_1 += s->lf_delta.ref[mb->ref_frame];",
"VAR_1 += s->lf_delta.mode[mb->mode];",
"}",
"#define POW2CLIP(x,max) (((x) & ~max) ? (-(x))>>31 & max : (x));",
"VAR_1 = POW2CLIP(VAR_1, 63);",
"VAR_0 = VAR_1;",
"if (s->filter.sharpness) {",
"VAR_0 >>= s->filter.sharpness > 4 ? 2 : 1;",
"VAR_0 = FFMIN(VAR_0, 9 - s->filter.sharpness);",
"}",
"VAR_0 = FFMAX(VAR_0, 1);",
"f->VAR_1 = VAR_1;",
"f->inner_limit = VAR_0;",
"f->inner_filter = !mb->skip || mb->mode == MODE_I4x4 || mb->mode == VP8_MVMODE_SPLIT;",
"}"
] | [
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
],
[
23
],
[
25
],
[
27
],
[
29
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
]
] |
25,899 | void rgb15tobgr16(const uint8_t *src, uint8_t *dst, long src_size)
{
long i;
long num_pixels = src_size >> 1;
for(i=0; i<num_pixels; i++)
{
unsigned b,g,r;
register uint16_t rgb;
rgb = src[2*i];
r = rgb&0x1F;
g = (rgb&0x3E0)>>5;
b = (rgb&0x7C00)>>10;
dst[2*i] = (b&0x1F) | ((g&0x3F)<<5) | ((r&0x1F)<<11);
}
}
| true | FFmpeg | 6e42e6c4b410dbef8b593c2d796a5dad95f89ee4 | void rgb15tobgr16(const uint8_t *src, uint8_t *dst, long src_size)
{
long i;
long num_pixels = src_size >> 1;
for(i=0; i<num_pixels; i++)
{
unsigned b,g,r;
register uint16_t rgb;
rgb = src[2*i];
r = rgb&0x1F;
g = (rgb&0x3E0)>>5;
b = (rgb&0x7C00)>>10;
dst[2*i] = (b&0x1F) | ((g&0x3F)<<5) | ((r&0x1F)<<11);
}
}
| {
"code": [
"\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++)",
"\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;",
"\tfor(i=0; i<num_pixels; i++)",
"\tlong i;",
"\tlong i;",
"\tlong num_pixels = src_size >> 1;",
"\tfor(i=0; i<num_pixels; i++)",
"\t unsigned b,g,r;",
"\t register uint16_t rgb;",
"\t rgb = src[2*i];",
"\t r = rgb&0x1F;",
"\t dst[2*i] = (b&0x1F) | ((g&0x3F)<<5) | ((r&0x1F)<<11);",
"\tlong i;",
"\tlong num_pixels = src_size >> 1;",
"\tfor(i=0; i<num_pixels; i++)",
"\t unsigned b,g,r;",
"\t register uint16_t rgb;",
"\t rgb = src[2*i];",
"\t r = rgb&0x1F;",
"\tlong i;",
"\tlong num_pixels = src_size >> 1;",
"\tfor(i=0; i<num_pixels; i++)",
"\t unsigned b,g,r;",
"\t register uint16_t rgb;",
"\t rgb = src[2*i];",
"\t r = rgb&0x1F;",
"\t g = (rgb&0x3E0)>>5;",
"\t b = (rgb&0x7C00)>>10;",
"\t dst[2*i] = (b&0x1F) | ((g&0x3F)<<5) | ((r&0x1F)<<11);",
"\tlong i;",
"\tlong num_pixels = src_size >> 1;",
"\tfor(i=0; i<num_pixels; i++)",
"\t unsigned b,g,r;",
"\t register uint16_t rgb;",
"\t rgb = src[2*i];",
"\t r = rgb&0x1F;",
"\t g = (rgb&0x3E0)>>5;",
"\t b = (rgb&0x7C00)>>10;",
"\tlong i;",
"\tfor(i=0; i<num_pixels; i++)",
"\t unsigned b,g,r;"
],
"line_no": [
5,
11,
11,
5,
11,
5,
11,
11,
5,
11,
11,
5,
11,
5,
11,
5,
11,
5,
11,
5,
11,
5,
5,
7,
11,
15,
17,
19,
21,
27,
5,
7,
11,
15,
17,
19,
21,
5,
7,
11,
15,
17,
19,
21,
23,
25,
27,
5,
7,
11,
15,
17,
19,
21,
23,
25,
5,
11,
15
]
} | void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, long VAR_2)
{
long VAR_3;
long VAR_4 = VAR_2 >> 1;
for(VAR_3=0; VAR_3<VAR_4; VAR_3++)
{
unsigned VAR_5,VAR_6,VAR_7;
register uint16_t VAR_8;
VAR_8 = VAR_0[2*VAR_3];
VAR_7 = VAR_8&0x1F;
VAR_6 = (VAR_8&0x3E0)>>5;
VAR_5 = (VAR_8&0x7C00)>>10;
VAR_1[2*VAR_3] = (VAR_5&0x1F) | ((VAR_6&0x3F)<<5) | ((VAR_7&0x1F)<<11);
}
}
| [
"void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, long VAR_2)\n{",
"long VAR_3;",
"long VAR_4 = VAR_2 >> 1;",
"for(VAR_3=0; VAR_3<VAR_4; VAR_3++)",
"{",
"unsigned VAR_5,VAR_6,VAR_7;",
"register uint16_t VAR_8;",
"VAR_8 = VAR_0[2*VAR_3];",
"VAR_7 = VAR_8&0x1F;",
"VAR_6 = (VAR_8&0x3E0)>>5;",
"VAR_5 = (VAR_8&0x7C00)>>10;",
"VAR_1[2*VAR_3] = (VAR_5&0x1F) | ((VAR_6&0x3F)<<5) | ((VAR_7&0x1F)<<11);",
"}",
"}"
] | [
0,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
]
] |
25,900 | static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,
int opc)
{
int addr_reg, data_reg, arg0, arg1, arg2, mem_index, s_bits;
#if defined(CONFIG_SOFTMMU)
uint32_t *label1_ptr, *label2_ptr;
data_reg = *args++;
addr_reg = *args++;
mem_index = *args;
s_bits = opc & 3;
arg0 = TCG_REG_O0;
arg1 = TCG_REG_O1;
arg2 = TCG_REG_O2;
#if defined(CONFIG_SOFTMMU)
/* srl addr_reg, x, arg1 */
tcg_out_arithi(s, arg1, addr_reg, TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS,
SHIFT_SRL);
tcg_out_arithi(s, arg0, addr_reg, TARGET_PAGE_MASK | ((1 << s_bits) - 1),
ARITH_AND);
/* and arg1, x, arg1 */
tcg_out_andi(s, arg1, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS);
/* add arg1, x, arg1 */
tcg_out_addi(s, arg1, offsetof(CPUState,
tlb_table[mem_index][0].addr_read));
/* add env, arg1, arg1 */
tcg_out_arith(s, arg1, TCG_AREG0, arg1, ARITH_ADD);
/* ld [arg1], arg2 */
tcg_out32(s, TARGET_LD_OP | INSN_RD(arg2) | INSN_RS1(arg1) |
INSN_RS2(TCG_REG_G0));
/* subcc arg0, arg2, %g0 */
tcg_out_arith(s, TCG_REG_G0, arg0, arg2, ARITH_SUBCC);
/* will become:
be label1 */
label1_ptr = (uint32_t *)s->code_ptr;
tcg_out32(s, 0);
/* mov (delay slot) */
tcg_out_mov(s, arg0, addr_reg);
/* mov */
tcg_out_movi(s, TCG_TYPE_I32, arg1, mem_index);
/* XXX: move that code at the end of the TB */
/* qemu_ld_helper[s_bits](arg0, arg1) */
tcg_out32(s, CALL | ((((tcg_target_ulong)qemu_ld_helpers[s_bits]
- (tcg_target_ulong)s->code_ptr) >> 2)
& 0x3fffffff));
/* Store AREG0 in stack to avoid ugly glibc bugs that mangle
global registers */
// delay slot
tcg_out_ldst(s, TCG_AREG0, TCG_REG_CALL_STACK,
TCG_TARGET_CALL_STACK_OFFSET - sizeof(long), HOST_ST_OP);
tcg_out_ldst(s, TCG_AREG0, TCG_REG_CALL_STACK,
TCG_TARGET_CALL_STACK_OFFSET - sizeof(long), HOST_LD_OP);
/* data_reg = sign_extend(arg0) */
switch(opc) {
case 0 | 4:
/* sll arg0, 24/56, data_reg */
tcg_out_arithi(s, data_reg, arg0, (int)sizeof(tcg_target_long) * 8 - 8,
HOST_SLL_OP);
/* sra data_reg, 24/56, data_reg */
tcg_out_arithi(s, data_reg, data_reg,
(int)sizeof(tcg_target_long) * 8 - 8, HOST_SRA_OP);
break;
case 1 | 4:
/* sll arg0, 16/48, data_reg */
tcg_out_arithi(s, data_reg, arg0,
(int)sizeof(tcg_target_long) * 8 - 16, HOST_SLL_OP);
/* sra data_reg, 16/48, data_reg */
tcg_out_arithi(s, data_reg, data_reg,
(int)sizeof(tcg_target_long) * 8 - 16, HOST_SRA_OP);
break;
case 2 | 4:
/* sll arg0, 32, data_reg */
tcg_out_arithi(s, data_reg, arg0, 32, HOST_SLL_OP);
/* sra data_reg, 32, data_reg */
tcg_out_arithi(s, data_reg, data_reg, 32, HOST_SRA_OP);
break;
case 0:
case 1:
case 2:
case 3:
default:
/* mov */
tcg_out_mov(s, data_reg, arg0);
break;
}
/* will become:
ba label2 */
label2_ptr = (uint32_t *)s->code_ptr;
tcg_out32(s, 0);
/* nop (delay slot */
tcg_out_nop(s);
/* label1: */
*label1_ptr = (INSN_OP(0) | INSN_COND(COND_E, 0) | INSN_OP2(0x2) |
INSN_OFF22((unsigned long)s->code_ptr -
(unsigned long)label1_ptr));
/* ld [arg1 + x], arg1 */
tcg_out_ldst(s, arg1, arg1, offsetof(CPUTLBEntry, addend) -
offsetof(CPUTLBEntry, addr_read), HOST_LD_OP);
/* add addr_reg, arg1, arg0 */
tcg_out_arith(s, arg0, addr_reg, arg1, ARITH_ADD);
arg0 = addr_reg;
switch(opc) {
case 0:
/* ldub [arg0], data_reg */
tcg_out_ldst(s, data_reg, arg0, 0, LDUB);
break;
case 0 | 4:
/* ldsb [arg0], data_reg */
tcg_out_ldst(s, data_reg, arg0, 0, LDSB);
break;
case 1:
#ifdef TARGET_WORDS_BIGENDIAN
/* lduh [arg0], data_reg */
tcg_out_ldst(s, data_reg, arg0, 0, LDUH);
/* lduha [arg0] ASI_PRIMARY_LITTLE, data_reg */
tcg_out_ldst_asi(s, data_reg, arg0, 0, LDUHA, ASI_PRIMARY_LITTLE);
break;
case 1 | 4:
#ifdef TARGET_WORDS_BIGENDIAN
/* ldsh [arg0], data_reg */
tcg_out_ldst(s, data_reg, arg0, 0, LDSH);
/* ldsha [arg0] ASI_PRIMARY_LITTLE, data_reg */
tcg_out_ldst_asi(s, data_reg, arg0, 0, LDSHA, ASI_PRIMARY_LITTLE);
break;
case 2:
#ifdef TARGET_WORDS_BIGENDIAN
/* lduw [arg0], data_reg */
tcg_out_ldst(s, data_reg, arg0, 0, LDUW);
/* lduwa [arg0] ASI_PRIMARY_LITTLE, data_reg */
tcg_out_ldst_asi(s, data_reg, arg0, 0, LDUWA, ASI_PRIMARY_LITTLE);
break;
case 2 | 4:
#ifdef TARGET_WORDS_BIGENDIAN
/* ldsw [arg0], data_reg */
tcg_out_ldst(s, data_reg, arg0, 0, LDSW);
/* ldswa [arg0] ASI_PRIMARY_LITTLE, data_reg */
tcg_out_ldst_asi(s, data_reg, arg0, 0, LDSWA, ASI_PRIMARY_LITTLE);
break;
case 3:
#ifdef TARGET_WORDS_BIGENDIAN
/* ldx [arg0], data_reg */
tcg_out_ldst(s, data_reg, arg0, 0, LDX);
/* ldxa [arg0] ASI_PRIMARY_LITTLE, data_reg */
tcg_out_ldst_asi(s, data_reg, arg0, 0, LDXA, ASI_PRIMARY_LITTLE);
break;
default:
tcg_abort();
}
#if defined(CONFIG_SOFTMMU)
/* label2: */
*label2_ptr = (INSN_OP(0) | INSN_COND(COND_A, 0) | INSN_OP2(0x2) |
INSN_OFF22((unsigned long)s->code_ptr -
(unsigned long)label2_ptr));
} | true | qemu | 90cbed4656108fec86d157ced39192e0774a6615 | static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,
int opc)
{
int addr_reg, data_reg, arg0, arg1, arg2, mem_index, s_bits;
#if defined(CONFIG_SOFTMMU)
uint32_t *label1_ptr, *label2_ptr;
data_reg = *args++;
addr_reg = *args++;
mem_index = *args;
s_bits = opc & 3;
arg0 = TCG_REG_O0;
arg1 = TCG_REG_O1;
arg2 = TCG_REG_O2;
#if defined(CONFIG_SOFTMMU)
tcg_out_arithi(s, arg1, addr_reg, TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS,
SHIFT_SRL);
tcg_out_arithi(s, arg0, addr_reg, TARGET_PAGE_MASK | ((1 << s_bits) - 1),
ARITH_AND);
tcg_out_andi(s, arg1, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS);
tcg_out_addi(s, arg1, offsetof(CPUState,
tlb_table[mem_index][0].addr_read));
tcg_out_arith(s, arg1, TCG_AREG0, arg1, ARITH_ADD);
tcg_out32(s, TARGET_LD_OP | INSN_RD(arg2) | INSN_RS1(arg1) |
INSN_RS2(TCG_REG_G0));
tcg_out_arith(s, TCG_REG_G0, arg0, arg2, ARITH_SUBCC);
label1_ptr = (uint32_t *)s->code_ptr;
tcg_out32(s, 0);
tcg_out_mov(s, arg0, addr_reg);
tcg_out_movi(s, TCG_TYPE_I32, arg1, mem_index);
tcg_out32(s, CALL | ((((tcg_target_ulong)qemu_ld_helpers[s_bits]
- (tcg_target_ulong)s->code_ptr) >> 2)
& 0x3fffffff));
tcg_out_ldst(s, TCG_AREG0, TCG_REG_CALL_STACK,
TCG_TARGET_CALL_STACK_OFFSET - sizeof(long), HOST_ST_OP);
tcg_out_ldst(s, TCG_AREG0, TCG_REG_CALL_STACK,
TCG_TARGET_CALL_STACK_OFFSET - sizeof(long), HOST_LD_OP);
switch(opc) {
case 0 | 4:
tcg_out_arithi(s, data_reg, arg0, (int)sizeof(tcg_target_long) * 8 - 8,
HOST_SLL_OP);
tcg_out_arithi(s, data_reg, data_reg,
(int)sizeof(tcg_target_long) * 8 - 8, HOST_SRA_OP);
break;
case 1 | 4:
tcg_out_arithi(s, data_reg, arg0,
(int)sizeof(tcg_target_long) * 8 - 16, HOST_SLL_OP);
tcg_out_arithi(s, data_reg, data_reg,
(int)sizeof(tcg_target_long) * 8 - 16, HOST_SRA_OP);
break;
case 2 | 4:
tcg_out_arithi(s, data_reg, arg0, 32, HOST_SLL_OP);
tcg_out_arithi(s, data_reg, data_reg, 32, HOST_SRA_OP);
break;
case 0:
case 1:
case 2:
case 3:
default:
tcg_out_mov(s, data_reg, arg0);
break;
}
label2_ptr = (uint32_t *)s->code_ptr;
tcg_out32(s, 0);
tcg_out_nop(s);
*label1_ptr = (INSN_OP(0) | INSN_COND(COND_E, 0) | INSN_OP2(0x2) |
INSN_OFF22((unsigned long)s->code_ptr -
(unsigned long)label1_ptr));
tcg_out_ldst(s, arg1, arg1, offsetof(CPUTLBEntry, addend) -
offsetof(CPUTLBEntry, addr_read), HOST_LD_OP);
tcg_out_arith(s, arg0, addr_reg, arg1, ARITH_ADD);
arg0 = addr_reg;
switch(opc) {
case 0:
tcg_out_ldst(s, data_reg, arg0, 0, LDUB);
break;
case 0 | 4:
tcg_out_ldst(s, data_reg, arg0, 0, LDSB);
break;
case 1:
#ifdef TARGET_WORDS_BIGENDIAN
tcg_out_ldst(s, data_reg, arg0, 0, LDUH);
tcg_out_ldst_asi(s, data_reg, arg0, 0, LDUHA, ASI_PRIMARY_LITTLE);
break;
case 1 | 4:
#ifdef TARGET_WORDS_BIGENDIAN
tcg_out_ldst(s, data_reg, arg0, 0, LDSH);
tcg_out_ldst_asi(s, data_reg, arg0, 0, LDSHA, ASI_PRIMARY_LITTLE);
break;
case 2:
#ifdef TARGET_WORDS_BIGENDIAN
tcg_out_ldst(s, data_reg, arg0, 0, LDUW);
tcg_out_ldst_asi(s, data_reg, arg0, 0, LDUWA, ASI_PRIMARY_LITTLE);
break;
case 2 | 4:
#ifdef TARGET_WORDS_BIGENDIAN
tcg_out_ldst(s, data_reg, arg0, 0, LDSW);
tcg_out_ldst_asi(s, data_reg, arg0, 0, LDSWA, ASI_PRIMARY_LITTLE);
break;
case 3:
#ifdef TARGET_WORDS_BIGENDIAN
tcg_out_ldst(s, data_reg, arg0, 0, LDX);
tcg_out_ldst_asi(s, data_reg, arg0, 0, LDXA, ASI_PRIMARY_LITTLE);
break;
default:
tcg_abort();
}
#if defined(CONFIG_SOFTMMU)
*label2_ptr = (INSN_OP(0) | INSN_COND(COND_A, 0) | INSN_OP2(0x2) |
INSN_OFF22((unsigned long)s->code_ptr -
(unsigned long)label2_ptr));
} | {
"code": [],
"line_no": []
} | static void FUNC_0(TCGContext *VAR_0, const TCGArg *VAR_1,
int VAR_2)
{
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;
#if defined(CONFIG_SOFTMMU)
uint32_t *label1_ptr, *label2_ptr;
VAR_4 = *VAR_1++;
VAR_3 = *VAR_1++;
VAR_8 = *VAR_1;
VAR_9 = VAR_2 & 3;
VAR_5 = TCG_REG_O0;
VAR_6 = TCG_REG_O1;
VAR_7 = TCG_REG_O2;
#if defined(CONFIG_SOFTMMU)
tcg_out_arithi(VAR_0, VAR_6, VAR_3, TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS,
SHIFT_SRL);
tcg_out_arithi(VAR_0, VAR_5, VAR_3, TARGET_PAGE_MASK | ((1 << VAR_9) - 1),
ARITH_AND);
tcg_out_andi(VAR_0, VAR_6, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS);
tcg_out_addi(VAR_0, VAR_6, offsetof(CPUState,
tlb_table[VAR_8][0].addr_read));
tcg_out_arith(VAR_0, VAR_6, TCG_AREG0, VAR_6, ARITH_ADD);
tcg_out32(VAR_0, TARGET_LD_OP | INSN_RD(VAR_7) | INSN_RS1(VAR_6) |
INSN_RS2(TCG_REG_G0));
tcg_out_arith(VAR_0, TCG_REG_G0, VAR_5, VAR_7, ARITH_SUBCC);
label1_ptr = (uint32_t *)VAR_0->code_ptr;
tcg_out32(VAR_0, 0);
tcg_out_mov(VAR_0, VAR_5, VAR_3);
tcg_out_movi(VAR_0, TCG_TYPE_I32, VAR_6, VAR_8);
tcg_out32(VAR_0, CALL | ((((tcg_target_ulong)qemu_ld_helpers[VAR_9]
- (tcg_target_ulong)VAR_0->code_ptr) >> 2)
& 0x3fffffff));
tcg_out_ldst(VAR_0, TCG_AREG0, TCG_REG_CALL_STACK,
TCG_TARGET_CALL_STACK_OFFSET - sizeof(long), HOST_ST_OP);
tcg_out_ldst(VAR_0, TCG_AREG0, TCG_REG_CALL_STACK,
TCG_TARGET_CALL_STACK_OFFSET - sizeof(long), HOST_LD_OP);
switch(VAR_2) {
case 0 | 4:
tcg_out_arithi(VAR_0, VAR_4, VAR_5, (int)sizeof(tcg_target_long) * 8 - 8,
HOST_SLL_OP);
tcg_out_arithi(VAR_0, VAR_4, VAR_4,
(int)sizeof(tcg_target_long) * 8 - 8, HOST_SRA_OP);
break;
case 1 | 4:
tcg_out_arithi(VAR_0, VAR_4, VAR_5,
(int)sizeof(tcg_target_long) * 8 - 16, HOST_SLL_OP);
tcg_out_arithi(VAR_0, VAR_4, VAR_4,
(int)sizeof(tcg_target_long) * 8 - 16, HOST_SRA_OP);
break;
case 2 | 4:
tcg_out_arithi(VAR_0, VAR_4, VAR_5, 32, HOST_SLL_OP);
tcg_out_arithi(VAR_0, VAR_4, VAR_4, 32, HOST_SRA_OP);
break;
case 0:
case 1:
case 2:
case 3:
default:
tcg_out_mov(VAR_0, VAR_4, VAR_5);
break;
}
label2_ptr = (uint32_t *)VAR_0->code_ptr;
tcg_out32(VAR_0, 0);
tcg_out_nop(VAR_0);
*label1_ptr = (INSN_OP(0) | INSN_COND(COND_E, 0) | INSN_OP2(0x2) |
INSN_OFF22((unsigned long)VAR_0->code_ptr -
(unsigned long)label1_ptr));
tcg_out_ldst(VAR_0, VAR_6, VAR_6, offsetof(CPUTLBEntry, addend) -
offsetof(CPUTLBEntry, addr_read), HOST_LD_OP);
tcg_out_arith(VAR_0, VAR_5, VAR_3, VAR_6, ARITH_ADD);
VAR_5 = VAR_3;
switch(VAR_2) {
case 0:
tcg_out_ldst(VAR_0, VAR_4, VAR_5, 0, LDUB);
break;
case 0 | 4:
tcg_out_ldst(VAR_0, VAR_4, VAR_5, 0, LDSB);
break;
case 1:
#ifdef TARGET_WORDS_BIGENDIAN
tcg_out_ldst(VAR_0, VAR_4, VAR_5, 0, LDUH);
tcg_out_ldst_asi(VAR_0, VAR_4, VAR_5, 0, LDUHA, ASI_PRIMARY_LITTLE);
break;
case 1 | 4:
#ifdef TARGET_WORDS_BIGENDIAN
tcg_out_ldst(VAR_0, VAR_4, VAR_5, 0, LDSH);
tcg_out_ldst_asi(VAR_0, VAR_4, VAR_5, 0, LDSHA, ASI_PRIMARY_LITTLE);
break;
case 2:
#ifdef TARGET_WORDS_BIGENDIAN
tcg_out_ldst(VAR_0, VAR_4, VAR_5, 0, LDUW);
tcg_out_ldst_asi(VAR_0, VAR_4, VAR_5, 0, LDUWA, ASI_PRIMARY_LITTLE);
break;
case 2 | 4:
#ifdef TARGET_WORDS_BIGENDIAN
tcg_out_ldst(VAR_0, VAR_4, VAR_5, 0, LDSW);
tcg_out_ldst_asi(VAR_0, VAR_4, VAR_5, 0, LDSWA, ASI_PRIMARY_LITTLE);
break;
case 3:
#ifdef TARGET_WORDS_BIGENDIAN
tcg_out_ldst(VAR_0, VAR_4, VAR_5, 0, LDX);
tcg_out_ldst_asi(VAR_0, VAR_4, VAR_5, 0, LDXA, ASI_PRIMARY_LITTLE);
break;
default:
tcg_abort();
}
#if defined(CONFIG_SOFTMMU)
*label2_ptr = (INSN_OP(0) | INSN_COND(COND_A, 0) | INSN_OP2(0x2) |
INSN_OFF22((unsigned long)VAR_0->code_ptr -
(unsigned long)label2_ptr));
} | [
"static void FUNC_0(TCGContext *VAR_0, const TCGArg *VAR_1,\nint VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;",
"#if defined(CONFIG_SOFTMMU)\nuint32_t *label1_ptr, *label2_ptr;",
"VAR_4 = *VAR_1++;",
"VAR_3 = *VAR_1++;",
"VAR_8 = *VAR_1;",
"VAR_9 = VAR_2 & 3;",
"VAR_5 = TCG_REG_O0;",
"VAR_6 = TCG_REG_O1;",
"VAR_7 = TCG_REG_O2;",
"#if defined(CONFIG_SOFTMMU)\ntcg_out_arithi(VAR_0, VAR_6, VAR_3, TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS,\nSHIFT_SRL);",
"tcg_out_arithi(VAR_0, VAR_5, VAR_3, TARGET_PAGE_MASK | ((1 << VAR_9) - 1),\nARITH_AND);",
"tcg_out_andi(VAR_0, VAR_6, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS);",
"tcg_out_addi(VAR_0, VAR_6, offsetof(CPUState,\ntlb_table[VAR_8][0].addr_read));",
"tcg_out_arith(VAR_0, VAR_6, TCG_AREG0, VAR_6, ARITH_ADD);",
"tcg_out32(VAR_0, TARGET_LD_OP | INSN_RD(VAR_7) | INSN_RS1(VAR_6) |\nINSN_RS2(TCG_REG_G0));",
"tcg_out_arith(VAR_0, TCG_REG_G0, VAR_5, VAR_7, ARITH_SUBCC);",
"label1_ptr = (uint32_t *)VAR_0->code_ptr;",
"tcg_out32(VAR_0, 0);",
"tcg_out_mov(VAR_0, VAR_5, VAR_3);",
"tcg_out_movi(VAR_0, TCG_TYPE_I32, VAR_6, VAR_8);",
"tcg_out32(VAR_0, CALL | ((((tcg_target_ulong)qemu_ld_helpers[VAR_9]\n- (tcg_target_ulong)VAR_0->code_ptr) >> 2)\n& 0x3fffffff));",
"tcg_out_ldst(VAR_0, TCG_AREG0, TCG_REG_CALL_STACK,\nTCG_TARGET_CALL_STACK_OFFSET - sizeof(long), HOST_ST_OP);",
"tcg_out_ldst(VAR_0, TCG_AREG0, TCG_REG_CALL_STACK,\nTCG_TARGET_CALL_STACK_OFFSET - sizeof(long), HOST_LD_OP);",
"switch(VAR_2) {",
"case 0 | 4:\ntcg_out_arithi(VAR_0, VAR_4, VAR_5, (int)sizeof(tcg_target_long) * 8 - 8,\nHOST_SLL_OP);",
"tcg_out_arithi(VAR_0, VAR_4, VAR_4,\n(int)sizeof(tcg_target_long) * 8 - 8, HOST_SRA_OP);",
"break;",
"case 1 | 4:\ntcg_out_arithi(VAR_0, VAR_4, VAR_5,\n(int)sizeof(tcg_target_long) * 8 - 16, HOST_SLL_OP);",
"tcg_out_arithi(VAR_0, VAR_4, VAR_4,\n(int)sizeof(tcg_target_long) * 8 - 16, HOST_SRA_OP);",
"break;",
"case 2 | 4:\ntcg_out_arithi(VAR_0, VAR_4, VAR_5, 32, HOST_SLL_OP);",
"tcg_out_arithi(VAR_0, VAR_4, VAR_4, 32, HOST_SRA_OP);",
"break;",
"case 0:\ncase 1:\ncase 2:\ncase 3:\ndefault:\ntcg_out_mov(VAR_0, VAR_4, VAR_5);",
"break;",
"}",
"label2_ptr = (uint32_t *)VAR_0->code_ptr;",
"tcg_out32(VAR_0, 0);",
"tcg_out_nop(VAR_0);",
"*label1_ptr = (INSN_OP(0) | INSN_COND(COND_E, 0) | INSN_OP2(0x2) |\nINSN_OFF22((unsigned long)VAR_0->code_ptr -\n(unsigned long)label1_ptr));",
"tcg_out_ldst(VAR_0, VAR_6, VAR_6, offsetof(CPUTLBEntry, addend) -\noffsetof(CPUTLBEntry, addr_read), HOST_LD_OP);",
"tcg_out_arith(VAR_0, VAR_5, VAR_3, VAR_6, ARITH_ADD);",
"VAR_5 = VAR_3;",
"switch(VAR_2) {",
"case 0:\ntcg_out_ldst(VAR_0, VAR_4, VAR_5, 0, LDUB);",
"break;",
"case 0 | 4:\ntcg_out_ldst(VAR_0, VAR_4, VAR_5, 0, LDSB);",
"break;",
"case 1:\n#ifdef TARGET_WORDS_BIGENDIAN\ntcg_out_ldst(VAR_0, VAR_4, VAR_5, 0, LDUH);",
"tcg_out_ldst_asi(VAR_0, VAR_4, VAR_5, 0, LDUHA, ASI_PRIMARY_LITTLE);",
"break;",
"case 1 | 4:\n#ifdef TARGET_WORDS_BIGENDIAN\ntcg_out_ldst(VAR_0, VAR_4, VAR_5, 0, LDSH);",
"tcg_out_ldst_asi(VAR_0, VAR_4, VAR_5, 0, LDSHA, ASI_PRIMARY_LITTLE);",
"break;",
"case 2:\n#ifdef TARGET_WORDS_BIGENDIAN\ntcg_out_ldst(VAR_0, VAR_4, VAR_5, 0, LDUW);",
"tcg_out_ldst_asi(VAR_0, VAR_4, VAR_5, 0, LDUWA, ASI_PRIMARY_LITTLE);",
"break;",
"case 2 | 4:\n#ifdef TARGET_WORDS_BIGENDIAN\ntcg_out_ldst(VAR_0, VAR_4, VAR_5, 0, LDSW);",
"tcg_out_ldst_asi(VAR_0, VAR_4, VAR_5, 0, LDSWA, ASI_PRIMARY_LITTLE);",
"break;",
"case 3:\n#ifdef TARGET_WORDS_BIGENDIAN\ntcg_out_ldst(VAR_0, VAR_4, VAR_5, 0, LDX);",
"tcg_out_ldst_asi(VAR_0, VAR_4, VAR_5, 0, LDXA, ASI_PRIMARY_LITTLE);",
"break;",
"default:\ntcg_abort();",
"}",
"#if defined(CONFIG_SOFTMMU)\n*label2_ptr = (INSN_OP(0) | INSN_COND(COND_A, 0) | INSN_OP2(0x2) |\nINSN_OFF22((unsigned long)VAR_0->code_ptr -\n(unsigned long)label2_ptr));",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2,
3
],
[
4
],
[
5,
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14,
16,
17
],
[
18,
19
],
[
21
],
[
23,
24
],
[
26
],
[
28,
29
],
[
31
],
[
34
],
[
35
],
[
37
],
[
39
],
[
42,
43,
44
],
[
48,
49
],
[
50,
51
],
[
53
],
[
54,
56,
57
],
[
59,
60
],
[
61
],
[
62,
64,
65
],
[
67,
68
],
[
69
],
[
70,
72
],
[
74
],
[
75
],
[
76,
77,
78,
79,
80,
82
],
[
83
],
[
84
],
[
87
],
[
88
],
[
90
],
[
92,
93,
94
],
[
96,
97
],
[
99
],
[
100
],
[
101
],
[
102,
104
],
[
105
],
[
106,
108
],
[
109
],
[
110,
111,
113
],
[
115
],
[
116
],
[
117,
118,
120
],
[
122
],
[
123
],
[
124,
125,
127
],
[
129
],
[
130
],
[
131,
132,
134
],
[
136
],
[
137
],
[
138,
139,
141
],
[
143
],
[
144
],
[
145,
146
],
[
147
],
[
148,
150,
151,
152
],
[
153
]
] |
25,901 | static int mxf_read_index_table_segment(MXFIndexTableSegment *segment, ByteIOContext *pb, int tag)
{
switch(tag) {
case 0x3F05: dprintf(NULL, "EditUnitByteCount %d\n", get_be32(pb)); break;
case 0x3F06: dprintf(NULL, "IndexSID %d\n", get_be32(pb)); break;
case 0x3F07: dprintf(NULL, "BodySID %d\n", get_be32(pb)); break;
case 0x3F0B: dprintf(NULL, "IndexEditRate %d/%d\n", get_be32(pb), get_be32(pb)); break;
case 0x3F0C: dprintf(NULL, "IndexStartPosition %lld\n", get_be64(pb)); break;
case 0x3F0D: dprintf(NULL, "IndexDuration %lld\n", get_be64(pb)); break;
}
return 0;
}
| true | FFmpeg | 39bb30f6640fe1faf4bbc779a79786028febc95d | static int mxf_read_index_table_segment(MXFIndexTableSegment *segment, ByteIOContext *pb, int tag)
{
switch(tag) {
case 0x3F05: dprintf(NULL, "EditUnitByteCount %d\n", get_be32(pb)); break;
case 0x3F06: dprintf(NULL, "IndexSID %d\n", get_be32(pb)); break;
case 0x3F07: dprintf(NULL, "BodySID %d\n", get_be32(pb)); break;
case 0x3F0B: dprintf(NULL, "IndexEditRate %d/%d\n", get_be32(pb), get_be32(pb)); break;
case 0x3F0C: dprintf(NULL, "IndexStartPosition %lld\n", get_be64(pb)); break;
case 0x3F0D: dprintf(NULL, "IndexDuration %lld\n", get_be64(pb)); break;
}
return 0;
}
| {
"code": [
"static int mxf_read_index_table_segment(MXFIndexTableSegment *segment, ByteIOContext *pb, int tag)"
],
"line_no": [
1
]
} | static int FUNC_0(MXFIndexTableSegment *VAR_0, ByteIOContext *VAR_1, int VAR_2)
{
switch(VAR_2) {
case 0x3F05: dprintf(NULL, "EditUnitByteCount %d\n", get_be32(VAR_1)); break;
case 0x3F06: dprintf(NULL, "IndexSID %d\n", get_be32(VAR_1)); break;
case 0x3F07: dprintf(NULL, "BodySID %d\n", get_be32(VAR_1)); break;
case 0x3F0B: dprintf(NULL, "IndexEditRate %d/%d\n", get_be32(VAR_1), get_be32(VAR_1)); break;
case 0x3F0C: dprintf(NULL, "IndexStartPosition %lld\n", get_be64(VAR_1)); break;
case 0x3F0D: dprintf(NULL, "IndexDuration %lld\n", get_be64(VAR_1)); break;
}
return 0;
}
| [
"static int FUNC_0(MXFIndexTableSegment *VAR_0, ByteIOContext *VAR_1, int VAR_2)\n{",
"switch(VAR_2) {",
"case 0x3F05: dprintf(NULL, \"EditUnitByteCount %d\\n\", get_be32(VAR_1)); break;",
"case 0x3F06: dprintf(NULL, \"IndexSID %d\\n\", get_be32(VAR_1)); break;",
"case 0x3F07: dprintf(NULL, \"BodySID %d\\n\", get_be32(VAR_1)); break;",
"case 0x3F0B: dprintf(NULL, \"IndexEditRate %d/%d\\n\", get_be32(VAR_1), get_be32(VAR_1)); break;",
"case 0x3F0C: dprintf(NULL, \"IndexStartPosition %lld\\n\", get_be64(VAR_1)); break;",
"case 0x3F0D: dprintf(NULL, \"IndexDuration %lld\\n\", get_be64(VAR_1)); break;",
"}",
"return 0;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
25,902 | static const char *vnc_auth_name(VncDisplay *vd) {
switch (vd->auth) {
case VNC_AUTH_INVALID:
return "invalid";
case VNC_AUTH_NONE:
return "none";
case VNC_AUTH_VNC:
return "vnc";
case VNC_AUTH_RA2:
return "ra2";
case VNC_AUTH_RA2NE:
return "ra2ne";
case VNC_AUTH_TIGHT:
return "tight";
case VNC_AUTH_ULTRA:
return "ultra";
case VNC_AUTH_TLS:
return "tls";
case VNC_AUTH_VENCRYPT:
#ifdef CONFIG_VNC_TLS
switch (vd->subauth) {
case VNC_AUTH_VENCRYPT_PLAIN:
return "vencrypt+plain";
case VNC_AUTH_VENCRYPT_TLSNONE:
return "vencrypt+tls+none";
case VNC_AUTH_VENCRYPT_TLSVNC:
return "vencrypt+tls+vnc";
case VNC_AUTH_VENCRYPT_TLSPLAIN:
return "vencrypt+tls+plain";
case VNC_AUTH_VENCRYPT_X509NONE:
return "vencrypt+x509+none";
case VNC_AUTH_VENCRYPT_X509VNC:
return "vencrypt+x509+vnc";
case VNC_AUTH_VENCRYPT_X509PLAIN:
return "vencrypt+x509+plain";
case VNC_AUTH_VENCRYPT_TLSSASL:
return "vencrypt+tls+sasl";
case VNC_AUTH_VENCRYPT_X509SASL:
return "vencrypt+x509+sasl";
default:
return "vencrypt";
}
#else
return "vencrypt";
#endif
case VNC_AUTH_SASL:
return "sasl";
}
return "unknown";
}
| true | qemu | 3e305e4a4752f70c0b5c3cf5b43ec957881714f7 | static const char *vnc_auth_name(VncDisplay *vd) {
switch (vd->auth) {
case VNC_AUTH_INVALID:
return "invalid";
case VNC_AUTH_NONE:
return "none";
case VNC_AUTH_VNC:
return "vnc";
case VNC_AUTH_RA2:
return "ra2";
case VNC_AUTH_RA2NE:
return "ra2ne";
case VNC_AUTH_TIGHT:
return "tight";
case VNC_AUTH_ULTRA:
return "ultra";
case VNC_AUTH_TLS:
return "tls";
case VNC_AUTH_VENCRYPT:
#ifdef CONFIG_VNC_TLS
switch (vd->subauth) {
case VNC_AUTH_VENCRYPT_PLAIN:
return "vencrypt+plain";
case VNC_AUTH_VENCRYPT_TLSNONE:
return "vencrypt+tls+none";
case VNC_AUTH_VENCRYPT_TLSVNC:
return "vencrypt+tls+vnc";
case VNC_AUTH_VENCRYPT_TLSPLAIN:
return "vencrypt+tls+plain";
case VNC_AUTH_VENCRYPT_X509NONE:
return "vencrypt+x509+none";
case VNC_AUTH_VENCRYPT_X509VNC:
return "vencrypt+x509+vnc";
case VNC_AUTH_VENCRYPT_X509PLAIN:
return "vencrypt+x509+plain";
case VNC_AUTH_VENCRYPT_TLSSASL:
return "vencrypt+tls+sasl";
case VNC_AUTH_VENCRYPT_X509SASL:
return "vencrypt+x509+sasl";
default:
return "vencrypt";
}
#else
return "vencrypt";
#endif
case VNC_AUTH_SASL:
return "sasl";
}
return "unknown";
}
| {
"code": [
"#ifdef CONFIG_VNC_TLS",
"#ifdef CONFIG_VNC_TLS",
"#endif",
"#else",
"#endif",
"#ifdef CONFIG_VNC_TLS",
"#ifdef CONFIG_VNC_TLS",
"#ifdef CONFIG_VNC_TLS",
"#else",
" return \"vencrypt\";",
"#endif",
"#ifdef CONFIG_VNC_TLS",
"#endif",
"#ifdef CONFIG_VNC_TLS",
"#endif",
"#ifdef CONFIG_VNC_TLS",
"#endif",
"#ifdef CONFIG_VNC_TLS",
"#ifdef CONFIG_VNC_TLS",
"#ifdef CONFIG_VNC_TLS",
"#ifdef CONFIG_VNC_TLS",
"#ifdef CONFIG_VNC_TLS",
"#ifdef CONFIG_VNC_TLS",
"#ifdef CONFIG_VNC_TLS",
"#ifdef CONFIG_VNC_TLS",
"#ifdef CONFIG_VNC_TLS",
"#ifdef CONFIG_VNC_TLS",
"#endif",
"#ifdef CONFIG_VNC_TLS",
"#endif",
"#endif",
"#ifdef CONFIG_VNC_TLS",
"#endif",
"#ifdef CONFIG_VNC_TLS",
"#endif",
"#ifdef CONFIG_VNC_TLS",
"#endif",
"#ifdef CONFIG_VNC_TLS",
"#endif",
"#ifdef CONFIG_VNC_TLS",
"#endif"
],
"line_no": [
39,
39,
89,
85,
89,
39,
39,
39,
85,
87,
89,
39,
89,
39,
89,
39,
89,
39,
39,
39,
39,
39,
39,
39,
39,
39,
39,
89,
39,
89,
89,
39,
89,
39,
89,
39,
89,
39,
89,
39,
89
]
} | static const char *FUNC_0(VncDisplay *VAR_0) {
switch (VAR_0->auth) {
case VNC_AUTH_INVALID:
return "invalid";
case VNC_AUTH_NONE:
return "none";
case VNC_AUTH_VNC:
return "vnc";
case VNC_AUTH_RA2:
return "ra2";
case VNC_AUTH_RA2NE:
return "ra2ne";
case VNC_AUTH_TIGHT:
return "tight";
case VNC_AUTH_ULTRA:
return "ultra";
case VNC_AUTH_TLS:
return "tls";
case VNC_AUTH_VENCRYPT:
#ifdef CONFIG_VNC_TLS
switch (VAR_0->subauth) {
case VNC_AUTH_VENCRYPT_PLAIN:
return "vencrypt+plain";
case VNC_AUTH_VENCRYPT_TLSNONE:
return "vencrypt+tls+none";
case VNC_AUTH_VENCRYPT_TLSVNC:
return "vencrypt+tls+vnc";
case VNC_AUTH_VENCRYPT_TLSPLAIN:
return "vencrypt+tls+plain";
case VNC_AUTH_VENCRYPT_X509NONE:
return "vencrypt+x509+none";
case VNC_AUTH_VENCRYPT_X509VNC:
return "vencrypt+x509+vnc";
case VNC_AUTH_VENCRYPT_X509PLAIN:
return "vencrypt+x509+plain";
case VNC_AUTH_VENCRYPT_TLSSASL:
return "vencrypt+tls+sasl";
case VNC_AUTH_VENCRYPT_X509SASL:
return "vencrypt+x509+sasl";
default:
return "vencrypt";
}
#else
return "vencrypt";
#endif
case VNC_AUTH_SASL:
return "sasl";
}
return "unknown";
}
| [
"static const char *FUNC_0(VncDisplay *VAR_0) {",
"switch (VAR_0->auth) {",
"case VNC_AUTH_INVALID:\nreturn \"invalid\";",
"case VNC_AUTH_NONE:\nreturn \"none\";",
"case VNC_AUTH_VNC:\nreturn \"vnc\";",
"case VNC_AUTH_RA2:\nreturn \"ra2\";",
"case VNC_AUTH_RA2NE:\nreturn \"ra2ne\";",
"case VNC_AUTH_TIGHT:\nreturn \"tight\";",
"case VNC_AUTH_ULTRA:\nreturn \"ultra\";",
"case VNC_AUTH_TLS:\nreturn \"tls\";",
"case VNC_AUTH_VENCRYPT:\n#ifdef CONFIG_VNC_TLS\nswitch (VAR_0->subauth) {",
"case VNC_AUTH_VENCRYPT_PLAIN:\nreturn \"vencrypt+plain\";",
"case VNC_AUTH_VENCRYPT_TLSNONE:\nreturn \"vencrypt+tls+none\";",
"case VNC_AUTH_VENCRYPT_TLSVNC:\nreturn \"vencrypt+tls+vnc\";",
"case VNC_AUTH_VENCRYPT_TLSPLAIN:\nreturn \"vencrypt+tls+plain\";",
"case VNC_AUTH_VENCRYPT_X509NONE:\nreturn \"vencrypt+x509+none\";",
"case VNC_AUTH_VENCRYPT_X509VNC:\nreturn \"vencrypt+x509+vnc\";",
"case VNC_AUTH_VENCRYPT_X509PLAIN:\nreturn \"vencrypt+x509+plain\";",
"case VNC_AUTH_VENCRYPT_TLSSASL:\nreturn \"vencrypt+tls+sasl\";",
"case VNC_AUTH_VENCRYPT_X509SASL:\nreturn \"vencrypt+x509+sasl\";",
"default:\nreturn \"vencrypt\";",
"}",
"#else\nreturn \"vencrypt\";",
"#endif\ncase VNC_AUTH_SASL:\nreturn \"sasl\";",
"}",
"return \"unknown\";",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0
] | [
[
1
],
[
3
],
[
5,
7
],
[
9,
11
],
[
13,
15
],
[
17,
19
],
[
21,
23
],
[
25,
27
],
[
29,
31
],
[
33,
35
],
[
37,
39,
41
],
[
43,
45
],
[
47,
49
],
[
51,
53
],
[
55,
57
],
[
59,
61
],
[
63,
65
],
[
67,
69
],
[
71,
73
],
[
75,
77
],
[
79,
81
],
[
83
],
[
85,
87
],
[
89,
91,
93
],
[
95
],
[
97
],
[
99
]
] |
25,903 | static void cpu_x86_register(X86CPU *cpu, const char *name, Error **errp)
{
CPUX86State *env = &cpu->env;
x86_def_t def1, *def = &def1;
memset(def, 0, sizeof(*def));
if (cpu_x86_find_by_name(cpu, def, name) < 0) {
error_setg(errp, "Unable to find CPU definition: %s", name);
return;
}
if (kvm_enabled()) {
def->features[FEAT_KVM] |= kvm_default_features;
}
def->features[FEAT_1_ECX] |= CPUID_EXT_HYPERVISOR;
object_property_set_str(OBJECT(cpu), def->vendor, "vendor", errp);
object_property_set_int(OBJECT(cpu), def->level, "level", errp);
object_property_set_int(OBJECT(cpu), def->family, "family", errp);
object_property_set_int(OBJECT(cpu), def->model, "model", errp);
object_property_set_int(OBJECT(cpu), def->stepping, "stepping", errp);
env->features[FEAT_1_EDX] = def->features[FEAT_1_EDX];
env->features[FEAT_1_ECX] = def->features[FEAT_1_ECX];
env->features[FEAT_8000_0001_EDX] = def->features[FEAT_8000_0001_EDX];
env->features[FEAT_8000_0001_ECX] = def->features[FEAT_8000_0001_ECX];
object_property_set_int(OBJECT(cpu), def->xlevel, "xlevel", errp);
env->features[FEAT_KVM] = def->features[FEAT_KVM];
env->features[FEAT_SVM] = def->features[FEAT_SVM];
env->features[FEAT_C000_0001_EDX] = def->features[FEAT_C000_0001_EDX];
env->features[FEAT_7_0_EBX] = def->features[FEAT_7_0_EBX];
env->cpuid_xlevel2 = def->xlevel2;
object_property_set_str(OBJECT(cpu), def->model_id, "model-id", errp);
} | true | qemu | 787aaf5703a702094f395db6795e74230282cd62 | static void cpu_x86_register(X86CPU *cpu, const char *name, Error **errp)
{
CPUX86State *env = &cpu->env;
x86_def_t def1, *def = &def1;
memset(def, 0, sizeof(*def));
if (cpu_x86_find_by_name(cpu, def, name) < 0) {
error_setg(errp, "Unable to find CPU definition: %s", name);
return;
}
if (kvm_enabled()) {
def->features[FEAT_KVM] |= kvm_default_features;
}
def->features[FEAT_1_ECX] |= CPUID_EXT_HYPERVISOR;
object_property_set_str(OBJECT(cpu), def->vendor, "vendor", errp);
object_property_set_int(OBJECT(cpu), def->level, "level", errp);
object_property_set_int(OBJECT(cpu), def->family, "family", errp);
object_property_set_int(OBJECT(cpu), def->model, "model", errp);
object_property_set_int(OBJECT(cpu), def->stepping, "stepping", errp);
env->features[FEAT_1_EDX] = def->features[FEAT_1_EDX];
env->features[FEAT_1_ECX] = def->features[FEAT_1_ECX];
env->features[FEAT_8000_0001_EDX] = def->features[FEAT_8000_0001_EDX];
env->features[FEAT_8000_0001_ECX] = def->features[FEAT_8000_0001_ECX];
object_property_set_int(OBJECT(cpu), def->xlevel, "xlevel", errp);
env->features[FEAT_KVM] = def->features[FEAT_KVM];
env->features[FEAT_SVM] = def->features[FEAT_SVM];
env->features[FEAT_C000_0001_EDX] = def->features[FEAT_C000_0001_EDX];
env->features[FEAT_7_0_EBX] = def->features[FEAT_7_0_EBX];
env->cpuid_xlevel2 = def->xlevel2;
object_property_set_str(OBJECT(cpu), def->model_id, "model-id", errp);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(X86CPU *VAR_0, const char *VAR_1, Error **VAR_2)
{
CPUX86State *env = &VAR_0->env;
x86_def_t def1, *def = &def1;
memset(def, 0, sizeof(*def));
if (cpu_x86_find_by_name(VAR_0, def, VAR_1) < 0) {
error_setg(VAR_2, "Unable to find CPU definition: %s", VAR_1);
return;
}
if (kvm_enabled()) {
def->features[FEAT_KVM] |= kvm_default_features;
}
def->features[FEAT_1_ECX] |= CPUID_EXT_HYPERVISOR;
object_property_set_str(OBJECT(VAR_0), def->vendor, "vendor", VAR_2);
object_property_set_int(OBJECT(VAR_0), def->level, "level", VAR_2);
object_property_set_int(OBJECT(VAR_0), def->family, "family", VAR_2);
object_property_set_int(OBJECT(VAR_0), def->model, "model", VAR_2);
object_property_set_int(OBJECT(VAR_0), def->stepping, "stepping", VAR_2);
env->features[FEAT_1_EDX] = def->features[FEAT_1_EDX];
env->features[FEAT_1_ECX] = def->features[FEAT_1_ECX];
env->features[FEAT_8000_0001_EDX] = def->features[FEAT_8000_0001_EDX];
env->features[FEAT_8000_0001_ECX] = def->features[FEAT_8000_0001_ECX];
object_property_set_int(OBJECT(VAR_0), def->xlevel, "xlevel", VAR_2);
env->features[FEAT_KVM] = def->features[FEAT_KVM];
env->features[FEAT_SVM] = def->features[FEAT_SVM];
env->features[FEAT_C000_0001_EDX] = def->features[FEAT_C000_0001_EDX];
env->features[FEAT_7_0_EBX] = def->features[FEAT_7_0_EBX];
env->cpuid_xlevel2 = def->xlevel2;
object_property_set_str(OBJECT(VAR_0), def->model_id, "model-id", VAR_2);
} | [
"static void FUNC_0(X86CPU *VAR_0, const char *VAR_1, Error **VAR_2)\n{",
"CPUX86State *env = &VAR_0->env;",
"x86_def_t def1, *def = &def1;",
"memset(def, 0, sizeof(*def));",
"if (cpu_x86_find_by_name(VAR_0, def, VAR_1) < 0) {",
"error_setg(VAR_2, \"Unable to find CPU definition: %s\", VAR_1);",
"return;",
"}",
"if (kvm_enabled()) {",
"def->features[FEAT_KVM] |= kvm_default_features;",
"}",
"def->features[FEAT_1_ECX] |= CPUID_EXT_HYPERVISOR;",
"object_property_set_str(OBJECT(VAR_0), def->vendor, \"vendor\", VAR_2);",
"object_property_set_int(OBJECT(VAR_0), def->level, \"level\", VAR_2);",
"object_property_set_int(OBJECT(VAR_0), def->family, \"family\", VAR_2);",
"object_property_set_int(OBJECT(VAR_0), def->model, \"model\", VAR_2);",
"object_property_set_int(OBJECT(VAR_0), def->stepping, \"stepping\", VAR_2);",
"env->features[FEAT_1_EDX] = def->features[FEAT_1_EDX];",
"env->features[FEAT_1_ECX] = def->features[FEAT_1_ECX];",
"env->features[FEAT_8000_0001_EDX] = def->features[FEAT_8000_0001_EDX];",
"env->features[FEAT_8000_0001_ECX] = def->features[FEAT_8000_0001_ECX];",
"object_property_set_int(OBJECT(VAR_0), def->xlevel, \"xlevel\", VAR_2);",
"env->features[FEAT_KVM] = def->features[FEAT_KVM];",
"env->features[FEAT_SVM] = def->features[FEAT_SVM];",
"env->features[FEAT_C000_0001_EDX] = def->features[FEAT_C000_0001_EDX];",
"env->features[FEAT_7_0_EBX] = def->features[FEAT_7_0_EBX];",
"env->cpuid_xlevel2 = def->xlevel2;",
"object_property_set_str(OBJECT(VAR_0), def->model_id, \"model-id\", 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
68
],
[
70
]
] |
25,904 | int bdrv_pwrite(BlockDriverState *bs, int64_t offset,
const void *buf1, int count1)
{
BlockDriver *drv = bs->drv;
if (!drv)
return -ENOMEDIUM;
if (!drv->bdrv_pwrite)
return bdrv_pwrite_em(bs, offset, buf1, count1);
return drv->bdrv_pwrite(bs, offset, buf1, count1);
} | true | qemu | 71d0770c4cec9f1dc04f4dadcbf7fd6c335030a9 | int bdrv_pwrite(BlockDriverState *bs, int64_t offset,
const void *buf1, int count1)
{
BlockDriver *drv = bs->drv;
if (!drv)
return -ENOMEDIUM;
if (!drv->bdrv_pwrite)
return bdrv_pwrite_em(bs, offset, buf1, count1);
return drv->bdrv_pwrite(bs, offset, buf1, count1);
} | {
"code": [],
"line_no": []
} | int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,
const void *VAR_2, int VAR_3)
{
BlockDriver *drv = VAR_0->drv;
if (!drv)
return -ENOMEDIUM;
if (!drv->FUNC_0)
return bdrv_pwrite_em(VAR_0, VAR_1, VAR_2, VAR_3);
return drv->FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3);
} | [
"int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,\nconst void *VAR_2, int VAR_3)\n{",
"BlockDriver *drv = VAR_0->drv;",
"if (!drv)\nreturn -ENOMEDIUM;",
"if (!drv->FUNC_0)\nreturn bdrv_pwrite_em(VAR_0, VAR_1, VAR_2, VAR_3);",
"return drv->FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3);",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
2,
3
],
[
4
],
[
5,
6
],
[
7,
8
],
[
9
],
[
10
]
] |
25,905 | static void yuv2nv12X_c(SwsContext *c, const int16_t *lumFilter,
const int16_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **chrUSrc,
const int16_t **chrVSrc, int chrFilterSize,
const int16_t **alpSrc, uint8_t *dest, uint8_t *uDest,
uint8_t *vDest, uint8_t *aDest,
int dstW, int chrDstW)
{
enum PixelFormat dstFormat = c->dstFormat;
//FIXME Optimize (just quickly written not optimized..)
int i;
for (i=0; i<dstW; i++) {
int val=1<<18;
int j;
for (j=0; j<lumFilterSize; j++)
val += lumSrc[j][i] * lumFilter[j];
dest[i]= av_clip_uint8(val>>19);
}
if (!uDest)
return;
if (dstFormat == PIX_FMT_NV12)
for (i=0; i<chrDstW; i++) {
int u=1<<18;
int v=1<<18;
int j;
for (j=0; j<chrFilterSize; j++) {
u += chrUSrc[j][i] * chrFilter[j];
v += chrVSrc[j][i] * chrFilter[j];
}
uDest[2*i]= av_clip_uint8(u>>19);
uDest[2*i+1]= av_clip_uint8(v>>19);
}
else
for (i=0; i<chrDstW; i++) {
int u=1<<18;
int v=1<<18;
int j;
for (j=0; j<chrFilterSize; j++) {
u += chrUSrc[j][i] * chrFilter[j];
v += chrVSrc[j][i] * chrFilter[j];
}
uDest[2*i]= av_clip_uint8(v>>19);
uDest[2*i+1]= av_clip_uint8(u>>19);
}
}
| false | FFmpeg | 13a099799e89a76eb921ca452e1b04a7a28a9855 | static void yuv2nv12X_c(SwsContext *c, const int16_t *lumFilter,
const int16_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **chrUSrc,
const int16_t **chrVSrc, int chrFilterSize,
const int16_t **alpSrc, uint8_t *dest, uint8_t *uDest,
uint8_t *vDest, uint8_t *aDest,
int dstW, int chrDstW)
{
enum PixelFormat dstFormat = c->dstFormat;
int i;
for (i=0; i<dstW; i++) {
int val=1<<18;
int j;
for (j=0; j<lumFilterSize; j++)
val += lumSrc[j][i] * lumFilter[j];
dest[i]= av_clip_uint8(val>>19);
}
if (!uDest)
return;
if (dstFormat == PIX_FMT_NV12)
for (i=0; i<chrDstW; i++) {
int u=1<<18;
int v=1<<18;
int j;
for (j=0; j<chrFilterSize; j++) {
u += chrUSrc[j][i] * chrFilter[j];
v += chrVSrc[j][i] * chrFilter[j];
}
uDest[2*i]= av_clip_uint8(u>>19);
uDest[2*i+1]= av_clip_uint8(v>>19);
}
else
for (i=0; i<chrDstW; i++) {
int u=1<<18;
int v=1<<18;
int j;
for (j=0; j<chrFilterSize; j++) {
u += chrUSrc[j][i] * chrFilter[j];
v += chrVSrc[j][i] * chrFilter[j];
}
uDest[2*i]= av_clip_uint8(v>>19);
uDest[2*i+1]= av_clip_uint8(u>>19);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(SwsContext *VAR_0, const int16_t *VAR_1,
const int16_t **VAR_2, int VAR_3,
const int16_t *VAR_4, const int16_t **VAR_5,
const int16_t **VAR_6, int VAR_7,
const int16_t **VAR_8, uint8_t *VAR_9, uint8_t *VAR_10,
uint8_t *VAR_11, uint8_t *VAR_12,
int VAR_13, int VAR_14)
{
enum PixelFormat VAR_15 = VAR_0->VAR_15;
int VAR_16;
for (VAR_16=0; VAR_16<VAR_13; VAR_16++) {
int VAR_17=1<<18;
int VAR_21;
for (VAR_21=0; VAR_21<VAR_3; VAR_21++)
VAR_17 += VAR_2[VAR_21][VAR_16] * VAR_1[VAR_21];
VAR_9[VAR_16]= av_clip_uint8(VAR_17>>19);
}
if (!VAR_10)
return;
if (VAR_15 == PIX_FMT_NV12)
for (VAR_16=0; VAR_16<VAR_14; VAR_16++) {
int VAR_21=1<<18;
int VAR_21=1<<18;
int VAR_21;
for (VAR_21=0; VAR_21<VAR_7; VAR_21++) {
VAR_21 += VAR_5[VAR_21][VAR_16] * VAR_4[VAR_21];
VAR_21 += VAR_6[VAR_21][VAR_16] * VAR_4[VAR_21];
}
VAR_10[2*VAR_16]= av_clip_uint8(VAR_21>>19);
VAR_10[2*VAR_16+1]= av_clip_uint8(VAR_21>>19);
}
else
for (VAR_16=0; VAR_16<VAR_14; VAR_16++) {
int VAR_21=1<<18;
int VAR_21=1<<18;
int VAR_21;
for (VAR_21=0; VAR_21<VAR_7; VAR_21++) {
VAR_21 += VAR_5[VAR_21][VAR_16] * VAR_4[VAR_21];
VAR_21 += VAR_6[VAR_21][VAR_16] * VAR_4[VAR_21];
}
VAR_10[2*VAR_16]= av_clip_uint8(VAR_21>>19);
VAR_10[2*VAR_16+1]= av_clip_uint8(VAR_21>>19);
}
}
| [
"static void FUNC_0(SwsContext *VAR_0, const int16_t *VAR_1,\nconst int16_t **VAR_2, int VAR_3,\nconst int16_t *VAR_4, const int16_t **VAR_5,\nconst int16_t **VAR_6, int VAR_7,\nconst int16_t **VAR_8, uint8_t *VAR_9, uint8_t *VAR_10,\nuint8_t *VAR_11, uint8_t *VAR_12,\nint VAR_13, int VAR_14)\n{",
"enum PixelFormat VAR_15 = VAR_0->VAR_15;",
"int VAR_16;",
"for (VAR_16=0; VAR_16<VAR_13; VAR_16++) {",
"int VAR_17=1<<18;",
"int VAR_21;",
"for (VAR_21=0; VAR_21<VAR_3; VAR_21++)",
"VAR_17 += VAR_2[VAR_21][VAR_16] * VAR_1[VAR_21];",
"VAR_9[VAR_16]= av_clip_uint8(VAR_17>>19);",
"}",
"if (!VAR_10)\nreturn;",
"if (VAR_15 == PIX_FMT_NV12)\nfor (VAR_16=0; VAR_16<VAR_14; VAR_16++) {",
"int VAR_21=1<<18;",
"int VAR_21=1<<18;",
"int VAR_21;",
"for (VAR_21=0; VAR_21<VAR_7; VAR_21++) {",
"VAR_21 += VAR_5[VAR_21][VAR_16] * VAR_4[VAR_21];",
"VAR_21 += VAR_6[VAR_21][VAR_16] * VAR_4[VAR_21];",
"}",
"VAR_10[2*VAR_16]= av_clip_uint8(VAR_21>>19);",
"VAR_10[2*VAR_16+1]= av_clip_uint8(VAR_21>>19);",
"}",
"else\nfor (VAR_16=0; VAR_16<VAR_14; VAR_16++) {",
"int VAR_21=1<<18;",
"int VAR_21=1<<18;",
"int VAR_21;",
"for (VAR_21=0; VAR_21<VAR_7; VAR_21++) {",
"VAR_21 += VAR_5[VAR_21][VAR_16] * VAR_4[VAR_21];",
"VAR_21 += VAR_6[VAR_21][VAR_16] * VAR_4[VAR_21];",
"}",
"VAR_10[2*VAR_16]= av_clip_uint8(VAR_21>>19);",
"VAR_10[2*VAR_16+1]= av_clip_uint8(VAR_21>>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
] | [
[
1,
3,
5,
7,
9,
11,
13,
15
],
[
17
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
43,
45
],
[
49,
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
]
] |
25,906 | static BlockAIOCB *blk_aio_prwv(BlockBackend *blk, int64_t offset, int bytes,
QEMUIOVector *qiov, CoroutineEntry co_entry,
BdrvRequestFlags flags,
BlockCompletionFunc *cb, void *opaque)
{
BlkAioEmAIOCB *acb;
Coroutine *co;
bdrv_inc_in_flight(blk_bs(blk));
acb = blk_aio_get(&blk_aio_em_aiocb_info, blk, cb, opaque);
acb->rwco = (BlkRwCo) {
.blk = blk,
.offset = offset,
.qiov = qiov,
.flags = flags,
.ret = NOT_DONE,
};
acb->bytes = bytes;
acb->has_returned = false;
co = qemu_coroutine_create(co_entry, acb);
qemu_coroutine_enter(co);
acb->has_returned = true;
if (acb->rwco.ret != NOT_DONE) {
aio_bh_schedule_oneshot(blk_get_aio_context(blk),
blk_aio_complete_bh, acb);
}
return &acb->common;
}
| true | qemu | e92f0e1910f0655a0edd8d87c5a7262d36517a89 | static BlockAIOCB *blk_aio_prwv(BlockBackend *blk, int64_t offset, int bytes,
QEMUIOVector *qiov, CoroutineEntry co_entry,
BdrvRequestFlags flags,
BlockCompletionFunc *cb, void *opaque)
{
BlkAioEmAIOCB *acb;
Coroutine *co;
bdrv_inc_in_flight(blk_bs(blk));
acb = blk_aio_get(&blk_aio_em_aiocb_info, blk, cb, opaque);
acb->rwco = (BlkRwCo) {
.blk = blk,
.offset = offset,
.qiov = qiov,
.flags = flags,
.ret = NOT_DONE,
};
acb->bytes = bytes;
acb->has_returned = false;
co = qemu_coroutine_create(co_entry, acb);
qemu_coroutine_enter(co);
acb->has_returned = true;
if (acb->rwco.ret != NOT_DONE) {
aio_bh_schedule_oneshot(blk_get_aio_context(blk),
blk_aio_complete_bh, acb);
}
return &acb->common;
}
| {
"code": [
" qemu_coroutine_enter(co);",
" qemu_coroutine_enter(co);",
" qemu_coroutine_enter(co);"
],
"line_no": [
43,
43,
43
]
} | static BlockAIOCB *FUNC_0(BlockBackend *blk, int64_t offset, int bytes,
QEMUIOVector *qiov, CoroutineEntry co_entry,
BdrvRequestFlags flags,
BlockCompletionFunc *cb, void *opaque)
{
BlkAioEmAIOCB *acb;
Coroutine *co;
bdrv_inc_in_flight(blk_bs(blk));
acb = blk_aio_get(&blk_aio_em_aiocb_info, blk, cb, opaque);
acb->rwco = (BlkRwCo) {
.blk = blk,
.offset = offset,
.qiov = qiov,
.flags = flags,
.ret = NOT_DONE,
};
acb->bytes = bytes;
acb->has_returned = false;
co = qemu_coroutine_create(co_entry, acb);
qemu_coroutine_enter(co);
acb->has_returned = true;
if (acb->rwco.ret != NOT_DONE) {
aio_bh_schedule_oneshot(blk_get_aio_context(blk),
blk_aio_complete_bh, acb);
}
return &acb->common;
}
| [
"static BlockAIOCB *FUNC_0(BlockBackend *blk, int64_t offset, int bytes,\nQEMUIOVector *qiov, CoroutineEntry co_entry,\nBdrvRequestFlags flags,\nBlockCompletionFunc *cb, void *opaque)\n{",
"BlkAioEmAIOCB *acb;",
"Coroutine *co;",
"bdrv_inc_in_flight(blk_bs(blk));",
"acb = blk_aio_get(&blk_aio_em_aiocb_info, blk, cb, opaque);",
"acb->rwco = (BlkRwCo) {",
".blk = blk,\n.offset = offset,\n.qiov = qiov,\n.flags = flags,\n.ret = NOT_DONE,\n};",
"acb->bytes = bytes;",
"acb->has_returned = false;",
"co = qemu_coroutine_create(co_entry, acb);",
"qemu_coroutine_enter(co);",
"acb->has_returned = true;",
"if (acb->rwco.ret != NOT_DONE) {",
"aio_bh_schedule_oneshot(blk_get_aio_context(blk),\nblk_aio_complete_bh, acb);",
"}",
"return &acb->common;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23,
25,
27,
29,
31,
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51,
53
],
[
55
],
[
59
],
[
61
]
] |
25,907 | static int rv10_decode_packet(AVCodecContext *avctx,
const uint8_t *buf, int buf_size, int buf_size2)
{
MpegEncContext *s = avctx->priv_data;
int mb_count, mb_pos, left, start_mb_x;
init_get_bits(&s->gb, buf, buf_size*8);
if(s->codec_id ==CODEC_ID_RV10)
mb_count = rv10_decode_picture_header(s);
else
mb_count = rv20_decode_picture_header(s);
if (mb_count < 0) {
av_log(s->avctx, AV_LOG_ERROR, "HEADER ERROR\n");
return -1;
}
if (s->mb_x >= s->mb_width ||
s->mb_y >= s->mb_height) {
av_log(s->avctx, AV_LOG_ERROR, "POS ERROR %d %d\n", s->mb_x, s->mb_y);
return -1;
}
mb_pos = s->mb_y * s->mb_width + s->mb_x;
left = s->mb_width * s->mb_height - mb_pos;
if (mb_count > left) {
av_log(s->avctx, AV_LOG_ERROR, "COUNT ERROR\n");
return -1;
}
if ((s->mb_x == 0 && s->mb_y == 0) || s->current_picture_ptr==NULL) {
if(s->current_picture_ptr){ //FIXME write parser so we always have complete frames?
ff_er_frame_end(s);
ff_MPV_frame_end(s);
s->mb_x= s->mb_y = s->resync_mb_x = s->resync_mb_y= 0;
}
if(ff_MPV_frame_start(s, avctx) < 0)
return -1;
ff_er_frame_start(s);
} else {
if (s->current_picture_ptr->f.pict_type != s->pict_type) {
av_log(s->avctx, AV_LOG_ERROR, "Slice type mismatch\n");
return -1;
}
}
av_dlog(avctx, "qscale=%d\n", s->qscale);
/* default quantization values */
if(s->codec_id== CODEC_ID_RV10){
if(s->mb_y==0) s->first_slice_line=1;
}else{
s->first_slice_line=1;
s->resync_mb_x= s->mb_x;
}
start_mb_x= s->mb_x;
s->resync_mb_y= s->mb_y;
if(s->h263_aic){
s->y_dc_scale_table=
s->c_dc_scale_table= ff_aic_dc_scale_table;
}else{
s->y_dc_scale_table=
s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
}
if(s->modified_quant)
s->chroma_qscale_table= ff_h263_chroma_qscale_table;
ff_set_qscale(s, s->qscale);
s->rv10_first_dc_coded[0] = 0;
s->rv10_first_dc_coded[1] = 0;
s->rv10_first_dc_coded[2] = 0;
s->block_wrap[0]=
s->block_wrap[1]=
s->block_wrap[2]=
s->block_wrap[3]= s->b8_stride;
s->block_wrap[4]=
s->block_wrap[5]= s->mb_stride;
ff_init_block_index(s);
/* decode each macroblock */
for(s->mb_num_left= mb_count; s->mb_num_left>0; s->mb_num_left--) {
int ret;
ff_update_block_index(s);
av_dlog(avctx, "**mb x=%d y=%d\n", s->mb_x, s->mb_y);
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
ret=ff_h263_decode_mb(s, s->block);
if (ret != SLICE_ERROR && s->gb.size_in_bits < get_bits_count(&s->gb) && 8*buf_size2 >= get_bits_count(&s->gb)){
av_log(avctx, AV_LOG_DEBUG, "update size from %d to %d\n", s->gb.size_in_bits, 8*buf_size2);
s->gb.size_in_bits= 8*buf_size2;
ret= SLICE_OK;
}
if (ret == SLICE_ERROR || s->gb.size_in_bits < get_bits_count(&s->gb)) {
av_log(s->avctx, AV_LOG_ERROR, "ERROR at MB %d %d\n", s->mb_x, s->mb_y);
return -1;
}
if(s->pict_type != AV_PICTURE_TYPE_B)
ff_h263_update_motion_val(s);
ff_MPV_decode_mb(s, s->block);
if(s->loop_filter)
ff_h263_loop_filter(s);
if (++s->mb_x == s->mb_width) {
s->mb_x = 0;
s->mb_y++;
ff_init_block_index(s);
}
if(s->mb_x == s->resync_mb_x)
s->first_slice_line=0;
if(ret == SLICE_END) break;
}
ff_er_add_slice(s, start_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END);
return s->gb.size_in_bits;
}
| true | FFmpeg | 9243ec4a508c81a621e941bb7e012e2d45d93659 | static int rv10_decode_packet(AVCodecContext *avctx,
const uint8_t *buf, int buf_size, int buf_size2)
{
MpegEncContext *s = avctx->priv_data;
int mb_count, mb_pos, left, start_mb_x;
init_get_bits(&s->gb, buf, buf_size*8);
if(s->codec_id ==CODEC_ID_RV10)
mb_count = rv10_decode_picture_header(s);
else
mb_count = rv20_decode_picture_header(s);
if (mb_count < 0) {
av_log(s->avctx, AV_LOG_ERROR, "HEADER ERROR\n");
return -1;
}
if (s->mb_x >= s->mb_width ||
s->mb_y >= s->mb_height) {
av_log(s->avctx, AV_LOG_ERROR, "POS ERROR %d %d\n", s->mb_x, s->mb_y);
return -1;
}
mb_pos = s->mb_y * s->mb_width + s->mb_x;
left = s->mb_width * s->mb_height - mb_pos;
if (mb_count > left) {
av_log(s->avctx, AV_LOG_ERROR, "COUNT ERROR\n");
return -1;
}
if ((s->mb_x == 0 && s->mb_y == 0) || s->current_picture_ptr==NULL) {
if(s->current_picture_ptr){
ff_er_frame_end(s);
ff_MPV_frame_end(s);
s->mb_x= s->mb_y = s->resync_mb_x = s->resync_mb_y= 0;
}
if(ff_MPV_frame_start(s, avctx) < 0)
return -1;
ff_er_frame_start(s);
} else {
if (s->current_picture_ptr->f.pict_type != s->pict_type) {
av_log(s->avctx, AV_LOG_ERROR, "Slice type mismatch\n");
return -1;
}
}
av_dlog(avctx, "qscale=%d\n", s->qscale);
if(s->codec_id== CODEC_ID_RV10){
if(s->mb_y==0) s->first_slice_line=1;
}else{
s->first_slice_line=1;
s->resync_mb_x= s->mb_x;
}
start_mb_x= s->mb_x;
s->resync_mb_y= s->mb_y;
if(s->h263_aic){
s->y_dc_scale_table=
s->c_dc_scale_table= ff_aic_dc_scale_table;
}else{
s->y_dc_scale_table=
s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
}
if(s->modified_quant)
s->chroma_qscale_table= ff_h263_chroma_qscale_table;
ff_set_qscale(s, s->qscale);
s->rv10_first_dc_coded[0] = 0;
s->rv10_first_dc_coded[1] = 0;
s->rv10_first_dc_coded[2] = 0;
s->block_wrap[0]=
s->block_wrap[1]=
s->block_wrap[2]=
s->block_wrap[3]= s->b8_stride;
s->block_wrap[4]=
s->block_wrap[5]= s->mb_stride;
ff_init_block_index(s);
for(s->mb_num_left= mb_count; s->mb_num_left>0; s->mb_num_left--) {
int ret;
ff_update_block_index(s);
av_dlog(avctx, "**mb x=%d y=%d\n", s->mb_x, s->mb_y);
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
ret=ff_h263_decode_mb(s, s->block);
if (ret != SLICE_ERROR && s->gb.size_in_bits < get_bits_count(&s->gb) && 8*buf_size2 >= get_bits_count(&s->gb)){
av_log(avctx, AV_LOG_DEBUG, "update size from %d to %d\n", s->gb.size_in_bits, 8*buf_size2);
s->gb.size_in_bits= 8*buf_size2;
ret= SLICE_OK;
}
if (ret == SLICE_ERROR || s->gb.size_in_bits < get_bits_count(&s->gb)) {
av_log(s->avctx, AV_LOG_ERROR, "ERROR at MB %d %d\n", s->mb_x, s->mb_y);
return -1;
}
if(s->pict_type != AV_PICTURE_TYPE_B)
ff_h263_update_motion_val(s);
ff_MPV_decode_mb(s, s->block);
if(s->loop_filter)
ff_h263_loop_filter(s);
if (++s->mb_x == s->mb_width) {
s->mb_x = 0;
s->mb_y++;
ff_init_block_index(s);
}
if(s->mb_x == s->resync_mb_x)
s->first_slice_line=0;
if(ret == SLICE_END) break;
}
ff_er_add_slice(s, start_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END);
return s->gb.size_in_bits;
}
| {
"code": [
" int mb_count, mb_pos, left, start_mb_x;",
" init_get_bits(&s->gb, buf, buf_size*8);",
" if (ret != SLICE_ERROR && s->gb.size_in_bits < get_bits_count(&s->gb) && 8*buf_size2 >= get_bits_count(&s->gb)){",
" av_log(avctx, AV_LOG_DEBUG, \"update size from %d to %d\\n\", s->gb.size_in_bits, 8*buf_size2);",
" s->gb.size_in_bits= 8*buf_size2;",
" if (ret == SLICE_ERROR || s->gb.size_in_bits < get_bits_count(&s->gb)) {",
" return s->gb.size_in_bits;"
],
"line_no": [
9,
13,
179,
181,
183,
191,
235
]
} | static int FUNC_0(AVCodecContext *VAR_0,
const uint8_t *VAR_1, int VAR_2, int VAR_3)
{
MpegEncContext *s = VAR_0->priv_data;
int VAR_4, VAR_5, VAR_6, VAR_7;
init_get_bits(&s->gb, VAR_1, VAR_2*8);
if(s->codec_id ==CODEC_ID_RV10)
VAR_4 = rv10_decode_picture_header(s);
else
VAR_4 = rv20_decode_picture_header(s);
if (VAR_4 < 0) {
av_log(s->VAR_0, AV_LOG_ERROR, "HEADER ERROR\n");
return -1;
}
if (s->mb_x >= s->mb_width ||
s->mb_y >= s->mb_height) {
av_log(s->VAR_0, AV_LOG_ERROR, "POS ERROR %d %d\n", s->mb_x, s->mb_y);
return -1;
}
VAR_5 = s->mb_y * s->mb_width + s->mb_x;
VAR_6 = s->mb_width * s->mb_height - VAR_5;
if (VAR_4 > VAR_6) {
av_log(s->VAR_0, AV_LOG_ERROR, "COUNT ERROR\n");
return -1;
}
if ((s->mb_x == 0 && s->mb_y == 0) || s->current_picture_ptr==NULL) {
if(s->current_picture_ptr){
ff_er_frame_end(s);
ff_MPV_frame_end(s);
s->mb_x= s->mb_y = s->resync_mb_x = s->resync_mb_y= 0;
}
if(ff_MPV_frame_start(s, VAR_0) < 0)
return -1;
ff_er_frame_start(s);
} else {
if (s->current_picture_ptr->f.pict_type != s->pict_type) {
av_log(s->VAR_0, AV_LOG_ERROR, "Slice type mismatch\n");
return -1;
}
}
av_dlog(VAR_0, "qscale=%d\n", s->qscale);
if(s->codec_id== CODEC_ID_RV10){
if(s->mb_y==0) s->first_slice_line=1;
}else{
s->first_slice_line=1;
s->resync_mb_x= s->mb_x;
}
VAR_7= s->mb_x;
s->resync_mb_y= s->mb_y;
if(s->h263_aic){
s->y_dc_scale_table=
s->c_dc_scale_table= ff_aic_dc_scale_table;
}else{
s->y_dc_scale_table=
s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
}
if(s->modified_quant)
s->chroma_qscale_table= ff_h263_chroma_qscale_table;
ff_set_qscale(s, s->qscale);
s->rv10_first_dc_coded[0] = 0;
s->rv10_first_dc_coded[1] = 0;
s->rv10_first_dc_coded[2] = 0;
s->block_wrap[0]=
s->block_wrap[1]=
s->block_wrap[2]=
s->block_wrap[3]= s->b8_stride;
s->block_wrap[4]=
s->block_wrap[5]= s->mb_stride;
ff_init_block_index(s);
for(s->mb_num_left= VAR_4; s->mb_num_left>0; s->mb_num_left--) {
int ret;
ff_update_block_index(s);
av_dlog(VAR_0, "**mb x=%d y=%d\n", s->mb_x, s->mb_y);
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
ret=ff_h263_decode_mb(s, s->block);
if (ret != SLICE_ERROR && s->gb.size_in_bits < get_bits_count(&s->gb) && 8*VAR_3 >= get_bits_count(&s->gb)){
av_log(VAR_0, AV_LOG_DEBUG, "update size from %d to %d\n", s->gb.size_in_bits, 8*VAR_3);
s->gb.size_in_bits= 8*VAR_3;
ret= SLICE_OK;
}
if (ret == SLICE_ERROR || s->gb.size_in_bits < get_bits_count(&s->gb)) {
av_log(s->VAR_0, AV_LOG_ERROR, "ERROR at MB %d %d\n", s->mb_x, s->mb_y);
return -1;
}
if(s->pict_type != AV_PICTURE_TYPE_B)
ff_h263_update_motion_val(s);
ff_MPV_decode_mb(s, s->block);
if(s->loop_filter)
ff_h263_loop_filter(s);
if (++s->mb_x == s->mb_width) {
s->mb_x = 0;
s->mb_y++;
ff_init_block_index(s);
}
if(s->mb_x == s->resync_mb_x)
s->first_slice_line=0;
if(ret == SLICE_END) break;
}
ff_er_add_slice(s, VAR_7, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END);
return s->gb.size_in_bits;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nconst uint8_t *VAR_1, int VAR_2, int VAR_3)\n{",
"MpegEncContext *s = VAR_0->priv_data;",
"int VAR_4, VAR_5, VAR_6, VAR_7;",
"init_get_bits(&s->gb, VAR_1, VAR_2*8);",
"if(s->codec_id ==CODEC_ID_RV10)\nVAR_4 = rv10_decode_picture_header(s);",
"else\nVAR_4 = rv20_decode_picture_header(s);",
"if (VAR_4 < 0) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \"HEADER ERROR\\n\");",
"return -1;",
"}",
"if (s->mb_x >= s->mb_width ||\ns->mb_y >= s->mb_height) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \"POS ERROR %d %d\\n\", s->mb_x, s->mb_y);",
"return -1;",
"}",
"VAR_5 = s->mb_y * s->mb_width + s->mb_x;",
"VAR_6 = s->mb_width * s->mb_height - VAR_5;",
"if (VAR_4 > VAR_6) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \"COUNT ERROR\\n\");",
"return -1;",
"}",
"if ((s->mb_x == 0 && s->mb_y == 0) || s->current_picture_ptr==NULL) {",
"if(s->current_picture_ptr){",
"ff_er_frame_end(s);",
"ff_MPV_frame_end(s);",
"s->mb_x= s->mb_y = s->resync_mb_x = s->resync_mb_y= 0;",
"}",
"if(ff_MPV_frame_start(s, VAR_0) < 0)\nreturn -1;",
"ff_er_frame_start(s);",
"} else {",
"if (s->current_picture_ptr->f.pict_type != s->pict_type) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \"Slice type mismatch\\n\");",
"return -1;",
"}",
"}",
"av_dlog(VAR_0, \"qscale=%d\\n\", s->qscale);",
"if(s->codec_id== CODEC_ID_RV10){",
"if(s->mb_y==0) s->first_slice_line=1;",
"}else{",
"s->first_slice_line=1;",
"s->resync_mb_x= s->mb_x;",
"}",
"VAR_7= s->mb_x;",
"s->resync_mb_y= s->mb_y;",
"if(s->h263_aic){",
"s->y_dc_scale_table=\ns->c_dc_scale_table= ff_aic_dc_scale_table;",
"}else{",
"s->y_dc_scale_table=\ns->c_dc_scale_table= ff_mpeg1_dc_scale_table;",
"}",
"if(s->modified_quant)\ns->chroma_qscale_table= ff_h263_chroma_qscale_table;",
"ff_set_qscale(s, s->qscale);",
"s->rv10_first_dc_coded[0] = 0;",
"s->rv10_first_dc_coded[1] = 0;",
"s->rv10_first_dc_coded[2] = 0;",
"s->block_wrap[0]=\ns->block_wrap[1]=\ns->block_wrap[2]=\ns->block_wrap[3]= s->b8_stride;",
"s->block_wrap[4]=\ns->block_wrap[5]= s->mb_stride;",
"ff_init_block_index(s);",
"for(s->mb_num_left= VAR_4; s->mb_num_left>0; s->mb_num_left--) {",
"int ret;",
"ff_update_block_index(s);",
"av_dlog(VAR_0, \"**mb x=%d y=%d\\n\", s->mb_x, s->mb_y);",
"s->mv_dir = MV_DIR_FORWARD;",
"s->mv_type = MV_TYPE_16X16;",
"ret=ff_h263_decode_mb(s, s->block);",
"if (ret != SLICE_ERROR && s->gb.size_in_bits < get_bits_count(&s->gb) && 8*VAR_3 >= get_bits_count(&s->gb)){",
"av_log(VAR_0, AV_LOG_DEBUG, \"update size from %d to %d\\n\", s->gb.size_in_bits, 8*VAR_3);",
"s->gb.size_in_bits= 8*VAR_3;",
"ret= SLICE_OK;",
"}",
"if (ret == SLICE_ERROR || s->gb.size_in_bits < get_bits_count(&s->gb)) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \"ERROR at MB %d %d\\n\", s->mb_x, s->mb_y);",
"return -1;",
"}",
"if(s->pict_type != AV_PICTURE_TYPE_B)\nff_h263_update_motion_val(s);",
"ff_MPV_decode_mb(s, s->block);",
"if(s->loop_filter)\nff_h263_loop_filter(s);",
"if (++s->mb_x == s->mb_width) {",
"s->mb_x = 0;",
"s->mb_y++;",
"ff_init_block_index(s);",
"}",
"if(s->mb_x == s->resync_mb_x)\ns->first_slice_line=0;",
"if(ret == SLICE_END) break;",
"}",
"ff_er_add_slice(s, VAR_7, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END);",
"return s->gb.size_in_bits;",
"}"
] | [
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113,
115
],
[
117
],
[
119,
121
],
[
123
],
[
127,
129
],
[
133
],
[
137
],
[
139
],
[
141
],
[
143,
145,
147,
149
],
[
151,
153
],
[
155
],
[
161
],
[
163
],
[
165
],
[
167
],
[
171
],
[
173
],
[
175
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199,
201
],
[
203
],
[
205,
207
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221,
223
],
[
225
],
[
227
],
[
231
],
[
235
],
[
237
]
] |
25,908 | static void coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req,
struct iovec *iov, int niov, bool create,
enum AIOCBState aiocb_type)
{
int nr_copies = s->inode.nr_copies;
SheepdogObjReq hdr;
unsigned int wlen = 0;
int ret;
uint64_t oid = aio_req->oid;
unsigned int datalen = aio_req->data_len;
uint64_t offset = aio_req->offset;
uint8_t flags = aio_req->flags;
uint64_t old_oid = aio_req->base_oid;
if (!nr_copies) {
error_report("bug");
}
memset(&hdr, 0, sizeof(hdr));
switch (aiocb_type) {
case AIOCB_FLUSH_CACHE:
hdr.opcode = SD_OP_FLUSH_VDI;
break;
case AIOCB_READ_UDATA:
hdr.opcode = SD_OP_READ_OBJ;
hdr.flags = flags;
break;
case AIOCB_WRITE_UDATA:
if (create) {
hdr.opcode = SD_OP_CREATE_AND_WRITE_OBJ;
} else {
hdr.opcode = SD_OP_WRITE_OBJ;
}
wlen = datalen;
hdr.flags = SD_FLAG_CMD_WRITE | flags;
break;
case AIOCB_DISCARD_OBJ:
hdr.opcode = SD_OP_DISCARD_OBJ;
break;
}
if (s->cache_flags) {
hdr.flags |= s->cache_flags;
}
hdr.oid = oid;
hdr.cow_oid = old_oid;
hdr.copies = s->inode.nr_copies;
hdr.data_length = datalen;
hdr.offset = offset;
hdr.id = aio_req->id;
qemu_co_mutex_lock(&s->lock);
s->co_send = qemu_coroutine_self();
aio_set_fd_handler(s->aio_context, s->fd,
co_read_response, co_write_request, s);
socket_set_cork(s->fd, 1);
/* send a header */
ret = qemu_co_send(s->fd, &hdr, sizeof(hdr));
if (ret != sizeof(hdr)) {
error_report("failed to send a req, %s", strerror(errno));
goto out;
}
if (wlen) {
ret = qemu_co_sendv(s->fd, iov, niov, aio_req->iov_offset, wlen);
if (ret != wlen) {
error_report("failed to send a data, %s", strerror(errno));
}
}
out:
socket_set_cork(s->fd, 0);
aio_set_fd_handler(s->aio_context, s->fd, co_read_response, NULL, s);
s->co_send = NULL;
qemu_co_mutex_unlock(&s->lock);
}
| true | qemu | b544c1aba8681c2fe5d6715fbd37cf6caf1bc7bb | static void coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req,
struct iovec *iov, int niov, bool create,
enum AIOCBState aiocb_type)
{
int nr_copies = s->inode.nr_copies;
SheepdogObjReq hdr;
unsigned int wlen = 0;
int ret;
uint64_t oid = aio_req->oid;
unsigned int datalen = aio_req->data_len;
uint64_t offset = aio_req->offset;
uint8_t flags = aio_req->flags;
uint64_t old_oid = aio_req->base_oid;
if (!nr_copies) {
error_report("bug");
}
memset(&hdr, 0, sizeof(hdr));
switch (aiocb_type) {
case AIOCB_FLUSH_CACHE:
hdr.opcode = SD_OP_FLUSH_VDI;
break;
case AIOCB_READ_UDATA:
hdr.opcode = SD_OP_READ_OBJ;
hdr.flags = flags;
break;
case AIOCB_WRITE_UDATA:
if (create) {
hdr.opcode = SD_OP_CREATE_AND_WRITE_OBJ;
} else {
hdr.opcode = SD_OP_WRITE_OBJ;
}
wlen = datalen;
hdr.flags = SD_FLAG_CMD_WRITE | flags;
break;
case AIOCB_DISCARD_OBJ:
hdr.opcode = SD_OP_DISCARD_OBJ;
break;
}
if (s->cache_flags) {
hdr.flags |= s->cache_flags;
}
hdr.oid = oid;
hdr.cow_oid = old_oid;
hdr.copies = s->inode.nr_copies;
hdr.data_length = datalen;
hdr.offset = offset;
hdr.id = aio_req->id;
qemu_co_mutex_lock(&s->lock);
s->co_send = qemu_coroutine_self();
aio_set_fd_handler(s->aio_context, s->fd,
co_read_response, co_write_request, s);
socket_set_cork(s->fd, 1);
ret = qemu_co_send(s->fd, &hdr, sizeof(hdr));
if (ret != sizeof(hdr)) {
error_report("failed to send a req, %s", strerror(errno));
goto out;
}
if (wlen) {
ret = qemu_co_sendv(s->fd, iov, niov, aio_req->iov_offset, wlen);
if (ret != wlen) {
error_report("failed to send a data, %s", strerror(errno));
}
}
out:
socket_set_cork(s->fd, 0);
aio_set_fd_handler(s->aio_context, s->fd, co_read_response, NULL, s);
s->co_send = NULL;
qemu_co_mutex_unlock(&s->lock);
}
| {
"code": [
" struct iovec *iov, int niov, bool create,",
" struct iovec *iov, int niov, bool create,",
" enum AIOCBState aiocb_type)"
],
"line_no": [
3,
3,
5
]
} | static void VAR_0 add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req,
struct iovec *iov, int niov, bool create,
enum AIOCBState aiocb_type)
{
int nr_copies = s->inode.nr_copies;
SheepdogObjReq hdr;
unsigned int wlen = 0;
int ret;
uint64_t oid = aio_req->oid;
unsigned int datalen = aio_req->data_len;
uint64_t offset = aio_req->offset;
uint8_t flags = aio_req->flags;
uint64_t old_oid = aio_req->base_oid;
if (!nr_copies) {
error_report("bug");
}
memset(&hdr, 0, sizeof(hdr));
switch (aiocb_type) {
case AIOCB_FLUSH_CACHE:
hdr.opcode = SD_OP_FLUSH_VDI;
break;
case AIOCB_READ_UDATA:
hdr.opcode = SD_OP_READ_OBJ;
hdr.flags = flags;
break;
case AIOCB_WRITE_UDATA:
if (create) {
hdr.opcode = SD_OP_CREATE_AND_WRITE_OBJ;
} else {
hdr.opcode = SD_OP_WRITE_OBJ;
}
wlen = datalen;
hdr.flags = SD_FLAG_CMD_WRITE | flags;
break;
case AIOCB_DISCARD_OBJ:
hdr.opcode = SD_OP_DISCARD_OBJ;
break;
}
if (s->cache_flags) {
hdr.flags |= s->cache_flags;
}
hdr.oid = oid;
hdr.cow_oid = old_oid;
hdr.copies = s->inode.nr_copies;
hdr.data_length = datalen;
hdr.offset = offset;
hdr.id = aio_req->id;
qemu_co_mutex_lock(&s->lock);
s->co_send = qemu_coroutine_self();
aio_set_fd_handler(s->aio_context, s->fd,
co_read_response, co_write_request, s);
socket_set_cork(s->fd, 1);
ret = qemu_co_send(s->fd, &hdr, sizeof(hdr));
if (ret != sizeof(hdr)) {
error_report("failed to send a req, %s", strerror(errno));
goto out;
}
if (wlen) {
ret = qemu_co_sendv(s->fd, iov, niov, aio_req->iov_offset, wlen);
if (ret != wlen) {
error_report("failed to send a data, %s", strerror(errno));
}
}
out:
socket_set_cork(s->fd, 0);
aio_set_fd_handler(s->aio_context, s->fd, co_read_response, NULL, s);
s->co_send = NULL;
qemu_co_mutex_unlock(&s->lock);
}
| [
"static void VAR_0 add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req,\nstruct iovec *iov, int niov, bool create,\nenum AIOCBState aiocb_type)\n{",
"int nr_copies = s->inode.nr_copies;",
"SheepdogObjReq hdr;",
"unsigned int wlen = 0;",
"int ret;",
"uint64_t oid = aio_req->oid;",
"unsigned int datalen = aio_req->data_len;",
"uint64_t offset = aio_req->offset;",
"uint8_t flags = aio_req->flags;",
"uint64_t old_oid = aio_req->base_oid;",
"if (!nr_copies) {",
"error_report(\"bug\");",
"}",
"memset(&hdr, 0, sizeof(hdr));",
"switch (aiocb_type) {",
"case AIOCB_FLUSH_CACHE:\nhdr.opcode = SD_OP_FLUSH_VDI;",
"break;",
"case AIOCB_READ_UDATA:\nhdr.opcode = SD_OP_READ_OBJ;",
"hdr.flags = flags;",
"break;",
"case AIOCB_WRITE_UDATA:\nif (create) {",
"hdr.opcode = SD_OP_CREATE_AND_WRITE_OBJ;",
"} else {",
"hdr.opcode = SD_OP_WRITE_OBJ;",
"}",
"wlen = datalen;",
"hdr.flags = SD_FLAG_CMD_WRITE | flags;",
"break;",
"case AIOCB_DISCARD_OBJ:\nhdr.opcode = SD_OP_DISCARD_OBJ;",
"break;",
"}",
"if (s->cache_flags) {",
"hdr.flags |= s->cache_flags;",
"}",
"hdr.oid = oid;",
"hdr.cow_oid = old_oid;",
"hdr.copies = s->inode.nr_copies;",
"hdr.data_length = datalen;",
"hdr.offset = offset;",
"hdr.id = aio_req->id;",
"qemu_co_mutex_lock(&s->lock);",
"s->co_send = qemu_coroutine_self();",
"aio_set_fd_handler(s->aio_context, s->fd,\nco_read_response, co_write_request, s);",
"socket_set_cork(s->fd, 1);",
"ret = qemu_co_send(s->fd, &hdr, sizeof(hdr));",
"if (ret != sizeof(hdr)) {",
"error_report(\"failed to send a req, %s\", strerror(errno));",
"goto out;",
"}",
"if (wlen) {",
"ret = qemu_co_sendv(s->fd, iov, niov, aio_req->iov_offset, wlen);",
"if (ret != wlen) {",
"error_report(\"failed to send a data, %s\", strerror(errno));",
"}",
"}",
"out:\nsocket_set_cork(s->fd, 0);",
"aio_set_fd_handler(s->aio_context, s->fd, co_read_response, NULL, s);",
"s->co_send = NULL;",
"qemu_co_mutex_unlock(&s->lock);",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
41
],
[
43,
45
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
107
],
[
111
],
[
113
],
[
115,
117
],
[
119
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149,
151
],
[
153
],
[
155
],
[
157
],
[
159
]
] |
25,909 | static void init_proc_750gx (CPUPPCState *env)
{
gen_spr_ne_601(env);
gen_spr_7xx(env);
/* XXX : not implemented (XXX: different from 750fx) */
spr_register(env, SPR_L2CR, "L2CR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, NULL,
0x00000000);
/* Time base */
gen_tbl(env);
/* Thermal management */
gen_spr_thrm(env);
/* XXX : not implemented */
spr_register(env, SPR_750_THRM4, "THRM4",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
/* Hardware implementation registers */
/* XXX : not implemented (XXX: different from 750fx) */
spr_register(env, SPR_HID0, "HID0",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
/* XXX : not implemented */
spr_register(env, SPR_HID1, "HID1",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
/* XXX : not implemented (XXX: different from 750fx) */
spr_register(env, SPR_750FX_HID2, "HID2",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
/* Memory management */
gen_low_BATs(env);
/* PowerPC 750fx & 750gx has 8 DBATs and 8 IBATs */
gen_high_BATs(env);
init_excp_7x0(env);
env->dcache_line_size = 32;
env->icache_line_size = 32;
/* Allocate hardware IRQ controller */
ppc6xx_irq_init(env);
}
| true | qemu | 9633fcc6a02f23e3ef00aa5fe3fe9c41f57c3456 | static void init_proc_750gx (CPUPPCState *env)
{
gen_spr_ne_601(env);
gen_spr_7xx(env);
spr_register(env, SPR_L2CR, "L2CR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, NULL,
0x00000000);
gen_tbl(env);
gen_spr_thrm(env);
spr_register(env, SPR_750_THRM4, "THRM4",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_HID0, "HID0",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_HID1, "HID1",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_750FX_HID2, "HID2",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
gen_low_BATs(env);
gen_high_BATs(env);
init_excp_7x0(env);
env->dcache_line_size = 32;
env->icache_line_size = 32;
ppc6xx_irq_init(env);
}
| {
"code": [
" &spr_read_generic, NULL,",
" &spr_read_generic, NULL,",
" &spr_read_generic, NULL,",
" &spr_read_generic, NULL,",
" &spr_read_generic, NULL,",
" &spr_read_generic, NULL,",
" &spr_read_generic, NULL,",
" &spr_read_generic, NULL,",
" &spr_read_generic, NULL,",
" &spr_read_generic, NULL,",
" &spr_read_generic, NULL,",
" &spr_read_generic, NULL,"
],
"line_no": [
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15
]
} | static void FUNC_0 (CPUPPCState *VAR_0)
{
gen_spr_ne_601(VAR_0);
gen_spr_7xx(VAR_0);
spr_register(VAR_0, SPR_L2CR, "L2CR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, NULL,
0x00000000);
gen_tbl(VAR_0);
gen_spr_thrm(VAR_0);
spr_register(VAR_0, SPR_750_THRM4, "THRM4",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(VAR_0, SPR_HID0, "HID0",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(VAR_0, SPR_HID1, "HID1",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(VAR_0, SPR_750FX_HID2, "HID2",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
gen_low_BATs(VAR_0);
gen_high_BATs(VAR_0);
init_excp_7x0(VAR_0);
VAR_0->dcache_line_size = 32;
VAR_0->icache_line_size = 32;
ppc6xx_irq_init(VAR_0);
}
| [
"static void FUNC_0 (CPUPPCState *VAR_0)\n{",
"gen_spr_ne_601(VAR_0);",
"gen_spr_7xx(VAR_0);",
"spr_register(VAR_0, SPR_L2CR, \"L2CR\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, NULL,\n0x00000000);",
"gen_tbl(VAR_0);",
"gen_spr_thrm(VAR_0);",
"spr_register(VAR_0, SPR_750_THRM4, \"THRM4\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\n0x00000000);",
"spr_register(VAR_0, SPR_HID0, \"HID0\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\n0x00000000);",
"spr_register(VAR_0, SPR_HID1, \"HID1\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\n0x00000000);",
"spr_register(VAR_0, SPR_750FX_HID2, \"HID2\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\n0x00000000);",
"gen_low_BATs(VAR_0);",
"gen_high_BATs(VAR_0);",
"init_excp_7x0(VAR_0);",
"VAR_0->dcache_line_size = 32;",
"VAR_0->icache_line_size = 32;",
"ppc6xx_irq_init(VAR_0);",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13,
15,
17
],
[
21
],
[
25
],
[
29,
31,
33,
35
],
[
41,
43,
45,
47
],
[
51,
53,
55,
57
],
[
61,
63,
65,
67
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
]
] |
25,910 | static int cloop_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVCloopState *s = bs->opaque;
uint32_t offsets_size, max_compressed_block_size = 1, i;
int ret;
bs->read_only = 1;
/* read header */
ret = bdrv_pread(bs->file, 128, &s->block_size, 4);
if (ret < 0) {
return ret;
}
s->block_size = be32_to_cpu(s->block_size);
if (s->block_size % 512) {
error_setg(errp, "block_size %u must be a multiple of 512",
s->block_size);
return -EINVAL;
}
if (s->block_size == 0) {
error_setg(errp, "block_size cannot be zero");
return -EINVAL;
}
/* cloop's create_compressed_fs.c warns about block sizes beyond 256 KB but
* we can accept more. Prevent ridiculous values like 4 GB - 1 since we
* need a buffer this big.
*/
if (s->block_size > MAX_BLOCK_SIZE) {
error_setg(errp, "block_size %u must be %u MB or less",
s->block_size,
MAX_BLOCK_SIZE / (1024 * 1024));
return -EINVAL;
}
ret = bdrv_pread(bs->file, 128 + 4, &s->n_blocks, 4);
if (ret < 0) {
return ret;
}
s->n_blocks = be32_to_cpu(s->n_blocks);
/* read offsets */
if (s->n_blocks > UINT32_MAX / sizeof(uint64_t)) {
/* Prevent integer overflow */
error_setg(errp, "n_blocks %u must be %zu or less",
s->n_blocks,
UINT32_MAX / sizeof(uint64_t));
return -EINVAL;
}
offsets_size = s->n_blocks * sizeof(uint64_t);
if (offsets_size > 512 * 1024 * 1024) {
/* Prevent ridiculous offsets_size which causes memory allocation to
* fail or overflows bdrv_pread() size. In practice the 512 MB
* offsets[] limit supports 16 TB images at 256 KB block size.
*/
error_setg(errp, "image requires too many offsets, "
"try increasing block size");
return -EINVAL;
}
s->offsets = g_malloc(offsets_size);
ret = bdrv_pread(bs->file, 128 + 4 + 4, s->offsets, offsets_size);
if (ret < 0) {
goto fail;
}
for(i=0;i<s->n_blocks;i++) {
s->offsets[i] = be64_to_cpu(s->offsets[i]);
if (i > 0) {
uint32_t size = s->offsets[i] - s->offsets[i - 1];
if (size > max_compressed_block_size) {
max_compressed_block_size = size;
}
}
}
/* initialize zlib engine */
s->compressed_block = g_malloc(max_compressed_block_size + 1);
s->uncompressed_block = g_malloc(s->block_size);
if (inflateInit(&s->zstream) != Z_OK) {
ret = -EINVAL;
goto fail;
}
s->current_block = s->n_blocks;
s->sectors_per_block = s->block_size/512;
bs->total_sectors = s->n_blocks * s->sectors_per_block;
qemu_co_mutex_init(&s->lock);
return 0;
fail:
g_free(s->offsets);
g_free(s->compressed_block);
g_free(s->uncompressed_block);
return ret;
}
| true | qemu | f56b9bc3ae20fc93815b34aa022be919941406ce | static int cloop_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVCloopState *s = bs->opaque;
uint32_t offsets_size, max_compressed_block_size = 1, i;
int ret;
bs->read_only = 1;
ret = bdrv_pread(bs->file, 128, &s->block_size, 4);
if (ret < 0) {
return ret;
}
s->block_size = be32_to_cpu(s->block_size);
if (s->block_size % 512) {
error_setg(errp, "block_size %u must be a multiple of 512",
s->block_size);
return -EINVAL;
}
if (s->block_size == 0) {
error_setg(errp, "block_size cannot be zero");
return -EINVAL;
}
if (s->block_size > MAX_BLOCK_SIZE) {
error_setg(errp, "block_size %u must be %u MB or less",
s->block_size,
MAX_BLOCK_SIZE / (1024 * 1024));
return -EINVAL;
}
ret = bdrv_pread(bs->file, 128 + 4, &s->n_blocks, 4);
if (ret < 0) {
return ret;
}
s->n_blocks = be32_to_cpu(s->n_blocks);
if (s->n_blocks > UINT32_MAX / sizeof(uint64_t)) {
error_setg(errp, "n_blocks %u must be %zu or less",
s->n_blocks,
UINT32_MAX / sizeof(uint64_t));
return -EINVAL;
}
offsets_size = s->n_blocks * sizeof(uint64_t);
if (offsets_size > 512 * 1024 * 1024) {
error_setg(errp, "image requires too many offsets, "
"try increasing block size");
return -EINVAL;
}
s->offsets = g_malloc(offsets_size);
ret = bdrv_pread(bs->file, 128 + 4 + 4, s->offsets, offsets_size);
if (ret < 0) {
goto fail;
}
for(i=0;i<s->n_blocks;i++) {
s->offsets[i] = be64_to_cpu(s->offsets[i]);
if (i > 0) {
uint32_t size = s->offsets[i] - s->offsets[i - 1];
if (size > max_compressed_block_size) {
max_compressed_block_size = size;
}
}
}
s->compressed_block = g_malloc(max_compressed_block_size + 1);
s->uncompressed_block = g_malloc(s->block_size);
if (inflateInit(&s->zstream) != Z_OK) {
ret = -EINVAL;
goto fail;
}
s->current_block = s->n_blocks;
s->sectors_per_block = s->block_size/512;
bs->total_sectors = s->n_blocks * s->sectors_per_block;
qemu_co_mutex_init(&s->lock);
return 0;
fail:
g_free(s->offsets);
g_free(s->compressed_block);
g_free(s->uncompressed_block);
return ret;
}
| {
"code": [
" if (i > 0) {",
" uint32_t size = s->offsets[i] - s->offsets[i - 1];",
" if (size > max_compressed_block_size) {",
" max_compressed_block_size = size;"
],
"line_no": [
139,
141,
143,
145
]
} | static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,
Error **VAR_3)
{
BDRVCloopState *s = VAR_0->opaque;
uint32_t offsets_size, max_compressed_block_size = 1, i;
int VAR_4;
VAR_0->read_only = 1;
VAR_4 = bdrv_pread(VAR_0->file, 128, &s->block_size, 4);
if (VAR_4 < 0) {
return VAR_4;
}
s->block_size = be32_to_cpu(s->block_size);
if (s->block_size % 512) {
error_setg(VAR_3, "block_size %u must be a multiple of 512",
s->block_size);
return -EINVAL;
}
if (s->block_size == 0) {
error_setg(VAR_3, "block_size cannot be zero");
return -EINVAL;
}
if (s->block_size > MAX_BLOCK_SIZE) {
error_setg(VAR_3, "block_size %u must be %u MB or less",
s->block_size,
MAX_BLOCK_SIZE / (1024 * 1024));
return -EINVAL;
}
VAR_4 = bdrv_pread(VAR_0->file, 128 + 4, &s->n_blocks, 4);
if (VAR_4 < 0) {
return VAR_4;
}
s->n_blocks = be32_to_cpu(s->n_blocks);
if (s->n_blocks > UINT32_MAX / sizeof(uint64_t)) {
error_setg(VAR_3, "n_blocks %u must be %zu or less",
s->n_blocks,
UINT32_MAX / sizeof(uint64_t));
return -EINVAL;
}
offsets_size = s->n_blocks * sizeof(uint64_t);
if (offsets_size > 512 * 1024 * 1024) {
error_setg(VAR_3, "image requires too many offsets, "
"try increasing block size");
return -EINVAL;
}
s->offsets = g_malloc(offsets_size);
VAR_4 = bdrv_pread(VAR_0->file, 128 + 4 + 4, s->offsets, offsets_size);
if (VAR_4 < 0) {
goto fail;
}
for(i=0;i<s->n_blocks;i++) {
s->offsets[i] = be64_to_cpu(s->offsets[i]);
if (i > 0) {
uint32_t size = s->offsets[i] - s->offsets[i - 1];
if (size > max_compressed_block_size) {
max_compressed_block_size = size;
}
}
}
s->compressed_block = g_malloc(max_compressed_block_size + 1);
s->uncompressed_block = g_malloc(s->block_size);
if (inflateInit(&s->zstream) != Z_OK) {
VAR_4 = -EINVAL;
goto fail;
}
s->current_block = s->n_blocks;
s->sectors_per_block = s->block_size/512;
VAR_0->total_sectors = s->n_blocks * s->sectors_per_block;
qemu_co_mutex_init(&s->lock);
return 0;
fail:
g_free(s->offsets);
g_free(s->compressed_block);
g_free(s->uncompressed_block);
return VAR_4;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,\nError **VAR_3)\n{",
"BDRVCloopState *s = VAR_0->opaque;",
"uint32_t offsets_size, max_compressed_block_size = 1, i;",
"int VAR_4;",
"VAR_0->read_only = 1;",
"VAR_4 = bdrv_pread(VAR_0->file, 128, &s->block_size, 4);",
"if (VAR_4 < 0) {",
"return VAR_4;",
"}",
"s->block_size = be32_to_cpu(s->block_size);",
"if (s->block_size % 512) {",
"error_setg(VAR_3, \"block_size %u must be a multiple of 512\",\ns->block_size);",
"return -EINVAL;",
"}",
"if (s->block_size == 0) {",
"error_setg(VAR_3, \"block_size cannot be zero\");",
"return -EINVAL;",
"}",
"if (s->block_size > MAX_BLOCK_SIZE) {",
"error_setg(VAR_3, \"block_size %u must be %u MB or less\",\ns->block_size,\nMAX_BLOCK_SIZE / (1024 * 1024));",
"return -EINVAL;",
"}",
"VAR_4 = bdrv_pread(VAR_0->file, 128 + 4, &s->n_blocks, 4);",
"if (VAR_4 < 0) {",
"return VAR_4;",
"}",
"s->n_blocks = be32_to_cpu(s->n_blocks);",
"if (s->n_blocks > UINT32_MAX / sizeof(uint64_t)) {",
"error_setg(VAR_3, \"n_blocks %u must be %zu or less\",\ns->n_blocks,\nUINT32_MAX / sizeof(uint64_t));",
"return -EINVAL;",
"}",
"offsets_size = s->n_blocks * sizeof(uint64_t);",
"if (offsets_size > 512 * 1024 * 1024) {",
"error_setg(VAR_3, \"image requires too many offsets, \"\n\"try increasing block size\");",
"return -EINVAL;",
"}",
"s->offsets = g_malloc(offsets_size);",
"VAR_4 = bdrv_pread(VAR_0->file, 128 + 4 + 4, s->offsets, offsets_size);",
"if (VAR_4 < 0) {",
"goto fail;",
"}",
"for(i=0;i<s->n_blocks;i++) {",
"s->offsets[i] = be64_to_cpu(s->offsets[i]);",
"if (i > 0) {",
"uint32_t size = s->offsets[i] - s->offsets[i - 1];",
"if (size > max_compressed_block_size) {",
"max_compressed_block_size = size;",
"}",
"}",
"}",
"s->compressed_block = g_malloc(max_compressed_block_size + 1);",
"s->uncompressed_block = g_malloc(s->block_size);",
"if (inflateInit(&s->zstream) != Z_OK) {",
"VAR_4 = -EINVAL;",
"goto fail;",
"}",
"s->current_block = s->n_blocks;",
"s->sectors_per_block = s->block_size/512;",
"VAR_0->total_sectors = s->n_blocks * s->sectors_per_block;",
"qemu_co_mutex_init(&s->lock);",
"return 0;",
"fail:\ng_free(s->offsets);",
"g_free(s->compressed_block);",
"g_free(s->uncompressed_block);",
"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,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
59
],
[
61,
63,
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
87
],
[
91,
93,
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
113,
115
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173
],
[
175
],
[
177
],
[
179
],
[
183,
185
],
[
187
],
[
189
],
[
191
],
[
193
]
] |
25,911 | static void spapr_tce_table_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->vmsd = &vmstate_spapr_tce_table;
dc->init = spapr_tce_table_realize;
dc->reset = spapr_tce_reset;
QLIST_INIT(&spapr_tce_tables);
/* hcall-tce */
spapr_register_hypercall(H_PUT_TCE, h_put_tce);
} | true | qemu | a0fcac9c21dcbf481eeb5573a738f55023f5a953 | static void spapr_tce_table_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->vmsd = &vmstate_spapr_tce_table;
dc->init = spapr_tce_table_realize;
dc->reset = spapr_tce_reset;
QLIST_INIT(&spapr_tce_tables);
spapr_register_hypercall(H_PUT_TCE, h_put_tce);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
DeviceClass *dc = DEVICE_CLASS(VAR_0);
dc->vmsd = &vmstate_spapr_tce_table;
dc->init = spapr_tce_table_realize;
dc->reset = spapr_tce_reset;
QLIST_INIT(&spapr_tce_tables);
spapr_register_hypercall(H_PUT_TCE, h_put_tce);
} | [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"DeviceClass *dc = DEVICE_CLASS(VAR_0);",
"dc->vmsd = &vmstate_spapr_tce_table;",
"dc->init = spapr_tce_table_realize;",
"dc->reset = spapr_tce_reset;",
"QLIST_INIT(&spapr_tce_tables);",
"spapr_register_hypercall(H_PUT_TCE, h_put_tce);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
21
],
[
24
]
] |
25,912 | static void gmc1_motion(MpegEncContext *s,
uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
uint8_t **ref_picture)
{
uint8_t *ptr;
int src_x, src_y, motion_x, motion_y;
ptrdiff_t offset, linesize, uvlinesize;
int emu = 0;
motion_x = s->sprite_offset[0][0];
motion_y = s->sprite_offset[0][1];
src_x = s->mb_x * 16 + (motion_x >> (s->sprite_warping_accuracy + 1));
src_y = s->mb_y * 16 + (motion_y >> (s->sprite_warping_accuracy + 1));
motion_x <<= (3 - s->sprite_warping_accuracy);
motion_y <<= (3 - s->sprite_warping_accuracy);
src_x = av_clip(src_x, -16, s->width);
if (src_x == s->width)
motion_x = 0;
src_y = av_clip(src_y, -16, s->height);
if (src_y == s->height)
motion_y = 0;
linesize = s->linesize;
uvlinesize = s->uvlinesize;
ptr = ref_picture[0] + src_y * linesize + src_x;
if ((unsigned)src_x >= FFMAX(s->h_edge_pos - 17, 0) ||
(unsigned)src_y >= FFMAX(s->v_edge_pos - 17, 0)) {
s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr,
linesize, linesize,
17, 17,
src_x, src_y,
s->h_edge_pos, s->v_edge_pos);
ptr = s->sc.edge_emu_buffer;
}
if ((motion_x | motion_y) & 7) {
s->mdsp.gmc1(dest_y, ptr, linesize, 16,
motion_x & 15, motion_y & 15, 128 - s->no_rounding);
s->mdsp.gmc1(dest_y + 8, ptr + 8, linesize, 16,
motion_x & 15, motion_y & 15, 128 - s->no_rounding);
} else {
int dxy;
dxy = ((motion_x >> 3) & 1) | ((motion_y >> 2) & 2);
if (s->no_rounding) {
s->hdsp.put_no_rnd_pixels_tab[0][dxy](dest_y, ptr, linesize, 16);
} else {
s->hdsp.put_pixels_tab[0][dxy](dest_y, ptr, linesize, 16);
}
}
if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY)
return;
motion_x = s->sprite_offset[1][0];
motion_y = s->sprite_offset[1][1];
src_x = s->mb_x * 8 + (motion_x >> (s->sprite_warping_accuracy + 1));
src_y = s->mb_y * 8 + (motion_y >> (s->sprite_warping_accuracy + 1));
motion_x <<= (3 - s->sprite_warping_accuracy);
motion_y <<= (3 - s->sprite_warping_accuracy);
src_x = av_clip(src_x, -8, s->width >> 1);
if (src_x == s->width >> 1)
motion_x = 0;
src_y = av_clip(src_y, -8, s->height >> 1);
if (src_y == s->height >> 1)
motion_y = 0;
offset = (src_y * uvlinesize) + src_x;
ptr = ref_picture[1] + offset;
if ((unsigned)src_x >= FFMAX((s->h_edge_pos >> 1) - 9, 0) ||
(unsigned)src_y >= FFMAX((s->v_edge_pos >> 1) - 9, 0)) {
s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr,
uvlinesize, uvlinesize,
9, 9,
src_x, src_y,
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
ptr = s->sc.edge_emu_buffer;
emu = 1;
}
s->mdsp.gmc1(dest_cb, ptr, uvlinesize, 8,
motion_x & 15, motion_y & 15, 128 - s->no_rounding);
ptr = ref_picture[2] + offset;
if (emu) {
s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr,
uvlinesize, uvlinesize,
9, 9,
src_x, src_y,
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
ptr = s->sc.edge_emu_buffer;
}
s->mdsp.gmc1(dest_cr, ptr, uvlinesize, 8,
motion_x & 15, motion_y & 15, 128 - s->no_rounding);
}
| true | FFmpeg | 6179dc8aa7e5fc5358b9614306f93f1adadf22a4 | static void gmc1_motion(MpegEncContext *s,
uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
uint8_t **ref_picture)
{
uint8_t *ptr;
int src_x, src_y, motion_x, motion_y;
ptrdiff_t offset, linesize, uvlinesize;
int emu = 0;
motion_x = s->sprite_offset[0][0];
motion_y = s->sprite_offset[0][1];
src_x = s->mb_x * 16 + (motion_x >> (s->sprite_warping_accuracy + 1));
src_y = s->mb_y * 16 + (motion_y >> (s->sprite_warping_accuracy + 1));
motion_x <<= (3 - s->sprite_warping_accuracy);
motion_y <<= (3 - s->sprite_warping_accuracy);
src_x = av_clip(src_x, -16, s->width);
if (src_x == s->width)
motion_x = 0;
src_y = av_clip(src_y, -16, s->height);
if (src_y == s->height)
motion_y = 0;
linesize = s->linesize;
uvlinesize = s->uvlinesize;
ptr = ref_picture[0] + src_y * linesize + src_x;
if ((unsigned)src_x >= FFMAX(s->h_edge_pos - 17, 0) ||
(unsigned)src_y >= FFMAX(s->v_edge_pos - 17, 0)) {
s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr,
linesize, linesize,
17, 17,
src_x, src_y,
s->h_edge_pos, s->v_edge_pos);
ptr = s->sc.edge_emu_buffer;
}
if ((motion_x | motion_y) & 7) {
s->mdsp.gmc1(dest_y, ptr, linesize, 16,
motion_x & 15, motion_y & 15, 128 - s->no_rounding);
s->mdsp.gmc1(dest_y + 8, ptr + 8, linesize, 16,
motion_x & 15, motion_y & 15, 128 - s->no_rounding);
} else {
int dxy;
dxy = ((motion_x >> 3) & 1) | ((motion_y >> 2) & 2);
if (s->no_rounding) {
s->hdsp.put_no_rnd_pixels_tab[0][dxy](dest_y, ptr, linesize, 16);
} else {
s->hdsp.put_pixels_tab[0][dxy](dest_y, ptr, linesize, 16);
}
}
if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY)
return;
motion_x = s->sprite_offset[1][0];
motion_y = s->sprite_offset[1][1];
src_x = s->mb_x * 8 + (motion_x >> (s->sprite_warping_accuracy + 1));
src_y = s->mb_y * 8 + (motion_y >> (s->sprite_warping_accuracy + 1));
motion_x <<= (3 - s->sprite_warping_accuracy);
motion_y <<= (3 - s->sprite_warping_accuracy);
src_x = av_clip(src_x, -8, s->width >> 1);
if (src_x == s->width >> 1)
motion_x = 0;
src_y = av_clip(src_y, -8, s->height >> 1);
if (src_y == s->height >> 1)
motion_y = 0;
offset = (src_y * uvlinesize) + src_x;
ptr = ref_picture[1] + offset;
if ((unsigned)src_x >= FFMAX((s->h_edge_pos >> 1) - 9, 0) ||
(unsigned)src_y >= FFMAX((s->v_edge_pos >> 1) - 9, 0)) {
s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr,
uvlinesize, uvlinesize,
9, 9,
src_x, src_y,
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
ptr = s->sc.edge_emu_buffer;
emu = 1;
}
s->mdsp.gmc1(dest_cb, ptr, uvlinesize, 8,
motion_x & 15, motion_y & 15, 128 - s->no_rounding);
ptr = ref_picture[2] + offset;
if (emu) {
s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr,
uvlinesize, uvlinesize,
9, 9,
src_x, src_y,
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
ptr = s->sc.edge_emu_buffer;
}
s->mdsp.gmc1(dest_cr, ptr, uvlinesize, 8,
motion_x & 15, motion_y & 15, 128 - s->no_rounding);
}
| {
"code": [
" motion_x <<= (3 - s->sprite_warping_accuracy);",
" motion_y <<= (3 - s->sprite_warping_accuracy);",
" motion_x <<= (3 - s->sprite_warping_accuracy);",
" motion_y <<= (3 - s->sprite_warping_accuracy);"
],
"line_no": [
27,
29,
27,
29
]
} | static void FUNC_0(MpegEncContext *VAR_0,
uint8_t *VAR_1, uint8_t *VAR_2, uint8_t *VAR_3,
uint8_t **VAR_4)
{
uint8_t *ptr;
int VAR_5, VAR_6, VAR_7, VAR_8;
ptrdiff_t offset, linesize, uvlinesize;
int VAR_9 = 0;
VAR_7 = VAR_0->sprite_offset[0][0];
VAR_8 = VAR_0->sprite_offset[0][1];
VAR_5 = VAR_0->mb_x * 16 + (VAR_7 >> (VAR_0->sprite_warping_accuracy + 1));
VAR_6 = VAR_0->mb_y * 16 + (VAR_8 >> (VAR_0->sprite_warping_accuracy + 1));
VAR_7 <<= (3 - VAR_0->sprite_warping_accuracy);
VAR_8 <<= (3 - VAR_0->sprite_warping_accuracy);
VAR_5 = av_clip(VAR_5, -16, VAR_0->width);
if (VAR_5 == VAR_0->width)
VAR_7 = 0;
VAR_6 = av_clip(VAR_6, -16, VAR_0->height);
if (VAR_6 == VAR_0->height)
VAR_8 = 0;
linesize = VAR_0->linesize;
uvlinesize = VAR_0->uvlinesize;
ptr = VAR_4[0] + VAR_6 * linesize + VAR_5;
if ((unsigned)VAR_5 >= FFMAX(VAR_0->h_edge_pos - 17, 0) ||
(unsigned)VAR_6 >= FFMAX(VAR_0->v_edge_pos - 17, 0)) {
VAR_0->vdsp.emulated_edge_mc(VAR_0->sc.edge_emu_buffer, ptr,
linesize, linesize,
17, 17,
VAR_5, VAR_6,
VAR_0->h_edge_pos, VAR_0->v_edge_pos);
ptr = VAR_0->sc.edge_emu_buffer;
}
if ((VAR_7 | VAR_8) & 7) {
VAR_0->mdsp.gmc1(VAR_1, ptr, linesize, 16,
VAR_7 & 15, VAR_8 & 15, 128 - VAR_0->no_rounding);
VAR_0->mdsp.gmc1(VAR_1 + 8, ptr + 8, linesize, 16,
VAR_7 & 15, VAR_8 & 15, 128 - VAR_0->no_rounding);
} else {
int VAR_10;
VAR_10 = ((VAR_7 >> 3) & 1) | ((VAR_8 >> 2) & 2);
if (VAR_0->no_rounding) {
VAR_0->hdsp.put_no_rnd_pixels_tab[0][VAR_10](VAR_1, ptr, linesize, 16);
} else {
VAR_0->hdsp.put_pixels_tab[0][VAR_10](VAR_1, ptr, linesize, 16);
}
}
if (CONFIG_GRAY && VAR_0->avctx->flags & AV_CODEC_FLAG_GRAY)
return;
VAR_7 = VAR_0->sprite_offset[1][0];
VAR_8 = VAR_0->sprite_offset[1][1];
VAR_5 = VAR_0->mb_x * 8 + (VAR_7 >> (VAR_0->sprite_warping_accuracy + 1));
VAR_6 = VAR_0->mb_y * 8 + (VAR_8 >> (VAR_0->sprite_warping_accuracy + 1));
VAR_7 <<= (3 - VAR_0->sprite_warping_accuracy);
VAR_8 <<= (3 - VAR_0->sprite_warping_accuracy);
VAR_5 = av_clip(VAR_5, -8, VAR_0->width >> 1);
if (VAR_5 == VAR_0->width >> 1)
VAR_7 = 0;
VAR_6 = av_clip(VAR_6, -8, VAR_0->height >> 1);
if (VAR_6 == VAR_0->height >> 1)
VAR_8 = 0;
offset = (VAR_6 * uvlinesize) + VAR_5;
ptr = VAR_4[1] + offset;
if ((unsigned)VAR_5 >= FFMAX((VAR_0->h_edge_pos >> 1) - 9, 0) ||
(unsigned)VAR_6 >= FFMAX((VAR_0->v_edge_pos >> 1) - 9, 0)) {
VAR_0->vdsp.emulated_edge_mc(VAR_0->sc.edge_emu_buffer, ptr,
uvlinesize, uvlinesize,
9, 9,
VAR_5, VAR_6,
VAR_0->h_edge_pos >> 1, VAR_0->v_edge_pos >> 1);
ptr = VAR_0->sc.edge_emu_buffer;
VAR_9 = 1;
}
VAR_0->mdsp.gmc1(VAR_2, ptr, uvlinesize, 8,
VAR_7 & 15, VAR_8 & 15, 128 - VAR_0->no_rounding);
ptr = VAR_4[2] + offset;
if (VAR_9) {
VAR_0->vdsp.emulated_edge_mc(VAR_0->sc.edge_emu_buffer, ptr,
uvlinesize, uvlinesize,
9, 9,
VAR_5, VAR_6,
VAR_0->h_edge_pos >> 1, VAR_0->v_edge_pos >> 1);
ptr = VAR_0->sc.edge_emu_buffer;
}
VAR_0->mdsp.gmc1(VAR_3, ptr, uvlinesize, 8,
VAR_7 & 15, VAR_8 & 15, 128 - VAR_0->no_rounding);
}
| [
"static void FUNC_0(MpegEncContext *VAR_0,\nuint8_t *VAR_1, uint8_t *VAR_2, uint8_t *VAR_3,\nuint8_t **VAR_4)\n{",
"uint8_t *ptr;",
"int VAR_5, VAR_6, VAR_7, VAR_8;",
"ptrdiff_t offset, linesize, uvlinesize;",
"int VAR_9 = 0;",
"VAR_7 = VAR_0->sprite_offset[0][0];",
"VAR_8 = VAR_0->sprite_offset[0][1];",
"VAR_5 = VAR_0->mb_x * 16 + (VAR_7 >> (VAR_0->sprite_warping_accuracy + 1));",
"VAR_6 = VAR_0->mb_y * 16 + (VAR_8 >> (VAR_0->sprite_warping_accuracy + 1));",
"VAR_7 <<= (3 - VAR_0->sprite_warping_accuracy);",
"VAR_8 <<= (3 - VAR_0->sprite_warping_accuracy);",
"VAR_5 = av_clip(VAR_5, -16, VAR_0->width);",
"if (VAR_5 == VAR_0->width)\nVAR_7 = 0;",
"VAR_6 = av_clip(VAR_6, -16, VAR_0->height);",
"if (VAR_6 == VAR_0->height)\nVAR_8 = 0;",
"linesize = VAR_0->linesize;",
"uvlinesize = VAR_0->uvlinesize;",
"ptr = VAR_4[0] + VAR_6 * linesize + VAR_5;",
"if ((unsigned)VAR_5 >= FFMAX(VAR_0->h_edge_pos - 17, 0) ||\n(unsigned)VAR_6 >= FFMAX(VAR_0->v_edge_pos - 17, 0)) {",
"VAR_0->vdsp.emulated_edge_mc(VAR_0->sc.edge_emu_buffer, ptr,\nlinesize, linesize,\n17, 17,\nVAR_5, VAR_6,\nVAR_0->h_edge_pos, VAR_0->v_edge_pos);",
"ptr = VAR_0->sc.edge_emu_buffer;",
"}",
"if ((VAR_7 | VAR_8) & 7) {",
"VAR_0->mdsp.gmc1(VAR_1, ptr, linesize, 16,\nVAR_7 & 15, VAR_8 & 15, 128 - VAR_0->no_rounding);",
"VAR_0->mdsp.gmc1(VAR_1 + 8, ptr + 8, linesize, 16,\nVAR_7 & 15, VAR_8 & 15, 128 - VAR_0->no_rounding);",
"} else {",
"int VAR_10;",
"VAR_10 = ((VAR_7 >> 3) & 1) | ((VAR_8 >> 2) & 2);",
"if (VAR_0->no_rounding) {",
"VAR_0->hdsp.put_no_rnd_pixels_tab[0][VAR_10](VAR_1, ptr, linesize, 16);",
"} else {",
"VAR_0->hdsp.put_pixels_tab[0][VAR_10](VAR_1, ptr, linesize, 16);",
"}",
"}",
"if (CONFIG_GRAY && VAR_0->avctx->flags & AV_CODEC_FLAG_GRAY)\nreturn;",
"VAR_7 = VAR_0->sprite_offset[1][0];",
"VAR_8 = VAR_0->sprite_offset[1][1];",
"VAR_5 = VAR_0->mb_x * 8 + (VAR_7 >> (VAR_0->sprite_warping_accuracy + 1));",
"VAR_6 = VAR_0->mb_y * 8 + (VAR_8 >> (VAR_0->sprite_warping_accuracy + 1));",
"VAR_7 <<= (3 - VAR_0->sprite_warping_accuracy);",
"VAR_8 <<= (3 - VAR_0->sprite_warping_accuracy);",
"VAR_5 = av_clip(VAR_5, -8, VAR_0->width >> 1);",
"if (VAR_5 == VAR_0->width >> 1)\nVAR_7 = 0;",
"VAR_6 = av_clip(VAR_6, -8, VAR_0->height >> 1);",
"if (VAR_6 == VAR_0->height >> 1)\nVAR_8 = 0;",
"offset = (VAR_6 * uvlinesize) + VAR_5;",
"ptr = VAR_4[1] + offset;",
"if ((unsigned)VAR_5 >= FFMAX((VAR_0->h_edge_pos >> 1) - 9, 0) ||\n(unsigned)VAR_6 >= FFMAX((VAR_0->v_edge_pos >> 1) - 9, 0)) {",
"VAR_0->vdsp.emulated_edge_mc(VAR_0->sc.edge_emu_buffer, ptr,\nuvlinesize, uvlinesize,\n9, 9,\nVAR_5, VAR_6,\nVAR_0->h_edge_pos >> 1, VAR_0->v_edge_pos >> 1);",
"ptr = VAR_0->sc.edge_emu_buffer;",
"VAR_9 = 1;",
"}",
"VAR_0->mdsp.gmc1(VAR_2, ptr, uvlinesize, 8,\nVAR_7 & 15, VAR_8 & 15, 128 - VAR_0->no_rounding);",
"ptr = VAR_4[2] + offset;",
"if (VAR_9) {",
"VAR_0->vdsp.emulated_edge_mc(VAR_0->sc.edge_emu_buffer, ptr,\nuvlinesize, uvlinesize,\n9, 9,\nVAR_5, VAR_6,\nVAR_0->h_edge_pos >> 1, VAR_0->v_edge_pos >> 1);",
"ptr = VAR_0->sc.edge_emu_buffer;",
"}",
"VAR_0->mdsp.gmc1(VAR_3, ptr, uvlinesize, 8,\nVAR_7 & 15, VAR_8 & 15, 128 - VAR_0->no_rounding);",
"}"
] | [
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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39,
41
],
[
45
],
[
47
],
[
51
],
[
55,
57
],
[
59,
61,
63,
65,
67
],
[
69
],
[
71
],
[
75
],
[
77,
79
],
[
81,
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107,
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127,
129
],
[
131
],
[
133,
135
],
[
139
],
[
141
],
[
143,
145
],
[
147,
149,
151,
153,
155
],
[
157
],
[
159
],
[
161
],
[
163,
165
],
[
169
],
[
171
],
[
173,
175,
177,
179,
181
],
[
183
],
[
185
],
[
187,
189
],
[
191
]
] |
25,914 | static void gxf_write_padding(ByteIOContext *pb, offset_t to_pad)
{
while (to_pad--) {
put_byte(pb, 0);
}
}
| false | FFmpeg | 0e15b7b0dde44130069739bfb98c29e74c72be86 | static void gxf_write_padding(ByteIOContext *pb, offset_t to_pad)
{
while (to_pad--) {
put_byte(pb, 0);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(ByteIOContext *VAR_0, offset_t VAR_1)
{
while (VAR_1--) {
put_byte(VAR_0, 0);
}
}
| [
"static void FUNC_0(ByteIOContext *VAR_0, offset_t VAR_1)\n{",
"while (VAR_1--) {",
"put_byte(VAR_0, 0);",
"}",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
25,915 | static int aea_read_header(AVFormatContext *s)
{
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
/* Parse the amount of channels and skip to pos 2048(0x800) */
avio_skip(s->pb, 264);
st->codec->channels = avio_r8(s->pb);
avio_skip(s->pb, 1783);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_ATRAC1;
st->codec->sample_rate = 44100;
st->codec->bit_rate = 292000;
if (st->codec->channels != 1 && st->codec->channels != 2) {
av_log(s,AV_LOG_ERROR,"Channels %d not supported!\n",st->codec->channels);
return -1;
}
st->codec->channel_layout = (st->codec->channels == 1) ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO;
st->codec->block_align = AT1_SU_SIZE * st->codec->channels;
return 0;
}
| false | FFmpeg | 3941df546276b190cc9362fd093e6721e8e52f50 | static int aea_read_header(AVFormatContext *s)
{
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
avio_skip(s->pb, 264);
st->codec->channels = avio_r8(s->pb);
avio_skip(s->pb, 1783);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_ATRAC1;
st->codec->sample_rate = 44100;
st->codec->bit_rate = 292000;
if (st->codec->channels != 1 && st->codec->channels != 2) {
av_log(s,AV_LOG_ERROR,"Channels %d not supported!\n",st->codec->channels);
return -1;
}
st->codec->channel_layout = (st->codec->channels == 1) ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO;
st->codec->block_align = AT1_SU_SIZE * st->codec->channels;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0)
{
AVStream *st = avformat_new_stream(VAR_0, NULL);
if (!st)
return AVERROR(ENOMEM);
avio_skip(VAR_0->pb, 264);
st->codec->channels = avio_r8(VAR_0->pb);
avio_skip(VAR_0->pb, 1783);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_ATRAC1;
st->codec->sample_rate = 44100;
st->codec->bit_rate = 292000;
if (st->codec->channels != 1 && st->codec->channels != 2) {
av_log(VAR_0,AV_LOG_ERROR,"Channels %d not supported!\n",st->codec->channels);
return -1;
}
st->codec->channel_layout = (st->codec->channels == 1) ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO;
st->codec->block_align = AT1_SU_SIZE * st->codec->channels;
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"AVStream *st = avformat_new_stream(VAR_0, NULL);",
"if (!st)\nreturn AVERROR(ENOMEM);",
"avio_skip(VAR_0->pb, 264);",
"st->codec->channels = avio_r8(VAR_0->pb);",
"avio_skip(VAR_0->pb, 1783);",
"st->codec->codec_type = AVMEDIA_TYPE_AUDIO;",
"st->codec->codec_id = AV_CODEC_ID_ATRAC1;",
"st->codec->sample_rate = 44100;",
"st->codec->bit_rate = 292000;",
"if (st->codec->channels != 1 && st->codec->channels != 2) {",
"av_log(VAR_0,AV_LOG_ERROR,\"Channels %d not supported!\\n\",st->codec->channels);",
"return -1;",
"}",
"st->codec->channel_layout = (st->codec->channels == 1) ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO;",
"st->codec->block_align = AT1_SU_SIZE * st->codec->channels;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
15
],
[
17
],
[
19
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
49
],
[
51
],
[
53
]
] |
25,916 | static void spr_write_ibatl (void *opaque, int sprn)
{
DisasContext *ctx = opaque;
gen_op_store_ibatl((sprn - SPR_IBAT0L) / 2);
RET_STOP(ctx);
}
| false | qemu | e1833e1f96456fd8fc17463246fe0b2050e68efb | static void spr_write_ibatl (void *opaque, int sprn)
{
DisasContext *ctx = opaque;
gen_op_store_ibatl((sprn - SPR_IBAT0L) / 2);
RET_STOP(ctx);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0 (void *VAR_0, int VAR_1)
{
DisasContext *ctx = VAR_0;
gen_op_store_ibatl((VAR_1 - SPR_IBAT0L) / 2);
RET_STOP(ctx);
}
| [
"static void FUNC_0 (void *VAR_0, int VAR_1)\n{",
"DisasContext *ctx = VAR_0;",
"gen_op_store_ibatl((VAR_1 - SPR_IBAT0L) / 2);",
"RET_STOP(ctx);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
]
] |
25,917 | static void gen_eob_inhibit_irq(DisasContext *s, bool inhibit)
{
gen_update_cc_op(s);
/* If several instructions disable interrupts, only the first does it. */
if (inhibit && !(s->flags & HF_INHIBIT_IRQ_MASK)) {
gen_set_hflag(s, HF_INHIBIT_IRQ_MASK);
} else {
gen_reset_hflag(s, HF_INHIBIT_IRQ_MASK);
}
if (s->tb->flags & HF_RF_MASK) {
gen_helper_reset_rf(cpu_env);
}
if (s->singlestep_enabled) {
gen_helper_debug(cpu_env);
} else if (s->tf) {
gen_helper_single_step(cpu_env);
} else {
tcg_gen_exit_tb(0);
}
s->is_jmp = DISAS_TB_JUMP;
}
| false | qemu | c52ab08aee6f7d4717fc6b517174043126bd302f | static void gen_eob_inhibit_irq(DisasContext *s, bool inhibit)
{
gen_update_cc_op(s);
if (inhibit && !(s->flags & HF_INHIBIT_IRQ_MASK)) {
gen_set_hflag(s, HF_INHIBIT_IRQ_MASK);
} else {
gen_reset_hflag(s, HF_INHIBIT_IRQ_MASK);
}
if (s->tb->flags & HF_RF_MASK) {
gen_helper_reset_rf(cpu_env);
}
if (s->singlestep_enabled) {
gen_helper_debug(cpu_env);
} else if (s->tf) {
gen_helper_single_step(cpu_env);
} else {
tcg_gen_exit_tb(0);
}
s->is_jmp = DISAS_TB_JUMP;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0, bool VAR_1)
{
gen_update_cc_op(VAR_0);
if (VAR_1 && !(VAR_0->flags & HF_INHIBIT_IRQ_MASK)) {
gen_set_hflag(VAR_0, HF_INHIBIT_IRQ_MASK);
} else {
gen_reset_hflag(VAR_0, HF_INHIBIT_IRQ_MASK);
}
if (VAR_0->tb->flags & HF_RF_MASK) {
gen_helper_reset_rf(cpu_env);
}
if (VAR_0->singlestep_enabled) {
gen_helper_debug(cpu_env);
} else if (VAR_0->tf) {
gen_helper_single_step(cpu_env);
} else {
tcg_gen_exit_tb(0);
}
VAR_0->is_jmp = DISAS_TB_JUMP;
}
| [
"static void FUNC_0(DisasContext *VAR_0, bool VAR_1)\n{",
"gen_update_cc_op(VAR_0);",
"if (VAR_1 && !(VAR_0->flags & HF_INHIBIT_IRQ_MASK)) {",
"gen_set_hflag(VAR_0, HF_INHIBIT_IRQ_MASK);",
"} else {",
"gen_reset_hflag(VAR_0, HF_INHIBIT_IRQ_MASK);",
"}",
"if (VAR_0->tb->flags & HF_RF_MASK) {",
"gen_helper_reset_rf(cpu_env);",
"}",
"if (VAR_0->singlestep_enabled) {",
"gen_helper_debug(cpu_env);",
"} else if (VAR_0->tf) {",
"gen_helper_single_step(cpu_env);",
"} else {",
"tcg_gen_exit_tb(0);",
"}",
"VAR_0->is_jmp = DISAS_TB_JUMP;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
]
] |
25,918 | void tb_invalidate_page_range(target_ulong start, target_ulong end)
{
/* XXX: cannot enable it yet because it yields to MMU exception
where NIP != read address on PowerPC */
#if 0
target_ulong phys_addr;
phys_addr = get_phys_addr_code(env, start);
tb_invalidate_phys_page_range(phys_addr, phys_addr + end - start, 0);
#endif
}
| false | qemu | dcfd14b3741983c466ad92fa2ae91eeafce3e5d5 | void tb_invalidate_page_range(target_ulong start, target_ulong end)
{
#if 0
target_ulong phys_addr;
phys_addr = get_phys_addr_code(env, start);
tb_invalidate_phys_page_range(phys_addr, phys_addr + end - start, 0);
#endif
}
| {
"code": [],
"line_no": []
} | void FUNC_0(target_ulong VAR_0, target_ulong VAR_1)
{
#if 0
target_ulong phys_addr;
phys_addr = get_phys_addr_code(env, VAR_0);
tb_invalidate_phys_page_range(phys_addr, phys_addr + VAR_1 - VAR_0, 0);
#endif
}
| [
"void FUNC_0(target_ulong VAR_0, target_ulong VAR_1)\n{",
"#if 0\ntarget_ulong phys_addr;",
"phys_addr = get_phys_addr_code(env, VAR_0);",
"tb_invalidate_phys_page_range(phys_addr, phys_addr + VAR_1 - VAR_0, 0);",
"#endif\n}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
9,
11
],
[
13
],
[
15
],
[
17,
19
]
] |
25,919 | static bool kvmppc_is_pr(KVMState *ks)
{
/* Assume KVM-PR if the GET_PVINFO capability is available */
return kvm_check_extension(ks, KVM_CAP_PPC_GET_PVINFO) != 0;
}
| false | qemu | 70a0c19e83aa4c71c879d51e426e89e4b3d4e014 | static bool kvmppc_is_pr(KVMState *ks)
{
return kvm_check_extension(ks, KVM_CAP_PPC_GET_PVINFO) != 0;
}
| {
"code": [],
"line_no": []
} | static bool FUNC_0(KVMState *ks)
{
return kvm_check_extension(ks, KVM_CAP_PPC_GET_PVINFO) != 0;
}
| [
"static bool FUNC_0(KVMState *ks)\n{",
"return kvm_check_extension(ks, KVM_CAP_PPC_GET_PVINFO) != 0;",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
9
]
] |
25,920 | void aio_set_fd_handler(AioContext *ctx,
int fd,
IOHandler *io_read,
IOHandler *io_write,
AioFlushHandler *io_flush,
void *opaque)
{
AioHandler *node;
node = find_aio_handler(ctx, fd);
/* Are we deleting the fd handler? */
if (!io_read && !io_write) {
if (node) {
/* If the lock is held, just mark the node as deleted */
if (ctx->walking_handlers)
node->deleted = 1;
else {
/* Otherwise, delete it for real. We can't just mark it as
* deleted because deleted nodes are only cleaned up after
* releasing the walking_handlers lock.
*/
QLIST_REMOVE(node, node);
g_free(node);
}
}
} else {
if (node == NULL) {
/* Alloc and insert if it's not already there */
node = g_malloc0(sizeof(AioHandler));
node->fd = fd;
QLIST_INSERT_HEAD(&ctx->aio_handlers, node, node);
}
/* Update handler with latest information */
node->io_read = io_read;
node->io_write = io_write;
node->io_flush = io_flush;
node->opaque = opaque;
}
}
| false | qemu | cd9ba1ebcf0439457f22b75b38533f6634f23c5f | void aio_set_fd_handler(AioContext *ctx,
int fd,
IOHandler *io_read,
IOHandler *io_write,
AioFlushHandler *io_flush,
void *opaque)
{
AioHandler *node;
node = find_aio_handler(ctx, fd);
if (!io_read && !io_write) {
if (node) {
if (ctx->walking_handlers)
node->deleted = 1;
else {
QLIST_REMOVE(node, node);
g_free(node);
}
}
} else {
if (node == NULL) {
node = g_malloc0(sizeof(AioHandler));
node->fd = fd;
QLIST_INSERT_HEAD(&ctx->aio_handlers, node, node);
}
node->io_read = io_read;
node->io_write = io_write;
node->io_flush = io_flush;
node->opaque = opaque;
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(AioContext *VAR_0,
int VAR_1,
IOHandler *VAR_2,
IOHandler *VAR_3,
AioFlushHandler *VAR_4,
void *VAR_5)
{
AioHandler *node;
node = find_aio_handler(VAR_0, VAR_1);
if (!VAR_2 && !VAR_3) {
if (node) {
if (VAR_0->walking_handlers)
node->deleted = 1;
else {
QLIST_REMOVE(node, node);
g_free(node);
}
}
} else {
if (node == NULL) {
node = g_malloc0(sizeof(AioHandler));
node->VAR_1 = VAR_1;
QLIST_INSERT_HEAD(&VAR_0->aio_handlers, node, node);
}
node->VAR_2 = VAR_2;
node->VAR_3 = VAR_3;
node->VAR_4 = VAR_4;
node->VAR_5 = VAR_5;
}
}
| [
"void FUNC_0(AioContext *VAR_0,\nint VAR_1,\nIOHandler *VAR_2,\nIOHandler *VAR_3,\nAioFlushHandler *VAR_4,\nvoid *VAR_5)\n{",
"AioHandler *node;",
"node = find_aio_handler(VAR_0, VAR_1);",
"if (!VAR_2 && !VAR_3) {",
"if (node) {",
"if (VAR_0->walking_handlers)\nnode->deleted = 1;",
"else {",
"QLIST_REMOVE(node, node);",
"g_free(node);",
"}",
"}",
"} else {",
"if (node == NULL) {",
"node = g_malloc0(sizeof(AioHandler));",
"node->VAR_1 = VAR_1;",
"QLIST_INSERT_HEAD(&VAR_0->aio_handlers, node, node);",
"}",
"node->VAR_2 = VAR_2;",
"node->VAR_3 = VAR_3;",
"node->VAR_4 = VAR_4;",
"node->VAR_5 = VAR_5;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13
],
[
15
],
[
19
],
[
25
],
[
27
],
[
31,
33
],
[
35
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
]
] |
25,922 | static uint64_t gic_do_cpu_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
GICState **backref = (GICState **)opaque;
GICState *s = *backref;
int id = (backref - s->backref);
return gic_cpu_read(s, id, addr);
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t gic_do_cpu_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
GICState **backref = (GICState **)opaque;
GICState *s = *backref;
int id = (backref - s->backref);
return gic_cpu_read(s, id, addr);
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,
unsigned size)
{
GICState **backref = (GICState **)opaque;
GICState *s = *backref;
int VAR_0 = (backref - s->backref);
return gic_cpu_read(s, VAR_0, addr);
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned size)\n{",
"GICState **backref = (GICState **)opaque;",
"GICState *s = *backref;",
"int VAR_0 = (backref - s->backref);",
"return gic_cpu_read(s, VAR_0, addr);",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
25,923 | void bdrv_io_unplug(BlockDriverState *bs)
{
BlockDriver *drv = bs->drv;
if (drv && drv->bdrv_io_unplug) {
drv->bdrv_io_unplug(bs);
} else if (bs->file) {
bdrv_io_unplug(bs->file->bs);
}
}
| false | qemu | 6b98bd649520d07df4d1b7a0a54ac73bf178519c | void bdrv_io_unplug(BlockDriverState *bs)
{
BlockDriver *drv = bs->drv;
if (drv && drv->bdrv_io_unplug) {
drv->bdrv_io_unplug(bs);
} else if (bs->file) {
bdrv_io_unplug(bs->file->bs);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(BlockDriverState *VAR_0)
{
BlockDriver *drv = VAR_0->drv;
if (drv && drv->FUNC_0) {
drv->FUNC_0(VAR_0);
} else if (VAR_0->file) {
FUNC_0(VAR_0->file->VAR_0);
}
}
| [
"void FUNC_0(BlockDriverState *VAR_0)\n{",
"BlockDriver *drv = VAR_0->drv;",
"if (drv && drv->FUNC_0) {",
"drv->FUNC_0(VAR_0);",
"} else if (VAR_0->file) {",
"FUNC_0(VAR_0->file->VAR_0);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
25,924 | static void ehci_advance_async_state(EHCIState *ehci)
{
const int async = 1;
switch(ehci_get_state(ehci, async)) {
case EST_INACTIVE:
if (!ehci_async_enabled(ehci)) {
break;
}
ehci_set_state(ehci, async, EST_ACTIVE);
// No break, fall through to ACTIVE
case EST_ACTIVE:
if (!ehci_async_enabled(ehci)) {
ehci_queues_rip_all(ehci, async);
ehci_set_state(ehci, async, EST_INACTIVE);
break;
}
/* make sure guest has acknowledged the doorbell interrupt */
/* TO-DO: is this really needed? */
if (ehci->usbsts & USBSTS_IAA) {
DPRINTF("IAA status bit still set.\n");
break;
}
/* check that address register has been set */
if (ehci->asynclistaddr == 0) {
break;
}
ehci_set_state(ehci, async, EST_WAITLISTHEAD);
ehci_advance_state(ehci, async);
/* If the doorbell is set, the guest wants to make a change to the
* schedule. The host controller needs to release cached data.
* (section 4.8.2)
*/
if (ehci->usbcmd & USBCMD_IAAD) {
/* Remove all unseen qhs from the async qhs queue */
ehci_queues_rip_unused(ehci, async, 1);
DPRINTF("ASYNC: doorbell request acknowledged\n");
ehci->usbcmd &= ~USBCMD_IAAD;
ehci_set_interrupt(ehci, USBSTS_IAA);
}
break;
default:
/* this should only be due to a developer mistake */
fprintf(stderr, "ehci: Bad asynchronous state %d. "
"Resetting to active\n", ehci->astate);
assert(0);
}
}
| false | qemu | 9bc3a3a216e2689bfcdd36c3e079333bbdbf3ba0 | static void ehci_advance_async_state(EHCIState *ehci)
{
const int async = 1;
switch(ehci_get_state(ehci, async)) {
case EST_INACTIVE:
if (!ehci_async_enabled(ehci)) {
break;
}
ehci_set_state(ehci, async, EST_ACTIVE);
case EST_ACTIVE:
if (!ehci_async_enabled(ehci)) {
ehci_queues_rip_all(ehci, async);
ehci_set_state(ehci, async, EST_INACTIVE);
break;
}
if (ehci->usbsts & USBSTS_IAA) {
DPRINTF("IAA status bit still set.\n");
break;
}
if (ehci->asynclistaddr == 0) {
break;
}
ehci_set_state(ehci, async, EST_WAITLISTHEAD);
ehci_advance_state(ehci, async);
if (ehci->usbcmd & USBCMD_IAAD) {
ehci_queues_rip_unused(ehci, async, 1);
DPRINTF("ASYNC: doorbell request acknowledged\n");
ehci->usbcmd &= ~USBCMD_IAAD;
ehci_set_interrupt(ehci, USBSTS_IAA);
}
break;
default:
fprintf(stderr, "ehci: Bad asynchronous state %d. "
"Resetting to active\n", ehci->astate);
assert(0);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(EHCIState *VAR_0)
{
const int VAR_1 = 1;
switch(ehci_get_state(VAR_0, VAR_1)) {
case EST_INACTIVE:
if (!ehci_async_enabled(VAR_0)) {
break;
}
ehci_set_state(VAR_0, VAR_1, EST_ACTIVE);
case EST_ACTIVE:
if (!ehci_async_enabled(VAR_0)) {
ehci_queues_rip_all(VAR_0, VAR_1);
ehci_set_state(VAR_0, VAR_1, EST_INACTIVE);
break;
}
if (VAR_0->usbsts & USBSTS_IAA) {
DPRINTF("IAA status bit still set.\n");
break;
}
if (VAR_0->asynclistaddr == 0) {
break;
}
ehci_set_state(VAR_0, VAR_1, EST_WAITLISTHEAD);
ehci_advance_state(VAR_0, VAR_1);
if (VAR_0->usbcmd & USBCMD_IAAD) {
ehci_queues_rip_unused(VAR_0, VAR_1, 1);
DPRINTF("ASYNC: doorbell request acknowledged\n");
VAR_0->usbcmd &= ~USBCMD_IAAD;
ehci_set_interrupt(VAR_0, USBSTS_IAA);
}
break;
default:
fprintf(stderr, "VAR_0: Bad asynchronous state %d. "
"Resetting to active\n", VAR_0->astate);
assert(0);
}
}
| [
"static void FUNC_0(EHCIState *VAR_0)\n{",
"const int VAR_1 = 1;",
"switch(ehci_get_state(VAR_0, VAR_1)) {",
"case EST_INACTIVE:\nif (!ehci_async_enabled(VAR_0)) {",
"break;",
"}",
"ehci_set_state(VAR_0, VAR_1, EST_ACTIVE);",
"case EST_ACTIVE:\nif (!ehci_async_enabled(VAR_0)) {",
"ehci_queues_rip_all(VAR_0, VAR_1);",
"ehci_set_state(VAR_0, VAR_1, EST_INACTIVE);",
"break;",
"}",
"if (VAR_0->usbsts & USBSTS_IAA) {",
"DPRINTF(\"IAA status bit still set.\\n\");",
"break;",
"}",
"if (VAR_0->asynclistaddr == 0) {",
"break;",
"}",
"ehci_set_state(VAR_0, VAR_1, EST_WAITLISTHEAD);",
"ehci_advance_state(VAR_0, VAR_1);",
"if (VAR_0->usbcmd & USBCMD_IAAD) {",
"ehci_queues_rip_unused(VAR_0, VAR_1, 1);",
"DPRINTF(\"ASYNC: doorbell request acknowledged\\n\");",
"VAR_0->usbcmd &= ~USBCMD_IAAD;",
"ehci_set_interrupt(VAR_0, USBSTS_IAA);",
"}",
"break;",
"default:\nfprintf(stderr, \"VAR_0: Bad asynchronous state %d. \"\n\"Resetting to active\\n\", VAR_0->astate);",
"assert(0);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
43
],
[
45
],
[
47
],
[
49
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95,
99,
101
],
[
103
],
[
105
],
[
107
]
] |
25,926 | static int rpl_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
AVIOContext *pb = s->pb;
RPLContext *rpl = s->priv_data;
AVStream *vst = NULL, *ast = NULL;
int total_audio_size;
int error = 0;
uint32_t i;
int32_t audio_format, chunk_catalog_offset, number_of_chunks;
AVRational fps;
char line[RPL_LINE_LENGTH];
// The header for RPL/ARMovie files is 21 lines of text
// containing the various header fields. The fields are always
// in the same order, and other text besides the first
// number usually isn't important.
// (The spec says that there exists some significance
// for the text in a few cases; samples needed.)
error |= read_line(pb, line, sizeof(line)); // ARMovie
error |= read_line(pb, line, sizeof(line)); // movie name
av_dict_set(&s->metadata, "title" , line, 0);
error |= read_line(pb, line, sizeof(line)); // date/copyright
av_dict_set(&s->metadata, "copyright", line, 0);
error |= read_line(pb, line, sizeof(line)); // author and other
av_dict_set(&s->metadata, "author" , line, 0);
// video headers
vst = avformat_new_stream(s, NULL);
if (!vst)
return AVERROR(ENOMEM);
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codec->codec_tag = read_line_and_int(pb, &error); // video format
vst->codec->width = read_line_and_int(pb, &error); // video width
vst->codec->height = read_line_and_int(pb, &error); // video height
vst->codec->bits_per_coded_sample = read_line_and_int(pb, &error); // video bits per sample
error |= read_line(pb, line, sizeof(line)); // video frames per second
fps = read_fps(line, &error);
avpriv_set_pts_info(vst, 32, fps.den, fps.num);
// Figure out the video codec
switch (vst->codec->codec_tag) {
#if 0
case 122:
vst->codec->codec_id = CODEC_ID_ESCAPE122;
break;
#endif
case 124:
vst->codec->codec_id = CODEC_ID_ESCAPE124;
// The header is wrong here, at least sometimes
vst->codec->bits_per_coded_sample = 16;
break;
case 130:
vst->codec->codec_id = CODEC_ID_ESCAPE130;
break;
default:
av_log(s, AV_LOG_WARNING,
"RPL video format %i not supported yet!\n",
vst->codec->codec_tag);
vst->codec->codec_id = CODEC_ID_NONE;
}
// Audio headers
// ARMovie supports multiple audio tracks; I don't have any
// samples, though. This code will ignore additional tracks.
audio_format = read_line_and_int(pb, &error); // audio format ID
if (audio_format) {
ast = avformat_new_stream(s, NULL);
if (!ast)
return AVERROR(ENOMEM);
ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
ast->codec->codec_tag = audio_format;
ast->codec->sample_rate = read_line_and_int(pb, &error); // audio bitrate
ast->codec->channels = read_line_and_int(pb, &error); // number of audio channels
ast->codec->bits_per_coded_sample = read_line_and_int(pb, &error); // audio bits per sample
// At least one sample uses 0 for ADPCM, which is really 4 bits
// per sample.
if (ast->codec->bits_per_coded_sample == 0)
ast->codec->bits_per_coded_sample = 4;
ast->codec->bit_rate = ast->codec->sample_rate *
ast->codec->bits_per_coded_sample *
ast->codec->channels;
ast->codec->codec_id = CODEC_ID_NONE;
switch (audio_format) {
case 1:
if (ast->codec->bits_per_coded_sample == 16) {
// 16-bit audio is always signed
ast->codec->codec_id = CODEC_ID_PCM_S16LE;
break;
}
// There are some other formats listed as legal per the spec;
// samples needed.
break;
case 101:
if (ast->codec->bits_per_coded_sample == 8) {
// The samples with this kind of audio that I have
// are all unsigned.
ast->codec->codec_id = CODEC_ID_PCM_U8;
break;
} else if (ast->codec->bits_per_coded_sample == 4) {
ast->codec->codec_id = CODEC_ID_ADPCM_IMA_EA_SEAD;
break;
}
break;
}
if (ast->codec->codec_id == CODEC_ID_NONE) {
av_log(s, AV_LOG_WARNING,
"RPL audio format %i not supported yet!\n",
audio_format);
}
avpriv_set_pts_info(ast, 32, 1, ast->codec->bit_rate);
} else {
for (i = 0; i < 3; i++)
error |= read_line(pb, line, sizeof(line));
}
rpl->frames_per_chunk = read_line_and_int(pb, &error); // video frames per chunk
if (rpl->frames_per_chunk > 1 && vst->codec->codec_tag != 124)
av_log(s, AV_LOG_WARNING,
"Don't know how to split frames for video format %i. "
"Video stream will be broken!\n", vst->codec->codec_tag);
number_of_chunks = read_line_and_int(pb, &error); // number of chunks in the file
// The number in the header is actually the index of the last chunk.
number_of_chunks++;
error |= read_line(pb, line, sizeof(line)); // "even" chunk size in bytes
error |= read_line(pb, line, sizeof(line)); // "odd" chunk size in bytes
chunk_catalog_offset = // offset of the "chunk catalog"
read_line_and_int(pb, &error); // (file index)
error |= read_line(pb, line, sizeof(line)); // offset to "helpful" sprite
error |= read_line(pb, line, sizeof(line)); // size of "helpful" sprite
error |= read_line(pb, line, sizeof(line)); // offset to key frame list
// Read the index
avio_seek(pb, chunk_catalog_offset, SEEK_SET);
total_audio_size = 0;
for (i = 0; i < number_of_chunks; i++) {
int64_t offset, video_size, audio_size;
error |= read_line(pb, line, sizeof(line));
if (3 != sscanf(line, "%"PRId64" , %"PRId64" ; %"PRId64,
&offset, &video_size, &audio_size))
error = -1;
av_add_index_entry(vst, offset, i * rpl->frames_per_chunk,
video_size, rpl->frames_per_chunk, 0);
if (ast)
av_add_index_entry(ast, offset + video_size, total_audio_size,
audio_size, audio_size * 8, 0);
total_audio_size += audio_size * 8;
}
if (error) return AVERROR(EIO);
return 0;
}
| false | FFmpeg | 43abef9fde0cf87153cc9031cad61f75b02cfa01 | static int rpl_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
AVIOContext *pb = s->pb;
RPLContext *rpl = s->priv_data;
AVStream *vst = NULL, *ast = NULL;
int total_audio_size;
int error = 0;
uint32_t i;
int32_t audio_format, chunk_catalog_offset, number_of_chunks;
AVRational fps;
char line[RPL_LINE_LENGTH];
error |= read_line(pb, line, sizeof(line));
error |= read_line(pb, line, sizeof(line));
av_dict_set(&s->metadata, "title" , line, 0);
error |= read_line(pb, line, sizeof(line));
av_dict_set(&s->metadata, "copyright", line, 0);
error |= read_line(pb, line, sizeof(line));
av_dict_set(&s->metadata, "author" , line, 0);
vst = avformat_new_stream(s, NULL);
if (!vst)
return AVERROR(ENOMEM);
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codec->codec_tag = read_line_and_int(pb, &error);
vst->codec->width = read_line_and_int(pb, &error);
vst->codec->height = read_line_and_int(pb, &error);
vst->codec->bits_per_coded_sample = read_line_and_int(pb, &error);
error |= read_line(pb, line, sizeof(line));
fps = read_fps(line, &error);
avpriv_set_pts_info(vst, 32, fps.den, fps.num);
switch (vst->codec->codec_tag) {
#if 0
case 122:
vst->codec->codec_id = CODEC_ID_ESCAPE122;
break;
#endif
case 124:
vst->codec->codec_id = CODEC_ID_ESCAPE124;
vst->codec->bits_per_coded_sample = 16;
break;
case 130:
vst->codec->codec_id = CODEC_ID_ESCAPE130;
break;
default:
av_log(s, AV_LOG_WARNING,
"RPL video format %i not supported yet!\n",
vst->codec->codec_tag);
vst->codec->codec_id = CODEC_ID_NONE;
}
supports multiple audio tracks; I don't have any
audio_format = read_line_and_int(pb, &error);
if (audio_format) {
ast = avformat_new_stream(s, NULL);
if (!ast)
return AVERROR(ENOMEM);
ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
ast->codec->codec_tag = audio_format;
ast->codec->sample_rate = read_line_and_int(pb, &error);
ast->codec->channels = read_line_and_int(pb, &error);
ast->codec->bits_per_coded_sample = read_line_and_int(pb, &error);
if (ast->codec->bits_per_coded_sample == 0)
ast->codec->bits_per_coded_sample = 4;
ast->codec->bit_rate = ast->codec->sample_rate *
ast->codec->bits_per_coded_sample *
ast->codec->channels;
ast->codec->codec_id = CODEC_ID_NONE;
switch (audio_format) {
case 1:
if (ast->codec->bits_per_coded_sample == 16) {
ast->codec->codec_id = CODEC_ID_PCM_S16LE;
break;
}
break;
case 101:
if (ast->codec->bits_per_coded_sample == 8) {
ast->codec->codec_id = CODEC_ID_PCM_U8;
break;
} else if (ast->codec->bits_per_coded_sample == 4) {
ast->codec->codec_id = CODEC_ID_ADPCM_IMA_EA_SEAD;
break;
}
break;
}
if (ast->codec->codec_id == CODEC_ID_NONE) {
av_log(s, AV_LOG_WARNING,
"RPL audio format %i not supported yet!\n",
audio_format);
}
avpriv_set_pts_info(ast, 32, 1, ast->codec->bit_rate);
} else {
for (i = 0; i < 3; i++)
error |= read_line(pb, line, sizeof(line));
}
rpl->frames_per_chunk = read_line_and_int(pb, &error);
if (rpl->frames_per_chunk > 1 && vst->codec->codec_tag != 124)
av_log(s, AV_LOG_WARNING,
"Don't know how to split frames for video format %i. "
"Video stream will be broken!\n", vst->codec->codec_tag);
number_of_chunks = read_line_and_int(pb, &error);
number_of_chunks++;
error |= read_line(pb, line, sizeof(line));
error |= read_line(pb, line, sizeof(line));
chunk_catalog_offset =
read_line_and_int(pb, &error);
error |= read_line(pb, line, sizeof(line));
error |= read_line(pb, line, sizeof(line));
error |= read_line(pb, line, sizeof(line));
avio_seek(pb, chunk_catalog_offset, SEEK_SET);
total_audio_size = 0;
for (i = 0; i < number_of_chunks; i++) {
int64_t offset, video_size, audio_size;
error |= read_line(pb, line, sizeof(line));
if (3 != sscanf(line, "%"PRId64" , %"PRId64" ; %"PRId64,
&offset, &video_size, &audio_size))
error = -1;
av_add_index_entry(vst, offset, i * rpl->frames_per_chunk,
video_size, rpl->frames_per_chunk, 0);
if (ast)
av_add_index_entry(ast, offset + video_size, total_audio_size,
audio_size, audio_size * 8, 0);
total_audio_size += audio_size * 8;
}
if (error) return AVERROR(EIO);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVFormatParameters *VAR_1)
{
AVIOContext *pb = VAR_0->pb;
RPLContext *rpl = VAR_0->priv_data;
AVStream *vst = NULL, *ast = NULL;
int VAR_2;
int VAR_3 = 0;
uint32_t i;
int32_t audio_format, chunk_catalog_offset, number_of_chunks;
AVRational fps;
char VAR_4[RPL_LINE_LENGTH];
VAR_3 |= read_line(pb, VAR_4, sizeof(VAR_4));
VAR_3 |= read_line(pb, VAR_4, sizeof(VAR_4));
av_dict_set(&VAR_0->metadata, "title" , VAR_4, 0);
VAR_3 |= read_line(pb, VAR_4, sizeof(VAR_4));
av_dict_set(&VAR_0->metadata, "copyright", VAR_4, 0);
VAR_3 |= read_line(pb, VAR_4, sizeof(VAR_4));
av_dict_set(&VAR_0->metadata, "author" , VAR_4, 0);
vst = avformat_new_stream(VAR_0, NULL);
if (!vst)
return AVERROR(ENOMEM);
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codec->codec_tag = read_line_and_int(pb, &VAR_3);
vst->codec->width = read_line_and_int(pb, &VAR_3);
vst->codec->height = read_line_and_int(pb, &VAR_3);
vst->codec->bits_per_coded_sample = read_line_and_int(pb, &VAR_3);
VAR_3 |= read_line(pb, VAR_4, sizeof(VAR_4));
fps = read_fps(VAR_4, &VAR_3);
avpriv_set_pts_info(vst, 32, fps.den, fps.num);
switch (vst->codec->codec_tag) {
#if 0
case 122:
vst->codec->codec_id = CODEC_ID_ESCAPE122;
break;
#endif
case 124:
vst->codec->codec_id = CODEC_ID_ESCAPE124;
vst->codec->bits_per_coded_sample = 16;
break;
case 130:
vst->codec->codec_id = CODEC_ID_ESCAPE130;
break;
default:
av_log(VAR_0, AV_LOG_WARNING,
"RPL video format %i not supported yet!\n",
vst->codec->codec_tag);
vst->codec->codec_id = CODEC_ID_NONE;
}
supports multiple audio tracks; I don't have any
audio_format = read_line_and_int(pb, &VAR_3);
if (audio_format) {
ast = avformat_new_stream(VAR_0, NULL);
if (!ast)
return AVERROR(ENOMEM);
ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
ast->codec->codec_tag = audio_format;
ast->codec->sample_rate = read_line_and_int(pb, &VAR_3);
ast->codec->channels = read_line_and_int(pb, &VAR_3);
ast->codec->bits_per_coded_sample = read_line_and_int(pb, &VAR_3);
if (ast->codec->bits_per_coded_sample == 0)
ast->codec->bits_per_coded_sample = 4;
ast->codec->bit_rate = ast->codec->sample_rate *
ast->codec->bits_per_coded_sample *
ast->codec->channels;
ast->codec->codec_id = CODEC_ID_NONE;
switch (audio_format) {
case 1:
if (ast->codec->bits_per_coded_sample == 16) {
ast->codec->codec_id = CODEC_ID_PCM_S16LE;
break;
}
break;
case 101:
if (ast->codec->bits_per_coded_sample == 8) {
ast->codec->codec_id = CODEC_ID_PCM_U8;
break;
} else if (ast->codec->bits_per_coded_sample == 4) {
ast->codec->codec_id = CODEC_ID_ADPCM_IMA_EA_SEAD;
break;
}
break;
}
if (ast->codec->codec_id == CODEC_ID_NONE) {
av_log(VAR_0, AV_LOG_WARNING,
"RPL audio format %i not supported yet!\n",
audio_format);
}
avpriv_set_pts_info(ast, 32, 1, ast->codec->bit_rate);
} else {
for (i = 0; i < 3; i++)
VAR_3 |= read_line(pb, VAR_4, sizeof(VAR_4));
}
rpl->frames_per_chunk = read_line_and_int(pb, &VAR_3);
if (rpl->frames_per_chunk > 1 && vst->codec->codec_tag != 124)
av_log(VAR_0, AV_LOG_WARNING,
"Don't know how to split frames for video format %i. "
"Video stream will be broken!\n", vst->codec->codec_tag);
number_of_chunks = read_line_and_int(pb, &VAR_3);
number_of_chunks++;
VAR_3 |= read_line(pb, VAR_4, sizeof(VAR_4));
VAR_3 |= read_line(pb, VAR_4, sizeof(VAR_4));
chunk_catalog_offset =
read_line_and_int(pb, &VAR_3);
VAR_3 |= read_line(pb, VAR_4, sizeof(VAR_4));
VAR_3 |= read_line(pb, VAR_4, sizeof(VAR_4));
VAR_3 |= read_line(pb, VAR_4, sizeof(VAR_4));
avio_seek(pb, chunk_catalog_offset, SEEK_SET);
VAR_2 = 0;
for (i = 0; i < number_of_chunks; i++) {
int64_t offset, video_size, audio_size;
VAR_3 |= read_line(pb, VAR_4, sizeof(VAR_4));
if (3 != sscanf(VAR_4, "%"PRId64" , %"PRId64" ; %"PRId64,
&offset, &video_size, &audio_size))
VAR_3 = -1;
av_add_index_entry(vst, offset, i * rpl->frames_per_chunk,
video_size, rpl->frames_per_chunk, 0);
if (ast)
av_add_index_entry(ast, offset + video_size, VAR_2,
audio_size, audio_size * 8, 0);
VAR_2 += audio_size * 8;
}
if (VAR_3) return AVERROR(EIO);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVFormatParameters *VAR_1)\n{",
"AVIOContext *pb = VAR_0->pb;",
"RPLContext *rpl = VAR_0->priv_data;",
"AVStream *vst = NULL, *ast = NULL;",
"int VAR_2;",
"int VAR_3 = 0;",
"uint32_t i;",
"int32_t audio_format, chunk_catalog_offset, number_of_chunks;",
"AVRational fps;",
"char VAR_4[RPL_LINE_LENGTH];",
"VAR_3 |= read_line(pb, VAR_4, sizeof(VAR_4));",
"VAR_3 |= read_line(pb, VAR_4, sizeof(VAR_4));",
"av_dict_set(&VAR_0->metadata, \"title\" , VAR_4, 0);",
"VAR_3 |= read_line(pb, VAR_4, sizeof(VAR_4));",
"av_dict_set(&VAR_0->metadata, \"copyright\", VAR_4, 0);",
"VAR_3 |= read_line(pb, VAR_4, sizeof(VAR_4));",
"av_dict_set(&VAR_0->metadata, \"author\" , VAR_4, 0);",
"vst = avformat_new_stream(VAR_0, NULL);",
"if (!vst)\nreturn AVERROR(ENOMEM);",
"vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;",
"vst->codec->codec_tag = read_line_and_int(pb, &VAR_3);",
"vst->codec->width = read_line_and_int(pb, &VAR_3);",
"vst->codec->height = read_line_and_int(pb, &VAR_3);",
"vst->codec->bits_per_coded_sample = read_line_and_int(pb, &VAR_3);",
"VAR_3 |= read_line(pb, VAR_4, sizeof(VAR_4));",
"fps = read_fps(VAR_4, &VAR_3);",
"avpriv_set_pts_info(vst, 32, fps.den, fps.num);",
"switch (vst->codec->codec_tag) {",
"#if 0\ncase 122:\nvst->codec->codec_id = CODEC_ID_ESCAPE122;",
"break;",
"#endif\ncase 124:\nvst->codec->codec_id = CODEC_ID_ESCAPE124;",
"vst->codec->bits_per_coded_sample = 16;",
"break;",
"case 130:\nvst->codec->codec_id = CODEC_ID_ESCAPE130;",
"break;",
"default:\nav_log(VAR_0, AV_LOG_WARNING,\n\"RPL video format %i not supported yet!\\n\",\nvst->codec->codec_tag);",
"vst->codec->codec_id = CODEC_ID_NONE;",
"}",
"supports multiple audio tracks; I don't have any",
"audio_format = read_line_and_int(pb, &VAR_3);",
"if (audio_format) {",
"ast = avformat_new_stream(VAR_0, NULL);",
"if (!ast)\nreturn AVERROR(ENOMEM);",
"ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;",
"ast->codec->codec_tag = audio_format;",
"ast->codec->sample_rate = read_line_and_int(pb, &VAR_3);",
"ast->codec->channels = read_line_and_int(pb, &VAR_3);",
"ast->codec->bits_per_coded_sample = read_line_and_int(pb, &VAR_3);",
"if (ast->codec->bits_per_coded_sample == 0)\nast->codec->bits_per_coded_sample = 4;",
"ast->codec->bit_rate = ast->codec->sample_rate *\nast->codec->bits_per_coded_sample *\nast->codec->channels;",
"ast->codec->codec_id = CODEC_ID_NONE;",
"switch (audio_format) {",
"case 1:\nif (ast->codec->bits_per_coded_sample == 16) {",
"ast->codec->codec_id = CODEC_ID_PCM_S16LE;",
"break;",
"}",
"break;",
"case 101:\nif (ast->codec->bits_per_coded_sample == 8) {",
"ast->codec->codec_id = CODEC_ID_PCM_U8;",
"break;",
"} else if (ast->codec->bits_per_coded_sample == 4) {",
"ast->codec->codec_id = CODEC_ID_ADPCM_IMA_EA_SEAD;",
"break;",
"}",
"break;",
"}",
"if (ast->codec->codec_id == CODEC_ID_NONE) {",
"av_log(VAR_0, AV_LOG_WARNING,\n\"RPL audio format %i not supported yet!\\n\",\naudio_format);",
"}",
"avpriv_set_pts_info(ast, 32, 1, ast->codec->bit_rate);",
"} else {",
"for (i = 0; i < 3; i++)",
"VAR_3 |= read_line(pb, VAR_4, sizeof(VAR_4));",
"}",
"rpl->frames_per_chunk = read_line_and_int(pb, &VAR_3);",
"if (rpl->frames_per_chunk > 1 && vst->codec->codec_tag != 124)\nav_log(VAR_0, AV_LOG_WARNING,\n\"Don't know how to split frames for video format %i. \"\n\"Video stream will be broken!\\n\", vst->codec->codec_tag);",
"number_of_chunks = read_line_and_int(pb, &VAR_3);",
"number_of_chunks++;",
"VAR_3 |= read_line(pb, VAR_4, sizeof(VAR_4));",
"VAR_3 |= read_line(pb, VAR_4, sizeof(VAR_4));",
"chunk_catalog_offset =\nread_line_and_int(pb, &VAR_3);",
"VAR_3 |= read_line(pb, VAR_4, sizeof(VAR_4));",
"VAR_3 |= read_line(pb, VAR_4, sizeof(VAR_4));",
"VAR_3 |= read_line(pb, VAR_4, sizeof(VAR_4));",
"avio_seek(pb, chunk_catalog_offset, SEEK_SET);",
"VAR_2 = 0;",
"for (i = 0; i < number_of_chunks; i++) {",
"int64_t offset, video_size, audio_size;",
"VAR_3 |= read_line(pb, VAR_4, sizeof(VAR_4));",
"if (3 != sscanf(VAR_4, \"%\"PRId64\" , %\"PRId64\" ; %\"PRId64,",
"&offset, &video_size, &audio_size))\nVAR_3 = -1;",
"av_add_index_entry(vst, offset, i * rpl->frames_per_chunk,\nvideo_size, rpl->frames_per_chunk, 0);",
"if (ast)\nav_add_index_entry(ast, offset + video_size, VAR_2,\naudio_size, audio_size * 8, 0);",
"VAR_2 += audio_size * 8;",
"}",
"if (VAR_3) return AVERROR(EIO);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
27
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
87
],
[
89,
91,
93
],
[
95
],
[
97,
99,
101
],
[
105
],
[
107
],
[
109,
111
],
[
113
],
[
115,
117,
119,
121
],
[
123
],
[
125
],
[
133
],
[
137
],
[
139
],
[
141
],
[
143,
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
161,
163
],
[
167,
169,
171
],
[
175
],
[
177
],
[
179,
181
],
[
185
],
[
187
],
[
189
],
[
195
],
[
197,
199
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223,
225,
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
243
],
[
245,
247,
249,
251
],
[
255
],
[
259
],
[
263
],
[
265
],
[
267,
269
],
[
271
],
[
273
],
[
275
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293,
295
],
[
297,
299
],
[
301,
303,
305
],
[
307
],
[
309
],
[
313
],
[
317
],
[
319
]
] |
25,927 | static QDict *monitor_parse_arguments(Monitor *mon,
const char **endp,
const mon_cmd_t *cmd)
{
const char *typestr;
char *key;
int c;
const char *p = *endp;
char buf[1024];
QDict *qdict = qdict_new();
/* parse the parameters */
typestr = cmd->args_type;
for(;;) {
typestr = key_get_info(typestr, &key);
if (!typestr)
break;
c = *typestr;
typestr++;
switch(c) {
case 'F':
case 'B':
case 's':
{
int ret;
while (qemu_isspace(*p))
p++;
if (*typestr == '?') {
typestr++;
if (*p == '\0') {
/* no optional string: NULL argument */
break;
}
}
ret = get_str(buf, sizeof(buf), &p);
if (ret < 0) {
switch(c) {
case 'F':
monitor_printf(mon, "%s: filename expected\n",
cmd->name);
break;
case 'B':
monitor_printf(mon, "%s: block device name expected\n",
cmd->name);
break;
default:
monitor_printf(mon, "%s: string expected\n", cmd->name);
break;
}
goto fail;
}
qdict_put(qdict, key, qstring_from_str(buf));
}
break;
case 'O':
{
QemuOptsList *opts_list;
QemuOpts *opts;
opts_list = qemu_find_opts(key);
if (!opts_list || opts_list->desc->name) {
goto bad_type;
}
while (qemu_isspace(*p)) {
p++;
}
if (!*p)
break;
if (get_str(buf, sizeof(buf), &p) < 0) {
goto fail;
}
opts = qemu_opts_parse_noisily(opts_list, buf, true);
if (!opts) {
goto fail;
}
qemu_opts_to_qdict(opts, qdict);
qemu_opts_del(opts);
}
break;
case '/':
{
int count, format, size;
while (qemu_isspace(*p))
p++;
if (*p == '/') {
/* format found */
p++;
count = 1;
if (qemu_isdigit(*p)) {
count = 0;
while (qemu_isdigit(*p)) {
count = count * 10 + (*p - '0');
p++;
}
}
size = -1;
format = -1;
for(;;) {
switch(*p) {
case 'o':
case 'd':
case 'u':
case 'x':
case 'i':
case 'c':
format = *p++;
break;
case 'b':
size = 1;
p++;
break;
case 'h':
size = 2;
p++;
break;
case 'w':
size = 4;
p++;
break;
case 'g':
case 'L':
size = 8;
p++;
break;
default:
goto next;
}
}
next:
if (*p != '\0' && !qemu_isspace(*p)) {
monitor_printf(mon, "invalid char in format: '%c'\n",
*p);
goto fail;
}
if (format < 0)
format = default_fmt_format;
if (format != 'i') {
/* for 'i', not specifying a size gives -1 as size */
if (size < 0)
size = default_fmt_size;
default_fmt_size = size;
}
default_fmt_format = format;
} else {
count = 1;
format = default_fmt_format;
if (format != 'i') {
size = default_fmt_size;
} else {
size = -1;
}
}
qdict_put(qdict, "count", qint_from_int(count));
qdict_put(qdict, "format", qint_from_int(format));
qdict_put(qdict, "size", qint_from_int(size));
}
break;
case 'i':
case 'l':
case 'M':
{
int64_t val;
while (qemu_isspace(*p))
p++;
if (*typestr == '?' || *typestr == '.') {
if (*typestr == '?') {
if (*p == '\0') {
typestr++;
break;
}
} else {
if (*p == '.') {
p++;
while (qemu_isspace(*p))
p++;
} else {
typestr++;
break;
}
}
typestr++;
}
if (get_expr(mon, &val, &p))
goto fail;
/* Check if 'i' is greater than 32-bit */
if ((c == 'i') && ((val >> 32) & 0xffffffff)) {
monitor_printf(mon, "\'%s\' has failed: ", cmd->name);
monitor_printf(mon, "integer is for 32-bit values\n");
goto fail;
} else if (c == 'M') {
if (val < 0) {
monitor_printf(mon, "enter a positive value\n");
goto fail;
}
val <<= 20;
}
qdict_put(qdict, key, qint_from_int(val));
}
break;
case 'o':
{
int64_t val;
char *end;
while (qemu_isspace(*p)) {
p++;
}
if (*typestr == '?') {
typestr++;
if (*p == '\0') {
break;
}
}
val = qemu_strtosz_MiB(p, &end);
if (val < 0) {
monitor_printf(mon, "invalid size\n");
goto fail;
}
qdict_put(qdict, key, qint_from_int(val));
p = end;
}
break;
case 'T':
{
double val;
while (qemu_isspace(*p))
p++;
if (*typestr == '?') {
typestr++;
if (*p == '\0') {
break;
}
}
if (get_double(mon, &val, &p) < 0) {
goto fail;
}
if (p[0] && p[1] == 's') {
switch (*p) {
case 'm':
val /= 1e3; p += 2; break;
case 'u':
val /= 1e6; p += 2; break;
case 'n':
val /= 1e9; p += 2; break;
}
}
if (*p && !qemu_isspace(*p)) {
monitor_printf(mon, "Unknown unit suffix\n");
goto fail;
}
qdict_put(qdict, key, qfloat_from_double(val));
}
break;
case 'b':
{
const char *beg;
bool val;
while (qemu_isspace(*p)) {
p++;
}
beg = p;
while (qemu_isgraph(*p)) {
p++;
}
if (p - beg == 2 && !memcmp(beg, "on", p - beg)) {
val = true;
} else if (p - beg == 3 && !memcmp(beg, "off", p - beg)) {
val = false;
} else {
monitor_printf(mon, "Expected 'on' or 'off'\n");
goto fail;
}
qdict_put(qdict, key, qbool_from_bool(val));
}
break;
case '-':
{
const char *tmp = p;
int skip_key = 0;
/* option */
c = *typestr++;
if (c == '\0')
goto bad_type;
while (qemu_isspace(*p))
p++;
if (*p == '-') {
p++;
if(c != *p) {
if(!is_valid_option(p, typestr)) {
monitor_printf(mon, "%s: unsupported option -%c\n",
cmd->name, *p);
goto fail;
} else {
skip_key = 1;
}
}
if(skip_key) {
p = tmp;
} else {
/* has option */
p++;
qdict_put(qdict, key, qbool_from_bool(true));
}
}
}
break;
case 'S':
{
/* package all remaining string */
int len;
while (qemu_isspace(*p)) {
p++;
}
if (*typestr == '?') {
typestr++;
if (*p == '\0') {
/* no remaining string: NULL argument */
break;
}
}
len = strlen(p);
if (len <= 0) {
monitor_printf(mon, "%s: string expected\n",
cmd->name);
goto fail;
}
qdict_put(qdict, key, qstring_from_str(p));
p += len;
}
break;
default:
bad_type:
monitor_printf(mon, "%s: unknown type '%c'\n", cmd->name, c);
goto fail;
}
g_free(key);
key = NULL;
}
/* check that all arguments were parsed */
while (qemu_isspace(*p))
p++;
if (*p != '\0') {
monitor_printf(mon, "%s: extraneous characters at the end of line\n",
cmd->name);
goto fail;
}
return qdict;
fail:
QDECREF(qdict);
g_free(key);
return NULL;
}
| false | qemu | f17fd4fdf0df3d2f3444399d04c38d22b9a3e1b7 | static QDict *monitor_parse_arguments(Monitor *mon,
const char **endp,
const mon_cmd_t *cmd)
{
const char *typestr;
char *key;
int c;
const char *p = *endp;
char buf[1024];
QDict *qdict = qdict_new();
typestr = cmd->args_type;
for(;;) {
typestr = key_get_info(typestr, &key);
if (!typestr)
break;
c = *typestr;
typestr++;
switch(c) {
case 'F':
case 'B':
case 's':
{
int ret;
while (qemu_isspace(*p))
p++;
if (*typestr == '?') {
typestr++;
if (*p == '\0') {
break;
}
}
ret = get_str(buf, sizeof(buf), &p);
if (ret < 0) {
switch(c) {
case 'F':
monitor_printf(mon, "%s: filename expected\n",
cmd->name);
break;
case 'B':
monitor_printf(mon, "%s: block device name expected\n",
cmd->name);
break;
default:
monitor_printf(mon, "%s: string expected\n", cmd->name);
break;
}
goto fail;
}
qdict_put(qdict, key, qstring_from_str(buf));
}
break;
case 'O':
{
QemuOptsList *opts_list;
QemuOpts *opts;
opts_list = qemu_find_opts(key);
if (!opts_list || opts_list->desc->name) {
goto bad_type;
}
while (qemu_isspace(*p)) {
p++;
}
if (!*p)
break;
if (get_str(buf, sizeof(buf), &p) < 0) {
goto fail;
}
opts = qemu_opts_parse_noisily(opts_list, buf, true);
if (!opts) {
goto fail;
}
qemu_opts_to_qdict(opts, qdict);
qemu_opts_del(opts);
}
break;
case '/':
{
int count, format, size;
while (qemu_isspace(*p))
p++;
if (*p == '/') {
p++;
count = 1;
if (qemu_isdigit(*p)) {
count = 0;
while (qemu_isdigit(*p)) {
count = count * 10 + (*p - '0');
p++;
}
}
size = -1;
format = -1;
for(;;) {
switch(*p) {
case 'o':
case 'd':
case 'u':
case 'x':
case 'i':
case 'c':
format = *p++;
break;
case 'b':
size = 1;
p++;
break;
case 'h':
size = 2;
p++;
break;
case 'w':
size = 4;
p++;
break;
case 'g':
case 'L':
size = 8;
p++;
break;
default:
goto next;
}
}
next:
if (*p != '\0' && !qemu_isspace(*p)) {
monitor_printf(mon, "invalid char in format: '%c'\n",
*p);
goto fail;
}
if (format < 0)
format = default_fmt_format;
if (format != 'i') {
if (size < 0)
size = default_fmt_size;
default_fmt_size = size;
}
default_fmt_format = format;
} else {
count = 1;
format = default_fmt_format;
if (format != 'i') {
size = default_fmt_size;
} else {
size = -1;
}
}
qdict_put(qdict, "count", qint_from_int(count));
qdict_put(qdict, "format", qint_from_int(format));
qdict_put(qdict, "size", qint_from_int(size));
}
break;
case 'i':
case 'l':
case 'M':
{
int64_t val;
while (qemu_isspace(*p))
p++;
if (*typestr == '?' || *typestr == '.') {
if (*typestr == '?') {
if (*p == '\0') {
typestr++;
break;
}
} else {
if (*p == '.') {
p++;
while (qemu_isspace(*p))
p++;
} else {
typestr++;
break;
}
}
typestr++;
}
if (get_expr(mon, &val, &p))
goto fail;
if ((c == 'i') && ((val >> 32) & 0xffffffff)) {
monitor_printf(mon, "\'%s\' has failed: ", cmd->name);
monitor_printf(mon, "integer is for 32-bit values\n");
goto fail;
} else if (c == 'M') {
if (val < 0) {
monitor_printf(mon, "enter a positive value\n");
goto fail;
}
val <<= 20;
}
qdict_put(qdict, key, qint_from_int(val));
}
break;
case 'o':
{
int64_t val;
char *end;
while (qemu_isspace(*p)) {
p++;
}
if (*typestr == '?') {
typestr++;
if (*p == '\0') {
break;
}
}
val = qemu_strtosz_MiB(p, &end);
if (val < 0) {
monitor_printf(mon, "invalid size\n");
goto fail;
}
qdict_put(qdict, key, qint_from_int(val));
p = end;
}
break;
case 'T':
{
double val;
while (qemu_isspace(*p))
p++;
if (*typestr == '?') {
typestr++;
if (*p == '\0') {
break;
}
}
if (get_double(mon, &val, &p) < 0) {
goto fail;
}
if (p[0] && p[1] == 's') {
switch (*p) {
case 'm':
val /= 1e3; p += 2; break;
case 'u':
val /= 1e6; p += 2; break;
case 'n':
val /= 1e9; p += 2; break;
}
}
if (*p && !qemu_isspace(*p)) {
monitor_printf(mon, "Unknown unit suffix\n");
goto fail;
}
qdict_put(qdict, key, qfloat_from_double(val));
}
break;
case 'b':
{
const char *beg;
bool val;
while (qemu_isspace(*p)) {
p++;
}
beg = p;
while (qemu_isgraph(*p)) {
p++;
}
if (p - beg == 2 && !memcmp(beg, "on", p - beg)) {
val = true;
} else if (p - beg == 3 && !memcmp(beg, "off", p - beg)) {
val = false;
} else {
monitor_printf(mon, "Expected 'on' or 'off'\n");
goto fail;
}
qdict_put(qdict, key, qbool_from_bool(val));
}
break;
case '-':
{
const char *tmp = p;
int skip_key = 0;
c = *typestr++;
if (c == '\0')
goto bad_type;
while (qemu_isspace(*p))
p++;
if (*p == '-') {
p++;
if(c != *p) {
if(!is_valid_option(p, typestr)) {
monitor_printf(mon, "%s: unsupported option -%c\n",
cmd->name, *p);
goto fail;
} else {
skip_key = 1;
}
}
if(skip_key) {
p = tmp;
} else {
p++;
qdict_put(qdict, key, qbool_from_bool(true));
}
}
}
break;
case 'S':
{
int len;
while (qemu_isspace(*p)) {
p++;
}
if (*typestr == '?') {
typestr++;
if (*p == '\0') {
break;
}
}
len = strlen(p);
if (len <= 0) {
monitor_printf(mon, "%s: string expected\n",
cmd->name);
goto fail;
}
qdict_put(qdict, key, qstring_from_str(p));
p += len;
}
break;
default:
bad_type:
monitor_printf(mon, "%s: unknown type '%c'\n", cmd->name, c);
goto fail;
}
g_free(key);
key = NULL;
}
while (qemu_isspace(*p))
p++;
if (*p != '\0') {
monitor_printf(mon, "%s: extraneous characters at the end of line\n",
cmd->name);
goto fail;
}
return qdict;
fail:
QDECREF(qdict);
g_free(key);
return NULL;
}
| {
"code": [],
"line_no": []
} | static QDict *FUNC_0(Monitor *mon,
const char **endp,
const mon_cmd_t *cmd)
{
const char *VAR_0;
char *VAR_1;
int VAR_2;
const char *VAR_3 = *endp;
char VAR_4[1024];
QDict *qdict = qdict_new();
VAR_0 = cmd->args_type;
for(;;) {
VAR_0 = key_get_info(VAR_0, &VAR_1);
if (!VAR_0)
break;
VAR_2 = *VAR_0;
VAR_0++;
switch(VAR_2) {
case 'F':
case 'B':
case 's':
{
int VAR_5;
while (qemu_isspace(*VAR_3))
VAR_3++;
if (*VAR_0 == '?') {
VAR_0++;
if (*VAR_3 == '\0') {
break;
}
}
VAR_5 = get_str(VAR_4, sizeof(VAR_4), &VAR_3);
if (VAR_5 < 0) {
switch(VAR_2) {
case 'F':
monitor_printf(mon, "%s: filename expected\n",
cmd->name);
break;
case 'B':
monitor_printf(mon, "%s: block device name expected\n",
cmd->name);
break;
default:
monitor_printf(mon, "%s: string expected\n", cmd->name);
break;
}
goto fail;
}
qdict_put(qdict, VAR_1, qstring_from_str(VAR_4));
}
break;
case 'O':
{
QemuOptsList *opts_list;
QemuOpts *opts;
opts_list = qemu_find_opts(VAR_1);
if (!opts_list || opts_list->desc->name) {
goto bad_type;
}
while (qemu_isspace(*VAR_3)) {
VAR_3++;
}
if (!*VAR_3)
break;
if (get_str(VAR_4, sizeof(VAR_4), &VAR_3) < 0) {
goto fail;
}
opts = qemu_opts_parse_noisily(opts_list, VAR_4, true);
if (!opts) {
goto fail;
}
qemu_opts_to_qdict(opts, qdict);
qemu_opts_del(opts);
}
break;
case '/':
{
int VAR_6, VAR_7, VAR_8;
while (qemu_isspace(*VAR_3))
VAR_3++;
if (*VAR_3 == '/') {
VAR_3++;
VAR_6 = 1;
if (qemu_isdigit(*VAR_3)) {
VAR_6 = 0;
while (qemu_isdigit(*VAR_3)) {
VAR_6 = VAR_6 * 10 + (*VAR_3 - '0');
VAR_3++;
}
}
VAR_8 = -1;
VAR_7 = -1;
for(;;) {
switch(*VAR_3) {
case 'o':
case 'd':
case 'u':
case 'x':
case 'i':
case 'VAR_2':
VAR_7 = *VAR_3++;
break;
case 'b':
VAR_8 = 1;
VAR_3++;
break;
case 'h':
VAR_8 = 2;
VAR_3++;
break;
case 'w':
VAR_8 = 4;
VAR_3++;
break;
case 'g':
case 'L':
VAR_8 = 8;
VAR_3++;
break;
default:
goto next;
}
}
next:
if (*VAR_3 != '\0' && !qemu_isspace(*VAR_3)) {
monitor_printf(mon, "invalid char in VAR_7: '%VAR_2'\n",
*VAR_3);
goto fail;
}
if (VAR_7 < 0)
VAR_7 = default_fmt_format;
if (VAR_7 != 'i') {
if (VAR_8 < 0)
VAR_8 = default_fmt_size;
default_fmt_size = VAR_8;
}
default_fmt_format = VAR_7;
} else {
VAR_6 = 1;
VAR_7 = default_fmt_format;
if (VAR_7 != 'i') {
VAR_8 = default_fmt_size;
} else {
VAR_8 = -1;
}
}
qdict_put(qdict, "VAR_6", qint_from_int(VAR_6));
qdict_put(qdict, "VAR_7", qint_from_int(VAR_7));
qdict_put(qdict, "VAR_8", qint_from_int(VAR_8));
}
break;
case 'i':
case 'l':
case 'M':
{
int64_t VAR_10;
while (qemu_isspace(*VAR_3))
VAR_3++;
if (*VAR_0 == '?' || *VAR_0 == '.') {
if (*VAR_0 == '?') {
if (*VAR_3 == '\0') {
VAR_0++;
break;
}
} else {
if (*VAR_3 == '.') {
VAR_3++;
while (qemu_isspace(*VAR_3))
VAR_3++;
} else {
VAR_0++;
break;
}
}
VAR_0++;
}
if (get_expr(mon, &VAR_10, &VAR_3))
goto fail;
if ((VAR_2 == 'i') && ((VAR_10 >> 32) & 0xffffffff)) {
monitor_printf(mon, "\'%s\' has failed: ", cmd->name);
monitor_printf(mon, "integer is for 32-bit values\n");
goto fail;
} else if (VAR_2 == 'M') {
if (VAR_10 < 0) {
monitor_printf(mon, "enter a positive value\n");
goto fail;
}
VAR_10 <<= 20;
}
qdict_put(qdict, VAR_1, qint_from_int(VAR_10));
}
break;
case 'o':
{
int64_t VAR_10;
char *VAR_9;
while (qemu_isspace(*VAR_3)) {
VAR_3++;
}
if (*VAR_0 == '?') {
VAR_0++;
if (*VAR_3 == '\0') {
break;
}
}
VAR_10 = qemu_strtosz_MiB(VAR_3, &VAR_9);
if (VAR_10 < 0) {
monitor_printf(mon, "invalid VAR_8\n");
goto fail;
}
qdict_put(qdict, VAR_1, qint_from_int(VAR_10));
VAR_3 = VAR_9;
}
break;
case 'T':
{
double VAR_10;
while (qemu_isspace(*VAR_3))
VAR_3++;
if (*VAR_0 == '?') {
VAR_0++;
if (*VAR_3 == '\0') {
break;
}
}
if (get_double(mon, &VAR_10, &VAR_3) < 0) {
goto fail;
}
if (VAR_3[0] && VAR_3[1] == 's') {
switch (*VAR_3) {
case 'm':
VAR_10 /= 1e3; VAR_3 += 2; break;
case 'u':
VAR_10 /= 1e6; VAR_3 += 2; break;
case 'n':
VAR_10 /= 1e9; VAR_3 += 2; break;
}
}
if (*VAR_3 && !qemu_isspace(*VAR_3)) {
monitor_printf(mon, "Unknown unit suffix\n");
goto fail;
}
qdict_put(qdict, VAR_1, qfloat_from_double(VAR_10));
}
break;
case 'b':
{
const char *VAR_11;
bool VAR_10;
while (qemu_isspace(*VAR_3)) {
VAR_3++;
}
VAR_11 = VAR_3;
while (qemu_isgraph(*VAR_3)) {
VAR_3++;
}
if (VAR_3 - VAR_11 == 2 && !memcmp(VAR_11, "on", VAR_3 - VAR_11)) {
VAR_10 = true;
} else if (VAR_3 - VAR_11 == 3 && !memcmp(VAR_11, "off", VAR_3 - VAR_11)) {
VAR_10 = false;
} else {
monitor_printf(mon, "Expected 'on' or 'off'\n");
goto fail;
}
qdict_put(qdict, VAR_1, qbool_from_bool(VAR_10));
}
break;
case '-':
{
const char *VAR_12 = VAR_3;
int VAR_13 = 0;
VAR_2 = *VAR_0++;
if (VAR_2 == '\0')
goto bad_type;
while (qemu_isspace(*VAR_3))
VAR_3++;
if (*VAR_3 == '-') {
VAR_3++;
if(VAR_2 != *VAR_3) {
if(!is_valid_option(VAR_3, VAR_0)) {
monitor_printf(mon, "%s: unsupported option -%VAR_2\n",
cmd->name, *VAR_3);
goto fail;
} else {
VAR_13 = 1;
}
}
if(VAR_13) {
VAR_3 = VAR_12;
} else {
VAR_3++;
qdict_put(qdict, VAR_1, qbool_from_bool(true));
}
}
}
break;
case 'S':
{
int VAR_14;
while (qemu_isspace(*VAR_3)) {
VAR_3++;
}
if (*VAR_0 == '?') {
VAR_0++;
if (*VAR_3 == '\0') {
break;
}
}
VAR_14 = strlen(VAR_3);
if (VAR_14 <= 0) {
monitor_printf(mon, "%s: string expected\n",
cmd->name);
goto fail;
}
qdict_put(qdict, VAR_1, qstring_from_str(VAR_3));
VAR_3 += VAR_14;
}
break;
default:
bad_type:
monitor_printf(mon, "%s: unknown type '%VAR_2'\n", cmd->name, VAR_2);
goto fail;
}
g_free(VAR_1);
VAR_1 = NULL;
}
while (qemu_isspace(*VAR_3))
VAR_3++;
if (*VAR_3 != '\0') {
monitor_printf(mon, "%s: extraneous characters at the VAR_9 of line\n",
cmd->name);
goto fail;
}
return qdict;
fail:
QDECREF(qdict);
g_free(VAR_1);
return NULL;
}
| [
"static QDict *FUNC_0(Monitor *mon,\nconst char **endp,\nconst mon_cmd_t *cmd)\n{",
"const char *VAR_0;",
"char *VAR_1;",
"int VAR_2;",
"const char *VAR_3 = *endp;",
"char VAR_4[1024];",
"QDict *qdict = qdict_new();",
"VAR_0 = cmd->args_type;",
"for(;;) {",
"VAR_0 = key_get_info(VAR_0, &VAR_1);",
"if (!VAR_0)\nbreak;",
"VAR_2 = *VAR_0;",
"VAR_0++;",
"switch(VAR_2) {",
"case 'F':\ncase 'B':\ncase 's':\n{",
"int VAR_5;",
"while (qemu_isspace(*VAR_3))\nVAR_3++;",
"if (*VAR_0 == '?') {",
"VAR_0++;",
"if (*VAR_3 == '\\0') {",
"break;",
"}",
"}",
"VAR_5 = get_str(VAR_4, sizeof(VAR_4), &VAR_3);",
"if (VAR_5 < 0) {",
"switch(VAR_2) {",
"case 'F':\nmonitor_printf(mon, \"%s: filename expected\\n\",\ncmd->name);",
"break;",
"case 'B':\nmonitor_printf(mon, \"%s: block device name expected\\n\",\ncmd->name);",
"break;",
"default:\nmonitor_printf(mon, \"%s: string expected\\n\", cmd->name);",
"break;",
"}",
"goto fail;",
"}",
"qdict_put(qdict, VAR_1, qstring_from_str(VAR_4));",
"}",
"break;",
"case 'O':\n{",
"QemuOptsList *opts_list;",
"QemuOpts *opts;",
"opts_list = qemu_find_opts(VAR_1);",
"if (!opts_list || opts_list->desc->name) {",
"goto bad_type;",
"}",
"while (qemu_isspace(*VAR_3)) {",
"VAR_3++;",
"}",
"if (!*VAR_3)\nbreak;",
"if (get_str(VAR_4, sizeof(VAR_4), &VAR_3) < 0) {",
"goto fail;",
"}",
"opts = qemu_opts_parse_noisily(opts_list, VAR_4, true);",
"if (!opts) {",
"goto fail;",
"}",
"qemu_opts_to_qdict(opts, qdict);",
"qemu_opts_del(opts);",
"}",
"break;",
"case '/':\n{",
"int VAR_6, VAR_7, VAR_8;",
"while (qemu_isspace(*VAR_3))\nVAR_3++;",
"if (*VAR_3 == '/') {",
"VAR_3++;",
"VAR_6 = 1;",
"if (qemu_isdigit(*VAR_3)) {",
"VAR_6 = 0;",
"while (qemu_isdigit(*VAR_3)) {",
"VAR_6 = VAR_6 * 10 + (*VAR_3 - '0');",
"VAR_3++;",
"}",
"}",
"VAR_8 = -1;",
"VAR_7 = -1;",
"for(;;) {",
"switch(*VAR_3) {",
"case 'o':\ncase 'd':\ncase 'u':\ncase 'x':\ncase 'i':\ncase 'VAR_2':\nVAR_7 = *VAR_3++;",
"break;",
"case 'b':\nVAR_8 = 1;",
"VAR_3++;",
"break;",
"case 'h':\nVAR_8 = 2;",
"VAR_3++;",
"break;",
"case 'w':\nVAR_8 = 4;",
"VAR_3++;",
"break;",
"case 'g':\ncase 'L':\nVAR_8 = 8;",
"VAR_3++;",
"break;",
"default:\ngoto next;",
"}",
"}",
"next:\nif (*VAR_3 != '\\0' && !qemu_isspace(*VAR_3)) {",
"monitor_printf(mon, \"invalid char in VAR_7: '%VAR_2'\\n\",\n*VAR_3);",
"goto fail;",
"}",
"if (VAR_7 < 0)\nVAR_7 = default_fmt_format;",
"if (VAR_7 != 'i') {",
"if (VAR_8 < 0)\nVAR_8 = default_fmt_size;",
"default_fmt_size = VAR_8;",
"}",
"default_fmt_format = VAR_7;",
"} else {",
"VAR_6 = 1;",
"VAR_7 = default_fmt_format;",
"if (VAR_7 != 'i') {",
"VAR_8 = default_fmt_size;",
"} else {",
"VAR_8 = -1;",
"}",
"}",
"qdict_put(qdict, \"VAR_6\", qint_from_int(VAR_6));",
"qdict_put(qdict, \"VAR_7\", qint_from_int(VAR_7));",
"qdict_put(qdict, \"VAR_8\", qint_from_int(VAR_8));",
"}",
"break;",
"case 'i':\ncase 'l':\ncase 'M':\n{",
"int64_t VAR_10;",
"while (qemu_isspace(*VAR_3))\nVAR_3++;",
"if (*VAR_0 == '?' || *VAR_0 == '.') {",
"if (*VAR_0 == '?') {",
"if (*VAR_3 == '\\0') {",
"VAR_0++;",
"break;",
"}",
"} else {",
"if (*VAR_3 == '.') {",
"VAR_3++;",
"while (qemu_isspace(*VAR_3))\nVAR_3++;",
"} else {",
"VAR_0++;",
"break;",
"}",
"}",
"VAR_0++;",
"}",
"if (get_expr(mon, &VAR_10, &VAR_3))\ngoto fail;",
"if ((VAR_2 == 'i') && ((VAR_10 >> 32) & 0xffffffff)) {",
"monitor_printf(mon, \"\\'%s\\' has failed: \", cmd->name);",
"monitor_printf(mon, \"integer is for 32-bit values\\n\");",
"goto fail;",
"} else if (VAR_2 == 'M') {",
"if (VAR_10 < 0) {",
"monitor_printf(mon, \"enter a positive value\\n\");",
"goto fail;",
"}",
"VAR_10 <<= 20;",
"}",
"qdict_put(qdict, VAR_1, qint_from_int(VAR_10));",
"}",
"break;",
"case 'o':\n{",
"int64_t VAR_10;",
"char *VAR_9;",
"while (qemu_isspace(*VAR_3)) {",
"VAR_3++;",
"}",
"if (*VAR_0 == '?') {",
"VAR_0++;",
"if (*VAR_3 == '\\0') {",
"break;",
"}",
"}",
"VAR_10 = qemu_strtosz_MiB(VAR_3, &VAR_9);",
"if (VAR_10 < 0) {",
"monitor_printf(mon, \"invalid VAR_8\\n\");",
"goto fail;",
"}",
"qdict_put(qdict, VAR_1, qint_from_int(VAR_10));",
"VAR_3 = VAR_9;",
"}",
"break;",
"case 'T':\n{",
"double VAR_10;",
"while (qemu_isspace(*VAR_3))\nVAR_3++;",
"if (*VAR_0 == '?') {",
"VAR_0++;",
"if (*VAR_3 == '\\0') {",
"break;",
"}",
"}",
"if (get_double(mon, &VAR_10, &VAR_3) < 0) {",
"goto fail;",
"}",
"if (VAR_3[0] && VAR_3[1] == 's') {",
"switch (*VAR_3) {",
"case 'm':\nVAR_10 /= 1e3; VAR_3 += 2; break;",
"case 'u':\nVAR_10 /= 1e6; VAR_3 += 2; break;",
"case 'n':\nVAR_10 /= 1e9; VAR_3 += 2; break;",
"}",
"}",
"if (*VAR_3 && !qemu_isspace(*VAR_3)) {",
"monitor_printf(mon, \"Unknown unit suffix\\n\");",
"goto fail;",
"}",
"qdict_put(qdict, VAR_1, qfloat_from_double(VAR_10));",
"}",
"break;",
"case 'b':\n{",
"const char *VAR_11;",
"bool VAR_10;",
"while (qemu_isspace(*VAR_3)) {",
"VAR_3++;",
"}",
"VAR_11 = VAR_3;",
"while (qemu_isgraph(*VAR_3)) {",
"VAR_3++;",
"}",
"if (VAR_3 - VAR_11 == 2 && !memcmp(VAR_11, \"on\", VAR_3 - VAR_11)) {",
"VAR_10 = true;",
"} else if (VAR_3 - VAR_11 == 3 && !memcmp(VAR_11, \"off\", VAR_3 - VAR_11)) {",
"VAR_10 = false;",
"} else {",
"monitor_printf(mon, \"Expected 'on' or 'off'\\n\");",
"goto fail;",
"}",
"qdict_put(qdict, VAR_1, qbool_from_bool(VAR_10));",
"}",
"break;",
"case '-':\n{",
"const char *VAR_12 = VAR_3;",
"int VAR_13 = 0;",
"VAR_2 = *VAR_0++;",
"if (VAR_2 == '\\0')\ngoto bad_type;",
"while (qemu_isspace(*VAR_3))\nVAR_3++;",
"if (*VAR_3 == '-') {",
"VAR_3++;",
"if(VAR_2 != *VAR_3) {",
"if(!is_valid_option(VAR_3, VAR_0)) {",
"monitor_printf(mon, \"%s: unsupported option -%VAR_2\\n\",\ncmd->name, *VAR_3);",
"goto fail;",
"} else {",
"VAR_13 = 1;",
"}",
"}",
"if(VAR_13) {",
"VAR_3 = VAR_12;",
"} else {",
"VAR_3++;",
"qdict_put(qdict, VAR_1, qbool_from_bool(true));",
"}",
"}",
"}",
"break;",
"case 'S':\n{",
"int VAR_14;",
"while (qemu_isspace(*VAR_3)) {",
"VAR_3++;",
"}",
"if (*VAR_0 == '?') {",
"VAR_0++;",
"if (*VAR_3 == '\\0') {",
"break;",
"}",
"}",
"VAR_14 = strlen(VAR_3);",
"if (VAR_14 <= 0) {",
"monitor_printf(mon, \"%s: string expected\\n\",\ncmd->name);",
"goto fail;",
"}",
"qdict_put(qdict, VAR_1, qstring_from_str(VAR_3));",
"VAR_3 += VAR_14;",
"}",
"break;",
"default:\nbad_type:\nmonitor_printf(mon, \"%s: unknown type '%VAR_2'\\n\", cmd->name, VAR_2);",
"goto fail;",
"}",
"g_free(VAR_1);",
"VAR_1 = NULL;",
"}",
"while (qemu_isspace(*VAR_3))\nVAR_3++;",
"if (*VAR_3 != '\\0') {",
"monitor_printf(mon, \"%s: extraneous characters at the VAR_9 of line\\n\",\ncmd->name);",
"goto fail;",
"}",
"return qdict;",
"fail:\nQDECREF(qdict);",
"g_free(VAR_1);",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41,
43,
45,
47
],
[
49
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
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
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135,
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161,
163
],
[
165
],
[
169,
171
],
[
173
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203,
205,
207,
209,
211,
213,
215
],
[
217
],
[
219,
221
],
[
223
],
[
225
],
[
227,
229
],
[
231
],
[
233
],
[
235,
237
],
[
239
],
[
241
],
[
243,
245,
247
],
[
249
],
[
251
],
[
253,
255
],
[
257
],
[
259
],
[
261,
263
],
[
265,
267
],
[
269
],
[
271
],
[
273,
275
],
[
277
],
[
281,
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
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
],
[
367
],
[
369
],
[
371,
373
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405,
407
],
[
409
],
[
411
],
[
415
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
449
],
[
451,
453
],
[
455
],
[
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
],
[
525
],
[
527
],
[
529
],
[
531
],
[
533
],
[
535
],
[
537
],
[
539
],
[
541
],
[
543
],
[
545
],
[
547
],
[
549
],
[
551
],
[
553
],
[
555
],
[
557
],
[
559
],
[
561,
563
],
[
565
],
[
567
],
[
573
],
[
575,
577
],
[
579,
581
],
[
583
],
[
585
],
[
587
],
[
589
],
[
593,
595
],
[
597
],
[
599
],
[
601
],
[
603
],
[
605
],
[
607
],
[
609
],
[
611
],
[
615
],
[
617
],
[
619
],
[
621
],
[
623
],
[
625
],
[
627,
629
],
[
633
],
[
637
],
[
639
],
[
641
],
[
643
],
[
645
],
[
647
],
[
651
],
[
653
],
[
655
],
[
657
],
[
659
],
[
661,
663
],
[
665
],
[
667
],
[
669
],
[
671
],
[
673
],
[
675
],
[
677,
679,
681
],
[
683
],
[
685
],
[
687
],
[
689
],
[
691
],
[
695,
697
],
[
699
],
[
701,
703
],
[
705
],
[
707
],
[
711
],
[
715,
717
],
[
719
],
[
721
],
[
723
]
] |
25,928 | static void visitor_input_teardown(TestInputVisitorData *data,
const void *unused)
{
qobject_decref(data->obj);
data->obj = NULL;
if (data->qiv) {
visit_free(data->qiv);
data->qiv = NULL;
}
}
| false | qemu | b3db211f3c80bb996a704d665fe275619f728bd4 | static void visitor_input_teardown(TestInputVisitorData *data,
const void *unused)
{
qobject_decref(data->obj);
data->obj = NULL;
if (data->qiv) {
visit_free(data->qiv);
data->qiv = NULL;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TestInputVisitorData *VAR_0,
const void *VAR_1)
{
qobject_decref(VAR_0->obj);
VAR_0->obj = NULL;
if (VAR_0->qiv) {
visit_free(VAR_0->qiv);
VAR_0->qiv = NULL;
}
}
| [
"static void FUNC_0(TestInputVisitorData *VAR_0,\nconst void *VAR_1)\n{",
"qobject_decref(VAR_0->obj);",
"VAR_0->obj = NULL;",
"if (VAR_0->qiv) {",
"visit_free(VAR_0->qiv);",
"VAR_0->qiv = NULL;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
25,929 | MigrationState *migrate_get_current(void)
{
static bool once;
static MigrationState current_migration = {
.state = MIGRATION_STATUS_NONE,
.xbzrle_cache_size = DEFAULT_MIGRATE_CACHE_SIZE,
.mbps = -1,
.parameters = {
.compress_level = DEFAULT_MIGRATE_COMPRESS_LEVEL,
.compress_threads = DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT,
.decompress_threads = DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT,
.cpu_throttle_initial = DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL,
.cpu_throttle_increment = DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT,
.max_bandwidth = MAX_THROTTLE,
.downtime_limit = DEFAULT_MIGRATE_SET_DOWNTIME,
.x_checkpoint_delay = DEFAULT_MIGRATE_X_CHECKPOINT_DELAY,
},
};
if (!once) {
current_migration.parameters.tls_creds = g_strdup("");
current_migration.parameters.tls_hostname = g_strdup("");
once = true;
}
return ¤t_migration;
}
| false | qemu | e5cb7e7677010f529d3f0f9dcdb385dea9446f8d | MigrationState *migrate_get_current(void)
{
static bool once;
static MigrationState current_migration = {
.state = MIGRATION_STATUS_NONE,
.xbzrle_cache_size = DEFAULT_MIGRATE_CACHE_SIZE,
.mbps = -1,
.parameters = {
.compress_level = DEFAULT_MIGRATE_COMPRESS_LEVEL,
.compress_threads = DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT,
.decompress_threads = DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT,
.cpu_throttle_initial = DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL,
.cpu_throttle_increment = DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT,
.max_bandwidth = MAX_THROTTLE,
.downtime_limit = DEFAULT_MIGRATE_SET_DOWNTIME,
.x_checkpoint_delay = DEFAULT_MIGRATE_X_CHECKPOINT_DELAY,
},
};
if (!once) {
current_migration.parameters.tls_creds = g_strdup("");
current_migration.parameters.tls_hostname = g_strdup("");
once = true;
}
return ¤t_migration;
}
| {
"code": [],
"line_no": []
} | MigrationState *FUNC_0(void)
{
static bool VAR_0;
static MigrationState VAR_1 = {
.state = MIGRATION_STATUS_NONE,
.xbzrle_cache_size = DEFAULT_MIGRATE_CACHE_SIZE,
.mbps = -1,
.parameters = {
.compress_level = DEFAULT_MIGRATE_COMPRESS_LEVEL,
.compress_threads = DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT,
.decompress_threads = DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT,
.cpu_throttle_initial = DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL,
.cpu_throttle_increment = DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT,
.max_bandwidth = MAX_THROTTLE,
.downtime_limit = DEFAULT_MIGRATE_SET_DOWNTIME,
.x_checkpoint_delay = DEFAULT_MIGRATE_X_CHECKPOINT_DELAY,
},
};
if (!VAR_0) {
VAR_1.parameters.tls_creds = g_strdup("");
VAR_1.parameters.tls_hostname = g_strdup("");
VAR_0 = true;
}
return &VAR_1;
}
| [
"MigrationState *FUNC_0(void)\n{",
"static bool VAR_0;",
"static MigrationState VAR_1 = {",
".state = MIGRATION_STATUS_NONE,\n.xbzrle_cache_size = DEFAULT_MIGRATE_CACHE_SIZE,\n.mbps = -1,\n.parameters = {",
".compress_level = DEFAULT_MIGRATE_COMPRESS_LEVEL,\n.compress_threads = DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT,\n.decompress_threads = DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT,\n.cpu_throttle_initial = DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL,\n.cpu_throttle_increment = DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT,\n.max_bandwidth = MAX_THROTTLE,\n.downtime_limit = DEFAULT_MIGRATE_SET_DOWNTIME,\n.x_checkpoint_delay = DEFAULT_MIGRATE_X_CHECKPOINT_DELAY,\n},",
"};",
"if (!VAR_0) {",
"VAR_1.parameters.tls_creds = g_strdup(\"\");",
"VAR_1.parameters.tls_hostname = g_strdup(\"\");",
"VAR_0 = true;",
"}",
"return &VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
11,
13,
15
],
[
17,
19,
21,
23,
25,
27,
29,
31,
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
]
] |
25,930 | static int coroutine_fn qed_aio_read_data(void *opaque, int ret,
uint64_t offset, size_t len)
{
QEDAIOCB *acb = opaque;
BDRVQEDState *s = acb_to_s(acb);
BlockDriverState *bs = acb->bs;
/* Adjust offset into cluster */
offset += qed_offset_into_cluster(s, acb->cur_pos);
trace_qed_aio_read_data(s, acb, ret, offset, len);
qemu_iovec_concat(&acb->cur_qiov, acb->qiov, acb->qiov_offset, len);
/* Handle zero cluster and backing file reads */
if (ret == QED_CLUSTER_ZERO) {
qemu_iovec_memset(&acb->cur_qiov, 0, 0, acb->cur_qiov.size);
return 0;
} else if (ret != QED_CLUSTER_FOUND) {
return qed_read_backing_file(s, acb->cur_pos, &acb->cur_qiov,
&acb->backing_qiov);
}
BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO);
ret = bdrv_co_preadv(bs->file, offset, acb->cur_qiov.size,
&acb->cur_qiov, 0);
if (ret < 0) {
return ret;
}
return 0;
}
| false | qemu | 1f01e50b8330c24714ddca5841fdbb703076b121 | static int coroutine_fn qed_aio_read_data(void *opaque, int ret,
uint64_t offset, size_t len)
{
QEDAIOCB *acb = opaque;
BDRVQEDState *s = acb_to_s(acb);
BlockDriverState *bs = acb->bs;
offset += qed_offset_into_cluster(s, acb->cur_pos);
trace_qed_aio_read_data(s, acb, ret, offset, len);
qemu_iovec_concat(&acb->cur_qiov, acb->qiov, acb->qiov_offset, len);
if (ret == QED_CLUSTER_ZERO) {
qemu_iovec_memset(&acb->cur_qiov, 0, 0, acb->cur_qiov.size);
return 0;
} else if (ret != QED_CLUSTER_FOUND) {
return qed_read_backing_file(s, acb->cur_pos, &acb->cur_qiov,
&acb->backing_qiov);
}
BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO);
ret = bdrv_co_preadv(bs->file, offset, acb->cur_qiov.size,
&acb->cur_qiov, 0);
if (ret < 0) {
return ret;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int VAR_0 qed_aio_read_data(void *opaque, int ret,
uint64_t offset, size_t len)
{
QEDAIOCB *acb = opaque;
BDRVQEDState *s = acb_to_s(acb);
BlockDriverState *bs = acb->bs;
offset += qed_offset_into_cluster(s, acb->cur_pos);
trace_qed_aio_read_data(s, acb, ret, offset, len);
qemu_iovec_concat(&acb->cur_qiov, acb->qiov, acb->qiov_offset, len);
if (ret == QED_CLUSTER_ZERO) {
qemu_iovec_memset(&acb->cur_qiov, 0, 0, acb->cur_qiov.size);
return 0;
} else if (ret != QED_CLUSTER_FOUND) {
return qed_read_backing_file(s, acb->cur_pos, &acb->cur_qiov,
&acb->backing_qiov);
}
BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO);
ret = bdrv_co_preadv(bs->file, offset, acb->cur_qiov.size,
&acb->cur_qiov, 0);
if (ret < 0) {
return ret;
}
return 0;
}
| [
"static int VAR_0 qed_aio_read_data(void *opaque, int ret,\nuint64_t offset, size_t len)\n{",
"QEDAIOCB *acb = opaque;",
"BDRVQEDState *s = acb_to_s(acb);",
"BlockDriverState *bs = acb->bs;",
"offset += qed_offset_into_cluster(s, acb->cur_pos);",
"trace_qed_aio_read_data(s, acb, ret, offset, len);",
"qemu_iovec_concat(&acb->cur_qiov, acb->qiov, acb->qiov_offset, len);",
"if (ret == QED_CLUSTER_ZERO) {",
"qemu_iovec_memset(&acb->cur_qiov, 0, 0, acb->cur_qiov.size);",
"return 0;",
"} else if (ret != QED_CLUSTER_FOUND) {",
"return qed_read_backing_file(s, acb->cur_pos, &acb->cur_qiov,\n&acb->backing_qiov);",
"}",
"BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO);",
"ret = bdrv_co_preadv(bs->file, offset, acb->cur_qiov.size,\n&acb->cur_qiov, 0);",
"if (ret < 0) {",
"return ret;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
17
],
[
21
],
[
25
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
]
] |
25,931 | static void portio_list_add_1(PortioList *piolist,
const MemoryRegionPortio *pio_init,
unsigned count, unsigned start,
unsigned off_low, unsigned off_high)
{
MemoryRegionPortio *pio;
MemoryRegionOps *ops;
MemoryRegion *region, *alias;
unsigned i;
/* Copy the sub-list and null-terminate it. */
pio = g_new(MemoryRegionPortio, count + 1);
memcpy(pio, pio_init, sizeof(MemoryRegionPortio) * count);
memset(pio + count, 0, sizeof(MemoryRegionPortio));
/* Adjust the offsets to all be zero-based for the region. */
for (i = 0; i < count; ++i) {
pio[i].offset -= off_low;
}
ops = g_new0(MemoryRegionOps, 1);
ops->old_portio = pio;
region = g_new(MemoryRegion, 1);
alias = g_new(MemoryRegion, 1);
/*
* Use an alias so that the callback is called with an absolute address,
* rather than an offset relative to to start + off_low.
*/
memory_region_init_io(region, ops, piolist->opaque, piolist->name,
INT64_MAX);
memory_region_init_alias(alias, piolist->name,
region, start + off_low, off_high - off_low);
memory_region_add_subregion(piolist->address_space,
start + off_low, alias);
piolist->regions[piolist->nr] = region;
piolist->aliases[piolist->nr] = alias;
++piolist->nr;
}
| false | qemu | b40acf99bef69fa8ab0f9092ff162fde945eec12 | static void portio_list_add_1(PortioList *piolist,
const MemoryRegionPortio *pio_init,
unsigned count, unsigned start,
unsigned off_low, unsigned off_high)
{
MemoryRegionPortio *pio;
MemoryRegionOps *ops;
MemoryRegion *region, *alias;
unsigned i;
pio = g_new(MemoryRegionPortio, count + 1);
memcpy(pio, pio_init, sizeof(MemoryRegionPortio) * count);
memset(pio + count, 0, sizeof(MemoryRegionPortio));
for (i = 0; i < count; ++i) {
pio[i].offset -= off_low;
}
ops = g_new0(MemoryRegionOps, 1);
ops->old_portio = pio;
region = g_new(MemoryRegion, 1);
alias = g_new(MemoryRegion, 1);
memory_region_init_io(region, ops, piolist->opaque, piolist->name,
INT64_MAX);
memory_region_init_alias(alias, piolist->name,
region, start + off_low, off_high - off_low);
memory_region_add_subregion(piolist->address_space,
start + off_low, alias);
piolist->regions[piolist->nr] = region;
piolist->aliases[piolist->nr] = alias;
++piolist->nr;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(PortioList *VAR_0,
const MemoryRegionPortio *VAR_1,
unsigned VAR_2, unsigned VAR_3,
unsigned VAR_4, unsigned VAR_5)
{
MemoryRegionPortio *pio;
MemoryRegionOps *ops;
MemoryRegion *region, *alias;
unsigned VAR_6;
pio = g_new(MemoryRegionPortio, VAR_2 + 1);
memcpy(pio, VAR_1, sizeof(MemoryRegionPortio) * VAR_2);
memset(pio + VAR_2, 0, sizeof(MemoryRegionPortio));
for (VAR_6 = 0; VAR_6 < VAR_2; ++VAR_6) {
pio[VAR_6].offset -= VAR_4;
}
ops = g_new0(MemoryRegionOps, 1);
ops->old_portio = pio;
region = g_new(MemoryRegion, 1);
alias = g_new(MemoryRegion, 1);
memory_region_init_io(region, ops, VAR_0->opaque, VAR_0->name,
INT64_MAX);
memory_region_init_alias(alias, VAR_0->name,
region, VAR_3 + VAR_4, VAR_5 - VAR_4);
memory_region_add_subregion(VAR_0->address_space,
VAR_3 + VAR_4, alias);
VAR_0->regions[VAR_0->nr] = region;
VAR_0->aliases[VAR_0->nr] = alias;
++VAR_0->nr;
}
| [
"static void FUNC_0(PortioList *VAR_0,\nconst MemoryRegionPortio *VAR_1,\nunsigned VAR_2, unsigned VAR_3,\nunsigned VAR_4, unsigned VAR_5)\n{",
"MemoryRegionPortio *pio;",
"MemoryRegionOps *ops;",
"MemoryRegion *region, *alias;",
"unsigned VAR_6;",
"pio = g_new(MemoryRegionPortio, VAR_2 + 1);",
"memcpy(pio, VAR_1, sizeof(MemoryRegionPortio) * VAR_2);",
"memset(pio + VAR_2, 0, sizeof(MemoryRegionPortio));",
"for (VAR_6 = 0; VAR_6 < VAR_2; ++VAR_6) {",
"pio[VAR_6].offset -= VAR_4;",
"}",
"ops = g_new0(MemoryRegionOps, 1);",
"ops->old_portio = pio;",
"region = g_new(MemoryRegion, 1);",
"alias = g_new(MemoryRegion, 1);",
"memory_region_init_io(region, ops, VAR_0->opaque, VAR_0->name,\nINT64_MAX);",
"memory_region_init_alias(alias, VAR_0->name,\nregion, VAR_3 + VAR_4, VAR_5 - VAR_4);",
"memory_region_add_subregion(VAR_0->address_space,\nVAR_3 + VAR_4, alias);",
"VAR_0->regions[VAR_0->nr] = region;",
"VAR_0->aliases[VAR_0->nr] = alias;",
"++VAR_0->nr;",
"}"
] | [
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
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
47
],
[
49
],
[
59,
61
],
[
63,
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
]
] |
25,933 | static int bochs_read(BlockDriverState *bs, int64_t sector_num,
uint8_t *buf, int nb_sectors)
{
int ret;
while (nb_sectors > 0) {
int64_t block_offset = seek_to_sector(bs, sector_num);
if (block_offset >= 0) {
ret = bdrv_pread(bs->file, block_offset, buf, 512);
if (ret != 512) {
return -1;
}
} else
memset(buf, 0, 512);
nb_sectors--;
sector_num++;
buf += 512;
}
return 0;
}
| false | qemu | e1b42f456fad6e797eaf795ed2e400c4e47d5eb4 | static int bochs_read(BlockDriverState *bs, int64_t sector_num,
uint8_t *buf, int nb_sectors)
{
int ret;
while (nb_sectors > 0) {
int64_t block_offset = seek_to_sector(bs, sector_num);
if (block_offset >= 0) {
ret = bdrv_pread(bs->file, block_offset, buf, 512);
if (ret != 512) {
return -1;
}
} else
memset(buf, 0, 512);
nb_sectors--;
sector_num++;
buf += 512;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,
uint8_t *VAR_2, int VAR_3)
{
int VAR_4;
while (VAR_3 > 0) {
int64_t block_offset = seek_to_sector(VAR_0, VAR_1);
if (block_offset >= 0) {
VAR_4 = bdrv_pread(VAR_0->file, block_offset, VAR_2, 512);
if (VAR_4 != 512) {
return -1;
}
} else
memset(VAR_2, 0, 512);
VAR_3--;
VAR_1++;
VAR_2 += 512;
}
return 0;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,\nuint8_t *VAR_2, int VAR_3)\n{",
"int VAR_4;",
"while (VAR_3 > 0) {",
"int64_t block_offset = seek_to_sector(VAR_0, VAR_1);",
"if (block_offset >= 0) {",
"VAR_4 = bdrv_pread(VAR_0->file, block_offset, VAR_2, 512);",
"if (VAR_4 != 512) {",
"return -1;",
"}",
"} else",
"memset(VAR_2, 0, 512);",
"VAR_3--;",
"VAR_1++;",
"VAR_2 += 512;",
"}",
"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
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
]
] |
25,935 | static void visit_nested_struct_list(Visitor *v, void **native, Error **errp)
{
visit_type_UserDefNestedList(v, (UserDefNestedList **)native, NULL, errp);
}
| false | qemu | b6fcf32d9b851a83dedcb609091236b97cc4a985 | static void visit_nested_struct_list(Visitor *v, void **native, Error **errp)
{
visit_type_UserDefNestedList(v, (UserDefNestedList **)native, NULL, errp);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Visitor *VAR_0, void **VAR_1, Error **VAR_2)
{
visit_type_UserDefNestedList(VAR_0, (UserDefNestedList **)VAR_1, NULL, VAR_2);
}
| [
"static void FUNC_0(Visitor *VAR_0, void **VAR_1, Error **VAR_2)\n{",
"visit_type_UserDefNestedList(VAR_0, (UserDefNestedList **)VAR_1, NULL, VAR_2);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
25,938 | int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Context *h0)
{
unsigned int first_mb_in_slice;
unsigned int pps_id;
int ret;
unsigned int slice_type, tmp, i, j;
int default_ref_list_done = 0;
int last_pic_structure, last_pic_droppable;
int needs_reinit = 0;
int field_pic_flag, bottom_field_flag;
h->qpel_put = h->h264qpel.put_h264_qpel_pixels_tab;
h->qpel_avg = h->h264qpel.avg_h264_qpel_pixels_tab;
first_mb_in_slice = get_ue_golomb(&h->gb);
if (first_mb_in_slice == 0) { // FIXME better field boundary detection
if (h0->current_slice && h->cur_pic_ptr && FIELD_PICTURE(h)) {
ff_h264_field_end(h, sl, 1);
}
h0->current_slice = 0;
if (!h0->first_field) {
if (h->cur_pic_ptr && !h->droppable) {
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
h->picture_structure == PICT_BOTTOM_FIELD);
}
h->cur_pic_ptr = NULL;
}
}
slice_type = get_ue_golomb_31(&h->gb);
if (slice_type > 9) {
av_log(h->avctx, AV_LOG_ERROR,
"slice type %d too large at %d %d\n",
slice_type, h->mb_x, h->mb_y);
return AVERROR_INVALIDDATA;
}
if (slice_type > 4) {
slice_type -= 5;
sl->slice_type_fixed = 1;
} else
sl->slice_type_fixed = 0;
slice_type = golomb_to_pict_type[slice_type];
if (slice_type == AV_PICTURE_TYPE_I ||
(h0->current_slice != 0 && slice_type == h0->last_slice_type)) {
default_ref_list_done = 1;
}
sl->slice_type = slice_type;
sl->slice_type_nos = slice_type & 3;
if (h->nal_unit_type == NAL_IDR_SLICE &&
sl->slice_type_nos != AV_PICTURE_TYPE_I) {
av_log(h->avctx, AV_LOG_ERROR, "A non-intra slice in an IDR NAL unit.\n");
return AVERROR_INVALIDDATA;
}
// to make a few old functions happy, it's wrong though
h->pict_type = sl->slice_type;
pps_id = get_ue_golomb(&h->gb);
if (pps_id >= MAX_PPS_COUNT) {
av_log(h->avctx, AV_LOG_ERROR, "pps_id %u out of range\n", pps_id);
return AVERROR_INVALIDDATA;
}
if (!h0->pps_buffers[pps_id]) {
av_log(h->avctx, AV_LOG_ERROR,
"non-existing PPS %u referenced\n",
pps_id);
return AVERROR_INVALIDDATA;
}
h->pps = *h0->pps_buffers[pps_id];
if (!h0->sps_buffers[h->pps.sps_id]) {
av_log(h->avctx, AV_LOG_ERROR,
"non-existing SPS %u referenced\n",
h->pps.sps_id);
return AVERROR_INVALIDDATA;
}
if (h->pps.sps_id != h->sps.sps_id ||
h0->sps_buffers[h->pps.sps_id]->new) {
h0->sps_buffers[h->pps.sps_id]->new = 0;
h->sps = *h0->sps_buffers[h->pps.sps_id];
if (h->bit_depth_luma != h->sps.bit_depth_luma ||
h->chroma_format_idc != h->sps.chroma_format_idc) {
h->bit_depth_luma = h->sps.bit_depth_luma;
h->chroma_format_idc = h->sps.chroma_format_idc;
needs_reinit = 1;
}
if ((ret = ff_h264_set_parameter_from_sps(h)) < 0)
return ret;
}
h->avctx->profile = ff_h264_get_profile(&h->sps);
h->avctx->level = h->sps.level_idc;
h->avctx->refs = h->sps.ref_frame_count;
if (h->mb_width != h->sps.mb_width ||
h->mb_height != h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag))
needs_reinit = 1;
h->mb_width = h->sps.mb_width;
h->mb_height = h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag);
h->mb_num = h->mb_width * h->mb_height;
h->mb_stride = h->mb_width + 1;
h->b_stride = h->mb_width * 4;
h->chroma_y_shift = h->sps.chroma_format_idc <= 1; // 400 uses yuv420p
h->width = 16 * h->mb_width;
h->height = 16 * h->mb_height;
ret = init_dimensions(h);
if (ret < 0)
return ret;
if (h->sps.video_signal_type_present_flag) {
h->avctx->color_range = h->sps.full_range ? AVCOL_RANGE_JPEG
: AVCOL_RANGE_MPEG;
if (h->sps.colour_description_present_flag) {
if (h->avctx->colorspace != h->sps.colorspace)
needs_reinit = 1;
h->avctx->color_primaries = h->sps.color_primaries;
h->avctx->color_trc = h->sps.color_trc;
h->avctx->colorspace = h->sps.colorspace;
}
}
if (h->context_initialized && needs_reinit) {
if (h != h0) {
av_log(h->avctx, AV_LOG_ERROR,
"changing width %d -> %d / height %d -> %d on "
"slice %d\n",
h->width, h->avctx->coded_width,
h->height, h->avctx->coded_height,
h0->current_slice + 1);
return AVERROR_INVALIDDATA;
}
ff_h264_flush_change(h);
if ((ret = get_pixel_format(h)) < 0)
return ret;
h->avctx->pix_fmt = ret;
av_log(h->avctx, AV_LOG_INFO, "Reinit context to %dx%d, "
"pix_fmt: %d\n", h->width, h->height, h->avctx->pix_fmt);
if ((ret = h264_slice_header_init(h, 1)) < 0) {
av_log(h->avctx, AV_LOG_ERROR,
"h264_slice_header_init() failed\n");
return ret;
}
}
if (!h->context_initialized) {
if (h != h0) {
av_log(h->avctx, AV_LOG_ERROR,
"Cannot (re-)initialize context during parallel decoding.\n");
return AVERROR_PATCHWELCOME;
}
if ((ret = get_pixel_format(h)) < 0)
return ret;
h->avctx->pix_fmt = ret;
if ((ret = h264_slice_header_init(h, 0)) < 0) {
av_log(h->avctx, AV_LOG_ERROR,
"h264_slice_header_init() failed\n");
return ret;
}
}
if (h == h0 && h->dequant_coeff_pps != pps_id) {
h->dequant_coeff_pps = pps_id;
h264_init_dequant_tables(h);
}
h->frame_num = get_bits(&h->gb, h->sps.log2_max_frame_num);
h->mb_mbaff = 0;
h->mb_aff_frame = 0;
last_pic_structure = h0->picture_structure;
last_pic_droppable = h0->droppable;
h->droppable = h->nal_ref_idc == 0;
if (h->sps.frame_mbs_only_flag) {
h->picture_structure = PICT_FRAME;
} else {
field_pic_flag = get_bits1(&h->gb);
if (field_pic_flag) {
bottom_field_flag = get_bits1(&h->gb);
h->picture_structure = PICT_TOP_FIELD + bottom_field_flag;
} else {
h->picture_structure = PICT_FRAME;
h->mb_aff_frame = h->sps.mb_aff;
}
}
h->mb_field_decoding_flag = h->picture_structure != PICT_FRAME;
if (h0->current_slice != 0) {
if (last_pic_structure != h->picture_structure ||
last_pic_droppable != h->droppable) {
av_log(h->avctx, AV_LOG_ERROR,
"Changing field mode (%d -> %d) between slices is not allowed\n",
last_pic_structure, h->picture_structure);
h->picture_structure = last_pic_structure;
h->droppable = last_pic_droppable;
return AVERROR_INVALIDDATA;
} else if (!h0->cur_pic_ptr) {
av_log(h->avctx, AV_LOG_ERROR,
"unset cur_pic_ptr on slice %d\n",
h0->current_slice + 1);
return AVERROR_INVALIDDATA;
}
} else {
/* Shorten frame num gaps so we don't have to allocate reference
* frames just to throw them away */
if (h->frame_num != h->prev_frame_num) {
int unwrap_prev_frame_num = h->prev_frame_num;
int max_frame_num = 1 << h->sps.log2_max_frame_num;
if (unwrap_prev_frame_num > h->frame_num)
unwrap_prev_frame_num -= max_frame_num;
if ((h->frame_num - unwrap_prev_frame_num) > h->sps.ref_frame_count) {
unwrap_prev_frame_num = (h->frame_num - h->sps.ref_frame_count) - 1;
if (unwrap_prev_frame_num < 0)
unwrap_prev_frame_num += max_frame_num;
h->prev_frame_num = unwrap_prev_frame_num;
}
}
/* See if we have a decoded first field looking for a pair...
* Here, we're using that to see if we should mark previously
* decode frames as "finished".
* We have to do that before the "dummy" in-between frame allocation,
* since that can modify s->current_picture_ptr. */
if (h0->first_field) {
assert(h0->cur_pic_ptr);
assert(h0->cur_pic_ptr->f.buf[0]);
assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF);
/* figure out if we have a complementary field pair */
if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) {
/* Previous field is unmatched. Don't display it, but let it
* remain for reference if marked as such. */
if (!last_pic_droppable && last_pic_structure != PICT_FRAME) {
ff_thread_report_progress(&h0->cur_pic_ptr->tf, INT_MAX,
last_pic_structure == PICT_TOP_FIELD);
}
} else {
if (h0->cur_pic_ptr->frame_num != h->frame_num) {
/* This and previous field were reference, but had
* different frame_nums. Consider this field first in
* pair. Throw away previous field except for reference
* purposes. */
if (!last_pic_droppable && last_pic_structure != PICT_FRAME) {
ff_thread_report_progress(&h0->cur_pic_ptr->tf, INT_MAX,
last_pic_structure == PICT_TOP_FIELD);
}
} else {
/* Second field in complementary pair */
if (!((last_pic_structure == PICT_TOP_FIELD &&
h->picture_structure == PICT_BOTTOM_FIELD) ||
(last_pic_structure == PICT_BOTTOM_FIELD &&
h->picture_structure == PICT_TOP_FIELD))) {
av_log(h->avctx, AV_LOG_ERROR,
"Invalid field mode combination %d/%d\n",
last_pic_structure, h->picture_structure);
h->picture_structure = last_pic_structure;
h->droppable = last_pic_droppable;
return AVERROR_INVALIDDATA;
} else if (last_pic_droppable != h->droppable) {
avpriv_request_sample(h->avctx,
"Found reference and non-reference fields in the same frame, which");
h->picture_structure = last_pic_structure;
h->droppable = last_pic_droppable;
return AVERROR_PATCHWELCOME;
}
}
}
}
while (h->frame_num != h->prev_frame_num &&
h->frame_num != (h->prev_frame_num + 1) % (1 << h->sps.log2_max_frame_num)) {
H264Picture *prev = h->short_ref_count ? h->short_ref[0] : NULL;
av_log(h->avctx, AV_LOG_DEBUG, "Frame num gap %d %d\n",
h->frame_num, h->prev_frame_num);
ret = h264_frame_start(h);
if (ret < 0) {
h0->first_field = 0;
return ret;
}
h->prev_frame_num++;
h->prev_frame_num %= 1 << h->sps.log2_max_frame_num;
h->cur_pic_ptr->frame_num = h->prev_frame_num;
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 0);
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 1);
ret = ff_generate_sliding_window_mmcos(h, 1);
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
return ret;
ret = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index);
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
return ret;
/* Error concealment: If a ref is missing, copy the previous ref
* in its place.
* FIXME: Avoiding a memcpy would be nice, but ref handling makes
* many assumptions about there being no actual duplicates.
* FIXME: This does not copy padding for out-of-frame motion
* vectors. Given we are concealing a lost frame, this probably
* is not noticeable by comparison, but it should be fixed. */
if (h->short_ref_count) {
if (prev) {
av_image_copy(h->short_ref[0]->f.data,
h->short_ref[0]->f.linesize,
(const uint8_t **)prev->f.data,
prev->f.linesize,
h->avctx->pix_fmt,
h->mb_width * 16,
h->mb_height * 16);
h->short_ref[0]->poc = prev->poc + 2;
}
h->short_ref[0]->frame_num = h->prev_frame_num;
}
}
/* See if we have a decoded first field looking for a pair...
* We're using that to see whether to continue decoding in that
* frame, or to allocate a new one. */
if (h0->first_field) {
assert(h0->cur_pic_ptr);
assert(h0->cur_pic_ptr->f.buf[0]);
assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF);
/* figure out if we have a complementary field pair */
if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) {
/* Previous field is unmatched. Don't display it, but let it
* remain for reference if marked as such. */
h0->cur_pic_ptr = NULL;
h0->first_field = FIELD_PICTURE(h);
} else {
if (h0->cur_pic_ptr->frame_num != h->frame_num) {
/* This and the previous field had different frame_nums.
* Consider this field first in pair. Throw away previous
* one except for reference purposes. */
h0->first_field = 1;
h0->cur_pic_ptr = NULL;
} else {
/* Second field in complementary pair */
h0->first_field = 0;
}
}
} else {
/* Frame or first field in a potentially complementary pair */
h0->first_field = FIELD_PICTURE(h);
}
if (!FIELD_PICTURE(h) || h0->first_field) {
if (h264_frame_start(h) < 0) {
h0->first_field = 0;
return AVERROR_INVALIDDATA;
}
} else {
release_unused_pictures(h, 0);
}
}
if (h != h0 && (ret = clone_slice(h, h0)) < 0)
return ret;
h->cur_pic_ptr->frame_num = h->frame_num; // FIXME frame_num cleanup
assert(h->mb_num == h->mb_width * h->mb_height);
if (first_mb_in_slice << FIELD_OR_MBAFF_PICTURE(h) >= h->mb_num ||
first_mb_in_slice >= h->mb_num) {
av_log(h->avctx, AV_LOG_ERROR, "first_mb_in_slice overflow\n");
return AVERROR_INVALIDDATA;
}
h->resync_mb_x = h->mb_x = first_mb_in_slice % h->mb_width;
h->resync_mb_y = h->mb_y = (first_mb_in_slice / h->mb_width) <<
FIELD_OR_MBAFF_PICTURE(h);
if (h->picture_structure == PICT_BOTTOM_FIELD)
h->resync_mb_y = h->mb_y = h->mb_y + 1;
assert(h->mb_y < h->mb_height);
if (h->picture_structure == PICT_FRAME) {
h->curr_pic_num = h->frame_num;
h->max_pic_num = 1 << h->sps.log2_max_frame_num;
} else {
h->curr_pic_num = 2 * h->frame_num + 1;
h->max_pic_num = 1 << (h->sps.log2_max_frame_num + 1);
}
if (h->nal_unit_type == NAL_IDR_SLICE)
get_ue_golomb(&h->gb); /* idr_pic_id */
if (h->sps.poc_type == 0) {
h->poc_lsb = get_bits(&h->gb, h->sps.log2_max_poc_lsb);
if (h->pps.pic_order_present == 1 && h->picture_structure == PICT_FRAME)
h->delta_poc_bottom = get_se_golomb(&h->gb);
}
if (h->sps.poc_type == 1 && !h->sps.delta_pic_order_always_zero_flag) {
h->delta_poc[0] = get_se_golomb(&h->gb);
if (h->pps.pic_order_present == 1 && h->picture_structure == PICT_FRAME)
h->delta_poc[1] = get_se_golomb(&h->gb);
}
ff_init_poc(h, h->cur_pic_ptr->field_poc, &h->cur_pic_ptr->poc);
if (h->pps.redundant_pic_cnt_present)
h->redundant_pic_count = get_ue_golomb(&h->gb);
ret = ff_set_ref_count(h, sl);
if (ret < 0)
return ret;
else if (ret == 1)
default_ref_list_done = 0;
if (!default_ref_list_done)
ff_h264_fill_default_ref_list(h, sl);
if (sl->slice_type_nos != AV_PICTURE_TYPE_I) {
ret = ff_h264_decode_ref_pic_list_reordering(h, sl);
if (ret < 0) {
sl->ref_count[1] = sl->ref_count[0] = 0;
return ret;
}
}
if ((h->pps.weighted_pred && sl->slice_type_nos == AV_PICTURE_TYPE_P) ||
(h->pps.weighted_bipred_idc == 1 &&
sl->slice_type_nos == AV_PICTURE_TYPE_B))
ff_pred_weight_table(h, sl);
else if (h->pps.weighted_bipred_idc == 2 &&
sl->slice_type_nos == AV_PICTURE_TYPE_B) {
implicit_weight_table(h, sl, -1);
} else {
sl->use_weight = 0;
for (i = 0; i < 2; i++) {
sl->luma_weight_flag[i] = 0;
sl->chroma_weight_flag[i] = 0;
}
}
// If frame-mt is enabled, only update mmco tables for the first slice
// in a field. Subsequent slices can temporarily clobber h->mmco_index
// or h->mmco, which will cause ref list mix-ups and decoding errors
// further down the line. This may break decoding if the first slice is
// corrupt, thus we only do this if frame-mt is enabled.
if (h->nal_ref_idc) {
ret = ff_h264_decode_ref_pic_marking(h0, &h->gb,
!(h->avctx->active_thread_type & FF_THREAD_FRAME) ||
h0->current_slice == 0);
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
return AVERROR_INVALIDDATA;
}
if (FRAME_MBAFF(h)) {
ff_h264_fill_mbaff_ref_list(h, sl);
if (h->pps.weighted_bipred_idc == 2 && sl->slice_type_nos == AV_PICTURE_TYPE_B) {
implicit_weight_table(h, sl, 0);
implicit_weight_table(h, sl, 1);
}
}
if (sl->slice_type_nos == AV_PICTURE_TYPE_B && !sl->direct_spatial_mv_pred)
ff_h264_direct_dist_scale_factor(h, sl);
ff_h264_direct_ref_list_init(h, sl);
if (sl->slice_type_nos != AV_PICTURE_TYPE_I && h->pps.cabac) {
tmp = get_ue_golomb_31(&h->gb);
if (tmp > 2) {
av_log(h->avctx, AV_LOG_ERROR, "cabac_init_idc %u overflow\n", tmp);
return AVERROR_INVALIDDATA;
}
h->cabac_init_idc = tmp;
}
sl->last_qscale_diff = 0;
tmp = h->pps.init_qp + get_se_golomb(&h->gb);
if (tmp > 51 + 6 * (h->sps.bit_depth_luma - 8)) {
av_log(h->avctx, AV_LOG_ERROR, "QP %u out of range\n", tmp);
return AVERROR_INVALIDDATA;
}
sl->qscale = tmp;
sl->chroma_qp[0] = get_chroma_qp(h, 0, sl->qscale);
sl->chroma_qp[1] = get_chroma_qp(h, 1, sl->qscale);
// FIXME qscale / qp ... stuff
if (sl->slice_type == AV_PICTURE_TYPE_SP)
get_bits1(&h->gb); /* sp_for_switch_flag */
if (sl->slice_type == AV_PICTURE_TYPE_SP ||
sl->slice_type == AV_PICTURE_TYPE_SI)
get_se_golomb(&h->gb); /* slice_qs_delta */
h->deblocking_filter = 1;
h->slice_alpha_c0_offset = 0;
h->slice_beta_offset = 0;
if (h->pps.deblocking_filter_parameters_present) {
tmp = get_ue_golomb_31(&h->gb);
if (tmp > 2) {
av_log(h->avctx, AV_LOG_ERROR,
"deblocking_filter_idc %u out of range\n", tmp);
return AVERROR_INVALIDDATA;
}
h->deblocking_filter = tmp;
if (h->deblocking_filter < 2)
h->deblocking_filter ^= 1; // 1<->0
if (h->deblocking_filter) {
h->slice_alpha_c0_offset = get_se_golomb(&h->gb) * 2;
h->slice_beta_offset = get_se_golomb(&h->gb) * 2;
if (h->slice_alpha_c0_offset > 12 ||
h->slice_alpha_c0_offset < -12 ||
h->slice_beta_offset > 12 ||
h->slice_beta_offset < -12) {
av_log(h->avctx, AV_LOG_ERROR,
"deblocking filter parameters %d %d out of range\n",
h->slice_alpha_c0_offset, h->slice_beta_offset);
return AVERROR_INVALIDDATA;
}
}
}
if (h->avctx->skip_loop_filter >= AVDISCARD_ALL ||
(h->avctx->skip_loop_filter >= AVDISCARD_NONKEY &&
sl->slice_type_nos != AV_PICTURE_TYPE_I) ||
(h->avctx->skip_loop_filter >= AVDISCARD_BIDIR &&
sl->slice_type_nos == AV_PICTURE_TYPE_B) ||
(h->avctx->skip_loop_filter >= AVDISCARD_NONREF &&
h->nal_ref_idc == 0))
h->deblocking_filter = 0;
if (h->deblocking_filter == 1 && h0->max_contexts > 1) {
if (h->avctx->flags2 & CODEC_FLAG2_FAST) {
/* Cheat slightly for speed:
* Do not bother to deblock across slices. */
h->deblocking_filter = 2;
} else {
h0->max_contexts = 1;
if (!h0->single_decode_warning) {
av_log(h->avctx, AV_LOG_INFO,
"Cannot parallelize deblocking type 1, decoding such frames in sequential order\n");
h0->single_decode_warning = 1;
}
if (h != h0) {
av_log(h->avctx, AV_LOG_ERROR,
"Deblocking switched inside frame.\n");
return 1;
}
}
}
sl->qp_thresh = 15 -
FFMIN(h->slice_alpha_c0_offset, h->slice_beta_offset) -
FFMAX3(0,
h->pps.chroma_qp_index_offset[0],
h->pps.chroma_qp_index_offset[1]) +
6 * (h->sps.bit_depth_luma - 8);
h0->last_slice_type = slice_type;
sl->slice_num = ++h0->current_slice;
if (sl->slice_num >= MAX_SLICES) {
av_log(h->avctx, AV_LOG_ERROR,
"Too many slices, increase MAX_SLICES and recompile\n");
}
for (j = 0; j < 2; j++) {
int id_list[16];
int *ref2frm = sl->ref2frm[sl->slice_num & (MAX_SLICES - 1)][j];
for (i = 0; i < 16; i++) {
id_list[i] = 60;
if (j < sl->list_count && i < sl->ref_count[j] &&
sl->ref_list[j][i].f.buf[0]) {
int k;
AVBuffer *buf = sl->ref_list[j][i].f.buf[0]->buffer;
for (k = 0; k < h->short_ref_count; k++)
if (h->short_ref[k]->f.buf[0]->buffer == buf) {
id_list[i] = k;
break;
}
for (k = 0; k < h->long_ref_count; k++)
if (h->long_ref[k] && h->long_ref[k]->f.buf[0]->buffer == buf) {
id_list[i] = h->short_ref_count + k;
break;
}
}
}
ref2frm[0] =
ref2frm[1] = -1;
for (i = 0; i < 16; i++)
ref2frm[i + 2] = 4 * id_list[i] + (sl->ref_list[j][i].reference & 3);
ref2frm[18 + 0] =
ref2frm[18 + 1] = -1;
for (i = 16; i < 48; i++)
ref2frm[i + 4] = 4 * id_list[(i - 16) >> 1] +
(sl->ref_list[j][i].reference & 3);
}
if (h->avctx->debug & FF_DEBUG_PICT_INFO) {
av_log(h->avctx, AV_LOG_DEBUG,
"slice:%d %s mb:%d %c%s%s pps:%u frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d:%d:%d weight:%d%s %s\n",
sl->slice_num,
(h->picture_structure == PICT_FRAME ? "F" : h->picture_structure == PICT_TOP_FIELD ? "T" : "B"),
first_mb_in_slice,
av_get_picture_type_char(sl->slice_type),
sl->slice_type_fixed ? " fix" : "",
h->nal_unit_type == NAL_IDR_SLICE ? " IDR" : "",
pps_id, h->frame_num,
h->cur_pic_ptr->field_poc[0],
h->cur_pic_ptr->field_poc[1],
sl->ref_count[0], sl->ref_count[1],
sl->qscale,
h->deblocking_filter,
h->slice_alpha_c0_offset, h->slice_beta_offset,
sl->use_weight,
sl->use_weight == 1 && sl->use_weight_chroma ? "c" : "",
sl->slice_type == AV_PICTURE_TYPE_B ? (sl->direct_spatial_mv_pred ? "SPAT" : "TEMP") : "");
}
return 0;
}
| false | FFmpeg | e6c90ce94f1b07f50cea2babf7471af455cca0ff | int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Context *h0)
{
unsigned int first_mb_in_slice;
unsigned int pps_id;
int ret;
unsigned int slice_type, tmp, i, j;
int default_ref_list_done = 0;
int last_pic_structure, last_pic_droppable;
int needs_reinit = 0;
int field_pic_flag, bottom_field_flag;
h->qpel_put = h->h264qpel.put_h264_qpel_pixels_tab;
h->qpel_avg = h->h264qpel.avg_h264_qpel_pixels_tab;
first_mb_in_slice = get_ue_golomb(&h->gb);
if (first_mb_in_slice == 0) {
if (h0->current_slice && h->cur_pic_ptr && FIELD_PICTURE(h)) {
ff_h264_field_end(h, sl, 1);
}
h0->current_slice = 0;
if (!h0->first_field) {
if (h->cur_pic_ptr && !h->droppable) {
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
h->picture_structure == PICT_BOTTOM_FIELD);
}
h->cur_pic_ptr = NULL;
}
}
slice_type = get_ue_golomb_31(&h->gb);
if (slice_type > 9) {
av_log(h->avctx, AV_LOG_ERROR,
"slice type %d too large at %d %d\n",
slice_type, h->mb_x, h->mb_y);
return AVERROR_INVALIDDATA;
}
if (slice_type > 4) {
slice_type -= 5;
sl->slice_type_fixed = 1;
} else
sl->slice_type_fixed = 0;
slice_type = golomb_to_pict_type[slice_type];
if (slice_type == AV_PICTURE_TYPE_I ||
(h0->current_slice != 0 && slice_type == h0->last_slice_type)) {
default_ref_list_done = 1;
}
sl->slice_type = slice_type;
sl->slice_type_nos = slice_type & 3;
if (h->nal_unit_type == NAL_IDR_SLICE &&
sl->slice_type_nos != AV_PICTURE_TYPE_I) {
av_log(h->avctx, AV_LOG_ERROR, "A non-intra slice in an IDR NAL unit.\n");
return AVERROR_INVALIDDATA;
}
h->pict_type = sl->slice_type;
pps_id = get_ue_golomb(&h->gb);
if (pps_id >= MAX_PPS_COUNT) {
av_log(h->avctx, AV_LOG_ERROR, "pps_id %u out of range\n", pps_id);
return AVERROR_INVALIDDATA;
}
if (!h0->pps_buffers[pps_id]) {
av_log(h->avctx, AV_LOG_ERROR,
"non-existing PPS %u referenced\n",
pps_id);
return AVERROR_INVALIDDATA;
}
h->pps = *h0->pps_buffers[pps_id];
if (!h0->sps_buffers[h->pps.sps_id]) {
av_log(h->avctx, AV_LOG_ERROR,
"non-existing SPS %u referenced\n",
h->pps.sps_id);
return AVERROR_INVALIDDATA;
}
if (h->pps.sps_id != h->sps.sps_id ||
h0->sps_buffers[h->pps.sps_id]->new) {
h0->sps_buffers[h->pps.sps_id]->new = 0;
h->sps = *h0->sps_buffers[h->pps.sps_id];
if (h->bit_depth_luma != h->sps.bit_depth_luma ||
h->chroma_format_idc != h->sps.chroma_format_idc) {
h->bit_depth_luma = h->sps.bit_depth_luma;
h->chroma_format_idc = h->sps.chroma_format_idc;
needs_reinit = 1;
}
if ((ret = ff_h264_set_parameter_from_sps(h)) < 0)
return ret;
}
h->avctx->profile = ff_h264_get_profile(&h->sps);
h->avctx->level = h->sps.level_idc;
h->avctx->refs = h->sps.ref_frame_count;
if (h->mb_width != h->sps.mb_width ||
h->mb_height != h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag))
needs_reinit = 1;
h->mb_width = h->sps.mb_width;
h->mb_height = h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag);
h->mb_num = h->mb_width * h->mb_height;
h->mb_stride = h->mb_width + 1;
h->b_stride = h->mb_width * 4;
h->chroma_y_shift = h->sps.chroma_format_idc <= 1;
h->width = 16 * h->mb_width;
h->height = 16 * h->mb_height;
ret = init_dimensions(h);
if (ret < 0)
return ret;
if (h->sps.video_signal_type_present_flag) {
h->avctx->color_range = h->sps.full_range ? AVCOL_RANGE_JPEG
: AVCOL_RANGE_MPEG;
if (h->sps.colour_description_present_flag) {
if (h->avctx->colorspace != h->sps.colorspace)
needs_reinit = 1;
h->avctx->color_primaries = h->sps.color_primaries;
h->avctx->color_trc = h->sps.color_trc;
h->avctx->colorspace = h->sps.colorspace;
}
}
if (h->context_initialized && needs_reinit) {
if (h != h0) {
av_log(h->avctx, AV_LOG_ERROR,
"changing width %d -> %d / height %d -> %d on "
"slice %d\n",
h->width, h->avctx->coded_width,
h->height, h->avctx->coded_height,
h0->current_slice + 1);
return AVERROR_INVALIDDATA;
}
ff_h264_flush_change(h);
if ((ret = get_pixel_format(h)) < 0)
return ret;
h->avctx->pix_fmt = ret;
av_log(h->avctx, AV_LOG_INFO, "Reinit context to %dx%d, "
"pix_fmt: %d\n", h->width, h->height, h->avctx->pix_fmt);
if ((ret = h264_slice_header_init(h, 1)) < 0) {
av_log(h->avctx, AV_LOG_ERROR,
"h264_slice_header_init() failed\n");
return ret;
}
}
if (!h->context_initialized) {
if (h != h0) {
av_log(h->avctx, AV_LOG_ERROR,
"Cannot (re-)initialize context during parallel decoding.\n");
return AVERROR_PATCHWELCOME;
}
if ((ret = get_pixel_format(h)) < 0)
return ret;
h->avctx->pix_fmt = ret;
if ((ret = h264_slice_header_init(h, 0)) < 0) {
av_log(h->avctx, AV_LOG_ERROR,
"h264_slice_header_init() failed\n");
return ret;
}
}
if (h == h0 && h->dequant_coeff_pps != pps_id) {
h->dequant_coeff_pps = pps_id;
h264_init_dequant_tables(h);
}
h->frame_num = get_bits(&h->gb, h->sps.log2_max_frame_num);
h->mb_mbaff = 0;
h->mb_aff_frame = 0;
last_pic_structure = h0->picture_structure;
last_pic_droppable = h0->droppable;
h->droppable = h->nal_ref_idc == 0;
if (h->sps.frame_mbs_only_flag) {
h->picture_structure = PICT_FRAME;
} else {
field_pic_flag = get_bits1(&h->gb);
if (field_pic_flag) {
bottom_field_flag = get_bits1(&h->gb);
h->picture_structure = PICT_TOP_FIELD + bottom_field_flag;
} else {
h->picture_structure = PICT_FRAME;
h->mb_aff_frame = h->sps.mb_aff;
}
}
h->mb_field_decoding_flag = h->picture_structure != PICT_FRAME;
if (h0->current_slice != 0) {
if (last_pic_structure != h->picture_structure ||
last_pic_droppable != h->droppable) {
av_log(h->avctx, AV_LOG_ERROR,
"Changing field mode (%d -> %d) between slices is not allowed\n",
last_pic_structure, h->picture_structure);
h->picture_structure = last_pic_structure;
h->droppable = last_pic_droppable;
return AVERROR_INVALIDDATA;
} else if (!h0->cur_pic_ptr) {
av_log(h->avctx, AV_LOG_ERROR,
"unset cur_pic_ptr on slice %d\n",
h0->current_slice + 1);
return AVERROR_INVALIDDATA;
}
} else {
if (h->frame_num != h->prev_frame_num) {
int unwrap_prev_frame_num = h->prev_frame_num;
int max_frame_num = 1 << h->sps.log2_max_frame_num;
if (unwrap_prev_frame_num > h->frame_num)
unwrap_prev_frame_num -= max_frame_num;
if ((h->frame_num - unwrap_prev_frame_num) > h->sps.ref_frame_count) {
unwrap_prev_frame_num = (h->frame_num - h->sps.ref_frame_count) - 1;
if (unwrap_prev_frame_num < 0)
unwrap_prev_frame_num += max_frame_num;
h->prev_frame_num = unwrap_prev_frame_num;
}
}
if (h0->first_field) {
assert(h0->cur_pic_ptr);
assert(h0->cur_pic_ptr->f.buf[0]);
assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF);
if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) {
if (!last_pic_droppable && last_pic_structure != PICT_FRAME) {
ff_thread_report_progress(&h0->cur_pic_ptr->tf, INT_MAX,
last_pic_structure == PICT_TOP_FIELD);
}
} else {
if (h0->cur_pic_ptr->frame_num != h->frame_num) {
if (!last_pic_droppable && last_pic_structure != PICT_FRAME) {
ff_thread_report_progress(&h0->cur_pic_ptr->tf, INT_MAX,
last_pic_structure == PICT_TOP_FIELD);
}
} else {
if (!((last_pic_structure == PICT_TOP_FIELD &&
h->picture_structure == PICT_BOTTOM_FIELD) ||
(last_pic_structure == PICT_BOTTOM_FIELD &&
h->picture_structure == PICT_TOP_FIELD))) {
av_log(h->avctx, AV_LOG_ERROR,
"Invalid field mode combination %d/%d\n",
last_pic_structure, h->picture_structure);
h->picture_structure = last_pic_structure;
h->droppable = last_pic_droppable;
return AVERROR_INVALIDDATA;
} else if (last_pic_droppable != h->droppable) {
avpriv_request_sample(h->avctx,
"Found reference and non-reference fields in the same frame, which");
h->picture_structure = last_pic_structure;
h->droppable = last_pic_droppable;
return AVERROR_PATCHWELCOME;
}
}
}
}
while (h->frame_num != h->prev_frame_num &&
h->frame_num != (h->prev_frame_num + 1) % (1 << h->sps.log2_max_frame_num)) {
H264Picture *prev = h->short_ref_count ? h->short_ref[0] : NULL;
av_log(h->avctx, AV_LOG_DEBUG, "Frame num gap %d %d\n",
h->frame_num, h->prev_frame_num);
ret = h264_frame_start(h);
if (ret < 0) {
h0->first_field = 0;
return ret;
}
h->prev_frame_num++;
h->prev_frame_num %= 1 << h->sps.log2_max_frame_num;
h->cur_pic_ptr->frame_num = h->prev_frame_num;
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 0);
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 1);
ret = ff_generate_sliding_window_mmcos(h, 1);
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
return ret;
ret = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index);
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
return ret;
if (h->short_ref_count) {
if (prev) {
av_image_copy(h->short_ref[0]->f.data,
h->short_ref[0]->f.linesize,
(const uint8_t **)prev->f.data,
prev->f.linesize,
h->avctx->pix_fmt,
h->mb_width * 16,
h->mb_height * 16);
h->short_ref[0]->poc = prev->poc + 2;
}
h->short_ref[0]->frame_num = h->prev_frame_num;
}
}
if (h0->first_field) {
assert(h0->cur_pic_ptr);
assert(h0->cur_pic_ptr->f.buf[0]);
assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF);
if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) {
h0->cur_pic_ptr = NULL;
h0->first_field = FIELD_PICTURE(h);
} else {
if (h0->cur_pic_ptr->frame_num != h->frame_num) {
h0->first_field = 1;
h0->cur_pic_ptr = NULL;
} else {
h0->first_field = 0;
}
}
} else {
h0->first_field = FIELD_PICTURE(h);
}
if (!FIELD_PICTURE(h) || h0->first_field) {
if (h264_frame_start(h) < 0) {
h0->first_field = 0;
return AVERROR_INVALIDDATA;
}
} else {
release_unused_pictures(h, 0);
}
}
if (h != h0 && (ret = clone_slice(h, h0)) < 0)
return ret;
h->cur_pic_ptr->frame_num = h->frame_num;
assert(h->mb_num == h->mb_width * h->mb_height);
if (first_mb_in_slice << FIELD_OR_MBAFF_PICTURE(h) >= h->mb_num ||
first_mb_in_slice >= h->mb_num) {
av_log(h->avctx, AV_LOG_ERROR, "first_mb_in_slice overflow\n");
return AVERROR_INVALIDDATA;
}
h->resync_mb_x = h->mb_x = first_mb_in_slice % h->mb_width;
h->resync_mb_y = h->mb_y = (first_mb_in_slice / h->mb_width) <<
FIELD_OR_MBAFF_PICTURE(h);
if (h->picture_structure == PICT_BOTTOM_FIELD)
h->resync_mb_y = h->mb_y = h->mb_y + 1;
assert(h->mb_y < h->mb_height);
if (h->picture_structure == PICT_FRAME) {
h->curr_pic_num = h->frame_num;
h->max_pic_num = 1 << h->sps.log2_max_frame_num;
} else {
h->curr_pic_num = 2 * h->frame_num + 1;
h->max_pic_num = 1 << (h->sps.log2_max_frame_num + 1);
}
if (h->nal_unit_type == NAL_IDR_SLICE)
get_ue_golomb(&h->gb);
if (h->sps.poc_type == 0) {
h->poc_lsb = get_bits(&h->gb, h->sps.log2_max_poc_lsb);
if (h->pps.pic_order_present == 1 && h->picture_structure == PICT_FRAME)
h->delta_poc_bottom = get_se_golomb(&h->gb);
}
if (h->sps.poc_type == 1 && !h->sps.delta_pic_order_always_zero_flag) {
h->delta_poc[0] = get_se_golomb(&h->gb);
if (h->pps.pic_order_present == 1 && h->picture_structure == PICT_FRAME)
h->delta_poc[1] = get_se_golomb(&h->gb);
}
ff_init_poc(h, h->cur_pic_ptr->field_poc, &h->cur_pic_ptr->poc);
if (h->pps.redundant_pic_cnt_present)
h->redundant_pic_count = get_ue_golomb(&h->gb);
ret = ff_set_ref_count(h, sl);
if (ret < 0)
return ret;
else if (ret == 1)
default_ref_list_done = 0;
if (!default_ref_list_done)
ff_h264_fill_default_ref_list(h, sl);
if (sl->slice_type_nos != AV_PICTURE_TYPE_I) {
ret = ff_h264_decode_ref_pic_list_reordering(h, sl);
if (ret < 0) {
sl->ref_count[1] = sl->ref_count[0] = 0;
return ret;
}
}
if ((h->pps.weighted_pred && sl->slice_type_nos == AV_PICTURE_TYPE_P) ||
(h->pps.weighted_bipred_idc == 1 &&
sl->slice_type_nos == AV_PICTURE_TYPE_B))
ff_pred_weight_table(h, sl);
else if (h->pps.weighted_bipred_idc == 2 &&
sl->slice_type_nos == AV_PICTURE_TYPE_B) {
implicit_weight_table(h, sl, -1);
} else {
sl->use_weight = 0;
for (i = 0; i < 2; i++) {
sl->luma_weight_flag[i] = 0;
sl->chroma_weight_flag[i] = 0;
}
}
if (h->nal_ref_idc) {
ret = ff_h264_decode_ref_pic_marking(h0, &h->gb,
!(h->avctx->active_thread_type & FF_THREAD_FRAME) ||
h0->current_slice == 0);
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
return AVERROR_INVALIDDATA;
}
if (FRAME_MBAFF(h)) {
ff_h264_fill_mbaff_ref_list(h, sl);
if (h->pps.weighted_bipred_idc == 2 && sl->slice_type_nos == AV_PICTURE_TYPE_B) {
implicit_weight_table(h, sl, 0);
implicit_weight_table(h, sl, 1);
}
}
if (sl->slice_type_nos == AV_PICTURE_TYPE_B && !sl->direct_spatial_mv_pred)
ff_h264_direct_dist_scale_factor(h, sl);
ff_h264_direct_ref_list_init(h, sl);
if (sl->slice_type_nos != AV_PICTURE_TYPE_I && h->pps.cabac) {
tmp = get_ue_golomb_31(&h->gb);
if (tmp > 2) {
av_log(h->avctx, AV_LOG_ERROR, "cabac_init_idc %u overflow\n", tmp);
return AVERROR_INVALIDDATA;
}
h->cabac_init_idc = tmp;
}
sl->last_qscale_diff = 0;
tmp = h->pps.init_qp + get_se_golomb(&h->gb);
if (tmp > 51 + 6 * (h->sps.bit_depth_luma - 8)) {
av_log(h->avctx, AV_LOG_ERROR, "QP %u out of range\n", tmp);
return AVERROR_INVALIDDATA;
}
sl->qscale = tmp;
sl->chroma_qp[0] = get_chroma_qp(h, 0, sl->qscale);
sl->chroma_qp[1] = get_chroma_qp(h, 1, sl->qscale);
if (sl->slice_type == AV_PICTURE_TYPE_SP)
get_bits1(&h->gb);
if (sl->slice_type == AV_PICTURE_TYPE_SP ||
sl->slice_type == AV_PICTURE_TYPE_SI)
get_se_golomb(&h->gb);
h->deblocking_filter = 1;
h->slice_alpha_c0_offset = 0;
h->slice_beta_offset = 0;
if (h->pps.deblocking_filter_parameters_present) {
tmp = get_ue_golomb_31(&h->gb);
if (tmp > 2) {
av_log(h->avctx, AV_LOG_ERROR,
"deblocking_filter_idc %u out of range\n", tmp);
return AVERROR_INVALIDDATA;
}
h->deblocking_filter = tmp;
if (h->deblocking_filter < 2)
h->deblocking_filter ^= 1;
if (h->deblocking_filter) {
h->slice_alpha_c0_offset = get_se_golomb(&h->gb) * 2;
h->slice_beta_offset = get_se_golomb(&h->gb) * 2;
if (h->slice_alpha_c0_offset > 12 ||
h->slice_alpha_c0_offset < -12 ||
h->slice_beta_offset > 12 ||
h->slice_beta_offset < -12) {
av_log(h->avctx, AV_LOG_ERROR,
"deblocking filter parameters %d %d out of range\n",
h->slice_alpha_c0_offset, h->slice_beta_offset);
return AVERROR_INVALIDDATA;
}
}
}
if (h->avctx->skip_loop_filter >= AVDISCARD_ALL ||
(h->avctx->skip_loop_filter >= AVDISCARD_NONKEY &&
sl->slice_type_nos != AV_PICTURE_TYPE_I) ||
(h->avctx->skip_loop_filter >= AVDISCARD_BIDIR &&
sl->slice_type_nos == AV_PICTURE_TYPE_B) ||
(h->avctx->skip_loop_filter >= AVDISCARD_NONREF &&
h->nal_ref_idc == 0))
h->deblocking_filter = 0;
if (h->deblocking_filter == 1 && h0->max_contexts > 1) {
if (h->avctx->flags2 & CODEC_FLAG2_FAST) {
h->deblocking_filter = 2;
} else {
h0->max_contexts = 1;
if (!h0->single_decode_warning) {
av_log(h->avctx, AV_LOG_INFO,
"Cannot parallelize deblocking type 1, decoding such frames in sequential order\n");
h0->single_decode_warning = 1;
}
if (h != h0) {
av_log(h->avctx, AV_LOG_ERROR,
"Deblocking switched inside frame.\n");
return 1;
}
}
}
sl->qp_thresh = 15 -
FFMIN(h->slice_alpha_c0_offset, h->slice_beta_offset) -
FFMAX3(0,
h->pps.chroma_qp_index_offset[0],
h->pps.chroma_qp_index_offset[1]) +
6 * (h->sps.bit_depth_luma - 8);
h0->last_slice_type = slice_type;
sl->slice_num = ++h0->current_slice;
if (sl->slice_num >= MAX_SLICES) {
av_log(h->avctx, AV_LOG_ERROR,
"Too many slices, increase MAX_SLICES and recompile\n");
}
for (j = 0; j < 2; j++) {
int id_list[16];
int *ref2frm = sl->ref2frm[sl->slice_num & (MAX_SLICES - 1)][j];
for (i = 0; i < 16; i++) {
id_list[i] = 60;
if (j < sl->list_count && i < sl->ref_count[j] &&
sl->ref_list[j][i].f.buf[0]) {
int k;
AVBuffer *buf = sl->ref_list[j][i].f.buf[0]->buffer;
for (k = 0; k < h->short_ref_count; k++)
if (h->short_ref[k]->f.buf[0]->buffer == buf) {
id_list[i] = k;
break;
}
for (k = 0; k < h->long_ref_count; k++)
if (h->long_ref[k] && h->long_ref[k]->f.buf[0]->buffer == buf) {
id_list[i] = h->short_ref_count + k;
break;
}
}
}
ref2frm[0] =
ref2frm[1] = -1;
for (i = 0; i < 16; i++)
ref2frm[i + 2] = 4 * id_list[i] + (sl->ref_list[j][i].reference & 3);
ref2frm[18 + 0] =
ref2frm[18 + 1] = -1;
for (i = 16; i < 48; i++)
ref2frm[i + 4] = 4 * id_list[(i - 16) >> 1] +
(sl->ref_list[j][i].reference & 3);
}
if (h->avctx->debug & FF_DEBUG_PICT_INFO) {
av_log(h->avctx, AV_LOG_DEBUG,
"slice:%d %s mb:%d %c%s%s pps:%u frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d:%d:%d weight:%d%s %s\n",
sl->slice_num,
(h->picture_structure == PICT_FRAME ? "F" : h->picture_structure == PICT_TOP_FIELD ? "T" : "B"),
first_mb_in_slice,
av_get_picture_type_char(sl->slice_type),
sl->slice_type_fixed ? " fix" : "",
h->nal_unit_type == NAL_IDR_SLICE ? " IDR" : "",
pps_id, h->frame_num,
h->cur_pic_ptr->field_poc[0],
h->cur_pic_ptr->field_poc[1],
sl->ref_count[0], sl->ref_count[1],
sl->qscale,
h->deblocking_filter,
h->slice_alpha_c0_offset, h->slice_beta_offset,
sl->use_weight,
sl->use_weight == 1 && sl->use_weight_chroma ? "c" : "",
sl->slice_type == AV_PICTURE_TYPE_B ? (sl->direct_spatial_mv_pred ? "SPAT" : "TEMP") : "");
}
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(H264Context *VAR_0, H264SliceContext *VAR_1, H264Context *VAR_2)
{
unsigned int VAR_3;
unsigned int VAR_4;
int VAR_5;
unsigned int VAR_6, VAR_7, VAR_8, VAR_9;
int VAR_10 = 0;
int VAR_11, VAR_12;
int VAR_13 = 0;
int VAR_14, VAR_15;
VAR_0->qpel_put = VAR_0->h264qpel.put_h264_qpel_pixels_tab;
VAR_0->qpel_avg = VAR_0->h264qpel.avg_h264_qpel_pixels_tab;
VAR_3 = get_ue_golomb(&VAR_0->gb);
if (VAR_3 == 0) {
if (VAR_2->current_slice && VAR_0->cur_pic_ptr && FIELD_PICTURE(VAR_0)) {
ff_h264_field_end(VAR_0, VAR_1, 1);
}
VAR_2->current_slice = 0;
if (!VAR_2->first_field) {
if (VAR_0->cur_pic_ptr && !VAR_0->droppable) {
ff_thread_report_progress(&VAR_0->cur_pic_ptr->tf, INT_MAX,
VAR_0->picture_structure == PICT_BOTTOM_FIELD);
}
VAR_0->cur_pic_ptr = NULL;
}
}
VAR_6 = get_ue_golomb_31(&VAR_0->gb);
if (VAR_6 > 9) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"slice type %d too large at %d %d\n",
VAR_6, VAR_0->mb_x, VAR_0->mb_y);
return AVERROR_INVALIDDATA;
}
if (VAR_6 > 4) {
VAR_6 -= 5;
VAR_1->slice_type_fixed = 1;
} else
VAR_1->slice_type_fixed = 0;
VAR_6 = golomb_to_pict_type[VAR_6];
if (VAR_6 == AV_PICTURE_TYPE_I ||
(VAR_2->current_slice != 0 && VAR_6 == VAR_2->last_slice_type)) {
VAR_10 = 1;
}
VAR_1->VAR_6 = VAR_6;
VAR_1->slice_type_nos = VAR_6 & 3;
if (VAR_0->nal_unit_type == NAL_IDR_SLICE &&
VAR_1->slice_type_nos != AV_PICTURE_TYPE_I) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "A non-intra slice in an IDR NAL unit.\n");
return AVERROR_INVALIDDATA;
}
VAR_0->pict_type = VAR_1->VAR_6;
VAR_4 = get_ue_golomb(&VAR_0->gb);
if (VAR_4 >= MAX_PPS_COUNT) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "VAR_4 %u out of range\n", VAR_4);
return AVERROR_INVALIDDATA;
}
if (!VAR_2->pps_buffers[VAR_4]) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"non-existing PPS %u referenced\n",
VAR_4);
return AVERROR_INVALIDDATA;
}
VAR_0->pps = *VAR_2->pps_buffers[VAR_4];
if (!VAR_2->sps_buffers[VAR_0->pps.sps_id]) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"non-existing SPS %u referenced\n",
VAR_0->pps.sps_id);
return AVERROR_INVALIDDATA;
}
if (VAR_0->pps.sps_id != VAR_0->sps.sps_id ||
VAR_2->sps_buffers[VAR_0->pps.sps_id]->new) {
VAR_2->sps_buffers[VAR_0->pps.sps_id]->new = 0;
VAR_0->sps = *VAR_2->sps_buffers[VAR_0->pps.sps_id];
if (VAR_0->bit_depth_luma != VAR_0->sps.bit_depth_luma ||
VAR_0->chroma_format_idc != VAR_0->sps.chroma_format_idc) {
VAR_0->bit_depth_luma = VAR_0->sps.bit_depth_luma;
VAR_0->chroma_format_idc = VAR_0->sps.chroma_format_idc;
VAR_13 = 1;
}
if ((VAR_5 = ff_h264_set_parameter_from_sps(VAR_0)) < 0)
return VAR_5;
}
VAR_0->avctx->profile = ff_h264_get_profile(&VAR_0->sps);
VAR_0->avctx->level = VAR_0->sps.level_idc;
VAR_0->avctx->refs = VAR_0->sps.ref_frame_count;
if (VAR_0->mb_width != VAR_0->sps.mb_width ||
VAR_0->mb_height != VAR_0->sps.mb_height * (2 - VAR_0->sps.frame_mbs_only_flag))
VAR_13 = 1;
VAR_0->mb_width = VAR_0->sps.mb_width;
VAR_0->mb_height = VAR_0->sps.mb_height * (2 - VAR_0->sps.frame_mbs_only_flag);
VAR_0->mb_num = VAR_0->mb_width * VAR_0->mb_height;
VAR_0->mb_stride = VAR_0->mb_width + 1;
VAR_0->b_stride = VAR_0->mb_width * 4;
VAR_0->chroma_y_shift = VAR_0->sps.chroma_format_idc <= 1;
VAR_0->width = 16 * VAR_0->mb_width;
VAR_0->height = 16 * VAR_0->mb_height;
VAR_5 = init_dimensions(VAR_0);
if (VAR_5 < 0)
return VAR_5;
if (VAR_0->sps.video_signal_type_present_flag) {
VAR_0->avctx->color_range = VAR_0->sps.full_range ? AVCOL_RANGE_JPEG
: AVCOL_RANGE_MPEG;
if (VAR_0->sps.colour_description_present_flag) {
if (VAR_0->avctx->colorspace != VAR_0->sps.colorspace)
VAR_13 = 1;
VAR_0->avctx->color_primaries = VAR_0->sps.color_primaries;
VAR_0->avctx->color_trc = VAR_0->sps.color_trc;
VAR_0->avctx->colorspace = VAR_0->sps.colorspace;
}
}
if (VAR_0->context_initialized && VAR_13) {
if (VAR_0 != VAR_2) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"changing width %d -> %d / height %d -> %d on "
"slice %d\n",
VAR_0->width, VAR_0->avctx->coded_width,
VAR_0->height, VAR_0->avctx->coded_height,
VAR_2->current_slice + 1);
return AVERROR_INVALIDDATA;
}
ff_h264_flush_change(VAR_0);
if ((VAR_5 = get_pixel_format(VAR_0)) < 0)
return VAR_5;
VAR_0->avctx->pix_fmt = VAR_5;
av_log(VAR_0->avctx, AV_LOG_INFO, "Reinit context to %dx%d, "
"pix_fmt: %d\n", VAR_0->width, VAR_0->height, VAR_0->avctx->pix_fmt);
if ((VAR_5 = h264_slice_header_init(VAR_0, 1)) < 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"h264_slice_header_init() failed\n");
return VAR_5;
}
}
if (!VAR_0->context_initialized) {
if (VAR_0 != VAR_2) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Cannot (re-)initialize context during parallel decoding.\n");
return AVERROR_PATCHWELCOME;
}
if ((VAR_5 = get_pixel_format(VAR_0)) < 0)
return VAR_5;
VAR_0->avctx->pix_fmt = VAR_5;
if ((VAR_5 = h264_slice_header_init(VAR_0, 0)) < 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"h264_slice_header_init() failed\n");
return VAR_5;
}
}
if (VAR_0 == VAR_2 && VAR_0->dequant_coeff_pps != VAR_4) {
VAR_0->dequant_coeff_pps = VAR_4;
h264_init_dequant_tables(VAR_0);
}
VAR_0->frame_num = get_bits(&VAR_0->gb, VAR_0->sps.log2_max_frame_num);
VAR_0->mb_mbaff = 0;
VAR_0->mb_aff_frame = 0;
VAR_11 = VAR_2->picture_structure;
VAR_12 = VAR_2->droppable;
VAR_0->droppable = VAR_0->nal_ref_idc == 0;
if (VAR_0->sps.frame_mbs_only_flag) {
VAR_0->picture_structure = PICT_FRAME;
} else {
VAR_14 = get_bits1(&VAR_0->gb);
if (VAR_14) {
VAR_15 = get_bits1(&VAR_0->gb);
VAR_0->picture_structure = PICT_TOP_FIELD + VAR_15;
} else {
VAR_0->picture_structure = PICT_FRAME;
VAR_0->mb_aff_frame = VAR_0->sps.mb_aff;
}
}
VAR_0->mb_field_decoding_flag = VAR_0->picture_structure != PICT_FRAME;
if (VAR_2->current_slice != 0) {
if (VAR_11 != VAR_0->picture_structure ||
VAR_12 != VAR_0->droppable) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Changing field mode (%d -> %d) between slices is not allowed\n",
VAR_11, VAR_0->picture_structure);
VAR_0->picture_structure = VAR_11;
VAR_0->droppable = VAR_12;
return AVERROR_INVALIDDATA;
} else if (!VAR_2->cur_pic_ptr) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"unset cur_pic_ptr on slice %d\n",
VAR_2->current_slice + 1);
return AVERROR_INVALIDDATA;
}
} else {
if (VAR_0->frame_num != VAR_0->prev_frame_num) {
int VAR_16 = VAR_0->prev_frame_num;
int VAR_17 = 1 << VAR_0->sps.log2_max_frame_num;
if (VAR_16 > VAR_0->frame_num)
VAR_16 -= VAR_17;
if ((VAR_0->frame_num - VAR_16) > VAR_0->sps.ref_frame_count) {
VAR_16 = (VAR_0->frame_num - VAR_0->sps.ref_frame_count) - 1;
if (VAR_16 < 0)
VAR_16 += VAR_17;
VAR_0->prev_frame_num = VAR_16;
}
}
if (VAR_2->first_field) {
assert(VAR_2->cur_pic_ptr);
assert(VAR_2->cur_pic_ptr->f.buf[0]);
assert(VAR_2->cur_pic_ptr->reference != DELAYED_PIC_REF);
if (!FIELD_PICTURE(VAR_0) || VAR_0->picture_structure == VAR_11) {
if (!VAR_12 && VAR_11 != PICT_FRAME) {
ff_thread_report_progress(&VAR_2->cur_pic_ptr->tf, INT_MAX,
VAR_11 == PICT_TOP_FIELD);
}
} else {
if (VAR_2->cur_pic_ptr->frame_num != VAR_0->frame_num) {
if (!VAR_12 && VAR_11 != PICT_FRAME) {
ff_thread_report_progress(&VAR_2->cur_pic_ptr->tf, INT_MAX,
VAR_11 == PICT_TOP_FIELD);
}
} else {
if (!((VAR_11 == PICT_TOP_FIELD &&
VAR_0->picture_structure == PICT_BOTTOM_FIELD) ||
(VAR_11 == PICT_BOTTOM_FIELD &&
VAR_0->picture_structure == PICT_TOP_FIELD))) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Invalid field mode combination %d/%d\n",
VAR_11, VAR_0->picture_structure);
VAR_0->picture_structure = VAR_11;
VAR_0->droppable = VAR_12;
return AVERROR_INVALIDDATA;
} else if (VAR_12 != VAR_0->droppable) {
avpriv_request_sample(VAR_0->avctx,
"Found reference and non-reference fields in the same frame, which");
VAR_0->picture_structure = VAR_11;
VAR_0->droppable = VAR_12;
return AVERROR_PATCHWELCOME;
}
}
}
}
while (VAR_0->frame_num != VAR_0->prev_frame_num &&
VAR_0->frame_num != (VAR_0->prev_frame_num + 1) % (1 << VAR_0->sps.log2_max_frame_num)) {
H264Picture *prev = VAR_0->short_ref_count ? VAR_0->short_ref[0] : NULL;
av_log(VAR_0->avctx, AV_LOG_DEBUG, "Frame num gap %d %d\n",
VAR_0->frame_num, VAR_0->prev_frame_num);
VAR_5 = h264_frame_start(VAR_0);
if (VAR_5 < 0) {
VAR_2->first_field = 0;
return VAR_5;
}
VAR_0->prev_frame_num++;
VAR_0->prev_frame_num %= 1 << VAR_0->sps.log2_max_frame_num;
VAR_0->cur_pic_ptr->frame_num = VAR_0->prev_frame_num;
ff_thread_report_progress(&VAR_0->cur_pic_ptr->tf, INT_MAX, 0);
ff_thread_report_progress(&VAR_0->cur_pic_ptr->tf, INT_MAX, 1);
VAR_5 = ff_generate_sliding_window_mmcos(VAR_0, 1);
if (VAR_5 < 0 && (VAR_0->avctx->err_recognition & AV_EF_EXPLODE))
return VAR_5;
VAR_5 = ff_h264_execute_ref_pic_marking(VAR_0, VAR_0->mmco, VAR_0->mmco_index);
if (VAR_5 < 0 && (VAR_0->avctx->err_recognition & AV_EF_EXPLODE))
return VAR_5;
if (VAR_0->short_ref_count) {
if (prev) {
av_image_copy(VAR_0->short_ref[0]->f.data,
VAR_0->short_ref[0]->f.linesize,
(const uint8_t **)prev->f.data,
prev->f.linesize,
VAR_0->avctx->pix_fmt,
VAR_0->mb_width * 16,
VAR_0->mb_height * 16);
VAR_0->short_ref[0]->poc = prev->poc + 2;
}
VAR_0->short_ref[0]->frame_num = VAR_0->prev_frame_num;
}
}
if (VAR_2->first_field) {
assert(VAR_2->cur_pic_ptr);
assert(VAR_2->cur_pic_ptr->f.buf[0]);
assert(VAR_2->cur_pic_ptr->reference != DELAYED_PIC_REF);
if (!FIELD_PICTURE(VAR_0) || VAR_0->picture_structure == VAR_11) {
VAR_2->cur_pic_ptr = NULL;
VAR_2->first_field = FIELD_PICTURE(VAR_0);
} else {
if (VAR_2->cur_pic_ptr->frame_num != VAR_0->frame_num) {
VAR_2->first_field = 1;
VAR_2->cur_pic_ptr = NULL;
} else {
VAR_2->first_field = 0;
}
}
} else {
VAR_2->first_field = FIELD_PICTURE(VAR_0);
}
if (!FIELD_PICTURE(VAR_0) || VAR_2->first_field) {
if (h264_frame_start(VAR_0) < 0) {
VAR_2->first_field = 0;
return AVERROR_INVALIDDATA;
}
} else {
release_unused_pictures(VAR_0, 0);
}
}
if (VAR_0 != VAR_2 && (VAR_5 = clone_slice(VAR_0, VAR_2)) < 0)
return VAR_5;
VAR_0->cur_pic_ptr->frame_num = VAR_0->frame_num;
assert(VAR_0->mb_num == VAR_0->mb_width * VAR_0->mb_height);
if (VAR_3 << FIELD_OR_MBAFF_PICTURE(VAR_0) >= VAR_0->mb_num ||
VAR_3 >= VAR_0->mb_num) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "VAR_3 overflow\n");
return AVERROR_INVALIDDATA;
}
VAR_0->resync_mb_x = VAR_0->mb_x = VAR_3 % VAR_0->mb_width;
VAR_0->resync_mb_y = VAR_0->mb_y = (VAR_3 / VAR_0->mb_width) <<
FIELD_OR_MBAFF_PICTURE(VAR_0);
if (VAR_0->picture_structure == PICT_BOTTOM_FIELD)
VAR_0->resync_mb_y = VAR_0->mb_y = VAR_0->mb_y + 1;
assert(VAR_0->mb_y < VAR_0->mb_height);
if (VAR_0->picture_structure == PICT_FRAME) {
VAR_0->curr_pic_num = VAR_0->frame_num;
VAR_0->max_pic_num = 1 << VAR_0->sps.log2_max_frame_num;
} else {
VAR_0->curr_pic_num = 2 * VAR_0->frame_num + 1;
VAR_0->max_pic_num = 1 << (VAR_0->sps.log2_max_frame_num + 1);
}
if (VAR_0->nal_unit_type == NAL_IDR_SLICE)
get_ue_golomb(&VAR_0->gb);
if (VAR_0->sps.poc_type == 0) {
VAR_0->poc_lsb = get_bits(&VAR_0->gb, VAR_0->sps.log2_max_poc_lsb);
if (VAR_0->pps.pic_order_present == 1 && VAR_0->picture_structure == PICT_FRAME)
VAR_0->delta_poc_bottom = get_se_golomb(&VAR_0->gb);
}
if (VAR_0->sps.poc_type == 1 && !VAR_0->sps.delta_pic_order_always_zero_flag) {
VAR_0->delta_poc[0] = get_se_golomb(&VAR_0->gb);
if (VAR_0->pps.pic_order_present == 1 && VAR_0->picture_structure == PICT_FRAME)
VAR_0->delta_poc[1] = get_se_golomb(&VAR_0->gb);
}
ff_init_poc(VAR_0, VAR_0->cur_pic_ptr->field_poc, &VAR_0->cur_pic_ptr->poc);
if (VAR_0->pps.redundant_pic_cnt_present)
VAR_0->redundant_pic_count = get_ue_golomb(&VAR_0->gb);
VAR_5 = ff_set_ref_count(VAR_0, VAR_1);
if (VAR_5 < 0)
return VAR_5;
else if (VAR_5 == 1)
VAR_10 = 0;
if (!VAR_10)
ff_h264_fill_default_ref_list(VAR_0, VAR_1);
if (VAR_1->slice_type_nos != AV_PICTURE_TYPE_I) {
VAR_5 = ff_h264_decode_ref_pic_list_reordering(VAR_0, VAR_1);
if (VAR_5 < 0) {
VAR_1->ref_count[1] = VAR_1->ref_count[0] = 0;
return VAR_5;
}
}
if ((VAR_0->pps.weighted_pred && VAR_1->slice_type_nos == AV_PICTURE_TYPE_P) ||
(VAR_0->pps.weighted_bipred_idc == 1 &&
VAR_1->slice_type_nos == AV_PICTURE_TYPE_B))
ff_pred_weight_table(VAR_0, VAR_1);
else if (VAR_0->pps.weighted_bipred_idc == 2 &&
VAR_1->slice_type_nos == AV_PICTURE_TYPE_B) {
implicit_weight_table(VAR_0, VAR_1, -1);
} else {
VAR_1->use_weight = 0;
for (VAR_8 = 0; VAR_8 < 2; VAR_8++) {
VAR_1->luma_weight_flag[VAR_8] = 0;
VAR_1->chroma_weight_flag[VAR_8] = 0;
}
}
if (VAR_0->nal_ref_idc) {
VAR_5 = ff_h264_decode_ref_pic_marking(VAR_2, &VAR_0->gb,
!(VAR_0->avctx->active_thread_type & FF_THREAD_FRAME) ||
VAR_2->current_slice == 0);
if (VAR_5 < 0 && (VAR_0->avctx->err_recognition & AV_EF_EXPLODE))
return AVERROR_INVALIDDATA;
}
if (FRAME_MBAFF(VAR_0)) {
ff_h264_fill_mbaff_ref_list(VAR_0, VAR_1);
if (VAR_0->pps.weighted_bipred_idc == 2 && VAR_1->slice_type_nos == AV_PICTURE_TYPE_B) {
implicit_weight_table(VAR_0, VAR_1, 0);
implicit_weight_table(VAR_0, VAR_1, 1);
}
}
if (VAR_1->slice_type_nos == AV_PICTURE_TYPE_B && !VAR_1->direct_spatial_mv_pred)
ff_h264_direct_dist_scale_factor(VAR_0, VAR_1);
ff_h264_direct_ref_list_init(VAR_0, VAR_1);
if (VAR_1->slice_type_nos != AV_PICTURE_TYPE_I && VAR_0->pps.cabac) {
VAR_7 = get_ue_golomb_31(&VAR_0->gb);
if (VAR_7 > 2) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "cabac_init_idc %u overflow\n", VAR_7);
return AVERROR_INVALIDDATA;
}
VAR_0->cabac_init_idc = VAR_7;
}
VAR_1->last_qscale_diff = 0;
VAR_7 = VAR_0->pps.init_qp + get_se_golomb(&VAR_0->gb);
if (VAR_7 > 51 + 6 * (VAR_0->sps.bit_depth_luma - 8)) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "QP %u out of range\n", VAR_7);
return AVERROR_INVALIDDATA;
}
VAR_1->qscale = VAR_7;
VAR_1->chroma_qp[0] = get_chroma_qp(VAR_0, 0, VAR_1->qscale);
VAR_1->chroma_qp[1] = get_chroma_qp(VAR_0, 1, VAR_1->qscale);
if (VAR_1->VAR_6 == AV_PICTURE_TYPE_SP)
get_bits1(&VAR_0->gb);
if (VAR_1->VAR_6 == AV_PICTURE_TYPE_SP ||
VAR_1->VAR_6 == AV_PICTURE_TYPE_SI)
get_se_golomb(&VAR_0->gb);
VAR_0->deblocking_filter = 1;
VAR_0->slice_alpha_c0_offset = 0;
VAR_0->slice_beta_offset = 0;
if (VAR_0->pps.deblocking_filter_parameters_present) {
VAR_7 = get_ue_golomb_31(&VAR_0->gb);
if (VAR_7 > 2) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"deblocking_filter_idc %u out of range\n", VAR_7);
return AVERROR_INVALIDDATA;
}
VAR_0->deblocking_filter = VAR_7;
if (VAR_0->deblocking_filter < 2)
VAR_0->deblocking_filter ^= 1;
if (VAR_0->deblocking_filter) {
VAR_0->slice_alpha_c0_offset = get_se_golomb(&VAR_0->gb) * 2;
VAR_0->slice_beta_offset = get_se_golomb(&VAR_0->gb) * 2;
if (VAR_0->slice_alpha_c0_offset > 12 ||
VAR_0->slice_alpha_c0_offset < -12 ||
VAR_0->slice_beta_offset > 12 ||
VAR_0->slice_beta_offset < -12) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"deblocking filter parameters %d %d out of range\n",
VAR_0->slice_alpha_c0_offset, VAR_0->slice_beta_offset);
return AVERROR_INVALIDDATA;
}
}
}
if (VAR_0->avctx->skip_loop_filter >= AVDISCARD_ALL ||
(VAR_0->avctx->skip_loop_filter >= AVDISCARD_NONKEY &&
VAR_1->slice_type_nos != AV_PICTURE_TYPE_I) ||
(VAR_0->avctx->skip_loop_filter >= AVDISCARD_BIDIR &&
VAR_1->slice_type_nos == AV_PICTURE_TYPE_B) ||
(VAR_0->avctx->skip_loop_filter >= AVDISCARD_NONREF &&
VAR_0->nal_ref_idc == 0))
VAR_0->deblocking_filter = 0;
if (VAR_0->deblocking_filter == 1 && VAR_2->max_contexts > 1) {
if (VAR_0->avctx->flags2 & CODEC_FLAG2_FAST) {
VAR_0->deblocking_filter = 2;
} else {
VAR_2->max_contexts = 1;
if (!VAR_2->single_decode_warning) {
av_log(VAR_0->avctx, AV_LOG_INFO,
"Cannot parallelize deblocking type 1, decoding such frames in sequential order\n");
VAR_2->single_decode_warning = 1;
}
if (VAR_0 != VAR_2) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Deblocking switched inside frame.\n");
return 1;
}
}
}
VAR_1->qp_thresh = 15 -
FFMIN(VAR_0->slice_alpha_c0_offset, VAR_0->slice_beta_offset) -
FFMAX3(0,
VAR_0->pps.chroma_qp_index_offset[0],
VAR_0->pps.chroma_qp_index_offset[1]) +
6 * (VAR_0->sps.bit_depth_luma - 8);
VAR_2->last_slice_type = VAR_6;
VAR_1->slice_num = ++VAR_2->current_slice;
if (VAR_1->slice_num >= MAX_SLICES) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Too many slices, increase MAX_SLICES and recompile\n");
}
for (VAR_9 = 0; VAR_9 < 2; VAR_9++) {
int VAR_18[16];
int *VAR_19 = VAR_1->VAR_19[VAR_1->slice_num & (MAX_SLICES - 1)][VAR_9];
for (VAR_8 = 0; VAR_8 < 16; VAR_8++) {
VAR_18[VAR_8] = 60;
if (VAR_9 < VAR_1->list_count && VAR_8 < VAR_1->ref_count[VAR_9] &&
VAR_1->ref_list[VAR_9][VAR_8].f.buf[0]) {
int VAR_20;
AVBuffer *buf = VAR_1->ref_list[VAR_9][VAR_8].f.buf[0]->buffer;
for (VAR_20 = 0; VAR_20 < VAR_0->short_ref_count; VAR_20++)
if (VAR_0->short_ref[VAR_20]->f.buf[0]->buffer == buf) {
VAR_18[VAR_8] = VAR_20;
break;
}
for (VAR_20 = 0; VAR_20 < VAR_0->long_ref_count; VAR_20++)
if (VAR_0->long_ref[VAR_20] && VAR_0->long_ref[VAR_20]->f.buf[0]->buffer == buf) {
VAR_18[VAR_8] = VAR_0->short_ref_count + VAR_20;
break;
}
}
}
VAR_19[0] =
VAR_19[1] = -1;
for (VAR_8 = 0; VAR_8 < 16; VAR_8++)
VAR_19[VAR_8 + 2] = 4 * VAR_18[VAR_8] + (VAR_1->ref_list[VAR_9][VAR_8].reference & 3);
VAR_19[18 + 0] =
VAR_19[18 + 1] = -1;
for (VAR_8 = 16; VAR_8 < 48; VAR_8++)
VAR_19[VAR_8 + 4] = 4 * VAR_18[(VAR_8 - 16) >> 1] +
(VAR_1->ref_list[VAR_9][VAR_8].reference & 3);
}
if (VAR_0->avctx->debug & FF_DEBUG_PICT_INFO) {
av_log(VAR_0->avctx, AV_LOG_DEBUG,
"slice:%d %s mb:%d %c%s%s pps:%u frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d:%d:%d weight:%d%s %s\n",
VAR_1->slice_num,
(VAR_0->picture_structure == PICT_FRAME ? "F" : VAR_0->picture_structure == PICT_TOP_FIELD ? "T" : "B"),
VAR_3,
av_get_picture_type_char(VAR_1->VAR_6),
VAR_1->slice_type_fixed ? " fix" : "",
VAR_0->nal_unit_type == NAL_IDR_SLICE ? " IDR" : "",
VAR_4, VAR_0->frame_num,
VAR_0->cur_pic_ptr->field_poc[0],
VAR_0->cur_pic_ptr->field_poc[1],
VAR_1->ref_count[0], VAR_1->ref_count[1],
VAR_1->qscale,
VAR_0->deblocking_filter,
VAR_0->slice_alpha_c0_offset, VAR_0->slice_beta_offset,
VAR_1->use_weight,
VAR_1->use_weight == 1 && VAR_1->use_weight_chroma ? "c" : "",
VAR_1->VAR_6 == AV_PICTURE_TYPE_B ? (VAR_1->direct_spatial_mv_pred ? "SPAT" : "TEMP") : "");
}
return 0;
}
| [
"int FUNC_0(H264Context *VAR_0, H264SliceContext *VAR_1, H264Context *VAR_2)\n{",
"unsigned int VAR_3;",
"unsigned int VAR_4;",
"int VAR_5;",
"unsigned int VAR_6, VAR_7, VAR_8, VAR_9;",
"int VAR_10 = 0;",
"int VAR_11, VAR_12;",
"int VAR_13 = 0;",
"int VAR_14, VAR_15;",
"VAR_0->qpel_put = VAR_0->h264qpel.put_h264_qpel_pixels_tab;",
"VAR_0->qpel_avg = VAR_0->h264qpel.avg_h264_qpel_pixels_tab;",
"VAR_3 = get_ue_golomb(&VAR_0->gb);",
"if (VAR_3 == 0) {",
"if (VAR_2->current_slice && VAR_0->cur_pic_ptr && FIELD_PICTURE(VAR_0)) {",
"ff_h264_field_end(VAR_0, VAR_1, 1);",
"}",
"VAR_2->current_slice = 0;",
"if (!VAR_2->first_field) {",
"if (VAR_0->cur_pic_ptr && !VAR_0->droppable) {",
"ff_thread_report_progress(&VAR_0->cur_pic_ptr->tf, INT_MAX,\nVAR_0->picture_structure == PICT_BOTTOM_FIELD);",
"}",
"VAR_0->cur_pic_ptr = NULL;",
"}",
"}",
"VAR_6 = get_ue_golomb_31(&VAR_0->gb);",
"if (VAR_6 > 9) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"slice type %d too large at %d %d\\n\",\nVAR_6, VAR_0->mb_x, VAR_0->mb_y);",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_6 > 4) {",
"VAR_6 -= 5;",
"VAR_1->slice_type_fixed = 1;",
"} else",
"VAR_1->slice_type_fixed = 0;",
"VAR_6 = golomb_to_pict_type[VAR_6];",
"if (VAR_6 == AV_PICTURE_TYPE_I ||\n(VAR_2->current_slice != 0 && VAR_6 == VAR_2->last_slice_type)) {",
"VAR_10 = 1;",
"}",
"VAR_1->VAR_6 = VAR_6;",
"VAR_1->slice_type_nos = VAR_6 & 3;",
"if (VAR_0->nal_unit_type == NAL_IDR_SLICE &&\nVAR_1->slice_type_nos != AV_PICTURE_TYPE_I) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"A non-intra slice in an IDR NAL unit.\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_0->pict_type = VAR_1->VAR_6;",
"VAR_4 = get_ue_golomb(&VAR_0->gb);",
"if (VAR_4 >= MAX_PPS_COUNT) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"VAR_4 %u out of range\\n\", VAR_4);",
"return AVERROR_INVALIDDATA;",
"}",
"if (!VAR_2->pps_buffers[VAR_4]) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"non-existing PPS %u referenced\\n\",\nVAR_4);",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_0->pps = *VAR_2->pps_buffers[VAR_4];",
"if (!VAR_2->sps_buffers[VAR_0->pps.sps_id]) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"non-existing SPS %u referenced\\n\",\nVAR_0->pps.sps_id);",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_0->pps.sps_id != VAR_0->sps.sps_id ||\nVAR_2->sps_buffers[VAR_0->pps.sps_id]->new) {",
"VAR_2->sps_buffers[VAR_0->pps.sps_id]->new = 0;",
"VAR_0->sps = *VAR_2->sps_buffers[VAR_0->pps.sps_id];",
"if (VAR_0->bit_depth_luma != VAR_0->sps.bit_depth_luma ||\nVAR_0->chroma_format_idc != VAR_0->sps.chroma_format_idc) {",
"VAR_0->bit_depth_luma = VAR_0->sps.bit_depth_luma;",
"VAR_0->chroma_format_idc = VAR_0->sps.chroma_format_idc;",
"VAR_13 = 1;",
"}",
"if ((VAR_5 = ff_h264_set_parameter_from_sps(VAR_0)) < 0)\nreturn VAR_5;",
"}",
"VAR_0->avctx->profile = ff_h264_get_profile(&VAR_0->sps);",
"VAR_0->avctx->level = VAR_0->sps.level_idc;",
"VAR_0->avctx->refs = VAR_0->sps.ref_frame_count;",
"if (VAR_0->mb_width != VAR_0->sps.mb_width ||\nVAR_0->mb_height != VAR_0->sps.mb_height * (2 - VAR_0->sps.frame_mbs_only_flag))\nVAR_13 = 1;",
"VAR_0->mb_width = VAR_0->sps.mb_width;",
"VAR_0->mb_height = VAR_0->sps.mb_height * (2 - VAR_0->sps.frame_mbs_only_flag);",
"VAR_0->mb_num = VAR_0->mb_width * VAR_0->mb_height;",
"VAR_0->mb_stride = VAR_0->mb_width + 1;",
"VAR_0->b_stride = VAR_0->mb_width * 4;",
"VAR_0->chroma_y_shift = VAR_0->sps.chroma_format_idc <= 1;",
"VAR_0->width = 16 * VAR_0->mb_width;",
"VAR_0->height = 16 * VAR_0->mb_height;",
"VAR_5 = init_dimensions(VAR_0);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"if (VAR_0->sps.video_signal_type_present_flag) {",
"VAR_0->avctx->color_range = VAR_0->sps.full_range ? AVCOL_RANGE_JPEG\n: AVCOL_RANGE_MPEG;",
"if (VAR_0->sps.colour_description_present_flag) {",
"if (VAR_0->avctx->colorspace != VAR_0->sps.colorspace)\nVAR_13 = 1;",
"VAR_0->avctx->color_primaries = VAR_0->sps.color_primaries;",
"VAR_0->avctx->color_trc = VAR_0->sps.color_trc;",
"VAR_0->avctx->colorspace = VAR_0->sps.colorspace;",
"}",
"}",
"if (VAR_0->context_initialized && VAR_13) {",
"if (VAR_0 != VAR_2) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"changing width %d -> %d / height %d -> %d on \"\n\"slice %d\\n\",\nVAR_0->width, VAR_0->avctx->coded_width,\nVAR_0->height, VAR_0->avctx->coded_height,\nVAR_2->current_slice + 1);",
"return AVERROR_INVALIDDATA;",
"}",
"ff_h264_flush_change(VAR_0);",
"if ((VAR_5 = get_pixel_format(VAR_0)) < 0)\nreturn VAR_5;",
"VAR_0->avctx->pix_fmt = VAR_5;",
"av_log(VAR_0->avctx, AV_LOG_INFO, \"Reinit context to %dx%d, \"\n\"pix_fmt: %d\\n\", VAR_0->width, VAR_0->height, VAR_0->avctx->pix_fmt);",
"if ((VAR_5 = h264_slice_header_init(VAR_0, 1)) < 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"h264_slice_header_init() failed\\n\");",
"return VAR_5;",
"}",
"}",
"if (!VAR_0->context_initialized) {",
"if (VAR_0 != VAR_2) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Cannot (re-)initialize context during parallel decoding.\\n\");",
"return AVERROR_PATCHWELCOME;",
"}",
"if ((VAR_5 = get_pixel_format(VAR_0)) < 0)\nreturn VAR_5;",
"VAR_0->avctx->pix_fmt = VAR_5;",
"if ((VAR_5 = h264_slice_header_init(VAR_0, 0)) < 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"h264_slice_header_init() failed\\n\");",
"return VAR_5;",
"}",
"}",
"if (VAR_0 == VAR_2 && VAR_0->dequant_coeff_pps != VAR_4) {",
"VAR_0->dequant_coeff_pps = VAR_4;",
"h264_init_dequant_tables(VAR_0);",
"}",
"VAR_0->frame_num = get_bits(&VAR_0->gb, VAR_0->sps.log2_max_frame_num);",
"VAR_0->mb_mbaff = 0;",
"VAR_0->mb_aff_frame = 0;",
"VAR_11 = VAR_2->picture_structure;",
"VAR_12 = VAR_2->droppable;",
"VAR_0->droppable = VAR_0->nal_ref_idc == 0;",
"if (VAR_0->sps.frame_mbs_only_flag) {",
"VAR_0->picture_structure = PICT_FRAME;",
"} else {",
"VAR_14 = get_bits1(&VAR_0->gb);",
"if (VAR_14) {",
"VAR_15 = get_bits1(&VAR_0->gb);",
"VAR_0->picture_structure = PICT_TOP_FIELD + VAR_15;",
"} else {",
"VAR_0->picture_structure = PICT_FRAME;",
"VAR_0->mb_aff_frame = VAR_0->sps.mb_aff;",
"}",
"}",
"VAR_0->mb_field_decoding_flag = VAR_0->picture_structure != PICT_FRAME;",
"if (VAR_2->current_slice != 0) {",
"if (VAR_11 != VAR_0->picture_structure ||\nVAR_12 != VAR_0->droppable) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Changing field mode (%d -> %d) between slices is not allowed\\n\",\nVAR_11, VAR_0->picture_structure);",
"VAR_0->picture_structure = VAR_11;",
"VAR_0->droppable = VAR_12;",
"return AVERROR_INVALIDDATA;",
"} else if (!VAR_2->cur_pic_ptr) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"unset cur_pic_ptr on slice %d\\n\",\nVAR_2->current_slice + 1);",
"return AVERROR_INVALIDDATA;",
"}",
"} else {",
"if (VAR_0->frame_num != VAR_0->prev_frame_num) {",
"int VAR_16 = VAR_0->prev_frame_num;",
"int VAR_17 = 1 << VAR_0->sps.log2_max_frame_num;",
"if (VAR_16 > VAR_0->frame_num)\nVAR_16 -= VAR_17;",
"if ((VAR_0->frame_num - VAR_16) > VAR_0->sps.ref_frame_count) {",
"VAR_16 = (VAR_0->frame_num - VAR_0->sps.ref_frame_count) - 1;",
"if (VAR_16 < 0)\nVAR_16 += VAR_17;",
"VAR_0->prev_frame_num = VAR_16;",
"}",
"}",
"if (VAR_2->first_field) {",
"assert(VAR_2->cur_pic_ptr);",
"assert(VAR_2->cur_pic_ptr->f.buf[0]);",
"assert(VAR_2->cur_pic_ptr->reference != DELAYED_PIC_REF);",
"if (!FIELD_PICTURE(VAR_0) || VAR_0->picture_structure == VAR_11) {",
"if (!VAR_12 && VAR_11 != PICT_FRAME) {",
"ff_thread_report_progress(&VAR_2->cur_pic_ptr->tf, INT_MAX,\nVAR_11 == PICT_TOP_FIELD);",
"}",
"} else {",
"if (VAR_2->cur_pic_ptr->frame_num != VAR_0->frame_num) {",
"if (!VAR_12 && VAR_11 != PICT_FRAME) {",
"ff_thread_report_progress(&VAR_2->cur_pic_ptr->tf, INT_MAX,\nVAR_11 == PICT_TOP_FIELD);",
"}",
"} else {",
"if (!((VAR_11 == PICT_TOP_FIELD &&\nVAR_0->picture_structure == PICT_BOTTOM_FIELD) ||\n(VAR_11 == PICT_BOTTOM_FIELD &&\nVAR_0->picture_structure == PICT_TOP_FIELD))) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Invalid field mode combination %d/%d\\n\",\nVAR_11, VAR_0->picture_structure);",
"VAR_0->picture_structure = VAR_11;",
"VAR_0->droppable = VAR_12;",
"return AVERROR_INVALIDDATA;",
"} else if (VAR_12 != VAR_0->droppable) {",
"avpriv_request_sample(VAR_0->avctx,\n\"Found reference and non-reference fields in the same frame, which\");",
"VAR_0->picture_structure = VAR_11;",
"VAR_0->droppable = VAR_12;",
"return AVERROR_PATCHWELCOME;",
"}",
"}",
"}",
"}",
"while (VAR_0->frame_num != VAR_0->prev_frame_num &&\nVAR_0->frame_num != (VAR_0->prev_frame_num + 1) % (1 << VAR_0->sps.log2_max_frame_num)) {",
"H264Picture *prev = VAR_0->short_ref_count ? VAR_0->short_ref[0] : NULL;",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Frame num gap %d %d\\n\",\nVAR_0->frame_num, VAR_0->prev_frame_num);",
"VAR_5 = h264_frame_start(VAR_0);",
"if (VAR_5 < 0) {",
"VAR_2->first_field = 0;",
"return VAR_5;",
"}",
"VAR_0->prev_frame_num++;",
"VAR_0->prev_frame_num %= 1 << VAR_0->sps.log2_max_frame_num;",
"VAR_0->cur_pic_ptr->frame_num = VAR_0->prev_frame_num;",
"ff_thread_report_progress(&VAR_0->cur_pic_ptr->tf, INT_MAX, 0);",
"ff_thread_report_progress(&VAR_0->cur_pic_ptr->tf, INT_MAX, 1);",
"VAR_5 = ff_generate_sliding_window_mmcos(VAR_0, 1);",
"if (VAR_5 < 0 && (VAR_0->avctx->err_recognition & AV_EF_EXPLODE))\nreturn VAR_5;",
"VAR_5 = ff_h264_execute_ref_pic_marking(VAR_0, VAR_0->mmco, VAR_0->mmco_index);",
"if (VAR_5 < 0 && (VAR_0->avctx->err_recognition & AV_EF_EXPLODE))\nreturn VAR_5;",
"if (VAR_0->short_ref_count) {",
"if (prev) {",
"av_image_copy(VAR_0->short_ref[0]->f.data,\nVAR_0->short_ref[0]->f.linesize,\n(const uint8_t **)prev->f.data,\nprev->f.linesize,\nVAR_0->avctx->pix_fmt,\nVAR_0->mb_width * 16,\nVAR_0->mb_height * 16);",
"VAR_0->short_ref[0]->poc = prev->poc + 2;",
"}",
"VAR_0->short_ref[0]->frame_num = VAR_0->prev_frame_num;",
"}",
"}",
"if (VAR_2->first_field) {",
"assert(VAR_2->cur_pic_ptr);",
"assert(VAR_2->cur_pic_ptr->f.buf[0]);",
"assert(VAR_2->cur_pic_ptr->reference != DELAYED_PIC_REF);",
"if (!FIELD_PICTURE(VAR_0) || VAR_0->picture_structure == VAR_11) {",
"VAR_2->cur_pic_ptr = NULL;",
"VAR_2->first_field = FIELD_PICTURE(VAR_0);",
"} else {",
"if (VAR_2->cur_pic_ptr->frame_num != VAR_0->frame_num) {",
"VAR_2->first_field = 1;",
"VAR_2->cur_pic_ptr = NULL;",
"} else {",
"VAR_2->first_field = 0;",
"}",
"}",
"} else {",
"VAR_2->first_field = FIELD_PICTURE(VAR_0);",
"}",
"if (!FIELD_PICTURE(VAR_0) || VAR_2->first_field) {",
"if (h264_frame_start(VAR_0) < 0) {",
"VAR_2->first_field = 0;",
"return AVERROR_INVALIDDATA;",
"}",
"} else {",
"release_unused_pictures(VAR_0, 0);",
"}",
"}",
"if (VAR_0 != VAR_2 && (VAR_5 = clone_slice(VAR_0, VAR_2)) < 0)\nreturn VAR_5;",
"VAR_0->cur_pic_ptr->frame_num = VAR_0->frame_num;",
"assert(VAR_0->mb_num == VAR_0->mb_width * VAR_0->mb_height);",
"if (VAR_3 << FIELD_OR_MBAFF_PICTURE(VAR_0) >= VAR_0->mb_num ||\nVAR_3 >= VAR_0->mb_num) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"VAR_3 overflow\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_0->resync_mb_x = VAR_0->mb_x = VAR_3 % VAR_0->mb_width;",
"VAR_0->resync_mb_y = VAR_0->mb_y = (VAR_3 / VAR_0->mb_width) <<\nFIELD_OR_MBAFF_PICTURE(VAR_0);",
"if (VAR_0->picture_structure == PICT_BOTTOM_FIELD)\nVAR_0->resync_mb_y = VAR_0->mb_y = VAR_0->mb_y + 1;",
"assert(VAR_0->mb_y < VAR_0->mb_height);",
"if (VAR_0->picture_structure == PICT_FRAME) {",
"VAR_0->curr_pic_num = VAR_0->frame_num;",
"VAR_0->max_pic_num = 1 << VAR_0->sps.log2_max_frame_num;",
"} else {",
"VAR_0->curr_pic_num = 2 * VAR_0->frame_num + 1;",
"VAR_0->max_pic_num = 1 << (VAR_0->sps.log2_max_frame_num + 1);",
"}",
"if (VAR_0->nal_unit_type == NAL_IDR_SLICE)\nget_ue_golomb(&VAR_0->gb);",
"if (VAR_0->sps.poc_type == 0) {",
"VAR_0->poc_lsb = get_bits(&VAR_0->gb, VAR_0->sps.log2_max_poc_lsb);",
"if (VAR_0->pps.pic_order_present == 1 && VAR_0->picture_structure == PICT_FRAME)\nVAR_0->delta_poc_bottom = get_se_golomb(&VAR_0->gb);",
"}",
"if (VAR_0->sps.poc_type == 1 && !VAR_0->sps.delta_pic_order_always_zero_flag) {",
"VAR_0->delta_poc[0] = get_se_golomb(&VAR_0->gb);",
"if (VAR_0->pps.pic_order_present == 1 && VAR_0->picture_structure == PICT_FRAME)\nVAR_0->delta_poc[1] = get_se_golomb(&VAR_0->gb);",
"}",
"ff_init_poc(VAR_0, VAR_0->cur_pic_ptr->field_poc, &VAR_0->cur_pic_ptr->poc);",
"if (VAR_0->pps.redundant_pic_cnt_present)\nVAR_0->redundant_pic_count = get_ue_golomb(&VAR_0->gb);",
"VAR_5 = ff_set_ref_count(VAR_0, VAR_1);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"else if (VAR_5 == 1)\nVAR_10 = 0;",
"if (!VAR_10)\nff_h264_fill_default_ref_list(VAR_0, VAR_1);",
"if (VAR_1->slice_type_nos != AV_PICTURE_TYPE_I) {",
"VAR_5 = ff_h264_decode_ref_pic_list_reordering(VAR_0, VAR_1);",
"if (VAR_5 < 0) {",
"VAR_1->ref_count[1] = VAR_1->ref_count[0] = 0;",
"return VAR_5;",
"}",
"}",
"if ((VAR_0->pps.weighted_pred && VAR_1->slice_type_nos == AV_PICTURE_TYPE_P) ||\n(VAR_0->pps.weighted_bipred_idc == 1 &&\nVAR_1->slice_type_nos == AV_PICTURE_TYPE_B))\nff_pred_weight_table(VAR_0, VAR_1);",
"else if (VAR_0->pps.weighted_bipred_idc == 2 &&\nVAR_1->slice_type_nos == AV_PICTURE_TYPE_B) {",
"implicit_weight_table(VAR_0, VAR_1, -1);",
"} else {",
"VAR_1->use_weight = 0;",
"for (VAR_8 = 0; VAR_8 < 2; VAR_8++) {",
"VAR_1->luma_weight_flag[VAR_8] = 0;",
"VAR_1->chroma_weight_flag[VAR_8] = 0;",
"}",
"}",
"if (VAR_0->nal_ref_idc) {",
"VAR_5 = ff_h264_decode_ref_pic_marking(VAR_2, &VAR_0->gb,\n!(VAR_0->avctx->active_thread_type & FF_THREAD_FRAME) ||\nVAR_2->current_slice == 0);",
"if (VAR_5 < 0 && (VAR_0->avctx->err_recognition & AV_EF_EXPLODE))\nreturn AVERROR_INVALIDDATA;",
"}",
"if (FRAME_MBAFF(VAR_0)) {",
"ff_h264_fill_mbaff_ref_list(VAR_0, VAR_1);",
"if (VAR_0->pps.weighted_bipred_idc == 2 && VAR_1->slice_type_nos == AV_PICTURE_TYPE_B) {",
"implicit_weight_table(VAR_0, VAR_1, 0);",
"implicit_weight_table(VAR_0, VAR_1, 1);",
"}",
"}",
"if (VAR_1->slice_type_nos == AV_PICTURE_TYPE_B && !VAR_1->direct_spatial_mv_pred)\nff_h264_direct_dist_scale_factor(VAR_0, VAR_1);",
"ff_h264_direct_ref_list_init(VAR_0, VAR_1);",
"if (VAR_1->slice_type_nos != AV_PICTURE_TYPE_I && VAR_0->pps.cabac) {",
"VAR_7 = get_ue_golomb_31(&VAR_0->gb);",
"if (VAR_7 > 2) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"cabac_init_idc %u overflow\\n\", VAR_7);",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_0->cabac_init_idc = VAR_7;",
"}",
"VAR_1->last_qscale_diff = 0;",
"VAR_7 = VAR_0->pps.init_qp + get_se_golomb(&VAR_0->gb);",
"if (VAR_7 > 51 + 6 * (VAR_0->sps.bit_depth_luma - 8)) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"QP %u out of range\\n\", VAR_7);",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_1->qscale = VAR_7;",
"VAR_1->chroma_qp[0] = get_chroma_qp(VAR_0, 0, VAR_1->qscale);",
"VAR_1->chroma_qp[1] = get_chroma_qp(VAR_0, 1, VAR_1->qscale);",
"if (VAR_1->VAR_6 == AV_PICTURE_TYPE_SP)\nget_bits1(&VAR_0->gb);",
"if (VAR_1->VAR_6 == AV_PICTURE_TYPE_SP ||\nVAR_1->VAR_6 == AV_PICTURE_TYPE_SI)\nget_se_golomb(&VAR_0->gb);",
"VAR_0->deblocking_filter = 1;",
"VAR_0->slice_alpha_c0_offset = 0;",
"VAR_0->slice_beta_offset = 0;",
"if (VAR_0->pps.deblocking_filter_parameters_present) {",
"VAR_7 = get_ue_golomb_31(&VAR_0->gb);",
"if (VAR_7 > 2) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"deblocking_filter_idc %u out of range\\n\", VAR_7);",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_0->deblocking_filter = VAR_7;",
"if (VAR_0->deblocking_filter < 2)\nVAR_0->deblocking_filter ^= 1;",
"if (VAR_0->deblocking_filter) {",
"VAR_0->slice_alpha_c0_offset = get_se_golomb(&VAR_0->gb) * 2;",
"VAR_0->slice_beta_offset = get_se_golomb(&VAR_0->gb) * 2;",
"if (VAR_0->slice_alpha_c0_offset > 12 ||\nVAR_0->slice_alpha_c0_offset < -12 ||\nVAR_0->slice_beta_offset > 12 ||\nVAR_0->slice_beta_offset < -12) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"deblocking filter parameters %d %d out of range\\n\",\nVAR_0->slice_alpha_c0_offset, VAR_0->slice_beta_offset);",
"return AVERROR_INVALIDDATA;",
"}",
"}",
"}",
"if (VAR_0->avctx->skip_loop_filter >= AVDISCARD_ALL ||\n(VAR_0->avctx->skip_loop_filter >= AVDISCARD_NONKEY &&\nVAR_1->slice_type_nos != AV_PICTURE_TYPE_I) ||\n(VAR_0->avctx->skip_loop_filter >= AVDISCARD_BIDIR &&\nVAR_1->slice_type_nos == AV_PICTURE_TYPE_B) ||\n(VAR_0->avctx->skip_loop_filter >= AVDISCARD_NONREF &&\nVAR_0->nal_ref_idc == 0))\nVAR_0->deblocking_filter = 0;",
"if (VAR_0->deblocking_filter == 1 && VAR_2->max_contexts > 1) {",
"if (VAR_0->avctx->flags2 & CODEC_FLAG2_FAST) {",
"VAR_0->deblocking_filter = 2;",
"} else {",
"VAR_2->max_contexts = 1;",
"if (!VAR_2->single_decode_warning) {",
"av_log(VAR_0->avctx, AV_LOG_INFO,\n\"Cannot parallelize deblocking type 1, decoding such frames in sequential order\\n\");",
"VAR_2->single_decode_warning = 1;",
"}",
"if (VAR_0 != VAR_2) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Deblocking switched inside frame.\\n\");",
"return 1;",
"}",
"}",
"}",
"VAR_1->qp_thresh = 15 -\nFFMIN(VAR_0->slice_alpha_c0_offset, VAR_0->slice_beta_offset) -\nFFMAX3(0,\nVAR_0->pps.chroma_qp_index_offset[0],\nVAR_0->pps.chroma_qp_index_offset[1]) +\n6 * (VAR_0->sps.bit_depth_luma - 8);",
"VAR_2->last_slice_type = VAR_6;",
"VAR_1->slice_num = ++VAR_2->current_slice;",
"if (VAR_1->slice_num >= MAX_SLICES) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Too many slices, increase MAX_SLICES and recompile\\n\");",
"}",
"for (VAR_9 = 0; VAR_9 < 2; VAR_9++) {",
"int VAR_18[16];",
"int *VAR_19 = VAR_1->VAR_19[VAR_1->slice_num & (MAX_SLICES - 1)][VAR_9];",
"for (VAR_8 = 0; VAR_8 < 16; VAR_8++) {",
"VAR_18[VAR_8] = 60;",
"if (VAR_9 < VAR_1->list_count && VAR_8 < VAR_1->ref_count[VAR_9] &&\nVAR_1->ref_list[VAR_9][VAR_8].f.buf[0]) {",
"int VAR_20;",
"AVBuffer *buf = VAR_1->ref_list[VAR_9][VAR_8].f.buf[0]->buffer;",
"for (VAR_20 = 0; VAR_20 < VAR_0->short_ref_count; VAR_20++)",
"if (VAR_0->short_ref[VAR_20]->f.buf[0]->buffer == buf) {",
"VAR_18[VAR_8] = VAR_20;",
"break;",
"}",
"for (VAR_20 = 0; VAR_20 < VAR_0->long_ref_count; VAR_20++)",
"if (VAR_0->long_ref[VAR_20] && VAR_0->long_ref[VAR_20]->f.buf[0]->buffer == buf) {",
"VAR_18[VAR_8] = VAR_0->short_ref_count + VAR_20;",
"break;",
"}",
"}",
"}",
"VAR_19[0] =\nVAR_19[1] = -1;",
"for (VAR_8 = 0; VAR_8 < 16; VAR_8++)",
"VAR_19[VAR_8 + 2] = 4 * VAR_18[VAR_8] + (VAR_1->ref_list[VAR_9][VAR_8].reference & 3);",
"VAR_19[18 + 0] =\nVAR_19[18 + 1] = -1;",
"for (VAR_8 = 16; VAR_8 < 48; VAR_8++)",
"VAR_19[VAR_8 + 4] = 4 * VAR_18[(VAR_8 - 16) >> 1] +\n(VAR_1->ref_list[VAR_9][VAR_8].reference & 3);",
"}",
"if (VAR_0->avctx->debug & FF_DEBUG_PICT_INFO) {",
"av_log(VAR_0->avctx, AV_LOG_DEBUG,\n\"slice:%d %s mb:%d %c%s%s pps:%u frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d:%d:%d weight:%d%s %s\\n\",\nVAR_1->slice_num,\n(VAR_0->picture_structure == PICT_FRAME ? \"F\" : VAR_0->picture_structure == PICT_TOP_FIELD ? \"T\" : \"B\"),\nVAR_3,\nav_get_picture_type_char(VAR_1->VAR_6),\nVAR_1->slice_type_fixed ? \" fix\" : \"\",\nVAR_0->nal_unit_type == NAL_IDR_SLICE ? \" IDR\" : \"\",\nVAR_4, VAR_0->frame_num,\nVAR_0->cur_pic_ptr->field_poc[0],\nVAR_0->cur_pic_ptr->field_poc[1],\nVAR_1->ref_count[0], VAR_1->ref_count[1],\nVAR_1->qscale,\nVAR_0->deblocking_filter,\nVAR_0->slice_alpha_c0_offset, VAR_0->slice_beta_offset,\nVAR_1->use_weight,\nVAR_1->use_weight == 1 && VAR_1->use_weight_chroma ? \"c\" : \"\",\nVAR_1->VAR_6 == AV_PICTURE_TYPE_B ? (VAR_1->direct_spatial_mv_pred ? \"SPAT\" : \"TEMP\") : \"\");",
"}",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67,
69,
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91,
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105,
107
],
[
109
],
[
111
],
[
113
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135,
137,
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151,
153,
155
],
[
157
],
[
159
],
[
163,
165
],
[
167
],
[
171
],
[
175,
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187,
189
],
[
191
],
[
195
],
[
197
],
[
199
],
[
203,
205,
207
],
[
211
],
[
213
],
[
215
],
[
217
],
[
221
],
[
225
],
[
229
],
[
231
],
[
235
],
[
237,
239
],
[
243
],
[
245,
247
],
[
249
],
[
251,
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
267
],
[
269
],
[
271,
273,
275,
277,
279,
281
],
[
283
],
[
285
],
[
289
],
[
293,
295
],
[
297
],
[
301,
303
],
[
307
],
[
309,
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323,
325
],
[
327
],
[
329
],
[
333,
335
],
[
337
],
[
341
],
[
343,
345
],
[
347
],
[
349
],
[
351
],
[
355
],
[
357
],
[
359
],
[
361
],
[
365
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
407
],
[
409,
411
],
[
413,
415,
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427,
429,
431
],
[
433
],
[
435
],
[
437
],
[
443
],
[
445
],
[
447
],
[
451,
453
],
[
457
],
[
459
],
[
461,
463
],
[
467
],
[
469
],
[
471
],
[
485
],
[
487
],
[
489
],
[
491
],
[
497
],
[
503
],
[
505,
507
],
[
509
],
[
511
],
[
513
],
[
523
],
[
525,
527
],
[
529
],
[
531
],
[
535,
537,
539,
541
],
[
543,
545,
547
],
[
549
],
[
551
],
[
553
],
[
555
],
[
557,
559
],
[
561
],
[
563
],
[
565
],
[
567
],
[
569
],
[
571
],
[
573
],
[
577,
579
],
[
581
],
[
583,
585
],
[
587
],
[
589
],
[
591
],
[
593
],
[
595
],
[
599
],
[
601
],
[
603
],
[
605
],
[
607
],
[
609
],
[
611,
613
],
[
615
],
[
617,
619
],
[
635
],
[
637
],
[
639,
641,
643,
645,
647,
649,
651
],
[
653
],
[
655
],
[
657
],
[
659
],
[
661
],
[
671
],
[
673
],
[
675
],
[
677
],
[
683
],
[
689
],
[
691
],
[
693
],
[
695
],
[
703
],
[
705
],
[
707
],
[
711
],
[
713
],
[
715
],
[
717
],
[
721
],
[
723
],
[
727
],
[
729
],
[
731
],
[
733
],
[
735
],
[
737
],
[
739
],
[
741
],
[
743
],
[
745,
747
],
[
751
],
[
755
],
[
757,
759
],
[
761
],
[
763
],
[
765
],
[
767
],
[
769,
771
],
[
773,
775
],
[
777
],
[
781
],
[
783
],
[
785
],
[
787
],
[
789
],
[
791
],
[
793
],
[
797,
799
],
[
803
],
[
805
],
[
809,
811
],
[
813
],
[
817
],
[
819
],
[
823,
825
],
[
827
],
[
831
],
[
835,
837
],
[
841
],
[
843,
845
],
[
847,
849
],
[
853,
855
],
[
859
],
[
861
],
[
863
],
[
865
],
[
867
],
[
869
],
[
871
],
[
875,
877,
879,
881
],
[
883,
885
],
[
887
],
[
889
],
[
891
],
[
893
],
[
895
],
[
897
],
[
899
],
[
901
],
[
915
],
[
917,
919,
921
],
[
923,
925
],
[
927
],
[
931
],
[
933
],
[
937
],
[
939
],
[
941
],
[
943
],
[
945
],
[
949,
951
],
[
953
],
[
957
],
[
959
],
[
961
],
[
963
],
[
965
],
[
967
],
[
969
],
[
971
],
[
975
],
[
977
],
[
979
],
[
981
],
[
983
],
[
985
],
[
987
],
[
989
],
[
991
],
[
995,
997
],
[
999,
1001,
1003
],
[
1007
],
[
1009
],
[
1011
],
[
1013
],
[
1015
],
[
1017
],
[
1019,
1021
],
[
1023
],
[
1025
],
[
1027
],
[
1029,
1031
],
[
1035
],
[
1037
],
[
1039
],
[
1041,
1043,
1045,
1047
],
[
1049,
1051,
1053
],
[
1055
],
[
1057
],
[
1059
],
[
1061
],
[
1065,
1067,
1069,
1071,
1073,
1075,
1077,
1079
],
[
1083
],
[
1085
],
[
1091
],
[
1093
],
[
1095
],
[
1097
],
[
1099,
1101
],
[
1103
],
[
1105
],
[
1107
],
[
1109,
1111
],
[
1113
],
[
1115
],
[
1117
],
[
1119
],
[
1121,
1123,
1125,
1127,
1129,
1131
],
[
1135
],
[
1137
],
[
1139
],
[
1141,
1143
],
[
1145
],
[
1149
],
[
1151
],
[
1153
],
[
1155
],
[
1157
],
[
1159,
1161
],
[
1163
],
[
1165
],
[
1167
],
[
1169
],
[
1171
],
[
1173
],
[
1175
],
[
1177
],
[
1179
],
[
1181
],
[
1183
],
[
1185
],
[
1187
],
[
1189
],
[
1193,
1195
],
[
1197
],
[
1199
],
[
1201,
1203
],
[
1205
],
[
1207,
1209
],
[
1211
],
[
1215
],
[
1217,
1219,
1221,
1223,
1225,
1227,
1229,
1231,
1233,
1235,
1237,
1239,
1241,
1243,
1245,
1247,
1249,
1251
],
[
1253
],
[
1257
],
[
1259
]
] |
25,939 | Object *qio_task_get_source(QIOTask *task)
{
object_ref(task->source);
return task->source;
}
| true | qemu | 937470bb5470825e781ae50e92ff973a6b54d80f | Object *qio_task_get_source(QIOTask *task)
{
object_ref(task->source);
return task->source;
}
| {
"code": [
" object_ref(task->source);"
],
"line_no": [
5
]
} | Object *FUNC_0(QIOTask *task)
{
object_ref(task->source);
return task->source;
}
| [
"Object *FUNC_0(QIOTask *task)\n{",
"object_ref(task->source);",
"return task->source;",
"}"
] | [
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
25,940 | static void gen_ldx(DisasContext *dc, uint32_t code, uint32_t flags)
{
I_TYPE(instr, code);
TCGv addr = tcg_temp_new();
TCGv data;
/*
* WARNING: Loads into R_ZERO are ignored, but we must generate the
* memory access itself to emulate the CPU precisely. Load
* from a protected page to R_ZERO will cause SIGSEGV on
* the Nios2 CPU.
*/
if (likely(instr.b != R_ZERO)) {
data = dc->cpu_R[instr.b];
} else {
data = tcg_temp_new();
}
tcg_gen_addi_tl(addr, load_gpr(dc, instr.a), instr.imm16s);
tcg_gen_qemu_ld_tl(data, addr, dc->mem_idx, flags);
if (unlikely(instr.b == R_ZERO)) {
tcg_temp_free(data);
}
tcg_temp_free(addr);
}
| true | qemu | 4ae4b609ee2d5bcc9df6c03c21dc1fed527aada1 | static void gen_ldx(DisasContext *dc, uint32_t code, uint32_t flags)
{
I_TYPE(instr, code);
TCGv addr = tcg_temp_new();
TCGv data;
if (likely(instr.b != R_ZERO)) {
data = dc->cpu_R[instr.b];
} else {
data = tcg_temp_new();
}
tcg_gen_addi_tl(addr, load_gpr(dc, instr.a), instr.imm16s);
tcg_gen_qemu_ld_tl(data, addr, dc->mem_idx, flags);
if (unlikely(instr.b == R_ZERO)) {
tcg_temp_free(data);
}
tcg_temp_free(addr);
}
| {
"code": [
" tcg_gen_addi_tl(addr, load_gpr(dc, instr.a), instr.imm16s);",
" tcg_gen_addi_tl(addr, load_gpr(dc, instr.a), instr.imm16s);"
],
"line_no": [
39,
39
]
} | static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1, uint32_t VAR_2)
{
I_TYPE(instr, VAR_1);
TCGv addr = tcg_temp_new();
TCGv data;
if (likely(instr.b != R_ZERO)) {
data = VAR_0->cpu_R[instr.b];
} else {
data = tcg_temp_new();
}
tcg_gen_addi_tl(addr, load_gpr(VAR_0, instr.a), instr.imm16s);
tcg_gen_qemu_ld_tl(data, addr, VAR_0->mem_idx, VAR_2);
if (unlikely(instr.b == R_ZERO)) {
tcg_temp_free(data);
}
tcg_temp_free(addr);
}
| [
"static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1, uint32_t VAR_2)\n{",
"I_TYPE(instr, VAR_1);",
"TCGv addr = tcg_temp_new();",
"TCGv data;",
"if (likely(instr.b != R_ZERO)) {",
"data = VAR_0->cpu_R[instr.b];",
"} else {",
"data = tcg_temp_new();",
"}",
"tcg_gen_addi_tl(addr, load_gpr(VAR_0, instr.a), instr.imm16s);",
"tcg_gen_qemu_ld_tl(data, addr, VAR_0->mem_idx, VAR_2);",
"if (unlikely(instr.b == R_ZERO)) {",
"tcg_temp_free(data);",
"}",
"tcg_temp_free(addr);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
]
] |
25,941 | static int64_t mpegts_get_dts(AVFormatContext *s, int stream_index,
int64_t *ppos, int64_t pos_limit)
{
MpegTSContext *ts = s->priv_data;
int64_t pos;
int pos47 = ts->pos47_full % ts->raw_packet_size;
pos = ((*ppos + ts->raw_packet_size - 1 - pos47) / ts->raw_packet_size) * ts->raw_packet_size + pos47;
ff_read_frame_flush(s);
if (avio_seek(s->pb, pos, SEEK_SET) < 0)
return AV_NOPTS_VALUE;
while(pos < pos_limit) {
int ret;
AVPacket pkt;
av_init_packet(&pkt);
ret= av_read_frame(s, &pkt);
if(ret < 0)
return AV_NOPTS_VALUE;
av_free_packet(&pkt);
if(pkt.dts != AV_NOPTS_VALUE && pkt.pos >= 0){
ff_reduce_index(s, pkt.stream_index);
av_add_index_entry(s->streams[pkt.stream_index], pkt.pos, pkt.dts, 0, 0, AVINDEX_KEYFRAME /* FIXME keyframe? */);
if(pkt.stream_index == stream_index){
*ppos= pkt.pos;
return pkt.dts;
}
}
pos = pkt.pos;
}
return AV_NOPTS_VALUE;
}
| false | FFmpeg | a66099192159d02b1a1c1820ddb24c7cea271a44 | static int64_t mpegts_get_dts(AVFormatContext *s, int stream_index,
int64_t *ppos, int64_t pos_limit)
{
MpegTSContext *ts = s->priv_data;
int64_t pos;
int pos47 = ts->pos47_full % ts->raw_packet_size;
pos = ((*ppos + ts->raw_packet_size - 1 - pos47) / ts->raw_packet_size) * ts->raw_packet_size + pos47;
ff_read_frame_flush(s);
if (avio_seek(s->pb, pos, SEEK_SET) < 0)
return AV_NOPTS_VALUE;
while(pos < pos_limit) {
int ret;
AVPacket pkt;
av_init_packet(&pkt);
ret= av_read_frame(s, &pkt);
if(ret < 0)
return AV_NOPTS_VALUE;
av_free_packet(&pkt);
if(pkt.dts != AV_NOPTS_VALUE && pkt.pos >= 0){
ff_reduce_index(s, pkt.stream_index);
av_add_index_entry(s->streams[pkt.stream_index], pkt.pos, pkt.dts, 0, 0, AVINDEX_KEYFRAME );
if(pkt.stream_index == stream_index){
*ppos= pkt.pos;
return pkt.dts;
}
}
pos = pkt.pos;
}
return AV_NOPTS_VALUE;
}
| {
"code": [],
"line_no": []
} | static int64_t FUNC_0(AVFormatContext *s, int stream_index,
int64_t *ppos, int64_t pos_limit)
{
MpegTSContext *ts = s->priv_data;
int64_t pos;
int VAR_0 = ts->pos47_full % ts->raw_packet_size;
pos = ((*ppos + ts->raw_packet_size - 1 - VAR_0) / ts->raw_packet_size) * ts->raw_packet_size + VAR_0;
ff_read_frame_flush(s);
if (avio_seek(s->pb, pos, SEEK_SET) < 0)
return AV_NOPTS_VALUE;
while(pos < pos_limit) {
int VAR_1;
AVPacket pkt;
av_init_packet(&pkt);
VAR_1= av_read_frame(s, &pkt);
if(VAR_1 < 0)
return AV_NOPTS_VALUE;
av_free_packet(&pkt);
if(pkt.dts != AV_NOPTS_VALUE && pkt.pos >= 0){
ff_reduce_index(s, pkt.stream_index);
av_add_index_entry(s->streams[pkt.stream_index], pkt.pos, pkt.dts, 0, 0, AVINDEX_KEYFRAME );
if(pkt.stream_index == stream_index){
*ppos= pkt.pos;
return pkt.dts;
}
}
pos = pkt.pos;
}
return AV_NOPTS_VALUE;
}
| [
"static int64_t FUNC_0(AVFormatContext *s, int stream_index,\nint64_t *ppos, int64_t pos_limit)\n{",
"MpegTSContext *ts = s->priv_data;",
"int64_t pos;",
"int VAR_0 = ts->pos47_full % ts->raw_packet_size;",
"pos = ((*ppos + ts->raw_packet_size - 1 - VAR_0) / ts->raw_packet_size) * ts->raw_packet_size + VAR_0;",
"ff_read_frame_flush(s);",
"if (avio_seek(s->pb, pos, SEEK_SET) < 0)\nreturn AV_NOPTS_VALUE;",
"while(pos < pos_limit) {",
"int VAR_1;",
"AVPacket pkt;",
"av_init_packet(&pkt);",
"VAR_1= av_read_frame(s, &pkt);",
"if(VAR_1 < 0)\nreturn AV_NOPTS_VALUE;",
"av_free_packet(&pkt);",
"if(pkt.dts != AV_NOPTS_VALUE && pkt.pos >= 0){",
"ff_reduce_index(s, pkt.stream_index);",
"av_add_index_entry(s->streams[pkt.stream_index], pkt.pos, pkt.dts, 0, 0, AVINDEX_KEYFRAME );",
"if(pkt.stream_index == stream_index){",
"*ppos= pkt.pos;",
"return pkt.dts;",
"}",
"}",
"pos = pkt.pos;",
"}",
"return AV_NOPTS_VALUE;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
59
],
[
61
]
] |
25,942 | static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset,
uint64_t *host_offset, uint64_t *bytes, QCowL2Meta **m)
{
BDRVQcowState *s = bs->opaque;
int l2_index;
uint64_t *l2_table;
uint64_t entry;
unsigned int nb_clusters;
int ret;
uint64_t alloc_cluster_offset;
trace_qcow2_handle_alloc(qemu_coroutine_self(), guest_offset, *host_offset,
*bytes);
assert(*bytes > 0);
/*
* Calculate the number of clusters to look for. We stop at L2 table
* boundaries to keep things simple.
*/
nb_clusters =
size_to_clusters(s, offset_into_cluster(s, guest_offset) + *bytes);
l2_index = offset_to_l2_index(s, guest_offset);
nb_clusters = MIN(nb_clusters, s->l2_size - l2_index);
/* Find L2 entry for the first involved cluster */
ret = get_cluster_table(bs, guest_offset, &l2_table, &l2_index);
if (ret < 0) {
return ret;
entry = be64_to_cpu(l2_table[l2_index]);
/* For the moment, overwrite compressed clusters one by one */
if (entry & QCOW_OFLAG_COMPRESSED) {
nb_clusters = 1;
} else {
nb_clusters = count_cow_clusters(s, nb_clusters, l2_table, l2_index);
/* This function is only called when there were no non-COW clusters, so if
* we can't find any unallocated or COW clusters either, something is
* wrong with our code. */
assert(nb_clusters > 0);
ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
if (ret < 0) {
return ret;
/* Allocate, if necessary at a given offset in the image file */
alloc_cluster_offset = start_of_cluster(s, *host_offset);
ret = do_alloc_cluster_offset(bs, guest_offset, &alloc_cluster_offset,
&nb_clusters);
if (ret < 0) {
/* Can't extend contiguous allocation */
if (nb_clusters == 0) {
*bytes = 0;
return 0;
/*
* Save info needed for meta data update.
*
* requested_sectors: Number of sectors from the start of the first
* newly allocated cluster to the end of the (possibly shortened
* before) write request.
*
* avail_sectors: Number of sectors from the start of the first
* newly allocated to the end of the last newly allocated cluster.
*
* nb_sectors: The number of sectors from the start of the first
* newly allocated cluster to the end of the area that the write
* request actually writes to (excluding COW at the end)
*/
int requested_sectors =
(*bytes + offset_into_cluster(s, guest_offset))
>> BDRV_SECTOR_BITS;
int avail_sectors = nb_clusters
<< (s->cluster_bits - BDRV_SECTOR_BITS);
int alloc_n_start = offset_into_cluster(s, guest_offset)
>> BDRV_SECTOR_BITS;
int nb_sectors = MIN(requested_sectors, avail_sectors);
QCowL2Meta *old_m = *m;
*m = g_malloc0(sizeof(**m));
**m = (QCowL2Meta) {
.next = old_m,
.alloc_offset = alloc_cluster_offset,
.offset = start_of_cluster(s, guest_offset),
.nb_clusters = nb_clusters,
.nb_available = nb_sectors,
.cow_start = {
.offset = 0,
.nb_sectors = alloc_n_start,
},
.cow_end = {
.offset = nb_sectors * BDRV_SECTOR_SIZE,
.nb_sectors = avail_sectors - nb_sectors,
},
};
qemu_co_queue_init(&(*m)->dependent_requests);
QLIST_INSERT_HEAD(&s->cluster_allocs, *m, next_in_flight);
*host_offset = alloc_cluster_offset + offset_into_cluster(s, guest_offset);
*bytes = MIN(*bytes, (nb_sectors * BDRV_SECTOR_SIZE)
- offset_into_cluster(s, guest_offset));
assert(*bytes != 0);
return 1;
fail:
if (*m && (*m)->nb_clusters > 0) {
QLIST_REMOVE(*m, next_in_flight);
return ret; | true | qemu | ff52aab2df5c5e10f231481961b88d25a3021724 | static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset,
uint64_t *host_offset, uint64_t *bytes, QCowL2Meta **m)
{
BDRVQcowState *s = bs->opaque;
int l2_index;
uint64_t *l2_table;
uint64_t entry;
unsigned int nb_clusters;
int ret;
uint64_t alloc_cluster_offset;
trace_qcow2_handle_alloc(qemu_coroutine_self(), guest_offset, *host_offset,
*bytes);
assert(*bytes > 0);
nb_clusters =
size_to_clusters(s, offset_into_cluster(s, guest_offset) + *bytes);
l2_index = offset_to_l2_index(s, guest_offset);
nb_clusters = MIN(nb_clusters, s->l2_size - l2_index);
ret = get_cluster_table(bs, guest_offset, &l2_table, &l2_index);
if (ret < 0) {
return ret;
entry = be64_to_cpu(l2_table[l2_index]);
if (entry & QCOW_OFLAG_COMPRESSED) {
nb_clusters = 1;
} else {
nb_clusters = count_cow_clusters(s, nb_clusters, l2_table, l2_index);
assert(nb_clusters > 0);
ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
if (ret < 0) {
return ret;
alloc_cluster_offset = start_of_cluster(s, *host_offset);
ret = do_alloc_cluster_offset(bs, guest_offset, &alloc_cluster_offset,
&nb_clusters);
if (ret < 0) {
if (nb_clusters == 0) {
*bytes = 0;
return 0;
int requested_sectors =
(*bytes + offset_into_cluster(s, guest_offset))
>> BDRV_SECTOR_BITS;
int avail_sectors = nb_clusters
<< (s->cluster_bits - BDRV_SECTOR_BITS);
int alloc_n_start = offset_into_cluster(s, guest_offset)
>> BDRV_SECTOR_BITS;
int nb_sectors = MIN(requested_sectors, avail_sectors);
QCowL2Meta *old_m = *m;
*m = g_malloc0(sizeof(**m));
**m = (QCowL2Meta) {
.next = old_m,
.alloc_offset = alloc_cluster_offset,
.offset = start_of_cluster(s, guest_offset),
.nb_clusters = nb_clusters,
.nb_available = nb_sectors,
.cow_start = {
.offset = 0,
.nb_sectors = alloc_n_start,
},
.cow_end = {
.offset = nb_sectors * BDRV_SECTOR_SIZE,
.nb_sectors = avail_sectors - nb_sectors,
},
};
qemu_co_queue_init(&(*m)->dependent_requests);
QLIST_INSERT_HEAD(&s->cluster_allocs, *m, next_in_flight);
*host_offset = alloc_cluster_offset + offset_into_cluster(s, guest_offset);
*bytes = MIN(*bytes, (nb_sectors * BDRV_SECTOR_SIZE)
- offset_into_cluster(s, guest_offset));
assert(*bytes != 0);
return 1;
fail:
if (*m && (*m)->nb_clusters > 0) {
QLIST_REMOVE(*m, next_in_flight);
return ret; | {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,
uint64_t *VAR_2, uint64_t *VAR_3, QCowL2Meta **VAR_4)
{
BDRVQcowState *s = VAR_0->opaque;
int VAR_5;
uint64_t *l2_table;
uint64_t entry;
unsigned int VAR_6;
int VAR_7;
uint64_t alloc_cluster_offset;
trace_qcow2_handle_alloc(qemu_coroutine_self(), VAR_1, *VAR_2,
*VAR_3);
assert(*VAR_3 > 0);
VAR_6 =
size_to_clusters(s, offset_into_cluster(s, VAR_1) + *VAR_3);
VAR_5 = offset_to_l2_index(s, VAR_1);
VAR_6 = MIN(VAR_6, s->l2_size - VAR_5);
VAR_7 = get_cluster_table(VAR_0, VAR_1, &l2_table, &VAR_5);
if (VAR_7 < 0) {
return VAR_7;
entry = be64_to_cpu(l2_table[VAR_5]);
if (entry & QCOW_OFLAG_COMPRESSED) {
VAR_6 = 1;
} else {
VAR_6 = count_cow_clusters(s, VAR_6, l2_table, VAR_5);
assert(VAR_6 > 0);
VAR_7 = qcow2_cache_put(VAR_0, s->l2_table_cache, (void**) &l2_table);
if (VAR_7 < 0) {
return VAR_7;
alloc_cluster_offset = start_of_cluster(s, *VAR_2);
VAR_7 = do_alloc_cluster_offset(VAR_0, VAR_1, &alloc_cluster_offset,
&VAR_6);
if (VAR_7 < 0) {
if (VAR_6 == 0) {
*VAR_3 = 0;
return 0;
int VAR_8 =
(*VAR_3 + offset_into_cluster(s, VAR_1))
>> BDRV_SECTOR_BITS;
int VAR_9 = VAR_6
<< (s->cluster_bits - BDRV_SECTOR_BITS);
int VAR_10 = offset_into_cluster(s, VAR_1)
>> BDRV_SECTOR_BITS;
int VAR_11 = MIN(VAR_8, VAR_9);
QCowL2Meta *old_m = *VAR_4;
*VAR_4 = g_malloc0(sizeof(**VAR_4));
**VAR_4 = (QCowL2Meta) {
.next = old_m,
.alloc_offset = alloc_cluster_offset,
.offset = start_of_cluster(s, VAR_1),
.VAR_6 = VAR_6,
.nb_available = VAR_11,
.cow_start = {
.offset = 0,
.VAR_11 = VAR_10,
},
.cow_end = {
.offset = VAR_11 * BDRV_SECTOR_SIZE,
.VAR_11 = VAR_9 - VAR_11,
},
};
qemu_co_queue_init(&(*VAR_4)->dependent_requests);
QLIST_INSERT_HEAD(&s->cluster_allocs, *VAR_4, next_in_flight);
*VAR_2 = alloc_cluster_offset + offset_into_cluster(s, VAR_1);
*VAR_3 = MIN(*VAR_3, (VAR_11 * BDRV_SECTOR_SIZE)
- offset_into_cluster(s, VAR_1));
assert(*VAR_3 != 0);
return 1;
fail:
if (*VAR_4 && (*VAR_4)->VAR_6 > 0) {
QLIST_REMOVE(*VAR_4, next_in_flight);
return VAR_7; | [
"static int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,\nuint64_t *VAR_2, uint64_t *VAR_3, QCowL2Meta **VAR_4)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"int VAR_5;",
"uint64_t *l2_table;",
"uint64_t entry;",
"unsigned int VAR_6;",
"int VAR_7;",
"uint64_t alloc_cluster_offset;",
"trace_qcow2_handle_alloc(qemu_coroutine_self(), VAR_1, *VAR_2,\n*VAR_3);",
"assert(*VAR_3 > 0);",
"VAR_6 =\nsize_to_clusters(s, offset_into_cluster(s, VAR_1) + *VAR_3);",
"VAR_5 = offset_to_l2_index(s, VAR_1);",
"VAR_6 = MIN(VAR_6, s->l2_size - VAR_5);",
"VAR_7 = get_cluster_table(VAR_0, VAR_1, &l2_table, &VAR_5);",
"if (VAR_7 < 0) {",
"return VAR_7;",
"entry = be64_to_cpu(l2_table[VAR_5]);",
"if (entry & QCOW_OFLAG_COMPRESSED) {",
"VAR_6 = 1;",
"} else {",
"VAR_6 = count_cow_clusters(s, VAR_6, l2_table, VAR_5);",
"assert(VAR_6 > 0);",
"VAR_7 = qcow2_cache_put(VAR_0, s->l2_table_cache, (void**) &l2_table);",
"if (VAR_7 < 0) {",
"return VAR_7;",
"alloc_cluster_offset = start_of_cluster(s, *VAR_2);",
"VAR_7 = do_alloc_cluster_offset(VAR_0, VAR_1, &alloc_cluster_offset,\n&VAR_6);",
"if (VAR_7 < 0) {",
"if (VAR_6 == 0) {",
"*VAR_3 = 0;",
"return 0;",
"int VAR_8 =\n(*VAR_3 + offset_into_cluster(s, VAR_1))\n>> BDRV_SECTOR_BITS;",
"int VAR_9 = VAR_6\n<< (s->cluster_bits - BDRV_SECTOR_BITS);",
"int VAR_10 = offset_into_cluster(s, VAR_1)\n>> BDRV_SECTOR_BITS;",
"int VAR_11 = MIN(VAR_8, VAR_9);",
"QCowL2Meta *old_m = *VAR_4;",
"*VAR_4 = g_malloc0(sizeof(**VAR_4));",
"**VAR_4 = (QCowL2Meta) {",
".next = old_m,\n.alloc_offset = alloc_cluster_offset,\n.offset = start_of_cluster(s, VAR_1),\n.VAR_6 = VAR_6,\n.nb_available = VAR_11,\n.cow_start = {",
".offset = 0,\n.VAR_11 = VAR_10,\n},",
".cow_end = {",
".offset = VAR_11 * BDRV_SECTOR_SIZE,\n.VAR_11 = VAR_9 - VAR_11,\n},",
"};",
"qemu_co_queue_init(&(*VAR_4)->dependent_requests);",
"QLIST_INSERT_HEAD(&s->cluster_allocs, *VAR_4, next_in_flight);",
"*VAR_2 = alloc_cluster_offset + offset_into_cluster(s, VAR_1);",
"*VAR_3 = MIN(*VAR_3, (VAR_11 * BDRV_SECTOR_SIZE)\n- offset_into_cluster(s, VAR_1));",
"assert(*VAR_3 != 0);",
"return 1;",
"fail:\nif (*VAR_4 && (*VAR_4)->VAR_6 > 0) {",
"QLIST_REMOVE(*VAR_4, next_in_flight);",
"return VAR_7;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2,
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11,
12
],
[
13
],
[
18,
19
],
[
20
],
[
21
],
[
23
],
[
24
],
[
25
],
[
26
],
[
28
],
[
29
],
[
30
],
[
31
],
[
35
],
[
36
],
[
37
],
[
38
],
[
40
],
[
41,
42
],
[
43
],
[
45
],
[
46
],
[
47
],
[
62,
63,
64
],
[
65,
66
],
[
67,
68
],
[
69
],
[
70
],
[
71
],
[
72
],
[
73,
74,
75,
76,
77,
78
],
[
79,
80,
81
],
[
82
],
[
83,
84,
85
],
[
86
],
[
87
],
[
88
],
[
89
],
[
90,
91
],
[
92
],
[
93
],
[
94,
95
],
[
96
],
[
97
]
] |
25,943 | static int rv10_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
UINT8 *buf, int buf_size)
{
MpegEncContext *s = avctx->priv_data;
int i, mb_count, mb_pos, left;
DCTELEM block[6][64];
AVPicture *pict = data;
#ifdef DEBUG
printf("*****frame %d size=%d\n", avctx->frame_number, buf_size);
#endif
/* no supplementary picture */
if (buf_size == 0) {
*data_size = 0;
return 0;
}
init_get_bits(&s->gb, buf, buf_size);
mb_count = rv10_decode_picture_header(s);
if (mb_count < 0) {
#ifdef DEBUG
printf("HEADER ERROR\n");
#endif
return -1;
}
if (s->mb_x >= s->mb_width ||
s->mb_y >= s->mb_height) {
#ifdef DEBUG
printf("POS ERROR %d %d\n", s->mb_x, s->mb_y);
#endif
return -1;
}
mb_pos = s->mb_y * s->mb_width + s->mb_x;
left = s->mb_width * s->mb_height - mb_pos;
if (mb_count > left) {
#ifdef DEBUG
printf("COUNT ERROR\n");
#endif
return -1;
}
if (s->mb_x == 0 && s->mb_y == 0) {
MPV_frame_start(s, avctx);
}
#ifdef DEBUG
printf("qscale=%d\n", s->qscale);
#endif
/* default quantization values */
s->y_dc_scale = 8;
s->c_dc_scale = 8;
s->rv10_first_dc_coded[0] = 0;
s->rv10_first_dc_coded[1] = 0;
s->rv10_first_dc_coded[2] = 0;
s->block_wrap[0]=
s->block_wrap[1]=
s->block_wrap[2]=
s->block_wrap[3]= s->mb_width*2 + 2;
s->block_wrap[4]=
s->block_wrap[5]= s->mb_width + 2;
s->block_index[0]= s->block_wrap[0]*(s->mb_y*2 + 1) - 1 + s->mb_x*2;
s->block_index[1]= s->block_wrap[0]*(s->mb_y*2 + 1) + s->mb_x*2;
s->block_index[2]= s->block_wrap[0]*(s->mb_y*2 + 2) - 1 + s->mb_x*2;
s->block_index[3]= s->block_wrap[0]*(s->mb_y*2 + 2) + s->mb_x*2;
s->block_index[4]= s->block_wrap[4]*(s->mb_y + 1) + s->block_wrap[0]*(s->mb_height*2 + 2) + s->mb_x;
s->block_index[5]= s->block_wrap[4]*(s->mb_y + 1 + s->mb_height + 2) + s->block_wrap[0]*(s->mb_height*2 + 2) + s->mb_x;
/* decode each macroblock */
for(i=0;i<mb_count;i++) {
s->block_index[0]+=2;
s->block_index[1]+=2;
s->block_index[2]+=2;
s->block_index[3]+=2;
s->block_index[4]++;
s->block_index[5]++;
#ifdef DEBUG
printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y);
#endif
memset(block, 0, sizeof(block));
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
if (h263_decode_mb(s, block) < 0) {
#ifdef DEBUG
printf("ERROR\n");
#endif
return -1;
}
MPV_decode_mb(s, block);
if (++s->mb_x == s->mb_width) {
s->mb_x = 0;
s->mb_y++;
s->block_index[0]= s->block_wrap[0]*(s->mb_y*2 + 1) - 1;
s->block_index[1]= s->block_wrap[0]*(s->mb_y*2 + 1);
s->block_index[2]= s->block_wrap[0]*(s->mb_y*2 + 2) - 1;
s->block_index[3]= s->block_wrap[0]*(s->mb_y*2 + 2);
s->block_index[4]= s->block_wrap[4]*(s->mb_y + 1) + s->block_wrap[0]*(s->mb_height*2 + 2);
s->block_index[5]= s->block_wrap[4]*(s->mb_y + 1 + s->mb_height + 2) + s->block_wrap[0]*(s->mb_height*2 + 2);
}
}
if (s->mb_x == 0 &&
s->mb_y == s->mb_height) {
MPV_frame_end(s);
pict->data[0] = s->current_picture[0];
pict->data[1] = s->current_picture[1];
pict->data[2] = s->current_picture[2];
pict->linesize[0] = s->linesize;
pict->linesize[1] = s->uvlinesize;
pict->linesize[2] = s->uvlinesize;
avctx->quality = s->qscale;
*data_size = sizeof(AVPicture);
} else {
*data_size = 0;
}
return buf_size;
}
| true | FFmpeg | 68bd11f5de271a1a674f196a9e8ca2e7fe40ab6e | static int rv10_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
UINT8 *buf, int buf_size)
{
MpegEncContext *s = avctx->priv_data;
int i, mb_count, mb_pos, left;
DCTELEM block[6][64];
AVPicture *pict = data;
#ifdef DEBUG
printf("*****frame %d size=%d\n", avctx->frame_number, buf_size);
#endif
if (buf_size == 0) {
*data_size = 0;
return 0;
}
init_get_bits(&s->gb, buf, buf_size);
mb_count = rv10_decode_picture_header(s);
if (mb_count < 0) {
#ifdef DEBUG
printf("HEADER ERROR\n");
#endif
return -1;
}
if (s->mb_x >= s->mb_width ||
s->mb_y >= s->mb_height) {
#ifdef DEBUG
printf("POS ERROR %d %d\n", s->mb_x, s->mb_y);
#endif
return -1;
}
mb_pos = s->mb_y * s->mb_width + s->mb_x;
left = s->mb_width * s->mb_height - mb_pos;
if (mb_count > left) {
#ifdef DEBUG
printf("COUNT ERROR\n");
#endif
return -1;
}
if (s->mb_x == 0 && s->mb_y == 0) {
MPV_frame_start(s, avctx);
}
#ifdef DEBUG
printf("qscale=%d\n", s->qscale);
#endif
s->y_dc_scale = 8;
s->c_dc_scale = 8;
s->rv10_first_dc_coded[0] = 0;
s->rv10_first_dc_coded[1] = 0;
s->rv10_first_dc_coded[2] = 0;
s->block_wrap[0]=
s->block_wrap[1]=
s->block_wrap[2]=
s->block_wrap[3]= s->mb_width*2 + 2;
s->block_wrap[4]=
s->block_wrap[5]= s->mb_width + 2;
s->block_index[0]= s->block_wrap[0]*(s->mb_y*2 + 1) - 1 + s->mb_x*2;
s->block_index[1]= s->block_wrap[0]*(s->mb_y*2 + 1) + s->mb_x*2;
s->block_index[2]= s->block_wrap[0]*(s->mb_y*2 + 2) - 1 + s->mb_x*2;
s->block_index[3]= s->block_wrap[0]*(s->mb_y*2 + 2) + s->mb_x*2;
s->block_index[4]= s->block_wrap[4]*(s->mb_y + 1) + s->block_wrap[0]*(s->mb_height*2 + 2) + s->mb_x;
s->block_index[5]= s->block_wrap[4]*(s->mb_y + 1 + s->mb_height + 2) + s->block_wrap[0]*(s->mb_height*2 + 2) + s->mb_x;
for(i=0;i<mb_count;i++) {
s->block_index[0]+=2;
s->block_index[1]+=2;
s->block_index[2]+=2;
s->block_index[3]+=2;
s->block_index[4]++;
s->block_index[5]++;
#ifdef DEBUG
printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y);
#endif
memset(block, 0, sizeof(block));
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
if (h263_decode_mb(s, block) < 0) {
#ifdef DEBUG
printf("ERROR\n");
#endif
return -1;
}
MPV_decode_mb(s, block);
if (++s->mb_x == s->mb_width) {
s->mb_x = 0;
s->mb_y++;
s->block_index[0]= s->block_wrap[0]*(s->mb_y*2 + 1) - 1;
s->block_index[1]= s->block_wrap[0]*(s->mb_y*2 + 1);
s->block_index[2]= s->block_wrap[0]*(s->mb_y*2 + 2) - 1;
s->block_index[3]= s->block_wrap[0]*(s->mb_y*2 + 2);
s->block_index[4]= s->block_wrap[4]*(s->mb_y + 1) + s->block_wrap[0]*(s->mb_height*2 + 2);
s->block_index[5]= s->block_wrap[4]*(s->mb_y + 1 + s->mb_height + 2) + s->block_wrap[0]*(s->mb_height*2 + 2);
}
}
if (s->mb_x == 0 &&
s->mb_y == s->mb_height) {
MPV_frame_end(s);
pict->data[0] = s->current_picture[0];
pict->data[1] = s->current_picture[1];
pict->data[2] = s->current_picture[2];
pict->linesize[0] = s->linesize;
pict->linesize[1] = s->uvlinesize;
pict->linesize[2] = s->uvlinesize;
avctx->quality = s->qscale;
*data_size = sizeof(AVPicture);
} else {
*data_size = 0;
}
return buf_size;
}
| {
"code": [
"#ifdef DEBUG",
" printf(\"HEADER ERROR\\n\");",
"#endif",
"#ifdef DEBUG",
" printf(\"POS ERROR %d %d\\n\", s->mb_x, s->mb_y);",
"#endif",
"#ifdef DEBUG",
" printf(\"COUNT ERROR\\n\");",
"#endif",
"#ifdef DEBUG",
" printf(\"ERROR\\n\");",
"#endif"
],
"line_no": [
19,
49,
23,
19,
65,
23,
19,
81,
23,
19,
179,
23
]
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
UINT8 *VAR_3, int VAR_4)
{
MpegEncContext *s = VAR_0->priv_data;
int VAR_5, VAR_6, VAR_7, VAR_8;
DCTELEM block[6][64];
AVPicture *pict = VAR_1;
#ifdef DEBUG
printf("*****frame %d size=%d\n", VAR_0->frame_number, VAR_4);
#endif
if (VAR_4 == 0) {
*VAR_2 = 0;
return 0;
}
init_get_bits(&s->gb, VAR_3, VAR_4);
VAR_6 = rv10_decode_picture_header(s);
if (VAR_6 < 0) {
#ifdef DEBUG
printf("HEADER ERROR\n");
#endif
return -1;
}
if (s->mb_x >= s->mb_width ||
s->mb_y >= s->mb_height) {
#ifdef DEBUG
printf("POS ERROR %d %d\n", s->mb_x, s->mb_y);
#endif
return -1;
}
VAR_7 = s->mb_y * s->mb_width + s->mb_x;
VAR_8 = s->mb_width * s->mb_height - VAR_7;
if (VAR_6 > VAR_8) {
#ifdef DEBUG
printf("COUNT ERROR\n");
#endif
return -1;
}
if (s->mb_x == 0 && s->mb_y == 0) {
MPV_frame_start(s, VAR_0);
}
#ifdef DEBUG
printf("qscale=%d\n", s->qscale);
#endif
s->y_dc_scale = 8;
s->c_dc_scale = 8;
s->rv10_first_dc_coded[0] = 0;
s->rv10_first_dc_coded[1] = 0;
s->rv10_first_dc_coded[2] = 0;
s->block_wrap[0]=
s->block_wrap[1]=
s->block_wrap[2]=
s->block_wrap[3]= s->mb_width*2 + 2;
s->block_wrap[4]=
s->block_wrap[5]= s->mb_width + 2;
s->block_index[0]= s->block_wrap[0]*(s->mb_y*2 + 1) - 1 + s->mb_x*2;
s->block_index[1]= s->block_wrap[0]*(s->mb_y*2 + 1) + s->mb_x*2;
s->block_index[2]= s->block_wrap[0]*(s->mb_y*2 + 2) - 1 + s->mb_x*2;
s->block_index[3]= s->block_wrap[0]*(s->mb_y*2 + 2) + s->mb_x*2;
s->block_index[4]= s->block_wrap[4]*(s->mb_y + 1) + s->block_wrap[0]*(s->mb_height*2 + 2) + s->mb_x;
s->block_index[5]= s->block_wrap[4]*(s->mb_y + 1 + s->mb_height + 2) + s->block_wrap[0]*(s->mb_height*2 + 2) + s->mb_x;
for(VAR_5=0;VAR_5<VAR_6;VAR_5++) {
s->block_index[0]+=2;
s->block_index[1]+=2;
s->block_index[2]+=2;
s->block_index[3]+=2;
s->block_index[4]++;
s->block_index[5]++;
#ifdef DEBUG
printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y);
#endif
memset(block, 0, sizeof(block));
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
if (h263_decode_mb(s, block) < 0) {
#ifdef DEBUG
printf("ERROR\n");
#endif
return -1;
}
MPV_decode_mb(s, block);
if (++s->mb_x == s->mb_width) {
s->mb_x = 0;
s->mb_y++;
s->block_index[0]= s->block_wrap[0]*(s->mb_y*2 + 1) - 1;
s->block_index[1]= s->block_wrap[0]*(s->mb_y*2 + 1);
s->block_index[2]= s->block_wrap[0]*(s->mb_y*2 + 2) - 1;
s->block_index[3]= s->block_wrap[0]*(s->mb_y*2 + 2);
s->block_index[4]= s->block_wrap[4]*(s->mb_y + 1) + s->block_wrap[0]*(s->mb_height*2 + 2);
s->block_index[5]= s->block_wrap[4]*(s->mb_y + 1 + s->mb_height + 2) + s->block_wrap[0]*(s->mb_height*2 + 2);
}
}
if (s->mb_x == 0 &&
s->mb_y == s->mb_height) {
MPV_frame_end(s);
pict->VAR_1[0] = s->current_picture[0];
pict->VAR_1[1] = s->current_picture[1];
pict->VAR_1[2] = s->current_picture[2];
pict->linesize[0] = s->linesize;
pict->linesize[1] = s->uvlinesize;
pict->linesize[2] = s->uvlinesize;
VAR_0->quality = s->qscale;
*VAR_2 = sizeof(AVPicture);
} else {
*VAR_2 = 0;
}
return VAR_4;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nUINT8 *VAR_3, int VAR_4)\n{",
"MpegEncContext *s = VAR_0->priv_data;",
"int VAR_5, VAR_6, VAR_7, VAR_8;",
"DCTELEM block[6][64];",
"AVPicture *pict = VAR_1;",
"#ifdef DEBUG\nprintf(\"*****frame %d size=%d\\n\", VAR_0->frame_number, VAR_4);",
"#endif\nif (VAR_4 == 0) {",
"*VAR_2 = 0;",
"return 0;",
"}",
"init_get_bits(&s->gb, VAR_3, VAR_4);",
"VAR_6 = rv10_decode_picture_header(s);",
"if (VAR_6 < 0) {",
"#ifdef DEBUG\nprintf(\"HEADER ERROR\\n\");",
"#endif\nreturn -1;",
"}",
"if (s->mb_x >= s->mb_width ||\ns->mb_y >= s->mb_height) {",
"#ifdef DEBUG\nprintf(\"POS ERROR %d %d\\n\", s->mb_x, s->mb_y);",
"#endif\nreturn -1;",
"}",
"VAR_7 = s->mb_y * s->mb_width + s->mb_x;",
"VAR_8 = s->mb_width * s->mb_height - VAR_7;",
"if (VAR_6 > VAR_8) {",
"#ifdef DEBUG\nprintf(\"COUNT ERROR\\n\");",
"#endif\nreturn -1;",
"}",
"if (s->mb_x == 0 && s->mb_y == 0) {",
"MPV_frame_start(s, VAR_0);",
"}",
"#ifdef DEBUG\nprintf(\"qscale=%d\\n\", s->qscale);",
"#endif\ns->y_dc_scale = 8;",
"s->c_dc_scale = 8;",
"s->rv10_first_dc_coded[0] = 0;",
"s->rv10_first_dc_coded[1] = 0;",
"s->rv10_first_dc_coded[2] = 0;",
"s->block_wrap[0]=\ns->block_wrap[1]=\ns->block_wrap[2]=\ns->block_wrap[3]= s->mb_width*2 + 2;",
"s->block_wrap[4]=\ns->block_wrap[5]= s->mb_width + 2;",
"s->block_index[0]= s->block_wrap[0]*(s->mb_y*2 + 1) - 1 + s->mb_x*2;",
"s->block_index[1]= s->block_wrap[0]*(s->mb_y*2 + 1) + s->mb_x*2;",
"s->block_index[2]= s->block_wrap[0]*(s->mb_y*2 + 2) - 1 + s->mb_x*2;",
"s->block_index[3]= s->block_wrap[0]*(s->mb_y*2 + 2) + s->mb_x*2;",
"s->block_index[4]= s->block_wrap[4]*(s->mb_y + 1) + s->block_wrap[0]*(s->mb_height*2 + 2) + s->mb_x;",
"s->block_index[5]= s->block_wrap[4]*(s->mb_y + 1 + s->mb_height + 2) + s->block_wrap[0]*(s->mb_height*2 + 2) + s->mb_x;",
"for(VAR_5=0;VAR_5<VAR_6;VAR_5++) {",
"s->block_index[0]+=2;",
"s->block_index[1]+=2;",
"s->block_index[2]+=2;",
"s->block_index[3]+=2;",
"s->block_index[4]++;",
"s->block_index[5]++;",
"#ifdef DEBUG\nprintf(\"**mb x=%d y=%d\\n\", s->mb_x, s->mb_y);",
"#endif\nmemset(block, 0, sizeof(block));",
"s->mv_dir = MV_DIR_FORWARD;",
"s->mv_type = MV_TYPE_16X16;",
"if (h263_decode_mb(s, block) < 0) {",
"#ifdef DEBUG\nprintf(\"ERROR\\n\");",
"#endif\nreturn -1;",
"}",
"MPV_decode_mb(s, block);",
"if (++s->mb_x == s->mb_width) {",
"s->mb_x = 0;",
"s->mb_y++;",
"s->block_index[0]= s->block_wrap[0]*(s->mb_y*2 + 1) - 1;",
"s->block_index[1]= s->block_wrap[0]*(s->mb_y*2 + 1);",
"s->block_index[2]= s->block_wrap[0]*(s->mb_y*2 + 2) - 1;",
"s->block_index[3]= s->block_wrap[0]*(s->mb_y*2 + 2);",
"s->block_index[4]= s->block_wrap[4]*(s->mb_y + 1) + s->block_wrap[0]*(s->mb_height*2 + 2);",
"s->block_index[5]= s->block_wrap[4]*(s->mb_y + 1 + s->mb_height + 2) + s->block_wrap[0]*(s->mb_height*2 + 2);",
"}",
"}",
"if (s->mb_x == 0 &&\ns->mb_y == s->mb_height) {",
"MPV_frame_end(s);",
"pict->VAR_1[0] = s->current_picture[0];",
"pict->VAR_1[1] = s->current_picture[1];",
"pict->VAR_1[2] = s->current_picture[2];",
"pict->linesize[0] = s->linesize;",
"pict->linesize[1] = s->uvlinesize;",
"pict->linesize[2] = s->uvlinesize;",
"VAR_0->quality = s->qscale;",
"*VAR_2 = sizeof(AVPicture);",
"} else {",
"*VAR_2 = 0;",
"}",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
1,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
21
],
[
23,
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
43
],
[
45
],
[
47,
49
],
[
51,
53
],
[
55
],
[
59,
61
],
[
63,
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79,
81
],
[
83,
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
99,
101
],
[
103,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121,
123,
125,
127
],
[
129,
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161,
163
],
[
165,
169
],
[
171
],
[
173
],
[
175
],
[
177,
179
],
[
181,
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
213,
215
],
[
217
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
]
] |
25,945 | static int http_open(URLContext *h, const char *uri, int flags)
{
HTTPContext *s = h->priv_data;
h->is_streamed = 1;
s->filesize = -1;
av_strlcpy(s->location, uri, sizeof(s->location));
if (s->headers) {
int len = strlen(s->headers);
if (len < 2 || strcmp("\r\n", s->headers + len - 2))
av_log(h, AV_LOG_WARNING, "No trailing CRLF found in HTTP header.\n");
}
return http_open_cnx(h);
}
| false | FFmpeg | dd1e6b2a139a9eea61aefe24fc3295499e70d04b | static int http_open(URLContext *h, const char *uri, int flags)
{
HTTPContext *s = h->priv_data;
h->is_streamed = 1;
s->filesize = -1;
av_strlcpy(s->location, uri, sizeof(s->location));
if (s->headers) {
int len = strlen(s->headers);
if (len < 2 || strcmp("\r\n", s->headers + len - 2))
av_log(h, AV_LOG_WARNING, "No trailing CRLF found in HTTP header.\n");
}
return http_open_cnx(h);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(URLContext *VAR_0, const char *VAR_1, int VAR_2)
{
HTTPContext *s = VAR_0->priv_data;
VAR_0->is_streamed = 1;
s->filesize = -1;
av_strlcpy(s->location, VAR_1, sizeof(s->location));
if (s->headers) {
int VAR_3 = strlen(s->headers);
if (VAR_3 < 2 || strcmp("\r\n", s->headers + VAR_3 - 2))
av_log(VAR_0, AV_LOG_WARNING, "No trailing CRLF found in HTTP header.\n");
}
return http_open_cnx(VAR_0);
}
| [
"static int FUNC_0(URLContext *VAR_0, const char *VAR_1, int VAR_2)\n{",
"HTTPContext *s = VAR_0->priv_data;",
"VAR_0->is_streamed = 1;",
"s->filesize = -1;",
"av_strlcpy(s->location, VAR_1, sizeof(s->location));",
"if (s->headers) {",
"int VAR_3 = strlen(s->headers);",
"if (VAR_3 < 2 || strcmp(\"\\r\\n\", s->headers + VAR_3 - 2))\nav_log(VAR_0, AV_LOG_WARNING, \"No trailing CRLF found in HTTP header.\\n\");",
"}",
"return http_open_cnx(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
31
],
[
33
]
] |
25,946 | static inline void softusb_read_pmem(MilkymistSoftUsbState *s,
uint32_t offset, uint8_t *buf, uint32_t len)
{
if (offset + len >= s->pmem_size) {
error_report("milkymist_softusb: read pmem out of bounds "
"at offset 0x%x, len %d", offset, len);
return;
}
memcpy(buf, s->pmem_ptr + offset, len);
} | true | qemu | c31bc98e3bcf52fe1cd4b9b7a70869330eae80ea | static inline void softusb_read_pmem(MilkymistSoftUsbState *s,
uint32_t offset, uint8_t *buf, uint32_t len)
{
if (offset + len >= s->pmem_size) {
error_report("milkymist_softusb: read pmem out of bounds "
"at offset 0x%x, len %d", offset, len);
return;
}
memcpy(buf, s->pmem_ptr + offset, len);
} | {
"code": [],
"line_no": []
} | static inline void FUNC_0(MilkymistSoftUsbState *VAR_0,
uint32_t VAR_1, uint8_t *VAR_2, uint32_t VAR_3)
{
if (VAR_1 + VAR_3 >= VAR_0->pmem_size) {
error_report("milkymist_softusb: read pmem out of bounds "
"at VAR_1 0x%x, VAR_3 %d", VAR_1, VAR_3);
return;
}
memcpy(VAR_2, VAR_0->pmem_ptr + VAR_1, VAR_3);
} | [
"static inline void FUNC_0(MilkymistSoftUsbState *VAR_0,\nuint32_t VAR_1, uint8_t *VAR_2, uint32_t VAR_3)\n{",
"if (VAR_1 + VAR_3 >= VAR_0->pmem_size) {",
"error_report(\"milkymist_softusb: read pmem out of bounds \"\n\"at VAR_1 0x%x, VAR_3 %d\", VAR_1, VAR_3);",
"return;",
"}",
"memcpy(VAR_2, VAR_0->pmem_ptr + VAR_1, VAR_3);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9,
11
],
[
14
],
[
16
],
[
20
],
[
22
]
] |
25,949 | int attribute_align_arg sws_scale(struct SwsContext *c,
const uint8_t * const srcSlice[],
const int srcStride[], int srcSliceY,
int srcSliceH, uint8_t *const dst[],
const int dstStride[])
{
int i, ret;
const uint8_t *src2[4] = { srcSlice[0], srcSlice[1], srcSlice[2], srcSlice[3] };
uint8_t *dst2[4] = { dst[0], dst[1], dst[2], dst[3] };
uint8_t *rgb0_tmp = NULL;
// do not mess up sliceDir if we have a "trailing" 0-size slice
if (srcSliceH == 0)
return 0;
if (!check_image_pointers(srcSlice, c->srcFormat, srcStride)) {
av_log(c, AV_LOG_ERROR, "bad src image pointers\n");
return 0;
}
if (!check_image_pointers((const uint8_t* const*)dst, c->dstFormat, dstStride)) {
av_log(c, AV_LOG_ERROR, "bad dst image pointers\n");
return 0;
}
if (c->sliceDir == 0 && srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) {
av_log(c, AV_LOG_ERROR, "Slices start in the middle!\n");
return 0;
}
if (c->sliceDir == 0) {
if (srcSliceY == 0) c->sliceDir = 1; else c->sliceDir = -1;
}
if (usePal(c->srcFormat)) {
for (i = 0; i < 256; i++) {
int p, r, g, b, y, u, v, a = 0xff;
if (c->srcFormat == AV_PIX_FMT_PAL8) {
p = ((const uint32_t *)(srcSlice[1]))[i];
a = (p >> 24) & 0xFF;
r = (p >> 16) & 0xFF;
g = (p >> 8) & 0xFF;
b = p & 0xFF;
} else if (c->srcFormat == AV_PIX_FMT_RGB8) {
r = ( i >> 5 ) * 36;
g = ((i >> 2) & 7) * 36;
b = ( i & 3) * 85;
} else if (c->srcFormat == AV_PIX_FMT_BGR8) {
b = ( i >> 6 ) * 85;
g = ((i >> 3) & 7) * 36;
r = ( i & 7) * 36;
} else if (c->srcFormat == AV_PIX_FMT_RGB4_BYTE) {
r = ( i >> 3 ) * 255;
g = ((i >> 1) & 3) * 85;
b = ( i & 1) * 255;
} else if (c->srcFormat == AV_PIX_FMT_GRAY8 || c->srcFormat == AV_PIX_FMT_GRAY8A) {
r = g = b = i;
} else {
av_assert1(c->srcFormat == AV_PIX_FMT_BGR4_BYTE);
b = ( i >> 3 ) * 255;
g = ((i >> 1) & 3) * 85;
r = ( i & 1) * 255;
}
#define RGB2YUV_SHIFT 15
#define BY ( (int) (0.114 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define BV (-(int) (0.081 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define BU ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define GY ( (int) (0.587 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define GV (-(int) (0.419 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define GU (-(int) (0.331 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define RY ( (int) (0.299 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define RV ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define RU (-(int) (0.169 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
y = av_clip_uint8((RY * r + GY * g + BY * b + ( 33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
u = av_clip_uint8((RU * r + GU * g + BU * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
v = av_clip_uint8((RV * r + GV * g + BV * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
c->pal_yuv[i]= y + (u<<8) + (v<<16) + (a<<24);
switch (c->dstFormat) {
case AV_PIX_FMT_BGR32:
#if !HAVE_BIGENDIAN
case AV_PIX_FMT_RGB24:
#endif
c->pal_rgb[i]= r + (g<<8) + (b<<16) + (a<<24);
break;
case AV_PIX_FMT_BGR32_1:
#if HAVE_BIGENDIAN
case AV_PIX_FMT_BGR24:
#endif
c->pal_rgb[i]= a + (r<<8) + (g<<16) + (b<<24);
break;
case AV_PIX_FMT_RGB32_1:
#if HAVE_BIGENDIAN
case AV_PIX_FMT_RGB24:
#endif
c->pal_rgb[i]= a + (b<<8) + (g<<16) + (r<<24);
break;
case AV_PIX_FMT_RGB32:
#if !HAVE_BIGENDIAN
case AV_PIX_FMT_BGR24:
#endif
default:
c->pal_rgb[i]= b + (g<<8) + (r<<16) + (a<<24);
}
}
}
if (c->src0Alpha && !c->dst0Alpha && isALPHA(c->dstFormat)) {
uint8_t *base;
int x,y;
rgb0_tmp = av_malloc(FFABS(srcStride[0]) * srcSliceH + 32);
base = srcStride[0] < 0 ? rgb0_tmp - srcStride[0] * (srcSliceH-1) : rgb0_tmp;
for (y=0; y<srcSliceH; y++){
memcpy(base + srcStride[0]*y, src2[0] + srcStride[0]*y, 4*c->srcW);
for (x=c->src0Alpha-1; x<4*c->srcW; x+=4) {
base[ srcStride[0]*y + x] = 0xFF;
}
}
src2[0] = base;
}
// copy strides, so they can safely be modified
if (c->sliceDir == 1) {
// slices go from top to bottom
int srcStride2[4] = { srcStride[0], srcStride[1], srcStride[2],
srcStride[3] };
int dstStride2[4] = { dstStride[0], dstStride[1], dstStride[2],
dstStride[3] };
reset_ptr(src2, c->srcFormat);
reset_ptr((void*)dst2, c->dstFormat);
/* reset slice direction at end of frame */
if (srcSliceY + srcSliceH == c->srcH)
c->sliceDir = 0;
ret = c->swScale(c, src2, srcStride2, srcSliceY, srcSliceH, dst2,
dstStride2);
} else {
// slices go from bottom to top => we flip the image internally
int srcStride2[4] = { -srcStride[0], -srcStride[1], -srcStride[2],
-srcStride[3] };
int dstStride2[4] = { -dstStride[0], -dstStride[1], -dstStride[2],
-dstStride[3] };
src2[0] += (srcSliceH - 1) * srcStride[0];
if (!usePal(c->srcFormat))
src2[1] += ((srcSliceH >> c->chrSrcVSubSample) - 1) * srcStride[1];
src2[2] += ((srcSliceH >> c->chrSrcVSubSample) - 1) * srcStride[2];
src2[3] += (srcSliceH - 1) * srcStride[3];
dst2[0] += ( c->dstH - 1) * dstStride[0];
dst2[1] += ((c->dstH >> c->chrDstVSubSample) - 1) * dstStride[1];
dst2[2] += ((c->dstH >> c->chrDstVSubSample) - 1) * dstStride[2];
dst2[3] += ( c->dstH - 1) * dstStride[3];
reset_ptr(src2, c->srcFormat);
reset_ptr((void*)dst2, c->dstFormat);
/* reset slice direction at end of frame */
if (!srcSliceY)
c->sliceDir = 0;
ret = c->swScale(c, src2, srcStride2, c->srcH-srcSliceY-srcSliceH,
srcSliceH, dst2, dstStride2);
}
av_free(rgb0_tmp);
return ret;
}
| true | FFmpeg | 3ee8eefbf2623e1e337df7d962412b0703336431 | int attribute_align_arg sws_scale(struct SwsContext *c,
const uint8_t * const srcSlice[],
const int srcStride[], int srcSliceY,
int srcSliceH, uint8_t *const dst[],
const int dstStride[])
{
int i, ret;
const uint8_t *src2[4] = { srcSlice[0], srcSlice[1], srcSlice[2], srcSlice[3] };
uint8_t *dst2[4] = { dst[0], dst[1], dst[2], dst[3] };
uint8_t *rgb0_tmp = NULL;
if (srcSliceH == 0)
return 0;
if (!check_image_pointers(srcSlice, c->srcFormat, srcStride)) {
av_log(c, AV_LOG_ERROR, "bad src image pointers\n");
return 0;
}
if (!check_image_pointers((const uint8_t* const*)dst, c->dstFormat, dstStride)) {
av_log(c, AV_LOG_ERROR, "bad dst image pointers\n");
return 0;
}
if (c->sliceDir == 0 && srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) {
av_log(c, AV_LOG_ERROR, "Slices start in the middle!\n");
return 0;
}
if (c->sliceDir == 0) {
if (srcSliceY == 0) c->sliceDir = 1; else c->sliceDir = -1;
}
if (usePal(c->srcFormat)) {
for (i = 0; i < 256; i++) {
int p, r, g, b, y, u, v, a = 0xff;
if (c->srcFormat == AV_PIX_FMT_PAL8) {
p = ((const uint32_t *)(srcSlice[1]))[i];
a = (p >> 24) & 0xFF;
r = (p >> 16) & 0xFF;
g = (p >> 8) & 0xFF;
b = p & 0xFF;
} else if (c->srcFormat == AV_PIX_FMT_RGB8) {
r = ( i >> 5 ) * 36;
g = ((i >> 2) & 7) * 36;
b = ( i & 3) * 85;
} else if (c->srcFormat == AV_PIX_FMT_BGR8) {
b = ( i >> 6 ) * 85;
g = ((i >> 3) & 7) * 36;
r = ( i & 7) * 36;
} else if (c->srcFormat == AV_PIX_FMT_RGB4_BYTE) {
r = ( i >> 3 ) * 255;
g = ((i >> 1) & 3) * 85;
b = ( i & 1) * 255;
} else if (c->srcFormat == AV_PIX_FMT_GRAY8 || c->srcFormat == AV_PIX_FMT_GRAY8A) {
r = g = b = i;
} else {
av_assert1(c->srcFormat == AV_PIX_FMT_BGR4_BYTE);
b = ( i >> 3 ) * 255;
g = ((i >> 1) & 3) * 85;
r = ( i & 1) * 255;
}
#define RGB2YUV_SHIFT 15
#define BY ( (int) (0.114 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define BV (-(int) (0.081 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define BU ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define GY ( (int) (0.587 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define GV (-(int) (0.419 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define GU (-(int) (0.331 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define RY ( (int) (0.299 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define RV ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define RU (-(int) (0.169 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
y = av_clip_uint8((RY * r + GY * g + BY * b + ( 33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
u = av_clip_uint8((RU * r + GU * g + BU * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
v = av_clip_uint8((RV * r + GV * g + BV * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
c->pal_yuv[i]= y + (u<<8) + (v<<16) + (a<<24);
switch (c->dstFormat) {
case AV_PIX_FMT_BGR32:
#if !HAVE_BIGENDIAN
case AV_PIX_FMT_RGB24:
#endif
c->pal_rgb[i]= r + (g<<8) + (b<<16) + (a<<24);
break;
case AV_PIX_FMT_BGR32_1:
#if HAVE_BIGENDIAN
case AV_PIX_FMT_BGR24:
#endif
c->pal_rgb[i]= a + (r<<8) + (g<<16) + (b<<24);
break;
case AV_PIX_FMT_RGB32_1:
#if HAVE_BIGENDIAN
case AV_PIX_FMT_RGB24:
#endif
c->pal_rgb[i]= a + (b<<8) + (g<<16) + (r<<24);
break;
case AV_PIX_FMT_RGB32:
#if !HAVE_BIGENDIAN
case AV_PIX_FMT_BGR24:
#endif
default:
c->pal_rgb[i]= b + (g<<8) + (r<<16) + (a<<24);
}
}
}
if (c->src0Alpha && !c->dst0Alpha && isALPHA(c->dstFormat)) {
uint8_t *base;
int x,y;
rgb0_tmp = av_malloc(FFABS(srcStride[0]) * srcSliceH + 32);
base = srcStride[0] < 0 ? rgb0_tmp - srcStride[0] * (srcSliceH-1) : rgb0_tmp;
for (y=0; y<srcSliceH; y++){
memcpy(base + srcStride[0]*y, src2[0] + srcStride[0]*y, 4*c->srcW);
for (x=c->src0Alpha-1; x<4*c->srcW; x+=4) {
base[ srcStride[0]*y + x] = 0xFF;
}
}
src2[0] = base;
}
if (c->sliceDir == 1) {
int srcStride2[4] = { srcStride[0], srcStride[1], srcStride[2],
srcStride[3] };
int dstStride2[4] = { dstStride[0], dstStride[1], dstStride[2],
dstStride[3] };
reset_ptr(src2, c->srcFormat);
reset_ptr((void*)dst2, c->dstFormat);
if (srcSliceY + srcSliceH == c->srcH)
c->sliceDir = 0;
ret = c->swScale(c, src2, srcStride2, srcSliceY, srcSliceH, dst2,
dstStride2);
} else {
int srcStride2[4] = { -srcStride[0], -srcStride[1], -srcStride[2],
-srcStride[3] };
int dstStride2[4] = { -dstStride[0], -dstStride[1], -dstStride[2],
-dstStride[3] };
src2[0] += (srcSliceH - 1) * srcStride[0];
if (!usePal(c->srcFormat))
src2[1] += ((srcSliceH >> c->chrSrcVSubSample) - 1) * srcStride[1];
src2[2] += ((srcSliceH >> c->chrSrcVSubSample) - 1) * srcStride[2];
src2[3] += (srcSliceH - 1) * srcStride[3];
dst2[0] += ( c->dstH - 1) * dstStride[0];
dst2[1] += ((c->dstH >> c->chrDstVSubSample) - 1) * dstStride[1];
dst2[2] += ((c->dstH >> c->chrDstVSubSample) - 1) * dstStride[2];
dst2[3] += ( c->dstH - 1) * dstStride[3];
reset_ptr(src2, c->srcFormat);
reset_ptr((void*)dst2, c->dstFormat);
if (!srcSliceY)
c->sliceDir = 0;
ret = c->swScale(c, src2, srcStride2, c->srcH-srcSliceY-srcSliceH,
srcSliceH, dst2, dstStride2);
}
av_free(rgb0_tmp);
return ret;
}
| {
"code": [
" c->pal_yuv[i]= y + (u<<8) + (v<<16) + (a<<24);",
" c->pal_rgb[i]= r + (g<<8) + (b<<16) + (a<<24);",
" c->pal_rgb[i]= a + (r<<8) + (g<<16) + (b<<24);",
" c->pal_rgb[i]= a + (b<<8) + (g<<16) + (r<<24);",
" c->pal_rgb[i]= b + (g<<8) + (r<<16) + (a<<24);"
],
"line_no": [
151,
165,
177,
189,
203
]
} | int VAR_0 sws_scale(struct SwsContext *c,
const uint8_t * const srcSlice[],
const int srcStride[], int srcSliceY,
int srcSliceH, uint8_t *const dst[],
const int dstStride[])
{
int i, ret;
const uint8_t *src2[4] = { srcSlice[0], srcSlice[1], srcSlice[2], srcSlice[3] };
uint8_t *dst2[4] = { dst[0], dst[1], dst[2], dst[3] };
uint8_t *rgb0_tmp = NULL;
if (srcSliceH == 0)
return 0;
if (!check_image_pointers(srcSlice, c->srcFormat, srcStride)) {
av_log(c, AV_LOG_ERROR, "bad src image pointers\n");
return 0;
}
if (!check_image_pointers((const uint8_t* const*)dst, c->dstFormat, dstStride)) {
av_log(c, AV_LOG_ERROR, "bad dst image pointers\n");
return 0;
}
if (c->sliceDir == 0 && srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) {
av_log(c, AV_LOG_ERROR, "Slices start in the middle!\n");
return 0;
}
if (c->sliceDir == 0) {
if (srcSliceY == 0) c->sliceDir = 1; else c->sliceDir = -1;
}
if (usePal(c->srcFormat)) {
for (i = 0; i < 256; i++) {
int p, r, g, b, y, u, v, a = 0xff;
if (c->srcFormat == AV_PIX_FMT_PAL8) {
p = ((const uint32_t *)(srcSlice[1]))[i];
a = (p >> 24) & 0xFF;
r = (p >> 16) & 0xFF;
g = (p >> 8) & 0xFF;
b = p & 0xFF;
} else if (c->srcFormat == AV_PIX_FMT_RGB8) {
r = ( i >> 5 ) * 36;
g = ((i >> 2) & 7) * 36;
b = ( i & 3) * 85;
} else if (c->srcFormat == AV_PIX_FMT_BGR8) {
b = ( i >> 6 ) * 85;
g = ((i >> 3) & 7) * 36;
r = ( i & 7) * 36;
} else if (c->srcFormat == AV_PIX_FMT_RGB4_BYTE) {
r = ( i >> 3 ) * 255;
g = ((i >> 1) & 3) * 85;
b = ( i & 1) * 255;
} else if (c->srcFormat == AV_PIX_FMT_GRAY8 || c->srcFormat == AV_PIX_FMT_GRAY8A) {
r = g = b = i;
} else {
av_assert1(c->srcFormat == AV_PIX_FMT_BGR4_BYTE);
b = ( i >> 3 ) * 255;
g = ((i >> 1) & 3) * 85;
r = ( i & 1) * 255;
}
#define RGB2YUV_SHIFT 15
#define BY ( (int) (0.114 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define BV (-(int) (0.081 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define BU ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define GY ( (int) (0.587 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define GV (-(int) (0.419 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define GU (-(int) (0.331 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define RY ( (int) (0.299 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define RV ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define RU (-(int) (0.169 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
y = av_clip_uint8((RY * r + GY * g + BY * b + ( 33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
u = av_clip_uint8((RU * r + GU * g + BU * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
v = av_clip_uint8((RV * r + GV * g + BV * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
c->pal_yuv[i]= y + (u<<8) + (v<<16) + (a<<24);
switch (c->dstFormat) {
case AV_PIX_FMT_BGR32:
#if !HAVE_BIGENDIAN
case AV_PIX_FMT_RGB24:
#endif
c->pal_rgb[i]= r + (g<<8) + (b<<16) + (a<<24);
break;
case AV_PIX_FMT_BGR32_1:
#if HAVE_BIGENDIAN
case AV_PIX_FMT_BGR24:
#endif
c->pal_rgb[i]= a + (r<<8) + (g<<16) + (b<<24);
break;
case AV_PIX_FMT_RGB32_1:
#if HAVE_BIGENDIAN
case AV_PIX_FMT_RGB24:
#endif
c->pal_rgb[i]= a + (b<<8) + (g<<16) + (r<<24);
break;
case AV_PIX_FMT_RGB32:
#if !HAVE_BIGENDIAN
case AV_PIX_FMT_BGR24:
#endif
default:
c->pal_rgb[i]= b + (g<<8) + (r<<16) + (a<<24);
}
}
}
if (c->src0Alpha && !c->dst0Alpha && isALPHA(c->dstFormat)) {
uint8_t *base;
int x,y;
rgb0_tmp = av_malloc(FFABS(srcStride[0]) * srcSliceH + 32);
base = srcStride[0] < 0 ? rgb0_tmp - srcStride[0] * (srcSliceH-1) : rgb0_tmp;
for (y=0; y<srcSliceH; y++){
memcpy(base + srcStride[0]*y, src2[0] + srcStride[0]*y, 4*c->srcW);
for (x=c->src0Alpha-1; x<4*c->srcW; x+=4) {
base[ srcStride[0]*y + x] = 0xFF;
}
}
src2[0] = base;
}
if (c->sliceDir == 1) {
int srcStride2[4] = { srcStride[0], srcStride[1], srcStride[2],
srcStride[3] };
int dstStride2[4] = { dstStride[0], dstStride[1], dstStride[2],
dstStride[3] };
reset_ptr(src2, c->srcFormat);
reset_ptr((void*)dst2, c->dstFormat);
if (srcSliceY + srcSliceH == c->srcH)
c->sliceDir = 0;
ret = c->swScale(c, src2, srcStride2, srcSliceY, srcSliceH, dst2,
dstStride2);
} else {
int srcStride2[4] = { -srcStride[0], -srcStride[1], -srcStride[2],
-srcStride[3] };
int dstStride2[4] = { -dstStride[0], -dstStride[1], -dstStride[2],
-dstStride[3] };
src2[0] += (srcSliceH - 1) * srcStride[0];
if (!usePal(c->srcFormat))
src2[1] += ((srcSliceH >> c->chrSrcVSubSample) - 1) * srcStride[1];
src2[2] += ((srcSliceH >> c->chrSrcVSubSample) - 1) * srcStride[2];
src2[3] += (srcSliceH - 1) * srcStride[3];
dst2[0] += ( c->dstH - 1) * dstStride[0];
dst2[1] += ((c->dstH >> c->chrDstVSubSample) - 1) * dstStride[1];
dst2[2] += ((c->dstH >> c->chrDstVSubSample) - 1) * dstStride[2];
dst2[3] += ( c->dstH - 1) * dstStride[3];
reset_ptr(src2, c->srcFormat);
reset_ptr((void*)dst2, c->dstFormat);
if (!srcSliceY)
c->sliceDir = 0;
ret = c->swScale(c, src2, srcStride2, c->srcH-srcSliceY-srcSliceH,
srcSliceH, dst2, dstStride2);
}
av_free(rgb0_tmp);
return ret;
}
| [
"int VAR_0 sws_scale(struct SwsContext *c,\nconst uint8_t * const srcSlice[],\nconst int srcStride[], int srcSliceY,\nint srcSliceH, uint8_t *const dst[],\nconst int dstStride[])\n{",
"int i, ret;",
"const uint8_t *src2[4] = { srcSlice[0], srcSlice[1], srcSlice[2], srcSlice[3] };",
"uint8_t *dst2[4] = { dst[0], dst[1], dst[2], dst[3] };",
"uint8_t *rgb0_tmp = NULL;",
"if (srcSliceH == 0)\nreturn 0;",
"if (!check_image_pointers(srcSlice, c->srcFormat, srcStride)) {",
"av_log(c, AV_LOG_ERROR, \"bad src image pointers\\n\");",
"return 0;",
"}",
"if (!check_image_pointers((const uint8_t* const*)dst, c->dstFormat, dstStride)) {",
"av_log(c, AV_LOG_ERROR, \"bad dst image pointers\\n\");",
"return 0;",
"}",
"if (c->sliceDir == 0 && srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) {",
"av_log(c, AV_LOG_ERROR, \"Slices start in the middle!\\n\");",
"return 0;",
"}",
"if (c->sliceDir == 0) {",
"if (srcSliceY == 0) c->sliceDir = 1; else c->sliceDir = -1;",
"}",
"if (usePal(c->srcFormat)) {",
"for (i = 0; i < 256; i++) {",
"int p, r, g, b, y, u, v, a = 0xff;",
"if (c->srcFormat == AV_PIX_FMT_PAL8) {",
"p = ((const uint32_t *)(srcSlice[1]))[i];",
"a = (p >> 24) & 0xFF;",
"r = (p >> 16) & 0xFF;",
"g = (p >> 8) & 0xFF;",
"b = p & 0xFF;",
"} else if (c->srcFormat == AV_PIX_FMT_RGB8) {",
"r = ( i >> 5 ) * 36;",
"g = ((i >> 2) & 7) * 36;",
"b = ( i & 3) * 85;",
"} else if (c->srcFormat == AV_PIX_FMT_BGR8) {",
"b = ( i >> 6 ) * 85;",
"g = ((i >> 3) & 7) * 36;",
"r = ( i & 7) * 36;",
"} else if (c->srcFormat == AV_PIX_FMT_RGB4_BYTE) {",
"r = ( i >> 3 ) * 255;",
"g = ((i >> 1) & 3) * 85;",
"b = ( i & 1) * 255;",
"} else if (c->srcFormat == AV_PIX_FMT_GRAY8 || c->srcFormat == AV_PIX_FMT_GRAY8A) {",
"r = g = b = i;",
"} else {",
"av_assert1(c->srcFormat == AV_PIX_FMT_BGR4_BYTE);",
"b = ( i >> 3 ) * 255;",
"g = ((i >> 1) & 3) * 85;",
"r = ( i & 1) * 255;",
"}",
"#define RGB2YUV_SHIFT 15\n#define BY ( (int) (0.114 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))\n#define BV (-(int) (0.081 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))\n#define BU ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))\n#define GY ( (int) (0.587 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))\n#define GV (-(int) (0.419 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))\n#define GU (-(int) (0.331 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))\n#define RY ( (int) (0.299 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))\n#define RV ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))\n#define RU (-(int) (0.169 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))\ny = av_clip_uint8((RY * r + GY * g + BY * b + ( 33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);",
"u = av_clip_uint8((RU * r + GU * g + BU * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);",
"v = av_clip_uint8((RV * r + GV * g + BV * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);",
"c->pal_yuv[i]= y + (u<<8) + (v<<16) + (a<<24);",
"switch (c->dstFormat) {",
"case AV_PIX_FMT_BGR32:\n#if !HAVE_BIGENDIAN\ncase AV_PIX_FMT_RGB24:\n#endif\nc->pal_rgb[i]= r + (g<<8) + (b<<16) + (a<<24);",
"break;",
"case AV_PIX_FMT_BGR32_1:\n#if HAVE_BIGENDIAN\ncase AV_PIX_FMT_BGR24:\n#endif\nc->pal_rgb[i]= a + (r<<8) + (g<<16) + (b<<24);",
"break;",
"case AV_PIX_FMT_RGB32_1:\n#if HAVE_BIGENDIAN\ncase AV_PIX_FMT_RGB24:\n#endif\nc->pal_rgb[i]= a + (b<<8) + (g<<16) + (r<<24);",
"break;",
"case AV_PIX_FMT_RGB32:\n#if !HAVE_BIGENDIAN\ncase AV_PIX_FMT_BGR24:\n#endif\ndefault:\nc->pal_rgb[i]= b + (g<<8) + (r<<16) + (a<<24);",
"}",
"}",
"}",
"if (c->src0Alpha && !c->dst0Alpha && isALPHA(c->dstFormat)) {",
"uint8_t *base;",
"int x,y;",
"rgb0_tmp = av_malloc(FFABS(srcStride[0]) * srcSliceH + 32);",
"base = srcStride[0] < 0 ? rgb0_tmp - srcStride[0] * (srcSliceH-1) : rgb0_tmp;",
"for (y=0; y<srcSliceH; y++){",
"memcpy(base + srcStride[0]*y, src2[0] + srcStride[0]*y, 4*c->srcW);",
"for (x=c->src0Alpha-1; x<4*c->srcW; x+=4) {",
"base[ srcStride[0]*y + x] = 0xFF;",
"}",
"}",
"src2[0] = base;",
"}",
"if (c->sliceDir == 1) {",
"int srcStride2[4] = { srcStride[0], srcStride[1], srcStride[2],",
"srcStride[3] };",
"int dstStride2[4] = { dstStride[0], dstStride[1], dstStride[2],",
"dstStride[3] };",
"reset_ptr(src2, c->srcFormat);",
"reset_ptr((void*)dst2, c->dstFormat);",
"if (srcSliceY + srcSliceH == c->srcH)\nc->sliceDir = 0;",
"ret = c->swScale(c, src2, srcStride2, srcSliceY, srcSliceH, dst2,\ndstStride2);",
"} else {",
"int srcStride2[4] = { -srcStride[0], -srcStride[1], -srcStride[2],",
"-srcStride[3] };",
"int dstStride2[4] = { -dstStride[0], -dstStride[1], -dstStride[2],",
"-dstStride[3] };",
"src2[0] += (srcSliceH - 1) * srcStride[0];",
"if (!usePal(c->srcFormat))\nsrc2[1] += ((srcSliceH >> c->chrSrcVSubSample) - 1) * srcStride[1];",
"src2[2] += ((srcSliceH >> c->chrSrcVSubSample) - 1) * srcStride[2];",
"src2[3] += (srcSliceH - 1) * srcStride[3];",
"dst2[0] += ( c->dstH - 1) * dstStride[0];",
"dst2[1] += ((c->dstH >> c->chrDstVSubSample) - 1) * dstStride[1];",
"dst2[2] += ((c->dstH >> c->chrDstVSubSample) - 1) * dstStride[2];",
"dst2[3] += ( c->dstH - 1) * dstStride[3];",
"reset_ptr(src2, c->srcFormat);",
"reset_ptr((void*)dst2, c->dstFormat);",
"if (!srcSliceY)\nc->sliceDir = 0;",
"ret = c->swScale(c, src2, srcStride2, c->srcH-srcSliceY-srcSliceH,\nsrcSliceH, dst2, dstStride2);",
"}",
"av_free(rgb0_tmp);",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
25,
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123,
125,
127,
129,
131,
133,
135,
137,
139,
141,
145
],
[
147
],
[
149
],
[
151
],
[
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
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
243
],
[
247
],
[
249
],
[
251
],
[
253
],
[
257
],
[
259
],
[
265,
267
],
[
271,
273
],
[
275
],
[
279
],
[
281
],
[
283
],
[
285
],
[
289
],
[
291,
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
309
],
[
311
],
[
317,
319
],
[
323,
325
],
[
327
],
[
331
],
[
333
],
[
335
]
] |
25,950 | static av_cold int MPA_encode_init(AVCodecContext *avctx)
{
MpegAudioContext *s = avctx->priv_data;
int freq = avctx->sample_rate;
int bitrate = avctx->bit_rate;
int channels = avctx->channels;
int i, v, table;
float a;
if (channels <= 0 || channels > 2){
av_log(avctx, AV_LOG_ERROR, "encoding %d channel(s) is not allowed in mp2\n", channels);
return AVERROR(EINVAL);
}
bitrate = bitrate / 1000;
s->nb_channels = channels;
avctx->frame_size = MPA_FRAME_SIZE;
avctx->delay = 512 - 32 + 1;
/* encoding freq */
s->lsf = 0;
for(i=0;i<3;i++) {
if (avpriv_mpa_freq_tab[i] == freq)
break;
if ((avpriv_mpa_freq_tab[i] / 2) == freq) {
s->lsf = 1;
break;
}
}
if (i == 3){
av_log(avctx, AV_LOG_ERROR, "Sampling rate %d is not allowed in mp2\n", freq);
return AVERROR(EINVAL);
}
s->freq_index = i;
/* encoding bitrate & frequency */
for(i=0;i<15;i++) {
if (avpriv_mpa_bitrate_tab[s->lsf][1][i] == bitrate)
break;
}
if (i == 15){
av_log(avctx, AV_LOG_ERROR, "bitrate %d is not allowed in mp2\n", bitrate);
return AVERROR(EINVAL);
}
s->bitrate_index = i;
/* compute total header size & pad bit */
a = (float)(bitrate * 1000 * MPA_FRAME_SIZE) / (freq * 8.0);
s->frame_size = ((int)a) * 8;
/* frame fractional size to compute padding */
s->frame_frac = 0;
s->frame_frac_incr = (int)((a - floor(a)) * 65536.0);
/* select the right allocation table */
table = ff_mpa_l2_select_table(bitrate, s->nb_channels, freq, s->lsf);
/* number of used subbands */
s->sblimit = ff_mpa_sblimit_table[table];
s->alloc_table = ff_mpa_alloc_tables[table];
av_dlog(avctx, "%d kb/s, %d Hz, frame_size=%d bits, table=%d, padincr=%x\n",
bitrate, freq, s->frame_size, table, s->frame_frac_incr);
for(i=0;i<s->nb_channels;i++)
s->samples_offset[i] = 0;
for(i=0;i<257;i++) {
int v;
v = ff_mpa_enwindow[i];
#if WFRAC_BITS != 16
v = (v + (1 << (16 - WFRAC_BITS - 1))) >> (16 - WFRAC_BITS);
#endif
s->filter_bank[i] = v;
if ((i & 63) != 0)
v = -v;
if (i != 0)
s->filter_bank[512 - i] = v;
}
for(i=0;i<64;i++) {
v = (int)(exp2((3 - i) / 3.0) * (1 << 20));
if (v <= 0)
v = 1;
s->scale_factor_table[i] = v;
#if USE_FLOATS
s->scale_factor_inv_table[i] = exp2(-(3 - i) / 3.0) / (float)(1 << 20);
#else
#define P 15
s->scale_factor_shift[i] = 21 - P - (i / 3);
s->scale_factor_mult[i] = (1 << P) * exp2((i % 3) / 3.0);
#endif
}
for(i=0;i<128;i++) {
v = i - 64;
if (v <= -3)
v = 0;
else if (v < 0)
v = 1;
else if (v == 0)
v = 2;
else if (v < 3)
v = 3;
else
v = 4;
s->scale_diff_table[i] = v;
}
for(i=0;i<17;i++) {
v = ff_mpa_quant_bits[i];
if (v < 0)
v = -v;
else
v = v * 3;
s->total_quant_bits[i] = 12 * v;
}
return 0;
}
| true | FFmpeg | 9d66aa2c8fa60fe4a570021175ce66316baeb746 | static av_cold int MPA_encode_init(AVCodecContext *avctx)
{
MpegAudioContext *s = avctx->priv_data;
int freq = avctx->sample_rate;
int bitrate = avctx->bit_rate;
int channels = avctx->channels;
int i, v, table;
float a;
if (channels <= 0 || channels > 2){
av_log(avctx, AV_LOG_ERROR, "encoding %d channel(s) is not allowed in mp2\n", channels);
return AVERROR(EINVAL);
}
bitrate = bitrate / 1000;
s->nb_channels = channels;
avctx->frame_size = MPA_FRAME_SIZE;
avctx->delay = 512 - 32 + 1;
s->lsf = 0;
for(i=0;i<3;i++) {
if (avpriv_mpa_freq_tab[i] == freq)
break;
if ((avpriv_mpa_freq_tab[i] / 2) == freq) {
s->lsf = 1;
break;
}
}
if (i == 3){
av_log(avctx, AV_LOG_ERROR, "Sampling rate %d is not allowed in mp2\n", freq);
return AVERROR(EINVAL);
}
s->freq_index = i;
for(i=0;i<15;i++) {
if (avpriv_mpa_bitrate_tab[s->lsf][1][i] == bitrate)
break;
}
if (i == 15){
av_log(avctx, AV_LOG_ERROR, "bitrate %d is not allowed in mp2\n", bitrate);
return AVERROR(EINVAL);
}
s->bitrate_index = i;
a = (float)(bitrate * 1000 * MPA_FRAME_SIZE) / (freq * 8.0);
s->frame_size = ((int)a) * 8;
s->frame_frac = 0;
s->frame_frac_incr = (int)((a - floor(a)) * 65536.0);
table = ff_mpa_l2_select_table(bitrate, s->nb_channels, freq, s->lsf);
s->sblimit = ff_mpa_sblimit_table[table];
s->alloc_table = ff_mpa_alloc_tables[table];
av_dlog(avctx, "%d kb/s, %d Hz, frame_size=%d bits, table=%d, padincr=%x\n",
bitrate, freq, s->frame_size, table, s->frame_frac_incr);
for(i=0;i<s->nb_channels;i++)
s->samples_offset[i] = 0;
for(i=0;i<257;i++) {
int v;
v = ff_mpa_enwindow[i];
#if WFRAC_BITS != 16
v = (v + (1 << (16 - WFRAC_BITS - 1))) >> (16 - WFRAC_BITS);
#endif
s->filter_bank[i] = v;
if ((i & 63) != 0)
v = -v;
if (i != 0)
s->filter_bank[512 - i] = v;
}
for(i=0;i<64;i++) {
v = (int)(exp2((3 - i) / 3.0) * (1 << 20));
if (v <= 0)
v = 1;
s->scale_factor_table[i] = v;
#if USE_FLOATS
s->scale_factor_inv_table[i] = exp2(-(3 - i) / 3.0) / (float)(1 << 20);
#else
#define P 15
s->scale_factor_shift[i] = 21 - P - (i / 3);
s->scale_factor_mult[i] = (1 << P) * exp2((i % 3) / 3.0);
#endif
}
for(i=0;i<128;i++) {
v = i - 64;
if (v <= -3)
v = 0;
else if (v < 0)
v = 1;
else if (v == 0)
v = 2;
else if (v < 3)
v = 3;
else
v = 4;
s->scale_diff_table[i] = v;
}
for(i=0;i<17;i++) {
v = ff_mpa_quant_bits[i];
if (v < 0)
v = -v;
else
v = v * 3;
s->total_quant_bits[i] = 12 * v;
}
return 0;
}
| {
"code": [
" for(i=0;i<15;i++) {"
],
"line_no": [
71
]
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
MpegAudioContext *s = avctx->priv_data;
int VAR_0 = avctx->sample_rate;
int VAR_1 = avctx->bit_rate;
int VAR_2 = avctx->VAR_2;
int VAR_3, VAR_7, VAR_5;
float VAR_6;
if (VAR_2 <= 0 || VAR_2 > 2){
av_log(avctx, AV_LOG_ERROR, "encoding %d channel(s) is not allowed in mp2\n", VAR_2);
return AVERROR(EINVAL);
}
VAR_1 = VAR_1 / 1000;
s->nb_channels = VAR_2;
avctx->frame_size = MPA_FRAME_SIZE;
avctx->delay = 512 - 32 + 1;
s->lsf = 0;
for(VAR_3=0;VAR_3<3;VAR_3++) {
if (avpriv_mpa_freq_tab[VAR_3] == VAR_0)
break;
if ((avpriv_mpa_freq_tab[VAR_3] / 2) == VAR_0) {
s->lsf = 1;
break;
}
}
if (VAR_3 == 3){
av_log(avctx, AV_LOG_ERROR, "Sampling rate %d is not allowed in mp2\n", VAR_0);
return AVERROR(EINVAL);
}
s->freq_index = VAR_3;
for(VAR_3=0;VAR_3<15;VAR_3++) {
if (avpriv_mpa_bitrate_tab[s->lsf][1][VAR_3] == VAR_1)
break;
}
if (VAR_3 == 15){
av_log(avctx, AV_LOG_ERROR, "VAR_1 %d is not allowed in mp2\n", VAR_1);
return AVERROR(EINVAL);
}
s->bitrate_index = VAR_3;
VAR_6 = (float)(VAR_1 * 1000 * MPA_FRAME_SIZE) / (VAR_0 * 8.0);
s->frame_size = ((int)VAR_6) * 8;
s->frame_frac = 0;
s->frame_frac_incr = (int)((VAR_6 - floor(VAR_6)) * 65536.0);
VAR_5 = ff_mpa_l2_select_table(VAR_1, s->nb_channels, VAR_0, s->lsf);
s->sblimit = ff_mpa_sblimit_table[VAR_5];
s->alloc_table = ff_mpa_alloc_tables[VAR_5];
av_dlog(avctx, "%d kb/s, %d Hz, frame_size=%d bits, VAR_5=%d, padincr=%x\n",
VAR_1, VAR_0, s->frame_size, VAR_5, s->frame_frac_incr);
for(VAR_3=0;VAR_3<s->nb_channels;VAR_3++)
s->samples_offset[VAR_3] = 0;
for(VAR_3=0;VAR_3<257;VAR_3++) {
int VAR_7;
VAR_7 = ff_mpa_enwindow[VAR_3];
#if WFRAC_BITS != 16
VAR_7 = (VAR_7 + (1 << (16 - WFRAC_BITS - 1))) >> (16 - WFRAC_BITS);
#endif
s->filter_bank[VAR_3] = VAR_7;
if ((VAR_3 & 63) != 0)
VAR_7 = -VAR_7;
if (VAR_3 != 0)
s->filter_bank[512 - VAR_3] = VAR_7;
}
for(VAR_3=0;VAR_3<64;VAR_3++) {
VAR_7 = (int)(exp2((3 - VAR_3) / 3.0) * (1 << 20));
if (VAR_7 <= 0)
VAR_7 = 1;
s->scale_factor_table[VAR_3] = VAR_7;
#if USE_FLOATS
s->scale_factor_inv_table[VAR_3] = exp2(-(3 - VAR_3) / 3.0) / (float)(1 << 20);
#else
#define P 15
s->scale_factor_shift[VAR_3] = 21 - P - (VAR_3 / 3);
s->scale_factor_mult[VAR_3] = (1 << P) * exp2((VAR_3 % 3) / 3.0);
#endif
}
for(VAR_3=0;VAR_3<128;VAR_3++) {
VAR_7 = VAR_3 - 64;
if (VAR_7 <= -3)
VAR_7 = 0;
else if (VAR_7 < 0)
VAR_7 = 1;
else if (VAR_7 == 0)
VAR_7 = 2;
else if (VAR_7 < 3)
VAR_7 = 3;
else
VAR_7 = 4;
s->scale_diff_table[VAR_3] = VAR_7;
}
for(VAR_3=0;VAR_3<17;VAR_3++) {
VAR_7 = ff_mpa_quant_bits[VAR_3];
if (VAR_7 < 0)
VAR_7 = -VAR_7;
else
VAR_7 = VAR_7 * 3;
s->total_quant_bits[VAR_3] = 12 * VAR_7;
}
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"MpegAudioContext *s = avctx->priv_data;",
"int VAR_0 = avctx->sample_rate;",
"int VAR_1 = avctx->bit_rate;",
"int VAR_2 = avctx->VAR_2;",
"int VAR_3, VAR_7, VAR_5;",
"float VAR_6;",
"if (VAR_2 <= 0 || VAR_2 > 2){",
"av_log(avctx, AV_LOG_ERROR, \"encoding %d channel(s) is not allowed in mp2\\n\", VAR_2);",
"return AVERROR(EINVAL);",
"}",
"VAR_1 = VAR_1 / 1000;",
"s->nb_channels = VAR_2;",
"avctx->frame_size = MPA_FRAME_SIZE;",
"avctx->delay = 512 - 32 + 1;",
"s->lsf = 0;",
"for(VAR_3=0;VAR_3<3;VAR_3++) {",
"if (avpriv_mpa_freq_tab[VAR_3] == VAR_0)\nbreak;",
"if ((avpriv_mpa_freq_tab[VAR_3] / 2) == VAR_0) {",
"s->lsf = 1;",
"break;",
"}",
"}",
"if (VAR_3 == 3){",
"av_log(avctx, AV_LOG_ERROR, \"Sampling rate %d is not allowed in mp2\\n\", VAR_0);",
"return AVERROR(EINVAL);",
"}",
"s->freq_index = VAR_3;",
"for(VAR_3=0;VAR_3<15;VAR_3++) {",
"if (avpriv_mpa_bitrate_tab[s->lsf][1][VAR_3] == VAR_1)\nbreak;",
"}",
"if (VAR_3 == 15){",
"av_log(avctx, AV_LOG_ERROR, \"VAR_1 %d is not allowed in mp2\\n\", VAR_1);",
"return AVERROR(EINVAL);",
"}",
"s->bitrate_index = VAR_3;",
"VAR_6 = (float)(VAR_1 * 1000 * MPA_FRAME_SIZE) / (VAR_0 * 8.0);",
"s->frame_size = ((int)VAR_6) * 8;",
"s->frame_frac = 0;",
"s->frame_frac_incr = (int)((VAR_6 - floor(VAR_6)) * 65536.0);",
"VAR_5 = ff_mpa_l2_select_table(VAR_1, s->nb_channels, VAR_0, s->lsf);",
"s->sblimit = ff_mpa_sblimit_table[VAR_5];",
"s->alloc_table = ff_mpa_alloc_tables[VAR_5];",
"av_dlog(avctx, \"%d kb/s, %d Hz, frame_size=%d bits, VAR_5=%d, padincr=%x\\n\",\nVAR_1, VAR_0, s->frame_size, VAR_5, s->frame_frac_incr);",
"for(VAR_3=0;VAR_3<s->nb_channels;VAR_3++)",
"s->samples_offset[VAR_3] = 0;",
"for(VAR_3=0;VAR_3<257;VAR_3++) {",
"int VAR_7;",
"VAR_7 = ff_mpa_enwindow[VAR_3];",
"#if WFRAC_BITS != 16\nVAR_7 = (VAR_7 + (1 << (16 - WFRAC_BITS - 1))) >> (16 - WFRAC_BITS);",
"#endif\ns->filter_bank[VAR_3] = VAR_7;",
"if ((VAR_3 & 63) != 0)\nVAR_7 = -VAR_7;",
"if (VAR_3 != 0)\ns->filter_bank[512 - VAR_3] = VAR_7;",
"}",
"for(VAR_3=0;VAR_3<64;VAR_3++) {",
"VAR_7 = (int)(exp2((3 - VAR_3) / 3.0) * (1 << 20));",
"if (VAR_7 <= 0)\nVAR_7 = 1;",
"s->scale_factor_table[VAR_3] = VAR_7;",
"#if USE_FLOATS\ns->scale_factor_inv_table[VAR_3] = exp2(-(3 - VAR_3) / 3.0) / (float)(1 << 20);",
"#else\n#define P 15\ns->scale_factor_shift[VAR_3] = 21 - P - (VAR_3 / 3);",
"s->scale_factor_mult[VAR_3] = (1 << P) * exp2((VAR_3 % 3) / 3.0);",
"#endif\n}",
"for(VAR_3=0;VAR_3<128;VAR_3++) {",
"VAR_7 = VAR_3 - 64;",
"if (VAR_7 <= -3)\nVAR_7 = 0;",
"else if (VAR_7 < 0)\nVAR_7 = 1;",
"else if (VAR_7 == 0)\nVAR_7 = 2;",
"else if (VAR_7 < 3)\nVAR_7 = 3;",
"else\nVAR_7 = 4;",
"s->scale_diff_table[VAR_3] = VAR_7;",
"}",
"for(VAR_3=0;VAR_3<17;VAR_3++) {",
"VAR_7 = ff_mpa_quant_bits[VAR_3];",
"if (VAR_7 < 0)\nVAR_7 = -VAR_7;",
"else\nVAR_7 = VAR_7 * 3;",
"s->total_quant_bits[VAR_3] = 12 * VAR_7;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
33
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
95
],
[
97
],
[
103
],
[
105
],
[
111
],
[
117
],
[
119
],
[
123,
125
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141,
143
],
[
145,
147
],
[
149,
151
],
[
153,
155
],
[
157
],
[
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
],
[
217
],
[
219
],
[
221,
223
],
[
225,
227
],
[
229
],
[
231
],
[
235
],
[
237
]
] |
25,952 | static av_cold int vc1_decode_init(AVCodecContext *avctx)
{
VC1Context *v = avctx->priv_data;
MpegEncContext *s = &v->s;
GetBitContext gb;
int ret;
/* save the container output size for WMImage */
v->output_width = avctx->width;
v->output_height = avctx->height;
if (!avctx->extradata_size || !avctx->extradata)
return -1;
if (!(avctx->flags & CODEC_FLAG_GRAY))
avctx->pix_fmt = ff_get_format(avctx, avctx->codec->pix_fmts);
else
avctx->pix_fmt = AV_PIX_FMT_GRAY8;
v->s.avctx = avctx;
if ((ret = ff_vc1_init_common(v)) < 0)
return ret;
// ensure static VLC tables are initialized
if ((ret = ff_msmpeg4_decode_init(avctx)) < 0)
return ret;
if ((ret = ff_vc1_decode_init_alloc_tables(v)) < 0)
return ret;
// Hack to ensure the above functions will be called
// again once we know all necessary settings.
// That this is necessary might indicate a bug.
ff_vc1_decode_end(avctx);
ff_blockdsp_init(&s->bdsp, avctx);
ff_h264chroma_init(&v->h264chroma, 8);
ff_qpeldsp_init(&s->qdsp);
if (avctx->codec_id == AV_CODEC_ID_WMV3 || avctx->codec_id == AV_CODEC_ID_WMV3IMAGE) {
int count = 0;
// looks like WMV3 has a sequence header stored in the extradata
// advanced sequence header may be before the first frame
// the last byte of the extradata is a version number, 1 for the
// samples we can decode
init_get_bits(&gb, avctx->extradata, avctx->extradata_size*8);
if ((ret = ff_vc1_decode_sequence_header(avctx, v, &gb)) < 0)
return ret;
count = avctx->extradata_size*8 - get_bits_count(&gb);
if (count > 0) {
av_log(avctx, AV_LOG_INFO, "Extra data: %i bits left, value: %X\n",
count, get_bits(&gb, count));
} else if (count < 0) {
av_log(avctx, AV_LOG_INFO, "Read %i bits in overflow\n", -count);
}
} else { // VC1/WVC1/WVP2
const uint8_t *start = avctx->extradata;
uint8_t *end = avctx->extradata + avctx->extradata_size;
const uint8_t *next;
int size, buf2_size;
uint8_t *buf2 = NULL;
int seq_initialized = 0, ep_initialized = 0;
if (avctx->extradata_size < 16) {
av_log(avctx, AV_LOG_ERROR, "Extradata size too small: %i\n", avctx->extradata_size);
return -1;
}
buf2 = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
start = find_next_marker(start, end); // in WVC1 extradata first byte is its size, but can be 0 in mkv
next = start;
for (; next < end; start = next) {
next = find_next_marker(start + 4, end);
size = next - start - 4;
if (size <= 0)
continue;
buf2_size = vc1_unescape_buffer(start + 4, size, buf2);
init_get_bits(&gb, buf2, buf2_size * 8);
switch (AV_RB32(start)) {
case VC1_CODE_SEQHDR:
if ((ret = ff_vc1_decode_sequence_header(avctx, v, &gb)) < 0) {
av_free(buf2);
return ret;
}
seq_initialized = 1;
break;
case VC1_CODE_ENTRYPOINT:
if ((ret = ff_vc1_decode_entry_point(avctx, v, &gb)) < 0) {
av_free(buf2);
return ret;
}
ep_initialized = 1;
break;
}
}
av_free(buf2);
if (!seq_initialized || !ep_initialized) {
av_log(avctx, AV_LOG_ERROR, "Incomplete extradata\n");
return -1;
}
v->res_sprite = (avctx->codec_id == AV_CODEC_ID_VC1IMAGE);
}
v->sprite_output_frame = av_frame_alloc();
if (!v->sprite_output_frame)
avctx->profile = v->profile;
if (v->profile == PROFILE_ADVANCED)
avctx->level = v->level;
avctx->has_b_frames = !!avctx->max_b_frames;
if (v->color_prim == 1 || v->color_prim == 5 || v->color_prim == 6)
avctx->color_primaries = v->color_prim;
if (v->transfer_char == 1 || v->transfer_char == 7)
avctx->color_trc = v->transfer_char;
if (v->matrix_coef == 1 || v->matrix_coef == 6 || v->matrix_coef == 7)
avctx->colorspace = v->matrix_coef;
s->mb_width = (avctx->coded_width + 15) >> 4;
s->mb_height = (avctx->coded_height + 15) >> 4;
if (v->profile == PROFILE_ADVANCED || v->res_fasttx) {
ff_vc1_init_transposed_scantables(v);
} else {
memcpy(v->zz_8x8, ff_wmv1_scantable, 4*64);
v->left_blk_sh = 3;
v->top_blk_sh = 0;
}
if (avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) {
v->sprite_width = avctx->coded_width;
v->sprite_height = avctx->coded_height;
avctx->coded_width = avctx->width = v->output_width;
avctx->coded_height = avctx->height = v->output_height;
// prevent 16.16 overflows
if (v->sprite_width > 1 << 14 ||
v->sprite_height > 1 << 14 ||
v->output_width > 1 << 14 ||
v->output_height > 1 << 14) return -1;
if ((v->sprite_width&1) || (v->sprite_height&1)) {
avpriv_request_sample(avctx, "odd sprites support");
return AVERROR_PATCHWELCOME;
}
}
return 0;
} | true | FFmpeg | a66dcfeedc68c080965cf78e1e0694967acef5af | static av_cold int vc1_decode_init(AVCodecContext *avctx)
{
VC1Context *v = avctx->priv_data;
MpegEncContext *s = &v->s;
GetBitContext gb;
int ret;
v->output_width = avctx->width;
v->output_height = avctx->height;
if (!avctx->extradata_size || !avctx->extradata)
return -1;
if (!(avctx->flags & CODEC_FLAG_GRAY))
avctx->pix_fmt = ff_get_format(avctx, avctx->codec->pix_fmts);
else
avctx->pix_fmt = AV_PIX_FMT_GRAY8;
v->s.avctx = avctx;
if ((ret = ff_vc1_init_common(v)) < 0)
return ret;
if ((ret = ff_msmpeg4_decode_init(avctx)) < 0)
return ret;
if ((ret = ff_vc1_decode_init_alloc_tables(v)) < 0)
return ret;
ff_vc1_decode_end(avctx);
ff_blockdsp_init(&s->bdsp, avctx);
ff_h264chroma_init(&v->h264chroma, 8);
ff_qpeldsp_init(&s->qdsp);
if (avctx->codec_id == AV_CODEC_ID_WMV3 || avctx->codec_id == AV_CODEC_ID_WMV3IMAGE) {
int count = 0;
init_get_bits(&gb, avctx->extradata, avctx->extradata_size*8);
if ((ret = ff_vc1_decode_sequence_header(avctx, v, &gb)) < 0)
return ret;
count = avctx->extradata_size*8 - get_bits_count(&gb);
if (count > 0) {
av_log(avctx, AV_LOG_INFO, "Extra data: %i bits left, value: %X\n",
count, get_bits(&gb, count));
} else if (count < 0) {
av_log(avctx, AV_LOG_INFO, "Read %i bits in overflow\n", -count);
}
} else {
const uint8_t *start = avctx->extradata;
uint8_t *end = avctx->extradata + avctx->extradata_size;
const uint8_t *next;
int size, buf2_size;
uint8_t *buf2 = NULL;
int seq_initialized = 0, ep_initialized = 0;
if (avctx->extradata_size < 16) {
av_log(avctx, AV_LOG_ERROR, "Extradata size too small: %i\n", avctx->extradata_size);
return -1;
}
buf2 = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
start = find_next_marker(start, end);
next = start;
for (; next < end; start = next) {
next = find_next_marker(start + 4, end);
size = next - start - 4;
if (size <= 0)
continue;
buf2_size = vc1_unescape_buffer(start + 4, size, buf2);
init_get_bits(&gb, buf2, buf2_size * 8);
switch (AV_RB32(start)) {
case VC1_CODE_SEQHDR:
if ((ret = ff_vc1_decode_sequence_header(avctx, v, &gb)) < 0) {
av_free(buf2);
return ret;
}
seq_initialized = 1;
break;
case VC1_CODE_ENTRYPOINT:
if ((ret = ff_vc1_decode_entry_point(avctx, v, &gb)) < 0) {
av_free(buf2);
return ret;
}
ep_initialized = 1;
break;
}
}
av_free(buf2);
if (!seq_initialized || !ep_initialized) {
av_log(avctx, AV_LOG_ERROR, "Incomplete extradata\n");
return -1;
}
v->res_sprite = (avctx->codec_id == AV_CODEC_ID_VC1IMAGE);
}
v->sprite_output_frame = av_frame_alloc();
if (!v->sprite_output_frame)
avctx->profile = v->profile;
if (v->profile == PROFILE_ADVANCED)
avctx->level = v->level;
avctx->has_b_frames = !!avctx->max_b_frames;
if (v->color_prim == 1 || v->color_prim == 5 || v->color_prim == 6)
avctx->color_primaries = v->color_prim;
if (v->transfer_char == 1 || v->transfer_char == 7)
avctx->color_trc = v->transfer_char;
if (v->matrix_coef == 1 || v->matrix_coef == 6 || v->matrix_coef == 7)
avctx->colorspace = v->matrix_coef;
s->mb_width = (avctx->coded_width + 15) >> 4;
s->mb_height = (avctx->coded_height + 15) >> 4;
if (v->profile == PROFILE_ADVANCED || v->res_fasttx) {
ff_vc1_init_transposed_scantables(v);
} else {
memcpy(v->zz_8x8, ff_wmv1_scantable, 4*64);
v->left_blk_sh = 3;
v->top_blk_sh = 0;
}
if (avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) {
v->sprite_width = avctx->coded_width;
v->sprite_height = avctx->coded_height;
avctx->coded_width = avctx->width = v->output_width;
avctx->coded_height = avctx->height = v->output_height;
if (v->sprite_width > 1 << 14 ||
v->sprite_height > 1 << 14 ||
v->output_width > 1 << 14 ||
v->output_height > 1 << 14) return -1;
if ((v->sprite_width&1) || (v->sprite_height&1)) {
avpriv_request_sample(avctx, "odd sprites support");
return AVERROR_PATCHWELCOME;
}
}
return 0;
} | {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
VC1Context *v = avctx->priv_data;
MpegEncContext *s = &v->s;
GetBitContext gb;
int VAR_0;
v->output_width = avctx->width;
v->output_height = avctx->height;
if (!avctx->extradata_size || !avctx->extradata)
return -1;
if (!(avctx->flags & CODEC_FLAG_GRAY))
avctx->pix_fmt = ff_get_format(avctx, avctx->codec->pix_fmts);
else
avctx->pix_fmt = AV_PIX_FMT_GRAY8;
v->s.avctx = avctx;
if ((VAR_0 = ff_vc1_init_common(v)) < 0)
return VAR_0;
if ((VAR_0 = ff_msmpeg4_decode_init(avctx)) < 0)
return VAR_0;
if ((VAR_0 = ff_vc1_decode_init_alloc_tables(v)) < 0)
return VAR_0;
ff_vc1_decode_end(avctx);
ff_blockdsp_init(&s->bdsp, avctx);
ff_h264chroma_init(&v->h264chroma, 8);
ff_qpeldsp_init(&s->qdsp);
if (avctx->codec_id == AV_CODEC_ID_WMV3 || avctx->codec_id == AV_CODEC_ID_WMV3IMAGE) {
int VAR_1 = 0;
init_get_bits(&gb, avctx->extradata, avctx->extradata_size*8);
if ((VAR_0 = ff_vc1_decode_sequence_header(avctx, v, &gb)) < 0)
return VAR_0;
VAR_1 = avctx->extradata_size*8 - get_bits_count(&gb);
if (VAR_1 > 0) {
av_log(avctx, AV_LOG_INFO, "Extra data: %i bits left, value: %X\n",
VAR_1, get_bits(&gb, VAR_1));
} else if (VAR_1 < 0) {
av_log(avctx, AV_LOG_INFO, "Read %i bits in overflow\n", -VAR_1);
}
} else {
const uint8_t *VAR_2 = avctx->extradata;
uint8_t *end = avctx->extradata + avctx->extradata_size;
const uint8_t *VAR_3;
int VAR_4, VAR_5;
uint8_t *buf2 = NULL;
int VAR_6 = 0, VAR_7 = 0;
if (avctx->extradata_size < 16) {
av_log(avctx, AV_LOG_ERROR, "Extradata VAR_4 too small: %i\n", avctx->extradata_size);
return -1;
}
buf2 = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
VAR_2 = find_next_marker(VAR_2, end);
VAR_3 = VAR_2;
for (; VAR_3 < end; VAR_2 = VAR_3) {
VAR_3 = find_next_marker(VAR_2 + 4, end);
VAR_4 = VAR_3 - VAR_2 - 4;
if (VAR_4 <= 0)
continue;
VAR_5 = vc1_unescape_buffer(VAR_2 + 4, VAR_4, buf2);
init_get_bits(&gb, buf2, VAR_5 * 8);
switch (AV_RB32(VAR_2)) {
case VC1_CODE_SEQHDR:
if ((VAR_0 = ff_vc1_decode_sequence_header(avctx, v, &gb)) < 0) {
av_free(buf2);
return VAR_0;
}
VAR_6 = 1;
break;
case VC1_CODE_ENTRYPOINT:
if ((VAR_0 = ff_vc1_decode_entry_point(avctx, v, &gb)) < 0) {
av_free(buf2);
return VAR_0;
}
VAR_7 = 1;
break;
}
}
av_free(buf2);
if (!VAR_6 || !VAR_7) {
av_log(avctx, AV_LOG_ERROR, "Incomplete extradata\n");
return -1;
}
v->res_sprite = (avctx->codec_id == AV_CODEC_ID_VC1IMAGE);
}
v->sprite_output_frame = av_frame_alloc();
if (!v->sprite_output_frame)
avctx->profile = v->profile;
if (v->profile == PROFILE_ADVANCED)
avctx->level = v->level;
avctx->has_b_frames = !!avctx->max_b_frames;
if (v->color_prim == 1 || v->color_prim == 5 || v->color_prim == 6)
avctx->color_primaries = v->color_prim;
if (v->transfer_char == 1 || v->transfer_char == 7)
avctx->color_trc = v->transfer_char;
if (v->matrix_coef == 1 || v->matrix_coef == 6 || v->matrix_coef == 7)
avctx->colorspace = v->matrix_coef;
s->mb_width = (avctx->coded_width + 15) >> 4;
s->mb_height = (avctx->coded_height + 15) >> 4;
if (v->profile == PROFILE_ADVANCED || v->res_fasttx) {
ff_vc1_init_transposed_scantables(v);
} else {
memcpy(v->zz_8x8, ff_wmv1_scantable, 4*64);
v->left_blk_sh = 3;
v->top_blk_sh = 0;
}
if (avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) {
v->sprite_width = avctx->coded_width;
v->sprite_height = avctx->coded_height;
avctx->coded_width = avctx->width = v->output_width;
avctx->coded_height = avctx->height = v->output_height;
if (v->sprite_width > 1 << 14 ||
v->sprite_height > 1 << 14 ||
v->output_width > 1 << 14 ||
v->output_height > 1 << 14) return -1;
if ((v->sprite_width&1) || (v->sprite_height&1)) {
avpriv_request_sample(avctx, "odd sprites support");
return AVERROR_PATCHWELCOME;
}
}
return 0;
} | [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"VC1Context *v = avctx->priv_data;",
"MpegEncContext *s = &v->s;",
"GetBitContext gb;",
"int VAR_0;",
"v->output_width = avctx->width;",
"v->output_height = avctx->height;",
"if (!avctx->extradata_size || !avctx->extradata)\nreturn -1;",
"if (!(avctx->flags & CODEC_FLAG_GRAY))\navctx->pix_fmt = ff_get_format(avctx, avctx->codec->pix_fmts);",
"else\navctx->pix_fmt = AV_PIX_FMT_GRAY8;",
"v->s.avctx = avctx;",
"if ((VAR_0 = ff_vc1_init_common(v)) < 0)\nreturn VAR_0;",
"if ((VAR_0 = ff_msmpeg4_decode_init(avctx)) < 0)\nreturn VAR_0;",
"if ((VAR_0 = ff_vc1_decode_init_alloc_tables(v)) < 0)\nreturn VAR_0;",
"ff_vc1_decode_end(avctx);",
"ff_blockdsp_init(&s->bdsp, avctx);",
"ff_h264chroma_init(&v->h264chroma, 8);",
"ff_qpeldsp_init(&s->qdsp);",
"if (avctx->codec_id == AV_CODEC_ID_WMV3 || avctx->codec_id == AV_CODEC_ID_WMV3IMAGE) {",
"int VAR_1 = 0;",
"init_get_bits(&gb, avctx->extradata, avctx->extradata_size*8);",
"if ((VAR_0 = ff_vc1_decode_sequence_header(avctx, v, &gb)) < 0)\nreturn VAR_0;",
"VAR_1 = avctx->extradata_size*8 - get_bits_count(&gb);",
"if (VAR_1 > 0) {",
"av_log(avctx, AV_LOG_INFO, \"Extra data: %i bits left, value: %X\\n\",\nVAR_1, get_bits(&gb, VAR_1));",
"} else if (VAR_1 < 0) {",
"av_log(avctx, AV_LOG_INFO, \"Read %i bits in overflow\\n\", -VAR_1);",
"}",
"} else {",
"const uint8_t *VAR_2 = avctx->extradata;",
"uint8_t *end = avctx->extradata + avctx->extradata_size;",
"const uint8_t *VAR_3;",
"int VAR_4, VAR_5;",
"uint8_t *buf2 = NULL;",
"int VAR_6 = 0, VAR_7 = 0;",
"if (avctx->extradata_size < 16) {",
"av_log(avctx, AV_LOG_ERROR, \"Extradata VAR_4 too small: %i\\n\", avctx->extradata_size);",
"return -1;",
"}",
"buf2 = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);",
"VAR_2 = find_next_marker(VAR_2, end);",
"VAR_3 = VAR_2;",
"for (; VAR_3 < end; VAR_2 = VAR_3) {",
"VAR_3 = find_next_marker(VAR_2 + 4, end);",
"VAR_4 = VAR_3 - VAR_2 - 4;",
"if (VAR_4 <= 0)\ncontinue;",
"VAR_5 = vc1_unescape_buffer(VAR_2 + 4, VAR_4, buf2);",
"init_get_bits(&gb, buf2, VAR_5 * 8);",
"switch (AV_RB32(VAR_2)) {",
"case VC1_CODE_SEQHDR:\nif ((VAR_0 = ff_vc1_decode_sequence_header(avctx, v, &gb)) < 0) {",
"av_free(buf2);",
"return VAR_0;",
"}",
"VAR_6 = 1;",
"break;",
"case VC1_CODE_ENTRYPOINT:\nif ((VAR_0 = ff_vc1_decode_entry_point(avctx, v, &gb)) < 0) {",
"av_free(buf2);",
"return VAR_0;",
"}",
"VAR_7 = 1;",
"break;",
"}",
"}",
"av_free(buf2);",
"if (!VAR_6 || !VAR_7) {",
"av_log(avctx, AV_LOG_ERROR, \"Incomplete extradata\\n\");",
"return -1;",
"}",
"v->res_sprite = (avctx->codec_id == AV_CODEC_ID_VC1IMAGE);",
"}",
"v->sprite_output_frame = av_frame_alloc();",
"if (!v->sprite_output_frame)\navctx->profile = v->profile;",
"if (v->profile == PROFILE_ADVANCED)\navctx->level = v->level;",
"avctx->has_b_frames = !!avctx->max_b_frames;",
"if (v->color_prim == 1 || v->color_prim == 5 || v->color_prim == 6)\navctx->color_primaries = v->color_prim;",
"if (v->transfer_char == 1 || v->transfer_char == 7)\navctx->color_trc = v->transfer_char;",
"if (v->matrix_coef == 1 || v->matrix_coef == 6 || v->matrix_coef == 7)\navctx->colorspace = v->matrix_coef;",
"s->mb_width = (avctx->coded_width + 15) >> 4;",
"s->mb_height = (avctx->coded_height + 15) >> 4;",
"if (v->profile == PROFILE_ADVANCED || v->res_fasttx) {",
"ff_vc1_init_transposed_scantables(v);",
"} else {",
"memcpy(v->zz_8x8, ff_wmv1_scantable, 4*64);",
"v->left_blk_sh = 3;",
"v->top_blk_sh = 0;",
"}",
"if (avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) {",
"v->sprite_width = avctx->coded_width;",
"v->sprite_height = avctx->coded_height;",
"avctx->coded_width = avctx->width = v->output_width;",
"avctx->coded_height = avctx->height = v->output_height;",
"if (v->sprite_width > 1 << 14 ||\nv->sprite_height > 1 << 14 ||\nv->output_width > 1 << 14 ||\nv->output_height > 1 << 14) return -1;",
"if ((v->sprite_width&1) || (v->sprite_height&1)) {",
"avpriv_request_sample(avctx, \"odd sprites support\");",
"return AVERROR_PATCHWELCOME;",
"}",
"}",
"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
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
8
],
[
9
],
[
10,
11
],
[
12,
13
],
[
14,
15
],
[
16
],
[
17,
18
],
[
20,
21
],
[
22,
23
],
[
27
],
[
28
],
[
29
],
[
30
],
[
31
],
[
32
],
[
37
],
[
38,
39
],
[
40
],
[
41
],
[
42,
43
],
[
44
],
[
45
],
[
46
],
[
47
],
[
48
],
[
49
],
[
50
],
[
51
],
[
52
],
[
53
],
[
54
],
[
55
],
[
56
],
[
57
],
[
58
],
[
59
],
[
60
],
[
61
],
[
62
],
[
63
],
[
64,
65
],
[
66
],
[
67
],
[
68
],
[
69,
70
],
[
71
],
[
72
],
[
73
],
[
74
],
[
75
],
[
76,
77
],
[
78
],
[
79
],
[
80
],
[
81
],
[
82
],
[
83
],
[
84
],
[
85
],
[
86
],
[
87
],
[
88
],
[
89
],
[
90
],
[
91
],
[
92
],
[
93,
94
],
[
95,
96
],
[
97
],
[
98,
99
],
[
100,
101
],
[
102,
103
],
[
104
],
[
105
],
[
106
],
[
107
],
[
108
],
[
109
],
[
110
],
[
111
],
[
112
],
[
113
],
[
114
],
[
115
],
[
116
],
[
117
],
[
119,
120,
121,
122
],
[
123
],
[
124
],
[
125
],
[
126
],
[
127
],
[
128
],
[
129
]
] |
25,953 | int ff_h264_fill_default_ref_list(H264Context *h)
{
int i, len;
if (h->slice_type_nos == AV_PICTURE_TYPE_B) {
Picture *sorted[32];
int cur_poc, list;
int lens[2];
if (FIELD_PICTURE(h))
cur_poc = h->cur_pic_ptr->field_poc[h->picture_structure == PICT_BOTTOM_FIELD];
else
cur_poc = h->cur_pic_ptr->poc;
for (list = 0; list < 2; list++) {
len = add_sorted(sorted, h->short_ref, h->short_ref_count, cur_poc, 1 ^ list);
len += add_sorted(sorted + len, h->short_ref, h->short_ref_count, cur_poc, 0 ^ list);
assert(len <= 32);
len = build_def_list(h->default_ref_list[list], sorted, len, 0, h->picture_structure);
len += build_def_list(h->default_ref_list[list] + len, h->long_ref, 16, 1, h->picture_structure);
assert(len <= 32);
if (len < h->ref_count[list])
memset(&h->default_ref_list[list][len], 0, sizeof(Picture) * (h->ref_count[list] - len));
lens[list] = len;
}
if (lens[0] == lens[1] && lens[1] > 1) {
for (i = 0; i < lens[0] &&
h->default_ref_list[0][i].f.buf[0]->buffer ==
h->default_ref_list[1][i].f.buf[0]->buffer; i++);
if (i == lens[0]) {
Picture tmp;
COPY_PICTURE(&tmp, &h->default_ref_list[1][0]);
COPY_PICTURE(&h->default_ref_list[1][0], &h->default_ref_list[1][1]);
COPY_PICTURE(&h->default_ref_list[1][1], &tmp);
}
}
} else {
len = build_def_list(h->default_ref_list[0], h->short_ref, h->short_ref_count, 0, h->picture_structure);
len += build_def_list(h->default_ref_list[0] + len, h-> long_ref, 16, 1, h->picture_structure);
assert(len <= 32);
if (len < h->ref_count[0])
memset(&h->default_ref_list[0][len], 0, sizeof(Picture) * (h->ref_count[0] - len));
}
#ifdef TRACE
for (i = 0; i < h->ref_count[0]; i++) {
tprintf(h->avctx, "List0: %s fn:%d 0x%p\n",
(h->default_ref_list[0][i].long_ref ? "LT" : "ST"),
h->default_ref_list[0][i].pic_id,
h->default_ref_list[0][i].f.data[0]);
}
if (h->slice_type_nos == AV_PICTURE_TYPE_B) {
for (i = 0; i < h->ref_count[1]; i++) {
tprintf(h->avctx, "List1: %s fn:%d 0x%p\n",
(h->default_ref_list[1][i].long_ref ? "LT" : "ST"),
h->default_ref_list[1][i].pic_id,
h->default_ref_list[1][i].f.data[0]);
}
}
#endif
return 0;
}
| true | FFmpeg | 4d388c0cd05dd4de545e8ea333ab4de7d67ad12d | int ff_h264_fill_default_ref_list(H264Context *h)
{
int i, len;
if (h->slice_type_nos == AV_PICTURE_TYPE_B) {
Picture *sorted[32];
int cur_poc, list;
int lens[2];
if (FIELD_PICTURE(h))
cur_poc = h->cur_pic_ptr->field_poc[h->picture_structure == PICT_BOTTOM_FIELD];
else
cur_poc = h->cur_pic_ptr->poc;
for (list = 0; list < 2; list++) {
len = add_sorted(sorted, h->short_ref, h->short_ref_count, cur_poc, 1 ^ list);
len += add_sorted(sorted + len, h->short_ref, h->short_ref_count, cur_poc, 0 ^ list);
assert(len <= 32);
len = build_def_list(h->default_ref_list[list], sorted, len, 0, h->picture_structure);
len += build_def_list(h->default_ref_list[list] + len, h->long_ref, 16, 1, h->picture_structure);
assert(len <= 32);
if (len < h->ref_count[list])
memset(&h->default_ref_list[list][len], 0, sizeof(Picture) * (h->ref_count[list] - len));
lens[list] = len;
}
if (lens[0] == lens[1] && lens[1] > 1) {
for (i = 0; i < lens[0] &&
h->default_ref_list[0][i].f.buf[0]->buffer ==
h->default_ref_list[1][i].f.buf[0]->buffer; i++);
if (i == lens[0]) {
Picture tmp;
COPY_PICTURE(&tmp, &h->default_ref_list[1][0]);
COPY_PICTURE(&h->default_ref_list[1][0], &h->default_ref_list[1][1]);
COPY_PICTURE(&h->default_ref_list[1][1], &tmp);
}
}
} else {
len = build_def_list(h->default_ref_list[0], h->short_ref, h->short_ref_count, 0, h->picture_structure);
len += build_def_list(h->default_ref_list[0] + len, h-> long_ref, 16, 1, h->picture_structure);
assert(len <= 32);
if (len < h->ref_count[0])
memset(&h->default_ref_list[0][len], 0, sizeof(Picture) * (h->ref_count[0] - len));
}
#ifdef TRACE
for (i = 0; i < h->ref_count[0]; i++) {
tprintf(h->avctx, "List0: %s fn:%d 0x%p\n",
(h->default_ref_list[0][i].long_ref ? "LT" : "ST"),
h->default_ref_list[0][i].pic_id,
h->default_ref_list[0][i].f.data[0]);
}
if (h->slice_type_nos == AV_PICTURE_TYPE_B) {
for (i = 0; i < h->ref_count[1]; i++) {
tprintf(h->avctx, "List1: %s fn:%d 0x%p\n",
(h->default_ref_list[1][i].long_ref ? "LT" : "ST"),
h->default_ref_list[1][i].pic_id,
h->default_ref_list[1][i].f.data[0]);
}
}
#endif
return 0;
}
| {
"code": [
" len = build_def_list(h->default_ref_list[list], sorted, len, 0, h->picture_structure);",
" len += build_def_list(h->default_ref_list[list] + len, h->long_ref, 16, 1, h->picture_structure);",
" assert(len <= 32);",
" len = build_def_list(h->default_ref_list[0], h->short_ref, h->short_ref_count, 0, h->picture_structure);",
" len += build_def_list(h->default_ref_list[0] + len, h-> long_ref, 16, 1, h->picture_structure);",
" assert(len <= 32);"
],
"line_no": [
37,
39,
35,
79,
81,
83
]
} | int FUNC_0(H264Context *VAR_0)
{
int VAR_1, VAR_2;
if (VAR_0->slice_type_nos == AV_PICTURE_TYPE_B) {
Picture *sorted[32];
int VAR_3, VAR_4;
int VAR_5[2];
if (FIELD_PICTURE(VAR_0))
VAR_3 = VAR_0->cur_pic_ptr->field_poc[VAR_0->picture_structure == PICT_BOTTOM_FIELD];
else
VAR_3 = VAR_0->cur_pic_ptr->poc;
for (VAR_4 = 0; VAR_4 < 2; VAR_4++) {
VAR_2 = add_sorted(sorted, VAR_0->short_ref, VAR_0->short_ref_count, VAR_3, 1 ^ VAR_4);
VAR_2 += add_sorted(sorted + VAR_2, VAR_0->short_ref, VAR_0->short_ref_count, VAR_3, 0 ^ VAR_4);
assert(VAR_2 <= 32);
VAR_2 = build_def_list(VAR_0->default_ref_list[VAR_4], sorted, VAR_2, 0, VAR_0->picture_structure);
VAR_2 += build_def_list(VAR_0->default_ref_list[VAR_4] + VAR_2, VAR_0->long_ref, 16, 1, VAR_0->picture_structure);
assert(VAR_2 <= 32);
if (VAR_2 < VAR_0->ref_count[VAR_4])
memset(&VAR_0->default_ref_list[VAR_4][VAR_2], 0, sizeof(Picture) * (VAR_0->ref_count[VAR_4] - VAR_2));
VAR_5[VAR_4] = VAR_2;
}
if (VAR_5[0] == VAR_5[1] && VAR_5[1] > 1) {
for (VAR_1 = 0; VAR_1 < VAR_5[0] &&
VAR_0->default_ref_list[0][VAR_1].f.buf[0]->buffer ==
VAR_0->default_ref_list[1][VAR_1].f.buf[0]->buffer; VAR_1++);
if (VAR_1 == VAR_5[0]) {
Picture tmp;
COPY_PICTURE(&tmp, &VAR_0->default_ref_list[1][0]);
COPY_PICTURE(&VAR_0->default_ref_list[1][0], &VAR_0->default_ref_list[1][1]);
COPY_PICTURE(&VAR_0->default_ref_list[1][1], &tmp);
}
}
} else {
VAR_2 = build_def_list(VAR_0->default_ref_list[0], VAR_0->short_ref, VAR_0->short_ref_count, 0, VAR_0->picture_structure);
VAR_2 += build_def_list(VAR_0->default_ref_list[0] + VAR_2, VAR_0-> long_ref, 16, 1, VAR_0->picture_structure);
assert(VAR_2 <= 32);
if (VAR_2 < VAR_0->ref_count[0])
memset(&VAR_0->default_ref_list[0][VAR_2], 0, sizeof(Picture) * (VAR_0->ref_count[0] - VAR_2));
}
#ifdef TRACE
for (VAR_1 = 0; VAR_1 < VAR_0->ref_count[0]; VAR_1++) {
tprintf(VAR_0->avctx, "List0: %s fn:%d 0x%p\n",
(VAR_0->default_ref_list[0][VAR_1].long_ref ? "LT" : "ST"),
VAR_0->default_ref_list[0][VAR_1].pic_id,
VAR_0->default_ref_list[0][VAR_1].f.data[0]);
}
if (VAR_0->slice_type_nos == AV_PICTURE_TYPE_B) {
for (VAR_1 = 0; VAR_1 < VAR_0->ref_count[1]; VAR_1++) {
tprintf(VAR_0->avctx, "List1: %s fn:%d 0x%p\n",
(VAR_0->default_ref_list[1][VAR_1].long_ref ? "LT" : "ST"),
VAR_0->default_ref_list[1][VAR_1].pic_id,
VAR_0->default_ref_list[1][VAR_1].f.data[0]);
}
}
#endif
return 0;
}
| [
"int FUNC_0(H264Context *VAR_0)\n{",
"int VAR_1, VAR_2;",
"if (VAR_0->slice_type_nos == AV_PICTURE_TYPE_B) {",
"Picture *sorted[32];",
"int VAR_3, VAR_4;",
"int VAR_5[2];",
"if (FIELD_PICTURE(VAR_0))\nVAR_3 = VAR_0->cur_pic_ptr->field_poc[VAR_0->picture_structure == PICT_BOTTOM_FIELD];",
"else\nVAR_3 = VAR_0->cur_pic_ptr->poc;",
"for (VAR_4 = 0; VAR_4 < 2; VAR_4++) {",
"VAR_2 = add_sorted(sorted, VAR_0->short_ref, VAR_0->short_ref_count, VAR_3, 1 ^ VAR_4);",
"VAR_2 += add_sorted(sorted + VAR_2, VAR_0->short_ref, VAR_0->short_ref_count, VAR_3, 0 ^ VAR_4);",
"assert(VAR_2 <= 32);",
"VAR_2 = build_def_list(VAR_0->default_ref_list[VAR_4], sorted, VAR_2, 0, VAR_0->picture_structure);",
"VAR_2 += build_def_list(VAR_0->default_ref_list[VAR_4] + VAR_2, VAR_0->long_ref, 16, 1, VAR_0->picture_structure);",
"assert(VAR_2 <= 32);",
"if (VAR_2 < VAR_0->ref_count[VAR_4])\nmemset(&VAR_0->default_ref_list[VAR_4][VAR_2], 0, sizeof(Picture) * (VAR_0->ref_count[VAR_4] - VAR_2));",
"VAR_5[VAR_4] = VAR_2;",
"}",
"if (VAR_5[0] == VAR_5[1] && VAR_5[1] > 1) {",
"for (VAR_1 = 0; VAR_1 < VAR_5[0] &&",
"VAR_0->default_ref_list[0][VAR_1].f.buf[0]->buffer ==\nVAR_0->default_ref_list[1][VAR_1].f.buf[0]->buffer; VAR_1++);",
"if (VAR_1 == VAR_5[0]) {",
"Picture tmp;",
"COPY_PICTURE(&tmp, &VAR_0->default_ref_list[1][0]);",
"COPY_PICTURE(&VAR_0->default_ref_list[1][0], &VAR_0->default_ref_list[1][1]);",
"COPY_PICTURE(&VAR_0->default_ref_list[1][1], &tmp);",
"}",
"}",
"} else {",
"VAR_2 = build_def_list(VAR_0->default_ref_list[0], VAR_0->short_ref, VAR_0->short_ref_count, 0, VAR_0->picture_structure);",
"VAR_2 += build_def_list(VAR_0->default_ref_list[0] + VAR_2, VAR_0-> long_ref, 16, 1, VAR_0->picture_structure);",
"assert(VAR_2 <= 32);",
"if (VAR_2 < VAR_0->ref_count[0])\nmemset(&VAR_0->default_ref_list[0][VAR_2], 0, sizeof(Picture) * (VAR_0->ref_count[0] - VAR_2));",
"}",
"#ifdef TRACE\nfor (VAR_1 = 0; VAR_1 < VAR_0->ref_count[0]; VAR_1++) {",
"tprintf(VAR_0->avctx, \"List0: %s fn:%d 0x%p\\n\",\n(VAR_0->default_ref_list[0][VAR_1].long_ref ? \"LT\" : \"ST\"),\nVAR_0->default_ref_list[0][VAR_1].pic_id,\nVAR_0->default_ref_list[0][VAR_1].f.data[0]);",
"}",
"if (VAR_0->slice_type_nos == AV_PICTURE_TYPE_B) {",
"for (VAR_1 = 0; VAR_1 < VAR_0->ref_count[1]; VAR_1++) {",
"tprintf(VAR_0->avctx, \"List1: %s fn:%d 0x%p\\n\",\n(VAR_0->default_ref_list[1][VAR_1].long_ref ? \"LT\" : \"ST\"),\nVAR_0->default_ref_list[1][VAR_1].pic_id,\nVAR_0->default_ref_list[1][VAR_1].f.data[0]);",
"}",
"}",
"#endif\nreturn 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
21
],
[
23,
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45,
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85,
87
],
[
89
],
[
91,
93
],
[
95,
97,
99,
101
],
[
103
],
[
105
],
[
107
],
[
109,
111,
113,
115
],
[
117
],
[
119
],
[
121,
123
],
[
125
]
] |
25,954 | static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
{
AVFilterContext *ctx = link->dst;
CropContext *crop = ctx->priv;
AVFilterBufferRef *ref2;
int i;
picref->video->w = crop->w;
picref->video->h = crop->h;
ref2 = avfilter_ref_buffer(picref, ~0);
crop->var_values[VAR_T] = picref->pts == AV_NOPTS_VALUE ?
NAN : picref->pts * av_q2d(link->time_base);
crop->var_values[VAR_POS] = picref->pos == -1 ? NAN : picref->pos;
crop->var_values[VAR_X] = av_expr_eval(crop->x_pexpr, crop->var_values, NULL);
crop->var_values[VAR_Y] = av_expr_eval(crop->y_pexpr, crop->var_values, NULL);
crop->var_values[VAR_X] = av_expr_eval(crop->x_pexpr, crop->var_values, NULL);
normalize_double(&crop->x, crop->var_values[VAR_X]);
normalize_double(&crop->y, crop->var_values[VAR_Y]);
if (crop->x < 0) crop->x = 0;
if (crop->y < 0) crop->y = 0;
if ((unsigned)crop->x + (unsigned)crop->w > link->w) crop->x = link->w - crop->w;
if ((unsigned)crop->y + (unsigned)crop->h > link->h) crop->y = link->h - crop->h;
crop->x &= ~((1 << crop->hsub) - 1);
crop->y &= ~((1 << crop->vsub) - 1);
av_log(ctx, AV_LOG_DEBUG,
"n:%d t:%f x:%d y:%d x+w:%d y+h:%d\n",
(int)crop->var_values[VAR_N], crop->var_values[VAR_T], crop->x, crop->y, crop->x+crop->w, crop->y+crop->h);
ref2->data[0] += crop->y * ref2->linesize[0];
ref2->data[0] += crop->x * crop->max_step[0];
if (!(av_pix_fmt_descriptors[link->format].flags & PIX_FMT_PAL)) {
for (i = 1; i < 3; i ++) {
if (ref2->data[i]) {
ref2->data[i] += (crop->y >> crop->vsub) * ref2->linesize[i];
ref2->data[i] += (crop->x * crop->max_step[i]) >> crop->hsub;
}
}
}
/* alpha plane */
if (ref2->data[3]) {
ref2->data[3] += crop->y * ref2->linesize[3];
ref2->data[3] += crop->x * crop->max_step[3];
}
avfilter_start_frame(link->dst->outputs[0], ref2);
} | true | FFmpeg | b4356e4118b6cbe3a6ed81d16369acc5ff40ad05 | static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
{
AVFilterContext *ctx = link->dst;
CropContext *crop = ctx->priv;
AVFilterBufferRef *ref2;
int i;
picref->video->w = crop->w;
picref->video->h = crop->h;
ref2 = avfilter_ref_buffer(picref, ~0);
crop->var_values[VAR_T] = picref->pts == AV_NOPTS_VALUE ?
NAN : picref->pts * av_q2d(link->time_base);
crop->var_values[VAR_POS] = picref->pos == -1 ? NAN : picref->pos;
crop->var_values[VAR_X] = av_expr_eval(crop->x_pexpr, crop->var_values, NULL);
crop->var_values[VAR_Y] = av_expr_eval(crop->y_pexpr, crop->var_values, NULL);
crop->var_values[VAR_X] = av_expr_eval(crop->x_pexpr, crop->var_values, NULL);
normalize_double(&crop->x, crop->var_values[VAR_X]);
normalize_double(&crop->y, crop->var_values[VAR_Y]);
if (crop->x < 0) crop->x = 0;
if (crop->y < 0) crop->y = 0;
if ((unsigned)crop->x + (unsigned)crop->w > link->w) crop->x = link->w - crop->w;
if ((unsigned)crop->y + (unsigned)crop->h > link->h) crop->y = link->h - crop->h;
crop->x &= ~((1 << crop->hsub) - 1);
crop->y &= ~((1 << crop->vsub) - 1);
av_log(ctx, AV_LOG_DEBUG,
"n:%d t:%f x:%d y:%d x+w:%d y+h:%d\n",
(int)crop->var_values[VAR_N], crop->var_values[VAR_T], crop->x, crop->y, crop->x+crop->w, crop->y+crop->h);
ref2->data[0] += crop->y * ref2->linesize[0];
ref2->data[0] += crop->x * crop->max_step[0];
if (!(av_pix_fmt_descriptors[link->format].flags & PIX_FMT_PAL)) {
for (i = 1; i < 3; i ++) {
if (ref2->data[i]) {
ref2->data[i] += (crop->y >> crop->vsub) * ref2->linesize[i];
ref2->data[i] += (crop->x * crop->max_step[i]) >> crop->hsub;
}
}
}
if (ref2->data[3]) {
ref2->data[3] += crop->y * ref2->linesize[3];
ref2->data[3] += crop->x * crop->max_step[3];
}
avfilter_start_frame(link->dst->outputs[0], ref2);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(AVFilterLink *VAR_0, AVFilterBufferRef *VAR_1)
{
AVFilterContext *ctx = VAR_0->dst;
CropContext *crop = ctx->priv;
AVFilterBufferRef *ref2;
int VAR_2;
VAR_1->video->w = crop->w;
VAR_1->video->h = crop->h;
ref2 = avfilter_ref_buffer(VAR_1, ~0);
crop->var_values[VAR_T] = VAR_1->pts == AV_NOPTS_VALUE ?
NAN : VAR_1->pts * av_q2d(VAR_0->time_base);
crop->var_values[VAR_POS] = VAR_1->pos == -1 ? NAN : VAR_1->pos;
crop->var_values[VAR_X] = av_expr_eval(crop->x_pexpr, crop->var_values, NULL);
crop->var_values[VAR_Y] = av_expr_eval(crop->y_pexpr, crop->var_values, NULL);
crop->var_values[VAR_X] = av_expr_eval(crop->x_pexpr, crop->var_values, NULL);
normalize_double(&crop->x, crop->var_values[VAR_X]);
normalize_double(&crop->y, crop->var_values[VAR_Y]);
if (crop->x < 0) crop->x = 0;
if (crop->y < 0) crop->y = 0;
if ((unsigned)crop->x + (unsigned)crop->w > VAR_0->w) crop->x = VAR_0->w - crop->w;
if ((unsigned)crop->y + (unsigned)crop->h > VAR_0->h) crop->y = VAR_0->h - crop->h;
crop->x &= ~((1 << crop->hsub) - 1);
crop->y &= ~((1 << crop->vsub) - 1);
av_log(ctx, AV_LOG_DEBUG,
"n:%d t:%f x:%d y:%d x+w:%d y+h:%d\n",
(int)crop->var_values[VAR_N], crop->var_values[VAR_T], crop->x, crop->y, crop->x+crop->w, crop->y+crop->h);
ref2->data[0] += crop->y * ref2->linesize[0];
ref2->data[0] += crop->x * crop->max_step[0];
if (!(av_pix_fmt_descriptors[VAR_0->format].flags & PIX_FMT_PAL)) {
for (VAR_2 = 1; VAR_2 < 3; VAR_2 ++) {
if (ref2->data[VAR_2]) {
ref2->data[VAR_2] += (crop->y >> crop->vsub) * ref2->linesize[VAR_2];
ref2->data[VAR_2] += (crop->x * crop->max_step[VAR_2]) >> crop->hsub;
}
}
}
if (ref2->data[3]) {
ref2->data[3] += crop->y * ref2->linesize[3];
ref2->data[3] += crop->x * crop->max_step[3];
}
avfilter_start_frame(VAR_0->dst->outputs[0], ref2);
} | [
"static void FUNC_0(AVFilterLink *VAR_0, AVFilterBufferRef *VAR_1)\n{",
"AVFilterContext *ctx = VAR_0->dst;",
"CropContext *crop = ctx->priv;",
"AVFilterBufferRef *ref2;",
"int VAR_2;",
"VAR_1->video->w = crop->w;",
"VAR_1->video->h = crop->h;",
"ref2 = avfilter_ref_buffer(VAR_1, ~0);",
"crop->var_values[VAR_T] = VAR_1->pts == AV_NOPTS_VALUE ?\nNAN : VAR_1->pts * av_q2d(VAR_0->time_base);",
"crop->var_values[VAR_POS] = VAR_1->pos == -1 ? NAN : VAR_1->pos;",
"crop->var_values[VAR_X] = av_expr_eval(crop->x_pexpr, crop->var_values, NULL);",
"crop->var_values[VAR_Y] = av_expr_eval(crop->y_pexpr, crop->var_values, NULL);",
"crop->var_values[VAR_X] = av_expr_eval(crop->x_pexpr, crop->var_values, NULL);",
"normalize_double(&crop->x, crop->var_values[VAR_X]);",
"normalize_double(&crop->y, crop->var_values[VAR_Y]);",
"if (crop->x < 0) crop->x = 0;",
"if (crop->y < 0) crop->y = 0;",
"if ((unsigned)crop->x + (unsigned)crop->w > VAR_0->w) crop->x = VAR_0->w - crop->w;",
"if ((unsigned)crop->y + (unsigned)crop->h > VAR_0->h) crop->y = VAR_0->h - crop->h;",
"crop->x &= ~((1 << crop->hsub) - 1);",
"crop->y &= ~((1 << crop->vsub) - 1);",
"av_log(ctx, AV_LOG_DEBUG,\n\"n:%d t:%f x:%d y:%d x+w:%d y+h:%d\\n\",\n(int)crop->var_values[VAR_N], crop->var_values[VAR_T], crop->x, crop->y, crop->x+crop->w, crop->y+crop->h);",
"ref2->data[0] += crop->y * ref2->linesize[0];",
"ref2->data[0] += crop->x * crop->max_step[0];",
"if (!(av_pix_fmt_descriptors[VAR_0->format].flags & PIX_FMT_PAL)) {",
"for (VAR_2 = 1; VAR_2 < 3; VAR_2 ++) {",
"if (ref2->data[VAR_2]) {",
"ref2->data[VAR_2] += (crop->y >> crop->vsub) * ref2->linesize[VAR_2];",
"ref2->data[VAR_2] += (crop->x * crop->max_step[VAR_2]) >> crop->hsub;",
"}",
"}",
"}",
"if (ref2->data[3]) {",
"ref2->data[3] += crop->y * ref2->linesize[3];",
"ref2->data[3] += crop->x * crop->max_step[3];",
"}",
"avfilter_start_frame(VAR_0->dst->outputs[0], ref2);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
60,
62,
64
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
]
] |
25,955 | static void gen_tlbsx_440(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
TCGv t0;
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
t0 = tcg_temp_new();
gen_addr_reg_index(ctx, t0);
gen_helper_440_tlbsx(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
tcg_temp_free(t0);
if (Rc(ctx->opcode)) {
TCGLabel *l1 = gen_new_label();
tcg_gen_trunc_tl_i32(cpu_crf[0], cpu_so);
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_gpr[rD(ctx->opcode)], -1, l1);
tcg_gen_ori_i32(cpu_crf[0], cpu_crf[0], 0x02);
gen_set_label(l1);
}
#endif
}
| true | qemu | 9b2fadda3e0196ffd485adde4fe9cdd6fae35300 | static void gen_tlbsx_440(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
TCGv t0;
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
t0 = tcg_temp_new();
gen_addr_reg_index(ctx, t0);
gen_helper_440_tlbsx(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
tcg_temp_free(t0);
if (Rc(ctx->opcode)) {
TCGLabel *l1 = gen_new_label();
tcg_gen_trunc_tl_i32(cpu_crf[0], cpu_so);
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_gpr[rD(ctx->opcode)], -1, l1);
tcg_gen_ori_i32(cpu_crf[0], cpu_crf[0], 0x02);
gen_set_label(l1);
}
#endif
}
| {
"code": [
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
"#endif",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif"
],
"line_no": [
15,
7,
13,
15,
7,
13,
15,
7,
15,
5,
9,
13,
43,
5,
9,
13,
43,
43,
5,
9,
13,
7,
13,
15,
43,
13,
43,
13,
43,
13,
43,
13,
43,
13,
43,
13,
43,
13,
43,
13,
43,
13,
43,
13,
43,
13,
43,
7,
15,
43,
7,
13,
15,
43,
7,
15,
43,
7,
15,
43,
7,
13,
15,
43,
7,
13,
15,
43,
43,
7,
13,
15,
43,
7,
13,
15,
43,
7,
13,
15,
43,
7,
13,
15,
43,
7,
13,
15,
43,
7,
13,
15,
43,
7,
13,
15,
43,
7,
13,
15,
43,
7,
13,
15,
43,
7,
13,
15,
43,
13,
43,
13,
43,
13,
43,
13,
43,
5,
7,
9,
13,
15,
43,
7,
13,
15,
43,
5,
7,
9,
13,
15,
43,
5,
7,
9,
13,
15,
43,
7,
13,
15,
43,
7,
13,
15,
43,
7,
13,
15,
43,
7,
13,
15,
43,
7,
13,
15,
43,
7,
13,
15,
43,
7,
13,
15,
43,
7,
13,
15,
43,
7,
13,
15,
43,
7,
13,
15,
43,
5,
7,
13,
15,
43,
7,
13,
15,
43,
7,
13,
15,
43,
7,
13,
15,
43,
7,
13,
15,
43,
7,
13,
15,
43,
7,
13,
15,
43,
7,
13,
15,
43,
7,
13,
15,
43
]
} | static void FUNC_0(DisasContext *VAR_0)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);
#else
TCGv t0;
if (unlikely(VAR_0->pr)) {
gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);
return;
}
t0 = tcg_temp_new();
gen_addr_reg_index(VAR_0, t0);
gen_helper_440_tlbsx(cpu_gpr[rD(VAR_0->opcode)], cpu_env, t0);
tcg_temp_free(t0);
if (Rc(VAR_0->opcode)) {
TCGLabel *l1 = gen_new_label();
tcg_gen_trunc_tl_i32(cpu_crf[0], cpu_so);
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_gpr[rD(VAR_0->opcode)], -1, l1);
tcg_gen_ori_i32(cpu_crf[0], cpu_crf[0], 0x02);
gen_set_label(l1);
}
#endif
}
| [
"static void FUNC_0(DisasContext *VAR_0)\n{",
"#if defined(CONFIG_USER_ONLY)\ngen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);",
"#else\nTCGv t0;",
"if (unlikely(VAR_0->pr)) {",
"gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);",
"return;",
"}",
"t0 = tcg_temp_new();",
"gen_addr_reg_index(VAR_0, t0);",
"gen_helper_440_tlbsx(cpu_gpr[rD(VAR_0->opcode)], cpu_env, t0);",
"tcg_temp_free(t0);",
"if (Rc(VAR_0->opcode)) {",
"TCGLabel *l1 = gen_new_label();",
"tcg_gen_trunc_tl_i32(cpu_crf[0], cpu_so);",
"tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_gpr[rD(VAR_0->opcode)], -1, l1);",
"tcg_gen_ori_i32(cpu_crf[0], cpu_crf[0], 0x02);",
"gen_set_label(l1);",
"}",
"#endif\n}"
] | [
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1
] | [
[
1,
3
],
[
5,
7
],
[
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
]
] |
25,956 | static void blockdev_backup_prepare(BlkActionState *common, Error **errp)
{
BlockdevBackupState *state = DO_UPCAST(BlockdevBackupState, common, common);
BlockdevBackup *backup;
BlockDriverState *bs, *target;
Error *local_err = NULL;
assert(common->action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP);
backup = common->action->u.blockdev_backup.data;
bs = qmp_get_root_bs(backup->device, errp);
if (!bs) {
return;
}
target = bdrv_lookup_bs(backup->target, backup->target, errp);
if (!target) {
return;
}
/* AioContext is released in .clean() */
state->aio_context = bdrv_get_aio_context(bs);
if (state->aio_context != bdrv_get_aio_context(target)) {
state->aio_context = NULL;
error_setg(errp, "Backup between two IO threads is not implemented");
return;
}
aio_context_acquire(state->aio_context);
state->bs = bs;
bdrv_drained_begin(state->bs);
do_blockdev_backup(backup, common->block_job_txn, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
state->job = state->bs->job;
}
| true | qemu | 111049a4ecefc9cf1ac75c773f4c5c165f27fe63 | static void blockdev_backup_prepare(BlkActionState *common, Error **errp)
{
BlockdevBackupState *state = DO_UPCAST(BlockdevBackupState, common, common);
BlockdevBackup *backup;
BlockDriverState *bs, *target;
Error *local_err = NULL;
assert(common->action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP);
backup = common->action->u.blockdev_backup.data;
bs = qmp_get_root_bs(backup->device, errp);
if (!bs) {
return;
}
target = bdrv_lookup_bs(backup->target, backup->target, errp);
if (!target) {
return;
}
state->aio_context = bdrv_get_aio_context(bs);
if (state->aio_context != bdrv_get_aio_context(target)) {
state->aio_context = NULL;
error_setg(errp, "Backup between two IO threads is not implemented");
return;
}
aio_context_acquire(state->aio_context);
state->bs = bs;
bdrv_drained_begin(state->bs);
do_blockdev_backup(backup, common->block_job_txn, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
state->job = state->bs->job;
}
| {
"code": [
" state->job = state->bs->job;",
" do_blockdev_backup(backup, common->block_job_txn, &local_err);",
" state->job = state->bs->job;"
],
"line_no": [
75,
63,
75
]
} | static void FUNC_0(BlkActionState *VAR_0, Error **VAR_1)
{
BlockdevBackupState *state = DO_UPCAST(BlockdevBackupState, VAR_0, VAR_0);
BlockdevBackup *backup;
BlockDriverState *bs, *target;
Error *local_err = NULL;
assert(VAR_0->action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP);
backup = VAR_0->action->u.blockdev_backup.data;
bs = qmp_get_root_bs(backup->device, VAR_1);
if (!bs) {
return;
}
target = bdrv_lookup_bs(backup->target, backup->target, VAR_1);
if (!target) {
return;
}
state->aio_context = bdrv_get_aio_context(bs);
if (state->aio_context != bdrv_get_aio_context(target)) {
state->aio_context = NULL;
error_setg(VAR_1, "Backup between two IO threads is not implemented");
return;
}
aio_context_acquire(state->aio_context);
state->bs = bs;
bdrv_drained_begin(state->bs);
do_blockdev_backup(backup, VAR_0->block_job_txn, &local_err);
if (local_err) {
error_propagate(VAR_1, local_err);
return;
}
state->job = state->bs->job;
}
| [
"static void FUNC_0(BlkActionState *VAR_0, Error **VAR_1)\n{",
"BlockdevBackupState *state = DO_UPCAST(BlockdevBackupState, VAR_0, VAR_0);",
"BlockdevBackup *backup;",
"BlockDriverState *bs, *target;",
"Error *local_err = NULL;",
"assert(VAR_0->action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP);",
"backup = VAR_0->action->u.blockdev_backup.data;",
"bs = qmp_get_root_bs(backup->device, VAR_1);",
"if (!bs) {",
"return;",
"}",
"target = bdrv_lookup_bs(backup->target, backup->target, VAR_1);",
"if (!target) {",
"return;",
"}",
"state->aio_context = bdrv_get_aio_context(bs);",
"if (state->aio_context != bdrv_get_aio_context(target)) {",
"state->aio_context = NULL;",
"error_setg(VAR_1, \"Backup between two IO threads is not implemented\");",
"return;",
"}",
"aio_context_acquire(state->aio_context);",
"state->bs = bs;",
"bdrv_drained_begin(state->bs);",
"do_blockdev_backup(backup, VAR_0->block_job_txn, &local_err);",
"if (local_err) {",
"error_propagate(VAR_1, local_err);",
"return;",
"}",
"state->job = state->bs->job;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
]
] |
25,957 | static int guest_get_network_stats(const char *name,
GuestNetworkInterfaceStat *stats)
{
DWORD if_index = 0;
MIB_IFROW a_mid_ifrow;
memset(&a_mid_ifrow, 0, sizeof(a_mid_ifrow));
if_index = get_interface_index(name);
a_mid_ifrow.dwIndex = if_index;
if (NO_ERROR == GetIfEntry(&a_mid_ifrow)) {
stats->rx_bytes = a_mid_ifrow.dwInOctets;
stats->rx_packets = a_mid_ifrow.dwInUcastPkts;
stats->rx_errs = a_mid_ifrow.dwInErrors;
stats->rx_dropped = a_mid_ifrow.dwInDiscards;
stats->tx_bytes = a_mid_ifrow.dwOutOctets;
stats->tx_packets = a_mid_ifrow.dwOutUcastPkts;
stats->tx_errs = a_mid_ifrow.dwOutErrors;
stats->tx_dropped = a_mid_ifrow.dwOutDiscards;
return 0;
}
return -1;
}
| true | qemu | df83eabd5245828cbca32060aa191d8b03bc5d50 | static int guest_get_network_stats(const char *name,
GuestNetworkInterfaceStat *stats)
{
DWORD if_index = 0;
MIB_IFROW a_mid_ifrow;
memset(&a_mid_ifrow, 0, sizeof(a_mid_ifrow));
if_index = get_interface_index(name);
a_mid_ifrow.dwIndex = if_index;
if (NO_ERROR == GetIfEntry(&a_mid_ifrow)) {
stats->rx_bytes = a_mid_ifrow.dwInOctets;
stats->rx_packets = a_mid_ifrow.dwInUcastPkts;
stats->rx_errs = a_mid_ifrow.dwInErrors;
stats->rx_dropped = a_mid_ifrow.dwInDiscards;
stats->tx_bytes = a_mid_ifrow.dwOutOctets;
stats->tx_packets = a_mid_ifrow.dwOutUcastPkts;
stats->tx_errs = a_mid_ifrow.dwOutErrors;
stats->tx_dropped = a_mid_ifrow.dwOutDiscards;
return 0;
}
return -1;
}
| {
"code": [
" GuestNetworkInterfaceStat *stats)",
" DWORD if_index = 0;",
" MIB_IFROW a_mid_ifrow;",
" memset(&a_mid_ifrow, 0, sizeof(a_mid_ifrow));",
" if_index = get_interface_index(name);",
" a_mid_ifrow.dwIndex = if_index;",
" if (NO_ERROR == GetIfEntry(&a_mid_ifrow)) {",
" stats->rx_bytes = a_mid_ifrow.dwInOctets;",
" stats->rx_packets = a_mid_ifrow.dwInUcastPkts;",
" stats->rx_errs = a_mid_ifrow.dwInErrors;",
" stats->rx_dropped = a_mid_ifrow.dwInDiscards;",
" stats->tx_bytes = a_mid_ifrow.dwOutOctets;",
" stats->tx_packets = a_mid_ifrow.dwOutUcastPkts;",
" stats->tx_errs = a_mid_ifrow.dwOutErrors;",
" stats->tx_dropped = a_mid_ifrow.dwOutDiscards;",
" return 0;"
],
"line_no": [
3,
7,
9,
11,
13,
15,
17,
19,
21,
23,
25,
27,
29,
31,
33,
35
]
} | static int FUNC_0(const char *VAR_0,
GuestNetworkInterfaceStat *VAR_1)
{
DWORD if_index = 0;
MIB_IFROW a_mid_ifrow;
memset(&a_mid_ifrow, 0, sizeof(a_mid_ifrow));
if_index = get_interface_index(VAR_0);
a_mid_ifrow.dwIndex = if_index;
if (NO_ERROR == GetIfEntry(&a_mid_ifrow)) {
VAR_1->rx_bytes = a_mid_ifrow.dwInOctets;
VAR_1->rx_packets = a_mid_ifrow.dwInUcastPkts;
VAR_1->rx_errs = a_mid_ifrow.dwInErrors;
VAR_1->rx_dropped = a_mid_ifrow.dwInDiscards;
VAR_1->tx_bytes = a_mid_ifrow.dwOutOctets;
VAR_1->tx_packets = a_mid_ifrow.dwOutUcastPkts;
VAR_1->tx_errs = a_mid_ifrow.dwOutErrors;
VAR_1->tx_dropped = a_mid_ifrow.dwOutDiscards;
return 0;
}
return -1;
}
| [
"static int FUNC_0(const char *VAR_0,\nGuestNetworkInterfaceStat *VAR_1)\n{",
"DWORD if_index = 0;",
"MIB_IFROW a_mid_ifrow;",
"memset(&a_mid_ifrow, 0, sizeof(a_mid_ifrow));",
"if_index = get_interface_index(VAR_0);",
"a_mid_ifrow.dwIndex = if_index;",
"if (NO_ERROR == GetIfEntry(&a_mid_ifrow)) {",
"VAR_1->rx_bytes = a_mid_ifrow.dwInOctets;",
"VAR_1->rx_packets = a_mid_ifrow.dwInUcastPkts;",
"VAR_1->rx_errs = a_mid_ifrow.dwInErrors;",
"VAR_1->rx_dropped = a_mid_ifrow.dwInDiscards;",
"VAR_1->tx_bytes = a_mid_ifrow.dwOutOctets;",
"VAR_1->tx_packets = a_mid_ifrow.dwOutUcastPkts;",
"VAR_1->tx_errs = a_mid_ifrow.dwOutErrors;",
"VAR_1->tx_dropped = a_mid_ifrow.dwOutDiscards;",
"return 0;",
"}",
"return -1;",
"}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
]
] |
25,959 | void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
{
CPUARMState *env = &cpu->env;
int kernel_size;
int initrd_size;
int n;
int is_linux = 0;
uint64_t elf_entry;
target_phys_addr_t entry;
int big_endian;
QemuOpts *machine_opts;
/* Load the kernel. */
if (!info->kernel_filename) {
fprintf(stderr, "Kernel image must be specified\n");
exit(1);
}
machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
if (machine_opts) {
info->dtb_filename = qemu_opt_get(machine_opts, "dtb");
} else {
info->dtb_filename = NULL;
}
if (!info->secondary_cpu_reset_hook) {
info->secondary_cpu_reset_hook = default_reset_secondary;
}
if (!info->write_secondary_boot) {
info->write_secondary_boot = default_write_secondary;
}
if (info->nb_cpus == 0)
info->nb_cpus = 1;
#ifdef TARGET_WORDS_BIGENDIAN
big_endian = 1;
#else
big_endian = 0;
#endif
/* Assume that raw images are linux kernels, and ELF images are not. */
kernel_size = load_elf(info->kernel_filename, NULL, NULL, &elf_entry,
NULL, NULL, big_endian, ELF_MACHINE, 1);
entry = elf_entry;
if (kernel_size < 0) {
kernel_size = load_uimage(info->kernel_filename, &entry, NULL,
&is_linux);
}
if (kernel_size < 0) {
entry = info->loader_start + KERNEL_LOAD_ADDR;
kernel_size = load_image_targphys(info->kernel_filename, entry,
info->ram_size - KERNEL_LOAD_ADDR);
is_linux = 1;
}
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
info->kernel_filename);
exit(1);
}
info->entry = entry;
if (is_linux) {
if (info->initrd_filename) {
initrd_size = load_image_targphys(info->initrd_filename,
info->loader_start
+ INITRD_LOAD_ADDR,
info->ram_size
- INITRD_LOAD_ADDR);
if (initrd_size < 0) {
fprintf(stderr, "qemu: could not load initrd '%s'\n",
info->initrd_filename);
exit(1);
}
} else {
initrd_size = 0;
}
info->initrd_size = initrd_size;
bootloader[4] = info->board_id;
/* for device tree boot, we pass the DTB directly in r2. Otherwise
* we point to the kernel args.
*/
if (info->dtb_filename) {
/* Place the DTB after the initrd in memory */
target_phys_addr_t dtb_start = TARGET_PAGE_ALIGN(info->loader_start
+ INITRD_LOAD_ADDR
+ initrd_size);
if (load_dtb(dtb_start, info)) {
exit(1);
}
bootloader[5] = dtb_start;
} else {
bootloader[5] = info->loader_start + KERNEL_ARGS_ADDR;
if (info->ram_size >= (1ULL << 32)) {
fprintf(stderr, "qemu: RAM size must be less than 4GB to boot"
" Linux kernel using ATAGS (try passing a device tree"
" using -dtb)\n");
exit(1);
}
}
bootloader[6] = entry;
for (n = 0; n < sizeof(bootloader) / 4; n++) {
bootloader[n] = tswap32(bootloader[n]);
}
rom_add_blob_fixed("bootloader", bootloader, sizeof(bootloader),
info->loader_start);
if (info->nb_cpus > 1) {
info->write_secondary_boot(cpu, info);
}
}
info->is_linux = is_linux;
for (; env; env = env->next_cpu) {
cpu = arm_env_get_cpu(env);
env->boot_info = info;
qemu_register_reset(do_cpu_reset, cpu);
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
{
CPUARMState *env = &cpu->env;
int kernel_size;
int initrd_size;
int n;
int is_linux = 0;
uint64_t elf_entry;
target_phys_addr_t entry;
int big_endian;
QemuOpts *machine_opts;
if (!info->kernel_filename) {
fprintf(stderr, "Kernel image must be specified\n");
exit(1);
}
machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
if (machine_opts) {
info->dtb_filename = qemu_opt_get(machine_opts, "dtb");
} else {
info->dtb_filename = NULL;
}
if (!info->secondary_cpu_reset_hook) {
info->secondary_cpu_reset_hook = default_reset_secondary;
}
if (!info->write_secondary_boot) {
info->write_secondary_boot = default_write_secondary;
}
if (info->nb_cpus == 0)
info->nb_cpus = 1;
#ifdef TARGET_WORDS_BIGENDIAN
big_endian = 1;
#else
big_endian = 0;
#endif
kernel_size = load_elf(info->kernel_filename, NULL, NULL, &elf_entry,
NULL, NULL, big_endian, ELF_MACHINE, 1);
entry = elf_entry;
if (kernel_size < 0) {
kernel_size = load_uimage(info->kernel_filename, &entry, NULL,
&is_linux);
}
if (kernel_size < 0) {
entry = info->loader_start + KERNEL_LOAD_ADDR;
kernel_size = load_image_targphys(info->kernel_filename, entry,
info->ram_size - KERNEL_LOAD_ADDR);
is_linux = 1;
}
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
info->kernel_filename);
exit(1);
}
info->entry = entry;
if (is_linux) {
if (info->initrd_filename) {
initrd_size = load_image_targphys(info->initrd_filename,
info->loader_start
+ INITRD_LOAD_ADDR,
info->ram_size
- INITRD_LOAD_ADDR);
if (initrd_size < 0) {
fprintf(stderr, "qemu: could not load initrd '%s'\n",
info->initrd_filename);
exit(1);
}
} else {
initrd_size = 0;
}
info->initrd_size = initrd_size;
bootloader[4] = info->board_id;
if (info->dtb_filename) {
target_phys_addr_t dtb_start = TARGET_PAGE_ALIGN(info->loader_start
+ INITRD_LOAD_ADDR
+ initrd_size);
if (load_dtb(dtb_start, info)) {
exit(1);
}
bootloader[5] = dtb_start;
} else {
bootloader[5] = info->loader_start + KERNEL_ARGS_ADDR;
if (info->ram_size >= (1ULL << 32)) {
fprintf(stderr, "qemu: RAM size must be less than 4GB to boot"
" Linux kernel using ATAGS (try passing a device tree"
" using -dtb)\n");
exit(1);
}
}
bootloader[6] = entry;
for (n = 0; n < sizeof(bootloader) / 4; n++) {
bootloader[n] = tswap32(bootloader[n]);
}
rom_add_blob_fixed("bootloader", bootloader, sizeof(bootloader),
info->loader_start);
if (info->nb_cpus > 1) {
info->write_secondary_boot(cpu, info);
}
}
info->is_linux = is_linux;
for (; env; env = env->next_cpu) {
cpu = arm_env_get_cpu(env);
env->boot_info = info;
qemu_register_reset(do_cpu_reset, cpu);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(ARMCPU *VAR_0, struct arm_boot_info *VAR_1)
{
CPUARMState *env = &VAR_0->env;
int VAR_2;
int VAR_3;
int VAR_4;
int VAR_5 = 0;
uint64_t elf_entry;
target_phys_addr_t entry;
int VAR_6;
QemuOpts *machine_opts;
if (!VAR_1->kernel_filename) {
fprintf(stderr, "Kernel image must be specified\VAR_4");
exit(1);
}
machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
if (machine_opts) {
VAR_1->dtb_filename = qemu_opt_get(machine_opts, "dtb");
} else {
VAR_1->dtb_filename = NULL;
}
if (!VAR_1->secondary_cpu_reset_hook) {
VAR_1->secondary_cpu_reset_hook = default_reset_secondary;
}
if (!VAR_1->write_secondary_boot) {
VAR_1->write_secondary_boot = default_write_secondary;
}
if (VAR_1->nb_cpus == 0)
VAR_1->nb_cpus = 1;
#ifdef TARGET_WORDS_BIGENDIAN
VAR_6 = 1;
#else
VAR_6 = 0;
#endif
VAR_2 = load_elf(VAR_1->kernel_filename, NULL, NULL, &elf_entry,
NULL, NULL, VAR_6, ELF_MACHINE, 1);
entry = elf_entry;
if (VAR_2 < 0) {
VAR_2 = load_uimage(VAR_1->kernel_filename, &entry, NULL,
&VAR_5);
}
if (VAR_2 < 0) {
entry = VAR_1->loader_start + KERNEL_LOAD_ADDR;
VAR_2 = load_image_targphys(VAR_1->kernel_filename, entry,
VAR_1->ram_size - KERNEL_LOAD_ADDR);
VAR_5 = 1;
}
if (VAR_2 < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\VAR_4",
VAR_1->kernel_filename);
exit(1);
}
VAR_1->entry = entry;
if (VAR_5) {
if (VAR_1->initrd_filename) {
VAR_3 = load_image_targphys(VAR_1->initrd_filename,
VAR_1->loader_start
+ INITRD_LOAD_ADDR,
VAR_1->ram_size
- INITRD_LOAD_ADDR);
if (VAR_3 < 0) {
fprintf(stderr, "qemu: could not load initrd '%s'\VAR_4",
VAR_1->initrd_filename);
exit(1);
}
} else {
VAR_3 = 0;
}
VAR_1->VAR_3 = VAR_3;
bootloader[4] = VAR_1->board_id;
if (VAR_1->dtb_filename) {
target_phys_addr_t dtb_start = TARGET_PAGE_ALIGN(VAR_1->loader_start
+ INITRD_LOAD_ADDR
+ VAR_3);
if (load_dtb(dtb_start, VAR_1)) {
exit(1);
}
bootloader[5] = dtb_start;
} else {
bootloader[5] = VAR_1->loader_start + KERNEL_ARGS_ADDR;
if (VAR_1->ram_size >= (1ULL << 32)) {
fprintf(stderr, "qemu: RAM size must be less than 4GB to boot"
" Linux kernel using ATAGS (try passing a device tree"
" using -dtb)\VAR_4");
exit(1);
}
}
bootloader[6] = entry;
for (VAR_4 = 0; VAR_4 < sizeof(bootloader) / 4; VAR_4++) {
bootloader[VAR_4] = tswap32(bootloader[VAR_4]);
}
rom_add_blob_fixed("bootloader", bootloader, sizeof(bootloader),
VAR_1->loader_start);
if (VAR_1->nb_cpus > 1) {
VAR_1->write_secondary_boot(VAR_0, VAR_1);
}
}
VAR_1->VAR_5 = VAR_5;
for (; env; env = env->next_cpu) {
VAR_0 = arm_env_get_cpu(env);
env->boot_info = VAR_1;
qemu_register_reset(do_cpu_reset, VAR_0);
}
}
| [
"void FUNC_0(ARMCPU *VAR_0, struct arm_boot_info *VAR_1)\n{",
"CPUARMState *env = &VAR_0->env;",
"int VAR_2;",
"int VAR_3;",
"int VAR_4;",
"int VAR_5 = 0;",
"uint64_t elf_entry;",
"target_phys_addr_t entry;",
"int VAR_6;",
"QemuOpts *machine_opts;",
"if (!VAR_1->kernel_filename) {",
"fprintf(stderr, \"Kernel image must be specified\\VAR_4\");",
"exit(1);",
"}",
"machine_opts = qemu_opts_find(qemu_find_opts(\"machine\"), 0);",
"if (machine_opts) {",
"VAR_1->dtb_filename = qemu_opt_get(machine_opts, \"dtb\");",
"} else {",
"VAR_1->dtb_filename = NULL;",
"}",
"if (!VAR_1->secondary_cpu_reset_hook) {",
"VAR_1->secondary_cpu_reset_hook = default_reset_secondary;",
"}",
"if (!VAR_1->write_secondary_boot) {",
"VAR_1->write_secondary_boot = default_write_secondary;",
"}",
"if (VAR_1->nb_cpus == 0)\nVAR_1->nb_cpus = 1;",
"#ifdef TARGET_WORDS_BIGENDIAN\nVAR_6 = 1;",
"#else\nVAR_6 = 0;",
"#endif\nVAR_2 = load_elf(VAR_1->kernel_filename, NULL, NULL, &elf_entry,\nNULL, NULL, VAR_6, ELF_MACHINE, 1);",
"entry = elf_entry;",
"if (VAR_2 < 0) {",
"VAR_2 = load_uimage(VAR_1->kernel_filename, &entry, NULL,\n&VAR_5);",
"}",
"if (VAR_2 < 0) {",
"entry = VAR_1->loader_start + KERNEL_LOAD_ADDR;",
"VAR_2 = load_image_targphys(VAR_1->kernel_filename, entry,\nVAR_1->ram_size - KERNEL_LOAD_ADDR);",
"VAR_5 = 1;",
"}",
"if (VAR_2 < 0) {",
"fprintf(stderr, \"qemu: could not load kernel '%s'\\VAR_4\",\nVAR_1->kernel_filename);",
"exit(1);",
"}",
"VAR_1->entry = entry;",
"if (VAR_5) {",
"if (VAR_1->initrd_filename) {",
"VAR_3 = load_image_targphys(VAR_1->initrd_filename,\nVAR_1->loader_start\n+ INITRD_LOAD_ADDR,\nVAR_1->ram_size\n- INITRD_LOAD_ADDR);",
"if (VAR_3 < 0) {",
"fprintf(stderr, \"qemu: could not load initrd '%s'\\VAR_4\",\nVAR_1->initrd_filename);",
"exit(1);",
"}",
"} else {",
"VAR_3 = 0;",
"}",
"VAR_1->VAR_3 = VAR_3;",
"bootloader[4] = VAR_1->board_id;",
"if (VAR_1->dtb_filename) {",
"target_phys_addr_t dtb_start = TARGET_PAGE_ALIGN(VAR_1->loader_start\n+ INITRD_LOAD_ADDR\n+ VAR_3);",
"if (load_dtb(dtb_start, VAR_1)) {",
"exit(1);",
"}",
"bootloader[5] = dtb_start;",
"} else {",
"bootloader[5] = VAR_1->loader_start + KERNEL_ARGS_ADDR;",
"if (VAR_1->ram_size >= (1ULL << 32)) {",
"fprintf(stderr, \"qemu: RAM size must be less than 4GB to boot\"\n\" Linux kernel using ATAGS (try passing a device tree\"\n\" using -dtb)\\VAR_4\");",
"exit(1);",
"}",
"}",
"bootloader[6] = entry;",
"for (VAR_4 = 0; VAR_4 < sizeof(bootloader) / 4; VAR_4++) {",
"bootloader[VAR_4] = tswap32(bootloader[VAR_4]);",
"}",
"rom_add_blob_fixed(\"bootloader\", bootloader, sizeof(bootloader),\nVAR_1->loader_start);",
"if (VAR_1->nb_cpus > 1) {",
"VAR_1->write_secondary_boot(VAR_0, VAR_1);",
"}",
"}",
"VAR_1->VAR_5 = VAR_5;",
"for (; env; env = env->next_cpu) {",
"VAR_0 = arm_env_get_cpu(env);",
"env->boot_info = VAR_1;",
"qemu_register_reset(do_cpu_reset, 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65,
67
],
[
71,
73
],
[
75,
77
],
[
79,
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
],
[
157
],
[
167
],
[
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
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
]
] |
25,960 | static CharDriverState *qemu_chr_open_null(void)
{
CharDriverState *chr;
chr = g_malloc0(sizeof(CharDriverState));
chr->chr_write = null_chr_write;
chr->explicit_be_open = true;
return chr;
}
| false | qemu | db39fcf1f690b02d612e2bfc00980700887abe03 | static CharDriverState *qemu_chr_open_null(void)
{
CharDriverState *chr;
chr = g_malloc0(sizeof(CharDriverState));
chr->chr_write = null_chr_write;
chr->explicit_be_open = true;
return chr;
}
| {
"code": [],
"line_no": []
} | static CharDriverState *FUNC_0(void)
{
CharDriverState *chr;
chr = g_malloc0(sizeof(CharDriverState));
chr->chr_write = null_chr_write;
chr->explicit_be_open = true;
return chr;
}
| [
"static CharDriverState *FUNC_0(void)\n{",
"CharDriverState *chr;",
"chr = g_malloc0(sizeof(CharDriverState));",
"chr->chr_write = null_chr_write;",
"chr->explicit_be_open = true;",
"return chr;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
25,961 | static bool nvic_rettobase(NVICState *s)
{
int irq, nhand = 0;
for (irq = ARMV7M_EXCP_RESET; irq < s->num_irq; irq++) {
if (s->vectors[irq].active) {
nhand++;
if (nhand == 2) {
return 0;
}
}
}
return 1;
}
| false | qemu | 028b0da424ba85049557c61f9f0a8a6698352b41 | static bool nvic_rettobase(NVICState *s)
{
int irq, nhand = 0;
for (irq = ARMV7M_EXCP_RESET; irq < s->num_irq; irq++) {
if (s->vectors[irq].active) {
nhand++;
if (nhand == 2) {
return 0;
}
}
}
return 1;
}
| {
"code": [],
"line_no": []
} | static bool FUNC_0(NVICState *s)
{
int VAR_0, VAR_1 = 0;
for (VAR_0 = ARMV7M_EXCP_RESET; VAR_0 < s->num_irq; VAR_0++) {
if (s->vectors[VAR_0].active) {
VAR_1++;
if (VAR_1 == 2) {
return 0;
}
}
}
return 1;
}
| [
"static bool FUNC_0(NVICState *s)\n{",
"int VAR_0, VAR_1 = 0;",
"for (VAR_0 = ARMV7M_EXCP_RESET; VAR_0 < s->num_irq; VAR_0++) {",
"if (s->vectors[VAR_0].active) {",
"VAR_1++;",
"if (VAR_1 == 2) {",
"return 0;",
"}",
"}",
"}",
"return 1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
]
] |
25,963 | void ioinst_handle_xsch(S390CPU *cpu, uint64_t reg1)
{
int cssid, ssid, schid, m;
SubchDev *sch;
int ret = -ENODEV;
int cc;
if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) {
program_interrupt(&cpu->env, PGM_OPERAND, 2);
return;
}
trace_ioinst_sch_id("xsch", cssid, ssid, schid);
sch = css_find_subch(m, cssid, ssid, schid);
if (sch && css_subch_visible(sch)) {
ret = css_do_xsch(sch);
}
switch (ret) {
case -ENODEV:
cc = 3;
break;
case -EBUSY:
cc = 2;
break;
case 0:
cc = 0;
break;
default:
cc = 1;
break;
}
setcc(cpu, cc);
}
| false | qemu | 7e01376daea75e888c370aab521a7d4aeaf2ffd1 | void ioinst_handle_xsch(S390CPU *cpu, uint64_t reg1)
{
int cssid, ssid, schid, m;
SubchDev *sch;
int ret = -ENODEV;
int cc;
if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) {
program_interrupt(&cpu->env, PGM_OPERAND, 2);
return;
}
trace_ioinst_sch_id("xsch", cssid, ssid, schid);
sch = css_find_subch(m, cssid, ssid, schid);
if (sch && css_subch_visible(sch)) {
ret = css_do_xsch(sch);
}
switch (ret) {
case -ENODEV:
cc = 3;
break;
case -EBUSY:
cc = 2;
break;
case 0:
cc = 0;
break;
default:
cc = 1;
break;
}
setcc(cpu, cc);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(S390CPU *VAR_0, uint64_t VAR_1)
{
int VAR_2, VAR_3, VAR_4, VAR_5;
SubchDev *sch;
int VAR_6 = -ENODEV;
int VAR_7;
if (ioinst_disassemble_sch_ident(VAR_1, &VAR_5, &VAR_2, &VAR_3, &VAR_4)) {
program_interrupt(&VAR_0->env, PGM_OPERAND, 2);
return;
}
trace_ioinst_sch_id("xsch", VAR_2, VAR_3, VAR_4);
sch = css_find_subch(VAR_5, VAR_2, VAR_3, VAR_4);
if (sch && css_subch_visible(sch)) {
VAR_6 = css_do_xsch(sch);
}
switch (VAR_6) {
case -ENODEV:
VAR_7 = 3;
break;
case -EBUSY:
VAR_7 = 2;
break;
case 0:
VAR_7 = 0;
break;
default:
VAR_7 = 1;
break;
}
setcc(VAR_0, VAR_7);
}
| [
"void FUNC_0(S390CPU *VAR_0, uint64_t VAR_1)\n{",
"int VAR_2, VAR_3, VAR_4, VAR_5;",
"SubchDev *sch;",
"int VAR_6 = -ENODEV;",
"int VAR_7;",
"if (ioinst_disassemble_sch_ident(VAR_1, &VAR_5, &VAR_2, &VAR_3, &VAR_4)) {",
"program_interrupt(&VAR_0->env, PGM_OPERAND, 2);",
"return;",
"}",
"trace_ioinst_sch_id(\"xsch\", VAR_2, VAR_3, VAR_4);",
"sch = css_find_subch(VAR_5, VAR_2, VAR_3, VAR_4);",
"if (sch && css_subch_visible(sch)) {",
"VAR_6 = css_do_xsch(sch);",
"}",
"switch (VAR_6) {",
"case -ENODEV:\nVAR_7 = 3;",
"break;",
"case -EBUSY:\nVAR_7 = 2;",
"break;",
"case 0:\nVAR_7 = 0;",
"break;",
"default:\nVAR_7 = 1;",
"break;",
"}",
"setcc(VAR_0, VAR_7);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41,
43
],
[
45
],
[
47,
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
]
] |
25,964 | static int vtd_dev_to_context_entry(IntelIOMMUState *s, uint8_t bus_num,
uint8_t devfn, VTDContextEntry *ce)
{
VTDRootEntry re;
int ret_fr;
X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(s);
ret_fr = vtd_get_root_entry(s, bus_num, &re);
if (ret_fr) {
return ret_fr;
}
if (!vtd_root_entry_present(&re)) {
/* Not error - it's okay we don't have root entry. */
trace_vtd_re_not_present(bus_num);
return -VTD_FR_ROOT_ENTRY_P;
}
if (re.rsvd || (re.val & VTD_ROOT_ENTRY_RSVD(VTD_HOST_ADDRESS_WIDTH))) {
trace_vtd_re_invalid(re.rsvd, re.val);
return -VTD_FR_ROOT_ENTRY_RSVD;
}
ret_fr = vtd_get_context_entry_from_root(&re, devfn, ce);
if (ret_fr) {
return ret_fr;
}
if (!vtd_ce_present(ce)) {
/* Not error - it's okay we don't have context entry. */
trace_vtd_ce_not_present(bus_num, devfn);
return -VTD_FR_CONTEXT_ENTRY_P;
}
if ((ce->hi & VTD_CONTEXT_ENTRY_RSVD_HI) ||
(ce->lo & VTD_CONTEXT_ENTRY_RSVD_LO(VTD_HOST_ADDRESS_WIDTH))) {
trace_vtd_ce_invalid(ce->hi, ce->lo);
return -VTD_FR_CONTEXT_ENTRY_RSVD;
}
/* Check if the programming of context-entry is valid */
if (!vtd_is_level_supported(s, vtd_ce_get_level(ce))) {
trace_vtd_ce_invalid(ce->hi, ce->lo);
return -VTD_FR_CONTEXT_ENTRY_INV;
}
/* Do translation type check */
if (!vtd_ce_type_check(x86_iommu, ce)) {
trace_vtd_ce_invalid(ce->hi, ce->lo);
return -VTD_FR_CONTEXT_ENTRY_INV;
}
return 0;
}
| false | qemu | 37f51384ae05bd50f83308339dbffa3e78404874 | static int vtd_dev_to_context_entry(IntelIOMMUState *s, uint8_t bus_num,
uint8_t devfn, VTDContextEntry *ce)
{
VTDRootEntry re;
int ret_fr;
X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(s);
ret_fr = vtd_get_root_entry(s, bus_num, &re);
if (ret_fr) {
return ret_fr;
}
if (!vtd_root_entry_present(&re)) {
trace_vtd_re_not_present(bus_num);
return -VTD_FR_ROOT_ENTRY_P;
}
if (re.rsvd || (re.val & VTD_ROOT_ENTRY_RSVD(VTD_HOST_ADDRESS_WIDTH))) {
trace_vtd_re_invalid(re.rsvd, re.val);
return -VTD_FR_ROOT_ENTRY_RSVD;
}
ret_fr = vtd_get_context_entry_from_root(&re, devfn, ce);
if (ret_fr) {
return ret_fr;
}
if (!vtd_ce_present(ce)) {
trace_vtd_ce_not_present(bus_num, devfn);
return -VTD_FR_CONTEXT_ENTRY_P;
}
if ((ce->hi & VTD_CONTEXT_ENTRY_RSVD_HI) ||
(ce->lo & VTD_CONTEXT_ENTRY_RSVD_LO(VTD_HOST_ADDRESS_WIDTH))) {
trace_vtd_ce_invalid(ce->hi, ce->lo);
return -VTD_FR_CONTEXT_ENTRY_RSVD;
}
if (!vtd_is_level_supported(s, vtd_ce_get_level(ce))) {
trace_vtd_ce_invalid(ce->hi, ce->lo);
return -VTD_FR_CONTEXT_ENTRY_INV;
}
if (!vtd_ce_type_check(x86_iommu, ce)) {
trace_vtd_ce_invalid(ce->hi, ce->lo);
return -VTD_FR_CONTEXT_ENTRY_INV;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(IntelIOMMUState *VAR_0, uint8_t VAR_1,
uint8_t VAR_2, VTDContextEntry *VAR_3)
{
VTDRootEntry re;
int VAR_4;
X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(VAR_0);
VAR_4 = vtd_get_root_entry(VAR_0, VAR_1, &re);
if (VAR_4) {
return VAR_4;
}
if (!vtd_root_entry_present(&re)) {
trace_vtd_re_not_present(VAR_1);
return -VTD_FR_ROOT_ENTRY_P;
}
if (re.rsvd || (re.val & VTD_ROOT_ENTRY_RSVD(VTD_HOST_ADDRESS_WIDTH))) {
trace_vtd_re_invalid(re.rsvd, re.val);
return -VTD_FR_ROOT_ENTRY_RSVD;
}
VAR_4 = vtd_get_context_entry_from_root(&re, VAR_2, VAR_3);
if (VAR_4) {
return VAR_4;
}
if (!vtd_ce_present(VAR_3)) {
trace_vtd_ce_not_present(VAR_1, VAR_2);
return -VTD_FR_CONTEXT_ENTRY_P;
}
if ((VAR_3->hi & VTD_CONTEXT_ENTRY_RSVD_HI) ||
(VAR_3->lo & VTD_CONTEXT_ENTRY_RSVD_LO(VTD_HOST_ADDRESS_WIDTH))) {
trace_vtd_ce_invalid(VAR_3->hi, VAR_3->lo);
return -VTD_FR_CONTEXT_ENTRY_RSVD;
}
if (!vtd_is_level_supported(VAR_0, vtd_ce_get_level(VAR_3))) {
trace_vtd_ce_invalid(VAR_3->hi, VAR_3->lo);
return -VTD_FR_CONTEXT_ENTRY_INV;
}
if (!vtd_ce_type_check(x86_iommu, VAR_3)) {
trace_vtd_ce_invalid(VAR_3->hi, VAR_3->lo);
return -VTD_FR_CONTEXT_ENTRY_INV;
}
return 0;
}
| [
"static int FUNC_0(IntelIOMMUState *VAR_0, uint8_t VAR_1,\nuint8_t VAR_2, VTDContextEntry *VAR_3)\n{",
"VTDRootEntry re;",
"int VAR_4;",
"X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(VAR_0);",
"VAR_4 = vtd_get_root_entry(VAR_0, VAR_1, &re);",
"if (VAR_4) {",
"return VAR_4;",
"}",
"if (!vtd_root_entry_present(&re)) {",
"trace_vtd_re_not_present(VAR_1);",
"return -VTD_FR_ROOT_ENTRY_P;",
"}",
"if (re.rsvd || (re.val & VTD_ROOT_ENTRY_RSVD(VTD_HOST_ADDRESS_WIDTH))) {",
"trace_vtd_re_invalid(re.rsvd, re.val);",
"return -VTD_FR_ROOT_ENTRY_RSVD;",
"}",
"VAR_4 = vtd_get_context_entry_from_root(&re, VAR_2, VAR_3);",
"if (VAR_4) {",
"return VAR_4;",
"}",
"if (!vtd_ce_present(VAR_3)) {",
"trace_vtd_ce_not_present(VAR_1, VAR_2);",
"return -VTD_FR_CONTEXT_ENTRY_P;",
"}",
"if ((VAR_3->hi & VTD_CONTEXT_ENTRY_RSVD_HI) ||\n(VAR_3->lo & VTD_CONTEXT_ENTRY_RSVD_LO(VTD_HOST_ADDRESS_WIDTH))) {",
"trace_vtd_ce_invalid(VAR_3->hi, VAR_3->lo);",
"return -VTD_FR_CONTEXT_ENTRY_RSVD;",
"}",
"if (!vtd_is_level_supported(VAR_0, vtd_ce_get_level(VAR_3))) {",
"trace_vtd_ce_invalid(VAR_3->hi, VAR_3->lo);",
"return -VTD_FR_CONTEXT_ENTRY_INV;",
"}",
"if (!vtd_ce_type_check(x86_iommu, VAR_3)) {",
"trace_vtd_ce_invalid(VAR_3->hi, VAR_3->lo);",
"return -VTD_FR_CONTEXT_ENTRY_INV;",
"}",
"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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
61
],
[
63
],
[
65
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
83
],
[
85
],
[
87
],
[
89
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
]
] |
25,965 | static void do_interrupt_real(int intno, int is_int, int error_code,
unsigned int next_eip)
{
SegmentCache *dt;
uint8_t *ptr, *ssp;
int selector;
uint32_t offset, esp;
uint32_t old_cs, old_eip;
/* real mode (simpler !) */
dt = &env->idt;
if (intno * 4 + 3 > dt->limit)
raise_exception_err(EXCP0D_GPF, intno * 8 + 2);
ptr = dt->base + intno * 4;
offset = lduw(ptr);
selector = lduw(ptr + 2);
esp = env->regs[R_ESP];
ssp = env->segs[R_SS].base;
if (is_int)
old_eip = next_eip;
else
old_eip = env->eip;
old_cs = env->segs[R_CS].selector;
esp -= 2;
stw(ssp + (esp & 0xffff), compute_eflags());
esp -= 2;
stw(ssp + (esp & 0xffff), old_cs);
esp -= 2;
stw(ssp + (esp & 0xffff), old_eip);
/* update processor state */
env->regs[R_ESP] = (env->regs[R_ESP] & ~0xffff) | (esp & 0xffff);
env->eip = offset;
env->segs[R_CS].selector = selector;
env->segs[R_CS].base = (uint8_t *)(selector << 4);
env->eflags &= ~(IF_MASK | TF_MASK | AC_MASK | RF_MASK);
}
| false | qemu | 3b22c4707decb706b10ce023534f8b79413ff9fe | static void do_interrupt_real(int intno, int is_int, int error_code,
unsigned int next_eip)
{
SegmentCache *dt;
uint8_t *ptr, *ssp;
int selector;
uint32_t offset, esp;
uint32_t old_cs, old_eip;
dt = &env->idt;
if (intno * 4 + 3 > dt->limit)
raise_exception_err(EXCP0D_GPF, intno * 8 + 2);
ptr = dt->base + intno * 4;
offset = lduw(ptr);
selector = lduw(ptr + 2);
esp = env->regs[R_ESP];
ssp = env->segs[R_SS].base;
if (is_int)
old_eip = next_eip;
else
old_eip = env->eip;
old_cs = env->segs[R_CS].selector;
esp -= 2;
stw(ssp + (esp & 0xffff), compute_eflags());
esp -= 2;
stw(ssp + (esp & 0xffff), old_cs);
esp -= 2;
stw(ssp + (esp & 0xffff), old_eip);
env->regs[R_ESP] = (env->regs[R_ESP] & ~0xffff) | (esp & 0xffff);
env->eip = offset;
env->segs[R_CS].selector = selector;
env->segs[R_CS].base = (uint8_t *)(selector << 4);
env->eflags &= ~(IF_MASK | TF_MASK | AC_MASK | RF_MASK);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(int VAR_0, int VAR_1, int VAR_2,
unsigned int VAR_3)
{
SegmentCache *dt;
uint8_t *ptr, *ssp;
int VAR_4;
uint32_t offset, esp;
uint32_t old_cs, old_eip;
dt = &env->idt;
if (VAR_0 * 4 + 3 > dt->limit)
raise_exception_err(EXCP0D_GPF, VAR_0 * 8 + 2);
ptr = dt->base + VAR_0 * 4;
offset = lduw(ptr);
VAR_4 = lduw(ptr + 2);
esp = env->regs[R_ESP];
ssp = env->segs[R_SS].base;
if (VAR_1)
old_eip = VAR_3;
else
old_eip = env->eip;
old_cs = env->segs[R_CS].VAR_4;
esp -= 2;
stw(ssp + (esp & 0xffff), compute_eflags());
esp -= 2;
stw(ssp + (esp & 0xffff), old_cs);
esp -= 2;
stw(ssp + (esp & 0xffff), old_eip);
env->regs[R_ESP] = (env->regs[R_ESP] & ~0xffff) | (esp & 0xffff);
env->eip = offset;
env->segs[R_CS].VAR_4 = VAR_4;
env->segs[R_CS].base = (uint8_t *)(VAR_4 << 4);
env->eflags &= ~(IF_MASK | TF_MASK | AC_MASK | RF_MASK);
}
| [
"static void FUNC_0(int VAR_0, int VAR_1, int VAR_2,\nunsigned int VAR_3)\n{",
"SegmentCache *dt;",
"uint8_t *ptr, *ssp;",
"int VAR_4;",
"uint32_t offset, esp;",
"uint32_t old_cs, old_eip;",
"dt = &env->idt;",
"if (VAR_0 * 4 + 3 > dt->limit)\nraise_exception_err(EXCP0D_GPF, VAR_0 * 8 + 2);",
"ptr = dt->base + VAR_0 * 4;",
"offset = lduw(ptr);",
"VAR_4 = lduw(ptr + 2);",
"esp = env->regs[R_ESP];",
"ssp = env->segs[R_SS].base;",
"if (VAR_1)\nold_eip = VAR_3;",
"else\nold_eip = env->eip;",
"old_cs = env->segs[R_CS].VAR_4;",
"esp -= 2;",
"stw(ssp + (esp & 0xffff), compute_eflags());",
"esp -= 2;",
"stw(ssp + (esp & 0xffff), old_cs);",
"esp -= 2;",
"stw(ssp + (esp & 0xffff), old_eip);",
"env->regs[R_ESP] = (env->regs[R_ESP] & ~0xffff) | (esp & 0xffff);",
"env->eip = offset;",
"env->segs[R_CS].VAR_4 = VAR_4;",
"env->segs[R_CS].base = (uint8_t *)(VAR_4 << 4);",
"env->eflags &= ~(IF_MASK | TF_MASK | AC_MASK | RF_MASK);",
"}"
] | [
0,
0,
0,
0,
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
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
]
] |
25,966 | void ff_ass_init(AVSubtitle *sub)
{
memset(sub, 0, sizeof(*sub));
}
| false | FFmpeg | 3ee8ca9b0894df3aaf5086c643283cb58ef9763d | void ff_ass_init(AVSubtitle *sub)
{
memset(sub, 0, sizeof(*sub));
}
| {
"code": [],
"line_no": []
} | void FUNC_0(AVSubtitle *VAR_0)
{
memset(VAR_0, 0, sizeof(*VAR_0));
}
| [
"void FUNC_0(AVSubtitle *VAR_0)\n{",
"memset(VAR_0, 0, sizeof(*VAR_0));",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
25,967 | uint64_t helper_stl_c_raw(uint64_t t0, uint64_t t1)
{
uint64_t ret;
if (t1 == env->lock) {
stl_raw(t1, t0);
ret = 0;
} else
ret = 1;
env->lock = 1;
return ret;
}
| false | qemu | 2374e73edafff0586cbfb67c333c5a7588f81fd5 | uint64_t helper_stl_c_raw(uint64_t t0, uint64_t t1)
{
uint64_t ret;
if (t1 == env->lock) {
stl_raw(t1, t0);
ret = 0;
} else
ret = 1;
env->lock = 1;
return ret;
}
| {
"code": [],
"line_no": []
} | uint64_t FUNC_0(uint64_t t0, uint64_t t1)
{
uint64_t ret;
if (t1 == env->lock) {
stl_raw(t1, t0);
ret = 0;
} else
ret = 1;
env->lock = 1;
return ret;
}
| [
"uint64_t FUNC_0(uint64_t t0, uint64_t t1)\n{",
"uint64_t ret;",
"if (t1 == env->lock) {",
"stl_raw(t1, t0);",
"ret = 0;",
"} else",
"ret = 1;",
"env->lock = 1;",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
25
],
[
27
]
] |
25,968 | int AUD_read (SWVoiceIn *sw, void *buf, int size)
{
int bytes;
if (!sw) {
/* XXX: Consider options */
return size;
}
if (!sw->hw->enabled) {
dolog ("Reading from disabled voice %s\n", SW_NAME (sw));
return 0;
}
bytes = sw->hw->pcm_ops->read (sw, buf, size);
return bytes;
}
| false | qemu | 9be385980d37e8f4fd33f605f5fb1c3d144170a8 | int AUD_read (SWVoiceIn *sw, void *buf, int size)
{
int bytes;
if (!sw) {
return size;
}
if (!sw->hw->enabled) {
dolog ("Reading from disabled voice %s\n", SW_NAME (sw));
return 0;
}
bytes = sw->hw->pcm_ops->read (sw, buf, size);
return bytes;
}
| {
"code": [],
"line_no": []
} | int FUNC_0 (SWVoiceIn *VAR_0, void *VAR_1, int VAR_2)
{
int VAR_3;
if (!VAR_0) {
return VAR_2;
}
if (!VAR_0->hw->enabled) {
dolog ("Reading from disabled voice %s\n", SW_NAME (VAR_0));
return 0;
}
VAR_3 = VAR_0->hw->pcm_ops->read (VAR_0, VAR_1, VAR_2);
return VAR_3;
}
| [
"int FUNC_0 (SWVoiceIn *VAR_0, void *VAR_1, int VAR_2)\n{",
"int VAR_3;",
"if (!VAR_0) {",
"return VAR_2;",
"}",
"if (!VAR_0->hw->enabled) {",
"dolog (\"Reading from disabled voice %s\\n\", SW_NAME (VAR_0));",
"return 0;",
"}",
"VAR_3 = VAR_0->hw->pcm_ops->read (VAR_0, VAR_1, VAR_2);",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
]
] |
25,969 | QEMUFile *qemu_fopen_ops_buffered(void *opaque,
size_t bytes_per_sec,
BufferedPutFunc *put_buffer,
BufferedPutReadyFunc *put_ready,
BufferedWaitForUnfreezeFunc *wait_for_unfreeze,
BufferedCloseFunc *close)
{
QEMUFileBuffered *s;
s = qemu_mallocz(sizeof(*s));
s->opaque = opaque;
s->xfer_limit = bytes_per_sec / 10;
s->put_buffer = put_buffer;
s->put_ready = put_ready;
s->wait_for_unfreeze = wait_for_unfreeze;
s->close = close;
s->file = qemu_fopen_ops(s, buffered_put_buffer, NULL,
buffered_close, buffered_rate_limit,
buffered_set_rate_limit,
buffered_get_rate_limit);
s->timer = qemu_new_timer(rt_clock, buffered_rate_tick, s);
qemu_mod_timer(s->timer, qemu_get_clock(rt_clock) + 100);
return s->file;
}
| false | qemu | 7bd427d801e1e3293a634d3c83beadaa90ffb911 | QEMUFile *qemu_fopen_ops_buffered(void *opaque,
size_t bytes_per_sec,
BufferedPutFunc *put_buffer,
BufferedPutReadyFunc *put_ready,
BufferedWaitForUnfreezeFunc *wait_for_unfreeze,
BufferedCloseFunc *close)
{
QEMUFileBuffered *s;
s = qemu_mallocz(sizeof(*s));
s->opaque = opaque;
s->xfer_limit = bytes_per_sec / 10;
s->put_buffer = put_buffer;
s->put_ready = put_ready;
s->wait_for_unfreeze = wait_for_unfreeze;
s->close = close;
s->file = qemu_fopen_ops(s, buffered_put_buffer, NULL,
buffered_close, buffered_rate_limit,
buffered_set_rate_limit,
buffered_get_rate_limit);
s->timer = qemu_new_timer(rt_clock, buffered_rate_tick, s);
qemu_mod_timer(s->timer, qemu_get_clock(rt_clock) + 100);
return s->file;
}
| {
"code": [],
"line_no": []
} | QEMUFile *FUNC_0(void *opaque,
size_t bytes_per_sec,
BufferedPutFunc *put_buffer,
BufferedPutReadyFunc *put_ready,
BufferedWaitForUnfreezeFunc *wait_for_unfreeze,
BufferedCloseFunc *close)
{
QEMUFileBuffered *s;
s = qemu_mallocz(sizeof(*s));
s->opaque = opaque;
s->xfer_limit = bytes_per_sec / 10;
s->put_buffer = put_buffer;
s->put_ready = put_ready;
s->wait_for_unfreeze = wait_for_unfreeze;
s->close = close;
s->file = qemu_fopen_ops(s, buffered_put_buffer, NULL,
buffered_close, buffered_rate_limit,
buffered_set_rate_limit,
buffered_get_rate_limit);
s->timer = qemu_new_timer(rt_clock, buffered_rate_tick, s);
qemu_mod_timer(s->timer, qemu_get_clock(rt_clock) + 100);
return s->file;
}
| [
"QEMUFile *FUNC_0(void *opaque,\nsize_t bytes_per_sec,\nBufferedPutFunc *put_buffer,\nBufferedPutReadyFunc *put_ready,\nBufferedWaitForUnfreezeFunc *wait_for_unfreeze,\nBufferedCloseFunc *close)\n{",
"QEMUFileBuffered *s;",
"s = qemu_mallocz(sizeof(*s));",
"s->opaque = opaque;",
"s->xfer_limit = bytes_per_sec / 10;",
"s->put_buffer = put_buffer;",
"s->put_ready = put_ready;",
"s->wait_for_unfreeze = wait_for_unfreeze;",
"s->close = close;",
"s->file = qemu_fopen_ops(s, buffered_put_buffer, NULL,\nbuffered_close, buffered_rate_limit,\nbuffered_set_rate_limit,\nbuffered_get_rate_limit);",
"s->timer = qemu_new_timer(rt_clock, buffered_rate_tick, s);",
"qemu_mod_timer(s->timer, qemu_get_clock(rt_clock) + 100);",
"return s->file;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13
],
[
15
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37,
39,
41,
43
],
[
47
],
[
51
],
[
55
],
[
57
]
] |
25,970 | int keysym2scancode(void *kbd_layout, int keysym)
{
kbd_layout_t *k = kbd_layout;
if (keysym < MAX_NORMAL_KEYCODE) {
if (k->keysym2keycode[keysym] == 0) {
trace_keymap_unmapped(keysym);
fprintf(stderr, "Warning: no scancode found for keysym %d\n",
keysym);
}
return k->keysym2keycode[keysym];
} else {
int i;
#ifdef XK_ISO_Left_Tab
if (keysym == XK_ISO_Left_Tab) {
keysym = XK_Tab;
}
#endif
for (i = 0; i < k->extra_count; i++) {
if (k->keysym2keycode_extra[i].keysym == keysym) {
return k->keysym2keycode_extra[i].keycode;
}
}
}
return 0;
}
| false | qemu | 8297be80f7cf71e09617669a8bd8b2836dcfd4c3 | int keysym2scancode(void *kbd_layout, int keysym)
{
kbd_layout_t *k = kbd_layout;
if (keysym < MAX_NORMAL_KEYCODE) {
if (k->keysym2keycode[keysym] == 0) {
trace_keymap_unmapped(keysym);
fprintf(stderr, "Warning: no scancode found for keysym %d\n",
keysym);
}
return k->keysym2keycode[keysym];
} else {
int i;
#ifdef XK_ISO_Left_Tab
if (keysym == XK_ISO_Left_Tab) {
keysym = XK_Tab;
}
#endif
for (i = 0; i < k->extra_count; i++) {
if (k->keysym2keycode_extra[i].keysym == keysym) {
return k->keysym2keycode_extra[i].keycode;
}
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(void *VAR_0, int VAR_1)
{
kbd_layout_t *k = VAR_0;
if (VAR_1 < MAX_NORMAL_KEYCODE) {
if (k->keysym2keycode[VAR_1] == 0) {
trace_keymap_unmapped(VAR_1);
fprintf(stderr, "Warning: no scancode found for VAR_1 %d\n",
VAR_1);
}
return k->keysym2keycode[VAR_1];
} else {
int VAR_2;
#ifdef XK_ISO_Left_Tab
if (VAR_1 == XK_ISO_Left_Tab) {
VAR_1 = XK_Tab;
}
#endif
for (VAR_2 = 0; VAR_2 < k->extra_count; VAR_2++) {
if (k->keysym2keycode_extra[VAR_2].VAR_1 == VAR_1) {
return k->keysym2keycode_extra[VAR_2].keycode;
}
}
}
return 0;
}
| [
"int FUNC_0(void *VAR_0, int VAR_1)\n{",
"kbd_layout_t *k = VAR_0;",
"if (VAR_1 < MAX_NORMAL_KEYCODE) {",
"if (k->keysym2keycode[VAR_1] == 0) {",
"trace_keymap_unmapped(VAR_1);",
"fprintf(stderr, \"Warning: no scancode found for VAR_1 %d\\n\",\nVAR_1);",
"}",
"return k->keysym2keycode[VAR_1];",
"} else {",
"int VAR_2;",
"#ifdef XK_ISO_Left_Tab\nif (VAR_1 == XK_ISO_Left_Tab) {",
"VAR_1 = XK_Tab;",
"}",
"#endif\nfor (VAR_2 = 0; VAR_2 < k->extra_count; VAR_2++) {",
"if (k->keysym2keycode_extra[VAR_2].VAR_1 == VAR_1) {",
"return k->keysym2keycode_extra[VAR_2].keycode;",
"}",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
]
] |
25,971 | gen_intermediate_code_internal(M68kCPU *cpu, TranslationBlock *tb,
bool search_pc)
{
CPUState *cs = CPU(cpu);
CPUM68KState *env = &cpu->env;
DisasContext dc1, *dc = &dc1;
uint16_t *gen_opc_end;
CPUBreakpoint *bp;
int j, lj;
target_ulong pc_start;
int pc_offset;
int num_insns;
int max_insns;
/* generate intermediate code */
pc_start = tb->pc;
dc->tb = tb;
gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;
dc->env = env;
dc->is_jmp = DISAS_NEXT;
dc->pc = pc_start;
dc->cc_op = CC_OP_DYNAMIC;
dc->singlestep_enabled = cs->singlestep_enabled;
dc->fpcr = env->fpcr;
dc->user = (env->sr & SR_S) == 0;
dc->is_mem = 0;
dc->done_mac = 0;
lj = -1;
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0)
max_insns = CF_COUNT_MASK;
gen_tb_start();
do {
pc_offset = dc->pc - pc_start;
gen_throws_exception = NULL;
if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {
QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {
if (bp->pc == dc->pc) {
gen_exception(dc, dc->pc, EXCP_DEBUG);
dc->is_jmp = DISAS_JUMP;
break;
}
}
if (dc->is_jmp)
break;
}
if (search_pc) {
j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j)
tcg_ctx.gen_opc_instr_start[lj++] = 0;
}
tcg_ctx.gen_opc_pc[lj] = dc->pc;
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
gen_io_start();
dc->insn_pc = dc->pc;
disas_m68k_insn(env, dc);
num_insns++;
} while (!dc->is_jmp && tcg_ctx.gen_opc_ptr < gen_opc_end &&
!cs->singlestep_enabled &&
!singlestep &&
(pc_offset) < (TARGET_PAGE_SIZE - 32) &&
num_insns < max_insns);
if (tb->cflags & CF_LAST_IO)
gen_io_end();
if (unlikely(cs->singlestep_enabled)) {
/* Make sure the pc is updated, and raise a debug exception. */
if (!dc->is_jmp) {
gen_flush_cc_op(dc);
tcg_gen_movi_i32(QREG_PC, dc->pc);
}
gen_helper_raise_exception(cpu_env, tcg_const_i32(EXCP_DEBUG));
} else {
switch(dc->is_jmp) {
case DISAS_NEXT:
gen_flush_cc_op(dc);
gen_jmp_tb(dc, 0, dc->pc);
break;
default:
case DISAS_JUMP:
case DISAS_UPDATE:
gen_flush_cc_op(dc);
/* indicate that the hash table must be used to find the next TB */
tcg_gen_exit_tb(0);
break;
case DISAS_TB_JUMP:
/* nothing more to generate */
break;
}
}
gen_tb_end(tb, num_insns);
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("----------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(env, pc_start, dc->pc - pc_start, 0);
qemu_log("\n");
}
#endif
if (search_pc) {
j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
lj++;
while (lj <= j)
tcg_ctx.gen_opc_instr_start[lj++] = 0;
} else {
tb->size = dc->pc - pc_start;
tb->icount = num_insns;
}
//optimize_flags();
//expand_target_qops();
}
| false | qemu | cd42d5b23691ad73edfd6dbcfc935a960a9c5a65 | gen_intermediate_code_internal(M68kCPU *cpu, TranslationBlock *tb,
bool search_pc)
{
CPUState *cs = CPU(cpu);
CPUM68KState *env = &cpu->env;
DisasContext dc1, *dc = &dc1;
uint16_t *gen_opc_end;
CPUBreakpoint *bp;
int j, lj;
target_ulong pc_start;
int pc_offset;
int num_insns;
int max_insns;
pc_start = tb->pc;
dc->tb = tb;
gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;
dc->env = env;
dc->is_jmp = DISAS_NEXT;
dc->pc = pc_start;
dc->cc_op = CC_OP_DYNAMIC;
dc->singlestep_enabled = cs->singlestep_enabled;
dc->fpcr = env->fpcr;
dc->user = (env->sr & SR_S) == 0;
dc->is_mem = 0;
dc->done_mac = 0;
lj = -1;
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0)
max_insns = CF_COUNT_MASK;
gen_tb_start();
do {
pc_offset = dc->pc - pc_start;
gen_throws_exception = NULL;
if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {
QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {
if (bp->pc == dc->pc) {
gen_exception(dc, dc->pc, EXCP_DEBUG);
dc->is_jmp = DISAS_JUMP;
break;
}
}
if (dc->is_jmp)
break;
}
if (search_pc) {
j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j)
tcg_ctx.gen_opc_instr_start[lj++] = 0;
}
tcg_ctx.gen_opc_pc[lj] = dc->pc;
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
gen_io_start();
dc->insn_pc = dc->pc;
disas_m68k_insn(env, dc);
num_insns++;
} while (!dc->is_jmp && tcg_ctx.gen_opc_ptr < gen_opc_end &&
!cs->singlestep_enabled &&
!singlestep &&
(pc_offset) < (TARGET_PAGE_SIZE - 32) &&
num_insns < max_insns);
if (tb->cflags & CF_LAST_IO)
gen_io_end();
if (unlikely(cs->singlestep_enabled)) {
if (!dc->is_jmp) {
gen_flush_cc_op(dc);
tcg_gen_movi_i32(QREG_PC, dc->pc);
}
gen_helper_raise_exception(cpu_env, tcg_const_i32(EXCP_DEBUG));
} else {
switch(dc->is_jmp) {
case DISAS_NEXT:
gen_flush_cc_op(dc);
gen_jmp_tb(dc, 0, dc->pc);
break;
default:
case DISAS_JUMP:
case DISAS_UPDATE:
gen_flush_cc_op(dc);
tcg_gen_exit_tb(0);
break;
case DISAS_TB_JUMP:
break;
}
}
gen_tb_end(tb, num_insns);
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("----------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(env, pc_start, dc->pc - pc_start, 0);
qemu_log("\n");
}
#endif
if (search_pc) {
j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
lj++;
while (lj <= j)
tcg_ctx.gen_opc_instr_start[lj++] = 0;
} else {
tb->size = dc->pc - pc_start;
tb->icount = num_insns;
}
}
| {
"code": [],
"line_no": []
} | FUNC_0(M68kCPU *VAR_0, TranslationBlock *VAR_1,
bool VAR_2)
{
CPUState *cs = CPU(VAR_0);
CPUM68KState *env = &VAR_0->env;
DisasContext dc1, *dc = &dc1;
uint16_t *gen_opc_end;
CPUBreakpoint *bp;
int VAR_3, VAR_4;
target_ulong pc_start;
int VAR_5;
int VAR_6;
int VAR_7;
pc_start = VAR_1->pc;
dc->VAR_1 = VAR_1;
gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;
dc->env = env;
dc->is_jmp = DISAS_NEXT;
dc->pc = pc_start;
dc->cc_op = CC_OP_DYNAMIC;
dc->singlestep_enabled = cs->singlestep_enabled;
dc->fpcr = env->fpcr;
dc->user = (env->sr & SR_S) == 0;
dc->is_mem = 0;
dc->done_mac = 0;
VAR_4 = -1;
VAR_6 = 0;
VAR_7 = VAR_1->cflags & CF_COUNT_MASK;
if (VAR_7 == 0)
VAR_7 = CF_COUNT_MASK;
gen_tb_start();
do {
VAR_5 = dc->pc - pc_start;
gen_throws_exception = NULL;
if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {
QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {
if (bp->pc == dc->pc) {
gen_exception(dc, dc->pc, EXCP_DEBUG);
dc->is_jmp = DISAS_JUMP;
break;
}
}
if (dc->is_jmp)
break;
}
if (VAR_2) {
VAR_3 = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
if (VAR_4 < VAR_3) {
VAR_4++;
while (VAR_4 < VAR_3)
tcg_ctx.gen_opc_instr_start[VAR_4++] = 0;
}
tcg_ctx.gen_opc_pc[VAR_4] = dc->pc;
tcg_ctx.gen_opc_instr_start[VAR_4] = 1;
tcg_ctx.gen_opc_icount[VAR_4] = VAR_6;
}
if (VAR_6 + 1 == VAR_7 && (VAR_1->cflags & CF_LAST_IO))
gen_io_start();
dc->insn_pc = dc->pc;
disas_m68k_insn(env, dc);
VAR_6++;
} while (!dc->is_jmp && tcg_ctx.gen_opc_ptr < gen_opc_end &&
!cs->singlestep_enabled &&
!singlestep &&
(VAR_5) < (TARGET_PAGE_SIZE - 32) &&
VAR_6 < VAR_7);
if (VAR_1->cflags & CF_LAST_IO)
gen_io_end();
if (unlikely(cs->singlestep_enabled)) {
if (!dc->is_jmp) {
gen_flush_cc_op(dc);
tcg_gen_movi_i32(QREG_PC, dc->pc);
}
gen_helper_raise_exception(cpu_env, tcg_const_i32(EXCP_DEBUG));
} else {
switch(dc->is_jmp) {
case DISAS_NEXT:
gen_flush_cc_op(dc);
gen_jmp_tb(dc, 0, dc->pc);
break;
default:
case DISAS_JUMP:
case DISAS_UPDATE:
gen_flush_cc_op(dc);
tcg_gen_exit_tb(0);
break;
case DISAS_TB_JUMP:
break;
}
}
gen_tb_end(VAR_1, VAR_6);
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("----------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(env, pc_start, dc->pc - pc_start, 0);
qemu_log("\n");
}
#endif
if (VAR_2) {
VAR_3 = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
VAR_4++;
while (VAR_4 <= VAR_3)
tcg_ctx.gen_opc_instr_start[VAR_4++] = 0;
} else {
VAR_1->size = dc->pc - pc_start;
VAR_1->icount = VAR_6;
}
}
| [
"FUNC_0(M68kCPU *VAR_0, TranslationBlock *VAR_1,\nbool VAR_2)\n{",
"CPUState *cs = CPU(VAR_0);",
"CPUM68KState *env = &VAR_0->env;",
"DisasContext dc1, *dc = &dc1;",
"uint16_t *gen_opc_end;",
"CPUBreakpoint *bp;",
"int VAR_3, VAR_4;",
"target_ulong pc_start;",
"int VAR_5;",
"int VAR_6;",
"int VAR_7;",
"pc_start = VAR_1->pc;",
"dc->VAR_1 = VAR_1;",
"gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;",
"dc->env = env;",
"dc->is_jmp = DISAS_NEXT;",
"dc->pc = pc_start;",
"dc->cc_op = CC_OP_DYNAMIC;",
"dc->singlestep_enabled = cs->singlestep_enabled;",
"dc->fpcr = env->fpcr;",
"dc->user = (env->sr & SR_S) == 0;",
"dc->is_mem = 0;",
"dc->done_mac = 0;",
"VAR_4 = -1;",
"VAR_6 = 0;",
"VAR_7 = VAR_1->cflags & CF_COUNT_MASK;",
"if (VAR_7 == 0)\nVAR_7 = CF_COUNT_MASK;",
"gen_tb_start();",
"do {",
"VAR_5 = dc->pc - pc_start;",
"gen_throws_exception = NULL;",
"if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {",
"QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {",
"if (bp->pc == dc->pc) {",
"gen_exception(dc, dc->pc, EXCP_DEBUG);",
"dc->is_jmp = DISAS_JUMP;",
"break;",
"}",
"}",
"if (dc->is_jmp)\nbreak;",
"}",
"if (VAR_2) {",
"VAR_3 = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;",
"if (VAR_4 < VAR_3) {",
"VAR_4++;",
"while (VAR_4 < VAR_3)\ntcg_ctx.gen_opc_instr_start[VAR_4++] = 0;",
"}",
"tcg_ctx.gen_opc_pc[VAR_4] = dc->pc;",
"tcg_ctx.gen_opc_instr_start[VAR_4] = 1;",
"tcg_ctx.gen_opc_icount[VAR_4] = VAR_6;",
"}",
"if (VAR_6 + 1 == VAR_7 && (VAR_1->cflags & CF_LAST_IO))\ngen_io_start();",
"dc->insn_pc = dc->pc;",
"disas_m68k_insn(env, dc);",
"VAR_6++;",
"} while (!dc->is_jmp && tcg_ctx.gen_opc_ptr < gen_opc_end &&",
"!cs->singlestep_enabled &&\n!singlestep &&\n(VAR_5) < (TARGET_PAGE_SIZE - 32) &&\nVAR_6 < VAR_7);",
"if (VAR_1->cflags & CF_LAST_IO)\ngen_io_end();",
"if (unlikely(cs->singlestep_enabled)) {",
"if (!dc->is_jmp) {",
"gen_flush_cc_op(dc);",
"tcg_gen_movi_i32(QREG_PC, dc->pc);",
"}",
"gen_helper_raise_exception(cpu_env, tcg_const_i32(EXCP_DEBUG));",
"} else {",
"switch(dc->is_jmp) {",
"case DISAS_NEXT:\ngen_flush_cc_op(dc);",
"gen_jmp_tb(dc, 0, dc->pc);",
"break;",
"default:\ncase DISAS_JUMP:\ncase DISAS_UPDATE:\ngen_flush_cc_op(dc);",
"tcg_gen_exit_tb(0);",
"break;",
"case DISAS_TB_JUMP:\nbreak;",
"}",
"}",
"gen_tb_end(VAR_1, VAR_6);",
"*tcg_ctx.gen_opc_ptr = INDEX_op_end;",
"#ifdef DEBUG_DISAS\nif (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {",
"qemu_log(\"----------------\\n\");",
"qemu_log(\"IN: %s\\n\", lookup_symbol(pc_start));",
"log_target_disas(env, pc_start, dc->pc - pc_start, 0);",
"qemu_log(\"\\n\");",
"}",
"#endif\nif (VAR_2) {",
"VAR_3 = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;",
"VAR_4++;",
"while (VAR_4 <= VAR_3)\ntcg_ctx.gen_opc_instr_start[VAR_4++] = 0;",
"} else {",
"VAR_1->size = dc->pc - pc_start;",
"VAR_1->icount = VAR_6;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
31
],
[
35
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67,
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97,
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111,
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125,
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137,
139,
141,
143
],
[
147,
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169,
171
],
[
173
],
[
175
],
[
177,
179,
181,
183
],
[
187
],
[
189
],
[
191,
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
207,
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221,
223
],
[
225
],
[
227
],
[
229,
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
247
]
] |
25,972 | static CCPrepare gen_prepare_eflags_c(DisasContext *s, TCGv reg)
{
TCGv t0, t1;
int size, shift;
switch (s->cc_op) {
case CC_OP_SUBB ... CC_OP_SUBQ:
/* (DATA_TYPE)(CC_DST + CC_SRC) < (DATA_TYPE)CC_SRC */
size = s->cc_op - CC_OP_SUBB;
t1 = gen_ext_tl(cpu_tmp0, cpu_cc_src, size, false);
/* If no temporary was used, be careful not to alias t1 and t0. */
t0 = TCGV_EQUAL(t1, cpu_cc_src) ? cpu_tmp0 : reg;
tcg_gen_add_tl(t0, cpu_cc_dst, cpu_cc_src);
gen_extu(size, t0);
goto add_sub;
case CC_OP_ADDB ... CC_OP_ADDQ:
/* (DATA_TYPE)CC_DST < (DATA_TYPE)CC_SRC */
size = s->cc_op - CC_OP_ADDB;
t1 = gen_ext_tl(cpu_tmp0, cpu_cc_src, size, false);
t0 = gen_ext_tl(reg, cpu_cc_dst, size, false);
add_sub:
return (CCPrepare) { .cond = TCG_COND_LTU, .reg = t0,
.reg2 = t1, .mask = -1, .use_reg2 = true };
case CC_OP_SBBB ... CC_OP_SBBQ:
/* (DATA_TYPE)(CC_DST + CC_SRC + 1) <= (DATA_TYPE)CC_SRC */
size = s->cc_op - CC_OP_SBBB;
t1 = gen_ext_tl(cpu_tmp0, cpu_cc_src, size, false);
if (TCGV_EQUAL(t1, reg) && TCGV_EQUAL(reg, cpu_cc_src)) {
tcg_gen_mov_tl(cpu_tmp0, cpu_cc_src);
t1 = cpu_tmp0;
}
tcg_gen_add_tl(reg, cpu_cc_dst, cpu_cc_src);
tcg_gen_addi_tl(reg, reg, 1);
gen_extu(size, reg);
t0 = reg;
goto adc_sbb;
case CC_OP_ADCB ... CC_OP_ADCQ:
/* (DATA_TYPE)CC_DST <= (DATA_TYPE)CC_SRC */
size = s->cc_op - CC_OP_ADCB;
t1 = gen_ext_tl(cpu_tmp0, cpu_cc_src, size, false);
t0 = gen_ext_tl(reg, cpu_cc_dst, size, false);
adc_sbb:
return (CCPrepare) { .cond = TCG_COND_LEU, .reg = t0,
.reg2 = t1, .mask = -1, .use_reg2 = true };
case CC_OP_LOGICB ... CC_OP_LOGICQ:
return (CCPrepare) { .cond = TCG_COND_NEVER, .mask = -1 };
case CC_OP_INCB ... CC_OP_INCQ:
case CC_OP_DECB ... CC_OP_DECQ:
return (CCPrepare) { .cond = TCG_COND_NE, .reg = cpu_cc_src,
.mask = -1, .no_setcond = true };
case CC_OP_SHLB ... CC_OP_SHLQ:
/* (CC_SRC >> (DATA_BITS - 1)) & 1 */
size = s->cc_op - CC_OP_SHLB;
shift = (8 << size) - 1;
return (CCPrepare) { .cond = TCG_COND_NE, .reg = cpu_cc_src,
.mask = (target_ulong)1 << shift };
case CC_OP_MULB ... CC_OP_MULQ:
return (CCPrepare) { .cond = TCG_COND_NE,
.reg = cpu_cc_src, .mask = -1 };
case CC_OP_EFLAGS:
case CC_OP_SARB ... CC_OP_SARQ:
/* CC_SRC & 1 */
return (CCPrepare) { .cond = TCG_COND_NE,
.reg = cpu_cc_src, .mask = CC_C };
default:
/* The need to compute only C from CC_OP_DYNAMIC is important
in efficiently implementing e.g. INC at the start of a TB. */
gen_update_cc_op(s);
gen_helper_cc_compute_c(cpu_tmp2_i32, cpu_env, cpu_cc_op);
tcg_gen_extu_i32_tl(reg, cpu_tmp2_i32);
return (CCPrepare) { .cond = TCG_COND_NE, .reg = reg,
.mask = -1, .no_setcond = true };
}
}
| false | qemu | a3251186fc6a04d421e9c4b65aa04ec32379ec38 | static CCPrepare gen_prepare_eflags_c(DisasContext *s, TCGv reg)
{
TCGv t0, t1;
int size, shift;
switch (s->cc_op) {
case CC_OP_SUBB ... CC_OP_SUBQ:
size = s->cc_op - CC_OP_SUBB;
t1 = gen_ext_tl(cpu_tmp0, cpu_cc_src, size, false);
t0 = TCGV_EQUAL(t1, cpu_cc_src) ? cpu_tmp0 : reg;
tcg_gen_add_tl(t0, cpu_cc_dst, cpu_cc_src);
gen_extu(size, t0);
goto add_sub;
case CC_OP_ADDB ... CC_OP_ADDQ:
size = s->cc_op - CC_OP_ADDB;
t1 = gen_ext_tl(cpu_tmp0, cpu_cc_src, size, false);
t0 = gen_ext_tl(reg, cpu_cc_dst, size, false);
add_sub:
return (CCPrepare) { .cond = TCG_COND_LTU, .reg = t0,
.reg2 = t1, .mask = -1, .use_reg2 = true };
case CC_OP_SBBB ... CC_OP_SBBQ:
size = s->cc_op - CC_OP_SBBB;
t1 = gen_ext_tl(cpu_tmp0, cpu_cc_src, size, false);
if (TCGV_EQUAL(t1, reg) && TCGV_EQUAL(reg, cpu_cc_src)) {
tcg_gen_mov_tl(cpu_tmp0, cpu_cc_src);
t1 = cpu_tmp0;
}
tcg_gen_add_tl(reg, cpu_cc_dst, cpu_cc_src);
tcg_gen_addi_tl(reg, reg, 1);
gen_extu(size, reg);
t0 = reg;
goto adc_sbb;
case CC_OP_ADCB ... CC_OP_ADCQ:
size = s->cc_op - CC_OP_ADCB;
t1 = gen_ext_tl(cpu_tmp0, cpu_cc_src, size, false);
t0 = gen_ext_tl(reg, cpu_cc_dst, size, false);
adc_sbb:
return (CCPrepare) { .cond = TCG_COND_LEU, .reg = t0,
.reg2 = t1, .mask = -1, .use_reg2 = true };
case CC_OP_LOGICB ... CC_OP_LOGICQ:
return (CCPrepare) { .cond = TCG_COND_NEVER, .mask = -1 };
case CC_OP_INCB ... CC_OP_INCQ:
case CC_OP_DECB ... CC_OP_DECQ:
return (CCPrepare) { .cond = TCG_COND_NE, .reg = cpu_cc_src,
.mask = -1, .no_setcond = true };
case CC_OP_SHLB ... CC_OP_SHLQ:
size = s->cc_op - CC_OP_SHLB;
shift = (8 << size) - 1;
return (CCPrepare) { .cond = TCG_COND_NE, .reg = cpu_cc_src,
.mask = (target_ulong)1 << shift };
case CC_OP_MULB ... CC_OP_MULQ:
return (CCPrepare) { .cond = TCG_COND_NE,
.reg = cpu_cc_src, .mask = -1 };
case CC_OP_EFLAGS:
case CC_OP_SARB ... CC_OP_SARQ:
return (CCPrepare) { .cond = TCG_COND_NE,
.reg = cpu_cc_src, .mask = CC_C };
default:
gen_update_cc_op(s);
gen_helper_cc_compute_c(cpu_tmp2_i32, cpu_env, cpu_cc_op);
tcg_gen_extu_i32_tl(reg, cpu_tmp2_i32);
return (CCPrepare) { .cond = TCG_COND_NE, .reg = reg,
.mask = -1, .no_setcond = true };
}
}
| {
"code": [],
"line_no": []
} | static CCPrepare FUNC_0(DisasContext *s, TCGv reg)
{
TCGv t0, t1;
int VAR_0, VAR_1;
switch (s->cc_op) {
case CC_OP_SUBB ... CC_OP_SUBQ:
VAR_0 = s->cc_op - CC_OP_SUBB;
t1 = gen_ext_tl(cpu_tmp0, cpu_cc_src, VAR_0, false);
t0 = TCGV_EQUAL(t1, cpu_cc_src) ? cpu_tmp0 : reg;
tcg_gen_add_tl(t0, cpu_cc_dst, cpu_cc_src);
gen_extu(VAR_0, t0);
goto add_sub;
case CC_OP_ADDB ... CC_OP_ADDQ:
VAR_0 = s->cc_op - CC_OP_ADDB;
t1 = gen_ext_tl(cpu_tmp0, cpu_cc_src, VAR_0, false);
t0 = gen_ext_tl(reg, cpu_cc_dst, VAR_0, false);
add_sub:
return (CCPrepare) { .cond = TCG_COND_LTU, .reg = t0,
.reg2 = t1, .mask = -1, .use_reg2 = true };
case CC_OP_SBBB ... CC_OP_SBBQ:
VAR_0 = s->cc_op - CC_OP_SBBB;
t1 = gen_ext_tl(cpu_tmp0, cpu_cc_src, VAR_0, false);
if (TCGV_EQUAL(t1, reg) && TCGV_EQUAL(reg, cpu_cc_src)) {
tcg_gen_mov_tl(cpu_tmp0, cpu_cc_src);
t1 = cpu_tmp0;
}
tcg_gen_add_tl(reg, cpu_cc_dst, cpu_cc_src);
tcg_gen_addi_tl(reg, reg, 1);
gen_extu(VAR_0, reg);
t0 = reg;
goto adc_sbb;
case CC_OP_ADCB ... CC_OP_ADCQ:
VAR_0 = s->cc_op - CC_OP_ADCB;
t1 = gen_ext_tl(cpu_tmp0, cpu_cc_src, VAR_0, false);
t0 = gen_ext_tl(reg, cpu_cc_dst, VAR_0, false);
adc_sbb:
return (CCPrepare) { .cond = TCG_COND_LEU, .reg = t0,
.reg2 = t1, .mask = -1, .use_reg2 = true };
case CC_OP_LOGICB ... CC_OP_LOGICQ:
return (CCPrepare) { .cond = TCG_COND_NEVER, .mask = -1 };
case CC_OP_INCB ... CC_OP_INCQ:
case CC_OP_DECB ... CC_OP_DECQ:
return (CCPrepare) { .cond = TCG_COND_NE, .reg = cpu_cc_src,
.mask = -1, .no_setcond = true };
case CC_OP_SHLB ... CC_OP_SHLQ:
VAR_0 = s->cc_op - CC_OP_SHLB;
VAR_1 = (8 << VAR_0) - 1;
return (CCPrepare) { .cond = TCG_COND_NE, .reg = cpu_cc_src,
.mask = (target_ulong)1 << VAR_1 };
case CC_OP_MULB ... CC_OP_MULQ:
return (CCPrepare) { .cond = TCG_COND_NE,
.reg = cpu_cc_src, .mask = -1 };
case CC_OP_EFLAGS:
case CC_OP_SARB ... CC_OP_SARQ:
return (CCPrepare) { .cond = TCG_COND_NE,
.reg = cpu_cc_src, .mask = CC_C };
default:
gen_update_cc_op(s);
gen_helper_cc_compute_c(cpu_tmp2_i32, cpu_env, cpu_cc_op);
tcg_gen_extu_i32_tl(reg, cpu_tmp2_i32);
return (CCPrepare) { .cond = TCG_COND_NE, .reg = reg,
.mask = -1, .no_setcond = true };
}
}
| [
"static CCPrepare FUNC_0(DisasContext *s, TCGv reg)\n{",
"TCGv t0, t1;",
"int VAR_0, VAR_1;",
"switch (s->cc_op) {",
"case CC_OP_SUBB ... CC_OP_SUBQ:\nVAR_0 = s->cc_op - CC_OP_SUBB;",
"t1 = gen_ext_tl(cpu_tmp0, cpu_cc_src, VAR_0, false);",
"t0 = TCGV_EQUAL(t1, cpu_cc_src) ? cpu_tmp0 : reg;",
"tcg_gen_add_tl(t0, cpu_cc_dst, cpu_cc_src);",
"gen_extu(VAR_0, t0);",
"goto add_sub;",
"case CC_OP_ADDB ... CC_OP_ADDQ:\nVAR_0 = s->cc_op - CC_OP_ADDB;",
"t1 = gen_ext_tl(cpu_tmp0, cpu_cc_src, VAR_0, false);",
"t0 = gen_ext_tl(reg, cpu_cc_dst, VAR_0, false);",
"add_sub:\nreturn (CCPrepare) { .cond = TCG_COND_LTU, .reg = t0,",
".reg2 = t1, .mask = -1, .use_reg2 = true };",
"case CC_OP_SBBB ... CC_OP_SBBQ:\nVAR_0 = s->cc_op - CC_OP_SBBB;",
"t1 = gen_ext_tl(cpu_tmp0, cpu_cc_src, VAR_0, false);",
"if (TCGV_EQUAL(t1, reg) && TCGV_EQUAL(reg, cpu_cc_src)) {",
"tcg_gen_mov_tl(cpu_tmp0, cpu_cc_src);",
"t1 = cpu_tmp0;",
"}",
"tcg_gen_add_tl(reg, cpu_cc_dst, cpu_cc_src);",
"tcg_gen_addi_tl(reg, reg, 1);",
"gen_extu(VAR_0, reg);",
"t0 = reg;",
"goto adc_sbb;",
"case CC_OP_ADCB ... CC_OP_ADCQ:\nVAR_0 = s->cc_op - CC_OP_ADCB;",
"t1 = gen_ext_tl(cpu_tmp0, cpu_cc_src, VAR_0, false);",
"t0 = gen_ext_tl(reg, cpu_cc_dst, VAR_0, false);",
"adc_sbb:\nreturn (CCPrepare) { .cond = TCG_COND_LEU, .reg = t0,",
".reg2 = t1, .mask = -1, .use_reg2 = true };",
"case CC_OP_LOGICB ... CC_OP_LOGICQ:\nreturn (CCPrepare) { .cond = TCG_COND_NEVER, .mask = -1 };",
"case CC_OP_INCB ... CC_OP_INCQ:\ncase CC_OP_DECB ... CC_OP_DECQ:\nreturn (CCPrepare) { .cond = TCG_COND_NE, .reg = cpu_cc_src,",
".mask = -1, .no_setcond = true };",
"case CC_OP_SHLB ... CC_OP_SHLQ:\nVAR_0 = s->cc_op - CC_OP_SHLB;",
"VAR_1 = (8 << VAR_0) - 1;",
"return (CCPrepare) { .cond = TCG_COND_NE, .reg = cpu_cc_src,",
".mask = (target_ulong)1 << VAR_1 };",
"case CC_OP_MULB ... CC_OP_MULQ:\nreturn (CCPrepare) { .cond = TCG_COND_NE,",
".reg = cpu_cc_src, .mask = -1 };",
"case CC_OP_EFLAGS:\ncase CC_OP_SARB ... CC_OP_SARQ:\nreturn (CCPrepare) { .cond = TCG_COND_NE,",
".reg = cpu_cc_src, .mask = CC_C };",
"default:\ngen_update_cc_op(s);",
"gen_helper_cc_compute_c(cpu_tmp2_i32, cpu_env, cpu_cc_op);",
"tcg_gen_extu_i32_tl(reg, cpu_tmp2_i32);",
"return (CCPrepare) { .cond = TCG_COND_NE, .reg = reg,",
".mask = -1, .no_setcond = true };",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33,
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
51,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81,
85
],
[
87
],
[
89
],
[
91,
93
],
[
95
],
[
99,
101
],
[
105,
107,
109
],
[
111
],
[
115,
119
],
[
121
],
[
123
],
[
125
],
[
129,
131
],
[
133
],
[
137,
139,
143
],
[
145
],
[
149,
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
]
] |
25,973 | static void pflash_cfi01_realize(DeviceState *dev, Error **errp)
{
pflash_t *pfl = CFI_PFLASH01(dev);
uint64_t total_len;
int ret;
uint64_t blocks_per_device, device_len;
int num_devices;
Error *local_err = NULL;
total_len = pfl->sector_len * pfl->nb_blocs;
/* These are only used to expose the parameters of each device
* in the cfi_table[].
*/
num_devices = pfl->device_width ? (pfl->bank_width / pfl->device_width) : 1;
blocks_per_device = pfl->nb_blocs / num_devices;
device_len = pfl->sector_len * blocks_per_device;
/* XXX: to be fixed */
#if 0
if (total_len != (8 * 1024 * 1024) && total_len != (16 * 1024 * 1024) &&
total_len != (32 * 1024 * 1024) && total_len != (64 * 1024 * 1024))
return NULL;
#endif
memory_region_init_rom_device(
&pfl->mem, OBJECT(dev),
pfl->be ? &pflash_cfi01_ops_be : &pflash_cfi01_ops_le, pfl,
pfl->name, total_len, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
vmstate_register_ram(&pfl->mem, DEVICE(pfl));
pfl->storage = memory_region_get_ram_ptr(&pfl->mem);
sysbus_init_mmio(SYS_BUS_DEVICE(dev), &pfl->mem);
if (pfl->bs) {
/* read the initial flash content */
ret = bdrv_read(pfl->bs, 0, pfl->storage, total_len >> 9);
if (ret < 0) {
vmstate_unregister_ram(&pfl->mem, DEVICE(pfl));
error_setg(errp, "failed to read the initial flash content");
return;
}
}
if (pfl->bs) {
pfl->ro = bdrv_is_read_only(pfl->bs);
} else {
pfl->ro = 0;
}
/* Default to devices being used at their maximum device width. This was
* assumed before the device_width support was added.
*/
if (!pfl->max_device_width) {
pfl->max_device_width = pfl->device_width;
}
pfl->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, pflash_timer, pfl);
pfl->wcycle = 0;
pfl->cmd = 0;
pfl->status = 0;
/* Hardcoded CFI table */
pfl->cfi_len = 0x52;
/* Standard "QRY" string */
pfl->cfi_table[0x10] = 'Q';
pfl->cfi_table[0x11] = 'R';
pfl->cfi_table[0x12] = 'Y';
/* Command set (Intel) */
pfl->cfi_table[0x13] = 0x01;
pfl->cfi_table[0x14] = 0x00;
/* Primary extended table address (none) */
pfl->cfi_table[0x15] = 0x31;
pfl->cfi_table[0x16] = 0x00;
/* Alternate command set (none) */
pfl->cfi_table[0x17] = 0x00;
pfl->cfi_table[0x18] = 0x00;
/* Alternate extended table (none) */
pfl->cfi_table[0x19] = 0x00;
pfl->cfi_table[0x1A] = 0x00;
/* Vcc min */
pfl->cfi_table[0x1B] = 0x45;
/* Vcc max */
pfl->cfi_table[0x1C] = 0x55;
/* Vpp min (no Vpp pin) */
pfl->cfi_table[0x1D] = 0x00;
/* Vpp max (no Vpp pin) */
pfl->cfi_table[0x1E] = 0x00;
/* Reserved */
pfl->cfi_table[0x1F] = 0x07;
/* Timeout for min size buffer write */
pfl->cfi_table[0x20] = 0x07;
/* Typical timeout for block erase */
pfl->cfi_table[0x21] = 0x0a;
/* Typical timeout for full chip erase (4096 ms) */
pfl->cfi_table[0x22] = 0x00;
/* Reserved */
pfl->cfi_table[0x23] = 0x04;
/* Max timeout for buffer write */
pfl->cfi_table[0x24] = 0x04;
/* Max timeout for block erase */
pfl->cfi_table[0x25] = 0x04;
/* Max timeout for chip erase */
pfl->cfi_table[0x26] = 0x00;
/* Device size */
pfl->cfi_table[0x27] = ctz32(device_len); /* + 1; */
/* Flash device interface (8 & 16 bits) */
pfl->cfi_table[0x28] = 0x02;
pfl->cfi_table[0x29] = 0x00;
/* Max number of bytes in multi-bytes write */
if (pfl->bank_width == 1) {
pfl->cfi_table[0x2A] = 0x08;
} else {
pfl->cfi_table[0x2A] = 0x0B;
}
pfl->writeblock_size = 1 << pfl->cfi_table[0x2A];
pfl->cfi_table[0x2B] = 0x00;
/* Number of erase block regions (uniform) */
pfl->cfi_table[0x2C] = 0x01;
/* Erase block region 1 */
pfl->cfi_table[0x2D] = blocks_per_device - 1;
pfl->cfi_table[0x2E] = (blocks_per_device - 1) >> 8;
pfl->cfi_table[0x2F] = pfl->sector_len >> 8;
pfl->cfi_table[0x30] = pfl->sector_len >> 16;
/* Extended */
pfl->cfi_table[0x31] = 'P';
pfl->cfi_table[0x32] = 'R';
pfl->cfi_table[0x33] = 'I';
pfl->cfi_table[0x34] = '1';
pfl->cfi_table[0x35] = '0';
pfl->cfi_table[0x36] = 0x00;
pfl->cfi_table[0x37] = 0x00;
pfl->cfi_table[0x38] = 0x00;
pfl->cfi_table[0x39] = 0x00;
pfl->cfi_table[0x3a] = 0x00;
pfl->cfi_table[0x3b] = 0x00;
pfl->cfi_table[0x3c] = 0x00;
pfl->cfi_table[0x3f] = 0x01; /* Number of protection fields */
}
| false | qemu | 4be746345f13e99e468c60acbd3a355e8183e3ce | static void pflash_cfi01_realize(DeviceState *dev, Error **errp)
{
pflash_t *pfl = CFI_PFLASH01(dev);
uint64_t total_len;
int ret;
uint64_t blocks_per_device, device_len;
int num_devices;
Error *local_err = NULL;
total_len = pfl->sector_len * pfl->nb_blocs;
num_devices = pfl->device_width ? (pfl->bank_width / pfl->device_width) : 1;
blocks_per_device = pfl->nb_blocs / num_devices;
device_len = pfl->sector_len * blocks_per_device;
#if 0
if (total_len != (8 * 1024 * 1024) && total_len != (16 * 1024 * 1024) &&
total_len != (32 * 1024 * 1024) && total_len != (64 * 1024 * 1024))
return NULL;
#endif
memory_region_init_rom_device(
&pfl->mem, OBJECT(dev),
pfl->be ? &pflash_cfi01_ops_be : &pflash_cfi01_ops_le, pfl,
pfl->name, total_len, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
vmstate_register_ram(&pfl->mem, DEVICE(pfl));
pfl->storage = memory_region_get_ram_ptr(&pfl->mem);
sysbus_init_mmio(SYS_BUS_DEVICE(dev), &pfl->mem);
if (pfl->bs) {
ret = bdrv_read(pfl->bs, 0, pfl->storage, total_len >> 9);
if (ret < 0) {
vmstate_unregister_ram(&pfl->mem, DEVICE(pfl));
error_setg(errp, "failed to read the initial flash content");
return;
}
}
if (pfl->bs) {
pfl->ro = bdrv_is_read_only(pfl->bs);
} else {
pfl->ro = 0;
}
if (!pfl->max_device_width) {
pfl->max_device_width = pfl->device_width;
}
pfl->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, pflash_timer, pfl);
pfl->wcycle = 0;
pfl->cmd = 0;
pfl->status = 0;
pfl->cfi_len = 0x52;
pfl->cfi_table[0x10] = 'Q';
pfl->cfi_table[0x11] = 'R';
pfl->cfi_table[0x12] = 'Y';
pfl->cfi_table[0x13] = 0x01;
pfl->cfi_table[0x14] = 0x00;
pfl->cfi_table[0x15] = 0x31;
pfl->cfi_table[0x16] = 0x00;
pfl->cfi_table[0x17] = 0x00;
pfl->cfi_table[0x18] = 0x00;
pfl->cfi_table[0x19] = 0x00;
pfl->cfi_table[0x1A] = 0x00;
pfl->cfi_table[0x1B] = 0x45;
pfl->cfi_table[0x1C] = 0x55;
pfl->cfi_table[0x1D] = 0x00;
pfl->cfi_table[0x1E] = 0x00;
pfl->cfi_table[0x1F] = 0x07;
pfl->cfi_table[0x20] = 0x07;
pfl->cfi_table[0x21] = 0x0a;
pfl->cfi_table[0x22] = 0x00;
pfl->cfi_table[0x23] = 0x04;
pfl->cfi_table[0x24] = 0x04;
pfl->cfi_table[0x25] = 0x04;
pfl->cfi_table[0x26] = 0x00;
pfl->cfi_table[0x27] = ctz32(device_len);
pfl->cfi_table[0x28] = 0x02;
pfl->cfi_table[0x29] = 0x00;
if (pfl->bank_width == 1) {
pfl->cfi_table[0x2A] = 0x08;
} else {
pfl->cfi_table[0x2A] = 0x0B;
}
pfl->writeblock_size = 1 << pfl->cfi_table[0x2A];
pfl->cfi_table[0x2B] = 0x00;
pfl->cfi_table[0x2C] = 0x01;
pfl->cfi_table[0x2D] = blocks_per_device - 1;
pfl->cfi_table[0x2E] = (blocks_per_device - 1) >> 8;
pfl->cfi_table[0x2F] = pfl->sector_len >> 8;
pfl->cfi_table[0x30] = pfl->sector_len >> 16;
pfl->cfi_table[0x31] = 'P';
pfl->cfi_table[0x32] = 'R';
pfl->cfi_table[0x33] = 'I';
pfl->cfi_table[0x34] = '1';
pfl->cfi_table[0x35] = '0';
pfl->cfi_table[0x36] = 0x00;
pfl->cfi_table[0x37] = 0x00;
pfl->cfi_table[0x38] = 0x00;
pfl->cfi_table[0x39] = 0x00;
pfl->cfi_table[0x3a] = 0x00;
pfl->cfi_table[0x3b] = 0x00;
pfl->cfi_table[0x3c] = 0x00;
pfl->cfi_table[0x3f] = 0x01;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
pflash_t *pfl = CFI_PFLASH01(VAR_0);
uint64_t total_len;
int VAR_2;
uint64_t blocks_per_device, device_len;
int VAR_3;
Error *local_err = NULL;
total_len = pfl->sector_len * pfl->nb_blocs;
VAR_3 = pfl->device_width ? (pfl->bank_width / pfl->device_width) : 1;
blocks_per_device = pfl->nb_blocs / VAR_3;
device_len = pfl->sector_len * blocks_per_device;
#if 0
if (total_len != (8 * 1024 * 1024) && total_len != (16 * 1024 * 1024) &&
total_len != (32 * 1024 * 1024) && total_len != (64 * 1024 * 1024))
return NULL;
#endif
memory_region_init_rom_device(
&pfl->mem, OBJECT(VAR_0),
pfl->be ? &pflash_cfi01_ops_be : &pflash_cfi01_ops_le, pfl,
pfl->name, total_len, &local_err);
if (local_err) {
error_propagate(VAR_1, local_err);
return;
}
vmstate_register_ram(&pfl->mem, DEVICE(pfl));
pfl->storage = memory_region_get_ram_ptr(&pfl->mem);
sysbus_init_mmio(SYS_BUS_DEVICE(VAR_0), &pfl->mem);
if (pfl->bs) {
VAR_2 = bdrv_read(pfl->bs, 0, pfl->storage, total_len >> 9);
if (VAR_2 < 0) {
vmstate_unregister_ram(&pfl->mem, DEVICE(pfl));
error_setg(VAR_1, "failed to read the initial flash content");
return;
}
}
if (pfl->bs) {
pfl->ro = bdrv_is_read_only(pfl->bs);
} else {
pfl->ro = 0;
}
if (!pfl->max_device_width) {
pfl->max_device_width = pfl->device_width;
}
pfl->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, pflash_timer, pfl);
pfl->wcycle = 0;
pfl->cmd = 0;
pfl->status = 0;
pfl->cfi_len = 0x52;
pfl->cfi_table[0x10] = 'Q';
pfl->cfi_table[0x11] = 'R';
pfl->cfi_table[0x12] = 'Y';
pfl->cfi_table[0x13] = 0x01;
pfl->cfi_table[0x14] = 0x00;
pfl->cfi_table[0x15] = 0x31;
pfl->cfi_table[0x16] = 0x00;
pfl->cfi_table[0x17] = 0x00;
pfl->cfi_table[0x18] = 0x00;
pfl->cfi_table[0x19] = 0x00;
pfl->cfi_table[0x1A] = 0x00;
pfl->cfi_table[0x1B] = 0x45;
pfl->cfi_table[0x1C] = 0x55;
pfl->cfi_table[0x1D] = 0x00;
pfl->cfi_table[0x1E] = 0x00;
pfl->cfi_table[0x1F] = 0x07;
pfl->cfi_table[0x20] = 0x07;
pfl->cfi_table[0x21] = 0x0a;
pfl->cfi_table[0x22] = 0x00;
pfl->cfi_table[0x23] = 0x04;
pfl->cfi_table[0x24] = 0x04;
pfl->cfi_table[0x25] = 0x04;
pfl->cfi_table[0x26] = 0x00;
pfl->cfi_table[0x27] = ctz32(device_len);
pfl->cfi_table[0x28] = 0x02;
pfl->cfi_table[0x29] = 0x00;
if (pfl->bank_width == 1) {
pfl->cfi_table[0x2A] = 0x08;
} else {
pfl->cfi_table[0x2A] = 0x0B;
}
pfl->writeblock_size = 1 << pfl->cfi_table[0x2A];
pfl->cfi_table[0x2B] = 0x00;
pfl->cfi_table[0x2C] = 0x01;
pfl->cfi_table[0x2D] = blocks_per_device - 1;
pfl->cfi_table[0x2E] = (blocks_per_device - 1) >> 8;
pfl->cfi_table[0x2F] = pfl->sector_len >> 8;
pfl->cfi_table[0x30] = pfl->sector_len >> 16;
pfl->cfi_table[0x31] = 'P';
pfl->cfi_table[0x32] = 'R';
pfl->cfi_table[0x33] = 'I';
pfl->cfi_table[0x34] = '1';
pfl->cfi_table[0x35] = '0';
pfl->cfi_table[0x36] = 0x00;
pfl->cfi_table[0x37] = 0x00;
pfl->cfi_table[0x38] = 0x00;
pfl->cfi_table[0x39] = 0x00;
pfl->cfi_table[0x3a] = 0x00;
pfl->cfi_table[0x3b] = 0x00;
pfl->cfi_table[0x3c] = 0x00;
pfl->cfi_table[0x3f] = 0x01;
}
| [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"pflash_t *pfl = CFI_PFLASH01(VAR_0);",
"uint64_t total_len;",
"int VAR_2;",
"uint64_t blocks_per_device, device_len;",
"int VAR_3;",
"Error *local_err = NULL;",
"total_len = pfl->sector_len * pfl->nb_blocs;",
"VAR_3 = pfl->device_width ? (pfl->bank_width / pfl->device_width) : 1;",
"blocks_per_device = pfl->nb_blocs / VAR_3;",
"device_len = pfl->sector_len * blocks_per_device;",
"#if 0\nif (total_len != (8 * 1024 * 1024) && total_len != (16 * 1024 * 1024) &&\ntotal_len != (32 * 1024 * 1024) && total_len != (64 * 1024 * 1024))\nreturn NULL;",
"#endif\nmemory_region_init_rom_device(\n&pfl->mem, OBJECT(VAR_0),\npfl->be ? &pflash_cfi01_ops_be : &pflash_cfi01_ops_le, pfl,\npfl->name, total_len, &local_err);",
"if (local_err) {",
"error_propagate(VAR_1, local_err);",
"return;",
"}",
"vmstate_register_ram(&pfl->mem, DEVICE(pfl));",
"pfl->storage = memory_region_get_ram_ptr(&pfl->mem);",
"sysbus_init_mmio(SYS_BUS_DEVICE(VAR_0), &pfl->mem);",
"if (pfl->bs) {",
"VAR_2 = bdrv_read(pfl->bs, 0, pfl->storage, total_len >> 9);",
"if (VAR_2 < 0) {",
"vmstate_unregister_ram(&pfl->mem, DEVICE(pfl));",
"error_setg(VAR_1, \"failed to read the initial flash content\");",
"return;",
"}",
"}",
"if (pfl->bs) {",
"pfl->ro = bdrv_is_read_only(pfl->bs);",
"} else {",
"pfl->ro = 0;",
"}",
"if (!pfl->max_device_width) {",
"pfl->max_device_width = pfl->device_width;",
"}",
"pfl->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, pflash_timer, pfl);",
"pfl->wcycle = 0;",
"pfl->cmd = 0;",
"pfl->status = 0;",
"pfl->cfi_len = 0x52;",
"pfl->cfi_table[0x10] = 'Q';",
"pfl->cfi_table[0x11] = 'R';",
"pfl->cfi_table[0x12] = 'Y';",
"pfl->cfi_table[0x13] = 0x01;",
"pfl->cfi_table[0x14] = 0x00;",
"pfl->cfi_table[0x15] = 0x31;",
"pfl->cfi_table[0x16] = 0x00;",
"pfl->cfi_table[0x17] = 0x00;",
"pfl->cfi_table[0x18] = 0x00;",
"pfl->cfi_table[0x19] = 0x00;",
"pfl->cfi_table[0x1A] = 0x00;",
"pfl->cfi_table[0x1B] = 0x45;",
"pfl->cfi_table[0x1C] = 0x55;",
"pfl->cfi_table[0x1D] = 0x00;",
"pfl->cfi_table[0x1E] = 0x00;",
"pfl->cfi_table[0x1F] = 0x07;",
"pfl->cfi_table[0x20] = 0x07;",
"pfl->cfi_table[0x21] = 0x0a;",
"pfl->cfi_table[0x22] = 0x00;",
"pfl->cfi_table[0x23] = 0x04;",
"pfl->cfi_table[0x24] = 0x04;",
"pfl->cfi_table[0x25] = 0x04;",
"pfl->cfi_table[0x26] = 0x00;",
"pfl->cfi_table[0x27] = ctz32(device_len);",
"pfl->cfi_table[0x28] = 0x02;",
"pfl->cfi_table[0x29] = 0x00;",
"if (pfl->bank_width == 1) {",
"pfl->cfi_table[0x2A] = 0x08;",
"} else {",
"pfl->cfi_table[0x2A] = 0x0B;",
"}",
"pfl->writeblock_size = 1 << pfl->cfi_table[0x2A];",
"pfl->cfi_table[0x2B] = 0x00;",
"pfl->cfi_table[0x2C] = 0x01;",
"pfl->cfi_table[0x2D] = blocks_per_device - 1;",
"pfl->cfi_table[0x2E] = (blocks_per_device - 1) >> 8;",
"pfl->cfi_table[0x2F] = pfl->sector_len >> 8;",
"pfl->cfi_table[0x30] = pfl->sector_len >> 16;",
"pfl->cfi_table[0x31] = 'P';",
"pfl->cfi_table[0x32] = 'R';",
"pfl->cfi_table[0x33] = 'I';",
"pfl->cfi_table[0x34] = '1';",
"pfl->cfi_table[0x35] = '0';",
"pfl->cfi_table[0x36] = 0x00;",
"pfl->cfi_table[0x37] = 0x00;",
"pfl->cfi_table[0x38] = 0x00;",
"pfl->cfi_table[0x39] = 0x00;",
"pfl->cfi_table[0x3a] = 0x00;",
"pfl->cfi_table[0x3b] = 0x00;",
"pfl->cfi_table[0x3c] = 0x00;",
"pfl->cfi_table[0x3f] = 0x01;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
29
],
[
31
],
[
33
],
[
39,
41,
43,
45
],
[
47,
51,
53,
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
77
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
],
[
153
],
[
155
],
[
159
],
[
161
],
[
165
],
[
167
],
[
171
],
[
175
],
[
179
],
[
183
],
[
187
],
[
191
],
[
195
],
[
199
],
[
203
],
[
207
],
[
211
],
[
215
],
[
219
],
[
223
],
[
225
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
243
],
[
247
],
[
251
],
[
253
],
[
255
],
[
257
],
[
263
],
[
265
],
[
267
],
[
271
],
[
273
],
[
277
],
[
279
],
[
281
],
[
283
],
[
287
],
[
291
],
[
293
],
[
297
],
[
299
]
] |
25,974 | static long do_rt_sigreturn_v2(CPUARMState *env)
{
abi_ulong frame_addr;
struct rt_sigframe_v2 *frame = NULL;
/*
* Since we stacked the signal on a 64-bit boundary,
* then 'sp' should be word aligned here. If it's
* not, then the user is trying to mess with us.
*/
frame_addr = env->regs[13];
trace_user_do_rt_sigreturn(env, frame_addr);
if (frame_addr & 7) {
goto badframe;
}
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
goto badframe;
}
if (do_sigframe_return_v2(env, frame_addr, &frame->uc)) {
goto badframe;
}
unlock_user_struct(frame, frame_addr, 0);
return env->regs[0];
badframe:
unlock_user_struct(frame, frame_addr, 0);
force_sig(TARGET_SIGSEGV /* , current */);
return 0;
}
| false | qemu | f0267ef7115656119bf00ed77857789adc036bda | static long do_rt_sigreturn_v2(CPUARMState *env)
{
abi_ulong frame_addr;
struct rt_sigframe_v2 *frame = NULL;
frame_addr = env->regs[13];
trace_user_do_rt_sigreturn(env, frame_addr);
if (frame_addr & 7) {
goto badframe;
}
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
goto badframe;
}
if (do_sigframe_return_v2(env, frame_addr, &frame->uc)) {
goto badframe;
}
unlock_user_struct(frame, frame_addr, 0);
return env->regs[0];
badframe:
unlock_user_struct(frame, frame_addr, 0);
force_sig(TARGET_SIGSEGV );
return 0;
}
| {
"code": [],
"line_no": []
} | static long FUNC_0(CPUARMState *VAR_0)
{
abi_ulong frame_addr;
struct rt_sigframe_v2 *VAR_1 = NULL;
frame_addr = VAR_0->regs[13];
trace_user_do_rt_sigreturn(VAR_0, frame_addr);
if (frame_addr & 7) {
goto badframe;
}
if (!lock_user_struct(VERIFY_READ, VAR_1, frame_addr, 1)) {
goto badframe;
}
if (do_sigframe_return_v2(VAR_0, frame_addr, &VAR_1->uc)) {
goto badframe;
}
unlock_user_struct(VAR_1, frame_addr, 0);
return VAR_0->regs[0];
badframe:
unlock_user_struct(VAR_1, frame_addr, 0);
force_sig(TARGET_SIGSEGV );
return 0;
}
| [
"static long FUNC_0(CPUARMState *VAR_0)\n{",
"abi_ulong frame_addr;",
"struct rt_sigframe_v2 *VAR_1 = NULL;",
"frame_addr = VAR_0->regs[13];",
"trace_user_do_rt_sigreturn(VAR_0, frame_addr);",
"if (frame_addr & 7) {",
"goto badframe;",
"}",
"if (!lock_user_struct(VERIFY_READ, VAR_1, frame_addr, 1)) {",
"goto badframe;",
"}",
"if (do_sigframe_return_v2(VAR_0, frame_addr, &VAR_1->uc)) {",
"goto badframe;",
"}",
"unlock_user_struct(VAR_1, frame_addr, 0);",
"return VAR_0->regs[0];",
"badframe:\nunlock_user_struct(VAR_1, frame_addr, 0);",
"force_sig(TARGET_SIGSEGV );",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
55,
57
],
[
59
],
[
61
],
[
63
]
] |
25,976 | void bdrv_drain_all_begin(void)
{
/* Always run first iteration so any pending completion BHs run */
bool waited = true;
BlockDriverState *bs;
BdrvNextIterator it;
GSList *aio_ctxs = NULL, *ctx;
block_job_pause_all();
for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
AioContext *aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
bdrv_parent_drained_begin(bs);
aio_disable_external(aio_context);
aio_context_release(aio_context);
if (!g_slist_find(aio_ctxs, aio_context)) {
aio_ctxs = g_slist_prepend(aio_ctxs, aio_context);
}
}
/* Note that completion of an asynchronous I/O operation can trigger any
* number of other I/O operations on other devices---for example a
* coroutine can submit an I/O request to another device in response to
* request completion. Therefore we must keep looping until there was no
* more activity rather than simply draining each device independently.
*/
while (waited) {
waited = false;
for (ctx = aio_ctxs; ctx != NULL; ctx = ctx->next) {
AioContext *aio_context = ctx->data;
aio_context_acquire(aio_context);
for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
if (aio_context == bdrv_get_aio_context(bs)) {
/* FIXME Calling this multiple times is wrong */
bdrv_drain_invoke(bs, true);
waited |= bdrv_drain_recurse(bs, true);
}
}
aio_context_release(aio_context);
}
}
g_slist_free(aio_ctxs);
}
| false | qemu | 2da9b7d456278bccc6ce889ae350f2867155d7e8 | void bdrv_drain_all_begin(void)
{
bool waited = true;
BlockDriverState *bs;
BdrvNextIterator it;
GSList *aio_ctxs = NULL, *ctx;
block_job_pause_all();
for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
AioContext *aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
bdrv_parent_drained_begin(bs);
aio_disable_external(aio_context);
aio_context_release(aio_context);
if (!g_slist_find(aio_ctxs, aio_context)) {
aio_ctxs = g_slist_prepend(aio_ctxs, aio_context);
}
}
while (waited) {
waited = false;
for (ctx = aio_ctxs; ctx != NULL; ctx = ctx->next) {
AioContext *aio_context = ctx->data;
aio_context_acquire(aio_context);
for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
if (aio_context == bdrv_get_aio_context(bs)) {
bdrv_drain_invoke(bs, true);
waited |= bdrv_drain_recurse(bs, true);
}
}
aio_context_release(aio_context);
}
}
g_slist_free(aio_ctxs);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(void)
{
bool waited = true;
BlockDriverState *bs;
BdrvNextIterator it;
GSList *aio_ctxs = NULL, *ctx;
block_job_pause_all();
for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
AioContext *aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
bdrv_parent_drained_begin(bs);
aio_disable_external(aio_context);
aio_context_release(aio_context);
if (!g_slist_find(aio_ctxs, aio_context)) {
aio_ctxs = g_slist_prepend(aio_ctxs, aio_context);
}
}
while (waited) {
waited = false;
for (ctx = aio_ctxs; ctx != NULL; ctx = ctx->next) {
AioContext *aio_context = ctx->data;
aio_context_acquire(aio_context);
for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
if (aio_context == bdrv_get_aio_context(bs)) {
bdrv_drain_invoke(bs, true);
waited |= bdrv_drain_recurse(bs, true);
}
}
aio_context_release(aio_context);
}
}
g_slist_free(aio_ctxs);
}
| [
"void FUNC_0(void)\n{",
"bool waited = true;",
"BlockDriverState *bs;",
"BdrvNextIterator it;",
"GSList *aio_ctxs = NULL, *ctx;",
"block_job_pause_all();",
"for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {",
"AioContext *aio_context = bdrv_get_aio_context(bs);",
"aio_context_acquire(aio_context);",
"bdrv_parent_drained_begin(bs);",
"aio_disable_external(aio_context);",
"aio_context_release(aio_context);",
"if (!g_slist_find(aio_ctxs, aio_context)) {",
"aio_ctxs = g_slist_prepend(aio_ctxs, aio_context);",
"}",
"}",
"while (waited) {",
"waited = false;",
"for (ctx = aio_ctxs; ctx != NULL; ctx = ctx->next) {",
"AioContext *aio_context = ctx->data;",
"aio_context_acquire(aio_context);",
"for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {",
"if (aio_context == bdrv_get_aio_context(bs)) {",
"bdrv_drain_invoke(bs, true);",
"waited |= bdrv_drain_recurse(bs, true);",
"}",
"}",
"aio_context_release(aio_context);",
"}",
"}",
"g_slist_free(aio_ctxs);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
59
],
[
61
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
]
] |
25,977 | static size_t qemu_rdma_save_page(QEMUFile *f, void *opaque,
ram_addr_t block_offset, ram_addr_t offset,
size_t size, int *bytes_sent)
{
QEMUFileRDMA *rfile = opaque;
RDMAContext *rdma = rfile->rdma;
int ret;
CHECK_ERROR_STATE();
qemu_fflush(f);
if (size > 0) {
/*
* Add this page to the current 'chunk'. If the chunk
* is full, or the page doen't belong to the current chunk,
* an actual RDMA write will occur and a new chunk will be formed.
*/
ret = qemu_rdma_write(f, rdma, block_offset, offset, size);
if (ret < 0) {
fprintf(stderr, "rdma migration: write error! %d\n", ret);
goto err;
}
/*
* We always return 1 bytes because the RDMA
* protocol is completely asynchronous. We do not yet know
* whether an identified chunk is zero or not because we're
* waiting for other pages to potentially be merged with
* the current chunk. So, we have to call qemu_update_position()
* later on when the actual write occurs.
*/
if (bytes_sent) {
*bytes_sent = 1;
}
} else {
uint64_t index, chunk;
/* TODO: Change QEMUFileOps prototype to be signed: size_t => long
if (size < 0) {
ret = qemu_rdma_drain_cq(f, rdma);
if (ret < 0) {
fprintf(stderr, "rdma: failed to synchronously drain"
" completion queue before unregistration.\n");
goto err;
}
}
*/
ret = qemu_rdma_search_ram_block(rdma, block_offset,
offset, size, &index, &chunk);
if (ret) {
fprintf(stderr, "ram block search failed\n");
goto err;
}
qemu_rdma_signal_unregister(rdma, index, chunk, 0);
/*
* TODO: Synchronous, guaranteed unregistration (should not occur during
* fast-path). Otherwise, unregisters will process on the next call to
* qemu_rdma_drain_cq()
if (size < 0) {
qemu_rdma_unregister_waiting(rdma);
}
*/
}
/*
* Drain the Completion Queue if possible, but do not block,
* just poll.
*
* If nothing to poll, the end of the iteration will do this
* again to make sure we don't overflow the request queue.
*/
while (1) {
uint64_t wr_id, wr_id_in;
int ret = qemu_rdma_poll(rdma, &wr_id_in, NULL);
if (ret < 0) {
fprintf(stderr, "rdma migration: polling error! %d\n", ret);
goto err;
}
wr_id = wr_id_in & RDMA_WRID_TYPE_MASK;
if (wr_id == RDMA_WRID_NONE) {
break;
}
}
return RAM_SAVE_CONTROL_DELAYED;
err:
rdma->error_state = ret;
return ret;
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | static size_t qemu_rdma_save_page(QEMUFile *f, void *opaque,
ram_addr_t block_offset, ram_addr_t offset,
size_t size, int *bytes_sent)
{
QEMUFileRDMA *rfile = opaque;
RDMAContext *rdma = rfile->rdma;
int ret;
CHECK_ERROR_STATE();
qemu_fflush(f);
if (size > 0) {
ret = qemu_rdma_write(f, rdma, block_offset, offset, size);
if (ret < 0) {
fprintf(stderr, "rdma migration: write error! %d\n", ret);
goto err;
}
if (bytes_sent) {
*bytes_sent = 1;
}
} else {
uint64_t index, chunk;
ret = qemu_rdma_search_ram_block(rdma, block_offset,
offset, size, &index, &chunk);
if (ret) {
fprintf(stderr, "ram block search failed\n");
goto err;
}
qemu_rdma_signal_unregister(rdma, index, chunk, 0);
}
while (1) {
uint64_t wr_id, wr_id_in;
int ret = qemu_rdma_poll(rdma, &wr_id_in, NULL);
if (ret < 0) {
fprintf(stderr, "rdma migration: polling error! %d\n", ret);
goto err;
}
wr_id = wr_id_in & RDMA_WRID_TYPE_MASK;
if (wr_id == RDMA_WRID_NONE) {
break;
}
}
return RAM_SAVE_CONTROL_DELAYED;
err:
rdma->error_state = ret;
return ret;
}
| {
"code": [],
"line_no": []
} | static size_t FUNC_0(QEMUFile *f, void *opaque,
ram_addr_t block_offset, ram_addr_t offset,
size_t size, int *bytes_sent)
{
QEMUFileRDMA *rfile = opaque;
RDMAContext *rdma = rfile->rdma;
int VAR_1;
CHECK_ERROR_STATE();
qemu_fflush(f);
if (size > 0) {
VAR_1 = qemu_rdma_write(f, rdma, block_offset, offset, size);
if (VAR_1 < 0) {
fprintf(stderr, "rdma migration: write error! %d\n", VAR_1);
goto err;
}
if (bytes_sent) {
*bytes_sent = 1;
}
} else {
uint64_t index, chunk;
VAR_1 = qemu_rdma_search_ram_block(rdma, block_offset,
offset, size, &index, &chunk);
if (VAR_1) {
fprintf(stderr, "ram block search failed\n");
goto err;
}
qemu_rdma_signal_unregister(rdma, index, chunk, 0);
}
while (1) {
uint64_t wr_id, wr_id_in;
int VAR_1 = qemu_rdma_poll(rdma, &wr_id_in, NULL);
if (VAR_1 < 0) {
fprintf(stderr, "rdma migration: polling error! %d\n", VAR_1);
goto err;
}
wr_id = wr_id_in & RDMA_WRID_TYPE_MASK;
if (wr_id == RDMA_WRID_NONE) {
break;
}
}
return RAM_SAVE_CONTROL_DELAYED;
err:
rdma->error_state = VAR_1;
return VAR_1;
}
| [
"static size_t FUNC_0(QEMUFile *f, void *opaque,\nram_addr_t block_offset, ram_addr_t offset,\nsize_t size, int *bytes_sent)\n{",
"QEMUFileRDMA *rfile = opaque;",
"RDMAContext *rdma = rfile->rdma;",
"int VAR_1;",
"CHECK_ERROR_STATE();",
"qemu_fflush(f);",
"if (size > 0) {",
"VAR_1 = qemu_rdma_write(f, rdma, block_offset, offset, size);",
"if (VAR_1 < 0) {",
"fprintf(stderr, \"rdma migration: write error! %d\\n\", VAR_1);",
"goto err;",
"}",
"if (bytes_sent) {",
"*bytes_sent = 1;",
"}",
"} else {",
"uint64_t index, chunk;",
"VAR_1 = qemu_rdma_search_ram_block(rdma, block_offset,\noffset, size, &index, &chunk);",
"if (VAR_1) {",
"fprintf(stderr, \"ram block search failed\\n\");",
"goto err;",
"}",
"qemu_rdma_signal_unregister(rdma, index, chunk, 0);",
"}",
"while (1) {",
"uint64_t wr_id, wr_id_in;",
"int VAR_1 = qemu_rdma_poll(rdma, &wr_id_in, NULL);",
"if (VAR_1 < 0) {",
"fprintf(stderr, \"rdma migration: polling error! %d\\n\", VAR_1);",
"goto err;",
"}",
"wr_id = wr_id_in & RDMA_WRID_TYPE_MASK;",
"if (wr_id == RDMA_WRID_NONE) {",
"break;",
"}",
"}",
"return RAM_SAVE_CONTROL_DELAYED;",
"err:\nrdma->error_state = VAR_1;",
"return VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
25
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
99,
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
135
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169
],
[
173
],
[
175
],
[
177
],
[
179
],
[
183
],
[
185,
187
],
[
189
],
[
191
]
] |
25,978 | int xen_be_init(void)
{
xenstore = xs_daemon_open();
if (!xenstore) {
xen_be_printf(NULL, 0, "can't connect to xenstored\n");
return -1;
}
if (qemu_set_fd_handler(xs_fileno(xenstore), xenstore_update, NULL, NULL) < 0) {
goto err;
}
if (xen_xc == XC_HANDLER_INITIAL_VALUE) {
/* Check if xen_init() have been called */
goto err;
}
return 0;
err:
qemu_set_fd_handler(xs_fileno(xenstore), NULL, NULL, NULL);
xs_daemon_close(xenstore);
xenstore = NULL;
return -1;
}
| true | qemu | 6b5166f8a82888638bb9aba9dc49aa7fa25f292f | int xen_be_init(void)
{
xenstore = xs_daemon_open();
if (!xenstore) {
xen_be_printf(NULL, 0, "can't connect to xenstored\n");
return -1;
}
if (qemu_set_fd_handler(xs_fileno(xenstore), xenstore_update, NULL, NULL) < 0) {
goto err;
}
if (xen_xc == XC_HANDLER_INITIAL_VALUE) {
goto err;
}
return 0;
err:
qemu_set_fd_handler(xs_fileno(xenstore), NULL, NULL, NULL);
xs_daemon_close(xenstore);
xenstore = NULL;
return -1;
}
| {
"code": [
" if (qemu_set_fd_handler(xs_fileno(xenstore), xenstore_update, NULL, NULL) < 0) {",
" goto err;"
],
"line_no": [
17,
19
]
} | int FUNC_0(void)
{
xenstore = xs_daemon_open();
if (!xenstore) {
xen_be_printf(NULL, 0, "can't connect to xenstored\n");
return -1;
}
if (qemu_set_fd_handler(xs_fileno(xenstore), xenstore_update, NULL, NULL) < 0) {
goto err;
}
if (xen_xc == XC_HANDLER_INITIAL_VALUE) {
goto err;
}
return 0;
err:
qemu_set_fd_handler(xs_fileno(xenstore), NULL, NULL, NULL);
xs_daemon_close(xenstore);
xenstore = NULL;
return -1;
}
| [
"int FUNC_0(void)\n{",
"xenstore = xs_daemon_open();",
"if (!xenstore) {",
"xen_be_printf(NULL, 0, \"can't connect to xenstored\\n\");",
"return -1;",
"}",
"if (qemu_set_fd_handler(xs_fileno(xenstore), xenstore_update, NULL, NULL) < 0) {",
"goto err;",
"}",
"if (xen_xc == XC_HANDLER_INITIAL_VALUE) {",
"goto err;",
"}",
"return 0;",
"err:\nqemu_set_fd_handler(xs_fileno(xenstore), NULL, NULL, NULL);",
"xs_daemon_close(xenstore);",
"xenstore = NULL;",
"return -1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37,
39
],
[
41
],
[
43
],
[
47
],
[
49
]
] |
25,979 | static void guess_palette(DVDSubContext* ctx,
uint32_t *rgba_palette,
uint32_t subtitle_color)
{
static const uint8_t level_map[4][4] = {
// this configuration (full range, lowest to highest) in tests
// seemed most common, so assume this
{0xff},
{0x00, 0xff},
{0x00, 0x80, 0xff},
{0x00, 0x55, 0xaa, 0xff},
};
uint8_t color_used[16] = { 0 };
int nb_opaque_colors, i, level, j, r, g, b;
uint8_t *colormap = ctx->colormap, *alpha = ctx->alpha;
if(ctx->has_palette) {
for(i = 0; i < 4; i++)
rgba_palette[i] = (ctx->palette[colormap[i]] & 0x00ffffff)
| ((alpha[i] * 17U) << 24);
return;
}
for(i = 0; i < 4; i++)
rgba_palette[i] = 0;
nb_opaque_colors = 0;
for(i = 0; i < 4; i++) {
if (alpha[i] != 0 && !color_used[colormap[i]]) {
color_used[colormap[i]] = 1;
nb_opaque_colors++;
}
}
if (nb_opaque_colors == 0)
return;
j = 0;
memset(color_used, 0, 16);
for(i = 0; i < 4; i++) {
if (alpha[i] != 0) {
if (!color_used[colormap[i]]) {
level = level_map[nb_opaque_colors - 1][j];
r = (((subtitle_color >> 16) & 0xff) * level) >> 8;
g = (((subtitle_color >> 8) & 0xff) * level) >> 8;
b = (((subtitle_color >> 0) & 0xff) * level) >> 8;
rgba_palette[i] = b | (g << 8) | (r << 16) | ((alpha[i] * 17) << 24);
color_used[colormap[i]] = (i + 1);
j++;
} else {
rgba_palette[i] = (rgba_palette[color_used[colormap[i]] - 1] & 0x00ffffff) |
((alpha[i] * 17) << 24);
}
}
}
}
| true | FFmpeg | 61ee2ca7758672128e30b3e87908b6845e006d71 | static void guess_palette(DVDSubContext* ctx,
uint32_t *rgba_palette,
uint32_t subtitle_color)
{
static const uint8_t level_map[4][4] = {
{0xff},
{0x00, 0xff},
{0x00, 0x80, 0xff},
{0x00, 0x55, 0xaa, 0xff},
};
uint8_t color_used[16] = { 0 };
int nb_opaque_colors, i, level, j, r, g, b;
uint8_t *colormap = ctx->colormap, *alpha = ctx->alpha;
if(ctx->has_palette) {
for(i = 0; i < 4; i++)
rgba_palette[i] = (ctx->palette[colormap[i]] & 0x00ffffff)
| ((alpha[i] * 17U) << 24);
return;
}
for(i = 0; i < 4; i++)
rgba_palette[i] = 0;
nb_opaque_colors = 0;
for(i = 0; i < 4; i++) {
if (alpha[i] != 0 && !color_used[colormap[i]]) {
color_used[colormap[i]] = 1;
nb_opaque_colors++;
}
}
if (nb_opaque_colors == 0)
return;
j = 0;
memset(color_used, 0, 16);
for(i = 0; i < 4; i++) {
if (alpha[i] != 0) {
if (!color_used[colormap[i]]) {
level = level_map[nb_opaque_colors - 1][j];
r = (((subtitle_color >> 16) & 0xff) * level) >> 8;
g = (((subtitle_color >> 8) & 0xff) * level) >> 8;
b = (((subtitle_color >> 0) & 0xff) * level) >> 8;
rgba_palette[i] = b | (g << 8) | (r << 16) | ((alpha[i] * 17) << 24);
color_used[colormap[i]] = (i + 1);
j++;
} else {
rgba_palette[i] = (rgba_palette[color_used[colormap[i]] - 1] & 0x00ffffff) |
((alpha[i] * 17) << 24);
}
}
}
}
| {
"code": [
" rgba_palette[i] = b | (g << 8) | (r << 16) | ((alpha[i] * 17) << 24);",
" ((alpha[i] * 17) << 24);"
],
"line_no": [
93,
103
]
} | static void FUNC_0(DVDSubContext* VAR_0,
uint32_t *VAR_1,
uint32_t VAR_2)
{
static const uint8_t VAR_3[4][4] = {
{0xff},
{0x00, 0xff},
{0x00, 0x80, 0xff},
{0x00, 0x55, 0xaa, 0xff},
};
uint8_t color_used[16] = { 0 };
int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;
uint8_t *colormap = VAR_0->colormap, *alpha = VAR_0->alpha;
if(VAR_0->has_palette) {
for(VAR_5 = 0; VAR_5 < 4; VAR_5++)
VAR_1[VAR_5] = (VAR_0->palette[colormap[VAR_5]] & 0x00ffffff)
| ((alpha[VAR_5] * 17U) << 24);
return;
}
for(VAR_5 = 0; VAR_5 < 4; VAR_5++)
VAR_1[VAR_5] = 0;
VAR_4 = 0;
for(VAR_5 = 0; VAR_5 < 4; VAR_5++) {
if (alpha[VAR_5] != 0 && !color_used[colormap[VAR_5]]) {
color_used[colormap[VAR_5]] = 1;
VAR_4++;
}
}
if (VAR_4 == 0)
return;
VAR_7 = 0;
memset(color_used, 0, 16);
for(VAR_5 = 0; VAR_5 < 4; VAR_5++) {
if (alpha[VAR_5] != 0) {
if (!color_used[colormap[VAR_5]]) {
VAR_6 = VAR_3[VAR_4 - 1][VAR_7];
VAR_8 = (((VAR_2 >> 16) & 0xff) * VAR_6) >> 8;
VAR_9 = (((VAR_2 >> 8) & 0xff) * VAR_6) >> 8;
VAR_10 = (((VAR_2 >> 0) & 0xff) * VAR_6) >> 8;
VAR_1[VAR_5] = VAR_10 | (VAR_9 << 8) | (VAR_8 << 16) | ((alpha[VAR_5] * 17) << 24);
color_used[colormap[VAR_5]] = (VAR_5 + 1);
VAR_7++;
} else {
VAR_1[VAR_5] = (VAR_1[color_used[colormap[VAR_5]] - 1] & 0x00ffffff) |
((alpha[VAR_5] * 17) << 24);
}
}
}
}
| [
"static void FUNC_0(DVDSubContext* VAR_0,\nuint32_t *VAR_1,\nuint32_t VAR_2)\n{",
"static const uint8_t VAR_3[4][4] = {",
"{0xff},",
"{0x00, 0xff},",
"{0x00, 0x80, 0xff},",
"{0x00, 0x55, 0xaa, 0xff},",
"};",
"uint8_t color_used[16] = { 0 };",
"int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;",
"uint8_t *colormap = VAR_0->colormap, *alpha = VAR_0->alpha;",
"if(VAR_0->has_palette) {",
"for(VAR_5 = 0; VAR_5 < 4; VAR_5++)",
"VAR_1[VAR_5] = (VAR_0->palette[colormap[VAR_5]] & 0x00ffffff)\n| ((alpha[VAR_5] * 17U) << 24);",
"return;",
"}",
"for(VAR_5 = 0; VAR_5 < 4; VAR_5++)",
"VAR_1[VAR_5] = 0;",
"VAR_4 = 0;",
"for(VAR_5 = 0; VAR_5 < 4; VAR_5++) {",
"if (alpha[VAR_5] != 0 && !color_used[colormap[VAR_5]]) {",
"color_used[colormap[VAR_5]] = 1;",
"VAR_4++;",
"}",
"}",
"if (VAR_4 == 0)\nreturn;",
"VAR_7 = 0;",
"memset(color_used, 0, 16);",
"for(VAR_5 = 0; VAR_5 < 4; VAR_5++) {",
"if (alpha[VAR_5] != 0) {",
"if (!color_used[colormap[VAR_5]]) {",
"VAR_6 = VAR_3[VAR_4 - 1][VAR_7];",
"VAR_8 = (((VAR_2 >> 16) & 0xff) * VAR_6) >> 8;",
"VAR_9 = (((VAR_2 >> 8) & 0xff) * VAR_6) >> 8;",
"VAR_10 = (((VAR_2 >> 0) & 0xff) * VAR_6) >> 8;",
"VAR_1[VAR_5] = VAR_10 | (VAR_9 << 8) | (VAR_8 << 16) | ((alpha[VAR_5] * 17) << 24);",
"color_used[colormap[VAR_5]] = (VAR_5 + 1);",
"VAR_7++;",
"} else {",
"VAR_1[VAR_5] = (VAR_1[color_used[colormap[VAR_5]] - 1] & 0x00ffffff) |\n((alpha[VAR_5] * 17) << 24);",
"}",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69,
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101,
103
],
[
105
],
[
107
],
[
109
],
[
111
]
] |
25,981 | int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice)
{
MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = first_slice ? h->mmco : mmco_temp;
int mmco_index = 0, i;
assert(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count);
if (h->short_ref_count &&
h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count &&
!(FIELD_PICTURE(h) && !h->first_field && h->cur_pic_ptr->reference)) {
mmco[0].opcode = MMCO_SHORT2UNUSED;
mmco[0].short_pic_num = h->short_ref[h->short_ref_count - 1]->frame_num;
mmco_index = 1;
if (FIELD_PICTURE(h)) {
mmco[0].short_pic_num *= 2;
mmco[1].opcode = MMCO_SHORT2UNUSED;
mmco[1].short_pic_num = mmco[0].short_pic_num + 1;
mmco_index = 2;
}
}
if (first_slice) {
h->mmco_index = mmco_index;
} else if (!first_slice && mmco_index >= 0 &&
(mmco_index != h->mmco_index ||
(i = check_opcodes(h->mmco, mmco_temp, mmco_index)))) {
av_log(h->avctx, AV_LOG_ERROR,
"Inconsistent MMCO state between slices [%d, %d, %d]\n",
mmco_index, h->mmco_index, i);
return AVERROR_INVALIDDATA;
}
return 0;
}
| true | FFmpeg | f4bd9fe326ad1315a74206939ae56df93b940a09 | int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice)
{
MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = first_slice ? h->mmco : mmco_temp;
int mmco_index = 0, i;
assert(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count);
if (h->short_ref_count &&
h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count &&
!(FIELD_PICTURE(h) && !h->first_field && h->cur_pic_ptr->reference)) {
mmco[0].opcode = MMCO_SHORT2UNUSED;
mmco[0].short_pic_num = h->short_ref[h->short_ref_count - 1]->frame_num;
mmco_index = 1;
if (FIELD_PICTURE(h)) {
mmco[0].short_pic_num *= 2;
mmco[1].opcode = MMCO_SHORT2UNUSED;
mmco[1].short_pic_num = mmco[0].short_pic_num + 1;
mmco_index = 2;
}
}
if (first_slice) {
h->mmco_index = mmco_index;
} else if (!first_slice && mmco_index >= 0 &&
(mmco_index != h->mmco_index ||
(i = check_opcodes(h->mmco, mmco_temp, mmco_index)))) {
av_log(h->avctx, AV_LOG_ERROR,
"Inconsistent MMCO state between slices [%d, %d, %d]\n",
mmco_index, h->mmco_index, i);
return AVERROR_INVALIDDATA;
}
return 0;
}
| {
"code": [
" int mmco_index = 0, i;"
],
"line_no": [
7
]
} | int FUNC_0(H264Context *VAR_0, int VAR_1)
{
MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = VAR_1 ? VAR_0->mmco : mmco_temp;
int VAR_2 = 0, VAR_3;
assert(VAR_0->long_ref_count + VAR_0->short_ref_count <= VAR_0->sps.ref_frame_count);
if (VAR_0->short_ref_count &&
VAR_0->long_ref_count + VAR_0->short_ref_count == VAR_0->sps.ref_frame_count &&
!(FIELD_PICTURE(VAR_0) && !VAR_0->first_field && VAR_0->cur_pic_ptr->reference)) {
mmco[0].opcode = MMCO_SHORT2UNUSED;
mmco[0].short_pic_num = VAR_0->short_ref[VAR_0->short_ref_count - 1]->frame_num;
VAR_2 = 1;
if (FIELD_PICTURE(VAR_0)) {
mmco[0].short_pic_num *= 2;
mmco[1].opcode = MMCO_SHORT2UNUSED;
mmco[1].short_pic_num = mmco[0].short_pic_num + 1;
VAR_2 = 2;
}
}
if (VAR_1) {
VAR_0->VAR_2 = VAR_2;
} else if (!VAR_1 && VAR_2 >= 0 &&
(VAR_2 != VAR_0->VAR_2 ||
(VAR_3 = check_opcodes(VAR_0->mmco, mmco_temp, VAR_2)))) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Inconsistent MMCO state between slices [%d, %d, %d]\n",
VAR_2, VAR_0->VAR_2, VAR_3);
return AVERROR_INVALIDDATA;
}
return 0;
}
| [
"int FUNC_0(H264Context *VAR_0, int VAR_1)\n{",
"MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = VAR_1 ? VAR_0->mmco : mmco_temp;",
"int VAR_2 = 0, VAR_3;",
"assert(VAR_0->long_ref_count + VAR_0->short_ref_count <= VAR_0->sps.ref_frame_count);",
"if (VAR_0->short_ref_count &&\nVAR_0->long_ref_count + VAR_0->short_ref_count == VAR_0->sps.ref_frame_count &&\n!(FIELD_PICTURE(VAR_0) && !VAR_0->first_field && VAR_0->cur_pic_ptr->reference)) {",
"mmco[0].opcode = MMCO_SHORT2UNUSED;",
"mmco[0].short_pic_num = VAR_0->short_ref[VAR_0->short_ref_count - 1]->frame_num;",
"VAR_2 = 1;",
"if (FIELD_PICTURE(VAR_0)) {",
"mmco[0].short_pic_num *= 2;",
"mmco[1].opcode = MMCO_SHORT2UNUSED;",
"mmco[1].short_pic_num = mmco[0].short_pic_num + 1;",
"VAR_2 = 2;",
"}",
"}",
"if (VAR_1) {",
"VAR_0->VAR_2 = VAR_2;",
"} else if (!VAR_1 && VAR_2 >= 0 &&",
"(VAR_2 != VAR_0->VAR_2 ||\n(VAR_3 = check_opcodes(VAR_0->mmco, mmco_temp, VAR_2)))) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Inconsistent MMCO state between slices [%d, %d, %d]\\n\",\nVAR_2, VAR_0->VAR_2, VAR_3);",
"return AVERROR_INVALIDDATA;",
"}",
"return 0;",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15,
17,
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
53,
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
]
] |
25,983 | ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
int iwidth, int iheight,
int topBand, int bottomBand,
int leftBand, int rightBand,
int padtop, int padbottom,
int padleft, int padright)
{
ImgReSampleContext *s;
s = av_mallocz(sizeof(ImgReSampleContext));
if (!s)
s->line_buf = av_mallocz(owidth * (LINE_BUF_HEIGHT + NB_TAPS));
if (!s->line_buf)
goto fail;
s->owidth = owidth;
s->oheight = oheight;
s->iwidth = iwidth;
s->iheight = iheight;
s->topBand = topBand;
s->bottomBand = bottomBand;
s->leftBand = leftBand;
s->rightBand = rightBand;
s->padtop = padtop;
s->padbottom = padbottom;
s->padleft = padleft;
s->padright = padright;
s->pad_owidth = owidth - (padleft + padright);
s->pad_oheight = oheight - (padtop + padbottom);
s->h_incr = ((iwidth - leftBand - rightBand) * POS_FRAC) / s->pad_owidth;
s->v_incr = ((iheight - topBand - bottomBand) * POS_FRAC) / s->pad_oheight;
av_build_filter(&s->h_filters[0][0], (float) s->pad_owidth /
(float) (iwidth - leftBand - rightBand), NB_TAPS, NB_PHASES, 1<<FILTER_BITS, 0);
av_build_filter(&s->v_filters[0][0], (float) s->pad_oheight /
(float) (iheight - topBand - bottomBand), NB_TAPS, NB_PHASES, 1<<FILTER_BITS, 0);
return s;
fail:
av_free(s);
} | true | FFmpeg | 0ecca7a49f8e254c12a3a1de048d738bfbb614c6 | ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
int iwidth, int iheight,
int topBand, int bottomBand,
int leftBand, int rightBand,
int padtop, int padbottom,
int padleft, int padright)
{
ImgReSampleContext *s;
s = av_mallocz(sizeof(ImgReSampleContext));
if (!s)
s->line_buf = av_mallocz(owidth * (LINE_BUF_HEIGHT + NB_TAPS));
if (!s->line_buf)
goto fail;
s->owidth = owidth;
s->oheight = oheight;
s->iwidth = iwidth;
s->iheight = iheight;
s->topBand = topBand;
s->bottomBand = bottomBand;
s->leftBand = leftBand;
s->rightBand = rightBand;
s->padtop = padtop;
s->padbottom = padbottom;
s->padleft = padleft;
s->padright = padright;
s->pad_owidth = owidth - (padleft + padright);
s->pad_oheight = oheight - (padtop + padbottom);
s->h_incr = ((iwidth - leftBand - rightBand) * POS_FRAC) / s->pad_owidth;
s->v_incr = ((iheight - topBand - bottomBand) * POS_FRAC) / s->pad_oheight;
av_build_filter(&s->h_filters[0][0], (float) s->pad_owidth /
(float) (iwidth - leftBand - rightBand), NB_TAPS, NB_PHASES, 1<<FILTER_BITS, 0);
av_build_filter(&s->v_filters[0][0], (float) s->pad_oheight /
(float) (iheight - topBand - bottomBand), NB_TAPS, NB_PHASES, 1<<FILTER_BITS, 0);
return s;
fail:
av_free(s);
} | {
"code": [],
"line_no": []
} | ImgReSampleContext *FUNC_0(int owidth, int oheight,
int iwidth, int iheight,
int topBand, int bottomBand,
int leftBand, int rightBand,
int padtop, int padbottom,
int padleft, int padright)
{
ImgReSampleContext *s;
s = av_mallocz(sizeof(ImgReSampleContext));
if (!s)
s->line_buf = av_mallocz(owidth * (LINE_BUF_HEIGHT + NB_TAPS));
if (!s->line_buf)
goto fail;
s->owidth = owidth;
s->oheight = oheight;
s->iwidth = iwidth;
s->iheight = iheight;
s->topBand = topBand;
s->bottomBand = bottomBand;
s->leftBand = leftBand;
s->rightBand = rightBand;
s->padtop = padtop;
s->padbottom = padbottom;
s->padleft = padleft;
s->padright = padright;
s->pad_owidth = owidth - (padleft + padright);
s->pad_oheight = oheight - (padtop + padbottom);
s->h_incr = ((iwidth - leftBand - rightBand) * POS_FRAC) / s->pad_owidth;
s->v_incr = ((iheight - topBand - bottomBand) * POS_FRAC) / s->pad_oheight;
av_build_filter(&s->h_filters[0][0], (float) s->pad_owidth /
(float) (iwidth - leftBand - rightBand), NB_TAPS, NB_PHASES, 1<<FILTER_BITS, 0);
av_build_filter(&s->v_filters[0][0], (float) s->pad_oheight /
(float) (iheight - topBand - bottomBand), NB_TAPS, NB_PHASES, 1<<FILTER_BITS, 0);
return s;
fail:
av_free(s);
} | [
"ImgReSampleContext *FUNC_0(int owidth, int oheight,\nint iwidth, int iheight,\nint topBand, int bottomBand,\nint leftBand, int rightBand,\nint padtop, int padbottom,\nint padleft, int padright)\n{",
"ImgReSampleContext *s;",
"s = av_mallocz(sizeof(ImgReSampleContext));",
"if (!s)\ns->line_buf = av_mallocz(owidth * (LINE_BUF_HEIGHT + NB_TAPS));",
"if (!s->line_buf)\ngoto fail;",
"s->owidth = owidth;",
"s->oheight = oheight;",
"s->iwidth = iwidth;",
"s->iheight = iheight;",
"s->topBand = topBand;",
"s->bottomBand = bottomBand;",
"s->leftBand = leftBand;",
"s->rightBand = rightBand;",
"s->padtop = padtop;",
"s->padbottom = padbottom;",
"s->padleft = padleft;",
"s->padright = padright;",
"s->pad_owidth = owidth - (padleft + padright);",
"s->pad_oheight = oheight - (padtop + padbottom);",
"s->h_incr = ((iwidth - leftBand - rightBand) * POS_FRAC) / s->pad_owidth;",
"s->v_incr = ((iheight - topBand - bottomBand) * POS_FRAC) / s->pad_oheight;",
"av_build_filter(&s->h_filters[0][0], (float) s->pad_owidth /\n(float) (iwidth - leftBand - rightBand), NB_TAPS, NB_PHASES, 1<<FILTER_BITS, 0);",
"av_build_filter(&s->v_filters[0][0], (float) s->pad_oheight /\n(float) (iheight - topBand - bottomBand), NB_TAPS, NB_PHASES, 1<<FILTER_BITS, 0);",
"return s;",
"fail:\nav_free(s);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13
],
[
15
],
[
19
],
[
21,
26
],
[
28,
30
],
[
34
],
[
36
],
[
38
],
[
40
],
[
44
],
[
46
],
[
48
],
[
50
],
[
54
],
[
56
],
[
58
],
[
60
],
[
64
],
[
66
],
[
70
],
[
72
],
[
76,
78
],
[
80,
82
],
[
86
],
[
88,
90
],
[
93
]
] |
25,984 | static abi_long do_socketcall(int num, abi_ulong vptr)
{
static const unsigned ac[] = { /* number of arguments per call */
[SOCKOP_socket] = 3, /* domain, type, protocol */
[SOCKOP_bind] = 3, /* sockfd, addr, addrlen */
[SOCKOP_connect] = 3, /* sockfd, addr, addrlen */
[SOCKOP_listen] = 2, /* sockfd, backlog */
[SOCKOP_accept] = 3, /* sockfd, addr, addrlen */
[SOCKOP_accept4] = 4, /* sockfd, addr, addrlen, flags */
[SOCKOP_getsockname] = 3, /* sockfd, addr, addrlen */
[SOCKOP_getpeername] = 3, /* sockfd, addr, addrlen */
[SOCKOP_socketpair] = 4, /* domain, type, protocol, tab */
[SOCKOP_send] = 4, /* sockfd, msg, len, flags */
[SOCKOP_recv] = 4, /* sockfd, msg, len, flags */
[SOCKOP_sendto] = 6, /* sockfd, msg, len, flags, addr, addrlen */
[SOCKOP_recvfrom] = 6, /* sockfd, msg, len, flags, addr, addrlen */
[SOCKOP_shutdown] = 2, /* sockfd, how */
[SOCKOP_sendmsg] = 3, /* sockfd, msg, flags */
[SOCKOP_recvmsg] = 3, /* sockfd, msg, flags */
[SOCKOP_sendmmsg] = 4, /* sockfd, msgvec, vlen, flags */
[SOCKOP_recvmmsg] = 4, /* sockfd, msgvec, vlen, flags */
[SOCKOP_setsockopt] = 5, /* sockfd, level, optname, optval, optlen */
[SOCKOP_getsockopt] = 5, /* sockfd, level, optname, optval, optlen */
};
abi_long a[6]; /* max 6 args */
/* first, collect the arguments in a[] according to ac[] */
if (num >= 0 && num < ARRAY_SIZE(ac)) {
unsigned i;
assert(ARRAY_SIZE(a) >= ac[num]); /* ensure we have space for args */
for (i = 0; i < ac[num]; ++i) {
if (get_user_ual(a[i], vptr + i * sizeof(abi_long)) != 0) {
return -TARGET_EFAULT;
}
}
}
/* now when we have the args, actually handle the call */
switch (num) {
case SOCKOP_socket: /* domain, type, protocol */
return do_socket(a[0], a[1], a[2]);
case SOCKOP_bind: /* sockfd, addr, addrlen */
return do_bind(a[0], a[1], a[2]);
case SOCKOP_connect: /* sockfd, addr, addrlen */
return do_connect(a[0], a[1], a[2]);
case SOCKOP_listen: /* sockfd, backlog */
return get_errno(listen(a[0], a[1]));
case SOCKOP_accept: /* sockfd, addr, addrlen */
return do_accept4(a[0], a[1], a[2], 0);
case SOCKOP_accept4: /* sockfd, addr, addrlen, flags */
return do_accept4(a[0], a[1], a[2], a[3]);
case SOCKOP_getsockname: /* sockfd, addr, addrlen */
return do_getsockname(a[0], a[1], a[2]);
case SOCKOP_getpeername: /* sockfd, addr, addrlen */
return do_getpeername(a[0], a[1], a[2]);
case SOCKOP_socketpair: /* domain, type, protocol, tab */
return do_socketpair(a[0], a[1], a[2], a[3]);
case SOCKOP_send: /* sockfd, msg, len, flags */
return do_sendto(a[0], a[1], a[2], a[3], 0, 0);
case SOCKOP_recv: /* sockfd, msg, len, flags */
return do_recvfrom(a[0], a[1], a[2], a[3], 0, 0);
case SOCKOP_sendto: /* sockfd, msg, len, flags, addr, addrlen */
return do_sendto(a[0], a[1], a[2], a[3], a[4], a[5]);
case SOCKOP_recvfrom: /* sockfd, msg, len, flags, addr, addrlen */
return do_recvfrom(a[0], a[1], a[2], a[3], a[4], a[5]);
case SOCKOP_shutdown: /* sockfd, how */
return get_errno(shutdown(a[0], a[1]));
case SOCKOP_sendmsg: /* sockfd, msg, flags */
return do_sendrecvmsg(a[0], a[1], a[2], 1);
case SOCKOP_recvmsg: /* sockfd, msg, flags */
return do_sendrecvmsg(a[0], a[1], a[2], 0);
case SOCKOP_sendmmsg: /* sockfd, msgvec, vlen, flags */
return do_sendrecvmmsg(a[0], a[1], a[2], a[3], 1);
case SOCKOP_recvmmsg: /* sockfd, msgvec, vlen, flags */
return do_sendrecvmmsg(a[0], a[1], a[2], a[3], 0);
case SOCKOP_setsockopt: /* sockfd, level, optname, optval, optlen */
return do_setsockopt(a[0], a[1], a[2], a[3], a[4]);
case SOCKOP_getsockopt: /* sockfd, level, optname, optval, optlen */
return do_getsockopt(a[0], a[1], a[2], a[3], a[4]);
default:
gemu_log("Unsupported socketcall: %d\n", num);
return -TARGET_ENOSYS;
}
}
| true | qemu | ff71a4545c0d9b452e77a91ab1c46f79a10a9eca | static abi_long do_socketcall(int num, abi_ulong vptr)
{
static const unsigned ac[] = {
[SOCKOP_socket] = 3,
[SOCKOP_bind] = 3,
[SOCKOP_connect] = 3,
[SOCKOP_listen] = 2,
[SOCKOP_accept] = 3,
[SOCKOP_accept4] = 4,
[SOCKOP_getsockname] = 3,
[SOCKOP_getpeername] = 3,
[SOCKOP_socketpair] = 4,
[SOCKOP_send] = 4,
[SOCKOP_recv] = 4,
[SOCKOP_sendto] = 6,
[SOCKOP_recvfrom] = 6,
[SOCKOP_shutdown] = 2,
[SOCKOP_sendmsg] = 3,
[SOCKOP_recvmsg] = 3,
[SOCKOP_sendmmsg] = 4,
[SOCKOP_recvmmsg] = 4,
[SOCKOP_setsockopt] = 5,
[SOCKOP_getsockopt] = 5,
};
abi_long a[6];
if (num >= 0 && num < ARRAY_SIZE(ac)) {
unsigned i;
assert(ARRAY_SIZE(a) >= ac[num]);
for (i = 0; i < ac[num]; ++i) {
if (get_user_ual(a[i], vptr + i * sizeof(abi_long)) != 0) {
return -TARGET_EFAULT;
}
}
}
switch (num) {
case SOCKOP_socket:
return do_socket(a[0], a[1], a[2]);
case SOCKOP_bind:
return do_bind(a[0], a[1], a[2]);
case SOCKOP_connect:
return do_connect(a[0], a[1], a[2]);
case SOCKOP_listen:
return get_errno(listen(a[0], a[1]));
case SOCKOP_accept:
return do_accept4(a[0], a[1], a[2], 0);
case SOCKOP_accept4:
return do_accept4(a[0], a[1], a[2], a[3]);
case SOCKOP_getsockname:
return do_getsockname(a[0], a[1], a[2]);
case SOCKOP_getpeername:
return do_getpeername(a[0], a[1], a[2]);
case SOCKOP_socketpair:
return do_socketpair(a[0], a[1], a[2], a[3]);
case SOCKOP_send:
return do_sendto(a[0], a[1], a[2], a[3], 0, 0);
case SOCKOP_recv:
return do_recvfrom(a[0], a[1], a[2], a[3], 0, 0);
case SOCKOP_sendto:
return do_sendto(a[0], a[1], a[2], a[3], a[4], a[5]);
case SOCKOP_recvfrom:
return do_recvfrom(a[0], a[1], a[2], a[3], a[4], a[5]);
case SOCKOP_shutdown:
return get_errno(shutdown(a[0], a[1]));
case SOCKOP_sendmsg:
return do_sendrecvmsg(a[0], a[1], a[2], 1);
case SOCKOP_recvmsg:
return do_sendrecvmsg(a[0], a[1], a[2], 0);
case SOCKOP_sendmmsg:
return do_sendrecvmmsg(a[0], a[1], a[2], a[3], 1);
case SOCKOP_recvmmsg:
return do_sendrecvmmsg(a[0], a[1], a[2], a[3], 0);
case SOCKOP_setsockopt:
return do_setsockopt(a[0], a[1], a[2], a[3], a[4]);
case SOCKOP_getsockopt:
return do_getsockopt(a[0], a[1], a[2], a[3], a[4]);
default:
gemu_log("Unsupported socketcall: %d\n", num);
return -TARGET_ENOSYS;
}
}
| {
"code": [
" if (num >= 0 && num < ARRAY_SIZE(ac)) {",
" unsigned i;",
" for (i = 0; i < ac[num]; ++i) {",
" if (get_user_ual(a[i], vptr + i * sizeof(abi_long)) != 0) {",
" return -TARGET_EFAULT;",
" return do_accept4(a[0], a[1], a[2], a[3]);",
" return do_sendrecvmmsg(a[0], a[1], a[2], a[3], 1);",
" return do_setsockopt(a[0], a[1], a[2], a[3], a[4]);",
" return do_getsockopt(a[0], a[1], a[2], a[3], a[4]);",
" return -TARGET_ENOSYS;"
],
"line_no": [
55,
57,
61,
63,
65,
101,
145,
153,
157,
163
]
} | static abi_long FUNC_0(int num, abi_ulong vptr)
{
static const unsigned VAR_0[] = {
[SOCKOP_socket] = 3,
[SOCKOP_bind] = 3,
[SOCKOP_connect] = 3,
[SOCKOP_listen] = 2,
[SOCKOP_accept] = 3,
[SOCKOP_accept4] = 4,
[SOCKOP_getsockname] = 3,
[SOCKOP_getpeername] = 3,
[SOCKOP_socketpair] = 4,
[SOCKOP_send] = 4,
[SOCKOP_recv] = 4,
[SOCKOP_sendto] = 6,
[SOCKOP_recvfrom] = 6,
[SOCKOP_shutdown] = 2,
[SOCKOP_sendmsg] = 3,
[SOCKOP_recvmsg] = 3,
[SOCKOP_sendmmsg] = 4,
[SOCKOP_recvmmsg] = 4,
[SOCKOP_setsockopt] = 5,
[SOCKOP_getsockopt] = 5,
};
abi_long a[6];
if (num >= 0 && num < ARRAY_SIZE(VAR_0)) {
unsigned VAR_1;
assert(ARRAY_SIZE(a) >= VAR_0[num]);
for (VAR_1 = 0; VAR_1 < VAR_0[num]; ++VAR_1) {
if (get_user_ual(a[VAR_1], vptr + VAR_1 * sizeof(abi_long)) != 0) {
return -TARGET_EFAULT;
}
}
}
switch (num) {
case SOCKOP_socket:
return do_socket(a[0], a[1], a[2]);
case SOCKOP_bind:
return do_bind(a[0], a[1], a[2]);
case SOCKOP_connect:
return do_connect(a[0], a[1], a[2]);
case SOCKOP_listen:
return get_errno(listen(a[0], a[1]));
case SOCKOP_accept:
return do_accept4(a[0], a[1], a[2], 0);
case SOCKOP_accept4:
return do_accept4(a[0], a[1], a[2], a[3]);
case SOCKOP_getsockname:
return do_getsockname(a[0], a[1], a[2]);
case SOCKOP_getpeername:
return do_getpeername(a[0], a[1], a[2]);
case SOCKOP_socketpair:
return do_socketpair(a[0], a[1], a[2], a[3]);
case SOCKOP_send:
return do_sendto(a[0], a[1], a[2], a[3], 0, 0);
case SOCKOP_recv:
return do_recvfrom(a[0], a[1], a[2], a[3], 0, 0);
case SOCKOP_sendto:
return do_sendto(a[0], a[1], a[2], a[3], a[4], a[5]);
case SOCKOP_recvfrom:
return do_recvfrom(a[0], a[1], a[2], a[3], a[4], a[5]);
case SOCKOP_shutdown:
return get_errno(shutdown(a[0], a[1]));
case SOCKOP_sendmsg:
return do_sendrecvmsg(a[0], a[1], a[2], 1);
case SOCKOP_recvmsg:
return do_sendrecvmsg(a[0], a[1], a[2], 0);
case SOCKOP_sendmmsg:
return do_sendrecvmmsg(a[0], a[1], a[2], a[3], 1);
case SOCKOP_recvmmsg:
return do_sendrecvmmsg(a[0], a[1], a[2], a[3], 0);
case SOCKOP_setsockopt:
return do_setsockopt(a[0], a[1], a[2], a[3], a[4]);
case SOCKOP_getsockopt:
return do_getsockopt(a[0], a[1], a[2], a[3], a[4]);
default:
gemu_log("Unsupported socketcall: %d\n", num);
return -TARGET_ENOSYS;
}
}
| [
"static abi_long FUNC_0(int num, abi_ulong vptr)\n{",
"static const unsigned VAR_0[] = {",
"[SOCKOP_socket] = 3,\n[SOCKOP_bind] = 3,\n[SOCKOP_connect] = 3,\n[SOCKOP_listen] = 2,\n[SOCKOP_accept] = 3,\n[SOCKOP_accept4] = 4,\n[SOCKOP_getsockname] = 3,\n[SOCKOP_getpeername] = 3,\n[SOCKOP_socketpair] = 4,\n[SOCKOP_send] = 4,\n[SOCKOP_recv] = 4,\n[SOCKOP_sendto] = 6,\n[SOCKOP_recvfrom] = 6,\n[SOCKOP_shutdown] = 2,\n[SOCKOP_sendmsg] = 3,\n[SOCKOP_recvmsg] = 3,\n[SOCKOP_sendmmsg] = 4,\n[SOCKOP_recvmmsg] = 4,\n[SOCKOP_setsockopt] = 5,\n[SOCKOP_getsockopt] = 5,\n};",
"abi_long a[6];",
"if (num >= 0 && num < ARRAY_SIZE(VAR_0)) {",
"unsigned VAR_1;",
"assert(ARRAY_SIZE(a) >= VAR_0[num]);",
"for (VAR_1 = 0; VAR_1 < VAR_0[num]; ++VAR_1) {",
"if (get_user_ual(a[VAR_1], vptr + VAR_1 * sizeof(abi_long)) != 0) {",
"return -TARGET_EFAULT;",
"}",
"}",
"}",
"switch (num) {",
"case SOCKOP_socket:\nreturn do_socket(a[0], a[1], a[2]);",
"case SOCKOP_bind:\nreturn do_bind(a[0], a[1], a[2]);",
"case SOCKOP_connect:\nreturn do_connect(a[0], a[1], a[2]);",
"case SOCKOP_listen:\nreturn get_errno(listen(a[0], a[1]));",
"case SOCKOP_accept:\nreturn do_accept4(a[0], a[1], a[2], 0);",
"case SOCKOP_accept4:\nreturn do_accept4(a[0], a[1], a[2], a[3]);",
"case SOCKOP_getsockname:\nreturn do_getsockname(a[0], a[1], a[2]);",
"case SOCKOP_getpeername:\nreturn do_getpeername(a[0], a[1], a[2]);",
"case SOCKOP_socketpair:\nreturn do_socketpair(a[0], a[1], a[2], a[3]);",
"case SOCKOP_send:\nreturn do_sendto(a[0], a[1], a[2], a[3], 0, 0);",
"case SOCKOP_recv:\nreturn do_recvfrom(a[0], a[1], a[2], a[3], 0, 0);",
"case SOCKOP_sendto:\nreturn do_sendto(a[0], a[1], a[2], a[3], a[4], a[5]);",
"case SOCKOP_recvfrom:\nreturn do_recvfrom(a[0], a[1], a[2], a[3], a[4], a[5]);",
"case SOCKOP_shutdown:\nreturn get_errno(shutdown(a[0], a[1]));",
"case SOCKOP_sendmsg:\nreturn do_sendrecvmsg(a[0], a[1], a[2], 1);",
"case SOCKOP_recvmsg:\nreturn do_sendrecvmsg(a[0], a[1], a[2], 0);",
"case SOCKOP_sendmmsg:\nreturn do_sendrecvmmsg(a[0], a[1], a[2], a[3], 1);",
"case SOCKOP_recvmmsg:\nreturn do_sendrecvmmsg(a[0], a[1], a[2], a[3], 0);",
"case SOCKOP_setsockopt:\nreturn do_setsockopt(a[0], a[1], a[2], a[3], a[4]);",
"case SOCKOP_getsockopt:\nreturn do_getsockopt(a[0], a[1], a[2], a[3], a[4]);",
"default:\ngemu_log(\"Unsupported socketcall: %d\\n\", num);",
"return -TARGET_ENOSYS;",
"}",
"}"
] | [
0,
0,
0,
0,
1,
1,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
1,
0,
1,
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
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
77
],
[
79,
81
],
[
83,
85
],
[
87,
89
],
[
91,
93
],
[
95,
97
],
[
99,
101
],
[
103,
105
],
[
107,
109
],
[
111,
113
],
[
115,
117
],
[
119,
121
],
[
123,
125
],
[
127,
129
],
[
131,
133
],
[
135,
137
],
[
139,
141
],
[
143,
145
],
[
147,
149
],
[
151,
153
],
[
155,
157
],
[
159,
161
],
[
163
],
[
165
],
[
167
]
] |
25,985 | static MemTxResult address_space_write_continue(AddressSpace *as, hwaddr addr,
MemTxAttrs attrs,
const uint8_t *buf,
int len, hwaddr addr1,
hwaddr l, MemoryRegion *mr)
{
uint8_t *ptr;
uint64_t val;
MemTxResult result = MEMTX_OK;
bool release_lock = false;
for (;;) {
if (!memory_access_is_direct(mr, true)) {
release_lock |= prepare_mmio_access(mr);
l = memory_access_size(mr, l, addr1);
/* XXX: could force current_cpu to NULL to avoid
potential bugs */
switch (l) {
case 8:
/* 64 bit write access */
val = ldq_p(buf);
result |= memory_region_dispatch_write(mr, addr1, val, 8,
attrs);
break;
case 4:
/* 32 bit write access */
val = ldl_p(buf);
result |= memory_region_dispatch_write(mr, addr1, val, 4,
attrs);
break;
case 2:
/* 16 bit write access */
val = lduw_p(buf);
result |= memory_region_dispatch_write(mr, addr1, val, 2,
attrs);
break;
case 1:
/* 8 bit write access */
val = ldub_p(buf);
result |= memory_region_dispatch_write(mr, addr1, val, 1,
attrs);
break;
default:
abort();
}
} else {
/* RAM case */
ptr = qemu_map_ram_ptr(mr->ram_block, addr1);
memcpy(ptr, buf, l);
invalidate_and_set_dirty(mr, addr1, l);
}
if (release_lock) {
qemu_mutex_unlock_iothread();
release_lock = false;
}
len -= l;
buf += l;
addr += l;
if (!len) {
break;
}
l = len;
mr = address_space_translate(as, addr, &addr1, &l, true);
}
return result;
}
| true | qemu | 6da67de6803e93cbb7e93ac3497865832f8c00ea | static MemTxResult address_space_write_continue(AddressSpace *as, hwaddr addr,
MemTxAttrs attrs,
const uint8_t *buf,
int len, hwaddr addr1,
hwaddr l, MemoryRegion *mr)
{
uint8_t *ptr;
uint64_t val;
MemTxResult result = MEMTX_OK;
bool release_lock = false;
for (;;) {
if (!memory_access_is_direct(mr, true)) {
release_lock |= prepare_mmio_access(mr);
l = memory_access_size(mr, l, addr1);
switch (l) {
case 8:
val = ldq_p(buf);
result |= memory_region_dispatch_write(mr, addr1, val, 8,
attrs);
break;
case 4:
val = ldl_p(buf);
result |= memory_region_dispatch_write(mr, addr1, val, 4,
attrs);
break;
case 2:
val = lduw_p(buf);
result |= memory_region_dispatch_write(mr, addr1, val, 2,
attrs);
break;
case 1:
val = ldub_p(buf);
result |= memory_region_dispatch_write(mr, addr1, val, 1,
attrs);
break;
default:
abort();
}
} else {
ptr = qemu_map_ram_ptr(mr->ram_block, addr1);
memcpy(ptr, buf, l);
invalidate_and_set_dirty(mr, addr1, l);
}
if (release_lock) {
qemu_mutex_unlock_iothread();
release_lock = false;
}
len -= l;
buf += l;
addr += l;
if (!len) {
break;
}
l = len;
mr = address_space_translate(as, addr, &addr1, &l, true);
}
return result;
}
| {
"code": [
" val = ldl_p(buf);"
],
"line_no": [
53
]
} | static MemTxResult FUNC_0(AddressSpace *as, hwaddr addr,
MemTxAttrs attrs,
const uint8_t *buf,
int len, hwaddr addr1,
hwaddr l, MemoryRegion *mr)
{
uint8_t *ptr;
uint64_t val;
MemTxResult result = MEMTX_OK;
bool release_lock = false;
for (;;) {
if (!memory_access_is_direct(mr, true)) {
release_lock |= prepare_mmio_access(mr);
l = memory_access_size(mr, l, addr1);
switch (l) {
case 8:
val = ldq_p(buf);
result |= memory_region_dispatch_write(mr, addr1, val, 8,
attrs);
break;
case 4:
val = ldl_p(buf);
result |= memory_region_dispatch_write(mr, addr1, val, 4,
attrs);
break;
case 2:
val = lduw_p(buf);
result |= memory_region_dispatch_write(mr, addr1, val, 2,
attrs);
break;
case 1:
val = ldub_p(buf);
result |= memory_region_dispatch_write(mr, addr1, val, 1,
attrs);
break;
default:
abort();
}
} else {
ptr = qemu_map_ram_ptr(mr->ram_block, addr1);
memcpy(ptr, buf, l);
invalidate_and_set_dirty(mr, addr1, l);
}
if (release_lock) {
qemu_mutex_unlock_iothread();
release_lock = false;
}
len -= l;
buf += l;
addr += l;
if (!len) {
break;
}
l = len;
mr = address_space_translate(as, addr, &addr1, &l, true);
}
return result;
}
| [
"static MemTxResult FUNC_0(AddressSpace *as, hwaddr addr,\nMemTxAttrs attrs,\nconst uint8_t *buf,\nint len, hwaddr addr1,\nhwaddr l, MemoryRegion *mr)\n{",
"uint8_t *ptr;",
"uint64_t val;",
"MemTxResult result = MEMTX_OK;",
"bool release_lock = false;",
"for (;;) {",
"if (!memory_access_is_direct(mr, true)) {",
"release_lock |= prepare_mmio_access(mr);",
"l = memory_access_size(mr, l, addr1);",
"switch (l) {",
"case 8:\nval = ldq_p(buf);",
"result |= memory_region_dispatch_write(mr, addr1, val, 8,\nattrs);",
"break;",
"case 4:\nval = ldl_p(buf);",
"result |= memory_region_dispatch_write(mr, addr1, val, 4,\nattrs);",
"break;",
"case 2:\nval = lduw_p(buf);",
"result |= memory_region_dispatch_write(mr, addr1, val, 2,\nattrs);",
"break;",
"case 1:\nval = ldub_p(buf);",
"result |= memory_region_dispatch_write(mr, addr1, val, 1,\nattrs);",
"break;",
"default:\nabort();",
"}",
"} else {",
"ptr = qemu_map_ram_ptr(mr->ram_block, addr1);",
"memcpy(ptr, buf, l);",
"invalidate_and_set_dirty(mr, addr1, l);",
"}",
"if (release_lock) {",
"qemu_mutex_unlock_iothread();",
"release_lock = false;",
"}",
"len -= l;",
"buf += l;",
"addr += l;",
"if (!len) {",
"break;",
"}",
"l = len;",
"mr = address_space_translate(as, addr, &addr1, &l, true);",
"}",
"return result;",
"}"
] | [
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
] | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
35
],
[
37,
41
],
[
43,
45
],
[
47
],
[
49,
53
],
[
55,
57
],
[
59
],
[
61,
65
],
[
67,
69
],
[
71
],
[
73,
77
],
[
79,
81
],
[
83
],
[
85,
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127
],
[
131
],
[
133
],
[
135
],
[
139
],
[
141
]
] |
25,987 | void visit_type_int64(Visitor *v, int64_t *obj, const char *name, Error **errp)
{
if (!error_is_set(errp)) {
if (v->type_int64) {
v->type_int64(v, obj, name, errp);
} else {
v->type_int(v, obj, name, errp);
}
}
}
| true | qemu | 297a3646c2947ee64a6d42ca264039732c6218e0 | void visit_type_int64(Visitor *v, int64_t *obj, const char *name, Error **errp)
{
if (!error_is_set(errp)) {
if (v->type_int64) {
v->type_int64(v, obj, name, errp);
} else {
v->type_int(v, obj, name, errp);
}
}
}
| {
"code": [
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" } else {",
" if (!error_is_set(errp)) {",
" } else {",
" if (!error_is_set(errp)) {",
" } else {",
" if (!error_is_set(errp)) {",
" } else {",
" if (!error_is_set(errp)) {",
" } else {",
" if (!error_is_set(errp)) {",
" } else {",
" if (!error_is_set(errp)) {",
" } else {",
" if (!error_is_set(errp)) {",
" if (v->type_int64) {",
" v->type_int64(v, obj, name, errp);",
" } else {",
" v->type_int(v, obj, name, errp);",
" if (!error_is_set(errp)) {",
" } else {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {"
],
"line_no": [
5,
5,
5,
5,
5,
5,
11,
5,
11,
5,
11,
5,
11,
5,
11,
5,
11,
5,
11,
5,
7,
9,
11,
13,
5,
11,
5,
5,
5,
5,
5,
5,
5
]
} | void FUNC_0(Visitor *VAR_0, int64_t *VAR_1, const char *VAR_2, Error **VAR_3)
{
if (!error_is_set(VAR_3)) {
if (VAR_0->type_int64) {
VAR_0->type_int64(VAR_0, VAR_1, VAR_2, VAR_3);
} else {
VAR_0->type_int(VAR_0, VAR_1, VAR_2, VAR_3);
}
}
}
| [
"void FUNC_0(Visitor *VAR_0, int64_t *VAR_1, const char *VAR_2, Error **VAR_3)\n{",
"if (!error_is_set(VAR_3)) {",
"if (VAR_0->type_int64) {",
"VAR_0->type_int64(VAR_0, VAR_1, VAR_2, VAR_3);",
"} else {",
"VAR_0->type_int(VAR_0, VAR_1, VAR_2, VAR_3);",
"}",
"}",
"}"
] | [
0,
1,
1,
1,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
25,988 | static inline void idct4col_add(uint8_t *dest, int line_size, const DCTELEM *col)
{
int c0, c1, c2, c3, a0, a1, a2, a3;
const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
a0 = col[8*0];
a1 = col[8*1];
a2 = col[8*2];
a3 = col[8*3];
c0 = (a0 + a2)*C3 + (1 << (C_SHIFT - 1));
c2 = (a0 - a2)*C3 + (1 << (C_SHIFT - 1));
c1 = a1 * C1 + a3 * C2;
c3 = a1 * C2 - a3 * C1;
dest[0] = cm[dest[0] + ((c0 + c1) >> C_SHIFT)];
dest += line_size;
dest[0] = cm[dest[0] + ((c2 + c3) >> C_SHIFT)];
dest += line_size;
dest[0] = cm[dest[0] + ((c2 - c3) >> C_SHIFT)];
dest += line_size;
dest[0] = cm[dest[0] + ((c0 - c1) >> C_SHIFT)];
}
| true | FFmpeg | c23acbaed40101c677dfcfbbfe0d2c230a8e8f44 | static inline void idct4col_add(uint8_t *dest, int line_size, const DCTELEM *col)
{
int c0, c1, c2, c3, a0, a1, a2, a3;
const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
a0 = col[8*0];
a1 = col[8*1];
a2 = col[8*2];
a3 = col[8*3];
c0 = (a0 + a2)*C3 + (1 << (C_SHIFT - 1));
c2 = (a0 - a2)*C3 + (1 << (C_SHIFT - 1));
c1 = a1 * C1 + a3 * C2;
c3 = a1 * C2 - a3 * C1;
dest[0] = cm[dest[0] + ((c0 + c1) >> C_SHIFT)];
dest += line_size;
dest[0] = cm[dest[0] + ((c2 + c3) >> C_SHIFT)];
dest += line_size;
dest[0] = cm[dest[0] + ((c2 - c3) >> C_SHIFT)];
dest += line_size;
dest[0] = cm[dest[0] + ((c0 - c1) >> C_SHIFT)];
}
| {
"code": [
" const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" dest[0] = cm[dest[0] + ((c0 + c1) >> C_SHIFT)];",
" dest[0] = cm[dest[0] + ((c2 + c3) >> C_SHIFT)];",
" dest[0] = cm[dest[0] + ((c2 - c3) >> C_SHIFT)];",
" dest[0] = cm[dest[0] + ((c0 - c1) >> C_SHIFT)];",
" const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;"
],
"line_no": [
7,
7,
7,
27,
31,
35,
39,
7,
7,
7
]
} | static inline void FUNC_0(uint8_t *VAR_0, int VAR_1, const DCTELEM *VAR_2)
{
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;
const uint8_t *VAR_11 = ff_cropTbl + MAX_NEG_CROP;
VAR_7 = VAR_2[8*0];
VAR_8 = VAR_2[8*1];
VAR_9 = VAR_2[8*2];
VAR_10 = VAR_2[8*3];
VAR_3 = (VAR_7 + VAR_9)*C3 + (1 << (C_SHIFT - 1));
VAR_5 = (VAR_7 - VAR_9)*C3 + (1 << (C_SHIFT - 1));
VAR_4 = VAR_8 * C1 + VAR_10 * C2;
VAR_6 = VAR_8 * C2 - VAR_10 * C1;
VAR_0[0] = VAR_11[VAR_0[0] + ((VAR_3 + VAR_4) >> C_SHIFT)];
VAR_0 += VAR_1;
VAR_0[0] = VAR_11[VAR_0[0] + ((VAR_5 + VAR_6) >> C_SHIFT)];
VAR_0 += VAR_1;
VAR_0[0] = VAR_11[VAR_0[0] + ((VAR_5 - VAR_6) >> C_SHIFT)];
VAR_0 += VAR_1;
VAR_0[0] = VAR_11[VAR_0[0] + ((VAR_3 - VAR_4) >> C_SHIFT)];
}
| [
"static inline void FUNC_0(uint8_t *VAR_0, int VAR_1, const DCTELEM *VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;",
"const uint8_t *VAR_11 = ff_cropTbl + MAX_NEG_CROP;",
"VAR_7 = VAR_2[8*0];",
"VAR_8 = VAR_2[8*1];",
"VAR_9 = VAR_2[8*2];",
"VAR_10 = VAR_2[8*3];",
"VAR_3 = (VAR_7 + VAR_9)*C3 + (1 << (C_SHIFT - 1));",
"VAR_5 = (VAR_7 - VAR_9)*C3 + (1 << (C_SHIFT - 1));",
"VAR_4 = VAR_8 * C1 + VAR_10 * C2;",
"VAR_6 = VAR_8 * C2 - VAR_10 * C1;",
"VAR_0[0] = VAR_11[VAR_0[0] + ((VAR_3 + VAR_4) >> C_SHIFT)];",
"VAR_0 += VAR_1;",
"VAR_0[0] = VAR_11[VAR_0[0] + ((VAR_5 + VAR_6) >> C_SHIFT)];",
"VAR_0 += VAR_1;",
"VAR_0[0] = VAR_11[VAR_0[0] + ((VAR_5 - VAR_6) >> C_SHIFT)];",
"VAR_0 += VAR_1;",
"VAR_0[0] = VAR_11[VAR_0[0] + ((VAR_3 - VAR_4) >> C_SHIFT)];",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
1,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
]
] |
25,989 | void bdrv_detach_aio_context(BlockDriverState *bs)
{
BdrvAioNotifier *baf;
BdrvChild *child;
if (!bs->drv) {
return;
}
QLIST_FOREACH(baf, &bs->aio_notifiers, list) {
baf->detach_aio_context(baf->opaque);
}
if (bs->drv->bdrv_detach_aio_context) {
bs->drv->bdrv_detach_aio_context(bs);
}
QLIST_FOREACH(child, &bs->children, next) {
bdrv_detach_aio_context(child->bs);
}
bs->aio_context = NULL;
}
| true | qemu | e8a095dadb70e2ea6d5169d261920db3747bfa45 | void bdrv_detach_aio_context(BlockDriverState *bs)
{
BdrvAioNotifier *baf;
BdrvChild *child;
if (!bs->drv) {
return;
}
QLIST_FOREACH(baf, &bs->aio_notifiers, list) {
baf->detach_aio_context(baf->opaque);
}
if (bs->drv->bdrv_detach_aio_context) {
bs->drv->bdrv_detach_aio_context(bs);
}
QLIST_FOREACH(child, &bs->children, next) {
bdrv_detach_aio_context(child->bs);
}
bs->aio_context = NULL;
}
| {
"code": [
" BdrvAioNotifier *baf;",
" QLIST_FOREACH(baf, &bs->aio_notifiers, list) {",
" baf->detach_aio_context(baf->opaque);"
],
"line_no": [
5,
19,
21
]
} | void FUNC_0(BlockDriverState *VAR_0)
{
BdrvAioNotifier *baf;
BdrvChild *child;
if (!VAR_0->drv) {
return;
}
QLIST_FOREACH(baf, &VAR_0->aio_notifiers, list) {
baf->detach_aio_context(baf->opaque);
}
if (VAR_0->drv->FUNC_0) {
VAR_0->drv->FUNC_0(VAR_0);
}
QLIST_FOREACH(child, &VAR_0->children, next) {
FUNC_0(child->VAR_0);
}
VAR_0->aio_context = NULL;
}
| [
"void FUNC_0(BlockDriverState *VAR_0)\n{",
"BdrvAioNotifier *baf;",
"BdrvChild *child;",
"if (!VAR_0->drv) {",
"return;",
"}",
"QLIST_FOREACH(baf, &VAR_0->aio_notifiers, list) {",
"baf->detach_aio_context(baf->opaque);",
"}",
"if (VAR_0->drv->FUNC_0) {",
"VAR_0->drv->FUNC_0(VAR_0);",
"}",
"QLIST_FOREACH(child, &VAR_0->children, next) {",
"FUNC_0(child->VAR_0);",
"}",
"VAR_0->aio_context = NULL;",
"}"
] | [
0,
1,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
]
] |
25,990 | void cpu_ppc_reset (void *opaque)
{
CPUPPCState *env;
target_ulong msr;
env = opaque;
msr = (target_ulong)0;
if (0) {
/* XXX: find a suitable condition to enable the hypervisor mode */
msr |= (target_ulong)MSR_HVB;
}
msr |= (target_ulong)0 << MSR_AP; /* TO BE CHECKED */
msr |= (target_ulong)0 << MSR_SA; /* TO BE CHECKED */
msr |= (target_ulong)1 << MSR_EP;
#if defined (DO_SINGLE_STEP) && 0
/* Single step trace mode */
msr |= (target_ulong)1 << MSR_SE;
msr |= (target_ulong)1 << MSR_BE;
#endif
#if defined(CONFIG_USER_ONLY)
msr |= (target_ulong)1 << MSR_FP; /* Allow floating point usage */
msr |= (target_ulong)1 << MSR_PR;
#else
env->nip = env->hreset_vector | env->excp_prefix;
if (env->mmu_model != POWERPC_MMU_REAL)
ppc_tlb_invalidate_all(env);
#endif
env->msr = msr;
hreg_compute_hflags(env);
env->reserve = (target_ulong)-1ULL;
/* Be sure no exception or interrupt is pending */
env->pending_interrupts = 0;
env->exception_index = POWERPC_EXCP_NONE;
env->error_code = 0;
/* Flush all TLBs */
tlb_flush(env, 1);
}
| false | qemu | fe463b7dbc16cc66f3b9a8b7be197fb340378fa3 | void cpu_ppc_reset (void *opaque)
{
CPUPPCState *env;
target_ulong msr;
env = opaque;
msr = (target_ulong)0;
if (0) {
msr |= (target_ulong)MSR_HVB;
}
msr |= (target_ulong)0 << MSR_AP;
msr |= (target_ulong)0 << MSR_SA;
msr |= (target_ulong)1 << MSR_EP;
#if defined (DO_SINGLE_STEP) && 0
msr |= (target_ulong)1 << MSR_SE;
msr |= (target_ulong)1 << MSR_BE;
#endif
#if defined(CONFIG_USER_ONLY)
msr |= (target_ulong)1 << MSR_FP;
msr |= (target_ulong)1 << MSR_PR;
#else
env->nip = env->hreset_vector | env->excp_prefix;
if (env->mmu_model != POWERPC_MMU_REAL)
ppc_tlb_invalidate_all(env);
#endif
env->msr = msr;
hreg_compute_hflags(env);
env->reserve = (target_ulong)-1ULL;
env->pending_interrupts = 0;
env->exception_index = POWERPC_EXCP_NONE;
env->error_code = 0;
tlb_flush(env, 1);
}
| {
"code": [],
"line_no": []
} | void FUNC_0 (void *VAR_0)
{
CPUPPCState *env;
target_ulong msr;
env = VAR_0;
msr = (target_ulong)0;
if (0) {
msr |= (target_ulong)MSR_HVB;
}
msr |= (target_ulong)0 << MSR_AP;
msr |= (target_ulong)0 << MSR_SA;
msr |= (target_ulong)1 << MSR_EP;
#if defined (DO_SINGLE_STEP) && 0
msr |= (target_ulong)1 << MSR_SE;
msr |= (target_ulong)1 << MSR_BE;
#endif
#if defined(CONFIG_USER_ONLY)
msr |= (target_ulong)1 << MSR_FP;
msr |= (target_ulong)1 << MSR_PR;
#else
env->nip = env->hreset_vector | env->excp_prefix;
if (env->mmu_model != POWERPC_MMU_REAL)
ppc_tlb_invalidate_all(env);
#endif
env->msr = msr;
hreg_compute_hflags(env);
env->reserve = (target_ulong)-1ULL;
env->pending_interrupts = 0;
env->exception_index = POWERPC_EXCP_NONE;
env->error_code = 0;
tlb_flush(env, 1);
}
| [
"void FUNC_0 (void *VAR_0)\n{",
"CPUPPCState *env;",
"target_ulong msr;",
"env = VAR_0;",
"msr = (target_ulong)0;",
"if (0) {",
"msr |= (target_ulong)MSR_HVB;",
"}",
"msr |= (target_ulong)0 << MSR_AP;",
"msr |= (target_ulong)0 << MSR_SA;",
"msr |= (target_ulong)1 << MSR_EP;",
"#if defined (DO_SINGLE_STEP) && 0\nmsr |= (target_ulong)1 << MSR_SE;",
"msr |= (target_ulong)1 << MSR_BE;",
"#endif\n#if defined(CONFIG_USER_ONLY)\nmsr |= (target_ulong)1 << MSR_FP;",
"msr |= (target_ulong)1 << MSR_PR;",
"#else\nenv->nip = env->hreset_vector | env->excp_prefix;",
"if (env->mmu_model != POWERPC_MMU_REAL)\nppc_tlb_invalidate_all(env);",
"#endif\nenv->msr = msr;",
"hreg_compute_hflags(env);",
"env->reserve = (target_ulong)-1ULL;",
"env->pending_interrupts = 0;",
"env->exception_index = POWERPC_EXCP_NONE;",
"env->error_code = 0;",
"tlb_flush(env, 1);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29,
33
],
[
35
],
[
37,
39,
41
],
[
43
],
[
45,
47
],
[
49,
51
],
[
53,
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
]
] |
25,991 | static void omap_sti_write(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
struct omap_sti_s *s = (struct omap_sti_s *) opaque;
if (size != 4) {
return omap_badwidth_write32(opaque, addr, value);
}
switch (addr) {
case 0x00: /* STI_REVISION */
case 0x14: /* STI_SYSSTATUS / STI_RX_STATUS / XTI_SYSSTATUS */
OMAP_RO_REG(addr);
return;
case 0x10: /* STI_SYSCONFIG */
if (value & (1 << 1)) /* SOFTRESET */
omap_sti_reset(s);
s->sysconfig = value & 0xfe;
break;
case 0x18: /* STI_IRQSTATUS */
s->irqst &= ~value;
omap_sti_interrupt_update(s);
break;
case 0x1c: /* STI_IRQSETEN / STI_IRQCLREN */
s->irqen = value & 0xffff;
omap_sti_interrupt_update(s);
break;
case 0x2c: /* STI_CLK_CTRL / XTI_SCLKCRTL */
s->clkcontrol = value & 0xff;
break;
case 0x30: /* STI_SERIAL_CFG / XTI_SCONFIG */
s->serial_config = value & 0xff;
break;
case 0x24: /* STI_ER / STI_DR / XTI_TRACESELECT */
case 0x28: /* STI_RX_DR / XTI_RXDATA */
/* TODO */
return;
default:
OMAP_BAD_REG(addr);
return;
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void omap_sti_write(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
struct omap_sti_s *s = (struct omap_sti_s *) opaque;
if (size != 4) {
return omap_badwidth_write32(opaque, addr, value);
}
switch (addr) {
case 0x00:
case 0x14:
OMAP_RO_REG(addr);
return;
case 0x10:
if (value & (1 << 1))
omap_sti_reset(s);
s->sysconfig = value & 0xfe;
break;
case 0x18:
s->irqst &= ~value;
omap_sti_interrupt_update(s);
break;
case 0x1c:
s->irqen = value & 0xffff;
omap_sti_interrupt_update(s);
break;
case 0x2c:
s->clkcontrol = value & 0xff;
break;
case 0x30:
s->serial_config = value & 0xff;
break;
case 0x24:
case 0x28:
return;
default:
OMAP_BAD_REG(addr);
return;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
struct omap_sti_s *VAR_4 = (struct omap_sti_s *) VAR_0;
if (VAR_3 != 4) {
return omap_badwidth_write32(VAR_0, VAR_1, VAR_2);
}
switch (VAR_1) {
case 0x00:
case 0x14:
OMAP_RO_REG(VAR_1);
return;
case 0x10:
if (VAR_2 & (1 << 1))
omap_sti_reset(VAR_4);
VAR_4->sysconfig = VAR_2 & 0xfe;
break;
case 0x18:
VAR_4->irqst &= ~VAR_2;
omap_sti_interrupt_update(VAR_4);
break;
case 0x1c:
VAR_4->irqen = VAR_2 & 0xffff;
omap_sti_interrupt_update(VAR_4);
break;
case 0x2c:
VAR_4->clkcontrol = VAR_2 & 0xff;
break;
case 0x30:
VAR_4->serial_config = VAR_2 & 0xff;
break;
case 0x24:
case 0x28:
return;
default:
OMAP_BAD_REG(VAR_1);
return;
}
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"struct omap_sti_s *VAR_4 = (struct omap_sti_s *) VAR_0;",
"if (VAR_3 != 4) {",
"return omap_badwidth_write32(VAR_0, VAR_1, VAR_2);",
"}",
"switch (VAR_1) {",
"case 0x00:\ncase 0x14:\nOMAP_RO_REG(VAR_1);",
"return;",
"case 0x10:\nif (VAR_2 & (1 << 1))\nomap_sti_reset(VAR_4);",
"VAR_4->sysconfig = VAR_2 & 0xfe;",
"break;",
"case 0x18:\nVAR_4->irqst &= ~VAR_2;",
"omap_sti_interrupt_update(VAR_4);",
"break;",
"case 0x1c:\nVAR_4->irqen = VAR_2 & 0xffff;",
"omap_sti_interrupt_update(VAR_4);",
"break;",
"case 0x2c:\nVAR_4->clkcontrol = VAR_2 & 0xff;",
"break;",
"case 0x30:\nVAR_4->serial_config = VAR_2 & 0xff;",
"break;",
"case 0x24:\ncase 0x28:\nreturn;",
"default:\nOMAP_BAD_REG(VAR_1);",
"return;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21,
23,
25
],
[
27
],
[
31,
33,
35
],
[
37
],
[
39
],
[
43,
45
],
[
47
],
[
49
],
[
53,
55
],
[
57
],
[
59
],
[
63,
65
],
[
67
],
[
71,
73
],
[
75
],
[
79,
81,
85
],
[
89,
91
],
[
93
],
[
95
],
[
97
]
] |
25,992 | static void gdb_chr_event(void *opaque, int event)
{
switch (event) {
case CHR_EVENT_RESET:
vm_stop(EXCP_INTERRUPT);
gdb_syscall_state = opaque;
gdb_has_xml = 0;
break;
default:
break;
}
}
| false | qemu | 880a7578381d1c7ed4d41c7599ae3cc06567a824 | static void gdb_chr_event(void *opaque, int event)
{
switch (event) {
case CHR_EVENT_RESET:
vm_stop(EXCP_INTERRUPT);
gdb_syscall_state = opaque;
gdb_has_xml = 0;
break;
default:
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, int VAR_1)
{
switch (VAR_1) {
case CHR_EVENT_RESET:
vm_stop(EXCP_INTERRUPT);
gdb_syscall_state = VAR_0;
gdb_has_xml = 0;
break;
default:
break;
}
}
| [
"static void FUNC_0(void *VAR_0, int VAR_1)\n{",
"switch (VAR_1) {",
"case CHR_EVENT_RESET:\nvm_stop(EXCP_INTERRUPT);",
"gdb_syscall_state = VAR_0;",
"gdb_has_xml = 0;",
"break;",
"default:\nbreak;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11
],
[
13
],
[
15
],
[
17,
19
],
[
21
],
[
23
]
] |
25,993 | static void release_keys(void *opaque)
{
int keycode;
while (nb_pending_keycodes > 0) {
nb_pending_keycodes--;
keycode = keycodes[nb_pending_keycodes];
if (keycode & 0x80)
kbd_put_keycode(0xe0);
kbd_put_keycode(keycode | 0x80);
}
}
| false | qemu | e4c8f004c55d9da3eae3e14df740238bf805b5d6 | static void release_keys(void *opaque)
{
int keycode;
while (nb_pending_keycodes > 0) {
nb_pending_keycodes--;
keycode = keycodes[nb_pending_keycodes];
if (keycode & 0x80)
kbd_put_keycode(0xe0);
kbd_put_keycode(keycode | 0x80);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
int VAR_1;
while (nb_pending_keycodes > 0) {
nb_pending_keycodes--;
VAR_1 = keycodes[nb_pending_keycodes];
if (VAR_1 & 0x80)
kbd_put_keycode(0xe0);
kbd_put_keycode(VAR_1 | 0x80);
}
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"int VAR_1;",
"while (nb_pending_keycodes > 0) {",
"nb_pending_keycodes--;",
"VAR_1 = keycodes[nb_pending_keycodes];",
"if (VAR_1 & 0x80)\nkbd_put_keycode(0xe0);",
"kbd_put_keycode(VAR_1 | 0x80);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
]
] |
25,994 | static int virtio_scsi_parse_req(VirtIOSCSIReq *req,
unsigned req_size, unsigned resp_size)
{
VirtIODevice *vdev = (VirtIODevice *) req->dev;
size_t in_size, out_size;
if (iov_to_buf(req->elem.out_sg, req->elem.out_num, 0,
&req->req, req_size) < req_size) {
return -EINVAL;
}
if (qemu_iovec_concat_iov(&req->resp_iov,
req->elem.in_sg, req->elem.in_num, 0,
resp_size) < resp_size) {
return -EINVAL;
}
req->resp_size = resp_size;
/* Old BIOSes left some padding by mistake after the req_size/resp_size.
* As a workaround, always consider the first buffer as the virtio-scsi
* request/response, making the payload start at the second element
* of the iovec.
*
* The actual length of the response header, stored in req->resp_size,
* does not change.
*
* TODO: always disable this workaround for virtio 1.0 devices.
*/
if ((vdev->guest_features & (1 << VIRTIO_F_ANY_LAYOUT)) == 0) {
req_size = req->elem.out_sg[0].iov_len;
resp_size = req->elem.in_sg[0].iov_len;
}
out_size = qemu_sgl_concat(req, req->elem.out_sg,
&req->elem.out_addr[0], req->elem.out_num,
req_size);
in_size = qemu_sgl_concat(req, req->elem.in_sg,
&req->elem.in_addr[0], req->elem.in_num,
resp_size);
if (out_size && in_size) {
return -ENOTSUP;
}
if (out_size) {
req->mode = SCSI_XFER_TO_DEV;
} else if (in_size) {
req->mode = SCSI_XFER_FROM_DEV;
}
return 0;
}
| false | qemu | ef546f1275f6563e8934dd5e338d29d9f9909ca6 | static int virtio_scsi_parse_req(VirtIOSCSIReq *req,
unsigned req_size, unsigned resp_size)
{
VirtIODevice *vdev = (VirtIODevice *) req->dev;
size_t in_size, out_size;
if (iov_to_buf(req->elem.out_sg, req->elem.out_num, 0,
&req->req, req_size) < req_size) {
return -EINVAL;
}
if (qemu_iovec_concat_iov(&req->resp_iov,
req->elem.in_sg, req->elem.in_num, 0,
resp_size) < resp_size) {
return -EINVAL;
}
req->resp_size = resp_size;
if ((vdev->guest_features & (1 << VIRTIO_F_ANY_LAYOUT)) == 0) {
req_size = req->elem.out_sg[0].iov_len;
resp_size = req->elem.in_sg[0].iov_len;
}
out_size = qemu_sgl_concat(req, req->elem.out_sg,
&req->elem.out_addr[0], req->elem.out_num,
req_size);
in_size = qemu_sgl_concat(req, req->elem.in_sg,
&req->elem.in_addr[0], req->elem.in_num,
resp_size);
if (out_size && in_size) {
return -ENOTSUP;
}
if (out_size) {
req->mode = SCSI_XFER_TO_DEV;
} else if (in_size) {
req->mode = SCSI_XFER_FROM_DEV;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(VirtIOSCSIReq *VAR_0,
unsigned VAR_1, unsigned VAR_2)
{
VirtIODevice *vdev = (VirtIODevice *) VAR_0->dev;
size_t in_size, out_size;
if (iov_to_buf(VAR_0->elem.out_sg, VAR_0->elem.out_num, 0,
&VAR_0->VAR_0, VAR_1) < VAR_1) {
return -EINVAL;
}
if (qemu_iovec_concat_iov(&VAR_0->resp_iov,
VAR_0->elem.in_sg, VAR_0->elem.in_num, 0,
VAR_2) < VAR_2) {
return -EINVAL;
}
VAR_0->VAR_2 = VAR_2;
if ((vdev->guest_features & (1 << VIRTIO_F_ANY_LAYOUT)) == 0) {
VAR_1 = VAR_0->elem.out_sg[0].iov_len;
VAR_2 = VAR_0->elem.in_sg[0].iov_len;
}
out_size = qemu_sgl_concat(VAR_0, VAR_0->elem.out_sg,
&VAR_0->elem.out_addr[0], VAR_0->elem.out_num,
VAR_1);
in_size = qemu_sgl_concat(VAR_0, VAR_0->elem.in_sg,
&VAR_0->elem.in_addr[0], VAR_0->elem.in_num,
VAR_2);
if (out_size && in_size) {
return -ENOTSUP;
}
if (out_size) {
VAR_0->mode = SCSI_XFER_TO_DEV;
} else if (in_size) {
VAR_0->mode = SCSI_XFER_FROM_DEV;
}
return 0;
}
| [
"static int FUNC_0(VirtIOSCSIReq *VAR_0,\nunsigned VAR_1, unsigned VAR_2)\n{",
"VirtIODevice *vdev = (VirtIODevice *) VAR_0->dev;",
"size_t in_size, out_size;",
"if (iov_to_buf(VAR_0->elem.out_sg, VAR_0->elem.out_num, 0,\n&VAR_0->VAR_0, VAR_1) < VAR_1) {",
"return -EINVAL;",
"}",
"if (qemu_iovec_concat_iov(&VAR_0->resp_iov,\nVAR_0->elem.in_sg, VAR_0->elem.in_num, 0,\nVAR_2) < VAR_2) {",
"return -EINVAL;",
"}",
"VAR_0->VAR_2 = VAR_2;",
"if ((vdev->guest_features & (1 << VIRTIO_F_ANY_LAYOUT)) == 0) {",
"VAR_1 = VAR_0->elem.out_sg[0].iov_len;",
"VAR_2 = VAR_0->elem.in_sg[0].iov_len;",
"}",
"out_size = qemu_sgl_concat(VAR_0, VAR_0->elem.out_sg,\n&VAR_0->elem.out_addr[0], VAR_0->elem.out_num,\nVAR_1);",
"in_size = qemu_sgl_concat(VAR_0, VAR_0->elem.in_sg,\n&VAR_0->elem.in_addr[0], VAR_0->elem.in_num,\nVAR_2);",
"if (out_size && in_size) {",
"return -ENOTSUP;",
"}",
"if (out_size) {",
"VAR_0->mode = SCSI_XFER_TO_DEV;",
"} else if (in_size) {",
"VAR_0->mode = SCSI_XFER_FROM_DEV;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13,
15
],
[
17
],
[
19
],
[
23,
25,
27
],
[
29
],
[
31
],
[
35
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69,
71,
73
],
[
75,
77,
79
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
]
] |
25,995 | void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms,
MemoryRegion *mr)
{
PCDIMMDevice *dimm = PC_DIMM(dev);
numa_unset_mem_node_id(dimm->addr, memory_region_size(mr), dimm->node);
memory_region_del_subregion(&hpms->mr, mr);
vmstate_unregister_ram(mr, dev);
}
| false | qemu | 8df1426e44176512be1b6456e90d100d1af907e1 | void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms,
MemoryRegion *mr)
{
PCDIMMDevice *dimm = PC_DIMM(dev);
numa_unset_mem_node_id(dimm->addr, memory_region_size(mr), dimm->node);
memory_region_del_subregion(&hpms->mr, mr);
vmstate_unregister_ram(mr, dev);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(DeviceState *VAR_0, MemoryHotplugState *VAR_1,
MemoryRegion *VAR_2)
{
PCDIMMDevice *dimm = PC_DIMM(VAR_0);
numa_unset_mem_node_id(dimm->addr, memory_region_size(VAR_2), dimm->node);
memory_region_del_subregion(&VAR_1->VAR_2, VAR_2);
vmstate_unregister_ram(VAR_2, VAR_0);
}
| [
"void FUNC_0(DeviceState *VAR_0, MemoryHotplugState *VAR_1,\nMemoryRegion *VAR_2)\n{",
"PCDIMMDevice *dimm = PC_DIMM(VAR_0);",
"numa_unset_mem_node_id(dimm->addr, memory_region_size(VAR_2), dimm->node);",
"memory_region_del_subregion(&VAR_1->VAR_2, VAR_2);",
"vmstate_unregister_ram(VAR_2, VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
25,996 | static void kvm_handle_internal_error(CPUState *env, struct kvm_run *run)
{
if (kvm_check_extension(kvm_state, KVM_CAP_INTERNAL_ERROR_DATA)) {
int i;
fprintf(stderr, "KVM internal error. Suberror: %d\n",
run->internal.suberror);
for (i = 0; i < run->internal.ndata; ++i) {
fprintf(stderr, "extra data[%d]: %"PRIx64"\n",
i, (uint64_t)run->internal.data[i]);
}
}
cpu_dump_state(env, stderr, fprintf, 0);
if (run->internal.suberror == KVM_INTERNAL_ERROR_EMULATION) {
fprintf(stderr, "emulation failure\n");
if (!kvm_arch_stop_on_emulation_error(env)) {
return;
}
}
/* FIXME: Should trigger a qmp message to let management know
* something went wrong.
*/
vm_stop(0);
}
| false | qemu | 73aaec4a39b3cf11082303a6cf6bcde8796c09c6 | static void kvm_handle_internal_error(CPUState *env, struct kvm_run *run)
{
if (kvm_check_extension(kvm_state, KVM_CAP_INTERNAL_ERROR_DATA)) {
int i;
fprintf(stderr, "KVM internal error. Suberror: %d\n",
run->internal.suberror);
for (i = 0; i < run->internal.ndata; ++i) {
fprintf(stderr, "extra data[%d]: %"PRIx64"\n",
i, (uint64_t)run->internal.data[i]);
}
}
cpu_dump_state(env, stderr, fprintf, 0);
if (run->internal.suberror == KVM_INTERNAL_ERROR_EMULATION) {
fprintf(stderr, "emulation failure\n");
if (!kvm_arch_stop_on_emulation_error(env)) {
return;
}
}
vm_stop(0);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(CPUState *VAR_0, struct kvm_run *VAR_1)
{
if (kvm_check_extension(kvm_state, KVM_CAP_INTERNAL_ERROR_DATA)) {
int VAR_2;
fprintf(stderr, "KVM internal error. Suberror: %d\n",
VAR_1->internal.suberror);
for (VAR_2 = 0; VAR_2 < VAR_1->internal.ndata; ++VAR_2) {
fprintf(stderr, "extra data[%d]: %"PRIx64"\n",
VAR_2, (uint64_t)VAR_1->internal.data[VAR_2]);
}
}
cpu_dump_state(VAR_0, stderr, fprintf, 0);
if (VAR_1->internal.suberror == KVM_INTERNAL_ERROR_EMULATION) {
fprintf(stderr, "emulation failure\n");
if (!kvm_arch_stop_on_emulation_error(VAR_0)) {
return;
}
}
vm_stop(0);
}
| [
"static void FUNC_0(CPUState *VAR_0, struct kvm_run *VAR_1)\n{",
"if (kvm_check_extension(kvm_state, KVM_CAP_INTERNAL_ERROR_DATA)) {",
"int VAR_2;",
"fprintf(stderr, \"KVM internal error. Suberror: %d\\n\",\nVAR_1->internal.suberror);",
"for (VAR_2 = 0; VAR_2 < VAR_1->internal.ndata; ++VAR_2) {",
"fprintf(stderr, \"extra data[%d]: %\"PRIx64\"\\n\",\nVAR_2, (uint64_t)VAR_1->internal.data[VAR_2]);",
"}",
"}",
"cpu_dump_state(VAR_0, stderr, fprintf, 0);",
"if (VAR_1->internal.suberror == KVM_INTERNAL_ERROR_EMULATION) {",
"fprintf(stderr, \"emulation failure\\n\");",
"if (!kvm_arch_stop_on_emulation_error(VAR_0)) {",
"return;",
"}",
"}",
"vm_stop(0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
9
],
[
13,
15
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
49
],
[
51
]
] |
25,998 | void ff_slice_buffer_init(slice_buffer *buf, int line_count,
int max_allocated_lines, int line_width,
IDWTELEM *base_buffer)
{
int i;
buf->base_buffer = base_buffer;
buf->line_count = line_count;
buf->line_width = line_width;
buf->data_count = max_allocated_lines;
buf->line = av_mallocz(sizeof(IDWTELEM *) * line_count);
buf->data_stack = av_malloc(sizeof(IDWTELEM *) * max_allocated_lines);
for (i = 0; i < max_allocated_lines; i++)
buf->data_stack[i] = av_malloc(sizeof(IDWTELEM) * line_width);
buf->data_stack_top = max_allocated_lines - 1;
}
| false | FFmpeg | c89e428ed8c2c31396af2d18cab4342b7d82958f | void ff_slice_buffer_init(slice_buffer *buf, int line_count,
int max_allocated_lines, int line_width,
IDWTELEM *base_buffer)
{
int i;
buf->base_buffer = base_buffer;
buf->line_count = line_count;
buf->line_width = line_width;
buf->data_count = max_allocated_lines;
buf->line = av_mallocz(sizeof(IDWTELEM *) * line_count);
buf->data_stack = av_malloc(sizeof(IDWTELEM *) * max_allocated_lines);
for (i = 0; i < max_allocated_lines; i++)
buf->data_stack[i] = av_malloc(sizeof(IDWTELEM) * line_width);
buf->data_stack_top = max_allocated_lines - 1;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(slice_buffer *VAR_0, int VAR_1,
int VAR_2, int VAR_3,
IDWTELEM *VAR_4)
{
int VAR_5;
VAR_0->VAR_4 = VAR_4;
VAR_0->VAR_1 = VAR_1;
VAR_0->VAR_3 = VAR_3;
VAR_0->data_count = VAR_2;
VAR_0->line = av_mallocz(sizeof(IDWTELEM *) * VAR_1);
VAR_0->data_stack = av_malloc(sizeof(IDWTELEM *) * VAR_2);
for (VAR_5 = 0; VAR_5 < VAR_2; VAR_5++)
VAR_0->data_stack[VAR_5] = av_malloc(sizeof(IDWTELEM) * VAR_3);
VAR_0->data_stack_top = VAR_2 - 1;
}
| [
"void FUNC_0(slice_buffer *VAR_0, int VAR_1,\nint VAR_2, int VAR_3,\nIDWTELEM *VAR_4)\n{",
"int VAR_5;",
"VAR_0->VAR_4 = VAR_4;",
"VAR_0->VAR_1 = VAR_1;",
"VAR_0->VAR_3 = VAR_3;",
"VAR_0->data_count = VAR_2;",
"VAR_0->line = av_mallocz(sizeof(IDWTELEM *) * VAR_1);",
"VAR_0->data_stack = av_malloc(sizeof(IDWTELEM *) * VAR_2);",
"for (VAR_5 = 0; VAR_5 < VAR_2; VAR_5++)",
"VAR_0->data_stack[VAR_5] = av_malloc(sizeof(IDWTELEM) * VAR_3);",
"VAR_0->data_stack_top = VAR_2 - 1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
33
],
[
35
]
] |
25,999 | static void xenfb_mouse_event(DeviceState *dev, QemuConsole *src,
InputEvent *evt)
{
struct XenInput *xenfb = (struct XenInput *)dev;
InputBtnEvent *btn;
InputMoveEvent *move;
QemuConsole *con;
DisplaySurface *surface;
int scale;
switch (evt->type) {
case INPUT_EVENT_KIND_BTN:
btn = evt->u.btn.data;
switch (btn->button) {
case INPUT_BUTTON_LEFT:
xenfb_send_key(xenfb, btn->down, BTN_LEFT);
break;
case INPUT_BUTTON_RIGHT:
xenfb_send_key(xenfb, btn->down, BTN_LEFT + 1);
break;
case INPUT_BUTTON_MIDDLE:
xenfb_send_key(xenfb, btn->down, BTN_LEFT + 2);
break;
case INPUT_BUTTON_WHEEL_UP:
if (btn->down) {
xenfb->wheel--;
}
break;
case INPUT_BUTTON_WHEEL_DOWN:
if (btn->down) {
xenfb->wheel++;
}
break;
default:
break;
}
break;
case INPUT_EVENT_KIND_ABS:
move = evt->u.abs.data;
con = qemu_console_lookup_by_index(0);
if (!con) {
xen_pv_printf(&xenfb->c.xendev, 0, "No QEMU console available");
return;
}
surface = qemu_console_surface(con);
switch (move->axis) {
case INPUT_AXIS_X:
scale = surface_width(surface) - 1;
break;
case INPUT_AXIS_Y:
scale = surface_height(surface) - 1;
break;
default:
scale = 0x8000;
break;
}
xenfb->axis[move->axis] = move->value * scale / 0x7fff;
break;
case INPUT_EVENT_KIND_REL:
move = evt->u.rel.data;
xenfb->axis[move->axis] += move->value;
break;
default:
break;
}
}
| false | qemu | 34975e536f3531ad852d724a46280b882ec1bc9d | static void xenfb_mouse_event(DeviceState *dev, QemuConsole *src,
InputEvent *evt)
{
struct XenInput *xenfb = (struct XenInput *)dev;
InputBtnEvent *btn;
InputMoveEvent *move;
QemuConsole *con;
DisplaySurface *surface;
int scale;
switch (evt->type) {
case INPUT_EVENT_KIND_BTN:
btn = evt->u.btn.data;
switch (btn->button) {
case INPUT_BUTTON_LEFT:
xenfb_send_key(xenfb, btn->down, BTN_LEFT);
break;
case INPUT_BUTTON_RIGHT:
xenfb_send_key(xenfb, btn->down, BTN_LEFT + 1);
break;
case INPUT_BUTTON_MIDDLE:
xenfb_send_key(xenfb, btn->down, BTN_LEFT + 2);
break;
case INPUT_BUTTON_WHEEL_UP:
if (btn->down) {
xenfb->wheel--;
}
break;
case INPUT_BUTTON_WHEEL_DOWN:
if (btn->down) {
xenfb->wheel++;
}
break;
default:
break;
}
break;
case INPUT_EVENT_KIND_ABS:
move = evt->u.abs.data;
con = qemu_console_lookup_by_index(0);
if (!con) {
xen_pv_printf(&xenfb->c.xendev, 0, "No QEMU console available");
return;
}
surface = qemu_console_surface(con);
switch (move->axis) {
case INPUT_AXIS_X:
scale = surface_width(surface) - 1;
break;
case INPUT_AXIS_Y:
scale = surface_height(surface) - 1;
break;
default:
scale = 0x8000;
break;
}
xenfb->axis[move->axis] = move->value * scale / 0x7fff;
break;
case INPUT_EVENT_KIND_REL:
move = evt->u.rel.data;
xenfb->axis[move->axis] += move->value;
break;
default:
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0, QemuConsole *VAR_1,
InputEvent *VAR_2)
{
struct XenInput *VAR_3 = (struct XenInput *)VAR_0;
InputBtnEvent *btn;
InputMoveEvent *move;
QemuConsole *con;
DisplaySurface *surface;
int VAR_4;
switch (VAR_2->type) {
case INPUT_EVENT_KIND_BTN:
btn = VAR_2->u.btn.data;
switch (btn->button) {
case INPUT_BUTTON_LEFT:
xenfb_send_key(VAR_3, btn->down, BTN_LEFT);
break;
case INPUT_BUTTON_RIGHT:
xenfb_send_key(VAR_3, btn->down, BTN_LEFT + 1);
break;
case INPUT_BUTTON_MIDDLE:
xenfb_send_key(VAR_3, btn->down, BTN_LEFT + 2);
break;
case INPUT_BUTTON_WHEEL_UP:
if (btn->down) {
VAR_3->wheel--;
}
break;
case INPUT_BUTTON_WHEEL_DOWN:
if (btn->down) {
VAR_3->wheel++;
}
break;
default:
break;
}
break;
case INPUT_EVENT_KIND_ABS:
move = VAR_2->u.abs.data;
con = qemu_console_lookup_by_index(0);
if (!con) {
xen_pv_printf(&VAR_3->c.xendev, 0, "No QEMU console available");
return;
}
surface = qemu_console_surface(con);
switch (move->axis) {
case INPUT_AXIS_X:
VAR_4 = surface_width(surface) - 1;
break;
case INPUT_AXIS_Y:
VAR_4 = surface_height(surface) - 1;
break;
default:
VAR_4 = 0x8000;
break;
}
VAR_3->axis[move->axis] = move->value * VAR_4 / 0x7fff;
break;
case INPUT_EVENT_KIND_REL:
move = VAR_2->u.rel.data;
VAR_3->axis[move->axis] += move->value;
break;
default:
break;
}
}
| [
"static void FUNC_0(DeviceState *VAR_0, QemuConsole *VAR_1,\nInputEvent *VAR_2)\n{",
"struct XenInput *VAR_3 = (struct XenInput *)VAR_0;",
"InputBtnEvent *btn;",
"InputMoveEvent *move;",
"QemuConsole *con;",
"DisplaySurface *surface;",
"int VAR_4;",
"switch (VAR_2->type) {",
"case INPUT_EVENT_KIND_BTN:\nbtn = VAR_2->u.btn.data;",
"switch (btn->button) {",
"case INPUT_BUTTON_LEFT:\nxenfb_send_key(VAR_3, btn->down, BTN_LEFT);",
"break;",
"case INPUT_BUTTON_RIGHT:\nxenfb_send_key(VAR_3, btn->down, BTN_LEFT + 1);",
"break;",
"case INPUT_BUTTON_MIDDLE:\nxenfb_send_key(VAR_3, btn->down, BTN_LEFT + 2);",
"break;",
"case INPUT_BUTTON_WHEEL_UP:\nif (btn->down) {",
"VAR_3->wheel--;",
"}",
"break;",
"case INPUT_BUTTON_WHEEL_DOWN:\nif (btn->down) {",
"VAR_3->wheel++;",
"}",
"break;",
"default:\nbreak;",
"}",
"break;",
"case INPUT_EVENT_KIND_ABS:\nmove = VAR_2->u.abs.data;",
"con = qemu_console_lookup_by_index(0);",
"if (!con) {",
"xen_pv_printf(&VAR_3->c.xendev, 0, \"No QEMU console available\");",
"return;",
"}",
"surface = qemu_console_surface(con);",
"switch (move->axis) {",
"case INPUT_AXIS_X:\nVAR_4 = surface_width(surface) - 1;",
"break;",
"case INPUT_AXIS_Y:\nVAR_4 = surface_height(surface) - 1;",
"break;",
"default:\nVAR_4 = 0x8000;",
"break;",
"}",
"VAR_3->axis[move->axis] = move->value * VAR_4 / 0x7fff;",
"break;",
"case INPUT_EVENT_KIND_REL:\nmove = VAR_2->u.rel.data;",
"VAR_3->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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23,
25
],
[
27
],
[
29,
31
],
[
33
],
[
35,
37
],
[
39
],
[
41,
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
77,
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95,
97
],
[
99
],
[
101,
103
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121,
123
],
[
125
],
[
127
],
[
131,
133
],
[
135
],
[
137
]
] |
26,000 | static CharDriverState *qemu_chr_open_socket_fd(int fd, bool do_nodelay,
bool is_listen, bool is_telnet,
bool is_waitconnect,
Error **errp)
{
CharDriverState *chr = NULL;
TCPCharDriver *s = NULL;
char host[NI_MAXHOST], serv[NI_MAXSERV];
const char *left = "", *right = "";
struct sockaddr_storage ss;
socklen_t ss_len = sizeof(ss);
memset(&ss, 0, ss_len);
if (getsockname(fd, (struct sockaddr *) &ss, &ss_len) != 0) {
error_setg_errno(errp, errno, "getsockname");
return NULL;
}
chr = g_malloc0(sizeof(CharDriverState));
s = g_malloc0(sizeof(TCPCharDriver));
s->connected = 0;
s->fd = -1;
s->listen_fd = -1;
s->read_msgfds = 0;
s->read_msgfds_num = 0;
s->write_msgfds = 0;
s->write_msgfds_num = 0;
chr->filename = g_malloc(256);
switch (ss.ss_family) {
#ifndef _WIN32
case AF_UNIX:
s->is_unix = 1;
snprintf(chr->filename, 256, "unix:%s%s",
((struct sockaddr_un *)(&ss))->sun_path,
is_listen ? ",server" : "");
break;
#endif
case AF_INET6:
left = "[";
right = "]";
/* fall through */
case AF_INET:
s->do_nodelay = do_nodelay;
getnameinfo((struct sockaddr *) &ss, ss_len, host, sizeof(host),
serv, sizeof(serv), NI_NUMERICHOST | NI_NUMERICSERV);
snprintf(chr->filename, 256, "%s:%s%s%s:%s%s",
is_telnet ? "telnet" : "tcp",
left, host, right, serv,
is_listen ? ",server" : "");
break;
}
chr->opaque = s;
chr->chr_write = tcp_chr_write;
chr->chr_sync_read = tcp_chr_sync_read;
chr->chr_close = tcp_chr_close;
chr->get_msgfds = tcp_get_msgfds;
chr->set_msgfds = tcp_set_msgfds;
chr->chr_add_client = tcp_chr_add_client;
chr->chr_add_watch = tcp_chr_add_watch;
chr->chr_update_read_handler = tcp_chr_update_read_handler;
/* be isn't opened until we get a connection */
chr->explicit_be_open = true;
if (is_listen) {
s->listen_fd = fd;
s->listen_chan = io_channel_from_socket(s->listen_fd);
s->listen_tag = g_io_add_watch(s->listen_chan, G_IO_IN, tcp_chr_accept, chr);
if (is_telnet) {
s->do_telnetopt = 1;
}
} else {
s->connected = 1;
s->fd = fd;
socket_set_nodelay(fd);
s->chan = io_channel_from_socket(s->fd);
tcp_chr_connect(chr);
}
if (is_listen && is_waitconnect) {
fprintf(stderr, "QEMU waiting for connection on: %s\n",
chr->filename);
tcp_chr_accept(s->listen_chan, G_IO_IN, chr);
qemu_set_nonblock(s->listen_fd);
}
return chr;
}
| false | qemu | db39fcf1f690b02d612e2bfc00980700887abe03 | static CharDriverState *qemu_chr_open_socket_fd(int fd, bool do_nodelay,
bool is_listen, bool is_telnet,
bool is_waitconnect,
Error **errp)
{
CharDriverState *chr = NULL;
TCPCharDriver *s = NULL;
char host[NI_MAXHOST], serv[NI_MAXSERV];
const char *left = "", *right = "";
struct sockaddr_storage ss;
socklen_t ss_len = sizeof(ss);
memset(&ss, 0, ss_len);
if (getsockname(fd, (struct sockaddr *) &ss, &ss_len) != 0) {
error_setg_errno(errp, errno, "getsockname");
return NULL;
}
chr = g_malloc0(sizeof(CharDriverState));
s = g_malloc0(sizeof(TCPCharDriver));
s->connected = 0;
s->fd = -1;
s->listen_fd = -1;
s->read_msgfds = 0;
s->read_msgfds_num = 0;
s->write_msgfds = 0;
s->write_msgfds_num = 0;
chr->filename = g_malloc(256);
switch (ss.ss_family) {
#ifndef _WIN32
case AF_UNIX:
s->is_unix = 1;
snprintf(chr->filename, 256, "unix:%s%s",
((struct sockaddr_un *)(&ss))->sun_path,
is_listen ? ",server" : "");
break;
#endif
case AF_INET6:
left = "[";
right = "]";
case AF_INET:
s->do_nodelay = do_nodelay;
getnameinfo((struct sockaddr *) &ss, ss_len, host, sizeof(host),
serv, sizeof(serv), NI_NUMERICHOST | NI_NUMERICSERV);
snprintf(chr->filename, 256, "%s:%s%s%s:%s%s",
is_telnet ? "telnet" : "tcp",
left, host, right, serv,
is_listen ? ",server" : "");
break;
}
chr->opaque = s;
chr->chr_write = tcp_chr_write;
chr->chr_sync_read = tcp_chr_sync_read;
chr->chr_close = tcp_chr_close;
chr->get_msgfds = tcp_get_msgfds;
chr->set_msgfds = tcp_set_msgfds;
chr->chr_add_client = tcp_chr_add_client;
chr->chr_add_watch = tcp_chr_add_watch;
chr->chr_update_read_handler = tcp_chr_update_read_handler;
chr->explicit_be_open = true;
if (is_listen) {
s->listen_fd = fd;
s->listen_chan = io_channel_from_socket(s->listen_fd);
s->listen_tag = g_io_add_watch(s->listen_chan, G_IO_IN, tcp_chr_accept, chr);
if (is_telnet) {
s->do_telnetopt = 1;
}
} else {
s->connected = 1;
s->fd = fd;
socket_set_nodelay(fd);
s->chan = io_channel_from_socket(s->fd);
tcp_chr_connect(chr);
}
if (is_listen && is_waitconnect) {
fprintf(stderr, "QEMU waiting for connection on: %s\n",
chr->filename);
tcp_chr_accept(s->listen_chan, G_IO_IN, chr);
qemu_set_nonblock(s->listen_fd);
}
return chr;
}
| {
"code": [],
"line_no": []
} | static CharDriverState *FUNC_0(int fd, bool do_nodelay,
bool is_listen, bool is_telnet,
bool is_waitconnect,
Error **errp)
{
CharDriverState *chr = NULL;
TCPCharDriver *s = NULL;
char VAR_0[NI_MAXHOST], serv[NI_MAXSERV];
const char *VAR_1 = "", *VAR_2 = "";
struct sockaddr_storage VAR_3;
socklen_t ss_len = sizeof(VAR_3);
memset(&VAR_3, 0, ss_len);
if (getsockname(fd, (struct sockaddr *) &VAR_3, &ss_len) != 0) {
error_setg_errno(errp, errno, "getsockname");
return NULL;
}
chr = g_malloc0(sizeof(CharDriverState));
s = g_malloc0(sizeof(TCPCharDriver));
s->connected = 0;
s->fd = -1;
s->listen_fd = -1;
s->read_msgfds = 0;
s->read_msgfds_num = 0;
s->write_msgfds = 0;
s->write_msgfds_num = 0;
chr->filename = g_malloc(256);
switch (VAR_3.ss_family) {
#ifndef _WIN32
case AF_UNIX:
s->is_unix = 1;
snprintf(chr->filename, 256, "unix:%s%s",
((struct sockaddr_un *)(&VAR_3))->sun_path,
is_listen ? ",server" : "");
break;
#endif
case AF_INET6:
VAR_1 = "[";
VAR_2 = "]";
case AF_INET:
s->do_nodelay = do_nodelay;
getnameinfo((struct sockaddr *) &VAR_3, ss_len, VAR_0, sizeof(VAR_0),
serv, sizeof(serv), NI_NUMERICHOST | NI_NUMERICSERV);
snprintf(chr->filename, 256, "%s:%s%s%s:%s%s",
is_telnet ? "telnet" : "tcp",
VAR_1, VAR_0, VAR_2, serv,
is_listen ? ",server" : "");
break;
}
chr->opaque = s;
chr->chr_write = tcp_chr_write;
chr->chr_sync_read = tcp_chr_sync_read;
chr->chr_close = tcp_chr_close;
chr->get_msgfds = tcp_get_msgfds;
chr->set_msgfds = tcp_set_msgfds;
chr->chr_add_client = tcp_chr_add_client;
chr->chr_add_watch = tcp_chr_add_watch;
chr->chr_update_read_handler = tcp_chr_update_read_handler;
chr->explicit_be_open = true;
if (is_listen) {
s->listen_fd = fd;
s->listen_chan = io_channel_from_socket(s->listen_fd);
s->listen_tag = g_io_add_watch(s->listen_chan, G_IO_IN, tcp_chr_accept, chr);
if (is_telnet) {
s->do_telnetopt = 1;
}
} else {
s->connected = 1;
s->fd = fd;
socket_set_nodelay(fd);
s->chan = io_channel_from_socket(s->fd);
tcp_chr_connect(chr);
}
if (is_listen && is_waitconnect) {
fprintf(stderr, "QEMU waiting for connection on: %s\n",
chr->filename);
tcp_chr_accept(s->listen_chan, G_IO_IN, chr);
qemu_set_nonblock(s->listen_fd);
}
return chr;
}
| [
"static CharDriverState *FUNC_0(int fd, bool do_nodelay,\nbool is_listen, bool is_telnet,\nbool is_waitconnect,\nError **errp)\n{",
"CharDriverState *chr = NULL;",
"TCPCharDriver *s = NULL;",
"char VAR_0[NI_MAXHOST], serv[NI_MAXSERV];",
"const char *VAR_1 = \"\", *VAR_2 = \"\";",
"struct sockaddr_storage VAR_3;",
"socklen_t ss_len = sizeof(VAR_3);",
"memset(&VAR_3, 0, ss_len);",
"if (getsockname(fd, (struct sockaddr *) &VAR_3, &ss_len) != 0) {",
"error_setg_errno(errp, errno, \"getsockname\");",
"return NULL;",
"}",
"chr = g_malloc0(sizeof(CharDriverState));",
"s = g_malloc0(sizeof(TCPCharDriver));",
"s->connected = 0;",
"s->fd = -1;",
"s->listen_fd = -1;",
"s->read_msgfds = 0;",
"s->read_msgfds_num = 0;",
"s->write_msgfds = 0;",
"s->write_msgfds_num = 0;",
"chr->filename = g_malloc(256);",
"switch (VAR_3.ss_family) {",
"#ifndef _WIN32\ncase AF_UNIX:\ns->is_unix = 1;",
"snprintf(chr->filename, 256, \"unix:%s%s\",\n((struct sockaddr_un *)(&VAR_3))->sun_path,\nis_listen ? \",server\" : \"\");",
"break;",
"#endif\ncase AF_INET6:\nVAR_1 = \"[\";",
"VAR_2 = \"]\";",
"case AF_INET:\ns->do_nodelay = do_nodelay;",
"getnameinfo((struct sockaddr *) &VAR_3, ss_len, VAR_0, sizeof(VAR_0),\nserv, sizeof(serv), NI_NUMERICHOST | NI_NUMERICSERV);",
"snprintf(chr->filename, 256, \"%s:%s%s%s:%s%s\",\nis_telnet ? \"telnet\" : \"tcp\",\nVAR_1, VAR_0, VAR_2, serv,\nis_listen ? \",server\" : \"\");",
"break;",
"}",
"chr->opaque = s;",
"chr->chr_write = tcp_chr_write;",
"chr->chr_sync_read = tcp_chr_sync_read;",
"chr->chr_close = tcp_chr_close;",
"chr->get_msgfds = tcp_get_msgfds;",
"chr->set_msgfds = tcp_set_msgfds;",
"chr->chr_add_client = tcp_chr_add_client;",
"chr->chr_add_watch = tcp_chr_add_watch;",
"chr->chr_update_read_handler = tcp_chr_update_read_handler;",
"chr->explicit_be_open = true;",
"if (is_listen) {",
"s->listen_fd = fd;",
"s->listen_chan = io_channel_from_socket(s->listen_fd);",
"s->listen_tag = g_io_add_watch(s->listen_chan, G_IO_IN, tcp_chr_accept, chr);",
"if (is_telnet) {",
"s->do_telnetopt = 1;",
"}",
"} else {",
"s->connected = 1;",
"s->fd = fd;",
"socket_set_nodelay(fd);",
"s->chan = io_channel_from_socket(s->fd);",
"tcp_chr_connect(chr);",
"}",
"if (is_listen && is_waitconnect) {",
"fprintf(stderr, \"QEMU waiting for connection on: %s\\n\",\nchr->filename);",
"tcp_chr_accept(s->listen_chan, G_IO_IN, chr);",
"qemu_set_nonblock(s->listen_fd);",
"}",
"return chr;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63,
65,
67
],
[
69,
71,
73
],
[
75
],
[
77,
79,
81
],
[
83
],
[
87,
89
],
[
91,
93
],
[
95,
97,
99,
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
163
],
[
165,
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
]
] |
26,001 | static void dhcp_decode(const struct bootp_t *bp, int *pmsg_type,
const struct in_addr **preq_addr)
{
const uint8_t *p, *p_end;
int len, tag;
*pmsg_type = 0;
*preq_addr = NULL;
p = bp->bp_vend;
p_end = p + DHCP_OPT_LEN;
if (memcmp(p, rfc1533_cookie, 4) != 0)
return;
p += 4;
while (p < p_end) {
tag = p[0];
if (tag == RFC1533_PAD) {
p++;
} else if (tag == RFC1533_END) {
break;
} else {
p++;
if (p >= p_end)
break;
len = *p++;
DPRINTF("dhcp: tag=%d len=%d\n", tag, len);
switch(tag) {
case RFC2132_MSG_TYPE:
if (len >= 1)
*pmsg_type = p[0];
break;
case RFC2132_REQ_ADDR:
if (len >= 4)
*preq_addr = (struct in_addr *)p;
break;
default:
break;
}
p += len;
}
}
if (*pmsg_type == DHCPREQUEST && !*preq_addr && bp->bp_ciaddr.s_addr) {
*preq_addr = &bp->bp_ciaddr;
}
}
| false | qemu | 8aaf42ed0f203da63860b0a3ab3ff2bdfe9b4cb0 | static void dhcp_decode(const struct bootp_t *bp, int *pmsg_type,
const struct in_addr **preq_addr)
{
const uint8_t *p, *p_end;
int len, tag;
*pmsg_type = 0;
*preq_addr = NULL;
p = bp->bp_vend;
p_end = p + DHCP_OPT_LEN;
if (memcmp(p, rfc1533_cookie, 4) != 0)
return;
p += 4;
while (p < p_end) {
tag = p[0];
if (tag == RFC1533_PAD) {
p++;
} else if (tag == RFC1533_END) {
break;
} else {
p++;
if (p >= p_end)
break;
len = *p++;
DPRINTF("dhcp: tag=%d len=%d\n", tag, len);
switch(tag) {
case RFC2132_MSG_TYPE:
if (len >= 1)
*pmsg_type = p[0];
break;
case RFC2132_REQ_ADDR:
if (len >= 4)
*preq_addr = (struct in_addr *)p;
break;
default:
break;
}
p += len;
}
}
if (*pmsg_type == DHCPREQUEST && !*preq_addr && bp->bp_ciaddr.s_addr) {
*preq_addr = &bp->bp_ciaddr;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const struct bootp_t *VAR_0, int *VAR_1,
const struct in_addr **VAR_2)
{
const uint8_t *VAR_3, *p_end;
int VAR_4, VAR_5;
*VAR_1 = 0;
*VAR_2 = NULL;
VAR_3 = VAR_0->bp_vend;
p_end = VAR_3 + DHCP_OPT_LEN;
if (memcmp(VAR_3, rfc1533_cookie, 4) != 0)
return;
VAR_3 += 4;
while (VAR_3 < p_end) {
VAR_5 = VAR_3[0];
if (VAR_5 == RFC1533_PAD) {
VAR_3++;
} else if (VAR_5 == RFC1533_END) {
break;
} else {
VAR_3++;
if (VAR_3 >= p_end)
break;
VAR_4 = *VAR_3++;
DPRINTF("dhcp: VAR_5=%d VAR_4=%d\n", VAR_5, VAR_4);
switch(VAR_5) {
case RFC2132_MSG_TYPE:
if (VAR_4 >= 1)
*VAR_1 = VAR_3[0];
break;
case RFC2132_REQ_ADDR:
if (VAR_4 >= 4)
*VAR_2 = (struct in_addr *)VAR_3;
break;
default:
break;
}
VAR_3 += VAR_4;
}
}
if (*VAR_1 == DHCPREQUEST && !*VAR_2 && VAR_0->bp_ciaddr.s_addr) {
*VAR_2 = &VAR_0->bp_ciaddr;
}
}
| [
"static void FUNC_0(const struct bootp_t *VAR_0, int *VAR_1,\nconst struct in_addr **VAR_2)\n{",
"const uint8_t *VAR_3, *p_end;",
"int VAR_4, VAR_5;",
"*VAR_1 = 0;",
"*VAR_2 = NULL;",
"VAR_3 = VAR_0->bp_vend;",
"p_end = VAR_3 + DHCP_OPT_LEN;",
"if (memcmp(VAR_3, rfc1533_cookie, 4) != 0)\nreturn;",
"VAR_3 += 4;",
"while (VAR_3 < p_end) {",
"VAR_5 = VAR_3[0];",
"if (VAR_5 == RFC1533_PAD) {",
"VAR_3++;",
"} else if (VAR_5 == RFC1533_END) {",
"break;",
"} else {",
"VAR_3++;",
"if (VAR_3 >= p_end)\nbreak;",
"VAR_4 = *VAR_3++;",
"DPRINTF(\"dhcp: VAR_5=%d VAR_4=%d\\n\", VAR_5, VAR_4);",
"switch(VAR_5) {",
"case RFC2132_MSG_TYPE:\nif (VAR_4 >= 1)\n*VAR_1 = VAR_3[0];",
"break;",
"case RFC2132_REQ_ADDR:\nif (VAR_4 >= 4)\n*VAR_2 = (struct in_addr *)VAR_3;",
"break;",
"default:\nbreak;",
"}",
"VAR_3 += VAR_4;",
"}",
"}",
"if (*VAR_1 == DHCPREQUEST && !*VAR_2 && VAR_0->bp_ciaddr.s_addr) {",
"*VAR_2 = &VAR_0->bp_ciaddr;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
55
],
[
57,
59,
61
],
[
63
],
[
65,
67,
69
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
]
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.