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
|
---|---|---|---|---|---|---|---|---|---|---|
26,761 | int ff_h264_decode_sei(H264Context *h){
while (get_bits_left(&h->gb) > 16) {
int size, type;
type=0;
do{
if (get_bits_left(&h->gb) < 8)
return AVERROR_INVALIDDATA;
type+= show_bits(&h->gb, 8);
}while(get_bits(&h->gb, 8) == 255);
size=0;
do{
if (get_bits_left(&h->gb) < 8)
return AVERROR_INVALIDDATA;
size+= show_bits(&h->gb, 8);
}while(get_bits(&h->gb, 8) == 255);
if(h->avctx->debug&FF_DEBUG_STARTCODE)
av_log(h->avctx, AV_LOG_DEBUG, "SEI %d len:%d\n", type, size);
switch(type){
case SEI_TYPE_PIC_TIMING: // Picture timing SEI
if(decode_picture_timing(h) < 0)
return -1;
break;
case SEI_TYPE_USER_DATA_ITU_T_T35:
if(decode_user_data_itu_t_t35(h, size) < 0)
return -1;
break;
case SEI_TYPE_USER_DATA_UNREGISTERED:
if(decode_unregistered_user_data(h, size) < 0)
return -1;
break;
case SEI_TYPE_RECOVERY_POINT:
if(decode_recovery_point(h) < 0)
return -1;
break;
case SEI_BUFFERING_PERIOD:
if(decode_buffering_period(h) < 0)
return -1;
break;
case SEI_TYPE_FRAME_PACKING:
if(decode_frame_packing(h, size) < 0)
return -1;
default:
skip_bits(&h->gb, 8*size);
}
//FIXME check bits here
align_get_bits(&h->gb);
}
return 0;
}
| true | FFmpeg | 80c873a87ed07c6dd772dcf6befb4cf0fd98ef7b | int ff_h264_decode_sei(H264Context *h){
while (get_bits_left(&h->gb) > 16) {
int size, type;
type=0;
do{
if (get_bits_left(&h->gb) < 8)
return AVERROR_INVALIDDATA;
type+= show_bits(&h->gb, 8);
}while(get_bits(&h->gb, 8) == 255);
size=0;
do{
if (get_bits_left(&h->gb) < 8)
return AVERROR_INVALIDDATA;
size+= show_bits(&h->gb, 8);
}while(get_bits(&h->gb, 8) == 255);
if(h->avctx->debug&FF_DEBUG_STARTCODE)
av_log(h->avctx, AV_LOG_DEBUG, "SEI %d len:%d\n", type, size);
switch(type){
case SEI_TYPE_PIC_TIMING:
if(decode_picture_timing(h) < 0)
return -1;
break;
case SEI_TYPE_USER_DATA_ITU_T_T35:
if(decode_user_data_itu_t_t35(h, size) < 0)
return -1;
break;
case SEI_TYPE_USER_DATA_UNREGISTERED:
if(decode_unregistered_user_data(h, size) < 0)
return -1;
break;
case SEI_TYPE_RECOVERY_POINT:
if(decode_recovery_point(h) < 0)
return -1;
break;
case SEI_BUFFERING_PERIOD:
if(decode_buffering_period(h) < 0)
return -1;
break;
case SEI_TYPE_FRAME_PACKING:
if(decode_frame_packing(h, size) < 0)
return -1;
default:
skip_bits(&h->gb, 8*size);
}
align_get_bits(&h->gb);
}
return 0;
}
| {
"code": [
" int size, type;"
],
"line_no": [
5
]
} | int FUNC_0(H264Context *VAR_0){
while (get_bits_left(&VAR_0->gb) > 16) {
int VAR_1, VAR_2;
VAR_2=0;
do{
if (get_bits_left(&VAR_0->gb) < 8)
return AVERROR_INVALIDDATA;
VAR_2+= show_bits(&VAR_0->gb, 8);
}while(get_bits(&VAR_0->gb, 8) == 255);
VAR_1=0;
do{
if (get_bits_left(&VAR_0->gb) < 8)
return AVERROR_INVALIDDATA;
VAR_1+= show_bits(&VAR_0->gb, 8);
}while(get_bits(&VAR_0->gb, 8) == 255);
if(VAR_0->avctx->debug&FF_DEBUG_STARTCODE)
av_log(VAR_0->avctx, AV_LOG_DEBUG, "SEI %d len:%d\n", VAR_2, VAR_1);
switch(VAR_2){
case SEI_TYPE_PIC_TIMING:
if(decode_picture_timing(VAR_0) < 0)
return -1;
break;
case SEI_TYPE_USER_DATA_ITU_T_T35:
if(decode_user_data_itu_t_t35(VAR_0, VAR_1) < 0)
return -1;
break;
case SEI_TYPE_USER_DATA_UNREGISTERED:
if(decode_unregistered_user_data(VAR_0, VAR_1) < 0)
return -1;
break;
case SEI_TYPE_RECOVERY_POINT:
if(decode_recovery_point(VAR_0) < 0)
return -1;
break;
case SEI_BUFFERING_PERIOD:
if(decode_buffering_period(VAR_0) < 0)
return -1;
break;
case SEI_TYPE_FRAME_PACKING:
if(decode_frame_packing(VAR_0, VAR_1) < 0)
return -1;
default:
skip_bits(&VAR_0->gb, 8*VAR_1);
}
align_get_bits(&VAR_0->gb);
}
return 0;
}
| [
"int FUNC_0(H264Context *VAR_0){",
"while (get_bits_left(&VAR_0->gb) > 16) {",
"int VAR_1, VAR_2;",
"VAR_2=0;",
"do{",
"if (get_bits_left(&VAR_0->gb) < 8)\nreturn AVERROR_INVALIDDATA;",
"VAR_2+= show_bits(&VAR_0->gb, 8);",
"}while(get_bits(&VAR_0->gb, 8) == 255);",
"VAR_1=0;",
"do{",
"if (get_bits_left(&VAR_0->gb) < 8)\nreturn AVERROR_INVALIDDATA;",
"VAR_1+= show_bits(&VAR_0->gb, 8);",
"}while(get_bits(&VAR_0->gb, 8) == 255);",
"if(VAR_0->avctx->debug&FF_DEBUG_STARTCODE)\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \"SEI %d len:%d\\n\", VAR_2, VAR_1);",
"switch(VAR_2){",
"case SEI_TYPE_PIC_TIMING:\nif(decode_picture_timing(VAR_0) < 0)\nreturn -1;",
"break;",
"case SEI_TYPE_USER_DATA_ITU_T_T35:\nif(decode_user_data_itu_t_t35(VAR_0, VAR_1) < 0)\nreturn -1;",
"break;",
"case SEI_TYPE_USER_DATA_UNREGISTERED:\nif(decode_unregistered_user_data(VAR_0, VAR_1) < 0)\nreturn -1;",
"break;",
"case SEI_TYPE_RECOVERY_POINT:\nif(decode_recovery_point(VAR_0) < 0)\nreturn -1;",
"break;",
"case SEI_BUFFERING_PERIOD:\nif(decode_buffering_period(VAR_0) < 0)\nreturn -1;",
"break;",
"case SEI_TYPE_FRAME_PACKING:\nif(decode_frame_packing(VAR_0, VAR_1) < 0)\nreturn -1;",
"default:\nskip_bits(&VAR_0->gb, 8*VAR_1);",
"}",
"align_get_bits(&VAR_0->gb);",
"}",
"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,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
9
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
37,
39
],
[
43
],
[
45,
47,
49
],
[
51
],
[
53,
55,
57
],
[
59
],
[
61,
63,
65
],
[
67
],
[
69,
71,
73
],
[
75
],
[
77,
79,
81
],
[
83
],
[
85,
87,
89
],
[
91,
93
],
[
95
],
[
101
],
[
103
],
[
107
],
[
109
]
] |
26,763 | static int mpeg_decode_postinit(AVCodecContext *avctx)
{
Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
uint8_t old_permutation[64];
int ret;
if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
// MPEG-1 aspect
avctx->sample_aspect_ratio = av_d2q(1.0 / ff_mpeg1_aspect[s->aspect_ratio_info], 255);
} else { // MPEG-2
// MPEG-2 aspect
if (s->aspect_ratio_info > 1) {
AVRational dar =
av_mul_q(av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info],
(AVRational) { s1->pan_scan.width,
s1->pan_scan.height }),
(AVRational) { s->width, s->height });
/* We ignore the spec here and guess a bit as reality does not
* match the spec, see for example res_change_ffmpeg_aspect.ts
* and sequence-display-aspect.mpg.
* issue1613, 621, 562 */
if ((s1->pan_scan.width == 0) || (s1->pan_scan.height == 0) ||
(av_cmp_q(dar, (AVRational) { 4, 3 }) &&
av_cmp_q(dar, (AVRational) { 16, 9 }))) {
s->avctx->sample_aspect_ratio =
av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info],
(AVRational) { s->width, s->height });
} else {
s->avctx->sample_aspect_ratio =
av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info],
(AVRational) { s1->pan_scan.width, s1->pan_scan.height });
// issue1613 4/3 16/9 -> 16/9
// res_change_ffmpeg_aspect.ts 4/3 225/44 ->4/3
// widescreen-issue562.mpg 4/3 16/9 -> 16/9
// s->avctx->sample_aspect_ratio = av_mul_q(s->avctx->sample_aspect_ratio, (AVRational) {s->width, s->height});
av_dlog(avctx, "A %d/%d\n",
ff_mpeg2_aspect[s->aspect_ratio_info].num,
ff_mpeg2_aspect[s->aspect_ratio_info].den);
av_dlog(avctx, "B %d/%d\n", s->avctx->sample_aspect_ratio.num,
s->avctx->sample_aspect_ratio.den);
}
} else {
s->avctx->sample_aspect_ratio =
ff_mpeg2_aspect[s->aspect_ratio_info];
}
} // MPEG-2
ff_set_sar(s->avctx, s->avctx->sample_aspect_ratio);
if ((s1->mpeg_enc_ctx_allocated == 0) ||
avctx->coded_width != s->width ||
avctx->coded_height != s->height ||
s1->save_width != s->width ||
s1->save_height != s->height ||
s1->save_aspect_info != s->aspect_ratio_info ||
(s1->save_progressive_seq != s->progressive_sequence && FFALIGN(s->height, 16) != FFALIGN(s->height, 32)) ||
0) {
if (s1->mpeg_enc_ctx_allocated) {
ParseContext pc = s->parse_context;
s->parse_context.buffer = 0;
ff_mpv_common_end(s);
s->parse_context = pc;
s1->mpeg_enc_ctx_allocated = 0;
}
ret = ff_set_dimensions(avctx, s->width, s->height);
if (ret < 0)
return ret;
if (avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO && s->bit_rate) {
avctx->rc_max_rate = s->bit_rate;
} else if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO && s->bit_rate &&
(s->bit_rate != 0x3FFFF*400 || s->vbv_delay != 0xFFFF)) {
avctx->bit_rate = s->bit_rate;
}
s1->save_aspect_info = s->aspect_ratio_info;
s1->save_width = s->width;
s1->save_height = s->height;
s1->save_progressive_seq = s->progressive_sequence;
/* low_delay may be forced, in this case we will have B-frames
* that behave like P-frames. */
avctx->has_b_frames = !s->low_delay;
if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
// MPEG-1 fps
avctx->framerate = ff_mpeg12_frame_rate_tab[s->frame_rate_index];
avctx->ticks_per_frame = 1;
} else { // MPEG-2
// MPEG-2 fps
av_reduce(&s->avctx->framerate.num,
&s->avctx->framerate.den,
ff_mpeg12_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num,
ff_mpeg12_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den,
1 << 30);
avctx->ticks_per_frame = 2;
} // MPEG-2
avctx->pix_fmt = mpeg_get_pixelformat(avctx);
setup_hwaccel_for_pixfmt(avctx);
/* Quantization matrices may need reordering
* if DCT permutation is changed. */
memcpy(old_permutation, s->idsp.idct_permutation, 64 * sizeof(uint8_t));
ff_mpv_idct_init(s);
if ((ret = ff_mpv_common_init(s)) < 0)
return ret;
quant_matrix_rebuild(s->intra_matrix, old_permutation, s->idsp.idct_permutation);
quant_matrix_rebuild(s->inter_matrix, old_permutation, s->idsp.idct_permutation);
quant_matrix_rebuild(s->chroma_intra_matrix, old_permutation, s->idsp.idct_permutation);
quant_matrix_rebuild(s->chroma_inter_matrix, old_permutation, s->idsp.idct_permutation);
s1->mpeg_enc_ctx_allocated = 1;
}
return 0;
}
| false | FFmpeg | 75cc57f73f9aee8721a101b3c6ef85312ea9e54c | static int mpeg_decode_postinit(AVCodecContext *avctx)
{
Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
uint8_t old_permutation[64];
int ret;
if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
avctx->sample_aspect_ratio = av_d2q(1.0 / ff_mpeg1_aspect[s->aspect_ratio_info], 255);
} else {
aspect
if (s->aspect_ratio_info > 1) {
AVRational dar =
av_mul_q(av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info],
(AVRational) { s1->pan_scan.width,
s1->pan_scan.height }),
(AVRational) { s->width, s->height });
if ((s1->pan_scan.width == 0) || (s1->pan_scan.height == 0) ||
(av_cmp_q(dar, (AVRational) { 4, 3 }) &&
av_cmp_q(dar, (AVRational) { 16, 9 }))) {
s->avctx->sample_aspect_ratio =
av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info],
(AVRational) { s->width, s->height });
} else {
s->avctx->sample_aspect_ratio =
av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info],
(AVRational) { s1->pan_scan.width, s1->pan_scan.height });
av_dlog(avctx, "A %d/%d\n",
ff_mpeg2_aspect[s->aspect_ratio_info].num,
ff_mpeg2_aspect[s->aspect_ratio_info].den);
av_dlog(avctx, "B %d/%d\n", s->avctx->sample_aspect_ratio.num,
s->avctx->sample_aspect_ratio.den);
}
} else {
s->avctx->sample_aspect_ratio =
ff_mpeg2_aspect[s->aspect_ratio_info];
}
}
ff_set_sar(s->avctx, s->avctx->sample_aspect_ratio);
if ((s1->mpeg_enc_ctx_allocated == 0) ||
avctx->coded_width != s->width ||
avctx->coded_height != s->height ||
s1->save_width != s->width ||
s1->save_height != s->height ||
s1->save_aspect_info != s->aspect_ratio_info ||
(s1->save_progressive_seq != s->progressive_sequence && FFALIGN(s->height, 16) != FFALIGN(s->height, 32)) ||
0) {
if (s1->mpeg_enc_ctx_allocated) {
ParseContext pc = s->parse_context;
s->parse_context.buffer = 0;
ff_mpv_common_end(s);
s->parse_context = pc;
s1->mpeg_enc_ctx_allocated = 0;
}
ret = ff_set_dimensions(avctx, s->width, s->height);
if (ret < 0)
return ret;
if (avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO && s->bit_rate) {
avctx->rc_max_rate = s->bit_rate;
} else if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO && s->bit_rate &&
(s->bit_rate != 0x3FFFF*400 || s->vbv_delay != 0xFFFF)) {
avctx->bit_rate = s->bit_rate;
}
s1->save_aspect_info = s->aspect_ratio_info;
s1->save_width = s->width;
s1->save_height = s->height;
s1->save_progressive_seq = s->progressive_sequence;
avctx->has_b_frames = !s->low_delay;
if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
avctx->framerate = ff_mpeg12_frame_rate_tab[s->frame_rate_index];
avctx->ticks_per_frame = 1;
} else {
fps
av_reduce(&s->avctx->framerate.num,
&s->avctx->framerate.den,
ff_mpeg12_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num,
ff_mpeg12_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den,
1 << 30);
avctx->ticks_per_frame = 2;
}
avctx->pix_fmt = mpeg_get_pixelformat(avctx);
setup_hwaccel_for_pixfmt(avctx);
memcpy(old_permutation, s->idsp.idct_permutation, 64 * sizeof(uint8_t));
ff_mpv_idct_init(s);
if ((ret = ff_mpv_common_init(s)) < 0)
return ret;
quant_matrix_rebuild(s->intra_matrix, old_permutation, s->idsp.idct_permutation);
quant_matrix_rebuild(s->inter_matrix, old_permutation, s->idsp.idct_permutation);
quant_matrix_rebuild(s->chroma_intra_matrix, old_permutation, s->idsp.idct_permutation);
quant_matrix_rebuild(s->chroma_inter_matrix, old_permutation, s->idsp.idct_permutation);
s1->mpeg_enc_ctx_allocated = 1;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0)
{
Mpeg1Context *s1 = VAR_0->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
uint8_t old_permutation[64];
int VAR_1;
if (VAR_0->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
VAR_0->sample_aspect_ratio = av_d2q(1.0 / ff_mpeg1_aspect[s->aspect_ratio_info], 255);
} else {
aspect
if (s->aspect_ratio_info > 1) {
AVRational dar =
av_mul_q(av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info],
(AVRational) { s1->pan_scan.width,
s1->pan_scan.height }),
(AVRational) { s->width, s->height });
if ((s1->pan_scan.width == 0) || (s1->pan_scan.height == 0) ||
(av_cmp_q(dar, (AVRational) { 4, 3 }) &&
av_cmp_q(dar, (AVRational) { 16, 9 }))) {
s->VAR_0->sample_aspect_ratio =
av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info],
(AVRational) { s->width, s->height });
} else {
s->VAR_0->sample_aspect_ratio =
av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info],
(AVRational) { s1->pan_scan.width, s1->pan_scan.height });
av_dlog(VAR_0, "A %d/%d\n",
ff_mpeg2_aspect[s->aspect_ratio_info].num,
ff_mpeg2_aspect[s->aspect_ratio_info].den);
av_dlog(VAR_0, "B %d/%d\n", s->VAR_0->sample_aspect_ratio.num,
s->VAR_0->sample_aspect_ratio.den);
}
} else {
s->VAR_0->sample_aspect_ratio =
ff_mpeg2_aspect[s->aspect_ratio_info];
}
}
ff_set_sar(s->VAR_0, s->VAR_0->sample_aspect_ratio);
if ((s1->mpeg_enc_ctx_allocated == 0) ||
VAR_0->coded_width != s->width ||
VAR_0->coded_height != s->height ||
s1->save_width != s->width ||
s1->save_height != s->height ||
s1->save_aspect_info != s->aspect_ratio_info ||
(s1->save_progressive_seq != s->progressive_sequence && FFALIGN(s->height, 16) != FFALIGN(s->height, 32)) ||
0) {
if (s1->mpeg_enc_ctx_allocated) {
ParseContext pc = s->parse_context;
s->parse_context.buffer = 0;
ff_mpv_common_end(s);
s->parse_context = pc;
s1->mpeg_enc_ctx_allocated = 0;
}
VAR_1 = ff_set_dimensions(VAR_0, s->width, s->height);
if (VAR_1 < 0)
return VAR_1;
if (VAR_0->codec_id == AV_CODEC_ID_MPEG2VIDEO && s->bit_rate) {
VAR_0->rc_max_rate = s->bit_rate;
} else if (VAR_0->codec_id == AV_CODEC_ID_MPEG1VIDEO && s->bit_rate &&
(s->bit_rate != 0x3FFFF*400 || s->vbv_delay != 0xFFFF)) {
VAR_0->bit_rate = s->bit_rate;
}
s1->save_aspect_info = s->aspect_ratio_info;
s1->save_width = s->width;
s1->save_height = s->height;
s1->save_progressive_seq = s->progressive_sequence;
VAR_0->has_b_frames = !s->low_delay;
if (VAR_0->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
VAR_0->framerate = ff_mpeg12_frame_rate_tab[s->frame_rate_index];
VAR_0->ticks_per_frame = 1;
} else {
fps
av_reduce(&s->VAR_0->framerate.num,
&s->VAR_0->framerate.den,
ff_mpeg12_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num,
ff_mpeg12_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den,
1 << 30);
VAR_0->ticks_per_frame = 2;
}
VAR_0->pix_fmt = mpeg_get_pixelformat(VAR_0);
setup_hwaccel_for_pixfmt(VAR_0);
memcpy(old_permutation, s->idsp.idct_permutation, 64 * sizeof(uint8_t));
ff_mpv_idct_init(s);
if ((VAR_1 = ff_mpv_common_init(s)) < 0)
return VAR_1;
quant_matrix_rebuild(s->intra_matrix, old_permutation, s->idsp.idct_permutation);
quant_matrix_rebuild(s->inter_matrix, old_permutation, s->idsp.idct_permutation);
quant_matrix_rebuild(s->chroma_intra_matrix, old_permutation, s->idsp.idct_permutation);
quant_matrix_rebuild(s->chroma_inter_matrix, old_permutation, s->idsp.idct_permutation);
s1->mpeg_enc_ctx_allocated = 1;
}
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0)\n{",
"Mpeg1Context *s1 = VAR_0->priv_data;",
"MpegEncContext *s = &s1->mpeg_enc_ctx;",
"uint8_t old_permutation[64];",
"int VAR_1;",
"if (VAR_0->codec_id == AV_CODEC_ID_MPEG1VIDEO) {",
"VAR_0->sample_aspect_ratio = av_d2q(1.0 / ff_mpeg1_aspect[s->aspect_ratio_info], 255);",
"} else {",
"aspect\nif (s->aspect_ratio_info > 1) {",
"AVRational dar =\nav_mul_q(av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info],\n(AVRational) { s1->pan_scan.width,",
"s1->pan_scan.height }),",
"(AVRational) { s->width, s->height });",
"if ((s1->pan_scan.width == 0) || (s1->pan_scan.height == 0) ||\n(av_cmp_q(dar, (AVRational) { 4, 3 }) &&",
"av_cmp_q(dar, (AVRational) { 16, 9 }))) {",
"s->VAR_0->sample_aspect_ratio =\nav_div_q(ff_mpeg2_aspect[s->aspect_ratio_info],\n(AVRational) { s->width, s->height });",
"} else {",
"s->VAR_0->sample_aspect_ratio =\nav_div_q(ff_mpeg2_aspect[s->aspect_ratio_info],\n(AVRational) { s1->pan_scan.width, s1->pan_scan.height });",
"av_dlog(VAR_0, \"A %d/%d\\n\",\nff_mpeg2_aspect[s->aspect_ratio_info].num,\nff_mpeg2_aspect[s->aspect_ratio_info].den);",
"av_dlog(VAR_0, \"B %d/%d\\n\", s->VAR_0->sample_aspect_ratio.num,\ns->VAR_0->sample_aspect_ratio.den);",
"}",
"} else {",
"s->VAR_0->sample_aspect_ratio =\nff_mpeg2_aspect[s->aspect_ratio_info];",
"}",
"}",
"ff_set_sar(s->VAR_0, s->VAR_0->sample_aspect_ratio);",
"if ((s1->mpeg_enc_ctx_allocated == 0) ||\nVAR_0->coded_width != s->width ||\nVAR_0->coded_height != s->height ||\ns1->save_width != s->width ||\ns1->save_height != s->height ||\ns1->save_aspect_info != s->aspect_ratio_info ||\n(s1->save_progressive_seq != s->progressive_sequence && FFALIGN(s->height, 16) != FFALIGN(s->height, 32)) ||\n0) {",
"if (s1->mpeg_enc_ctx_allocated) {",
"ParseContext pc = s->parse_context;",
"s->parse_context.buffer = 0;",
"ff_mpv_common_end(s);",
"s->parse_context = pc;",
"s1->mpeg_enc_ctx_allocated = 0;",
"}",
"VAR_1 = ff_set_dimensions(VAR_0, s->width, s->height);",
"if (VAR_1 < 0)\nreturn VAR_1;",
"if (VAR_0->codec_id == AV_CODEC_ID_MPEG2VIDEO && s->bit_rate) {",
"VAR_0->rc_max_rate = s->bit_rate;",
"} else if (VAR_0->codec_id == AV_CODEC_ID_MPEG1VIDEO && s->bit_rate &&",
"(s->bit_rate != 0x3FFFF*400 || s->vbv_delay != 0xFFFF)) {",
"VAR_0->bit_rate = s->bit_rate;",
"}",
"s1->save_aspect_info = s->aspect_ratio_info;",
"s1->save_width = s->width;",
"s1->save_height = s->height;",
"s1->save_progressive_seq = s->progressive_sequence;",
"VAR_0->has_b_frames = !s->low_delay;",
"if (VAR_0->codec_id == AV_CODEC_ID_MPEG1VIDEO) {",
"VAR_0->framerate = ff_mpeg12_frame_rate_tab[s->frame_rate_index];",
"VAR_0->ticks_per_frame = 1;",
"} else {",
"fps\nav_reduce(&s->VAR_0->framerate.num,\n&s->VAR_0->framerate.den,\nff_mpeg12_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num,\nff_mpeg12_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den,\n1 << 30);",
"VAR_0->ticks_per_frame = 2;",
"}",
"VAR_0->pix_fmt = mpeg_get_pixelformat(VAR_0);",
"setup_hwaccel_for_pixfmt(VAR_0);",
"memcpy(old_permutation, s->idsp.idct_permutation, 64 * sizeof(uint8_t));",
"ff_mpv_idct_init(s);",
"if ((VAR_1 = ff_mpv_common_init(s)) < 0)\nreturn VAR_1;",
"quant_matrix_rebuild(s->intra_matrix, old_permutation, s->idsp.idct_permutation);",
"quant_matrix_rebuild(s->inter_matrix, old_permutation, s->idsp.idct_permutation);",
"quant_matrix_rebuild(s->chroma_intra_matrix, old_permutation, s->idsp.idct_permutation);",
"quant_matrix_rebuild(s->chroma_inter_matrix, old_permutation, s->idsp.idct_permutation);",
"s1->mpeg_enc_ctx_allocated = 1;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23,
25
],
[
27,
29,
31
],
[
33
],
[
35
],
[
47,
49
],
[
51
],
[
53,
55,
57
],
[
59
],
[
61,
63,
65
],
[
75,
77,
79
],
[
81,
83
],
[
85
],
[
87
],
[
89,
91
],
[
93
],
[
95
],
[
99
],
[
103,
105,
107,
109,
111,
113,
115,
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137,
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
169
],
[
173
],
[
177
],
[
179
],
[
181
],
[
183,
185,
187,
189,
191,
193
],
[
195
],
[
197
],
[
201
],
[
203
],
[
211
],
[
215
],
[
217,
219
],
[
223
],
[
225
],
[
227
],
[
229
],
[
233
],
[
235
],
[
237
],
[
239
]
] |
26,764 | static int mxf_read_primer_pack(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
{
MXFContext *mxf = arg;
int item_num = avio_rb32(pb);
int item_len = avio_rb32(pb);
if (item_len != 18) {
avpriv_request_sample(pb, "Primer pack item length %d", item_len);
return AVERROR_PATCHWELCOME;
}
if (item_num > 65536) {
av_log(mxf->fc, AV_LOG_ERROR, "item_num %d is too large\n", item_num);
return AVERROR_INVALIDDATA;
}
mxf->local_tags = av_calloc(item_num, item_len);
if (!mxf->local_tags)
return AVERROR(ENOMEM);
mxf->local_tags_count = item_num;
avio_read(pb, mxf->local_tags, item_num*item_len);
return 0;
} | true | FFmpeg | aae4f5108d04041bb264a9c547f05c4f0d18c9c7 | static int mxf_read_primer_pack(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
{
MXFContext *mxf = arg;
int item_num = avio_rb32(pb);
int item_len = avio_rb32(pb);
if (item_len != 18) {
avpriv_request_sample(pb, "Primer pack item length %d", item_len);
return AVERROR_PATCHWELCOME;
}
if (item_num > 65536) {
av_log(mxf->fc, AV_LOG_ERROR, "item_num %d is too large\n", item_num);
return AVERROR_INVALIDDATA;
}
mxf->local_tags = av_calloc(item_num, item_len);
if (!mxf->local_tags)
return AVERROR(ENOMEM);
mxf->local_tags_count = item_num;
avio_read(pb, mxf->local_tags, item_num*item_len);
return 0;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(void *VAR_0, AVIOContext *VAR_1, int VAR_2, int VAR_3, UID VAR_4, int64_t VAR_5)
{
MXFContext *mxf = VAR_0;
int VAR_6 = avio_rb32(VAR_1);
int VAR_7 = avio_rb32(VAR_1);
if (VAR_7 != 18) {
avpriv_request_sample(VAR_1, "Primer pack item length %d", VAR_7);
return AVERROR_PATCHWELCOME;
}
if (VAR_6 > 65536) {
av_log(mxf->fc, AV_LOG_ERROR, "VAR_6 %d is too large\n", VAR_6);
return AVERROR_INVALIDDATA;
}
mxf->local_tags = av_calloc(VAR_6, VAR_7);
if (!mxf->local_tags)
return AVERROR(ENOMEM);
mxf->local_tags_count = VAR_6;
avio_read(VAR_1, mxf->local_tags, VAR_6*VAR_7);
return 0;
} | [
"static int FUNC_0(void *VAR_0, AVIOContext *VAR_1, int VAR_2, int VAR_3, UID VAR_4, int64_t VAR_5)\n{",
"MXFContext *mxf = VAR_0;",
"int VAR_6 = avio_rb32(VAR_1);",
"int VAR_7 = avio_rb32(VAR_1);",
"if (VAR_7 != 18) {",
"avpriv_request_sample(VAR_1, \"Primer pack item length %d\", VAR_7);",
"return AVERROR_PATCHWELCOME;",
"}",
"if (VAR_6 > 65536) {",
"av_log(mxf->fc, AV_LOG_ERROR, \"VAR_6 %d is too large\\n\", VAR_6);",
"return AVERROR_INVALIDDATA;",
"}",
"mxf->local_tags = av_calloc(VAR_6, VAR_7);",
"if (!mxf->local_tags)\nreturn AVERROR(ENOMEM);",
"mxf->local_tags_count = VAR_6;",
"avio_read(VAR_1, mxf->local_tags, VAR_6*VAR_7);",
"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
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
]
] |
26,765 | void kvm_inject_x86_mce(CPUState *cenv, int bank, uint64_t status,
uint64_t mcg_status, uint64_t addr, uint64_t misc,
int abort_on_error)
{
#ifdef KVM_CAP_MCE
struct kvm_x86_mce mce = {
.bank = bank,
.status = status,
.mcg_status = mcg_status,
.addr = addr,
.misc = misc,
};
struct kvm_x86_mce_data data = {
.env = cenv,
.mce = &mce,
};
if (!cenv->mcg_cap) {
fprintf(stderr, "MCE support is not enabled!\n");
return;
}
run_on_cpu(cenv, kvm_do_inject_x86_mce, &data);
#else
if (abort_on_error)
abort();
#endif
}
| true | qemu | 31ce5e0c49821d92fb30cce2f3055ef33613b287 | void kvm_inject_x86_mce(CPUState *cenv, int bank, uint64_t status,
uint64_t mcg_status, uint64_t addr, uint64_t misc,
int abort_on_error)
{
#ifdef KVM_CAP_MCE
struct kvm_x86_mce mce = {
.bank = bank,
.status = status,
.mcg_status = mcg_status,
.addr = addr,
.misc = misc,
};
struct kvm_x86_mce_data data = {
.env = cenv,
.mce = &mce,
};
if (!cenv->mcg_cap) {
fprintf(stderr, "MCE support is not enabled!\n");
return;
}
run_on_cpu(cenv, kvm_do_inject_x86_mce, &data);
#else
if (abort_on_error)
abort();
#endif
}
| {
"code": [
" int abort_on_error)",
" if (abort_on_error)"
],
"line_no": [
5,
49
]
} | void FUNC_0(CPUState *VAR_0, int VAR_1, uint64_t VAR_2,
uint64_t VAR_3, uint64_t VAR_4, uint64_t VAR_5,
int VAR_6)
{
#ifdef KVM_CAP_MCE
struct kvm_x86_mce mce = {
.VAR_1 = VAR_1,
.VAR_2 = VAR_2,
.VAR_3 = VAR_3,
.VAR_4 = VAR_4,
.VAR_5 = VAR_5,
};
struct kvm_x86_mce_data data = {
.env = VAR_0,
.mce = &mce,
};
if (!VAR_0->mcg_cap) {
fprintf(stderr, "MCE support is not enabled!\n");
return;
}
run_on_cpu(VAR_0, kvm_do_inject_x86_mce, &data);
#else
if (VAR_6)
abort();
#endif
}
| [
"void FUNC_0(CPUState *VAR_0, int VAR_1, uint64_t VAR_2,\nuint64_t VAR_3, uint64_t VAR_4, uint64_t VAR_5,\nint VAR_6)\n{",
"#ifdef KVM_CAP_MCE\nstruct kvm_x86_mce mce = {",
".VAR_1 = VAR_1,\n.VAR_2 = VAR_2,\n.VAR_3 = VAR_3,\n.VAR_4 = VAR_4,\n.VAR_5 = VAR_5,\n};",
"struct kvm_x86_mce_data data = {",
".env = VAR_0,\n.mce = &mce,\n};",
"if (!VAR_0->mcg_cap) {",
"fprintf(stderr, \"MCE support is not enabled!\\n\");",
"return;",
"}",
"run_on_cpu(VAR_0, kvm_do_inject_x86_mce, &data);",
"#else\nif (VAR_6)\nabort();",
"#endif\n}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3,
5,
7
],
[
9,
11
],
[
13,
15,
17,
19,
21,
23
],
[
25
],
[
27,
29,
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47,
49,
51
],
[
53,
55
]
] |
26,766 | static inline void RENAME(yuv2bgr24_2)(SwsContext *c, const uint16_t *buf0,
const uint16_t *buf1, const uint16_t *ubuf0,
const uint16_t *ubuf1, const uint16_t *vbuf0,
const uint16_t *vbuf1, const uint16_t *abuf0,
const uint16_t *abuf1, uint8_t *dest,
int dstW, int yalpha, int uvalpha, int y)
{
x86_reg uv_off = c->uv_off << 1;
//Note 8280 == DSTW_OFFSET but the preprocessor can't handle that there :(
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB(%%REGBP, %5, %6)
"pxor %%mm7, %%mm7 \n\t"
WRITEBGR24(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither), "m"(uv_off)
);
}
| true | FFmpeg | 009f829dde811af654af7110326aea3a72c05d5e | static inline void RENAME(yuv2bgr24_2)(SwsContext *c, const uint16_t *buf0,
const uint16_t *buf1, const uint16_t *ubuf0,
const uint16_t *ubuf1, const uint16_t *vbuf0,
const uint16_t *vbuf1, const uint16_t *abuf0,
const uint16_t *abuf1, uint8_t *dest,
int dstW, int yalpha, int uvalpha, int y)
{
x86_reg uv_off = c->uv_off << 1;
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB(%%REGBP, %5, %6)
"pxor %%mm7, %%mm7 \n\t"
WRITEBGR24(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither), "m"(uv_off)
);
}
| {
"code": [
" x86_reg uv_off = c->uv_off << 1;",
" x86_reg uv_off = c->uv_off << 1;",
" YSCALEYUV2RGB(%%REGBP, %5, %6)",
" \"a\" (&c->redDither), \"m\"(uv_off)",
" x86_reg uv_off = c->uv_off << 1;",
" YSCALEYUV2RGB(%%REGBP, %5, %6)",
" \"a\" (&c->redDither), \"m\"(uv_off)",
" x86_reg uv_off = c->uv_off << 1;",
" YSCALEYUV2RGB(%%REGBP, %5, %6)",
" \"a\" (&c->redDither), \"m\"(uv_off)",
" x86_reg uv_off = c->uv_off << 1;",
" \"a\" (&c->redDither), \"m\"(uv_off)",
" x86_reg uv_off = c->uv_off << 1;",
" x86_reg uv_off = c->uv_off << 1;",
" x86_reg uv_off = c->uv_off << 1;",
" x86_reg uv_off = c->uv_off << 1;",
" x86_reg uv_off = c->uv_off << 1;"
],
"line_no": [
15,
15,
29,
41,
15,
29,
41,
15,
29,
41,
15,
41,
15,
15,
15,
15,
15
]
} | static inline void FUNC_0(yuv2bgr24_2)(SwsContext *c, const uint16_t *buf0,
const uint16_t *buf1, const uint16_t *ubuf0,
const uint16_t *ubuf1, const uint16_t *vbuf0,
const uint16_t *vbuf1, const uint16_t *abuf0,
const uint16_t *abuf1, uint8_t *dest,
int dstW, int yalpha, int uvalpha, int y)
{
x86_reg uv_off = c->uv_off << 1;
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB(%%REGBP, %5, %6)
"pxor %%mm7, %%mm7 \n\t"
WRITEBGR24(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither), "m"(uv_off)
);
}
| [
"static inline void FUNC_0(yuv2bgr24_2)(SwsContext *c, const uint16_t *buf0,\nconst uint16_t *buf1, const uint16_t *ubuf0,\nconst uint16_t *ubuf1, const uint16_t *vbuf0,\nconst uint16_t *vbuf1, const uint16_t *abuf0,\nconst uint16_t *abuf1, uint8_t *dest,\nint dstW, int yalpha, int uvalpha, int y)\n{",
"x86_reg uv_off = c->uv_off << 1;",
"__asm__ volatile(\n\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5) \\n\\t\"\n\"mov %4, %%\"REG_b\" \\n\\t\"\n\"push %%\"REG_BP\" \\n\\t\"\nYSCALEYUV2RGB(%%REGBP, %5, %6)\n\"pxor %%mm7, %%mm7 \\n\\t\"\nWRITEBGR24(%%REGb, 8280(%5), %%REGBP)\n\"pop %%\"REG_BP\" \\n\\t\"\n\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\" \\n\\t\"\n:: \"c\" (buf0), \"d\" (buf1), \"S\" (ubuf0), \"D\" (ubuf1), \"m\" (dest),\n\"a\" (&c->redDither), \"m\"(uv_off)\n);",
"}"
] | [
0,
1,
1,
0
] | [
[
1,
3,
5,
7,
9,
11,
13
],
[
15
],
[
21,
23,
25,
27,
29,
31,
33,
35,
37,
39,
41,
43
],
[
45
]
] |
26,767 | static int usb_xhci_initfn(struct PCIDevice *dev)
{
int i, ret;
XHCIState *xhci = DO_UPCAST(XHCIState, pci_dev, dev);
xhci->pci_dev.config[PCI_CLASS_PROG] = 0x30; /* xHCI */
xhci->pci_dev.config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin 1 */
xhci->pci_dev.config[PCI_CACHE_LINE_SIZE] = 0x10;
xhci->pci_dev.config[0x60] = 0x30; /* release number */
usb_xhci_init(xhci, &dev->qdev);
if (xhci->numintrs > MAXINTRS) {
xhci->numintrs = MAXINTRS;
if (xhci->numintrs < 1) {
xhci->numintrs = 1;
if (xhci->numslots > MAXSLOTS) {
xhci->numslots = MAXSLOTS;
if (xhci->numslots < 1) {
xhci->numslots = 1;
xhci->mfwrap_timer = qemu_new_timer_ns(vm_clock, xhci_mfwrap_timer, xhci);
xhci->irq = xhci->pci_dev.irq[0];
memory_region_init(&xhci->mem, "xhci", LEN_REGS);
memory_region_init_io(&xhci->mem_cap, &xhci_cap_ops, xhci,
"capabilities", LEN_CAP);
memory_region_init_io(&xhci->mem_oper, &xhci_oper_ops, xhci,
"operational", 0x400);
memory_region_init_io(&xhci->mem_runtime, &xhci_runtime_ops, xhci,
"runtime", LEN_RUNTIME);
memory_region_init_io(&xhci->mem_doorbell, &xhci_doorbell_ops, xhci,
"doorbell", LEN_DOORBELL);
memory_region_add_subregion(&xhci->mem, 0, &xhci->mem_cap);
memory_region_add_subregion(&xhci->mem, OFF_OPER, &xhci->mem_oper);
memory_region_add_subregion(&xhci->mem, OFF_RUNTIME, &xhci->mem_runtime);
memory_region_add_subregion(&xhci->mem, OFF_DOORBELL, &xhci->mem_doorbell);
for (i = 0; i < xhci->numports; i++) {
XHCIPort *port = &xhci->ports[i];
uint32_t offset = OFF_OPER + 0x400 + 0x10 * i;
port->xhci = xhci;
memory_region_init_io(&port->mem, &xhci_port_ops, port,
port->name, 0x10);
memory_region_add_subregion(&xhci->mem, offset, &port->mem);
pci_register_bar(&xhci->pci_dev, 0,
PCI_BASE_ADDRESS_SPACE_MEMORY|PCI_BASE_ADDRESS_MEM_TYPE_64,
&xhci->mem);
ret = pcie_endpoint_cap_init(&xhci->pci_dev, 0xa0);
assert(ret >= 0);
if (xhci->flags & (1 << XHCI_FLAG_USE_MSI)) {
msi_init(&xhci->pci_dev, 0x70, xhci->numintrs, true, false);
if (xhci->flags & (1 << XHCI_FLAG_USE_MSI_X)) {
msix_init(&xhci->pci_dev, xhci->numintrs,
&xhci->mem, 0, OFF_MSIX_TABLE,
&xhci->mem, 0, OFF_MSIX_PBA,
0x90);
return 0;
| true | qemu | c94a7c6979cafa7a71f32b35e0ff71ed00c61a89 | static int usb_xhci_initfn(struct PCIDevice *dev)
{
int i, ret;
XHCIState *xhci = DO_UPCAST(XHCIState, pci_dev, dev);
xhci->pci_dev.config[PCI_CLASS_PROG] = 0x30;
xhci->pci_dev.config[PCI_INTERRUPT_PIN] = 0x01;
xhci->pci_dev.config[PCI_CACHE_LINE_SIZE] = 0x10;
xhci->pci_dev.config[0x60] = 0x30;
usb_xhci_init(xhci, &dev->qdev);
if (xhci->numintrs > MAXINTRS) {
xhci->numintrs = MAXINTRS;
if (xhci->numintrs < 1) {
xhci->numintrs = 1;
if (xhci->numslots > MAXSLOTS) {
xhci->numslots = MAXSLOTS;
if (xhci->numslots < 1) {
xhci->numslots = 1;
xhci->mfwrap_timer = qemu_new_timer_ns(vm_clock, xhci_mfwrap_timer, xhci);
xhci->irq = xhci->pci_dev.irq[0];
memory_region_init(&xhci->mem, "xhci", LEN_REGS);
memory_region_init_io(&xhci->mem_cap, &xhci_cap_ops, xhci,
"capabilities", LEN_CAP);
memory_region_init_io(&xhci->mem_oper, &xhci_oper_ops, xhci,
"operational", 0x400);
memory_region_init_io(&xhci->mem_runtime, &xhci_runtime_ops, xhci,
"runtime", LEN_RUNTIME);
memory_region_init_io(&xhci->mem_doorbell, &xhci_doorbell_ops, xhci,
"doorbell", LEN_DOORBELL);
memory_region_add_subregion(&xhci->mem, 0, &xhci->mem_cap);
memory_region_add_subregion(&xhci->mem, OFF_OPER, &xhci->mem_oper);
memory_region_add_subregion(&xhci->mem, OFF_RUNTIME, &xhci->mem_runtime);
memory_region_add_subregion(&xhci->mem, OFF_DOORBELL, &xhci->mem_doorbell);
for (i = 0; i < xhci->numports; i++) {
XHCIPort *port = &xhci->ports[i];
uint32_t offset = OFF_OPER + 0x400 + 0x10 * i;
port->xhci = xhci;
memory_region_init_io(&port->mem, &xhci_port_ops, port,
port->name, 0x10);
memory_region_add_subregion(&xhci->mem, offset, &port->mem);
pci_register_bar(&xhci->pci_dev, 0,
PCI_BASE_ADDRESS_SPACE_MEMORY|PCI_BASE_ADDRESS_MEM_TYPE_64,
&xhci->mem);
ret = pcie_endpoint_cap_init(&xhci->pci_dev, 0xa0);
assert(ret >= 0);
if (xhci->flags & (1 << XHCI_FLAG_USE_MSI)) {
msi_init(&xhci->pci_dev, 0x70, xhci->numintrs, true, false);
if (xhci->flags & (1 << XHCI_FLAG_USE_MSI_X)) {
msix_init(&xhci->pci_dev, xhci->numintrs,
&xhci->mem, 0, OFF_MSIX_TABLE,
&xhci->mem, 0, OFF_MSIX_PBA,
0x90);
return 0;
| {
"code": [],
"line_no": []
} | static int FUNC_0(struct PCIDevice *VAR_0)
{
int VAR_1, VAR_2;
XHCIState *xhci = DO_UPCAST(XHCIState, pci_dev, VAR_0);
xhci->pci_dev.config[PCI_CLASS_PROG] = 0x30;
xhci->pci_dev.config[PCI_INTERRUPT_PIN] = 0x01;
xhci->pci_dev.config[PCI_CACHE_LINE_SIZE] = 0x10;
xhci->pci_dev.config[0x60] = 0x30;
usb_xhci_init(xhci, &VAR_0->qdev);
if (xhci->numintrs > MAXINTRS) {
xhci->numintrs = MAXINTRS;
if (xhci->numintrs < 1) {
xhci->numintrs = 1;
if (xhci->numslots > MAXSLOTS) {
xhci->numslots = MAXSLOTS;
if (xhci->numslots < 1) {
xhci->numslots = 1;
xhci->mfwrap_timer = qemu_new_timer_ns(vm_clock, xhci_mfwrap_timer, xhci);
xhci->irq = xhci->pci_dev.irq[0];
memory_region_init(&xhci->mem, "xhci", LEN_REGS);
memory_region_init_io(&xhci->mem_cap, &xhci_cap_ops, xhci,
"capabilities", LEN_CAP);
memory_region_init_io(&xhci->mem_oper, &xhci_oper_ops, xhci,
"operational", 0x400);
memory_region_init_io(&xhci->mem_runtime, &xhci_runtime_ops, xhci,
"runtime", LEN_RUNTIME);
memory_region_init_io(&xhci->mem_doorbell, &xhci_doorbell_ops, xhci,
"doorbell", LEN_DOORBELL);
memory_region_add_subregion(&xhci->mem, 0, &xhci->mem_cap);
memory_region_add_subregion(&xhci->mem, OFF_OPER, &xhci->mem_oper);
memory_region_add_subregion(&xhci->mem, OFF_RUNTIME, &xhci->mem_runtime);
memory_region_add_subregion(&xhci->mem, OFF_DOORBELL, &xhci->mem_doorbell);
for (VAR_1 = 0; VAR_1 < xhci->numports; VAR_1++) {
XHCIPort *port = &xhci->ports[VAR_1];
uint32_t offset = OFF_OPER + 0x400 + 0x10 * VAR_1;
port->xhci = xhci;
memory_region_init_io(&port->mem, &xhci_port_ops, port,
port->name, 0x10);
memory_region_add_subregion(&xhci->mem, offset, &port->mem);
pci_register_bar(&xhci->pci_dev, 0,
PCI_BASE_ADDRESS_SPACE_MEMORY|PCI_BASE_ADDRESS_MEM_TYPE_64,
&xhci->mem);
VAR_2 = pcie_endpoint_cap_init(&xhci->pci_dev, 0xa0);
assert(VAR_2 >= 0);
if (xhci->flags & (1 << XHCI_FLAG_USE_MSI)) {
msi_init(&xhci->pci_dev, 0x70, xhci->numintrs, true, false);
if (xhci->flags & (1 << XHCI_FLAG_USE_MSI_X)) {
msix_init(&xhci->pci_dev, xhci->numintrs,
&xhci->mem, 0, OFF_MSIX_TABLE,
&xhci->mem, 0, OFF_MSIX_PBA,
0x90);
return 0;
| [
"static int FUNC_0(struct PCIDevice *VAR_0)\n{",
"int VAR_1, VAR_2;",
"XHCIState *xhci = DO_UPCAST(XHCIState, pci_dev, VAR_0);",
"xhci->pci_dev.config[PCI_CLASS_PROG] = 0x30;",
"xhci->pci_dev.config[PCI_INTERRUPT_PIN] = 0x01;",
"xhci->pci_dev.config[PCI_CACHE_LINE_SIZE] = 0x10;",
"xhci->pci_dev.config[0x60] = 0x30;",
"usb_xhci_init(xhci, &VAR_0->qdev);",
"if (xhci->numintrs > MAXINTRS) {",
"xhci->numintrs = MAXINTRS;",
"if (xhci->numintrs < 1) {",
"xhci->numintrs = 1;",
"if (xhci->numslots > MAXSLOTS) {",
"xhci->numslots = MAXSLOTS;",
"if (xhci->numslots < 1) {",
"xhci->numslots = 1;",
"xhci->mfwrap_timer = qemu_new_timer_ns(vm_clock, xhci_mfwrap_timer, xhci);",
"xhci->irq = xhci->pci_dev.irq[0];",
"memory_region_init(&xhci->mem, \"xhci\", LEN_REGS);",
"memory_region_init_io(&xhci->mem_cap, &xhci_cap_ops, xhci,\n\"capabilities\", LEN_CAP);",
"memory_region_init_io(&xhci->mem_oper, &xhci_oper_ops, xhci,\n\"operational\", 0x400);",
"memory_region_init_io(&xhci->mem_runtime, &xhci_runtime_ops, xhci,\n\"runtime\", LEN_RUNTIME);",
"memory_region_init_io(&xhci->mem_doorbell, &xhci_doorbell_ops, xhci,\n\"doorbell\", LEN_DOORBELL);",
"memory_region_add_subregion(&xhci->mem, 0, &xhci->mem_cap);",
"memory_region_add_subregion(&xhci->mem, OFF_OPER, &xhci->mem_oper);",
"memory_region_add_subregion(&xhci->mem, OFF_RUNTIME, &xhci->mem_runtime);",
"memory_region_add_subregion(&xhci->mem, OFF_DOORBELL, &xhci->mem_doorbell);",
"for (VAR_1 = 0; VAR_1 < xhci->numports; VAR_1++) {",
"XHCIPort *port = &xhci->ports[VAR_1];",
"uint32_t offset = OFF_OPER + 0x400 + 0x10 * VAR_1;",
"port->xhci = xhci;",
"memory_region_init_io(&port->mem, &xhci_port_ops, port,\nport->name, 0x10);",
"memory_region_add_subregion(&xhci->mem, offset, &port->mem);",
"pci_register_bar(&xhci->pci_dev, 0,\nPCI_BASE_ADDRESS_SPACE_MEMORY|PCI_BASE_ADDRESS_MEM_TYPE_64,\n&xhci->mem);",
"VAR_2 = pcie_endpoint_cap_init(&xhci->pci_dev, 0xa0);",
"assert(VAR_2 >= 0);",
"if (xhci->flags & (1 << XHCI_FLAG_USE_MSI)) {",
"msi_init(&xhci->pci_dev, 0x70, xhci->numintrs, true, false);",
"if (xhci->flags & (1 << XHCI_FLAG_USE_MSI_X)) {",
"msix_init(&xhci->pci_dev, xhci->numintrs,\n&xhci->mem, 0, OFF_MSIX_TABLE,\n&xhci->mem, 0, OFF_MSIX_PBA,\n0x90);",
"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
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
27
],
[
29
],
[
35
],
[
37
],
[
40
],
[
42
],
[
45
],
[
47
],
[
52
],
[
56
],
[
60
],
[
62,
64
],
[
66,
68
],
[
70,
72
],
[
74,
76
],
[
80
],
[
82
],
[
84
],
[
86
],
[
90
],
[
92
],
[
94
],
[
96
],
[
98,
100
],
[
102
],
[
107,
109,
111
],
[
115
],
[
117
],
[
121
],
[
123
],
[
126
],
[
128,
130,
132,
134
],
[
139
]
] |
26,768 | int avformat_network_init(void)
{
#if CONFIG_NETWORK
int ret;
ff_network_inited_globally = 1;
if ((ret = ff_network_init()) < 0)
return ret;
ff_tls_init();
#endif
return 0;
}
| true | FFmpeg | 7620d48f2eab67812d8c535d12a98eaa754a1177 | int avformat_network_init(void)
{
#if CONFIG_NETWORK
int ret;
ff_network_inited_globally = 1;
if ((ret = ff_network_init()) < 0)
return ret;
ff_tls_init();
#endif
return 0;
}
| {
"code": [
" ff_tls_init();",
" ff_tls_init();"
],
"line_no": [
15,
15
]
} | int FUNC_0(void)
{
#if CONFIG_NETWORK
int ret;
ff_network_inited_globally = 1;
if ((ret = ff_network_init()) < 0)
return ret;
ff_tls_init();
#endif
return 0;
}
| [
"int FUNC_0(void)\n{",
"#if CONFIG_NETWORK\nint ret;",
"ff_network_inited_globally = 1;",
"if ((ret = ff_network_init()) < 0)\nreturn ret;",
"ff_tls_init();",
"#endif\nreturn 0;",
"}"
] | [
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
],
[
11,
13
],
[
15
],
[
17,
19
],
[
21
]
] |
26,769 | GList *range_list_insert(GList *list, Range *data)
{
GList *l, *next = NULL;
Range *r, *nextr;
if (!list) {
list = g_list_insert_sorted(list, data, range_compare);
return list;
}
nextr = data;
l = list;
while (l && l != next && nextr) {
r = l->data;
if (ranges_can_merge(r, nextr)) {
range_merge(r, nextr);
l = g_list_remove_link(l, next);
next = g_list_next(l);
if (next) {
nextr = next->data;
} else {
nextr = NULL;
}
} else {
l = g_list_next(l);
}
}
if (!l) {
list = g_list_insert_sorted(list, data, range_compare);
}
return list;
}
| true | qemu | db486cc334aafd3dbdaf107388e37fc3d6d3e171 | GList *range_list_insert(GList *list, Range *data)
{
GList *l, *next = NULL;
Range *r, *nextr;
if (!list) {
list = g_list_insert_sorted(list, data, range_compare);
return list;
}
nextr = data;
l = list;
while (l && l != next && nextr) {
r = l->data;
if (ranges_can_merge(r, nextr)) {
range_merge(r, nextr);
l = g_list_remove_link(l, next);
next = g_list_next(l);
if (next) {
nextr = next->data;
} else {
nextr = NULL;
}
} else {
l = g_list_next(l);
}
}
if (!l) {
list = g_list_insert_sorted(list, data, range_compare);
}
return list;
}
| {
"code": [
" GList *l, *next = NULL;",
" Range *r, *nextr;",
" if (!list) {",
" list = g_list_insert_sorted(list, data, range_compare);",
" return list;",
" nextr = data;",
" l = list;",
" while (l && l != next && nextr) {",
" r = l->data;",
" if (ranges_can_merge(r, nextr)) {",
" range_merge(r, nextr);",
" l = g_list_remove_link(l, next);",
" next = g_list_next(l);",
" if (next) {",
" nextr = next->data;",
" } else {",
" nextr = NULL;",
" } else {",
" l = g_list_next(l);",
" if (!l) {",
" list = g_list_insert_sorted(list, data, range_compare);"
],
"line_no": [
5,
7,
11,
13,
15,
21,
23,
25,
27,
29,
31,
33,
35,
37,
39,
41,
43,
47,
49,
57,
13
]
} | GList *FUNC_0(GList *list, Range *data)
{
GList *l, *next = NULL;
Range *r, *nextr;
if (!list) {
list = g_list_insert_sorted(list, data, range_compare);
return list;
}
nextr = data;
l = list;
while (l && l != next && nextr) {
r = l->data;
if (ranges_can_merge(r, nextr)) {
range_merge(r, nextr);
l = g_list_remove_link(l, next);
next = g_list_next(l);
if (next) {
nextr = next->data;
} else {
nextr = NULL;
}
} else {
l = g_list_next(l);
}
}
if (!l) {
list = g_list_insert_sorted(list, data, range_compare);
}
return list;
}
| [
"GList *FUNC_0(GList *list, Range *data)\n{",
"GList *l, *next = NULL;",
"Range *r, *nextr;",
"if (!list) {",
"list = g_list_insert_sorted(list, data, range_compare);",
"return list;",
"}",
"nextr = data;",
"l = list;",
"while (l && l != next && nextr) {",
"r = l->data;",
"if (ranges_can_merge(r, nextr)) {",
"range_merge(r, nextr);",
"l = g_list_remove_link(l, next);",
"next = g_list_next(l);",
"if (next) {",
"nextr = next->data;",
"} else {",
"nextr = NULL;",
"}",
"} else {",
"l = g_list_next(l);",
"}",
"}",
"if (!l) {",
"list = g_list_insert_sorted(list, data, range_compare);",
"}",
"return list;",
"}"
] | [
0,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
]
] |
26,770 | static int sab_diamond_search(MpegEncContext * s, int *best, int dmin,
int src_index, int ref_index, int const penalty_factor,
int size, int h, int flags)
{
MotionEstContext * const c= &s->me;
me_cmp_func cmpf, chroma_cmpf;
Minima minima[MAX_SAB_SIZE];
const int minima_count= FFABS(c->dia_size);
int i, j;
LOAD_COMMON
LOAD_COMMON2
int map_generation= c->map_generation;
cmpf= s->dsp.me_cmp[size];
chroma_cmpf= s->dsp.me_cmp[size+1];
for(j=i=0; i<ME_MAP_SIZE; i++){
uint32_t key= map[i];
key += (1<<(ME_MAP_MV_BITS-1)) + (1<<(2*ME_MAP_MV_BITS-1));
if((key&((-1)<<(2*ME_MAP_MV_BITS))) != map_generation) continue;
assert(j<MAX_SAB_SIZE); //max j = number of predictors
minima[j].height= score_map[i];
minima[j].x= key & ((1<<ME_MAP_MV_BITS)-1); key>>=ME_MAP_MV_BITS;
minima[j].y= key & ((1<<ME_MAP_MV_BITS)-1);
minima[j].x-= (1<<(ME_MAP_MV_BITS-1));
minima[j].y-= (1<<(ME_MAP_MV_BITS-1));
minima[j].checked=0;
if(minima[j].x || minima[j].y)
minima[j].height+= (mv_penalty[((minima[j].x)<<shift)-pred_x] + mv_penalty[((minima[j].y)<<shift)-pred_y])*penalty_factor;
j++;
}
qsort(minima, j, sizeof(Minima), minima_cmp);
for(; j<minima_count; j++){
minima[j].height=256*256*256*64;
minima[j].checked=0;
minima[j].x= minima[j].y=0;
}
for(i=0; i<minima_count; i++){
const int x= minima[i].x;
const int y= minima[i].y;
int d;
if(minima[i].checked) continue;
if( x >= xmax || x <= xmin
|| y >= ymax || y <= ymin)
continue;
SAB_CHECK_MV(x-1, y)
SAB_CHECK_MV(x+1, y)
SAB_CHECK_MV(x , y-1)
SAB_CHECK_MV(x , y+1)
minima[i].checked= 1;
}
best[0]= minima[0].x;
best[1]= minima[0].y;
dmin= minima[0].height;
if( best[0] < xmax && best[0] > xmin
&& best[1] < ymax && best[1] > ymin){
int d;
//ensure that the refernece samples for hpel refinement are in the map
CHECK_MV(best[0]-1, best[1])
CHECK_MV(best[0]+1, best[1])
CHECK_MV(best[0], best[1]-1)
CHECK_MV(best[0], best[1]+1)
}
return dmin;
}
| true | FFmpeg | 2b0cdd9ec697164ac0415b8629c4a6e5ae9a3b8d | static int sab_diamond_search(MpegEncContext * s, int *best, int dmin,
int src_index, int ref_index, int const penalty_factor,
int size, int h, int flags)
{
MotionEstContext * const c= &s->me;
me_cmp_func cmpf, chroma_cmpf;
Minima minima[MAX_SAB_SIZE];
const int minima_count= FFABS(c->dia_size);
int i, j;
LOAD_COMMON
LOAD_COMMON2
int map_generation= c->map_generation;
cmpf= s->dsp.me_cmp[size];
chroma_cmpf= s->dsp.me_cmp[size+1];
for(j=i=0; i<ME_MAP_SIZE; i++){
uint32_t key= map[i];
key += (1<<(ME_MAP_MV_BITS-1)) + (1<<(2*ME_MAP_MV_BITS-1));
if((key&((-1)<<(2*ME_MAP_MV_BITS))) != map_generation) continue;
assert(j<MAX_SAB_SIZE);
minima[j].height= score_map[i];
minima[j].x= key & ((1<<ME_MAP_MV_BITS)-1); key>>=ME_MAP_MV_BITS;
minima[j].y= key & ((1<<ME_MAP_MV_BITS)-1);
minima[j].x-= (1<<(ME_MAP_MV_BITS-1));
minima[j].y-= (1<<(ME_MAP_MV_BITS-1));
minima[j].checked=0;
if(minima[j].x || minima[j].y)
minima[j].height+= (mv_penalty[((minima[j].x)<<shift)-pred_x] + mv_penalty[((minima[j].y)<<shift)-pred_y])*penalty_factor;
j++;
}
qsort(minima, j, sizeof(Minima), minima_cmp);
for(; j<minima_count; j++){
minima[j].height=256*256*256*64;
minima[j].checked=0;
minima[j].x= minima[j].y=0;
}
for(i=0; i<minima_count; i++){
const int x= minima[i].x;
const int y= minima[i].y;
int d;
if(minima[i].checked) continue;
if( x >= xmax || x <= xmin
|| y >= ymax || y <= ymin)
continue;
SAB_CHECK_MV(x-1, y)
SAB_CHECK_MV(x+1, y)
SAB_CHECK_MV(x , y-1)
SAB_CHECK_MV(x , y+1)
minima[i].checked= 1;
}
best[0]= minima[0].x;
best[1]= minima[0].y;
dmin= minima[0].height;
if( best[0] < xmax && best[0] > xmin
&& best[1] < ymax && best[1] > ymin){
int d;
CHECK_MV(best[0]-1, best[1])
CHECK_MV(best[0]+1, best[1])
CHECK_MV(best[0], best[1]-1)
CHECK_MV(best[0], best[1]+1)
}
return dmin;
}
| {
"code": [
" for(j=i=0; i<ME_MAP_SIZE; i++){"
],
"line_no": [
33
]
} | static int FUNC_0(MpegEncContext * VAR_0, int *VAR_1, int VAR_2,
int VAR_3, int VAR_4, int const VAR_5,
int VAR_6, int VAR_7, int VAR_8)
{
MotionEstContext * const c= &VAR_0->me;
me_cmp_func cmpf, chroma_cmpf;
Minima minima[MAX_SAB_SIZE];
const int VAR_9= FFABS(c->dia_size);
int VAR_10, VAR_11;
LOAD_COMMON
LOAD_COMMON2
int map_generation= c->map_generation;
cmpf= VAR_0->dsp.me_cmp[VAR_6];
chroma_cmpf= VAR_0->dsp.me_cmp[VAR_6+1];
for(VAR_11=VAR_10=0; VAR_10<ME_MAP_SIZE; VAR_10++){
uint32_t key= map[VAR_10];
key += (1<<(ME_MAP_MV_BITS-1)) + (1<<(2*ME_MAP_MV_BITS-1));
if((key&((-1)<<(2*ME_MAP_MV_BITS))) != map_generation) continue;
assert(VAR_11<MAX_SAB_SIZE);
minima[VAR_11].height= score_map[VAR_10];
minima[VAR_11].VAR_12= key & ((1<<ME_MAP_MV_BITS)-1); key>>=ME_MAP_MV_BITS;
minima[VAR_11].VAR_13= key & ((1<<ME_MAP_MV_BITS)-1);
minima[VAR_11].VAR_12-= (1<<(ME_MAP_MV_BITS-1));
minima[VAR_11].VAR_13-= (1<<(ME_MAP_MV_BITS-1));
minima[VAR_11].checked=0;
if(minima[VAR_11].VAR_12 || minima[VAR_11].VAR_13)
minima[VAR_11].height+= (mv_penalty[((minima[VAR_11].VAR_12)<<shift)-pred_x] + mv_penalty[((minima[VAR_11].VAR_13)<<shift)-pred_y])*VAR_5;
VAR_11++;
}
qsort(minima, VAR_11, sizeof(Minima), minima_cmp);
for(; VAR_11<VAR_9; VAR_11++){
minima[VAR_11].height=256*256*256*64;
minima[VAR_11].checked=0;
minima[VAR_11].VAR_12= minima[VAR_11].VAR_13=0;
}
for(VAR_10=0; VAR_10<VAR_9; VAR_10++){
const int VAR_12= minima[VAR_10].VAR_12;
const int VAR_13= minima[VAR_10].VAR_13;
int VAR_15;
if(minima[VAR_10].checked) continue;
if( VAR_12 >= xmax || VAR_12 <= xmin
|| VAR_13 >= ymax || VAR_13 <= ymin)
continue;
SAB_CHECK_MV(VAR_12-1, VAR_13)
SAB_CHECK_MV(VAR_12+1, VAR_13)
SAB_CHECK_MV(VAR_12 , VAR_13-1)
SAB_CHECK_MV(VAR_12 , VAR_13+1)
minima[VAR_10].checked= 1;
}
VAR_1[0]= minima[0].VAR_12;
VAR_1[1]= minima[0].VAR_13;
VAR_2= minima[0].height;
if( VAR_1[0] < xmax && VAR_1[0] > xmin
&& VAR_1[1] < ymax && VAR_1[1] > ymin){
int VAR_15;
CHECK_MV(VAR_1[0]-1, VAR_1[1])
CHECK_MV(VAR_1[0]+1, VAR_1[1])
CHECK_MV(VAR_1[0], VAR_1[1]-1)
CHECK_MV(VAR_1[0], VAR_1[1]+1)
}
return VAR_2;
}
| [
"static int FUNC_0(MpegEncContext * VAR_0, int *VAR_1, int VAR_2,\nint VAR_3, int VAR_4, int const VAR_5,\nint VAR_6, int VAR_7, int VAR_8)\n{",
"MotionEstContext * const c= &VAR_0->me;",
"me_cmp_func cmpf, chroma_cmpf;",
"Minima minima[MAX_SAB_SIZE];",
"const int VAR_9= FFABS(c->dia_size);",
"int VAR_10, VAR_11;",
"LOAD_COMMON\nLOAD_COMMON2\nint map_generation= c->map_generation;",
"cmpf= VAR_0->dsp.me_cmp[VAR_6];",
"chroma_cmpf= VAR_0->dsp.me_cmp[VAR_6+1];",
"for(VAR_11=VAR_10=0; VAR_10<ME_MAP_SIZE; VAR_10++){",
"uint32_t key= map[VAR_10];",
"key += (1<<(ME_MAP_MV_BITS-1)) + (1<<(2*ME_MAP_MV_BITS-1));",
"if((key&((-1)<<(2*ME_MAP_MV_BITS))) != map_generation) continue;",
"assert(VAR_11<MAX_SAB_SIZE);",
"minima[VAR_11].height= score_map[VAR_10];",
"minima[VAR_11].VAR_12= key & ((1<<ME_MAP_MV_BITS)-1); key>>=ME_MAP_MV_BITS;",
"minima[VAR_11].VAR_13= key & ((1<<ME_MAP_MV_BITS)-1);",
"minima[VAR_11].VAR_12-= (1<<(ME_MAP_MV_BITS-1));",
"minima[VAR_11].VAR_13-= (1<<(ME_MAP_MV_BITS-1));",
"minima[VAR_11].checked=0;",
"if(minima[VAR_11].VAR_12 || minima[VAR_11].VAR_13)\nminima[VAR_11].height+= (mv_penalty[((minima[VAR_11].VAR_12)<<shift)-pred_x] + mv_penalty[((minima[VAR_11].VAR_13)<<shift)-pred_y])*VAR_5;",
"VAR_11++;",
"}",
"qsort(minima, VAR_11, sizeof(Minima), minima_cmp);",
"for(; VAR_11<VAR_9; VAR_11++){",
"minima[VAR_11].height=256*256*256*64;",
"minima[VAR_11].checked=0;",
"minima[VAR_11].VAR_12= minima[VAR_11].VAR_13=0;",
"}",
"for(VAR_10=0; VAR_10<VAR_9; VAR_10++){",
"const int VAR_12= minima[VAR_10].VAR_12;",
"const int VAR_13= minima[VAR_10].VAR_13;",
"int VAR_15;",
"if(minima[VAR_10].checked) continue;",
"if( VAR_12 >= xmax || VAR_12 <= xmin\n|| VAR_13 >= ymax || VAR_13 <= ymin)\ncontinue;",
"SAB_CHECK_MV(VAR_12-1, VAR_13)\nSAB_CHECK_MV(VAR_12+1, VAR_13)\nSAB_CHECK_MV(VAR_12 , VAR_13-1)\nSAB_CHECK_MV(VAR_12 , VAR_13+1)\nminima[VAR_10].checked= 1;",
"}",
"VAR_1[0]= minima[0].VAR_12;",
"VAR_1[1]= minima[0].VAR_13;",
"VAR_2= minima[0].height;",
"if( VAR_1[0] < xmax && VAR_1[0] > xmin\n&& VAR_1[1] < ymax && VAR_1[1] > ymin){",
"int VAR_15;",
"CHECK_MV(VAR_1[0]-1, VAR_1[1])\nCHECK_MV(VAR_1[0]+1, VAR_1[1])\nCHECK_MV(VAR_1[0], VAR_1[1]-1)\nCHECK_MV(VAR_1[0], VAR_1[1]+1)\n}",
"return VAR_2;",
"}"
] | [
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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19,
21,
23
],
[
27
],
[
29
],
[
33
],
[
35
],
[
39
],
[
43
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63,
65
],
[
69
],
[
71
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
105,
107,
109
],
[
113,
115,
117,
119,
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
137,
139
],
[
141
],
[
145,
147,
149,
151,
153
],
[
155
],
[
157
]
] |
26,771 | static void close_guest_eventfds(IVShmemState *s, int posn)
{
int i, guest_curr_max;
if (!ivshmem_has_feature(s, IVSHMEM_IOEVENTFD)) {
guest_curr_max = s->peers[posn].nb_eventfds;
memory_region_transaction_begin();
for (i = 0; i < guest_curr_max; i++) {
ivshmem_del_eventfd(s, posn, i);
memory_region_transaction_commit();
for (i = 0; i < guest_curr_max; i++) {
event_notifier_cleanup(&s->peers[posn].eventfds[i]);
g_free(s->peers[posn].eventfds);
s->peers[posn].nb_eventfds = 0;
| true | qemu | 363ba1c72fed4425e7917afc36722584aaeaad8a | static void close_guest_eventfds(IVShmemState *s, int posn)
{
int i, guest_curr_max;
if (!ivshmem_has_feature(s, IVSHMEM_IOEVENTFD)) {
guest_curr_max = s->peers[posn].nb_eventfds;
memory_region_transaction_begin();
for (i = 0; i < guest_curr_max; i++) {
ivshmem_del_eventfd(s, posn, i);
memory_region_transaction_commit();
for (i = 0; i < guest_curr_max; i++) {
event_notifier_cleanup(&s->peers[posn].eventfds[i]);
g_free(s->peers[posn].eventfds);
s->peers[posn].nb_eventfds = 0;
| {
"code": [],
"line_no": []
} | static void FUNC_0(IVShmemState *VAR_0, int VAR_1)
{
int VAR_2, VAR_3;
if (!ivshmem_has_feature(VAR_0, IVSHMEM_IOEVENTFD)) {
VAR_3 = VAR_0->peers[VAR_1].nb_eventfds;
memory_region_transaction_begin();
for (VAR_2 = 0; VAR_2 < VAR_3; VAR_2++) {
ivshmem_del_eventfd(VAR_0, VAR_1, VAR_2);
memory_region_transaction_commit();
for (VAR_2 = 0; VAR_2 < VAR_3; VAR_2++) {
event_notifier_cleanup(&VAR_0->peers[VAR_1].eventfds[VAR_2]);
g_free(VAR_0->peers[VAR_1].eventfds);
VAR_0->peers[VAR_1].nb_eventfds = 0;
| [
"static void FUNC_0(IVShmemState *VAR_0, int VAR_1)\n{",
"int VAR_2, VAR_3;",
"if (!ivshmem_has_feature(VAR_0, IVSHMEM_IOEVENTFD)) {",
"VAR_3 = VAR_0->peers[VAR_1].nb_eventfds;",
"memory_region_transaction_begin();",
"for (VAR_2 = 0; VAR_2 < VAR_3; VAR_2++) {",
"ivshmem_del_eventfd(VAR_0, VAR_1, VAR_2);",
"memory_region_transaction_commit();",
"for (VAR_2 = 0; VAR_2 < VAR_3; VAR_2++) {",
"event_notifier_cleanup(&VAR_0->peers[VAR_1].eventfds[VAR_2]);",
"g_free(VAR_0->peers[VAR_1].eventfds);",
"VAR_0->peers[VAR_1].nb_eventfds = 0;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
18
],
[
22
],
[
24
],
[
26
],
[
29
],
[
31
],
[
33
],
[
38
],
[
40
]
] |
26,772 | static int tiff_decode_tag(TiffContext *s, const uint8_t *start,
const uint8_t *buf, const uint8_t *end_buf)
{
unsigned tag, type, count, off, value = 0;
int i;
uint32_t *pal;
const uint8_t *rp, *gp, *bp;
if (end_buf - buf < 12)
return AVERROR_INVALIDDATA;
tag = tget_short(&buf, s->le);
type = tget_short(&buf, s->le);
count = tget_long(&buf, s->le);
off = tget_long(&buf, s->le);
if (type == 0 || type >= FF_ARRAY_ELEMS(type_sizes)) {
av_log(s->avctx, AV_LOG_DEBUG, "Unknown tiff type (%u) encountered\n",
type);
return 0;
}
if (count == 1) {
switch (type) {
case TIFF_BYTE:
case TIFF_SHORT:
buf -= 4;
value = tget(&buf, type, s->le);
buf = NULL;
break;
case TIFF_LONG:
value = off;
buf = NULL;
break;
case TIFF_STRING:
if (count <= 4) {
buf -= 4;
break;
}
default:
value = UINT_MAX;
buf = start + off;
}
} else {
if (count <= 4 && type_sizes[type] * count <= 4)
buf -= 4;
else
buf = start + off;
}
if (buf && (buf < start || buf > end_buf)) {
av_log(s->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return AVERROR_INVALIDDATA;
}
switch (tag) {
case TIFF_WIDTH:
s->width = value;
break;
case TIFF_HEIGHT:
s->height = value;
break;
case TIFF_BPP:
s->bppcount = count;
if (count > 4) {
av_log(s->avctx, AV_LOG_ERROR,
"This format is not supported (bpp=%d, %d components)\n",
s->bpp, count);
return AVERROR_INVALIDDATA;
}
if (count == 1)
s->bpp = value;
else {
switch (type) {
case TIFF_BYTE:
s->bpp = (off & 0xFF) + ((off >> 8) & 0xFF) +
((off >> 16) & 0xFF) + ((off >> 24) & 0xFF);
break;
case TIFF_SHORT:
case TIFF_LONG:
s->bpp = 0;
for (i = 0; i < count && buf < end_buf; i++)
s->bpp += tget(&buf, type, s->le);
break;
default:
s->bpp = -1;
}
}
break;
case TIFF_SAMPLES_PER_PIXEL:
if (count != 1) {
av_log(s->avctx, AV_LOG_ERROR,
"Samples per pixel requires a single value, many provided\n");
return AVERROR_INVALIDDATA;
}
if (s->bppcount == 1)
s->bpp *= value;
s->bppcount = value;
break;
case TIFF_COMPR:
s->compr = value;
s->predictor = 0;
switch (s->compr) {
case TIFF_RAW:
case TIFF_PACKBITS:
case TIFF_LZW:
case TIFF_CCITT_RLE:
break;
case TIFF_G3:
case TIFF_G4:
s->fax_opts = 0;
break;
case TIFF_DEFLATE:
case TIFF_ADOBE_DEFLATE:
#if CONFIG_ZLIB
break;
#else
av_log(s->avctx, AV_LOG_ERROR, "Deflate: ZLib not compiled in\n");
return AVERROR(ENOSYS);
#endif
case TIFF_JPEG:
case TIFF_NEWJPEG:
avpriv_report_missing_feature(s->avctx, "JPEG compression");
return AVERROR_PATCHWELCOME;
default:
av_log(s->avctx, AV_LOG_ERROR, "Unknown compression method %i\n",
s->compr);
return AVERROR_INVALIDDATA;
}
break;
case TIFF_ROWSPERSTRIP:
if (type == TIFF_LONG && value == UINT_MAX)
value = s->avctx->height;
if (value < 1) {
av_log(s->avctx, AV_LOG_ERROR,
"Incorrect value of rows per strip\n");
return AVERROR_INVALIDDATA;
}
s->rps = value;
break;
case TIFF_STRIP_OFFS:
if (count == 1) {
s->stripdata = NULL;
s->stripoff = value;
} else
s->stripdata = start + off;
s->strips = count;
if (s->strips == 1)
s->rps = s->height;
s->sot = type;
if (s->stripdata > end_buf) {
av_log(s->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return AVERROR_INVALIDDATA;
}
break;
case TIFF_STRIP_SIZE:
if (count == 1) {
s->stripsizes = NULL;
s->stripsize = value;
s->strips = 1;
} else {
s->stripsizes = start + off;
}
s->strips = count;
s->sstype = type;
if (s->stripsizes > end_buf) {
av_log(s->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return AVERROR_INVALIDDATA;
}
break;
case TIFF_PREDICTOR:
s->predictor = value;
break;
case TIFF_INVERT:
switch (value) {
case 0:
s->invert = 1;
break;
case 1:
s->invert = 0;
break;
case 2:
case 3:
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Color mode %d is not supported\n",
value);
return AVERROR_INVALIDDATA;
}
break;
case TIFF_FILL_ORDER:
if (value < 1 || value > 2) {
av_log(s->avctx, AV_LOG_ERROR,
"Unknown FillOrder value %d, trying default one\n", value);
value = 1;
}
s->fill_order = value - 1;
break;
case TIFF_PAL:
pal = (uint32_t *) s->palette;
off = type_sizes[type];
if (count / 3 > 256 || end_buf - buf < count / 3 * off * 3)
return AVERROR_INVALIDDATA;
rp = buf;
gp = buf + count / 3 * off;
bp = buf + count / 3 * off * 2;
off = (type_sizes[type] - 1) << 3;
for (i = 0; i < count / 3; i++) {
uint32_t p = 0xFF000000;
p |= (tget(&rp, type, s->le) >> off) << 16;
p |= (tget(&gp, type, s->le) >> off) << 8;
p |= tget(&bp, type, s->le) >> off;
pal[i] = p;
}
s->palette_is_set = 1;
break;
case TIFF_PLANAR:
if (value == 2) {
avpriv_report_missing_feature(s->avctx, "Planar format");
return AVERROR_PATCHWELCOME;
}
break;
case TIFF_T4OPTIONS:
if (s->compr == TIFF_G3)
s->fax_opts = value;
break;
case TIFF_T6OPTIONS:
if (s->compr == TIFF_G4)
s->fax_opts = value;
break;
default:
if (s->avctx->err_recognition & AV_EF_EXPLODE) {
av_log(s->avctx, AV_LOG_ERROR,
"Unknown or unsupported tag %d/0X%0X\n",
tag, tag);
return AVERROR_INVALIDDATA;
}
}
return 0;
}
| true | FFmpeg | 0a467a9b594dd67aa96bad687d05f8845b009f18 | static int tiff_decode_tag(TiffContext *s, const uint8_t *start,
const uint8_t *buf, const uint8_t *end_buf)
{
unsigned tag, type, count, off, value = 0;
int i;
uint32_t *pal;
const uint8_t *rp, *gp, *bp;
if (end_buf - buf < 12)
return AVERROR_INVALIDDATA;
tag = tget_short(&buf, s->le);
type = tget_short(&buf, s->le);
count = tget_long(&buf, s->le);
off = tget_long(&buf, s->le);
if (type == 0 || type >= FF_ARRAY_ELEMS(type_sizes)) {
av_log(s->avctx, AV_LOG_DEBUG, "Unknown tiff type (%u) encountered\n",
type);
return 0;
}
if (count == 1) {
switch (type) {
case TIFF_BYTE:
case TIFF_SHORT:
buf -= 4;
value = tget(&buf, type, s->le);
buf = NULL;
break;
case TIFF_LONG:
value = off;
buf = NULL;
break;
case TIFF_STRING:
if (count <= 4) {
buf -= 4;
break;
}
default:
value = UINT_MAX;
buf = start + off;
}
} else {
if (count <= 4 && type_sizes[type] * count <= 4)
buf -= 4;
else
buf = start + off;
}
if (buf && (buf < start || buf > end_buf)) {
av_log(s->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return AVERROR_INVALIDDATA;
}
switch (tag) {
case TIFF_WIDTH:
s->width = value;
break;
case TIFF_HEIGHT:
s->height = value;
break;
case TIFF_BPP:
s->bppcount = count;
if (count > 4) {
av_log(s->avctx, AV_LOG_ERROR,
"This format is not supported (bpp=%d, %d components)\n",
s->bpp, count);
return AVERROR_INVALIDDATA;
}
if (count == 1)
s->bpp = value;
else {
switch (type) {
case TIFF_BYTE:
s->bpp = (off & 0xFF) + ((off >> 8) & 0xFF) +
((off >> 16) & 0xFF) + ((off >> 24) & 0xFF);
break;
case TIFF_SHORT:
case TIFF_LONG:
s->bpp = 0;
for (i = 0; i < count && buf < end_buf; i++)
s->bpp += tget(&buf, type, s->le);
break;
default:
s->bpp = -1;
}
}
break;
case TIFF_SAMPLES_PER_PIXEL:
if (count != 1) {
av_log(s->avctx, AV_LOG_ERROR,
"Samples per pixel requires a single value, many provided\n");
return AVERROR_INVALIDDATA;
}
if (s->bppcount == 1)
s->bpp *= value;
s->bppcount = value;
break;
case TIFF_COMPR:
s->compr = value;
s->predictor = 0;
switch (s->compr) {
case TIFF_RAW:
case TIFF_PACKBITS:
case TIFF_LZW:
case TIFF_CCITT_RLE:
break;
case TIFF_G3:
case TIFF_G4:
s->fax_opts = 0;
break;
case TIFF_DEFLATE:
case TIFF_ADOBE_DEFLATE:
#if CONFIG_ZLIB
break;
#else
av_log(s->avctx, AV_LOG_ERROR, "Deflate: ZLib not compiled in\n");
return AVERROR(ENOSYS);
#endif
case TIFF_JPEG:
case TIFF_NEWJPEG:
avpriv_report_missing_feature(s->avctx, "JPEG compression");
return AVERROR_PATCHWELCOME;
default:
av_log(s->avctx, AV_LOG_ERROR, "Unknown compression method %i\n",
s->compr);
return AVERROR_INVALIDDATA;
}
break;
case TIFF_ROWSPERSTRIP:
if (type == TIFF_LONG && value == UINT_MAX)
value = s->avctx->height;
if (value < 1) {
av_log(s->avctx, AV_LOG_ERROR,
"Incorrect value of rows per strip\n");
return AVERROR_INVALIDDATA;
}
s->rps = value;
break;
case TIFF_STRIP_OFFS:
if (count == 1) {
s->stripdata = NULL;
s->stripoff = value;
} else
s->stripdata = start + off;
s->strips = count;
if (s->strips == 1)
s->rps = s->height;
s->sot = type;
if (s->stripdata > end_buf) {
av_log(s->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return AVERROR_INVALIDDATA;
}
break;
case TIFF_STRIP_SIZE:
if (count == 1) {
s->stripsizes = NULL;
s->stripsize = value;
s->strips = 1;
} else {
s->stripsizes = start + off;
}
s->strips = count;
s->sstype = type;
if (s->stripsizes > end_buf) {
av_log(s->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return AVERROR_INVALIDDATA;
}
break;
case TIFF_PREDICTOR:
s->predictor = value;
break;
case TIFF_INVERT:
switch (value) {
case 0:
s->invert = 1;
break;
case 1:
s->invert = 0;
break;
case 2:
case 3:
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Color mode %d is not supported\n",
value);
return AVERROR_INVALIDDATA;
}
break;
case TIFF_FILL_ORDER:
if (value < 1 || value > 2) {
av_log(s->avctx, AV_LOG_ERROR,
"Unknown FillOrder value %d, trying default one\n", value);
value = 1;
}
s->fill_order = value - 1;
break;
case TIFF_PAL:
pal = (uint32_t *) s->palette;
off = type_sizes[type];
if (count / 3 > 256 || end_buf - buf < count / 3 * off * 3)
return AVERROR_INVALIDDATA;
rp = buf;
gp = buf + count / 3 * off;
bp = buf + count / 3 * off * 2;
off = (type_sizes[type] - 1) << 3;
for (i = 0; i < count / 3; i++) {
uint32_t p = 0xFF000000;
p |= (tget(&rp, type, s->le) >> off) << 16;
p |= (tget(&gp, type, s->le) >> off) << 8;
p |= tget(&bp, type, s->le) >> off;
pal[i] = p;
}
s->palette_is_set = 1;
break;
case TIFF_PLANAR:
if (value == 2) {
avpriv_report_missing_feature(s->avctx, "Planar format");
return AVERROR_PATCHWELCOME;
}
break;
case TIFF_T4OPTIONS:
if (s->compr == TIFF_G3)
s->fax_opts = value;
break;
case TIFF_T6OPTIONS:
if (s->compr == TIFF_G4)
s->fax_opts = value;
break;
default:
if (s->avctx->err_recognition & AV_EF_EXPLODE) {
av_log(s->avctx, AV_LOG_ERROR,
"Unknown or unsupported tag %d/0X%0X\n",
tag, tag);
return AVERROR_INVALIDDATA;
}
}
return 0;
}
| {
"code": [
" default:",
" return AVERROR_INVALIDDATA;",
" case TIFF_LZW:",
" break;",
"static int tiff_decode_tag(TiffContext *s, const uint8_t *start,",
" const uint8_t *buf, const uint8_t *end_buf)",
" int i;",
" const uint8_t *rp, *gp, *bp;",
" if (end_buf - buf < 12)",
" tag = tget_short(&buf, s->le);",
" type = tget_short(&buf, s->le);",
" count = tget_long(&buf, s->le);",
" off = tget_long(&buf, s->le);",
" buf -= 4;",
" value = tget(&buf, type, s->le);",
" buf = NULL;",
" buf = NULL;",
" buf -= 4;",
" buf = start + off;",
" buf -= 4;",
" buf = start + off;",
" if (buf && (buf < start || buf > end_buf)) {",
" av_log(s->avctx, AV_LOG_ERROR,",
" \"Tag referencing position outside the image\\n\");",
" return AVERROR_INVALIDDATA;",
" for (i = 0; i < count && buf < end_buf; i++)",
" s->bpp += tget(&buf, type, s->le);",
" s->stripdata = NULL;",
" s->stripoff = value;",
" s->stripdata = start + off;",
" if (s->stripdata > end_buf) {",
" av_log(s->avctx, AV_LOG_ERROR,",
" \"Tag referencing position outside the image\\n\");",
" return AVERROR_INVALIDDATA;",
" s->stripsizes = NULL;",
" s->stripsize = value;",
" s->strips = 1;",
" s->stripsizes = start + off;",
" if (s->stripsizes > end_buf) {",
" av_log(s->avctx, AV_LOG_ERROR,",
" \"Tag referencing position outside the image\\n\");",
" return AVERROR_INVALIDDATA;",
" case TIFF_PAL:",
" if (count / 3 > 256 || end_buf - buf < count / 3 * off * 3)",
" rp = buf;",
" gp = buf + count / 3 * off;",
" bp = buf + count / 3 * off * 2;",
" p |= (tget(&rp, type, s->le) >> off) << 16;",
" p |= (tget(&gp, type, s->le) >> off) << 8;",
" p |= tget(&bp, type, s->le) >> off;",
" } else",
" } else"
],
"line_no": [
465,
137,
211,
57,
1,
3,
9,
13,
17,
21,
23,
25,
27,
51,
53,
55,
55,
71,
81,
89,
93,
99,
101,
103,
19,
163,
165,
285,
287,
291,
301,
131,
305,
137,
317,
319,
321,
325,
333,
131,
305,
137,
401,
407,
411,
413,
415,
423,
425,
427,
289,
289
]
} | static int FUNC_0(TiffContext *VAR_0, const uint8_t *VAR_1,
const uint8_t *VAR_2, const uint8_t *VAR_3)
{
unsigned VAR_4, VAR_5, VAR_6, VAR_7, VAR_8 = 0;
int VAR_9;
uint32_t *pal;
const uint8_t *VAR_10, *gp, *bp;
if (VAR_3 - VAR_2 < 12)
return AVERROR_INVALIDDATA;
VAR_4 = tget_short(&VAR_2, VAR_0->le);
VAR_5 = tget_short(&VAR_2, VAR_0->le);
VAR_6 = tget_long(&VAR_2, VAR_0->le);
VAR_7 = tget_long(&VAR_2, VAR_0->le);
if (VAR_5 == 0 || VAR_5 >= FF_ARRAY_ELEMS(type_sizes)) {
av_log(VAR_0->avctx, AV_LOG_DEBUG, "Unknown tiff VAR_5 (%u) encountered\n",
VAR_5);
return 0;
}
if (VAR_6 == 1) {
switch (VAR_5) {
case TIFF_BYTE:
case TIFF_SHORT:
VAR_2 -= 4;
VAR_8 = tget(&VAR_2, VAR_5, VAR_0->le);
VAR_2 = NULL;
break;
case TIFF_LONG:
VAR_8 = VAR_7;
VAR_2 = NULL;
break;
case TIFF_STRING:
if (VAR_6 <= 4) {
VAR_2 -= 4;
break;
}
default:
VAR_8 = UINT_MAX;
VAR_2 = VAR_1 + VAR_7;
}
} else {
if (VAR_6 <= 4 && type_sizes[VAR_5] * VAR_6 <= 4)
VAR_2 -= 4;
else
VAR_2 = VAR_1 + VAR_7;
}
if (VAR_2 && (VAR_2 < VAR_1 || VAR_2 > VAR_3)) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return AVERROR_INVALIDDATA;
}
switch (VAR_4) {
case TIFF_WIDTH:
VAR_0->width = VAR_8;
break;
case TIFF_HEIGHT:
VAR_0->height = VAR_8;
break;
case TIFF_BPP:
VAR_0->bppcount = VAR_6;
if (VAR_6 > 4) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"This format is not supported (bpp=%d, %d components)\n",
VAR_0->bpp, VAR_6);
return AVERROR_INVALIDDATA;
}
if (VAR_6 == 1)
VAR_0->bpp = VAR_8;
else {
switch (VAR_5) {
case TIFF_BYTE:
VAR_0->bpp = (VAR_7 & 0xFF) + ((VAR_7 >> 8) & 0xFF) +
((VAR_7 >> 16) & 0xFF) + ((VAR_7 >> 24) & 0xFF);
break;
case TIFF_SHORT:
case TIFF_LONG:
VAR_0->bpp = 0;
for (VAR_9 = 0; VAR_9 < VAR_6 && VAR_2 < VAR_3; VAR_9++)
VAR_0->bpp += tget(&VAR_2, VAR_5, VAR_0->le);
break;
default:
VAR_0->bpp = -1;
}
}
break;
case TIFF_SAMPLES_PER_PIXEL:
if (VAR_6 != 1) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Samples per pixel requires a single VAR_8, many provided\n");
return AVERROR_INVALIDDATA;
}
if (VAR_0->bppcount == 1)
VAR_0->bpp *= VAR_8;
VAR_0->bppcount = VAR_8;
break;
case TIFF_COMPR:
VAR_0->compr = VAR_8;
VAR_0->predictor = 0;
switch (VAR_0->compr) {
case TIFF_RAW:
case TIFF_PACKBITS:
case TIFF_LZW:
case TIFF_CCITT_RLE:
break;
case TIFF_G3:
case TIFF_G4:
VAR_0->fax_opts = 0;
break;
case TIFF_DEFLATE:
case TIFF_ADOBE_DEFLATE:
#if CONFIG_ZLIB
break;
#else
av_log(VAR_0->avctx, AV_LOG_ERROR, "Deflate: ZLib not compiled in\n");
return AVERROR(ENOSYS);
#endif
case TIFF_JPEG:
case TIFF_NEWJPEG:
avpriv_report_missing_feature(VAR_0->avctx, "JPEG compression");
return AVERROR_PATCHWELCOME;
default:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Unknown compression method %VAR_9\n",
VAR_0->compr);
return AVERROR_INVALIDDATA;
}
break;
case TIFF_ROWSPERSTRIP:
if (VAR_5 == TIFF_LONG && VAR_8 == UINT_MAX)
VAR_8 = VAR_0->avctx->height;
if (VAR_8 < 1) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Incorrect VAR_8 of rows per strip\n");
return AVERROR_INVALIDDATA;
}
VAR_0->rps = VAR_8;
break;
case TIFF_STRIP_OFFS:
if (VAR_6 == 1) {
VAR_0->stripdata = NULL;
VAR_0->stripoff = VAR_8;
} else
VAR_0->stripdata = VAR_1 + VAR_7;
VAR_0->strips = VAR_6;
if (VAR_0->strips == 1)
VAR_0->rps = VAR_0->height;
VAR_0->sot = VAR_5;
if (VAR_0->stripdata > VAR_3) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return AVERROR_INVALIDDATA;
}
break;
case TIFF_STRIP_SIZE:
if (VAR_6 == 1) {
VAR_0->stripsizes = NULL;
VAR_0->stripsize = VAR_8;
VAR_0->strips = 1;
} else {
VAR_0->stripsizes = VAR_1 + VAR_7;
}
VAR_0->strips = VAR_6;
VAR_0->sstype = VAR_5;
if (VAR_0->stripsizes > VAR_3) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return AVERROR_INVALIDDATA;
}
break;
case TIFF_PREDICTOR:
VAR_0->predictor = VAR_8;
break;
case TIFF_INVERT:
switch (VAR_8) {
case 0:
VAR_0->invert = 1;
break;
case 1:
VAR_0->invert = 0;
break;
case 2:
case 3:
break;
default:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Color mode %d is not supported\n",
VAR_8);
return AVERROR_INVALIDDATA;
}
break;
case TIFF_FILL_ORDER:
if (VAR_8 < 1 || VAR_8 > 2) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Unknown FillOrder VAR_8 %d, trying default one\n", VAR_8);
VAR_8 = 1;
}
VAR_0->fill_order = VAR_8 - 1;
break;
case TIFF_PAL:
pal = (uint32_t *) VAR_0->palette;
VAR_7 = type_sizes[VAR_5];
if (VAR_6 / 3 > 256 || VAR_3 - VAR_2 < VAR_6 / 3 * VAR_7 * 3)
return AVERROR_INVALIDDATA;
VAR_10 = VAR_2;
gp = VAR_2 + VAR_6 / 3 * VAR_7;
bp = VAR_2 + VAR_6 / 3 * VAR_7 * 2;
VAR_7 = (type_sizes[VAR_5] - 1) << 3;
for (VAR_9 = 0; VAR_9 < VAR_6 / 3; VAR_9++) {
uint32_t p = 0xFF000000;
p |= (tget(&VAR_10, VAR_5, VAR_0->le) >> VAR_7) << 16;
p |= (tget(&gp, VAR_5, VAR_0->le) >> VAR_7) << 8;
p |= tget(&bp, VAR_5, VAR_0->le) >> VAR_7;
pal[VAR_9] = p;
}
VAR_0->palette_is_set = 1;
break;
case TIFF_PLANAR:
if (VAR_8 == 2) {
avpriv_report_missing_feature(VAR_0->avctx, "Planar format");
return AVERROR_PATCHWELCOME;
}
break;
case TIFF_T4OPTIONS:
if (VAR_0->compr == TIFF_G3)
VAR_0->fax_opts = VAR_8;
break;
case TIFF_T6OPTIONS:
if (VAR_0->compr == TIFF_G4)
VAR_0->fax_opts = VAR_8;
break;
default:
if (VAR_0->avctx->err_recognition & AV_EF_EXPLODE) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Unknown or unsupported VAR_4 %d/0X%0X\n",
VAR_4, VAR_4);
return AVERROR_INVALIDDATA;
}
}
return 0;
}
| [
"static int FUNC_0(TiffContext *VAR_0, const uint8_t *VAR_1,\nconst uint8_t *VAR_2, const uint8_t *VAR_3)\n{",
"unsigned VAR_4, VAR_5, VAR_6, VAR_7, VAR_8 = 0;",
"int VAR_9;",
"uint32_t *pal;",
"const uint8_t *VAR_10, *gp, *bp;",
"if (VAR_3 - VAR_2 < 12)\nreturn AVERROR_INVALIDDATA;",
"VAR_4 = tget_short(&VAR_2, VAR_0->le);",
"VAR_5 = tget_short(&VAR_2, VAR_0->le);",
"VAR_6 = tget_long(&VAR_2, VAR_0->le);",
"VAR_7 = tget_long(&VAR_2, VAR_0->le);",
"if (VAR_5 == 0 || VAR_5 >= FF_ARRAY_ELEMS(type_sizes)) {",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Unknown tiff VAR_5 (%u) encountered\\n\",\nVAR_5);",
"return 0;",
"}",
"if (VAR_6 == 1) {",
"switch (VAR_5) {",
"case TIFF_BYTE:\ncase TIFF_SHORT:\nVAR_2 -= 4;",
"VAR_8 = tget(&VAR_2, VAR_5, VAR_0->le);",
"VAR_2 = NULL;",
"break;",
"case TIFF_LONG:\nVAR_8 = VAR_7;",
"VAR_2 = NULL;",
"break;",
"case TIFF_STRING:\nif (VAR_6 <= 4) {",
"VAR_2 -= 4;",
"break;",
"}",
"default:\nVAR_8 = UINT_MAX;",
"VAR_2 = VAR_1 + VAR_7;",
"}",
"} else {",
"if (VAR_6 <= 4 && type_sizes[VAR_5] * VAR_6 <= 4)\nVAR_2 -= 4;",
"else\nVAR_2 = VAR_1 + VAR_7;",
"}",
"if (VAR_2 && (VAR_2 < VAR_1 || VAR_2 > VAR_3)) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Tag referencing position outside the image\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"switch (VAR_4) {",
"case TIFF_WIDTH:\nVAR_0->width = VAR_8;",
"break;",
"case TIFF_HEIGHT:\nVAR_0->height = VAR_8;",
"break;",
"case TIFF_BPP:\nVAR_0->bppcount = VAR_6;",
"if (VAR_6 > 4) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"This format is not supported (bpp=%d, %d components)\\n\",\nVAR_0->bpp, VAR_6);",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_6 == 1)\nVAR_0->bpp = VAR_8;",
"else {",
"switch (VAR_5) {",
"case TIFF_BYTE:\nVAR_0->bpp = (VAR_7 & 0xFF) + ((VAR_7 >> 8) & 0xFF) +\n((VAR_7 >> 16) & 0xFF) + ((VAR_7 >> 24) & 0xFF);",
"break;",
"case TIFF_SHORT:\ncase TIFF_LONG:\nVAR_0->bpp = 0;",
"for (VAR_9 = 0; VAR_9 < VAR_6 && VAR_2 < VAR_3; VAR_9++)",
"VAR_0->bpp += tget(&VAR_2, VAR_5, VAR_0->le);",
"break;",
"default:\nVAR_0->bpp = -1;",
"}",
"}",
"break;",
"case TIFF_SAMPLES_PER_PIXEL:\nif (VAR_6 != 1) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Samples per pixel requires a single VAR_8, many provided\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_0->bppcount == 1)\nVAR_0->bpp *= VAR_8;",
"VAR_0->bppcount = VAR_8;",
"break;",
"case TIFF_COMPR:\nVAR_0->compr = VAR_8;",
"VAR_0->predictor = 0;",
"switch (VAR_0->compr) {",
"case TIFF_RAW:\ncase TIFF_PACKBITS:\ncase TIFF_LZW:\ncase TIFF_CCITT_RLE:\nbreak;",
"case TIFF_G3:\ncase TIFF_G4:\nVAR_0->fax_opts = 0;",
"break;",
"case TIFF_DEFLATE:\ncase TIFF_ADOBE_DEFLATE:\n#if CONFIG_ZLIB\nbreak;",
"#else\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Deflate: ZLib not compiled in\\n\");",
"return AVERROR(ENOSYS);",
"#endif\ncase TIFF_JPEG:\ncase TIFF_NEWJPEG:\navpriv_report_missing_feature(VAR_0->avctx, \"JPEG compression\");",
"return AVERROR_PATCHWELCOME;",
"default:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Unknown compression method %VAR_9\\n\",\nVAR_0->compr);",
"return AVERROR_INVALIDDATA;",
"}",
"break;",
"case TIFF_ROWSPERSTRIP:\nif (VAR_5 == TIFF_LONG && VAR_8 == UINT_MAX)\nVAR_8 = VAR_0->avctx->height;",
"if (VAR_8 < 1) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Incorrect VAR_8 of rows per strip\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_0->rps = VAR_8;",
"break;",
"case TIFF_STRIP_OFFS:\nif (VAR_6 == 1) {",
"VAR_0->stripdata = NULL;",
"VAR_0->stripoff = VAR_8;",
"} else",
"VAR_0->stripdata = VAR_1 + VAR_7;",
"VAR_0->strips = VAR_6;",
"if (VAR_0->strips == 1)\nVAR_0->rps = VAR_0->height;",
"VAR_0->sot = VAR_5;",
"if (VAR_0->stripdata > VAR_3) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Tag referencing position outside the image\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"break;",
"case TIFF_STRIP_SIZE:\nif (VAR_6 == 1) {",
"VAR_0->stripsizes = NULL;",
"VAR_0->stripsize = VAR_8;",
"VAR_0->strips = 1;",
"} else {",
"VAR_0->stripsizes = VAR_1 + VAR_7;",
"}",
"VAR_0->strips = VAR_6;",
"VAR_0->sstype = VAR_5;",
"if (VAR_0->stripsizes > VAR_3) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Tag referencing position outside the image\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"break;",
"case TIFF_PREDICTOR:\nVAR_0->predictor = VAR_8;",
"break;",
"case TIFF_INVERT:\nswitch (VAR_8) {",
"case 0:\nVAR_0->invert = 1;",
"break;",
"case 1:\nVAR_0->invert = 0;",
"break;",
"case 2:\ncase 3:\nbreak;",
"default:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Color mode %d is not supported\\n\",\nVAR_8);",
"return AVERROR_INVALIDDATA;",
"}",
"break;",
"case TIFF_FILL_ORDER:\nif (VAR_8 < 1 || VAR_8 > 2) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Unknown FillOrder VAR_8 %d, trying default one\\n\", VAR_8);",
"VAR_8 = 1;",
"}",
"VAR_0->fill_order = VAR_8 - 1;",
"break;",
"case TIFF_PAL:\npal = (uint32_t *) VAR_0->palette;",
"VAR_7 = type_sizes[VAR_5];",
"if (VAR_6 / 3 > 256 || VAR_3 - VAR_2 < VAR_6 / 3 * VAR_7 * 3)\nreturn AVERROR_INVALIDDATA;",
"VAR_10 = VAR_2;",
"gp = VAR_2 + VAR_6 / 3 * VAR_7;",
"bp = VAR_2 + VAR_6 / 3 * VAR_7 * 2;",
"VAR_7 = (type_sizes[VAR_5] - 1) << 3;",
"for (VAR_9 = 0; VAR_9 < VAR_6 / 3; VAR_9++) {",
"uint32_t p = 0xFF000000;",
"p |= (tget(&VAR_10, VAR_5, VAR_0->le) >> VAR_7) << 16;",
"p |= (tget(&gp, VAR_5, VAR_0->le) >> VAR_7) << 8;",
"p |= tget(&bp, VAR_5, VAR_0->le) >> VAR_7;",
"pal[VAR_9] = p;",
"}",
"VAR_0->palette_is_set = 1;",
"break;",
"case TIFF_PLANAR:\nif (VAR_8 == 2) {",
"avpriv_report_missing_feature(VAR_0->avctx, \"Planar format\");",
"return AVERROR_PATCHWELCOME;",
"}",
"break;",
"case TIFF_T4OPTIONS:\nif (VAR_0->compr == TIFF_G3)\nVAR_0->fax_opts = VAR_8;",
"break;",
"case TIFF_T6OPTIONS:\nif (VAR_0->compr == TIFF_G4)\nVAR_0->fax_opts = VAR_8;",
"break;",
"default:\nif (VAR_0->avctx->err_recognition & AV_EF_EXPLODE) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Unknown or unsupported VAR_4 %d/0X%0X\\n\",\nVAR_4, VAR_4);",
"return AVERROR_INVALIDDATA;",
"}",
"}",
"return 0;",
"}"
] | [
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
1,
0,
0,
0,
1,
0,
0,
1,
1,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
1,
0,
0,
0,
1,
1,
0,
0,
0,
0,
1,
1,
1,
0,
1,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
1,
1,
1,
0,
0,
0,
1,
1,
1,
0,
0,
0,
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
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47,
49,
51
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
85
],
[
87,
89
],
[
91,
93
],
[
95
],
[
99
],
[
101,
103
],
[
105
],
[
107
],
[
111
],
[
113,
115
],
[
117
],
[
119,
121
],
[
123
],
[
125,
127
],
[
129
],
[
131,
133,
135
],
[
137
],
[
139
],
[
141,
143
],
[
145
],
[
147
],
[
149,
151,
153
],
[
155
],
[
157,
159,
161
],
[
163
],
[
165
],
[
167
],
[
169,
171
],
[
173
],
[
175
],
[
177
],
[
179,
181
],
[
183,
185
],
[
187
],
[
189
],
[
191,
193
],
[
195
],
[
197
],
[
199,
201
],
[
203
],
[
205
],
[
207,
209,
211,
213,
215
],
[
217,
219,
221
],
[
223
],
[
225,
227,
229,
231
],
[
233,
235
],
[
237
],
[
239,
241,
243,
245
],
[
247
],
[
249,
251,
253
],
[
255
],
[
257
],
[
259
],
[
261,
263,
265
],
[
267
],
[
269,
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281,
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295,
297
],
[
299
],
[
301
],
[
303,
305
],
[
307
],
[
309
],
[
311
],
[
313,
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335,
337
],
[
339
],
[
341
],
[
343
],
[
345,
347
],
[
349
],
[
351,
353
],
[
355,
357
],
[
359
],
[
361,
363
],
[
365
],
[
367,
369,
371
],
[
373,
375,
377
],
[
379
],
[
381
],
[
383
],
[
385,
387
],
[
389,
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401,
403
],
[
405
],
[
407,
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
435
],
[
437,
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
449,
451,
453
],
[
455
],
[
457,
459,
461
],
[
463
],
[
465,
467
],
[
469,
471,
473
],
[
475
],
[
477
],
[
479
],
[
481
],
[
483
]
] |
26,773 | static int read_packet(AVFormatContext *s,
AVPacket *pkt)
{
MmDemuxContext *mm = s->priv_data;
AVIOContext *pb = s->pb;
unsigned char preamble[MM_PREAMBLE_SIZE];
unsigned int type, length;
while(1) {
if (avio_read(pb, preamble, MM_PREAMBLE_SIZE) != MM_PREAMBLE_SIZE) {
return AVERROR(EIO);
}
type = AV_RL16(&preamble[0]);
length = AV_RL16(&preamble[2]);
switch(type) {
case MM_TYPE_PALETTE :
case MM_TYPE_INTER :
case MM_TYPE_INTRA :
case MM_TYPE_INTRA_HH :
case MM_TYPE_INTER_HH :
case MM_TYPE_INTRA_HHV :
case MM_TYPE_INTER_HHV :
/* output preamble + data */
if (av_new_packet(pkt, length + MM_PREAMBLE_SIZE))
return AVERROR(ENOMEM);
memcpy(pkt->data, preamble, MM_PREAMBLE_SIZE);
if (avio_read(pb, pkt->data + MM_PREAMBLE_SIZE, length) != length)
return AVERROR(EIO);
pkt->size = length + MM_PREAMBLE_SIZE;
pkt->stream_index = 0;
pkt->pts = mm->video_pts;
if (type!=MM_TYPE_PALETTE)
mm->video_pts++;
return 0;
case MM_TYPE_AUDIO :
if (av_get_packet(s->pb, pkt, length)<0)
return AVERROR(ENOMEM);
pkt->size = length;
pkt->stream_index = 1;
pkt->pts = mm->audio_pts++;
return 0;
default :
av_log(s, AV_LOG_INFO, "unknown chunk type 0x%x\n", type);
avio_skip(pb, length);
}
}
}
| false | FFmpeg | 0c97fd336e17535239ab44d755a0d957dc2688f3 | static int read_packet(AVFormatContext *s,
AVPacket *pkt)
{
MmDemuxContext *mm = s->priv_data;
AVIOContext *pb = s->pb;
unsigned char preamble[MM_PREAMBLE_SIZE];
unsigned int type, length;
while(1) {
if (avio_read(pb, preamble, MM_PREAMBLE_SIZE) != MM_PREAMBLE_SIZE) {
return AVERROR(EIO);
}
type = AV_RL16(&preamble[0]);
length = AV_RL16(&preamble[2]);
switch(type) {
case MM_TYPE_PALETTE :
case MM_TYPE_INTER :
case MM_TYPE_INTRA :
case MM_TYPE_INTRA_HH :
case MM_TYPE_INTER_HH :
case MM_TYPE_INTRA_HHV :
case MM_TYPE_INTER_HHV :
if (av_new_packet(pkt, length + MM_PREAMBLE_SIZE))
return AVERROR(ENOMEM);
memcpy(pkt->data, preamble, MM_PREAMBLE_SIZE);
if (avio_read(pb, pkt->data + MM_PREAMBLE_SIZE, length) != length)
return AVERROR(EIO);
pkt->size = length + MM_PREAMBLE_SIZE;
pkt->stream_index = 0;
pkt->pts = mm->video_pts;
if (type!=MM_TYPE_PALETTE)
mm->video_pts++;
return 0;
case MM_TYPE_AUDIO :
if (av_get_packet(s->pb, pkt, length)<0)
return AVERROR(ENOMEM);
pkt->size = length;
pkt->stream_index = 1;
pkt->pts = mm->audio_pts++;
return 0;
default :
av_log(s, AV_LOG_INFO, "unknown chunk type 0x%x\n", type);
avio_skip(pb, length);
}
}
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0,
AVPacket *VAR_1)
{
MmDemuxContext *mm = VAR_0->priv_data;
AVIOContext *pb = VAR_0->pb;
unsigned char VAR_2[MM_PREAMBLE_SIZE];
unsigned int VAR_3, VAR_4;
while(1) {
if (avio_read(pb, VAR_2, MM_PREAMBLE_SIZE) != MM_PREAMBLE_SIZE) {
return AVERROR(EIO);
}
VAR_3 = AV_RL16(&VAR_2[0]);
VAR_4 = AV_RL16(&VAR_2[2]);
switch(VAR_3) {
case MM_TYPE_PALETTE :
case MM_TYPE_INTER :
case MM_TYPE_INTRA :
case MM_TYPE_INTRA_HH :
case MM_TYPE_INTER_HH :
case MM_TYPE_INTRA_HHV :
case MM_TYPE_INTER_HHV :
if (av_new_packet(VAR_1, VAR_4 + MM_PREAMBLE_SIZE))
return AVERROR(ENOMEM);
memcpy(VAR_1->data, VAR_2, MM_PREAMBLE_SIZE);
if (avio_read(pb, VAR_1->data + MM_PREAMBLE_SIZE, VAR_4) != VAR_4)
return AVERROR(EIO);
VAR_1->size = VAR_4 + MM_PREAMBLE_SIZE;
VAR_1->stream_index = 0;
VAR_1->pts = mm->video_pts;
if (VAR_3!=MM_TYPE_PALETTE)
mm->video_pts++;
return 0;
case MM_TYPE_AUDIO :
if (av_get_packet(VAR_0->pb, VAR_1, VAR_4)<0)
return AVERROR(ENOMEM);
VAR_1->size = VAR_4;
VAR_1->stream_index = 1;
VAR_1->pts = mm->audio_pts++;
return 0;
default :
av_log(VAR_0, AV_LOG_INFO, "unknown chunk VAR_3 0x%x\n", VAR_3);
avio_skip(pb, VAR_4);
}
}
}
| [
"static int FUNC_0(AVFormatContext *VAR_0,\nAVPacket *VAR_1)\n{",
"MmDemuxContext *mm = VAR_0->priv_data;",
"AVIOContext *pb = VAR_0->pb;",
"unsigned char VAR_2[MM_PREAMBLE_SIZE];",
"unsigned int VAR_3, VAR_4;",
"while(1) {",
"if (avio_read(pb, VAR_2, MM_PREAMBLE_SIZE) != MM_PREAMBLE_SIZE) {",
"return AVERROR(EIO);",
"}",
"VAR_3 = AV_RL16(&VAR_2[0]);",
"VAR_4 = AV_RL16(&VAR_2[2]);",
"switch(VAR_3) {",
"case MM_TYPE_PALETTE :\ncase MM_TYPE_INTER :\ncase MM_TYPE_INTRA :\ncase MM_TYPE_INTRA_HH :\ncase MM_TYPE_INTER_HH :\ncase MM_TYPE_INTRA_HHV :\ncase MM_TYPE_INTER_HHV :\nif (av_new_packet(VAR_1, VAR_4 + MM_PREAMBLE_SIZE))\nreturn AVERROR(ENOMEM);",
"memcpy(VAR_1->data, VAR_2, MM_PREAMBLE_SIZE);",
"if (avio_read(pb, VAR_1->data + MM_PREAMBLE_SIZE, VAR_4) != VAR_4)\nreturn AVERROR(EIO);",
"VAR_1->size = VAR_4 + MM_PREAMBLE_SIZE;",
"VAR_1->stream_index = 0;",
"VAR_1->pts = mm->video_pts;",
"if (VAR_3!=MM_TYPE_PALETTE)\nmm->video_pts++;",
"return 0;",
"case MM_TYPE_AUDIO :\nif (av_get_packet(VAR_0->pb, VAR_1, VAR_4)<0)\nreturn AVERROR(ENOMEM);",
"VAR_1->size = VAR_4;",
"VAR_1->stream_index = 1;",
"VAR_1->pts = mm->audio_pts++;",
"return 0;",
"default :\nav_log(VAR_0, AV_LOG_INFO, \"unknown chunk VAR_3 0x%x\\n\", VAR_3);",
"avio_skip(pb, 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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
35
],
[
37,
39,
41,
43,
45,
47,
49,
53,
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
77,
79,
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93,
95
],
[
97
],
[
99
],
[
101
],
[
103
]
] |
26,775 | static int handle_name_to_path(FsContext *ctx, V9fsPath *dir_path,
const char *name, V9fsPath *target)
{
char buffer[PATH_MAX];
struct file_handle *fh;
int dirfd, ret, mnt_id;
struct handle_data *data = (struct handle_data *)ctx->private;
/* "." and ".." are not allowed */
if (!strcmp(name, ".") || !strcmp(name, "..")) {
errno = EINVAL;
return -1;
}
if (dir_path) {
dirfd = open_by_handle(data->mountfd, dir_path->data, O_PATH);
} else {
/* relative to export root */
dirfd = open(rpath(ctx, ".", buffer), O_DIRECTORY);
}
if (dirfd < 0) {
return dirfd;
}
fh = g_malloc(sizeof(struct file_handle) + data->handle_bytes);
fh->handle_bytes = data->handle_bytes;
/* add a "./" at the beginning of the path */
snprintf(buffer, PATH_MAX, "./%s", name);
/* flag = 0 imply don't follow symlink */
ret = name_to_handle(dirfd, buffer, fh, &mnt_id, 0);
if (!ret) {
target->data = (char *)fh;
target->size = sizeof(struct file_handle) + data->handle_bytes;
} else {
g_free(fh);
}
close(dirfd);
return ret;
}
| false | qemu | 4fa4ce7107c6ec432f185307158c5df91ce54308 | static int handle_name_to_path(FsContext *ctx, V9fsPath *dir_path,
const char *name, V9fsPath *target)
{
char buffer[PATH_MAX];
struct file_handle *fh;
int dirfd, ret, mnt_id;
struct handle_data *data = (struct handle_data *)ctx->private;
if (!strcmp(name, ".") || !strcmp(name, "..")) {
errno = EINVAL;
return -1;
}
if (dir_path) {
dirfd = open_by_handle(data->mountfd, dir_path->data, O_PATH);
} else {
dirfd = open(rpath(ctx, ".", buffer), O_DIRECTORY);
}
if (dirfd < 0) {
return dirfd;
}
fh = g_malloc(sizeof(struct file_handle) + data->handle_bytes);
fh->handle_bytes = data->handle_bytes;
snprintf(buffer, PATH_MAX, "./%s", name);
ret = name_to_handle(dirfd, buffer, fh, &mnt_id, 0);
if (!ret) {
target->data = (char *)fh;
target->size = sizeof(struct file_handle) + data->handle_bytes;
} else {
g_free(fh);
}
close(dirfd);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1,
const char *VAR_2, V9fsPath *VAR_3)
{
char VAR_4[PATH_MAX];
struct file_handle *VAR_5;
int VAR_6, VAR_7, VAR_8;
struct handle_data *VAR_9 = (struct handle_data *)VAR_0->private;
if (!strcmp(VAR_2, ".") || !strcmp(VAR_2, "..")) {
errno = EINVAL;
return -1;
}
if (VAR_1) {
VAR_6 = open_by_handle(VAR_9->mountfd, VAR_1->VAR_9, O_PATH);
} else {
VAR_6 = open(rpath(VAR_0, ".", VAR_4), O_DIRECTORY);
}
if (VAR_6 < 0) {
return VAR_6;
}
VAR_5 = g_malloc(sizeof(struct file_handle) + VAR_9->handle_bytes);
VAR_5->handle_bytes = VAR_9->handle_bytes;
snprintf(VAR_4, PATH_MAX, "./%s", VAR_2);
VAR_7 = name_to_handle(VAR_6, VAR_4, VAR_5, &VAR_8, 0);
if (!VAR_7) {
VAR_3->VAR_9 = (char *)VAR_5;
VAR_3->size = sizeof(struct file_handle) + VAR_9->handle_bytes;
} else {
g_free(VAR_5);
}
close(VAR_6);
return VAR_7;
}
| [
"static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1,\nconst char *VAR_2, V9fsPath *VAR_3)\n{",
"char VAR_4[PATH_MAX];",
"struct file_handle *VAR_5;",
"int VAR_6, VAR_7, VAR_8;",
"struct handle_data *VAR_9 = (struct handle_data *)VAR_0->private;",
"if (!strcmp(VAR_2, \".\") || !strcmp(VAR_2, \"..\")) {",
"errno = EINVAL;",
"return -1;",
"}",
"if (VAR_1) {",
"VAR_6 = open_by_handle(VAR_9->mountfd, VAR_1->VAR_9, O_PATH);",
"} else {",
"VAR_6 = open(rpath(VAR_0, \".\", VAR_4), O_DIRECTORY);",
"}",
"if (VAR_6 < 0) {",
"return VAR_6;",
"}",
"VAR_5 = g_malloc(sizeof(struct file_handle) + VAR_9->handle_bytes);",
"VAR_5->handle_bytes = VAR_9->handle_bytes;",
"snprintf(VAR_4, PATH_MAX, \"./%s\", VAR_2);",
"VAR_7 = name_to_handle(VAR_6, VAR_4, VAR_5, &VAR_8, 0);",
"if (!VAR_7) {",
"VAR_3->VAR_9 = (char *)VAR_5;",
"VAR_3->size = sizeof(struct file_handle) + VAR_9->handle_bytes;",
"} else {",
"g_free(VAR_5);",
"}",
"close(VAR_6);",
"return VAR_7;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
]
] |
26,778 | static int qio_dns_resolver_lookup_sync_inet(QIODNSResolver *resolver,
SocketAddress *addr,
size_t *naddrs,
SocketAddress ***addrs,
Error **errp)
{
struct addrinfo ai, *res, *e;
InetSocketAddress *iaddr = addr->u.inet.data;
char port[33];
char uaddr[INET6_ADDRSTRLEN + 1];
char uport[33];
int rc;
Error *err = NULL;
size_t i;
*naddrs = 0;
*addrs = NULL;
memset(&ai, 0, sizeof(ai));
ai.ai_flags = AI_PASSIVE;
if (iaddr->has_numeric && iaddr->numeric) {
ai.ai_flags |= AI_NUMERICHOST | AI_NUMERICSERV;
}
ai.ai_family = inet_ai_family_from_address(iaddr, &err);
ai.ai_socktype = SOCK_STREAM;
if (err) {
error_propagate(errp, err);
return -1;
}
if (iaddr->host == NULL) {
error_setg(errp, "host not specified");
return -1;
}
if (iaddr->port != NULL) {
pstrcpy(port, sizeof(port), iaddr->port);
} else {
port[0] = '\0';
}
rc = getaddrinfo(strlen(iaddr->host) ? iaddr->host : NULL,
strlen(port) ? port : NULL, &ai, &res);
if (rc != 0) {
error_setg(errp, "address resolution failed for %s:%s: %s",
iaddr->host, port, gai_strerror(rc));
return -1;
}
for (e = res; e != NULL; e = e->ai_next) {
(*naddrs)++;
}
*addrs = g_new0(SocketAddress *, *naddrs);
/* create socket + bind */
for (i = 0, e = res; e != NULL; i++, e = e->ai_next) {
SocketAddress *newaddr = g_new0(SocketAddress, 1);
InetSocketAddress *newiaddr = g_new0(InetSocketAddress, 1);
newaddr->u.inet.data = newiaddr;
newaddr->type = SOCKET_ADDRESS_KIND_INET;
getnameinfo((struct sockaddr *)e->ai_addr, e->ai_addrlen,
uaddr, INET6_ADDRSTRLEN, uport, 32,
NI_NUMERICHOST | NI_NUMERICSERV);
*newiaddr = (InetSocketAddress){
.host = g_strdup(uaddr),
.port = g_strdup(uport),
.has_numeric = true,
.numeric = true,
.has_to = iaddr->has_to,
.to = iaddr->to,
.has_ipv4 = false,
.has_ipv6 = false,
};
(*addrs)[i] = newaddr;
}
freeaddrinfo(res);
return 0;
}
| false | qemu | dfd100f242370886bb6732f70f1f7cbd8eb9fedc | static int qio_dns_resolver_lookup_sync_inet(QIODNSResolver *resolver,
SocketAddress *addr,
size_t *naddrs,
SocketAddress ***addrs,
Error **errp)
{
struct addrinfo ai, *res, *e;
InetSocketAddress *iaddr = addr->u.inet.data;
char port[33];
char uaddr[INET6_ADDRSTRLEN + 1];
char uport[33];
int rc;
Error *err = NULL;
size_t i;
*naddrs = 0;
*addrs = NULL;
memset(&ai, 0, sizeof(ai));
ai.ai_flags = AI_PASSIVE;
if (iaddr->has_numeric && iaddr->numeric) {
ai.ai_flags |= AI_NUMERICHOST | AI_NUMERICSERV;
}
ai.ai_family = inet_ai_family_from_address(iaddr, &err);
ai.ai_socktype = SOCK_STREAM;
if (err) {
error_propagate(errp, err);
return -1;
}
if (iaddr->host == NULL) {
error_setg(errp, "host not specified");
return -1;
}
if (iaddr->port != NULL) {
pstrcpy(port, sizeof(port), iaddr->port);
} else {
port[0] = '\0';
}
rc = getaddrinfo(strlen(iaddr->host) ? iaddr->host : NULL,
strlen(port) ? port : NULL, &ai, &res);
if (rc != 0) {
error_setg(errp, "address resolution failed for %s:%s: %s",
iaddr->host, port, gai_strerror(rc));
return -1;
}
for (e = res; e != NULL; e = e->ai_next) {
(*naddrs)++;
}
*addrs = g_new0(SocketAddress *, *naddrs);
for (i = 0, e = res; e != NULL; i++, e = e->ai_next) {
SocketAddress *newaddr = g_new0(SocketAddress, 1);
InetSocketAddress *newiaddr = g_new0(InetSocketAddress, 1);
newaddr->u.inet.data = newiaddr;
newaddr->type = SOCKET_ADDRESS_KIND_INET;
getnameinfo((struct sockaddr *)e->ai_addr, e->ai_addrlen,
uaddr, INET6_ADDRSTRLEN, uport, 32,
NI_NUMERICHOST | NI_NUMERICSERV);
*newiaddr = (InetSocketAddress){
.host = g_strdup(uaddr),
.port = g_strdup(uport),
.has_numeric = true,
.numeric = true,
.has_to = iaddr->has_to,
.to = iaddr->to,
.has_ipv4 = false,
.has_ipv6 = false,
};
(*addrs)[i] = newaddr;
}
freeaddrinfo(res);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(QIODNSResolver *VAR_0,
SocketAddress *VAR_1,
size_t *VAR_2,
SocketAddress ***VAR_3,
Error **VAR_4)
{
struct addrinfo VAR_5, *VAR_6, *VAR_7;
InetSocketAddress *iaddr = VAR_1->u.inet.data;
char VAR_8[33];
char VAR_9[INET6_ADDRSTRLEN + 1];
char VAR_10[33];
int VAR_11;
Error *err = NULL;
size_t i;
*VAR_2 = 0;
*VAR_3 = NULL;
memset(&VAR_5, 0, sizeof(VAR_5));
VAR_5.ai_flags = AI_PASSIVE;
if (iaddr->has_numeric && iaddr->numeric) {
VAR_5.ai_flags |= AI_NUMERICHOST | AI_NUMERICSERV;
}
VAR_5.ai_family = inet_ai_family_from_address(iaddr, &err);
VAR_5.ai_socktype = SOCK_STREAM;
if (err) {
error_propagate(VAR_4, err);
return -1;
}
if (iaddr->host == NULL) {
error_setg(VAR_4, "host not specified");
return -1;
}
if (iaddr->VAR_8 != NULL) {
pstrcpy(VAR_8, sizeof(VAR_8), iaddr->VAR_8);
} else {
VAR_8[0] = '\0';
}
VAR_11 = getaddrinfo(strlen(iaddr->host) ? iaddr->host : NULL,
strlen(VAR_8) ? VAR_8 : NULL, &VAR_5, &VAR_6);
if (VAR_11 != 0) {
error_setg(VAR_4, "address resolution failed for %s:%s: %s",
iaddr->host, VAR_8, gai_strerror(VAR_11));
return -1;
}
for (VAR_7 = VAR_6; VAR_7 != NULL; VAR_7 = VAR_7->ai_next) {
(*VAR_2)++;
}
*VAR_3 = g_new0(SocketAddress *, *VAR_2);
for (i = 0, VAR_7 = VAR_6; VAR_7 != NULL; i++, VAR_7 = VAR_7->ai_next) {
SocketAddress *newaddr = g_new0(SocketAddress, 1);
InetSocketAddress *newiaddr = g_new0(InetSocketAddress, 1);
newaddr->u.inet.data = newiaddr;
newaddr->type = SOCKET_ADDRESS_KIND_INET;
getnameinfo((struct sockaddr *)VAR_7->ai_addr, VAR_7->ai_addrlen,
VAR_9, INET6_ADDRSTRLEN, VAR_10, 32,
NI_NUMERICHOST | NI_NUMERICSERV);
*newiaddr = (InetSocketAddress){
.host = g_strdup(VAR_9),
.VAR_8 = g_strdup(VAR_10),
.has_numeric = true,
.numeric = true,
.has_to = iaddr->has_to,
.to = iaddr->to,
.has_ipv4 = false,
.has_ipv6 = false,
};
(*VAR_3)[i] = newaddr;
}
freeaddrinfo(VAR_6);
return 0;
}
| [
"static int FUNC_0(QIODNSResolver *VAR_0,\nSocketAddress *VAR_1,\nsize_t *VAR_2,\nSocketAddress ***VAR_3,\nError **VAR_4)\n{",
"struct addrinfo VAR_5, *VAR_6, *VAR_7;",
"InetSocketAddress *iaddr = VAR_1->u.inet.data;",
"char VAR_8[33];",
"char VAR_9[INET6_ADDRSTRLEN + 1];",
"char VAR_10[33];",
"int VAR_11;",
"Error *err = NULL;",
"size_t i;",
"*VAR_2 = 0;",
"*VAR_3 = NULL;",
"memset(&VAR_5, 0, sizeof(VAR_5));",
"VAR_5.ai_flags = AI_PASSIVE;",
"if (iaddr->has_numeric && iaddr->numeric) {",
"VAR_5.ai_flags |= AI_NUMERICHOST | AI_NUMERICSERV;",
"}",
"VAR_5.ai_family = inet_ai_family_from_address(iaddr, &err);",
"VAR_5.ai_socktype = SOCK_STREAM;",
"if (err) {",
"error_propagate(VAR_4, err);",
"return -1;",
"}",
"if (iaddr->host == NULL) {",
"error_setg(VAR_4, \"host not specified\");",
"return -1;",
"}",
"if (iaddr->VAR_8 != NULL) {",
"pstrcpy(VAR_8, sizeof(VAR_8), iaddr->VAR_8);",
"} else {",
"VAR_8[0] = '\\0';",
"}",
"VAR_11 = getaddrinfo(strlen(iaddr->host) ? iaddr->host : NULL,\nstrlen(VAR_8) ? VAR_8 : NULL, &VAR_5, &VAR_6);",
"if (VAR_11 != 0) {",
"error_setg(VAR_4, \"address resolution failed for %s:%s: %s\",\niaddr->host, VAR_8, gai_strerror(VAR_11));",
"return -1;",
"}",
"for (VAR_7 = VAR_6; VAR_7 != NULL; VAR_7 = VAR_7->ai_next) {",
"(*VAR_2)++;",
"}",
"*VAR_3 = g_new0(SocketAddress *, *VAR_2);",
"for (i = 0, VAR_7 = VAR_6; VAR_7 != NULL; i++, VAR_7 = VAR_7->ai_next) {",
"SocketAddress *newaddr = g_new0(SocketAddress, 1);",
"InetSocketAddress *newiaddr = g_new0(InetSocketAddress, 1);",
"newaddr->u.inet.data = newiaddr;",
"newaddr->type = SOCKET_ADDRESS_KIND_INET;",
"getnameinfo((struct sockaddr *)VAR_7->ai_addr, VAR_7->ai_addrlen,\nVAR_9, INET6_ADDRSTRLEN, VAR_10, 32,\nNI_NUMERICHOST | NI_NUMERICSERV);",
"*newiaddr = (InetSocketAddress){",
".host = g_strdup(VAR_9),\n.VAR_8 = g_strdup(VAR_10),\n.has_numeric = true,\n.numeric = true,\n.has_to = iaddr->has_to,\n.to = iaddr->to,\n.has_ipv4 = false,\n.has_ipv6 = false,\n};",
"(*VAR_3)[i] = newaddr;",
"}",
"freeaddrinfo(VAR_6);",
"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
] | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83,
85
],
[
87
],
[
89,
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
107
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125,
127,
129
],
[
133
],
[
135,
137,
139,
141,
143,
145,
147,
149,
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
]
] |
26,779 | void acpi_build(AcpiBuildTables *tables, MachineState *machine)
{
PCMachineState *pcms = PC_MACHINE(machine);
PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
GArray *table_offsets;
unsigned facs, dsdt, rsdt, fadt;
AcpiPmInfo pm;
AcpiMiscInfo misc;
AcpiMcfgInfo mcfg;
Range pci_hole, pci_hole64;
uint8_t *u;
size_t aml_len = 0;
GArray *tables_blob = tables->table_data;
AcpiSlicOem slic_oem = { .id = NULL, .table_id = NULL };
Object *vmgenid_dev;
acpi_get_pm_info(&pm);
acpi_get_misc_info(&misc);
acpi_get_pci_holes(&pci_hole, &pci_hole64);
acpi_get_slic_oem(&slic_oem);
table_offsets = g_array_new(false, true /* clear */,
sizeof(uint32_t));
ACPI_BUILD_DPRINTF("init ACPI tables\n");
bios_linker_loader_alloc(tables->linker,
ACPI_BUILD_TABLE_FILE, tables_blob,
64 /* Ensure FACS is aligned */,
false /* high memory */);
/*
* FACS is pointed to by FADT.
* We place it first since it's the only table that has alignment
* requirements.
*/
facs = tables_blob->len;
build_facs(tables_blob, tables->linker);
/* DSDT is pointed to by FADT */
dsdt = tables_blob->len;
build_dsdt(tables_blob, tables->linker, &pm, &misc,
&pci_hole, &pci_hole64, machine);
/* Count the size of the DSDT and SSDT, we will need it for legacy
* sizing of ACPI tables.
*/
aml_len += tables_blob->len - dsdt;
/* ACPI tables pointed to by RSDT */
fadt = tables_blob->len;
acpi_add_table(table_offsets, tables_blob);
build_fadt(tables_blob, tables->linker, &pm, facs, dsdt,
slic_oem.id, slic_oem.table_id);
aml_len += tables_blob->len - fadt;
acpi_add_table(table_offsets, tables_blob);
build_madt(tables_blob, tables->linker, pcms);
vmgenid_dev = find_vmgenid_dev();
if (vmgenid_dev) {
acpi_add_table(table_offsets, tables_blob);
vmgenid_build_acpi(VMGENID(vmgenid_dev), tables_blob,
tables->vmgenid, tables->linker);
}
if (misc.has_hpet) {
acpi_add_table(table_offsets, tables_blob);
build_hpet(tables_blob, tables->linker);
}
if (misc.tpm_version != TPM_VERSION_UNSPEC) {
acpi_add_table(table_offsets, tables_blob);
build_tpm_tcpa(tables_blob, tables->linker, tables->tcpalog);
if (misc.tpm_version == TPM_VERSION_2_0) {
acpi_add_table(table_offsets, tables_blob);
build_tpm2(tables_blob, tables->linker);
}
}
if (pcms->numa_nodes) {
acpi_add_table(table_offsets, tables_blob);
build_srat(tables_blob, tables->linker, machine);
if (have_numa_distance) {
acpi_add_table(table_offsets, tables_blob);
build_slit(tables_blob, tables->linker);
}
}
if (acpi_get_mcfg(&mcfg)) {
acpi_add_table(table_offsets, tables_blob);
build_mcfg_q35(tables_blob, tables->linker, &mcfg);
}
if (x86_iommu_get_default()) {
IommuType IOMMUType = x86_iommu_get_type();
if (IOMMUType == TYPE_AMD) {
acpi_add_table(table_offsets, tables_blob);
build_amd_iommu(tables_blob, tables->linker);
} else if (IOMMUType == TYPE_INTEL) {
acpi_add_table(table_offsets, tables_blob);
build_dmar_q35(tables_blob, tables->linker);
}
}
if (pcms->acpi_nvdimm_state.is_enabled) {
nvdimm_build_acpi(table_offsets, tables_blob, tables->linker,
&pcms->acpi_nvdimm_state, machine->ram_slots);
}
/* Add tables supplied by user (if any) */
for (u = acpi_table_first(); u; u = acpi_table_next(u)) {
unsigned len = acpi_table_len(u);
acpi_add_table(table_offsets, tables_blob);
g_array_append_vals(tables_blob, u, len);
}
/* RSDT is pointed to by RSDP */
rsdt = tables_blob->len;
build_rsdt(tables_blob, tables->linker, table_offsets,
slic_oem.id, slic_oem.table_id);
/* RSDP is in FSEG memory, so allocate it separately */
build_rsdp(tables->rsdp, tables->linker, rsdt);
/* We'll expose it all to Guest so we want to reduce
* chance of size changes.
*
* We used to align the tables to 4k, but of course this would
* too simple to be enough. 4k turned out to be too small an
* alignment very soon, and in fact it is almost impossible to
* keep the table size stable for all (max_cpus, max_memory_slots)
* combinations. So the table size is always 64k for pc-i440fx-2.1
* and we give an error if the table grows beyond that limit.
*
* We still have the problem of migrating from "-M pc-i440fx-2.0". For
* that, we exploit the fact that QEMU 2.1 generates _smaller_ tables
* than 2.0 and we can always pad the smaller tables with zeros. We can
* then use the exact size of the 2.0 tables.
*
* All this is for PIIX4, since QEMU 2.0 didn't support Q35 migration.
*/
if (pcmc->legacy_acpi_table_size) {
/* Subtracting aml_len gives the size of fixed tables. Then add the
* size of the PIIX4 DSDT/SSDT in QEMU 2.0.
*/
int legacy_aml_len =
pcmc->legacy_acpi_table_size +
ACPI_BUILD_LEGACY_CPU_AML_SIZE * pcms->apic_id_limit;
int legacy_table_size =
ROUND_UP(tables_blob->len - aml_len + legacy_aml_len,
ACPI_BUILD_ALIGN_SIZE);
if (tables_blob->len > legacy_table_size) {
/* Should happen only with PCI bridges and -M pc-i440fx-2.0. */
error_report("Warning: migration may not work.");
}
g_array_set_size(tables_blob, legacy_table_size);
} else {
/* Make sure we have a buffer in case we need to resize the tables. */
if (tables_blob->len > ACPI_BUILD_TABLE_SIZE / 2) {
/* As of QEMU 2.1, this fires with 160 VCPUs and 255 memory slots. */
error_report("Warning: ACPI tables are larger than 64k.");
error_report("Warning: migration may not work.");
error_report("Warning: please remove CPUs, NUMA nodes, "
"memory slots or PCI bridges.");
}
acpi_align_size(tables_blob, ACPI_BUILD_TABLE_SIZE);
}
acpi_align_size(tables->linker->cmd_blob, ACPI_BUILD_ALIGN_SIZE);
/* Cleanup memory that's no longer used. */
g_array_free(table_offsets, true);
}
| false | qemu | 3dc6f8693694a649a9c83f1e2746565b47683923 | void acpi_build(AcpiBuildTables *tables, MachineState *machine)
{
PCMachineState *pcms = PC_MACHINE(machine);
PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
GArray *table_offsets;
unsigned facs, dsdt, rsdt, fadt;
AcpiPmInfo pm;
AcpiMiscInfo misc;
AcpiMcfgInfo mcfg;
Range pci_hole, pci_hole64;
uint8_t *u;
size_t aml_len = 0;
GArray *tables_blob = tables->table_data;
AcpiSlicOem slic_oem = { .id = NULL, .table_id = NULL };
Object *vmgenid_dev;
acpi_get_pm_info(&pm);
acpi_get_misc_info(&misc);
acpi_get_pci_holes(&pci_hole, &pci_hole64);
acpi_get_slic_oem(&slic_oem);
table_offsets = g_array_new(false, true ,
sizeof(uint32_t));
ACPI_BUILD_DPRINTF("init ACPI tables\n");
bios_linker_loader_alloc(tables->linker,
ACPI_BUILD_TABLE_FILE, tables_blob,
64 ,
false );
facs = tables_blob->len;
build_facs(tables_blob, tables->linker);
dsdt = tables_blob->len;
build_dsdt(tables_blob, tables->linker, &pm, &misc,
&pci_hole, &pci_hole64, machine);
aml_len += tables_blob->len - dsdt;
fadt = tables_blob->len;
acpi_add_table(table_offsets, tables_blob);
build_fadt(tables_blob, tables->linker, &pm, facs, dsdt,
slic_oem.id, slic_oem.table_id);
aml_len += tables_blob->len - fadt;
acpi_add_table(table_offsets, tables_blob);
build_madt(tables_blob, tables->linker, pcms);
vmgenid_dev = find_vmgenid_dev();
if (vmgenid_dev) {
acpi_add_table(table_offsets, tables_blob);
vmgenid_build_acpi(VMGENID(vmgenid_dev), tables_blob,
tables->vmgenid, tables->linker);
}
if (misc.has_hpet) {
acpi_add_table(table_offsets, tables_blob);
build_hpet(tables_blob, tables->linker);
}
if (misc.tpm_version != TPM_VERSION_UNSPEC) {
acpi_add_table(table_offsets, tables_blob);
build_tpm_tcpa(tables_blob, tables->linker, tables->tcpalog);
if (misc.tpm_version == TPM_VERSION_2_0) {
acpi_add_table(table_offsets, tables_blob);
build_tpm2(tables_blob, tables->linker);
}
}
if (pcms->numa_nodes) {
acpi_add_table(table_offsets, tables_blob);
build_srat(tables_blob, tables->linker, machine);
if (have_numa_distance) {
acpi_add_table(table_offsets, tables_blob);
build_slit(tables_blob, tables->linker);
}
}
if (acpi_get_mcfg(&mcfg)) {
acpi_add_table(table_offsets, tables_blob);
build_mcfg_q35(tables_blob, tables->linker, &mcfg);
}
if (x86_iommu_get_default()) {
IommuType IOMMUType = x86_iommu_get_type();
if (IOMMUType == TYPE_AMD) {
acpi_add_table(table_offsets, tables_blob);
build_amd_iommu(tables_blob, tables->linker);
} else if (IOMMUType == TYPE_INTEL) {
acpi_add_table(table_offsets, tables_blob);
build_dmar_q35(tables_blob, tables->linker);
}
}
if (pcms->acpi_nvdimm_state.is_enabled) {
nvdimm_build_acpi(table_offsets, tables_blob, tables->linker,
&pcms->acpi_nvdimm_state, machine->ram_slots);
}
for (u = acpi_table_first(); u; u = acpi_table_next(u)) {
unsigned len = acpi_table_len(u);
acpi_add_table(table_offsets, tables_blob);
g_array_append_vals(tables_blob, u, len);
}
rsdt = tables_blob->len;
build_rsdt(tables_blob, tables->linker, table_offsets,
slic_oem.id, slic_oem.table_id);
build_rsdp(tables->rsdp, tables->linker, rsdt);
if (pcmc->legacy_acpi_table_size) {
int legacy_aml_len =
pcmc->legacy_acpi_table_size +
ACPI_BUILD_LEGACY_CPU_AML_SIZE * pcms->apic_id_limit;
int legacy_table_size =
ROUND_UP(tables_blob->len - aml_len + legacy_aml_len,
ACPI_BUILD_ALIGN_SIZE);
if (tables_blob->len > legacy_table_size) {
error_report("Warning: migration may not work.");
}
g_array_set_size(tables_blob, legacy_table_size);
} else {
if (tables_blob->len > ACPI_BUILD_TABLE_SIZE / 2) {
error_report("Warning: ACPI tables are larger than 64k.");
error_report("Warning: migration may not work.");
error_report("Warning: please remove CPUs, NUMA nodes, "
"memory slots or PCI bridges.");
}
acpi_align_size(tables_blob, ACPI_BUILD_TABLE_SIZE);
}
acpi_align_size(tables->linker->cmd_blob, ACPI_BUILD_ALIGN_SIZE);
g_array_free(table_offsets, true);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(AcpiBuildTables *VAR_0, MachineState *VAR_1)
{
PCMachineState *pcms = PC_MACHINE(VAR_1);
PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
GArray *table_offsets;
unsigned VAR_2, VAR_3, VAR_4, VAR_5;
AcpiPmInfo pm;
AcpiMiscInfo misc;
AcpiMcfgInfo mcfg;
Range pci_hole, pci_hole64;
uint8_t *u;
size_t aml_len = 0;
GArray *tables_blob = VAR_0->table_data;
AcpiSlicOem slic_oem = { .id = NULL, .table_id = NULL };
Object *vmgenid_dev;
acpi_get_pm_info(&pm);
acpi_get_misc_info(&misc);
acpi_get_pci_holes(&pci_hole, &pci_hole64);
acpi_get_slic_oem(&slic_oem);
table_offsets = g_array_new(false, true ,
sizeof(uint32_t));
ACPI_BUILD_DPRINTF("init ACPI VAR_0\n");
bios_linker_loader_alloc(VAR_0->linker,
ACPI_BUILD_TABLE_FILE, tables_blob,
64 ,
false );
VAR_2 = tables_blob->len;
build_facs(tables_blob, VAR_0->linker);
VAR_3 = tables_blob->len;
build_dsdt(tables_blob, VAR_0->linker, &pm, &misc,
&pci_hole, &pci_hole64, VAR_1);
aml_len += tables_blob->len - VAR_3;
VAR_5 = tables_blob->len;
acpi_add_table(table_offsets, tables_blob);
build_fadt(tables_blob, VAR_0->linker, &pm, VAR_2, VAR_3,
slic_oem.id, slic_oem.table_id);
aml_len += tables_blob->len - VAR_5;
acpi_add_table(table_offsets, tables_blob);
build_madt(tables_blob, VAR_0->linker, pcms);
vmgenid_dev = find_vmgenid_dev();
if (vmgenid_dev) {
acpi_add_table(table_offsets, tables_blob);
vmgenid_build_acpi(VMGENID(vmgenid_dev), tables_blob,
VAR_0->vmgenid, VAR_0->linker);
}
if (misc.has_hpet) {
acpi_add_table(table_offsets, tables_blob);
build_hpet(tables_blob, VAR_0->linker);
}
if (misc.tpm_version != TPM_VERSION_UNSPEC) {
acpi_add_table(table_offsets, tables_blob);
build_tpm_tcpa(tables_blob, VAR_0->linker, VAR_0->tcpalog);
if (misc.tpm_version == TPM_VERSION_2_0) {
acpi_add_table(table_offsets, tables_blob);
build_tpm2(tables_blob, VAR_0->linker);
}
}
if (pcms->numa_nodes) {
acpi_add_table(table_offsets, tables_blob);
build_srat(tables_blob, VAR_0->linker, VAR_1);
if (have_numa_distance) {
acpi_add_table(table_offsets, tables_blob);
build_slit(tables_blob, VAR_0->linker);
}
}
if (acpi_get_mcfg(&mcfg)) {
acpi_add_table(table_offsets, tables_blob);
build_mcfg_q35(tables_blob, VAR_0->linker, &mcfg);
}
if (x86_iommu_get_default()) {
IommuType IOMMUType = x86_iommu_get_type();
if (IOMMUType == TYPE_AMD) {
acpi_add_table(table_offsets, tables_blob);
build_amd_iommu(tables_blob, VAR_0->linker);
} else if (IOMMUType == TYPE_INTEL) {
acpi_add_table(table_offsets, tables_blob);
build_dmar_q35(tables_blob, VAR_0->linker);
}
}
if (pcms->acpi_nvdimm_state.is_enabled) {
nvdimm_build_acpi(table_offsets, tables_blob, VAR_0->linker,
&pcms->acpi_nvdimm_state, VAR_1->ram_slots);
}
for (u = acpi_table_first(); u; u = acpi_table_next(u)) {
unsigned len = acpi_table_len(u);
acpi_add_table(table_offsets, tables_blob);
g_array_append_vals(tables_blob, u, len);
}
VAR_4 = tables_blob->len;
build_rsdt(tables_blob, VAR_0->linker, table_offsets,
slic_oem.id, slic_oem.table_id);
build_rsdp(VAR_0->rsdp, VAR_0->linker, VAR_4);
if (pcmc->legacy_acpi_table_size) {
int VAR_6 =
pcmc->legacy_acpi_table_size +
ACPI_BUILD_LEGACY_CPU_AML_SIZE * pcms->apic_id_limit;
int VAR_7 =
ROUND_UP(tables_blob->len - aml_len + VAR_6,
ACPI_BUILD_ALIGN_SIZE);
if (tables_blob->len > VAR_7) {
error_report("Warning: migration may not work.");
}
g_array_set_size(tables_blob, VAR_7);
} else {
if (tables_blob->len > ACPI_BUILD_TABLE_SIZE / 2) {
error_report("Warning: ACPI VAR_0 are larger than 64k.");
error_report("Warning: migration may not work.");
error_report("Warning: please remove CPUs, NUMA nodes, "
"memory slots or PCI bridges.");
}
acpi_align_size(tables_blob, ACPI_BUILD_TABLE_SIZE);
}
acpi_align_size(VAR_0->linker->cmd_blob, ACPI_BUILD_ALIGN_SIZE);
g_array_free(table_offsets, true);
}
| [
"void FUNC_0(AcpiBuildTables *VAR_0, MachineState *VAR_1)\n{",
"PCMachineState *pcms = PC_MACHINE(VAR_1);",
"PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);",
"GArray *table_offsets;",
"unsigned VAR_2, VAR_3, VAR_4, VAR_5;",
"AcpiPmInfo pm;",
"AcpiMiscInfo misc;",
"AcpiMcfgInfo mcfg;",
"Range pci_hole, pci_hole64;",
"uint8_t *u;",
"size_t aml_len = 0;",
"GArray *tables_blob = VAR_0->table_data;",
"AcpiSlicOem slic_oem = { .id = NULL, .table_id = NULL };",
"Object *vmgenid_dev;",
"acpi_get_pm_info(&pm);",
"acpi_get_misc_info(&misc);",
"acpi_get_pci_holes(&pci_hole, &pci_hole64);",
"acpi_get_slic_oem(&slic_oem);",
"table_offsets = g_array_new(false, true ,\nsizeof(uint32_t));",
"ACPI_BUILD_DPRINTF(\"init ACPI VAR_0\\n\");",
"bios_linker_loader_alloc(VAR_0->linker,\nACPI_BUILD_TABLE_FILE, tables_blob,\n64 ,\nfalse );",
"VAR_2 = tables_blob->len;",
"build_facs(tables_blob, VAR_0->linker);",
"VAR_3 = tables_blob->len;",
"build_dsdt(tables_blob, VAR_0->linker, &pm, &misc,\n&pci_hole, &pci_hole64, VAR_1);",
"aml_len += tables_blob->len - VAR_3;",
"VAR_5 = tables_blob->len;",
"acpi_add_table(table_offsets, tables_blob);",
"build_fadt(tables_blob, VAR_0->linker, &pm, VAR_2, VAR_3,\nslic_oem.id, slic_oem.table_id);",
"aml_len += tables_blob->len - VAR_5;",
"acpi_add_table(table_offsets, tables_blob);",
"build_madt(tables_blob, VAR_0->linker, pcms);",
"vmgenid_dev = find_vmgenid_dev();",
"if (vmgenid_dev) {",
"acpi_add_table(table_offsets, tables_blob);",
"vmgenid_build_acpi(VMGENID(vmgenid_dev), tables_blob,\nVAR_0->vmgenid, VAR_0->linker);",
"}",
"if (misc.has_hpet) {",
"acpi_add_table(table_offsets, tables_blob);",
"build_hpet(tables_blob, VAR_0->linker);",
"}",
"if (misc.tpm_version != TPM_VERSION_UNSPEC) {",
"acpi_add_table(table_offsets, tables_blob);",
"build_tpm_tcpa(tables_blob, VAR_0->linker, VAR_0->tcpalog);",
"if (misc.tpm_version == TPM_VERSION_2_0) {",
"acpi_add_table(table_offsets, tables_blob);",
"build_tpm2(tables_blob, VAR_0->linker);",
"}",
"}",
"if (pcms->numa_nodes) {",
"acpi_add_table(table_offsets, tables_blob);",
"build_srat(tables_blob, VAR_0->linker, VAR_1);",
"if (have_numa_distance) {",
"acpi_add_table(table_offsets, tables_blob);",
"build_slit(tables_blob, VAR_0->linker);",
"}",
"}",
"if (acpi_get_mcfg(&mcfg)) {",
"acpi_add_table(table_offsets, tables_blob);",
"build_mcfg_q35(tables_blob, VAR_0->linker, &mcfg);",
"}",
"if (x86_iommu_get_default()) {",
"IommuType IOMMUType = x86_iommu_get_type();",
"if (IOMMUType == TYPE_AMD) {",
"acpi_add_table(table_offsets, tables_blob);",
"build_amd_iommu(tables_blob, VAR_0->linker);",
"} else if (IOMMUType == TYPE_INTEL) {",
"acpi_add_table(table_offsets, tables_blob);",
"build_dmar_q35(tables_blob, VAR_0->linker);",
"}",
"}",
"if (pcms->acpi_nvdimm_state.is_enabled) {",
"nvdimm_build_acpi(table_offsets, tables_blob, VAR_0->linker,\n&pcms->acpi_nvdimm_state, VAR_1->ram_slots);",
"}",
"for (u = acpi_table_first(); u; u = acpi_table_next(u)) {",
"unsigned len = acpi_table_len(u);",
"acpi_add_table(table_offsets, tables_blob);",
"g_array_append_vals(tables_blob, u, len);",
"}",
"VAR_4 = tables_blob->len;",
"build_rsdt(tables_blob, VAR_0->linker, table_offsets,\nslic_oem.id, slic_oem.table_id);",
"build_rsdp(VAR_0->rsdp, VAR_0->linker, VAR_4);",
"if (pcmc->legacy_acpi_table_size) {",
"int VAR_6 =\npcmc->legacy_acpi_table_size +\nACPI_BUILD_LEGACY_CPU_AML_SIZE * pcms->apic_id_limit;",
"int VAR_7 =\nROUND_UP(tables_blob->len - aml_len + VAR_6,\nACPI_BUILD_ALIGN_SIZE);",
"if (tables_blob->len > VAR_7) {",
"error_report(\"Warning: migration may not work.\");",
"}",
"g_array_set_size(tables_blob, VAR_7);",
"} else {",
"if (tables_blob->len > ACPI_BUILD_TABLE_SIZE / 2) {",
"error_report(\"Warning: ACPI VAR_0 are larger than 64k.\");",
"error_report(\"Warning: migration may not work.\");",
"error_report(\"Warning: please remove CPUs, NUMA nodes, \"\n\"memory slots or PCI bridges.\");",
"}",
"acpi_align_size(tables_blob, ACPI_BUILD_TABLE_SIZE);",
"}",
"acpi_align_size(VAR_0->linker->cmd_blob, ACPI_BUILD_ALIGN_SIZE);",
"g_array_free(table_offsets, 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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43,
45
],
[
47
],
[
51,
53,
55,
57
],
[
71
],
[
73
],
[
79
],
[
81,
83
],
[
93
],
[
99
],
[
101
],
[
103,
105
],
[
107
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123,
125
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203,
205
],
[
207
],
[
213
],
[
215
],
[
219
],
[
221
],
[
223
],
[
229
],
[
231,
233
],
[
239
],
[
277
],
[
285,
287,
289
],
[
291,
293,
295
],
[
297
],
[
301
],
[
303
],
[
305
],
[
307
],
[
311
],
[
315
],
[
317
],
[
319,
321
],
[
323
],
[
325
],
[
327
],
[
331
],
[
337
],
[
339
]
] |
26,781 | static Aml *build_crs(PCIHostState *host,
GPtrArray *io_ranges, GPtrArray *mem_ranges)
{
Aml *crs = aml_resource_template();
uint8_t max_bus = pci_bus_num(host->bus);
uint8_t type;
int devfn;
for (devfn = 0; devfn < ARRAY_SIZE(host->bus->devices); devfn++) {
int i;
uint64_t range_base, range_limit;
PCIDevice *dev = host->bus->devices[devfn];
if (!dev) {
continue;
}
for (i = 0; i < PCI_NUM_REGIONS; i++) {
PCIIORegion *r = &dev->io_regions[i];
range_base = r->addr;
range_limit = r->addr + r->size - 1;
/*
* Work-around for old bioses
* that do not support multiple root buses
*/
if (!range_base || range_base > range_limit) {
continue;
}
if (r->type & PCI_BASE_ADDRESS_SPACE_IO) {
aml_append(crs,
aml_word_io(AML_MIN_FIXED, AML_MAX_FIXED,
AML_POS_DECODE, AML_ENTIRE_RANGE,
0,
range_base,
range_limit,
0,
range_limit - range_base + 1));
crs_range_insert(io_ranges, range_base, range_limit);
} else { /* "memory" */
aml_append(crs,
aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED,
AML_MAX_FIXED, AML_NON_CACHEABLE,
AML_READ_WRITE,
0,
range_base,
range_limit,
0,
range_limit - range_base + 1));
crs_range_insert(mem_ranges, range_base, range_limit);
}
}
type = dev->config[PCI_HEADER_TYPE] & ~PCI_HEADER_TYPE_MULTI_FUNCTION;
if (type == PCI_HEADER_TYPE_BRIDGE) {
uint8_t subordinate = dev->config[PCI_SUBORDINATE_BUS];
if (subordinate > max_bus) {
max_bus = subordinate;
}
range_base = pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_IO);
range_limit = pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_IO);
/*
* Work-around for old bioses
* that do not support multiple root buses
*/
if (range_base || range_base > range_limit) {
aml_append(crs,
aml_word_io(AML_MIN_FIXED, AML_MAX_FIXED,
AML_POS_DECODE, AML_ENTIRE_RANGE,
0,
range_base,
range_limit,
0,
range_limit - range_base + 1));
crs_range_insert(io_ranges, range_base, range_limit);
}
range_base =
pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_MEMORY);
range_limit =
pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_MEMORY);
/*
* Work-around for old bioses
* that do not support multiple root buses
*/
if (range_base || range_base > range_limit) {
aml_append(crs,
aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED,
AML_MAX_FIXED, AML_NON_CACHEABLE,
AML_READ_WRITE,
0,
range_base,
range_limit,
0,
range_limit - range_base + 1));
crs_range_insert(mem_ranges, range_base, range_limit);
}
range_base =
pci_bridge_get_base(dev, PCI_BASE_ADDRESS_MEM_PREFETCH);
range_limit =
pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_MEM_PREFETCH);
/*
* Work-around for old bioses
* that do not support multiple root buses
*/
if (range_base || range_base > range_limit) {
aml_append(crs,
aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED,
AML_MAX_FIXED, AML_NON_CACHEABLE,
AML_READ_WRITE,
0,
range_base,
range_limit,
0,
range_limit - range_base + 1));
crs_range_insert(mem_ranges, range_base, range_limit);
}
}
}
aml_append(crs,
aml_word_bus_number(AML_MIN_FIXED, AML_MAX_FIXED, AML_POS_DECODE,
0,
pci_bus_num(host->bus),
max_bus,
0,
max_bus - pci_bus_num(host->bus) + 1));
return crs;
}
| false | qemu | 4ebc736e9938a7e88ecc785734b17145bf802a56 | static Aml *build_crs(PCIHostState *host,
GPtrArray *io_ranges, GPtrArray *mem_ranges)
{
Aml *crs = aml_resource_template();
uint8_t max_bus = pci_bus_num(host->bus);
uint8_t type;
int devfn;
for (devfn = 0; devfn < ARRAY_SIZE(host->bus->devices); devfn++) {
int i;
uint64_t range_base, range_limit;
PCIDevice *dev = host->bus->devices[devfn];
if (!dev) {
continue;
}
for (i = 0; i < PCI_NUM_REGIONS; i++) {
PCIIORegion *r = &dev->io_regions[i];
range_base = r->addr;
range_limit = r->addr + r->size - 1;
if (!range_base || range_base > range_limit) {
continue;
}
if (r->type & PCI_BASE_ADDRESS_SPACE_IO) {
aml_append(crs,
aml_word_io(AML_MIN_FIXED, AML_MAX_FIXED,
AML_POS_DECODE, AML_ENTIRE_RANGE,
0,
range_base,
range_limit,
0,
range_limit - range_base + 1));
crs_range_insert(io_ranges, range_base, range_limit);
} else {
aml_append(crs,
aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED,
AML_MAX_FIXED, AML_NON_CACHEABLE,
AML_READ_WRITE,
0,
range_base,
range_limit,
0,
range_limit - range_base + 1));
crs_range_insert(mem_ranges, range_base, range_limit);
}
}
type = dev->config[PCI_HEADER_TYPE] & ~PCI_HEADER_TYPE_MULTI_FUNCTION;
if (type == PCI_HEADER_TYPE_BRIDGE) {
uint8_t subordinate = dev->config[PCI_SUBORDINATE_BUS];
if (subordinate > max_bus) {
max_bus = subordinate;
}
range_base = pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_IO);
range_limit = pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_IO);
if (range_base || range_base > range_limit) {
aml_append(crs,
aml_word_io(AML_MIN_FIXED, AML_MAX_FIXED,
AML_POS_DECODE, AML_ENTIRE_RANGE,
0,
range_base,
range_limit,
0,
range_limit - range_base + 1));
crs_range_insert(io_ranges, range_base, range_limit);
}
range_base =
pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_MEMORY);
range_limit =
pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_MEMORY);
if (range_base || range_base > range_limit) {
aml_append(crs,
aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED,
AML_MAX_FIXED, AML_NON_CACHEABLE,
AML_READ_WRITE,
0,
range_base,
range_limit,
0,
range_limit - range_base + 1));
crs_range_insert(mem_ranges, range_base, range_limit);
}
range_base =
pci_bridge_get_base(dev, PCI_BASE_ADDRESS_MEM_PREFETCH);
range_limit =
pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_MEM_PREFETCH);
if (range_base || range_base > range_limit) {
aml_append(crs,
aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED,
AML_MAX_FIXED, AML_NON_CACHEABLE,
AML_READ_WRITE,
0,
range_base,
range_limit,
0,
range_limit - range_base + 1));
crs_range_insert(mem_ranges, range_base, range_limit);
}
}
}
aml_append(crs,
aml_word_bus_number(AML_MIN_FIXED, AML_MAX_FIXED, AML_POS_DECODE,
0,
pci_bus_num(host->bus),
max_bus,
0,
max_bus - pci_bus_num(host->bus) + 1));
return crs;
}
| {
"code": [],
"line_no": []
} | static Aml *FUNC_0(PCIHostState *host,
GPtrArray *io_ranges, GPtrArray *mem_ranges)
{
Aml *crs = aml_resource_template();
uint8_t max_bus = pci_bus_num(host->bus);
uint8_t type;
int VAR_0;
for (VAR_0 = 0; VAR_0 < ARRAY_SIZE(host->bus->devices); VAR_0++) {
int i;
uint64_t range_base, range_limit;
PCIDevice *dev = host->bus->devices[VAR_0];
if (!dev) {
continue;
}
for (i = 0; i < PCI_NUM_REGIONS; i++) {
PCIIORegion *r = &dev->io_regions[i];
range_base = r->addr;
range_limit = r->addr + r->size - 1;
if (!range_base || range_base > range_limit) {
continue;
}
if (r->type & PCI_BASE_ADDRESS_SPACE_IO) {
aml_append(crs,
aml_word_io(AML_MIN_FIXED, AML_MAX_FIXED,
AML_POS_DECODE, AML_ENTIRE_RANGE,
0,
range_base,
range_limit,
0,
range_limit - range_base + 1));
crs_range_insert(io_ranges, range_base, range_limit);
} else {
aml_append(crs,
aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED,
AML_MAX_FIXED, AML_NON_CACHEABLE,
AML_READ_WRITE,
0,
range_base,
range_limit,
0,
range_limit - range_base + 1));
crs_range_insert(mem_ranges, range_base, range_limit);
}
}
type = dev->config[PCI_HEADER_TYPE] & ~PCI_HEADER_TYPE_MULTI_FUNCTION;
if (type == PCI_HEADER_TYPE_BRIDGE) {
uint8_t subordinate = dev->config[PCI_SUBORDINATE_BUS];
if (subordinate > max_bus) {
max_bus = subordinate;
}
range_base = pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_IO);
range_limit = pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_IO);
if (range_base || range_base > range_limit) {
aml_append(crs,
aml_word_io(AML_MIN_FIXED, AML_MAX_FIXED,
AML_POS_DECODE, AML_ENTIRE_RANGE,
0,
range_base,
range_limit,
0,
range_limit - range_base + 1));
crs_range_insert(io_ranges, range_base, range_limit);
}
range_base =
pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_MEMORY);
range_limit =
pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_MEMORY);
if (range_base || range_base > range_limit) {
aml_append(crs,
aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED,
AML_MAX_FIXED, AML_NON_CACHEABLE,
AML_READ_WRITE,
0,
range_base,
range_limit,
0,
range_limit - range_base + 1));
crs_range_insert(mem_ranges, range_base, range_limit);
}
range_base =
pci_bridge_get_base(dev, PCI_BASE_ADDRESS_MEM_PREFETCH);
range_limit =
pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_MEM_PREFETCH);
if (range_base || range_base > range_limit) {
aml_append(crs,
aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED,
AML_MAX_FIXED, AML_NON_CACHEABLE,
AML_READ_WRITE,
0,
range_base,
range_limit,
0,
range_limit - range_base + 1));
crs_range_insert(mem_ranges, range_base, range_limit);
}
}
}
aml_append(crs,
aml_word_bus_number(AML_MIN_FIXED, AML_MAX_FIXED, AML_POS_DECODE,
0,
pci_bus_num(host->bus),
max_bus,
0,
max_bus - pci_bus_num(host->bus) + 1));
return crs;
}
| [
"static Aml *FUNC_0(PCIHostState *host,\nGPtrArray *io_ranges, GPtrArray *mem_ranges)\n{",
"Aml *crs = aml_resource_template();",
"uint8_t max_bus = pci_bus_num(host->bus);",
"uint8_t type;",
"int VAR_0;",
"for (VAR_0 = 0; VAR_0 < ARRAY_SIZE(host->bus->devices); VAR_0++) {",
"int i;",
"uint64_t range_base, range_limit;",
"PCIDevice *dev = host->bus->devices[VAR_0];",
"if (!dev) {",
"continue;",
"}",
"for (i = 0; i < PCI_NUM_REGIONS; i++) {",
"PCIIORegion *r = &dev->io_regions[i];",
"range_base = r->addr;",
"range_limit = r->addr + r->size - 1;",
"if (!range_base || range_base > range_limit) {",
"continue;",
"}",
"if (r->type & PCI_BASE_ADDRESS_SPACE_IO) {",
"aml_append(crs,\naml_word_io(AML_MIN_FIXED, AML_MAX_FIXED,\nAML_POS_DECODE, AML_ENTIRE_RANGE,\n0,\nrange_base,\nrange_limit,\n0,\nrange_limit - range_base + 1));",
"crs_range_insert(io_ranges, range_base, range_limit);",
"} else {",
"aml_append(crs,\naml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED,\nAML_MAX_FIXED, AML_NON_CACHEABLE,\nAML_READ_WRITE,\n0,\nrange_base,\nrange_limit,\n0,\nrange_limit - range_base + 1));",
"crs_range_insert(mem_ranges, range_base, range_limit);",
"}",
"}",
"type = dev->config[PCI_HEADER_TYPE] & ~PCI_HEADER_TYPE_MULTI_FUNCTION;",
"if (type == PCI_HEADER_TYPE_BRIDGE) {",
"uint8_t subordinate = dev->config[PCI_SUBORDINATE_BUS];",
"if (subordinate > max_bus) {",
"max_bus = subordinate;",
"}",
"range_base = pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_IO);",
"range_limit = pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_IO);",
"if (range_base || range_base > range_limit) {",
"aml_append(crs,\naml_word_io(AML_MIN_FIXED, AML_MAX_FIXED,\nAML_POS_DECODE, AML_ENTIRE_RANGE,\n0,\nrange_base,\nrange_limit,\n0,\nrange_limit - range_base + 1));",
"crs_range_insert(io_ranges, range_base, range_limit);",
"}",
"range_base =\npci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_MEMORY);",
"range_limit =\npci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_MEMORY);",
"if (range_base || range_base > range_limit) {",
"aml_append(crs,\naml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED,\nAML_MAX_FIXED, AML_NON_CACHEABLE,\nAML_READ_WRITE,\n0,\nrange_base,\nrange_limit,\n0,\nrange_limit - range_base + 1));",
"crs_range_insert(mem_ranges, range_base, range_limit);",
"}",
"range_base =\npci_bridge_get_base(dev, PCI_BASE_ADDRESS_MEM_PREFETCH);",
"range_limit =\npci_bridge_get_limit(dev, PCI_BASE_ADDRESS_MEM_PREFETCH);",
"if (range_base || range_base > range_limit) {",
"aml_append(crs,\naml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED,\nAML_MAX_FIXED, AML_NON_CACHEABLE,\nAML_READ_WRITE,\n0,\nrange_base,\nrange_limit,\n0,\nrange_limit - range_base + 1));",
"crs_range_insert(mem_ranges, range_base, range_limit);",
"}",
"}",
"}",
"aml_append(crs,\naml_word_bus_number(AML_MIN_FIXED, AML_MAX_FIXED, AML_POS_DECODE,\n0,\npci_bus_num(host->bus),\nmax_bus,\n0,\nmax_bus - pci_bus_num(host->bus) + 1));",
"return crs;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
41
],
[
43
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65,
67,
69,
71,
73,
75,
77,
79
],
[
81
],
[
83
],
[
85,
87,
89,
91,
93,
95,
97,
99,
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
139
],
[
141,
143,
145,
147,
149,
151,
153,
155
],
[
157
],
[
159
],
[
163,
165
],
[
167,
169
],
[
181
],
[
183,
185,
187,
189,
191,
193,
195,
197,
199
],
[
201
],
[
203
],
[
207,
209
],
[
211,
213
],
[
225
],
[
227,
229,
231,
233,
235,
237,
239,
241,
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
255,
257,
259,
261,
263,
265,
267
],
[
271
],
[
273
]
] |
26,782 | static int escc_init1(SysBusDevice *dev)
{
ESCCState *s = ESCC(dev);
unsigned int i;
s->chn[0].disabled = s->disabled;
s->chn[1].disabled = s->disabled;
for (i = 0; i < 2; i++) {
sysbus_init_irq(dev, &s->chn[i].irq);
s->chn[i].chn = 1 - i;
s->chn[i].clock = s->frequency / 2;
if (s->chn[i].chr) {
qemu_chr_add_handlers(s->chn[i].chr, serial_can_receive,
serial_receive1, serial_event, &s->chn[i]);
}
}
s->chn[0].otherchn = &s->chn[1];
s->chn[1].otherchn = &s->chn[0];
memory_region_init_io(&s->mmio, OBJECT(s), &escc_mem_ops, s, "escc",
ESCC_SIZE << s->it_shift);
sysbus_init_mmio(dev, &s->mmio);
if (s->chn[0].type == mouse) {
qemu_add_mouse_event_handler(sunmouse_event, &s->chn[0], 0,
"QEMU Sun Mouse");
}
if (s->chn[1].type == kbd) {
qemu_add_kbd_event_handler(sunkbd_event, &s->chn[1]);
}
return 0;
}
| false | qemu | 65e7545ea3c65a6468fb59418a6dbe66ef71d6d1 | static int escc_init1(SysBusDevice *dev)
{
ESCCState *s = ESCC(dev);
unsigned int i;
s->chn[0].disabled = s->disabled;
s->chn[1].disabled = s->disabled;
for (i = 0; i < 2; i++) {
sysbus_init_irq(dev, &s->chn[i].irq);
s->chn[i].chn = 1 - i;
s->chn[i].clock = s->frequency / 2;
if (s->chn[i].chr) {
qemu_chr_add_handlers(s->chn[i].chr, serial_can_receive,
serial_receive1, serial_event, &s->chn[i]);
}
}
s->chn[0].otherchn = &s->chn[1];
s->chn[1].otherchn = &s->chn[0];
memory_region_init_io(&s->mmio, OBJECT(s), &escc_mem_ops, s, "escc",
ESCC_SIZE << s->it_shift);
sysbus_init_mmio(dev, &s->mmio);
if (s->chn[0].type == mouse) {
qemu_add_mouse_event_handler(sunmouse_event, &s->chn[0], 0,
"QEMU Sun Mouse");
}
if (s->chn[1].type == kbd) {
qemu_add_kbd_event_handler(sunkbd_event, &s->chn[1]);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(SysBusDevice *VAR_0)
{
ESCCState *s = ESCC(VAR_0);
unsigned int VAR_1;
s->chn[0].disabled = s->disabled;
s->chn[1].disabled = s->disabled;
for (VAR_1 = 0; VAR_1 < 2; VAR_1++) {
sysbus_init_irq(VAR_0, &s->chn[VAR_1].irq);
s->chn[VAR_1].chn = 1 - VAR_1;
s->chn[VAR_1].clock = s->frequency / 2;
if (s->chn[VAR_1].chr) {
qemu_chr_add_handlers(s->chn[VAR_1].chr, serial_can_receive,
serial_receive1, serial_event, &s->chn[VAR_1]);
}
}
s->chn[0].otherchn = &s->chn[1];
s->chn[1].otherchn = &s->chn[0];
memory_region_init_io(&s->mmio, OBJECT(s), &escc_mem_ops, s, "escc",
ESCC_SIZE << s->it_shift);
sysbus_init_mmio(VAR_0, &s->mmio);
if (s->chn[0].type == mouse) {
qemu_add_mouse_event_handler(sunmouse_event, &s->chn[0], 0,
"QEMU Sun Mouse");
}
if (s->chn[1].type == kbd) {
qemu_add_kbd_event_handler(sunkbd_event, &s->chn[1]);
}
return 0;
}
| [
"static int FUNC_0(SysBusDevice *VAR_0)\n{",
"ESCCState *s = ESCC(VAR_0);",
"unsigned int VAR_1;",
"s->chn[0].disabled = s->disabled;",
"s->chn[1].disabled = s->disabled;",
"for (VAR_1 = 0; VAR_1 < 2; VAR_1++) {",
"sysbus_init_irq(VAR_0, &s->chn[VAR_1].irq);",
"s->chn[VAR_1].chn = 1 - VAR_1;",
"s->chn[VAR_1].clock = s->frequency / 2;",
"if (s->chn[VAR_1].chr) {",
"qemu_chr_add_handlers(s->chn[VAR_1].chr, serial_can_receive,\nserial_receive1, serial_event, &s->chn[VAR_1]);",
"}",
"}",
"s->chn[0].otherchn = &s->chn[1];",
"s->chn[1].otherchn = &s->chn[0];",
"memory_region_init_io(&s->mmio, OBJECT(s), &escc_mem_ops, s, \"escc\",\nESCC_SIZE << s->it_shift);",
"sysbus_init_mmio(VAR_0, &s->mmio);",
"if (s->chn[0].type == mouse) {",
"qemu_add_mouse_event_handler(sunmouse_event, &s->chn[0], 0,\n\"QEMU Sun Mouse\");",
"}",
"if (s->chn[1].type == kbd) {",
"qemu_add_kbd_event_handler(sunkbd_event, &s->chn[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
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39,
41
],
[
43
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
]
] |
26,783 | void aio_bh_update_timeout(AioContext *ctx, uint32_t *timeout)
{
QEMUBH *bh;
for (bh = ctx->first_bh; bh; bh = bh->next) {
if (!bh->deleted && bh->scheduled) {
if (bh->idle) {
/* idle bottom halves will be polled at least
* every 10ms */
*timeout = MIN(10, *timeout);
} else {
/* non-idle bottom halves will be executed
* immediately */
*timeout = 0;
break;
}
}
}
}
| false | qemu | 22bfa75eafc21522afbb265091faa9cc0649e9fb | void aio_bh_update_timeout(AioContext *ctx, uint32_t *timeout)
{
QEMUBH *bh;
for (bh = ctx->first_bh; bh; bh = bh->next) {
if (!bh->deleted && bh->scheduled) {
if (bh->idle) {
*timeout = MIN(10, *timeout);
} else {
*timeout = 0;
break;
}
}
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(AioContext *VAR_0, uint32_t *VAR_1)
{
QEMUBH *bh;
for (bh = VAR_0->first_bh; bh; bh = bh->next) {
if (!bh->deleted && bh->scheduled) {
if (bh->idle) {
*VAR_1 = MIN(10, *VAR_1);
} else {
*VAR_1 = 0;
break;
}
}
}
}
| [
"void FUNC_0(AioContext *VAR_0, uint32_t *VAR_1)\n{",
"QEMUBH *bh;",
"for (bh = VAR_0->first_bh; bh; bh = bh->next) {",
"if (!bh->deleted && bh->scheduled) {",
"if (bh->idle) {",
"*VAR_1 = MIN(10, *VAR_1);",
"} else {",
"*VAR_1 = 0;",
"break;",
"}",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
19
],
[
21
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
]
] |
26,784 | void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f,
ImageInfoSpecific *info_spec)
{
QObject *obj, *data;
Visitor *v = qobject_output_visitor_new(&obj);
visit_type_ImageInfoSpecific(v, NULL, &info_spec, &error_abort);
visit_complete(v, &obj);
assert(qobject_type(obj) == QTYPE_QDICT);
data = qdict_get(qobject_to_qdict(obj), "data");
dump_qobject(func_fprintf, f, 1, data);
qobject_decref(obj);
visit_free(v);
}
| false | qemu | 7c81e4e9db5f63635fbf11d66bf08e73d325ae97 | void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f,
ImageInfoSpecific *info_spec)
{
QObject *obj, *data;
Visitor *v = qobject_output_visitor_new(&obj);
visit_type_ImageInfoSpecific(v, NULL, &info_spec, &error_abort);
visit_complete(v, &obj);
assert(qobject_type(obj) == QTYPE_QDICT);
data = qdict_get(qobject_to_qdict(obj), "data");
dump_qobject(func_fprintf, f, 1, data);
qobject_decref(obj);
visit_free(v);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(fprintf_function VAR_0, void *VAR_1,
ImageInfoSpecific *VAR_2)
{
QObject *obj, *data;
Visitor *v = qobject_output_visitor_new(&obj);
visit_type_ImageInfoSpecific(v, NULL, &VAR_2, &error_abort);
visit_complete(v, &obj);
assert(qobject_type(obj) == QTYPE_QDICT);
data = qdict_get(qobject_to_qdict(obj), "data");
dump_qobject(VAR_0, VAR_1, 1, data);
qobject_decref(obj);
visit_free(v);
}
| [
"void FUNC_0(fprintf_function VAR_0, void *VAR_1,\nImageInfoSpecific *VAR_2)\n{",
"QObject *obj, *data;",
"Visitor *v = qobject_output_visitor_new(&obj);",
"visit_type_ImageInfoSpecific(v, NULL, &VAR_2, &error_abort);",
"visit_complete(v, &obj);",
"assert(qobject_type(obj) == QTYPE_QDICT);",
"data = qdict_get(qobject_to_qdict(obj), \"data\");",
"dump_qobject(VAR_0, VAR_1, 1, data);",
"qobject_decref(obj);",
"visit_free(v);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
26,785 | static mfxIMPL choose_implementation(const InputStream *ist)
{
static const struct {
const char *name;
mfxIMPL impl;
} impl_map[] = {
{ "auto", MFX_IMPL_AUTO },
{ "sw", MFX_IMPL_SOFTWARE },
{ "hw", MFX_IMPL_HARDWARE },
{ "auto_any", MFX_IMPL_AUTO_ANY },
{ "hw_any", MFX_IMPL_HARDWARE_ANY },
{ "hw2", MFX_IMPL_HARDWARE2 },
{ "hw3", MFX_IMPL_HARDWARE3 },
{ "hw4", MFX_IMPL_HARDWARE4 },
};
mfxIMPL impl = MFX_IMPL_AUTO_ANY;
int i;
if (ist->hwaccel_device) {
for (i = 0; i < FF_ARRAY_ELEMS(impl_map); i++)
if (!strcmp(ist->hwaccel_device, impl_map[i].name)) {
impl = impl_map[i].impl;
break;
}
if (i == FF_ARRAY_ELEMS(impl_map))
impl = strtol(ist->hwaccel_device, NULL, 0);
}
return impl;
}
| false | FFmpeg | 03cef34aa66662e2ab3681d290e7c5a6634f4058 | static mfxIMPL choose_implementation(const InputStream *ist)
{
static const struct {
const char *name;
mfxIMPL impl;
} impl_map[] = {
{ "auto", MFX_IMPL_AUTO },
{ "sw", MFX_IMPL_SOFTWARE },
{ "hw", MFX_IMPL_HARDWARE },
{ "auto_any", MFX_IMPL_AUTO_ANY },
{ "hw_any", MFX_IMPL_HARDWARE_ANY },
{ "hw2", MFX_IMPL_HARDWARE2 },
{ "hw3", MFX_IMPL_HARDWARE3 },
{ "hw4", MFX_IMPL_HARDWARE4 },
};
mfxIMPL impl = MFX_IMPL_AUTO_ANY;
int i;
if (ist->hwaccel_device) {
for (i = 0; i < FF_ARRAY_ELEMS(impl_map); i++)
if (!strcmp(ist->hwaccel_device, impl_map[i].name)) {
impl = impl_map[i].impl;
break;
}
if (i == FF_ARRAY_ELEMS(impl_map))
impl = strtol(ist->hwaccel_device, NULL, 0);
}
return impl;
}
| {
"code": [],
"line_no": []
} | static mfxIMPL FUNC_0(const InputStream *ist)
{
static const struct {
const char *name;
mfxIMPL impl;
} VAR_0[] = {
{ "auto", MFX_IMPL_AUTO },
{ "sw", MFX_IMPL_SOFTWARE },
{ "hw", MFX_IMPL_HARDWARE },
{ "auto_any", MFX_IMPL_AUTO_ANY },
{ "hw_any", MFX_IMPL_HARDWARE_ANY },
{ "hw2", MFX_IMPL_HARDWARE2 },
{ "hw3", MFX_IMPL_HARDWARE3 },
{ "hw4", MFX_IMPL_HARDWARE4 },
};
mfxIMPL impl = MFX_IMPL_AUTO_ANY;
int VAR_1;
if (ist->hwaccel_device) {
for (VAR_1 = 0; VAR_1 < FF_ARRAY_ELEMS(VAR_0); VAR_1++)
if (!strcmp(ist->hwaccel_device, VAR_0[VAR_1].name)) {
impl = VAR_0[VAR_1].impl;
break;
}
if (VAR_1 == FF_ARRAY_ELEMS(VAR_0))
impl = strtol(ist->hwaccel_device, NULL, 0);
}
return impl;
}
| [
"static mfxIMPL FUNC_0(const InputStream *ist)\n{",
"static const struct {",
"const char *name;",
"mfxIMPL impl;",
"} VAR_0[] = {",
"{ \"auto\", MFX_IMPL_AUTO },",
"{ \"sw\", MFX_IMPL_SOFTWARE },",
"{ \"hw\", MFX_IMPL_HARDWARE },",
"{ \"auto_any\", MFX_IMPL_AUTO_ANY },",
"{ \"hw_any\", MFX_IMPL_HARDWARE_ANY },",
"{ \"hw2\", MFX_IMPL_HARDWARE2 },",
"{ \"hw3\", MFX_IMPL_HARDWARE3 },",
"{ \"hw4\", MFX_IMPL_HARDWARE4 },",
"};",
"mfxIMPL impl = MFX_IMPL_AUTO_ANY;",
"int VAR_1;",
"if (ist->hwaccel_device) {",
"for (VAR_1 = 0; VAR_1 < FF_ARRAY_ELEMS(VAR_0); VAR_1++)",
"if (!strcmp(ist->hwaccel_device, VAR_0[VAR_1].name)) {",
"impl = VAR_0[VAR_1].impl;",
"break;",
"}",
"if (VAR_1 == FF_ARRAY_ELEMS(VAR_0))\nimpl = strtol(ist->hwaccel_device, NULL, 0);",
"}",
"return impl;",
"}"
] | [
0,
0,
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
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51,
53
],
[
55
],
[
59
],
[
61
]
] |
26,786 | SocketAddress *socket_address_crumple(SocketAddressFlat *addr_flat)
{
SocketAddress *addr = g_new(SocketAddress, 1);
switch (addr_flat->type) {
case SOCKET_ADDRESS_FLAT_TYPE_INET:
addr->type = SOCKET_ADDRESS_KIND_INET;
addr->u.inet.data = QAPI_CLONE(InetSocketAddress,
&addr_flat->u.inet);
break;
case SOCKET_ADDRESS_FLAT_TYPE_UNIX:
addr->type = SOCKET_ADDRESS_KIND_UNIX;
addr->u.q_unix.data = QAPI_CLONE(UnixSocketAddress,
&addr_flat->u.q_unix);
break;
case SOCKET_ADDRESS_FLAT_TYPE_VSOCK:
addr->type = SOCKET_ADDRESS_KIND_VSOCK;
addr->u.vsock.data = QAPI_CLONE(VsockSocketAddress,
&addr_flat->u.vsock);
break;
case SOCKET_ADDRESS_FLAT_TYPE_FD:
addr->type = SOCKET_ADDRESS_KIND_FD;
addr->u.fd.data = QAPI_CLONE(String, &addr_flat->u.fd);
break;
default:
abort();
}
return addr;
}
| false | qemu | dfd100f242370886bb6732f70f1f7cbd8eb9fedc | SocketAddress *socket_address_crumple(SocketAddressFlat *addr_flat)
{
SocketAddress *addr = g_new(SocketAddress, 1);
switch (addr_flat->type) {
case SOCKET_ADDRESS_FLAT_TYPE_INET:
addr->type = SOCKET_ADDRESS_KIND_INET;
addr->u.inet.data = QAPI_CLONE(InetSocketAddress,
&addr_flat->u.inet);
break;
case SOCKET_ADDRESS_FLAT_TYPE_UNIX:
addr->type = SOCKET_ADDRESS_KIND_UNIX;
addr->u.q_unix.data = QAPI_CLONE(UnixSocketAddress,
&addr_flat->u.q_unix);
break;
case SOCKET_ADDRESS_FLAT_TYPE_VSOCK:
addr->type = SOCKET_ADDRESS_KIND_VSOCK;
addr->u.vsock.data = QAPI_CLONE(VsockSocketAddress,
&addr_flat->u.vsock);
break;
case SOCKET_ADDRESS_FLAT_TYPE_FD:
addr->type = SOCKET_ADDRESS_KIND_FD;
addr->u.fd.data = QAPI_CLONE(String, &addr_flat->u.fd);
break;
default:
abort();
}
return addr;
}
| {
"code": [],
"line_no": []
} | SocketAddress *FUNC_0(SocketAddressFlat *addr_flat)
{
SocketAddress *addr = g_new(SocketAddress, 1);
switch (addr_flat->type) {
case SOCKET_ADDRESS_FLAT_TYPE_INET:
addr->type = SOCKET_ADDRESS_KIND_INET;
addr->u.inet.data = QAPI_CLONE(InetSocketAddress,
&addr_flat->u.inet);
break;
case SOCKET_ADDRESS_FLAT_TYPE_UNIX:
addr->type = SOCKET_ADDRESS_KIND_UNIX;
addr->u.q_unix.data = QAPI_CLONE(UnixSocketAddress,
&addr_flat->u.q_unix);
break;
case SOCKET_ADDRESS_FLAT_TYPE_VSOCK:
addr->type = SOCKET_ADDRESS_KIND_VSOCK;
addr->u.vsock.data = QAPI_CLONE(VsockSocketAddress,
&addr_flat->u.vsock);
break;
case SOCKET_ADDRESS_FLAT_TYPE_FD:
addr->type = SOCKET_ADDRESS_KIND_FD;
addr->u.fd.data = QAPI_CLONE(String, &addr_flat->u.fd);
break;
default:
abort();
}
return addr;
}
| [
"SocketAddress *FUNC_0(SocketAddressFlat *addr_flat)\n{",
"SocketAddress *addr = g_new(SocketAddress, 1);",
"switch (addr_flat->type) {",
"case SOCKET_ADDRESS_FLAT_TYPE_INET:\naddr->type = SOCKET_ADDRESS_KIND_INET;",
"addr->u.inet.data = QAPI_CLONE(InetSocketAddress,\n&addr_flat->u.inet);",
"break;",
"case SOCKET_ADDRESS_FLAT_TYPE_UNIX:\naddr->type = SOCKET_ADDRESS_KIND_UNIX;",
"addr->u.q_unix.data = QAPI_CLONE(UnixSocketAddress,\n&addr_flat->u.q_unix);",
"break;",
"case SOCKET_ADDRESS_FLAT_TYPE_VSOCK:\naddr->type = SOCKET_ADDRESS_KIND_VSOCK;",
"addr->u.vsock.data = QAPI_CLONE(VsockSocketAddress,\n&addr_flat->u.vsock);",
"break;",
"case SOCKET_ADDRESS_FLAT_TYPE_FD:\naddr->type = SOCKET_ADDRESS_KIND_FD;",
"addr->u.fd.data = QAPI_CLONE(String, &addr_flat->u.fd);",
"break;",
"default:\nabort();",
"}",
"return addr;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
15,
17
],
[
19
],
[
21,
23
],
[
25,
27
],
[
29
],
[
31,
33
],
[
35,
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49,
51
],
[
53
],
[
57
],
[
59
]
] |
26,787 | void aio_set_event_notifier(AioContext *ctx,
EventNotifier *e,
EventNotifierHandler *io_notify)
{
AioHandler *node;
QLIST_FOREACH(node, &ctx->aio_handlers, node) {
if (node->e == e && !node->deleted) {
break;
}
}
/* Are we deleting the fd handler? */
if (!io_notify) {
if (node) {
g_source_remove_poll(&ctx->source, &node->pfd);
/* If the lock is held, just mark the node as deleted */
if (ctx->walking_handlers) {
node->deleted = 1;
node->pfd.revents = 0;
} 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->e = e;
node->pfd.fd = (uintptr_t)event_notifier_get_handle(e);
node->pfd.events = G_IO_IN;
QLIST_INSERT_HEAD(&ctx->aio_handlers, node, node);
g_source_add_poll(&ctx->source, &node->pfd);
}
/* Update handler with latest information */
node->io_notify = io_notify;
}
aio_notify(ctx);
}
| false | qemu | 3ba235a02284c39b34a68a2a588508ffb52a7b55 | void aio_set_event_notifier(AioContext *ctx,
EventNotifier *e,
EventNotifierHandler *io_notify)
{
AioHandler *node;
QLIST_FOREACH(node, &ctx->aio_handlers, node) {
if (node->e == e && !node->deleted) {
break;
}
}
if (!io_notify) {
if (node) {
g_source_remove_poll(&ctx->source, &node->pfd);
if (ctx->walking_handlers) {
node->deleted = 1;
node->pfd.revents = 0;
} else {
QLIST_REMOVE(node, node);
g_free(node);
}
}
} else {
if (node == NULL) {
node = g_malloc0(sizeof(AioHandler));
node->e = e;
node->pfd.fd = (uintptr_t)event_notifier_get_handle(e);
node->pfd.events = G_IO_IN;
QLIST_INSERT_HEAD(&ctx->aio_handlers, node, node);
g_source_add_poll(&ctx->source, &node->pfd);
}
node->io_notify = io_notify;
}
aio_notify(ctx);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(AioContext *VAR_0,
EventNotifier *VAR_1,
EventNotifierHandler *VAR_2)
{
AioHandler *node;
QLIST_FOREACH(node, &VAR_0->aio_handlers, node) {
if (node->VAR_1 == VAR_1 && !node->deleted) {
break;
}
}
if (!VAR_2) {
if (node) {
g_source_remove_poll(&VAR_0->source, &node->pfd);
if (VAR_0->walking_handlers) {
node->deleted = 1;
node->pfd.revents = 0;
} else {
QLIST_REMOVE(node, node);
g_free(node);
}
}
} else {
if (node == NULL) {
node = g_malloc0(sizeof(AioHandler));
node->VAR_1 = VAR_1;
node->pfd.fd = (uintptr_t)event_notifier_get_handle(VAR_1);
node->pfd.events = G_IO_IN;
QLIST_INSERT_HEAD(&VAR_0->aio_handlers, node, node);
g_source_add_poll(&VAR_0->source, &node->pfd);
}
node->VAR_2 = VAR_2;
}
aio_notify(VAR_0);
}
| [
"void FUNC_0(AioContext *VAR_0,\nEventNotifier *VAR_1,\nEventNotifierHandler *VAR_2)\n{",
"AioHandler *node;",
"QLIST_FOREACH(node, &VAR_0->aio_handlers, node) {",
"if (node->VAR_1 == VAR_1 && !node->deleted) {",
"break;",
"}",
"}",
"if (!VAR_2) {",
"if (node) {",
"g_source_remove_poll(&VAR_0->source, &node->pfd);",
"if (VAR_0->walking_handlers) {",
"node->deleted = 1;",
"node->pfd.revents = 0;",
"} else {",
"QLIST_REMOVE(node, node);",
"g_free(node);",
"}",
"}",
"} else {",
"if (node == NULL) {",
"node = g_malloc0(sizeof(AioHandler));",
"node->VAR_1 = VAR_1;",
"node->pfd.fd = (uintptr_t)event_notifier_get_handle(VAR_1);",
"node->pfd.events = G_IO_IN;",
"QLIST_INSERT_HEAD(&VAR_0->aio_handlers, node, node);",
"g_source_add_poll(&VAR_0->source, &node->pfd);",
"}",
"node->VAR_2 = VAR_2;",
"}",
"aio_notify(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
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
27
],
[
29
],
[
31
],
[
37
],
[
39
],
[
41
],
[
43
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
85
],
[
87
],
[
91
],
[
93
]
] |
26,788 | static void uhci_fill_queue(UHCIState *s, UHCI_TD *td)
{
uint32_t int_mask = 0;
uint32_t plink = td->link;
uint32_t token = uhci_queue_token(td);
UHCI_TD ptd;
int ret;
while (is_valid(plink)) {
pci_dma_read(&s->dev, plink & ~0xf, &ptd, sizeof(ptd));
le32_to_cpus(&ptd.link);
le32_to_cpus(&ptd.ctrl);
le32_to_cpus(&ptd.token);
le32_to_cpus(&ptd.buffer);
if (!(ptd.ctrl & TD_CTRL_ACTIVE)) {
break;
}
if (uhci_queue_token(&ptd) != token) {
break;
}
trace_usb_uhci_td_queue(plink & ~0xf, ptd.ctrl, ptd.token);
ret = uhci_handle_td(s, plink, &ptd, &int_mask, true);
if (ret == TD_RESULT_ASYNC_CONT) {
break;
}
assert(ret == TD_RESULT_ASYNC_START);
assert(int_mask == 0);
if (ptd.ctrl & TD_CTRL_SPD) {
break;
}
plink = ptd.link;
}
}
| false | qemu | 7c2eaca4efa46e02caaec4ca7ddf05a6e461da94 | static void uhci_fill_queue(UHCIState *s, UHCI_TD *td)
{
uint32_t int_mask = 0;
uint32_t plink = td->link;
uint32_t token = uhci_queue_token(td);
UHCI_TD ptd;
int ret;
while (is_valid(plink)) {
pci_dma_read(&s->dev, plink & ~0xf, &ptd, sizeof(ptd));
le32_to_cpus(&ptd.link);
le32_to_cpus(&ptd.ctrl);
le32_to_cpus(&ptd.token);
le32_to_cpus(&ptd.buffer);
if (!(ptd.ctrl & TD_CTRL_ACTIVE)) {
break;
}
if (uhci_queue_token(&ptd) != token) {
break;
}
trace_usb_uhci_td_queue(plink & ~0xf, ptd.ctrl, ptd.token);
ret = uhci_handle_td(s, plink, &ptd, &int_mask, true);
if (ret == TD_RESULT_ASYNC_CONT) {
break;
}
assert(ret == TD_RESULT_ASYNC_START);
assert(int_mask == 0);
if (ptd.ctrl & TD_CTRL_SPD) {
break;
}
plink = ptd.link;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(UHCIState *VAR_0, UHCI_TD *VAR_1)
{
uint32_t int_mask = 0;
uint32_t plink = VAR_1->link;
uint32_t token = uhci_queue_token(VAR_1);
UHCI_TD ptd;
int VAR_2;
while (is_valid(plink)) {
pci_dma_read(&VAR_0->dev, plink & ~0xf, &ptd, sizeof(ptd));
le32_to_cpus(&ptd.link);
le32_to_cpus(&ptd.ctrl);
le32_to_cpus(&ptd.token);
le32_to_cpus(&ptd.buffer);
if (!(ptd.ctrl & TD_CTRL_ACTIVE)) {
break;
}
if (uhci_queue_token(&ptd) != token) {
break;
}
trace_usb_uhci_td_queue(plink & ~0xf, ptd.ctrl, ptd.token);
VAR_2 = uhci_handle_td(VAR_0, plink, &ptd, &int_mask, true);
if (VAR_2 == TD_RESULT_ASYNC_CONT) {
break;
}
assert(VAR_2 == TD_RESULT_ASYNC_START);
assert(int_mask == 0);
if (ptd.ctrl & TD_CTRL_SPD) {
break;
}
plink = ptd.link;
}
}
| [
"static void FUNC_0(UHCIState *VAR_0, UHCI_TD *VAR_1)\n{",
"uint32_t int_mask = 0;",
"uint32_t plink = VAR_1->link;",
"uint32_t token = uhci_queue_token(VAR_1);",
"UHCI_TD ptd;",
"int VAR_2;",
"while (is_valid(plink)) {",
"pci_dma_read(&VAR_0->dev, plink & ~0xf, &ptd, sizeof(ptd));",
"le32_to_cpus(&ptd.link);",
"le32_to_cpus(&ptd.ctrl);",
"le32_to_cpus(&ptd.token);",
"le32_to_cpus(&ptd.buffer);",
"if (!(ptd.ctrl & TD_CTRL_ACTIVE)) {",
"break;",
"}",
"if (uhci_queue_token(&ptd) != token) {",
"break;",
"}",
"trace_usb_uhci_td_queue(plink & ~0xf, ptd.ctrl, ptd.token);",
"VAR_2 = uhci_handle_td(VAR_0, plink, &ptd, &int_mask, true);",
"if (VAR_2 == TD_RESULT_ASYNC_CONT) {",
"break;",
"}",
"assert(VAR_2 == TD_RESULT_ASYNC_START);",
"assert(int_mask == 0);",
"if (ptd.ctrl & TD_CTRL_SPD) {",
"break;",
"}",
"plink = ptd.link;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
]
] |
26,789 | static inline int get_segment(CPUPPCState *env, mmu_ctx_t *ctx,
target_ulong eaddr, int rw, int type)
{
hwaddr hash;
target_ulong vsid;
int ds, pr, target_page_bits;
int ret, ret2;
pr = msr_pr;
ctx->eaddr = eaddr;
#if defined(TARGET_PPC64)
if (env->mmu_model & POWERPC_MMU_64) {
ppc_slb_t *slb;
target_ulong pageaddr;
int segment_bits;
LOG_MMU("Check SLBs\n");
slb = slb_lookup(env, eaddr);
if (!slb) {
return -5;
}
if (slb->vsid & SLB_VSID_B) {
vsid = (slb->vsid & SLB_VSID_VSID) >> SLB_VSID_SHIFT_1T;
segment_bits = 40;
} else {
vsid = (slb->vsid & SLB_VSID_VSID) >> SLB_VSID_SHIFT;
segment_bits = 28;
}
target_page_bits = (slb->vsid & SLB_VSID_L)
? TARGET_PAGE_BITS_16M : TARGET_PAGE_BITS;
ctx->key = !!(pr ? (slb->vsid & SLB_VSID_KP)
: (slb->vsid & SLB_VSID_KS));
ds = 0;
ctx->nx = !!(slb->vsid & SLB_VSID_N);
pageaddr = eaddr & ((1ULL << segment_bits)
- (1ULL << target_page_bits));
if (slb->vsid & SLB_VSID_B) {
hash = vsid ^ (vsid << 25) ^ (pageaddr >> target_page_bits);
} else {
hash = vsid ^ (pageaddr >> target_page_bits);
}
/* Only 5 bits of the page index are used in the AVPN */
ctx->ptem = (slb->vsid & SLB_VSID_PTEM) |
((pageaddr >> 16) & ((1ULL << segment_bits) - 0x80));
} else
#endif /* defined(TARGET_PPC64) */
{
target_ulong sr, pgidx;
sr = env->sr[eaddr >> 28];
ctx->key = (((sr & 0x20000000) && (pr != 0)) ||
((sr & 0x40000000) && (pr == 0))) ? 1 : 0;
ds = sr & 0x80000000 ? 1 : 0;
ctx->nx = sr & 0x10000000 ? 1 : 0;
vsid = sr & 0x00FFFFFF;
target_page_bits = TARGET_PAGE_BITS;
LOG_MMU("Check segment v=" TARGET_FMT_lx " %d " TARGET_FMT_lx " nip="
TARGET_FMT_lx " lr=" TARGET_FMT_lx
" ir=%d dr=%d pr=%d %d t=%d\n",
eaddr, (int)(eaddr >> 28), sr, env->nip, env->lr, (int)msr_ir,
(int)msr_dr, pr != 0 ? 1 : 0, rw, type);
pgidx = (eaddr & ~SEGMENT_MASK_256M) >> target_page_bits;
hash = vsid ^ pgidx;
ctx->ptem = (vsid << 7) | (pgidx >> 10);
}
LOG_MMU("pte segment: key=%d ds %d nx %d vsid " TARGET_FMT_lx "\n",
ctx->key, ds, ctx->nx, vsid);
ret = -1;
if (!ds) {
/* Check if instruction fetch is allowed, if needed */
if (type != ACCESS_CODE || ctx->nx == 0) {
/* Page address translation */
LOG_MMU("htab_base " TARGET_FMT_plx " htab_mask " TARGET_FMT_plx
" hash " TARGET_FMT_plx "\n",
env->htab_base, env->htab_mask, hash);
ctx->hash[0] = hash;
ctx->hash[1] = ~hash;
/* Initialize real address with an invalid value */
ctx->raddr = (hwaddr)-1ULL;
if (unlikely(env->mmu_model == POWERPC_MMU_SOFT_6xx ||
env->mmu_model == POWERPC_MMU_SOFT_74xx)) {
/* Software TLB search */
ret = ppc6xx_tlb_check(env, ctx, eaddr, rw, type);
} else {
LOG_MMU("0 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=" TARGET_FMT_lx " ptem=" TARGET_FMT_lx
" hash=" TARGET_FMT_plx "\n",
env->htab_base, env->htab_mask, vsid, ctx->ptem,
ctx->hash[0]);
/* Primary table lookup */
ret = find_pte(env, ctx, 0, rw, type, target_page_bits);
if (ret < 0) {
/* Secondary table lookup */
if (eaddr != 0xEFFFFFFF) {
LOG_MMU("1 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=" TARGET_FMT_lx " api=" TARGET_FMT_lx
" hash=" TARGET_FMT_plx "\n", env->htab_base,
env->htab_mask, vsid, ctx->ptem, ctx->hash[1]);
}
ret2 = find_pte(env, ctx, 1, rw, type,
target_page_bits);
if (ret2 != -1) {
ret = ret2;
}
}
}
#if defined(DUMP_PAGE_TABLES)
if (qemu_log_enabled()) {
hwaddr curaddr;
uint32_t a0, a1, a2, a3;
qemu_log("Page table: " TARGET_FMT_plx " len " TARGET_FMT_plx
"\n", sdr, mask + 0x80);
for (curaddr = sdr; curaddr < (sdr + mask + 0x80);
curaddr += 16) {
a0 = ldl_phys(curaddr);
a1 = ldl_phys(curaddr + 4);
a2 = ldl_phys(curaddr + 8);
a3 = ldl_phys(curaddr + 12);
if (a0 != 0 || a1 != 0 || a2 != 0 || a3 != 0) {
qemu_log(TARGET_FMT_plx ": %08x %08x %08x %08x\n",
curaddr, a0, a1, a2, a3);
}
}
}
#endif
} else {
LOG_MMU("No access allowed\n");
ret = -3;
}
} else {
target_ulong sr;
LOG_MMU("direct store...\n");
/* Direct-store segment : absolutely *BUGGY* for now */
/* Direct-store implies a 32-bit MMU.
* Check the Segment Register's bus unit ID (BUID).
*/
sr = env->sr[eaddr >> 28];
if ((sr & 0x1FF00000) >> 20 == 0x07f) {
/* Memory-forced I/O controller interface access */
/* If T=1 and BUID=x'07F', the 601 performs a memory access
* to SR[28-31] LA[4-31], bypassing all protection mechanisms.
*/
ctx->raddr = ((sr & 0xF) << 28) | (eaddr & 0x0FFFFFFF);
ctx->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
return 0;
}
switch (type) {
case ACCESS_INT:
/* Integer load/store : only access allowed */
break;
case ACCESS_CODE:
/* No code fetch is allowed in direct-store areas */
return -4;
case ACCESS_FLOAT:
/* Floating point load/store */
return -4;
case ACCESS_RES:
/* lwarx, ldarx or srwcx. */
return -4;
case ACCESS_CACHE:
/* dcba, dcbt, dcbtst, dcbf, dcbi, dcbst, dcbz, or icbi */
/* Should make the instruction do no-op.
* As it already do no-op, it's quite easy :-)
*/
ctx->raddr = eaddr;
return 0;
case ACCESS_EXT:
/* eciwx or ecowx */
return -4;
default:
qemu_log("ERROR: instruction should not need "
"address translation\n");
return -4;
}
if ((rw == 1 || ctx->key != 1) && (rw == 0 || ctx->key != 0)) {
ctx->raddr = eaddr;
ret = 2;
} else {
ret = -2;
}
}
return ret;
}
| false | qemu | 8152ceaf6eea6d63f6ee65eb419fff56bb3b987b | static inline int get_segment(CPUPPCState *env, mmu_ctx_t *ctx,
target_ulong eaddr, int rw, int type)
{
hwaddr hash;
target_ulong vsid;
int ds, pr, target_page_bits;
int ret, ret2;
pr = msr_pr;
ctx->eaddr = eaddr;
#if defined(TARGET_PPC64)
if (env->mmu_model & POWERPC_MMU_64) {
ppc_slb_t *slb;
target_ulong pageaddr;
int segment_bits;
LOG_MMU("Check SLBs\n");
slb = slb_lookup(env, eaddr);
if (!slb) {
return -5;
}
if (slb->vsid & SLB_VSID_B) {
vsid = (slb->vsid & SLB_VSID_VSID) >> SLB_VSID_SHIFT_1T;
segment_bits = 40;
} else {
vsid = (slb->vsid & SLB_VSID_VSID) >> SLB_VSID_SHIFT;
segment_bits = 28;
}
target_page_bits = (slb->vsid & SLB_VSID_L)
? TARGET_PAGE_BITS_16M : TARGET_PAGE_BITS;
ctx->key = !!(pr ? (slb->vsid & SLB_VSID_KP)
: (slb->vsid & SLB_VSID_KS));
ds = 0;
ctx->nx = !!(slb->vsid & SLB_VSID_N);
pageaddr = eaddr & ((1ULL << segment_bits)
- (1ULL << target_page_bits));
if (slb->vsid & SLB_VSID_B) {
hash = vsid ^ (vsid << 25) ^ (pageaddr >> target_page_bits);
} else {
hash = vsid ^ (pageaddr >> target_page_bits);
}
ctx->ptem = (slb->vsid & SLB_VSID_PTEM) |
((pageaddr >> 16) & ((1ULL << segment_bits) - 0x80));
} else
#endif
{
target_ulong sr, pgidx;
sr = env->sr[eaddr >> 28];
ctx->key = (((sr & 0x20000000) && (pr != 0)) ||
((sr & 0x40000000) && (pr == 0))) ? 1 : 0;
ds = sr & 0x80000000 ? 1 : 0;
ctx->nx = sr & 0x10000000 ? 1 : 0;
vsid = sr & 0x00FFFFFF;
target_page_bits = TARGET_PAGE_BITS;
LOG_MMU("Check segment v=" TARGET_FMT_lx " %d " TARGET_FMT_lx " nip="
TARGET_FMT_lx " lr=" TARGET_FMT_lx
" ir=%d dr=%d pr=%d %d t=%d\n",
eaddr, (int)(eaddr >> 28), sr, env->nip, env->lr, (int)msr_ir,
(int)msr_dr, pr != 0 ? 1 : 0, rw, type);
pgidx = (eaddr & ~SEGMENT_MASK_256M) >> target_page_bits;
hash = vsid ^ pgidx;
ctx->ptem = (vsid << 7) | (pgidx >> 10);
}
LOG_MMU("pte segment: key=%d ds %d nx %d vsid " TARGET_FMT_lx "\n",
ctx->key, ds, ctx->nx, vsid);
ret = -1;
if (!ds) {
if (type != ACCESS_CODE || ctx->nx == 0) {
LOG_MMU("htab_base " TARGET_FMT_plx " htab_mask " TARGET_FMT_plx
" hash " TARGET_FMT_plx "\n",
env->htab_base, env->htab_mask, hash);
ctx->hash[0] = hash;
ctx->hash[1] = ~hash;
ctx->raddr = (hwaddr)-1ULL;
if (unlikely(env->mmu_model == POWERPC_MMU_SOFT_6xx ||
env->mmu_model == POWERPC_MMU_SOFT_74xx)) {
ret = ppc6xx_tlb_check(env, ctx, eaddr, rw, type);
} else {
LOG_MMU("0 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=" TARGET_FMT_lx " ptem=" TARGET_FMT_lx
" hash=" TARGET_FMT_plx "\n",
env->htab_base, env->htab_mask, vsid, ctx->ptem,
ctx->hash[0]);
ret = find_pte(env, ctx, 0, rw, type, target_page_bits);
if (ret < 0) {
if (eaddr != 0xEFFFFFFF) {
LOG_MMU("1 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=" TARGET_FMT_lx " api=" TARGET_FMT_lx
" hash=" TARGET_FMT_plx "\n", env->htab_base,
env->htab_mask, vsid, ctx->ptem, ctx->hash[1]);
}
ret2 = find_pte(env, ctx, 1, rw, type,
target_page_bits);
if (ret2 != -1) {
ret = ret2;
}
}
}
#if defined(DUMP_PAGE_TABLES)
if (qemu_log_enabled()) {
hwaddr curaddr;
uint32_t a0, a1, a2, a3;
qemu_log("Page table: " TARGET_FMT_plx " len " TARGET_FMT_plx
"\n", sdr, mask + 0x80);
for (curaddr = sdr; curaddr < (sdr + mask + 0x80);
curaddr += 16) {
a0 = ldl_phys(curaddr);
a1 = ldl_phys(curaddr + 4);
a2 = ldl_phys(curaddr + 8);
a3 = ldl_phys(curaddr + 12);
if (a0 != 0 || a1 != 0 || a2 != 0 || a3 != 0) {
qemu_log(TARGET_FMT_plx ": %08x %08x %08x %08x\n",
curaddr, a0, a1, a2, a3);
}
}
}
#endif
} else {
LOG_MMU("No access allowed\n");
ret = -3;
}
} else {
target_ulong sr;
LOG_MMU("direct store...\n");
sr = env->sr[eaddr >> 28];
if ((sr & 0x1FF00000) >> 20 == 0x07f) {
ctx->raddr = ((sr & 0xF) << 28) | (eaddr & 0x0FFFFFFF);
ctx->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
return 0;
}
switch (type) {
case ACCESS_INT:
break;
case ACCESS_CODE:
return -4;
case ACCESS_FLOAT:
return -4;
case ACCESS_RES:
return -4;
case ACCESS_CACHE:
ctx->raddr = eaddr;
return 0;
case ACCESS_EXT:
return -4;
default:
qemu_log("ERROR: instruction should not need "
"address translation\n");
return -4;
}
if ((rw == 1 || ctx->key != 1) && (rw == 0 || ctx->key != 0)) {
ctx->raddr = eaddr;
ret = 2;
} else {
ret = -2;
}
}
return ret;
}
| {
"code": [],
"line_no": []
} | static inline int FUNC_0(CPUPPCState *VAR_0, mmu_ctx_t *VAR_1,
target_ulong VAR_2, int VAR_3, int VAR_4)
{
hwaddr hash;
target_ulong vsid;
int VAR_5, VAR_6, VAR_7;
int VAR_8, VAR_9;
VAR_6 = msr_pr;
VAR_1->VAR_2 = VAR_2;
#if defined(TARGET_PPC64)
if (VAR_0->mmu_model & POWERPC_MMU_64) {
ppc_slb_t *slb;
target_ulong pageaddr;
int segment_bits;
LOG_MMU("Check SLBs\n");
slb = slb_lookup(VAR_0, VAR_2);
if (!slb) {
return -5;
}
if (slb->vsid & SLB_VSID_B) {
vsid = (slb->vsid & SLB_VSID_VSID) >> SLB_VSID_SHIFT_1T;
segment_bits = 40;
} else {
vsid = (slb->vsid & SLB_VSID_VSID) >> SLB_VSID_SHIFT;
segment_bits = 28;
}
VAR_7 = (slb->vsid & SLB_VSID_L)
? TARGET_PAGE_BITS_16M : TARGET_PAGE_BITS;
VAR_1->key = !!(VAR_6 ? (slb->vsid & SLB_VSID_KP)
: (slb->vsid & SLB_VSID_KS));
VAR_5 = 0;
VAR_1->nx = !!(slb->vsid & SLB_VSID_N);
pageaddr = VAR_2 & ((1ULL << segment_bits)
- (1ULL << VAR_7));
if (slb->vsid & SLB_VSID_B) {
hash = vsid ^ (vsid << 25) ^ (pageaddr >> VAR_7);
} else {
hash = vsid ^ (pageaddr >> VAR_7);
}
VAR_1->ptem = (slb->vsid & SLB_VSID_PTEM) |
((pageaddr >> 16) & ((1ULL << segment_bits) - 0x80));
} else
#endif
{
target_ulong sr, pgidx;
sr = VAR_0->sr[VAR_2 >> 28];
VAR_1->key = (((sr & 0x20000000) && (VAR_6 != 0)) ||
((sr & 0x40000000) && (VAR_6 == 0))) ? 1 : 0;
VAR_5 = sr & 0x80000000 ? 1 : 0;
VAR_1->nx = sr & 0x10000000 ? 1 : 0;
vsid = sr & 0x00FFFFFF;
VAR_7 = TARGET_PAGE_BITS;
LOG_MMU("Check segment v=" TARGET_FMT_lx " %d " TARGET_FMT_lx " nip="
TARGET_FMT_lx " lr=" TARGET_FMT_lx
" ir=%d dr=%d VAR_6=%d %d t=%d\n",
VAR_2, (int)(VAR_2 >> 28), sr, VAR_0->nip, VAR_0->lr, (int)msr_ir,
(int)msr_dr, VAR_6 != 0 ? 1 : 0, VAR_3, VAR_4);
pgidx = (VAR_2 & ~SEGMENT_MASK_256M) >> VAR_7;
hash = vsid ^ pgidx;
VAR_1->ptem = (vsid << 7) | (pgidx >> 10);
}
LOG_MMU("pte segment: key=%d VAR_5 %d nx %d vsid " TARGET_FMT_lx "\n",
VAR_1->key, VAR_5, VAR_1->nx, vsid);
VAR_8 = -1;
if (!VAR_5) {
if (VAR_4 != ACCESS_CODE || VAR_1->nx == 0) {
LOG_MMU("htab_base " TARGET_FMT_plx " htab_mask " TARGET_FMT_plx
" hash " TARGET_FMT_plx "\n",
VAR_0->htab_base, VAR_0->htab_mask, hash);
VAR_1->hash[0] = hash;
VAR_1->hash[1] = ~hash;
VAR_1->raddr = (hwaddr)-1ULL;
if (unlikely(VAR_0->mmu_model == POWERPC_MMU_SOFT_6xx ||
VAR_0->mmu_model == POWERPC_MMU_SOFT_74xx)) {
VAR_8 = ppc6xx_tlb_check(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4);
} else {
LOG_MMU("0 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=" TARGET_FMT_lx " ptem=" TARGET_FMT_lx
" hash=" TARGET_FMT_plx "\n",
VAR_0->htab_base, VAR_0->htab_mask, vsid, VAR_1->ptem,
VAR_1->hash[0]);
VAR_8 = find_pte(VAR_0, VAR_1, 0, VAR_3, VAR_4, VAR_7);
if (VAR_8 < 0) {
if (VAR_2 != 0xEFFFFFFF) {
LOG_MMU("1 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=" TARGET_FMT_lx " api=" TARGET_FMT_lx
" hash=" TARGET_FMT_plx "\n", VAR_0->htab_base,
VAR_0->htab_mask, vsid, VAR_1->ptem, VAR_1->hash[1]);
}
VAR_9 = find_pte(VAR_0, VAR_1, 1, VAR_3, VAR_4,
VAR_7);
if (VAR_9 != -1) {
VAR_8 = VAR_9;
}
}
}
#if defined(DUMP_PAGE_TABLES)
if (qemu_log_enabled()) {
hwaddr curaddr;
uint32_t a0, a1, a2, a3;
qemu_log("Page table: " TARGET_FMT_plx " len " TARGET_FMT_plx
"\n", sdr, mask + 0x80);
for (curaddr = sdr; curaddr < (sdr + mask + 0x80);
curaddr += 16) {
a0 = ldl_phys(curaddr);
a1 = ldl_phys(curaddr + 4);
a2 = ldl_phys(curaddr + 8);
a3 = ldl_phys(curaddr + 12);
if (a0 != 0 || a1 != 0 || a2 != 0 || a3 != 0) {
qemu_log(TARGET_FMT_plx ": %08x %08x %08x %08x\n",
curaddr, a0, a1, a2, a3);
}
}
}
#endif
} else {
LOG_MMU("No access allowed\n");
VAR_8 = -3;
}
} else {
target_ulong sr;
LOG_MMU("direct store...\n");
sr = VAR_0->sr[VAR_2 >> 28];
if ((sr & 0x1FF00000) >> 20 == 0x07f) {
VAR_1->raddr = ((sr & 0xF) << 28) | (VAR_2 & 0x0FFFFFFF);
VAR_1->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
return 0;
}
switch (VAR_4) {
case ACCESS_INT:
break;
case ACCESS_CODE:
return -4;
case ACCESS_FLOAT:
return -4;
case ACCESS_RES:
return -4;
case ACCESS_CACHE:
VAR_1->raddr = VAR_2;
return 0;
case ACCESS_EXT:
return -4;
default:
qemu_log("ERROR: instruction should not need "
"address translation\n");
return -4;
}
if ((VAR_3 == 1 || VAR_1->key != 1) && (VAR_3 == 0 || VAR_1->key != 0)) {
VAR_1->raddr = VAR_2;
VAR_8 = 2;
} else {
VAR_8 = -2;
}
}
return VAR_8;
}
| [
"static inline int FUNC_0(CPUPPCState *VAR_0, mmu_ctx_t *VAR_1,\ntarget_ulong VAR_2, int VAR_3, int VAR_4)\n{",
"hwaddr hash;",
"target_ulong vsid;",
"int VAR_5, VAR_6, VAR_7;",
"int VAR_8, VAR_9;",
"VAR_6 = msr_pr;",
"VAR_1->VAR_2 = VAR_2;",
"#if defined(TARGET_PPC64)\nif (VAR_0->mmu_model & POWERPC_MMU_64) {",
"ppc_slb_t *slb;",
"target_ulong pageaddr;",
"int segment_bits;",
"LOG_MMU(\"Check SLBs\\n\");",
"slb = slb_lookup(VAR_0, VAR_2);",
"if (!slb) {",
"return -5;",
"}",
"if (slb->vsid & SLB_VSID_B) {",
"vsid = (slb->vsid & SLB_VSID_VSID) >> SLB_VSID_SHIFT_1T;",
"segment_bits = 40;",
"} else {",
"vsid = (slb->vsid & SLB_VSID_VSID) >> SLB_VSID_SHIFT;",
"segment_bits = 28;",
"}",
"VAR_7 = (slb->vsid & SLB_VSID_L)\n? TARGET_PAGE_BITS_16M : TARGET_PAGE_BITS;",
"VAR_1->key = !!(VAR_6 ? (slb->vsid & SLB_VSID_KP)\n: (slb->vsid & SLB_VSID_KS));",
"VAR_5 = 0;",
"VAR_1->nx = !!(slb->vsid & SLB_VSID_N);",
"pageaddr = VAR_2 & ((1ULL << segment_bits)\n- (1ULL << VAR_7));",
"if (slb->vsid & SLB_VSID_B) {",
"hash = vsid ^ (vsid << 25) ^ (pageaddr >> VAR_7);",
"} else {",
"hash = vsid ^ (pageaddr >> VAR_7);",
"}",
"VAR_1->ptem = (slb->vsid & SLB_VSID_PTEM) |\n((pageaddr >> 16) & ((1ULL << segment_bits) - 0x80));",
"} else",
"#endif\n{",
"target_ulong sr, pgidx;",
"sr = VAR_0->sr[VAR_2 >> 28];",
"VAR_1->key = (((sr & 0x20000000) && (VAR_6 != 0)) ||\n((sr & 0x40000000) && (VAR_6 == 0))) ? 1 : 0;",
"VAR_5 = sr & 0x80000000 ? 1 : 0;",
"VAR_1->nx = sr & 0x10000000 ? 1 : 0;",
"vsid = sr & 0x00FFFFFF;",
"VAR_7 = TARGET_PAGE_BITS;",
"LOG_MMU(\"Check segment v=\" TARGET_FMT_lx \" %d \" TARGET_FMT_lx \" nip=\"\nTARGET_FMT_lx \" lr=\" TARGET_FMT_lx\n\" ir=%d dr=%d VAR_6=%d %d t=%d\\n\",\nVAR_2, (int)(VAR_2 >> 28), sr, VAR_0->nip, VAR_0->lr, (int)msr_ir,\n(int)msr_dr, VAR_6 != 0 ? 1 : 0, VAR_3, VAR_4);",
"pgidx = (VAR_2 & ~SEGMENT_MASK_256M) >> VAR_7;",
"hash = vsid ^ pgidx;",
"VAR_1->ptem = (vsid << 7) | (pgidx >> 10);",
"}",
"LOG_MMU(\"pte segment: key=%d VAR_5 %d nx %d vsid \" TARGET_FMT_lx \"\\n\",\nVAR_1->key, VAR_5, VAR_1->nx, vsid);",
"VAR_8 = -1;",
"if (!VAR_5) {",
"if (VAR_4 != ACCESS_CODE || VAR_1->nx == 0) {",
"LOG_MMU(\"htab_base \" TARGET_FMT_plx \" htab_mask \" TARGET_FMT_plx\n\" hash \" TARGET_FMT_plx \"\\n\",\nVAR_0->htab_base, VAR_0->htab_mask, hash);",
"VAR_1->hash[0] = hash;",
"VAR_1->hash[1] = ~hash;",
"VAR_1->raddr = (hwaddr)-1ULL;",
"if (unlikely(VAR_0->mmu_model == POWERPC_MMU_SOFT_6xx ||\nVAR_0->mmu_model == POWERPC_MMU_SOFT_74xx)) {",
"VAR_8 = ppc6xx_tlb_check(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4);",
"} else {",
"LOG_MMU(\"0 htab=\" TARGET_FMT_plx \"/\" TARGET_FMT_plx\n\" vsid=\" TARGET_FMT_lx \" ptem=\" TARGET_FMT_lx\n\" hash=\" TARGET_FMT_plx \"\\n\",\nVAR_0->htab_base, VAR_0->htab_mask, vsid, VAR_1->ptem,\nVAR_1->hash[0]);",
"VAR_8 = find_pte(VAR_0, VAR_1, 0, VAR_3, VAR_4, VAR_7);",
"if (VAR_8 < 0) {",
"if (VAR_2 != 0xEFFFFFFF) {",
"LOG_MMU(\"1 htab=\" TARGET_FMT_plx \"/\" TARGET_FMT_plx\n\" vsid=\" TARGET_FMT_lx \" api=\" TARGET_FMT_lx\n\" hash=\" TARGET_FMT_plx \"\\n\", VAR_0->htab_base,\nVAR_0->htab_mask, vsid, VAR_1->ptem, VAR_1->hash[1]);",
"}",
"VAR_9 = find_pte(VAR_0, VAR_1, 1, VAR_3, VAR_4,\nVAR_7);",
"if (VAR_9 != -1) {",
"VAR_8 = VAR_9;",
"}",
"}",
"}",
"#if defined(DUMP_PAGE_TABLES)\nif (qemu_log_enabled()) {",
"hwaddr curaddr;",
"uint32_t a0, a1, a2, a3;",
"qemu_log(\"Page table: \" TARGET_FMT_plx \" len \" TARGET_FMT_plx\n\"\\n\", sdr, mask + 0x80);",
"for (curaddr = sdr; curaddr < (sdr + mask + 0x80);",
"curaddr += 16) {",
"a0 = ldl_phys(curaddr);",
"a1 = ldl_phys(curaddr + 4);",
"a2 = ldl_phys(curaddr + 8);",
"a3 = ldl_phys(curaddr + 12);",
"if (a0 != 0 || a1 != 0 || a2 != 0 || a3 != 0) {",
"qemu_log(TARGET_FMT_plx \": %08x %08x %08x %08x\\n\",\ncuraddr, a0, a1, a2, a3);",
"}",
"}",
"}",
"#endif\n} else {",
"LOG_MMU(\"No access allowed\\n\");",
"VAR_8 = -3;",
"}",
"} else {",
"target_ulong sr;",
"LOG_MMU(\"direct store...\\n\");",
"sr = VAR_0->sr[VAR_2 >> 28];",
"if ((sr & 0x1FF00000) >> 20 == 0x07f) {",
"VAR_1->raddr = ((sr & 0xF) << 28) | (VAR_2 & 0x0FFFFFFF);",
"VAR_1->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;",
"return 0;",
"}",
"switch (VAR_4) {",
"case ACCESS_INT:\nbreak;",
"case ACCESS_CODE:\nreturn -4;",
"case ACCESS_FLOAT:\nreturn -4;",
"case ACCESS_RES:\nreturn -4;",
"case ACCESS_CACHE:\nVAR_1->raddr = VAR_2;",
"return 0;",
"case ACCESS_EXT:\nreturn -4;",
"default:\nqemu_log(\"ERROR: instruction should not need \"\n\"address translation\\n\");",
"return -4;",
"}",
"if ((VAR_3 == 1 || VAR_1->key != 1) && (VAR_3 == 0 || VAR_1->key != 0)) {",
"VAR_1->raddr = VAR_2;",
"VAR_8 = 2;",
"} else {",
"VAR_8 = -2;",
"}",
"}",
"return VAR_8;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61,
63
],
[
65,
67
],
[
69
],
[
71
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91,
93
],
[
95
],
[
97,
99
],
[
101
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119,
121,
123,
125,
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137,
139
],
[
141
],
[
143
],
[
147
],
[
151,
153,
155
],
[
157
],
[
159
],
[
165
],
[
167,
169
],
[
173
],
[
175
],
[
177,
179,
181,
183,
185
],
[
189
],
[
191
],
[
195
],
[
197,
199,
201,
203
],
[
205
],
[
207,
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221,
223
],
[
225
],
[
227
],
[
231,
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249,
251
],
[
253
],
[
255
],
[
257
],
[
259,
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
275
],
[
287
],
[
289
],
[
299
],
[
301
],
[
303
],
[
305
],
[
309
],
[
311,
315
],
[
317,
321
],
[
323,
327
],
[
329,
333
],
[
335,
345
],
[
347
],
[
349,
353
],
[
355,
357,
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
381
],
[
383
]
] |
26,790 | static void char_socket_test(void)
{
Chardev *chr = qemu_chr_new("server", "tcp:127.0.0.1:0,server,nowait");
Chardev *chr_client;
QObject *addr;
QDict *qdict, *data;
const char *port;
SocketIdleData d = { .chr = chr };
CharBackend be;
CharBackend client_be;
char *tmp;
d.be = &be;
d.client_be = &be;
g_assert_nonnull(chr);
g_assert(!object_property_get_bool(OBJECT(chr), "connected", &error_abort));
addr = object_property_get_qobject(OBJECT(chr), "addr", &error_abort);
qdict = qobject_to_qdict(addr);
data = qdict_get_qdict(qdict, "data");
port = qdict_get_str(data, "port");
tmp = g_strdup_printf("tcp:127.0.0.1:%s", port);
QDECREF(qdict);
qemu_chr_fe_init(&be, chr, &error_abort);
qemu_chr_fe_set_handlers(&be, socket_can_read, socket_read,
NULL, &d, NULL, true);
chr_client = qemu_chr_new("client", tmp);
qemu_chr_fe_init(&client_be, chr_client, &error_abort);
qemu_chr_fe_set_handlers(&client_be, socket_can_read_hello,
socket_read_hello,
NULL, &d, NULL, true);
g_free(tmp);
d.conn_expected = true;
guint id = g_idle_add(char_socket_test_idle, &d);
g_source_set_name_by_id(id, "test-idle");
g_assert_cmpint(id, >, 0);
main_loop();
g_assert(object_property_get_bool(OBJECT(chr), "connected", &error_abort));
g_assert(object_property_get_bool(OBJECT(chr_client),
"connected", &error_abort));
qemu_chr_write_all(chr_client, (const uint8_t *)"Z", 1);
main_loop();
object_unparent(OBJECT(chr_client));
d.conn_expected = false;
g_idle_add(char_socket_test_idle, &d);
main_loop();
object_unparent(OBJECT(chr));
}
| false | qemu | bd269ebc82fbaa5fe7ce5bc7c1770ac8acecd884 | static void char_socket_test(void)
{
Chardev *chr = qemu_chr_new("server", "tcp:127.0.0.1:0,server,nowait");
Chardev *chr_client;
QObject *addr;
QDict *qdict, *data;
const char *port;
SocketIdleData d = { .chr = chr };
CharBackend be;
CharBackend client_be;
char *tmp;
d.be = &be;
d.client_be = &be;
g_assert_nonnull(chr);
g_assert(!object_property_get_bool(OBJECT(chr), "connected", &error_abort));
addr = object_property_get_qobject(OBJECT(chr), "addr", &error_abort);
qdict = qobject_to_qdict(addr);
data = qdict_get_qdict(qdict, "data");
port = qdict_get_str(data, "port");
tmp = g_strdup_printf("tcp:127.0.0.1:%s", port);
QDECREF(qdict);
qemu_chr_fe_init(&be, chr, &error_abort);
qemu_chr_fe_set_handlers(&be, socket_can_read, socket_read,
NULL, &d, NULL, true);
chr_client = qemu_chr_new("client", tmp);
qemu_chr_fe_init(&client_be, chr_client, &error_abort);
qemu_chr_fe_set_handlers(&client_be, socket_can_read_hello,
socket_read_hello,
NULL, &d, NULL, true);
g_free(tmp);
d.conn_expected = true;
guint id = g_idle_add(char_socket_test_idle, &d);
g_source_set_name_by_id(id, "test-idle");
g_assert_cmpint(id, >, 0);
main_loop();
g_assert(object_property_get_bool(OBJECT(chr), "connected", &error_abort));
g_assert(object_property_get_bool(OBJECT(chr_client),
"connected", &error_abort));
qemu_chr_write_all(chr_client, (const uint8_t *)"Z", 1);
main_loop();
object_unparent(OBJECT(chr_client));
d.conn_expected = false;
g_idle_add(char_socket_test_idle, &d);
main_loop();
object_unparent(OBJECT(chr));
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
Chardev *chr = qemu_chr_new("server", "tcp:127.0.0.1:0,server,nowait");
Chardev *chr_client;
QObject *addr;
QDict *qdict, *data;
const char *VAR_0;
SocketIdleData d = { .chr = chr };
CharBackend be;
CharBackend client_be;
char *VAR_1;
d.be = &be;
d.client_be = &be;
g_assert_nonnull(chr);
g_assert(!object_property_get_bool(OBJECT(chr), "connected", &error_abort));
addr = object_property_get_qobject(OBJECT(chr), "addr", &error_abort);
qdict = qobject_to_qdict(addr);
data = qdict_get_qdict(qdict, "data");
VAR_0 = qdict_get_str(data, "VAR_0");
VAR_1 = g_strdup_printf("tcp:127.0.0.1:%s", VAR_0);
QDECREF(qdict);
qemu_chr_fe_init(&be, chr, &error_abort);
qemu_chr_fe_set_handlers(&be, socket_can_read, socket_read,
NULL, &d, NULL, true);
chr_client = qemu_chr_new("client", VAR_1);
qemu_chr_fe_init(&client_be, chr_client, &error_abort);
qemu_chr_fe_set_handlers(&client_be, socket_can_read_hello,
socket_read_hello,
NULL, &d, NULL, true);
g_free(VAR_1);
d.conn_expected = true;
guint id = g_idle_add(char_socket_test_idle, &d);
g_source_set_name_by_id(id, "test-idle");
g_assert_cmpint(id, >, 0);
main_loop();
g_assert(object_property_get_bool(OBJECT(chr), "connected", &error_abort));
g_assert(object_property_get_bool(OBJECT(chr_client),
"connected", &error_abort));
qemu_chr_write_all(chr_client, (const uint8_t *)"Z", 1);
main_loop();
object_unparent(OBJECT(chr_client));
d.conn_expected = false;
g_idle_add(char_socket_test_idle, &d);
main_loop();
object_unparent(OBJECT(chr));
}
| [
"static void FUNC_0(void)\n{",
"Chardev *chr = qemu_chr_new(\"server\", \"tcp:127.0.0.1:0,server,nowait\");",
"Chardev *chr_client;",
"QObject *addr;",
"QDict *qdict, *data;",
"const char *VAR_0;",
"SocketIdleData d = { .chr = chr };",
"CharBackend be;",
"CharBackend client_be;",
"char *VAR_1;",
"d.be = &be;",
"d.client_be = &be;",
"g_assert_nonnull(chr);",
"g_assert(!object_property_get_bool(OBJECT(chr), \"connected\", &error_abort));",
"addr = object_property_get_qobject(OBJECT(chr), \"addr\", &error_abort);",
"qdict = qobject_to_qdict(addr);",
"data = qdict_get_qdict(qdict, \"data\");",
"VAR_0 = qdict_get_str(data, \"VAR_0\");",
"VAR_1 = g_strdup_printf(\"tcp:127.0.0.1:%s\", VAR_0);",
"QDECREF(qdict);",
"qemu_chr_fe_init(&be, chr, &error_abort);",
"qemu_chr_fe_set_handlers(&be, socket_can_read, socket_read,\nNULL, &d, NULL, true);",
"chr_client = qemu_chr_new(\"client\", VAR_1);",
"qemu_chr_fe_init(&client_be, chr_client, &error_abort);",
"qemu_chr_fe_set_handlers(&client_be, socket_can_read_hello,\nsocket_read_hello,\nNULL, &d, NULL, true);",
"g_free(VAR_1);",
"d.conn_expected = true;",
"guint id = g_idle_add(char_socket_test_idle, &d);",
"g_source_set_name_by_id(id, \"test-idle\");",
"g_assert_cmpint(id, >, 0);",
"main_loop();",
"g_assert(object_property_get_bool(OBJECT(chr), \"connected\", &error_abort));",
"g_assert(object_property_get_bool(OBJECT(chr_client),\n\"connected\", &error_abort));",
"qemu_chr_write_all(chr_client, (const uint8_t *)\"Z\", 1);",
"main_loop();",
"object_unparent(OBJECT(chr_client));",
"d.conn_expected = false;",
"g_idle_add(char_socket_test_idle, &d);",
"main_loop();",
"object_unparent(OBJECT(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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53,
55
],
[
59
],
[
61
],
[
63,
65,
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87,
89
],
[
93
],
[
95
],
[
99
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
]
] |
26,793 | void virtio_scsi_dataplane_start(VirtIOSCSI *s)
{
int i;
int rc;
BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s)));
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
if (s->dataplane_started ||
s->dataplane_starting ||
s->dataplane_fenced ||
s->ctx != iothread_get_aio_context(vs->conf.iothread)) {
return;
}
s->dataplane_starting = true;
/* Set up guest notifier (irq) */
rc = k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, true);
if (rc != 0) {
fprintf(stderr, "virtio-scsi: Failed to set guest notifiers (%d), "
"ensure -enable-kvm is set\n", rc);
goto fail_guest_notifiers;
}
aio_context_acquire(s->ctx);
rc = virtio_scsi_vring_init(s, vs->ctrl_vq, 0,
virtio_scsi_data_plane_handle_ctrl);
if (rc) {
goto fail_vrings;
}
rc = virtio_scsi_vring_init(s, vs->event_vq, 1,
virtio_scsi_data_plane_handle_event);
if (rc) {
goto fail_vrings;
}
for (i = 0; i < vs->conf.num_queues; i++) {
rc = virtio_scsi_vring_init(s, vs->cmd_vqs[i], i + 2,
virtio_scsi_data_plane_handle_cmd);
if (rc) {
goto fail_vrings;
}
}
s->dataplane_starting = false;
s->dataplane_started = true;
aio_context_release(s->ctx);
return;
fail_vrings:
virtio_scsi_clear_aio(s);
aio_context_release(s->ctx);
for (i = 0; i < vs->conf.num_queues + 2; i++) {
virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false);
}
k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, false);
fail_guest_notifiers:
s->dataplane_fenced = true;
s->dataplane_starting = false;
s->dataplane_started = true;
}
| false | qemu | ad07cd69ecaffbaa015459a46975ab32e50df805 | void virtio_scsi_dataplane_start(VirtIOSCSI *s)
{
int i;
int rc;
BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s)));
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
if (s->dataplane_started ||
s->dataplane_starting ||
s->dataplane_fenced ||
s->ctx != iothread_get_aio_context(vs->conf.iothread)) {
return;
}
s->dataplane_starting = true;
rc = k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, true);
if (rc != 0) {
fprintf(stderr, "virtio-scsi: Failed to set guest notifiers (%d), "
"ensure -enable-kvm is set\n", rc);
goto fail_guest_notifiers;
}
aio_context_acquire(s->ctx);
rc = virtio_scsi_vring_init(s, vs->ctrl_vq, 0,
virtio_scsi_data_plane_handle_ctrl);
if (rc) {
goto fail_vrings;
}
rc = virtio_scsi_vring_init(s, vs->event_vq, 1,
virtio_scsi_data_plane_handle_event);
if (rc) {
goto fail_vrings;
}
for (i = 0; i < vs->conf.num_queues; i++) {
rc = virtio_scsi_vring_init(s, vs->cmd_vqs[i], i + 2,
virtio_scsi_data_plane_handle_cmd);
if (rc) {
goto fail_vrings;
}
}
s->dataplane_starting = false;
s->dataplane_started = true;
aio_context_release(s->ctx);
return;
fail_vrings:
virtio_scsi_clear_aio(s);
aio_context_release(s->ctx);
for (i = 0; i < vs->conf.num_queues + 2; i++) {
virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false);
}
k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, false);
fail_guest_notifiers:
s->dataplane_fenced = true;
s->dataplane_starting = false;
s->dataplane_started = true;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(VirtIOSCSI *VAR_0)
{
int VAR_1;
int VAR_2;
BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(VAR_0)));
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(VAR_0);
if (VAR_0->dataplane_started ||
VAR_0->dataplane_starting ||
VAR_0->dataplane_fenced ||
VAR_0->ctx != iothread_get_aio_context(vs->conf.iothread)) {
return;
}
VAR_0->dataplane_starting = true;
VAR_2 = k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, true);
if (VAR_2 != 0) {
fprintf(stderr, "virtio-scsi: Failed to set guest notifiers (%d), "
"ensure -enable-kvm is set\n", VAR_2);
goto fail_guest_notifiers;
}
aio_context_acquire(VAR_0->ctx);
VAR_2 = virtio_scsi_vring_init(VAR_0, vs->ctrl_vq, 0,
virtio_scsi_data_plane_handle_ctrl);
if (VAR_2) {
goto fail_vrings;
}
VAR_2 = virtio_scsi_vring_init(VAR_0, vs->event_vq, 1,
virtio_scsi_data_plane_handle_event);
if (VAR_2) {
goto fail_vrings;
}
for (VAR_1 = 0; VAR_1 < vs->conf.num_queues; VAR_1++) {
VAR_2 = virtio_scsi_vring_init(VAR_0, vs->cmd_vqs[VAR_1], VAR_1 + 2,
virtio_scsi_data_plane_handle_cmd);
if (VAR_2) {
goto fail_vrings;
}
}
VAR_0->dataplane_starting = false;
VAR_0->dataplane_started = true;
aio_context_release(VAR_0->ctx);
return;
fail_vrings:
virtio_scsi_clear_aio(VAR_0);
aio_context_release(VAR_0->ctx);
for (VAR_1 = 0; VAR_1 < vs->conf.num_queues + 2; VAR_1++) {
virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), VAR_1, false);
}
k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, false);
fail_guest_notifiers:
VAR_0->dataplane_fenced = true;
VAR_0->dataplane_starting = false;
VAR_0->dataplane_started = true;
}
| [
"void FUNC_0(VirtIOSCSI *VAR_0)\n{",
"int VAR_1;",
"int VAR_2;",
"BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(VAR_0)));",
"VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);",
"VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(VAR_0);",
"if (VAR_0->dataplane_started ||\nVAR_0->dataplane_starting ||\nVAR_0->dataplane_fenced ||\nVAR_0->ctx != iothread_get_aio_context(vs->conf.iothread)) {",
"return;",
"}",
"VAR_0->dataplane_starting = true;",
"VAR_2 = k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, true);",
"if (VAR_2 != 0) {",
"fprintf(stderr, \"virtio-scsi: Failed to set guest notifiers (%d), \"\n\"ensure -enable-kvm is set\\n\", VAR_2);",
"goto fail_guest_notifiers;",
"}",
"aio_context_acquire(VAR_0->ctx);",
"VAR_2 = virtio_scsi_vring_init(VAR_0, vs->ctrl_vq, 0,\nvirtio_scsi_data_plane_handle_ctrl);",
"if (VAR_2) {",
"goto fail_vrings;",
"}",
"VAR_2 = virtio_scsi_vring_init(VAR_0, vs->event_vq, 1,\nvirtio_scsi_data_plane_handle_event);",
"if (VAR_2) {",
"goto fail_vrings;",
"}",
"for (VAR_1 = 0; VAR_1 < vs->conf.num_queues; VAR_1++) {",
"VAR_2 = virtio_scsi_vring_init(VAR_0, vs->cmd_vqs[VAR_1], VAR_1 + 2,\nvirtio_scsi_data_plane_handle_cmd);",
"if (VAR_2) {",
"goto fail_vrings;",
"}",
"}",
"VAR_0->dataplane_starting = false;",
"VAR_0->dataplane_started = true;",
"aio_context_release(VAR_0->ctx);",
"return;",
"fail_vrings:\nvirtio_scsi_clear_aio(VAR_0);",
"aio_context_release(VAR_0->ctx);",
"for (VAR_1 = 0; VAR_1 < vs->conf.num_queues + 2; VAR_1++) {",
"virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), VAR_1, false);",
"}",
"k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, false);",
"fail_guest_notifiers:\nVAR_0->dataplane_fenced = true;",
"VAR_0->dataplane_starting = false;",
"VAR_0->dataplane_started = 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17,
19,
21,
23
],
[
25
],
[
27
],
[
31
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99,
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113,
115
],
[
117
],
[
119
],
[
121
]
] |
26,794 | static void disas_fp_csel(DisasContext *s, uint32_t insn)
{
unsigned int mos, type, rm, cond, rn, rd;
int label_continue = -1;
mos = extract32(insn, 29, 3);
type = extract32(insn, 22, 2); /* 0 = single, 1 = double */
rm = extract32(insn, 16, 5);
cond = extract32(insn, 12, 4);
rn = extract32(insn, 5, 5);
rd = extract32(insn, 0, 5);
if (mos || type > 1) {
unallocated_encoding(s);
return;
}
if (!fp_access_check(s)) {
return;
}
if (cond < 0x0e) { /* not always */
int label_match = gen_new_label();
label_continue = gen_new_label();
arm_gen_test_cc(cond, label_match);
/* nomatch: */
gen_mov_fp2fp(s, type, rd, rm);
tcg_gen_br(label_continue);
gen_set_label(label_match);
}
gen_mov_fp2fp(s, type, rd, rn);
if (cond < 0x0e) { /* continue */
gen_set_label(label_continue);
}
}
| false | qemu | 42a268c241183877192c376d03bd9b6d527407c7 | static void disas_fp_csel(DisasContext *s, uint32_t insn)
{
unsigned int mos, type, rm, cond, rn, rd;
int label_continue = -1;
mos = extract32(insn, 29, 3);
type = extract32(insn, 22, 2);
rm = extract32(insn, 16, 5);
cond = extract32(insn, 12, 4);
rn = extract32(insn, 5, 5);
rd = extract32(insn, 0, 5);
if (mos || type > 1) {
unallocated_encoding(s);
return;
}
if (!fp_access_check(s)) {
return;
}
if (cond < 0x0e) {
int label_match = gen_new_label();
label_continue = gen_new_label();
arm_gen_test_cc(cond, label_match);
gen_mov_fp2fp(s, type, rd, rm);
tcg_gen_br(label_continue);
gen_set_label(label_match);
}
gen_mov_fp2fp(s, type, rd, rn);
if (cond < 0x0e) {
gen_set_label(label_continue);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1)
{
unsigned int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;
int VAR_8 = -1;
VAR_2 = extract32(VAR_1, 29, 3);
VAR_3 = extract32(VAR_1, 22, 2);
VAR_4 = extract32(VAR_1, 16, 5);
VAR_5 = extract32(VAR_1, 12, 4);
VAR_6 = extract32(VAR_1, 5, 5);
VAR_7 = extract32(VAR_1, 0, 5);
if (VAR_2 || VAR_3 > 1) {
unallocated_encoding(VAR_0);
return;
}
if (!fp_access_check(VAR_0)) {
return;
}
if (VAR_5 < 0x0e) {
int VAR_9 = gen_new_label();
VAR_8 = gen_new_label();
arm_gen_test_cc(VAR_5, VAR_9);
gen_mov_fp2fp(VAR_0, VAR_3, VAR_7, VAR_4);
tcg_gen_br(VAR_8);
gen_set_label(VAR_9);
}
gen_mov_fp2fp(VAR_0, VAR_3, VAR_7, VAR_6);
if (VAR_5 < 0x0e) {
gen_set_label(VAR_8);
}
}
| [
"static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1)\n{",
"unsigned int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;",
"int VAR_8 = -1;",
"VAR_2 = extract32(VAR_1, 29, 3);",
"VAR_3 = extract32(VAR_1, 22, 2);",
"VAR_4 = extract32(VAR_1, 16, 5);",
"VAR_5 = extract32(VAR_1, 12, 4);",
"VAR_6 = extract32(VAR_1, 5, 5);",
"VAR_7 = extract32(VAR_1, 0, 5);",
"if (VAR_2 || VAR_3 > 1) {",
"unallocated_encoding(VAR_0);",
"return;",
"}",
"if (!fp_access_check(VAR_0)) {",
"return;",
"}",
"if (VAR_5 < 0x0e) {",
"int VAR_9 = gen_new_label();",
"VAR_8 = gen_new_label();",
"arm_gen_test_cc(VAR_5, VAR_9);",
"gen_mov_fp2fp(VAR_0, VAR_3, VAR_7, VAR_4);",
"tcg_gen_br(VAR_8);",
"gen_set_label(VAR_9);",
"}",
"gen_mov_fp2fp(VAR_0, VAR_3, VAR_7, VAR_6);",
"if (VAR_5 < 0x0e) {",
"gen_set_label(VAR_8);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
]
] |
26,795 | int bdrv_open(BlockDriverState **pbs, const char *filename,
const char *reference, QDict *options, int flags,
BlockDriver *drv, Error **errp)
{
int ret;
BlockDriverState *file = NULL, *bs;
const char *drvname;
Error *local_err = NULL;
int snapshot_flags = 0;
assert(pbs);
if (reference) {
bool options_non_empty = options ? qdict_size(options) : false;
QDECREF(options);
if (*pbs) {
error_setg(errp, "Cannot reuse an existing BDS when referencing "
"another block device");
return -EINVAL;
}
if (filename || options_non_empty) {
error_setg(errp, "Cannot reference an existing block device with "
"additional options or a new filename");
return -EINVAL;
}
bs = bdrv_lookup_bs(reference, reference, errp);
if (!bs) {
return -ENODEV;
}
bdrv_ref(bs);
*pbs = bs;
return 0;
}
if (*pbs) {
bs = *pbs;
} else {
bs = bdrv_new();
}
/* NULL means an empty set of options */
if (options == NULL) {
options = qdict_new();
}
ret = bdrv_fill_options(&options, &filename, flags, drv, &local_err);
if (local_err) {
goto fail;
}
/* Find the right image format driver */
drv = NULL;
drvname = qdict_get_try_str(options, "driver");
if (drvname) {
drv = bdrv_find_format(drvname);
qdict_del(options, "driver");
if (!drv) {
error_setg(errp, "Unknown driver: '%s'", drvname);
ret = -EINVAL;
goto fail;
}
}
assert(drvname || !(flags & BDRV_O_PROTOCOL));
if (drv && !drv->bdrv_file_open) {
/* If the user explicitly wants a format driver here, we'll need to add
* another layer for the protocol in bs->file */
flags &= ~BDRV_O_PROTOCOL;
}
bs->options = options;
options = qdict_clone_shallow(options);
/* Open image file without format layer */
if ((flags & BDRV_O_PROTOCOL) == 0) {
if (flags & BDRV_O_RDWR) {
flags |= BDRV_O_ALLOW_RDWR;
}
if (flags & BDRV_O_SNAPSHOT) {
snapshot_flags = bdrv_temp_snapshot_flags(flags);
flags = bdrv_backing_flags(flags);
}
assert(file == NULL);
ret = bdrv_open_image(&file, filename, options, "file",
bdrv_inherited_flags(flags),
true, &local_err);
if (ret < 0) {
goto fail;
}
}
/* Image format probing */
bs->probed = !drv;
if (!drv && file) {
ret = find_image_format(file, filename, &drv, &local_err);
if (ret < 0) {
goto fail;
}
} else if (!drv) {
error_setg(errp, "Must specify either driver or file");
ret = -EINVAL;
goto fail;
}
/* Open the image */
ret = bdrv_open_common(bs, file, options, flags, drv, &local_err);
if (ret < 0) {
goto fail;
}
if (file && (bs->file != file)) {
bdrv_unref(file);
file = NULL;
}
/* If there is a backing file, use it */
if ((flags & BDRV_O_NO_BACKING) == 0) {
QDict *backing_options;
qdict_extract_subqdict(options, &backing_options, "backing.");
ret = bdrv_open_backing_file(bs, backing_options, &local_err);
if (ret < 0) {
goto close_and_fail;
}
}
bdrv_refresh_filename(bs);
/* For snapshot=on, create a temporary qcow2 overlay. bs points to the
* temporary snapshot afterwards. */
if (snapshot_flags) {
ret = bdrv_append_temp_snapshot(bs, snapshot_flags, &local_err);
if (local_err) {
goto close_and_fail;
}
}
/* Check if any unknown options were used */
if (options && (qdict_size(options) != 0)) {
const QDictEntry *entry = qdict_first(options);
if (flags & BDRV_O_PROTOCOL) {
error_setg(errp, "Block protocol '%s' doesn't support the option "
"'%s'", drv->format_name, entry->key);
} else {
error_setg(errp, "Block format '%s' used by device '%s' doesn't "
"support the option '%s'", drv->format_name,
bdrv_get_device_name(bs), entry->key);
}
ret = -EINVAL;
goto close_and_fail;
}
if (!bdrv_key_required(bs)) {
if (bs->blk) {
blk_dev_change_media_cb(bs->blk, true);
}
} else if (!runstate_check(RUN_STATE_PRELAUNCH)
&& !runstate_check(RUN_STATE_INMIGRATE)
&& !runstate_check(RUN_STATE_PAUSED)) { /* HACK */
error_setg(errp,
"Guest must be stopped for opening of encrypted image");
ret = -EBUSY;
goto close_and_fail;
}
QDECREF(options);
*pbs = bs;
return 0;
fail:
if (file != NULL) {
bdrv_unref(file);
}
QDECREF(bs->options);
QDECREF(options);
bs->options = NULL;
if (!*pbs) {
/* If *pbs is NULL, a new BDS has been created in this function and
needs to be freed now. Otherwise, it does not need to be closed,
since it has not really been opened yet. */
bdrv_unref(bs);
}
if (local_err) {
error_propagate(errp, local_err);
}
return ret;
close_and_fail:
/* See fail path, but now the BDS has to be always closed */
if (*pbs) {
bdrv_close(bs);
} else {
bdrv_unref(bs);
}
QDECREF(options);
if (local_err) {
error_propagate(errp, local_err);
}
return ret;
}
| false | qemu | 53a295131274c87914c97053e2ca00f19a9c2efa | int bdrv_open(BlockDriverState **pbs, const char *filename,
const char *reference, QDict *options, int flags,
BlockDriver *drv, Error **errp)
{
int ret;
BlockDriverState *file = NULL, *bs;
const char *drvname;
Error *local_err = NULL;
int snapshot_flags = 0;
assert(pbs);
if (reference) {
bool options_non_empty = options ? qdict_size(options) : false;
QDECREF(options);
if (*pbs) {
error_setg(errp, "Cannot reuse an existing BDS when referencing "
"another block device");
return -EINVAL;
}
if (filename || options_non_empty) {
error_setg(errp, "Cannot reference an existing block device with "
"additional options or a new filename");
return -EINVAL;
}
bs = bdrv_lookup_bs(reference, reference, errp);
if (!bs) {
return -ENODEV;
}
bdrv_ref(bs);
*pbs = bs;
return 0;
}
if (*pbs) {
bs = *pbs;
} else {
bs = bdrv_new();
}
if (options == NULL) {
options = qdict_new();
}
ret = bdrv_fill_options(&options, &filename, flags, drv, &local_err);
if (local_err) {
goto fail;
}
drv = NULL;
drvname = qdict_get_try_str(options, "driver");
if (drvname) {
drv = bdrv_find_format(drvname);
qdict_del(options, "driver");
if (!drv) {
error_setg(errp, "Unknown driver: '%s'", drvname);
ret = -EINVAL;
goto fail;
}
}
assert(drvname || !(flags & BDRV_O_PROTOCOL));
if (drv && !drv->bdrv_file_open) {
flags &= ~BDRV_O_PROTOCOL;
}
bs->options = options;
options = qdict_clone_shallow(options);
if ((flags & BDRV_O_PROTOCOL) == 0) {
if (flags & BDRV_O_RDWR) {
flags |= BDRV_O_ALLOW_RDWR;
}
if (flags & BDRV_O_SNAPSHOT) {
snapshot_flags = bdrv_temp_snapshot_flags(flags);
flags = bdrv_backing_flags(flags);
}
assert(file == NULL);
ret = bdrv_open_image(&file, filename, options, "file",
bdrv_inherited_flags(flags),
true, &local_err);
if (ret < 0) {
goto fail;
}
}
bs->probed = !drv;
if (!drv && file) {
ret = find_image_format(file, filename, &drv, &local_err);
if (ret < 0) {
goto fail;
}
} else if (!drv) {
error_setg(errp, "Must specify either driver or file");
ret = -EINVAL;
goto fail;
}
ret = bdrv_open_common(bs, file, options, flags, drv, &local_err);
if (ret < 0) {
goto fail;
}
if (file && (bs->file != file)) {
bdrv_unref(file);
file = NULL;
}
if ((flags & BDRV_O_NO_BACKING) == 0) {
QDict *backing_options;
qdict_extract_subqdict(options, &backing_options, "backing.");
ret = bdrv_open_backing_file(bs, backing_options, &local_err);
if (ret < 0) {
goto close_and_fail;
}
}
bdrv_refresh_filename(bs);
if (snapshot_flags) {
ret = bdrv_append_temp_snapshot(bs, snapshot_flags, &local_err);
if (local_err) {
goto close_and_fail;
}
}
if (options && (qdict_size(options) != 0)) {
const QDictEntry *entry = qdict_first(options);
if (flags & BDRV_O_PROTOCOL) {
error_setg(errp, "Block protocol '%s' doesn't support the option "
"'%s'", drv->format_name, entry->key);
} else {
error_setg(errp, "Block format '%s' used by device '%s' doesn't "
"support the option '%s'", drv->format_name,
bdrv_get_device_name(bs), entry->key);
}
ret = -EINVAL;
goto close_and_fail;
}
if (!bdrv_key_required(bs)) {
if (bs->blk) {
blk_dev_change_media_cb(bs->blk, true);
}
} else if (!runstate_check(RUN_STATE_PRELAUNCH)
&& !runstate_check(RUN_STATE_INMIGRATE)
&& !runstate_check(RUN_STATE_PAUSED)) {
error_setg(errp,
"Guest must be stopped for opening of encrypted image");
ret = -EBUSY;
goto close_and_fail;
}
QDECREF(options);
*pbs = bs;
return 0;
fail:
if (file != NULL) {
bdrv_unref(file);
}
QDECREF(bs->options);
QDECREF(options);
bs->options = NULL;
if (!*pbs) {
bdrv_unref(bs);
}
if (local_err) {
error_propagate(errp, local_err);
}
return ret;
close_and_fail:
if (*pbs) {
bdrv_close(bs);
} else {
bdrv_unref(bs);
}
QDECREF(options);
if (local_err) {
error_propagate(errp, local_err);
}
return ret;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(BlockDriverState **VAR_0, const char *VAR_1,
const char *VAR_2, QDict *VAR_3, int VAR_4,
BlockDriver *VAR_5, Error **VAR_6)
{
int VAR_7;
BlockDriverState *file = NULL, *bs;
const char *VAR_8;
Error *local_err = NULL;
int VAR_9 = 0;
assert(VAR_0);
if (VAR_2) {
bool options_non_empty = VAR_3 ? qdict_size(VAR_3) : false;
QDECREF(VAR_3);
if (*VAR_0) {
error_setg(VAR_6, "Cannot reuse an existing BDS when referencing "
"another block device");
return -EINVAL;
}
if (VAR_1 || options_non_empty) {
error_setg(VAR_6, "Cannot VAR_2 an existing block device with "
"additional VAR_3 or a new VAR_1");
return -EINVAL;
}
bs = bdrv_lookup_bs(VAR_2, VAR_2, VAR_6);
if (!bs) {
return -ENODEV;
}
bdrv_ref(bs);
*VAR_0 = bs;
return 0;
}
if (*VAR_0) {
bs = *VAR_0;
} else {
bs = bdrv_new();
}
if (VAR_3 == NULL) {
VAR_3 = qdict_new();
}
VAR_7 = bdrv_fill_options(&VAR_3, &VAR_1, VAR_4, VAR_5, &local_err);
if (local_err) {
goto fail;
}
VAR_5 = NULL;
VAR_8 = qdict_get_try_str(VAR_3, "driver");
if (VAR_8) {
VAR_5 = bdrv_find_format(VAR_8);
qdict_del(VAR_3, "driver");
if (!VAR_5) {
error_setg(VAR_6, "Unknown driver: '%s'", VAR_8);
VAR_7 = -EINVAL;
goto fail;
}
}
assert(VAR_8 || !(VAR_4 & BDRV_O_PROTOCOL));
if (VAR_5 && !VAR_5->bdrv_file_open) {
VAR_4 &= ~BDRV_O_PROTOCOL;
}
bs->VAR_3 = VAR_3;
VAR_3 = qdict_clone_shallow(VAR_3);
if ((VAR_4 & BDRV_O_PROTOCOL) == 0) {
if (VAR_4 & BDRV_O_RDWR) {
VAR_4 |= BDRV_O_ALLOW_RDWR;
}
if (VAR_4 & BDRV_O_SNAPSHOT) {
VAR_9 = bdrv_temp_snapshot_flags(VAR_4);
VAR_4 = bdrv_backing_flags(VAR_4);
}
assert(file == NULL);
VAR_7 = bdrv_open_image(&file, VAR_1, VAR_3, "file",
bdrv_inherited_flags(VAR_4),
true, &local_err);
if (VAR_7 < 0) {
goto fail;
}
}
bs->probed = !VAR_5;
if (!VAR_5 && file) {
VAR_7 = find_image_format(file, VAR_1, &VAR_5, &local_err);
if (VAR_7 < 0) {
goto fail;
}
} else if (!VAR_5) {
error_setg(VAR_6, "Must specify either driver or file");
VAR_7 = -EINVAL;
goto fail;
}
VAR_7 = bdrv_open_common(bs, file, VAR_3, VAR_4, VAR_5, &local_err);
if (VAR_7 < 0) {
goto fail;
}
if (file && (bs->file != file)) {
bdrv_unref(file);
file = NULL;
}
if ((VAR_4 & BDRV_O_NO_BACKING) == 0) {
QDict *backing_options;
qdict_extract_subqdict(VAR_3, &backing_options, "backing.");
VAR_7 = bdrv_open_backing_file(bs, backing_options, &local_err);
if (VAR_7 < 0) {
goto close_and_fail;
}
}
bdrv_refresh_filename(bs);
if (VAR_9) {
VAR_7 = bdrv_append_temp_snapshot(bs, VAR_9, &local_err);
if (local_err) {
goto close_and_fail;
}
}
if (VAR_3 && (qdict_size(VAR_3) != 0)) {
const QDictEntry *VAR_10 = qdict_first(VAR_3);
if (VAR_4 & BDRV_O_PROTOCOL) {
error_setg(VAR_6, "Block protocol '%s' doesn't support the option "
"'%s'", VAR_5->format_name, VAR_10->key);
} else {
error_setg(VAR_6, "Block format '%s' used by device '%s' doesn't "
"support the option '%s'", VAR_5->format_name,
bdrv_get_device_name(bs), VAR_10->key);
}
VAR_7 = -EINVAL;
goto close_and_fail;
}
if (!bdrv_key_required(bs)) {
if (bs->blk) {
blk_dev_change_media_cb(bs->blk, true);
}
} else if (!runstate_check(RUN_STATE_PRELAUNCH)
&& !runstate_check(RUN_STATE_INMIGRATE)
&& !runstate_check(RUN_STATE_PAUSED)) {
error_setg(VAR_6,
"Guest must be stopped for opening of encrypted image");
VAR_7 = -EBUSY;
goto close_and_fail;
}
QDECREF(VAR_3);
*VAR_0 = bs;
return 0;
fail:
if (file != NULL) {
bdrv_unref(file);
}
QDECREF(bs->VAR_3);
QDECREF(VAR_3);
bs->VAR_3 = NULL;
if (!*VAR_0) {
bdrv_unref(bs);
}
if (local_err) {
error_propagate(VAR_6, local_err);
}
return VAR_7;
close_and_fail:
if (*VAR_0) {
bdrv_close(bs);
} else {
bdrv_unref(bs);
}
QDECREF(VAR_3);
if (local_err) {
error_propagate(VAR_6, local_err);
}
return VAR_7;
}
| [
"int FUNC_0(BlockDriverState **VAR_0, const char *VAR_1,\nconst char *VAR_2, QDict *VAR_3, int VAR_4,\nBlockDriver *VAR_5, Error **VAR_6)\n{",
"int VAR_7;",
"BlockDriverState *file = NULL, *bs;",
"const char *VAR_8;",
"Error *local_err = NULL;",
"int VAR_9 = 0;",
"assert(VAR_0);",
"if (VAR_2) {",
"bool options_non_empty = VAR_3 ? qdict_size(VAR_3) : false;",
"QDECREF(VAR_3);",
"if (*VAR_0) {",
"error_setg(VAR_6, \"Cannot reuse an existing BDS when referencing \"\n\"another block device\");",
"return -EINVAL;",
"}",
"if (VAR_1 || options_non_empty) {",
"error_setg(VAR_6, \"Cannot VAR_2 an existing block device with \"\n\"additional VAR_3 or a new VAR_1\");",
"return -EINVAL;",
"}",
"bs = bdrv_lookup_bs(VAR_2, VAR_2, VAR_6);",
"if (!bs) {",
"return -ENODEV;",
"}",
"bdrv_ref(bs);",
"*VAR_0 = bs;",
"return 0;",
"}",
"if (*VAR_0) {",
"bs = *VAR_0;",
"} else {",
"bs = bdrv_new();",
"}",
"if (VAR_3 == NULL) {",
"VAR_3 = qdict_new();",
"}",
"VAR_7 = bdrv_fill_options(&VAR_3, &VAR_1, VAR_4, VAR_5, &local_err);",
"if (local_err) {",
"goto fail;",
"}",
"VAR_5 = NULL;",
"VAR_8 = qdict_get_try_str(VAR_3, \"driver\");",
"if (VAR_8) {",
"VAR_5 = bdrv_find_format(VAR_8);",
"qdict_del(VAR_3, \"driver\");",
"if (!VAR_5) {",
"error_setg(VAR_6, \"Unknown driver: '%s'\", VAR_8);",
"VAR_7 = -EINVAL;",
"goto fail;",
"}",
"}",
"assert(VAR_8 || !(VAR_4 & BDRV_O_PROTOCOL));",
"if (VAR_5 && !VAR_5->bdrv_file_open) {",
"VAR_4 &= ~BDRV_O_PROTOCOL;",
"}",
"bs->VAR_3 = VAR_3;",
"VAR_3 = qdict_clone_shallow(VAR_3);",
"if ((VAR_4 & BDRV_O_PROTOCOL) == 0) {",
"if (VAR_4 & BDRV_O_RDWR) {",
"VAR_4 |= BDRV_O_ALLOW_RDWR;",
"}",
"if (VAR_4 & BDRV_O_SNAPSHOT) {",
"VAR_9 = bdrv_temp_snapshot_flags(VAR_4);",
"VAR_4 = bdrv_backing_flags(VAR_4);",
"}",
"assert(file == NULL);",
"VAR_7 = bdrv_open_image(&file, VAR_1, VAR_3, \"file\",\nbdrv_inherited_flags(VAR_4),\ntrue, &local_err);",
"if (VAR_7 < 0) {",
"goto fail;",
"}",
"}",
"bs->probed = !VAR_5;",
"if (!VAR_5 && file) {",
"VAR_7 = find_image_format(file, VAR_1, &VAR_5, &local_err);",
"if (VAR_7 < 0) {",
"goto fail;",
"}",
"} else if (!VAR_5) {",
"error_setg(VAR_6, \"Must specify either driver or file\");",
"VAR_7 = -EINVAL;",
"goto fail;",
"}",
"VAR_7 = bdrv_open_common(bs, file, VAR_3, VAR_4, VAR_5, &local_err);",
"if (VAR_7 < 0) {",
"goto fail;",
"}",
"if (file && (bs->file != file)) {",
"bdrv_unref(file);",
"file = NULL;",
"}",
"if ((VAR_4 & BDRV_O_NO_BACKING) == 0) {",
"QDict *backing_options;",
"qdict_extract_subqdict(VAR_3, &backing_options, \"backing.\");",
"VAR_7 = bdrv_open_backing_file(bs, backing_options, &local_err);",
"if (VAR_7 < 0) {",
"goto close_and_fail;",
"}",
"}",
"bdrv_refresh_filename(bs);",
"if (VAR_9) {",
"VAR_7 = bdrv_append_temp_snapshot(bs, VAR_9, &local_err);",
"if (local_err) {",
"goto close_and_fail;",
"}",
"}",
"if (VAR_3 && (qdict_size(VAR_3) != 0)) {",
"const QDictEntry *VAR_10 = qdict_first(VAR_3);",
"if (VAR_4 & BDRV_O_PROTOCOL) {",
"error_setg(VAR_6, \"Block protocol '%s' doesn't support the option \"\n\"'%s'\", VAR_5->format_name, VAR_10->key);",
"} else {",
"error_setg(VAR_6, \"Block format '%s' used by device '%s' doesn't \"\n\"support the option '%s'\", VAR_5->format_name,\nbdrv_get_device_name(bs), VAR_10->key);",
"}",
"VAR_7 = -EINVAL;",
"goto close_and_fail;",
"}",
"if (!bdrv_key_required(bs)) {",
"if (bs->blk) {",
"blk_dev_change_media_cb(bs->blk, true);",
"}",
"} else if (!runstate_check(RUN_STATE_PRELAUNCH)",
"&& !runstate_check(RUN_STATE_INMIGRATE)\n&& !runstate_check(RUN_STATE_PAUSED)) {",
"error_setg(VAR_6,\n\"Guest must be stopped for opening of encrypted image\");",
"VAR_7 = -EBUSY;",
"goto close_and_fail;",
"}",
"QDECREF(VAR_3);",
"*VAR_0 = bs;",
"return 0;",
"fail:\nif (file != NULL) {",
"bdrv_unref(file);",
"}",
"QDECREF(bs->VAR_3);",
"QDECREF(VAR_3);",
"bs->VAR_3 = NULL;",
"if (!*VAR_0) {",
"bdrv_unref(bs);",
"}",
"if (local_err) {",
"error_propagate(VAR_6, local_err);",
"}",
"return VAR_7;",
"close_and_fail:\nif (*VAR_0) {",
"bdrv_close(bs);",
"} else {",
"bdrv_unref(bs);",
"}",
"QDECREF(VAR_3);",
"if (local_err) {",
"error_propagate(VAR_6, local_err);",
"}",
"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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133
],
[
135
],
[
141
],
[
143
],
[
147
],
[
149
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173
],
[
175,
177,
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
219
],
[
221
],
[
223
],
[
225
],
[
229
],
[
231
],
[
233
],
[
235
],
[
241
],
[
243
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
261
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
285
],
[
287
],
[
289
],
[
291,
293
],
[
295
],
[
297,
299,
301
],
[
303
],
[
307
],
[
309
],
[
311
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325,
327
],
[
329,
331
],
[
333
],
[
335
],
[
337
],
[
341
],
[
343
],
[
345
],
[
349,
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
385,
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409
]
] |
26,796 | START_TEST(qdict_haskey_test)
{
const char *key = "test";
qdict_put(tests_dict, key, qint_from_int(0));
fail_unless(qdict_haskey(tests_dict, key) == 1);
}
| false | qemu | ac531cb6e542b1e61d668604adf9dc5306a948c0 | START_TEST(qdict_haskey_test)
{
const char *key = "test";
qdict_put(tests_dict, key, qint_from_int(0));
fail_unless(qdict_haskey(tests_dict, key) == 1);
}
| {
"code": [],
"line_no": []
} | FUNC_0(VAR_0)
{
const char *VAR_1 = "test";
qdict_put(tests_dict, VAR_1, qint_from_int(0));
fail_unless(qdict_haskey(tests_dict, VAR_1) == 1);
}
| [
"FUNC_0(VAR_0)\n{",
"const char *VAR_1 = \"test\";",
"qdict_put(tests_dict, VAR_1, qint_from_int(0));",
"fail_unless(qdict_haskey(tests_dict, VAR_1) == 1);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
]
] |
26,797 | static void pc_dimm_check_memdev_is_busy(const Object *obj, const char *name,
Object *val, Error **errp)
{
Error *local_err = NULL;
if (host_memory_backend_is_mapped(MEMORY_BACKEND(val))) {
char *path = object_get_canonical_path_component(val);
error_setg(&local_err, "can't use already busy memdev: %s", path);
g_free(path);
} else {
qdev_prop_allow_set_link_before_realize(obj, name, val, &local_err);
}
error_propagate(errp, local_err);
}
| false | qemu | 2de7e26891db3d5b7f214fa485a5e946b17a57b9 | static void pc_dimm_check_memdev_is_busy(const Object *obj, const char *name,
Object *val, Error **errp)
{
Error *local_err = NULL;
if (host_memory_backend_is_mapped(MEMORY_BACKEND(val))) {
char *path = object_get_canonical_path_component(val);
error_setg(&local_err, "can't use already busy memdev: %s", path);
g_free(path);
} else {
qdev_prop_allow_set_link_before_realize(obj, name, val, &local_err);
}
error_propagate(errp, local_err);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const Object *VAR_0, const char *VAR_1,
Object *VAR_2, Error **VAR_3)
{
Error *local_err = NULL;
if (host_memory_backend_is_mapped(MEMORY_BACKEND(VAR_2))) {
char *VAR_4 = object_get_canonical_path_component(VAR_2);
error_setg(&local_err, "can't use already busy memdev: %s", VAR_4);
g_free(VAR_4);
} else {
qdev_prop_allow_set_link_before_realize(VAR_0, VAR_1, VAR_2, &local_err);
}
error_propagate(VAR_3, local_err);
}
| [
"static void FUNC_0(const Object *VAR_0, const char *VAR_1,\nObject *VAR_2, Error **VAR_3)\n{",
"Error *local_err = NULL;",
"if (host_memory_backend_is_mapped(MEMORY_BACKEND(VAR_2))) {",
"char *VAR_4 = object_get_canonical_path_component(VAR_2);",
"error_setg(&local_err, \"can't use already busy memdev: %s\", VAR_4);",
"g_free(VAR_4);",
"} else {",
"qdev_prop_allow_set_link_before_realize(VAR_0, VAR_1, VAR_2, &local_err);",
"}",
"error_propagate(VAR_3, local_err);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
]
] |
26,798 | void co_run_in_worker_bh(void *opaque)
{
Coroutine *co = opaque;
thread_pool_submit_aio(aio_get_thread_pool(qemu_get_aio_context()),
coroutine_enter_func, co, coroutine_enter_cb, co);
}
| false | qemu | fe52840c8760122257be7b7e4893dd951480a71f | void co_run_in_worker_bh(void *opaque)
{
Coroutine *co = opaque;
thread_pool_submit_aio(aio_get_thread_pool(qemu_get_aio_context()),
coroutine_enter_func, co, coroutine_enter_cb, co);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(void *VAR_0)
{
Coroutine *co = VAR_0;
thread_pool_submit_aio(aio_get_thread_pool(qemu_get_aio_context()),
coroutine_enter_func, co, coroutine_enter_cb, co);
}
| [
"void FUNC_0(void *VAR_0)\n{",
"Coroutine *co = VAR_0;",
"thread_pool_submit_aio(aio_get_thread_pool(qemu_get_aio_context()),\ncoroutine_enter_func, co, coroutine_enter_cb, co);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11
]
] |
26,799 | static int local_fstat(FsContext *ctx, int fd, struct stat *stbuf)
{
return fstat(fd, stbuf);
}
| false | qemu | 1237ad7607aae5859067831e36a59d3b017c5a54 | static int local_fstat(FsContext *ctx, int fd, struct stat *stbuf)
{
return fstat(fd, stbuf);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(FsContext *VAR_0, int VAR_1, struct stat *VAR_2)
{
return fstat(VAR_1, VAR_2);
}
| [
"static int FUNC_0(FsContext *VAR_0, int VAR_1, struct stat *VAR_2)\n{",
"return fstat(VAR_1, VAR_2);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
26,800 | static bool virtio_blk_sect_range_ok(VirtIOBlock *dev,
uint64_t sector, size_t size)
{
uint64_t nb_sectors = size >> BDRV_SECTOR_BITS;
uint64_t total_sectors;
if (nb_sectors > INT_MAX) {
return false;
}
if (sector & dev->sector_mask) {
return false;
}
if (size % dev->conf.conf.logical_block_size) {
return false;
}
blk_get_geometry(dev->blk, &total_sectors);
if (sector > total_sectors || nb_sectors > total_sectors - sector) {
return false;
}
return true;
}
| false | qemu | 75af1f34cd5b07c3c7fcf86dfc99a42de48a600d | static bool virtio_blk_sect_range_ok(VirtIOBlock *dev,
uint64_t sector, size_t size)
{
uint64_t nb_sectors = size >> BDRV_SECTOR_BITS;
uint64_t total_sectors;
if (nb_sectors > INT_MAX) {
return false;
}
if (sector & dev->sector_mask) {
return false;
}
if (size % dev->conf.conf.logical_block_size) {
return false;
}
blk_get_geometry(dev->blk, &total_sectors);
if (sector > total_sectors || nb_sectors > total_sectors - sector) {
return false;
}
return true;
}
| {
"code": [],
"line_no": []
} | static bool FUNC_0(VirtIOBlock *dev,
uint64_t sector, size_t size)
{
uint64_t nb_sectors = size >> BDRV_SECTOR_BITS;
uint64_t total_sectors;
if (nb_sectors > INT_MAX) {
return false;
}
if (sector & dev->sector_mask) {
return false;
}
if (size % dev->conf.conf.logical_block_size) {
return false;
}
blk_get_geometry(dev->blk, &total_sectors);
if (sector > total_sectors || nb_sectors > total_sectors - sector) {
return false;
}
return true;
}
| [
"static bool FUNC_0(VirtIOBlock *dev,\nuint64_t sector, size_t size)\n{",
"uint64_t nb_sectors = size >> BDRV_SECTOR_BITS;",
"uint64_t total_sectors;",
"if (nb_sectors > INT_MAX) {",
"return false;",
"}",
"if (sector & dev->sector_mask) {",
"return false;",
"}",
"if (size % dev->conf.conf.logical_block_size) {",
"return false;",
"}",
"blk_get_geometry(dev->blk, &total_sectors);",
"if (sector > total_sectors || nb_sectors > total_sectors - sector) {",
"return false;",
"}",
"return true;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
]
] |
26,801 | static inline void RENAME(rgb16to15)(const uint8_t *src, uint8_t *dst, long src_size)
{
register const uint8_t* s=src;
register uint8_t* d=dst;
register const uint8_t *end;
const uint8_t *mm_end;
end = s + src_size;
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(PREFETCH" %0"::"m"(*s));
__asm__ volatile("movq %0, %%mm7"::"m"(mask15rg));
__asm__ volatile("movq %0, %%mm6"::"m"(mask15b));
mm_end = end - 15;
while (s<mm_end) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq 8%1, %%mm2 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"psrlq $1, %%mm0 \n\t"
"psrlq $1, %%mm2 \n\t"
"pand %%mm7, %%mm0 \n\t"
"pand %%mm7, %%mm2 \n\t"
"pand %%mm6, %%mm1 \n\t"
"pand %%mm6, %%mm3 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm3, %%mm2 \n\t"
MOVNTQ" %%mm0, %0 \n\t"
MOVNTQ" %%mm2, 8%0"
:"=m"(*d)
:"m"(*s)
);
d+=16;
s+=16;
}
__asm__ volatile(SFENCE:::"memory");
__asm__ volatile(EMMS:::"memory");
#endif
mm_end = end - 3;
while (s < mm_end) {
register uint32_t x= *((const uint32_t*)s);
*((uint32_t *)d) = ((x>>1)&0x7FE07FE0) | (x&0x001F001F);
s+=4;
d+=4;
}
if (s < end) {
register uint16_t x= *((const uint16_t*)s);
*((uint16_t *)d) = ((x>>1)&0x7FE0) | (x&0x001F);
}
}
| false | FFmpeg | d1adad3cca407f493c3637e20ecd4f7124e69212 | static inline void RENAME(rgb16to15)(const uint8_t *src, uint8_t *dst, long src_size)
{
register const uint8_t* s=src;
register uint8_t* d=dst;
register const uint8_t *end;
const uint8_t *mm_end;
end = s + src_size;
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(PREFETCH" %0"::"m"(*s));
__asm__ volatile("movq %0, %%mm7"::"m"(mask15rg));
__asm__ volatile("movq %0, %%mm6"::"m"(mask15b));
mm_end = end - 15;
while (s<mm_end) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq 8%1, %%mm2 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"psrlq $1, %%mm0 \n\t"
"psrlq $1, %%mm2 \n\t"
"pand %%mm7, %%mm0 \n\t"
"pand %%mm7, %%mm2 \n\t"
"pand %%mm6, %%mm1 \n\t"
"pand %%mm6, %%mm3 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm3, %%mm2 \n\t"
MOVNTQ" %%mm0, %0 \n\t"
MOVNTQ" %%mm2, 8%0"
:"=m"(*d)
:"m"(*s)
);
d+=16;
s+=16;
}
__asm__ volatile(SFENCE:::"memory");
__asm__ volatile(EMMS:::"memory");
#endif
mm_end = end - 3;
while (s < mm_end) {
register uint32_t x= *((const uint32_t*)s);
*((uint32_t *)d) = ((x>>1)&0x7FE07FE0) | (x&0x001F001F);
s+=4;
d+=4;
}
if (s < end) {
register uint16_t x= *((const uint16_t*)s);
*((uint16_t *)d) = ((x>>1)&0x7FE0) | (x&0x001F);
}
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(rgb16to15)(const uint8_t *src, uint8_t *dst, long src_size)
{
register const uint8_t* VAR_0=src;
register uint8_t* VAR_1=dst;
register const uint8_t *VAR_2;
const uint8_t *VAR_3;
VAR_2 = VAR_0 + src_size;
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(PREFETCH" %0"::"m"(*VAR_0));
__asm__ volatile("movq %0, %%mm7"::"m"(mask15rg));
__asm__ volatile("movq %0, %%mm6"::"m"(mask15b));
VAR_3 = VAR_2 - 15;
while (VAR_0<VAR_3) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq 8%1, %%mm2 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"psrlq $1, %%mm0 \n\t"
"psrlq $1, %%mm2 \n\t"
"pand %%mm7, %%mm0 \n\t"
"pand %%mm7, %%mm2 \n\t"
"pand %%mm6, %%mm1 \n\t"
"pand %%mm6, %%mm3 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm3, %%mm2 \n\t"
MOVNTQ" %%mm0, %0 \n\t"
MOVNTQ" %%mm2, 8%0"
:"=m"(*VAR_1)
:"m"(*VAR_0)
);
VAR_1+=16;
VAR_0+=16;
}
__asm__ volatile(SFENCE:::"memory");
__asm__ volatile(EMMS:::"memory");
#endif
VAR_3 = VAR_2 - 3;
while (VAR_0 < VAR_3) {
register uint32_t VAR_5= *((const uint32_t*)VAR_0);
*((uint32_t *)VAR_1) = ((VAR_5>>1)&0x7FE07FE0) | (VAR_5&0x001F001F);
VAR_0+=4;
VAR_1+=4;
}
if (VAR_0 < VAR_2) {
register uint16_t VAR_5= *((const uint16_t*)VAR_0);
*((uint16_t *)VAR_1) = ((VAR_5>>1)&0x7FE0) | (VAR_5&0x001F);
}
}
| [
"static inline void FUNC_0(rgb16to15)(const uint8_t *src, uint8_t *dst, long src_size)\n{",
"register const uint8_t* VAR_0=src;",
"register uint8_t* VAR_1=dst;",
"register const uint8_t *VAR_2;",
"const uint8_t *VAR_3;",
"VAR_2 = VAR_0 + src_size;",
"#if COMPILE_TEMPLATE_MMX\n__asm__ volatile(PREFETCH\" %0\"::\"m\"(*VAR_0));",
"__asm__ volatile(\"movq %0, %%mm7\"::\"m\"(mask15rg));",
"__asm__ volatile(\"movq %0, %%mm6\"::\"m\"(mask15b));",
"VAR_3 = VAR_2 - 15;",
"while (VAR_0<VAR_3) {",
"__asm__ volatile(\nPREFETCH\" 32%1 \\n\\t\"\n\"movq %1, %%mm0 \\n\\t\"\n\"movq 8%1, %%mm2 \\n\\t\"\n\"movq %%mm0, %%mm1 \\n\\t\"\n\"movq %%mm2, %%mm3 \\n\\t\"\n\"psrlq $1, %%mm0 \\n\\t\"\n\"psrlq $1, %%mm2 \\n\\t\"\n\"pand %%mm7, %%mm0 \\n\\t\"\n\"pand %%mm7, %%mm2 \\n\\t\"\n\"pand %%mm6, %%mm1 \\n\\t\"\n\"pand %%mm6, %%mm3 \\n\\t\"\n\"por %%mm1, %%mm0 \\n\\t\"\n\"por %%mm3, %%mm2 \\n\\t\"\nMOVNTQ\" %%mm0, %0 \\n\\t\"\nMOVNTQ\" %%mm2, 8%0\"\n:\"=m\"(*VAR_1)\n:\"m\"(*VAR_0)\n);",
"VAR_1+=16;",
"VAR_0+=16;",
"}",
"__asm__ volatile(SFENCE:::\"memory\");",
"__asm__ volatile(EMMS:::\"memory\");",
"#endif\nVAR_3 = VAR_2 - 3;",
"while (VAR_0 < VAR_3) {",
"register uint32_t VAR_5= *((const uint32_t*)VAR_0);",
"*((uint32_t *)VAR_1) = ((VAR_5>>1)&0x7FE07FE0) | (VAR_5&0x001F001F);",
"VAR_0+=4;",
"VAR_1+=4;",
"}",
"if (VAR_0 < VAR_2) {",
"register uint16_t VAR_5= *((const uint16_t*)VAR_0);",
"*((uint16_t *)VAR_1) = ((VAR_5>>1)&0x7FE0) | (VAR_5&0x001F);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27,
29,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
]
] |
26,802 | static void do_interrupt64(CPUX86State *env, int intno, int is_int,
int error_code, target_ulong next_eip, int is_hw)
{
SegmentCache *dt;
target_ulong ptr;
int type, dpl, selector, cpl, ist;
int has_error_code, new_stack;
uint32_t e1, e2, e3, ss;
target_ulong old_eip, esp, offset;
has_error_code = 0;
if (!is_int && !is_hw) {
has_error_code = exception_has_error_code(intno);
}
if (is_int) {
old_eip = next_eip;
} else {
old_eip = env->eip;
}
dt = &env->idt;
if (intno * 16 + 15 > dt->limit) {
raise_exception_err(env, EXCP0D_GPF, intno * 16 + 2);
}
ptr = dt->base + intno * 16;
e1 = cpu_ldl_kernel(env, ptr);
e2 = cpu_ldl_kernel(env, ptr + 4);
e3 = cpu_ldl_kernel(env, ptr + 8);
/* check gate type */
type = (e2 >> DESC_TYPE_SHIFT) & 0x1f;
switch (type) {
case 14: /* 386 interrupt gate */
case 15: /* 386 trap gate */
break;
default:
raise_exception_err(env, EXCP0D_GPF, intno * 16 + 2);
break;
}
dpl = (e2 >> DESC_DPL_SHIFT) & 3;
cpl = env->hflags & HF_CPL_MASK;
/* check privilege if software int */
if (is_int && dpl < cpl) {
raise_exception_err(env, EXCP0D_GPF, intno * 16 + 2);
}
/* check valid bit */
if (!(e2 & DESC_P_MASK)) {
raise_exception_err(env, EXCP0B_NOSEG, intno * 16 + 2);
}
selector = e1 >> 16;
offset = ((target_ulong)e3 << 32) | (e2 & 0xffff0000) | (e1 & 0x0000ffff);
ist = e2 & 7;
if ((selector & 0xfffc) == 0) {
raise_exception_err(env, EXCP0D_GPF, 0);
}
if (load_segment(env, &e1, &e2, selector) != 0) {
raise_exception_err(env, EXCP0D_GPF, selector & 0xfffc);
}
if (!(e2 & DESC_S_MASK) || !(e2 & (DESC_CS_MASK))) {
raise_exception_err(env, EXCP0D_GPF, selector & 0xfffc);
}
dpl = (e2 >> DESC_DPL_SHIFT) & 3;
if (dpl > cpl) {
raise_exception_err(env, EXCP0D_GPF, selector & 0xfffc);
}
if (!(e2 & DESC_P_MASK)) {
raise_exception_err(env, EXCP0B_NOSEG, selector & 0xfffc);
}
if (!(e2 & DESC_L_MASK) || (e2 & DESC_B_MASK)) {
raise_exception_err(env, EXCP0D_GPF, selector & 0xfffc);
}
if ((!(e2 & DESC_C_MASK) && dpl < cpl) || ist != 0) {
/* to inner privilege */
if (ist != 0) {
esp = get_rsp_from_tss(env, ist + 3);
} else {
esp = get_rsp_from_tss(env, dpl);
}
esp &= ~0xfLL; /* align stack */
ss = 0;
new_stack = 1;
} else if ((e2 & DESC_C_MASK) || dpl == cpl) {
/* to same privilege */
if (env->eflags & VM_MASK) {
raise_exception_err(env, EXCP0D_GPF, selector & 0xfffc);
}
new_stack = 0;
if (ist != 0) {
esp = get_rsp_from_tss(env, ist + 3);
} else {
esp = env->regs[R_ESP];
}
esp &= ~0xfLL; /* align stack */
dpl = cpl;
} else {
raise_exception_err(env, EXCP0D_GPF, selector & 0xfffc);
new_stack = 0; /* avoid warning */
esp = 0; /* avoid warning */
}
PUSHQ(esp, env->segs[R_SS].selector);
PUSHQ(esp, env->regs[R_ESP]);
PUSHQ(esp, cpu_compute_eflags(env));
PUSHQ(esp, env->segs[R_CS].selector);
PUSHQ(esp, old_eip);
if (has_error_code) {
PUSHQ(esp, error_code);
}
/* interrupt gate clear IF mask */
if ((type & 1) == 0) {
env->eflags &= ~IF_MASK;
}
env->eflags &= ~(TF_MASK | VM_MASK | RF_MASK | NT_MASK);
if (new_stack) {
ss = 0 | dpl;
cpu_x86_load_seg_cache(env, R_SS, ss, 0, 0, 0);
}
env->regs[R_ESP] = esp;
selector = (selector & ~3) | dpl;
cpu_x86_load_seg_cache(env, R_CS, selector,
get_seg_base(e1, e2),
get_seg_limit(e1, e2),
e2);
env->eip = offset;
}
| false | qemu | ae67dc72e4f19238941894227d96b6201d71a70a | static void do_interrupt64(CPUX86State *env, int intno, int is_int,
int error_code, target_ulong next_eip, int is_hw)
{
SegmentCache *dt;
target_ulong ptr;
int type, dpl, selector, cpl, ist;
int has_error_code, new_stack;
uint32_t e1, e2, e3, ss;
target_ulong old_eip, esp, offset;
has_error_code = 0;
if (!is_int && !is_hw) {
has_error_code = exception_has_error_code(intno);
}
if (is_int) {
old_eip = next_eip;
} else {
old_eip = env->eip;
}
dt = &env->idt;
if (intno * 16 + 15 > dt->limit) {
raise_exception_err(env, EXCP0D_GPF, intno * 16 + 2);
}
ptr = dt->base + intno * 16;
e1 = cpu_ldl_kernel(env, ptr);
e2 = cpu_ldl_kernel(env, ptr + 4);
e3 = cpu_ldl_kernel(env, ptr + 8);
type = (e2 >> DESC_TYPE_SHIFT) & 0x1f;
switch (type) {
case 14:
case 15:
break;
default:
raise_exception_err(env, EXCP0D_GPF, intno * 16 + 2);
break;
}
dpl = (e2 >> DESC_DPL_SHIFT) & 3;
cpl = env->hflags & HF_CPL_MASK;
if (is_int && dpl < cpl) {
raise_exception_err(env, EXCP0D_GPF, intno * 16 + 2);
}
if (!(e2 & DESC_P_MASK)) {
raise_exception_err(env, EXCP0B_NOSEG, intno * 16 + 2);
}
selector = e1 >> 16;
offset = ((target_ulong)e3 << 32) | (e2 & 0xffff0000) | (e1 & 0x0000ffff);
ist = e2 & 7;
if ((selector & 0xfffc) == 0) {
raise_exception_err(env, EXCP0D_GPF, 0);
}
if (load_segment(env, &e1, &e2, selector) != 0) {
raise_exception_err(env, EXCP0D_GPF, selector & 0xfffc);
}
if (!(e2 & DESC_S_MASK) || !(e2 & (DESC_CS_MASK))) {
raise_exception_err(env, EXCP0D_GPF, selector & 0xfffc);
}
dpl = (e2 >> DESC_DPL_SHIFT) & 3;
if (dpl > cpl) {
raise_exception_err(env, EXCP0D_GPF, selector & 0xfffc);
}
if (!(e2 & DESC_P_MASK)) {
raise_exception_err(env, EXCP0B_NOSEG, selector & 0xfffc);
}
if (!(e2 & DESC_L_MASK) || (e2 & DESC_B_MASK)) {
raise_exception_err(env, EXCP0D_GPF, selector & 0xfffc);
}
if ((!(e2 & DESC_C_MASK) && dpl < cpl) || ist != 0) {
if (ist != 0) {
esp = get_rsp_from_tss(env, ist + 3);
} else {
esp = get_rsp_from_tss(env, dpl);
}
esp &= ~0xfLL;
ss = 0;
new_stack = 1;
} else if ((e2 & DESC_C_MASK) || dpl == cpl) {
if (env->eflags & VM_MASK) {
raise_exception_err(env, EXCP0D_GPF, selector & 0xfffc);
}
new_stack = 0;
if (ist != 0) {
esp = get_rsp_from_tss(env, ist + 3);
} else {
esp = env->regs[R_ESP];
}
esp &= ~0xfLL;
dpl = cpl;
} else {
raise_exception_err(env, EXCP0D_GPF, selector & 0xfffc);
new_stack = 0;
esp = 0;
}
PUSHQ(esp, env->segs[R_SS].selector);
PUSHQ(esp, env->regs[R_ESP]);
PUSHQ(esp, cpu_compute_eflags(env));
PUSHQ(esp, env->segs[R_CS].selector);
PUSHQ(esp, old_eip);
if (has_error_code) {
PUSHQ(esp, error_code);
}
if ((type & 1) == 0) {
env->eflags &= ~IF_MASK;
}
env->eflags &= ~(TF_MASK | VM_MASK | RF_MASK | NT_MASK);
if (new_stack) {
ss = 0 | dpl;
cpu_x86_load_seg_cache(env, R_SS, ss, 0, 0, 0);
}
env->regs[R_ESP] = esp;
selector = (selector & ~3) | dpl;
cpu_x86_load_seg_cache(env, R_CS, selector,
get_seg_base(e1, e2),
get_seg_limit(e1, e2),
e2);
env->eip = offset;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(CPUX86State *VAR_0, int VAR_1, int VAR_2,
int VAR_3, target_ulong VAR_4, int VAR_5)
{
SegmentCache *dt;
target_ulong ptr;
int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;
int VAR_11, VAR_12;
uint32_t e1, e2, e3, ss;
target_ulong old_eip, esp, offset;
VAR_11 = 0;
if (!VAR_2 && !VAR_5) {
VAR_11 = exception_has_error_code(VAR_1);
}
if (VAR_2) {
old_eip = VAR_4;
} else {
old_eip = VAR_0->eip;
}
dt = &VAR_0->idt;
if (VAR_1 * 16 + 15 > dt->limit) {
raise_exception_err(VAR_0, EXCP0D_GPF, VAR_1 * 16 + 2);
}
ptr = dt->base + VAR_1 * 16;
e1 = cpu_ldl_kernel(VAR_0, ptr);
e2 = cpu_ldl_kernel(VAR_0, ptr + 4);
e3 = cpu_ldl_kernel(VAR_0, ptr + 8);
VAR_6 = (e2 >> DESC_TYPE_SHIFT) & 0x1f;
switch (VAR_6) {
case 14:
case 15:
break;
default:
raise_exception_err(VAR_0, EXCP0D_GPF, VAR_1 * 16 + 2);
break;
}
VAR_7 = (e2 >> DESC_DPL_SHIFT) & 3;
VAR_9 = VAR_0->hflags & HF_CPL_MASK;
if (VAR_2 && VAR_7 < VAR_9) {
raise_exception_err(VAR_0, EXCP0D_GPF, VAR_1 * 16 + 2);
}
if (!(e2 & DESC_P_MASK)) {
raise_exception_err(VAR_0, EXCP0B_NOSEG, VAR_1 * 16 + 2);
}
VAR_8 = e1 >> 16;
offset = ((target_ulong)e3 << 32) | (e2 & 0xffff0000) | (e1 & 0x0000ffff);
VAR_10 = e2 & 7;
if ((VAR_8 & 0xfffc) == 0) {
raise_exception_err(VAR_0, EXCP0D_GPF, 0);
}
if (load_segment(VAR_0, &e1, &e2, VAR_8) != 0) {
raise_exception_err(VAR_0, EXCP0D_GPF, VAR_8 & 0xfffc);
}
if (!(e2 & DESC_S_MASK) || !(e2 & (DESC_CS_MASK))) {
raise_exception_err(VAR_0, EXCP0D_GPF, VAR_8 & 0xfffc);
}
VAR_7 = (e2 >> DESC_DPL_SHIFT) & 3;
if (VAR_7 > VAR_9) {
raise_exception_err(VAR_0, EXCP0D_GPF, VAR_8 & 0xfffc);
}
if (!(e2 & DESC_P_MASK)) {
raise_exception_err(VAR_0, EXCP0B_NOSEG, VAR_8 & 0xfffc);
}
if (!(e2 & DESC_L_MASK) || (e2 & DESC_B_MASK)) {
raise_exception_err(VAR_0, EXCP0D_GPF, VAR_8 & 0xfffc);
}
if ((!(e2 & DESC_C_MASK) && VAR_7 < VAR_9) || VAR_10 != 0) {
if (VAR_10 != 0) {
esp = get_rsp_from_tss(VAR_0, VAR_10 + 3);
} else {
esp = get_rsp_from_tss(VAR_0, VAR_7);
}
esp &= ~0xfLL;
ss = 0;
VAR_12 = 1;
} else if ((e2 & DESC_C_MASK) || VAR_7 == VAR_9) {
if (VAR_0->eflags & VM_MASK) {
raise_exception_err(VAR_0, EXCP0D_GPF, VAR_8 & 0xfffc);
}
VAR_12 = 0;
if (VAR_10 != 0) {
esp = get_rsp_from_tss(VAR_0, VAR_10 + 3);
} else {
esp = VAR_0->regs[R_ESP];
}
esp &= ~0xfLL;
VAR_7 = VAR_9;
} else {
raise_exception_err(VAR_0, EXCP0D_GPF, VAR_8 & 0xfffc);
VAR_12 = 0;
esp = 0;
}
PUSHQ(esp, VAR_0->segs[R_SS].VAR_8);
PUSHQ(esp, VAR_0->regs[R_ESP]);
PUSHQ(esp, cpu_compute_eflags(VAR_0));
PUSHQ(esp, VAR_0->segs[R_CS].VAR_8);
PUSHQ(esp, old_eip);
if (VAR_11) {
PUSHQ(esp, VAR_3);
}
if ((VAR_6 & 1) == 0) {
VAR_0->eflags &= ~IF_MASK;
}
VAR_0->eflags &= ~(TF_MASK | VM_MASK | RF_MASK | NT_MASK);
if (VAR_12) {
ss = 0 | VAR_7;
cpu_x86_load_seg_cache(VAR_0, R_SS, ss, 0, 0, 0);
}
VAR_0->regs[R_ESP] = esp;
VAR_8 = (VAR_8 & ~3) | VAR_7;
cpu_x86_load_seg_cache(VAR_0, R_CS, VAR_8,
get_seg_base(e1, e2),
get_seg_limit(e1, e2),
e2);
VAR_0->eip = offset;
}
| [
"static void FUNC_0(CPUX86State *VAR_0, int VAR_1, int VAR_2,\nint VAR_3, target_ulong VAR_4, int VAR_5)\n{",
"SegmentCache *dt;",
"target_ulong ptr;",
"int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;",
"int VAR_11, VAR_12;",
"uint32_t e1, e2, e3, ss;",
"target_ulong old_eip, esp, offset;",
"VAR_11 = 0;",
"if (!VAR_2 && !VAR_5) {",
"VAR_11 = exception_has_error_code(VAR_1);",
"}",
"if (VAR_2) {",
"old_eip = VAR_4;",
"} else {",
"old_eip = VAR_0->eip;",
"}",
"dt = &VAR_0->idt;",
"if (VAR_1 * 16 + 15 > dt->limit) {",
"raise_exception_err(VAR_0, EXCP0D_GPF, VAR_1 * 16 + 2);",
"}",
"ptr = dt->base + VAR_1 * 16;",
"e1 = cpu_ldl_kernel(VAR_0, ptr);",
"e2 = cpu_ldl_kernel(VAR_0, ptr + 4);",
"e3 = cpu_ldl_kernel(VAR_0, ptr + 8);",
"VAR_6 = (e2 >> DESC_TYPE_SHIFT) & 0x1f;",
"switch (VAR_6) {",
"case 14:\ncase 15:\nbreak;",
"default:\nraise_exception_err(VAR_0, EXCP0D_GPF, VAR_1 * 16 + 2);",
"break;",
"}",
"VAR_7 = (e2 >> DESC_DPL_SHIFT) & 3;",
"VAR_9 = VAR_0->hflags & HF_CPL_MASK;",
"if (VAR_2 && VAR_7 < VAR_9) {",
"raise_exception_err(VAR_0, EXCP0D_GPF, VAR_1 * 16 + 2);",
"}",
"if (!(e2 & DESC_P_MASK)) {",
"raise_exception_err(VAR_0, EXCP0B_NOSEG, VAR_1 * 16 + 2);",
"}",
"VAR_8 = e1 >> 16;",
"offset = ((target_ulong)e3 << 32) | (e2 & 0xffff0000) | (e1 & 0x0000ffff);",
"VAR_10 = e2 & 7;",
"if ((VAR_8 & 0xfffc) == 0) {",
"raise_exception_err(VAR_0, EXCP0D_GPF, 0);",
"}",
"if (load_segment(VAR_0, &e1, &e2, VAR_8) != 0) {",
"raise_exception_err(VAR_0, EXCP0D_GPF, VAR_8 & 0xfffc);",
"}",
"if (!(e2 & DESC_S_MASK) || !(e2 & (DESC_CS_MASK))) {",
"raise_exception_err(VAR_0, EXCP0D_GPF, VAR_8 & 0xfffc);",
"}",
"VAR_7 = (e2 >> DESC_DPL_SHIFT) & 3;",
"if (VAR_7 > VAR_9) {",
"raise_exception_err(VAR_0, EXCP0D_GPF, VAR_8 & 0xfffc);",
"}",
"if (!(e2 & DESC_P_MASK)) {",
"raise_exception_err(VAR_0, EXCP0B_NOSEG, VAR_8 & 0xfffc);",
"}",
"if (!(e2 & DESC_L_MASK) || (e2 & DESC_B_MASK)) {",
"raise_exception_err(VAR_0, EXCP0D_GPF, VAR_8 & 0xfffc);",
"}",
"if ((!(e2 & DESC_C_MASK) && VAR_7 < VAR_9) || VAR_10 != 0) {",
"if (VAR_10 != 0) {",
"esp = get_rsp_from_tss(VAR_0, VAR_10 + 3);",
"} else {",
"esp = get_rsp_from_tss(VAR_0, VAR_7);",
"}",
"esp &= ~0xfLL;",
"ss = 0;",
"VAR_12 = 1;",
"} else if ((e2 & DESC_C_MASK) || VAR_7 == VAR_9) {",
"if (VAR_0->eflags & VM_MASK) {",
"raise_exception_err(VAR_0, EXCP0D_GPF, VAR_8 & 0xfffc);",
"}",
"VAR_12 = 0;",
"if (VAR_10 != 0) {",
"esp = get_rsp_from_tss(VAR_0, VAR_10 + 3);",
"} else {",
"esp = VAR_0->regs[R_ESP];",
"}",
"esp &= ~0xfLL;",
"VAR_7 = VAR_9;",
"} else {",
"raise_exception_err(VAR_0, EXCP0D_GPF, VAR_8 & 0xfffc);",
"VAR_12 = 0;",
"esp = 0;",
"}",
"PUSHQ(esp, VAR_0->segs[R_SS].VAR_8);",
"PUSHQ(esp, VAR_0->regs[R_ESP]);",
"PUSHQ(esp, cpu_compute_eflags(VAR_0));",
"PUSHQ(esp, VAR_0->segs[R_CS].VAR_8);",
"PUSHQ(esp, old_eip);",
"if (VAR_11) {",
"PUSHQ(esp, VAR_3);",
"}",
"if ((VAR_6 & 1) == 0) {",
"VAR_0->eflags &= ~IF_MASK;",
"}",
"VAR_0->eflags &= ~(TF_MASK | VM_MASK | RF_MASK | NT_MASK);",
"if (VAR_12) {",
"ss = 0 | VAR_7;",
"cpu_x86_load_seg_cache(VAR_0, R_SS, ss, 0, 0, 0);",
"}",
"VAR_0->regs[R_ESP] = esp;",
"VAR_8 = (VAR_8 & ~3) | VAR_7;",
"cpu_x86_load_seg_cache(VAR_0, R_CS, VAR_8,\nget_seg_base(e1, e2),\nget_seg_limit(e1, e2),\ne2);",
"VAR_0->eip = offset;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63,
65,
67
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
221
],
[
223
],
[
225
],
[
227
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
243
],
[
245,
247,
249,
251
],
[
253
],
[
255
]
] |
26,803 | static void sdhci_generic_reset(DeviceState *ds)
{
SDHCIState *s = SDHCI(ds);
SDHCI_GET_CLASS(s)->reset(s);
}
| false | qemu | d368ba4376b2c1c24175c74b3733b8fe64dbe8a6 | static void sdhci_generic_reset(DeviceState *ds)
{
SDHCIState *s = SDHCI(ds);
SDHCI_GET_CLASS(s)->reset(s);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0)
{
SDHCIState *s = SDHCI(VAR_0);
SDHCI_GET_CLASS(s)->reset(s);
}
| [
"static void FUNC_0(DeviceState *VAR_0)\n{",
"SDHCIState *s = SDHCI(VAR_0);",
"SDHCI_GET_CLASS(s)->reset(s);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
26,804 | static void write_vec_element_i32(DisasContext *s, TCGv_i32 tcg_src,
int destidx, int element, TCGMemOp memop)
{
int vect_off = vec_reg_offset(destidx, element, memop & MO_SIZE);
switch (memop) {
case MO_8:
tcg_gen_st8_i32(tcg_src, cpu_env, vect_off);
break;
case MO_16:
tcg_gen_st16_i32(tcg_src, cpu_env, vect_off);
break;
case MO_32:
tcg_gen_st_i32(tcg_src, cpu_env, vect_off);
break;
default:
g_assert_not_reached();
}
}
| false | qemu | 90e496386fe7fd32c189561f846b7913f95b8cf4 | static void write_vec_element_i32(DisasContext *s, TCGv_i32 tcg_src,
int destidx, int element, TCGMemOp memop)
{
int vect_off = vec_reg_offset(destidx, element, memop & MO_SIZE);
switch (memop) {
case MO_8:
tcg_gen_st8_i32(tcg_src, cpu_env, vect_off);
break;
case MO_16:
tcg_gen_st16_i32(tcg_src, cpu_env, vect_off);
break;
case MO_32:
tcg_gen_st_i32(tcg_src, cpu_env, vect_off);
break;
default:
g_assert_not_reached();
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0, TCGv_i32 VAR_1,
int VAR_2, int VAR_3, TCGMemOp VAR_4)
{
int VAR_5 = vec_reg_offset(VAR_2, VAR_3, VAR_4 & MO_SIZE);
switch (VAR_4) {
case MO_8:
tcg_gen_st8_i32(VAR_1, cpu_env, VAR_5);
break;
case MO_16:
tcg_gen_st16_i32(VAR_1, cpu_env, VAR_5);
break;
case MO_32:
tcg_gen_st_i32(VAR_1, cpu_env, VAR_5);
break;
default:
g_assert_not_reached();
}
}
| [
"static void FUNC_0(DisasContext *VAR_0, TCGv_i32 VAR_1,\nint VAR_2, int VAR_3, TCGMemOp VAR_4)\n{",
"int VAR_5 = vec_reg_offset(VAR_2, VAR_3, VAR_4 & MO_SIZE);",
"switch (VAR_4) {",
"case MO_8:\ntcg_gen_st8_i32(VAR_1, cpu_env, VAR_5);",
"break;",
"case MO_16:\ntcg_gen_st16_i32(VAR_1, cpu_env, VAR_5);",
"break;",
"case MO_32:\ntcg_gen_st_i32(VAR_1, cpu_env, VAR_5);",
"break;",
"default:\ng_assert_not_reached();",
"}",
"}"
] | [
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
]
] |
26,805 | static void net_socket_cleanup(NetClientState *nc)
{
NetSocketState *s = DO_UPCAST(NetSocketState, nc, nc);
qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
close(s->fd);
}
| false | qemu | 011de2b512a83aa5e9f8899ed5bbf2f31995b90e | static void net_socket_cleanup(NetClientState *nc)
{
NetSocketState *s = DO_UPCAST(NetSocketState, nc, nc);
qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
close(s->fd);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(NetClientState *VAR_0)
{
NetSocketState *s = DO_UPCAST(NetSocketState, VAR_0, VAR_0);
qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
close(s->fd);
}
| [
"static void FUNC_0(NetClientState *VAR_0)\n{",
"NetSocketState *s = DO_UPCAST(NetSocketState, VAR_0, VAR_0);",
"qemu_set_fd_handler(s->fd, NULL, NULL, NULL);",
"close(s->fd);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
26,806 | void qtest_init(const char *qtest_chrdev, const char *qtest_log, Error **errp)
{
CharDriverState *chr;
chr = qemu_chr_new("qtest", qtest_chrdev, NULL);
if (chr == NULL) {
error_setg(errp, "Failed to initialize device for qtest: \"%s\"",
qtest_chrdev);
return;
}
qemu_chr_add_handlers(chr, qtest_can_read, qtest_read, qtest_event, chr);
qemu_chr_fe_set_echo(chr, true);
inbuf = g_string_new("");
if (qtest_log) {
if (strcmp(qtest_log, "none") != 0) {
qtest_log_fp = fopen(qtest_log, "w+");
}
} else {
qtest_log_fp = stderr;
}
qtest_chr = chr;
}
| false | qemu | 107684c05d80c457aa6e81d090b36a1a294110ec | void qtest_init(const char *qtest_chrdev, const char *qtest_log, Error **errp)
{
CharDriverState *chr;
chr = qemu_chr_new("qtest", qtest_chrdev, NULL);
if (chr == NULL) {
error_setg(errp, "Failed to initialize device for qtest: \"%s\"",
qtest_chrdev);
return;
}
qemu_chr_add_handlers(chr, qtest_can_read, qtest_read, qtest_event, chr);
qemu_chr_fe_set_echo(chr, true);
inbuf = g_string_new("");
if (qtest_log) {
if (strcmp(qtest_log, "none") != 0) {
qtest_log_fp = fopen(qtest_log, "w+");
}
} else {
qtest_log_fp = stderr;
}
qtest_chr = chr;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(const char *VAR_0, const char *VAR_1, Error **VAR_2)
{
CharDriverState *chr;
chr = qemu_chr_new("qtest", VAR_0, NULL);
if (chr == NULL) {
error_setg(VAR_2, "Failed to initialize device for qtest: \"%s\"",
VAR_0);
return;
}
qemu_chr_add_handlers(chr, qtest_can_read, qtest_read, qtest_event, chr);
qemu_chr_fe_set_echo(chr, true);
inbuf = g_string_new("");
if (VAR_1) {
if (strcmp(VAR_1, "none") != 0) {
qtest_log_fp = fopen(VAR_1, "w+");
}
} else {
qtest_log_fp = stderr;
}
qtest_chr = chr;
}
| [
"void FUNC_0(const char *VAR_0, const char *VAR_1, Error **VAR_2)\n{",
"CharDriverState *chr;",
"chr = qemu_chr_new(\"qtest\", VAR_0, NULL);",
"if (chr == NULL) {",
"error_setg(VAR_2, \"Failed to initialize device for qtest: \\\"%s\\\"\",\nVAR_0);",
"return;",
"}",
"qemu_chr_add_handlers(chr, qtest_can_read, qtest_read, qtest_event, chr);",
"qemu_chr_fe_set_echo(chr, true);",
"inbuf = g_string_new(\"\");",
"if (VAR_1) {",
"if (strcmp(VAR_1, \"none\") != 0) {",
"qtest_log_fp = fopen(VAR_1, \"w+\");",
"}",
"} else {",
"qtest_log_fp = stderr;",
"}",
"qtest_chr = chr;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
]
] |
26,809 | static uint32_t taihu_cpld_readl (void *opaque, hwaddr addr)
{
uint32_t ret;
ret = taihu_cpld_readb(opaque, addr) << 24;
ret |= taihu_cpld_readb(opaque, addr + 1) << 16;
ret |= taihu_cpld_readb(opaque, addr + 2) << 8;
ret |= taihu_cpld_readb(opaque, addr + 3);
return ret;
}
| false | qemu | e2a176dfda32f5cf80703c2921a19fe75850c38c | static uint32_t taihu_cpld_readl (void *opaque, hwaddr addr)
{
uint32_t ret;
ret = taihu_cpld_readb(opaque, addr) << 24;
ret |= taihu_cpld_readb(opaque, addr + 1) << 16;
ret |= taihu_cpld_readb(opaque, addr + 2) << 8;
ret |= taihu_cpld_readb(opaque, addr + 3);
return ret;
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0 (void *opaque, hwaddr addr)
{
uint32_t ret;
ret = taihu_cpld_readb(opaque, addr) << 24;
ret |= taihu_cpld_readb(opaque, addr + 1) << 16;
ret |= taihu_cpld_readb(opaque, addr + 2) << 8;
ret |= taihu_cpld_readb(opaque, addr + 3);
return ret;
}
| [
"static uint32_t FUNC_0 (void *opaque, hwaddr addr)\n{",
"uint32_t ret;",
"ret = taihu_cpld_readb(opaque, addr) << 24;",
"ret |= taihu_cpld_readb(opaque, addr + 1) << 16;",
"ret |= taihu_cpld_readb(opaque, addr + 2) << 8;",
"ret |= taihu_cpld_readb(opaque, addr + 3);",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
]
] |
26,810 | static int htab_save_complete(QEMUFile *f, void *opaque)
{
sPAPRMachineState *spapr = opaque;
/* Iteration header */
qemu_put_be32(f, 0);
if (!spapr->htab) {
int rc;
assert(kvm_enabled());
rc = spapr_check_htab_fd(spapr);
if (rc < 0) {
return rc;
}
rc = kvmppc_save_htab(f, spapr->htab_fd, MAX_KVM_BUF_SIZE, -1);
if (rc < 0) {
return rc;
}
close(spapr->htab_fd);
spapr->htab_fd = -1;
} else {
htab_save_later_pass(f, spapr, -1);
}
/* End marker */
qemu_put_be32(f, 0);
qemu_put_be16(f, 0);
qemu_put_be16(f, 0);
return 0;
}
| false | qemu | 715c54071a43ab978dc12b9da22a5016203ed284 | static int htab_save_complete(QEMUFile *f, void *opaque)
{
sPAPRMachineState *spapr = opaque;
qemu_put_be32(f, 0);
if (!spapr->htab) {
int rc;
assert(kvm_enabled());
rc = spapr_check_htab_fd(spapr);
if (rc < 0) {
return rc;
}
rc = kvmppc_save_htab(f, spapr->htab_fd, MAX_KVM_BUF_SIZE, -1);
if (rc < 0) {
return rc;
}
close(spapr->htab_fd);
spapr->htab_fd = -1;
} else {
htab_save_later_pass(f, spapr, -1);
}
qemu_put_be32(f, 0);
qemu_put_be16(f, 0);
qemu_put_be16(f, 0);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(QEMUFile *VAR_0, void *VAR_1)
{
sPAPRMachineState *spapr = VAR_1;
qemu_put_be32(VAR_0, 0);
if (!spapr->htab) {
int VAR_2;
assert(kvm_enabled());
VAR_2 = spapr_check_htab_fd(spapr);
if (VAR_2 < 0) {
return VAR_2;
}
VAR_2 = kvmppc_save_htab(VAR_0, spapr->htab_fd, MAX_KVM_BUF_SIZE, -1);
if (VAR_2 < 0) {
return VAR_2;
}
close(spapr->htab_fd);
spapr->htab_fd = -1;
} else {
htab_save_later_pass(VAR_0, spapr, -1);
}
qemu_put_be32(VAR_0, 0);
qemu_put_be16(VAR_0, 0);
qemu_put_be16(VAR_0, 0);
return 0;
}
| [
"static int FUNC_0(QEMUFile *VAR_0, void *VAR_1)\n{",
"sPAPRMachineState *spapr = VAR_1;",
"qemu_put_be32(VAR_0, 0);",
"if (!spapr->htab) {",
"int VAR_2;",
"assert(kvm_enabled());",
"VAR_2 = spapr_check_htab_fd(spapr);",
"if (VAR_2 < 0) {",
"return VAR_2;",
"}",
"VAR_2 = kvmppc_save_htab(VAR_0, spapr->htab_fd, MAX_KVM_BUF_SIZE, -1);",
"if (VAR_2 < 0) {",
"return VAR_2;",
"}",
"close(spapr->htab_fd);",
"spapr->htab_fd = -1;",
"} else {",
"htab_save_later_pass(VAR_0, spapr, -1);",
"}",
"qemu_put_be32(VAR_0, 0);",
"qemu_put_be16(VAR_0, 0);",
"qemu_put_be16(VAR_0, 0);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
11
],
[
15
],
[
17
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
]
] |
26,811 | static uint32_t ahci_port_read(AHCIState *s, int port, int offset)
{
uint32_t val;
AHCIPortRegs *pr;
pr = &s->dev[port].port_regs;
switch (offset) {
case PORT_LST_ADDR:
val = pr->lst_addr;
break;
case PORT_LST_ADDR_HI:
val = pr->lst_addr_hi;
break;
case PORT_FIS_ADDR:
val = pr->fis_addr;
break;
case PORT_FIS_ADDR_HI:
val = pr->fis_addr_hi;
break;
case PORT_IRQ_STAT:
val = pr->irq_stat;
break;
case PORT_IRQ_MASK:
val = pr->irq_mask;
break;
case PORT_CMD:
val = pr->cmd;
break;
case PORT_TFDATA:
val = pr->tfdata;
break;
case PORT_SIG:
val = pr->sig;
break;
case PORT_SCR_STAT:
if (s->dev[port].port.ifs[0].bs) {
val = SATA_SCR_SSTATUS_DET_DEV_PRESENT_PHY_UP |
SATA_SCR_SSTATUS_SPD_GEN1 | SATA_SCR_SSTATUS_IPM_ACTIVE;
} else {
val = SATA_SCR_SSTATUS_DET_NODEV;
}
break;
case PORT_SCR_CTL:
val = pr->scr_ctl;
break;
case PORT_SCR_ERR:
val = pr->scr_err;
break;
case PORT_SCR_ACT:
pr->scr_act &= ~s->dev[port].finished;
s->dev[port].finished = 0;
val = pr->scr_act;
break;
case PORT_CMD_ISSUE:
val = pr->cmd_issue;
break;
case PORT_RESERVED:
default:
val = 0;
}
DPRINTF(port, "offset: 0x%x val: 0x%x\n", offset, val);
return val;
}
| false | qemu | 4be746345f13e99e468c60acbd3a355e8183e3ce | static uint32_t ahci_port_read(AHCIState *s, int port, int offset)
{
uint32_t val;
AHCIPortRegs *pr;
pr = &s->dev[port].port_regs;
switch (offset) {
case PORT_LST_ADDR:
val = pr->lst_addr;
break;
case PORT_LST_ADDR_HI:
val = pr->lst_addr_hi;
break;
case PORT_FIS_ADDR:
val = pr->fis_addr;
break;
case PORT_FIS_ADDR_HI:
val = pr->fis_addr_hi;
break;
case PORT_IRQ_STAT:
val = pr->irq_stat;
break;
case PORT_IRQ_MASK:
val = pr->irq_mask;
break;
case PORT_CMD:
val = pr->cmd;
break;
case PORT_TFDATA:
val = pr->tfdata;
break;
case PORT_SIG:
val = pr->sig;
break;
case PORT_SCR_STAT:
if (s->dev[port].port.ifs[0].bs) {
val = SATA_SCR_SSTATUS_DET_DEV_PRESENT_PHY_UP |
SATA_SCR_SSTATUS_SPD_GEN1 | SATA_SCR_SSTATUS_IPM_ACTIVE;
} else {
val = SATA_SCR_SSTATUS_DET_NODEV;
}
break;
case PORT_SCR_CTL:
val = pr->scr_ctl;
break;
case PORT_SCR_ERR:
val = pr->scr_err;
break;
case PORT_SCR_ACT:
pr->scr_act &= ~s->dev[port].finished;
s->dev[port].finished = 0;
val = pr->scr_act;
break;
case PORT_CMD_ISSUE:
val = pr->cmd_issue;
break;
case PORT_RESERVED:
default:
val = 0;
}
DPRINTF(port, "offset: 0x%x val: 0x%x\n", offset, val);
return val;
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0(AHCIState *s, int port, int offset)
{
uint32_t val;
AHCIPortRegs *pr;
pr = &s->dev[port].port_regs;
switch (offset) {
case PORT_LST_ADDR:
val = pr->lst_addr;
break;
case PORT_LST_ADDR_HI:
val = pr->lst_addr_hi;
break;
case PORT_FIS_ADDR:
val = pr->fis_addr;
break;
case PORT_FIS_ADDR_HI:
val = pr->fis_addr_hi;
break;
case PORT_IRQ_STAT:
val = pr->irq_stat;
break;
case PORT_IRQ_MASK:
val = pr->irq_mask;
break;
case PORT_CMD:
val = pr->cmd;
break;
case PORT_TFDATA:
val = pr->tfdata;
break;
case PORT_SIG:
val = pr->sig;
break;
case PORT_SCR_STAT:
if (s->dev[port].port.ifs[0].bs) {
val = SATA_SCR_SSTATUS_DET_DEV_PRESENT_PHY_UP |
SATA_SCR_SSTATUS_SPD_GEN1 | SATA_SCR_SSTATUS_IPM_ACTIVE;
} else {
val = SATA_SCR_SSTATUS_DET_NODEV;
}
break;
case PORT_SCR_CTL:
val = pr->scr_ctl;
break;
case PORT_SCR_ERR:
val = pr->scr_err;
break;
case PORT_SCR_ACT:
pr->scr_act &= ~s->dev[port].finished;
s->dev[port].finished = 0;
val = pr->scr_act;
break;
case PORT_CMD_ISSUE:
val = pr->cmd_issue;
break;
case PORT_RESERVED:
default:
val = 0;
}
DPRINTF(port, "offset: 0x%x val: 0x%x\n", offset, val);
return val;
}
| [
"static uint32_t FUNC_0(AHCIState *s, int port, int offset)\n{",
"uint32_t val;",
"AHCIPortRegs *pr;",
"pr = &s->dev[port].port_regs;",
"switch (offset) {",
"case PORT_LST_ADDR:\nval = pr->lst_addr;",
"break;",
"case PORT_LST_ADDR_HI:\nval = pr->lst_addr_hi;",
"break;",
"case PORT_FIS_ADDR:\nval = pr->fis_addr;",
"break;",
"case PORT_FIS_ADDR_HI:\nval = pr->fis_addr_hi;",
"break;",
"case PORT_IRQ_STAT:\nval = pr->irq_stat;",
"break;",
"case PORT_IRQ_MASK:\nval = pr->irq_mask;",
"break;",
"case PORT_CMD:\nval = pr->cmd;",
"break;",
"case PORT_TFDATA:\nval = pr->tfdata;",
"break;",
"case PORT_SIG:\nval = pr->sig;",
"break;",
"case PORT_SCR_STAT:\nif (s->dev[port].port.ifs[0].bs) {",
"val = SATA_SCR_SSTATUS_DET_DEV_PRESENT_PHY_UP |\nSATA_SCR_SSTATUS_SPD_GEN1 | SATA_SCR_SSTATUS_IPM_ACTIVE;",
"} else {",
"val = SATA_SCR_SSTATUS_DET_NODEV;",
"}",
"break;",
"case PORT_SCR_CTL:\nval = pr->scr_ctl;",
"break;",
"case PORT_SCR_ERR:\nval = pr->scr_err;",
"break;",
"case PORT_SCR_ACT:\npr->scr_act &= ~s->dev[port].finished;",
"s->dev[port].finished = 0;",
"val = pr->scr_act;",
"break;",
"case PORT_CMD_ISSUE:\nval = pr->cmd_issue;",
"break;",
"case PORT_RESERVED:\ndefault:\nval = 0;",
"}",
"DPRINTF(port, \"offset: 0x%x val: 0x%x\\n\", offset, val);",
"return val;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
19
],
[
21,
23
],
[
25
],
[
27,
29
],
[
31
],
[
33,
35
],
[
37
],
[
39,
41
],
[
43
],
[
45,
47
],
[
49
],
[
51,
53
],
[
55
],
[
57,
59
],
[
61
],
[
63,
65
],
[
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
],
[
127
]
] |
26,812 | static void hscroll(AVCodecContext *avctx)
{
AnsiContext *s = avctx->priv_data;
int i;
if (s->y < avctx->height - s->font_height) {
s->y += s->font_height;
return;
}
i = 0;
for (; i < avctx->height - s->font_height; i++)
memcpy(s->frame->data[0] + i * s->frame->linesize[0],
s->frame->data[0] + (i + s->font_height) * s->frame->linesize[0],
avctx->width);
for (; i < avctx->height; i++)
memset(s->frame->data[0] + i * s->frame->linesize[0],
DEFAULT_BG_COLOR, avctx->width);
}
| false | FFmpeg | 6021615bbe393381f23b34a7cd0dcfd1a42687ba | static void hscroll(AVCodecContext *avctx)
{
AnsiContext *s = avctx->priv_data;
int i;
if (s->y < avctx->height - s->font_height) {
s->y += s->font_height;
return;
}
i = 0;
for (; i < avctx->height - s->font_height; i++)
memcpy(s->frame->data[0] + i * s->frame->linesize[0],
s->frame->data[0] + (i + s->font_height) * s->frame->linesize[0],
avctx->width);
for (; i < avctx->height; i++)
memset(s->frame->data[0] + i * s->frame->linesize[0],
DEFAULT_BG_COLOR, avctx->width);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVCodecContext *VAR_0)
{
AnsiContext *s = VAR_0->priv_data;
int VAR_1;
if (s->y < VAR_0->height - s->font_height) {
s->y += s->font_height;
return;
}
VAR_1 = 0;
for (; VAR_1 < VAR_0->height - s->font_height; VAR_1++)
memcpy(s->frame->data[0] + VAR_1 * s->frame->linesize[0],
s->frame->data[0] + (VAR_1 + s->font_height) * s->frame->linesize[0],
VAR_0->width);
for (; VAR_1 < VAR_0->height; VAR_1++)
memset(s->frame->data[0] + VAR_1 * s->frame->linesize[0],
DEFAULT_BG_COLOR, VAR_0->width);
}
| [
"static void FUNC_0(AVCodecContext *VAR_0)\n{",
"AnsiContext *s = VAR_0->priv_data;",
"int VAR_1;",
"if (s->y < VAR_0->height - s->font_height) {",
"s->y += s->font_height;",
"return;",
"}",
"VAR_1 = 0;",
"for (; VAR_1 < VAR_0->height - s->font_height; VAR_1++)",
"memcpy(s->frame->data[0] + VAR_1 * s->frame->linesize[0],\ns->frame->data[0] + (VAR_1 + s->font_height) * s->frame->linesize[0],\nVAR_0->width);",
"for (; VAR_1 < VAR_0->height; VAR_1++)",
"memset(s->frame->data[0] + VAR_1 * s->frame->linesize[0],\nDEFAULT_BG_COLOR, VAR_0->width);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25,
27,
29
],
[
31
],
[
33,
35
],
[
37
]
] |
26,813 | static int64_t buffered_set_rate_limit(void *opaque, int64_t new_rate)
{
QEMUFileBuffered *s = opaque;
if (qemu_file_get_error(s->file)) {
goto out;
}
if (new_rate > SIZE_MAX) {
new_rate = SIZE_MAX;
}
s->xfer_limit = new_rate / 10;
out:
return s->xfer_limit;
}
| false | qemu | 0d82d0e8b98cf0ea03a45f8542d835ebd3a84cd3 | static int64_t buffered_set_rate_limit(void *opaque, int64_t new_rate)
{
QEMUFileBuffered *s = opaque;
if (qemu_file_get_error(s->file)) {
goto out;
}
if (new_rate > SIZE_MAX) {
new_rate = SIZE_MAX;
}
s->xfer_limit = new_rate / 10;
out:
return s->xfer_limit;
}
| {
"code": [],
"line_no": []
} | static int64_t FUNC_0(void *opaque, int64_t new_rate)
{
QEMUFileBuffered *s = opaque;
if (qemu_file_get_error(s->file)) {
goto out;
}
if (new_rate > SIZE_MAX) {
new_rate = SIZE_MAX;
}
s->xfer_limit = new_rate / 10;
out:
return s->xfer_limit;
}
| [
"static int64_t FUNC_0(void *opaque, int64_t new_rate)\n{",
"QEMUFileBuffered *s = opaque;",
"if (qemu_file_get_error(s->file)) {",
"goto out;",
"}",
"if (new_rate > SIZE_MAX) {",
"new_rate = SIZE_MAX;",
"}",
"s->xfer_limit = new_rate / 10;",
"out:\nreturn s->xfer_limit;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
25,
27
],
[
29
]
] |
26,814 | static int mp_dacl_setxattr(FsContext *ctx, const char *path, const char *name,
void *value, size_t size, int flags)
{
char buffer[PATH_MAX];
return lsetxattr(rpath(ctx, path, buffer), MAP_ACL_DEFAULT, value,
size, flags);
}
| false | qemu | 4fa4ce7107c6ec432f185307158c5df91ce54308 | static int mp_dacl_setxattr(FsContext *ctx, const char *path, const char *name,
void *value, size_t size, int flags)
{
char buffer[PATH_MAX];
return lsetxattr(rpath(ctx, path, buffer), MAP_ACL_DEFAULT, value,
size, flags);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(FsContext *VAR_0, const char *VAR_1, const char *VAR_2,
void *VAR_3, size_t VAR_4, int VAR_5)
{
char VAR_6[PATH_MAX];
return lsetxattr(rpath(VAR_0, VAR_1, VAR_6), MAP_ACL_DEFAULT, VAR_3,
VAR_4, VAR_5);
}
| [
"static int FUNC_0(FsContext *VAR_0, const char *VAR_1, const char *VAR_2,\nvoid *VAR_3, size_t VAR_4, int VAR_5)\n{",
"char VAR_6[PATH_MAX];",
"return lsetxattr(rpath(VAR_0, VAR_1, VAR_6), MAP_ACL_DEFAULT, VAR_3,\nVAR_4, VAR_5);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9,
11
],
[
13
]
] |
26,815 | static int spapr_vio_check_reg(VIOsPAPRDevice *sdev, VIOsPAPRDeviceInfo *info)
{
VIOsPAPRDevice *other_sdev;
DeviceState *qdev;
VIOsPAPRBus *sbus;
sbus = DO_UPCAST(VIOsPAPRBus, bus, sdev->qdev.parent_bus);
/*
* Check two device aren't given clashing addresses by the user (or some
* other mechanism). We have to open code this because we have to check
* for matches with devices other than us.
*/
QTAILQ_FOREACH(qdev, &sbus->bus.children, sibling) {
other_sdev = DO_UPCAST(VIOsPAPRDevice, qdev, qdev);
if (other_sdev != sdev && other_sdev->reg == sdev->reg) {
fprintf(stderr, "vio: %s and %s devices conflict at address %#x\n",
info->qdev.name, other_sdev->qdev.info->name, sdev->reg);
return -EEXIST;
}
}
return 0;
}
| false | qemu | 3954d33ab7f82f5a5fa0ced231849920265a5fec | static int spapr_vio_check_reg(VIOsPAPRDevice *sdev, VIOsPAPRDeviceInfo *info)
{
VIOsPAPRDevice *other_sdev;
DeviceState *qdev;
VIOsPAPRBus *sbus;
sbus = DO_UPCAST(VIOsPAPRBus, bus, sdev->qdev.parent_bus);
QTAILQ_FOREACH(qdev, &sbus->bus.children, sibling) {
other_sdev = DO_UPCAST(VIOsPAPRDevice, qdev, qdev);
if (other_sdev != sdev && other_sdev->reg == sdev->reg) {
fprintf(stderr, "vio: %s and %s devices conflict at address %#x\n",
info->qdev.name, other_sdev->qdev.info->name, sdev->reg);
return -EEXIST;
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(VIOsPAPRDevice *VAR_0, VIOsPAPRDeviceInfo *VAR_1)
{
VIOsPAPRDevice *other_sdev;
DeviceState *qdev;
VIOsPAPRBus *sbus;
sbus = DO_UPCAST(VIOsPAPRBus, bus, VAR_0->qdev.parent_bus);
QTAILQ_FOREACH(qdev, &sbus->bus.children, sibling) {
other_sdev = DO_UPCAST(VIOsPAPRDevice, qdev, qdev);
if (other_sdev != VAR_0 && other_sdev->reg == VAR_0->reg) {
fprintf(stderr, "vio: %s and %s devices conflict at address %#x\n",
VAR_1->qdev.name, other_sdev->qdev.VAR_1->name, VAR_0->reg);
return -EEXIST;
}
}
return 0;
}
| [
"static int FUNC_0(VIOsPAPRDevice *VAR_0, VIOsPAPRDeviceInfo *VAR_1)\n{",
"VIOsPAPRDevice *other_sdev;",
"DeviceState *qdev;",
"VIOsPAPRBus *sbus;",
"sbus = DO_UPCAST(VIOsPAPRBus, bus, VAR_0->qdev.parent_bus);",
"QTAILQ_FOREACH(qdev, &sbus->bus.children, sibling) {",
"other_sdev = DO_UPCAST(VIOsPAPRDevice, qdev, qdev);",
"if (other_sdev != VAR_0 && other_sdev->reg == VAR_0->reg) {",
"fprintf(stderr, \"vio: %s and %s devices conflict at address %#x\\n\",\nVAR_1->qdev.name, other_sdev->qdev.VAR_1->name, VAR_0->reg);",
"return -EEXIST;",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
27
],
[
29
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
]
] |
26,816 | static int vaapi_encode_issue(AVCodecContext *avctx,
VAAPIEncodePicture *pic)
{
VAAPIEncodeContext *ctx = avctx->priv_data;
VAAPIEncodeSlice *slice;
VAStatus vas;
int err, i;
char data[MAX_PARAM_BUFFER_SIZE];
size_t bit_len;
av_log(avctx, AV_LOG_DEBUG, "Issuing encode for pic %"PRId64"/%"PRId64" "
"as type %s.\n", pic->display_order, pic->encode_order,
picture_type_name[pic->type]);
if (pic->nb_refs == 0) {
av_log(avctx, AV_LOG_DEBUG, "No reference pictures.\n");
} else {
av_log(avctx, AV_LOG_DEBUG, "Refers to:");
for (i = 0; i < pic->nb_refs; i++) {
av_log(avctx, AV_LOG_DEBUG, " %"PRId64"/%"PRId64,
pic->refs[i]->display_order, pic->refs[i]->encode_order);
}
av_log(avctx, AV_LOG_DEBUG, ".\n");
}
av_assert0(pic->input_available && !pic->encode_issued);
for (i = 0; i < pic->nb_refs; i++) {
av_assert0(pic->refs[i]);
// If we are serialised then the references must have already
// completed. If not, they must have been issued but need not
// have completed yet.
if (ctx->issue_mode == ISSUE_MODE_SERIALISE_EVERYTHING)
av_assert0(pic->refs[i]->encode_complete);
else
av_assert0(pic->refs[i]->encode_issued);
}
av_log(avctx, AV_LOG_DEBUG, "Input surface is %#x.\n", pic->input_surface);
pic->recon_image = av_frame_alloc();
if (!pic->recon_image) {
err = AVERROR(ENOMEM);
goto fail;
}
err = av_hwframe_get_buffer(ctx->recon_frames_ref, pic->recon_image, 0);
if (err < 0) {
err = AVERROR(ENOMEM);
goto fail;
}
pic->recon_surface = (VASurfaceID)(uintptr_t)pic->recon_image->data[3];
av_log(avctx, AV_LOG_DEBUG, "Recon surface is %#x.\n", pic->recon_surface);
pic->output_buffer_ref = av_buffer_pool_get(ctx->output_buffer_pool);
if (!pic->output_buffer_ref) {
err = AVERROR(ENOMEM);
goto fail;
}
pic->output_buffer = (VABufferID)(uintptr_t)pic->output_buffer_ref->data;
av_log(avctx, AV_LOG_DEBUG, "Output buffer is %#x.\n",
pic->output_buffer);
if (ctx->codec->picture_params_size > 0) {
pic->codec_picture_params = av_malloc(ctx->codec->picture_params_size);
if (!pic->codec_picture_params)
goto fail;
memcpy(pic->codec_picture_params, ctx->codec_picture_params,
ctx->codec->picture_params_size);
} else {
av_assert0(!ctx->codec_picture_params);
}
pic->nb_param_buffers = 0;
if (pic->encode_order == 0) {
// Global parameter buffers are set on the first picture only.
for (i = 0; i < ctx->nb_global_params; i++) {
err = vaapi_encode_make_param_buffer(avctx, pic,
VAEncMiscParameterBufferType,
(char*)ctx->global_params[i],
ctx->global_params_size[i]);
if (err < 0)
goto fail;
}
}
if (pic->type == PICTURE_TYPE_IDR && ctx->codec->init_sequence_params) {
err = vaapi_encode_make_param_buffer(avctx, pic,
VAEncSequenceParameterBufferType,
ctx->codec_sequence_params,
ctx->codec->sequence_params_size);
if (err < 0)
goto fail;
}
if (ctx->codec->init_picture_params) {
err = ctx->codec->init_picture_params(avctx, pic);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to initialise picture "
"parameters: %d.\n", err);
goto fail;
}
err = vaapi_encode_make_param_buffer(avctx, pic,
VAEncPictureParameterBufferType,
pic->codec_picture_params,
ctx->codec->picture_params_size);
if (err < 0)
goto fail;
}
if (pic->type == PICTURE_TYPE_IDR) {
if (ctx->codec->write_sequence_header) {
bit_len = 8 * sizeof(data);
err = ctx->codec->write_sequence_header(avctx, data, &bit_len);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to write per-sequence "
"header: %d.\n", err);
goto fail;
}
err = vaapi_encode_make_packed_header(avctx, pic,
ctx->codec->sequence_header_type,
data, bit_len);
if (err < 0)
goto fail;
}
}
if (ctx->codec->write_picture_header) {
bit_len = 8 * sizeof(data);
err = ctx->codec->write_picture_header(avctx, pic, data, &bit_len);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to write per-picture "
"header: %d.\n", err);
goto fail;
}
err = vaapi_encode_make_packed_header(avctx, pic,
ctx->codec->picture_header_type,
data, bit_len);
if (err < 0)
goto fail;
}
if (ctx->codec->write_extra_buffer) {
for (i = 0;; i++) {
size_t len = sizeof(data);
int type;
err = ctx->codec->write_extra_buffer(avctx, pic, i, &type,
data, &len);
if (err == AVERROR_EOF)
break;
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to write extra "
"buffer %d: %d.\n", i, err);
goto fail;
}
err = vaapi_encode_make_param_buffer(avctx, pic, type,
data, len);
if (err < 0)
goto fail;
}
}
if (ctx->codec->write_extra_header) {
for (i = 0;; i++) {
int type;
bit_len = 8 * sizeof(data);
err = ctx->codec->write_extra_header(avctx, pic, i, &type,
data, &bit_len);
if (err == AVERROR_EOF)
break;
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to write extra "
"header %d: %d.\n", i, err);
goto fail;
}
err = vaapi_encode_make_packed_header(avctx, pic, type,
data, bit_len);
if (err < 0)
goto fail;
}
}
av_assert0(pic->nb_slices <= MAX_PICTURE_SLICES);
for (i = 0; i < pic->nb_slices; i++) {
slice = av_mallocz(sizeof(*slice));
if (!slice) {
err = AVERROR(ENOMEM);
goto fail;
}
pic->slices[i] = slice;
if (ctx->codec->slice_params_size > 0) {
slice->codec_slice_params = av_mallocz(ctx->codec->slice_params_size);
if (!slice->codec_slice_params) {
err = AVERROR(ENOMEM);
goto fail;
}
}
if (ctx->codec->init_slice_params) {
err = ctx->codec->init_slice_params(avctx, pic, slice);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to initalise slice "
"parameters: %d.\n", err);
goto fail;
}
}
if (ctx->codec->write_slice_header) {
bit_len = 8 * sizeof(data);
err = ctx->codec->write_slice_header(avctx, pic, slice,
data, &bit_len);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to write per-slice "
"header: %d.\n", err);
goto fail;
}
err = vaapi_encode_make_packed_header(avctx, pic,
ctx->codec->slice_header_type,
data, bit_len);
if (err < 0)
goto fail;
}
if (ctx->codec->init_slice_params) {
err = vaapi_encode_make_param_buffer(avctx, pic,
VAEncSliceParameterBufferType,
slice->codec_slice_params,
ctx->codec->slice_params_size);
if (err < 0)
goto fail;
}
}
vas = vaBeginPicture(ctx->hwctx->display, ctx->va_context,
pic->input_surface);
if (vas != VA_STATUS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "Failed to begin picture encode issue: "
"%d (%s).\n", vas, vaErrorStr(vas));
err = AVERROR(EIO);
goto fail_with_picture;
}
vas = vaRenderPicture(ctx->hwctx->display, ctx->va_context,
pic->param_buffers, pic->nb_param_buffers);
if (vas != VA_STATUS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "Failed to upload encode parameters: "
"%d (%s).\n", vas, vaErrorStr(vas));
err = AVERROR(EIO);
goto fail_with_picture;
}
vas = vaEndPicture(ctx->hwctx->display, ctx->va_context);
if (vas != VA_STATUS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "Failed to end picture encode issue: "
"%d (%s).\n", vas, vaErrorStr(vas));
err = AVERROR(EIO);
// vaRenderPicture() has been called here, so we should not destroy
// the parameter buffers unless separate destruction is required.
if (ctx->hwctx->driver_quirks &
AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS)
goto fail;
else
goto fail_at_end;
}
if (ctx->hwctx->driver_quirks &
AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS) {
for (i = 0; i < pic->nb_param_buffers; i++) {
vas = vaDestroyBuffer(ctx->hwctx->display,
pic->param_buffers[i]);
if (vas != VA_STATUS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "Failed to destroy "
"param buffer %#x: %d (%s).\n",
pic->param_buffers[i], vas, vaErrorStr(vas));
// And ignore.
}
}
}
pic->encode_issued = 1;
if (ctx->issue_mode == ISSUE_MODE_SERIALISE_EVERYTHING)
return vaapi_encode_wait(avctx, pic);
else
return 0;
fail_with_picture:
vaEndPicture(ctx->hwctx->display, ctx->va_context);
fail:
for(i = 0; i < pic->nb_param_buffers; i++)
vaDestroyBuffer(ctx->hwctx->display, pic->param_buffers[i]);
fail_at_end:
av_freep(&pic->codec_picture_params);
av_frame_free(&pic->recon_image);
return err;
}
| false | FFmpeg | 892bbbcdc171ff0d08d69636a240ffb95f54243c | static int vaapi_encode_issue(AVCodecContext *avctx,
VAAPIEncodePicture *pic)
{
VAAPIEncodeContext *ctx = avctx->priv_data;
VAAPIEncodeSlice *slice;
VAStatus vas;
int err, i;
char data[MAX_PARAM_BUFFER_SIZE];
size_t bit_len;
av_log(avctx, AV_LOG_DEBUG, "Issuing encode for pic %"PRId64"/%"PRId64" "
"as type %s.\n", pic->display_order, pic->encode_order,
picture_type_name[pic->type]);
if (pic->nb_refs == 0) {
av_log(avctx, AV_LOG_DEBUG, "No reference pictures.\n");
} else {
av_log(avctx, AV_LOG_DEBUG, "Refers to:");
for (i = 0; i < pic->nb_refs; i++) {
av_log(avctx, AV_LOG_DEBUG, " %"PRId64"/%"PRId64,
pic->refs[i]->display_order, pic->refs[i]->encode_order);
}
av_log(avctx, AV_LOG_DEBUG, ".\n");
}
av_assert0(pic->input_available && !pic->encode_issued);
for (i = 0; i < pic->nb_refs; i++) {
av_assert0(pic->refs[i]);
if (ctx->issue_mode == ISSUE_MODE_SERIALISE_EVERYTHING)
av_assert0(pic->refs[i]->encode_complete);
else
av_assert0(pic->refs[i]->encode_issued);
}
av_log(avctx, AV_LOG_DEBUG, "Input surface is %#x.\n", pic->input_surface);
pic->recon_image = av_frame_alloc();
if (!pic->recon_image) {
err = AVERROR(ENOMEM);
goto fail;
}
err = av_hwframe_get_buffer(ctx->recon_frames_ref, pic->recon_image, 0);
if (err < 0) {
err = AVERROR(ENOMEM);
goto fail;
}
pic->recon_surface = (VASurfaceID)(uintptr_t)pic->recon_image->data[3];
av_log(avctx, AV_LOG_DEBUG, "Recon surface is %#x.\n", pic->recon_surface);
pic->output_buffer_ref = av_buffer_pool_get(ctx->output_buffer_pool);
if (!pic->output_buffer_ref) {
err = AVERROR(ENOMEM);
goto fail;
}
pic->output_buffer = (VABufferID)(uintptr_t)pic->output_buffer_ref->data;
av_log(avctx, AV_LOG_DEBUG, "Output buffer is %#x.\n",
pic->output_buffer);
if (ctx->codec->picture_params_size > 0) {
pic->codec_picture_params = av_malloc(ctx->codec->picture_params_size);
if (!pic->codec_picture_params)
goto fail;
memcpy(pic->codec_picture_params, ctx->codec_picture_params,
ctx->codec->picture_params_size);
} else {
av_assert0(!ctx->codec_picture_params);
}
pic->nb_param_buffers = 0;
if (pic->encode_order == 0) {
for (i = 0; i < ctx->nb_global_params; i++) {
err = vaapi_encode_make_param_buffer(avctx, pic,
VAEncMiscParameterBufferType,
(char*)ctx->global_params[i],
ctx->global_params_size[i]);
if (err < 0)
goto fail;
}
}
if (pic->type == PICTURE_TYPE_IDR && ctx->codec->init_sequence_params) {
err = vaapi_encode_make_param_buffer(avctx, pic,
VAEncSequenceParameterBufferType,
ctx->codec_sequence_params,
ctx->codec->sequence_params_size);
if (err < 0)
goto fail;
}
if (ctx->codec->init_picture_params) {
err = ctx->codec->init_picture_params(avctx, pic);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to initialise picture "
"parameters: %d.\n", err);
goto fail;
}
err = vaapi_encode_make_param_buffer(avctx, pic,
VAEncPictureParameterBufferType,
pic->codec_picture_params,
ctx->codec->picture_params_size);
if (err < 0)
goto fail;
}
if (pic->type == PICTURE_TYPE_IDR) {
if (ctx->codec->write_sequence_header) {
bit_len = 8 * sizeof(data);
err = ctx->codec->write_sequence_header(avctx, data, &bit_len);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to write per-sequence "
"header: %d.\n", err);
goto fail;
}
err = vaapi_encode_make_packed_header(avctx, pic,
ctx->codec->sequence_header_type,
data, bit_len);
if (err < 0)
goto fail;
}
}
if (ctx->codec->write_picture_header) {
bit_len = 8 * sizeof(data);
err = ctx->codec->write_picture_header(avctx, pic, data, &bit_len);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to write per-picture "
"header: %d.\n", err);
goto fail;
}
err = vaapi_encode_make_packed_header(avctx, pic,
ctx->codec->picture_header_type,
data, bit_len);
if (err < 0)
goto fail;
}
if (ctx->codec->write_extra_buffer) {
for (i = 0;; i++) {
size_t len = sizeof(data);
int type;
err = ctx->codec->write_extra_buffer(avctx, pic, i, &type,
data, &len);
if (err == AVERROR_EOF)
break;
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to write extra "
"buffer %d: %d.\n", i, err);
goto fail;
}
err = vaapi_encode_make_param_buffer(avctx, pic, type,
data, len);
if (err < 0)
goto fail;
}
}
if (ctx->codec->write_extra_header) {
for (i = 0;; i++) {
int type;
bit_len = 8 * sizeof(data);
err = ctx->codec->write_extra_header(avctx, pic, i, &type,
data, &bit_len);
if (err == AVERROR_EOF)
break;
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to write extra "
"header %d: %d.\n", i, err);
goto fail;
}
err = vaapi_encode_make_packed_header(avctx, pic, type,
data, bit_len);
if (err < 0)
goto fail;
}
}
av_assert0(pic->nb_slices <= MAX_PICTURE_SLICES);
for (i = 0; i < pic->nb_slices; i++) {
slice = av_mallocz(sizeof(*slice));
if (!slice) {
err = AVERROR(ENOMEM);
goto fail;
}
pic->slices[i] = slice;
if (ctx->codec->slice_params_size > 0) {
slice->codec_slice_params = av_mallocz(ctx->codec->slice_params_size);
if (!slice->codec_slice_params) {
err = AVERROR(ENOMEM);
goto fail;
}
}
if (ctx->codec->init_slice_params) {
err = ctx->codec->init_slice_params(avctx, pic, slice);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to initalise slice "
"parameters: %d.\n", err);
goto fail;
}
}
if (ctx->codec->write_slice_header) {
bit_len = 8 * sizeof(data);
err = ctx->codec->write_slice_header(avctx, pic, slice,
data, &bit_len);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to write per-slice "
"header: %d.\n", err);
goto fail;
}
err = vaapi_encode_make_packed_header(avctx, pic,
ctx->codec->slice_header_type,
data, bit_len);
if (err < 0)
goto fail;
}
if (ctx->codec->init_slice_params) {
err = vaapi_encode_make_param_buffer(avctx, pic,
VAEncSliceParameterBufferType,
slice->codec_slice_params,
ctx->codec->slice_params_size);
if (err < 0)
goto fail;
}
}
vas = vaBeginPicture(ctx->hwctx->display, ctx->va_context,
pic->input_surface);
if (vas != VA_STATUS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "Failed to begin picture encode issue: "
"%d (%s).\n", vas, vaErrorStr(vas));
err = AVERROR(EIO);
goto fail_with_picture;
}
vas = vaRenderPicture(ctx->hwctx->display, ctx->va_context,
pic->param_buffers, pic->nb_param_buffers);
if (vas != VA_STATUS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "Failed to upload encode parameters: "
"%d (%s).\n", vas, vaErrorStr(vas));
err = AVERROR(EIO);
goto fail_with_picture;
}
vas = vaEndPicture(ctx->hwctx->display, ctx->va_context);
if (vas != VA_STATUS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "Failed to end picture encode issue: "
"%d (%s).\n", vas, vaErrorStr(vas));
err = AVERROR(EIO);
if (ctx->hwctx->driver_quirks &
AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS)
goto fail;
else
goto fail_at_end;
}
if (ctx->hwctx->driver_quirks &
AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS) {
for (i = 0; i < pic->nb_param_buffers; i++) {
vas = vaDestroyBuffer(ctx->hwctx->display,
pic->param_buffers[i]);
if (vas != VA_STATUS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "Failed to destroy "
"param buffer %#x: %d (%s).\n",
pic->param_buffers[i], vas, vaErrorStr(vas));
}
}
}
pic->encode_issued = 1;
if (ctx->issue_mode == ISSUE_MODE_SERIALISE_EVERYTHING)
return vaapi_encode_wait(avctx, pic);
else
return 0;
fail_with_picture:
vaEndPicture(ctx->hwctx->display, ctx->va_context);
fail:
for(i = 0; i < pic->nb_param_buffers; i++)
vaDestroyBuffer(ctx->hwctx->display, pic->param_buffers[i]);
fail_at_end:
av_freep(&pic->codec_picture_params);
av_frame_free(&pic->recon_image);
return err;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
VAAPIEncodePicture *VAR_1)
{
VAAPIEncodeContext *ctx = VAR_0->priv_data;
VAAPIEncodeSlice *slice;
VAStatus vas;
int VAR_2, VAR_3;
char VAR_4[MAX_PARAM_BUFFER_SIZE];
size_t bit_len;
av_log(VAR_0, AV_LOG_DEBUG, "Issuing encode for VAR_1 %"PRId64"/%"PRId64" "
"as VAR_6 %s.\n", VAR_1->display_order, VAR_1->encode_order,
picture_type_name[VAR_1->VAR_6]);
if (VAR_1->nb_refs == 0) {
av_log(VAR_0, AV_LOG_DEBUG, "No reference pictures.\n");
} else {
av_log(VAR_0, AV_LOG_DEBUG, "Refers to:");
for (VAR_3 = 0; VAR_3 < VAR_1->nb_refs; VAR_3++) {
av_log(VAR_0, AV_LOG_DEBUG, " %"PRId64"/%"PRId64,
VAR_1->refs[VAR_3]->display_order, VAR_1->refs[VAR_3]->encode_order);
}
av_log(VAR_0, AV_LOG_DEBUG, ".\n");
}
av_assert0(VAR_1->input_available && !VAR_1->encode_issued);
for (VAR_3 = 0; VAR_3 < VAR_1->nb_refs; VAR_3++) {
av_assert0(VAR_1->refs[VAR_3]);
if (ctx->issue_mode == ISSUE_MODE_SERIALISE_EVERYTHING)
av_assert0(VAR_1->refs[VAR_3]->encode_complete);
else
av_assert0(VAR_1->refs[VAR_3]->encode_issued);
}
av_log(VAR_0, AV_LOG_DEBUG, "Input surface is %#x.\n", VAR_1->input_surface);
VAR_1->recon_image = av_frame_alloc();
if (!VAR_1->recon_image) {
VAR_2 = AVERROR(ENOMEM);
goto fail;
}
VAR_2 = av_hwframe_get_buffer(ctx->recon_frames_ref, VAR_1->recon_image, 0);
if (VAR_2 < 0) {
VAR_2 = AVERROR(ENOMEM);
goto fail;
}
VAR_1->recon_surface = (VASurfaceID)(uintptr_t)VAR_1->recon_image->VAR_4[3];
av_log(VAR_0, AV_LOG_DEBUG, "Recon surface is %#x.\n", VAR_1->recon_surface);
VAR_1->output_buffer_ref = av_buffer_pool_get(ctx->output_buffer_pool);
if (!VAR_1->output_buffer_ref) {
VAR_2 = AVERROR(ENOMEM);
goto fail;
}
VAR_1->output_buffer = (VABufferID)(uintptr_t)VAR_1->output_buffer_ref->VAR_4;
av_log(VAR_0, AV_LOG_DEBUG, "Output buffer is %#x.\n",
VAR_1->output_buffer);
if (ctx->codec->picture_params_size > 0) {
VAR_1->codec_picture_params = av_malloc(ctx->codec->picture_params_size);
if (!VAR_1->codec_picture_params)
goto fail;
memcpy(VAR_1->codec_picture_params, ctx->codec_picture_params,
ctx->codec->picture_params_size);
} else {
av_assert0(!ctx->codec_picture_params);
}
VAR_1->nb_param_buffers = 0;
if (VAR_1->encode_order == 0) {
for (VAR_3 = 0; VAR_3 < ctx->nb_global_params; VAR_3++) {
VAR_2 = vaapi_encode_make_param_buffer(VAR_0, VAR_1,
VAEncMiscParameterBufferType,
(char*)ctx->global_params[VAR_3],
ctx->global_params_size[VAR_3]);
if (VAR_2 < 0)
goto fail;
}
}
if (VAR_1->VAR_6 == PICTURE_TYPE_IDR && ctx->codec->init_sequence_params) {
VAR_2 = vaapi_encode_make_param_buffer(VAR_0, VAR_1,
VAEncSequenceParameterBufferType,
ctx->codec_sequence_params,
ctx->codec->sequence_params_size);
if (VAR_2 < 0)
goto fail;
}
if (ctx->codec->init_picture_params) {
VAR_2 = ctx->codec->init_picture_params(VAR_0, VAR_1);
if (VAR_2 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to initialise picture "
"parameters: %d.\n", VAR_2);
goto fail;
}
VAR_2 = vaapi_encode_make_param_buffer(VAR_0, VAR_1,
VAEncPictureParameterBufferType,
VAR_1->codec_picture_params,
ctx->codec->picture_params_size);
if (VAR_2 < 0)
goto fail;
}
if (VAR_1->VAR_6 == PICTURE_TYPE_IDR) {
if (ctx->codec->write_sequence_header) {
bit_len = 8 * sizeof(VAR_4);
VAR_2 = ctx->codec->write_sequence_header(VAR_0, VAR_4, &bit_len);
if (VAR_2 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to write per-sequence "
"header: %d.\n", VAR_2);
goto fail;
}
VAR_2 = vaapi_encode_make_packed_header(VAR_0, VAR_1,
ctx->codec->sequence_header_type,
VAR_4, bit_len);
if (VAR_2 < 0)
goto fail;
}
}
if (ctx->codec->write_picture_header) {
bit_len = 8 * sizeof(VAR_4);
VAR_2 = ctx->codec->write_picture_header(VAR_0, VAR_1, VAR_4, &bit_len);
if (VAR_2 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to write per-picture "
"header: %d.\n", VAR_2);
goto fail;
}
VAR_2 = vaapi_encode_make_packed_header(VAR_0, VAR_1,
ctx->codec->picture_header_type,
VAR_4, bit_len);
if (VAR_2 < 0)
goto fail;
}
if (ctx->codec->write_extra_buffer) {
for (VAR_3 = 0;; VAR_3++) {
size_t len = sizeof(VAR_4);
int VAR_6;
VAR_2 = ctx->codec->write_extra_buffer(VAR_0, VAR_1, VAR_3, &VAR_6,
VAR_4, &len);
if (VAR_2 == AVERROR_EOF)
break;
if (VAR_2 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to write extra "
"buffer %d: %d.\n", VAR_3, VAR_2);
goto fail;
}
VAR_2 = vaapi_encode_make_param_buffer(VAR_0, VAR_1, VAR_6,
VAR_4, len);
if (VAR_2 < 0)
goto fail;
}
}
if (ctx->codec->write_extra_header) {
for (VAR_3 = 0;; VAR_3++) {
int VAR_6;
bit_len = 8 * sizeof(VAR_4);
VAR_2 = ctx->codec->write_extra_header(VAR_0, VAR_1, VAR_3, &VAR_6,
VAR_4, &bit_len);
if (VAR_2 == AVERROR_EOF)
break;
if (VAR_2 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to write extra "
"header %d: %d.\n", VAR_3, VAR_2);
goto fail;
}
VAR_2 = vaapi_encode_make_packed_header(VAR_0, VAR_1, VAR_6,
VAR_4, bit_len);
if (VAR_2 < 0)
goto fail;
}
}
av_assert0(VAR_1->nb_slices <= MAX_PICTURE_SLICES);
for (VAR_3 = 0; VAR_3 < VAR_1->nb_slices; VAR_3++) {
slice = av_mallocz(sizeof(*slice));
if (!slice) {
VAR_2 = AVERROR(ENOMEM);
goto fail;
}
VAR_1->slices[VAR_3] = slice;
if (ctx->codec->slice_params_size > 0) {
slice->codec_slice_params = av_mallocz(ctx->codec->slice_params_size);
if (!slice->codec_slice_params) {
VAR_2 = AVERROR(ENOMEM);
goto fail;
}
}
if (ctx->codec->init_slice_params) {
VAR_2 = ctx->codec->init_slice_params(VAR_0, VAR_1, slice);
if (VAR_2 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to initalise slice "
"parameters: %d.\n", VAR_2);
goto fail;
}
}
if (ctx->codec->write_slice_header) {
bit_len = 8 * sizeof(VAR_4);
VAR_2 = ctx->codec->write_slice_header(VAR_0, VAR_1, slice,
VAR_4, &bit_len);
if (VAR_2 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to write per-slice "
"header: %d.\n", VAR_2);
goto fail;
}
VAR_2 = vaapi_encode_make_packed_header(VAR_0, VAR_1,
ctx->codec->slice_header_type,
VAR_4, bit_len);
if (VAR_2 < 0)
goto fail;
}
if (ctx->codec->init_slice_params) {
VAR_2 = vaapi_encode_make_param_buffer(VAR_0, VAR_1,
VAEncSliceParameterBufferType,
slice->codec_slice_params,
ctx->codec->slice_params_size);
if (VAR_2 < 0)
goto fail;
}
}
vas = vaBeginPicture(ctx->hwctx->display, ctx->va_context,
VAR_1->input_surface);
if (vas != VA_STATUS_SUCCESS) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to begin picture encode issue: "
"%d (%s).\n", vas, vaErrorStr(vas));
VAR_2 = AVERROR(EIO);
goto fail_with_picture;
}
vas = vaRenderPicture(ctx->hwctx->display, ctx->va_context,
VAR_1->param_buffers, VAR_1->nb_param_buffers);
if (vas != VA_STATUS_SUCCESS) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to upload encode parameters: "
"%d (%s).\n", vas, vaErrorStr(vas));
VAR_2 = AVERROR(EIO);
goto fail_with_picture;
}
vas = vaEndPicture(ctx->hwctx->display, ctx->va_context);
if (vas != VA_STATUS_SUCCESS) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to end picture encode issue: "
"%d (%s).\n", vas, vaErrorStr(vas));
VAR_2 = AVERROR(EIO);
if (ctx->hwctx->driver_quirks &
AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS)
goto fail;
else
goto fail_at_end;
}
if (ctx->hwctx->driver_quirks &
AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS) {
for (VAR_3 = 0; VAR_3 < VAR_1->nb_param_buffers; VAR_3++) {
vas = vaDestroyBuffer(ctx->hwctx->display,
VAR_1->param_buffers[VAR_3]);
if (vas != VA_STATUS_SUCCESS) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to destroy "
"param buffer %#x: %d (%s).\n",
VAR_1->param_buffers[VAR_3], vas, vaErrorStr(vas));
}
}
}
VAR_1->encode_issued = 1;
if (ctx->issue_mode == ISSUE_MODE_SERIALISE_EVERYTHING)
return vaapi_encode_wait(VAR_0, VAR_1);
else
return 0;
fail_with_picture:
vaEndPicture(ctx->hwctx->display, ctx->va_context);
fail:
for(VAR_3 = 0; VAR_3 < VAR_1->nb_param_buffers; VAR_3++)
vaDestroyBuffer(ctx->hwctx->display, VAR_1->param_buffers[VAR_3]);
fail_at_end:
av_freep(&VAR_1->codec_picture_params);
av_frame_free(&VAR_1->recon_image);
return VAR_2;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nVAAPIEncodePicture *VAR_1)\n{",
"VAAPIEncodeContext *ctx = VAR_0->priv_data;",
"VAAPIEncodeSlice *slice;",
"VAStatus vas;",
"int VAR_2, VAR_3;",
"char VAR_4[MAX_PARAM_BUFFER_SIZE];",
"size_t bit_len;",
"av_log(VAR_0, AV_LOG_DEBUG, \"Issuing encode for VAR_1 %\"PRId64\"/%\"PRId64\" \"\n\"as VAR_6 %s.\\n\", VAR_1->display_order, VAR_1->encode_order,\npicture_type_name[VAR_1->VAR_6]);",
"if (VAR_1->nb_refs == 0) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"No reference pictures.\\n\");",
"} else {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Refers to:\");",
"for (VAR_3 = 0; VAR_3 < VAR_1->nb_refs; VAR_3++) {",
"av_log(VAR_0, AV_LOG_DEBUG, \" %\"PRId64\"/%\"PRId64,\nVAR_1->refs[VAR_3]->display_order, VAR_1->refs[VAR_3]->encode_order);",
"}",
"av_log(VAR_0, AV_LOG_DEBUG, \".\\n\");",
"}",
"av_assert0(VAR_1->input_available && !VAR_1->encode_issued);",
"for (VAR_3 = 0; VAR_3 < VAR_1->nb_refs; VAR_3++) {",
"av_assert0(VAR_1->refs[VAR_3]);",
"if (ctx->issue_mode == ISSUE_MODE_SERIALISE_EVERYTHING)\nav_assert0(VAR_1->refs[VAR_3]->encode_complete);",
"else\nav_assert0(VAR_1->refs[VAR_3]->encode_issued);",
"}",
"av_log(VAR_0, AV_LOG_DEBUG, \"Input surface is %#x.\\n\", VAR_1->input_surface);",
"VAR_1->recon_image = av_frame_alloc();",
"if (!VAR_1->recon_image) {",
"VAR_2 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"VAR_2 = av_hwframe_get_buffer(ctx->recon_frames_ref, VAR_1->recon_image, 0);",
"if (VAR_2 < 0) {",
"VAR_2 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"VAR_1->recon_surface = (VASurfaceID)(uintptr_t)VAR_1->recon_image->VAR_4[3];",
"av_log(VAR_0, AV_LOG_DEBUG, \"Recon surface is %#x.\\n\", VAR_1->recon_surface);",
"VAR_1->output_buffer_ref = av_buffer_pool_get(ctx->output_buffer_pool);",
"if (!VAR_1->output_buffer_ref) {",
"VAR_2 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"VAR_1->output_buffer = (VABufferID)(uintptr_t)VAR_1->output_buffer_ref->VAR_4;",
"av_log(VAR_0, AV_LOG_DEBUG, \"Output buffer is %#x.\\n\",\nVAR_1->output_buffer);",
"if (ctx->codec->picture_params_size > 0) {",
"VAR_1->codec_picture_params = av_malloc(ctx->codec->picture_params_size);",
"if (!VAR_1->codec_picture_params)\ngoto fail;",
"memcpy(VAR_1->codec_picture_params, ctx->codec_picture_params,\nctx->codec->picture_params_size);",
"} else {",
"av_assert0(!ctx->codec_picture_params);",
"}",
"VAR_1->nb_param_buffers = 0;",
"if (VAR_1->encode_order == 0) {",
"for (VAR_3 = 0; VAR_3 < ctx->nb_global_params; VAR_3++) {",
"VAR_2 = vaapi_encode_make_param_buffer(VAR_0, VAR_1,\nVAEncMiscParameterBufferType,\n(char*)ctx->global_params[VAR_3],\nctx->global_params_size[VAR_3]);",
"if (VAR_2 < 0)\ngoto fail;",
"}",
"}",
"if (VAR_1->VAR_6 == PICTURE_TYPE_IDR && ctx->codec->init_sequence_params) {",
"VAR_2 = vaapi_encode_make_param_buffer(VAR_0, VAR_1,\nVAEncSequenceParameterBufferType,\nctx->codec_sequence_params,\nctx->codec->sequence_params_size);",
"if (VAR_2 < 0)\ngoto fail;",
"}",
"if (ctx->codec->init_picture_params) {",
"VAR_2 = ctx->codec->init_picture_params(VAR_0, VAR_1);",
"if (VAR_2 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to initialise picture \"\n\"parameters: %d.\\n\", VAR_2);",
"goto fail;",
"}",
"VAR_2 = vaapi_encode_make_param_buffer(VAR_0, VAR_1,\nVAEncPictureParameterBufferType,\nVAR_1->codec_picture_params,\nctx->codec->picture_params_size);",
"if (VAR_2 < 0)\ngoto fail;",
"}",
"if (VAR_1->VAR_6 == PICTURE_TYPE_IDR) {",
"if (ctx->codec->write_sequence_header) {",
"bit_len = 8 * sizeof(VAR_4);",
"VAR_2 = ctx->codec->write_sequence_header(VAR_0, VAR_4, &bit_len);",
"if (VAR_2 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to write per-sequence \"\n\"header: %d.\\n\", VAR_2);",
"goto fail;",
"}",
"VAR_2 = vaapi_encode_make_packed_header(VAR_0, VAR_1,\nctx->codec->sequence_header_type,\nVAR_4, bit_len);",
"if (VAR_2 < 0)\ngoto fail;",
"}",
"}",
"if (ctx->codec->write_picture_header) {",
"bit_len = 8 * sizeof(VAR_4);",
"VAR_2 = ctx->codec->write_picture_header(VAR_0, VAR_1, VAR_4, &bit_len);",
"if (VAR_2 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to write per-picture \"\n\"header: %d.\\n\", VAR_2);",
"goto fail;",
"}",
"VAR_2 = vaapi_encode_make_packed_header(VAR_0, VAR_1,\nctx->codec->picture_header_type,\nVAR_4, bit_len);",
"if (VAR_2 < 0)\ngoto fail;",
"}",
"if (ctx->codec->write_extra_buffer) {",
"for (VAR_3 = 0;; VAR_3++) {",
"size_t len = sizeof(VAR_4);",
"int VAR_6;",
"VAR_2 = ctx->codec->write_extra_buffer(VAR_0, VAR_1, VAR_3, &VAR_6,\nVAR_4, &len);",
"if (VAR_2 == AVERROR_EOF)\nbreak;",
"if (VAR_2 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to write extra \"\n\"buffer %d: %d.\\n\", VAR_3, VAR_2);",
"goto fail;",
"}",
"VAR_2 = vaapi_encode_make_param_buffer(VAR_0, VAR_1, VAR_6,\nVAR_4, len);",
"if (VAR_2 < 0)\ngoto fail;",
"}",
"}",
"if (ctx->codec->write_extra_header) {",
"for (VAR_3 = 0;; VAR_3++) {",
"int VAR_6;",
"bit_len = 8 * sizeof(VAR_4);",
"VAR_2 = ctx->codec->write_extra_header(VAR_0, VAR_1, VAR_3, &VAR_6,\nVAR_4, &bit_len);",
"if (VAR_2 == AVERROR_EOF)\nbreak;",
"if (VAR_2 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to write extra \"\n\"header %d: %d.\\n\", VAR_3, VAR_2);",
"goto fail;",
"}",
"VAR_2 = vaapi_encode_make_packed_header(VAR_0, VAR_1, VAR_6,\nVAR_4, bit_len);",
"if (VAR_2 < 0)\ngoto fail;",
"}",
"}",
"av_assert0(VAR_1->nb_slices <= MAX_PICTURE_SLICES);",
"for (VAR_3 = 0; VAR_3 < VAR_1->nb_slices; VAR_3++) {",
"slice = av_mallocz(sizeof(*slice));",
"if (!slice) {",
"VAR_2 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"VAR_1->slices[VAR_3] = slice;",
"if (ctx->codec->slice_params_size > 0) {",
"slice->codec_slice_params = av_mallocz(ctx->codec->slice_params_size);",
"if (!slice->codec_slice_params) {",
"VAR_2 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"}",
"if (ctx->codec->init_slice_params) {",
"VAR_2 = ctx->codec->init_slice_params(VAR_0, VAR_1, slice);",
"if (VAR_2 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to initalise slice \"\n\"parameters: %d.\\n\", VAR_2);",
"goto fail;",
"}",
"}",
"if (ctx->codec->write_slice_header) {",
"bit_len = 8 * sizeof(VAR_4);",
"VAR_2 = ctx->codec->write_slice_header(VAR_0, VAR_1, slice,\nVAR_4, &bit_len);",
"if (VAR_2 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to write per-slice \"\n\"header: %d.\\n\", VAR_2);",
"goto fail;",
"}",
"VAR_2 = vaapi_encode_make_packed_header(VAR_0, VAR_1,\nctx->codec->slice_header_type,\nVAR_4, bit_len);",
"if (VAR_2 < 0)\ngoto fail;",
"}",
"if (ctx->codec->init_slice_params) {",
"VAR_2 = vaapi_encode_make_param_buffer(VAR_0, VAR_1,\nVAEncSliceParameterBufferType,\nslice->codec_slice_params,\nctx->codec->slice_params_size);",
"if (VAR_2 < 0)\ngoto fail;",
"}",
"}",
"vas = vaBeginPicture(ctx->hwctx->display, ctx->va_context,\nVAR_1->input_surface);",
"if (vas != VA_STATUS_SUCCESS) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to begin picture encode issue: \"\n\"%d (%s).\\n\", vas, vaErrorStr(vas));",
"VAR_2 = AVERROR(EIO);",
"goto fail_with_picture;",
"}",
"vas = vaRenderPicture(ctx->hwctx->display, ctx->va_context,\nVAR_1->param_buffers, VAR_1->nb_param_buffers);",
"if (vas != VA_STATUS_SUCCESS) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to upload encode parameters: \"\n\"%d (%s).\\n\", vas, vaErrorStr(vas));",
"VAR_2 = AVERROR(EIO);",
"goto fail_with_picture;",
"}",
"vas = vaEndPicture(ctx->hwctx->display, ctx->va_context);",
"if (vas != VA_STATUS_SUCCESS) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to end picture encode issue: \"\n\"%d (%s).\\n\", vas, vaErrorStr(vas));",
"VAR_2 = AVERROR(EIO);",
"if (ctx->hwctx->driver_quirks &\nAV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS)\ngoto fail;",
"else\ngoto fail_at_end;",
"}",
"if (ctx->hwctx->driver_quirks &\nAV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS) {",
"for (VAR_3 = 0; VAR_3 < VAR_1->nb_param_buffers; VAR_3++) {",
"vas = vaDestroyBuffer(ctx->hwctx->display,\nVAR_1->param_buffers[VAR_3]);",
"if (vas != VA_STATUS_SUCCESS) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to destroy \"\n\"param buffer %#x: %d (%s).\\n\",\nVAR_1->param_buffers[VAR_3], vas, vaErrorStr(vas));",
"}",
"}",
"}",
"VAR_1->encode_issued = 1;",
"if (ctx->issue_mode == ISSUE_MODE_SERIALISE_EVERYTHING)\nreturn vaapi_encode_wait(VAR_0, VAR_1);",
"else\nreturn 0;",
"fail_with_picture:\nvaEndPicture(ctx->hwctx->display, ctx->va_context);",
"fail:\nfor(VAR_3 = 0; VAR_3 < VAR_1->nb_param_buffers; VAR_3++)",
"vaDestroyBuffer(ctx->hwctx->display, VAR_1->param_buffers[VAR_3]);",
"fail_at_end:\nav_freep(&VAR_1->codec_picture_params);",
"av_frame_free(&VAR_1->recon_image);",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
49
],
[
51
],
[
53
],
[
61,
63
],
[
65,
67
],
[
69
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117,
119
],
[
123
],
[
125
],
[
127,
129
],
[
131,
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
147
],
[
153
],
[
155,
157,
159,
161
],
[
163,
165
],
[
167
],
[
169
],
[
173
],
[
175,
177,
179,
181
],
[
183,
185
],
[
187
],
[
191
],
[
193
],
[
195
],
[
197,
199
],
[
201
],
[
203
],
[
205,
207,
209,
211
],
[
213,
215
],
[
217
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231,
233
],
[
235
],
[
237
],
[
239,
241,
243
],
[
245,
247
],
[
249
],
[
251
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263,
265
],
[
267
],
[
269
],
[
271,
273,
275
],
[
277,
279
],
[
281
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293,
295
],
[
297,
299
],
[
301
],
[
303,
305
],
[
307
],
[
309
],
[
313,
315
],
[
317,
319
],
[
321
],
[
323
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335,
337
],
[
339,
341
],
[
343
],
[
345,
347
],
[
349
],
[
351
],
[
355,
357
],
[
359,
361
],
[
363
],
[
365
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
403
],
[
405
],
[
407
],
[
409,
411
],
[
413
],
[
415
],
[
417
],
[
421
],
[
423
],
[
425,
427
],
[
429
],
[
431,
433
],
[
435
],
[
437
],
[
439,
441,
443
],
[
445,
447
],
[
449
],
[
453
],
[
455,
457,
459,
461
],
[
463,
465
],
[
467
],
[
469
],
[
473,
475
],
[
477
],
[
479,
481
],
[
483
],
[
485
],
[
487
],
[
491,
493
],
[
495
],
[
497,
499
],
[
501
],
[
503
],
[
505
],
[
509
],
[
511
],
[
513,
515
],
[
517
],
[
523,
525,
527
],
[
529,
531
],
[
533
],
[
537,
539
],
[
541
],
[
543,
545
],
[
547
],
[
549,
551,
553
],
[
557
],
[
559
],
[
561
],
[
565
],
[
569,
571
],
[
573,
575
],
[
579,
581
],
[
583,
585
],
[
587
],
[
589,
591
],
[
593
],
[
595
],
[
597
]
] |
26,817 | static void avc_luma_hv_qrt_8w_msa(const uint8_t *src_x, const uint8_t *src_y,
int32_t src_stride, uint8_t *dst,
int32_t dst_stride, int32_t height)
{
uint32_t loop_cnt;
v16i8 src_hz0, src_hz1, src_hz2, src_hz3;
v16i8 src_vt0, src_vt1, src_vt2, src_vt3, src_vt4;
v16i8 src_vt5, src_vt6, src_vt7, src_vt8;
v16i8 mask0, mask1, mask2;
v8i16 hz_out0, hz_out1, hz_out2, hz_out3;
v8i16 vert_out0, vert_out1, vert_out2, vert_out3;
v8i16 out0, out1, out2, out3;
v16u8 tmp0, tmp1;
LD_SB3(&luma_mask_arr[0], 16, mask0, mask1, mask2);
LD_SB5(src_y, src_stride, src_vt0, src_vt1, src_vt2, src_vt3, src_vt4);
src_y += (5 * src_stride);
src_vt0 = (v16i8) __msa_insve_d((v2i64) src_vt0, 1, (v2i64) src_vt1);
src_vt1 = (v16i8) __msa_insve_d((v2i64) src_vt1, 1, (v2i64) src_vt2);
src_vt2 = (v16i8) __msa_insve_d((v2i64) src_vt2, 1, (v2i64) src_vt3);
src_vt3 = (v16i8) __msa_insve_d((v2i64) src_vt3, 1, (v2i64) src_vt4);
XORI_B4_128_SB(src_vt0, src_vt1, src_vt2, src_vt3);
for (loop_cnt = (height >> 2); loop_cnt--;) {
LD_SB4(src_x, src_stride, src_hz0, src_hz1, src_hz2, src_hz3);
XORI_B4_128_SB(src_hz0, src_hz1, src_hz2, src_hz3);
src_x += (4 * src_stride);
hz_out0 = AVC_HORZ_FILTER_SH(src_hz0, src_hz0, mask0, mask1, mask2);
hz_out1 = AVC_HORZ_FILTER_SH(src_hz1, src_hz1, mask0, mask1, mask2);
hz_out2 = AVC_HORZ_FILTER_SH(src_hz2, src_hz2, mask0, mask1, mask2);
hz_out3 = AVC_HORZ_FILTER_SH(src_hz3, src_hz3, mask0, mask1, mask2);
SRARI_H4_SH(hz_out0, hz_out1, hz_out2, hz_out3, 5);
SAT_SH4_SH(hz_out0, hz_out1, hz_out2, hz_out3, 7);
LD_SB4(src_y, src_stride, src_vt5, src_vt6, src_vt7, src_vt8);
src_y += (4 * src_stride);
src_vt4 = (v16i8) __msa_insve_d((v2i64) src_vt4, 1, (v2i64) src_vt5);
src_vt5 = (v16i8) __msa_insve_d((v2i64) src_vt5, 1, (v2i64) src_vt6);
src_vt6 = (v16i8) __msa_insve_d((v2i64) src_vt6, 1, (v2i64) src_vt7);
src_vt7 = (v16i8) __msa_insve_d((v2i64) src_vt7, 1, (v2i64) src_vt8);
XORI_B4_128_SB(src_vt4, src_vt5, src_vt6, src_vt7);
/* filter calc */
AVC_CALC_DPADD_B_6PIX_2COEFF_SH(src_vt0, src_vt1, src_vt2, src_vt3,
src_vt4, src_vt5, vert_out0, vert_out1);
AVC_CALC_DPADD_B_6PIX_2COEFF_SH(src_vt2, src_vt3, src_vt4, src_vt5,
src_vt6, src_vt7, vert_out2, vert_out3);
SRARI_H4_SH(vert_out0, vert_out1, vert_out2, vert_out3, 5);
SAT_SH4_SH(vert_out0, vert_out1, vert_out2, vert_out3, 7);
out0 = __msa_srari_h((hz_out0 + vert_out0), 1);
out1 = __msa_srari_h((hz_out1 + vert_out1), 1);
out2 = __msa_srari_h((hz_out2 + vert_out2), 1);
out3 = __msa_srari_h((hz_out3 + vert_out3), 1);
SAT_SH4_SH(out0, out1, out2, out3, 7);
tmp0 = PCKEV_XORI128_UB(out0, out1);
tmp1 = PCKEV_XORI128_UB(out2, out3);
ST8x4_UB(tmp0, tmp1, dst, dst_stride);
dst += (4 * dst_stride);
src_vt3 = src_vt7;
src_vt1 = src_vt5;
src_vt5 = src_vt4;
src_vt4 = src_vt8;
src_vt2 = src_vt6;
src_vt0 = src_vt5;
}
}
| false | FFmpeg | 2aab7c2dfaca4386c38e5d565cd2bf73096bcc86 | static void avc_luma_hv_qrt_8w_msa(const uint8_t *src_x, const uint8_t *src_y,
int32_t src_stride, uint8_t *dst,
int32_t dst_stride, int32_t height)
{
uint32_t loop_cnt;
v16i8 src_hz0, src_hz1, src_hz2, src_hz3;
v16i8 src_vt0, src_vt1, src_vt2, src_vt3, src_vt4;
v16i8 src_vt5, src_vt6, src_vt7, src_vt8;
v16i8 mask0, mask1, mask2;
v8i16 hz_out0, hz_out1, hz_out2, hz_out3;
v8i16 vert_out0, vert_out1, vert_out2, vert_out3;
v8i16 out0, out1, out2, out3;
v16u8 tmp0, tmp1;
LD_SB3(&luma_mask_arr[0], 16, mask0, mask1, mask2);
LD_SB5(src_y, src_stride, src_vt0, src_vt1, src_vt2, src_vt3, src_vt4);
src_y += (5 * src_stride);
src_vt0 = (v16i8) __msa_insve_d((v2i64) src_vt0, 1, (v2i64) src_vt1);
src_vt1 = (v16i8) __msa_insve_d((v2i64) src_vt1, 1, (v2i64) src_vt2);
src_vt2 = (v16i8) __msa_insve_d((v2i64) src_vt2, 1, (v2i64) src_vt3);
src_vt3 = (v16i8) __msa_insve_d((v2i64) src_vt3, 1, (v2i64) src_vt4);
XORI_B4_128_SB(src_vt0, src_vt1, src_vt2, src_vt3);
for (loop_cnt = (height >> 2); loop_cnt--;) {
LD_SB4(src_x, src_stride, src_hz0, src_hz1, src_hz2, src_hz3);
XORI_B4_128_SB(src_hz0, src_hz1, src_hz2, src_hz3);
src_x += (4 * src_stride);
hz_out0 = AVC_HORZ_FILTER_SH(src_hz0, src_hz0, mask0, mask1, mask2);
hz_out1 = AVC_HORZ_FILTER_SH(src_hz1, src_hz1, mask0, mask1, mask2);
hz_out2 = AVC_HORZ_FILTER_SH(src_hz2, src_hz2, mask0, mask1, mask2);
hz_out3 = AVC_HORZ_FILTER_SH(src_hz3, src_hz3, mask0, mask1, mask2);
SRARI_H4_SH(hz_out0, hz_out1, hz_out2, hz_out3, 5);
SAT_SH4_SH(hz_out0, hz_out1, hz_out2, hz_out3, 7);
LD_SB4(src_y, src_stride, src_vt5, src_vt6, src_vt7, src_vt8);
src_y += (4 * src_stride);
src_vt4 = (v16i8) __msa_insve_d((v2i64) src_vt4, 1, (v2i64) src_vt5);
src_vt5 = (v16i8) __msa_insve_d((v2i64) src_vt5, 1, (v2i64) src_vt6);
src_vt6 = (v16i8) __msa_insve_d((v2i64) src_vt6, 1, (v2i64) src_vt7);
src_vt7 = (v16i8) __msa_insve_d((v2i64) src_vt7, 1, (v2i64) src_vt8);
XORI_B4_128_SB(src_vt4, src_vt5, src_vt6, src_vt7);
AVC_CALC_DPADD_B_6PIX_2COEFF_SH(src_vt0, src_vt1, src_vt2, src_vt3,
src_vt4, src_vt5, vert_out0, vert_out1);
AVC_CALC_DPADD_B_6PIX_2COEFF_SH(src_vt2, src_vt3, src_vt4, src_vt5,
src_vt6, src_vt7, vert_out2, vert_out3);
SRARI_H4_SH(vert_out0, vert_out1, vert_out2, vert_out3, 5);
SAT_SH4_SH(vert_out0, vert_out1, vert_out2, vert_out3, 7);
out0 = __msa_srari_h((hz_out0 + vert_out0), 1);
out1 = __msa_srari_h((hz_out1 + vert_out1), 1);
out2 = __msa_srari_h((hz_out2 + vert_out2), 1);
out3 = __msa_srari_h((hz_out3 + vert_out3), 1);
SAT_SH4_SH(out0, out1, out2, out3, 7);
tmp0 = PCKEV_XORI128_UB(out0, out1);
tmp1 = PCKEV_XORI128_UB(out2, out3);
ST8x4_UB(tmp0, tmp1, dst, dst_stride);
dst += (4 * dst_stride);
src_vt3 = src_vt7;
src_vt1 = src_vt5;
src_vt5 = src_vt4;
src_vt4 = src_vt8;
src_vt2 = src_vt6;
src_vt0 = src_vt5;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const uint8_t *VAR_0, const uint8_t *VAR_1,
int32_t VAR_2, uint8_t *VAR_3,
int32_t VAR_4, int32_t VAR_5)
{
uint32_t loop_cnt;
v16i8 src_hz0, src_hz1, src_hz2, src_hz3;
v16i8 src_vt0, src_vt1, src_vt2, src_vt3, src_vt4;
v16i8 src_vt5, src_vt6, src_vt7, src_vt8;
v16i8 mask0, mask1, mask2;
v8i16 hz_out0, hz_out1, hz_out2, hz_out3;
v8i16 vert_out0, vert_out1, vert_out2, vert_out3;
v8i16 out0, out1, out2, out3;
v16u8 tmp0, tmp1;
LD_SB3(&luma_mask_arr[0], 16, mask0, mask1, mask2);
LD_SB5(VAR_1, VAR_2, src_vt0, src_vt1, src_vt2, src_vt3, src_vt4);
VAR_1 += (5 * VAR_2);
src_vt0 = (v16i8) __msa_insve_d((v2i64) src_vt0, 1, (v2i64) src_vt1);
src_vt1 = (v16i8) __msa_insve_d((v2i64) src_vt1, 1, (v2i64) src_vt2);
src_vt2 = (v16i8) __msa_insve_d((v2i64) src_vt2, 1, (v2i64) src_vt3);
src_vt3 = (v16i8) __msa_insve_d((v2i64) src_vt3, 1, (v2i64) src_vt4);
XORI_B4_128_SB(src_vt0, src_vt1, src_vt2, src_vt3);
for (loop_cnt = (VAR_5 >> 2); loop_cnt--;) {
LD_SB4(VAR_0, VAR_2, src_hz0, src_hz1, src_hz2, src_hz3);
XORI_B4_128_SB(src_hz0, src_hz1, src_hz2, src_hz3);
VAR_0 += (4 * VAR_2);
hz_out0 = AVC_HORZ_FILTER_SH(src_hz0, src_hz0, mask0, mask1, mask2);
hz_out1 = AVC_HORZ_FILTER_SH(src_hz1, src_hz1, mask0, mask1, mask2);
hz_out2 = AVC_HORZ_FILTER_SH(src_hz2, src_hz2, mask0, mask1, mask2);
hz_out3 = AVC_HORZ_FILTER_SH(src_hz3, src_hz3, mask0, mask1, mask2);
SRARI_H4_SH(hz_out0, hz_out1, hz_out2, hz_out3, 5);
SAT_SH4_SH(hz_out0, hz_out1, hz_out2, hz_out3, 7);
LD_SB4(VAR_1, VAR_2, src_vt5, src_vt6, src_vt7, src_vt8);
VAR_1 += (4 * VAR_2);
src_vt4 = (v16i8) __msa_insve_d((v2i64) src_vt4, 1, (v2i64) src_vt5);
src_vt5 = (v16i8) __msa_insve_d((v2i64) src_vt5, 1, (v2i64) src_vt6);
src_vt6 = (v16i8) __msa_insve_d((v2i64) src_vt6, 1, (v2i64) src_vt7);
src_vt7 = (v16i8) __msa_insve_d((v2i64) src_vt7, 1, (v2i64) src_vt8);
XORI_B4_128_SB(src_vt4, src_vt5, src_vt6, src_vt7);
AVC_CALC_DPADD_B_6PIX_2COEFF_SH(src_vt0, src_vt1, src_vt2, src_vt3,
src_vt4, src_vt5, vert_out0, vert_out1);
AVC_CALC_DPADD_B_6PIX_2COEFF_SH(src_vt2, src_vt3, src_vt4, src_vt5,
src_vt6, src_vt7, vert_out2, vert_out3);
SRARI_H4_SH(vert_out0, vert_out1, vert_out2, vert_out3, 5);
SAT_SH4_SH(vert_out0, vert_out1, vert_out2, vert_out3, 7);
out0 = __msa_srari_h((hz_out0 + vert_out0), 1);
out1 = __msa_srari_h((hz_out1 + vert_out1), 1);
out2 = __msa_srari_h((hz_out2 + vert_out2), 1);
out3 = __msa_srari_h((hz_out3 + vert_out3), 1);
SAT_SH4_SH(out0, out1, out2, out3, 7);
tmp0 = PCKEV_XORI128_UB(out0, out1);
tmp1 = PCKEV_XORI128_UB(out2, out3);
ST8x4_UB(tmp0, tmp1, VAR_3, VAR_4);
VAR_3 += (4 * VAR_4);
src_vt3 = src_vt7;
src_vt1 = src_vt5;
src_vt5 = src_vt4;
src_vt4 = src_vt8;
src_vt2 = src_vt6;
src_vt0 = src_vt5;
}
}
| [
"static void FUNC_0(const uint8_t *VAR_0, const uint8_t *VAR_1,\nint32_t VAR_2, uint8_t *VAR_3,\nint32_t VAR_4, int32_t VAR_5)\n{",
"uint32_t loop_cnt;",
"v16i8 src_hz0, src_hz1, src_hz2, src_hz3;",
"v16i8 src_vt0, src_vt1, src_vt2, src_vt3, src_vt4;",
"v16i8 src_vt5, src_vt6, src_vt7, src_vt8;",
"v16i8 mask0, mask1, mask2;",
"v8i16 hz_out0, hz_out1, hz_out2, hz_out3;",
"v8i16 vert_out0, vert_out1, vert_out2, vert_out3;",
"v8i16 out0, out1, out2, out3;",
"v16u8 tmp0, tmp1;",
"LD_SB3(&luma_mask_arr[0], 16, mask0, mask1, mask2);",
"LD_SB5(VAR_1, VAR_2, src_vt0, src_vt1, src_vt2, src_vt3, src_vt4);",
"VAR_1 += (5 * VAR_2);",
"src_vt0 = (v16i8) __msa_insve_d((v2i64) src_vt0, 1, (v2i64) src_vt1);",
"src_vt1 = (v16i8) __msa_insve_d((v2i64) src_vt1, 1, (v2i64) src_vt2);",
"src_vt2 = (v16i8) __msa_insve_d((v2i64) src_vt2, 1, (v2i64) src_vt3);",
"src_vt3 = (v16i8) __msa_insve_d((v2i64) src_vt3, 1, (v2i64) src_vt4);",
"XORI_B4_128_SB(src_vt0, src_vt1, src_vt2, src_vt3);",
"for (loop_cnt = (VAR_5 >> 2); loop_cnt--;) {",
"LD_SB4(VAR_0, VAR_2, src_hz0, src_hz1, src_hz2, src_hz3);",
"XORI_B4_128_SB(src_hz0, src_hz1, src_hz2, src_hz3);",
"VAR_0 += (4 * VAR_2);",
"hz_out0 = AVC_HORZ_FILTER_SH(src_hz0, src_hz0, mask0, mask1, mask2);",
"hz_out1 = AVC_HORZ_FILTER_SH(src_hz1, src_hz1, mask0, mask1, mask2);",
"hz_out2 = AVC_HORZ_FILTER_SH(src_hz2, src_hz2, mask0, mask1, mask2);",
"hz_out3 = AVC_HORZ_FILTER_SH(src_hz3, src_hz3, mask0, mask1, mask2);",
"SRARI_H4_SH(hz_out0, hz_out1, hz_out2, hz_out3, 5);",
"SAT_SH4_SH(hz_out0, hz_out1, hz_out2, hz_out3, 7);",
"LD_SB4(VAR_1, VAR_2, src_vt5, src_vt6, src_vt7, src_vt8);",
"VAR_1 += (4 * VAR_2);",
"src_vt4 = (v16i8) __msa_insve_d((v2i64) src_vt4, 1, (v2i64) src_vt5);",
"src_vt5 = (v16i8) __msa_insve_d((v2i64) src_vt5, 1, (v2i64) src_vt6);",
"src_vt6 = (v16i8) __msa_insve_d((v2i64) src_vt6, 1, (v2i64) src_vt7);",
"src_vt7 = (v16i8) __msa_insve_d((v2i64) src_vt7, 1, (v2i64) src_vt8);",
"XORI_B4_128_SB(src_vt4, src_vt5, src_vt6, src_vt7);",
"AVC_CALC_DPADD_B_6PIX_2COEFF_SH(src_vt0, src_vt1, src_vt2, src_vt3,\nsrc_vt4, src_vt5, vert_out0, vert_out1);",
"AVC_CALC_DPADD_B_6PIX_2COEFF_SH(src_vt2, src_vt3, src_vt4, src_vt5,\nsrc_vt6, src_vt7, vert_out2, vert_out3);",
"SRARI_H4_SH(vert_out0, vert_out1, vert_out2, vert_out3, 5);",
"SAT_SH4_SH(vert_out0, vert_out1, vert_out2, vert_out3, 7);",
"out0 = __msa_srari_h((hz_out0 + vert_out0), 1);",
"out1 = __msa_srari_h((hz_out1 + vert_out1), 1);",
"out2 = __msa_srari_h((hz_out2 + vert_out2), 1);",
"out3 = __msa_srari_h((hz_out3 + vert_out3), 1);",
"SAT_SH4_SH(out0, out1, out2, out3, 7);",
"tmp0 = PCKEV_XORI128_UB(out0, out1);",
"tmp1 = PCKEV_XORI128_UB(out2, out3);",
"ST8x4_UB(tmp0, tmp1, VAR_3, VAR_4);",
"VAR_3 += (4 * VAR_4);",
"src_vt3 = src_vt7;",
"src_vt1 = src_vt5;",
"src_vt5 = src_vt4;",
"src_vt4 = src_vt8;",
"src_vt2 = src_vt6;",
"src_vt0 = src_vt5;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
39
],
[
41
],
[
43
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
99,
101
],
[
103,
105
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
]
] |
26,820 | static int dxva_get_decoder_guid(AVCodecContext *avctx, void *service, void *surface_format,
unsigned guid_count, const GUID *guid_list, GUID *decoder_guid)
{
FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx);
unsigned i, j;
*decoder_guid = ff_GUID_NULL;
for (i = 0; dxva_modes[i].guid; i++) {
const dxva_mode *mode = &dxva_modes[i];
int validate;
if (mode->codec != avctx->codec_id)
continue;
for (j = 0; j < guid_count; j++) {
if (IsEqualGUID(mode->guid, &guid_list[j]))
break;
}
if (j == guid_count)
continue;
#if CONFIG_D3D11VA
if (sctx->pix_fmt == AV_PIX_FMT_D3D11)
validate = d3d11va_validate_output(service, *mode->guid, surface_format);
#endif
#if CONFIG_DXVA2
if (sctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD)
validate = dxva2_validate_output(service, *mode->guid, surface_format);
#endif
if (validate) {
*decoder_guid = *mode->guid;
break;
}
}
if (IsEqualGUID(decoder_guid, &ff_GUID_NULL)) {
av_log(avctx, AV_LOG_VERBOSE, "No decoder device for codec found\n");
return AVERROR(EINVAL);
}
if (IsEqualGUID(decoder_guid, &ff_DXVADDI_Intel_ModeH264_E))
sctx->workaround |= FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO;
return 0;
}
| false | FFmpeg | e2afcc33e0bcba92ab6c767f09f17a67911a4928 | static int dxva_get_decoder_guid(AVCodecContext *avctx, void *service, void *surface_format,
unsigned guid_count, const GUID *guid_list, GUID *decoder_guid)
{
FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx);
unsigned i, j;
*decoder_guid = ff_GUID_NULL;
for (i = 0; dxva_modes[i].guid; i++) {
const dxva_mode *mode = &dxva_modes[i];
int validate;
if (mode->codec != avctx->codec_id)
continue;
for (j = 0; j < guid_count; j++) {
if (IsEqualGUID(mode->guid, &guid_list[j]))
break;
}
if (j == guid_count)
continue;
#if CONFIG_D3D11VA
if (sctx->pix_fmt == AV_PIX_FMT_D3D11)
validate = d3d11va_validate_output(service, *mode->guid, surface_format);
#endif
#if CONFIG_DXVA2
if (sctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD)
validate = dxva2_validate_output(service, *mode->guid, surface_format);
#endif
if (validate) {
*decoder_guid = *mode->guid;
break;
}
}
if (IsEqualGUID(decoder_guid, &ff_GUID_NULL)) {
av_log(avctx, AV_LOG_VERBOSE, "No decoder device for codec found\n");
return AVERROR(EINVAL);
}
if (IsEqualGUID(decoder_guid, &ff_DXVADDI_Intel_ModeH264_E))
sctx->workaround |= FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, void *VAR_2,
unsigned VAR_3, const GUID *VAR_4, GUID *VAR_5)
{
FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(VAR_0);
unsigned VAR_6, VAR_7;
*VAR_5 = ff_GUID_NULL;
for (VAR_6 = 0; dxva_modes[VAR_6].guid; VAR_6++) {
const dxva_mode *mode = &dxva_modes[VAR_6];
int validate;
if (mode->codec != VAR_0->codec_id)
continue;
for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) {
if (IsEqualGUID(mode->guid, &VAR_4[VAR_7]))
break;
}
if (VAR_7 == VAR_3)
continue;
#if CONFIG_D3D11VA
if (sctx->pix_fmt == AV_PIX_FMT_D3D11)
validate = d3d11va_validate_output(VAR_1, *mode->guid, VAR_2);
#endif
#if CONFIG_DXVA2
if (sctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD)
validate = dxva2_validate_output(VAR_1, *mode->guid, VAR_2);
#endif
if (validate) {
*VAR_5 = *mode->guid;
break;
}
}
if (IsEqualGUID(VAR_5, &ff_GUID_NULL)) {
av_log(VAR_0, AV_LOG_VERBOSE, "No decoder device for codec found\n");
return AVERROR(EINVAL);
}
if (IsEqualGUID(VAR_5, &ff_DXVADDI_Intel_ModeH264_E))
sctx->workaround |= FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, void *VAR_2,\nunsigned VAR_3, const GUID *VAR_4, GUID *VAR_5)\n{",
"FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(VAR_0);",
"unsigned VAR_6, VAR_7;",
"*VAR_5 = ff_GUID_NULL;",
"for (VAR_6 = 0; dxva_modes[VAR_6].guid; VAR_6++) {",
"const dxva_mode *mode = &dxva_modes[VAR_6];",
"int validate;",
"if (mode->codec != VAR_0->codec_id)\ncontinue;",
"for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) {",
"if (IsEqualGUID(mode->guid, &VAR_4[VAR_7]))\nbreak;",
"}",
"if (VAR_7 == VAR_3)\ncontinue;",
"#if CONFIG_D3D11VA\nif (sctx->pix_fmt == AV_PIX_FMT_D3D11)\nvalidate = d3d11va_validate_output(VAR_1, *mode->guid, VAR_2);",
"#endif\n#if CONFIG_DXVA2\nif (sctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD)\nvalidate = dxva2_validate_output(VAR_1, *mode->guid, VAR_2);",
"#endif\nif (validate) {",
"*VAR_5 = *mode->guid;",
"break;",
"}",
"}",
"if (IsEqualGUID(VAR_5, &ff_GUID_NULL)) {",
"av_log(VAR_0, AV_LOG_VERBOSE, \"No decoder device for codec found\\n\");",
"return AVERROR(EINVAL);",
"}",
"if (IsEqualGUID(VAR_5, &ff_DXVADDI_Intel_ModeH264_E))\nsctx->workaround |= FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO;",
"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
],
[
21,
23
],
[
27
],
[
29,
31
],
[
33
],
[
35,
37
],
[
41,
43,
45
],
[
47,
49,
51,
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79,
81
],
[
85
],
[
87
]
] |
26,821 | static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
{
MpegEncContext *s = &ctx->m;
int width, height, vo_ver_id;
/* vol header */
skip_bits(gb, 1); /* random access */
s->vo_type = get_bits(gb, 8);
if (get_bits1(gb) != 0) { /* is_ol_id */
vo_ver_id = get_bits(gb, 4); /* vo_ver_id */
skip_bits(gb, 3); /* vo_priority */
} else {
vo_ver_id = 1;
}
s->aspect_ratio_info = get_bits(gb, 4);
if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) {
s->avctx->sample_aspect_ratio.num = get_bits(gb, 8); // par_width
s->avctx->sample_aspect_ratio.den = get_bits(gb, 8); // par_height
} else {
s->avctx->sample_aspect_ratio = ff_h263_pixel_aspect[s->aspect_ratio_info];
}
if ((ctx->vol_control_parameters = get_bits1(gb))) { /* vol control parameter */
int chroma_format = get_bits(gb, 2);
if (chroma_format != CHROMA_420)
av_log(s->avctx, AV_LOG_ERROR, "illegal chroma format\n");
s->low_delay = get_bits1(gb);
if (get_bits1(gb)) { /* vbv parameters */
get_bits(gb, 15); /* first_half_bitrate */
skip_bits1(gb); /* marker */
get_bits(gb, 15); /* latter_half_bitrate */
skip_bits1(gb); /* marker */
get_bits(gb, 15); /* first_half_vbv_buffer_size */
skip_bits1(gb); /* marker */
get_bits(gb, 3); /* latter_half_vbv_buffer_size */
get_bits(gb, 11); /* first_half_vbv_occupancy */
skip_bits1(gb); /* marker */
get_bits(gb, 15); /* latter_half_vbv_occupancy */
skip_bits1(gb); /* marker */
}
} else {
/* is setting low delay flag only once the smartest thing to do?
* low delay detection won't be overridden. */
if (s->picture_number == 0)
s->low_delay = 0;
}
ctx->shape = get_bits(gb, 2); /* vol shape */
if (ctx->shape != RECT_SHAPE)
av_log(s->avctx, AV_LOG_ERROR, "only rectangular vol supported\n");
if (ctx->shape == GRAY_SHAPE && vo_ver_id != 1) {
av_log(s->avctx, AV_LOG_ERROR, "Gray shape not supported\n");
skip_bits(gb, 4); /* video_object_layer_shape_extension */
}
check_marker(gb, "before time_increment_resolution");
s->avctx->framerate.num = get_bits(gb, 16);
if (!s->avctx->framerate.num) {
av_log(s->avctx, AV_LOG_ERROR, "framerate==0\n");
return AVERROR_INVALIDDATA;
}
ctx->time_increment_bits = av_log2(s->avctx->framerate.num - 1) + 1;
if (ctx->time_increment_bits < 1)
ctx->time_increment_bits = 1;
check_marker(gb, "before fixed_vop_rate");
if (get_bits1(gb) != 0) /* fixed_vop_rate */
s->avctx->framerate.den = get_bits(gb, ctx->time_increment_bits);
else
s->avctx->framerate.den = 1;
s->avctx->time_base = av_inv_q(av_mul_q(s->avctx->framerate, (AVRational){s->avctx->ticks_per_frame, 1}));
ctx->t_frame = 0;
if (ctx->shape != BIN_ONLY_SHAPE) {
if (ctx->shape == RECT_SHAPE) {
check_marker(gb, "before width");
width = get_bits(gb, 13);
check_marker(gb, "before height");
height = get_bits(gb, 13);
check_marker(gb, "after height");
if (width && height && /* they should be non zero but who knows */
!(s->width && s->codec_tag == AV_RL32("MP4S"))) {
if (s->width && s->height &&
(s->width != width || s->height != height))
s->context_reinit = 1;
s->width = width;
s->height = height;
}
}
s->progressive_sequence =
s->progressive_frame = get_bits1(gb) ^ 1;
s->interlaced_dct = 0;
if (!get_bits1(gb) && (s->avctx->debug & FF_DEBUG_PICT_INFO))
av_log(s->avctx, AV_LOG_INFO, /* OBMC Disable */
"MPEG4 OBMC not supported (very likely buggy encoder)\n");
if (vo_ver_id == 1)
ctx->vol_sprite_usage = get_bits1(gb); /* vol_sprite_usage */
else
ctx->vol_sprite_usage = get_bits(gb, 2); /* vol_sprite_usage */
if (ctx->vol_sprite_usage == STATIC_SPRITE)
av_log(s->avctx, AV_LOG_ERROR, "Static Sprites not supported\n");
if (ctx->vol_sprite_usage == STATIC_SPRITE ||
ctx->vol_sprite_usage == GMC_SPRITE) {
if (ctx->vol_sprite_usage == STATIC_SPRITE) {
skip_bits(gb, 13); // sprite_width
skip_bits1(gb); /* marker */
skip_bits(gb, 13); // sprite_height
skip_bits1(gb); /* marker */
skip_bits(gb, 13); // sprite_left
skip_bits1(gb); /* marker */
skip_bits(gb, 13); // sprite_top
skip_bits1(gb); /* marker */
}
ctx->num_sprite_warping_points = get_bits(gb, 6);
if (ctx->num_sprite_warping_points > 3) {
av_log(s->avctx, AV_LOG_ERROR,
"%d sprite_warping_points\n",
ctx->num_sprite_warping_points);
ctx->num_sprite_warping_points = 0;
return AVERROR_INVALIDDATA;
}
s->sprite_warping_accuracy = get_bits(gb, 2);
ctx->sprite_brightness_change = get_bits1(gb);
if (ctx->vol_sprite_usage == STATIC_SPRITE)
skip_bits1(gb); // low_latency_sprite
}
// FIXME sadct disable bit if verid!=1 && shape not rect
if (get_bits1(gb) == 1) { /* not_8_bit */
s->quant_precision = get_bits(gb, 4); /* quant_precision */
if (get_bits(gb, 4) != 8) /* bits_per_pixel */
av_log(s->avctx, AV_LOG_ERROR, "N-bit not supported\n");
if (s->quant_precision != 5)
av_log(s->avctx, AV_LOG_ERROR,
"quant precision %d\n", s->quant_precision);
if (s->quant_precision<3 || s->quant_precision>9) {
s->quant_precision = 5;
}
} else {
s->quant_precision = 5;
}
// FIXME a bunch of grayscale shape things
if ((s->mpeg_quant = get_bits1(gb))) { /* vol_quant_type */
int i, v;
/* load default matrixes */
for (i = 0; i < 64; i++) {
int j = s->idsp.idct_permutation[i];
v = ff_mpeg4_default_intra_matrix[i];
s->intra_matrix[j] = v;
s->chroma_intra_matrix[j] = v;
v = ff_mpeg4_default_non_intra_matrix[i];
s->inter_matrix[j] = v;
s->chroma_inter_matrix[j] = v;
}
/* load custom intra matrix */
if (get_bits1(gb)) {
int last = 0;
for (i = 0; i < 64; i++) {
int j;
v = get_bits(gb, 8);
if (v == 0)
break;
last = v;
j = s->idsp.idct_permutation[ff_zigzag_direct[i]];
s->intra_matrix[j] = last;
s->chroma_intra_matrix[j] = last;
}
/* replicate last value */
for (; i < 64; i++) {
int j = s->idsp.idct_permutation[ff_zigzag_direct[i]];
s->intra_matrix[j] = last;
s->chroma_intra_matrix[j] = last;
}
}
/* load custom non intra matrix */
if (get_bits1(gb)) {
int last = 0;
for (i = 0; i < 64; i++) {
int j;
v = get_bits(gb, 8);
if (v == 0)
break;
last = v;
j = s->idsp.idct_permutation[ff_zigzag_direct[i]];
s->inter_matrix[j] = v;
s->chroma_inter_matrix[j] = v;
}
/* replicate last value */
for (; i < 64; i++) {
int j = s->idsp.idct_permutation[ff_zigzag_direct[i]];
s->inter_matrix[j] = last;
s->chroma_inter_matrix[j] = last;
}
}
// FIXME a bunch of grayscale shape things
}
if (vo_ver_id != 1)
s->quarter_sample = get_bits1(gb);
else
s->quarter_sample = 0;
if (get_bits_left(gb) < 4) {
av_log(s->avctx, AV_LOG_ERROR, "VOL Header truncated\n");
return AVERROR_INVALIDDATA;
}
if (!get_bits1(gb)) {
int pos = get_bits_count(gb);
int estimation_method = get_bits(gb, 2);
if (estimation_method < 2) {
if (!get_bits1(gb)) {
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb); /* opaque */
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb); /* transparent */
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb); /* intra_cae */
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb); /* inter_cae */
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb); /* no_update */
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb); /* upampling */
}
if (!get_bits1(gb)) {
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb); /* intra_blocks */
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb); /* inter_blocks */
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb); /* inter4v_blocks */
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb); /* not coded blocks */
}
if (!check_marker(gb, "in complexity estimation part 1")) {
skip_bits_long(gb, pos - get_bits_count(gb));
goto no_cplx_est;
}
if (!get_bits1(gb)) {
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb); /* dct_coeffs */
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb); /* dct_lines */
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb); /* vlc_syms */
ctx->cplx_estimation_trash_i += 4 * get_bits1(gb); /* vlc_bits */
}
if (!get_bits1(gb)) {
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb); /* apm */
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb); /* npm */
ctx->cplx_estimation_trash_b += 8 * get_bits1(gb); /* interpolate_mc_q */
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb); /* forwback_mc_q */
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb); /* halfpel2 */
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb); /* halfpel4 */
}
if (!check_marker(gb, "in complexity estimation part 2")) {
skip_bits_long(gb, pos - get_bits_count(gb));
goto no_cplx_est;
}
if (estimation_method == 1) {
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb); /* sadct */
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb); /* qpel */
}
} else
av_log(s->avctx, AV_LOG_ERROR,
"Invalid Complexity estimation method %d\n",
estimation_method);
} else {
no_cplx_est:
ctx->cplx_estimation_trash_i =
ctx->cplx_estimation_trash_p =
ctx->cplx_estimation_trash_b = 0;
}
ctx->resync_marker = !get_bits1(gb); /* resync_marker_disabled */
s->data_partitioning = get_bits1(gb);
if (s->data_partitioning)
ctx->rvlc = get_bits1(gb);
if (vo_ver_id != 1) {
ctx->new_pred = get_bits1(gb);
if (ctx->new_pred) {
av_log(s->avctx, AV_LOG_ERROR, "new pred not supported\n");
skip_bits(gb, 2); /* requested upstream message type */
skip_bits1(gb); /* newpred segment type */
}
if (get_bits1(gb)) // reduced_res_vop
av_log(s->avctx, AV_LOG_ERROR,
"reduced resolution VOP not supported\n");
} else {
ctx->new_pred = 0;
}
ctx->scalability = get_bits1(gb);
if (ctx->scalability) {
GetBitContext bak = *gb;
int h_sampling_factor_n;
int h_sampling_factor_m;
int v_sampling_factor_n;
int v_sampling_factor_m;
skip_bits1(gb); // hierarchy_type
skip_bits(gb, 4); /* ref_layer_id */
skip_bits1(gb); /* ref_layer_sampling_dir */
h_sampling_factor_n = get_bits(gb, 5);
h_sampling_factor_m = get_bits(gb, 5);
v_sampling_factor_n = get_bits(gb, 5);
v_sampling_factor_m = get_bits(gb, 5);
ctx->enhancement_type = get_bits1(gb);
if (h_sampling_factor_n == 0 || h_sampling_factor_m == 0 ||
v_sampling_factor_n == 0 || v_sampling_factor_m == 0) {
/* illegal scalability header (VERY broken encoder),
* trying to workaround */
ctx->scalability = 0;
*gb = bak;
} else
av_log(s->avctx, AV_LOG_ERROR, "scalability not supported\n");
// bin shape stuff FIXME
}
}
if (s->avctx->debug&FF_DEBUG_PICT_INFO) {
av_log(s->avctx, AV_LOG_DEBUG, "tb %d/%d, tincrbits:%d, qp_prec:%d, ps:%d, %s%s%s%s\n",
s->avctx->framerate.den, s->avctx->framerate.num,
ctx->time_increment_bits,
s->quant_precision,
s->progressive_sequence,
ctx->scalability ? "scalability " :"" , s->quarter_sample ? "qpel " : "",
s->data_partitioning ? "partition " : "", ctx->rvlc ? "rvlc " : ""
);
}
return 0;
}
| false | FFmpeg | 9a0f60a0f89a7a71839dfa9def5a26f2037aed62 | static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
{
MpegEncContext *s = &ctx->m;
int width, height, vo_ver_id;
skip_bits(gb, 1);
s->vo_type = get_bits(gb, 8);
if (get_bits1(gb) != 0) {
vo_ver_id = get_bits(gb, 4);
skip_bits(gb, 3);
} else {
vo_ver_id = 1;
}
s->aspect_ratio_info = get_bits(gb, 4);
if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) {
s->avctx->sample_aspect_ratio.num = get_bits(gb, 8);
s->avctx->sample_aspect_ratio.den = get_bits(gb, 8);
} else {
s->avctx->sample_aspect_ratio = ff_h263_pixel_aspect[s->aspect_ratio_info];
}
if ((ctx->vol_control_parameters = get_bits1(gb))) {
int chroma_format = get_bits(gb, 2);
if (chroma_format != CHROMA_420)
av_log(s->avctx, AV_LOG_ERROR, "illegal chroma format\n");
s->low_delay = get_bits1(gb);
if (get_bits1(gb)) {
get_bits(gb, 15);
skip_bits1(gb);
get_bits(gb, 15);
skip_bits1(gb);
get_bits(gb, 15);
skip_bits1(gb);
get_bits(gb, 3);
get_bits(gb, 11);
skip_bits1(gb);
get_bits(gb, 15);
skip_bits1(gb);
}
} else {
if (s->picture_number == 0)
s->low_delay = 0;
}
ctx->shape = get_bits(gb, 2);
if (ctx->shape != RECT_SHAPE)
av_log(s->avctx, AV_LOG_ERROR, "only rectangular vol supported\n");
if (ctx->shape == GRAY_SHAPE && vo_ver_id != 1) {
av_log(s->avctx, AV_LOG_ERROR, "Gray shape not supported\n");
skip_bits(gb, 4);
}
check_marker(gb, "before time_increment_resolution");
s->avctx->framerate.num = get_bits(gb, 16);
if (!s->avctx->framerate.num) {
av_log(s->avctx, AV_LOG_ERROR, "framerate==0\n");
return AVERROR_INVALIDDATA;
}
ctx->time_increment_bits = av_log2(s->avctx->framerate.num - 1) + 1;
if (ctx->time_increment_bits < 1)
ctx->time_increment_bits = 1;
check_marker(gb, "before fixed_vop_rate");
if (get_bits1(gb) != 0)
s->avctx->framerate.den = get_bits(gb, ctx->time_increment_bits);
else
s->avctx->framerate.den = 1;
s->avctx->time_base = av_inv_q(av_mul_q(s->avctx->framerate, (AVRational){s->avctx->ticks_per_frame, 1}));
ctx->t_frame = 0;
if (ctx->shape != BIN_ONLY_SHAPE) {
if (ctx->shape == RECT_SHAPE) {
check_marker(gb, "before width");
width = get_bits(gb, 13);
check_marker(gb, "before height");
height = get_bits(gb, 13);
check_marker(gb, "after height");
if (width && height &&
!(s->width && s->codec_tag == AV_RL32("MP4S"))) {
if (s->width && s->height &&
(s->width != width || s->height != height))
s->context_reinit = 1;
s->width = width;
s->height = height;
}
}
s->progressive_sequence =
s->progressive_frame = get_bits1(gb) ^ 1;
s->interlaced_dct = 0;
if (!get_bits1(gb) && (s->avctx->debug & FF_DEBUG_PICT_INFO))
av_log(s->avctx, AV_LOG_INFO,
"MPEG4 OBMC not supported (very likely buggy encoder)\n");
if (vo_ver_id == 1)
ctx->vol_sprite_usage = get_bits1(gb);
else
ctx->vol_sprite_usage = get_bits(gb, 2);
if (ctx->vol_sprite_usage == STATIC_SPRITE)
av_log(s->avctx, AV_LOG_ERROR, "Static Sprites not supported\n");
if (ctx->vol_sprite_usage == STATIC_SPRITE ||
ctx->vol_sprite_usage == GMC_SPRITE) {
if (ctx->vol_sprite_usage == STATIC_SPRITE) {
skip_bits(gb, 13);
skip_bits1(gb);
skip_bits(gb, 13);
skip_bits1(gb);
skip_bits(gb, 13);
skip_bits1(gb);
skip_bits(gb, 13);
skip_bits1(gb);
}
ctx->num_sprite_warping_points = get_bits(gb, 6);
if (ctx->num_sprite_warping_points > 3) {
av_log(s->avctx, AV_LOG_ERROR,
"%d sprite_warping_points\n",
ctx->num_sprite_warping_points);
ctx->num_sprite_warping_points = 0;
return AVERROR_INVALIDDATA;
}
s->sprite_warping_accuracy = get_bits(gb, 2);
ctx->sprite_brightness_change = get_bits1(gb);
if (ctx->vol_sprite_usage == STATIC_SPRITE)
skip_bits1(gb);
}
if (get_bits1(gb) == 1) {
s->quant_precision = get_bits(gb, 4);
if (get_bits(gb, 4) != 8)
av_log(s->avctx, AV_LOG_ERROR, "N-bit not supported\n");
if (s->quant_precision != 5)
av_log(s->avctx, AV_LOG_ERROR,
"quant precision %d\n", s->quant_precision);
if (s->quant_precision<3 || s->quant_precision>9) {
s->quant_precision = 5;
}
} else {
s->quant_precision = 5;
}
if ((s->mpeg_quant = get_bits1(gb))) {
int i, v;
for (i = 0; i < 64; i++) {
int j = s->idsp.idct_permutation[i];
v = ff_mpeg4_default_intra_matrix[i];
s->intra_matrix[j] = v;
s->chroma_intra_matrix[j] = v;
v = ff_mpeg4_default_non_intra_matrix[i];
s->inter_matrix[j] = v;
s->chroma_inter_matrix[j] = v;
}
if (get_bits1(gb)) {
int last = 0;
for (i = 0; i < 64; i++) {
int j;
v = get_bits(gb, 8);
if (v == 0)
break;
last = v;
j = s->idsp.idct_permutation[ff_zigzag_direct[i]];
s->intra_matrix[j] = last;
s->chroma_intra_matrix[j] = last;
}
for (; i < 64; i++) {
int j = s->idsp.idct_permutation[ff_zigzag_direct[i]];
s->intra_matrix[j] = last;
s->chroma_intra_matrix[j] = last;
}
}
if (get_bits1(gb)) {
int last = 0;
for (i = 0; i < 64; i++) {
int j;
v = get_bits(gb, 8);
if (v == 0)
break;
last = v;
j = s->idsp.idct_permutation[ff_zigzag_direct[i]];
s->inter_matrix[j] = v;
s->chroma_inter_matrix[j] = v;
}
for (; i < 64; i++) {
int j = s->idsp.idct_permutation[ff_zigzag_direct[i]];
s->inter_matrix[j] = last;
s->chroma_inter_matrix[j] = last;
}
}
}
if (vo_ver_id != 1)
s->quarter_sample = get_bits1(gb);
else
s->quarter_sample = 0;
if (get_bits_left(gb) < 4) {
av_log(s->avctx, AV_LOG_ERROR, "VOL Header truncated\n");
return AVERROR_INVALIDDATA;
}
if (!get_bits1(gb)) {
int pos = get_bits_count(gb);
int estimation_method = get_bits(gb, 2);
if (estimation_method < 2) {
if (!get_bits1(gb)) {
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb);
}
if (!get_bits1(gb)) {
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb);
}
if (!check_marker(gb, "in complexity estimation part 1")) {
skip_bits_long(gb, pos - get_bits_count(gb));
goto no_cplx_est;
}
if (!get_bits1(gb)) {
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_i += 4 * get_bits1(gb);
}
if (!get_bits1(gb)) {
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_b += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb);
}
if (!check_marker(gb, "in complexity estimation part 2")) {
skip_bits_long(gb, pos - get_bits_count(gb));
goto no_cplx_est;
}
if (estimation_method == 1) {
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb);
}
} else
av_log(s->avctx, AV_LOG_ERROR,
"Invalid Complexity estimation method %d\n",
estimation_method);
} else {
no_cplx_est:
ctx->cplx_estimation_trash_i =
ctx->cplx_estimation_trash_p =
ctx->cplx_estimation_trash_b = 0;
}
ctx->resync_marker = !get_bits1(gb);
s->data_partitioning = get_bits1(gb);
if (s->data_partitioning)
ctx->rvlc = get_bits1(gb);
if (vo_ver_id != 1) {
ctx->new_pred = get_bits1(gb);
if (ctx->new_pred) {
av_log(s->avctx, AV_LOG_ERROR, "new pred not supported\n");
skip_bits(gb, 2);
skip_bits1(gb);
}
if (get_bits1(gb))
av_log(s->avctx, AV_LOG_ERROR,
"reduced resolution VOP not supported\n");
} else {
ctx->new_pred = 0;
}
ctx->scalability = get_bits1(gb);
if (ctx->scalability) {
GetBitContext bak = *gb;
int h_sampling_factor_n;
int h_sampling_factor_m;
int v_sampling_factor_n;
int v_sampling_factor_m;
skip_bits1(gb);
skip_bits(gb, 4);
skip_bits1(gb);
h_sampling_factor_n = get_bits(gb, 5);
h_sampling_factor_m = get_bits(gb, 5);
v_sampling_factor_n = get_bits(gb, 5);
v_sampling_factor_m = get_bits(gb, 5);
ctx->enhancement_type = get_bits1(gb);
if (h_sampling_factor_n == 0 || h_sampling_factor_m == 0 ||
v_sampling_factor_n == 0 || v_sampling_factor_m == 0) {
ctx->scalability = 0;
*gb = bak;
} else
av_log(s->avctx, AV_LOG_ERROR, "scalability not supported\n");
}
}
if (s->avctx->debug&FF_DEBUG_PICT_INFO) {
av_log(s->avctx, AV_LOG_DEBUG, "tb %d/%d, tincrbits:%d, qp_prec:%d, ps:%d, %s%s%s%s\n",
s->avctx->framerate.den, s->avctx->framerate.num,
ctx->time_increment_bits,
s->quant_precision,
s->progressive_sequence,
ctx->scalability ? "scalability " :"" , s->quarter_sample ? "qpel " : "",
s->data_partitioning ? "partition " : "", ctx->rvlc ? "rvlc " : ""
);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(Mpeg4DecContext *VAR_0, GetBitContext *VAR_1)
{
MpegEncContext *s = &VAR_0->m;
int VAR_2, VAR_3, VAR_4;
skip_bits(VAR_1, 1);
s->vo_type = get_bits(VAR_1, 8);
if (get_bits1(VAR_1) != 0) {
VAR_4 = get_bits(VAR_1, 4);
skip_bits(VAR_1, 3);
} else {
VAR_4 = 1;
}
s->aspect_ratio_info = get_bits(VAR_1, 4);
if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) {
s->avctx->sample_aspect_ratio.num = get_bits(VAR_1, 8);
s->avctx->sample_aspect_ratio.den = get_bits(VAR_1, 8);
} else {
s->avctx->sample_aspect_ratio = ff_h263_pixel_aspect[s->aspect_ratio_info];
}
if ((VAR_0->vol_control_parameters = get_bits1(VAR_1))) {
int VAR_5 = get_bits(VAR_1, 2);
if (VAR_5 != CHROMA_420)
av_log(s->avctx, AV_LOG_ERROR, "illegal chroma format\n");
s->low_delay = get_bits1(VAR_1);
if (get_bits1(VAR_1)) {
get_bits(VAR_1, 15);
skip_bits1(VAR_1);
get_bits(VAR_1, 15);
skip_bits1(VAR_1);
get_bits(VAR_1, 15);
skip_bits1(VAR_1);
get_bits(VAR_1, 3);
get_bits(VAR_1, 11);
skip_bits1(VAR_1);
get_bits(VAR_1, 15);
skip_bits1(VAR_1);
}
} else {
if (s->picture_number == 0)
s->low_delay = 0;
}
VAR_0->shape = get_bits(VAR_1, 2);
if (VAR_0->shape != RECT_SHAPE)
av_log(s->avctx, AV_LOG_ERROR, "only rectangular vol supported\n");
if (VAR_0->shape == GRAY_SHAPE && VAR_4 != 1) {
av_log(s->avctx, AV_LOG_ERROR, "Gray shape not supported\n");
skip_bits(VAR_1, 4);
}
check_marker(VAR_1, "before time_increment_resolution");
s->avctx->framerate.num = get_bits(VAR_1, 16);
if (!s->avctx->framerate.num) {
av_log(s->avctx, AV_LOG_ERROR, "framerate==0\n");
return AVERROR_INVALIDDATA;
}
VAR_0->time_increment_bits = av_log2(s->avctx->framerate.num - 1) + 1;
if (VAR_0->time_increment_bits < 1)
VAR_0->time_increment_bits = 1;
check_marker(VAR_1, "before fixed_vop_rate");
if (get_bits1(VAR_1) != 0)
s->avctx->framerate.den = get_bits(VAR_1, VAR_0->time_increment_bits);
else
s->avctx->framerate.den = 1;
s->avctx->time_base = av_inv_q(av_mul_q(s->avctx->framerate, (AVRational){s->avctx->ticks_per_frame, 1}));
VAR_0->t_frame = 0;
if (VAR_0->shape != BIN_ONLY_SHAPE) {
if (VAR_0->shape == RECT_SHAPE) {
check_marker(VAR_1, "before VAR_2");
VAR_2 = get_bits(VAR_1, 13);
check_marker(VAR_1, "before VAR_3");
VAR_3 = get_bits(VAR_1, 13);
check_marker(VAR_1, "after VAR_3");
if (VAR_2 && VAR_3 &&
!(s->VAR_2 && s->codec_tag == AV_RL32("MP4S"))) {
if (s->VAR_2 && s->VAR_3 &&
(s->VAR_2 != VAR_2 || s->VAR_3 != VAR_3))
s->context_reinit = 1;
s->VAR_2 = VAR_2;
s->VAR_3 = VAR_3;
}
}
s->progressive_sequence =
s->progressive_frame = get_bits1(VAR_1) ^ 1;
s->interlaced_dct = 0;
if (!get_bits1(VAR_1) && (s->avctx->debug & FF_DEBUG_PICT_INFO))
av_log(s->avctx, AV_LOG_INFO,
"MPEG4 OBMC not supported (very likely buggy encoder)\n");
if (VAR_4 == 1)
VAR_0->vol_sprite_usage = get_bits1(VAR_1);
else
VAR_0->vol_sprite_usage = get_bits(VAR_1, 2);
if (VAR_0->vol_sprite_usage == STATIC_SPRITE)
av_log(s->avctx, AV_LOG_ERROR, "Static Sprites not supported\n");
if (VAR_0->vol_sprite_usage == STATIC_SPRITE ||
VAR_0->vol_sprite_usage == GMC_SPRITE) {
if (VAR_0->vol_sprite_usage == STATIC_SPRITE) {
skip_bits(VAR_1, 13);
skip_bits1(VAR_1);
skip_bits(VAR_1, 13);
skip_bits1(VAR_1);
skip_bits(VAR_1, 13);
skip_bits1(VAR_1);
skip_bits(VAR_1, 13);
skip_bits1(VAR_1);
}
VAR_0->num_sprite_warping_points = get_bits(VAR_1, 6);
if (VAR_0->num_sprite_warping_points > 3) {
av_log(s->avctx, AV_LOG_ERROR,
"%d sprite_warping_points\n",
VAR_0->num_sprite_warping_points);
VAR_0->num_sprite_warping_points = 0;
return AVERROR_INVALIDDATA;
}
s->sprite_warping_accuracy = get_bits(VAR_1, 2);
VAR_0->sprite_brightness_change = get_bits1(VAR_1);
if (VAR_0->vol_sprite_usage == STATIC_SPRITE)
skip_bits1(VAR_1);
}
if (get_bits1(VAR_1) == 1) {
s->quant_precision = get_bits(VAR_1, 4);
if (get_bits(VAR_1, 4) != 8)
av_log(s->avctx, AV_LOG_ERROR, "N-bit not supported\n");
if (s->quant_precision != 5)
av_log(s->avctx, AV_LOG_ERROR,
"quant precision %d\n", s->quant_precision);
if (s->quant_precision<3 || s->quant_precision>9) {
s->quant_precision = 5;
}
} else {
s->quant_precision = 5;
}
if ((s->mpeg_quant = get_bits1(VAR_1))) {
int VAR_6, VAR_7;
for (VAR_6 = 0; VAR_6 < 64; VAR_6++) {
int VAR_10 = s->idsp.idct_permutation[VAR_6];
VAR_7 = ff_mpeg4_default_intra_matrix[VAR_6];
s->intra_matrix[VAR_10] = VAR_7;
s->chroma_intra_matrix[VAR_10] = VAR_7;
VAR_7 = ff_mpeg4_default_non_intra_matrix[VAR_6];
s->inter_matrix[VAR_10] = VAR_7;
s->chroma_inter_matrix[VAR_10] = VAR_7;
}
if (get_bits1(VAR_1)) {
int VAR_10 = 0;
for (VAR_6 = 0; VAR_6 < 64; VAR_6++) {
int VAR_10;
VAR_7 = get_bits(VAR_1, 8);
if (VAR_7 == 0)
break;
VAR_10 = VAR_7;
VAR_10 = s->idsp.idct_permutation[ff_zigzag_direct[VAR_6]];
s->intra_matrix[VAR_10] = VAR_10;
s->chroma_intra_matrix[VAR_10] = VAR_10;
}
for (; VAR_6 < 64; VAR_6++) {
int VAR_10 = s->idsp.idct_permutation[ff_zigzag_direct[VAR_6]];
s->intra_matrix[VAR_10] = VAR_10;
s->chroma_intra_matrix[VAR_10] = VAR_10;
}
}
if (get_bits1(VAR_1)) {
int VAR_10 = 0;
for (VAR_6 = 0; VAR_6 < 64; VAR_6++) {
int VAR_10;
VAR_7 = get_bits(VAR_1, 8);
if (VAR_7 == 0)
break;
VAR_10 = VAR_7;
VAR_10 = s->idsp.idct_permutation[ff_zigzag_direct[VAR_6]];
s->inter_matrix[VAR_10] = VAR_7;
s->chroma_inter_matrix[VAR_10] = VAR_7;
}
for (; VAR_6 < 64; VAR_6++) {
int VAR_10 = s->idsp.idct_permutation[ff_zigzag_direct[VAR_6]];
s->inter_matrix[VAR_10] = VAR_10;
s->chroma_inter_matrix[VAR_10] = VAR_10;
}
}
}
if (VAR_4 != 1)
s->quarter_sample = get_bits1(VAR_1);
else
s->quarter_sample = 0;
if (get_bits_left(VAR_1) < 4) {
av_log(s->avctx, AV_LOG_ERROR, "VOL Header truncated\n");
return AVERROR_INVALIDDATA;
}
if (!get_bits1(VAR_1)) {
int VAR_10 = get_bits_count(VAR_1);
int VAR_11 = get_bits(VAR_1, 2);
if (VAR_11 < 2) {
if (!get_bits1(VAR_1)) {
VAR_0->cplx_estimation_trash_i += 8 * get_bits1(VAR_1);
VAR_0->cplx_estimation_trash_i += 8 * get_bits1(VAR_1);
VAR_0->cplx_estimation_trash_i += 8 * get_bits1(VAR_1);
VAR_0->cplx_estimation_trash_i += 8 * get_bits1(VAR_1);
VAR_0->cplx_estimation_trash_i += 8 * get_bits1(VAR_1);
VAR_0->cplx_estimation_trash_i += 8 * get_bits1(VAR_1);
}
if (!get_bits1(VAR_1)) {
VAR_0->cplx_estimation_trash_i += 8 * get_bits1(VAR_1);
VAR_0->cplx_estimation_trash_p += 8 * get_bits1(VAR_1);
VAR_0->cplx_estimation_trash_p += 8 * get_bits1(VAR_1);
VAR_0->cplx_estimation_trash_i += 8 * get_bits1(VAR_1);
}
if (!check_marker(VAR_1, "in complexity estimation part 1")) {
skip_bits_long(VAR_1, VAR_10 - get_bits_count(VAR_1));
goto no_cplx_est;
}
if (!get_bits1(VAR_1)) {
VAR_0->cplx_estimation_trash_i += 8 * get_bits1(VAR_1);
VAR_0->cplx_estimation_trash_i += 8 * get_bits1(VAR_1);
VAR_0->cplx_estimation_trash_i += 8 * get_bits1(VAR_1);
VAR_0->cplx_estimation_trash_i += 4 * get_bits1(VAR_1);
}
if (!get_bits1(VAR_1)) {
VAR_0->cplx_estimation_trash_p += 8 * get_bits1(VAR_1);
VAR_0->cplx_estimation_trash_p += 8 * get_bits1(VAR_1);
VAR_0->cplx_estimation_trash_b += 8 * get_bits1(VAR_1);
VAR_0->cplx_estimation_trash_p += 8 * get_bits1(VAR_1);
VAR_0->cplx_estimation_trash_p += 8 * get_bits1(VAR_1);
VAR_0->cplx_estimation_trash_p += 8 * get_bits1(VAR_1);
}
if (!check_marker(VAR_1, "in complexity estimation part 2")) {
skip_bits_long(VAR_1, VAR_10 - get_bits_count(VAR_1));
goto no_cplx_est;
}
if (VAR_11 == 1) {
VAR_0->cplx_estimation_trash_i += 8 * get_bits1(VAR_1);
VAR_0->cplx_estimation_trash_p += 8 * get_bits1(VAR_1);
}
} else
av_log(s->avctx, AV_LOG_ERROR,
"Invalid Complexity estimation method %d\n",
VAR_11);
} else {
no_cplx_est:
VAR_0->cplx_estimation_trash_i =
VAR_0->cplx_estimation_trash_p =
VAR_0->cplx_estimation_trash_b = 0;
}
VAR_0->resync_marker = !get_bits1(VAR_1);
s->data_partitioning = get_bits1(VAR_1);
if (s->data_partitioning)
VAR_0->rvlc = get_bits1(VAR_1);
if (VAR_4 != 1) {
VAR_0->new_pred = get_bits1(VAR_1);
if (VAR_0->new_pred) {
av_log(s->avctx, AV_LOG_ERROR, "new pred not supported\n");
skip_bits(VAR_1, 2);
skip_bits1(VAR_1);
}
if (get_bits1(VAR_1))
av_log(s->avctx, AV_LOG_ERROR,
"reduced resolution VOP not supported\n");
} else {
VAR_0->new_pred = 0;
}
VAR_0->scalability = get_bits1(VAR_1);
if (VAR_0->scalability) {
GetBitContext bak = *VAR_1;
int VAR_12;
int VAR_13;
int VAR_14;
int VAR_15;
skip_bits1(VAR_1);
skip_bits(VAR_1, 4);
skip_bits1(VAR_1);
VAR_12 = get_bits(VAR_1, 5);
VAR_13 = get_bits(VAR_1, 5);
VAR_14 = get_bits(VAR_1, 5);
VAR_15 = get_bits(VAR_1, 5);
VAR_0->enhancement_type = get_bits1(VAR_1);
if (VAR_12 == 0 || VAR_13 == 0 ||
VAR_14 == 0 || VAR_15 == 0) {
VAR_0->scalability = 0;
*VAR_1 = bak;
} else
av_log(s->avctx, AV_LOG_ERROR, "scalability not supported\n");
}
}
if (s->avctx->debug&FF_DEBUG_PICT_INFO) {
av_log(s->avctx, AV_LOG_DEBUG, "tb %d/%d, tincrbits:%d, qp_prec:%d, ps:%d, %s%s%s%s\n",
s->avctx->framerate.den, s->avctx->framerate.num,
VAR_0->time_increment_bits,
s->quant_precision,
s->progressive_sequence,
VAR_0->scalability ? "scalability " :"" , s->quarter_sample ? "qpel " : "",
s->data_partitioning ? "partition " : "", VAR_0->rvlc ? "rvlc " : ""
);
}
return 0;
}
| [
"static int FUNC_0(Mpeg4DecContext *VAR_0, GetBitContext *VAR_1)\n{",
"MpegEncContext *s = &VAR_0->m;",
"int VAR_2, VAR_3, VAR_4;",
"skip_bits(VAR_1, 1);",
"s->vo_type = get_bits(VAR_1, 8);",
"if (get_bits1(VAR_1) != 0) {",
"VAR_4 = get_bits(VAR_1, 4);",
"skip_bits(VAR_1, 3);",
"} else {",
"VAR_4 = 1;",
"}",
"s->aspect_ratio_info = get_bits(VAR_1, 4);",
"if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) {",
"s->avctx->sample_aspect_ratio.num = get_bits(VAR_1, 8);",
"s->avctx->sample_aspect_ratio.den = get_bits(VAR_1, 8);",
"} else {",
"s->avctx->sample_aspect_ratio = ff_h263_pixel_aspect[s->aspect_ratio_info];",
"}",
"if ((VAR_0->vol_control_parameters = get_bits1(VAR_1))) {",
"int VAR_5 = get_bits(VAR_1, 2);",
"if (VAR_5 != CHROMA_420)\nav_log(s->avctx, AV_LOG_ERROR, \"illegal chroma format\\n\");",
"s->low_delay = get_bits1(VAR_1);",
"if (get_bits1(VAR_1)) {",
"get_bits(VAR_1, 15);",
"skip_bits1(VAR_1);",
"get_bits(VAR_1, 15);",
"skip_bits1(VAR_1);",
"get_bits(VAR_1, 15);",
"skip_bits1(VAR_1);",
"get_bits(VAR_1, 3);",
"get_bits(VAR_1, 11);",
"skip_bits1(VAR_1);",
"get_bits(VAR_1, 15);",
"skip_bits1(VAR_1);",
"}",
"} else {",
"if (s->picture_number == 0)\ns->low_delay = 0;",
"}",
"VAR_0->shape = get_bits(VAR_1, 2);",
"if (VAR_0->shape != RECT_SHAPE)\nav_log(s->avctx, AV_LOG_ERROR, \"only rectangular vol supported\\n\");",
"if (VAR_0->shape == GRAY_SHAPE && VAR_4 != 1) {",
"av_log(s->avctx, AV_LOG_ERROR, \"Gray shape not supported\\n\");",
"skip_bits(VAR_1, 4);",
"}",
"check_marker(VAR_1, \"before time_increment_resolution\");",
"s->avctx->framerate.num = get_bits(VAR_1, 16);",
"if (!s->avctx->framerate.num) {",
"av_log(s->avctx, AV_LOG_ERROR, \"framerate==0\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_0->time_increment_bits = av_log2(s->avctx->framerate.num - 1) + 1;",
"if (VAR_0->time_increment_bits < 1)\nVAR_0->time_increment_bits = 1;",
"check_marker(VAR_1, \"before fixed_vop_rate\");",
"if (get_bits1(VAR_1) != 0)\ns->avctx->framerate.den = get_bits(VAR_1, VAR_0->time_increment_bits);",
"else\ns->avctx->framerate.den = 1;",
"s->avctx->time_base = av_inv_q(av_mul_q(s->avctx->framerate, (AVRational){s->avctx->ticks_per_frame, 1}));",
"VAR_0->t_frame = 0;",
"if (VAR_0->shape != BIN_ONLY_SHAPE) {",
"if (VAR_0->shape == RECT_SHAPE) {",
"check_marker(VAR_1, \"before VAR_2\");",
"VAR_2 = get_bits(VAR_1, 13);",
"check_marker(VAR_1, \"before VAR_3\");",
"VAR_3 = get_bits(VAR_1, 13);",
"check_marker(VAR_1, \"after VAR_3\");",
"if (VAR_2 && VAR_3 &&\n!(s->VAR_2 && s->codec_tag == AV_RL32(\"MP4S\"))) {",
"if (s->VAR_2 && s->VAR_3 &&\n(s->VAR_2 != VAR_2 || s->VAR_3 != VAR_3))\ns->context_reinit = 1;",
"s->VAR_2 = VAR_2;",
"s->VAR_3 = VAR_3;",
"}",
"}",
"s->progressive_sequence =\ns->progressive_frame = get_bits1(VAR_1) ^ 1;",
"s->interlaced_dct = 0;",
"if (!get_bits1(VAR_1) && (s->avctx->debug & FF_DEBUG_PICT_INFO))\nav_log(s->avctx, AV_LOG_INFO,\n\"MPEG4 OBMC not supported (very likely buggy encoder)\\n\");",
"if (VAR_4 == 1)\nVAR_0->vol_sprite_usage = get_bits1(VAR_1);",
"else\nVAR_0->vol_sprite_usage = get_bits(VAR_1, 2);",
"if (VAR_0->vol_sprite_usage == STATIC_SPRITE)\nav_log(s->avctx, AV_LOG_ERROR, \"Static Sprites not supported\\n\");",
"if (VAR_0->vol_sprite_usage == STATIC_SPRITE ||\nVAR_0->vol_sprite_usage == GMC_SPRITE) {",
"if (VAR_0->vol_sprite_usage == STATIC_SPRITE) {",
"skip_bits(VAR_1, 13);",
"skip_bits1(VAR_1);",
"skip_bits(VAR_1, 13);",
"skip_bits1(VAR_1);",
"skip_bits(VAR_1, 13);",
"skip_bits1(VAR_1);",
"skip_bits(VAR_1, 13);",
"skip_bits1(VAR_1);",
"}",
"VAR_0->num_sprite_warping_points = get_bits(VAR_1, 6);",
"if (VAR_0->num_sprite_warping_points > 3) {",
"av_log(s->avctx, AV_LOG_ERROR,\n\"%d sprite_warping_points\\n\",\nVAR_0->num_sprite_warping_points);",
"VAR_0->num_sprite_warping_points = 0;",
"return AVERROR_INVALIDDATA;",
"}",
"s->sprite_warping_accuracy = get_bits(VAR_1, 2);",
"VAR_0->sprite_brightness_change = get_bits1(VAR_1);",
"if (VAR_0->vol_sprite_usage == STATIC_SPRITE)\nskip_bits1(VAR_1);",
"}",
"if (get_bits1(VAR_1) == 1) {",
"s->quant_precision = get_bits(VAR_1, 4);",
"if (get_bits(VAR_1, 4) != 8)\nav_log(s->avctx, AV_LOG_ERROR, \"N-bit not supported\\n\");",
"if (s->quant_precision != 5)\nav_log(s->avctx, AV_LOG_ERROR,\n\"quant precision %d\\n\", s->quant_precision);",
"if (s->quant_precision<3 || s->quant_precision>9) {",
"s->quant_precision = 5;",
"}",
"} else {",
"s->quant_precision = 5;",
"}",
"if ((s->mpeg_quant = get_bits1(VAR_1))) {",
"int VAR_6, VAR_7;",
"for (VAR_6 = 0; VAR_6 < 64; VAR_6++) {",
"int VAR_10 = s->idsp.idct_permutation[VAR_6];",
"VAR_7 = ff_mpeg4_default_intra_matrix[VAR_6];",
"s->intra_matrix[VAR_10] = VAR_7;",
"s->chroma_intra_matrix[VAR_10] = VAR_7;",
"VAR_7 = ff_mpeg4_default_non_intra_matrix[VAR_6];",
"s->inter_matrix[VAR_10] = VAR_7;",
"s->chroma_inter_matrix[VAR_10] = VAR_7;",
"}",
"if (get_bits1(VAR_1)) {",
"int VAR_10 = 0;",
"for (VAR_6 = 0; VAR_6 < 64; VAR_6++) {",
"int VAR_10;",
"VAR_7 = get_bits(VAR_1, 8);",
"if (VAR_7 == 0)\nbreak;",
"VAR_10 = VAR_7;",
"VAR_10 = s->idsp.idct_permutation[ff_zigzag_direct[VAR_6]];",
"s->intra_matrix[VAR_10] = VAR_10;",
"s->chroma_intra_matrix[VAR_10] = VAR_10;",
"}",
"for (; VAR_6 < 64; VAR_6++) {",
"int VAR_10 = s->idsp.idct_permutation[ff_zigzag_direct[VAR_6]];",
"s->intra_matrix[VAR_10] = VAR_10;",
"s->chroma_intra_matrix[VAR_10] = VAR_10;",
"}",
"}",
"if (get_bits1(VAR_1)) {",
"int VAR_10 = 0;",
"for (VAR_6 = 0; VAR_6 < 64; VAR_6++) {",
"int VAR_10;",
"VAR_7 = get_bits(VAR_1, 8);",
"if (VAR_7 == 0)\nbreak;",
"VAR_10 = VAR_7;",
"VAR_10 = s->idsp.idct_permutation[ff_zigzag_direct[VAR_6]];",
"s->inter_matrix[VAR_10] = VAR_7;",
"s->chroma_inter_matrix[VAR_10] = VAR_7;",
"}",
"for (; VAR_6 < 64; VAR_6++) {",
"int VAR_10 = s->idsp.idct_permutation[ff_zigzag_direct[VAR_6]];",
"s->inter_matrix[VAR_10] = VAR_10;",
"s->chroma_inter_matrix[VAR_10] = VAR_10;",
"}",
"}",
"}",
"if (VAR_4 != 1)\ns->quarter_sample = get_bits1(VAR_1);",
"else\ns->quarter_sample = 0;",
"if (get_bits_left(VAR_1) < 4) {",
"av_log(s->avctx, AV_LOG_ERROR, \"VOL Header truncated\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (!get_bits1(VAR_1)) {",
"int VAR_10 = get_bits_count(VAR_1);",
"int VAR_11 = get_bits(VAR_1, 2);",
"if (VAR_11 < 2) {",
"if (!get_bits1(VAR_1)) {",
"VAR_0->cplx_estimation_trash_i += 8 * get_bits1(VAR_1);",
"VAR_0->cplx_estimation_trash_i += 8 * get_bits1(VAR_1);",
"VAR_0->cplx_estimation_trash_i += 8 * get_bits1(VAR_1);",
"VAR_0->cplx_estimation_trash_i += 8 * get_bits1(VAR_1);",
"VAR_0->cplx_estimation_trash_i += 8 * get_bits1(VAR_1);",
"VAR_0->cplx_estimation_trash_i += 8 * get_bits1(VAR_1);",
"}",
"if (!get_bits1(VAR_1)) {",
"VAR_0->cplx_estimation_trash_i += 8 * get_bits1(VAR_1);",
"VAR_0->cplx_estimation_trash_p += 8 * get_bits1(VAR_1);",
"VAR_0->cplx_estimation_trash_p += 8 * get_bits1(VAR_1);",
"VAR_0->cplx_estimation_trash_i += 8 * get_bits1(VAR_1);",
"}",
"if (!check_marker(VAR_1, \"in complexity estimation part 1\")) {",
"skip_bits_long(VAR_1, VAR_10 - get_bits_count(VAR_1));",
"goto no_cplx_est;",
"}",
"if (!get_bits1(VAR_1)) {",
"VAR_0->cplx_estimation_trash_i += 8 * get_bits1(VAR_1);",
"VAR_0->cplx_estimation_trash_i += 8 * get_bits1(VAR_1);",
"VAR_0->cplx_estimation_trash_i += 8 * get_bits1(VAR_1);",
"VAR_0->cplx_estimation_trash_i += 4 * get_bits1(VAR_1);",
"}",
"if (!get_bits1(VAR_1)) {",
"VAR_0->cplx_estimation_trash_p += 8 * get_bits1(VAR_1);",
"VAR_0->cplx_estimation_trash_p += 8 * get_bits1(VAR_1);",
"VAR_0->cplx_estimation_trash_b += 8 * get_bits1(VAR_1);",
"VAR_0->cplx_estimation_trash_p += 8 * get_bits1(VAR_1);",
"VAR_0->cplx_estimation_trash_p += 8 * get_bits1(VAR_1);",
"VAR_0->cplx_estimation_trash_p += 8 * get_bits1(VAR_1);",
"}",
"if (!check_marker(VAR_1, \"in complexity estimation part 2\")) {",
"skip_bits_long(VAR_1, VAR_10 - get_bits_count(VAR_1));",
"goto no_cplx_est;",
"}",
"if (VAR_11 == 1) {",
"VAR_0->cplx_estimation_trash_i += 8 * get_bits1(VAR_1);",
"VAR_0->cplx_estimation_trash_p += 8 * get_bits1(VAR_1);",
"}",
"} else",
"av_log(s->avctx, AV_LOG_ERROR,\n\"Invalid Complexity estimation method %d\\n\",\nVAR_11);",
"} else {",
"no_cplx_est:\nVAR_0->cplx_estimation_trash_i =\nVAR_0->cplx_estimation_trash_p =\nVAR_0->cplx_estimation_trash_b = 0;",
"}",
"VAR_0->resync_marker = !get_bits1(VAR_1);",
"s->data_partitioning = get_bits1(VAR_1);",
"if (s->data_partitioning)\nVAR_0->rvlc = get_bits1(VAR_1);",
"if (VAR_4 != 1) {",
"VAR_0->new_pred = get_bits1(VAR_1);",
"if (VAR_0->new_pred) {",
"av_log(s->avctx, AV_LOG_ERROR, \"new pred not supported\\n\");",
"skip_bits(VAR_1, 2);",
"skip_bits1(VAR_1);",
"}",
"if (get_bits1(VAR_1))\nav_log(s->avctx, AV_LOG_ERROR,\n\"reduced resolution VOP not supported\\n\");",
"} else {",
"VAR_0->new_pred = 0;",
"}",
"VAR_0->scalability = get_bits1(VAR_1);",
"if (VAR_0->scalability) {",
"GetBitContext bak = *VAR_1;",
"int VAR_12;",
"int VAR_13;",
"int VAR_14;",
"int VAR_15;",
"skip_bits1(VAR_1);",
"skip_bits(VAR_1, 4);",
"skip_bits1(VAR_1);",
"VAR_12 = get_bits(VAR_1, 5);",
"VAR_13 = get_bits(VAR_1, 5);",
"VAR_14 = get_bits(VAR_1, 5);",
"VAR_15 = get_bits(VAR_1, 5);",
"VAR_0->enhancement_type = get_bits1(VAR_1);",
"if (VAR_12 == 0 || VAR_13 == 0 ||\nVAR_14 == 0 || VAR_15 == 0) {",
"VAR_0->scalability = 0;",
"*VAR_1 = bak;",
"} else",
"av_log(s->avctx, AV_LOG_ERROR, \"scalability not supported\\n\");",
"}",
"}",
"if (s->avctx->debug&FF_DEBUG_PICT_INFO) {",
"av_log(s->avctx, AV_LOG_DEBUG, \"tb %d/%d, tincrbits:%d, qp_prec:%d, ps:%d, %s%s%s%s\\n\",\ns->avctx->framerate.den, s->avctx->framerate.num,\nVAR_0->time_increment_bits,\ns->quant_precision,\ns->progressive_sequence,\nVAR_0->scalability ? \"scalability \" :\"\" , s->quarter_sample ? \"qpel \" : \"\",\ns->data_partitioning ? \"partition \" : \"\", VAR_0->rvlc ? \"rvlc \" : \"\"\n);",
"}",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
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
],
[
89,
91
],
[
93
],
[
97
],
[
99,
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131,
133
],
[
137
],
[
141,
143
],
[
145,
147
],
[
151
],
[
155
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173,
175
],
[
177,
179,
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
193,
195
],
[
197
],
[
199,
201,
203
],
[
205,
207
],
[
209,
211
],
[
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
],
[
273
],
[
275
],
[
277,
279
],
[
281,
283,
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
305
],
[
307
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
325
],
[
327
],
[
329
],
[
331
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347,
349
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393,
395
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
423
],
[
429
],
[
433,
435
],
[
437,
439
],
[
443
],
[
445
],
[
447
],
[
449
],
[
453
],
[
455
],
[
457
],
[
459
],
[
461
],
[
463
],
[
465
],
[
467
],
[
469
],
[
471
],
[
473
],
[
475
],
[
477
],
[
479
],
[
481
],
[
483
],
[
485
],
[
487
],
[
489
],
[
491
],
[
493
],
[
495
],
[
497
],
[
499
],
[
501
],
[
503
],
[
505
],
[
507
],
[
509
],
[
511
],
[
513
],
[
515
],
[
517
],
[
519
],
[
521
],
[
523
],
[
525
],
[
527
],
[
529
],
[
531
],
[
533
],
[
535
],
[
537
],
[
539
],
[
541
],
[
543,
545,
547
],
[
549
],
[
553,
555,
557,
559
],
[
561
],
[
565
],
[
569
],
[
571,
573
],
[
577
],
[
579
],
[
581
],
[
583
],
[
585
],
[
587
],
[
589
],
[
591,
593,
595
],
[
597
],
[
599
],
[
601
],
[
605
],
[
609
],
[
611
],
[
613
],
[
615
],
[
617
],
[
619
],
[
623
],
[
625
],
[
627
],
[
629
],
[
631
],
[
633
],
[
635
],
[
637
],
[
641,
643
],
[
649
],
[
651
],
[
653
],
[
655
],
[
661
],
[
663
],
[
667
],
[
669,
671,
673,
675,
677,
679,
681,
683
],
[
685
],
[
689
],
[
691
]
] |
26,822 | static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt)
{
struct video_data *s = ctx->priv_data;
struct v4l2_buffer buf = {
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
.memory = V4L2_MEMORY_MMAP
};
struct pollfd p = { .fd = s->fd, .events = POLLIN };
int res;
res = poll(&p, 1, s->timeout);
if (res < 0)
return AVERROR(errno);
if (!(p.revents & (POLLIN | POLLERR | POLLHUP)))
return AVERROR(EAGAIN);
/* FIXME: Some special treatment might be needed in case of loss of signal... */
while ((res = ioctl(s->fd, VIDIOC_DQBUF, &buf)) < 0 && (errno == EINTR));
if (res < 0) {
if (errno == EAGAIN) {
pkt->size = 0;
return AVERROR(EAGAIN);
}
av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_DQBUF): %s\n",
strerror(errno));
return AVERROR(errno);
}
if (buf.index >= s->buffers) {
av_log(ctx, AV_LOG_ERROR, "Invalid buffer index received.\n");
return AVERROR(EINVAL);
}
avpriv_atomic_int_add_and_fetch(&s->buffers_queued, -1);
// always keep at least one buffer queued
av_assert0(avpriv_atomic_int_get(&s->buffers_queued) >= 1);
if (s->frame_size > 0 && buf.bytesused != s->frame_size) {
av_log(ctx, AV_LOG_ERROR,
"The v4l2 frame is %d bytes, but %d bytes are expected\n",
buf.bytesused, s->frame_size);
return AVERROR_INVALIDDATA;
}
/* Image is at s->buff_start[buf.index] */
if (avpriv_atomic_int_get(&s->buffers_queued) == FFMAX(s->buffers / 8, 1)) {
/* when we start getting low on queued buffers, fall back on copying data */
res = av_new_packet(pkt, buf.bytesused);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "Error allocating a packet.\n");
return res;
}
memcpy(pkt->data, s->buf_start[buf.index], buf.bytesused);
res = ioctl(s->fd, VIDIOC_QBUF, &buf);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_QBUF)\n");
av_free_packet(pkt);
return AVERROR(errno);
}
avpriv_atomic_int_add_and_fetch(&s->buffers_queued, 1);
} else {
struct buff_data *buf_descriptor;
pkt->data = s->buf_start[buf.index];
pkt->size = buf.bytesused;
#if FF_API_DESTRUCT_PACKET
FF_DISABLE_DEPRECATION_WARNINGS
pkt->destruct = dummy_release_buffer;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
buf_descriptor = av_malloc(sizeof(struct buff_data));
if (buf_descriptor == NULL) {
/* Something went wrong... Since av_malloc() failed, we cannot even
* allocate a buffer for memcpying into it
*/
av_log(ctx, AV_LOG_ERROR, "Failed to allocate a buffer descriptor\n");
res = ioctl(s->fd, VIDIOC_QBUF, &buf);
return AVERROR(ENOMEM);
}
buf_descriptor->fd = s->fd;
buf_descriptor->index = buf.index;
buf_descriptor->s = s;
pkt->buf = av_buffer_create(pkt->data, pkt->size, mmap_release_buffer,
buf_descriptor, 0);
if (!pkt->buf) {
av_freep(&buf_descriptor);
return AVERROR(ENOMEM);
}
}
pkt->pts = buf.timestamp.tv_sec * INT64_C(1000000) + buf.timestamp.tv_usec;
return s->buf_len[buf.index];
}
| false | FFmpeg | f929ab0569ff31ed5a59b0b0adb7ce09df3fca39 | static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt)
{
struct video_data *s = ctx->priv_data;
struct v4l2_buffer buf = {
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
.memory = V4L2_MEMORY_MMAP
};
struct pollfd p = { .fd = s->fd, .events = POLLIN };
int res;
res = poll(&p, 1, s->timeout);
if (res < 0)
return AVERROR(errno);
if (!(p.revents & (POLLIN | POLLERR | POLLHUP)))
return AVERROR(EAGAIN);
while ((res = ioctl(s->fd, VIDIOC_DQBUF, &buf)) < 0 && (errno == EINTR));
if (res < 0) {
if (errno == EAGAIN) {
pkt->size = 0;
return AVERROR(EAGAIN);
}
av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_DQBUF): %s\n",
strerror(errno));
return AVERROR(errno);
}
if (buf.index >= s->buffers) {
av_log(ctx, AV_LOG_ERROR, "Invalid buffer index received.\n");
return AVERROR(EINVAL);
}
avpriv_atomic_int_add_and_fetch(&s->buffers_queued, -1);
av_assert0(avpriv_atomic_int_get(&s->buffers_queued) >= 1);
if (s->frame_size > 0 && buf.bytesused != s->frame_size) {
av_log(ctx, AV_LOG_ERROR,
"The v4l2 frame is %d bytes, but %d bytes are expected\n",
buf.bytesused, s->frame_size);
return AVERROR_INVALIDDATA;
}
if (avpriv_atomic_int_get(&s->buffers_queued) == FFMAX(s->buffers / 8, 1)) {
res = av_new_packet(pkt, buf.bytesused);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "Error allocating a packet.\n");
return res;
}
memcpy(pkt->data, s->buf_start[buf.index], buf.bytesused);
res = ioctl(s->fd, VIDIOC_QBUF, &buf);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_QBUF)\n");
av_free_packet(pkt);
return AVERROR(errno);
}
avpriv_atomic_int_add_and_fetch(&s->buffers_queued, 1);
} else {
struct buff_data *buf_descriptor;
pkt->data = s->buf_start[buf.index];
pkt->size = buf.bytesused;
#if FF_API_DESTRUCT_PACKET
FF_DISABLE_DEPRECATION_WARNINGS
pkt->destruct = dummy_release_buffer;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
buf_descriptor = av_malloc(sizeof(struct buff_data));
if (buf_descriptor == NULL) {
av_log(ctx, AV_LOG_ERROR, "Failed to allocate a buffer descriptor\n");
res = ioctl(s->fd, VIDIOC_QBUF, &buf);
return AVERROR(ENOMEM);
}
buf_descriptor->fd = s->fd;
buf_descriptor->index = buf.index;
buf_descriptor->s = s;
pkt->buf = av_buffer_create(pkt->data, pkt->size, mmap_release_buffer,
buf_descriptor, 0);
if (!pkt->buf) {
av_freep(&buf_descriptor);
return AVERROR(ENOMEM);
}
}
pkt->pts = buf.timestamp.tv_sec * INT64_C(1000000) + buf.timestamp.tv_usec;
return s->buf_len[buf.index];
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{
struct video_data *VAR_2 = VAR_0->priv_data;
struct v4l2_buffer VAR_3 = {
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
.memory = V4L2_MEMORY_MMAP
};
struct pollfd VAR_4 = { .fd = VAR_2->fd, .events = POLLIN };
int VAR_5;
VAR_5 = poll(&VAR_4, 1, VAR_2->timeout);
if (VAR_5 < 0)
return AVERROR(errno);
if (!(VAR_4.revents & (POLLIN | POLLERR | POLLHUP)))
return AVERROR(EAGAIN);
while ((VAR_5 = ioctl(VAR_2->fd, VIDIOC_DQBUF, &VAR_3)) < 0 && (errno == EINTR));
if (VAR_5 < 0) {
if (errno == EAGAIN) {
VAR_1->size = 0;
return AVERROR(EAGAIN);
}
av_log(VAR_0, AV_LOG_ERROR, "ioctl(VIDIOC_DQBUF): %VAR_2\n",
strerror(errno));
return AVERROR(errno);
}
if (VAR_3.index >= VAR_2->buffers) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid buffer index received.\n");
return AVERROR(EINVAL);
}
avpriv_atomic_int_add_and_fetch(&VAR_2->buffers_queued, -1);
av_assert0(avpriv_atomic_int_get(&VAR_2->buffers_queued) >= 1);
if (VAR_2->frame_size > 0 && VAR_3.bytesused != VAR_2->frame_size) {
av_log(VAR_0, AV_LOG_ERROR,
"The v4l2 frame is %d bytes, but %d bytes are expected\n",
VAR_3.bytesused, VAR_2->frame_size);
return AVERROR_INVALIDDATA;
}
if (avpriv_atomic_int_get(&VAR_2->buffers_queued) == FFMAX(VAR_2->buffers / 8, 1)) {
VAR_5 = av_new_packet(VAR_1, VAR_3.bytesused);
if (VAR_5 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Error allocating a packet.\n");
return VAR_5;
}
memcpy(VAR_1->data, VAR_2->buf_start[VAR_3.index], VAR_3.bytesused);
VAR_5 = ioctl(VAR_2->fd, VIDIOC_QBUF, &VAR_3);
if (VAR_5 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "ioctl(VIDIOC_QBUF)\n");
av_free_packet(VAR_1);
return AVERROR(errno);
}
avpriv_atomic_int_add_and_fetch(&VAR_2->buffers_queued, 1);
} else {
struct buff_data *VAR_6;
VAR_1->data = VAR_2->buf_start[VAR_3.index];
VAR_1->size = VAR_3.bytesused;
#if FF_API_DESTRUCT_PACKET
FF_DISABLE_DEPRECATION_WARNINGS
VAR_1->destruct = dummy_release_buffer;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
VAR_6 = av_malloc(sizeof(struct buff_data));
if (VAR_6 == NULL) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to allocate a buffer descriptor\n");
VAR_5 = ioctl(VAR_2->fd, VIDIOC_QBUF, &VAR_3);
return AVERROR(ENOMEM);
}
VAR_6->fd = VAR_2->fd;
VAR_6->index = VAR_3.index;
VAR_6->VAR_2 = VAR_2;
VAR_1->VAR_3 = av_buffer_create(VAR_1->data, VAR_1->size, mmap_release_buffer,
VAR_6, 0);
if (!VAR_1->VAR_3) {
av_freep(&VAR_6);
return AVERROR(ENOMEM);
}
}
VAR_1->pts = VAR_3.timestamp.tv_sec * INT64_C(1000000) + VAR_3.timestamp.tv_usec;
return VAR_2->buf_len[VAR_3.index];
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{",
"struct video_data *VAR_2 = VAR_0->priv_data;",
"struct v4l2_buffer VAR_3 = {",
".type = V4L2_BUF_TYPE_VIDEO_CAPTURE,\n.memory = V4L2_MEMORY_MMAP\n};",
"struct pollfd VAR_4 = { .fd = VAR_2->fd, .events = POLLIN };",
"int VAR_5;",
"VAR_5 = poll(&VAR_4, 1, VAR_2->timeout);",
"if (VAR_5 < 0)\nreturn AVERROR(errno);",
"if (!(VAR_4.revents & (POLLIN | POLLERR | POLLHUP)))\nreturn AVERROR(EAGAIN);",
"while ((VAR_5 = ioctl(VAR_2->fd, VIDIOC_DQBUF, &VAR_3)) < 0 && (errno == EINTR));",
"if (VAR_5 < 0) {",
"if (errno == EAGAIN) {",
"VAR_1->size = 0;",
"return AVERROR(EAGAIN);",
"}",
"av_log(VAR_0, AV_LOG_ERROR, \"ioctl(VIDIOC_DQBUF): %VAR_2\\n\",\nstrerror(errno));",
"return AVERROR(errno);",
"}",
"if (VAR_3.index >= VAR_2->buffers) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid buffer index received.\\n\");",
"return AVERROR(EINVAL);",
"}",
"avpriv_atomic_int_add_and_fetch(&VAR_2->buffers_queued, -1);",
"av_assert0(avpriv_atomic_int_get(&VAR_2->buffers_queued) >= 1);",
"if (VAR_2->frame_size > 0 && VAR_3.bytesused != VAR_2->frame_size) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"The v4l2 frame is %d bytes, but %d bytes are expected\\n\",\nVAR_3.bytesused, VAR_2->frame_size);",
"return AVERROR_INVALIDDATA;",
"}",
"if (avpriv_atomic_int_get(&VAR_2->buffers_queued) == FFMAX(VAR_2->buffers / 8, 1)) {",
"VAR_5 = av_new_packet(VAR_1, VAR_3.bytesused);",
"if (VAR_5 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error allocating a packet.\\n\");",
"return VAR_5;",
"}",
"memcpy(VAR_1->data, VAR_2->buf_start[VAR_3.index], VAR_3.bytesused);",
"VAR_5 = ioctl(VAR_2->fd, VIDIOC_QBUF, &VAR_3);",
"if (VAR_5 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"ioctl(VIDIOC_QBUF)\\n\");",
"av_free_packet(VAR_1);",
"return AVERROR(errno);",
"}",
"avpriv_atomic_int_add_and_fetch(&VAR_2->buffers_queued, 1);",
"} else {",
"struct buff_data *VAR_6;",
"VAR_1->data = VAR_2->buf_start[VAR_3.index];",
"VAR_1->size = VAR_3.bytesused;",
"#if FF_API_DESTRUCT_PACKET\nFF_DISABLE_DEPRECATION_WARNINGS\nVAR_1->destruct = dummy_release_buffer;",
"FF_ENABLE_DEPRECATION_WARNINGS\n#endif\nVAR_6 = av_malloc(sizeof(struct buff_data));",
"if (VAR_6 == NULL) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to allocate a buffer descriptor\\n\");",
"VAR_5 = ioctl(VAR_2->fd, VIDIOC_QBUF, &VAR_3);",
"return AVERROR(ENOMEM);",
"}",
"VAR_6->fd = VAR_2->fd;",
"VAR_6->index = VAR_3.index;",
"VAR_6->VAR_2 = VAR_2;",
"VAR_1->VAR_3 = av_buffer_create(VAR_1->data, VAR_1->size, mmap_release_buffer,\nVAR_6, 0);",
"if (!VAR_1->VAR_3) {",
"av_freep(&VAR_6);",
"return AVERROR(ENOMEM);",
"}",
"}",
"VAR_1->pts = VAR_3.timestamp.tv_sec * INT64_C(1000000) + VAR_3.timestamp.tv_usec;",
"return VAR_2->buf_len[VAR_3.index];",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
11,
13
],
[
15
],
[
17
],
[
21
],
[
23,
25
],
[
29,
31
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51,
53
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
79
],
[
81,
83,
85
],
[
89
],
[
91
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139,
141,
143
],
[
145,
147,
151
],
[
153
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
179,
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
197
],
[
199
]
] |
26,823 | void cpu_ppc_set_papr(PowerPCCPU *cpu)
{
CPUPPCState *env = &cpu->env;
/* PAPR always has exception vectors in RAM not ROM. To ensure this,
* MSR[IP] should never be set.
*
* We also disallow setting of MSR_HV
*/
env->msr_mask &= ~((1ull << MSR_EP) | MSR_HVB);
/* Set a full AMOR so guest can use the AMR as it sees fit */
env->spr[SPR_AMOR] = amor->default_value = 0xffffffffffffffffull;
/* Tell KVM that we're in PAPR mode */
if (kvm_enabled()) {
kvmppc_set_papr(cpu);
}
} | true | qemu | 6a9c4ef452c98060e919aa49db49c09ed8c37745 | void cpu_ppc_set_papr(PowerPCCPU *cpu)
{
CPUPPCState *env = &cpu->env;
env->msr_mask &= ~((1ull << MSR_EP) | MSR_HVB);
env->spr[SPR_AMOR] = amor->default_value = 0xffffffffffffffffull;
if (kvm_enabled()) {
kvmppc_set_papr(cpu);
}
} | {
"code": [],
"line_no": []
} | void FUNC_0(PowerPCCPU *VAR_0)
{
CPUPPCState *env = &VAR_0->env;
env->msr_mask &= ~((1ull << MSR_EP) | MSR_HVB);
env->spr[SPR_AMOR] = amor->default_value = 0xffffffffffffffffull;
if (kvm_enabled()) {
kvmppc_set_papr(VAR_0);
}
} | [
"void FUNC_0(PowerPCCPU *VAR_0)\n{",
"CPUPPCState *env = &VAR_0->env;",
"env->msr_mask &= ~((1ull << MSR_EP) | MSR_HVB);",
"env->spr[SPR_AMOR] = amor->default_value = 0xffffffffffffffffull;",
"if (kvm_enabled()) {",
"kvmppc_set_papr(VAR_0);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
20
],
[
26
],
[
32
],
[
34
],
[
36
],
[
38
]
] |
26,824 | static int aac_encode_frame(AVCodecContext *avctx,
uint8_t *frame, int buf_size, void *data)
{
AACEncContext *s = avctx->priv_data;
int16_t *samples = s->samples, *samples2, *la;
ChannelElement *cpe;
int i, j, chans, tag, start_ch;
const uint8_t *chan_map = aac_chan_configs[avctx->channels-1];
int chan_el_counter[4];
FFPsyWindowInfo windows[avctx->channels];
if (s->last_frame)
return 0;
if (data) {
if (!s->psypp) {
memcpy(s->samples + 1024 * avctx->channels, data,
1024 * avctx->channels * sizeof(s->samples[0]));
} else {
start_ch = 0;
samples2 = s->samples + 1024 * avctx->channels;
for (i = 0; i < chan_map[0]; i++) {
tag = chan_map[i+1];
chans = tag == TYPE_CPE ? 2 : 1;
ff_psy_preprocess(s->psypp, (uint16_t*)data + start_ch,
samples2 + start_ch, start_ch, chans);
start_ch += chans;
}
}
}
if (!avctx->frame_number) {
memcpy(s->samples, s->samples + 1024 * avctx->channels,
1024 * avctx->channels * sizeof(s->samples[0]));
return 0;
}
start_ch = 0;
for (i = 0; i < chan_map[0]; i++) {
FFPsyWindowInfo* wi = windows + start_ch;
tag = chan_map[i+1];
chans = tag == TYPE_CPE ? 2 : 1;
cpe = &s->cpe[i];
samples2 = samples + start_ch;
la = samples2 + 1024 * avctx->channels + start_ch;
if (!data)
la = NULL;
for (j = 0; j < chans; j++) {
IndividualChannelStream *ics = &cpe->ch[j].ics;
int k;
wi[j] = ff_psy_suggest_window(&s->psy, samples2, la, start_ch + j, ics->window_sequence[0]);
ics->window_sequence[1] = ics->window_sequence[0];
ics->window_sequence[0] = wi[j].window_type[0];
ics->use_kb_window[1] = ics->use_kb_window[0];
ics->use_kb_window[0] = wi[j].window_shape;
ics->num_windows = wi[j].num_windows;
ics->swb_sizes = s->psy.bands [ics->num_windows == 8];
ics->num_swb = s->psy.num_bands[ics->num_windows == 8];
for (k = 0; k < ics->num_windows; k++)
ics->group_len[k] = wi[j].grouping[k];
s->cur_channel = start_ch + j;
apply_window_and_mdct(avctx, s, &cpe->ch[j], samples2, j);
}
start_ch += chans;
}
init_put_bits(&s->pb, frame, buf_size*8);
if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & CODEC_FLAG_BITEXACT))
put_bitstream_info(avctx, s, LIBAVCODEC_IDENT);
start_ch = 0;
memset(chan_el_counter, 0, sizeof(chan_el_counter));
for (i = 0; i < chan_map[0]; i++) {
FFPsyWindowInfo* wi = windows + start_ch;
tag = chan_map[i+1];
chans = tag == TYPE_CPE ? 2 : 1;
cpe = &s->cpe[i];
for (j = 0; j < chans; j++) {
s->coder->search_for_quantizers(avctx, s, &cpe->ch[j], s->lambda);
}
cpe->common_window = 0;
if (chans > 1
&& wi[0].window_type[0] == wi[1].window_type[0]
&& wi[0].window_shape == wi[1].window_shape) {
cpe->common_window = 1;
for (j = 0; j < wi[0].num_windows; j++) {
if (wi[0].grouping[j] != wi[1].grouping[j]) {
cpe->common_window = 0;
break;
}
}
}
if (cpe->common_window && s->coder->search_for_ms)
s->coder->search_for_ms(s, cpe, s->lambda);
adjust_frame_information(s, cpe, chans);
put_bits(&s->pb, 3, tag);
put_bits(&s->pb, 4, chan_el_counter[tag]++);
if (chans == 2) {
put_bits(&s->pb, 1, cpe->common_window);
if (cpe->common_window) {
put_ics_info(s, &cpe->ch[0].ics);
encode_ms_info(&s->pb, cpe);
}
}
for (j = 0; j < chans; j++) {
s->cur_channel = start_ch + j;
ff_psy_set_band_info(&s->psy, s->cur_channel, cpe->ch[j].coeffs, &wi[j]);
encode_individual_channel(avctx, s, &cpe->ch[j], cpe->common_window);
}
start_ch += chans;
}
put_bits(&s->pb, 3, TYPE_END);
flush_put_bits(&s->pb);
avctx->frame_bits = put_bits_count(&s->pb);
// rate control stuff
if (!(avctx->flags & CODEC_FLAG_QSCALE)) {
float ratio = avctx->bit_rate * 1024.0f / avctx->sample_rate / avctx->frame_bits;
s->lambda *= ratio;
s->lambda = fminf(s->lambda, 65536.f);
}
if (avctx->frame_bits > 6144*avctx->channels)
av_log(avctx, AV_LOG_ERROR, "input buffer violation %d > %d.\n",
avctx->frame_bits, 6144*avctx->channels);
if (!data)
s->last_frame = 1;
memcpy(s->samples, s->samples + 1024 * avctx->channels,
1024 * avctx->channels * sizeof(s->samples[0]));
return put_bits_count(&s->pb)>>3;
}
| true | FFmpeg | 48d20c11ba8141337e2bbc6a779a29142390556e | static int aac_encode_frame(AVCodecContext *avctx,
uint8_t *frame, int buf_size, void *data)
{
AACEncContext *s = avctx->priv_data;
int16_t *samples = s->samples, *samples2, *la;
ChannelElement *cpe;
int i, j, chans, tag, start_ch;
const uint8_t *chan_map = aac_chan_configs[avctx->channels-1];
int chan_el_counter[4];
FFPsyWindowInfo windows[avctx->channels];
if (s->last_frame)
return 0;
if (data) {
if (!s->psypp) {
memcpy(s->samples + 1024 * avctx->channels, data,
1024 * avctx->channels * sizeof(s->samples[0]));
} else {
start_ch = 0;
samples2 = s->samples + 1024 * avctx->channels;
for (i = 0; i < chan_map[0]; i++) {
tag = chan_map[i+1];
chans = tag == TYPE_CPE ? 2 : 1;
ff_psy_preprocess(s->psypp, (uint16_t*)data + start_ch,
samples2 + start_ch, start_ch, chans);
start_ch += chans;
}
}
}
if (!avctx->frame_number) {
memcpy(s->samples, s->samples + 1024 * avctx->channels,
1024 * avctx->channels * sizeof(s->samples[0]));
return 0;
}
start_ch = 0;
for (i = 0; i < chan_map[0]; i++) {
FFPsyWindowInfo* wi = windows + start_ch;
tag = chan_map[i+1];
chans = tag == TYPE_CPE ? 2 : 1;
cpe = &s->cpe[i];
samples2 = samples + start_ch;
la = samples2 + 1024 * avctx->channels + start_ch;
if (!data)
la = NULL;
for (j = 0; j < chans; j++) {
IndividualChannelStream *ics = &cpe->ch[j].ics;
int k;
wi[j] = ff_psy_suggest_window(&s->psy, samples2, la, start_ch + j, ics->window_sequence[0]);
ics->window_sequence[1] = ics->window_sequence[0];
ics->window_sequence[0] = wi[j].window_type[0];
ics->use_kb_window[1] = ics->use_kb_window[0];
ics->use_kb_window[0] = wi[j].window_shape;
ics->num_windows = wi[j].num_windows;
ics->swb_sizes = s->psy.bands [ics->num_windows == 8];
ics->num_swb = s->psy.num_bands[ics->num_windows == 8];
for (k = 0; k < ics->num_windows; k++)
ics->group_len[k] = wi[j].grouping[k];
s->cur_channel = start_ch + j;
apply_window_and_mdct(avctx, s, &cpe->ch[j], samples2, j);
}
start_ch += chans;
}
init_put_bits(&s->pb, frame, buf_size*8);
if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & CODEC_FLAG_BITEXACT))
put_bitstream_info(avctx, s, LIBAVCODEC_IDENT);
start_ch = 0;
memset(chan_el_counter, 0, sizeof(chan_el_counter));
for (i = 0; i < chan_map[0]; i++) {
FFPsyWindowInfo* wi = windows + start_ch;
tag = chan_map[i+1];
chans = tag == TYPE_CPE ? 2 : 1;
cpe = &s->cpe[i];
for (j = 0; j < chans; j++) {
s->coder->search_for_quantizers(avctx, s, &cpe->ch[j], s->lambda);
}
cpe->common_window = 0;
if (chans > 1
&& wi[0].window_type[0] == wi[1].window_type[0]
&& wi[0].window_shape == wi[1].window_shape) {
cpe->common_window = 1;
for (j = 0; j < wi[0].num_windows; j++) {
if (wi[0].grouping[j] != wi[1].grouping[j]) {
cpe->common_window = 0;
break;
}
}
}
if (cpe->common_window && s->coder->search_for_ms)
s->coder->search_for_ms(s, cpe, s->lambda);
adjust_frame_information(s, cpe, chans);
put_bits(&s->pb, 3, tag);
put_bits(&s->pb, 4, chan_el_counter[tag]++);
if (chans == 2) {
put_bits(&s->pb, 1, cpe->common_window);
if (cpe->common_window) {
put_ics_info(s, &cpe->ch[0].ics);
encode_ms_info(&s->pb, cpe);
}
}
for (j = 0; j < chans; j++) {
s->cur_channel = start_ch + j;
ff_psy_set_band_info(&s->psy, s->cur_channel, cpe->ch[j].coeffs, &wi[j]);
encode_individual_channel(avctx, s, &cpe->ch[j], cpe->common_window);
}
start_ch += chans;
}
put_bits(&s->pb, 3, TYPE_END);
flush_put_bits(&s->pb);
avctx->frame_bits = put_bits_count(&s->pb);
if (!(avctx->flags & CODEC_FLAG_QSCALE)) {
float ratio = avctx->bit_rate * 1024.0f / avctx->sample_rate / avctx->frame_bits;
s->lambda *= ratio;
s->lambda = fminf(s->lambda, 65536.f);
}
if (avctx->frame_bits > 6144*avctx->channels)
av_log(avctx, AV_LOG_ERROR, "input buffer violation %d > %d.\n",
avctx->frame_bits, 6144*avctx->channels);
if (!data)
s->last_frame = 1;
memcpy(s->samples, s->samples + 1024 * avctx->channels,
1024 * avctx->channels * sizeof(s->samples[0]));
return put_bits_count(&s->pb)>>3;
}
| {
"code": [
" if (avctx->frame_bits > 6144*avctx->channels)",
" av_log(avctx, AV_LOG_ERROR, \"input buffer violation %d > %d.\\n\",",
" avctx->frame_bits, 6144*avctx->channels);"
],
"line_no": [
243,
245,
247
]
} | static int FUNC_0(AVCodecContext *VAR_0,
uint8_t *VAR_1, int VAR_2, void *VAR_3)
{
AACEncContext *s = VAR_0->priv_data;
int16_t *samples = s->samples, *samples2, *la;
ChannelElement *cpe;
int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;
const uint8_t *VAR_9 = aac_chan_configs[VAR_0->channels-1];
int VAR_10[4];
FFPsyWindowInfo windows[VAR_0->channels];
if (s->last_frame)
return 0;
if (VAR_3) {
if (!s->psypp) {
memcpy(s->samples + 1024 * VAR_0->channels, VAR_3,
1024 * VAR_0->channels * sizeof(s->samples[0]));
} else {
VAR_8 = 0;
samples2 = s->samples + 1024 * VAR_0->channels;
for (VAR_4 = 0; VAR_4 < VAR_9[0]; VAR_4++) {
VAR_7 = VAR_9[VAR_4+1];
VAR_6 = VAR_7 == TYPE_CPE ? 2 : 1;
ff_psy_preprocess(s->psypp, (uint16_t*)VAR_3 + VAR_8,
samples2 + VAR_8, VAR_8, VAR_6);
VAR_8 += VAR_6;
}
}
}
if (!VAR_0->frame_number) {
memcpy(s->samples, s->samples + 1024 * VAR_0->channels,
1024 * VAR_0->channels * sizeof(s->samples[0]));
return 0;
}
VAR_8 = 0;
for (VAR_4 = 0; VAR_4 < VAR_9[0]; VAR_4++) {
FFPsyWindowInfo* wi = windows + VAR_8;
VAR_7 = VAR_9[VAR_4+1];
VAR_6 = VAR_7 == TYPE_CPE ? 2 : 1;
cpe = &s->cpe[VAR_4];
samples2 = samples + VAR_8;
la = samples2 + 1024 * VAR_0->channels + VAR_8;
if (!VAR_3)
la = NULL;
for (VAR_5 = 0; VAR_5 < VAR_6; VAR_5++) {
IndividualChannelStream *ics = &cpe->ch[VAR_5].ics;
int k;
wi[VAR_5] = ff_psy_suggest_window(&s->psy, samples2, la, VAR_8 + VAR_5, ics->window_sequence[0]);
ics->window_sequence[1] = ics->window_sequence[0];
ics->window_sequence[0] = wi[VAR_5].window_type[0];
ics->use_kb_window[1] = ics->use_kb_window[0];
ics->use_kb_window[0] = wi[VAR_5].window_shape;
ics->num_windows = wi[VAR_5].num_windows;
ics->swb_sizes = s->psy.bands [ics->num_windows == 8];
ics->num_swb = s->psy.num_bands[ics->num_windows == 8];
for (k = 0; k < ics->num_windows; k++)
ics->group_len[k] = wi[VAR_5].grouping[k];
s->cur_channel = VAR_8 + VAR_5;
apply_window_and_mdct(VAR_0, s, &cpe->ch[VAR_5], samples2, VAR_5);
}
VAR_8 += VAR_6;
}
init_put_bits(&s->pb, VAR_1, VAR_2*8);
if ((VAR_0->frame_number & 0xFF)==1 && !(VAR_0->flags & CODEC_FLAG_BITEXACT))
put_bitstream_info(VAR_0, s, LIBAVCODEC_IDENT);
VAR_8 = 0;
memset(VAR_10, 0, sizeof(VAR_10));
for (VAR_4 = 0; VAR_4 < VAR_9[0]; VAR_4++) {
FFPsyWindowInfo* wi = windows + VAR_8;
VAR_7 = VAR_9[VAR_4+1];
VAR_6 = VAR_7 == TYPE_CPE ? 2 : 1;
cpe = &s->cpe[VAR_4];
for (VAR_5 = 0; VAR_5 < VAR_6; VAR_5++) {
s->coder->search_for_quantizers(VAR_0, s, &cpe->ch[VAR_5], s->lambda);
}
cpe->common_window = 0;
if (VAR_6 > 1
&& wi[0].window_type[0] == wi[1].window_type[0]
&& wi[0].window_shape == wi[1].window_shape) {
cpe->common_window = 1;
for (VAR_5 = 0; VAR_5 < wi[0].num_windows; VAR_5++) {
if (wi[0].grouping[VAR_5] != wi[1].grouping[VAR_5]) {
cpe->common_window = 0;
break;
}
}
}
if (cpe->common_window && s->coder->search_for_ms)
s->coder->search_for_ms(s, cpe, s->lambda);
adjust_frame_information(s, cpe, VAR_6);
put_bits(&s->pb, 3, VAR_7);
put_bits(&s->pb, 4, VAR_10[VAR_7]++);
if (VAR_6 == 2) {
put_bits(&s->pb, 1, cpe->common_window);
if (cpe->common_window) {
put_ics_info(s, &cpe->ch[0].ics);
encode_ms_info(&s->pb, cpe);
}
}
for (VAR_5 = 0; VAR_5 < VAR_6; VAR_5++) {
s->cur_channel = VAR_8 + VAR_5;
ff_psy_set_band_info(&s->psy, s->cur_channel, cpe->ch[VAR_5].coeffs, &wi[VAR_5]);
encode_individual_channel(VAR_0, s, &cpe->ch[VAR_5], cpe->common_window);
}
VAR_8 += VAR_6;
}
put_bits(&s->pb, 3, TYPE_END);
flush_put_bits(&s->pb);
VAR_0->frame_bits = put_bits_count(&s->pb);
if (!(VAR_0->flags & CODEC_FLAG_QSCALE)) {
float VAR_11 = VAR_0->bit_rate * 1024.0f / VAR_0->sample_rate / VAR_0->frame_bits;
s->lambda *= VAR_11;
s->lambda = fminf(s->lambda, 65536.f);
}
if (VAR_0->frame_bits > 6144*VAR_0->channels)
av_log(VAR_0, AV_LOG_ERROR, "input buffer violation %d > %d.\n",
VAR_0->frame_bits, 6144*VAR_0->channels);
if (!VAR_3)
s->last_frame = 1;
memcpy(s->samples, s->samples + 1024 * VAR_0->channels,
1024 * VAR_0->channels * sizeof(s->samples[0]));
return put_bits_count(&s->pb)>>3;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nuint8_t *VAR_1, int VAR_2, void *VAR_3)\n{",
"AACEncContext *s = VAR_0->priv_data;",
"int16_t *samples = s->samples, *samples2, *la;",
"ChannelElement *cpe;",
"int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;",
"const uint8_t *VAR_9 = aac_chan_configs[VAR_0->channels-1];",
"int VAR_10[4];",
"FFPsyWindowInfo windows[VAR_0->channels];",
"if (s->last_frame)\nreturn 0;",
"if (VAR_3) {",
"if (!s->psypp) {",
"memcpy(s->samples + 1024 * VAR_0->channels, VAR_3,\n1024 * VAR_0->channels * sizeof(s->samples[0]));",
"} else {",
"VAR_8 = 0;",
"samples2 = s->samples + 1024 * VAR_0->channels;",
"for (VAR_4 = 0; VAR_4 < VAR_9[0]; VAR_4++) {",
"VAR_7 = VAR_9[VAR_4+1];",
"VAR_6 = VAR_7 == TYPE_CPE ? 2 : 1;",
"ff_psy_preprocess(s->psypp, (uint16_t*)VAR_3 + VAR_8,\nsamples2 + VAR_8, VAR_8, VAR_6);",
"VAR_8 += VAR_6;",
"}",
"}",
"}",
"if (!VAR_0->frame_number) {",
"memcpy(s->samples, s->samples + 1024 * VAR_0->channels,\n1024 * VAR_0->channels * sizeof(s->samples[0]));",
"return 0;",
"}",
"VAR_8 = 0;",
"for (VAR_4 = 0; VAR_4 < VAR_9[0]; VAR_4++) {",
"FFPsyWindowInfo* wi = windows + VAR_8;",
"VAR_7 = VAR_9[VAR_4+1];",
"VAR_6 = VAR_7 == TYPE_CPE ? 2 : 1;",
"cpe = &s->cpe[VAR_4];",
"samples2 = samples + VAR_8;",
"la = samples2 + 1024 * VAR_0->channels + VAR_8;",
"if (!VAR_3)\nla = NULL;",
"for (VAR_5 = 0; VAR_5 < VAR_6; VAR_5++) {",
"IndividualChannelStream *ics = &cpe->ch[VAR_5].ics;",
"int k;",
"wi[VAR_5] = ff_psy_suggest_window(&s->psy, samples2, la, VAR_8 + VAR_5, ics->window_sequence[0]);",
"ics->window_sequence[1] = ics->window_sequence[0];",
"ics->window_sequence[0] = wi[VAR_5].window_type[0];",
"ics->use_kb_window[1] = ics->use_kb_window[0];",
"ics->use_kb_window[0] = wi[VAR_5].window_shape;",
"ics->num_windows = wi[VAR_5].num_windows;",
"ics->swb_sizes = s->psy.bands [ics->num_windows == 8];",
"ics->num_swb = s->psy.num_bands[ics->num_windows == 8];",
"for (k = 0; k < ics->num_windows; k++)",
"ics->group_len[k] = wi[VAR_5].grouping[k];",
"s->cur_channel = VAR_8 + VAR_5;",
"apply_window_and_mdct(VAR_0, s, &cpe->ch[VAR_5], samples2, VAR_5);",
"}",
"VAR_8 += VAR_6;",
"}",
"init_put_bits(&s->pb, VAR_1, VAR_2*8);",
"if ((VAR_0->frame_number & 0xFF)==1 && !(VAR_0->flags & CODEC_FLAG_BITEXACT))\nput_bitstream_info(VAR_0, s, LIBAVCODEC_IDENT);",
"VAR_8 = 0;",
"memset(VAR_10, 0, sizeof(VAR_10));",
"for (VAR_4 = 0; VAR_4 < VAR_9[0]; VAR_4++) {",
"FFPsyWindowInfo* wi = windows + VAR_8;",
"VAR_7 = VAR_9[VAR_4+1];",
"VAR_6 = VAR_7 == TYPE_CPE ? 2 : 1;",
"cpe = &s->cpe[VAR_4];",
"for (VAR_5 = 0; VAR_5 < VAR_6; VAR_5++) {",
"s->coder->search_for_quantizers(VAR_0, s, &cpe->ch[VAR_5], s->lambda);",
"}",
"cpe->common_window = 0;",
"if (VAR_6 > 1\n&& wi[0].window_type[0] == wi[1].window_type[0]\n&& wi[0].window_shape == wi[1].window_shape) {",
"cpe->common_window = 1;",
"for (VAR_5 = 0; VAR_5 < wi[0].num_windows; VAR_5++) {",
"if (wi[0].grouping[VAR_5] != wi[1].grouping[VAR_5]) {",
"cpe->common_window = 0;",
"break;",
"}",
"}",
"}",
"if (cpe->common_window && s->coder->search_for_ms)\ns->coder->search_for_ms(s, cpe, s->lambda);",
"adjust_frame_information(s, cpe, VAR_6);",
"put_bits(&s->pb, 3, VAR_7);",
"put_bits(&s->pb, 4, VAR_10[VAR_7]++);",
"if (VAR_6 == 2) {",
"put_bits(&s->pb, 1, cpe->common_window);",
"if (cpe->common_window) {",
"put_ics_info(s, &cpe->ch[0].ics);",
"encode_ms_info(&s->pb, cpe);",
"}",
"}",
"for (VAR_5 = 0; VAR_5 < VAR_6; VAR_5++) {",
"s->cur_channel = VAR_8 + VAR_5;",
"ff_psy_set_band_info(&s->psy, s->cur_channel, cpe->ch[VAR_5].coeffs, &wi[VAR_5]);",
"encode_individual_channel(VAR_0, s, &cpe->ch[VAR_5], cpe->common_window);",
"}",
"VAR_8 += VAR_6;",
"}",
"put_bits(&s->pb, 3, TYPE_END);",
"flush_put_bits(&s->pb);",
"VAR_0->frame_bits = put_bits_count(&s->pb);",
"if (!(VAR_0->flags & CODEC_FLAG_QSCALE)) {",
"float VAR_11 = VAR_0->bit_rate * 1024.0f / VAR_0->sample_rate / VAR_0->frame_bits;",
"s->lambda *= VAR_11;",
"s->lambda = fminf(s->lambda, 65536.f);",
"}",
"if (VAR_0->frame_bits > 6144*VAR_0->channels)\nav_log(VAR_0, AV_LOG_ERROR, \"input buffer violation %d > %d.\\n\",\nVAR_0->frame_bits, 6144*VAR_0->channels);",
"if (!VAR_3)\ns->last_frame = 1;",
"memcpy(s->samples, s->samples + 1024 * VAR_0->channels,\n1024 * VAR_0->channels * sizeof(s->samples[0]));",
"return put_bits_count(&s->pb)>>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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23,
25
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87,
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131,
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157,
159,
161
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181,
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
221
],
[
223
],
[
225
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
243,
245,
247
],
[
251,
253
],
[
255,
257
],
[
259
],
[
261
]
] |
26,825 | static int vc1_decode_intra_block(VC1Context *v, DCTELEM block[64], int n, int coded, int mquant, int codingset)
{
GetBitContext *gb = &v->s.gb;
MpegEncContext *s = &v->s;
int dc_pred_dir = 0; /* Direction of the DC prediction used */
int run_diff, i;
int16_t *dc_val;
int16_t *ac_val, *ac_val2;
int dcdiff;
int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
int a_avail, c_avail;
/* XXX: Guard against dumb values of mquant */
mquant = (mquant < 1) ? 0 : ( (mquant>31) ? 31 : mquant );
/* Set DC scale - y and c use the same */
s->y_dc_scale = s->y_dc_scale_table[mquant];
s->c_dc_scale = s->c_dc_scale_table[mquant];
/* check if prediction blocks A and C are available */
a_avail = c_avail = 0;
if((n == 2 || n == 3) || (s->mb_y && IS_INTRA(s->current_picture.mb_type[mb_pos - s->mb_stride])))
a_avail = 1;
if((n == 1 || n == 3) || (s->mb_x && IS_INTRA(s->current_picture.mb_type[mb_pos - 1])))
c_avail = 1;
/* Get DC differential */
if (n < 4) {
dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
} else {
dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
}
if (dcdiff < 0){
av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n");
return -1;
}
if (dcdiff)
{
if (dcdiff == 119 /* ESC index value */)
{
/* TODO: Optimize */
if (mquant == 1) dcdiff = get_bits(gb, 10);
else if (mquant == 2) dcdiff = get_bits(gb, 9);
else dcdiff = get_bits(gb, 8);
}
else
{
if (mquant == 1)
dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3;
else if (mquant == 2)
dcdiff = (dcdiff<<1) + get_bits(gb, 1) - 1;
}
if (get_bits(gb, 1))
dcdiff = -dcdiff;
}
/* Prediction */
dcdiff += vc1_pred_dc(&v->s, v->overlap, mquant, n, a_avail, c_avail, &dc_val, &dc_pred_dir);
*dc_val = dcdiff;
/* Store the quantized DC coeff, used for prediction */
if (n < 4) {
block[0] = dcdiff * s->y_dc_scale;
} else {
block[0] = dcdiff * s->c_dc_scale;
}
/* Skip ? */
run_diff = 0;
i = 0;
if (!coded) {
goto not_coded;
}
//AC Decoding
i = 1;
{
int last = 0, skip, value;
const int8_t *zz_table;
int scale;
int k;
scale = mquant * 2 + v->halfpq;
zz_table = vc1_simple_progressive_8x8_zz;
ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
ac_val2 = ac_val;
if(dc_pred_dir) //left
ac_val -= 16;
else //top
ac_val -= 16 * s->block_wrap[n];
while (!last) {
vc1_decode_ac_coeff(v, &last, &skip, &value, codingset);
i += skip;
if(i > 63)
break;
block[zz_table[i++]] = value;
}
/* apply AC prediction if needed */
if(s->ac_pred) {
/* scale predictors if needed*/
int mb_pos2, q1, q2;
mb_pos2 = mb_pos - dc_pred_dir - (1 - dc_pred_dir) * s->mb_stride;
q1 = s->current_picture.qscale_table[mb_pos];
q2 = s->current_picture.qscale_table[mb_pos2];
if(!c_avail) {
memset(ac_val, 0, 8 * sizeof(ac_val[0]));
dc_pred_dir = 0;
}
if(!a_avail) {
memset(ac_val + 8, 0, 8 * sizeof(ac_val[0]));
dc_pred_dir = 1;
}
if(!q1 && q1 && q2 && q1 != q2) {
q1 = q1 * 2 - 1;
q2 = q2 * 2 - 1;
if(dc_pred_dir) { //left
for(k = 1; k < 8; k++)
block[k << 3] += (ac_val[k] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18;
} else { //top
for(k = 1; k < 8; k++)
block[k] += (ac_val[k + 8] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
} else {
if(dc_pred_dir) { //left
for(k = 1; k < 8; k++)
block[k << 3] += ac_val[k];
} else { //top
for(k = 1; k < 8; k++)
block[k] += ac_val[k + 8];
}
}
}
/* save AC coeffs for further prediction */
for(k = 1; k < 8; k++) {
ac_val2[k] = block[k << 3];
ac_val2[k + 8] = block[k];
}
/* scale AC coeffs */
for(k = 1; k < 64; k++)
if(block[k]) {
block[k] *= scale;
if(!v->pquantizer)
block[k] += (block[k] < 0) ? -mquant : mquant;
}
if(s->ac_pred) i = 63;
}
not_coded:
if(!coded) {
int k, scale;
ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
ac_val2 = ac_val;
if(!c_avail) {
memset(ac_val, 0, 8 * sizeof(ac_val[0]));
dc_pred_dir = 0;
}
if(!a_avail) {
memset(ac_val + 8, 0, 8 * sizeof(ac_val[0]));
dc_pred_dir = 1;
}
scale = mquant * 2 + v->halfpq;
memset(ac_val2, 0, 16 * 2);
if(dc_pred_dir) {//left
ac_val -= 16;
if(s->ac_pred)
memcpy(ac_val2, ac_val, 8 * 2);
} else {//top
ac_val -= 16 * s->block_wrap[n];
if(s->ac_pred)
memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
}
/* apply AC prediction if needed */
if(s->ac_pred) {
if(dc_pred_dir) { //left
for(k = 1; k < 8; k++) {
block[k << 3] = ac_val[k] * scale;
if(!v->pquantizer)
block[k << 3] += (block[k << 3] < 0) ? -mquant : mquant;
}
} else { //top
for(k = 1; k < 8; k++) {
block[k] = ac_val[k + 8] * scale;
if(!v->pquantizer)
block[k] += (block[k] < 0) ? -mquant : mquant;
}
}
i = 63;
}
}
s->block_last_index[n] = i;
return 0;
}
| false | FFmpeg | f26c2ef53b68f4e7e0f8e4eac8466b4fdeffb8b1 | static int vc1_decode_intra_block(VC1Context *v, DCTELEM block[64], int n, int coded, int mquant, int codingset)
{
GetBitContext *gb = &v->s.gb;
MpegEncContext *s = &v->s;
int dc_pred_dir = 0;
int run_diff, i;
int16_t *dc_val;
int16_t *ac_val, *ac_val2;
int dcdiff;
int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
int a_avail, c_avail;
mquant = (mquant < 1) ? 0 : ( (mquant>31) ? 31 : mquant );
s->y_dc_scale = s->y_dc_scale_table[mquant];
s->c_dc_scale = s->c_dc_scale_table[mquant];
a_avail = c_avail = 0;
if((n == 2 || n == 3) || (s->mb_y && IS_INTRA(s->current_picture.mb_type[mb_pos - s->mb_stride])))
a_avail = 1;
if((n == 1 || n == 3) || (s->mb_x && IS_INTRA(s->current_picture.mb_type[mb_pos - 1])))
c_avail = 1;
if (n < 4) {
dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
} else {
dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
}
if (dcdiff < 0){
av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n");
return -1;
}
if (dcdiff)
{
if (dcdiff == 119 )
{
if (mquant == 1) dcdiff = get_bits(gb, 10);
else if (mquant == 2) dcdiff = get_bits(gb, 9);
else dcdiff = get_bits(gb, 8);
}
else
{
if (mquant == 1)
dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3;
else if (mquant == 2)
dcdiff = (dcdiff<<1) + get_bits(gb, 1) - 1;
}
if (get_bits(gb, 1))
dcdiff = -dcdiff;
}
dcdiff += vc1_pred_dc(&v->s, v->overlap, mquant, n, a_avail, c_avail, &dc_val, &dc_pred_dir);
*dc_val = dcdiff;
if (n < 4) {
block[0] = dcdiff * s->y_dc_scale;
} else {
block[0] = dcdiff * s->c_dc_scale;
}
run_diff = 0;
i = 0;
if (!coded) {
goto not_coded;
}
i = 1;
{
int last = 0, skip, value;
const int8_t *zz_table;
int scale;
int k;
scale = mquant * 2 + v->halfpq;
zz_table = vc1_simple_progressive_8x8_zz;
ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
ac_val2 = ac_val;
if(dc_pred_dir)
ac_val -= 16;
else
ac_val -= 16 * s->block_wrap[n];
while (!last) {
vc1_decode_ac_coeff(v, &last, &skip, &value, codingset);
i += skip;
if(i > 63)
break;
block[zz_table[i++]] = value;
}
if(s->ac_pred) {
int mb_pos2, q1, q2;
mb_pos2 = mb_pos - dc_pred_dir - (1 - dc_pred_dir) * s->mb_stride;
q1 = s->current_picture.qscale_table[mb_pos];
q2 = s->current_picture.qscale_table[mb_pos2];
if(!c_avail) {
memset(ac_val, 0, 8 * sizeof(ac_val[0]));
dc_pred_dir = 0;
}
if(!a_avail) {
memset(ac_val + 8, 0, 8 * sizeof(ac_val[0]));
dc_pred_dir = 1;
}
if(!q1 && q1 && q2 && q1 != q2) {
q1 = q1 * 2 - 1;
q2 = q2 * 2 - 1;
if(dc_pred_dir) {
for(k = 1; k < 8; k++)
block[k << 3] += (ac_val[k] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18;
} else {
for(k = 1; k < 8; k++)
block[k] += (ac_val[k + 8] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
} else {
if(dc_pred_dir) {
for(k = 1; k < 8; k++)
block[k << 3] += ac_val[k];
} else {
for(k = 1; k < 8; k++)
block[k] += ac_val[k + 8];
}
}
}
for(k = 1; k < 8; k++) {
ac_val2[k] = block[k << 3];
ac_val2[k + 8] = block[k];
}
for(k = 1; k < 64; k++)
if(block[k]) {
block[k] *= scale;
if(!v->pquantizer)
block[k] += (block[k] < 0) ? -mquant : mquant;
}
if(s->ac_pred) i = 63;
}
not_coded:
if(!coded) {
int k, scale;
ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
ac_val2 = ac_val;
if(!c_avail) {
memset(ac_val, 0, 8 * sizeof(ac_val[0]));
dc_pred_dir = 0;
}
if(!a_avail) {
memset(ac_val + 8, 0, 8 * sizeof(ac_val[0]));
dc_pred_dir = 1;
}
scale = mquant * 2 + v->halfpq;
memset(ac_val2, 0, 16 * 2);
if(dc_pred_dir) {
ac_val -= 16;
if(s->ac_pred)
memcpy(ac_val2, ac_val, 8 * 2);
} else {
ac_val -= 16 * s->block_wrap[n];
if(s->ac_pred)
memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
}
if(s->ac_pred) {
if(dc_pred_dir) {
for(k = 1; k < 8; k++) {
block[k << 3] = ac_val[k] * scale;
if(!v->pquantizer)
block[k << 3] += (block[k << 3] < 0) ? -mquant : mquant;
}
} else {
for(k = 1; k < 8; k++) {
block[k] = ac_val[k + 8] * scale;
if(!v->pquantizer)
block[k] += (block[k] < 0) ? -mquant : mquant;
}
}
i = 63;
}
}
s->block_last_index[n] = i;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(VC1Context *VAR_0, DCTELEM VAR_1[64], int VAR_2, int VAR_3, int VAR_4, int VAR_5)
{
GetBitContext *gb = &VAR_0->s.gb;
MpegEncContext *s = &VAR_0->s;
int VAR_6 = 0;
int VAR_7, VAR_8;
int16_t *dc_val;
int16_t *ac_val, *ac_val2;
int VAR_9;
int VAR_10 = s->mb_x + s->mb_y * s->mb_stride;
int VAR_11, VAR_12;
VAR_4 = (VAR_4 < 1) ? 0 : ( (VAR_4>31) ? 31 : VAR_4 );
s->y_dc_scale = s->y_dc_scale_table[VAR_4];
s->c_dc_scale = s->c_dc_scale_table[VAR_4];
VAR_11 = VAR_12 = 0;
if((VAR_2 == 2 || VAR_2 == 3) || (s->mb_y && IS_INTRA(s->current_picture.mb_type[VAR_10 - s->mb_stride])))
VAR_11 = 1;
if((VAR_2 == 1 || VAR_2 == 3) || (s->mb_x && IS_INTRA(s->current_picture.mb_type[VAR_10 - 1])))
VAR_12 = 1;
if (VAR_2 < 4) {
VAR_9 = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
} else {
VAR_9 = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
}
if (VAR_9 < 0){
av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\VAR_2");
return -1;
}
if (VAR_9)
{
if (VAR_9 == 119 )
{
if (VAR_4 == 1) VAR_9 = get_bits(gb, 10);
else if (VAR_4 == 2) VAR_9 = get_bits(gb, 9);
else VAR_9 = get_bits(gb, 8);
}
else
{
if (VAR_4 == 1)
VAR_9 = (VAR_9<<2) + get_bits(gb, 2) - 3;
else if (VAR_4 == 2)
VAR_9 = (VAR_9<<1) + get_bits(gb, 1) - 1;
}
if (get_bits(gb, 1))
VAR_9 = -VAR_9;
}
VAR_9 += vc1_pred_dc(&VAR_0->s, VAR_0->overlap, VAR_4, VAR_2, VAR_11, VAR_12, &dc_val, &VAR_6);
*dc_val = VAR_9;
if (VAR_2 < 4) {
VAR_1[0] = VAR_9 * s->y_dc_scale;
} else {
VAR_1[0] = VAR_9 * s->c_dc_scale;
}
VAR_7 = 0;
VAR_8 = 0;
if (!VAR_3) {
goto not_coded;
}
VAR_8 = 1;
{
int VAR_13 = 0, VAR_14, VAR_15;
const int8_t *VAR_16;
int VAR_22;
int VAR_22;
VAR_22 = VAR_4 * 2 + VAR_0->halfpq;
VAR_16 = vc1_simple_progressive_8x8_zz;
ac_val = s->ac_val[0][0] + s->block_index[VAR_2] * 16;
ac_val2 = ac_val;
if(VAR_6)
ac_val -= 16;
else
ac_val -= 16 * s->block_wrap[VAR_2];
while (!VAR_13) {
vc1_decode_ac_coeff(VAR_0, &VAR_13, &VAR_14, &VAR_15, VAR_5);
VAR_8 += VAR_14;
if(VAR_8 > 63)
break;
VAR_1[VAR_16[VAR_8++]] = VAR_15;
}
if(s->ac_pred) {
int VAR_19, VAR_20, VAR_21;
VAR_19 = VAR_10 - VAR_6 - (1 - VAR_6) * s->mb_stride;
VAR_20 = s->current_picture.qscale_table[VAR_10];
VAR_21 = s->current_picture.qscale_table[VAR_19];
if(!VAR_12) {
memset(ac_val, 0, 8 * sizeof(ac_val[0]));
VAR_6 = 0;
}
if(!VAR_11) {
memset(ac_val + 8, 0, 8 * sizeof(ac_val[0]));
VAR_6 = 1;
}
if(!VAR_20 && VAR_20 && VAR_21 && VAR_20 != VAR_21) {
VAR_20 = VAR_20 * 2 - 1;
VAR_21 = VAR_21 * 2 - 1;
if(VAR_6) {
for(VAR_22 = 1; VAR_22 < 8; VAR_22++)
VAR_1[VAR_22 << 3] += (ac_val[VAR_22] * VAR_21 * vc1_dqscale[VAR_20 - 1] + 0x20000) >> 18;
} else {
for(VAR_22 = 1; VAR_22 < 8; VAR_22++)
VAR_1[VAR_22] += (ac_val[VAR_22 + 8] * VAR_21 * vc1_dqscale[VAR_20 - 1] + 0x20000) >> 18;
}
} else {
if(VAR_6) {
for(VAR_22 = 1; VAR_22 < 8; VAR_22++)
VAR_1[VAR_22 << 3] += ac_val[VAR_22];
} else {
for(VAR_22 = 1; VAR_22 < 8; VAR_22++)
VAR_1[VAR_22] += ac_val[VAR_22 + 8];
}
}
}
for(VAR_22 = 1; VAR_22 < 8; VAR_22++) {
ac_val2[VAR_22] = VAR_1[VAR_22 << 3];
ac_val2[VAR_22 + 8] = VAR_1[VAR_22];
}
for(VAR_22 = 1; VAR_22 < 64; VAR_22++)
if(VAR_1[VAR_22]) {
VAR_1[VAR_22] *= VAR_22;
if(!VAR_0->pquantizer)
VAR_1[VAR_22] += (VAR_1[VAR_22] < 0) ? -VAR_4 : VAR_4;
}
if(s->ac_pred) VAR_8 = 63;
}
not_coded:
if(!VAR_3) {
int VAR_22, VAR_22;
ac_val = s->ac_val[0][0] + s->block_index[VAR_2] * 16;
ac_val2 = ac_val;
if(!VAR_12) {
memset(ac_val, 0, 8 * sizeof(ac_val[0]));
VAR_6 = 0;
}
if(!VAR_11) {
memset(ac_val + 8, 0, 8 * sizeof(ac_val[0]));
VAR_6 = 1;
}
VAR_22 = VAR_4 * 2 + VAR_0->halfpq;
memset(ac_val2, 0, 16 * 2);
if(VAR_6) {
ac_val -= 16;
if(s->ac_pred)
memcpy(ac_val2, ac_val, 8 * 2);
} else {
ac_val -= 16 * s->block_wrap[VAR_2];
if(s->ac_pred)
memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
}
if(s->ac_pred) {
if(VAR_6) {
for(VAR_22 = 1; VAR_22 < 8; VAR_22++) {
VAR_1[VAR_22 << 3] = ac_val[VAR_22] * VAR_22;
if(!VAR_0->pquantizer)
VAR_1[VAR_22 << 3] += (VAR_1[VAR_22 << 3] < 0) ? -VAR_4 : VAR_4;
}
} else {
for(VAR_22 = 1; VAR_22 < 8; VAR_22++) {
VAR_1[VAR_22] = ac_val[VAR_22 + 8] * VAR_22;
if(!VAR_0->pquantizer)
VAR_1[VAR_22] += (VAR_1[VAR_22] < 0) ? -VAR_4 : VAR_4;
}
}
VAR_8 = 63;
}
}
s->block_last_index[VAR_2] = VAR_8;
return 0;
}
| [
"static int FUNC_0(VC1Context *VAR_0, DCTELEM VAR_1[64], int VAR_2, int VAR_3, int VAR_4, int VAR_5)\n{",
"GetBitContext *gb = &VAR_0->s.gb;",
"MpegEncContext *s = &VAR_0->s;",
"int VAR_6 = 0;",
"int VAR_7, VAR_8;",
"int16_t *dc_val;",
"int16_t *ac_val, *ac_val2;",
"int VAR_9;",
"int VAR_10 = s->mb_x + s->mb_y * s->mb_stride;",
"int VAR_11, VAR_12;",
"VAR_4 = (VAR_4 < 1) ? 0 : ( (VAR_4>31) ? 31 : VAR_4 );",
"s->y_dc_scale = s->y_dc_scale_table[VAR_4];",
"s->c_dc_scale = s->c_dc_scale_table[VAR_4];",
"VAR_11 = VAR_12 = 0;",
"if((VAR_2 == 2 || VAR_2 == 3) || (s->mb_y && IS_INTRA(s->current_picture.mb_type[VAR_10 - s->mb_stride])))\nVAR_11 = 1;",
"if((VAR_2 == 1 || VAR_2 == 3) || (s->mb_x && IS_INTRA(s->current_picture.mb_type[VAR_10 - 1])))\nVAR_12 = 1;",
"if (VAR_2 < 4) {",
"VAR_9 = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);",
"} else {",
"VAR_9 = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);",
"}",
"if (VAR_9 < 0){",
"av_log(s->avctx, AV_LOG_ERROR, \"Illegal DC VLC\\VAR_2\");",
"return -1;",
"}",
"if (VAR_9)\n{",
"if (VAR_9 == 119 )\n{",
"if (VAR_4 == 1) VAR_9 = get_bits(gb, 10);",
"else if (VAR_4 == 2) VAR_9 = get_bits(gb, 9);",
"else VAR_9 = get_bits(gb, 8);",
"}",
"else\n{",
"if (VAR_4 == 1)\nVAR_9 = (VAR_9<<2) + get_bits(gb, 2) - 3;",
"else if (VAR_4 == 2)\nVAR_9 = (VAR_9<<1) + get_bits(gb, 1) - 1;",
"}",
"if (get_bits(gb, 1))\nVAR_9 = -VAR_9;",
"}",
"VAR_9 += vc1_pred_dc(&VAR_0->s, VAR_0->overlap, VAR_4, VAR_2, VAR_11, VAR_12, &dc_val, &VAR_6);",
"*dc_val = VAR_9;",
"if (VAR_2 < 4) {",
"VAR_1[0] = VAR_9 * s->y_dc_scale;",
"} else {",
"VAR_1[0] = VAR_9 * s->c_dc_scale;",
"}",
"VAR_7 = 0;",
"VAR_8 = 0;",
"if (!VAR_3) {",
"goto not_coded;",
"}",
"VAR_8 = 1;",
"{",
"int VAR_13 = 0, VAR_14, VAR_15;",
"const int8_t *VAR_16;",
"int VAR_22;",
"int VAR_22;",
"VAR_22 = VAR_4 * 2 + VAR_0->halfpq;",
"VAR_16 = vc1_simple_progressive_8x8_zz;",
"ac_val = s->ac_val[0][0] + s->block_index[VAR_2] * 16;",
"ac_val2 = ac_val;",
"if(VAR_6)\nac_val -= 16;",
"else\nac_val -= 16 * s->block_wrap[VAR_2];",
"while (!VAR_13) {",
"vc1_decode_ac_coeff(VAR_0, &VAR_13, &VAR_14, &VAR_15, VAR_5);",
"VAR_8 += VAR_14;",
"if(VAR_8 > 63)\nbreak;",
"VAR_1[VAR_16[VAR_8++]] = VAR_15;",
"}",
"if(s->ac_pred) {",
"int VAR_19, VAR_20, VAR_21;",
"VAR_19 = VAR_10 - VAR_6 - (1 - VAR_6) * s->mb_stride;",
"VAR_20 = s->current_picture.qscale_table[VAR_10];",
"VAR_21 = s->current_picture.qscale_table[VAR_19];",
"if(!VAR_12) {",
"memset(ac_val, 0, 8 * sizeof(ac_val[0]));",
"VAR_6 = 0;",
"}",
"if(!VAR_11) {",
"memset(ac_val + 8, 0, 8 * sizeof(ac_val[0]));",
"VAR_6 = 1;",
"}",
"if(!VAR_20 && VAR_20 && VAR_21 && VAR_20 != VAR_21) {",
"VAR_20 = VAR_20 * 2 - 1;",
"VAR_21 = VAR_21 * 2 - 1;",
"if(VAR_6) {",
"for(VAR_22 = 1; VAR_22 < 8; VAR_22++)",
"VAR_1[VAR_22 << 3] += (ac_val[VAR_22] * VAR_21 * vc1_dqscale[VAR_20 - 1] + 0x20000) >> 18;",
"} else {",
"for(VAR_22 = 1; VAR_22 < 8; VAR_22++)",
"VAR_1[VAR_22] += (ac_val[VAR_22 + 8] * VAR_21 * vc1_dqscale[VAR_20 - 1] + 0x20000) >> 18;",
"}",
"} else {",
"if(VAR_6) {",
"for(VAR_22 = 1; VAR_22 < 8; VAR_22++)",
"VAR_1[VAR_22 << 3] += ac_val[VAR_22];",
"} else {",
"for(VAR_22 = 1; VAR_22 < 8; VAR_22++)",
"VAR_1[VAR_22] += ac_val[VAR_22 + 8];",
"}",
"}",
"}",
"for(VAR_22 = 1; VAR_22 < 8; VAR_22++) {",
"ac_val2[VAR_22] = VAR_1[VAR_22 << 3];",
"ac_val2[VAR_22 + 8] = VAR_1[VAR_22];",
"}",
"for(VAR_22 = 1; VAR_22 < 64; VAR_22++)",
"if(VAR_1[VAR_22]) {",
"VAR_1[VAR_22] *= VAR_22;",
"if(!VAR_0->pquantizer)\nVAR_1[VAR_22] += (VAR_1[VAR_22] < 0) ? -VAR_4 : VAR_4;",
"}",
"if(s->ac_pred) VAR_8 = 63;",
"}",
"not_coded:\nif(!VAR_3) {",
"int VAR_22, VAR_22;",
"ac_val = s->ac_val[0][0] + s->block_index[VAR_2] * 16;",
"ac_val2 = ac_val;",
"if(!VAR_12) {",
"memset(ac_val, 0, 8 * sizeof(ac_val[0]));",
"VAR_6 = 0;",
"}",
"if(!VAR_11) {",
"memset(ac_val + 8, 0, 8 * sizeof(ac_val[0]));",
"VAR_6 = 1;",
"}",
"VAR_22 = VAR_4 * 2 + VAR_0->halfpq;",
"memset(ac_val2, 0, 16 * 2);",
"if(VAR_6) {",
"ac_val -= 16;",
"if(s->ac_pred)\nmemcpy(ac_val2, ac_val, 8 * 2);",
"} else {",
"ac_val -= 16 * s->block_wrap[VAR_2];",
"if(s->ac_pred)\nmemcpy(ac_val2 + 8, ac_val + 8, 8 * 2);",
"}",
"if(s->ac_pred) {",
"if(VAR_6) {",
"for(VAR_22 = 1; VAR_22 < 8; VAR_22++) {",
"VAR_1[VAR_22 << 3] = ac_val[VAR_22] * VAR_22;",
"if(!VAR_0->pquantizer)\nVAR_1[VAR_22 << 3] += (VAR_1[VAR_22 << 3] < 0) ? -VAR_4 : VAR_4;",
"}",
"} else {",
"for(VAR_22 = 1; VAR_22 < 8; VAR_22++) {",
"VAR_1[VAR_22] = ac_val[VAR_22 + 8] * VAR_22;",
"if(!VAR_0->pquantizer)\nVAR_1[VAR_22] += (VAR_1[VAR_22] < 0) ? -VAR_4 : VAR_4;",
"}",
"}",
"VAR_8 = 63;",
"}",
"}",
"s->block_last_index[VAR_2] = VAR_8;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
27
],
[
33
],
[
35
],
[
41
],
[
43,
45
],
[
47,
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
75,
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89,
91
],
[
93,
95
],
[
97,
99
],
[
101
],
[
103,
105
],
[
107
],
[
113
],
[
115
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
149
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
165
],
[
169
],
[
173
],
[
175
],
[
177,
179
],
[
181,
183
],
[
187
],
[
189
],
[
191
],
[
193,
195
],
[
197
],
[
199
],
[
205
],
[
209
],
[
213
],
[
215
],
[
217
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
281
],
[
283
],
[
285
],
[
287
],
[
293
],
[
295
],
[
297
],
[
299,
301
],
[
303
],
[
307
],
[
309
],
[
313,
315
],
[
317
],
[
319
],
[
321
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351,
353
],
[
355
],
[
357
],
[
359,
361
],
[
363
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377,
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389,
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
407
],
[
409
]
] |
26,826 | static int vp3_decode_end(AVCodecContext *avctx)
{
Vp3DecodeContext *s = avctx->priv_data;
av_free(s->all_fragments);
av_free(s->coded_fragment_list);
av_free(s->superblock_fragments);
av_free(s->superblock_macroblocks);
av_free(s->macroblock_fragments);
av_free(s->macroblock_coded);
/* release all frames */
avctx->release_buffer(avctx, &s->golden_frame);
avctx->release_buffer(avctx, &s->last_frame);
avctx->release_buffer(avctx, &s->current_frame);
return 0;
}
| false | FFmpeg | 892fc83e88a20f9543c6c5be3626712be7a2e6f2 | static int vp3_decode_end(AVCodecContext *avctx)
{
Vp3DecodeContext *s = avctx->priv_data;
av_free(s->all_fragments);
av_free(s->coded_fragment_list);
av_free(s->superblock_fragments);
av_free(s->superblock_macroblocks);
av_free(s->macroblock_fragments);
av_free(s->macroblock_coded);
avctx->release_buffer(avctx, &s->golden_frame);
avctx->release_buffer(avctx, &s->last_frame);
avctx->release_buffer(avctx, &s->current_frame);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0)
{
Vp3DecodeContext *s = VAR_0->priv_data;
av_free(s->all_fragments);
av_free(s->coded_fragment_list);
av_free(s->superblock_fragments);
av_free(s->superblock_macroblocks);
av_free(s->macroblock_fragments);
av_free(s->macroblock_coded);
VAR_0->release_buffer(VAR_0, &s->golden_frame);
VAR_0->release_buffer(VAR_0, &s->last_frame);
VAR_0->release_buffer(VAR_0, &s->current_frame);
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0)\n{",
"Vp3DecodeContext *s = VAR_0->priv_data;",
"av_free(s->all_fragments);",
"av_free(s->coded_fragment_list);",
"av_free(s->superblock_fragments);",
"av_free(s->superblock_macroblocks);",
"av_free(s->macroblock_fragments);",
"av_free(s->macroblock_coded);",
"VAR_0->release_buffer(VAR_0, &s->golden_frame);",
"VAR_0->release_buffer(VAR_0, &s->last_frame);",
"VAR_0->release_buffer(VAR_0, &s->current_frame);",
"return 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
],
[
33
],
[
35
]
] |
26,827 | static uint64_t openpic_src_read(void *opaque, uint64_t addr, unsigned len)
{
OpenPICState *opp = opaque;
uint32_t retval;
int idx;
DPRINTF("%s: addr %08x\n", __func__, addr);
retval = 0xFFFFFFFF;
if (addr & 0xF) {
return retval;
}
addr = addr & 0xFFF0;
idx = addr >> 5;
if (addr & 0x10) {
/* EXDE / IFEDE / IEEDE */
retval = read_IRQreg_ide(opp, idx);
} else {
/* EXVP / IFEVP / IEEVP */
retval = read_IRQreg_ipvp(opp, idx);
}
DPRINTF("%s: => %08x\n", __func__, retval);
return retval;
}
| true | qemu | 4c4f0e4801ac79632d03867c88aafc90b4ce503c | static uint64_t openpic_src_read(void *opaque, uint64_t addr, unsigned len)
{
OpenPICState *opp = opaque;
uint32_t retval;
int idx;
DPRINTF("%s: addr %08x\n", __func__, addr);
retval = 0xFFFFFFFF;
if (addr & 0xF) {
return retval;
}
addr = addr & 0xFFF0;
idx = addr >> 5;
if (addr & 0x10) {
retval = read_IRQreg_ide(opp, idx);
} else {
retval = read_IRQreg_ipvp(opp, idx);
}
DPRINTF("%s: => %08x\n", __func__, retval);
return retval;
}
| {
"code": [
" DPRINTF(\"%s: => %08x\\n\", __func__, retval);",
" DPRINTF(\"%s: addr %08x\\n\", __func__, addr);",
" DPRINTF(\"%s: => %08x\\n\", __func__, retval);",
" DPRINTF(\"%s: addr %08x\\n\", __func__, addr);",
" DPRINTF(\"%s: => %08x\\n\", __func__, retval);",
" DPRINTF(\"%s: => %08x\\n\", __func__, retval);"
],
"line_no": [
41,
13,
41,
13,
41,
41
]
} | static uint64_t FUNC_0(void *opaque, uint64_t addr, unsigned len)
{
OpenPICState *opp = opaque;
uint32_t retval;
int VAR_0;
DPRINTF("%s: addr %08x\n", __func__, addr);
retval = 0xFFFFFFFF;
if (addr & 0xF) {
return retval;
}
addr = addr & 0xFFF0;
VAR_0 = addr >> 5;
if (addr & 0x10) {
retval = read_IRQreg_ide(opp, VAR_0);
} else {
retval = read_IRQreg_ipvp(opp, VAR_0);
}
DPRINTF("%s: => %08x\n", __func__, retval);
return retval;
}
| [
"static uint64_t FUNC_0(void *opaque, uint64_t addr, unsigned len)\n{",
"OpenPICState *opp = opaque;",
"uint32_t retval;",
"int VAR_0;",
"DPRINTF(\"%s: addr %08x\\n\", __func__, addr);",
"retval = 0xFFFFFFFF;",
"if (addr & 0xF) {",
"return retval;",
"}",
"addr = addr & 0xFFF0;",
"VAR_0 = addr >> 5;",
"if (addr & 0x10) {",
"retval = read_IRQreg_ide(opp, VAR_0);",
"} else {",
"retval = read_IRQreg_ipvp(opp, VAR_0);",
"}",
"DPRINTF(\"%s: => %08x\\n\", __func__, retval);",
"return retval;",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
]
] |
26,828 | SchroFrame *ff_create_schro_frame(AVCodecContext *avccontext,
SchroFrameFormat schro_frame_fmt)
{
AVPicture *p_pic;
SchroFrame *p_frame;
int y_width, uv_width;
int y_height, uv_height;
int i;
y_width = avccontext->width;
y_height = avccontext->height;
uv_width = y_width >> (SCHRO_FRAME_FORMAT_H_SHIFT(schro_frame_fmt));
uv_height = y_height >> (SCHRO_FRAME_FORMAT_V_SHIFT(schro_frame_fmt));
p_pic = av_mallocz(sizeof(AVPicture));
avpicture_alloc(p_pic, avccontext->pix_fmt, y_width, y_height);
p_frame = schro_frame_new();
p_frame->format = schro_frame_fmt;
p_frame->width = y_width;
p_frame->height = y_height;
schro_frame_set_free_callback(p_frame, free_schro_frame, (void *)p_pic);
for (i = 0; i < 3; ++i) {
p_frame->components[i].width = i ? uv_width : y_width;
p_frame->components[i].stride = p_pic->linesize[i];
p_frame->components[i].height = i ? uv_height : y_height;
p_frame->components[i].length =
p_frame->components[i].stride * p_frame->components[i].height;
p_frame->components[i].data = p_pic->data[i];
if (i) {
p_frame->components[i].v_shift =
SCHRO_FRAME_FORMAT_V_SHIFT(p_frame->format);
p_frame->components[i].h_shift =
SCHRO_FRAME_FORMAT_H_SHIFT(p_frame->format);
}
}
return p_frame;
}
| true | FFmpeg | 5793a6d9f9b35723f4aaeba68630f63b45d915f8 | SchroFrame *ff_create_schro_frame(AVCodecContext *avccontext,
SchroFrameFormat schro_frame_fmt)
{
AVPicture *p_pic;
SchroFrame *p_frame;
int y_width, uv_width;
int y_height, uv_height;
int i;
y_width = avccontext->width;
y_height = avccontext->height;
uv_width = y_width >> (SCHRO_FRAME_FORMAT_H_SHIFT(schro_frame_fmt));
uv_height = y_height >> (SCHRO_FRAME_FORMAT_V_SHIFT(schro_frame_fmt));
p_pic = av_mallocz(sizeof(AVPicture));
avpicture_alloc(p_pic, avccontext->pix_fmt, y_width, y_height);
p_frame = schro_frame_new();
p_frame->format = schro_frame_fmt;
p_frame->width = y_width;
p_frame->height = y_height;
schro_frame_set_free_callback(p_frame, free_schro_frame, (void *)p_pic);
for (i = 0; i < 3; ++i) {
p_frame->components[i].width = i ? uv_width : y_width;
p_frame->components[i].stride = p_pic->linesize[i];
p_frame->components[i].height = i ? uv_height : y_height;
p_frame->components[i].length =
p_frame->components[i].stride * p_frame->components[i].height;
p_frame->components[i].data = p_pic->data[i];
if (i) {
p_frame->components[i].v_shift =
SCHRO_FRAME_FORMAT_V_SHIFT(p_frame->format);
p_frame->components[i].h_shift =
SCHRO_FRAME_FORMAT_H_SHIFT(p_frame->format);
}
}
return p_frame;
}
| {
"code": [
" avpicture_alloc(p_pic, avccontext->pix_fmt, y_width, y_height);"
],
"line_no": [
31
]
} | SchroFrame *FUNC_0(AVCodecContext *avccontext,
SchroFrameFormat schro_frame_fmt)
{
AVPicture *p_pic;
SchroFrame *p_frame;
int VAR_0, VAR_1;
int VAR_2, VAR_3;
int VAR_4;
VAR_0 = avccontext->width;
VAR_2 = avccontext->height;
VAR_1 = VAR_0 >> (SCHRO_FRAME_FORMAT_H_SHIFT(schro_frame_fmt));
VAR_3 = VAR_2 >> (SCHRO_FRAME_FORMAT_V_SHIFT(schro_frame_fmt));
p_pic = av_mallocz(sizeof(AVPicture));
avpicture_alloc(p_pic, avccontext->pix_fmt, VAR_0, VAR_2);
p_frame = schro_frame_new();
p_frame->format = schro_frame_fmt;
p_frame->width = VAR_0;
p_frame->height = VAR_2;
schro_frame_set_free_callback(p_frame, free_schro_frame, (void *)p_pic);
for (VAR_4 = 0; VAR_4 < 3; ++VAR_4) {
p_frame->components[VAR_4].width = VAR_4 ? VAR_1 : VAR_0;
p_frame->components[VAR_4].stride = p_pic->linesize[VAR_4];
p_frame->components[VAR_4].height = VAR_4 ? VAR_3 : VAR_2;
p_frame->components[VAR_4].length =
p_frame->components[VAR_4].stride * p_frame->components[VAR_4].height;
p_frame->components[VAR_4].data = p_pic->data[VAR_4];
if (VAR_4) {
p_frame->components[VAR_4].v_shift =
SCHRO_FRAME_FORMAT_V_SHIFT(p_frame->format);
p_frame->components[VAR_4].h_shift =
SCHRO_FRAME_FORMAT_H_SHIFT(p_frame->format);
}
}
return p_frame;
}
| [
"SchroFrame *FUNC_0(AVCodecContext *avccontext,\nSchroFrameFormat schro_frame_fmt)\n{",
"AVPicture *p_pic;",
"SchroFrame *p_frame;",
"int VAR_0, VAR_1;",
"int VAR_2, VAR_3;",
"int VAR_4;",
"VAR_0 = avccontext->width;",
"VAR_2 = avccontext->height;",
"VAR_1 = VAR_0 >> (SCHRO_FRAME_FORMAT_H_SHIFT(schro_frame_fmt));",
"VAR_3 = VAR_2 >> (SCHRO_FRAME_FORMAT_V_SHIFT(schro_frame_fmt));",
"p_pic = av_mallocz(sizeof(AVPicture));",
"avpicture_alloc(p_pic, avccontext->pix_fmt, VAR_0, VAR_2);",
"p_frame = schro_frame_new();",
"p_frame->format = schro_frame_fmt;",
"p_frame->width = VAR_0;",
"p_frame->height = VAR_2;",
"schro_frame_set_free_callback(p_frame, free_schro_frame, (void *)p_pic);",
"for (VAR_4 = 0; VAR_4 < 3; ++VAR_4) {",
"p_frame->components[VAR_4].width = VAR_4 ? VAR_1 : VAR_0;",
"p_frame->components[VAR_4].stride = p_pic->linesize[VAR_4];",
"p_frame->components[VAR_4].height = VAR_4 ? VAR_3 : VAR_2;",
"p_frame->components[VAR_4].length =\np_frame->components[VAR_4].stride * p_frame->components[VAR_4].height;",
"p_frame->components[VAR_4].data = p_pic->data[VAR_4];",
"if (VAR_4) {",
"p_frame->components[VAR_4].v_shift =\nSCHRO_FRAME_FORMAT_V_SHIFT(p_frame->format);",
"p_frame->components[VAR_4].h_shift =\nSCHRO_FRAME_FORMAT_H_SHIFT(p_frame->format);",
"}",
"}",
"return p_frame;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
63
],
[
65,
67
],
[
69,
71
],
[
73
],
[
75
],
[
79
],
[
81
]
] |
26,829 | static int ffm_seek(AVFormatContext *s, int stream_index, int64_t wanted_pts, int flags)
{
FFMContext *ffm = s->priv_data;
int64_t pos_min, pos_max, pos;
int64_t pts_min, pts_max, pts;
double pos1;
av_dlog(s, "wanted_pts=%0.6f\n", wanted_pts / 1000000.0);
/* find the position using linear interpolation (better than
dichotomy in typical cases) */
if (ffm->write_index && ffm->write_index < ffm->file_size) {
if (get_dts(s, FFM_PACKET_SIZE) < wanted_pts) {
pos_min = FFM_PACKET_SIZE;
pos_max = ffm->write_index - FFM_PACKET_SIZE;
} else {
pos_min = ffm->write_index;
pos_max = ffm->file_size - FFM_PACKET_SIZE;
}
} else {
pos_min = FFM_PACKET_SIZE;
pos_max = ffm->file_size - FFM_PACKET_SIZE;
}
while (pos_min <= pos_max) {
pts_min = get_dts(s, pos_min);
pts_max = get_dts(s, pos_max);
if (pts_min > wanted_pts || pts_max <= wanted_pts) {
pos = pts_min > wanted_pts ? pos_min : pos_max;
goto found;
}
/* linear interpolation */
pos1 = (double)(pos_max - pos_min) * (double)(wanted_pts - pts_min) /
(double)(pts_max - pts_min);
pos = (((int64_t)pos1) / FFM_PACKET_SIZE) * FFM_PACKET_SIZE;
if (pos <= pos_min)
pos = pos_min;
else if (pos >= pos_max)
pos = pos_max;
pts = get_dts(s, pos);
/* check if we are lucky */
if (pts == wanted_pts) {
goto found;
} else if (pts > wanted_pts) {
pos_max = pos - FFM_PACKET_SIZE;
} else {
pos_min = pos + FFM_PACKET_SIZE;
}
}
pos = (flags & AVSEEK_FLAG_BACKWARD) ? pos_min : pos_max;
found:
if (ffm_seek1(s, pos) < 0)
return -1;
/* reset read state */
ffm->read_state = READ_HEADER;
ffm->packet_ptr = ffm->packet;
ffm->packet_end = ffm->packet;
ffm->first_packet = 1;
return 0;
}
| false | FFmpeg | 229843aa359ae0c9519977d7fa952688db63f559 | static int ffm_seek(AVFormatContext *s, int stream_index, int64_t wanted_pts, int flags)
{
FFMContext *ffm = s->priv_data;
int64_t pos_min, pos_max, pos;
int64_t pts_min, pts_max, pts;
double pos1;
av_dlog(s, "wanted_pts=%0.6f\n", wanted_pts / 1000000.0);
if (ffm->write_index && ffm->write_index < ffm->file_size) {
if (get_dts(s, FFM_PACKET_SIZE) < wanted_pts) {
pos_min = FFM_PACKET_SIZE;
pos_max = ffm->write_index - FFM_PACKET_SIZE;
} else {
pos_min = ffm->write_index;
pos_max = ffm->file_size - FFM_PACKET_SIZE;
}
} else {
pos_min = FFM_PACKET_SIZE;
pos_max = ffm->file_size - FFM_PACKET_SIZE;
}
while (pos_min <= pos_max) {
pts_min = get_dts(s, pos_min);
pts_max = get_dts(s, pos_max);
if (pts_min > wanted_pts || pts_max <= wanted_pts) {
pos = pts_min > wanted_pts ? pos_min : pos_max;
goto found;
}
pos1 = (double)(pos_max - pos_min) * (double)(wanted_pts - pts_min) /
(double)(pts_max - pts_min);
pos = (((int64_t)pos1) / FFM_PACKET_SIZE) * FFM_PACKET_SIZE;
if (pos <= pos_min)
pos = pos_min;
else if (pos >= pos_max)
pos = pos_max;
pts = get_dts(s, pos);
if (pts == wanted_pts) {
goto found;
} else if (pts > wanted_pts) {
pos_max = pos - FFM_PACKET_SIZE;
} else {
pos_min = pos + FFM_PACKET_SIZE;
}
}
pos = (flags & AVSEEK_FLAG_BACKWARD) ? pos_min : pos_max;
found:
if (ffm_seek1(s, pos) < 0)
return -1;
ffm->read_state = READ_HEADER;
ffm->packet_ptr = ffm->packet;
ffm->packet_end = ffm->packet;
ffm->first_packet = 1;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, int VAR_1, int64_t VAR_2, int VAR_3)
{
FFMContext *ffm = VAR_0->priv_data;
int64_t pos_min, pos_max, pos;
int64_t pts_min, pts_max, pts;
double VAR_4;
av_dlog(VAR_0, "VAR_2=%0.6f\n", VAR_2 / 1000000.0);
if (ffm->write_index && ffm->write_index < ffm->file_size) {
if (get_dts(VAR_0, FFM_PACKET_SIZE) < VAR_2) {
pos_min = FFM_PACKET_SIZE;
pos_max = ffm->write_index - FFM_PACKET_SIZE;
} else {
pos_min = ffm->write_index;
pos_max = ffm->file_size - FFM_PACKET_SIZE;
}
} else {
pos_min = FFM_PACKET_SIZE;
pos_max = ffm->file_size - FFM_PACKET_SIZE;
}
while (pos_min <= pos_max) {
pts_min = get_dts(VAR_0, pos_min);
pts_max = get_dts(VAR_0, pos_max);
if (pts_min > VAR_2 || pts_max <= VAR_2) {
pos = pts_min > VAR_2 ? pos_min : pos_max;
goto found;
}
VAR_4 = (double)(pos_max - pos_min) * (double)(VAR_2 - pts_min) /
(double)(pts_max - pts_min);
pos = (((int64_t)VAR_4) / FFM_PACKET_SIZE) * FFM_PACKET_SIZE;
if (pos <= pos_min)
pos = pos_min;
else if (pos >= pos_max)
pos = pos_max;
pts = get_dts(VAR_0, pos);
if (pts == VAR_2) {
goto found;
} else if (pts > VAR_2) {
pos_max = pos - FFM_PACKET_SIZE;
} else {
pos_min = pos + FFM_PACKET_SIZE;
}
}
pos = (VAR_3 & AVSEEK_FLAG_BACKWARD) ? pos_min : pos_max;
found:
if (ffm_seek1(VAR_0, pos) < 0)
return -1;
ffm->read_state = READ_HEADER;
ffm->packet_ptr = ffm->packet;
ffm->packet_end = ffm->packet;
ffm->first_packet = 1;
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, int VAR_1, int64_t VAR_2, int VAR_3)\n{",
"FFMContext *ffm = VAR_0->priv_data;",
"int64_t pos_min, pos_max, pos;",
"int64_t pts_min, pts_max, pts;",
"double VAR_4;",
"av_dlog(VAR_0, \"VAR_2=%0.6f\\n\", VAR_2 / 1000000.0);",
"if (ffm->write_index && ffm->write_index < ffm->file_size) {",
"if (get_dts(VAR_0, FFM_PACKET_SIZE) < VAR_2) {",
"pos_min = FFM_PACKET_SIZE;",
"pos_max = ffm->write_index - FFM_PACKET_SIZE;",
"} else {",
"pos_min = ffm->write_index;",
"pos_max = ffm->file_size - FFM_PACKET_SIZE;",
"}",
"} else {",
"pos_min = FFM_PACKET_SIZE;",
"pos_max = ffm->file_size - FFM_PACKET_SIZE;",
"}",
"while (pos_min <= pos_max) {",
"pts_min = get_dts(VAR_0, pos_min);",
"pts_max = get_dts(VAR_0, pos_max);",
"if (pts_min > VAR_2 || pts_max <= VAR_2) {",
"pos = pts_min > VAR_2 ? pos_min : pos_max;",
"goto found;",
"}",
"VAR_4 = (double)(pos_max - pos_min) * (double)(VAR_2 - pts_min) /\n(double)(pts_max - pts_min);",
"pos = (((int64_t)VAR_4) / FFM_PACKET_SIZE) * FFM_PACKET_SIZE;",
"if (pos <= pos_min)\npos = pos_min;",
"else if (pos >= pos_max)\npos = pos_max;",
"pts = get_dts(VAR_0, pos);",
"if (pts == VAR_2) {",
"goto found;",
"} else if (pts > VAR_2) {",
"pos_max = pos - FFM_PACKET_SIZE;",
"} else {",
"pos_min = pos + FFM_PACKET_SIZE;",
"}",
"}",
"pos = (VAR_3 & AVSEEK_FLAG_BACKWARD) ? pos_min : pos_max;",
"found:\nif (ffm_seek1(VAR_0, pos) < 0)\nreturn -1;",
"ffm->read_state = READ_HEADER;",
"ffm->packet_ptr = ffm->packet;",
"ffm->packet_end = ffm->packet;",
"ffm->first_packet = 1;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
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
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99,
101,
103
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
]
] |
26,830 | static void moxie_cpu_realizefn(DeviceState *dev, Error **errp)
{
MoxieCPU *cpu = MOXIE_CPU(dev);
MoxieCPUClass *mcc = MOXIE_CPU_GET_CLASS(dev);
cpu_reset(CPU(cpu));
mcc->parent_realize(dev, errp);
}
| true | qemu | 14a10fc39923b3af07c8c46d22cb20843bee3a72 | static void moxie_cpu_realizefn(DeviceState *dev, Error **errp)
{
MoxieCPU *cpu = MOXIE_CPU(dev);
MoxieCPUClass *mcc = MOXIE_CPU_GET_CLASS(dev);
cpu_reset(CPU(cpu));
mcc->parent_realize(dev, errp);
}
| {
"code": [
" cpu_reset(CPU(cpu));",
" cpu_reset(CPU(cpu));",
" cpu_reset(CPU(cpu));",
" cpu_reset(CPU(cpu));",
" cpu_reset(CPU(cpu));",
" cpu_reset(CPU(cpu));",
" cpu_reset(CPU(cpu));",
" MoxieCPU *cpu = MOXIE_CPU(dev);",
" cpu_reset(CPU(cpu));",
" cpu_reset(CPU(cpu));",
" cpu_reset(CPU(cpu));",
" cpu_reset(CPU(cpu));"
],
"line_no": [
11,
11,
11,
11,
11,
11,
11,
5,
11,
11,
11,
11
]
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
MoxieCPU *cpu = MOXIE_CPU(VAR_0);
MoxieCPUClass *mcc = MOXIE_CPU_GET_CLASS(VAR_0);
cpu_reset(CPU(cpu));
mcc->parent_realize(VAR_0, VAR_1);
}
| [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"MoxieCPU *cpu = MOXIE_CPU(VAR_0);",
"MoxieCPUClass *mcc = MOXIE_CPU_GET_CLASS(VAR_0);",
"cpu_reset(CPU(cpu));",
"mcc->parent_realize(VAR_0, VAR_1);",
"}"
] | [
0,
1,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
]
] |
26,831 | int ga_install_service(const char *path, const char *logfile)
{
SC_HANDLE manager;
SC_HANDLE service;
TCHAR cmdline[MAX_PATH];
if (GetModuleFileName(NULL, cmdline, MAX_PATH) == 0) {
printf_win_error("No full path to service's executable");
return EXIT_FAILURE;
}
_snprintf(cmdline, MAX_PATH - strlen(cmdline), "%s -d", cmdline);
if (path) {
_snprintf(cmdline, MAX_PATH - strlen(cmdline), "%s -p %s", cmdline, path);
}
if (logfile) {
_snprintf(cmdline, MAX_PATH - strlen(cmdline), "%s -l %s -v",
cmdline, logfile);
}
g_debug("service's cmdline: %s", cmdline);
manager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if (manager == NULL) {
printf_win_error("No handle to service control manager");
return EXIT_FAILURE;
}
service = CreateService(manager, QGA_SERVICE_NAME, QGA_SERVICE_DISPLAY_NAME,
SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START,
SERVICE_ERROR_NORMAL, cmdline, NULL, NULL, NULL, NULL, NULL);
if (service) {
SERVICE_DESCRIPTION desc = { (char *)QGA_SERVICE_DESCRIPTION };
ChangeServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, &desc);
printf("Service was installed successfully.\n");
} else {
printf_win_error("Failed to install service");
}
CloseServiceHandle(service);
CloseServiceHandle(manager);
return (service == NULL);
}
| true | qemu | a880845f3d92e508e43fcc38f0631b91c203e5d5 | int ga_install_service(const char *path, const char *logfile)
{
SC_HANDLE manager;
SC_HANDLE service;
TCHAR cmdline[MAX_PATH];
if (GetModuleFileName(NULL, cmdline, MAX_PATH) == 0) {
printf_win_error("No full path to service's executable");
return EXIT_FAILURE;
}
_snprintf(cmdline, MAX_PATH - strlen(cmdline), "%s -d", cmdline);
if (path) {
_snprintf(cmdline, MAX_PATH - strlen(cmdline), "%s -p %s", cmdline, path);
}
if (logfile) {
_snprintf(cmdline, MAX_PATH - strlen(cmdline), "%s -l %s -v",
cmdline, logfile);
}
g_debug("service's cmdline: %s", cmdline);
manager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if (manager == NULL) {
printf_win_error("No handle to service control manager");
return EXIT_FAILURE;
}
service = CreateService(manager, QGA_SERVICE_NAME, QGA_SERVICE_DISPLAY_NAME,
SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START,
SERVICE_ERROR_NORMAL, cmdline, NULL, NULL, NULL, NULL, NULL);
if (service) {
SERVICE_DESCRIPTION desc = { (char *)QGA_SERVICE_DESCRIPTION };
ChangeServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, &desc);
printf("Service was installed successfully.\n");
} else {
printf_win_error("Failed to install service");
}
CloseServiceHandle(service);
CloseServiceHandle(manager);
return (service == NULL);
}
| {
"code": [
" TCHAR cmdline[MAX_PATH];",
" if (GetModuleFileName(NULL, cmdline, MAX_PATH) == 0) {",
" _snprintf(cmdline, MAX_PATH - strlen(cmdline), \"%s -d\", cmdline);",
" _snprintf(cmdline, MAX_PATH - strlen(cmdline), \"%s -p %s\", cmdline, path);",
" _snprintf(cmdline, MAX_PATH - strlen(cmdline), \"%s -l %s -v\",",
" cmdline, logfile);",
" g_debug(\"service's cmdline: %s\", cmdline);",
" SERVICE_ERROR_NORMAL, cmdline, NULL, NULL, NULL, NULL, NULL);"
],
"line_no": [
9,
13,
23,
29,
35,
37,
43,
63
]
} | int FUNC_0(const char *VAR_0, const char *VAR_1)
{
SC_HANDLE manager;
SC_HANDLE service;
TCHAR cmdline[MAX_PATH];
if (GetModuleFileName(NULL, cmdline, MAX_PATH) == 0) {
printf_win_error("No full VAR_0 to service's executable");
return EXIT_FAILURE;
}
_snprintf(cmdline, MAX_PATH - strlen(cmdline), "%s -d", cmdline);
if (VAR_0) {
_snprintf(cmdline, MAX_PATH - strlen(cmdline), "%s -p %s", cmdline, VAR_0);
}
if (VAR_1) {
_snprintf(cmdline, MAX_PATH - strlen(cmdline), "%s -l %s -v",
cmdline, VAR_1);
}
g_debug("service's cmdline: %s", cmdline);
manager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if (manager == NULL) {
printf_win_error("No handle to service control manager");
return EXIT_FAILURE;
}
service = CreateService(manager, QGA_SERVICE_NAME, QGA_SERVICE_DISPLAY_NAME,
SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START,
SERVICE_ERROR_NORMAL, cmdline, NULL, NULL, NULL, NULL, NULL);
if (service) {
SERVICE_DESCRIPTION desc = { (char *)QGA_SERVICE_DESCRIPTION };
ChangeServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, &desc);
printf("Service was installed successfully.\n");
} else {
printf_win_error("Failed to install service");
}
CloseServiceHandle(service);
CloseServiceHandle(manager);
return (service == NULL);
}
| [
"int FUNC_0(const char *VAR_0, const char *VAR_1)\n{",
"SC_HANDLE manager;",
"SC_HANDLE service;",
"TCHAR cmdline[MAX_PATH];",
"if (GetModuleFileName(NULL, cmdline, MAX_PATH) == 0) {",
"printf_win_error(\"No full VAR_0 to service's executable\");",
"return EXIT_FAILURE;",
"}",
"_snprintf(cmdline, MAX_PATH - strlen(cmdline), \"%s -d\", cmdline);",
"if (VAR_0) {",
"_snprintf(cmdline, MAX_PATH - strlen(cmdline), \"%s -p %s\", cmdline, VAR_0);",
"}",
"if (VAR_1) {",
"_snprintf(cmdline, MAX_PATH - strlen(cmdline), \"%s -l %s -v\",\ncmdline, VAR_1);",
"}",
"g_debug(\"service's cmdline: %s\", cmdline);",
"manager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);",
"if (manager == NULL) {",
"printf_win_error(\"No handle to service control manager\");",
"return EXIT_FAILURE;",
"}",
"service = CreateService(manager, QGA_SERVICE_NAME, QGA_SERVICE_DISPLAY_NAME,\nSERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START,\nSERVICE_ERROR_NORMAL, cmdline, NULL, NULL, NULL, NULL, NULL);",
"if (service) {",
"SERVICE_DESCRIPTION desc = { (char *)QGA_SERVICE_DESCRIPTION };",
"ChangeServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, &desc);",
"printf(\"Service was installed successfully.\\n\");",
"} else {",
"printf_win_error(\"Failed to install service\");",
"}",
"CloseServiceHandle(service);",
"CloseServiceHandle(manager);",
"return (service == NULL);",
"}"
] | [
0,
0,
0,
1,
1,
0,
0,
0,
1,
0,
1,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59,
61,
63
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
91
],
[
93
]
] |
26,832 | static inline void RENAME(rgb16tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
{
const uint16_t *end;
const uint16_t *mm_end;
uint8_t *d = (uint8_t *)dst;
const uint16_t *s = (const uint16_t *)src;
end = s + src_size/2;
__asm__ volatile(PREFETCH" %0"::"m"(*s):"memory");
mm_end = end - 7;
while (s < mm_end) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq %1, %%mm1 \n\t"
"movq %1, %%mm2 \n\t"
"pand %2, %%mm0 \n\t"
"pand %3, %%mm1 \n\t"
"pand %4, %%mm2 \n\t"
"psllq $3, %%mm0 \n\t"
"psrlq $3, %%mm1 \n\t"
"psrlq $8, %%mm2 \n\t"
"movq %%mm0, %%mm3 \n\t"
"movq %%mm1, %%mm4 \n\t"
"movq %%mm2, %%mm5 \n\t"
"punpcklwd %5, %%mm0 \n\t"
"punpcklwd %5, %%mm1 \n\t"
"punpcklwd %5, %%mm2 \n\t"
"punpckhwd %5, %%mm3 \n\t"
"punpckhwd %5, %%mm4 \n\t"
"punpckhwd %5, %%mm5 \n\t"
"psllq $8, %%mm1 \n\t"
"psllq $16, %%mm2 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm2, %%mm0 \n\t"
"psllq $8, %%mm4 \n\t"
"psllq $16, %%mm5 \n\t"
"por %%mm4, %%mm3 \n\t"
"por %%mm5, %%mm3 \n\t"
"movq %%mm0, %%mm6 \n\t"
"movq %%mm3, %%mm7 \n\t"
"movq 8%1, %%mm0 \n\t"
"movq 8%1, %%mm1 \n\t"
"movq 8%1, %%mm2 \n\t"
"pand %2, %%mm0 \n\t"
"pand %3, %%mm1 \n\t"
"pand %4, %%mm2 \n\t"
"psllq $3, %%mm0 \n\t"
"psrlq $3, %%mm1 \n\t"
"psrlq $8, %%mm2 \n\t"
"movq %%mm0, %%mm3 \n\t"
"movq %%mm1, %%mm4 \n\t"
"movq %%mm2, %%mm5 \n\t"
"punpcklwd %5, %%mm0 \n\t"
"punpcklwd %5, %%mm1 \n\t"
"punpcklwd %5, %%mm2 \n\t"
"punpckhwd %5, %%mm3 \n\t"
"punpckhwd %5, %%mm4 \n\t"
"punpckhwd %5, %%mm5 \n\t"
"psllq $8, %%mm1 \n\t"
"psllq $16, %%mm2 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm2, %%mm0 \n\t"
"psllq $8, %%mm4 \n\t"
"psllq $16, %%mm5 \n\t"
"por %%mm4, %%mm3 \n\t"
"por %%mm5, %%mm3 \n\t"
:"=m"(*d)
:"m"(*s),"m"(mask16b),"m"(mask16g),"m"(mask16r),"m"(mmx_null)
:"memory");
/* borrowed 32 to 24 */
__asm__ volatile(
"movq %%mm0, %%mm4 \n\t"
"movq %%mm3, %%mm5 \n\t"
"movq %%mm6, %%mm0 \n\t"
"movq %%mm7, %%mm1 \n\t"
"movq %%mm4, %%mm6 \n\t"
"movq %%mm5, %%mm7 \n\t"
"movq %%mm0, %%mm2 \n\t"
"movq %%mm1, %%mm3 \n\t"
STORE_BGR24_MMX
:"=m"(*d)
:"m"(*s)
:"memory");
d += 24;
s += 8;
}
__asm__ volatile(SFENCE:::"memory");
__asm__ volatile(EMMS:::"memory");
while (s < end) {
register uint16_t bgr;
bgr = *s++;
*d++ = (bgr&0x1F)<<3;
*d++ = (bgr&0x7E0)>>3;
*d++ = (bgr&0xF800)>>8;
}
}
| true | FFmpeg | 90540c2d5ace46a1e9789c75fde0b1f7dbb12a9b | static inline void RENAME(rgb16tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
{
const uint16_t *end;
const uint16_t *mm_end;
uint8_t *d = (uint8_t *)dst;
const uint16_t *s = (const uint16_t *)src;
end = s + src_size/2;
__asm__ volatile(PREFETCH" %0"::"m"(*s):"memory");
mm_end = end - 7;
while (s < mm_end) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq %1, %%mm1 \n\t"
"movq %1, %%mm2 \n\t"
"pand %2, %%mm0 \n\t"
"pand %3, %%mm1 \n\t"
"pand %4, %%mm2 \n\t"
"psllq $3, %%mm0 \n\t"
"psrlq $3, %%mm1 \n\t"
"psrlq $8, %%mm2 \n\t"
"movq %%mm0, %%mm3 \n\t"
"movq %%mm1, %%mm4 \n\t"
"movq %%mm2, %%mm5 \n\t"
"punpcklwd %5, %%mm0 \n\t"
"punpcklwd %5, %%mm1 \n\t"
"punpcklwd %5, %%mm2 \n\t"
"punpckhwd %5, %%mm3 \n\t"
"punpckhwd %5, %%mm4 \n\t"
"punpckhwd %5, %%mm5 \n\t"
"psllq $8, %%mm1 \n\t"
"psllq $16, %%mm2 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm2, %%mm0 \n\t"
"psllq $8, %%mm4 \n\t"
"psllq $16, %%mm5 \n\t"
"por %%mm4, %%mm3 \n\t"
"por %%mm5, %%mm3 \n\t"
"movq %%mm0, %%mm6 \n\t"
"movq %%mm3, %%mm7 \n\t"
"movq 8%1, %%mm0 \n\t"
"movq 8%1, %%mm1 \n\t"
"movq 8%1, %%mm2 \n\t"
"pand %2, %%mm0 \n\t"
"pand %3, %%mm1 \n\t"
"pand %4, %%mm2 \n\t"
"psllq $3, %%mm0 \n\t"
"psrlq $3, %%mm1 \n\t"
"psrlq $8, %%mm2 \n\t"
"movq %%mm0, %%mm3 \n\t"
"movq %%mm1, %%mm4 \n\t"
"movq %%mm2, %%mm5 \n\t"
"punpcklwd %5, %%mm0 \n\t"
"punpcklwd %5, %%mm1 \n\t"
"punpcklwd %5, %%mm2 \n\t"
"punpckhwd %5, %%mm3 \n\t"
"punpckhwd %5, %%mm4 \n\t"
"punpckhwd %5, %%mm5 \n\t"
"psllq $8, %%mm1 \n\t"
"psllq $16, %%mm2 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm2, %%mm0 \n\t"
"psllq $8, %%mm4 \n\t"
"psllq $16, %%mm5 \n\t"
"por %%mm4, %%mm3 \n\t"
"por %%mm5, %%mm3 \n\t"
:"=m"(*d)
:"m"(*s),"m"(mask16b),"m"(mask16g),"m"(mask16r),"m"(mmx_null)
:"memory");
__asm__ volatile(
"movq %%mm0, %%mm4 \n\t"
"movq %%mm3, %%mm5 \n\t"
"movq %%mm6, %%mm0 \n\t"
"movq %%mm7, %%mm1 \n\t"
"movq %%mm4, %%mm6 \n\t"
"movq %%mm5, %%mm7 \n\t"
"movq %%mm0, %%mm2 \n\t"
"movq %%mm1, %%mm3 \n\t"
STORE_BGR24_MMX
:"=m"(*d)
:"m"(*s)
:"memory");
d += 24;
s += 8;
}
__asm__ volatile(SFENCE:::"memory");
__asm__ volatile(EMMS:::"memory");
while (s < end) {
register uint16_t bgr;
bgr = *s++;
*d++ = (bgr&0x1F)<<3;
*d++ = (bgr&0x7E0)>>3;
*d++ = (bgr&0xF800)>>8;
}
}
| {
"code": [
" PREFETCH\" 32%1 \\n\\t\"",
" :\"m\"(*s)",
" PREFETCH\" 32%1 \\n\\t\"",
" \"movq %1, %%mm0 \\n\\t\"",
" \"movq 8%1, %%mm1 \\n\\t\"",
" :\"m\"(*s)",
" :\"=m\"(*d)",
" :\"m\"(*s)",
" :\"=m\"(*d)",
" :\"m\"(*s)",
" PREFETCH\" 32%1 \\n\\t\"",
" PREFETCH\" 32%1 \\n\\t\"",
" PREFETCH\" 32%1 \\n\\t\"",
" PREFETCH\" 32%1 \\n\\t\"",
" PREFETCH\" 32%1 \\n\\t\"",
" PREFETCH\" 32%1 \\n\\t\"",
" \"movq %1, %%mm0 \\n\\t\"",
" \"movq %1, %%mm1 \\n\\t\"",
" \"movq %1, %%mm2 \\n\\t\"",
" \"movq 8%1, %%mm0 \\n\\t\"",
" \"movq 8%1, %%mm1 \\n\\t\"",
" \"movq 8%1, %%mm2 \\n\\t\"",
" :\"=m\"(*d)",
" :\"m\"(*s)",
" PREFETCH\" 32%1 \\n\\t\"",
" \"movq %1, %%mm0 \\n\\t\"",
" \"movq %1, %%mm1 \\n\\t\"",
" \"movq %1, %%mm2 \\n\\t\"",
" \"movq 8%1, %%mm0 \\n\\t\"",
" \"movq 8%1, %%mm1 \\n\\t\"",
" \"movq 8%1, %%mm2 \\n\\t\"",
" :\"m\"(*s),\"m\"(mask16b),\"m\"(mask16g),\"m\"(mask16r),\"m\"(mmx_null)",
" :\"=m\"(*d)",
" :\"m\"(*s)",
" PREFETCH\" 32%1 \\n\\t\"",
" \"movq %1, %%mm0 \\n\\t\"",
" \"movq %1, %%mm1 \\n\\t\"",
" \"movq %1, %%mm2 \\n\\t\"",
" :\"=m\"(*d)",
" PREFETCH\" 32%1 \\n\\t\"",
" \"movq %1, %%mm0 \\n\\t\"",
" \"movq %1, %%mm1 \\n\\t\"",
" \"movq %1, %%mm2 \\n\\t\"",
" :\"=m\"(*d)"
],
"line_no": [
23,
173,
23,
25,
87,
173,
137,
173,
137,
173,
23,
23,
23,
23,
23,
23,
25,
27,
29,
85,
87,
89,
137,
173,
23,
25,
27,
29,
85,
87,
89,
139,
137,
173,
23,
25,
27,
29,
137,
23,
25,
27,
29,
137
]
} | static inline void FUNC_0(rgb16tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
{
const uint16_t *VAR_0;
const uint16_t *VAR_1;
uint8_t *d = (uint8_t *)dst;
const uint16_t *VAR_2 = (const uint16_t *)src;
VAR_0 = VAR_2 + src_size/2;
__asm__ volatile(PREFETCH" %0"::"m"(*VAR_2):"memory");
VAR_1 = VAR_0 - 7;
while (VAR_2 < VAR_1) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq %1, %%mm1 \n\t"
"movq %1, %%mm2 \n\t"
"pand %2, %%mm0 \n\t"
"pand %3, %%mm1 \n\t"
"pand %4, %%mm2 \n\t"
"psllq $3, %%mm0 \n\t"
"psrlq $3, %%mm1 \n\t"
"psrlq $8, %%mm2 \n\t"
"movq %%mm0, %%mm3 \n\t"
"movq %%mm1, %%mm4 \n\t"
"movq %%mm2, %%mm5 \n\t"
"punpcklwd %5, %%mm0 \n\t"
"punpcklwd %5, %%mm1 \n\t"
"punpcklwd %5, %%mm2 \n\t"
"punpckhwd %5, %%mm3 \n\t"
"punpckhwd %5, %%mm4 \n\t"
"punpckhwd %5, %%mm5 \n\t"
"psllq $8, %%mm1 \n\t"
"psllq $16, %%mm2 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm2, %%mm0 \n\t"
"psllq $8, %%mm4 \n\t"
"psllq $16, %%mm5 \n\t"
"por %%mm4, %%mm3 \n\t"
"por %%mm5, %%mm3 \n\t"
"movq %%mm0, %%mm6 \n\t"
"movq %%mm3, %%mm7 \n\t"
"movq 8%1, %%mm0 \n\t"
"movq 8%1, %%mm1 \n\t"
"movq 8%1, %%mm2 \n\t"
"pand %2, %%mm0 \n\t"
"pand %3, %%mm1 \n\t"
"pand %4, %%mm2 \n\t"
"psllq $3, %%mm0 \n\t"
"psrlq $3, %%mm1 \n\t"
"psrlq $8, %%mm2 \n\t"
"movq %%mm0, %%mm3 \n\t"
"movq %%mm1, %%mm4 \n\t"
"movq %%mm2, %%mm5 \n\t"
"punpcklwd %5, %%mm0 \n\t"
"punpcklwd %5, %%mm1 \n\t"
"punpcklwd %5, %%mm2 \n\t"
"punpckhwd %5, %%mm3 \n\t"
"punpckhwd %5, %%mm4 \n\t"
"punpckhwd %5, %%mm5 \n\t"
"psllq $8, %%mm1 \n\t"
"psllq $16, %%mm2 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm2, %%mm0 \n\t"
"psllq $8, %%mm4 \n\t"
"psllq $16, %%mm5 \n\t"
"por %%mm4, %%mm3 \n\t"
"por %%mm5, %%mm3 \n\t"
:"=m"(*d)
:"m"(*VAR_2),"m"(mask16b),"m"(mask16g),"m"(mask16r),"m"(mmx_null)
:"memory");
__asm__ volatile(
"movq %%mm0, %%mm4 \n\t"
"movq %%mm3, %%mm5 \n\t"
"movq %%mm6, %%mm0 \n\t"
"movq %%mm7, %%mm1 \n\t"
"movq %%mm4, %%mm6 \n\t"
"movq %%mm5, %%mm7 \n\t"
"movq %%mm0, %%mm2 \n\t"
"movq %%mm1, %%mm3 \n\t"
STORE_BGR24_MMX
:"=m"(*d)
:"m"(*VAR_2)
:"memory");
d += 24;
VAR_2 += 8;
}
__asm__ volatile(SFENCE:::"memory");
__asm__ volatile(EMMS:::"memory");
while (VAR_2 < VAR_0) {
register uint16_t VAR_3;
VAR_3 = *VAR_2++;
*d++ = (VAR_3&0x1F)<<3;
*d++ = (VAR_3&0x7E0)>>3;
*d++ = (VAR_3&0xF800)>>8;
}
}
| [
"static inline void FUNC_0(rgb16tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)\n{",
"const uint16_t *VAR_0;",
"const uint16_t *VAR_1;",
"uint8_t *d = (uint8_t *)dst;",
"const uint16_t *VAR_2 = (const uint16_t *)src;",
"VAR_0 = VAR_2 + src_size/2;",
"__asm__ volatile(PREFETCH\" %0\"::\"m\"(*VAR_2):\"memory\");",
"VAR_1 = VAR_0 - 7;",
"while (VAR_2 < VAR_1) {",
"__asm__ volatile(\nPREFETCH\" 32%1 \\n\\t\"\n\"movq %1, %%mm0 \\n\\t\"\n\"movq %1, %%mm1 \\n\\t\"\n\"movq %1, %%mm2 \\n\\t\"\n\"pand %2, %%mm0 \\n\\t\"\n\"pand %3, %%mm1 \\n\\t\"\n\"pand %4, %%mm2 \\n\\t\"\n\"psllq $3, %%mm0 \\n\\t\"\n\"psrlq $3, %%mm1 \\n\\t\"\n\"psrlq $8, %%mm2 \\n\\t\"\n\"movq %%mm0, %%mm3 \\n\\t\"\n\"movq %%mm1, %%mm4 \\n\\t\"\n\"movq %%mm2, %%mm5 \\n\\t\"\n\"punpcklwd %5, %%mm0 \\n\\t\"\n\"punpcklwd %5, %%mm1 \\n\\t\"\n\"punpcklwd %5, %%mm2 \\n\\t\"\n\"punpckhwd %5, %%mm3 \\n\\t\"\n\"punpckhwd %5, %%mm4 \\n\\t\"\n\"punpckhwd %5, %%mm5 \\n\\t\"\n\"psllq $8, %%mm1 \\n\\t\"\n\"psllq $16, %%mm2 \\n\\t\"\n\"por %%mm1, %%mm0 \\n\\t\"\n\"por %%mm2, %%mm0 \\n\\t\"\n\"psllq $8, %%mm4 \\n\\t\"\n\"psllq $16, %%mm5 \\n\\t\"\n\"por %%mm4, %%mm3 \\n\\t\"\n\"por %%mm5, %%mm3 \\n\\t\"\n\"movq %%mm0, %%mm6 \\n\\t\"\n\"movq %%mm3, %%mm7 \\n\\t\"\n\"movq 8%1, %%mm0 \\n\\t\"\n\"movq 8%1, %%mm1 \\n\\t\"\n\"movq 8%1, %%mm2 \\n\\t\"\n\"pand %2, %%mm0 \\n\\t\"\n\"pand %3, %%mm1 \\n\\t\"\n\"pand %4, %%mm2 \\n\\t\"\n\"psllq $3, %%mm0 \\n\\t\"\n\"psrlq $3, %%mm1 \\n\\t\"\n\"psrlq $8, %%mm2 \\n\\t\"\n\"movq %%mm0, %%mm3 \\n\\t\"\n\"movq %%mm1, %%mm4 \\n\\t\"\n\"movq %%mm2, %%mm5 \\n\\t\"\n\"punpcklwd %5, %%mm0 \\n\\t\"\n\"punpcklwd %5, %%mm1 \\n\\t\"\n\"punpcklwd %5, %%mm2 \\n\\t\"\n\"punpckhwd %5, %%mm3 \\n\\t\"\n\"punpckhwd %5, %%mm4 \\n\\t\"\n\"punpckhwd %5, %%mm5 \\n\\t\"\n\"psllq $8, %%mm1 \\n\\t\"\n\"psllq $16, %%mm2 \\n\\t\"\n\"por %%mm1, %%mm0 \\n\\t\"\n\"por %%mm2, %%mm0 \\n\\t\"\n\"psllq $8, %%mm4 \\n\\t\"\n\"psllq $16, %%mm5 \\n\\t\"\n\"por %%mm4, %%mm3 \\n\\t\"\n\"por %%mm5, %%mm3 \\n\\t\"\n:\"=m\"(*d)\n:\"m\"(*VAR_2),\"m\"(mask16b),\"m\"(mask16g),\"m\"(mask16r),\"m\"(mmx_null)\n:\"memory\");",
"__asm__ volatile(\n\"movq %%mm0, %%mm4 \\n\\t\"\n\"movq %%mm3, %%mm5 \\n\\t\"\n\"movq %%mm6, %%mm0 \\n\\t\"\n\"movq %%mm7, %%mm1 \\n\\t\"\n\"movq %%mm4, %%mm6 \\n\\t\"\n\"movq %%mm5, %%mm7 \\n\\t\"\n\"movq %%mm0, %%mm2 \\n\\t\"\n\"movq %%mm1, %%mm3 \\n\\t\"\nSTORE_BGR24_MMX\n:\"=m\"(*d)\n:\"m\"(*VAR_2)\n:\"memory\");",
"d += 24;",
"VAR_2 += 8;",
"}",
"__asm__ volatile(SFENCE:::\"memory\");",
"__asm__ volatile(EMMS:::\"memory\");",
"while (VAR_2 < VAR_0) {",
"register uint16_t VAR_3;",
"VAR_3 = *VAR_2++;",
"*d++ = (VAR_3&0x1F)<<3;",
"*d++ = (VAR_3&0x7E0)>>3;",
"*d++ = (VAR_3&0xF800)>>8;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
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,
79,
81,
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,
153,
157,
159,
161,
163,
167,
171,
173,
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
]
] |
26,833 | static void thread_pool_cancel(BlockDriverAIOCB *acb)
{
ThreadPoolElement *elem = (ThreadPoolElement *)acb;
ThreadPool *pool = elem->pool;
trace_thread_pool_cancel(elem, elem->common.opaque);
qemu_mutex_lock(&pool->lock);
if (elem->state == THREAD_QUEUED &&
/* No thread has yet started working on elem. we can try to "steal"
* the item from the worker if we can get a signal from the
* semaphore. Because this is non-blocking, we can do it with
* the lock taken and ensure that elem will remain THREAD_QUEUED.
*/
qemu_sem_timedwait(&pool->sem, 0) == 0) {
QTAILQ_REMOVE(&pool->request_list, elem, reqs);
elem->state = THREAD_CANCELED;
event_notifier_set(&pool->notifier);
} else {
pool->pending_cancellations++;
while (elem->state != THREAD_CANCELED && elem->state != THREAD_DONE) {
qemu_cond_wait(&pool->check_cancel, &pool->lock);
}
pool->pending_cancellations--;
}
qemu_mutex_unlock(&pool->lock);
} | true | qemu | 271c0f68b4eae72691721243a1c37f46a3232d61 | static void thread_pool_cancel(BlockDriverAIOCB *acb)
{
ThreadPoolElement *elem = (ThreadPoolElement *)acb;
ThreadPool *pool = elem->pool;
trace_thread_pool_cancel(elem, elem->common.opaque);
qemu_mutex_lock(&pool->lock);
if (elem->state == THREAD_QUEUED &&
qemu_sem_timedwait(&pool->sem, 0) == 0) {
QTAILQ_REMOVE(&pool->request_list, elem, reqs);
elem->state = THREAD_CANCELED;
event_notifier_set(&pool->notifier);
} else {
pool->pending_cancellations++;
while (elem->state != THREAD_CANCELED && elem->state != THREAD_DONE) {
qemu_cond_wait(&pool->check_cancel, &pool->lock);
}
pool->pending_cancellations--;
}
qemu_mutex_unlock(&pool->lock);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(BlockDriverAIOCB *VAR_0)
{
ThreadPoolElement *elem = (ThreadPoolElement *)VAR_0;
ThreadPool *pool = elem->pool;
trace_thread_pool_cancel(elem, elem->common.opaque);
qemu_mutex_lock(&pool->lock);
if (elem->state == THREAD_QUEUED &&
qemu_sem_timedwait(&pool->sem, 0) == 0) {
QTAILQ_REMOVE(&pool->request_list, elem, reqs);
elem->state = THREAD_CANCELED;
event_notifier_set(&pool->notifier);
} else {
pool->pending_cancellations++;
while (elem->state != THREAD_CANCELED && elem->state != THREAD_DONE) {
qemu_cond_wait(&pool->check_cancel, &pool->lock);
}
pool->pending_cancellations--;
}
qemu_mutex_unlock(&pool->lock);
} | [
"static void FUNC_0(BlockDriverAIOCB *VAR_0)\n{",
"ThreadPoolElement *elem = (ThreadPoolElement *)VAR_0;",
"ThreadPool *pool = elem->pool;",
"trace_thread_pool_cancel(elem, elem->common.opaque);",
"qemu_mutex_lock(&pool->lock);",
"if (elem->state == THREAD_QUEUED &&\nqemu_sem_timedwait(&pool->sem, 0) == 0) {",
"QTAILQ_REMOVE(&pool->request_list, elem, reqs);",
"elem->state = THREAD_CANCELED;",
"event_notifier_set(&pool->notifier);",
"} else {",
"pool->pending_cancellations++;",
"while (elem->state != THREAD_CANCELED && elem->state != THREAD_DONE) {",
"qemu_cond_wait(&pool->check_cancel, &pool->lock);",
"}",
"pool->pending_cancellations--;",
"}",
"qemu_mutex_unlock(&pool->lock);",
"}"
] | [
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,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
54
]
] |
26,834 | static void vhost_dev_unassign_memory(struct vhost_dev *dev,
uint64_t start_addr,
uint64_t size)
{
int from, to, n = dev->mem->nregions;
/* Track overlapping/split regions for sanity checking. */
int overlap_start = 0, overlap_end = 0, overlap_middle = 0, split = 0;
for (from = 0, to = 0; from < n; ++from, ++to) {
struct vhost_memory_region *reg = dev->mem->regions + to;
uint64_t reglast;
uint64_t memlast;
uint64_t change;
/* clone old region */
if (to != from) {
memcpy(reg, dev->mem->regions + from, sizeof *reg);
}
/* No overlap is simple */
if (!ranges_overlap(reg->guest_phys_addr, reg->memory_size,
start_addr, size)) {
continue;
}
/* Split only happens if supplied region
* is in the middle of an existing one. Thus it can not
* overlap with any other existing region. */
assert(!split);
reglast = range_get_last(reg->guest_phys_addr, reg->memory_size);
memlast = range_get_last(start_addr, size);
/* Remove whole region */
if (start_addr <= reg->guest_phys_addr && memlast >= reglast) {
--dev->mem->nregions;
--to;
assert(to >= 0);
++overlap_middle;
continue;
}
/* Shrink region */
if (memlast >= reglast) {
reg->memory_size = start_addr - reg->guest_phys_addr;
assert(reg->memory_size);
assert(!overlap_end);
++overlap_end;
continue;
}
/* Shift region */
if (start_addr <= reg->guest_phys_addr) {
change = memlast + 1 - reg->guest_phys_addr;
reg->memory_size -= change;
reg->guest_phys_addr += change;
reg->userspace_addr += change;
assert(reg->memory_size);
assert(!overlap_start);
++overlap_start;
continue;
}
/* This only happens if supplied region
* is in the middle of an existing one. Thus it can not
* overlap with any other existing region. */
assert(!overlap_start);
assert(!overlap_end);
assert(!overlap_middle);
/* Split region: shrink first part, shift second part. */
memcpy(dev->mem->regions + n, reg, sizeof *reg);
reg->memory_size = start_addr - reg->guest_phys_addr;
assert(reg->memory_size);
change = memlast + 1 - reg->guest_phys_addr;
reg = dev->mem->regions + n;
reg->memory_size -= change;
assert(reg->memory_size);
reg->guest_phys_addr += change;
reg->userspace_addr += change;
/* Never add more than 1 region */
assert(dev->mem->nregions == n);
++dev->mem->nregions;
++split;
}
}
| true | qemu | cb4b4fde82b064472c13fb9d983ca36a70e560aa | static void vhost_dev_unassign_memory(struct vhost_dev *dev,
uint64_t start_addr,
uint64_t size)
{
int from, to, n = dev->mem->nregions;
int overlap_start = 0, overlap_end = 0, overlap_middle = 0, split = 0;
for (from = 0, to = 0; from < n; ++from, ++to) {
struct vhost_memory_region *reg = dev->mem->regions + to;
uint64_t reglast;
uint64_t memlast;
uint64_t change;
if (to != from) {
memcpy(reg, dev->mem->regions + from, sizeof *reg);
}
if (!ranges_overlap(reg->guest_phys_addr, reg->memory_size,
start_addr, size)) {
continue;
}
assert(!split);
reglast = range_get_last(reg->guest_phys_addr, reg->memory_size);
memlast = range_get_last(start_addr, size);
if (start_addr <= reg->guest_phys_addr && memlast >= reglast) {
--dev->mem->nregions;
--to;
assert(to >= 0);
++overlap_middle;
continue;
}
if (memlast >= reglast) {
reg->memory_size = start_addr - reg->guest_phys_addr;
assert(reg->memory_size);
assert(!overlap_end);
++overlap_end;
continue;
}
if (start_addr <= reg->guest_phys_addr) {
change = memlast + 1 - reg->guest_phys_addr;
reg->memory_size -= change;
reg->guest_phys_addr += change;
reg->userspace_addr += change;
assert(reg->memory_size);
assert(!overlap_start);
++overlap_start;
continue;
}
assert(!overlap_start);
assert(!overlap_end);
assert(!overlap_middle);
memcpy(dev->mem->regions + n, reg, sizeof *reg);
reg->memory_size = start_addr - reg->guest_phys_addr;
assert(reg->memory_size);
change = memlast + 1 - reg->guest_phys_addr;
reg = dev->mem->regions + n;
reg->memory_size -= change;
assert(reg->memory_size);
reg->guest_phys_addr += change;
reg->userspace_addr += change;
assert(dev->mem->nregions == n);
++dev->mem->nregions;
++split;
}
}
| {
"code": [
" assert(to >= 0);"
],
"line_no": [
75
]
} | static void FUNC_0(struct vhost_dev *VAR_0,
uint64_t VAR_1,
uint64_t VAR_2)
{
int VAR_3, VAR_4, VAR_5 = VAR_0->mem->nregions;
int VAR_6 = 0, VAR_7 = 0, VAR_8 = 0, VAR_9 = 0;
for (VAR_3 = 0, VAR_4 = 0; VAR_3 < VAR_5; ++VAR_3, ++VAR_4) {
struct vhost_memory_region *VAR_10 = VAR_0->mem->regions + VAR_4;
uint64_t reglast;
uint64_t memlast;
uint64_t change;
if (VAR_4 != VAR_3) {
memcpy(VAR_10, VAR_0->mem->regions + VAR_3, sizeof *VAR_10);
}
if (!ranges_overlap(VAR_10->guest_phys_addr, VAR_10->memory_size,
VAR_1, VAR_2)) {
continue;
}
assert(!VAR_9);
reglast = range_get_last(VAR_10->guest_phys_addr, VAR_10->memory_size);
memlast = range_get_last(VAR_1, VAR_2);
if (VAR_1 <= VAR_10->guest_phys_addr && memlast >= reglast) {
--VAR_0->mem->nregions;
--VAR_4;
assert(VAR_4 >= 0);
++VAR_8;
continue;
}
if (memlast >= reglast) {
VAR_10->memory_size = VAR_1 - VAR_10->guest_phys_addr;
assert(VAR_10->memory_size);
assert(!VAR_7);
++VAR_7;
continue;
}
if (VAR_1 <= VAR_10->guest_phys_addr) {
change = memlast + 1 - VAR_10->guest_phys_addr;
VAR_10->memory_size -= change;
VAR_10->guest_phys_addr += change;
VAR_10->userspace_addr += change;
assert(VAR_10->memory_size);
assert(!VAR_6);
++VAR_6;
continue;
}
assert(!VAR_6);
assert(!VAR_7);
assert(!VAR_8);
memcpy(VAR_0->mem->regions + VAR_5, VAR_10, sizeof *VAR_10);
VAR_10->memory_size = VAR_1 - VAR_10->guest_phys_addr;
assert(VAR_10->memory_size);
change = memlast + 1 - VAR_10->guest_phys_addr;
VAR_10 = VAR_0->mem->regions + VAR_5;
VAR_10->memory_size -= change;
assert(VAR_10->memory_size);
VAR_10->guest_phys_addr += change;
VAR_10->userspace_addr += change;
assert(VAR_0->mem->nregions == VAR_5);
++VAR_0->mem->nregions;
++VAR_9;
}
}
| [
"static void FUNC_0(struct vhost_dev *VAR_0,\nuint64_t VAR_1,\nuint64_t VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5 = VAR_0->mem->nregions;",
"int VAR_6 = 0, VAR_7 = 0, VAR_8 = 0, VAR_9 = 0;",
"for (VAR_3 = 0, VAR_4 = 0; VAR_3 < VAR_5; ++VAR_3, ++VAR_4) {",
"struct vhost_memory_region *VAR_10 = VAR_0->mem->regions + VAR_4;",
"uint64_t reglast;",
"uint64_t memlast;",
"uint64_t change;",
"if (VAR_4 != VAR_3) {",
"memcpy(VAR_10, VAR_0->mem->regions + VAR_3, sizeof *VAR_10);",
"}",
"if (!ranges_overlap(VAR_10->guest_phys_addr, VAR_10->memory_size,\nVAR_1, VAR_2)) {",
"continue;",
"}",
"assert(!VAR_9);",
"reglast = range_get_last(VAR_10->guest_phys_addr, VAR_10->memory_size);",
"memlast = range_get_last(VAR_1, VAR_2);",
"if (VAR_1 <= VAR_10->guest_phys_addr && memlast >= reglast) {",
"--VAR_0->mem->nregions;",
"--VAR_4;",
"assert(VAR_4 >= 0);",
"++VAR_8;",
"continue;",
"}",
"if (memlast >= reglast) {",
"VAR_10->memory_size = VAR_1 - VAR_10->guest_phys_addr;",
"assert(VAR_10->memory_size);",
"assert(!VAR_7);",
"++VAR_7;",
"continue;",
"}",
"if (VAR_1 <= VAR_10->guest_phys_addr) {",
"change = memlast + 1 - VAR_10->guest_phys_addr;",
"VAR_10->memory_size -= change;",
"VAR_10->guest_phys_addr += change;",
"VAR_10->userspace_addr += change;",
"assert(VAR_10->memory_size);",
"assert(!VAR_6);",
"++VAR_6;",
"continue;",
"}",
"assert(!VAR_6);",
"assert(!VAR_7);",
"assert(!VAR_8);",
"memcpy(VAR_0->mem->regions + VAR_5, VAR_10, sizeof *VAR_10);",
"VAR_10->memory_size = VAR_1 - VAR_10->guest_phys_addr;",
"assert(VAR_10->memory_size);",
"change = memlast + 1 - VAR_10->guest_phys_addr;",
"VAR_10 = VAR_0->mem->regions + VAR_5;",
"VAR_10->memory_size -= change;",
"assert(VAR_10->memory_size);",
"VAR_10->guest_phys_addr += change;",
"VAR_10->userspace_addr += change;",
"assert(VAR_0->mem->nregions == VAR_5);",
"++VAR_0->mem->nregions;",
"++VAR_9;",
"}",
"}"
] | [
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
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
31
],
[
33
],
[
35
],
[
41,
43
],
[
45
],
[
47
],
[
57
],
[
61
],
[
63
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
]
] |
26,835 | static int pfpu_decode_insn(MilkymistPFPUState *s)
{
uint32_t pc = s->regs[R_PC];
uint32_t insn = s->microcode[pc];
uint32_t reg_a = (insn >> 18) & 0x7f;
uint32_t reg_b = (insn >> 11) & 0x7f;
uint32_t op = (insn >> 7) & 0xf;
uint32_t reg_d = insn & 0x7f;
uint32_t r;
int latency = 0;
switch (op) {
case OP_NOP:
break;
case OP_FADD:
{
float a = REINTERPRET_CAST(float, s->gp_regs[reg_a]);
float b = REINTERPRET_CAST(float, s->gp_regs[reg_b]);
float t = a + b;
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_FADD;
D_EXEC(qemu_log("ADD a=%f b=%f t=%f, r=%08x\n", a, b, t, r));
} break;
case OP_FSUB:
{
float a = REINTERPRET_CAST(float, s->gp_regs[reg_a]);
float b = REINTERPRET_CAST(float, s->gp_regs[reg_b]);
float t = a - b;
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_FSUB;
D_EXEC(qemu_log("SUB a=%f b=%f t=%f, r=%08x\n", a, b, t, r));
} break;
case OP_FMUL:
{
float a = REINTERPRET_CAST(float, s->gp_regs[reg_a]);
float b = REINTERPRET_CAST(float, s->gp_regs[reg_b]);
float t = a * b;
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_FMUL;
D_EXEC(qemu_log("MUL a=%f b=%f t=%f, r=%08x\n", a, b, t, r));
} break;
case OP_FABS:
{
float a = REINTERPRET_CAST(float, s->gp_regs[reg_a]);
float t = fabsf(a);
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_FABS;
D_EXEC(qemu_log("ABS a=%f t=%f, r=%08x\n", a, t, r));
} break;
case OP_F2I:
{
float a = REINTERPRET_CAST(float, s->gp_regs[reg_a]);
int32_t t = a;
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_F2I;
D_EXEC(qemu_log("F2I a=%f t=%d, r=%08x\n", a, t, r));
} break;
case OP_I2F:
{
int32_t a = REINTERPRET_CAST(int32_t, s->gp_regs[reg_a]);
float t = a;
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_I2F;
D_EXEC(qemu_log("I2F a=%08x t=%f, r=%08x\n", a, t, r));
} break;
case OP_VECTOUT:
{
uint32_t a = cpu_to_be32(s->gp_regs[reg_a]);
uint32_t b = cpu_to_be32(s->gp_regs[reg_b]);
target_phys_addr_t dma_ptr =
get_dma_address(s->regs[R_MESHBASE],
s->gp_regs[GPR_X], s->gp_regs[GPR_Y]);
cpu_physical_memory_write(dma_ptr, (uint8_t *)&a, 4);
cpu_physical_memory_write(dma_ptr + 4, (uint8_t *)&b, 4);
s->regs[R_LASTDMA] = dma_ptr + 4;
D_EXEC(qemu_log("VECTOUT a=%08x b=%08x dma=%08x\n", a, b, dma_ptr));
trace_milkymist_pfpu_vectout(a, b, dma_ptr);
} break;
case OP_SIN:
{
int32_t a = REINTERPRET_CAST(int32_t, s->gp_regs[reg_a]);
float t = sinf(a * (1.0f / (M_PI * 4096.0f)));
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_SIN;
D_EXEC(qemu_log("SIN a=%d t=%f, r=%08x\n", a, t, r));
} break;
case OP_COS:
{
int32_t a = REINTERPRET_CAST(int32_t, s->gp_regs[reg_a]);
float t = cosf(a * (1.0f / (M_PI * 4096.0f)));
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_COS;
D_EXEC(qemu_log("COS a=%d t=%f, r=%08x\n", a, t, r));
} break;
case OP_ABOVE:
{
float a = REINTERPRET_CAST(float, s->gp_regs[reg_a]);
float b = REINTERPRET_CAST(float, s->gp_regs[reg_b]);
float t = (a > b) ? 1.0f : 0.0f;
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_ABOVE;
D_EXEC(qemu_log("ABOVE a=%f b=%f t=%f, r=%08x\n", a, b, t, r));
} break;
case OP_EQUAL:
{
float a = REINTERPRET_CAST(float, s->gp_regs[reg_a]);
float b = REINTERPRET_CAST(float, s->gp_regs[reg_b]);
float t = (a == b) ? 1.0f : 0.0f;
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_EQUAL;
D_EXEC(qemu_log("EQUAL a=%f b=%f t=%f, r=%08x\n", a, b, t, r));
} break;
case OP_COPY:
{
r = s->gp_regs[reg_a];
latency = LATENCY_COPY;
D_EXEC(qemu_log("COPY"));
} break;
case OP_IF:
{
float a = REINTERPRET_CAST(float, s->gp_regs[reg_a]);
float b = REINTERPRET_CAST(float, s->gp_regs[reg_b]);
uint32_t f = s->gp_regs[GPR_FLAGS];
float t = (f != 0) ? a : b;
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_IF;
D_EXEC(qemu_log("IF f=%u a=%f b=%f t=%f, r=%08x\n", f, a, b, t, r));
} break;
case OP_TSIGN:
{
float a = REINTERPRET_CAST(float, s->gp_regs[reg_a]);
float b = REINTERPRET_CAST(float, s->gp_regs[reg_b]);
float t = (b < 0) ? -a : a;
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_TSIGN;
D_EXEC(qemu_log("TSIGN a=%f b=%f t=%f, r=%08x\n", a, b, t, r));
} break;
case OP_QUAKE:
{
uint32_t a = s->gp_regs[reg_a];
r = 0x5f3759df - (a >> 1);
latency = LATENCY_QUAKE;
D_EXEC(qemu_log("QUAKE a=%d r=%08x\n", a, r));
} break;
default:
error_report("milkymist_pfpu: unknown opcode %d\n", op);
break;
}
if (!reg_d) {
D_EXEC(qemu_log("%04d %8s R%03d, R%03d <L=%d, E=%04d>\n",
s->regs[R_PC], opcode_to_str[op], reg_a, reg_b, latency,
s->regs[R_PC] + latency));
} else {
D_EXEC(qemu_log("%04d %8s R%03d, R%03d <L=%d, E=%04d> -> R%03d\n",
s->regs[R_PC], opcode_to_str[op], reg_a, reg_b, latency,
s->regs[R_PC] + latency, reg_d));
}
if (op == OP_VECTOUT) {
return 0;
}
/* store output for this cycle */
if (reg_d) {
uint32_t val = output_queue_remove(s);
D_EXEC(qemu_log("R%03d <- 0x%08x\n", reg_d, val));
s->gp_regs[reg_d] = val;
}
output_queue_advance(s);
/* store op output */
if (op != OP_NOP) {
output_queue_insert(s, r, latency-1);
}
/* advance PC */
s->regs[R_PC]++;
return 1;
};
| true | qemu | 7f7454ec296b3403b4accec55349a8f0232d3576 | static int pfpu_decode_insn(MilkymistPFPUState *s)
{
uint32_t pc = s->regs[R_PC];
uint32_t insn = s->microcode[pc];
uint32_t reg_a = (insn >> 18) & 0x7f;
uint32_t reg_b = (insn >> 11) & 0x7f;
uint32_t op = (insn >> 7) & 0xf;
uint32_t reg_d = insn & 0x7f;
uint32_t r;
int latency = 0;
switch (op) {
case OP_NOP:
break;
case OP_FADD:
{
float a = REINTERPRET_CAST(float, s->gp_regs[reg_a]);
float b = REINTERPRET_CAST(float, s->gp_regs[reg_b]);
float t = a + b;
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_FADD;
D_EXEC(qemu_log("ADD a=%f b=%f t=%f, r=%08x\n", a, b, t, r));
} break;
case OP_FSUB:
{
float a = REINTERPRET_CAST(float, s->gp_regs[reg_a]);
float b = REINTERPRET_CAST(float, s->gp_regs[reg_b]);
float t = a - b;
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_FSUB;
D_EXEC(qemu_log("SUB a=%f b=%f t=%f, r=%08x\n", a, b, t, r));
} break;
case OP_FMUL:
{
float a = REINTERPRET_CAST(float, s->gp_regs[reg_a]);
float b = REINTERPRET_CAST(float, s->gp_regs[reg_b]);
float t = a * b;
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_FMUL;
D_EXEC(qemu_log("MUL a=%f b=%f t=%f, r=%08x\n", a, b, t, r));
} break;
case OP_FABS:
{
float a = REINTERPRET_CAST(float, s->gp_regs[reg_a]);
float t = fabsf(a);
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_FABS;
D_EXEC(qemu_log("ABS a=%f t=%f, r=%08x\n", a, t, r));
} break;
case OP_F2I:
{
float a = REINTERPRET_CAST(float, s->gp_regs[reg_a]);
int32_t t = a;
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_F2I;
D_EXEC(qemu_log("F2I a=%f t=%d, r=%08x\n", a, t, r));
} break;
case OP_I2F:
{
int32_t a = REINTERPRET_CAST(int32_t, s->gp_regs[reg_a]);
float t = a;
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_I2F;
D_EXEC(qemu_log("I2F a=%08x t=%f, r=%08x\n", a, t, r));
} break;
case OP_VECTOUT:
{
uint32_t a = cpu_to_be32(s->gp_regs[reg_a]);
uint32_t b = cpu_to_be32(s->gp_regs[reg_b]);
target_phys_addr_t dma_ptr =
get_dma_address(s->regs[R_MESHBASE],
s->gp_regs[GPR_X], s->gp_regs[GPR_Y]);
cpu_physical_memory_write(dma_ptr, (uint8_t *)&a, 4);
cpu_physical_memory_write(dma_ptr + 4, (uint8_t *)&b, 4);
s->regs[R_LASTDMA] = dma_ptr + 4;
D_EXEC(qemu_log("VECTOUT a=%08x b=%08x dma=%08x\n", a, b, dma_ptr));
trace_milkymist_pfpu_vectout(a, b, dma_ptr);
} break;
case OP_SIN:
{
int32_t a = REINTERPRET_CAST(int32_t, s->gp_regs[reg_a]);
float t = sinf(a * (1.0f / (M_PI * 4096.0f)));
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_SIN;
D_EXEC(qemu_log("SIN a=%d t=%f, r=%08x\n", a, t, r));
} break;
case OP_COS:
{
int32_t a = REINTERPRET_CAST(int32_t, s->gp_regs[reg_a]);
float t = cosf(a * (1.0f / (M_PI * 4096.0f)));
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_COS;
D_EXEC(qemu_log("COS a=%d t=%f, r=%08x\n", a, t, r));
} break;
case OP_ABOVE:
{
float a = REINTERPRET_CAST(float, s->gp_regs[reg_a]);
float b = REINTERPRET_CAST(float, s->gp_regs[reg_b]);
float t = (a > b) ? 1.0f : 0.0f;
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_ABOVE;
D_EXEC(qemu_log("ABOVE a=%f b=%f t=%f, r=%08x\n", a, b, t, r));
} break;
case OP_EQUAL:
{
float a = REINTERPRET_CAST(float, s->gp_regs[reg_a]);
float b = REINTERPRET_CAST(float, s->gp_regs[reg_b]);
float t = (a == b) ? 1.0f : 0.0f;
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_EQUAL;
D_EXEC(qemu_log("EQUAL a=%f b=%f t=%f, r=%08x\n", a, b, t, r));
} break;
case OP_COPY:
{
r = s->gp_regs[reg_a];
latency = LATENCY_COPY;
D_EXEC(qemu_log("COPY"));
} break;
case OP_IF:
{
float a = REINTERPRET_CAST(float, s->gp_regs[reg_a]);
float b = REINTERPRET_CAST(float, s->gp_regs[reg_b]);
uint32_t f = s->gp_regs[GPR_FLAGS];
float t = (f != 0) ? a : b;
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_IF;
D_EXEC(qemu_log("IF f=%u a=%f b=%f t=%f, r=%08x\n", f, a, b, t, r));
} break;
case OP_TSIGN:
{
float a = REINTERPRET_CAST(float, s->gp_regs[reg_a]);
float b = REINTERPRET_CAST(float, s->gp_regs[reg_b]);
float t = (b < 0) ? -a : a;
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_TSIGN;
D_EXEC(qemu_log("TSIGN a=%f b=%f t=%f, r=%08x\n", a, b, t, r));
} break;
case OP_QUAKE:
{
uint32_t a = s->gp_regs[reg_a];
r = 0x5f3759df - (a >> 1);
latency = LATENCY_QUAKE;
D_EXEC(qemu_log("QUAKE a=%d r=%08x\n", a, r));
} break;
default:
error_report("milkymist_pfpu: unknown opcode %d\n", op);
break;
}
if (!reg_d) {
D_EXEC(qemu_log("%04d %8s R%03d, R%03d <L=%d, E=%04d>\n",
s->regs[R_PC], opcode_to_str[op], reg_a, reg_b, latency,
s->regs[R_PC] + latency));
} else {
D_EXEC(qemu_log("%04d %8s R%03d, R%03d <L=%d, E=%04d> -> R%03d\n",
s->regs[R_PC], opcode_to_str[op], reg_a, reg_b, latency,
s->regs[R_PC] + latency, reg_d));
}
if (op == OP_VECTOUT) {
return 0;
}
if (reg_d) {
uint32_t val = output_queue_remove(s);
D_EXEC(qemu_log("R%03d <- 0x%08x\n", reg_d, val));
s->gp_regs[reg_d] = val;
}
output_queue_advance(s);
if (op != OP_NOP) {
output_queue_insert(s, r, latency-1);
}
s->regs[R_PC]++;
return 1;
};
| {
"code": [
" uint32_t r;"
],
"line_no": [
17
]
} | static int FUNC_0(MilkymistPFPUState *VAR_0)
{
uint32_t pc = VAR_0->regs[R_PC];
uint32_t insn = VAR_0->microcode[pc];
uint32_t reg_a = (insn >> 18) & 0x7f;
uint32_t reg_b = (insn >> 11) & 0x7f;
uint32_t op = (insn >> 7) & 0xf;
uint32_t reg_d = insn & 0x7f;
uint32_t r;
int VAR_1 = 0;
switch (op) {
case OP_NOP:
break;
case OP_FADD:
{
float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_a]);
float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_b]);
float VAR_5 = VAR_5 + VAR_5;
r = REINTERPRET_CAST(uint32_t, VAR_5);
VAR_1 = LATENCY_FADD;
D_EXEC(qemu_log("ADD VAR_5=%f VAR_5=%f VAR_5=%f, r=%08x\n", VAR_5, VAR_5, VAR_5, r));
} break;
case OP_FSUB:
{
float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_a]);
float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_b]);
float VAR_5 = VAR_5 - VAR_5;
r = REINTERPRET_CAST(uint32_t, VAR_5);
VAR_1 = LATENCY_FSUB;
D_EXEC(qemu_log("SUB VAR_5=%f VAR_5=%f VAR_5=%f, r=%08x\n", VAR_5, VAR_5, VAR_5, r));
} break;
case OP_FMUL:
{
float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_a]);
float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_b]);
float VAR_5 = VAR_5 * VAR_5;
r = REINTERPRET_CAST(uint32_t, VAR_5);
VAR_1 = LATENCY_FMUL;
D_EXEC(qemu_log("MUL VAR_5=%f VAR_5=%f VAR_5=%f, r=%08x\n", VAR_5, VAR_5, VAR_5, r));
} break;
case OP_FABS:
{
float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_a]);
float VAR_5 = fabsf(VAR_5);
r = REINTERPRET_CAST(uint32_t, VAR_5);
VAR_1 = LATENCY_FABS;
D_EXEC(qemu_log("ABS VAR_5=%f VAR_5=%f, r=%08x\n", VAR_5, VAR_5, r));
} break;
case OP_F2I:
{
float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_a]);
int32_t VAR_5 = VAR_5;
r = REINTERPRET_CAST(uint32_t, VAR_5);
VAR_1 = LATENCY_F2I;
D_EXEC(qemu_log("F2I VAR_5=%f VAR_5=%d, r=%08x\n", VAR_5, VAR_5, r));
} break;
case OP_I2F:
{
int32_t VAR_5 = REINTERPRET_CAST(int32_t, VAR_0->gp_regs[reg_a]);
float VAR_5 = VAR_5;
r = REINTERPRET_CAST(uint32_t, VAR_5);
VAR_1 = LATENCY_I2F;
D_EXEC(qemu_log("I2F VAR_5=%08x VAR_5=%f, r=%08x\n", VAR_5, VAR_5, r));
} break;
case OP_VECTOUT:
{
uint32_t VAR_5 = cpu_to_be32(VAR_0->gp_regs[reg_a]);
uint32_t VAR_5 = cpu_to_be32(VAR_0->gp_regs[reg_b]);
target_phys_addr_t dma_ptr =
get_dma_address(VAR_0->regs[R_MESHBASE],
VAR_0->gp_regs[GPR_X], VAR_0->gp_regs[GPR_Y]);
cpu_physical_memory_write(dma_ptr, (uint8_t *)&VAR_5, 4);
cpu_physical_memory_write(dma_ptr + 4, (uint8_t *)&VAR_5, 4);
VAR_0->regs[R_LASTDMA] = dma_ptr + 4;
D_EXEC(qemu_log("VECTOUT VAR_5=%08x VAR_5=%08x dma=%08x\n", VAR_5, VAR_5, dma_ptr));
trace_milkymist_pfpu_vectout(VAR_5, VAR_5, dma_ptr);
} break;
case OP_SIN:
{
int32_t VAR_5 = REINTERPRET_CAST(int32_t, VAR_0->gp_regs[reg_a]);
float VAR_5 = sinf(VAR_5 * (1.0f / (M_PI * 4096.0f)));
r = REINTERPRET_CAST(uint32_t, VAR_5);
VAR_1 = LATENCY_SIN;
D_EXEC(qemu_log("SIN VAR_5=%d VAR_5=%f, r=%08x\n", VAR_5, VAR_5, r));
} break;
case OP_COS:
{
int32_t VAR_5 = REINTERPRET_CAST(int32_t, VAR_0->gp_regs[reg_a]);
float VAR_5 = cosf(VAR_5 * (1.0f / (M_PI * 4096.0f)));
r = REINTERPRET_CAST(uint32_t, VAR_5);
VAR_1 = LATENCY_COS;
D_EXEC(qemu_log("COS VAR_5=%d VAR_5=%f, r=%08x\n", VAR_5, VAR_5, r));
} break;
case OP_ABOVE:
{
float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_a]);
float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_b]);
float VAR_5 = (VAR_5 > VAR_5) ? 1.0f : 0.0f;
r = REINTERPRET_CAST(uint32_t, VAR_5);
VAR_1 = LATENCY_ABOVE;
D_EXEC(qemu_log("ABOVE VAR_5=%f VAR_5=%f VAR_5=%f, r=%08x\n", VAR_5, VAR_5, VAR_5, r));
} break;
case OP_EQUAL:
{
float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_a]);
float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_b]);
float VAR_5 = (VAR_5 == VAR_5) ? 1.0f : 0.0f;
r = REINTERPRET_CAST(uint32_t, VAR_5);
VAR_1 = LATENCY_EQUAL;
D_EXEC(qemu_log("EQUAL VAR_5=%f VAR_5=%f VAR_5=%f, r=%08x\n", VAR_5, VAR_5, VAR_5, r));
} break;
case OP_COPY:
{
r = VAR_0->gp_regs[reg_a];
VAR_1 = LATENCY_COPY;
D_EXEC(qemu_log("COPY"));
} break;
case OP_IF:
{
float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_a]);
float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_b]);
uint32_t f = VAR_0->gp_regs[GPR_FLAGS];
float VAR_5 = (f != 0) ? VAR_5 : VAR_5;
r = REINTERPRET_CAST(uint32_t, VAR_5);
VAR_1 = LATENCY_IF;
D_EXEC(qemu_log("IF f=%u VAR_5=%f VAR_5=%f VAR_5=%f, r=%08x\n", f, VAR_5, VAR_5, VAR_5, r));
} break;
case OP_TSIGN:
{
float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_a]);
float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_b]);
float VAR_5 = (VAR_5 < 0) ? -VAR_5 : VAR_5;
r = REINTERPRET_CAST(uint32_t, VAR_5);
VAR_1 = LATENCY_TSIGN;
D_EXEC(qemu_log("TSIGN VAR_5=%f VAR_5=%f VAR_5=%f, r=%08x\n", VAR_5, VAR_5, VAR_5, r));
} break;
case OP_QUAKE:
{
uint32_t VAR_5 = VAR_0->gp_regs[reg_a];
r = 0x5f3759df - (VAR_5 >> 1);
VAR_1 = LATENCY_QUAKE;
D_EXEC(qemu_log("QUAKE VAR_5=%d r=%08x\n", VAR_5, r));
} break;
default:
error_report("milkymist_pfpu: unknown opcode %d\n", op);
break;
}
if (!reg_d) {
D_EXEC(qemu_log("%04d %8s R%03d, R%03d <L=%d, E=%04d>\n",
VAR_0->regs[R_PC], opcode_to_str[op], reg_a, reg_b, VAR_1,
VAR_0->regs[R_PC] + VAR_1));
} else {
D_EXEC(qemu_log("%04d %8s R%03d, R%03d <L=%d, E=%04d> -> R%03d\n",
VAR_0->regs[R_PC], opcode_to_str[op], reg_a, reg_b, VAR_1,
VAR_0->regs[R_PC] + VAR_1, reg_d));
}
if (op == OP_VECTOUT) {
return 0;
}
if (reg_d) {
uint32_t val = output_queue_remove(VAR_0);
D_EXEC(qemu_log("R%03d <- 0x%08x\n", reg_d, val));
VAR_0->gp_regs[reg_d] = val;
}
output_queue_advance(VAR_0);
if (op != OP_NOP) {
output_queue_insert(VAR_0, r, VAR_1-1);
}
VAR_0->regs[R_PC]++;
return 1;
};
| [
"static int FUNC_0(MilkymistPFPUState *VAR_0)\n{",
"uint32_t pc = VAR_0->regs[R_PC];",
"uint32_t insn = VAR_0->microcode[pc];",
"uint32_t reg_a = (insn >> 18) & 0x7f;",
"uint32_t reg_b = (insn >> 11) & 0x7f;",
"uint32_t op = (insn >> 7) & 0xf;",
"uint32_t reg_d = insn & 0x7f;",
"uint32_t r;",
"int VAR_1 = 0;",
"switch (op) {",
"case OP_NOP:\nbreak;",
"case OP_FADD:\n{",
"float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_a]);",
"float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_b]);",
"float VAR_5 = VAR_5 + VAR_5;",
"r = REINTERPRET_CAST(uint32_t, VAR_5);",
"VAR_1 = LATENCY_FADD;",
"D_EXEC(qemu_log(\"ADD VAR_5=%f VAR_5=%f VAR_5=%f, r=%08x\\n\", VAR_5, VAR_5, VAR_5, r));",
"} break;",
"case OP_FSUB:\n{",
"float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_a]);",
"float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_b]);",
"float VAR_5 = VAR_5 - VAR_5;",
"r = REINTERPRET_CAST(uint32_t, VAR_5);",
"VAR_1 = LATENCY_FSUB;",
"D_EXEC(qemu_log(\"SUB VAR_5=%f VAR_5=%f VAR_5=%f, r=%08x\\n\", VAR_5, VAR_5, VAR_5, r));",
"} break;",
"case OP_FMUL:\n{",
"float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_a]);",
"float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_b]);",
"float VAR_5 = VAR_5 * VAR_5;",
"r = REINTERPRET_CAST(uint32_t, VAR_5);",
"VAR_1 = LATENCY_FMUL;",
"D_EXEC(qemu_log(\"MUL VAR_5=%f VAR_5=%f VAR_5=%f, r=%08x\\n\", VAR_5, VAR_5, VAR_5, r));",
"} break;",
"case OP_FABS:\n{",
"float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_a]);",
"float VAR_5 = fabsf(VAR_5);",
"r = REINTERPRET_CAST(uint32_t, VAR_5);",
"VAR_1 = LATENCY_FABS;",
"D_EXEC(qemu_log(\"ABS VAR_5=%f VAR_5=%f, r=%08x\\n\", VAR_5, VAR_5, r));",
"} break;",
"case OP_F2I:\n{",
"float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_a]);",
"int32_t VAR_5 = VAR_5;",
"r = REINTERPRET_CAST(uint32_t, VAR_5);",
"VAR_1 = LATENCY_F2I;",
"D_EXEC(qemu_log(\"F2I VAR_5=%f VAR_5=%d, r=%08x\\n\", VAR_5, VAR_5, r));",
"} break;",
"case OP_I2F:\n{",
"int32_t VAR_5 = REINTERPRET_CAST(int32_t, VAR_0->gp_regs[reg_a]);",
"float VAR_5 = VAR_5;",
"r = REINTERPRET_CAST(uint32_t, VAR_5);",
"VAR_1 = LATENCY_I2F;",
"D_EXEC(qemu_log(\"I2F VAR_5=%08x VAR_5=%f, r=%08x\\n\", VAR_5, VAR_5, r));",
"} break;",
"case OP_VECTOUT:\n{",
"uint32_t VAR_5 = cpu_to_be32(VAR_0->gp_regs[reg_a]);",
"uint32_t VAR_5 = cpu_to_be32(VAR_0->gp_regs[reg_b]);",
"target_phys_addr_t dma_ptr =\nget_dma_address(VAR_0->regs[R_MESHBASE],\nVAR_0->gp_regs[GPR_X], VAR_0->gp_regs[GPR_Y]);",
"cpu_physical_memory_write(dma_ptr, (uint8_t *)&VAR_5, 4);",
"cpu_physical_memory_write(dma_ptr + 4, (uint8_t *)&VAR_5, 4);",
"VAR_0->regs[R_LASTDMA] = dma_ptr + 4;",
"D_EXEC(qemu_log(\"VECTOUT VAR_5=%08x VAR_5=%08x dma=%08x\\n\", VAR_5, VAR_5, dma_ptr));",
"trace_milkymist_pfpu_vectout(VAR_5, VAR_5, dma_ptr);",
"} break;",
"case OP_SIN:\n{",
"int32_t VAR_5 = REINTERPRET_CAST(int32_t, VAR_0->gp_regs[reg_a]);",
"float VAR_5 = sinf(VAR_5 * (1.0f / (M_PI * 4096.0f)));",
"r = REINTERPRET_CAST(uint32_t, VAR_5);",
"VAR_1 = LATENCY_SIN;",
"D_EXEC(qemu_log(\"SIN VAR_5=%d VAR_5=%f, r=%08x\\n\", VAR_5, VAR_5, r));",
"} break;",
"case OP_COS:\n{",
"int32_t VAR_5 = REINTERPRET_CAST(int32_t, VAR_0->gp_regs[reg_a]);",
"float VAR_5 = cosf(VAR_5 * (1.0f / (M_PI * 4096.0f)));",
"r = REINTERPRET_CAST(uint32_t, VAR_5);",
"VAR_1 = LATENCY_COS;",
"D_EXEC(qemu_log(\"COS VAR_5=%d VAR_5=%f, r=%08x\\n\", VAR_5, VAR_5, r));",
"} break;",
"case OP_ABOVE:\n{",
"float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_a]);",
"float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_b]);",
"float VAR_5 = (VAR_5 > VAR_5) ? 1.0f : 0.0f;",
"r = REINTERPRET_CAST(uint32_t, VAR_5);",
"VAR_1 = LATENCY_ABOVE;",
"D_EXEC(qemu_log(\"ABOVE VAR_5=%f VAR_5=%f VAR_5=%f, r=%08x\\n\", VAR_5, VAR_5, VAR_5, r));",
"} break;",
"case OP_EQUAL:\n{",
"float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_a]);",
"float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_b]);",
"float VAR_5 = (VAR_5 == VAR_5) ? 1.0f : 0.0f;",
"r = REINTERPRET_CAST(uint32_t, VAR_5);",
"VAR_1 = LATENCY_EQUAL;",
"D_EXEC(qemu_log(\"EQUAL VAR_5=%f VAR_5=%f VAR_5=%f, r=%08x\\n\", VAR_5, VAR_5, VAR_5, r));",
"} break;",
"case OP_COPY:\n{",
"r = VAR_0->gp_regs[reg_a];",
"VAR_1 = LATENCY_COPY;",
"D_EXEC(qemu_log(\"COPY\"));",
"} break;",
"case OP_IF:\n{",
"float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_a]);",
"float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_b]);",
"uint32_t f = VAR_0->gp_regs[GPR_FLAGS];",
"float VAR_5 = (f != 0) ? VAR_5 : VAR_5;",
"r = REINTERPRET_CAST(uint32_t, VAR_5);",
"VAR_1 = LATENCY_IF;",
"D_EXEC(qemu_log(\"IF f=%u VAR_5=%f VAR_5=%f VAR_5=%f, r=%08x\\n\", f, VAR_5, VAR_5, VAR_5, r));",
"} break;",
"case OP_TSIGN:\n{",
"float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_a]);",
"float VAR_5 = REINTERPRET_CAST(float, VAR_0->gp_regs[reg_b]);",
"float VAR_5 = (VAR_5 < 0) ? -VAR_5 : VAR_5;",
"r = REINTERPRET_CAST(uint32_t, VAR_5);",
"VAR_1 = LATENCY_TSIGN;",
"D_EXEC(qemu_log(\"TSIGN VAR_5=%f VAR_5=%f VAR_5=%f, r=%08x\\n\", VAR_5, VAR_5, VAR_5, r));",
"} break;",
"case OP_QUAKE:\n{",
"uint32_t VAR_5 = VAR_0->gp_regs[reg_a];",
"r = 0x5f3759df - (VAR_5 >> 1);",
"VAR_1 = LATENCY_QUAKE;",
"D_EXEC(qemu_log(\"QUAKE VAR_5=%d r=%08x\\n\", VAR_5, r));",
"} break;",
"default:\nerror_report(\"milkymist_pfpu: unknown opcode %d\\n\", op);",
"break;",
"}",
"if (!reg_d) {",
"D_EXEC(qemu_log(\"%04d %8s R%03d, R%03d <L=%d, E=%04d>\\n\",\nVAR_0->regs[R_PC], opcode_to_str[op], reg_a, reg_b, VAR_1,\nVAR_0->regs[R_PC] + VAR_1));",
"} else {",
"D_EXEC(qemu_log(\"%04d %8s R%03d, R%03d <L=%d, E=%04d> -> R%03d\\n\",\nVAR_0->regs[R_PC], opcode_to_str[op], reg_a, reg_b, VAR_1,\nVAR_0->regs[R_PC] + VAR_1, reg_d));",
"}",
"if (op == OP_VECTOUT) {",
"return 0;",
"}",
"if (reg_d) {",
"uint32_t val = output_queue_remove(VAR_0);",
"D_EXEC(qemu_log(\"R%03d <- 0x%08x\\n\", reg_d, val));",
"VAR_0->gp_regs[reg_d] = val;",
"}",
"output_queue_advance(VAR_0);",
"if (op != OP_NOP) {",
"output_queue_insert(VAR_0, r, VAR_1-1);",
"}",
"VAR_0->regs[R_PC]++;",
"return 1;",
"};"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83,
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99,
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115,
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131,
133
],
[
135
],
[
137
],
[
139,
141,
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157,
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173,
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189,
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207,
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225,
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237,
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257,
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275,
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
291,
293
],
[
295
],
[
297
],
[
301
],
[
303,
305,
307
],
[
309
],
[
311,
313,
315
],
[
317
],
[
321
],
[
323
],
[
325
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
343
],
[
349
],
[
351
],
[
353
],
[
359
],
[
363
],
[
365
]
] |
26,837 | double av_int2dbl(int64_t v){
if(v+v > 0xFFEULL<<52)
return NAN;
return ldexp(((v&((1LL<<52)-1)) + (1LL<<52)) * (v>>63|1), (v>>52&0x7FF)-1075);
}
| true | FFmpeg | 88d1e2b2b0a129365a62efd666db0394e8ffbe08 | double av_int2dbl(int64_t v){
if(v+v > 0xFFEULL<<52)
return NAN;
return ldexp(((v&((1LL<<52)-1)) + (1LL<<52)) * (v>>63|1), (v>>52&0x7FF)-1075);
}
| {
"code": [
" if(v+v > 0xFFEULL<<52)"
],
"line_no": [
3
]
} | double FUNC_0(int64_t VAR_0){
if(VAR_0+VAR_0 > 0xFFEULL<<52)
return NAN;
return ldexp(((VAR_0&((1LL<<52)-1)) + (1LL<<52)) * (VAR_0>>63|1), (VAR_0>>52&0x7FF)-1075);
}
| [
"double FUNC_0(int64_t VAR_0){",
"if(VAR_0+VAR_0 > 0xFFEULL<<52)\nreturn NAN;",
"return ldexp(((VAR_0&((1LL<<52)-1)) + (1LL<<52)) * (VAR_0>>63|1), (VAR_0>>52&0x7FF)-1075);",
"}"
] | [
0,
1,
0,
0
] | [
[
1
],
[
3,
5
],
[
7
],
[
9
]
] |
26,838 | static inline int mxf_read_utf16_string(AVIOContext *pb, int size, char** str, int be)
{
int ret;
size_t buf_size;
if (size < 0)
return AVERROR(EINVAL);
buf_size = size + size / 2 + 1;
*str = av_malloc(buf_size);
if (!*str)
return AVERROR(ENOMEM);
if (be)
ret = avio_get_str16be(pb, size, *str, buf_size);
else
ret = avio_get_str16le(pb, size, *str, buf_size);
if (ret < 0) {
av_freep(str);
return ret;
}
return ret;
}
| true | FFmpeg | fecb3e82a4ba09dc11a51ad0961ab491881a53a1 | static inline int mxf_read_utf16_string(AVIOContext *pb, int size, char** str, int be)
{
int ret;
size_t buf_size;
if (size < 0)
return AVERROR(EINVAL);
buf_size = size + size / 2 + 1;
*str = av_malloc(buf_size);
if (!*str)
return AVERROR(ENOMEM);
if (be)
ret = avio_get_str16be(pb, size, *str, buf_size);
else
ret = avio_get_str16le(pb, size, *str, buf_size);
if (ret < 0) {
av_freep(str);
return ret;
}
return ret;
}
| {
"code": [
" if (size < 0)"
],
"line_no": [
11
]
} | static inline int FUNC_0(AVIOContext *VAR_0, int VAR_1, char** VAR_2, int VAR_3)
{
int VAR_4;
size_t buf_size;
if (VAR_1 < 0)
return AVERROR(EINVAL);
buf_size = VAR_1 + VAR_1 / 2 + 1;
*VAR_2 = av_malloc(buf_size);
if (!*VAR_2)
return AVERROR(ENOMEM);
if (VAR_3)
VAR_4 = avio_get_str16be(VAR_0, VAR_1, *VAR_2, buf_size);
else
VAR_4 = avio_get_str16le(VAR_0, VAR_1, *VAR_2, buf_size);
if (VAR_4 < 0) {
av_freep(VAR_2);
return VAR_4;
}
return VAR_4;
}
| [
"static inline int FUNC_0(AVIOContext *VAR_0, int VAR_1, char** VAR_2, int VAR_3)\n{",
"int VAR_4;",
"size_t buf_size;",
"if (VAR_1 < 0)\nreturn AVERROR(EINVAL);",
"buf_size = VAR_1 + VAR_1 / 2 + 1;",
"*VAR_2 = av_malloc(buf_size);",
"if (!*VAR_2)\nreturn AVERROR(ENOMEM);",
"if (VAR_3)\nVAR_4 = avio_get_str16be(VAR_0, VAR_1, *VAR_2, buf_size);",
"else\nVAR_4 = avio_get_str16le(VAR_0, VAR_1, *VAR_2, buf_size);",
"if (VAR_4 < 0) {",
"av_freep(VAR_2);",
"return VAR_4;",
"}",
"return VAR_4;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
17
],
[
19
],
[
21,
23
],
[
27,
29
],
[
31,
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
]
] |
26,839 | static void synth_block_fcb_acb(WMAVoiceContext *s, GetBitContext *gb,
int block_idx, int size,
int block_pitch_sh2,
const struct frame_type_desc *frame_desc,
float *excitation)
{
static const float gain_coeff[6] = {
0.8169, -0.06545, 0.1726, 0.0185, -0.0359, 0.0458
};
float pulses[MAX_FRAMESIZE / 2], pred_err, acb_gain, fcb_gain;
int n, idx, gain_weight;
AMRFixed fcb;
assert(size <= MAX_FRAMESIZE / 2);
memset(pulses, 0, sizeof(*pulses) * size);
fcb.pitch_lag = block_pitch_sh2 >> 2;
fcb.pitch_fac = 1.0;
fcb.no_repeat_mask = 0;
fcb.n = 0;
/* For the other frame types, this is where we apply the innovation
* (fixed) codebook pulses of the speech signal. */
if (frame_desc->fcb_type == FCB_TYPE_AW_PULSES) {
aw_pulse_set1(s, gb, block_idx, &fcb);
aw_pulse_set2(s, gb, block_idx, &fcb);
} else /* FCB_TYPE_EXC_PULSES */ {
int offset_nbits = 5 - frame_desc->log_n_blocks;
fcb.no_repeat_mask = -1;
/* similar to ff_decode_10_pulses_35bits(), but with single pulses
* (instead of double) for a subset of pulses */
for (n = 0; n < 5; n++) {
float sign;
int pos1, pos2;
sign = get_bits1(gb) ? 1.0 : -1.0;
pos1 = get_bits(gb, offset_nbits);
fcb.x[fcb.n] = n + 5 * pos1;
fcb.y[fcb.n++] = sign;
if (n < frame_desc->dbl_pulses) {
pos2 = get_bits(gb, offset_nbits);
fcb.x[fcb.n] = n + 5 * pos2;
fcb.y[fcb.n++] = (pos1 < pos2) ? -sign : sign;
}
}
}
ff_set_fixed_vector(pulses, &fcb, 1.0, size);
/* Calculate gain for adaptive & fixed codebook signal.
* see ff_amr_set_fixed_gain(). */
idx = get_bits(gb, 7);
fcb_gain = expf(avpriv_scalarproduct_float_c(s->gain_pred_err,
gain_coeff, 6) -
5.2409161640 + wmavoice_gain_codebook_fcb[idx]);
acb_gain = wmavoice_gain_codebook_acb[idx];
pred_err = av_clipf(wmavoice_gain_codebook_fcb[idx],
-2.9957322736 /* log(0.05) */,
1.6094379124 /* log(5.0) */);
gain_weight = 8 >> frame_desc->log_n_blocks;
memmove(&s->gain_pred_err[gain_weight], s->gain_pred_err,
sizeof(*s->gain_pred_err) * (6 - gain_weight));
for (n = 0; n < gain_weight; n++)
s->gain_pred_err[n] = pred_err;
/* Calculation of adaptive codebook */
if (frame_desc->acb_type == ACB_TYPE_ASYMMETRIC) {
int len;
for (n = 0; n < size; n += len) {
int next_idx_sh16;
int abs_idx = block_idx * size + n;
int pitch_sh16 = (s->last_pitch_val << 16) +
s->pitch_diff_sh16 * abs_idx;
int pitch = (pitch_sh16 + 0x6FFF) >> 16;
int idx_sh16 = ((pitch << 16) - pitch_sh16) * 8 + 0x58000;
idx = idx_sh16 >> 16;
if (s->pitch_diff_sh16) {
if (s->pitch_diff_sh16 > 0) {
next_idx_sh16 = (idx_sh16) &~ 0xFFFF;
} else
next_idx_sh16 = (idx_sh16 + 0x10000) &~ 0xFFFF;
len = av_clip((idx_sh16 - next_idx_sh16) / s->pitch_diff_sh16 / 8,
1, size - n);
} else
len = size;
ff_acelp_interpolatef(&excitation[n], &excitation[n - pitch],
wmavoice_ipol1_coeffs, 17,
idx, 9, len);
}
} else /* ACB_TYPE_HAMMING */ {
int block_pitch = block_pitch_sh2 >> 2;
idx = block_pitch_sh2 & 3;
if (idx) {
ff_acelp_interpolatef(excitation, &excitation[-block_pitch],
wmavoice_ipol2_coeffs, 4,
idx, 8, size);
} else
av_memcpy_backptr((uint8_t *) excitation, sizeof(float) * block_pitch,
sizeof(float) * size);
}
/* Interpolate ACB/FCB and use as excitation signal */
ff_weighted_vector_sumf(excitation, excitation, pulses,
acb_gain, fcb_gain, size);
}
| true | FFmpeg | d14a26edb7c4487df581f11e5c6911dc0e623d08 | static void synth_block_fcb_acb(WMAVoiceContext *s, GetBitContext *gb,
int block_idx, int size,
int block_pitch_sh2,
const struct frame_type_desc *frame_desc,
float *excitation)
{
static const float gain_coeff[6] = {
0.8169, -0.06545, 0.1726, 0.0185, -0.0359, 0.0458
};
float pulses[MAX_FRAMESIZE / 2], pred_err, acb_gain, fcb_gain;
int n, idx, gain_weight;
AMRFixed fcb;
assert(size <= MAX_FRAMESIZE / 2);
memset(pulses, 0, sizeof(*pulses) * size);
fcb.pitch_lag = block_pitch_sh2 >> 2;
fcb.pitch_fac = 1.0;
fcb.no_repeat_mask = 0;
fcb.n = 0;
if (frame_desc->fcb_type == FCB_TYPE_AW_PULSES) {
aw_pulse_set1(s, gb, block_idx, &fcb);
aw_pulse_set2(s, gb, block_idx, &fcb);
} else {
int offset_nbits = 5 - frame_desc->log_n_blocks;
fcb.no_repeat_mask = -1;
for (n = 0; n < 5; n++) {
float sign;
int pos1, pos2;
sign = get_bits1(gb) ? 1.0 : -1.0;
pos1 = get_bits(gb, offset_nbits);
fcb.x[fcb.n] = n + 5 * pos1;
fcb.y[fcb.n++] = sign;
if (n < frame_desc->dbl_pulses) {
pos2 = get_bits(gb, offset_nbits);
fcb.x[fcb.n] = n + 5 * pos2;
fcb.y[fcb.n++] = (pos1 < pos2) ? -sign : sign;
}
}
}
ff_set_fixed_vector(pulses, &fcb, 1.0, size);
idx = get_bits(gb, 7);
fcb_gain = expf(avpriv_scalarproduct_float_c(s->gain_pred_err,
gain_coeff, 6) -
5.2409161640 + wmavoice_gain_codebook_fcb[idx]);
acb_gain = wmavoice_gain_codebook_acb[idx];
pred_err = av_clipf(wmavoice_gain_codebook_fcb[idx],
-2.9957322736 ,
1.6094379124 );
gain_weight = 8 >> frame_desc->log_n_blocks;
memmove(&s->gain_pred_err[gain_weight], s->gain_pred_err,
sizeof(*s->gain_pred_err) * (6 - gain_weight));
for (n = 0; n < gain_weight; n++)
s->gain_pred_err[n] = pred_err;
if (frame_desc->acb_type == ACB_TYPE_ASYMMETRIC) {
int len;
for (n = 0; n < size; n += len) {
int next_idx_sh16;
int abs_idx = block_idx * size + n;
int pitch_sh16 = (s->last_pitch_val << 16) +
s->pitch_diff_sh16 * abs_idx;
int pitch = (pitch_sh16 + 0x6FFF) >> 16;
int idx_sh16 = ((pitch << 16) - pitch_sh16) * 8 + 0x58000;
idx = idx_sh16 >> 16;
if (s->pitch_diff_sh16) {
if (s->pitch_diff_sh16 > 0) {
next_idx_sh16 = (idx_sh16) &~ 0xFFFF;
} else
next_idx_sh16 = (idx_sh16 + 0x10000) &~ 0xFFFF;
len = av_clip((idx_sh16 - next_idx_sh16) / s->pitch_diff_sh16 / 8,
1, size - n);
} else
len = size;
ff_acelp_interpolatef(&excitation[n], &excitation[n - pitch],
wmavoice_ipol1_coeffs, 17,
idx, 9, len);
}
} else {
int block_pitch = block_pitch_sh2 >> 2;
idx = block_pitch_sh2 & 3;
if (idx) {
ff_acelp_interpolatef(excitation, &excitation[-block_pitch],
wmavoice_ipol2_coeffs, 4,
idx, 8, size);
} else
av_memcpy_backptr((uint8_t *) excitation, sizeof(float) * block_pitch,
sizeof(float) * size);
}
ff_weighted_vector_sumf(excitation, excitation, pulses,
acb_gain, fcb_gain, size);
}
| {
"code": [
" aw_pulse_set2(s, gb, block_idx, &fcb);"
],
"line_no": [
51
]
} | static void FUNC_0(WMAVoiceContext *VAR_0, GetBitContext *VAR_1,
int VAR_2, int VAR_3,
int VAR_4,
const struct frame_type_desc *VAR_5,
float *VAR_6)
{
static const float VAR_7[6] = {
0.8169, -0.06545, 0.1726, 0.0185, -0.0359, 0.0458
};
float VAR_8[MAX_FRAMESIZE / 2], pred_err, acb_gain, fcb_gain;
int VAR_9, VAR_10, VAR_11;
AMRFixed fcb;
assert(VAR_3 <= MAX_FRAMESIZE / 2);
memset(VAR_8, 0, sizeof(*VAR_8) * VAR_3);
fcb.pitch_lag = VAR_4 >> 2;
fcb.pitch_fac = 1.0;
fcb.no_repeat_mask = 0;
fcb.VAR_9 = 0;
if (VAR_5->fcb_type == FCB_TYPE_AW_PULSES) {
aw_pulse_set1(VAR_0, VAR_1, VAR_2, &fcb);
aw_pulse_set2(VAR_0, VAR_1, VAR_2, &fcb);
} else {
int VAR_12 = 5 - VAR_5->log_n_blocks;
fcb.no_repeat_mask = -1;
for (VAR_9 = 0; VAR_9 < 5; VAR_9++) {
float VAR_13;
int VAR_14, VAR_15;
VAR_13 = get_bits1(VAR_1) ? 1.0 : -1.0;
VAR_14 = get_bits(VAR_1, VAR_12);
fcb.x[fcb.VAR_9] = VAR_9 + 5 * VAR_14;
fcb.y[fcb.VAR_9++] = VAR_13;
if (VAR_9 < VAR_5->dbl_pulses) {
VAR_15 = get_bits(VAR_1, VAR_12);
fcb.x[fcb.VAR_9] = VAR_9 + 5 * VAR_15;
fcb.y[fcb.VAR_9++] = (VAR_14 < VAR_15) ? -VAR_13 : VAR_13;
}
}
}
ff_set_fixed_vector(VAR_8, &fcb, 1.0, VAR_3);
VAR_10 = get_bits(VAR_1, 7);
fcb_gain = expf(avpriv_scalarproduct_float_c(VAR_0->gain_pred_err,
VAR_7, 6) -
5.2409161640 + wmavoice_gain_codebook_fcb[VAR_10]);
acb_gain = wmavoice_gain_codebook_acb[VAR_10];
pred_err = av_clipf(wmavoice_gain_codebook_fcb[VAR_10],
-2.9957322736 ,
1.6094379124 );
VAR_11 = 8 >> VAR_5->log_n_blocks;
memmove(&VAR_0->gain_pred_err[VAR_11], VAR_0->gain_pred_err,
sizeof(*VAR_0->gain_pred_err) * (6 - VAR_11));
for (VAR_9 = 0; VAR_9 < VAR_11; VAR_9++)
VAR_0->gain_pred_err[VAR_9] = pred_err;
if (VAR_5->acb_type == ACB_TYPE_ASYMMETRIC) {
int VAR_16;
for (VAR_9 = 0; VAR_9 < VAR_3; VAR_9 += VAR_16) {
int VAR_17;
int VAR_18 = VAR_2 * VAR_3 + VAR_9;
int VAR_19 = (VAR_0->last_pitch_val << 16) +
VAR_0->pitch_diff_sh16 * VAR_18;
int VAR_20 = (VAR_19 + 0x6FFF) >> 16;
int VAR_21 = ((VAR_20 << 16) - VAR_19) * 8 + 0x58000;
VAR_10 = VAR_21 >> 16;
if (VAR_0->pitch_diff_sh16) {
if (VAR_0->pitch_diff_sh16 > 0) {
VAR_17 = (VAR_21) &~ 0xFFFF;
} else
VAR_17 = (VAR_21 + 0x10000) &~ 0xFFFF;
VAR_16 = av_clip((VAR_21 - VAR_17) / VAR_0->pitch_diff_sh16 / 8,
1, VAR_3 - VAR_9);
} else
VAR_16 = VAR_3;
ff_acelp_interpolatef(&VAR_6[VAR_9], &VAR_6[VAR_9 - VAR_20],
wmavoice_ipol1_coeffs, 17,
VAR_10, 9, VAR_16);
}
} else {
int VAR_22 = VAR_4 >> 2;
VAR_10 = VAR_4 & 3;
if (VAR_10) {
ff_acelp_interpolatef(VAR_6, &VAR_6[-VAR_22],
wmavoice_ipol2_coeffs, 4,
VAR_10, 8, VAR_3);
} else
av_memcpy_backptr((uint8_t *) VAR_6, sizeof(float) * VAR_22,
sizeof(float) * VAR_3);
}
ff_weighted_vector_sumf(VAR_6, VAR_6, VAR_8,
acb_gain, fcb_gain, VAR_3);
}
| [
"static void FUNC_0(WMAVoiceContext *VAR_0, GetBitContext *VAR_1,\nint VAR_2, int VAR_3,\nint VAR_4,\nconst struct frame_type_desc *VAR_5,\nfloat *VAR_6)\n{",
"static const float VAR_7[6] = {",
"0.8169, -0.06545, 0.1726, 0.0185, -0.0359, 0.0458\n};",
"float VAR_8[MAX_FRAMESIZE / 2], pred_err, acb_gain, fcb_gain;",
"int VAR_9, VAR_10, VAR_11;",
"AMRFixed fcb;",
"assert(VAR_3 <= MAX_FRAMESIZE / 2);",
"memset(VAR_8, 0, sizeof(*VAR_8) * VAR_3);",
"fcb.pitch_lag = VAR_4 >> 2;",
"fcb.pitch_fac = 1.0;",
"fcb.no_repeat_mask = 0;",
"fcb.VAR_9 = 0;",
"if (VAR_5->fcb_type == FCB_TYPE_AW_PULSES) {",
"aw_pulse_set1(VAR_0, VAR_1, VAR_2, &fcb);",
"aw_pulse_set2(VAR_0, VAR_1, VAR_2, &fcb);",
"} else {",
"int VAR_12 = 5 - VAR_5->log_n_blocks;",
"fcb.no_repeat_mask = -1;",
"for (VAR_9 = 0; VAR_9 < 5; VAR_9++) {",
"float VAR_13;",
"int VAR_14, VAR_15;",
"VAR_13 = get_bits1(VAR_1) ? 1.0 : -1.0;",
"VAR_14 = get_bits(VAR_1, VAR_12);",
"fcb.x[fcb.VAR_9] = VAR_9 + 5 * VAR_14;",
"fcb.y[fcb.VAR_9++] = VAR_13;",
"if (VAR_9 < VAR_5->dbl_pulses) {",
"VAR_15 = get_bits(VAR_1, VAR_12);",
"fcb.x[fcb.VAR_9] = VAR_9 + 5 * VAR_15;",
"fcb.y[fcb.VAR_9++] = (VAR_14 < VAR_15) ? -VAR_13 : VAR_13;",
"}",
"}",
"}",
"ff_set_fixed_vector(VAR_8, &fcb, 1.0, VAR_3);",
"VAR_10 = get_bits(VAR_1, 7);",
"fcb_gain = expf(avpriv_scalarproduct_float_c(VAR_0->gain_pred_err,\nVAR_7, 6) -\n5.2409161640 + wmavoice_gain_codebook_fcb[VAR_10]);",
"acb_gain = wmavoice_gain_codebook_acb[VAR_10];",
"pred_err = av_clipf(wmavoice_gain_codebook_fcb[VAR_10],\n-2.9957322736 ,\n1.6094379124 );",
"VAR_11 = 8 >> VAR_5->log_n_blocks;",
"memmove(&VAR_0->gain_pred_err[VAR_11], VAR_0->gain_pred_err,\nsizeof(*VAR_0->gain_pred_err) * (6 - VAR_11));",
"for (VAR_9 = 0; VAR_9 < VAR_11; VAR_9++)",
"VAR_0->gain_pred_err[VAR_9] = pred_err;",
"if (VAR_5->acb_type == ACB_TYPE_ASYMMETRIC) {",
"int VAR_16;",
"for (VAR_9 = 0; VAR_9 < VAR_3; VAR_9 += VAR_16) {",
"int VAR_17;",
"int VAR_18 = VAR_2 * VAR_3 + VAR_9;",
"int VAR_19 = (VAR_0->last_pitch_val << 16) +\nVAR_0->pitch_diff_sh16 * VAR_18;",
"int VAR_20 = (VAR_19 + 0x6FFF) >> 16;",
"int VAR_21 = ((VAR_20 << 16) - VAR_19) * 8 + 0x58000;",
"VAR_10 = VAR_21 >> 16;",
"if (VAR_0->pitch_diff_sh16) {",
"if (VAR_0->pitch_diff_sh16 > 0) {",
"VAR_17 = (VAR_21) &~ 0xFFFF;",
"} else",
"VAR_17 = (VAR_21 + 0x10000) &~ 0xFFFF;",
"VAR_16 = av_clip((VAR_21 - VAR_17) / VAR_0->pitch_diff_sh16 / 8,\n1, VAR_3 - VAR_9);",
"} else",
"VAR_16 = VAR_3;",
"ff_acelp_interpolatef(&VAR_6[VAR_9], &VAR_6[VAR_9 - VAR_20],\nwmavoice_ipol1_coeffs, 17,\nVAR_10, 9, VAR_16);",
"}",
"} else {",
"int VAR_22 = VAR_4 >> 2;",
"VAR_10 = VAR_4 & 3;",
"if (VAR_10) {",
"ff_acelp_interpolatef(VAR_6, &VAR_6[-VAR_22],\nwmavoice_ipol2_coeffs, 4,\nVAR_10, 8, VAR_3);",
"} else",
"av_memcpy_backptr((uint8_t *) VAR_6, sizeof(float) * VAR_22,\nsizeof(float) * VAR_3);",
"}",
"ff_weighted_vector_sumf(VAR_6, VAR_6, VAR_8,\nacb_gain, fcb_gain, VAR_3);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
103
],
[
105,
107,
109
],
[
111
],
[
113,
115,
117
],
[
121
],
[
123,
125
],
[
127
],
[
129
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145,
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165,
167
],
[
169
],
[
171
],
[
175,
177,
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191,
193,
195
],
[
197
],
[
199,
201
],
[
203
],
[
209,
211
],
[
213
]
] |
26,840 | type_init(serial_register_types)
static bool serial_isa_init(ISABus *bus, int index, CharDriverState *chr)
{
DeviceState *dev;
ISADevice *isadev;
isadev = isa_try_create(bus, TYPE_ISA_SERIAL);
if (!isadev) {
return false;
}
dev = DEVICE(isadev);
qdev_prop_set_uint32(dev, "index", index);
qdev_prop_set_chr(dev, "chardev", chr);
if (qdev_init(dev) < 0) {
return false;
}
return true;
}
| true | qemu | c6f10a5876a81f7a016714df06730c48210ee419 | type_init(serial_register_types)
static bool serial_isa_init(ISABus *bus, int index, CharDriverState *chr)
{
DeviceState *dev;
ISADevice *isadev;
isadev = isa_try_create(bus, TYPE_ISA_SERIAL);
if (!isadev) {
return false;
}
dev = DEVICE(isadev);
qdev_prop_set_uint32(dev, "index", index);
qdev_prop_set_chr(dev, "chardev", chr);
if (qdev_init(dev) < 0) {
return false;
}
return true;
}
| {
"code": [
"static bool serial_isa_init(ISABus *bus, int index, CharDriverState *chr)",
" isadev = isa_try_create(bus, TYPE_ISA_SERIAL);",
" if (!isadev) {",
" return false;",
" if (qdev_init(dev) < 0) {",
" return false;",
" return true;"
],
"line_no": [
5,
15,
17,
19,
29,
19,
35
]
} | FUNC_0(VAR_0)
static bool serial_isa_init(ISABus *bus, int index, CharDriverState *chr)
{
DeviceState *dev;
ISADevice *isadev;
isadev = isa_try_create(bus, TYPE_ISA_SERIAL);
if (!isadev) {
return false;
}
dev = DEVICE(isadev);
qdev_prop_set_uint32(dev, "index", index);
qdev_prop_set_chr(dev, "chardev", chr);
if (qdev_init(dev) < 0) {
return false;
}
return true;
}
| [
"FUNC_0(VAR_0)\nstatic bool serial_isa_init(ISABus *bus, int index, CharDriverState *chr)\n{",
"DeviceState *dev;",
"ISADevice *isadev;",
"isadev = isa_try_create(bus, TYPE_ISA_SERIAL);",
"if (!isadev) {",
"return false;",
"}",
"dev = DEVICE(isadev);",
"qdev_prop_set_uint32(dev, \"index\", index);",
"qdev_prop_set_chr(dev, \"chardev\", chr);",
"if (qdev_init(dev) < 0) {",
"return false;",
"}",
"return true;",
"}"
] | [
1,
0,
0,
1,
1,
1,
0,
0,
0,
0,
1,
0,
0,
1,
0
] | [
[
1,
5,
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
]
] |
26,842 | void url_split(char *proto, int proto_size,
char *hostname, int hostname_size,
int *port_ptr,
char *path, int path_size,
const char *url)
{
const char *p;
char *q;
int port;
port = -1;
p = url;
q = proto;
while (*p != ':' && *p != '\0') {
if ((q - proto) < proto_size - 1)
*q++ = *p;
p++;
}
if (proto_size > 0)
*q = '\0';
if (*p == '\0') {
if (proto_size > 0)
proto[0] = '\0';
if (hostname_size > 0)
hostname[0] = '\0';
p = url;
} else {
p++;
if (*p == '/')
p++;
if (*p == '/')
p++;
q = hostname;
while (*p != ':' && *p != '/' && *p != '?' && *p != '\0') {
if ((q - hostname) < hostname_size - 1)
*q++ = *p;
p++;
}
if (hostname_size > 0)
*q = '\0';
if (*p == ':') {
p++;
port = strtoul(p, (char **)&p, 10);
}
}
if (port_ptr)
*port_ptr = port;
pstrcpy(path, path_size, p);
}
| false | FFmpeg | 6ba5cbc699e77cae66bb719354fa142114b64eab | void url_split(char *proto, int proto_size,
char *hostname, int hostname_size,
int *port_ptr,
char *path, int path_size,
const char *url)
{
const char *p;
char *q;
int port;
port = -1;
p = url;
q = proto;
while (*p != ':' && *p != '\0') {
if ((q - proto) < proto_size - 1)
*q++ = *p;
p++;
}
if (proto_size > 0)
*q = '\0';
if (*p == '\0') {
if (proto_size > 0)
proto[0] = '\0';
if (hostname_size > 0)
hostname[0] = '\0';
p = url;
} else {
p++;
if (*p == '/')
p++;
if (*p == '/')
p++;
q = hostname;
while (*p != ':' && *p != '/' && *p != '?' && *p != '\0') {
if ((q - hostname) < hostname_size - 1)
*q++ = *p;
p++;
}
if (hostname_size > 0)
*q = '\0';
if (*p == ':') {
p++;
port = strtoul(p, (char **)&p, 10);
}
}
if (port_ptr)
*port_ptr = port;
pstrcpy(path, path_size, p);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(char *VAR_0, int VAR_1,
char *VAR_2, int VAR_3,
int *VAR_4,
char *VAR_5, int VAR_6,
const char *VAR_7)
{
const char *VAR_8;
char *VAR_9;
int VAR_10;
VAR_10 = -1;
VAR_8 = VAR_7;
VAR_9 = VAR_0;
while (*VAR_8 != ':' && *VAR_8 != '\0') {
if ((VAR_9 - VAR_0) < VAR_1 - 1)
*VAR_9++ = *VAR_8;
VAR_8++;
}
if (VAR_1 > 0)
*VAR_9 = '\0';
if (*VAR_8 == '\0') {
if (VAR_1 > 0)
VAR_0[0] = '\0';
if (VAR_3 > 0)
VAR_2[0] = '\0';
VAR_8 = VAR_7;
} else {
VAR_8++;
if (*VAR_8 == '/')
VAR_8++;
if (*VAR_8 == '/')
VAR_8++;
VAR_9 = VAR_2;
while (*VAR_8 != ':' && *VAR_8 != '/' && *VAR_8 != '?' && *VAR_8 != '\0') {
if ((VAR_9 - VAR_2) < VAR_3 - 1)
*VAR_9++ = *VAR_8;
VAR_8++;
}
if (VAR_3 > 0)
*VAR_9 = '\0';
if (*VAR_8 == ':') {
VAR_8++;
VAR_10 = strtoul(VAR_8, (char **)&VAR_8, 10);
}
}
if (VAR_4)
*VAR_4 = VAR_10;
pstrcpy(VAR_5, VAR_6, VAR_8);
}
| [
"void FUNC_0(char *VAR_0, int VAR_1,\nchar *VAR_2, int VAR_3,\nint *VAR_4,\nchar *VAR_5, int VAR_6,\nconst char *VAR_7)\n{",
"const char *VAR_8;",
"char *VAR_9;",
"int VAR_10;",
"VAR_10 = -1;",
"VAR_8 = VAR_7;",
"VAR_9 = VAR_0;",
"while (*VAR_8 != ':' && *VAR_8 != '\\0') {",
"if ((VAR_9 - VAR_0) < VAR_1 - 1)\n*VAR_9++ = *VAR_8;",
"VAR_8++;",
"}",
"if (VAR_1 > 0)\n*VAR_9 = '\\0';",
"if (*VAR_8 == '\\0') {",
"if (VAR_1 > 0)\nVAR_0[0] = '\\0';",
"if (VAR_3 > 0)\nVAR_2[0] = '\\0';",
"VAR_8 = VAR_7;",
"} else {",
"VAR_8++;",
"if (*VAR_8 == '/')\nVAR_8++;",
"if (*VAR_8 == '/')\nVAR_8++;",
"VAR_9 = VAR_2;",
"while (*VAR_8 != ':' && *VAR_8 != '/' && *VAR_8 != '?' && *VAR_8 != '\\0') {",
"if ((VAR_9 - VAR_2) < VAR_3 - 1)\n*VAR_9++ = *VAR_8;",
"VAR_8++;",
"}",
"if (VAR_3 > 0)\n*VAR_9 = '\\0';",
"if (*VAR_8 == ':') {",
"VAR_8++;",
"VAR_10 = strtoul(VAR_8, (char **)&VAR_8, 10);",
"}",
"}",
"if (VAR_4)\n*VAR_4 = VAR_10;",
"pstrcpy(VAR_5, VAR_6, VAR_8);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45,
47
],
[
49,
51
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
63,
65
],
[
67
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
79,
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93,
95
],
[
97
],
[
99
]
] |
26,843 | static unsigned long iv_decode_frame(Indeo3DecodeContext *s,
const uint8_t *buf, int buf_size)
{
unsigned int image_width, image_height,
chroma_width, chroma_height;
unsigned long flags, cb_offset, data_size,
y_offset, v_offset, u_offset, mc_vector_count;
const uint8_t *hdr_pos, *buf_pos;
buf_pos = buf;
buf_pos += 18; /* skip OS header (16 bytes) and version number */
flags = bytestream_get_le16(&buf_pos);
data_size = bytestream_get_le32(&buf_pos);
cb_offset = *buf_pos++;
buf_pos += 3; /* skip reserved byte and checksum */
image_height = bytestream_get_le16(&buf_pos);
image_width = bytestream_get_le16(&buf_pos);
if(avcodec_check_dimensions(NULL, image_width, image_height))
return -1;
chroma_height = ((image_height >> 2) + 3) & 0x7ffc;
chroma_width = ((image_width >> 2) + 3) & 0x7ffc;
y_offset = bytestream_get_le32(&buf_pos);
v_offset = bytestream_get_le32(&buf_pos);
u_offset = bytestream_get_le32(&buf_pos);
buf_pos += 4; /* reserved */
hdr_pos = buf_pos;
if(data_size == 0x80) return 4;
if(flags & 0x200) {
s->cur_frame = s->iv_frame + 1;
s->ref_frame = s->iv_frame;
} else {
s->cur_frame = s->iv_frame;
s->ref_frame = s->iv_frame + 1;
}
buf_pos = buf + 16 + y_offset;
mc_vector_count = bytestream_get_le32(&buf_pos);
iv_Decode_Chunk(s, s->cur_frame->Ybuf, s->ref_frame->Ybuf, image_width,
image_height, buf_pos + mc_vector_count * 2, cb_offset, hdr_pos, buf_pos,
FFMIN(image_width, 160));
if (!(s->avctx->flags & CODEC_FLAG_GRAY))
{
buf_pos = buf + 16 + v_offset;
mc_vector_count = bytestream_get_le32(&buf_pos);
iv_Decode_Chunk(s, s->cur_frame->Vbuf, s->ref_frame->Vbuf, chroma_width,
chroma_height, buf_pos + mc_vector_count * 2, cb_offset, hdr_pos, buf_pos,
FFMIN(chroma_width, 40));
buf_pos = buf + 16 + u_offset;
mc_vector_count = bytestream_get_le32(&buf_pos);
iv_Decode_Chunk(s, s->cur_frame->Ubuf, s->ref_frame->Ubuf, chroma_width,
chroma_height, buf_pos + mc_vector_count * 2, cb_offset, hdr_pos, buf_pos,
FFMIN(chroma_width, 40));
}
return 8;
}
| false | FFmpeg | 274aa1d02f12aba969b280139cf79907134dcd89 | static unsigned long iv_decode_frame(Indeo3DecodeContext *s,
const uint8_t *buf, int buf_size)
{
unsigned int image_width, image_height,
chroma_width, chroma_height;
unsigned long flags, cb_offset, data_size,
y_offset, v_offset, u_offset, mc_vector_count;
const uint8_t *hdr_pos, *buf_pos;
buf_pos = buf;
buf_pos += 18;
flags = bytestream_get_le16(&buf_pos);
data_size = bytestream_get_le32(&buf_pos);
cb_offset = *buf_pos++;
buf_pos += 3;
image_height = bytestream_get_le16(&buf_pos);
image_width = bytestream_get_le16(&buf_pos);
if(avcodec_check_dimensions(NULL, image_width, image_height))
return -1;
chroma_height = ((image_height >> 2) + 3) & 0x7ffc;
chroma_width = ((image_width >> 2) + 3) & 0x7ffc;
y_offset = bytestream_get_le32(&buf_pos);
v_offset = bytestream_get_le32(&buf_pos);
u_offset = bytestream_get_le32(&buf_pos);
buf_pos += 4;
hdr_pos = buf_pos;
if(data_size == 0x80) return 4;
if(flags & 0x200) {
s->cur_frame = s->iv_frame + 1;
s->ref_frame = s->iv_frame;
} else {
s->cur_frame = s->iv_frame;
s->ref_frame = s->iv_frame + 1;
}
buf_pos = buf + 16 + y_offset;
mc_vector_count = bytestream_get_le32(&buf_pos);
iv_Decode_Chunk(s, s->cur_frame->Ybuf, s->ref_frame->Ybuf, image_width,
image_height, buf_pos + mc_vector_count * 2, cb_offset, hdr_pos, buf_pos,
FFMIN(image_width, 160));
if (!(s->avctx->flags & CODEC_FLAG_GRAY))
{
buf_pos = buf + 16 + v_offset;
mc_vector_count = bytestream_get_le32(&buf_pos);
iv_Decode_Chunk(s, s->cur_frame->Vbuf, s->ref_frame->Vbuf, chroma_width,
chroma_height, buf_pos + mc_vector_count * 2, cb_offset, hdr_pos, buf_pos,
FFMIN(chroma_width, 40));
buf_pos = buf + 16 + u_offset;
mc_vector_count = bytestream_get_le32(&buf_pos);
iv_Decode_Chunk(s, s->cur_frame->Ubuf, s->ref_frame->Ubuf, chroma_width,
chroma_height, buf_pos + mc_vector_count * 2, cb_offset, hdr_pos, buf_pos,
FFMIN(chroma_width, 40));
}
return 8;
}
| {
"code": [],
"line_no": []
} | static unsigned long FUNC_0(Indeo3DecodeContext *VAR_0,
const uint8_t *VAR_1, int VAR_2)
{
unsigned int VAR_3, VAR_4,
VAR_5, VAR_6;
unsigned long VAR_7, VAR_8, VAR_9,
VAR_10, VAR_11, VAR_12, VAR_13;
const uint8_t *VAR_14, *buf_pos;
buf_pos = VAR_1;
buf_pos += 18;
VAR_7 = bytestream_get_le16(&buf_pos);
VAR_9 = bytestream_get_le32(&buf_pos);
VAR_8 = *buf_pos++;
buf_pos += 3;
VAR_4 = bytestream_get_le16(&buf_pos);
VAR_3 = bytestream_get_le16(&buf_pos);
if(avcodec_check_dimensions(NULL, VAR_3, VAR_4))
return -1;
VAR_6 = ((VAR_4 >> 2) + 3) & 0x7ffc;
VAR_5 = ((VAR_3 >> 2) + 3) & 0x7ffc;
VAR_10 = bytestream_get_le32(&buf_pos);
VAR_11 = bytestream_get_le32(&buf_pos);
VAR_12 = bytestream_get_le32(&buf_pos);
buf_pos += 4;
VAR_14 = buf_pos;
if(VAR_9 == 0x80) return 4;
if(VAR_7 & 0x200) {
VAR_0->cur_frame = VAR_0->iv_frame + 1;
VAR_0->ref_frame = VAR_0->iv_frame;
} else {
VAR_0->cur_frame = VAR_0->iv_frame;
VAR_0->ref_frame = VAR_0->iv_frame + 1;
}
buf_pos = VAR_1 + 16 + VAR_10;
VAR_13 = bytestream_get_le32(&buf_pos);
iv_Decode_Chunk(VAR_0, VAR_0->cur_frame->Ybuf, VAR_0->ref_frame->Ybuf, VAR_3,
VAR_4, buf_pos + VAR_13 * 2, VAR_8, VAR_14, buf_pos,
FFMIN(VAR_3, 160));
if (!(VAR_0->avctx->VAR_7 & CODEC_FLAG_GRAY))
{
buf_pos = VAR_1 + 16 + VAR_11;
VAR_13 = bytestream_get_le32(&buf_pos);
iv_Decode_Chunk(VAR_0, VAR_0->cur_frame->Vbuf, VAR_0->ref_frame->Vbuf, VAR_5,
VAR_6, buf_pos + VAR_13 * 2, VAR_8, VAR_14, buf_pos,
FFMIN(VAR_5, 40));
buf_pos = VAR_1 + 16 + VAR_12;
VAR_13 = bytestream_get_le32(&buf_pos);
iv_Decode_Chunk(VAR_0, VAR_0->cur_frame->Ubuf, VAR_0->ref_frame->Ubuf, VAR_5,
VAR_6, buf_pos + VAR_13 * 2, VAR_8, VAR_14, buf_pos,
FFMIN(VAR_5, 40));
}
return 8;
}
| [
"static unsigned long FUNC_0(Indeo3DecodeContext *VAR_0,\nconst uint8_t *VAR_1, int VAR_2)\n{",
"unsigned int VAR_3, VAR_4,\nVAR_5, VAR_6;",
"unsigned long VAR_7, VAR_8, VAR_9,\nVAR_10, VAR_11, VAR_12, VAR_13;",
"const uint8_t *VAR_14, *buf_pos;",
"buf_pos = VAR_1;",
"buf_pos += 18;",
"VAR_7 = bytestream_get_le16(&buf_pos);",
"VAR_9 = bytestream_get_le32(&buf_pos);",
"VAR_8 = *buf_pos++;",
"buf_pos += 3;",
"VAR_4 = bytestream_get_le16(&buf_pos);",
"VAR_3 = bytestream_get_le16(&buf_pos);",
"if(avcodec_check_dimensions(NULL, VAR_3, VAR_4))\nreturn -1;",
"VAR_6 = ((VAR_4 >> 2) + 3) & 0x7ffc;",
"VAR_5 = ((VAR_3 >> 2) + 3) & 0x7ffc;",
"VAR_10 = bytestream_get_le32(&buf_pos);",
"VAR_11 = bytestream_get_le32(&buf_pos);",
"VAR_12 = bytestream_get_le32(&buf_pos);",
"buf_pos += 4;",
"VAR_14 = buf_pos;",
"if(VAR_9 == 0x80) return 4;",
"if(VAR_7 & 0x200) {",
"VAR_0->cur_frame = VAR_0->iv_frame + 1;",
"VAR_0->ref_frame = VAR_0->iv_frame;",
"} else {",
"VAR_0->cur_frame = VAR_0->iv_frame;",
"VAR_0->ref_frame = VAR_0->iv_frame + 1;",
"}",
"buf_pos = VAR_1 + 16 + VAR_10;",
"VAR_13 = bytestream_get_le32(&buf_pos);",
"iv_Decode_Chunk(VAR_0, VAR_0->cur_frame->Ybuf, VAR_0->ref_frame->Ybuf, VAR_3,\nVAR_4, buf_pos + VAR_13 * 2, VAR_8, VAR_14, buf_pos,\nFFMIN(VAR_3, 160));",
"if (!(VAR_0->avctx->VAR_7 & CODEC_FLAG_GRAY))\n{",
"buf_pos = VAR_1 + 16 + VAR_11;",
"VAR_13 = bytestream_get_le32(&buf_pos);",
"iv_Decode_Chunk(VAR_0, VAR_0->cur_frame->Vbuf, VAR_0->ref_frame->Vbuf, VAR_5,\nVAR_6, buf_pos + VAR_13 * 2, VAR_8, VAR_14, buf_pos,\nFFMIN(VAR_5, 40));",
"buf_pos = VAR_1 + 16 + VAR_12;",
"VAR_13 = bytestream_get_le32(&buf_pos);",
"iv_Decode_Chunk(VAR_0, VAR_0->cur_frame->Ubuf, VAR_0->ref_frame->Ubuf, VAR_5,\nVAR_6, buf_pos + VAR_13 * 2, VAR_8, VAR_14, buf_pos,\nFFMIN(VAR_5, 40));",
"}",
"return 8;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7,
9
],
[
11,
13
],
[
15
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39,
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
85,
87,
89
],
[
93,
95
],
[
99
],
[
101
],
[
105,
107,
109
],
[
113
],
[
115
],
[
119,
121,
123
],
[
127
],
[
131
],
[
133
]
] |
26,844 | static void rtsp_send_cmd_async (AVFormatContext *s,
const char *cmd, RTSPMessageHeader *reply,
unsigned char **content_ptr)
{
RTSPState *rt = s->priv_data;
char buf[4096], buf1[1024];
rt->seq++;
av_strlcpy(buf, cmd, sizeof(buf));
snprintf(buf1, sizeof(buf1), "CSeq: %d\r\n", rt->seq);
av_strlcat(buf, buf1, sizeof(buf));
if (rt->session_id[0] != '\0' && !strstr(cmd, "\nIf-Match:")) {
snprintf(buf1, sizeof(buf1), "Session: %s\r\n", rt->session_id);
av_strlcat(buf, buf1, sizeof(buf));
}
if (rt->auth_b64)
av_strlcatf(buf, sizeof(buf),
"Authorization: Basic %s\r\n",
rt->auth_b64);
av_strlcat(buf, "\r\n", sizeof(buf));
dprintf(s, "Sending:\n%s--\n", buf);
url_write(rt->rtsp_hd, buf, strlen(buf));
rt->last_cmd_time = av_gettime();
}
| false | FFmpeg | c89658008705d949c319df3fa6f400c481ad73e1 | static void rtsp_send_cmd_async (AVFormatContext *s,
const char *cmd, RTSPMessageHeader *reply,
unsigned char **content_ptr)
{
RTSPState *rt = s->priv_data;
char buf[4096], buf1[1024];
rt->seq++;
av_strlcpy(buf, cmd, sizeof(buf));
snprintf(buf1, sizeof(buf1), "CSeq: %d\r\n", rt->seq);
av_strlcat(buf, buf1, sizeof(buf));
if (rt->session_id[0] != '\0' && !strstr(cmd, "\nIf-Match:")) {
snprintf(buf1, sizeof(buf1), "Session: %s\r\n", rt->session_id);
av_strlcat(buf, buf1, sizeof(buf));
}
if (rt->auth_b64)
av_strlcatf(buf, sizeof(buf),
"Authorization: Basic %s\r\n",
rt->auth_b64);
av_strlcat(buf, "\r\n", sizeof(buf));
dprintf(s, "Sending:\n%s--\n", buf);
url_write(rt->rtsp_hd, buf, strlen(buf));
rt->last_cmd_time = av_gettime();
}
| {
"code": [],
"line_no": []
} | static void FUNC_0 (AVFormatContext *VAR_0,
const char *VAR_1, RTSPMessageHeader *VAR_2,
unsigned char **VAR_3)
{
RTSPState *rt = VAR_0->priv_data;
char VAR_4[4096], VAR_5[1024];
rt->seq++;
av_strlcpy(VAR_4, VAR_1, sizeof(VAR_4));
snprintf(VAR_5, sizeof(VAR_5), "CSeq: %d\r\n", rt->seq);
av_strlcat(VAR_4, VAR_5, sizeof(VAR_4));
if (rt->session_id[0] != '\0' && !strstr(VAR_1, "\nIf-Match:")) {
snprintf(VAR_5, sizeof(VAR_5), "Session: %VAR_0\r\n", rt->session_id);
av_strlcat(VAR_4, VAR_5, sizeof(VAR_4));
}
if (rt->auth_b64)
av_strlcatf(VAR_4, sizeof(VAR_4),
"Authorization: Basic %VAR_0\r\n",
rt->auth_b64);
av_strlcat(VAR_4, "\r\n", sizeof(VAR_4));
dprintf(VAR_0, "Sending:\n%VAR_0--\n", VAR_4);
url_write(rt->rtsp_hd, VAR_4, strlen(VAR_4));
rt->last_cmd_time = av_gettime();
}
| [
"static void FUNC_0 (AVFormatContext *VAR_0,\nconst char *VAR_1, RTSPMessageHeader *VAR_2,\nunsigned char **VAR_3)\n{",
"RTSPState *rt = VAR_0->priv_data;",
"char VAR_4[4096], VAR_5[1024];",
"rt->seq++;",
"av_strlcpy(VAR_4, VAR_1, sizeof(VAR_4));",
"snprintf(VAR_5, sizeof(VAR_5), \"CSeq: %d\\r\\n\", rt->seq);",
"av_strlcat(VAR_4, VAR_5, sizeof(VAR_4));",
"if (rt->session_id[0] != '\\0' && !strstr(VAR_1, \"\\nIf-Match:\")) {",
"snprintf(VAR_5, sizeof(VAR_5), \"Session: %VAR_0\\r\\n\", rt->session_id);",
"av_strlcat(VAR_4, VAR_5, sizeof(VAR_4));",
"}",
"if (rt->auth_b64)\nav_strlcatf(VAR_4, sizeof(VAR_4),\n\"Authorization: Basic %VAR_0\\r\\n\",\nrt->auth_b64);",
"av_strlcat(VAR_4, \"\\r\\n\", sizeof(VAR_4));",
"dprintf(VAR_0, \"Sending:\\n%VAR_0--\\n\", VAR_4);",
"url_write(rt->rtsp_hd, VAR_4, strlen(VAR_4));",
"rt->last_cmd_time = av_gettime();",
"}"
] | [
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
],
[
43
],
[
47
],
[
49
],
[
51
]
] |
26,845 | static void apply_channel_coupling(AC3EncodeContext *s)
{
LOCAL_ALIGNED_16(CoefType, cpl_coords, [AC3_MAX_BLOCKS], [AC3_MAX_CHANNELS][16]);
#if CONFIG_AC3ENC_FLOAT
LOCAL_ALIGNED_16(int32_t, fixed_cpl_coords, [AC3_MAX_BLOCKS], [AC3_MAX_CHANNELS][16]);
#else
int32_t (*fixed_cpl_coords)[AC3_MAX_CHANNELS][16] = cpl_coords;
#endif
int blk, ch, bnd, i, j;
CoefSumType energy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][16] = {{{0}}};
int cpl_start, num_cpl_coefs;
memset(cpl_coords, 0, AC3_MAX_BLOCKS * sizeof(*cpl_coords));
#if CONFIG_AC3ENC_FLOAT
memset(fixed_cpl_coords, 0, AC3_MAX_BLOCKS * sizeof(*cpl_coords));
#endif
/* align start to 16-byte boundary. align length to multiple of 32.
note: coupling start bin % 4 will always be 1 */
cpl_start = s->start_freq[CPL_CH] - 1;
num_cpl_coefs = FFALIGN(s->num_cpl_subbands * 12 + 1, 32);
cpl_start = FFMIN(256, cpl_start + num_cpl_coefs) - num_cpl_coefs;
/* calculate coupling channel from fbw channels */
for (blk = 0; blk < s->num_blocks; blk++) {
AC3Block *block = &s->blocks[blk];
CoefType *cpl_coef = &block->mdct_coef[CPL_CH][cpl_start];
if (!block->cpl_in_use)
continue;
memset(cpl_coef, 0, num_cpl_coefs * sizeof(*cpl_coef));
for (ch = 1; ch <= s->fbw_channels; ch++) {
CoefType *ch_coef = &block->mdct_coef[ch][cpl_start];
if (!block->channel_in_cpl[ch])
continue;
for (i = 0; i < num_cpl_coefs; i++)
cpl_coef[i] += ch_coef[i];
}
/* coefficients must be clipped in order to be encoded */
clip_coefficients(&s->dsp, cpl_coef, num_cpl_coefs);
}
/* calculate energy in each band in coupling channel and each fbw channel */
/* TODO: possibly use SIMD to speed up energy calculation */
bnd = 0;
i = s->start_freq[CPL_CH];
while (i < s->cpl_end_freq) {
int band_size = s->cpl_band_sizes[bnd];
for (ch = CPL_CH; ch <= s->fbw_channels; ch++) {
for (blk = 0; blk < s->num_blocks; blk++) {
AC3Block *block = &s->blocks[blk];
if (!block->cpl_in_use || (ch > CPL_CH && !block->channel_in_cpl[ch]))
continue;
for (j = 0; j < band_size; j++) {
CoefType v = block->mdct_coef[ch][i+j];
MAC_COEF(energy[blk][ch][bnd], v, v);
}
}
}
i += band_size;
bnd++;
}
/* calculate coupling coordinates for all blocks for all channels */
for (blk = 0; blk < s->num_blocks; blk++) {
AC3Block *block = &s->blocks[blk];
if (!block->cpl_in_use)
continue;
for (ch = 1; ch <= s->fbw_channels; ch++) {
if (!block->channel_in_cpl[ch])
continue;
for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {
cpl_coords[blk][ch][bnd] = calc_cpl_coord(energy[blk][ch][bnd],
energy[blk][CPL_CH][bnd]);
}
}
}
/* determine which blocks to send new coupling coordinates for */
for (blk = 0; blk < s->num_blocks; blk++) {
AC3Block *block = &s->blocks[blk];
AC3Block *block0 = blk ? &s->blocks[blk-1] : NULL;
memset(block->new_cpl_coords, 0, sizeof(block->new_cpl_coords));
if (block->cpl_in_use) {
/* send new coordinates if this is the first block, if previous
* block did not use coupling but this block does, the channels
* using coupling has changed from the previous block, or the
* coordinate difference from the last block for any channel is
* greater than a threshold value. */
if (blk == 0 || !block0->cpl_in_use) {
for (ch = 1; ch <= s->fbw_channels; ch++)
block->new_cpl_coords[ch] = 1;
} else {
for (ch = 1; ch <= s->fbw_channels; ch++) {
if (!block->channel_in_cpl[ch])
continue;
if (!block0->channel_in_cpl[ch]) {
block->new_cpl_coords[ch] = 1;
} else {
CoefSumType coord_diff = 0;
for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {
coord_diff += FFABS(cpl_coords[blk-1][ch][bnd] -
cpl_coords[blk ][ch][bnd]);
}
coord_diff /= s->num_cpl_bands;
if (coord_diff > NEW_CPL_COORD_THRESHOLD)
block->new_cpl_coords[ch] = 1;
}
}
}
}
}
/* calculate final coupling coordinates, taking into account reusing of
coordinates in successive blocks */
for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {
blk = 0;
while (blk < s->num_blocks) {
int av_uninit(blk1);
AC3Block *block = &s->blocks[blk];
if (!block->cpl_in_use) {
blk++;
continue;
}
for (ch = 1; ch <= s->fbw_channels; ch++) {
CoefSumType energy_ch, energy_cpl;
if (!block->channel_in_cpl[ch])
continue;
energy_cpl = energy[blk][CPL_CH][bnd];
energy_ch = energy[blk][ch][bnd];
blk1 = blk+1;
while (!s->blocks[blk1].new_cpl_coords[ch] && blk1 < s->num_blocks) {
if (s->blocks[blk1].cpl_in_use) {
energy_cpl += energy[blk1][CPL_CH][bnd];
energy_ch += energy[blk1][ch][bnd];
}
blk1++;
}
cpl_coords[blk][ch][bnd] = calc_cpl_coord(energy_ch, energy_cpl);
}
blk = blk1;
}
}
/* calculate exponents/mantissas for coupling coordinates */
for (blk = 0; blk < s->num_blocks; blk++) {
AC3Block *block = &s->blocks[blk];
if (!block->cpl_in_use)
continue;
#if CONFIG_AC3ENC_FLOAT
s->ac3dsp.float_to_fixed24(fixed_cpl_coords[blk][1],
cpl_coords[blk][1],
s->fbw_channels * 16);
#endif
s->ac3dsp.extract_exponents(block->cpl_coord_exp[1],
fixed_cpl_coords[blk][1],
s->fbw_channels * 16);
for (ch = 1; ch <= s->fbw_channels; ch++) {
int bnd, min_exp, max_exp, master_exp;
if (!block->new_cpl_coords[ch])
continue;
/* determine master exponent */
min_exp = max_exp = block->cpl_coord_exp[ch][0];
for (bnd = 1; bnd < s->num_cpl_bands; bnd++) {
int exp = block->cpl_coord_exp[ch][bnd];
min_exp = FFMIN(exp, min_exp);
max_exp = FFMAX(exp, max_exp);
}
master_exp = ((max_exp - 15) + 2) / 3;
master_exp = FFMAX(master_exp, 0);
while (min_exp < master_exp * 3)
master_exp--;
for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {
block->cpl_coord_exp[ch][bnd] = av_clip(block->cpl_coord_exp[ch][bnd] -
master_exp * 3, 0, 15);
}
block->cpl_master_exp[ch] = master_exp;
/* quantize mantissas */
for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {
int cpl_exp = block->cpl_coord_exp[ch][bnd];
int cpl_mant = (fixed_cpl_coords[blk][ch][bnd] << (5 + cpl_exp + master_exp * 3)) >> 24;
if (cpl_exp == 15)
cpl_mant >>= 1;
else
cpl_mant -= 16;
block->cpl_coord_mant[ch][bnd] = cpl_mant;
}
}
}
if (CONFIG_EAC3_ENCODER && s->eac3)
ff_eac3_set_cpl_states(s);
}
| true | FFmpeg | f6fff8e54697ff4418283eb8aa9afd0d9e7e4736 | static void apply_channel_coupling(AC3EncodeContext *s)
{
LOCAL_ALIGNED_16(CoefType, cpl_coords, [AC3_MAX_BLOCKS], [AC3_MAX_CHANNELS][16]);
#if CONFIG_AC3ENC_FLOAT
LOCAL_ALIGNED_16(int32_t, fixed_cpl_coords, [AC3_MAX_BLOCKS], [AC3_MAX_CHANNELS][16]);
#else
int32_t (*fixed_cpl_coords)[AC3_MAX_CHANNELS][16] = cpl_coords;
#endif
int blk, ch, bnd, i, j;
CoefSumType energy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][16] = {{{0}}};
int cpl_start, num_cpl_coefs;
memset(cpl_coords, 0, AC3_MAX_BLOCKS * sizeof(*cpl_coords));
#if CONFIG_AC3ENC_FLOAT
memset(fixed_cpl_coords, 0, AC3_MAX_BLOCKS * sizeof(*cpl_coords));
#endif
cpl_start = s->start_freq[CPL_CH] - 1;
num_cpl_coefs = FFALIGN(s->num_cpl_subbands * 12 + 1, 32);
cpl_start = FFMIN(256, cpl_start + num_cpl_coefs) - num_cpl_coefs;
for (blk = 0; blk < s->num_blocks; blk++) {
AC3Block *block = &s->blocks[blk];
CoefType *cpl_coef = &block->mdct_coef[CPL_CH][cpl_start];
if (!block->cpl_in_use)
continue;
memset(cpl_coef, 0, num_cpl_coefs * sizeof(*cpl_coef));
for (ch = 1; ch <= s->fbw_channels; ch++) {
CoefType *ch_coef = &block->mdct_coef[ch][cpl_start];
if (!block->channel_in_cpl[ch])
continue;
for (i = 0; i < num_cpl_coefs; i++)
cpl_coef[i] += ch_coef[i];
}
clip_coefficients(&s->dsp, cpl_coef, num_cpl_coefs);
}
bnd = 0;
i = s->start_freq[CPL_CH];
while (i < s->cpl_end_freq) {
int band_size = s->cpl_band_sizes[bnd];
for (ch = CPL_CH; ch <= s->fbw_channels; ch++) {
for (blk = 0; blk < s->num_blocks; blk++) {
AC3Block *block = &s->blocks[blk];
if (!block->cpl_in_use || (ch > CPL_CH && !block->channel_in_cpl[ch]))
continue;
for (j = 0; j < band_size; j++) {
CoefType v = block->mdct_coef[ch][i+j];
MAC_COEF(energy[blk][ch][bnd], v, v);
}
}
}
i += band_size;
bnd++;
}
for (blk = 0; blk < s->num_blocks; blk++) {
AC3Block *block = &s->blocks[blk];
if (!block->cpl_in_use)
continue;
for (ch = 1; ch <= s->fbw_channels; ch++) {
if (!block->channel_in_cpl[ch])
continue;
for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {
cpl_coords[blk][ch][bnd] = calc_cpl_coord(energy[blk][ch][bnd],
energy[blk][CPL_CH][bnd]);
}
}
}
for (blk = 0; blk < s->num_blocks; blk++) {
AC3Block *block = &s->blocks[blk];
AC3Block *block0 = blk ? &s->blocks[blk-1] : NULL;
memset(block->new_cpl_coords, 0, sizeof(block->new_cpl_coords));
if (block->cpl_in_use) {
if (blk == 0 || !block0->cpl_in_use) {
for (ch = 1; ch <= s->fbw_channels; ch++)
block->new_cpl_coords[ch] = 1;
} else {
for (ch = 1; ch <= s->fbw_channels; ch++) {
if (!block->channel_in_cpl[ch])
continue;
if (!block0->channel_in_cpl[ch]) {
block->new_cpl_coords[ch] = 1;
} else {
CoefSumType coord_diff = 0;
for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {
coord_diff += FFABS(cpl_coords[blk-1][ch][bnd] -
cpl_coords[blk ][ch][bnd]);
}
coord_diff /= s->num_cpl_bands;
if (coord_diff > NEW_CPL_COORD_THRESHOLD)
block->new_cpl_coords[ch] = 1;
}
}
}
}
}
for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {
blk = 0;
while (blk < s->num_blocks) {
int av_uninit(blk1);
AC3Block *block = &s->blocks[blk];
if (!block->cpl_in_use) {
blk++;
continue;
}
for (ch = 1; ch <= s->fbw_channels; ch++) {
CoefSumType energy_ch, energy_cpl;
if (!block->channel_in_cpl[ch])
continue;
energy_cpl = energy[blk][CPL_CH][bnd];
energy_ch = energy[blk][ch][bnd];
blk1 = blk+1;
while (!s->blocks[blk1].new_cpl_coords[ch] && blk1 < s->num_blocks) {
if (s->blocks[blk1].cpl_in_use) {
energy_cpl += energy[blk1][CPL_CH][bnd];
energy_ch += energy[blk1][ch][bnd];
}
blk1++;
}
cpl_coords[blk][ch][bnd] = calc_cpl_coord(energy_ch, energy_cpl);
}
blk = blk1;
}
}
for (blk = 0; blk < s->num_blocks; blk++) {
AC3Block *block = &s->blocks[blk];
if (!block->cpl_in_use)
continue;
#if CONFIG_AC3ENC_FLOAT
s->ac3dsp.float_to_fixed24(fixed_cpl_coords[blk][1],
cpl_coords[blk][1],
s->fbw_channels * 16);
#endif
s->ac3dsp.extract_exponents(block->cpl_coord_exp[1],
fixed_cpl_coords[blk][1],
s->fbw_channels * 16);
for (ch = 1; ch <= s->fbw_channels; ch++) {
int bnd, min_exp, max_exp, master_exp;
if (!block->new_cpl_coords[ch])
continue;
min_exp = max_exp = block->cpl_coord_exp[ch][0];
for (bnd = 1; bnd < s->num_cpl_bands; bnd++) {
int exp = block->cpl_coord_exp[ch][bnd];
min_exp = FFMIN(exp, min_exp);
max_exp = FFMAX(exp, max_exp);
}
master_exp = ((max_exp - 15) + 2) / 3;
master_exp = FFMAX(master_exp, 0);
while (min_exp < master_exp * 3)
master_exp--;
for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {
block->cpl_coord_exp[ch][bnd] = av_clip(block->cpl_coord_exp[ch][bnd] -
master_exp * 3, 0, 15);
}
block->cpl_master_exp[ch] = master_exp;
for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {
int cpl_exp = block->cpl_coord_exp[ch][bnd];
int cpl_mant = (fixed_cpl_coords[blk][ch][bnd] << (5 + cpl_exp + master_exp * 3)) >> 24;
if (cpl_exp == 15)
cpl_mant >>= 1;
else
cpl_mant -= 16;
block->cpl_coord_mant[ch][bnd] = cpl_mant;
}
}
}
if (CONFIG_EAC3_ENCODER && s->eac3)
ff_eac3_set_cpl_states(s);
}
| {
"code": [
" int blk, ch, bnd, i, j;"
],
"line_no": [
17
]
} | static void FUNC_0(AC3EncodeContext *VAR_0)
{
LOCAL_ALIGNED_16(CoefType, cpl_coords, [AC3_MAX_BLOCKS], [AC3_MAX_CHANNELS][16]);
#if CONFIG_AC3ENC_FLOAT
LOCAL_ALIGNED_16(int32_t, fixed_cpl_coords, [AC3_MAX_BLOCKS], [AC3_MAX_CHANNELS][16]);
#else
int32_t (*fixed_cpl_coords)[AC3_MAX_CHANNELS][16] = cpl_coords;
#endif
int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5;
CoefSumType energy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][16] = {{{0}}};
int VAR_6, VAR_7;
memset(cpl_coords, 0, AC3_MAX_BLOCKS * sizeof(*cpl_coords));
#if CONFIG_AC3ENC_FLOAT
memset(fixed_cpl_coords, 0, AC3_MAX_BLOCKS * sizeof(*cpl_coords));
#endif
VAR_6 = VAR_0->start_freq[CPL_CH] - 1;
VAR_7 = FFALIGN(VAR_0->num_cpl_subbands * 12 + 1, 32);
VAR_6 = FFMIN(256, VAR_6 + VAR_7) - VAR_7;
for (VAR_1 = 0; VAR_1 < VAR_0->num_blocks; VAR_1++) {
AC3Block *block = &VAR_0->blocks[VAR_1];
CoefType *cpl_coef = &block->mdct_coef[CPL_CH][VAR_6];
if (!block->cpl_in_use)
continue;
memset(cpl_coef, 0, VAR_7 * sizeof(*cpl_coef));
for (VAR_2 = 1; VAR_2 <= VAR_0->fbw_channels; VAR_2++) {
CoefType *ch_coef = &block->mdct_coef[VAR_2][VAR_6];
if (!block->channel_in_cpl[VAR_2])
continue;
for (VAR_4 = 0; VAR_4 < VAR_7; VAR_4++)
cpl_coef[VAR_4] += ch_coef[VAR_4];
}
clip_coefficients(&VAR_0->dsp, cpl_coef, VAR_7);
}
VAR_3 = 0;
VAR_4 = VAR_0->start_freq[CPL_CH];
while (VAR_4 < VAR_0->cpl_end_freq) {
int VAR_8 = VAR_0->cpl_band_sizes[VAR_3];
for (VAR_2 = CPL_CH; VAR_2 <= VAR_0->fbw_channels; VAR_2++) {
for (VAR_1 = 0; VAR_1 < VAR_0->num_blocks; VAR_1++) {
AC3Block *block = &VAR_0->blocks[VAR_1];
if (!block->cpl_in_use || (VAR_2 > CPL_CH && !block->channel_in_cpl[VAR_2]))
continue;
for (VAR_5 = 0; VAR_5 < VAR_8; VAR_5++) {
CoefType v = block->mdct_coef[VAR_2][VAR_4+VAR_5];
MAC_COEF(energy[VAR_1][VAR_2][VAR_3], v, v);
}
}
}
VAR_4 += VAR_8;
VAR_3++;
}
for (VAR_1 = 0; VAR_1 < VAR_0->num_blocks; VAR_1++) {
AC3Block *block = &VAR_0->blocks[VAR_1];
if (!block->cpl_in_use)
continue;
for (VAR_2 = 1; VAR_2 <= VAR_0->fbw_channels; VAR_2++) {
if (!block->channel_in_cpl[VAR_2])
continue;
for (VAR_3 = 0; VAR_3 < VAR_0->num_cpl_bands; VAR_3++) {
cpl_coords[VAR_1][VAR_2][VAR_3] = calc_cpl_coord(energy[VAR_1][VAR_2][VAR_3],
energy[VAR_1][CPL_CH][VAR_3]);
}
}
}
for (VAR_1 = 0; VAR_1 < VAR_0->num_blocks; VAR_1++) {
AC3Block *block = &VAR_0->blocks[VAR_1];
AC3Block *block0 = VAR_1 ? &VAR_0->blocks[VAR_1-1] : NULL;
memset(block->new_cpl_coords, 0, sizeof(block->new_cpl_coords));
if (block->cpl_in_use) {
if (VAR_1 == 0 || !block0->cpl_in_use) {
for (VAR_2 = 1; VAR_2 <= VAR_0->fbw_channels; VAR_2++)
block->new_cpl_coords[VAR_2] = 1;
} else {
for (VAR_2 = 1; VAR_2 <= VAR_0->fbw_channels; VAR_2++) {
if (!block->channel_in_cpl[VAR_2])
continue;
if (!block0->channel_in_cpl[VAR_2]) {
block->new_cpl_coords[VAR_2] = 1;
} else {
CoefSumType coord_diff = 0;
for (VAR_3 = 0; VAR_3 < VAR_0->num_cpl_bands; VAR_3++) {
coord_diff += FFABS(cpl_coords[VAR_1-1][VAR_2][VAR_3] -
cpl_coords[VAR_1 ][VAR_2][VAR_3]);
}
coord_diff /= VAR_0->num_cpl_bands;
if (coord_diff > NEW_CPL_COORD_THRESHOLD)
block->new_cpl_coords[VAR_2] = 1;
}
}
}
}
}
for (VAR_3 = 0; VAR_3 < VAR_0->num_cpl_bands; VAR_3++) {
VAR_1 = 0;
while (VAR_1 < VAR_0->num_blocks) {
int av_uninit(blk1);
AC3Block *block = &VAR_0->blocks[VAR_1];
if (!block->cpl_in_use) {
VAR_1++;
continue;
}
for (VAR_2 = 1; VAR_2 <= VAR_0->fbw_channels; VAR_2++) {
CoefSumType energy_ch, energy_cpl;
if (!block->channel_in_cpl[VAR_2])
continue;
energy_cpl = energy[VAR_1][CPL_CH][VAR_3];
energy_ch = energy[VAR_1][VAR_2][VAR_3];
blk1 = VAR_1+1;
while (!VAR_0->blocks[blk1].new_cpl_coords[VAR_2] && blk1 < VAR_0->num_blocks) {
if (VAR_0->blocks[blk1].cpl_in_use) {
energy_cpl += energy[blk1][CPL_CH][VAR_3];
energy_ch += energy[blk1][VAR_2][VAR_3];
}
blk1++;
}
cpl_coords[VAR_1][VAR_2][VAR_3] = calc_cpl_coord(energy_ch, energy_cpl);
}
VAR_1 = blk1;
}
}
for (VAR_1 = 0; VAR_1 < VAR_0->num_blocks; VAR_1++) {
AC3Block *block = &VAR_0->blocks[VAR_1];
if (!block->cpl_in_use)
continue;
#if CONFIG_AC3ENC_FLOAT
VAR_0->ac3dsp.float_to_fixed24(fixed_cpl_coords[VAR_1][1],
cpl_coords[VAR_1][1],
VAR_0->fbw_channels * 16);
#endif
VAR_0->ac3dsp.extract_exponents(block->cpl_coord_exp[1],
fixed_cpl_coords[VAR_1][1],
VAR_0->fbw_channels * 16);
for (VAR_2 = 1; VAR_2 <= VAR_0->fbw_channels; VAR_2++) {
int VAR_3, min_exp, max_exp, master_exp;
if (!block->new_cpl_coords[VAR_2])
continue;
min_exp = max_exp = block->cpl_coord_exp[VAR_2][0];
for (VAR_3 = 1; VAR_3 < VAR_0->num_cpl_bands; VAR_3++) {
int exp = block->cpl_coord_exp[VAR_2][VAR_3];
min_exp = FFMIN(exp, min_exp);
max_exp = FFMAX(exp, max_exp);
}
master_exp = ((max_exp - 15) + 2) / 3;
master_exp = FFMAX(master_exp, 0);
while (min_exp < master_exp * 3)
master_exp--;
for (VAR_3 = 0; VAR_3 < VAR_0->num_cpl_bands; VAR_3++) {
block->cpl_coord_exp[VAR_2][VAR_3] = av_clip(block->cpl_coord_exp[VAR_2][VAR_3] -
master_exp * 3, 0, 15);
}
block->cpl_master_exp[VAR_2] = master_exp;
for (VAR_3 = 0; VAR_3 < VAR_0->num_cpl_bands; VAR_3++) {
int cpl_exp = block->cpl_coord_exp[VAR_2][VAR_3];
int cpl_mant = (fixed_cpl_coords[VAR_1][VAR_2][VAR_3] << (5 + cpl_exp + master_exp * 3)) >> 24;
if (cpl_exp == 15)
cpl_mant >>= 1;
else
cpl_mant -= 16;
block->cpl_coord_mant[VAR_2][VAR_3] = cpl_mant;
}
}
}
if (CONFIG_EAC3_ENCODER && VAR_0->eac3)
ff_eac3_set_cpl_states(VAR_0);
}
| [
"static void FUNC_0(AC3EncodeContext *VAR_0)\n{",
"LOCAL_ALIGNED_16(CoefType, cpl_coords, [AC3_MAX_BLOCKS], [AC3_MAX_CHANNELS][16]);",
"#if CONFIG_AC3ENC_FLOAT\nLOCAL_ALIGNED_16(int32_t, fixed_cpl_coords, [AC3_MAX_BLOCKS], [AC3_MAX_CHANNELS][16]);",
"#else\nint32_t (*fixed_cpl_coords)[AC3_MAX_CHANNELS][16] = cpl_coords;",
"#endif\nint VAR_1, VAR_2, VAR_3, VAR_4, VAR_5;",
"CoefSumType energy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][16] = {{{0}}};",
"int VAR_6, VAR_7;",
"memset(cpl_coords, 0, AC3_MAX_BLOCKS * sizeof(*cpl_coords));",
"#if CONFIG_AC3ENC_FLOAT\nmemset(fixed_cpl_coords, 0, AC3_MAX_BLOCKS * sizeof(*cpl_coords));",
"#endif\nVAR_6 = VAR_0->start_freq[CPL_CH] - 1;",
"VAR_7 = FFALIGN(VAR_0->num_cpl_subbands * 12 + 1, 32);",
"VAR_6 = FFMIN(256, VAR_6 + VAR_7) - VAR_7;",
"for (VAR_1 = 0; VAR_1 < VAR_0->num_blocks; VAR_1++) {",
"AC3Block *block = &VAR_0->blocks[VAR_1];",
"CoefType *cpl_coef = &block->mdct_coef[CPL_CH][VAR_6];",
"if (!block->cpl_in_use)\ncontinue;",
"memset(cpl_coef, 0, VAR_7 * sizeof(*cpl_coef));",
"for (VAR_2 = 1; VAR_2 <= VAR_0->fbw_channels; VAR_2++) {",
"CoefType *ch_coef = &block->mdct_coef[VAR_2][VAR_6];",
"if (!block->channel_in_cpl[VAR_2])\ncontinue;",
"for (VAR_4 = 0; VAR_4 < VAR_7; VAR_4++)",
"cpl_coef[VAR_4] += ch_coef[VAR_4];",
"}",
"clip_coefficients(&VAR_0->dsp, cpl_coef, VAR_7);",
"}",
"VAR_3 = 0;",
"VAR_4 = VAR_0->start_freq[CPL_CH];",
"while (VAR_4 < VAR_0->cpl_end_freq) {",
"int VAR_8 = VAR_0->cpl_band_sizes[VAR_3];",
"for (VAR_2 = CPL_CH; VAR_2 <= VAR_0->fbw_channels; VAR_2++) {",
"for (VAR_1 = 0; VAR_1 < VAR_0->num_blocks; VAR_1++) {",
"AC3Block *block = &VAR_0->blocks[VAR_1];",
"if (!block->cpl_in_use || (VAR_2 > CPL_CH && !block->channel_in_cpl[VAR_2]))\ncontinue;",
"for (VAR_5 = 0; VAR_5 < VAR_8; VAR_5++) {",
"CoefType v = block->mdct_coef[VAR_2][VAR_4+VAR_5];",
"MAC_COEF(energy[VAR_1][VAR_2][VAR_3], v, v);",
"}",
"}",
"}",
"VAR_4 += VAR_8;",
"VAR_3++;",
"}",
"for (VAR_1 = 0; VAR_1 < VAR_0->num_blocks; VAR_1++) {",
"AC3Block *block = &VAR_0->blocks[VAR_1];",
"if (!block->cpl_in_use)\ncontinue;",
"for (VAR_2 = 1; VAR_2 <= VAR_0->fbw_channels; VAR_2++) {",
"if (!block->channel_in_cpl[VAR_2])\ncontinue;",
"for (VAR_3 = 0; VAR_3 < VAR_0->num_cpl_bands; VAR_3++) {",
"cpl_coords[VAR_1][VAR_2][VAR_3] = calc_cpl_coord(energy[VAR_1][VAR_2][VAR_3],\nenergy[VAR_1][CPL_CH][VAR_3]);",
"}",
"}",
"}",
"for (VAR_1 = 0; VAR_1 < VAR_0->num_blocks; VAR_1++) {",
"AC3Block *block = &VAR_0->blocks[VAR_1];",
"AC3Block *block0 = VAR_1 ? &VAR_0->blocks[VAR_1-1] : NULL;",
"memset(block->new_cpl_coords, 0, sizeof(block->new_cpl_coords));",
"if (block->cpl_in_use) {",
"if (VAR_1 == 0 || !block0->cpl_in_use) {",
"for (VAR_2 = 1; VAR_2 <= VAR_0->fbw_channels; VAR_2++)",
"block->new_cpl_coords[VAR_2] = 1;",
"} else {",
"for (VAR_2 = 1; VAR_2 <= VAR_0->fbw_channels; VAR_2++) {",
"if (!block->channel_in_cpl[VAR_2])\ncontinue;",
"if (!block0->channel_in_cpl[VAR_2]) {",
"block->new_cpl_coords[VAR_2] = 1;",
"} else {",
"CoefSumType coord_diff = 0;",
"for (VAR_3 = 0; VAR_3 < VAR_0->num_cpl_bands; VAR_3++) {",
"coord_diff += FFABS(cpl_coords[VAR_1-1][VAR_2][VAR_3] -\ncpl_coords[VAR_1 ][VAR_2][VAR_3]);",
"}",
"coord_diff /= VAR_0->num_cpl_bands;",
"if (coord_diff > NEW_CPL_COORD_THRESHOLD)\nblock->new_cpl_coords[VAR_2] = 1;",
"}",
"}",
"}",
"}",
"}",
"for (VAR_3 = 0; VAR_3 < VAR_0->num_cpl_bands; VAR_3++) {",
"VAR_1 = 0;",
"while (VAR_1 < VAR_0->num_blocks) {",
"int av_uninit(blk1);",
"AC3Block *block = &VAR_0->blocks[VAR_1];",
"if (!block->cpl_in_use) {",
"VAR_1++;",
"continue;",
"}",
"for (VAR_2 = 1; VAR_2 <= VAR_0->fbw_channels; VAR_2++) {",
"CoefSumType energy_ch, energy_cpl;",
"if (!block->channel_in_cpl[VAR_2])\ncontinue;",
"energy_cpl = energy[VAR_1][CPL_CH][VAR_3];",
"energy_ch = energy[VAR_1][VAR_2][VAR_3];",
"blk1 = VAR_1+1;",
"while (!VAR_0->blocks[blk1].new_cpl_coords[VAR_2] && blk1 < VAR_0->num_blocks) {",
"if (VAR_0->blocks[blk1].cpl_in_use) {",
"energy_cpl += energy[blk1][CPL_CH][VAR_3];",
"energy_ch += energy[blk1][VAR_2][VAR_3];",
"}",
"blk1++;",
"}",
"cpl_coords[VAR_1][VAR_2][VAR_3] = calc_cpl_coord(energy_ch, energy_cpl);",
"}",
"VAR_1 = blk1;",
"}",
"}",
"for (VAR_1 = 0; VAR_1 < VAR_0->num_blocks; VAR_1++) {",
"AC3Block *block = &VAR_0->blocks[VAR_1];",
"if (!block->cpl_in_use)\ncontinue;",
"#if CONFIG_AC3ENC_FLOAT\nVAR_0->ac3dsp.float_to_fixed24(fixed_cpl_coords[VAR_1][1],\ncpl_coords[VAR_1][1],\nVAR_0->fbw_channels * 16);",
"#endif\nVAR_0->ac3dsp.extract_exponents(block->cpl_coord_exp[1],\nfixed_cpl_coords[VAR_1][1],\nVAR_0->fbw_channels * 16);",
"for (VAR_2 = 1; VAR_2 <= VAR_0->fbw_channels; VAR_2++) {",
"int VAR_3, min_exp, max_exp, master_exp;",
"if (!block->new_cpl_coords[VAR_2])\ncontinue;",
"min_exp = max_exp = block->cpl_coord_exp[VAR_2][0];",
"for (VAR_3 = 1; VAR_3 < VAR_0->num_cpl_bands; VAR_3++) {",
"int exp = block->cpl_coord_exp[VAR_2][VAR_3];",
"min_exp = FFMIN(exp, min_exp);",
"max_exp = FFMAX(exp, max_exp);",
"}",
"master_exp = ((max_exp - 15) + 2) / 3;",
"master_exp = FFMAX(master_exp, 0);",
"while (min_exp < master_exp * 3)\nmaster_exp--;",
"for (VAR_3 = 0; VAR_3 < VAR_0->num_cpl_bands; VAR_3++) {",
"block->cpl_coord_exp[VAR_2][VAR_3] = av_clip(block->cpl_coord_exp[VAR_2][VAR_3] -\nmaster_exp * 3, 0, 15);",
"}",
"block->cpl_master_exp[VAR_2] = master_exp;",
"for (VAR_3 = 0; VAR_3 < VAR_0->num_cpl_bands; VAR_3++) {",
"int cpl_exp = block->cpl_coord_exp[VAR_2][VAR_3];",
"int cpl_mant = (fixed_cpl_coords[VAR_1][VAR_2][VAR_3] << (5 + cpl_exp + master_exp * 3)) >> 24;",
"if (cpl_exp == 15)\ncpl_mant >>= 1;",
"else\ncpl_mant -= 16;",
"block->cpl_coord_mant[VAR_2][VAR_3] = cpl_mant;",
"}",
"}",
"}",
"if (CONFIG_EAC3_ENCODER && VAR_0->eac3)\nff_eac3_set_cpl_states(VAR_0);",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11,
13
],
[
15,
17
],
[
19
],
[
21
],
[
25
],
[
27,
29
],
[
31,
39
],
[
41
],
[
43
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
79
],
[
81
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103,
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
129
],
[
131
],
[
133,
135
],
[
137
],
[
139,
141
],
[
143
],
[
145,
147
],
[
149
],
[
151
],
[
153
],
[
159
],
[
161
],
[
163
],
[
167
],
[
171
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193,
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207,
209
],
[
211
],
[
213
],
[
215,
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
247
],
[
249
],
[
251
],
[
253
],
[
257
],
[
259
],
[
261,
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
299
],
[
301
],
[
303,
305
],
[
309,
311,
313,
315
],
[
317,
319,
321,
323
],
[
327
],
[
329
],
[
333,
335
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357,
359
],
[
361
],
[
363,
365
],
[
367
],
[
369
],
[
375
],
[
377
],
[
379
],
[
381,
383
],
[
385,
387
],
[
391
],
[
393
],
[
395
],
[
397
],
[
401,
403
],
[
405
]
] |
26,846 | static int get_high_utility_cell(elbg_data *elbg)
{
int i=0;
/* Using linear search, do binary if it ever turns to be speed critical */
int r = av_lfg_get(elbg->rand_state)%elbg->utility_inc[elbg->numCB-1] + 1;
while (elbg->utility_inc[i] < r)
i++;
av_assert2(elbg->cells[i]);
return i;
}
| true | FFmpeg | 87ecefdab0097537c5c30014e57b19113ab05eee | static int get_high_utility_cell(elbg_data *elbg)
{
int i=0;
int r = av_lfg_get(elbg->rand_state)%elbg->utility_inc[elbg->numCB-1] + 1;
while (elbg->utility_inc[i] < r)
i++;
av_assert2(elbg->cells[i]);
return i;
}
| {
"code": [
" int r = av_lfg_get(elbg->rand_state)%elbg->utility_inc[elbg->numCB-1] + 1;",
" while (elbg->utility_inc[i] < r)"
],
"line_no": [
9,
11
]
} | static int FUNC_0(elbg_data *VAR_0)
{
int VAR_1=0;
int VAR_2 = av_lfg_get(VAR_0->rand_state)%VAR_0->utility_inc[VAR_0->numCB-1] + 1;
while (VAR_0->utility_inc[VAR_1] < VAR_2)
VAR_1++;
av_assert2(VAR_0->cells[VAR_1]);
return VAR_1;
}
| [
"static int FUNC_0(elbg_data *VAR_0)\n{",
"int VAR_1=0;",
"int VAR_2 = av_lfg_get(VAR_0->rand_state)%VAR_0->utility_inc[VAR_0->numCB-1] + 1;",
"while (VAR_0->utility_inc[VAR_1] < VAR_2)\nVAR_1++;",
"av_assert2(VAR_0->cells[VAR_1]);",
"return VAR_1;",
"}"
] | [
0,
0,
1,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
17
],
[
21
],
[
23
]
] |
26,847 | static uint32_t acpi_find_vgia(void)
{
uint32_t rsdp_offset;
uint32_t guid_offset = 0;
AcpiRsdpDescriptor rsdp_table;
uint32_t rsdt;
AcpiRsdtDescriptorRev1 rsdt_table;
int tables_nr;
uint32_t *tables;
AcpiTableHeader ssdt_table;
VgidTable vgid_table;
int i;
/* Tables may take a short time to be set up by the guest */
for (i = 0; i < RSDP_TRIES_MAX; i++) {
rsdp_offset = acpi_find_rsdp_address();
if (rsdp_offset < RSDP_ADDR_INVALID) {
break;
}
g_usleep(RSDP_SLEEP_US);
}
g_assert_cmphex(rsdp_offset, <, RSDP_ADDR_INVALID);
acpi_parse_rsdp_table(rsdp_offset, &rsdp_table);
rsdt = rsdp_table.rsdt_physical_address;
/* read the header */
ACPI_READ_TABLE_HEADER(&rsdt_table, rsdt);
ACPI_ASSERT_CMP(rsdt_table.signature, "RSDT");
/* compute the table entries in rsdt */
tables_nr = (rsdt_table.length - sizeof(AcpiRsdtDescriptorRev1)) /
sizeof(uint32_t);
g_assert_cmpint(tables_nr, >, 0);
/* get the addresses of the tables pointed by rsdt */
tables = g_new0(uint32_t, tables_nr);
ACPI_READ_ARRAY_PTR(tables, tables_nr, rsdt);
for (i = 0; i < tables_nr; i++) {
ACPI_READ_TABLE_HEADER(&ssdt_table, tables[i]);
if (!strncmp((char *)ssdt_table.oem_table_id, "VMGENID", 7)) {
/* the first entry in the table should be VGIA
* That's all we need
*/
ACPI_READ_FIELD(vgid_table.name_op, tables[i]);
g_assert(vgid_table.name_op == 0x08); /* name */
ACPI_READ_ARRAY(vgid_table.vgia, tables[i]);
g_assert(memcmp(vgid_table.vgia, "VGIA", 4) == 0);
ACPI_READ_FIELD(vgid_table.val_op, tables[i]);
g_assert(vgid_table.val_op == 0x0C); /* dword */
ACPI_READ_FIELD(vgid_table.vgia_val, tables[i]);
/* The GUID is written at a fixed offset into the fw_cfg file
* in order to implement the "OVMF SDT Header probe suppressor"
* see docs/specs/vmgenid.txt for more details
*/
guid_offset = vgid_table.vgia_val + VMGENID_GUID_OFFSET;
break;
}
}
g_free(tables);
return guid_offset;
}
| true | qemu | 4871b51b9241b10f4fd8e04bbb21577886795e25 | static uint32_t acpi_find_vgia(void)
{
uint32_t rsdp_offset;
uint32_t guid_offset = 0;
AcpiRsdpDescriptor rsdp_table;
uint32_t rsdt;
AcpiRsdtDescriptorRev1 rsdt_table;
int tables_nr;
uint32_t *tables;
AcpiTableHeader ssdt_table;
VgidTable vgid_table;
int i;
for (i = 0; i < RSDP_TRIES_MAX; i++) {
rsdp_offset = acpi_find_rsdp_address();
if (rsdp_offset < RSDP_ADDR_INVALID) {
break;
}
g_usleep(RSDP_SLEEP_US);
}
g_assert_cmphex(rsdp_offset, <, RSDP_ADDR_INVALID);
acpi_parse_rsdp_table(rsdp_offset, &rsdp_table);
rsdt = rsdp_table.rsdt_physical_address;
ACPI_READ_TABLE_HEADER(&rsdt_table, rsdt);
ACPI_ASSERT_CMP(rsdt_table.signature, "RSDT");
tables_nr = (rsdt_table.length - sizeof(AcpiRsdtDescriptorRev1)) /
sizeof(uint32_t);
g_assert_cmpint(tables_nr, >, 0);
tables = g_new0(uint32_t, tables_nr);
ACPI_READ_ARRAY_PTR(tables, tables_nr, rsdt);
for (i = 0; i < tables_nr; i++) {
ACPI_READ_TABLE_HEADER(&ssdt_table, tables[i]);
if (!strncmp((char *)ssdt_table.oem_table_id, "VMGENID", 7)) {
ACPI_READ_FIELD(vgid_table.name_op, tables[i]);
g_assert(vgid_table.name_op == 0x08);
ACPI_READ_ARRAY(vgid_table.vgia, tables[i]);
g_assert(memcmp(vgid_table.vgia, "VGIA", 4) == 0);
ACPI_READ_FIELD(vgid_table.val_op, tables[i]);
g_assert(vgid_table.val_op == 0x0C);
ACPI_READ_FIELD(vgid_table.vgia_val, tables[i]);
guid_offset = vgid_table.vgia_val + VMGENID_GUID_OFFSET;
break;
}
}
g_free(tables);
return guid_offset;
}
| {
"code": [
" for (i = 0; i < RSDP_TRIES_MAX; i++) {",
" rsdp_offset = acpi_find_rsdp_address();",
" if (rsdp_offset < RSDP_ADDR_INVALID) {",
" break;",
" g_usleep(RSDP_SLEEP_US);"
],
"line_no": [
29,
31,
33,
35,
39
]
} | static uint32_t FUNC_0(void)
{
uint32_t rsdp_offset;
uint32_t guid_offset = 0;
AcpiRsdpDescriptor rsdp_table;
uint32_t rsdt;
AcpiRsdtDescriptorRev1 rsdt_table;
int VAR_0;
uint32_t *tables;
AcpiTableHeader ssdt_table;
VgidTable vgid_table;
int VAR_1;
for (VAR_1 = 0; VAR_1 < RSDP_TRIES_MAX; VAR_1++) {
rsdp_offset = acpi_find_rsdp_address();
if (rsdp_offset < RSDP_ADDR_INVALID) {
break;
}
g_usleep(RSDP_SLEEP_US);
}
g_assert_cmphex(rsdp_offset, <, RSDP_ADDR_INVALID);
acpi_parse_rsdp_table(rsdp_offset, &rsdp_table);
rsdt = rsdp_table.rsdt_physical_address;
ACPI_READ_TABLE_HEADER(&rsdt_table, rsdt);
ACPI_ASSERT_CMP(rsdt_table.signature, "RSDT");
VAR_0 = (rsdt_table.length - sizeof(AcpiRsdtDescriptorRev1)) /
sizeof(uint32_t);
g_assert_cmpint(VAR_0, >, 0);
tables = g_new0(uint32_t, VAR_0);
ACPI_READ_ARRAY_PTR(tables, VAR_0, rsdt);
for (VAR_1 = 0; VAR_1 < VAR_0; VAR_1++) {
ACPI_READ_TABLE_HEADER(&ssdt_table, tables[VAR_1]);
if (!strncmp((char *)ssdt_table.oem_table_id, "VMGENID", 7)) {
ACPI_READ_FIELD(vgid_table.name_op, tables[VAR_1]);
g_assert(vgid_table.name_op == 0x08);
ACPI_READ_ARRAY(vgid_table.vgia, tables[VAR_1]);
g_assert(memcmp(vgid_table.vgia, "VGIA", 4) == 0);
ACPI_READ_FIELD(vgid_table.val_op, tables[VAR_1]);
g_assert(vgid_table.val_op == 0x0C);
ACPI_READ_FIELD(vgid_table.vgia_val, tables[VAR_1]);
guid_offset = vgid_table.vgia_val + VMGENID_GUID_OFFSET;
break;
}
}
g_free(tables);
return guid_offset;
}
| [
"static uint32_t FUNC_0(void)\n{",
"uint32_t rsdp_offset;",
"uint32_t guid_offset = 0;",
"AcpiRsdpDescriptor rsdp_table;",
"uint32_t rsdt;",
"AcpiRsdtDescriptorRev1 rsdt_table;",
"int VAR_0;",
"uint32_t *tables;",
"AcpiTableHeader ssdt_table;",
"VgidTable vgid_table;",
"int VAR_1;",
"for (VAR_1 = 0; VAR_1 < RSDP_TRIES_MAX; VAR_1++) {",
"rsdp_offset = acpi_find_rsdp_address();",
"if (rsdp_offset < RSDP_ADDR_INVALID) {",
"break;",
"}",
"g_usleep(RSDP_SLEEP_US);",
"}",
"g_assert_cmphex(rsdp_offset, <, RSDP_ADDR_INVALID);",
"acpi_parse_rsdp_table(rsdp_offset, &rsdp_table);",
"rsdt = rsdp_table.rsdt_physical_address;",
"ACPI_READ_TABLE_HEADER(&rsdt_table, rsdt);",
"ACPI_ASSERT_CMP(rsdt_table.signature, \"RSDT\");",
"VAR_0 = (rsdt_table.length - sizeof(AcpiRsdtDescriptorRev1)) /\nsizeof(uint32_t);",
"g_assert_cmpint(VAR_0, >, 0);",
"tables = g_new0(uint32_t, VAR_0);",
"ACPI_READ_ARRAY_PTR(tables, VAR_0, rsdt);",
"for (VAR_1 = 0; VAR_1 < VAR_0; VAR_1++) {",
"ACPI_READ_TABLE_HEADER(&ssdt_table, tables[VAR_1]);",
"if (!strncmp((char *)ssdt_table.oem_table_id, \"VMGENID\", 7)) {",
"ACPI_READ_FIELD(vgid_table.name_op, tables[VAR_1]);",
"g_assert(vgid_table.name_op == 0x08);",
"ACPI_READ_ARRAY(vgid_table.vgia, tables[VAR_1]);",
"g_assert(memcmp(vgid_table.vgia, \"VGIA\", 4) == 0);",
"ACPI_READ_FIELD(vgid_table.val_op, tables[VAR_1]);",
"g_assert(vgid_table.val_op == 0x0C);",
"ACPI_READ_FIELD(vgid_table.vgia_val, tables[VAR_1]);",
"guid_offset = vgid_table.vgia_val + VMGENID_GUID_OFFSET;",
"break;",
"}",
"}",
"g_free(tables);",
"return guid_offset;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
51
],
[
55
],
[
57
],
[
63,
65
],
[
67
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
]
] |
26,849 | static void ff_jref_idct1_put(uint8_t *dest, int line_size, DCTELEM *block)
{
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
dest[0] = cm[(block[0] + 4)>>3];
}
| true | FFmpeg | c23acbaed40101c677dfcfbbfe0d2c230a8e8f44 | static void ff_jref_idct1_put(uint8_t *dest, int line_size, DCTELEM *block)
{
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
dest[0] = cm[(block[0] + 4)>>3];
}
| {
"code": [
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" dest[0] = cm[(block[0] + 4)>>3];",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;"
],
"line_no": [
5,
5,
5,
5,
5,
5,
5,
9,
5,
5,
5,
5,
5,
5
]
} | static void FUNC_0(uint8_t *VAR_0, int VAR_1, DCTELEM *VAR_2)
{
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
VAR_0[0] = cm[(VAR_2[0] + 4)>>3];
}
| [
"static void FUNC_0(uint8_t *VAR_0, int VAR_1, DCTELEM *VAR_2)\n{",
"uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
"VAR_0[0] = cm[(VAR_2[0] + 4)>>3];",
"}"
] | [
0,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
]
] |
26,850 | int cpu_load(QEMUFile *f, void *opaque, int version_id)
{
CPUState *env = opaque;
int i;
uint32_t tmp;
if (version_id != 5)
return -EINVAL;
for(i = 0; i < 8; i++)
qemu_get_betls(f, &env->gregs[i]);
qemu_get_be32s(f, &env->nwindows);
for(i = 0; i < env->nwindows * 16; i++)
qemu_get_betls(f, &env->regbase[i]);
/* FPU */
for(i = 0; i < TARGET_FPREGS; i++) {
union {
float32 f;
uint32_t i;
} u;
u.i = qemu_get_be32(f);
env->fpr[i] = u.f;
}
qemu_get_betls(f, &env->pc);
qemu_get_betls(f, &env->npc);
qemu_get_betls(f, &env->y);
tmp = qemu_get_be32(f);
env->cwp = 0; /* needed to ensure that the wrapping registers are
correctly updated */
PUT_PSR(env, tmp);
qemu_get_betls(f, &env->fsr);
qemu_get_betls(f, &env->tbr);
tmp = qemu_get_be32(f);
env->interrupt_index = tmp;
qemu_get_be32s(f, &env->pil_in);
#ifndef TARGET_SPARC64
qemu_get_be32s(f, &env->wim);
/* MMU */
for (i = 0; i < 32; i++)
qemu_get_be32s(f, &env->mmuregs[i]);
#else
qemu_get_be64s(f, &env->lsu);
for (i = 0; i < 16; i++) {
qemu_get_be64s(f, &env->immuregs[i]);
qemu_get_be64s(f, &env->dmmuregs[i]);
}
for (i = 0; i < 64; i++) {
qemu_get_be64s(f, &env->itlb[i].tag);
qemu_get_be64s(f, &env->itlb[i].tte);
qemu_get_be64s(f, &env->dtlb[i].tag);
qemu_get_be64s(f, &env->dtlb[i].tte);
}
qemu_get_be32s(f, &env->mmu_version);
for (i = 0; i < MAXTL_MAX; i++) {
qemu_get_be64s(f, &env->ts[i].tpc);
qemu_get_be64s(f, &env->ts[i].tnpc);
qemu_get_be64s(f, &env->ts[i].tstate);
qemu_get_be32s(f, &env->ts[i].tt);
}
qemu_get_be32s(f, &env->xcc);
qemu_get_be32s(f, &env->asi);
qemu_get_be32s(f, &env->pstate);
qemu_get_be32s(f, &env->tl);
env->tsptr = &env->ts[env->tl & MAXTL_MASK];
qemu_get_be32s(f, &env->cansave);
qemu_get_be32s(f, &env->canrestore);
qemu_get_be32s(f, &env->otherwin);
qemu_get_be32s(f, &env->wstate);
qemu_get_be32s(f, &env->cleanwin);
for (i = 0; i < 8; i++)
qemu_get_be64s(f, &env->agregs[i]);
for (i = 0; i < 8; i++)
qemu_get_be64s(f, &env->bgregs[i]);
for (i = 0; i < 8; i++)
qemu_get_be64s(f, &env->igregs[i]);
for (i = 0; i < 8; i++)
qemu_get_be64s(f, &env->mgregs[i]);
qemu_get_be64s(f, &env->fprs);
qemu_get_be64s(f, &env->tick_cmpr);
qemu_get_be64s(f, &env->stick_cmpr);
qemu_get_ptimer(f, env->tick);
qemu_get_ptimer(f, env->stick);
qemu_get_be64s(f, &env->gsr);
qemu_get_be32s(f, &env->gl);
qemu_get_be64s(f, &env->hpstate);
for (i = 0; i < MAXTL_MAX; i++)
qemu_get_be64s(f, &env->htstate[i]);
qemu_get_be64s(f, &env->hintp);
qemu_get_be64s(f, &env->htba);
qemu_get_be64s(f, &env->hver);
qemu_get_be64s(f, &env->hstick_cmpr);
qemu_get_be64s(f, &env->ssr);
qemu_get_ptimer(f, env->hstick);
#endif
tlb_flush(env, 1);
return 0;
}
| true | qemu | 8194f35a0c71a3bf169459bf715bea53b7bbc904 | int cpu_load(QEMUFile *f, void *opaque, int version_id)
{
CPUState *env = opaque;
int i;
uint32_t tmp;
if (version_id != 5)
return -EINVAL;
for(i = 0; i < 8; i++)
qemu_get_betls(f, &env->gregs[i]);
qemu_get_be32s(f, &env->nwindows);
for(i = 0; i < env->nwindows * 16; i++)
qemu_get_betls(f, &env->regbase[i]);
for(i = 0; i < TARGET_FPREGS; i++) {
union {
float32 f;
uint32_t i;
} u;
u.i = qemu_get_be32(f);
env->fpr[i] = u.f;
}
qemu_get_betls(f, &env->pc);
qemu_get_betls(f, &env->npc);
qemu_get_betls(f, &env->y);
tmp = qemu_get_be32(f);
env->cwp = 0;
PUT_PSR(env, tmp);
qemu_get_betls(f, &env->fsr);
qemu_get_betls(f, &env->tbr);
tmp = qemu_get_be32(f);
env->interrupt_index = tmp;
qemu_get_be32s(f, &env->pil_in);
#ifndef TARGET_SPARC64
qemu_get_be32s(f, &env->wim);
for (i = 0; i < 32; i++)
qemu_get_be32s(f, &env->mmuregs[i]);
#else
qemu_get_be64s(f, &env->lsu);
for (i = 0; i < 16; i++) {
qemu_get_be64s(f, &env->immuregs[i]);
qemu_get_be64s(f, &env->dmmuregs[i]);
}
for (i = 0; i < 64; i++) {
qemu_get_be64s(f, &env->itlb[i].tag);
qemu_get_be64s(f, &env->itlb[i].tte);
qemu_get_be64s(f, &env->dtlb[i].tag);
qemu_get_be64s(f, &env->dtlb[i].tte);
}
qemu_get_be32s(f, &env->mmu_version);
for (i = 0; i < MAXTL_MAX; i++) {
qemu_get_be64s(f, &env->ts[i].tpc);
qemu_get_be64s(f, &env->ts[i].tnpc);
qemu_get_be64s(f, &env->ts[i].tstate);
qemu_get_be32s(f, &env->ts[i].tt);
}
qemu_get_be32s(f, &env->xcc);
qemu_get_be32s(f, &env->asi);
qemu_get_be32s(f, &env->pstate);
qemu_get_be32s(f, &env->tl);
env->tsptr = &env->ts[env->tl & MAXTL_MASK];
qemu_get_be32s(f, &env->cansave);
qemu_get_be32s(f, &env->canrestore);
qemu_get_be32s(f, &env->otherwin);
qemu_get_be32s(f, &env->wstate);
qemu_get_be32s(f, &env->cleanwin);
for (i = 0; i < 8; i++)
qemu_get_be64s(f, &env->agregs[i]);
for (i = 0; i < 8; i++)
qemu_get_be64s(f, &env->bgregs[i]);
for (i = 0; i < 8; i++)
qemu_get_be64s(f, &env->igregs[i]);
for (i = 0; i < 8; i++)
qemu_get_be64s(f, &env->mgregs[i]);
qemu_get_be64s(f, &env->fprs);
qemu_get_be64s(f, &env->tick_cmpr);
qemu_get_be64s(f, &env->stick_cmpr);
qemu_get_ptimer(f, env->tick);
qemu_get_ptimer(f, env->stick);
qemu_get_be64s(f, &env->gsr);
qemu_get_be32s(f, &env->gl);
qemu_get_be64s(f, &env->hpstate);
for (i = 0; i < MAXTL_MAX; i++)
qemu_get_be64s(f, &env->htstate[i]);
qemu_get_be64s(f, &env->hintp);
qemu_get_be64s(f, &env->htba);
qemu_get_be64s(f, &env->hver);
qemu_get_be64s(f, &env->hstick_cmpr);
qemu_get_be64s(f, &env->ssr);
qemu_get_ptimer(f, env->hstick);
#endif
tlb_flush(env, 1);
return 0;
}
| {
"code": [
" env->tsptr = &env->ts[env->tl & MAXTL_MASK];",
" env->tsptr = &env->ts[env->tl & MAXTL_MASK];",
" env->tsptr = &env->ts[env->tl & MAXTL_MASK];",
" env->tsptr = &env->ts[env->tl & MAXTL_MASK];",
" env->tsptr = &env->ts[env->tl & MAXTL_MASK];"
],
"line_no": [
129,
129,
129,
129,
129
]
} | int FUNC_0(QEMUFile *VAR_0, void *VAR_1, int VAR_2)
{
CPUState *env = VAR_1;
int VAR_3;
uint32_t tmp;
if (VAR_2 != 5)
return -EINVAL;
for(VAR_3 = 0; VAR_3 < 8; VAR_3++)
qemu_get_betls(VAR_0, &env->gregs[VAR_3]);
qemu_get_be32s(VAR_0, &env->nwindows);
for(VAR_3 = 0; VAR_3 < env->nwindows * 16; VAR_3++)
qemu_get_betls(VAR_0, &env->regbase[VAR_3]);
for(VAR_3 = 0; VAR_3 < TARGET_FPREGS; VAR_3++) {
union {
float32 VAR_0;
uint32_t VAR_3;
} u;
u.VAR_3 = qemu_get_be32(VAR_0);
env->fpr[VAR_3] = u.VAR_0;
}
qemu_get_betls(VAR_0, &env->pc);
qemu_get_betls(VAR_0, &env->npc);
qemu_get_betls(VAR_0, &env->y);
tmp = qemu_get_be32(VAR_0);
env->cwp = 0;
PUT_PSR(env, tmp);
qemu_get_betls(VAR_0, &env->fsr);
qemu_get_betls(VAR_0, &env->tbr);
tmp = qemu_get_be32(VAR_0);
env->interrupt_index = tmp;
qemu_get_be32s(VAR_0, &env->pil_in);
#ifndef TARGET_SPARC64
qemu_get_be32s(VAR_0, &env->wim);
for (VAR_3 = 0; VAR_3 < 32; VAR_3++)
qemu_get_be32s(VAR_0, &env->mmuregs[VAR_3]);
#else
qemu_get_be64s(VAR_0, &env->lsu);
for (VAR_3 = 0; VAR_3 < 16; VAR_3++) {
qemu_get_be64s(VAR_0, &env->immuregs[VAR_3]);
qemu_get_be64s(VAR_0, &env->dmmuregs[VAR_3]);
}
for (VAR_3 = 0; VAR_3 < 64; VAR_3++) {
qemu_get_be64s(VAR_0, &env->itlb[VAR_3].tag);
qemu_get_be64s(VAR_0, &env->itlb[VAR_3].tte);
qemu_get_be64s(VAR_0, &env->dtlb[VAR_3].tag);
qemu_get_be64s(VAR_0, &env->dtlb[VAR_3].tte);
}
qemu_get_be32s(VAR_0, &env->mmu_version);
for (VAR_3 = 0; VAR_3 < MAXTL_MAX; VAR_3++) {
qemu_get_be64s(VAR_0, &env->ts[VAR_3].tpc);
qemu_get_be64s(VAR_0, &env->ts[VAR_3].tnpc);
qemu_get_be64s(VAR_0, &env->ts[VAR_3].tstate);
qemu_get_be32s(VAR_0, &env->ts[VAR_3].tt);
}
qemu_get_be32s(VAR_0, &env->xcc);
qemu_get_be32s(VAR_0, &env->asi);
qemu_get_be32s(VAR_0, &env->pstate);
qemu_get_be32s(VAR_0, &env->tl);
env->tsptr = &env->ts[env->tl & MAXTL_MASK];
qemu_get_be32s(VAR_0, &env->cansave);
qemu_get_be32s(VAR_0, &env->canrestore);
qemu_get_be32s(VAR_0, &env->otherwin);
qemu_get_be32s(VAR_0, &env->wstate);
qemu_get_be32s(VAR_0, &env->cleanwin);
for (VAR_3 = 0; VAR_3 < 8; VAR_3++)
qemu_get_be64s(VAR_0, &env->agregs[VAR_3]);
for (VAR_3 = 0; VAR_3 < 8; VAR_3++)
qemu_get_be64s(VAR_0, &env->bgregs[VAR_3]);
for (VAR_3 = 0; VAR_3 < 8; VAR_3++)
qemu_get_be64s(VAR_0, &env->igregs[VAR_3]);
for (VAR_3 = 0; VAR_3 < 8; VAR_3++)
qemu_get_be64s(VAR_0, &env->mgregs[VAR_3]);
qemu_get_be64s(VAR_0, &env->fprs);
qemu_get_be64s(VAR_0, &env->tick_cmpr);
qemu_get_be64s(VAR_0, &env->stick_cmpr);
qemu_get_ptimer(VAR_0, env->tick);
qemu_get_ptimer(VAR_0, env->stick);
qemu_get_be64s(VAR_0, &env->gsr);
qemu_get_be32s(VAR_0, &env->gl);
qemu_get_be64s(VAR_0, &env->hpstate);
for (VAR_3 = 0; VAR_3 < MAXTL_MAX; VAR_3++)
qemu_get_be64s(VAR_0, &env->htstate[VAR_3]);
qemu_get_be64s(VAR_0, &env->hintp);
qemu_get_be64s(VAR_0, &env->htba);
qemu_get_be64s(VAR_0, &env->hver);
qemu_get_be64s(VAR_0, &env->hstick_cmpr);
qemu_get_be64s(VAR_0, &env->ssr);
qemu_get_ptimer(VAR_0, env->hstick);
#endif
tlb_flush(env, 1);
return 0;
}
| [
"int FUNC_0(QEMUFile *VAR_0, void *VAR_1, int VAR_2)\n{",
"CPUState *env = VAR_1;",
"int VAR_3;",
"uint32_t tmp;",
"if (VAR_2 != 5)\nreturn -EINVAL;",
"for(VAR_3 = 0; VAR_3 < 8; VAR_3++)",
"qemu_get_betls(VAR_0, &env->gregs[VAR_3]);",
"qemu_get_be32s(VAR_0, &env->nwindows);",
"for(VAR_3 = 0; VAR_3 < env->nwindows * 16; VAR_3++)",
"qemu_get_betls(VAR_0, &env->regbase[VAR_3]);",
"for(VAR_3 = 0; VAR_3 < TARGET_FPREGS; VAR_3++) {",
"union {",
"float32 VAR_0;",
"uint32_t VAR_3;",
"} u;",
"u.VAR_3 = qemu_get_be32(VAR_0);",
"env->fpr[VAR_3] = u.VAR_0;",
"}",
"qemu_get_betls(VAR_0, &env->pc);",
"qemu_get_betls(VAR_0, &env->npc);",
"qemu_get_betls(VAR_0, &env->y);",
"tmp = qemu_get_be32(VAR_0);",
"env->cwp = 0;",
"PUT_PSR(env, tmp);",
"qemu_get_betls(VAR_0, &env->fsr);",
"qemu_get_betls(VAR_0, &env->tbr);",
"tmp = qemu_get_be32(VAR_0);",
"env->interrupt_index = tmp;",
"qemu_get_be32s(VAR_0, &env->pil_in);",
"#ifndef TARGET_SPARC64\nqemu_get_be32s(VAR_0, &env->wim);",
"for (VAR_3 = 0; VAR_3 < 32; VAR_3++)",
"qemu_get_be32s(VAR_0, &env->mmuregs[VAR_3]);",
"#else\nqemu_get_be64s(VAR_0, &env->lsu);",
"for (VAR_3 = 0; VAR_3 < 16; VAR_3++) {",
"qemu_get_be64s(VAR_0, &env->immuregs[VAR_3]);",
"qemu_get_be64s(VAR_0, &env->dmmuregs[VAR_3]);",
"}",
"for (VAR_3 = 0; VAR_3 < 64; VAR_3++) {",
"qemu_get_be64s(VAR_0, &env->itlb[VAR_3].tag);",
"qemu_get_be64s(VAR_0, &env->itlb[VAR_3].tte);",
"qemu_get_be64s(VAR_0, &env->dtlb[VAR_3].tag);",
"qemu_get_be64s(VAR_0, &env->dtlb[VAR_3].tte);",
"}",
"qemu_get_be32s(VAR_0, &env->mmu_version);",
"for (VAR_3 = 0; VAR_3 < MAXTL_MAX; VAR_3++) {",
"qemu_get_be64s(VAR_0, &env->ts[VAR_3].tpc);",
"qemu_get_be64s(VAR_0, &env->ts[VAR_3].tnpc);",
"qemu_get_be64s(VAR_0, &env->ts[VAR_3].tstate);",
"qemu_get_be32s(VAR_0, &env->ts[VAR_3].tt);",
"}",
"qemu_get_be32s(VAR_0, &env->xcc);",
"qemu_get_be32s(VAR_0, &env->asi);",
"qemu_get_be32s(VAR_0, &env->pstate);",
"qemu_get_be32s(VAR_0, &env->tl);",
"env->tsptr = &env->ts[env->tl & MAXTL_MASK];",
"qemu_get_be32s(VAR_0, &env->cansave);",
"qemu_get_be32s(VAR_0, &env->canrestore);",
"qemu_get_be32s(VAR_0, &env->otherwin);",
"qemu_get_be32s(VAR_0, &env->wstate);",
"qemu_get_be32s(VAR_0, &env->cleanwin);",
"for (VAR_3 = 0; VAR_3 < 8; VAR_3++)",
"qemu_get_be64s(VAR_0, &env->agregs[VAR_3]);",
"for (VAR_3 = 0; VAR_3 < 8; VAR_3++)",
"qemu_get_be64s(VAR_0, &env->bgregs[VAR_3]);",
"for (VAR_3 = 0; VAR_3 < 8; VAR_3++)",
"qemu_get_be64s(VAR_0, &env->igregs[VAR_3]);",
"for (VAR_3 = 0; VAR_3 < 8; VAR_3++)",
"qemu_get_be64s(VAR_0, &env->mgregs[VAR_3]);",
"qemu_get_be64s(VAR_0, &env->fprs);",
"qemu_get_be64s(VAR_0, &env->tick_cmpr);",
"qemu_get_be64s(VAR_0, &env->stick_cmpr);",
"qemu_get_ptimer(VAR_0, env->tick);",
"qemu_get_ptimer(VAR_0, env->stick);",
"qemu_get_be64s(VAR_0, &env->gsr);",
"qemu_get_be32s(VAR_0, &env->gl);",
"qemu_get_be64s(VAR_0, &env->hpstate);",
"for (VAR_3 = 0; VAR_3 < MAXTL_MAX; VAR_3++)",
"qemu_get_be64s(VAR_0, &env->htstate[VAR_3]);",
"qemu_get_be64s(VAR_0, &env->hintp);",
"qemu_get_be64s(VAR_0, &env->htba);",
"qemu_get_be64s(VAR_0, &env->hver);",
"qemu_get_be64s(VAR_0, &env->hstick_cmpr);",
"qemu_get_be64s(VAR_0, &env->ssr);",
"qemu_get_ptimer(VAR_0, env->hstick);",
"#endif\ntlb_flush(env, 1);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73,
75
],
[
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
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189,
191
],
[
193
],
[
195
]
] |
26,851 | static av_cold int v410_encode_close(AVCodecContext *avctx)
{
av_freep(&avctx->coded_frame);
return 0;
}
| false | FFmpeg | d6604b29ef544793479d7fb4e05ef6622bb3e534 | static av_cold int v410_encode_close(AVCodecContext *avctx)
{
av_freep(&avctx->coded_frame);
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
av_freep(&avctx->coded_frame);
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"av_freep(&avctx->coded_frame);",
"return 0;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
]
] |
26,852 | static int vp3_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
Vp3DecodeContext *s = avctx->priv_data;
GetBitContext gb;
static int counter = 0;
init_get_bits(&gb, buf, buf_size * 8);
if (s->theora && get_bits1(&gb))
{
int ptype = get_bits(&gb, 7);
skip_bits(&gb, 6*8); /* "theora" */
switch(ptype)
{
case 1:
theora_decode_comments(avctx, gb);
break;
case 2:
theora_decode_tables(avctx, gb);
init_dequantizer(s);
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown Theora config packet: %d\n", ptype);
}
return buf_size;
}
s->keyframe = !get_bits1(&gb);
if (!s->theora)
skip_bits(&gb, 1);
s->last_quality_index = s->quality_index;
s->quality_index = get_bits(&gb, 6);
if (s->theora >= 0x030200)
skip_bits1(&gb);
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_INFO, " VP3 %sframe #%d: Q index = %d\n",
s->keyframe?"key":"", counter, s->quality_index);
counter++;
if (s->quality_index != s->last_quality_index)
init_dequantizer(s);
if (s->keyframe) {
if (!s->theora)
{
skip_bits(&gb, 4); /* width code */
skip_bits(&gb, 4); /* height code */
if (s->version)
{
s->version = get_bits(&gb, 5);
if (counter == 1)
av_log(s->avctx, AV_LOG_DEBUG, "VP version: %d\n", s->version);
}
}
if (s->version || s->theora)
{
if (get_bits1(&gb))
av_log(s->avctx, AV_LOG_ERROR, "Warning, unsupported keyframe coding type?!\n");
skip_bits(&gb, 2); /* reserved? */
}
if (s->last_frame.data[0] == s->golden_frame.data[0]) {
if (s->golden_frame.data[0])
avctx->release_buffer(avctx, &s->golden_frame);
s->last_frame= s->golden_frame; /* ensure that we catch any access to this released frame */
} else {
if (s->golden_frame.data[0])
avctx->release_buffer(avctx, &s->golden_frame);
if (s->last_frame.data[0])
avctx->release_buffer(avctx, &s->last_frame);
}
s->golden_frame.reference = 3;
if(avctx->get_buffer(avctx, &s->golden_frame) < 0) {
av_log(s->avctx, AV_LOG_ERROR, "vp3: get_buffer() failed\n");
return -1;
}
/* golden frame is also the current frame */
memcpy(&s->current_frame, &s->golden_frame, sizeof(AVFrame));
/* time to figure out pixel addresses? */
if (!s->pixel_addresses_inited)
{
if (!s->flipped_image)
vp3_calculate_pixel_addresses(s);
else
theora_calculate_pixel_addresses(s);
}
} else {
/* allocate a new current frame */
s->current_frame.reference = 3;
if(avctx->get_buffer(avctx, &s->current_frame) < 0) {
av_log(s->avctx, AV_LOG_ERROR, "vp3: get_buffer() failed\n");
return -1;
}
}
s->current_frame.qscale_table= s->qscale_table; //FIXME allocate individual tables per AVFrame
s->current_frame.qstride= 0;
init_frame(s, &gb);
#if KEYFRAMES_ONLY
if (!s->keyframe) {
memcpy(s->current_frame.data[0], s->golden_frame.data[0],
s->current_frame.linesize[0] * s->height);
memcpy(s->current_frame.data[1], s->golden_frame.data[1],
s->current_frame.linesize[1] * s->height / 2);
memcpy(s->current_frame.data[2], s->golden_frame.data[2],
s->current_frame.linesize[2] * s->height / 2);
} else {
#endif
if (unpack_superblocks(s, &gb) ||
unpack_modes(s, &gb) ||
unpack_vectors(s, &gb) ||
unpack_dct_coeffs(s, &gb)) {
av_log(s->avctx, AV_LOG_ERROR, " vp3: could not decode frame\n");
return -1;
}
reverse_dc_prediction(s, 0, s->fragment_width, s->fragment_height);
render_fragments(s, 0, s->width, s->height, 0);
// apply_loop_filter(s);
if ((avctx->flags & CODEC_FLAG_GRAY) == 0) {
reverse_dc_prediction(s, s->u_fragment_start,
s->fragment_width / 2, s->fragment_height / 2);
reverse_dc_prediction(s, s->v_fragment_start,
s->fragment_width / 2, s->fragment_height / 2);
render_fragments(s, s->u_fragment_start, s->width / 2, s->height / 2, 1);
render_fragments(s, s->v_fragment_start, s->width / 2, s->height / 2, 2);
} else {
memset(s->current_frame.data[1], 0x80, s->width * s->height / 4);
memset(s->current_frame.data[2], 0x80, s->width * s->height / 4);
}
#if KEYFRAMES_ONLY
}
#endif
*data_size=sizeof(AVFrame);
*(AVFrame*)data= s->current_frame;
/* release the last frame, if it is allocated and if it is not the
* golden frame */
if ((s->last_frame.data[0]) &&
(s->last_frame.data[0] != s->golden_frame.data[0]))
avctx->release_buffer(avctx, &s->last_frame);
/* shuffle frames (last = current) */
memcpy(&s->last_frame, &s->current_frame, sizeof(AVFrame));
s->current_frame.data[0]= NULL; /* ensure that we catch any access to this released frame */
return buf_size;
}
| false | FFmpeg | d5e188359e768226cd272669e3f49d7f931abf71 | static int vp3_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
Vp3DecodeContext *s = avctx->priv_data;
GetBitContext gb;
static int counter = 0;
init_get_bits(&gb, buf, buf_size * 8);
if (s->theora && get_bits1(&gb))
{
int ptype = get_bits(&gb, 7);
skip_bits(&gb, 6*8);
switch(ptype)
{
case 1:
theora_decode_comments(avctx, gb);
break;
case 2:
theora_decode_tables(avctx, gb);
init_dequantizer(s);
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown Theora config packet: %d\n", ptype);
}
return buf_size;
}
s->keyframe = !get_bits1(&gb);
if (!s->theora)
skip_bits(&gb, 1);
s->last_quality_index = s->quality_index;
s->quality_index = get_bits(&gb, 6);
if (s->theora >= 0x030200)
skip_bits1(&gb);
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_INFO, " VP3 %sframe #%d: Q index = %d\n",
s->keyframe?"key":"", counter, s->quality_index);
counter++;
if (s->quality_index != s->last_quality_index)
init_dequantizer(s);
if (s->keyframe) {
if (!s->theora)
{
skip_bits(&gb, 4);
skip_bits(&gb, 4);
if (s->version)
{
s->version = get_bits(&gb, 5);
if (counter == 1)
av_log(s->avctx, AV_LOG_DEBUG, "VP version: %d\n", s->version);
}
}
if (s->version || s->theora)
{
if (get_bits1(&gb))
av_log(s->avctx, AV_LOG_ERROR, "Warning, unsupported keyframe coding type?!\n");
skip_bits(&gb, 2);
}
if (s->last_frame.data[0] == s->golden_frame.data[0]) {
if (s->golden_frame.data[0])
avctx->release_buffer(avctx, &s->golden_frame);
s->last_frame= s->golden_frame;
} else {
if (s->golden_frame.data[0])
avctx->release_buffer(avctx, &s->golden_frame);
if (s->last_frame.data[0])
avctx->release_buffer(avctx, &s->last_frame);
}
s->golden_frame.reference = 3;
if(avctx->get_buffer(avctx, &s->golden_frame) < 0) {
av_log(s->avctx, AV_LOG_ERROR, "vp3: get_buffer() failed\n");
return -1;
}
memcpy(&s->current_frame, &s->golden_frame, sizeof(AVFrame));
if (!s->pixel_addresses_inited)
{
if (!s->flipped_image)
vp3_calculate_pixel_addresses(s);
else
theora_calculate_pixel_addresses(s);
}
} else {
s->current_frame.reference = 3;
if(avctx->get_buffer(avctx, &s->current_frame) < 0) {
av_log(s->avctx, AV_LOG_ERROR, "vp3: get_buffer() failed\n");
return -1;
}
}
s->current_frame.qscale_table= s->qscale_table;
s->current_frame.qstride= 0;
init_frame(s, &gb);
#if KEYFRAMES_ONLY
if (!s->keyframe) {
memcpy(s->current_frame.data[0], s->golden_frame.data[0],
s->current_frame.linesize[0] * s->height);
memcpy(s->current_frame.data[1], s->golden_frame.data[1],
s->current_frame.linesize[1] * s->height / 2);
memcpy(s->current_frame.data[2], s->golden_frame.data[2],
s->current_frame.linesize[2] * s->height / 2);
} else {
#endif
if (unpack_superblocks(s, &gb) ||
unpack_modes(s, &gb) ||
unpack_vectors(s, &gb) ||
unpack_dct_coeffs(s, &gb)) {
av_log(s->avctx, AV_LOG_ERROR, " vp3: could not decode frame\n");
return -1;
}
reverse_dc_prediction(s, 0, s->fragment_width, s->fragment_height);
render_fragments(s, 0, s->width, s->height, 0);
if ((avctx->flags & CODEC_FLAG_GRAY) == 0) {
reverse_dc_prediction(s, s->u_fragment_start,
s->fragment_width / 2, s->fragment_height / 2);
reverse_dc_prediction(s, s->v_fragment_start,
s->fragment_width / 2, s->fragment_height / 2);
render_fragments(s, s->u_fragment_start, s->width / 2, s->height / 2, 1);
render_fragments(s, s->v_fragment_start, s->width / 2, s->height / 2, 2);
} else {
memset(s->current_frame.data[1], 0x80, s->width * s->height / 4);
memset(s->current_frame.data[2], 0x80, s->width * s->height / 4);
}
#if KEYFRAMES_ONLY
}
#endif
*data_size=sizeof(AVFrame);
*(AVFrame*)data= s->current_frame;
if ((s->last_frame.data[0]) &&
(s->last_frame.data[0] != s->golden_frame.data[0]))
avctx->release_buffer(avctx, &s->last_frame);
memcpy(&s->last_frame, &s->current_frame, sizeof(AVFrame));
s->current_frame.data[0]= NULL;
return buf_size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
uint8_t *VAR_3, int VAR_4)
{
Vp3DecodeContext *s = VAR_0->priv_data;
GetBitContext gb;
static int VAR_5 = 0;
init_get_bits(&gb, VAR_3, VAR_4 * 8);
if (s->theora && get_bits1(&gb))
{
int VAR_6 = get_bits(&gb, 7);
skip_bits(&gb, 6*8);
switch(VAR_6)
{
case 1:
theora_decode_comments(VAR_0, gb);
break;
case 2:
theora_decode_tables(VAR_0, gb);
init_dequantizer(s);
break;
default:
av_log(VAR_0, AV_LOG_ERROR, "Unknown Theora config packet: %d\n", VAR_6);
}
return VAR_4;
}
s->keyframe = !get_bits1(&gb);
if (!s->theora)
skip_bits(&gb, 1);
s->last_quality_index = s->quality_index;
s->quality_index = get_bits(&gb, 6);
if (s->theora >= 0x030200)
skip_bits1(&gb);
if (s->VAR_0->debug & FF_DEBUG_PICT_INFO)
av_log(s->VAR_0, AV_LOG_INFO, " VP3 %sframe #%d: Q index = %d\n",
s->keyframe?"key":"", VAR_5, s->quality_index);
VAR_5++;
if (s->quality_index != s->last_quality_index)
init_dequantizer(s);
if (s->keyframe) {
if (!s->theora)
{
skip_bits(&gb, 4);
skip_bits(&gb, 4);
if (s->version)
{
s->version = get_bits(&gb, 5);
if (VAR_5 == 1)
av_log(s->VAR_0, AV_LOG_DEBUG, "VP version: %d\n", s->version);
}
}
if (s->version || s->theora)
{
if (get_bits1(&gb))
av_log(s->VAR_0, AV_LOG_ERROR, "Warning, unsupported keyframe coding type?!\n");
skip_bits(&gb, 2);
}
if (s->last_frame.VAR_1[0] == s->golden_frame.VAR_1[0]) {
if (s->golden_frame.VAR_1[0])
VAR_0->release_buffer(VAR_0, &s->golden_frame);
s->last_frame= s->golden_frame;
} else {
if (s->golden_frame.VAR_1[0])
VAR_0->release_buffer(VAR_0, &s->golden_frame);
if (s->last_frame.VAR_1[0])
VAR_0->release_buffer(VAR_0, &s->last_frame);
}
s->golden_frame.reference = 3;
if(VAR_0->get_buffer(VAR_0, &s->golden_frame) < 0) {
av_log(s->VAR_0, AV_LOG_ERROR, "vp3: get_buffer() failed\n");
return -1;
}
memcpy(&s->current_frame, &s->golden_frame, sizeof(AVFrame));
if (!s->pixel_addresses_inited)
{
if (!s->flipped_image)
vp3_calculate_pixel_addresses(s);
else
theora_calculate_pixel_addresses(s);
}
} else {
s->current_frame.reference = 3;
if(VAR_0->get_buffer(VAR_0, &s->current_frame) < 0) {
av_log(s->VAR_0, AV_LOG_ERROR, "vp3: get_buffer() failed\n");
return -1;
}
}
s->current_frame.qscale_table= s->qscale_table;
s->current_frame.qstride= 0;
init_frame(s, &gb);
#if KEYFRAMES_ONLY
if (!s->keyframe) {
memcpy(s->current_frame.VAR_1[0], s->golden_frame.VAR_1[0],
s->current_frame.linesize[0] * s->height);
memcpy(s->current_frame.VAR_1[1], s->golden_frame.VAR_1[1],
s->current_frame.linesize[1] * s->height / 2);
memcpy(s->current_frame.VAR_1[2], s->golden_frame.VAR_1[2],
s->current_frame.linesize[2] * s->height / 2);
} else {
#endif
if (unpack_superblocks(s, &gb) ||
unpack_modes(s, &gb) ||
unpack_vectors(s, &gb) ||
unpack_dct_coeffs(s, &gb)) {
av_log(s->VAR_0, AV_LOG_ERROR, " vp3: could not decode frame\n");
return -1;
}
reverse_dc_prediction(s, 0, s->fragment_width, s->fragment_height);
render_fragments(s, 0, s->width, s->height, 0);
if ((VAR_0->flags & CODEC_FLAG_GRAY) == 0) {
reverse_dc_prediction(s, s->u_fragment_start,
s->fragment_width / 2, s->fragment_height / 2);
reverse_dc_prediction(s, s->v_fragment_start,
s->fragment_width / 2, s->fragment_height / 2);
render_fragments(s, s->u_fragment_start, s->width / 2, s->height / 2, 1);
render_fragments(s, s->v_fragment_start, s->width / 2, s->height / 2, 2);
} else {
memset(s->current_frame.VAR_1[1], 0x80, s->width * s->height / 4);
memset(s->current_frame.VAR_1[2], 0x80, s->width * s->height / 4);
}
#if KEYFRAMES_ONLY
}
#endif
*VAR_2=sizeof(AVFrame);
*(AVFrame*)VAR_1= s->current_frame;
if ((s->last_frame.VAR_1[0]) &&
(s->last_frame.VAR_1[0] != s->golden_frame.VAR_1[0]))
VAR_0->release_buffer(VAR_0, &s->last_frame);
memcpy(&s->last_frame, &s->current_frame, sizeof(AVFrame));
s->current_frame.VAR_1[0]= NULL;
return VAR_4;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nuint8_t *VAR_3, int VAR_4)\n{",
"Vp3DecodeContext *s = VAR_0->priv_data;",
"GetBitContext gb;",
"static int VAR_5 = 0;",
"init_get_bits(&gb, VAR_3, VAR_4 * 8);",
"if (s->theora && get_bits1(&gb))\n{",
"int VAR_6 = get_bits(&gb, 7);",
"skip_bits(&gb, 6*8);",
"switch(VAR_6)\n{",
"case 1:\ntheora_decode_comments(VAR_0, gb);",
"break;",
"case 2:\ntheora_decode_tables(VAR_0, gb);",
"init_dequantizer(s);",
"break;",
"default:\nav_log(VAR_0, AV_LOG_ERROR, \"Unknown Theora config packet: %d\\n\", VAR_6);",
"}",
"return VAR_4;",
"}",
"s->keyframe = !get_bits1(&gb);",
"if (!s->theora)\nskip_bits(&gb, 1);",
"s->last_quality_index = s->quality_index;",
"s->quality_index = get_bits(&gb, 6);",
"if (s->theora >= 0x030200)\nskip_bits1(&gb);",
"if (s->VAR_0->debug & FF_DEBUG_PICT_INFO)\nav_log(s->VAR_0, AV_LOG_INFO, \" VP3 %sframe #%d: Q index = %d\\n\",\ns->keyframe?\"key\":\"\", VAR_5, s->quality_index);",
"VAR_5++;",
"if (s->quality_index != s->last_quality_index)\ninit_dequantizer(s);",
"if (s->keyframe) {",
"if (!s->theora)\n{",
"skip_bits(&gb, 4);",
"skip_bits(&gb, 4);",
"if (s->version)\n{",
"s->version = get_bits(&gb, 5);",
"if (VAR_5 == 1)\nav_log(s->VAR_0, AV_LOG_DEBUG, \"VP version: %d\\n\", s->version);",
"}",
"}",
"if (s->version || s->theora)\n{",
"if (get_bits1(&gb))\nav_log(s->VAR_0, AV_LOG_ERROR, \"Warning, unsupported keyframe coding type?!\\n\");",
"skip_bits(&gb, 2);",
"}",
"if (s->last_frame.VAR_1[0] == s->golden_frame.VAR_1[0]) {",
"if (s->golden_frame.VAR_1[0])\nVAR_0->release_buffer(VAR_0, &s->golden_frame);",
"s->last_frame= s->golden_frame;",
"} else {",
"if (s->golden_frame.VAR_1[0])\nVAR_0->release_buffer(VAR_0, &s->golden_frame);",
"if (s->last_frame.VAR_1[0])\nVAR_0->release_buffer(VAR_0, &s->last_frame);",
"}",
"s->golden_frame.reference = 3;",
"if(VAR_0->get_buffer(VAR_0, &s->golden_frame) < 0) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \"vp3: get_buffer() failed\\n\");",
"return -1;",
"}",
"memcpy(&s->current_frame, &s->golden_frame, sizeof(AVFrame));",
"if (!s->pixel_addresses_inited)\n{",
"if (!s->flipped_image)\nvp3_calculate_pixel_addresses(s);",
"else\ntheora_calculate_pixel_addresses(s);",
"}",
"} else {",
"s->current_frame.reference = 3;",
"if(VAR_0->get_buffer(VAR_0, &s->current_frame) < 0) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \"vp3: get_buffer() failed\\n\");",
"return -1;",
"}",
"}",
"s->current_frame.qscale_table= s->qscale_table;",
"s->current_frame.qstride= 0;",
"init_frame(s, &gb);",
"#if KEYFRAMES_ONLY\nif (!s->keyframe) {",
"memcpy(s->current_frame.VAR_1[0], s->golden_frame.VAR_1[0],\ns->current_frame.linesize[0] * s->height);",
"memcpy(s->current_frame.VAR_1[1], s->golden_frame.VAR_1[1],\ns->current_frame.linesize[1] * s->height / 2);",
"memcpy(s->current_frame.VAR_1[2], s->golden_frame.VAR_1[2],\ns->current_frame.linesize[2] * s->height / 2);",
"} else {",
"#endif\nif (unpack_superblocks(s, &gb) ||\nunpack_modes(s, &gb) ||\nunpack_vectors(s, &gb) ||\nunpack_dct_coeffs(s, &gb)) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \" vp3: could not decode frame\\n\");",
"return -1;",
"}",
"reverse_dc_prediction(s, 0, s->fragment_width, s->fragment_height);",
"render_fragments(s, 0, s->width, s->height, 0);",
"if ((VAR_0->flags & CODEC_FLAG_GRAY) == 0) {",
"reverse_dc_prediction(s, s->u_fragment_start,\ns->fragment_width / 2, s->fragment_height / 2);",
"reverse_dc_prediction(s, s->v_fragment_start,\ns->fragment_width / 2, s->fragment_height / 2);",
"render_fragments(s, s->u_fragment_start, s->width / 2, s->height / 2, 1);",
"render_fragments(s, s->v_fragment_start, s->width / 2, s->height / 2, 2);",
"} else {",
"memset(s->current_frame.VAR_1[1], 0x80, s->width * s->height / 4);",
"memset(s->current_frame.VAR_1[2], 0x80, s->width * s->height / 4);",
"}",
"#if KEYFRAMES_ONLY\n}",
"#endif\n*VAR_2=sizeof(AVFrame);",
"*(AVFrame*)VAR_1= s->current_frame;",
"if ((s->last_frame.VAR_1[0]) &&\n(s->last_frame.VAR_1[0] != s->golden_frame.VAR_1[0]))\nVAR_0->release_buffer(VAR_0, &s->last_frame);",
"memcpy(&s->last_frame, &s->current_frame, sizeof(AVFrame));",
"s->current_frame.VAR_1[0]= NULL;",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21,
23
],
[
25
],
[
29
],
[
33,
35
],
[
37,
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73,
75
],
[
79,
81,
83
],
[
85
],
[
89,
91
],
[
95
],
[
97,
99
],
[
101
],
[
103
],
[
105,
107
],
[
109
],
[
111,
113
],
[
115
],
[
117
],
[
119,
121
],
[
123,
125
],
[
127
],
[
129
],
[
133
],
[
135,
137
],
[
139
],
[
141
],
[
143,
145
],
[
147,
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
169
],
[
175,
177
],
[
179,
181
],
[
183,
185
],
[
187
],
[
189
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
207
],
[
209
],
[
213
],
[
217,
219
],
[
223,
225
],
[
227,
229
],
[
231,
233
],
[
237
],
[
239,
243,
245,
247,
249
],
[
253
],
[
255
],
[
257
],
[
261
],
[
263
],
[
269
],
[
271,
273
],
[
275,
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
293,
295
],
[
297,
301
],
[
303
],
[
311,
313,
315
],
[
321
],
[
323
],
[
327
],
[
329
]
] |
26,853 | static int au_read_header(AVFormatContext *s)
{
int size;
unsigned int tag;
AVIOContext *pb = s->pb;
unsigned int id, channels, rate;
enum AVCodecID codec;
AVStream *st;
/* check ".snd" header */
tag = avio_rl32(pb);
if (tag != MKTAG('.', 's', 'n', 'd'))
return -1;
size = avio_rb32(pb); /* header size */
avio_rb32(pb); /* data size */
id = avio_rb32(pb);
rate = avio_rb32(pb);
channels = avio_rb32(pb);
codec = ff_codec_get_id(codec_au_tags, id);
if (!av_get_bits_per_sample(codec)) {
av_log_ask_for_sample(s, "could not determine bits per sample\n");
return AVERROR_PATCHWELCOME;
}
if (channels == 0 || channels > 64) {
av_log(s, AV_LOG_ERROR, "Invalid number of channels %d\n", channels);
return AVERROR_INVALIDDATA;
}
if (size >= 24) {
/* skip unused data */
avio_skip(pb, size - 24);
}
/* now we are ready: build format streams */
st = avformat_new_stream(s, NULL);
if (!st)
return -1;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_tag = id;
st->codec->codec_id = codec;
st->codec->channels = channels;
st->codec->sample_rate = rate;
avpriv_set_pts_info(st, 64, 1, rate);
return 0;
}
| false | FFmpeg | 3f98848d6e04a11f28e776b665fb14e58d56e015 | static int au_read_header(AVFormatContext *s)
{
int size;
unsigned int tag;
AVIOContext *pb = s->pb;
unsigned int id, channels, rate;
enum AVCodecID codec;
AVStream *st;
tag = avio_rl32(pb);
if (tag != MKTAG('.', 's', 'n', 'd'))
return -1;
size = avio_rb32(pb);
avio_rb32(pb);
id = avio_rb32(pb);
rate = avio_rb32(pb);
channels = avio_rb32(pb);
codec = ff_codec_get_id(codec_au_tags, id);
if (!av_get_bits_per_sample(codec)) {
av_log_ask_for_sample(s, "could not determine bits per sample\n");
return AVERROR_PATCHWELCOME;
}
if (channels == 0 || channels > 64) {
av_log(s, AV_LOG_ERROR, "Invalid number of channels %d\n", channels);
return AVERROR_INVALIDDATA;
}
if (size >= 24) {
avio_skip(pb, size - 24);
}
st = avformat_new_stream(s, NULL);
if (!st)
return -1;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_tag = id;
st->codec->codec_id = codec;
st->codec->channels = channels;
st->codec->sample_rate = rate;
avpriv_set_pts_info(st, 64, 1, rate);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0)
{
int VAR_1;
unsigned int VAR_2;
AVIOContext *pb = VAR_0->pb;
unsigned int VAR_3, VAR_4, VAR_5;
enum AVCodecID VAR_6;
AVStream *st;
VAR_2 = avio_rl32(pb);
if (VAR_2 != MKTAG('.', 'VAR_0', 'n', 'd'))
return -1;
VAR_1 = avio_rb32(pb);
avio_rb32(pb);
VAR_3 = avio_rb32(pb);
VAR_5 = avio_rb32(pb);
VAR_4 = avio_rb32(pb);
VAR_6 = ff_codec_get_id(codec_au_tags, VAR_3);
if (!av_get_bits_per_sample(VAR_6)) {
av_log_ask_for_sample(VAR_0, "could not determine bits per sample\n");
return AVERROR_PATCHWELCOME;
}
if (VAR_4 == 0 || VAR_4 > 64) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid number of VAR_4 %d\n", VAR_4);
return AVERROR_INVALIDDATA;
}
if (VAR_1 >= 24) {
avio_skip(pb, VAR_1 - 24);
}
st = avformat_new_stream(VAR_0, NULL);
if (!st)
return -1;
st->VAR_6->codec_type = AVMEDIA_TYPE_AUDIO;
st->VAR_6->codec_tag = VAR_3;
st->VAR_6->codec_id = VAR_6;
st->VAR_6->VAR_4 = VAR_4;
st->VAR_6->sample_rate = VAR_5;
avpriv_set_pts_info(st, 64, 1, VAR_5);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"int VAR_1;",
"unsigned int VAR_2;",
"AVIOContext *pb = VAR_0->pb;",
"unsigned int VAR_3, VAR_4, VAR_5;",
"enum AVCodecID VAR_6;",
"AVStream *st;",
"VAR_2 = avio_rl32(pb);",
"if (VAR_2 != MKTAG('.', 'VAR_0', 'n', 'd'))\nreturn -1;",
"VAR_1 = avio_rb32(pb);",
"avio_rb32(pb);",
"VAR_3 = avio_rb32(pb);",
"VAR_5 = avio_rb32(pb);",
"VAR_4 = avio_rb32(pb);",
"VAR_6 = ff_codec_get_id(codec_au_tags, VAR_3);",
"if (!av_get_bits_per_sample(VAR_6)) {",
"av_log_ask_for_sample(VAR_0, \"could not determine bits per sample\\n\");",
"return AVERROR_PATCHWELCOME;",
"}",
"if (VAR_4 == 0 || VAR_4 > 64) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid number of VAR_4 %d\\n\", VAR_4);",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_1 >= 24) {",
"avio_skip(pb, VAR_1 - 24);",
"}",
"st = avformat_new_stream(VAR_0, NULL);",
"if (!st)\nreturn -1;",
"st->VAR_6->codec_type = AVMEDIA_TYPE_AUDIO;",
"st->VAR_6->codec_tag = VAR_3;",
"st->VAR_6->codec_id = VAR_6;",
"st->VAR_6->VAR_4 = VAR_4;",
"st->VAR_6->sample_rate = VAR_5;",
"avpriv_set_pts_info(st, 64, 1, VAR_5);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
69
],
[
71
],
[
77
],
[
79,
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
]
] |
26,854 | static void mtree_print_mr(fprintf_function mon_printf, void *f,
const MemoryRegion *mr, unsigned int level,
target_phys_addr_t base,
MemoryRegionListHead *alias_print_queue)
{
MemoryRegionList *new_ml, *ml, *next_ml;
MemoryRegionListHead submr_print_queue;
const MemoryRegion *submr;
unsigned int i;
if (!mr) {
return;
}
for (i = 0; i < level; i++) {
mon_printf(f, " ");
}
if (mr->alias) {
MemoryRegionList *ml;
bool found = false;
/* check if the alias is already in the queue */
QTAILQ_FOREACH(ml, alias_print_queue, queue) {
if (ml->mr == mr->alias && !ml->printed) {
found = true;
}
}
if (!found) {
ml = g_new(MemoryRegionList, 1);
ml->mr = mr->alias;
ml->printed = false;
QTAILQ_INSERT_TAIL(alias_print_queue, ml, queue);
}
mon_printf(f, TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d): alias %s @%s "
TARGET_FMT_plx "-" TARGET_FMT_plx "\n",
base + mr->addr,
base + mr->addr
+ (target_phys_addr_t)int128_get64(mr->size) - 1,
mr->priority,
mr->name,
mr->alias->name,
mr->alias_offset,
mr->alias_offset
+ (target_phys_addr_t)int128_get64(mr->size) - 1);
} else {
mon_printf(f, TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d): %s\n",
base + mr->addr,
base + mr->addr
+ (target_phys_addr_t)int128_get64(mr->size) - 1,
mr->priority,
mr->name);
}
QTAILQ_INIT(&submr_print_queue);
QTAILQ_FOREACH(submr, &mr->subregions, subregions_link) {
new_ml = g_new(MemoryRegionList, 1);
new_ml->mr = submr;
QTAILQ_FOREACH(ml, &submr_print_queue, queue) {
if (new_ml->mr->addr < ml->mr->addr ||
(new_ml->mr->addr == ml->mr->addr &&
new_ml->mr->priority > ml->mr->priority)) {
QTAILQ_INSERT_BEFORE(ml, new_ml, queue);
new_ml = NULL;
break;
}
}
if (new_ml) {
QTAILQ_INSERT_TAIL(&submr_print_queue, new_ml, queue);
}
}
QTAILQ_FOREACH(ml, &submr_print_queue, queue) {
mtree_print_mr(mon_printf, f, ml->mr, level + 1, base + mr->addr,
alias_print_queue);
}
QTAILQ_FOREACH_SAFE(next_ml, &submr_print_queue, queue, ml) {
g_free(ml);
}
}
| true | qemu | 88365e47dd19da8776252a94ed5fa0b7242ea9e9 | static void mtree_print_mr(fprintf_function mon_printf, void *f,
const MemoryRegion *mr, unsigned int level,
target_phys_addr_t base,
MemoryRegionListHead *alias_print_queue)
{
MemoryRegionList *new_ml, *ml, *next_ml;
MemoryRegionListHead submr_print_queue;
const MemoryRegion *submr;
unsigned int i;
if (!mr) {
return;
}
for (i = 0; i < level; i++) {
mon_printf(f, " ");
}
if (mr->alias) {
MemoryRegionList *ml;
bool found = false;
QTAILQ_FOREACH(ml, alias_print_queue, queue) {
if (ml->mr == mr->alias && !ml->printed) {
found = true;
}
}
if (!found) {
ml = g_new(MemoryRegionList, 1);
ml->mr = mr->alias;
ml->printed = false;
QTAILQ_INSERT_TAIL(alias_print_queue, ml, queue);
}
mon_printf(f, TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d): alias %s @%s "
TARGET_FMT_plx "-" TARGET_FMT_plx "\n",
base + mr->addr,
base + mr->addr
+ (target_phys_addr_t)int128_get64(mr->size) - 1,
mr->priority,
mr->name,
mr->alias->name,
mr->alias_offset,
mr->alias_offset
+ (target_phys_addr_t)int128_get64(mr->size) - 1);
} else {
mon_printf(f, TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d): %s\n",
base + mr->addr,
base + mr->addr
+ (target_phys_addr_t)int128_get64(mr->size) - 1,
mr->priority,
mr->name);
}
QTAILQ_INIT(&submr_print_queue);
QTAILQ_FOREACH(submr, &mr->subregions, subregions_link) {
new_ml = g_new(MemoryRegionList, 1);
new_ml->mr = submr;
QTAILQ_FOREACH(ml, &submr_print_queue, queue) {
if (new_ml->mr->addr < ml->mr->addr ||
(new_ml->mr->addr == ml->mr->addr &&
new_ml->mr->priority > ml->mr->priority)) {
QTAILQ_INSERT_BEFORE(ml, new_ml, queue);
new_ml = NULL;
break;
}
}
if (new_ml) {
QTAILQ_INSERT_TAIL(&submr_print_queue, new_ml, queue);
}
}
QTAILQ_FOREACH(ml, &submr_print_queue, queue) {
mtree_print_mr(mon_printf, f, ml->mr, level + 1, base + mr->addr,
alias_print_queue);
}
QTAILQ_FOREACH_SAFE(next_ml, &submr_print_queue, queue, ml) {
g_free(ml);
}
}
| {
"code": [
" QTAILQ_FOREACH_SAFE(next_ml, &submr_print_queue, queue, ml) {"
],
"line_no": [
159
]
} | static void FUNC_0(fprintf_function VAR_0, void *VAR_1,
const MemoryRegion *VAR_2, unsigned int VAR_3,
target_phys_addr_t VAR_4,
MemoryRegionListHead *VAR_5)
{
MemoryRegionList *new_ml, *ml, *next_ml;
MemoryRegionListHead submr_print_queue;
const MemoryRegion *VAR_6;
unsigned int VAR_7;
if (!VAR_2) {
return;
}
for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) {
VAR_0(VAR_1, " ");
}
if (VAR_2->alias) {
MemoryRegionList *ml;
bool found = false;
QTAILQ_FOREACH(ml, VAR_5, queue) {
if (ml->VAR_2 == VAR_2->alias && !ml->printed) {
found = true;
}
}
if (!found) {
ml = g_new(MemoryRegionList, 1);
ml->VAR_2 = VAR_2->alias;
ml->printed = false;
QTAILQ_INSERT_TAIL(VAR_5, ml, queue);
}
VAR_0(VAR_1, TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d): alias %s @%s "
TARGET_FMT_plx "-" TARGET_FMT_plx "\n",
VAR_4 + VAR_2->addr,
VAR_4 + VAR_2->addr
+ (target_phys_addr_t)int128_get64(VAR_2->size) - 1,
VAR_2->priority,
VAR_2->name,
VAR_2->alias->name,
VAR_2->alias_offset,
VAR_2->alias_offset
+ (target_phys_addr_t)int128_get64(VAR_2->size) - 1);
} else {
VAR_0(VAR_1, TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d): %s\n",
VAR_4 + VAR_2->addr,
VAR_4 + VAR_2->addr
+ (target_phys_addr_t)int128_get64(VAR_2->size) - 1,
VAR_2->priority,
VAR_2->name);
}
QTAILQ_INIT(&submr_print_queue);
QTAILQ_FOREACH(VAR_6, &VAR_2->subregions, subregions_link) {
new_ml = g_new(MemoryRegionList, 1);
new_ml->VAR_2 = VAR_6;
QTAILQ_FOREACH(ml, &submr_print_queue, queue) {
if (new_ml->VAR_2->addr < ml->VAR_2->addr ||
(new_ml->VAR_2->addr == ml->VAR_2->addr &&
new_ml->VAR_2->priority > ml->VAR_2->priority)) {
QTAILQ_INSERT_BEFORE(ml, new_ml, queue);
new_ml = NULL;
break;
}
}
if (new_ml) {
QTAILQ_INSERT_TAIL(&submr_print_queue, new_ml, queue);
}
}
QTAILQ_FOREACH(ml, &submr_print_queue, queue) {
FUNC_0(VAR_0, VAR_1, ml->VAR_2, VAR_3 + 1, VAR_4 + VAR_2->addr,
VAR_5);
}
QTAILQ_FOREACH_SAFE(next_ml, &submr_print_queue, queue, ml) {
g_free(ml);
}
}
| [
"static void FUNC_0(fprintf_function VAR_0, void *VAR_1,\nconst MemoryRegion *VAR_2, unsigned int VAR_3,\ntarget_phys_addr_t VAR_4,\nMemoryRegionListHead *VAR_5)\n{",
"MemoryRegionList *new_ml, *ml, *next_ml;",
"MemoryRegionListHead submr_print_queue;",
"const MemoryRegion *VAR_6;",
"unsigned int VAR_7;",
"if (!VAR_2) {",
"return;",
"}",
"for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) {",
"VAR_0(VAR_1, \" \");",
"}",
"if (VAR_2->alias) {",
"MemoryRegionList *ml;",
"bool found = false;",
"QTAILQ_FOREACH(ml, VAR_5, queue) {",
"if (ml->VAR_2 == VAR_2->alias && !ml->printed) {",
"found = true;",
"}",
"}",
"if (!found) {",
"ml = g_new(MemoryRegionList, 1);",
"ml->VAR_2 = VAR_2->alias;",
"ml->printed = false;",
"QTAILQ_INSERT_TAIL(VAR_5, ml, queue);",
"}",
"VAR_0(VAR_1, TARGET_FMT_plx \"-\" TARGET_FMT_plx \" (prio %d): alias %s @%s \"\nTARGET_FMT_plx \"-\" TARGET_FMT_plx \"\\n\",\nVAR_4 + VAR_2->addr,\nVAR_4 + VAR_2->addr\n+ (target_phys_addr_t)int128_get64(VAR_2->size) - 1,\nVAR_2->priority,\nVAR_2->name,\nVAR_2->alias->name,\nVAR_2->alias_offset,\nVAR_2->alias_offset\n+ (target_phys_addr_t)int128_get64(VAR_2->size) - 1);",
"} else {",
"VAR_0(VAR_1, TARGET_FMT_plx \"-\" TARGET_FMT_plx \" (prio %d): %s\\n\",\nVAR_4 + VAR_2->addr,\nVAR_4 + VAR_2->addr\n+ (target_phys_addr_t)int128_get64(VAR_2->size) - 1,\nVAR_2->priority,\nVAR_2->name);",
"}",
"QTAILQ_INIT(&submr_print_queue);",
"QTAILQ_FOREACH(VAR_6, &VAR_2->subregions, subregions_link) {",
"new_ml = g_new(MemoryRegionList, 1);",
"new_ml->VAR_2 = VAR_6;",
"QTAILQ_FOREACH(ml, &submr_print_queue, queue) {",
"if (new_ml->VAR_2->addr < ml->VAR_2->addr ||\n(new_ml->VAR_2->addr == ml->VAR_2->addr &&\nnew_ml->VAR_2->priority > ml->VAR_2->priority)) {",
"QTAILQ_INSERT_BEFORE(ml, new_ml, queue);",
"new_ml = NULL;",
"break;",
"}",
"}",
"if (new_ml) {",
"QTAILQ_INSERT_TAIL(&submr_print_queue, new_ml, queue);",
"}",
"}",
"QTAILQ_FOREACH(ml, &submr_print_queue, queue) {",
"FUNC_0(VAR_0, VAR_1, ml->VAR_2, VAR_3 + 1, VAR_4 + VAR_2->addr,\nVAR_5);",
"}",
"QTAILQ_FOREACH_SAFE(next_ml, &submr_print_queue, queue, ml) {",
"g_free(ml);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91
],
[
93
],
[
95,
97,
99,
101,
103,
105
],
[
107
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123,
125,
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151,
153
],
[
155
],
[
159
],
[
161
],
[
163
],
[
165
]
] |
26,855 | int spapr_vio_check_tces(VIOsPAPRDevice *dev, target_ulong ioba,
target_ulong len, enum VIOsPAPR_TCEAccess access)
{
int start, end, i;
start = ioba >> SPAPR_VIO_TCE_PAGE_SHIFT;
end = (ioba + len - 1) >> SPAPR_VIO_TCE_PAGE_SHIFT;
for (i = start; i <= end; i++) {
if ((dev->rtce_table[i].tce & access) != access) {
#ifdef DEBUG_TCE
fprintf(stderr, "FAIL on %d\n", i);
#endif
return -1;
}
}
return 0;
}
| true | qemu | ad0ebb91cd8b5fdc4a583b03645677771f420a46 | int spapr_vio_check_tces(VIOsPAPRDevice *dev, target_ulong ioba,
target_ulong len, enum VIOsPAPR_TCEAccess access)
{
int start, end, i;
start = ioba >> SPAPR_VIO_TCE_PAGE_SHIFT;
end = (ioba + len - 1) >> SPAPR_VIO_TCE_PAGE_SHIFT;
for (i = start; i <= end; i++) {
if ((dev->rtce_table[i].tce & access) != access) {
#ifdef DEBUG_TCE
fprintf(stderr, "FAIL on %d\n", i);
#endif
return -1;
}
}
return 0;
}
| {
"code": [
"#ifdef DEBUG_TCE",
"#endif",
"int spapr_vio_check_tces(VIOsPAPRDevice *dev, target_ulong ioba,",
" target_ulong len, enum VIOsPAPR_TCEAccess access)",
" int start, end, i;",
" start = ioba >> SPAPR_VIO_TCE_PAGE_SHIFT;",
" end = (ioba + len - 1) >> SPAPR_VIO_TCE_PAGE_SHIFT;",
" for (i = start; i <= end; i++) {",
" if ((dev->rtce_table[i].tce & access) != access) {",
"#ifdef DEBUG_TCE",
" fprintf(stderr, \"FAIL on %d\\n\", i);",
"#endif",
" return -1;",
" return 0;",
"#ifdef DEBUG_TCE",
"#endif",
"#ifdef DEBUG_TCE",
"#endif",
"#ifdef DEBUG_TCE",
"#endif",
" return 0;",
"#ifdef DEBUG_TCE",
"#endif",
"#ifdef DEBUG_TCE",
"#endif",
"#ifdef DEBUG_TCE",
"#endif",
"#ifdef DEBUG_TCE",
"#endif",
"int spapr_vio_check_tces(VIOsPAPRDevice *dev, target_ulong ioba,"
],
"line_no": [
21,
25,
1,
3,
7,
11,
13,
17,
19,
21,
23,
25,
27,
35,
21,
25,
21,
25,
21,
25,
35,
21,
25,
21,
25,
21,
25,
21,
25,
1
]
} | int FUNC_0(VIOsPAPRDevice *VAR_0, target_ulong VAR_1,
target_ulong VAR_2, enum VIOsPAPR_TCEAccess VAR_3)
{
int VAR_4, VAR_5, VAR_6;
VAR_4 = VAR_1 >> SPAPR_VIO_TCE_PAGE_SHIFT;
VAR_5 = (VAR_1 + VAR_2 - 1) >> SPAPR_VIO_TCE_PAGE_SHIFT;
for (VAR_6 = VAR_4; VAR_6 <= VAR_5; VAR_6++) {
if ((VAR_0->rtce_table[VAR_6].tce & VAR_3) != VAR_3) {
#ifdef DEBUG_TCE
fprintf(stderr, "FAIL on %d\n", VAR_6);
#endif
return -1;
}
}
return 0;
}
| [
"int FUNC_0(VIOsPAPRDevice *VAR_0, target_ulong VAR_1,\ntarget_ulong VAR_2, enum VIOsPAPR_TCEAccess VAR_3)\n{",
"int VAR_4, VAR_5, VAR_6;",
"VAR_4 = VAR_1 >> SPAPR_VIO_TCE_PAGE_SHIFT;",
"VAR_5 = (VAR_1 + VAR_2 - 1) >> SPAPR_VIO_TCE_PAGE_SHIFT;",
"for (VAR_6 = VAR_4; VAR_6 <= VAR_5; VAR_6++) {",
"if ((VAR_0->rtce_table[VAR_6].tce & VAR_3) != VAR_3) {",
"#ifdef DEBUG_TCE\nfprintf(stderr, \"FAIL on %d\\n\", VAR_6);",
"#endif\nreturn -1;",
"}",
"}",
"return 0;",
"}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21,
23
],
[
25,
27
],
[
29
],
[
31
],
[
35
],
[
37
]
] |
26,857 | void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
{
int ret = 0;
FsMountList mounts;
struct FsMount *mount;
int fd;
Error *local_err = NULL;
struct fstrim_range r = {
.start = 0,
.len = -1,
.minlen = has_minimum ? minimum : 0,
};
slog("guest-fstrim called");
QTAILQ_INIT(&mounts);
build_fs_mount_list(&mounts, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
QTAILQ_FOREACH(mount, &mounts, next) {
fd = qemu_open(mount->dirname, O_RDONLY);
if (fd == -1) {
error_setg_errno(errp, errno, "failed to open %s", mount->dirname);
goto error;
}
/* We try to cull filesytems we know won't work in advance, but other
* filesytems may not implement fstrim for less obvious reasons. These
* will report EOPNOTSUPP; we simply ignore these errors. Any other
* error means an unexpected error, so return it in those cases. In
* some other cases ENOTTY will be reported (e.g. CD-ROMs).
*/
ret = ioctl(fd, FITRIM, &r);
if (ret == -1) {
if (errno != ENOTTY && errno != EOPNOTSUPP) {
error_setg_errno(errp, errno, "failed to trim %s",
mount->dirname);
close(fd);
goto error;
}
}
close(fd);
}
error:
free_fs_mount_list(&mounts);
}
| true | qemu | 73a652a1b08445e8d91e50cdbb2da50e571c61b3 | void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
{
int ret = 0;
FsMountList mounts;
struct FsMount *mount;
int fd;
Error *local_err = NULL;
struct fstrim_range r = {
.start = 0,
.len = -1,
.minlen = has_minimum ? minimum : 0,
};
slog("guest-fstrim called");
QTAILQ_INIT(&mounts);
build_fs_mount_list(&mounts, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
QTAILQ_FOREACH(mount, &mounts, next) {
fd = qemu_open(mount->dirname, O_RDONLY);
if (fd == -1) {
error_setg_errno(errp, errno, "failed to open %s", mount->dirname);
goto error;
}
ret = ioctl(fd, FITRIM, &r);
if (ret == -1) {
if (errno != ENOTTY && errno != EOPNOTSUPP) {
error_setg_errno(errp, errno, "failed to trim %s",
mount->dirname);
close(fd);
goto error;
}
}
close(fd);
}
error:
free_fs_mount_list(&mounts);
}
| {
"code": [
" struct fstrim_range r = {",
" .start = 0,",
" .len = -1,",
" .minlen = has_minimum ? minimum : 0,",
" };"
],
"line_no": [
15,
17,
19,
21,
23
]
} | void FUNC_0(bool VAR_0, int64_t VAR_1, Error **VAR_2)
{
int VAR_3 = 0;
FsMountList mounts;
struct FsMount *VAR_4;
int VAR_5;
Error *local_err = NULL;
struct fstrim_range VAR_6 = {
.start = 0,
.len = -1,
.minlen = VAR_0 ? VAR_1 : 0,
};
slog("guest-fstrim called");
QTAILQ_INIT(&mounts);
build_fs_mount_list(&mounts, &local_err);
if (local_err) {
error_propagate(VAR_2, local_err);
return;
}
QTAILQ_FOREACH(VAR_4, &mounts, next) {
VAR_5 = qemu_open(VAR_4->dirname, O_RDONLY);
if (VAR_5 == -1) {
error_setg_errno(VAR_2, errno, "failed to open %s", VAR_4->dirname);
goto error;
}
VAR_3 = ioctl(VAR_5, FITRIM, &VAR_6);
if (VAR_3 == -1) {
if (errno != ENOTTY && errno != EOPNOTSUPP) {
error_setg_errno(VAR_2, errno, "failed to trim %s",
VAR_4->dirname);
close(VAR_5);
goto error;
}
}
close(VAR_5);
}
error:
free_fs_mount_list(&mounts);
}
| [
"void FUNC_0(bool VAR_0, int64_t VAR_1, Error **VAR_2)\n{",
"int VAR_3 = 0;",
"FsMountList mounts;",
"struct FsMount *VAR_4;",
"int VAR_5;",
"Error *local_err = NULL;",
"struct fstrim_range VAR_6 = {",
".start = 0,\n.len = -1,\n.minlen = VAR_0 ? VAR_1 : 0,\n};",
"slog(\"guest-fstrim called\");",
"QTAILQ_INIT(&mounts);",
"build_fs_mount_list(&mounts, &local_err);",
"if (local_err) {",
"error_propagate(VAR_2, local_err);",
"return;",
"}",
"QTAILQ_FOREACH(VAR_4, &mounts, next) {",
"VAR_5 = qemu_open(VAR_4->dirname, O_RDONLY);",
"if (VAR_5 == -1) {",
"error_setg_errno(VAR_2, errno, \"failed to open %s\", VAR_4->dirname);",
"goto error;",
"}",
"VAR_3 = ioctl(VAR_5, FITRIM, &VAR_6);",
"if (VAR_3 == -1) {",
"if (errno != ENOTTY && errno != EOPNOTSUPP) {",
"error_setg_errno(VAR_2, errno, \"failed to trim %s\",\nVAR_4->dirname);",
"close(VAR_5);",
"goto error;",
"}",
"}",
"close(VAR_5);",
"}",
"error:\nfree_fs_mount_list(&mounts);",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17,
19,
21,
23
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95,
97
],
[
99
]
] |
26,858 | static av_always_inline void encode_mb_internal(MpegEncContext *s, int motion_x, int motion_y, int mb_block_height, int mb_block_count)
{
int16_t weight[8][64];
DCTELEM orig[8][64];
const int mb_x= s->mb_x;
const int mb_y= s->mb_y;
int i;
int skip_dct[8];
int dct_offset = s->linesize*8; //default for progressive frames
uint8_t *ptr_y, *ptr_cb, *ptr_cr;
int wrap_y, wrap_c;
for(i=0; i<mb_block_count; i++) skip_dct[i]=s->skipdct;
if(s->adaptive_quant){
const int last_qp= s->qscale;
const int mb_xy= mb_x + mb_y*s->mb_stride;
s->lambda= s->lambda_table[mb_xy];
update_qscale(s);
if(!(s->flags&CODEC_FLAG_QP_RD)){
s->qscale= s->current_picture_ptr->qscale_table[mb_xy];
s->dquant= s->qscale - last_qp;
if(s->out_format==FMT_H263){
s->dquant= av_clip(s->dquant, -2, 2);
if(s->codec_id==CODEC_ID_MPEG4){
if(!s->mb_intra){
if(s->pict_type == FF_B_TYPE){
if(s->dquant&1 || s->mv_dir&MV_DIRECT)
s->dquant= 0;
}
if(s->mv_type==MV_TYPE_8X8)
s->dquant=0;
}
}
}
}
ff_set_qscale(s, last_qp + s->dquant);
}else if(s->flags&CODEC_FLAG_QP_RD)
ff_set_qscale(s, s->qscale + s->dquant);
wrap_y = s->linesize;
wrap_c = s->uvlinesize;
ptr_y = s->new_picture.data[0] + (mb_y * 16 * wrap_y) + mb_x * 16;
ptr_cb = s->new_picture.data[1] + (mb_y * mb_block_height * wrap_c) + mb_x * 8;
ptr_cr = s->new_picture.data[2] + (mb_y * mb_block_height * wrap_c) + mb_x * 8;
if(mb_x*16+16 > s->width || mb_y*16+16 > s->height){
uint8_t *ebuf= s->edge_emu_buffer + 32;
ff_emulated_edge_mc(ebuf , ptr_y , wrap_y,16,16,mb_x*16,mb_y*16, s->width , s->height);
ptr_y= ebuf;
ff_emulated_edge_mc(ebuf+18*wrap_y , ptr_cb, wrap_c, 8, mb_block_height, mb_x*8, mb_y*8, s->width>>1, s->height>>1);
ptr_cb= ebuf+18*wrap_y;
ff_emulated_edge_mc(ebuf+18*wrap_y+8, ptr_cr, wrap_c, 8, mb_block_height, mb_x*8, mb_y*8, s->width>>1, s->height>>1);
ptr_cr= ebuf+18*wrap_y+8;
}
if (s->mb_intra) {
if(s->flags&CODEC_FLAG_INTERLACED_DCT){
int progressive_score, interlaced_score;
s->interlaced_dct=0;
progressive_score= s->dsp.ildct_cmp[4](s, ptr_y , NULL, wrap_y, 8)
+s->dsp.ildct_cmp[4](s, ptr_y + wrap_y*8, NULL, wrap_y, 8) - 400;
if(progressive_score > 0){
interlaced_score = s->dsp.ildct_cmp[4](s, ptr_y , NULL, wrap_y*2, 8)
+s->dsp.ildct_cmp[4](s, ptr_y + wrap_y , NULL, wrap_y*2, 8);
if(progressive_score > interlaced_score){
s->interlaced_dct=1;
dct_offset= wrap_y;
wrap_y<<=1;
if (s->chroma_format == CHROMA_422)
wrap_c<<=1;
}
}
}
s->dsp.get_pixels(s->block[0], ptr_y , wrap_y);
s->dsp.get_pixels(s->block[1], ptr_y + 8, wrap_y);
s->dsp.get_pixels(s->block[2], ptr_y + dct_offset , wrap_y);
s->dsp.get_pixels(s->block[3], ptr_y + dct_offset + 8, wrap_y);
if(s->flags&CODEC_FLAG_GRAY){
skip_dct[4]= 1;
skip_dct[5]= 1;
}else{
s->dsp.get_pixels(s->block[4], ptr_cb, wrap_c);
s->dsp.get_pixels(s->block[5], ptr_cr, wrap_c);
if(!s->chroma_y_shift){ /* 422 */
s->dsp.get_pixels(s->block[6], ptr_cb + (dct_offset>>1), wrap_c);
s->dsp.get_pixels(s->block[7], ptr_cr + (dct_offset>>1), wrap_c);
}
}
}else{
op_pixels_func (*op_pix)[4];
qpel_mc_func (*op_qpix)[16];
uint8_t *dest_y, *dest_cb, *dest_cr;
dest_y = s->dest[0];
dest_cb = s->dest[1];
dest_cr = s->dest[2];
if ((!s->no_rounding) || s->pict_type==FF_B_TYPE){
op_pix = s->dsp.put_pixels_tab;
op_qpix= s->dsp.put_qpel_pixels_tab;
}else{
op_pix = s->dsp.put_no_rnd_pixels_tab;
op_qpix= s->dsp.put_no_rnd_qpel_pixels_tab;
}
if (s->mv_dir & MV_DIR_FORWARD) {
MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.data, op_pix, op_qpix);
op_pix = s->dsp.avg_pixels_tab;
op_qpix= s->dsp.avg_qpel_pixels_tab;
}
if (s->mv_dir & MV_DIR_BACKWARD) {
MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.data, op_pix, op_qpix);
}
if(s->flags&CODEC_FLAG_INTERLACED_DCT){
int progressive_score, interlaced_score;
s->interlaced_dct=0;
progressive_score= s->dsp.ildct_cmp[0](s, dest_y , ptr_y , wrap_y, 8)
+s->dsp.ildct_cmp[0](s, dest_y + wrap_y*8, ptr_y + wrap_y*8, wrap_y, 8) - 400;
if(s->avctx->ildct_cmp == FF_CMP_VSSE) progressive_score -= 400;
if(progressive_score>0){
interlaced_score = s->dsp.ildct_cmp[0](s, dest_y , ptr_y , wrap_y*2, 8)
+s->dsp.ildct_cmp[0](s, dest_y + wrap_y , ptr_y + wrap_y , wrap_y*2, 8);
if(progressive_score > interlaced_score){
s->interlaced_dct=1;
dct_offset= wrap_y;
wrap_y<<=1;
if (s->chroma_format == CHROMA_422)
wrap_c<<=1;
}
}
}
s->dsp.diff_pixels(s->block[0], ptr_y , dest_y , wrap_y);
s->dsp.diff_pixels(s->block[1], ptr_y + 8, dest_y + 8, wrap_y);
s->dsp.diff_pixels(s->block[2], ptr_y + dct_offset , dest_y + dct_offset , wrap_y);
s->dsp.diff_pixels(s->block[3], ptr_y + dct_offset + 8, dest_y + dct_offset + 8, wrap_y);
if(s->flags&CODEC_FLAG_GRAY){
skip_dct[4]= 1;
skip_dct[5]= 1;
}else{
s->dsp.diff_pixels(s->block[4], ptr_cb, dest_cb, wrap_c);
s->dsp.diff_pixels(s->block[5], ptr_cr, dest_cr, wrap_c);
if(!s->chroma_y_shift){ /* 422 */
s->dsp.diff_pixels(s->block[6], ptr_cb + (dct_offset>>1), dest_cb + (dct_offset>>1), wrap_c);
s->dsp.diff_pixels(s->block[7], ptr_cr + (dct_offset>>1), dest_cr + (dct_offset>>1), wrap_c);
}
}
/* pre quantization */
if(s->current_picture.mc_mb_var[s->mb_stride*mb_y+ mb_x]<2*s->qscale*s->qscale){
//FIXME optimize
if(s->dsp.sad[1](NULL, ptr_y , dest_y , wrap_y, 8) < 20*s->qscale) skip_dct[0]= 1;
if(s->dsp.sad[1](NULL, ptr_y + 8, dest_y + 8, wrap_y, 8) < 20*s->qscale) skip_dct[1]= 1;
if(s->dsp.sad[1](NULL, ptr_y +dct_offset , dest_y +dct_offset , wrap_y, 8) < 20*s->qscale) skip_dct[2]= 1;
if(s->dsp.sad[1](NULL, ptr_y +dct_offset+ 8, dest_y +dct_offset+ 8, wrap_y, 8) < 20*s->qscale) skip_dct[3]= 1;
if(s->dsp.sad[1](NULL, ptr_cb , dest_cb , wrap_c, 8) < 20*s->qscale) skip_dct[4]= 1;
if(s->dsp.sad[1](NULL, ptr_cr , dest_cr , wrap_c, 8) < 20*s->qscale) skip_dct[5]= 1;
if(!s->chroma_y_shift){ /* 422 */
if(s->dsp.sad[1](NULL, ptr_cb +(dct_offset>>1), dest_cb +(dct_offset>>1), wrap_c, 8) < 20*s->qscale) skip_dct[6]= 1;
if(s->dsp.sad[1](NULL, ptr_cr +(dct_offset>>1), dest_cr +(dct_offset>>1), wrap_c, 8) < 20*s->qscale) skip_dct[7]= 1;
}
}
}
if(s->avctx->quantizer_noise_shaping){
if(!skip_dct[0]) get_visual_weight(weight[0], ptr_y , wrap_y);
if(!skip_dct[1]) get_visual_weight(weight[1], ptr_y + 8, wrap_y);
if(!skip_dct[2]) get_visual_weight(weight[2], ptr_y + dct_offset , wrap_y);
if(!skip_dct[3]) get_visual_weight(weight[3], ptr_y + dct_offset + 8, wrap_y);
if(!skip_dct[4]) get_visual_weight(weight[4], ptr_cb , wrap_c);
if(!skip_dct[5]) get_visual_weight(weight[5], ptr_cr , wrap_c);
if(!s->chroma_y_shift){ /* 422 */
if(!skip_dct[6]) get_visual_weight(weight[6], ptr_cb + (dct_offset>>1), wrap_c);
if(!skip_dct[7]) get_visual_weight(weight[7], ptr_cr + (dct_offset>>1), wrap_c);
}
memcpy(orig[0], s->block[0], sizeof(DCTELEM)*64*mb_block_count);
}
/* DCT & quantize */
assert(s->out_format!=FMT_MJPEG || s->qscale==8);
{
for(i=0;i<mb_block_count;i++) {
if(!skip_dct[i]){
int overflow;
s->block_last_index[i] = s->dct_quantize(s, s->block[i], i, s->qscale, &overflow);
// FIXME we could decide to change to quantizer instead of clipping
// JS: I don't think that would be a good idea it could lower quality instead
// of improve it. Just INTRADC clipping deserves changes in quantizer
if (overflow) clip_coeffs(s, s->block[i], s->block_last_index[i]);
}else
s->block_last_index[i]= -1;
}
if(s->avctx->quantizer_noise_shaping){
for(i=0;i<mb_block_count;i++) {
if(!skip_dct[i]){
s->block_last_index[i] = dct_quantize_refine(s, s->block[i], weight[i], orig[i], i, s->qscale);
}
}
}
if(s->luma_elim_threshold && !s->mb_intra)
for(i=0; i<4; i++)
dct_single_coeff_elimination(s, i, s->luma_elim_threshold);
if(s->chroma_elim_threshold && !s->mb_intra)
for(i=4; i<mb_block_count; i++)
dct_single_coeff_elimination(s, i, s->chroma_elim_threshold);
if(s->flags & CODEC_FLAG_CBP_RD){
for(i=0;i<mb_block_count;i++) {
if(s->block_last_index[i] == -1)
s->coded_score[i]= INT_MAX/256;
}
}
}
if((s->flags&CODEC_FLAG_GRAY) && s->mb_intra){
s->block_last_index[4]=
s->block_last_index[5]= 0;
s->block[4][0]=
s->block[5][0]= (1024 + s->c_dc_scale/2)/ s->c_dc_scale;
}
//non c quantize code returns incorrect block_last_index FIXME
if(s->alternate_scan && s->dct_quantize != dct_quantize_c){
for(i=0; i<mb_block_count; i++){
int j;
if(s->block_last_index[i]>0){
for(j=63; j>0; j--){
if(s->block[i][ s->intra_scantable.permutated[j] ]) break;
}
s->block_last_index[i]= j;
}
}
}
/* huffman encode */
switch(s->codec_id){ //FIXME funct ptr could be slightly faster
case CODEC_ID_MPEG1VIDEO:
case CODEC_ID_MPEG2VIDEO:
if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER)
mpeg1_encode_mb(s, s->block, motion_x, motion_y);
break;
case CODEC_ID_MPEG4:
if (CONFIG_MPEG4_ENCODER)
mpeg4_encode_mb(s, s->block, motion_x, motion_y);
break;
case CODEC_ID_MSMPEG4V2:
case CODEC_ID_MSMPEG4V3:
case CODEC_ID_WMV1:
if (CONFIG_MSMPEG4_ENCODER)
msmpeg4_encode_mb(s, s->block, motion_x, motion_y);
break;
case CODEC_ID_WMV2:
if (CONFIG_WMV2_ENCODER)
ff_wmv2_encode_mb(s, s->block, motion_x, motion_y);
break;
case CODEC_ID_H261:
if (CONFIG_H261_ENCODER)
ff_h261_encode_mb(s, s->block, motion_x, motion_y);
break;
case CODEC_ID_H263:
case CODEC_ID_H263P:
case CODEC_ID_FLV1:
case CODEC_ID_RV10:
case CODEC_ID_RV20:
if (CONFIG_H263_ENCODER || CONFIG_H263P_ENCODER ||
CONFIG_FLV_ENCODER || CONFIG_RV10_ENCODER || CONFIG_RV20_ENCODER)
h263_encode_mb(s, s->block, motion_x, motion_y);
break;
case CODEC_ID_MJPEG:
if (CONFIG_MJPEG_ENCODER)
ff_mjpeg_encode_mb(s, s->block);
break;
default:
assert(0);
}
}
| false | FFmpeg | 735e36a3e4427b009f27d27baa7541f686c180d4 | static av_always_inline void encode_mb_internal(MpegEncContext *s, int motion_x, int motion_y, int mb_block_height, int mb_block_count)
{
int16_t weight[8][64];
DCTELEM orig[8][64];
const int mb_x= s->mb_x;
const int mb_y= s->mb_y;
int i;
int skip_dct[8];
int dct_offset = s->linesize*8;
uint8_t *ptr_y, *ptr_cb, *ptr_cr;
int wrap_y, wrap_c;
for(i=0; i<mb_block_count; i++) skip_dct[i]=s->skipdct;
if(s->adaptive_quant){
const int last_qp= s->qscale;
const int mb_xy= mb_x + mb_y*s->mb_stride;
s->lambda= s->lambda_table[mb_xy];
update_qscale(s);
if(!(s->flags&CODEC_FLAG_QP_RD)){
s->qscale= s->current_picture_ptr->qscale_table[mb_xy];
s->dquant= s->qscale - last_qp;
if(s->out_format==FMT_H263){
s->dquant= av_clip(s->dquant, -2, 2);
if(s->codec_id==CODEC_ID_MPEG4){
if(!s->mb_intra){
if(s->pict_type == FF_B_TYPE){
if(s->dquant&1 || s->mv_dir&MV_DIRECT)
s->dquant= 0;
}
if(s->mv_type==MV_TYPE_8X8)
s->dquant=0;
}
}
}
}
ff_set_qscale(s, last_qp + s->dquant);
}else if(s->flags&CODEC_FLAG_QP_RD)
ff_set_qscale(s, s->qscale + s->dquant);
wrap_y = s->linesize;
wrap_c = s->uvlinesize;
ptr_y = s->new_picture.data[0] + (mb_y * 16 * wrap_y) + mb_x * 16;
ptr_cb = s->new_picture.data[1] + (mb_y * mb_block_height * wrap_c) + mb_x * 8;
ptr_cr = s->new_picture.data[2] + (mb_y * mb_block_height * wrap_c) + mb_x * 8;
if(mb_x*16+16 > s->width || mb_y*16+16 > s->height){
uint8_t *ebuf= s->edge_emu_buffer + 32;
ff_emulated_edge_mc(ebuf , ptr_y , wrap_y,16,16,mb_x*16,mb_y*16, s->width , s->height);
ptr_y= ebuf;
ff_emulated_edge_mc(ebuf+18*wrap_y , ptr_cb, wrap_c, 8, mb_block_height, mb_x*8, mb_y*8, s->width>>1, s->height>>1);
ptr_cb= ebuf+18*wrap_y;
ff_emulated_edge_mc(ebuf+18*wrap_y+8, ptr_cr, wrap_c, 8, mb_block_height, mb_x*8, mb_y*8, s->width>>1, s->height>>1);
ptr_cr= ebuf+18*wrap_y+8;
}
if (s->mb_intra) {
if(s->flags&CODEC_FLAG_INTERLACED_DCT){
int progressive_score, interlaced_score;
s->interlaced_dct=0;
progressive_score= s->dsp.ildct_cmp[4](s, ptr_y , NULL, wrap_y, 8)
+s->dsp.ildct_cmp[4](s, ptr_y + wrap_y*8, NULL, wrap_y, 8) - 400;
if(progressive_score > 0){
interlaced_score = s->dsp.ildct_cmp[4](s, ptr_y , NULL, wrap_y*2, 8)
+s->dsp.ildct_cmp[4](s, ptr_y + wrap_y , NULL, wrap_y*2, 8);
if(progressive_score > interlaced_score){
s->interlaced_dct=1;
dct_offset= wrap_y;
wrap_y<<=1;
if (s->chroma_format == CHROMA_422)
wrap_c<<=1;
}
}
}
s->dsp.get_pixels(s->block[0], ptr_y , wrap_y);
s->dsp.get_pixels(s->block[1], ptr_y + 8, wrap_y);
s->dsp.get_pixels(s->block[2], ptr_y + dct_offset , wrap_y);
s->dsp.get_pixels(s->block[3], ptr_y + dct_offset + 8, wrap_y);
if(s->flags&CODEC_FLAG_GRAY){
skip_dct[4]= 1;
skip_dct[5]= 1;
}else{
s->dsp.get_pixels(s->block[4], ptr_cb, wrap_c);
s->dsp.get_pixels(s->block[5], ptr_cr, wrap_c);
if(!s->chroma_y_shift){
s->dsp.get_pixels(s->block[6], ptr_cb + (dct_offset>>1), wrap_c);
s->dsp.get_pixels(s->block[7], ptr_cr + (dct_offset>>1), wrap_c);
}
}
}else{
op_pixels_func (*op_pix)[4];
qpel_mc_func (*op_qpix)[16];
uint8_t *dest_y, *dest_cb, *dest_cr;
dest_y = s->dest[0];
dest_cb = s->dest[1];
dest_cr = s->dest[2];
if ((!s->no_rounding) || s->pict_type==FF_B_TYPE){
op_pix = s->dsp.put_pixels_tab;
op_qpix= s->dsp.put_qpel_pixels_tab;
}else{
op_pix = s->dsp.put_no_rnd_pixels_tab;
op_qpix= s->dsp.put_no_rnd_qpel_pixels_tab;
}
if (s->mv_dir & MV_DIR_FORWARD) {
MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.data, op_pix, op_qpix);
op_pix = s->dsp.avg_pixels_tab;
op_qpix= s->dsp.avg_qpel_pixels_tab;
}
if (s->mv_dir & MV_DIR_BACKWARD) {
MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.data, op_pix, op_qpix);
}
if(s->flags&CODEC_FLAG_INTERLACED_DCT){
int progressive_score, interlaced_score;
s->interlaced_dct=0;
progressive_score= s->dsp.ildct_cmp[0](s, dest_y , ptr_y , wrap_y, 8)
+s->dsp.ildct_cmp[0](s, dest_y + wrap_y*8, ptr_y + wrap_y*8, wrap_y, 8) - 400;
if(s->avctx->ildct_cmp == FF_CMP_VSSE) progressive_score -= 400;
if(progressive_score>0){
interlaced_score = s->dsp.ildct_cmp[0](s, dest_y , ptr_y , wrap_y*2, 8)
+s->dsp.ildct_cmp[0](s, dest_y + wrap_y , ptr_y + wrap_y , wrap_y*2, 8);
if(progressive_score > interlaced_score){
s->interlaced_dct=1;
dct_offset= wrap_y;
wrap_y<<=1;
if (s->chroma_format == CHROMA_422)
wrap_c<<=1;
}
}
}
s->dsp.diff_pixels(s->block[0], ptr_y , dest_y , wrap_y);
s->dsp.diff_pixels(s->block[1], ptr_y + 8, dest_y + 8, wrap_y);
s->dsp.diff_pixels(s->block[2], ptr_y + dct_offset , dest_y + dct_offset , wrap_y);
s->dsp.diff_pixels(s->block[3], ptr_y + dct_offset + 8, dest_y + dct_offset + 8, wrap_y);
if(s->flags&CODEC_FLAG_GRAY){
skip_dct[4]= 1;
skip_dct[5]= 1;
}else{
s->dsp.diff_pixels(s->block[4], ptr_cb, dest_cb, wrap_c);
s->dsp.diff_pixels(s->block[5], ptr_cr, dest_cr, wrap_c);
if(!s->chroma_y_shift){
s->dsp.diff_pixels(s->block[6], ptr_cb + (dct_offset>>1), dest_cb + (dct_offset>>1), wrap_c);
s->dsp.diff_pixels(s->block[7], ptr_cr + (dct_offset>>1), dest_cr + (dct_offset>>1), wrap_c);
}
}
if(s->current_picture.mc_mb_var[s->mb_stride*mb_y+ mb_x]<2*s->qscale*s->qscale){
if(s->dsp.sad[1](NULL, ptr_y , dest_y , wrap_y, 8) < 20*s->qscale) skip_dct[0]= 1;
if(s->dsp.sad[1](NULL, ptr_y + 8, dest_y + 8, wrap_y, 8) < 20*s->qscale) skip_dct[1]= 1;
if(s->dsp.sad[1](NULL, ptr_y +dct_offset , dest_y +dct_offset , wrap_y, 8) < 20*s->qscale) skip_dct[2]= 1;
if(s->dsp.sad[1](NULL, ptr_y +dct_offset+ 8, dest_y +dct_offset+ 8, wrap_y, 8) < 20*s->qscale) skip_dct[3]= 1;
if(s->dsp.sad[1](NULL, ptr_cb , dest_cb , wrap_c, 8) < 20*s->qscale) skip_dct[4]= 1;
if(s->dsp.sad[1](NULL, ptr_cr , dest_cr , wrap_c, 8) < 20*s->qscale) skip_dct[5]= 1;
if(!s->chroma_y_shift){
if(s->dsp.sad[1](NULL, ptr_cb +(dct_offset>>1), dest_cb +(dct_offset>>1), wrap_c, 8) < 20*s->qscale) skip_dct[6]= 1;
if(s->dsp.sad[1](NULL, ptr_cr +(dct_offset>>1), dest_cr +(dct_offset>>1), wrap_c, 8) < 20*s->qscale) skip_dct[7]= 1;
}
}
}
if(s->avctx->quantizer_noise_shaping){
if(!skip_dct[0]) get_visual_weight(weight[0], ptr_y , wrap_y);
if(!skip_dct[1]) get_visual_weight(weight[1], ptr_y + 8, wrap_y);
if(!skip_dct[2]) get_visual_weight(weight[2], ptr_y + dct_offset , wrap_y);
if(!skip_dct[3]) get_visual_weight(weight[3], ptr_y + dct_offset + 8, wrap_y);
if(!skip_dct[4]) get_visual_weight(weight[4], ptr_cb , wrap_c);
if(!skip_dct[5]) get_visual_weight(weight[5], ptr_cr , wrap_c);
if(!s->chroma_y_shift){
if(!skip_dct[6]) get_visual_weight(weight[6], ptr_cb + (dct_offset>>1), wrap_c);
if(!skip_dct[7]) get_visual_weight(weight[7], ptr_cr + (dct_offset>>1), wrap_c);
}
memcpy(orig[0], s->block[0], sizeof(DCTELEM)*64*mb_block_count);
}
assert(s->out_format!=FMT_MJPEG || s->qscale==8);
{
for(i=0;i<mb_block_count;i++) {
if(!skip_dct[i]){
int overflow;
s->block_last_index[i] = s->dct_quantize(s, s->block[i], i, s->qscale, &overflow);
if (overflow) clip_coeffs(s, s->block[i], s->block_last_index[i]);
}else
s->block_last_index[i]= -1;
}
if(s->avctx->quantizer_noise_shaping){
for(i=0;i<mb_block_count;i++) {
if(!skip_dct[i]){
s->block_last_index[i] = dct_quantize_refine(s, s->block[i], weight[i], orig[i], i, s->qscale);
}
}
}
if(s->luma_elim_threshold && !s->mb_intra)
for(i=0; i<4; i++)
dct_single_coeff_elimination(s, i, s->luma_elim_threshold);
if(s->chroma_elim_threshold && !s->mb_intra)
for(i=4; i<mb_block_count; i++)
dct_single_coeff_elimination(s, i, s->chroma_elim_threshold);
if(s->flags & CODEC_FLAG_CBP_RD){
for(i=0;i<mb_block_count;i++) {
if(s->block_last_index[i] == -1)
s->coded_score[i]= INT_MAX/256;
}
}
}
if((s->flags&CODEC_FLAG_GRAY) && s->mb_intra){
s->block_last_index[4]=
s->block_last_index[5]= 0;
s->block[4][0]=
s->block[5][0]= (1024 + s->c_dc_scale/2)/ s->c_dc_scale;
}
if(s->alternate_scan && s->dct_quantize != dct_quantize_c){
for(i=0; i<mb_block_count; i++){
int j;
if(s->block_last_index[i]>0){
for(j=63; j>0; j--){
if(s->block[i][ s->intra_scantable.permutated[j] ]) break;
}
s->block_last_index[i]= j;
}
}
}
switch(s->codec_id){
case CODEC_ID_MPEG1VIDEO:
case CODEC_ID_MPEG2VIDEO:
if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER)
mpeg1_encode_mb(s, s->block, motion_x, motion_y);
break;
case CODEC_ID_MPEG4:
if (CONFIG_MPEG4_ENCODER)
mpeg4_encode_mb(s, s->block, motion_x, motion_y);
break;
case CODEC_ID_MSMPEG4V2:
case CODEC_ID_MSMPEG4V3:
case CODEC_ID_WMV1:
if (CONFIG_MSMPEG4_ENCODER)
msmpeg4_encode_mb(s, s->block, motion_x, motion_y);
break;
case CODEC_ID_WMV2:
if (CONFIG_WMV2_ENCODER)
ff_wmv2_encode_mb(s, s->block, motion_x, motion_y);
break;
case CODEC_ID_H261:
if (CONFIG_H261_ENCODER)
ff_h261_encode_mb(s, s->block, motion_x, motion_y);
break;
case CODEC_ID_H263:
case CODEC_ID_H263P:
case CODEC_ID_FLV1:
case CODEC_ID_RV10:
case CODEC_ID_RV20:
if (CONFIG_H263_ENCODER || CONFIG_H263P_ENCODER ||
CONFIG_FLV_ENCODER || CONFIG_RV10_ENCODER || CONFIG_RV20_ENCODER)
h263_encode_mb(s, s->block, motion_x, motion_y);
break;
case CODEC_ID_MJPEG:
if (CONFIG_MJPEG_ENCODER)
ff_mjpeg_encode_mb(s, s->block);
break;
default:
assert(0);
}
}
| {
"code": [],
"line_no": []
} | static av_always_inline void FUNC_0(MpegEncContext *s, int motion_x, int motion_y, int mb_block_height, int mb_block_count)
{
int16_t weight[8][64];
DCTELEM orig[8][64];
const int VAR_0= s->VAR_0;
const int VAR_1= s->VAR_1;
int VAR_2;
int VAR_3[8];
int VAR_4 = s->linesize*8;
uint8_t *ptr_y, *ptr_cb, *ptr_cr;
int VAR_5, VAR_6;
for(VAR_2=0; VAR_2<mb_block_count; VAR_2++) VAR_3[VAR_2]=s->skipdct;
if(s->adaptive_quant){
const int VAR_7= s->qscale;
const int VAR_8= VAR_0 + VAR_1*s->mb_stride;
s->lambda= s->lambda_table[VAR_8];
update_qscale(s);
if(!(s->flags&CODEC_FLAG_QP_RD)){
s->qscale= s->current_picture_ptr->qscale_table[VAR_8];
s->dquant= s->qscale - VAR_7;
if(s->out_format==FMT_H263){
s->dquant= av_clip(s->dquant, -2, 2);
if(s->codec_id==CODEC_ID_MPEG4){
if(!s->mb_intra){
if(s->pict_type == FF_B_TYPE){
if(s->dquant&1 || s->mv_dir&MV_DIRECT)
s->dquant= 0;
}
if(s->mv_type==MV_TYPE_8X8)
s->dquant=0;
}
}
}
}
ff_set_qscale(s, VAR_7 + s->dquant);
}else if(s->flags&CODEC_FLAG_QP_RD)
ff_set_qscale(s, s->qscale + s->dquant);
VAR_5 = s->linesize;
VAR_6 = s->uvlinesize;
ptr_y = s->new_picture.data[0] + (VAR_1 * 16 * VAR_5) + VAR_0 * 16;
ptr_cb = s->new_picture.data[1] + (VAR_1 * mb_block_height * VAR_6) + VAR_0 * 8;
ptr_cr = s->new_picture.data[2] + (VAR_1 * mb_block_height * VAR_6) + VAR_0 * 8;
if(VAR_0*16+16 > s->width || VAR_1*16+16 > s->height){
uint8_t *ebuf= s->edge_emu_buffer + 32;
ff_emulated_edge_mc(ebuf , ptr_y , VAR_5,16,16,VAR_0*16,VAR_1*16, s->width , s->height);
ptr_y= ebuf;
ff_emulated_edge_mc(ebuf+18*VAR_5 , ptr_cb, VAR_6, 8, mb_block_height, VAR_0*8, VAR_1*8, s->width>>1, s->height>>1);
ptr_cb= ebuf+18*VAR_5;
ff_emulated_edge_mc(ebuf+18*VAR_5+8, ptr_cr, VAR_6, 8, mb_block_height, VAR_0*8, VAR_1*8, s->width>>1, s->height>>1);
ptr_cr= ebuf+18*VAR_5+8;
}
if (s->mb_intra) {
if(s->flags&CODEC_FLAG_INTERLACED_DCT){
int VAR_11, VAR_11;
s->interlaced_dct=0;
VAR_11= s->dsp.ildct_cmp[4](s, ptr_y , NULL, VAR_5, 8)
+s->dsp.ildct_cmp[4](s, ptr_y + VAR_5*8, NULL, VAR_5, 8) - 400;
if(VAR_11 > 0){
VAR_11 = s->dsp.ildct_cmp[4](s, ptr_y , NULL, VAR_5*2, 8)
+s->dsp.ildct_cmp[4](s, ptr_y + VAR_5 , NULL, VAR_5*2, 8);
if(VAR_11 > VAR_11){
s->interlaced_dct=1;
VAR_4= VAR_5;
VAR_5<<=1;
if (s->chroma_format == CHROMA_422)
VAR_6<<=1;
}
}
}
s->dsp.get_pixels(s->block[0], ptr_y , VAR_5);
s->dsp.get_pixels(s->block[1], ptr_y + 8, VAR_5);
s->dsp.get_pixels(s->block[2], ptr_y + VAR_4 , VAR_5);
s->dsp.get_pixels(s->block[3], ptr_y + VAR_4 + 8, VAR_5);
if(s->flags&CODEC_FLAG_GRAY){
VAR_3[4]= 1;
VAR_3[5]= 1;
}else{
s->dsp.get_pixels(s->block[4], ptr_cb, VAR_6);
s->dsp.get_pixels(s->block[5], ptr_cr, VAR_6);
if(!s->chroma_y_shift){
s->dsp.get_pixels(s->block[6], ptr_cb + (VAR_4>>1), VAR_6);
s->dsp.get_pixels(s->block[7], ptr_cr + (VAR_4>>1), VAR_6);
}
}
}else{
op_pixels_func (*op_pix)[4];
qpel_mc_func (*op_qpix)[16];
uint8_t *dest_y, *dest_cb, *dest_cr;
dest_y = s->dest[0];
dest_cb = s->dest[1];
dest_cr = s->dest[2];
if ((!s->no_rounding) || s->pict_type==FF_B_TYPE){
op_pix = s->dsp.put_pixels_tab;
op_qpix= s->dsp.put_qpel_pixels_tab;
}else{
op_pix = s->dsp.put_no_rnd_pixels_tab;
op_qpix= s->dsp.put_no_rnd_qpel_pixels_tab;
}
if (s->mv_dir & MV_DIR_FORWARD) {
MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.data, op_pix, op_qpix);
op_pix = s->dsp.avg_pixels_tab;
op_qpix= s->dsp.avg_qpel_pixels_tab;
}
if (s->mv_dir & MV_DIR_BACKWARD) {
MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.data, op_pix, op_qpix);
}
if(s->flags&CODEC_FLAG_INTERLACED_DCT){
int VAR_11, VAR_11;
s->interlaced_dct=0;
VAR_11= s->dsp.ildct_cmp[0](s, dest_y , ptr_y , VAR_5, 8)
+s->dsp.ildct_cmp[0](s, dest_y + VAR_5*8, ptr_y + VAR_5*8, VAR_5, 8) - 400;
if(s->avctx->ildct_cmp == FF_CMP_VSSE) VAR_11 -= 400;
if(VAR_11>0){
VAR_11 = s->dsp.ildct_cmp[0](s, dest_y , ptr_y , VAR_5*2, 8)
+s->dsp.ildct_cmp[0](s, dest_y + VAR_5 , ptr_y + VAR_5 , VAR_5*2, 8);
if(VAR_11 > VAR_11){
s->interlaced_dct=1;
VAR_4= VAR_5;
VAR_5<<=1;
if (s->chroma_format == CHROMA_422)
VAR_6<<=1;
}
}
}
s->dsp.diff_pixels(s->block[0], ptr_y , dest_y , VAR_5);
s->dsp.diff_pixels(s->block[1], ptr_y + 8, dest_y + 8, VAR_5);
s->dsp.diff_pixels(s->block[2], ptr_y + VAR_4 , dest_y + VAR_4 , VAR_5);
s->dsp.diff_pixels(s->block[3], ptr_y + VAR_4 + 8, dest_y + VAR_4 + 8, VAR_5);
if(s->flags&CODEC_FLAG_GRAY){
VAR_3[4]= 1;
VAR_3[5]= 1;
}else{
s->dsp.diff_pixels(s->block[4], ptr_cb, dest_cb, VAR_6);
s->dsp.diff_pixels(s->block[5], ptr_cr, dest_cr, VAR_6);
if(!s->chroma_y_shift){
s->dsp.diff_pixels(s->block[6], ptr_cb + (VAR_4>>1), dest_cb + (VAR_4>>1), VAR_6);
s->dsp.diff_pixels(s->block[7], ptr_cr + (VAR_4>>1), dest_cr + (VAR_4>>1), VAR_6);
}
}
if(s->current_picture.mc_mb_var[s->mb_stride*VAR_1+ VAR_0]<2*s->qscale*s->qscale){
if(s->dsp.sad[1](NULL, ptr_y , dest_y , VAR_5, 8) < 20*s->qscale) VAR_3[0]= 1;
if(s->dsp.sad[1](NULL, ptr_y + 8, dest_y + 8, VAR_5, 8) < 20*s->qscale) VAR_3[1]= 1;
if(s->dsp.sad[1](NULL, ptr_y +VAR_4 , dest_y +VAR_4 , VAR_5, 8) < 20*s->qscale) VAR_3[2]= 1;
if(s->dsp.sad[1](NULL, ptr_y +VAR_4+ 8, dest_y +VAR_4+ 8, VAR_5, 8) < 20*s->qscale) VAR_3[3]= 1;
if(s->dsp.sad[1](NULL, ptr_cb , dest_cb , VAR_6, 8) < 20*s->qscale) VAR_3[4]= 1;
if(s->dsp.sad[1](NULL, ptr_cr , dest_cr , VAR_6, 8) < 20*s->qscale) VAR_3[5]= 1;
if(!s->chroma_y_shift){
if(s->dsp.sad[1](NULL, ptr_cb +(VAR_4>>1), dest_cb +(VAR_4>>1), VAR_6, 8) < 20*s->qscale) VAR_3[6]= 1;
if(s->dsp.sad[1](NULL, ptr_cr +(VAR_4>>1), dest_cr +(VAR_4>>1), VAR_6, 8) < 20*s->qscale) VAR_3[7]= 1;
}
}
}
if(s->avctx->quantizer_noise_shaping){
if(!VAR_3[0]) get_visual_weight(weight[0], ptr_y , VAR_5);
if(!VAR_3[1]) get_visual_weight(weight[1], ptr_y + 8, VAR_5);
if(!VAR_3[2]) get_visual_weight(weight[2], ptr_y + VAR_4 , VAR_5);
if(!VAR_3[3]) get_visual_weight(weight[3], ptr_y + VAR_4 + 8, VAR_5);
if(!VAR_3[4]) get_visual_weight(weight[4], ptr_cb , VAR_6);
if(!VAR_3[5]) get_visual_weight(weight[5], ptr_cr , VAR_6);
if(!s->chroma_y_shift){
if(!VAR_3[6]) get_visual_weight(weight[6], ptr_cb + (VAR_4>>1), VAR_6);
if(!VAR_3[7]) get_visual_weight(weight[7], ptr_cr + (VAR_4>>1), VAR_6);
}
memcpy(orig[0], s->block[0], sizeof(DCTELEM)*64*mb_block_count);
}
assert(s->out_format!=FMT_MJPEG || s->qscale==8);
{
for(VAR_2=0;VAR_2<mb_block_count;VAR_2++) {
if(!VAR_3[VAR_2]){
int VAR_11;
s->block_last_index[VAR_2] = s->dct_quantize(s, s->block[VAR_2], VAR_2, s->qscale, &VAR_11);
if (VAR_11) clip_coeffs(s, s->block[VAR_2], s->block_last_index[VAR_2]);
}else
s->block_last_index[VAR_2]= -1;
}
if(s->avctx->quantizer_noise_shaping){
for(VAR_2=0;VAR_2<mb_block_count;VAR_2++) {
if(!VAR_3[VAR_2]){
s->block_last_index[VAR_2] = dct_quantize_refine(s, s->block[VAR_2], weight[VAR_2], orig[VAR_2], VAR_2, s->qscale);
}
}
}
if(s->luma_elim_threshold && !s->mb_intra)
for(VAR_2=0; VAR_2<4; VAR_2++)
dct_single_coeff_elimination(s, VAR_2, s->luma_elim_threshold);
if(s->chroma_elim_threshold && !s->mb_intra)
for(VAR_2=4; VAR_2<mb_block_count; VAR_2++)
dct_single_coeff_elimination(s, VAR_2, s->chroma_elim_threshold);
if(s->flags & CODEC_FLAG_CBP_RD){
for(VAR_2=0;VAR_2<mb_block_count;VAR_2++) {
if(s->block_last_index[VAR_2] == -1)
s->coded_score[VAR_2]= INT_MAX/256;
}
}
}
if((s->flags&CODEC_FLAG_GRAY) && s->mb_intra){
s->block_last_index[4]=
s->block_last_index[5]= 0;
s->block[4][0]=
s->block[5][0]= (1024 + s->c_dc_scale/2)/ s->c_dc_scale;
}
if(s->alternate_scan && s->dct_quantize != dct_quantize_c){
for(VAR_2=0; VAR_2<mb_block_count; VAR_2++){
int VAR_12;
if(s->block_last_index[VAR_2]>0){
for(VAR_12=63; VAR_12>0; VAR_12--){
if(s->block[VAR_2][ s->intra_scantable.permutated[VAR_12] ]) break;
}
s->block_last_index[VAR_2]= VAR_12;
}
}
}
switch(s->codec_id){
case CODEC_ID_MPEG1VIDEO:
case CODEC_ID_MPEG2VIDEO:
if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER)
mpeg1_encode_mb(s, s->block, motion_x, motion_y);
break;
case CODEC_ID_MPEG4:
if (CONFIG_MPEG4_ENCODER)
mpeg4_encode_mb(s, s->block, motion_x, motion_y);
break;
case CODEC_ID_MSMPEG4V2:
case CODEC_ID_MSMPEG4V3:
case CODEC_ID_WMV1:
if (CONFIG_MSMPEG4_ENCODER)
msmpeg4_encode_mb(s, s->block, motion_x, motion_y);
break;
case CODEC_ID_WMV2:
if (CONFIG_WMV2_ENCODER)
ff_wmv2_encode_mb(s, s->block, motion_x, motion_y);
break;
case CODEC_ID_H261:
if (CONFIG_H261_ENCODER)
ff_h261_encode_mb(s, s->block, motion_x, motion_y);
break;
case CODEC_ID_H263:
case CODEC_ID_H263P:
case CODEC_ID_FLV1:
case CODEC_ID_RV10:
case CODEC_ID_RV20:
if (CONFIG_H263_ENCODER || CONFIG_H263P_ENCODER ||
CONFIG_FLV_ENCODER || CONFIG_RV10_ENCODER || CONFIG_RV20_ENCODER)
h263_encode_mb(s, s->block, motion_x, motion_y);
break;
case CODEC_ID_MJPEG:
if (CONFIG_MJPEG_ENCODER)
ff_mjpeg_encode_mb(s, s->block);
break;
default:
assert(0);
}
}
| [
"static av_always_inline void FUNC_0(MpegEncContext *s, int motion_x, int motion_y, int mb_block_height, int mb_block_count)\n{",
"int16_t weight[8][64];",
"DCTELEM orig[8][64];",
"const int VAR_0= s->VAR_0;",
"const int VAR_1= s->VAR_1;",
"int VAR_2;",
"int VAR_3[8];",
"int VAR_4 = s->linesize*8;",
"uint8_t *ptr_y, *ptr_cb, *ptr_cr;",
"int VAR_5, VAR_6;",
"for(VAR_2=0; VAR_2<mb_block_count; VAR_2++) VAR_3[VAR_2]=s->skipdct;",
"if(s->adaptive_quant){",
"const int VAR_7= s->qscale;",
"const int VAR_8= VAR_0 + VAR_1*s->mb_stride;",
"s->lambda= s->lambda_table[VAR_8];",
"update_qscale(s);",
"if(!(s->flags&CODEC_FLAG_QP_RD)){",
"s->qscale= s->current_picture_ptr->qscale_table[VAR_8];",
"s->dquant= s->qscale - VAR_7;",
"if(s->out_format==FMT_H263){",
"s->dquant= av_clip(s->dquant, -2, 2);",
"if(s->codec_id==CODEC_ID_MPEG4){",
"if(!s->mb_intra){",
"if(s->pict_type == FF_B_TYPE){",
"if(s->dquant&1 || s->mv_dir&MV_DIRECT)\ns->dquant= 0;",
"}",
"if(s->mv_type==MV_TYPE_8X8)\ns->dquant=0;",
"}",
"}",
"}",
"}",
"ff_set_qscale(s, VAR_7 + s->dquant);",
"}else if(s->flags&CODEC_FLAG_QP_RD)",
"ff_set_qscale(s, s->qscale + s->dquant);",
"VAR_5 = s->linesize;",
"VAR_6 = s->uvlinesize;",
"ptr_y = s->new_picture.data[0] + (VAR_1 * 16 * VAR_5) + VAR_0 * 16;",
"ptr_cb = s->new_picture.data[1] + (VAR_1 * mb_block_height * VAR_6) + VAR_0 * 8;",
"ptr_cr = s->new_picture.data[2] + (VAR_1 * mb_block_height * VAR_6) + VAR_0 * 8;",
"if(VAR_0*16+16 > s->width || VAR_1*16+16 > s->height){",
"uint8_t *ebuf= s->edge_emu_buffer + 32;",
"ff_emulated_edge_mc(ebuf , ptr_y , VAR_5,16,16,VAR_0*16,VAR_1*16, s->width , s->height);",
"ptr_y= ebuf;",
"ff_emulated_edge_mc(ebuf+18*VAR_5 , ptr_cb, VAR_6, 8, mb_block_height, VAR_0*8, VAR_1*8, s->width>>1, s->height>>1);",
"ptr_cb= ebuf+18*VAR_5;",
"ff_emulated_edge_mc(ebuf+18*VAR_5+8, ptr_cr, VAR_6, 8, mb_block_height, VAR_0*8, VAR_1*8, s->width>>1, s->height>>1);",
"ptr_cr= ebuf+18*VAR_5+8;",
"}",
"if (s->mb_intra) {",
"if(s->flags&CODEC_FLAG_INTERLACED_DCT){",
"int VAR_11, VAR_11;",
"s->interlaced_dct=0;",
"VAR_11= s->dsp.ildct_cmp[4](s, ptr_y , NULL, VAR_5, 8)\n+s->dsp.ildct_cmp[4](s, ptr_y + VAR_5*8, NULL, VAR_5, 8) - 400;",
"if(VAR_11 > 0){",
"VAR_11 = s->dsp.ildct_cmp[4](s, ptr_y , NULL, VAR_5*2, 8)\n+s->dsp.ildct_cmp[4](s, ptr_y + VAR_5 , NULL, VAR_5*2, 8);",
"if(VAR_11 > VAR_11){",
"s->interlaced_dct=1;",
"VAR_4= VAR_5;",
"VAR_5<<=1;",
"if (s->chroma_format == CHROMA_422)\nVAR_6<<=1;",
"}",
"}",
"}",
"s->dsp.get_pixels(s->block[0], ptr_y , VAR_5);",
"s->dsp.get_pixels(s->block[1], ptr_y + 8, VAR_5);",
"s->dsp.get_pixels(s->block[2], ptr_y + VAR_4 , VAR_5);",
"s->dsp.get_pixels(s->block[3], ptr_y + VAR_4 + 8, VAR_5);",
"if(s->flags&CODEC_FLAG_GRAY){",
"VAR_3[4]= 1;",
"VAR_3[5]= 1;",
"}else{",
"s->dsp.get_pixels(s->block[4], ptr_cb, VAR_6);",
"s->dsp.get_pixels(s->block[5], ptr_cr, VAR_6);",
"if(!s->chroma_y_shift){",
"s->dsp.get_pixels(s->block[6], ptr_cb + (VAR_4>>1), VAR_6);",
"s->dsp.get_pixels(s->block[7], ptr_cr + (VAR_4>>1), VAR_6);",
"}",
"}",
"}else{",
"op_pixels_func (*op_pix)[4];",
"qpel_mc_func (*op_qpix)[16];",
"uint8_t *dest_y, *dest_cb, *dest_cr;",
"dest_y = s->dest[0];",
"dest_cb = s->dest[1];",
"dest_cr = s->dest[2];",
"if ((!s->no_rounding) || s->pict_type==FF_B_TYPE){",
"op_pix = s->dsp.put_pixels_tab;",
"op_qpix= s->dsp.put_qpel_pixels_tab;",
"}else{",
"op_pix = s->dsp.put_no_rnd_pixels_tab;",
"op_qpix= s->dsp.put_no_rnd_qpel_pixels_tab;",
"}",
"if (s->mv_dir & MV_DIR_FORWARD) {",
"MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.data, op_pix, op_qpix);",
"op_pix = s->dsp.avg_pixels_tab;",
"op_qpix= s->dsp.avg_qpel_pixels_tab;",
"}",
"if (s->mv_dir & MV_DIR_BACKWARD) {",
"MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.data, op_pix, op_qpix);",
"}",
"if(s->flags&CODEC_FLAG_INTERLACED_DCT){",
"int VAR_11, VAR_11;",
"s->interlaced_dct=0;",
"VAR_11= s->dsp.ildct_cmp[0](s, dest_y , ptr_y , VAR_5, 8)\n+s->dsp.ildct_cmp[0](s, dest_y + VAR_5*8, ptr_y + VAR_5*8, VAR_5, 8) - 400;",
"if(s->avctx->ildct_cmp == FF_CMP_VSSE) VAR_11 -= 400;",
"if(VAR_11>0){",
"VAR_11 = s->dsp.ildct_cmp[0](s, dest_y , ptr_y , VAR_5*2, 8)\n+s->dsp.ildct_cmp[0](s, dest_y + VAR_5 , ptr_y + VAR_5 , VAR_5*2, 8);",
"if(VAR_11 > VAR_11){",
"s->interlaced_dct=1;",
"VAR_4= VAR_5;",
"VAR_5<<=1;",
"if (s->chroma_format == CHROMA_422)\nVAR_6<<=1;",
"}",
"}",
"}",
"s->dsp.diff_pixels(s->block[0], ptr_y , dest_y , VAR_5);",
"s->dsp.diff_pixels(s->block[1], ptr_y + 8, dest_y + 8, VAR_5);",
"s->dsp.diff_pixels(s->block[2], ptr_y + VAR_4 , dest_y + VAR_4 , VAR_5);",
"s->dsp.diff_pixels(s->block[3], ptr_y + VAR_4 + 8, dest_y + VAR_4 + 8, VAR_5);",
"if(s->flags&CODEC_FLAG_GRAY){",
"VAR_3[4]= 1;",
"VAR_3[5]= 1;",
"}else{",
"s->dsp.diff_pixels(s->block[4], ptr_cb, dest_cb, VAR_6);",
"s->dsp.diff_pixels(s->block[5], ptr_cr, dest_cr, VAR_6);",
"if(!s->chroma_y_shift){",
"s->dsp.diff_pixels(s->block[6], ptr_cb + (VAR_4>>1), dest_cb + (VAR_4>>1), VAR_6);",
"s->dsp.diff_pixels(s->block[7], ptr_cr + (VAR_4>>1), dest_cr + (VAR_4>>1), VAR_6);",
"}",
"}",
"if(s->current_picture.mc_mb_var[s->mb_stride*VAR_1+ VAR_0]<2*s->qscale*s->qscale){",
"if(s->dsp.sad[1](NULL, ptr_y , dest_y , VAR_5, 8) < 20*s->qscale) VAR_3[0]= 1;",
"if(s->dsp.sad[1](NULL, ptr_y + 8, dest_y + 8, VAR_5, 8) < 20*s->qscale) VAR_3[1]= 1;",
"if(s->dsp.sad[1](NULL, ptr_y +VAR_4 , dest_y +VAR_4 , VAR_5, 8) < 20*s->qscale) VAR_3[2]= 1;",
"if(s->dsp.sad[1](NULL, ptr_y +VAR_4+ 8, dest_y +VAR_4+ 8, VAR_5, 8) < 20*s->qscale) VAR_3[3]= 1;",
"if(s->dsp.sad[1](NULL, ptr_cb , dest_cb , VAR_6, 8) < 20*s->qscale) VAR_3[4]= 1;",
"if(s->dsp.sad[1](NULL, ptr_cr , dest_cr , VAR_6, 8) < 20*s->qscale) VAR_3[5]= 1;",
"if(!s->chroma_y_shift){",
"if(s->dsp.sad[1](NULL, ptr_cb +(VAR_4>>1), dest_cb +(VAR_4>>1), VAR_6, 8) < 20*s->qscale) VAR_3[6]= 1;",
"if(s->dsp.sad[1](NULL, ptr_cr +(VAR_4>>1), dest_cr +(VAR_4>>1), VAR_6, 8) < 20*s->qscale) VAR_3[7]= 1;",
"}",
"}",
"}",
"if(s->avctx->quantizer_noise_shaping){",
"if(!VAR_3[0]) get_visual_weight(weight[0], ptr_y , VAR_5);",
"if(!VAR_3[1]) get_visual_weight(weight[1], ptr_y + 8, VAR_5);",
"if(!VAR_3[2]) get_visual_weight(weight[2], ptr_y + VAR_4 , VAR_5);",
"if(!VAR_3[3]) get_visual_weight(weight[3], ptr_y + VAR_4 + 8, VAR_5);",
"if(!VAR_3[4]) get_visual_weight(weight[4], ptr_cb , VAR_6);",
"if(!VAR_3[5]) get_visual_weight(weight[5], ptr_cr , VAR_6);",
"if(!s->chroma_y_shift){",
"if(!VAR_3[6]) get_visual_weight(weight[6], ptr_cb + (VAR_4>>1), VAR_6);",
"if(!VAR_3[7]) get_visual_weight(weight[7], ptr_cr + (VAR_4>>1), VAR_6);",
"}",
"memcpy(orig[0], s->block[0], sizeof(DCTELEM)*64*mb_block_count);",
"}",
"assert(s->out_format!=FMT_MJPEG || s->qscale==8);",
"{",
"for(VAR_2=0;VAR_2<mb_block_count;VAR_2++) {",
"if(!VAR_3[VAR_2]){",
"int VAR_11;",
"s->block_last_index[VAR_2] = s->dct_quantize(s, s->block[VAR_2], VAR_2, s->qscale, &VAR_11);",
"if (VAR_11) clip_coeffs(s, s->block[VAR_2], s->block_last_index[VAR_2]);",
"}else",
"s->block_last_index[VAR_2]= -1;",
"}",
"if(s->avctx->quantizer_noise_shaping){",
"for(VAR_2=0;VAR_2<mb_block_count;VAR_2++) {",
"if(!VAR_3[VAR_2]){",
"s->block_last_index[VAR_2] = dct_quantize_refine(s, s->block[VAR_2], weight[VAR_2], orig[VAR_2], VAR_2, s->qscale);",
"}",
"}",
"}",
"if(s->luma_elim_threshold && !s->mb_intra)\nfor(VAR_2=0; VAR_2<4; VAR_2++)",
"dct_single_coeff_elimination(s, VAR_2, s->luma_elim_threshold);",
"if(s->chroma_elim_threshold && !s->mb_intra)\nfor(VAR_2=4; VAR_2<mb_block_count; VAR_2++)",
"dct_single_coeff_elimination(s, VAR_2, s->chroma_elim_threshold);",
"if(s->flags & CODEC_FLAG_CBP_RD){",
"for(VAR_2=0;VAR_2<mb_block_count;VAR_2++) {",
"if(s->block_last_index[VAR_2] == -1)\ns->coded_score[VAR_2]= INT_MAX/256;",
"}",
"}",
"}",
"if((s->flags&CODEC_FLAG_GRAY) && s->mb_intra){",
"s->block_last_index[4]=\ns->block_last_index[5]= 0;",
"s->block[4][0]=\ns->block[5][0]= (1024 + s->c_dc_scale/2)/ s->c_dc_scale;",
"}",
"if(s->alternate_scan && s->dct_quantize != dct_quantize_c){",
"for(VAR_2=0; VAR_2<mb_block_count; VAR_2++){",
"int VAR_12;",
"if(s->block_last_index[VAR_2]>0){",
"for(VAR_12=63; VAR_12>0; VAR_12--){",
"if(s->block[VAR_2][ s->intra_scantable.permutated[VAR_12] ]) break;",
"}",
"s->block_last_index[VAR_2]= VAR_12;",
"}",
"}",
"}",
"switch(s->codec_id){",
"case CODEC_ID_MPEG1VIDEO:\ncase CODEC_ID_MPEG2VIDEO:\nif (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER)\nmpeg1_encode_mb(s, s->block, motion_x, motion_y);",
"break;",
"case CODEC_ID_MPEG4:\nif (CONFIG_MPEG4_ENCODER)\nmpeg4_encode_mb(s, s->block, motion_x, motion_y);",
"break;",
"case CODEC_ID_MSMPEG4V2:\ncase CODEC_ID_MSMPEG4V3:\ncase CODEC_ID_WMV1:\nif (CONFIG_MSMPEG4_ENCODER)\nmsmpeg4_encode_mb(s, s->block, motion_x, motion_y);",
"break;",
"case CODEC_ID_WMV2:\nif (CONFIG_WMV2_ENCODER)\nff_wmv2_encode_mb(s, s->block, motion_x, motion_y);",
"break;",
"case CODEC_ID_H261:\nif (CONFIG_H261_ENCODER)\nff_h261_encode_mb(s, s->block, motion_x, motion_y);",
"break;",
"case CODEC_ID_H263:\ncase CODEC_ID_H263P:\ncase CODEC_ID_FLV1:\ncase CODEC_ID_RV10:\ncase CODEC_ID_RV20:\nif (CONFIG_H263_ENCODER || CONFIG_H263P_ENCODER ||\nCONFIG_FLV_ENCODER || CONFIG_RV10_ENCODER || CONFIG_RV20_ENCODER)\nh263_encode_mb(s, s->block, motion_x, motion_y);",
"break;",
"case CODEC_ID_MJPEG:\nif (CONFIG_MJPEG_ENCODER)\nff_mjpeg_encode_mb(s, s->block);",
"break;",
"default:\nassert(0);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131,
133
],
[
137
],
[
139,
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153,
155
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
207
],
[
209
],
[
211
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
249
],
[
251
],
[
255
],
[
257,
259
],
[
263
],
[
267
],
[
269,
271
],
[
275
],
[
277
],
[
281
],
[
283
],
[
285,
287
],
[
289
],
[
291
],
[
293
],
[
297
],
[
299
],
[
301
],
[
303
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
331
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
433,
435
],
[
437
],
[
439,
441
],
[
443
],
[
447
],
[
449
],
[
451,
453
],
[
455
],
[
457
],
[
459
],
[
463
],
[
465,
467
],
[
469,
471
],
[
473
],
[
479
],
[
481
],
[
483
],
[
485
],
[
487
],
[
489
],
[
491
],
[
493
],
[
495
],
[
497
],
[
499
],
[
505
],
[
507,
509,
511,
513
],
[
515
],
[
517,
519,
521
],
[
523
],
[
525,
527,
529,
531,
533
],
[
535
],
[
537,
539,
541
],
[
543
],
[
545,
547,
549
],
[
551
],
[
553,
555,
557,
559,
561,
563,
565,
567
],
[
569
],
[
571,
573,
575
],
[
577
],
[
579,
581
],
[
583
],
[
585
]
] |
26,859 | vpc_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
QEMUIOVector *qiov, int flags)
{
BDRVVPCState *s = bs->opaque;
int64_t image_offset;
int64_t n_bytes;
int64_t bytes_done = 0;
int ret;
VHDFooter *footer = (VHDFooter *) s->footer_buf;
QEMUIOVector local_qiov;
if (be32_to_cpu(footer->type) == VHD_FIXED) {
return bdrv_co_pwritev(bs->file, offset, bytes, qiov, 0);
}
qemu_co_mutex_lock(&s->lock);
qemu_iovec_init(&local_qiov, qiov->niov);
while (bytes > 0) {
image_offset = get_image_offset(bs, offset, true);
n_bytes = MIN(bytes, s->block_size - (offset % s->block_size));
if (image_offset == -1) {
image_offset = alloc_block(bs, offset);
if (image_offset < 0) {
ret = image_offset;
goto fail;
}
}
qemu_iovec_reset(&local_qiov);
qemu_iovec_concat(&local_qiov, qiov, bytes_done, n_bytes);
ret = bdrv_co_pwritev(bs->file, image_offset, n_bytes,
&local_qiov, 0);
if (ret < 0) {
goto fail;
}
bytes -= n_bytes;
offset += n_bytes;
bytes_done += n_bytes;
}
ret = 0;
fail:
qemu_iovec_destroy(&local_qiov);
qemu_co_mutex_unlock(&s->lock);
return ret;
}
| true | qemu | cfc87e00c22ab4ea0262c9771c803ed03d754001 | vpc_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
QEMUIOVector *qiov, int flags)
{
BDRVVPCState *s = bs->opaque;
int64_t image_offset;
int64_t n_bytes;
int64_t bytes_done = 0;
int ret;
VHDFooter *footer = (VHDFooter *) s->footer_buf;
QEMUIOVector local_qiov;
if (be32_to_cpu(footer->type) == VHD_FIXED) {
return bdrv_co_pwritev(bs->file, offset, bytes, qiov, 0);
}
qemu_co_mutex_lock(&s->lock);
qemu_iovec_init(&local_qiov, qiov->niov);
while (bytes > 0) {
image_offset = get_image_offset(bs, offset, true);
n_bytes = MIN(bytes, s->block_size - (offset % s->block_size));
if (image_offset == -1) {
image_offset = alloc_block(bs, offset);
if (image_offset < 0) {
ret = image_offset;
goto fail;
}
}
qemu_iovec_reset(&local_qiov);
qemu_iovec_concat(&local_qiov, qiov, bytes_done, n_bytes);
ret = bdrv_co_pwritev(bs->file, image_offset, n_bytes,
&local_qiov, 0);
if (ret < 0) {
goto fail;
}
bytes -= n_bytes;
offset += n_bytes;
bytes_done += n_bytes;
}
ret = 0;
fail:
qemu_iovec_destroy(&local_qiov);
qemu_co_mutex_unlock(&s->lock);
return ret;
}
| {
"code": [
" image_offset = get_image_offset(bs, offset, true);"
],
"line_no": [
39
]
} | FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1, uint64_t VAR_2,
QEMUIOVector *VAR_3, int VAR_4)
{
BDRVVPCState *s = VAR_0->opaque;
int64_t image_offset;
int64_t n_bytes;
int64_t bytes_done = 0;
int VAR_5;
VHDFooter *footer = (VHDFooter *) s->footer_buf;
QEMUIOVector local_qiov;
if (be32_to_cpu(footer->type) == VHD_FIXED) {
return bdrv_co_pwritev(VAR_0->file, VAR_1, VAR_2, VAR_3, 0);
}
qemu_co_mutex_lock(&s->lock);
qemu_iovec_init(&local_qiov, VAR_3->niov);
while (VAR_2 > 0) {
image_offset = get_image_offset(VAR_0, VAR_1, true);
n_bytes = MIN(VAR_2, s->block_size - (VAR_1 % s->block_size));
if (image_offset == -1) {
image_offset = alloc_block(VAR_0, VAR_1);
if (image_offset < 0) {
VAR_5 = image_offset;
goto fail;
}
}
qemu_iovec_reset(&local_qiov);
qemu_iovec_concat(&local_qiov, VAR_3, bytes_done, n_bytes);
VAR_5 = bdrv_co_pwritev(VAR_0->file, image_offset, n_bytes,
&local_qiov, 0);
if (VAR_5 < 0) {
goto fail;
}
VAR_2 -= n_bytes;
VAR_1 += n_bytes;
bytes_done += n_bytes;
}
VAR_5 = 0;
fail:
qemu_iovec_destroy(&local_qiov);
qemu_co_mutex_unlock(&s->lock);
return VAR_5;
}
| [
"FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1, uint64_t VAR_2,\nQEMUIOVector *VAR_3, int VAR_4)\n{",
"BDRVVPCState *s = VAR_0->opaque;",
"int64_t image_offset;",
"int64_t n_bytes;",
"int64_t bytes_done = 0;",
"int VAR_5;",
"VHDFooter *footer = (VHDFooter *) s->footer_buf;",
"QEMUIOVector local_qiov;",
"if (be32_to_cpu(footer->type) == VHD_FIXED) {",
"return bdrv_co_pwritev(VAR_0->file, VAR_1, VAR_2, VAR_3, 0);",
"}",
"qemu_co_mutex_lock(&s->lock);",
"qemu_iovec_init(&local_qiov, VAR_3->niov);",
"while (VAR_2 > 0) {",
"image_offset = get_image_offset(VAR_0, VAR_1, true);",
"n_bytes = MIN(VAR_2, s->block_size - (VAR_1 % s->block_size));",
"if (image_offset == -1) {",
"image_offset = alloc_block(VAR_0, VAR_1);",
"if (image_offset < 0) {",
"VAR_5 = image_offset;",
"goto fail;",
"}",
"}",
"qemu_iovec_reset(&local_qiov);",
"qemu_iovec_concat(&local_qiov, VAR_3, bytes_done, n_bytes);",
"VAR_5 = bdrv_co_pwritev(VAR_0->file, image_offset, n_bytes,\n&local_qiov, 0);",
"if (VAR_5 < 0) {",
"goto fail;",
"}",
"VAR_2 -= n_bytes;",
"VAR_1 += n_bytes;",
"bytes_done += n_bytes;",
"}",
"VAR_5 = 0;",
"fail:\nqemu_iovec_destroy(&local_qiov);",
"qemu_co_mutex_unlock(&s->lock);",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91,
93
],
[
95
],
[
99
],
[
101
]
] |
26,860 | bool memory_region_present(MemoryRegion *container, hwaddr addr)
{
MemoryRegion *mr = memory_region_find(container, addr, 1).mr;
if (!mr || (mr == container)) {
return false;
}
memory_region_unref(mr);
return true;
}
| true | qemu | c6742b14fe7352059cd4954a356a8105757af31b | bool memory_region_present(MemoryRegion *container, hwaddr addr)
{
MemoryRegion *mr = memory_region_find(container, addr, 1).mr;
if (!mr || (mr == container)) {
return false;
}
memory_region_unref(mr);
return true;
}
| {
"code": [
"bool memory_region_present(MemoryRegion *container, hwaddr addr)",
" MemoryRegion *mr = memory_region_find(container, addr, 1).mr;",
" if (!mr || (mr == container)) {",
" return false;",
" memory_region_unref(mr);",
" return true;"
],
"line_no": [
1,
5,
7,
9,
13,
15
]
} | bool FUNC_0(MemoryRegion *container, hwaddr addr)
{
MemoryRegion *mr = memory_region_find(container, addr, 1).mr;
if (!mr || (mr == container)) {
return false;
}
memory_region_unref(mr);
return true;
}
| [
"bool FUNC_0(MemoryRegion *container, hwaddr addr)\n{",
"MemoryRegion *mr = memory_region_find(container, addr, 1).mr;",
"if (!mr || (mr == container)) {",
"return false;",
"}",
"memory_region_unref(mr);",
"return true;",
"}"
] | [
1,
1,
1,
1,
0,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
26,861 | static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l)
{
TCGMemOp opc = l->opc;
TCGReg data_reg;
uint8_t **label_ptr = &l->label_ptr[0];
/* resolve label address */
*(uint32_t *)label_ptr[0] = (uint32_t)(s->code_ptr - label_ptr[0] - 4);
if (TARGET_LONG_BITS > TCG_TARGET_REG_BITS) {
*(uint32_t *)label_ptr[1] = (uint32_t)(s->code_ptr - label_ptr[1] - 4);
}
if (TCG_TARGET_REG_BITS == 32) {
int ofs = 0;
tcg_out_st(s, TCG_TYPE_PTR, TCG_AREG0, TCG_REG_ESP, ofs);
ofs += 4;
tcg_out_st(s, TCG_TYPE_I32, l->addrlo_reg, TCG_REG_ESP, ofs);
ofs += 4;
if (TARGET_LONG_BITS == 64) {
tcg_out_st(s, TCG_TYPE_I32, l->addrhi_reg, TCG_REG_ESP, ofs);
ofs += 4;
}
tcg_out_sti(s, TCG_TYPE_I32, TCG_REG_ESP, ofs, l->mem_index);
ofs += 4;
tcg_out_sti(s, TCG_TYPE_I32, TCG_REG_ESP, ofs, (uintptr_t)l->raddr);
} else {
tcg_out_mov(s, TCG_TYPE_PTR, tcg_target_call_iarg_regs[0], TCG_AREG0);
/* The second argument is already loaded with addrlo. */
tcg_out_movi(s, TCG_TYPE_I32, tcg_target_call_iarg_regs[2],
l->mem_index);
tcg_out_movi(s, TCG_TYPE_PTR, tcg_target_call_iarg_regs[3],
(uintptr_t)l->raddr);
}
tcg_out_calli(s, (uintptr_t)qemu_ld_helpers[opc & ~MO_SIGN]);
data_reg = l->datalo_reg;
switch (opc & MO_SSIZE) {
case MO_SB:
tcg_out_ext8s(s, data_reg, TCG_REG_EAX, P_REXW);
break;
case MO_SW:
tcg_out_ext16s(s, data_reg, TCG_REG_EAX, P_REXW);
break;
#if TCG_TARGET_REG_BITS == 64
case MO_SL:
tcg_out_ext32s(s, data_reg, TCG_REG_EAX);
break;
#endif
case MO_UB:
case MO_UW:
/* Note that the helpers have zero-extended to tcg_target_long. */
case MO_UL:
tcg_out_mov(s, TCG_TYPE_I32, data_reg, TCG_REG_EAX);
break;
case MO_Q:
if (TCG_TARGET_REG_BITS == 64) {
tcg_out_mov(s, TCG_TYPE_I64, data_reg, TCG_REG_RAX);
} else if (data_reg == TCG_REG_EDX) {
/* xchg %edx, %eax */
tcg_out_opc(s, OPC_XCHG_ax_r32 + TCG_REG_EDX, 0, 0, 0);
tcg_out_mov(s, TCG_TYPE_I32, l->datahi_reg, TCG_REG_EAX);
} else {
tcg_out_mov(s, TCG_TYPE_I32, data_reg, TCG_REG_EAX);
tcg_out_mov(s, TCG_TYPE_I32, l->datahi_reg, TCG_REG_EDX);
}
break;
default:
tcg_abort();
}
/* Jump to the code corresponding to next IR of qemu_st */
tcg_out_jmp(s, (uintptr_t)l->raddr);
}
| true | qemu | 5c53bb812152c3d7919cadfd47c210b181bf89ac | static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l)
{
TCGMemOp opc = l->opc;
TCGReg data_reg;
uint8_t **label_ptr = &l->label_ptr[0];
*(uint32_t *)label_ptr[0] = (uint32_t)(s->code_ptr - label_ptr[0] - 4);
if (TARGET_LONG_BITS > TCG_TARGET_REG_BITS) {
*(uint32_t *)label_ptr[1] = (uint32_t)(s->code_ptr - label_ptr[1] - 4);
}
if (TCG_TARGET_REG_BITS == 32) {
int ofs = 0;
tcg_out_st(s, TCG_TYPE_PTR, TCG_AREG0, TCG_REG_ESP, ofs);
ofs += 4;
tcg_out_st(s, TCG_TYPE_I32, l->addrlo_reg, TCG_REG_ESP, ofs);
ofs += 4;
if (TARGET_LONG_BITS == 64) {
tcg_out_st(s, TCG_TYPE_I32, l->addrhi_reg, TCG_REG_ESP, ofs);
ofs += 4;
}
tcg_out_sti(s, TCG_TYPE_I32, TCG_REG_ESP, ofs, l->mem_index);
ofs += 4;
tcg_out_sti(s, TCG_TYPE_I32, TCG_REG_ESP, ofs, (uintptr_t)l->raddr);
} else {
tcg_out_mov(s, TCG_TYPE_PTR, tcg_target_call_iarg_regs[0], TCG_AREG0);
tcg_out_movi(s, TCG_TYPE_I32, tcg_target_call_iarg_regs[2],
l->mem_index);
tcg_out_movi(s, TCG_TYPE_PTR, tcg_target_call_iarg_regs[3],
(uintptr_t)l->raddr);
}
tcg_out_calli(s, (uintptr_t)qemu_ld_helpers[opc & ~MO_SIGN]);
data_reg = l->datalo_reg;
switch (opc & MO_SSIZE) {
case MO_SB:
tcg_out_ext8s(s, data_reg, TCG_REG_EAX, P_REXW);
break;
case MO_SW:
tcg_out_ext16s(s, data_reg, TCG_REG_EAX, P_REXW);
break;
#if TCG_TARGET_REG_BITS == 64
case MO_SL:
tcg_out_ext32s(s, data_reg, TCG_REG_EAX);
break;
#endif
case MO_UB:
case MO_UW:
case MO_UL:
tcg_out_mov(s, TCG_TYPE_I32, data_reg, TCG_REG_EAX);
break;
case MO_Q:
if (TCG_TARGET_REG_BITS == 64) {
tcg_out_mov(s, TCG_TYPE_I64, data_reg, TCG_REG_RAX);
} else if (data_reg == TCG_REG_EDX) {
tcg_out_opc(s, OPC_XCHG_ax_r32 + TCG_REG_EDX, 0, 0, 0);
tcg_out_mov(s, TCG_TYPE_I32, l->datahi_reg, TCG_REG_EAX);
} else {
tcg_out_mov(s, TCG_TYPE_I32, data_reg, TCG_REG_EAX);
tcg_out_mov(s, TCG_TYPE_I32, l->datahi_reg, TCG_REG_EDX);
}
break;
default:
tcg_abort();
}
tcg_out_jmp(s, (uintptr_t)l->raddr);
}
| {
"code": [
" *(uint32_t *)label_ptr[0] = (uint32_t)(s->code_ptr - label_ptr[0] - 4);",
" *(uint32_t *)label_ptr[1] = (uint32_t)(s->code_ptr - label_ptr[1] - 4);",
" *(uint32_t *)label_ptr[0] = (uint32_t)(s->code_ptr - label_ptr[0] - 4);",
" *(uint32_t *)label_ptr[1] = (uint32_t)(s->code_ptr - label_ptr[1] - 4);"
],
"line_no": [
15,
19,
15,
19
]
} | static void FUNC_0(TCGContext *VAR_0, TCGLabelQemuLdst *VAR_1)
{
TCGMemOp opc = VAR_1->opc;
TCGReg data_reg;
uint8_t **label_ptr = &VAR_1->label_ptr[0];
*(uint32_t *)label_ptr[0] = (uint32_t)(VAR_0->code_ptr - label_ptr[0] - 4);
if (TARGET_LONG_BITS > TCG_TARGET_REG_BITS) {
*(uint32_t *)label_ptr[1] = (uint32_t)(VAR_0->code_ptr - label_ptr[1] - 4);
}
if (TCG_TARGET_REG_BITS == 32) {
int VAR_2 = 0;
tcg_out_st(VAR_0, TCG_TYPE_PTR, TCG_AREG0, TCG_REG_ESP, VAR_2);
VAR_2 += 4;
tcg_out_st(VAR_0, TCG_TYPE_I32, VAR_1->addrlo_reg, TCG_REG_ESP, VAR_2);
VAR_2 += 4;
if (TARGET_LONG_BITS == 64) {
tcg_out_st(VAR_0, TCG_TYPE_I32, VAR_1->addrhi_reg, TCG_REG_ESP, VAR_2);
VAR_2 += 4;
}
tcg_out_sti(VAR_0, TCG_TYPE_I32, TCG_REG_ESP, VAR_2, VAR_1->mem_index);
VAR_2 += 4;
tcg_out_sti(VAR_0, TCG_TYPE_I32, TCG_REG_ESP, VAR_2, (uintptr_t)VAR_1->raddr);
} else {
tcg_out_mov(VAR_0, TCG_TYPE_PTR, tcg_target_call_iarg_regs[0], TCG_AREG0);
tcg_out_movi(VAR_0, TCG_TYPE_I32, tcg_target_call_iarg_regs[2],
VAR_1->mem_index);
tcg_out_movi(VAR_0, TCG_TYPE_PTR, tcg_target_call_iarg_regs[3],
(uintptr_t)VAR_1->raddr);
}
tcg_out_calli(VAR_0, (uintptr_t)qemu_ld_helpers[opc & ~MO_SIGN]);
data_reg = VAR_1->datalo_reg;
switch (opc & MO_SSIZE) {
case MO_SB:
tcg_out_ext8s(VAR_0, data_reg, TCG_REG_EAX, P_REXW);
break;
case MO_SW:
tcg_out_ext16s(VAR_0, data_reg, TCG_REG_EAX, P_REXW);
break;
#if TCG_TARGET_REG_BITS == 64
case MO_SL:
tcg_out_ext32s(VAR_0, data_reg, TCG_REG_EAX);
break;
#endif
case MO_UB:
case MO_UW:
case MO_UL:
tcg_out_mov(VAR_0, TCG_TYPE_I32, data_reg, TCG_REG_EAX);
break;
case MO_Q:
if (TCG_TARGET_REG_BITS == 64) {
tcg_out_mov(VAR_0, TCG_TYPE_I64, data_reg, TCG_REG_RAX);
} else if (data_reg == TCG_REG_EDX) {
tcg_out_opc(VAR_0, OPC_XCHG_ax_r32 + TCG_REG_EDX, 0, 0, 0);
tcg_out_mov(VAR_0, TCG_TYPE_I32, VAR_1->datahi_reg, TCG_REG_EAX);
} else {
tcg_out_mov(VAR_0, TCG_TYPE_I32, data_reg, TCG_REG_EAX);
tcg_out_mov(VAR_0, TCG_TYPE_I32, VAR_1->datahi_reg, TCG_REG_EDX);
}
break;
default:
tcg_abort();
}
tcg_out_jmp(VAR_0, (uintptr_t)VAR_1->raddr);
}
| [
"static void FUNC_0(TCGContext *VAR_0, TCGLabelQemuLdst *VAR_1)\n{",
"TCGMemOp opc = VAR_1->opc;",
"TCGReg data_reg;",
"uint8_t **label_ptr = &VAR_1->label_ptr[0];",
"*(uint32_t *)label_ptr[0] = (uint32_t)(VAR_0->code_ptr - label_ptr[0] - 4);",
"if (TARGET_LONG_BITS > TCG_TARGET_REG_BITS) {",
"*(uint32_t *)label_ptr[1] = (uint32_t)(VAR_0->code_ptr - label_ptr[1] - 4);",
"}",
"if (TCG_TARGET_REG_BITS == 32) {",
"int VAR_2 = 0;",
"tcg_out_st(VAR_0, TCG_TYPE_PTR, TCG_AREG0, TCG_REG_ESP, VAR_2);",
"VAR_2 += 4;",
"tcg_out_st(VAR_0, TCG_TYPE_I32, VAR_1->addrlo_reg, TCG_REG_ESP, VAR_2);",
"VAR_2 += 4;",
"if (TARGET_LONG_BITS == 64) {",
"tcg_out_st(VAR_0, TCG_TYPE_I32, VAR_1->addrhi_reg, TCG_REG_ESP, VAR_2);",
"VAR_2 += 4;",
"}",
"tcg_out_sti(VAR_0, TCG_TYPE_I32, TCG_REG_ESP, VAR_2, VAR_1->mem_index);",
"VAR_2 += 4;",
"tcg_out_sti(VAR_0, TCG_TYPE_I32, TCG_REG_ESP, VAR_2, (uintptr_t)VAR_1->raddr);",
"} else {",
"tcg_out_mov(VAR_0, TCG_TYPE_PTR, tcg_target_call_iarg_regs[0], TCG_AREG0);",
"tcg_out_movi(VAR_0, TCG_TYPE_I32, tcg_target_call_iarg_regs[2],\nVAR_1->mem_index);",
"tcg_out_movi(VAR_0, TCG_TYPE_PTR, tcg_target_call_iarg_regs[3],\n(uintptr_t)VAR_1->raddr);",
"}",
"tcg_out_calli(VAR_0, (uintptr_t)qemu_ld_helpers[opc & ~MO_SIGN]);",
"data_reg = VAR_1->datalo_reg;",
"switch (opc & MO_SSIZE) {",
"case MO_SB:\ntcg_out_ext8s(VAR_0, data_reg, TCG_REG_EAX, P_REXW);",
"break;",
"case MO_SW:\ntcg_out_ext16s(VAR_0, data_reg, TCG_REG_EAX, P_REXW);",
"break;",
"#if TCG_TARGET_REG_BITS == 64\ncase MO_SL:\ntcg_out_ext32s(VAR_0, data_reg, TCG_REG_EAX);",
"break;",
"#endif\ncase MO_UB:\ncase MO_UW:\ncase MO_UL:\ntcg_out_mov(VAR_0, TCG_TYPE_I32, data_reg, TCG_REG_EAX);",
"break;",
"case MO_Q:\nif (TCG_TARGET_REG_BITS == 64) {",
"tcg_out_mov(VAR_0, TCG_TYPE_I64, data_reg, TCG_REG_RAX);",
"} else if (data_reg == TCG_REG_EDX) {",
"tcg_out_opc(VAR_0, OPC_XCHG_ax_r32 + TCG_REG_EDX, 0, 0, 0);",
"tcg_out_mov(VAR_0, TCG_TYPE_I32, VAR_1->datahi_reg, TCG_REG_EAX);",
"} else {",
"tcg_out_mov(VAR_0, TCG_TYPE_I32, data_reg, TCG_REG_EAX);",
"tcg_out_mov(VAR_0, TCG_TYPE_I32, VAR_1->datahi_reg, TCG_REG_EDX);",
"}",
"break;",
"default:\ntcg_abort();",
"}",
"tcg_out_jmp(VAR_0, (uintptr_t)VAR_1->raddr);",
"}"
] | [
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
67,
69
],
[
71,
73
],
[
75
],
[
79
],
[
83
],
[
85
],
[
87,
89
],
[
91
],
[
93,
95
],
[
97
],
[
99,
101,
103
],
[
105
],
[
107,
109,
111,
115,
117
],
[
119
],
[
121,
123
],
[
125
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145,
147
],
[
149
],
[
155
],
[
157
]
] |
26,863 | static long do_sigreturn_v1(CPUARMState *env)
{
abi_ulong frame_addr;
struct sigframe_v1 *frame;
target_sigset_t set;
sigset_t host_set;
int i;
/*
* 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.
*/
if (env->regs[13] & 7)
goto badframe;
frame_addr = env->regs[13];
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
goto badframe;
if (__get_user(set.sig[0], &frame->sc.oldmask))
goto badframe;
for(i = 1; i < TARGET_NSIG_WORDS; i++) {
if (__get_user(set.sig[i], &frame->extramask[i - 1]))
goto badframe;
}
target_to_host_sigset_internal(&host_set, &set);
sigprocmask(SIG_SETMASK, &host_set, NULL);
if (restore_sigcontext(env, &frame->sc))
goto badframe;
#if 0
/* Send SIGTRAP if we're single-stepping */
if (ptrace_cancel_bpt(current))
send_sig(SIGTRAP, current, 1);
#endif
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;
}
| true | qemu | 978fae9f1ac47e22890a1bd9ebf5fa46fe8b6ef7 | static long do_sigreturn_v1(CPUARMState *env)
{
abi_ulong frame_addr;
struct sigframe_v1 *frame;
target_sigset_t set;
sigset_t host_set;
int i;
if (env->regs[13] & 7)
goto badframe;
frame_addr = env->regs[13];
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
goto badframe;
if (__get_user(set.sig[0], &frame->sc.oldmask))
goto badframe;
for(i = 1; i < TARGET_NSIG_WORDS; i++) {
if (__get_user(set.sig[i], &frame->extramask[i - 1]))
goto badframe;
}
target_to_host_sigset_internal(&host_set, &set);
sigprocmask(SIG_SETMASK, &host_set, NULL);
if (restore_sigcontext(env, &frame->sc))
goto badframe;
#if 0
if (ptrace_cancel_bpt(current))
send_sig(SIGTRAP, current, 1);
#endif
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": [
"\tstruct sigframe_v1 *frame;",
"\tif (env->regs[13] & 7)",
"\t\tgoto badframe;",
"\tif (env->regs[13] & 7)",
"\t\tgoto badframe;",
"\tif (env->regs[13] & 7)",
"\t\tgoto badframe;",
"\tif (env->regs[13] & 7)",
"\t\tgoto badframe;"
],
"line_no": [
7,
27,
29,
27,
29,
27,
29,
27,
29
]
} | static long FUNC_0(CPUARMState *VAR_0)
{
abi_ulong frame_addr;
struct sigframe_v1 *VAR_1;
target_sigset_t set;
sigset_t host_set;
int VAR_2;
if (VAR_0->regs[13] & 7)
goto badframe;
frame_addr = VAR_0->regs[13];
if (!lock_user_struct(VERIFY_READ, VAR_1, frame_addr, 1))
goto badframe;
if (__get_user(set.sig[0], &VAR_1->sc.oldmask))
goto badframe;
for(VAR_2 = 1; VAR_2 < TARGET_NSIG_WORDS; VAR_2++) {
if (__get_user(set.sig[VAR_2], &VAR_1->extramask[VAR_2 - 1]))
goto badframe;
}
target_to_host_sigset_internal(&host_set, &set);
sigprocmask(SIG_SETMASK, &host_set, NULL);
if (restore_sigcontext(VAR_0, &VAR_1->sc))
goto badframe;
#if 0
if (ptrace_cancel_bpt(current))
send_sig(SIGTRAP, current, 1);
#endif
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 sigframe_v1 *VAR_1;",
"target_sigset_t set;",
"sigset_t host_set;",
"int VAR_2;",
"if (VAR_0->regs[13] & 7)\ngoto badframe;",
"frame_addr = VAR_0->regs[13];",
"if (!lock_user_struct(VERIFY_READ, VAR_1, frame_addr, 1))\ngoto badframe;",
"if (__get_user(set.sig[0], &VAR_1->sc.oldmask))\ngoto badframe;",
"for(VAR_2 = 1; VAR_2 < TARGET_NSIG_WORDS; VAR_2++) {",
"if (__get_user(set.sig[VAR_2], &VAR_1->extramask[VAR_2 - 1]))\ngoto badframe;",
"}",
"target_to_host_sigset_internal(&host_set, &set);",
"sigprocmask(SIG_SETMASK, &host_set, NULL);",
"if (restore_sigcontext(VAR_0, &VAR_1->sc))\ngoto badframe;",
"#if 0\nif (ptrace_cancel_bpt(current))\nsend_sig(SIGTRAP, current, 1);",
"#endif\nunlock_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,
1,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
27,
29
],
[
33
],
[
35,
37
],
[
41,
43
],
[
45
],
[
47,
49
],
[
51
],
[
55
],
[
57
],
[
61,
63
],
[
67,
71,
73
],
[
75,
77
],
[
79
],
[
83,
85
],
[
87
],
[
89
],
[
91
]
] |
26,864 | static void tcp_chr_connect(void *opaque)
{
CharDriverState *chr = opaque;
TCPCharDriver *s = chr->opaque;
QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(s->ioc);
g_free(chr->filename);
chr->filename = sockaddr_to_str(&sioc->localAddr, sioc->localAddrLen,
&sioc->remoteAddr, sioc->remoteAddrLen,
s->is_listen, s->is_telnet);
s->connected = 1;
if (s->ioc) {
chr->fd_in_tag = io_add_watch_poll(s->ioc,
tcp_chr_read_poll,
tcp_chr_read, chr);
}
qemu_chr_be_generic_open(chr);
}
| true | qemu | a8fb542705ac7e0dcf00908bc47bf49cdd058abe | static void tcp_chr_connect(void *opaque)
{
CharDriverState *chr = opaque;
TCPCharDriver *s = chr->opaque;
QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(s->ioc);
g_free(chr->filename);
chr->filename = sockaddr_to_str(&sioc->localAddr, sioc->localAddrLen,
&sioc->remoteAddr, sioc->remoteAddrLen,
s->is_listen, s->is_telnet);
s->connected = 1;
if (s->ioc) {
chr->fd_in_tag = io_add_watch_poll(s->ioc,
tcp_chr_read_poll,
tcp_chr_read, chr);
}
qemu_chr_be_generic_open(chr);
}
| {
"code": [
" QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(s->ioc);",
" chr->filename = sockaddr_to_str(&sioc->localAddr, sioc->localAddrLen,",
" &sioc->remoteAddr, sioc->remoteAddrLen,",
" s->is_listen, s->is_telnet);"
],
"line_no": [
9,
15,
17,
19
]
} | static void FUNC_0(void *VAR_0)
{
CharDriverState *chr = VAR_0;
TCPCharDriver *s = chr->VAR_0;
QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(s->ioc);
g_free(chr->filename);
chr->filename = sockaddr_to_str(&sioc->localAddr, sioc->localAddrLen,
&sioc->remoteAddr, sioc->remoteAddrLen,
s->is_listen, s->is_telnet);
s->connected = 1;
if (s->ioc) {
chr->fd_in_tag = io_add_watch_poll(s->ioc,
tcp_chr_read_poll,
tcp_chr_read, chr);
}
qemu_chr_be_generic_open(chr);
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"CharDriverState *chr = VAR_0;",
"TCPCharDriver *s = chr->VAR_0;",
"QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(s->ioc);",
"g_free(chr->filename);",
"chr->filename = sockaddr_to_str(&sioc->localAddr, sioc->localAddrLen,\n&sioc->remoteAddr, sioc->remoteAddrLen,\ns->is_listen, s->is_telnet);",
"s->connected = 1;",
"if (s->ioc) {",
"chr->fd_in_tag = io_add_watch_poll(s->ioc,\ntcp_chr_read_poll,\ntcp_chr_read, chr);",
"}",
"qemu_chr_be_generic_open(chr);",
"}"
] | [
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15,
17,
19
],
[
23
],
[
25
],
[
27,
29,
31
],
[
33
],
[
35
],
[
37
]
] |
26,865 | static void gen_muldiv (DisasContext *ctx, uint32_t opc,
int rs, int rt)
{
const char *opn = "mul/div";
TCGv t0, t1;
unsigned int acc;
switch (opc) {
case OPC_DIV:
case OPC_DIVU:
#if defined(TARGET_MIPS64)
case OPC_DDIV:
case OPC_DDIVU:
#endif
t0 = tcg_temp_local_new();
t1 = tcg_temp_local_new();
break;
default:
t0 = tcg_temp_new();
t1 = tcg_temp_new();
break;
}
gen_load_gpr(t0, rs);
gen_load_gpr(t1, rt);
switch (opc) {
case OPC_DIV:
{
int l1 = gen_new_label();
int l2 = gen_new_label();
tcg_gen_ext32s_tl(t0, t0);
tcg_gen_ext32s_tl(t1, t1);
tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);
tcg_gen_brcondi_tl(TCG_COND_NE, t0, INT_MIN, l2);
tcg_gen_brcondi_tl(TCG_COND_NE, t1, -1, l2);
tcg_gen_mov_tl(cpu_LO[0], t0);
tcg_gen_movi_tl(cpu_HI[0], 0);
tcg_gen_br(l1);
gen_set_label(l2);
tcg_gen_div_tl(cpu_LO[0], t0, t1);
tcg_gen_rem_tl(cpu_HI[0], t0, t1);
tcg_gen_ext32s_tl(cpu_LO[0], cpu_LO[0]);
tcg_gen_ext32s_tl(cpu_HI[0], cpu_HI[0]);
gen_set_label(l1);
}
opn = "div";
break;
case OPC_DIVU:
{
int l1 = gen_new_label();
tcg_gen_ext32u_tl(t0, t0);
tcg_gen_ext32u_tl(t1, t1);
tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);
tcg_gen_divu_tl(cpu_LO[0], t0, t1);
tcg_gen_remu_tl(cpu_HI[0], t0, t1);
tcg_gen_ext32s_tl(cpu_LO[0], cpu_LO[0]);
tcg_gen_ext32s_tl(cpu_HI[0], cpu_HI[0]);
gen_set_label(l1);
}
opn = "divu";
break;
case OPC_MULT:
{
TCGv_i64 t2 = tcg_temp_new_i64();
TCGv_i64 t3 = tcg_temp_new_i64();
acc = ((ctx->opcode) >> 11) & 0x03;
if (acc != 0) {
check_dsp(ctx);
}
tcg_gen_ext_tl_i64(t2, t0);
tcg_gen_ext_tl_i64(t3, t1);
tcg_gen_mul_i64(t2, t2, t3);
tcg_temp_free_i64(t3);
tcg_gen_trunc_i64_tl(t0, t2);
tcg_gen_shri_i64(t2, t2, 32);
tcg_gen_trunc_i64_tl(t1, t2);
tcg_temp_free_i64(t2);
tcg_gen_ext32s_tl(cpu_LO[acc], t0);
tcg_gen_ext32s_tl(cpu_HI[acc], t1);
}
opn = "mult";
break;
case OPC_MULTU:
{
TCGv_i64 t2 = tcg_temp_new_i64();
TCGv_i64 t3 = tcg_temp_new_i64();
acc = ((ctx->opcode) >> 11) & 0x03;
if (acc != 0) {
check_dsp(ctx);
}
tcg_gen_ext32u_tl(t0, t0);
tcg_gen_ext32u_tl(t1, t1);
tcg_gen_extu_tl_i64(t2, t0);
tcg_gen_extu_tl_i64(t3, t1);
tcg_gen_mul_i64(t2, t2, t3);
tcg_temp_free_i64(t3);
tcg_gen_trunc_i64_tl(t0, t2);
tcg_gen_shri_i64(t2, t2, 32);
tcg_gen_trunc_i64_tl(t1, t2);
tcg_temp_free_i64(t2);
tcg_gen_ext32s_tl(cpu_LO[acc], t0);
tcg_gen_ext32s_tl(cpu_HI[acc], t1);
}
opn = "multu";
break;
#if defined(TARGET_MIPS64)
case OPC_DDIV:
{
int l1 = gen_new_label();
int l2 = gen_new_label();
tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);
tcg_gen_brcondi_tl(TCG_COND_NE, t0, -1LL << 63, l2);
tcg_gen_brcondi_tl(TCG_COND_NE, t1, -1LL, l2);
tcg_gen_mov_tl(cpu_LO[0], t0);
tcg_gen_movi_tl(cpu_HI[0], 0);
tcg_gen_br(l1);
gen_set_label(l2);
tcg_gen_div_i64(cpu_LO[0], t0, t1);
tcg_gen_rem_i64(cpu_HI[0], t0, t1);
gen_set_label(l1);
}
opn = "ddiv";
break;
case OPC_DDIVU:
{
int l1 = gen_new_label();
tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);
tcg_gen_divu_i64(cpu_LO[0], t0, t1);
tcg_gen_remu_i64(cpu_HI[0], t0, t1);
gen_set_label(l1);
}
opn = "ddivu";
break;
case OPC_DMULT:
gen_helper_dmult(cpu_env, t0, t1);
opn = "dmult";
break;
case OPC_DMULTU:
gen_helper_dmultu(cpu_env, t0, t1);
opn = "dmultu";
break;
#endif
case OPC_MADD:
{
TCGv_i64 t2 = tcg_temp_new_i64();
TCGv_i64 t3 = tcg_temp_new_i64();
acc = ((ctx->opcode) >> 11) & 0x03;
if (acc != 0) {
check_dsp(ctx);
}
tcg_gen_ext_tl_i64(t2, t0);
tcg_gen_ext_tl_i64(t3, t1);
tcg_gen_mul_i64(t2, t2, t3);
tcg_gen_concat_tl_i64(t3, cpu_LO[acc], cpu_HI[acc]);
tcg_gen_add_i64(t2, t2, t3);
tcg_temp_free_i64(t3);
tcg_gen_trunc_i64_tl(t0, t2);
tcg_gen_shri_i64(t2, t2, 32);
tcg_gen_trunc_i64_tl(t1, t2);
tcg_temp_free_i64(t2);
tcg_gen_ext32s_tl(cpu_LO[acc], t0);
tcg_gen_ext32s_tl(cpu_HI[acc], t1);
}
opn = "madd";
break;
case OPC_MADDU:
{
TCGv_i64 t2 = tcg_temp_new_i64();
TCGv_i64 t3 = tcg_temp_new_i64();
acc = ((ctx->opcode) >> 11) & 0x03;
if (acc != 0) {
check_dsp(ctx);
}
tcg_gen_ext32u_tl(t0, t0);
tcg_gen_ext32u_tl(t1, t1);
tcg_gen_extu_tl_i64(t2, t0);
tcg_gen_extu_tl_i64(t3, t1);
tcg_gen_mul_i64(t2, t2, t3);
tcg_gen_concat_tl_i64(t3, cpu_LO[acc], cpu_HI[acc]);
tcg_gen_add_i64(t2, t2, t3);
tcg_temp_free_i64(t3);
tcg_gen_trunc_i64_tl(t0, t2);
tcg_gen_shri_i64(t2, t2, 32);
tcg_gen_trunc_i64_tl(t1, t2);
tcg_temp_free_i64(t2);
tcg_gen_ext32s_tl(cpu_LO[acc], t0);
tcg_gen_ext32s_tl(cpu_HI[acc], t1);
}
opn = "maddu";
break;
case OPC_MSUB:
{
TCGv_i64 t2 = tcg_temp_new_i64();
TCGv_i64 t3 = tcg_temp_new_i64();
acc = ((ctx->opcode) >> 11) & 0x03;
if (acc != 0) {
check_dsp(ctx);
}
tcg_gen_ext_tl_i64(t2, t0);
tcg_gen_ext_tl_i64(t3, t1);
tcg_gen_mul_i64(t2, t2, t3);
tcg_gen_concat_tl_i64(t3, cpu_LO[acc], cpu_HI[acc]);
tcg_gen_sub_i64(t2, t3, t2);
tcg_temp_free_i64(t3);
tcg_gen_trunc_i64_tl(t0, t2);
tcg_gen_shri_i64(t2, t2, 32);
tcg_gen_trunc_i64_tl(t1, t2);
tcg_temp_free_i64(t2);
tcg_gen_ext32s_tl(cpu_LO[acc], t0);
tcg_gen_ext32s_tl(cpu_HI[acc], t1);
}
opn = "msub";
break;
case OPC_MSUBU:
{
TCGv_i64 t2 = tcg_temp_new_i64();
TCGv_i64 t3 = tcg_temp_new_i64();
acc = ((ctx->opcode) >> 11) & 0x03;
if (acc != 0) {
check_dsp(ctx);
}
tcg_gen_ext32u_tl(t0, t0);
tcg_gen_ext32u_tl(t1, t1);
tcg_gen_extu_tl_i64(t2, t0);
tcg_gen_extu_tl_i64(t3, t1);
tcg_gen_mul_i64(t2, t2, t3);
tcg_gen_concat_tl_i64(t3, cpu_LO[acc], cpu_HI[acc]);
tcg_gen_sub_i64(t2, t3, t2);
tcg_temp_free_i64(t3);
tcg_gen_trunc_i64_tl(t0, t2);
tcg_gen_shri_i64(t2, t2, 32);
tcg_gen_trunc_i64_tl(t1, t2);
tcg_temp_free_i64(t2);
tcg_gen_ext32s_tl(cpu_LO[acc], t0);
tcg_gen_ext32s_tl(cpu_HI[acc], t1);
}
opn = "msubu";
break;
default:
MIPS_INVAL(opn);
generate_exception(ctx, EXCP_RI);
goto out;
}
(void)opn; /* avoid a compiler warning */
MIPS_DEBUG("%s %s %s", opn, regnames[rs], regnames[rt]);
out:
tcg_temp_free(t0);
tcg_temp_free(t1);
}
| true | qemu | 51127181cfac0315720e6ca502eb133a353f6b11 | static void gen_muldiv (DisasContext *ctx, uint32_t opc,
int rs, int rt)
{
const char *opn = "mul/div";
TCGv t0, t1;
unsigned int acc;
switch (opc) {
case OPC_DIV:
case OPC_DIVU:
#if defined(TARGET_MIPS64)
case OPC_DDIV:
case OPC_DDIVU:
#endif
t0 = tcg_temp_local_new();
t1 = tcg_temp_local_new();
break;
default:
t0 = tcg_temp_new();
t1 = tcg_temp_new();
break;
}
gen_load_gpr(t0, rs);
gen_load_gpr(t1, rt);
switch (opc) {
case OPC_DIV:
{
int l1 = gen_new_label();
int l2 = gen_new_label();
tcg_gen_ext32s_tl(t0, t0);
tcg_gen_ext32s_tl(t1, t1);
tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);
tcg_gen_brcondi_tl(TCG_COND_NE, t0, INT_MIN, l2);
tcg_gen_brcondi_tl(TCG_COND_NE, t1, -1, l2);
tcg_gen_mov_tl(cpu_LO[0], t0);
tcg_gen_movi_tl(cpu_HI[0], 0);
tcg_gen_br(l1);
gen_set_label(l2);
tcg_gen_div_tl(cpu_LO[0], t0, t1);
tcg_gen_rem_tl(cpu_HI[0], t0, t1);
tcg_gen_ext32s_tl(cpu_LO[0], cpu_LO[0]);
tcg_gen_ext32s_tl(cpu_HI[0], cpu_HI[0]);
gen_set_label(l1);
}
opn = "div";
break;
case OPC_DIVU:
{
int l1 = gen_new_label();
tcg_gen_ext32u_tl(t0, t0);
tcg_gen_ext32u_tl(t1, t1);
tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);
tcg_gen_divu_tl(cpu_LO[0], t0, t1);
tcg_gen_remu_tl(cpu_HI[0], t0, t1);
tcg_gen_ext32s_tl(cpu_LO[0], cpu_LO[0]);
tcg_gen_ext32s_tl(cpu_HI[0], cpu_HI[0]);
gen_set_label(l1);
}
opn = "divu";
break;
case OPC_MULT:
{
TCGv_i64 t2 = tcg_temp_new_i64();
TCGv_i64 t3 = tcg_temp_new_i64();
acc = ((ctx->opcode) >> 11) & 0x03;
if (acc != 0) {
check_dsp(ctx);
}
tcg_gen_ext_tl_i64(t2, t0);
tcg_gen_ext_tl_i64(t3, t1);
tcg_gen_mul_i64(t2, t2, t3);
tcg_temp_free_i64(t3);
tcg_gen_trunc_i64_tl(t0, t2);
tcg_gen_shri_i64(t2, t2, 32);
tcg_gen_trunc_i64_tl(t1, t2);
tcg_temp_free_i64(t2);
tcg_gen_ext32s_tl(cpu_LO[acc], t0);
tcg_gen_ext32s_tl(cpu_HI[acc], t1);
}
opn = "mult";
break;
case OPC_MULTU:
{
TCGv_i64 t2 = tcg_temp_new_i64();
TCGv_i64 t3 = tcg_temp_new_i64();
acc = ((ctx->opcode) >> 11) & 0x03;
if (acc != 0) {
check_dsp(ctx);
}
tcg_gen_ext32u_tl(t0, t0);
tcg_gen_ext32u_tl(t1, t1);
tcg_gen_extu_tl_i64(t2, t0);
tcg_gen_extu_tl_i64(t3, t1);
tcg_gen_mul_i64(t2, t2, t3);
tcg_temp_free_i64(t3);
tcg_gen_trunc_i64_tl(t0, t2);
tcg_gen_shri_i64(t2, t2, 32);
tcg_gen_trunc_i64_tl(t1, t2);
tcg_temp_free_i64(t2);
tcg_gen_ext32s_tl(cpu_LO[acc], t0);
tcg_gen_ext32s_tl(cpu_HI[acc], t1);
}
opn = "multu";
break;
#if defined(TARGET_MIPS64)
case OPC_DDIV:
{
int l1 = gen_new_label();
int l2 = gen_new_label();
tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);
tcg_gen_brcondi_tl(TCG_COND_NE, t0, -1LL << 63, l2);
tcg_gen_brcondi_tl(TCG_COND_NE, t1, -1LL, l2);
tcg_gen_mov_tl(cpu_LO[0], t0);
tcg_gen_movi_tl(cpu_HI[0], 0);
tcg_gen_br(l1);
gen_set_label(l2);
tcg_gen_div_i64(cpu_LO[0], t0, t1);
tcg_gen_rem_i64(cpu_HI[0], t0, t1);
gen_set_label(l1);
}
opn = "ddiv";
break;
case OPC_DDIVU:
{
int l1 = gen_new_label();
tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);
tcg_gen_divu_i64(cpu_LO[0], t0, t1);
tcg_gen_remu_i64(cpu_HI[0], t0, t1);
gen_set_label(l1);
}
opn = "ddivu";
break;
case OPC_DMULT:
gen_helper_dmult(cpu_env, t0, t1);
opn = "dmult";
break;
case OPC_DMULTU:
gen_helper_dmultu(cpu_env, t0, t1);
opn = "dmultu";
break;
#endif
case OPC_MADD:
{
TCGv_i64 t2 = tcg_temp_new_i64();
TCGv_i64 t3 = tcg_temp_new_i64();
acc = ((ctx->opcode) >> 11) & 0x03;
if (acc != 0) {
check_dsp(ctx);
}
tcg_gen_ext_tl_i64(t2, t0);
tcg_gen_ext_tl_i64(t3, t1);
tcg_gen_mul_i64(t2, t2, t3);
tcg_gen_concat_tl_i64(t3, cpu_LO[acc], cpu_HI[acc]);
tcg_gen_add_i64(t2, t2, t3);
tcg_temp_free_i64(t3);
tcg_gen_trunc_i64_tl(t0, t2);
tcg_gen_shri_i64(t2, t2, 32);
tcg_gen_trunc_i64_tl(t1, t2);
tcg_temp_free_i64(t2);
tcg_gen_ext32s_tl(cpu_LO[acc], t0);
tcg_gen_ext32s_tl(cpu_HI[acc], t1);
}
opn = "madd";
break;
case OPC_MADDU:
{
TCGv_i64 t2 = tcg_temp_new_i64();
TCGv_i64 t3 = tcg_temp_new_i64();
acc = ((ctx->opcode) >> 11) & 0x03;
if (acc != 0) {
check_dsp(ctx);
}
tcg_gen_ext32u_tl(t0, t0);
tcg_gen_ext32u_tl(t1, t1);
tcg_gen_extu_tl_i64(t2, t0);
tcg_gen_extu_tl_i64(t3, t1);
tcg_gen_mul_i64(t2, t2, t3);
tcg_gen_concat_tl_i64(t3, cpu_LO[acc], cpu_HI[acc]);
tcg_gen_add_i64(t2, t2, t3);
tcg_temp_free_i64(t3);
tcg_gen_trunc_i64_tl(t0, t2);
tcg_gen_shri_i64(t2, t2, 32);
tcg_gen_trunc_i64_tl(t1, t2);
tcg_temp_free_i64(t2);
tcg_gen_ext32s_tl(cpu_LO[acc], t0);
tcg_gen_ext32s_tl(cpu_HI[acc], t1);
}
opn = "maddu";
break;
case OPC_MSUB:
{
TCGv_i64 t2 = tcg_temp_new_i64();
TCGv_i64 t3 = tcg_temp_new_i64();
acc = ((ctx->opcode) >> 11) & 0x03;
if (acc != 0) {
check_dsp(ctx);
}
tcg_gen_ext_tl_i64(t2, t0);
tcg_gen_ext_tl_i64(t3, t1);
tcg_gen_mul_i64(t2, t2, t3);
tcg_gen_concat_tl_i64(t3, cpu_LO[acc], cpu_HI[acc]);
tcg_gen_sub_i64(t2, t3, t2);
tcg_temp_free_i64(t3);
tcg_gen_trunc_i64_tl(t0, t2);
tcg_gen_shri_i64(t2, t2, 32);
tcg_gen_trunc_i64_tl(t1, t2);
tcg_temp_free_i64(t2);
tcg_gen_ext32s_tl(cpu_LO[acc], t0);
tcg_gen_ext32s_tl(cpu_HI[acc], t1);
}
opn = "msub";
break;
case OPC_MSUBU:
{
TCGv_i64 t2 = tcg_temp_new_i64();
TCGv_i64 t3 = tcg_temp_new_i64();
acc = ((ctx->opcode) >> 11) & 0x03;
if (acc != 0) {
check_dsp(ctx);
}
tcg_gen_ext32u_tl(t0, t0);
tcg_gen_ext32u_tl(t1, t1);
tcg_gen_extu_tl_i64(t2, t0);
tcg_gen_extu_tl_i64(t3, t1);
tcg_gen_mul_i64(t2, t2, t3);
tcg_gen_concat_tl_i64(t3, cpu_LO[acc], cpu_HI[acc]);
tcg_gen_sub_i64(t2, t3, t2);
tcg_temp_free_i64(t3);
tcg_gen_trunc_i64_tl(t0, t2);
tcg_gen_shri_i64(t2, t2, 32);
tcg_gen_trunc_i64_tl(t1, t2);
tcg_temp_free_i64(t2);
tcg_gen_ext32s_tl(cpu_LO[acc], t0);
tcg_gen_ext32s_tl(cpu_HI[acc], t1);
}
opn = "msubu";
break;
default:
MIPS_INVAL(opn);
generate_exception(ctx, EXCP_RI);
goto out;
}
(void)opn;
MIPS_DEBUG("%s %s %s", opn, regnames[rs], regnames[rt]);
out:
tcg_temp_free(t0);
tcg_temp_free(t1);
}
| {
"code": [
" switch (opc) {",
" case OPC_DIV:",
" case OPC_DIVU:",
"#if defined(TARGET_MIPS64)",
" case OPC_DDIV:",
" case OPC_DDIVU:",
"#endif",
" t0 = tcg_temp_local_new();",
" t1 = tcg_temp_local_new();",
" break;",
" default:",
" t0 = tcg_temp_new();",
" t1 = tcg_temp_new();",
" break;",
" int l1 = gen_new_label();",
" int l2 = gen_new_label();",
" tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);",
" tcg_gen_brcondi_tl(TCG_COND_NE, t0, INT_MIN, l2);",
" tcg_gen_brcondi_tl(TCG_COND_NE, t1, -1, l2);",
" tcg_gen_mov_tl(cpu_LO[0], t0);",
" tcg_gen_movi_tl(cpu_HI[0], 0);",
" tcg_gen_br(l1);",
" gen_set_label(l2);",
" gen_set_label(l1);",
" int l1 = gen_new_label();",
" tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);",
" gen_set_label(l1);",
" int l1 = gen_new_label();",
" int l2 = gen_new_label();",
" tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);",
" tcg_gen_brcondi_tl(TCG_COND_NE, t0, -1LL << 63, l2);",
" tcg_gen_brcondi_tl(TCG_COND_NE, t1, -1LL, l2);",
" tcg_gen_mov_tl(cpu_LO[0], t0);",
" tcg_gen_movi_tl(cpu_HI[0], 0);",
" tcg_gen_br(l1);",
" gen_set_label(l2);",
" tcg_gen_div_i64(cpu_LO[0], t0, t1);",
" tcg_gen_rem_i64(cpu_HI[0], t0, t1);",
" gen_set_label(l1);",
" int l1 = gen_new_label();",
" tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);",
" gen_set_label(l1);"
],
"line_no": [
15,
17,
19,
21,
23,
25,
27,
29,
31,
33,
35,
37,
39,
33,
57,
59,
67,
69,
71,
75,
77,
79,
81,
91,
57,
67,
91,
57,
59,
67,
235,
237,
75,
77,
79,
81,
247,
249,
91,
57,
67,
91
]
} | static void FUNC_0 (DisasContext *VAR_0, uint32_t VAR_1,
int VAR_2, int VAR_3)
{
const char *VAR_4 = "mul/div";
TCGv t0, t1;
unsigned int VAR_5;
switch (VAR_1) {
case OPC_DIV:
case OPC_DIVU:
#if defined(TARGET_MIPS64)
case OPC_DDIV:
case OPC_DDIVU:
#endif
t0 = tcg_temp_local_new();
t1 = tcg_temp_local_new();
break;
default:
t0 = tcg_temp_new();
t1 = tcg_temp_new();
break;
}
gen_load_gpr(t0, VAR_2);
gen_load_gpr(t1, VAR_3);
switch (VAR_1) {
case OPC_DIV:
{
int VAR_8 = gen_new_label();
int VAR_7 = gen_new_label();
tcg_gen_ext32s_tl(t0, t0);
tcg_gen_ext32s_tl(t1, t1);
tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, VAR_8);
tcg_gen_brcondi_tl(TCG_COND_NE, t0, INT_MIN, VAR_7);
tcg_gen_brcondi_tl(TCG_COND_NE, t1, -1, VAR_7);
tcg_gen_mov_tl(cpu_LO[0], t0);
tcg_gen_movi_tl(cpu_HI[0], 0);
tcg_gen_br(VAR_8);
gen_set_label(VAR_7);
tcg_gen_div_tl(cpu_LO[0], t0, t1);
tcg_gen_rem_tl(cpu_HI[0], t0, t1);
tcg_gen_ext32s_tl(cpu_LO[0], cpu_LO[0]);
tcg_gen_ext32s_tl(cpu_HI[0], cpu_HI[0]);
gen_set_label(VAR_8);
}
VAR_4 = "div";
break;
case OPC_DIVU:
{
int VAR_8 = gen_new_label();
tcg_gen_ext32u_tl(t0, t0);
tcg_gen_ext32u_tl(t1, t1);
tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, VAR_8);
tcg_gen_divu_tl(cpu_LO[0], t0, t1);
tcg_gen_remu_tl(cpu_HI[0], t0, t1);
tcg_gen_ext32s_tl(cpu_LO[0], cpu_LO[0]);
tcg_gen_ext32s_tl(cpu_HI[0], cpu_HI[0]);
gen_set_label(VAR_8);
}
VAR_4 = "divu";
break;
case OPC_MULT:
{
TCGv_i64 t2 = tcg_temp_new_i64();
TCGv_i64 t3 = tcg_temp_new_i64();
VAR_5 = ((VAR_0->opcode) >> 11) & 0x03;
if (VAR_5 != 0) {
check_dsp(VAR_0);
}
tcg_gen_ext_tl_i64(t2, t0);
tcg_gen_ext_tl_i64(t3, t1);
tcg_gen_mul_i64(t2, t2, t3);
tcg_temp_free_i64(t3);
tcg_gen_trunc_i64_tl(t0, t2);
tcg_gen_shri_i64(t2, t2, 32);
tcg_gen_trunc_i64_tl(t1, t2);
tcg_temp_free_i64(t2);
tcg_gen_ext32s_tl(cpu_LO[VAR_5], t0);
tcg_gen_ext32s_tl(cpu_HI[VAR_5], t1);
}
VAR_4 = "mult";
break;
case OPC_MULTU:
{
TCGv_i64 t2 = tcg_temp_new_i64();
TCGv_i64 t3 = tcg_temp_new_i64();
VAR_5 = ((VAR_0->opcode) >> 11) & 0x03;
if (VAR_5 != 0) {
check_dsp(VAR_0);
}
tcg_gen_ext32u_tl(t0, t0);
tcg_gen_ext32u_tl(t1, t1);
tcg_gen_extu_tl_i64(t2, t0);
tcg_gen_extu_tl_i64(t3, t1);
tcg_gen_mul_i64(t2, t2, t3);
tcg_temp_free_i64(t3);
tcg_gen_trunc_i64_tl(t0, t2);
tcg_gen_shri_i64(t2, t2, 32);
tcg_gen_trunc_i64_tl(t1, t2);
tcg_temp_free_i64(t2);
tcg_gen_ext32s_tl(cpu_LO[VAR_5], t0);
tcg_gen_ext32s_tl(cpu_HI[VAR_5], t1);
}
VAR_4 = "multu";
break;
#if defined(TARGET_MIPS64)
case OPC_DDIV:
{
int VAR_8 = gen_new_label();
int VAR_7 = gen_new_label();
tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, VAR_8);
tcg_gen_brcondi_tl(TCG_COND_NE, t0, -1LL << 63, VAR_7);
tcg_gen_brcondi_tl(TCG_COND_NE, t1, -1LL, VAR_7);
tcg_gen_mov_tl(cpu_LO[0], t0);
tcg_gen_movi_tl(cpu_HI[0], 0);
tcg_gen_br(VAR_8);
gen_set_label(VAR_7);
tcg_gen_div_i64(cpu_LO[0], t0, t1);
tcg_gen_rem_i64(cpu_HI[0], t0, t1);
gen_set_label(VAR_8);
}
VAR_4 = "ddiv";
break;
case OPC_DDIVU:
{
int VAR_8 = gen_new_label();
tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, VAR_8);
tcg_gen_divu_i64(cpu_LO[0], t0, t1);
tcg_gen_remu_i64(cpu_HI[0], t0, t1);
gen_set_label(VAR_8);
}
VAR_4 = "ddivu";
break;
case OPC_DMULT:
gen_helper_dmult(cpu_env, t0, t1);
VAR_4 = "dmult";
break;
case OPC_DMULTU:
gen_helper_dmultu(cpu_env, t0, t1);
VAR_4 = "dmultu";
break;
#endif
case OPC_MADD:
{
TCGv_i64 t2 = tcg_temp_new_i64();
TCGv_i64 t3 = tcg_temp_new_i64();
VAR_5 = ((VAR_0->opcode) >> 11) & 0x03;
if (VAR_5 != 0) {
check_dsp(VAR_0);
}
tcg_gen_ext_tl_i64(t2, t0);
tcg_gen_ext_tl_i64(t3, t1);
tcg_gen_mul_i64(t2, t2, t3);
tcg_gen_concat_tl_i64(t3, cpu_LO[VAR_5], cpu_HI[VAR_5]);
tcg_gen_add_i64(t2, t2, t3);
tcg_temp_free_i64(t3);
tcg_gen_trunc_i64_tl(t0, t2);
tcg_gen_shri_i64(t2, t2, 32);
tcg_gen_trunc_i64_tl(t1, t2);
tcg_temp_free_i64(t2);
tcg_gen_ext32s_tl(cpu_LO[VAR_5], t0);
tcg_gen_ext32s_tl(cpu_HI[VAR_5], t1);
}
VAR_4 = "madd";
break;
case OPC_MADDU:
{
TCGv_i64 t2 = tcg_temp_new_i64();
TCGv_i64 t3 = tcg_temp_new_i64();
VAR_5 = ((VAR_0->opcode) >> 11) & 0x03;
if (VAR_5 != 0) {
check_dsp(VAR_0);
}
tcg_gen_ext32u_tl(t0, t0);
tcg_gen_ext32u_tl(t1, t1);
tcg_gen_extu_tl_i64(t2, t0);
tcg_gen_extu_tl_i64(t3, t1);
tcg_gen_mul_i64(t2, t2, t3);
tcg_gen_concat_tl_i64(t3, cpu_LO[VAR_5], cpu_HI[VAR_5]);
tcg_gen_add_i64(t2, t2, t3);
tcg_temp_free_i64(t3);
tcg_gen_trunc_i64_tl(t0, t2);
tcg_gen_shri_i64(t2, t2, 32);
tcg_gen_trunc_i64_tl(t1, t2);
tcg_temp_free_i64(t2);
tcg_gen_ext32s_tl(cpu_LO[VAR_5], t0);
tcg_gen_ext32s_tl(cpu_HI[VAR_5], t1);
}
VAR_4 = "maddu";
break;
case OPC_MSUB:
{
TCGv_i64 t2 = tcg_temp_new_i64();
TCGv_i64 t3 = tcg_temp_new_i64();
VAR_5 = ((VAR_0->opcode) >> 11) & 0x03;
if (VAR_5 != 0) {
check_dsp(VAR_0);
}
tcg_gen_ext_tl_i64(t2, t0);
tcg_gen_ext_tl_i64(t3, t1);
tcg_gen_mul_i64(t2, t2, t3);
tcg_gen_concat_tl_i64(t3, cpu_LO[VAR_5], cpu_HI[VAR_5]);
tcg_gen_sub_i64(t2, t3, t2);
tcg_temp_free_i64(t3);
tcg_gen_trunc_i64_tl(t0, t2);
tcg_gen_shri_i64(t2, t2, 32);
tcg_gen_trunc_i64_tl(t1, t2);
tcg_temp_free_i64(t2);
tcg_gen_ext32s_tl(cpu_LO[VAR_5], t0);
tcg_gen_ext32s_tl(cpu_HI[VAR_5], t1);
}
VAR_4 = "msub";
break;
case OPC_MSUBU:
{
TCGv_i64 t2 = tcg_temp_new_i64();
TCGv_i64 t3 = tcg_temp_new_i64();
VAR_5 = ((VAR_0->opcode) >> 11) & 0x03;
if (VAR_5 != 0) {
check_dsp(VAR_0);
}
tcg_gen_ext32u_tl(t0, t0);
tcg_gen_ext32u_tl(t1, t1);
tcg_gen_extu_tl_i64(t2, t0);
tcg_gen_extu_tl_i64(t3, t1);
tcg_gen_mul_i64(t2, t2, t3);
tcg_gen_concat_tl_i64(t3, cpu_LO[VAR_5], cpu_HI[VAR_5]);
tcg_gen_sub_i64(t2, t3, t2);
tcg_temp_free_i64(t3);
tcg_gen_trunc_i64_tl(t0, t2);
tcg_gen_shri_i64(t2, t2, 32);
tcg_gen_trunc_i64_tl(t1, t2);
tcg_temp_free_i64(t2);
tcg_gen_ext32s_tl(cpu_LO[VAR_5], t0);
tcg_gen_ext32s_tl(cpu_HI[VAR_5], t1);
}
VAR_4 = "msubu";
break;
default:
MIPS_INVAL(VAR_4);
generate_exception(VAR_0, EXCP_RI);
goto out;
}
(void)VAR_4;
MIPS_DEBUG("%s %s %s", VAR_4, regnames[VAR_2], regnames[VAR_3]);
out:
tcg_temp_free(t0);
tcg_temp_free(t1);
}
| [
"static void FUNC_0 (DisasContext *VAR_0, uint32_t VAR_1,\nint VAR_2, int VAR_3)\n{",
"const char *VAR_4 = \"mul/div\";",
"TCGv t0, t1;",
"unsigned int VAR_5;",
"switch (VAR_1) {",
"case OPC_DIV:\ncase OPC_DIVU:\n#if defined(TARGET_MIPS64)\ncase OPC_DDIV:\ncase OPC_DDIVU:\n#endif\nt0 = tcg_temp_local_new();",
"t1 = tcg_temp_local_new();",
"break;",
"default:\nt0 = tcg_temp_new();",
"t1 = tcg_temp_new();",
"break;",
"}",
"gen_load_gpr(t0, VAR_2);",
"gen_load_gpr(t1, VAR_3);",
"switch (VAR_1) {",
"case OPC_DIV:\n{",
"int VAR_8 = gen_new_label();",
"int VAR_7 = gen_new_label();",
"tcg_gen_ext32s_tl(t0, t0);",
"tcg_gen_ext32s_tl(t1, t1);",
"tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, VAR_8);",
"tcg_gen_brcondi_tl(TCG_COND_NE, t0, INT_MIN, VAR_7);",
"tcg_gen_brcondi_tl(TCG_COND_NE, t1, -1, VAR_7);",
"tcg_gen_mov_tl(cpu_LO[0], t0);",
"tcg_gen_movi_tl(cpu_HI[0], 0);",
"tcg_gen_br(VAR_8);",
"gen_set_label(VAR_7);",
"tcg_gen_div_tl(cpu_LO[0], t0, t1);",
"tcg_gen_rem_tl(cpu_HI[0], t0, t1);",
"tcg_gen_ext32s_tl(cpu_LO[0], cpu_LO[0]);",
"tcg_gen_ext32s_tl(cpu_HI[0], cpu_HI[0]);",
"gen_set_label(VAR_8);",
"}",
"VAR_4 = \"div\";",
"break;",
"case OPC_DIVU:\n{",
"int VAR_8 = gen_new_label();",
"tcg_gen_ext32u_tl(t0, t0);",
"tcg_gen_ext32u_tl(t1, t1);",
"tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, VAR_8);",
"tcg_gen_divu_tl(cpu_LO[0], t0, t1);",
"tcg_gen_remu_tl(cpu_HI[0], t0, t1);",
"tcg_gen_ext32s_tl(cpu_LO[0], cpu_LO[0]);",
"tcg_gen_ext32s_tl(cpu_HI[0], cpu_HI[0]);",
"gen_set_label(VAR_8);",
"}",
"VAR_4 = \"divu\";",
"break;",
"case OPC_MULT:\n{",
"TCGv_i64 t2 = tcg_temp_new_i64();",
"TCGv_i64 t3 = tcg_temp_new_i64();",
"VAR_5 = ((VAR_0->opcode) >> 11) & 0x03;",
"if (VAR_5 != 0) {",
"check_dsp(VAR_0);",
"}",
"tcg_gen_ext_tl_i64(t2, t0);",
"tcg_gen_ext_tl_i64(t3, t1);",
"tcg_gen_mul_i64(t2, t2, t3);",
"tcg_temp_free_i64(t3);",
"tcg_gen_trunc_i64_tl(t0, t2);",
"tcg_gen_shri_i64(t2, t2, 32);",
"tcg_gen_trunc_i64_tl(t1, t2);",
"tcg_temp_free_i64(t2);",
"tcg_gen_ext32s_tl(cpu_LO[VAR_5], t0);",
"tcg_gen_ext32s_tl(cpu_HI[VAR_5], t1);",
"}",
"VAR_4 = \"mult\";",
"break;",
"case OPC_MULTU:\n{",
"TCGv_i64 t2 = tcg_temp_new_i64();",
"TCGv_i64 t3 = tcg_temp_new_i64();",
"VAR_5 = ((VAR_0->opcode) >> 11) & 0x03;",
"if (VAR_5 != 0) {",
"check_dsp(VAR_0);",
"}",
"tcg_gen_ext32u_tl(t0, t0);",
"tcg_gen_ext32u_tl(t1, t1);",
"tcg_gen_extu_tl_i64(t2, t0);",
"tcg_gen_extu_tl_i64(t3, t1);",
"tcg_gen_mul_i64(t2, t2, t3);",
"tcg_temp_free_i64(t3);",
"tcg_gen_trunc_i64_tl(t0, t2);",
"tcg_gen_shri_i64(t2, t2, 32);",
"tcg_gen_trunc_i64_tl(t1, t2);",
"tcg_temp_free_i64(t2);",
"tcg_gen_ext32s_tl(cpu_LO[VAR_5], t0);",
"tcg_gen_ext32s_tl(cpu_HI[VAR_5], t1);",
"}",
"VAR_4 = \"multu\";",
"break;",
"#if defined(TARGET_MIPS64)\ncase OPC_DDIV:\n{",
"int VAR_8 = gen_new_label();",
"int VAR_7 = gen_new_label();",
"tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, VAR_8);",
"tcg_gen_brcondi_tl(TCG_COND_NE, t0, -1LL << 63, VAR_7);",
"tcg_gen_brcondi_tl(TCG_COND_NE, t1, -1LL, VAR_7);",
"tcg_gen_mov_tl(cpu_LO[0], t0);",
"tcg_gen_movi_tl(cpu_HI[0], 0);",
"tcg_gen_br(VAR_8);",
"gen_set_label(VAR_7);",
"tcg_gen_div_i64(cpu_LO[0], t0, t1);",
"tcg_gen_rem_i64(cpu_HI[0], t0, t1);",
"gen_set_label(VAR_8);",
"}",
"VAR_4 = \"ddiv\";",
"break;",
"case OPC_DDIVU:\n{",
"int VAR_8 = gen_new_label();",
"tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, VAR_8);",
"tcg_gen_divu_i64(cpu_LO[0], t0, t1);",
"tcg_gen_remu_i64(cpu_HI[0], t0, t1);",
"gen_set_label(VAR_8);",
"}",
"VAR_4 = \"ddivu\";",
"break;",
"case OPC_DMULT:\ngen_helper_dmult(cpu_env, t0, t1);",
"VAR_4 = \"dmult\";",
"break;",
"case OPC_DMULTU:\ngen_helper_dmultu(cpu_env, t0, t1);",
"VAR_4 = \"dmultu\";",
"break;",
"#endif\ncase OPC_MADD:\n{",
"TCGv_i64 t2 = tcg_temp_new_i64();",
"TCGv_i64 t3 = tcg_temp_new_i64();",
"VAR_5 = ((VAR_0->opcode) >> 11) & 0x03;",
"if (VAR_5 != 0) {",
"check_dsp(VAR_0);",
"}",
"tcg_gen_ext_tl_i64(t2, t0);",
"tcg_gen_ext_tl_i64(t3, t1);",
"tcg_gen_mul_i64(t2, t2, t3);",
"tcg_gen_concat_tl_i64(t3, cpu_LO[VAR_5], cpu_HI[VAR_5]);",
"tcg_gen_add_i64(t2, t2, t3);",
"tcg_temp_free_i64(t3);",
"tcg_gen_trunc_i64_tl(t0, t2);",
"tcg_gen_shri_i64(t2, t2, 32);",
"tcg_gen_trunc_i64_tl(t1, t2);",
"tcg_temp_free_i64(t2);",
"tcg_gen_ext32s_tl(cpu_LO[VAR_5], t0);",
"tcg_gen_ext32s_tl(cpu_HI[VAR_5], t1);",
"}",
"VAR_4 = \"madd\";",
"break;",
"case OPC_MADDU:\n{",
"TCGv_i64 t2 = tcg_temp_new_i64();",
"TCGv_i64 t3 = tcg_temp_new_i64();",
"VAR_5 = ((VAR_0->opcode) >> 11) & 0x03;",
"if (VAR_5 != 0) {",
"check_dsp(VAR_0);",
"}",
"tcg_gen_ext32u_tl(t0, t0);",
"tcg_gen_ext32u_tl(t1, t1);",
"tcg_gen_extu_tl_i64(t2, t0);",
"tcg_gen_extu_tl_i64(t3, t1);",
"tcg_gen_mul_i64(t2, t2, t3);",
"tcg_gen_concat_tl_i64(t3, cpu_LO[VAR_5], cpu_HI[VAR_5]);",
"tcg_gen_add_i64(t2, t2, t3);",
"tcg_temp_free_i64(t3);",
"tcg_gen_trunc_i64_tl(t0, t2);",
"tcg_gen_shri_i64(t2, t2, 32);",
"tcg_gen_trunc_i64_tl(t1, t2);",
"tcg_temp_free_i64(t2);",
"tcg_gen_ext32s_tl(cpu_LO[VAR_5], t0);",
"tcg_gen_ext32s_tl(cpu_HI[VAR_5], t1);",
"}",
"VAR_4 = \"maddu\";",
"break;",
"case OPC_MSUB:\n{",
"TCGv_i64 t2 = tcg_temp_new_i64();",
"TCGv_i64 t3 = tcg_temp_new_i64();",
"VAR_5 = ((VAR_0->opcode) >> 11) & 0x03;",
"if (VAR_5 != 0) {",
"check_dsp(VAR_0);",
"}",
"tcg_gen_ext_tl_i64(t2, t0);",
"tcg_gen_ext_tl_i64(t3, t1);",
"tcg_gen_mul_i64(t2, t2, t3);",
"tcg_gen_concat_tl_i64(t3, cpu_LO[VAR_5], cpu_HI[VAR_5]);",
"tcg_gen_sub_i64(t2, t3, t2);",
"tcg_temp_free_i64(t3);",
"tcg_gen_trunc_i64_tl(t0, t2);",
"tcg_gen_shri_i64(t2, t2, 32);",
"tcg_gen_trunc_i64_tl(t1, t2);",
"tcg_temp_free_i64(t2);",
"tcg_gen_ext32s_tl(cpu_LO[VAR_5], t0);",
"tcg_gen_ext32s_tl(cpu_HI[VAR_5], t1);",
"}",
"VAR_4 = \"msub\";",
"break;",
"case OPC_MSUBU:\n{",
"TCGv_i64 t2 = tcg_temp_new_i64();",
"TCGv_i64 t3 = tcg_temp_new_i64();",
"VAR_5 = ((VAR_0->opcode) >> 11) & 0x03;",
"if (VAR_5 != 0) {",
"check_dsp(VAR_0);",
"}",
"tcg_gen_ext32u_tl(t0, t0);",
"tcg_gen_ext32u_tl(t1, t1);",
"tcg_gen_extu_tl_i64(t2, t0);",
"tcg_gen_extu_tl_i64(t3, t1);",
"tcg_gen_mul_i64(t2, t2, t3);",
"tcg_gen_concat_tl_i64(t3, cpu_LO[VAR_5], cpu_HI[VAR_5]);",
"tcg_gen_sub_i64(t2, t3, t2);",
"tcg_temp_free_i64(t3);",
"tcg_gen_trunc_i64_tl(t0, t2);",
"tcg_gen_shri_i64(t2, t2, 32);",
"tcg_gen_trunc_i64_tl(t1, t2);",
"tcg_temp_free_i64(t2);",
"tcg_gen_ext32s_tl(cpu_LO[VAR_5], t0);",
"tcg_gen_ext32s_tl(cpu_HI[VAR_5], t1);",
"}",
"VAR_4 = \"msubu\";",
"break;",
"default:\nMIPS_INVAL(VAR_4);",
"generate_exception(VAR_0, EXCP_RI);",
"goto out;",
"}",
"(void)VAR_4;",
"MIPS_DEBUG(\"%s %s %s\", VAR_4, regnames[VAR_2], regnames[VAR_3]);",
"out:\ntcg_temp_free(t0);",
"tcg_temp_free(t1);",
"}"
] | [
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99,
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129,
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173,
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221,
223,
225
],
[
227
],
[
229
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259,
261
],
[
263
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281,
283
],
[
285
],
[
287
],
[
289,
291
],
[
293
],
[
295
],
[
297,
299,
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347,
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399,
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411
],
[
413
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447,
449
],
[
451
],
[
453
],
[
455
],
[
457
],
[
459
],
[
461
],
[
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
]
] |
26,866 | static void usb_msd_copy_data(MSDState *s)
{
uint32_t len;
len = s->usb_len;
if (len > s->scsi_len)
len = s->scsi_len;
if (s->mode == USB_MSDM_DATAIN) {
memcpy(s->usb_buf, s->scsi_buf, len);
} else {
memcpy(s->scsi_buf, s->usb_buf, len);
}
s->usb_len -= len;
s->scsi_len -= len;
s->usb_buf += len;
s->scsi_buf += len;
s->data_len -= len;
if (s->scsi_len == 0 || s->data_len == 0) {
if (s->mode == USB_MSDM_DATAIN) {
s->scsi_dev->info->read_data(s->scsi_dev, s->tag);
} else if (s->mode == USB_MSDM_DATAOUT) {
s->scsi_dev->info->write_data(s->scsi_dev, s->tag);
}
}
}
| true | qemu | 5c6c0e513600ba57c3e73b7151d3c0664438f7b5 | static void usb_msd_copy_data(MSDState *s)
{
uint32_t len;
len = s->usb_len;
if (len > s->scsi_len)
len = s->scsi_len;
if (s->mode == USB_MSDM_DATAIN) {
memcpy(s->usb_buf, s->scsi_buf, len);
} else {
memcpy(s->scsi_buf, s->usb_buf, len);
}
s->usb_len -= len;
s->scsi_len -= len;
s->usb_buf += len;
s->scsi_buf += len;
s->data_len -= len;
if (s->scsi_len == 0 || s->data_len == 0) {
if (s->mode == USB_MSDM_DATAIN) {
s->scsi_dev->info->read_data(s->scsi_dev, s->tag);
} else if (s->mode == USB_MSDM_DATAOUT) {
s->scsi_dev->info->write_data(s->scsi_dev, s->tag);
}
}
}
| {
"code": [
" s->scsi_dev->info->read_data(s->scsi_dev, s->tag);",
" s->scsi_dev->info->write_data(s->scsi_dev, s->tag);"
],
"line_no": [
37,
41
]
} | static void FUNC_0(MSDState *VAR_0)
{
uint32_t len;
len = VAR_0->usb_len;
if (len > VAR_0->scsi_len)
len = VAR_0->scsi_len;
if (VAR_0->mode == USB_MSDM_DATAIN) {
memcpy(VAR_0->usb_buf, VAR_0->scsi_buf, len);
} else {
memcpy(VAR_0->scsi_buf, VAR_0->usb_buf, len);
}
VAR_0->usb_len -= len;
VAR_0->scsi_len -= len;
VAR_0->usb_buf += len;
VAR_0->scsi_buf += len;
VAR_0->data_len -= len;
if (VAR_0->scsi_len == 0 || VAR_0->data_len == 0) {
if (VAR_0->mode == USB_MSDM_DATAIN) {
VAR_0->scsi_dev->info->read_data(VAR_0->scsi_dev, VAR_0->tag);
} else if (VAR_0->mode == USB_MSDM_DATAOUT) {
VAR_0->scsi_dev->info->write_data(VAR_0->scsi_dev, VAR_0->tag);
}
}
}
| [
"static void FUNC_0(MSDState *VAR_0)\n{",
"uint32_t len;",
"len = VAR_0->usb_len;",
"if (len > VAR_0->scsi_len)\nlen = VAR_0->scsi_len;",
"if (VAR_0->mode == USB_MSDM_DATAIN) {",
"memcpy(VAR_0->usb_buf, VAR_0->scsi_buf, len);",
"} else {",
"memcpy(VAR_0->scsi_buf, VAR_0->usb_buf, len);",
"}",
"VAR_0->usb_len -= len;",
"VAR_0->scsi_len -= len;",
"VAR_0->usb_buf += len;",
"VAR_0->scsi_buf += len;",
"VAR_0->data_len -= len;",
"if (VAR_0->scsi_len == 0 || VAR_0->data_len == 0) {",
"if (VAR_0->mode == USB_MSDM_DATAIN) {",
"VAR_0->scsi_dev->info->read_data(VAR_0->scsi_dev, VAR_0->tag);",
"} else if (VAR_0->mode == USB_MSDM_DATAOUT) {",
"VAR_0->scsi_dev->info->write_data(VAR_0->scsi_dev, VAR_0->tag);",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
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
]
] |
26,867 | void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl,
char *line, int line_size, int *print_prefix)
{
char part[3][512];
format_line(ptr, level, fmt, vl, part, sizeof(part[0]), print_prefix, NULL);
snprintf(line, line_size, "%s%s%s", part[0], part[1], part[2]);
}
| true | FFmpeg | 258dfff8394d383beaa639d19912b3f068f67e16 | void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl,
char *line, int line_size, int *print_prefix)
{
char part[3][512];
format_line(ptr, level, fmt, vl, part, sizeof(part[0]), print_prefix, NULL);
snprintf(line, line_size, "%s%s%s", part[0], part[1], part[2]);
}
| {
"code": [
" char part[3][512];",
" char part[3][512];"
],
"line_no": [
7,
7
]
} | void FUNC_0(void *VAR_0, int VAR_1, const char *VAR_2, va_list VAR_3,
char *VAR_4, int VAR_5, int *VAR_6)
{
char VAR_7[3][512];
format_line(VAR_0, VAR_1, VAR_2, VAR_3, VAR_7, sizeof(VAR_7[0]), VAR_6, NULL);
snprintf(VAR_4, VAR_5, "%s%s%s", VAR_7[0], VAR_7[1], VAR_7[2]);
}
| [
"void FUNC_0(void *VAR_0, int VAR_1, const char *VAR_2, va_list VAR_3,\nchar *VAR_4, int VAR_5, int *VAR_6)\n{",
"char VAR_7[3][512];",
"format_line(VAR_0, VAR_1, VAR_2, VAR_3, VAR_7, sizeof(VAR_7[0]), VAR_6, NULL);",
"snprintf(VAR_4, VAR_5, \"%s%s%s\", VAR_7[0], VAR_7[1], VAR_7[2]);",
"}"
] | [
0,
1,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
26,868 | static inline void RENAME(rgb32tobgr15)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint8_t *s = src;
const uint8_t *end;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_15mask),"m"(green_15mask));
mm_end = end - 15;
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 4%1, %%mm3\n\t"
"punpckldq 8%1, %%mm0\n\t"
"punpckldq 12%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psllq $7, %%mm0\n\t"
"psllq $7, %%mm3\n\t"
"pand %%mm7, %%mm0\n\t"
"pand %%mm7, %%mm3\n\t"
"psrlq $6, %%mm1\n\t"
"psrlq $6, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $19, %%mm2\n\t"
"psrlq $19, %%mm5\n\t"
"pand %2, %%mm2\n\t"
"pand %2, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*s),"m"(blue_15mask):"memory");
d += 4;
s += 16;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
register int rgb = *(uint32_t*)s; s += 4;
*d++ = ((rgb&0xF8)<<7) + ((rgb&0xF800)>>6) + ((rgb&0xF80000)>>19);
}
}
| true | FFmpeg | 6e42e6c4b410dbef8b593c2d796a5dad95f89ee4 | static inline void RENAME(rgb32tobgr15)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint8_t *s = src;
const uint8_t *end;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_15mask),"m"(green_15mask));
mm_end = end - 15;
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 4%1, %%mm3\n\t"
"punpckldq 8%1, %%mm0\n\t"
"punpckldq 12%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psllq $7, %%mm0\n\t"
"psllq $7, %%mm3\n\t"
"pand %%mm7, %%mm0\n\t"
"pand %%mm7, %%mm3\n\t"
"psrlq $6, %%mm1\n\t"
"psrlq $6, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $19, %%mm2\n\t"
"psrlq $19, %%mm5\n\t"
"pand %2, %%mm2\n\t"
"pand %2, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*s),"m"(blue_15mask):"memory");
d += 4;
s += 16;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
register int rgb = *(uint32_t*)s; s += 4;
*d++ = ((rgb&0xF8)<<7) + ((rgb&0xF800)>>6) + ((rgb&0xF80000)>>19);
}
}
| {
"code": [
"\twhile(s < end)",
"\twhile(s < end)",
"\twhile(s < end)",
"\twhile(s < end)",
"#ifdef HAVE_MMX",
"#endif",
"#ifdef HAVE_MMX",
"#endif",
"#endif",
"#endif",
"\t__asm __volatile(",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm0\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\tconst uint8_t *s = src;",
"\tconst uint8_t *end;",
"\tconst uint8_t *mm_end;",
"\tuint16_t *d = (uint16_t *)dst;",
"\tend = s + src_size;",
"\tmm_end = end - 15;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"\t__asm __volatile(",
"\t \"movq\t%0, %%mm7\\n\\t\"",
"\t \"movq\t%1, %%mm6\\n\\t\"",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movd\t%1, %%mm0\\n\\t\"",
"\t\t\"movd\t4%1, %%mm3\\n\\t\"",
"\t\t\"punpckldq 8%1, %%mm0\\n\\t\"",
"\t\t\"punpckldq 12%1, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"psllq\t$16, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\td += 4;",
"\t\ts += 16;",
"#endif",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\t\tregister int rgb = *(uint32_t*)s; s += 4;",
"\tconst uint8_t *s = src;",
"\tconst uint8_t *end;",
"\tconst uint8_t *mm_end;",
"\tuint16_t *d = (uint16_t *)dst;",
"\tend = s + src_size;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"\t__asm __volatile(",
"\t \"movq\t%0, %%mm7\\n\\t\"",
"\t \"movq\t%1, %%mm6\\n\\t\"",
"\tmm_end = end - 15;",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movd\t%1, %%mm0\\n\\t\"",
"\t\t\"movd\t4%1, %%mm3\\n\\t\"",
"\t\t\"punpckldq 8%1, %%mm0\\n\\t\"",
"\t\t\"punpckldq 12%1, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm0\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm3\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"psrlq\t$19, %%mm2\\n\\t\"",
"\t\t\"psrlq\t$19, %%mm5\\n\\t\"",
"\t\t\"pand\t%2, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"psllq\t$16, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\td += 4;",
"\t\ts += 16;",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\t\tregister int rgb = *(uint32_t*)s; s += 4;",
"\tconst uint8_t *s = src;",
"\tconst uint8_t *end;",
"\tconst uint8_t *mm_end;",
"\tuint16_t *d = (uint16_t *)dst;",
"\tend = s + src_size;",
"\tmm_end = end - 15;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"\t__asm __volatile(",
"\t \"movq\t%0, %%mm7\\n\\t\"",
"\t \"movq\t%1, %%mm6\\n\\t\"",
"\t ::\"m\"(red_15mask),\"m\"(green_15mask));",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movd\t%1, %%mm0\\n\\t\"",
"\t\t\"movd\t4%1, %%mm3\\n\\t\"",
"\t\t\"punpckldq 8%1, %%mm0\\n\\t\"",
"\t\t\"punpckldq 12%1, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"psrlq\t$6, %%mm1\\n\\t\"",
"\t\t\"psrlq\t$6, %%mm4\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"psllq\t$16, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\t:\"=m\"(*d):\"m\"(*s),\"m\"(blue_15mask):\"memory\");",
"\t\td += 4;",
"\t\ts += 16;",
"#endif",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\t\tregister int rgb = *(uint32_t*)s; s += 4;",
"\tconst uint8_t *s = src;",
"\tconst uint8_t *end;",
"\tconst uint8_t *mm_end;",
"\tuint16_t *d = (uint16_t *)dst;",
"\tend = s + src_size;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"\t__asm __volatile(",
"\t \"movq\t%0, %%mm7\\n\\t\"",
"\t \"movq\t%1, %%mm6\\n\\t\"",
"\t ::\"m\"(red_15mask),\"m\"(green_15mask));",
"\tmm_end = end - 15;",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movd\t%1, %%mm0\\n\\t\"",
"\t\t\"movd\t4%1, %%mm3\\n\\t\"",
"\t\t\"punpckldq 8%1, %%mm0\\n\\t\"",
"\t\t\"punpckldq 12%1, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"psllq\t$7, %%mm0\\n\\t\"",
"\t\t\"psllq\t$7, %%mm3\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm0\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm3\\n\\t\"",
"\t\t\"psrlq\t$6, %%mm1\\n\\t\"",
"\t\t\"psrlq\t$6, %%mm4\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"psrlq\t$19, %%mm2\\n\\t\"",
"\t\t\"psrlq\t$19, %%mm5\\n\\t\"",
"\t\t\"pand\t%2, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"psllq\t$16, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\t:\"=m\"(*d):\"m\"(*s),\"m\"(blue_15mask):\"memory\");",
"\t\td += 4;",
"\t\ts += 16;",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\t\tregister int rgb = *(uint32_t*)s; s += 4;",
"\t\t*d++ = ((rgb&0xF8)<<7) + ((rgb&0xF800)>>6) + ((rgb&0xF80000)>>19);",
"\tconst uint8_t *s = src;",
"\tconst uint8_t *end;",
"\tconst uint8_t *mm_end;",
"\tuint16_t *d = (uint16_t *)dst;",
"\tend = s + src_size;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"\t__asm __volatile(",
"\t \"movq\t%0, %%mm7\\n\\t\"",
"\t \"movq\t%1, %%mm6\\n\\t\"",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movd\t%1, %%mm0\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"psllq\t$16, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\td += 4;",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\tconst uint8_t *s = src;",
"\tconst uint8_t *end;",
"\tconst uint8_t *mm_end;",
"\tuint16_t *d = (uint16_t *)dst;",
"\tend = s + src_size;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"\t__asm __volatile(",
"\t \"movq\t%0, %%mm7\\n\\t\"",
"\t \"movq\t%1, %%mm6\\n\\t\"",
"\tmm_end = end - 15;",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movd\t%1, %%mm0\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm0\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm3\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"psrlq\t$19, %%mm2\\n\\t\"",
"\t\t\"psrlq\t$19, %%mm5\\n\\t\"",
"\t\t\"pand\t%2, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"psllq\t$16, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\td += 4;",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\tconst uint8_t *s = src;",
"\tconst uint8_t *end;",
"\tconst uint8_t *mm_end;",
"\tuint16_t *d = (uint16_t *)dst;",
"\tend = s + src_size;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"\t__asm __volatile(",
"\t \"movq\t%0, %%mm7\\n\\t\"",
"\t \"movq\t%1, %%mm6\\n\\t\"",
"\t ::\"m\"(red_15mask),\"m\"(green_15mask));",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movd\t%1, %%mm0\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"psrlq\t$6, %%mm1\\n\\t\"",
"\t\t\"psrlq\t$6, %%mm4\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"psllq\t$16, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\t:\"=m\"(*d):\"m\"(*s),\"m\"(blue_15mask):\"memory\");",
"\t\td += 4;",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\tconst uint8_t *s = src;",
"\tconst uint8_t *end;",
"\tconst uint8_t *mm_end;",
"\tuint16_t *d = (uint16_t *)dst;",
"\tend = s + src_size;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"\t__asm __volatile(",
"\t \"movq\t%0, %%mm7\\n\\t\"",
"\t \"movq\t%1, %%mm6\\n\\t\"",
"\t ::\"m\"(red_15mask),\"m\"(green_15mask));",
"\tmm_end = end - 15;",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movd\t%1, %%mm0\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"psllq\t$7, %%mm0\\n\\t\"",
"\t\t\"psllq\t$7, %%mm3\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm0\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm3\\n\\t\"",
"\t\t\"psrlq\t$6, %%mm1\\n\\t\"",
"\t\t\"psrlq\t$6, %%mm4\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"psrlq\t$19, %%mm2\\n\\t\"",
"\t\t\"psrlq\t$19, %%mm5\\n\\t\"",
"\t\t\"pand\t%2, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"psllq\t$16, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\t:\"=m\"(*d):\"m\"(*s),\"m\"(blue_15mask):\"memory\");",
"\t\td += 4;",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t __asm __volatile(",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t __asm __volatile(",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\t__asm __volatile(",
"#endif",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"#endif",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"#endif",
"#endif"
],
"line_no": [
109,
109,
109,
109,
9,
13,
9,
13,
13,
13,
23,
49,
93,
23,
49,
61,
69,
81,
93,
5,
7,
11,
15,
17,
31,
21,
23,
25,
27,
33,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
69,
71,
81,
83,
85,
87,
89,
91,
93,
97,
99,
13,
103,
105,
13,
109,
113,
5,
7,
11,
15,
17,
21,
23,
25,
27,
31,
33,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
61,
63,
69,
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91,
93,
97,
99,
103,
105,
13,
109,
113,
5,
7,
11,
15,
17,
31,
21,
23,
25,
27,
29,
33,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
65,
67,
69,
71,
81,
83,
85,
87,
89,
91,
93,
95,
97,
99,
13,
103,
105,
13,
109,
113,
5,
7,
11,
15,
17,
21,
23,
25,
27,
29,
31,
33,
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,
103,
105,
13,
109,
113,
115,
5,
7,
11,
15,
17,
21,
23,
25,
27,
33,
37,
39,
41,
49,
51,
53,
55,
69,
71,
81,
83,
85,
87,
89,
91,
93,
97,
103,
105,
13,
109,
5,
7,
11,
15,
17,
21,
23,
25,
27,
31,
33,
37,
39,
41,
49,
51,
53,
55,
61,
63,
69,
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91,
93,
97,
103,
105,
13,
109,
5,
7,
11,
15,
17,
21,
23,
25,
27,
29,
33,
37,
39,
41,
49,
51,
53,
55,
65,
67,
69,
71,
81,
83,
85,
87,
89,
91,
93,
95,
97,
103,
105,
13,
109,
5,
7,
11,
15,
17,
21,
23,
25,
27,
29,
31,
33,
37,
39,
41,
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,
103,
105,
13,
109,
33,
37,
39,
81,
85,
83,
87,
81,
85,
83,
87,
37,
55,
51,
79,
85,
85,
93,
103,
105,
13,
109,
33,
37,
39,
81,
85,
83,
87,
81,
85,
83,
87,
37,
55,
51,
79,
85,
85,
93,
103,
105,
13,
109,
33,
37,
39,
81,
85,
83,
87,
93,
103,
105,
13,
109,
33,
37,
39,
81,
85,
83,
87,
93,
103,
105,
13,
109,
23,
13,
103,
105,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
39,
93,
13,
39,
93,
13,
13
]
} | static inline void FUNC_0(rgb32tobgr15)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint8_t *VAR_0 = src;
const uint8_t *VAR_1;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
VAR_1 = VAR_0 + src_size;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_15mask),"m"(green_15mask));
mm_end = VAR_1 - 15;
while(VAR_0 < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 4%1, %%mm3\n\t"
"punpckldq 8%1, %%mm0\n\t"
"punpckldq 12%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psllq $7, %%mm0\n\t"
"psllq $7, %%mm3\n\t"
"pand %%mm7, %%mm0\n\t"
"pand %%mm7, %%mm3\n\t"
"psrlq $6, %%mm1\n\t"
"psrlq $6, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $19, %%mm2\n\t"
"psrlq $19, %%mm5\n\t"
"pand %2, %%mm2\n\t"
"pand %2, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*VAR_0),"m"(blue_15mask):"memory");
d += 4;
VAR_0 += 16;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(VAR_0 < VAR_1)
{
register int VAR_2 = *(uint32_t*)VAR_0; VAR_0 += 4;
*d++ = ((VAR_2&0xF8)<<7) + ((VAR_2&0xF800)>>6) + ((VAR_2&0xF80000)>>19);
}
}
| [
"static inline void FUNC_0(rgb32tobgr15)(const uint8_t *src, uint8_t *dst, long src_size)\n{",
"const uint8_t *VAR_0 = src;",
"const uint8_t *VAR_1;",
"#ifdef HAVE_MMX\nconst uint8_t *mm_end;",
"#endif\nuint16_t *d = (uint16_t *)dst;",
"VAR_1 = VAR_0 + src_size;",
"#ifdef HAVE_MMX\n__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"__asm __volatile(\n\"movq\t%0, %%mm7\\n\\t\"\n\"movq\t%1, %%mm6\\n\\t\"\n::\"m\"(red_15mask),\"m\"(green_15mask));",
"mm_end = VAR_1 - 15;",
"while(VAR_0 < mm_end)\n{",
"__asm __volatile(\nPREFETCH\" 32%1\\n\\t\"\n\"movd\t%1, %%mm0\\n\\t\"\n\"movd\t4%1, %%mm3\\n\\t\"\n\"punpckldq 8%1, %%mm0\\n\\t\"\n\"punpckldq 12%1, %%mm3\\n\\t\"\n\"movq\t%%mm0, %%mm1\\n\\t\"\n\"movq\t%%mm0, %%mm2\\n\\t\"\n\"movq\t%%mm3, %%mm4\\n\\t\"\n\"movq\t%%mm3, %%mm5\\n\\t\"\n\"psllq\t$7, %%mm0\\n\\t\"\n\"psllq\t$7, %%mm3\\n\\t\"\n\"pand\t%%mm7, %%mm0\\n\\t\"\n\"pand\t%%mm7, %%mm3\\n\\t\"\n\"psrlq\t$6, %%mm1\\n\\t\"\n\"psrlq\t$6, %%mm4\\n\\t\"\n\"pand\t%%mm6, %%mm1\\n\\t\"\n\"pand\t%%mm6, %%mm4\\n\\t\"\n\"psrlq\t$19, %%mm2\\n\\t\"\n\"psrlq\t$19, %%mm5\\n\\t\"\n\"pand\t%2, %%mm2\\n\\t\"\n\"pand\t%2, %%mm5\\n\\t\"\n\"por\t%%mm1, %%mm0\\n\\t\"\n\"por\t%%mm4, %%mm3\\n\\t\"\n\"por\t%%mm2, %%mm0\\n\\t\"\n\"por\t%%mm5, %%mm3\\n\\t\"\n\"psllq\t$16, %%mm3\\n\\t\"\n\"por\t%%mm3, %%mm0\\n\\t\"\nMOVNTQ\"\t%%mm0, %0\\n\\t\"\n:\"=m\"(*d):\"m\"(*VAR_0),\"m\"(blue_15mask):\"memory\");",
"d += 4;",
"VAR_0 += 16;",
"}",
"__asm __volatile(SFENCE:::\"memory\");",
"__asm __volatile(EMMS:::\"memory\");",
"#endif\nwhile(VAR_0 < VAR_1)\n{",
"register int VAR_2 = *(uint32_t*)VAR_0; VAR_0 += 4;",
"*d++ = ((VAR_2&0xF8)<<7) + ((VAR_2&0xF800)>>6) + ((VAR_2&0xF80000)>>19);",
"}",
"}"
] | [
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
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,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91,
93,
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107,
109,
111
],
[
113
],
[
115
],
[
117
],
[
119
]
] |
26,869 | static int http_receive_data(HTTPContext *c)
{
HTTPContext *c1;
if (c->buffer_end > c->buffer_ptr) {
int len;
len = recv(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr, 0);
if (len < 0) {
if (ff_neterrno() != FF_NETERROR(EAGAIN) &&
ff_neterrno() != FF_NETERROR(EINTR))
/* error : close connection */
goto fail;
} else if (len == 0)
/* end of connection : close it */
goto fail;
else {
c->buffer_ptr += len;
c->data_count += len;
update_datarate(&c->datarate, c->data_count);
}
}
if (c->buffer_ptr - c->buffer >= 2 && c->data_count > FFM_PACKET_SIZE) {
if (c->buffer[0] != 'f' ||
c->buffer[1] != 'm') {
http_log("Feed stream has become desynchronized -- disconnecting\n");
goto fail;
}
}
if (c->buffer_ptr >= c->buffer_end) {
FFStream *feed = c->stream;
/* a packet has been received : write it in the store, except
if header */
if (c->data_count > FFM_PACKET_SIZE) {
// printf("writing pos=0x%"PRIx64" size=0x%"PRIx64"\n", feed->feed_write_index, feed->feed_size);
/* XXX: use llseek or url_seek */
lseek(c->feed_fd, feed->feed_write_index, SEEK_SET);
if (write(c->feed_fd, c->buffer, FFM_PACKET_SIZE) < 0) {
http_log("Error writing to feed file: %s\n", strerror(errno));
goto fail;
}
feed->feed_write_index += FFM_PACKET_SIZE;
/* update file size */
if (feed->feed_write_index > c->stream->feed_size)
feed->feed_size = feed->feed_write_index;
/* handle wrap around if max file size reached */
if (c->stream->feed_max_size && feed->feed_write_index >= c->stream->feed_max_size)
feed->feed_write_index = FFM_PACKET_SIZE;
/* write index */
ffm_write_write_index(c->feed_fd, feed->feed_write_index);
/* wake up any waiting connections */
for(c1 = first_http_ctx; c1 != NULL; c1 = c1->next) {
if (c1->state == HTTPSTATE_WAIT_FEED &&
c1->stream->feed == c->stream->feed)
c1->state = HTTPSTATE_SEND_DATA;
}
} else {
/* We have a header in our hands that contains useful data */
AVFormatContext *s = NULL;
ByteIOContext *pb;
AVInputFormat *fmt_in;
int i;
url_open_buf(&pb, c->buffer, c->buffer_end - c->buffer, URL_RDONLY);
pb->is_streamed = 1;
/* use feed output format name to find corresponding input format */
fmt_in = av_find_input_format(feed->fmt->name);
if (!fmt_in)
goto fail;
av_open_input_stream(&s, pb, c->stream->feed_filename, fmt_in, NULL);
/* Now we have the actual streams */
if (s->nb_streams != feed->nb_streams) {
av_close_input_stream(s);
av_free(pb);
goto fail;
}
for (i = 0; i < s->nb_streams; i++)
memcpy(feed->streams[i]->codec,
s->streams[i]->codec, sizeof(AVCodecContext));
av_close_input_stream(s);
av_free(pb);
}
c->buffer_ptr = c->buffer;
}
return 0;
fail:
c->stream->feed_opened = 0;
close(c->feed_fd);
/* wake up any waiting connections to stop waiting for feed */
for(c1 = first_http_ctx; c1 != NULL; c1 = c1->next) {
if (c1->state == HTTPSTATE_WAIT_FEED &&
c1->stream->feed == c->stream->feed)
c1->state = HTTPSTATE_SEND_DATA_TRAILER;
}
return -1;
}
| false | FFmpeg | e6f0deab806f518f55ee54b970f70de1948bbf5d | static int http_receive_data(HTTPContext *c)
{
HTTPContext *c1;
if (c->buffer_end > c->buffer_ptr) {
int len;
len = recv(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr, 0);
if (len < 0) {
if (ff_neterrno() != FF_NETERROR(EAGAIN) &&
ff_neterrno() != FF_NETERROR(EINTR))
goto fail;
} else if (len == 0)
goto fail;
else {
c->buffer_ptr += len;
c->data_count += len;
update_datarate(&c->datarate, c->data_count);
}
}
if (c->buffer_ptr - c->buffer >= 2 && c->data_count > FFM_PACKET_SIZE) {
if (c->buffer[0] != 'f' ||
c->buffer[1] != 'm') {
http_log("Feed stream has become desynchronized -- disconnecting\n");
goto fail;
}
}
if (c->buffer_ptr >= c->buffer_end) {
FFStream *feed = c->stream;
if (c->data_count > FFM_PACKET_SIZE) {
lseek(c->feed_fd, feed->feed_write_index, SEEK_SET);
if (write(c->feed_fd, c->buffer, FFM_PACKET_SIZE) < 0) {
http_log("Error writing to feed file: %s\n", strerror(errno));
goto fail;
}
feed->feed_write_index += FFM_PACKET_SIZE;
if (feed->feed_write_index > c->stream->feed_size)
feed->feed_size = feed->feed_write_index;
if (c->stream->feed_max_size && feed->feed_write_index >= c->stream->feed_max_size)
feed->feed_write_index = FFM_PACKET_SIZE;
ffm_write_write_index(c->feed_fd, feed->feed_write_index);
for(c1 = first_http_ctx; c1 != NULL; c1 = c1->next) {
if (c1->state == HTTPSTATE_WAIT_FEED &&
c1->stream->feed == c->stream->feed)
c1->state = HTTPSTATE_SEND_DATA;
}
} else {
AVFormatContext *s = NULL;
ByteIOContext *pb;
AVInputFormat *fmt_in;
int i;
url_open_buf(&pb, c->buffer, c->buffer_end - c->buffer, URL_RDONLY);
pb->is_streamed = 1;
fmt_in = av_find_input_format(feed->fmt->name);
if (!fmt_in)
goto fail;
av_open_input_stream(&s, pb, c->stream->feed_filename, fmt_in, NULL);
if (s->nb_streams != feed->nb_streams) {
av_close_input_stream(s);
av_free(pb);
goto fail;
}
for (i = 0; i < s->nb_streams; i++)
memcpy(feed->streams[i]->codec,
s->streams[i]->codec, sizeof(AVCodecContext));
av_close_input_stream(s);
av_free(pb);
}
c->buffer_ptr = c->buffer;
}
return 0;
fail:
c->stream->feed_opened = 0;
close(c->feed_fd);
for(c1 = first_http_ctx; c1 != NULL; c1 = c1->next) {
if (c1->state == HTTPSTATE_WAIT_FEED &&
c1->stream->feed == c->stream->feed)
c1->state = HTTPSTATE_SEND_DATA_TRAILER;
}
return -1;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(HTTPContext *VAR_0)
{
HTTPContext *c1;
if (VAR_0->buffer_end > VAR_0->buffer_ptr) {
int VAR_1;
VAR_1 = recv(VAR_0->fd, VAR_0->buffer_ptr, VAR_0->buffer_end - VAR_0->buffer_ptr, 0);
if (VAR_1 < 0) {
if (ff_neterrno() != FF_NETERROR(EAGAIN) &&
ff_neterrno() != FF_NETERROR(EINTR))
goto fail;
} else if (VAR_1 == 0)
goto fail;
else {
VAR_0->buffer_ptr += VAR_1;
VAR_0->data_count += VAR_1;
update_datarate(&VAR_0->datarate, VAR_0->data_count);
}
}
if (VAR_0->buffer_ptr - VAR_0->buffer >= 2 && VAR_0->data_count > FFM_PACKET_SIZE) {
if (VAR_0->buffer[0] != 'f' ||
VAR_0->buffer[1] != 'm') {
http_log("Feed stream has become desynchronized -- disconnecting\n");
goto fail;
}
}
if (VAR_0->buffer_ptr >= VAR_0->buffer_end) {
FFStream *feed = VAR_0->stream;
if (VAR_0->data_count > FFM_PACKET_SIZE) {
lseek(VAR_0->feed_fd, feed->feed_write_index, SEEK_SET);
if (write(VAR_0->feed_fd, VAR_0->buffer, FFM_PACKET_SIZE) < 0) {
http_log("Error writing to feed file: %s\n", strerror(errno));
goto fail;
}
feed->feed_write_index += FFM_PACKET_SIZE;
if (feed->feed_write_index > VAR_0->stream->feed_size)
feed->feed_size = feed->feed_write_index;
if (VAR_0->stream->feed_max_size && feed->feed_write_index >= VAR_0->stream->feed_max_size)
feed->feed_write_index = FFM_PACKET_SIZE;
ffm_write_write_index(VAR_0->feed_fd, feed->feed_write_index);
for(c1 = first_http_ctx; c1 != NULL; c1 = c1->next) {
if (c1->state == HTTPSTATE_WAIT_FEED &&
c1->stream->feed == VAR_0->stream->feed)
c1->state = HTTPSTATE_SEND_DATA;
}
} else {
AVFormatContext *s = NULL;
ByteIOContext *pb;
AVInputFormat *fmt_in;
int VAR_2;
url_open_buf(&pb, VAR_0->buffer, VAR_0->buffer_end - VAR_0->buffer, URL_RDONLY);
pb->is_streamed = 1;
fmt_in = av_find_input_format(feed->fmt->name);
if (!fmt_in)
goto fail;
av_open_input_stream(&s, pb, VAR_0->stream->feed_filename, fmt_in, NULL);
if (s->nb_streams != feed->nb_streams) {
av_close_input_stream(s);
av_free(pb);
goto fail;
}
for (VAR_2 = 0; VAR_2 < s->nb_streams; VAR_2++)
memcpy(feed->streams[VAR_2]->codec,
s->streams[VAR_2]->codec, sizeof(AVCodecContext));
av_close_input_stream(s);
av_free(pb);
}
VAR_0->buffer_ptr = VAR_0->buffer;
}
return 0;
fail:
VAR_0->stream->feed_opened = 0;
close(VAR_0->feed_fd);
for(c1 = first_http_ctx; c1 != NULL; c1 = c1->next) {
if (c1->state == HTTPSTATE_WAIT_FEED &&
c1->stream->feed == VAR_0->stream->feed)
c1->state = HTTPSTATE_SEND_DATA_TRAILER;
}
return -1;
}
| [
"static int FUNC_0(HTTPContext *VAR_0)\n{",
"HTTPContext *c1;",
"if (VAR_0->buffer_end > VAR_0->buffer_ptr) {",
"int VAR_1;",
"VAR_1 = recv(VAR_0->fd, VAR_0->buffer_ptr, VAR_0->buffer_end - VAR_0->buffer_ptr, 0);",
"if (VAR_1 < 0) {",
"if (ff_neterrno() != FF_NETERROR(EAGAIN) &&\nff_neterrno() != FF_NETERROR(EINTR))\ngoto fail;",
"} else if (VAR_1 == 0)",
"goto fail;",
"else {",
"VAR_0->buffer_ptr += VAR_1;",
"VAR_0->data_count += VAR_1;",
"update_datarate(&VAR_0->datarate, VAR_0->data_count);",
"}",
"}",
"if (VAR_0->buffer_ptr - VAR_0->buffer >= 2 && VAR_0->data_count > FFM_PACKET_SIZE) {",
"if (VAR_0->buffer[0] != 'f' ||\nVAR_0->buffer[1] != 'm') {",
"http_log(\"Feed stream has become desynchronized -- disconnecting\\n\");",
"goto fail;",
"}",
"}",
"if (VAR_0->buffer_ptr >= VAR_0->buffer_end) {",
"FFStream *feed = VAR_0->stream;",
"if (VAR_0->data_count > FFM_PACKET_SIZE) {",
"lseek(VAR_0->feed_fd, feed->feed_write_index, SEEK_SET);",
"if (write(VAR_0->feed_fd, VAR_0->buffer, FFM_PACKET_SIZE) < 0) {",
"http_log(\"Error writing to feed file: %s\\n\", strerror(errno));",
"goto fail;",
"}",
"feed->feed_write_index += FFM_PACKET_SIZE;",
"if (feed->feed_write_index > VAR_0->stream->feed_size)\nfeed->feed_size = feed->feed_write_index;",
"if (VAR_0->stream->feed_max_size && feed->feed_write_index >= VAR_0->stream->feed_max_size)\nfeed->feed_write_index = FFM_PACKET_SIZE;",
"ffm_write_write_index(VAR_0->feed_fd, feed->feed_write_index);",
"for(c1 = first_http_ctx; c1 != NULL; c1 = c1->next) {",
"if (c1->state == HTTPSTATE_WAIT_FEED &&\nc1->stream->feed == VAR_0->stream->feed)\nc1->state = HTTPSTATE_SEND_DATA;",
"}",
"} else {",
"AVFormatContext *s = NULL;",
"ByteIOContext *pb;",
"AVInputFormat *fmt_in;",
"int VAR_2;",
"url_open_buf(&pb, VAR_0->buffer, VAR_0->buffer_end - VAR_0->buffer, URL_RDONLY);",
"pb->is_streamed = 1;",
"fmt_in = av_find_input_format(feed->fmt->name);",
"if (!fmt_in)\ngoto fail;",
"av_open_input_stream(&s, pb, VAR_0->stream->feed_filename, fmt_in, NULL);",
"if (s->nb_streams != feed->nb_streams) {",
"av_close_input_stream(s);",
"av_free(pb);",
"goto fail;",
"}",
"for (VAR_2 = 0; VAR_2 < s->nb_streams; VAR_2++)",
"memcpy(feed->streams[VAR_2]->codec,\ns->streams[VAR_2]->codec, sizeof(AVCodecContext));",
"av_close_input_stream(s);",
"av_free(pb);",
"}",
"VAR_0->buffer_ptr = VAR_0->buffer;",
"}",
"return 0;",
"fail:\nVAR_0->stream->feed_opened = 0;",
"close(VAR_0->feed_fd);",
"for(c1 = first_http_ctx; c1 != NULL; c1 = c1->next) {",
"if (c1->state == HTTPSTATE_WAIT_FEED &&\nc1->stream->feed == VAR_0->stream->feed)\nc1->state = HTTPSTATE_SEND_DATA_TRAILER;",
"}",
"return -1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19,
21,
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
71
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
95,
97
],
[
103,
105
],
[
111
],
[
117
],
[
119,
121,
123
],
[
125
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
149
],
[
151,
153
],
[
157
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177,
179
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197,
199
],
[
201
],
[
205
],
[
207,
209,
211
],
[
213
],
[
215
],
[
217
]
] |
26,871 | uint32_t kvmppc_get_dfp(void)
{
return kvmppc_read_int_cpu_dt("ibm,dfp");
}
| false | qemu | 3f2ca480eb872b4946baf77f756236b637a5b15a | uint32_t kvmppc_get_dfp(void)
{
return kvmppc_read_int_cpu_dt("ibm,dfp");
}
| {
"code": [],
"line_no": []
} | uint32_t FUNC_0(void)
{
return kvmppc_read_int_cpu_dt("ibm,dfp");
}
| [
"uint32_t FUNC_0(void)\n{",
"return kvmppc_read_int_cpu_dt(\"ibm,dfp\");",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
26,872 | static int send_full_color_rect(VncState *vs, int w, int h)
{
int stream = 0;
size_t bytes;
vnc_write_u8(vs, stream << 4); /* no flushing, no filter */
if (vs->tight_pixel24) {
tight_pack24(vs, vs->tight.buffer, w * h, &vs->tight.offset);
bytes = 3;
} else {
bytes = vs->clientds.pf.bytes_per_pixel;
}
bytes = tight_compress_data(vs, stream, w * h * bytes,
tight_conf[vs->tight_compression].raw_zlib_level,
Z_DEFAULT_STRATEGY);
return (bytes >= 0);
}
| false | qemu | 245f7b51c0ea04fb2224b1127430a096c91aee70 | static int send_full_color_rect(VncState *vs, int w, int h)
{
int stream = 0;
size_t bytes;
vnc_write_u8(vs, stream << 4);
if (vs->tight_pixel24) {
tight_pack24(vs, vs->tight.buffer, w * h, &vs->tight.offset);
bytes = 3;
} else {
bytes = vs->clientds.pf.bytes_per_pixel;
}
bytes = tight_compress_data(vs, stream, w * h * bytes,
tight_conf[vs->tight_compression].raw_zlib_level,
Z_DEFAULT_STRATEGY);
return (bytes >= 0);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(VncState *VAR_0, int VAR_1, int VAR_2)
{
int VAR_3 = 0;
size_t bytes;
vnc_write_u8(VAR_0, VAR_3 << 4);
if (VAR_0->tight_pixel24) {
tight_pack24(VAR_0, VAR_0->tight.buffer, VAR_1 * VAR_2, &VAR_0->tight.offset);
bytes = 3;
} else {
bytes = VAR_0->clientds.pf.bytes_per_pixel;
}
bytes = tight_compress_data(VAR_0, VAR_3, VAR_1 * VAR_2 * bytes,
tight_conf[VAR_0->tight_compression].raw_zlib_level,
Z_DEFAULT_STRATEGY);
return (bytes >= 0);
}
| [
"static int FUNC_0(VncState *VAR_0, int VAR_1, int VAR_2)\n{",
"int VAR_3 = 0;",
"size_t bytes;",
"vnc_write_u8(VAR_0, VAR_3 << 4);",
"if (VAR_0->tight_pixel24) {",
"tight_pack24(VAR_0, VAR_0->tight.buffer, VAR_1 * VAR_2, &VAR_0->tight.offset);",
"bytes = 3;",
"} else {",
"bytes = VAR_0->clientds.pf.bytes_per_pixel;",
"}",
"bytes = tight_compress_data(VAR_0, VAR_3, VAR_1 * VAR_2 * bytes,\ntight_conf[VAR_0->tight_compression].raw_zlib_level,\nZ_DEFAULT_STRATEGY);",
"return (bytes >= 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
],
[
29,
31,
33
],
[
37
],
[
39
]
] |
26,874 | static void test_visitor_in_string(TestInputVisitorData *data,
const void *unused)
{
char *res = NULL, *value = (char *) "Q E M U";
Visitor *v;
v = visitor_input_test_init(data, "%s", value);
visit_type_str(v, NULL, &res, &error_abort);
g_assert_cmpstr(res, ==, value);
g_free(res);
}
| false | qemu | b3db211f3c80bb996a704d665fe275619f728bd4 | static void test_visitor_in_string(TestInputVisitorData *data,
const void *unused)
{
char *res = NULL, *value = (char *) "Q E M U";
Visitor *v;
v = visitor_input_test_init(data, "%s", value);
visit_type_str(v, NULL, &res, &error_abort);
g_assert_cmpstr(res, ==, value);
g_free(res);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TestInputVisitorData *VAR_0,
const void *VAR_1)
{
char *VAR_2 = NULL, *VAR_3 = (char *) "Q E M U";
Visitor *v;
v = visitor_input_test_init(VAR_0, "%s", VAR_3);
visit_type_str(v, NULL, &VAR_2, &error_abort);
g_assert_cmpstr(VAR_2, ==, VAR_3);
g_free(VAR_2);
}
| [
"static void FUNC_0(TestInputVisitorData *VAR_0,\nconst void *VAR_1)\n{",
"char *VAR_2 = NULL, *VAR_3 = (char *) \"Q E M U\";",
"Visitor *v;",
"v = visitor_input_test_init(VAR_0, \"%s\", VAR_3);",
"visit_type_str(v, NULL, &VAR_2, &error_abort);",
"g_assert_cmpstr(VAR_2, ==, VAR_3);",
"g_free(VAR_2);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
23
],
[
25
]
] |
26,876 | static int kvm_init(MachineState *ms)
{
MachineClass *mc = MACHINE_GET_CLASS(ms);
static const char upgrade_note[] =
"Please upgrade to at least kernel 2.6.29 or recent kvm-kmod\n"
"(see http://sourceforge.net/projects/kvm).\n";
struct {
const char *name;
int num;
} num_cpus[] = {
{ "SMP", smp_cpus },
{ "hotpluggable", max_cpus },
{ NULL, }
}, *nc = num_cpus;
int soft_vcpus_limit, hard_vcpus_limit;
KVMState *s;
const KVMCapabilityInfo *missing_cap;
int ret;
int type = 0;
const char *kvm_type;
s = KVM_STATE(ms->accelerator);
/*
* On systems where the kernel can support different base page
* sizes, host page size may be different from TARGET_PAGE_SIZE,
* even with KVM. TARGET_PAGE_SIZE is assumed to be the minimum
* page size for the system though.
*/
assert(TARGET_PAGE_SIZE <= getpagesize());
page_size_init();
s->sigmask_len = 8;
#ifdef KVM_CAP_SET_GUEST_DEBUG
QTAILQ_INIT(&s->kvm_sw_breakpoints);
#endif
s->vmfd = -1;
s->fd = qemu_open("/dev/kvm", O_RDWR);
if (s->fd == -1) {
fprintf(stderr, "Could not access KVM kernel module: %m\n");
ret = -errno;
goto err;
}
ret = kvm_ioctl(s, KVM_GET_API_VERSION, 0);
if (ret < KVM_API_VERSION) {
if (ret >= 0) {
ret = -EINVAL;
}
fprintf(stderr, "kvm version too old\n");
goto err;
}
if (ret > KVM_API_VERSION) {
ret = -EINVAL;
fprintf(stderr, "kvm version not supported\n");
goto err;
}
s->nr_slots = kvm_check_extension(s, KVM_CAP_NR_MEMSLOTS);
/* If unspecified, use the default value */
if (!s->nr_slots) {
s->nr_slots = 32;
}
/* check the vcpu limits */
soft_vcpus_limit = kvm_recommended_vcpus(s);
hard_vcpus_limit = kvm_max_vcpus(s);
while (nc->name) {
if (nc->num > soft_vcpus_limit) {
fprintf(stderr,
"Warning: Number of %s cpus requested (%d) exceeds "
"the recommended cpus supported by KVM (%d)\n",
nc->name, nc->num, soft_vcpus_limit);
if (nc->num > hard_vcpus_limit) {
fprintf(stderr, "Number of %s cpus requested (%d) exceeds "
"the maximum cpus supported by KVM (%d)\n",
nc->name, nc->num, hard_vcpus_limit);
exit(1);
}
}
nc++;
}
kvm_type = qemu_opt_get(qemu_get_machine_opts(), "kvm-type");
if (mc->kvm_type) {
type = mc->kvm_type(kvm_type);
} else if (kvm_type) {
ret = -EINVAL;
fprintf(stderr, "Invalid argument kvm-type=%s\n", kvm_type);
goto err;
}
do {
ret = kvm_ioctl(s, KVM_CREATE_VM, type);
} while (ret == -EINTR);
if (ret < 0) {
fprintf(stderr, "ioctl(KVM_CREATE_VM) failed: %d %s\n", -ret,
strerror(-ret));
#ifdef TARGET_S390X
if (ret == -EINVAL) {
fprintf(stderr,
"Host kernel setup problem detected. Please verify:\n");
fprintf(stderr, "- for kernels supporting the switch_amode or"
" user_mode parameters, whether\n");
fprintf(stderr,
" user space is running in primary address space\n");
fprintf(stderr,
"- for kernels supporting the vm.allocate_pgste sysctl, "
"whether it is enabled\n");
}
#endif
goto err;
}
s->vmfd = ret;
missing_cap = kvm_check_extension_list(s, kvm_required_capabilites);
if (!missing_cap) {
missing_cap =
kvm_check_extension_list(s, kvm_arch_required_capabilities);
}
if (missing_cap) {
ret = -EINVAL;
fprintf(stderr, "kvm does not support %s\n%s",
missing_cap->name, upgrade_note);
goto err;
}
s->coalesced_mmio = kvm_check_extension(s, KVM_CAP_COALESCED_MMIO);
s->broken_set_mem_region = 1;
ret = kvm_check_extension(s, KVM_CAP_JOIN_MEMORY_REGIONS_WORKS);
if (ret > 0) {
s->broken_set_mem_region = 0;
}
#ifdef KVM_CAP_VCPU_EVENTS
s->vcpu_events = kvm_check_extension(s, KVM_CAP_VCPU_EVENTS);
#endif
s->robust_singlestep =
kvm_check_extension(s, KVM_CAP_X86_ROBUST_SINGLESTEP);
#ifdef KVM_CAP_DEBUGREGS
s->debugregs = kvm_check_extension(s, KVM_CAP_DEBUGREGS);
#endif
#ifdef KVM_CAP_XSAVE
s->xsave = kvm_check_extension(s, KVM_CAP_XSAVE);
#endif
#ifdef KVM_CAP_XCRS
s->xcrs = kvm_check_extension(s, KVM_CAP_XCRS);
#endif
#ifdef KVM_CAP_PIT_STATE2
s->pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2);
#endif
#ifdef KVM_CAP_IRQ_ROUTING
kvm_direct_msi_allowed = (kvm_check_extension(s, KVM_CAP_SIGNAL_MSI) > 0);
#endif
s->intx_set_mask = kvm_check_extension(s, KVM_CAP_PCI_2_3);
s->irq_set_ioctl = KVM_IRQ_LINE;
if (kvm_check_extension(s, KVM_CAP_IRQ_INJECT_STATUS)) {
s->irq_set_ioctl = KVM_IRQ_LINE_STATUS;
}
#ifdef KVM_CAP_READONLY_MEM
kvm_readonly_mem_allowed =
(kvm_check_extension(s, KVM_CAP_READONLY_MEM) > 0);
#endif
kvm_eventfds_allowed =
(kvm_check_extension(s, KVM_CAP_IOEVENTFD) > 0);
kvm_irqfds_allowed =
(kvm_check_extension(s, KVM_CAP_IRQFD) > 0);
kvm_resamplefds_allowed =
(kvm_check_extension(s, KVM_CAP_IRQFD_RESAMPLE) > 0);
kvm_vm_attributes_allowed =
(kvm_check_extension(s, KVM_CAP_VM_ATTRIBUTES) > 0);
ret = kvm_arch_init(ms, s);
if (ret < 0) {
goto err;
}
if (machine_kernel_irqchip_allowed(ms)) {
kvm_irqchip_create(ms, s);
}
kvm_state = s;
s->memory_listener.listener.eventfd_add = kvm_mem_ioeventfd_add;
s->memory_listener.listener.eventfd_del = kvm_mem_ioeventfd_del;
s->memory_listener.listener.coalesced_mmio_add = kvm_coalesce_mmio_region;
s->memory_listener.listener.coalesced_mmio_del = kvm_uncoalesce_mmio_region;
kvm_memory_listener_register(s, &s->memory_listener,
&address_space_memory, 0);
memory_listener_register(&kvm_io_listener,
&address_space_io);
s->many_ioeventfds = kvm_check_many_ioeventfds();
cpu_interrupt_handler = kvm_handle_interrupt;
return 0;
err:
assert(ret < 0);
if (s->vmfd >= 0) {
close(s->vmfd);
}
if (s->fd != -1) {
close(s->fd);
}
g_free(s->memory_listener.slots);
return ret;
}
| false | qemu | 28143b409f698210d85165ca518235ac7e7c5ac5 | static int kvm_init(MachineState *ms)
{
MachineClass *mc = MACHINE_GET_CLASS(ms);
static const char upgrade_note[] =
"Please upgrade to at least kernel 2.6.29 or recent kvm-kmod\n"
"(see http:
struct {
const char *name;
int num;
} num_cpus[] = {
{ "SMP", smp_cpus },
{ "hotpluggable", max_cpus },
{ NULL, }
}, *nc = num_cpus;
int soft_vcpus_limit, hard_vcpus_limit;
KVMState *s;
const KVMCapabilityInfo *missing_cap;
int ret;
int type = 0;
const char *kvm_type;
s = KVM_STATE(ms->accelerator);
assert(TARGET_PAGE_SIZE <= getpagesize());
page_size_init();
s->sigmask_len = 8;
#ifdef KVM_CAP_SET_GUEST_DEBUG
QTAILQ_INIT(&s->kvm_sw_breakpoints);
#endif
s->vmfd = -1;
s->fd = qemu_open("/dev/kvm", O_RDWR);
if (s->fd == -1) {
fprintf(stderr, "Could not access KVM kernel module: %m\n");
ret = -errno;
goto err;
}
ret = kvm_ioctl(s, KVM_GET_API_VERSION, 0);
if (ret < KVM_API_VERSION) {
if (ret >= 0) {
ret = -EINVAL;
}
fprintf(stderr, "kvm version too old\n");
goto err;
}
if (ret > KVM_API_VERSION) {
ret = -EINVAL;
fprintf(stderr, "kvm version not supported\n");
goto err;
}
s->nr_slots = kvm_check_extension(s, KVM_CAP_NR_MEMSLOTS);
if (!s->nr_slots) {
s->nr_slots = 32;
}
soft_vcpus_limit = kvm_recommended_vcpus(s);
hard_vcpus_limit = kvm_max_vcpus(s);
while (nc->name) {
if (nc->num > soft_vcpus_limit) {
fprintf(stderr,
"Warning: Number of %s cpus requested (%d) exceeds "
"the recommended cpus supported by KVM (%d)\n",
nc->name, nc->num, soft_vcpus_limit);
if (nc->num > hard_vcpus_limit) {
fprintf(stderr, "Number of %s cpus requested (%d) exceeds "
"the maximum cpus supported by KVM (%d)\n",
nc->name, nc->num, hard_vcpus_limit);
exit(1);
}
}
nc++;
}
kvm_type = qemu_opt_get(qemu_get_machine_opts(), "kvm-type");
if (mc->kvm_type) {
type = mc->kvm_type(kvm_type);
} else if (kvm_type) {
ret = -EINVAL;
fprintf(stderr, "Invalid argument kvm-type=%s\n", kvm_type);
goto err;
}
do {
ret = kvm_ioctl(s, KVM_CREATE_VM, type);
} while (ret == -EINTR);
if (ret < 0) {
fprintf(stderr, "ioctl(KVM_CREATE_VM) failed: %d %s\n", -ret,
strerror(-ret));
#ifdef TARGET_S390X
if (ret == -EINVAL) {
fprintf(stderr,
"Host kernel setup problem detected. Please verify:\n");
fprintf(stderr, "- for kernels supporting the switch_amode or"
" user_mode parameters, whether\n");
fprintf(stderr,
" user space is running in primary address space\n");
fprintf(stderr,
"- for kernels supporting the vm.allocate_pgste sysctl, "
"whether it is enabled\n");
}
#endif
goto err;
}
s->vmfd = ret;
missing_cap = kvm_check_extension_list(s, kvm_required_capabilites);
if (!missing_cap) {
missing_cap =
kvm_check_extension_list(s, kvm_arch_required_capabilities);
}
if (missing_cap) {
ret = -EINVAL;
fprintf(stderr, "kvm does not support %s\n%s",
missing_cap->name, upgrade_note);
goto err;
}
s->coalesced_mmio = kvm_check_extension(s, KVM_CAP_COALESCED_MMIO);
s->broken_set_mem_region = 1;
ret = kvm_check_extension(s, KVM_CAP_JOIN_MEMORY_REGIONS_WORKS);
if (ret > 0) {
s->broken_set_mem_region = 0;
}
#ifdef KVM_CAP_VCPU_EVENTS
s->vcpu_events = kvm_check_extension(s, KVM_CAP_VCPU_EVENTS);
#endif
s->robust_singlestep =
kvm_check_extension(s, KVM_CAP_X86_ROBUST_SINGLESTEP);
#ifdef KVM_CAP_DEBUGREGS
s->debugregs = kvm_check_extension(s, KVM_CAP_DEBUGREGS);
#endif
#ifdef KVM_CAP_XSAVE
s->xsave = kvm_check_extension(s, KVM_CAP_XSAVE);
#endif
#ifdef KVM_CAP_XCRS
s->xcrs = kvm_check_extension(s, KVM_CAP_XCRS);
#endif
#ifdef KVM_CAP_PIT_STATE2
s->pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2);
#endif
#ifdef KVM_CAP_IRQ_ROUTING
kvm_direct_msi_allowed = (kvm_check_extension(s, KVM_CAP_SIGNAL_MSI) > 0);
#endif
s->intx_set_mask = kvm_check_extension(s, KVM_CAP_PCI_2_3);
s->irq_set_ioctl = KVM_IRQ_LINE;
if (kvm_check_extension(s, KVM_CAP_IRQ_INJECT_STATUS)) {
s->irq_set_ioctl = KVM_IRQ_LINE_STATUS;
}
#ifdef KVM_CAP_READONLY_MEM
kvm_readonly_mem_allowed =
(kvm_check_extension(s, KVM_CAP_READONLY_MEM) > 0);
#endif
kvm_eventfds_allowed =
(kvm_check_extension(s, KVM_CAP_IOEVENTFD) > 0);
kvm_irqfds_allowed =
(kvm_check_extension(s, KVM_CAP_IRQFD) > 0);
kvm_resamplefds_allowed =
(kvm_check_extension(s, KVM_CAP_IRQFD_RESAMPLE) > 0);
kvm_vm_attributes_allowed =
(kvm_check_extension(s, KVM_CAP_VM_ATTRIBUTES) > 0);
ret = kvm_arch_init(ms, s);
if (ret < 0) {
goto err;
}
if (machine_kernel_irqchip_allowed(ms)) {
kvm_irqchip_create(ms, s);
}
kvm_state = s;
s->memory_listener.listener.eventfd_add = kvm_mem_ioeventfd_add;
s->memory_listener.listener.eventfd_del = kvm_mem_ioeventfd_del;
s->memory_listener.listener.coalesced_mmio_add = kvm_coalesce_mmio_region;
s->memory_listener.listener.coalesced_mmio_del = kvm_uncoalesce_mmio_region;
kvm_memory_listener_register(s, &s->memory_listener,
&address_space_memory, 0);
memory_listener_register(&kvm_io_listener,
&address_space_io);
s->many_ioeventfds = kvm_check_many_ioeventfds();
cpu_interrupt_handler = kvm_handle_interrupt;
return 0;
err:
assert(ret < 0);
if (s->vmfd >= 0) {
close(s->vmfd);
}
if (s->fd != -1) {
close(s->fd);
}
g_free(s->memory_listener.slots);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MachineState *VAR_0)
{
MachineClass *mc = MACHINE_GET_CLASS(VAR_0);
static const char VAR_1[] =
"Please upgrade to at least kernel 2.6.29 or recent kvm-kmod\n"
"(see http:
struct {
const char *name;
int num;
} num_cpus[] = {
{ "SMP", smp_cpus },
{ "hotpluggable", max_cpus },
{ NULL, }
}, *nc = num_cpus;
int VAR_2, VAR_3;
KVMState *s;
const KVMCapabilityInfo *VAR_4;
int VAR_5;
int VAR_6 = 0;
const char *VAR_7;
s = KVM_STATE(VAR_0->accelerator);
assert(TARGET_PAGE_SIZE <= getpagesize());
page_size_init();
s->sigmask_len = 8;
#ifdef KVM_CAP_SET_GUEST_DEBUG
QTAILQ_INIT(&s->kvm_sw_breakpoints);
#endif
s->vmfd = -1;
s->fd = qemu_open("/dev/kvm", O_RDWR);
if (s->fd == -1) {
fprintf(stderr, "Could not access KVM kernel module: %m\n");
VAR_5 = -errno;
goto err;
}
VAR_5 = kvm_ioctl(s, KVM_GET_API_VERSION, 0);
if (VAR_5 < KVM_API_VERSION) {
if (VAR_5 >= 0) {
VAR_5 = -EINVAL;
}
fprintf(stderr, "kvm version too old\n");
goto err;
}
if (VAR_5 > KVM_API_VERSION) {
VAR_5 = -EINVAL;
fprintf(stderr, "kvm version not supported\n");
goto err;
}
s->nr_slots = kvm_check_extension(s, KVM_CAP_NR_MEMSLOTS);
if (!s->nr_slots) {
s->nr_slots = 32;
}
VAR_2 = kvm_recommended_vcpus(s);
VAR_3 = kvm_max_vcpus(s);
while (nc->name) {
if (nc->num > VAR_2) {
fprintf(stderr,
"Warning: Number of %s cpus requested (%d) exceeds "
"the recommended cpus supported by KVM (%d)\n",
nc->name, nc->num, VAR_2);
if (nc->num > VAR_3) {
fprintf(stderr, "Number of %s cpus requested (%d) exceeds "
"the maximum cpus supported by KVM (%d)\n",
nc->name, nc->num, VAR_3);
exit(1);
}
}
nc++;
}
VAR_7 = qemu_opt_get(qemu_get_machine_opts(), "kvm-VAR_6");
if (mc->VAR_7) {
VAR_6 = mc->VAR_7(VAR_7);
} else if (VAR_7) {
VAR_5 = -EINVAL;
fprintf(stderr, "Invalid argument kvm-VAR_6=%s\n", VAR_7);
goto err;
}
do {
VAR_5 = kvm_ioctl(s, KVM_CREATE_VM, VAR_6);
} while (VAR_5 == -EINTR);
if (VAR_5 < 0) {
fprintf(stderr, "ioctl(KVM_CREATE_VM) failed: %d %s\n", -VAR_5,
strerror(-VAR_5));
#ifdef TARGET_S390X
if (VAR_5 == -EINVAL) {
fprintf(stderr,
"Host kernel setup problem detected. Please verify:\n");
fprintf(stderr, "- for kernels supporting the switch_amode or"
" user_mode parameters, whether\n");
fprintf(stderr,
" user space is running in primary address space\n");
fprintf(stderr,
"- for kernels supporting the vm.allocate_pgste sysctl, "
"whether it is enabled\n");
}
#endif
goto err;
}
s->vmfd = VAR_5;
VAR_4 = kvm_check_extension_list(s, kvm_required_capabilites);
if (!VAR_4) {
VAR_4 =
kvm_check_extension_list(s, kvm_arch_required_capabilities);
}
if (VAR_4) {
VAR_5 = -EINVAL;
fprintf(stderr, "kvm does not support %s\n%s",
VAR_4->name, VAR_1);
goto err;
}
s->coalesced_mmio = kvm_check_extension(s, KVM_CAP_COALESCED_MMIO);
s->broken_set_mem_region = 1;
VAR_5 = kvm_check_extension(s, KVM_CAP_JOIN_MEMORY_REGIONS_WORKS);
if (VAR_5 > 0) {
s->broken_set_mem_region = 0;
}
#ifdef KVM_CAP_VCPU_EVENTS
s->vcpu_events = kvm_check_extension(s, KVM_CAP_VCPU_EVENTS);
#endif
s->robust_singlestep =
kvm_check_extension(s, KVM_CAP_X86_ROBUST_SINGLESTEP);
#ifdef KVM_CAP_DEBUGREGS
s->debugregs = kvm_check_extension(s, KVM_CAP_DEBUGREGS);
#endif
#ifdef KVM_CAP_XSAVE
s->xsave = kvm_check_extension(s, KVM_CAP_XSAVE);
#endif
#ifdef KVM_CAP_XCRS
s->xcrs = kvm_check_extension(s, KVM_CAP_XCRS);
#endif
#ifdef KVM_CAP_PIT_STATE2
s->pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2);
#endif
#ifdef KVM_CAP_IRQ_ROUTING
kvm_direct_msi_allowed = (kvm_check_extension(s, KVM_CAP_SIGNAL_MSI) > 0);
#endif
s->intx_set_mask = kvm_check_extension(s, KVM_CAP_PCI_2_3);
s->irq_set_ioctl = KVM_IRQ_LINE;
if (kvm_check_extension(s, KVM_CAP_IRQ_INJECT_STATUS)) {
s->irq_set_ioctl = KVM_IRQ_LINE_STATUS;
}
#ifdef KVM_CAP_READONLY_MEM
kvm_readonly_mem_allowed =
(kvm_check_extension(s, KVM_CAP_READONLY_MEM) > 0);
#endif
kvm_eventfds_allowed =
(kvm_check_extension(s, KVM_CAP_IOEVENTFD) > 0);
kvm_irqfds_allowed =
(kvm_check_extension(s, KVM_CAP_IRQFD) > 0);
kvm_resamplefds_allowed =
(kvm_check_extension(s, KVM_CAP_IRQFD_RESAMPLE) > 0);
kvm_vm_attributes_allowed =
(kvm_check_extension(s, KVM_CAP_VM_ATTRIBUTES) > 0);
VAR_5 = kvm_arch_init(VAR_0, s);
if (VAR_5 < 0) {
goto err;
}
if (machine_kernel_irqchip_allowed(VAR_0)) {
kvm_irqchip_create(VAR_0, s);
}
kvm_state = s;
s->memory_listener.listener.eventfd_add = kvm_mem_ioeventfd_add;
s->memory_listener.listener.eventfd_del = kvm_mem_ioeventfd_del;
s->memory_listener.listener.coalesced_mmio_add = kvm_coalesce_mmio_region;
s->memory_listener.listener.coalesced_mmio_del = kvm_uncoalesce_mmio_region;
kvm_memory_listener_register(s, &s->memory_listener,
&address_space_memory, 0);
memory_listener_register(&kvm_io_listener,
&address_space_io);
s->many_ioeventfds = kvm_check_many_ioeventfds();
cpu_interrupt_handler = kvm_handle_interrupt;
return 0;
err:
assert(VAR_5 < 0);
if (s->vmfd >= 0) {
close(s->vmfd);
}
if (s->fd != -1) {
close(s->fd);
}
g_free(s->memory_listener.slots);
return VAR_5;
}
| [
"static int FUNC_0(MachineState *VAR_0)\n{",
"MachineClass *mc = MACHINE_GET_CLASS(VAR_0);",
"static const char VAR_1[] =\n\"Please upgrade to at least kernel 2.6.29 or recent kvm-kmod\\n\"\n\"(see http:\nstruct {",
"const char *name;",
"int num;",
"} num_cpus[] = {",
"{ \"SMP\", smp_cpus },",
"{ \"hotpluggable\", max_cpus },",
"{ NULL, }",
"}, *nc = num_cpus;",
"int VAR_2, VAR_3;",
"KVMState *s;",
"const KVMCapabilityInfo *VAR_4;",
"int VAR_5;",
"int VAR_6 = 0;",
"const char *VAR_7;",
"s = KVM_STATE(VAR_0->accelerator);",
"assert(TARGET_PAGE_SIZE <= getpagesize());",
"page_size_init();",
"s->sigmask_len = 8;",
"#ifdef KVM_CAP_SET_GUEST_DEBUG\nQTAILQ_INIT(&s->kvm_sw_breakpoints);",
"#endif\ns->vmfd = -1;",
"s->fd = qemu_open(\"/dev/kvm\", O_RDWR);",
"if (s->fd == -1) {",
"fprintf(stderr, \"Could not access KVM kernel module: %m\\n\");",
"VAR_5 = -errno;",
"goto err;",
"}",
"VAR_5 = kvm_ioctl(s, KVM_GET_API_VERSION, 0);",
"if (VAR_5 < KVM_API_VERSION) {",
"if (VAR_5 >= 0) {",
"VAR_5 = -EINVAL;",
"}",
"fprintf(stderr, \"kvm version too old\\n\");",
"goto err;",
"}",
"if (VAR_5 > KVM_API_VERSION) {",
"VAR_5 = -EINVAL;",
"fprintf(stderr, \"kvm version not supported\\n\");",
"goto err;",
"}",
"s->nr_slots = kvm_check_extension(s, KVM_CAP_NR_MEMSLOTS);",
"if (!s->nr_slots) {",
"s->nr_slots = 32;",
"}",
"VAR_2 = kvm_recommended_vcpus(s);",
"VAR_3 = kvm_max_vcpus(s);",
"while (nc->name) {",
"if (nc->num > VAR_2) {",
"fprintf(stderr,\n\"Warning: Number of %s cpus requested (%d) exceeds \"\n\"the recommended cpus supported by KVM (%d)\\n\",\nnc->name, nc->num, VAR_2);",
"if (nc->num > VAR_3) {",
"fprintf(stderr, \"Number of %s cpus requested (%d) exceeds \"\n\"the maximum cpus supported by KVM (%d)\\n\",\nnc->name, nc->num, VAR_3);",
"exit(1);",
"}",
"}",
"nc++;",
"}",
"VAR_7 = qemu_opt_get(qemu_get_machine_opts(), \"kvm-VAR_6\");",
"if (mc->VAR_7) {",
"VAR_6 = mc->VAR_7(VAR_7);",
"} else if (VAR_7) {",
"VAR_5 = -EINVAL;",
"fprintf(stderr, \"Invalid argument kvm-VAR_6=%s\\n\", VAR_7);",
"goto err;",
"}",
"do {",
"VAR_5 = kvm_ioctl(s, KVM_CREATE_VM, VAR_6);",
"} while (VAR_5 == -EINTR);",
"if (VAR_5 < 0) {",
"fprintf(stderr, \"ioctl(KVM_CREATE_VM) failed: %d %s\\n\", -VAR_5,\nstrerror(-VAR_5));",
"#ifdef TARGET_S390X\nif (VAR_5 == -EINVAL) {",
"fprintf(stderr,\n\"Host kernel setup problem detected. Please verify:\\n\");",
"fprintf(stderr, \"- for kernels supporting the switch_amode or\"\n\" user_mode parameters, whether\\n\");",
"fprintf(stderr,\n\" user space is running in primary address space\\n\");",
"fprintf(stderr,\n\"- for kernels supporting the vm.allocate_pgste sysctl, \"\n\"whether it is enabled\\n\");",
"}",
"#endif\ngoto err;",
"}",
"s->vmfd = VAR_5;",
"VAR_4 = kvm_check_extension_list(s, kvm_required_capabilites);",
"if (!VAR_4) {",
"VAR_4 =\nkvm_check_extension_list(s, kvm_arch_required_capabilities);",
"}",
"if (VAR_4) {",
"VAR_5 = -EINVAL;",
"fprintf(stderr, \"kvm does not support %s\\n%s\",\nVAR_4->name, VAR_1);",
"goto err;",
"}",
"s->coalesced_mmio = kvm_check_extension(s, KVM_CAP_COALESCED_MMIO);",
"s->broken_set_mem_region = 1;",
"VAR_5 = kvm_check_extension(s, KVM_CAP_JOIN_MEMORY_REGIONS_WORKS);",
"if (VAR_5 > 0) {",
"s->broken_set_mem_region = 0;",
"}",
"#ifdef KVM_CAP_VCPU_EVENTS\ns->vcpu_events = kvm_check_extension(s, KVM_CAP_VCPU_EVENTS);",
"#endif\ns->robust_singlestep =\nkvm_check_extension(s, KVM_CAP_X86_ROBUST_SINGLESTEP);",
"#ifdef KVM_CAP_DEBUGREGS\ns->debugregs = kvm_check_extension(s, KVM_CAP_DEBUGREGS);",
"#endif\n#ifdef KVM_CAP_XSAVE\ns->xsave = kvm_check_extension(s, KVM_CAP_XSAVE);",
"#endif\n#ifdef KVM_CAP_XCRS\ns->xcrs = kvm_check_extension(s, KVM_CAP_XCRS);",
"#endif\n#ifdef KVM_CAP_PIT_STATE2\ns->pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2);",
"#endif\n#ifdef KVM_CAP_IRQ_ROUTING\nkvm_direct_msi_allowed = (kvm_check_extension(s, KVM_CAP_SIGNAL_MSI) > 0);",
"#endif\ns->intx_set_mask = kvm_check_extension(s, KVM_CAP_PCI_2_3);",
"s->irq_set_ioctl = KVM_IRQ_LINE;",
"if (kvm_check_extension(s, KVM_CAP_IRQ_INJECT_STATUS)) {",
"s->irq_set_ioctl = KVM_IRQ_LINE_STATUS;",
"}",
"#ifdef KVM_CAP_READONLY_MEM\nkvm_readonly_mem_allowed =\n(kvm_check_extension(s, KVM_CAP_READONLY_MEM) > 0);",
"#endif\nkvm_eventfds_allowed =\n(kvm_check_extension(s, KVM_CAP_IOEVENTFD) > 0);",
"kvm_irqfds_allowed =\n(kvm_check_extension(s, KVM_CAP_IRQFD) > 0);",
"kvm_resamplefds_allowed =\n(kvm_check_extension(s, KVM_CAP_IRQFD_RESAMPLE) > 0);",
"kvm_vm_attributes_allowed =\n(kvm_check_extension(s, KVM_CAP_VM_ATTRIBUTES) > 0);",
"VAR_5 = kvm_arch_init(VAR_0, s);",
"if (VAR_5 < 0) {",
"goto err;",
"}",
"if (machine_kernel_irqchip_allowed(VAR_0)) {",
"kvm_irqchip_create(VAR_0, s);",
"}",
"kvm_state = s;",
"s->memory_listener.listener.eventfd_add = kvm_mem_ioeventfd_add;",
"s->memory_listener.listener.eventfd_del = kvm_mem_ioeventfd_del;",
"s->memory_listener.listener.coalesced_mmio_add = kvm_coalesce_mmio_region;",
"s->memory_listener.listener.coalesced_mmio_del = kvm_uncoalesce_mmio_region;",
"kvm_memory_listener_register(s, &s->memory_listener,\n&address_space_memory, 0);",
"memory_listener_register(&kvm_io_listener,\n&address_space_io);",
"s->many_ioeventfds = kvm_check_many_ioeventfds();",
"cpu_interrupt_handler = kvm_handle_interrupt;",
"return 0;",
"err:\nassert(VAR_5 < 0);",
"if (s->vmfd >= 0) {",
"close(s->vmfd);",
"}",
"if (s->fd != -1) {",
"close(s->fd);",
"}",
"g_free(s->memory_listener.slots);",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9,
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
59
],
[
61
],
[
65
],
[
69,
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
127
],
[
129
],
[
131
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147,
149,
151,
153
],
[
157
],
[
159,
161,
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197
],
[
199
],
[
203
],
[
205,
207
],
[
211,
213
],
[
215,
217
],
[
219,
221
],
[
223,
225
],
[
227,
229,
231
],
[
233
],
[
235,
237
],
[
239
],
[
243
],
[
245
],
[
247
],
[
249,
251
],
[
253
],
[
255
],
[
257
],
[
259,
261
],
[
263
],
[
265
],
[
269
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
285,
287
],
[
289,
293,
295
],
[
299,
301
],
[
303,
307,
309
],
[
311,
315,
317
],
[
319,
323,
325
],
[
327,
331,
333
],
[
335,
339
],
[
343
],
[
345
],
[
347
],
[
349
],
[
353,
355,
357
],
[
359,
363,
365
],
[
369,
371
],
[
375,
377
],
[
381,
383
],
[
387
],
[
389
],
[
391
],
[
393
],
[
397
],
[
399
],
[
401
],
[
405
],
[
409
],
[
411
],
[
413
],
[
415
],
[
419,
421
],
[
423,
425
],
[
429
],
[
433
],
[
437
],
[
441,
443
],
[
445
],
[
447
],
[
449
],
[
451
],
[
453
],
[
455
],
[
457
],
[
461
],
[
463
]
] |
26,877 | static void qemu_gluster_gconf_free(GlusterConf *gconf)
{
g_free(gconf->server);
g_free(gconf->volname);
g_free(gconf->image);
g_free(gconf->transport);
g_free(gconf);
}
| false | qemu | 1b37b3442f78a77844fdaf7f53e5f04e4ce8f1d6 | static void qemu_gluster_gconf_free(GlusterConf *gconf)
{
g_free(gconf->server);
g_free(gconf->volname);
g_free(gconf->image);
g_free(gconf->transport);
g_free(gconf);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(GlusterConf *VAR_0)
{
g_free(VAR_0->server);
g_free(VAR_0->volname);
g_free(VAR_0->image);
g_free(VAR_0->transport);
g_free(VAR_0);
}
| [
"static void FUNC_0(GlusterConf *VAR_0)\n{",
"g_free(VAR_0->server);",
"g_free(VAR_0->volname);",
"g_free(VAR_0->image);",
"g_free(VAR_0->transport);",
"g_free(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
26,878 | void net_tx_pkt_init(struct NetTxPkt **pkt, uint32_t max_frags,
bool has_virt_hdr)
{
struct NetTxPkt *p = g_malloc0(sizeof *p);
p->vec = g_malloc((sizeof *p->vec) *
(max_frags + NET_TX_PKT_PL_START_FRAG));
p->raw = g_malloc((sizeof *p->raw) * max_frags);
p->max_payload_frags = max_frags;
p->max_raw_frags = max_frags;
p->has_virt_hdr = has_virt_hdr;
p->vec[NET_TX_PKT_VHDR_FRAG].iov_base = &p->virt_hdr;
p->vec[NET_TX_PKT_VHDR_FRAG].iov_len =
p->has_virt_hdr ? sizeof p->virt_hdr : 0;
p->vec[NET_TX_PKT_L2HDR_FRAG].iov_base = &p->l2_hdr;
p->vec[NET_TX_PKT_L3HDR_FRAG].iov_base = NULL;
p->vec[NET_TX_PKT_L3HDR_FRAG].iov_len = 0;
*pkt = p;
}
| false | qemu | eb700029c7836798046191d62d595363d92c84d4 | void net_tx_pkt_init(struct NetTxPkt **pkt, uint32_t max_frags,
bool has_virt_hdr)
{
struct NetTxPkt *p = g_malloc0(sizeof *p);
p->vec = g_malloc((sizeof *p->vec) *
(max_frags + NET_TX_PKT_PL_START_FRAG));
p->raw = g_malloc((sizeof *p->raw) * max_frags);
p->max_payload_frags = max_frags;
p->max_raw_frags = max_frags;
p->has_virt_hdr = has_virt_hdr;
p->vec[NET_TX_PKT_VHDR_FRAG].iov_base = &p->virt_hdr;
p->vec[NET_TX_PKT_VHDR_FRAG].iov_len =
p->has_virt_hdr ? sizeof p->virt_hdr : 0;
p->vec[NET_TX_PKT_L2HDR_FRAG].iov_base = &p->l2_hdr;
p->vec[NET_TX_PKT_L3HDR_FRAG].iov_base = NULL;
p->vec[NET_TX_PKT_L3HDR_FRAG].iov_len = 0;
*pkt = p;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(struct NetTxPkt **VAR_0, uint32_t VAR_1,
bool VAR_2)
{
struct NetTxPkt *VAR_3 = g_malloc0(sizeof *VAR_3);
VAR_3->vec = g_malloc((sizeof *VAR_3->vec) *
(VAR_1 + NET_TX_PKT_PL_START_FRAG));
VAR_3->raw = g_malloc((sizeof *VAR_3->raw) * VAR_1);
VAR_3->max_payload_frags = VAR_1;
VAR_3->max_raw_frags = VAR_1;
VAR_3->VAR_2 = VAR_2;
VAR_3->vec[NET_TX_PKT_VHDR_FRAG].iov_base = &VAR_3->virt_hdr;
VAR_3->vec[NET_TX_PKT_VHDR_FRAG].iov_len =
VAR_3->VAR_2 ? sizeof VAR_3->virt_hdr : 0;
VAR_3->vec[NET_TX_PKT_L2HDR_FRAG].iov_base = &VAR_3->l2_hdr;
VAR_3->vec[NET_TX_PKT_L3HDR_FRAG].iov_base = NULL;
VAR_3->vec[NET_TX_PKT_L3HDR_FRAG].iov_len = 0;
*VAR_0 = VAR_3;
}
| [
"void FUNC_0(struct NetTxPkt **VAR_0, uint32_t VAR_1,\nbool VAR_2)\n{",
"struct NetTxPkt *VAR_3 = g_malloc0(sizeof *VAR_3);",
"VAR_3->vec = g_malloc((sizeof *VAR_3->vec) *\n(VAR_1 + NET_TX_PKT_PL_START_FRAG));",
"VAR_3->raw = g_malloc((sizeof *VAR_3->raw) * VAR_1);",
"VAR_3->max_payload_frags = VAR_1;",
"VAR_3->max_raw_frags = VAR_1;",
"VAR_3->VAR_2 = VAR_2;",
"VAR_3->vec[NET_TX_PKT_VHDR_FRAG].iov_base = &VAR_3->virt_hdr;",
"VAR_3->vec[NET_TX_PKT_VHDR_FRAG].iov_len =\nVAR_3->VAR_2 ? sizeof VAR_3->virt_hdr : 0;",
"VAR_3->vec[NET_TX_PKT_L2HDR_FRAG].iov_base = &VAR_3->l2_hdr;",
"VAR_3->vec[NET_TX_PKT_L3HDR_FRAG].iov_base = NULL;",
"VAR_3->vec[NET_TX_PKT_L3HDR_FRAG].iov_len = 0;",
"*VAR_0 = VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11,
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
]
] |
26,879 | static void vtd_init(IntelIOMMUState *s)
{
memset(s->csr, 0, DMAR_REG_SIZE);
memset(s->wmask, 0, DMAR_REG_SIZE);
memset(s->w1cmask, 0, DMAR_REG_SIZE);
memset(s->womask, 0, DMAR_REG_SIZE);
s->iommu_ops.translate = vtd_iommu_translate;
s->root = 0;
s->root_extended = false;
s->dmar_enabled = false;
s->iq_head = 0;
s->iq_tail = 0;
s->iq = 0;
s->iq_size = 0;
s->qi_enabled = false;
s->iq_last_desc_type = VTD_INV_DESC_NONE;
s->next_frcd_reg = 0;
s->cap = VTD_CAP_FRO | VTD_CAP_NFR | VTD_CAP_ND | VTD_CAP_MGAW |
VTD_CAP_SAGAW | VTD_CAP_MAMV | VTD_CAP_PSI;
s->ecap = VTD_ECAP_QI | VTD_ECAP_IRO;
vtd_reset_context_cache(s);
vtd_reset_iotlb(s);
/* Define registers with default values and bit semantics */
vtd_define_long(s, DMAR_VER_REG, 0x10UL, 0, 0);
vtd_define_quad(s, DMAR_CAP_REG, s->cap, 0, 0);
vtd_define_quad(s, DMAR_ECAP_REG, s->ecap, 0, 0);
vtd_define_long(s, DMAR_GCMD_REG, 0, 0xff800000UL, 0);
vtd_define_long_wo(s, DMAR_GCMD_REG, 0xff800000UL);
vtd_define_long(s, DMAR_GSTS_REG, 0, 0, 0);
vtd_define_quad(s, DMAR_RTADDR_REG, 0, 0xfffffffffffff000ULL, 0);
vtd_define_quad(s, DMAR_CCMD_REG, 0, 0xe0000003ffffffffULL, 0);
vtd_define_quad_wo(s, DMAR_CCMD_REG, 0x3ffff0000ULL);
/* Advanced Fault Logging not supported */
vtd_define_long(s, DMAR_FSTS_REG, 0, 0, 0x11UL);
vtd_define_long(s, DMAR_FECTL_REG, 0x80000000UL, 0x80000000UL, 0);
vtd_define_long(s, DMAR_FEDATA_REG, 0, 0x0000ffffUL, 0);
vtd_define_long(s, DMAR_FEADDR_REG, 0, 0xfffffffcUL, 0);
/* Treated as RsvdZ when EIM in ECAP_REG is not supported
* vtd_define_long(s, DMAR_FEUADDR_REG, 0, 0xffffffffUL, 0);
*/
vtd_define_long(s, DMAR_FEUADDR_REG, 0, 0, 0);
/* Treated as RO for implementations that PLMR and PHMR fields reported
* as Clear in the CAP_REG.
* vtd_define_long(s, DMAR_PMEN_REG, 0, 0x80000000UL, 0);
*/
vtd_define_long(s, DMAR_PMEN_REG, 0, 0, 0);
vtd_define_quad(s, DMAR_IQH_REG, 0, 0, 0);
vtd_define_quad(s, DMAR_IQT_REG, 0, 0x7fff0ULL, 0);
vtd_define_quad(s, DMAR_IQA_REG, 0, 0xfffffffffffff007ULL, 0);
vtd_define_long(s, DMAR_ICS_REG, 0, 0, 0x1UL);
vtd_define_long(s, DMAR_IECTL_REG, 0x80000000UL, 0x80000000UL, 0);
vtd_define_long(s, DMAR_IEDATA_REG, 0, 0xffffffffUL, 0);
vtd_define_long(s, DMAR_IEADDR_REG, 0, 0xfffffffcUL, 0);
/* Treadted as RsvdZ when EIM in ECAP_REG is not supported */
vtd_define_long(s, DMAR_IEUADDR_REG, 0, 0, 0);
/* IOTLB registers */
vtd_define_quad(s, DMAR_IOTLB_REG, 0, 0Xb003ffff00000000ULL, 0);
vtd_define_quad(s, DMAR_IVA_REG, 0, 0xfffffffffffff07fULL, 0);
vtd_define_quad_wo(s, DMAR_IVA_REG, 0xfffffffffffff07fULL);
/* Fault Recording Registers, 128-bit */
vtd_define_quad(s, DMAR_FRCD_REG_0_0, 0, 0, 0);
vtd_define_quad(s, DMAR_FRCD_REG_0_2, 0, 0, 0x8000000000000000ULL);
}
| false | qemu | d66b969b0d9c8eefdcbff4b48535b0fe1501d139 | static void vtd_init(IntelIOMMUState *s)
{
memset(s->csr, 0, DMAR_REG_SIZE);
memset(s->wmask, 0, DMAR_REG_SIZE);
memset(s->w1cmask, 0, DMAR_REG_SIZE);
memset(s->womask, 0, DMAR_REG_SIZE);
s->iommu_ops.translate = vtd_iommu_translate;
s->root = 0;
s->root_extended = false;
s->dmar_enabled = false;
s->iq_head = 0;
s->iq_tail = 0;
s->iq = 0;
s->iq_size = 0;
s->qi_enabled = false;
s->iq_last_desc_type = VTD_INV_DESC_NONE;
s->next_frcd_reg = 0;
s->cap = VTD_CAP_FRO | VTD_CAP_NFR | VTD_CAP_ND | VTD_CAP_MGAW |
VTD_CAP_SAGAW | VTD_CAP_MAMV | VTD_CAP_PSI;
s->ecap = VTD_ECAP_QI | VTD_ECAP_IRO;
vtd_reset_context_cache(s);
vtd_reset_iotlb(s);
vtd_define_long(s, DMAR_VER_REG, 0x10UL, 0, 0);
vtd_define_quad(s, DMAR_CAP_REG, s->cap, 0, 0);
vtd_define_quad(s, DMAR_ECAP_REG, s->ecap, 0, 0);
vtd_define_long(s, DMAR_GCMD_REG, 0, 0xff800000UL, 0);
vtd_define_long_wo(s, DMAR_GCMD_REG, 0xff800000UL);
vtd_define_long(s, DMAR_GSTS_REG, 0, 0, 0);
vtd_define_quad(s, DMAR_RTADDR_REG, 0, 0xfffffffffffff000ULL, 0);
vtd_define_quad(s, DMAR_CCMD_REG, 0, 0xe0000003ffffffffULL, 0);
vtd_define_quad_wo(s, DMAR_CCMD_REG, 0x3ffff0000ULL);
vtd_define_long(s, DMAR_FSTS_REG, 0, 0, 0x11UL);
vtd_define_long(s, DMAR_FECTL_REG, 0x80000000UL, 0x80000000UL, 0);
vtd_define_long(s, DMAR_FEDATA_REG, 0, 0x0000ffffUL, 0);
vtd_define_long(s, DMAR_FEADDR_REG, 0, 0xfffffffcUL, 0);
vtd_define_long(s, DMAR_FEUADDR_REG, 0, 0, 0);
vtd_define_long(s, DMAR_PMEN_REG, 0, 0, 0);
vtd_define_quad(s, DMAR_IQH_REG, 0, 0, 0);
vtd_define_quad(s, DMAR_IQT_REG, 0, 0x7fff0ULL, 0);
vtd_define_quad(s, DMAR_IQA_REG, 0, 0xfffffffffffff007ULL, 0);
vtd_define_long(s, DMAR_ICS_REG, 0, 0, 0x1UL);
vtd_define_long(s, DMAR_IECTL_REG, 0x80000000UL, 0x80000000UL, 0);
vtd_define_long(s, DMAR_IEDATA_REG, 0, 0xffffffffUL, 0);
vtd_define_long(s, DMAR_IEADDR_REG, 0, 0xfffffffcUL, 0);
vtd_define_long(s, DMAR_IEUADDR_REG, 0, 0, 0);
vtd_define_quad(s, DMAR_IOTLB_REG, 0, 0Xb003ffff00000000ULL, 0);
vtd_define_quad(s, DMAR_IVA_REG, 0, 0xfffffffffffff07fULL, 0);
vtd_define_quad_wo(s, DMAR_IVA_REG, 0xfffffffffffff07fULL);
vtd_define_quad(s, DMAR_FRCD_REG_0_0, 0, 0, 0);
vtd_define_quad(s, DMAR_FRCD_REG_0_2, 0, 0, 0x8000000000000000ULL);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(IntelIOMMUState *VAR_0)
{
memset(VAR_0->csr, 0, DMAR_REG_SIZE);
memset(VAR_0->wmask, 0, DMAR_REG_SIZE);
memset(VAR_0->w1cmask, 0, DMAR_REG_SIZE);
memset(VAR_0->womask, 0, DMAR_REG_SIZE);
VAR_0->iommu_ops.translate = vtd_iommu_translate;
VAR_0->root = 0;
VAR_0->root_extended = false;
VAR_0->dmar_enabled = false;
VAR_0->iq_head = 0;
VAR_0->iq_tail = 0;
VAR_0->iq = 0;
VAR_0->iq_size = 0;
VAR_0->qi_enabled = false;
VAR_0->iq_last_desc_type = VTD_INV_DESC_NONE;
VAR_0->next_frcd_reg = 0;
VAR_0->cap = VTD_CAP_FRO | VTD_CAP_NFR | VTD_CAP_ND | VTD_CAP_MGAW |
VTD_CAP_SAGAW | VTD_CAP_MAMV | VTD_CAP_PSI;
VAR_0->ecap = VTD_ECAP_QI | VTD_ECAP_IRO;
vtd_reset_context_cache(VAR_0);
vtd_reset_iotlb(VAR_0);
vtd_define_long(VAR_0, DMAR_VER_REG, 0x10UL, 0, 0);
vtd_define_quad(VAR_0, DMAR_CAP_REG, VAR_0->cap, 0, 0);
vtd_define_quad(VAR_0, DMAR_ECAP_REG, VAR_0->ecap, 0, 0);
vtd_define_long(VAR_0, DMAR_GCMD_REG, 0, 0xff800000UL, 0);
vtd_define_long_wo(VAR_0, DMAR_GCMD_REG, 0xff800000UL);
vtd_define_long(VAR_0, DMAR_GSTS_REG, 0, 0, 0);
vtd_define_quad(VAR_0, DMAR_RTADDR_REG, 0, 0xfffffffffffff000ULL, 0);
vtd_define_quad(VAR_0, DMAR_CCMD_REG, 0, 0xe0000003ffffffffULL, 0);
vtd_define_quad_wo(VAR_0, DMAR_CCMD_REG, 0x3ffff0000ULL);
vtd_define_long(VAR_0, DMAR_FSTS_REG, 0, 0, 0x11UL);
vtd_define_long(VAR_0, DMAR_FECTL_REG, 0x80000000UL, 0x80000000UL, 0);
vtd_define_long(VAR_0, DMAR_FEDATA_REG, 0, 0x0000ffffUL, 0);
vtd_define_long(VAR_0, DMAR_FEADDR_REG, 0, 0xfffffffcUL, 0);
vtd_define_long(VAR_0, DMAR_FEUADDR_REG, 0, 0, 0);
vtd_define_long(VAR_0, DMAR_PMEN_REG, 0, 0, 0);
vtd_define_quad(VAR_0, DMAR_IQH_REG, 0, 0, 0);
vtd_define_quad(VAR_0, DMAR_IQT_REG, 0, 0x7fff0ULL, 0);
vtd_define_quad(VAR_0, DMAR_IQA_REG, 0, 0xfffffffffffff007ULL, 0);
vtd_define_long(VAR_0, DMAR_ICS_REG, 0, 0, 0x1UL);
vtd_define_long(VAR_0, DMAR_IECTL_REG, 0x80000000UL, 0x80000000UL, 0);
vtd_define_long(VAR_0, DMAR_IEDATA_REG, 0, 0xffffffffUL, 0);
vtd_define_long(VAR_0, DMAR_IEADDR_REG, 0, 0xfffffffcUL, 0);
vtd_define_long(VAR_0, DMAR_IEUADDR_REG, 0, 0, 0);
vtd_define_quad(VAR_0, DMAR_IOTLB_REG, 0, 0Xb003ffff00000000ULL, 0);
vtd_define_quad(VAR_0, DMAR_IVA_REG, 0, 0xfffffffffffff07fULL, 0);
vtd_define_quad_wo(VAR_0, DMAR_IVA_REG, 0xfffffffffffff07fULL);
vtd_define_quad(VAR_0, DMAR_FRCD_REG_0_0, 0, 0, 0);
vtd_define_quad(VAR_0, DMAR_FRCD_REG_0_2, 0, 0, 0x8000000000000000ULL);
}
| [
"static void FUNC_0(IntelIOMMUState *VAR_0)\n{",
"memset(VAR_0->csr, 0, DMAR_REG_SIZE);",
"memset(VAR_0->wmask, 0, DMAR_REG_SIZE);",
"memset(VAR_0->w1cmask, 0, DMAR_REG_SIZE);",
"memset(VAR_0->womask, 0, DMAR_REG_SIZE);",
"VAR_0->iommu_ops.translate = vtd_iommu_translate;",
"VAR_0->root = 0;",
"VAR_0->root_extended = false;",
"VAR_0->dmar_enabled = false;",
"VAR_0->iq_head = 0;",
"VAR_0->iq_tail = 0;",
"VAR_0->iq = 0;",
"VAR_0->iq_size = 0;",
"VAR_0->qi_enabled = false;",
"VAR_0->iq_last_desc_type = VTD_INV_DESC_NONE;",
"VAR_0->next_frcd_reg = 0;",
"VAR_0->cap = VTD_CAP_FRO | VTD_CAP_NFR | VTD_CAP_ND | VTD_CAP_MGAW |\nVTD_CAP_SAGAW | VTD_CAP_MAMV | VTD_CAP_PSI;",
"VAR_0->ecap = VTD_ECAP_QI | VTD_ECAP_IRO;",
"vtd_reset_context_cache(VAR_0);",
"vtd_reset_iotlb(VAR_0);",
"vtd_define_long(VAR_0, DMAR_VER_REG, 0x10UL, 0, 0);",
"vtd_define_quad(VAR_0, DMAR_CAP_REG, VAR_0->cap, 0, 0);",
"vtd_define_quad(VAR_0, DMAR_ECAP_REG, VAR_0->ecap, 0, 0);",
"vtd_define_long(VAR_0, DMAR_GCMD_REG, 0, 0xff800000UL, 0);",
"vtd_define_long_wo(VAR_0, DMAR_GCMD_REG, 0xff800000UL);",
"vtd_define_long(VAR_0, DMAR_GSTS_REG, 0, 0, 0);",
"vtd_define_quad(VAR_0, DMAR_RTADDR_REG, 0, 0xfffffffffffff000ULL, 0);",
"vtd_define_quad(VAR_0, DMAR_CCMD_REG, 0, 0xe0000003ffffffffULL, 0);",
"vtd_define_quad_wo(VAR_0, DMAR_CCMD_REG, 0x3ffff0000ULL);",
"vtd_define_long(VAR_0, DMAR_FSTS_REG, 0, 0, 0x11UL);",
"vtd_define_long(VAR_0, DMAR_FECTL_REG, 0x80000000UL, 0x80000000UL, 0);",
"vtd_define_long(VAR_0, DMAR_FEDATA_REG, 0, 0x0000ffffUL, 0);",
"vtd_define_long(VAR_0, DMAR_FEADDR_REG, 0, 0xfffffffcUL, 0);",
"vtd_define_long(VAR_0, DMAR_FEUADDR_REG, 0, 0, 0);",
"vtd_define_long(VAR_0, DMAR_PMEN_REG, 0, 0, 0);",
"vtd_define_quad(VAR_0, DMAR_IQH_REG, 0, 0, 0);",
"vtd_define_quad(VAR_0, DMAR_IQT_REG, 0, 0x7fff0ULL, 0);",
"vtd_define_quad(VAR_0, DMAR_IQA_REG, 0, 0xfffffffffffff007ULL, 0);",
"vtd_define_long(VAR_0, DMAR_ICS_REG, 0, 0, 0x1UL);",
"vtd_define_long(VAR_0, DMAR_IECTL_REG, 0x80000000UL, 0x80000000UL, 0);",
"vtd_define_long(VAR_0, DMAR_IEDATA_REG, 0, 0xffffffffUL, 0);",
"vtd_define_long(VAR_0, DMAR_IEADDR_REG, 0, 0xfffffffcUL, 0);",
"vtd_define_long(VAR_0, DMAR_IEUADDR_REG, 0, 0, 0);",
"vtd_define_quad(VAR_0, DMAR_IOTLB_REG, 0, 0Xb003ffff00000000ULL, 0);",
"vtd_define_quad(VAR_0, DMAR_IVA_REG, 0, 0xfffffffffffff07fULL, 0);",
"vtd_define_quad_wo(VAR_0, DMAR_IVA_REG, 0xfffffffffffff07fULL);",
"vtd_define_quad(VAR_0, DMAR_FRCD_REG_0_0, 0, 0, 0);",
"vtd_define_quad(VAR_0, DMAR_FRCD_REG_0_2, 0, 0, 0x8000000000000000ULL);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
45
],
[
47
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
75
],
[
77
],
[
79
],
[
81
],
[
91
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
129
],
[
131
],
[
133
],
[
139
],
[
141
],
[
143
]
] |
Subsets and Splits