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
|
---|---|---|---|---|---|---|---|---|---|---|
4,423 | void helper_discard_movcal_backup(CPUSH4State *env)
{
memory_content *current = env->movcal_backup;
while(current)
{
memory_content *next = current->next;
free (current);
env->movcal_backup = current = next;
if (current == NULL)
env->movcal_backup_tail = &(env->movcal_backup);
}
}
| true | qemu | 01a720125f5e2f0a23d2682b39dead2fcc820066 | void helper_discard_movcal_backup(CPUSH4State *env)
{
memory_content *current = env->movcal_backup;
while(current)
{
memory_content *next = current->next;
free (current);
env->movcal_backup = current = next;
if (current == NULL)
env->movcal_backup_tail = &(env->movcal_backup);
}
}
| {
"code": [
"\tfree (current);"
],
"line_no": [
15
]
} | void FUNC_0(CPUSH4State *VAR_0)
{
memory_content *current = VAR_0->movcal_backup;
while(current)
{
memory_content *next = current->next;
free (current);
VAR_0->movcal_backup = current = next;
if (current == NULL)
VAR_0->movcal_backup_tail = &(VAR_0->movcal_backup);
}
}
| [
"void FUNC_0(CPUSH4State *VAR_0)\n{",
"memory_content *current = VAR_0->movcal_backup;",
"while(current)\n{",
"memory_content *next = current->next;",
"free (current);",
"VAR_0->movcal_backup = current = next;",
"if (current == NULL)\nVAR_0->movcal_backup_tail = &(VAR_0->movcal_backup);",
"}",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
13
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
25
]
] |
4,425 | static FlatView *address_space_get_flatview(AddressSpace *as)
{
FlatView *view;
rcu_read_lock();
view = atomic_rcu_read(&as->current_map);
flatview_ref(view);
rcu_read_unlock();
return view;
}
| true | qemu | 447b0d0b9ee8a0ac216c3186e0f3c427a1001f0c | static FlatView *address_space_get_flatview(AddressSpace *as)
{
FlatView *view;
rcu_read_lock();
view = atomic_rcu_read(&as->current_map);
flatview_ref(view);
rcu_read_unlock();
return view;
}
| {
"code": [
" view = atomic_rcu_read(&as->current_map);",
" flatview_ref(view);"
],
"line_no": [
11,
13
]
} | static FlatView *FUNC_0(AddressSpace *as)
{
FlatView *view;
rcu_read_lock();
view = atomic_rcu_read(&as->current_map);
flatview_ref(view);
rcu_read_unlock();
return view;
}
| [
"static FlatView *FUNC_0(AddressSpace *as)\n{",
"FlatView *view;",
"rcu_read_lock();",
"view = atomic_rcu_read(&as->current_map);",
"flatview_ref(view);",
"rcu_read_unlock();",
"return view;",
"}"
] | [
0,
0,
0,
1,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
4,426 | static int dx2_decode_slice_444(GetBitContext *gb, AVFrame *frame,
int line, int left,
uint8_t lru[3][8])
{
int x, y;
int width = frame->width;
int ystride = frame->linesize[0];
int ustride = frame->linesize[1];
int vstride = frame->linesize[2];
uint8_t *Y = frame->data[0] + ystride * line;
uint8_t *U = frame->data[1] + ustride * line;
uint8_t *V = frame->data[2] + vstride * line;
for (y = 0; y < left && get_bits_left(gb) > 16; y++) {
for (x = 0; x < width; x++) {
Y[x] = decode_sym(gb, lru[0]);
U[x] = decode_sym(gb, lru[1]) ^ 0x80;
V[x] = decode_sym(gb, lru[2]) ^ 0x80;
}
Y += ystride;
U += ustride;
V += vstride;
}
return y;
}
| true | FFmpeg | 6e1a167c5564085385488b4f579e9efb987d4bfa | static int dx2_decode_slice_444(GetBitContext *gb, AVFrame *frame,
int line, int left,
uint8_t lru[3][8])
{
int x, y;
int width = frame->width;
int ystride = frame->linesize[0];
int ustride = frame->linesize[1];
int vstride = frame->linesize[2];
uint8_t *Y = frame->data[0] + ystride * line;
uint8_t *U = frame->data[1] + ustride * line;
uint8_t *V = frame->data[2] + vstride * line;
for (y = 0; y < left && get_bits_left(gb) > 16; y++) {
for (x = 0; x < width; x++) {
Y[x] = decode_sym(gb, lru[0]);
U[x] = decode_sym(gb, lru[1]) ^ 0x80;
V[x] = decode_sym(gb, lru[2]) ^ 0x80;
}
Y += ystride;
U += ustride;
V += vstride;
}
return y;
}
| {
"code": [
" for (y = 0; y < left && get_bits_left(gb) > 16; y++) {",
" for (y = 0; y < left && get_bits_left(gb) > 16; y++) {",
" for (y = 0; y < left && get_bits_left(gb) > 16; y++) {"
],
"line_no": [
33,
33,
33
]
} | static int FUNC_0(GetBitContext *VAR_0, AVFrame *VAR_1,
int VAR_2, int VAR_3,
uint8_t VAR_4[3][8])
{
int VAR_5, VAR_6;
int VAR_7 = VAR_1->VAR_7;
int VAR_8 = VAR_1->linesize[0];
int VAR_9 = VAR_1->linesize[1];
int VAR_10 = VAR_1->linesize[2];
uint8_t *Y = VAR_1->data[0] + VAR_8 * VAR_2;
uint8_t *U = VAR_1->data[1] + VAR_9 * VAR_2;
uint8_t *V = VAR_1->data[2] + VAR_10 * VAR_2;
for (VAR_6 = 0; VAR_6 < VAR_3 && get_bits_left(VAR_0) > 16; VAR_6++) {
for (VAR_5 = 0; VAR_5 < VAR_7; VAR_5++) {
Y[VAR_5] = decode_sym(VAR_0, VAR_4[0]);
U[VAR_5] = decode_sym(VAR_0, VAR_4[1]) ^ 0x80;
V[VAR_5] = decode_sym(VAR_0, VAR_4[2]) ^ 0x80;
}
Y += VAR_8;
U += VAR_9;
V += VAR_10;
}
return VAR_6;
}
| [
"static int FUNC_0(GetBitContext *VAR_0, AVFrame *VAR_1,\nint VAR_2, int VAR_3,\nuint8_t VAR_4[3][8])\n{",
"int VAR_5, VAR_6;",
"int VAR_7 = VAR_1->VAR_7;",
"int VAR_8 = VAR_1->linesize[0];",
"int VAR_9 = VAR_1->linesize[1];",
"int VAR_10 = VAR_1->linesize[2];",
"uint8_t *Y = VAR_1->data[0] + VAR_8 * VAR_2;",
"uint8_t *U = VAR_1->data[1] + VAR_9 * VAR_2;",
"uint8_t *V = VAR_1->data[2] + VAR_10 * VAR_2;",
"for (VAR_6 = 0; VAR_6 < VAR_3 && get_bits_left(VAR_0) > 16; VAR_6++) {",
"for (VAR_5 = 0; VAR_5 < VAR_7; VAR_5++) {",
"Y[VAR_5] = decode_sym(VAR_0, VAR_4[0]);",
"U[VAR_5] = decode_sym(VAR_0, VAR_4[1]) ^ 0x80;",
"V[VAR_5] = decode_sym(VAR_0, VAR_4[2]) ^ 0x80;",
"}",
"Y += VAR_8;",
"U += VAR_9;",
"V += VAR_10;",
"}",
"return VAR_6;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
]
] |
4,428 | static size_t qemu_rdma_fill(RDMAContext *rdma, uint8_t *buf,
int size, int idx)
{
size_t len = 0;
if (rdma->wr_data[idx].control_len) {
DDDPRINTF("RDMA %" PRId64 " of %d bytes already in buffer\n",
rdma->wr_data[idx].control_len, size);
len = MIN(size, rdma->wr_data[idx].control_len);
memcpy(buf, rdma->wr_data[idx].control_curr, len);
rdma->wr_data[idx].control_curr += len;
rdma->wr_data[idx].control_len -= len;
}
return len;
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | static size_t qemu_rdma_fill(RDMAContext *rdma, uint8_t *buf,
int size, int idx)
{
size_t len = 0;
if (rdma->wr_data[idx].control_len) {
DDDPRINTF("RDMA %" PRId64 " of %d bytes already in buffer\n",
rdma->wr_data[idx].control_len, size);
len = MIN(size, rdma->wr_data[idx].control_len);
memcpy(buf, rdma->wr_data[idx].control_curr, len);
rdma->wr_data[idx].control_curr += len;
rdma->wr_data[idx].control_len -= len;
}
return len;
}
| {
"code": [],
"line_no": []
} | static size_t FUNC_0(RDMAContext *rdma, uint8_t *buf,
int size, int idx)
{
size_t len = 0;
if (rdma->wr_data[idx].control_len) {
DDDPRINTF("RDMA %" PRId64 " of %d bytes already in buffer\n",
rdma->wr_data[idx].control_len, size);
len = MIN(size, rdma->wr_data[idx].control_len);
memcpy(buf, rdma->wr_data[idx].control_curr, len);
rdma->wr_data[idx].control_curr += len;
rdma->wr_data[idx].control_len -= len;
}
return len;
}
| [
"static size_t FUNC_0(RDMAContext *rdma, uint8_t *buf,\nint size, int idx)\n{",
"size_t len = 0;",
"if (rdma->wr_data[idx].control_len) {",
"DDDPRINTF(\"RDMA %\" PRId64 \" of %d bytes already in buffer\\n\",\nrdma->wr_data[idx].control_len, size);",
"len = MIN(size, rdma->wr_data[idx].control_len);",
"memcpy(buf, rdma->wr_data[idx].control_curr, len);",
"rdma->wr_data[idx].control_curr += len;",
"rdma->wr_data[idx].control_len -= len;",
"}",
"return len;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13,
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
]
] |
4,429 | static void new_audio_stream(AVFormatContext *oc, int file_idx)
{
AVStream *st;
AVOutputStream *ost;
AVCodec *codec= NULL;
AVCodecContext *audio_enc;
enum CodecID codec_id;
st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0);
if (!st) {
fprintf(stderr, "Could not alloc stream\n");
ffmpeg_exit(1);
}
ost = new_output_stream(oc, file_idx);
output_codecs = grow_array(output_codecs, sizeof(*output_codecs), &nb_output_codecs, nb_output_codecs + 1);
if(!audio_stream_copy){
if (audio_codec_name) {
codec_id = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1,
avcodec_opts[AVMEDIA_TYPE_AUDIO]->strict_std_compliance);
codec = avcodec_find_encoder_by_name(audio_codec_name);
output_codecs[nb_output_codecs-1] = codec;
} else {
codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_AUDIO);
codec = avcodec_find_encoder(codec_id);
}
}
avcodec_get_context_defaults3(st->codec, codec);
ost->bitstream_filters = audio_bitstream_filters;
audio_bitstream_filters= NULL;
avcodec_thread_init(st->codec, thread_count);
audio_enc = st->codec;
audio_enc->codec_type = AVMEDIA_TYPE_AUDIO;
if(audio_codec_tag)
audio_enc->codec_tag= audio_codec_tag;
if (oc->oformat->flags & AVFMT_GLOBALHEADER) {
audio_enc->flags |= CODEC_FLAG_GLOBAL_HEADER;
avcodec_opts[AVMEDIA_TYPE_AUDIO]->flags|= CODEC_FLAG_GLOBAL_HEADER;
}
if (audio_stream_copy) {
st->stream_copy = 1;
audio_enc->channels = audio_channels;
audio_enc->sample_rate = audio_sample_rate;
} else {
audio_enc->codec_id = codec_id;
set_context_opts(audio_enc, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec);
if (audio_qscale > QSCALE_NONE) {
audio_enc->flags |= CODEC_FLAG_QSCALE;
audio_enc->global_quality = st->quality = FF_QP2LAMBDA * audio_qscale;
}
audio_enc->channels = audio_channels;
audio_enc->sample_fmt = audio_sample_fmt;
audio_enc->sample_rate = audio_sample_rate;
audio_enc->channel_layout = channel_layout;
if (av_get_channel_layout_nb_channels(channel_layout) != audio_channels)
audio_enc->channel_layout = 0;
choose_sample_fmt(st, codec);
choose_sample_rate(st, codec);
}
audio_enc->time_base= (AVRational){1, audio_sample_rate};
if (audio_language) {
av_metadata_set2(&st->metadata, "language", audio_language, 0);
av_freep(&audio_language);
}
/* reset some key parameters */
audio_disable = 0;
av_freep(&audio_codec_name);
audio_stream_copy = 0;
}
| true | FFmpeg | 4618637aca3b771b0bfb8fe15f3a080dacf9f0c0 | static void new_audio_stream(AVFormatContext *oc, int file_idx)
{
AVStream *st;
AVOutputStream *ost;
AVCodec *codec= NULL;
AVCodecContext *audio_enc;
enum CodecID codec_id;
st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0);
if (!st) {
fprintf(stderr, "Could not alloc stream\n");
ffmpeg_exit(1);
}
ost = new_output_stream(oc, file_idx);
output_codecs = grow_array(output_codecs, sizeof(*output_codecs), &nb_output_codecs, nb_output_codecs + 1);
if(!audio_stream_copy){
if (audio_codec_name) {
codec_id = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1,
avcodec_opts[AVMEDIA_TYPE_AUDIO]->strict_std_compliance);
codec = avcodec_find_encoder_by_name(audio_codec_name);
output_codecs[nb_output_codecs-1] = codec;
} else {
codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_AUDIO);
codec = avcodec_find_encoder(codec_id);
}
}
avcodec_get_context_defaults3(st->codec, codec);
ost->bitstream_filters = audio_bitstream_filters;
audio_bitstream_filters= NULL;
avcodec_thread_init(st->codec, thread_count);
audio_enc = st->codec;
audio_enc->codec_type = AVMEDIA_TYPE_AUDIO;
if(audio_codec_tag)
audio_enc->codec_tag= audio_codec_tag;
if (oc->oformat->flags & AVFMT_GLOBALHEADER) {
audio_enc->flags |= CODEC_FLAG_GLOBAL_HEADER;
avcodec_opts[AVMEDIA_TYPE_AUDIO]->flags|= CODEC_FLAG_GLOBAL_HEADER;
}
if (audio_stream_copy) {
st->stream_copy = 1;
audio_enc->channels = audio_channels;
audio_enc->sample_rate = audio_sample_rate;
} else {
audio_enc->codec_id = codec_id;
set_context_opts(audio_enc, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec);
if (audio_qscale > QSCALE_NONE) {
audio_enc->flags |= CODEC_FLAG_QSCALE;
audio_enc->global_quality = st->quality = FF_QP2LAMBDA * audio_qscale;
}
audio_enc->channels = audio_channels;
audio_enc->sample_fmt = audio_sample_fmt;
audio_enc->sample_rate = audio_sample_rate;
audio_enc->channel_layout = channel_layout;
if (av_get_channel_layout_nb_channels(channel_layout) != audio_channels)
audio_enc->channel_layout = 0;
choose_sample_fmt(st, codec);
choose_sample_rate(st, codec);
}
audio_enc->time_base= (AVRational){1, audio_sample_rate};
if (audio_language) {
av_metadata_set2(&st->metadata, "language", audio_language, 0);
av_freep(&audio_language);
}
audio_disable = 0;
av_freep(&audio_codec_name);
audio_stream_copy = 0;
}
| {
"code": [
" enum CodecID codec_id;",
" enum CodecID codec_id;",
" enum CodecID codec_id;"
],
"line_no": [
13,
13,
13
]
} | static void FUNC_0(AVFormatContext *VAR_0, int VAR_1)
{
AVStream *st;
AVOutputStream *ost;
AVCodec *codec= NULL;
AVCodecContext *audio_enc;
enum CodecID VAR_2;
st = av_new_stream(VAR_0, VAR_0->nb_streams < nb_streamid_map ? streamid_map[VAR_0->nb_streams] : 0);
if (!st) {
fprintf(stderr, "Could not alloc stream\n");
ffmpeg_exit(1);
}
ost = new_output_stream(VAR_0, VAR_1);
output_codecs = grow_array(output_codecs, sizeof(*output_codecs), &nb_output_codecs, nb_output_codecs + 1);
if(!audio_stream_copy){
if (audio_codec_name) {
VAR_2 = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1,
avcodec_opts[AVMEDIA_TYPE_AUDIO]->strict_std_compliance);
codec = avcodec_find_encoder_by_name(audio_codec_name);
output_codecs[nb_output_codecs-1] = codec;
} else {
VAR_2 = av_guess_codec(VAR_0->oformat, NULL, VAR_0->filename, NULL, AVMEDIA_TYPE_AUDIO);
codec = avcodec_find_encoder(VAR_2);
}
}
avcodec_get_context_defaults3(st->codec, codec);
ost->bitstream_filters = audio_bitstream_filters;
audio_bitstream_filters= NULL;
avcodec_thread_init(st->codec, thread_count);
audio_enc = st->codec;
audio_enc->codec_type = AVMEDIA_TYPE_AUDIO;
if(audio_codec_tag)
audio_enc->codec_tag= audio_codec_tag;
if (VAR_0->oformat->flags & AVFMT_GLOBALHEADER) {
audio_enc->flags |= CODEC_FLAG_GLOBAL_HEADER;
avcodec_opts[AVMEDIA_TYPE_AUDIO]->flags|= CODEC_FLAG_GLOBAL_HEADER;
}
if (audio_stream_copy) {
st->stream_copy = 1;
audio_enc->channels = audio_channels;
audio_enc->sample_rate = audio_sample_rate;
} else {
audio_enc->VAR_2 = VAR_2;
set_context_opts(audio_enc, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec);
if (audio_qscale > QSCALE_NONE) {
audio_enc->flags |= CODEC_FLAG_QSCALE;
audio_enc->global_quality = st->quality = FF_QP2LAMBDA * audio_qscale;
}
audio_enc->channels = audio_channels;
audio_enc->sample_fmt = audio_sample_fmt;
audio_enc->sample_rate = audio_sample_rate;
audio_enc->channel_layout = channel_layout;
if (av_get_channel_layout_nb_channels(channel_layout) != audio_channels)
audio_enc->channel_layout = 0;
choose_sample_fmt(st, codec);
choose_sample_rate(st, codec);
}
audio_enc->time_base= (AVRational){1, audio_sample_rate};
if (audio_language) {
av_metadata_set2(&st->metadata, "language", audio_language, 0);
av_freep(&audio_language);
}
audio_disable = 0;
av_freep(&audio_codec_name);
audio_stream_copy = 0;
}
| [
"static void FUNC_0(AVFormatContext *VAR_0, int VAR_1)\n{",
"AVStream *st;",
"AVOutputStream *ost;",
"AVCodec *codec= NULL;",
"AVCodecContext *audio_enc;",
"enum CodecID VAR_2;",
"st = av_new_stream(VAR_0, VAR_0->nb_streams < nb_streamid_map ? streamid_map[VAR_0->nb_streams] : 0);",
"if (!st) {",
"fprintf(stderr, \"Could not alloc stream\\n\");",
"ffmpeg_exit(1);",
"}",
"ost = new_output_stream(VAR_0, VAR_1);",
"output_codecs = grow_array(output_codecs, sizeof(*output_codecs), &nb_output_codecs, nb_output_codecs + 1);",
"if(!audio_stream_copy){",
"if (audio_codec_name) {",
"VAR_2 = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1,\navcodec_opts[AVMEDIA_TYPE_AUDIO]->strict_std_compliance);",
"codec = avcodec_find_encoder_by_name(audio_codec_name);",
"output_codecs[nb_output_codecs-1] = codec;",
"} else {",
"VAR_2 = av_guess_codec(VAR_0->oformat, NULL, VAR_0->filename, NULL, AVMEDIA_TYPE_AUDIO);",
"codec = avcodec_find_encoder(VAR_2);",
"}",
"}",
"avcodec_get_context_defaults3(st->codec, codec);",
"ost->bitstream_filters = audio_bitstream_filters;",
"audio_bitstream_filters= NULL;",
"avcodec_thread_init(st->codec, thread_count);",
"audio_enc = st->codec;",
"audio_enc->codec_type = AVMEDIA_TYPE_AUDIO;",
"if(audio_codec_tag)\naudio_enc->codec_tag= audio_codec_tag;",
"if (VAR_0->oformat->flags & AVFMT_GLOBALHEADER) {",
"audio_enc->flags |= CODEC_FLAG_GLOBAL_HEADER;",
"avcodec_opts[AVMEDIA_TYPE_AUDIO]->flags|= CODEC_FLAG_GLOBAL_HEADER;",
"}",
"if (audio_stream_copy) {",
"st->stream_copy = 1;",
"audio_enc->channels = audio_channels;",
"audio_enc->sample_rate = audio_sample_rate;",
"} else {",
"audio_enc->VAR_2 = VAR_2;",
"set_context_opts(audio_enc, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec);",
"if (audio_qscale > QSCALE_NONE) {",
"audio_enc->flags |= CODEC_FLAG_QSCALE;",
"audio_enc->global_quality = st->quality = FF_QP2LAMBDA * audio_qscale;",
"}",
"audio_enc->channels = audio_channels;",
"audio_enc->sample_fmt = audio_sample_fmt;",
"audio_enc->sample_rate = audio_sample_rate;",
"audio_enc->channel_layout = channel_layout;",
"if (av_get_channel_layout_nb_channels(channel_layout) != audio_channels)\naudio_enc->channel_layout = 0;",
"choose_sample_fmt(st, codec);",
"choose_sample_rate(st, codec);",
"}",
"audio_enc->time_base= (AVRational){1, audio_sample_rate};",
"if (audio_language) {",
"av_metadata_set2(&st->metadata, \"language\", audio_language, 0);",
"av_freep(&audio_language);",
"}",
"audio_disable = 0;",
"av_freep(&audio_codec_name);",
"audio_stream_copy = 0;",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
61
],
[
63
],
[
67
],
[
71
],
[
73
],
[
77,
79
],
[
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
],
[
147
],
[
149
],
[
151
],
[
153
]
] |
4,430 | uint32_t helper_efdctuf (uint64_t val)
{
CPU_DoubleU u;
float64 tmp;
u.ll = val;
/* NaN are not treated the same way IEEE 754 does */
if (unlikely(float64_is_nan(u.d)))
return 0;
tmp = uint64_to_float64(1ULL << 32, &env->vec_status);
u.d = float64_mul(u.d, tmp, &env->vec_status);
return float64_to_uint32(u.d, &env->vec_status);
}
| false | qemu | 185698715dfb18c82ad2a5dbc169908602d43e81 | uint32_t helper_efdctuf (uint64_t val)
{
CPU_DoubleU u;
float64 tmp;
u.ll = val;
if (unlikely(float64_is_nan(u.d)))
return 0;
tmp = uint64_to_float64(1ULL << 32, &env->vec_status);
u.d = float64_mul(u.d, tmp, &env->vec_status);
return float64_to_uint32(u.d, &env->vec_status);
}
| {
"code": [],
"line_no": []
} | uint32_t FUNC_0 (uint64_t val)
{
CPU_DoubleU u;
float64 tmp;
u.ll = val;
if (unlikely(float64_is_nan(u.d)))
return 0;
tmp = uint64_to_float64(1ULL << 32, &env->vec_status);
u.d = float64_mul(u.d, tmp, &env->vec_status);
return float64_to_uint32(u.d, &env->vec_status);
}
| [
"uint32_t FUNC_0 (uint64_t val)\n{",
"CPU_DoubleU u;",
"float64 tmp;",
"u.ll = val;",
"if (unlikely(float64_is_nan(u.d)))\nreturn 0;",
"tmp = uint64_to_float64(1ULL << 32, &env->vec_status);",
"u.d = float64_mul(u.d, tmp, &env->vec_status);",
"return float64_to_uint32(u.d, &env->vec_status);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15,
17
],
[
19
],
[
21
],
[
25
],
[
27
]
] |
4,431 | static void bt_dummy_lmp_disconnect_master(struct bt_link_s *link)
{
fprintf(stderr, "%s: stray LMP_detach received, fixme\n", __func__);
exit(-1);
}
| false | qemu | bf937a7965c1d1a6dce4f615d0ead2e2ab505004 | static void bt_dummy_lmp_disconnect_master(struct bt_link_s *link)
{
fprintf(stderr, "%s: stray LMP_detach received, fixme\n", __func__);
exit(-1);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(struct bt_link_s *VAR_0)
{
fprintf(stderr, "%s: stray LMP_detach received, fixme\n", __func__);
exit(-1);
}
| [
"static void FUNC_0(struct bt_link_s *VAR_0)\n{",
"fprintf(stderr, \"%s: stray LMP_detach received, fixme\\n\", __func__);",
"exit(-1);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
4,432 | static CharDriverState *qemu_chr_open_win_path(const char *filename)
{
CharDriverState *chr;
WinCharState *s;
chr = g_malloc0(sizeof(CharDriverState));
s = g_malloc0(sizeof(WinCharState));
chr->opaque = s;
chr->chr_write = win_chr_write;
chr->chr_close = win_chr_close;
if (win_chr_init(chr, filename) < 0) {
g_free(s);
g_free(chr);
return NULL;
}
qemu_chr_be_generic_open(chr);
return chr;
}
| false | qemu | bd5c51ee6c4f1c79cae5ad2516d711a27b4ea8ec | static CharDriverState *qemu_chr_open_win_path(const char *filename)
{
CharDriverState *chr;
WinCharState *s;
chr = g_malloc0(sizeof(CharDriverState));
s = g_malloc0(sizeof(WinCharState));
chr->opaque = s;
chr->chr_write = win_chr_write;
chr->chr_close = win_chr_close;
if (win_chr_init(chr, filename) < 0) {
g_free(s);
g_free(chr);
return NULL;
}
qemu_chr_be_generic_open(chr);
return chr;
}
| {
"code": [],
"line_no": []
} | static CharDriverState *FUNC_0(const char *filename)
{
CharDriverState *chr;
WinCharState *s;
chr = g_malloc0(sizeof(CharDriverState));
s = g_malloc0(sizeof(WinCharState));
chr->opaque = s;
chr->chr_write = win_chr_write;
chr->chr_close = win_chr_close;
if (win_chr_init(chr, filename) < 0) {
g_free(s);
g_free(chr);
return NULL;
}
qemu_chr_be_generic_open(chr);
return chr;
}
| [
"static CharDriverState *FUNC_0(const char *filename)\n{",
"CharDriverState *chr;",
"WinCharState *s;",
"chr = g_malloc0(sizeof(CharDriverState));",
"s = g_malloc0(sizeof(WinCharState));",
"chr->opaque = s;",
"chr->chr_write = win_chr_write;",
"chr->chr_close = win_chr_close;",
"if (win_chr_init(chr, filename) < 0) {",
"g_free(s);",
"g_free(chr);",
"return NULL;",
"}",
"qemu_chr_be_generic_open(chr);",
"return chr;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
]
] |
4,433 | void HELPER(pka)(CPUS390XState *env, uint64_t dest, uint64_t src,
uint32_t srclen)
{
uintptr_t ra = GETPC();
int i;
/* The destination operand is always 16 bytes long. */
const int destlen = 16;
/* The operands are processed from right to left. */
src += srclen - 1;
dest += destlen - 1;
for (i = 0; i < destlen; i++) {
uint8_t b = 0;
/* Start with a positive sign */
if (i == 0) {
b = 0xc;
} else if (srclen > 1) {
b = cpu_ldub_data_ra(env, src, ra) & 0x0f;
src--;
srclen--;
}
if (srclen > 1) {
b |= cpu_ldub_data_ra(env, src, ra) << 4;
src--;
srclen--;
}
cpu_stb_data_ra(env, dest, b, ra);
dest--;
}
}
| false | qemu | 4e256bef6552ee0b4c0c844077b44e4c7fcc05fc | void HELPER(pka)(CPUS390XState *env, uint64_t dest, uint64_t src,
uint32_t srclen)
{
uintptr_t ra = GETPC();
int i;
const int destlen = 16;
src += srclen - 1;
dest += destlen - 1;
for (i = 0; i < destlen; i++) {
uint8_t b = 0;
if (i == 0) {
b = 0xc;
} else if (srclen > 1) {
b = cpu_ldub_data_ra(env, src, ra) & 0x0f;
src--;
srclen--;
}
if (srclen > 1) {
b |= cpu_ldub_data_ra(env, src, ra) << 4;
src--;
srclen--;
}
cpu_stb_data_ra(env, dest, b, ra);
dest--;
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(pka)(CPUS390XState *env, uint64_t dest, uint64_t src,
uint32_t srclen)
{
uintptr_t ra = GETPC();
int VAR_0;
const int VAR_1 = 16;
src += srclen - 1;
dest += VAR_1 - 1;
for (VAR_0 = 0; VAR_0 < VAR_1; VAR_0++) {
uint8_t b = 0;
if (VAR_0 == 0) {
b = 0xc;
} else if (srclen > 1) {
b = cpu_ldub_data_ra(env, src, ra) & 0x0f;
src--;
srclen--;
}
if (srclen > 1) {
b |= cpu_ldub_data_ra(env, src, ra) << 4;
src--;
srclen--;
}
cpu_stb_data_ra(env, dest, b, ra);
dest--;
}
}
| [
"void FUNC_0(pka)(CPUS390XState *env, uint64_t dest, uint64_t src,\nuint32_t srclen)\n{",
"uintptr_t ra = GETPC();",
"int VAR_0;",
"const int VAR_1 = 16;",
"src += srclen - 1;",
"dest += VAR_1 - 1;",
"for (VAR_0 = 0; VAR_0 < VAR_1; VAR_0++) {",
"uint8_t b = 0;",
"if (VAR_0 == 0) {",
"b = 0xc;",
"} else if (srclen > 1) {",
"b = cpu_ldub_data_ra(env, src, ra) & 0x0f;",
"src--;",
"srclen--;",
"}",
"if (srclen > 1) {",
"b |= cpu_ldub_data_ra(env, src, ra) << 4;",
"src--;",
"srclen--;",
"}",
"cpu_stb_data_ra(env, dest, b, ra);",
"dest--;",
"}",
"}"
] | [
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
],
[
19
],
[
21
],
[
25
],
[
27
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
]
] |
4,434 | static void piix3_update_irq_levels(PIIX3State *piix3)
{
int pirq;
piix3->pic_levels = 0;
for (pirq = 0; pirq < PIIX_NUM_PIRQS; pirq++) {
piix3_set_irq_level(piix3, pirq,
pci_bus_get_irq_level(piix3->dev.bus, pirq));
}
}
| false | qemu | fd56e0612b6454a282fa6a953fdb09281a98c589 | static void piix3_update_irq_levels(PIIX3State *piix3)
{
int pirq;
piix3->pic_levels = 0;
for (pirq = 0; pirq < PIIX_NUM_PIRQS; pirq++) {
piix3_set_irq_level(piix3, pirq,
pci_bus_get_irq_level(piix3->dev.bus, pirq));
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(PIIX3State *VAR_0)
{
int VAR_1;
VAR_0->pic_levels = 0;
for (VAR_1 = 0; VAR_1 < PIIX_NUM_PIRQS; VAR_1++) {
piix3_set_irq_level(VAR_0, VAR_1,
pci_bus_get_irq_level(VAR_0->dev.bus, VAR_1));
}
}
| [
"static void FUNC_0(PIIX3State *VAR_0)\n{",
"int VAR_1;",
"VAR_0->pic_levels = 0;",
"for (VAR_1 = 0; VAR_1 < PIIX_NUM_PIRQS; VAR_1++) {",
"piix3_set_irq_level(VAR_0, VAR_1,\npci_bus_get_irq_level(VAR_0->dev.bus, VAR_1));",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13,
15
],
[
17
],
[
19
]
] |
4,435 | static int get_pci_config_device(QEMUFile *f, void *pv, size_t size)
{
PCIDevice *s = container_of(pv, PCIDevice, config);
uint8_t *config;
int i;
assert(size == pci_config_size(s));
config = qemu_malloc(size);
qemu_get_buffer(f, config, size);
for (i = 0; i < size; ++i) {
if ((config[i] ^ s->config[i]) & s->cmask[i] & ~s->wmask[i]) {
qemu_free(config);
return -EINVAL;
}
}
memcpy(s->config, config, size);
pci_update_mappings(s);
qemu_free(config);
return 0;
}
| false | qemu | f9aebe2ef52ff0dcb733999f57e00a7b430303c6 | static int get_pci_config_device(QEMUFile *f, void *pv, size_t size)
{
PCIDevice *s = container_of(pv, PCIDevice, config);
uint8_t *config;
int i;
assert(size == pci_config_size(s));
config = qemu_malloc(size);
qemu_get_buffer(f, config, size);
for (i = 0; i < size; ++i) {
if ((config[i] ^ s->config[i]) & s->cmask[i] & ~s->wmask[i]) {
qemu_free(config);
return -EINVAL;
}
}
memcpy(s->config, config, size);
pci_update_mappings(s);
qemu_free(config);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2)
{
PCIDevice *s = container_of(VAR_1, PCIDevice, config);
uint8_t *config;
int VAR_3;
assert(VAR_2 == pci_config_size(s));
config = qemu_malloc(VAR_2);
qemu_get_buffer(VAR_0, config, VAR_2);
for (VAR_3 = 0; VAR_3 < VAR_2; ++VAR_3) {
if ((config[VAR_3] ^ s->config[VAR_3]) & s->cmask[VAR_3] & ~s->wmask[VAR_3]) {
qemu_free(config);
return -EINVAL;
}
}
memcpy(s->config, config, VAR_2);
pci_update_mappings(s);
qemu_free(config);
return 0;
}
| [
"static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2)\n{",
"PCIDevice *s = container_of(VAR_1, PCIDevice, config);",
"uint8_t *config;",
"int VAR_3;",
"assert(VAR_2 == pci_config_size(s));",
"config = qemu_malloc(VAR_2);",
"qemu_get_buffer(VAR_0, config, VAR_2);",
"for (VAR_3 = 0; VAR_3 < VAR_2; ++VAR_3) {",
"if ((config[VAR_3] ^ s->config[VAR_3]) & s->cmask[VAR_3] & ~s->wmask[VAR_3]) {",
"qemu_free(config);",
"return -EINVAL;",
"}",
"}",
"memcpy(s->config, config, VAR_2);",
"pci_update_mappings(s);",
"qemu_free(config);",
"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
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
41
],
[
43
],
[
45
]
] |
4,436 | static int smacker_decode_tree(GetBitContext *gb, HuffContext *hc, uint32_t prefix, int length)
{
if(length > 32) {
av_log(NULL, AV_LOG_ERROR, "length too long\n");
return AVERROR_INVALIDDATA;
}
if(!get_bits1(gb)){ //Leaf
if(hc->current >= 256){
av_log(NULL, AV_LOG_ERROR, "Tree size exceeded!\n");
return AVERROR_INVALIDDATA;
}
if(length){
hc->bits[hc->current] = prefix;
hc->lengths[hc->current] = length;
} else {
hc->bits[hc->current] = 0;
hc->lengths[hc->current] = 0;
}
hc->values[hc->current] = get_bits(gb, 8);
hc->current++;
if(hc->maxlength < length)
hc->maxlength = length;
return 0;
} else { //Node
int r;
length++;
r = smacker_decode_tree(gb, hc, prefix, length);
if(r)
return r;
return smacker_decode_tree(gb, hc, prefix | (1 << (length - 1)), length);
}
}
| false | FFmpeg | 2c69fcc2ffe671649e56dc981e9f4cd9d46a61be | static int smacker_decode_tree(GetBitContext *gb, HuffContext *hc, uint32_t prefix, int length)
{
if(length > 32) {
av_log(NULL, AV_LOG_ERROR, "length too long\n");
return AVERROR_INVALIDDATA;
}
if(!get_bits1(gb)){
if(hc->current >= 256){
av_log(NULL, AV_LOG_ERROR, "Tree size exceeded!\n");
return AVERROR_INVALIDDATA;
}
if(length){
hc->bits[hc->current] = prefix;
hc->lengths[hc->current] = length;
} else {
hc->bits[hc->current] = 0;
hc->lengths[hc->current] = 0;
}
hc->values[hc->current] = get_bits(gb, 8);
hc->current++;
if(hc->maxlength < length)
hc->maxlength = length;
return 0;
} else {
int r;
length++;
r = smacker_decode_tree(gb, hc, prefix, length);
if(r)
return r;
return smacker_decode_tree(gb, hc, prefix | (1 << (length - 1)), length);
}
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(GetBitContext *VAR_0, HuffContext *VAR_1, uint32_t VAR_2, int VAR_3)
{
if(VAR_3 > 32) {
av_log(NULL, AV_LOG_ERROR, "VAR_3 too long\n");
return AVERROR_INVALIDDATA;
}
if(!get_bits1(VAR_0)){
if(VAR_1->current >= 256){
av_log(NULL, AV_LOG_ERROR, "Tree size exceeded!\n");
return AVERROR_INVALIDDATA;
}
if(VAR_3){
VAR_1->bits[VAR_1->current] = VAR_2;
VAR_1->lengths[VAR_1->current] = VAR_3;
} else {
VAR_1->bits[VAR_1->current] = 0;
VAR_1->lengths[VAR_1->current] = 0;
}
VAR_1->values[VAR_1->current] = get_bits(VAR_0, 8);
VAR_1->current++;
if(VAR_1->maxlength < VAR_3)
VAR_1->maxlength = VAR_3;
return 0;
} else {
int VAR_4;
VAR_3++;
VAR_4 = FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3);
if(VAR_4)
return VAR_4;
return FUNC_0(VAR_0, VAR_1, VAR_2 | (1 << (VAR_3 - 1)), VAR_3);
}
}
| [
"static int FUNC_0(GetBitContext *VAR_0, HuffContext *VAR_1, uint32_t VAR_2, int VAR_3)\n{",
"if(VAR_3 > 32) {",
"av_log(NULL, AV_LOG_ERROR, \"VAR_3 too long\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if(!get_bits1(VAR_0)){",
"if(VAR_1->current >= 256){",
"av_log(NULL, AV_LOG_ERROR, \"Tree size exceeded!\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if(VAR_3){",
"VAR_1->bits[VAR_1->current] = VAR_2;",
"VAR_1->lengths[VAR_1->current] = VAR_3;",
"} else {",
"VAR_1->bits[VAR_1->current] = 0;",
"VAR_1->lengths[VAR_1->current] = 0;",
"}",
"VAR_1->values[VAR_1->current] = get_bits(VAR_0, 8);",
"VAR_1->current++;",
"if(VAR_1->maxlength < VAR_3)\nVAR_1->maxlength = VAR_3;",
"return 0;",
"} else {",
"int VAR_4;",
"VAR_3++;",
"VAR_4 = FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3);",
"if(VAR_4)\nreturn VAR_4;",
"return FUNC_0(VAR_0, VAR_1, VAR_2 | (1 << (VAR_3 - 1)), VAR_3);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
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
]
] |
4,437 | static void usb_hub_handle_attach(USBDevice *dev)
{
USBHubState *s = DO_UPCAST(USBHubState, dev, dev);
int i;
for (i = 0; i < NUM_PORTS; i++) {
usb_port_location(&s->ports[i].port, dev->port, i+1);
}
}
| false | qemu | 891fb2cd4592b6fe76106a69e0ca40efbf82726a | static void usb_hub_handle_attach(USBDevice *dev)
{
USBHubState *s = DO_UPCAST(USBHubState, dev, dev);
int i;
for (i = 0; i < NUM_PORTS; i++) {
usb_port_location(&s->ports[i].port, dev->port, i+1);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(USBDevice *VAR_0)
{
USBHubState *s = DO_UPCAST(USBHubState, VAR_0, VAR_0);
int VAR_1;
for (VAR_1 = 0; VAR_1 < NUM_PORTS; VAR_1++) {
usb_port_location(&s->ports[VAR_1].port, VAR_0->port, VAR_1+1);
}
}
| [
"static void FUNC_0(USBDevice *VAR_0)\n{",
"USBHubState *s = DO_UPCAST(USBHubState, VAR_0, VAR_0);",
"int VAR_1;",
"for (VAR_1 = 0; VAR_1 < NUM_PORTS; VAR_1++) {",
"usb_port_location(&s->ports[VAR_1].port, VAR_0->port, VAR_1+1);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
4,438 | static void __attribute__((destructor)) coroutine_pool_cleanup(void)
{
Coroutine *co;
Coroutine *tmp;
QSLIST_FOREACH_SAFE(co, &pool, pool_next, tmp) {
QSLIST_REMOVE_HEAD(&pool, pool_next);
qemu_coroutine_delete(co);
}
qemu_mutex_destroy(&pool_lock);
}
| false | qemu | 4d68e86bb10159099da0798f74e7512955f15eec | static void __attribute__((destructor)) coroutine_pool_cleanup(void)
{
Coroutine *co;
Coroutine *tmp;
QSLIST_FOREACH_SAFE(co, &pool, pool_next, tmp) {
QSLIST_REMOVE_HEAD(&pool, pool_next);
qemu_coroutine_delete(co);
}
qemu_mutex_destroy(&pool_lock);
}
| {
"code": [],
"line_no": []
} | static void __attribute__((destructor)) FUNC_0(void)
{
Coroutine *co;
Coroutine *tmp;
QSLIST_FOREACH_SAFE(co, &pool, pool_next, tmp) {
QSLIST_REMOVE_HEAD(&pool, pool_next);
qemu_coroutine_delete(co);
}
qemu_mutex_destroy(&pool_lock);
}
| [
"static void __attribute__((destructor)) FUNC_0(void)\n{",
"Coroutine *co;",
"Coroutine *tmp;",
"QSLIST_FOREACH_SAFE(co, &pool, pool_next, tmp) {",
"QSLIST_REMOVE_HEAD(&pool, pool_next);",
"qemu_coroutine_delete(co);",
"}",
"qemu_mutex_destroy(&pool_lock);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
]
] |
4,439 | pvscsi_on_cmd_setup_rings(PVSCSIState *s)
{
PVSCSICmdDescSetupRings *rc =
(PVSCSICmdDescSetupRings *) s->curr_cmd_data;
trace_pvscsi_on_cmd_arrived("PVSCSI_CMD_SETUP_RINGS");
pvscsi_dbg_dump_tx_rings_config(rc);
if (pvscsi_ring_init_data(&s->rings, rc) < 0) {
return PVSCSI_COMMAND_PROCESSING_FAILED;
}
s->rings_info_valid = TRUE;
return PVSCSI_COMMAND_PROCESSING_SUCCEEDED;
}
| false | qemu | 7f61f4690dd153be98900a2a508b88989e692753 | pvscsi_on_cmd_setup_rings(PVSCSIState *s)
{
PVSCSICmdDescSetupRings *rc =
(PVSCSICmdDescSetupRings *) s->curr_cmd_data;
trace_pvscsi_on_cmd_arrived("PVSCSI_CMD_SETUP_RINGS");
pvscsi_dbg_dump_tx_rings_config(rc);
if (pvscsi_ring_init_data(&s->rings, rc) < 0) {
return PVSCSI_COMMAND_PROCESSING_FAILED;
}
s->rings_info_valid = TRUE;
return PVSCSI_COMMAND_PROCESSING_SUCCEEDED;
}
| {
"code": [],
"line_no": []
} | FUNC_0(PVSCSIState *VAR_0)
{
PVSCSICmdDescSetupRings *rc =
(PVSCSICmdDescSetupRings *) VAR_0->curr_cmd_data;
trace_pvscsi_on_cmd_arrived("PVSCSI_CMD_SETUP_RINGS");
pvscsi_dbg_dump_tx_rings_config(rc);
if (pvscsi_ring_init_data(&VAR_0->rings, rc) < 0) {
return PVSCSI_COMMAND_PROCESSING_FAILED;
}
VAR_0->rings_info_valid = TRUE;
return PVSCSI_COMMAND_PROCESSING_SUCCEEDED;
}
| [
"FUNC_0(PVSCSIState *VAR_0)\n{",
"PVSCSICmdDescSetupRings *rc =\n(PVSCSICmdDescSetupRings *) VAR_0->curr_cmd_data;",
"trace_pvscsi_on_cmd_arrived(\"PVSCSI_CMD_SETUP_RINGS\");",
"pvscsi_dbg_dump_tx_rings_config(rc);",
"if (pvscsi_ring_init_data(&VAR_0->rings, rc) < 0) {",
"return PVSCSI_COMMAND_PROCESSING_FAILED;",
"}",
"VAR_0->rings_info_valid = TRUE;",
"return PVSCSI_COMMAND_PROCESSING_SUCCEEDED;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
]
] |
4,441 | static void omap1_mpu_reset(void *opaque)
{
struct omap_mpu_state_s *mpu = (struct omap_mpu_state_s *) opaque;
omap_inth_reset(mpu->ih[0]);
omap_inth_reset(mpu->ih[1]);
omap_dma_reset(mpu->dma);
omap_mpu_timer_reset(mpu->timer[0]);
omap_mpu_timer_reset(mpu->timer[1]);
omap_mpu_timer_reset(mpu->timer[2]);
omap_wd_timer_reset(mpu->wdt);
omap_os_timer_reset(mpu->os_timer);
omap_lcdc_reset(mpu->lcd);
omap_ulpd_pm_reset(mpu);
omap_pin_cfg_reset(mpu);
omap_mpui_reset(mpu);
omap_tipb_bridge_reset(mpu->private_tipb);
omap_tipb_bridge_reset(mpu->public_tipb);
omap_dpll_reset(&mpu->dpll[0]);
omap_dpll_reset(&mpu->dpll[1]);
omap_dpll_reset(&mpu->dpll[2]);
omap_uart_reset(mpu->uart[0]);
omap_uart_reset(mpu->uart[1]);
omap_uart_reset(mpu->uart[2]);
omap_mmc_reset(mpu->mmc);
omap_mpuio_reset(mpu->mpuio);
omap_uwire_reset(mpu->microwire);
omap_pwl_reset(mpu);
omap_pwt_reset(mpu);
omap_i2c_reset(mpu->i2c[0]);
omap_rtc_reset(mpu->rtc);
omap_mcbsp_reset(mpu->mcbsp1);
omap_mcbsp_reset(mpu->mcbsp2);
omap_mcbsp_reset(mpu->mcbsp3);
omap_lpg_reset(mpu->led[0]);
omap_lpg_reset(mpu->led[1]);
omap_clkm_reset(mpu);
cpu_reset(mpu->env);
}
| false | qemu | 0919ac787641db11024912651f3bc5764d4f1286 | static void omap1_mpu_reset(void *opaque)
{
struct omap_mpu_state_s *mpu = (struct omap_mpu_state_s *) opaque;
omap_inth_reset(mpu->ih[0]);
omap_inth_reset(mpu->ih[1]);
omap_dma_reset(mpu->dma);
omap_mpu_timer_reset(mpu->timer[0]);
omap_mpu_timer_reset(mpu->timer[1]);
omap_mpu_timer_reset(mpu->timer[2]);
omap_wd_timer_reset(mpu->wdt);
omap_os_timer_reset(mpu->os_timer);
omap_lcdc_reset(mpu->lcd);
omap_ulpd_pm_reset(mpu);
omap_pin_cfg_reset(mpu);
omap_mpui_reset(mpu);
omap_tipb_bridge_reset(mpu->private_tipb);
omap_tipb_bridge_reset(mpu->public_tipb);
omap_dpll_reset(&mpu->dpll[0]);
omap_dpll_reset(&mpu->dpll[1]);
omap_dpll_reset(&mpu->dpll[2]);
omap_uart_reset(mpu->uart[0]);
omap_uart_reset(mpu->uart[1]);
omap_uart_reset(mpu->uart[2]);
omap_mmc_reset(mpu->mmc);
omap_mpuio_reset(mpu->mpuio);
omap_uwire_reset(mpu->microwire);
omap_pwl_reset(mpu);
omap_pwt_reset(mpu);
omap_i2c_reset(mpu->i2c[0]);
omap_rtc_reset(mpu->rtc);
omap_mcbsp_reset(mpu->mcbsp1);
omap_mcbsp_reset(mpu->mcbsp2);
omap_mcbsp_reset(mpu->mcbsp3);
omap_lpg_reset(mpu->led[0]);
omap_lpg_reset(mpu->led[1]);
omap_clkm_reset(mpu);
cpu_reset(mpu->env);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
struct omap_mpu_state_s *VAR_1 = (struct omap_mpu_state_s *) VAR_0;
omap_inth_reset(VAR_1->ih[0]);
omap_inth_reset(VAR_1->ih[1]);
omap_dma_reset(VAR_1->dma);
omap_mpu_timer_reset(VAR_1->timer[0]);
omap_mpu_timer_reset(VAR_1->timer[1]);
omap_mpu_timer_reset(VAR_1->timer[2]);
omap_wd_timer_reset(VAR_1->wdt);
omap_os_timer_reset(VAR_1->os_timer);
omap_lcdc_reset(VAR_1->lcd);
omap_ulpd_pm_reset(VAR_1);
omap_pin_cfg_reset(VAR_1);
omap_mpui_reset(VAR_1);
omap_tipb_bridge_reset(VAR_1->private_tipb);
omap_tipb_bridge_reset(VAR_1->public_tipb);
omap_dpll_reset(&VAR_1->dpll[0]);
omap_dpll_reset(&VAR_1->dpll[1]);
omap_dpll_reset(&VAR_1->dpll[2]);
omap_uart_reset(VAR_1->uart[0]);
omap_uart_reset(VAR_1->uart[1]);
omap_uart_reset(VAR_1->uart[2]);
omap_mmc_reset(VAR_1->mmc);
omap_mpuio_reset(VAR_1->mpuio);
omap_uwire_reset(VAR_1->microwire);
omap_pwl_reset(VAR_1);
omap_pwt_reset(VAR_1);
omap_i2c_reset(VAR_1->i2c[0]);
omap_rtc_reset(VAR_1->rtc);
omap_mcbsp_reset(VAR_1->mcbsp1);
omap_mcbsp_reset(VAR_1->mcbsp2);
omap_mcbsp_reset(VAR_1->mcbsp3);
omap_lpg_reset(VAR_1->led[0]);
omap_lpg_reset(VAR_1->led[1]);
omap_clkm_reset(VAR_1);
cpu_reset(VAR_1->env);
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"struct omap_mpu_state_s *VAR_1 = (struct omap_mpu_state_s *) VAR_0;",
"omap_inth_reset(VAR_1->ih[0]);",
"omap_inth_reset(VAR_1->ih[1]);",
"omap_dma_reset(VAR_1->dma);",
"omap_mpu_timer_reset(VAR_1->timer[0]);",
"omap_mpu_timer_reset(VAR_1->timer[1]);",
"omap_mpu_timer_reset(VAR_1->timer[2]);",
"omap_wd_timer_reset(VAR_1->wdt);",
"omap_os_timer_reset(VAR_1->os_timer);",
"omap_lcdc_reset(VAR_1->lcd);",
"omap_ulpd_pm_reset(VAR_1);",
"omap_pin_cfg_reset(VAR_1);",
"omap_mpui_reset(VAR_1);",
"omap_tipb_bridge_reset(VAR_1->private_tipb);",
"omap_tipb_bridge_reset(VAR_1->public_tipb);",
"omap_dpll_reset(&VAR_1->dpll[0]);",
"omap_dpll_reset(&VAR_1->dpll[1]);",
"omap_dpll_reset(&VAR_1->dpll[2]);",
"omap_uart_reset(VAR_1->uart[0]);",
"omap_uart_reset(VAR_1->uart[1]);",
"omap_uart_reset(VAR_1->uart[2]);",
"omap_mmc_reset(VAR_1->mmc);",
"omap_mpuio_reset(VAR_1->mpuio);",
"omap_uwire_reset(VAR_1->microwire);",
"omap_pwl_reset(VAR_1);",
"omap_pwt_reset(VAR_1);",
"omap_i2c_reset(VAR_1->i2c[0]);",
"omap_rtc_reset(VAR_1->rtc);",
"omap_mcbsp_reset(VAR_1->mcbsp1);",
"omap_mcbsp_reset(VAR_1->mcbsp2);",
"omap_mcbsp_reset(VAR_1->mcbsp3);",
"omap_lpg_reset(VAR_1->led[0]);",
"omap_lpg_reset(VAR_1->led[1]);",
"omap_clkm_reset(VAR_1);",
"cpu_reset(VAR_1->env);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
]
] |
4,444 | size_t slirp_socket_can_recv(struct in_addr guest_addr, int guest_port)
{
struct iovec iov[2];
struct socket *so;
if (!link_up)
return 0;
so = slirp_find_ctl_socket(guest_addr, guest_port);
if (!so || so->so_state & SS_NOFDREF)
return 0;
if (!CONN_CANFRCV(so) || so->so_snd.sb_cc >= (so->so_snd.sb_datalen/2))
return 0;
return sopreprbuf(so, iov, NULL);
}
| false | qemu | b5302e1a9d8a47bd29a3e1876fba34be111728a2 | size_t slirp_socket_can_recv(struct in_addr guest_addr, int guest_port)
{
struct iovec iov[2];
struct socket *so;
if (!link_up)
return 0;
so = slirp_find_ctl_socket(guest_addr, guest_port);
if (!so || so->so_state & SS_NOFDREF)
return 0;
if (!CONN_CANFRCV(so) || so->so_snd.sb_cc >= (so->so_snd.sb_datalen/2))
return 0;
return sopreprbuf(so, iov, NULL);
}
| {
"code": [],
"line_no": []
} | size_t FUNC_0(struct in_addr guest_addr, int guest_port)
{
struct iovec VAR_0[2];
struct socket *VAR_1;
if (!link_up)
return 0;
VAR_1 = slirp_find_ctl_socket(guest_addr, guest_port);
if (!VAR_1 || VAR_1->so_state & SS_NOFDREF)
return 0;
if (!CONN_CANFRCV(VAR_1) || VAR_1->so_snd.sb_cc >= (VAR_1->so_snd.sb_datalen/2))
return 0;
return sopreprbuf(VAR_1, VAR_0, NULL);
}
| [
"size_t FUNC_0(struct in_addr guest_addr, int guest_port)\n{",
"struct iovec VAR_0[2];",
"struct socket *VAR_1;",
"if (!link_up)\nreturn 0;",
"VAR_1 = slirp_find_ctl_socket(guest_addr, guest_port);",
"if (!VAR_1 || VAR_1->so_state & SS_NOFDREF)\nreturn 0;",
"if (!CONN_CANFRCV(VAR_1) || VAR_1->so_snd.sb_cc >= (VAR_1->so_snd.sb_datalen/2))\nreturn 0;",
"return sopreprbuf(VAR_1, VAR_0, NULL);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
17
],
[
21,
23
],
[
27,
29
],
[
33
],
[
35
]
] |
4,445 | static int bdrv_open_common(BlockDriverState *bs, const char *filename,
int flags, BlockDriver *drv)
{
int ret, open_flags;
assert(drv != NULL);
trace_bdrv_open_common(bs, filename, flags, drv->format_name);
bs->file = NULL;
bs->total_sectors = 0;
bs->encrypted = 0;
bs->valid_key = 0;
bs->open_flags = flags;
bs->buffer_alignment = 512;
pstrcpy(bs->filename, sizeof(bs->filename), filename);
if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv)) {
return -ENOTSUP;
}
bs->drv = drv;
bs->opaque = g_malloc0(drv->instance_size);
if (flags & BDRV_O_CACHE_WB)
bs->enable_write_cache = 1;
/*
* Clear flags that are internal to the block layer before opening the
* image.
*/
open_flags = flags & ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);
/*
* Snapshots should be writable.
*/
if (bs->is_temporary) {
open_flags |= BDRV_O_RDWR;
}
/* Open the image, either directly or using a protocol */
if (drv->bdrv_file_open) {
ret = drv->bdrv_file_open(bs, filename, open_flags);
} else {
ret = bdrv_file_open(&bs->file, filename, open_flags);
if (ret >= 0) {
ret = drv->bdrv_open(bs, open_flags);
}
}
if (ret < 0) {
goto free_and_fail;
}
bs->keep_read_only = bs->read_only = !(open_flags & BDRV_O_RDWR);
ret = refresh_total_sectors(bs, bs->total_sectors);
if (ret < 0) {
goto free_and_fail;
}
#ifndef _WIN32
if (bs->is_temporary) {
unlink(filename);
}
#endif
return 0;
free_and_fail:
if (bs->file) {
bdrv_delete(bs->file);
bs->file = NULL;
}
g_free(bs->opaque);
bs->opaque = NULL;
bs->drv = NULL;
return ret;
}
| false | qemu | e7c637967e6aad195b5f30cfd995913c9e0b4666 | static int bdrv_open_common(BlockDriverState *bs, const char *filename,
int flags, BlockDriver *drv)
{
int ret, open_flags;
assert(drv != NULL);
trace_bdrv_open_common(bs, filename, flags, drv->format_name);
bs->file = NULL;
bs->total_sectors = 0;
bs->encrypted = 0;
bs->valid_key = 0;
bs->open_flags = flags;
bs->buffer_alignment = 512;
pstrcpy(bs->filename, sizeof(bs->filename), filename);
if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv)) {
return -ENOTSUP;
}
bs->drv = drv;
bs->opaque = g_malloc0(drv->instance_size);
if (flags & BDRV_O_CACHE_WB)
bs->enable_write_cache = 1;
open_flags = flags & ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);
if (bs->is_temporary) {
open_flags |= BDRV_O_RDWR;
}
if (drv->bdrv_file_open) {
ret = drv->bdrv_file_open(bs, filename, open_flags);
} else {
ret = bdrv_file_open(&bs->file, filename, open_flags);
if (ret >= 0) {
ret = drv->bdrv_open(bs, open_flags);
}
}
if (ret < 0) {
goto free_and_fail;
}
bs->keep_read_only = bs->read_only = !(open_flags & BDRV_O_RDWR);
ret = refresh_total_sectors(bs, bs->total_sectors);
if (ret < 0) {
goto free_and_fail;
}
#ifndef _WIN32
if (bs->is_temporary) {
unlink(filename);
}
#endif
return 0;
free_and_fail:
if (bs->file) {
bdrv_delete(bs->file);
bs->file = NULL;
}
g_free(bs->opaque);
bs->opaque = NULL;
bs->drv = NULL;
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, const char *VAR_1,
int VAR_2, BlockDriver *VAR_3)
{
int VAR_4, VAR_5;
assert(VAR_3 != NULL);
trace_bdrv_open_common(VAR_0, VAR_1, VAR_2, VAR_3->format_name);
VAR_0->file = NULL;
VAR_0->total_sectors = 0;
VAR_0->encrypted = 0;
VAR_0->valid_key = 0;
VAR_0->VAR_5 = VAR_2;
VAR_0->buffer_alignment = 512;
pstrcpy(VAR_0->VAR_1, sizeof(VAR_0->VAR_1), VAR_1);
if (use_bdrv_whitelist && !bdrv_is_whitelisted(VAR_3)) {
return -ENOTSUP;
}
VAR_0->VAR_3 = VAR_3;
VAR_0->opaque = g_malloc0(VAR_3->instance_size);
if (VAR_2 & BDRV_O_CACHE_WB)
VAR_0->enable_write_cache = 1;
VAR_5 = VAR_2 & ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);
if (VAR_0->is_temporary) {
VAR_5 |= BDRV_O_RDWR;
}
if (VAR_3->bdrv_file_open) {
VAR_4 = VAR_3->bdrv_file_open(VAR_0, VAR_1, VAR_5);
} else {
VAR_4 = bdrv_file_open(&VAR_0->file, VAR_1, VAR_5);
if (VAR_4 >= 0) {
VAR_4 = VAR_3->bdrv_open(VAR_0, VAR_5);
}
}
if (VAR_4 < 0) {
goto free_and_fail;
}
VAR_0->keep_read_only = VAR_0->read_only = !(VAR_5 & BDRV_O_RDWR);
VAR_4 = refresh_total_sectors(VAR_0, VAR_0->total_sectors);
if (VAR_4 < 0) {
goto free_and_fail;
}
#ifndef _WIN32
if (VAR_0->is_temporary) {
unlink(VAR_1);
}
#endif
return 0;
free_and_fail:
if (VAR_0->file) {
bdrv_delete(VAR_0->file);
VAR_0->file = NULL;
}
g_free(VAR_0->opaque);
VAR_0->opaque = NULL;
VAR_0->VAR_3 = NULL;
return VAR_4;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, const char *VAR_1,\nint VAR_2, BlockDriver *VAR_3)\n{",
"int VAR_4, VAR_5;",
"assert(VAR_3 != NULL);",
"trace_bdrv_open_common(VAR_0, VAR_1, VAR_2, VAR_3->format_name);",
"VAR_0->file = NULL;",
"VAR_0->total_sectors = 0;",
"VAR_0->encrypted = 0;",
"VAR_0->valid_key = 0;",
"VAR_0->VAR_5 = VAR_2;",
"VAR_0->buffer_alignment = 512;",
"pstrcpy(VAR_0->VAR_1, sizeof(VAR_0->VAR_1), VAR_1);",
"if (use_bdrv_whitelist && !bdrv_is_whitelisted(VAR_3)) {",
"return -ENOTSUP;",
"}",
"VAR_0->VAR_3 = VAR_3;",
"VAR_0->opaque = g_malloc0(VAR_3->instance_size);",
"if (VAR_2 & BDRV_O_CACHE_WB)\nVAR_0->enable_write_cache = 1;",
"VAR_5 = VAR_2 & ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);",
"if (VAR_0->is_temporary) {",
"VAR_5 |= BDRV_O_RDWR;",
"}",
"if (VAR_3->bdrv_file_open) {",
"VAR_4 = VAR_3->bdrv_file_open(VAR_0, VAR_1, VAR_5);",
"} else {",
"VAR_4 = bdrv_file_open(&VAR_0->file, VAR_1, VAR_5);",
"if (VAR_4 >= 0) {",
"VAR_4 = VAR_3->bdrv_open(VAR_0, VAR_5);",
"}",
"}",
"if (VAR_4 < 0) {",
"goto free_and_fail;",
"}",
"VAR_0->keep_read_only = VAR_0->read_only = !(VAR_5 & BDRV_O_RDWR);",
"VAR_4 = refresh_total_sectors(VAR_0, VAR_0->total_sectors);",
"if (VAR_4 < 0) {",
"goto free_and_fail;",
"}",
"#ifndef _WIN32\nif (VAR_0->is_temporary) {",
"unlink(VAR_1);",
"}",
"#endif\nreturn 0;",
"free_and_fail:\nif (VAR_0->file) {",
"bdrv_delete(VAR_0->file);",
"VAR_0->file = NULL;",
"}",
"g_free(VAR_0->opaque);",
"VAR_0->opaque = NULL;",
"VAR_0->VAR_3 = 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
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
51,
53
],
[
65
],
[
75
],
[
77
],
[
79
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125,
127
],
[
129
],
[
131
],
[
133,
135
],
[
139,
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
]
] |
4,446 | static void qxl_log_cmd_draw_copy(PCIQXLDevice *qxl, QXLCopy *copy, int group_id)
{
fprintf(stderr, " src %" PRIx64,
copy->src_bitmap);
qxl_log_image(qxl, copy->src_bitmap, group_id);
fprintf(stderr, " area");
qxl_log_rect(©->src_area);
fprintf(stderr, " rop %d", copy->rop_descriptor);
}
| false | qemu | fae2afb10e3fdceab612c62a2b1e8b944ff578d9 | static void qxl_log_cmd_draw_copy(PCIQXLDevice *qxl, QXLCopy *copy, int group_id)
{
fprintf(stderr, " src %" PRIx64,
copy->src_bitmap);
qxl_log_image(qxl, copy->src_bitmap, group_id);
fprintf(stderr, " area");
qxl_log_rect(©->src_area);
fprintf(stderr, " rop %d", copy->rop_descriptor);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(PCIQXLDevice *VAR_0, QXLCopy *VAR_1, int VAR_2)
{
fprintf(stderr, " src %" PRIx64,
VAR_1->src_bitmap);
qxl_log_image(VAR_0, VAR_1->src_bitmap, VAR_2);
fprintf(stderr, " area");
qxl_log_rect(&VAR_1->src_area);
fprintf(stderr, " rop %d", VAR_1->rop_descriptor);
}
| [
"static void FUNC_0(PCIQXLDevice *VAR_0, QXLCopy *VAR_1, int VAR_2)\n{",
"fprintf(stderr, \" src %\" PRIx64,\nVAR_1->src_bitmap);",
"qxl_log_image(VAR_0, VAR_1->src_bitmap, VAR_2);",
"fprintf(stderr, \" area\");",
"qxl_log_rect(&VAR_1->src_area);",
"fprintf(stderr, \" rop %d\", VAR_1->rop_descriptor);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
4,448 | int qemu_paio_cancel(int fd, struct qemu_paiocb *aiocb)
{
int ret;
pthread_mutex_lock(&lock);
if (!aiocb->active) {
TAILQ_REMOVE(&request_list, aiocb, node);
aiocb->ret = -ECANCELED;
ret = QEMU_PAIO_CANCELED;
} else if (aiocb->ret == -EINPROGRESS)
ret = QEMU_PAIO_NOTCANCELED;
else
ret = QEMU_PAIO_ALLDONE;
pthread_mutex_unlock(&lock);
return ret;
}
| false | qemu | 8653c0158c23ec592f0041ab48b83d6cc6d152fe | int qemu_paio_cancel(int fd, struct qemu_paiocb *aiocb)
{
int ret;
pthread_mutex_lock(&lock);
if (!aiocb->active) {
TAILQ_REMOVE(&request_list, aiocb, node);
aiocb->ret = -ECANCELED;
ret = QEMU_PAIO_CANCELED;
} else if (aiocb->ret == -EINPROGRESS)
ret = QEMU_PAIO_NOTCANCELED;
else
ret = QEMU_PAIO_ALLDONE;
pthread_mutex_unlock(&lock);
return ret;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(int VAR_0, struct qemu_paiocb *VAR_1)
{
int VAR_2;
pthread_mutex_lock(&lock);
if (!VAR_1->active) {
TAILQ_REMOVE(&request_list, VAR_1, node);
VAR_1->VAR_2 = -ECANCELED;
VAR_2 = QEMU_PAIO_CANCELED;
} else if (VAR_1->VAR_2 == -EINPROGRESS)
VAR_2 = QEMU_PAIO_NOTCANCELED;
else
VAR_2 = QEMU_PAIO_ALLDONE;
pthread_mutex_unlock(&lock);
return VAR_2;
}
| [
"int FUNC_0(int VAR_0, struct qemu_paiocb *VAR_1)\n{",
"int VAR_2;",
"pthread_mutex_lock(&lock);",
"if (!VAR_1->active) {",
"TAILQ_REMOVE(&request_list, VAR_1, node);",
"VAR_1->VAR_2 = -ECANCELED;",
"VAR_2 = QEMU_PAIO_CANCELED;",
"} else if (VAR_1->VAR_2 == -EINPROGRESS)",
"VAR_2 = QEMU_PAIO_NOTCANCELED;",
"else\nVAR_2 = QEMU_PAIO_ALLDONE;",
"pthread_mutex_unlock(&lock);",
"return VAR_2;",
"}"
] | [
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
],
[
31
],
[
33
]
] |
4,449 | int qdev_unplug(DeviceState *dev)
{
if (!dev->parent_bus->allow_hotplug) {
qerror_report(QERR_BUS_NO_HOTPLUG, dev->parent_bus->name);
return -1;
}
assert(dev->info->unplug != NULL);
if (dev->ref != 0) {
qerror_report(QERR_DEVICE_IN_USE, dev->id?:"");
return -1;
}
qdev_hot_removed = true;
return dev->info->unplug(dev);
}
| false | qemu | 024a6fbdb9d8cbc4d7f833b23db51c9d1004bc47 | int qdev_unplug(DeviceState *dev)
{
if (!dev->parent_bus->allow_hotplug) {
qerror_report(QERR_BUS_NO_HOTPLUG, dev->parent_bus->name);
return -1;
}
assert(dev->info->unplug != NULL);
if (dev->ref != 0) {
qerror_report(QERR_DEVICE_IN_USE, dev->id?:"");
return -1;
}
qdev_hot_removed = true;
return dev->info->unplug(dev);
}
| {
"code": [],
"line_no": []
} | int FUNC_0(DeviceState *VAR_0)
{
if (!VAR_0->parent_bus->allow_hotplug) {
qerror_report(QERR_BUS_NO_HOTPLUG, VAR_0->parent_bus->name);
return -1;
}
assert(VAR_0->info->unplug != NULL);
if (VAR_0->ref != 0) {
qerror_report(QERR_DEVICE_IN_USE, VAR_0->id?:"");
return -1;
}
qdev_hot_removed = true;
return VAR_0->info->unplug(VAR_0);
}
| [
"int FUNC_0(DeviceState *VAR_0)\n{",
"if (!VAR_0->parent_bus->allow_hotplug) {",
"qerror_report(QERR_BUS_NO_HOTPLUG, VAR_0->parent_bus->name);",
"return -1;",
"}",
"assert(VAR_0->info->unplug != NULL);",
"if (VAR_0->ref != 0) {",
"qerror_report(QERR_DEVICE_IN_USE, VAR_0->id?:\"\");",
"return -1;",
"}",
"qdev_hot_removed = true;",
"return VAR_0->info->unplug(VAR_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
],
[
31
],
[
33
]
] |
4,450 | int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg,
PCIDevice *dev)
{
struct kvm_irq_routing_entry kroute = {};
if (kvm_gsi_direct_mapping()) {
return 0;
}
if (!kvm_irqchip_in_kernel()) {
return -ENOSYS;
}
kroute.gsi = virq;
kroute.type = KVM_IRQ_ROUTING_MSI;
kroute.flags = 0;
kroute.u.msi.address_lo = (uint32_t)msg.address;
kroute.u.msi.address_hi = msg.address >> 32;
kroute.u.msi.data = le32_to_cpu(msg.data);
if (kvm_msi_devid_required()) {
kroute.flags = KVM_MSI_VALID_DEVID;
kroute.u.msi.devid = pci_requester_id(dev);
}
if (kvm_arch_fixup_msi_route(&kroute, msg.address, msg.data, dev)) {
return -EINVAL;
}
trace_kvm_irqchip_update_msi_route(virq);
return kvm_update_routing_entry(s, &kroute);
}
| false | qemu | 88c725c78e87eecb061f882177c7a6a2ac1059ad | int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg,
PCIDevice *dev)
{
struct kvm_irq_routing_entry kroute = {};
if (kvm_gsi_direct_mapping()) {
return 0;
}
if (!kvm_irqchip_in_kernel()) {
return -ENOSYS;
}
kroute.gsi = virq;
kroute.type = KVM_IRQ_ROUTING_MSI;
kroute.flags = 0;
kroute.u.msi.address_lo = (uint32_t)msg.address;
kroute.u.msi.address_hi = msg.address >> 32;
kroute.u.msi.data = le32_to_cpu(msg.data);
if (kvm_msi_devid_required()) {
kroute.flags = KVM_MSI_VALID_DEVID;
kroute.u.msi.devid = pci_requester_id(dev);
}
if (kvm_arch_fixup_msi_route(&kroute, msg.address, msg.data, dev)) {
return -EINVAL;
}
trace_kvm_irqchip_update_msi_route(virq);
return kvm_update_routing_entry(s, &kroute);
}
| {
"code": [],
"line_no": []
} | int FUNC_0(KVMState *VAR_0, int VAR_1, MSIMessage VAR_2,
PCIDevice *VAR_3)
{
struct kvm_irq_routing_entry VAR_4 = {};
if (kvm_gsi_direct_mapping()) {
return 0;
}
if (!kvm_irqchip_in_kernel()) {
return -ENOSYS;
}
VAR_4.gsi = VAR_1;
VAR_4.type = KVM_IRQ_ROUTING_MSI;
VAR_4.flags = 0;
VAR_4.u.msi.address_lo = (uint32_t)VAR_2.address;
VAR_4.u.msi.address_hi = VAR_2.address >> 32;
VAR_4.u.msi.data = le32_to_cpu(VAR_2.data);
if (kvm_msi_devid_required()) {
VAR_4.flags = KVM_MSI_VALID_DEVID;
VAR_4.u.msi.devid = pci_requester_id(VAR_3);
}
if (kvm_arch_fixup_msi_route(&VAR_4, VAR_2.address, VAR_2.data, VAR_3)) {
return -EINVAL;
}
trace_kvm_irqchip_update_msi_route(VAR_1);
return kvm_update_routing_entry(VAR_0, &VAR_4);
}
| [
"int FUNC_0(KVMState *VAR_0, int VAR_1, MSIMessage VAR_2,\nPCIDevice *VAR_3)\n{",
"struct kvm_irq_routing_entry VAR_4 = {};",
"if (kvm_gsi_direct_mapping()) {",
"return 0;",
"}",
"if (!kvm_irqchip_in_kernel()) {",
"return -ENOSYS;",
"}",
"VAR_4.gsi = VAR_1;",
"VAR_4.type = KVM_IRQ_ROUTING_MSI;",
"VAR_4.flags = 0;",
"VAR_4.u.msi.address_lo = (uint32_t)VAR_2.address;",
"VAR_4.u.msi.address_hi = VAR_2.address >> 32;",
"VAR_4.u.msi.data = le32_to_cpu(VAR_2.data);",
"if (kvm_msi_devid_required()) {",
"VAR_4.flags = KVM_MSI_VALID_DEVID;",
"VAR_4.u.msi.devid = pci_requester_id(VAR_3);",
"}",
"if (kvm_arch_fixup_msi_route(&VAR_4, VAR_2.address, VAR_2.data, VAR_3)) {",
"return -EINVAL;",
"}",
"trace_kvm_irqchip_update_msi_route(VAR_1);",
"return kvm_update_routing_entry(VAR_0, &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
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
59
],
[
61
]
] |
4,451 | static const MemoryRegionPortio *find_portio(MemoryRegion *mr, uint64_t offset,
unsigned width, bool write)
{
const MemoryRegionPortio *mrp;
for (mrp = mr->ops->old_portio; mrp->size; ++mrp) {
if (offset >= mrp->offset && offset < mrp->offset + mrp->len
&& width == mrp->size
&& (write ? (bool)mrp->write : (bool)mrp->read)) {
return mrp;
}
}
return NULL;
}
| false | qemu | b40acf99bef69fa8ab0f9092ff162fde945eec12 | static const MemoryRegionPortio *find_portio(MemoryRegion *mr, uint64_t offset,
unsigned width, bool write)
{
const MemoryRegionPortio *mrp;
for (mrp = mr->ops->old_portio; mrp->size; ++mrp) {
if (offset >= mrp->offset && offset < mrp->offset + mrp->len
&& width == mrp->size
&& (write ? (bool)mrp->write : (bool)mrp->read)) {
return mrp;
}
}
return NULL;
}
| {
"code": [],
"line_no": []
} | static const MemoryRegionPortio *FUNC_0(MemoryRegion *mr, uint64_t offset,
unsigned width, bool write)
{
const MemoryRegionPortio *VAR_0;
for (VAR_0 = mr->ops->old_portio; VAR_0->size; ++VAR_0) {
if (offset >= VAR_0->offset && offset < VAR_0->offset + VAR_0->len
&& width == VAR_0->size
&& (write ? (bool)VAR_0->write : (bool)VAR_0->read)) {
return VAR_0;
}
}
return NULL;
}
| [
"static const MemoryRegionPortio *FUNC_0(MemoryRegion *mr, uint64_t offset,\nunsigned width, bool write)\n{",
"const MemoryRegionPortio *VAR_0;",
"for (VAR_0 = mr->ops->old_portio; VAR_0->size; ++VAR_0) {",
"if (offset >= VAR_0->offset && offset < VAR_0->offset + VAR_0->len\n&& width == VAR_0->size\n&& (write ? (bool)VAR_0->write : (bool)VAR_0->read)) {",
"return VAR_0;",
"}",
"}",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13,
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
4,452 | static void gen_mftr(CPUMIPSState *env, DisasContext *ctx, int rt, int rd,
int u, int sel, int h)
{
int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
TCGv t0 = tcg_temp_local_new();
if ((env->CP0_VPEConf0 & (1 << CP0VPEC0_MVP)) == 0 &&
((env->tcs[other_tc].CP0_TCBind & (0xf << CP0TCBd_CurVPE)) !=
(env->active_tc.CP0_TCBind & (0xf << CP0TCBd_CurVPE))))
tcg_gen_movi_tl(t0, -1);
else if ((env->CP0_VPEControl & (0xff << CP0VPECo_TargTC)) >
(env->mvp->CP0_MVPConf0 & (0xff << CP0MVPC0_PTC)))
tcg_gen_movi_tl(t0, -1);
else if (u == 0) {
switch (rt) {
case 1:
switch (sel) {
case 1:
gen_helper_mftc0_vpecontrol(t0, cpu_env);
break;
case 2:
gen_helper_mftc0_vpeconf0(t0, cpu_env);
break;
default:
goto die;
break;
}
break;
case 2:
switch (sel) {
case 1:
gen_helper_mftc0_tcstatus(t0, cpu_env);
break;
case 2:
gen_helper_mftc0_tcbind(t0, cpu_env);
break;
case 3:
gen_helper_mftc0_tcrestart(t0, cpu_env);
break;
case 4:
gen_helper_mftc0_tchalt(t0, cpu_env);
break;
case 5:
gen_helper_mftc0_tccontext(t0, cpu_env);
break;
case 6:
gen_helper_mftc0_tcschedule(t0, cpu_env);
break;
case 7:
gen_helper_mftc0_tcschefback(t0, cpu_env);
break;
default:
gen_mfc0(ctx, t0, rt, sel);
break;
}
break;
case 10:
switch (sel) {
case 0:
gen_helper_mftc0_entryhi(t0, cpu_env);
break;
default:
gen_mfc0(ctx, t0, rt, sel);
break;
}
case 12:
switch (sel) {
case 0:
gen_helper_mftc0_status(t0, cpu_env);
break;
default:
gen_mfc0(ctx, t0, rt, sel);
break;
}
case 13:
switch (sel) {
case 0:
gen_helper_mftc0_cause(t0, cpu_env);
break;
default:
goto die;
break;
}
break;
case 14:
switch (sel) {
case 0:
gen_helper_mftc0_epc(t0, cpu_env);
break;
default:
goto die;
break;
}
break;
case 15:
switch (sel) {
case 1:
gen_helper_mftc0_ebase(t0, cpu_env);
break;
default:
goto die;
break;
}
break;
case 16:
switch (sel) {
case 0 ... 7:
gen_helper_mftc0_configx(t0, cpu_env, tcg_const_tl(sel));
break;
default:
goto die;
break;
}
break;
case 23:
switch (sel) {
case 0:
gen_helper_mftc0_debug(t0, cpu_env);
break;
default:
gen_mfc0(ctx, t0, rt, sel);
break;
}
break;
default:
gen_mfc0(ctx, t0, rt, sel);
}
} else switch (sel) {
/* GPR registers. */
case 0:
gen_helper_1e0i(mftgpr, t0, rt);
break;
/* Auxiliary CPU registers */
case 1:
switch (rt) {
case 0:
gen_helper_1e0i(mftlo, t0, 0);
break;
case 1:
gen_helper_1e0i(mfthi, t0, 0);
break;
case 2:
gen_helper_1e0i(mftacx, t0, 0);
break;
case 4:
gen_helper_1e0i(mftlo, t0, 1);
break;
case 5:
gen_helper_1e0i(mfthi, t0, 1);
break;
case 6:
gen_helper_1e0i(mftacx, t0, 1);
break;
case 8:
gen_helper_1e0i(mftlo, t0, 2);
break;
case 9:
gen_helper_1e0i(mfthi, t0, 2);
break;
case 10:
gen_helper_1e0i(mftacx, t0, 2);
break;
case 12:
gen_helper_1e0i(mftlo, t0, 3);
break;
case 13:
gen_helper_1e0i(mfthi, t0, 3);
break;
case 14:
gen_helper_1e0i(mftacx, t0, 3);
break;
case 16:
gen_helper_mftdsp(t0, cpu_env);
break;
default:
goto die;
}
break;
/* Floating point (COP1). */
case 2:
/* XXX: For now we support only a single FPU context. */
if (h == 0) {
TCGv_i32 fp0 = tcg_temp_new_i32();
gen_load_fpr32(fp0, rt);
tcg_gen_ext_i32_tl(t0, fp0);
tcg_temp_free_i32(fp0);
} else {
TCGv_i32 fp0 = tcg_temp_new_i32();
gen_load_fpr32h(fp0, rt);
tcg_gen_ext_i32_tl(t0, fp0);
tcg_temp_free_i32(fp0);
}
break;
case 3:
/* XXX: For now we support only a single FPU context. */
gen_helper_1e0i(cfc1, t0, rt);
break;
/* COP2: Not implemented. */
case 4:
case 5:
/* fall through */
default:
goto die;
}
LOG_DISAS("mftr (reg %d u %d sel %d h %d)\n", rt, u, sel, h);
gen_store_gpr(t0, rd);
tcg_temp_free(t0);
return;
die:
tcg_temp_free(t0);
LOG_DISAS("mftr (reg %d u %d sel %d h %d)\n", rt, u, sel, h);
generate_exception(ctx, EXCP_RI);
}
| false | qemu | 7f6613cedc59fa849105668ae971dc31004bca1c | static void gen_mftr(CPUMIPSState *env, DisasContext *ctx, int rt, int rd,
int u, int sel, int h)
{
int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
TCGv t0 = tcg_temp_local_new();
if ((env->CP0_VPEConf0 & (1 << CP0VPEC0_MVP)) == 0 &&
((env->tcs[other_tc].CP0_TCBind & (0xf << CP0TCBd_CurVPE)) !=
(env->active_tc.CP0_TCBind & (0xf << CP0TCBd_CurVPE))))
tcg_gen_movi_tl(t0, -1);
else if ((env->CP0_VPEControl & (0xff << CP0VPECo_TargTC)) >
(env->mvp->CP0_MVPConf0 & (0xff << CP0MVPC0_PTC)))
tcg_gen_movi_tl(t0, -1);
else if (u == 0) {
switch (rt) {
case 1:
switch (sel) {
case 1:
gen_helper_mftc0_vpecontrol(t0, cpu_env);
break;
case 2:
gen_helper_mftc0_vpeconf0(t0, cpu_env);
break;
default:
goto die;
break;
}
break;
case 2:
switch (sel) {
case 1:
gen_helper_mftc0_tcstatus(t0, cpu_env);
break;
case 2:
gen_helper_mftc0_tcbind(t0, cpu_env);
break;
case 3:
gen_helper_mftc0_tcrestart(t0, cpu_env);
break;
case 4:
gen_helper_mftc0_tchalt(t0, cpu_env);
break;
case 5:
gen_helper_mftc0_tccontext(t0, cpu_env);
break;
case 6:
gen_helper_mftc0_tcschedule(t0, cpu_env);
break;
case 7:
gen_helper_mftc0_tcschefback(t0, cpu_env);
break;
default:
gen_mfc0(ctx, t0, rt, sel);
break;
}
break;
case 10:
switch (sel) {
case 0:
gen_helper_mftc0_entryhi(t0, cpu_env);
break;
default:
gen_mfc0(ctx, t0, rt, sel);
break;
}
case 12:
switch (sel) {
case 0:
gen_helper_mftc0_status(t0, cpu_env);
break;
default:
gen_mfc0(ctx, t0, rt, sel);
break;
}
case 13:
switch (sel) {
case 0:
gen_helper_mftc0_cause(t0, cpu_env);
break;
default:
goto die;
break;
}
break;
case 14:
switch (sel) {
case 0:
gen_helper_mftc0_epc(t0, cpu_env);
break;
default:
goto die;
break;
}
break;
case 15:
switch (sel) {
case 1:
gen_helper_mftc0_ebase(t0, cpu_env);
break;
default:
goto die;
break;
}
break;
case 16:
switch (sel) {
case 0 ... 7:
gen_helper_mftc0_configx(t0, cpu_env, tcg_const_tl(sel));
break;
default:
goto die;
break;
}
break;
case 23:
switch (sel) {
case 0:
gen_helper_mftc0_debug(t0, cpu_env);
break;
default:
gen_mfc0(ctx, t0, rt, sel);
break;
}
break;
default:
gen_mfc0(ctx, t0, rt, sel);
}
} else switch (sel) {
case 0:
gen_helper_1e0i(mftgpr, t0, rt);
break;
case 1:
switch (rt) {
case 0:
gen_helper_1e0i(mftlo, t0, 0);
break;
case 1:
gen_helper_1e0i(mfthi, t0, 0);
break;
case 2:
gen_helper_1e0i(mftacx, t0, 0);
break;
case 4:
gen_helper_1e0i(mftlo, t0, 1);
break;
case 5:
gen_helper_1e0i(mfthi, t0, 1);
break;
case 6:
gen_helper_1e0i(mftacx, t0, 1);
break;
case 8:
gen_helper_1e0i(mftlo, t0, 2);
break;
case 9:
gen_helper_1e0i(mfthi, t0, 2);
break;
case 10:
gen_helper_1e0i(mftacx, t0, 2);
break;
case 12:
gen_helper_1e0i(mftlo, t0, 3);
break;
case 13:
gen_helper_1e0i(mfthi, t0, 3);
break;
case 14:
gen_helper_1e0i(mftacx, t0, 3);
break;
case 16:
gen_helper_mftdsp(t0, cpu_env);
break;
default:
goto die;
}
break;
case 2:
if (h == 0) {
TCGv_i32 fp0 = tcg_temp_new_i32();
gen_load_fpr32(fp0, rt);
tcg_gen_ext_i32_tl(t0, fp0);
tcg_temp_free_i32(fp0);
} else {
TCGv_i32 fp0 = tcg_temp_new_i32();
gen_load_fpr32h(fp0, rt);
tcg_gen_ext_i32_tl(t0, fp0);
tcg_temp_free_i32(fp0);
}
break;
case 3:
gen_helper_1e0i(cfc1, t0, rt);
break;
case 4:
case 5:
default:
goto die;
}
LOG_DISAS("mftr (reg %d u %d sel %d h %d)\n", rt, u, sel, h);
gen_store_gpr(t0, rd);
tcg_temp_free(t0);
return;
die:
tcg_temp_free(t0);
LOG_DISAS("mftr (reg %d u %d sel %d h %d)\n", rt, u, sel, h);
generate_exception(ctx, EXCP_RI);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(CPUMIPSState *VAR_0, DisasContext *VAR_1, int VAR_2, int VAR_3,
int VAR_4, int VAR_5, int VAR_6)
{
int VAR_7 = VAR_0->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
TCGv t0 = tcg_temp_local_new();
if ((VAR_0->CP0_VPEConf0 & (1 << CP0VPEC0_MVP)) == 0 &&
((VAR_0->tcs[VAR_7].CP0_TCBind & (0xf << CP0TCBd_CurVPE)) !=
(VAR_0->active_tc.CP0_TCBind & (0xf << CP0TCBd_CurVPE))))
tcg_gen_movi_tl(t0, -1);
else if ((VAR_0->CP0_VPEControl & (0xff << CP0VPECo_TargTC)) >
(VAR_0->mvp->CP0_MVPConf0 & (0xff << CP0MVPC0_PTC)))
tcg_gen_movi_tl(t0, -1);
else if (VAR_4 == 0) {
switch (VAR_2) {
case 1:
switch (VAR_5) {
case 1:
gen_helper_mftc0_vpecontrol(t0, cpu_env);
break;
case 2:
gen_helper_mftc0_vpeconf0(t0, cpu_env);
break;
default:
goto die;
break;
}
break;
case 2:
switch (VAR_5) {
case 1:
gen_helper_mftc0_tcstatus(t0, cpu_env);
break;
case 2:
gen_helper_mftc0_tcbind(t0, cpu_env);
break;
case 3:
gen_helper_mftc0_tcrestart(t0, cpu_env);
break;
case 4:
gen_helper_mftc0_tchalt(t0, cpu_env);
break;
case 5:
gen_helper_mftc0_tccontext(t0, cpu_env);
break;
case 6:
gen_helper_mftc0_tcschedule(t0, cpu_env);
break;
case 7:
gen_helper_mftc0_tcschefback(t0, cpu_env);
break;
default:
gen_mfc0(VAR_1, t0, VAR_2, VAR_5);
break;
}
break;
case 10:
switch (VAR_5) {
case 0:
gen_helper_mftc0_entryhi(t0, cpu_env);
break;
default:
gen_mfc0(VAR_1, t0, VAR_2, VAR_5);
break;
}
case 12:
switch (VAR_5) {
case 0:
gen_helper_mftc0_status(t0, cpu_env);
break;
default:
gen_mfc0(VAR_1, t0, VAR_2, VAR_5);
break;
}
case 13:
switch (VAR_5) {
case 0:
gen_helper_mftc0_cause(t0, cpu_env);
break;
default:
goto die;
break;
}
break;
case 14:
switch (VAR_5) {
case 0:
gen_helper_mftc0_epc(t0, cpu_env);
break;
default:
goto die;
break;
}
break;
case 15:
switch (VAR_5) {
case 1:
gen_helper_mftc0_ebase(t0, cpu_env);
break;
default:
goto die;
break;
}
break;
case 16:
switch (VAR_5) {
case 0 ... 7:
gen_helper_mftc0_configx(t0, cpu_env, tcg_const_tl(VAR_5));
break;
default:
goto die;
break;
}
break;
case 23:
switch (VAR_5) {
case 0:
gen_helper_mftc0_debug(t0, cpu_env);
break;
default:
gen_mfc0(VAR_1, t0, VAR_2, VAR_5);
break;
}
break;
default:
gen_mfc0(VAR_1, t0, VAR_2, VAR_5);
}
} else switch (VAR_5) {
case 0:
gen_helper_1e0i(mftgpr, t0, VAR_2);
break;
case 1:
switch (VAR_2) {
case 0:
gen_helper_1e0i(mftlo, t0, 0);
break;
case 1:
gen_helper_1e0i(mfthi, t0, 0);
break;
case 2:
gen_helper_1e0i(mftacx, t0, 0);
break;
case 4:
gen_helper_1e0i(mftlo, t0, 1);
break;
case 5:
gen_helper_1e0i(mfthi, t0, 1);
break;
case 6:
gen_helper_1e0i(mftacx, t0, 1);
break;
case 8:
gen_helper_1e0i(mftlo, t0, 2);
break;
case 9:
gen_helper_1e0i(mfthi, t0, 2);
break;
case 10:
gen_helper_1e0i(mftacx, t0, 2);
break;
case 12:
gen_helper_1e0i(mftlo, t0, 3);
break;
case 13:
gen_helper_1e0i(mfthi, t0, 3);
break;
case 14:
gen_helper_1e0i(mftacx, t0, 3);
break;
case 16:
gen_helper_mftdsp(t0, cpu_env);
break;
default:
goto die;
}
break;
case 2:
if (VAR_6 == 0) {
TCGv_i32 fp0 = tcg_temp_new_i32();
gen_load_fpr32(fp0, VAR_2);
tcg_gen_ext_i32_tl(t0, fp0);
tcg_temp_free_i32(fp0);
} else {
TCGv_i32 fp0 = tcg_temp_new_i32();
gen_load_fpr32h(fp0, VAR_2);
tcg_gen_ext_i32_tl(t0, fp0);
tcg_temp_free_i32(fp0);
}
break;
case 3:
gen_helper_1e0i(cfc1, t0, VAR_2);
break;
case 4:
case 5:
default:
goto die;
}
LOG_DISAS("mftr (reg %d VAR_4 %d VAR_5 %d VAR_6 %d)\n", VAR_2, VAR_4, VAR_5, VAR_6);
gen_store_gpr(t0, VAR_3);
tcg_temp_free(t0);
return;
die:
tcg_temp_free(t0);
LOG_DISAS("mftr (reg %d VAR_4 %d VAR_5 %d VAR_6 %d)\n", VAR_2, VAR_4, VAR_5, VAR_6);
generate_exception(VAR_1, EXCP_RI);
}
| [
"static void FUNC_0(CPUMIPSState *VAR_0, DisasContext *VAR_1, int VAR_2, int VAR_3,\nint VAR_4, int VAR_5, int VAR_6)\n{",
"int VAR_7 = VAR_0->CP0_VPEControl & (0xff << CP0VPECo_TargTC);",
"TCGv t0 = tcg_temp_local_new();",
"if ((VAR_0->CP0_VPEConf0 & (1 << CP0VPEC0_MVP)) == 0 &&\n((VAR_0->tcs[VAR_7].CP0_TCBind & (0xf << CP0TCBd_CurVPE)) !=\n(VAR_0->active_tc.CP0_TCBind & (0xf << CP0TCBd_CurVPE))))\ntcg_gen_movi_tl(t0, -1);",
"else if ((VAR_0->CP0_VPEControl & (0xff << CP0VPECo_TargTC)) >\n(VAR_0->mvp->CP0_MVPConf0 & (0xff << CP0MVPC0_PTC)))\ntcg_gen_movi_tl(t0, -1);",
"else if (VAR_4 == 0) {",
"switch (VAR_2) {",
"case 1:\nswitch (VAR_5) {",
"case 1:\ngen_helper_mftc0_vpecontrol(t0, cpu_env);",
"break;",
"case 2:\ngen_helper_mftc0_vpeconf0(t0, cpu_env);",
"break;",
"default:\ngoto die;",
"break;",
"}",
"break;",
"case 2:\nswitch (VAR_5) {",
"case 1:\ngen_helper_mftc0_tcstatus(t0, cpu_env);",
"break;",
"case 2:\ngen_helper_mftc0_tcbind(t0, cpu_env);",
"break;",
"case 3:\ngen_helper_mftc0_tcrestart(t0, cpu_env);",
"break;",
"case 4:\ngen_helper_mftc0_tchalt(t0, cpu_env);",
"break;",
"case 5:\ngen_helper_mftc0_tccontext(t0, cpu_env);",
"break;",
"case 6:\ngen_helper_mftc0_tcschedule(t0, cpu_env);",
"break;",
"case 7:\ngen_helper_mftc0_tcschefback(t0, cpu_env);",
"break;",
"default:\ngen_mfc0(VAR_1, t0, VAR_2, VAR_5);",
"break;",
"}",
"break;",
"case 10:\nswitch (VAR_5) {",
"case 0:\ngen_helper_mftc0_entryhi(t0, cpu_env);",
"break;",
"default:\ngen_mfc0(VAR_1, t0, VAR_2, VAR_5);",
"break;",
"}",
"case 12:\nswitch (VAR_5) {",
"case 0:\ngen_helper_mftc0_status(t0, cpu_env);",
"break;",
"default:\ngen_mfc0(VAR_1, t0, VAR_2, VAR_5);",
"break;",
"}",
"case 13:\nswitch (VAR_5) {",
"case 0:\ngen_helper_mftc0_cause(t0, cpu_env);",
"break;",
"default:\ngoto die;",
"break;",
"}",
"break;",
"case 14:\nswitch (VAR_5) {",
"case 0:\ngen_helper_mftc0_epc(t0, cpu_env);",
"break;",
"default:\ngoto die;",
"break;",
"}",
"break;",
"case 15:\nswitch (VAR_5) {",
"case 1:\ngen_helper_mftc0_ebase(t0, cpu_env);",
"break;",
"default:\ngoto die;",
"break;",
"}",
"break;",
"case 16:\nswitch (VAR_5) {",
"case 0 ... 7:\ngen_helper_mftc0_configx(t0, cpu_env, tcg_const_tl(VAR_5));",
"break;",
"default:\ngoto die;",
"break;",
"}",
"break;",
"case 23:\nswitch (VAR_5) {",
"case 0:\ngen_helper_mftc0_debug(t0, cpu_env);",
"break;",
"default:\ngen_mfc0(VAR_1, t0, VAR_2, VAR_5);",
"break;",
"}",
"break;",
"default:\ngen_mfc0(VAR_1, t0, VAR_2, VAR_5);",
"}",
"} else switch (VAR_5) {",
"case 0:\ngen_helper_1e0i(mftgpr, t0, VAR_2);",
"break;",
"case 1:\nswitch (VAR_2) {",
"case 0:\ngen_helper_1e0i(mftlo, t0, 0);",
"break;",
"case 1:\ngen_helper_1e0i(mfthi, t0, 0);",
"break;",
"case 2:\ngen_helper_1e0i(mftacx, t0, 0);",
"break;",
"case 4:\ngen_helper_1e0i(mftlo, t0, 1);",
"break;",
"case 5:\ngen_helper_1e0i(mfthi, t0, 1);",
"break;",
"case 6:\ngen_helper_1e0i(mftacx, t0, 1);",
"break;",
"case 8:\ngen_helper_1e0i(mftlo, t0, 2);",
"break;",
"case 9:\ngen_helper_1e0i(mfthi, t0, 2);",
"break;",
"case 10:\ngen_helper_1e0i(mftacx, t0, 2);",
"break;",
"case 12:\ngen_helper_1e0i(mftlo, t0, 3);",
"break;",
"case 13:\ngen_helper_1e0i(mfthi, t0, 3);",
"break;",
"case 14:\ngen_helper_1e0i(mftacx, t0, 3);",
"break;",
"case 16:\ngen_helper_mftdsp(t0, cpu_env);",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 2:\nif (VAR_6 == 0) {",
"TCGv_i32 fp0 = tcg_temp_new_i32();",
"gen_load_fpr32(fp0, VAR_2);",
"tcg_gen_ext_i32_tl(t0, fp0);",
"tcg_temp_free_i32(fp0);",
"} else {",
"TCGv_i32 fp0 = tcg_temp_new_i32();",
"gen_load_fpr32h(fp0, VAR_2);",
"tcg_gen_ext_i32_tl(t0, fp0);",
"tcg_temp_free_i32(fp0);",
"}",
"break;",
"case 3:\ngen_helper_1e0i(cfc1, t0, VAR_2);",
"break;",
"case 4:\ncase 5:\ndefault:\ngoto die;",
"}",
"LOG_DISAS(\"mftr (reg %d VAR_4 %d VAR_5 %d VAR_6 %d)\\n\", VAR_2, VAR_4, VAR_5, VAR_6);",
"gen_store_gpr(t0, VAR_3);",
"tcg_temp_free(t0);",
"return;",
"die:\ntcg_temp_free(t0);",
"LOG_DISAS(\"mftr (reg %d VAR_4 %d VAR_5 %d VAR_6 %d)\\n\", VAR_2, VAR_4, VAR_5, VAR_6);",
"generate_exception(VAR_1, EXCP_RI);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
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
],
[
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,
315
],
[
317
],
[
319,
321
],
[
323
],
[
325,
327
],
[
329
],
[
331,
333
],
[
335
],
[
337,
339
],
[
341
],
[
343,
345
],
[
347
],
[
349,
351
],
[
353
],
[
355
],
[
359,
363
],
[
365
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391,
395
],
[
397
],
[
401,
403,
407,
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
423,
425
],
[
427
],
[
429
],
[
431
]
] |
4,453 | static void dbdma_cmdptr_save(DBDMA_channel *ch)
{
DBDMA_DPRINTF("dbdma_cmdptr_save 0x%08x\n",
be32_to_cpu(ch->regs[DBDMA_CMDPTR_LO]));
DBDMA_DPRINTF("xfer_status 0x%08x res_count 0x%04x\n",
le16_to_cpu(ch->current.xfer_status),
le16_to_cpu(ch->current.res_count));
cpu_physical_memory_write(be32_to_cpu(ch->regs[DBDMA_CMDPTR_LO]),
(uint8_t*)&ch->current, sizeof(dbdma_cmd));
}
| false | qemu | ad674e53b5cce265fadafbde2c6a4f190345cd00 | static void dbdma_cmdptr_save(DBDMA_channel *ch)
{
DBDMA_DPRINTF("dbdma_cmdptr_save 0x%08x\n",
be32_to_cpu(ch->regs[DBDMA_CMDPTR_LO]));
DBDMA_DPRINTF("xfer_status 0x%08x res_count 0x%04x\n",
le16_to_cpu(ch->current.xfer_status),
le16_to_cpu(ch->current.res_count));
cpu_physical_memory_write(be32_to_cpu(ch->regs[DBDMA_CMDPTR_LO]),
(uint8_t*)&ch->current, sizeof(dbdma_cmd));
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DBDMA_channel *VAR_0)
{
DBDMA_DPRINTF("FUNC_0 0x%08x\n",
be32_to_cpu(VAR_0->regs[DBDMA_CMDPTR_LO]));
DBDMA_DPRINTF("xfer_status 0x%08x res_count 0x%04x\n",
le16_to_cpu(VAR_0->current.xfer_status),
le16_to_cpu(VAR_0->current.res_count));
cpu_physical_memory_write(be32_to_cpu(VAR_0->regs[DBDMA_CMDPTR_LO]),
(uint8_t*)&VAR_0->current, sizeof(dbdma_cmd));
}
| [
"static void FUNC_0(DBDMA_channel *VAR_0)\n{",
"DBDMA_DPRINTF(\"FUNC_0 0x%08x\\n\",\nbe32_to_cpu(VAR_0->regs[DBDMA_CMDPTR_LO]));",
"DBDMA_DPRINTF(\"xfer_status 0x%08x res_count 0x%04x\\n\",\nle16_to_cpu(VAR_0->current.xfer_status),\nle16_to_cpu(VAR_0->current.res_count));",
"cpu_physical_memory_write(be32_to_cpu(VAR_0->regs[DBDMA_CMDPTR_LO]),\n(uint8_t*)&VAR_0->current, sizeof(dbdma_cmd));",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9,
11,
13
],
[
15,
17
],
[
19
]
] |
4,454 | void helper_ldl_raw(uint64_t t0, uint64_t t1)
{
ldl_raw(t1, t0);
}
| false | qemu | 2374e73edafff0586cbfb67c333c5a7588f81fd5 | void helper_ldl_raw(uint64_t t0, uint64_t t1)
{
ldl_raw(t1, t0);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(uint64_t VAR_0, uint64_t VAR_1)
{
ldl_raw(VAR_1, VAR_0);
}
| [
"void FUNC_0(uint64_t VAR_0, uint64_t VAR_1)\n{",
"ldl_raw(VAR_1, VAR_0);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
4,455 | uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function,
uint32_t index, int reg)
{
struct kvm_cpuid2 *cpuid;
int i, max;
uint32_t ret = 0;
uint32_t cpuid_1_edx;
int has_kvm_features = 0;
max = 1;
while ((cpuid = try_get_cpuid(env->kvm_state, max)) == NULL) {
max *= 2;
}
for (i = 0; i < cpuid->nent; ++i) {
if (cpuid->entries[i].function == function &&
cpuid->entries[i].index == index) {
if (cpuid->entries[i].function == KVM_CPUID_FEATURES) {
has_kvm_features = 1;
}
switch (reg) {
case R_EAX:
ret = cpuid->entries[i].eax;
break;
case R_EBX:
ret = cpuid->entries[i].ebx;
break;
case R_ECX:
ret = cpuid->entries[i].ecx;
break;
case R_EDX:
ret = cpuid->entries[i].edx;
switch (function) {
case 1:
/* KVM before 2.6.30 misreports the following features */
ret |= CPUID_MTRR | CPUID_PAT | CPUID_MCE | CPUID_MCA;
break;
case 0x80000001:
/* On Intel, kvm returns cpuid according to the Intel spec,
* so add missing bits according to the AMD spec:
*/
cpuid_1_edx = kvm_arch_get_supported_cpuid(env, 1, 0, R_EDX);
ret |= cpuid_1_edx & 0x183f7ff;
break;
}
break;
}
}
}
qemu_free(cpuid);
/* fallback for older kernels */
if (!has_kvm_features && (function == KVM_CPUID_FEATURES)) {
ret = get_para_features(env);
}
return ret;
}
| false | qemu | ba9bc59e1f5dc91caf35e0ef08da137b3a5e7386 | uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function,
uint32_t index, int reg)
{
struct kvm_cpuid2 *cpuid;
int i, max;
uint32_t ret = 0;
uint32_t cpuid_1_edx;
int has_kvm_features = 0;
max = 1;
while ((cpuid = try_get_cpuid(env->kvm_state, max)) == NULL) {
max *= 2;
}
for (i = 0; i < cpuid->nent; ++i) {
if (cpuid->entries[i].function == function &&
cpuid->entries[i].index == index) {
if (cpuid->entries[i].function == KVM_CPUID_FEATURES) {
has_kvm_features = 1;
}
switch (reg) {
case R_EAX:
ret = cpuid->entries[i].eax;
break;
case R_EBX:
ret = cpuid->entries[i].ebx;
break;
case R_ECX:
ret = cpuid->entries[i].ecx;
break;
case R_EDX:
ret = cpuid->entries[i].edx;
switch (function) {
case 1:
ret |= CPUID_MTRR | CPUID_PAT | CPUID_MCE | CPUID_MCA;
break;
case 0x80000001:
cpuid_1_edx = kvm_arch_get_supported_cpuid(env, 1, 0, R_EDX);
ret |= cpuid_1_edx & 0x183f7ff;
break;
}
break;
}
}
}
qemu_free(cpuid);
if (!has_kvm_features && (function == KVM_CPUID_FEATURES)) {
ret = get_para_features(env);
}
return ret;
}
| {
"code": [],
"line_no": []
} | uint32_t FUNC_0(CPUState *env, uint32_t function,
uint32_t index, int reg)
{
struct kvm_cpuid2 *VAR_0;
int VAR_1, VAR_2;
uint32_t ret = 0;
uint32_t cpuid_1_edx;
int VAR_3 = 0;
VAR_2 = 1;
while ((VAR_0 = try_get_cpuid(env->kvm_state, VAR_2)) == NULL) {
VAR_2 *= 2;
}
for (VAR_1 = 0; VAR_1 < VAR_0->nent; ++VAR_1) {
if (VAR_0->entries[VAR_1].function == function &&
VAR_0->entries[VAR_1].index == index) {
if (VAR_0->entries[VAR_1].function == KVM_CPUID_FEATURES) {
VAR_3 = 1;
}
switch (reg) {
case R_EAX:
ret = VAR_0->entries[VAR_1].eax;
break;
case R_EBX:
ret = VAR_0->entries[VAR_1].ebx;
break;
case R_ECX:
ret = VAR_0->entries[VAR_1].ecx;
break;
case R_EDX:
ret = VAR_0->entries[VAR_1].edx;
switch (function) {
case 1:
ret |= CPUID_MTRR | CPUID_PAT | CPUID_MCE | CPUID_MCA;
break;
case 0x80000001:
cpuid_1_edx = FUNC_0(env, 1, 0, R_EDX);
ret |= cpuid_1_edx & 0x183f7ff;
break;
}
break;
}
}
}
qemu_free(VAR_0);
if (!VAR_3 && (function == KVM_CPUID_FEATURES)) {
ret = get_para_features(env);
}
return ret;
}
| [
"uint32_t FUNC_0(CPUState *env, uint32_t function,\nuint32_t index, int reg)\n{",
"struct kvm_cpuid2 *VAR_0;",
"int VAR_1, VAR_2;",
"uint32_t ret = 0;",
"uint32_t cpuid_1_edx;",
"int VAR_3 = 0;",
"VAR_2 = 1;",
"while ((VAR_0 = try_get_cpuid(env->kvm_state, VAR_2)) == NULL) {",
"VAR_2 *= 2;",
"}",
"for (VAR_1 = 0; VAR_1 < VAR_0->nent; ++VAR_1) {",
"if (VAR_0->entries[VAR_1].function == function &&\nVAR_0->entries[VAR_1].index == index) {",
"if (VAR_0->entries[VAR_1].function == KVM_CPUID_FEATURES) {",
"VAR_3 = 1;",
"}",
"switch (reg) {",
"case R_EAX:\nret = VAR_0->entries[VAR_1].eax;",
"break;",
"case R_EBX:\nret = VAR_0->entries[VAR_1].ebx;",
"break;",
"case R_ECX:\nret = VAR_0->entries[VAR_1].ecx;",
"break;",
"case R_EDX:\nret = VAR_0->entries[VAR_1].edx;",
"switch (function) {",
"case 1:\nret |= CPUID_MTRR | CPUID_PAT | CPUID_MCE | CPUID_MCA;",
"break;",
"case 0x80000001:\ncpuid_1_edx = FUNC_0(env, 1, 0, R_EDX);",
"ret |= cpuid_1_edx & 0x183f7ff;",
"break;",
"}",
"break;",
"}",
"}",
"}",
"qemu_free(VAR_0);",
"if (!VAR_3 && (function == KVM_CPUID_FEATURES)) {",
"ret = get_para_features(env);",
"}",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49,
51
],
[
53
],
[
55,
57
],
[
59
],
[
61,
63
],
[
65
],
[
67,
71
],
[
73
],
[
75,
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
]
] |
4,456 | int chsc_sei_nt2_have_event(void)
{
S390pciState *s = S390_PCI_HOST_BRIDGE(
object_resolve_path(TYPE_S390_PCI_HOST_BRIDGE, NULL));
if (!s) {
return 0;
}
return !QTAILQ_EMPTY(&s->pending_sei);
}
| false | qemu | e7d336959b7c01699702dcda4b54a822972d74a8 | int chsc_sei_nt2_have_event(void)
{
S390pciState *s = S390_PCI_HOST_BRIDGE(
object_resolve_path(TYPE_S390_PCI_HOST_BRIDGE, NULL));
if (!s) {
return 0;
}
return !QTAILQ_EMPTY(&s->pending_sei);
}
| {
"code": [],
"line_no": []
} | int FUNC_0(void)
{
S390pciState *s = S390_PCI_HOST_BRIDGE(
object_resolve_path(TYPE_S390_PCI_HOST_BRIDGE, NULL));
if (!s) {
return 0;
}
return !QTAILQ_EMPTY(&s->pending_sei);
}
| [
"int FUNC_0(void)\n{",
"S390pciState *s = S390_PCI_HOST_BRIDGE(\nobject_resolve_path(TYPE_S390_PCI_HOST_BRIDGE, NULL));",
"if (!s) {",
"return 0;",
"}",
"return !QTAILQ_EMPTY(&s->pending_sei);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
]
] |
4,457 | static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,
int opc)
{
int addr_regl, addr_reg1, addr_meml;
int data_regl, data_regh, data_reg1, data_reg2;
int mem_index, s_bits;
#if defined(CONFIG_SOFTMMU)
uint8_t *label1_ptr, *label2_ptr;
int sp_args;
#endif
#if TARGET_LONG_BITS == 64
# if defined(CONFIG_SOFTMMU)
uint8_t *label3_ptr;
# endif
int addr_regh, addr_reg2, addr_memh;
#endif
data_regl = *args++;
if (opc == 3) {
data_regh = *args++;
#if defined(TCG_TARGET_WORDS_BIGENDIAN)
data_reg1 = data_regh;
data_reg2 = data_regl;
#else
data_reg1 = data_regl;
data_reg2 = data_regh;
#endif
} else {
data_reg1 = data_regl;
data_reg2 = 0;
data_regh = 0;
}
addr_regl = *args++;
#if TARGET_LONG_BITS == 64
addr_regh = *args++;
# if defined(TCG_TARGET_WORDS_BIGENDIAN)
addr_reg1 = addr_regh;
addr_reg2 = addr_regl;
addr_memh = 0;
addr_meml = 4;
# else
addr_reg1 = addr_regl;
addr_reg2 = addr_regh;
addr_memh = 4;
addr_meml = 0;
# endif
#else
addr_reg1 = addr_regl;
addr_meml = 0;
#endif
mem_index = *args;
s_bits = opc;
#if defined(CONFIG_SOFTMMU)
tcg_out_opc_sa(s, OPC_SRL, TCG_REG_A0, addr_regl, TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS);
tcg_out_opc_imm(s, OPC_ANDI, TCG_REG_A0, TCG_REG_A0, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS);
tcg_out_opc_reg(s, OPC_ADDU, TCG_REG_A0, TCG_REG_A0, TCG_AREG0);
tcg_out_opc_imm(s, OPC_LW, TCG_REG_AT, TCG_REG_A0,
offsetof(CPUState, tlb_table[mem_index][0].addr_write) + addr_meml);
tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_T0, TARGET_PAGE_MASK | ((1 << s_bits) - 1));
tcg_out_opc_reg(s, OPC_AND, TCG_REG_T0, TCG_REG_T0, addr_regl);
# if TARGET_LONG_BITS == 64
label3_ptr = s->code_ptr;
tcg_out_opc_br(s, OPC_BNE, TCG_REG_T0, TCG_REG_AT);
tcg_out_nop(s);
tcg_out_opc_imm(s, OPC_LW, TCG_REG_AT, TCG_REG_A0,
offsetof(CPUState, tlb_table[mem_index][0].addr_write) + addr_memh);
label1_ptr = s->code_ptr;
tcg_out_opc_br(s, OPC_BEQ, addr_regh, TCG_REG_AT);
tcg_out_nop(s);
reloc_pc16(label3_ptr, (tcg_target_long) s->code_ptr);
# else
label1_ptr = s->code_ptr;
tcg_out_opc_br(s, OPC_BEQ, TCG_REG_T0, TCG_REG_AT);
tcg_out_nop(s);
# endif
/* slow path */
sp_args = TCG_REG_A0;
tcg_out_mov(s, sp_args++, addr_reg1);
# if TARGET_LONG_BITS == 64
tcg_out_mov(s, sp_args++, addr_reg2);
# endif
switch(opc) {
case 0:
tcg_out_opc_imm(s, OPC_ANDI, sp_args++, data_reg1, 0xff);
break;
case 1:
tcg_out_opc_imm(s, OPC_ANDI, sp_args++, data_reg1, 0xffff);
break;
case 2:
tcg_out_mov(s, sp_args++, data_reg1);
break;
case 3:
sp_args = (sp_args + 1) & ~1;
tcg_out_mov(s, sp_args++, data_reg1);
tcg_out_mov(s, sp_args++, data_reg2);
break;
default:
tcg_abort();
}
if (sp_args > TCG_REG_A3) {
/* Push mem_index on the stack */
tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_AT, mem_index);
tcg_out_st(s, TCG_TYPE_I32, TCG_REG_AT, TCG_REG_SP, 16);
} else {
tcg_out_movi(s, TCG_TYPE_I32, sp_args, mem_index);
}
tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_T9, (tcg_target_long)qemu_st_helpers[s_bits]);
tcg_out_opc_reg(s, OPC_JALR, TCG_REG_RA, TCG_REG_T9, 0);
tcg_out_nop(s);
label2_ptr = s->code_ptr;
tcg_out_opc_br(s, OPC_BEQ, TCG_REG_ZERO, TCG_REG_ZERO);
tcg_out_nop(s);
/* label1: fast path */
reloc_pc16(label1_ptr, (tcg_target_long) s->code_ptr);
tcg_out_opc_imm(s, OPC_LW, TCG_REG_A0, TCG_REG_A0,
offsetof(CPUState, tlb_table[mem_index][0].addend) + addr_meml);
tcg_out_opc_reg(s, OPC_ADDU, TCG_REG_A0, TCG_REG_A0, addr_regl);
#else
if (GUEST_BASE == (int16_t)GUEST_BASE) {
tcg_out_opc_imm(s, OPC_ADDIU, TCG_REG_A0, addr_reg1, GUEST_BASE);
} else {
tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_A0, GUEST_BASE);
tcg_out_opc_reg(s, OPC_ADDU, TCG_REG_A0, TCG_REG_A0, addr_reg1);
}
#endif
switch(opc) {
case 0:
tcg_out_opc_imm(s, OPC_SB, data_reg1, TCG_REG_A0, 0);
break;
case 1:
if (TCG_NEED_BSWAP) {
tcg_out_bswap16(s, TCG_REG_T0, data_reg1);
tcg_out_opc_imm(s, OPC_SH, TCG_REG_T0, TCG_REG_A0, 0);
} else {
tcg_out_opc_imm(s, OPC_SH, data_reg1, TCG_REG_A0, 0);
}
break;
case 2:
if (TCG_NEED_BSWAP) {
tcg_out_bswap32(s, TCG_REG_T0, data_reg1);
tcg_out_opc_imm(s, OPC_SW, TCG_REG_T0, TCG_REG_A0, 0);
} else {
tcg_out_opc_imm(s, OPC_SW, data_reg1, TCG_REG_A0, 0);
}
break;
case 3:
if (TCG_NEED_BSWAP) {
tcg_out_bswap32(s, TCG_REG_T0, data_reg2);
tcg_out_opc_imm(s, OPC_SW, TCG_REG_T0, TCG_REG_A0, 0);
tcg_out_bswap32(s, TCG_REG_T0, data_reg1);
tcg_out_opc_imm(s, OPC_SW, TCG_REG_T0, TCG_REG_A0, 4);
} else {
tcg_out_opc_imm(s, OPC_SW, data_reg1, TCG_REG_A0, 0);
tcg_out_opc_imm(s, OPC_SW, data_reg2, TCG_REG_A0, 4);
}
break;
default:
tcg_abort();
}
#if defined(CONFIG_SOFTMMU)
reloc_pc16(label2_ptr, (tcg_target_long) s->code_ptr);
#endif
}
| false | qemu | 355b194369d02df7a97d554eef2a9cffe98d736f | static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,
int opc)
{
int addr_regl, addr_reg1, addr_meml;
int data_regl, data_regh, data_reg1, data_reg2;
int mem_index, s_bits;
#if defined(CONFIG_SOFTMMU)
uint8_t *label1_ptr, *label2_ptr;
int sp_args;
#endif
#if TARGET_LONG_BITS == 64
# if defined(CONFIG_SOFTMMU)
uint8_t *label3_ptr;
# endif
int addr_regh, addr_reg2, addr_memh;
#endif
data_regl = *args++;
if (opc == 3) {
data_regh = *args++;
#if defined(TCG_TARGET_WORDS_BIGENDIAN)
data_reg1 = data_regh;
data_reg2 = data_regl;
#else
data_reg1 = data_regl;
data_reg2 = data_regh;
#endif
} else {
data_reg1 = data_regl;
data_reg2 = 0;
data_regh = 0;
}
addr_regl = *args++;
#if TARGET_LONG_BITS == 64
addr_regh = *args++;
# if defined(TCG_TARGET_WORDS_BIGENDIAN)
addr_reg1 = addr_regh;
addr_reg2 = addr_regl;
addr_memh = 0;
addr_meml = 4;
# else
addr_reg1 = addr_regl;
addr_reg2 = addr_regh;
addr_memh = 4;
addr_meml = 0;
# endif
#else
addr_reg1 = addr_regl;
addr_meml = 0;
#endif
mem_index = *args;
s_bits = opc;
#if defined(CONFIG_SOFTMMU)
tcg_out_opc_sa(s, OPC_SRL, TCG_REG_A0, addr_regl, TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS);
tcg_out_opc_imm(s, OPC_ANDI, TCG_REG_A0, TCG_REG_A0, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS);
tcg_out_opc_reg(s, OPC_ADDU, TCG_REG_A0, TCG_REG_A0, TCG_AREG0);
tcg_out_opc_imm(s, OPC_LW, TCG_REG_AT, TCG_REG_A0,
offsetof(CPUState, tlb_table[mem_index][0].addr_write) + addr_meml);
tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_T0, TARGET_PAGE_MASK | ((1 << s_bits) - 1));
tcg_out_opc_reg(s, OPC_AND, TCG_REG_T0, TCG_REG_T0, addr_regl);
# if TARGET_LONG_BITS == 64
label3_ptr = s->code_ptr;
tcg_out_opc_br(s, OPC_BNE, TCG_REG_T0, TCG_REG_AT);
tcg_out_nop(s);
tcg_out_opc_imm(s, OPC_LW, TCG_REG_AT, TCG_REG_A0,
offsetof(CPUState, tlb_table[mem_index][0].addr_write) + addr_memh);
label1_ptr = s->code_ptr;
tcg_out_opc_br(s, OPC_BEQ, addr_regh, TCG_REG_AT);
tcg_out_nop(s);
reloc_pc16(label3_ptr, (tcg_target_long) s->code_ptr);
# else
label1_ptr = s->code_ptr;
tcg_out_opc_br(s, OPC_BEQ, TCG_REG_T0, TCG_REG_AT);
tcg_out_nop(s);
# endif
sp_args = TCG_REG_A0;
tcg_out_mov(s, sp_args++, addr_reg1);
# if TARGET_LONG_BITS == 64
tcg_out_mov(s, sp_args++, addr_reg2);
# endif
switch(opc) {
case 0:
tcg_out_opc_imm(s, OPC_ANDI, sp_args++, data_reg1, 0xff);
break;
case 1:
tcg_out_opc_imm(s, OPC_ANDI, sp_args++, data_reg1, 0xffff);
break;
case 2:
tcg_out_mov(s, sp_args++, data_reg1);
break;
case 3:
sp_args = (sp_args + 1) & ~1;
tcg_out_mov(s, sp_args++, data_reg1);
tcg_out_mov(s, sp_args++, data_reg2);
break;
default:
tcg_abort();
}
if (sp_args > TCG_REG_A3) {
tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_AT, mem_index);
tcg_out_st(s, TCG_TYPE_I32, TCG_REG_AT, TCG_REG_SP, 16);
} else {
tcg_out_movi(s, TCG_TYPE_I32, sp_args, mem_index);
}
tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_T9, (tcg_target_long)qemu_st_helpers[s_bits]);
tcg_out_opc_reg(s, OPC_JALR, TCG_REG_RA, TCG_REG_T9, 0);
tcg_out_nop(s);
label2_ptr = s->code_ptr;
tcg_out_opc_br(s, OPC_BEQ, TCG_REG_ZERO, TCG_REG_ZERO);
tcg_out_nop(s);
reloc_pc16(label1_ptr, (tcg_target_long) s->code_ptr);
tcg_out_opc_imm(s, OPC_LW, TCG_REG_A0, TCG_REG_A0,
offsetof(CPUState, tlb_table[mem_index][0].addend) + addr_meml);
tcg_out_opc_reg(s, OPC_ADDU, TCG_REG_A0, TCG_REG_A0, addr_regl);
#else
if (GUEST_BASE == (int16_t)GUEST_BASE) {
tcg_out_opc_imm(s, OPC_ADDIU, TCG_REG_A0, addr_reg1, GUEST_BASE);
} else {
tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_A0, GUEST_BASE);
tcg_out_opc_reg(s, OPC_ADDU, TCG_REG_A0, TCG_REG_A0, addr_reg1);
}
#endif
switch(opc) {
case 0:
tcg_out_opc_imm(s, OPC_SB, data_reg1, TCG_REG_A0, 0);
break;
case 1:
if (TCG_NEED_BSWAP) {
tcg_out_bswap16(s, TCG_REG_T0, data_reg1);
tcg_out_opc_imm(s, OPC_SH, TCG_REG_T0, TCG_REG_A0, 0);
} else {
tcg_out_opc_imm(s, OPC_SH, data_reg1, TCG_REG_A0, 0);
}
break;
case 2:
if (TCG_NEED_BSWAP) {
tcg_out_bswap32(s, TCG_REG_T0, data_reg1);
tcg_out_opc_imm(s, OPC_SW, TCG_REG_T0, TCG_REG_A0, 0);
} else {
tcg_out_opc_imm(s, OPC_SW, data_reg1, TCG_REG_A0, 0);
}
break;
case 3:
if (TCG_NEED_BSWAP) {
tcg_out_bswap32(s, TCG_REG_T0, data_reg2);
tcg_out_opc_imm(s, OPC_SW, TCG_REG_T0, TCG_REG_A0, 0);
tcg_out_bswap32(s, TCG_REG_T0, data_reg1);
tcg_out_opc_imm(s, OPC_SW, TCG_REG_T0, TCG_REG_A0, 4);
} else {
tcg_out_opc_imm(s, OPC_SW, data_reg1, TCG_REG_A0, 0);
tcg_out_opc_imm(s, OPC_SW, data_reg2, TCG_REG_A0, 4);
}
break;
default:
tcg_abort();
}
#if defined(CONFIG_SOFTMMU)
reloc_pc16(label2_ptr, (tcg_target_long) s->code_ptr);
#endif
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TCGContext *VAR_0, const TCGArg *VAR_1,
int VAR_2)
{
int VAR_3, VAR_4, VAR_5;
int VAR_6, VAR_7, VAR_8, VAR_9;
int VAR_10, VAR_11;
#if defined(CONFIG_SOFTMMU)
uint8_t *label1_ptr, *label2_ptr;
int sp_args;
#endif
#if TARGET_LONG_BITS == 64
# if defined(CONFIG_SOFTMMU)
uint8_t *label3_ptr;
# endif
int addr_regh, addr_reg2, addr_memh;
#endif
VAR_6 = *VAR_1++;
if (VAR_2 == 3) {
VAR_7 = *VAR_1++;
#if defined(TCG_TARGET_WORDS_BIGENDIAN)
VAR_8 = VAR_7;
VAR_9 = VAR_6;
#else
VAR_8 = VAR_6;
VAR_9 = VAR_7;
#endif
} else {
VAR_8 = VAR_6;
VAR_9 = 0;
VAR_7 = 0;
}
VAR_3 = *VAR_1++;
#if TARGET_LONG_BITS == 64
addr_regh = *VAR_1++;
# if defined(TCG_TARGET_WORDS_BIGENDIAN)
VAR_4 = addr_regh;
addr_reg2 = VAR_3;
addr_memh = 0;
VAR_5 = 4;
# else
VAR_4 = VAR_3;
addr_reg2 = addr_regh;
addr_memh = 4;
VAR_5 = 0;
# endif
#else
VAR_4 = VAR_3;
VAR_5 = 0;
#endif
VAR_10 = *VAR_1;
VAR_11 = VAR_2;
#if defined(CONFIG_SOFTMMU)
tcg_out_opc_sa(VAR_0, OPC_SRL, TCG_REG_A0, VAR_3, TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS);
tcg_out_opc_imm(VAR_0, OPC_ANDI, TCG_REG_A0, TCG_REG_A0, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS);
tcg_out_opc_reg(VAR_0, OPC_ADDU, TCG_REG_A0, TCG_REG_A0, TCG_AREG0);
tcg_out_opc_imm(VAR_0, OPC_LW, TCG_REG_AT, TCG_REG_A0,
offsetof(CPUState, tlb_table[VAR_10][0].addr_write) + VAR_5);
tcg_out_movi(VAR_0, TCG_TYPE_I32, TCG_REG_T0, TARGET_PAGE_MASK | ((1 << VAR_11) - 1));
tcg_out_opc_reg(VAR_0, OPC_AND, TCG_REG_T0, TCG_REG_T0, VAR_3);
# if TARGET_LONG_BITS == 64
label3_ptr = VAR_0->code_ptr;
tcg_out_opc_br(VAR_0, OPC_BNE, TCG_REG_T0, TCG_REG_AT);
tcg_out_nop(VAR_0);
tcg_out_opc_imm(VAR_0, OPC_LW, TCG_REG_AT, TCG_REG_A0,
offsetof(CPUState, tlb_table[VAR_10][0].addr_write) + addr_memh);
label1_ptr = VAR_0->code_ptr;
tcg_out_opc_br(VAR_0, OPC_BEQ, addr_regh, TCG_REG_AT);
tcg_out_nop(VAR_0);
reloc_pc16(label3_ptr, (tcg_target_long) VAR_0->code_ptr);
# else
label1_ptr = VAR_0->code_ptr;
tcg_out_opc_br(VAR_0, OPC_BEQ, TCG_REG_T0, TCG_REG_AT);
tcg_out_nop(VAR_0);
# endif
sp_args = TCG_REG_A0;
tcg_out_mov(VAR_0, sp_args++, VAR_4);
# if TARGET_LONG_BITS == 64
tcg_out_mov(VAR_0, sp_args++, addr_reg2);
# endif
switch(VAR_2) {
case 0:
tcg_out_opc_imm(VAR_0, OPC_ANDI, sp_args++, VAR_8, 0xff);
break;
case 1:
tcg_out_opc_imm(VAR_0, OPC_ANDI, sp_args++, VAR_8, 0xffff);
break;
case 2:
tcg_out_mov(VAR_0, sp_args++, VAR_8);
break;
case 3:
sp_args = (sp_args + 1) & ~1;
tcg_out_mov(VAR_0, sp_args++, VAR_8);
tcg_out_mov(VAR_0, sp_args++, VAR_9);
break;
default:
tcg_abort();
}
if (sp_args > TCG_REG_A3) {
tcg_out_movi(VAR_0, TCG_TYPE_I32, TCG_REG_AT, VAR_10);
tcg_out_st(VAR_0, TCG_TYPE_I32, TCG_REG_AT, TCG_REG_SP, 16);
} else {
tcg_out_movi(VAR_0, TCG_TYPE_I32, sp_args, VAR_10);
}
tcg_out_movi(VAR_0, TCG_TYPE_I32, TCG_REG_T9, (tcg_target_long)qemu_st_helpers[VAR_11]);
tcg_out_opc_reg(VAR_0, OPC_JALR, TCG_REG_RA, TCG_REG_T9, 0);
tcg_out_nop(VAR_0);
label2_ptr = VAR_0->code_ptr;
tcg_out_opc_br(VAR_0, OPC_BEQ, TCG_REG_ZERO, TCG_REG_ZERO);
tcg_out_nop(VAR_0);
reloc_pc16(label1_ptr, (tcg_target_long) VAR_0->code_ptr);
tcg_out_opc_imm(VAR_0, OPC_LW, TCG_REG_A0, TCG_REG_A0,
offsetof(CPUState, tlb_table[VAR_10][0].addend) + VAR_5);
tcg_out_opc_reg(VAR_0, OPC_ADDU, TCG_REG_A0, TCG_REG_A0, VAR_3);
#else
if (GUEST_BASE == (int16_t)GUEST_BASE) {
tcg_out_opc_imm(VAR_0, OPC_ADDIU, TCG_REG_A0, VAR_4, GUEST_BASE);
} else {
tcg_out_movi(VAR_0, TCG_TYPE_PTR, TCG_REG_A0, GUEST_BASE);
tcg_out_opc_reg(VAR_0, OPC_ADDU, TCG_REG_A0, TCG_REG_A0, VAR_4);
}
#endif
switch(VAR_2) {
case 0:
tcg_out_opc_imm(VAR_0, OPC_SB, VAR_8, TCG_REG_A0, 0);
break;
case 1:
if (TCG_NEED_BSWAP) {
tcg_out_bswap16(VAR_0, TCG_REG_T0, VAR_8);
tcg_out_opc_imm(VAR_0, OPC_SH, TCG_REG_T0, TCG_REG_A0, 0);
} else {
tcg_out_opc_imm(VAR_0, OPC_SH, VAR_8, TCG_REG_A0, 0);
}
break;
case 2:
if (TCG_NEED_BSWAP) {
tcg_out_bswap32(VAR_0, TCG_REG_T0, VAR_8);
tcg_out_opc_imm(VAR_0, OPC_SW, TCG_REG_T0, TCG_REG_A0, 0);
} else {
tcg_out_opc_imm(VAR_0, OPC_SW, VAR_8, TCG_REG_A0, 0);
}
break;
case 3:
if (TCG_NEED_BSWAP) {
tcg_out_bswap32(VAR_0, TCG_REG_T0, VAR_9);
tcg_out_opc_imm(VAR_0, OPC_SW, TCG_REG_T0, TCG_REG_A0, 0);
tcg_out_bswap32(VAR_0, TCG_REG_T0, VAR_8);
tcg_out_opc_imm(VAR_0, OPC_SW, TCG_REG_T0, TCG_REG_A0, 4);
} else {
tcg_out_opc_imm(VAR_0, OPC_SW, VAR_8, TCG_REG_A0, 0);
tcg_out_opc_imm(VAR_0, OPC_SW, VAR_9, TCG_REG_A0, 4);
}
break;
default:
tcg_abort();
}
#if defined(CONFIG_SOFTMMU)
reloc_pc16(label2_ptr, (tcg_target_long) VAR_0->code_ptr);
#endif
}
| [
"static void FUNC_0(TCGContext *VAR_0, const TCGArg *VAR_1,\nint VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5;",
"int VAR_6, VAR_7, VAR_8, VAR_9;",
"int VAR_10, VAR_11;",
"#if defined(CONFIG_SOFTMMU)\nuint8_t *label1_ptr, *label2_ptr;",
"int sp_args;",
"#endif\n#if TARGET_LONG_BITS == 64\n# if defined(CONFIG_SOFTMMU)\nuint8_t *label3_ptr;",
"# endif\nint addr_regh, addr_reg2, addr_memh;",
"#endif\nVAR_6 = *VAR_1++;",
"if (VAR_2 == 3) {",
"VAR_7 = *VAR_1++;",
"#if defined(TCG_TARGET_WORDS_BIGENDIAN)\nVAR_8 = VAR_7;",
"VAR_9 = VAR_6;",
"#else\nVAR_8 = VAR_6;",
"VAR_9 = VAR_7;",
"#endif\n} else {",
"VAR_8 = VAR_6;",
"VAR_9 = 0;",
"VAR_7 = 0;",
"}",
"VAR_3 = *VAR_1++;",
"#if TARGET_LONG_BITS == 64\naddr_regh = *VAR_1++;",
"# if defined(TCG_TARGET_WORDS_BIGENDIAN)\nVAR_4 = addr_regh;",
"addr_reg2 = VAR_3;",
"addr_memh = 0;",
"VAR_5 = 4;",
"# else\nVAR_4 = VAR_3;",
"addr_reg2 = addr_regh;",
"addr_memh = 4;",
"VAR_5 = 0;",
"# endif\n#else\nVAR_4 = VAR_3;",
"VAR_5 = 0;",
"#endif\nVAR_10 = *VAR_1;",
"VAR_11 = VAR_2;",
"#if defined(CONFIG_SOFTMMU)\ntcg_out_opc_sa(VAR_0, OPC_SRL, TCG_REG_A0, VAR_3, TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS);",
"tcg_out_opc_imm(VAR_0, OPC_ANDI, TCG_REG_A0, TCG_REG_A0, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS);",
"tcg_out_opc_reg(VAR_0, OPC_ADDU, TCG_REG_A0, TCG_REG_A0, TCG_AREG0);",
"tcg_out_opc_imm(VAR_0, OPC_LW, TCG_REG_AT, TCG_REG_A0,\noffsetof(CPUState, tlb_table[VAR_10][0].addr_write) + VAR_5);",
"tcg_out_movi(VAR_0, TCG_TYPE_I32, TCG_REG_T0, TARGET_PAGE_MASK | ((1 << VAR_11) - 1));",
"tcg_out_opc_reg(VAR_0, OPC_AND, TCG_REG_T0, TCG_REG_T0, VAR_3);",
"# if TARGET_LONG_BITS == 64\nlabel3_ptr = VAR_0->code_ptr;",
"tcg_out_opc_br(VAR_0, OPC_BNE, TCG_REG_T0, TCG_REG_AT);",
"tcg_out_nop(VAR_0);",
"tcg_out_opc_imm(VAR_0, OPC_LW, TCG_REG_AT, TCG_REG_A0,\noffsetof(CPUState, tlb_table[VAR_10][0].addr_write) + addr_memh);",
"label1_ptr = VAR_0->code_ptr;",
"tcg_out_opc_br(VAR_0, OPC_BEQ, addr_regh, TCG_REG_AT);",
"tcg_out_nop(VAR_0);",
"reloc_pc16(label3_ptr, (tcg_target_long) VAR_0->code_ptr);",
"# else\nlabel1_ptr = VAR_0->code_ptr;",
"tcg_out_opc_br(VAR_0, OPC_BEQ, TCG_REG_T0, TCG_REG_AT);",
"tcg_out_nop(VAR_0);",
"# endif\nsp_args = TCG_REG_A0;",
"tcg_out_mov(VAR_0, sp_args++, VAR_4);",
"# if TARGET_LONG_BITS == 64\ntcg_out_mov(VAR_0, sp_args++, addr_reg2);",
"# endif\nswitch(VAR_2) {",
"case 0:\ntcg_out_opc_imm(VAR_0, OPC_ANDI, sp_args++, VAR_8, 0xff);",
"break;",
"case 1:\ntcg_out_opc_imm(VAR_0, OPC_ANDI, sp_args++, VAR_8, 0xffff);",
"break;",
"case 2:\ntcg_out_mov(VAR_0, sp_args++, VAR_8);",
"break;",
"case 3:\nsp_args = (sp_args + 1) & ~1;",
"tcg_out_mov(VAR_0, sp_args++, VAR_8);",
"tcg_out_mov(VAR_0, sp_args++, VAR_9);",
"break;",
"default:\ntcg_abort();",
"}",
"if (sp_args > TCG_REG_A3) {",
"tcg_out_movi(VAR_0, TCG_TYPE_I32, TCG_REG_AT, VAR_10);",
"tcg_out_st(VAR_0, TCG_TYPE_I32, TCG_REG_AT, TCG_REG_SP, 16);",
"} else {",
"tcg_out_movi(VAR_0, TCG_TYPE_I32, sp_args, VAR_10);",
"}",
"tcg_out_movi(VAR_0, TCG_TYPE_I32, TCG_REG_T9, (tcg_target_long)qemu_st_helpers[VAR_11]);",
"tcg_out_opc_reg(VAR_0, OPC_JALR, TCG_REG_RA, TCG_REG_T9, 0);",
"tcg_out_nop(VAR_0);",
"label2_ptr = VAR_0->code_ptr;",
"tcg_out_opc_br(VAR_0, OPC_BEQ, TCG_REG_ZERO, TCG_REG_ZERO);",
"tcg_out_nop(VAR_0);",
"reloc_pc16(label1_ptr, (tcg_target_long) VAR_0->code_ptr);",
"tcg_out_opc_imm(VAR_0, OPC_LW, TCG_REG_A0, TCG_REG_A0,\noffsetof(CPUState, tlb_table[VAR_10][0].addend) + VAR_5);",
"tcg_out_opc_reg(VAR_0, OPC_ADDU, TCG_REG_A0, TCG_REG_A0, VAR_3);",
"#else\nif (GUEST_BASE == (int16_t)GUEST_BASE) {",
"tcg_out_opc_imm(VAR_0, OPC_ADDIU, TCG_REG_A0, VAR_4, GUEST_BASE);",
"} else {",
"tcg_out_movi(VAR_0, TCG_TYPE_PTR, TCG_REG_A0, GUEST_BASE);",
"tcg_out_opc_reg(VAR_0, OPC_ADDU, TCG_REG_A0, TCG_REG_A0, VAR_4);",
"}",
"#endif\nswitch(VAR_2) {",
"case 0:\ntcg_out_opc_imm(VAR_0, OPC_SB, VAR_8, TCG_REG_A0, 0);",
"break;",
"case 1:\nif (TCG_NEED_BSWAP) {",
"tcg_out_bswap16(VAR_0, TCG_REG_T0, VAR_8);",
"tcg_out_opc_imm(VAR_0, OPC_SH, TCG_REG_T0, TCG_REG_A0, 0);",
"} else {",
"tcg_out_opc_imm(VAR_0, OPC_SH, VAR_8, TCG_REG_A0, 0);",
"}",
"break;",
"case 2:\nif (TCG_NEED_BSWAP) {",
"tcg_out_bswap32(VAR_0, TCG_REG_T0, VAR_8);",
"tcg_out_opc_imm(VAR_0, OPC_SW, TCG_REG_T0, TCG_REG_A0, 0);",
"} else {",
"tcg_out_opc_imm(VAR_0, OPC_SW, VAR_8, TCG_REG_A0, 0);",
"}",
"break;",
"case 3:\nif (TCG_NEED_BSWAP) {",
"tcg_out_bswap32(VAR_0, TCG_REG_T0, VAR_9);",
"tcg_out_opc_imm(VAR_0, OPC_SW, TCG_REG_T0, TCG_REG_A0, 0);",
"tcg_out_bswap32(VAR_0, TCG_REG_T0, VAR_8);",
"tcg_out_opc_imm(VAR_0, OPC_SW, TCG_REG_T0, TCG_REG_A0, 4);",
"} else {",
"tcg_out_opc_imm(VAR_0, OPC_SW, VAR_8, TCG_REG_A0, 0);",
"tcg_out_opc_imm(VAR_0, OPC_SW, VAR_9, TCG_REG_A0, 4);",
"}",
"break;",
"default:\ntcg_abort();",
"}",
"#if defined(CONFIG_SOFTMMU)\nreloc_pc16(label2_ptr, (tcg_target_long) VAR_0->code_ptr);",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
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
],
[
107,
109
],
[
111
],
[
113
],
[
115,
117
],
[
119
],
[
121
],
[
125,
127
],
[
129
],
[
131
],
[
135,
137
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151,
153
],
[
155
],
[
157
],
[
159,
165
],
[
167
],
[
169,
171
],
[
173,
175
],
[
177,
179
],
[
181
],
[
183,
185
],
[
187
],
[
189,
191
],
[
193
],
[
195,
197
],
[
199
],
[
201
],
[
203
],
[
205,
207
],
[
209
],
[
211
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
227
],
[
229
],
[
231
],
[
235
],
[
237
],
[
239
],
[
245
],
[
249,
251
],
[
253
],
[
255,
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
271,
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
],
[
345,
347
],
[
349,
351
]
] |
4,458 | static inline void RENAME(BEToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused)
{
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(
"movq "MANGLE(bm01010101)", %%mm4 \n\t"
"mov %0, %%"REG_a" \n\t"
"1: \n\t"
"movq (%1, %%"REG_a",2), %%mm0 \n\t"
"movq 8(%1, %%"REG_a",2), %%mm1 \n\t"
"movq (%2, %%"REG_a",2), %%mm2 \n\t"
"movq 8(%2, %%"REG_a",2), %%mm3 \n\t"
"pand %%mm4, %%mm0 \n\t"
"pand %%mm4, %%mm1 \n\t"
"pand %%mm4, %%mm2 \n\t"
"pand %%mm4, %%mm3 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"packuswb %%mm3, %%mm2 \n\t"
"movq %%mm0, (%3, %%"REG_a") \n\t"
"movq %%mm2, (%4, %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t"
" js 1b \n\t"
: : "g" ((x86_reg)-width), "r" (src1+width*2), "r" (src2+width*2), "r" (dstU+width), "r" (dstV+width)
: "%"REG_a
);
#else
int i;
for (i=0; i<width; i++) {
dstU[i]= src1[2*i];
dstV[i]= src2[2*i];
}
#endif
}
| false | FFmpeg | d1adad3cca407f493c3637e20ecd4f7124e69212 | static inline void RENAME(BEToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused)
{
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(
"movq "MANGLE(bm01010101)", %%mm4 \n\t"
"mov %0, %%"REG_a" \n\t"
"1: \n\t"
"movq (%1, %%"REG_a",2), %%mm0 \n\t"
"movq 8(%1, %%"REG_a",2), %%mm1 \n\t"
"movq (%2, %%"REG_a",2), %%mm2 \n\t"
"movq 8(%2, %%"REG_a",2), %%mm3 \n\t"
"pand %%mm4, %%mm0 \n\t"
"pand %%mm4, %%mm1 \n\t"
"pand %%mm4, %%mm2 \n\t"
"pand %%mm4, %%mm3 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"packuswb %%mm3, %%mm2 \n\t"
"movq %%mm0, (%3, %%"REG_a") \n\t"
"movq %%mm2, (%4, %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t"
" js 1b \n\t"
: : "g" ((x86_reg)-width), "r" (src1+width*2), "r" (src2+width*2), "r" (dstU+width), "r" (dstV+width)
: "%"REG_a
);
#else
int i;
for (i=0; i<width; i++) {
dstU[i]= src1[2*i];
dstV[i]= src2[2*i];
}
#endif
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(BEToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused)
{
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(
"movq "MANGLE(bm01010101)", %%mm4 \n\t"
"mov %0, %%"REG_a" \n\t"
"1: \n\t"
"movq (%1, %%"REG_a",2), %%mm0 \n\t"
"movq 8(%1, %%"REG_a",2), %%mm1 \n\t"
"movq (%2, %%"REG_a",2), %%mm2 \n\t"
"movq 8(%2, %%"REG_a",2), %%mm3 \n\t"
"pand %%mm4, %%mm0 \n\t"
"pand %%mm4, %%mm1 \n\t"
"pand %%mm4, %%mm2 \n\t"
"pand %%mm4, %%mm3 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"packuswb %%mm3, %%mm2 \n\t"
"movq %%mm0, (%3, %%"REG_a") \n\t"
"movq %%mm2, (%4, %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t"
" js 1b \n\t"
: : "g" ((x86_reg)-width), "r" (src1+width*2), "r" (src2+width*2), "r" (dstU+width), "r" (dstV+width)
: "%"REG_a
);
#else
int VAR_0;
for (VAR_0=0; VAR_0<width; VAR_0++) {
dstU[VAR_0]= src1[2*VAR_0];
dstV[VAR_0]= src2[2*VAR_0];
}
#endif
}
| [
"static inline void FUNC_0(BEToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused)\n{",
"#if COMPILE_TEMPLATE_MMX\n__asm__ volatile(\n\"movq \"MANGLE(bm01010101)\", %%mm4 \\n\\t\"\n\"mov %0, %%\"REG_a\" \\n\\t\"\n\"1: \\n\\t\"\n\"movq (%1, %%\"REG_a\",2), %%mm0 \\n\\t\"\n\"movq 8(%1, %%\"REG_a\",2), %%mm1 \\n\\t\"\n\"movq (%2, %%\"REG_a\",2), %%mm2 \\n\\t\"\n\"movq 8(%2, %%\"REG_a\",2), %%mm3 \\n\\t\"\n\"pand %%mm4, %%mm0 \\n\\t\"\n\"pand %%mm4, %%mm1 \\n\\t\"\n\"pand %%mm4, %%mm2 \\n\\t\"\n\"pand %%mm4, %%mm3 \\n\\t\"\n\"packuswb %%mm1, %%mm0 \\n\\t\"\n\"packuswb %%mm3, %%mm2 \\n\\t\"\n\"movq %%mm0, (%3, %%\"REG_a\") \\n\\t\"\n\"movq %%mm2, (%4, %%\"REG_a\") \\n\\t\"\n\"add $8, %%\"REG_a\" \\n\\t\"\n\" js 1b \\n\\t\"\n: : \"g\" ((x86_reg)-width), \"r\" (src1+width*2), \"r\" (src2+width*2), \"r\" (dstU+width), \"r\" (dstV+width)\n: \"%\"REG_a\n);",
"#else\nint VAR_0;",
"for (VAR_0=0; VAR_0<width; VAR_0++) {",
"dstU[VAR_0]= src1[2*VAR_0];",
"dstV[VAR_0]= src2[2*VAR_0];",
"}",
"#endif\n}"
] | [
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
]
] |
4,459 | static int usb_msd_handle_data(USBDevice *dev, USBPacket *p)
{
MSDState *s = (MSDState *)dev;
int ret = 0;
struct usb_msd_cbw cbw;
uint8_t devep = p->devep;
switch (p->pid) {
case USB_TOKEN_OUT:
if (devep != 2)
goto fail;
switch (s->mode) {
case USB_MSDM_CBW:
if (p->iov.size != 31) {
fprintf(stderr, "usb-msd: Bad CBW size");
goto fail;
}
usb_packet_copy(p, &cbw, 31);
if (le32_to_cpu(cbw.sig) != 0x43425355) {
fprintf(stderr, "usb-msd: Bad signature %08x\n",
le32_to_cpu(cbw.sig));
goto fail;
}
DPRINTF("Command on LUN %d\n", cbw.lun);
if (cbw.lun != 0) {
fprintf(stderr, "usb-msd: Bad LUN %d\n", cbw.lun);
goto fail;
}
s->tag = le32_to_cpu(cbw.tag);
s->data_len = le32_to_cpu(cbw.data_len);
if (s->data_len == 0) {
s->mode = USB_MSDM_CSW;
} else if (cbw.flags & 0x80) {
s->mode = USB_MSDM_DATAIN;
} else {
s->mode = USB_MSDM_DATAOUT;
}
DPRINTF("Command tag 0x%x flags %08x len %d data %d\n",
s->tag, cbw.flags, cbw.cmd_len, s->data_len);
s->residue = 0;
s->scsi_len = 0;
s->req = scsi_req_new(s->scsi_dev, s->tag, 0, NULL);
scsi_req_enqueue(s->req, cbw.cmd);
/* ??? Should check that USB and SCSI data transfer
directions match. */
if (s->mode != USB_MSDM_CSW && s->residue == 0) {
scsi_req_continue(s->req);
}
ret = p->result;
break;
case USB_MSDM_DATAOUT:
DPRINTF("Data out %zd/%d\n", p->iov.size, s->data_len);
if (p->iov.size > s->data_len) {
goto fail;
}
if (s->scsi_len) {
usb_msd_copy_data(s, p);
}
if (s->residue) {
int len = p->iov.size - p->result;
if (len) {
usb_packet_skip(p, len);
s->data_len -= len;
if (s->data_len == 0) {
s->mode = USB_MSDM_CSW;
}
}
}
if (p->result < p->iov.size) {
DPRINTF("Deferring packet %p\n", p);
s->packet = p;
ret = USB_RET_ASYNC;
} else {
ret = p->result;
}
break;
default:
DPRINTF("Unexpected write (len %zd)\n", p->iov.size);
goto fail;
}
break;
case USB_TOKEN_IN:
if (devep != 1)
goto fail;
switch (s->mode) {
case USB_MSDM_DATAOUT:
if (s->data_len != 0 || p->iov.size < 13) {
goto fail;
}
/* Waiting for SCSI write to complete. */
s->packet = p;
ret = USB_RET_ASYNC;
break;
case USB_MSDM_CSW:
DPRINTF("Command status %d tag 0x%x, len %zd\n",
s->result, s->tag, p->iov.size);
if (p->iov.size < 13) {
goto fail;
}
usb_msd_send_status(s, p);
s->mode = USB_MSDM_CBW;
ret = 13;
break;
case USB_MSDM_DATAIN:
DPRINTF("Data in %zd/%d, scsi_len %d\n",
p->iov.size, s->data_len, s->scsi_len);
if (s->scsi_len) {
usb_msd_copy_data(s, p);
}
if (s->residue) {
int len = p->iov.size - p->result;
if (len) {
usb_packet_skip(p, len);
s->data_len -= len;
if (s->data_len == 0) {
s->mode = USB_MSDM_CSW;
}
}
}
if (p->result < p->iov.size) {
DPRINTF("Deferring packet %p\n", p);
s->packet = p;
ret = USB_RET_ASYNC;
} else {
ret = p->result;
}
break;
default:
DPRINTF("Unexpected read (len %zd)\n", p->iov.size);
goto fail;
}
break;
default:
DPRINTF("Bad token\n");
fail:
ret = USB_RET_STALL;
break;
}
return ret;
}
| false | qemu | c39ce112b60ffafbaf700853e32bea74cbb2c148 | static int usb_msd_handle_data(USBDevice *dev, USBPacket *p)
{
MSDState *s = (MSDState *)dev;
int ret = 0;
struct usb_msd_cbw cbw;
uint8_t devep = p->devep;
switch (p->pid) {
case USB_TOKEN_OUT:
if (devep != 2)
goto fail;
switch (s->mode) {
case USB_MSDM_CBW:
if (p->iov.size != 31) {
fprintf(stderr, "usb-msd: Bad CBW size");
goto fail;
}
usb_packet_copy(p, &cbw, 31);
if (le32_to_cpu(cbw.sig) != 0x43425355) {
fprintf(stderr, "usb-msd: Bad signature %08x\n",
le32_to_cpu(cbw.sig));
goto fail;
}
DPRINTF("Command on LUN %d\n", cbw.lun);
if (cbw.lun != 0) {
fprintf(stderr, "usb-msd: Bad LUN %d\n", cbw.lun);
goto fail;
}
s->tag = le32_to_cpu(cbw.tag);
s->data_len = le32_to_cpu(cbw.data_len);
if (s->data_len == 0) {
s->mode = USB_MSDM_CSW;
} else if (cbw.flags & 0x80) {
s->mode = USB_MSDM_DATAIN;
} else {
s->mode = USB_MSDM_DATAOUT;
}
DPRINTF("Command tag 0x%x flags %08x len %d data %d\n",
s->tag, cbw.flags, cbw.cmd_len, s->data_len);
s->residue = 0;
s->scsi_len = 0;
s->req = scsi_req_new(s->scsi_dev, s->tag, 0, NULL);
scsi_req_enqueue(s->req, cbw.cmd);
if (s->mode != USB_MSDM_CSW && s->residue == 0) {
scsi_req_continue(s->req);
}
ret = p->result;
break;
case USB_MSDM_DATAOUT:
DPRINTF("Data out %zd/%d\n", p->iov.size, s->data_len);
if (p->iov.size > s->data_len) {
goto fail;
}
if (s->scsi_len) {
usb_msd_copy_data(s, p);
}
if (s->residue) {
int len = p->iov.size - p->result;
if (len) {
usb_packet_skip(p, len);
s->data_len -= len;
if (s->data_len == 0) {
s->mode = USB_MSDM_CSW;
}
}
}
if (p->result < p->iov.size) {
DPRINTF("Deferring packet %p\n", p);
s->packet = p;
ret = USB_RET_ASYNC;
} else {
ret = p->result;
}
break;
default:
DPRINTF("Unexpected write (len %zd)\n", p->iov.size);
goto fail;
}
break;
case USB_TOKEN_IN:
if (devep != 1)
goto fail;
switch (s->mode) {
case USB_MSDM_DATAOUT:
if (s->data_len != 0 || p->iov.size < 13) {
goto fail;
}
s->packet = p;
ret = USB_RET_ASYNC;
break;
case USB_MSDM_CSW:
DPRINTF("Command status %d tag 0x%x, len %zd\n",
s->result, s->tag, p->iov.size);
if (p->iov.size < 13) {
goto fail;
}
usb_msd_send_status(s, p);
s->mode = USB_MSDM_CBW;
ret = 13;
break;
case USB_MSDM_DATAIN:
DPRINTF("Data in %zd/%d, scsi_len %d\n",
p->iov.size, s->data_len, s->scsi_len);
if (s->scsi_len) {
usb_msd_copy_data(s, p);
}
if (s->residue) {
int len = p->iov.size - p->result;
if (len) {
usb_packet_skip(p, len);
s->data_len -= len;
if (s->data_len == 0) {
s->mode = USB_MSDM_CSW;
}
}
}
if (p->result < p->iov.size) {
DPRINTF("Deferring packet %p\n", p);
s->packet = p;
ret = USB_RET_ASYNC;
} else {
ret = p->result;
}
break;
default:
DPRINTF("Unexpected read (len %zd)\n", p->iov.size);
goto fail;
}
break;
default:
DPRINTF("Bad token\n");
fail:
ret = USB_RET_STALL;
break;
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)
{
MSDState *s = (MSDState *)VAR_0;
int VAR_2 = 0;
struct usb_msd_cbw VAR_3;
uint8_t devep = VAR_1->devep;
switch (VAR_1->pid) {
case USB_TOKEN_OUT:
if (devep != 2)
goto fail;
switch (s->mode) {
case USB_MSDM_CBW:
if (VAR_1->iov.size != 31) {
fprintf(stderr, "usb-msd: Bad CBW size");
goto fail;
}
usb_packet_copy(VAR_1, &VAR_3, 31);
if (le32_to_cpu(VAR_3.sig) != 0x43425355) {
fprintf(stderr, "usb-msd: Bad signature %08x\n",
le32_to_cpu(VAR_3.sig));
goto fail;
}
DPRINTF("Command on LUN %d\n", VAR_3.lun);
if (VAR_3.lun != 0) {
fprintf(stderr, "usb-msd: Bad LUN %d\n", VAR_3.lun);
goto fail;
}
s->tag = le32_to_cpu(VAR_3.tag);
s->data_len = le32_to_cpu(VAR_3.data_len);
if (s->data_len == 0) {
s->mode = USB_MSDM_CSW;
} else if (VAR_3.flags & 0x80) {
s->mode = USB_MSDM_DATAIN;
} else {
s->mode = USB_MSDM_DATAOUT;
}
DPRINTF("Command tag 0x%x flags %08x VAR_5 %d data %d\n",
s->tag, VAR_3.flags, VAR_3.cmd_len, s->data_len);
s->residue = 0;
s->scsi_len = 0;
s->req = scsi_req_new(s->scsi_dev, s->tag, 0, NULL);
scsi_req_enqueue(s->req, VAR_3.cmd);
if (s->mode != USB_MSDM_CSW && s->residue == 0) {
scsi_req_continue(s->req);
}
VAR_2 = VAR_1->result;
break;
case USB_MSDM_DATAOUT:
DPRINTF("Data out %zd/%d\n", VAR_1->iov.size, s->data_len);
if (VAR_1->iov.size > s->data_len) {
goto fail;
}
if (s->scsi_len) {
usb_msd_copy_data(s, VAR_1);
}
if (s->residue) {
int VAR_5 = VAR_1->iov.size - VAR_1->result;
if (VAR_5) {
usb_packet_skip(VAR_1, VAR_5);
s->data_len -= VAR_5;
if (s->data_len == 0) {
s->mode = USB_MSDM_CSW;
}
}
}
if (VAR_1->result < VAR_1->iov.size) {
DPRINTF("Deferring packet %VAR_1\n", VAR_1);
s->packet = VAR_1;
VAR_2 = USB_RET_ASYNC;
} else {
VAR_2 = VAR_1->result;
}
break;
default:
DPRINTF("Unexpected write (VAR_5 %zd)\n", VAR_1->iov.size);
goto fail;
}
break;
case USB_TOKEN_IN:
if (devep != 1)
goto fail;
switch (s->mode) {
case USB_MSDM_DATAOUT:
if (s->data_len != 0 || VAR_1->iov.size < 13) {
goto fail;
}
s->packet = VAR_1;
VAR_2 = USB_RET_ASYNC;
break;
case USB_MSDM_CSW:
DPRINTF("Command status %d tag 0x%x, VAR_5 %zd\n",
s->result, s->tag, VAR_1->iov.size);
if (VAR_1->iov.size < 13) {
goto fail;
}
usb_msd_send_status(s, VAR_1);
s->mode = USB_MSDM_CBW;
VAR_2 = 13;
break;
case USB_MSDM_DATAIN:
DPRINTF("Data in %zd/%d, scsi_len %d\n",
VAR_1->iov.size, s->data_len, s->scsi_len);
if (s->scsi_len) {
usb_msd_copy_data(s, VAR_1);
}
if (s->residue) {
int VAR_5 = VAR_1->iov.size - VAR_1->result;
if (VAR_5) {
usb_packet_skip(VAR_1, VAR_5);
s->data_len -= VAR_5;
if (s->data_len == 0) {
s->mode = USB_MSDM_CSW;
}
}
}
if (VAR_1->result < VAR_1->iov.size) {
DPRINTF("Deferring packet %VAR_1\n", VAR_1);
s->packet = VAR_1;
VAR_2 = USB_RET_ASYNC;
} else {
VAR_2 = VAR_1->result;
}
break;
default:
DPRINTF("Unexpected read (VAR_5 %zd)\n", VAR_1->iov.size);
goto fail;
}
break;
default:
DPRINTF("Bad token\n");
fail:
VAR_2 = USB_RET_STALL;
break;
}
return VAR_2;
}
| [
"static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)\n{",
"MSDState *s = (MSDState *)VAR_0;",
"int VAR_2 = 0;",
"struct usb_msd_cbw VAR_3;",
"uint8_t devep = VAR_1->devep;",
"switch (VAR_1->pid) {",
"case USB_TOKEN_OUT:\nif (devep != 2)\ngoto fail;",
"switch (s->mode) {",
"case USB_MSDM_CBW:\nif (VAR_1->iov.size != 31) {",
"fprintf(stderr, \"usb-msd: Bad CBW size\");",
"goto fail;",
"}",
"usb_packet_copy(VAR_1, &VAR_3, 31);",
"if (le32_to_cpu(VAR_3.sig) != 0x43425355) {",
"fprintf(stderr, \"usb-msd: Bad signature %08x\\n\",\nle32_to_cpu(VAR_3.sig));",
"goto fail;",
"}",
"DPRINTF(\"Command on LUN %d\\n\", VAR_3.lun);",
"if (VAR_3.lun != 0) {",
"fprintf(stderr, \"usb-msd: Bad LUN %d\\n\", VAR_3.lun);",
"goto fail;",
"}",
"s->tag = le32_to_cpu(VAR_3.tag);",
"s->data_len = le32_to_cpu(VAR_3.data_len);",
"if (s->data_len == 0) {",
"s->mode = USB_MSDM_CSW;",
"} else if (VAR_3.flags & 0x80) {",
"s->mode = USB_MSDM_DATAIN;",
"} else {",
"s->mode = USB_MSDM_DATAOUT;",
"}",
"DPRINTF(\"Command tag 0x%x flags %08x VAR_5 %d data %d\\n\",\ns->tag, VAR_3.flags, VAR_3.cmd_len, s->data_len);",
"s->residue = 0;",
"s->scsi_len = 0;",
"s->req = scsi_req_new(s->scsi_dev, s->tag, 0, NULL);",
"scsi_req_enqueue(s->req, VAR_3.cmd);",
"if (s->mode != USB_MSDM_CSW && s->residue == 0) {",
"scsi_req_continue(s->req);",
"}",
"VAR_2 = VAR_1->result;",
"break;",
"case USB_MSDM_DATAOUT:\nDPRINTF(\"Data out %zd/%d\\n\", VAR_1->iov.size, s->data_len);",
"if (VAR_1->iov.size > s->data_len) {",
"goto fail;",
"}",
"if (s->scsi_len) {",
"usb_msd_copy_data(s, VAR_1);",
"}",
"if (s->residue) {",
"int VAR_5 = VAR_1->iov.size - VAR_1->result;",
"if (VAR_5) {",
"usb_packet_skip(VAR_1, VAR_5);",
"s->data_len -= VAR_5;",
"if (s->data_len == 0) {",
"s->mode = USB_MSDM_CSW;",
"}",
"}",
"}",
"if (VAR_1->result < VAR_1->iov.size) {",
"DPRINTF(\"Deferring packet %VAR_1\\n\", VAR_1);",
"s->packet = VAR_1;",
"VAR_2 = USB_RET_ASYNC;",
"} else {",
"VAR_2 = VAR_1->result;",
"}",
"break;",
"default:\nDPRINTF(\"Unexpected write (VAR_5 %zd)\\n\", VAR_1->iov.size);",
"goto fail;",
"}",
"break;",
"case USB_TOKEN_IN:\nif (devep != 1)\ngoto fail;",
"switch (s->mode) {",
"case USB_MSDM_DATAOUT:\nif (s->data_len != 0 || VAR_1->iov.size < 13) {",
"goto fail;",
"}",
"s->packet = VAR_1;",
"VAR_2 = USB_RET_ASYNC;",
"break;",
"case USB_MSDM_CSW:\nDPRINTF(\"Command status %d tag 0x%x, VAR_5 %zd\\n\",\ns->result, s->tag, VAR_1->iov.size);",
"if (VAR_1->iov.size < 13) {",
"goto fail;",
"}",
"usb_msd_send_status(s, VAR_1);",
"s->mode = USB_MSDM_CBW;",
"VAR_2 = 13;",
"break;",
"case USB_MSDM_DATAIN:\nDPRINTF(\"Data in %zd/%d, scsi_len %d\\n\",\nVAR_1->iov.size, s->data_len, s->scsi_len);",
"if (s->scsi_len) {",
"usb_msd_copy_data(s, VAR_1);",
"}",
"if (s->residue) {",
"int VAR_5 = VAR_1->iov.size - VAR_1->result;",
"if (VAR_5) {",
"usb_packet_skip(VAR_1, VAR_5);",
"s->data_len -= VAR_5;",
"if (s->data_len == 0) {",
"s->mode = USB_MSDM_CSW;",
"}",
"}",
"}",
"if (VAR_1->result < VAR_1->iov.size) {",
"DPRINTF(\"Deferring packet %VAR_1\\n\", VAR_1);",
"s->packet = VAR_1;",
"VAR_2 = USB_RET_ASYNC;",
"} else {",
"VAR_2 = VAR_1->result;",
"}",
"break;",
"default:\nDPRINTF(\"Unexpected read (VAR_5 %zd)\\n\", VAR_1->iov.size);",
"goto fail;",
"}",
"break;",
"default:\nDPRINTF(\"Bad token\\n\");",
"fail:\nVAR_2 = USB_RET_STALL;",
"break;",
"}",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17,
19,
21
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105,
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
161,
163
],
[
165
],
[
167
],
[
169
],
[
173,
175,
177
],
[
181
],
[
183,
185
],
[
187
],
[
189
],
[
193
],
[
195
],
[
197
],
[
201,
203,
205
],
[
207
],
[
209
],
[
211
],
[
215
],
[
217
],
[
219
],
[
221
],
[
225,
227,
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
275,
277
],
[
279
],
[
281
],
[
283
],
[
287,
289
],
[
291,
293
],
[
295
],
[
297
],
[
301
],
[
303
]
] |
4,460 | static bool main_loop_should_exit(void)
{
RunState r;
ShutdownCause request;
if (qemu_debug_requested()) {
vm_stop(RUN_STATE_DEBUG);
}
if (qemu_suspend_requested()) {
qemu_system_suspend();
}
request = qemu_shutdown_requested();
if (request) {
qemu_kill_report();
/* TODO update event based on request */
qapi_event_send_shutdown(&error_abort);
if (no_shutdown) {
vm_stop(RUN_STATE_SHUTDOWN);
} else {
return true;
}
}
request = qemu_reset_requested();
if (request) {
pause_all_vcpus();
qemu_system_reset(request);
resume_all_vcpus();
if (!runstate_check(RUN_STATE_RUNNING) &&
!runstate_check(RUN_STATE_INMIGRATE)) {
runstate_set(RUN_STATE_PRELAUNCH);
}
}
if (qemu_wakeup_requested()) {
pause_all_vcpus();
qemu_system_reset(SHUTDOWN_CAUSE_NONE);
notifier_list_notify(&wakeup_notifiers, &wakeup_reason);
wakeup_reason = QEMU_WAKEUP_REASON_NONE;
resume_all_vcpus();
qapi_event_send_wakeup(&error_abort);
}
if (qemu_powerdown_requested()) {
qemu_system_powerdown();
}
if (qemu_vmstop_requested(&r)) {
vm_stop(r);
}
return false;
}
| false | qemu | 08fba7ac9b618516a5f1d096f78a7e2837fe0594 | static bool main_loop_should_exit(void)
{
RunState r;
ShutdownCause request;
if (qemu_debug_requested()) {
vm_stop(RUN_STATE_DEBUG);
}
if (qemu_suspend_requested()) {
qemu_system_suspend();
}
request = qemu_shutdown_requested();
if (request) {
qemu_kill_report();
qapi_event_send_shutdown(&error_abort);
if (no_shutdown) {
vm_stop(RUN_STATE_SHUTDOWN);
} else {
return true;
}
}
request = qemu_reset_requested();
if (request) {
pause_all_vcpus();
qemu_system_reset(request);
resume_all_vcpus();
if (!runstate_check(RUN_STATE_RUNNING) &&
!runstate_check(RUN_STATE_INMIGRATE)) {
runstate_set(RUN_STATE_PRELAUNCH);
}
}
if (qemu_wakeup_requested()) {
pause_all_vcpus();
qemu_system_reset(SHUTDOWN_CAUSE_NONE);
notifier_list_notify(&wakeup_notifiers, &wakeup_reason);
wakeup_reason = QEMU_WAKEUP_REASON_NONE;
resume_all_vcpus();
qapi_event_send_wakeup(&error_abort);
}
if (qemu_powerdown_requested()) {
qemu_system_powerdown();
}
if (qemu_vmstop_requested(&r)) {
vm_stop(r);
}
return false;
}
| {
"code": [],
"line_no": []
} | static bool FUNC_0(void)
{
RunState r;
ShutdownCause request;
if (qemu_debug_requested()) {
vm_stop(RUN_STATE_DEBUG);
}
if (qemu_suspend_requested()) {
qemu_system_suspend();
}
request = qemu_shutdown_requested();
if (request) {
qemu_kill_report();
qapi_event_send_shutdown(&error_abort);
if (no_shutdown) {
vm_stop(RUN_STATE_SHUTDOWN);
} else {
return true;
}
}
request = qemu_reset_requested();
if (request) {
pause_all_vcpus();
qemu_system_reset(request);
resume_all_vcpus();
if (!runstate_check(RUN_STATE_RUNNING) &&
!runstate_check(RUN_STATE_INMIGRATE)) {
runstate_set(RUN_STATE_PRELAUNCH);
}
}
if (qemu_wakeup_requested()) {
pause_all_vcpus();
qemu_system_reset(SHUTDOWN_CAUSE_NONE);
notifier_list_notify(&wakeup_notifiers, &wakeup_reason);
wakeup_reason = QEMU_WAKEUP_REASON_NONE;
resume_all_vcpus();
qapi_event_send_wakeup(&error_abort);
}
if (qemu_powerdown_requested()) {
qemu_system_powerdown();
}
if (qemu_vmstop_requested(&r)) {
vm_stop(r);
}
return false;
}
| [
"static bool FUNC_0(void)\n{",
"RunState r;",
"ShutdownCause request;",
"if (qemu_debug_requested()) {",
"vm_stop(RUN_STATE_DEBUG);",
"}",
"if (qemu_suspend_requested()) {",
"qemu_system_suspend();",
"}",
"request = qemu_shutdown_requested();",
"if (request) {",
"qemu_kill_report();",
"qapi_event_send_shutdown(&error_abort);",
"if (no_shutdown) {",
"vm_stop(RUN_STATE_SHUTDOWN);",
"} else {",
"return true;",
"}",
"}",
"request = qemu_reset_requested();",
"if (request) {",
"pause_all_vcpus();",
"qemu_system_reset(request);",
"resume_all_vcpus();",
"if (!runstate_check(RUN_STATE_RUNNING) &&\n!runstate_check(RUN_STATE_INMIGRATE)) {",
"runstate_set(RUN_STATE_PRELAUNCH);",
"}",
"}",
"if (qemu_wakeup_requested()) {",
"pause_all_vcpus();",
"qemu_system_reset(SHUTDOWN_CAUSE_NONE);",
"notifier_list_notify(&wakeup_notifiers, &wakeup_reason);",
"wakeup_reason = QEMU_WAKEUP_REASON_NONE;",
"resume_all_vcpus();",
"qapi_event_send_wakeup(&error_abort);",
"}",
"if (qemu_powerdown_requested()) {",
"qemu_system_powerdown();",
"}",
"if (qemu_vmstop_requested(&r)) {",
"vm_stop(r);",
"}",
"return false;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
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
]
] |
4,462 | soread(so)
struct socket *so;
{
int n, nn, lss, total;
struct sbuf *sb = &so->so_snd;
int len = sb->sb_datalen - sb->sb_cc;
struct iovec iov[2];
int mss = so->so_tcpcb->t_maxseg;
DEBUG_CALL("soread");
DEBUG_ARG("so = %lx", (long )so);
/*
* No need to check if there's enough room to read.
* soread wouldn't have been called if there weren't
*/
len = sb->sb_datalen - sb->sb_cc;
iov[0].iov_base = sb->sb_wptr;
if (sb->sb_wptr < sb->sb_rptr) {
iov[0].iov_len = sb->sb_rptr - sb->sb_wptr;
/* Should never succeed, but... */
if (iov[0].iov_len > len)
iov[0].iov_len = len;
if (iov[0].iov_len > mss)
iov[0].iov_len -= iov[0].iov_len%mss;
n = 1;
} else {
iov[0].iov_len = (sb->sb_data + sb->sb_datalen) - sb->sb_wptr;
/* Should never succeed, but... */
if (iov[0].iov_len > len) iov[0].iov_len = len;
len -= iov[0].iov_len;
if (len) {
iov[1].iov_base = sb->sb_data;
iov[1].iov_len = sb->sb_rptr - sb->sb_data;
if(iov[1].iov_len > len)
iov[1].iov_len = len;
total = iov[0].iov_len + iov[1].iov_len;
if (total > mss) {
lss = total%mss;
if (iov[1].iov_len > lss) {
iov[1].iov_len -= lss;
n = 2;
} else {
lss -= iov[1].iov_len;
iov[0].iov_len -= lss;
n = 1;
}
} else
n = 2;
} else {
if (iov[0].iov_len > mss)
iov[0].iov_len -= iov[0].iov_len%mss;
n = 1;
}
}
#ifdef HAVE_READV
nn = readv(so->s, (struct iovec *)iov, n);
DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn));
#else
nn = recv(so->s, iov[0].iov_base, iov[0].iov_len,0);
#endif
if (nn <= 0) {
if (nn < 0 && (errno == EINTR || errno == EAGAIN))
return 0;
else {
DEBUG_MISC((dfd, " --- soread() disconnected, nn = %d, errno = %d-%s\n", nn, errno,strerror(errno)));
sofcantrcvmore(so);
tcp_sockclosed(sototcpcb(so));
return -1;
}
}
#ifndef HAVE_READV
/*
* If there was no error, try and read the second time round
* We read again if n = 2 (ie, there's another part of the buffer)
* and we read as much as we could in the first read
* We don't test for <= 0 this time, because there legitimately
* might not be any more data (since the socket is non-blocking),
* a close will be detected on next iteration.
* A return of -1 wont (shouldn't) happen, since it didn't happen above
*/
if (n == 2 && nn == iov[0].iov_len)
nn += recv(so->s, iov[1].iov_base, iov[1].iov_len,0);
DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn));
#endif
/* Update fields */
sb->sb_cc += nn;
sb->sb_wptr += nn;
if (sb->sb_wptr >= (sb->sb_data + sb->sb_datalen))
sb->sb_wptr -= sb->sb_datalen;
return nn;
}
| false | qemu | 17444c9c84fd0c8679499198fd4ee3b155fb297f | soread(so)
struct socket *so;
{
int n, nn, lss, total;
struct sbuf *sb = &so->so_snd;
int len = sb->sb_datalen - sb->sb_cc;
struct iovec iov[2];
int mss = so->so_tcpcb->t_maxseg;
DEBUG_CALL("soread");
DEBUG_ARG("so = %lx", (long )so);
len = sb->sb_datalen - sb->sb_cc;
iov[0].iov_base = sb->sb_wptr;
if (sb->sb_wptr < sb->sb_rptr) {
iov[0].iov_len = sb->sb_rptr - sb->sb_wptr;
if (iov[0].iov_len > len)
iov[0].iov_len = len;
if (iov[0].iov_len > mss)
iov[0].iov_len -= iov[0].iov_len%mss;
n = 1;
} else {
iov[0].iov_len = (sb->sb_data + sb->sb_datalen) - sb->sb_wptr;
if (iov[0].iov_len > len) iov[0].iov_len = len;
len -= iov[0].iov_len;
if (len) {
iov[1].iov_base = sb->sb_data;
iov[1].iov_len = sb->sb_rptr - sb->sb_data;
if(iov[1].iov_len > len)
iov[1].iov_len = len;
total = iov[0].iov_len + iov[1].iov_len;
if (total > mss) {
lss = total%mss;
if (iov[1].iov_len > lss) {
iov[1].iov_len -= lss;
n = 2;
} else {
lss -= iov[1].iov_len;
iov[0].iov_len -= lss;
n = 1;
}
} else
n = 2;
} else {
if (iov[0].iov_len > mss)
iov[0].iov_len -= iov[0].iov_len%mss;
n = 1;
}
}
#ifdef HAVE_READV
nn = readv(so->s, (struct iovec *)iov, n);
DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn));
#else
nn = recv(so->s, iov[0].iov_base, iov[0].iov_len,0);
#endif
if (nn <= 0) {
if (nn < 0 && (errno == EINTR || errno == EAGAIN))
return 0;
else {
DEBUG_MISC((dfd, " --- soread() disconnected, nn = %d, errno = %d-%s\n", nn, errno,strerror(errno)));
sofcantrcvmore(so);
tcp_sockclosed(sototcpcb(so));
return -1;
}
}
#ifndef HAVE_READV
if (n == 2 && nn == iov[0].iov_len)
nn += recv(so->s, iov[1].iov_base, iov[1].iov_len,0);
DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn));
#endif
sb->sb_cc += nn;
sb->sb_wptr += nn;
if (sb->sb_wptr >= (sb->sb_data + sb->sb_datalen))
sb->sb_wptr -= sb->sb_datalen;
return nn;
}
| {
"code": [],
"line_no": []
} | FUNC_0(VAR_0)
struct socket *VAR_0;
{
int VAR_1, VAR_2, VAR_3, VAR_4;
struct sbuf *VAR_5 = &VAR_0->so_snd;
int VAR_6 = VAR_5->sb_datalen - VAR_5->sb_cc;
struct iovec VAR_7[2];
int VAR_8 = VAR_0->so_tcpcb->t_maxseg;
DEBUG_CALL("FUNC_0");
DEBUG_ARG("VAR_0 = %lx", (long )VAR_0);
VAR_6 = VAR_5->sb_datalen - VAR_5->sb_cc;
VAR_7[0].iov_base = VAR_5->sb_wptr;
if (VAR_5->sb_wptr < VAR_5->sb_rptr) {
VAR_7[0].iov_len = VAR_5->sb_rptr - VAR_5->sb_wptr;
if (VAR_7[0].iov_len > VAR_6)
VAR_7[0].iov_len = VAR_6;
if (VAR_7[0].iov_len > VAR_8)
VAR_7[0].iov_len -= VAR_7[0].iov_len%VAR_8;
VAR_1 = 1;
} else {
VAR_7[0].iov_len = (VAR_5->sb_data + VAR_5->sb_datalen) - VAR_5->sb_wptr;
if (VAR_7[0].iov_len > VAR_6) VAR_7[0].iov_len = VAR_6;
VAR_6 -= VAR_7[0].iov_len;
if (VAR_6) {
VAR_7[1].iov_base = VAR_5->sb_data;
VAR_7[1].iov_len = VAR_5->sb_rptr - VAR_5->sb_data;
if(VAR_7[1].iov_len > VAR_6)
VAR_7[1].iov_len = VAR_6;
VAR_4 = VAR_7[0].iov_len + VAR_7[1].iov_len;
if (VAR_4 > VAR_8) {
VAR_3 = VAR_4%VAR_8;
if (VAR_7[1].iov_len > VAR_3) {
VAR_7[1].iov_len -= VAR_3;
VAR_1 = 2;
} else {
VAR_3 -= VAR_7[1].iov_len;
VAR_7[0].iov_len -= VAR_3;
VAR_1 = 1;
}
} else
VAR_1 = 2;
} else {
if (VAR_7[0].iov_len > VAR_8)
VAR_7[0].iov_len -= VAR_7[0].iov_len%VAR_8;
VAR_1 = 1;
}
}
#ifdef HAVE_READV
VAR_2 = readv(VAR_0->s, (struct iovec *)VAR_7, VAR_1);
DEBUG_MISC((dfd, " ... read VAR_2 = %d bytes\VAR_1", VAR_2));
#else
VAR_2 = recv(VAR_0->s, VAR_7[0].iov_base, VAR_7[0].iov_len,0);
#endif
if (VAR_2 <= 0) {
if (VAR_2 < 0 && (errno == EINTR || errno == EAGAIN))
return 0;
else {
DEBUG_MISC((dfd, " --- FUNC_0() disconnected, VAR_2 = %d, errno = %d-%s\VAR_1", VAR_2, errno,strerror(errno)));
sofcantrcvmore(VAR_0);
tcp_sockclosed(sototcpcb(VAR_0));
return -1;
}
}
#ifndef HAVE_READV
if (VAR_1 == 2 && VAR_2 == VAR_7[0].iov_len)
VAR_2 += recv(VAR_0->s, VAR_7[1].iov_base, VAR_7[1].iov_len,0);
DEBUG_MISC((dfd, " ... read VAR_2 = %d bytes\VAR_1", VAR_2));
#endif
VAR_5->sb_cc += VAR_2;
VAR_5->sb_wptr += VAR_2;
if (VAR_5->sb_wptr >= (VAR_5->sb_data + VAR_5->sb_datalen))
VAR_5->sb_wptr -= VAR_5->sb_datalen;
return VAR_2;
}
| [
"FUNC_0(VAR_0)\nstruct socket *VAR_0;",
"{",
"int VAR_1, VAR_2, VAR_3, VAR_4;",
"struct sbuf *VAR_5 = &VAR_0->so_snd;",
"int VAR_6 = VAR_5->sb_datalen - VAR_5->sb_cc;",
"struct iovec VAR_7[2];",
"int VAR_8 = VAR_0->so_tcpcb->t_maxseg;",
"DEBUG_CALL(\"FUNC_0\");",
"DEBUG_ARG(\"VAR_0 = %lx\", (long )VAR_0);",
"VAR_6 = VAR_5->sb_datalen - VAR_5->sb_cc;",
"VAR_7[0].iov_base = VAR_5->sb_wptr;",
"if (VAR_5->sb_wptr < VAR_5->sb_rptr) {",
"VAR_7[0].iov_len = VAR_5->sb_rptr - VAR_5->sb_wptr;",
"if (VAR_7[0].iov_len > VAR_6)\nVAR_7[0].iov_len = VAR_6;",
"if (VAR_7[0].iov_len > VAR_8)\nVAR_7[0].iov_len -= VAR_7[0].iov_len%VAR_8;",
"VAR_1 = 1;",
"} else {",
"VAR_7[0].iov_len = (VAR_5->sb_data + VAR_5->sb_datalen) - VAR_5->sb_wptr;",
"if (VAR_7[0].iov_len > VAR_6) VAR_7[0].iov_len = VAR_6;",
"VAR_6 -= VAR_7[0].iov_len;",
"if (VAR_6) {",
"VAR_7[1].iov_base = VAR_5->sb_data;",
"VAR_7[1].iov_len = VAR_5->sb_rptr - VAR_5->sb_data;",
"if(VAR_7[1].iov_len > VAR_6)\nVAR_7[1].iov_len = VAR_6;",
"VAR_4 = VAR_7[0].iov_len + VAR_7[1].iov_len;",
"if (VAR_4 > VAR_8) {",
"VAR_3 = VAR_4%VAR_8;",
"if (VAR_7[1].iov_len > VAR_3) {",
"VAR_7[1].iov_len -= VAR_3;",
"VAR_1 = 2;",
"} else {",
"VAR_3 -= VAR_7[1].iov_len;",
"VAR_7[0].iov_len -= VAR_3;",
"VAR_1 = 1;",
"}",
"} else",
"VAR_1 = 2;",
"} else {",
"if (VAR_7[0].iov_len > VAR_8)\nVAR_7[0].iov_len -= VAR_7[0].iov_len%VAR_8;",
"VAR_1 = 1;",
"}",
"}",
"#ifdef HAVE_READV\nVAR_2 = readv(VAR_0->s, (struct iovec *)VAR_7, VAR_1);",
"DEBUG_MISC((dfd, \" ... read VAR_2 = %d bytes\\VAR_1\", VAR_2));",
"#else\nVAR_2 = recv(VAR_0->s, VAR_7[0].iov_base, VAR_7[0].iov_len,0);",
"#endif\nif (VAR_2 <= 0) {",
"if (VAR_2 < 0 && (errno == EINTR || errno == EAGAIN))\nreturn 0;",
"else {",
"DEBUG_MISC((dfd, \" --- FUNC_0() disconnected, VAR_2 = %d, errno = %d-%s\\VAR_1\", VAR_2, errno,strerror(errno)));",
"sofcantrcvmore(VAR_0);",
"tcp_sockclosed(sototcpcb(VAR_0));",
"return -1;",
"}",
"}",
"#ifndef HAVE_READV\nif (VAR_1 == 2 && VAR_2 == VAR_7[0].iov_len)\nVAR_2 += recv(VAR_0->s, VAR_7[1].iov_base, VAR_7[1].iov_len,0);",
"DEBUG_MISC((dfd, \" ... read VAR_2 = %d bytes\\VAR_1\", VAR_2));",
"#endif\nVAR_5->sb_cc += VAR_2;",
"VAR_5->sb_wptr += VAR_2;",
"if (VAR_5->sb_wptr >= (VAR_5->sb_data + VAR_5->sb_datalen))\nVAR_5->sb_wptr -= VAR_5->sb_datalen;",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
35
],
[
39
],
[
41
],
[
43
],
[
47,
49
],
[
51,
53
],
[
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
],
[
109
],
[
111
],
[
113
],
[
117,
119
],
[
121
],
[
123,
125
],
[
127,
129
],
[
131,
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
151,
171,
173
],
[
177
],
[
179,
185
],
[
187
],
[
189,
191
],
[
193
],
[
195
]
] |
4,463 | static inline bool object_property_is_link(ObjectProperty *prop)
{
return strstart(prop->type, "link<", NULL);
}
| false | qemu | 64607d088132abdb25bf30d93e97d0c8df7b364c | static inline bool object_property_is_link(ObjectProperty *prop)
{
return strstart(prop->type, "link<", NULL);
}
| {
"code": [],
"line_no": []
} | static inline bool FUNC_0(ObjectProperty *prop)
{
return strstart(prop->type, "link<", NULL);
}
| [
"static inline bool FUNC_0(ObjectProperty *prop)\n{",
"return strstart(prop->type, \"link<\", NULL);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
4,464 | static uint64_t mpcore_scu_read(void *opaque, target_phys_addr_t offset,
unsigned size)
{
mpcore_priv_state *s = (mpcore_priv_state *)opaque;
int id;
/* SCU */
switch (offset) {
case 0x00: /* Control. */
return s->scu_control;
case 0x04: /* Configuration. */
id = ((1 << s->num_cpu) - 1) << 4;
return id | (s->num_cpu - 1);
case 0x08: /* CPU status. */
return 0;
case 0x0c: /* Invalidate all. */
return 0;
default:
hw_error("mpcore_priv_read: Bad offset %x\n", (int)offset);
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t mpcore_scu_read(void *opaque, target_phys_addr_t offset,
unsigned size)
{
mpcore_priv_state *s = (mpcore_priv_state *)opaque;
int id;
switch (offset) {
case 0x00:
return s->scu_control;
case 0x04:
id = ((1 << s->num_cpu) - 1) << 4;
return id | (s->num_cpu - 1);
case 0x08:
return 0;
case 0x0c:
return 0;
default:
hw_error("mpcore_priv_read: Bad offset %x\n", (int)offset);
}
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t offset,
unsigned size)
{
mpcore_priv_state *s = (mpcore_priv_state *)opaque;
int VAR_0;
switch (offset) {
case 0x00:
return s->scu_control;
case 0x04:
VAR_0 = ((1 << s->num_cpu) - 1) << 4;
return VAR_0 | (s->num_cpu - 1);
case 0x08:
return 0;
case 0x0c:
return 0;
default:
hw_error("mpcore_priv_read: Bad offset %x\n", (int)offset);
}
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t offset,\nunsigned size)\n{",
"mpcore_priv_state *s = (mpcore_priv_state *)opaque;",
"int VAR_0;",
"switch (offset) {",
"case 0x00:\nreturn s->scu_control;",
"case 0x04:\nVAR_0 = ((1 << s->num_cpu) - 1) << 4;",
"return VAR_0 | (s->num_cpu - 1);",
"case 0x08:\nreturn 0;",
"case 0x0c:\nreturn 0;",
"default:\nhw_error(\"mpcore_priv_read: Bad offset %x\\n\", (int)offset);",
"}",
"}"
] | [
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
]
] |
4,465 | static int64_t run_opencl_bench(AVOpenCLExternalEnv *ext_opencl_env)
{
int i, arg = 0, width = 1920, height = 1088;
int64_t start, ret = 0;
cl_int status;
size_t kernel_len;
char *inbuf;
int *mask;
int buf_size = width * height * sizeof(char);
int mask_size = sizeof(uint32_t) * 128;
cl_mem cl_mask, cl_inbuf, cl_outbuf;
cl_kernel kernel = NULL;
cl_program program = NULL;
size_t local_work_size_2d[2] = {16, 16};
size_t global_work_size_2d[2] = {(size_t)width, (size_t)height};
if (!(inbuf = av_malloc(buf_size)) || !(mask = av_malloc(mask_size))) {
av_log(NULL, AV_LOG_ERROR, "Out of memory\n");
ret = AVERROR(ENOMEM);
goto end;
}
fill_rand_int((int*)inbuf, buf_size/4);
fill_rand_int(mask, mask_size/4);
CREATEBUF(cl_mask, CL_MEM_READ_ONLY, mask_size);
CREATEBUF(cl_inbuf, CL_MEM_READ_ONLY, buf_size);
CREATEBUF(cl_outbuf, CL_MEM_READ_WRITE, buf_size);
kernel_len = strlen(ocl_bench_source);
program = clCreateProgramWithSource(ext_opencl_env->context, 1, &ocl_bench_source,
&kernel_len, &status);
if (status != CL_SUCCESS || !program) {
av_log(NULL, AV_LOG_ERROR, "OpenCL unable to create benchmark program\n");
ret = AVERROR_EXTERNAL;
goto end;
}
status = clBuildProgram(program, 1, &(ext_opencl_env->device_id), NULL, NULL, NULL);
if (status != CL_SUCCESS) {
av_log(NULL, AV_LOG_ERROR, "OpenCL unable to build benchmark program\n");
ret = AVERROR_EXTERNAL;
goto end;
}
kernel = clCreateKernel(program, "unsharp_bench", &status);
if (status != CL_SUCCESS) {
av_log(NULL, AV_LOG_ERROR, "OpenCL unable to create benchmark kernel\n");
ret = AVERROR_EXTERNAL;
goto end;
}
OCLCHECK(clEnqueueWriteBuffer, ext_opencl_env->command_queue, cl_inbuf, CL_TRUE, 0,
buf_size, inbuf, 0, NULL, NULL);
OCLCHECK(clEnqueueWriteBuffer, ext_opencl_env->command_queue, cl_mask, CL_TRUE, 0,
mask_size, mask, 0, NULL, NULL);
OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_mem), &cl_inbuf);
OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_mem), &cl_outbuf);
OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_mem), &cl_mask);
OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_int), &width);
OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_int), &height);
start = av_gettime_relative();
for (i = 0; i < OPENCL_NB_ITER; i++)
OCLCHECK(clEnqueueNDRangeKernel, ext_opencl_env->command_queue, kernel, 2, NULL,
global_work_size_2d, local_work_size_2d, 0, NULL, NULL);
clFinish(ext_opencl_env->command_queue);
ret = (av_gettime_relative() - start)/OPENCL_NB_ITER;
end:
if (kernel)
clReleaseKernel(kernel);
if (program)
clReleaseProgram(program);
if (cl_inbuf)
clReleaseMemObject(cl_inbuf);
if (cl_outbuf)
clReleaseMemObject(cl_outbuf);
if (cl_mask)
clReleaseMemObject(cl_mask);
av_free(inbuf);
av_free(mask);
return ret;
}
| true | FFmpeg | d712a5cddbfc12e21384f97a291aa64ea7e8005f | static int64_t run_opencl_bench(AVOpenCLExternalEnv *ext_opencl_env)
{
int i, arg = 0, width = 1920, height = 1088;
int64_t start, ret = 0;
cl_int status;
size_t kernel_len;
char *inbuf;
int *mask;
int buf_size = width * height * sizeof(char);
int mask_size = sizeof(uint32_t) * 128;
cl_mem cl_mask, cl_inbuf, cl_outbuf;
cl_kernel kernel = NULL;
cl_program program = NULL;
size_t local_work_size_2d[2] = {16, 16};
size_t global_work_size_2d[2] = {(size_t)width, (size_t)height};
if (!(inbuf = av_malloc(buf_size)) || !(mask = av_malloc(mask_size))) {
av_log(NULL, AV_LOG_ERROR, "Out of memory\n");
ret = AVERROR(ENOMEM);
goto end;
}
fill_rand_int((int*)inbuf, buf_size/4);
fill_rand_int(mask, mask_size/4);
CREATEBUF(cl_mask, CL_MEM_READ_ONLY, mask_size);
CREATEBUF(cl_inbuf, CL_MEM_READ_ONLY, buf_size);
CREATEBUF(cl_outbuf, CL_MEM_READ_WRITE, buf_size);
kernel_len = strlen(ocl_bench_source);
program = clCreateProgramWithSource(ext_opencl_env->context, 1, &ocl_bench_source,
&kernel_len, &status);
if (status != CL_SUCCESS || !program) {
av_log(NULL, AV_LOG_ERROR, "OpenCL unable to create benchmark program\n");
ret = AVERROR_EXTERNAL;
goto end;
}
status = clBuildProgram(program, 1, &(ext_opencl_env->device_id), NULL, NULL, NULL);
if (status != CL_SUCCESS) {
av_log(NULL, AV_LOG_ERROR, "OpenCL unable to build benchmark program\n");
ret = AVERROR_EXTERNAL;
goto end;
}
kernel = clCreateKernel(program, "unsharp_bench", &status);
if (status != CL_SUCCESS) {
av_log(NULL, AV_LOG_ERROR, "OpenCL unable to create benchmark kernel\n");
ret = AVERROR_EXTERNAL;
goto end;
}
OCLCHECK(clEnqueueWriteBuffer, ext_opencl_env->command_queue, cl_inbuf, CL_TRUE, 0,
buf_size, inbuf, 0, NULL, NULL);
OCLCHECK(clEnqueueWriteBuffer, ext_opencl_env->command_queue, cl_mask, CL_TRUE, 0,
mask_size, mask, 0, NULL, NULL);
OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_mem), &cl_inbuf);
OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_mem), &cl_outbuf);
OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_mem), &cl_mask);
OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_int), &width);
OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_int), &height);
start = av_gettime_relative();
for (i = 0; i < OPENCL_NB_ITER; i++)
OCLCHECK(clEnqueueNDRangeKernel, ext_opencl_env->command_queue, kernel, 2, NULL,
global_work_size_2d, local_work_size_2d, 0, NULL, NULL);
clFinish(ext_opencl_env->command_queue);
ret = (av_gettime_relative() - start)/OPENCL_NB_ITER;
end:
if (kernel)
clReleaseKernel(kernel);
if (program)
clReleaseProgram(program);
if (cl_inbuf)
clReleaseMemObject(cl_inbuf);
if (cl_outbuf)
clReleaseMemObject(cl_outbuf);
if (cl_mask)
clReleaseMemObject(cl_mask);
av_free(inbuf);
av_free(mask);
return ret;
}
| {
"code": [
" int *mask;"
],
"line_no": [
15
]
} | static int64_t FUNC_0(AVOpenCLExternalEnv *ext_opencl_env)
{
int VAR_0, VAR_1 = 0, VAR_2 = 1920, VAR_3 = 1088;
int64_t start, ret = 0;
cl_int status;
size_t kernel_len;
char *VAR_4;
int *VAR_5;
int VAR_6 = VAR_2 * VAR_3 * sizeof(char);
int VAR_7 = sizeof(uint32_t) * 128;
cl_mem cl_mask, cl_inbuf, cl_outbuf;
cl_kernel kernel = NULL;
cl_program program = NULL;
size_t local_work_size_2d[2] = {16, 16};
size_t global_work_size_2d[2] = {(size_t)VAR_2, (size_t)VAR_3};
if (!(VAR_4 = av_malloc(VAR_6)) || !(VAR_5 = av_malloc(VAR_7))) {
av_log(NULL, AV_LOG_ERROR, "Out of memory\n");
ret = AVERROR(ENOMEM);
goto end;
}
fill_rand_int((int*)VAR_4, VAR_6/4);
fill_rand_int(VAR_5, VAR_7/4);
CREATEBUF(cl_mask, CL_MEM_READ_ONLY, VAR_7);
CREATEBUF(cl_inbuf, CL_MEM_READ_ONLY, VAR_6);
CREATEBUF(cl_outbuf, CL_MEM_READ_WRITE, VAR_6);
kernel_len = strlen(ocl_bench_source);
program = clCreateProgramWithSource(ext_opencl_env->context, 1, &ocl_bench_source,
&kernel_len, &status);
if (status != CL_SUCCESS || !program) {
av_log(NULL, AV_LOG_ERROR, "OpenCL unable to create benchmark program\n");
ret = AVERROR_EXTERNAL;
goto end;
}
status = clBuildProgram(program, 1, &(ext_opencl_env->device_id), NULL, NULL, NULL);
if (status != CL_SUCCESS) {
av_log(NULL, AV_LOG_ERROR, "OpenCL unable to build benchmark program\n");
ret = AVERROR_EXTERNAL;
goto end;
}
kernel = clCreateKernel(program, "unsharp_bench", &status);
if (status != CL_SUCCESS) {
av_log(NULL, AV_LOG_ERROR, "OpenCL unable to create benchmark kernel\n");
ret = AVERROR_EXTERNAL;
goto end;
}
OCLCHECK(clEnqueueWriteBuffer, ext_opencl_env->command_queue, cl_inbuf, CL_TRUE, 0,
VAR_6, VAR_4, 0, NULL, NULL);
OCLCHECK(clEnqueueWriteBuffer, ext_opencl_env->command_queue, cl_mask, CL_TRUE, 0,
VAR_7, VAR_5, 0, NULL, NULL);
OCLCHECK(clSetKernelArg, kernel, VAR_1++, sizeof(cl_mem), &cl_inbuf);
OCLCHECK(clSetKernelArg, kernel, VAR_1++, sizeof(cl_mem), &cl_outbuf);
OCLCHECK(clSetKernelArg, kernel, VAR_1++, sizeof(cl_mem), &cl_mask);
OCLCHECK(clSetKernelArg, kernel, VAR_1++, sizeof(cl_int), &VAR_2);
OCLCHECK(clSetKernelArg, kernel, VAR_1++, sizeof(cl_int), &VAR_3);
start = av_gettime_relative();
for (VAR_0 = 0; VAR_0 < OPENCL_NB_ITER; VAR_0++)
OCLCHECK(clEnqueueNDRangeKernel, ext_opencl_env->command_queue, kernel, 2, NULL,
global_work_size_2d, local_work_size_2d, 0, NULL, NULL);
clFinish(ext_opencl_env->command_queue);
ret = (av_gettime_relative() - start)/OPENCL_NB_ITER;
end:
if (kernel)
clReleaseKernel(kernel);
if (program)
clReleaseProgram(program);
if (cl_inbuf)
clReleaseMemObject(cl_inbuf);
if (cl_outbuf)
clReleaseMemObject(cl_outbuf);
if (cl_mask)
clReleaseMemObject(cl_mask);
av_free(VAR_4);
av_free(VAR_5);
return ret;
}
| [
"static int64_t FUNC_0(AVOpenCLExternalEnv *ext_opencl_env)\n{",
"int VAR_0, VAR_1 = 0, VAR_2 = 1920, VAR_3 = 1088;",
"int64_t start, ret = 0;",
"cl_int status;",
"size_t kernel_len;",
"char *VAR_4;",
"int *VAR_5;",
"int VAR_6 = VAR_2 * VAR_3 * sizeof(char);",
"int VAR_7 = sizeof(uint32_t) * 128;",
"cl_mem cl_mask, cl_inbuf, cl_outbuf;",
"cl_kernel kernel = NULL;",
"cl_program program = NULL;",
"size_t local_work_size_2d[2] = {16, 16};",
"size_t global_work_size_2d[2] = {(size_t)VAR_2, (size_t)VAR_3};",
"if (!(VAR_4 = av_malloc(VAR_6)) || !(VAR_5 = av_malloc(VAR_7))) {",
"av_log(NULL, AV_LOG_ERROR, \"Out of memory\\n\");",
"ret = AVERROR(ENOMEM);",
"goto end;",
"}",
"fill_rand_int((int*)VAR_4, VAR_6/4);",
"fill_rand_int(VAR_5, VAR_7/4);",
"CREATEBUF(cl_mask, CL_MEM_READ_ONLY, VAR_7);",
"CREATEBUF(cl_inbuf, CL_MEM_READ_ONLY, VAR_6);",
"CREATEBUF(cl_outbuf, CL_MEM_READ_WRITE, VAR_6);",
"kernel_len = strlen(ocl_bench_source);",
"program = clCreateProgramWithSource(ext_opencl_env->context, 1, &ocl_bench_source,\n&kernel_len, &status);",
"if (status != CL_SUCCESS || !program) {",
"av_log(NULL, AV_LOG_ERROR, \"OpenCL unable to create benchmark program\\n\");",
"ret = AVERROR_EXTERNAL;",
"goto end;",
"}",
"status = clBuildProgram(program, 1, &(ext_opencl_env->device_id), NULL, NULL, NULL);",
"if (status != CL_SUCCESS) {",
"av_log(NULL, AV_LOG_ERROR, \"OpenCL unable to build benchmark program\\n\");",
"ret = AVERROR_EXTERNAL;",
"goto end;",
"}",
"kernel = clCreateKernel(program, \"unsharp_bench\", &status);",
"if (status != CL_SUCCESS) {",
"av_log(NULL, AV_LOG_ERROR, \"OpenCL unable to create benchmark kernel\\n\");",
"ret = AVERROR_EXTERNAL;",
"goto end;",
"}",
"OCLCHECK(clEnqueueWriteBuffer, ext_opencl_env->command_queue, cl_inbuf, CL_TRUE, 0,\nVAR_6, VAR_4, 0, NULL, NULL);",
"OCLCHECK(clEnqueueWriteBuffer, ext_opencl_env->command_queue, cl_mask, CL_TRUE, 0,\nVAR_7, VAR_5, 0, NULL, NULL);",
"OCLCHECK(clSetKernelArg, kernel, VAR_1++, sizeof(cl_mem), &cl_inbuf);",
"OCLCHECK(clSetKernelArg, kernel, VAR_1++, sizeof(cl_mem), &cl_outbuf);",
"OCLCHECK(clSetKernelArg, kernel, VAR_1++, sizeof(cl_mem), &cl_mask);",
"OCLCHECK(clSetKernelArg, kernel, VAR_1++, sizeof(cl_int), &VAR_2);",
"OCLCHECK(clSetKernelArg, kernel, VAR_1++, sizeof(cl_int), &VAR_3);",
"start = av_gettime_relative();",
"for (VAR_0 = 0; VAR_0 < OPENCL_NB_ITER; VAR_0++)",
"OCLCHECK(clEnqueueNDRangeKernel, ext_opencl_env->command_queue, kernel, 2, NULL,\nglobal_work_size_2d, local_work_size_2d, 0, NULL, NULL);",
"clFinish(ext_opencl_env->command_queue);",
"ret = (av_gettime_relative() - start)/OPENCL_NB_ITER;",
"end:\nif (kernel)\nclReleaseKernel(kernel);",
"if (program)\nclReleaseProgram(program);",
"if (cl_inbuf)\nclReleaseMemObject(cl_inbuf);",
"if (cl_outbuf)\nclReleaseMemObject(cl_outbuf);",
"if (cl_mask)\nclReleaseMemObject(cl_mask);",
"av_free(VAR_4);",
"av_free(VAR_5);",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101,
103
],
[
105,
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125,
127
],
[
129
],
[
131
],
[
133,
135,
137
],
[
139,
141
],
[
143,
145
],
[
147,
149
],
[
151,
153
],
[
155
],
[
157
],
[
159
],
[
161
]
] |
4,466 | static int local_symlink(FsContext *fs_ctx, const char *oldpath,
const char *newpath, FsCred *credp)
{
int err = -1;
int serrno = 0;
/* Determine the security model */
if (fs_ctx->fs_sm == SM_MAPPED) {
int fd;
ssize_t oldpath_size, write_size;
fd = open(rpath(fs_ctx, newpath), O_CREAT|O_EXCL|O_RDWR,
SM_LOCAL_MODE_BITS);
if (fd == -1) {
return fd;
}
/* Write the oldpath (target) to the file. */
oldpath_size = strlen(oldpath) + 1;
do {
write_size = write(fd, (void *)oldpath, oldpath_size);
} while (write_size == -1 && errno == EINTR);
if (write_size != oldpath_size) {
serrno = errno;
close(fd);
err = -1;
goto err_end;
}
close(fd);
/* Set cleint credentials in symlink's xattr */
credp->fc_mode = credp->fc_mode|S_IFLNK;
err = local_set_xattr(rpath(fs_ctx, newpath), credp);
if (err == -1) {
serrno = errno;
goto err_end;
}
} else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
(fs_ctx->fs_sm == SM_NONE)) {
err = symlink(oldpath, rpath(fs_ctx, newpath));
if (err) {
return err;
}
err = lchown(rpath(fs_ctx, newpath), credp->fc_uid, credp->fc_gid);
if (err == -1) {
/*
* If we fail to change ownership and if we are
* using security model none. Ignore the error
*/
if (fs_ctx->fs_sm != SM_NONE) {
serrno = errno;
goto err_end;
} else
err = 0;
}
}
return err;
err_end:
remove(rpath(fs_ctx, newpath));
errno = serrno;
return err;
}
| true | qemu | f35bde2f8fb55541d4d7ddca50d64ce5a6ef384c | static int local_symlink(FsContext *fs_ctx, const char *oldpath,
const char *newpath, FsCred *credp)
{
int err = -1;
int serrno = 0;
if (fs_ctx->fs_sm == SM_MAPPED) {
int fd;
ssize_t oldpath_size, write_size;
fd = open(rpath(fs_ctx, newpath), O_CREAT|O_EXCL|O_RDWR,
SM_LOCAL_MODE_BITS);
if (fd == -1) {
return fd;
}
oldpath_size = strlen(oldpath) + 1;
do {
write_size = write(fd, (void *)oldpath, oldpath_size);
} while (write_size == -1 && errno == EINTR);
if (write_size != oldpath_size) {
serrno = errno;
close(fd);
err = -1;
goto err_end;
}
close(fd);
credp->fc_mode = credp->fc_mode|S_IFLNK;
err = local_set_xattr(rpath(fs_ctx, newpath), credp);
if (err == -1) {
serrno = errno;
goto err_end;
}
} else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
(fs_ctx->fs_sm == SM_NONE)) {
err = symlink(oldpath, rpath(fs_ctx, newpath));
if (err) {
return err;
}
err = lchown(rpath(fs_ctx, newpath), credp->fc_uid, credp->fc_gid);
if (err == -1) {
if (fs_ctx->fs_sm != SM_NONE) {
serrno = errno;
goto err_end;
} else
err = 0;
}
}
return err;
err_end:
remove(rpath(fs_ctx, newpath));
errno = serrno;
return err;
}
| {
"code": [
" oldpath_size = strlen(oldpath) + 1;"
],
"line_no": [
33
]
} | static int FUNC_0(FsContext *VAR_0, const char *VAR_1,
const char *VAR_2, FsCred *VAR_3)
{
int VAR_4 = -1;
int VAR_5 = 0;
if (VAR_0->fs_sm == SM_MAPPED) {
int VAR_6;
ssize_t oldpath_size, write_size;
VAR_6 = open(rpath(VAR_0, VAR_2), O_CREAT|O_EXCL|O_RDWR,
SM_LOCAL_MODE_BITS);
if (VAR_6 == -1) {
return VAR_6;
}
oldpath_size = strlen(VAR_1) + 1;
do {
write_size = write(VAR_6, (void *)VAR_1, oldpath_size);
} while (write_size == -1 && errno == EINTR);
if (write_size != oldpath_size) {
VAR_5 = errno;
close(VAR_6);
VAR_4 = -1;
goto err_end;
}
close(VAR_6);
VAR_3->fc_mode = VAR_3->fc_mode|S_IFLNK;
VAR_4 = local_set_xattr(rpath(VAR_0, VAR_2), VAR_3);
if (VAR_4 == -1) {
VAR_5 = errno;
goto err_end;
}
} else if ((VAR_0->fs_sm == SM_PASSTHROUGH) ||
(VAR_0->fs_sm == SM_NONE)) {
VAR_4 = symlink(VAR_1, rpath(VAR_0, VAR_2));
if (VAR_4) {
return VAR_4;
}
VAR_4 = lchown(rpath(VAR_0, VAR_2), VAR_3->fc_uid, VAR_3->fc_gid);
if (VAR_4 == -1) {
if (VAR_0->fs_sm != SM_NONE) {
VAR_5 = errno;
goto err_end;
} else
VAR_4 = 0;
}
}
return VAR_4;
err_end:
remove(rpath(VAR_0, VAR_2));
errno = VAR_5;
return VAR_4;
}
| [
"static int FUNC_0(FsContext *VAR_0, const char *VAR_1,\nconst char *VAR_2, FsCred *VAR_3)\n{",
"int VAR_4 = -1;",
"int VAR_5 = 0;",
"if (VAR_0->fs_sm == SM_MAPPED) {",
"int VAR_6;",
"ssize_t oldpath_size, write_size;",
"VAR_6 = open(rpath(VAR_0, VAR_2), O_CREAT|O_EXCL|O_RDWR,\nSM_LOCAL_MODE_BITS);",
"if (VAR_6 == -1) {",
"return VAR_6;",
"}",
"oldpath_size = strlen(VAR_1) + 1;",
"do {",
"write_size = write(VAR_6, (void *)VAR_1, oldpath_size);",
"} while (write_size == -1 && errno == EINTR);",
"if (write_size != oldpath_size) {",
"VAR_5 = errno;",
"close(VAR_6);",
"VAR_4 = -1;",
"goto err_end;",
"}",
"close(VAR_6);",
"VAR_3->fc_mode = VAR_3->fc_mode|S_IFLNK;",
"VAR_4 = local_set_xattr(rpath(VAR_0, VAR_2), VAR_3);",
"if (VAR_4 == -1) {",
"VAR_5 = errno;",
"goto err_end;",
"}",
"} else if ((VAR_0->fs_sm == SM_PASSTHROUGH) ||",
"(VAR_0->fs_sm == SM_NONE)) {",
"VAR_4 = symlink(VAR_1, rpath(VAR_0, VAR_2));",
"if (VAR_4) {",
"return VAR_4;",
"}",
"VAR_4 = lchown(rpath(VAR_0, VAR_2), VAR_3->fc_uid, VAR_3->fc_gid);",
"if (VAR_4 == -1) {",
"if (VAR_0->fs_sm != SM_NONE) {",
"VAR_5 = errno;",
"goto err_end;",
"} else",
"VAR_4 = 0;",
"}",
"}",
"return VAR_4;",
"err_end:\nremove(rpath(VAR_0, VAR_2));",
"errno = VAR_5;",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
15
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113,
115
],
[
117
],
[
119
],
[
121
]
] |
4,467 | static int parse_strk(AVFormatContext *s,
FourxmDemuxContext *fourxm, uint8_t *buf, int size,
int left)
{
AVStream *st;
int track;
/* check that there is enough data */
if (size != strk_SIZE || left < size + 8)
return AVERROR_INVALIDDATA;
track = AV_RL32(buf + 8);
if ((unsigned)track >= UINT_MAX / sizeof(AudioTrack) - 1) {
av_log(s, AV_LOG_ERROR, "current_track too large\n");
return AVERROR_INVALIDDATA;
}
if (track + 1 > fourxm->track_count) {
if (av_reallocp_array(&fourxm->tracks, track + 1, sizeof(AudioTrack)))
return AVERROR(ENOMEM);
memset(&fourxm->tracks[fourxm->track_count], 0,
sizeof(AudioTrack) * (track + 1 - fourxm->track_count));
fourxm->track_count = track + 1;
}
fourxm->tracks[track].adpcm = AV_RL32(buf + 12);
fourxm->tracks[track].channels = AV_RL32(buf + 36);
fourxm->tracks[track].sample_rate = AV_RL32(buf + 40);
fourxm->tracks[track].bits = AV_RL32(buf + 44);
fourxm->tracks[track].audio_pts = 0;
if (fourxm->tracks[track].channels <= 0 ||
fourxm->tracks[track].sample_rate <= 0 ||
fourxm->tracks[track].bits <= 0) {
av_log(s, AV_LOG_ERROR, "audio header invalid\n");
return AVERROR_INVALIDDATA;
}
if (!fourxm->tracks[track].adpcm && fourxm->tracks[track].bits<8) {
av_log(s, AV_LOG_ERROR, "bits unspecified for non ADPCM\n");
return AVERROR_INVALIDDATA;
}
if (fourxm->tracks[track].sample_rate > INT64_MAX / fourxm->tracks[track].bits / fourxm->tracks[track].channels) {
av_log(s, AV_LOG_ERROR, "Overflow during bit rate calculation %d * %d * %d\n",
fourxm->tracks[track].sample_rate, fourxm->tracks[track].bits, fourxm->tracks[track].channels);
return AVERROR_INVALIDDATA;
}
/* allocate a new AVStream */
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->id = track;
avpriv_set_pts_info(st, 60, 1, fourxm->tracks[track].sample_rate);
fourxm->tracks[track].stream_index = st->index;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_tag = 0;
st->codecpar->channels = fourxm->tracks[track].channels;
st->codecpar->sample_rate = fourxm->tracks[track].sample_rate;
st->codecpar->bits_per_coded_sample = fourxm->tracks[track].bits;
st->codecpar->bit_rate = (int64_t)st->codecpar->channels *
st->codecpar->sample_rate *
st->codecpar->bits_per_coded_sample;
st->codecpar->block_align = st->codecpar->channels *
st->codecpar->bits_per_coded_sample;
if (fourxm->tracks[track].adpcm){
st->codecpar->codec_id = AV_CODEC_ID_ADPCM_4XM;
} else if (st->codecpar->bits_per_coded_sample == 8) {
st->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
} else
st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
return 0;
}
| true | FFmpeg | e3f13d3a87274d537d319a84e9104f44f84ec3b2 | static int parse_strk(AVFormatContext *s,
FourxmDemuxContext *fourxm, uint8_t *buf, int size,
int left)
{
AVStream *st;
int track;
if (size != strk_SIZE || left < size + 8)
return AVERROR_INVALIDDATA;
track = AV_RL32(buf + 8);
if ((unsigned)track >= UINT_MAX / sizeof(AudioTrack) - 1) {
av_log(s, AV_LOG_ERROR, "current_track too large\n");
return AVERROR_INVALIDDATA;
}
if (track + 1 > fourxm->track_count) {
if (av_reallocp_array(&fourxm->tracks, track + 1, sizeof(AudioTrack)))
return AVERROR(ENOMEM);
memset(&fourxm->tracks[fourxm->track_count], 0,
sizeof(AudioTrack) * (track + 1 - fourxm->track_count));
fourxm->track_count = track + 1;
}
fourxm->tracks[track].adpcm = AV_RL32(buf + 12);
fourxm->tracks[track].channels = AV_RL32(buf + 36);
fourxm->tracks[track].sample_rate = AV_RL32(buf + 40);
fourxm->tracks[track].bits = AV_RL32(buf + 44);
fourxm->tracks[track].audio_pts = 0;
if (fourxm->tracks[track].channels <= 0 ||
fourxm->tracks[track].sample_rate <= 0 ||
fourxm->tracks[track].bits <= 0) {
av_log(s, AV_LOG_ERROR, "audio header invalid\n");
return AVERROR_INVALIDDATA;
}
if (!fourxm->tracks[track].adpcm && fourxm->tracks[track].bits<8) {
av_log(s, AV_LOG_ERROR, "bits unspecified for non ADPCM\n");
return AVERROR_INVALIDDATA;
}
if (fourxm->tracks[track].sample_rate > INT64_MAX / fourxm->tracks[track].bits / fourxm->tracks[track].channels) {
av_log(s, AV_LOG_ERROR, "Overflow during bit rate calculation %d * %d * %d\n",
fourxm->tracks[track].sample_rate, fourxm->tracks[track].bits, fourxm->tracks[track].channels);
return AVERROR_INVALIDDATA;
}
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->id = track;
avpriv_set_pts_info(st, 60, 1, fourxm->tracks[track].sample_rate);
fourxm->tracks[track].stream_index = st->index;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_tag = 0;
st->codecpar->channels = fourxm->tracks[track].channels;
st->codecpar->sample_rate = fourxm->tracks[track].sample_rate;
st->codecpar->bits_per_coded_sample = fourxm->tracks[track].bits;
st->codecpar->bit_rate = (int64_t)st->codecpar->channels *
st->codecpar->sample_rate *
st->codecpar->bits_per_coded_sample;
st->codecpar->block_align = st->codecpar->channels *
st->codecpar->bits_per_coded_sample;
if (fourxm->tracks[track].adpcm){
st->codecpar->codec_id = AV_CODEC_ID_ADPCM_4XM;
} else if (st->codecpar->bits_per_coded_sample == 8) {
st->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
} else
st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
return 0;
}
| {
"code": [
" fourxm->tracks[track].bits <= 0) {"
],
"line_no": [
63
]
} | static int FUNC_0(AVFormatContext *VAR_0,
FourxmDemuxContext *VAR_1, uint8_t *VAR_2, int VAR_3,
int VAR_4)
{
AVStream *st;
int VAR_5;
if (VAR_3 != strk_SIZE || VAR_4 < VAR_3 + 8)
return AVERROR_INVALIDDATA;
VAR_5 = AV_RL32(VAR_2 + 8);
if ((unsigned)VAR_5 >= UINT_MAX / sizeof(AudioTrack) - 1) {
av_log(VAR_0, AV_LOG_ERROR, "current_track too large\n");
return AVERROR_INVALIDDATA;
}
if (VAR_5 + 1 > VAR_1->track_count) {
if (av_reallocp_array(&VAR_1->tracks, VAR_5 + 1, sizeof(AudioTrack)))
return AVERROR(ENOMEM);
memset(&VAR_1->tracks[VAR_1->track_count], 0,
sizeof(AudioTrack) * (VAR_5 + 1 - VAR_1->track_count));
VAR_1->track_count = VAR_5 + 1;
}
VAR_1->tracks[VAR_5].adpcm = AV_RL32(VAR_2 + 12);
VAR_1->tracks[VAR_5].channels = AV_RL32(VAR_2 + 36);
VAR_1->tracks[VAR_5].sample_rate = AV_RL32(VAR_2 + 40);
VAR_1->tracks[VAR_5].bits = AV_RL32(VAR_2 + 44);
VAR_1->tracks[VAR_5].audio_pts = 0;
if (VAR_1->tracks[VAR_5].channels <= 0 ||
VAR_1->tracks[VAR_5].sample_rate <= 0 ||
VAR_1->tracks[VAR_5].bits <= 0) {
av_log(VAR_0, AV_LOG_ERROR, "audio header invalid\n");
return AVERROR_INVALIDDATA;
}
if (!VAR_1->tracks[VAR_5].adpcm && VAR_1->tracks[VAR_5].bits<8) {
av_log(VAR_0, AV_LOG_ERROR, "bits unspecified for non ADPCM\n");
return AVERROR_INVALIDDATA;
}
if (VAR_1->tracks[VAR_5].sample_rate > INT64_MAX / VAR_1->tracks[VAR_5].bits / VAR_1->tracks[VAR_5].channels) {
av_log(VAR_0, AV_LOG_ERROR, "Overflow during bit rate calculation %d * %d * %d\n",
VAR_1->tracks[VAR_5].sample_rate, VAR_1->tracks[VAR_5].bits, VAR_1->tracks[VAR_5].channels);
return AVERROR_INVALIDDATA;
}
st = avformat_new_stream(VAR_0, NULL);
if (!st)
return AVERROR(ENOMEM);
st->id = VAR_5;
avpriv_set_pts_info(st, 60, 1, VAR_1->tracks[VAR_5].sample_rate);
VAR_1->tracks[VAR_5].stream_index = st->index;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_tag = 0;
st->codecpar->channels = VAR_1->tracks[VAR_5].channels;
st->codecpar->sample_rate = VAR_1->tracks[VAR_5].sample_rate;
st->codecpar->bits_per_coded_sample = VAR_1->tracks[VAR_5].bits;
st->codecpar->bit_rate = (int64_t)st->codecpar->channels *
st->codecpar->sample_rate *
st->codecpar->bits_per_coded_sample;
st->codecpar->block_align = st->codecpar->channels *
st->codecpar->bits_per_coded_sample;
if (VAR_1->tracks[VAR_5].adpcm){
st->codecpar->codec_id = AV_CODEC_ID_ADPCM_4XM;
} else if (st->codecpar->bits_per_coded_sample == 8) {
st->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
} else
st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0,\nFourxmDemuxContext *VAR_1, uint8_t *VAR_2, int VAR_3,\nint VAR_4)\n{",
"AVStream *st;",
"int VAR_5;",
"if (VAR_3 != strk_SIZE || VAR_4 < VAR_3 + 8)\nreturn AVERROR_INVALIDDATA;",
"VAR_5 = AV_RL32(VAR_2 + 8);",
"if ((unsigned)VAR_5 >= UINT_MAX / sizeof(AudioTrack) - 1) {",
"av_log(VAR_0, AV_LOG_ERROR, \"current_track too large\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_5 + 1 > VAR_1->track_count) {",
"if (av_reallocp_array(&VAR_1->tracks, VAR_5 + 1, sizeof(AudioTrack)))\nreturn AVERROR(ENOMEM);",
"memset(&VAR_1->tracks[VAR_1->track_count], 0,\nsizeof(AudioTrack) * (VAR_5 + 1 - VAR_1->track_count));",
"VAR_1->track_count = VAR_5 + 1;",
"}",
"VAR_1->tracks[VAR_5].adpcm = AV_RL32(VAR_2 + 12);",
"VAR_1->tracks[VAR_5].channels = AV_RL32(VAR_2 + 36);",
"VAR_1->tracks[VAR_5].sample_rate = AV_RL32(VAR_2 + 40);",
"VAR_1->tracks[VAR_5].bits = AV_RL32(VAR_2 + 44);",
"VAR_1->tracks[VAR_5].audio_pts = 0;",
"if (VAR_1->tracks[VAR_5].channels <= 0 ||\nVAR_1->tracks[VAR_5].sample_rate <= 0 ||\nVAR_1->tracks[VAR_5].bits <= 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"audio header invalid\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (!VAR_1->tracks[VAR_5].adpcm && VAR_1->tracks[VAR_5].bits<8) {",
"av_log(VAR_0, AV_LOG_ERROR, \"bits unspecified for non ADPCM\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_1->tracks[VAR_5].sample_rate > INT64_MAX / VAR_1->tracks[VAR_5].bits / VAR_1->tracks[VAR_5].channels) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Overflow during bit rate calculation %d * %d * %d\\n\",\nVAR_1->tracks[VAR_5].sample_rate, VAR_1->tracks[VAR_5].bits, VAR_1->tracks[VAR_5].channels);",
"return AVERROR_INVALIDDATA;",
"}",
"st = avformat_new_stream(VAR_0, NULL);",
"if (!st)\nreturn AVERROR(ENOMEM);",
"st->id = VAR_5;",
"avpriv_set_pts_info(st, 60, 1, VAR_1->tracks[VAR_5].sample_rate);",
"VAR_1->tracks[VAR_5].stream_index = st->index;",
"st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;",
"st->codecpar->codec_tag = 0;",
"st->codecpar->channels = VAR_1->tracks[VAR_5].channels;",
"st->codecpar->sample_rate = VAR_1->tracks[VAR_5].sample_rate;",
"st->codecpar->bits_per_coded_sample = VAR_1->tracks[VAR_5].bits;",
"st->codecpar->bit_rate = (int64_t)st->codecpar->channels *\nst->codecpar->sample_rate *\nst->codecpar->bits_per_coded_sample;",
"st->codecpar->block_align = st->codecpar->channels *\nst->codecpar->bits_per_coded_sample;",
"if (VAR_1->tracks[VAR_5].adpcm){",
"st->codecpar->codec_id = AV_CODEC_ID_ADPCM_4XM;",
"} else if (st->codecpar->bits_per_coded_sample == 8) {",
"st->codecpar->codec_id = AV_CODEC_ID_PCM_U8;",
"} else",
"st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;",
"return 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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15,
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35,
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59,
61,
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83,
85
],
[
87
],
[
89
],
[
95
],
[
97,
99
],
[
103
],
[
105
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123,
125,
127
],
[
129,
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
]
] |
4,468 | void yuv2rgb_altivec_init_tables (SwsContext *c, const int inv_table[4],int brightness,int contrast, int saturation)
{
union {
signed short tmp[8] __attribute__ ((aligned(16)));
vector signed short vec;
} buf;
buf.tmp[0] = ( (0xffffLL) * contrast>>8 )>>9; //cy
buf.tmp[1] = -256*brightness; //oy
buf.tmp[2] = (inv_table[0]>>3) *(contrast>>16)*(saturation>>16); //crv
buf.tmp[3] = (inv_table[1]>>3) *(contrast>>16)*(saturation>>16); //cbu
buf.tmp[4] = -((inv_table[2]>>1)*(contrast>>16)*(saturation>>16)); //cgu
buf.tmp[5] = -((inv_table[3]>>1)*(contrast>>16)*(saturation>>16)); //cgv
c->CSHIFT = (vector unsigned short)vec_splat_u16(2);
c->CY = vec_splat ((vector signed short)buf.vec, 0);
c->OY = vec_splat ((vector signed short)buf.vec, 1);
c->CRV = vec_splat ((vector signed short)buf.vec, 2);
c->CBU = vec_splat ((vector signed short)buf.vec, 3);
c->CGU = vec_splat ((vector signed short)buf.vec, 4);
c->CGV = vec_splat ((vector signed short)buf.vec, 5);
#if 0
{
int i;
char *v[6]={"cy","oy","crv","cbu","cgu","cgv"};
for (i=0; i<6;i++)
printf("%s %d ", v[i],buf.tmp[i] );
printf("\n");
}
#endif
return;
}
| true | FFmpeg | 428098165de4c3edfe42c1b7f00627d287015863 | void yuv2rgb_altivec_init_tables (SwsContext *c, const int inv_table[4],int brightness,int contrast, int saturation)
{
union {
signed short tmp[8] __attribute__ ((aligned(16)));
vector signed short vec;
} buf;
buf.tmp[0] = ( (0xffffLL) * contrast>>8 )>>9;
buf.tmp[1] = -256*brightness;
buf.tmp[2] = (inv_table[0]>>3) *(contrast>>16)*(saturation>>16);
buf.tmp[3] = (inv_table[1]>>3) *(contrast>>16)*(saturation>>16);
buf.tmp[4] = -((inv_table[2]>>1)*(contrast>>16)*(saturation>>16));
buf.tmp[5] = -((inv_table[3]>>1)*(contrast>>16)*(saturation>>16));
c->CSHIFT = (vector unsigned short)vec_splat_u16(2);
c->CY = vec_splat ((vector signed short)buf.vec, 0);
c->OY = vec_splat ((vector signed short)buf.vec, 1);
c->CRV = vec_splat ((vector signed short)buf.vec, 2);
c->CBU = vec_splat ((vector signed short)buf.vec, 3);
c->CGU = vec_splat ((vector signed short)buf.vec, 4);
c->CGV = vec_splat ((vector signed short)buf.vec, 5);
#if 0
{
int i;
char *v[6]={"cy","oy","crv","cbu","cgu","cgv"};
for (i=0; i<6;i++)
printf("%s %d ", v[i],buf.tmp[i] );
printf("\n");
}
#endif
return;
}
| {
"code": [
" union {",
" \tsigned short tmp[8] __attribute__ ((aligned(16)));",
"\tvector signed short vec;",
"\t} buf;",
" c->CSHIFT = (vector unsigned short)vec_splat_u16(2);",
" c->CY = vec_splat ((vector signed short)buf.vec, 0);",
" c->OY = vec_splat ((vector signed short)buf.vec, 1);",
" c->CRV = vec_splat ((vector signed short)buf.vec, 2);",
" c->CBU = vec_splat ((vector signed short)buf.vec, 3);",
" c->CGU = vec_splat ((vector signed short)buf.vec, 4);",
" c->CGV = vec_splat ((vector signed short)buf.vec, 5);",
"int i;",
"char *v[6]={\"cy\",\"oy\",\"crv\",\"cbu\",\"cgu\",\"cgv\"};",
"for (i=0; i<6;i++)",
" printf(\"%s %d \", v[i],buf.tmp[i] );",
" printf(\"\\n\");"
],
"line_no": [
5,
7,
9,
11,
31,
33,
35,
37,
39,
41,
43,
49,
51,
53,
55,
57
]
} | void FUNC_0 (SwsContext *VAR_0, const int VAR_1[4],int VAR_2,int VAR_3, int VAR_4)
{
union {
signed short tmp[8] __attribute__ ((aligned(16)));
vector signed short vec;
} VAR_5;
VAR_5.tmp[0] = ( (0xffffLL) * VAR_3>>8 )>>9;
VAR_5.tmp[1] = -256*VAR_2;
VAR_5.tmp[2] = (VAR_1[0]>>3) *(VAR_3>>16)*(VAR_4>>16);
VAR_5.tmp[3] = (VAR_1[1]>>3) *(VAR_3>>16)*(VAR_4>>16);
VAR_5.tmp[4] = -((VAR_1[2]>>1)*(VAR_3>>16)*(VAR_4>>16));
VAR_5.tmp[5] = -((VAR_1[3]>>1)*(VAR_3>>16)*(VAR_4>>16));
VAR_0->CSHIFT = (vector unsigned short)vec_splat_u16(2);
VAR_0->CY = vec_splat ((vector signed short)VAR_5.vec, 0);
VAR_0->OY = vec_splat ((vector signed short)VAR_5.vec, 1);
VAR_0->CRV = vec_splat ((vector signed short)VAR_5.vec, 2);
VAR_0->CBU = vec_splat ((vector signed short)VAR_5.vec, 3);
VAR_0->CGU = vec_splat ((vector signed short)VAR_5.vec, 4);
VAR_0->CGV = vec_splat ((vector signed short)VAR_5.vec, 5);
#if 0
{
int i;
char *v[6]={"cy","oy","crv","cbu","cgu","cgv"};
for (i=0; i<6;i++)
printf("%s %d ", v[i],VAR_5.tmp[i] );
printf("\n");
}
#endif
return;
}
| [
"void FUNC_0 (SwsContext *VAR_0, const int VAR_1[4],int VAR_2,int VAR_3, int VAR_4)\n{",
"union {",
"signed short tmp[8] __attribute__ ((aligned(16)));",
"vector signed short vec;",
"} VAR_5;",
"VAR_5.tmp[0] = ( (0xffffLL) * VAR_3>>8 )>>9;",
"VAR_5.tmp[1] = -256*VAR_2;",
"VAR_5.tmp[2] = (VAR_1[0]>>3) *(VAR_3>>16)*(VAR_4>>16);",
"VAR_5.tmp[3] = (VAR_1[1]>>3) *(VAR_3>>16)*(VAR_4>>16);",
"VAR_5.tmp[4] = -((VAR_1[2]>>1)*(VAR_3>>16)*(VAR_4>>16));",
"VAR_5.tmp[5] = -((VAR_1[3]>>1)*(VAR_3>>16)*(VAR_4>>16));",
"VAR_0->CSHIFT = (vector unsigned short)vec_splat_u16(2);",
"VAR_0->CY = vec_splat ((vector signed short)VAR_5.vec, 0);",
"VAR_0->OY = vec_splat ((vector signed short)VAR_5.vec, 1);",
"VAR_0->CRV = vec_splat ((vector signed short)VAR_5.vec, 2);",
"VAR_0->CBU = vec_splat ((vector signed short)VAR_5.vec, 3);",
"VAR_0->CGU = vec_splat ((vector signed short)VAR_5.vec, 4);",
"VAR_0->CGV = vec_splat ((vector signed short)VAR_5.vec, 5);",
"#if 0\n{",
"int i;",
"char *v[6]={\"cy\",\"oy\",\"crv\",\"cbu\",\"cgu\",\"cgv\"};",
"for (i=0; i<6;i++)",
"printf(\"%s %d \", v[i],VAR_5.tmp[i] );",
"printf(\"\\n\");",
"}",
"#endif\nreturn;",
"}"
] | [
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[
65
]
] |
4,469 | static void control_out(VirtIODevice *vdev, VirtQueue *vq)
{
VirtQueueElement elem;
VirtIOSerial *vser;
vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
while (virtqueue_pop(vq, &elem)) {
handle_control_message(vser, elem.out_sg[0].iov_base);
virtqueue_push(vq, &elem, elem.out_sg[0].iov_len);
}
virtio_notify(vdev, vq);
}
| true | qemu | e61da14d60ba1cceacad8396adcb9662c7f690af | static void control_out(VirtIODevice *vdev, VirtQueue *vq)
{
VirtQueueElement elem;
VirtIOSerial *vser;
vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
while (virtqueue_pop(vq, &elem)) {
handle_control_message(vser, elem.out_sg[0].iov_base);
virtqueue_push(vq, &elem, elem.out_sg[0].iov_len);
}
virtio_notify(vdev, vq);
}
| {
"code": [
" handle_control_message(vser, elem.out_sg[0].iov_base);",
" virtqueue_push(vq, &elem, elem.out_sg[0].iov_len);"
],
"line_no": [
17,
19
]
} | static void FUNC_0(VirtIODevice *VAR_0, VirtQueue *VAR_1)
{
VirtQueueElement elem;
VirtIOSerial *vser;
vser = DO_UPCAST(VirtIOSerial, VAR_0, VAR_0);
while (virtqueue_pop(VAR_1, &elem)) {
handle_control_message(vser, elem.out_sg[0].iov_base);
virtqueue_push(VAR_1, &elem, elem.out_sg[0].iov_len);
}
virtio_notify(VAR_0, VAR_1);
}
| [
"static void FUNC_0(VirtIODevice *VAR_0, VirtQueue *VAR_1)\n{",
"VirtQueueElement elem;",
"VirtIOSerial *vser;",
"vser = DO_UPCAST(VirtIOSerial, VAR_0, VAR_0);",
"while (virtqueue_pop(VAR_1, &elem)) {",
"handle_control_message(vser, elem.out_sg[0].iov_base);",
"virtqueue_push(VAR_1, &elem, elem.out_sg[0].iov_len);",
"}",
"virtio_notify(VAR_0, VAR_1);",
"}"
] | [
0,
0,
0,
0,
0,
1,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
]
] |
4,470 | static int img_amend(int argc, char **argv)
{
Error *err = NULL;
int c, ret = 0;
char *options = NULL;
QemuOptsList *create_opts = NULL;
QemuOpts *opts = NULL;
const char *fmt = NULL, *filename, *cache;
int flags;
bool quiet = false, progress = false;
BlockBackend *blk = NULL;
BlockDriverState *bs = NULL;
cache = BDRV_DEFAULT_CACHE;
for (;;) {
c = getopt(argc, argv, "ho:f:t:pq");
if (c == -1) {
break;
}
switch (c) {
case 'h':
case '?':
help();
break;
case 'o':
if (!is_valid_option_list(optarg)) {
error_report("Invalid option list: %s", optarg);
ret = -1;
goto out;
}
if (!options) {
options = g_strdup(optarg);
} else {
char *old_options = options;
options = g_strdup_printf("%s,%s", options, optarg);
g_free(old_options);
}
break;
case 'f':
fmt = optarg;
break;
case 't':
cache = optarg;
break;
case 'p':
progress = true;
break;
case 'q':
quiet = true;
break;
}
}
if (!options) {
error_exit("Must specify options (-o)");
}
if (quiet) {
progress = false;
}
qemu_progress_init(progress, 1.0);
filename = (optind == argc - 1) ? argv[argc - 1] : NULL;
if (fmt && has_help_option(options)) {
/* If a format is explicitly specified (and possibly no filename is
* given), print option help here */
ret = print_block_option_help(filename, fmt);
goto out;
}
if (optind != argc - 1) {
error_report("Expecting one image file name");
ret = -1;
goto out;
}
flags = BDRV_O_FLAGS | BDRV_O_RDWR;
ret = bdrv_parse_cache_flags(cache, &flags);
if (ret < 0) {
error_report("Invalid cache option: %s", cache);
goto out;
}
blk = img_open("image", filename, fmt, flags, true, quiet);
if (!blk) {
ret = -1;
goto out;
}
bs = blk_bs(blk);
fmt = bs->drv->format_name;
if (has_help_option(options)) {
/* If the format was auto-detected, print option help here */
ret = print_block_option_help(filename, fmt);
goto out;
}
if (!bs->drv->create_opts) {
error_report("Format driver '%s' does not support any options to amend",
fmt);
ret = -1;
goto out;
}
create_opts = qemu_opts_append(create_opts, bs->drv->create_opts);
opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
if (options) {
qemu_opts_do_parse(opts, options, NULL, &err);
if (err) {
error_report_err(err);
ret = -1;
goto out;
}
}
/* In case the driver does not call amend_status_cb() */
qemu_progress_print(0.f, 0);
ret = bdrv_amend_options(bs, opts, &amend_status_cb);
qemu_progress_print(100.f, 0);
if (ret < 0) {
error_report("Error while amending options: %s", strerror(-ret));
goto out;
}
out:
qemu_progress_end();
blk_unref(blk);
qemu_opts_del(opts);
qemu_opts_free(create_opts);
g_free(options);
if (ret) {
return 1;
}
return 0;
}
| true | qemu | e814dffcc9810ed77fe99081be9751b620a894c4 | static int img_amend(int argc, char **argv)
{
Error *err = NULL;
int c, ret = 0;
char *options = NULL;
QemuOptsList *create_opts = NULL;
QemuOpts *opts = NULL;
const char *fmt = NULL, *filename, *cache;
int flags;
bool quiet = false, progress = false;
BlockBackend *blk = NULL;
BlockDriverState *bs = NULL;
cache = BDRV_DEFAULT_CACHE;
for (;;) {
c = getopt(argc, argv, "ho:f:t:pq");
if (c == -1) {
break;
}
switch (c) {
case 'h':
case '?':
help();
break;
case 'o':
if (!is_valid_option_list(optarg)) {
error_report("Invalid option list: %s", optarg);
ret = -1;
goto out;
}
if (!options) {
options = g_strdup(optarg);
} else {
char *old_options = options;
options = g_strdup_printf("%s,%s", options, optarg);
g_free(old_options);
}
break;
case 'f':
fmt = optarg;
break;
case 't':
cache = optarg;
break;
case 'p':
progress = true;
break;
case 'q':
quiet = true;
break;
}
}
if (!options) {
error_exit("Must specify options (-o)");
}
if (quiet) {
progress = false;
}
qemu_progress_init(progress, 1.0);
filename = (optind == argc - 1) ? argv[argc - 1] : NULL;
if (fmt && has_help_option(options)) {
ret = print_block_option_help(filename, fmt);
goto out;
}
if (optind != argc - 1) {
error_report("Expecting one image file name");
ret = -1;
goto out;
}
flags = BDRV_O_FLAGS | BDRV_O_RDWR;
ret = bdrv_parse_cache_flags(cache, &flags);
if (ret < 0) {
error_report("Invalid cache option: %s", cache);
goto out;
}
blk = img_open("image", filename, fmt, flags, true, quiet);
if (!blk) {
ret = -1;
goto out;
}
bs = blk_bs(blk);
fmt = bs->drv->format_name;
if (has_help_option(options)) {
ret = print_block_option_help(filename, fmt);
goto out;
}
if (!bs->drv->create_opts) {
error_report("Format driver '%s' does not support any options to amend",
fmt);
ret = -1;
goto out;
}
create_opts = qemu_opts_append(create_opts, bs->drv->create_opts);
opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
if (options) {
qemu_opts_do_parse(opts, options, NULL, &err);
if (err) {
error_report_err(err);
ret = -1;
goto out;
}
}
qemu_progress_print(0.f, 0);
ret = bdrv_amend_options(bs, opts, &amend_status_cb);
qemu_progress_print(100.f, 0);
if (ret < 0) {
error_report("Error while amending options: %s", strerror(-ret));
goto out;
}
out:
qemu_progress_end();
blk_unref(blk);
qemu_opts_del(opts);
qemu_opts_free(create_opts);
g_free(options);
if (ret) {
return 1;
}
return 0;
}
| {
"code": [
" goto out;"
],
"line_no": [
59
]
} | static int FUNC_0(int VAR_0, char **VAR_1)
{
Error *err = NULL;
int VAR_2, VAR_3 = 0;
char *VAR_4 = NULL;
QemuOptsList *create_opts = NULL;
QemuOpts *opts = NULL;
const char *VAR_5 = NULL, *VAR_6, *VAR_7;
int VAR_8;
bool quiet = false, progress = false;
BlockBackend *blk = NULL;
BlockDriverState *bs = NULL;
VAR_7 = BDRV_DEFAULT_CACHE;
for (;;) {
VAR_2 = getopt(VAR_0, VAR_1, "ho:f:t:pq");
if (VAR_2 == -1) {
break;
}
switch (VAR_2) {
case 'h':
case '?':
help();
break;
case 'o':
if (!is_valid_option_list(optarg)) {
error_report("Invalid option list: %s", optarg);
VAR_3 = -1;
goto out;
}
if (!VAR_4) {
VAR_4 = g_strdup(optarg);
} else {
char *VAR_9 = VAR_4;
VAR_4 = g_strdup_printf("%s,%s", VAR_4, optarg);
g_free(VAR_9);
}
break;
case 'f':
VAR_5 = optarg;
break;
case 't':
VAR_7 = optarg;
break;
case 'p':
progress = true;
break;
case 'q':
quiet = true;
break;
}
}
if (!VAR_4) {
error_exit("Must specify VAR_4 (-o)");
}
if (quiet) {
progress = false;
}
qemu_progress_init(progress, 1.0);
VAR_6 = (optind == VAR_0 - 1) ? VAR_1[VAR_0 - 1] : NULL;
if (VAR_5 && has_help_option(VAR_4)) {
VAR_3 = print_block_option_help(VAR_6, VAR_5);
goto out;
}
if (optind != VAR_0 - 1) {
error_report("Expecting one image file name");
VAR_3 = -1;
goto out;
}
VAR_8 = BDRV_O_FLAGS | BDRV_O_RDWR;
VAR_3 = bdrv_parse_cache_flags(VAR_7, &VAR_8);
if (VAR_3 < 0) {
error_report("Invalid VAR_7 option: %s", VAR_7);
goto out;
}
blk = img_open("image", VAR_6, VAR_5, VAR_8, true, quiet);
if (!blk) {
VAR_3 = -1;
goto out;
}
bs = blk_bs(blk);
VAR_5 = bs->drv->format_name;
if (has_help_option(VAR_4)) {
VAR_3 = print_block_option_help(VAR_6, VAR_5);
goto out;
}
if (!bs->drv->create_opts) {
error_report("Format driver '%s' does not support any VAR_4 to amend",
VAR_5);
VAR_3 = -1;
goto out;
}
create_opts = qemu_opts_append(create_opts, bs->drv->create_opts);
opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
if (VAR_4) {
qemu_opts_do_parse(opts, VAR_4, NULL, &err);
if (err) {
error_report_err(err);
VAR_3 = -1;
goto out;
}
}
qemu_progress_print(0.f, 0);
VAR_3 = bdrv_amend_options(bs, opts, &amend_status_cb);
qemu_progress_print(100.f, 0);
if (VAR_3 < 0) {
error_report("Error while amending VAR_4: %s", strerror(-VAR_3));
goto out;
}
out:
qemu_progress_end();
blk_unref(blk);
qemu_opts_del(opts);
qemu_opts_free(create_opts);
g_free(VAR_4);
if (VAR_3) {
return 1;
}
return 0;
}
| [
"static int FUNC_0(int VAR_0, char **VAR_1)\n{",
"Error *err = NULL;",
"int VAR_2, VAR_3 = 0;",
"char *VAR_4 = NULL;",
"QemuOptsList *create_opts = NULL;",
"QemuOpts *opts = NULL;",
"const char *VAR_5 = NULL, *VAR_6, *VAR_7;",
"int VAR_8;",
"bool quiet = false, progress = false;",
"BlockBackend *blk = NULL;",
"BlockDriverState *bs = NULL;",
"VAR_7 = BDRV_DEFAULT_CACHE;",
"for (;;) {",
"VAR_2 = getopt(VAR_0, VAR_1, \"ho:f:t:pq\");",
"if (VAR_2 == -1) {",
"break;",
"}",
"switch (VAR_2) {",
"case 'h':\ncase '?':\nhelp();",
"break;",
"case 'o':\nif (!is_valid_option_list(optarg)) {",
"error_report(\"Invalid option list: %s\", optarg);",
"VAR_3 = -1;",
"goto out;",
"}",
"if (!VAR_4) {",
"VAR_4 = g_strdup(optarg);",
"} else {",
"char *VAR_9 = VAR_4;",
"VAR_4 = g_strdup_printf(\"%s,%s\", VAR_4, optarg);",
"g_free(VAR_9);",
"}",
"break;",
"case 'f':\nVAR_5 = optarg;",
"break;",
"case 't':\nVAR_7 = optarg;",
"break;",
"case 'p':\nprogress = true;",
"break;",
"case 'q':\nquiet = true;",
"break;",
"}",
"}",
"if (!VAR_4) {",
"error_exit(\"Must specify VAR_4 (-o)\");",
"}",
"if (quiet) {",
"progress = false;",
"}",
"qemu_progress_init(progress, 1.0);",
"VAR_6 = (optind == VAR_0 - 1) ? VAR_1[VAR_0 - 1] : NULL;",
"if (VAR_5 && has_help_option(VAR_4)) {",
"VAR_3 = print_block_option_help(VAR_6, VAR_5);",
"goto out;",
"}",
"if (optind != VAR_0 - 1) {",
"error_report(\"Expecting one image file name\");",
"VAR_3 = -1;",
"goto out;",
"}",
"VAR_8 = BDRV_O_FLAGS | BDRV_O_RDWR;",
"VAR_3 = bdrv_parse_cache_flags(VAR_7, &VAR_8);",
"if (VAR_3 < 0) {",
"error_report(\"Invalid VAR_7 option: %s\", VAR_7);",
"goto out;",
"}",
"blk = img_open(\"image\", VAR_6, VAR_5, VAR_8, true, quiet);",
"if (!blk) {",
"VAR_3 = -1;",
"goto out;",
"}",
"bs = blk_bs(blk);",
"VAR_5 = bs->drv->format_name;",
"if (has_help_option(VAR_4)) {",
"VAR_3 = print_block_option_help(VAR_6, VAR_5);",
"goto out;",
"}",
"if (!bs->drv->create_opts) {",
"error_report(\"Format driver '%s' does not support any VAR_4 to amend\",\nVAR_5);",
"VAR_3 = -1;",
"goto out;",
"}",
"create_opts = qemu_opts_append(create_opts, bs->drv->create_opts);",
"opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);",
"if (VAR_4) {",
"qemu_opts_do_parse(opts, VAR_4, NULL, &err);",
"if (err) {",
"error_report_err(err);",
"VAR_3 = -1;",
"goto out;",
"}",
"}",
"qemu_progress_print(0.f, 0);",
"VAR_3 = bdrv_amend_options(bs, opts, &amend_status_cb);",
"qemu_progress_print(100.f, 0);",
"if (VAR_3 < 0) {",
"error_report(\"Error while amending VAR_4: %s\", strerror(-VAR_3));",
"goto out;",
"}",
"out:\nqemu_progress_end();",
"blk_unref(blk);",
"qemu_opts_del(opts);",
"qemu_opts_free(create_opts);",
"g_free(VAR_4);",
"if (VAR_3) {",
"return 1;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
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
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79,
81
],
[
83
],
[
85,
87
],
[
89
],
[
91,
93
],
[
95
],
[
97,
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
183
],
[
187
],
[
191
],
[
193
],
[
195
],
[
199
],
[
201,
203
],
[
205
],
[
207
],
[
209
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
253,
255
],
[
259
],
[
261
],
[
263
],
[
265
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
]
] |
4,471 | static void powernv_populate_chip(PnvChip *chip, void *fdt)
{
PnvChipClass *pcc = PNV_CHIP_GET_CLASS(chip);
char *typename = pnv_core_typename(pcc->cpu_model);
size_t typesize = object_type_get_instance_size(typename);
int i;
for (i = 0; i < chip->nr_cores; i++) {
PnvCore *pnv_core = PNV_CORE(chip->cores + i * typesize);
powernv_create_core_node(chip, pnv_core, fdt);
}
if (chip->ram_size) {
powernv_populate_memory_node(fdt, chip->chip_id, chip->ram_start,
chip->ram_size);
}
g_free(typename);
} | true | qemu | 967b75230b9720ea2b3ae49f38f8287026125f9f | static void powernv_populate_chip(PnvChip *chip, void *fdt)
{
PnvChipClass *pcc = PNV_CHIP_GET_CLASS(chip);
char *typename = pnv_core_typename(pcc->cpu_model);
size_t typesize = object_type_get_instance_size(typename);
int i;
for (i = 0; i < chip->nr_cores; i++) {
PnvCore *pnv_core = PNV_CORE(chip->cores + i * typesize);
powernv_create_core_node(chip, pnv_core, fdt);
}
if (chip->ram_size) {
powernv_populate_memory_node(fdt, chip->chip_id, chip->ram_start,
chip->ram_size);
}
g_free(typename);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(PnvChip *VAR_0, void *VAR_1)
{
PnvChipClass *pcc = PNV_CHIP_GET_CLASS(VAR_0);
char *VAR_2 = pnv_core_typename(pcc->cpu_model);
size_t typesize = object_type_get_instance_size(VAR_2);
int VAR_3;
for (VAR_3 = 0; VAR_3 < VAR_0->nr_cores; VAR_3++) {
PnvCore *pnv_core = PNV_CORE(VAR_0->cores + VAR_3 * typesize);
powernv_create_core_node(VAR_0, pnv_core, VAR_1);
}
if (VAR_0->ram_size) {
powernv_populate_memory_node(VAR_1, VAR_0->chip_id, VAR_0->ram_start,
VAR_0->ram_size);
}
g_free(VAR_2);
} | [
"static void FUNC_0(PnvChip *VAR_0, void *VAR_1)\n{",
"PnvChipClass *pcc = PNV_CHIP_GET_CLASS(VAR_0);",
"char *VAR_2 = pnv_core_typename(pcc->cpu_model);",
"size_t typesize = object_type_get_instance_size(VAR_2);",
"int VAR_3;",
"for (VAR_3 = 0; VAR_3 < VAR_0->nr_cores; VAR_3++) {",
"PnvCore *pnv_core = PNV_CORE(VAR_0->cores + VAR_3 * typesize);",
"powernv_create_core_node(VAR_0, pnv_core, VAR_1);",
"}",
"if (VAR_0->ram_size) {",
"powernv_populate_memory_node(VAR_1, VAR_0->chip_id, VAR_0->ram_start,\nVAR_0->ram_size);",
"}",
"g_free(VAR_2);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12,
13
],
[
14
],
[
15
],
[
16
]
] |
4,472 | static int virtio_rng_load_device(VirtIODevice *vdev, QEMUFile *f,
int version_id)
{
/* We may have an element ready but couldn't process it due to a quota
* limit. Make sure to try again after live migration when the quota may
* have been reset.
*/
virtio_rng_process(VIRTIO_RNG(vdev));
return 0;
}
| true | qemu | db12451decf7dfe0f083564183e135f2095228b9 | static int virtio_rng_load_device(VirtIODevice *vdev, QEMUFile *f,
int version_id)
{
virtio_rng_process(VIRTIO_RNG(vdev));
return 0;
}
| {
"code": [
"static int virtio_rng_load_device(VirtIODevice *vdev, QEMUFile *f,",
" int version_id)",
" virtio_rng_process(VIRTIO_RNG(vdev));"
],
"line_no": [
1,
3,
15
]
} | static int FUNC_0(VirtIODevice *VAR_0, QEMUFile *VAR_1,
int VAR_2)
{
virtio_rng_process(VIRTIO_RNG(VAR_0));
return 0;
}
| [
"static int FUNC_0(VirtIODevice *VAR_0, QEMUFile *VAR_1,\nint VAR_2)\n{",
"virtio_rng_process(VIRTIO_RNG(VAR_0));",
"return 0;",
"}"
] | [
1,
1,
0,
0
] | [
[
1,
3,
5
],
[
15
],
[
19
],
[
21
]
] |
4,473 | static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s, int16_t *block, int n)
{
int level, i, j, run;
RLTable *rl = &ff_rl_mpeg1;
uint8_t * const scantable = s->intra_scantable.permutated;
const int qscale = s->qscale;
{
OPEN_READER(re, &s->gb);
i = -1;
// special case for first coefficient, no need to add second VLC table
UPDATE_CACHE(re, &s->gb);
if (((int32_t)GET_CACHE(re, &s->gb)) < 0) {
level = (3 * qscale) >> 1;
level = (level - 1) | 1;
if (GET_CACHE(re, &s->gb) & 0x40000000)
level = -level;
block[0] = level;
i++;
SKIP_BITS(re, &s->gb, 2);
if (((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
goto end;
}
/* now quantify & encode AC coefficients */
for (;;) {
GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
if (level != 0) {
i += run;
j = scantable[i];
level = ((level * 2 + 1) * qscale) >> 1;
level = (level - 1) | 1;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
SKIP_BITS(re, &s->gb, 1);
} else {
/* escape */
run = SHOW_UBITS(re, &s->gb, 6)+1; LAST_SKIP_BITS(re, &s->gb, 6);
UPDATE_CACHE(re, &s->gb);
level = SHOW_SBITS(re, &s->gb, 8); SKIP_BITS(re, &s->gb, 8);
if (level == -128) {
level = SHOW_UBITS(re, &s->gb, 8) - 256; SKIP_BITS(re, &s->gb, 8);
} else if (level == 0) {
level = SHOW_UBITS(re, &s->gb, 8) ; SKIP_BITS(re, &s->gb, 8);
}
i += run;
j = scantable[i];
if (level < 0) {
level = -level;
level = ((level * 2 + 1) * qscale) >> 1;
level = (level - 1) | 1;
level = -level;
} else {
level = ((level * 2 + 1) * qscale) >> 1;
level = (level - 1) | 1;
}
}
block[j] = level;
if (((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
break;
UPDATE_CACHE(re, &s->gb);
}
end:
LAST_SKIP_BITS(re, &s->gb, 2);
CLOSE_READER(re, &s->gb);
}
s->block_last_index[n] = i;
return 0;
}
| true | FFmpeg | 0a59055167eea3087a36d9091501d3bb52ed8ebe | static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s, int16_t *block, int n)
{
int level, i, j, run;
RLTable *rl = &ff_rl_mpeg1;
uint8_t * const scantable = s->intra_scantable.permutated;
const int qscale = s->qscale;
{
OPEN_READER(re, &s->gb);
i = -1;
UPDATE_CACHE(re, &s->gb);
if (((int32_t)GET_CACHE(re, &s->gb)) < 0) {
level = (3 * qscale) >> 1;
level = (level - 1) | 1;
if (GET_CACHE(re, &s->gb) & 0x40000000)
level = -level;
block[0] = level;
i++;
SKIP_BITS(re, &s->gb, 2);
if (((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
goto end;
}
for (;;) {
GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
if (level != 0) {
i += run;
j = scantable[i];
level = ((level * 2 + 1) * qscale) >> 1;
level = (level - 1) | 1;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
SKIP_BITS(re, &s->gb, 1);
} else {
run = SHOW_UBITS(re, &s->gb, 6)+1; LAST_SKIP_BITS(re, &s->gb, 6);
UPDATE_CACHE(re, &s->gb);
level = SHOW_SBITS(re, &s->gb, 8); SKIP_BITS(re, &s->gb, 8);
if (level == -128) {
level = SHOW_UBITS(re, &s->gb, 8) - 256; SKIP_BITS(re, &s->gb, 8);
} else if (level == 0) {
level = SHOW_UBITS(re, &s->gb, 8) ; SKIP_BITS(re, &s->gb, 8);
}
i += run;
j = scantable[i];
if (level < 0) {
level = -level;
level = ((level * 2 + 1) * qscale) >> 1;
level = (level - 1) | 1;
level = -level;
} else {
level = ((level * 2 + 1) * qscale) >> 1;
level = (level - 1) | 1;
}
}
block[j] = level;
if (((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
break;
UPDATE_CACHE(re, &s->gb);
}
end:
LAST_SKIP_BITS(re, &s->gb, 2);
CLOSE_READER(re, &s->gb);
}
s->block_last_index[n] = i;
return 0;
}
| {
"code": [
" if (((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)"
],
"line_no": [
41
]
} | static inline int FUNC_0(MpegEncContext *VAR_0, int16_t *VAR_1, int VAR_2)
{
int VAR_3, VAR_4, VAR_5, VAR_6;
RLTable *rl = &ff_rl_mpeg1;
uint8_t * const scantable = VAR_0->intra_scantable.permutated;
const int VAR_7 = VAR_0->VAR_7;
{
OPEN_READER(re, &VAR_0->gb);
VAR_4 = -1;
UPDATE_CACHE(re, &VAR_0->gb);
if (((int32_t)GET_CACHE(re, &VAR_0->gb)) < 0) {
VAR_3 = (3 * VAR_7) >> 1;
VAR_3 = (VAR_3 - 1) | 1;
if (GET_CACHE(re, &VAR_0->gb) & 0x40000000)
VAR_3 = -VAR_3;
VAR_1[0] = VAR_3;
VAR_4++;
SKIP_BITS(re, &VAR_0->gb, 2);
if (((int32_t)GET_CACHE(re, &VAR_0->gb)) <= (int32_t)0xBFFFFFFF)
goto end;
}
for (;;) {
GET_RL_VLC(VAR_3, VAR_6, re, &VAR_0->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
if (VAR_3 != 0) {
VAR_4 += VAR_6;
VAR_5 = scantable[VAR_4];
VAR_3 = ((VAR_3 * 2 + 1) * VAR_7) >> 1;
VAR_3 = (VAR_3 - 1) | 1;
VAR_3 = (VAR_3 ^ SHOW_SBITS(re, &VAR_0->gb, 1)) - SHOW_SBITS(re, &VAR_0->gb, 1);
SKIP_BITS(re, &VAR_0->gb, 1);
} else {
VAR_6 = SHOW_UBITS(re, &VAR_0->gb, 6)+1; LAST_SKIP_BITS(re, &VAR_0->gb, 6);
UPDATE_CACHE(re, &VAR_0->gb);
VAR_3 = SHOW_SBITS(re, &VAR_0->gb, 8); SKIP_BITS(re, &VAR_0->gb, 8);
if (VAR_3 == -128) {
VAR_3 = SHOW_UBITS(re, &VAR_0->gb, 8) - 256; SKIP_BITS(re, &VAR_0->gb, 8);
} else if (VAR_3 == 0) {
VAR_3 = SHOW_UBITS(re, &VAR_0->gb, 8) ; SKIP_BITS(re, &VAR_0->gb, 8);
}
VAR_4 += VAR_6;
VAR_5 = scantable[VAR_4];
if (VAR_3 < 0) {
VAR_3 = -VAR_3;
VAR_3 = ((VAR_3 * 2 + 1) * VAR_7) >> 1;
VAR_3 = (VAR_3 - 1) | 1;
VAR_3 = -VAR_3;
} else {
VAR_3 = ((VAR_3 * 2 + 1) * VAR_7) >> 1;
VAR_3 = (VAR_3 - 1) | 1;
}
}
VAR_1[VAR_5] = VAR_3;
if (((int32_t)GET_CACHE(re, &VAR_0->gb)) <= (int32_t)0xBFFFFFFF)
break;
UPDATE_CACHE(re, &VAR_0->gb);
}
end:
LAST_SKIP_BITS(re, &VAR_0->gb, 2);
CLOSE_READER(re, &VAR_0->gb);
}
VAR_0->block_last_index[VAR_2] = VAR_4;
return 0;
}
| [
"static inline int FUNC_0(MpegEncContext *VAR_0, int16_t *VAR_1, int VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5, VAR_6;",
"RLTable *rl = &ff_rl_mpeg1;",
"uint8_t * const scantable = VAR_0->intra_scantable.permutated;",
"const int VAR_7 = VAR_0->VAR_7;",
"{",
"OPEN_READER(re, &VAR_0->gb);",
"VAR_4 = -1;",
"UPDATE_CACHE(re, &VAR_0->gb);",
"if (((int32_t)GET_CACHE(re, &VAR_0->gb)) < 0) {",
"VAR_3 = (3 * VAR_7) >> 1;",
"VAR_3 = (VAR_3 - 1) | 1;",
"if (GET_CACHE(re, &VAR_0->gb) & 0x40000000)\nVAR_3 = -VAR_3;",
"VAR_1[0] = VAR_3;",
"VAR_4++;",
"SKIP_BITS(re, &VAR_0->gb, 2);",
"if (((int32_t)GET_CACHE(re, &VAR_0->gb)) <= (int32_t)0xBFFFFFFF)\ngoto end;",
"}",
"for (;;) {",
"GET_RL_VLC(VAR_3, VAR_6, re, &VAR_0->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);",
"if (VAR_3 != 0) {",
"VAR_4 += VAR_6;",
"VAR_5 = scantable[VAR_4];",
"VAR_3 = ((VAR_3 * 2 + 1) * VAR_7) >> 1;",
"VAR_3 = (VAR_3 - 1) | 1;",
"VAR_3 = (VAR_3 ^ SHOW_SBITS(re, &VAR_0->gb, 1)) - SHOW_SBITS(re, &VAR_0->gb, 1);",
"SKIP_BITS(re, &VAR_0->gb, 1);",
"} else {",
"VAR_6 = SHOW_UBITS(re, &VAR_0->gb, 6)+1; LAST_SKIP_BITS(re, &VAR_0->gb, 6);",
"UPDATE_CACHE(re, &VAR_0->gb);",
"VAR_3 = SHOW_SBITS(re, &VAR_0->gb, 8); SKIP_BITS(re, &VAR_0->gb, 8);",
"if (VAR_3 == -128) {",
"VAR_3 = SHOW_UBITS(re, &VAR_0->gb, 8) - 256; SKIP_BITS(re, &VAR_0->gb, 8);",
"} else if (VAR_3 == 0) {",
"VAR_3 = SHOW_UBITS(re, &VAR_0->gb, 8) ; SKIP_BITS(re, &VAR_0->gb, 8);",
"}",
"VAR_4 += VAR_6;",
"VAR_5 = scantable[VAR_4];",
"if (VAR_3 < 0) {",
"VAR_3 = -VAR_3;",
"VAR_3 = ((VAR_3 * 2 + 1) * VAR_7) >> 1;",
"VAR_3 = (VAR_3 - 1) | 1;",
"VAR_3 = -VAR_3;",
"} else {",
"VAR_3 = ((VAR_3 * 2 + 1) * VAR_7) >> 1;",
"VAR_3 = (VAR_3 - 1) | 1;",
"}",
"}",
"VAR_1[VAR_5] = VAR_3;",
"if (((int32_t)GET_CACHE(re, &VAR_0->gb)) <= (int32_t)0xBFFFFFFF)\nbreak;",
"UPDATE_CACHE(re, &VAR_0->gb);",
"}",
"end:\nLAST_SKIP_BITS(re, &VAR_0->gb, 2);",
"CLOSE_READER(re, &VAR_0->gb);",
"}",
"VAR_0->block_last_index[VAR_2] = VAR_4;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119,
121
],
[
123
],
[
125
],
[
127,
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
]
] |
4,474 | static int usb_net_handle_datain(USBNetState *s, USBPacket *p)
{
int ret = USB_RET_NAK;
if (s->in_ptr > s->in_len) {
s->in_ptr = s->in_len = 0;
ret = USB_RET_NAK;
return ret;
}
if (!s->in_len) {
ret = USB_RET_NAK;
return ret;
}
ret = s->in_len - s->in_ptr;
if (ret > p->len)
ret = p->len;
memcpy(p->data, &s->in_buf[s->in_ptr], ret);
s->in_ptr += ret;
if (s->in_ptr >= s->in_len &&
(is_rndis(s) || (s->in_len & (64 - 1)) || !ret)) {
/* no short packet necessary */
s->in_ptr = s->in_len = 0;
}
#ifdef TRAFFIC_DEBUG
fprintf(stderr, "usbnet: data in len %u return %d", p->len, ret);
{
int i;
fprintf(stderr, ":");
for (i = 0; i < ret; i++) {
if (!(i & 15))
fprintf(stderr, "\n%04x:", i);
fprintf(stderr, " %02x", p->data[i]);
}
fprintf(stderr, "\n\n");
}
#endif
return ret;
}
| true | qemu | 4f4321c11ff6e98583846bfd6f0e81954924b003 | static int usb_net_handle_datain(USBNetState *s, USBPacket *p)
{
int ret = USB_RET_NAK;
if (s->in_ptr > s->in_len) {
s->in_ptr = s->in_len = 0;
ret = USB_RET_NAK;
return ret;
}
if (!s->in_len) {
ret = USB_RET_NAK;
return ret;
}
ret = s->in_len - s->in_ptr;
if (ret > p->len)
ret = p->len;
memcpy(p->data, &s->in_buf[s->in_ptr], ret);
s->in_ptr += ret;
if (s->in_ptr >= s->in_len &&
(is_rndis(s) || (s->in_len & (64 - 1)) || !ret)) {
s->in_ptr = s->in_len = 0;
}
#ifdef TRAFFIC_DEBUG
fprintf(stderr, "usbnet: data in len %u return %d", p->len, ret);
{
int i;
fprintf(stderr, ":");
for (i = 0; i < ret; i++) {
if (!(i & 15))
fprintf(stderr, "\n%04x:", i);
fprintf(stderr, " %02x", p->data[i]);
}
fprintf(stderr, "\n\n");
}
#endif
return ret;
}
| {
"code": [
" int i;",
" fprintf(stderr, \":\");",
" for (i = 0; i < ret; i++) {",
" if (!(i & 15))",
" fprintf(stderr, \"\\n%04x:\", i);",
" fprintf(stderr, \" %02x\", p->data[i]);",
" fprintf(stderr, \"\\n\\n\");",
" if (ret > p->len)",
" ret = p->len;",
" memcpy(p->data, &s->in_buf[s->in_ptr], ret);",
" fprintf(stderr, \"usbnet: data in len %u return %d\", p->len, ret);",
" int i;",
" fprintf(stderr, \":\");",
" for (i = 0; i < ret; i++) {",
" if (!(i & 15))",
" fprintf(stderr, \"\\n%04x:\", i);",
" fprintf(stderr, \" %02x\", p->data[i]);",
" fprintf(stderr, \"\\n\\n\");",
" int i;",
" fprintf(stderr, \":\");",
" if (!(i & 15))",
" fprintf(stderr, \"\\n%04x:\", i);",
" fprintf(stderr, \" %02x\", p->data[i]);",
" fprintf(stderr, \"\\n\\n\");"
],
"line_no": [
55,
57,
59,
61,
63,
65,
69,
29,
31,
33,
51,
55,
57,
59,
61,
63,
65,
69,
55,
57,
61,
63,
65,
69
]
} | static int FUNC_0(USBNetState *VAR_0, USBPacket *VAR_1)
{
int VAR_2 = USB_RET_NAK;
if (VAR_0->in_ptr > VAR_0->in_len) {
VAR_0->in_ptr = VAR_0->in_len = 0;
VAR_2 = USB_RET_NAK;
return VAR_2;
}
if (!VAR_0->in_len) {
VAR_2 = USB_RET_NAK;
return VAR_2;
}
VAR_2 = VAR_0->in_len - VAR_0->in_ptr;
if (VAR_2 > VAR_1->len)
VAR_2 = VAR_1->len;
memcpy(VAR_1->data, &VAR_0->in_buf[VAR_0->in_ptr], VAR_2);
VAR_0->in_ptr += VAR_2;
if (VAR_0->in_ptr >= VAR_0->in_len &&
(is_rndis(VAR_0) || (VAR_0->in_len & (64 - 1)) || !VAR_2)) {
VAR_0->in_ptr = VAR_0->in_len = 0;
}
#ifdef TRAFFIC_DEBUG
fprintf(stderr, "usbnet: data in len %u return %d", VAR_1->len, VAR_2);
{
int i;
fprintf(stderr, ":");
for (i = 0; i < VAR_2; i++) {
if (!(i & 15))
fprintf(stderr, "\n%04x:", i);
fprintf(stderr, " %02x", VAR_1->data[i]);
}
fprintf(stderr, "\n\n");
}
#endif
return VAR_2;
}
| [
"static int FUNC_0(USBNetState *VAR_0, USBPacket *VAR_1)\n{",
"int VAR_2 = USB_RET_NAK;",
"if (VAR_0->in_ptr > VAR_0->in_len) {",
"VAR_0->in_ptr = VAR_0->in_len = 0;",
"VAR_2 = USB_RET_NAK;",
"return VAR_2;",
"}",
"if (!VAR_0->in_len) {",
"VAR_2 = USB_RET_NAK;",
"return VAR_2;",
"}",
"VAR_2 = VAR_0->in_len - VAR_0->in_ptr;",
"if (VAR_2 > VAR_1->len)\nVAR_2 = VAR_1->len;",
"memcpy(VAR_1->data, &VAR_0->in_buf[VAR_0->in_ptr], VAR_2);",
"VAR_0->in_ptr += VAR_2;",
"if (VAR_0->in_ptr >= VAR_0->in_len &&\n(is_rndis(VAR_0) || (VAR_0->in_len & (64 - 1)) || !VAR_2)) {",
"VAR_0->in_ptr = VAR_0->in_len = 0;",
"}",
"#ifdef TRAFFIC_DEBUG\nfprintf(stderr, \"usbnet: data in len %u return %d\", VAR_1->len, VAR_2);",
"{",
"int i;",
"fprintf(stderr, \":\");",
"for (i = 0; i < VAR_2; i++) {",
"if (!(i & 15))\nfprintf(stderr, \"\\n%04x:\", i);",
"fprintf(stderr, \" %02x\", VAR_1->data[i]);",
"}",
"fprintf(stderr, \"\\n\\n\");",
"}",
"#endif\nreturn VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
1,
0,
1,
1,
1,
1,
1,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37,
39
],
[
43
],
[
45
],
[
49,
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73,
77
],
[
79
]
] |
4,475 | static void read_xing_toc(AVFormatContext *s, int64_t filesize, int64_t duration)
{
int i;
MP3DecContext *mp3 = s->priv_data;
int fill_index = mp3->usetoc == 1 && duration > 0;
if (!filesize &&
!(filesize = avio_size(s->pb))) {
av_log(s, AV_LOG_WARNING, "Cannot determine file size, skipping TOC table.\n");
fill_index = 0;
}
for (i = 0; i < XING_TOC_COUNT; i++) {
uint8_t b = avio_r8(s->pb);
if (fill_index)
av_add_index_entry(s->streams[0],
av_rescale(b, filesize, 256),
av_rescale(i, duration, XING_TOC_COUNT),
0, 0, AVINDEX_KEYFRAME);
}
if (fill_index)
mp3->xing_toc = 1;
}
| false | FFmpeg | 5e6ce28dabe002a6130f17b59c454bdee33088f7 | static void read_xing_toc(AVFormatContext *s, int64_t filesize, int64_t duration)
{
int i;
MP3DecContext *mp3 = s->priv_data;
int fill_index = mp3->usetoc == 1 && duration > 0;
if (!filesize &&
!(filesize = avio_size(s->pb))) {
av_log(s, AV_LOG_WARNING, "Cannot determine file size, skipping TOC table.\n");
fill_index = 0;
}
for (i = 0; i < XING_TOC_COUNT; i++) {
uint8_t b = avio_r8(s->pb);
if (fill_index)
av_add_index_entry(s->streams[0],
av_rescale(b, filesize, 256),
av_rescale(i, duration, XING_TOC_COUNT),
0, 0, AVINDEX_KEYFRAME);
}
if (fill_index)
mp3->xing_toc = 1;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVFormatContext *VAR_0, int64_t VAR_1, int64_t VAR_2)
{
int VAR_3;
MP3DecContext *mp3 = VAR_0->priv_data;
int VAR_4 = mp3->usetoc == 1 && VAR_2 > 0;
if (!VAR_1 &&
!(VAR_1 = avio_size(VAR_0->pb))) {
av_log(VAR_0, AV_LOG_WARNING, "Cannot determine file size, skipping TOC table.\n");
VAR_4 = 0;
}
for (VAR_3 = 0; VAR_3 < XING_TOC_COUNT; VAR_3++) {
uint8_t b = avio_r8(VAR_0->pb);
if (VAR_4)
av_add_index_entry(VAR_0->streams[0],
av_rescale(b, VAR_1, 256),
av_rescale(VAR_3, VAR_2, XING_TOC_COUNT),
0, 0, AVINDEX_KEYFRAME);
}
if (VAR_4)
mp3->xing_toc = 1;
}
| [
"static void FUNC_0(AVFormatContext *VAR_0, int64_t VAR_1, int64_t VAR_2)\n{",
"int VAR_3;",
"MP3DecContext *mp3 = VAR_0->priv_data;",
"int VAR_4 = mp3->usetoc == 1 && VAR_2 > 0;",
"if (!VAR_1 &&\n!(VAR_1 = avio_size(VAR_0->pb))) {",
"av_log(VAR_0, AV_LOG_WARNING, \"Cannot determine file size, skipping TOC table.\\n\");",
"VAR_4 = 0;",
"}",
"for (VAR_3 = 0; VAR_3 < XING_TOC_COUNT; VAR_3++) {",
"uint8_t b = avio_r8(VAR_0->pb);",
"if (VAR_4)\nav_add_index_entry(VAR_0->streams[0],\nav_rescale(b, VAR_1, 256),\nav_rescale(VAR_3, VAR_2, XING_TOC_COUNT),\n0, 0, AVINDEX_KEYFRAME);",
"}",
"if (VAR_4)\nmp3->xing_toc = 1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29,
31,
33,
35,
37
],
[
39
],
[
41,
43
],
[
45
]
] |
4,476 | void ff_put_h264_qpel8_mc00_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
copy_width8_msa(src, stride, dst, stride, 8);
}
| false | FFmpeg | 0105ed551cb9610c62b6920a301125781e1161a0 | void ff_put_h264_qpel8_mc00_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
copy_width8_msa(src, stride, dst, stride, 8);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,
ptrdiff_t VAR_2)
{
copy_width8_msa(VAR_1, VAR_2, VAR_0, VAR_2, 8);
}
| [
"void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,\nptrdiff_t VAR_2)\n{",
"copy_width8_msa(VAR_1, VAR_2, VAR_0, VAR_2, 8);",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
]
] |
4,477 | static int ape_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
APEContext *s = avctx->priv_data;
int16_t *samples = data;
uint32_t nblocks;
int i;
int blockstodecode;
int bytes_used;
/* should not happen but who knows */
if (BLOCKS_PER_LOOP * 2 * avctx->channels > *data_size) {
av_log (avctx, AV_LOG_ERROR, "Output buffer is too small.\n");
return AVERROR(EINVAL);
}
/* this should never be negative, but bad things will happen if it is, so
check it just to make sure. */
av_assert0(s->samples >= 0);
if(!s->samples){
uint32_t offset;
void *tmp_data;
if (buf_size < 8) {
av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
return AVERROR_INVALIDDATA;
}
tmp_data = av_realloc(s->data, FFALIGN(buf_size, 4));
if (!tmp_data)
return AVERROR(ENOMEM);
s->data = tmp_data;
s->dsp.bswap_buf((uint32_t*)s->data, (const uint32_t*)buf, buf_size >> 2);
s->ptr = s->last_ptr = s->data;
s->data_end = s->data + buf_size;
nblocks = bytestream_get_be32(&s->ptr);
offset = bytestream_get_be32(&s->ptr);
if (offset > 3) {
av_log(avctx, AV_LOG_ERROR, "Incorrect offset passed\n");
s->data = NULL;
return AVERROR_INVALIDDATA;
}
if (s->data_end - s->ptr < offset) {
av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
return AVERROR_INVALIDDATA;
}
s->ptr += offset;
if (!nblocks || nblocks > INT_MAX) {
av_log(avctx, AV_LOG_ERROR, "Invalid sample count: %u.\n", nblocks);
return AVERROR_INVALIDDATA;
}
s->samples = nblocks;
memset(s->decoded0, 0, sizeof(s->decoded0));
memset(s->decoded1, 0, sizeof(s->decoded1));
/* Initialize the frame decoder */
if (init_frame_decoder(s) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error reading frame header\n");
return AVERROR_INVALIDDATA;
}
}
if (!s->data) {
*data_size = 0;
return buf_size;
}
nblocks = s->samples;
blockstodecode = FFMIN(BLOCKS_PER_LOOP, nblocks);
s->error=0;
if ((s->channels == 1) || (s->frameflags & APE_FRAMECODE_PSEUDO_STEREO))
ape_unpack_mono(s, blockstodecode);
else
ape_unpack_stereo(s, blockstodecode);
emms_c();
if (s->error) {
s->samples=0;
av_log(avctx, AV_LOG_ERROR, "Error decoding frame\n");
return AVERROR_INVALIDDATA;
}
for (i = 0; i < blockstodecode; i++) {
*samples++ = s->decoded0[i];
if(s->channels == 2)
*samples++ = s->decoded1[i];
}
s->samples -= blockstodecode;
*data_size = blockstodecode * 2 * s->channels;
bytes_used = s->samples ? s->ptr - s->last_ptr : buf_size;
s->last_ptr = s->ptr;
return bytes_used;
}
| false | FFmpeg | 4315c7d35aa946fb3a0da9a30f08fb4e0ca8edfb | static int ape_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
APEContext *s = avctx->priv_data;
int16_t *samples = data;
uint32_t nblocks;
int i;
int blockstodecode;
int bytes_used;
if (BLOCKS_PER_LOOP * 2 * avctx->channels > *data_size) {
av_log (avctx, AV_LOG_ERROR, "Output buffer is too small.\n");
return AVERROR(EINVAL);
}
av_assert0(s->samples >= 0);
if(!s->samples){
uint32_t offset;
void *tmp_data;
if (buf_size < 8) {
av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
return AVERROR_INVALIDDATA;
}
tmp_data = av_realloc(s->data, FFALIGN(buf_size, 4));
if (!tmp_data)
return AVERROR(ENOMEM);
s->data = tmp_data;
s->dsp.bswap_buf((uint32_t*)s->data, (const uint32_t*)buf, buf_size >> 2);
s->ptr = s->last_ptr = s->data;
s->data_end = s->data + buf_size;
nblocks = bytestream_get_be32(&s->ptr);
offset = bytestream_get_be32(&s->ptr);
if (offset > 3) {
av_log(avctx, AV_LOG_ERROR, "Incorrect offset passed\n");
s->data = NULL;
return AVERROR_INVALIDDATA;
}
if (s->data_end - s->ptr < offset) {
av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
return AVERROR_INVALIDDATA;
}
s->ptr += offset;
if (!nblocks || nblocks > INT_MAX) {
av_log(avctx, AV_LOG_ERROR, "Invalid sample count: %u.\n", nblocks);
return AVERROR_INVALIDDATA;
}
s->samples = nblocks;
memset(s->decoded0, 0, sizeof(s->decoded0));
memset(s->decoded1, 0, sizeof(s->decoded1));
if (init_frame_decoder(s) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error reading frame header\n");
return AVERROR_INVALIDDATA;
}
}
if (!s->data) {
*data_size = 0;
return buf_size;
}
nblocks = s->samples;
blockstodecode = FFMIN(BLOCKS_PER_LOOP, nblocks);
s->error=0;
if ((s->channels == 1) || (s->frameflags & APE_FRAMECODE_PSEUDO_STEREO))
ape_unpack_mono(s, blockstodecode);
else
ape_unpack_stereo(s, blockstodecode);
emms_c();
if (s->error) {
s->samples=0;
av_log(avctx, AV_LOG_ERROR, "Error decoding frame\n");
return AVERROR_INVALIDDATA;
}
for (i = 0; i < blockstodecode; i++) {
*samples++ = s->decoded0[i];
if(s->channels == 2)
*samples++ = s->decoded1[i];
}
s->samples -= blockstodecode;
*data_size = blockstodecode * 2 * s->channels;
bytes_used = s->samples ? s->ptr - s->last_ptr : buf_size;
s->last_ptr = s->ptr;
return bytes_used;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
APEContext *s = VAR_0->priv_data;
int16_t *samples = VAR_1;
uint32_t nblocks;
int VAR_6;
int VAR_7;
int VAR_8;
if (BLOCKS_PER_LOOP * 2 * VAR_0->channels > *VAR_2) {
av_log (VAR_0, AV_LOG_ERROR, "Output buffer is too small.\n");
return AVERROR(EINVAL);
}
av_assert0(s->samples >= 0);
if(!s->samples){
uint32_t offset;
void *VAR_9;
if (VAR_5 < 8) {
av_log(VAR_0, AV_LOG_ERROR, "Packet is too small\n");
return AVERROR_INVALIDDATA;
}
VAR_9 = av_realloc(s->VAR_1, FFALIGN(VAR_5, 4));
if (!VAR_9)
return AVERROR(ENOMEM);
s->VAR_1 = VAR_9;
s->dsp.bswap_buf((uint32_t*)s->VAR_1, (const uint32_t*)VAR_4, VAR_5 >> 2);
s->ptr = s->last_ptr = s->VAR_1;
s->data_end = s->VAR_1 + VAR_5;
nblocks = bytestream_get_be32(&s->ptr);
offset = bytestream_get_be32(&s->ptr);
if (offset > 3) {
av_log(VAR_0, AV_LOG_ERROR, "Incorrect offset passed\n");
s->VAR_1 = NULL;
return AVERROR_INVALIDDATA;
}
if (s->data_end - s->ptr < offset) {
av_log(VAR_0, AV_LOG_ERROR, "Packet is too small\n");
return AVERROR_INVALIDDATA;
}
s->ptr += offset;
if (!nblocks || nblocks > INT_MAX) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid sample count: %u.\n", nblocks);
return AVERROR_INVALIDDATA;
}
s->samples = nblocks;
memset(s->decoded0, 0, sizeof(s->decoded0));
memset(s->decoded1, 0, sizeof(s->decoded1));
if (init_frame_decoder(s) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Error reading frame header\n");
return AVERROR_INVALIDDATA;
}
}
if (!s->VAR_1) {
*VAR_2 = 0;
return VAR_5;
}
nblocks = s->samples;
VAR_7 = FFMIN(BLOCKS_PER_LOOP, nblocks);
s->error=0;
if ((s->channels == 1) || (s->frameflags & APE_FRAMECODE_PSEUDO_STEREO))
ape_unpack_mono(s, VAR_7);
else
ape_unpack_stereo(s, VAR_7);
emms_c();
if (s->error) {
s->samples=0;
av_log(VAR_0, AV_LOG_ERROR, "Error decoding frame\n");
return AVERROR_INVALIDDATA;
}
for (VAR_6 = 0; VAR_6 < VAR_7; VAR_6++) {
*samples++ = s->decoded0[VAR_6];
if(s->channels == 2)
*samples++ = s->decoded1[VAR_6];
}
s->samples -= VAR_7;
*VAR_2 = VAR_7 * 2 * s->channels;
VAR_8 = s->samples ? s->ptr - s->last_ptr : VAR_5;
s->last_ptr = s->ptr;
return VAR_8;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"APEContext *s = VAR_0->priv_data;",
"int16_t *samples = VAR_1;",
"uint32_t nblocks;",
"int VAR_6;",
"int VAR_7;",
"int VAR_8;",
"if (BLOCKS_PER_LOOP * 2 * VAR_0->channels > *VAR_2) {",
"av_log (VAR_0, AV_LOG_ERROR, \"Output buffer is too small.\\n\");",
"return AVERROR(EINVAL);",
"}",
"av_assert0(s->samples >= 0);",
"if(!s->samples){",
"uint32_t offset;",
"void *VAR_9;",
"if (VAR_5 < 8) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Packet is too small\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_9 = av_realloc(s->VAR_1, FFALIGN(VAR_5, 4));",
"if (!VAR_9)\nreturn AVERROR(ENOMEM);",
"s->VAR_1 = VAR_9;",
"s->dsp.bswap_buf((uint32_t*)s->VAR_1, (const uint32_t*)VAR_4, VAR_5 >> 2);",
"s->ptr = s->last_ptr = s->VAR_1;",
"s->data_end = s->VAR_1 + VAR_5;",
"nblocks = bytestream_get_be32(&s->ptr);",
"offset = bytestream_get_be32(&s->ptr);",
"if (offset > 3) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Incorrect offset passed\\n\");",
"s->VAR_1 = NULL;",
"return AVERROR_INVALIDDATA;",
"}",
"if (s->data_end - s->ptr < offset) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Packet is too small\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"s->ptr += offset;",
"if (!nblocks || nblocks > INT_MAX) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid sample count: %u.\\n\", nblocks);",
"return AVERROR_INVALIDDATA;",
"}",
"s->samples = nblocks;",
"memset(s->decoded0, 0, sizeof(s->decoded0));",
"memset(s->decoded1, 0, sizeof(s->decoded1));",
"if (init_frame_decoder(s) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error reading frame header\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"}",
"if (!s->VAR_1) {",
"*VAR_2 = 0;",
"return VAR_5;",
"}",
"nblocks = s->samples;",
"VAR_7 = FFMIN(BLOCKS_PER_LOOP, nblocks);",
"s->error=0;",
"if ((s->channels == 1) || (s->frameflags & APE_FRAMECODE_PSEUDO_STEREO))\nape_unpack_mono(s, VAR_7);",
"else\nape_unpack_stereo(s, VAR_7);",
"emms_c();",
"if (s->error) {",
"s->samples=0;",
"av_log(VAR_0, AV_LOG_ERROR, \"Error decoding frame\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"for (VAR_6 = 0; VAR_6 < VAR_7; VAR_6++) {",
"*samples++ = s->decoded0[VAR_6];",
"if(s->channels == 2)\n*samples++ = s->decoded1[VAR_6];",
"}",
"s->samples -= VAR_7;",
"*VAR_2 = VAR_7 * 2 * s->channels;",
"VAR_8 = s->samples ? s->ptr - s->last_ptr : VAR_5;",
"s->last_ptr = s->ptr;",
"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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
29
],
[
31
],
[
33
],
[
35
],
[
43
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
155
],
[
159,
161
],
[
163,
165
],
[
167
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
183
],
[
185
],
[
187,
189
],
[
191
],
[
195
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
]
] |
4,480 | static void sun4uv_init(ram_addr_t RAM_size,
const char *boot_devices,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model,
const struct hwdef *hwdef)
{
CPUState *env;
m48t59_t *nvram;
unsigned int i;
long initrd_size, kernel_size;
PCIBus *pci_bus, *pci_bus2, *pci_bus3;
qemu_irq *irq;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
DriveInfo *fd[MAX_FD];
void *fw_cfg;
/* init CPUs */
env = cpu_devinit(cpu_model, hwdef);
/* set up devices */
ram_init(0, RAM_size);
prom_init(hwdef->prom_addr, bios_name);
irq = qemu_allocate_irqs(cpu_set_irq, env, MAX_PILS);
pci_bus = pci_apb_init(APB_SPECIAL_BASE, APB_MEM_BASE, irq, &pci_bus2,
&pci_bus3);
isa_mem_base = VGA_BASE;
pci_vga_init(pci_bus, 0, 0);
// XXX Should be pci_bus3
pci_ebus_init(pci_bus, -1);
i = 0;
if (hwdef->console_serial_base) {
serial_mm_init(hwdef->console_serial_base, 0, NULL, 115200,
serial_hds[i], 1);
i++;
}
for(; i < MAX_SERIAL_PORTS; i++) {
if (serial_hds[i]) {
serial_isa_init(i, serial_hds[i]);
}
}
for(i = 0; i < MAX_PARALLEL_PORTS; i++) {
if (parallel_hds[i]) {
parallel_init(i, parallel_hds[i]);
}
}
for(i = 0; i < nb_nics; i++)
pci_nic_init(&nd_table[i], "ne2k_pci", NULL);
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
fprintf(stderr, "qemu: too many IDE bus\n");
exit(1);
}
for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) {
hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS,
i % MAX_IDE_DEVS);
}
pci_cmd646_ide_init(pci_bus, hd, 1);
isa_create_simple("i8042");
for(i = 0; i < MAX_FD; i++) {
fd[i] = drive_get(IF_FLOPPY, 0, i);
}
fdctrl_init_isa(fd);
nvram = m48t59_init_isa(0x0074, NVRAM_SIZE, 59);
initrd_size = 0;
kernel_size = sun4u_load_kernel(kernel_filename, initrd_filename,
ram_size, &initrd_size);
sun4u_NVRAM_set_params(nvram, NVRAM_SIZE, "Sun4u", RAM_size, boot_devices,
KERNEL_LOAD_ADDR, kernel_size,
kernel_cmdline,
INITRD_LOAD_ADDR, initrd_size,
/* XXX: need an option to load a NVRAM image */
0,
graphic_width, graphic_height, graphic_depth,
(uint8_t *)&nd_table[0].macaddr);
fw_cfg = fw_cfg_init(BIOS_CFG_IOPORT, BIOS_CFG_IOPORT + 1, 0, 0);
fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, KERNEL_LOAD_ADDR);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
if (kernel_cmdline) {
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
pstrcpy_targphys(CMDLINE_ADDR, TARGET_PAGE_SIZE, kernel_cmdline);
} else {
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
}
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, INITRD_LOAD_ADDR);
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size);
fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, boot_devices[0]);
fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_WIDTH, graphic_width);
fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_HEIGHT, graphic_height);
fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_DEPTH, graphic_depth);
qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
}
| true | qemu | 07caea315a85ebfe90851f9c2e4ef3fdd24117b5 | static void sun4uv_init(ram_addr_t RAM_size,
const char *boot_devices,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model,
const struct hwdef *hwdef)
{
CPUState *env;
m48t59_t *nvram;
unsigned int i;
long initrd_size, kernel_size;
PCIBus *pci_bus, *pci_bus2, *pci_bus3;
qemu_irq *irq;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
DriveInfo *fd[MAX_FD];
void *fw_cfg;
env = cpu_devinit(cpu_model, hwdef);
ram_init(0, RAM_size);
prom_init(hwdef->prom_addr, bios_name);
irq = qemu_allocate_irqs(cpu_set_irq, env, MAX_PILS);
pci_bus = pci_apb_init(APB_SPECIAL_BASE, APB_MEM_BASE, irq, &pci_bus2,
&pci_bus3);
isa_mem_base = VGA_BASE;
pci_vga_init(pci_bus, 0, 0);
pci_ebus_init(pci_bus, -1);
i = 0;
if (hwdef->console_serial_base) {
serial_mm_init(hwdef->console_serial_base, 0, NULL, 115200,
serial_hds[i], 1);
i++;
}
for(; i < MAX_SERIAL_PORTS; i++) {
if (serial_hds[i]) {
serial_isa_init(i, serial_hds[i]);
}
}
for(i = 0; i < MAX_PARALLEL_PORTS; i++) {
if (parallel_hds[i]) {
parallel_init(i, parallel_hds[i]);
}
}
for(i = 0; i < nb_nics; i++)
pci_nic_init(&nd_table[i], "ne2k_pci", NULL);
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
fprintf(stderr, "qemu: too many IDE bus\n");
exit(1);
}
for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) {
hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS,
i % MAX_IDE_DEVS);
}
pci_cmd646_ide_init(pci_bus, hd, 1);
isa_create_simple("i8042");
for(i = 0; i < MAX_FD; i++) {
fd[i] = drive_get(IF_FLOPPY, 0, i);
}
fdctrl_init_isa(fd);
nvram = m48t59_init_isa(0x0074, NVRAM_SIZE, 59);
initrd_size = 0;
kernel_size = sun4u_load_kernel(kernel_filename, initrd_filename,
ram_size, &initrd_size);
sun4u_NVRAM_set_params(nvram, NVRAM_SIZE, "Sun4u", RAM_size, boot_devices,
KERNEL_LOAD_ADDR, kernel_size,
kernel_cmdline,
INITRD_LOAD_ADDR, initrd_size,
0,
graphic_width, graphic_height, graphic_depth,
(uint8_t *)&nd_table[0].macaddr);
fw_cfg = fw_cfg_init(BIOS_CFG_IOPORT, BIOS_CFG_IOPORT + 1, 0, 0);
fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, KERNEL_LOAD_ADDR);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
if (kernel_cmdline) {
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
pstrcpy_targphys(CMDLINE_ADDR, TARGET_PAGE_SIZE, kernel_cmdline);
} else {
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
}
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, INITRD_LOAD_ADDR);
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size);
fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, boot_devices[0]);
fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_WIDTH, graphic_width);
fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_HEIGHT, graphic_height);
fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_DEPTH, graphic_depth);
qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
}
| {
"code": [
" pci_nic_init(&nd_table[i], \"ne2k_pci\", NULL);",
" pci_nic_init(&nd_table[i], \"ne2k_pci\", NULL);",
" pci_nic_init(&nd_table[i], \"ne2k_pci\", NULL);"
],
"line_no": [
107,
107,
107
]
} | static void FUNC_0(ram_addr_t VAR_0,
const char *VAR_1,
const char *VAR_2, const char *VAR_3,
const char *VAR_4, const char *VAR_5,
const struct VAR_6 *VAR_6)
{
CPUState *env;
m48t59_t *nvram;
unsigned int VAR_7;
long VAR_8, VAR_9;
PCIBus *pci_bus, *pci_bus2, *pci_bus3;
qemu_irq *irq;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
DriveInfo *fd[MAX_FD];
void *VAR_10;
env = cpu_devinit(VAR_5, VAR_6);
ram_init(0, VAR_0);
prom_init(VAR_6->prom_addr, bios_name);
irq = qemu_allocate_irqs(cpu_set_irq, env, MAX_PILS);
pci_bus = pci_apb_init(APB_SPECIAL_BASE, APB_MEM_BASE, irq, &pci_bus2,
&pci_bus3);
isa_mem_base = VGA_BASE;
pci_vga_init(pci_bus, 0, 0);
pci_ebus_init(pci_bus, -1);
VAR_7 = 0;
if (VAR_6->console_serial_base) {
serial_mm_init(VAR_6->console_serial_base, 0, NULL, 115200,
serial_hds[VAR_7], 1);
VAR_7++;
}
for(; VAR_7 < MAX_SERIAL_PORTS; VAR_7++) {
if (serial_hds[VAR_7]) {
serial_isa_init(VAR_7, serial_hds[VAR_7]);
}
}
for(VAR_7 = 0; VAR_7 < MAX_PARALLEL_PORTS; VAR_7++) {
if (parallel_hds[VAR_7]) {
parallel_init(VAR_7, parallel_hds[VAR_7]);
}
}
for(VAR_7 = 0; VAR_7 < nb_nics; VAR_7++)
pci_nic_init(&nd_table[VAR_7], "ne2k_pci", NULL);
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
fprintf(stderr, "qemu: too many IDE bus\n");
exit(1);
}
for(VAR_7 = 0; VAR_7 < MAX_IDE_BUS * MAX_IDE_DEVS; VAR_7++) {
hd[VAR_7] = drive_get(IF_IDE, VAR_7 / MAX_IDE_DEVS,
VAR_7 % MAX_IDE_DEVS);
}
pci_cmd646_ide_init(pci_bus, hd, 1);
isa_create_simple("i8042");
for(VAR_7 = 0; VAR_7 < MAX_FD; VAR_7++) {
fd[VAR_7] = drive_get(IF_FLOPPY, 0, VAR_7);
}
fdctrl_init_isa(fd);
nvram = m48t59_init_isa(0x0074, NVRAM_SIZE, 59);
VAR_8 = 0;
VAR_9 = sun4u_load_kernel(VAR_2, VAR_4,
ram_size, &VAR_8);
sun4u_NVRAM_set_params(nvram, NVRAM_SIZE, "Sun4u", VAR_0, VAR_1,
KERNEL_LOAD_ADDR, VAR_9,
VAR_3,
INITRD_LOAD_ADDR, VAR_8,
0,
graphic_width, graphic_height, graphic_depth,
(uint8_t *)&nd_table[0].macaddr);
VAR_10 = fw_cfg_init(BIOS_CFG_IOPORT, BIOS_CFG_IOPORT + 1, 0, 0);
fw_cfg_add_i32(VAR_10, FW_CFG_ID, 1);
fw_cfg_add_i64(VAR_10, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
fw_cfg_add_i16(VAR_10, FW_CFG_MACHINE_ID, VAR_6->machine_id);
fw_cfg_add_i32(VAR_10, FW_CFG_KERNEL_ADDR, KERNEL_LOAD_ADDR);
fw_cfg_add_i32(VAR_10, FW_CFG_KERNEL_SIZE, VAR_9);
if (VAR_3) {
fw_cfg_add_i32(VAR_10, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
pstrcpy_targphys(CMDLINE_ADDR, TARGET_PAGE_SIZE, VAR_3);
} else {
fw_cfg_add_i32(VAR_10, FW_CFG_KERNEL_CMDLINE, 0);
}
fw_cfg_add_i32(VAR_10, FW_CFG_INITRD_ADDR, INITRD_LOAD_ADDR);
fw_cfg_add_i32(VAR_10, FW_CFG_INITRD_SIZE, VAR_8);
fw_cfg_add_i16(VAR_10, FW_CFG_BOOT_DEVICE, VAR_1[0]);
fw_cfg_add_i16(VAR_10, FW_CFG_SPARC64_WIDTH, graphic_width);
fw_cfg_add_i16(VAR_10, FW_CFG_SPARC64_HEIGHT, graphic_height);
fw_cfg_add_i16(VAR_10, FW_CFG_SPARC64_DEPTH, graphic_depth);
qemu_register_boot_set(fw_cfg_boot_set, VAR_10);
}
| [
"static void FUNC_0(ram_addr_t VAR_0,\nconst char *VAR_1,\nconst char *VAR_2, const char *VAR_3,\nconst char *VAR_4, const char *VAR_5,\nconst struct VAR_6 *VAR_6)\n{",
"CPUState *env;",
"m48t59_t *nvram;",
"unsigned int VAR_7;",
"long VAR_8, VAR_9;",
"PCIBus *pci_bus, *pci_bus2, *pci_bus3;",
"qemu_irq *irq;",
"DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];",
"DriveInfo *fd[MAX_FD];",
"void *VAR_10;",
"env = cpu_devinit(VAR_5, VAR_6);",
"ram_init(0, VAR_0);",
"prom_init(VAR_6->prom_addr, bios_name);",
"irq = qemu_allocate_irqs(cpu_set_irq, env, MAX_PILS);",
"pci_bus = pci_apb_init(APB_SPECIAL_BASE, APB_MEM_BASE, irq, &pci_bus2,\n&pci_bus3);",
"isa_mem_base = VGA_BASE;",
"pci_vga_init(pci_bus, 0, 0);",
"pci_ebus_init(pci_bus, -1);",
"VAR_7 = 0;",
"if (VAR_6->console_serial_base) {",
"serial_mm_init(VAR_6->console_serial_base, 0, NULL, 115200,\nserial_hds[VAR_7], 1);",
"VAR_7++;",
"}",
"for(; VAR_7 < MAX_SERIAL_PORTS; VAR_7++) {",
"if (serial_hds[VAR_7]) {",
"serial_isa_init(VAR_7, serial_hds[VAR_7]);",
"}",
"}",
"for(VAR_7 = 0; VAR_7 < MAX_PARALLEL_PORTS; VAR_7++) {",
"if (parallel_hds[VAR_7]) {",
"parallel_init(VAR_7, parallel_hds[VAR_7]);",
"}",
"}",
"for(VAR_7 = 0; VAR_7 < nb_nics; VAR_7++)",
"pci_nic_init(&nd_table[VAR_7], \"ne2k_pci\", NULL);",
"if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {",
"fprintf(stderr, \"qemu: too many IDE bus\\n\");",
"exit(1);",
"}",
"for(VAR_7 = 0; VAR_7 < MAX_IDE_BUS * MAX_IDE_DEVS; VAR_7++) {",
"hd[VAR_7] = drive_get(IF_IDE, VAR_7 / MAX_IDE_DEVS,\nVAR_7 % MAX_IDE_DEVS);",
"}",
"pci_cmd646_ide_init(pci_bus, hd, 1);",
"isa_create_simple(\"i8042\");",
"for(VAR_7 = 0; VAR_7 < MAX_FD; VAR_7++) {",
"fd[VAR_7] = drive_get(IF_FLOPPY, 0, VAR_7);",
"}",
"fdctrl_init_isa(fd);",
"nvram = m48t59_init_isa(0x0074, NVRAM_SIZE, 59);",
"VAR_8 = 0;",
"VAR_9 = sun4u_load_kernel(VAR_2, VAR_4,\nram_size, &VAR_8);",
"sun4u_NVRAM_set_params(nvram, NVRAM_SIZE, \"Sun4u\", VAR_0, VAR_1,\nKERNEL_LOAD_ADDR, VAR_9,\nVAR_3,\nINITRD_LOAD_ADDR, VAR_8,\n0,\ngraphic_width, graphic_height, graphic_depth,\n(uint8_t *)&nd_table[0].macaddr);",
"VAR_10 = fw_cfg_init(BIOS_CFG_IOPORT, BIOS_CFG_IOPORT + 1, 0, 0);",
"fw_cfg_add_i32(VAR_10, FW_CFG_ID, 1);",
"fw_cfg_add_i64(VAR_10, FW_CFG_RAM_SIZE, (uint64_t)ram_size);",
"fw_cfg_add_i16(VAR_10, FW_CFG_MACHINE_ID, VAR_6->machine_id);",
"fw_cfg_add_i32(VAR_10, FW_CFG_KERNEL_ADDR, KERNEL_LOAD_ADDR);",
"fw_cfg_add_i32(VAR_10, FW_CFG_KERNEL_SIZE, VAR_9);",
"if (VAR_3) {",
"fw_cfg_add_i32(VAR_10, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);",
"pstrcpy_targphys(CMDLINE_ADDR, TARGET_PAGE_SIZE, VAR_3);",
"} else {",
"fw_cfg_add_i32(VAR_10, FW_CFG_KERNEL_CMDLINE, 0);",
"}",
"fw_cfg_add_i32(VAR_10, FW_CFG_INITRD_ADDR, INITRD_LOAD_ADDR);",
"fw_cfg_add_i32(VAR_10, FW_CFG_INITRD_SIZE, VAR_8);",
"fw_cfg_add_i16(VAR_10, FW_CFG_BOOT_DEVICE, VAR_1[0]);",
"fw_cfg_add_i16(VAR_10, FW_CFG_SPARC64_WIDTH, graphic_width);",
"fw_cfg_add_i16(VAR_10, FW_CFG_SPARC64_HEIGHT, graphic_height);",
"fw_cfg_add_i16(VAR_10, FW_CFG_SPARC64_DEPTH, graphic_depth);",
"qemu_register_boot_set(fw_cfg_boot_set, VAR_10);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
35
],
[
41
],
[
45
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
65
],
[
69
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121,
123
],
[
125
],
[
129
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149,
151
],
[
155,
157,
159,
161,
165,
167,
169
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
205
],
[
207
],
[
209
],
[
213
],
[
215
]
] |
4,481 | bool bdrv_all_can_snapshot(BlockDriverState **first_bad_bs)
{
bool ok = true;
BlockDriverState *bs;
BdrvNextIterator it;
for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
AioContext *ctx = bdrv_get_aio_context(bs);
aio_context_acquire(ctx);
if (bdrv_is_inserted(bs) && !bdrv_is_read_only(bs)) {
ok = bdrv_can_snapshot(bs);
}
aio_context_release(ctx);
if (!ok) {
goto fail;
}
}
fail:
*first_bad_bs = bs;
return ok;
} | true | qemu | 5e003f17ec518cd96f5d2ac23ce9e14144426235 | bool bdrv_all_can_snapshot(BlockDriverState **first_bad_bs)
{
bool ok = true;
BlockDriverState *bs;
BdrvNextIterator it;
for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
AioContext *ctx = bdrv_get_aio_context(bs);
aio_context_acquire(ctx);
if (bdrv_is_inserted(bs) && !bdrv_is_read_only(bs)) {
ok = bdrv_can_snapshot(bs);
}
aio_context_release(ctx);
if (!ok) {
goto fail;
}
}
fail:
*first_bad_bs = bs;
return ok;
} | {
"code": [
" BlockDriverState *bs;"
],
"line_no": [
7
]
} | bool FUNC_0(BlockDriverState **first_bad_bs)
{
bool ok = true;
BlockDriverState *bs;
BdrvNextIterator it;
for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
AioContext *ctx = bdrv_get_aio_context(bs);
aio_context_acquire(ctx);
if (bdrv_is_inserted(bs) && !bdrv_is_read_only(bs)) {
ok = bdrv_can_snapshot(bs);
}
aio_context_release(ctx);
if (!ok) {
goto fail;
}
}
fail:
*first_bad_bs = bs;
return ok;
} | [
"bool FUNC_0(BlockDriverState **first_bad_bs)\n{",
"bool ok = true;",
"BlockDriverState *bs;",
"BdrvNextIterator it;",
"for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {",
"AioContext *ctx = bdrv_get_aio_context(bs);",
"aio_context_acquire(ctx);",
"if (bdrv_is_inserted(bs) && !bdrv_is_read_only(bs)) {",
"ok = bdrv_can_snapshot(bs);",
"}",
"aio_context_release(ctx);",
"if (!ok) {",
"goto fail;",
"}",
"}",
"fail:\n*first_bad_bs = bs;",
"return ok;",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
32
],
[
34
],
[
36
],
[
40,
42
],
[
44
],
[
46
]
] |
4,482 | static void ps2_reset_keyboard(PS2KbdState *s)
{
trace_ps2_reset_keyboard(s);
s->scan_enabled = 1;
s->scancode_set = 2;
ps2_set_ledstate(s, 0);
} | true | qemu | 6e24ee0c1e4b6c0c9c748acab77ecd113c942a4d | static void ps2_reset_keyboard(PS2KbdState *s)
{
trace_ps2_reset_keyboard(s);
s->scan_enabled = 1;
s->scancode_set = 2;
ps2_set_ledstate(s, 0);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(PS2KbdState *VAR_0)
{
trace_ps2_reset_keyboard(VAR_0);
VAR_0->scan_enabled = 1;
VAR_0->scancode_set = 2;
ps2_set_ledstate(VAR_0, 0);
} | [
"static void FUNC_0(PS2KbdState *VAR_0)\n{",
"trace_ps2_reset_keyboard(VAR_0);",
"VAR_0->scan_enabled = 1;",
"VAR_0->scancode_set = 2;",
"ps2_set_ledstate(VAR_0, 0);",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
12
],
[
14
]
] |
4,483 | int qemu_savevm_state_complete(QEMUFile *f)
{
SaveStateEntry *se;
TAILQ_FOREACH(se, &savevm_handlers, entry) {
if (se->save_live_state == NULL)
continue;
/* Section type */
qemu_put_byte(f, QEMU_VM_SECTION_END);
qemu_put_be32(f, se->section_id);
se->save_live_state(f, QEMU_VM_SECTION_END, se->opaque);
}
TAILQ_FOREACH(se, &savevm_handlers, entry) {
int len;
if (se->save_state == NULL && se->vmsd == NULL)
continue;
/* Section type */
qemu_put_byte(f, QEMU_VM_SECTION_FULL);
qemu_put_be32(f, se->section_id);
/* ID string */
len = strlen(se->idstr);
qemu_put_byte(f, len);
qemu_put_buffer(f, (uint8_t *)se->idstr, len);
qemu_put_be32(f, se->instance_id);
qemu_put_be32(f, se->version_id);
vmstate_save(f, se);
}
qemu_put_byte(f, QEMU_VM_EOF);
if (qemu_file_has_error(f))
return -EIO;
return 0;
}
| false | qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | int qemu_savevm_state_complete(QEMUFile *f)
{
SaveStateEntry *se;
TAILQ_FOREACH(se, &savevm_handlers, entry) {
if (se->save_live_state == NULL)
continue;
qemu_put_byte(f, QEMU_VM_SECTION_END);
qemu_put_be32(f, se->section_id);
se->save_live_state(f, QEMU_VM_SECTION_END, se->opaque);
}
TAILQ_FOREACH(se, &savevm_handlers, entry) {
int len;
if (se->save_state == NULL && se->vmsd == NULL)
continue;
qemu_put_byte(f, QEMU_VM_SECTION_FULL);
qemu_put_be32(f, se->section_id);
len = strlen(se->idstr);
qemu_put_byte(f, len);
qemu_put_buffer(f, (uint8_t *)se->idstr, len);
qemu_put_be32(f, se->instance_id);
qemu_put_be32(f, se->version_id);
vmstate_save(f, se);
}
qemu_put_byte(f, QEMU_VM_EOF);
if (qemu_file_has_error(f))
return -EIO;
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(QEMUFile *VAR_0)
{
SaveStateEntry *se;
TAILQ_FOREACH(se, &savevm_handlers, entry) {
if (se->save_live_state == NULL)
continue;
qemu_put_byte(VAR_0, QEMU_VM_SECTION_END);
qemu_put_be32(VAR_0, se->section_id);
se->save_live_state(VAR_0, QEMU_VM_SECTION_END, se->opaque);
}
TAILQ_FOREACH(se, &savevm_handlers, entry) {
int len;
if (se->save_state == NULL && se->vmsd == NULL)
continue;
qemu_put_byte(VAR_0, QEMU_VM_SECTION_FULL);
qemu_put_be32(VAR_0, se->section_id);
len = strlen(se->idstr);
qemu_put_byte(VAR_0, len);
qemu_put_buffer(VAR_0, (uint8_t *)se->idstr, len);
qemu_put_be32(VAR_0, se->instance_id);
qemu_put_be32(VAR_0, se->version_id);
vmstate_save(VAR_0, se);
}
qemu_put_byte(VAR_0, QEMU_VM_EOF);
if (qemu_file_has_error(VAR_0))
return -EIO;
return 0;
}
| [
"int FUNC_0(QEMUFile *VAR_0)\n{",
"SaveStateEntry *se;",
"TAILQ_FOREACH(se, &savevm_handlers, entry) {",
"if (se->save_live_state == NULL)\ncontinue;",
"qemu_put_byte(VAR_0, QEMU_VM_SECTION_END);",
"qemu_put_be32(VAR_0, se->section_id);",
"se->save_live_state(VAR_0, QEMU_VM_SECTION_END, se->opaque);",
"}",
"TAILQ_FOREACH(se, &savevm_handlers, entry) {",
"int len;",
"if (se->save_state == NULL && se->vmsd == NULL)\ncontinue;",
"qemu_put_byte(VAR_0, QEMU_VM_SECTION_FULL);",
"qemu_put_be32(VAR_0, se->section_id);",
"len = strlen(se->idstr);",
"qemu_put_byte(VAR_0, len);",
"qemu_put_buffer(VAR_0, (uint8_t *)se->idstr, len);",
"qemu_put_be32(VAR_0, se->instance_id);",
"qemu_put_be32(VAR_0, se->version_id);",
"vmstate_save(VAR_0, se);",
"}",
"qemu_put_byte(VAR_0, QEMU_VM_EOF);",
"if (qemu_file_has_error(VAR_0))\nreturn -EIO;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37,
39
],
[
45
],
[
47
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
67
],
[
69
],
[
73
],
[
77,
79
],
[
83
],
[
85
]
] |
4,484 | static GenericList *next_list(Visitor *v, GenericList **list, size_t size)
{
StringOutputVisitor *sov = to_sov(v);
GenericList *ret = NULL;
if (*list) {
if (sov->head) {
ret = *list;
} else {
ret = (*list)->next;
}
if (sov->head) {
if (ret && ret->next == NULL) {
sov->list_mode = LM_NONE;
}
sov->head = false;
} else {
if (ret && ret->next == NULL) {
sov->list_mode = LM_END;
}
}
}
return ret;
}
| false | qemu | d9f62dde1303286b24ac8ce88be27e2b9b9c5f46 | static GenericList *next_list(Visitor *v, GenericList **list, size_t size)
{
StringOutputVisitor *sov = to_sov(v);
GenericList *ret = NULL;
if (*list) {
if (sov->head) {
ret = *list;
} else {
ret = (*list)->next;
}
if (sov->head) {
if (ret && ret->next == NULL) {
sov->list_mode = LM_NONE;
}
sov->head = false;
} else {
if (ret && ret->next == NULL) {
sov->list_mode = LM_END;
}
}
}
return ret;
}
| {
"code": [],
"line_no": []
} | static GenericList *FUNC_0(Visitor *v, GenericList **list, size_t size)
{
StringOutputVisitor *sov = to_sov(v);
GenericList *ret = NULL;
if (*list) {
if (sov->head) {
ret = *list;
} else {
ret = (*list)->next;
}
if (sov->head) {
if (ret && ret->next == NULL) {
sov->list_mode = LM_NONE;
}
sov->head = false;
} else {
if (ret && ret->next == NULL) {
sov->list_mode = LM_END;
}
}
}
return ret;
}
| [
"static GenericList *FUNC_0(Visitor *v, GenericList **list, size_t size)\n{",
"StringOutputVisitor *sov = to_sov(v);",
"GenericList *ret = NULL;",
"if (*list) {",
"if (sov->head) {",
"ret = *list;",
"} else {",
"ret = (*list)->next;",
"}",
"if (sov->head) {",
"if (ret && ret->next == NULL) {",
"sov->list_mode = LM_NONE;",
"}",
"sov->head = false;",
"} else {",
"if (ret && ret->next == NULL) {",
"sov->list_mode = LM_END;",
"}",
"}",
"}",
"return ret;",
"}"
] | [
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
],
[
47
],
[
49
]
] |
4,485 | static void curl_multi_timeout_do(void *arg)
{
#ifdef NEED_CURL_TIMER_CALLBACK
BDRVCURLState *s = (BDRVCURLState *)arg;
int running;
if (!s->multi) {
return;
}
aio_context_acquire(s->aio_context);
curl_multi_socket_action(s->multi, CURL_SOCKET_TIMEOUT, 0, &running);
curl_multi_check_completion(s);
aio_context_release(s->aio_context);
#else
abort();
#endif
}
| false | qemu | ba3186c4e473963ba83b5792f3d02d4ac0a76ba5 | static void curl_multi_timeout_do(void *arg)
{
#ifdef NEED_CURL_TIMER_CALLBACK
BDRVCURLState *s = (BDRVCURLState *)arg;
int running;
if (!s->multi) {
return;
}
aio_context_acquire(s->aio_context);
curl_multi_socket_action(s->multi, CURL_SOCKET_TIMEOUT, 0, &running);
curl_multi_check_completion(s);
aio_context_release(s->aio_context);
#else
abort();
#endif
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
#ifdef NEED_CURL_TIMER_CALLBACK
BDRVCURLState *s = (BDRVCURLState *)VAR_0;
int running;
if (!s->multi) {
return;
}
aio_context_acquire(s->aio_context);
curl_multi_socket_action(s->multi, CURL_SOCKET_TIMEOUT, 0, &running);
curl_multi_check_completion(s);
aio_context_release(s->aio_context);
#else
abort();
#endif
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"#ifdef NEED_CURL_TIMER_CALLBACK\nBDRVCURLState *s = (BDRVCURLState *)VAR_0;",
"int running;",
"if (!s->multi) {",
"return;",
"}",
"aio_context_acquire(s->aio_context);",
"curl_multi_socket_action(s->multi, CURL_SOCKET_TIMEOUT, 0, &running);",
"curl_multi_check_completion(s);",
"aio_context_release(s->aio_context);",
"#else\nabort();",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31,
33
],
[
35,
37
]
] |
4,486 | static int virtio_pci_ioeventfd_assign(DeviceState *d, EventNotifier *notifier,
int n, bool assign)
{
VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
VirtQueue *vq = virtio_get_queue(vdev, n);
bool legacy = !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_LEGACY);
bool modern = !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN);
bool fast_mmio = kvm_ioeventfd_any_length_enabled();
bool modern_pio = proxy->flags & VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY;
MemoryRegion *modern_mr = &proxy->notify.mr;
MemoryRegion *modern_notify_mr = &proxy->notify_pio.mr;
MemoryRegion *legacy_mr = &proxy->bar;
hwaddr modern_addr = QEMU_VIRTIO_PCI_QUEUE_MEM_MULT *
virtio_get_queue_index(vq);
hwaddr legacy_addr = VIRTIO_PCI_QUEUE_NOTIFY;
if (assign) {
if (modern) {
if (fast_mmio) {
memory_region_add_eventfd(modern_mr, modern_addr, 0,
false, n, notifier);
} else {
memory_region_add_eventfd(modern_mr, modern_addr, 2,
false, n, notifier);
}
if (modern_pio) {
memory_region_add_eventfd(modern_notify_mr, 0, 2,
true, n, notifier);
}
}
if (legacy) {
memory_region_add_eventfd(legacy_mr, legacy_addr, 2,
true, n, notifier);
}
} else {
if (modern) {
if (fast_mmio) {
memory_region_del_eventfd(modern_mr, modern_addr, 0,
false, n, notifier);
} else {
memory_region_del_eventfd(modern_mr, modern_addr, 2,
false, n, notifier);
}
if (modern_pio) {
memory_region_del_eventfd(modern_notify_mr, 0, 2,
true, n, notifier);
}
}
if (legacy) {
memory_region_del_eventfd(legacy_mr, legacy_addr, 2,
true, n, notifier);
}
}
return 0;
}
| false | qemu | 9a4c0e220d8a4f82b5665d0ee95ef94d8e1509d5 | static int virtio_pci_ioeventfd_assign(DeviceState *d, EventNotifier *notifier,
int n, bool assign)
{
VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
VirtQueue *vq = virtio_get_queue(vdev, n);
bool legacy = !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_LEGACY);
bool modern = !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN);
bool fast_mmio = kvm_ioeventfd_any_length_enabled();
bool modern_pio = proxy->flags & VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY;
MemoryRegion *modern_mr = &proxy->notify.mr;
MemoryRegion *modern_notify_mr = &proxy->notify_pio.mr;
MemoryRegion *legacy_mr = &proxy->bar;
hwaddr modern_addr = QEMU_VIRTIO_PCI_QUEUE_MEM_MULT *
virtio_get_queue_index(vq);
hwaddr legacy_addr = VIRTIO_PCI_QUEUE_NOTIFY;
if (assign) {
if (modern) {
if (fast_mmio) {
memory_region_add_eventfd(modern_mr, modern_addr, 0,
false, n, notifier);
} else {
memory_region_add_eventfd(modern_mr, modern_addr, 2,
false, n, notifier);
}
if (modern_pio) {
memory_region_add_eventfd(modern_notify_mr, 0, 2,
true, n, notifier);
}
}
if (legacy) {
memory_region_add_eventfd(legacy_mr, legacy_addr, 2,
true, n, notifier);
}
} else {
if (modern) {
if (fast_mmio) {
memory_region_del_eventfd(modern_mr, modern_addr, 0,
false, n, notifier);
} else {
memory_region_del_eventfd(modern_mr, modern_addr, 2,
false, n, notifier);
}
if (modern_pio) {
memory_region_del_eventfd(modern_notify_mr, 0, 2,
true, n, notifier);
}
}
if (legacy) {
memory_region_del_eventfd(legacy_mr, legacy_addr, 2,
true, n, notifier);
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(DeviceState *VAR_0, EventNotifier *VAR_1,
int VAR_2, bool VAR_3)
{
VirtIOPCIProxy *proxy = to_virtio_pci_proxy(VAR_0);
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
VirtQueue *vq = virtio_get_queue(vdev, VAR_2);
bool legacy = !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_LEGACY);
bool modern = !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN);
bool fast_mmio = kvm_ioeventfd_any_length_enabled();
bool modern_pio = proxy->flags & VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY;
MemoryRegion *modern_mr = &proxy->notify.mr;
MemoryRegion *modern_notify_mr = &proxy->notify_pio.mr;
MemoryRegion *legacy_mr = &proxy->bar;
hwaddr modern_addr = QEMU_VIRTIO_PCI_QUEUE_MEM_MULT *
virtio_get_queue_index(vq);
hwaddr legacy_addr = VIRTIO_PCI_QUEUE_NOTIFY;
if (VAR_3) {
if (modern) {
if (fast_mmio) {
memory_region_add_eventfd(modern_mr, modern_addr, 0,
false, VAR_2, VAR_1);
} else {
memory_region_add_eventfd(modern_mr, modern_addr, 2,
false, VAR_2, VAR_1);
}
if (modern_pio) {
memory_region_add_eventfd(modern_notify_mr, 0, 2,
true, VAR_2, VAR_1);
}
}
if (legacy) {
memory_region_add_eventfd(legacy_mr, legacy_addr, 2,
true, VAR_2, VAR_1);
}
} else {
if (modern) {
if (fast_mmio) {
memory_region_del_eventfd(modern_mr, modern_addr, 0,
false, VAR_2, VAR_1);
} else {
memory_region_del_eventfd(modern_mr, modern_addr, 2,
false, VAR_2, VAR_1);
}
if (modern_pio) {
memory_region_del_eventfd(modern_notify_mr, 0, 2,
true, VAR_2, VAR_1);
}
}
if (legacy) {
memory_region_del_eventfd(legacy_mr, legacy_addr, 2,
true, VAR_2, VAR_1);
}
}
return 0;
}
| [
"static int FUNC_0(DeviceState *VAR_0, EventNotifier *VAR_1,\nint VAR_2, bool VAR_3)\n{",
"VirtIOPCIProxy *proxy = to_virtio_pci_proxy(VAR_0);",
"VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);",
"VirtQueue *vq = virtio_get_queue(vdev, VAR_2);",
"bool legacy = !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_LEGACY);",
"bool modern = !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN);",
"bool fast_mmio = kvm_ioeventfd_any_length_enabled();",
"bool modern_pio = proxy->flags & VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY;",
"MemoryRegion *modern_mr = &proxy->notify.mr;",
"MemoryRegion *modern_notify_mr = &proxy->notify_pio.mr;",
"MemoryRegion *legacy_mr = &proxy->bar;",
"hwaddr modern_addr = QEMU_VIRTIO_PCI_QUEUE_MEM_MULT *\nvirtio_get_queue_index(vq);",
"hwaddr legacy_addr = VIRTIO_PCI_QUEUE_NOTIFY;",
"if (VAR_3) {",
"if (modern) {",
"if (fast_mmio) {",
"memory_region_add_eventfd(modern_mr, modern_addr, 0,\nfalse, VAR_2, VAR_1);",
"} else {",
"memory_region_add_eventfd(modern_mr, modern_addr, 2,\nfalse, VAR_2, VAR_1);",
"}",
"if (modern_pio) {",
"memory_region_add_eventfd(modern_notify_mr, 0, 2,\ntrue, VAR_2, VAR_1);",
"}",
"}",
"if (legacy) {",
"memory_region_add_eventfd(legacy_mr, legacy_addr, 2,\ntrue, VAR_2, VAR_1);",
"}",
"} else {",
"if (modern) {",
"if (fast_mmio) {",
"memory_region_del_eventfd(modern_mr, modern_addr, 0,\nfalse, VAR_2, VAR_1);",
"} else {",
"memory_region_del_eventfd(modern_mr, modern_addr, 2,\nfalse, VAR_2, VAR_1);",
"}",
"if (modern_pio) {",
"memory_region_del_eventfd(modern_notify_mr, 0, 2,\ntrue, VAR_2, VAR_1);",
"}",
"}",
"if (legacy) {",
"memory_region_del_eventfd(legacy_mr, legacy_addr, 2,\ntrue, VAR_2, VAR_1);",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
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
]
] |
4,487 | static uint64_t esp_pci_io_read(void *opaque, target_phys_addr_t addr,
unsigned int size)
{
PCIESPState *pci = opaque;
uint32_t ret;
if (addr < 0x40) {
/* SCSI core reg */
ret = esp_reg_read(&pci->esp, addr >> 2);
} else if (addr < 0x60) {
/* PCI DMA CCB */
ret = esp_pci_dma_read(pci, (addr - 0x40) >> 2);
} else if (addr == 0x70) {
/* DMA SCSI Bus and control */
trace_esp_pci_sbac_read(pci->sbac);
ret = pci->sbac;
} else {
/* Invalid region */
trace_esp_pci_error_invalid_read((int)addr);
ret = 0;
}
/* give only requested data */
ret >>= (addr & 3) * 8;
ret &= ~(~(uint64_t)0 << (8 * size));
return ret;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t esp_pci_io_read(void *opaque, target_phys_addr_t addr,
unsigned int size)
{
PCIESPState *pci = opaque;
uint32_t ret;
if (addr < 0x40) {
ret = esp_reg_read(&pci->esp, addr >> 2);
} else if (addr < 0x60) {
ret = esp_pci_dma_read(pci, (addr - 0x40) >> 2);
} else if (addr == 0x70) {
trace_esp_pci_sbac_read(pci->sbac);
ret = pci->sbac;
} else {
trace_esp_pci_error_invalid_read((int)addr);
ret = 0;
}
ret >>= (addr & 3) * 8;
ret &= ~(~(uint64_t)0 << (8 * size));
return ret;
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,
unsigned int size)
{
PCIESPState *pci = opaque;
uint32_t ret;
if (addr < 0x40) {
ret = esp_reg_read(&pci->esp, addr >> 2);
} else if (addr < 0x60) {
ret = esp_pci_dma_read(pci, (addr - 0x40) >> 2);
} else if (addr == 0x70) {
trace_esp_pci_sbac_read(pci->sbac);
ret = pci->sbac;
} else {
trace_esp_pci_error_invalid_read((int)addr);
ret = 0;
}
ret >>= (addr & 3) * 8;
ret &= ~(~(uint64_t)0 << (8 * size));
return ret;
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned int size)\n{",
"PCIESPState *pci = opaque;",
"uint32_t ret;",
"if (addr < 0x40) {",
"ret = esp_reg_read(&pci->esp, addr >> 2);",
"} else if (addr < 0x60) {",
"ret = esp_pci_dma_read(pci, (addr - 0x40) >> 2);",
"} else if (addr == 0x70) {",
"trace_esp_pci_sbac_read(pci->sbac);",
"ret = pci->sbac;",
"} else {",
"trace_esp_pci_error_invalid_read((int)addr);",
"ret = 0;",
"}",
"ret >>= (addr & 3) * 8;",
"ret &= ~(~(uint64_t)0 << (8 * size));",
"return ret;",
"}"
] | [
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
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
47
],
[
49
],
[
53
],
[
55
]
] |
4,489 | sorecvfrom(struct socket *so)
{
struct sockaddr_storage addr;
socklen_t addrlen = sizeof(struct sockaddr_storage);
DEBUG_CALL("sorecvfrom");
DEBUG_ARG("so = %p", so);
if (so->so_type == IPPROTO_ICMP) { /* This is a "ping" reply */
char buff[256];
int len;
len = recvfrom(so->s, buff, 256, 0,
(struct sockaddr *)&addr, &addrlen);
/* XXX Check if reply is "correct"? */
if(len == -1 || len == 0) {
u_char code=ICMP_UNREACH_PORT;
if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST;
else if(errno == ENETUNREACH) code=ICMP_UNREACH_NET;
DEBUG_MISC((dfd," udp icmp rx errno = %d-%s\n",
errno,strerror(errno)));
icmp_error(so->so_m, ICMP_UNREACH,code, 0,strerror(errno));
} else {
icmp_reflect(so->so_m);
so->so_m = NULL; /* Don't m_free() it again! */
}
/* No need for this socket anymore, udp_detach it */
udp_detach(so);
} else { /* A "normal" UDP packet */
struct mbuf *m;
int len;
#ifdef _WIN32
unsigned long n;
#else
int n;
#endif
m = m_get(so->slirp);
if (!m) {
return;
}
m->m_data += IF_MAXLINKHDR;
/*
* XXX Shouldn't FIONREAD packets destined for port 53,
* but I don't know the max packet size for DNS lookups
*/
len = M_FREEROOM(m);
/* if (so->so_fport != htons(53)) { */
ioctlsocket(so->s, FIONREAD, &n);
if (n > len) {
n = (m->m_data - m->m_dat) + m->m_len + n + 1;
m_inc(m, n);
len = M_FREEROOM(m);
}
/* } */
m->m_len = recvfrom(so->s, m->m_data, len, 0,
(struct sockaddr *)&addr, &addrlen);
DEBUG_MISC((dfd, " did recvfrom %d, errno = %d-%s\n",
m->m_len, errno,strerror(errno)));
if(m->m_len<0) {
u_char code=ICMP_UNREACH_PORT;
if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST;
else if(errno == ENETUNREACH) code=ICMP_UNREACH_NET;
DEBUG_MISC((dfd," rx error, tx icmp ICMP_UNREACH:%i\n", code));
icmp_error(so->so_m, ICMP_UNREACH,code, 0,strerror(errno));
m_free(m);
} else {
/*
* Hack: domain name lookup will be used the most for UDP,
* and since they'll only be used once there's no need
* for the 4 minute (or whatever) timeout... So we time them
* out much quicker (10 seconds for now...)
*/
if (so->so_expire) {
if (so->so_fport == htons(53))
so->so_expire = curtime + SO_EXPIREFAST;
else
so->so_expire = curtime + SO_EXPIRE;
}
/*
* If this packet was destined for CTL_ADDR,
* make it look like that's where it came from, done by udp_output
*/
switch (so->so_ffamily) {
case AF_INET:
udp_output(so, m, (struct sockaddr_in *) &addr);
break;
default:
break;
}
} /* rx error */
} /* if ping packet */
}
| false | qemu | 5379229a2708df3a1506113315214c3ce5325859 | sorecvfrom(struct socket *so)
{
struct sockaddr_storage addr;
socklen_t addrlen = sizeof(struct sockaddr_storage);
DEBUG_CALL("sorecvfrom");
DEBUG_ARG("so = %p", so);
if (so->so_type == IPPROTO_ICMP) {
char buff[256];
int len;
len = recvfrom(so->s, buff, 256, 0,
(struct sockaddr *)&addr, &addrlen);
if(len == -1 || len == 0) {
u_char code=ICMP_UNREACH_PORT;
if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST;
else if(errno == ENETUNREACH) code=ICMP_UNREACH_NET;
DEBUG_MISC((dfd," udp icmp rx errno = %d-%s\n",
errno,strerror(errno)));
icmp_error(so->so_m, ICMP_UNREACH,code, 0,strerror(errno));
} else {
icmp_reflect(so->so_m);
so->so_m = NULL;
}
udp_detach(so);
} else {
struct mbuf *m;
int len;
#ifdef _WIN32
unsigned long n;
#else
int n;
#endif
m = m_get(so->slirp);
if (!m) {
return;
}
m->m_data += IF_MAXLINKHDR;
len = M_FREEROOM(m);
ioctlsocket(so->s, FIONREAD, &n);
if (n > len) {
n = (m->m_data - m->m_dat) + m->m_len + n + 1;
m_inc(m, n);
len = M_FREEROOM(m);
}
m->m_len = recvfrom(so->s, m->m_data, len, 0,
(struct sockaddr *)&addr, &addrlen);
DEBUG_MISC((dfd, " did recvfrom %d, errno = %d-%s\n",
m->m_len, errno,strerror(errno)));
if(m->m_len<0) {
u_char code=ICMP_UNREACH_PORT;
if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST;
else if(errno == ENETUNREACH) code=ICMP_UNREACH_NET;
DEBUG_MISC((dfd," rx error, tx icmp ICMP_UNREACH:%i\n", code));
icmp_error(so->so_m, ICMP_UNREACH,code, 0,strerror(errno));
m_free(m);
} else {
if (so->so_expire) {
if (so->so_fport == htons(53))
so->so_expire = curtime + SO_EXPIREFAST;
else
so->so_expire = curtime + SO_EXPIRE;
}
switch (so->so_ffamily) {
case AF_INET:
udp_output(so, m, (struct sockaddr_in *) &addr);
break;
default:
break;
}
}
}
}
| {
"code": [],
"line_no": []
} | FUNC_0(struct socket *VAR_0)
{
struct sockaddr_storage VAR_1;
socklen_t addrlen = sizeof(struct sockaddr_storage);
DEBUG_CALL("FUNC_0");
DEBUG_ARG("VAR_0 = %p", VAR_0);
if (VAR_0->so_type == IPPROTO_ICMP) {
char VAR_2[256];
int VAR_5;
VAR_5 = recvfrom(VAR_0->s, VAR_2, 256, 0,
(struct sockaddr *)&VAR_1, &addrlen);
if(VAR_5 == -1 || VAR_5 == 0) {
u_char code=ICMP_UNREACH_PORT;
if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST;
else if(errno == ENETUNREACH) code=ICMP_UNREACH_NET;
DEBUG_MISC((dfd," udp icmp rx errno = %d-%s\VAR_5",
errno,strerror(errno)));
icmp_error(VAR_0->so_m, ICMP_UNREACH,code, 0,strerror(errno));
} else {
icmp_reflect(VAR_0->so_m);
VAR_0->so_m = NULL;
}
udp_detach(VAR_0);
} else {
struct mbuf *VAR_4;
int VAR_5;
#ifdef _WIN32
unsigned long VAR_5;
#else
int VAR_5;
#endif
VAR_4 = m_get(VAR_0->slirp);
if (!VAR_4) {
return;
}
VAR_4->m_data += IF_MAXLINKHDR;
VAR_5 = M_FREEROOM(VAR_4);
ioctlsocket(VAR_0->s, FIONREAD, &VAR_5);
if (VAR_5 > VAR_5) {
VAR_5 = (VAR_4->m_data - VAR_4->m_dat) + VAR_4->m_len + VAR_5 + 1;
m_inc(VAR_4, VAR_5);
VAR_5 = M_FREEROOM(VAR_4);
}
VAR_4->m_len = recvfrom(VAR_0->s, VAR_4->m_data, VAR_5, 0,
(struct sockaddr *)&VAR_1, &addrlen);
DEBUG_MISC((dfd, " did recvfrom %d, errno = %d-%s\VAR_5",
VAR_4->m_len, errno,strerror(errno)));
if(VAR_4->m_len<0) {
u_char code=ICMP_UNREACH_PORT;
if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST;
else if(errno == ENETUNREACH) code=ICMP_UNREACH_NET;
DEBUG_MISC((dfd," rx error, tx icmp ICMP_UNREACH:%i\VAR_5", code));
icmp_error(VAR_0->so_m, ICMP_UNREACH,code, 0,strerror(errno));
m_free(VAR_4);
} else {
if (VAR_0->so_expire) {
if (VAR_0->so_fport == htons(53))
VAR_0->so_expire = curtime + SO_EXPIREFAST;
else
VAR_0->so_expire = curtime + SO_EXPIRE;
}
switch (VAR_0->so_ffamily) {
case AF_INET:
udp_output(VAR_0, VAR_4, (struct sockaddr_in *) &VAR_1);
break;
default:
break;
}
}
}
}
| [
"FUNC_0(struct socket *VAR_0)\n{",
"struct sockaddr_storage VAR_1;",
"socklen_t addrlen = sizeof(struct sockaddr_storage);",
"DEBUG_CALL(\"FUNC_0\");",
"DEBUG_ARG(\"VAR_0 = %p\", VAR_0);",
"if (VAR_0->so_type == IPPROTO_ICMP) {",
"char VAR_2[256];",
"int VAR_5;",
"VAR_5 = recvfrom(VAR_0->s, VAR_2, 256, 0,\n(struct sockaddr *)&VAR_1, &addrlen);",
"if(VAR_5 == -1 || VAR_5 == 0) {",
"u_char code=ICMP_UNREACH_PORT;",
"if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST;",
"else if(errno == ENETUNREACH) code=ICMP_UNREACH_NET;",
"DEBUG_MISC((dfd,\" udp icmp rx errno = %d-%s\\VAR_5\",\nerrno,strerror(errno)));",
"icmp_error(VAR_0->so_m, ICMP_UNREACH,code, 0,strerror(errno));",
"} else {",
"icmp_reflect(VAR_0->so_m);",
"VAR_0->so_m = NULL;",
"}",
"udp_detach(VAR_0);",
"} else {",
"struct mbuf *VAR_4;",
"int VAR_5;",
"#ifdef _WIN32\nunsigned long VAR_5;",
"#else\nint VAR_5;",
"#endif\nVAR_4 = m_get(VAR_0->slirp);",
"if (!VAR_4) {",
"return;",
"}",
"VAR_4->m_data += IF_MAXLINKHDR;",
"VAR_5 = M_FREEROOM(VAR_4);",
"ioctlsocket(VAR_0->s, FIONREAD, &VAR_5);",
"if (VAR_5 > VAR_5) {",
"VAR_5 = (VAR_4->m_data - VAR_4->m_dat) + VAR_4->m_len + VAR_5 + 1;",
"m_inc(VAR_4, VAR_5);",
"VAR_5 = M_FREEROOM(VAR_4);",
"}",
"VAR_4->m_len = recvfrom(VAR_0->s, VAR_4->m_data, VAR_5, 0,\n(struct sockaddr *)&VAR_1, &addrlen);",
"DEBUG_MISC((dfd, \" did recvfrom %d, errno = %d-%s\\VAR_5\",\nVAR_4->m_len, errno,strerror(errno)));",
"if(VAR_4->m_len<0) {",
"u_char code=ICMP_UNREACH_PORT;",
"if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST;",
"else if(errno == ENETUNREACH) code=ICMP_UNREACH_NET;",
"DEBUG_MISC((dfd,\" rx error, tx icmp ICMP_UNREACH:%i\\VAR_5\", code));",
"icmp_error(VAR_0->so_m, ICMP_UNREACH,code, 0,strerror(errno));",
"m_free(VAR_4);",
"} else {",
"if (VAR_0->so_expire) {",
"if (VAR_0->so_fport == htons(53))\nVAR_0->so_expire = curtime + SO_EXPIREFAST;",
"else\nVAR_0->so_expire = curtime + SO_EXPIRE;",
"}",
"switch (VAR_0->so_ffamily) {",
"case AF_INET:\nudp_output(VAR_0, VAR_4, (struct sockaddr_in *) &VAR_1);",
"break;",
"default:\nbreak;",
"}",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25,
27
],
[
33
],
[
35
],
[
39
],
[
41
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
73,
75
],
[
77,
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
101
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
123,
125
],
[
127,
129
],
[
131
],
[
133
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
163
],
[
165,
167
],
[
169,
171
],
[
173
],
[
185
],
[
187,
189
],
[
191
],
[
193,
195
],
[
197
],
[
199
],
[
201
],
[
203
]
] |
4,490 | static int pxa2xx_rtc_init(SysBusDevice *dev)
{
PXA2xxRTCState *s = FROM_SYSBUS(PXA2xxRTCState, dev);
struct tm tm;
int wom;
int iomemtype;
s->rttr = 0x7fff;
s->rtsr = 0;
qemu_get_timedate(&tm, 0);
wom = ((tm.tm_mday - 1) / 7) + 1;
s->last_rcnr = (uint32_t) mktimegm(&tm);
s->last_rdcr = (wom << 20) | ((tm.tm_wday + 1) << 17) |
(tm.tm_hour << 12) | (tm.tm_min << 6) | tm.tm_sec;
s->last_rycr = ((tm.tm_year + 1900) << 9) |
((tm.tm_mon + 1) << 5) | tm.tm_mday;
s->last_swcr = (tm.tm_hour << 19) |
(tm.tm_min << 13) | (tm.tm_sec << 7);
s->last_rtcpicr = 0;
s->last_hz = s->last_sw = s->last_pi = qemu_get_clock(rt_clock);
s->rtc_hz = qemu_new_timer(rt_clock, pxa2xx_rtc_hz_tick, s);
s->rtc_rdal1 = qemu_new_timer(rt_clock, pxa2xx_rtc_rdal1_tick, s);
s->rtc_rdal2 = qemu_new_timer(rt_clock, pxa2xx_rtc_rdal2_tick, s);
s->rtc_swal1 = qemu_new_timer(rt_clock, pxa2xx_rtc_swal1_tick, s);
s->rtc_swal2 = qemu_new_timer(rt_clock, pxa2xx_rtc_swal2_tick, s);
s->rtc_pi = qemu_new_timer(rt_clock, pxa2xx_rtc_pi_tick, s);
sysbus_init_irq(dev, &s->rtc_irq);
iomemtype = cpu_register_io_memory(pxa2xx_rtc_readfn,
pxa2xx_rtc_writefn, s, DEVICE_NATIVE_ENDIAN);
sysbus_init_mmio(dev, 0x10000, iomemtype);
return 0;
}
| false | qemu | 7bd427d801e1e3293a634d3c83beadaa90ffb911 | static int pxa2xx_rtc_init(SysBusDevice *dev)
{
PXA2xxRTCState *s = FROM_SYSBUS(PXA2xxRTCState, dev);
struct tm tm;
int wom;
int iomemtype;
s->rttr = 0x7fff;
s->rtsr = 0;
qemu_get_timedate(&tm, 0);
wom = ((tm.tm_mday - 1) / 7) + 1;
s->last_rcnr = (uint32_t) mktimegm(&tm);
s->last_rdcr = (wom << 20) | ((tm.tm_wday + 1) << 17) |
(tm.tm_hour << 12) | (tm.tm_min << 6) | tm.tm_sec;
s->last_rycr = ((tm.tm_year + 1900) << 9) |
((tm.tm_mon + 1) << 5) | tm.tm_mday;
s->last_swcr = (tm.tm_hour << 19) |
(tm.tm_min << 13) | (tm.tm_sec << 7);
s->last_rtcpicr = 0;
s->last_hz = s->last_sw = s->last_pi = qemu_get_clock(rt_clock);
s->rtc_hz = qemu_new_timer(rt_clock, pxa2xx_rtc_hz_tick, s);
s->rtc_rdal1 = qemu_new_timer(rt_clock, pxa2xx_rtc_rdal1_tick, s);
s->rtc_rdal2 = qemu_new_timer(rt_clock, pxa2xx_rtc_rdal2_tick, s);
s->rtc_swal1 = qemu_new_timer(rt_clock, pxa2xx_rtc_swal1_tick, s);
s->rtc_swal2 = qemu_new_timer(rt_clock, pxa2xx_rtc_swal2_tick, s);
s->rtc_pi = qemu_new_timer(rt_clock, pxa2xx_rtc_pi_tick, s);
sysbus_init_irq(dev, &s->rtc_irq);
iomemtype = cpu_register_io_memory(pxa2xx_rtc_readfn,
pxa2xx_rtc_writefn, s, DEVICE_NATIVE_ENDIAN);
sysbus_init_mmio(dev, 0x10000, iomemtype);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(SysBusDevice *VAR_0)
{
PXA2xxRTCState *s = FROM_SYSBUS(PXA2xxRTCState, VAR_0);
struct VAR_1 VAR_1;
int VAR_2;
int VAR_3;
s->rttr = 0x7fff;
s->rtsr = 0;
qemu_get_timedate(&VAR_1, 0);
VAR_2 = ((VAR_1.tm_mday - 1) / 7) + 1;
s->last_rcnr = (uint32_t) mktimegm(&VAR_1);
s->last_rdcr = (VAR_2 << 20) | ((VAR_1.tm_wday + 1) << 17) |
(VAR_1.tm_hour << 12) | (VAR_1.tm_min << 6) | VAR_1.tm_sec;
s->last_rycr = ((VAR_1.tm_year + 1900) << 9) |
((VAR_1.tm_mon + 1) << 5) | VAR_1.tm_mday;
s->last_swcr = (VAR_1.tm_hour << 19) |
(VAR_1.tm_min << 13) | (VAR_1.tm_sec << 7);
s->last_rtcpicr = 0;
s->last_hz = s->last_sw = s->last_pi = qemu_get_clock(rt_clock);
s->rtc_hz = qemu_new_timer(rt_clock, pxa2xx_rtc_hz_tick, s);
s->rtc_rdal1 = qemu_new_timer(rt_clock, pxa2xx_rtc_rdal1_tick, s);
s->rtc_rdal2 = qemu_new_timer(rt_clock, pxa2xx_rtc_rdal2_tick, s);
s->rtc_swal1 = qemu_new_timer(rt_clock, pxa2xx_rtc_swal1_tick, s);
s->rtc_swal2 = qemu_new_timer(rt_clock, pxa2xx_rtc_swal2_tick, s);
s->rtc_pi = qemu_new_timer(rt_clock, pxa2xx_rtc_pi_tick, s);
sysbus_init_irq(VAR_0, &s->rtc_irq);
VAR_3 = cpu_register_io_memory(pxa2xx_rtc_readfn,
pxa2xx_rtc_writefn, s, DEVICE_NATIVE_ENDIAN);
sysbus_init_mmio(VAR_0, 0x10000, VAR_3);
return 0;
}
| [
"static int FUNC_0(SysBusDevice *VAR_0)\n{",
"PXA2xxRTCState *s = FROM_SYSBUS(PXA2xxRTCState, VAR_0);",
"struct VAR_1 VAR_1;",
"int VAR_2;",
"int VAR_3;",
"s->rttr = 0x7fff;",
"s->rtsr = 0;",
"qemu_get_timedate(&VAR_1, 0);",
"VAR_2 = ((VAR_1.tm_mday - 1) / 7) + 1;",
"s->last_rcnr = (uint32_t) mktimegm(&VAR_1);",
"s->last_rdcr = (VAR_2 << 20) | ((VAR_1.tm_wday + 1) << 17) |\n(VAR_1.tm_hour << 12) | (VAR_1.tm_min << 6) | VAR_1.tm_sec;",
"s->last_rycr = ((VAR_1.tm_year + 1900) << 9) |\n((VAR_1.tm_mon + 1) << 5) | VAR_1.tm_mday;",
"s->last_swcr = (VAR_1.tm_hour << 19) |\n(VAR_1.tm_min << 13) | (VAR_1.tm_sec << 7);",
"s->last_rtcpicr = 0;",
"s->last_hz = s->last_sw = s->last_pi = qemu_get_clock(rt_clock);",
"s->rtc_hz = qemu_new_timer(rt_clock, pxa2xx_rtc_hz_tick, s);",
"s->rtc_rdal1 = qemu_new_timer(rt_clock, pxa2xx_rtc_rdal1_tick, s);",
"s->rtc_rdal2 = qemu_new_timer(rt_clock, pxa2xx_rtc_rdal2_tick, s);",
"s->rtc_swal1 = qemu_new_timer(rt_clock, pxa2xx_rtc_swal1_tick, s);",
"s->rtc_swal2 = qemu_new_timer(rt_clock, pxa2xx_rtc_swal2_tick, s);",
"s->rtc_pi = qemu_new_timer(rt_clock, pxa2xx_rtc_pi_tick, s);",
"sysbus_init_irq(VAR_0, &s->rtc_irq);",
"VAR_3 = cpu_register_io_memory(pxa2xx_rtc_readfn,\npxa2xx_rtc_writefn, s, DEVICE_NATIVE_ENDIAN);",
"sysbus_init_mmio(VAR_0, 0x10000, VAR_3);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
27
],
[
29,
31
],
[
33,
35
],
[
37,
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
65,
67
],
[
69
],
[
73
],
[
75
]
] |
4,491 | static int transcode(AVFormatContext **output_files,
int nb_output_files,
AVFormatContext **input_files,
int nb_input_files,
AVStreamMap *stream_maps, int nb_stream_maps)
{
int ret = 0, i, j, k, n, nb_istreams = 0, nb_ostreams = 0, step;
AVFormatContext *is, *os;
AVCodecContext *codec, *icodec;
AVOutputStream *ost, **ost_table = NULL;
AVInputStream *ist, **ist_table = NULL;
AVInputFile *file_table;
char error[1024];
int key;
int want_sdp = 1;
uint8_t no_packet[MAX_FILES]={0};
int no_packet_count=0;
int nb_frame_threshold[AVMEDIA_TYPE_NB]={0};
int nb_streams[AVMEDIA_TYPE_NB]={0};
file_table= av_mallocz(nb_input_files * sizeof(AVInputFile));
if (!file_table)
goto fail;
/* input stream init */
j = 0;
for(i=0;i<nb_input_files;i++) {
is = input_files[i];
file_table[i].ist_index = j;
file_table[i].nb_streams = is->nb_streams;
j += is->nb_streams;
}
nb_istreams = j;
ist_table = av_mallocz(nb_istreams * sizeof(AVInputStream *));
if (!ist_table)
goto fail;
for(i=0;i<nb_istreams;i++) {
ist = av_mallocz(sizeof(AVInputStream));
if (!ist)
goto fail;
ist_table[i] = ist;
}
j = 0;
for(i=0;i<nb_input_files;i++) {
is = input_files[i];
for(k=0;k<is->nb_streams;k++) {
ist = ist_table[j++];
ist->st = is->streams[k];
ist->file_index = i;
ist->index = k;
ist->discard = 1; /* the stream is discarded by default
(changed later) */
if (rate_emu) {
ist->start = av_gettime();
}
}
}
/* output stream init */
nb_ostreams = 0;
for(i=0;i<nb_output_files;i++) {
os = output_files[i];
if (!os->nb_streams && !(os->oformat->flags & AVFMT_NOSTREAMS)) {
av_dump_format(output_files[i], i, output_files[i]->filename, 1);
fprintf(stderr, "Output file #%d does not contain any stream\n", i);
ret = AVERROR(EINVAL);
goto fail;
}
nb_ostreams += os->nb_streams;
}
if (nb_stream_maps > 0 && nb_stream_maps != nb_ostreams) {
fprintf(stderr, "Number of stream maps must match number of output streams\n");
ret = AVERROR(EINVAL);
goto fail;
}
/* Sanity check the mapping args -- do the input files & streams exist? */
for(i=0;i<nb_stream_maps;i++) {
int fi = stream_maps[i].file_index;
int si = stream_maps[i].stream_index;
if (fi < 0 || fi > nb_input_files - 1 ||
si < 0 || si > file_table[fi].nb_streams - 1) {
fprintf(stderr,"Could not find input stream #%d.%d\n", fi, si);
ret = AVERROR(EINVAL);
goto fail;
}
fi = stream_maps[i].sync_file_index;
si = stream_maps[i].sync_stream_index;
if (fi < 0 || fi > nb_input_files - 1 ||
si < 0 || si > file_table[fi].nb_streams - 1) {
fprintf(stderr,"Could not find sync stream #%d.%d\n", fi, si);
ret = AVERROR(EINVAL);
goto fail;
}
}
ost_table = av_mallocz(sizeof(AVOutputStream *) * nb_ostreams);
if (!ost_table)
goto fail;
for(k=0;k<nb_output_files;k++) {
os = output_files[k];
for(i=0;i<os->nb_streams;i++,n++) {
nb_streams[os->streams[i]->codec->codec_type]++;
}
}
for(step=1<<30; step; step>>=1){
int found_streams[AVMEDIA_TYPE_NB]={0};
for(j=0; j<AVMEDIA_TYPE_NB; j++)
nb_frame_threshold[j] += step;
for(j=0; j<nb_istreams; j++) {
int skip=0;
ist = ist_table[j];
if(opt_programid){
int pi,si;
AVFormatContext *f= input_files[ ist->file_index ];
skip=1;
for(pi=0; pi<f->nb_programs; pi++){
AVProgram *p= f->programs[pi];
if(p->id == opt_programid)
for(si=0; si<p->nb_stream_indexes; si++){
if(f->streams[ p->stream_index[si] ] == ist->st)
skip=0;
}
}
}
if (ist->discard && ist->st->discard != AVDISCARD_ALL && !skip
&& nb_frame_threshold[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames){
found_streams[ist->st->codec->codec_type]++;
}
}
for(j=0; j<AVMEDIA_TYPE_NB; j++)
if(found_streams[j] < nb_streams[j])
nb_frame_threshold[j] -= step;
}
n = 0;
for(k=0;k<nb_output_files;k++) {
os = output_files[k];
for(i=0;i<os->nb_streams;i++,n++) {
int found;
ost = ost_table[n] = output_streams_for_file[k][i];
ost->st = os->streams[i];
if (nb_stream_maps > 0) {
ost->source_index = file_table[stream_maps[n].file_index].ist_index +
stream_maps[n].stream_index;
/* Sanity check that the stream types match */
if (ist_table[ost->source_index]->st->codec->codec_type != ost->st->codec->codec_type) {
int i= ost->file_index;
av_dump_format(output_files[i], i, output_files[i]->filename, 1);
fprintf(stderr, "Codec type mismatch for mapping #%d.%d -> #%d.%d\n",
stream_maps[n].file_index, stream_maps[n].stream_index,
ost->file_index, ost->index);
ffmpeg_exit(1);
}
} else {
/* get corresponding input stream index : we select the first one with the right type */
found = 0;
for(j=0;j<nb_istreams;j++) {
int skip=0;
ist = ist_table[j];
if(opt_programid){
int pi,si;
AVFormatContext *f= input_files[ ist->file_index ];
skip=1;
for(pi=0; pi<f->nb_programs; pi++){
AVProgram *p= f->programs[pi];
if(p->id == opt_programid)
for(si=0; si<p->nb_stream_indexes; si++){
if(f->streams[ p->stream_index[si] ] == ist->st)
skip=0;
}
}
}
if (ist->discard && ist->st->discard != AVDISCARD_ALL && !skip &&
ist->st->codec->codec_type == ost->st->codec->codec_type &&
nb_frame_threshold[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames) {
ost->source_index = j;
found = 1;
break;
}
}
if (!found) {
if(! opt_programid) {
/* try again and reuse existing stream */
for(j=0;j<nb_istreams;j++) {
ist = ist_table[j];
if ( ist->st->codec->codec_type == ost->st->codec->codec_type
&& ist->st->discard != AVDISCARD_ALL) {
ost->source_index = j;
found = 1;
}
}
}
if (!found) {
int i= ost->file_index;
av_dump_format(output_files[i], i, output_files[i]->filename, 1);
fprintf(stderr, "Could not find input stream matching output stream #%d.%d\n",
ost->file_index, ost->index);
ffmpeg_exit(1);
}
}
}
ist = ist_table[ost->source_index];
ist->discard = 0;
ost->sync_ist = (nb_stream_maps > 0) ?
ist_table[file_table[stream_maps[n].sync_file_index].ist_index +
stream_maps[n].sync_stream_index] : ist;
}
}
/* for each output stream, we compute the right encoding parameters */
for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i];
os = output_files[ost->file_index];
ist = ist_table[ost->source_index];
codec = ost->st->codec;
icodec = ist->st->codec;
if (metadata_streams_autocopy)
av_metadata_copy(&ost->st->metadata, ist->st->metadata,
AV_METADATA_DONT_OVERWRITE);
ost->st->disposition = ist->st->disposition;
codec->bits_per_raw_sample= icodec->bits_per_raw_sample;
codec->chroma_sample_location = icodec->chroma_sample_location;
if (ost->st->stream_copy) {
uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE;
if (extra_size > INT_MAX)
goto fail;
/* if stream_copy is selected, no need to decode or encode */
codec->codec_id = icodec->codec_id;
codec->codec_type = icodec->codec_type;
if(!codec->codec_tag){
if( !os->oformat->codec_tag
|| av_codec_get_id (os->oformat->codec_tag, icodec->codec_tag) == codec->codec_id
|| av_codec_get_tag(os->oformat->codec_tag, icodec->codec_id) <= 0)
codec->codec_tag = icodec->codec_tag;
}
codec->bit_rate = icodec->bit_rate;
codec->rc_max_rate = icodec->rc_max_rate;
codec->rc_buffer_size = icodec->rc_buffer_size;
codec->extradata= av_mallocz(extra_size);
if (!codec->extradata)
goto fail;
memcpy(codec->extradata, icodec->extradata, icodec->extradata_size);
codec->extradata_size= icodec->extradata_size;
if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){
codec->time_base = icodec->time_base;
codec->time_base.num *= icodec->ticks_per_frame;
av_reduce(&codec->time_base.num, &codec->time_base.den,
codec->time_base.num, codec->time_base.den, INT_MAX);
}else
codec->time_base = ist->st->time_base;
switch(codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
if(audio_volume != 256) {
fprintf(stderr,"-acodec copy and -vol are incompatible (frames are not decoded)\n");
ffmpeg_exit(1);
}
codec->channel_layout = icodec->channel_layout;
codec->sample_rate = icodec->sample_rate;
codec->channels = icodec->channels;
codec->frame_size = icodec->frame_size;
codec->audio_service_type = icodec->audio_service_type;
codec->block_align= icodec->block_align;
if(codec->block_align == 1 && codec->codec_id == CODEC_ID_MP3)
codec->block_align= 0;
if(codec->codec_id == CODEC_ID_AC3)
codec->block_align= 0;
break;
case AVMEDIA_TYPE_VIDEO:
codec->pix_fmt = icodec->pix_fmt;
codec->width = icodec->width;
codec->height = icodec->height;
codec->has_b_frames = icodec->has_b_frames;
if (!codec->sample_aspect_ratio.num) {
codec->sample_aspect_ratio =
ost->st->sample_aspect_ratio =
ist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio :
ist->st->codec->sample_aspect_ratio.num ?
ist->st->codec->sample_aspect_ratio : (AVRational){0, 1};
}
break;
case AVMEDIA_TYPE_SUBTITLE:
codec->width = icodec->width;
codec->height = icodec->height;
break;
case AVMEDIA_TYPE_DATA:
break;
default:
abort();
}
} else {
switch(codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
ost->fifo= av_fifo_alloc(1024);
if(!ost->fifo)
goto fail;
ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE);
ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1;
icodec->request_channels = codec->channels;
ist->decoding_needed = 1;
ost->encoding_needed = 1;
ost->resample_sample_fmt = icodec->sample_fmt;
ost->resample_sample_rate = icodec->sample_rate;
ost->resample_channels = icodec->channels;
break;
case AVMEDIA_TYPE_VIDEO:
if (ost->st->codec->pix_fmt == PIX_FMT_NONE) {
fprintf(stderr, "Video pixel format is unknown, stream cannot be encoded\n");
ffmpeg_exit(1);
}
ost->video_resample = codec->width != icodec->width ||
codec->height != icodec->height ||
codec->pix_fmt != icodec->pix_fmt;
if (ost->video_resample) {
#if !CONFIG_AVFILTER
avcodec_get_frame_defaults(&ost->pict_tmp);
if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fmt,
codec->width, codec->height)) {
fprintf(stderr, "Cannot allocate temp picture, check pix fmt\n");
ffmpeg_exit(1);
}
sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
ost->img_resample_ctx = sws_getContext(
icodec->width,
icodec->height,
icodec->pix_fmt,
codec->width,
codec->height,
codec->pix_fmt,
sws_flags, NULL, NULL, NULL);
if (ost->img_resample_ctx == NULL) {
fprintf(stderr, "Cannot get resampling context\n");
ffmpeg_exit(1);
}
#endif
codec->bits_per_raw_sample= frame_bits_per_raw_sample;
}
ost->resample_height = icodec->height;
ost->resample_width = icodec->width;
ost->resample_pix_fmt= icodec->pix_fmt;
ost->encoding_needed = 1;
ist->decoding_needed = 1;
#if CONFIG_AVFILTER
if (configure_video_filters(ist, ost)) {
fprintf(stderr, "Error opening filters!\n");
exit(1);
}
#endif
break;
case AVMEDIA_TYPE_SUBTITLE:
ost->encoding_needed = 1;
ist->decoding_needed = 1;
break;
default:
abort();
break;
}
/* two pass mode */
if (ost->encoding_needed && codec->codec_id != CODEC_ID_H264 &&
(codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) {
char logfilename[1024];
FILE *f;
snprintf(logfilename, sizeof(logfilename), "%s-%d.log",
pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX,
i);
if (codec->flags & CODEC_FLAG_PASS1) {
f = fopen(logfilename, "wb");
if (!f) {
fprintf(stderr, "Cannot write log file '%s' for pass-1 encoding: %s\n", logfilename, strerror(errno));
ffmpeg_exit(1);
}
ost->logfile = f;
} else {
char *logbuffer;
size_t logbuffer_size;
if (read_file(logfilename, &logbuffer, &logbuffer_size) < 0) {
fprintf(stderr, "Error reading log file '%s' for pass-2 encoding\n", logfilename);
ffmpeg_exit(1);
}
codec->stats_in = logbuffer;
}
}
}
if(codec->codec_type == AVMEDIA_TYPE_VIDEO){
/* maximum video buffer size is 6-bytes per pixel, plus DPX header size */
int size= codec->width * codec->height;
bit_buffer_size= FFMAX(bit_buffer_size, 6*size + 1664);
}
}
if (!bit_buffer)
bit_buffer = av_malloc(bit_buffer_size);
if (!bit_buffer) {
fprintf(stderr, "Cannot allocate %d bytes output buffer\n",
bit_buffer_size);
ret = AVERROR(ENOMEM);
goto fail;
}
/* open each encoder */
for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i];
if (ost->encoding_needed) {
AVCodec *codec = i < nb_output_codecs ? output_codecs[i] : NULL;
AVCodecContext *dec = ist_table[ost->source_index]->st->codec;
if (!codec)
codec = avcodec_find_encoder(ost->st->codec->codec_id);
if (!codec) {
snprintf(error, sizeof(error), "Encoder (codec id %d) not found for output stream #%d.%d",
ost->st->codec->codec_id, ost->file_index, ost->index);
ret = AVERROR(EINVAL);
goto dump_format;
}
if (dec->subtitle_header) {
ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size);
if (!ost->st->codec->subtitle_header) {
ret = AVERROR(ENOMEM);
goto dump_format;
}
memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size);
ost->st->codec->subtitle_header_size = dec->subtitle_header_size;
}
if (avcodec_open(ost->st->codec, codec) < 0) {
snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height",
ost->file_index, ost->index);
ret = AVERROR(EINVAL);
goto dump_format;
}
extra_size += ost->st->codec->extradata_size;
}
}
/* open each decoder */
for(i=0;i<nb_istreams;i++) {
ist = ist_table[i];
if (ist->decoding_needed) {
AVCodec *codec = i < nb_input_codecs ? input_codecs[i] : NULL;
if (!codec)
codec = avcodec_find_decoder(ist->st->codec->codec_id);
if (!codec) {
snprintf(error, sizeof(error), "Decoder (codec id %d) not found for input stream #%d.%d",
ist->st->codec->codec_id, ist->file_index, ist->index);
ret = AVERROR(EINVAL);
goto dump_format;
}
if (avcodec_open(ist->st->codec, codec) < 0) {
snprintf(error, sizeof(error), "Error while opening decoder for input stream #%d.%d",
ist->file_index, ist->index);
ret = AVERROR(EINVAL);
goto dump_format;
}
//if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
// ist->st->codec->flags |= CODEC_FLAG_REPEAT_FIELD;
}
}
/* init pts */
for(i=0;i<nb_istreams;i++) {
AVStream *st;
ist = ist_table[i];
st= ist->st;
ist->pts = st->avg_frame_rate.num ? - st->codec->has_b_frames*AV_TIME_BASE / av_q2d(st->avg_frame_rate) : 0;
ist->next_pts = AV_NOPTS_VALUE;
ist->is_start = 1;
}
/* set meta data information from input file if required */
for (i=0;i<nb_meta_data_maps;i++) {
AVFormatContext *files[2];
AVMetadata **meta[2];
int j;
#define METADATA_CHECK_INDEX(index, nb_elems, desc)\
if ((index) < 0 || (index) >= (nb_elems)) {\
snprintf(error, sizeof(error), "Invalid %s index %d while processing metadata maps\n",\
(desc), (index));\
ret = AVERROR(EINVAL);\
goto dump_format;\
}
int out_file_index = meta_data_maps[i][0].file;
int in_file_index = meta_data_maps[i][1].file;
if (in_file_index < 0 || out_file_index < 0)
continue;
METADATA_CHECK_INDEX(out_file_index, nb_output_files, "output file")
METADATA_CHECK_INDEX(in_file_index, nb_input_files, "input file")
files[0] = output_files[out_file_index];
files[1] = input_files[in_file_index];
for (j = 0; j < 2; j++) {
AVMetaDataMap *map = &meta_data_maps[i][j];
switch (map->type) {
case 'g':
meta[j] = &files[j]->metadata;
break;
case 's':
METADATA_CHECK_INDEX(map->index, files[j]->nb_streams, "stream")
meta[j] = &files[j]->streams[map->index]->metadata;
break;
case 'c':
METADATA_CHECK_INDEX(map->index, files[j]->nb_chapters, "chapter")
meta[j] = &files[j]->chapters[map->index]->metadata;
break;
case 'p':
METADATA_CHECK_INDEX(map->index, files[j]->nb_programs, "program")
meta[j] = &files[j]->programs[map->index]->metadata;
break;
}
}
av_metadata_copy(meta[0], *meta[1], AV_METADATA_DONT_OVERWRITE);
}
/* copy global metadata by default */
if (metadata_global_autocopy) {
for (i = 0; i < nb_output_files; i++)
av_metadata_copy(&output_files[i]->metadata, input_files[0]->metadata,
AV_METADATA_DONT_OVERWRITE);
}
/* copy chapters according to chapter maps */
for (i = 0; i < nb_chapter_maps; i++) {
int infile = chapter_maps[i].in_file;
int outfile = chapter_maps[i].out_file;
if (infile < 0 || outfile < 0)
continue;
if (infile >= nb_input_files) {
snprintf(error, sizeof(error), "Invalid input file index %d in chapter mapping.\n", infile);
ret = AVERROR(EINVAL);
goto dump_format;
}
if (outfile >= nb_output_files) {
snprintf(error, sizeof(error), "Invalid output file index %d in chapter mapping.\n",outfile);
ret = AVERROR(EINVAL);
goto dump_format;
}
copy_chapters(infile, outfile);
}
/* copy chapters from the first input file that has them*/
if (!nb_chapter_maps)
for (i = 0; i < nb_input_files; i++) {
if (!input_files[i]->nb_chapters)
continue;
for (j = 0; j < nb_output_files; j++)
if ((ret = copy_chapters(i, j)) < 0)
goto dump_format;
break;
}
/* open files and write file headers */
for(i=0;i<nb_output_files;i++) {
os = output_files[i];
if (av_write_header(os) < 0) {
snprintf(error, sizeof(error), "Could not write header for output file #%d (incorrect codec parameters ?)", i);
ret = AVERROR(EINVAL);
goto dump_format;
}
if (strcmp(output_files[i]->oformat->name, "rtp")) {
want_sdp = 0;
}
}
dump_format:
/* dump the file output parameters - cannot be done before in case
of stream copy */
for(i=0;i<nb_output_files;i++) {
av_dump_format(output_files[i], i, output_files[i]->filename, 1);
}
/* dump the stream mapping */
if (verbose >= 0) {
fprintf(stderr, "Stream mapping:\n");
for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i];
fprintf(stderr, " Stream #%d.%d -> #%d.%d",
ist_table[ost->source_index]->file_index,
ist_table[ost->source_index]->index,
ost->file_index,
ost->index);
if (ost->sync_ist != ist_table[ost->source_index])
fprintf(stderr, " [sync #%d.%d]",
ost->sync_ist->file_index,
ost->sync_ist->index);
fprintf(stderr, "\n");
}
}
if (ret) {
fprintf(stderr, "%s\n", error);
goto fail;
}
if (want_sdp) {
print_sdp(output_files, nb_output_files);
}
if (!using_stdin) {
if(verbose >= 0)
fprintf(stderr, "Press [q] to stop encoding\n");
avio_set_interrupt_cb(decode_interrupt_cb);
}
term_init();
timer_start = av_gettime();
for(; received_sigterm == 0;) {
int file_index, ist_index;
AVPacket pkt;
double ipts_min;
double opts_min;
redo:
ipts_min= 1e100;
opts_min= 1e100;
/* if 'q' pressed, exits */
if (!using_stdin) {
if (q_pressed)
break;
/* read_key() returns 0 on EOF */
key = read_key();
if (key == 'q')
break;
}
/* select the stream that we must read now by looking at the
smallest output pts */
file_index = -1;
for(i=0;i<nb_ostreams;i++) {
double ipts, opts;
ost = ost_table[i];
os = output_files[ost->file_index];
ist = ist_table[ost->source_index];
if(ist->is_past_recording_time || no_packet[ist->file_index])
continue;
opts = ost->st->pts.val * av_q2d(ost->st->time_base);
ipts = (double)ist->pts;
if (!file_table[ist->file_index].eof_reached){
if(ipts < ipts_min) {
ipts_min = ipts;
if(input_sync ) file_index = ist->file_index;
}
if(opts < opts_min) {
opts_min = opts;
if(!input_sync) file_index = ist->file_index;
}
}
if(ost->frame_number >= max_frames[ost->st->codec->codec_type]){
file_index= -1;
break;
}
}
/* if none, if is finished */
if (file_index < 0) {
if(no_packet_count){
no_packet_count=0;
memset(no_packet, 0, sizeof(no_packet));
usleep(10000);
continue;
}
break;
}
/* finish if limit size exhausted */
if (limit_filesize != 0 && limit_filesize <= avio_tell(output_files[0]->pb))
break;
/* read a frame from it and output it in the fifo */
is = input_files[file_index];
ret= av_read_frame(is, &pkt);
if(ret == AVERROR(EAGAIN)){
no_packet[file_index]=1;
no_packet_count++;
continue;
}
if (ret < 0) {
file_table[file_index].eof_reached = 1;
if (opt_shortest)
break;
else
continue;
}
no_packet_count=0;
memset(no_packet, 0, sizeof(no_packet));
if (do_pkt_dump) {
av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump,
is->streams[pkt.stream_index]);
}
/* the following test is needed in case new streams appear
dynamically in stream : we ignore them */
if (pkt.stream_index >= file_table[file_index].nb_streams)
goto discard_packet;
ist_index = file_table[file_index].ist_index + pkt.stream_index;
ist = ist_table[ist_index];
if (ist->discard)
goto discard_packet;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts += av_rescale_q(input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts += av_rescale_q(input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.stream_index < nb_input_files_ts_scale[file_index]
&& input_files_ts_scale[file_index][pkt.stream_index]){
if(pkt.pts != AV_NOPTS_VALUE)
pkt.pts *= input_files_ts_scale[file_index][pkt.stream_index];
if(pkt.dts != AV_NOPTS_VALUE)
pkt.dts *= input_files_ts_scale[file_index][pkt.stream_index];
}
// fprintf(stderr, "next:%"PRId64" dts:%"PRId64" off:%"PRId64" %d\n", ist->next_pts, pkt.dts, input_files_ts_offset[ist->file_index], ist->st->codec->codec_type);
if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE
&& (is->iformat->flags & AVFMT_TS_DISCONT)) {
int64_t pkt_dts= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);
int64_t delta= pkt_dts - ist->next_pts;
if((FFABS(delta) > 1LL*dts_delta_threshold*AV_TIME_BASE || pkt_dts+1<ist->pts)&& !copy_ts){
input_files_ts_offset[ist->file_index]-= delta;
if (verbose > 2)
fprintf(stderr, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", delta, input_files_ts_offset[ist->file_index]);
pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
if(pkt.pts != AV_NOPTS_VALUE)
pkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
}
}
/* finish if recording time exhausted */
if (recording_time != INT64_MAX &&
av_compare_ts(pkt.pts, ist->st->time_base, recording_time + start_time, (AVRational){1, 1000000}) >= 0) {
ist->is_past_recording_time = 1;
goto discard_packet;
}
//fprintf(stderr,"read #%d.%d size=%d\n", ist->file_index, ist->index, pkt.size);
if (output_packet(ist, ist_index, ost_table, nb_ostreams, &pkt) < 0) {
if (verbose >= 0)
fprintf(stderr, "Error while decoding stream #%d.%d\n",
ist->file_index, ist->index);
if (exit_on_error)
ffmpeg_exit(1);
av_free_packet(&pkt);
goto redo;
}
discard_packet:
av_free_packet(&pkt);
/* dump report by using the output first video and audio streams */
print_report(output_files, ost_table, nb_ostreams, 0);
}
/* at the end of stream, we must flush the decoder buffers */
for(i=0;i<nb_istreams;i++) {
ist = ist_table[i];
if (ist->decoding_needed) {
output_packet(ist, i, ost_table, nb_ostreams, NULL);
}
}
term_exit();
/* write the trailer if needed and close file */
for(i=0;i<nb_output_files;i++) {
os = output_files[i];
av_write_trailer(os);
}
/* dump report by using the first video and audio streams */
print_report(output_files, ost_table, nb_ostreams, 1);
/* close each encoder */
for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i];
if (ost->encoding_needed) {
av_freep(&ost->st->codec->stats_in);
avcodec_close(ost->st->codec);
}
#if CONFIG_AVFILTER
avfilter_graph_free(&ost->graph);
#endif
}
/* close each decoder */
for(i=0;i<nb_istreams;i++) {
ist = ist_table[i];
if (ist->decoding_needed) {
avcodec_close(ist->st->codec);
}
}
/* finished ! */
ret = 0;
fail:
av_freep(&bit_buffer);
av_free(file_table);
if (ist_table) {
for(i=0;i<nb_istreams;i++) {
ist = ist_table[i];
av_free(ist);
}
av_free(ist_table);
}
if (ost_table) {
for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i];
if (ost) {
if (ost->st->stream_copy)
av_freep(&ost->st->codec->extradata);
if (ost->logfile) {
fclose(ost->logfile);
ost->logfile = NULL;
}
av_fifo_free(ost->fifo); /* works even if fifo is not
initialized but set to zero */
av_freep(&ost->st->codec->subtitle_header);
av_free(ost->pict_tmp.data[0]);
av_free(ost->forced_kf_pts);
if (ost->video_resample)
sws_freeContext(ost->img_resample_ctx);
if (ost->resample)
audio_resample_close(ost->resample);
if (ost->reformat_ctx)
av_audio_convert_free(ost->reformat_ctx);
av_free(ost);
}
}
av_free(ost_table);
}
return ret;
}
| false | FFmpeg | f5a669c229425cdac828c230addf10d6d9cbe3a7 | static int transcode(AVFormatContext **output_files,
int nb_output_files,
AVFormatContext **input_files,
int nb_input_files,
AVStreamMap *stream_maps, int nb_stream_maps)
{
int ret = 0, i, j, k, n, nb_istreams = 0, nb_ostreams = 0, step;
AVFormatContext *is, *os;
AVCodecContext *codec, *icodec;
AVOutputStream *ost, **ost_table = NULL;
AVInputStream *ist, **ist_table = NULL;
AVInputFile *file_table;
char error[1024];
int key;
int want_sdp = 1;
uint8_t no_packet[MAX_FILES]={0};
int no_packet_count=0;
int nb_frame_threshold[AVMEDIA_TYPE_NB]={0};
int nb_streams[AVMEDIA_TYPE_NB]={0};
file_table= av_mallocz(nb_input_files * sizeof(AVInputFile));
if (!file_table)
goto fail;
j = 0;
for(i=0;i<nb_input_files;i++) {
is = input_files[i];
file_table[i].ist_index = j;
file_table[i].nb_streams = is->nb_streams;
j += is->nb_streams;
}
nb_istreams = j;
ist_table = av_mallocz(nb_istreams * sizeof(AVInputStream *));
if (!ist_table)
goto fail;
for(i=0;i<nb_istreams;i++) {
ist = av_mallocz(sizeof(AVInputStream));
if (!ist)
goto fail;
ist_table[i] = ist;
}
j = 0;
for(i=0;i<nb_input_files;i++) {
is = input_files[i];
for(k=0;k<is->nb_streams;k++) {
ist = ist_table[j++];
ist->st = is->streams[k];
ist->file_index = i;
ist->index = k;
ist->discard = 1;
if (rate_emu) {
ist->start = av_gettime();
}
}
}
nb_ostreams = 0;
for(i=0;i<nb_output_files;i++) {
os = output_files[i];
if (!os->nb_streams && !(os->oformat->flags & AVFMT_NOSTREAMS)) {
av_dump_format(output_files[i], i, output_files[i]->filename, 1);
fprintf(stderr, "Output file #%d does not contain any stream\n", i);
ret = AVERROR(EINVAL);
goto fail;
}
nb_ostreams += os->nb_streams;
}
if (nb_stream_maps > 0 && nb_stream_maps != nb_ostreams) {
fprintf(stderr, "Number of stream maps must match number of output streams\n");
ret = AVERROR(EINVAL);
goto fail;
}
for(i=0;i<nb_stream_maps;i++) {
int fi = stream_maps[i].file_index;
int si = stream_maps[i].stream_index;
if (fi < 0 || fi > nb_input_files - 1 ||
si < 0 || si > file_table[fi].nb_streams - 1) {
fprintf(stderr,"Could not find input stream #%d.%d\n", fi, si);
ret = AVERROR(EINVAL);
goto fail;
}
fi = stream_maps[i].sync_file_index;
si = stream_maps[i].sync_stream_index;
if (fi < 0 || fi > nb_input_files - 1 ||
si < 0 || si > file_table[fi].nb_streams - 1) {
fprintf(stderr,"Could not find sync stream #%d.%d\n", fi, si);
ret = AVERROR(EINVAL);
goto fail;
}
}
ost_table = av_mallocz(sizeof(AVOutputStream *) * nb_ostreams);
if (!ost_table)
goto fail;
for(k=0;k<nb_output_files;k++) {
os = output_files[k];
for(i=0;i<os->nb_streams;i++,n++) {
nb_streams[os->streams[i]->codec->codec_type]++;
}
}
for(step=1<<30; step; step>>=1){
int found_streams[AVMEDIA_TYPE_NB]={0};
for(j=0; j<AVMEDIA_TYPE_NB; j++)
nb_frame_threshold[j] += step;
for(j=0; j<nb_istreams; j++) {
int skip=0;
ist = ist_table[j];
if(opt_programid){
int pi,si;
AVFormatContext *f= input_files[ ist->file_index ];
skip=1;
for(pi=0; pi<f->nb_programs; pi++){
AVProgram *p= f->programs[pi];
if(p->id == opt_programid)
for(si=0; si<p->nb_stream_indexes; si++){
if(f->streams[ p->stream_index[si] ] == ist->st)
skip=0;
}
}
}
if (ist->discard && ist->st->discard != AVDISCARD_ALL && !skip
&& nb_frame_threshold[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames){
found_streams[ist->st->codec->codec_type]++;
}
}
for(j=0; j<AVMEDIA_TYPE_NB; j++)
if(found_streams[j] < nb_streams[j])
nb_frame_threshold[j] -= step;
}
n = 0;
for(k=0;k<nb_output_files;k++) {
os = output_files[k];
for(i=0;i<os->nb_streams;i++,n++) {
int found;
ost = ost_table[n] = output_streams_for_file[k][i];
ost->st = os->streams[i];
if (nb_stream_maps > 0) {
ost->source_index = file_table[stream_maps[n].file_index].ist_index +
stream_maps[n].stream_index;
if (ist_table[ost->source_index]->st->codec->codec_type != ost->st->codec->codec_type) {
int i= ost->file_index;
av_dump_format(output_files[i], i, output_files[i]->filename, 1);
fprintf(stderr, "Codec type mismatch for mapping #%d.%d -> #%d.%d\n",
stream_maps[n].file_index, stream_maps[n].stream_index,
ost->file_index, ost->index);
ffmpeg_exit(1);
}
} else {
found = 0;
for(j=0;j<nb_istreams;j++) {
int skip=0;
ist = ist_table[j];
if(opt_programid){
int pi,si;
AVFormatContext *f= input_files[ ist->file_index ];
skip=1;
for(pi=0; pi<f->nb_programs; pi++){
AVProgram *p= f->programs[pi];
if(p->id == opt_programid)
for(si=0; si<p->nb_stream_indexes; si++){
if(f->streams[ p->stream_index[si] ] == ist->st)
skip=0;
}
}
}
if (ist->discard && ist->st->discard != AVDISCARD_ALL && !skip &&
ist->st->codec->codec_type == ost->st->codec->codec_type &&
nb_frame_threshold[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames) {
ost->source_index = j;
found = 1;
break;
}
}
if (!found) {
if(! opt_programid) {
for(j=0;j<nb_istreams;j++) {
ist = ist_table[j];
if ( ist->st->codec->codec_type == ost->st->codec->codec_type
&& ist->st->discard != AVDISCARD_ALL) {
ost->source_index = j;
found = 1;
}
}
}
if (!found) {
int i= ost->file_index;
av_dump_format(output_files[i], i, output_files[i]->filename, 1);
fprintf(stderr, "Could not find input stream matching output stream #%d.%d\n",
ost->file_index, ost->index);
ffmpeg_exit(1);
}
}
}
ist = ist_table[ost->source_index];
ist->discard = 0;
ost->sync_ist = (nb_stream_maps > 0) ?
ist_table[file_table[stream_maps[n].sync_file_index].ist_index +
stream_maps[n].sync_stream_index] : ist;
}
}
for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i];
os = output_files[ost->file_index];
ist = ist_table[ost->source_index];
codec = ost->st->codec;
icodec = ist->st->codec;
if (metadata_streams_autocopy)
av_metadata_copy(&ost->st->metadata, ist->st->metadata,
AV_METADATA_DONT_OVERWRITE);
ost->st->disposition = ist->st->disposition;
codec->bits_per_raw_sample= icodec->bits_per_raw_sample;
codec->chroma_sample_location = icodec->chroma_sample_location;
if (ost->st->stream_copy) {
uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE;
if (extra_size > INT_MAX)
goto fail;
codec->codec_id = icodec->codec_id;
codec->codec_type = icodec->codec_type;
if(!codec->codec_tag){
if( !os->oformat->codec_tag
|| av_codec_get_id (os->oformat->codec_tag, icodec->codec_tag) == codec->codec_id
|| av_codec_get_tag(os->oformat->codec_tag, icodec->codec_id) <= 0)
codec->codec_tag = icodec->codec_tag;
}
codec->bit_rate = icodec->bit_rate;
codec->rc_max_rate = icodec->rc_max_rate;
codec->rc_buffer_size = icodec->rc_buffer_size;
codec->extradata= av_mallocz(extra_size);
if (!codec->extradata)
goto fail;
memcpy(codec->extradata, icodec->extradata, icodec->extradata_size);
codec->extradata_size= icodec->extradata_size;
if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){
codec->time_base = icodec->time_base;
codec->time_base.num *= icodec->ticks_per_frame;
av_reduce(&codec->time_base.num, &codec->time_base.den,
codec->time_base.num, codec->time_base.den, INT_MAX);
}else
codec->time_base = ist->st->time_base;
switch(codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
if(audio_volume != 256) {
fprintf(stderr,"-acodec copy and -vol are incompatible (frames are not decoded)\n");
ffmpeg_exit(1);
}
codec->channel_layout = icodec->channel_layout;
codec->sample_rate = icodec->sample_rate;
codec->channels = icodec->channels;
codec->frame_size = icodec->frame_size;
codec->audio_service_type = icodec->audio_service_type;
codec->block_align= icodec->block_align;
if(codec->block_align == 1 && codec->codec_id == CODEC_ID_MP3)
codec->block_align= 0;
if(codec->codec_id == CODEC_ID_AC3)
codec->block_align= 0;
break;
case AVMEDIA_TYPE_VIDEO:
codec->pix_fmt = icodec->pix_fmt;
codec->width = icodec->width;
codec->height = icodec->height;
codec->has_b_frames = icodec->has_b_frames;
if (!codec->sample_aspect_ratio.num) {
codec->sample_aspect_ratio =
ost->st->sample_aspect_ratio =
ist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio :
ist->st->codec->sample_aspect_ratio.num ?
ist->st->codec->sample_aspect_ratio : (AVRational){0, 1};
}
break;
case AVMEDIA_TYPE_SUBTITLE:
codec->width = icodec->width;
codec->height = icodec->height;
break;
case AVMEDIA_TYPE_DATA:
break;
default:
abort();
}
} else {
switch(codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
ost->fifo= av_fifo_alloc(1024);
if(!ost->fifo)
goto fail;
ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE);
ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1;
icodec->request_channels = codec->channels;
ist->decoding_needed = 1;
ost->encoding_needed = 1;
ost->resample_sample_fmt = icodec->sample_fmt;
ost->resample_sample_rate = icodec->sample_rate;
ost->resample_channels = icodec->channels;
break;
case AVMEDIA_TYPE_VIDEO:
if (ost->st->codec->pix_fmt == PIX_FMT_NONE) {
fprintf(stderr, "Video pixel format is unknown, stream cannot be encoded\n");
ffmpeg_exit(1);
}
ost->video_resample = codec->width != icodec->width ||
codec->height != icodec->height ||
codec->pix_fmt != icodec->pix_fmt;
if (ost->video_resample) {
#if !CONFIG_AVFILTER
avcodec_get_frame_defaults(&ost->pict_tmp);
if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fmt,
codec->width, codec->height)) {
fprintf(stderr, "Cannot allocate temp picture, check pix fmt\n");
ffmpeg_exit(1);
}
sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
ost->img_resample_ctx = sws_getContext(
icodec->width,
icodec->height,
icodec->pix_fmt,
codec->width,
codec->height,
codec->pix_fmt,
sws_flags, NULL, NULL, NULL);
if (ost->img_resample_ctx == NULL) {
fprintf(stderr, "Cannot get resampling context\n");
ffmpeg_exit(1);
}
#endif
codec->bits_per_raw_sample= frame_bits_per_raw_sample;
}
ost->resample_height = icodec->height;
ost->resample_width = icodec->width;
ost->resample_pix_fmt= icodec->pix_fmt;
ost->encoding_needed = 1;
ist->decoding_needed = 1;
#if CONFIG_AVFILTER
if (configure_video_filters(ist, ost)) {
fprintf(stderr, "Error opening filters!\n");
exit(1);
}
#endif
break;
case AVMEDIA_TYPE_SUBTITLE:
ost->encoding_needed = 1;
ist->decoding_needed = 1;
break;
default:
abort();
break;
}
if (ost->encoding_needed && codec->codec_id != CODEC_ID_H264 &&
(codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) {
char logfilename[1024];
FILE *f;
snprintf(logfilename, sizeof(logfilename), "%s-%d.log",
pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX,
i);
if (codec->flags & CODEC_FLAG_PASS1) {
f = fopen(logfilename, "wb");
if (!f) {
fprintf(stderr, "Cannot write log file '%s' for pass-1 encoding: %s\n", logfilename, strerror(errno));
ffmpeg_exit(1);
}
ost->logfile = f;
} else {
char *logbuffer;
size_t logbuffer_size;
if (read_file(logfilename, &logbuffer, &logbuffer_size) < 0) {
fprintf(stderr, "Error reading log file '%s' for pass-2 encoding\n", logfilename);
ffmpeg_exit(1);
}
codec->stats_in = logbuffer;
}
}
}
if(codec->codec_type == AVMEDIA_TYPE_VIDEO){
int size= codec->width * codec->height;
bit_buffer_size= FFMAX(bit_buffer_size, 6*size + 1664);
}
}
if (!bit_buffer)
bit_buffer = av_malloc(bit_buffer_size);
if (!bit_buffer) {
fprintf(stderr, "Cannot allocate %d bytes output buffer\n",
bit_buffer_size);
ret = AVERROR(ENOMEM);
goto fail;
}
for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i];
if (ost->encoding_needed) {
AVCodec *codec = i < nb_output_codecs ? output_codecs[i] : NULL;
AVCodecContext *dec = ist_table[ost->source_index]->st->codec;
if (!codec)
codec = avcodec_find_encoder(ost->st->codec->codec_id);
if (!codec) {
snprintf(error, sizeof(error), "Encoder (codec id %d) not found for output stream #%d.%d",
ost->st->codec->codec_id, ost->file_index, ost->index);
ret = AVERROR(EINVAL);
goto dump_format;
}
if (dec->subtitle_header) {
ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size);
if (!ost->st->codec->subtitle_header) {
ret = AVERROR(ENOMEM);
goto dump_format;
}
memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size);
ost->st->codec->subtitle_header_size = dec->subtitle_header_size;
}
if (avcodec_open(ost->st->codec, codec) < 0) {
snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height",
ost->file_index, ost->index);
ret = AVERROR(EINVAL);
goto dump_format;
}
extra_size += ost->st->codec->extradata_size;
}
}
for(i=0;i<nb_istreams;i++) {
ist = ist_table[i];
if (ist->decoding_needed) {
AVCodec *codec = i < nb_input_codecs ? input_codecs[i] : NULL;
if (!codec)
codec = avcodec_find_decoder(ist->st->codec->codec_id);
if (!codec) {
snprintf(error, sizeof(error), "Decoder (codec id %d) not found for input stream #%d.%d",
ist->st->codec->codec_id, ist->file_index, ist->index);
ret = AVERROR(EINVAL);
goto dump_format;
}
if (avcodec_open(ist->st->codec, codec) < 0) {
snprintf(error, sizeof(error), "Error while opening decoder for input stream #%d.%d",
ist->file_index, ist->index);
ret = AVERROR(EINVAL);
goto dump_format;
}
}
}
for(i=0;i<nb_istreams;i++) {
AVStream *st;
ist = ist_table[i];
st= ist->st;
ist->pts = st->avg_frame_rate.num ? - st->codec->has_b_frames*AV_TIME_BASE / av_q2d(st->avg_frame_rate) : 0;
ist->next_pts = AV_NOPTS_VALUE;
ist->is_start = 1;
}
for (i=0;i<nb_meta_data_maps;i++) {
AVFormatContext *files[2];
AVMetadata **meta[2];
int j;
#define METADATA_CHECK_INDEX(index, nb_elems, desc)\
if ((index) < 0 || (index) >= (nb_elems)) {\
snprintf(error, sizeof(error), "Invalid %s index %d while processing metadata maps\n",\
(desc), (index));\
ret = AVERROR(EINVAL);\
goto dump_format;\
}
int out_file_index = meta_data_maps[i][0].file;
int in_file_index = meta_data_maps[i][1].file;
if (in_file_index < 0 || out_file_index < 0)
continue;
METADATA_CHECK_INDEX(out_file_index, nb_output_files, "output file")
METADATA_CHECK_INDEX(in_file_index, nb_input_files, "input file")
files[0] = output_files[out_file_index];
files[1] = input_files[in_file_index];
for (j = 0; j < 2; j++) {
AVMetaDataMap *map = &meta_data_maps[i][j];
switch (map->type) {
case 'g':
meta[j] = &files[j]->metadata;
break;
case 's':
METADATA_CHECK_INDEX(map->index, files[j]->nb_streams, "stream")
meta[j] = &files[j]->streams[map->index]->metadata;
break;
case 'c':
METADATA_CHECK_INDEX(map->index, files[j]->nb_chapters, "chapter")
meta[j] = &files[j]->chapters[map->index]->metadata;
break;
case 'p':
METADATA_CHECK_INDEX(map->index, files[j]->nb_programs, "program")
meta[j] = &files[j]->programs[map->index]->metadata;
break;
}
}
av_metadata_copy(meta[0], *meta[1], AV_METADATA_DONT_OVERWRITE);
}
if (metadata_global_autocopy) {
for (i = 0; i < nb_output_files; i++)
av_metadata_copy(&output_files[i]->metadata, input_files[0]->metadata,
AV_METADATA_DONT_OVERWRITE);
}
for (i = 0; i < nb_chapter_maps; i++) {
int infile = chapter_maps[i].in_file;
int outfile = chapter_maps[i].out_file;
if (infile < 0 || outfile < 0)
continue;
if (infile >= nb_input_files) {
snprintf(error, sizeof(error), "Invalid input file index %d in chapter mapping.\n", infile);
ret = AVERROR(EINVAL);
goto dump_format;
}
if (outfile >= nb_output_files) {
snprintf(error, sizeof(error), "Invalid output file index %d in chapter mapping.\n",outfile);
ret = AVERROR(EINVAL);
goto dump_format;
}
copy_chapters(infile, outfile);
}
if (!nb_chapter_maps)
for (i = 0; i < nb_input_files; i++) {
if (!input_files[i]->nb_chapters)
continue;
for (j = 0; j < nb_output_files; j++)
if ((ret = copy_chapters(i, j)) < 0)
goto dump_format;
break;
}
for(i=0;i<nb_output_files;i++) {
os = output_files[i];
if (av_write_header(os) < 0) {
snprintf(error, sizeof(error), "Could not write header for output file #%d (incorrect codec parameters ?)", i);
ret = AVERROR(EINVAL);
goto dump_format;
}
if (strcmp(output_files[i]->oformat->name, "rtp")) {
want_sdp = 0;
}
}
dump_format:
for(i=0;i<nb_output_files;i++) {
av_dump_format(output_files[i], i, output_files[i]->filename, 1);
}
if (verbose >= 0) {
fprintf(stderr, "Stream mapping:\n");
for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i];
fprintf(stderr, " Stream #%d.%d -> #%d.%d",
ist_table[ost->source_index]->file_index,
ist_table[ost->source_index]->index,
ost->file_index,
ost->index);
if (ost->sync_ist != ist_table[ost->source_index])
fprintf(stderr, " [sync #%d.%d]",
ost->sync_ist->file_index,
ost->sync_ist->index);
fprintf(stderr, "\n");
}
}
if (ret) {
fprintf(stderr, "%s\n", error);
goto fail;
}
if (want_sdp) {
print_sdp(output_files, nb_output_files);
}
if (!using_stdin) {
if(verbose >= 0)
fprintf(stderr, "Press [q] to stop encoding\n");
avio_set_interrupt_cb(decode_interrupt_cb);
}
term_init();
timer_start = av_gettime();
for(; received_sigterm == 0;) {
int file_index, ist_index;
AVPacket pkt;
double ipts_min;
double opts_min;
redo:
ipts_min= 1e100;
opts_min= 1e100;
if (!using_stdin) {
if (q_pressed)
break;
key = read_key();
if (key == 'q')
break;
}
file_index = -1;
for(i=0;i<nb_ostreams;i++) {
double ipts, opts;
ost = ost_table[i];
os = output_files[ost->file_index];
ist = ist_table[ost->source_index];
if(ist->is_past_recording_time || no_packet[ist->file_index])
continue;
opts = ost->st->pts.val * av_q2d(ost->st->time_base);
ipts = (double)ist->pts;
if (!file_table[ist->file_index].eof_reached){
if(ipts < ipts_min) {
ipts_min = ipts;
if(input_sync ) file_index = ist->file_index;
}
if(opts < opts_min) {
opts_min = opts;
if(!input_sync) file_index = ist->file_index;
}
}
if(ost->frame_number >= max_frames[ost->st->codec->codec_type]){
file_index= -1;
break;
}
}
if (file_index < 0) {
if(no_packet_count){
no_packet_count=0;
memset(no_packet, 0, sizeof(no_packet));
usleep(10000);
continue;
}
break;
}
if (limit_filesize != 0 && limit_filesize <= avio_tell(output_files[0]->pb))
break;
is = input_files[file_index];
ret= av_read_frame(is, &pkt);
if(ret == AVERROR(EAGAIN)){
no_packet[file_index]=1;
no_packet_count++;
continue;
}
if (ret < 0) {
file_table[file_index].eof_reached = 1;
if (opt_shortest)
break;
else
continue;
}
no_packet_count=0;
memset(no_packet, 0, sizeof(no_packet));
if (do_pkt_dump) {
av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump,
is->streams[pkt.stream_index]);
}
if (pkt.stream_index >= file_table[file_index].nb_streams)
goto discard_packet;
ist_index = file_table[file_index].ist_index + pkt.stream_index;
ist = ist_table[ist_index];
if (ist->discard)
goto discard_packet;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts += av_rescale_q(input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts += av_rescale_q(input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.stream_index < nb_input_files_ts_scale[file_index]
&& input_files_ts_scale[file_index][pkt.stream_index]){
if(pkt.pts != AV_NOPTS_VALUE)
pkt.pts *= input_files_ts_scale[file_index][pkt.stream_index];
if(pkt.dts != AV_NOPTS_VALUE)
pkt.dts *= input_files_ts_scale[file_index][pkt.stream_index];
}
if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE
&& (is->iformat->flags & AVFMT_TS_DISCONT)) {
int64_t pkt_dts= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);
int64_t delta= pkt_dts - ist->next_pts;
if((FFABS(delta) > 1LL*dts_delta_threshold*AV_TIME_BASE || pkt_dts+1<ist->pts)&& !copy_ts){
input_files_ts_offset[ist->file_index]-= delta;
if (verbose > 2)
fprintf(stderr, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", delta, input_files_ts_offset[ist->file_index]);
pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
if(pkt.pts != AV_NOPTS_VALUE)
pkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
}
}
if (recording_time != INT64_MAX &&
av_compare_ts(pkt.pts, ist->st->time_base, recording_time + start_time, (AVRational){1, 1000000}) >= 0) {
ist->is_past_recording_time = 1;
goto discard_packet;
}
if (output_packet(ist, ist_index, ost_table, nb_ostreams, &pkt) < 0) {
if (verbose >= 0)
fprintf(stderr, "Error while decoding stream #%d.%d\n",
ist->file_index, ist->index);
if (exit_on_error)
ffmpeg_exit(1);
av_free_packet(&pkt);
goto redo;
}
discard_packet:
av_free_packet(&pkt);
print_report(output_files, ost_table, nb_ostreams, 0);
}
for(i=0;i<nb_istreams;i++) {
ist = ist_table[i];
if (ist->decoding_needed) {
output_packet(ist, i, ost_table, nb_ostreams, NULL);
}
}
term_exit();
for(i=0;i<nb_output_files;i++) {
os = output_files[i];
av_write_trailer(os);
}
print_report(output_files, ost_table, nb_ostreams, 1);
for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i];
if (ost->encoding_needed) {
av_freep(&ost->st->codec->stats_in);
avcodec_close(ost->st->codec);
}
#if CONFIG_AVFILTER
avfilter_graph_free(&ost->graph);
#endif
}
for(i=0;i<nb_istreams;i++) {
ist = ist_table[i];
if (ist->decoding_needed) {
avcodec_close(ist->st->codec);
}
}
ret = 0;
fail:
av_freep(&bit_buffer);
av_free(file_table);
if (ist_table) {
for(i=0;i<nb_istreams;i++) {
ist = ist_table[i];
av_free(ist);
}
av_free(ist_table);
}
if (ost_table) {
for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i];
if (ost) {
if (ost->st->stream_copy)
av_freep(&ost->st->codec->extradata);
if (ost->logfile) {
fclose(ost->logfile);
ost->logfile = NULL;
}
av_fifo_free(ost->fifo);
av_freep(&ost->st->codec->subtitle_header);
av_free(ost->pict_tmp.data[0]);
av_free(ost->forced_kf_pts);
if (ost->video_resample)
sws_freeContext(ost->img_resample_ctx);
if (ost->resample)
audio_resample_close(ost->resample);
if (ost->reformat_ctx)
av_audio_convert_free(ost->reformat_ctx);
av_free(ost);
}
}
av_free(ost_table);
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext **VAR_0,
int VAR_1,
AVFormatContext **VAR_2,
int VAR_3,
AVStreamMap *VAR_4, int VAR_5)
{
int VAR_6 = 0, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11 = 0, VAR_12 = 0, VAR_13;
AVFormatContext *is, *os;
AVCodecContext *codec, *icodec;
AVOutputStream *ost, **ost_table = NULL;
AVInputStream *ist, **ist_table = NULL;
AVInputFile *file_table;
char VAR_14[1024];
int VAR_15;
int VAR_16 = 1;
uint8_t no_packet[MAX_FILES]={0};
int VAR_17=0;
int VAR_18[AVMEDIA_TYPE_NB]={0};
int VAR_19[AVMEDIA_TYPE_NB]={0};
file_table= av_mallocz(VAR_3 * sizeof(AVInputFile));
if (!file_table)
goto fail;
VAR_8 = 0;
for(VAR_7=0;VAR_7<VAR_3;VAR_7++) {
is = VAR_2[VAR_7];
file_table[VAR_7].ist_index = VAR_8;
file_table[VAR_7].VAR_19 = is->VAR_19;
VAR_8 += is->VAR_19;
}
VAR_11 = VAR_8;
ist_table = av_mallocz(VAR_11 * sizeof(AVInputStream *));
if (!ist_table)
goto fail;
for(VAR_7=0;VAR_7<VAR_11;VAR_7++) {
ist = av_mallocz(sizeof(AVInputStream));
if (!ist)
goto fail;
ist_table[VAR_7] = ist;
}
VAR_8 = 0;
for(VAR_7=0;VAR_7<VAR_3;VAR_7++) {
is = VAR_2[VAR_7];
for(VAR_9=0;VAR_9<is->VAR_19;VAR_9++) {
ist = ist_table[VAR_8++];
ist->st = is->streams[VAR_9];
ist->file_index = VAR_7;
ist->index = VAR_9;
ist->discard = 1;
if (rate_emu) {
ist->start = av_gettime();
}
}
}
VAR_12 = 0;
for(VAR_7=0;VAR_7<VAR_1;VAR_7++) {
os = VAR_0[VAR_7];
if (!os->VAR_19 && !(os->oformat->flags & AVFMT_NOSTREAMS)) {
av_dump_format(VAR_0[VAR_7], VAR_7, VAR_0[VAR_7]->filename, 1);
fprintf(stderr, "Output file #%d does not contain any stream\VAR_10", VAR_7);
VAR_6 = AVERROR(EINVAL);
goto fail;
}
VAR_12 += os->VAR_19;
}
if (VAR_5 > 0 && VAR_5 != VAR_12) {
fprintf(stderr, "Number of stream maps must match number of output streams\VAR_10");
VAR_6 = AVERROR(EINVAL);
goto fail;
}
for(VAR_7=0;VAR_7<VAR_5;VAR_7++) {
int VAR_20 = VAR_4[VAR_7].file_index;
int VAR_25 = VAR_4[VAR_7].stream_index;
if (VAR_20 < 0 || VAR_20 > VAR_3 - 1 ||
VAR_25 < 0 || VAR_25 > file_table[VAR_20].VAR_19 - 1) {
fprintf(stderr,"Could not find input stream #%d.%d\VAR_10", VAR_20, VAR_25);
VAR_6 = AVERROR(EINVAL);
goto fail;
}
VAR_20 = VAR_4[VAR_7].sync_file_index;
VAR_25 = VAR_4[VAR_7].sync_stream_index;
if (VAR_20 < 0 || VAR_20 > VAR_3 - 1 ||
VAR_25 < 0 || VAR_25 > file_table[VAR_20].VAR_19 - 1) {
fprintf(stderr,"Could not find sync stream #%d.%d\VAR_10", VAR_20, VAR_25);
VAR_6 = AVERROR(EINVAL);
goto fail;
}
}
ost_table = av_mallocz(sizeof(AVOutputStream *) * VAR_12);
if (!ost_table)
goto fail;
for(VAR_9=0;VAR_9<VAR_1;VAR_9++) {
os = VAR_0[VAR_9];
for(VAR_7=0;VAR_7<os->VAR_19;VAR_7++,VAR_10++) {
VAR_19[os->streams[VAR_7]->codec->codec_type]++;
}
}
for(VAR_13=1<<30; VAR_13; VAR_13>>=1){
int VAR_22[AVMEDIA_TYPE_NB]={0};
for(VAR_8=0; VAR_8<AVMEDIA_TYPE_NB; VAR_8++)
VAR_18[VAR_8] += VAR_13;
for(VAR_8=0; VAR_8<VAR_11; VAR_8++) {
int VAR_23=0;
ist = ist_table[VAR_8];
if(opt_programid){
int VAR_24,VAR_25;
AVFormatContext *f= VAR_2[ ist->file_index ];
VAR_23=1;
for(VAR_24=0; VAR_24<f->nb_programs; VAR_24++){
AVProgram *p= f->programs[VAR_24];
if(p->id == opt_programid)
for(VAR_25=0; VAR_25<p->nb_stream_indexes; VAR_25++){
if(f->streams[ p->stream_index[VAR_25] ] == ist->st)
VAR_23=0;
}
}
}
if (ist->discard && ist->st->discard != AVDISCARD_ALL && !VAR_23
&& VAR_18[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames){
VAR_22[ist->st->codec->codec_type]++;
}
}
for(VAR_8=0; VAR_8<AVMEDIA_TYPE_NB; VAR_8++)
if(VAR_22[VAR_8] < VAR_19[VAR_8])
VAR_18[VAR_8] -= VAR_13;
}
VAR_10 = 0;
for(VAR_9=0;VAR_9<VAR_1;VAR_9++) {
os = VAR_0[VAR_9];
for(VAR_7=0;VAR_7<os->VAR_19;VAR_7++,VAR_10++) {
int found;
ost = ost_table[VAR_10] = output_streams_for_file[VAR_9][VAR_7];
ost->st = os->streams[VAR_7];
if (VAR_5 > 0) {
ost->source_index = file_table[VAR_4[VAR_10].file_index].ist_index +
VAR_4[VAR_10].stream_index;
if (ist_table[ost->source_index]->st->codec->codec_type != ost->st->codec->codec_type) {
int VAR_7= ost->file_index;
av_dump_format(VAR_0[VAR_7], VAR_7, VAR_0[VAR_7]->filename, 1);
fprintf(stderr, "Codec type mismatch for mapping #%d.%d -> #%d.%d\VAR_10",
VAR_4[VAR_10].file_index, VAR_4[VAR_10].stream_index,
ost->file_index, ost->index);
ffmpeg_exit(1);
}
} else {
found = 0;
for(VAR_8=0;VAR_8<VAR_11;VAR_8++) {
int VAR_23=0;
ist = ist_table[VAR_8];
if(opt_programid){
int VAR_24,VAR_25;
AVFormatContext *f= VAR_2[ ist->file_index ];
VAR_23=1;
for(VAR_24=0; VAR_24<f->nb_programs; VAR_24++){
AVProgram *p= f->programs[VAR_24];
if(p->id == opt_programid)
for(VAR_25=0; VAR_25<p->nb_stream_indexes; VAR_25++){
if(f->streams[ p->stream_index[VAR_25] ] == ist->st)
VAR_23=0;
}
}
}
if (ist->discard && ist->st->discard != AVDISCARD_ALL && !VAR_23 &&
ist->st->codec->codec_type == ost->st->codec->codec_type &&
VAR_18[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames) {
ost->source_index = VAR_8;
found = 1;
break;
}
}
if (!found) {
if(! opt_programid) {
for(VAR_8=0;VAR_8<VAR_11;VAR_8++) {
ist = ist_table[VAR_8];
if ( ist->st->codec->codec_type == ost->st->codec->codec_type
&& ist->st->discard != AVDISCARD_ALL) {
ost->source_index = VAR_8;
found = 1;
}
}
}
if (!found) {
int VAR_7= ost->file_index;
av_dump_format(VAR_0[VAR_7], VAR_7, VAR_0[VAR_7]->filename, 1);
fprintf(stderr, "Could not find input stream matching output stream #%d.%d\VAR_10",
ost->file_index, ost->index);
ffmpeg_exit(1);
}
}
}
ist = ist_table[ost->source_index];
ist->discard = 0;
ost->sync_ist = (VAR_5 > 0) ?
ist_table[file_table[VAR_4[VAR_10].sync_file_index].ist_index +
VAR_4[VAR_10].sync_stream_index] : ist;
}
}
for(VAR_7=0;VAR_7<VAR_12;VAR_7++) {
ost = ost_table[VAR_7];
os = VAR_0[ost->file_index];
ist = ist_table[ost->source_index];
codec = ost->st->codec;
icodec = ist->st->codec;
if (metadata_streams_autocopy)
av_metadata_copy(&ost->st->metadata, ist->st->metadata,
AV_METADATA_DONT_OVERWRITE);
ost->st->disposition = ist->st->disposition;
codec->bits_per_raw_sample= icodec->bits_per_raw_sample;
codec->chroma_sample_location = icodec->chroma_sample_location;
if (ost->st->stream_copy) {
uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE;
if (extra_size > INT_MAX)
goto fail;
codec->codec_id = icodec->codec_id;
codec->codec_type = icodec->codec_type;
if(!codec->codec_tag){
if( !os->oformat->codec_tag
|| av_codec_get_id (os->oformat->codec_tag, icodec->codec_tag) == codec->codec_id
|| av_codec_get_tag(os->oformat->codec_tag, icodec->codec_id) <= 0)
codec->codec_tag = icodec->codec_tag;
}
codec->bit_rate = icodec->bit_rate;
codec->rc_max_rate = icodec->rc_max_rate;
codec->rc_buffer_size = icodec->rc_buffer_size;
codec->extradata= av_mallocz(extra_size);
if (!codec->extradata)
goto fail;
memcpy(codec->extradata, icodec->extradata, icodec->extradata_size);
codec->extradata_size= icodec->extradata_size;
if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){
codec->time_base = icodec->time_base;
codec->time_base.num *= icodec->ticks_per_frame;
av_reduce(&codec->time_base.num, &codec->time_base.den,
codec->time_base.num, codec->time_base.den, INT_MAX);
}else
codec->time_base = ist->st->time_base;
switch(codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
if(audio_volume != 256) {
fprintf(stderr,"-acodec copy and -vol are incompatible (frames are not decoded)\VAR_10");
ffmpeg_exit(1);
}
codec->channel_layout = icodec->channel_layout;
codec->sample_rate = icodec->sample_rate;
codec->channels = icodec->channels;
codec->frame_size = icodec->frame_size;
codec->audio_service_type = icodec->audio_service_type;
codec->block_align= icodec->block_align;
if(codec->block_align == 1 && codec->codec_id == CODEC_ID_MP3)
codec->block_align= 0;
if(codec->codec_id == CODEC_ID_AC3)
codec->block_align= 0;
break;
case AVMEDIA_TYPE_VIDEO:
codec->pix_fmt = icodec->pix_fmt;
codec->width = icodec->width;
codec->height = icodec->height;
codec->has_b_frames = icodec->has_b_frames;
if (!codec->sample_aspect_ratio.num) {
codec->sample_aspect_ratio =
ost->st->sample_aspect_ratio =
ist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio :
ist->st->codec->sample_aspect_ratio.num ?
ist->st->codec->sample_aspect_ratio : (AVRational){0, 1};
}
break;
case AVMEDIA_TYPE_SUBTITLE:
codec->width = icodec->width;
codec->height = icodec->height;
break;
case AVMEDIA_TYPE_DATA:
break;
default:
abort();
}
} else {
switch(codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
ost->fifo= av_fifo_alloc(1024);
if(!ost->fifo)
goto fail;
ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE);
ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1;
icodec->request_channels = codec->channels;
ist->decoding_needed = 1;
ost->encoding_needed = 1;
ost->resample_sample_fmt = icodec->sample_fmt;
ost->resample_sample_rate = icodec->sample_rate;
ost->resample_channels = icodec->channels;
break;
case AVMEDIA_TYPE_VIDEO:
if (ost->st->codec->pix_fmt == PIX_FMT_NONE) {
fprintf(stderr, "Video pixel format is unknown, stream cannot be encoded\VAR_10");
ffmpeg_exit(1);
}
ost->video_resample = codec->width != icodec->width ||
codec->height != icodec->height ||
codec->pix_fmt != icodec->pix_fmt;
if (ost->video_resample) {
#if !CONFIG_AVFILTER
avcodec_get_frame_defaults(&ost->pict_tmp);
if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fmt,
codec->width, codec->height)) {
fprintf(stderr, "Cannot allocate temp picture, check pix fmt\VAR_10");
ffmpeg_exit(1);
}
sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
ost->img_resample_ctx = sws_getContext(
icodec->width,
icodec->height,
icodec->pix_fmt,
codec->width,
codec->height,
codec->pix_fmt,
sws_flags, NULL, NULL, NULL);
if (ost->img_resample_ctx == NULL) {
fprintf(stderr, "Cannot get resampling context\VAR_10");
ffmpeg_exit(1);
}
#endif
codec->bits_per_raw_sample= frame_bits_per_raw_sample;
}
ost->resample_height = icodec->height;
ost->resample_width = icodec->width;
ost->resample_pix_fmt= icodec->pix_fmt;
ost->encoding_needed = 1;
ist->decoding_needed = 1;
#if CONFIG_AVFILTER
if (configure_video_filters(ist, ost)) {
fprintf(stderr, "Error opening filters!\VAR_10");
exit(1);
}
#endif
break;
case AVMEDIA_TYPE_SUBTITLE:
ost->encoding_needed = 1;
ist->decoding_needed = 1;
break;
default:
abort();
break;
}
if (ost->encoding_needed && codec->codec_id != CODEC_ID_H264 &&
(codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) {
char VAR_25[1024];
FILE *f;
snprintf(VAR_25, sizeof(VAR_25), "%s-%d.log",
pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX,
VAR_7);
if (codec->flags & CODEC_FLAG_PASS1) {
f = fopen(VAR_25, "wb");
if (!f) {
fprintf(stderr, "Cannot write log file '%s' for pass-1 encoding: %s\VAR_10", VAR_25, strerror(errno));
ffmpeg_exit(1);
}
ost->logfile = f;
} else {
char *VAR_26;
size_t logbuffer_size;
if (read_file(VAR_25, &VAR_26, &logbuffer_size) < 0) {
fprintf(stderr, "Error reading log file '%s' for pass-2 encoding\VAR_10", VAR_25);
ffmpeg_exit(1);
}
codec->stats_in = VAR_26;
}
}
}
if(codec->codec_type == AVMEDIA_TYPE_VIDEO){
int VAR_27= codec->width * codec->height;
bit_buffer_size= FFMAX(bit_buffer_size, 6*VAR_27 + 1664);
}
}
if (!bit_buffer)
bit_buffer = av_malloc(bit_buffer_size);
if (!bit_buffer) {
fprintf(stderr, "Cannot allocate %d bytes output buffer\VAR_10",
bit_buffer_size);
VAR_6 = AVERROR(ENOMEM);
goto fail;
}
for(VAR_7=0;VAR_7<VAR_12;VAR_7++) {
ost = ost_table[VAR_7];
if (ost->encoding_needed) {
AVCodec *codec = VAR_7 < nb_output_codecs ? output_codecs[VAR_7] : NULL;
AVCodecContext *dec = ist_table[ost->source_index]->st->codec;
if (!codec)
codec = avcodec_find_encoder(ost->st->codec->codec_id);
if (!codec) {
snprintf(VAR_14, sizeof(VAR_14), "Encoder (codec id %d) not found for output stream #%d.%d",
ost->st->codec->codec_id, ost->file_index, ost->index);
VAR_6 = AVERROR(EINVAL);
goto dump_format;
}
if (dec->subtitle_header) {
ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size);
if (!ost->st->codec->subtitle_header) {
VAR_6 = AVERROR(ENOMEM);
goto dump_format;
}
memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size);
ost->st->codec->subtitle_header_size = dec->subtitle_header_size;
}
if (avcodec_open(ost->st->codec, codec) < 0) {
snprintf(VAR_14, sizeof(VAR_14), "Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height",
ost->file_index, ost->index);
VAR_6 = AVERROR(EINVAL);
goto dump_format;
}
extra_size += ost->st->codec->extradata_size;
}
}
for(VAR_7=0;VAR_7<VAR_11;VAR_7++) {
ist = ist_table[VAR_7];
if (ist->decoding_needed) {
AVCodec *codec = VAR_7 < nb_input_codecs ? input_codecs[VAR_7] : NULL;
if (!codec)
codec = avcodec_find_decoder(ist->st->codec->codec_id);
if (!codec) {
snprintf(VAR_14, sizeof(VAR_14), "Decoder (codec id %d) not found for input stream #%d.%d",
ist->st->codec->codec_id, ist->file_index, ist->index);
VAR_6 = AVERROR(EINVAL);
goto dump_format;
}
if (avcodec_open(ist->st->codec, codec) < 0) {
snprintf(VAR_14, sizeof(VAR_14), "Error while opening decoder for input stream #%d.%d",
ist->file_index, ist->index);
VAR_6 = AVERROR(EINVAL);
goto dump_format;
}
}
}
for(VAR_7=0;VAR_7<VAR_11;VAR_7++) {
AVStream *st;
ist = ist_table[VAR_7];
st= ist->st;
ist->pts = st->avg_frame_rate.num ? - st->codec->has_b_frames*AV_TIME_BASE / av_q2d(st->avg_frame_rate) : 0;
ist->next_pts = AV_NOPTS_VALUE;
ist->is_start = 1;
}
for (VAR_7=0;VAR_7<nb_meta_data_maps;VAR_7++) {
AVFormatContext *files[2];
AVMetadata **meta[2];
int VAR_8;
#define METADATA_CHECK_INDEX(index, nb_elems, desc)\
if ((index) < 0 || (index) >= (nb_elems)) {\
snprintf(VAR_14, sizeof(VAR_14), "Invalid %s index %d while processing metadata maps\VAR_10",\
(desc), (index));\
VAR_6 = AVERROR(EINVAL);\
goto dump_format;\
}
int out_file_index = meta_data_maps[VAR_7][0].file;
int in_file_index = meta_data_maps[VAR_7][1].file;
if (in_file_index < 0 || out_file_index < 0)
continue;
METADATA_CHECK_INDEX(out_file_index, VAR_1, "output file")
METADATA_CHECK_INDEX(in_file_index, VAR_3, "input file")
files[0] = VAR_0[out_file_index];
files[1] = VAR_2[in_file_index];
for (VAR_8 = 0; VAR_8 < 2; VAR_8++) {
AVMetaDataMap *map = &meta_data_maps[VAR_7][VAR_8];
switch (map->type) {
case 'g':
meta[VAR_8] = &files[VAR_8]->metadata;
break;
case 's':
METADATA_CHECK_INDEX(map->index, files[VAR_8]->VAR_19, "stream")
meta[VAR_8] = &files[VAR_8]->streams[map->index]->metadata;
break;
case 'c':
METADATA_CHECK_INDEX(map->index, files[VAR_8]->nb_chapters, "chapter")
meta[VAR_8] = &files[VAR_8]->chapters[map->index]->metadata;
break;
case 'p':
METADATA_CHECK_INDEX(map->index, files[VAR_8]->nb_programs, "program")
meta[VAR_8] = &files[VAR_8]->programs[map->index]->metadata;
break;
}
}
av_metadata_copy(meta[0], *meta[1], AV_METADATA_DONT_OVERWRITE);
}
if (metadata_global_autocopy) {
for (VAR_7 = 0; VAR_7 < VAR_1; VAR_7++)
av_metadata_copy(&VAR_0[VAR_7]->metadata, VAR_2[0]->metadata,
AV_METADATA_DONT_OVERWRITE);
}
for (VAR_7 = 0; VAR_7 < nb_chapter_maps; VAR_7++) {
int infile = chapter_maps[VAR_7].in_file;
int outfile = chapter_maps[VAR_7].out_file;
if (infile < 0 || outfile < 0)
continue;
if (infile >= VAR_3) {
snprintf(VAR_14, sizeof(VAR_14), "Invalid input file index %d in chapter mapping.\VAR_10", infile);
VAR_6 = AVERROR(EINVAL);
goto dump_format;
}
if (outfile >= VAR_1) {
snprintf(VAR_14, sizeof(VAR_14), "Invalid output file index %d in chapter mapping.\VAR_10",outfile);
VAR_6 = AVERROR(EINVAL);
goto dump_format;
}
copy_chapters(infile, outfile);
}
if (!nb_chapter_maps)
for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) {
if (!VAR_2[VAR_7]->nb_chapters)
continue;
for (VAR_8 = 0; VAR_8 < VAR_1; VAR_8++)
if ((VAR_6 = copy_chapters(VAR_7, VAR_8)) < 0)
goto dump_format;
break;
}
for(VAR_7=0;VAR_7<VAR_1;VAR_7++) {
os = VAR_0[VAR_7];
if (av_write_header(os) < 0) {
snprintf(VAR_14, sizeof(VAR_14), "Could not write header for output file #%d (incorrect codec parameters ?)", VAR_7);
VAR_6 = AVERROR(EINVAL);
goto dump_format;
}
if (strcmp(VAR_0[VAR_7]->oformat->name, "rtp")) {
VAR_16 = 0;
}
}
dump_format:
for(VAR_7=0;VAR_7<VAR_1;VAR_7++) {
av_dump_format(VAR_0[VAR_7], VAR_7, VAR_0[VAR_7]->filename, 1);
}
if (verbose >= 0) {
fprintf(stderr, "Stream mapping:\VAR_10");
for(VAR_7=0;VAR_7<VAR_12;VAR_7++) {
ost = ost_table[VAR_7];
fprintf(stderr, " Stream #%d.%d -> #%d.%d",
ist_table[ost->source_index]->file_index,
ist_table[ost->source_index]->index,
ost->file_index,
ost->index);
if (ost->sync_ist != ist_table[ost->source_index])
fprintf(stderr, " [sync #%d.%d]",
ost->sync_ist->file_index,
ost->sync_ist->index);
fprintf(stderr, "\VAR_10");
}
}
if (VAR_6) {
fprintf(stderr, "%s\VAR_10", VAR_14);
goto fail;
}
if (VAR_16) {
print_sdp(VAR_0, VAR_1);
}
if (!using_stdin) {
if(verbose >= 0)
fprintf(stderr, "Press [q] to stop encoding\VAR_10");
avio_set_interrupt_cb(decode_interrupt_cb);
}
term_init();
timer_start = av_gettime();
for(; received_sigterm == 0;) {
int file_index, ist_index;
AVPacket pkt;
double ipts_min;
double opts_min;
redo:
ipts_min= 1e100;
opts_min= 1e100;
if (!using_stdin) {
if (q_pressed)
break;
VAR_15 = read_key();
if (VAR_15 == 'q')
break;
}
file_index = -1;
for(VAR_7=0;VAR_7<VAR_12;VAR_7++) {
double ipts, opts;
ost = ost_table[VAR_7];
os = VAR_0[ost->file_index];
ist = ist_table[ost->source_index];
if(ist->is_past_recording_time || no_packet[ist->file_index])
continue;
opts = ost->st->pts.val * av_q2d(ost->st->time_base);
ipts = (double)ist->pts;
if (!file_table[ist->file_index].eof_reached){
if(ipts < ipts_min) {
ipts_min = ipts;
if(input_sync ) file_index = ist->file_index;
}
if(opts < opts_min) {
opts_min = opts;
if(!input_sync) file_index = ist->file_index;
}
}
if(ost->frame_number >= max_frames[ost->st->codec->codec_type]){
file_index= -1;
break;
}
}
if (file_index < 0) {
if(VAR_17){
VAR_17=0;
memset(no_packet, 0, sizeof(no_packet));
usleep(10000);
continue;
}
break;
}
if (limit_filesize != 0 && limit_filesize <= avio_tell(VAR_0[0]->pb))
break;
is = VAR_2[file_index];
VAR_6= av_read_frame(is, &pkt);
if(VAR_6 == AVERROR(EAGAIN)){
no_packet[file_index]=1;
VAR_17++;
continue;
}
if (VAR_6 < 0) {
file_table[file_index].eof_reached = 1;
if (opt_shortest)
break;
else
continue;
}
VAR_17=0;
memset(no_packet, 0, sizeof(no_packet));
if (do_pkt_dump) {
av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump,
is->streams[pkt.stream_index]);
}
if (pkt.stream_index >= file_table[file_index].VAR_19)
goto discard_packet;
ist_index = file_table[file_index].ist_index + pkt.stream_index;
ist = ist_table[ist_index];
if (ist->discard)
goto discard_packet;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts += av_rescale_q(input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts += av_rescale_q(input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.stream_index < nb_input_files_ts_scale[file_index]
&& input_files_ts_scale[file_index][pkt.stream_index]){
if(pkt.pts != AV_NOPTS_VALUE)
pkt.pts *= input_files_ts_scale[file_index][pkt.stream_index];
if(pkt.dts != AV_NOPTS_VALUE)
pkt.dts *= input_files_ts_scale[file_index][pkt.stream_index];
}
if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE
&& (is->iformat->flags & AVFMT_TS_DISCONT)) {
int64_t pkt_dts= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);
int64_t delta= pkt_dts - ist->next_pts;
if((FFABS(delta) > 1LL*dts_delta_threshold*AV_TIME_BASE || pkt_dts+1<ist->pts)&& !copy_ts){
input_files_ts_offset[ist->file_index]-= delta;
if (verbose > 2)
fprintf(stderr, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\VAR_10", delta, input_files_ts_offset[ist->file_index]);
pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
if(pkt.pts != AV_NOPTS_VALUE)
pkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
}
}
if (recording_time != INT64_MAX &&
av_compare_ts(pkt.pts, ist->st->time_base, recording_time + start_time, (AVRational){1, 1000000}) >= 0) {
ist->is_past_recording_time = 1;
goto discard_packet;
}
if (output_packet(ist, ist_index, ost_table, VAR_12, &pkt) < 0) {
if (verbose >= 0)
fprintf(stderr, "Error while decoding stream #%d.%d\VAR_10",
ist->file_index, ist->index);
if (exit_on_error)
ffmpeg_exit(1);
av_free_packet(&pkt);
goto redo;
}
discard_packet:
av_free_packet(&pkt);
print_report(VAR_0, ost_table, VAR_12, 0);
}
for(VAR_7=0;VAR_7<VAR_11;VAR_7++) {
ist = ist_table[VAR_7];
if (ist->decoding_needed) {
output_packet(ist, VAR_7, ost_table, VAR_12, NULL);
}
}
term_exit();
for(VAR_7=0;VAR_7<VAR_1;VAR_7++) {
os = VAR_0[VAR_7];
av_write_trailer(os);
}
print_report(VAR_0, ost_table, VAR_12, 1);
for(VAR_7=0;VAR_7<VAR_12;VAR_7++) {
ost = ost_table[VAR_7];
if (ost->encoding_needed) {
av_freep(&ost->st->codec->stats_in);
avcodec_close(ost->st->codec);
}
#if CONFIG_AVFILTER
avfilter_graph_free(&ost->graph);
#endif
}
for(VAR_7=0;VAR_7<VAR_11;VAR_7++) {
ist = ist_table[VAR_7];
if (ist->decoding_needed) {
avcodec_close(ist->st->codec);
}
}
VAR_6 = 0;
fail:
av_freep(&bit_buffer);
av_free(file_table);
if (ist_table) {
for(VAR_7=0;VAR_7<VAR_11;VAR_7++) {
ist = ist_table[VAR_7];
av_free(ist);
}
av_free(ist_table);
}
if (ost_table) {
for(VAR_7=0;VAR_7<VAR_12;VAR_7++) {
ost = ost_table[VAR_7];
if (ost) {
if (ost->st->stream_copy)
av_freep(&ost->st->codec->extradata);
if (ost->logfile) {
fclose(ost->logfile);
ost->logfile = NULL;
}
av_fifo_free(ost->fifo);
av_freep(&ost->st->codec->subtitle_header);
av_free(ost->pict_tmp.data[0]);
av_free(ost->forced_kf_pts);
if (ost->video_resample)
sws_freeContext(ost->img_resample_ctx);
if (ost->resample)
audio_resample_close(ost->resample);
if (ost->reformat_ctx)
av_audio_convert_free(ost->reformat_ctx);
av_free(ost);
}
}
av_free(ost_table);
}
return VAR_6;
}
| [
"static int FUNC_0(AVFormatContext **VAR_0,\nint VAR_1,\nAVFormatContext **VAR_2,\nint VAR_3,\nAVStreamMap *VAR_4, int VAR_5)\n{",
"int VAR_6 = 0, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11 = 0, VAR_12 = 0, VAR_13;",
"AVFormatContext *is, *os;",
"AVCodecContext *codec, *icodec;",
"AVOutputStream *ost, **ost_table = NULL;",
"AVInputStream *ist, **ist_table = NULL;",
"AVInputFile *file_table;",
"char VAR_14[1024];",
"int VAR_15;",
"int VAR_16 = 1;",
"uint8_t no_packet[MAX_FILES]={0};",
"int VAR_17=0;",
"int VAR_18[AVMEDIA_TYPE_NB]={0};",
"int VAR_19[AVMEDIA_TYPE_NB]={0};",
"file_table= av_mallocz(VAR_3 * sizeof(AVInputFile));",
"if (!file_table)\ngoto fail;",
"VAR_8 = 0;",
"for(VAR_7=0;VAR_7<VAR_3;VAR_7++) {",
"is = VAR_2[VAR_7];",
"file_table[VAR_7].ist_index = VAR_8;",
"file_table[VAR_7].VAR_19 = is->VAR_19;",
"VAR_8 += is->VAR_19;",
"}",
"VAR_11 = VAR_8;",
"ist_table = av_mallocz(VAR_11 * sizeof(AVInputStream *));",
"if (!ist_table)\ngoto fail;",
"for(VAR_7=0;VAR_7<VAR_11;VAR_7++) {",
"ist = av_mallocz(sizeof(AVInputStream));",
"if (!ist)\ngoto fail;",
"ist_table[VAR_7] = ist;",
"}",
"VAR_8 = 0;",
"for(VAR_7=0;VAR_7<VAR_3;VAR_7++) {",
"is = VAR_2[VAR_7];",
"for(VAR_9=0;VAR_9<is->VAR_19;VAR_9++) {",
"ist = ist_table[VAR_8++];",
"ist->st = is->streams[VAR_9];",
"ist->file_index = VAR_7;",
"ist->index = VAR_9;",
"ist->discard = 1;",
"if (rate_emu) {",
"ist->start = av_gettime();",
"}",
"}",
"}",
"VAR_12 = 0;",
"for(VAR_7=0;VAR_7<VAR_1;VAR_7++) {",
"os = VAR_0[VAR_7];",
"if (!os->VAR_19 && !(os->oformat->flags & AVFMT_NOSTREAMS)) {",
"av_dump_format(VAR_0[VAR_7], VAR_7, VAR_0[VAR_7]->filename, 1);",
"fprintf(stderr, \"Output file #%d does not contain any stream\\VAR_10\", VAR_7);",
"VAR_6 = AVERROR(EINVAL);",
"goto fail;",
"}",
"VAR_12 += os->VAR_19;",
"}",
"if (VAR_5 > 0 && VAR_5 != VAR_12) {",
"fprintf(stderr, \"Number of stream maps must match number of output streams\\VAR_10\");",
"VAR_6 = AVERROR(EINVAL);",
"goto fail;",
"}",
"for(VAR_7=0;VAR_7<VAR_5;VAR_7++) {",
"int VAR_20 = VAR_4[VAR_7].file_index;",
"int VAR_25 = VAR_4[VAR_7].stream_index;",
"if (VAR_20 < 0 || VAR_20 > VAR_3 - 1 ||\nVAR_25 < 0 || VAR_25 > file_table[VAR_20].VAR_19 - 1) {",
"fprintf(stderr,\"Could not find input stream #%d.%d\\VAR_10\", VAR_20, VAR_25);",
"VAR_6 = AVERROR(EINVAL);",
"goto fail;",
"}",
"VAR_20 = VAR_4[VAR_7].sync_file_index;",
"VAR_25 = VAR_4[VAR_7].sync_stream_index;",
"if (VAR_20 < 0 || VAR_20 > VAR_3 - 1 ||\nVAR_25 < 0 || VAR_25 > file_table[VAR_20].VAR_19 - 1) {",
"fprintf(stderr,\"Could not find sync stream #%d.%d\\VAR_10\", VAR_20, VAR_25);",
"VAR_6 = AVERROR(EINVAL);",
"goto fail;",
"}",
"}",
"ost_table = av_mallocz(sizeof(AVOutputStream *) * VAR_12);",
"if (!ost_table)\ngoto fail;",
"for(VAR_9=0;VAR_9<VAR_1;VAR_9++) {",
"os = VAR_0[VAR_9];",
"for(VAR_7=0;VAR_7<os->VAR_19;VAR_7++,VAR_10++) {",
"VAR_19[os->streams[VAR_7]->codec->codec_type]++;",
"}",
"}",
"for(VAR_13=1<<30; VAR_13; VAR_13>>=1){",
"int VAR_22[AVMEDIA_TYPE_NB]={0};",
"for(VAR_8=0; VAR_8<AVMEDIA_TYPE_NB; VAR_8++)",
"VAR_18[VAR_8] += VAR_13;",
"for(VAR_8=0; VAR_8<VAR_11; VAR_8++) {",
"int VAR_23=0;",
"ist = ist_table[VAR_8];",
"if(opt_programid){",
"int VAR_24,VAR_25;",
"AVFormatContext *f= VAR_2[ ist->file_index ];",
"VAR_23=1;",
"for(VAR_24=0; VAR_24<f->nb_programs; VAR_24++){",
"AVProgram *p= f->programs[VAR_24];",
"if(p->id == opt_programid)\nfor(VAR_25=0; VAR_25<p->nb_stream_indexes; VAR_25++){",
"if(f->streams[ p->stream_index[VAR_25] ] == ist->st)\nVAR_23=0;",
"}",
"}",
"}",
"if (ist->discard && ist->st->discard != AVDISCARD_ALL && !VAR_23\n&& VAR_18[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames){",
"VAR_22[ist->st->codec->codec_type]++;",
"}",
"}",
"for(VAR_8=0; VAR_8<AVMEDIA_TYPE_NB; VAR_8++)",
"if(VAR_22[VAR_8] < VAR_19[VAR_8])\nVAR_18[VAR_8] -= VAR_13;",
"}",
"VAR_10 = 0;",
"for(VAR_9=0;VAR_9<VAR_1;VAR_9++) {",
"os = VAR_0[VAR_9];",
"for(VAR_7=0;VAR_7<os->VAR_19;VAR_7++,VAR_10++) {",
"int found;",
"ost = ost_table[VAR_10] = output_streams_for_file[VAR_9][VAR_7];",
"ost->st = os->streams[VAR_7];",
"if (VAR_5 > 0) {",
"ost->source_index = file_table[VAR_4[VAR_10].file_index].ist_index +\nVAR_4[VAR_10].stream_index;",
"if (ist_table[ost->source_index]->st->codec->codec_type != ost->st->codec->codec_type) {",
"int VAR_7= ost->file_index;",
"av_dump_format(VAR_0[VAR_7], VAR_7, VAR_0[VAR_7]->filename, 1);",
"fprintf(stderr, \"Codec type mismatch for mapping #%d.%d -> #%d.%d\\VAR_10\",\nVAR_4[VAR_10].file_index, VAR_4[VAR_10].stream_index,\nost->file_index, ost->index);",
"ffmpeg_exit(1);",
"}",
"} else {",
"found = 0;",
"for(VAR_8=0;VAR_8<VAR_11;VAR_8++) {",
"int VAR_23=0;",
"ist = ist_table[VAR_8];",
"if(opt_programid){",
"int VAR_24,VAR_25;",
"AVFormatContext *f= VAR_2[ ist->file_index ];",
"VAR_23=1;",
"for(VAR_24=0; VAR_24<f->nb_programs; VAR_24++){",
"AVProgram *p= f->programs[VAR_24];",
"if(p->id == opt_programid)\nfor(VAR_25=0; VAR_25<p->nb_stream_indexes; VAR_25++){",
"if(f->streams[ p->stream_index[VAR_25] ] == ist->st)\nVAR_23=0;",
"}",
"}",
"}",
"if (ist->discard && ist->st->discard != AVDISCARD_ALL && !VAR_23 &&\nist->st->codec->codec_type == ost->st->codec->codec_type &&\nVAR_18[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames) {",
"ost->source_index = VAR_8;",
"found = 1;",
"break;",
"}",
"}",
"if (!found) {",
"if(! opt_programid) {",
"for(VAR_8=0;VAR_8<VAR_11;VAR_8++) {",
"ist = ist_table[VAR_8];",
"if ( ist->st->codec->codec_type == ost->st->codec->codec_type\n&& ist->st->discard != AVDISCARD_ALL) {",
"ost->source_index = VAR_8;",
"found = 1;",
"}",
"}",
"}",
"if (!found) {",
"int VAR_7= ost->file_index;",
"av_dump_format(VAR_0[VAR_7], VAR_7, VAR_0[VAR_7]->filename, 1);",
"fprintf(stderr, \"Could not find input stream matching output stream #%d.%d\\VAR_10\",\nost->file_index, ost->index);",
"ffmpeg_exit(1);",
"}",
"}",
"}",
"ist = ist_table[ost->source_index];",
"ist->discard = 0;",
"ost->sync_ist = (VAR_5 > 0) ?\nist_table[file_table[VAR_4[VAR_10].sync_file_index].ist_index +\nVAR_4[VAR_10].sync_stream_index] : ist;",
"}",
"}",
"for(VAR_7=0;VAR_7<VAR_12;VAR_7++) {",
"ost = ost_table[VAR_7];",
"os = VAR_0[ost->file_index];",
"ist = ist_table[ost->source_index];",
"codec = ost->st->codec;",
"icodec = ist->st->codec;",
"if (metadata_streams_autocopy)\nav_metadata_copy(&ost->st->metadata, ist->st->metadata,\nAV_METADATA_DONT_OVERWRITE);",
"ost->st->disposition = ist->st->disposition;",
"codec->bits_per_raw_sample= icodec->bits_per_raw_sample;",
"codec->chroma_sample_location = icodec->chroma_sample_location;",
"if (ost->st->stream_copy) {",
"uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE;",
"if (extra_size > INT_MAX)\ngoto fail;",
"codec->codec_id = icodec->codec_id;",
"codec->codec_type = icodec->codec_type;",
"if(!codec->codec_tag){",
"if( !os->oformat->codec_tag\n|| av_codec_get_id (os->oformat->codec_tag, icodec->codec_tag) == codec->codec_id\n|| av_codec_get_tag(os->oformat->codec_tag, icodec->codec_id) <= 0)\ncodec->codec_tag = icodec->codec_tag;",
"}",
"codec->bit_rate = icodec->bit_rate;",
"codec->rc_max_rate = icodec->rc_max_rate;",
"codec->rc_buffer_size = icodec->rc_buffer_size;",
"codec->extradata= av_mallocz(extra_size);",
"if (!codec->extradata)\ngoto fail;",
"memcpy(codec->extradata, icodec->extradata, icodec->extradata_size);",
"codec->extradata_size= icodec->extradata_size;",
"if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){",
"codec->time_base = icodec->time_base;",
"codec->time_base.num *= icodec->ticks_per_frame;",
"av_reduce(&codec->time_base.num, &codec->time_base.den,\ncodec->time_base.num, codec->time_base.den, INT_MAX);",
"}else",
"codec->time_base = ist->st->time_base;",
"switch(codec->codec_type) {",
"case AVMEDIA_TYPE_AUDIO:\nif(audio_volume != 256) {",
"fprintf(stderr,\"-acodec copy and -vol are incompatible (frames are not decoded)\\VAR_10\");",
"ffmpeg_exit(1);",
"}",
"codec->channel_layout = icodec->channel_layout;",
"codec->sample_rate = icodec->sample_rate;",
"codec->channels = icodec->channels;",
"codec->frame_size = icodec->frame_size;",
"codec->audio_service_type = icodec->audio_service_type;",
"codec->block_align= icodec->block_align;",
"if(codec->block_align == 1 && codec->codec_id == CODEC_ID_MP3)\ncodec->block_align= 0;",
"if(codec->codec_id == CODEC_ID_AC3)\ncodec->block_align= 0;",
"break;",
"case AVMEDIA_TYPE_VIDEO:\ncodec->pix_fmt = icodec->pix_fmt;",
"codec->width = icodec->width;",
"codec->height = icodec->height;",
"codec->has_b_frames = icodec->has_b_frames;",
"if (!codec->sample_aspect_ratio.num) {",
"codec->sample_aspect_ratio =\nost->st->sample_aspect_ratio =\nist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio :\nist->st->codec->sample_aspect_ratio.num ?\nist->st->codec->sample_aspect_ratio : (AVRational){0, 1};",
"}",
"break;",
"case AVMEDIA_TYPE_SUBTITLE:\ncodec->width = icodec->width;",
"codec->height = icodec->height;",
"break;",
"case AVMEDIA_TYPE_DATA:\nbreak;",
"default:\nabort();",
"}",
"} else {",
"switch(codec->codec_type) {",
"case AVMEDIA_TYPE_AUDIO:\nost->fifo= av_fifo_alloc(1024);",
"if(!ost->fifo)\ngoto fail;",
"ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE);",
"ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1;",
"icodec->request_channels = codec->channels;",
"ist->decoding_needed = 1;",
"ost->encoding_needed = 1;",
"ost->resample_sample_fmt = icodec->sample_fmt;",
"ost->resample_sample_rate = icodec->sample_rate;",
"ost->resample_channels = icodec->channels;",
"break;",
"case AVMEDIA_TYPE_VIDEO:\nif (ost->st->codec->pix_fmt == PIX_FMT_NONE) {",
"fprintf(stderr, \"Video pixel format is unknown, stream cannot be encoded\\VAR_10\");",
"ffmpeg_exit(1);",
"}",
"ost->video_resample = codec->width != icodec->width ||\ncodec->height != icodec->height ||\ncodec->pix_fmt != icodec->pix_fmt;",
"if (ost->video_resample) {",
"#if !CONFIG_AVFILTER\navcodec_get_frame_defaults(&ost->pict_tmp);",
"if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fmt,\ncodec->width, codec->height)) {",
"fprintf(stderr, \"Cannot allocate temp picture, check pix fmt\\VAR_10\");",
"ffmpeg_exit(1);",
"}",
"sws_flags = av_get_int(sws_opts, \"sws_flags\", NULL);",
"ost->img_resample_ctx = sws_getContext(\nicodec->width,\nicodec->height,\nicodec->pix_fmt,\ncodec->width,\ncodec->height,\ncodec->pix_fmt,\nsws_flags, NULL, NULL, NULL);",
"if (ost->img_resample_ctx == NULL) {",
"fprintf(stderr, \"Cannot get resampling context\\VAR_10\");",
"ffmpeg_exit(1);",
"}",
"#endif\ncodec->bits_per_raw_sample= frame_bits_per_raw_sample;",
"}",
"ost->resample_height = icodec->height;",
"ost->resample_width = icodec->width;",
"ost->resample_pix_fmt= icodec->pix_fmt;",
"ost->encoding_needed = 1;",
"ist->decoding_needed = 1;",
"#if CONFIG_AVFILTER\nif (configure_video_filters(ist, ost)) {",
"fprintf(stderr, \"Error opening filters!\\VAR_10\");",
"exit(1);",
"}",
"#endif\nbreak;",
"case AVMEDIA_TYPE_SUBTITLE:\nost->encoding_needed = 1;",
"ist->decoding_needed = 1;",
"break;",
"default:\nabort();",
"break;",
"}",
"if (ost->encoding_needed && codec->codec_id != CODEC_ID_H264 &&\n(codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) {",
"char VAR_25[1024];",
"FILE *f;",
"snprintf(VAR_25, sizeof(VAR_25), \"%s-%d.log\",\npass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX,\nVAR_7);",
"if (codec->flags & CODEC_FLAG_PASS1) {",
"f = fopen(VAR_25, \"wb\");",
"if (!f) {",
"fprintf(stderr, \"Cannot write log file '%s' for pass-1 encoding: %s\\VAR_10\", VAR_25, strerror(errno));",
"ffmpeg_exit(1);",
"}",
"ost->logfile = f;",
"} else {",
"char *VAR_26;",
"size_t logbuffer_size;",
"if (read_file(VAR_25, &VAR_26, &logbuffer_size) < 0) {",
"fprintf(stderr, \"Error reading log file '%s' for pass-2 encoding\\VAR_10\", VAR_25);",
"ffmpeg_exit(1);",
"}",
"codec->stats_in = VAR_26;",
"}",
"}",
"}",
"if(codec->codec_type == AVMEDIA_TYPE_VIDEO){",
"int VAR_27= codec->width * codec->height;",
"bit_buffer_size= FFMAX(bit_buffer_size, 6*VAR_27 + 1664);",
"}",
"}",
"if (!bit_buffer)\nbit_buffer = av_malloc(bit_buffer_size);",
"if (!bit_buffer) {",
"fprintf(stderr, \"Cannot allocate %d bytes output buffer\\VAR_10\",\nbit_buffer_size);",
"VAR_6 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"for(VAR_7=0;VAR_7<VAR_12;VAR_7++) {",
"ost = ost_table[VAR_7];",
"if (ost->encoding_needed) {",
"AVCodec *codec = VAR_7 < nb_output_codecs ? output_codecs[VAR_7] : NULL;",
"AVCodecContext *dec = ist_table[ost->source_index]->st->codec;",
"if (!codec)\ncodec = avcodec_find_encoder(ost->st->codec->codec_id);",
"if (!codec) {",
"snprintf(VAR_14, sizeof(VAR_14), \"Encoder (codec id %d) not found for output stream #%d.%d\",\nost->st->codec->codec_id, ost->file_index, ost->index);",
"VAR_6 = AVERROR(EINVAL);",
"goto dump_format;",
"}",
"if (dec->subtitle_header) {",
"ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size);",
"if (!ost->st->codec->subtitle_header) {",
"VAR_6 = AVERROR(ENOMEM);",
"goto dump_format;",
"}",
"memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size);",
"ost->st->codec->subtitle_header_size = dec->subtitle_header_size;",
"}",
"if (avcodec_open(ost->st->codec, codec) < 0) {",
"snprintf(VAR_14, sizeof(VAR_14), \"Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height\",\nost->file_index, ost->index);",
"VAR_6 = AVERROR(EINVAL);",
"goto dump_format;",
"}",
"extra_size += ost->st->codec->extradata_size;",
"}",
"}",
"for(VAR_7=0;VAR_7<VAR_11;VAR_7++) {",
"ist = ist_table[VAR_7];",
"if (ist->decoding_needed) {",
"AVCodec *codec = VAR_7 < nb_input_codecs ? input_codecs[VAR_7] : NULL;",
"if (!codec)\ncodec = avcodec_find_decoder(ist->st->codec->codec_id);",
"if (!codec) {",
"snprintf(VAR_14, sizeof(VAR_14), \"Decoder (codec id %d) not found for input stream #%d.%d\",\nist->st->codec->codec_id, ist->file_index, ist->index);",
"VAR_6 = AVERROR(EINVAL);",
"goto dump_format;",
"}",
"if (avcodec_open(ist->st->codec, codec) < 0) {",
"snprintf(VAR_14, sizeof(VAR_14), \"Error while opening decoder for input stream #%d.%d\",\nist->file_index, ist->index);",
"VAR_6 = AVERROR(EINVAL);",
"goto dump_format;",
"}",
"}",
"}",
"for(VAR_7=0;VAR_7<VAR_11;VAR_7++) {",
"AVStream *st;",
"ist = ist_table[VAR_7];",
"st= ist->st;",
"ist->pts = st->avg_frame_rate.num ? - st->codec->has_b_frames*AV_TIME_BASE / av_q2d(st->avg_frame_rate) : 0;",
"ist->next_pts = AV_NOPTS_VALUE;",
"ist->is_start = 1;",
"}",
"for (VAR_7=0;VAR_7<nb_meta_data_maps;VAR_7++) {",
"AVFormatContext *files[2];",
"AVMetadata **meta[2];",
"int VAR_8;",
"#define METADATA_CHECK_INDEX(index, nb_elems, desc)\\\nif ((index) < 0 || (index) >= (nb_elems)) {\\",
"snprintf(VAR_14, sizeof(VAR_14), \"Invalid %s index %d while processing metadata maps\\VAR_10\",\\\n(desc), (index));\\",
"VAR_6 = AVERROR(EINVAL);\\",
"goto dump_format;\\",
"}",
"int out_file_index = meta_data_maps[VAR_7][0].file;",
"int in_file_index = meta_data_maps[VAR_7][1].file;",
"if (in_file_index < 0 || out_file_index < 0)\ncontinue;",
"METADATA_CHECK_INDEX(out_file_index, VAR_1, \"output file\")\nMETADATA_CHECK_INDEX(in_file_index, VAR_3, \"input file\")\nfiles[0] = VAR_0[out_file_index];",
"files[1] = VAR_2[in_file_index];",
"for (VAR_8 = 0; VAR_8 < 2; VAR_8++) {",
"AVMetaDataMap *map = &meta_data_maps[VAR_7][VAR_8];",
"switch (map->type) {",
"case 'g':\nmeta[VAR_8] = &files[VAR_8]->metadata;",
"break;",
"case 's':\nMETADATA_CHECK_INDEX(map->index, files[VAR_8]->VAR_19, \"stream\")\nmeta[VAR_8] = &files[VAR_8]->streams[map->index]->metadata;",
"break;",
"case 'c':\nMETADATA_CHECK_INDEX(map->index, files[VAR_8]->nb_chapters, \"chapter\")\nmeta[VAR_8] = &files[VAR_8]->chapters[map->index]->metadata;",
"break;",
"case 'p':\nMETADATA_CHECK_INDEX(map->index, files[VAR_8]->nb_programs, \"program\")\nmeta[VAR_8] = &files[VAR_8]->programs[map->index]->metadata;",
"break;",
"}",
"}",
"av_metadata_copy(meta[0], *meta[1], AV_METADATA_DONT_OVERWRITE);",
"}",
"if (metadata_global_autocopy) {",
"for (VAR_7 = 0; VAR_7 < VAR_1; VAR_7++)",
"av_metadata_copy(&VAR_0[VAR_7]->metadata, VAR_2[0]->metadata,\nAV_METADATA_DONT_OVERWRITE);",
"}",
"for (VAR_7 = 0; VAR_7 < nb_chapter_maps; VAR_7++) {",
"int infile = chapter_maps[VAR_7].in_file;",
"int outfile = chapter_maps[VAR_7].out_file;",
"if (infile < 0 || outfile < 0)\ncontinue;",
"if (infile >= VAR_3) {",
"snprintf(VAR_14, sizeof(VAR_14), \"Invalid input file index %d in chapter mapping.\\VAR_10\", infile);",
"VAR_6 = AVERROR(EINVAL);",
"goto dump_format;",
"}",
"if (outfile >= VAR_1) {",
"snprintf(VAR_14, sizeof(VAR_14), \"Invalid output file index %d in chapter mapping.\\VAR_10\",outfile);",
"VAR_6 = AVERROR(EINVAL);",
"goto dump_format;",
"}",
"copy_chapters(infile, outfile);",
"}",
"if (!nb_chapter_maps)\nfor (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) {",
"if (!VAR_2[VAR_7]->nb_chapters)\ncontinue;",
"for (VAR_8 = 0; VAR_8 < VAR_1; VAR_8++)",
"if ((VAR_6 = copy_chapters(VAR_7, VAR_8)) < 0)\ngoto dump_format;",
"break;",
"}",
"for(VAR_7=0;VAR_7<VAR_1;VAR_7++) {",
"os = VAR_0[VAR_7];",
"if (av_write_header(os) < 0) {",
"snprintf(VAR_14, sizeof(VAR_14), \"Could not write header for output file #%d (incorrect codec parameters ?)\", VAR_7);",
"VAR_6 = AVERROR(EINVAL);",
"goto dump_format;",
"}",
"if (strcmp(VAR_0[VAR_7]->oformat->name, \"rtp\")) {",
"VAR_16 = 0;",
"}",
"}",
"dump_format:\nfor(VAR_7=0;VAR_7<VAR_1;VAR_7++) {",
"av_dump_format(VAR_0[VAR_7], VAR_7, VAR_0[VAR_7]->filename, 1);",
"}",
"if (verbose >= 0) {",
"fprintf(stderr, \"Stream mapping:\\VAR_10\");",
"for(VAR_7=0;VAR_7<VAR_12;VAR_7++) {",
"ost = ost_table[VAR_7];",
"fprintf(stderr, \" Stream #%d.%d -> #%d.%d\",\nist_table[ost->source_index]->file_index,\nist_table[ost->source_index]->index,\nost->file_index,\nost->index);",
"if (ost->sync_ist != ist_table[ost->source_index])\nfprintf(stderr, \" [sync #%d.%d]\",\nost->sync_ist->file_index,\nost->sync_ist->index);",
"fprintf(stderr, \"\\VAR_10\");",
"}",
"}",
"if (VAR_6) {",
"fprintf(stderr, \"%s\\VAR_10\", VAR_14);",
"goto fail;",
"}",
"if (VAR_16) {",
"print_sdp(VAR_0, VAR_1);",
"}",
"if (!using_stdin) {",
"if(verbose >= 0)\nfprintf(stderr, \"Press [q] to stop encoding\\VAR_10\");",
"avio_set_interrupt_cb(decode_interrupt_cb);",
"}",
"term_init();",
"timer_start = av_gettime();",
"for(; received_sigterm == 0;) {",
"int file_index, ist_index;",
"AVPacket pkt;",
"double ipts_min;",
"double opts_min;",
"redo:\nipts_min= 1e100;",
"opts_min= 1e100;",
"if (!using_stdin) {",
"if (q_pressed)\nbreak;",
"VAR_15 = read_key();",
"if (VAR_15 == 'q')\nbreak;",
"}",
"file_index = -1;",
"for(VAR_7=0;VAR_7<VAR_12;VAR_7++) {",
"double ipts, opts;",
"ost = ost_table[VAR_7];",
"os = VAR_0[ost->file_index];",
"ist = ist_table[ost->source_index];",
"if(ist->is_past_recording_time || no_packet[ist->file_index])\ncontinue;",
"opts = ost->st->pts.val * av_q2d(ost->st->time_base);",
"ipts = (double)ist->pts;",
"if (!file_table[ist->file_index].eof_reached){",
"if(ipts < ipts_min) {",
"ipts_min = ipts;",
"if(input_sync ) file_index = ist->file_index;",
"}",
"if(opts < opts_min) {",
"opts_min = opts;",
"if(!input_sync) file_index = ist->file_index;",
"}",
"}",
"if(ost->frame_number >= max_frames[ost->st->codec->codec_type]){",
"file_index= -1;",
"break;",
"}",
"}",
"if (file_index < 0) {",
"if(VAR_17){",
"VAR_17=0;",
"memset(no_packet, 0, sizeof(no_packet));",
"usleep(10000);",
"continue;",
"}",
"break;",
"}",
"if (limit_filesize != 0 && limit_filesize <= avio_tell(VAR_0[0]->pb))\nbreak;",
"is = VAR_2[file_index];",
"VAR_6= av_read_frame(is, &pkt);",
"if(VAR_6 == AVERROR(EAGAIN)){",
"no_packet[file_index]=1;",
"VAR_17++;",
"continue;",
"}",
"if (VAR_6 < 0) {",
"file_table[file_index].eof_reached = 1;",
"if (opt_shortest)\nbreak;",
"else\ncontinue;",
"}",
"VAR_17=0;",
"memset(no_packet, 0, sizeof(no_packet));",
"if (do_pkt_dump) {",
"av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump,\nis->streams[pkt.stream_index]);",
"}",
"if (pkt.stream_index >= file_table[file_index].VAR_19)\ngoto discard_packet;",
"ist_index = file_table[file_index].ist_index + pkt.stream_index;",
"ist = ist_table[ist_index];",
"if (ist->discard)\ngoto discard_packet;",
"if (pkt.dts != AV_NOPTS_VALUE)\npkt.dts += av_rescale_q(input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ist->st->time_base);",
"if (pkt.pts != AV_NOPTS_VALUE)\npkt.pts += av_rescale_q(input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ist->st->time_base);",
"if (pkt.stream_index < nb_input_files_ts_scale[file_index]\n&& input_files_ts_scale[file_index][pkt.stream_index]){",
"if(pkt.pts != AV_NOPTS_VALUE)\npkt.pts *= input_files_ts_scale[file_index][pkt.stream_index];",
"if(pkt.dts != AV_NOPTS_VALUE)\npkt.dts *= input_files_ts_scale[file_index][pkt.stream_index];",
"}",
"if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE\n&& (is->iformat->flags & AVFMT_TS_DISCONT)) {",
"int64_t pkt_dts= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);",
"int64_t delta= pkt_dts - ist->next_pts;",
"if((FFABS(delta) > 1LL*dts_delta_threshold*AV_TIME_BASE || pkt_dts+1<ist->pts)&& !copy_ts){",
"input_files_ts_offset[ist->file_index]-= delta;",
"if (verbose > 2)\nfprintf(stderr, \"timestamp discontinuity %\"PRId64\", new offset= %\"PRId64\"\\VAR_10\", delta, input_files_ts_offset[ist->file_index]);",
"pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);",
"if(pkt.pts != AV_NOPTS_VALUE)\npkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);",
"}",
"}",
"if (recording_time != INT64_MAX &&\nav_compare_ts(pkt.pts, ist->st->time_base, recording_time + start_time, (AVRational){1, 1000000}) >= 0) {",
"ist->is_past_recording_time = 1;",
"goto discard_packet;",
"}",
"if (output_packet(ist, ist_index, ost_table, VAR_12, &pkt) < 0) {",
"if (verbose >= 0)\nfprintf(stderr, \"Error while decoding stream #%d.%d\\VAR_10\",\nist->file_index, ist->index);",
"if (exit_on_error)\nffmpeg_exit(1);",
"av_free_packet(&pkt);",
"goto redo;",
"}",
"discard_packet:\nav_free_packet(&pkt);",
"print_report(VAR_0, ost_table, VAR_12, 0);",
"}",
"for(VAR_7=0;VAR_7<VAR_11;VAR_7++) {",
"ist = ist_table[VAR_7];",
"if (ist->decoding_needed) {",
"output_packet(ist, VAR_7, ost_table, VAR_12, NULL);",
"}",
"}",
"term_exit();",
"for(VAR_7=0;VAR_7<VAR_1;VAR_7++) {",
"os = VAR_0[VAR_7];",
"av_write_trailer(os);",
"}",
"print_report(VAR_0, ost_table, VAR_12, 1);",
"for(VAR_7=0;VAR_7<VAR_12;VAR_7++) {",
"ost = ost_table[VAR_7];",
"if (ost->encoding_needed) {",
"av_freep(&ost->st->codec->stats_in);",
"avcodec_close(ost->st->codec);",
"}",
"#if CONFIG_AVFILTER\navfilter_graph_free(&ost->graph);",
"#endif\n}",
"for(VAR_7=0;VAR_7<VAR_11;VAR_7++) {",
"ist = ist_table[VAR_7];",
"if (ist->decoding_needed) {",
"avcodec_close(ist->st->codec);",
"}",
"}",
"VAR_6 = 0;",
"fail:\nav_freep(&bit_buffer);",
"av_free(file_table);",
"if (ist_table) {",
"for(VAR_7=0;VAR_7<VAR_11;VAR_7++) {",
"ist = ist_table[VAR_7];",
"av_free(ist);",
"}",
"av_free(ist_table);",
"}",
"if (ost_table) {",
"for(VAR_7=0;VAR_7<VAR_12;VAR_7++) {",
"ost = ost_table[VAR_7];",
"if (ost) {",
"if (ost->st->stream_copy)\nav_freep(&ost->st->codec->extradata);",
"if (ost->logfile) {",
"fclose(ost->logfile);",
"ost->logfile = NULL;",
"}",
"av_fifo_free(ost->fifo);",
"av_freep(&ost->st->codec->subtitle_header);",
"av_free(ost->pict_tmp.data[0]);",
"av_free(ost->forced_kf_pts);",
"if (ost->video_resample)\nsws_freeContext(ost->img_resample_ctx);",
"if (ost->resample)\naudio_resample_close(ost->resample);",
"if (ost->reformat_ctx)\nav_audio_convert_free(ost->reformat_ctx);",
"av_free(ost);",
"}",
"}",
"av_free(ost_table);",
"}",
"return VAR_6;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43,
45
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71,
73
],
[
77
],
[
79
],
[
81,
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
161
],
[
163
],
[
165
],
[
169,
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185,
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
201
],
[
203,
205
],
[
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
],
[
273
],
[
275,
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297,
299
],
[
305
],
[
307
],
[
309
],
[
311,
313,
315
],
[
317
],
[
319
],
[
323
],
[
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
],
[
379
],
[
381
],
[
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
],
[
439
],
[
441
],
[
443
],
[
445
],
[
449
],
[
451
],
[
455,
457,
459
],
[
463
],
[
465
],
[
467
],
[
471
],
[
473
],
[
477,
479
],
[
485
],
[
487
],
[
491
],
[
493,
495,
497,
499
],
[
501
],
[
505
],
[
507
],
[
509
],
[
511
],
[
513,
515
],
[
517
],
[
519
],
[
521
],
[
523
],
[
525
],
[
527,
529
],
[
531
],
[
533
],
[
535
],
[
537,
539
],
[
541
],
[
543
],
[
545
],
[
547
],
[
549
],
[
551
],
[
553
],
[
555
],
[
557
],
[
559,
561
],
[
563,
565
],
[
567
],
[
569,
571
],
[
573
],
[
575
],
[
577
],
[
579
],
[
581,
583,
585,
587,
589
],
[
591
],
[
593
],
[
595,
597
],
[
599
],
[
601
],
[
603,
605
],
[
607,
609
],
[
611
],
[
613
],
[
615
],
[
617,
619
],
[
621,
623
],
[
625
],
[
627
],
[
629
],
[
631
],
[
633
],
[
635
],
[
637
],
[
639
],
[
641
],
[
643,
645
],
[
647
],
[
649
],
[
651
],
[
653,
655,
657
],
[
659
],
[
661,
663
],
[
665,
667
],
[
669
],
[
671
],
[
673
],
[
675
],
[
677,
679,
681,
683,
685,
687,
689,
691
],
[
693
],
[
695
],
[
697
],
[
699
],
[
701,
703
],
[
705
],
[
707
],
[
709
],
[
711
],
[
713
],
[
715
],
[
719,
721
],
[
723
],
[
725
],
[
727
],
[
729,
731
],
[
733,
735
],
[
737
],
[
739
],
[
741,
743
],
[
745
],
[
747
],
[
751,
753
],
[
755
],
[
757
],
[
761,
763,
765
],
[
767
],
[
769
],
[
771
],
[
773
],
[
775
],
[
777
],
[
779
],
[
781
],
[
783
],
[
785
],
[
787
],
[
789
],
[
791
],
[
793
],
[
795
],
[
797
],
[
799
],
[
801
],
[
803
],
[
807
],
[
809
],
[
811
],
[
813
],
[
817,
819
],
[
821
],
[
823,
825
],
[
827
],
[
829
],
[
831
],
[
837
],
[
839
],
[
841
],
[
843
],
[
845
],
[
847,
849
],
[
851
],
[
853,
855
],
[
857
],
[
859
],
[
861
],
[
863
],
[
865
],
[
867
],
[
869
],
[
871
],
[
873
],
[
875
],
[
877
],
[
879
],
[
881
],
[
883,
885
],
[
887
],
[
889
],
[
891
],
[
893
],
[
895
],
[
897
],
[
903
],
[
905
],
[
907
],
[
909
],
[
911,
913
],
[
915
],
[
917,
919
],
[
921
],
[
923
],
[
925
],
[
927
],
[
929,
931
],
[
933
],
[
935
],
[
937
],
[
943
],
[
945
],
[
951
],
[
953
],
[
955
],
[
957
],
[
959
],
[
961
],
[
963
],
[
965
],
[
971
],
[
973
],
[
975
],
[
977
],
[
981,
983
],
[
985,
987
],
[
989
],
[
991
],
[
993
],
[
997
],
[
999
],
[
1001,
1003
],
[
1005,
1007,
1011
],
[
1013
],
[
1017
],
[
1019
],
[
1023
],
[
1025,
1027
],
[
1029
],
[
1031,
1033,
1035
],
[
1037
],
[
1039,
1041,
1043
],
[
1045
],
[
1047,
1049,
1051
],
[
1053
],
[
1055
],
[
1057
],
[
1061
],
[
1063
],
[
1069
],
[
1073
],
[
1075,
1077
],
[
1079
],
[
1085
],
[
1087
],
[
1089
],
[
1093,
1095
],
[
1097
],
[
1099
],
[
1101
],
[
1103
],
[
1105
],
[
1107
],
[
1109
],
[
1111
],
[
1113
],
[
1115
],
[
1117
],
[
1119
],
[
1125,
1127
],
[
1129,
1131
],
[
1135
],
[
1137,
1139
],
[
1141
],
[
1143
],
[
1149
],
[
1151
],
[
1153
],
[
1155
],
[
1157
],
[
1159
],
[
1161
],
[
1163
],
[
1165
],
[
1167
],
[
1169
],
[
1173,
1179
],
[
1181
],
[
1183
],
[
1189
],
[
1191
],
[
1193
],
[
1195
],
[
1197,
1199,
1201,
1203,
1205
],
[
1207,
1209,
1211,
1213
],
[
1215
],
[
1217
],
[
1219
],
[
1223
],
[
1225
],
[
1227
],
[
1229
],
[
1233
],
[
1235
],
[
1237
],
[
1241
],
[
1243,
1245
],
[
1247
],
[
1249
],
[
1251
],
[
1255
],
[
1259
],
[
1261
],
[
1263
],
[
1265
],
[
1267
],
[
1271,
1273
],
[
1275
],
[
1279
],
[
1281,
1283
],
[
1287
],
[
1289,
1291
],
[
1293
],
[
1301
],
[
1303
],
[
1305
],
[
1307
],
[
1309
],
[
1311
],
[
1313,
1315
],
[
1317
],
[
1319
],
[
1321
],
[
1323
],
[
1325
],
[
1327
],
[
1329
],
[
1331
],
[
1333
],
[
1335
],
[
1337
],
[
1339
],
[
1341
],
[
1343
],
[
1345
],
[
1347
],
[
1349
],
[
1353
],
[
1355
],
[
1357
],
[
1359
],
[
1361
],
[
1363
],
[
1365
],
[
1367
],
[
1369
],
[
1375,
1377
],
[
1383
],
[
1385
],
[
1387
],
[
1389
],
[
1391
],
[
1393
],
[
1395
],
[
1397
],
[
1399
],
[
1401,
1403
],
[
1405,
1407
],
[
1409
],
[
1413
],
[
1415
],
[
1419
],
[
1421,
1423
],
[
1425
],
[
1431,
1433
],
[
1435
],
[
1437
],
[
1439,
1441
],
[
1445,
1447
],
[
1449,
1451
],
[
1455,
1457
],
[
1459,
1461
],
[
1463,
1465
],
[
1467
],
[
1473,
1475
],
[
1477
],
[
1479
],
[
1481
],
[
1483
],
[
1485,
1487
],
[
1489
],
[
1491,
1493
],
[
1495
],
[
1497
],
[
1503,
1505
],
[
1507
],
[
1509
],
[
1511
],
[
1517
],
[
1521,
1523,
1525
],
[
1527,
1529
],
[
1531
],
[
1533
],
[
1535
],
[
1539,
1541
],
[
1547
],
[
1549
],
[
1555
],
[
1557
],
[
1559
],
[
1561
],
[
1563
],
[
1565
],
[
1569
],
[
1575
],
[
1577
],
[
1579
],
[
1581
],
[
1587
],
[
1593
],
[
1595
],
[
1597
],
[
1599
],
[
1601
],
[
1603
],
[
1605,
1607
],
[
1609,
1611
],
[
1617
],
[
1619
],
[
1621
],
[
1623
],
[
1625
],
[
1627
],
[
1633
],
[
1637,
1639
],
[
1641
],
[
1645
],
[
1647
],
[
1649
],
[
1651
],
[
1653
],
[
1655
],
[
1657
],
[
1659
],
[
1661
],
[
1663
],
[
1665
],
[
1667,
1669
],
[
1671
],
[
1673
],
[
1675
],
[
1677
],
[
1679
],
[
1683
],
[
1685
],
[
1687
],
[
1689,
1691
],
[
1693,
1695
],
[
1697,
1699
],
[
1701
],
[
1703
],
[
1705
],
[
1707
],
[
1709
],
[
1711
],
[
1713
]
] |
4,492 | static void kqemu_vfree(void *ptr)
{
/* may be useful some day, but currently we do not need to free */
}
| false | qemu | 4a1418e07bdcfaa3177739e04707ecaec75d89e1 | static void kqemu_vfree(void *ptr)
{
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"}"
] | [
0,
0
] | [
[
1,
3
],
[
7
]
] |
4,493 | static inline void gen_movcf_ps (int fs, int fd, int cc, int tf)
{
int cond;
TCGv r_tmp1 = tcg_temp_local_new(TCG_TYPE_I32);
TCGv r_tmp2 = tcg_temp_local_new(TCG_TYPE_I32);
TCGv fp0 = tcg_temp_local_new(TCG_TYPE_I32);
TCGv fph0 = tcg_temp_local_new(TCG_TYPE_I32);
TCGv fp1 = tcg_temp_local_new(TCG_TYPE_I32);
TCGv fph1 = tcg_temp_local_new(TCG_TYPE_I32);
int l1 = gen_new_label();
int l2 = gen_new_label();
if (tf)
cond = TCG_COND_EQ;
else
cond = TCG_COND_NE;
gen_load_fpr32(fp0, fs);
gen_load_fpr32h(fph0, fs);
gen_load_fpr32(fp1, fd);
gen_load_fpr32h(fph1, fd);
get_fp_cond(r_tmp1);
tcg_gen_shri_i32(r_tmp1, r_tmp1, cc);
tcg_gen_andi_i32(r_tmp2, r_tmp1, 0x1);
tcg_gen_brcondi_i32(cond, r_tmp2, 0, l1);
tcg_gen_mov_i32(fp1, fp0);
tcg_temp_free(fp0);
gen_set_label(l1);
tcg_gen_andi_i32(r_tmp2, r_tmp1, 0x2);
tcg_gen_brcondi_i32(cond, r_tmp2, 0, l2);
tcg_gen_mov_i32(fph1, fph0);
tcg_temp_free(fph0);
gen_set_label(l2);
tcg_temp_free(r_tmp1);
tcg_temp_free(r_tmp2);
gen_store_fpr32(fp1, fd);
gen_store_fpr32h(fph1, fd);
tcg_temp_free(fp1);
tcg_temp_free(fph1);
}
| false | qemu | 9bf3eb2ca542dd9306cb2e72fc68e02ba3e56e2e | static inline void gen_movcf_ps (int fs, int fd, int cc, int tf)
{
int cond;
TCGv r_tmp1 = tcg_temp_local_new(TCG_TYPE_I32);
TCGv r_tmp2 = tcg_temp_local_new(TCG_TYPE_I32);
TCGv fp0 = tcg_temp_local_new(TCG_TYPE_I32);
TCGv fph0 = tcg_temp_local_new(TCG_TYPE_I32);
TCGv fp1 = tcg_temp_local_new(TCG_TYPE_I32);
TCGv fph1 = tcg_temp_local_new(TCG_TYPE_I32);
int l1 = gen_new_label();
int l2 = gen_new_label();
if (tf)
cond = TCG_COND_EQ;
else
cond = TCG_COND_NE;
gen_load_fpr32(fp0, fs);
gen_load_fpr32h(fph0, fs);
gen_load_fpr32(fp1, fd);
gen_load_fpr32h(fph1, fd);
get_fp_cond(r_tmp1);
tcg_gen_shri_i32(r_tmp1, r_tmp1, cc);
tcg_gen_andi_i32(r_tmp2, r_tmp1, 0x1);
tcg_gen_brcondi_i32(cond, r_tmp2, 0, l1);
tcg_gen_mov_i32(fp1, fp0);
tcg_temp_free(fp0);
gen_set_label(l1);
tcg_gen_andi_i32(r_tmp2, r_tmp1, 0x2);
tcg_gen_brcondi_i32(cond, r_tmp2, 0, l2);
tcg_gen_mov_i32(fph1, fph0);
tcg_temp_free(fph0);
gen_set_label(l2);
tcg_temp_free(r_tmp1);
tcg_temp_free(r_tmp2);
gen_store_fpr32(fp1, fd);
gen_store_fpr32h(fph1, fd);
tcg_temp_free(fp1);
tcg_temp_free(fph1);
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0 (int VAR_0, int VAR_1, int VAR_2, int VAR_3)
{
int VAR_4;
TCGv r_tmp1 = tcg_temp_local_new(TCG_TYPE_I32);
TCGv r_tmp2 = tcg_temp_local_new(TCG_TYPE_I32);
TCGv fp0 = tcg_temp_local_new(TCG_TYPE_I32);
TCGv fph0 = tcg_temp_local_new(TCG_TYPE_I32);
TCGv fp1 = tcg_temp_local_new(TCG_TYPE_I32);
TCGv fph1 = tcg_temp_local_new(TCG_TYPE_I32);
int VAR_5 = gen_new_label();
int VAR_6 = gen_new_label();
if (VAR_3)
VAR_4 = TCG_COND_EQ;
else
VAR_4 = TCG_COND_NE;
gen_load_fpr32(fp0, VAR_0);
gen_load_fpr32h(fph0, VAR_0);
gen_load_fpr32(fp1, VAR_1);
gen_load_fpr32h(fph1, VAR_1);
get_fp_cond(r_tmp1);
tcg_gen_shri_i32(r_tmp1, r_tmp1, VAR_2);
tcg_gen_andi_i32(r_tmp2, r_tmp1, 0x1);
tcg_gen_brcondi_i32(VAR_4, r_tmp2, 0, VAR_5);
tcg_gen_mov_i32(fp1, fp0);
tcg_temp_free(fp0);
gen_set_label(VAR_5);
tcg_gen_andi_i32(r_tmp2, r_tmp1, 0x2);
tcg_gen_brcondi_i32(VAR_4, r_tmp2, 0, VAR_6);
tcg_gen_mov_i32(fph1, fph0);
tcg_temp_free(fph0);
gen_set_label(VAR_6);
tcg_temp_free(r_tmp1);
tcg_temp_free(r_tmp2);
gen_store_fpr32(fp1, VAR_1);
gen_store_fpr32h(fph1, VAR_1);
tcg_temp_free(fp1);
tcg_temp_free(fph1);
}
| [
"static inline void FUNC_0 (int VAR_0, int VAR_1, int VAR_2, int VAR_3)\n{",
"int VAR_4;",
"TCGv r_tmp1 = tcg_temp_local_new(TCG_TYPE_I32);",
"TCGv r_tmp2 = tcg_temp_local_new(TCG_TYPE_I32);",
"TCGv fp0 = tcg_temp_local_new(TCG_TYPE_I32);",
"TCGv fph0 = tcg_temp_local_new(TCG_TYPE_I32);",
"TCGv fp1 = tcg_temp_local_new(TCG_TYPE_I32);",
"TCGv fph1 = tcg_temp_local_new(TCG_TYPE_I32);",
"int VAR_5 = gen_new_label();",
"int VAR_6 = gen_new_label();",
"if (VAR_3)\nVAR_4 = TCG_COND_EQ;",
"else\nVAR_4 = TCG_COND_NE;",
"gen_load_fpr32(fp0, VAR_0);",
"gen_load_fpr32h(fph0, VAR_0);",
"gen_load_fpr32(fp1, VAR_1);",
"gen_load_fpr32h(fph1, VAR_1);",
"get_fp_cond(r_tmp1);",
"tcg_gen_shri_i32(r_tmp1, r_tmp1, VAR_2);",
"tcg_gen_andi_i32(r_tmp2, r_tmp1, 0x1);",
"tcg_gen_brcondi_i32(VAR_4, r_tmp2, 0, VAR_5);",
"tcg_gen_mov_i32(fp1, fp0);",
"tcg_temp_free(fp0);",
"gen_set_label(VAR_5);",
"tcg_gen_andi_i32(r_tmp2, r_tmp1, 0x2);",
"tcg_gen_brcondi_i32(VAR_4, r_tmp2, 0, VAR_6);",
"tcg_gen_mov_i32(fph1, fph0);",
"tcg_temp_free(fph0);",
"gen_set_label(VAR_6);",
"tcg_temp_free(r_tmp1);",
"tcg_temp_free(r_tmp2);",
"gen_store_fpr32(fp1, VAR_1);",
"gen_store_fpr32h(fph1, VAR_1);",
"tcg_temp_free(fp1);",
"tcg_temp_free(fph1);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
]
] |
4,496 | static void bmdma_writeb(void *opaque, uint32_t addr, uint32_t val)
{
BMDMAState *bm = opaque;
PCIIDEState *pci_dev = pci_from_bm(bm);
#ifdef DEBUG_IDE
printf("bmdma: writeb 0x%02x : 0x%02x\n", addr, val);
#endif
switch(addr & 3) {
case 1:
pci_dev->dev.config[MRDMODE] =
(pci_dev->dev.config[MRDMODE] & ~0x30) | (val & 0x30);
cmd646_update_irq(pci_dev);
break;
case 2:
bm->status = (val & 0x60) | (bm->status & 1) | (bm->status & ~val & 0x06);
break;
case 3:
if (bm->unit == 0)
pci_dev->dev.config[UDIDETCR0] = val;
else
pci_dev->dev.config[UDIDETCR1] = val;
break;
}
}
| false | qemu | 70ae65f5d91462e1905a53236179fde21cda3a2f | static void bmdma_writeb(void *opaque, uint32_t addr, uint32_t val)
{
BMDMAState *bm = opaque;
PCIIDEState *pci_dev = pci_from_bm(bm);
#ifdef DEBUG_IDE
printf("bmdma: writeb 0x%02x : 0x%02x\n", addr, val);
#endif
switch(addr & 3) {
case 1:
pci_dev->dev.config[MRDMODE] =
(pci_dev->dev.config[MRDMODE] & ~0x30) | (val & 0x30);
cmd646_update_irq(pci_dev);
break;
case 2:
bm->status = (val & 0x60) | (bm->status & 1) | (bm->status & ~val & 0x06);
break;
case 3:
if (bm->unit == 0)
pci_dev->dev.config[UDIDETCR0] = val;
else
pci_dev->dev.config[UDIDETCR1] = val;
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, uint32_t VAR_1, uint32_t VAR_2)
{
BMDMAState *bm = VAR_0;
PCIIDEState *pci_dev = pci_from_bm(bm);
#ifdef DEBUG_IDE
printf("bmdma: writeb 0x%02x : 0x%02x\n", VAR_1, VAR_2);
#endif
switch(VAR_1 & 3) {
case 1:
pci_dev->dev.config[MRDMODE] =
(pci_dev->dev.config[MRDMODE] & ~0x30) | (VAR_2 & 0x30);
cmd646_update_irq(pci_dev);
break;
case 2:
bm->status = (VAR_2 & 0x60) | (bm->status & 1) | (bm->status & ~VAR_2 & 0x06);
break;
case 3:
if (bm->unit == 0)
pci_dev->dev.config[UDIDETCR0] = VAR_2;
else
pci_dev->dev.config[UDIDETCR1] = VAR_2;
break;
}
}
| [
"static void FUNC_0(void *VAR_0, uint32_t VAR_1, uint32_t VAR_2)\n{",
"BMDMAState *bm = VAR_0;",
"PCIIDEState *pci_dev = pci_from_bm(bm);",
"#ifdef DEBUG_IDE\nprintf(\"bmdma: writeb 0x%02x : 0x%02x\\n\", VAR_1, VAR_2);",
"#endif\nswitch(VAR_1 & 3) {",
"case 1:\npci_dev->dev.config[MRDMODE] =\n(pci_dev->dev.config[MRDMODE] & ~0x30) | (VAR_2 & 0x30);",
"cmd646_update_irq(pci_dev);",
"break;",
"case 2:\nbm->status = (VAR_2 & 0x60) | (bm->status & 1) | (bm->status & ~VAR_2 & 0x06);",
"break;",
"case 3:\nif (bm->unit == 0)\npci_dev->dev.config[UDIDETCR0] = VAR_2;",
"else\npci_dev->dev.config[UDIDETCR1] = VAR_2;",
"break;",
"}",
"}"
] | [
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
]
] |
4,497 | static uint64_t empty_slot_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
DPRINTF("read from " TARGET_FMT_plx "\n", addr);
return 0;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t empty_slot_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
DPRINTF("read from " TARGET_FMT_plx "\n", addr);
return 0;
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,
unsigned size)
{
DPRINTF("read from " TARGET_FMT_plx "\n", addr);
return 0;
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned size)\n{",
"DPRINTF(\"read from \" TARGET_FMT_plx \"\\n\", addr);",
"return 0;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
]
] |
4,498 | static pxa2xx_timer_info *pxa2xx_timer_init(target_phys_addr_t base,
qemu_irq *irqs)
{
int i;
int iomemtype;
pxa2xx_timer_info *s;
s = (pxa2xx_timer_info *) qemu_mallocz(sizeof(pxa2xx_timer_info));
s->irq_enabled = 0;
s->oldclock = 0;
s->clock = 0;
s->lastload = qemu_get_clock(vm_clock);
s->reset3 = 0;
for (i = 0; i < 4; i ++) {
s->timer[i].value = 0;
s->timer[i].irq = irqs[i];
s->timer[i].info = s;
s->timer[i].num = i;
s->timer[i].level = 0;
s->timer[i].qtimer = qemu_new_timer(vm_clock,
pxa2xx_timer_tick, &s->timer[i]);
}
iomemtype = cpu_register_io_memory(pxa2xx_timer_readfn,
pxa2xx_timer_writefn, s, DEVICE_NATIVE_ENDIAN);
cpu_register_physical_memory(base, 0x00001000, iomemtype);
register_savevm(NULL, "pxa2xx_timer", 0, 0,
pxa2xx_timer_save, pxa2xx_timer_load, s);
return s;
}
| false | qemu | e1f8c729fa890c67bb4532f22c22ace6fb0e1aaf | static pxa2xx_timer_info *pxa2xx_timer_init(target_phys_addr_t base,
qemu_irq *irqs)
{
int i;
int iomemtype;
pxa2xx_timer_info *s;
s = (pxa2xx_timer_info *) qemu_mallocz(sizeof(pxa2xx_timer_info));
s->irq_enabled = 0;
s->oldclock = 0;
s->clock = 0;
s->lastload = qemu_get_clock(vm_clock);
s->reset3 = 0;
for (i = 0; i < 4; i ++) {
s->timer[i].value = 0;
s->timer[i].irq = irqs[i];
s->timer[i].info = s;
s->timer[i].num = i;
s->timer[i].level = 0;
s->timer[i].qtimer = qemu_new_timer(vm_clock,
pxa2xx_timer_tick, &s->timer[i]);
}
iomemtype = cpu_register_io_memory(pxa2xx_timer_readfn,
pxa2xx_timer_writefn, s, DEVICE_NATIVE_ENDIAN);
cpu_register_physical_memory(base, 0x00001000, iomemtype);
register_savevm(NULL, "pxa2xx_timer", 0, 0,
pxa2xx_timer_save, pxa2xx_timer_load, s);
return s;
}
| {
"code": [],
"line_no": []
} | static pxa2xx_timer_info *FUNC_0(target_phys_addr_t base,
qemu_irq *irqs)
{
int VAR_0;
int VAR_1;
pxa2xx_timer_info *s;
s = (pxa2xx_timer_info *) qemu_mallocz(sizeof(pxa2xx_timer_info));
s->irq_enabled = 0;
s->oldclock = 0;
s->clock = 0;
s->lastload = qemu_get_clock(vm_clock);
s->reset3 = 0;
for (VAR_0 = 0; VAR_0 < 4; VAR_0 ++) {
s->timer[VAR_0].value = 0;
s->timer[VAR_0].irq = irqs[VAR_0];
s->timer[VAR_0].info = s;
s->timer[VAR_0].num = VAR_0;
s->timer[VAR_0].level = 0;
s->timer[VAR_0].qtimer = qemu_new_timer(vm_clock,
pxa2xx_timer_tick, &s->timer[VAR_0]);
}
VAR_1 = cpu_register_io_memory(pxa2xx_timer_readfn,
pxa2xx_timer_writefn, s, DEVICE_NATIVE_ENDIAN);
cpu_register_physical_memory(base, 0x00001000, VAR_1);
register_savevm(NULL, "pxa2xx_timer", 0, 0,
pxa2xx_timer_save, pxa2xx_timer_load, s);
return s;
}
| [
"static pxa2xx_timer_info *FUNC_0(target_phys_addr_t base,\nqemu_irq *irqs)\n{",
"int VAR_0;",
"int VAR_1;",
"pxa2xx_timer_info *s;",
"s = (pxa2xx_timer_info *) qemu_mallocz(sizeof(pxa2xx_timer_info));",
"s->irq_enabled = 0;",
"s->oldclock = 0;",
"s->clock = 0;",
"s->lastload = qemu_get_clock(vm_clock);",
"s->reset3 = 0;",
"for (VAR_0 = 0; VAR_0 < 4; VAR_0 ++) {",
"s->timer[VAR_0].value = 0;",
"s->timer[VAR_0].irq = irqs[VAR_0];",
"s->timer[VAR_0].info = s;",
"s->timer[VAR_0].num = VAR_0;",
"s->timer[VAR_0].level = 0;",
"s->timer[VAR_0].qtimer = qemu_new_timer(vm_clock,\npxa2xx_timer_tick, &s->timer[VAR_0]);",
"}",
"VAR_1 = cpu_register_io_memory(pxa2xx_timer_readfn,\npxa2xx_timer_writefn, s, DEVICE_NATIVE_ENDIAN);",
"cpu_register_physical_memory(base, 0x00001000, VAR_1);",
"register_savevm(NULL, \"pxa2xx_timer\", 0, 0,\npxa2xx_timer_save, pxa2xx_timer_load, s);",
"return s;",
"}"
] | [
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
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
49,
51
],
[
53
],
[
57,
59
],
[
63
],
[
65
]
] |
4,499 | static int do_subchannel_work(SubchDev *sch)
{
if (sch->do_subchannel_work) {
return sch->do_subchannel_work(sch);
} else {
return -EINVAL;
}
}
| false | qemu | 9ea63c05d90ba85d819f9b2472ce6dfba7a403b4 | static int do_subchannel_work(SubchDev *sch)
{
if (sch->do_subchannel_work) {
return sch->do_subchannel_work(sch);
} else {
return -EINVAL;
}
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(SubchDev *VAR_0)
{
if (VAR_0->FUNC_0) {
return VAR_0->FUNC_0(VAR_0);
} else {
return -EINVAL;
}
}
| [
"static int FUNC_0(SubchDev *VAR_0)\n{",
"if (VAR_0->FUNC_0) {",
"return VAR_0->FUNC_0(VAR_0);",
"} else {",
"return -EINVAL;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
4,500 | void block_job_enter(BlockJob *job)
{
if (job->co && !job->busy) {
bdrv_coroutine_enter(blk_bs(job->blk), job->co);
}
}
| false | qemu | eb05e011e248c6fb6baee295e14fd206e136028c | void block_job_enter(BlockJob *job)
{
if (job->co && !job->busy) {
bdrv_coroutine_enter(blk_bs(job->blk), job->co);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(BlockJob *VAR_0)
{
if (VAR_0->co && !VAR_0->busy) {
bdrv_coroutine_enter(blk_bs(VAR_0->blk), VAR_0->co);
}
}
| [
"void FUNC_0(BlockJob *VAR_0)\n{",
"if (VAR_0->co && !VAR_0->busy) {",
"bdrv_coroutine_enter(blk_bs(VAR_0->blk), VAR_0->co);",
"}",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
4,501 | static int get_physical_address (CPUMIPSState *env, hwaddr *physical,
int *prot, target_ulong real_address,
int rw, int access_type, int mmu_idx)
{
/* User mode can only access useg/xuseg */
int user_mode = mmu_idx == MIPS_HFLAG_UM;
int supervisor_mode = mmu_idx == MIPS_HFLAG_SM;
int kernel_mode = !user_mode && !supervisor_mode;
#if defined(TARGET_MIPS64)
int UX = (env->CP0_Status & (1 << CP0St_UX)) != 0;
int SX = (env->CP0_Status & (1 << CP0St_SX)) != 0;
int KX = (env->CP0_Status & (1 << CP0St_KX)) != 0;
#endif
int ret = TLBRET_MATCH;
/* effective address (modified for KVM T&E kernel segments) */
target_ulong address = real_address;
#define USEG_LIMIT 0x7FFFFFFFUL
#define KSEG0_BASE 0x80000000UL
#define KSEG1_BASE 0xA0000000UL
#define KSEG2_BASE 0xC0000000UL
#define KSEG3_BASE 0xE0000000UL
#define KVM_KSEG0_BASE 0x40000000UL
#define KVM_KSEG2_BASE 0x60000000UL
if (kvm_enabled()) {
/* KVM T&E adds guest kernel segments in useg */
if (real_address >= KVM_KSEG0_BASE) {
if (real_address < KVM_KSEG2_BASE) {
/* kseg0 */
address += KSEG0_BASE - KVM_KSEG0_BASE;
} else if (real_address <= USEG_LIMIT) {
/* kseg2/3 */
address += KSEG2_BASE - KVM_KSEG2_BASE;
}
}
}
if (address <= USEG_LIMIT) {
/* useg */
if (env->CP0_Status & (1 << CP0St_ERL)) {
*physical = address & 0xFFFFFFFF;
*prot = PAGE_READ | PAGE_WRITE;
} else {
ret = env->tlb->map_address(env, physical, prot, real_address, rw, access_type);
}
#if defined(TARGET_MIPS64)
} else if (address < 0x4000000000000000ULL) {
/* xuseg */
if (UX && address <= (0x3FFFFFFFFFFFFFFFULL & env->SEGMask)) {
ret = env->tlb->map_address(env, physical, prot, real_address, rw, access_type);
} else {
ret = TLBRET_BADADDR;
}
} else if (address < 0x8000000000000000ULL) {
/* xsseg */
if ((supervisor_mode || kernel_mode) &&
SX && address <= (0x7FFFFFFFFFFFFFFFULL & env->SEGMask)) {
ret = env->tlb->map_address(env, physical, prot, real_address, rw, access_type);
} else {
ret = TLBRET_BADADDR;
}
} else if (address < 0xC000000000000000ULL) {
/* xkphys */
if (kernel_mode && KX &&
(address & 0x07FFFFFFFFFFFFFFULL) <= env->PAMask) {
*physical = address & env->PAMask;
*prot = PAGE_READ | PAGE_WRITE;
} else {
ret = TLBRET_BADADDR;
}
} else if (address < 0xFFFFFFFF80000000ULL) {
/* xkseg */
if (kernel_mode && KX &&
address <= (0xFFFFFFFF7FFFFFFFULL & env->SEGMask)) {
ret = env->tlb->map_address(env, physical, prot, real_address, rw, access_type);
} else {
ret = TLBRET_BADADDR;
}
#endif
} else if (address < (int32_t)KSEG1_BASE) {
/* kseg0 */
if (kernel_mode) {
*physical = address - (int32_t)KSEG0_BASE;
*prot = PAGE_READ | PAGE_WRITE;
} else {
ret = TLBRET_BADADDR;
}
} else if (address < (int32_t)KSEG2_BASE) {
/* kseg1 */
if (kernel_mode) {
*physical = address - (int32_t)KSEG1_BASE;
*prot = PAGE_READ | PAGE_WRITE;
} else {
ret = TLBRET_BADADDR;
}
} else if (address < (int32_t)KSEG3_BASE) {
/* sseg (kseg2) */
if (supervisor_mode || kernel_mode) {
ret = env->tlb->map_address(env, physical, prot, real_address, rw, access_type);
} else {
ret = TLBRET_BADADDR;
}
} else {
/* kseg3 */
/* XXX: debug segment is not emulated */
if (kernel_mode) {
ret = env->tlb->map_address(env, physical, prot, real_address, rw, access_type);
} else {
ret = TLBRET_BADADDR;
}
}
return ret;
}
| false | qemu | 480e79aedd322fcfac17052caff21626ea7c78e2 | static int get_physical_address (CPUMIPSState *env, hwaddr *physical,
int *prot, target_ulong real_address,
int rw, int access_type, int mmu_idx)
{
int user_mode = mmu_idx == MIPS_HFLAG_UM;
int supervisor_mode = mmu_idx == MIPS_HFLAG_SM;
int kernel_mode = !user_mode && !supervisor_mode;
#if defined(TARGET_MIPS64)
int UX = (env->CP0_Status & (1 << CP0St_UX)) != 0;
int SX = (env->CP0_Status & (1 << CP0St_SX)) != 0;
int KX = (env->CP0_Status & (1 << CP0St_KX)) != 0;
#endif
int ret = TLBRET_MATCH;
target_ulong address = real_address;
#define USEG_LIMIT 0x7FFFFFFFUL
#define KSEG0_BASE 0x80000000UL
#define KSEG1_BASE 0xA0000000UL
#define KSEG2_BASE 0xC0000000UL
#define KSEG3_BASE 0xE0000000UL
#define KVM_KSEG0_BASE 0x40000000UL
#define KVM_KSEG2_BASE 0x60000000UL
if (kvm_enabled()) {
if (real_address >= KVM_KSEG0_BASE) {
if (real_address < KVM_KSEG2_BASE) {
address += KSEG0_BASE - KVM_KSEG0_BASE;
} else if (real_address <= USEG_LIMIT) {
address += KSEG2_BASE - KVM_KSEG2_BASE;
}
}
}
if (address <= USEG_LIMIT) {
if (env->CP0_Status & (1 << CP0St_ERL)) {
*physical = address & 0xFFFFFFFF;
*prot = PAGE_READ | PAGE_WRITE;
} else {
ret = env->tlb->map_address(env, physical, prot, real_address, rw, access_type);
}
#if defined(TARGET_MIPS64)
} else if (address < 0x4000000000000000ULL) {
if (UX && address <= (0x3FFFFFFFFFFFFFFFULL & env->SEGMask)) {
ret = env->tlb->map_address(env, physical, prot, real_address, rw, access_type);
} else {
ret = TLBRET_BADADDR;
}
} else if (address < 0x8000000000000000ULL) {
if ((supervisor_mode || kernel_mode) &&
SX && address <= (0x7FFFFFFFFFFFFFFFULL & env->SEGMask)) {
ret = env->tlb->map_address(env, physical, prot, real_address, rw, access_type);
} else {
ret = TLBRET_BADADDR;
}
} else if (address < 0xC000000000000000ULL) {
if (kernel_mode && KX &&
(address & 0x07FFFFFFFFFFFFFFULL) <= env->PAMask) {
*physical = address & env->PAMask;
*prot = PAGE_READ | PAGE_WRITE;
} else {
ret = TLBRET_BADADDR;
}
} else if (address < 0xFFFFFFFF80000000ULL) {
if (kernel_mode && KX &&
address <= (0xFFFFFFFF7FFFFFFFULL & env->SEGMask)) {
ret = env->tlb->map_address(env, physical, prot, real_address, rw, access_type);
} else {
ret = TLBRET_BADADDR;
}
#endif
} else if (address < (int32_t)KSEG1_BASE) {
if (kernel_mode) {
*physical = address - (int32_t)KSEG0_BASE;
*prot = PAGE_READ | PAGE_WRITE;
} else {
ret = TLBRET_BADADDR;
}
} else if (address < (int32_t)KSEG2_BASE) {
if (kernel_mode) {
*physical = address - (int32_t)KSEG1_BASE;
*prot = PAGE_READ | PAGE_WRITE;
} else {
ret = TLBRET_BADADDR;
}
} else if (address < (int32_t)KSEG3_BASE) {
if (supervisor_mode || kernel_mode) {
ret = env->tlb->map_address(env, physical, prot, real_address, rw, access_type);
} else {
ret = TLBRET_BADADDR;
}
} else {
if (kernel_mode) {
ret = env->tlb->map_address(env, physical, prot, real_address, rw, access_type);
} else {
ret = TLBRET_BADADDR;
}
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0 (CPUMIPSState *VAR_0, hwaddr *VAR_1,
int *VAR_2, target_ulong VAR_3,
int VAR_4, int VAR_5, int VAR_6)
{
int VAR_7 = VAR_6 == MIPS_HFLAG_UM;
int VAR_8 = VAR_6 == MIPS_HFLAG_SM;
int VAR_9 = !VAR_7 && !VAR_8;
#if defined(TARGET_MIPS64)
int UX = (VAR_0->CP0_Status & (1 << CP0St_UX)) != 0;
int SX = (VAR_0->CP0_Status & (1 << CP0St_SX)) != 0;
int KX = (VAR_0->CP0_Status & (1 << CP0St_KX)) != 0;
#endif
int VAR_10 = TLBRET_MATCH;
target_ulong address = VAR_3;
#define USEG_LIMIT 0x7FFFFFFFUL
#define KSEG0_BASE 0x80000000UL
#define KSEG1_BASE 0xA0000000UL
#define KSEG2_BASE 0xC0000000UL
#define KSEG3_BASE 0xE0000000UL
#define KVM_KSEG0_BASE 0x40000000UL
#define KVM_KSEG2_BASE 0x60000000UL
if (kvm_enabled()) {
if (VAR_3 >= KVM_KSEG0_BASE) {
if (VAR_3 < KVM_KSEG2_BASE) {
address += KSEG0_BASE - KVM_KSEG0_BASE;
} else if (VAR_3 <= USEG_LIMIT) {
address += KSEG2_BASE - KVM_KSEG2_BASE;
}
}
}
if (address <= USEG_LIMIT) {
if (VAR_0->CP0_Status & (1 << CP0St_ERL)) {
*VAR_1 = address & 0xFFFFFFFF;
*VAR_2 = PAGE_READ | PAGE_WRITE;
} else {
VAR_10 = VAR_0->tlb->map_address(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);
}
#if defined(TARGET_MIPS64)
} else if (address < 0x4000000000000000ULL) {
if (UX && address <= (0x3FFFFFFFFFFFFFFFULL & VAR_0->SEGMask)) {
VAR_10 = VAR_0->tlb->map_address(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);
} else {
VAR_10 = TLBRET_BADADDR;
}
} else if (address < 0x8000000000000000ULL) {
if ((VAR_8 || VAR_9) &&
SX && address <= (0x7FFFFFFFFFFFFFFFULL & VAR_0->SEGMask)) {
VAR_10 = VAR_0->tlb->map_address(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);
} else {
VAR_10 = TLBRET_BADADDR;
}
} else if (address < 0xC000000000000000ULL) {
if (VAR_9 && KX &&
(address & 0x07FFFFFFFFFFFFFFULL) <= VAR_0->PAMask) {
*VAR_1 = address & VAR_0->PAMask;
*VAR_2 = PAGE_READ | PAGE_WRITE;
} else {
VAR_10 = TLBRET_BADADDR;
}
} else if (address < 0xFFFFFFFF80000000ULL) {
if (VAR_9 && KX &&
address <= (0xFFFFFFFF7FFFFFFFULL & VAR_0->SEGMask)) {
VAR_10 = VAR_0->tlb->map_address(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);
} else {
VAR_10 = TLBRET_BADADDR;
}
#endif
} else if (address < (int32_t)KSEG1_BASE) {
if (VAR_9) {
*VAR_1 = address - (int32_t)KSEG0_BASE;
*VAR_2 = PAGE_READ | PAGE_WRITE;
} else {
VAR_10 = TLBRET_BADADDR;
}
} else if (address < (int32_t)KSEG2_BASE) {
if (VAR_9) {
*VAR_1 = address - (int32_t)KSEG1_BASE;
*VAR_2 = PAGE_READ | PAGE_WRITE;
} else {
VAR_10 = TLBRET_BADADDR;
}
} else if (address < (int32_t)KSEG3_BASE) {
if (VAR_8 || VAR_9) {
VAR_10 = VAR_0->tlb->map_address(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);
} else {
VAR_10 = TLBRET_BADADDR;
}
} else {
if (VAR_9) {
VAR_10 = VAR_0->tlb->map_address(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);
} else {
VAR_10 = TLBRET_BADADDR;
}
}
return VAR_10;
}
| [
"static int FUNC_0 (CPUMIPSState *VAR_0, hwaddr *VAR_1,\nint *VAR_2, target_ulong VAR_3,\nint VAR_4, int VAR_5, int VAR_6)\n{",
"int VAR_7 = VAR_6 == MIPS_HFLAG_UM;",
"int VAR_8 = VAR_6 == MIPS_HFLAG_SM;",
"int VAR_9 = !VAR_7 && !VAR_8;",
"#if defined(TARGET_MIPS64)\nint UX = (VAR_0->CP0_Status & (1 << CP0St_UX)) != 0;",
"int SX = (VAR_0->CP0_Status & (1 << CP0St_SX)) != 0;",
"int KX = (VAR_0->CP0_Status & (1 << CP0St_KX)) != 0;",
"#endif\nint VAR_10 = TLBRET_MATCH;",
"target_ulong address = VAR_3;",
"#define USEG_LIMIT 0x7FFFFFFFUL\n#define KSEG0_BASE 0x80000000UL\n#define KSEG1_BASE 0xA0000000UL\n#define KSEG2_BASE 0xC0000000UL\n#define KSEG3_BASE 0xE0000000UL\n#define KVM_KSEG0_BASE 0x40000000UL\n#define KVM_KSEG2_BASE 0x60000000UL\nif (kvm_enabled()) {",
"if (VAR_3 >= KVM_KSEG0_BASE) {",
"if (VAR_3 < KVM_KSEG2_BASE) {",
"address += KSEG0_BASE - KVM_KSEG0_BASE;",
"} else if (VAR_3 <= USEG_LIMIT) {",
"address += KSEG2_BASE - KVM_KSEG2_BASE;",
"}",
"}",
"}",
"if (address <= USEG_LIMIT) {",
"if (VAR_0->CP0_Status & (1 << CP0St_ERL)) {",
"*VAR_1 = address & 0xFFFFFFFF;",
"*VAR_2 = PAGE_READ | PAGE_WRITE;",
"} else {",
"VAR_10 = VAR_0->tlb->map_address(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);",
"}",
"#if defined(TARGET_MIPS64)\n} else if (address < 0x4000000000000000ULL) {",
"if (UX && address <= (0x3FFFFFFFFFFFFFFFULL & VAR_0->SEGMask)) {",
"VAR_10 = VAR_0->tlb->map_address(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);",
"} else {",
"VAR_10 = TLBRET_BADADDR;",
"}",
"} else if (address < 0x8000000000000000ULL) {",
"if ((VAR_8 || VAR_9) &&\nSX && address <= (0x7FFFFFFFFFFFFFFFULL & VAR_0->SEGMask)) {",
"VAR_10 = VAR_0->tlb->map_address(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);",
"} else {",
"VAR_10 = TLBRET_BADADDR;",
"}",
"} else if (address < 0xC000000000000000ULL) {",
"if (VAR_9 && KX &&\n(address & 0x07FFFFFFFFFFFFFFULL) <= VAR_0->PAMask) {",
"*VAR_1 = address & VAR_0->PAMask;",
"*VAR_2 = PAGE_READ | PAGE_WRITE;",
"} else {",
"VAR_10 = TLBRET_BADADDR;",
"}",
"} else if (address < 0xFFFFFFFF80000000ULL) {",
"if (VAR_9 && KX &&\naddress <= (0xFFFFFFFF7FFFFFFFULL & VAR_0->SEGMask)) {",
"VAR_10 = VAR_0->tlb->map_address(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);",
"} else {",
"VAR_10 = TLBRET_BADADDR;",
"}",
"#endif\n} else if (address < (int32_t)KSEG1_BASE) {",
"if (VAR_9) {",
"*VAR_1 = address - (int32_t)KSEG0_BASE;",
"*VAR_2 = PAGE_READ | PAGE_WRITE;",
"} else {",
"VAR_10 = TLBRET_BADADDR;",
"}",
"} else if (address < (int32_t)KSEG2_BASE) {",
"if (VAR_9) {",
"*VAR_1 = address - (int32_t)KSEG1_BASE;",
"*VAR_2 = PAGE_READ | PAGE_WRITE;",
"} else {",
"VAR_10 = TLBRET_BADADDR;",
"}",
"} else if (address < (int32_t)KSEG3_BASE) {",
"if (VAR_8 || VAR_9) {",
"VAR_10 = VAR_0->tlb->map_address(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);",
"} else {",
"VAR_10 = TLBRET_BADADDR;",
"}",
"} else {",
"if (VAR_9) {",
"VAR_10 = VAR_0->tlb->map_address(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);",
"} else {",
"VAR_10 = TLBRET_BADADDR;",
"}",
"}",
"return VAR_10;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
11
],
[
13
],
[
15
],
[
17,
19
],
[
21
],
[
23
],
[
25,
27
],
[
31
],
[
35,
37,
39,
41,
43,
47,
49,
53
],
[
57
],
[
59
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95,
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115,
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
131,
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149,
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161,
163
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
]
] |
4,502 | static int rv30_decode_mb_info(RV34DecContext *r)
{
static const int rv30_p_types[6] = { RV34_MB_SKIP, RV34_MB_P_16x16, RV34_MB_P_8x8, -1, RV34_MB_TYPE_INTRA, RV34_MB_TYPE_INTRA16x16 };
static const int rv30_b_types[6] = { RV34_MB_SKIP, RV34_MB_B_DIRECT, RV34_MB_B_FORWARD, RV34_MB_B_BACKWARD, RV34_MB_TYPE_INTRA, RV34_MB_TYPE_INTRA16x16 };
MpegEncContext *s = &r->s;
GetBitContext *gb = &s->gb;
int code = svq3_get_ue_golomb(gb);
if(code > 11){
av_log(s->avctx, AV_LOG_ERROR, "Incorrect MB type code\n");
return -1;
}
if(code > 5){
av_log(s->avctx, AV_LOG_ERROR, "dquant needed\n");
code -= 6;
}
if(s->pict_type != AV_PICTURE_TYPE_B)
return rv30_p_types[code];
else
return rv30_b_types[code];
}
| false | FFmpeg | 979bea13003ef489d95d2538ac2fb1c26c6f103b | static int rv30_decode_mb_info(RV34DecContext *r)
{
static const int rv30_p_types[6] = { RV34_MB_SKIP, RV34_MB_P_16x16, RV34_MB_P_8x8, -1, RV34_MB_TYPE_INTRA, RV34_MB_TYPE_INTRA16x16 };
static const int rv30_b_types[6] = { RV34_MB_SKIP, RV34_MB_B_DIRECT, RV34_MB_B_FORWARD, RV34_MB_B_BACKWARD, RV34_MB_TYPE_INTRA, RV34_MB_TYPE_INTRA16x16 };
MpegEncContext *s = &r->s;
GetBitContext *gb = &s->gb;
int code = svq3_get_ue_golomb(gb);
if(code > 11){
av_log(s->avctx, AV_LOG_ERROR, "Incorrect MB type code\n");
return -1;
}
if(code > 5){
av_log(s->avctx, AV_LOG_ERROR, "dquant needed\n");
code -= 6;
}
if(s->pict_type != AV_PICTURE_TYPE_B)
return rv30_p_types[code];
else
return rv30_b_types[code];
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(RV34DecContext *VAR_0)
{
static const int VAR_1[6] = { RV34_MB_SKIP, RV34_MB_P_16x16, RV34_MB_P_8x8, -1, RV34_MB_TYPE_INTRA, RV34_MB_TYPE_INTRA16x16 };
static const int VAR_2[6] = { RV34_MB_SKIP, RV34_MB_B_DIRECT, RV34_MB_B_FORWARD, RV34_MB_B_BACKWARD, RV34_MB_TYPE_INTRA, RV34_MB_TYPE_INTRA16x16 };
MpegEncContext *s = &VAR_0->s;
GetBitContext *gb = &s->gb;
int VAR_3 = svq3_get_ue_golomb(gb);
if(VAR_3 > 11){
av_log(s->avctx, AV_LOG_ERROR, "Incorrect MB type VAR_3\n");
return -1;
}
if(VAR_3 > 5){
av_log(s->avctx, AV_LOG_ERROR, "dquant needed\n");
VAR_3 -= 6;
}
if(s->pict_type != AV_PICTURE_TYPE_B)
return VAR_1[VAR_3];
else
return VAR_2[VAR_3];
}
| [
"static int FUNC_0(RV34DecContext *VAR_0)\n{",
"static const int VAR_1[6] = { RV34_MB_SKIP, RV34_MB_P_16x16, RV34_MB_P_8x8, -1, RV34_MB_TYPE_INTRA, RV34_MB_TYPE_INTRA16x16 };",
"static const int VAR_2[6] = { RV34_MB_SKIP, RV34_MB_B_DIRECT, RV34_MB_B_FORWARD, RV34_MB_B_BACKWARD, RV34_MB_TYPE_INTRA, RV34_MB_TYPE_INTRA16x16 };",
"MpegEncContext *s = &VAR_0->s;",
"GetBitContext *gb = &s->gb;",
"int VAR_3 = svq3_get_ue_golomb(gb);",
"if(VAR_3 > 11){",
"av_log(s->avctx, AV_LOG_ERROR, \"Incorrect MB type VAR_3\\n\");",
"return -1;",
"}",
"if(VAR_3 > 5){",
"av_log(s->avctx, AV_LOG_ERROR, \"dquant needed\\n\");",
"VAR_3 -= 6;",
"}",
"if(s->pict_type != AV_PICTURE_TYPE_B)\nreturn VAR_1[VAR_3];",
"else\nreturn VAR_2[VAR_3];",
"}"
] | [
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
]
] |
4,503 | static ssize_t test_block_write_func(QCryptoBlock *block,
size_t offset,
const uint8_t *buf,
size_t buflen,
Error **errp,
void *opaque)
{
Buffer *header = opaque;
g_assert_cmpint(buflen + offset, <=, header->capacity);
memcpy(header->buffer + offset, buf, buflen);
header->offset = offset + buflen;
return buflen;
}
| false | qemu | 375092332eeaa6e47561ce47fd36144cdaf964d0 | static ssize_t test_block_write_func(QCryptoBlock *block,
size_t offset,
const uint8_t *buf,
size_t buflen,
Error **errp,
void *opaque)
{
Buffer *header = opaque;
g_assert_cmpint(buflen + offset, <=, header->capacity);
memcpy(header->buffer + offset, buf, buflen);
header->offset = offset + buflen;
return buflen;
}
| {
"code": [],
"line_no": []
} | static ssize_t FUNC_0(QCryptoBlock *block,
size_t offset,
const uint8_t *buf,
size_t buflen,
Error **errp,
void *opaque)
{
Buffer *header = opaque;
g_assert_cmpint(buflen + offset, <=, header->capacity);
memcpy(header->buffer + offset, buf, buflen);
header->offset = offset + buflen;
return buflen;
}
| [
"static ssize_t FUNC_0(QCryptoBlock *block,\nsize_t offset,\nconst uint8_t *buf,\nsize_t buflen,\nError **errp,\nvoid *opaque)\n{",
"Buffer *header = opaque;",
"g_assert_cmpint(buflen + offset, <=, header->capacity);",
"memcpy(header->buffer + offset, buf, buflen);",
"header->offset = offset + buflen;",
"return buflen;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13
],
[
15
],
[
19
],
[
23
],
[
25
],
[
29
],
[
31
]
] |
4,504 | int net_init_vde(const NetClientOptions *opts, const char *name,
NetClientState *peer, Error **errp)
{
/* FIXME error_setg(errp, ...) on failure */
const NetdevVdeOptions *vde;
assert(opts->type == NET_CLIENT_OPTIONS_KIND_VDE);
vde = opts->u.vde;
/* missing optional values have been initialized to "all bits zero" */
if (net_vde_init(peer, "vde", name, vde->sock, vde->port, vde->group,
vde->has_mode ? vde->mode : 0700) == -1) {
return -1;
}
return 0;
}
| false | qemu | 32bafa8fdd098d52fbf1102d5a5e48d29398c0aa | int net_init_vde(const NetClientOptions *opts, const char *name,
NetClientState *peer, Error **errp)
{
const NetdevVdeOptions *vde;
assert(opts->type == NET_CLIENT_OPTIONS_KIND_VDE);
vde = opts->u.vde;
if (net_vde_init(peer, "vde", name, vde->sock, vde->port, vde->group,
vde->has_mode ? vde->mode : 0700) == -1) {
return -1;
}
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(const NetClientOptions *VAR_0, const char *VAR_1,
NetClientState *VAR_2, Error **VAR_3)
{
const NetdevVdeOptions *VAR_4;
assert(VAR_0->type == NET_CLIENT_OPTIONS_KIND_VDE);
VAR_4 = VAR_0->u.VAR_4;
if (net_vde_init(VAR_2, "VAR_4", VAR_1, VAR_4->sock, VAR_4->port, VAR_4->group,
VAR_4->has_mode ? VAR_4->mode : 0700) == -1) {
return -1;
}
return 0;
}
| [
"int FUNC_0(const NetClientOptions *VAR_0, const char *VAR_1,\nNetClientState *VAR_2, Error **VAR_3)\n{",
"const NetdevVdeOptions *VAR_4;",
"assert(VAR_0->type == NET_CLIENT_OPTIONS_KIND_VDE);",
"VAR_4 = VAR_0->u.VAR_4;",
"if (net_vde_init(VAR_2, \"VAR_4\", VAR_1, VAR_4->sock, VAR_4->port, VAR_4->group,\nVAR_4->has_mode ? VAR_4->mode : 0700) == -1) {",
"return -1;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
9
],
[
13
],
[
15
],
[
21,
23
],
[
25
],
[
27
],
[
31
],
[
33
]
] |
4,505 | static void tcx_rstip_writel(void *opaque, hwaddr addr,
uint64_t val, unsigned size)
{
TCXState *s = opaque;
int i;
uint32_t col;
if (!(addr & 4)) {
s->tmpblit = val;
} else {
addr = (addr >> 3) & 0xfffff;
col = cpu_to_be32(s->tmpblit);
if (s->depth == 24) {
for (i = 0; i < 32; i++) {
if (val & 0x80000000) {
s->vram[addr + i] = s->tmpblit;
s->vram24[addr + i] = col;
s->cplane[addr + i] = col;
}
val <<= 1;
}
} else {
for (i = 0; i < 32; i++) {
if (val & 0x80000000) {
s->vram[addr + i] = s->tmpblit;
}
val <<= 1;
}
}
memory_region_set_dirty(&s->vram_mem, addr, 32);
}
}
| false | qemu | 973945804d95878375b487c0c5c9b2556c5e4543 | static void tcx_rstip_writel(void *opaque, hwaddr addr,
uint64_t val, unsigned size)
{
TCXState *s = opaque;
int i;
uint32_t col;
if (!(addr & 4)) {
s->tmpblit = val;
} else {
addr = (addr >> 3) & 0xfffff;
col = cpu_to_be32(s->tmpblit);
if (s->depth == 24) {
for (i = 0; i < 32; i++) {
if (val & 0x80000000) {
s->vram[addr + i] = s->tmpblit;
s->vram24[addr + i] = col;
s->cplane[addr + i] = col;
}
val <<= 1;
}
} else {
for (i = 0; i < 32; i++) {
if (val & 0x80000000) {
s->vram[addr + i] = s->tmpblit;
}
val <<= 1;
}
}
memory_region_set_dirty(&s->vram_mem, addr, 32);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, hwaddr VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
TCXState *s = VAR_0;
int VAR_4;
uint32_t col;
if (!(VAR_1 & 4)) {
s->tmpblit = VAR_2;
} else {
VAR_1 = (VAR_1 >> 3) & 0xfffff;
col = cpu_to_be32(s->tmpblit);
if (s->depth == 24) {
for (VAR_4 = 0; VAR_4 < 32; VAR_4++) {
if (VAR_2 & 0x80000000) {
s->vram[VAR_1 + VAR_4] = s->tmpblit;
s->vram24[VAR_1 + VAR_4] = col;
s->cplane[VAR_1 + VAR_4] = col;
}
VAR_2 <<= 1;
}
} else {
for (VAR_4 = 0; VAR_4 < 32; VAR_4++) {
if (VAR_2 & 0x80000000) {
s->vram[VAR_1 + VAR_4] = s->tmpblit;
}
VAR_2 <<= 1;
}
}
memory_region_set_dirty(&s->vram_mem, VAR_1, 32);
}
}
| [
"static void FUNC_0(void *VAR_0, hwaddr VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"TCXState *s = VAR_0;",
"int VAR_4;",
"uint32_t col;",
"if (!(VAR_1 & 4)) {",
"s->tmpblit = VAR_2;",
"} else {",
"VAR_1 = (VAR_1 >> 3) & 0xfffff;",
"col = cpu_to_be32(s->tmpblit);",
"if (s->depth == 24) {",
"for (VAR_4 = 0; VAR_4 < 32; VAR_4++) {",
"if (VAR_2 & 0x80000000) {",
"s->vram[VAR_1 + VAR_4] = s->tmpblit;",
"s->vram24[VAR_1 + VAR_4] = col;",
"s->cplane[VAR_1 + VAR_4] = col;",
"}",
"VAR_2 <<= 1;",
"}",
"} else {",
"for (VAR_4 = 0; VAR_4 < 32; VAR_4++) {",
"if (VAR_2 & 0x80000000) {",
"s->vram[VAR_1 + VAR_4] = s->tmpblit;",
"}",
"VAR_2 <<= 1;",
"}",
"}",
"memory_region_set_dirty(&s->vram_mem, VAR_1, 32);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
]
] |
4,506 | static int load_flat_file(struct linux_binprm * bprm,
struct lib_info *libinfo, int id, abi_ulong *extra_stack)
{
struct flat_hdr * hdr;
abi_ulong textpos = 0, datapos = 0;
abi_long result;
abi_ulong realdatastart = 0;
abi_ulong text_len, data_len, bss_len, stack_len, flags;
abi_ulong memp = 0; /* for finding the brk area */
abi_ulong extra;
abi_ulong reloc = 0, rp;
int i, rev, relocs = 0;
abi_ulong fpos;
abi_ulong start_code, end_code;
abi_ulong indx_len;
hdr = ((struct flat_hdr *) bprm->buf); /* exec-header */
text_len = ntohl(hdr->data_start);
data_len = ntohl(hdr->data_end) - ntohl(hdr->data_start);
bss_len = ntohl(hdr->bss_end) - ntohl(hdr->data_end);
stack_len = ntohl(hdr->stack_size);
if (extra_stack) {
stack_len += *extra_stack;
*extra_stack = stack_len;
}
relocs = ntohl(hdr->reloc_count);
flags = ntohl(hdr->flags);
rev = ntohl(hdr->rev);
DBG_FLT("BINFMT_FLAT: Loading file: %s\n", bprm->filename);
if (rev != FLAT_VERSION && rev != OLD_FLAT_VERSION) {
fprintf(stderr, "BINFMT_FLAT: bad magic/rev (0x%x, need 0x%x)\n",
rev, (int) FLAT_VERSION);
return -ENOEXEC;
}
/* Don't allow old format executables to use shared libraries */
if (rev == OLD_FLAT_VERSION && id != 0) {
fprintf(stderr, "BINFMT_FLAT: shared libraries are not available\n");
return -ENOEXEC;
}
/*
* fix up the flags for the older format, there were all kinds
* of endian hacks, this only works for the simple cases
*/
if (rev == OLD_FLAT_VERSION && flat_old_ram_flag(flags))
flags = FLAT_FLAG_RAM;
#ifndef CONFIG_BINFMT_ZFLAT
if (flags & (FLAT_FLAG_GZIP|FLAT_FLAG_GZDATA)) {
fprintf(stderr, "Support for ZFLAT executables is not enabled\n");
return -ENOEXEC;
}
#endif
/*
* calculate the extra space we need to map in
*/
extra = relocs * sizeof(abi_ulong);
if (extra < bss_len + stack_len)
extra = bss_len + stack_len;
/* Add space for library base pointers. Make sure this does not
misalign the doesn't misalign the data segment. */
indx_len = MAX_SHARED_LIBS * sizeof(abi_ulong);
indx_len = (indx_len + 15) & ~(abi_ulong)15;
/*
* there are a couple of cases here, the separate code/data
* case, and then the fully copied to RAM case which lumps
* it all together.
*/
if ((flags & (FLAT_FLAG_RAM|FLAT_FLAG_GZIP)) == 0) {
/*
* this should give us a ROM ptr, but if it doesn't we don't
* really care
*/
DBG_FLT("BINFMT_FLAT: ROM mapping of file (we hope)\n");
textpos = target_mmap(0, text_len, PROT_READ|PROT_EXEC,
MAP_PRIVATE, bprm->fd, 0);
if (textpos == -1) {
fprintf(stderr, "Unable to mmap process text\n");
return -1;
}
realdatastart = target_mmap(0, data_len + extra + indx_len,
PROT_READ|PROT_WRITE|PROT_EXEC,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (realdatastart == -1) {
fprintf(stderr, "Unable to allocate RAM for process data\n");
return realdatastart;
}
datapos = realdatastart + indx_len;
DBG_FLT("BINFMT_FLAT: Allocated data+bss+stack (%d bytes): %x\n",
(int)(data_len + bss_len + stack_len), (int)datapos);
fpos = ntohl(hdr->data_start);
#ifdef CONFIG_BINFMT_ZFLAT
if (flags & FLAT_FLAG_GZDATA) {
result = decompress_exec(bprm, fpos, (char *) datapos,
data_len + (relocs * sizeof(abi_ulong)))
} else
#endif
{
result = target_pread(bprm->fd, datapos,
data_len + (relocs * sizeof(abi_ulong)),
fpos);
}
if (result < 0) {
fprintf(stderr, "Unable to read data+bss\n");
return result;
}
reloc = datapos + (ntohl(hdr->reloc_start) - text_len);
memp = realdatastart;
} else {
textpos = target_mmap(0, text_len + data_len + extra + indx_len,
PROT_READ | PROT_EXEC | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (textpos == -1 ) {
fprintf(stderr, "Unable to allocate RAM for process text/data\n");
return -1;
}
realdatastart = textpos + ntohl(hdr->data_start);
datapos = realdatastart + indx_len;
reloc = (textpos + ntohl(hdr->reloc_start) + indx_len);
memp = textpos;
#ifdef CONFIG_BINFMT_ZFLAT
#error code needs checking
/*
* load it all in and treat it like a RAM load from now on
*/
if (flags & FLAT_FLAG_GZIP) {
result = decompress_exec(bprm, sizeof (struct flat_hdr),
(((char *) textpos) + sizeof (struct flat_hdr)),
(text_len + data_len + (relocs * sizeof(unsigned long))
- sizeof (struct flat_hdr)),
0);
memmove((void *) datapos, (void *) realdatastart,
data_len + (relocs * sizeof(unsigned long)));
} else if (flags & FLAT_FLAG_GZDATA) {
fpos = 0;
result = bprm->file->f_op->read(bprm->file,
(char *) textpos, text_len, &fpos);
if (result < (unsigned long) -4096)
result = decompress_exec(bprm, text_len, (char *) datapos,
data_len + (relocs * sizeof(unsigned long)), 0);
}
else
#endif
{
result = target_pread(bprm->fd, textpos,
text_len, 0);
if (result >= 0) {
result = target_pread(bprm->fd, datapos,
data_len + (relocs * sizeof(abi_ulong)),
ntohl(hdr->data_start));
}
}
if (result < 0) {
fprintf(stderr, "Unable to read code+data+bss\n");
return result;
}
}
DBG_FLT("Mapping is 0x%x, Entry point is 0x%x, data_start is 0x%x\n",
(int)textpos, 0x00ffffff&ntohl(hdr->entry),
ntohl(hdr->data_start));
/* The main program needs a little extra setup in the task structure */
start_code = textpos + sizeof (struct flat_hdr);
end_code = textpos + text_len;
DBG_FLT("%s %s: TEXT=%x-%x DATA=%x-%x BSS=%x-%x\n",
id ? "Lib" : "Load", bprm->filename,
(int) start_code, (int) end_code,
(int) datapos,
(int) (datapos + data_len),
(int) (datapos + data_len),
(int) (((datapos + data_len + bss_len) + 3) & ~3));
text_len -= sizeof(struct flat_hdr); /* the real code len */
/* Store the current module values into the global library structure */
libinfo[id].start_code = start_code;
libinfo[id].start_data = datapos;
libinfo[id].end_data = datapos + data_len;
libinfo[id].start_brk = datapos + data_len + bss_len;
libinfo[id].text_len = text_len;
libinfo[id].loaded = 1;
libinfo[id].entry = (0x00ffffff & ntohl(hdr->entry)) + textpos;
libinfo[id].build_date = ntohl(hdr->build_date);
/*
* We just load the allocations into some temporary memory to
* help simplify all this mumbo jumbo
*
* We've got two different sections of relocation entries.
* The first is the GOT which resides at the begining of the data segment
* and is terminated with a -1. This one can be relocated in place.
* The second is the extra relocation entries tacked after the image's
* data segment. These require a little more processing as the entry is
* really an offset into the image which contains an offset into the
* image.
*/
if (flags & FLAT_FLAG_GOTPIC) {
rp = datapos;
while (1) {
abi_ulong addr;
if (get_user_ual(addr, rp))
return -EFAULT;
if (addr == -1)
break;
if (addr) {
addr = calc_reloc(addr, libinfo, id, 0);
if (addr == RELOC_FAILED)
return -ENOEXEC;
if (put_user_ual(addr, rp))
return -EFAULT;
}
rp += sizeof(abi_ulong);
}
}
/*
* Now run through the relocation entries.
* We've got to be careful here as C++ produces relocatable zero
* entries in the constructor and destructor tables which are then
* tested for being not zero (which will always occur unless we're
* based from address zero). This causes an endless loop as __start
* is at zero. The solution used is to not relocate zero addresses.
* This has the negative side effect of not allowing a global data
* reference to be statically initialised to _stext (I've moved
* __start to address 4 so that is okay).
*/
if (rev > OLD_FLAT_VERSION) {
for (i = 0; i < relocs; i++) {
abi_ulong addr, relval;
/* Get the address of the pointer to be
relocated (of course, the address has to be
relocated first). */
if (get_user_ual(relval, reloc + i * sizeof(abi_ulong)))
return -EFAULT;
addr = flat_get_relocate_addr(relval);
rp = calc_reloc(addr, libinfo, id, 1);
if (rp == RELOC_FAILED)
return -ENOEXEC;
/* Get the pointer's value. */
if (get_user_ual(addr, rp))
return -EFAULT;
if (addr != 0) {
/*
* Do the relocation. PIC relocs in the data section are
* already in target order
*/
#ifndef TARGET_WORDS_BIGENDIAN
if ((flags & FLAT_FLAG_GOTPIC) == 0)
addr = bswap32(addr);
#endif
addr = calc_reloc(addr, libinfo, id, 0);
if (addr == RELOC_FAILED)
return -ENOEXEC;
/* Write back the relocated pointer. */
if (put_user_ual(addr, rp))
return -EFAULT;
}
}
} else {
for (i = 0; i < relocs; i++) {
abi_ulong relval;
if (get_user_ual(relval, reloc + i * sizeof(abi_ulong)))
return -EFAULT;
old_reloc(&libinfo[0], relval);
}
}
/* zero the BSS. */
memset((void *)((unsigned long)datapos + data_len), 0, bss_len);
return 0;
}
| false | qemu | c3109ba1b109f84929abbfe0462d910d5aa8617c | static int load_flat_file(struct linux_binprm * bprm,
struct lib_info *libinfo, int id, abi_ulong *extra_stack)
{
struct flat_hdr * hdr;
abi_ulong textpos = 0, datapos = 0;
abi_long result;
abi_ulong realdatastart = 0;
abi_ulong text_len, data_len, bss_len, stack_len, flags;
abi_ulong memp = 0;
abi_ulong extra;
abi_ulong reloc = 0, rp;
int i, rev, relocs = 0;
abi_ulong fpos;
abi_ulong start_code, end_code;
abi_ulong indx_len;
hdr = ((struct flat_hdr *) bprm->buf);
text_len = ntohl(hdr->data_start);
data_len = ntohl(hdr->data_end) - ntohl(hdr->data_start);
bss_len = ntohl(hdr->bss_end) - ntohl(hdr->data_end);
stack_len = ntohl(hdr->stack_size);
if (extra_stack) {
stack_len += *extra_stack;
*extra_stack = stack_len;
}
relocs = ntohl(hdr->reloc_count);
flags = ntohl(hdr->flags);
rev = ntohl(hdr->rev);
DBG_FLT("BINFMT_FLAT: Loading file: %s\n", bprm->filename);
if (rev != FLAT_VERSION && rev != OLD_FLAT_VERSION) {
fprintf(stderr, "BINFMT_FLAT: bad magic/rev (0x%x, need 0x%x)\n",
rev, (int) FLAT_VERSION);
return -ENOEXEC;
}
if (rev == OLD_FLAT_VERSION && id != 0) {
fprintf(stderr, "BINFMT_FLAT: shared libraries are not available\n");
return -ENOEXEC;
}
if (rev == OLD_FLAT_VERSION && flat_old_ram_flag(flags))
flags = FLAT_FLAG_RAM;
#ifndef CONFIG_BINFMT_ZFLAT
if (flags & (FLAT_FLAG_GZIP|FLAT_FLAG_GZDATA)) {
fprintf(stderr, "Support for ZFLAT executables is not enabled\n");
return -ENOEXEC;
}
#endif
extra = relocs * sizeof(abi_ulong);
if (extra < bss_len + stack_len)
extra = bss_len + stack_len;
indx_len = MAX_SHARED_LIBS * sizeof(abi_ulong);
indx_len = (indx_len + 15) & ~(abi_ulong)15;
if ((flags & (FLAT_FLAG_RAM|FLAT_FLAG_GZIP)) == 0) {
DBG_FLT("BINFMT_FLAT: ROM mapping of file (we hope)\n");
textpos = target_mmap(0, text_len, PROT_READ|PROT_EXEC,
MAP_PRIVATE, bprm->fd, 0);
if (textpos == -1) {
fprintf(stderr, "Unable to mmap process text\n");
return -1;
}
realdatastart = target_mmap(0, data_len + extra + indx_len,
PROT_READ|PROT_WRITE|PROT_EXEC,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (realdatastart == -1) {
fprintf(stderr, "Unable to allocate RAM for process data\n");
return realdatastart;
}
datapos = realdatastart + indx_len;
DBG_FLT("BINFMT_FLAT: Allocated data+bss+stack (%d bytes): %x\n",
(int)(data_len + bss_len + stack_len), (int)datapos);
fpos = ntohl(hdr->data_start);
#ifdef CONFIG_BINFMT_ZFLAT
if (flags & FLAT_FLAG_GZDATA) {
result = decompress_exec(bprm, fpos, (char *) datapos,
data_len + (relocs * sizeof(abi_ulong)))
} else
#endif
{
result = target_pread(bprm->fd, datapos,
data_len + (relocs * sizeof(abi_ulong)),
fpos);
}
if (result < 0) {
fprintf(stderr, "Unable to read data+bss\n");
return result;
}
reloc = datapos + (ntohl(hdr->reloc_start) - text_len);
memp = realdatastart;
} else {
textpos = target_mmap(0, text_len + data_len + extra + indx_len,
PROT_READ | PROT_EXEC | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (textpos == -1 ) {
fprintf(stderr, "Unable to allocate RAM for process text/data\n");
return -1;
}
realdatastart = textpos + ntohl(hdr->data_start);
datapos = realdatastart + indx_len;
reloc = (textpos + ntohl(hdr->reloc_start) + indx_len);
memp = textpos;
#ifdef CONFIG_BINFMT_ZFLAT
#error code needs checking
if (flags & FLAT_FLAG_GZIP) {
result = decompress_exec(bprm, sizeof (struct flat_hdr),
(((char *) textpos) + sizeof (struct flat_hdr)),
(text_len + data_len + (relocs * sizeof(unsigned long))
- sizeof (struct flat_hdr)),
0);
memmove((void *) datapos, (void *) realdatastart,
data_len + (relocs * sizeof(unsigned long)));
} else if (flags & FLAT_FLAG_GZDATA) {
fpos = 0;
result = bprm->file->f_op->read(bprm->file,
(char *) textpos, text_len, &fpos);
if (result < (unsigned long) -4096)
result = decompress_exec(bprm, text_len, (char *) datapos,
data_len + (relocs * sizeof(unsigned long)), 0);
}
else
#endif
{
result = target_pread(bprm->fd, textpos,
text_len, 0);
if (result >= 0) {
result = target_pread(bprm->fd, datapos,
data_len + (relocs * sizeof(abi_ulong)),
ntohl(hdr->data_start));
}
}
if (result < 0) {
fprintf(stderr, "Unable to read code+data+bss\n");
return result;
}
}
DBG_FLT("Mapping is 0x%x, Entry point is 0x%x, data_start is 0x%x\n",
(int)textpos, 0x00ffffff&ntohl(hdr->entry),
ntohl(hdr->data_start));
start_code = textpos + sizeof (struct flat_hdr);
end_code = textpos + text_len;
DBG_FLT("%s %s: TEXT=%x-%x DATA=%x-%x BSS=%x-%x\n",
id ? "Lib" : "Load", bprm->filename,
(int) start_code, (int) end_code,
(int) datapos,
(int) (datapos + data_len),
(int) (datapos + data_len),
(int) (((datapos + data_len + bss_len) + 3) & ~3));
text_len -= sizeof(struct flat_hdr);
libinfo[id].start_code = start_code;
libinfo[id].start_data = datapos;
libinfo[id].end_data = datapos + data_len;
libinfo[id].start_brk = datapos + data_len + bss_len;
libinfo[id].text_len = text_len;
libinfo[id].loaded = 1;
libinfo[id].entry = (0x00ffffff & ntohl(hdr->entry)) + textpos;
libinfo[id].build_date = ntohl(hdr->build_date);
if (flags & FLAT_FLAG_GOTPIC) {
rp = datapos;
while (1) {
abi_ulong addr;
if (get_user_ual(addr, rp))
return -EFAULT;
if (addr == -1)
break;
if (addr) {
addr = calc_reloc(addr, libinfo, id, 0);
if (addr == RELOC_FAILED)
return -ENOEXEC;
if (put_user_ual(addr, rp))
return -EFAULT;
}
rp += sizeof(abi_ulong);
}
}
if (rev > OLD_FLAT_VERSION) {
for (i = 0; i < relocs; i++) {
abi_ulong addr, relval;
if (get_user_ual(relval, reloc + i * sizeof(abi_ulong)))
return -EFAULT;
addr = flat_get_relocate_addr(relval);
rp = calc_reloc(addr, libinfo, id, 1);
if (rp == RELOC_FAILED)
return -ENOEXEC;
if (get_user_ual(addr, rp))
return -EFAULT;
if (addr != 0) {
#ifndef TARGET_WORDS_BIGENDIAN
if ((flags & FLAT_FLAG_GOTPIC) == 0)
addr = bswap32(addr);
#endif
addr = calc_reloc(addr, libinfo, id, 0);
if (addr == RELOC_FAILED)
return -ENOEXEC;
if (put_user_ual(addr, rp))
return -EFAULT;
}
}
} else {
for (i = 0; i < relocs; i++) {
abi_ulong relval;
if (get_user_ual(relval, reloc + i * sizeof(abi_ulong)))
return -EFAULT;
old_reloc(&libinfo[0], relval);
}
}
memset((void *)((unsigned long)datapos + data_len), 0, bss_len);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(struct linux_binprm * VAR_0,
struct lib_info *VAR_1, int VAR_2, abi_ulong *VAR_3)
{
struct flat_hdr * VAR_4;
abi_ulong textpos = 0, datapos = 0;
abi_long result;
abi_ulong realdatastart = 0;
abi_ulong text_len, data_len, bss_len, stack_len, flags;
abi_ulong memp = 0;
abi_ulong extra;
abi_ulong reloc = 0, rp;
int VAR_5, VAR_6, VAR_7 = 0;
abi_ulong fpos;
abi_ulong start_code, end_code;
abi_ulong indx_len;
VAR_4 = ((struct flat_hdr *) VAR_0->buf);
text_len = ntohl(VAR_4->data_start);
data_len = ntohl(VAR_4->data_end) - ntohl(VAR_4->data_start);
bss_len = ntohl(VAR_4->bss_end) - ntohl(VAR_4->data_end);
stack_len = ntohl(VAR_4->stack_size);
if (VAR_3) {
stack_len += *VAR_3;
*VAR_3 = stack_len;
}
VAR_7 = ntohl(VAR_4->reloc_count);
flags = ntohl(VAR_4->flags);
VAR_6 = ntohl(VAR_4->VAR_6);
DBG_FLT("BINFMT_FLAT: Loading file: %s\n", VAR_0->filename);
if (VAR_6 != FLAT_VERSION && VAR_6 != OLD_FLAT_VERSION) {
fprintf(stderr, "BINFMT_FLAT: bad magic/VAR_6 (0x%x, need 0x%x)\n",
VAR_6, (int) FLAT_VERSION);
return -ENOEXEC;
}
if (VAR_6 == OLD_FLAT_VERSION && VAR_2 != 0) {
fprintf(stderr, "BINFMT_FLAT: shared libraries are not available\n");
return -ENOEXEC;
}
if (VAR_6 == OLD_FLAT_VERSION && flat_old_ram_flag(flags))
flags = FLAT_FLAG_RAM;
#ifndef CONFIG_BINFMT_ZFLAT
if (flags & (FLAT_FLAG_GZIP|FLAT_FLAG_GZDATA)) {
fprintf(stderr, "Support for ZFLAT executables is not enabled\n");
return -ENOEXEC;
}
#endif
extra = VAR_7 * sizeof(abi_ulong);
if (extra < bss_len + stack_len)
extra = bss_len + stack_len;
indx_len = MAX_SHARED_LIBS * sizeof(abi_ulong);
indx_len = (indx_len + 15) & ~(abi_ulong)15;
if ((flags & (FLAT_FLAG_RAM|FLAT_FLAG_GZIP)) == 0) {
DBG_FLT("BINFMT_FLAT: ROM mapping of file (we hope)\n");
textpos = target_mmap(0, text_len, PROT_READ|PROT_EXEC,
MAP_PRIVATE, VAR_0->fd, 0);
if (textpos == -1) {
fprintf(stderr, "Unable to mmap process text\n");
return -1;
}
realdatastart = target_mmap(0, data_len + extra + indx_len,
PROT_READ|PROT_WRITE|PROT_EXEC,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (realdatastart == -1) {
fprintf(stderr, "Unable to allocate RAM for process data\n");
return realdatastart;
}
datapos = realdatastart + indx_len;
DBG_FLT("BINFMT_FLAT: Allocated data+bss+stack (%d bytes): %x\n",
(int)(data_len + bss_len + stack_len), (int)datapos);
fpos = ntohl(VAR_4->data_start);
#ifdef CONFIG_BINFMT_ZFLAT
if (flags & FLAT_FLAG_GZDATA) {
result = decompress_exec(VAR_0, fpos, (char *) datapos,
data_len + (VAR_7 * sizeof(abi_ulong)))
} else
#endif
{
result = target_pread(VAR_0->fd, datapos,
data_len + (VAR_7 * sizeof(abi_ulong)),
fpos);
}
if (result < 0) {
fprintf(stderr, "Unable to read data+bss\n");
return result;
}
reloc = datapos + (ntohl(VAR_4->reloc_start) - text_len);
memp = realdatastart;
} else {
textpos = target_mmap(0, text_len + data_len + extra + indx_len,
PROT_READ | PROT_EXEC | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (textpos == -1 ) {
fprintf(stderr, "Unable to allocate RAM for process text/data\n");
return -1;
}
realdatastart = textpos + ntohl(VAR_4->data_start);
datapos = realdatastart + indx_len;
reloc = (textpos + ntohl(VAR_4->reloc_start) + indx_len);
memp = textpos;
#ifdef CONFIG_BINFMT_ZFLAT
#error code needs checking
if (flags & FLAT_FLAG_GZIP) {
result = decompress_exec(VAR_0, sizeof (struct flat_hdr),
(((char *) textpos) + sizeof (struct flat_hdr)),
(text_len + data_len + (VAR_7 * sizeof(unsigned long))
- sizeof (struct flat_hdr)),
0);
memmove((void *) datapos, (void *) realdatastart,
data_len + (VAR_7 * sizeof(unsigned long)));
} else if (flags & FLAT_FLAG_GZDATA) {
fpos = 0;
result = VAR_0->file->f_op->read(VAR_0->file,
(char *) textpos, text_len, &fpos);
if (result < (unsigned long) -4096)
result = decompress_exec(VAR_0, text_len, (char *) datapos,
data_len + (VAR_7 * sizeof(unsigned long)), 0);
}
else
#endif
{
result = target_pread(VAR_0->fd, textpos,
text_len, 0);
if (result >= 0) {
result = target_pread(VAR_0->fd, datapos,
data_len + (VAR_7 * sizeof(abi_ulong)),
ntohl(VAR_4->data_start));
}
}
if (result < 0) {
fprintf(stderr, "Unable to read code+data+bss\n");
return result;
}
}
DBG_FLT("Mapping is 0x%x, Entry point is 0x%x, data_start is 0x%x\n",
(int)textpos, 0x00ffffff&ntohl(VAR_4->entry),
ntohl(VAR_4->data_start));
start_code = textpos + sizeof (struct flat_hdr);
end_code = textpos + text_len;
DBG_FLT("%s %s: TEXT=%x-%x DATA=%x-%x BSS=%x-%x\n",
VAR_2 ? "Lib" : "Load", VAR_0->filename,
(int) start_code, (int) end_code,
(int) datapos,
(int) (datapos + data_len),
(int) (datapos + data_len),
(int) (((datapos + data_len + bss_len) + 3) & ~3));
text_len -= sizeof(struct flat_hdr);
VAR_1[VAR_2].start_code = start_code;
VAR_1[VAR_2].start_data = datapos;
VAR_1[VAR_2].end_data = datapos + data_len;
VAR_1[VAR_2].start_brk = datapos + data_len + bss_len;
VAR_1[VAR_2].text_len = text_len;
VAR_1[VAR_2].loaded = 1;
VAR_1[VAR_2].entry = (0x00ffffff & ntohl(VAR_4->entry)) + textpos;
VAR_1[VAR_2].build_date = ntohl(VAR_4->build_date);
if (flags & FLAT_FLAG_GOTPIC) {
rp = datapos;
while (1) {
abi_ulong addr;
if (get_user_ual(addr, rp))
return -EFAULT;
if (addr == -1)
break;
if (addr) {
addr = calc_reloc(addr, VAR_1, VAR_2, 0);
if (addr == RELOC_FAILED)
return -ENOEXEC;
if (put_user_ual(addr, rp))
return -EFAULT;
}
rp += sizeof(abi_ulong);
}
}
if (VAR_6 > OLD_FLAT_VERSION) {
for (VAR_5 = 0; VAR_5 < VAR_7; VAR_5++) {
abi_ulong addr, relval;
if (get_user_ual(relval, reloc + VAR_5 * sizeof(abi_ulong)))
return -EFAULT;
addr = flat_get_relocate_addr(relval);
rp = calc_reloc(addr, VAR_1, VAR_2, 1);
if (rp == RELOC_FAILED)
return -ENOEXEC;
if (get_user_ual(addr, rp))
return -EFAULT;
if (addr != 0) {
#ifndef TARGET_WORDS_BIGENDIAN
if ((flags & FLAT_FLAG_GOTPIC) == 0)
addr = bswap32(addr);
#endif
addr = calc_reloc(addr, VAR_1, VAR_2, 0);
if (addr == RELOC_FAILED)
return -ENOEXEC;
if (put_user_ual(addr, rp))
return -EFAULT;
}
}
} else {
for (VAR_5 = 0; VAR_5 < VAR_7; VAR_5++) {
abi_ulong relval;
if (get_user_ual(relval, reloc + VAR_5 * sizeof(abi_ulong)))
return -EFAULT;
old_reloc(&VAR_1[0], relval);
}
}
memset((void *)((unsigned long)datapos + data_len), 0, bss_len);
return 0;
}
| [
"static int FUNC_0(struct linux_binprm * VAR_0,\nstruct lib_info *VAR_1, int VAR_2, abi_ulong *VAR_3)\n{",
"struct flat_hdr * VAR_4;",
"abi_ulong textpos = 0, datapos = 0;",
"abi_long result;",
"abi_ulong realdatastart = 0;",
"abi_ulong text_len, data_len, bss_len, stack_len, flags;",
"abi_ulong memp = 0;",
"abi_ulong extra;",
"abi_ulong reloc = 0, rp;",
"int VAR_5, VAR_6, VAR_7 = 0;",
"abi_ulong fpos;",
"abi_ulong start_code, end_code;",
"abi_ulong indx_len;",
"VAR_4 = ((struct flat_hdr *) VAR_0->buf);",
"text_len = ntohl(VAR_4->data_start);",
"data_len = ntohl(VAR_4->data_end) - ntohl(VAR_4->data_start);",
"bss_len = ntohl(VAR_4->bss_end) - ntohl(VAR_4->data_end);",
"stack_len = ntohl(VAR_4->stack_size);",
"if (VAR_3) {",
"stack_len += *VAR_3;",
"*VAR_3 = stack_len;",
"}",
"VAR_7 = ntohl(VAR_4->reloc_count);",
"flags = ntohl(VAR_4->flags);",
"VAR_6 = ntohl(VAR_4->VAR_6);",
"DBG_FLT(\"BINFMT_FLAT: Loading file: %s\\n\", VAR_0->filename);",
"if (VAR_6 != FLAT_VERSION && VAR_6 != OLD_FLAT_VERSION) {",
"fprintf(stderr, \"BINFMT_FLAT: bad magic/VAR_6 (0x%x, need 0x%x)\\n\",\nVAR_6, (int) FLAT_VERSION);",
"return -ENOEXEC;",
"}",
"if (VAR_6 == OLD_FLAT_VERSION && VAR_2 != 0) {",
"fprintf(stderr, \"BINFMT_FLAT: shared libraries are not available\\n\");",
"return -ENOEXEC;",
"}",
"if (VAR_6 == OLD_FLAT_VERSION && flat_old_ram_flag(flags))\nflags = FLAT_FLAG_RAM;",
"#ifndef CONFIG_BINFMT_ZFLAT\nif (flags & (FLAT_FLAG_GZIP|FLAT_FLAG_GZDATA)) {",
"fprintf(stderr, \"Support for ZFLAT executables is not enabled\\n\");",
"return -ENOEXEC;",
"}",
"#endif\nextra = VAR_7 * sizeof(abi_ulong);",
"if (extra < bss_len + stack_len)\nextra = bss_len + stack_len;",
"indx_len = MAX_SHARED_LIBS * sizeof(abi_ulong);",
"indx_len = (indx_len + 15) & ~(abi_ulong)15;",
"if ((flags & (FLAT_FLAG_RAM|FLAT_FLAG_GZIP)) == 0) {",
"DBG_FLT(\"BINFMT_FLAT: ROM mapping of file (we hope)\\n\");",
"textpos = target_mmap(0, text_len, PROT_READ|PROT_EXEC,\nMAP_PRIVATE, VAR_0->fd, 0);",
"if (textpos == -1) {",
"fprintf(stderr, \"Unable to mmap process text\\n\");",
"return -1;",
"}",
"realdatastart = target_mmap(0, data_len + extra + indx_len,\nPROT_READ|PROT_WRITE|PROT_EXEC,\nMAP_PRIVATE | MAP_ANONYMOUS, -1, 0);",
"if (realdatastart == -1) {",
"fprintf(stderr, \"Unable to allocate RAM for process data\\n\");",
"return realdatastart;",
"}",
"datapos = realdatastart + indx_len;",
"DBG_FLT(\"BINFMT_FLAT: Allocated data+bss+stack (%d bytes): %x\\n\",\n(int)(data_len + bss_len + stack_len), (int)datapos);",
"fpos = ntohl(VAR_4->data_start);",
"#ifdef CONFIG_BINFMT_ZFLAT\nif (flags & FLAT_FLAG_GZDATA) {",
"result = decompress_exec(VAR_0, fpos, (char *) datapos,\ndata_len + (VAR_7 * sizeof(abi_ulong)))\n} else",
"#endif\n{",
"result = target_pread(VAR_0->fd, datapos,\ndata_len + (VAR_7 * sizeof(abi_ulong)),\nfpos);",
"}",
"if (result < 0) {",
"fprintf(stderr, \"Unable to read data+bss\\n\");",
"return result;",
"}",
"reloc = datapos + (ntohl(VAR_4->reloc_start) - text_len);",
"memp = realdatastart;",
"} else {",
"textpos = target_mmap(0, text_len + data_len + extra + indx_len,\nPROT_READ | PROT_EXEC | PROT_WRITE,\nMAP_PRIVATE | MAP_ANONYMOUS, -1, 0);",
"if (textpos == -1 ) {",
"fprintf(stderr, \"Unable to allocate RAM for process text/data\\n\");",
"return -1;",
"}",
"realdatastart = textpos + ntohl(VAR_4->data_start);",
"datapos = realdatastart + indx_len;",
"reloc = (textpos + ntohl(VAR_4->reloc_start) + indx_len);",
"memp = textpos;",
"#ifdef CONFIG_BINFMT_ZFLAT\n#error code needs checking\nif (flags & FLAT_FLAG_GZIP) {",
"result = decompress_exec(VAR_0, sizeof (struct flat_hdr),\n(((char *) textpos) + sizeof (struct flat_hdr)),\n(text_len + data_len + (VAR_7 * sizeof(unsigned long))\n- sizeof (struct flat_hdr)),\n0);",
"memmove((void *) datapos, (void *) realdatastart,\ndata_len + (VAR_7 * sizeof(unsigned long)));",
"} else if (flags & FLAT_FLAG_GZDATA) {",
"fpos = 0;",
"result = VAR_0->file->f_op->read(VAR_0->file,\n(char *) textpos, text_len, &fpos);",
"if (result < (unsigned long) -4096)\nresult = decompress_exec(VAR_0, text_len, (char *) datapos,\ndata_len + (VAR_7 * sizeof(unsigned long)), 0);",
"}",
"else\n#endif\n{",
"result = target_pread(VAR_0->fd, textpos,\ntext_len, 0);",
"if (result >= 0) {",
"result = target_pread(VAR_0->fd, datapos,\ndata_len + (VAR_7 * sizeof(abi_ulong)),\nntohl(VAR_4->data_start));",
"}",
"}",
"if (result < 0) {",
"fprintf(stderr, \"Unable to read code+data+bss\\n\");",
"return result;",
"}",
"}",
"DBG_FLT(\"Mapping is 0x%x, Entry point is 0x%x, data_start is 0x%x\\n\",\n(int)textpos, 0x00ffffff&ntohl(VAR_4->entry),\nntohl(VAR_4->data_start));",
"start_code = textpos + sizeof (struct flat_hdr);",
"end_code = textpos + text_len;",
"DBG_FLT(\"%s %s: TEXT=%x-%x DATA=%x-%x BSS=%x-%x\\n\",\nVAR_2 ? \"Lib\" : \"Load\", VAR_0->filename,\n(int) start_code, (int) end_code,\n(int) datapos,\n(int) (datapos + data_len),\n(int) (datapos + data_len),\n(int) (((datapos + data_len + bss_len) + 3) & ~3));",
"text_len -= sizeof(struct flat_hdr);",
"VAR_1[VAR_2].start_code = start_code;",
"VAR_1[VAR_2].start_data = datapos;",
"VAR_1[VAR_2].end_data = datapos + data_len;",
"VAR_1[VAR_2].start_brk = datapos + data_len + bss_len;",
"VAR_1[VAR_2].text_len = text_len;",
"VAR_1[VAR_2].loaded = 1;",
"VAR_1[VAR_2].entry = (0x00ffffff & ntohl(VAR_4->entry)) + textpos;",
"VAR_1[VAR_2].build_date = ntohl(VAR_4->build_date);",
"if (flags & FLAT_FLAG_GOTPIC) {",
"rp = datapos;",
"while (1) {",
"abi_ulong addr;",
"if (get_user_ual(addr, rp))\nreturn -EFAULT;",
"if (addr == -1)\nbreak;",
"if (addr) {",
"addr = calc_reloc(addr, VAR_1, VAR_2, 0);",
"if (addr == RELOC_FAILED)\nreturn -ENOEXEC;",
"if (put_user_ual(addr, rp))\nreturn -EFAULT;",
"}",
"rp += sizeof(abi_ulong);",
"}",
"}",
"if (VAR_6 > OLD_FLAT_VERSION) {",
"for (VAR_5 = 0; VAR_5 < VAR_7; VAR_5++) {",
"abi_ulong addr, relval;",
"if (get_user_ual(relval, reloc + VAR_5 * sizeof(abi_ulong)))\nreturn -EFAULT;",
"addr = flat_get_relocate_addr(relval);",
"rp = calc_reloc(addr, VAR_1, VAR_2, 1);",
"if (rp == RELOC_FAILED)\nreturn -ENOEXEC;",
"if (get_user_ual(addr, rp))\nreturn -EFAULT;",
"if (addr != 0) {",
"#ifndef TARGET_WORDS_BIGENDIAN\nif ((flags & FLAT_FLAG_GOTPIC) == 0)\naddr = bswap32(addr);",
"#endif\naddr = calc_reloc(addr, VAR_1, VAR_2, 0);",
"if (addr == RELOC_FAILED)\nreturn -ENOEXEC;",
"if (put_user_ual(addr, rp))\nreturn -EFAULT;",
"}",
"}",
"} else {",
"for (VAR_5 = 0; VAR_5 < VAR_7; VAR_5++) {",
"abi_ulong relval;",
"if (get_user_ual(relval, reloc + VAR_5 * sizeof(abi_ulong)))\nreturn -EFAULT;",
"old_reloc(&VAR_1[0], relval);",
"}",
"}",
"memset((void *)((unsigned long)datapos + data_len), 0, bss_len);",
"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
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
79
],
[
81
],
[
83
],
[
85
],
[
97,
99
],
[
103,
105
],
[
107
],
[
109
],
[
111
],
[
113,
123
],
[
125,
127
],
[
135
],
[
137
],
[
151
],
[
161
],
[
165,
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
179,
181,
183
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
199,
201
],
[
205
],
[
207,
209
],
[
211,
213,
215
],
[
217,
219
],
[
221,
223,
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
239
],
[
241
],
[
245
],
[
249,
251,
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
265
],
[
267
],
[
269
],
[
271
],
[
275,
277,
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
],
[
351,
353,
355
],
[
361
],
[
363
],
[
367,
369,
371,
373,
375,
377,
379
],
[
383
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
431
],
[
433
],
[
435
],
[
437
],
[
439,
441
],
[
443,
445
],
[
447
],
[
449
],
[
451,
453
],
[
455,
457
],
[
459
],
[
461
],
[
463
],
[
465
],
[
491
],
[
493
],
[
495
],
[
505,
507
],
[
509
],
[
511
],
[
513,
515
],
[
521,
523
],
[
525
],
[
537,
539,
541
],
[
543,
545
],
[
547,
549
],
[
555,
557
],
[
559
],
[
561
],
[
563
],
[
565
],
[
567
],
[
569,
571
],
[
573
],
[
575
],
[
577
],
[
583
],
[
587
],
[
589
]
] |
4,507 | static void tcg_out_bc(TCGContext *s, int bc, int label_index)
{
TCGLabel *l = &s->labels[label_index];
if (l->has_value) {
tcg_out32(s, bc | reloc_pc14_val(s->code_ptr, l->u.value_ptr));
} else {
tcg_out_reloc(s, s->code_ptr, R_PPC_REL14, label_index, 0);
tcg_out_bc_noaddr(s, bc);
}
}
| false | qemu | bec1631100323fac0900aea71043d5c4e22fc2fa | static void tcg_out_bc(TCGContext *s, int bc, int label_index)
{
TCGLabel *l = &s->labels[label_index];
if (l->has_value) {
tcg_out32(s, bc | reloc_pc14_val(s->code_ptr, l->u.value_ptr));
} else {
tcg_out_reloc(s, s->code_ptr, R_PPC_REL14, label_index, 0);
tcg_out_bc_noaddr(s, bc);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TCGContext *VAR_0, int VAR_1, int VAR_2)
{
TCGLabel *l = &VAR_0->labels[VAR_2];
if (l->has_value) {
tcg_out32(VAR_0, VAR_1 | reloc_pc14_val(VAR_0->code_ptr, l->u.value_ptr));
} else {
tcg_out_reloc(VAR_0, VAR_0->code_ptr, R_PPC_REL14, VAR_2, 0);
tcg_out_bc_noaddr(VAR_0, VAR_1);
}
}
| [
"static void FUNC_0(TCGContext *VAR_0, int VAR_1, int VAR_2)\n{",
"TCGLabel *l = &VAR_0->labels[VAR_2];",
"if (l->has_value) {",
"tcg_out32(VAR_0, VAR_1 | reloc_pc14_val(VAR_0->code_ptr, l->u.value_ptr));",
"} else {",
"tcg_out_reloc(VAR_0, VAR_0->code_ptr, R_PPC_REL14, VAR_2, 0);",
"tcg_out_bc_noaddr(VAR_0, VAR_1);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
4,508 | static void rng_egd_free_request(RngRequest *req)
{
g_free(req->data);
g_free(req);
}
| false | qemu | 9f14b0add1dcdbfa2ee61051d068211fb0a1fcc9 | static void rng_egd_free_request(RngRequest *req)
{
g_free(req->data);
g_free(req);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(RngRequest *VAR_0)
{
g_free(VAR_0->data);
g_free(VAR_0);
}
| [
"static void FUNC_0(RngRequest *VAR_0)\n{",
"g_free(VAR_0->data);",
"g_free(VAR_0);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
4,509 | static int vhdx_create_bat(BlockDriverState *bs, BDRVVHDXState *s,
uint64_t image_size, VHDXImageType type,
bool use_zero_blocks, uint64_t file_offset,
uint32_t length)
{
int ret = 0;
uint64_t data_file_offset;
uint64_t total_sectors = 0;
uint64_t sector_num = 0;
uint64_t unused;
int block_state;
VHDXSectorInfo sinfo;
assert(s->bat == NULL);
/* this gives a data start after BAT/bitmap entries, and well
* past any metadata entries (with a 4 MB buffer for future
* expansion */
data_file_offset = file_offset + length + 5 * MiB;
total_sectors = image_size >> s->logical_sector_size_bits;
if (type == VHDX_TYPE_DYNAMIC) {
/* All zeroes, so we can just extend the file - the end of the BAT
* is the furthest thing we have written yet */
ret = bdrv_truncate(bs, data_file_offset);
if (ret < 0) {
goto exit;
}
} else if (type == VHDX_TYPE_FIXED) {
ret = bdrv_truncate(bs, data_file_offset + image_size);
if (ret < 0) {
goto exit;
}
} else {
ret = -ENOTSUP;
goto exit;
}
if (type == VHDX_TYPE_FIXED ||
use_zero_blocks ||
bdrv_has_zero_init(bs) == 0) {
/* for a fixed file, the default BAT entry is not zero */
s->bat = g_try_malloc0(length);
if (length && s->bat != NULL) {
ret = -ENOMEM;
goto exit;
}
block_state = type == VHDX_TYPE_FIXED ? PAYLOAD_BLOCK_FULLY_PRESENT :
PAYLOAD_BLOCK_NOT_PRESENT;
block_state = use_zero_blocks ? PAYLOAD_BLOCK_ZERO : block_state;
/* fill the BAT by emulating sector writes of sectors_per_block size */
while (sector_num < total_sectors) {
vhdx_block_translate(s, sector_num, s->sectors_per_block, &sinfo);
sinfo.file_offset = data_file_offset +
(sector_num << s->logical_sector_size_bits);
sinfo.file_offset = ROUND_UP(sinfo.file_offset, MiB);
vhdx_update_bat_table_entry(bs, s, &sinfo, &unused, &unused,
block_state);
cpu_to_le64s(&s->bat[sinfo.bat_idx]);
sector_num += s->sectors_per_block;
}
ret = bdrv_pwrite(bs, file_offset, s->bat, length);
if (ret < 0) {
goto exit;
}
}
exit:
g_free(s->bat);
return ret;
}
| false | qemu | a011898d25b8a26a311d56dfe37e8d3a4374ec65 | static int vhdx_create_bat(BlockDriverState *bs, BDRVVHDXState *s,
uint64_t image_size, VHDXImageType type,
bool use_zero_blocks, uint64_t file_offset,
uint32_t length)
{
int ret = 0;
uint64_t data_file_offset;
uint64_t total_sectors = 0;
uint64_t sector_num = 0;
uint64_t unused;
int block_state;
VHDXSectorInfo sinfo;
assert(s->bat == NULL);
data_file_offset = file_offset + length + 5 * MiB;
total_sectors = image_size >> s->logical_sector_size_bits;
if (type == VHDX_TYPE_DYNAMIC) {
ret = bdrv_truncate(bs, data_file_offset);
if (ret < 0) {
goto exit;
}
} else if (type == VHDX_TYPE_FIXED) {
ret = bdrv_truncate(bs, data_file_offset + image_size);
if (ret < 0) {
goto exit;
}
} else {
ret = -ENOTSUP;
goto exit;
}
if (type == VHDX_TYPE_FIXED ||
use_zero_blocks ||
bdrv_has_zero_init(bs) == 0) {
s->bat = g_try_malloc0(length);
if (length && s->bat != NULL) {
ret = -ENOMEM;
goto exit;
}
block_state = type == VHDX_TYPE_FIXED ? PAYLOAD_BLOCK_FULLY_PRESENT :
PAYLOAD_BLOCK_NOT_PRESENT;
block_state = use_zero_blocks ? PAYLOAD_BLOCK_ZERO : block_state;
while (sector_num < total_sectors) {
vhdx_block_translate(s, sector_num, s->sectors_per_block, &sinfo);
sinfo.file_offset = data_file_offset +
(sector_num << s->logical_sector_size_bits);
sinfo.file_offset = ROUND_UP(sinfo.file_offset, MiB);
vhdx_update_bat_table_entry(bs, s, &sinfo, &unused, &unused,
block_state);
cpu_to_le64s(&s->bat[sinfo.bat_idx]);
sector_num += s->sectors_per_block;
}
ret = bdrv_pwrite(bs, file_offset, s->bat, length);
if (ret < 0) {
goto exit;
}
}
exit:
g_free(s->bat);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, BDRVVHDXState *VAR_1,
uint64_t VAR_2, VHDXImageType VAR_3,
bool VAR_4, uint64_t VAR_5,
uint32_t VAR_6)
{
int VAR_7 = 0;
uint64_t data_file_offset;
uint64_t total_sectors = 0;
uint64_t sector_num = 0;
uint64_t unused;
int VAR_8;
VHDXSectorInfo sinfo;
assert(VAR_1->bat == NULL);
data_file_offset = VAR_5 + VAR_6 + 5 * MiB;
total_sectors = VAR_2 >> VAR_1->logical_sector_size_bits;
if (VAR_3 == VHDX_TYPE_DYNAMIC) {
VAR_7 = bdrv_truncate(VAR_0, data_file_offset);
if (VAR_7 < 0) {
goto exit;
}
} else if (VAR_3 == VHDX_TYPE_FIXED) {
VAR_7 = bdrv_truncate(VAR_0, data_file_offset + VAR_2);
if (VAR_7 < 0) {
goto exit;
}
} else {
VAR_7 = -ENOTSUP;
goto exit;
}
if (VAR_3 == VHDX_TYPE_FIXED ||
VAR_4 ||
bdrv_has_zero_init(VAR_0) == 0) {
VAR_1->bat = g_try_malloc0(VAR_6);
if (VAR_6 && VAR_1->bat != NULL) {
VAR_7 = -ENOMEM;
goto exit;
}
VAR_8 = VAR_3 == VHDX_TYPE_FIXED ? PAYLOAD_BLOCK_FULLY_PRESENT :
PAYLOAD_BLOCK_NOT_PRESENT;
VAR_8 = VAR_4 ? PAYLOAD_BLOCK_ZERO : VAR_8;
while (sector_num < total_sectors) {
vhdx_block_translate(VAR_1, sector_num, VAR_1->sectors_per_block, &sinfo);
sinfo.VAR_5 = data_file_offset +
(sector_num << VAR_1->logical_sector_size_bits);
sinfo.VAR_5 = ROUND_UP(sinfo.VAR_5, MiB);
vhdx_update_bat_table_entry(VAR_0, VAR_1, &sinfo, &unused, &unused,
VAR_8);
cpu_to_le64s(&VAR_1->bat[sinfo.bat_idx]);
sector_num += VAR_1->sectors_per_block;
}
VAR_7 = bdrv_pwrite(VAR_0, VAR_5, VAR_1->bat, VAR_6);
if (VAR_7 < 0) {
goto exit;
}
}
exit:
g_free(VAR_1->bat);
return VAR_7;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, BDRVVHDXState *VAR_1,\nuint64_t VAR_2, VHDXImageType VAR_3,\nbool VAR_4, uint64_t VAR_5,\nuint32_t VAR_6)\n{",
"int VAR_7 = 0;",
"uint64_t data_file_offset;",
"uint64_t total_sectors = 0;",
"uint64_t sector_num = 0;",
"uint64_t unused;",
"int VAR_8;",
"VHDXSectorInfo sinfo;",
"assert(VAR_1->bat == NULL);",
"data_file_offset = VAR_5 + VAR_6 + 5 * MiB;",
"total_sectors = VAR_2 >> VAR_1->logical_sector_size_bits;",
"if (VAR_3 == VHDX_TYPE_DYNAMIC) {",
"VAR_7 = bdrv_truncate(VAR_0, data_file_offset);",
"if (VAR_7 < 0) {",
"goto exit;",
"}",
"} else if (VAR_3 == VHDX_TYPE_FIXED) {",
"VAR_7 = bdrv_truncate(VAR_0, data_file_offset + VAR_2);",
"if (VAR_7 < 0) {",
"goto exit;",
"}",
"} else {",
"VAR_7 = -ENOTSUP;",
"goto exit;",
"}",
"if (VAR_3 == VHDX_TYPE_FIXED ||\nVAR_4 ||\nbdrv_has_zero_init(VAR_0) == 0) {",
"VAR_1->bat = g_try_malloc0(VAR_6);",
"if (VAR_6 && VAR_1->bat != NULL) {",
"VAR_7 = -ENOMEM;",
"goto exit;",
"}",
"VAR_8 = VAR_3 == VHDX_TYPE_FIXED ? PAYLOAD_BLOCK_FULLY_PRESENT :\nPAYLOAD_BLOCK_NOT_PRESENT;",
"VAR_8 = VAR_4 ? PAYLOAD_BLOCK_ZERO : VAR_8;",
"while (sector_num < total_sectors) {",
"vhdx_block_translate(VAR_1, sector_num, VAR_1->sectors_per_block, &sinfo);",
"sinfo.VAR_5 = data_file_offset +\n(sector_num << VAR_1->logical_sector_size_bits);",
"sinfo.VAR_5 = ROUND_UP(sinfo.VAR_5, MiB);",
"vhdx_update_bat_table_entry(VAR_0, VAR_1, &sinfo, &unused, &unused,\nVAR_8);",
"cpu_to_le64s(&VAR_1->bat[sinfo.bat_idx]);",
"sector_num += VAR_1->sectors_per_block;",
"}",
"VAR_7 = bdrv_pwrite(VAR_0, VAR_5, VAR_1->bat, VAR_6);",
"if (VAR_7 < 0) {",
"goto exit;",
"}",
"}",
"exit:\ng_free(VAR_1->bat);",
"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
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
37
],
[
39
],
[
43
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77,
79,
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95,
97
],
[
99
],
[
103
],
[
105
],
[
107,
109
],
[
111
],
[
113,
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
139,
141
],
[
143
],
[
145
]
] |
4,510 | int kvm_set_signal_mask(CPUState *cpu, const sigset_t *sigset)
{
struct kvm_signal_mask *sigmask;
int r;
if (!sigset) {
return kvm_vcpu_ioctl(cpu, KVM_SET_SIGNAL_MASK, NULL);
}
sigmask = g_malloc(sizeof(*sigmask) + sizeof(*sigset));
sigmask->len = 8;
memcpy(sigmask->sigset, sigset, sizeof(*sigset));
r = kvm_vcpu_ioctl(cpu, KVM_SET_SIGNAL_MASK, sigmask);
g_free(sigmask);
return r;
}
| false | qemu | aed6efb90cc43faf45f1e40425646c55d37a340f | int kvm_set_signal_mask(CPUState *cpu, const sigset_t *sigset)
{
struct kvm_signal_mask *sigmask;
int r;
if (!sigset) {
return kvm_vcpu_ioctl(cpu, KVM_SET_SIGNAL_MASK, NULL);
}
sigmask = g_malloc(sizeof(*sigmask) + sizeof(*sigset));
sigmask->len = 8;
memcpy(sigmask->sigset, sigset, sizeof(*sigset));
r = kvm_vcpu_ioctl(cpu, KVM_SET_SIGNAL_MASK, sigmask);
g_free(sigmask);
return r;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(CPUState *VAR_0, const sigset_t *VAR_1)
{
struct kvm_signal_mask *VAR_2;
int VAR_3;
if (!VAR_1) {
return kvm_vcpu_ioctl(VAR_0, KVM_SET_SIGNAL_MASK, NULL);
}
VAR_2 = g_malloc(sizeof(*VAR_2) + sizeof(*VAR_1));
VAR_2->len = 8;
memcpy(VAR_2->VAR_1, VAR_1, sizeof(*VAR_1));
VAR_3 = kvm_vcpu_ioctl(VAR_0, KVM_SET_SIGNAL_MASK, VAR_2);
g_free(VAR_2);
return VAR_3;
}
| [
"int FUNC_0(CPUState *VAR_0, const sigset_t *VAR_1)\n{",
"struct kvm_signal_mask *VAR_2;",
"int VAR_3;",
"if (!VAR_1) {",
"return kvm_vcpu_ioctl(VAR_0, KVM_SET_SIGNAL_MASK, NULL);",
"}",
"VAR_2 = g_malloc(sizeof(*VAR_2) + sizeof(*VAR_1));",
"VAR_2->len = 8;",
"memcpy(VAR_2->VAR_1, VAR_1, sizeof(*VAR_1));",
"VAR_3 = kvm_vcpu_ioctl(VAR_0, KVM_SET_SIGNAL_MASK, VAR_2);",
"g_free(VAR_2);",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
]
] |
4,512 | unsigned avutil_version(void)
{
av_assert0(AV_PIX_FMT_VDA_VLD == 81); //check if the pix fmt enum has not had anything inserted or removed by mistake
av_assert0(AV_SAMPLE_FMT_DBLP == 9);
av_assert0(AVMEDIA_TYPE_ATTACHMENT == 4);
av_assert0(AV_PICTURE_TYPE_BI == 7);
av_assert0(LIBAVUTIL_VERSION_MICRO >= 100);
av_assert0(HAVE_MMX2 == HAVE_MMXEXT);
if (av_sat_dadd32(1, 2) != 5) {
av_log(NULL, AV_LOG_FATAL, "Libavutil has been build with a broken binutils, please upgrade binutils and rebuild\n");
abort();
}
ff_check_pixfmt_descriptors();
return LIBAVUTIL_VERSION_INT;
}
| false | FFmpeg | e701cd96c2d5dc034e7615967d208db3d953e111 | unsigned avutil_version(void)
{
av_assert0(AV_PIX_FMT_VDA_VLD == 81);
av_assert0(AV_SAMPLE_FMT_DBLP == 9);
av_assert0(AVMEDIA_TYPE_ATTACHMENT == 4);
av_assert0(AV_PICTURE_TYPE_BI == 7);
av_assert0(LIBAVUTIL_VERSION_MICRO >= 100);
av_assert0(HAVE_MMX2 == HAVE_MMXEXT);
if (av_sat_dadd32(1, 2) != 5) {
av_log(NULL, AV_LOG_FATAL, "Libavutil has been build with a broken binutils, please upgrade binutils and rebuild\n");
abort();
}
ff_check_pixfmt_descriptors();
return LIBAVUTIL_VERSION_INT;
}
| {
"code": [],
"line_no": []
} | unsigned FUNC_0(void)
{
av_assert0(AV_PIX_FMT_VDA_VLD == 81);
av_assert0(AV_SAMPLE_FMT_DBLP == 9);
av_assert0(AVMEDIA_TYPE_ATTACHMENT == 4);
av_assert0(AV_PICTURE_TYPE_BI == 7);
av_assert0(LIBAVUTIL_VERSION_MICRO >= 100);
av_assert0(HAVE_MMX2 == HAVE_MMXEXT);
if (av_sat_dadd32(1, 2) != 5) {
av_log(NULL, AV_LOG_FATAL, "Libavutil has been build with a broken binutils, please upgrade binutils and rebuild\n");
abort();
}
ff_check_pixfmt_descriptors();
return LIBAVUTIL_VERSION_INT;
}
| [
"unsigned FUNC_0(void)\n{",
"av_assert0(AV_PIX_FMT_VDA_VLD == 81);",
"av_assert0(AV_SAMPLE_FMT_DBLP == 9);",
"av_assert0(AVMEDIA_TYPE_ATTACHMENT == 4);",
"av_assert0(AV_PICTURE_TYPE_BI == 7);",
"av_assert0(LIBAVUTIL_VERSION_MICRO >= 100);",
"av_assert0(HAVE_MMX2 == HAVE_MMXEXT);",
"if (av_sat_dadd32(1, 2) != 5) {",
"av_log(NULL, AV_LOG_FATAL, \"Libavutil has been build with a broken binutils, please upgrade binutils and rebuild\\n\");",
"abort();",
"}",
"ff_check_pixfmt_descriptors();",
"return LIBAVUTIL_VERSION_INT;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
33
],
[
35
]
] |
4,513 | static int udp_open(URLContext *h, const char *uri, int flags)
{
char hostname[1024], localaddr[1024] = "";
int port, udp_fd = -1, tmp, bind_ret = -1;
UDPContext *s = h->priv_data;
int is_output;
const char *p;
char buf[256];
struct sockaddr_storage my_addr;
int len;
int reuse_specified = 0;
h->is_streamed = 1;
h->max_packet_size = 1472;
is_output = !(flags & AVIO_FLAG_READ);
s->ttl = 16;
s->buffer_size = is_output ? UDP_TX_BUF_SIZE : UDP_MAX_PKT_SIZE;
s->circular_buffer_size = 7*188*4096;
p = strchr(uri, '?');
if (p) {
if (av_find_info_tag(buf, sizeof(buf), "reuse", p)) {
char *endptr = NULL;
s->reuse_socket = strtol(buf, &endptr, 10);
/* assume if no digits were found it is a request to enable it */
if (buf == endptr)
s->reuse_socket = 1;
reuse_specified = 1;
}
if (av_find_info_tag(buf, sizeof(buf), "overrun_nonfatal", p)) {
char *endptr = NULL;
s->overrun_nonfatal = strtol(buf, &endptr, 10);
/* assume if no digits were found it is a request to enable it */
if (buf == endptr)
s->overrun_nonfatal = 1;
}
if (av_find_info_tag(buf, sizeof(buf), "ttl", p)) {
s->ttl = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "localport", p)) {
s->local_port = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "pkt_size", p)) {
h->max_packet_size = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "buffer_size", p)) {
s->buffer_size = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "connect", p)) {
s->is_connected = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "fifo_size", p)) {
s->circular_buffer_size = strtol(buf, NULL, 10)*188;
}
if (av_find_info_tag(buf, sizeof(buf), "localaddr", p)) {
av_strlcpy(localaddr, buf, sizeof(localaddr));
}
}
/* fill the dest addr */
av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri);
/* XXX: fix av_url_split */
if (hostname[0] == '\0' || hostname[0] == '?') {
/* only accepts null hostname if input */
if (!(flags & AVIO_FLAG_READ))
goto fail;
} else {
if (ff_udp_set_remote_url(h, uri) < 0)
goto fail;
}
if ((s->is_multicast || !s->local_port) && (h->flags & AVIO_FLAG_READ))
s->local_port = port;
udp_fd = udp_socket_create(s, &my_addr, &len, localaddr);
if (udp_fd < 0)
goto fail;
/* Follow the requested reuse option, unless it's multicast in which
* case enable reuse unless explicitly disabled.
*/
if (s->reuse_socket || (s->is_multicast && !reuse_specified)) {
s->reuse_socket = 1;
if (setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), sizeof(s->reuse_socket)) != 0)
goto fail;
}
/* If multicast, try binding the multicast address first, to avoid
* receiving UDP packets from other sources aimed at the same UDP
* port. This fails on windows. This makes sending to the same address
* using sendto() fail, so only do it if we're opened in read-only mode. */
if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE)) {
bind_ret = bind(udp_fd,(struct sockaddr *)&s->dest_addr, len);
}
/* bind to the local address if not multicast or if the multicast
* bind failed */
/* the bind is needed to give a port to the socket now */
if (bind_ret < 0 && bind(udp_fd,(struct sockaddr *)&my_addr, len) < 0) {
av_log(h, AV_LOG_ERROR, "bind failed: %s\n", strerror(errno));
goto fail;
}
len = sizeof(my_addr);
getsockname(udp_fd, (struct sockaddr *)&my_addr, &len);
s->local_port = udp_port(&my_addr, len);
if (s->is_multicast) {
if (h->flags & AVIO_FLAG_WRITE) {
/* output */
if (udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr *)&s->dest_addr) < 0)
goto fail;
}
if (h->flags & AVIO_FLAG_READ) {
/* input */
if (udp_join_multicast_group(udp_fd, (struct sockaddr *)&s->dest_addr) < 0)
goto fail;
}
}
if (is_output) {
/* limit the tx buf size to limit latency */
tmp = s->buffer_size;
if (setsockopt(udp_fd, SOL_SOCKET, SO_SNDBUF, &tmp, sizeof(tmp)) < 0) {
av_log(h, AV_LOG_ERROR, "setsockopt(SO_SNDBUF): %s\n", strerror(errno));
goto fail;
}
} else {
/* set udp recv buffer size to the largest possible udp packet size to
* avoid losing data on OSes that set this too low by default. */
tmp = s->buffer_size;
if (setsockopt(udp_fd, SOL_SOCKET, SO_RCVBUF, &tmp, sizeof(tmp)) < 0) {
av_log(h, AV_LOG_WARNING, "setsockopt(SO_RECVBUF): %s\n", strerror(errno));
}
/* make the socket non-blocking */
ff_socket_nonblock(udp_fd, 1);
}
if (s->is_connected) {
if (connect(udp_fd, (struct sockaddr *) &s->dest_addr, s->dest_addr_len)) {
av_log(h, AV_LOG_ERROR, "connect: %s\n", strerror(errno));
goto fail;
}
}
s->udp_fd = udp_fd;
#if HAVE_PTHREADS
if (!is_output && s->circular_buffer_size) {
int ret;
/* start the task going */
s->fifo = av_fifo_alloc(s->circular_buffer_size);
ret = pthread_mutex_init(&s->mutex, NULL);
if (ret != 0) {
av_log(h, AV_LOG_ERROR, "pthread_mutex_init failed : %s\n", strerror(ret));
goto fail;
}
ret = pthread_cond_init(&s->cond, NULL);
if (ret != 0) {
av_log(h, AV_LOG_ERROR, "pthread_cond_init failed : %s\n", strerror(ret));
goto cond_fail;
}
ret = pthread_create(&s->circular_buffer_thread, NULL, circular_buffer_task, h);
if (ret != 0) {
av_log(h, AV_LOG_ERROR, "pthread_create failed : %s\n", strerror(ret));
goto thread_fail;
}
s->thread_started = 1;
}
#endif
return 0;
#if HAVE_PTHREADS
thread_fail:
pthread_cond_destroy(&s->cond);
cond_fail:
pthread_mutex_destroy(&s->mutex);
#endif
fail:
if (udp_fd >= 0)
closesocket(udp_fd);
av_fifo_free(s->fifo);
return AVERROR(EIO);
}
| false | FFmpeg | 281bde27894f994d0982ab9283f15d6073ae352c | static int udp_open(URLContext *h, const char *uri, int flags)
{
char hostname[1024], localaddr[1024] = "";
int port, udp_fd = -1, tmp, bind_ret = -1;
UDPContext *s = h->priv_data;
int is_output;
const char *p;
char buf[256];
struct sockaddr_storage my_addr;
int len;
int reuse_specified = 0;
h->is_streamed = 1;
h->max_packet_size = 1472;
is_output = !(flags & AVIO_FLAG_READ);
s->ttl = 16;
s->buffer_size = is_output ? UDP_TX_BUF_SIZE : UDP_MAX_PKT_SIZE;
s->circular_buffer_size = 7*188*4096;
p = strchr(uri, '?');
if (p) {
if (av_find_info_tag(buf, sizeof(buf), "reuse", p)) {
char *endptr = NULL;
s->reuse_socket = strtol(buf, &endptr, 10);
if (buf == endptr)
s->reuse_socket = 1;
reuse_specified = 1;
}
if (av_find_info_tag(buf, sizeof(buf), "overrun_nonfatal", p)) {
char *endptr = NULL;
s->overrun_nonfatal = strtol(buf, &endptr, 10);
if (buf == endptr)
s->overrun_nonfatal = 1;
}
if (av_find_info_tag(buf, sizeof(buf), "ttl", p)) {
s->ttl = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "localport", p)) {
s->local_port = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "pkt_size", p)) {
h->max_packet_size = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "buffer_size", p)) {
s->buffer_size = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "connect", p)) {
s->is_connected = strtol(buf, NULL, 10);
}
if (av_find_info_tag(buf, sizeof(buf), "fifo_size", p)) {
s->circular_buffer_size = strtol(buf, NULL, 10)*188;
}
if (av_find_info_tag(buf, sizeof(buf), "localaddr", p)) {
av_strlcpy(localaddr, buf, sizeof(localaddr));
}
}
av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri);
if (hostname[0] == '\0' || hostname[0] == '?') {
if (!(flags & AVIO_FLAG_READ))
goto fail;
} else {
if (ff_udp_set_remote_url(h, uri) < 0)
goto fail;
}
if ((s->is_multicast || !s->local_port) && (h->flags & AVIO_FLAG_READ))
s->local_port = port;
udp_fd = udp_socket_create(s, &my_addr, &len, localaddr);
if (udp_fd < 0)
goto fail;
if (s->reuse_socket || (s->is_multicast && !reuse_specified)) {
s->reuse_socket = 1;
if (setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), sizeof(s->reuse_socket)) != 0)
goto fail;
}
if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE)) {
bind_ret = bind(udp_fd,(struct sockaddr *)&s->dest_addr, len);
}
if (bind_ret < 0 && bind(udp_fd,(struct sockaddr *)&my_addr, len) < 0) {
av_log(h, AV_LOG_ERROR, "bind failed: %s\n", strerror(errno));
goto fail;
}
len = sizeof(my_addr);
getsockname(udp_fd, (struct sockaddr *)&my_addr, &len);
s->local_port = udp_port(&my_addr, len);
if (s->is_multicast) {
if (h->flags & AVIO_FLAG_WRITE) {
if (udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr *)&s->dest_addr) < 0)
goto fail;
}
if (h->flags & AVIO_FLAG_READ) {
if (udp_join_multicast_group(udp_fd, (struct sockaddr *)&s->dest_addr) < 0)
goto fail;
}
}
if (is_output) {
tmp = s->buffer_size;
if (setsockopt(udp_fd, SOL_SOCKET, SO_SNDBUF, &tmp, sizeof(tmp)) < 0) {
av_log(h, AV_LOG_ERROR, "setsockopt(SO_SNDBUF): %s\n", strerror(errno));
goto fail;
}
} else {
tmp = s->buffer_size;
if (setsockopt(udp_fd, SOL_SOCKET, SO_RCVBUF, &tmp, sizeof(tmp)) < 0) {
av_log(h, AV_LOG_WARNING, "setsockopt(SO_RECVBUF): %s\n", strerror(errno));
}
ff_socket_nonblock(udp_fd, 1);
}
if (s->is_connected) {
if (connect(udp_fd, (struct sockaddr *) &s->dest_addr, s->dest_addr_len)) {
av_log(h, AV_LOG_ERROR, "connect: %s\n", strerror(errno));
goto fail;
}
}
s->udp_fd = udp_fd;
#if HAVE_PTHREADS
if (!is_output && s->circular_buffer_size) {
int ret;
s->fifo = av_fifo_alloc(s->circular_buffer_size);
ret = pthread_mutex_init(&s->mutex, NULL);
if (ret != 0) {
av_log(h, AV_LOG_ERROR, "pthread_mutex_init failed : %s\n", strerror(ret));
goto fail;
}
ret = pthread_cond_init(&s->cond, NULL);
if (ret != 0) {
av_log(h, AV_LOG_ERROR, "pthread_cond_init failed : %s\n", strerror(ret));
goto cond_fail;
}
ret = pthread_create(&s->circular_buffer_thread, NULL, circular_buffer_task, h);
if (ret != 0) {
av_log(h, AV_LOG_ERROR, "pthread_create failed : %s\n", strerror(ret));
goto thread_fail;
}
s->thread_started = 1;
}
#endif
return 0;
#if HAVE_PTHREADS
thread_fail:
pthread_cond_destroy(&s->cond);
cond_fail:
pthread_mutex_destroy(&s->mutex);
#endif
fail:
if (udp_fd >= 0)
closesocket(udp_fd);
av_fifo_free(s->fifo);
return AVERROR(EIO);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(URLContext *VAR_0, const char *VAR_1, int VAR_2)
{
char VAR_3[1024], VAR_4[1024] = "";
int VAR_5, VAR_6 = -1, VAR_7, VAR_8 = -1;
UDPContext *s = VAR_0->priv_data;
int VAR_9;
const char *VAR_10;
char VAR_11[256];
struct sockaddr_storage VAR_12;
int VAR_13;
int VAR_14 = 0;
VAR_0->is_streamed = 1;
VAR_0->max_packet_size = 1472;
VAR_9 = !(VAR_2 & AVIO_FLAG_READ);
s->ttl = 16;
s->buffer_size = VAR_9 ? UDP_TX_BUF_SIZE : UDP_MAX_PKT_SIZE;
s->circular_buffer_size = 7*188*4096;
VAR_10 = strchr(VAR_1, '?');
if (VAR_10) {
if (av_find_info_tag(VAR_11, sizeof(VAR_11), "reuse", VAR_10)) {
char *VAR_16 = NULL;
s->reuse_socket = strtol(VAR_11, &VAR_16, 10);
if (VAR_11 == VAR_16)
s->reuse_socket = 1;
VAR_14 = 1;
}
if (av_find_info_tag(VAR_11, sizeof(VAR_11), "overrun_nonfatal", VAR_10)) {
char *VAR_16 = NULL;
s->overrun_nonfatal = strtol(VAR_11, &VAR_16, 10);
if (VAR_11 == VAR_16)
s->overrun_nonfatal = 1;
}
if (av_find_info_tag(VAR_11, sizeof(VAR_11), "ttl", VAR_10)) {
s->ttl = strtol(VAR_11, NULL, 10);
}
if (av_find_info_tag(VAR_11, sizeof(VAR_11), "localport", VAR_10)) {
s->local_port = strtol(VAR_11, NULL, 10);
}
if (av_find_info_tag(VAR_11, sizeof(VAR_11), "pkt_size", VAR_10)) {
VAR_0->max_packet_size = strtol(VAR_11, NULL, 10);
}
if (av_find_info_tag(VAR_11, sizeof(VAR_11), "buffer_size", VAR_10)) {
s->buffer_size = strtol(VAR_11, NULL, 10);
}
if (av_find_info_tag(VAR_11, sizeof(VAR_11), "connect", VAR_10)) {
s->is_connected = strtol(VAR_11, NULL, 10);
}
if (av_find_info_tag(VAR_11, sizeof(VAR_11), "fifo_size", VAR_10)) {
s->circular_buffer_size = strtol(VAR_11, NULL, 10)*188;
}
if (av_find_info_tag(VAR_11, sizeof(VAR_11), "VAR_4", VAR_10)) {
av_strlcpy(VAR_4, VAR_11, sizeof(VAR_4));
}
}
av_url_split(NULL, 0, NULL, 0, VAR_3, sizeof(VAR_3), &VAR_5, NULL, 0, VAR_1);
if (VAR_3[0] == '\0' || VAR_3[0] == '?') {
if (!(VAR_2 & AVIO_FLAG_READ))
goto fail;
} else {
if (ff_udp_set_remote_url(VAR_0, VAR_1) < 0)
goto fail;
}
if ((s->is_multicast || !s->local_port) && (VAR_0->VAR_2 & AVIO_FLAG_READ))
s->local_port = VAR_5;
VAR_6 = udp_socket_create(s, &VAR_12, &VAR_13, VAR_4);
if (VAR_6 < 0)
goto fail;
if (s->reuse_socket || (s->is_multicast && !VAR_14)) {
s->reuse_socket = 1;
if (setsockopt (VAR_6, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), sizeof(s->reuse_socket)) != 0)
goto fail;
}
if (s->is_multicast && !(VAR_0->VAR_2 & AVIO_FLAG_WRITE)) {
VAR_8 = bind(VAR_6,(struct sockaddr *)&s->dest_addr, VAR_13);
}
if (VAR_8 < 0 && bind(VAR_6,(struct sockaddr *)&VAR_12, VAR_13) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "bind failed: %s\n", strerror(errno));
goto fail;
}
VAR_13 = sizeof(VAR_12);
getsockname(VAR_6, (struct sockaddr *)&VAR_12, &VAR_13);
s->local_port = udp_port(&VAR_12, VAR_13);
if (s->is_multicast) {
if (VAR_0->VAR_2 & AVIO_FLAG_WRITE) {
if (udp_set_multicast_ttl(VAR_6, s->ttl, (struct sockaddr *)&s->dest_addr) < 0)
goto fail;
}
if (VAR_0->VAR_2 & AVIO_FLAG_READ) {
if (udp_join_multicast_group(VAR_6, (struct sockaddr *)&s->dest_addr) < 0)
goto fail;
}
}
if (VAR_9) {
VAR_7 = s->buffer_size;
if (setsockopt(VAR_6, SOL_SOCKET, SO_SNDBUF, &VAR_7, sizeof(VAR_7)) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "setsockopt(SO_SNDBUF): %s\n", strerror(errno));
goto fail;
}
} else {
VAR_7 = s->buffer_size;
if (setsockopt(VAR_6, SOL_SOCKET, SO_RCVBUF, &VAR_7, sizeof(VAR_7)) < 0) {
av_log(VAR_0, AV_LOG_WARNING, "setsockopt(SO_RECVBUF): %s\n", strerror(errno));
}
ff_socket_nonblock(VAR_6, 1);
}
if (s->is_connected) {
if (connect(VAR_6, (struct sockaddr *) &s->dest_addr, s->dest_addr_len)) {
av_log(VAR_0, AV_LOG_ERROR, "connect: %s\n", strerror(errno));
goto fail;
}
}
s->VAR_6 = VAR_6;
#if HAVE_PTHREADS
if (!VAR_9 && s->circular_buffer_size) {
int ret;
s->fifo = av_fifo_alloc(s->circular_buffer_size);
ret = pthread_mutex_init(&s->mutex, NULL);
if (ret != 0) {
av_log(VAR_0, AV_LOG_ERROR, "pthread_mutex_init failed : %s\n", strerror(ret));
goto fail;
}
ret = pthread_cond_init(&s->cond, NULL);
if (ret != 0) {
av_log(VAR_0, AV_LOG_ERROR, "pthread_cond_init failed : %s\n", strerror(ret));
goto cond_fail;
}
ret = pthread_create(&s->circular_buffer_thread, NULL, circular_buffer_task, VAR_0);
if (ret != 0) {
av_log(VAR_0, AV_LOG_ERROR, "pthread_create failed : %s\n", strerror(ret));
goto thread_fail;
}
s->thread_started = 1;
}
#endif
return 0;
#if HAVE_PTHREADS
thread_fail:
pthread_cond_destroy(&s->cond);
cond_fail:
pthread_mutex_destroy(&s->mutex);
#endif
fail:
if (VAR_6 >= 0)
closesocket(VAR_6);
av_fifo_free(s->fifo);
return AVERROR(EIO);
}
| [
"static int FUNC_0(URLContext *VAR_0, const char *VAR_1, int VAR_2)\n{",
"char VAR_3[1024], VAR_4[1024] = \"\";",
"int VAR_5, VAR_6 = -1, VAR_7, VAR_8 = -1;",
"UDPContext *s = VAR_0->priv_data;",
"int VAR_9;",
"const char *VAR_10;",
"char VAR_11[256];",
"struct sockaddr_storage VAR_12;",
"int VAR_13;",
"int VAR_14 = 0;",
"VAR_0->is_streamed = 1;",
"VAR_0->max_packet_size = 1472;",
"VAR_9 = !(VAR_2 & AVIO_FLAG_READ);",
"s->ttl = 16;",
"s->buffer_size = VAR_9 ? UDP_TX_BUF_SIZE : UDP_MAX_PKT_SIZE;",
"s->circular_buffer_size = 7*188*4096;",
"VAR_10 = strchr(VAR_1, '?');",
"if (VAR_10) {",
"if (av_find_info_tag(VAR_11, sizeof(VAR_11), \"reuse\", VAR_10)) {",
"char *VAR_16 = NULL;",
"s->reuse_socket = strtol(VAR_11, &VAR_16, 10);",
"if (VAR_11 == VAR_16)\ns->reuse_socket = 1;",
"VAR_14 = 1;",
"}",
"if (av_find_info_tag(VAR_11, sizeof(VAR_11), \"overrun_nonfatal\", VAR_10)) {",
"char *VAR_16 = NULL;",
"s->overrun_nonfatal = strtol(VAR_11, &VAR_16, 10);",
"if (VAR_11 == VAR_16)\ns->overrun_nonfatal = 1;",
"}",
"if (av_find_info_tag(VAR_11, sizeof(VAR_11), \"ttl\", VAR_10)) {",
"s->ttl = strtol(VAR_11, NULL, 10);",
"}",
"if (av_find_info_tag(VAR_11, sizeof(VAR_11), \"localport\", VAR_10)) {",
"s->local_port = strtol(VAR_11, NULL, 10);",
"}",
"if (av_find_info_tag(VAR_11, sizeof(VAR_11), \"pkt_size\", VAR_10)) {",
"VAR_0->max_packet_size = strtol(VAR_11, NULL, 10);",
"}",
"if (av_find_info_tag(VAR_11, sizeof(VAR_11), \"buffer_size\", VAR_10)) {",
"s->buffer_size = strtol(VAR_11, NULL, 10);",
"}",
"if (av_find_info_tag(VAR_11, sizeof(VAR_11), \"connect\", VAR_10)) {",
"s->is_connected = strtol(VAR_11, NULL, 10);",
"}",
"if (av_find_info_tag(VAR_11, sizeof(VAR_11), \"fifo_size\", VAR_10)) {",
"s->circular_buffer_size = strtol(VAR_11, NULL, 10)*188;",
"}",
"if (av_find_info_tag(VAR_11, sizeof(VAR_11), \"VAR_4\", VAR_10)) {",
"av_strlcpy(VAR_4, VAR_11, sizeof(VAR_4));",
"}",
"}",
"av_url_split(NULL, 0, NULL, 0, VAR_3, sizeof(VAR_3), &VAR_5, NULL, 0, VAR_1);",
"if (VAR_3[0] == '\\0' || VAR_3[0] == '?') {",
"if (!(VAR_2 & AVIO_FLAG_READ))\ngoto fail;",
"} else {",
"if (ff_udp_set_remote_url(VAR_0, VAR_1) < 0)\ngoto fail;",
"}",
"if ((s->is_multicast || !s->local_port) && (VAR_0->VAR_2 & AVIO_FLAG_READ))\ns->local_port = VAR_5;",
"VAR_6 = udp_socket_create(s, &VAR_12, &VAR_13, VAR_4);",
"if (VAR_6 < 0)\ngoto fail;",
"if (s->reuse_socket || (s->is_multicast && !VAR_14)) {",
"s->reuse_socket = 1;",
"if (setsockopt (VAR_6, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), sizeof(s->reuse_socket)) != 0)\ngoto fail;",
"}",
"if (s->is_multicast && !(VAR_0->VAR_2 & AVIO_FLAG_WRITE)) {",
"VAR_8 = bind(VAR_6,(struct sockaddr *)&s->dest_addr, VAR_13);",
"}",
"if (VAR_8 < 0 && bind(VAR_6,(struct sockaddr *)&VAR_12, VAR_13) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"bind failed: %s\\n\", strerror(errno));",
"goto fail;",
"}",
"VAR_13 = sizeof(VAR_12);",
"getsockname(VAR_6, (struct sockaddr *)&VAR_12, &VAR_13);",
"s->local_port = udp_port(&VAR_12, VAR_13);",
"if (s->is_multicast) {",
"if (VAR_0->VAR_2 & AVIO_FLAG_WRITE) {",
"if (udp_set_multicast_ttl(VAR_6, s->ttl, (struct sockaddr *)&s->dest_addr) < 0)\ngoto fail;",
"}",
"if (VAR_0->VAR_2 & AVIO_FLAG_READ) {",
"if (udp_join_multicast_group(VAR_6, (struct sockaddr *)&s->dest_addr) < 0)\ngoto fail;",
"}",
"}",
"if (VAR_9) {",
"VAR_7 = s->buffer_size;",
"if (setsockopt(VAR_6, SOL_SOCKET, SO_SNDBUF, &VAR_7, sizeof(VAR_7)) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"setsockopt(SO_SNDBUF): %s\\n\", strerror(errno));",
"goto fail;",
"}",
"} else {",
"VAR_7 = s->buffer_size;",
"if (setsockopt(VAR_6, SOL_SOCKET, SO_RCVBUF, &VAR_7, sizeof(VAR_7)) < 0) {",
"av_log(VAR_0, AV_LOG_WARNING, \"setsockopt(SO_RECVBUF): %s\\n\", strerror(errno));",
"}",
"ff_socket_nonblock(VAR_6, 1);",
"}",
"if (s->is_connected) {",
"if (connect(VAR_6, (struct sockaddr *) &s->dest_addr, s->dest_addr_len)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"connect: %s\\n\", strerror(errno));",
"goto fail;",
"}",
"}",
"s->VAR_6 = VAR_6;",
"#if HAVE_PTHREADS\nif (!VAR_9 && s->circular_buffer_size) {",
"int ret;",
"s->fifo = av_fifo_alloc(s->circular_buffer_size);",
"ret = pthread_mutex_init(&s->mutex, NULL);",
"if (ret != 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"pthread_mutex_init failed : %s\\n\", strerror(ret));",
"goto fail;",
"}",
"ret = pthread_cond_init(&s->cond, NULL);",
"if (ret != 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"pthread_cond_init failed : %s\\n\", strerror(ret));",
"goto cond_fail;",
"}",
"ret = pthread_create(&s->circular_buffer_thread, NULL, circular_buffer_task, VAR_0);",
"if (ret != 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"pthread_create failed : %s\\n\", strerror(ret));",
"goto thread_fail;",
"}",
"s->thread_started = 1;",
"}",
"#endif\nreturn 0;",
"#if HAVE_PTHREADS\nthread_fail:\npthread_cond_destroy(&s->cond);",
"cond_fail:\npthread_mutex_destroy(&s->mutex);",
"#endif\nfail:\nif (VAR_6 >= 0)\nclosesocket(VAR_6);",
"av_fifo_free(s->fifo);",
"return AVERROR(EIO);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
35
],
[
37
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
127
],
[
133
],
[
137,
139
],
[
141
],
[
143,
145
],
[
147
],
[
151,
153
],
[
155
],
[
157,
159
],
[
169
],
[
171
],
[
173,
175
],
[
177
],
[
189
],
[
191
],
[
193
],
[
201
],
[
203
],
[
205
],
[
207
],
[
211
],
[
213
],
[
215
],
[
219
],
[
221
],
[
225,
227
],
[
229
],
[
231
],
[
235,
237
],
[
239
],
[
241
],
[
245
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
265
],
[
267
],
[
269
],
[
271
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
293
],
[
297,
299
],
[
301
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343,
347
],
[
349,
351,
353
],
[
355,
357
],
[
359,
361,
363,
365
],
[
367
],
[
369
],
[
371
]
] |
4,515 | static int txd_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
AVPacket *avpkt) {
const uint8_t *buf = avpkt->data;
TXDContext * const s = avctx->priv_data;
AVFrame *picture = data;
AVFrame * const p = &s->picture;
unsigned int version, w, h, d3d_format, depth, stride, mipmap_count, flags;
unsigned int y, v;
uint8_t *ptr;
const uint8_t *cur = buf;
const uint32_t *palette = (const uint32_t *)(cur + 88);
uint32_t *pal;
version = AV_RL32(cur);
d3d_format = AV_RL32(cur+76);
w = AV_RL16(cur+80);
h = AV_RL16(cur+82);
depth = AV_RL8 (cur+84);
mipmap_count = AV_RL8 (cur+85);
flags = AV_RL8 (cur+87);
cur += 92;
if (version < 8 || version > 9) {
av_log(avctx, AV_LOG_ERROR, "texture data version %i is unsupported\n",
version);
return -1;
}
if (depth == 8) {
avctx->pix_fmt = PIX_FMT_PAL8;
cur += 1024;
} else if (depth == 16 || depth == 32)
avctx->pix_fmt = PIX_FMT_RGB32;
else {
av_log(avctx, AV_LOG_ERROR, "depth of %i is unsupported\n", depth);
return -1;
}
if (p->data[0])
avctx->release_buffer(avctx, p);
if (av_image_check_size(w, h, 0, avctx))
return -1;
if (w != avctx->width || h != avctx->height)
avcodec_set_dimensions(avctx, w, h);
if (avctx->get_buffer(avctx, p) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
p->pict_type = AV_PICTURE_TYPE_I;
ptr = p->data[0];
stride = p->linesize[0];
if (depth == 8) {
pal = (uint32_t *) p->data[1];
for (y=0; y<256; y++) {
v = AV_RB32(palette+y);
pal[y] = (v>>8) + (v<<24);
}
for (y=0; y<h; y++) {
memcpy(ptr, cur, w);
ptr += stride;
cur += w;
}
} else if (depth == 16) {
switch (d3d_format) {
case 0:
if (!(flags & 1))
goto unsupported;
case FF_S3TC_DXT1:
ff_decode_dxt1(cur, ptr, w, h, stride);
break;
case FF_S3TC_DXT3:
ff_decode_dxt3(cur, ptr, w, h, stride);
break;
default:
goto unsupported;
}
} else if (depth == 32) {
switch (d3d_format) {
case 0x15:
case 0x16:
for (y=0; y<h; y++) {
memcpy(ptr, cur, w*4);
ptr += stride;
cur += w*4;
}
break;
default:
goto unsupported;
}
}
for (; mipmap_count > 1; mipmap_count--)
cur += AV_RL32(cur) + 4;
*picture = s->picture;
*data_size = sizeof(AVPicture);
return cur - buf;
unsupported:
av_log(avctx, AV_LOG_ERROR, "unsupported d3d format (%08x)\n", d3d_format);
return -1;
}
| true | FFmpeg | 919f3554387e043bdfe10c6369356d1104882183 | static int txd_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
AVPacket *avpkt) {
const uint8_t *buf = avpkt->data;
TXDContext * const s = avctx->priv_data;
AVFrame *picture = data;
AVFrame * const p = &s->picture;
unsigned int version, w, h, d3d_format, depth, stride, mipmap_count, flags;
unsigned int y, v;
uint8_t *ptr;
const uint8_t *cur = buf;
const uint32_t *palette = (const uint32_t *)(cur + 88);
uint32_t *pal;
version = AV_RL32(cur);
d3d_format = AV_RL32(cur+76);
w = AV_RL16(cur+80);
h = AV_RL16(cur+82);
depth = AV_RL8 (cur+84);
mipmap_count = AV_RL8 (cur+85);
flags = AV_RL8 (cur+87);
cur += 92;
if (version < 8 || version > 9) {
av_log(avctx, AV_LOG_ERROR, "texture data version %i is unsupported\n",
version);
return -1;
}
if (depth == 8) {
avctx->pix_fmt = PIX_FMT_PAL8;
cur += 1024;
} else if (depth == 16 || depth == 32)
avctx->pix_fmt = PIX_FMT_RGB32;
else {
av_log(avctx, AV_LOG_ERROR, "depth of %i is unsupported\n", depth);
return -1;
}
if (p->data[0])
avctx->release_buffer(avctx, p);
if (av_image_check_size(w, h, 0, avctx))
return -1;
if (w != avctx->width || h != avctx->height)
avcodec_set_dimensions(avctx, w, h);
if (avctx->get_buffer(avctx, p) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
p->pict_type = AV_PICTURE_TYPE_I;
ptr = p->data[0];
stride = p->linesize[0];
if (depth == 8) {
pal = (uint32_t *) p->data[1];
for (y=0; y<256; y++) {
v = AV_RB32(palette+y);
pal[y] = (v>>8) + (v<<24);
}
for (y=0; y<h; y++) {
memcpy(ptr, cur, w);
ptr += stride;
cur += w;
}
} else if (depth == 16) {
switch (d3d_format) {
case 0:
if (!(flags & 1))
goto unsupported;
case FF_S3TC_DXT1:
ff_decode_dxt1(cur, ptr, w, h, stride);
break;
case FF_S3TC_DXT3:
ff_decode_dxt3(cur, ptr, w, h, stride);
break;
default:
goto unsupported;
}
} else if (depth == 32) {
switch (d3d_format) {
case 0x15:
case 0x16:
for (y=0; y<h; y++) {
memcpy(ptr, cur, w*4);
ptr += stride;
cur += w*4;
}
break;
default:
goto unsupported;
}
}
for (; mipmap_count > 1; mipmap_count--)
cur += AV_RL32(cur) + 4;
*picture = s->picture;
*data_size = sizeof(AVPicture);
return cur - buf;
unsupported:
av_log(avctx, AV_LOG_ERROR, "unsupported d3d format (%08x)\n", d3d_format);
return -1;
}
| {
"code": [
" const uint8_t *buf = avpkt->data;",
" const uint8_t *cur = buf;",
" const uint32_t *palette = (const uint32_t *)(cur + 88);",
" version = AV_RL32(cur);",
" d3d_format = AV_RL32(cur+76);",
" w = AV_RL16(cur+80);",
" h = AV_RL16(cur+82);",
" depth = AV_RL8 (cur+84);",
" mipmap_count = AV_RL8 (cur+85);",
" flags = AV_RL8 (cur+87);",
" cur += 92;",
" cur += 1024;",
" } else if (depth == 16 || depth == 32)",
" else {",
" for (y=0; y<256; y++) {",
" v = AV_RB32(palette+y);",
" pal[y] = (v>>8) + (v<<24);",
" memcpy(ptr, cur, w);",
" cur += w;",
" ff_decode_dxt1(cur, ptr, w, h, stride);",
" ff_decode_dxt3(cur, ptr, w, h, stride);",
" memcpy(ptr, cur, w*4);",
" cur += w*4;",
" for (; mipmap_count > 1; mipmap_count--)",
" cur += AV_RL32(cur) + 4;",
" return cur - buf;"
],
"line_no": [
5,
19,
21,
27,
29,
31,
33,
35,
37,
39,
41,
61,
63,
67,
115,
117,
119,
125,
129,
145,
151,
171,
175,
191,
193,
203
]
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,
AVPacket *VAR_3) {
const uint8_t *VAR_4 = VAR_3->VAR_1;
TXDContext * const s = VAR_0->priv_data;
AVFrame *picture = VAR_1;
AVFrame * const p = &s->picture;
unsigned int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;
unsigned int VAR_13, VAR_14;
uint8_t *ptr;
const uint8_t *VAR_15 = VAR_4;
const uint32_t *VAR_16 = (const uint32_t *)(VAR_15 + 88);
uint32_t *pal;
VAR_5 = AV_RL32(VAR_15);
VAR_8 = AV_RL32(VAR_15+76);
VAR_6 = AV_RL16(VAR_15+80);
VAR_7 = AV_RL16(VAR_15+82);
VAR_9 = AV_RL8 (VAR_15+84);
VAR_11 = AV_RL8 (VAR_15+85);
VAR_12 = AV_RL8 (VAR_15+87);
VAR_15 += 92;
if (VAR_5 < 8 || VAR_5 > 9) {
av_log(VAR_0, AV_LOG_ERROR, "texture VAR_1 VAR_5 %i is unsupported\n",
VAR_5);
return -1;
}
if (VAR_9 == 8) {
VAR_0->pix_fmt = PIX_FMT_PAL8;
VAR_15 += 1024;
} else if (VAR_9 == 16 || VAR_9 == 32)
VAR_0->pix_fmt = PIX_FMT_RGB32;
else {
av_log(VAR_0, AV_LOG_ERROR, "VAR_9 of %i is unsupported\n", VAR_9);
return -1;
}
if (p->VAR_1[0])
VAR_0->release_buffer(VAR_0, p);
if (av_image_check_size(VAR_6, VAR_7, 0, VAR_0))
return -1;
if (VAR_6 != VAR_0->width || VAR_7 != VAR_0->height)
avcodec_set_dimensions(VAR_0, VAR_6, VAR_7);
if (VAR_0->get_buffer(VAR_0, p) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
p->pict_type = AV_PICTURE_TYPE_I;
ptr = p->VAR_1[0];
VAR_10 = p->linesize[0];
if (VAR_9 == 8) {
pal = (uint32_t *) p->VAR_1[1];
for (VAR_13=0; VAR_13<256; VAR_13++) {
VAR_14 = AV_RB32(VAR_16+VAR_13);
pal[VAR_13] = (VAR_14>>8) + (VAR_14<<24);
}
for (VAR_13=0; VAR_13<VAR_7; VAR_13++) {
memcpy(ptr, VAR_15, VAR_6);
ptr += VAR_10;
VAR_15 += VAR_6;
}
} else if (VAR_9 == 16) {
switch (VAR_8) {
case 0:
if (!(VAR_12 & 1))
goto unsupported;
case FF_S3TC_DXT1:
ff_decode_dxt1(VAR_15, ptr, VAR_6, VAR_7, VAR_10);
break;
case FF_S3TC_DXT3:
ff_decode_dxt3(VAR_15, ptr, VAR_6, VAR_7, VAR_10);
break;
default:
goto unsupported;
}
} else if (VAR_9 == 32) {
switch (VAR_8) {
case 0x15:
case 0x16:
for (VAR_13=0; VAR_13<VAR_7; VAR_13++) {
memcpy(ptr, VAR_15, VAR_6*4);
ptr += VAR_10;
VAR_15 += VAR_6*4;
}
break;
default:
goto unsupported;
}
}
for (; VAR_11 > 1; VAR_11--)
VAR_15 += AV_RL32(VAR_15) + 4;
*picture = s->picture;
*VAR_2 = sizeof(AVPicture);
return VAR_15 - VAR_4;
unsupported:
av_log(VAR_0, AV_LOG_ERROR, "unsupported d3d format (%08x)\n", VAR_8);
return -1;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,\nAVPacket *VAR_3) {",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"TXDContext * const s = VAR_0->priv_data;",
"AVFrame *picture = VAR_1;",
"AVFrame * const p = &s->picture;",
"unsigned int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;",
"unsigned int VAR_13, VAR_14;",
"uint8_t *ptr;",
"const uint8_t *VAR_15 = VAR_4;",
"const uint32_t *VAR_16 = (const uint32_t *)(VAR_15 + 88);",
"uint32_t *pal;",
"VAR_5 = AV_RL32(VAR_15);",
"VAR_8 = AV_RL32(VAR_15+76);",
"VAR_6 = AV_RL16(VAR_15+80);",
"VAR_7 = AV_RL16(VAR_15+82);",
"VAR_9 = AV_RL8 (VAR_15+84);",
"VAR_11 = AV_RL8 (VAR_15+85);",
"VAR_12 = AV_RL8 (VAR_15+87);",
"VAR_15 += 92;",
"if (VAR_5 < 8 || VAR_5 > 9) {",
"av_log(VAR_0, AV_LOG_ERROR, \"texture VAR_1 VAR_5 %i is unsupported\\n\",\nVAR_5);",
"return -1;",
"}",
"if (VAR_9 == 8) {",
"VAR_0->pix_fmt = PIX_FMT_PAL8;",
"VAR_15 += 1024;",
"} else if (VAR_9 == 16 || VAR_9 == 32)",
"VAR_0->pix_fmt = PIX_FMT_RGB32;",
"else {",
"av_log(VAR_0, AV_LOG_ERROR, \"VAR_9 of %i is unsupported\\n\", VAR_9);",
"return -1;",
"}",
"if (p->VAR_1[0])\nVAR_0->release_buffer(VAR_0, p);",
"if (av_image_check_size(VAR_6, VAR_7, 0, VAR_0))\nreturn -1;",
"if (VAR_6 != VAR_0->width || VAR_7 != VAR_0->height)\navcodec_set_dimensions(VAR_0, VAR_6, VAR_7);",
"if (VAR_0->get_buffer(VAR_0, p) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"get_buffer() failed\\n\");",
"return -1;",
"}",
"p->pict_type = AV_PICTURE_TYPE_I;",
"ptr = p->VAR_1[0];",
"VAR_10 = p->linesize[0];",
"if (VAR_9 == 8) {",
"pal = (uint32_t *) p->VAR_1[1];",
"for (VAR_13=0; VAR_13<256; VAR_13++) {",
"VAR_14 = AV_RB32(VAR_16+VAR_13);",
"pal[VAR_13] = (VAR_14>>8) + (VAR_14<<24);",
"}",
"for (VAR_13=0; VAR_13<VAR_7; VAR_13++) {",
"memcpy(ptr, VAR_15, VAR_6);",
"ptr += VAR_10;",
"VAR_15 += VAR_6;",
"}",
"} else if (VAR_9 == 16) {",
"switch (VAR_8) {",
"case 0:\nif (!(VAR_12 & 1))\ngoto unsupported;",
"case FF_S3TC_DXT1:\nff_decode_dxt1(VAR_15, ptr, VAR_6, VAR_7, VAR_10);",
"break;",
"case FF_S3TC_DXT3:\nff_decode_dxt3(VAR_15, ptr, VAR_6, VAR_7, VAR_10);",
"break;",
"default:\ngoto unsupported;",
"}",
"} else if (VAR_9 == 32) {",
"switch (VAR_8) {",
"case 0x15:\ncase 0x16:\nfor (VAR_13=0; VAR_13<VAR_7; VAR_13++) {",
"memcpy(ptr, VAR_15, VAR_6*4);",
"ptr += VAR_10;",
"VAR_15 += VAR_6*4;",
"}",
"break;",
"default:\ngoto unsupported;",
"}",
"}",
"for (; VAR_11 > 1; VAR_11--)",
"VAR_15 += AV_RL32(VAR_15) + 4;",
"*picture = s->picture;",
"*VAR_2 = sizeof(AVPicture);",
"return VAR_15 - VAR_4;",
"unsupported:\nav_log(VAR_0, AV_LOG_ERROR, \"unsupported d3d format (%08x)\\n\", VAR_8);",
"return -1;",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
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,
1,
1,
1,
0,
0,
1,
0,
1,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
1,
1,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77,
79
],
[
83,
85
],
[
87,
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
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
],
[
191
],
[
193
],
[
197
],
[
199
],
[
203
],
[
207,
209
],
[
211
],
[
213
]
] |
4,516 | 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);
if (rc) {
goto fail_vrings;
}
rc = virtio_scsi_vring_init(s, vs->event_vq, 1);
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);
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++) {
k->set_host_notifier(qbus->parent, 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;
}
| true | qemu | a8f2e5c8fffbaf7fbd4f0efc8efbeebade78008f | 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);
if (rc) {
goto fail_vrings;
}
rc = virtio_scsi_vring_init(s, vs->event_vq, 1);
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);
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++) {
k->set_host_notifier(qbus->parent, 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": [
" rc = virtio_scsi_vring_init(s, vs->ctrl_vq, 0);",
" rc = virtio_scsi_vring_init(s, vs->event_vq, 1);",
" rc = virtio_scsi_vring_init(s, vs->cmd_vqs[i], i + 2);"
],
"line_no": [
53,
61,
71
]
} | 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);
if (VAR_2) {
goto fail_vrings;
}
VAR_2 = virtio_scsi_vring_init(VAR_0, vs->event_vq, 1);
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);
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++) {
k->set_host_notifier(qbus->parent, 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);",
"if (VAR_2) {",
"goto fail_vrings;",
"}",
"VAR_2 = virtio_scsi_vring_init(VAR_0, vs->event_vq, 1);",
"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);",
"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++) {",
"k->set_host_notifier(qbus->parent, 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,
1,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
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
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93,
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
115
]
] |
4,517 | int bdrv_open(BlockDriverState *bs, const char *filename, int flags,
BlockDriver *drv)
{
int ret;
char tmp_filename[PATH_MAX];
if (flags & BDRV_O_SNAPSHOT) {
BlockDriverState *bs1;
int64_t total_size;
int is_protocol = 0;
BlockDriver *bdrv_qcow2;
QEMUOptionParameter *options;
char backing_filename[PATH_MAX];
/* if snapshot, we create a temporary backing file and open it
instead of opening 'filename' directly */
/* if there is a backing file, use it */
bs1 = bdrv_new("");
ret = bdrv_open(bs1, filename, 0, drv);
if (ret < 0) {
bdrv_delete(bs1);
return ret;
}
total_size = bdrv_getlength(bs1) & BDRV_SECTOR_MASK;
if (bs1->drv && bs1->drv->protocol_name)
is_protocol = 1;
bdrv_delete(bs1);
get_tmp_filename(tmp_filename, sizeof(tmp_filename));
/* Real path is meaningless for protocols */
if (is_protocol)
snprintf(backing_filename, sizeof(backing_filename),
"%s", filename);
else if (!realpath(filename, backing_filename))
return -errno;
bdrv_qcow2 = bdrv_find_format("qcow2");
options = parse_option_parameters("", bdrv_qcow2->create_options, NULL);
set_option_parameter_int(options, BLOCK_OPT_SIZE, total_size);
set_option_parameter(options, BLOCK_OPT_BACKING_FILE, backing_filename);
if (drv) {
set_option_parameter(options, BLOCK_OPT_BACKING_FMT,
drv->format_name);
}
ret = bdrv_create(bdrv_qcow2, tmp_filename, options);
free_option_parameters(options);
if (ret < 0) {
return ret;
}
filename = tmp_filename;
drv = bdrv_qcow2;
bs->is_temporary = 1;
}
/* Find the right image format driver */
if (!drv) {
ret = find_image_format(filename, &drv);
}
if (!drv) {
goto unlink_and_fail;
}
/* Open the image */
ret = bdrv_open_common(bs, filename, flags, drv);
if (ret < 0) {
goto unlink_and_fail;
}
/* If there is a backing file, use it */
if ((flags & BDRV_O_NO_BACKING) == 0 && bs->backing_file[0] != '\0') {
char backing_filename[PATH_MAX];
int back_flags;
BlockDriver *back_drv = NULL;
bs->backing_hd = bdrv_new("");
bdrv_get_full_backing_filename(bs, backing_filename,
sizeof(backing_filename));
if (bs->backing_format[0] != '\0') {
back_drv = bdrv_find_format(bs->backing_format);
}
/* backing files always opened read-only */
back_flags =
flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);
ret = bdrv_open(bs->backing_hd, backing_filename, back_flags, back_drv);
if (ret < 0) {
bdrv_close(bs);
return ret;
}
if (bs->is_temporary) {
bs->backing_hd->keep_read_only = !(flags & BDRV_O_RDWR);
} else {
/* base image inherits from "parent" */
bs->backing_hd->keep_read_only = bs->keep_read_only;
}
}
if (!bdrv_key_required(bs)) {
bdrv_dev_change_media_cb(bs, true);
}
/* throttling disk I/O limits */
if (bs->io_limits_enabled) {
bdrv_io_limits_enable(bs);
}
return 0;
unlink_and_fail:
if (bs->is_temporary) {
unlink(filename);
}
return ret;
}
| true | qemu | c2d76497b6eafcaedc806e07804e7bed55a98a0b | int bdrv_open(BlockDriverState *bs, const char *filename, int flags,
BlockDriver *drv)
{
int ret;
char tmp_filename[PATH_MAX];
if (flags & BDRV_O_SNAPSHOT) {
BlockDriverState *bs1;
int64_t total_size;
int is_protocol = 0;
BlockDriver *bdrv_qcow2;
QEMUOptionParameter *options;
char backing_filename[PATH_MAX];
bs1 = bdrv_new("");
ret = bdrv_open(bs1, filename, 0, drv);
if (ret < 0) {
bdrv_delete(bs1);
return ret;
}
total_size = bdrv_getlength(bs1) & BDRV_SECTOR_MASK;
if (bs1->drv && bs1->drv->protocol_name)
is_protocol = 1;
bdrv_delete(bs1);
get_tmp_filename(tmp_filename, sizeof(tmp_filename));
if (is_protocol)
snprintf(backing_filename, sizeof(backing_filename),
"%s", filename);
else if (!realpath(filename, backing_filename))
return -errno;
bdrv_qcow2 = bdrv_find_format("qcow2");
options = parse_option_parameters("", bdrv_qcow2->create_options, NULL);
set_option_parameter_int(options, BLOCK_OPT_SIZE, total_size);
set_option_parameter(options, BLOCK_OPT_BACKING_FILE, backing_filename);
if (drv) {
set_option_parameter(options, BLOCK_OPT_BACKING_FMT,
drv->format_name);
}
ret = bdrv_create(bdrv_qcow2, tmp_filename, options);
free_option_parameters(options);
if (ret < 0) {
return ret;
}
filename = tmp_filename;
drv = bdrv_qcow2;
bs->is_temporary = 1;
}
if (!drv) {
ret = find_image_format(filename, &drv);
}
if (!drv) {
goto unlink_and_fail;
}
ret = bdrv_open_common(bs, filename, flags, drv);
if (ret < 0) {
goto unlink_and_fail;
}
if ((flags & BDRV_O_NO_BACKING) == 0 && bs->backing_file[0] != '\0') {
char backing_filename[PATH_MAX];
int back_flags;
BlockDriver *back_drv = NULL;
bs->backing_hd = bdrv_new("");
bdrv_get_full_backing_filename(bs, backing_filename,
sizeof(backing_filename));
if (bs->backing_format[0] != '\0') {
back_drv = bdrv_find_format(bs->backing_format);
}
back_flags =
flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);
ret = bdrv_open(bs->backing_hd, backing_filename, back_flags, back_drv);
if (ret < 0) {
bdrv_close(bs);
return ret;
}
if (bs->is_temporary) {
bs->backing_hd->keep_read_only = !(flags & BDRV_O_RDWR);
} else {
bs->backing_hd->keep_read_only = bs->keep_read_only;
}
}
if (!bdrv_key_required(bs)) {
bdrv_dev_change_media_cb(bs, true);
}
if (bs->io_limits_enabled) {
bdrv_io_limits_enable(bs);
}
return 0;
unlink_and_fail:
if (bs->is_temporary) {
unlink(filename);
}
return ret;
}
| {
"code": [
" get_tmp_filename(tmp_filename, sizeof(tmp_filename));"
],
"line_no": [
63
]
} | int FUNC_0(BlockDriverState *VAR_0, const char *VAR_1, int VAR_2,
BlockDriver *VAR_3)
{
int VAR_4;
char VAR_5[PATH_MAX];
if (VAR_2 & BDRV_O_SNAPSHOT) {
BlockDriverState *bs1;
int64_t total_size;
int VAR_6 = 0;
BlockDriver *bdrv_qcow2;
QEMUOptionParameter *options;
char VAR_8[PATH_MAX];
bs1 = bdrv_new("");
VAR_4 = FUNC_0(bs1, VAR_1, 0, VAR_3);
if (VAR_4 < 0) {
bdrv_delete(bs1);
return VAR_4;
}
total_size = bdrv_getlength(bs1) & BDRV_SECTOR_MASK;
if (bs1->VAR_3 && bs1->VAR_3->protocol_name)
VAR_6 = 1;
bdrv_delete(bs1);
get_tmp_filename(VAR_5, sizeof(VAR_5));
if (VAR_6)
snprintf(VAR_8, sizeof(VAR_8),
"%s", VAR_1);
else if (!realpath(VAR_1, VAR_8))
return -errno;
bdrv_qcow2 = bdrv_find_format("qcow2");
options = parse_option_parameters("", bdrv_qcow2->create_options, NULL);
set_option_parameter_int(options, BLOCK_OPT_SIZE, total_size);
set_option_parameter(options, BLOCK_OPT_BACKING_FILE, VAR_8);
if (VAR_3) {
set_option_parameter(options, BLOCK_OPT_BACKING_FMT,
VAR_3->format_name);
}
VAR_4 = bdrv_create(bdrv_qcow2, VAR_5, options);
free_option_parameters(options);
if (VAR_4 < 0) {
return VAR_4;
}
VAR_1 = VAR_5;
VAR_3 = bdrv_qcow2;
VAR_0->is_temporary = 1;
}
if (!VAR_3) {
VAR_4 = find_image_format(VAR_1, &VAR_3);
}
if (!VAR_3) {
goto unlink_and_fail;
}
VAR_4 = bdrv_open_common(VAR_0, VAR_1, VAR_2, VAR_3);
if (VAR_4 < 0) {
goto unlink_and_fail;
}
if ((VAR_2 & BDRV_O_NO_BACKING) == 0 && VAR_0->backing_file[0] != '\0') {
char VAR_8[PATH_MAX];
int VAR_8;
BlockDriver *back_drv = NULL;
VAR_0->backing_hd = bdrv_new("");
bdrv_get_full_backing_filename(VAR_0, VAR_8,
sizeof(VAR_8));
if (VAR_0->backing_format[0] != '\0') {
back_drv = bdrv_find_format(VAR_0->backing_format);
}
VAR_8 =
VAR_2 & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);
VAR_4 = FUNC_0(VAR_0->backing_hd, VAR_8, VAR_8, back_drv);
if (VAR_4 < 0) {
bdrv_close(VAR_0);
return VAR_4;
}
if (VAR_0->is_temporary) {
VAR_0->backing_hd->keep_read_only = !(VAR_2 & BDRV_O_RDWR);
} else {
VAR_0->backing_hd->keep_read_only = VAR_0->keep_read_only;
}
}
if (!bdrv_key_required(VAR_0)) {
bdrv_dev_change_media_cb(VAR_0, true);
}
if (VAR_0->io_limits_enabled) {
bdrv_io_limits_enable(VAR_0);
}
return 0;
unlink_and_fail:
if (VAR_0->is_temporary) {
unlink(VAR_1);
}
return VAR_4;
}
| [
"int FUNC_0(BlockDriverState *VAR_0, const char *VAR_1, int VAR_2,\nBlockDriver *VAR_3)\n{",
"int VAR_4;",
"char VAR_5[PATH_MAX];",
"if (VAR_2 & BDRV_O_SNAPSHOT) {",
"BlockDriverState *bs1;",
"int64_t total_size;",
"int VAR_6 = 0;",
"BlockDriver *bdrv_qcow2;",
"QEMUOptionParameter *options;",
"char VAR_8[PATH_MAX];",
"bs1 = bdrv_new(\"\");",
"VAR_4 = FUNC_0(bs1, VAR_1, 0, VAR_3);",
"if (VAR_4 < 0) {",
"bdrv_delete(bs1);",
"return VAR_4;",
"}",
"total_size = bdrv_getlength(bs1) & BDRV_SECTOR_MASK;",
"if (bs1->VAR_3 && bs1->VAR_3->protocol_name)\nVAR_6 = 1;",
"bdrv_delete(bs1);",
"get_tmp_filename(VAR_5, sizeof(VAR_5));",
"if (VAR_6)\nsnprintf(VAR_8, sizeof(VAR_8),\n\"%s\", VAR_1);",
"else if (!realpath(VAR_1, VAR_8))\nreturn -errno;",
"bdrv_qcow2 = bdrv_find_format(\"qcow2\");",
"options = parse_option_parameters(\"\", bdrv_qcow2->create_options, NULL);",
"set_option_parameter_int(options, BLOCK_OPT_SIZE, total_size);",
"set_option_parameter(options, BLOCK_OPT_BACKING_FILE, VAR_8);",
"if (VAR_3) {",
"set_option_parameter(options, BLOCK_OPT_BACKING_FMT,\nVAR_3->format_name);",
"}",
"VAR_4 = bdrv_create(bdrv_qcow2, VAR_5, options);",
"free_option_parameters(options);",
"if (VAR_4 < 0) {",
"return VAR_4;",
"}",
"VAR_1 = VAR_5;",
"VAR_3 = bdrv_qcow2;",
"VAR_0->is_temporary = 1;",
"}",
"if (!VAR_3) {",
"VAR_4 = find_image_format(VAR_1, &VAR_3);",
"}",
"if (!VAR_3) {",
"goto unlink_and_fail;",
"}",
"VAR_4 = bdrv_open_common(VAR_0, VAR_1, VAR_2, VAR_3);",
"if (VAR_4 < 0) {",
"goto unlink_and_fail;",
"}",
"if ((VAR_2 & BDRV_O_NO_BACKING) == 0 && VAR_0->backing_file[0] != '\\0') {",
"char VAR_8[PATH_MAX];",
"int VAR_8;",
"BlockDriver *back_drv = NULL;",
"VAR_0->backing_hd = bdrv_new(\"\");",
"bdrv_get_full_backing_filename(VAR_0, VAR_8,\nsizeof(VAR_8));",
"if (VAR_0->backing_format[0] != '\\0') {",
"back_drv = bdrv_find_format(VAR_0->backing_format);",
"}",
"VAR_8 =\nVAR_2 & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);",
"VAR_4 = FUNC_0(VAR_0->backing_hd, VAR_8, VAR_8, back_drv);",
"if (VAR_4 < 0) {",
"bdrv_close(VAR_0);",
"return VAR_4;",
"}",
"if (VAR_0->is_temporary) {",
"VAR_0->backing_hd->keep_read_only = !(VAR_2 & BDRV_O_RDWR);",
"} else {",
"VAR_0->backing_hd->keep_read_only = VAR_0->keep_read_only;",
"}",
"}",
"if (!bdrv_key_required(VAR_0)) {",
"bdrv_dev_change_media_cb(VAR_0, true);",
"}",
"if (VAR_0->io_limits_enabled) {",
"bdrv_io_limits_enable(VAR_0);",
"}",
"return 0;",
"unlink_and_fail:\nif (VAR_0->is_temporary) {",
"unlink(VAR_1);",
"}",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53,
55
],
[
59
],
[
63
],
[
69,
71,
73
],
[
75,
77
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93,
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
125
],
[
127
],
[
129
],
[
133
],
[
135
],
[
137
],
[
143
],
[
145
],
[
147
],
[
149
],
[
155
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167,
169
],
[
173
],
[
175
],
[
177
],
[
183,
185
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
207
],
[
209
],
[
211
],
[
215
],
[
217
],
[
219
],
[
225
],
[
227
],
[
229
],
[
233
],
[
237,
239
],
[
241
],
[
243
],
[
245
],
[
247
]
] |
4,518 | void helper_booke206_tlbwe(void)
{
uint32_t tlbncfg, tlbn;
ppcmas_tlb_t *tlb;
uint32_t size_tlb, size_ps;
switch (env->spr[SPR_BOOKE_MAS0] & MAS0_WQ_MASK) {
case MAS0_WQ_ALWAYS:
/* good to go, write that entry */
break;
case MAS0_WQ_COND:
/* XXX check if reserved */
if (0) {
return;
break;
case MAS0_WQ_CLR_RSRV:
/* XXX clear entry */
return;
default:
/* no idea what to do */
return;
if (((env->spr[SPR_BOOKE_MAS0] & MAS0_ATSEL) == MAS0_ATSEL_LRAT) &&
!msr_gs) {
/* XXX we don't support direct LRAT setting yet */
fprintf(stderr, "cpu: don't support LRAT setting yet\n");
return;
tlbn = (env->spr[SPR_BOOKE_MAS0] & MAS0_TLBSEL_MASK) >> MAS0_TLBSEL_SHIFT;
tlbncfg = env->spr[SPR_BOOKE_TLB0CFG + tlbn];
tlb = booke206_cur_tlb(env);
if (msr_gs) {
cpu_abort(env, "missing HV implementation\n");
tlb->mas7_3 = ((uint64_t)env->spr[SPR_BOOKE_MAS7] << 32) |
env->spr[SPR_BOOKE_MAS3];
tlb->mas1 = env->spr[SPR_BOOKE_MAS1];
/* XXX needs to change when supporting 64-bit e500 */
tlb->mas2 = env->spr[SPR_BOOKE_MAS2] & 0xffffffff;
if (!(tlbncfg & TLBnCFG_IPROT)) {
/* no IPROT supported by TLB */
tlb->mas1 &= ~MAS1_IPROT;
if (booke206_tlb_to_page_size(env, tlb) == TARGET_PAGE_SIZE) {
tlb_flush_page(env, tlb->mas2 & MAS2_EPN_MASK);
} else {
tlb_flush(env, 1); | true | qemu | 5935ee072d6fbcdf28ff6132ba6d8c3a1356bb0a | void helper_booke206_tlbwe(void)
{
uint32_t tlbncfg, tlbn;
ppcmas_tlb_t *tlb;
uint32_t size_tlb, size_ps;
switch (env->spr[SPR_BOOKE_MAS0] & MAS0_WQ_MASK) {
case MAS0_WQ_ALWAYS:
break;
case MAS0_WQ_COND:
if (0) {
return;
break;
case MAS0_WQ_CLR_RSRV:
return;
default:
return;
if (((env->spr[SPR_BOOKE_MAS0] & MAS0_ATSEL) == MAS0_ATSEL_LRAT) &&
!msr_gs) {
fprintf(stderr, "cpu: don't support LRAT setting yet\n");
return;
tlbn = (env->spr[SPR_BOOKE_MAS0] & MAS0_TLBSEL_MASK) >> MAS0_TLBSEL_SHIFT;
tlbncfg = env->spr[SPR_BOOKE_TLB0CFG + tlbn];
tlb = booke206_cur_tlb(env);
if (msr_gs) {
cpu_abort(env, "missing HV implementation\n");
tlb->mas7_3 = ((uint64_t)env->spr[SPR_BOOKE_MAS7] << 32) |
env->spr[SPR_BOOKE_MAS3];
tlb->mas1 = env->spr[SPR_BOOKE_MAS1];
tlb->mas2 = env->spr[SPR_BOOKE_MAS2] & 0xffffffff;
if (!(tlbncfg & TLBnCFG_IPROT)) {
tlb->mas1 &= ~MAS1_IPROT;
if (booke206_tlb_to_page_size(env, tlb) == TARGET_PAGE_SIZE) {
tlb_flush_page(env, tlb->mas2 & MAS2_EPN_MASK);
} else {
tlb_flush(env, 1); | {
"code": [],
"line_no": []
} | void FUNC_0(void)
{
uint32_t tlbncfg, tlbn;
ppcmas_tlb_t *tlb;
uint32_t size_tlb, size_ps;
switch (env->spr[SPR_BOOKE_MAS0] & MAS0_WQ_MASK) {
case MAS0_WQ_ALWAYS:
break;
case MAS0_WQ_COND:
if (0) {
return;
break;
case MAS0_WQ_CLR_RSRV:
return;
default:
return;
if (((env->spr[SPR_BOOKE_MAS0] & MAS0_ATSEL) == MAS0_ATSEL_LRAT) &&
!msr_gs) {
fprintf(stderr, "cpu: don't support LRAT setting yet\n");
return;
tlbn = (env->spr[SPR_BOOKE_MAS0] & MAS0_TLBSEL_MASK) >> MAS0_TLBSEL_SHIFT;
tlbncfg = env->spr[SPR_BOOKE_TLB0CFG + tlbn];
tlb = booke206_cur_tlb(env);
if (msr_gs) {
cpu_abort(env, "missing HV implementation\n");
tlb->mas7_3 = ((uint64_t)env->spr[SPR_BOOKE_MAS7] << 32) |
env->spr[SPR_BOOKE_MAS3];
tlb->mas1 = env->spr[SPR_BOOKE_MAS1];
tlb->mas2 = env->spr[SPR_BOOKE_MAS2] & 0xffffffff;
if (!(tlbncfg & TLBnCFG_IPROT)) {
tlb->mas1 &= ~MAS1_IPROT;
if (booke206_tlb_to_page_size(env, tlb) == TARGET_PAGE_SIZE) {
tlb_flush_page(env, tlb->mas2 & MAS2_EPN_MASK);
} else {
tlb_flush(env, 1); | [
"void FUNC_0(void)\n{",
"uint32_t tlbncfg, tlbn;",
"ppcmas_tlb_t *tlb;",
"uint32_t size_tlb, size_ps;",
"switch (env->spr[SPR_BOOKE_MAS0] & MAS0_WQ_MASK) {",
"case MAS0_WQ_ALWAYS:\nbreak;",
"case MAS0_WQ_COND:\nif (0) {",
"return;",
"break;",
"case MAS0_WQ_CLR_RSRV:\nreturn;",
"default:\nreturn;",
"if (((env->spr[SPR_BOOKE_MAS0] & MAS0_ATSEL) == MAS0_ATSEL_LRAT) &&\n!msr_gs) {",
"fprintf(stderr, \"cpu: don't support LRAT setting yet\\n\");",
"return;",
"tlbn = (env->spr[SPR_BOOKE_MAS0] & MAS0_TLBSEL_MASK) >> MAS0_TLBSEL_SHIFT;",
"tlbncfg = env->spr[SPR_BOOKE_TLB0CFG + tlbn];",
"tlb = booke206_cur_tlb(env);",
"if (msr_gs) {",
"cpu_abort(env, \"missing HV implementation\\n\");",
"tlb->mas7_3 = ((uint64_t)env->spr[SPR_BOOKE_MAS7] << 32) |\nenv->spr[SPR_BOOKE_MAS3];",
"tlb->mas1 = env->spr[SPR_BOOKE_MAS1];",
"tlb->mas2 = env->spr[SPR_BOOKE_MAS2] & 0xffffffff;",
"if (!(tlbncfg & TLBnCFG_IPROT)) {",
"tlb->mas1 &= ~MAS1_IPROT;",
"if (booke206_tlb_to_page_size(env, tlb) == TARGET_PAGE_SIZE) {",
"tlb_flush_page(env, tlb->mas2 & MAS2_EPN_MASK);",
"} else {",
"tlb_flush(env, 1);"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7,
9
],
[
10,
12
],
[
13
],
[
14
],
[
15,
17
],
[
18,
20
],
[
21,
22
],
[
24
],
[
25
],
[
26
],
[
27
],
[
28
],
[
29
],
[
30
],
[
31,
32
],
[
33
],
[
35
],
[
36
],
[
38
],
[
39
],
[
40
],
[
41
],
[
42
]
] |
4,520 | static void s390_qemu_cpu_model_initfn(Object *obj)
{
} | true | qemu | ad5afd07b628cd0610ea322ad60b5ad03aa250c8 | static void s390_qemu_cpu_model_initfn(Object *obj)
{
} | {
"code": [],
"line_no": []
} | static void FUNC_0(Object *VAR_0)
{
} | [
"static void FUNC_0(Object *VAR_0)\n{",
"}"
] | [
0,
0
] | [
[
1,
2
],
[
3
]
] |
4,523 | static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
{
AVFilterContext *ctx = inlink->dst;
TileContext *tile = ctx->priv;
AVFilterLink *outlink = ctx->outputs[0];
if (tile->current)
return 0;
outlink->out_buf = ff_get_video_buffer(outlink, AV_PERM_WRITE,
outlink->w, outlink->h);
avfilter_copy_buffer_ref_props(outlink->out_buf, picref);
outlink->out_buf->video->w = outlink->w;
outlink->out_buf->video->h = outlink->h;
/* fill surface once for margin/padding */
if (tile->margin || tile->padding)
ff_fill_rectangle(&tile->draw, &tile->blank,
outlink->out_buf->data, outlink->out_buf->linesize,
0, 0, outlink->w, outlink->h);
return 0;
}
| false | FFmpeg | 6f3d2fb18bb6225c27e22a95846c42f2093dc3b7 | static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
{
AVFilterContext *ctx = inlink->dst;
TileContext *tile = ctx->priv;
AVFilterLink *outlink = ctx->outputs[0];
if (tile->current)
return 0;
outlink->out_buf = ff_get_video_buffer(outlink, AV_PERM_WRITE,
outlink->w, outlink->h);
avfilter_copy_buffer_ref_props(outlink->out_buf, picref);
outlink->out_buf->video->w = outlink->w;
outlink->out_buf->video->h = outlink->h;
if (tile->margin || tile->padding)
ff_fill_rectangle(&tile->draw, &tile->blank,
outlink->out_buf->data, outlink->out_buf->linesize,
0, 0, outlink->w, outlink->h);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFilterLink *VAR_0, AVFilterBufferRef *VAR_1)
{
AVFilterContext *ctx = VAR_0->dst;
TileContext *tile = ctx->priv;
AVFilterLink *outlink = ctx->outputs[0];
if (tile->current)
return 0;
outlink->out_buf = ff_get_video_buffer(outlink, AV_PERM_WRITE,
outlink->w, outlink->h);
avfilter_copy_buffer_ref_props(outlink->out_buf, VAR_1);
outlink->out_buf->video->w = outlink->w;
outlink->out_buf->video->h = outlink->h;
if (tile->margin || tile->padding)
ff_fill_rectangle(&tile->draw, &tile->blank,
outlink->out_buf->data, outlink->out_buf->linesize,
0, 0, outlink->w, outlink->h);
return 0;
}
| [
"static int FUNC_0(AVFilterLink *VAR_0, AVFilterBufferRef *VAR_1)\n{",
"AVFilterContext *ctx = VAR_0->dst;",
"TileContext *tile = ctx->priv;",
"AVFilterLink *outlink = ctx->outputs[0];",
"if (tile->current)\nreturn 0;",
"outlink->out_buf = ff_get_video_buffer(outlink, AV_PERM_WRITE,\noutlink->w, outlink->h);",
"avfilter_copy_buffer_ref_props(outlink->out_buf, VAR_1);",
"outlink->out_buf->video->w = outlink->w;",
"outlink->out_buf->video->h = outlink->h;",
"if (tile->margin || tile->padding)\nff_fill_rectangle(&tile->draw, &tile->blank,\noutlink->out_buf->data, outlink->out_buf->linesize,\n0, 0, outlink->w, outlink->h);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
17,
19
],
[
21
],
[
23
],
[
25
],
[
31,
33,
35,
37
],
[
39
],
[
41
]
] |
4,526 | static int v4l2_read_header(AVFormatContext *ctx)
{
struct video_data *s = ctx->priv_data;
AVStream *st;
int res = 0;
uint32_t desired_format;
enum AVCodecID codec_id = AV_CODEC_ID_NONE;
enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE;
struct v4l2_input input = { 0 };
st = avformat_new_stream(ctx, NULL);
if (!st)
return AVERROR(ENOMEM);
#if CONFIG_LIBV4L2
/* silence libv4l2 logging. if fopen() fails v4l2_log_file will be NULL
and errors will get sent to stderr */
if (s->use_libv4l2)
v4l2_log_file = fopen("/dev/null", "w");
#endif
s->fd = device_open(ctx);
if (s->fd < 0)
return s->fd;
if (s->channel != -1) {
/* set video input */
av_log(ctx, AV_LOG_DEBUG, "Selecting input_channel: %d\n", s->channel);
if (v4l2_ioctl(s->fd, VIDIOC_S_INPUT, &s->channel) < 0) {
res = AVERROR(errno);
av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_S_INPUT): %s\n", av_err2str(res));
goto fail;
}
} else {
/* get current video input */
if (v4l2_ioctl(s->fd, VIDIOC_G_INPUT, &s->channel) < 0) {
res = AVERROR(errno);
av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_G_INPUT): %s\n", av_err2str(res));
goto fail;
}
}
/* enum input */
input.index = s->channel;
if (v4l2_ioctl(s->fd, VIDIOC_ENUMINPUT, &input) < 0) {
res = AVERROR(errno);
av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_ENUMINPUT): %s\n", av_err2str(res));
goto fail;
}
s->std_id = input.std;
av_log(ctx, AV_LOG_DEBUG, "Current input_channel: %d, input_name: %s, input_std: %"PRIx64"\n",
s->channel, input.name, (uint64_t)input.std);
if (s->list_format) {
list_formats(ctx, s->list_format);
res = AVERROR_EXIT;
goto fail;
}
if (s->list_standard) {
list_standards(ctx);
res = AVERROR_EXIT;
goto fail;
}
avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
if ((res = v4l2_set_parameters(ctx)) < 0)
goto fail;
if (s->pixel_format) {
AVCodec *codec = avcodec_find_decoder_by_name(s->pixel_format);
if (codec)
ctx->video_codec_id = codec->id;
pix_fmt = av_get_pix_fmt(s->pixel_format);
if (pix_fmt == AV_PIX_FMT_NONE && !codec) {
av_log(ctx, AV_LOG_ERROR, "No such input format: %s.\n",
s->pixel_format);
res = AVERROR(EINVAL);
goto fail;
}
}
if (!s->width && !s->height) {
struct v4l2_format fmt = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE };
av_log(ctx, AV_LOG_VERBOSE,
"Querying the device for the current frame size\n");
if (v4l2_ioctl(s->fd, VIDIOC_G_FMT, &fmt) < 0) {
res = AVERROR(errno);
av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_G_FMT): %s\n", av_err2str(res));
goto fail;
}
s->width = fmt.fmt.pix.width;
s->height = fmt.fmt.pix.height;
av_log(ctx, AV_LOG_VERBOSE,
"Setting frame size to %dx%d\n", s->width, s->height);
}
res = device_try_init(ctx, pix_fmt, &s->width, &s->height, &desired_format, &codec_id);
if (res < 0)
goto fail;
/* If no pixel_format was specified, the codec_id was not known up
* until now. Set video_codec_id in the context, as codec_id will
* not be available outside this function
*/
if (codec_id != AV_CODEC_ID_NONE && ctx->video_codec_id == AV_CODEC_ID_NONE)
ctx->video_codec_id = codec_id;
if ((res = av_image_check_size(s->width, s->height, 0, ctx)) < 0)
goto fail;
s->frame_format = desired_format;
st->codec->pix_fmt = avpriv_fmt_v4l2ff(desired_format, codec_id);
s->frame_size =
avpicture_get_size(st->codec->pix_fmt, s->width, s->height);
if ((res = mmap_init(ctx)) ||
(res = mmap_start(ctx)) < 0)
goto fail;
s->top_field_first = first_field(s);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = codec_id;
if (codec_id == AV_CODEC_ID_RAWVIDEO)
st->codec->codec_tag =
avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt);
else if (codec_id == AV_CODEC_ID_H264) {
st->need_parsing = AVSTREAM_PARSE_HEADERS;
}
if (desired_format == V4L2_PIX_FMT_YVU420)
st->codec->codec_tag = MKTAG('Y', 'V', '1', '2');
else if (desired_format == V4L2_PIX_FMT_YVU410)
st->codec->codec_tag = MKTAG('Y', 'V', 'U', '9');
st->codec->width = s->width;
st->codec->height = s->height;
if (st->avg_frame_rate.den)
st->codec->bit_rate = s->frame_size * av_q2d(st->avg_frame_rate) * 8;
return 0;
fail:
v4l2_close(s->fd);
return res;
}
| false | FFmpeg | 931da6a5e9dd54563fe5d4d30b7bd4d0a0218c87 | static int v4l2_read_header(AVFormatContext *ctx)
{
struct video_data *s = ctx->priv_data;
AVStream *st;
int res = 0;
uint32_t desired_format;
enum AVCodecID codec_id = AV_CODEC_ID_NONE;
enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE;
struct v4l2_input input = { 0 };
st = avformat_new_stream(ctx, NULL);
if (!st)
return AVERROR(ENOMEM);
#if CONFIG_LIBV4L2
if (s->use_libv4l2)
v4l2_log_file = fopen("/dev/null", "w");
#endif
s->fd = device_open(ctx);
if (s->fd < 0)
return s->fd;
if (s->channel != -1) {
av_log(ctx, AV_LOG_DEBUG, "Selecting input_channel: %d\n", s->channel);
if (v4l2_ioctl(s->fd, VIDIOC_S_INPUT, &s->channel) < 0) {
res = AVERROR(errno);
av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_S_INPUT): %s\n", av_err2str(res));
goto fail;
}
} else {
if (v4l2_ioctl(s->fd, VIDIOC_G_INPUT, &s->channel) < 0) {
res = AVERROR(errno);
av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_G_INPUT): %s\n", av_err2str(res));
goto fail;
}
}
input.index = s->channel;
if (v4l2_ioctl(s->fd, VIDIOC_ENUMINPUT, &input) < 0) {
res = AVERROR(errno);
av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_ENUMINPUT): %s\n", av_err2str(res));
goto fail;
}
s->std_id = input.std;
av_log(ctx, AV_LOG_DEBUG, "Current input_channel: %d, input_name: %s, input_std: %"PRIx64"\n",
s->channel, input.name, (uint64_t)input.std);
if (s->list_format) {
list_formats(ctx, s->list_format);
res = AVERROR_EXIT;
goto fail;
}
if (s->list_standard) {
list_standards(ctx);
res = AVERROR_EXIT;
goto fail;
}
avpriv_set_pts_info(st, 64, 1, 1000000);
if ((res = v4l2_set_parameters(ctx)) < 0)
goto fail;
if (s->pixel_format) {
AVCodec *codec = avcodec_find_decoder_by_name(s->pixel_format);
if (codec)
ctx->video_codec_id = codec->id;
pix_fmt = av_get_pix_fmt(s->pixel_format);
if (pix_fmt == AV_PIX_FMT_NONE && !codec) {
av_log(ctx, AV_LOG_ERROR, "No such input format: %s.\n",
s->pixel_format);
res = AVERROR(EINVAL);
goto fail;
}
}
if (!s->width && !s->height) {
struct v4l2_format fmt = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE };
av_log(ctx, AV_LOG_VERBOSE,
"Querying the device for the current frame size\n");
if (v4l2_ioctl(s->fd, VIDIOC_G_FMT, &fmt) < 0) {
res = AVERROR(errno);
av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_G_FMT): %s\n", av_err2str(res));
goto fail;
}
s->width = fmt.fmt.pix.width;
s->height = fmt.fmt.pix.height;
av_log(ctx, AV_LOG_VERBOSE,
"Setting frame size to %dx%d\n", s->width, s->height);
}
res = device_try_init(ctx, pix_fmt, &s->width, &s->height, &desired_format, &codec_id);
if (res < 0)
goto fail;
if (codec_id != AV_CODEC_ID_NONE && ctx->video_codec_id == AV_CODEC_ID_NONE)
ctx->video_codec_id = codec_id;
if ((res = av_image_check_size(s->width, s->height, 0, ctx)) < 0)
goto fail;
s->frame_format = desired_format;
st->codec->pix_fmt = avpriv_fmt_v4l2ff(desired_format, codec_id);
s->frame_size =
avpicture_get_size(st->codec->pix_fmt, s->width, s->height);
if ((res = mmap_init(ctx)) ||
(res = mmap_start(ctx)) < 0)
goto fail;
s->top_field_first = first_field(s);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = codec_id;
if (codec_id == AV_CODEC_ID_RAWVIDEO)
st->codec->codec_tag =
avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt);
else if (codec_id == AV_CODEC_ID_H264) {
st->need_parsing = AVSTREAM_PARSE_HEADERS;
}
if (desired_format == V4L2_PIX_FMT_YVU420)
st->codec->codec_tag = MKTAG('Y', 'V', '1', '2');
else if (desired_format == V4L2_PIX_FMT_YVU410)
st->codec->codec_tag = MKTAG('Y', 'V', 'U', '9');
st->codec->width = s->width;
st->codec->height = s->height;
if (st->avg_frame_rate.den)
st->codec->bit_rate = s->frame_size * av_q2d(st->avg_frame_rate) * 8;
return 0;
fail:
v4l2_close(s->fd);
return res;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0)
{
struct video_data *VAR_1 = VAR_0->priv_data;
AVStream *st;
int VAR_2 = 0;
uint32_t desired_format;
enum AVCodecID VAR_3 = AV_CODEC_ID_NONE;
enum AVPixelFormat VAR_4 = AV_PIX_FMT_NONE;
struct v4l2_input VAR_5 = { 0 };
st = avformat_new_stream(VAR_0, NULL);
if (!st)
return AVERROR(ENOMEM);
#if CONFIG_LIBV4L2
if (VAR_1->use_libv4l2)
v4l2_log_file = fopen("/dev/null", "w");
#endif
VAR_1->fd = device_open(VAR_0);
if (VAR_1->fd < 0)
return VAR_1->fd;
if (VAR_1->channel != -1) {
av_log(VAR_0, AV_LOG_DEBUG, "Selecting input_channel: %d\n", VAR_1->channel);
if (v4l2_ioctl(VAR_1->fd, VIDIOC_S_INPUT, &VAR_1->channel) < 0) {
VAR_2 = AVERROR(errno);
av_log(VAR_0, AV_LOG_ERROR, "ioctl(VIDIOC_S_INPUT): %VAR_1\n", av_err2str(VAR_2));
goto fail;
}
} else {
if (v4l2_ioctl(VAR_1->fd, VIDIOC_G_INPUT, &VAR_1->channel) < 0) {
VAR_2 = AVERROR(errno);
av_log(VAR_0, AV_LOG_ERROR, "ioctl(VIDIOC_G_INPUT): %VAR_1\n", av_err2str(VAR_2));
goto fail;
}
}
VAR_5.index = VAR_1->channel;
if (v4l2_ioctl(VAR_1->fd, VIDIOC_ENUMINPUT, &VAR_5) < 0) {
VAR_2 = AVERROR(errno);
av_log(VAR_0, AV_LOG_ERROR, "ioctl(VIDIOC_ENUMINPUT): %VAR_1\n", av_err2str(VAR_2));
goto fail;
}
VAR_1->std_id = VAR_5.std;
av_log(VAR_0, AV_LOG_DEBUG, "Current input_channel: %d, input_name: %VAR_1, input_std: %"PRIx64"\n",
VAR_1->channel, VAR_5.name, (uint64_t)VAR_5.std);
if (VAR_1->list_format) {
list_formats(VAR_0, VAR_1->list_format);
VAR_2 = AVERROR_EXIT;
goto fail;
}
if (VAR_1->list_standard) {
list_standards(VAR_0);
VAR_2 = AVERROR_EXIT;
goto fail;
}
avpriv_set_pts_info(st, 64, 1, 1000000);
if ((VAR_2 = v4l2_set_parameters(VAR_0)) < 0)
goto fail;
if (VAR_1->pixel_format) {
AVCodec *codec = avcodec_find_decoder_by_name(VAR_1->pixel_format);
if (codec)
VAR_0->video_codec_id = codec->id;
VAR_4 = av_get_pix_fmt(VAR_1->pixel_format);
if (VAR_4 == AV_PIX_FMT_NONE && !codec) {
av_log(VAR_0, AV_LOG_ERROR, "No such VAR_5 format: %VAR_1.\n",
VAR_1->pixel_format);
VAR_2 = AVERROR(EINVAL);
goto fail;
}
}
if (!VAR_1->width && !VAR_1->height) {
struct v4l2_format VAR_6 = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE };
av_log(VAR_0, AV_LOG_VERBOSE,
"Querying the device for the current frame size\n");
if (v4l2_ioctl(VAR_1->fd, VIDIOC_G_FMT, &VAR_6) < 0) {
VAR_2 = AVERROR(errno);
av_log(VAR_0, AV_LOG_ERROR, "ioctl(VIDIOC_G_FMT): %VAR_1\n", av_err2str(VAR_2));
goto fail;
}
VAR_1->width = VAR_6.VAR_6.pix.width;
VAR_1->height = VAR_6.VAR_6.pix.height;
av_log(VAR_0, AV_LOG_VERBOSE,
"Setting frame size to %dx%d\n", VAR_1->width, VAR_1->height);
}
VAR_2 = device_try_init(VAR_0, VAR_4, &VAR_1->width, &VAR_1->height, &desired_format, &VAR_3);
if (VAR_2 < 0)
goto fail;
if (VAR_3 != AV_CODEC_ID_NONE && VAR_0->video_codec_id == AV_CODEC_ID_NONE)
VAR_0->video_codec_id = VAR_3;
if ((VAR_2 = av_image_check_size(VAR_1->width, VAR_1->height, 0, VAR_0)) < 0)
goto fail;
VAR_1->frame_format = desired_format;
st->codec->VAR_4 = avpriv_fmt_v4l2ff(desired_format, VAR_3);
VAR_1->frame_size =
avpicture_get_size(st->codec->VAR_4, VAR_1->width, VAR_1->height);
if ((VAR_2 = mmap_init(VAR_0)) ||
(VAR_2 = mmap_start(VAR_0)) < 0)
goto fail;
VAR_1->top_field_first = first_field(VAR_1);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->VAR_3 = VAR_3;
if (VAR_3 == AV_CODEC_ID_RAWVIDEO)
st->codec->codec_tag =
avcodec_pix_fmt_to_codec_tag(st->codec->VAR_4);
else if (VAR_3 == AV_CODEC_ID_H264) {
st->need_parsing = AVSTREAM_PARSE_HEADERS;
}
if (desired_format == V4L2_PIX_FMT_YVU420)
st->codec->codec_tag = MKTAG('Y', 'V', '1', '2');
else if (desired_format == V4L2_PIX_FMT_YVU410)
st->codec->codec_tag = MKTAG('Y', 'V', 'U', '9');
st->codec->width = VAR_1->width;
st->codec->height = VAR_1->height;
if (st->avg_frame_rate.den)
st->codec->bit_rate = VAR_1->frame_size * av_q2d(st->avg_frame_rate) * 8;
return 0;
fail:
v4l2_close(VAR_1->fd);
return VAR_2;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"struct video_data *VAR_1 = VAR_0->priv_data;",
"AVStream *st;",
"int VAR_2 = 0;",
"uint32_t desired_format;",
"enum AVCodecID VAR_3 = AV_CODEC_ID_NONE;",
"enum AVPixelFormat VAR_4 = AV_PIX_FMT_NONE;",
"struct v4l2_input VAR_5 = { 0 };",
"st = avformat_new_stream(VAR_0, NULL);",
"if (!st)\nreturn AVERROR(ENOMEM);",
"#if CONFIG_LIBV4L2\nif (VAR_1->use_libv4l2)\nv4l2_log_file = fopen(\"/dev/null\", \"w\");",
"#endif\nVAR_1->fd = device_open(VAR_0);",
"if (VAR_1->fd < 0)\nreturn VAR_1->fd;",
"if (VAR_1->channel != -1) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Selecting input_channel: %d\\n\", VAR_1->channel);",
"if (v4l2_ioctl(VAR_1->fd, VIDIOC_S_INPUT, &VAR_1->channel) < 0) {",
"VAR_2 = AVERROR(errno);",
"av_log(VAR_0, AV_LOG_ERROR, \"ioctl(VIDIOC_S_INPUT): %VAR_1\\n\", av_err2str(VAR_2));",
"goto fail;",
"}",
"} else {",
"if (v4l2_ioctl(VAR_1->fd, VIDIOC_G_INPUT, &VAR_1->channel) < 0) {",
"VAR_2 = AVERROR(errno);",
"av_log(VAR_0, AV_LOG_ERROR, \"ioctl(VIDIOC_G_INPUT): %VAR_1\\n\", av_err2str(VAR_2));",
"goto fail;",
"}",
"}",
"VAR_5.index = VAR_1->channel;",
"if (v4l2_ioctl(VAR_1->fd, VIDIOC_ENUMINPUT, &VAR_5) < 0) {",
"VAR_2 = AVERROR(errno);",
"av_log(VAR_0, AV_LOG_ERROR, \"ioctl(VIDIOC_ENUMINPUT): %VAR_1\\n\", av_err2str(VAR_2));",
"goto fail;",
"}",
"VAR_1->std_id = VAR_5.std;",
"av_log(VAR_0, AV_LOG_DEBUG, \"Current input_channel: %d, input_name: %VAR_1, input_std: %\"PRIx64\"\\n\",\nVAR_1->channel, VAR_5.name, (uint64_t)VAR_5.std);",
"if (VAR_1->list_format) {",
"list_formats(VAR_0, VAR_1->list_format);",
"VAR_2 = AVERROR_EXIT;",
"goto fail;",
"}",
"if (VAR_1->list_standard) {",
"list_standards(VAR_0);",
"VAR_2 = AVERROR_EXIT;",
"goto fail;",
"}",
"avpriv_set_pts_info(st, 64, 1, 1000000);",
"if ((VAR_2 = v4l2_set_parameters(VAR_0)) < 0)\ngoto fail;",
"if (VAR_1->pixel_format) {",
"AVCodec *codec = avcodec_find_decoder_by_name(VAR_1->pixel_format);",
"if (codec)\nVAR_0->video_codec_id = codec->id;",
"VAR_4 = av_get_pix_fmt(VAR_1->pixel_format);",
"if (VAR_4 == AV_PIX_FMT_NONE && !codec) {",
"av_log(VAR_0, AV_LOG_ERROR, \"No such VAR_5 format: %VAR_1.\\n\",\nVAR_1->pixel_format);",
"VAR_2 = AVERROR(EINVAL);",
"goto fail;",
"}",
"}",
"if (!VAR_1->width && !VAR_1->height) {",
"struct v4l2_format VAR_6 = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE };",
"av_log(VAR_0, AV_LOG_VERBOSE,\n\"Querying the device for the current frame size\\n\");",
"if (v4l2_ioctl(VAR_1->fd, VIDIOC_G_FMT, &VAR_6) < 0) {",
"VAR_2 = AVERROR(errno);",
"av_log(VAR_0, AV_LOG_ERROR, \"ioctl(VIDIOC_G_FMT): %VAR_1\\n\", av_err2str(VAR_2));",
"goto fail;",
"}",
"VAR_1->width = VAR_6.VAR_6.pix.width;",
"VAR_1->height = VAR_6.VAR_6.pix.height;",
"av_log(VAR_0, AV_LOG_VERBOSE,\n\"Setting frame size to %dx%d\\n\", VAR_1->width, VAR_1->height);",
"}",
"VAR_2 = device_try_init(VAR_0, VAR_4, &VAR_1->width, &VAR_1->height, &desired_format, &VAR_3);",
"if (VAR_2 < 0)\ngoto fail;",
"if (VAR_3 != AV_CODEC_ID_NONE && VAR_0->video_codec_id == AV_CODEC_ID_NONE)\nVAR_0->video_codec_id = VAR_3;",
"if ((VAR_2 = av_image_check_size(VAR_1->width, VAR_1->height, 0, VAR_0)) < 0)\ngoto fail;",
"VAR_1->frame_format = desired_format;",
"st->codec->VAR_4 = avpriv_fmt_v4l2ff(desired_format, VAR_3);",
"VAR_1->frame_size =\navpicture_get_size(st->codec->VAR_4, VAR_1->width, VAR_1->height);",
"if ((VAR_2 = mmap_init(VAR_0)) ||\n(VAR_2 = mmap_start(VAR_0)) < 0)\ngoto fail;",
"VAR_1->top_field_first = first_field(VAR_1);",
"st->codec->codec_type = AVMEDIA_TYPE_VIDEO;",
"st->codec->VAR_3 = VAR_3;",
"if (VAR_3 == AV_CODEC_ID_RAWVIDEO)\nst->codec->codec_tag =\navcodec_pix_fmt_to_codec_tag(st->codec->VAR_4);",
"else if (VAR_3 == AV_CODEC_ID_H264) {",
"st->need_parsing = AVSTREAM_PARSE_HEADERS;",
"}",
"if (desired_format == V4L2_PIX_FMT_YVU420)\nst->codec->codec_tag = MKTAG('Y', 'V', '1', '2');",
"else if (desired_format == V4L2_PIX_FMT_YVU410)\nst->codec->codec_tag = MKTAG('Y', 'V', 'U', '9');",
"st->codec->width = VAR_1->width;",
"st->codec->height = VAR_1->height;",
"if (st->avg_frame_rate.den)\nst->codec->bit_rate = VAR_1->frame_size * av_q2d(st->avg_frame_rate) * 8;",
"return 0;",
"fail:\nv4l2_close(VAR_1->fd);",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23,
25
],
[
29,
35,
37
],
[
39,
43
],
[
45,
47
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101,
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
131
],
[
135,
137
],
[
141
],
[
143
],
[
147,
149
],
[
153
],
[
157
],
[
159,
161
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
181,
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
197
],
[
199
],
[
201,
203
],
[
205
],
[
209
],
[
211,
213
],
[
225,
227
],
[
231,
233
],
[
237
],
[
241
],
[
243,
245
],
[
249,
251,
253
],
[
257
],
[
261
],
[
263
],
[
265,
267,
269
],
[
271
],
[
273
],
[
275
],
[
277,
279
],
[
281,
283
],
[
285
],
[
287
],
[
289,
291
],
[
295
],
[
299,
301
],
[
303
],
[
305
]
] |
4,527 | static int output_frame(H264Context *h, AVFrame *dst, Picture *srcp)
{
AVFrame *src = &srcp->f;
int i;
int ret = av_frame_ref(dst, src);
if (ret < 0)
return ret;
av_dict_set(&dst->metadata, "stereo_mode", ff_h264_sei_stereo_mode(h), 0);
if (!srcp->crop)
return 0;
for (i = 0; i < 3; i++) {
int hshift = (i > 0) ? h->chroma_x_shift : 0;
int vshift = (i > 0) ? h->chroma_y_shift : 0;
int off = ((srcp->crop_left >> hshift) << h->pixel_shift) +
(srcp->crop_top >> vshift) * dst->linesize[i];
dst->data[i] += off;
}
return 0;
}
| false | FFmpeg | 8c55ff393340998faae887dfac19e7ef128e1e58 | static int output_frame(H264Context *h, AVFrame *dst, Picture *srcp)
{
AVFrame *src = &srcp->f;
int i;
int ret = av_frame_ref(dst, src);
if (ret < 0)
return ret;
av_dict_set(&dst->metadata, "stereo_mode", ff_h264_sei_stereo_mode(h), 0);
if (!srcp->crop)
return 0;
for (i = 0; i < 3; i++) {
int hshift = (i > 0) ? h->chroma_x_shift : 0;
int vshift = (i > 0) ? h->chroma_y_shift : 0;
int off = ((srcp->crop_left >> hshift) << h->pixel_shift) +
(srcp->crop_top >> vshift) * dst->linesize[i];
dst->data[i] += off;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(H264Context *VAR_0, AVFrame *VAR_1, Picture *VAR_2)
{
AVFrame *src = &VAR_2->f;
int VAR_3;
int VAR_4 = av_frame_ref(VAR_1, src);
if (VAR_4 < 0)
return VAR_4;
av_dict_set(&VAR_1->metadata, "stereo_mode", ff_h264_sei_stereo_mode(VAR_0), 0);
if (!VAR_2->crop)
return 0;
for (VAR_3 = 0; VAR_3 < 3; VAR_3++) {
int VAR_5 = (VAR_3 > 0) ? VAR_0->chroma_x_shift : 0;
int VAR_6 = (VAR_3 > 0) ? VAR_0->chroma_y_shift : 0;
int VAR_7 = ((VAR_2->crop_left >> VAR_5) << VAR_0->pixel_shift) +
(VAR_2->crop_top >> VAR_6) * VAR_1->linesize[VAR_3];
VAR_1->data[VAR_3] += VAR_7;
}
return 0;
}
| [
"static int FUNC_0(H264Context *VAR_0, AVFrame *VAR_1, Picture *VAR_2)\n{",
"AVFrame *src = &VAR_2->f;",
"int VAR_3;",
"int VAR_4 = av_frame_ref(VAR_1, src);",
"if (VAR_4 < 0)\nreturn VAR_4;",
"av_dict_set(&VAR_1->metadata, \"stereo_mode\", ff_h264_sei_stereo_mode(VAR_0), 0);",
"if (!VAR_2->crop)\nreturn 0;",
"for (VAR_3 = 0; VAR_3 < 3; VAR_3++) {",
"int VAR_5 = (VAR_3 > 0) ? VAR_0->chroma_x_shift : 0;",
"int VAR_6 = (VAR_3 > 0) ? VAR_0->chroma_y_shift : 0;",
"int VAR_7 = ((VAR_2->crop_left >> VAR_5) << VAR_0->pixel_shift) +\n(VAR_2->crop_top >> VAR_6) * VAR_1->linesize[VAR_3];",
"VAR_1->data[VAR_3] += VAR_7;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13
],
[
17
],
[
21,
23
],
[
27
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
]
] |
4,528 | static int flac_write_header(struct AVFormatContext *s)
{
int ret;
AVCodecContext *codec = s->streams[0]->codec;
FlacMuxerContext *c = s->priv_data;
if (!c->write_header)
return 0;
ret = ff_flac_write_header(s->pb, codec, 0);
if (ret)
return ret;
ret = flac_write_block_comment(s->pb, &s->metadata, 0,
codec->flags & CODEC_FLAG_BITEXACT);
if (ret)
return ret;
/* The command line flac encoder defaults to placing a seekpoint
* every 10s. So one might add padding to allow that later
* but there seems to be no simple way to get the duration here.
* So let's try the flac default of 8192 bytes */
flac_write_block_padding(s->pb, 8192, 1);
return ret;
}
| false | FFmpeg | 0c1959b056f6ccaa2eee2c824352ba93c8e36d52 | static int flac_write_header(struct AVFormatContext *s)
{
int ret;
AVCodecContext *codec = s->streams[0]->codec;
FlacMuxerContext *c = s->priv_data;
if (!c->write_header)
return 0;
ret = ff_flac_write_header(s->pb, codec, 0);
if (ret)
return ret;
ret = flac_write_block_comment(s->pb, &s->metadata, 0,
codec->flags & CODEC_FLAG_BITEXACT);
if (ret)
return ret;
flac_write_block_padding(s->pb, 8192, 1);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(struct AVFormatContext *VAR_0)
{
int VAR_1;
AVCodecContext *codec = VAR_0->streams[0]->codec;
FlacMuxerContext *c = VAR_0->priv_data;
if (!c->write_header)
return 0;
VAR_1 = ff_flac_write_header(VAR_0->pb, codec, 0);
if (VAR_1)
return VAR_1;
VAR_1 = flac_write_block_comment(VAR_0->pb, &VAR_0->metadata, 0,
codec->flags & CODEC_FLAG_BITEXACT);
if (VAR_1)
return VAR_1;
flac_write_block_padding(VAR_0->pb, 8192, 1);
return VAR_1;
}
| [
"static int FUNC_0(struct AVFormatContext *VAR_0)\n{",
"int VAR_1;",
"AVCodecContext *codec = VAR_0->streams[0]->codec;",
"FlacMuxerContext *c = VAR_0->priv_data;",
"if (!c->write_header)\nreturn 0;",
"VAR_1 = ff_flac_write_header(VAR_0->pb, codec, 0);",
"if (VAR_1)\nreturn VAR_1;",
"VAR_1 = flac_write_block_comment(VAR_0->pb, &VAR_0->metadata, 0,\ncodec->flags & CODEC_FLAG_BITEXACT);",
"if (VAR_1)\nreturn VAR_1;",
"flac_write_block_padding(VAR_0->pb, 8192, 1);",
"return VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
19
],
[
21,
23
],
[
27,
29
],
[
31,
33
],
[
45
],
[
49
],
[
51
]
] |
4,529 | int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q)
{
int opaque_alloc = 0;
int ret;
q->param.IOPattern = MFX_IOPATTERN_IN_SYSTEM_MEMORY;
q->param.AsyncDepth = q->async_depth;
q->async_fifo = av_fifo_alloc((1 + q->async_depth) *
(sizeof(AVPacket) + sizeof(mfxSyncPoint) + sizeof(mfxBitstream*)));
if (!q->async_fifo)
return AVERROR(ENOMEM);
if (avctx->hwaccel_context) {
AVQSVContext *qsv = avctx->hwaccel_context;
q->session = qsv->session;
q->param.IOPattern = qsv->iopattern;
opaque_alloc = qsv->opaque_alloc;
}
if (!q->session) {
ret = ff_qsv_init_internal_session(avctx, &q->internal_session,
q->load_plugins);
if (ret < 0)
return ret;
q->session = q->internal_session;
}
ret = init_video_param(avctx, q);
if (ret < 0)
return ret;
ret = MFXVideoENCODE_QueryIOSurf(q->session, &q->param, &q->req);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Error querying the encoding parameters\n");
return ff_qsv_error(ret);
}
if (opaque_alloc) {
ret = qsv_init_opaque_alloc(avctx, q);
if (ret < 0)
return ret;
}
if (avctx->hwaccel_context) {
AVQSVContext *qsv = avctx->hwaccel_context;
int i, j;
q->extparam = av_mallocz_array(qsv->nb_ext_buffers + q->nb_extparam_internal,
sizeof(*q->extparam));
if (!q->extparam)
return AVERROR(ENOMEM);
q->param.ExtParam = q->extparam;
for (i = 0; i < qsv->nb_ext_buffers; i++)
q->param.ExtParam[i] = qsv->ext_buffers[i];
q->param.NumExtParam = qsv->nb_ext_buffers;
for (i = 0; i < q->nb_extparam_internal; i++) {
for (j = 0; j < qsv->nb_ext_buffers; j++) {
if (qsv->ext_buffers[j]->BufferId == q->extparam_internal[i]->BufferId)
break;
}
if (j < qsv->nb_ext_buffers)
continue;
q->param.ExtParam[q->param.NumExtParam++] = q->extparam_internal[i];
}
} else {
q->param.ExtParam = q->extparam_internal;
q->param.NumExtParam = q->nb_extparam_internal;
}
ret = MFXVideoENCODE_Init(q->session, &q->param);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Error initializing the encoder\n");
return ff_qsv_error(ret);
}
ret = qsv_retrieve_enc_params(avctx, q);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Error retrieving encoding parameters.\n");
return ret;
}
q->avctx = avctx;
return 0;
}
| false | FFmpeg | a1335149fd610b16459d9281b611282cac51c950 | int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q)
{
int opaque_alloc = 0;
int ret;
q->param.IOPattern = MFX_IOPATTERN_IN_SYSTEM_MEMORY;
q->param.AsyncDepth = q->async_depth;
q->async_fifo = av_fifo_alloc((1 + q->async_depth) *
(sizeof(AVPacket) + sizeof(mfxSyncPoint) + sizeof(mfxBitstream*)));
if (!q->async_fifo)
return AVERROR(ENOMEM);
if (avctx->hwaccel_context) {
AVQSVContext *qsv = avctx->hwaccel_context;
q->session = qsv->session;
q->param.IOPattern = qsv->iopattern;
opaque_alloc = qsv->opaque_alloc;
}
if (!q->session) {
ret = ff_qsv_init_internal_session(avctx, &q->internal_session,
q->load_plugins);
if (ret < 0)
return ret;
q->session = q->internal_session;
}
ret = init_video_param(avctx, q);
if (ret < 0)
return ret;
ret = MFXVideoENCODE_QueryIOSurf(q->session, &q->param, &q->req);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Error querying the encoding parameters\n");
return ff_qsv_error(ret);
}
if (opaque_alloc) {
ret = qsv_init_opaque_alloc(avctx, q);
if (ret < 0)
return ret;
}
if (avctx->hwaccel_context) {
AVQSVContext *qsv = avctx->hwaccel_context;
int i, j;
q->extparam = av_mallocz_array(qsv->nb_ext_buffers + q->nb_extparam_internal,
sizeof(*q->extparam));
if (!q->extparam)
return AVERROR(ENOMEM);
q->param.ExtParam = q->extparam;
for (i = 0; i < qsv->nb_ext_buffers; i++)
q->param.ExtParam[i] = qsv->ext_buffers[i];
q->param.NumExtParam = qsv->nb_ext_buffers;
for (i = 0; i < q->nb_extparam_internal; i++) {
for (j = 0; j < qsv->nb_ext_buffers; j++) {
if (qsv->ext_buffers[j]->BufferId == q->extparam_internal[i]->BufferId)
break;
}
if (j < qsv->nb_ext_buffers)
continue;
q->param.ExtParam[q->param.NumExtParam++] = q->extparam_internal[i];
}
} else {
q->param.ExtParam = q->extparam_internal;
q->param.NumExtParam = q->nb_extparam_internal;
}
ret = MFXVideoENCODE_Init(q->session, &q->param);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Error initializing the encoder\n");
return ff_qsv_error(ret);
}
ret = qsv_retrieve_enc_params(avctx, q);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Error retrieving encoding parameters.\n");
return ret;
}
q->avctx = avctx;
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVCodecContext *VAR_0, QSVEncContext *VAR_1)
{
int VAR_2 = 0;
int VAR_3;
VAR_1->param.IOPattern = MFX_IOPATTERN_IN_SYSTEM_MEMORY;
VAR_1->param.AsyncDepth = VAR_1->async_depth;
VAR_1->async_fifo = av_fifo_alloc((1 + VAR_1->async_depth) *
(sizeof(AVPacket) + sizeof(mfxSyncPoint) + sizeof(mfxBitstream*)));
if (!VAR_1->async_fifo)
return AVERROR(ENOMEM);
if (VAR_0->hwaccel_context) {
AVQSVContext *qsv = VAR_0->hwaccel_context;
VAR_1->session = qsv->session;
VAR_1->param.IOPattern = qsv->iopattern;
VAR_2 = qsv->VAR_2;
}
if (!VAR_1->session) {
VAR_3 = ff_qsv_init_internal_session(VAR_0, &VAR_1->internal_session,
VAR_1->load_plugins);
if (VAR_3 < 0)
return VAR_3;
VAR_1->session = VAR_1->internal_session;
}
VAR_3 = init_video_param(VAR_0, VAR_1);
if (VAR_3 < 0)
return VAR_3;
VAR_3 = MFXVideoENCODE_QueryIOSurf(VAR_1->session, &VAR_1->param, &VAR_1->req);
if (VAR_3 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Error querying the encoding parameters\n");
return ff_qsv_error(VAR_3);
}
if (VAR_2) {
VAR_3 = qsv_init_opaque_alloc(VAR_0, VAR_1);
if (VAR_3 < 0)
return VAR_3;
}
if (VAR_0->hwaccel_context) {
AVQSVContext *qsv = VAR_0->hwaccel_context;
int VAR_4, VAR_5;
VAR_1->extparam = av_mallocz_array(qsv->nb_ext_buffers + VAR_1->nb_extparam_internal,
sizeof(*VAR_1->extparam));
if (!VAR_1->extparam)
return AVERROR(ENOMEM);
VAR_1->param.ExtParam = VAR_1->extparam;
for (VAR_4 = 0; VAR_4 < qsv->nb_ext_buffers; VAR_4++)
VAR_1->param.ExtParam[VAR_4] = qsv->ext_buffers[VAR_4];
VAR_1->param.NumExtParam = qsv->nb_ext_buffers;
for (VAR_4 = 0; VAR_4 < VAR_1->nb_extparam_internal; VAR_4++) {
for (VAR_5 = 0; VAR_5 < qsv->nb_ext_buffers; VAR_5++) {
if (qsv->ext_buffers[VAR_5]->BufferId == VAR_1->extparam_internal[VAR_4]->BufferId)
break;
}
if (VAR_5 < qsv->nb_ext_buffers)
continue;
VAR_1->param.ExtParam[VAR_1->param.NumExtParam++] = VAR_1->extparam_internal[VAR_4];
}
} else {
VAR_1->param.ExtParam = VAR_1->extparam_internal;
VAR_1->param.NumExtParam = VAR_1->nb_extparam_internal;
}
VAR_3 = MFXVideoENCODE_Init(VAR_1->session, &VAR_1->param);
if (VAR_3 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Error initializing the encoder\n");
return ff_qsv_error(VAR_3);
}
VAR_3 = qsv_retrieve_enc_params(VAR_0, VAR_1);
if (VAR_3 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Error retrieving encoding parameters.\n");
return VAR_3;
}
VAR_1->VAR_0 = VAR_0;
return 0;
}
| [
"int FUNC_0(AVCodecContext *VAR_0, QSVEncContext *VAR_1)\n{",
"int VAR_2 = 0;",
"int VAR_3;",
"VAR_1->param.IOPattern = MFX_IOPATTERN_IN_SYSTEM_MEMORY;",
"VAR_1->param.AsyncDepth = VAR_1->async_depth;",
"VAR_1->async_fifo = av_fifo_alloc((1 + VAR_1->async_depth) *\n(sizeof(AVPacket) + sizeof(mfxSyncPoint) + sizeof(mfxBitstream*)));",
"if (!VAR_1->async_fifo)\nreturn AVERROR(ENOMEM);",
"if (VAR_0->hwaccel_context) {",
"AVQSVContext *qsv = VAR_0->hwaccel_context;",
"VAR_1->session = qsv->session;",
"VAR_1->param.IOPattern = qsv->iopattern;",
"VAR_2 = qsv->VAR_2;",
"}",
"if (!VAR_1->session) {",
"VAR_3 = ff_qsv_init_internal_session(VAR_0, &VAR_1->internal_session,\nVAR_1->load_plugins);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"VAR_1->session = VAR_1->internal_session;",
"}",
"VAR_3 = init_video_param(VAR_0, VAR_1);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"VAR_3 = MFXVideoENCODE_QueryIOSurf(VAR_1->session, &VAR_1->param, &VAR_1->req);",
"if (VAR_3 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error querying the encoding parameters\\n\");",
"return ff_qsv_error(VAR_3);",
"}",
"if (VAR_2) {",
"VAR_3 = qsv_init_opaque_alloc(VAR_0, VAR_1);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"}",
"if (VAR_0->hwaccel_context) {",
"AVQSVContext *qsv = VAR_0->hwaccel_context;",
"int VAR_4, VAR_5;",
"VAR_1->extparam = av_mallocz_array(qsv->nb_ext_buffers + VAR_1->nb_extparam_internal,\nsizeof(*VAR_1->extparam));",
"if (!VAR_1->extparam)\nreturn AVERROR(ENOMEM);",
"VAR_1->param.ExtParam = VAR_1->extparam;",
"for (VAR_4 = 0; VAR_4 < qsv->nb_ext_buffers; VAR_4++)",
"VAR_1->param.ExtParam[VAR_4] = qsv->ext_buffers[VAR_4];",
"VAR_1->param.NumExtParam = qsv->nb_ext_buffers;",
"for (VAR_4 = 0; VAR_4 < VAR_1->nb_extparam_internal; VAR_4++) {",
"for (VAR_5 = 0; VAR_5 < qsv->nb_ext_buffers; VAR_5++) {",
"if (qsv->ext_buffers[VAR_5]->BufferId == VAR_1->extparam_internal[VAR_4]->BufferId)\nbreak;",
"}",
"if (VAR_5 < qsv->nb_ext_buffers)\ncontinue;",
"VAR_1->param.ExtParam[VAR_1->param.NumExtParam++] = VAR_1->extparam_internal[VAR_4];",
"}",
"} else {",
"VAR_1->param.ExtParam = VAR_1->extparam_internal;",
"VAR_1->param.NumExtParam = VAR_1->nb_extparam_internal;",
"}",
"VAR_3 = MFXVideoENCODE_Init(VAR_1->session, &VAR_1->param);",
"if (VAR_3 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error initializing the encoder\\n\");",
"return ff_qsv_error(VAR_3);",
"}",
"VAR_3 = qsv_retrieve_enc_params(VAR_0, VAR_1);",
"if (VAR_3 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error retrieving encoding parameters.\\n\");",
"return VAR_3;",
"}",
"VAR_1->VAR_0 = VAR_0;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17,
19
],
[
21,
23
],
[
27
],
[
29
],
[
33
],
[
35
],
[
39
],
[
41
],
[
45
],
[
47,
49
],
[
51,
53
],
[
57
],
[
59
],
[
63
],
[
65,
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87,
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
103,
105
],
[
107,
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127,
129
],
[
131
],
[
133,
135
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
177
],
[
181
],
[
183
]
] |
4,531 | void st_print_trace(FILE *stream, int (*stream_printf)(FILE *stream, const char *fmt, ...))
{
unsigned int i;
for (i = 0; i < TRACE_BUF_LEN; i++) {
TraceRecord record;
if (!get_trace_record(i, &record)) {
continue;
}
stream_printf(stream, "Event %" PRIu64 " : %" PRIx64 " %" PRIx64
" %" PRIx64 " %" PRIx64 " %" PRIx64 " %" PRIx64 "\n",
record.event, record.x1, record.x2,
record.x3, record.x4, record.x5,
record.x6);
}
}
| true | qemu | 88affa1c77c9019f3450f851495997897bd14e40 | void st_print_trace(FILE *stream, int (*stream_printf)(FILE *stream, const char *fmt, ...))
{
unsigned int i;
for (i = 0; i < TRACE_BUF_LEN; i++) {
TraceRecord record;
if (!get_trace_record(i, &record)) {
continue;
}
stream_printf(stream, "Event %" PRIu64 " : %" PRIx64 " %" PRIx64
" %" PRIx64 " %" PRIx64 " %" PRIx64 " %" PRIx64 "\n",
record.event, record.x1, record.x2,
record.x3, record.x4, record.x5,
record.x6);
}
}
| {
"code": [
"void st_print_trace(FILE *stream, int (*stream_printf)(FILE *stream, const char *fmt, ...))",
" unsigned int i;",
" for (i = 0; i < TRACE_BUF_LEN; i++) {",
" TraceRecord record;",
" if (!get_trace_record(i, &record)) {",
" continue;",
" stream_printf(stream, \"Event %\" PRIu64 \" : %\" PRIx64 \" %\" PRIx64",
" \" %\" PRIx64 \" %\" PRIx64 \" %\" PRIx64 \" %\" PRIx64 \"\\n\",",
" record.event, record.x1, record.x2,",
" record.x3, record.x4, record.x5,",
" record.x6);"
],
"line_no": [
1,
5,
9,
11,
15,
17,
21,
23,
25,
27,
29
]
} | void FUNC_0(FILE *VAR_2, int (*VAR_1)(FILE *VAR_2, const char *VAR_2, ...))
{
unsigned int VAR_3;
for (VAR_3 = 0; VAR_3 < TRACE_BUF_LEN; VAR_3++) {
TraceRecord record;
if (!get_trace_record(VAR_3, &record)) {
continue;
}
VAR_1(VAR_2, "Event %" PRIu64 " : %" PRIx64 " %" PRIx64
" %" PRIx64 " %" PRIx64 " %" PRIx64 " %" PRIx64 "\n",
record.event, record.x1, record.x2,
record.x3, record.x4, record.x5,
record.x6);
}
}
| [
"void FUNC_0(FILE *VAR_2, int (*VAR_1)(FILE *VAR_2, const char *VAR_2, ...))\n{",
"unsigned int VAR_3;",
"for (VAR_3 = 0; VAR_3 < TRACE_BUF_LEN; VAR_3++) {",
"TraceRecord record;",
"if (!get_trace_record(VAR_3, &record)) {",
"continue;",
"}",
"VAR_1(VAR_2, \"Event %\" PRIu64 \" : %\" PRIx64 \" %\" PRIx64\n\" %\" PRIx64 \" %\" PRIx64 \" %\" PRIx64 \" %\" PRIx64 \"\\n\",\nrecord.event, record.x1, record.x2,\nrecord.x3, record.x4, record.x5,\nrecord.x6);",
"}",
"}"
] | [
1,
1,
1,
1,
1,
1,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21,
23,
25,
27,
29
],
[
31
],
[
33
]
] |
4,532 | static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) {
GetBitContext *gb=&vc->gb;
uint_fast16_t i,j,k;
vc->floor_count=get_bits(gb, 6)+1;
vc->floors=av_mallocz(vc->floor_count * sizeof(vorbis_floor));
for (i=0;i<vc->floor_count;++i) {
vorbis_floor *floor_setup=&vc->floors[i];
floor_setup->floor_type=get_bits(gb, 16);
AV_DEBUG(" %d. floor type %d \n", i, floor_setup->floor_type);
if (floor_setup->floor_type==1) {
uint_fast8_t maximum_class=0;
uint_fast8_t rangebits;
uint_fast16_t floor1_values=2;
floor_setup->decode=vorbis_floor1_decode;
floor_setup->data.t1.partitions=get_bits(gb, 5);
AV_DEBUG(" %d.floor: %d partitions \n", i, floor_setup->data.t1.partitions);
for(j=0;j<floor_setup->data.t1.partitions;++j) {
floor_setup->data.t1.partition_class[j]=get_bits(gb, 4);
if (floor_setup->data.t1.partition_class[j]>maximum_class) maximum_class=floor_setup->data.t1.partition_class[j];
AV_DEBUG(" %d. floor %d partition class %d \n", i, j, floor_setup->data.t1.partition_class[j]);
}
AV_DEBUG(" maximum class %d \n", maximum_class);
floor_setup->data.t1.maximum_class=maximum_class;
for(j=0;j<=maximum_class;++j) {
floor_setup->data.t1.class_dimensions[j]=get_bits(gb, 3)+1;
floor_setup->data.t1.class_subclasses[j]=get_bits(gb, 2);
AV_DEBUG(" %d floor %d class dim: %d subclasses %d \n", i, j, floor_setup->data.t1.class_dimensions[j], floor_setup->data.t1.class_subclasses[j]);
if (floor_setup->data.t1.class_subclasses[j]) {
floor_setup->data.t1.class_masterbook[j]=get_bits(gb, 8);
AV_DEBUG(" masterbook: %d \n", floor_setup->data.t1.class_masterbook[j]);
}
for(k=0;k<(1<<floor_setup->data.t1.class_subclasses[j]);++k) {
floor_setup->data.t1.subclass_books[j][k]=(int16_t)get_bits(gb, 8)-1;
AV_DEBUG(" book %d. : %d \n", k, floor_setup->data.t1.subclass_books[j][k]);
}
}
floor_setup->data.t1.multiplier=get_bits(gb, 2)+1;
floor_setup->data.t1.x_list_dim=2;
for(j=0;j<floor_setup->data.t1.partitions;++j) {
floor_setup->data.t1.x_list_dim+=floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]];
}
floor_setup->data.t1.list=av_mallocz(floor_setup->data.t1.x_list_dim * sizeof(vorbis_floor1_entry));
rangebits=get_bits(gb, 4);
floor_setup->data.t1.list[0].x = 0;
floor_setup->data.t1.list[1].x = (1<<rangebits);
for(j=0;j<floor_setup->data.t1.partitions;++j) {
for(k=0;k<floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]];++k,++floor1_values) {
floor_setup->data.t1.list[floor1_values].x=get_bits(gb, rangebits);
AV_DEBUG(" %d. floor1 Y coord. %d \n", floor1_values, floor_setup->data.t1.list[floor1_values].x);
}
}
// Precalculate order of x coordinates - needed for decode
ff_vorbis_ready_floor1_list(floor_setup->data.t1.list, floor_setup->data.t1.x_list_dim);
}
else if(floor_setup->floor_type==0) {
uint_fast8_t max_codebook_dim=0;
floor_setup->decode=vorbis_floor0_decode;
floor_setup->data.t0.order=get_bits(gb, 8);
floor_setup->data.t0.rate=get_bits(gb, 16);
floor_setup->data.t0.bark_map_size=get_bits(gb, 16);
floor_setup->data.t0.amplitude_bits=get_bits(gb, 6);
/* zero would result in a div by zero later *
* 2^0 - 1 == 0 */
if (floor_setup->data.t0.amplitude_bits == 0) {
av_log(vc->avccontext, AV_LOG_ERROR,
"Floor 0 amplitude bits is 0.\n");
return 1;
}
floor_setup->data.t0.amplitude_offset=get_bits(gb, 8);
floor_setup->data.t0.num_books=get_bits(gb, 4)+1;
/* allocate mem for booklist */
floor_setup->data.t0.book_list=
av_malloc(floor_setup->data.t0.num_books);
if(!floor_setup->data.t0.book_list) { return 1; }
/* read book indexes */
{
int idx;
uint_fast8_t book_idx;
for (idx=0;idx<floor_setup->data.t0.num_books;++idx) {
book_idx=get_bits(gb, 8);
if (book_idx>=vc->codebook_count)
return 1;
floor_setup->data.t0.book_list[idx]=book_idx;
if (vc->codebooks[book_idx].dimensions > max_codebook_dim)
max_codebook_dim=vc->codebooks[book_idx].dimensions;
}
}
create_map( vc, i );
/* allocate mem for lsp coefficients */
{
/* codebook dim is for padding if codebook dim doesn't *
* divide order+1 then we need to read more data */
floor_setup->data.t0.lsp=
av_malloc((floor_setup->data.t0.order+1 + max_codebook_dim)
* sizeof(float));
if(!floor_setup->data.t0.lsp) { return 1; }
}
#ifdef V_DEBUG /* debug output parsed headers */
AV_DEBUG("floor0 order: %u\n", floor_setup->data.t0.order);
AV_DEBUG("floor0 rate: %u\n", floor_setup->data.t0.rate);
AV_DEBUG("floor0 bark map size: %u\n",
floor_setup->data.t0.bark_map_size);
AV_DEBUG("floor0 amplitude bits: %u\n",
floor_setup->data.t0.amplitude_bits);
AV_DEBUG("floor0 amplitude offset: %u\n",
floor_setup->data.t0.amplitude_offset);
AV_DEBUG("floor0 number of books: %u\n",
floor_setup->data.t0.num_books);
AV_DEBUG("floor0 book list pointer: %p\n",
floor_setup->data.t0.book_list);
{
int idx;
for (idx=0;idx<floor_setup->data.t0.num_books;++idx) {
AV_DEBUG( " Book %d: %u\n",
idx+1,
floor_setup->data.t0.book_list[idx] );
}
}
#endif
}
else {
av_log(vc->avccontext, AV_LOG_ERROR, "Invalid floor type!\n");
return 1;
}
}
return 0;
}
| false | FFmpeg | 993092dcd3fb7ec84fdd1cd3b28a3973740b22bf | static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) {
GetBitContext *gb=&vc->gb;
uint_fast16_t i,j,k;
vc->floor_count=get_bits(gb, 6)+1;
vc->floors=av_mallocz(vc->floor_count * sizeof(vorbis_floor));
for (i=0;i<vc->floor_count;++i) {
vorbis_floor *floor_setup=&vc->floors[i];
floor_setup->floor_type=get_bits(gb, 16);
AV_DEBUG(" %d. floor type %d \n", i, floor_setup->floor_type);
if (floor_setup->floor_type==1) {
uint_fast8_t maximum_class=0;
uint_fast8_t rangebits;
uint_fast16_t floor1_values=2;
floor_setup->decode=vorbis_floor1_decode;
floor_setup->data.t1.partitions=get_bits(gb, 5);
AV_DEBUG(" %d.floor: %d partitions \n", i, floor_setup->data.t1.partitions);
for(j=0;j<floor_setup->data.t1.partitions;++j) {
floor_setup->data.t1.partition_class[j]=get_bits(gb, 4);
if (floor_setup->data.t1.partition_class[j]>maximum_class) maximum_class=floor_setup->data.t1.partition_class[j];
AV_DEBUG(" %d. floor %d partition class %d \n", i, j, floor_setup->data.t1.partition_class[j]);
}
AV_DEBUG(" maximum class %d \n", maximum_class);
floor_setup->data.t1.maximum_class=maximum_class;
for(j=0;j<=maximum_class;++j) {
floor_setup->data.t1.class_dimensions[j]=get_bits(gb, 3)+1;
floor_setup->data.t1.class_subclasses[j]=get_bits(gb, 2);
AV_DEBUG(" %d floor %d class dim: %d subclasses %d \n", i, j, floor_setup->data.t1.class_dimensions[j], floor_setup->data.t1.class_subclasses[j]);
if (floor_setup->data.t1.class_subclasses[j]) {
floor_setup->data.t1.class_masterbook[j]=get_bits(gb, 8);
AV_DEBUG(" masterbook: %d \n", floor_setup->data.t1.class_masterbook[j]);
}
for(k=0;k<(1<<floor_setup->data.t1.class_subclasses[j]);++k) {
floor_setup->data.t1.subclass_books[j][k]=(int16_t)get_bits(gb, 8)-1;
AV_DEBUG(" book %d. : %d \n", k, floor_setup->data.t1.subclass_books[j][k]);
}
}
floor_setup->data.t1.multiplier=get_bits(gb, 2)+1;
floor_setup->data.t1.x_list_dim=2;
for(j=0;j<floor_setup->data.t1.partitions;++j) {
floor_setup->data.t1.x_list_dim+=floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]];
}
floor_setup->data.t1.list=av_mallocz(floor_setup->data.t1.x_list_dim * sizeof(vorbis_floor1_entry));
rangebits=get_bits(gb, 4);
floor_setup->data.t1.list[0].x = 0;
floor_setup->data.t1.list[1].x = (1<<rangebits);
for(j=0;j<floor_setup->data.t1.partitions;++j) {
for(k=0;k<floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]];++k,++floor1_values) {
floor_setup->data.t1.list[floor1_values].x=get_bits(gb, rangebits);
AV_DEBUG(" %d. floor1 Y coord. %d \n", floor1_values, floor_setup->data.t1.list[floor1_values].x);
}
}
ff_vorbis_ready_floor1_list(floor_setup->data.t1.list, floor_setup->data.t1.x_list_dim);
}
else if(floor_setup->floor_type==0) {
uint_fast8_t max_codebook_dim=0;
floor_setup->decode=vorbis_floor0_decode;
floor_setup->data.t0.order=get_bits(gb, 8);
floor_setup->data.t0.rate=get_bits(gb, 16);
floor_setup->data.t0.bark_map_size=get_bits(gb, 16);
floor_setup->data.t0.amplitude_bits=get_bits(gb, 6);
if (floor_setup->data.t0.amplitude_bits == 0) {
av_log(vc->avccontext, AV_LOG_ERROR,
"Floor 0 amplitude bits is 0.\n");
return 1;
}
floor_setup->data.t0.amplitude_offset=get_bits(gb, 8);
floor_setup->data.t0.num_books=get_bits(gb, 4)+1;
floor_setup->data.t0.book_list=
av_malloc(floor_setup->data.t0.num_books);
if(!floor_setup->data.t0.book_list) { return 1; }
{
int idx;
uint_fast8_t book_idx;
for (idx=0;idx<floor_setup->data.t0.num_books;++idx) {
book_idx=get_bits(gb, 8);
if (book_idx>=vc->codebook_count)
return 1;
floor_setup->data.t0.book_list[idx]=book_idx;
if (vc->codebooks[book_idx].dimensions > max_codebook_dim)
max_codebook_dim=vc->codebooks[book_idx].dimensions;
}
}
create_map( vc, i );
{
floor_setup->data.t0.lsp=
av_malloc((floor_setup->data.t0.order+1 + max_codebook_dim)
* sizeof(float));
if(!floor_setup->data.t0.lsp) { return 1; }
}
#ifdef V_DEBUG
AV_DEBUG("floor0 order: %u\n", floor_setup->data.t0.order);
AV_DEBUG("floor0 rate: %u\n", floor_setup->data.t0.rate);
AV_DEBUG("floor0 bark map size: %u\n",
floor_setup->data.t0.bark_map_size);
AV_DEBUG("floor0 amplitude bits: %u\n",
floor_setup->data.t0.amplitude_bits);
AV_DEBUG("floor0 amplitude offset: %u\n",
floor_setup->data.t0.amplitude_offset);
AV_DEBUG("floor0 number of books: %u\n",
floor_setup->data.t0.num_books);
AV_DEBUG("floor0 book list pointer: %p\n",
floor_setup->data.t0.book_list);
{
int idx;
for (idx=0;idx<floor_setup->data.t0.num_books;++idx) {
AV_DEBUG( " Book %d: %u\n",
idx+1,
floor_setup->data.t0.book_list[idx] );
}
}
#endif
}
else {
av_log(vc->avccontext, AV_LOG_ERROR, "Invalid floor type!\n");
return 1;
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(vorbis_context *VAR_0) {
GetBitContext *gb=&VAR_0->gb;
uint_fast16_t i,j,k;
VAR_0->floor_count=get_bits(gb, 6)+1;
VAR_0->floors=av_mallocz(VAR_0->floor_count * sizeof(vorbis_floor));
for (i=0;i<VAR_0->floor_count;++i) {
vorbis_floor *floor_setup=&VAR_0->floors[i];
floor_setup->floor_type=get_bits(gb, 16);
AV_DEBUG(" %d. floor type %d \n", i, floor_setup->floor_type);
if (floor_setup->floor_type==1) {
uint_fast8_t maximum_class=0;
uint_fast8_t rangebits;
uint_fast16_t floor1_values=2;
floor_setup->decode=vorbis_floor1_decode;
floor_setup->data.t1.partitions=get_bits(gb, 5);
AV_DEBUG(" %d.floor: %d partitions \n", i, floor_setup->data.t1.partitions);
for(j=0;j<floor_setup->data.t1.partitions;++j) {
floor_setup->data.t1.partition_class[j]=get_bits(gb, 4);
if (floor_setup->data.t1.partition_class[j]>maximum_class) maximum_class=floor_setup->data.t1.partition_class[j];
AV_DEBUG(" %d. floor %d partition class %d \n", i, j, floor_setup->data.t1.partition_class[j]);
}
AV_DEBUG(" maximum class %d \n", maximum_class);
floor_setup->data.t1.maximum_class=maximum_class;
for(j=0;j<=maximum_class;++j) {
floor_setup->data.t1.class_dimensions[j]=get_bits(gb, 3)+1;
floor_setup->data.t1.class_subclasses[j]=get_bits(gb, 2);
AV_DEBUG(" %d floor %d class dim: %d subclasses %d \n", i, j, floor_setup->data.t1.class_dimensions[j], floor_setup->data.t1.class_subclasses[j]);
if (floor_setup->data.t1.class_subclasses[j]) {
floor_setup->data.t1.class_masterbook[j]=get_bits(gb, 8);
AV_DEBUG(" masterbook: %d \n", floor_setup->data.t1.class_masterbook[j]);
}
for(k=0;k<(1<<floor_setup->data.t1.class_subclasses[j]);++k) {
floor_setup->data.t1.subclass_books[j][k]=(int16_t)get_bits(gb, 8)-1;
AV_DEBUG(" book %d. : %d \n", k, floor_setup->data.t1.subclass_books[j][k]);
}
}
floor_setup->data.t1.multiplier=get_bits(gb, 2)+1;
floor_setup->data.t1.x_list_dim=2;
for(j=0;j<floor_setup->data.t1.partitions;++j) {
floor_setup->data.t1.x_list_dim+=floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]];
}
floor_setup->data.t1.list=av_mallocz(floor_setup->data.t1.x_list_dim * sizeof(vorbis_floor1_entry));
rangebits=get_bits(gb, 4);
floor_setup->data.t1.list[0].x = 0;
floor_setup->data.t1.list[1].x = (1<<rangebits);
for(j=0;j<floor_setup->data.t1.partitions;++j) {
for(k=0;k<floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]];++k,++floor1_values) {
floor_setup->data.t1.list[floor1_values].x=get_bits(gb, rangebits);
AV_DEBUG(" %d. floor1 Y coord. %d \n", floor1_values, floor_setup->data.t1.list[floor1_values].x);
}
}
ff_vorbis_ready_floor1_list(floor_setup->data.t1.list, floor_setup->data.t1.x_list_dim);
}
else if(floor_setup->floor_type==0) {
uint_fast8_t max_codebook_dim=0;
floor_setup->decode=vorbis_floor0_decode;
floor_setup->data.t0.order=get_bits(gb, 8);
floor_setup->data.t0.rate=get_bits(gb, 16);
floor_setup->data.t0.bark_map_size=get_bits(gb, 16);
floor_setup->data.t0.amplitude_bits=get_bits(gb, 6);
if (floor_setup->data.t0.amplitude_bits == 0) {
av_log(VAR_0->avccontext, AV_LOG_ERROR,
"Floor 0 amplitude bits is 0.\n");
return 1;
}
floor_setup->data.t0.amplitude_offset=get_bits(gb, 8);
floor_setup->data.t0.num_books=get_bits(gb, 4)+1;
floor_setup->data.t0.book_list=
av_malloc(floor_setup->data.t0.num_books);
if(!floor_setup->data.t0.book_list) { return 1; }
{
int idx;
uint_fast8_t book_idx;
for (idx=0;idx<floor_setup->data.t0.num_books;++idx) {
book_idx=get_bits(gb, 8);
if (book_idx>=VAR_0->codebook_count)
return 1;
floor_setup->data.t0.book_list[idx]=book_idx;
if (VAR_0->codebooks[book_idx].dimensions > max_codebook_dim)
max_codebook_dim=VAR_0->codebooks[book_idx].dimensions;
}
}
create_map( VAR_0, i );
{
floor_setup->data.t0.lsp=
av_malloc((floor_setup->data.t0.order+1 + max_codebook_dim)
* sizeof(float));
if(!floor_setup->data.t0.lsp) { return 1; }
}
#ifdef V_DEBUG
AV_DEBUG("floor0 order: %u\n", floor_setup->data.t0.order);
AV_DEBUG("floor0 rate: %u\n", floor_setup->data.t0.rate);
AV_DEBUG("floor0 bark map size: %u\n",
floor_setup->data.t0.bark_map_size);
AV_DEBUG("floor0 amplitude bits: %u\n",
floor_setup->data.t0.amplitude_bits);
AV_DEBUG("floor0 amplitude offset: %u\n",
floor_setup->data.t0.amplitude_offset);
AV_DEBUG("floor0 number of books: %u\n",
floor_setup->data.t0.num_books);
AV_DEBUG("floor0 book list pointer: %p\n",
floor_setup->data.t0.book_list);
{
int idx;
for (idx=0;idx<floor_setup->data.t0.num_books;++idx) {
AV_DEBUG( " Book %d: %u\n",
idx+1,
floor_setup->data.t0.book_list[idx] );
}
}
#endif
}
else {
av_log(VAR_0->avccontext, AV_LOG_ERROR, "Invalid floor type!\n");
return 1;
}
}
return 0;
}
| [
"static int FUNC_0(vorbis_context *VAR_0) {",
"GetBitContext *gb=&VAR_0->gb;",
"uint_fast16_t i,j,k;",
"VAR_0->floor_count=get_bits(gb, 6)+1;",
"VAR_0->floors=av_mallocz(VAR_0->floor_count * sizeof(vorbis_floor));",
"for (i=0;i<VAR_0->floor_count;++i) {",
"vorbis_floor *floor_setup=&VAR_0->floors[i];",
"floor_setup->floor_type=get_bits(gb, 16);",
"AV_DEBUG(\" %d. floor type %d \\n\", i, floor_setup->floor_type);",
"if (floor_setup->floor_type==1) {",
"uint_fast8_t maximum_class=0;",
"uint_fast8_t rangebits;",
"uint_fast16_t floor1_values=2;",
"floor_setup->decode=vorbis_floor1_decode;",
"floor_setup->data.t1.partitions=get_bits(gb, 5);",
"AV_DEBUG(\" %d.floor: %d partitions \\n\", i, floor_setup->data.t1.partitions);",
"for(j=0;j<floor_setup->data.t1.partitions;++j) {",
"floor_setup->data.t1.partition_class[j]=get_bits(gb, 4);",
"if (floor_setup->data.t1.partition_class[j]>maximum_class) maximum_class=floor_setup->data.t1.partition_class[j];",
"AV_DEBUG(\" %d. floor %d partition class %d \\n\", i, j, floor_setup->data.t1.partition_class[j]);",
"}",
"AV_DEBUG(\" maximum class %d \\n\", maximum_class);",
"floor_setup->data.t1.maximum_class=maximum_class;",
"for(j=0;j<=maximum_class;++j) {",
"floor_setup->data.t1.class_dimensions[j]=get_bits(gb, 3)+1;",
"floor_setup->data.t1.class_subclasses[j]=get_bits(gb, 2);",
"AV_DEBUG(\" %d floor %d class dim: %d subclasses %d \\n\", i, j, floor_setup->data.t1.class_dimensions[j], floor_setup->data.t1.class_subclasses[j]);",
"if (floor_setup->data.t1.class_subclasses[j]) {",
"floor_setup->data.t1.class_masterbook[j]=get_bits(gb, 8);",
"AV_DEBUG(\" masterbook: %d \\n\", floor_setup->data.t1.class_masterbook[j]);",
"}",
"for(k=0;k<(1<<floor_setup->data.t1.class_subclasses[j]);++k) {",
"floor_setup->data.t1.subclass_books[j][k]=(int16_t)get_bits(gb, 8)-1;",
"AV_DEBUG(\" book %d. : %d \\n\", k, floor_setup->data.t1.subclass_books[j][k]);",
"}",
"}",
"floor_setup->data.t1.multiplier=get_bits(gb, 2)+1;",
"floor_setup->data.t1.x_list_dim=2;",
"for(j=0;j<floor_setup->data.t1.partitions;++j) {",
"floor_setup->data.t1.x_list_dim+=floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]];",
"}",
"floor_setup->data.t1.list=av_mallocz(floor_setup->data.t1.x_list_dim * sizeof(vorbis_floor1_entry));",
"rangebits=get_bits(gb, 4);",
"floor_setup->data.t1.list[0].x = 0;",
"floor_setup->data.t1.list[1].x = (1<<rangebits);",
"for(j=0;j<floor_setup->data.t1.partitions;++j) {",
"for(k=0;k<floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]];++k,++floor1_values) {",
"floor_setup->data.t1.list[floor1_values].x=get_bits(gb, rangebits);",
"AV_DEBUG(\" %d. floor1 Y coord. %d \\n\", floor1_values, floor_setup->data.t1.list[floor1_values].x);",
"}",
"}",
"ff_vorbis_ready_floor1_list(floor_setup->data.t1.list, floor_setup->data.t1.x_list_dim);",
"}",
"else if(floor_setup->floor_type==0) {",
"uint_fast8_t max_codebook_dim=0;",
"floor_setup->decode=vorbis_floor0_decode;",
"floor_setup->data.t0.order=get_bits(gb, 8);",
"floor_setup->data.t0.rate=get_bits(gb, 16);",
"floor_setup->data.t0.bark_map_size=get_bits(gb, 16);",
"floor_setup->data.t0.amplitude_bits=get_bits(gb, 6);",
"if (floor_setup->data.t0.amplitude_bits == 0) {",
"av_log(VAR_0->avccontext, AV_LOG_ERROR,\n\"Floor 0 amplitude bits is 0.\\n\");",
"return 1;",
"}",
"floor_setup->data.t0.amplitude_offset=get_bits(gb, 8);",
"floor_setup->data.t0.num_books=get_bits(gb, 4)+1;",
"floor_setup->data.t0.book_list=\nav_malloc(floor_setup->data.t0.num_books);",
"if(!floor_setup->data.t0.book_list) { return 1; }",
"{",
"int idx;",
"uint_fast8_t book_idx;",
"for (idx=0;idx<floor_setup->data.t0.num_books;++idx) {",
"book_idx=get_bits(gb, 8);",
"if (book_idx>=VAR_0->codebook_count)\nreturn 1;",
"floor_setup->data.t0.book_list[idx]=book_idx;",
"if (VAR_0->codebooks[book_idx].dimensions > max_codebook_dim)\nmax_codebook_dim=VAR_0->codebooks[book_idx].dimensions;",
"}",
"}",
"create_map( VAR_0, i );",
"{",
"floor_setup->data.t0.lsp=\nav_malloc((floor_setup->data.t0.order+1 + max_codebook_dim)\n* sizeof(float));",
"if(!floor_setup->data.t0.lsp) { return 1; }",
"}",
"#ifdef V_DEBUG\nAV_DEBUG(\"floor0 order: %u\\n\", floor_setup->data.t0.order);",
"AV_DEBUG(\"floor0 rate: %u\\n\", floor_setup->data.t0.rate);",
"AV_DEBUG(\"floor0 bark map size: %u\\n\",\nfloor_setup->data.t0.bark_map_size);",
"AV_DEBUG(\"floor0 amplitude bits: %u\\n\",\nfloor_setup->data.t0.amplitude_bits);",
"AV_DEBUG(\"floor0 amplitude offset: %u\\n\",\nfloor_setup->data.t0.amplitude_offset);",
"AV_DEBUG(\"floor0 number of books: %u\\n\",\nfloor_setup->data.t0.num_books);",
"AV_DEBUG(\"floor0 book list pointer: %p\\n\",\nfloor_setup->data.t0.book_list);",
"{",
"int idx;",
"for (idx=0;idx<floor_setup->data.t0.num_books;++idx) {",
"AV_DEBUG( \" Book %d: %u\\n\",\nidx+1,\nfloor_setup->data.t0.book_list[idx] );",
"}",
"}",
"#endif\n}",
"else {",
"av_log(VAR_0->avccontext, AV_LOG_ERROR, \"Invalid floor type!\\n\");",
"return 1;",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
17
],
[
19
],
[
23
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
45
],
[
49
],
[
53
],
[
55
],
[
57
],
[
61
],
[
65
],
[
69
],
[
73
],
[
77
],
[
79
],
[
81
],
[
85
],
[
89
],
[
91
],
[
95
],
[
97
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
129
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
151
],
[
153
],
[
155
],
[
161
],
[
163
],
[
165
],
[
167
],
[
171
],
[
175
],
[
177
],
[
179
],
[
181
],
[
187
],
[
189,
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
205,
207
],
[
209
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223,
225
],
[
227
],
[
229,
231
],
[
233
],
[
235
],
[
239
],
[
245
],
[
251,
253,
255
],
[
257
],
[
259
],
[
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
]
] |
4,533 | void qemu_anon_ram_free(void *ptr, size_t size)
{
trace_qemu_anon_ram_free(ptr, size);
if (ptr) {
munmap(ptr, size);
}
}
| true | qemu | 9fac18f03a9040b67ec38e14d3e1ed34db9c7e06 | void qemu_anon_ram_free(void *ptr, size_t size)
{
trace_qemu_anon_ram_free(ptr, size);
if (ptr) {
munmap(ptr, size);
}
}
| {
"code": [
" munmap(ptr, size);"
],
"line_no": [
9
]
} | void FUNC_0(void *VAR_0, size_t VAR_1)
{
trace_qemu_anon_ram_free(VAR_0, VAR_1);
if (VAR_0) {
munmap(VAR_0, VAR_1);
}
}
| [
"void FUNC_0(void *VAR_0, size_t VAR_1)\n{",
"trace_qemu_anon_ram_free(VAR_0, VAR_1);",
"if (VAR_0) {",
"munmap(VAR_0, VAR_1);",
"}",
"}"
] | [
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
4,534 | void qemu_run_all_timers(void)
{
/* rearm timer, if not periodic */
if (alarm_timer->expired) {
alarm_timer->expired = 0;
qemu_rearm_alarm_timer(alarm_timer);
}
alarm_timer->pending = 0;
/* vm time timers */
if (vm_running) {
qemu_run_timers(vm_clock);
}
qemu_run_timers(rt_clock);
qemu_run_timers(host_clock);
}
| true | qemu | ca5a2a4b12bd44762a5106c9352eafd878bbd52f | void qemu_run_all_timers(void)
{
if (alarm_timer->expired) {
alarm_timer->expired = 0;
qemu_rearm_alarm_timer(alarm_timer);
}
alarm_timer->pending = 0;
if (vm_running) {
qemu_run_timers(vm_clock);
}
qemu_run_timers(rt_clock);
qemu_run_timers(host_clock);
}
| {
"code": [
" alarm_timer->pending = 0;"
],
"line_no": [
17
]
} | void FUNC_0(void)
{
if (alarm_timer->expired) {
alarm_timer->expired = 0;
qemu_rearm_alarm_timer(alarm_timer);
}
alarm_timer->pending = 0;
if (vm_running) {
qemu_run_timers(vm_clock);
}
qemu_run_timers(rt_clock);
qemu_run_timers(host_clock);
}
| [
"void FUNC_0(void)\n{",
"if (alarm_timer->expired) {",
"alarm_timer->expired = 0;",
"qemu_rearm_alarm_timer(alarm_timer);",
"}",
"alarm_timer->pending = 0;",
"if (vm_running) {",
"qemu_run_timers(vm_clock);",
"}",
"qemu_run_timers(rt_clock);",
"qemu_run_timers(host_clock);",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
]
] |
4,535 | static void mips_jazz_init(MemoryRegion *address_space,
MemoryRegion *address_space_io,
ram_addr_t ram_size,
const char *cpu_model,
enum jazz_model_e jazz_model)
{
char *filename;
int bios_size, n;
MIPSCPU *cpu;
CPUMIPSState *env;
qemu_irq *rc4030, *i8259;
rc4030_dma *dmas;
void* rc4030_opaque;
MemoryRegion *rtc = g_new(MemoryRegion, 1);
MemoryRegion *i8042 = g_new(MemoryRegion, 1);
MemoryRegion *dma_dummy = g_new(MemoryRegion, 1);
NICInfo *nd;
DeviceState *dev;
SysBusDevice *sysbus;
ISABus *isa_bus;
ISADevice *pit;
DriveInfo *fds[MAX_FD];
qemu_irq esp_reset, dma_enable;
qemu_irq *cpu_exit_irq;
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *bios = g_new(MemoryRegion, 1);
MemoryRegion *bios2 = g_new(MemoryRegion, 1);
/* init CPUs */
if (cpu_model == NULL) {
#ifdef TARGET_MIPS64
cpu_model = "R4000";
#else
/* FIXME: All wrong, this maybe should be R3000 for the older JAZZs. */
cpu_model = "24Kf";
#endif
}
cpu = cpu_mips_init(cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
env = &cpu->env;
qemu_register_reset(main_cpu_reset, cpu);
/* allocate RAM */
memory_region_init_ram(ram, "mips_jazz.ram", ram_size);
vmstate_register_ram_global(ram);
memory_region_add_subregion(address_space, 0, ram);
memory_region_init_ram(bios, "mips_jazz.bios", MAGNUM_BIOS_SIZE);
vmstate_register_ram_global(bios);
memory_region_set_readonly(bios, true);
memory_region_init_alias(bios2, "mips_jazz.bios", bios,
0, MAGNUM_BIOS_SIZE);
memory_region_add_subregion(address_space, 0x1fc00000LL, bios);
memory_region_add_subregion(address_space, 0xfff00000LL, bios2);
/* load the BIOS image. */
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = load_image_targphys(filename, 0xfff00000LL,
MAGNUM_BIOS_SIZE);
g_free(filename);
} else {
bios_size = -1;
}
if (bios_size < 0 || bios_size > MAGNUM_BIOS_SIZE) {
fprintf(stderr, "qemu: Could not load MIPS bios '%s'\n",
bios_name);
exit(1);
}
/* Init CPU internal devices */
cpu_mips_irq_init_cpu(env);
cpu_mips_clock_init(env);
/* Chipset */
rc4030_opaque = rc4030_init(env->irq[6], env->irq[3], &rc4030, &dmas,
address_space);
memory_region_init_io(dma_dummy, &dma_dummy_ops, NULL, "dummy_dma", 0x1000);
memory_region_add_subregion(address_space, 0x8000d000, dma_dummy);
/* ISA devices */
isa_bus = isa_bus_new(NULL, address_space_io);
i8259 = i8259_init(isa_bus, env->irq[4]);
isa_bus_irqs(isa_bus, i8259);
cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
DMA_init(0, cpu_exit_irq);
pit = pit_init(isa_bus, 0x40, 0, NULL);
pcspk_init(isa_bus, pit);
/* ISA IO space at 0x90000000 */
isa_mmio_init(0x90000000, 0x01000000);
isa_mem_base = 0x11000000;
/* Video card */
switch (jazz_model) {
case JAZZ_MAGNUM:
dev = qdev_create(NULL, "sysbus-g364");
qdev_init_nofail(dev);
sysbus = sysbus_from_qdev(dev);
sysbus_mmio_map(sysbus, 0, 0x60080000);
sysbus_mmio_map(sysbus, 1, 0x40000000);
sysbus_connect_irq(sysbus, 0, rc4030[3]);
{
/* Simple ROM, so user doesn't have to provide one */
MemoryRegion *rom_mr = g_new(MemoryRegion, 1);
memory_region_init_ram(rom_mr, "g364fb.rom", 0x80000);
vmstate_register_ram_global(rom_mr);
memory_region_set_readonly(rom_mr, true);
uint8_t *rom = memory_region_get_ram_ptr(rom_mr);
memory_region_add_subregion(address_space, 0x60000000, rom_mr);
rom[0] = 0x10; /* Mips G364 */
}
break;
case JAZZ_PICA61:
isa_vga_mm_init(0x40000000, 0x60000000, 0, get_system_memory());
break;
default:
break;
}
/* Network controller */
for (n = 0; n < nb_nics; n++) {
nd = &nd_table[n];
if (!nd->model)
nd->model = g_strdup("dp83932");
if (strcmp(nd->model, "dp83932") == 0) {
dp83932_init(nd, 0x80001000, 2, get_system_memory(), rc4030[4],
rc4030_opaque, rc4030_dma_memory_rw);
break;
} else if (strcmp(nd->model, "?") == 0) {
fprintf(stderr, "qemu: Supported NICs: dp83932\n");
exit(1);
} else {
fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd->model);
exit(1);
}
}
/* SCSI adapter */
esp_init(0x80002000, 0,
rc4030_dma_read, rc4030_dma_write, dmas[0],
rc4030[5], &esp_reset, &dma_enable);
/* Floppy */
if (drive_get_max_bus(IF_FLOPPY) >= MAX_FD) {
fprintf(stderr, "qemu: too many floppy drives\n");
exit(1);
}
for (n = 0; n < MAX_FD; n++) {
fds[n] = drive_get(IF_FLOPPY, 0, n);
}
fdctrl_init_sysbus(rc4030[1], 0, 0x80003000, fds);
/* Real time clock */
rtc_init(isa_bus, 1980, NULL);
memory_region_init_io(rtc, &rtc_ops, NULL, "rtc", 0x1000);
memory_region_add_subregion(address_space, 0x80004000, rtc);
/* Keyboard (i8042) */
i8042_mm_init(rc4030[6], rc4030[7], i8042, 0x1000, 0x1);
memory_region_add_subregion(address_space, 0x80005000, i8042);
/* Serial ports */
if (serial_hds[0]) {
serial_mm_init(address_space, 0x80006000, 0, rc4030[8], 8000000/16,
serial_hds[0], DEVICE_NATIVE_ENDIAN);
}
if (serial_hds[1]) {
serial_mm_init(address_space, 0x80007000, 0, rc4030[9], 8000000/16,
serial_hds[1], DEVICE_NATIVE_ENDIAN);
}
/* Parallel port */
if (parallel_hds[0])
parallel_mm_init(address_space, 0x80008000, 0, rc4030[0],
parallel_hds[0]);
/* Sound card */
/* FIXME: missing Jazz sound at 0x8000c000, rc4030[2] */
audio_init(isa_bus, NULL);
/* NVRAM */
dev = qdev_create(NULL, "ds1225y");
qdev_init_nofail(dev);
sysbus = sysbus_from_qdev(dev);
sysbus_mmio_map(sysbus, 0, 0x80009000);
/* LED indicator */
sysbus_create_simple("jazz-led", 0x8000f000, NULL);
}
| true | qemu | c8057f951d64de93bfd01569c0a725baa9f94372 | static void mips_jazz_init(MemoryRegion *address_space,
MemoryRegion *address_space_io,
ram_addr_t ram_size,
const char *cpu_model,
enum jazz_model_e jazz_model)
{
char *filename;
int bios_size, n;
MIPSCPU *cpu;
CPUMIPSState *env;
qemu_irq *rc4030, *i8259;
rc4030_dma *dmas;
void* rc4030_opaque;
MemoryRegion *rtc = g_new(MemoryRegion, 1);
MemoryRegion *i8042 = g_new(MemoryRegion, 1);
MemoryRegion *dma_dummy = g_new(MemoryRegion, 1);
NICInfo *nd;
DeviceState *dev;
SysBusDevice *sysbus;
ISABus *isa_bus;
ISADevice *pit;
DriveInfo *fds[MAX_FD];
qemu_irq esp_reset, dma_enable;
qemu_irq *cpu_exit_irq;
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *bios = g_new(MemoryRegion, 1);
MemoryRegion *bios2 = g_new(MemoryRegion, 1);
if (cpu_model == NULL) {
#ifdef TARGET_MIPS64
cpu_model = "R4000";
#else
cpu_model = "24Kf";
#endif
}
cpu = cpu_mips_init(cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
env = &cpu->env;
qemu_register_reset(main_cpu_reset, cpu);
memory_region_init_ram(ram, "mips_jazz.ram", ram_size);
vmstate_register_ram_global(ram);
memory_region_add_subregion(address_space, 0, ram);
memory_region_init_ram(bios, "mips_jazz.bios", MAGNUM_BIOS_SIZE);
vmstate_register_ram_global(bios);
memory_region_set_readonly(bios, true);
memory_region_init_alias(bios2, "mips_jazz.bios", bios,
0, MAGNUM_BIOS_SIZE);
memory_region_add_subregion(address_space, 0x1fc00000LL, bios);
memory_region_add_subregion(address_space, 0xfff00000LL, bios2);
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = load_image_targphys(filename, 0xfff00000LL,
MAGNUM_BIOS_SIZE);
g_free(filename);
} else {
bios_size = -1;
}
if (bios_size < 0 || bios_size > MAGNUM_BIOS_SIZE) {
fprintf(stderr, "qemu: Could not load MIPS bios '%s'\n",
bios_name);
exit(1);
}
cpu_mips_irq_init_cpu(env);
cpu_mips_clock_init(env);
rc4030_opaque = rc4030_init(env->irq[6], env->irq[3], &rc4030, &dmas,
address_space);
memory_region_init_io(dma_dummy, &dma_dummy_ops, NULL, "dummy_dma", 0x1000);
memory_region_add_subregion(address_space, 0x8000d000, dma_dummy);
isa_bus = isa_bus_new(NULL, address_space_io);
i8259 = i8259_init(isa_bus, env->irq[4]);
isa_bus_irqs(isa_bus, i8259);
cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
DMA_init(0, cpu_exit_irq);
pit = pit_init(isa_bus, 0x40, 0, NULL);
pcspk_init(isa_bus, pit);
isa_mmio_init(0x90000000, 0x01000000);
isa_mem_base = 0x11000000;
switch (jazz_model) {
case JAZZ_MAGNUM:
dev = qdev_create(NULL, "sysbus-g364");
qdev_init_nofail(dev);
sysbus = sysbus_from_qdev(dev);
sysbus_mmio_map(sysbus, 0, 0x60080000);
sysbus_mmio_map(sysbus, 1, 0x40000000);
sysbus_connect_irq(sysbus, 0, rc4030[3]);
{
MemoryRegion *rom_mr = g_new(MemoryRegion, 1);
memory_region_init_ram(rom_mr, "g364fb.rom", 0x80000);
vmstate_register_ram_global(rom_mr);
memory_region_set_readonly(rom_mr, true);
uint8_t *rom = memory_region_get_ram_ptr(rom_mr);
memory_region_add_subregion(address_space, 0x60000000, rom_mr);
rom[0] = 0x10;
}
break;
case JAZZ_PICA61:
isa_vga_mm_init(0x40000000, 0x60000000, 0, get_system_memory());
break;
default:
break;
}
for (n = 0; n < nb_nics; n++) {
nd = &nd_table[n];
if (!nd->model)
nd->model = g_strdup("dp83932");
if (strcmp(nd->model, "dp83932") == 0) {
dp83932_init(nd, 0x80001000, 2, get_system_memory(), rc4030[4],
rc4030_opaque, rc4030_dma_memory_rw);
break;
} else if (strcmp(nd->model, "?") == 0) {
fprintf(stderr, "qemu: Supported NICs: dp83932\n");
exit(1);
} else {
fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd->model);
exit(1);
}
}
esp_init(0x80002000, 0,
rc4030_dma_read, rc4030_dma_write, dmas[0],
rc4030[5], &esp_reset, &dma_enable);
if (drive_get_max_bus(IF_FLOPPY) >= MAX_FD) {
fprintf(stderr, "qemu: too many floppy drives\n");
exit(1);
}
for (n = 0; n < MAX_FD; n++) {
fds[n] = drive_get(IF_FLOPPY, 0, n);
}
fdctrl_init_sysbus(rc4030[1], 0, 0x80003000, fds);
rtc_init(isa_bus, 1980, NULL);
memory_region_init_io(rtc, &rtc_ops, NULL, "rtc", 0x1000);
memory_region_add_subregion(address_space, 0x80004000, rtc);
i8042_mm_init(rc4030[6], rc4030[7], i8042, 0x1000, 0x1);
memory_region_add_subregion(address_space, 0x80005000, i8042);
if (serial_hds[0]) {
serial_mm_init(address_space, 0x80006000, 0, rc4030[8], 8000000/16,
serial_hds[0], DEVICE_NATIVE_ENDIAN);
}
if (serial_hds[1]) {
serial_mm_init(address_space, 0x80007000, 0, rc4030[9], 8000000/16,
serial_hds[1], DEVICE_NATIVE_ENDIAN);
}
if (parallel_hds[0])
parallel_mm_init(address_space, 0x80008000, 0, rc4030[0],
parallel_hds[0]);
audio_init(isa_bus, NULL);
dev = qdev_create(NULL, "ds1225y");
qdev_init_nofail(dev);
sysbus = sysbus_from_qdev(dev);
sysbus_mmio_map(sysbus, 0, 0x80009000);
sysbus_create_simple("jazz-led", 0x8000f000, NULL);
}
| {
"code": [
" } else if (strcmp(nd->model, \"?\") == 0) {"
],
"line_no": [
269
]
} | static void FUNC_0(MemoryRegion *VAR_0,
MemoryRegion *VAR_1,
ram_addr_t VAR_2,
const char *VAR_3,
enum jazz_model_e VAR_4)
{
char *VAR_5;
int VAR_6, VAR_7;
MIPSCPU *cpu;
CPUMIPSState *env;
qemu_irq *rc4030, *i8259;
rc4030_dma *dmas;
void* VAR_8;
MemoryRegion *rtc = g_new(MemoryRegion, 1);
MemoryRegion *i8042 = g_new(MemoryRegion, 1);
MemoryRegion *dma_dummy = g_new(MemoryRegion, 1);
NICInfo *nd;
DeviceState *dev;
SysBusDevice *sysbus;
ISABus *isa_bus;
ISADevice *pit;
DriveInfo *fds[MAX_FD];
qemu_irq esp_reset, dma_enable;
qemu_irq *cpu_exit_irq;
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *bios = g_new(MemoryRegion, 1);
MemoryRegion *bios2 = g_new(MemoryRegion, 1);
if (VAR_3 == NULL) {
#ifdef TARGET_MIPS64
VAR_3 = "R4000";
#else
VAR_3 = "24Kf";
#endif
}
cpu = cpu_mips_init(VAR_3);
if (cpu == NULL) {
fprintf(stderr, "Unable to find CPU definition\VAR_7");
exit(1);
}
env = &cpu->env;
qemu_register_reset(main_cpu_reset, cpu);
memory_region_init_ram(ram, "mips_jazz.ram", VAR_2);
vmstate_register_ram_global(ram);
memory_region_add_subregion(VAR_0, 0, ram);
memory_region_init_ram(bios, "mips_jazz.bios", MAGNUM_BIOS_SIZE);
vmstate_register_ram_global(bios);
memory_region_set_readonly(bios, true);
memory_region_init_alias(bios2, "mips_jazz.bios", bios,
0, MAGNUM_BIOS_SIZE);
memory_region_add_subregion(VAR_0, 0x1fc00000LL, bios);
memory_region_add_subregion(VAR_0, 0xfff00000LL, bios2);
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
VAR_5 = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (VAR_5) {
VAR_6 = load_image_targphys(VAR_5, 0xfff00000LL,
MAGNUM_BIOS_SIZE);
g_free(VAR_5);
} else {
VAR_6 = -1;
}
if (VAR_6 < 0 || VAR_6 > MAGNUM_BIOS_SIZE) {
fprintf(stderr, "qemu: Could not load MIPS bios '%s'\VAR_7",
bios_name);
exit(1);
}
cpu_mips_irq_init_cpu(env);
cpu_mips_clock_init(env);
VAR_8 = rc4030_init(env->irq[6], env->irq[3], &rc4030, &dmas,
VAR_0);
memory_region_init_io(dma_dummy, &dma_dummy_ops, NULL, "dummy_dma", 0x1000);
memory_region_add_subregion(VAR_0, 0x8000d000, dma_dummy);
isa_bus = isa_bus_new(NULL, VAR_1);
i8259 = i8259_init(isa_bus, env->irq[4]);
isa_bus_irqs(isa_bus, i8259);
cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
DMA_init(0, cpu_exit_irq);
pit = pit_init(isa_bus, 0x40, 0, NULL);
pcspk_init(isa_bus, pit);
isa_mmio_init(0x90000000, 0x01000000);
isa_mem_base = 0x11000000;
switch (VAR_4) {
case JAZZ_MAGNUM:
dev = qdev_create(NULL, "sysbus-g364");
qdev_init_nofail(dev);
sysbus = sysbus_from_qdev(dev);
sysbus_mmio_map(sysbus, 0, 0x60080000);
sysbus_mmio_map(sysbus, 1, 0x40000000);
sysbus_connect_irq(sysbus, 0, rc4030[3]);
{
MemoryRegion *rom_mr = g_new(MemoryRegion, 1);
memory_region_init_ram(rom_mr, "g364fb.rom", 0x80000);
vmstate_register_ram_global(rom_mr);
memory_region_set_readonly(rom_mr, true);
uint8_t *rom = memory_region_get_ram_ptr(rom_mr);
memory_region_add_subregion(VAR_0, 0x60000000, rom_mr);
rom[0] = 0x10;
}
break;
case JAZZ_PICA61:
isa_vga_mm_init(0x40000000, 0x60000000, 0, get_system_memory());
break;
default:
break;
}
for (VAR_7 = 0; VAR_7 < nb_nics; VAR_7++) {
nd = &nd_table[VAR_7];
if (!nd->model)
nd->model = g_strdup("dp83932");
if (strcmp(nd->model, "dp83932") == 0) {
dp83932_init(nd, 0x80001000, 2, get_system_memory(), rc4030[4],
VAR_8, rc4030_dma_memory_rw);
break;
} else if (strcmp(nd->model, "?") == 0) {
fprintf(stderr, "qemu: Supported NICs: dp83932\VAR_7");
exit(1);
} else {
fprintf(stderr, "qemu: Unsupported NIC: %s\VAR_7", nd->model);
exit(1);
}
}
esp_init(0x80002000, 0,
rc4030_dma_read, rc4030_dma_write, dmas[0],
rc4030[5], &esp_reset, &dma_enable);
if (drive_get_max_bus(IF_FLOPPY) >= MAX_FD) {
fprintf(stderr, "qemu: too many floppy drives\VAR_7");
exit(1);
}
for (VAR_7 = 0; VAR_7 < MAX_FD; VAR_7++) {
fds[VAR_7] = drive_get(IF_FLOPPY, 0, VAR_7);
}
fdctrl_init_sysbus(rc4030[1], 0, 0x80003000, fds);
rtc_init(isa_bus, 1980, NULL);
memory_region_init_io(rtc, &rtc_ops, NULL, "rtc", 0x1000);
memory_region_add_subregion(VAR_0, 0x80004000, rtc);
i8042_mm_init(rc4030[6], rc4030[7], i8042, 0x1000, 0x1);
memory_region_add_subregion(VAR_0, 0x80005000, i8042);
if (serial_hds[0]) {
serial_mm_init(VAR_0, 0x80006000, 0, rc4030[8], 8000000/16,
serial_hds[0], DEVICE_NATIVE_ENDIAN);
}
if (serial_hds[1]) {
serial_mm_init(VAR_0, 0x80007000, 0, rc4030[9], 8000000/16,
serial_hds[1], DEVICE_NATIVE_ENDIAN);
}
if (parallel_hds[0])
parallel_mm_init(VAR_0, 0x80008000, 0, rc4030[0],
parallel_hds[0]);
audio_init(isa_bus, NULL);
dev = qdev_create(NULL, "ds1225y");
qdev_init_nofail(dev);
sysbus = sysbus_from_qdev(dev);
sysbus_mmio_map(sysbus, 0, 0x80009000);
sysbus_create_simple("jazz-led", 0x8000f000, NULL);
}
| [
"static void FUNC_0(MemoryRegion *VAR_0,\nMemoryRegion *VAR_1,\nram_addr_t VAR_2,\nconst char *VAR_3,\nenum jazz_model_e VAR_4)\n{",
"char *VAR_5;",
"int VAR_6, VAR_7;",
"MIPSCPU *cpu;",
"CPUMIPSState *env;",
"qemu_irq *rc4030, *i8259;",
"rc4030_dma *dmas;",
"void* VAR_8;",
"MemoryRegion *rtc = g_new(MemoryRegion, 1);",
"MemoryRegion *i8042 = g_new(MemoryRegion, 1);",
"MemoryRegion *dma_dummy = g_new(MemoryRegion, 1);",
"NICInfo *nd;",
"DeviceState *dev;",
"SysBusDevice *sysbus;",
"ISABus *isa_bus;",
"ISADevice *pit;",
"DriveInfo *fds[MAX_FD];",
"qemu_irq esp_reset, dma_enable;",
"qemu_irq *cpu_exit_irq;",
"MemoryRegion *ram = g_new(MemoryRegion, 1);",
"MemoryRegion *bios = g_new(MemoryRegion, 1);",
"MemoryRegion *bios2 = g_new(MemoryRegion, 1);",
"if (VAR_3 == NULL) {",
"#ifdef TARGET_MIPS64\nVAR_3 = \"R4000\";",
"#else\nVAR_3 = \"24Kf\";",
"#endif\n}",
"cpu = cpu_mips_init(VAR_3);",
"if (cpu == NULL) {",
"fprintf(stderr, \"Unable to find CPU definition\\VAR_7\");",
"exit(1);",
"}",
"env = &cpu->env;",
"qemu_register_reset(main_cpu_reset, cpu);",
"memory_region_init_ram(ram, \"mips_jazz.ram\", VAR_2);",
"vmstate_register_ram_global(ram);",
"memory_region_add_subregion(VAR_0, 0, ram);",
"memory_region_init_ram(bios, \"mips_jazz.bios\", MAGNUM_BIOS_SIZE);",
"vmstate_register_ram_global(bios);",
"memory_region_set_readonly(bios, true);",
"memory_region_init_alias(bios2, \"mips_jazz.bios\", bios,\n0, MAGNUM_BIOS_SIZE);",
"memory_region_add_subregion(VAR_0, 0x1fc00000LL, bios);",
"memory_region_add_subregion(VAR_0, 0xfff00000LL, bios2);",
"if (bios_name == NULL)\nbios_name = BIOS_FILENAME;",
"VAR_5 = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);",
"if (VAR_5) {",
"VAR_6 = load_image_targphys(VAR_5, 0xfff00000LL,\nMAGNUM_BIOS_SIZE);",
"g_free(VAR_5);",
"} else {",
"VAR_6 = -1;",
"}",
"if (VAR_6 < 0 || VAR_6 > MAGNUM_BIOS_SIZE) {",
"fprintf(stderr, \"qemu: Could not load MIPS bios '%s'\\VAR_7\",\nbios_name);",
"exit(1);",
"}",
"cpu_mips_irq_init_cpu(env);",
"cpu_mips_clock_init(env);",
"VAR_8 = rc4030_init(env->irq[6], env->irq[3], &rc4030, &dmas,\nVAR_0);",
"memory_region_init_io(dma_dummy, &dma_dummy_ops, NULL, \"dummy_dma\", 0x1000);",
"memory_region_add_subregion(VAR_0, 0x8000d000, dma_dummy);",
"isa_bus = isa_bus_new(NULL, VAR_1);",
"i8259 = i8259_init(isa_bus, env->irq[4]);",
"isa_bus_irqs(isa_bus, i8259);",
"cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);",
"DMA_init(0, cpu_exit_irq);",
"pit = pit_init(isa_bus, 0x40, 0, NULL);",
"pcspk_init(isa_bus, pit);",
"isa_mmio_init(0x90000000, 0x01000000);",
"isa_mem_base = 0x11000000;",
"switch (VAR_4) {",
"case JAZZ_MAGNUM:\ndev = qdev_create(NULL, \"sysbus-g364\");",
"qdev_init_nofail(dev);",
"sysbus = sysbus_from_qdev(dev);",
"sysbus_mmio_map(sysbus, 0, 0x60080000);",
"sysbus_mmio_map(sysbus, 1, 0x40000000);",
"sysbus_connect_irq(sysbus, 0, rc4030[3]);",
"{",
"MemoryRegion *rom_mr = g_new(MemoryRegion, 1);",
"memory_region_init_ram(rom_mr, \"g364fb.rom\", 0x80000);",
"vmstate_register_ram_global(rom_mr);",
"memory_region_set_readonly(rom_mr, true);",
"uint8_t *rom = memory_region_get_ram_ptr(rom_mr);",
"memory_region_add_subregion(VAR_0, 0x60000000, rom_mr);",
"rom[0] = 0x10;",
"}",
"break;",
"case JAZZ_PICA61:\nisa_vga_mm_init(0x40000000, 0x60000000, 0, get_system_memory());",
"break;",
"default:\nbreak;",
"}",
"for (VAR_7 = 0; VAR_7 < nb_nics; VAR_7++) {",
"nd = &nd_table[VAR_7];",
"if (!nd->model)\nnd->model = g_strdup(\"dp83932\");",
"if (strcmp(nd->model, \"dp83932\") == 0) {",
"dp83932_init(nd, 0x80001000, 2, get_system_memory(), rc4030[4],\nVAR_8, rc4030_dma_memory_rw);",
"break;",
"} else if (strcmp(nd->model, \"?\") == 0) {",
"fprintf(stderr, \"qemu: Supported NICs: dp83932\\VAR_7\");",
"exit(1);",
"} else {",
"fprintf(stderr, \"qemu: Unsupported NIC: %s\\VAR_7\", nd->model);",
"exit(1);",
"}",
"}",
"esp_init(0x80002000, 0,\nrc4030_dma_read, rc4030_dma_write, dmas[0],\nrc4030[5], &esp_reset, &dma_enable);",
"if (drive_get_max_bus(IF_FLOPPY) >= MAX_FD) {",
"fprintf(stderr, \"qemu: too many floppy drives\\VAR_7\");",
"exit(1);",
"}",
"for (VAR_7 = 0; VAR_7 < MAX_FD; VAR_7++) {",
"fds[VAR_7] = drive_get(IF_FLOPPY, 0, VAR_7);",
"}",
"fdctrl_init_sysbus(rc4030[1], 0, 0x80003000, fds);",
"rtc_init(isa_bus, 1980, NULL);",
"memory_region_init_io(rtc, &rtc_ops, NULL, \"rtc\", 0x1000);",
"memory_region_add_subregion(VAR_0, 0x80004000, rtc);",
"i8042_mm_init(rc4030[6], rc4030[7], i8042, 0x1000, 0x1);",
"memory_region_add_subregion(VAR_0, 0x80005000, i8042);",
"if (serial_hds[0]) {",
"serial_mm_init(VAR_0, 0x80006000, 0, rc4030[8], 8000000/16,\nserial_hds[0], DEVICE_NATIVE_ENDIAN);",
"}",
"if (serial_hds[1]) {",
"serial_mm_init(VAR_0, 0x80007000, 0, rc4030[9], 8000000/16,\nserial_hds[1], DEVICE_NATIVE_ENDIAN);",
"}",
"if (parallel_hds[0])\nparallel_mm_init(VAR_0, 0x80008000, 0, rc4030[0],\nparallel_hds[0]);",
"audio_init(isa_bus, NULL);",
"dev = qdev_create(NULL, \"ds1225y\");",
"qdev_init_nofail(dev);",
"sysbus = sysbus_from_qdev(dev);",
"sysbus_mmio_map(sysbus, 0, 0x80009000);",
"sysbus_create_simple(\"jazz-led\", 0x8000f000, NULL);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
59
],
[
61,
63
],
[
65,
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
119,
121
],
[
123
],
[
125
],
[
127,
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141,
143
],
[
145
],
[
147
],
[
153
],
[
155
],
[
161,
163
],
[
165
],
[
167
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
191
],
[
193
],
[
199
],
[
201,
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237,
239
],
[
241
],
[
243,
245
],
[
247
],
[
253
],
[
255
],
[
257,
259
],
[
261
],
[
263,
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
289,
291,
293
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
319
],
[
321
],
[
323
],
[
329
],
[
331
],
[
337
],
[
339,
341
],
[
343
],
[
345
],
[
347,
349
],
[
351
],
[
357,
359,
361
],
[
369
],
[
375
],
[
377
],
[
379
],
[
381
],
[
387
],
[
389
]
] |
4,536 | static int qemu_rdma_close(void *opaque)
{
DPRINTF("Shutting down connection.\n");
QEMUFileRDMA *r = opaque;
if (r->rdma) {
qemu_rdma_cleanup(r->rdma);
g_free(r->rdma);
}
g_free(r);
return 0;
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | static int qemu_rdma_close(void *opaque)
{
DPRINTF("Shutting down connection.\n");
QEMUFileRDMA *r = opaque;
if (r->rdma) {
qemu_rdma_cleanup(r->rdma);
g_free(r->rdma);
}
g_free(r);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(void *VAR_0)
{
DPRINTF("Shutting down connection.\n");
QEMUFileRDMA *r = VAR_0;
if (r->rdma) {
qemu_rdma_cleanup(r->rdma);
g_free(r->rdma);
}
g_free(r);
return 0;
}
| [
"static int FUNC_0(void *VAR_0)\n{",
"DPRINTF(\"Shutting down connection.\\n\");",
"QEMUFileRDMA *r = VAR_0;",
"if (r->rdma) {",
"qemu_rdma_cleanup(r->rdma);",
"g_free(r->rdma);",
"}",
"g_free(r);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
4,537 | static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE], int total_gain){
int v, bsize, ch, coef_nb_bits, parse_exponents;
float mdct_norm;
int nb_coefs[MAX_CHANNELS];
static const int fixed_exp[25]={20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20};
//FIXME remove duplication relative to decoder
if (s->use_variable_block_len) {
assert(0); //FIXME not implemented
}else{
/* fixed block len */
s->next_block_len_bits = s->frame_len_bits;
s->prev_block_len_bits = s->frame_len_bits;
s->block_len_bits = s->frame_len_bits;
}
s->block_len = 1 << s->block_len_bits;
// assert((s->block_pos + s->block_len) <= s->frame_len);
bsize = s->frame_len_bits - s->block_len_bits;
//FIXME factor
v = s->coefs_end[bsize] - s->coefs_start;
for(ch = 0; ch < s->nb_channels; ch++)
nb_coefs[ch] = v;
{
int n4 = s->block_len / 2;
mdct_norm = 1.0 / (float)n4;
if (s->version == 1) {
mdct_norm *= sqrt(n4);
}
}
if (s->nb_channels == 2) {
put_bits(&s->pb, 1, !!s->ms_stereo);
}
for(ch = 0; ch < s->nb_channels; ch++) {
s->channel_coded[ch] = 1; //FIXME only set channel_coded when needed, instead of always
if (s->channel_coded[ch]) {
init_exp(s, ch, fixed_exp);
}
}
for(ch = 0; ch < s->nb_channels; ch++) {
if (s->channel_coded[ch]) {
WMACoef *coefs1;
float *coefs, *exponents, mult;
int i, n;
coefs1 = s->coefs1[ch];
exponents = s->exponents[ch];
mult = pow(10, total_gain * 0.05) / s->max_exponent[ch];
mult *= mdct_norm;
coefs = src_coefs[ch];
if (s->use_noise_coding && 0) {
assert(0); //FIXME not implemented
} else {
coefs += s->coefs_start;
n = nb_coefs[ch];
for(i = 0;i < n; i++){
double t= *coefs++ / (exponents[i] * mult);
if(t<-32768 || t>32767)
return -1;
coefs1[i] = lrint(t);
}
}
}
}
v = 0;
for(ch = 0; ch < s->nb_channels; ch++) {
int a = s->channel_coded[ch];
put_bits(&s->pb, 1, a);
v |= a;
}
if (!v)
return 1;
for(v= total_gain-1; v>=127; v-= 127)
put_bits(&s->pb, 7, 127);
put_bits(&s->pb, 7, v);
coef_nb_bits= ff_wma_total_gain_to_bits(total_gain);
if (s->use_noise_coding) {
for(ch = 0; ch < s->nb_channels; ch++) {
if (s->channel_coded[ch]) {
int i, n;
n = s->exponent_high_sizes[bsize];
for(i=0;i<n;i++) {
put_bits(&s->pb, 1, s->high_band_coded[ch][i]= 0);
if (0)
nb_coefs[ch] -= s->exponent_high_bands[bsize][i];
}
}
}
}
parse_exponents = 1;
if (s->block_len_bits != s->frame_len_bits) {
put_bits(&s->pb, 1, parse_exponents);
}
if (parse_exponents) {
for(ch = 0; ch < s->nb_channels; ch++) {
if (s->channel_coded[ch]) {
if (s->use_exp_vlc) {
encode_exp_vlc(s, ch, fixed_exp);
} else {
assert(0); //FIXME not implemented
// encode_exp_lsp(s, ch);
}
}
}
} else {
assert(0); //FIXME not implemented
}
for(ch = 0; ch < s->nb_channels; ch++) {
if (s->channel_coded[ch]) {
int run, tindex;
WMACoef *ptr, *eptr;
tindex = (ch == 1 && s->ms_stereo);
ptr = &s->coefs1[ch][0];
eptr = ptr + nb_coefs[ch];
run=0;
for(;ptr < eptr; ptr++){
if(*ptr){
int level= *ptr;
int abs_level= FFABS(level);
int code= 0;
if(abs_level <= s->coef_vlcs[tindex]->max_level){
if(run < s->coef_vlcs[tindex]->levels[abs_level-1])
code= run + s->int_table[tindex][abs_level-1];
}
assert(code < s->coef_vlcs[tindex]->n);
put_bits(&s->pb, s->coef_vlcs[tindex]->huffbits[code], s->coef_vlcs[tindex]->huffcodes[code]);
if(code == 0){
if(1<<coef_nb_bits <= abs_level)
return -1;
//Workaround minor rounding differences for the regression tests, FIXME we should find and replace the problematic float by fixpoint for reg tests
if(abs_level == 0x71B && (s->avctx->flags & CODEC_FLAG_BITEXACT)) abs_level=0x71A;
put_bits(&s->pb, coef_nb_bits, abs_level);
put_bits(&s->pb, s->frame_len_bits, run);
}
put_bits(&s->pb, 1, level < 0); //FIXME the sign is fliped somewhere
run=0;
}else{
run++;
}
}
if(run)
put_bits(&s->pb, s->coef_vlcs[tindex]->huffbits[1], s->coef_vlcs[tindex]->huffcodes[1]);
}
if (s->version == 1 && s->nb_channels >= 2) {
avpriv_align_put_bits(&s->pb);
}
}
return 0;
}
| true | FFmpeg | c3da9f506038aea306dd1b9ce48db94ca251a08d | static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE], int total_gain){
int v, bsize, ch, coef_nb_bits, parse_exponents;
float mdct_norm;
int nb_coefs[MAX_CHANNELS];
static const int fixed_exp[25]={20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20};
if (s->use_variable_block_len) {
assert(0);
}else{
s->next_block_len_bits = s->frame_len_bits;
s->prev_block_len_bits = s->frame_len_bits;
s->block_len_bits = s->frame_len_bits;
}
s->block_len = 1 << s->block_len_bits;
bsize = s->frame_len_bits - s->block_len_bits;
v = s->coefs_end[bsize] - s->coefs_start;
for(ch = 0; ch < s->nb_channels; ch++)
nb_coefs[ch] = v;
{
int n4 = s->block_len / 2;
mdct_norm = 1.0 / (float)n4;
if (s->version == 1) {
mdct_norm *= sqrt(n4);
}
}
if (s->nb_channels == 2) {
put_bits(&s->pb, 1, !!s->ms_stereo);
}
for(ch = 0; ch < s->nb_channels; ch++) {
s->channel_coded[ch] = 1;
if (s->channel_coded[ch]) {
init_exp(s, ch, fixed_exp);
}
}
for(ch = 0; ch < s->nb_channels; ch++) {
if (s->channel_coded[ch]) {
WMACoef *coefs1;
float *coefs, *exponents, mult;
int i, n;
coefs1 = s->coefs1[ch];
exponents = s->exponents[ch];
mult = pow(10, total_gain * 0.05) / s->max_exponent[ch];
mult *= mdct_norm;
coefs = src_coefs[ch];
if (s->use_noise_coding && 0) {
assert(0);
} else {
coefs += s->coefs_start;
n = nb_coefs[ch];
for(i = 0;i < n; i++){
double t= *coefs++ / (exponents[i] * mult);
if(t<-32768 || t>32767)
return -1;
coefs1[i] = lrint(t);
}
}
}
}
v = 0;
for(ch = 0; ch < s->nb_channels; ch++) {
int a = s->channel_coded[ch];
put_bits(&s->pb, 1, a);
v |= a;
}
if (!v)
return 1;
for(v= total_gain-1; v>=127; v-= 127)
put_bits(&s->pb, 7, 127);
put_bits(&s->pb, 7, v);
coef_nb_bits= ff_wma_total_gain_to_bits(total_gain);
if (s->use_noise_coding) {
for(ch = 0; ch < s->nb_channels; ch++) {
if (s->channel_coded[ch]) {
int i, n;
n = s->exponent_high_sizes[bsize];
for(i=0;i<n;i++) {
put_bits(&s->pb, 1, s->high_band_coded[ch][i]= 0);
if (0)
nb_coefs[ch] -= s->exponent_high_bands[bsize][i];
}
}
}
}
parse_exponents = 1;
if (s->block_len_bits != s->frame_len_bits) {
put_bits(&s->pb, 1, parse_exponents);
}
if (parse_exponents) {
for(ch = 0; ch < s->nb_channels; ch++) {
if (s->channel_coded[ch]) {
if (s->use_exp_vlc) {
encode_exp_vlc(s, ch, fixed_exp);
} else {
assert(0);
}
}
}
} else {
assert(0);
}
for(ch = 0; ch < s->nb_channels; ch++) {
if (s->channel_coded[ch]) {
int run, tindex;
WMACoef *ptr, *eptr;
tindex = (ch == 1 && s->ms_stereo);
ptr = &s->coefs1[ch][0];
eptr = ptr + nb_coefs[ch];
run=0;
for(;ptr < eptr; ptr++){
if(*ptr){
int level= *ptr;
int abs_level= FFABS(level);
int code= 0;
if(abs_level <= s->coef_vlcs[tindex]->max_level){
if(run < s->coef_vlcs[tindex]->levels[abs_level-1])
code= run + s->int_table[tindex][abs_level-1];
}
assert(code < s->coef_vlcs[tindex]->n);
put_bits(&s->pb, s->coef_vlcs[tindex]->huffbits[code], s->coef_vlcs[tindex]->huffcodes[code]);
if(code == 0){
if(1<<coef_nb_bits <= abs_level)
return -1;
if(abs_level == 0x71B && (s->avctx->flags & CODEC_FLAG_BITEXACT)) abs_level=0x71A;
put_bits(&s->pb, coef_nb_bits, abs_level);
put_bits(&s->pb, s->frame_len_bits, run);
}
put_bits(&s->pb, 1, level < 0);
run=0;
}else{
run++;
}
}
if(run)
put_bits(&s->pb, s->coef_vlcs[tindex]->huffbits[1], s->coef_vlcs[tindex]->huffcodes[1]);
}
if (s->version == 1 && s->nb_channels >= 2) {
avpriv_align_put_bits(&s->pb);
}
}
return 0;
}
| {
"code": [
" if(abs_level == 0x71B && (s->avctx->flags & CODEC_FLAG_BITEXACT)) abs_level=0x71A;"
],
"line_no": [
297
]
} | static int FUNC_0(WMACodecContext *VAR_0, float (*VAR_1)[BLOCK_MAX_SIZE], int VAR_2){
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;
float VAR_8;
int VAR_9[MAX_CHANNELS];
static const int VAR_10[25]={20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20};
if (VAR_0->use_variable_block_len) {
assert(0);
}else{
VAR_0->next_block_len_bits = VAR_0->frame_len_bits;
VAR_0->prev_block_len_bits = VAR_0->frame_len_bits;
VAR_0->block_len_bits = VAR_0->frame_len_bits;
}
VAR_0->block_len = 1 << VAR_0->block_len_bits;
VAR_4 = VAR_0->frame_len_bits - VAR_0->block_len_bits;
VAR_3 = VAR_0->coefs_end[VAR_4] - VAR_0->coefs_start;
for(VAR_5 = 0; VAR_5 < VAR_0->nb_channels; VAR_5++)
VAR_9[VAR_5] = VAR_3;
{
int VAR_11 = VAR_0->block_len / 2;
VAR_8 = 1.0 / (float)VAR_11;
if (VAR_0->version == 1) {
VAR_8 *= sqrt(VAR_11);
}
}
if (VAR_0->nb_channels == 2) {
put_bits(&VAR_0->pb, 1, !!VAR_0->ms_stereo);
}
for(VAR_5 = 0; VAR_5 < VAR_0->nb_channels; VAR_5++) {
VAR_0->channel_coded[VAR_5] = 1;
if (VAR_0->channel_coded[VAR_5]) {
init_exp(VAR_0, VAR_5, VAR_10);
}
}
for(VAR_5 = 0; VAR_5 < VAR_0->nb_channels; VAR_5++) {
if (VAR_0->channel_coded[VAR_5]) {
WMACoef *coefs1;
float *coefs, *exponents, mult;
int i, n;
coefs1 = VAR_0->coefs1[VAR_5];
exponents = VAR_0->exponents[VAR_5];
mult = pow(10, VAR_2 * 0.05) / VAR_0->max_exponent[VAR_5];
mult *= VAR_8;
coefs = VAR_1[VAR_5];
if (VAR_0->use_noise_coding && 0) {
assert(0);
} else {
coefs += VAR_0->coefs_start;
n = VAR_9[VAR_5];
for(i = 0;i < n; i++){
double t= *coefs++ / (exponents[i] * mult);
if(t<-32768 || t>32767)
return -1;
coefs1[i] = lrint(t);
}
}
}
}
VAR_3 = 0;
for(VAR_5 = 0; VAR_5 < VAR_0->nb_channels; VAR_5++) {
int a = VAR_0->channel_coded[VAR_5];
put_bits(&VAR_0->pb, 1, a);
VAR_3 |= a;
}
if (!VAR_3)
return 1;
for(VAR_3= VAR_2-1; VAR_3>=127; VAR_3-= 127)
put_bits(&VAR_0->pb, 7, 127);
put_bits(&VAR_0->pb, 7, VAR_3);
VAR_6= ff_wma_total_gain_to_bits(VAR_2);
if (VAR_0->use_noise_coding) {
for(VAR_5 = 0; VAR_5 < VAR_0->nb_channels; VAR_5++) {
if (VAR_0->channel_coded[VAR_5]) {
int i, n;
n = VAR_0->exponent_high_sizes[VAR_4];
for(i=0;i<n;i++) {
put_bits(&VAR_0->pb, 1, VAR_0->high_band_coded[VAR_5][i]= 0);
if (0)
VAR_9[VAR_5] -= VAR_0->exponent_high_bands[VAR_4][i];
}
}
}
}
VAR_7 = 1;
if (VAR_0->block_len_bits != VAR_0->frame_len_bits) {
put_bits(&VAR_0->pb, 1, VAR_7);
}
if (VAR_7) {
for(VAR_5 = 0; VAR_5 < VAR_0->nb_channels; VAR_5++) {
if (VAR_0->channel_coded[VAR_5]) {
if (VAR_0->use_exp_vlc) {
encode_exp_vlc(VAR_0, VAR_5, VAR_10);
} else {
assert(0);
}
}
}
} else {
assert(0);
}
for(VAR_5 = 0; VAR_5 < VAR_0->nb_channels; VAR_5++) {
if (VAR_0->channel_coded[VAR_5]) {
int run, tindex;
WMACoef *ptr, *eptr;
tindex = (VAR_5 == 1 && VAR_0->ms_stereo);
ptr = &VAR_0->coefs1[VAR_5][0];
eptr = ptr + VAR_9[VAR_5];
run=0;
for(;ptr < eptr; ptr++){
if(*ptr){
int level= *ptr;
int abs_level= FFABS(level);
int code= 0;
if(abs_level <= VAR_0->coef_vlcs[tindex]->max_level){
if(run < VAR_0->coef_vlcs[tindex]->levels[abs_level-1])
code= run + VAR_0->int_table[tindex][abs_level-1];
}
assert(code < VAR_0->coef_vlcs[tindex]->n);
put_bits(&VAR_0->pb, VAR_0->coef_vlcs[tindex]->huffbits[code], VAR_0->coef_vlcs[tindex]->huffcodes[code]);
if(code == 0){
if(1<<VAR_6 <= abs_level)
return -1;
if(abs_level == 0x71B && (VAR_0->avctx->flags & CODEC_FLAG_BITEXACT)) abs_level=0x71A;
put_bits(&VAR_0->pb, VAR_6, abs_level);
put_bits(&VAR_0->pb, VAR_0->frame_len_bits, run);
}
put_bits(&VAR_0->pb, 1, level < 0);
run=0;
}else{
run++;
}
}
if(run)
put_bits(&VAR_0->pb, VAR_0->coef_vlcs[tindex]->huffbits[1], VAR_0->coef_vlcs[tindex]->huffcodes[1]);
}
if (VAR_0->version == 1 && VAR_0->nb_channels >= 2) {
avpriv_align_put_bits(&VAR_0->pb);
}
}
return 0;
}
| [
"static int FUNC_0(WMACodecContext *VAR_0, float (*VAR_1)[BLOCK_MAX_SIZE], int VAR_2){",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;",
"float VAR_8;",
"int VAR_9[MAX_CHANNELS];",
"static const int VAR_10[25]={20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20};",
"if (VAR_0->use_variable_block_len) {",
"assert(0);",
"}else{",
"VAR_0->next_block_len_bits = VAR_0->frame_len_bits;",
"VAR_0->prev_block_len_bits = VAR_0->frame_len_bits;",
"VAR_0->block_len_bits = VAR_0->frame_len_bits;",
"}",
"VAR_0->block_len = 1 << VAR_0->block_len_bits;",
"VAR_4 = VAR_0->frame_len_bits - VAR_0->block_len_bits;",
"VAR_3 = VAR_0->coefs_end[VAR_4] - VAR_0->coefs_start;",
"for(VAR_5 = 0; VAR_5 < VAR_0->nb_channels; VAR_5++)",
"VAR_9[VAR_5] = VAR_3;",
"{",
"int VAR_11 = VAR_0->block_len / 2;",
"VAR_8 = 1.0 / (float)VAR_11;",
"if (VAR_0->version == 1) {",
"VAR_8 *= sqrt(VAR_11);",
"}",
"}",
"if (VAR_0->nb_channels == 2) {",
"put_bits(&VAR_0->pb, 1, !!VAR_0->ms_stereo);",
"}",
"for(VAR_5 = 0; VAR_5 < VAR_0->nb_channels; VAR_5++) {",
"VAR_0->channel_coded[VAR_5] = 1;",
"if (VAR_0->channel_coded[VAR_5]) {",
"init_exp(VAR_0, VAR_5, VAR_10);",
"}",
"}",
"for(VAR_5 = 0; VAR_5 < VAR_0->nb_channels; VAR_5++) {",
"if (VAR_0->channel_coded[VAR_5]) {",
"WMACoef *coefs1;",
"float *coefs, *exponents, mult;",
"int i, n;",
"coefs1 = VAR_0->coefs1[VAR_5];",
"exponents = VAR_0->exponents[VAR_5];",
"mult = pow(10, VAR_2 * 0.05) / VAR_0->max_exponent[VAR_5];",
"mult *= VAR_8;",
"coefs = VAR_1[VAR_5];",
"if (VAR_0->use_noise_coding && 0) {",
"assert(0);",
"} else {",
"coefs += VAR_0->coefs_start;",
"n = VAR_9[VAR_5];",
"for(i = 0;i < n; i++){",
"double t= *coefs++ / (exponents[i] * mult);",
"if(t<-32768 || t>32767)\nreturn -1;",
"coefs1[i] = lrint(t);",
"}",
"}",
"}",
"}",
"VAR_3 = 0;",
"for(VAR_5 = 0; VAR_5 < VAR_0->nb_channels; VAR_5++) {",
"int a = VAR_0->channel_coded[VAR_5];",
"put_bits(&VAR_0->pb, 1, a);",
"VAR_3 |= a;",
"}",
"if (!VAR_3)\nreturn 1;",
"for(VAR_3= VAR_2-1; VAR_3>=127; VAR_3-= 127)",
"put_bits(&VAR_0->pb, 7, 127);",
"put_bits(&VAR_0->pb, 7, VAR_3);",
"VAR_6= ff_wma_total_gain_to_bits(VAR_2);",
"if (VAR_0->use_noise_coding) {",
"for(VAR_5 = 0; VAR_5 < VAR_0->nb_channels; VAR_5++) {",
"if (VAR_0->channel_coded[VAR_5]) {",
"int i, n;",
"n = VAR_0->exponent_high_sizes[VAR_4];",
"for(i=0;i<n;i++) {",
"put_bits(&VAR_0->pb, 1, VAR_0->high_band_coded[VAR_5][i]= 0);",
"if (0)\nVAR_9[VAR_5] -= VAR_0->exponent_high_bands[VAR_4][i];",
"}",
"}",
"}",
"}",
"VAR_7 = 1;",
"if (VAR_0->block_len_bits != VAR_0->frame_len_bits) {",
"put_bits(&VAR_0->pb, 1, VAR_7);",
"}",
"if (VAR_7) {",
"for(VAR_5 = 0; VAR_5 < VAR_0->nb_channels; VAR_5++) {",
"if (VAR_0->channel_coded[VAR_5]) {",
"if (VAR_0->use_exp_vlc) {",
"encode_exp_vlc(VAR_0, VAR_5, VAR_10);",
"} else {",
"assert(0);",
"}",
"}",
"}",
"} else {",
"assert(0);",
"}",
"for(VAR_5 = 0; VAR_5 < VAR_0->nb_channels; VAR_5++) {",
"if (VAR_0->channel_coded[VAR_5]) {",
"int run, tindex;",
"WMACoef *ptr, *eptr;",
"tindex = (VAR_5 == 1 && VAR_0->ms_stereo);",
"ptr = &VAR_0->coefs1[VAR_5][0];",
"eptr = ptr + VAR_9[VAR_5];",
"run=0;",
"for(;ptr < eptr; ptr++){",
"if(*ptr){",
"int level= *ptr;",
"int abs_level= FFABS(level);",
"int code= 0;",
"if(abs_level <= VAR_0->coef_vlcs[tindex]->max_level){",
"if(run < VAR_0->coef_vlcs[tindex]->levels[abs_level-1])\ncode= run + VAR_0->int_table[tindex][abs_level-1];",
"}",
"assert(code < VAR_0->coef_vlcs[tindex]->n);",
"put_bits(&VAR_0->pb, VAR_0->coef_vlcs[tindex]->huffbits[code], VAR_0->coef_vlcs[tindex]->huffcodes[code]);",
"if(code == 0){",
"if(1<<VAR_6 <= abs_level)\nreturn -1;",
"if(abs_level == 0x71B && (VAR_0->avctx->flags & CODEC_FLAG_BITEXACT)) abs_level=0x71A;",
"put_bits(&VAR_0->pb, VAR_6, abs_level);",
"put_bits(&VAR_0->pb, VAR_0->frame_len_bits, run);",
"}",
"put_bits(&VAR_0->pb, 1, level < 0);",
"run=0;",
"}else{",
"run++;",
"}",
"}",
"if(run)\nput_bits(&VAR_0->pb, VAR_0->coef_vlcs[tindex]->huffbits[1], VAR_0->coef_vlcs[tindex]->huffcodes[1]);",
"}",
"if (VAR_0->version == 1 && VAR_0->nb_channels >= 2) {",
"avpriv_align_put_bits(&VAR_0->pb);",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
37
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123,
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155,
157
],
[
161
],
[
163
],
[
165
],
[
169
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187,
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
201
],
[
203
],
[
205
],
[
207
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271,
273
],
[
275
],
[
279
],
[
281
],
[
285
],
[
287,
289
],
[
297
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319,
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
]
] |
4,538 | static void check(int a, int b, bool expected)
{
struct qht_stats stats;
int i;
for (i = a; i < b; i++) {
void *p;
uint32_t hash;
int32_t val;
val = i;
hash = i;
p = qht_lookup(&ht, is_equal, &val, hash);
g_assert_true(!!p == expected);
}
rcu_read_unlock();
qht_statistics_init(&ht, &stats);
if (stats.used_head_buckets) {
g_assert_cmpfloat(qdist_avg(&stats.chain), >=, 1.0);
}
g_assert_cmpuint(stats.head_buckets, >, 0);
qht_statistics_destroy(&stats);
} | true | qemu | 9c7d64eb2a47033c9697fb4a5a540af1aa3915ab | static void check(int a, int b, bool expected)
{
struct qht_stats stats;
int i;
for (i = a; i < b; i++) {
void *p;
uint32_t hash;
int32_t val;
val = i;
hash = i;
p = qht_lookup(&ht, is_equal, &val, hash);
g_assert_true(!!p == expected);
}
rcu_read_unlock();
qht_statistics_init(&ht, &stats);
if (stats.used_head_buckets) {
g_assert_cmpfloat(qdist_avg(&stats.chain), >=, 1.0);
}
g_assert_cmpuint(stats.head_buckets, >, 0);
qht_statistics_destroy(&stats);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(int VAR_0, int VAR_1, bool VAR_2)
{
struct qht_stats VAR_3;
int VAR_4;
for (VAR_4 = VAR_0; VAR_4 < VAR_1; VAR_4++) {
void *VAR_5;
uint32_t hash;
int32_t val;
val = VAR_4;
hash = VAR_4;
VAR_5 = qht_lookup(&ht, is_equal, &val, hash);
g_assert_true(!!VAR_5 == VAR_2);
}
rcu_read_unlock();
qht_statistics_init(&ht, &VAR_3);
if (VAR_3.used_head_buckets) {
g_assert_cmpfloat(qdist_avg(&VAR_3.chain), >=, 1.0);
}
g_assert_cmpuint(VAR_3.head_buckets, >, 0);
qht_statistics_destroy(&VAR_3);
} | [
"static void FUNC_0(int VAR_0, int VAR_1, bool VAR_2)\n{",
"struct qht_stats VAR_3;",
"int VAR_4;",
"for (VAR_4 = VAR_0; VAR_4 < VAR_1; VAR_4++) {",
"void *VAR_5;",
"uint32_t hash;",
"int32_t val;",
"val = VAR_4;",
"hash = VAR_4;",
"VAR_5 = qht_lookup(&ht, is_equal, &val, hash);",
"g_assert_true(!!VAR_5 == VAR_2);",
"}",
"rcu_read_unlock();",
"qht_statistics_init(&ht, &VAR_3);",
"if (VAR_3.used_head_buckets) {",
"g_assert_cmpfloat(qdist_avg(&VAR_3.chain), >=, 1.0);",
"}",
"g_assert_cmpuint(VAR_3.head_buckets, >, 0);",
"qht_statistics_destroy(&VAR_3);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
12
],
[
14
],
[
16
],
[
18
],
[
22
],
[
24
],
[
26
],
[
28
],
[
30
],
[
32
],
[
36
],
[
38
],
[
40
],
[
42
],
[
44
],
[
46
],
[
48
]
] |
4,541 | int net_init_netmap(const NetClientOptions *opts,
const char *name, NetClientState *peer, Error **errp)
{
const NetdevNetmapOptions *netmap_opts = opts->u.netmap;
struct nm_desc *nmd;
NetClientState *nc;
Error *err = NULL;
NetmapState *s;
nmd = netmap_open(netmap_opts, &err);
if (err) {
error_propagate(errp, err);
return -1;
}
/* Create the object. */
nc = qemu_new_net_client(&net_netmap_info, peer, "netmap", name);
s = DO_UPCAST(NetmapState, nc, nc);
s->nmd = nmd;
s->tx = NETMAP_TXRING(nmd->nifp, 0);
s->rx = NETMAP_RXRING(nmd->nifp, 0);
s->vnet_hdr_len = 0;
pstrcpy(s->ifname, sizeof(s->ifname), netmap_opts->ifname);
netmap_read_poll(s, true); /* Initially only poll for reads. */
return 0;
}
| false | qemu | 32bafa8fdd098d52fbf1102d5a5e48d29398c0aa | int net_init_netmap(const NetClientOptions *opts,
const char *name, NetClientState *peer, Error **errp)
{
const NetdevNetmapOptions *netmap_opts = opts->u.netmap;
struct nm_desc *nmd;
NetClientState *nc;
Error *err = NULL;
NetmapState *s;
nmd = netmap_open(netmap_opts, &err);
if (err) {
error_propagate(errp, err);
return -1;
}
nc = qemu_new_net_client(&net_netmap_info, peer, "netmap", name);
s = DO_UPCAST(NetmapState, nc, nc);
s->nmd = nmd;
s->tx = NETMAP_TXRING(nmd->nifp, 0);
s->rx = NETMAP_RXRING(nmd->nifp, 0);
s->vnet_hdr_len = 0;
pstrcpy(s->ifname, sizeof(s->ifname), netmap_opts->ifname);
netmap_read_poll(s, true);
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(const NetClientOptions *VAR_0,
const char *VAR_1, NetClientState *VAR_2, Error **VAR_3)
{
const NetdevNetmapOptions *VAR_4 = VAR_0->u.netmap;
struct nm_desc *VAR_5;
NetClientState *nc;
Error *err = NULL;
NetmapState *s;
VAR_5 = netmap_open(VAR_4, &err);
if (err) {
error_propagate(VAR_3, err);
return -1;
}
nc = qemu_new_net_client(&net_netmap_info, VAR_2, "netmap", VAR_1);
s = DO_UPCAST(NetmapState, nc, nc);
s->VAR_5 = VAR_5;
s->tx = NETMAP_TXRING(VAR_5->nifp, 0);
s->rx = NETMAP_RXRING(VAR_5->nifp, 0);
s->vnet_hdr_len = 0;
pstrcpy(s->ifname, sizeof(s->ifname), VAR_4->ifname);
netmap_read_poll(s, true);
return 0;
}
| [
"int FUNC_0(const NetClientOptions *VAR_0,\nconst char *VAR_1, NetClientState *VAR_2, Error **VAR_3)\n{",
"const NetdevNetmapOptions *VAR_4 = VAR_0->u.netmap;",
"struct nm_desc *VAR_5;",
"NetClientState *nc;",
"Error *err = NULL;",
"NetmapState *s;",
"VAR_5 = netmap_open(VAR_4, &err);",
"if (err) {",
"error_propagate(VAR_3, err);",
"return -1;",
"}",
"nc = qemu_new_net_client(&net_netmap_info, VAR_2, \"netmap\", VAR_1);",
"s = DO_UPCAST(NetmapState, nc, nc);",
"s->VAR_5 = VAR_5;",
"s->tx = NETMAP_TXRING(VAR_5->nifp, 0);",
"s->rx = NETMAP_RXRING(VAR_5->nifp, 0);",
"s->vnet_hdr_len = 0;",
"pstrcpy(s->ifname, sizeof(s->ifname), VAR_4->ifname);",
"netmap_read_poll(s, true);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
]
] |
4,542 | static void pc_init1(MachineState *machine,
const char *host_type, const char *pci_type)
{
PCMachineState *pcms = PC_MACHINE(machine);
PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *system_io = get_system_io();
int i;
PCIBus *pci_bus;
ISABus *isa_bus;
PCII440FXState *i440fx_state;
int piix3_devfn = -1;
qemu_irq *i8259;
qemu_irq smi_irq;
GSIState *gsi_state;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
BusState *idebus[MAX_IDE_BUS];
ISADevice *rtc_state;
MemoryRegion *ram_memory;
MemoryRegion *pci_memory;
MemoryRegion *rom_memory;
ram_addr_t lowmem;
/*
* Calculate ram split, for memory below and above 4G. It's a bit
* complicated for backward compatibility reasons ...
*
* - Traditional split is 3.5G (lowmem = 0xe0000000). This is the
* default value for max_ram_below_4g now.
*
* - Then, to gigabyte align the memory, we move the split to 3G
* (lowmem = 0xc0000000). But only in case we have to split in
* the first place, i.e. ram_size is larger than (traditional)
* lowmem. And for new machine types (gigabyte_align = true)
* only, for live migration compatibility reasons.
*
* - Next the max-ram-below-4g option was added, which allowed to
* reduce lowmem to a smaller value, to allow a larger PCI I/O
* window below 4G. qemu doesn't enforce gigabyte alignment here,
* but prints a warning.
*
* - Finally max-ram-below-4g got updated to also allow raising lowmem,
* so legacy non-PAE guests can get as much memory as possible in
* the 32bit address space below 4G.
*
* - Note that Xen has its own ram setp code in xen_ram_init(),
* called via xen_hvm_init().
*
* Examples:
* qemu -M pc-1.7 -m 4G (old default) -> 3584M low, 512M high
* qemu -M pc -m 4G (new default) -> 3072M low, 1024M high
* qemu -M pc,max-ram-below-4g=2G -m 4G -> 2048M low, 2048M high
* qemu -M pc,max-ram-below-4g=4G -m 3968M -> 3968M low (=4G-128M)
*/
if (xen_enabled()) {
xen_hvm_init(pcms, &ram_memory);
} else {
if (!pcms->max_ram_below_4g) {
pcms->max_ram_below_4g = 0xe0000000; /* default: 3.5G */
}
lowmem = pcms->max_ram_below_4g;
if (machine->ram_size >= pcms->max_ram_below_4g) {
if (pcmc->gigabyte_align) {
if (lowmem > 0xc0000000) {
lowmem = 0xc0000000;
}
if (lowmem & ((1ULL << 30) - 1)) {
error_report("Warning: Large machine and max_ram_below_4g "
"(%" PRIu64 ") not a multiple of 1G; "
"possible bad performance.",
pcms->max_ram_below_4g);
}
}
}
if (machine->ram_size >= lowmem) {
pcms->above_4g_mem_size = machine->ram_size - lowmem;
pcms->below_4g_mem_size = lowmem;
} else {
pcms->above_4g_mem_size = 0;
pcms->below_4g_mem_size = machine->ram_size;
}
}
pc_cpus_init(pcms);
if (kvm_enabled() && pcmc->kvmclock_enabled) {
kvmclock_create();
}
if (pcmc->pci_enabled) {
pci_memory = g_new(MemoryRegion, 1);
memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
rom_memory = pci_memory;
} else {
pci_memory = NULL;
rom_memory = system_memory;
}
pc_guest_info_init(pcms);
if (pcmc->smbios_defaults) {
MachineClass *mc = MACHINE_GET_CLASS(machine);
/* These values are guest ABI, do not change */
smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)",
mc->name, pcmc->smbios_legacy_mode,
pcmc->smbios_uuid_encoded,
SMBIOS_ENTRY_POINT_21);
}
/* allocate ram and load rom/bios */
if (!xen_enabled()) {
pc_memory_init(pcms, system_memory,
rom_memory, &ram_memory);
} else if (machine->kernel_filename != NULL) {
/* For xen HVM direct kernel boot, load linux here */
xen_load_linux(pcms);
}
gsi_state = g_malloc0(sizeof(*gsi_state));
if (kvm_ioapic_in_kernel()) {
kvm_pc_setup_irq_routing(pcmc->pci_enabled);
pcms->gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
GSI_NUM_PINS);
} else {
pcms->gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
}
if (pcmc->pci_enabled) {
pci_bus = i440fx_init(host_type,
pci_type,
&i440fx_state, &piix3_devfn, &isa_bus, pcms->gsi,
system_memory, system_io, machine->ram_size,
pcms->below_4g_mem_size,
pcms->above_4g_mem_size,
pci_memory, ram_memory);
pcms->bus = pci_bus;
} else {
pci_bus = NULL;
i440fx_state = NULL;
isa_bus = isa_bus_new(NULL, get_system_memory(), system_io,
&error_abort);
no_hpet = 1;
}
isa_bus_irqs(isa_bus, pcms->gsi);
if (kvm_pic_in_kernel()) {
i8259 = kvm_i8259_init(isa_bus);
} else if (xen_enabled()) {
i8259 = xen_interrupt_controller_init();
} else {
i8259 = i8259_init(isa_bus, pc_allocate_cpu_irq());
}
for (i = 0; i < ISA_NUM_IRQS; i++) {
gsi_state->i8259_irq[i] = i8259[i];
}
g_free(i8259);
if (pcmc->pci_enabled) {
ioapic_init_gsi(gsi_state, "i440fx");
}
pc_register_ferr_irq(pcms->gsi[13]);
pc_vga_init(isa_bus, pcmc->pci_enabled ? pci_bus : NULL);
assert(pcms->vmport != ON_OFF_AUTO__MAX);
if (pcms->vmport == ON_OFF_AUTO_AUTO) {
pcms->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON;
}
/* init basic PC hardware */
pc_basic_device_init(isa_bus, pcms->gsi, &rtc_state, true,
(pcms->vmport != ON_OFF_AUTO_ON), pcms->pit, 0x4);
pc_nic_init(isa_bus, pci_bus);
ide_drive_get(hd, ARRAY_SIZE(hd));
if (pcmc->pci_enabled) {
PCIDevice *dev;
if (xen_enabled()) {
dev = pci_piix3_xen_ide_init(pci_bus, hd, piix3_devfn + 1);
} else {
dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1);
}
idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
} else {
for(i = 0; i < MAX_IDE_BUS; i++) {
ISADevice *dev;
char busname[] = "ide.0";
dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
ide_irq[i],
hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
/*
* The ide bus name is ide.0 for the first bus and ide.1 for the
* second one.
*/
busname[4] = '0' + i;
idebus[i] = qdev_get_child_bus(DEVICE(dev), busname);
}
}
pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state);
if (pcmc->pci_enabled && machine_usb(machine)) {
pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
}
if (pcmc->pci_enabled && acpi_enabled) {
DeviceState *piix4_pm;
I2CBus *smbus;
smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0);
/* TODO: Populate SPD eeprom data. */
smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
pcms->gsi[9], smi_irq,
pc_machine_is_smm_enabled(pcms),
&piix4_pm);
smbus_eeprom_init(smbus, 8, NULL, 0);
object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
TYPE_HOTPLUG_HANDLER,
(Object **)&pcms->acpi_dev,
object_property_allow_set_link,
OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort);
object_property_set_link(OBJECT(machine), OBJECT(piix4_pm),
PC_MACHINE_ACPI_DEVICE_PROP, &error_abort);
}
if (pcmc->pci_enabled) {
pc_pci_device_init(pci_bus);
}
if (pcms->acpi_nvdimm_state.is_enabled) {
nvdimm_init_acpi_state(&pcms->acpi_nvdimm_state, system_io,
pcms->fw_cfg, OBJECT(pcms));
}
}
| false | qemu | 3dc6f8693694a649a9c83f1e2746565b47683923 | static void pc_init1(MachineState *machine,
const char *host_type, const char *pci_type)
{
PCMachineState *pcms = PC_MACHINE(machine);
PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *system_io = get_system_io();
int i;
PCIBus *pci_bus;
ISABus *isa_bus;
PCII440FXState *i440fx_state;
int piix3_devfn = -1;
qemu_irq *i8259;
qemu_irq smi_irq;
GSIState *gsi_state;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
BusState *idebus[MAX_IDE_BUS];
ISADevice *rtc_state;
MemoryRegion *ram_memory;
MemoryRegion *pci_memory;
MemoryRegion *rom_memory;
ram_addr_t lowmem;
if (xen_enabled()) {
xen_hvm_init(pcms, &ram_memory);
} else {
if (!pcms->max_ram_below_4g) {
pcms->max_ram_below_4g = 0xe0000000;
}
lowmem = pcms->max_ram_below_4g;
if (machine->ram_size >= pcms->max_ram_below_4g) {
if (pcmc->gigabyte_align) {
if (lowmem > 0xc0000000) {
lowmem = 0xc0000000;
}
if (lowmem & ((1ULL << 30) - 1)) {
error_report("Warning: Large machine and max_ram_below_4g "
"(%" PRIu64 ") not a multiple of 1G; "
"possible bad performance.",
pcms->max_ram_below_4g);
}
}
}
if (machine->ram_size >= lowmem) {
pcms->above_4g_mem_size = machine->ram_size - lowmem;
pcms->below_4g_mem_size = lowmem;
} else {
pcms->above_4g_mem_size = 0;
pcms->below_4g_mem_size = machine->ram_size;
}
}
pc_cpus_init(pcms);
if (kvm_enabled() && pcmc->kvmclock_enabled) {
kvmclock_create();
}
if (pcmc->pci_enabled) {
pci_memory = g_new(MemoryRegion, 1);
memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
rom_memory = pci_memory;
} else {
pci_memory = NULL;
rom_memory = system_memory;
}
pc_guest_info_init(pcms);
if (pcmc->smbios_defaults) {
MachineClass *mc = MACHINE_GET_CLASS(machine);
smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)",
mc->name, pcmc->smbios_legacy_mode,
pcmc->smbios_uuid_encoded,
SMBIOS_ENTRY_POINT_21);
}
if (!xen_enabled()) {
pc_memory_init(pcms, system_memory,
rom_memory, &ram_memory);
} else if (machine->kernel_filename != NULL) {
xen_load_linux(pcms);
}
gsi_state = g_malloc0(sizeof(*gsi_state));
if (kvm_ioapic_in_kernel()) {
kvm_pc_setup_irq_routing(pcmc->pci_enabled);
pcms->gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
GSI_NUM_PINS);
} else {
pcms->gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
}
if (pcmc->pci_enabled) {
pci_bus = i440fx_init(host_type,
pci_type,
&i440fx_state, &piix3_devfn, &isa_bus, pcms->gsi,
system_memory, system_io, machine->ram_size,
pcms->below_4g_mem_size,
pcms->above_4g_mem_size,
pci_memory, ram_memory);
pcms->bus = pci_bus;
} else {
pci_bus = NULL;
i440fx_state = NULL;
isa_bus = isa_bus_new(NULL, get_system_memory(), system_io,
&error_abort);
no_hpet = 1;
}
isa_bus_irqs(isa_bus, pcms->gsi);
if (kvm_pic_in_kernel()) {
i8259 = kvm_i8259_init(isa_bus);
} else if (xen_enabled()) {
i8259 = xen_interrupt_controller_init();
} else {
i8259 = i8259_init(isa_bus, pc_allocate_cpu_irq());
}
for (i = 0; i < ISA_NUM_IRQS; i++) {
gsi_state->i8259_irq[i] = i8259[i];
}
g_free(i8259);
if (pcmc->pci_enabled) {
ioapic_init_gsi(gsi_state, "i440fx");
}
pc_register_ferr_irq(pcms->gsi[13]);
pc_vga_init(isa_bus, pcmc->pci_enabled ? pci_bus : NULL);
assert(pcms->vmport != ON_OFF_AUTO__MAX);
if (pcms->vmport == ON_OFF_AUTO_AUTO) {
pcms->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON;
}
pc_basic_device_init(isa_bus, pcms->gsi, &rtc_state, true,
(pcms->vmport != ON_OFF_AUTO_ON), pcms->pit, 0x4);
pc_nic_init(isa_bus, pci_bus);
ide_drive_get(hd, ARRAY_SIZE(hd));
if (pcmc->pci_enabled) {
PCIDevice *dev;
if (xen_enabled()) {
dev = pci_piix3_xen_ide_init(pci_bus, hd, piix3_devfn + 1);
} else {
dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1);
}
idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
} else {
for(i = 0; i < MAX_IDE_BUS; i++) {
ISADevice *dev;
char busname[] = "ide.0";
dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
ide_irq[i],
hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
busname[4] = '0' + i;
idebus[i] = qdev_get_child_bus(DEVICE(dev), busname);
}
}
pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state);
if (pcmc->pci_enabled && machine_usb(machine)) {
pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
}
if (pcmc->pci_enabled && acpi_enabled) {
DeviceState *piix4_pm;
I2CBus *smbus;
smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0);
smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
pcms->gsi[9], smi_irq,
pc_machine_is_smm_enabled(pcms),
&piix4_pm);
smbus_eeprom_init(smbus, 8, NULL, 0);
object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
TYPE_HOTPLUG_HANDLER,
(Object **)&pcms->acpi_dev,
object_property_allow_set_link,
OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort);
object_property_set_link(OBJECT(machine), OBJECT(piix4_pm),
PC_MACHINE_ACPI_DEVICE_PROP, &error_abort);
}
if (pcmc->pci_enabled) {
pc_pci_device_init(pci_bus);
}
if (pcms->acpi_nvdimm_state.is_enabled) {
nvdimm_init_acpi_state(&pcms->acpi_nvdimm_state, system_io,
pcms->fw_cfg, OBJECT(pcms));
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(MachineState *VAR_0,
const char *VAR_1, const char *VAR_2)
{
PCMachineState *pcms = PC_MACHINE(VAR_0);
PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *system_io = get_system_io();
int VAR_3;
PCIBus *pci_bus;
ISABus *isa_bus;
PCII440FXState *i440fx_state;
int VAR_4 = -1;
qemu_irq *i8259;
qemu_irq smi_irq;
GSIState *gsi_state;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
BusState *idebus[MAX_IDE_BUS];
ISADevice *rtc_state;
MemoryRegion *ram_memory;
MemoryRegion *pci_memory;
MemoryRegion *rom_memory;
ram_addr_t lowmem;
if (xen_enabled()) {
xen_hvm_init(pcms, &ram_memory);
} else {
if (!pcms->max_ram_below_4g) {
pcms->max_ram_below_4g = 0xe0000000;
}
lowmem = pcms->max_ram_below_4g;
if (VAR_0->ram_size >= pcms->max_ram_below_4g) {
if (pcmc->gigabyte_align) {
if (lowmem > 0xc0000000) {
lowmem = 0xc0000000;
}
if (lowmem & ((1ULL << 30) - 1)) {
error_report("Warning: Large VAR_0 and max_ram_below_4g "
"(%" PRIu64 ") not a multiple of 1G; "
"possible bad performance.",
pcms->max_ram_below_4g);
}
}
}
if (VAR_0->ram_size >= lowmem) {
pcms->above_4g_mem_size = VAR_0->ram_size - lowmem;
pcms->below_4g_mem_size = lowmem;
} else {
pcms->above_4g_mem_size = 0;
pcms->below_4g_mem_size = VAR_0->ram_size;
}
}
pc_cpus_init(pcms);
if (kvm_enabled() && pcmc->kvmclock_enabled) {
kvmclock_create();
}
if (pcmc->pci_enabled) {
pci_memory = g_new(MemoryRegion, 1);
memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
rom_memory = pci_memory;
} else {
pci_memory = NULL;
rom_memory = system_memory;
}
pc_guest_info_init(pcms);
if (pcmc->smbios_defaults) {
MachineClass *mc = MACHINE_GET_CLASS(VAR_0);
smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)",
mc->name, pcmc->smbios_legacy_mode,
pcmc->smbios_uuid_encoded,
SMBIOS_ENTRY_POINT_21);
}
if (!xen_enabled()) {
pc_memory_init(pcms, system_memory,
rom_memory, &ram_memory);
} else if (VAR_0->kernel_filename != NULL) {
xen_load_linux(pcms);
}
gsi_state = g_malloc0(sizeof(*gsi_state));
if (kvm_ioapic_in_kernel()) {
kvm_pc_setup_irq_routing(pcmc->pci_enabled);
pcms->gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
GSI_NUM_PINS);
} else {
pcms->gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
}
if (pcmc->pci_enabled) {
pci_bus = i440fx_init(VAR_1,
VAR_2,
&i440fx_state, &VAR_4, &isa_bus, pcms->gsi,
system_memory, system_io, VAR_0->ram_size,
pcms->below_4g_mem_size,
pcms->above_4g_mem_size,
pci_memory, ram_memory);
pcms->bus = pci_bus;
} else {
pci_bus = NULL;
i440fx_state = NULL;
isa_bus = isa_bus_new(NULL, get_system_memory(), system_io,
&error_abort);
no_hpet = 1;
}
isa_bus_irqs(isa_bus, pcms->gsi);
if (kvm_pic_in_kernel()) {
i8259 = kvm_i8259_init(isa_bus);
} else if (xen_enabled()) {
i8259 = xen_interrupt_controller_init();
} else {
i8259 = i8259_init(isa_bus, pc_allocate_cpu_irq());
}
for (VAR_3 = 0; VAR_3 < ISA_NUM_IRQS; VAR_3++) {
gsi_state->i8259_irq[VAR_3] = i8259[VAR_3];
}
g_free(i8259);
if (pcmc->pci_enabled) {
ioapic_init_gsi(gsi_state, "i440fx");
}
pc_register_ferr_irq(pcms->gsi[13]);
pc_vga_init(isa_bus, pcmc->pci_enabled ? pci_bus : NULL);
assert(pcms->vmport != ON_OFF_AUTO__MAX);
if (pcms->vmport == ON_OFF_AUTO_AUTO) {
pcms->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON;
}
pc_basic_device_init(isa_bus, pcms->gsi, &rtc_state, true,
(pcms->vmport != ON_OFF_AUTO_ON), pcms->pit, 0x4);
pc_nic_init(isa_bus, pci_bus);
ide_drive_get(hd, ARRAY_SIZE(hd));
if (pcmc->pci_enabled) {
PCIDevice *dev;
if (xen_enabled()) {
dev = pci_piix3_xen_ide_init(pci_bus, hd, VAR_4 + 1);
} else {
dev = pci_piix3_ide_init(pci_bus, hd, VAR_4 + 1);
}
idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
} else {
for(VAR_3 = 0; VAR_3 < MAX_IDE_BUS; VAR_3++) {
ISADevice *dev;
char busname[] = "ide.0";
dev = isa_ide_init(isa_bus, ide_iobase[VAR_3], ide_iobase2[VAR_3],
ide_irq[VAR_3],
hd[MAX_IDE_DEVS * VAR_3], hd[MAX_IDE_DEVS * VAR_3 + 1]);
busname[4] = '0' + VAR_3;
idebus[VAR_3] = qdev_get_child_bus(DEVICE(dev), busname);
}
}
pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state);
if (pcmc->pci_enabled && machine_usb(VAR_0)) {
pci_create_simple(pci_bus, VAR_4 + 2, "piix3-usb-uhci");
}
if (pcmc->pci_enabled && acpi_enabled) {
DeviceState *piix4_pm;
I2CBus *smbus;
smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0);
smbus = piix4_pm_init(pci_bus, VAR_4 + 3, 0xb100,
pcms->gsi[9], smi_irq,
pc_machine_is_smm_enabled(pcms),
&piix4_pm);
smbus_eeprom_init(smbus, 8, NULL, 0);
object_property_add_link(OBJECT(VAR_0), PC_MACHINE_ACPI_DEVICE_PROP,
TYPE_HOTPLUG_HANDLER,
(Object **)&pcms->acpi_dev,
object_property_allow_set_link,
OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort);
object_property_set_link(OBJECT(VAR_0), OBJECT(piix4_pm),
PC_MACHINE_ACPI_DEVICE_PROP, &error_abort);
}
if (pcmc->pci_enabled) {
pc_pci_device_init(pci_bus);
}
if (pcms->acpi_nvdimm_state.is_enabled) {
nvdimm_init_acpi_state(&pcms->acpi_nvdimm_state, system_io,
pcms->fw_cfg, OBJECT(pcms));
}
}
| [
"static void FUNC_0(MachineState *VAR_0,\nconst char *VAR_1, const char *VAR_2)\n{",
"PCMachineState *pcms = PC_MACHINE(VAR_0);",
"PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);",
"MemoryRegion *system_memory = get_system_memory();",
"MemoryRegion *system_io = get_system_io();",
"int VAR_3;",
"PCIBus *pci_bus;",
"ISABus *isa_bus;",
"PCII440FXState *i440fx_state;",
"int VAR_4 = -1;",
"qemu_irq *i8259;",
"qemu_irq smi_irq;",
"GSIState *gsi_state;",
"DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];",
"BusState *idebus[MAX_IDE_BUS];",
"ISADevice *rtc_state;",
"MemoryRegion *ram_memory;",
"MemoryRegion *pci_memory;",
"MemoryRegion *rom_memory;",
"ram_addr_t lowmem;",
"if (xen_enabled()) {",
"xen_hvm_init(pcms, &ram_memory);",
"} else {",
"if (!pcms->max_ram_below_4g) {",
"pcms->max_ram_below_4g = 0xe0000000;",
"}",
"lowmem = pcms->max_ram_below_4g;",
"if (VAR_0->ram_size >= pcms->max_ram_below_4g) {",
"if (pcmc->gigabyte_align) {",
"if (lowmem > 0xc0000000) {",
"lowmem = 0xc0000000;",
"}",
"if (lowmem & ((1ULL << 30) - 1)) {",
"error_report(\"Warning: Large VAR_0 and max_ram_below_4g \"\n\"(%\" PRIu64 \") not a multiple of 1G; \"",
"\"possible bad performance.\",\npcms->max_ram_below_4g);",
"}",
"}",
"}",
"if (VAR_0->ram_size >= lowmem) {",
"pcms->above_4g_mem_size = VAR_0->ram_size - lowmem;",
"pcms->below_4g_mem_size = lowmem;",
"} else {",
"pcms->above_4g_mem_size = 0;",
"pcms->below_4g_mem_size = VAR_0->ram_size;",
"}",
"}",
"pc_cpus_init(pcms);",
"if (kvm_enabled() && pcmc->kvmclock_enabled) {",
"kvmclock_create();",
"}",
"if (pcmc->pci_enabled) {",
"pci_memory = g_new(MemoryRegion, 1);",
"memory_region_init(pci_memory, NULL, \"pci\", UINT64_MAX);",
"rom_memory = pci_memory;",
"} else {",
"pci_memory = NULL;",
"rom_memory = system_memory;",
"}",
"pc_guest_info_init(pcms);",
"if (pcmc->smbios_defaults) {",
"MachineClass *mc = MACHINE_GET_CLASS(VAR_0);",
"smbios_set_defaults(\"QEMU\", \"Standard PC (i440FX + PIIX, 1996)\",\nmc->name, pcmc->smbios_legacy_mode,\npcmc->smbios_uuid_encoded,\nSMBIOS_ENTRY_POINT_21);",
"}",
"if (!xen_enabled()) {",
"pc_memory_init(pcms, system_memory,\nrom_memory, &ram_memory);",
"} else if (VAR_0->kernel_filename != NULL) {",
"xen_load_linux(pcms);",
"}",
"gsi_state = g_malloc0(sizeof(*gsi_state));",
"if (kvm_ioapic_in_kernel()) {",
"kvm_pc_setup_irq_routing(pcmc->pci_enabled);",
"pcms->gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,\nGSI_NUM_PINS);",
"} else {",
"pcms->gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);",
"}",
"if (pcmc->pci_enabled) {",
"pci_bus = i440fx_init(VAR_1,\nVAR_2,\n&i440fx_state, &VAR_4, &isa_bus, pcms->gsi,\nsystem_memory, system_io, VAR_0->ram_size,\npcms->below_4g_mem_size,\npcms->above_4g_mem_size,\npci_memory, ram_memory);",
"pcms->bus = pci_bus;",
"} else {",
"pci_bus = NULL;",
"i440fx_state = NULL;",
"isa_bus = isa_bus_new(NULL, get_system_memory(), system_io,\n&error_abort);",
"no_hpet = 1;",
"}",
"isa_bus_irqs(isa_bus, pcms->gsi);",
"if (kvm_pic_in_kernel()) {",
"i8259 = kvm_i8259_init(isa_bus);",
"} else if (xen_enabled()) {",
"i8259 = xen_interrupt_controller_init();",
"} else {",
"i8259 = i8259_init(isa_bus, pc_allocate_cpu_irq());",
"}",
"for (VAR_3 = 0; VAR_3 < ISA_NUM_IRQS; VAR_3++) {",
"gsi_state->i8259_irq[VAR_3] = i8259[VAR_3];",
"}",
"g_free(i8259);",
"if (pcmc->pci_enabled) {",
"ioapic_init_gsi(gsi_state, \"i440fx\");",
"}",
"pc_register_ferr_irq(pcms->gsi[13]);",
"pc_vga_init(isa_bus, pcmc->pci_enabled ? pci_bus : NULL);",
"assert(pcms->vmport != ON_OFF_AUTO__MAX);",
"if (pcms->vmport == ON_OFF_AUTO_AUTO) {",
"pcms->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON;",
"}",
"pc_basic_device_init(isa_bus, pcms->gsi, &rtc_state, true,\n(pcms->vmport != ON_OFF_AUTO_ON), pcms->pit, 0x4);",
"pc_nic_init(isa_bus, pci_bus);",
"ide_drive_get(hd, ARRAY_SIZE(hd));",
"if (pcmc->pci_enabled) {",
"PCIDevice *dev;",
"if (xen_enabled()) {",
"dev = pci_piix3_xen_ide_init(pci_bus, hd, VAR_4 + 1);",
"} else {",
"dev = pci_piix3_ide_init(pci_bus, hd, VAR_4 + 1);",
"}",
"idebus[0] = qdev_get_child_bus(&dev->qdev, \"ide.0\");",
"idebus[1] = qdev_get_child_bus(&dev->qdev, \"ide.1\");",
"} else {",
"for(VAR_3 = 0; VAR_3 < MAX_IDE_BUS; VAR_3++) {",
"ISADevice *dev;",
"char busname[] = \"ide.0\";",
"dev = isa_ide_init(isa_bus, ide_iobase[VAR_3], ide_iobase2[VAR_3],\nide_irq[VAR_3],\nhd[MAX_IDE_DEVS * VAR_3], hd[MAX_IDE_DEVS * VAR_3 + 1]);",
"busname[4] = '0' + VAR_3;",
"idebus[VAR_3] = qdev_get_child_bus(DEVICE(dev), busname);",
"}",
"}",
"pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state);",
"if (pcmc->pci_enabled && machine_usb(VAR_0)) {",
"pci_create_simple(pci_bus, VAR_4 + 2, \"piix3-usb-uhci\");",
"}",
"if (pcmc->pci_enabled && acpi_enabled) {",
"DeviceState *piix4_pm;",
"I2CBus *smbus;",
"smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0);",
"smbus = piix4_pm_init(pci_bus, VAR_4 + 3, 0xb100,\npcms->gsi[9], smi_irq,\npc_machine_is_smm_enabled(pcms),\n&piix4_pm);",
"smbus_eeprom_init(smbus, 8, NULL, 0);",
"object_property_add_link(OBJECT(VAR_0), PC_MACHINE_ACPI_DEVICE_PROP,\nTYPE_HOTPLUG_HANDLER,\n(Object **)&pcms->acpi_dev,\nobject_property_allow_set_link,\nOBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort);",
"object_property_set_link(OBJECT(VAR_0), OBJECT(piix4_pm),\nPC_MACHINE_ACPI_DEVICE_PROP, &error_abort);",
"}",
"if (pcmc->pci_enabled) {",
"pc_pci_device_init(pci_bus);",
"}",
"if (pcms->acpi_nvdimm_state.is_enabled) {",
"nvdimm_init_acpi_state(&pcms->acpi_nvdimm_state, system_io,\npcms->fw_cfg, OBJECT(pcms));",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135,
137
],
[
139,
141
],
[
143
],
[
145
],
[
147
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169
],
[
173
],
[
175
],
[
177
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
199
],
[
203
],
[
205
],
[
209,
211,
213,
215
],
[
217
],
[
223
],
[
225,
227
],
[
229
],
[
233
],
[
235
],
[
239
],
[
241
],
[
243
],
[
245,
247
],
[
249
],
[
251
],
[
253
],
[
257
],
[
259,
261,
263,
265,
267,
269,
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281,
283
],
[
285
],
[
287
],
[
289
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
325
],
[
329
],
[
333
],
[
335
],
[
337
],
[
339
],
[
345,
347
],
[
351
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383,
385,
387
],
[
397
],
[
399
],
[
401
],
[
403
],
[
407
],
[
411
],
[
413
],
[
415
],
[
419
],
[
421
],
[
423
],
[
427
],
[
431,
433,
435,
437
],
[
439
],
[
443,
445,
447,
449,
451
],
[
453,
455
],
[
457
],
[
461
],
[
463
],
[
465
],
[
469
],
[
471,
473
],
[
475
],
[
477
]
] |
4,543 | int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end,
const uint8_t *name, uint8_t *dst, int dst_size)
{
int namelen = strlen(name);
int len;
while (*data != AMF_DATA_TYPE_OBJECT && data < data_end) {
len = ff_amf_tag_size(data, data_end);
if (len < 0)
len = data_end - data;
data += len;
}
if (data_end - data < 3)
return -1;
data++;
for (;;) {
int size = bytestream_get_be16(&data);
if (!size)
break;
if (size < 0 || size >= data_end - data)
return -1;
data += size;
if (size == namelen && !memcmp(data-size, name, namelen)) {
switch (*data++) {
case AMF_DATA_TYPE_NUMBER:
snprintf(dst, dst_size, "%g", av_int2double(AV_RB64(data)));
break;
case AMF_DATA_TYPE_BOOL:
snprintf(dst, dst_size, "%s", *data ? "true" : "false");
break;
case AMF_DATA_TYPE_STRING:
len = bytestream_get_be16(&data);
av_strlcpy(dst, data, FFMIN(len+1, dst_size));
break;
default:
return -1;
}
return 0;
}
len = ff_amf_tag_size(data, data_end);
if (len < 0 || len >= data_end - data)
return -1;
data += len;
}
return -1;
}
| false | FFmpeg | ffcc82219cef0928bed2d558b19ef6ea35634130 | int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end,
const uint8_t *name, uint8_t *dst, int dst_size)
{
int namelen = strlen(name);
int len;
while (*data != AMF_DATA_TYPE_OBJECT && data < data_end) {
len = ff_amf_tag_size(data, data_end);
if (len < 0)
len = data_end - data;
data += len;
}
if (data_end - data < 3)
return -1;
data++;
for (;;) {
int size = bytestream_get_be16(&data);
if (!size)
break;
if (size < 0 || size >= data_end - data)
return -1;
data += size;
if (size == namelen && !memcmp(data-size, name, namelen)) {
switch (*data++) {
case AMF_DATA_TYPE_NUMBER:
snprintf(dst, dst_size, "%g", av_int2double(AV_RB64(data)));
break;
case AMF_DATA_TYPE_BOOL:
snprintf(dst, dst_size, "%s", *data ? "true" : "false");
break;
case AMF_DATA_TYPE_STRING:
len = bytestream_get_be16(&data);
av_strlcpy(dst, data, FFMIN(len+1, dst_size));
break;
default:
return -1;
}
return 0;
}
len = ff_amf_tag_size(data, data_end);
if (len < 0 || len >= data_end - data)
return -1;
data += len;
}
return -1;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(const uint8_t *VAR_0, const uint8_t *VAR_1,
const uint8_t *VAR_2, uint8_t *VAR_3, int VAR_4)
{
int VAR_5 = strlen(VAR_2);
int VAR_6;
while (*VAR_0 != AMF_DATA_TYPE_OBJECT && VAR_0 < VAR_1) {
VAR_6 = ff_amf_tag_size(VAR_0, VAR_1);
if (VAR_6 < 0)
VAR_6 = VAR_1 - VAR_0;
VAR_0 += VAR_6;
}
if (VAR_1 - VAR_0 < 3)
return -1;
VAR_0++;
for (;;) {
int VAR_7 = bytestream_get_be16(&VAR_0);
if (!VAR_7)
break;
if (VAR_7 < 0 || VAR_7 >= VAR_1 - VAR_0)
return -1;
VAR_0 += VAR_7;
if (VAR_7 == VAR_5 && !memcmp(VAR_0-VAR_7, VAR_2, VAR_5)) {
switch (*VAR_0++) {
case AMF_DATA_TYPE_NUMBER:
snprintf(VAR_3, VAR_4, "%g", av_int2double(AV_RB64(VAR_0)));
break;
case AMF_DATA_TYPE_BOOL:
snprintf(VAR_3, VAR_4, "%s", *VAR_0 ? "true" : "false");
break;
case AMF_DATA_TYPE_STRING:
VAR_6 = bytestream_get_be16(&VAR_0);
av_strlcpy(VAR_3, VAR_0, FFMIN(VAR_6+1, VAR_4));
break;
default:
return -1;
}
return 0;
}
VAR_6 = ff_amf_tag_size(VAR_0, VAR_1);
if (VAR_6 < 0 || VAR_6 >= VAR_1 - VAR_0)
return -1;
VAR_0 += VAR_6;
}
return -1;
}
| [
"int FUNC_0(const uint8_t *VAR_0, const uint8_t *VAR_1,\nconst uint8_t *VAR_2, uint8_t *VAR_3, int VAR_4)\n{",
"int VAR_5 = strlen(VAR_2);",
"int VAR_6;",
"while (*VAR_0 != AMF_DATA_TYPE_OBJECT && VAR_0 < VAR_1) {",
"VAR_6 = ff_amf_tag_size(VAR_0, VAR_1);",
"if (VAR_6 < 0)\nVAR_6 = VAR_1 - VAR_0;",
"VAR_0 += VAR_6;",
"}",
"if (VAR_1 - VAR_0 < 3)\nreturn -1;",
"VAR_0++;",
"for (;;) {",
"int VAR_7 = bytestream_get_be16(&VAR_0);",
"if (!VAR_7)\nbreak;",
"if (VAR_7 < 0 || VAR_7 >= VAR_1 - VAR_0)\nreturn -1;",
"VAR_0 += VAR_7;",
"if (VAR_7 == VAR_5 && !memcmp(VAR_0-VAR_7, VAR_2, VAR_5)) {",
"switch (*VAR_0++) {",
"case AMF_DATA_TYPE_NUMBER:\nsnprintf(VAR_3, VAR_4, \"%g\", av_int2double(AV_RB64(VAR_0)));",
"break;",
"case AMF_DATA_TYPE_BOOL:\nsnprintf(VAR_3, VAR_4, \"%s\", *VAR_0 ? \"true\" : \"false\");",
"break;",
"case AMF_DATA_TYPE_STRING:\nVAR_6 = bytestream_get_be16(&VAR_0);",
"av_strlcpy(VAR_3, VAR_0, FFMIN(VAR_6+1, VAR_4));",
"break;",
"default:\nreturn -1;",
"}",
"return 0;",
"}",
"VAR_6 = ff_amf_tag_size(VAR_0, VAR_1);",
"if (VAR_6 < 0 || VAR_6 >= VAR_1 - VAR_0)\nreturn -1;",
"VAR_0 += VAR_6;",
"}",
"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
] | [
[
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
]
] |
4,544 | static int raw_open(BlockDriverState *bs, const char *filename, int flags)
{
BDRVRawState *s = bs->opaque;
int access_flags, create_flags;
DWORD overlapped;
s->type = FTYPE_FILE;
if ((flags & BDRV_O_ACCESS) == O_RDWR) {
access_flags = GENERIC_READ | GENERIC_WRITE;
} else {
access_flags = GENERIC_READ;
}
if (flags & BDRV_O_CREAT) {
create_flags = CREATE_ALWAYS;
} else {
create_flags = OPEN_EXISTING;
}
#ifdef QEMU_TOOL
overlapped = FILE_ATTRIBUTE_NORMAL;
#else
overlapped = FILE_FLAG_OVERLAPPED;
#endif
s->hfile = CreateFile(filename, access_flags,
FILE_SHARE_READ, NULL,
create_flags, overlapped, NULL);
if (s->hfile == INVALID_HANDLE_VALUE)
return -1;
return 0;
}
| false | qemu | 54421cb17bc744bad15f2b1adb4adefdaea83c10 | static int raw_open(BlockDriverState *bs, const char *filename, int flags)
{
BDRVRawState *s = bs->opaque;
int access_flags, create_flags;
DWORD overlapped;
s->type = FTYPE_FILE;
if ((flags & BDRV_O_ACCESS) == O_RDWR) {
access_flags = GENERIC_READ | GENERIC_WRITE;
} else {
access_flags = GENERIC_READ;
}
if (flags & BDRV_O_CREAT) {
create_flags = CREATE_ALWAYS;
} else {
create_flags = OPEN_EXISTING;
}
#ifdef QEMU_TOOL
overlapped = FILE_ATTRIBUTE_NORMAL;
#else
overlapped = FILE_FLAG_OVERLAPPED;
#endif
s->hfile = CreateFile(filename, access_flags,
FILE_SHARE_READ, NULL,
create_flags, overlapped, NULL);
if (s->hfile == INVALID_HANDLE_VALUE)
return -1;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, const char *VAR_1, int VAR_2)
{
BDRVRawState *s = VAR_0->opaque;
int VAR_3, VAR_4;
DWORD overlapped;
s->type = FTYPE_FILE;
if ((VAR_2 & BDRV_O_ACCESS) == O_RDWR) {
VAR_3 = GENERIC_READ | GENERIC_WRITE;
} else {
VAR_3 = GENERIC_READ;
}
if (VAR_2 & BDRV_O_CREAT) {
VAR_4 = CREATE_ALWAYS;
} else {
VAR_4 = OPEN_EXISTING;
}
#ifdef QEMU_TOOL
overlapped = FILE_ATTRIBUTE_NORMAL;
#else
overlapped = FILE_FLAG_OVERLAPPED;
#endif
s->hfile = CreateFile(VAR_1, VAR_3,
FILE_SHARE_READ, NULL,
VAR_4, overlapped, NULL);
if (s->hfile == INVALID_HANDLE_VALUE)
return -1;
return 0;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, const char *VAR_1, int VAR_2)\n{",
"BDRVRawState *s = VAR_0->opaque;",
"int VAR_3, VAR_4;",
"DWORD overlapped;",
"s->type = FTYPE_FILE;",
"if ((VAR_2 & BDRV_O_ACCESS) == O_RDWR) {",
"VAR_3 = GENERIC_READ | GENERIC_WRITE;",
"} else {",
"VAR_3 = GENERIC_READ;",
"}",
"if (VAR_2 & BDRV_O_CREAT) {",
"VAR_4 = CREATE_ALWAYS;",
"} else {",
"VAR_4 = OPEN_EXISTING;",
"}",
"#ifdef QEMU_TOOL\noverlapped = FILE_ATTRIBUTE_NORMAL;",
"#else\noverlapped = FILE_FLAG_OVERLAPPED;",
"#endif\ns->hfile = CreateFile(VAR_1, VAR_3,\nFILE_SHARE_READ, NULL,\nVAR_4, overlapped, NULL);",
"if (s->hfile == INVALID_HANDLE_VALUE)\nreturn -1;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41,
43
],
[
45,
47,
49,
51
],
[
53,
55
],
[
57
],
[
59
]
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.