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
|
---|---|---|---|---|---|---|---|---|---|---|
3,165 | static void fft_ref_init(int nbits, int inverse)
{
int i, n = 1 << nbits;
exptab = av_malloc((n / 2) * sizeof(*exptab));
for (i = 0; i < (n/2); i++) {
double alpha = 2 * M_PI * (float)i / (float)n;
double c1 = cos(alpha), s1 = sin(alpha);
if (!inverse)
s1 = -s1;
exptab[i].re = c1;
exptab[i].im = s1;
}
}
| false | FFmpeg | c3c96deb5f8cbbdb700ba97920ceedddacb5dcb9 | static void fft_ref_init(int nbits, int inverse)
{
int i, n = 1 << nbits;
exptab = av_malloc((n / 2) * sizeof(*exptab));
for (i = 0; i < (n/2); i++) {
double alpha = 2 * M_PI * (float)i / (float)n;
double c1 = cos(alpha), s1 = sin(alpha);
if (!inverse)
s1 = -s1;
exptab[i].re = c1;
exptab[i].im = s1;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(int VAR_0, int VAR_1)
{
int VAR_2, VAR_3 = 1 << VAR_0;
exptab = av_malloc((VAR_3 / 2) * sizeof(*exptab));
for (VAR_2 = 0; VAR_2 < (VAR_3/2); VAR_2++) {
double VAR_4 = 2 * M_PI * (float)VAR_2 / (float)VAR_3;
double VAR_5 = cos(VAR_4), VAR_6 = sin(VAR_4);
if (!VAR_1)
VAR_6 = -VAR_6;
exptab[VAR_2].re = VAR_5;
exptab[VAR_2].im = VAR_6;
}
}
| [
"static void FUNC_0(int VAR_0, int VAR_1)\n{",
"int VAR_2, VAR_3 = 1 << VAR_0;",
"exptab = av_malloc((VAR_3 / 2) * sizeof(*exptab));",
"for (VAR_2 = 0; VAR_2 < (VAR_3/2); VAR_2++) {",
"double VAR_4 = 2 * M_PI * (float)VAR_2 / (float)VAR_3;",
"double VAR_5 = cos(VAR_4), VAR_6 = sin(VAR_4);",
"if (!VAR_1)\nVAR_6 = -VAR_6;",
"exptab[VAR_2].re = VAR_5;",
"exptab[VAR_2].im = VAR_6;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
3,166 | inline static int push_frame(AVFilterLink *outlink)
{
AVFilterContext *ctx = outlink->src;
AVFilterLink *inlink = ctx->inputs[0];
ShowWavesContext *showwaves = outlink->src->priv;
int nb_channels = inlink->channels;
int ret, i;
if ((ret = ff_filter_frame(outlink, showwaves->outpicref)) >= 0)
showwaves->req_fullfilled = 1;
showwaves->outpicref = NULL;
showwaves->buf_idx = 0;
for (i = 0; i < nb_channels; i++)
showwaves->buf_idy[i] = 0;
return ret;
}
| false | FFmpeg | 8a2e2fc34aaeb0c092a9fd08d18bd5af7d240f1d | inline static int push_frame(AVFilterLink *outlink)
{
AVFilterContext *ctx = outlink->src;
AVFilterLink *inlink = ctx->inputs[0];
ShowWavesContext *showwaves = outlink->src->priv;
int nb_channels = inlink->channels;
int ret, i;
if ((ret = ff_filter_frame(outlink, showwaves->outpicref)) >= 0)
showwaves->req_fullfilled = 1;
showwaves->outpicref = NULL;
showwaves->buf_idx = 0;
for (i = 0; i < nb_channels; i++)
showwaves->buf_idy[i] = 0;
return ret;
}
| {
"code": [],
"line_no": []
} | inline static int FUNC_0(AVFilterLink *VAR_0)
{
AVFilterContext *ctx = VAR_0->src;
AVFilterLink *inlink = ctx->inputs[0];
ShowWavesContext *showwaves = VAR_0->src->priv;
int VAR_1 = inlink->channels;
int VAR_2, VAR_3;
if ((VAR_2 = ff_filter_frame(VAR_0, showwaves->outpicref)) >= 0)
showwaves->req_fullfilled = 1;
showwaves->outpicref = NULL;
showwaves->buf_idx = 0;
for (VAR_3 = 0; VAR_3 < VAR_1; VAR_3++)
showwaves->buf_idy[VAR_3] = 0;
return VAR_2;
}
| [
"inline static int FUNC_0(AVFilterLink *VAR_0)\n{",
"AVFilterContext *ctx = VAR_0->src;",
"AVFilterLink *inlink = ctx->inputs[0];",
"ShowWavesContext *showwaves = VAR_0->src->priv;",
"int VAR_1 = inlink->channels;",
"int VAR_2, VAR_3;",
"if ((VAR_2 = ff_filter_frame(VAR_0, showwaves->outpicref)) >= 0)\nshowwaves->req_fullfilled = 1;",
"showwaves->outpicref = NULL;",
"showwaves->buf_idx = 0;",
"for (VAR_3 = 0; VAR_3 < VAR_1; VAR_3++)",
"showwaves->buf_idy[VAR_3] = 0;",
"return VAR_2;",
"}"
] | [
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
]
] |
3,167 | uint64_t helper_tick_get_count(void *opaque)
{
#if !defined(CONFIG_USER_ONLY)
return cpu_tick_get_count(opaque);
#else
return 0;
#endif
}
| true | qemu | c9a464420d7eb67dace1f630554245360b4c7c5b | uint64_t helper_tick_get_count(void *opaque)
{
#if !defined(CONFIG_USER_ONLY)
return cpu_tick_get_count(opaque);
#else
return 0;
#endif
}
| {
"code": [
"uint64_t helper_tick_get_count(void *opaque)",
" return cpu_tick_get_count(opaque);"
],
"line_no": [
1,
7
]
} | uint64_t FUNC_0(void *opaque)
{
#if !defined(CONFIG_USER_ONLY)
return cpu_tick_get_count(opaque);
#else
return 0;
#endif
}
| [
"uint64_t FUNC_0(void *opaque)\n{",
"#if !defined(CONFIG_USER_ONLY)\nreturn cpu_tick_get_count(opaque);",
"#else\nreturn 0;",
"#endif\n}"
] | [
1,
1,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9,
11
],
[
13,
15
]
] |
3,168 | uint64_t helper_mulqv (uint64_t op1, uint64_t op2)
{
uint64_t tl, th;
muls64(&tl, &th, op1, op2);
/* If th != 0 && th != -1, then we had an overflow */
if (unlikely((th + 1) > 1)) {
arith_excp(env, GETPC(), EXC_M_IOV, 0);
}
return tl;
}
| true | qemu | 2958620f67dcfd11476e62b4ca704dae0b978ea3 | uint64_t helper_mulqv (uint64_t op1, uint64_t op2)
{
uint64_t tl, th;
muls64(&tl, &th, op1, op2);
if (unlikely((th + 1) > 1)) {
arith_excp(env, GETPC(), EXC_M_IOV, 0);
}
return tl;
}
| {
"code": [
" arith_excp(env, GETPC(), EXC_M_IOV, 0);",
" arith_excp(env, GETPC(), EXC_M_IOV, 0);",
" arith_excp(env, GETPC(), EXC_M_IOV, 0);",
" arith_excp(env, GETPC(), EXC_M_IOV, 0);",
" arith_excp(env, GETPC(), EXC_M_IOV, 0);",
"uint64_t helper_mulqv (uint64_t op1, uint64_t op2)",
" uint64_t tl, th;",
" muls64(&tl, &th, op1, op2);",
" if (unlikely((th + 1) > 1)) {",
" arith_excp(env, GETPC(), EXC_M_IOV, 0);",
" return tl;"
],
"line_no": [
15,
15,
15,
15,
15,
1,
5,
9,
13,
15,
19
]
} | uint64_t FUNC_0 (uint64_t op1, uint64_t op2)
{
uint64_t tl, th;
muls64(&tl, &th, op1, op2);
if (unlikely((th + 1) > 1)) {
arith_excp(env, GETPC(), EXC_M_IOV, 0);
}
return tl;
}
| [
"uint64_t FUNC_0 (uint64_t op1, uint64_t op2)\n{",
"uint64_t tl, th;",
"muls64(&tl, &th, op1, op2);",
"if (unlikely((th + 1) > 1)) {",
"arith_excp(env, GETPC(), EXC_M_IOV, 0);",
"}",
"return tl;",
"}"
] | [
1,
1,
1,
1,
1,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
3,169 | static void dec_divu(DisasContext *dc)
{
int l1;
LOG_DIS("divu r%d, r%d, r%d\n", dc->r2, dc->r0, dc->r1);
if (!(dc->env->features & LM32_FEATURE_DIVIDE)) {
cpu_abort(dc->env, "hardware divider is not available\n");
}
l1 = gen_new_label();
tcg_gen_brcondi_tl(TCG_COND_NE, cpu_R[dc->r1], 0, l1);
tcg_gen_movi_tl(cpu_pc, dc->pc);
t_gen_raise_exception(dc, EXCP_DIVIDE_BY_ZERO);
gen_set_label(l1);
tcg_gen_divu_tl(cpu_R[dc->r2], cpu_R[dc->r0], cpu_R[dc->r1]);
}
| true | qemu | 3604a76fea6ff37738d4a8f596be38407be74a83 | static void dec_divu(DisasContext *dc)
{
int l1;
LOG_DIS("divu r%d, r%d, r%d\n", dc->r2, dc->r0, dc->r1);
if (!(dc->env->features & LM32_FEATURE_DIVIDE)) {
cpu_abort(dc->env, "hardware divider is not available\n");
}
l1 = gen_new_label();
tcg_gen_brcondi_tl(TCG_COND_NE, cpu_R[dc->r1], 0, l1);
tcg_gen_movi_tl(cpu_pc, dc->pc);
t_gen_raise_exception(dc, EXCP_DIVIDE_BY_ZERO);
gen_set_label(l1);
tcg_gen_divu_tl(cpu_R[dc->r2], cpu_R[dc->r0], cpu_R[dc->r1]);
}
| {
"code": [
" cpu_abort(dc->env, \"hardware divider is not available\\n\");",
" cpu_abort(dc->env, \"hardware divider is not available\\n\");"
],
"line_no": [
15,
15
]
} | static void FUNC_0(DisasContext *VAR_0)
{
int VAR_1;
LOG_DIS("divu r%d, r%d, r%d\n", VAR_0->r2, VAR_0->r0, VAR_0->r1);
if (!(VAR_0->env->features & LM32_FEATURE_DIVIDE)) {
cpu_abort(VAR_0->env, "hardware divider is not available\n");
}
VAR_1 = gen_new_label();
tcg_gen_brcondi_tl(TCG_COND_NE, cpu_R[VAR_0->r1], 0, VAR_1);
tcg_gen_movi_tl(cpu_pc, VAR_0->pc);
t_gen_raise_exception(VAR_0, EXCP_DIVIDE_BY_ZERO);
gen_set_label(VAR_1);
tcg_gen_divu_tl(cpu_R[VAR_0->r2], cpu_R[VAR_0->r0], cpu_R[VAR_0->r1]);
}
| [
"static void FUNC_0(DisasContext *VAR_0)\n{",
"int VAR_1;",
"LOG_DIS(\"divu r%d, r%d, r%d\\n\", VAR_0->r2, VAR_0->r0, VAR_0->r1);",
"if (!(VAR_0->env->features & LM32_FEATURE_DIVIDE)) {",
"cpu_abort(VAR_0->env, \"hardware divider is not available\\n\");",
"}",
"VAR_1 = gen_new_label();",
"tcg_gen_brcondi_tl(TCG_COND_NE, cpu_R[VAR_0->r1], 0, VAR_1);",
"tcg_gen_movi_tl(cpu_pc, VAR_0->pc);",
"t_gen_raise_exception(VAR_0, EXCP_DIVIDE_BY_ZERO);",
"gen_set_label(VAR_1);",
"tcg_gen_divu_tl(cpu_R[VAR_0->r2], cpu_R[VAR_0->r0], cpu_R[VAR_0->r1]);",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
]
] |
3,170 | static void ffmpeg_cleanup(int ret)
{
int i, j;
if (do_benchmark) {
int maxrss = getmaxrss() / 1024;
av_log(NULL, AV_LOG_INFO, "bench: maxrss=%ikB\n", maxrss);
}
for (i = 0; i < nb_filtergraphs; i++) {
FilterGraph *fg = filtergraphs[i];
avfilter_graph_free(&fg->graph);
for (j = 0; j < fg->nb_inputs; j++) {
av_freep(&fg->inputs[j]->name);
av_freep(&fg->inputs[j]);
}
av_freep(&fg->inputs);
for (j = 0; j < fg->nb_outputs; j++) {
av_freep(&fg->outputs[j]->name);
av_freep(&fg->outputs[j]);
}
av_freep(&fg->outputs);
av_freep(&fg->graph_desc);
av_freep(&filtergraphs[i]);
}
av_freep(&filtergraphs);
av_freep(&subtitle_out);
/* close files */
for (i = 0; i < nb_output_files; i++) {
OutputFile *of = output_files[i];
AVFormatContext *s;
if (!of)
continue;
s = of->ctx;
if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE))
avio_closep(&s->pb);
avformat_free_context(s);
av_dict_free(&of->opts);
av_freep(&output_files[i]);
}
for (i = 0; i < nb_output_streams; i++) {
OutputStream *ost = output_streams[i];
AVBitStreamFilterContext *bsfc;
if (!ost)
continue;
bsfc = ost->bitstream_filters;
while (bsfc) {
AVBitStreamFilterContext *next = bsfc->next;
av_bitstream_filter_close(bsfc);
bsfc = next;
}
ost->bitstream_filters = NULL;
av_frame_free(&ost->filtered_frame);
av_frame_free(&ost->last_frame);
av_parser_close(ost->parser);
av_freep(&ost->forced_keyframes);
av_expr_free(ost->forced_keyframes_pexpr);
av_freep(&ost->avfilter);
av_freep(&ost->logfile_prefix);
av_freep(&ost->audio_channels_map);
ost->audio_channels_mapped = 0;
avcodec_free_context(&ost->enc_ctx);
av_freep(&output_streams[i]);
}
#if HAVE_PTHREADS
free_input_threads();
#endif
for (i = 0; i < nb_input_files; i++) {
avformat_close_input(&input_files[i]->ctx);
av_freep(&input_files[i]);
}
for (i = 0; i < nb_input_streams; i++) {
InputStream *ist = input_streams[i];
av_frame_free(&ist->decoded_frame);
av_frame_free(&ist->filter_frame);
av_dict_free(&ist->decoder_opts);
avsubtitle_free(&ist->prev_sub.subtitle);
av_frame_free(&ist->sub2video.frame);
av_freep(&ist->filters);
av_freep(&ist->hwaccel_device);
avcodec_free_context(&ist->dec_ctx);
av_freep(&input_streams[i]);
}
if (vstats_file) {
if (fclose(vstats_file))
av_log(NULL, AV_LOG_ERROR,
"Error closing vstats file, loss of information possible: %s\n",
av_err2str(AVERROR(errno)));
}
av_freep(&vstats_filename);
av_freep(&input_streams);
av_freep(&input_files);
av_freep(&output_streams);
av_freep(&output_files);
uninit_opts();
avformat_network_deinit();
if (received_sigterm) {
av_log(NULL, AV_LOG_INFO, "Exiting normally, received signal %d.\n",
(int) received_sigterm);
} else if (ret && transcode_init_done) {
av_log(NULL, AV_LOG_INFO, "Conversion failed!\n");
}
term_exit();
ffmpeg_exited = 1;
} | true | FFmpeg | 7a0361b06f0afbdcface8cab17751ed2c7e81769 | static void ffmpeg_cleanup(int ret)
{
int i, j;
if (do_benchmark) {
int maxrss = getmaxrss() / 1024;
av_log(NULL, AV_LOG_INFO, "bench: maxrss=%ikB\n", maxrss);
}
for (i = 0; i < nb_filtergraphs; i++) {
FilterGraph *fg = filtergraphs[i];
avfilter_graph_free(&fg->graph);
for (j = 0; j < fg->nb_inputs; j++) {
av_freep(&fg->inputs[j]->name);
av_freep(&fg->inputs[j]);
}
av_freep(&fg->inputs);
for (j = 0; j < fg->nb_outputs; j++) {
av_freep(&fg->outputs[j]->name);
av_freep(&fg->outputs[j]);
}
av_freep(&fg->outputs);
av_freep(&fg->graph_desc);
av_freep(&filtergraphs[i]);
}
av_freep(&filtergraphs);
av_freep(&subtitle_out);
for (i = 0; i < nb_output_files; i++) {
OutputFile *of = output_files[i];
AVFormatContext *s;
if (!of)
continue;
s = of->ctx;
if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE))
avio_closep(&s->pb);
avformat_free_context(s);
av_dict_free(&of->opts);
av_freep(&output_files[i]);
}
for (i = 0; i < nb_output_streams; i++) {
OutputStream *ost = output_streams[i];
AVBitStreamFilterContext *bsfc;
if (!ost)
continue;
bsfc = ost->bitstream_filters;
while (bsfc) {
AVBitStreamFilterContext *next = bsfc->next;
av_bitstream_filter_close(bsfc);
bsfc = next;
}
ost->bitstream_filters = NULL;
av_frame_free(&ost->filtered_frame);
av_frame_free(&ost->last_frame);
av_parser_close(ost->parser);
av_freep(&ost->forced_keyframes);
av_expr_free(ost->forced_keyframes_pexpr);
av_freep(&ost->avfilter);
av_freep(&ost->logfile_prefix);
av_freep(&ost->audio_channels_map);
ost->audio_channels_mapped = 0;
avcodec_free_context(&ost->enc_ctx);
av_freep(&output_streams[i]);
}
#if HAVE_PTHREADS
free_input_threads();
#endif
for (i = 0; i < nb_input_files; i++) {
avformat_close_input(&input_files[i]->ctx);
av_freep(&input_files[i]);
}
for (i = 0; i < nb_input_streams; i++) {
InputStream *ist = input_streams[i];
av_frame_free(&ist->decoded_frame);
av_frame_free(&ist->filter_frame);
av_dict_free(&ist->decoder_opts);
avsubtitle_free(&ist->prev_sub.subtitle);
av_frame_free(&ist->sub2video.frame);
av_freep(&ist->filters);
av_freep(&ist->hwaccel_device);
avcodec_free_context(&ist->dec_ctx);
av_freep(&input_streams[i]);
}
if (vstats_file) {
if (fclose(vstats_file))
av_log(NULL, AV_LOG_ERROR,
"Error closing vstats file, loss of information possible: %s\n",
av_err2str(AVERROR(errno)));
}
av_freep(&vstats_filename);
av_freep(&input_streams);
av_freep(&input_files);
av_freep(&output_streams);
av_freep(&output_files);
uninit_opts();
avformat_network_deinit();
if (received_sigterm) {
av_log(NULL, AV_LOG_INFO, "Exiting normally, received signal %d.\n",
(int) received_sigterm);
} else if (ret && transcode_init_done) {
av_log(NULL, AV_LOG_INFO, "Conversion failed!\n");
}
term_exit();
ffmpeg_exited = 1;
} | {
"code": [],
"line_no": []
} | static void FUNC_0(int VAR_0)
{
int VAR_1, VAR_2;
if (do_benchmark) {
int VAR_3 = getmaxrss() / 1024;
av_log(NULL, AV_LOG_INFO, "bench: VAR_3=%ikB\n", VAR_3);
}
for (VAR_1 = 0; VAR_1 < nb_filtergraphs; VAR_1++) {
FilterGraph *fg = filtergraphs[VAR_1];
avfilter_graph_free(&fg->graph);
for (VAR_2 = 0; VAR_2 < fg->nb_inputs; VAR_2++) {
av_freep(&fg->inputs[VAR_2]->name);
av_freep(&fg->inputs[VAR_2]);
}
av_freep(&fg->inputs);
for (VAR_2 = 0; VAR_2 < fg->nb_outputs; VAR_2++) {
av_freep(&fg->outputs[VAR_2]->name);
av_freep(&fg->outputs[VAR_2]);
}
av_freep(&fg->outputs);
av_freep(&fg->graph_desc);
av_freep(&filtergraphs[VAR_1]);
}
av_freep(&filtergraphs);
av_freep(&subtitle_out);
for (VAR_1 = 0; VAR_1 < nb_output_files; VAR_1++) {
OutputFile *of = output_files[VAR_1];
AVFormatContext *s;
if (!of)
continue;
s = of->ctx;
if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE))
avio_closep(&s->pb);
avformat_free_context(s);
av_dict_free(&of->opts);
av_freep(&output_files[VAR_1]);
}
for (VAR_1 = 0; VAR_1 < nb_output_streams; VAR_1++) {
OutputStream *ost = output_streams[VAR_1];
AVBitStreamFilterContext *bsfc;
if (!ost)
continue;
bsfc = ost->bitstream_filters;
while (bsfc) {
AVBitStreamFilterContext *next = bsfc->next;
av_bitstream_filter_close(bsfc);
bsfc = next;
}
ost->bitstream_filters = NULL;
av_frame_free(&ost->filtered_frame);
av_frame_free(&ost->last_frame);
av_parser_close(ost->parser);
av_freep(&ost->forced_keyframes);
av_expr_free(ost->forced_keyframes_pexpr);
av_freep(&ost->avfilter);
av_freep(&ost->logfile_prefix);
av_freep(&ost->audio_channels_map);
ost->audio_channels_mapped = 0;
avcodec_free_context(&ost->enc_ctx);
av_freep(&output_streams[VAR_1]);
}
#if HAVE_PTHREADS
free_input_threads();
#endif
for (VAR_1 = 0; VAR_1 < nb_input_files; VAR_1++) {
avformat_close_input(&input_files[VAR_1]->ctx);
av_freep(&input_files[VAR_1]);
}
for (VAR_1 = 0; VAR_1 < nb_input_streams; VAR_1++) {
InputStream *ist = input_streams[VAR_1];
av_frame_free(&ist->decoded_frame);
av_frame_free(&ist->filter_frame);
av_dict_free(&ist->decoder_opts);
avsubtitle_free(&ist->prev_sub.subtitle);
av_frame_free(&ist->sub2video.frame);
av_freep(&ist->filters);
av_freep(&ist->hwaccel_device);
avcodec_free_context(&ist->dec_ctx);
av_freep(&input_streams[VAR_1]);
}
if (vstats_file) {
if (fclose(vstats_file))
av_log(NULL, AV_LOG_ERROR,
"Error closing vstats file, loss of information possible: %s\n",
av_err2str(AVERROR(errno)));
}
av_freep(&vstats_filename);
av_freep(&input_streams);
av_freep(&input_files);
av_freep(&output_streams);
av_freep(&output_files);
uninit_opts();
avformat_network_deinit();
if (received_sigterm) {
av_log(NULL, AV_LOG_INFO, "Exiting normally, received signal %d.\n",
(int) received_sigterm);
} else if (VAR_0 && transcode_init_done) {
av_log(NULL, AV_LOG_INFO, "Conversion failed!\n");
}
term_exit();
ffmpeg_exited = 1;
} | [
"static void FUNC_0(int VAR_0)\n{",
"int VAR_1, VAR_2;",
"if (do_benchmark) {",
"int VAR_3 = getmaxrss() / 1024;",
"av_log(NULL, AV_LOG_INFO, \"bench: VAR_3=%ikB\\n\", VAR_3);",
"}",
"for (VAR_1 = 0; VAR_1 < nb_filtergraphs; VAR_1++) {",
"FilterGraph *fg = filtergraphs[VAR_1];",
"avfilter_graph_free(&fg->graph);",
"for (VAR_2 = 0; VAR_2 < fg->nb_inputs; VAR_2++) {",
"av_freep(&fg->inputs[VAR_2]->name);",
"av_freep(&fg->inputs[VAR_2]);",
"}",
"av_freep(&fg->inputs);",
"for (VAR_2 = 0; VAR_2 < fg->nb_outputs; VAR_2++) {",
"av_freep(&fg->outputs[VAR_2]->name);",
"av_freep(&fg->outputs[VAR_2]);",
"}",
"av_freep(&fg->outputs);",
"av_freep(&fg->graph_desc);",
"av_freep(&filtergraphs[VAR_1]);",
"}",
"av_freep(&filtergraphs);",
"av_freep(&subtitle_out);",
"for (VAR_1 = 0; VAR_1 < nb_output_files; VAR_1++) {",
"OutputFile *of = output_files[VAR_1];",
"AVFormatContext *s;",
"if (!of)\ncontinue;",
"s = of->ctx;",
"if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE))\navio_closep(&s->pb);",
"avformat_free_context(s);",
"av_dict_free(&of->opts);",
"av_freep(&output_files[VAR_1]);",
"}",
"for (VAR_1 = 0; VAR_1 < nb_output_streams; VAR_1++) {",
"OutputStream *ost = output_streams[VAR_1];",
"AVBitStreamFilterContext *bsfc;",
"if (!ost)\ncontinue;",
"bsfc = ost->bitstream_filters;",
"while (bsfc) {",
"AVBitStreamFilterContext *next = bsfc->next;",
"av_bitstream_filter_close(bsfc);",
"bsfc = next;",
"}",
"ost->bitstream_filters = NULL;",
"av_frame_free(&ost->filtered_frame);",
"av_frame_free(&ost->last_frame);",
"av_parser_close(ost->parser);",
"av_freep(&ost->forced_keyframes);",
"av_expr_free(ost->forced_keyframes_pexpr);",
"av_freep(&ost->avfilter);",
"av_freep(&ost->logfile_prefix);",
"av_freep(&ost->audio_channels_map);",
"ost->audio_channels_mapped = 0;",
"avcodec_free_context(&ost->enc_ctx);",
"av_freep(&output_streams[VAR_1]);",
"}",
"#if HAVE_PTHREADS\nfree_input_threads();",
"#endif\nfor (VAR_1 = 0; VAR_1 < nb_input_files; VAR_1++) {",
"avformat_close_input(&input_files[VAR_1]->ctx);",
"av_freep(&input_files[VAR_1]);",
"}",
"for (VAR_1 = 0; VAR_1 < nb_input_streams; VAR_1++) {",
"InputStream *ist = input_streams[VAR_1];",
"av_frame_free(&ist->decoded_frame);",
"av_frame_free(&ist->filter_frame);",
"av_dict_free(&ist->decoder_opts);",
"avsubtitle_free(&ist->prev_sub.subtitle);",
"av_frame_free(&ist->sub2video.frame);",
"av_freep(&ist->filters);",
"av_freep(&ist->hwaccel_device);",
"avcodec_free_context(&ist->dec_ctx);",
"av_freep(&input_streams[VAR_1]);",
"}",
"if (vstats_file) {",
"if (fclose(vstats_file))\nav_log(NULL, AV_LOG_ERROR,\n\"Error closing vstats file, loss of information possible: %s\\n\",\nav_err2str(AVERROR(errno)));",
"}",
"av_freep(&vstats_filename);",
"av_freep(&input_streams);",
"av_freep(&input_files);",
"av_freep(&output_streams);",
"av_freep(&output_files);",
"uninit_opts();",
"avformat_network_deinit();",
"if (received_sigterm) {",
"av_log(NULL, AV_LOG_INFO, \"Exiting normally, received signal %d.\\n\",\n(int) received_sigterm);",
"} else if (VAR_0 && transcode_init_done) {",
"av_log(NULL, AV_LOG_INFO, \"Conversion failed!\\n\");",
"}",
"term_exit();",
"ffmpeg_exited = 1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20
],
[
21
],
[
22
],
[
23
],
[
24
],
[
25
],
[
27
],
[
28
],
[
29
],
[
30,
31
],
[
32
],
[
33,
34
],
[
35
],
[
36
],
[
37
],
[
38
],
[
39
],
[
40
],
[
41
],
[
42,
43
],
[
44
],
[
45
],
[
46
],
[
47
],
[
48
],
[
49
],
[
50
],
[
51
],
[
52
],
[
53
],
[
54
],
[
55
],
[
56
],
[
57
],
[
58
],
[
59
],
[
60
],
[
61
],
[
62
],
[
63,
64
],
[
65,
66
],
[
67
],
[
68
],
[
69
],
[
70
],
[
71
],
[
72
],
[
73
],
[
74
],
[
75
],
[
76
],
[
77
],
[
78
],
[
79
],
[
80
],
[
81
],
[
82
],
[
83,
84,
85,
86
],
[
87
],
[
88
],
[
89
],
[
90
],
[
91
],
[
92
],
[
93
],
[
94
],
[
95
],
[
96,
97
],
[
98
],
[
99
],
[
100
],
[
101
],
[
102
],
[
103
]
] |
3,171 | void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
const uint8_t *src_data[4], const int src_linesizes[4],
enum PixelFormat pix_fmt, int width, int height)
{
const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
if (desc->flags & PIX_FMT_HWACCEL)
return;
if (desc->flags & PIX_FMT_PAL) {
av_image_copy_plane(dst_data[0], dst_linesizes[0],
src_data[0], src_linesizes[0],
width, height);
/* copy the palette */
memcpy(dst_data[1], src_data[1], 4*256);
} else {
int i, planes_nb = 0;
for (i = 0; i < desc->nb_components; i++)
planes_nb = FFMAX(planes_nb, desc->comp[i].plane + 1);
for (i = 0; i < planes_nb; i++) {
int h = height;
int bwidth = av_image_get_linesize(pix_fmt, width, i);
if (i == 1 || i == 2) {
h= -((-height)>>desc->log2_chroma_h);
}
av_image_copy_plane(dst_data[i], dst_linesizes[i],
src_data[i], src_linesizes[i],
bwidth, h);
}
}
}
| true | FFmpeg | 38d553322891c8e47182f05199d19888422167dc | void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
const uint8_t *src_data[4], const int src_linesizes[4],
enum PixelFormat pix_fmt, int width, int height)
{
const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
if (desc->flags & PIX_FMT_HWACCEL)
return;
if (desc->flags & PIX_FMT_PAL) {
av_image_copy_plane(dst_data[0], dst_linesizes[0],
src_data[0], src_linesizes[0],
width, height);
memcpy(dst_data[1], src_data[1], 4*256);
} else {
int i, planes_nb = 0;
for (i = 0; i < desc->nb_components; i++)
planes_nb = FFMAX(planes_nb, desc->comp[i].plane + 1);
for (i = 0; i < planes_nb; i++) {
int h = height;
int bwidth = av_image_get_linesize(pix_fmt, width, i);
if (i == 1 || i == 2) {
h= -((-height)>>desc->log2_chroma_h);
}
av_image_copy_plane(dst_data[i], dst_linesizes[i],
src_data[i], src_linesizes[i],
bwidth, h);
}
}
}
| {
"code": [
" if (desc->flags & PIX_FMT_PAL) {",
" if (desc->flags & PIX_FMT_PAL) {"
],
"line_no": [
19,
19
]
} | void FUNC_0(uint8_t *VAR_0[4], int VAR_1[4],
const uint8_t *VAR_2[4], const int VAR_3[4],
enum PixelFormat VAR_4, int VAR_5, int VAR_6)
{
const AVPixFmtDescriptor *VAR_7 = &av_pix_fmt_descriptors[VAR_4];
if (VAR_7->flags & PIX_FMT_HWACCEL)
return;
if (VAR_7->flags & PIX_FMT_PAL) {
av_image_copy_plane(VAR_0[0], VAR_1[0],
VAR_2[0], VAR_3[0],
VAR_5, VAR_6);
memcpy(VAR_0[1], VAR_2[1], 4*256);
} else {
int VAR_8, VAR_9 = 0;
for (VAR_8 = 0; VAR_8 < VAR_7->nb_components; VAR_8++)
VAR_9 = FFMAX(VAR_9, VAR_7->comp[VAR_8].plane + 1);
for (VAR_8 = 0; VAR_8 < VAR_9; VAR_8++) {
int VAR_10 = VAR_6;
int VAR_11 = av_image_get_linesize(VAR_4, VAR_5, VAR_8);
if (VAR_8 == 1 || VAR_8 == 2) {
VAR_10= -((-VAR_6)>>VAR_7->log2_chroma_h);
}
av_image_copy_plane(VAR_0[VAR_8], VAR_1[VAR_8],
VAR_2[VAR_8], VAR_3[VAR_8],
VAR_11, VAR_10);
}
}
}
| [
"void FUNC_0(uint8_t *VAR_0[4], int VAR_1[4],\nconst uint8_t *VAR_2[4], const int VAR_3[4],\nenum PixelFormat VAR_4, int VAR_5, int VAR_6)\n{",
"const AVPixFmtDescriptor *VAR_7 = &av_pix_fmt_descriptors[VAR_4];",
"if (VAR_7->flags & PIX_FMT_HWACCEL)\nreturn;",
"if (VAR_7->flags & PIX_FMT_PAL) {",
"av_image_copy_plane(VAR_0[0], VAR_1[0],\nVAR_2[0], VAR_3[0],\nVAR_5, VAR_6);",
"memcpy(VAR_0[1], VAR_2[1], 4*256);",
"} else {",
"int VAR_8, VAR_9 = 0;",
"for (VAR_8 = 0; VAR_8 < VAR_7->nb_components; VAR_8++)",
"VAR_9 = FFMAX(VAR_9, VAR_7->comp[VAR_8].plane + 1);",
"for (VAR_8 = 0; VAR_8 < VAR_9; VAR_8++) {",
"int VAR_10 = VAR_6;",
"int VAR_11 = av_image_get_linesize(VAR_4, VAR_5, VAR_8);",
"if (VAR_8 == 1 || VAR_8 == 2) {",
"VAR_10= -((-VAR_6)>>VAR_7->log2_chroma_h);",
"}",
"av_image_copy_plane(VAR_0[VAR_8], VAR_1[VAR_8],\nVAR_2[VAR_8], VAR_3[VAR_8],\nVAR_11, VAR_10);",
"}",
"}",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
13,
15
],
[
19
],
[
21,
23,
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57,
59
],
[
61
],
[
63
],
[
65
]
] |
3,172 | static int webm_dash_manifest_cues(AVFormatContext *s)
{
MatroskaDemuxContext *matroska = s->priv_data;
EbmlList *seekhead_list = &matroska->seekhead;
MatroskaSeekhead *seekhead = seekhead_list->elem;
char *buf;
int64_t cues_start = -1, cues_end = -1, before_pos, bandwidth;
int i;
// determine cues start and end positions
for (i = 0; i < seekhead_list->nb_elem; i++)
if (seekhead[i].id == MATROSKA_ID_CUES)
break;
if (i >= seekhead_list->nb_elem) return -1;
before_pos = avio_tell(matroska->ctx->pb);
cues_start = seekhead[i].pos + matroska->segment_start;
if (avio_seek(matroska->ctx->pb, cues_start, SEEK_SET) == cues_start) {
// cues_end is computed as cues_start + cues_length + length of the
// Cues element ID + EBML length of the Cues element. cues_end is
// inclusive and the above sum is reduced by 1.
uint64_t cues_length = 0, cues_id = 0, bytes_read = 0;
bytes_read += ebml_read_num(matroska, matroska->ctx->pb, 4, &cues_id);
bytes_read += ebml_read_length(matroska, matroska->ctx->pb, &cues_length);
cues_end = cues_start + cues_length + bytes_read - 1;
}
avio_seek(matroska->ctx->pb, before_pos, SEEK_SET);
if (cues_start == -1 || cues_end == -1) return -1;
// parse the cues
matroska_parse_cues(matroska);
// cues start
av_dict_set_int(&s->streams[0]->metadata, CUES_START, cues_start, 0);
// cues end
av_dict_set_int(&s->streams[0]->metadata, CUES_END, cues_end, 0);
// bandwidth
bandwidth = webm_dash_manifest_compute_bandwidth(s, cues_start);
if (bandwidth < 0) return -1;
av_dict_set_int(&s->streams[0]->metadata, BANDWIDTH, bandwidth, 0);
// check if all clusters start with key frames
av_dict_set_int(&s->streams[0]->metadata, CLUSTER_KEYFRAME, webm_clusters_start_with_keyframe(s), 0);
// store cue point timestamps as a comma separated list for checking subsegment alignment in
// the muxer. assumes that each timestamp cannot be more than 20 characters long.
buf = av_malloc_array(s->streams[0]->nb_index_entries, 20 * sizeof(char));
if (!buf) return -1;
strcpy(buf, "");
for (i = 0; i < s->streams[0]->nb_index_entries; i++) {
snprintf(buf, (i + 1) * 20 * sizeof(char),
"%s%" PRId64, buf, s->streams[0]->index_entries[i].timestamp);
if (i != s->streams[0]->nb_index_entries - 1)
strncat(buf, ",", sizeof(char));
}
av_dict_set(&s->streams[0]->metadata, CUE_TIMESTAMPS, buf, 0);
av_free(buf);
return 0;
}
| true | FFmpeg | 8e6b9ef4733be91b32c8b7becd95124340b92334 | static int webm_dash_manifest_cues(AVFormatContext *s)
{
MatroskaDemuxContext *matroska = s->priv_data;
EbmlList *seekhead_list = &matroska->seekhead;
MatroskaSeekhead *seekhead = seekhead_list->elem;
char *buf;
int64_t cues_start = -1, cues_end = -1, before_pos, bandwidth;
int i;
for (i = 0; i < seekhead_list->nb_elem; i++)
if (seekhead[i].id == MATROSKA_ID_CUES)
break;
if (i >= seekhead_list->nb_elem) return -1;
before_pos = avio_tell(matroska->ctx->pb);
cues_start = seekhead[i].pos + matroska->segment_start;
if (avio_seek(matroska->ctx->pb, cues_start, SEEK_SET) == cues_start) {
uint64_t cues_length = 0, cues_id = 0, bytes_read = 0;
bytes_read += ebml_read_num(matroska, matroska->ctx->pb, 4, &cues_id);
bytes_read += ebml_read_length(matroska, matroska->ctx->pb, &cues_length);
cues_end = cues_start + cues_length + bytes_read - 1;
}
avio_seek(matroska->ctx->pb, before_pos, SEEK_SET);
if (cues_start == -1 || cues_end == -1) return -1;
matroska_parse_cues(matroska);
av_dict_set_int(&s->streams[0]->metadata, CUES_START, cues_start, 0);
av_dict_set_int(&s->streams[0]->metadata, CUES_END, cues_end, 0);
bandwidth = webm_dash_manifest_compute_bandwidth(s, cues_start);
if (bandwidth < 0) return -1;
av_dict_set_int(&s->streams[0]->metadata, BANDWIDTH, bandwidth, 0);
av_dict_set_int(&s->streams[0]->metadata, CLUSTER_KEYFRAME, webm_clusters_start_with_keyframe(s), 0);
buf = av_malloc_array(s->streams[0]->nb_index_entries, 20 * sizeof(char));
if (!buf) return -1;
strcpy(buf, "");
for (i = 0; i < s->streams[0]->nb_index_entries; i++) {
snprintf(buf, (i + 1) * 20 * sizeof(char),
"%s%" PRId64, buf, s->streams[0]->index_entries[i].timestamp);
if (i != s->streams[0]->nb_index_entries - 1)
strncat(buf, ",", sizeof(char));
}
av_dict_set(&s->streams[0]->metadata, CUE_TIMESTAMPS, buf, 0);
av_free(buf);
return 0;
}
| {
"code": [
" snprintf(buf, (i + 1) * 20 * sizeof(char),",
" \"%s%\" PRId64, buf, s->streams[0]->index_entries[i].timestamp);",
" if (i != s->streams[0]->nb_index_entries - 1)"
],
"line_no": [
107,
109,
111
]
} | static int FUNC_0(AVFormatContext *VAR_0)
{
MatroskaDemuxContext *matroska = VAR_0->priv_data;
EbmlList *seekhead_list = &matroska->seekhead;
MatroskaSeekhead *seekhead = seekhead_list->elem;
char *VAR_1;
int64_t cues_start = -1, cues_end = -1, before_pos, bandwidth;
int VAR_2;
for (VAR_2 = 0; VAR_2 < seekhead_list->nb_elem; VAR_2++)
if (seekhead[VAR_2].id == MATROSKA_ID_CUES)
break;
if (VAR_2 >= seekhead_list->nb_elem) return -1;
before_pos = avio_tell(matroska->ctx->pb);
cues_start = seekhead[VAR_2].pos + matroska->segment_start;
if (avio_seek(matroska->ctx->pb, cues_start, SEEK_SET) == cues_start) {
uint64_t cues_length = 0, cues_id = 0, bytes_read = 0;
bytes_read += ebml_read_num(matroska, matroska->ctx->pb, 4, &cues_id);
bytes_read += ebml_read_length(matroska, matroska->ctx->pb, &cues_length);
cues_end = cues_start + cues_length + bytes_read - 1;
}
avio_seek(matroska->ctx->pb, before_pos, SEEK_SET);
if (cues_start == -1 || cues_end == -1) return -1;
matroska_parse_cues(matroska);
av_dict_set_int(&VAR_0->streams[0]->metadata, CUES_START, cues_start, 0);
av_dict_set_int(&VAR_0->streams[0]->metadata, CUES_END, cues_end, 0);
bandwidth = webm_dash_manifest_compute_bandwidth(VAR_0, cues_start);
if (bandwidth < 0) return -1;
av_dict_set_int(&VAR_0->streams[0]->metadata, BANDWIDTH, bandwidth, 0);
av_dict_set_int(&VAR_0->streams[0]->metadata, CLUSTER_KEYFRAME, webm_clusters_start_with_keyframe(VAR_0), 0);
VAR_1 = av_malloc_array(VAR_0->streams[0]->nb_index_entries, 20 * sizeof(char));
if (!VAR_1) return -1;
strcpy(VAR_1, "");
for (VAR_2 = 0; VAR_2 < VAR_0->streams[0]->nb_index_entries; VAR_2++) {
snprintf(VAR_1, (VAR_2 + 1) * 20 * sizeof(char),
"%VAR_0%" PRId64, VAR_1, VAR_0->streams[0]->index_entries[VAR_2].timestamp);
if (VAR_2 != VAR_0->streams[0]->nb_index_entries - 1)
strncat(VAR_1, ",", sizeof(char));
}
av_dict_set(&VAR_0->streams[0]->metadata, CUE_TIMESTAMPS, VAR_1, 0);
av_free(VAR_1);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"MatroskaDemuxContext *matroska = VAR_0->priv_data;",
"EbmlList *seekhead_list = &matroska->seekhead;",
"MatroskaSeekhead *seekhead = seekhead_list->elem;",
"char *VAR_1;",
"int64_t cues_start = -1, cues_end = -1, before_pos, bandwidth;",
"int VAR_2;",
"for (VAR_2 = 0; VAR_2 < seekhead_list->nb_elem; VAR_2++)",
"if (seekhead[VAR_2].id == MATROSKA_ID_CUES)\nbreak;",
"if (VAR_2 >= seekhead_list->nb_elem) return -1;",
"before_pos = avio_tell(matroska->ctx->pb);",
"cues_start = seekhead[VAR_2].pos + matroska->segment_start;",
"if (avio_seek(matroska->ctx->pb, cues_start, SEEK_SET) == cues_start) {",
"uint64_t cues_length = 0, cues_id = 0, bytes_read = 0;",
"bytes_read += ebml_read_num(matroska, matroska->ctx->pb, 4, &cues_id);",
"bytes_read += ebml_read_length(matroska, matroska->ctx->pb, &cues_length);",
"cues_end = cues_start + cues_length + bytes_read - 1;",
"}",
"avio_seek(matroska->ctx->pb, before_pos, SEEK_SET);",
"if (cues_start == -1 || cues_end == -1) return -1;",
"matroska_parse_cues(matroska);",
"av_dict_set_int(&VAR_0->streams[0]->metadata, CUES_START, cues_start, 0);",
"av_dict_set_int(&VAR_0->streams[0]->metadata, CUES_END, cues_end, 0);",
"bandwidth = webm_dash_manifest_compute_bandwidth(VAR_0, cues_start);",
"if (bandwidth < 0) return -1;",
"av_dict_set_int(&VAR_0->streams[0]->metadata, BANDWIDTH, bandwidth, 0);",
"av_dict_set_int(&VAR_0->streams[0]->metadata, CLUSTER_KEYFRAME, webm_clusters_start_with_keyframe(VAR_0), 0);",
"VAR_1 = av_malloc_array(VAR_0->streams[0]->nb_index_entries, 20 * sizeof(char));",
"if (!VAR_1) return -1;",
"strcpy(VAR_1, \"\");",
"for (VAR_2 = 0; VAR_2 < VAR_0->streams[0]->nb_index_entries; VAR_2++) {",
"snprintf(VAR_1, (VAR_2 + 1) * 20 * sizeof(char),\n\"%VAR_0%\" PRId64, VAR_1, VAR_0->streams[0]->index_entries[VAR_2].timestamp);",
"if (VAR_2 != VAR_0->streams[0]->nb_index_entries - 1)\nstrncat(VAR_1, \",\", sizeof(char));",
"}",
"av_dict_set(&VAR_0->streams[0]->metadata, CUE_TIMESTAMPS, VAR_1, 0);",
"av_free(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,
1,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
21
],
[
23,
25
],
[
29
],
[
33
],
[
35
],
[
37
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
63
],
[
69
],
[
75
],
[
81
],
[
83
],
[
85
],
[
91
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107,
109
],
[
111,
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
]
] |
3,173 | static void pxa2xx_screen_dump(void *opaque, const char *filename)
{
/* TODO */
}
| true | qemu | 167351020420c285b67cdf0603501b3d3b15e3f7 | static void pxa2xx_screen_dump(void *opaque, const char *filename)
{
}
| {
"code": [
"static void pxa2xx_screen_dump(void *opaque, const char *filename)"
],
"line_no": [
1
]
} | static void FUNC_0(void *VAR_0, const char *VAR_1)
{
}
| [
"static void FUNC_0(void *VAR_0, const char *VAR_1)\n{",
"}"
] | [
1,
0
] | [
[
1,
3
],
[
7
]
] |
3,174 | static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int predictor, int point_transform)
{
int i, mb_x, mb_y;
uint16_t (*buffer)[4];
int left[4], top[4], topleft[4];
const int linesize = s->linesize[0];
const int mask = (1 << s->bits) - 1;
int resync_mb_y = 0;
int resync_mb_x = 0;
s->restart_count = s->restart_interval;
av_fast_malloc(&s->ljpeg_buffer, &s->ljpeg_buffer_size,
(unsigned)s->mb_width * 4 * sizeof(s->ljpeg_buffer[0][0]));
buffer = s->ljpeg_buffer;
for (i = 0; i < 4; i++)
buffer[0][i] = 1 << (s->bits - 1);
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
uint8_t *ptr = s->picture.data[0] + (linesize * mb_y);
if (s->interlaced && s->bottom_field)
ptr += linesize >> 1;
for (i = 0; i < 4; i++)
top[i] = left[i] = topleft[i] = buffer[0][i];
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
int modified_predictor = predictor;
if (s->restart_interval && !s->restart_count){
s->restart_count = s->restart_interval;
resync_mb_x = mb_x;
resync_mb_y = mb_y;
for(i=0; i<4; i++)
top[i] = left[i]= topleft[i]= 1 << (s->bits - 1);
}
if (mb_y == resync_mb_y || mb_y == resync_mb_y+1 && mb_x < resync_mb_x || !mb_x)
modified_predictor = 1;
for (i=0;i<nb_components;i++) {
int pred, dc;
topleft[i] = top[i];
top[i] = buffer[mb_x][i];
PREDICT(pred, topleft[i], top[i], left[i], modified_predictor);
dc = mjpeg_decode_dc(s, s->dc_index[i]);
if(dc == 0xFFFF)
return -1;
left[i] = buffer[mb_x][i] =
mask & (pred + (dc << point_transform));
}
if (s->restart_interval && !--s->restart_count) {
align_get_bits(&s->gb);
skip_bits(&s->gb, 16); /* skip RSTn */
}
}
if (s->nb_components == 4) {
for(i=0; i<nb_components; i++) {
int c= s->comp_index[i];
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[4*mb_x+3-c] = buffer[mb_x][i];
}
}
} else if (s->rct) {
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[3*mb_x + 1] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2] - 0x200) >> 2);
ptr[3*mb_x + 0] = buffer[mb_x][1] + ptr[3*mb_x + 1];
ptr[3*mb_x + 2] = buffer[mb_x][2] + ptr[3*mb_x + 1];
}
} else if (s->pegasus_rct) {
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[3*mb_x + 1] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2]) >> 2);
ptr[3*mb_x + 0] = buffer[mb_x][1] + ptr[3*mb_x + 1];
ptr[3*mb_x + 2] = buffer[mb_x][2] + ptr[3*mb_x + 1];
}
} else {
for(i=0; i<nb_components; i++) {
int c= s->comp_index[i];
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[3*mb_x+2-c] = buffer[mb_x][i];
}
}
}
}
return 0;
} | true | FFmpeg | 61c68000eda643dfce96dc46b488d39fd5c4e309 | static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int predictor, int point_transform)
{
int i, mb_x, mb_y;
uint16_t (*buffer)[4];
int left[4], top[4], topleft[4];
const int linesize = s->linesize[0];
const int mask = (1 << s->bits) - 1;
int resync_mb_y = 0;
int resync_mb_x = 0;
s->restart_count = s->restart_interval;
av_fast_malloc(&s->ljpeg_buffer, &s->ljpeg_buffer_size,
(unsigned)s->mb_width * 4 * sizeof(s->ljpeg_buffer[0][0]));
buffer = s->ljpeg_buffer;
for (i = 0; i < 4; i++)
buffer[0][i] = 1 << (s->bits - 1);
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
uint8_t *ptr = s->picture.data[0] + (linesize * mb_y);
if (s->interlaced && s->bottom_field)
ptr += linesize >> 1;
for (i = 0; i < 4; i++)
top[i] = left[i] = topleft[i] = buffer[0][i];
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
int modified_predictor = predictor;
if (s->restart_interval && !s->restart_count){
s->restart_count = s->restart_interval;
resync_mb_x = mb_x;
resync_mb_y = mb_y;
for(i=0; i<4; i++)
top[i] = left[i]= topleft[i]= 1 << (s->bits - 1);
}
if (mb_y == resync_mb_y || mb_y == resync_mb_y+1 && mb_x < resync_mb_x || !mb_x)
modified_predictor = 1;
for (i=0;i<nb_components;i++) {
int pred, dc;
topleft[i] = top[i];
top[i] = buffer[mb_x][i];
PREDICT(pred, topleft[i], top[i], left[i], modified_predictor);
dc = mjpeg_decode_dc(s, s->dc_index[i]);
if(dc == 0xFFFF)
return -1;
left[i] = buffer[mb_x][i] =
mask & (pred + (dc << point_transform));
}
if (s->restart_interval && !--s->restart_count) {
align_get_bits(&s->gb);
skip_bits(&s->gb, 16);
}
}
if (s->nb_components == 4) {
for(i=0; i<nb_components; i++) {
int c= s->comp_index[i];
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[4*mb_x+3-c] = buffer[mb_x][i];
}
}
} else if (s->rct) {
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[3*mb_x + 1] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2] - 0x200) >> 2);
ptr[3*mb_x + 0] = buffer[mb_x][1] + ptr[3*mb_x + 1];
ptr[3*mb_x + 2] = buffer[mb_x][2] + ptr[3*mb_x + 1];
}
} else if (s->pegasus_rct) {
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[3*mb_x + 1] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2]) >> 2);
ptr[3*mb_x + 0] = buffer[mb_x][1] + ptr[3*mb_x + 1];
ptr[3*mb_x + 2] = buffer[mb_x][2] + ptr[3*mb_x + 1];
}
} else {
for(i=0; i<nb_components; i++) {
int c= s->comp_index[i];
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[3*mb_x+2-c] = buffer[mb_x][i];
}
}
}
}
return 0;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(MJpegDecodeContext *VAR_0, int VAR_1, int VAR_2, int VAR_3)
{
int VAR_4, VAR_5, VAR_6;
uint16_t (*buffer)[4];
int VAR_7[4], VAR_8[4], VAR_9[4];
const int VAR_10 = VAR_0->VAR_10[0];
const int VAR_11 = (1 << VAR_0->bits) - 1;
int VAR_12 = 0;
int VAR_13 = 0;
VAR_0->restart_count = VAR_0->restart_interval;
av_fast_malloc(&VAR_0->ljpeg_buffer, &VAR_0->ljpeg_buffer_size,
(unsigned)VAR_0->mb_width * 4 * sizeof(VAR_0->ljpeg_buffer[0][0]));
buffer = VAR_0->ljpeg_buffer;
for (VAR_4 = 0; VAR_4 < 4; VAR_4++)
buffer[0][VAR_4] = 1 << (VAR_0->bits - 1);
for (VAR_6 = 0; VAR_6 < VAR_0->mb_height; VAR_6++) {
uint8_t *ptr = VAR_0->picture.data[0] + (VAR_10 * VAR_6);
if (VAR_0->interlaced && VAR_0->bottom_field)
ptr += VAR_10 >> 1;
for (VAR_4 = 0; VAR_4 < 4; VAR_4++)
VAR_8[VAR_4] = VAR_7[VAR_4] = VAR_9[VAR_4] = buffer[0][VAR_4];
for (VAR_5 = 0; VAR_5 < VAR_0->mb_width; VAR_5++) {
int modified_predictor = VAR_2;
if (VAR_0->restart_interval && !VAR_0->restart_count){
VAR_0->restart_count = VAR_0->restart_interval;
VAR_13 = VAR_5;
VAR_12 = VAR_6;
for(VAR_4=0; VAR_4<4; VAR_4++)
VAR_8[VAR_4] = VAR_7[VAR_4]= VAR_9[VAR_4]= 1 << (VAR_0->bits - 1);
}
if (VAR_6 == VAR_12 || VAR_6 == VAR_12+1 && VAR_5 < VAR_13 || !VAR_5)
modified_predictor = 1;
for (VAR_4=0;VAR_4<VAR_1;VAR_4++) {
int pred, dc;
VAR_9[VAR_4] = VAR_8[VAR_4];
VAR_8[VAR_4] = buffer[VAR_5][VAR_4];
PREDICT(pred, VAR_9[VAR_4], VAR_8[VAR_4], VAR_7[VAR_4], modified_predictor);
dc = mjpeg_decode_dc(VAR_0, VAR_0->dc_index[VAR_4]);
if(dc == 0xFFFF)
return -1;
VAR_7[VAR_4] = buffer[VAR_5][VAR_4] =
VAR_11 & (pred + (dc << VAR_3));
}
if (VAR_0->restart_interval && !--VAR_0->restart_count) {
align_get_bits(&VAR_0->gb);
skip_bits(&VAR_0->gb, 16);
}
}
if (VAR_0->VAR_1 == 4) {
for(VAR_4=0; VAR_4<VAR_1; VAR_4++) {
int c= VAR_0->comp_index[VAR_4];
for(VAR_5 = 0; VAR_5 < VAR_0->mb_width; VAR_5++) {
ptr[4*VAR_5+3-c] = buffer[VAR_5][VAR_4];
}
}
} else if (VAR_0->rct) {
for (VAR_5 = 0; VAR_5 < VAR_0->mb_width; VAR_5++) {
ptr[3*VAR_5 + 1] = buffer[VAR_5][0] - ((buffer[VAR_5][1] + buffer[VAR_5][2] - 0x200) >> 2);
ptr[3*VAR_5 + 0] = buffer[VAR_5][1] + ptr[3*VAR_5 + 1];
ptr[3*VAR_5 + 2] = buffer[VAR_5][2] + ptr[3*VAR_5 + 1];
}
} else if (VAR_0->pegasus_rct) {
for (VAR_5 = 0; VAR_5 < VAR_0->mb_width; VAR_5++) {
ptr[3*VAR_5 + 1] = buffer[VAR_5][0] - ((buffer[VAR_5][1] + buffer[VAR_5][2]) >> 2);
ptr[3*VAR_5 + 0] = buffer[VAR_5][1] + ptr[3*VAR_5 + 1];
ptr[3*VAR_5 + 2] = buffer[VAR_5][2] + ptr[3*VAR_5 + 1];
}
} else {
for(VAR_4=0; VAR_4<VAR_1; VAR_4++) {
int c= VAR_0->comp_index[VAR_4];
for(VAR_5 = 0; VAR_5 < VAR_0->mb_width; VAR_5++) {
ptr[3*VAR_5+2-c] = buffer[VAR_5][VAR_4];
}
}
}
}
return 0;
} | [
"static int FUNC_0(MJpegDecodeContext *VAR_0, int VAR_1, int VAR_2, int VAR_3)\n{",
"int VAR_4, VAR_5, VAR_6;",
"uint16_t (*buffer)[4];",
"int VAR_7[4], VAR_8[4], VAR_9[4];",
"const int VAR_10 = VAR_0->VAR_10[0];",
"const int VAR_11 = (1 << VAR_0->bits) - 1;",
"int VAR_12 = 0;",
"int VAR_13 = 0;",
"VAR_0->restart_count = VAR_0->restart_interval;",
"av_fast_malloc(&VAR_0->ljpeg_buffer, &VAR_0->ljpeg_buffer_size,\n(unsigned)VAR_0->mb_width * 4 * sizeof(VAR_0->ljpeg_buffer[0][0]));",
"buffer = VAR_0->ljpeg_buffer;",
"for (VAR_4 = 0; VAR_4 < 4; VAR_4++)",
"buffer[0][VAR_4] = 1 << (VAR_0->bits - 1);",
"for (VAR_6 = 0; VAR_6 < VAR_0->mb_height; VAR_6++) {",
"uint8_t *ptr = VAR_0->picture.data[0] + (VAR_10 * VAR_6);",
"if (VAR_0->interlaced && VAR_0->bottom_field)\nptr += VAR_10 >> 1;",
"for (VAR_4 = 0; VAR_4 < 4; VAR_4++)",
"VAR_8[VAR_4] = VAR_7[VAR_4] = VAR_9[VAR_4] = buffer[0][VAR_4];",
"for (VAR_5 = 0; VAR_5 < VAR_0->mb_width; VAR_5++) {",
"int modified_predictor = VAR_2;",
"if (VAR_0->restart_interval && !VAR_0->restart_count){",
"VAR_0->restart_count = VAR_0->restart_interval;",
"VAR_13 = VAR_5;",
"VAR_12 = VAR_6;",
"for(VAR_4=0; VAR_4<4; VAR_4++)",
"VAR_8[VAR_4] = VAR_7[VAR_4]= VAR_9[VAR_4]= 1 << (VAR_0->bits - 1);",
"}",
"if (VAR_6 == VAR_12 || VAR_6 == VAR_12+1 && VAR_5 < VAR_13 || !VAR_5)\nmodified_predictor = 1;",
"for (VAR_4=0;VAR_4<VAR_1;VAR_4++) {",
"int pred, dc;",
"VAR_9[VAR_4] = VAR_8[VAR_4];",
"VAR_8[VAR_4] = buffer[VAR_5][VAR_4];",
"PREDICT(pred, VAR_9[VAR_4], VAR_8[VAR_4], VAR_7[VAR_4], modified_predictor);",
"dc = mjpeg_decode_dc(VAR_0, VAR_0->dc_index[VAR_4]);",
"if(dc == 0xFFFF)\nreturn -1;",
"VAR_7[VAR_4] = buffer[VAR_5][VAR_4] =\nVAR_11 & (pred + (dc << VAR_3));",
"}",
"if (VAR_0->restart_interval && !--VAR_0->restart_count) {",
"align_get_bits(&VAR_0->gb);",
"skip_bits(&VAR_0->gb, 16);",
"}",
"}",
"if (VAR_0->VAR_1 == 4) {",
"for(VAR_4=0; VAR_4<VAR_1; VAR_4++) {",
"int c= VAR_0->comp_index[VAR_4];",
"for(VAR_5 = 0; VAR_5 < VAR_0->mb_width; VAR_5++) {",
"ptr[4*VAR_5+3-c] = buffer[VAR_5][VAR_4];",
"}",
"}",
"} else if (VAR_0->rct) {",
"for (VAR_5 = 0; VAR_5 < VAR_0->mb_width; VAR_5++) {",
"ptr[3*VAR_5 + 1] = buffer[VAR_5][0] - ((buffer[VAR_5][1] + buffer[VAR_5][2] - 0x200) >> 2);",
"ptr[3*VAR_5 + 0] = buffer[VAR_5][1] + ptr[3*VAR_5 + 1];",
"ptr[3*VAR_5 + 2] = buffer[VAR_5][2] + ptr[3*VAR_5 + 1];",
"}",
"} else if (VAR_0->pegasus_rct) {",
"for (VAR_5 = 0; VAR_5 < VAR_0->mb_width; VAR_5++) {",
"ptr[3*VAR_5 + 1] = buffer[VAR_5][0] - ((buffer[VAR_5][1] + buffer[VAR_5][2]) >> 2);",
"ptr[3*VAR_5 + 0] = buffer[VAR_5][1] + ptr[3*VAR_5 + 1];",
"ptr[3*VAR_5 + 2] = buffer[VAR_5][2] + ptr[3*VAR_5 + 1];",
"}",
"} else {",
"for(VAR_4=0; VAR_4<VAR_1; VAR_4++) {",
"int c= VAR_0->comp_index[VAR_4];",
"for(VAR_5 = 0; VAR_5 < VAR_0->mb_width; VAR_5++) {",
"ptr[3*VAR_5+2-c] = buffer[VAR_5][VAR_4];",
"}",
"}",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11,
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18,
19
],
[
20
],
[
21
],
[
22
],
[
23
],
[
24
],
[
25
],
[
26
],
[
27
],
[
28
],
[
29
],
[
30
],
[
31,
32
],
[
33
],
[
34
],
[
35
],
[
36
],
[
37
],
[
38
],
[
39,
40
],
[
41,
42
],
[
43
],
[
44
],
[
45
],
[
46
],
[
47
],
[
48
],
[
49
],
[
50
],
[
51
],
[
52
],
[
53
],
[
54
],
[
55
],
[
56
],
[
57
],
[
58
],
[
59
],
[
60
],
[
61
],
[
62
],
[
63
],
[
64
],
[
65
],
[
66
],
[
67
],
[
68
],
[
69
],
[
70
],
[
71
],
[
72
],
[
73
],
[
74
],
[
75
],
[
76
],
[
77
],
[
78
]
] |
3,175 | static av_cold int vp8_init(AVCodecContext *avctx)
{
VP8Context *ctx = avctx->priv_data;
const struct vpx_codec_iface *iface = &vpx_codec_vp8_cx_algo;
struct vpx_codec_enc_cfg enccfg;
int res;
av_log(avctx, AV_LOG_INFO, "%s\n", vpx_codec_version_str());
av_log(avctx, AV_LOG_VERBOSE, "%s\n", vpx_codec_build_config());
if ((res = vpx_codec_enc_config_default(iface, &enccfg, 0)) != VPX_CODEC_OK) {
av_log(avctx, AV_LOG_ERROR, "Failed to get config: %s\n",
vpx_codec_err_to_string(res));
return AVERROR(EINVAL);
}
dump_enc_cfg(avctx, &enccfg);
enccfg.g_w = avctx->width;
enccfg.g_h = avctx->height;
enccfg.g_timebase.num = avctx->time_base.num;
enccfg.g_timebase.den = avctx->time_base.den;
enccfg.g_threads = avctx->thread_count;
enccfg.g_lag_in_frames= ctx->lag_in_frames;
if (avctx->flags & CODEC_FLAG_PASS1)
enccfg.g_pass = VPX_RC_FIRST_PASS;
else if (avctx->flags & CODEC_FLAG_PASS2)
enccfg.g_pass = VPX_RC_LAST_PASS;
else
enccfg.g_pass = VPX_RC_ONE_PASS;
if (avctx->rc_min_rate == avctx->rc_max_rate &&
avctx->rc_min_rate == avctx->bit_rate)
enccfg.rc_end_usage = VPX_CBR;
else if (ctx->crf)
enccfg.rc_end_usage = VPX_CQ;
enccfg.rc_target_bitrate = av_rescale_rnd(avctx->bit_rate, 1, 1000,
AV_ROUND_NEAR_INF);
if (avctx->qmin > 0)
enccfg.rc_min_quantizer = avctx->qmin;
if (avctx->qmax > 0)
enccfg.rc_max_quantizer = avctx->qmax;
enccfg.rc_dropframe_thresh = avctx->frame_skip_threshold;
//0-100 (0 => CBR, 100 => VBR)
enccfg.rc_2pass_vbr_bias_pct = round(avctx->qcompress * 100);
enccfg.rc_2pass_vbr_minsection_pct =
avctx->rc_min_rate * 100LL / avctx->bit_rate;
if (avctx->rc_max_rate)
enccfg.rc_2pass_vbr_maxsection_pct =
avctx->rc_max_rate * 100LL / avctx->bit_rate;
if (avctx->rc_buffer_size)
enccfg.rc_buf_sz =
avctx->rc_buffer_size * 1000LL / avctx->bit_rate;
if (avctx->rc_initial_buffer_occupancy)
enccfg.rc_buf_initial_sz =
avctx->rc_initial_buffer_occupancy * 1000LL / avctx->bit_rate;
enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6;
enccfg.rc_undershoot_pct = round(avctx->rc_buffer_aggressivity * 100);
//_enc_init() will balk if kf_min_dist differs from max w/VPX_KF_AUTO
if (avctx->keyint_min >= 0 && avctx->keyint_min == avctx->gop_size)
enccfg.kf_min_dist = avctx->keyint_min;
if (avctx->gop_size >= 0)
enccfg.kf_max_dist = avctx->gop_size;
if (enccfg.g_pass == VPX_RC_FIRST_PASS)
enccfg.g_lag_in_frames = 0;
else if (enccfg.g_pass == VPX_RC_LAST_PASS) {
int decode_size;
if (!avctx->stats_in) {
av_log(avctx, AV_LOG_ERROR, "No stats file for second pass\n");
return AVERROR_INVALIDDATA;
}
ctx->twopass_stats.sz = strlen(avctx->stats_in) * 3 / 4;
ctx->twopass_stats.buf = av_malloc(ctx->twopass_stats.sz);
if (!ctx->twopass_stats.buf) {
av_log(avctx, AV_LOG_ERROR,
"Stat buffer alloc (%zu bytes) failed\n",
ctx->twopass_stats.sz);
return AVERROR(ENOMEM);
}
decode_size = av_base64_decode(ctx->twopass_stats.buf, avctx->stats_in,
ctx->twopass_stats.sz);
if (decode_size < 0) {
av_log(avctx, AV_LOG_ERROR, "Stat buffer decode failed\n");
return AVERROR_INVALIDDATA;
}
ctx->twopass_stats.sz = decode_size;
enccfg.rc_twopass_stats_in = ctx->twopass_stats;
}
/* 0-3: For non-zero values the encoder increasingly optimizes for reduced
complexity playback on low powered devices at the expense of encode
quality. */
if (avctx->profile != FF_PROFILE_UNKNOWN)
enccfg.g_profile = avctx->profile;
enccfg.g_error_resilient = ctx->error_resilient || ctx->flags & VP8F_ERROR_RESILIENT;
dump_enc_cfg(avctx, &enccfg);
/* Construct Encoder Context */
res = vpx_codec_enc_init(&ctx->encoder, iface, &enccfg, 0);
if (res != VPX_CODEC_OK) {
log_encoder_error(avctx, "Failed to initialize encoder");
return AVERROR(EINVAL);
}
//codec control failures are currently treated only as warnings
av_log(avctx, AV_LOG_DEBUG, "vpx_codec_control\n");
if (ctx->cpu_used != INT_MIN)
codecctl_int(avctx, VP8E_SET_CPUUSED, ctx->cpu_used);
if (ctx->flags & VP8F_AUTO_ALT_REF)
ctx->auto_alt_ref = 1;
if (ctx->auto_alt_ref >= 0)
codecctl_int(avctx, VP8E_SET_ENABLEAUTOALTREF, ctx->auto_alt_ref);
if (ctx->arnr_max_frames >= 0)
codecctl_int(avctx, VP8E_SET_ARNR_MAXFRAMES, ctx->arnr_max_frames);
if (ctx->arnr_strength >= 0)
codecctl_int(avctx, VP8E_SET_ARNR_STRENGTH, ctx->arnr_strength);
if (ctx->arnr_type >= 0)
codecctl_int(avctx, VP8E_SET_ARNR_TYPE, ctx->arnr_type);
codecctl_int(avctx, VP8E_SET_NOISE_SENSITIVITY, avctx->noise_reduction);
codecctl_int(avctx, VP8E_SET_TOKEN_PARTITIONS, av_log2(avctx->slices));
codecctl_int(avctx, VP8E_SET_STATIC_THRESHOLD, avctx->mb_threshold);
codecctl_int(avctx, VP8E_SET_CQ_LEVEL, ctx->crf);
if (ctx->max_intra_rate >= 0)
codecctl_int(avctx, VP8E_SET_MAX_INTRA_BITRATE_PCT, ctx->max_intra_rate);
av_log(avctx, AV_LOG_DEBUG, "Using deadline: %d\n", ctx->deadline);
//provide dummy value to initialize wrapper, values will be updated each _encode()
vpx_img_wrap(&ctx->rawimg, VPX_IMG_FMT_I420, avctx->width, avctx->height, 1,
(unsigned char*)1);
avctx->coded_frame = avcodec_alloc_frame();
if (!avctx->coded_frame) {
av_log(avctx, AV_LOG_ERROR, "Error allocating coded frame\n");
vp8_free(avctx);
return AVERROR(ENOMEM);
}
return 0;
}
| true | FFmpeg | d472453efd32bfb0b3cd348183f4fcb7d4df4389 | static av_cold int vp8_init(AVCodecContext *avctx)
{
VP8Context *ctx = avctx->priv_data;
const struct vpx_codec_iface *iface = &vpx_codec_vp8_cx_algo;
struct vpx_codec_enc_cfg enccfg;
int res;
av_log(avctx, AV_LOG_INFO, "%s\n", vpx_codec_version_str());
av_log(avctx, AV_LOG_VERBOSE, "%s\n", vpx_codec_build_config());
if ((res = vpx_codec_enc_config_default(iface, &enccfg, 0)) != VPX_CODEC_OK) {
av_log(avctx, AV_LOG_ERROR, "Failed to get config: %s\n",
vpx_codec_err_to_string(res));
return AVERROR(EINVAL);
}
dump_enc_cfg(avctx, &enccfg);
enccfg.g_w = avctx->width;
enccfg.g_h = avctx->height;
enccfg.g_timebase.num = avctx->time_base.num;
enccfg.g_timebase.den = avctx->time_base.den;
enccfg.g_threads = avctx->thread_count;
enccfg.g_lag_in_frames= ctx->lag_in_frames;
if (avctx->flags & CODEC_FLAG_PASS1)
enccfg.g_pass = VPX_RC_FIRST_PASS;
else if (avctx->flags & CODEC_FLAG_PASS2)
enccfg.g_pass = VPX_RC_LAST_PASS;
else
enccfg.g_pass = VPX_RC_ONE_PASS;
if (avctx->rc_min_rate == avctx->rc_max_rate &&
avctx->rc_min_rate == avctx->bit_rate)
enccfg.rc_end_usage = VPX_CBR;
else if (ctx->crf)
enccfg.rc_end_usage = VPX_CQ;
enccfg.rc_target_bitrate = av_rescale_rnd(avctx->bit_rate, 1, 1000,
AV_ROUND_NEAR_INF);
if (avctx->qmin > 0)
enccfg.rc_min_quantizer = avctx->qmin;
if (avctx->qmax > 0)
enccfg.rc_max_quantizer = avctx->qmax;
enccfg.rc_dropframe_thresh = avctx->frame_skip_threshold;
enccfg.rc_2pass_vbr_bias_pct = round(avctx->qcompress * 100);
enccfg.rc_2pass_vbr_minsection_pct =
avctx->rc_min_rate * 100LL / avctx->bit_rate;
if (avctx->rc_max_rate)
enccfg.rc_2pass_vbr_maxsection_pct =
avctx->rc_max_rate * 100LL / avctx->bit_rate;
if (avctx->rc_buffer_size)
enccfg.rc_buf_sz =
avctx->rc_buffer_size * 1000LL / avctx->bit_rate;
if (avctx->rc_initial_buffer_occupancy)
enccfg.rc_buf_initial_sz =
avctx->rc_initial_buffer_occupancy * 1000LL / avctx->bit_rate;
enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6;
enccfg.rc_undershoot_pct = round(avctx->rc_buffer_aggressivity * 100);
if (avctx->keyint_min >= 0 && avctx->keyint_min == avctx->gop_size)
enccfg.kf_min_dist = avctx->keyint_min;
if (avctx->gop_size >= 0)
enccfg.kf_max_dist = avctx->gop_size;
if (enccfg.g_pass == VPX_RC_FIRST_PASS)
enccfg.g_lag_in_frames = 0;
else if (enccfg.g_pass == VPX_RC_LAST_PASS) {
int decode_size;
if (!avctx->stats_in) {
av_log(avctx, AV_LOG_ERROR, "No stats file for second pass\n");
return AVERROR_INVALIDDATA;
}
ctx->twopass_stats.sz = strlen(avctx->stats_in) * 3 / 4;
ctx->twopass_stats.buf = av_malloc(ctx->twopass_stats.sz);
if (!ctx->twopass_stats.buf) {
av_log(avctx, AV_LOG_ERROR,
"Stat buffer alloc (%zu bytes) failed\n",
ctx->twopass_stats.sz);
return AVERROR(ENOMEM);
}
decode_size = av_base64_decode(ctx->twopass_stats.buf, avctx->stats_in,
ctx->twopass_stats.sz);
if (decode_size < 0) {
av_log(avctx, AV_LOG_ERROR, "Stat buffer decode failed\n");
return AVERROR_INVALIDDATA;
}
ctx->twopass_stats.sz = decode_size;
enccfg.rc_twopass_stats_in = ctx->twopass_stats;
}
if (avctx->profile != FF_PROFILE_UNKNOWN)
enccfg.g_profile = avctx->profile;
enccfg.g_error_resilient = ctx->error_resilient || ctx->flags & VP8F_ERROR_RESILIENT;
dump_enc_cfg(avctx, &enccfg);
res = vpx_codec_enc_init(&ctx->encoder, iface, &enccfg, 0);
if (res != VPX_CODEC_OK) {
log_encoder_error(avctx, "Failed to initialize encoder");
return AVERROR(EINVAL);
}
av_log(avctx, AV_LOG_DEBUG, "vpx_codec_control\n");
if (ctx->cpu_used != INT_MIN)
codecctl_int(avctx, VP8E_SET_CPUUSED, ctx->cpu_used);
if (ctx->flags & VP8F_AUTO_ALT_REF)
ctx->auto_alt_ref = 1;
if (ctx->auto_alt_ref >= 0)
codecctl_int(avctx, VP8E_SET_ENABLEAUTOALTREF, ctx->auto_alt_ref);
if (ctx->arnr_max_frames >= 0)
codecctl_int(avctx, VP8E_SET_ARNR_MAXFRAMES, ctx->arnr_max_frames);
if (ctx->arnr_strength >= 0)
codecctl_int(avctx, VP8E_SET_ARNR_STRENGTH, ctx->arnr_strength);
if (ctx->arnr_type >= 0)
codecctl_int(avctx, VP8E_SET_ARNR_TYPE, ctx->arnr_type);
codecctl_int(avctx, VP8E_SET_NOISE_SENSITIVITY, avctx->noise_reduction);
codecctl_int(avctx, VP8E_SET_TOKEN_PARTITIONS, av_log2(avctx->slices));
codecctl_int(avctx, VP8E_SET_STATIC_THRESHOLD, avctx->mb_threshold);
codecctl_int(avctx, VP8E_SET_CQ_LEVEL, ctx->crf);
if (ctx->max_intra_rate >= 0)
codecctl_int(avctx, VP8E_SET_MAX_INTRA_BITRATE_PCT, ctx->max_intra_rate);
av_log(avctx, AV_LOG_DEBUG, "Using deadline: %d\n", ctx->deadline);
vpx_img_wrap(&ctx->rawimg, VPX_IMG_FMT_I420, avctx->width, avctx->height, 1,
(unsigned char*)1);
avctx->coded_frame = avcodec_alloc_frame();
if (!avctx->coded_frame) {
av_log(avctx, AV_LOG_ERROR, "Error allocating coded frame\n");
vp8_free(avctx);
return AVERROR(ENOMEM);
}
return 0;
}
| {
"code": [
" enccfg.rc_2pass_vbr_minsection_pct =",
" avctx->rc_min_rate * 100LL / avctx->bit_rate;"
],
"line_no": [
93,
95
]
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
VP8Context *ctx = avctx->priv_data;
const struct vpx_codec_iface *VAR_0 = &vpx_codec_vp8_cx_algo;
struct vpx_codec_enc_cfg VAR_1;
int VAR_2;
av_log(avctx, AV_LOG_INFO, "%s\n", vpx_codec_version_str());
av_log(avctx, AV_LOG_VERBOSE, "%s\n", vpx_codec_build_config());
if ((VAR_2 = vpx_codec_enc_config_default(VAR_0, &VAR_1, 0)) != VPX_CODEC_OK) {
av_log(avctx, AV_LOG_ERROR, "Failed to get config: %s\n",
vpx_codec_err_to_string(VAR_2));
return AVERROR(EINVAL);
}
dump_enc_cfg(avctx, &VAR_1);
VAR_1.g_w = avctx->width;
VAR_1.g_h = avctx->height;
VAR_1.g_timebase.num = avctx->time_base.num;
VAR_1.g_timebase.den = avctx->time_base.den;
VAR_1.g_threads = avctx->thread_count;
VAR_1.g_lag_in_frames= ctx->lag_in_frames;
if (avctx->flags & CODEC_FLAG_PASS1)
VAR_1.g_pass = VPX_RC_FIRST_PASS;
else if (avctx->flags & CODEC_FLAG_PASS2)
VAR_1.g_pass = VPX_RC_LAST_PASS;
else
VAR_1.g_pass = VPX_RC_ONE_PASS;
if (avctx->rc_min_rate == avctx->rc_max_rate &&
avctx->rc_min_rate == avctx->bit_rate)
VAR_1.rc_end_usage = VPX_CBR;
else if (ctx->crf)
VAR_1.rc_end_usage = VPX_CQ;
VAR_1.rc_target_bitrate = av_rescale_rnd(avctx->bit_rate, 1, 1000,
AV_ROUND_NEAR_INF);
if (avctx->qmin > 0)
VAR_1.rc_min_quantizer = avctx->qmin;
if (avctx->qmax > 0)
VAR_1.rc_max_quantizer = avctx->qmax;
VAR_1.rc_dropframe_thresh = avctx->frame_skip_threshold;
VAR_1.rc_2pass_vbr_bias_pct = round(avctx->qcompress * 100);
VAR_1.rc_2pass_vbr_minsection_pct =
avctx->rc_min_rate * 100LL / avctx->bit_rate;
if (avctx->rc_max_rate)
VAR_1.rc_2pass_vbr_maxsection_pct =
avctx->rc_max_rate * 100LL / avctx->bit_rate;
if (avctx->rc_buffer_size)
VAR_1.rc_buf_sz =
avctx->rc_buffer_size * 1000LL / avctx->bit_rate;
if (avctx->rc_initial_buffer_occupancy)
VAR_1.rc_buf_initial_sz =
avctx->rc_initial_buffer_occupancy * 1000LL / avctx->bit_rate;
VAR_1.rc_buf_optimal_sz = VAR_1.rc_buf_sz * 5 / 6;
VAR_1.rc_undershoot_pct = round(avctx->rc_buffer_aggressivity * 100);
if (avctx->keyint_min >= 0 && avctx->keyint_min == avctx->gop_size)
VAR_1.kf_min_dist = avctx->keyint_min;
if (avctx->gop_size >= 0)
VAR_1.kf_max_dist = avctx->gop_size;
if (VAR_1.g_pass == VPX_RC_FIRST_PASS)
VAR_1.g_lag_in_frames = 0;
else if (VAR_1.g_pass == VPX_RC_LAST_PASS) {
int VAR_3;
if (!avctx->stats_in) {
av_log(avctx, AV_LOG_ERROR, "No stats file for second pass\n");
return AVERROR_INVALIDDATA;
}
ctx->twopass_stats.sz = strlen(avctx->stats_in) * 3 / 4;
ctx->twopass_stats.buf = av_malloc(ctx->twopass_stats.sz);
if (!ctx->twopass_stats.buf) {
av_log(avctx, AV_LOG_ERROR,
"Stat buffer alloc (%zu bytes) failed\n",
ctx->twopass_stats.sz);
return AVERROR(ENOMEM);
}
VAR_3 = av_base64_decode(ctx->twopass_stats.buf, avctx->stats_in,
ctx->twopass_stats.sz);
if (VAR_3 < 0) {
av_log(avctx, AV_LOG_ERROR, "Stat buffer decode failed\n");
return AVERROR_INVALIDDATA;
}
ctx->twopass_stats.sz = VAR_3;
VAR_1.rc_twopass_stats_in = ctx->twopass_stats;
}
if (avctx->profile != FF_PROFILE_UNKNOWN)
VAR_1.g_profile = avctx->profile;
VAR_1.g_error_resilient = ctx->error_resilient || ctx->flags & VP8F_ERROR_RESILIENT;
dump_enc_cfg(avctx, &VAR_1);
VAR_2 = vpx_codec_enc_init(&ctx->encoder, VAR_0, &VAR_1, 0);
if (VAR_2 != VPX_CODEC_OK) {
log_encoder_error(avctx, "Failed to initialize encoder");
return AVERROR(EINVAL);
}
av_log(avctx, AV_LOG_DEBUG, "vpx_codec_control\n");
if (ctx->cpu_used != INT_MIN)
codecctl_int(avctx, VP8E_SET_CPUUSED, ctx->cpu_used);
if (ctx->flags & VP8F_AUTO_ALT_REF)
ctx->auto_alt_ref = 1;
if (ctx->auto_alt_ref >= 0)
codecctl_int(avctx, VP8E_SET_ENABLEAUTOALTREF, ctx->auto_alt_ref);
if (ctx->arnr_max_frames >= 0)
codecctl_int(avctx, VP8E_SET_ARNR_MAXFRAMES, ctx->arnr_max_frames);
if (ctx->arnr_strength >= 0)
codecctl_int(avctx, VP8E_SET_ARNR_STRENGTH, ctx->arnr_strength);
if (ctx->arnr_type >= 0)
codecctl_int(avctx, VP8E_SET_ARNR_TYPE, ctx->arnr_type);
codecctl_int(avctx, VP8E_SET_NOISE_SENSITIVITY, avctx->noise_reduction);
codecctl_int(avctx, VP8E_SET_TOKEN_PARTITIONS, av_log2(avctx->slices));
codecctl_int(avctx, VP8E_SET_STATIC_THRESHOLD, avctx->mb_threshold);
codecctl_int(avctx, VP8E_SET_CQ_LEVEL, ctx->crf);
if (ctx->max_intra_rate >= 0)
codecctl_int(avctx, VP8E_SET_MAX_INTRA_BITRATE_PCT, ctx->max_intra_rate);
av_log(avctx, AV_LOG_DEBUG, "Using deadline: %d\n", ctx->deadline);
vpx_img_wrap(&ctx->rawimg, VPX_IMG_FMT_I420, avctx->width, avctx->height, 1,
(unsigned char*)1);
avctx->coded_frame = avcodec_alloc_frame();
if (!avctx->coded_frame) {
av_log(avctx, AV_LOG_ERROR, "Error allocating coded frame\n");
vp8_free(avctx);
return AVERROR(ENOMEM);
}
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"VP8Context *ctx = avctx->priv_data;",
"const struct vpx_codec_iface *VAR_0 = &vpx_codec_vp8_cx_algo;",
"struct vpx_codec_enc_cfg VAR_1;",
"int VAR_2;",
"av_log(avctx, AV_LOG_INFO, \"%s\\n\", vpx_codec_version_str());",
"av_log(avctx, AV_LOG_VERBOSE, \"%s\\n\", vpx_codec_build_config());",
"if ((VAR_2 = vpx_codec_enc_config_default(VAR_0, &VAR_1, 0)) != VPX_CODEC_OK) {",
"av_log(avctx, AV_LOG_ERROR, \"Failed to get config: %s\\n\",\nvpx_codec_err_to_string(VAR_2));",
"return AVERROR(EINVAL);",
"}",
"dump_enc_cfg(avctx, &VAR_1);",
"VAR_1.g_w = avctx->width;",
"VAR_1.g_h = avctx->height;",
"VAR_1.g_timebase.num = avctx->time_base.num;",
"VAR_1.g_timebase.den = avctx->time_base.den;",
"VAR_1.g_threads = avctx->thread_count;",
"VAR_1.g_lag_in_frames= ctx->lag_in_frames;",
"if (avctx->flags & CODEC_FLAG_PASS1)\nVAR_1.g_pass = VPX_RC_FIRST_PASS;",
"else if (avctx->flags & CODEC_FLAG_PASS2)\nVAR_1.g_pass = VPX_RC_LAST_PASS;",
"else\nVAR_1.g_pass = VPX_RC_ONE_PASS;",
"if (avctx->rc_min_rate == avctx->rc_max_rate &&\navctx->rc_min_rate == avctx->bit_rate)\nVAR_1.rc_end_usage = VPX_CBR;",
"else if (ctx->crf)\nVAR_1.rc_end_usage = VPX_CQ;",
"VAR_1.rc_target_bitrate = av_rescale_rnd(avctx->bit_rate, 1, 1000,\nAV_ROUND_NEAR_INF);",
"if (avctx->qmin > 0)\nVAR_1.rc_min_quantizer = avctx->qmin;",
"if (avctx->qmax > 0)\nVAR_1.rc_max_quantizer = avctx->qmax;",
"VAR_1.rc_dropframe_thresh = avctx->frame_skip_threshold;",
"VAR_1.rc_2pass_vbr_bias_pct = round(avctx->qcompress * 100);",
"VAR_1.rc_2pass_vbr_minsection_pct =\navctx->rc_min_rate * 100LL / avctx->bit_rate;",
"if (avctx->rc_max_rate)\nVAR_1.rc_2pass_vbr_maxsection_pct =\navctx->rc_max_rate * 100LL / avctx->bit_rate;",
"if (avctx->rc_buffer_size)\nVAR_1.rc_buf_sz =\navctx->rc_buffer_size * 1000LL / avctx->bit_rate;",
"if (avctx->rc_initial_buffer_occupancy)\nVAR_1.rc_buf_initial_sz =\navctx->rc_initial_buffer_occupancy * 1000LL / avctx->bit_rate;",
"VAR_1.rc_buf_optimal_sz = VAR_1.rc_buf_sz * 5 / 6;",
"VAR_1.rc_undershoot_pct = round(avctx->rc_buffer_aggressivity * 100);",
"if (avctx->keyint_min >= 0 && avctx->keyint_min == avctx->gop_size)\nVAR_1.kf_min_dist = avctx->keyint_min;",
"if (avctx->gop_size >= 0)\nVAR_1.kf_max_dist = avctx->gop_size;",
"if (VAR_1.g_pass == VPX_RC_FIRST_PASS)\nVAR_1.g_lag_in_frames = 0;",
"else if (VAR_1.g_pass == VPX_RC_LAST_PASS) {",
"int VAR_3;",
"if (!avctx->stats_in) {",
"av_log(avctx, AV_LOG_ERROR, \"No stats file for second pass\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"ctx->twopass_stats.sz = strlen(avctx->stats_in) * 3 / 4;",
"ctx->twopass_stats.buf = av_malloc(ctx->twopass_stats.sz);",
"if (!ctx->twopass_stats.buf) {",
"av_log(avctx, AV_LOG_ERROR,\n\"Stat buffer alloc (%zu bytes) failed\\n\",\nctx->twopass_stats.sz);",
"return AVERROR(ENOMEM);",
"}",
"VAR_3 = av_base64_decode(ctx->twopass_stats.buf, avctx->stats_in,\nctx->twopass_stats.sz);",
"if (VAR_3 < 0) {",
"av_log(avctx, AV_LOG_ERROR, \"Stat buffer decode failed\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"ctx->twopass_stats.sz = VAR_3;",
"VAR_1.rc_twopass_stats_in = ctx->twopass_stats;",
"}",
"if (avctx->profile != FF_PROFILE_UNKNOWN)\nVAR_1.g_profile = avctx->profile;",
"VAR_1.g_error_resilient = ctx->error_resilient || ctx->flags & VP8F_ERROR_RESILIENT;",
"dump_enc_cfg(avctx, &VAR_1);",
"VAR_2 = vpx_codec_enc_init(&ctx->encoder, VAR_0, &VAR_1, 0);",
"if (VAR_2 != VPX_CODEC_OK) {",
"log_encoder_error(avctx, \"Failed to initialize encoder\");",
"return AVERROR(EINVAL);",
"}",
"av_log(avctx, AV_LOG_DEBUG, \"vpx_codec_control\\n\");",
"if (ctx->cpu_used != INT_MIN)\ncodecctl_int(avctx, VP8E_SET_CPUUSED, ctx->cpu_used);",
"if (ctx->flags & VP8F_AUTO_ALT_REF)\nctx->auto_alt_ref = 1;",
"if (ctx->auto_alt_ref >= 0)\ncodecctl_int(avctx, VP8E_SET_ENABLEAUTOALTREF, ctx->auto_alt_ref);",
"if (ctx->arnr_max_frames >= 0)\ncodecctl_int(avctx, VP8E_SET_ARNR_MAXFRAMES, ctx->arnr_max_frames);",
"if (ctx->arnr_strength >= 0)\ncodecctl_int(avctx, VP8E_SET_ARNR_STRENGTH, ctx->arnr_strength);",
"if (ctx->arnr_type >= 0)\ncodecctl_int(avctx, VP8E_SET_ARNR_TYPE, ctx->arnr_type);",
"codecctl_int(avctx, VP8E_SET_NOISE_SENSITIVITY, avctx->noise_reduction);",
"codecctl_int(avctx, VP8E_SET_TOKEN_PARTITIONS, av_log2(avctx->slices));",
"codecctl_int(avctx, VP8E_SET_STATIC_THRESHOLD, avctx->mb_threshold);",
"codecctl_int(avctx, VP8E_SET_CQ_LEVEL, ctx->crf);",
"if (ctx->max_intra_rate >= 0)\ncodecctl_int(avctx, VP8E_SET_MAX_INTRA_BITRATE_PCT, ctx->max_intra_rate);",
"av_log(avctx, AV_LOG_DEBUG, \"Using deadline: %d\\n\", ctx->deadline);",
"vpx_img_wrap(&ctx->rawimg, VPX_IMG_FMT_I420, avctx->width, avctx->height, 1,\n(unsigned char*)1);",
"avctx->coded_frame = avcodec_alloc_frame();",
"if (!avctx->coded_frame) {",
"av_log(avctx, AV_LOG_ERROR, \"Error allocating coded frame\\n\");",
"vp8_free(avctx);",
"return AVERROR(ENOMEM);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49,
51
],
[
53,
55
],
[
57,
59
],
[
63,
65,
67
],
[
69,
71
],
[
73,
75
],
[
77,
79
],
[
81,
83
],
[
85
],
[
91
],
[
93,
95
],
[
97,
99,
101
],
[
105,
107,
109
],
[
111,
113,
115
],
[
117
],
[
119
],
[
125,
127
],
[
129,
131
],
[
135,
137
],
[
139
],
[
141
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161,
163,
165
],
[
167
],
[
169
],
[
171,
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
185
],
[
187
],
[
189
],
[
199,
201
],
[
205
],
[
209
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
227
],
[
229,
231
],
[
233,
235
],
[
237,
239
],
[
241,
243
],
[
245,
247
],
[
249,
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261,
263
],
[
267
],
[
273,
275
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
]
] |
3,177 | unsigned long virtio_load_direct(ulong rec_list1, ulong rec_list2,
ulong subchan_id, void *load_addr)
{
u8 status;
int sec = rec_list1;
int sec_num = ((rec_list2 >> 32) & 0xffff) + 1;
int sec_len = rec_list2 >> 48;
ulong addr = (ulong)load_addr;
if (sec_len != virtio_get_block_size()) {
return -1;
}
sclp_print(".");
status = virtio_read_many(sec, (void *)addr, sec_num);
if (status) {
virtio_panic("I/O Error");
}
addr += sec_num * virtio_get_block_size();
return addr;
}
| true | qemu | c9262e8a84a29f22fbb5edde5d17f4f6166d5ae1 | unsigned long virtio_load_direct(ulong rec_list1, ulong rec_list2,
ulong subchan_id, void *load_addr)
{
u8 status;
int sec = rec_list1;
int sec_num = ((rec_list2 >> 32) & 0xffff) + 1;
int sec_len = rec_list2 >> 48;
ulong addr = (ulong)load_addr;
if (sec_len != virtio_get_block_size()) {
return -1;
}
sclp_print(".");
status = virtio_read_many(sec, (void *)addr, sec_num);
if (status) {
virtio_panic("I/O Error");
}
addr += sec_num * virtio_get_block_size();
return addr;
}
| {
"code": [
" virtio_panic(\"I/O Error\");"
],
"line_no": [
33
]
} | unsigned long FUNC_0(ulong VAR_0, ulong VAR_1,
ulong VAR_2, void *VAR_3)
{
u8 status;
int VAR_4 = VAR_0;
int VAR_5 = ((VAR_1 >> 32) & 0xffff) + 1;
int VAR_6 = VAR_1 >> 48;
ulong addr = (ulong)VAR_3;
if (VAR_6 != virtio_get_block_size()) {
return -1;
}
sclp_print(".");
status = virtio_read_many(VAR_4, (void *)addr, VAR_5);
if (status) {
virtio_panic("I/O Error");
}
addr += VAR_5 * virtio_get_block_size();
return addr;
}
| [
"unsigned long FUNC_0(ulong VAR_0, ulong VAR_1,\nulong VAR_2, void *VAR_3)\n{",
"u8 status;",
"int VAR_4 = VAR_0;",
"int VAR_5 = ((VAR_1 >> 32) & 0xffff) + 1;",
"int VAR_6 = VAR_1 >> 48;",
"ulong addr = (ulong)VAR_3;",
"if (VAR_6 != virtio_get_block_size()) {",
"return -1;",
"}",
"sclp_print(\".\");",
"status = virtio_read_many(VAR_4, (void *)addr, VAR_5);",
"if (status) {",
"virtio_panic(\"I/O Error\");",
"}",
"addr += VAR_5 * virtio_get_block_size();",
"return addr;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
]
] |
3,178 | void restore_boot_order(void *opaque)
{
char *normal_boot_order = opaque;
static int first = 1;
/* Restore boot order and remove ourselves after the first boot */
if (first) {
first = 0;
return;
}
qemu_boot_set(normal_boot_order, NULL);
qemu_unregister_reset(restore_boot_order, normal_boot_order);
g_free(normal_boot_order);
}
| true | qemu | 76349f5ba8f4e2f0b8c93c12ec0950a8bc77408a | void restore_boot_order(void *opaque)
{
char *normal_boot_order = opaque;
static int first = 1;
if (first) {
first = 0;
return;
}
qemu_boot_set(normal_boot_order, NULL);
qemu_unregister_reset(restore_boot_order, normal_boot_order);
g_free(normal_boot_order);
}
| {
"code": [
" qemu_boot_set(normal_boot_order, NULL);"
],
"line_no": [
23
]
} | void FUNC_0(void *VAR_0)
{
char *VAR_1 = VAR_0;
static int VAR_2 = 1;
if (VAR_2) {
VAR_2 = 0;
return;
}
qemu_boot_set(VAR_1, NULL);
qemu_unregister_reset(FUNC_0, VAR_1);
g_free(VAR_1);
}
| [
"void FUNC_0(void *VAR_0)\n{",
"char *VAR_1 = VAR_0;",
"static int VAR_2 = 1;",
"if (VAR_2) {",
"VAR_2 = 0;",
"return;",
"}",
"qemu_boot_set(VAR_1, NULL);",
"qemu_unregister_reset(FUNC_0, VAR_1);",
"g_free(VAR_1);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
27
],
[
29
],
[
31
]
] |
3,181 | static int vmdaudio_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
const uint8_t *buf_end;
int buf_size = avpkt->size;
VmdAudioContext *s = avctx->priv_data;
int block_type, silent_chunks, audio_chunks;
int ret;
uint8_t *output_samples_u8;
int16_t *output_samples_s16;
if (buf_size < 16) {
av_log(avctx, AV_LOG_WARNING, "skipping small junk packet\n");
*got_frame_ptr = 0;
return buf_size;
}
block_type = buf[6];
if (block_type < BLOCK_TYPE_AUDIO || block_type > BLOCK_TYPE_SILENCE) {
av_log(avctx, AV_LOG_ERROR, "unknown block type: %d\n", block_type);
return AVERROR(EINVAL);
}
buf += 16;
buf_size -= 16;
/* get number of silent chunks */
silent_chunks = 0;
if (block_type == BLOCK_TYPE_INITIAL) {
uint32_t flags;
if (buf_size < 4) {
av_log(avctx, AV_LOG_ERROR, "packet is too small\n");
return AVERROR(EINVAL);
}
flags = AV_RB32(buf);
silent_chunks = av_popcount(flags);
buf += 4;
buf_size -= 4;
} else if (block_type == BLOCK_TYPE_SILENCE) {
silent_chunks = 1;
buf_size = 0; // should already be zero but set it just to be sure
}
/* ensure output buffer is large enough */
audio_chunks = buf_size / s->chunk_size;
/* get output buffer */
frame->nb_samples = ((silent_chunks + audio_chunks) * avctx->block_align) /
avctx->channels;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
output_samples_u8 = frame->data[0];
output_samples_s16 = (int16_t *)frame->data[0];
/* decode silent chunks */
if (silent_chunks > 0) {
int silent_size = avctx->block_align * silent_chunks;
if (s->out_bps == 2) {
memset(output_samples_s16, 0x00, silent_size * 2);
output_samples_s16 += silent_size;
} else {
memset(output_samples_u8, 0x80, silent_size);
output_samples_u8 += silent_size;
}
}
/* decode audio chunks */
if (audio_chunks > 0) {
buf_end = buf + buf_size;
while (buf < buf_end) {
if (s->out_bps == 2) {
decode_audio_s16(output_samples_s16, buf, s->chunk_size,
avctx->channels);
output_samples_s16 += avctx->block_align;
} else {
memcpy(output_samples_u8, buf, s->chunk_size);
output_samples_u8 += avctx->block_align;
}
buf += s->chunk_size;
}
}
*got_frame_ptr = 1;
return avpkt->size;
}
| true | FFmpeg | f86d66bcfa48998b0727aa0d1089a30cbeae0933 | static int vmdaudio_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
const uint8_t *buf_end;
int buf_size = avpkt->size;
VmdAudioContext *s = avctx->priv_data;
int block_type, silent_chunks, audio_chunks;
int ret;
uint8_t *output_samples_u8;
int16_t *output_samples_s16;
if (buf_size < 16) {
av_log(avctx, AV_LOG_WARNING, "skipping small junk packet\n");
*got_frame_ptr = 0;
return buf_size;
}
block_type = buf[6];
if (block_type < BLOCK_TYPE_AUDIO || block_type > BLOCK_TYPE_SILENCE) {
av_log(avctx, AV_LOG_ERROR, "unknown block type: %d\n", block_type);
return AVERROR(EINVAL);
}
buf += 16;
buf_size -= 16;
silent_chunks = 0;
if (block_type == BLOCK_TYPE_INITIAL) {
uint32_t flags;
if (buf_size < 4) {
av_log(avctx, AV_LOG_ERROR, "packet is too small\n");
return AVERROR(EINVAL);
}
flags = AV_RB32(buf);
silent_chunks = av_popcount(flags);
buf += 4;
buf_size -= 4;
} else if (block_type == BLOCK_TYPE_SILENCE) {
silent_chunks = 1;
buf_size = 0;
}
audio_chunks = buf_size / s->chunk_size;
frame->nb_samples = ((silent_chunks + audio_chunks) * avctx->block_align) /
avctx->channels;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
output_samples_u8 = frame->data[0];
output_samples_s16 = (int16_t *)frame->data[0];
if (silent_chunks > 0) {
int silent_size = avctx->block_align * silent_chunks;
if (s->out_bps == 2) {
memset(output_samples_s16, 0x00, silent_size * 2);
output_samples_s16 += silent_size;
} else {
memset(output_samples_u8, 0x80, silent_size);
output_samples_u8 += silent_size;
}
}
if (audio_chunks > 0) {
buf_end = buf + buf_size;
while (buf < buf_end) {
if (s->out_bps == 2) {
decode_audio_s16(output_samples_s16, buf, s->chunk_size,
avctx->channels);
output_samples_s16 += avctx->block_align;
} else {
memcpy(output_samples_u8, buf, s->chunk_size);
output_samples_u8 += avctx->block_align;
}
buf += s->chunk_size;
}
}
*got_frame_ptr = 1;
return avpkt->size;
}
| {
"code": [
" while (buf < buf_end) {"
],
"line_no": [
145
]
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{
AVFrame *frame = VAR_1;
const uint8_t *VAR_4 = VAR_3->VAR_1;
const uint8_t *VAR_5;
int VAR_6 = VAR_3->size;
VmdAudioContext *s = VAR_0->priv_data;
int VAR_7, VAR_8, VAR_9;
int VAR_10;
uint8_t *output_samples_u8;
int16_t *output_samples_s16;
if (VAR_6 < 16) {
av_log(VAR_0, AV_LOG_WARNING, "skipping small junk packet\n");
*VAR_2 = 0;
return VAR_6;
}
VAR_7 = VAR_4[6];
if (VAR_7 < BLOCK_TYPE_AUDIO || VAR_7 > BLOCK_TYPE_SILENCE) {
av_log(VAR_0, AV_LOG_ERROR, "unknown block type: %d\n", VAR_7);
return AVERROR(EINVAL);
}
VAR_4 += 16;
VAR_6 -= 16;
VAR_8 = 0;
if (VAR_7 == BLOCK_TYPE_INITIAL) {
uint32_t flags;
if (VAR_6 < 4) {
av_log(VAR_0, AV_LOG_ERROR, "packet is too small\n");
return AVERROR(EINVAL);
}
flags = AV_RB32(VAR_4);
VAR_8 = av_popcount(flags);
VAR_4 += 4;
VAR_6 -= 4;
} else if (VAR_7 == BLOCK_TYPE_SILENCE) {
VAR_8 = 1;
VAR_6 = 0;
}
VAR_9 = VAR_6 / s->chunk_size;
frame->nb_samples = ((VAR_8 + VAR_9) * VAR_0->block_align) /
VAR_0->channels;
if ((VAR_10 = ff_get_buffer(VAR_0, frame, 0)) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");
return VAR_10;
}
output_samples_u8 = frame->VAR_1[0];
output_samples_s16 = (int16_t *)frame->VAR_1[0];
if (VAR_8 > 0) {
int VAR_11 = VAR_0->block_align * VAR_8;
if (s->out_bps == 2) {
memset(output_samples_s16, 0x00, VAR_11 * 2);
output_samples_s16 += VAR_11;
} else {
memset(output_samples_u8, 0x80, VAR_11);
output_samples_u8 += VAR_11;
}
}
if (VAR_9 > 0) {
VAR_5 = VAR_4 + VAR_6;
while (VAR_4 < VAR_5) {
if (s->out_bps == 2) {
decode_audio_s16(output_samples_s16, VAR_4, s->chunk_size,
VAR_0->channels);
output_samples_s16 += VAR_0->block_align;
} else {
memcpy(output_samples_u8, VAR_4, s->chunk_size);
output_samples_u8 += VAR_0->block_align;
}
VAR_4 += s->chunk_size;
}
}
*VAR_2 = 1;
return VAR_3->size;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{",
"AVFrame *frame = VAR_1;",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"const uint8_t *VAR_5;",
"int VAR_6 = VAR_3->size;",
"VmdAudioContext *s = VAR_0->priv_data;",
"int VAR_7, VAR_8, VAR_9;",
"int VAR_10;",
"uint8_t *output_samples_u8;",
"int16_t *output_samples_s16;",
"if (VAR_6 < 16) {",
"av_log(VAR_0, AV_LOG_WARNING, \"skipping small junk packet\\n\");",
"*VAR_2 = 0;",
"return VAR_6;",
"}",
"VAR_7 = VAR_4[6];",
"if (VAR_7 < BLOCK_TYPE_AUDIO || VAR_7 > BLOCK_TYPE_SILENCE) {",
"av_log(VAR_0, AV_LOG_ERROR, \"unknown block type: %d\\n\", VAR_7);",
"return AVERROR(EINVAL);",
"}",
"VAR_4 += 16;",
"VAR_6 -= 16;",
"VAR_8 = 0;",
"if (VAR_7 == BLOCK_TYPE_INITIAL) {",
"uint32_t flags;",
"if (VAR_6 < 4) {",
"av_log(VAR_0, AV_LOG_ERROR, \"packet is too small\\n\");",
"return AVERROR(EINVAL);",
"}",
"flags = AV_RB32(VAR_4);",
"VAR_8 = av_popcount(flags);",
"VAR_4 += 4;",
"VAR_6 -= 4;",
"} else if (VAR_7 == BLOCK_TYPE_SILENCE) {",
"VAR_8 = 1;",
"VAR_6 = 0;",
"}",
"VAR_9 = VAR_6 / s->chunk_size;",
"frame->nb_samples = ((VAR_8 + VAR_9) * VAR_0->block_align) /\nVAR_0->channels;",
"if ((VAR_10 = ff_get_buffer(VAR_0, frame, 0)) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"get_buffer() failed\\n\");",
"return VAR_10;",
"}",
"output_samples_u8 = frame->VAR_1[0];",
"output_samples_s16 = (int16_t *)frame->VAR_1[0];",
"if (VAR_8 > 0) {",
"int VAR_11 = VAR_0->block_align * VAR_8;",
"if (s->out_bps == 2) {",
"memset(output_samples_s16, 0x00, VAR_11 * 2);",
"output_samples_s16 += VAR_11;",
"} else {",
"memset(output_samples_u8, 0x80, VAR_11);",
"output_samples_u8 += VAR_11;",
"}",
"}",
"if (VAR_9 > 0) {",
"VAR_5 = VAR_4 + VAR_6;",
"while (VAR_4 < VAR_5) {",
"if (s->out_bps == 2) {",
"decode_audio_s16(output_samples_s16, VAR_4, s->chunk_size,\nVAR_0->channels);",
"output_samples_s16 += VAR_0->block_align;",
"} else {",
"memcpy(output_samples_u8, VAR_4, s->chunk_size);",
"output_samples_u8 += VAR_0->block_align;",
"}",
"VAR_4 += s->chunk_size;",
"}",
"}",
"*VAR_2 = 1;",
"return VAR_3->size;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
91
],
[
97,
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149,
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
171
],
[
175
],
[
177
]
] |
3,185 | static int convert_sub_to_old_ass_form(AVSubtitle *sub, const AVPacket *pkt, AVRational tb)
{
int i;
AVBPrint buf;
av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED);
for (i = 0; i < sub->num_rects; i++) {
char *final_dialog;
const char *dialog;
AVSubtitleRect *rect = sub->rects[i];
int ts_start, ts_duration = -1;
long int layer;
if (rect->type != SUBTITLE_ASS || !strncmp(rect->ass, "Dialogue ", 10))
continue;
av_bprint_clear(&buf);
/* skip ReadOrder */
dialog = strchr(rect->ass, ',');
if (!dialog)
continue;
dialog++;
/* extract Layer or Marked */
layer = strtol(dialog, (char**)&dialog, 10);
if (*dialog != ',')
continue;
dialog++;
/* rescale timing to ASS time base (ms) */
ts_start = av_rescale_q(pkt->pts, tb, av_make_q(1, 100));
if (pkt->duration != -1)
ts_duration = av_rescale_q(pkt->duration, tb, av_make_q(1, 100));
sub->end_display_time = FFMAX(sub->end_display_time, 10 * ts_duration);
/* construct ASS (standalone file form with timestamps) string */
av_bprintf(&buf, "Dialogue: %ld,", layer);
insert_ts(&buf, ts_start);
insert_ts(&buf, ts_duration == -1 ? -1 : ts_start + ts_duration);
av_bprintf(&buf, "%s\r\n", dialog);
final_dialog = av_strdup(buf.str);
if (!av_bprint_is_complete(&buf) || !final_dialog) {
av_freep(&final_dialog);
av_bprint_finalize(&buf, NULL);
return AVERROR(ENOMEM);
}
av_freep(&rect->ass);
rect->ass = final_dialog;
}
av_bprint_finalize(&buf, NULL);
return 0;
}
| true | FFmpeg | 2b7a61cbd8ae134f839c4347a4c289e1e11475a3 | static int convert_sub_to_old_ass_form(AVSubtitle *sub, const AVPacket *pkt, AVRational tb)
{
int i;
AVBPrint buf;
av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED);
for (i = 0; i < sub->num_rects; i++) {
char *final_dialog;
const char *dialog;
AVSubtitleRect *rect = sub->rects[i];
int ts_start, ts_duration = -1;
long int layer;
if (rect->type != SUBTITLE_ASS || !strncmp(rect->ass, "Dialogue ", 10))
continue;
av_bprint_clear(&buf);
dialog = strchr(rect->ass, ',');
if (!dialog)
continue;
dialog++;
layer = strtol(dialog, (char**)&dialog, 10);
if (*dialog != ',')
continue;
dialog++;
ts_start = av_rescale_q(pkt->pts, tb, av_make_q(1, 100));
if (pkt->duration != -1)
ts_duration = av_rescale_q(pkt->duration, tb, av_make_q(1, 100));
sub->end_display_time = FFMAX(sub->end_display_time, 10 * ts_duration);
av_bprintf(&buf, "Dialogue: %ld,", layer);
insert_ts(&buf, ts_start);
insert_ts(&buf, ts_duration == -1 ? -1 : ts_start + ts_duration);
av_bprintf(&buf, "%s\r\n", dialog);
final_dialog = av_strdup(buf.str);
if (!av_bprint_is_complete(&buf) || !final_dialog) {
av_freep(&final_dialog);
av_bprint_finalize(&buf, NULL);
return AVERROR(ENOMEM);
}
av_freep(&rect->ass);
rect->ass = final_dialog;
}
av_bprint_finalize(&buf, NULL);
return 0;
}
| {
"code": [
" if (rect->type != SUBTITLE_ASS || !strncmp(rect->ass, \"Dialogue \", 10))"
],
"line_no": [
29
]
} | static int FUNC_0(AVSubtitle *VAR_0, const AVPacket *VAR_1, AVRational VAR_2)
{
int VAR_3;
AVBPrint buf;
av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED);
for (VAR_3 = 0; VAR_3 < VAR_0->num_rects; VAR_3++) {
char *final_dialog;
const char *dialog;
AVSubtitleRect *rect = VAR_0->rects[VAR_3];
int ts_start, ts_duration = -1;
long int layer;
if (rect->type != SUBTITLE_ASS || !strncmp(rect->ass, "Dialogue ", 10))
continue;
av_bprint_clear(&buf);
dialog = strchr(rect->ass, ',');
if (!dialog)
continue;
dialog++;
layer = strtol(dialog, (char**)&dialog, 10);
if (*dialog != ',')
continue;
dialog++;
ts_start = av_rescale_q(VAR_1->pts, VAR_2, av_make_q(1, 100));
if (VAR_1->duration != -1)
ts_duration = av_rescale_q(VAR_1->duration, VAR_2, av_make_q(1, 100));
VAR_0->end_display_time = FFMAX(VAR_0->end_display_time, 10 * ts_duration);
av_bprintf(&buf, "Dialogue: %ld,", layer);
insert_ts(&buf, ts_start);
insert_ts(&buf, ts_duration == -1 ? -1 : ts_start + ts_duration);
av_bprintf(&buf, "%s\r\n", dialog);
final_dialog = av_strdup(buf.str);
if (!av_bprint_is_complete(&buf) || !final_dialog) {
av_freep(&final_dialog);
av_bprint_finalize(&buf, NULL);
return AVERROR(ENOMEM);
}
av_freep(&rect->ass);
rect->ass = final_dialog;
}
av_bprint_finalize(&buf, NULL);
return 0;
}
| [
"static int FUNC_0(AVSubtitle *VAR_0, const AVPacket *VAR_1, AVRational VAR_2)\n{",
"int VAR_3;",
"AVBPrint buf;",
"av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED);",
"for (VAR_3 = 0; VAR_3 < VAR_0->num_rects; VAR_3++) {",
"char *final_dialog;",
"const char *dialog;",
"AVSubtitleRect *rect = VAR_0->rects[VAR_3];",
"int ts_start, ts_duration = -1;",
"long int layer;",
"if (rect->type != SUBTITLE_ASS || !strncmp(rect->ass, \"Dialogue \", 10))\ncontinue;",
"av_bprint_clear(&buf);",
"dialog = strchr(rect->ass, ',');",
"if (!dialog)\ncontinue;",
"dialog++;",
"layer = strtol(dialog, (char**)&dialog, 10);",
"if (*dialog != ',')\ncontinue;",
"dialog++;",
"ts_start = av_rescale_q(VAR_1->pts, VAR_2, av_make_q(1, 100));",
"if (VAR_1->duration != -1)\nts_duration = av_rescale_q(VAR_1->duration, VAR_2, av_make_q(1, 100));",
"VAR_0->end_display_time = FFMAX(VAR_0->end_display_time, 10 * ts_duration);",
"av_bprintf(&buf, \"Dialogue: %ld,\", layer);",
"insert_ts(&buf, ts_start);",
"insert_ts(&buf, ts_duration == -1 ? -1 : ts_start + ts_duration);",
"av_bprintf(&buf, \"%s\\r\\n\", dialog);",
"final_dialog = av_strdup(buf.str);",
"if (!av_bprint_is_complete(&buf) || !final_dialog) {",
"av_freep(&final_dialog);",
"av_bprint_finalize(&buf, NULL);",
"return AVERROR(ENOMEM);",
"}",
"av_freep(&rect->ass);",
"rect->ass = final_dialog;",
"}",
"av_bprint_finalize(&buf, NULL);",
"return 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29,
31
],
[
35
],
[
41
],
[
43,
45
],
[
47
],
[
53
],
[
55,
57
],
[
59
],
[
65
],
[
67,
69
],
[
71
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
]
] |
3,186 | static av_cold int bmp_encode_init(AVCodecContext *avctx){
switch (avctx->pix_fmt) {
case AV_PIX_FMT_BGR24:
avctx->bits_per_coded_sample = 24;
break;
case AV_PIX_FMT_RGB555:
case AV_PIX_FMT_RGB565:
case AV_PIX_FMT_RGB444:
avctx->bits_per_coded_sample = 16;
break;
case AV_PIX_FMT_RGB8:
case AV_PIX_FMT_BGR8:
case AV_PIX_FMT_RGB4_BYTE:
case AV_PIX_FMT_BGR4_BYTE:
case AV_PIX_FMT_GRAY8:
case AV_PIX_FMT_PAL8:
avctx->bits_per_coded_sample = 8;
break;
case AV_PIX_FMT_MONOBLACK:
avctx->bits_per_coded_sample = 1;
break;
default:
av_log(avctx, AV_LOG_INFO, "unsupported pixel format\n");
return -1;
}
avctx->coded_frame = av_frame_alloc();
if (!avctx->coded_frame)
return AVERROR(ENOMEM);
return 0;
}
| false | FFmpeg | d6604b29ef544793479d7fb4e05ef6622bb3e534 | static av_cold int bmp_encode_init(AVCodecContext *avctx){
switch (avctx->pix_fmt) {
case AV_PIX_FMT_BGR24:
avctx->bits_per_coded_sample = 24;
break;
case AV_PIX_FMT_RGB555:
case AV_PIX_FMT_RGB565:
case AV_PIX_FMT_RGB444:
avctx->bits_per_coded_sample = 16;
break;
case AV_PIX_FMT_RGB8:
case AV_PIX_FMT_BGR8:
case AV_PIX_FMT_RGB4_BYTE:
case AV_PIX_FMT_BGR4_BYTE:
case AV_PIX_FMT_GRAY8:
case AV_PIX_FMT_PAL8:
avctx->bits_per_coded_sample = 8;
break;
case AV_PIX_FMT_MONOBLACK:
avctx->bits_per_coded_sample = 1;
break;
default:
av_log(avctx, AV_LOG_INFO, "unsupported pixel format\n");
return -1;
}
avctx->coded_frame = av_frame_alloc();
if (!avctx->coded_frame)
return AVERROR(ENOMEM);
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx){
switch (avctx->pix_fmt) {
case AV_PIX_FMT_BGR24:
avctx->bits_per_coded_sample = 24;
break;
case AV_PIX_FMT_RGB555:
case AV_PIX_FMT_RGB565:
case AV_PIX_FMT_RGB444:
avctx->bits_per_coded_sample = 16;
break;
case AV_PIX_FMT_RGB8:
case AV_PIX_FMT_BGR8:
case AV_PIX_FMT_RGB4_BYTE:
case AV_PIX_FMT_BGR4_BYTE:
case AV_PIX_FMT_GRAY8:
case AV_PIX_FMT_PAL8:
avctx->bits_per_coded_sample = 8;
break;
case AV_PIX_FMT_MONOBLACK:
avctx->bits_per_coded_sample = 1;
break;
default:
av_log(avctx, AV_LOG_INFO, "unsupported pixel format\n");
return -1;
}
avctx->coded_frame = av_frame_alloc();
if (!avctx->coded_frame)
return AVERROR(ENOMEM);
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx){",
"switch (avctx->pix_fmt) {",
"case AV_PIX_FMT_BGR24:\navctx->bits_per_coded_sample = 24;",
"break;",
"case AV_PIX_FMT_RGB555:\ncase AV_PIX_FMT_RGB565:\ncase AV_PIX_FMT_RGB444:\navctx->bits_per_coded_sample = 16;",
"break;",
"case AV_PIX_FMT_RGB8:\ncase AV_PIX_FMT_BGR8:\ncase AV_PIX_FMT_RGB4_BYTE:\ncase AV_PIX_FMT_BGR4_BYTE:\ncase AV_PIX_FMT_GRAY8:\ncase AV_PIX_FMT_PAL8:\navctx->bits_per_coded_sample = 8;",
"break;",
"case AV_PIX_FMT_MONOBLACK:\navctx->bits_per_coded_sample = 1;",
"break;",
"default:\nav_log(avctx, AV_LOG_INFO, \"unsupported pixel format\\n\");",
"return -1;",
"}",
"avctx->coded_frame = av_frame_alloc();",
"if (!avctx->coded_frame)\nreturn AVERROR(ENOMEM);",
"return 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
],
[
53
],
[
55,
57
],
[
61
],
[
63
]
] |
3,188 | static int ape_read_header(AVFormatContext * s)
{
AVIOContext *pb = s->pb;
APEContext *ape = s->priv_data;
AVStream *st;
uint32_t tag;
int i;
int total_blocks, final_size = 0;
int64_t pts, file_size;
/* Skip any leading junk such as id3v2 tags */
ape->junklength = avio_tell(pb);
tag = avio_rl32(pb);
if (tag != MKTAG('M', 'A', 'C', ' '))
return -1;
ape->fileversion = avio_rl16(pb);
if (ape->fileversion < APE_MIN_VERSION || ape->fileversion > APE_MAX_VERSION) {
av_log(s, AV_LOG_ERROR, "Unsupported file version - %d.%02d\n",
ape->fileversion / 1000, (ape->fileversion % 1000) / 10);
return -1;
}
if (ape->fileversion >= 3980) {
ape->padding1 = avio_rl16(pb);
ape->descriptorlength = avio_rl32(pb);
ape->headerlength = avio_rl32(pb);
ape->seektablelength = avio_rl32(pb);
ape->wavheaderlength = avio_rl32(pb);
ape->audiodatalength = avio_rl32(pb);
ape->audiodatalength_high = avio_rl32(pb);
ape->wavtaillength = avio_rl32(pb);
avio_read(pb, ape->md5, 16);
/* Skip any unknown bytes at the end of the descriptor.
This is for future compatibility */
if (ape->descriptorlength > 52)
avio_skip(pb, ape->descriptorlength - 52);
/* Read header data */
ape->compressiontype = avio_rl16(pb);
ape->formatflags = avio_rl16(pb);
ape->blocksperframe = avio_rl32(pb);
ape->finalframeblocks = avio_rl32(pb);
ape->totalframes = avio_rl32(pb);
ape->bps = avio_rl16(pb);
ape->channels = avio_rl16(pb);
ape->samplerate = avio_rl32(pb);
} else {
ape->descriptorlength = 0;
ape->headerlength = 32;
ape->compressiontype = avio_rl16(pb);
ape->formatflags = avio_rl16(pb);
ape->channels = avio_rl16(pb);
ape->samplerate = avio_rl32(pb);
ape->wavheaderlength = avio_rl32(pb);
ape->wavtaillength = avio_rl32(pb);
ape->totalframes = avio_rl32(pb);
ape->finalframeblocks = avio_rl32(pb);
if (ape->formatflags & MAC_FORMAT_FLAG_HAS_PEAK_LEVEL) {
avio_skip(pb, 4); /* Skip the peak level */
ape->headerlength += 4;
}
if (ape->formatflags & MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS) {
ape->seektablelength = avio_rl32(pb);
ape->headerlength += 4;
ape->seektablelength *= sizeof(int32_t);
} else
ape->seektablelength = ape->totalframes * sizeof(int32_t);
if (ape->formatflags & MAC_FORMAT_FLAG_8_BIT)
ape->bps = 8;
else if (ape->formatflags & MAC_FORMAT_FLAG_24_BIT)
ape->bps = 24;
else
ape->bps = 16;
if (ape->fileversion >= 3950)
ape->blocksperframe = 73728 * 4;
else if (ape->fileversion >= 3900 || (ape->fileversion >= 3800 && ape->compressiontype >= 4000))
ape->blocksperframe = 73728;
else
ape->blocksperframe = 9216;
/* Skip any stored wav header */
if (!(ape->formatflags & MAC_FORMAT_FLAG_CREATE_WAV_HEADER))
avio_skip(pb, ape->wavheaderlength);
}
if(!ape->totalframes){
av_log(s, AV_LOG_ERROR, "No frames in the file!\n");
return AVERROR(EINVAL);
}
if(ape->totalframes > UINT_MAX / sizeof(APEFrame)){
av_log(s, AV_LOG_ERROR, "Too many frames: %"PRIu32"\n",
ape->totalframes);
return -1;
}
if (ape->seektablelength / sizeof(*ape->seektable) < ape->totalframes) {
av_log(s, AV_LOG_ERROR,
"Number of seek entries is less than number of frames: %zu vs. %"PRIu32"\n",
ape->seektablelength / sizeof(*ape->seektable), ape->totalframes);
return AVERROR_INVALIDDATA;
}
ape->frames = av_malloc(ape->totalframes * sizeof(APEFrame));
if(!ape->frames)
return AVERROR(ENOMEM);
ape->firstframe = ape->junklength + ape->descriptorlength + ape->headerlength + ape->seektablelength + ape->wavheaderlength;
if (ape->fileversion < 3810)
ape->firstframe += ape->totalframes;
ape->currentframe = 0;
ape->totalsamples = ape->finalframeblocks;
if (ape->totalframes > 1)
ape->totalsamples += ape->blocksperframe * (ape->totalframes - 1);
if (ape->seektablelength > 0) {
ape->seektable = av_malloc(ape->seektablelength);
if (!ape->seektable)
return AVERROR(ENOMEM);
for (i = 0; i < ape->seektablelength / sizeof(uint32_t) && !pb->eof_reached; i++)
ape->seektable[i] = avio_rl32(pb);
if (ape->fileversion < 3810) {
ape->bittable = av_malloc(ape->totalframes);
if (!ape->bittable)
return AVERROR(ENOMEM);
for (i = 0; i < ape->totalframes && !pb->eof_reached; i++)
ape->bittable[i] = avio_r8(pb);
}
}
ape->frames[0].pos = ape->firstframe;
ape->frames[0].nblocks = ape->blocksperframe;
ape->frames[0].skip = 0;
for (i = 1; i < ape->totalframes; i++) {
ape->frames[i].pos = ape->seektable[i] + ape->junklength;
ape->frames[i].nblocks = ape->blocksperframe;
ape->frames[i - 1].size = ape->frames[i].pos - ape->frames[i - 1].pos;
ape->frames[i].skip = (ape->frames[i].pos - ape->frames[0].pos) & 3;
}
ape->frames[ape->totalframes - 1].nblocks = ape->finalframeblocks;
/* calculate final packet size from total file size, if available */
file_size = avio_size(pb);
if (file_size > 0) {
final_size = file_size - ape->frames[ape->totalframes - 1].pos -
ape->wavtaillength;
final_size -= final_size & 3;
}
if (file_size <= 0 || final_size <= 0)
final_size = ape->finalframeblocks * 8;
ape->frames[ape->totalframes - 1].size = final_size;
for (i = 0; i < ape->totalframes; i++) {
if(ape->frames[i].skip){
ape->frames[i].pos -= ape->frames[i].skip;
ape->frames[i].size += ape->frames[i].skip;
}
ape->frames[i].size = (ape->frames[i].size + 3) & ~3;
}
if (ape->fileversion < 3810) {
for (i = 0; i < ape->totalframes; i++) {
if (i < ape->totalframes - 1 && ape->bittable[i + 1])
ape->frames[i].size += 4;
ape->frames[i].skip <<= 3;
ape->frames[i].skip += ape->bittable[i];
}
}
ape_dumpinfo(s, ape);
av_log(s, AV_LOG_DEBUG, "Decoding file - v%d.%02d, compression level %"PRIu16"\n",
ape->fileversion / 1000, (ape->fileversion % 1000) / 10,
ape->compressiontype);
/* now we are ready: build format streams */
st = avformat_new_stream(s, NULL);
if (!st)
return -1;
total_blocks = (ape->totalframes == 0) ? 0 : ((ape->totalframes - 1) * ape->blocksperframe) + ape->finalframeblocks;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_APE;
st->codecpar->codec_tag = MKTAG('A', 'P', 'E', ' ');
st->codecpar->channels = ape->channels;
st->codecpar->sample_rate = ape->samplerate;
st->codecpar->bits_per_coded_sample = ape->bps;
st->nb_frames = ape->totalframes;
st->start_time = 0;
st->duration = total_blocks / MAC_SUBFRAME_SIZE;
avpriv_set_pts_info(st, 64, MAC_SUBFRAME_SIZE, ape->samplerate);
st->codecpar->extradata = av_malloc(APE_EXTRADATA_SIZE);
st->codecpar->extradata_size = APE_EXTRADATA_SIZE;
AV_WL16(st->codecpar->extradata + 0, ape->fileversion);
AV_WL16(st->codecpar->extradata + 2, ape->compressiontype);
AV_WL16(st->codecpar->extradata + 4, ape->formatflags);
pts = 0;
for (i = 0; i < ape->totalframes; i++) {
ape->frames[i].pts = pts;
av_add_index_entry(st, ape->frames[i].pos, ape->frames[i].pts, 0, 0, AVINDEX_KEYFRAME);
pts += ape->blocksperframe / MAC_SUBFRAME_SIZE;
}
/* try to read APE tags */
if (pb->seekable) {
ff_ape_parse_tag(s);
avio_seek(pb, 0, SEEK_SET);
}
return 0;
}
| false | FFmpeg | 83548fe894cdb455cc127f754d09905b6d23c173 | static int ape_read_header(AVFormatContext * s)
{
AVIOContext *pb = s->pb;
APEContext *ape = s->priv_data;
AVStream *st;
uint32_t tag;
int i;
int total_blocks, final_size = 0;
int64_t pts, file_size;
ape->junklength = avio_tell(pb);
tag = avio_rl32(pb);
if (tag != MKTAG('M', 'A', 'C', ' '))
return -1;
ape->fileversion = avio_rl16(pb);
if (ape->fileversion < APE_MIN_VERSION || ape->fileversion > APE_MAX_VERSION) {
av_log(s, AV_LOG_ERROR, "Unsupported file version - %d.%02d\n",
ape->fileversion / 1000, (ape->fileversion % 1000) / 10);
return -1;
}
if (ape->fileversion >= 3980) {
ape->padding1 = avio_rl16(pb);
ape->descriptorlength = avio_rl32(pb);
ape->headerlength = avio_rl32(pb);
ape->seektablelength = avio_rl32(pb);
ape->wavheaderlength = avio_rl32(pb);
ape->audiodatalength = avio_rl32(pb);
ape->audiodatalength_high = avio_rl32(pb);
ape->wavtaillength = avio_rl32(pb);
avio_read(pb, ape->md5, 16);
if (ape->descriptorlength > 52)
avio_skip(pb, ape->descriptorlength - 52);
ape->compressiontype = avio_rl16(pb);
ape->formatflags = avio_rl16(pb);
ape->blocksperframe = avio_rl32(pb);
ape->finalframeblocks = avio_rl32(pb);
ape->totalframes = avio_rl32(pb);
ape->bps = avio_rl16(pb);
ape->channels = avio_rl16(pb);
ape->samplerate = avio_rl32(pb);
} else {
ape->descriptorlength = 0;
ape->headerlength = 32;
ape->compressiontype = avio_rl16(pb);
ape->formatflags = avio_rl16(pb);
ape->channels = avio_rl16(pb);
ape->samplerate = avio_rl32(pb);
ape->wavheaderlength = avio_rl32(pb);
ape->wavtaillength = avio_rl32(pb);
ape->totalframes = avio_rl32(pb);
ape->finalframeblocks = avio_rl32(pb);
if (ape->formatflags & MAC_FORMAT_FLAG_HAS_PEAK_LEVEL) {
avio_skip(pb, 4);
ape->headerlength += 4;
}
if (ape->formatflags & MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS) {
ape->seektablelength = avio_rl32(pb);
ape->headerlength += 4;
ape->seektablelength *= sizeof(int32_t);
} else
ape->seektablelength = ape->totalframes * sizeof(int32_t);
if (ape->formatflags & MAC_FORMAT_FLAG_8_BIT)
ape->bps = 8;
else if (ape->formatflags & MAC_FORMAT_FLAG_24_BIT)
ape->bps = 24;
else
ape->bps = 16;
if (ape->fileversion >= 3950)
ape->blocksperframe = 73728 * 4;
else if (ape->fileversion >= 3900 || (ape->fileversion >= 3800 && ape->compressiontype >= 4000))
ape->blocksperframe = 73728;
else
ape->blocksperframe = 9216;
if (!(ape->formatflags & MAC_FORMAT_FLAG_CREATE_WAV_HEADER))
avio_skip(pb, ape->wavheaderlength);
}
if(!ape->totalframes){
av_log(s, AV_LOG_ERROR, "No frames in the file!\n");
return AVERROR(EINVAL);
}
if(ape->totalframes > UINT_MAX / sizeof(APEFrame)){
av_log(s, AV_LOG_ERROR, "Too many frames: %"PRIu32"\n",
ape->totalframes);
return -1;
}
if (ape->seektablelength / sizeof(*ape->seektable) < ape->totalframes) {
av_log(s, AV_LOG_ERROR,
"Number of seek entries is less than number of frames: %zu vs. %"PRIu32"\n",
ape->seektablelength / sizeof(*ape->seektable), ape->totalframes);
return AVERROR_INVALIDDATA;
}
ape->frames = av_malloc(ape->totalframes * sizeof(APEFrame));
if(!ape->frames)
return AVERROR(ENOMEM);
ape->firstframe = ape->junklength + ape->descriptorlength + ape->headerlength + ape->seektablelength + ape->wavheaderlength;
if (ape->fileversion < 3810)
ape->firstframe += ape->totalframes;
ape->currentframe = 0;
ape->totalsamples = ape->finalframeblocks;
if (ape->totalframes > 1)
ape->totalsamples += ape->blocksperframe * (ape->totalframes - 1);
if (ape->seektablelength > 0) {
ape->seektable = av_malloc(ape->seektablelength);
if (!ape->seektable)
return AVERROR(ENOMEM);
for (i = 0; i < ape->seektablelength / sizeof(uint32_t) && !pb->eof_reached; i++)
ape->seektable[i] = avio_rl32(pb);
if (ape->fileversion < 3810) {
ape->bittable = av_malloc(ape->totalframes);
if (!ape->bittable)
return AVERROR(ENOMEM);
for (i = 0; i < ape->totalframes && !pb->eof_reached; i++)
ape->bittable[i] = avio_r8(pb);
}
}
ape->frames[0].pos = ape->firstframe;
ape->frames[0].nblocks = ape->blocksperframe;
ape->frames[0].skip = 0;
for (i = 1; i < ape->totalframes; i++) {
ape->frames[i].pos = ape->seektable[i] + ape->junklength;
ape->frames[i].nblocks = ape->blocksperframe;
ape->frames[i - 1].size = ape->frames[i].pos - ape->frames[i - 1].pos;
ape->frames[i].skip = (ape->frames[i].pos - ape->frames[0].pos) & 3;
}
ape->frames[ape->totalframes - 1].nblocks = ape->finalframeblocks;
file_size = avio_size(pb);
if (file_size > 0) {
final_size = file_size - ape->frames[ape->totalframes - 1].pos -
ape->wavtaillength;
final_size -= final_size & 3;
}
if (file_size <= 0 || final_size <= 0)
final_size = ape->finalframeblocks * 8;
ape->frames[ape->totalframes - 1].size = final_size;
for (i = 0; i < ape->totalframes; i++) {
if(ape->frames[i].skip){
ape->frames[i].pos -= ape->frames[i].skip;
ape->frames[i].size += ape->frames[i].skip;
}
ape->frames[i].size = (ape->frames[i].size + 3) & ~3;
}
if (ape->fileversion < 3810) {
for (i = 0; i < ape->totalframes; i++) {
if (i < ape->totalframes - 1 && ape->bittable[i + 1])
ape->frames[i].size += 4;
ape->frames[i].skip <<= 3;
ape->frames[i].skip += ape->bittable[i];
}
}
ape_dumpinfo(s, ape);
av_log(s, AV_LOG_DEBUG, "Decoding file - v%d.%02d, compression level %"PRIu16"\n",
ape->fileversion / 1000, (ape->fileversion % 1000) / 10,
ape->compressiontype);
st = avformat_new_stream(s, NULL);
if (!st)
return -1;
total_blocks = (ape->totalframes == 0) ? 0 : ((ape->totalframes - 1) * ape->blocksperframe) + ape->finalframeblocks;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_APE;
st->codecpar->codec_tag = MKTAG('A', 'P', 'E', ' ');
st->codecpar->channels = ape->channels;
st->codecpar->sample_rate = ape->samplerate;
st->codecpar->bits_per_coded_sample = ape->bps;
st->nb_frames = ape->totalframes;
st->start_time = 0;
st->duration = total_blocks / MAC_SUBFRAME_SIZE;
avpriv_set_pts_info(st, 64, MAC_SUBFRAME_SIZE, ape->samplerate);
st->codecpar->extradata = av_malloc(APE_EXTRADATA_SIZE);
st->codecpar->extradata_size = APE_EXTRADATA_SIZE;
AV_WL16(st->codecpar->extradata + 0, ape->fileversion);
AV_WL16(st->codecpar->extradata + 2, ape->compressiontype);
AV_WL16(st->codecpar->extradata + 4, ape->formatflags);
pts = 0;
for (i = 0; i < ape->totalframes; i++) {
ape->frames[i].pts = pts;
av_add_index_entry(st, ape->frames[i].pos, ape->frames[i].pts, 0, 0, AVINDEX_KEYFRAME);
pts += ape->blocksperframe / MAC_SUBFRAME_SIZE;
}
if (pb->seekable) {
ff_ape_parse_tag(s);
avio_seek(pb, 0, SEEK_SET);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext * VAR_0)
{
AVIOContext *pb = VAR_0->pb;
APEContext *ape = VAR_0->priv_data;
AVStream *st;
uint32_t tag;
int VAR_1;
int VAR_2, VAR_3 = 0;
int64_t pts, file_size;
ape->junklength = avio_tell(pb);
tag = avio_rl32(pb);
if (tag != MKTAG('M', 'A', 'C', ' '))
return -1;
ape->fileversion = avio_rl16(pb);
if (ape->fileversion < APE_MIN_VERSION || ape->fileversion > APE_MAX_VERSION) {
av_log(VAR_0, AV_LOG_ERROR, "Unsupported file version - %d.%02d\n",
ape->fileversion / 1000, (ape->fileversion % 1000) / 10);
return -1;
}
if (ape->fileversion >= 3980) {
ape->padding1 = avio_rl16(pb);
ape->descriptorlength = avio_rl32(pb);
ape->headerlength = avio_rl32(pb);
ape->seektablelength = avio_rl32(pb);
ape->wavheaderlength = avio_rl32(pb);
ape->audiodatalength = avio_rl32(pb);
ape->audiodatalength_high = avio_rl32(pb);
ape->wavtaillength = avio_rl32(pb);
avio_read(pb, ape->md5, 16);
if (ape->descriptorlength > 52)
avio_skip(pb, ape->descriptorlength - 52);
ape->compressiontype = avio_rl16(pb);
ape->formatflags = avio_rl16(pb);
ape->blocksperframe = avio_rl32(pb);
ape->finalframeblocks = avio_rl32(pb);
ape->totalframes = avio_rl32(pb);
ape->bps = avio_rl16(pb);
ape->channels = avio_rl16(pb);
ape->samplerate = avio_rl32(pb);
} else {
ape->descriptorlength = 0;
ape->headerlength = 32;
ape->compressiontype = avio_rl16(pb);
ape->formatflags = avio_rl16(pb);
ape->channels = avio_rl16(pb);
ape->samplerate = avio_rl32(pb);
ape->wavheaderlength = avio_rl32(pb);
ape->wavtaillength = avio_rl32(pb);
ape->totalframes = avio_rl32(pb);
ape->finalframeblocks = avio_rl32(pb);
if (ape->formatflags & MAC_FORMAT_FLAG_HAS_PEAK_LEVEL) {
avio_skip(pb, 4);
ape->headerlength += 4;
}
if (ape->formatflags & MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS) {
ape->seektablelength = avio_rl32(pb);
ape->headerlength += 4;
ape->seektablelength *= sizeof(int32_t);
} else
ape->seektablelength = ape->totalframes * sizeof(int32_t);
if (ape->formatflags & MAC_FORMAT_FLAG_8_BIT)
ape->bps = 8;
else if (ape->formatflags & MAC_FORMAT_FLAG_24_BIT)
ape->bps = 24;
else
ape->bps = 16;
if (ape->fileversion >= 3950)
ape->blocksperframe = 73728 * 4;
else if (ape->fileversion >= 3900 || (ape->fileversion >= 3800 && ape->compressiontype >= 4000))
ape->blocksperframe = 73728;
else
ape->blocksperframe = 9216;
if (!(ape->formatflags & MAC_FORMAT_FLAG_CREATE_WAV_HEADER))
avio_skip(pb, ape->wavheaderlength);
}
if(!ape->totalframes){
av_log(VAR_0, AV_LOG_ERROR, "No frames in the file!\n");
return AVERROR(EINVAL);
}
if(ape->totalframes > UINT_MAX / sizeof(APEFrame)){
av_log(VAR_0, AV_LOG_ERROR, "Too many frames: %"PRIu32"\n",
ape->totalframes);
return -1;
}
if (ape->seektablelength / sizeof(*ape->seektable) < ape->totalframes) {
av_log(VAR_0, AV_LOG_ERROR,
"Number of seek entries is less than number of frames: %zu vs. %"PRIu32"\n",
ape->seektablelength / sizeof(*ape->seektable), ape->totalframes);
return AVERROR_INVALIDDATA;
}
ape->frames = av_malloc(ape->totalframes * sizeof(APEFrame));
if(!ape->frames)
return AVERROR(ENOMEM);
ape->firstframe = ape->junklength + ape->descriptorlength + ape->headerlength + ape->seektablelength + ape->wavheaderlength;
if (ape->fileversion < 3810)
ape->firstframe += ape->totalframes;
ape->currentframe = 0;
ape->totalsamples = ape->finalframeblocks;
if (ape->totalframes > 1)
ape->totalsamples += ape->blocksperframe * (ape->totalframes - 1);
if (ape->seektablelength > 0) {
ape->seektable = av_malloc(ape->seektablelength);
if (!ape->seektable)
return AVERROR(ENOMEM);
for (VAR_1 = 0; VAR_1 < ape->seektablelength / sizeof(uint32_t) && !pb->eof_reached; VAR_1++)
ape->seektable[VAR_1] = avio_rl32(pb);
if (ape->fileversion < 3810) {
ape->bittable = av_malloc(ape->totalframes);
if (!ape->bittable)
return AVERROR(ENOMEM);
for (VAR_1 = 0; VAR_1 < ape->totalframes && !pb->eof_reached; VAR_1++)
ape->bittable[VAR_1] = avio_r8(pb);
}
}
ape->frames[0].pos = ape->firstframe;
ape->frames[0].nblocks = ape->blocksperframe;
ape->frames[0].skip = 0;
for (VAR_1 = 1; VAR_1 < ape->totalframes; VAR_1++) {
ape->frames[VAR_1].pos = ape->seektable[VAR_1] + ape->junklength;
ape->frames[VAR_1].nblocks = ape->blocksperframe;
ape->frames[VAR_1 - 1].size = ape->frames[VAR_1].pos - ape->frames[VAR_1 - 1].pos;
ape->frames[VAR_1].skip = (ape->frames[VAR_1].pos - ape->frames[0].pos) & 3;
}
ape->frames[ape->totalframes - 1].nblocks = ape->finalframeblocks;
file_size = avio_size(pb);
if (file_size > 0) {
VAR_3 = file_size - ape->frames[ape->totalframes - 1].pos -
ape->wavtaillength;
VAR_3 -= VAR_3 & 3;
}
if (file_size <= 0 || VAR_3 <= 0)
VAR_3 = ape->finalframeblocks * 8;
ape->frames[ape->totalframes - 1].size = VAR_3;
for (VAR_1 = 0; VAR_1 < ape->totalframes; VAR_1++) {
if(ape->frames[VAR_1].skip){
ape->frames[VAR_1].pos -= ape->frames[VAR_1].skip;
ape->frames[VAR_1].size += ape->frames[VAR_1].skip;
}
ape->frames[VAR_1].size = (ape->frames[VAR_1].size + 3) & ~3;
}
if (ape->fileversion < 3810) {
for (VAR_1 = 0; VAR_1 < ape->totalframes; VAR_1++) {
if (VAR_1 < ape->totalframes - 1 && ape->bittable[VAR_1 + 1])
ape->frames[VAR_1].size += 4;
ape->frames[VAR_1].skip <<= 3;
ape->frames[VAR_1].skip += ape->bittable[VAR_1];
}
}
ape_dumpinfo(VAR_0, ape);
av_log(VAR_0, AV_LOG_DEBUG, "Decoding file - v%d.%02d, compression level %"PRIu16"\n",
ape->fileversion / 1000, (ape->fileversion % 1000) / 10,
ape->compressiontype);
st = avformat_new_stream(VAR_0, NULL);
if (!st)
return -1;
VAR_2 = (ape->totalframes == 0) ? 0 : ((ape->totalframes - 1) * ape->blocksperframe) + ape->finalframeblocks;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_APE;
st->codecpar->codec_tag = MKTAG('A', 'P', 'E', ' ');
st->codecpar->channels = ape->channels;
st->codecpar->sample_rate = ape->samplerate;
st->codecpar->bits_per_coded_sample = ape->bps;
st->nb_frames = ape->totalframes;
st->start_time = 0;
st->duration = VAR_2 / MAC_SUBFRAME_SIZE;
avpriv_set_pts_info(st, 64, MAC_SUBFRAME_SIZE, ape->samplerate);
st->codecpar->extradata = av_malloc(APE_EXTRADATA_SIZE);
st->codecpar->extradata_size = APE_EXTRADATA_SIZE;
AV_WL16(st->codecpar->extradata + 0, ape->fileversion);
AV_WL16(st->codecpar->extradata + 2, ape->compressiontype);
AV_WL16(st->codecpar->extradata + 4, ape->formatflags);
pts = 0;
for (VAR_1 = 0; VAR_1 < ape->totalframes; VAR_1++) {
ape->frames[VAR_1].pts = pts;
av_add_index_entry(st, ape->frames[VAR_1].pos, ape->frames[VAR_1].pts, 0, 0, AVINDEX_KEYFRAME);
pts += ape->blocksperframe / MAC_SUBFRAME_SIZE;
}
if (pb->seekable) {
ff_ape_parse_tag(VAR_0);
avio_seek(pb, 0, SEEK_SET);
}
return 0;
}
| [
"static int FUNC_0(AVFormatContext * VAR_0)\n{",
"AVIOContext *pb = VAR_0->pb;",
"APEContext *ape = VAR_0->priv_data;",
"AVStream *st;",
"uint32_t tag;",
"int VAR_1;",
"int VAR_2, VAR_3 = 0;",
"int64_t pts, file_size;",
"ape->junklength = avio_tell(pb);",
"tag = avio_rl32(pb);",
"if (tag != MKTAG('M', 'A', 'C', ' '))\nreturn -1;",
"ape->fileversion = avio_rl16(pb);",
"if (ape->fileversion < APE_MIN_VERSION || ape->fileversion > APE_MAX_VERSION) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Unsupported file version - %d.%02d\\n\",\nape->fileversion / 1000, (ape->fileversion % 1000) / 10);",
"return -1;",
"}",
"if (ape->fileversion >= 3980) {",
"ape->padding1 = avio_rl16(pb);",
"ape->descriptorlength = avio_rl32(pb);",
"ape->headerlength = avio_rl32(pb);",
"ape->seektablelength = avio_rl32(pb);",
"ape->wavheaderlength = avio_rl32(pb);",
"ape->audiodatalength = avio_rl32(pb);",
"ape->audiodatalength_high = avio_rl32(pb);",
"ape->wavtaillength = avio_rl32(pb);",
"avio_read(pb, ape->md5, 16);",
"if (ape->descriptorlength > 52)\navio_skip(pb, ape->descriptorlength - 52);",
"ape->compressiontype = avio_rl16(pb);",
"ape->formatflags = avio_rl16(pb);",
"ape->blocksperframe = avio_rl32(pb);",
"ape->finalframeblocks = avio_rl32(pb);",
"ape->totalframes = avio_rl32(pb);",
"ape->bps = avio_rl16(pb);",
"ape->channels = avio_rl16(pb);",
"ape->samplerate = avio_rl32(pb);",
"} else {",
"ape->descriptorlength = 0;",
"ape->headerlength = 32;",
"ape->compressiontype = avio_rl16(pb);",
"ape->formatflags = avio_rl16(pb);",
"ape->channels = avio_rl16(pb);",
"ape->samplerate = avio_rl32(pb);",
"ape->wavheaderlength = avio_rl32(pb);",
"ape->wavtaillength = avio_rl32(pb);",
"ape->totalframes = avio_rl32(pb);",
"ape->finalframeblocks = avio_rl32(pb);",
"if (ape->formatflags & MAC_FORMAT_FLAG_HAS_PEAK_LEVEL) {",
"avio_skip(pb, 4);",
"ape->headerlength += 4;",
"}",
"if (ape->formatflags & MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS) {",
"ape->seektablelength = avio_rl32(pb);",
"ape->headerlength += 4;",
"ape->seektablelength *= sizeof(int32_t);",
"} else",
"ape->seektablelength = ape->totalframes * sizeof(int32_t);",
"if (ape->formatflags & MAC_FORMAT_FLAG_8_BIT)\nape->bps = 8;",
"else if (ape->formatflags & MAC_FORMAT_FLAG_24_BIT)\nape->bps = 24;",
"else\nape->bps = 16;",
"if (ape->fileversion >= 3950)\nape->blocksperframe = 73728 * 4;",
"else if (ape->fileversion >= 3900 || (ape->fileversion >= 3800 && ape->compressiontype >= 4000))\nape->blocksperframe = 73728;",
"else\nape->blocksperframe = 9216;",
"if (!(ape->formatflags & MAC_FORMAT_FLAG_CREATE_WAV_HEADER))\navio_skip(pb, ape->wavheaderlength);",
"}",
"if(!ape->totalframes){",
"av_log(VAR_0, AV_LOG_ERROR, \"No frames in the file!\\n\");",
"return AVERROR(EINVAL);",
"}",
"if(ape->totalframes > UINT_MAX / sizeof(APEFrame)){",
"av_log(VAR_0, AV_LOG_ERROR, \"Too many frames: %\"PRIu32\"\\n\",\nape->totalframes);",
"return -1;",
"}",
"if (ape->seektablelength / sizeof(*ape->seektable) < ape->totalframes) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Number of seek entries is less than number of frames: %zu vs. %\"PRIu32\"\\n\",\nape->seektablelength / sizeof(*ape->seektable), ape->totalframes);",
"return AVERROR_INVALIDDATA;",
"}",
"ape->frames = av_malloc(ape->totalframes * sizeof(APEFrame));",
"if(!ape->frames)\nreturn AVERROR(ENOMEM);",
"ape->firstframe = ape->junklength + ape->descriptorlength + ape->headerlength + ape->seektablelength + ape->wavheaderlength;",
"if (ape->fileversion < 3810)\nape->firstframe += ape->totalframes;",
"ape->currentframe = 0;",
"ape->totalsamples = ape->finalframeblocks;",
"if (ape->totalframes > 1)\nape->totalsamples += ape->blocksperframe * (ape->totalframes - 1);",
"if (ape->seektablelength > 0) {",
"ape->seektable = av_malloc(ape->seektablelength);",
"if (!ape->seektable)\nreturn AVERROR(ENOMEM);",
"for (VAR_1 = 0; VAR_1 < ape->seektablelength / sizeof(uint32_t) && !pb->eof_reached; VAR_1++)",
"ape->seektable[VAR_1] = avio_rl32(pb);",
"if (ape->fileversion < 3810) {",
"ape->bittable = av_malloc(ape->totalframes);",
"if (!ape->bittable)\nreturn AVERROR(ENOMEM);",
"for (VAR_1 = 0; VAR_1 < ape->totalframes && !pb->eof_reached; VAR_1++)",
"ape->bittable[VAR_1] = avio_r8(pb);",
"}",
"}",
"ape->frames[0].pos = ape->firstframe;",
"ape->frames[0].nblocks = ape->blocksperframe;",
"ape->frames[0].skip = 0;",
"for (VAR_1 = 1; VAR_1 < ape->totalframes; VAR_1++) {",
"ape->frames[VAR_1].pos = ape->seektable[VAR_1] + ape->junklength;",
"ape->frames[VAR_1].nblocks = ape->blocksperframe;",
"ape->frames[VAR_1 - 1].size = ape->frames[VAR_1].pos - ape->frames[VAR_1 - 1].pos;",
"ape->frames[VAR_1].skip = (ape->frames[VAR_1].pos - ape->frames[0].pos) & 3;",
"}",
"ape->frames[ape->totalframes - 1].nblocks = ape->finalframeblocks;",
"file_size = avio_size(pb);",
"if (file_size > 0) {",
"VAR_3 = file_size - ape->frames[ape->totalframes - 1].pos -\nape->wavtaillength;",
"VAR_3 -= VAR_3 & 3;",
"}",
"if (file_size <= 0 || VAR_3 <= 0)\nVAR_3 = ape->finalframeblocks * 8;",
"ape->frames[ape->totalframes - 1].size = VAR_3;",
"for (VAR_1 = 0; VAR_1 < ape->totalframes; VAR_1++) {",
"if(ape->frames[VAR_1].skip){",
"ape->frames[VAR_1].pos -= ape->frames[VAR_1].skip;",
"ape->frames[VAR_1].size += ape->frames[VAR_1].skip;",
"}",
"ape->frames[VAR_1].size = (ape->frames[VAR_1].size + 3) & ~3;",
"}",
"if (ape->fileversion < 3810) {",
"for (VAR_1 = 0; VAR_1 < ape->totalframes; VAR_1++) {",
"if (VAR_1 < ape->totalframes - 1 && ape->bittable[VAR_1 + 1])\nape->frames[VAR_1].size += 4;",
"ape->frames[VAR_1].skip <<= 3;",
"ape->frames[VAR_1].skip += ape->bittable[VAR_1];",
"}",
"}",
"ape_dumpinfo(VAR_0, ape);",
"av_log(VAR_0, AV_LOG_DEBUG, \"Decoding file - v%d.%02d, compression level %\"PRIu16\"\\n\",\nape->fileversion / 1000, (ape->fileversion % 1000) / 10,\nape->compressiontype);",
"st = avformat_new_stream(VAR_0, NULL);",
"if (!st)\nreturn -1;",
"VAR_2 = (ape->totalframes == 0) ? 0 : ((ape->totalframes - 1) * ape->blocksperframe) + ape->finalframeblocks;",
"st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;",
"st->codecpar->codec_id = AV_CODEC_ID_APE;",
"st->codecpar->codec_tag = MKTAG('A', 'P', 'E', ' ');",
"st->codecpar->channels = ape->channels;",
"st->codecpar->sample_rate = ape->samplerate;",
"st->codecpar->bits_per_coded_sample = ape->bps;",
"st->nb_frames = ape->totalframes;",
"st->start_time = 0;",
"st->duration = VAR_2 / MAC_SUBFRAME_SIZE;",
"avpriv_set_pts_info(st, 64, MAC_SUBFRAME_SIZE, ape->samplerate);",
"st->codecpar->extradata = av_malloc(APE_EXTRADATA_SIZE);",
"st->codecpar->extradata_size = APE_EXTRADATA_SIZE;",
"AV_WL16(st->codecpar->extradata + 0, ape->fileversion);",
"AV_WL16(st->codecpar->extradata + 2, ape->compressiontype);",
"AV_WL16(st->codecpar->extradata + 4, ape->formatflags);",
"pts = 0;",
"for (VAR_1 = 0; VAR_1 < ape->totalframes; VAR_1++) {",
"ape->frames[VAR_1].pts = pts;",
"av_add_index_entry(st, ape->frames[VAR_1].pos, ape->frames[VAR_1].pts, 0, 0, AVINDEX_KEYFRAME);",
"pts += ape->blocksperframe / MAC_SUBFRAME_SIZE;",
"}",
"if (pb->seekable) {",
"ff_ape_parse_tag(VAR_0);",
"avio_seek(pb, 0, SEEK_SET);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
27
],
[
29,
31
],
[
35
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
77,
79
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
151,
153
],
[
155,
157
],
[
159,
161
],
[
165,
167
],
[
169,
171
],
[
173,
175
],
[
181,
183
],
[
185
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199,
201
],
[
203
],
[
205
],
[
207
],
[
209,
211,
213
],
[
215
],
[
217
],
[
219
],
[
221,
223
],
[
225
],
[
227,
229
],
[
231
],
[
237
],
[
239,
241
],
[
245
],
[
247
],
[
249,
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261,
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
297
],
[
299
],
[
301,
303
],
[
305
],
[
307
],
[
309,
311
],
[
313
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335,
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
349
],
[
353,
355,
357
],
[
363
],
[
365,
367
],
[
371
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
389
],
[
391
],
[
393
],
[
395
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
427
],
[
429
],
[
431
],
[
433
],
[
437
],
[
439
]
] |
3,190 | static gboolean udp_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque)
{
CharDriverState *chr = opaque;
NetCharDriver *s = chr->opaque;
gsize bytes_read = 0;
GIOStatus status;
if (s->max_size == 0) {
return TRUE;
}
status = g_io_channel_read_chars(s->chan, (gchar *)s->buf, sizeof(s->buf),
&bytes_read, NULL);
s->bufcnt = bytes_read;
s->bufptr = s->bufcnt;
if (status != G_IO_STATUS_NORMAL) {
if (s->tag) {
g_source_remove(s->tag);
s->tag = 0;
}
return FALSE;
}
s->bufptr = 0;
while (s->max_size > 0 && s->bufptr < s->bufcnt) {
qemu_chr_be_write(chr, &s->buf[s->bufptr], 1);
s->bufptr++;
s->max_size = qemu_chr_be_can_write(chr);
}
return TRUE;
}
| true | qemu | 2b316774f60291f57ca9ecb6a9f0712c532cae34 | static gboolean udp_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque)
{
CharDriverState *chr = opaque;
NetCharDriver *s = chr->opaque;
gsize bytes_read = 0;
GIOStatus status;
if (s->max_size == 0) {
return TRUE;
}
status = g_io_channel_read_chars(s->chan, (gchar *)s->buf, sizeof(s->buf),
&bytes_read, NULL);
s->bufcnt = bytes_read;
s->bufptr = s->bufcnt;
if (status != G_IO_STATUS_NORMAL) {
if (s->tag) {
g_source_remove(s->tag);
s->tag = 0;
}
return FALSE;
}
s->bufptr = 0;
while (s->max_size > 0 && s->bufptr < s->bufcnt) {
qemu_chr_be_write(chr, &s->buf[s->bufptr], 1);
s->bufptr++;
s->max_size = qemu_chr_be_can_write(chr);
}
return TRUE;
}
| {
"code": [
" g_source_remove(s->tag);",
" g_source_remove(s->tag);",
" g_source_remove(s->tag);"
],
"line_no": [
33,
33,
33
]
} | static gboolean FUNC_0(GIOChannel *chan, GIOCondition cond, void *opaque)
{
CharDriverState *chr = opaque;
NetCharDriver *s = chr->opaque;
gsize bytes_read = 0;
GIOStatus status;
if (s->max_size == 0) {
return TRUE;
}
status = g_io_channel_read_chars(s->chan, (gchar *)s->buf, sizeof(s->buf),
&bytes_read, NULL);
s->bufcnt = bytes_read;
s->bufptr = s->bufcnt;
if (status != G_IO_STATUS_NORMAL) {
if (s->tag) {
g_source_remove(s->tag);
s->tag = 0;
}
return FALSE;
}
s->bufptr = 0;
while (s->max_size > 0 && s->bufptr < s->bufcnt) {
qemu_chr_be_write(chr, &s->buf[s->bufptr], 1);
s->bufptr++;
s->max_size = qemu_chr_be_can_write(chr);
}
return TRUE;
}
| [
"static gboolean FUNC_0(GIOChannel *chan, GIOCondition cond, void *opaque)\n{",
"CharDriverState *chr = opaque;",
"NetCharDriver *s = chr->opaque;",
"gsize bytes_read = 0;",
"GIOStatus status;",
"if (s->max_size == 0) {",
"return TRUE;",
"}",
"status = g_io_channel_read_chars(s->chan, (gchar *)s->buf, sizeof(s->buf),\n&bytes_read, NULL);",
"s->bufcnt = bytes_read;",
"s->bufptr = s->bufcnt;",
"if (status != G_IO_STATUS_NORMAL) {",
"if (s->tag) {",
"g_source_remove(s->tag);",
"s->tag = 0;",
"}",
"return FALSE;",
"}",
"s->bufptr = 0;",
"while (s->max_size > 0 && s->bufptr < s->bufcnt) {",
"qemu_chr_be_write(chr, &s->buf[s->bufptr], 1);",
"s->bufptr++;",
"s->max_size = qemu_chr_be_can_write(chr);",
"}",
"return TRUE;",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
]
] |
3,191 | static void pc_q35_init_1_4(QEMUMachineInitArgs *args)
{
pc_sysfw_flash_vs_rom_bug_compatible = true;
has_pvpanic = false;
x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);
pc_q35_init(args);
}
| true | qemu | 9e1c2ec8fd8d9a9ee299ea86c5f6c986fe25e838 | static void pc_q35_init_1_4(QEMUMachineInitArgs *args)
{
pc_sysfw_flash_vs_rom_bug_compatible = true;
has_pvpanic = false;
x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);
pc_q35_init(args);
}
| {
"code": [
" pc_sysfw_flash_vs_rom_bug_compatible = true;",
" pc_sysfw_flash_vs_rom_bug_compatible = true;",
" pc_sysfw_flash_vs_rom_bug_compatible = true;",
" pc_sysfw_flash_vs_rom_bug_compatible = true;"
],
"line_no": [
5,
5,
5,
5
]
} | static void FUNC_0(QEMUMachineInitArgs *VAR_0)
{
pc_sysfw_flash_vs_rom_bug_compatible = true;
has_pvpanic = false;
x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);
pc_q35_init(VAR_0);
}
| [
"static void FUNC_0(QEMUMachineInitArgs *VAR_0)\n{",
"pc_sysfw_flash_vs_rom_bug_compatible = true;",
"has_pvpanic = false;",
"x86_cpu_compat_set_features(\"n270\", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);",
"pc_q35_init(VAR_0);",
"}"
] | [
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
3,193 | void do_interrupt(CPUARMState *env)
{
uint32_t addr;
uint32_t mask;
int new_mode;
uint32_t offset;
if (IS_M(env)) {
do_interrupt_v7m(env);
return;
}
/* TODO: Vectored interrupt controller. */
switch (env->exception_index) {
case EXCP_UDEF:
new_mode = ARM_CPU_MODE_UND;
addr = 0x04;
mask = CPSR_I;
if (env->thumb)
offset = 2;
else
offset = 4;
break;
case EXCP_SWI:
if (semihosting_enabled) {
/* Check for semihosting interrupt. */
if (env->thumb) {
mask = lduw_code(env->regs[15] - 2) & 0xff;
} else {
mask = ldl_code(env->regs[15] - 4) & 0xffffff;
}
/* Only intercept calls from privileged modes, to provide some
semblance of security. */
if (((mask == 0x123456 && !env->thumb)
|| (mask == 0xab && env->thumb))
&& (env->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR) {
env->regs[0] = do_arm_semihosting(env);
return;
}
}
new_mode = ARM_CPU_MODE_SVC;
addr = 0x08;
mask = CPSR_I;
/* The PC already points to the next instruction. */
offset = 0;
break;
case EXCP_BKPT:
/* See if this is a semihosting syscall. */
if (env->thumb && semihosting_enabled) {
mask = lduw_code(env->regs[15]) & 0xff;
if (mask == 0xab
&& (env->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR) {
env->regs[15] += 2;
env->regs[0] = do_arm_semihosting(env);
return;
}
}
env->cp15.c5_insn = 2;
/* Fall through to prefetch abort. */
case EXCP_PREFETCH_ABORT:
new_mode = ARM_CPU_MODE_ABT;
addr = 0x0c;
mask = CPSR_A | CPSR_I;
offset = 4;
break;
case EXCP_DATA_ABORT:
new_mode = ARM_CPU_MODE_ABT;
addr = 0x10;
mask = CPSR_A | CPSR_I;
offset = 8;
break;
case EXCP_IRQ:
new_mode = ARM_CPU_MODE_IRQ;
addr = 0x18;
/* Disable IRQ and imprecise data aborts. */
mask = CPSR_A | CPSR_I;
offset = 4;
break;
case EXCP_FIQ:
new_mode = ARM_CPU_MODE_FIQ;
addr = 0x1c;
/* Disable FIQ, IRQ and imprecise data aborts. */
mask = CPSR_A | CPSR_I | CPSR_F;
offset = 4;
break;
default:
cpu_abort(env, "Unhandled exception 0x%x\n", env->exception_index);
return; /* Never happens. Keep compiler happy. */
}
/* High vectors. */
if (env->cp15.c1_sys & (1 << 13)) {
addr += 0xffff0000;
}
switch_mode (env, new_mode);
env->spsr = cpsr_read(env);
/* Clear IT bits. */
env->condexec_bits = 0;
/* Switch to the new mode, and to the correct instruction set. */
env->uncached_cpsr = (env->uncached_cpsr & ~CPSR_M) | new_mode;
env->uncached_cpsr |= mask;
/* this is a lie, as the was no c1_sys on V4T/V5, but who cares
* and we should just guard the thumb mode on V4 */
if (arm_feature(env, ARM_FEATURE_V4T)) {
env->thumb = (env->cp15.c1_sys & (1 << 30)) != 0;
}
env->regs[14] = env->regs[15] + offset;
env->regs[15] = addr;
env->interrupt_request |= CPU_INTERRUPT_EXITTB;
}
| true | qemu | d8fd2954996255ba6ad610917e7849832d0120b7 | void do_interrupt(CPUARMState *env)
{
uint32_t addr;
uint32_t mask;
int new_mode;
uint32_t offset;
if (IS_M(env)) {
do_interrupt_v7m(env);
return;
}
switch (env->exception_index) {
case EXCP_UDEF:
new_mode = ARM_CPU_MODE_UND;
addr = 0x04;
mask = CPSR_I;
if (env->thumb)
offset = 2;
else
offset = 4;
break;
case EXCP_SWI:
if (semihosting_enabled) {
if (env->thumb) {
mask = lduw_code(env->regs[15] - 2) & 0xff;
} else {
mask = ldl_code(env->regs[15] - 4) & 0xffffff;
}
if (((mask == 0x123456 && !env->thumb)
|| (mask == 0xab && env->thumb))
&& (env->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR) {
env->regs[0] = do_arm_semihosting(env);
return;
}
}
new_mode = ARM_CPU_MODE_SVC;
addr = 0x08;
mask = CPSR_I;
offset = 0;
break;
case EXCP_BKPT:
if (env->thumb && semihosting_enabled) {
mask = lduw_code(env->regs[15]) & 0xff;
if (mask == 0xab
&& (env->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR) {
env->regs[15] += 2;
env->regs[0] = do_arm_semihosting(env);
return;
}
}
env->cp15.c5_insn = 2;
case EXCP_PREFETCH_ABORT:
new_mode = ARM_CPU_MODE_ABT;
addr = 0x0c;
mask = CPSR_A | CPSR_I;
offset = 4;
break;
case EXCP_DATA_ABORT:
new_mode = ARM_CPU_MODE_ABT;
addr = 0x10;
mask = CPSR_A | CPSR_I;
offset = 8;
break;
case EXCP_IRQ:
new_mode = ARM_CPU_MODE_IRQ;
addr = 0x18;
mask = CPSR_A | CPSR_I;
offset = 4;
break;
case EXCP_FIQ:
new_mode = ARM_CPU_MODE_FIQ;
addr = 0x1c;
mask = CPSR_A | CPSR_I | CPSR_F;
offset = 4;
break;
default:
cpu_abort(env, "Unhandled exception 0x%x\n", env->exception_index);
return;
}
if (env->cp15.c1_sys & (1 << 13)) {
addr += 0xffff0000;
}
switch_mode (env, new_mode);
env->spsr = cpsr_read(env);
env->condexec_bits = 0;
env->uncached_cpsr = (env->uncached_cpsr & ~CPSR_M) | new_mode;
env->uncached_cpsr |= mask;
if (arm_feature(env, ARM_FEATURE_V4T)) {
env->thumb = (env->cp15.c1_sys & (1 << 30)) != 0;
}
env->regs[14] = env->regs[15] + offset;
env->regs[15] = addr;
env->interrupt_request |= CPU_INTERRUPT_EXITTB;
}
| {
"code": [
" mask = lduw_code(env->regs[15] - 2) & 0xff;",
" mask = ldl_code(env->regs[15] - 4) & 0xffffff;",
" mask = lduw_code(env->regs[15]) & 0xff;"
],
"line_no": [
53,
57,
97
]
} | void FUNC_0(CPUARMState *VAR_0)
{
uint32_t addr;
uint32_t mask;
int VAR_1;
uint32_t offset;
if (IS_M(VAR_0)) {
do_interrupt_v7m(VAR_0);
return;
}
switch (VAR_0->exception_index) {
case EXCP_UDEF:
VAR_1 = ARM_CPU_MODE_UND;
addr = 0x04;
mask = CPSR_I;
if (VAR_0->thumb)
offset = 2;
else
offset = 4;
break;
case EXCP_SWI:
if (semihosting_enabled) {
if (VAR_0->thumb) {
mask = lduw_code(VAR_0->regs[15] - 2) & 0xff;
} else {
mask = ldl_code(VAR_0->regs[15] - 4) & 0xffffff;
}
if (((mask == 0x123456 && !VAR_0->thumb)
|| (mask == 0xab && VAR_0->thumb))
&& (VAR_0->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR) {
VAR_0->regs[0] = do_arm_semihosting(VAR_0);
return;
}
}
VAR_1 = ARM_CPU_MODE_SVC;
addr = 0x08;
mask = CPSR_I;
offset = 0;
break;
case EXCP_BKPT:
if (VAR_0->thumb && semihosting_enabled) {
mask = lduw_code(VAR_0->regs[15]) & 0xff;
if (mask == 0xab
&& (VAR_0->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR) {
VAR_0->regs[15] += 2;
VAR_0->regs[0] = do_arm_semihosting(VAR_0);
return;
}
}
VAR_0->cp15.c5_insn = 2;
case EXCP_PREFETCH_ABORT:
VAR_1 = ARM_CPU_MODE_ABT;
addr = 0x0c;
mask = CPSR_A | CPSR_I;
offset = 4;
break;
case EXCP_DATA_ABORT:
VAR_1 = ARM_CPU_MODE_ABT;
addr = 0x10;
mask = CPSR_A | CPSR_I;
offset = 8;
break;
case EXCP_IRQ:
VAR_1 = ARM_CPU_MODE_IRQ;
addr = 0x18;
mask = CPSR_A | CPSR_I;
offset = 4;
break;
case EXCP_FIQ:
VAR_1 = ARM_CPU_MODE_FIQ;
addr = 0x1c;
mask = CPSR_A | CPSR_I | CPSR_F;
offset = 4;
break;
default:
cpu_abort(VAR_0, "Unhandled exception 0x%x\n", VAR_0->exception_index);
return;
}
if (VAR_0->cp15.c1_sys & (1 << 13)) {
addr += 0xffff0000;
}
switch_mode (VAR_0, VAR_1);
VAR_0->spsr = cpsr_read(VAR_0);
VAR_0->condexec_bits = 0;
VAR_0->uncached_cpsr = (VAR_0->uncached_cpsr & ~CPSR_M) | VAR_1;
VAR_0->uncached_cpsr |= mask;
if (arm_feature(VAR_0, ARM_FEATURE_V4T)) {
VAR_0->thumb = (VAR_0->cp15.c1_sys & (1 << 30)) != 0;
}
VAR_0->regs[14] = VAR_0->regs[15] + offset;
VAR_0->regs[15] = addr;
VAR_0->interrupt_request |= CPU_INTERRUPT_EXITTB;
}
| [
"void FUNC_0(CPUARMState *VAR_0)\n{",
"uint32_t addr;",
"uint32_t mask;",
"int VAR_1;",
"uint32_t offset;",
"if (IS_M(VAR_0)) {",
"do_interrupt_v7m(VAR_0);",
"return;",
"}",
"switch (VAR_0->exception_index) {",
"case EXCP_UDEF:\nVAR_1 = ARM_CPU_MODE_UND;",
"addr = 0x04;",
"mask = CPSR_I;",
"if (VAR_0->thumb)\noffset = 2;",
"else\noffset = 4;",
"break;",
"case EXCP_SWI:\nif (semihosting_enabled) {",
"if (VAR_0->thumb) {",
"mask = lduw_code(VAR_0->regs[15] - 2) & 0xff;",
"} else {",
"mask = ldl_code(VAR_0->regs[15] - 4) & 0xffffff;",
"}",
"if (((mask == 0x123456 && !VAR_0->thumb)\n|| (mask == 0xab && VAR_0->thumb))\n&& (VAR_0->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR) {",
"VAR_0->regs[0] = do_arm_semihosting(VAR_0);",
"return;",
"}",
"}",
"VAR_1 = ARM_CPU_MODE_SVC;",
"addr = 0x08;",
"mask = CPSR_I;",
"offset = 0;",
"break;",
"case EXCP_BKPT:\nif (VAR_0->thumb && semihosting_enabled) {",
"mask = lduw_code(VAR_0->regs[15]) & 0xff;",
"if (mask == 0xab\n&& (VAR_0->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR) {",
"VAR_0->regs[15] += 2;",
"VAR_0->regs[0] = do_arm_semihosting(VAR_0);",
"return;",
"}",
"}",
"VAR_0->cp15.c5_insn = 2;",
"case EXCP_PREFETCH_ABORT:\nVAR_1 = ARM_CPU_MODE_ABT;",
"addr = 0x0c;",
"mask = CPSR_A | CPSR_I;",
"offset = 4;",
"break;",
"case EXCP_DATA_ABORT:\nVAR_1 = ARM_CPU_MODE_ABT;",
"addr = 0x10;",
"mask = CPSR_A | CPSR_I;",
"offset = 8;",
"break;",
"case EXCP_IRQ:\nVAR_1 = ARM_CPU_MODE_IRQ;",
"addr = 0x18;",
"mask = CPSR_A | CPSR_I;",
"offset = 4;",
"break;",
"case EXCP_FIQ:\nVAR_1 = ARM_CPU_MODE_FIQ;",
"addr = 0x1c;",
"mask = CPSR_A | CPSR_I | CPSR_F;",
"offset = 4;",
"break;",
"default:\ncpu_abort(VAR_0, \"Unhandled exception 0x%x\\n\", VAR_0->exception_index);",
"return;",
"}",
"if (VAR_0->cp15.c1_sys & (1 << 13)) {",
"addr += 0xffff0000;",
"}",
"switch_mode (VAR_0, VAR_1);",
"VAR_0->spsr = cpsr_read(VAR_0);",
"VAR_0->condexec_bits = 0;",
"VAR_0->uncached_cpsr = (VAR_0->uncached_cpsr & ~CPSR_M) | VAR_1;",
"VAR_0->uncached_cpsr |= mask;",
"if (arm_feature(VAR_0, ARM_FEATURE_V4T)) {",
"VAR_0->thumb = (VAR_0->cp15.c1_sys & (1 << 30)) != 0;",
"}",
"VAR_0->regs[14] = VAR_0->regs[15] + offset;",
"VAR_0->regs[15] = addr;",
"VAR_0->interrupt_request |= CPU_INTERRUPT_EXITTB;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35,
37
],
[
39,
41
],
[
43
],
[
45,
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
65,
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91,
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
],
[
149
],
[
151
],
[
153
],
[
155,
157
],
[
159
],
[
163
],
[
165
],
[
167
],
[
169,
171
],
[
173
],
[
175
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191
],
[
195
],
[
197
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
]
] |
3,194 | static void ERROR(const char *str)
{
fprintf(stderr, "%s\n", str);
exit(1);
}
| true | FFmpeg | 1bfb4587a2e5b25ed15f742149e555efc8f305ae | static void ERROR(const char *str)
{
fprintf(stderr, "%s\n", str);
exit(1);
}
| {
"code": [
" fprintf(stderr, \"%s\\n\", str);",
" exit(1);"
],
"line_no": [
5,
7
]
} | static void FUNC_0(const char *VAR_0)
{
fprintf(stderr, "%s\n", VAR_0);
exit(1);
}
| [
"static void FUNC_0(const char *VAR_0)\n{",
"fprintf(stderr, \"%s\\n\", VAR_0);",
"exit(1);",
"}"
] | [
0,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
3,196 | static void handle_control_message(VirtIOSerial *vser, void *buf, size_t len)
{
struct VirtIOSerialPort *port;
struct virtio_console_control cpkt, *gcpkt;
uint8_t *buffer;
size_t buffer_len;
gcpkt = buf;
if (len < sizeof(cpkt)) {
/* The guest sent an invalid control packet */
return;
}
cpkt.event = lduw_p(&gcpkt->event);
cpkt.value = lduw_p(&gcpkt->value);
port = find_port_by_id(vser, ldl_p(&gcpkt->id));
if (!port && cpkt.event != VIRTIO_CONSOLE_DEVICE_READY)
return;
switch(cpkt.event) {
case VIRTIO_CONSOLE_DEVICE_READY:
if (!cpkt.value) {
error_report("virtio-serial-bus: Guest failure in adding device %s\n",
vser->bus->qbus.name);
break;
}
/*
* The device is up, we can now tell the device about all the
* ports we have here.
*/
QTAILQ_FOREACH(port, &vser->ports, next) {
send_control_event(port, VIRTIO_CONSOLE_PORT_ADD, 1);
}
break;
case VIRTIO_CONSOLE_PORT_READY:
if (!cpkt.value) {
error_report("virtio-serial-bus: Guest failure in adding port %u for device %s\n",
port->id, vser->bus->qbus.name);
break;
}
/*
* Now that we know the guest asked for the port name, we're
* sure the guest has initialised whatever state is necessary
* for this port. Now's a good time to let the guest know if
* this port is a console port so that the guest can hook it
* up to hvc.
*/
if (port->is_console) {
send_control_event(port, VIRTIO_CONSOLE_CONSOLE_PORT, 1);
}
if (port->name) {
stw_p(&cpkt.event, VIRTIO_CONSOLE_PORT_NAME);
stw_p(&cpkt.value, 1);
buffer_len = sizeof(cpkt) + strlen(port->name) + 1;
buffer = qemu_malloc(buffer_len);
memcpy(buffer, &cpkt, sizeof(cpkt));
memcpy(buffer + sizeof(cpkt), port->name, strlen(port->name));
buffer[buffer_len - 1] = 0;
send_control_msg(port, buffer, buffer_len);
qemu_free(buffer);
}
if (port->host_connected) {
send_control_event(port, VIRTIO_CONSOLE_PORT_OPEN, 1);
}
/*
* When the guest has asked us for this information it means
* the guest is all setup and has its virtqueues
* initialised. If some app is interested in knowing about
* this event, let it know.
*/
if (port->info->guest_ready) {
port->info->guest_ready(port);
}
break;
case VIRTIO_CONSOLE_PORT_OPEN:
port->guest_connected = cpkt.value;
if (cpkt.value && port->info->guest_open) {
/* Send the guest opened notification if an app is interested */
port->info->guest_open(port);
}
if (!cpkt.value && port->info->guest_close) {
/* Send the guest closed notification if an app is interested */
port->info->guest_close(port);
}
break;
}
}
| true | qemu | 5e52e5f903b2648c59030637e1610b32e965d615 | static void handle_control_message(VirtIOSerial *vser, void *buf, size_t len)
{
struct VirtIOSerialPort *port;
struct virtio_console_control cpkt, *gcpkt;
uint8_t *buffer;
size_t buffer_len;
gcpkt = buf;
if (len < sizeof(cpkt)) {
return;
}
cpkt.event = lduw_p(&gcpkt->event);
cpkt.value = lduw_p(&gcpkt->value);
port = find_port_by_id(vser, ldl_p(&gcpkt->id));
if (!port && cpkt.event != VIRTIO_CONSOLE_DEVICE_READY)
return;
switch(cpkt.event) {
case VIRTIO_CONSOLE_DEVICE_READY:
if (!cpkt.value) {
error_report("virtio-serial-bus: Guest failure in adding device %s\n",
vser->bus->qbus.name);
break;
}
QTAILQ_FOREACH(port, &vser->ports, next) {
send_control_event(port, VIRTIO_CONSOLE_PORT_ADD, 1);
}
break;
case VIRTIO_CONSOLE_PORT_READY:
if (!cpkt.value) {
error_report("virtio-serial-bus: Guest failure in adding port %u for device %s\n",
port->id, vser->bus->qbus.name);
break;
}
if (port->is_console) {
send_control_event(port, VIRTIO_CONSOLE_CONSOLE_PORT, 1);
}
if (port->name) {
stw_p(&cpkt.event, VIRTIO_CONSOLE_PORT_NAME);
stw_p(&cpkt.value, 1);
buffer_len = sizeof(cpkt) + strlen(port->name) + 1;
buffer = qemu_malloc(buffer_len);
memcpy(buffer, &cpkt, sizeof(cpkt));
memcpy(buffer + sizeof(cpkt), port->name, strlen(port->name));
buffer[buffer_len - 1] = 0;
send_control_msg(port, buffer, buffer_len);
qemu_free(buffer);
}
if (port->host_connected) {
send_control_event(port, VIRTIO_CONSOLE_PORT_OPEN, 1);
}
if (port->info->guest_ready) {
port->info->guest_ready(port);
}
break;
case VIRTIO_CONSOLE_PORT_OPEN:
port->guest_connected = cpkt.value;
if (cpkt.value && port->info->guest_open) {
port->info->guest_open(port);
}
if (!cpkt.value && port->info->guest_close) {
port->info->guest_close(port);
}
break;
}
}
| {
"code": [
" vser->bus->qbus.name);",
" port->id, vser->bus->qbus.name);"
],
"line_no": [
51,
81
]
} | static void FUNC_0(VirtIOSerial *VAR_0, void *VAR_1, size_t VAR_2)
{
struct VirtIOSerialPort *VAR_3;
struct virtio_console_control VAR_4, *VAR_5;
uint8_t *buffer;
size_t buffer_len;
VAR_5 = VAR_1;
if (VAR_2 < sizeof(VAR_4)) {
return;
}
VAR_4.event = lduw_p(&VAR_5->event);
VAR_4.value = lduw_p(&VAR_5->value);
VAR_3 = find_port_by_id(VAR_0, ldl_p(&VAR_5->id));
if (!VAR_3 && VAR_4.event != VIRTIO_CONSOLE_DEVICE_READY)
return;
switch(VAR_4.event) {
case VIRTIO_CONSOLE_DEVICE_READY:
if (!VAR_4.value) {
error_report("virtio-serial-bus: Guest failure in adding device %s\n",
VAR_0->bus->qbus.name);
break;
}
QTAILQ_FOREACH(VAR_3, &VAR_0->ports, next) {
send_control_event(VAR_3, VIRTIO_CONSOLE_PORT_ADD, 1);
}
break;
case VIRTIO_CONSOLE_PORT_READY:
if (!VAR_4.value) {
error_report("virtio-serial-bus: Guest failure in adding VAR_3 %u for device %s\n",
VAR_3->id, VAR_0->bus->qbus.name);
break;
}
if (VAR_3->is_console) {
send_control_event(VAR_3, VIRTIO_CONSOLE_CONSOLE_PORT, 1);
}
if (VAR_3->name) {
stw_p(&VAR_4.event, VIRTIO_CONSOLE_PORT_NAME);
stw_p(&VAR_4.value, 1);
buffer_len = sizeof(VAR_4) + strlen(VAR_3->name) + 1;
buffer = qemu_malloc(buffer_len);
memcpy(buffer, &VAR_4, sizeof(VAR_4));
memcpy(buffer + sizeof(VAR_4), VAR_3->name, strlen(VAR_3->name));
buffer[buffer_len - 1] = 0;
send_control_msg(VAR_3, buffer, buffer_len);
qemu_free(buffer);
}
if (VAR_3->host_connected) {
send_control_event(VAR_3, VIRTIO_CONSOLE_PORT_OPEN, 1);
}
if (VAR_3->info->guest_ready) {
VAR_3->info->guest_ready(VAR_3);
}
break;
case VIRTIO_CONSOLE_PORT_OPEN:
VAR_3->guest_connected = VAR_4.value;
if (VAR_4.value && VAR_3->info->guest_open) {
VAR_3->info->guest_open(VAR_3);
}
if (!VAR_4.value && VAR_3->info->guest_close) {
VAR_3->info->guest_close(VAR_3);
}
break;
}
}
| [
"static void FUNC_0(VirtIOSerial *VAR_0, void *VAR_1, size_t VAR_2)\n{",
"struct VirtIOSerialPort *VAR_3;",
"struct virtio_console_control VAR_4, *VAR_5;",
"uint8_t *buffer;",
"size_t buffer_len;",
"VAR_5 = VAR_1;",
"if (VAR_2 < sizeof(VAR_4)) {",
"return;",
"}",
"VAR_4.event = lduw_p(&VAR_5->event);",
"VAR_4.value = lduw_p(&VAR_5->value);",
"VAR_3 = find_port_by_id(VAR_0, ldl_p(&VAR_5->id));",
"if (!VAR_3 && VAR_4.event != VIRTIO_CONSOLE_DEVICE_READY)\nreturn;",
"switch(VAR_4.event) {",
"case VIRTIO_CONSOLE_DEVICE_READY:\nif (!VAR_4.value) {",
"error_report(\"virtio-serial-bus: Guest failure in adding device %s\\n\",\nVAR_0->bus->qbus.name);",
"break;",
"}",
"QTAILQ_FOREACH(VAR_3, &VAR_0->ports, next) {",
"send_control_event(VAR_3, VIRTIO_CONSOLE_PORT_ADD, 1);",
"}",
"break;",
"case VIRTIO_CONSOLE_PORT_READY:\nif (!VAR_4.value) {",
"error_report(\"virtio-serial-bus: Guest failure in adding VAR_3 %u for device %s\\n\",\nVAR_3->id, VAR_0->bus->qbus.name);",
"break;",
"}",
"if (VAR_3->is_console) {",
"send_control_event(VAR_3, VIRTIO_CONSOLE_CONSOLE_PORT, 1);",
"}",
"if (VAR_3->name) {",
"stw_p(&VAR_4.event, VIRTIO_CONSOLE_PORT_NAME);",
"stw_p(&VAR_4.value, 1);",
"buffer_len = sizeof(VAR_4) + strlen(VAR_3->name) + 1;",
"buffer = qemu_malloc(buffer_len);",
"memcpy(buffer, &VAR_4, sizeof(VAR_4));",
"memcpy(buffer + sizeof(VAR_4), VAR_3->name, strlen(VAR_3->name));",
"buffer[buffer_len - 1] = 0;",
"send_control_msg(VAR_3, buffer, buffer_len);",
"qemu_free(buffer);",
"}",
"if (VAR_3->host_connected) {",
"send_control_event(VAR_3, VIRTIO_CONSOLE_PORT_OPEN, 1);",
"}",
"if (VAR_3->info->guest_ready) {",
"VAR_3->info->guest_ready(VAR_3);",
"}",
"break;",
"case VIRTIO_CONSOLE_PORT_OPEN:\nVAR_3->guest_connected = VAR_4.value;",
"if (VAR_4.value && VAR_3->info->guest_open) {",
"VAR_3->info->guest_open(VAR_3);",
"}",
"if (!VAR_4.value && VAR_3->info->guest_close) {",
"VAR_3->info->guest_close(VAR_3);",
"}",
"break;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
23
],
[
25
],
[
29
],
[
31
],
[
35
],
[
37,
39
],
[
43
],
[
45,
47
],
[
49,
51
],
[
53
],
[
55
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75,
77
],
[
79,
81
],
[
83
],
[
85
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127
],
[
131
],
[
133
],
[
135
],
[
139
],
[
141
],
[
143
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169,
171
],
[
173
],
[
177
],
[
179
],
[
183
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
]
] |
3,197 | static int asf_write_header1(AVFormatContext *s, int64_t file_size,
int64_t data_chunk_size)
{
ASFContext *asf = s->priv_data;
AVIOContext *pb = s->pb;
AVDictionaryEntry *tags[5];
int header_size, n, extra_size, extra_size2, wav_extra_size, file_time;
int has_title, has_aspect_ratio = 0;
int metadata_count;
AVCodecContext *enc;
int64_t header_offset, cur_pos, hpos;
int bit_rate;
int64_t duration;
ff_metadata_conv(&s->metadata, ff_asf_metadata_conv, NULL);
tags[0] = av_dict_get(s->metadata, "title", NULL, 0);
tags[1] = av_dict_get(s->metadata, "author", NULL, 0);
tags[2] = av_dict_get(s->metadata, "copyright", NULL, 0);
tags[3] = av_dict_get(s->metadata, "comment", NULL, 0);
tags[4] = av_dict_get(s->metadata, "rating", NULL, 0);
duration = asf->duration + PREROLL_TIME * 10000;
has_title = tags[0] || tags[1] || tags[2] || tags[3] || tags[4];
metadata_count = av_dict_count(s->metadata);
bit_rate = 0;
for (n = 0; n < s->nb_streams; n++) {
enc = s->streams[n]->codec;
avpriv_set_pts_info(s->streams[n], 32, 1, 1000); /* 32 bit pts in ms */
bit_rate += enc->bit_rate;
if ( enc->codec_type == AVMEDIA_TYPE_VIDEO
&& enc->sample_aspect_ratio.num > 0
&& enc->sample_aspect_ratio.den > 0)
has_aspect_ratio++;
}
if (asf->is_streamed) {
put_chunk(s, 0x4824, 0, 0xc00); /* start of stream (length will be patched later) */
}
ff_put_guid(pb, &ff_asf_header);
avio_wl64(pb, -1); /* header length, will be patched after */
avio_wl32(pb, 3 + has_title + !!metadata_count + s->nb_streams); /* number of chunks in header */
avio_w8(pb, 1); /* ??? */
avio_w8(pb, 2); /* ??? */
/* file header */
header_offset = avio_tell(pb);
hpos = put_header(pb, &ff_asf_file_header);
ff_put_guid(pb, &ff_asf_my_guid);
avio_wl64(pb, file_size);
file_time = 0;
avio_wl64(pb, unix_to_file_time(file_time));
avio_wl64(pb, asf->nb_packets); /* number of packets */
avio_wl64(pb, duration); /* end time stamp (in 100ns units) */
avio_wl64(pb, asf->duration); /* duration (in 100ns units) */
avio_wl64(pb, PREROLL_TIME); /* start time stamp */
avio_wl32(pb, (asf->is_streamed || !pb->seekable) ? 3 : 2); /* ??? */
avio_wl32(pb, s->packet_size); /* packet size */
avio_wl32(pb, s->packet_size); /* packet size */
avio_wl32(pb, bit_rate ? bit_rate : -1); /* Maximum data rate in bps */
end_header(pb, hpos);
/* unknown headers */
hpos = put_header(pb, &ff_asf_head1_guid);
ff_put_guid(pb, &ff_asf_head2_guid);
avio_wl16(pb, 6);
if (has_aspect_ratio) {
int64_t hpos2;
avio_wl32(pb, 26 + has_aspect_ratio * 84);
hpos2 = put_header(pb, &ff_asf_metadata_header);
avio_wl16(pb, 2 * has_aspect_ratio);
for (n = 0; n < s->nb_streams; n++) {
enc = s->streams[n]->codec;
if ( enc->codec_type == AVMEDIA_TYPE_VIDEO
&& enc->sample_aspect_ratio.num > 0
&& enc->sample_aspect_ratio.den > 0) {
AVRational sar = enc->sample_aspect_ratio;
avio_wl16(pb, 0);
// the stream number is set like this below
avio_wl16(pb, n + 1);
avio_wl16(pb, 26); // name_len
avio_wl16(pb, 3); // value_type
avio_wl32(pb, 4); // value_len
avio_put_str16le(pb, "AspectRatioX");
avio_wl32(pb, sar.num);
avio_wl16(pb, 0);
// the stream number is set like this below
avio_wl16(pb, n + 1);
avio_wl16(pb, 26); // name_len
avio_wl16(pb, 3); // value_type
avio_wl32(pb, 4); // value_len
avio_put_str16le(pb, "AspectRatioY");
avio_wl32(pb, sar.den);
}
}
end_header(pb, hpos2);
} else {
avio_wl32(pb, 0);
}
end_header(pb, hpos);
/* title and other infos */
if (has_title) {
int len;
uint8_t *buf;
AVIOContext *dyn_buf;
if (avio_open_dyn_buf(&dyn_buf) < 0)
return AVERROR(ENOMEM);
hpos = put_header(pb, &ff_asf_comment_header);
for (n = 0; n < FF_ARRAY_ELEMS(tags); n++) {
len = tags[n] ? avio_put_str16le(dyn_buf, tags[n]->value) : 0;
avio_wl16(pb, len);
}
len = avio_close_dyn_buf(dyn_buf, &buf);
avio_write(pb, buf, len);
av_freep(&buf);
end_header(pb, hpos);
}
if (metadata_count) {
AVDictionaryEntry *tag = NULL;
hpos = put_header(pb, &ff_asf_extended_content_header);
avio_wl16(pb, metadata_count);
while ((tag = av_dict_get(s->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
put_str16(pb, tag->key);
avio_wl16(pb, 0);
put_str16(pb, tag->value);
}
end_header(pb, hpos);
}
/* chapters using ASF markers */
if (!asf->is_streamed && s->nb_chapters) {
int ret;
if (ret = asf_write_markers(s))
return ret;
}
/* stream headers */
for (n = 0; n < s->nb_streams; n++) {
int64_t es_pos;
// ASFStream *stream = &asf->streams[n];
enc = s->streams[n]->codec;
asf->streams[n].num = n + 1;
asf->streams[n].seq = 1;
switch (enc->codec_type) {
case AVMEDIA_TYPE_AUDIO:
wav_extra_size = 0;
extra_size = 18 + wav_extra_size;
extra_size2 = 8;
break;
default:
case AVMEDIA_TYPE_VIDEO:
wav_extra_size = enc->extradata_size;
extra_size = 0x33 + wav_extra_size;
extra_size2 = 0;
break;
}
hpos = put_header(pb, &ff_asf_stream_header);
if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
ff_put_guid(pb, &ff_asf_audio_stream);
ff_put_guid(pb, &ff_asf_audio_conceal_spread);
} else {
ff_put_guid(pb, &ff_asf_video_stream);
ff_put_guid(pb, &ff_asf_video_conceal_none);
}
avio_wl64(pb, 0); /* ??? */
es_pos = avio_tell(pb);
avio_wl32(pb, extra_size); /* wav header len */
avio_wl32(pb, extra_size2); /* additional data len */
avio_wl16(pb, n + 1); /* stream number */
avio_wl32(pb, 0); /* ??? */
if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
/* WAVEFORMATEX header */
int wavsize = ff_put_wav_header(pb, enc, FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX);
if (wavsize < 0)
return -1;
if (wavsize != extra_size) {
cur_pos = avio_tell(pb);
avio_seek(pb, es_pos, SEEK_SET);
avio_wl32(pb, wavsize); /* wav header len */
avio_seek(pb, cur_pos, SEEK_SET);
}
/* ERROR Correction */
avio_w8(pb, 0x01);
if (enc->codec_id == AV_CODEC_ID_ADPCM_G726 || !enc->block_align) {
avio_wl16(pb, 0x0190);
avio_wl16(pb, 0x0190);
} else {
avio_wl16(pb, enc->block_align);
avio_wl16(pb, enc->block_align);
}
avio_wl16(pb, 0x01);
avio_w8(pb, 0x00);
} else {
avio_wl32(pb, enc->width);
avio_wl32(pb, enc->height);
avio_w8(pb, 2); /* ??? */
avio_wl16(pb, 40 + enc->extradata_size); /* size */
/* BITMAPINFOHEADER header */
ff_put_bmp_header(pb, enc, ff_codec_bmp_tags, 1, 0);
}
end_header(pb, hpos);
}
/* media comments */
hpos = put_header(pb, &ff_asf_codec_comment_header);
ff_put_guid(pb, &ff_asf_codec_comment1_header);
avio_wl32(pb, s->nb_streams);
for (n = 0; n < s->nb_streams; n++) {
const AVCodecDescriptor *codec_desc;
const char *desc;
enc = s->streams[n]->codec;
codec_desc = avcodec_descriptor_get(enc->codec_id);
if (enc->codec_type == AVMEDIA_TYPE_AUDIO)
avio_wl16(pb, 2);
else if (enc->codec_type == AVMEDIA_TYPE_VIDEO)
avio_wl16(pb, 1);
else
avio_wl16(pb, -1);
if (enc->codec_id == AV_CODEC_ID_WMAV2)
desc = "Windows Media Audio V8";
else
desc = codec_desc ? codec_desc->name : NULL;
if (desc) {
AVIOContext *dyn_buf;
uint8_t *buf;
int len;
if (avio_open_dyn_buf(&dyn_buf) < 0)
return AVERROR(ENOMEM);
avio_put_str16le(dyn_buf, desc);
len = avio_close_dyn_buf(dyn_buf, &buf);
avio_wl16(pb, len / 2); // "number of characters" = length in bytes / 2
avio_write(pb, buf, len);
av_freep(&buf);
} else
avio_wl16(pb, 0);
avio_wl16(pb, 0); /* no parameters */
/* id */
if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
avio_wl16(pb, 2);
avio_wl16(pb, enc->codec_tag);
} else {
avio_wl16(pb, 4);
avio_wl32(pb, enc->codec_tag);
}
if (!enc->codec_tag)
return -1;
}
end_header(pb, hpos);
/* patch the header size fields */
cur_pos = avio_tell(pb);
header_size = cur_pos - header_offset;
if (asf->is_streamed) {
header_size += 8 + 30 + DATA_HEADER_SIZE;
avio_seek(pb, header_offset - 10 - 30, SEEK_SET);
avio_wl16(pb, header_size);
avio_seek(pb, header_offset - 2 - 30, SEEK_SET);
avio_wl16(pb, header_size);
header_size -= 8 + 30 + DATA_HEADER_SIZE;
}
header_size += 24 + 6;
avio_seek(pb, header_offset - 14, SEEK_SET);
avio_wl64(pb, header_size);
avio_seek(pb, cur_pos, SEEK_SET);
/* movie chunk, followed by packets of packet_size */
asf->data_offset = cur_pos;
ff_put_guid(pb, &ff_asf_data_header);
avio_wl64(pb, data_chunk_size);
ff_put_guid(pb, &ff_asf_my_guid);
avio_wl64(pb, asf->nb_packets); /* nb packets */
avio_w8(pb, 1); /* ??? */
avio_w8(pb, 1); /* ??? */
return 0;
}
| false | FFmpeg | 4b45aa517c30091c20b75f1fd12f3607a679b841 | static int asf_write_header1(AVFormatContext *s, int64_t file_size,
int64_t data_chunk_size)
{
ASFContext *asf = s->priv_data;
AVIOContext *pb = s->pb;
AVDictionaryEntry *tags[5];
int header_size, n, extra_size, extra_size2, wav_extra_size, file_time;
int has_title, has_aspect_ratio = 0;
int metadata_count;
AVCodecContext *enc;
int64_t header_offset, cur_pos, hpos;
int bit_rate;
int64_t duration;
ff_metadata_conv(&s->metadata, ff_asf_metadata_conv, NULL);
tags[0] = av_dict_get(s->metadata, "title", NULL, 0);
tags[1] = av_dict_get(s->metadata, "author", NULL, 0);
tags[2] = av_dict_get(s->metadata, "copyright", NULL, 0);
tags[3] = av_dict_get(s->metadata, "comment", NULL, 0);
tags[4] = av_dict_get(s->metadata, "rating", NULL, 0);
duration = asf->duration + PREROLL_TIME * 10000;
has_title = tags[0] || tags[1] || tags[2] || tags[3] || tags[4];
metadata_count = av_dict_count(s->metadata);
bit_rate = 0;
for (n = 0; n < s->nb_streams; n++) {
enc = s->streams[n]->codec;
avpriv_set_pts_info(s->streams[n], 32, 1, 1000);
bit_rate += enc->bit_rate;
if ( enc->codec_type == AVMEDIA_TYPE_VIDEO
&& enc->sample_aspect_ratio.num > 0
&& enc->sample_aspect_ratio.den > 0)
has_aspect_ratio++;
}
if (asf->is_streamed) {
put_chunk(s, 0x4824, 0, 0xc00);
}
ff_put_guid(pb, &ff_asf_header);
avio_wl64(pb, -1);
avio_wl32(pb, 3 + has_title + !!metadata_count + s->nb_streams);
avio_w8(pb, 1);
avio_w8(pb, 2);
header_offset = avio_tell(pb);
hpos = put_header(pb, &ff_asf_file_header);
ff_put_guid(pb, &ff_asf_my_guid);
avio_wl64(pb, file_size);
file_time = 0;
avio_wl64(pb, unix_to_file_time(file_time));
avio_wl64(pb, asf->nb_packets);
avio_wl64(pb, duration);
avio_wl64(pb, asf->duration);
avio_wl64(pb, PREROLL_TIME);
avio_wl32(pb, (asf->is_streamed || !pb->seekable) ? 3 : 2);
avio_wl32(pb, s->packet_size);
avio_wl32(pb, s->packet_size);
avio_wl32(pb, bit_rate ? bit_rate : -1);
end_header(pb, hpos);
hpos = put_header(pb, &ff_asf_head1_guid);
ff_put_guid(pb, &ff_asf_head2_guid);
avio_wl16(pb, 6);
if (has_aspect_ratio) {
int64_t hpos2;
avio_wl32(pb, 26 + has_aspect_ratio * 84);
hpos2 = put_header(pb, &ff_asf_metadata_header);
avio_wl16(pb, 2 * has_aspect_ratio);
for (n = 0; n < s->nb_streams; n++) {
enc = s->streams[n]->codec;
if ( enc->codec_type == AVMEDIA_TYPE_VIDEO
&& enc->sample_aspect_ratio.num > 0
&& enc->sample_aspect_ratio.den > 0) {
AVRational sar = enc->sample_aspect_ratio;
avio_wl16(pb, 0);
avio_wl16(pb, n + 1);
avio_wl16(pb, 26);
avio_wl16(pb, 3);
avio_wl32(pb, 4);
avio_put_str16le(pb, "AspectRatioX");
avio_wl32(pb, sar.num);
avio_wl16(pb, 0);
avio_wl16(pb, n + 1);
avio_wl16(pb, 26);
avio_wl16(pb, 3);
avio_wl32(pb, 4);
avio_put_str16le(pb, "AspectRatioY");
avio_wl32(pb, sar.den);
}
}
end_header(pb, hpos2);
} else {
avio_wl32(pb, 0);
}
end_header(pb, hpos);
if (has_title) {
int len;
uint8_t *buf;
AVIOContext *dyn_buf;
if (avio_open_dyn_buf(&dyn_buf) < 0)
return AVERROR(ENOMEM);
hpos = put_header(pb, &ff_asf_comment_header);
for (n = 0; n < FF_ARRAY_ELEMS(tags); n++) {
len = tags[n] ? avio_put_str16le(dyn_buf, tags[n]->value) : 0;
avio_wl16(pb, len);
}
len = avio_close_dyn_buf(dyn_buf, &buf);
avio_write(pb, buf, len);
av_freep(&buf);
end_header(pb, hpos);
}
if (metadata_count) {
AVDictionaryEntry *tag = NULL;
hpos = put_header(pb, &ff_asf_extended_content_header);
avio_wl16(pb, metadata_count);
while ((tag = av_dict_get(s->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
put_str16(pb, tag->key);
avio_wl16(pb, 0);
put_str16(pb, tag->value);
}
end_header(pb, hpos);
}
if (!asf->is_streamed && s->nb_chapters) {
int ret;
if (ret = asf_write_markers(s))
return ret;
}
for (n = 0; n < s->nb_streams; n++) {
int64_t es_pos;
enc = s->streams[n]->codec;
asf->streams[n].num = n + 1;
asf->streams[n].seq = 1;
switch (enc->codec_type) {
case AVMEDIA_TYPE_AUDIO:
wav_extra_size = 0;
extra_size = 18 + wav_extra_size;
extra_size2 = 8;
break;
default:
case AVMEDIA_TYPE_VIDEO:
wav_extra_size = enc->extradata_size;
extra_size = 0x33 + wav_extra_size;
extra_size2 = 0;
break;
}
hpos = put_header(pb, &ff_asf_stream_header);
if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
ff_put_guid(pb, &ff_asf_audio_stream);
ff_put_guid(pb, &ff_asf_audio_conceal_spread);
} else {
ff_put_guid(pb, &ff_asf_video_stream);
ff_put_guid(pb, &ff_asf_video_conceal_none);
}
avio_wl64(pb, 0);
es_pos = avio_tell(pb);
avio_wl32(pb, extra_size);
avio_wl32(pb, extra_size2);
avio_wl16(pb, n + 1);
avio_wl32(pb, 0);
if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
int wavsize = ff_put_wav_header(pb, enc, FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX);
if (wavsize < 0)
return -1;
if (wavsize != extra_size) {
cur_pos = avio_tell(pb);
avio_seek(pb, es_pos, SEEK_SET);
avio_wl32(pb, wavsize);
avio_seek(pb, cur_pos, SEEK_SET);
}
avio_w8(pb, 0x01);
if (enc->codec_id == AV_CODEC_ID_ADPCM_G726 || !enc->block_align) {
avio_wl16(pb, 0x0190);
avio_wl16(pb, 0x0190);
} else {
avio_wl16(pb, enc->block_align);
avio_wl16(pb, enc->block_align);
}
avio_wl16(pb, 0x01);
avio_w8(pb, 0x00);
} else {
avio_wl32(pb, enc->width);
avio_wl32(pb, enc->height);
avio_w8(pb, 2);
avio_wl16(pb, 40 + enc->extradata_size);
ff_put_bmp_header(pb, enc, ff_codec_bmp_tags, 1, 0);
}
end_header(pb, hpos);
}
hpos = put_header(pb, &ff_asf_codec_comment_header);
ff_put_guid(pb, &ff_asf_codec_comment1_header);
avio_wl32(pb, s->nb_streams);
for (n = 0; n < s->nb_streams; n++) {
const AVCodecDescriptor *codec_desc;
const char *desc;
enc = s->streams[n]->codec;
codec_desc = avcodec_descriptor_get(enc->codec_id);
if (enc->codec_type == AVMEDIA_TYPE_AUDIO)
avio_wl16(pb, 2);
else if (enc->codec_type == AVMEDIA_TYPE_VIDEO)
avio_wl16(pb, 1);
else
avio_wl16(pb, -1);
if (enc->codec_id == AV_CODEC_ID_WMAV2)
desc = "Windows Media Audio V8";
else
desc = codec_desc ? codec_desc->name : NULL;
if (desc) {
AVIOContext *dyn_buf;
uint8_t *buf;
int len;
if (avio_open_dyn_buf(&dyn_buf) < 0)
return AVERROR(ENOMEM);
avio_put_str16le(dyn_buf, desc);
len = avio_close_dyn_buf(dyn_buf, &buf);
avio_wl16(pb, len / 2);
avio_write(pb, buf, len);
av_freep(&buf);
} else
avio_wl16(pb, 0);
avio_wl16(pb, 0);
if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
avio_wl16(pb, 2);
avio_wl16(pb, enc->codec_tag);
} else {
avio_wl16(pb, 4);
avio_wl32(pb, enc->codec_tag);
}
if (!enc->codec_tag)
return -1;
}
end_header(pb, hpos);
cur_pos = avio_tell(pb);
header_size = cur_pos - header_offset;
if (asf->is_streamed) {
header_size += 8 + 30 + DATA_HEADER_SIZE;
avio_seek(pb, header_offset - 10 - 30, SEEK_SET);
avio_wl16(pb, header_size);
avio_seek(pb, header_offset - 2 - 30, SEEK_SET);
avio_wl16(pb, header_size);
header_size -= 8 + 30 + DATA_HEADER_SIZE;
}
header_size += 24 + 6;
avio_seek(pb, header_offset - 14, SEEK_SET);
avio_wl64(pb, header_size);
avio_seek(pb, cur_pos, SEEK_SET);
asf->data_offset = cur_pos;
ff_put_guid(pb, &ff_asf_data_header);
avio_wl64(pb, data_chunk_size);
ff_put_guid(pb, &ff_asf_my_guid);
avio_wl64(pb, asf->nb_packets);
avio_w8(pb, 1);
avio_w8(pb, 1);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, int64_t VAR_1,
int64_t VAR_2)
{
ASFContext *asf = VAR_0->priv_data;
AVIOContext *pb = VAR_0->pb;
AVDictionaryEntry *tags[5];
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;
int VAR_9, VAR_10 = 0;
int VAR_11;
AVCodecContext *enc;
int64_t header_offset, cur_pos, hpos;
int VAR_12;
int64_t duration;
ff_metadata_conv(&VAR_0->metadata, ff_asf_metadata_conv, NULL);
tags[0] = av_dict_get(VAR_0->metadata, "title", NULL, 0);
tags[1] = av_dict_get(VAR_0->metadata, "author", NULL, 0);
tags[2] = av_dict_get(VAR_0->metadata, "copyright", NULL, 0);
tags[3] = av_dict_get(VAR_0->metadata, "comment", NULL, 0);
tags[4] = av_dict_get(VAR_0->metadata, "rating", NULL, 0);
duration = asf->duration + PREROLL_TIME * 10000;
VAR_9 = tags[0] || tags[1] || tags[2] || tags[3] || tags[4];
VAR_11 = av_dict_count(VAR_0->metadata);
VAR_12 = 0;
for (VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++) {
enc = VAR_0->streams[VAR_4]->codec;
avpriv_set_pts_info(VAR_0->streams[VAR_4], 32, 1, 1000);
VAR_12 += enc->VAR_12;
if ( enc->codec_type == AVMEDIA_TYPE_VIDEO
&& enc->sample_aspect_ratio.num > 0
&& enc->sample_aspect_ratio.den > 0)
VAR_10++;
}
if (asf->is_streamed) {
put_chunk(VAR_0, 0x4824, 0, 0xc00);
}
ff_put_guid(pb, &ff_asf_header);
avio_wl64(pb, -1);
avio_wl32(pb, 3 + VAR_9 + !!VAR_11 + VAR_0->nb_streams);
avio_w8(pb, 1);
avio_w8(pb, 2);
header_offset = avio_tell(pb);
hpos = put_header(pb, &ff_asf_file_header);
ff_put_guid(pb, &ff_asf_my_guid);
avio_wl64(pb, VAR_1);
VAR_8 = 0;
avio_wl64(pb, unix_to_file_time(VAR_8));
avio_wl64(pb, asf->nb_packets);
avio_wl64(pb, duration);
avio_wl64(pb, asf->duration);
avio_wl64(pb, PREROLL_TIME);
avio_wl32(pb, (asf->is_streamed || !pb->seekable) ? 3 : 2);
avio_wl32(pb, VAR_0->packet_size);
avio_wl32(pb, VAR_0->packet_size);
avio_wl32(pb, VAR_12 ? VAR_12 : -1);
end_header(pb, hpos);
hpos = put_header(pb, &ff_asf_head1_guid);
ff_put_guid(pb, &ff_asf_head2_guid);
avio_wl16(pb, 6);
if (VAR_10) {
int64_t hpos2;
avio_wl32(pb, 26 + VAR_10 * 84);
hpos2 = put_header(pb, &ff_asf_metadata_header);
avio_wl16(pb, 2 * VAR_10);
for (VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++) {
enc = VAR_0->streams[VAR_4]->codec;
if ( enc->codec_type == AVMEDIA_TYPE_VIDEO
&& enc->sample_aspect_ratio.num > 0
&& enc->sample_aspect_ratio.den > 0) {
AVRational sar = enc->sample_aspect_ratio;
avio_wl16(pb, 0);
avio_wl16(pb, VAR_4 + 1);
avio_wl16(pb, 26);
avio_wl16(pb, 3);
avio_wl32(pb, 4);
avio_put_str16le(pb, "AspectRatioX");
avio_wl32(pb, sar.num);
avio_wl16(pb, 0);
avio_wl16(pb, VAR_4 + 1);
avio_wl16(pb, 26);
avio_wl16(pb, 3);
avio_wl32(pb, 4);
avio_put_str16le(pb, "AspectRatioY");
avio_wl32(pb, sar.den);
}
}
end_header(pb, hpos2);
} else {
avio_wl32(pb, 0);
}
end_header(pb, hpos);
if (VAR_9) {
int VAR_13;
uint8_t *buf;
AVIOContext *dyn_buf;
if (avio_open_dyn_buf(&dyn_buf) < 0)
return AVERROR(ENOMEM);
hpos = put_header(pb, &ff_asf_comment_header);
for (VAR_4 = 0; VAR_4 < FF_ARRAY_ELEMS(tags); VAR_4++) {
VAR_13 = tags[VAR_4] ? avio_put_str16le(dyn_buf, tags[VAR_4]->value) : 0;
avio_wl16(pb, VAR_13);
}
VAR_13 = avio_close_dyn_buf(dyn_buf, &buf);
avio_write(pb, buf, VAR_13);
av_freep(&buf);
end_header(pb, hpos);
}
if (VAR_11) {
AVDictionaryEntry *tag = NULL;
hpos = put_header(pb, &ff_asf_extended_content_header);
avio_wl16(pb, VAR_11);
while ((tag = av_dict_get(VAR_0->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
put_str16(pb, tag->key);
avio_wl16(pb, 0);
put_str16(pb, tag->value);
}
end_header(pb, hpos);
}
if (!asf->is_streamed && VAR_0->nb_chapters) {
int VAR_14;
if (VAR_14 = asf_write_markers(VAR_0))
return VAR_14;
}
for (VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++) {
int64_t es_pos;
enc = VAR_0->streams[VAR_4]->codec;
asf->streams[VAR_4].num = VAR_4 + 1;
asf->streams[VAR_4].seq = 1;
switch (enc->codec_type) {
case AVMEDIA_TYPE_AUDIO:
VAR_7 = 0;
VAR_5 = 18 + VAR_7;
VAR_6 = 8;
break;
default:
case AVMEDIA_TYPE_VIDEO:
VAR_7 = enc->extradata_size;
VAR_5 = 0x33 + VAR_7;
VAR_6 = 0;
break;
}
hpos = put_header(pb, &ff_asf_stream_header);
if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
ff_put_guid(pb, &ff_asf_audio_stream);
ff_put_guid(pb, &ff_asf_audio_conceal_spread);
} else {
ff_put_guid(pb, &ff_asf_video_stream);
ff_put_guid(pb, &ff_asf_video_conceal_none);
}
avio_wl64(pb, 0);
es_pos = avio_tell(pb);
avio_wl32(pb, VAR_5);
avio_wl32(pb, VAR_6);
avio_wl16(pb, VAR_4 + 1);
avio_wl32(pb, 0);
if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
int wavsize = ff_put_wav_header(pb, enc, FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX);
if (wavsize < 0)
return -1;
if (wavsize != VAR_5) {
cur_pos = avio_tell(pb);
avio_seek(pb, es_pos, SEEK_SET);
avio_wl32(pb, wavsize);
avio_seek(pb, cur_pos, SEEK_SET);
}
avio_w8(pb, 0x01);
if (enc->codec_id == AV_CODEC_ID_ADPCM_G726 || !enc->block_align) {
avio_wl16(pb, 0x0190);
avio_wl16(pb, 0x0190);
} else {
avio_wl16(pb, enc->block_align);
avio_wl16(pb, enc->block_align);
}
avio_wl16(pb, 0x01);
avio_w8(pb, 0x00);
} else {
avio_wl32(pb, enc->width);
avio_wl32(pb, enc->height);
avio_w8(pb, 2);
avio_wl16(pb, 40 + enc->extradata_size);
ff_put_bmp_header(pb, enc, ff_codec_bmp_tags, 1, 0);
}
end_header(pb, hpos);
}
hpos = put_header(pb, &ff_asf_codec_comment_header);
ff_put_guid(pb, &ff_asf_codec_comment1_header);
avio_wl32(pb, VAR_0->nb_streams);
for (VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++) {
const AVCodecDescriptor *codec_desc;
const char *desc;
enc = VAR_0->streams[VAR_4]->codec;
codec_desc = avcodec_descriptor_get(enc->codec_id);
if (enc->codec_type == AVMEDIA_TYPE_AUDIO)
avio_wl16(pb, 2);
else if (enc->codec_type == AVMEDIA_TYPE_VIDEO)
avio_wl16(pb, 1);
else
avio_wl16(pb, -1);
if (enc->codec_id == AV_CODEC_ID_WMAV2)
desc = "Windows Media Audio V8";
else
desc = codec_desc ? codec_desc->name : NULL;
if (desc) {
AVIOContext *dyn_buf;
uint8_t *buf;
int VAR_13;
if (avio_open_dyn_buf(&dyn_buf) < 0)
return AVERROR(ENOMEM);
avio_put_str16le(dyn_buf, desc);
VAR_13 = avio_close_dyn_buf(dyn_buf, &buf);
avio_wl16(pb, VAR_13 / 2);
avio_write(pb, buf, VAR_13);
av_freep(&buf);
} else
avio_wl16(pb, 0);
avio_wl16(pb, 0);
if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
avio_wl16(pb, 2);
avio_wl16(pb, enc->codec_tag);
} else {
avio_wl16(pb, 4);
avio_wl32(pb, enc->codec_tag);
}
if (!enc->codec_tag)
return -1;
}
end_header(pb, hpos);
cur_pos = avio_tell(pb);
VAR_3 = cur_pos - header_offset;
if (asf->is_streamed) {
VAR_3 += 8 + 30 + DATA_HEADER_SIZE;
avio_seek(pb, header_offset - 10 - 30, SEEK_SET);
avio_wl16(pb, VAR_3);
avio_seek(pb, header_offset - 2 - 30, SEEK_SET);
avio_wl16(pb, VAR_3);
VAR_3 -= 8 + 30 + DATA_HEADER_SIZE;
}
VAR_3 += 24 + 6;
avio_seek(pb, header_offset - 14, SEEK_SET);
avio_wl64(pb, VAR_3);
avio_seek(pb, cur_pos, SEEK_SET);
asf->data_offset = cur_pos;
ff_put_guid(pb, &ff_asf_data_header);
avio_wl64(pb, VAR_2);
ff_put_guid(pb, &ff_asf_my_guid);
avio_wl64(pb, asf->nb_packets);
avio_w8(pb, 1);
avio_w8(pb, 1);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, int64_t VAR_1,\nint64_t VAR_2)\n{",
"ASFContext *asf = VAR_0->priv_data;",
"AVIOContext *pb = VAR_0->pb;",
"AVDictionaryEntry *tags[5];",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;",
"int VAR_9, VAR_10 = 0;",
"int VAR_11;",
"AVCodecContext *enc;",
"int64_t header_offset, cur_pos, hpos;",
"int VAR_12;",
"int64_t duration;",
"ff_metadata_conv(&VAR_0->metadata, ff_asf_metadata_conv, NULL);",
"tags[0] = av_dict_get(VAR_0->metadata, \"title\", NULL, 0);",
"tags[1] = av_dict_get(VAR_0->metadata, \"author\", NULL, 0);",
"tags[2] = av_dict_get(VAR_0->metadata, \"copyright\", NULL, 0);",
"tags[3] = av_dict_get(VAR_0->metadata, \"comment\", NULL, 0);",
"tags[4] = av_dict_get(VAR_0->metadata, \"rating\", NULL, 0);",
"duration = asf->duration + PREROLL_TIME * 10000;",
"VAR_9 = tags[0] || tags[1] || tags[2] || tags[3] || tags[4];",
"VAR_11 = av_dict_count(VAR_0->metadata);",
"VAR_12 = 0;",
"for (VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++) {",
"enc = VAR_0->streams[VAR_4]->codec;",
"avpriv_set_pts_info(VAR_0->streams[VAR_4], 32, 1, 1000);",
"VAR_12 += enc->VAR_12;",
"if ( enc->codec_type == AVMEDIA_TYPE_VIDEO\n&& enc->sample_aspect_ratio.num > 0\n&& enc->sample_aspect_ratio.den > 0)\nVAR_10++;",
"}",
"if (asf->is_streamed) {",
"put_chunk(VAR_0, 0x4824, 0, 0xc00);",
"}",
"ff_put_guid(pb, &ff_asf_header);",
"avio_wl64(pb, -1);",
"avio_wl32(pb, 3 + VAR_9 + !!VAR_11 + VAR_0->nb_streams);",
"avio_w8(pb, 1);",
"avio_w8(pb, 2);",
"header_offset = avio_tell(pb);",
"hpos = put_header(pb, &ff_asf_file_header);",
"ff_put_guid(pb, &ff_asf_my_guid);",
"avio_wl64(pb, VAR_1);",
"VAR_8 = 0;",
"avio_wl64(pb, unix_to_file_time(VAR_8));",
"avio_wl64(pb, asf->nb_packets);",
"avio_wl64(pb, duration);",
"avio_wl64(pb, asf->duration);",
"avio_wl64(pb, PREROLL_TIME);",
"avio_wl32(pb, (asf->is_streamed || !pb->seekable) ? 3 : 2);",
"avio_wl32(pb, VAR_0->packet_size);",
"avio_wl32(pb, VAR_0->packet_size);",
"avio_wl32(pb, VAR_12 ? VAR_12 : -1);",
"end_header(pb, hpos);",
"hpos = put_header(pb, &ff_asf_head1_guid);",
"ff_put_guid(pb, &ff_asf_head2_guid);",
"avio_wl16(pb, 6);",
"if (VAR_10) {",
"int64_t hpos2;",
"avio_wl32(pb, 26 + VAR_10 * 84);",
"hpos2 = put_header(pb, &ff_asf_metadata_header);",
"avio_wl16(pb, 2 * VAR_10);",
"for (VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++) {",
"enc = VAR_0->streams[VAR_4]->codec;",
"if ( enc->codec_type == AVMEDIA_TYPE_VIDEO\n&& enc->sample_aspect_ratio.num > 0\n&& enc->sample_aspect_ratio.den > 0) {",
"AVRational sar = enc->sample_aspect_ratio;",
"avio_wl16(pb, 0);",
"avio_wl16(pb, VAR_4 + 1);",
"avio_wl16(pb, 26);",
"avio_wl16(pb, 3);",
"avio_wl32(pb, 4);",
"avio_put_str16le(pb, \"AspectRatioX\");",
"avio_wl32(pb, sar.num);",
"avio_wl16(pb, 0);",
"avio_wl16(pb, VAR_4 + 1);",
"avio_wl16(pb, 26);",
"avio_wl16(pb, 3);",
"avio_wl32(pb, 4);",
"avio_put_str16le(pb, \"AspectRatioY\");",
"avio_wl32(pb, sar.den);",
"}",
"}",
"end_header(pb, hpos2);",
"} else {",
"avio_wl32(pb, 0);",
"}",
"end_header(pb, hpos);",
"if (VAR_9) {",
"int VAR_13;",
"uint8_t *buf;",
"AVIOContext *dyn_buf;",
"if (avio_open_dyn_buf(&dyn_buf) < 0)\nreturn AVERROR(ENOMEM);",
"hpos = put_header(pb, &ff_asf_comment_header);",
"for (VAR_4 = 0; VAR_4 < FF_ARRAY_ELEMS(tags); VAR_4++) {",
"VAR_13 = tags[VAR_4] ? avio_put_str16le(dyn_buf, tags[VAR_4]->value) : 0;",
"avio_wl16(pb, VAR_13);",
"}",
"VAR_13 = avio_close_dyn_buf(dyn_buf, &buf);",
"avio_write(pb, buf, VAR_13);",
"av_freep(&buf);",
"end_header(pb, hpos);",
"}",
"if (VAR_11) {",
"AVDictionaryEntry *tag = NULL;",
"hpos = put_header(pb, &ff_asf_extended_content_header);",
"avio_wl16(pb, VAR_11);",
"while ((tag = av_dict_get(VAR_0->metadata, \"\", tag, AV_DICT_IGNORE_SUFFIX))) {",
"put_str16(pb, tag->key);",
"avio_wl16(pb, 0);",
"put_str16(pb, tag->value);",
"}",
"end_header(pb, hpos);",
"}",
"if (!asf->is_streamed && VAR_0->nb_chapters) {",
"int VAR_14;",
"if (VAR_14 = asf_write_markers(VAR_0))\nreturn VAR_14;",
"}",
"for (VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++) {",
"int64_t es_pos;",
"enc = VAR_0->streams[VAR_4]->codec;",
"asf->streams[VAR_4].num = VAR_4 + 1;",
"asf->streams[VAR_4].seq = 1;",
"switch (enc->codec_type) {",
"case AVMEDIA_TYPE_AUDIO:\nVAR_7 = 0;",
"VAR_5 = 18 + VAR_7;",
"VAR_6 = 8;",
"break;",
"default:\ncase AVMEDIA_TYPE_VIDEO:\nVAR_7 = enc->extradata_size;",
"VAR_5 = 0x33 + VAR_7;",
"VAR_6 = 0;",
"break;",
"}",
"hpos = put_header(pb, &ff_asf_stream_header);",
"if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {",
"ff_put_guid(pb, &ff_asf_audio_stream);",
"ff_put_guid(pb, &ff_asf_audio_conceal_spread);",
"} else {",
"ff_put_guid(pb, &ff_asf_video_stream);",
"ff_put_guid(pb, &ff_asf_video_conceal_none);",
"}",
"avio_wl64(pb, 0);",
"es_pos = avio_tell(pb);",
"avio_wl32(pb, VAR_5);",
"avio_wl32(pb, VAR_6);",
"avio_wl16(pb, VAR_4 + 1);",
"avio_wl32(pb, 0);",
"if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {",
"int wavsize = ff_put_wav_header(pb, enc, FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX);",
"if (wavsize < 0)\nreturn -1;",
"if (wavsize != VAR_5) {",
"cur_pos = avio_tell(pb);",
"avio_seek(pb, es_pos, SEEK_SET);",
"avio_wl32(pb, wavsize);",
"avio_seek(pb, cur_pos, SEEK_SET);",
"}",
"avio_w8(pb, 0x01);",
"if (enc->codec_id == AV_CODEC_ID_ADPCM_G726 || !enc->block_align) {",
"avio_wl16(pb, 0x0190);",
"avio_wl16(pb, 0x0190);",
"} else {",
"avio_wl16(pb, enc->block_align);",
"avio_wl16(pb, enc->block_align);",
"}",
"avio_wl16(pb, 0x01);",
"avio_w8(pb, 0x00);",
"} else {",
"avio_wl32(pb, enc->width);",
"avio_wl32(pb, enc->height);",
"avio_w8(pb, 2);",
"avio_wl16(pb, 40 + enc->extradata_size);",
"ff_put_bmp_header(pb, enc, ff_codec_bmp_tags, 1, 0);",
"}",
"end_header(pb, hpos);",
"}",
"hpos = put_header(pb, &ff_asf_codec_comment_header);",
"ff_put_guid(pb, &ff_asf_codec_comment1_header);",
"avio_wl32(pb, VAR_0->nb_streams);",
"for (VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++) {",
"const AVCodecDescriptor *codec_desc;",
"const char *desc;",
"enc = VAR_0->streams[VAR_4]->codec;",
"codec_desc = avcodec_descriptor_get(enc->codec_id);",
"if (enc->codec_type == AVMEDIA_TYPE_AUDIO)\navio_wl16(pb, 2);",
"else if (enc->codec_type == AVMEDIA_TYPE_VIDEO)\navio_wl16(pb, 1);",
"else\navio_wl16(pb, -1);",
"if (enc->codec_id == AV_CODEC_ID_WMAV2)\ndesc = \"Windows Media Audio V8\";",
"else\ndesc = codec_desc ? codec_desc->name : NULL;",
"if (desc) {",
"AVIOContext *dyn_buf;",
"uint8_t *buf;",
"int VAR_13;",
"if (avio_open_dyn_buf(&dyn_buf) < 0)\nreturn AVERROR(ENOMEM);",
"avio_put_str16le(dyn_buf, desc);",
"VAR_13 = avio_close_dyn_buf(dyn_buf, &buf);",
"avio_wl16(pb, VAR_13 / 2);",
"avio_write(pb, buf, VAR_13);",
"av_freep(&buf);",
"} else",
"avio_wl16(pb, 0);",
"avio_wl16(pb, 0);",
"if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {",
"avio_wl16(pb, 2);",
"avio_wl16(pb, enc->codec_tag);",
"} else {",
"avio_wl16(pb, 4);",
"avio_wl32(pb, enc->codec_tag);",
"}",
"if (!enc->codec_tag)\nreturn -1;",
"}",
"end_header(pb, hpos);",
"cur_pos = avio_tell(pb);",
"VAR_3 = cur_pos - header_offset;",
"if (asf->is_streamed) {",
"VAR_3 += 8 + 30 + DATA_HEADER_SIZE;",
"avio_seek(pb, header_offset - 10 - 30, SEEK_SET);",
"avio_wl16(pb, VAR_3);",
"avio_seek(pb, header_offset - 2 - 30, SEEK_SET);",
"avio_wl16(pb, VAR_3);",
"VAR_3 -= 8 + 30 + DATA_HEADER_SIZE;",
"}",
"VAR_3 += 24 + 6;",
"avio_seek(pb, header_offset - 14, SEEK_SET);",
"avio_wl64(pb, VAR_3);",
"avio_seek(pb, cur_pos, SEEK_SET);",
"asf->data_offset = cur_pos;",
"ff_put_guid(pb, &ff_asf_data_header);",
"avio_wl64(pb, VAR_2);",
"ff_put_guid(pb, &ff_asf_my_guid);",
"avio_wl64(pb, asf->nb_packets);",
"avio_w8(pb, 1);",
"avio_w8(pb, 1);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
61
],
[
65
],
[
67,
69,
71,
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155,
157,
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
213
],
[
215
],
[
217
],
[
219
],
[
223,
225
],
[
229
],
[
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
],
[
295
],
[
297
],
[
299
],
[
303
],
[
305,
307
],
[
309
],
[
311
],
[
313
],
[
315,
317,
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
361
],
[
365
],
[
369,
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411
],
[
413
],
[
415
],
[
421
],
[
423
],
[
425
],
[
427
],
[
435
],
[
437
],
[
439
],
[
441
],
[
443
],
[
445
],
[
449
],
[
451
],
[
455,
457
],
[
459,
461
],
[
463,
465
],
[
469,
471
],
[
473,
475
],
[
479
],
[
481
],
[
483
],
[
485
],
[
489,
491
],
[
495
],
[
497
],
[
499
],
[
503
],
[
505
],
[
507
],
[
509
],
[
513
],
[
519
],
[
521
],
[
523
],
[
525
],
[
527
],
[
529
],
[
531
],
[
533,
535
],
[
537
],
[
539
],
[
547
],
[
549
],
[
551
],
[
553
],
[
557
],
[
559
],
[
561
],
[
563
],
[
567
],
[
569
],
[
571
],
[
573
],
[
575
],
[
577
],
[
583
],
[
585
],
[
587
],
[
589
],
[
591
],
[
593
],
[
595
],
[
597
],
[
599
]
] |
3,198 | static unsigned int codec_get_asf_tag(const CodecTag *tags, unsigned int id)
{
while (tags->id != 0) {
if (!tags->invalid_asf && tags->id == id)
return tags->tag;
tags++;
}
return 0;
}
| false | FFmpeg | fb7a2bf6956173eda6f9caceef8599fa4f83500d | static unsigned int codec_get_asf_tag(const CodecTag *tags, unsigned int id)
{
while (tags->id != 0) {
if (!tags->invalid_asf && tags->id == id)
return tags->tag;
tags++;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static unsigned int FUNC_0(const CodecTag *VAR_0, unsigned int VAR_1)
{
while (VAR_0->VAR_1 != 0) {
if (!VAR_0->invalid_asf && VAR_0->VAR_1 == VAR_1)
return VAR_0->tag;
VAR_0++;
}
return 0;
}
| [
"static unsigned int FUNC_0(const CodecTag *VAR_0, unsigned int VAR_1)\n{",
"while (VAR_0->VAR_1 != 0) {",
"if (!VAR_0->invalid_asf && VAR_0->VAR_1 == VAR_1)\nreturn VAR_0->tag;",
"VAR_0++;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
3,199 | static int decode_cblk(J2kDecoderContext *s, J2kCodingStyle *codsty, J2kT1Context *t1, J2kCblk *cblk,
int width, int height, int bandpos)
{
int passno = cblk->npasses, pass_t = 2, bpno = cblk->nonzerobits - 1, y, clnpass_cnt = 0;
int bpass_csty_symbol = J2K_CBLK_BYPASS & codsty->cblk_style;
int vert_causal_ctx_csty_symbol = J2K_CBLK_VSC & codsty->cblk_style;
for (y = 0; y < height+2; y++)
memset(t1->flags[y], 0, (width+2)*sizeof(int));
for (y = 0; y < height; y++)
memset(t1->data[y], 0, width*sizeof(int));
ff_mqc_initdec(&t1->mqc, cblk->data);
cblk->data[cblk->length] = 0xff;
cblk->data[cblk->length+1] = 0xff;
while(passno--){
switch(pass_t){
case 0: decode_sigpass(t1, width, height, bpno+1, bandpos,
bpass_csty_symbol && (clnpass_cnt >= 4), vert_causal_ctx_csty_symbol);
break;
case 1: decode_refpass(t1, width, height, bpno+1);
if (bpass_csty_symbol && clnpass_cnt >= 4)
ff_mqc_initdec(&t1->mqc, cblk->data);
break;
case 2: decode_clnpass(s, t1, width, height, bpno+1, bandpos,
codsty->cblk_style & J2K_CBLK_SEGSYM);
clnpass_cnt = clnpass_cnt + 1;
if (bpass_csty_symbol && clnpass_cnt >= 4)
ff_mqc_initdec(&t1->mqc, cblk->data);
break;
}
pass_t++;
if (pass_t == 3){
bpno--;
pass_t = 0;
}
}
return 0;
}
| false | FFmpeg | 2fbf69103847d9449de466fa217f8bd4221aa3e9 | static int decode_cblk(J2kDecoderContext *s, J2kCodingStyle *codsty, J2kT1Context *t1, J2kCblk *cblk,
int width, int height, int bandpos)
{
int passno = cblk->npasses, pass_t = 2, bpno = cblk->nonzerobits - 1, y, clnpass_cnt = 0;
int bpass_csty_symbol = J2K_CBLK_BYPASS & codsty->cblk_style;
int vert_causal_ctx_csty_symbol = J2K_CBLK_VSC & codsty->cblk_style;
for (y = 0; y < height+2; y++)
memset(t1->flags[y], 0, (width+2)*sizeof(int));
for (y = 0; y < height; y++)
memset(t1->data[y], 0, width*sizeof(int));
ff_mqc_initdec(&t1->mqc, cblk->data);
cblk->data[cblk->length] = 0xff;
cblk->data[cblk->length+1] = 0xff;
while(passno--){
switch(pass_t){
case 0: decode_sigpass(t1, width, height, bpno+1, bandpos,
bpass_csty_symbol && (clnpass_cnt >= 4), vert_causal_ctx_csty_symbol);
break;
case 1: decode_refpass(t1, width, height, bpno+1);
if (bpass_csty_symbol && clnpass_cnt >= 4)
ff_mqc_initdec(&t1->mqc, cblk->data);
break;
case 2: decode_clnpass(s, t1, width, height, bpno+1, bandpos,
codsty->cblk_style & J2K_CBLK_SEGSYM);
clnpass_cnt = clnpass_cnt + 1;
if (bpass_csty_symbol && clnpass_cnt >= 4)
ff_mqc_initdec(&t1->mqc, cblk->data);
break;
}
pass_t++;
if (pass_t == 3){
bpno--;
pass_t = 0;
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(J2kDecoderContext *VAR_0, J2kCodingStyle *VAR_1, J2kT1Context *VAR_2, J2kCblk *VAR_3,
int VAR_4, int VAR_5, int VAR_6)
{
int VAR_7 = VAR_3->npasses, VAR_8 = 2, VAR_9 = VAR_3->nonzerobits - 1, VAR_10, VAR_11 = 0;
int VAR_12 = J2K_CBLK_BYPASS & VAR_1->cblk_style;
int VAR_13 = J2K_CBLK_VSC & VAR_1->cblk_style;
for (VAR_10 = 0; VAR_10 < VAR_5+2; VAR_10++)
memset(VAR_2->flags[VAR_10], 0, (VAR_4+2)*sizeof(int));
for (VAR_10 = 0; VAR_10 < VAR_5; VAR_10++)
memset(VAR_2->data[VAR_10], 0, VAR_4*sizeof(int));
ff_mqc_initdec(&VAR_2->mqc, VAR_3->data);
VAR_3->data[VAR_3->length] = 0xff;
VAR_3->data[VAR_3->length+1] = 0xff;
while(VAR_7--){
switch(VAR_8){
case 0: decode_sigpass(VAR_2, VAR_4, VAR_5, VAR_9+1, VAR_6,
VAR_12 && (VAR_11 >= 4), VAR_13);
break;
case 1: decode_refpass(VAR_2, VAR_4, VAR_5, VAR_9+1);
if (VAR_12 && VAR_11 >= 4)
ff_mqc_initdec(&VAR_2->mqc, VAR_3->data);
break;
case 2: decode_clnpass(VAR_0, VAR_2, VAR_4, VAR_5, VAR_9+1, VAR_6,
VAR_1->cblk_style & J2K_CBLK_SEGSYM);
VAR_11 = VAR_11 + 1;
if (VAR_12 && VAR_11 >= 4)
ff_mqc_initdec(&VAR_2->mqc, VAR_3->data);
break;
}
VAR_8++;
if (VAR_8 == 3){
VAR_9--;
VAR_8 = 0;
}
}
return 0;
}
| [
"static int FUNC_0(J2kDecoderContext *VAR_0, J2kCodingStyle *VAR_1, J2kT1Context *VAR_2, J2kCblk *VAR_3,\nint VAR_4, int VAR_5, int VAR_6)\n{",
"int VAR_7 = VAR_3->npasses, VAR_8 = 2, VAR_9 = VAR_3->nonzerobits - 1, VAR_10, VAR_11 = 0;",
"int VAR_12 = J2K_CBLK_BYPASS & VAR_1->cblk_style;",
"int VAR_13 = J2K_CBLK_VSC & VAR_1->cblk_style;",
"for (VAR_10 = 0; VAR_10 < VAR_5+2; VAR_10++)",
"memset(VAR_2->flags[VAR_10], 0, (VAR_4+2)*sizeof(int));",
"for (VAR_10 = 0; VAR_10 < VAR_5; VAR_10++)",
"memset(VAR_2->data[VAR_10], 0, VAR_4*sizeof(int));",
"ff_mqc_initdec(&VAR_2->mqc, VAR_3->data);",
"VAR_3->data[VAR_3->length] = 0xff;",
"VAR_3->data[VAR_3->length+1] = 0xff;",
"while(VAR_7--){",
"switch(VAR_8){",
"case 0: decode_sigpass(VAR_2, VAR_4, VAR_5, VAR_9+1, VAR_6,\nVAR_12 && (VAR_11 >= 4), VAR_13);",
"break;",
"case 1: decode_refpass(VAR_2, VAR_4, VAR_5, VAR_9+1);",
"if (VAR_12 && VAR_11 >= 4)\nff_mqc_initdec(&VAR_2->mqc, VAR_3->data);",
"break;",
"case 2: decode_clnpass(VAR_0, VAR_2, VAR_4, VAR_5, VAR_9+1, VAR_6,\nVAR_1->cblk_style & J2K_CBLK_SEGSYM);",
"VAR_11 = VAR_11 + 1;",
"if (VAR_12 && VAR_11 >= 4)\nff_mqc_initdec(&VAR_2->mqc, VAR_3->data);",
"break;",
"}",
"VAR_8++;",
"if (VAR_8 == 3){",
"VAR_9--;",
"VAR_8 = 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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
53,
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
]
] |
3,200 | static int do_token_out(USBDevice *s, USBPacket *p)
{
if (p->devep != 0)
return s->info->handle_data(s, p);
switch(s->setup_state) {
case SETUP_STATE_ACK:
if (s->setup_buf[0] & USB_DIR_IN) {
s->setup_state = SETUP_STATE_IDLE;
/* transfer OK */
} else {
/* ignore additional output */
}
return 0;
case SETUP_STATE_DATA:
if (!(s->setup_buf[0] & USB_DIR_IN)) {
int len = s->setup_len - s->setup_index;
if (len > p->len)
len = p->len;
memcpy(s->data_buf + s->setup_index, p->data, len);
s->setup_index += len;
if (s->setup_index >= s->setup_len)
s->setup_state = SETUP_STATE_ACK;
return len;
}
s->setup_state = SETUP_STATE_IDLE;
return USB_RET_STALL;
default:
return USB_RET_STALL;
}
}
| true | qemu | 4f4321c11ff6e98583846bfd6f0e81954924b003 | static int do_token_out(USBDevice *s, USBPacket *p)
{
if (p->devep != 0)
return s->info->handle_data(s, p);
switch(s->setup_state) {
case SETUP_STATE_ACK:
if (s->setup_buf[0] & USB_DIR_IN) {
s->setup_state = SETUP_STATE_IDLE;
} else {
}
return 0;
case SETUP_STATE_DATA:
if (!(s->setup_buf[0] & USB_DIR_IN)) {
int len = s->setup_len - s->setup_index;
if (len > p->len)
len = p->len;
memcpy(s->data_buf + s->setup_index, p->data, len);
s->setup_index += len;
if (s->setup_index >= s->setup_len)
s->setup_state = SETUP_STATE_ACK;
return len;
}
s->setup_state = SETUP_STATE_IDLE;
return USB_RET_STALL;
default:
return USB_RET_STALL;
}
}
| {
"code": [
" if (len > p->len)",
" len = p->len;",
" if (len > p->len)",
" len = p->len;",
" memcpy(s->data_buf + s->setup_index, p->data, len);"
],
"line_no": [
37,
39,
37,
39,
41
]
} | static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)
{
if (VAR_1->devep != 0)
return VAR_0->info->handle_data(VAR_0, VAR_1);
switch(VAR_0->setup_state) {
case SETUP_STATE_ACK:
if (VAR_0->setup_buf[0] & USB_DIR_IN) {
VAR_0->setup_state = SETUP_STATE_IDLE;
} else {
}
return 0;
case SETUP_STATE_DATA:
if (!(VAR_0->setup_buf[0] & USB_DIR_IN)) {
int VAR_2 = VAR_0->setup_len - VAR_0->setup_index;
if (VAR_2 > VAR_1->VAR_2)
VAR_2 = VAR_1->VAR_2;
memcpy(VAR_0->data_buf + VAR_0->setup_index, VAR_1->data, VAR_2);
VAR_0->setup_index += VAR_2;
if (VAR_0->setup_index >= VAR_0->setup_len)
VAR_0->setup_state = SETUP_STATE_ACK;
return VAR_2;
}
VAR_0->setup_state = SETUP_STATE_IDLE;
return USB_RET_STALL;
default:
return USB_RET_STALL;
}
}
| [
"static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)\n{",
"if (VAR_1->devep != 0)\nreturn VAR_0->info->handle_data(VAR_0, VAR_1);",
"switch(VAR_0->setup_state) {",
"case SETUP_STATE_ACK:\nif (VAR_0->setup_buf[0] & USB_DIR_IN) {",
"VAR_0->setup_state = SETUP_STATE_IDLE;",
"} else {",
"}",
"return 0;",
"case SETUP_STATE_DATA:\nif (!(VAR_0->setup_buf[0] & USB_DIR_IN)) {",
"int VAR_2 = VAR_0->setup_len - VAR_0->setup_index;",
"if (VAR_2 > VAR_1->VAR_2)\nVAR_2 = VAR_1->VAR_2;",
"memcpy(VAR_0->data_buf + VAR_0->setup_index, VAR_1->data, VAR_2);",
"VAR_0->setup_index += VAR_2;",
"if (VAR_0->setup_index >= VAR_0->setup_len)\nVAR_0->setup_state = SETUP_STATE_ACK;",
"return VAR_2;",
"}",
"VAR_0->setup_state = SETUP_STATE_IDLE;",
"return USB_RET_STALL;",
"default:\nreturn USB_RET_STALL;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
11
],
[
13,
15
],
[
17
],
[
21
],
[
25
],
[
27
],
[
31,
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
61,
63
],
[
65
],
[
67
]
] |
3,201 | static int coroutine_fn blkreplay_co_pwrite_zeroes(BlockDriverState *bs,
int64_t offset, int count, BdrvRequestFlags flags)
{
uint64_t reqid = request_id++;
int ret = bdrv_co_pwrite_zeroes(bs->file, offset, count, flags);
block_request_create(reqid, bs, qemu_coroutine_self());
qemu_coroutine_yield();
return ret;
}
| true | qemu | 6d0ceb80ffe18ad4b28aab7356f440636c0be7be | static int coroutine_fn blkreplay_co_pwrite_zeroes(BlockDriverState *bs,
int64_t offset, int count, BdrvRequestFlags flags)
{
uint64_t reqid = request_id++;
int ret = bdrv_co_pwrite_zeroes(bs->file, offset, count, flags);
block_request_create(reqid, bs, qemu_coroutine_self());
qemu_coroutine_yield();
return ret;
}
| {
"code": [
" uint64_t reqid = request_id++;",
" uint64_t reqid = request_id++;",
" uint64_t reqid = request_id++;",
" uint64_t reqid = request_id++;",
" uint64_t reqid = request_id++;"
],
"line_no": [
7,
7,
7,
7,
7
]
} | static int VAR_0 blkreplay_co_pwrite_zeroes(BlockDriverState *bs,
int64_t offset, int count, BdrvRequestFlags flags)
{
uint64_t reqid = request_id++;
int ret = bdrv_co_pwrite_zeroes(bs->file, offset, count, flags);
block_request_create(reqid, bs, qemu_coroutine_self());
qemu_coroutine_yield();
return ret;
}
| [
"static int VAR_0 blkreplay_co_pwrite_zeroes(BlockDriverState *bs,\nint64_t offset, int count, BdrvRequestFlags flags)\n{",
"uint64_t reqid = request_id++;",
"int ret = bdrv_co_pwrite_zeroes(bs->file, offset, count, flags);",
"block_request_create(reqid, bs, qemu_coroutine_self());",
"qemu_coroutine_yield();",
"return ret;",
"}"
] | [
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
]
] |
3,202 | int ff_eac3_parse_header(AC3DecodeContext *s)
{
int i, blk, ch;
int ac3_exponent_strategy, parse_aht_info, parse_spx_atten_data;
int parse_transient_proc_info;
int num_cpl_blocks;
GetBitContext *gbc = &s->gbc;
/* An E-AC-3 stream can have multiple independent streams which the
application can select from. each independent stream can also contain
dependent streams which are used to add or replace channels. */
if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT) {
avpriv_request_sample(s->avctx, "Dependent substream decoding");
return AAC_AC3_PARSE_ERROR_FRAME_TYPE;
} else if (s->frame_type == EAC3_FRAME_TYPE_RESERVED) {
av_log(s->avctx, AV_LOG_ERROR, "Reserved frame type\n");
return AAC_AC3_PARSE_ERROR_FRAME_TYPE;
}
/* The substream id indicates which substream this frame belongs to. each
independent stream has its own substream id, and the dependent streams
associated to an independent stream have matching substream id's. */
if (s->substreamid) {
/* only decode substream with id=0. skip any additional substreams. */
avpriv_request_sample(s->avctx, "Additional substreams");
return AAC_AC3_PARSE_ERROR_FRAME_TYPE;
}
if (s->bit_alloc_params.sr_code == EAC3_SR_CODE_REDUCED) {
/* The E-AC-3 specification does not tell how to handle reduced sample
rates in bit allocation. The best assumption would be that it is
handled like AC-3 DolbyNet, but we cannot be sure until we have a
sample which utilizes this feature. */
avpriv_request_sample(s->avctx, "Reduced sampling rate");
return AVERROR_PATCHWELCOME;
}
skip_bits(gbc, 5); // skip bitstream id
/* volume control params */
for (i = 0; i < (s->channel_mode ? 1 : 2); i++) {
skip_bits(gbc, 5); // skip dialog normalization
if (get_bits1(gbc)) {
skip_bits(gbc, 8); // skip compression gain word
}
}
/* dependent stream channel map */
if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT) {
if (get_bits1(gbc)) {
skip_bits(gbc, 16); // skip custom channel map
}
}
/* mixing metadata */
if (get_bits1(gbc)) {
/* center and surround mix levels */
if (s->channel_mode > AC3_CHMODE_STEREO) {
s->preferred_downmix = get_bits(gbc, 2);
if (s->channel_mode & 1) {
/* if three front channels exist */
s->center_mix_level_ltrt = get_bits(gbc, 3);
s->center_mix_level = get_bits(gbc, 3);
}
if (s->channel_mode & 4) {
/* if a surround channel exists */
s->surround_mix_level_ltrt = av_clip(get_bits(gbc, 3), 3, 7);
s->surround_mix_level = av_clip(get_bits(gbc, 3), 3, 7);
}
}
/* lfe mix level */
if (s->lfe_on && (s->lfe_mix_level_exists = get_bits1(gbc))) {
s->lfe_mix_level = get_bits(gbc, 5);
}
/* info for mixing with other streams and substreams */
if (s->frame_type == EAC3_FRAME_TYPE_INDEPENDENT) {
for (i = 0; i < (s->channel_mode ? 1 : 2); i++) {
// TODO: apply program scale factor
if (get_bits1(gbc)) {
skip_bits(gbc, 6); // skip program scale factor
}
}
if (get_bits1(gbc)) {
skip_bits(gbc, 6); // skip external program scale factor
}
/* skip mixing parameter data */
switch(get_bits(gbc, 2)) {
case 1: skip_bits(gbc, 5); break;
case 2: skip_bits(gbc, 12); break;
case 3: {
int mix_data_size = (get_bits(gbc, 5) + 2) << 3;
skip_bits_long(gbc, mix_data_size);
break;
}
}
/* skip pan information for mono or dual mono source */
if (s->channel_mode < AC3_CHMODE_STEREO) {
for (i = 0; i < (s->channel_mode ? 1 : 2); i++) {
if (get_bits1(gbc)) {
/* note: this is not in the ATSC A/52B specification
reference: ETSI TS 102 366 V1.1.1
section: E.1.3.1.25 */
skip_bits(gbc, 8); // skip pan mean direction index
skip_bits(gbc, 6); // skip reserved paninfo bits
}
}
}
/* skip mixing configuration information */
if (get_bits1(gbc)) {
for (blk = 0; blk < s->num_blocks; blk++) {
if (s->num_blocks == 1 || get_bits1(gbc)) {
skip_bits(gbc, 5);
}
}
}
}
}
/* informational metadata */
if (get_bits1(gbc)) {
s->bitstream_mode = get_bits(gbc, 3);
skip_bits(gbc, 2); // skip copyright bit and original bitstream bit
if (s->channel_mode == AC3_CHMODE_STEREO) {
s->dolby_surround_mode = get_bits(gbc, 2);
s->dolby_headphone_mode = get_bits(gbc, 2);
}
if (s->channel_mode >= AC3_CHMODE_2F2R) {
s->dolby_surround_ex_mode = get_bits(gbc, 2);
}
for (i = 0; i < (s->channel_mode ? 1 : 2); i++) {
if (get_bits1(gbc)) {
skip_bits(gbc, 8); // skip mix level, room type, and A/D converter type
}
}
if (s->bit_alloc_params.sr_code != EAC3_SR_CODE_REDUCED) {
skip_bits1(gbc); // skip source sample rate code
}
}
/* converter synchronization flag
If frames are less than six blocks, this bit should be turned on
once every 6 blocks to indicate the start of a frame set.
reference: RFC 4598, Section 2.1.3 Frame Sets */
if (s->frame_type == EAC3_FRAME_TYPE_INDEPENDENT && s->num_blocks != 6) {
skip_bits1(gbc); // skip converter synchronization flag
}
/* original frame size code if this stream was converted from AC-3 */
if (s->frame_type == EAC3_FRAME_TYPE_AC3_CONVERT &&
(s->num_blocks == 6 || get_bits1(gbc))) {
skip_bits(gbc, 6); // skip frame size code
}
/* additional bitstream info */
if (get_bits1(gbc)) {
int addbsil = get_bits(gbc, 6);
for (i = 0; i < addbsil + 1; i++) {
skip_bits(gbc, 8); // skip additional bit stream info
}
}
/* audio frame syntax flags, strategy data, and per-frame data */
if (s->num_blocks == 6) {
ac3_exponent_strategy = get_bits1(gbc);
parse_aht_info = get_bits1(gbc);
} else {
/* less than 6 blocks, so use AC-3-style exponent strategy syntax, and
do not use AHT */
ac3_exponent_strategy = 1;
parse_aht_info = 0;
}
s->snr_offset_strategy = get_bits(gbc, 2);
parse_transient_proc_info = get_bits1(gbc);
s->block_switch_syntax = get_bits1(gbc);
if (!s->block_switch_syntax)
memset(s->block_switch, 0, sizeof(s->block_switch));
s->dither_flag_syntax = get_bits1(gbc);
if (!s->dither_flag_syntax) {
for (ch = 1; ch <= s->fbw_channels; ch++)
s->dither_flag[ch] = 1;
}
s->dither_flag[CPL_CH] = s->dither_flag[s->lfe_ch] = 0;
s->bit_allocation_syntax = get_bits1(gbc);
if (!s->bit_allocation_syntax) {
/* set default bit allocation parameters */
s->bit_alloc_params.slow_decay = ff_ac3_slow_decay_tab[2];
s->bit_alloc_params.fast_decay = ff_ac3_fast_decay_tab[1];
s->bit_alloc_params.slow_gain = ff_ac3_slow_gain_tab [1];
s->bit_alloc_params.db_per_bit = ff_ac3_db_per_bit_tab[2];
s->bit_alloc_params.floor = ff_ac3_floor_tab [7];
}
s->fast_gain_syntax = get_bits1(gbc);
s->dba_syntax = get_bits1(gbc);
s->skip_syntax = get_bits1(gbc);
parse_spx_atten_data = get_bits1(gbc);
/* coupling strategy occurrence and coupling use per block */
num_cpl_blocks = 0;
if (s->channel_mode > 1) {
for (blk = 0; blk < s->num_blocks; blk++) {
s->cpl_strategy_exists[blk] = (!blk || get_bits1(gbc));
if (s->cpl_strategy_exists[blk]) {
s->cpl_in_use[blk] = get_bits1(gbc);
} else {
s->cpl_in_use[blk] = s->cpl_in_use[blk-1];
}
num_cpl_blocks += s->cpl_in_use[blk];
}
} else {
memset(s->cpl_in_use, 0, sizeof(s->cpl_in_use));
}
/* exponent strategy data */
if (ac3_exponent_strategy) {
/* AC-3-style exponent strategy syntax */
for (blk = 0; blk < s->num_blocks; blk++) {
for (ch = !s->cpl_in_use[blk]; ch <= s->fbw_channels; ch++) {
s->exp_strategy[blk][ch] = get_bits(gbc, 2);
}
}
} else {
/* LUT-based exponent strategy syntax */
for (ch = !((s->channel_mode > 1) && num_cpl_blocks); ch <= s->fbw_channels; ch++) {
int frmchexpstr = get_bits(gbc, 5);
for (blk = 0; blk < 6; blk++) {
s->exp_strategy[blk][ch] = ff_eac3_frm_expstr[frmchexpstr][blk];
}
}
}
/* LFE exponent strategy */
if (s->lfe_on) {
for (blk = 0; blk < s->num_blocks; blk++) {
s->exp_strategy[blk][s->lfe_ch] = get_bits1(gbc);
}
}
/* original exponent strategies if this stream was converted from AC-3 */
if (s->frame_type == EAC3_FRAME_TYPE_INDEPENDENT &&
(s->num_blocks == 6 || get_bits1(gbc))) {
skip_bits(gbc, 5 * s->fbw_channels); // skip converter channel exponent strategy
}
/* determine which channels use AHT */
if (parse_aht_info) {
/* For AHT to be used, all non-zero blocks must reuse exponents from
the first block. Furthermore, for AHT to be used in the coupling
channel, all blocks must use coupling and use the same coupling
strategy. */
s->channel_uses_aht[CPL_CH]=0;
for (ch = (num_cpl_blocks != 6); ch <= s->channels; ch++) {
int use_aht = 1;
for (blk = 1; blk < 6; blk++) {
if ((s->exp_strategy[blk][ch] != EXP_REUSE) ||
(!ch && s->cpl_strategy_exists[blk])) {
use_aht = 0;
break;
}
}
s->channel_uses_aht[ch] = use_aht && get_bits1(gbc);
}
} else {
memset(s->channel_uses_aht, 0, sizeof(s->channel_uses_aht));
}
/* per-frame SNR offset */
if (!s->snr_offset_strategy) {
int csnroffst = (get_bits(gbc, 6) - 15) << 4;
int snroffst = (csnroffst + get_bits(gbc, 4)) << 2;
for (ch = 0; ch <= s->channels; ch++)
s->snr_offset[ch] = snroffst;
}
/* transient pre-noise processing data */
if (parse_transient_proc_info) {
for (ch = 1; ch <= s->fbw_channels; ch++) {
if (get_bits1(gbc)) { // channel in transient processing
skip_bits(gbc, 10); // skip transient processing location
skip_bits(gbc, 8); // skip transient processing length
}
}
}
/* spectral extension attenuation data */
for (ch = 1; ch <= s->fbw_channels; ch++) {
if (parse_spx_atten_data && get_bits1(gbc)) {
s->spx_atten_code[ch] = get_bits(gbc, 5);
} else {
s->spx_atten_code[ch] = -1;
}
}
/* block start information */
if (s->num_blocks > 1 && get_bits1(gbc)) {
/* reference: Section E2.3.2.27
nblkstrtbits = (numblks - 1) * (4 + ceiling(log2(words_per_frame)))
The spec does not say what this data is or what it's used for.
It is likely the offset of each block within the frame. */
int block_start_bits = (s->num_blocks-1) * (4 + av_log2(s->frame_size-2));
skip_bits_long(gbc, block_start_bits);
avpriv_request_sample(s->avctx, "Block start info");
}
/* syntax state initialization */
for (ch = 1; ch <= s->fbw_channels; ch++) {
s->first_spx_coords[ch] = 1;
s->first_cpl_coords[ch] = 1;
}
s->first_cpl_leak = 1;
return 0;
}
| true | FFmpeg | 7b05b5093ea67a3397b0c37cf398bab471e1ce2b | int ff_eac3_parse_header(AC3DecodeContext *s)
{
int i, blk, ch;
int ac3_exponent_strategy, parse_aht_info, parse_spx_atten_data;
int parse_transient_proc_info;
int num_cpl_blocks;
GetBitContext *gbc = &s->gbc;
if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT) {
avpriv_request_sample(s->avctx, "Dependent substream decoding");
return AAC_AC3_PARSE_ERROR_FRAME_TYPE;
} else if (s->frame_type == EAC3_FRAME_TYPE_RESERVED) {
av_log(s->avctx, AV_LOG_ERROR, "Reserved frame type\n");
return AAC_AC3_PARSE_ERROR_FRAME_TYPE;
}
if (s->substreamid) {
avpriv_request_sample(s->avctx, "Additional substreams");
return AAC_AC3_PARSE_ERROR_FRAME_TYPE;
}
if (s->bit_alloc_params.sr_code == EAC3_SR_CODE_REDUCED) {
avpriv_request_sample(s->avctx, "Reduced sampling rate");
return AVERROR_PATCHWELCOME;
}
skip_bits(gbc, 5);
for (i = 0; i < (s->channel_mode ? 1 : 2); i++) {
skip_bits(gbc, 5);
if (get_bits1(gbc)) {
skip_bits(gbc, 8);
}
}
if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT) {
if (get_bits1(gbc)) {
skip_bits(gbc, 16);
}
}
if (get_bits1(gbc)) {
if (s->channel_mode > AC3_CHMODE_STEREO) {
s->preferred_downmix = get_bits(gbc, 2);
if (s->channel_mode & 1) {
s->center_mix_level_ltrt = get_bits(gbc, 3);
s->center_mix_level = get_bits(gbc, 3);
}
if (s->channel_mode & 4) {
s->surround_mix_level_ltrt = av_clip(get_bits(gbc, 3), 3, 7);
s->surround_mix_level = av_clip(get_bits(gbc, 3), 3, 7);
}
}
if (s->lfe_on && (s->lfe_mix_level_exists = get_bits1(gbc))) {
s->lfe_mix_level = get_bits(gbc, 5);
}
if (s->frame_type == EAC3_FRAME_TYPE_INDEPENDENT) {
for (i = 0; i < (s->channel_mode ? 1 : 2); i++) {
if (get_bits1(gbc)) {
skip_bits(gbc, 6);
}
}
if (get_bits1(gbc)) {
skip_bits(gbc, 6);
}
switch(get_bits(gbc, 2)) {
case 1: skip_bits(gbc, 5); break;
case 2: skip_bits(gbc, 12); break;
case 3: {
int mix_data_size = (get_bits(gbc, 5) + 2) << 3;
skip_bits_long(gbc, mix_data_size);
break;
}
}
if (s->channel_mode < AC3_CHMODE_STEREO) {
for (i = 0; i < (s->channel_mode ? 1 : 2); i++) {
if (get_bits1(gbc)) {
skip_bits(gbc, 8);
skip_bits(gbc, 6);
}
}
}
if (get_bits1(gbc)) {
for (blk = 0; blk < s->num_blocks; blk++) {
if (s->num_blocks == 1 || get_bits1(gbc)) {
skip_bits(gbc, 5);
}
}
}
}
}
if (get_bits1(gbc)) {
s->bitstream_mode = get_bits(gbc, 3);
skip_bits(gbc, 2);
if (s->channel_mode == AC3_CHMODE_STEREO) {
s->dolby_surround_mode = get_bits(gbc, 2);
s->dolby_headphone_mode = get_bits(gbc, 2);
}
if (s->channel_mode >= AC3_CHMODE_2F2R) {
s->dolby_surround_ex_mode = get_bits(gbc, 2);
}
for (i = 0; i < (s->channel_mode ? 1 : 2); i++) {
if (get_bits1(gbc)) {
skip_bits(gbc, 8);
}
}
if (s->bit_alloc_params.sr_code != EAC3_SR_CODE_REDUCED) {
skip_bits1(gbc);
}
}
if (s->frame_type == EAC3_FRAME_TYPE_INDEPENDENT && s->num_blocks != 6) {
skip_bits1(gbc);
}
if (s->frame_type == EAC3_FRAME_TYPE_AC3_CONVERT &&
(s->num_blocks == 6 || get_bits1(gbc))) {
skip_bits(gbc, 6);
}
if (get_bits1(gbc)) {
int addbsil = get_bits(gbc, 6);
for (i = 0; i < addbsil + 1; i++) {
skip_bits(gbc, 8);
}
}
if (s->num_blocks == 6) {
ac3_exponent_strategy = get_bits1(gbc);
parse_aht_info = get_bits1(gbc);
} else {
ac3_exponent_strategy = 1;
parse_aht_info = 0;
}
s->snr_offset_strategy = get_bits(gbc, 2);
parse_transient_proc_info = get_bits1(gbc);
s->block_switch_syntax = get_bits1(gbc);
if (!s->block_switch_syntax)
memset(s->block_switch, 0, sizeof(s->block_switch));
s->dither_flag_syntax = get_bits1(gbc);
if (!s->dither_flag_syntax) {
for (ch = 1; ch <= s->fbw_channels; ch++)
s->dither_flag[ch] = 1;
}
s->dither_flag[CPL_CH] = s->dither_flag[s->lfe_ch] = 0;
s->bit_allocation_syntax = get_bits1(gbc);
if (!s->bit_allocation_syntax) {
s->bit_alloc_params.slow_decay = ff_ac3_slow_decay_tab[2];
s->bit_alloc_params.fast_decay = ff_ac3_fast_decay_tab[1];
s->bit_alloc_params.slow_gain = ff_ac3_slow_gain_tab [1];
s->bit_alloc_params.db_per_bit = ff_ac3_db_per_bit_tab[2];
s->bit_alloc_params.floor = ff_ac3_floor_tab [7];
}
s->fast_gain_syntax = get_bits1(gbc);
s->dba_syntax = get_bits1(gbc);
s->skip_syntax = get_bits1(gbc);
parse_spx_atten_data = get_bits1(gbc);
num_cpl_blocks = 0;
if (s->channel_mode > 1) {
for (blk = 0; blk < s->num_blocks; blk++) {
s->cpl_strategy_exists[blk] = (!blk || get_bits1(gbc));
if (s->cpl_strategy_exists[blk]) {
s->cpl_in_use[blk] = get_bits1(gbc);
} else {
s->cpl_in_use[blk] = s->cpl_in_use[blk-1];
}
num_cpl_blocks += s->cpl_in_use[blk];
}
} else {
memset(s->cpl_in_use, 0, sizeof(s->cpl_in_use));
}
if (ac3_exponent_strategy) {
for (blk = 0; blk < s->num_blocks; blk++) {
for (ch = !s->cpl_in_use[blk]; ch <= s->fbw_channels; ch++) {
s->exp_strategy[blk][ch] = get_bits(gbc, 2);
}
}
} else {
for (ch = !((s->channel_mode > 1) && num_cpl_blocks); ch <= s->fbw_channels; ch++) {
int frmchexpstr = get_bits(gbc, 5);
for (blk = 0; blk < 6; blk++) {
s->exp_strategy[blk][ch] = ff_eac3_frm_expstr[frmchexpstr][blk];
}
}
}
if (s->lfe_on) {
for (blk = 0; blk < s->num_blocks; blk++) {
s->exp_strategy[blk][s->lfe_ch] = get_bits1(gbc);
}
}
if (s->frame_type == EAC3_FRAME_TYPE_INDEPENDENT &&
(s->num_blocks == 6 || get_bits1(gbc))) {
skip_bits(gbc, 5 * s->fbw_channels);
}
if (parse_aht_info) {
s->channel_uses_aht[CPL_CH]=0;
for (ch = (num_cpl_blocks != 6); ch <= s->channels; ch++) {
int use_aht = 1;
for (blk = 1; blk < 6; blk++) {
if ((s->exp_strategy[blk][ch] != EXP_REUSE) ||
(!ch && s->cpl_strategy_exists[blk])) {
use_aht = 0;
break;
}
}
s->channel_uses_aht[ch] = use_aht && get_bits1(gbc);
}
} else {
memset(s->channel_uses_aht, 0, sizeof(s->channel_uses_aht));
}
if (!s->snr_offset_strategy) {
int csnroffst = (get_bits(gbc, 6) - 15) << 4;
int snroffst = (csnroffst + get_bits(gbc, 4)) << 2;
for (ch = 0; ch <= s->channels; ch++)
s->snr_offset[ch] = snroffst;
}
if (parse_transient_proc_info) {
for (ch = 1; ch <= s->fbw_channels; ch++) {
if (get_bits1(gbc)) {
skip_bits(gbc, 10);
skip_bits(gbc, 8);
}
}
}
for (ch = 1; ch <= s->fbw_channels; ch++) {
if (parse_spx_atten_data && get_bits1(gbc)) {
s->spx_atten_code[ch] = get_bits(gbc, 5);
} else {
s->spx_atten_code[ch] = -1;
}
}
if (s->num_blocks > 1 && get_bits1(gbc)) {
int block_start_bits = (s->num_blocks-1) * (4 + av_log2(s->frame_size-2));
skip_bits_long(gbc, block_start_bits);
avpriv_request_sample(s->avctx, "Block start info");
}
for (ch = 1; ch <= s->fbw_channels; ch++) {
s->first_spx_coords[ch] = 1;
s->first_cpl_coords[ch] = 1;
}
s->first_cpl_leak = 1;
return 0;
}
| {
"code": [
"int ff_eac3_parse_header(AC3DecodeContext *s)"
],
"line_no": [
1
]
} | int FUNC_0(AC3DecodeContext *VAR_0)
{
int VAR_1, VAR_2, VAR_3;
int VAR_4, VAR_5, VAR_6;
int VAR_7;
int VAR_8;
GetBitContext *gbc = &VAR_0->gbc;
if (VAR_0->frame_type == EAC3_FRAME_TYPE_DEPENDENT) {
avpriv_request_sample(VAR_0->avctx, "Dependent substream decoding");
return AAC_AC3_PARSE_ERROR_FRAME_TYPE;
} else if (VAR_0->frame_type == EAC3_FRAME_TYPE_RESERVED) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Reserved frame type\n");
return AAC_AC3_PARSE_ERROR_FRAME_TYPE;
}
if (VAR_0->substreamid) {
avpriv_request_sample(VAR_0->avctx, "Additional substreams");
return AAC_AC3_PARSE_ERROR_FRAME_TYPE;
}
if (VAR_0->bit_alloc_params.sr_code == EAC3_SR_CODE_REDUCED) {
avpriv_request_sample(VAR_0->avctx, "Reduced sampling rate");
return AVERROR_PATCHWELCOME;
}
skip_bits(gbc, 5);
for (VAR_1 = 0; VAR_1 < (VAR_0->channel_mode ? 1 : 2); VAR_1++) {
skip_bits(gbc, 5);
if (get_bits1(gbc)) {
skip_bits(gbc, 8);
}
}
if (VAR_0->frame_type == EAC3_FRAME_TYPE_DEPENDENT) {
if (get_bits1(gbc)) {
skip_bits(gbc, 16);
}
}
if (get_bits1(gbc)) {
if (VAR_0->channel_mode > AC3_CHMODE_STEREO) {
VAR_0->preferred_downmix = get_bits(gbc, 2);
if (VAR_0->channel_mode & 1) {
VAR_0->center_mix_level_ltrt = get_bits(gbc, 3);
VAR_0->center_mix_level = get_bits(gbc, 3);
}
if (VAR_0->channel_mode & 4) {
VAR_0->surround_mix_level_ltrt = av_clip(get_bits(gbc, 3), 3, 7);
VAR_0->surround_mix_level = av_clip(get_bits(gbc, 3), 3, 7);
}
}
if (VAR_0->lfe_on && (VAR_0->lfe_mix_level_exists = get_bits1(gbc))) {
VAR_0->lfe_mix_level = get_bits(gbc, 5);
}
if (VAR_0->frame_type == EAC3_FRAME_TYPE_INDEPENDENT) {
for (VAR_1 = 0; VAR_1 < (VAR_0->channel_mode ? 1 : 2); VAR_1++) {
if (get_bits1(gbc)) {
skip_bits(gbc, 6);
}
}
if (get_bits1(gbc)) {
skip_bits(gbc, 6);
}
switch(get_bits(gbc, 2)) {
case 1: skip_bits(gbc, 5); break;
case 2: skip_bits(gbc, 12); break;
case 3: {
int VAR_9 = (get_bits(gbc, 5) + 2) << 3;
skip_bits_long(gbc, VAR_9);
break;
}
}
if (VAR_0->channel_mode < AC3_CHMODE_STEREO) {
for (VAR_1 = 0; VAR_1 < (VAR_0->channel_mode ? 1 : 2); VAR_1++) {
if (get_bits1(gbc)) {
skip_bits(gbc, 8);
skip_bits(gbc, 6);
}
}
}
if (get_bits1(gbc)) {
for (VAR_2 = 0; VAR_2 < VAR_0->num_blocks; VAR_2++) {
if (VAR_0->num_blocks == 1 || get_bits1(gbc)) {
skip_bits(gbc, 5);
}
}
}
}
}
if (get_bits1(gbc)) {
VAR_0->bitstream_mode = get_bits(gbc, 3);
skip_bits(gbc, 2);
if (VAR_0->channel_mode == AC3_CHMODE_STEREO) {
VAR_0->dolby_surround_mode = get_bits(gbc, 2);
VAR_0->dolby_headphone_mode = get_bits(gbc, 2);
}
if (VAR_0->channel_mode >= AC3_CHMODE_2F2R) {
VAR_0->dolby_surround_ex_mode = get_bits(gbc, 2);
}
for (VAR_1 = 0; VAR_1 < (VAR_0->channel_mode ? 1 : 2); VAR_1++) {
if (get_bits1(gbc)) {
skip_bits(gbc, 8);
}
}
if (VAR_0->bit_alloc_params.sr_code != EAC3_SR_CODE_REDUCED) {
skip_bits1(gbc);
}
}
if (VAR_0->frame_type == EAC3_FRAME_TYPE_INDEPENDENT && VAR_0->num_blocks != 6) {
skip_bits1(gbc);
}
if (VAR_0->frame_type == EAC3_FRAME_TYPE_AC3_CONVERT &&
(VAR_0->num_blocks == 6 || get_bits1(gbc))) {
skip_bits(gbc, 6);
}
if (get_bits1(gbc)) {
int VAR_10 = get_bits(gbc, 6);
for (VAR_1 = 0; VAR_1 < VAR_10 + 1; VAR_1++) {
skip_bits(gbc, 8);
}
}
if (VAR_0->num_blocks == 6) {
VAR_4 = get_bits1(gbc);
VAR_5 = get_bits1(gbc);
} else {
VAR_4 = 1;
VAR_5 = 0;
}
VAR_0->snr_offset_strategy = get_bits(gbc, 2);
VAR_7 = get_bits1(gbc);
VAR_0->block_switch_syntax = get_bits1(gbc);
if (!VAR_0->block_switch_syntax)
memset(VAR_0->block_switch, 0, sizeof(VAR_0->block_switch));
VAR_0->dither_flag_syntax = get_bits1(gbc);
if (!VAR_0->dither_flag_syntax) {
for (VAR_3 = 1; VAR_3 <= VAR_0->fbw_channels; VAR_3++)
VAR_0->dither_flag[VAR_3] = 1;
}
VAR_0->dither_flag[CPL_CH] = VAR_0->dither_flag[VAR_0->lfe_ch] = 0;
VAR_0->bit_allocation_syntax = get_bits1(gbc);
if (!VAR_0->bit_allocation_syntax) {
VAR_0->bit_alloc_params.slow_decay = ff_ac3_slow_decay_tab[2];
VAR_0->bit_alloc_params.fast_decay = ff_ac3_fast_decay_tab[1];
VAR_0->bit_alloc_params.slow_gain = ff_ac3_slow_gain_tab [1];
VAR_0->bit_alloc_params.db_per_bit = ff_ac3_db_per_bit_tab[2];
VAR_0->bit_alloc_params.floor = ff_ac3_floor_tab [7];
}
VAR_0->fast_gain_syntax = get_bits1(gbc);
VAR_0->dba_syntax = get_bits1(gbc);
VAR_0->skip_syntax = get_bits1(gbc);
VAR_6 = get_bits1(gbc);
VAR_8 = 0;
if (VAR_0->channel_mode > 1) {
for (VAR_2 = 0; VAR_2 < VAR_0->num_blocks; VAR_2++) {
VAR_0->cpl_strategy_exists[VAR_2] = (!VAR_2 || get_bits1(gbc));
if (VAR_0->cpl_strategy_exists[VAR_2]) {
VAR_0->cpl_in_use[VAR_2] = get_bits1(gbc);
} else {
VAR_0->cpl_in_use[VAR_2] = VAR_0->cpl_in_use[VAR_2-1];
}
VAR_8 += VAR_0->cpl_in_use[VAR_2];
}
} else {
memset(VAR_0->cpl_in_use, 0, sizeof(VAR_0->cpl_in_use));
}
if (VAR_4) {
for (VAR_2 = 0; VAR_2 < VAR_0->num_blocks; VAR_2++) {
for (VAR_3 = !VAR_0->cpl_in_use[VAR_2]; VAR_3 <= VAR_0->fbw_channels; VAR_3++) {
VAR_0->exp_strategy[VAR_2][VAR_3] = get_bits(gbc, 2);
}
}
} else {
for (VAR_3 = !((VAR_0->channel_mode > 1) && VAR_8); VAR_3 <= VAR_0->fbw_channels; VAR_3++) {
int frmchexpstr = get_bits(gbc, 5);
for (VAR_2 = 0; VAR_2 < 6; VAR_2++) {
VAR_0->exp_strategy[VAR_2][VAR_3] = ff_eac3_frm_expstr[frmchexpstr][VAR_2];
}
}
}
if (VAR_0->lfe_on) {
for (VAR_2 = 0; VAR_2 < VAR_0->num_blocks; VAR_2++) {
VAR_0->exp_strategy[VAR_2][VAR_0->lfe_ch] = get_bits1(gbc);
}
}
if (VAR_0->frame_type == EAC3_FRAME_TYPE_INDEPENDENT &&
(VAR_0->num_blocks == 6 || get_bits1(gbc))) {
skip_bits(gbc, 5 * VAR_0->fbw_channels);
}
if (VAR_5) {
VAR_0->channel_uses_aht[CPL_CH]=0;
for (VAR_3 = (VAR_8 != 6); VAR_3 <= VAR_0->channels; VAR_3++) {
int use_aht = 1;
for (VAR_2 = 1; VAR_2 < 6; VAR_2++) {
if ((VAR_0->exp_strategy[VAR_2][VAR_3] != EXP_REUSE) ||
(!VAR_3 && VAR_0->cpl_strategy_exists[VAR_2])) {
use_aht = 0;
break;
}
}
VAR_0->channel_uses_aht[VAR_3] = use_aht && get_bits1(gbc);
}
} else {
memset(VAR_0->channel_uses_aht, 0, sizeof(VAR_0->channel_uses_aht));
}
if (!VAR_0->snr_offset_strategy) {
int VAR_11 = (get_bits(gbc, 6) - 15) << 4;
int VAR_12 = (VAR_11 + get_bits(gbc, 4)) << 2;
for (VAR_3 = 0; VAR_3 <= VAR_0->channels; VAR_3++)
VAR_0->snr_offset[VAR_3] = VAR_12;
}
if (VAR_7) {
for (VAR_3 = 1; VAR_3 <= VAR_0->fbw_channels; VAR_3++) {
if (get_bits1(gbc)) {
skip_bits(gbc, 10);
skip_bits(gbc, 8);
}
}
}
for (VAR_3 = 1; VAR_3 <= VAR_0->fbw_channels; VAR_3++) {
if (VAR_6 && get_bits1(gbc)) {
VAR_0->spx_atten_code[VAR_3] = get_bits(gbc, 5);
} else {
VAR_0->spx_atten_code[VAR_3] = -1;
}
}
if (VAR_0->num_blocks > 1 && get_bits1(gbc)) {
int VAR_13 = (VAR_0->num_blocks-1) * (4 + av_log2(VAR_0->frame_size-2));
skip_bits_long(gbc, VAR_13);
avpriv_request_sample(VAR_0->avctx, "Block start info");
}
for (VAR_3 = 1; VAR_3 <= VAR_0->fbw_channels; VAR_3++) {
VAR_0->first_spx_coords[VAR_3] = 1;
VAR_0->first_cpl_coords[VAR_3] = 1;
}
VAR_0->first_cpl_leak = 1;
return 0;
}
| [
"int FUNC_0(AC3DecodeContext *VAR_0)\n{",
"int VAR_1, VAR_2, VAR_3;",
"int VAR_4, VAR_5, VAR_6;",
"int VAR_7;",
"int VAR_8;",
"GetBitContext *gbc = &VAR_0->gbc;",
"if (VAR_0->frame_type == EAC3_FRAME_TYPE_DEPENDENT) {",
"avpriv_request_sample(VAR_0->avctx, \"Dependent substream decoding\");",
"return AAC_AC3_PARSE_ERROR_FRAME_TYPE;",
"} else if (VAR_0->frame_type == EAC3_FRAME_TYPE_RESERVED) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Reserved frame type\\n\");",
"return AAC_AC3_PARSE_ERROR_FRAME_TYPE;",
"}",
"if (VAR_0->substreamid) {",
"avpriv_request_sample(VAR_0->avctx, \"Additional substreams\");",
"return AAC_AC3_PARSE_ERROR_FRAME_TYPE;",
"}",
"if (VAR_0->bit_alloc_params.sr_code == EAC3_SR_CODE_REDUCED) {",
"avpriv_request_sample(VAR_0->avctx, \"Reduced sampling rate\");",
"return AVERROR_PATCHWELCOME;",
"}",
"skip_bits(gbc, 5);",
"for (VAR_1 = 0; VAR_1 < (VAR_0->channel_mode ? 1 : 2); VAR_1++) {",
"skip_bits(gbc, 5);",
"if (get_bits1(gbc)) {",
"skip_bits(gbc, 8);",
"}",
"}",
"if (VAR_0->frame_type == EAC3_FRAME_TYPE_DEPENDENT) {",
"if (get_bits1(gbc)) {",
"skip_bits(gbc, 16);",
"}",
"}",
"if (get_bits1(gbc)) {",
"if (VAR_0->channel_mode > AC3_CHMODE_STEREO) {",
"VAR_0->preferred_downmix = get_bits(gbc, 2);",
"if (VAR_0->channel_mode & 1) {",
"VAR_0->center_mix_level_ltrt = get_bits(gbc, 3);",
"VAR_0->center_mix_level = get_bits(gbc, 3);",
"}",
"if (VAR_0->channel_mode & 4) {",
"VAR_0->surround_mix_level_ltrt = av_clip(get_bits(gbc, 3), 3, 7);",
"VAR_0->surround_mix_level = av_clip(get_bits(gbc, 3), 3, 7);",
"}",
"}",
"if (VAR_0->lfe_on && (VAR_0->lfe_mix_level_exists = get_bits1(gbc))) {",
"VAR_0->lfe_mix_level = get_bits(gbc, 5);",
"}",
"if (VAR_0->frame_type == EAC3_FRAME_TYPE_INDEPENDENT) {",
"for (VAR_1 = 0; VAR_1 < (VAR_0->channel_mode ? 1 : 2); VAR_1++) {",
"if (get_bits1(gbc)) {",
"skip_bits(gbc, 6);",
"}",
"}",
"if (get_bits1(gbc)) {",
"skip_bits(gbc, 6);",
"}",
"switch(get_bits(gbc, 2)) {",
"case 1: skip_bits(gbc, 5); break;",
"case 2: skip_bits(gbc, 12); break;",
"case 3: {",
"int VAR_9 = (get_bits(gbc, 5) + 2) << 3;",
"skip_bits_long(gbc, VAR_9);",
"break;",
"}",
"}",
"if (VAR_0->channel_mode < AC3_CHMODE_STEREO) {",
"for (VAR_1 = 0; VAR_1 < (VAR_0->channel_mode ? 1 : 2); VAR_1++) {",
"if (get_bits1(gbc)) {",
"skip_bits(gbc, 8);",
"skip_bits(gbc, 6);",
"}",
"}",
"}",
"if (get_bits1(gbc)) {",
"for (VAR_2 = 0; VAR_2 < VAR_0->num_blocks; VAR_2++) {",
"if (VAR_0->num_blocks == 1 || get_bits1(gbc)) {",
"skip_bits(gbc, 5);",
"}",
"}",
"}",
"}",
"}",
"if (get_bits1(gbc)) {",
"VAR_0->bitstream_mode = get_bits(gbc, 3);",
"skip_bits(gbc, 2);",
"if (VAR_0->channel_mode == AC3_CHMODE_STEREO) {",
"VAR_0->dolby_surround_mode = get_bits(gbc, 2);",
"VAR_0->dolby_headphone_mode = get_bits(gbc, 2);",
"}",
"if (VAR_0->channel_mode >= AC3_CHMODE_2F2R) {",
"VAR_0->dolby_surround_ex_mode = get_bits(gbc, 2);",
"}",
"for (VAR_1 = 0; VAR_1 < (VAR_0->channel_mode ? 1 : 2); VAR_1++) {",
"if (get_bits1(gbc)) {",
"skip_bits(gbc, 8);",
"}",
"}",
"if (VAR_0->bit_alloc_params.sr_code != EAC3_SR_CODE_REDUCED) {",
"skip_bits1(gbc);",
"}",
"}",
"if (VAR_0->frame_type == EAC3_FRAME_TYPE_INDEPENDENT && VAR_0->num_blocks != 6) {",
"skip_bits1(gbc);",
"}",
"if (VAR_0->frame_type == EAC3_FRAME_TYPE_AC3_CONVERT &&\n(VAR_0->num_blocks == 6 || get_bits1(gbc))) {",
"skip_bits(gbc, 6);",
"}",
"if (get_bits1(gbc)) {",
"int VAR_10 = get_bits(gbc, 6);",
"for (VAR_1 = 0; VAR_1 < VAR_10 + 1; VAR_1++) {",
"skip_bits(gbc, 8);",
"}",
"}",
"if (VAR_0->num_blocks == 6) {",
"VAR_4 = get_bits1(gbc);",
"VAR_5 = get_bits1(gbc);",
"} else {",
"VAR_4 = 1;",
"VAR_5 = 0;",
"}",
"VAR_0->snr_offset_strategy = get_bits(gbc, 2);",
"VAR_7 = get_bits1(gbc);",
"VAR_0->block_switch_syntax = get_bits1(gbc);",
"if (!VAR_0->block_switch_syntax)\nmemset(VAR_0->block_switch, 0, sizeof(VAR_0->block_switch));",
"VAR_0->dither_flag_syntax = get_bits1(gbc);",
"if (!VAR_0->dither_flag_syntax) {",
"for (VAR_3 = 1; VAR_3 <= VAR_0->fbw_channels; VAR_3++)",
"VAR_0->dither_flag[VAR_3] = 1;",
"}",
"VAR_0->dither_flag[CPL_CH] = VAR_0->dither_flag[VAR_0->lfe_ch] = 0;",
"VAR_0->bit_allocation_syntax = get_bits1(gbc);",
"if (!VAR_0->bit_allocation_syntax) {",
"VAR_0->bit_alloc_params.slow_decay = ff_ac3_slow_decay_tab[2];",
"VAR_0->bit_alloc_params.fast_decay = ff_ac3_fast_decay_tab[1];",
"VAR_0->bit_alloc_params.slow_gain = ff_ac3_slow_gain_tab [1];",
"VAR_0->bit_alloc_params.db_per_bit = ff_ac3_db_per_bit_tab[2];",
"VAR_0->bit_alloc_params.floor = ff_ac3_floor_tab [7];",
"}",
"VAR_0->fast_gain_syntax = get_bits1(gbc);",
"VAR_0->dba_syntax = get_bits1(gbc);",
"VAR_0->skip_syntax = get_bits1(gbc);",
"VAR_6 = get_bits1(gbc);",
"VAR_8 = 0;",
"if (VAR_0->channel_mode > 1) {",
"for (VAR_2 = 0; VAR_2 < VAR_0->num_blocks; VAR_2++) {",
"VAR_0->cpl_strategy_exists[VAR_2] = (!VAR_2 || get_bits1(gbc));",
"if (VAR_0->cpl_strategy_exists[VAR_2]) {",
"VAR_0->cpl_in_use[VAR_2] = get_bits1(gbc);",
"} else {",
"VAR_0->cpl_in_use[VAR_2] = VAR_0->cpl_in_use[VAR_2-1];",
"}",
"VAR_8 += VAR_0->cpl_in_use[VAR_2];",
"}",
"} else {",
"memset(VAR_0->cpl_in_use, 0, sizeof(VAR_0->cpl_in_use));",
"}",
"if (VAR_4) {",
"for (VAR_2 = 0; VAR_2 < VAR_0->num_blocks; VAR_2++) {",
"for (VAR_3 = !VAR_0->cpl_in_use[VAR_2]; VAR_3 <= VAR_0->fbw_channels; VAR_3++) {",
"VAR_0->exp_strategy[VAR_2][VAR_3] = get_bits(gbc, 2);",
"}",
"}",
"} else {",
"for (VAR_3 = !((VAR_0->channel_mode > 1) && VAR_8); VAR_3 <= VAR_0->fbw_channels; VAR_3++) {",
"int frmchexpstr = get_bits(gbc, 5);",
"for (VAR_2 = 0; VAR_2 < 6; VAR_2++) {",
"VAR_0->exp_strategy[VAR_2][VAR_3] = ff_eac3_frm_expstr[frmchexpstr][VAR_2];",
"}",
"}",
"}",
"if (VAR_0->lfe_on) {",
"for (VAR_2 = 0; VAR_2 < VAR_0->num_blocks; VAR_2++) {",
"VAR_0->exp_strategy[VAR_2][VAR_0->lfe_ch] = get_bits1(gbc);",
"}",
"}",
"if (VAR_0->frame_type == EAC3_FRAME_TYPE_INDEPENDENT &&\n(VAR_0->num_blocks == 6 || get_bits1(gbc))) {",
"skip_bits(gbc, 5 * VAR_0->fbw_channels);",
"}",
"if (VAR_5) {",
"VAR_0->channel_uses_aht[CPL_CH]=0;",
"for (VAR_3 = (VAR_8 != 6); VAR_3 <= VAR_0->channels; VAR_3++) {",
"int use_aht = 1;",
"for (VAR_2 = 1; VAR_2 < 6; VAR_2++) {",
"if ((VAR_0->exp_strategy[VAR_2][VAR_3] != EXP_REUSE) ||\n(!VAR_3 && VAR_0->cpl_strategy_exists[VAR_2])) {",
"use_aht = 0;",
"break;",
"}",
"}",
"VAR_0->channel_uses_aht[VAR_3] = use_aht && get_bits1(gbc);",
"}",
"} else {",
"memset(VAR_0->channel_uses_aht, 0, sizeof(VAR_0->channel_uses_aht));",
"}",
"if (!VAR_0->snr_offset_strategy) {",
"int VAR_11 = (get_bits(gbc, 6) - 15) << 4;",
"int VAR_12 = (VAR_11 + get_bits(gbc, 4)) << 2;",
"for (VAR_3 = 0; VAR_3 <= VAR_0->channels; VAR_3++)",
"VAR_0->snr_offset[VAR_3] = VAR_12;",
"}",
"if (VAR_7) {",
"for (VAR_3 = 1; VAR_3 <= VAR_0->fbw_channels; VAR_3++) {",
"if (get_bits1(gbc)) {",
"skip_bits(gbc, 10);",
"skip_bits(gbc, 8);",
"}",
"}",
"}",
"for (VAR_3 = 1; VAR_3 <= VAR_0->fbw_channels; VAR_3++) {",
"if (VAR_6 && get_bits1(gbc)) {",
"VAR_0->spx_atten_code[VAR_3] = get_bits(gbc, 5);",
"} else {",
"VAR_0->spx_atten_code[VAR_3] = -1;",
"}",
"}",
"if (VAR_0->num_blocks > 1 && get_bits1(gbc)) {",
"int VAR_13 = (VAR_0->num_blocks-1) * (4 + av_log2(VAR_0->frame_size-2));",
"skip_bits_long(gbc, VAR_13);",
"avpriv_request_sample(VAR_0->avctx, \"Block start info\");",
"}",
"for (VAR_3 = 1; VAR_3 <= VAR_0->fbw_channels; VAR_3++) {",
"VAR_0->first_spx_coords[VAR_3] = 1;",
"VAR_0->first_cpl_coords[VAR_3] = 1;",
"}",
"VAR_0->first_cpl_leak = 1;",
"return 0;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
45
],
[
49
],
[
51
],
[
53
],
[
57
],
[
67
],
[
69
],
[
71
],
[
73
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
109
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
143
],
[
145
],
[
147
],
[
153
],
[
155
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197
],
[
199
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
289
],
[
291
],
[
293
],
[
299,
301
],
[
303
],
[
305
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
329
],
[
331
],
[
333
],
[
335
],
[
341
],
[
343
],
[
345
],
[
349
],
[
351
],
[
355
],
[
357,
359
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
377
],
[
379
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
397
],
[
399
],
[
401
],
[
403
],
[
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
435
],
[
441
],
[
445
],
[
447
],
[
449
],
[
451
],
[
453
],
[
455
],
[
459
],
[
461
],
[
463
],
[
465
],
[
467
],
[
469
],
[
471
],
[
475
],
[
477
],
[
479
],
[
481
],
[
483
],
[
487,
489
],
[
491
],
[
493
],
[
499
],
[
509
],
[
511
],
[
513
],
[
515
],
[
517,
519
],
[
521
],
[
523
],
[
525
],
[
527
],
[
529
],
[
531
],
[
533
],
[
535
],
[
537
],
[
543
],
[
545
],
[
547
],
[
549
],
[
551
],
[
553
],
[
559
],
[
561
],
[
563
],
[
565
],
[
567
],
[
569
],
[
571
],
[
573
],
[
579
],
[
581
],
[
583
],
[
585
],
[
587
],
[
589
],
[
591
],
[
597
],
[
607
],
[
609
],
[
611
],
[
613
],
[
619
],
[
621
],
[
623
],
[
625
],
[
627
],
[
631
],
[
633
]
] |
3,203 | static void ipmi_init_sensors_from_sdrs(IPMIBmcSim *s)
{
unsigned int i, pos;
IPMISensor *sens;
for (i = 0; i < MAX_SENSORS; i++) {
memset(s->sensors + i, 0, sizeof(*sens));
}
pos = 0;
for (i = 0; !sdr_find_entry(&s->sdr, i, &pos, NULL); i++) {
struct ipmi_sdr_compact *sdr =
(struct ipmi_sdr_compact *) &s->sdr.sdr[pos];
unsigned int len = sdr->header.rec_length;
if (len < 20) {
continue;
}
if (sdr->header.rec_type != IPMI_SDR_COMPACT_TYPE) {
continue; /* Not a sensor SDR we set from */
}
if (sdr->sensor_owner_number > MAX_SENSORS) {
continue;
}
sens = s->sensors + sdr->sensor_owner_number;
IPMI_SENSOR_SET_PRESENT(sens, 1);
IPMI_SENSOR_SET_SCAN_ON(sens, (sdr->sensor_init >> 6) & 1);
IPMI_SENSOR_SET_EVENTS_ON(sens, (sdr->sensor_init >> 5) & 1);
sens->assert_suppt = sdr->assert_mask[0] | (sdr->assert_mask[1] << 8);
sens->deassert_suppt =
sdr->deassert_mask[0] | (sdr->deassert_mask[1] << 8);
sens->states_suppt =
sdr->discrete_mask[0] | (sdr->discrete_mask[1] << 8);
sens->sensor_type = sdr->sensor_type;
sens->evt_reading_type_code = sdr->reading_type & 0x7f;
/* Enable all the events that are supported. */
sens->assert_enable = sens->assert_suppt;
sens->deassert_enable = sens->deassert_suppt;
}
}
| true | qemu | 73d60fa5fae60c8e07e1f295d8c7fd5d04320160 | static void ipmi_init_sensors_from_sdrs(IPMIBmcSim *s)
{
unsigned int i, pos;
IPMISensor *sens;
for (i = 0; i < MAX_SENSORS; i++) {
memset(s->sensors + i, 0, sizeof(*sens));
}
pos = 0;
for (i = 0; !sdr_find_entry(&s->sdr, i, &pos, NULL); i++) {
struct ipmi_sdr_compact *sdr =
(struct ipmi_sdr_compact *) &s->sdr.sdr[pos];
unsigned int len = sdr->header.rec_length;
if (len < 20) {
continue;
}
if (sdr->header.rec_type != IPMI_SDR_COMPACT_TYPE) {
continue;
}
if (sdr->sensor_owner_number > MAX_SENSORS) {
continue;
}
sens = s->sensors + sdr->sensor_owner_number;
IPMI_SENSOR_SET_PRESENT(sens, 1);
IPMI_SENSOR_SET_SCAN_ON(sens, (sdr->sensor_init >> 6) & 1);
IPMI_SENSOR_SET_EVENTS_ON(sens, (sdr->sensor_init >> 5) & 1);
sens->assert_suppt = sdr->assert_mask[0] | (sdr->assert_mask[1] << 8);
sens->deassert_suppt =
sdr->deassert_mask[0] | (sdr->deassert_mask[1] << 8);
sens->states_suppt =
sdr->discrete_mask[0] | (sdr->discrete_mask[1] << 8);
sens->sensor_type = sdr->sensor_type;
sens->evt_reading_type_code = sdr->reading_type & 0x7f;
sens->assert_enable = sens->assert_suppt;
sens->deassert_enable = sens->deassert_suppt;
}
}
| {
"code": [
" if (sdr->sensor_owner_number > MAX_SENSORS) {"
],
"line_no": [
45
]
} | static void FUNC_0(IPMIBmcSim *VAR_0)
{
unsigned int VAR_1, VAR_2;
IPMISensor *sens;
for (VAR_1 = 0; VAR_1 < MAX_SENSORS; VAR_1++) {
memset(VAR_0->sensors + VAR_1, 0, sizeof(*sens));
}
VAR_2 = 0;
for (VAR_1 = 0; !sdr_find_entry(&VAR_0->sdr, VAR_1, &VAR_2, NULL); VAR_1++) {
struct ipmi_sdr_compact *sdr =
(struct ipmi_sdr_compact *) &VAR_0->sdr.sdr[VAR_2];
unsigned int len = sdr->header.rec_length;
if (len < 20) {
continue;
}
if (sdr->header.rec_type != IPMI_SDR_COMPACT_TYPE) {
continue;
}
if (sdr->sensor_owner_number > MAX_SENSORS) {
continue;
}
sens = VAR_0->sensors + sdr->sensor_owner_number;
IPMI_SENSOR_SET_PRESENT(sens, 1);
IPMI_SENSOR_SET_SCAN_ON(sens, (sdr->sensor_init >> 6) & 1);
IPMI_SENSOR_SET_EVENTS_ON(sens, (sdr->sensor_init >> 5) & 1);
sens->assert_suppt = sdr->assert_mask[0] | (sdr->assert_mask[1] << 8);
sens->deassert_suppt =
sdr->deassert_mask[0] | (sdr->deassert_mask[1] << 8);
sens->states_suppt =
sdr->discrete_mask[0] | (sdr->discrete_mask[1] << 8);
sens->sensor_type = sdr->sensor_type;
sens->evt_reading_type_code = sdr->reading_type & 0x7f;
sens->assert_enable = sens->assert_suppt;
sens->deassert_enable = sens->deassert_suppt;
}
}
| [
"static void FUNC_0(IPMIBmcSim *VAR_0)\n{",
"unsigned int VAR_1, VAR_2;",
"IPMISensor *sens;",
"for (VAR_1 = 0; VAR_1 < MAX_SENSORS; VAR_1++) {",
"memset(VAR_0->sensors + VAR_1, 0, sizeof(*sens));",
"}",
"VAR_2 = 0;",
"for (VAR_1 = 0; !sdr_find_entry(&VAR_0->sdr, VAR_1, &VAR_2, NULL); VAR_1++) {",
"struct ipmi_sdr_compact *sdr =\n(struct ipmi_sdr_compact *) &VAR_0->sdr.sdr[VAR_2];",
"unsigned int len = sdr->header.rec_length;",
"if (len < 20) {",
"continue;",
"}",
"if (sdr->header.rec_type != IPMI_SDR_COMPACT_TYPE) {",
"continue;",
"}",
"if (sdr->sensor_owner_number > MAX_SENSORS) {",
"continue;",
"}",
"sens = VAR_0->sensors + sdr->sensor_owner_number;",
"IPMI_SENSOR_SET_PRESENT(sens, 1);",
"IPMI_SENSOR_SET_SCAN_ON(sens, (sdr->sensor_init >> 6) & 1);",
"IPMI_SENSOR_SET_EVENTS_ON(sens, (sdr->sensor_init >> 5) & 1);",
"sens->assert_suppt = sdr->assert_mask[0] | (sdr->assert_mask[1] << 8);",
"sens->deassert_suppt =\nsdr->deassert_mask[0] | (sdr->deassert_mask[1] << 8);",
"sens->states_suppt =\nsdr->discrete_mask[0] | (sdr->discrete_mask[1] << 8);",
"sens->sensor_type = sdr->sensor_type;",
"sens->evt_reading_type_code = sdr->reading_type & 0x7f;",
"sens->assert_enable = sens->assert_suppt;",
"sens->deassert_enable = sens->deassert_suppt;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63,
65
],
[
67,
69
],
[
71
],
[
73
],
[
79
],
[
81
],
[
83
],
[
85
]
] |
3,204 | static int calc_bit_demand(AacPsyContext *ctx, float pe, int bits, int size,
int short_window)
{
const float bitsave_slope = short_window ? PSY_3GPP_SAVE_SLOPE_S : PSY_3GPP_SAVE_SLOPE_L;
const float bitsave_add = short_window ? PSY_3GPP_SAVE_ADD_S : PSY_3GPP_SAVE_ADD_L;
const float bitspend_slope = short_window ? PSY_3GPP_SPEND_SLOPE_S : PSY_3GPP_SPEND_SLOPE_L;
const float bitspend_add = short_window ? PSY_3GPP_SPEND_ADD_S : PSY_3GPP_SPEND_ADD_L;
const float clip_low = short_window ? PSY_3GPP_CLIP_LO_S : PSY_3GPP_CLIP_LO_L;
const float clip_high = short_window ? PSY_3GPP_CLIP_HI_S : PSY_3GPP_CLIP_HI_L;
float clipped_pe, bit_save, bit_spend, bit_factor, fill_level;
ctx->fill_level += ctx->frame_bits - bits;
ctx->fill_level = av_clip(ctx->fill_level, 0, size);
fill_level = av_clipf((float)ctx->fill_level / size, clip_low, clip_high);
clipped_pe = av_clipf(pe, ctx->pe.min, ctx->pe.max);
bit_save = (fill_level + bitsave_add) * bitsave_slope;
assert(bit_save <= 0.3f && bit_save >= -0.05000001f);
bit_spend = (fill_level + bitspend_add) * bitspend_slope;
assert(bit_spend <= 0.5f && bit_spend >= -0.1f);
/* The bit factor graph in the spec is obviously incorrect.
* bit_spend + ((bit_spend - bit_spend))...
* The reference encoder subtracts everything from 1, but also seems incorrect.
* 1 - bit_save + ((bit_spend + bit_save))...
* Hopefully below is correct.
*/
bit_factor = 1.0f - bit_save + ((bit_spend - bit_save) / (ctx->pe.max - ctx->pe.min)) * (clipped_pe - ctx->pe.min);
/* NOTE: The reference encoder attempts to center pe max/min around the current pe. */
ctx->pe.max = FFMAX(pe, ctx->pe.max);
ctx->pe.min = FFMIN(pe, ctx->pe.min);
return FFMIN(ctx->frame_bits * bit_factor, ctx->frame_bits + size - bits);
}
| true | FFmpeg | 01ecb7172b684f1c4b3e748f95c5a9a494ca36ec | static int calc_bit_demand(AacPsyContext *ctx, float pe, int bits, int size,
int short_window)
{
const float bitsave_slope = short_window ? PSY_3GPP_SAVE_SLOPE_S : PSY_3GPP_SAVE_SLOPE_L;
const float bitsave_add = short_window ? PSY_3GPP_SAVE_ADD_S : PSY_3GPP_SAVE_ADD_L;
const float bitspend_slope = short_window ? PSY_3GPP_SPEND_SLOPE_S : PSY_3GPP_SPEND_SLOPE_L;
const float bitspend_add = short_window ? PSY_3GPP_SPEND_ADD_S : PSY_3GPP_SPEND_ADD_L;
const float clip_low = short_window ? PSY_3GPP_CLIP_LO_S : PSY_3GPP_CLIP_LO_L;
const float clip_high = short_window ? PSY_3GPP_CLIP_HI_S : PSY_3GPP_CLIP_HI_L;
float clipped_pe, bit_save, bit_spend, bit_factor, fill_level;
ctx->fill_level += ctx->frame_bits - bits;
ctx->fill_level = av_clip(ctx->fill_level, 0, size);
fill_level = av_clipf((float)ctx->fill_level / size, clip_low, clip_high);
clipped_pe = av_clipf(pe, ctx->pe.min, ctx->pe.max);
bit_save = (fill_level + bitsave_add) * bitsave_slope;
assert(bit_save <= 0.3f && bit_save >= -0.05000001f);
bit_spend = (fill_level + bitspend_add) * bitspend_slope;
assert(bit_spend <= 0.5f && bit_spend >= -0.1f);
bit_factor = 1.0f - bit_save + ((bit_spend - bit_save) / (ctx->pe.max - ctx->pe.min)) * (clipped_pe - ctx->pe.min);
ctx->pe.max = FFMAX(pe, ctx->pe.max);
ctx->pe.min = FFMIN(pe, ctx->pe.min);
return FFMIN(ctx->frame_bits * bit_factor, ctx->frame_bits + size - bits);
}
| {
"code": [
" return FFMIN(ctx->frame_bits * bit_factor, ctx->frame_bits + size - bits);"
],
"line_no": [
61
]
} | static int FUNC_0(AacPsyContext *VAR_0, float VAR_1, int VAR_2, int VAR_3,
int VAR_4)
{
const float VAR_5 = VAR_4 ? PSY_3GPP_SAVE_SLOPE_S : PSY_3GPP_SAVE_SLOPE_L;
const float VAR_6 = VAR_4 ? PSY_3GPP_SAVE_ADD_S : PSY_3GPP_SAVE_ADD_L;
const float VAR_7 = VAR_4 ? PSY_3GPP_SPEND_SLOPE_S : PSY_3GPP_SPEND_SLOPE_L;
const float VAR_8 = VAR_4 ? PSY_3GPP_SPEND_ADD_S : PSY_3GPP_SPEND_ADD_L;
const float VAR_9 = VAR_4 ? PSY_3GPP_CLIP_LO_S : PSY_3GPP_CLIP_LO_L;
const float VAR_10 = VAR_4 ? PSY_3GPP_CLIP_HI_S : PSY_3GPP_CLIP_HI_L;
float VAR_11, VAR_12, VAR_13, VAR_14, VAR_15;
VAR_0->VAR_15 += VAR_0->frame_bits - VAR_2;
VAR_0->VAR_15 = av_clip(VAR_0->VAR_15, 0, VAR_3);
VAR_15 = av_clipf((float)VAR_0->VAR_15 / VAR_3, VAR_9, VAR_10);
VAR_11 = av_clipf(VAR_1, VAR_0->VAR_1.min, VAR_0->VAR_1.max);
VAR_12 = (VAR_15 + VAR_6) * VAR_5;
assert(VAR_12 <= 0.3f && VAR_12 >= -0.05000001f);
VAR_13 = (VAR_15 + VAR_8) * VAR_7;
assert(VAR_13 <= 0.5f && VAR_13 >= -0.1f);
VAR_14 = 1.0f - VAR_12 + ((VAR_13 - VAR_12) / (VAR_0->VAR_1.max - VAR_0->VAR_1.min)) * (VAR_11 - VAR_0->VAR_1.min);
VAR_0->VAR_1.max = FFMAX(VAR_1, VAR_0->VAR_1.max);
VAR_0->VAR_1.min = FFMIN(VAR_1, VAR_0->VAR_1.min);
return FFMIN(VAR_0->frame_bits * VAR_14, VAR_0->frame_bits + VAR_3 - VAR_2);
}
| [
"static int FUNC_0(AacPsyContext *VAR_0, float VAR_1, int VAR_2, int VAR_3,\nint VAR_4)\n{",
"const float VAR_5 = VAR_4 ? PSY_3GPP_SAVE_SLOPE_S : PSY_3GPP_SAVE_SLOPE_L;",
"const float VAR_6 = VAR_4 ? PSY_3GPP_SAVE_ADD_S : PSY_3GPP_SAVE_ADD_L;",
"const float VAR_7 = VAR_4 ? PSY_3GPP_SPEND_SLOPE_S : PSY_3GPP_SPEND_SLOPE_L;",
"const float VAR_8 = VAR_4 ? PSY_3GPP_SPEND_ADD_S : PSY_3GPP_SPEND_ADD_L;",
"const float VAR_9 = VAR_4 ? PSY_3GPP_CLIP_LO_S : PSY_3GPP_CLIP_LO_L;",
"const float VAR_10 = VAR_4 ? PSY_3GPP_CLIP_HI_S : PSY_3GPP_CLIP_HI_L;",
"float VAR_11, VAR_12, VAR_13, VAR_14, VAR_15;",
"VAR_0->VAR_15 += VAR_0->frame_bits - VAR_2;",
"VAR_0->VAR_15 = av_clip(VAR_0->VAR_15, 0, VAR_3);",
"VAR_15 = av_clipf((float)VAR_0->VAR_15 / VAR_3, VAR_9, VAR_10);",
"VAR_11 = av_clipf(VAR_1, VAR_0->VAR_1.min, VAR_0->VAR_1.max);",
"VAR_12 = (VAR_15 + VAR_6) * VAR_5;",
"assert(VAR_12 <= 0.3f && VAR_12 >= -0.05000001f);",
"VAR_13 = (VAR_15 + VAR_8) * VAR_7;",
"assert(VAR_13 <= 0.5f && VAR_13 >= -0.1f);",
"VAR_14 = 1.0f - VAR_12 + ((VAR_13 - VAR_12) / (VAR_0->VAR_1.max - VAR_0->VAR_1.min)) * (VAR_11 - VAR_0->VAR_1.min);",
"VAR_0->VAR_1.max = FFMAX(VAR_1, VAR_0->VAR_1.max);",
"VAR_0->VAR_1.min = FFMIN(VAR_1, VAR_0->VAR_1.min);",
"return FFMIN(VAR_0->frame_bits * VAR_14, VAR_0->frame_bits + VAR_3 - VAR_2);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
51
],
[
55
],
[
57
],
[
61
],
[
63
]
] |
3,206 | static void RENAME(yuyvtoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
long width, long height,
long lumStride, long chromStride, long srcStride)
{
long y;
const long chromWidth= -((-width)>>1);
for (y=0; y<height; y++) {
RENAME(extract_even)(src, ydst, width);
if(y&1) {
RENAME(extract_odd2avg)(src-srcStride, src, udst, vdst, chromWidth);
udst+= chromStride;
vdst+= chromStride;
}
src += srcStride;
ydst+= lumStride;
}
#if COMPILE_TEMPLATE_MMX
__asm__(
EMMS" \n\t"
SFENCE" \n\t"
::: "memory"
);
#endif
}
| false | FFmpeg | d1adad3cca407f493c3637e20ecd4f7124e69212 | static void RENAME(yuyvtoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
long width, long height,
long lumStride, long chromStride, long srcStride)
{
long y;
const long chromWidth= -((-width)>>1);
for (y=0; y<height; y++) {
RENAME(extract_even)(src, ydst, width);
if(y&1) {
RENAME(extract_odd2avg)(src-srcStride, src, udst, vdst, chromWidth);
udst+= chromStride;
vdst+= chromStride;
}
src += srcStride;
ydst+= lumStride;
}
#if COMPILE_TEMPLATE_MMX
__asm__(
EMMS" \n\t"
SFENCE" \n\t"
::: "memory"
);
#endif
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(yuyvtoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
long width, long height,
long lumStride, long chromStride, long srcStride)
{
long VAR_0;
const long VAR_1= -((-width)>>1);
for (VAR_0=0; VAR_0<height; VAR_0++) {
FUNC_0(extract_even)(src, ydst, width);
if(VAR_0&1) {
FUNC_0(extract_odd2avg)(src-srcStride, src, udst, vdst, VAR_1);
udst+= chromStride;
vdst+= chromStride;
}
src += srcStride;
ydst+= lumStride;
}
#if COMPILE_TEMPLATE_MMX
__asm__(
EMMS" \n\t"
SFENCE" \n\t"
::: "memory"
);
#endif
}
| [
"static void FUNC_0(yuyvtoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,\nlong width, long height,\nlong lumStride, long chromStride, long srcStride)\n{",
"long VAR_0;",
"const long VAR_1= -((-width)>>1);",
"for (VAR_0=0; VAR_0<height; VAR_0++) {",
"FUNC_0(extract_even)(src, ydst, width);",
"if(VAR_0&1) {",
"FUNC_0(extract_odd2avg)(src-srcStride, src, udst, vdst, VAR_1);",
"udst+= chromStride;",
"vdst+= chromStride;",
"}",
"src += srcStride;",
"ydst+= lumStride;",
"}",
"#if COMPILE_TEMPLATE_MMX\n__asm__(\nEMMS\" \\n\\t\"\nSFENCE\" \\n\\t\"\n::: \"memory\"\n);",
"#endif\n}"
] | [
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
],
[
31
],
[
33
],
[
35
],
[
37,
39,
41,
43,
45,
47
],
[
49,
51
]
] |
3,208 | static uint64_t log16(uint64_t a){
int i;
int out=0;
assert(a >= (1<<16));
a<<=16;
for(i=19;i>=0;i--){
if(a<(exp16_table[i]<<16)) continue;
out |= 1<<i;
a = ((a<<16) + exp16_table[i]/2)/exp16_table[i];
}
return out;
}
| true | FFmpeg | 8176bd1a4689ff08b0e85984563ad8288110f1a7 | static uint64_t log16(uint64_t a){
int i;
int out=0;
assert(a >= (1<<16));
a<<=16;
for(i=19;i>=0;i--){
if(a<(exp16_table[i]<<16)) continue;
out |= 1<<i;
a = ((a<<16) + exp16_table[i]/2)/exp16_table[i];
}
return out;
}
| {
"code": [
" if(a<(exp16_table[i]<<16)) continue;",
" a = ((a<<16) + exp16_table[i]/2)/exp16_table[i];"
],
"line_no": [
17,
21
]
} | static uint64_t FUNC_0(uint64_t a){
int VAR_0;
int VAR_1=0;
assert(a >= (1<<16));
a<<=16;
for(VAR_0=19;VAR_0>=0;VAR_0--){
if(a<(exp16_table[VAR_0]<<16)) continue;
VAR_1 |= 1<<VAR_0;
a = ((a<<16) + exp16_table[VAR_0]/2)/exp16_table[VAR_0];
}
return VAR_1;
}
| [
"static uint64_t FUNC_0(uint64_t a){",
"int VAR_0;",
"int VAR_1=0;",
"assert(a >= (1<<16));",
"a<<=16;",
"for(VAR_0=19;VAR_0>=0;VAR_0--){",
"if(a<(exp16_table[VAR_0]<<16)) continue;",
"VAR_1 |= 1<<VAR_0;",
"a = ((a<<16) + exp16_table[VAR_0]/2)/exp16_table[VAR_0];",
"}",
"return VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
3,209 | static int mxf_read_track(void *arg, AVIOContext *pb, int tag, int size, UID uid)
{
MXFTrack *track = arg;
switch(tag) {
case 0x4801:
track->track_id = avio_rb32(pb);
break;
case 0x4804:
avio_read(pb, track->track_number, 4);
break;
case 0x4B01:
track->edit_rate.den = avio_rb32(pb);
track->edit_rate.num = avio_rb32(pb);
break;
case 0x4803:
avio_read(pb, track->sequence_ref, 16);
break;
}
return 0;
}
| true | FFmpeg | fd34dbea58e097609ff09cf7dcc59f74930195d3 | static int mxf_read_track(void *arg, AVIOContext *pb, int tag, int size, UID uid)
{
MXFTrack *track = arg;
switch(tag) {
case 0x4801:
track->track_id = avio_rb32(pb);
break;
case 0x4804:
avio_read(pb, track->track_number, 4);
break;
case 0x4B01:
track->edit_rate.den = avio_rb32(pb);
track->edit_rate.num = avio_rb32(pb);
break;
case 0x4803:
avio_read(pb, track->sequence_ref, 16);
break;
}
return 0;
}
| {
"code": [
"static int mxf_read_track(void *arg, AVIOContext *pb, int tag, int size, UID uid)"
],
"line_no": [
1
]
} | static int FUNC_0(void *VAR_0, AVIOContext *VAR_1, int VAR_2, int VAR_3, UID VAR_4)
{
MXFTrack *track = VAR_0;
switch(VAR_2) {
case 0x4801:
track->track_id = avio_rb32(VAR_1);
break;
case 0x4804:
avio_read(VAR_1, track->track_number, 4);
break;
case 0x4B01:
track->edit_rate.den = avio_rb32(VAR_1);
track->edit_rate.num = avio_rb32(VAR_1);
break;
case 0x4803:
avio_read(VAR_1, track->sequence_ref, 16);
break;
}
return 0;
}
| [
"static int FUNC_0(void *VAR_0, AVIOContext *VAR_1, int VAR_2, int VAR_3, UID VAR_4)\n{",
"MXFTrack *track = VAR_0;",
"switch(VAR_2) {",
"case 0x4801:\ntrack->track_id = avio_rb32(VAR_1);",
"break;",
"case 0x4804:\navio_read(VAR_1, track->track_number, 4);",
"break;",
"case 0x4B01:\ntrack->edit_rate.den = avio_rb32(VAR_1);",
"track->edit_rate.num = avio_rb32(VAR_1);",
"break;",
"case 0x4803:\navio_read(VAR_1, track->sequence_ref, 16);",
"break;",
"}",
"return 0;",
"}"
] | [
1,
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
]
] |
3,210 | void pl181_init(uint32_t base, BlockDriverState *bd,
qemu_irq irq0, qemu_irq irq1)
{
int iomemtype;
pl181_state *s;
s = (pl181_state *)qemu_mallocz(sizeof(pl181_state));
iomemtype = cpu_register_io_memory(0, pl181_readfn,
pl181_writefn, s);
cpu_register_physical_memory(base, 0x00000fff, iomemtype);
s->base = base;
s->card = sd_init(bd);
s->irq[0] = irq0;
s->irq[1] = irq1;
qemu_register_reset(pl181_reset, s);
pl181_reset(s);
/* ??? Save/restore. */
}
| true | qemu | 187337f8b0ec0813dd3876d1efe37d415fb81c2e | void pl181_init(uint32_t base, BlockDriverState *bd,
qemu_irq irq0, qemu_irq irq1)
{
int iomemtype;
pl181_state *s;
s = (pl181_state *)qemu_mallocz(sizeof(pl181_state));
iomemtype = cpu_register_io_memory(0, pl181_readfn,
pl181_writefn, s);
cpu_register_physical_memory(base, 0x00000fff, iomemtype);
s->base = base;
s->card = sd_init(bd);
s->irq[0] = irq0;
s->irq[1] = irq1;
qemu_register_reset(pl181_reset, s);
pl181_reset(s);
}
| {
"code": [
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);"
],
"line_no": [
19,
19,
19,
19,
19,
19,
19,
19,
19,
19,
19,
19
]
} | void FUNC_0(uint32_t VAR_0, BlockDriverState *VAR_1,
qemu_irq VAR_2, qemu_irq VAR_3)
{
int VAR_4;
pl181_state *s;
s = (pl181_state *)qemu_mallocz(sizeof(pl181_state));
VAR_4 = cpu_register_io_memory(0, pl181_readfn,
pl181_writefn, s);
cpu_register_physical_memory(VAR_0, 0x00000fff, VAR_4);
s->VAR_0 = VAR_0;
s->card = sd_init(VAR_1);
s->irq[0] = VAR_2;
s->irq[1] = VAR_3;
qemu_register_reset(pl181_reset, s);
pl181_reset(s);
}
| [
"void FUNC_0(uint32_t VAR_0, BlockDriverState *VAR_1,\nqemu_irq VAR_2, qemu_irq VAR_3)\n{",
"int VAR_4;",
"pl181_state *s;",
"s = (pl181_state *)qemu_mallocz(sizeof(pl181_state));",
"VAR_4 = cpu_register_io_memory(0, pl181_readfn,\npl181_writefn, s);",
"cpu_register_physical_memory(VAR_0, 0x00000fff, VAR_4);",
"s->VAR_0 = VAR_0;",
"s->card = sd_init(VAR_1);",
"s->irq[0] = VAR_2;",
"s->irq[1] = VAR_3;",
"qemu_register_reset(pl181_reset, s);",
"pl181_reset(s);",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
]
] |
3,212 | static int dxva2_get_decoder_configuration(AVCodecContext *s, const GUID *device_guid,
const DXVA2_VideoDesc *desc,
DXVA2_ConfigPictureDecode *config)
{
InputStream *ist = s->opaque;
int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR;
DXVA2Context *ctx = ist->hwaccel_ctx;
unsigned cfg_count = 0, best_score = 0;
DXVA2_ConfigPictureDecode *cfg_list = NULL;
DXVA2_ConfigPictureDecode best_cfg = {{0}};
HRESULT hr;
int i;
hr = IDirectXVideoDecoderService_GetDecoderConfigurations(ctx->decoder_service, device_guid, desc, NULL, &cfg_count, &cfg_list);
if (FAILED(hr)) {
av_log(NULL, loglevel, "Unable to retrieve decoder configurations\n");
return AVERROR(EINVAL);
}
for (i = 0; i < cfg_count; i++) {
DXVA2_ConfigPictureDecode *cfg = &cfg_list[i];
unsigned score;
if (cfg->ConfigBitstreamRaw == 1)
score = 1;
else if (s->codec_id == AV_CODEC_ID_H264 && cfg->ConfigBitstreamRaw == 2)
score = 2;
else
continue;
if (IsEqualGUID(&cfg->guidConfigBitstreamEncryption, &DXVA2_NoEncrypt))
score += 16;
if (score > best_score) {
best_score = score;
best_cfg = *cfg;
}
}
CoTaskMemFree(cfg_list);
if (!best_score) {
av_log(NULL, loglevel, "No valid decoder configuration available\n");
return AVERROR(EINVAL);
}
*config = best_cfg;
return 0;
}
| false | FFmpeg | 70143a3954e1c4412efb2bf1a3a818adea2d3abf | static int dxva2_get_decoder_configuration(AVCodecContext *s, const GUID *device_guid,
const DXVA2_VideoDesc *desc,
DXVA2_ConfigPictureDecode *config)
{
InputStream *ist = s->opaque;
int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR;
DXVA2Context *ctx = ist->hwaccel_ctx;
unsigned cfg_count = 0, best_score = 0;
DXVA2_ConfigPictureDecode *cfg_list = NULL;
DXVA2_ConfigPictureDecode best_cfg = {{0}};
HRESULT hr;
int i;
hr = IDirectXVideoDecoderService_GetDecoderConfigurations(ctx->decoder_service, device_guid, desc, NULL, &cfg_count, &cfg_list);
if (FAILED(hr)) {
av_log(NULL, loglevel, "Unable to retrieve decoder configurations\n");
return AVERROR(EINVAL);
}
for (i = 0; i < cfg_count; i++) {
DXVA2_ConfigPictureDecode *cfg = &cfg_list[i];
unsigned score;
if (cfg->ConfigBitstreamRaw == 1)
score = 1;
else if (s->codec_id == AV_CODEC_ID_H264 && cfg->ConfigBitstreamRaw == 2)
score = 2;
else
continue;
if (IsEqualGUID(&cfg->guidConfigBitstreamEncryption, &DXVA2_NoEncrypt))
score += 16;
if (score > best_score) {
best_score = score;
best_cfg = *cfg;
}
}
CoTaskMemFree(cfg_list);
if (!best_score) {
av_log(NULL, loglevel, "No valid decoder configuration available\n");
return AVERROR(EINVAL);
}
*config = best_cfg;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, const GUID *VAR_1,
const DXVA2_VideoDesc *VAR_2,
DXVA2_ConfigPictureDecode *VAR_3)
{
InputStream *ist = VAR_0->opaque;
int VAR_4 = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR;
DXVA2Context *ctx = ist->hwaccel_ctx;
unsigned VAR_5 = 0, VAR_6 = 0;
DXVA2_ConfigPictureDecode *cfg_list = NULL;
DXVA2_ConfigPictureDecode best_cfg = {{0}};
HRESULT hr;
int VAR_7;
hr = IDirectXVideoDecoderService_GetDecoderConfigurations(ctx->decoder_service, VAR_1, VAR_2, NULL, &VAR_5, &cfg_list);
if (FAILED(hr)) {
av_log(NULL, VAR_4, "Unable to retrieve decoder configurations\n");
return AVERROR(EINVAL);
}
for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++) {
DXVA2_ConfigPictureDecode *cfg = &cfg_list[VAR_7];
unsigned VAR_8;
if (cfg->ConfigBitstreamRaw == 1)
VAR_8 = 1;
else if (VAR_0->codec_id == AV_CODEC_ID_H264 && cfg->ConfigBitstreamRaw == 2)
VAR_8 = 2;
else
continue;
if (IsEqualGUID(&cfg->guidConfigBitstreamEncryption, &DXVA2_NoEncrypt))
VAR_8 += 16;
if (VAR_8 > VAR_6) {
VAR_6 = VAR_8;
best_cfg = *cfg;
}
}
CoTaskMemFree(cfg_list);
if (!VAR_6) {
av_log(NULL, VAR_4, "No valid decoder configuration available\n");
return AVERROR(EINVAL);
}
*VAR_3 = best_cfg;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, const GUID *VAR_1,\nconst DXVA2_VideoDesc *VAR_2,\nDXVA2_ConfigPictureDecode *VAR_3)\n{",
"InputStream *ist = VAR_0->opaque;",
"int VAR_4 = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR;",
"DXVA2Context *ctx = ist->hwaccel_ctx;",
"unsigned VAR_5 = 0, VAR_6 = 0;",
"DXVA2_ConfigPictureDecode *cfg_list = NULL;",
"DXVA2_ConfigPictureDecode best_cfg = {{0}};",
"HRESULT hr;",
"int VAR_7;",
"hr = IDirectXVideoDecoderService_GetDecoderConfigurations(ctx->decoder_service, VAR_1, VAR_2, NULL, &VAR_5, &cfg_list);",
"if (FAILED(hr)) {",
"av_log(NULL, VAR_4, \"Unable to retrieve decoder configurations\\n\");",
"return AVERROR(EINVAL);",
"}",
"for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++) {",
"DXVA2_ConfigPictureDecode *cfg = &cfg_list[VAR_7];",
"unsigned VAR_8;",
"if (cfg->ConfigBitstreamRaw == 1)\nVAR_8 = 1;",
"else if (VAR_0->codec_id == AV_CODEC_ID_H264 && cfg->ConfigBitstreamRaw == 2)\nVAR_8 = 2;",
"else\ncontinue;",
"if (IsEqualGUID(&cfg->guidConfigBitstreamEncryption, &DXVA2_NoEncrypt))\nVAR_8 += 16;",
"if (VAR_8 > VAR_6) {",
"VAR_6 = VAR_8;",
"best_cfg = *cfg;",
"}",
"}",
"CoTaskMemFree(cfg_list);",
"if (!VAR_6) {",
"av_log(NULL, VAR_4, \"No valid decoder configuration available\\n\");",
"return AVERROR(EINVAL);",
"}",
"*VAR_3 = best_cfg;",
"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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
45
],
[
47,
49
],
[
51,
53
],
[
55,
57
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
]
] |
3,213 | static inline int RENAME(yuv420_rgb15)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]){
int y, h_size;
if(c->srcFormat == PIX_FMT_YUV422P){
srcStride[1] *= 2;
srcStride[2] *= 2;
}
h_size= (c->dstW+7)&~7;
if(h_size*2 > dstStride[0]) h_size-=8;
__asm__ __volatile__ ("pxor %mm4, %mm4;" /* zero mm4 */ );
//printf("%X %X %X %X %X %X %X %X %X %X\n", (int)&c->redDither, (int)&b5Dither, (int)src[0], (int)src[1], (int)src[2], (int)dst[0],
//srcStride[0],srcStride[1],srcStride[2],dstStride[0]);
for (y= 0; y<srcSliceH; y++ ) {
uint8_t *_image = dst[0] + (y+srcSliceY)*dstStride[0];
uint8_t *_py = src[0] + y*srcStride[0];
uint8_t *_pu = src[1] + (y>>1)*srcStride[1];
uint8_t *_pv = src[2] + (y>>1)*srcStride[2];
long index= -h_size/2;
b5Dither= dither8[y&1];
g6Dither= dither4[y&1];
g5Dither= dither8[y&1];
r5Dither= dither8[(y+1)&1];
/* this mmx assembly code deals with SINGLE scan line at a time, it convert 8
pixels in each iteration */
__asm__ __volatile__ (
/* load data for start of next scan line */
"movd (%2, %0), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */
"movd (%3, %0), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */
"movq (%5, %0, 2), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */
// ".balign 16 \n\t"
"1: \n\t"
YUV2RGB
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm0 \n\t"
"paddusb "MANGLE(g5Dither)", %%mm2 \n\t"
"paddusb "MANGLE(r5Dither)", %%mm1 \n\t"
#endif
/* mask unneeded bits off */
"pand "MANGLE(mmx_redmask)", %%mm0;" /* b7b6b5b4 b3_0_0_0 b7b6b5b4 b3_0_0_0 */
"pand "MANGLE(mmx_redmask)", %%mm2;" /* g7g6g5g4 g3_0_0_0 g7g6g5g4 g3_0_0_0 */
"pand "MANGLE(mmx_redmask)", %%mm1;" /* r7r6r5r4 r3_0_0_0 r7r6r5r4 r3_0_0_0 */
"psrlw $3,%%mm0;" /* 0_0_0_b7 b6b5b4b3 0_0_0_b7 b6b5b4b3 */
"psrlw $1,%%mm1;" /* 0_r7r6r5 r4r3_0_0 0_r7r6r5 r4r3_0_0 */
"pxor %%mm4, %%mm4;" /* zero mm4 */
"movq %%mm0, %%mm5;" /* Copy B7-B0 */
"movq %%mm2, %%mm7;" /* Copy G7-G0 */
/* convert rgb24 plane to rgb16 pack for pixel 0-3 */
"punpcklbw %%mm4, %%mm2;" /* 0_0_0_0 0_0_0_0 g7g6g5g4 g3_0_0_0 */
"punpcklbw %%mm1, %%mm0;" /* r7r6r5r4 r3_0_0_0 0_0_0_b7 b6b5b4b3 */
"psllw $2, %%mm2;" /* 0_0_0_0 0_0_g7g6 g5g4g3_0 0_0_0_0 */
"por %%mm2, %%mm0;" /* 0_r7r6r5 r4r3g7g6 g5g4g3b7 b6b5b4b3 */
"movq 8 (%5, %0, 2), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */
MOVNTQ " %%mm0, (%1);" /* store pixel 0-3 */
/* convert rgb24 plane to rgb16 pack for pixel 0-3 */
"punpckhbw %%mm4, %%mm7;" /* 0_0_0_0 0_0_0_0 0_g7g6g5 g4g3_0_0 */
"punpckhbw %%mm1, %%mm5;" /* r7r6r5r4 r3_0_0_0 0_0_0_b7 b6b5b4b3 */
"psllw $2, %%mm7;" /* 0_0_0_0 0_0_g7g6 g5g4g3_0 0_0_0_0 */
"movd 4 (%2, %0), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */
"por %%mm7, %%mm5;" /* 0_r7r6r5 r4r3g7g6 g5g4g3b7 b6b5b4b3 */
"movd 4 (%3, %0), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */
MOVNTQ " %%mm5, 8 (%1);" /* store pixel 4-7 */
"add $16, %1 \n\t"
"add $4, %0 \n\t"
" js 1b \n\t"
: "+r" (index), "+r" (_image)
: "r" (_pu - index), "r" (_pv - index), "r"(&c->redDither), "r" (_py - 2*index)
);
}
__asm__ __volatile__ (EMMS);
return srcSliceH;
}
| false | FFmpeg | 20da77449d4427a7152b80e4f9acce6a8c93ee7d | static inline int RENAME(yuv420_rgb15)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]){
int y, h_size;
if(c->srcFormat == PIX_FMT_YUV422P){
srcStride[1] *= 2;
srcStride[2] *= 2;
}
h_size= (c->dstW+7)&~7;
if(h_size*2 > dstStride[0]) h_size-=8;
__asm__ __volatile__ ("pxor %mm4, %mm4;" );
for (y= 0; y<srcSliceH; y++ ) {
uint8_t *_image = dst[0] + (y+srcSliceY)*dstStride[0];
uint8_t *_py = src[0] + y*srcStride[0];
uint8_t *_pu = src[1] + (y>>1)*srcStride[1];
uint8_t *_pv = src[2] + (y>>1)*srcStride[2];
long index= -h_size/2;
b5Dither= dither8[y&1];
g6Dither= dither4[y&1];
g5Dither= dither8[y&1];
r5Dither= dither8[(y+1)&1];
__asm__ __volatile__ (
"movd (%2, %0), %%mm0;"
"movd (%3, %0), %%mm1;"
"movq (%5, %0, 2), %%mm6;"
"1: \n\t"
YUV2RGB
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm0 \n\t"
"paddusb "MANGLE(g5Dither)", %%mm2 \n\t"
"paddusb "MANGLE(r5Dither)", %%mm1 \n\t"
#endif
"pand "MANGLE(mmx_redmask)", %%mm0;"
"pand "MANGLE(mmx_redmask)", %%mm2;"
"pand "MANGLE(mmx_redmask)", %%mm1;"
"psrlw $3,%%mm0;"
"psrlw $1,%%mm1;"
"pxor %%mm4, %%mm4;"
"movq %%mm0, %%mm5;"
"movq %%mm2, %%mm7;"
"punpcklbw %%mm4, %%mm2;"
"punpcklbw %%mm1, %%mm0;"
"psllw $2, %%mm2;"
"por %%mm2, %%mm0;"
"movq 8 (%5, %0, 2), %%mm6;"
MOVNTQ " %%mm0, (%1);"
"punpckhbw %%mm4, %%mm7;"
"punpckhbw %%mm1, %%mm5;"
"psllw $2, %%mm7;"
"movd 4 (%2, %0), %%mm0;"
"por %%mm7, %%mm5;"
"movd 4 (%3, %0), %%mm1;"
MOVNTQ " %%mm5, 8 (%1);"
"add $16, %1 \n\t"
"add $4, %0 \n\t"
" js 1b \n\t"
: "+r" (index), "+r" (_image)
: "r" (_pu - index), "r" (_pv - index), "r"(&c->redDither), "r" (_py - 2*index)
);
}
__asm__ __volatile__ (EMMS);
return srcSliceH;
}
| {
"code": [],
"line_no": []
} | static inline int FUNC_0(yuv420_rgb15)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]){
int VAR_0, VAR_1;
if(c->srcFormat == PIX_FMT_YUV422P){
srcStride[1] *= 2;
srcStride[2] *= 2;
}
VAR_1= (c->dstW+7)&~7;
if(VAR_1*2 > dstStride[0]) VAR_1-=8;
__asm__ __volatile__ ("pxor %mm4, %mm4;" );
for (VAR_0= 0; VAR_0<srcSliceH; VAR_0++ ) {
uint8_t *_image = dst[0] + (VAR_0+srcSliceY)*dstStride[0];
uint8_t *_py = src[0] + VAR_0*srcStride[0];
uint8_t *_pu = src[1] + (VAR_0>>1)*srcStride[1];
uint8_t *_pv = src[2] + (VAR_0>>1)*srcStride[2];
long index= -VAR_1/2;
b5Dither= dither8[VAR_0&1];
g6Dither= dither4[VAR_0&1];
g5Dither= dither8[VAR_0&1];
r5Dither= dither8[(VAR_0+1)&1];
__asm__ __volatile__ (
"movd (%2, %0), %%mm0;"
"movd (%3, %0), %%mm1;"
"movq (%5, %0, 2), %%mm6;"
"1: \n\t"
YUV2RGB
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm0 \n\t"
"paddusb "MANGLE(g5Dither)", %%mm2 \n\t"
"paddusb "MANGLE(r5Dither)", %%mm1 \n\t"
#endif
"pand "MANGLE(mmx_redmask)", %%mm0;"
"pand "MANGLE(mmx_redmask)", %%mm2;"
"pand "MANGLE(mmx_redmask)", %%mm1;"
"psrlw $3,%%mm0;"
"psrlw $1,%%mm1;"
"pxor %%mm4, %%mm4;"
"movq %%mm0, %%mm5;"
"movq %%mm2, %%mm7;"
"punpcklbw %%mm4, %%mm2;"
"punpcklbw %%mm1, %%mm0;"
"psllw $2, %%mm2;"
"por %%mm2, %%mm0;"
"movq 8 (%5, %0, 2), %%mm6;"
MOVNTQ " %%mm0, (%1);"
"punpckhbw %%mm4, %%mm7;"
"punpckhbw %%mm1, %%mm5;"
"psllw $2, %%mm7;"
"movd 4 (%2, %0), %%mm0;"
"por %%mm7, %%mm5;"
"movd 4 (%3, %0), %%mm1;"
MOVNTQ " %%mm5, 8 (%1);"
"add $16, %1 \n\t"
"add $4, %0 \n\t"
" js 1b \n\t"
: "+r" (index), "+r" (_image)
: "r" (_pu - index), "r" (_pv - index), "r"(&c->redDither), "r" (_py - 2*index)
);
}
__asm__ __volatile__ (EMMS);
return srcSliceH;
}
| [
"static inline int FUNC_0(yuv420_rgb15)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,\nint srcSliceH, uint8_t* dst[], int dstStride[]){",
"int VAR_0, VAR_1;",
"if(c->srcFormat == PIX_FMT_YUV422P){",
"srcStride[1] *= 2;",
"srcStride[2] *= 2;",
"}",
"VAR_1= (c->dstW+7)&~7;",
"if(VAR_1*2 > dstStride[0]) VAR_1-=8;",
"__asm__ __volatile__ (\"pxor %mm4, %mm4;\" );",
"for (VAR_0= 0; VAR_0<srcSliceH; VAR_0++ ) {",
"uint8_t *_image = dst[0] + (VAR_0+srcSliceY)*dstStride[0];",
"uint8_t *_py = src[0] + VAR_0*srcStride[0];",
"uint8_t *_pu = src[1] + (VAR_0>>1)*srcStride[1];",
"uint8_t *_pv = src[2] + (VAR_0>>1)*srcStride[2];",
"long index= -VAR_1/2;",
"b5Dither= dither8[VAR_0&1];",
"g6Dither= dither4[VAR_0&1];",
"g5Dither= dither8[VAR_0&1];",
"r5Dither= dither8[(VAR_0+1)&1];",
"__asm__ __volatile__ (\n\"movd (%2, %0), %%mm0;\"",
"\"movd (%3, %0), %%mm1;\"",
"\"movq (%5, %0, 2), %%mm6;\"",
"\"1:\t\t\t\t\\n\\t\"\nYUV2RGB\n#ifdef DITHER1XBPP\n\"paddusb \"MANGLE(b5Dither)\", %%mm0\t\\n\\t\"\n\"paddusb \"MANGLE(g5Dither)\", %%mm2\t\\n\\t\"\n\"paddusb \"MANGLE(r5Dither)\", %%mm1\t\\n\\t\"\n#endif\n\"pand \"MANGLE(mmx_redmask)\", %%mm0;\"",
"\"pand \"MANGLE(mmx_redmask)\", %%mm2;\"",
"\"pand \"MANGLE(mmx_redmask)\", %%mm1;\"",
"\"psrlw $3,%%mm0;\"",
"\"psrlw $1,%%mm1;\"",
"\"pxor %%mm4, %%mm4;\"",
"\"movq %%mm0, %%mm5;\"",
"\"movq %%mm2, %%mm7;\"",
"\"punpcklbw %%mm4, %%mm2;\"",
"\"punpcklbw %%mm1, %%mm0;\"",
"\"psllw $2, %%mm2;\"",
"\"por %%mm2, %%mm0;\"",
"\"movq 8 (%5, %0, 2), %%mm6;\"",
"MOVNTQ \" %%mm0, (%1);\"",
"\"punpckhbw %%mm4, %%mm7;\"",
"\"punpckhbw %%mm1, %%mm5;\"",
"\"psllw $2, %%mm7;\"",
"\"movd 4 (%2, %0), %%mm0;\"",
"\"por %%mm7, %%mm5;\"",
"\"movd 4 (%3, %0), %%mm1;\"",
"MOVNTQ \" %%mm5, 8 (%1);\"",
"\"add $16, %1\t\t\t\\n\\t\"\n\"add $4, %0\t\t\t\\n\\t\"\n\" js 1b\t\t\t\t\\n\\t\"\n: \"+r\" (index), \"+r\" (_image)\n: \"r\" (_pu - index), \"r\" (_pv - index), \"r\"(&c->redDither), \"r\" (_py - 2*index)\n);",
"}",
"__asm__ __volatile__ (EMMS);",
"return srcSliceH;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
19
],
[
21
],
[
25
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
57,
61
],
[
63
],
[
65
],
[
69,
71,
75,
77,
79,
81,
83,
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
113
],
[
115
],
[
119
],
[
121
],
[
125
],
[
127
],
[
133
],
[
135
],
[
139
],
[
141
],
[
145
],
[
147
],
[
151
],
[
155,
157,
159,
161,
163,
165
],
[
167
],
[
171
],
[
173
],
[
175
]
] |
3,214 | static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
int letter, const char *buf)
{
RTSPState *rt = s->priv_data;
char buf1[64], st_type[64];
const char *p;
int codec_type, payload_type, i;
AVStream *st;
RTSPStream *rtsp_st;
struct in_addr sdp_ip;
int ttl;
#ifdef DEBUG
printf("sdp: %c='%s'\n", letter, buf);
#endif
p = buf;
switch(letter) {
case 'c':
get_word(buf1, sizeof(buf1), &p);
if (strcmp(buf1, "IN") != 0)
return;
get_word(buf1, sizeof(buf1), &p);
if (strcmp(buf1, "IP4") != 0)
return;
get_word_sep(buf1, sizeof(buf1), "/", &p);
if (inet_aton(buf1, &sdp_ip) == 0)
return;
ttl = 16;
if (*p == '/') {
p++;
get_word_sep(buf1, sizeof(buf1), "/", &p);
ttl = atoi(buf1);
}
if (s->nb_streams == 0) {
s1->default_ip = sdp_ip;
s1->default_ttl = ttl;
} else {
st = s->streams[s->nb_streams - 1];
rtsp_st = st->priv_data;
rtsp_st->sdp_ip = sdp_ip;
rtsp_st->sdp_ttl = ttl;
}
break;
case 's':
pstrcpy(s->title, sizeof(s->title), p);
break;
case 'i':
if (s->nb_streams == 0) {
pstrcpy(s->comment, sizeof(s->comment), p);
break;
}
break;
case 'm':
/* new stream */
get_word(st_type, sizeof(st_type), &p);
if (!strcmp(st_type, "audio")) {
codec_type = CODEC_TYPE_AUDIO;
} else if (!strcmp(st_type, "video")) {
codec_type = CODEC_TYPE_VIDEO;
} else {
return;
}
rtsp_st = av_mallocz(sizeof(RTSPStream));
if (!rtsp_st)
return;
rtsp_st->stream_index = -1;
dynarray_add(&rt->rtsp_streams, &rt->nb_rtsp_streams, rtsp_st);
rtsp_st->sdp_ip = s1->default_ip;
rtsp_st->sdp_ttl = s1->default_ttl;
get_word(buf1, sizeof(buf1), &p); /* port */
rtsp_st->sdp_port = atoi(buf1);
get_word(buf1, sizeof(buf1), &p); /* protocol (ignored) */
/* XXX: handle list of formats */
get_word(buf1, sizeof(buf1), &p); /* format list */
rtsp_st->sdp_payload_type = atoi(buf1);
if (rtsp_st->sdp_payload_type == RTP_PT_MPEG2TS) {
/* no corresponding stream */
} else {
st = av_new_stream(s, 0);
if (!st)
return;
st->priv_data = rtsp_st;
rtsp_st->stream_index = st->index;
st->codec.codec_type = codec_type;
if (rtsp_st->sdp_payload_type < 96) {
/* if standard payload type, we can find the codec right now */
rtp_get_codec_info(&st->codec, rtsp_st->sdp_payload_type);
}
}
/* put a default control url */
pstrcpy(rtsp_st->control_url, sizeof(rtsp_st->control_url), s->filename);
break;
case 'a':
if (strstart(p, "control:", &p) && s->nb_streams > 0) {
char proto[32];
/* get the control url */
st = s->streams[s->nb_streams - 1];
rtsp_st = st->priv_data;
/* XXX: may need to add full url resolution */
url_split(proto, sizeof(proto), NULL, 0, NULL, NULL, 0, p);
if (proto[0] == '\0') {
/* relative control URL */
pstrcat(rtsp_st->control_url, sizeof(rtsp_st->control_url), "/");
pstrcat(rtsp_st->control_url, sizeof(rtsp_st->control_url), p);
} else {
pstrcpy(rtsp_st->control_url, sizeof(rtsp_st->control_url), p);
}
} else if (strstart(p, "rtpmap:", &p)) {
/* NOTE: rtpmap is only supported AFTER the 'm=' tag */
get_word(buf1, sizeof(buf1), &p);
payload_type = atoi(buf1);
for(i = 0; i < s->nb_streams;i++) {
st = s->streams[i];
rtsp_st = st->priv_data;
if (rtsp_st->sdp_payload_type == payload_type) {
sdp_parse_rtpmap(&st->codec, p);
}
}
} else if (strstart(p, "fmtp:", &p)) {
/* NOTE: fmtp is only supported AFTER the 'a=rtpmap:xxx' tag */
get_word(buf1, sizeof(buf1), &p);
payload_type = atoi(buf1);
for(i = 0; i < s->nb_streams;i++) {
st = s->streams[i];
rtsp_st = st->priv_data;
if (rtsp_st->sdp_payload_type == payload_type) {
sdp_parse_fmtp(&st->codec, p);
}
}
}
break;
}
}
| false | FFmpeg | 6ba5cbc699e77cae66bb719354fa142114b64eab | static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
int letter, const char *buf)
{
RTSPState *rt = s->priv_data;
char buf1[64], st_type[64];
const char *p;
int codec_type, payload_type, i;
AVStream *st;
RTSPStream *rtsp_st;
struct in_addr sdp_ip;
int ttl;
#ifdef DEBUG
printf("sdp: %c='%s'\n", letter, buf);
#endif
p = buf;
switch(letter) {
case 'c':
get_word(buf1, sizeof(buf1), &p);
if (strcmp(buf1, "IN") != 0)
return;
get_word(buf1, sizeof(buf1), &p);
if (strcmp(buf1, "IP4") != 0)
return;
get_word_sep(buf1, sizeof(buf1), "/", &p);
if (inet_aton(buf1, &sdp_ip) == 0)
return;
ttl = 16;
if (*p == '/') {
p++;
get_word_sep(buf1, sizeof(buf1), "/", &p);
ttl = atoi(buf1);
}
if (s->nb_streams == 0) {
s1->default_ip = sdp_ip;
s1->default_ttl = ttl;
} else {
st = s->streams[s->nb_streams - 1];
rtsp_st = st->priv_data;
rtsp_st->sdp_ip = sdp_ip;
rtsp_st->sdp_ttl = ttl;
}
break;
case 's':
pstrcpy(s->title, sizeof(s->title), p);
break;
case 'i':
if (s->nb_streams == 0) {
pstrcpy(s->comment, sizeof(s->comment), p);
break;
}
break;
case 'm':
get_word(st_type, sizeof(st_type), &p);
if (!strcmp(st_type, "audio")) {
codec_type = CODEC_TYPE_AUDIO;
} else if (!strcmp(st_type, "video")) {
codec_type = CODEC_TYPE_VIDEO;
} else {
return;
}
rtsp_st = av_mallocz(sizeof(RTSPStream));
if (!rtsp_st)
return;
rtsp_st->stream_index = -1;
dynarray_add(&rt->rtsp_streams, &rt->nb_rtsp_streams, rtsp_st);
rtsp_st->sdp_ip = s1->default_ip;
rtsp_st->sdp_ttl = s1->default_ttl;
get_word(buf1, sizeof(buf1), &p);
rtsp_st->sdp_port = atoi(buf1);
get_word(buf1, sizeof(buf1), &p);
get_word(buf1, sizeof(buf1), &p);
rtsp_st->sdp_payload_type = atoi(buf1);
if (rtsp_st->sdp_payload_type == RTP_PT_MPEG2TS) {
} else {
st = av_new_stream(s, 0);
if (!st)
return;
st->priv_data = rtsp_st;
rtsp_st->stream_index = st->index;
st->codec.codec_type = codec_type;
if (rtsp_st->sdp_payload_type < 96) {
rtp_get_codec_info(&st->codec, rtsp_st->sdp_payload_type);
}
}
pstrcpy(rtsp_st->control_url, sizeof(rtsp_st->control_url), s->filename);
break;
case 'a':
if (strstart(p, "control:", &p) && s->nb_streams > 0) {
char proto[32];
st = s->streams[s->nb_streams - 1];
rtsp_st = st->priv_data;
url_split(proto, sizeof(proto), NULL, 0, NULL, NULL, 0, p);
if (proto[0] == '\0') {
pstrcat(rtsp_st->control_url, sizeof(rtsp_st->control_url), "/");
pstrcat(rtsp_st->control_url, sizeof(rtsp_st->control_url), p);
} else {
pstrcpy(rtsp_st->control_url, sizeof(rtsp_st->control_url), p);
}
} else if (strstart(p, "rtpmap:", &p)) {
get_word(buf1, sizeof(buf1), &p);
payload_type = atoi(buf1);
for(i = 0; i < s->nb_streams;i++) {
st = s->streams[i];
rtsp_st = st->priv_data;
if (rtsp_st->sdp_payload_type == payload_type) {
sdp_parse_rtpmap(&st->codec, p);
}
}
} else if (strstart(p, "fmtp:", &p)) {
get_word(buf1, sizeof(buf1), &p);
payload_type = atoi(buf1);
for(i = 0; i < s->nb_streams;i++) {
st = s->streams[i];
rtsp_st = st->priv_data;
if (rtsp_st->sdp_payload_type == payload_type) {
sdp_parse_fmtp(&st->codec, p);
}
}
}
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVFormatContext *VAR_0, SDPParseState *VAR_1,
int VAR_2, const char *VAR_3)
{
RTSPState *rt = VAR_0->priv_data;
char VAR_4[64], VAR_5[64];
const char *VAR_6;
int VAR_7, VAR_8, VAR_9;
AVStream *st;
RTSPStream *rtsp_st;
struct in_addr VAR_10;
int VAR_11;
#ifdef DEBUG
printf("sdp: %c='%VAR_0'\n", VAR_2, VAR_3);
#endif
VAR_6 = VAR_3;
switch(VAR_2) {
case 'c':
get_word(VAR_4, sizeof(VAR_4), &VAR_6);
if (strcmp(VAR_4, "IN") != 0)
return;
get_word(VAR_4, sizeof(VAR_4), &VAR_6);
if (strcmp(VAR_4, "IP4") != 0)
return;
get_word_sep(VAR_4, sizeof(VAR_4), "/", &VAR_6);
if (inet_aton(VAR_4, &VAR_10) == 0)
return;
VAR_11 = 16;
if (*VAR_6 == '/') {
VAR_6++;
get_word_sep(VAR_4, sizeof(VAR_4), "/", &VAR_6);
VAR_11 = atoi(VAR_4);
}
if (VAR_0->nb_streams == 0) {
VAR_1->default_ip = VAR_10;
VAR_1->default_ttl = VAR_11;
} else {
st = VAR_0->streams[VAR_0->nb_streams - 1];
rtsp_st = st->priv_data;
rtsp_st->VAR_10 = VAR_10;
rtsp_st->sdp_ttl = VAR_11;
}
break;
case 'VAR_0':
pstrcpy(VAR_0->title, sizeof(VAR_0->title), VAR_6);
break;
case 'VAR_9':
if (VAR_0->nb_streams == 0) {
pstrcpy(VAR_0->comment, sizeof(VAR_0->comment), VAR_6);
break;
}
break;
case 'm':
get_word(VAR_5, sizeof(VAR_5), &VAR_6);
if (!strcmp(VAR_5, "audio")) {
VAR_7 = CODEC_TYPE_AUDIO;
} else if (!strcmp(VAR_5, "video")) {
VAR_7 = CODEC_TYPE_VIDEO;
} else {
return;
}
rtsp_st = av_mallocz(sizeof(RTSPStream));
if (!rtsp_st)
return;
rtsp_st->stream_index = -1;
dynarray_add(&rt->rtsp_streams, &rt->nb_rtsp_streams, rtsp_st);
rtsp_st->VAR_10 = VAR_1->default_ip;
rtsp_st->sdp_ttl = VAR_1->default_ttl;
get_word(VAR_4, sizeof(VAR_4), &VAR_6);
rtsp_st->sdp_port = atoi(VAR_4);
get_word(VAR_4, sizeof(VAR_4), &VAR_6);
get_word(VAR_4, sizeof(VAR_4), &VAR_6);
rtsp_st->sdp_payload_type = atoi(VAR_4);
if (rtsp_st->sdp_payload_type == RTP_PT_MPEG2TS) {
} else {
st = av_new_stream(VAR_0, 0);
if (!st)
return;
st->priv_data = rtsp_st;
rtsp_st->stream_index = st->index;
st->codec.VAR_7 = VAR_7;
if (rtsp_st->sdp_payload_type < 96) {
rtp_get_codec_info(&st->codec, rtsp_st->sdp_payload_type);
}
}
pstrcpy(rtsp_st->control_url, sizeof(rtsp_st->control_url), VAR_0->filename);
break;
case 'a':
if (strstart(VAR_6, "control:", &VAR_6) && VAR_0->nb_streams > 0) {
char VAR_12[32];
st = VAR_0->streams[VAR_0->nb_streams - 1];
rtsp_st = st->priv_data;
url_split(VAR_12, sizeof(VAR_12), NULL, 0, NULL, NULL, 0, VAR_6);
if (VAR_12[0] == '\0') {
pstrcat(rtsp_st->control_url, sizeof(rtsp_st->control_url), "/");
pstrcat(rtsp_st->control_url, sizeof(rtsp_st->control_url), VAR_6);
} else {
pstrcpy(rtsp_st->control_url, sizeof(rtsp_st->control_url), VAR_6);
}
} else if (strstart(VAR_6, "rtpmap:", &VAR_6)) {
get_word(VAR_4, sizeof(VAR_4), &VAR_6);
VAR_8 = atoi(VAR_4);
for(VAR_9 = 0; VAR_9 < VAR_0->nb_streams;VAR_9++) {
st = VAR_0->streams[VAR_9];
rtsp_st = st->priv_data;
if (rtsp_st->sdp_payload_type == VAR_8) {
sdp_parse_rtpmap(&st->codec, VAR_6);
}
}
} else if (strstart(VAR_6, "fmtp:", &VAR_6)) {
get_word(VAR_4, sizeof(VAR_4), &VAR_6);
VAR_8 = atoi(VAR_4);
for(VAR_9 = 0; VAR_9 < VAR_0->nb_streams;VAR_9++) {
st = VAR_0->streams[VAR_9];
rtsp_st = st->priv_data;
if (rtsp_st->sdp_payload_type == VAR_8) {
sdp_parse_fmtp(&st->codec, VAR_6);
}
}
}
break;
}
}
| [
"static void FUNC_0(AVFormatContext *VAR_0, SDPParseState *VAR_1,\nint VAR_2, const char *VAR_3)\n{",
"RTSPState *rt = VAR_0->priv_data;",
"char VAR_4[64], VAR_5[64];",
"const char *VAR_6;",
"int VAR_7, VAR_8, VAR_9;",
"AVStream *st;",
"RTSPStream *rtsp_st;",
"struct in_addr VAR_10;",
"int VAR_11;",
"#ifdef DEBUG\nprintf(\"sdp: %c='%VAR_0'\\n\", VAR_2, VAR_3);",
"#endif\nVAR_6 = VAR_3;",
"switch(VAR_2) {",
"case 'c':\nget_word(VAR_4, sizeof(VAR_4), &VAR_6);",
"if (strcmp(VAR_4, \"IN\") != 0)\nreturn;",
"get_word(VAR_4, sizeof(VAR_4), &VAR_6);",
"if (strcmp(VAR_4, \"IP4\") != 0)\nreturn;",
"get_word_sep(VAR_4, sizeof(VAR_4), \"/\", &VAR_6);",
"if (inet_aton(VAR_4, &VAR_10) == 0)\nreturn;",
"VAR_11 = 16;",
"if (*VAR_6 == '/') {",
"VAR_6++;",
"get_word_sep(VAR_4, sizeof(VAR_4), \"/\", &VAR_6);",
"VAR_11 = atoi(VAR_4);",
"}",
"if (VAR_0->nb_streams == 0) {",
"VAR_1->default_ip = VAR_10;",
"VAR_1->default_ttl = VAR_11;",
"} else {",
"st = VAR_0->streams[VAR_0->nb_streams - 1];",
"rtsp_st = st->priv_data;",
"rtsp_st->VAR_10 = VAR_10;",
"rtsp_st->sdp_ttl = VAR_11;",
"}",
"break;",
"case 'VAR_0':\npstrcpy(VAR_0->title, sizeof(VAR_0->title), VAR_6);",
"break;",
"case 'VAR_9':\nif (VAR_0->nb_streams == 0) {",
"pstrcpy(VAR_0->comment, sizeof(VAR_0->comment), VAR_6);",
"break;",
"}",
"break;",
"case 'm':\nget_word(VAR_5, sizeof(VAR_5), &VAR_6);",
"if (!strcmp(VAR_5, \"audio\")) {",
"VAR_7 = CODEC_TYPE_AUDIO;",
"} else if (!strcmp(VAR_5, \"video\")) {",
"VAR_7 = CODEC_TYPE_VIDEO;",
"} else {",
"return;",
"}",
"rtsp_st = av_mallocz(sizeof(RTSPStream));",
"if (!rtsp_st)\nreturn;",
"rtsp_st->stream_index = -1;",
"dynarray_add(&rt->rtsp_streams, &rt->nb_rtsp_streams, rtsp_st);",
"rtsp_st->VAR_10 = VAR_1->default_ip;",
"rtsp_st->sdp_ttl = VAR_1->default_ttl;",
"get_word(VAR_4, sizeof(VAR_4), &VAR_6);",
"rtsp_st->sdp_port = atoi(VAR_4);",
"get_word(VAR_4, sizeof(VAR_4), &VAR_6);",
"get_word(VAR_4, sizeof(VAR_4), &VAR_6);",
"rtsp_st->sdp_payload_type = atoi(VAR_4);",
"if (rtsp_st->sdp_payload_type == RTP_PT_MPEG2TS) {",
"} else {",
"st = av_new_stream(VAR_0, 0);",
"if (!st)\nreturn;",
"st->priv_data = rtsp_st;",
"rtsp_st->stream_index = st->index;",
"st->codec.VAR_7 = VAR_7;",
"if (rtsp_st->sdp_payload_type < 96) {",
"rtp_get_codec_info(&st->codec, rtsp_st->sdp_payload_type);",
"}",
"}",
"pstrcpy(rtsp_st->control_url, sizeof(rtsp_st->control_url), VAR_0->filename);",
"break;",
"case 'a':\nif (strstart(VAR_6, \"control:\", &VAR_6) && VAR_0->nb_streams > 0) {",
"char VAR_12[32];",
"st = VAR_0->streams[VAR_0->nb_streams - 1];",
"rtsp_st = st->priv_data;",
"url_split(VAR_12, sizeof(VAR_12), NULL, 0, NULL, NULL, 0, VAR_6);",
"if (VAR_12[0] == '\\0') {",
"pstrcat(rtsp_st->control_url, sizeof(rtsp_st->control_url), \"/\");",
"pstrcat(rtsp_st->control_url, sizeof(rtsp_st->control_url), VAR_6);",
"} else {",
"pstrcpy(rtsp_st->control_url, sizeof(rtsp_st->control_url), VAR_6);",
"}",
"} else if (strstart(VAR_6, \"rtpmap:\", &VAR_6)) {",
"get_word(VAR_4, sizeof(VAR_4), &VAR_6);",
"VAR_8 = atoi(VAR_4);",
"for(VAR_9 = 0; VAR_9 < VAR_0->nb_streams;VAR_9++) {",
"st = VAR_0->streams[VAR_9];",
"rtsp_st = st->priv_data;",
"if (rtsp_st->sdp_payload_type == VAR_8) {",
"sdp_parse_rtpmap(&st->codec, VAR_6);",
"}",
"}",
"} else if (strstart(VAR_6, \"fmtp:\", &VAR_6)) {",
"get_word(VAR_4, sizeof(VAR_4), &VAR_6);",
"VAR_8 = atoi(VAR_4);",
"for(VAR_9 = 0; VAR_9 < VAR_0->nb_streams;VAR_9++) {",
"st = VAR_0->streams[VAR_9];",
"rtsp_st = st->priv_data;",
"if (rtsp_st->sdp_payload_type == VAR_8) {",
"sdp_parse_fmtp(&st->codec, VAR_6);",
"}",
"}",
"}",
"break;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
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,
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129,
131
],
[
133
],
[
135
],
[
139
],
[
141
],
[
145
],
[
147
],
[
151
],
[
157
],
[
159
],
[
163
],
[
167
],
[
169
],
[
171,
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
185
],
[
187
],
[
189
],
[
193
],
[
195
],
[
197,
199
],
[
201
],
[
205
],
[
207
],
[
213
],
[
215
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
]
] |
3,216 | static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size)
{
s->scratch_size = SVGA_SCRATCH_SIZE;
s->scratch = qemu_malloc(s->scratch_size * 4);
vmsvga_reset(s);
s->fifo_size = SVGA_FIFO_SIZE;
s->fifo_offset = qemu_ram_alloc(s->fifo_size);
s->fifo_ptr = qemu_get_ram_ptr(s->fifo_offset);
vga_common_init(&s->vga, vga_ram_size);
vga_init(&s->vga);
vmstate_register(0, &vmstate_vga_common, &s->vga);
s->vga.ds = graphic_console_init(vmsvga_update_display,
vmsvga_invalidate_display,
vmsvga_screen_dump,
vmsvga_text_update, s);
vga_init_vbe(&s->vga);
rom_add_vga(VGABIOS_FILENAME);
}
| true | qemu | a6109ff1b5d7184a9d490c4ff94f175940232ebd | static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size)
{
s->scratch_size = SVGA_SCRATCH_SIZE;
s->scratch = qemu_malloc(s->scratch_size * 4);
vmsvga_reset(s);
s->fifo_size = SVGA_FIFO_SIZE;
s->fifo_offset = qemu_ram_alloc(s->fifo_size);
s->fifo_ptr = qemu_get_ram_ptr(s->fifo_offset);
vga_common_init(&s->vga, vga_ram_size);
vga_init(&s->vga);
vmstate_register(0, &vmstate_vga_common, &s->vga);
s->vga.ds = graphic_console_init(vmsvga_update_display,
vmsvga_invalidate_display,
vmsvga_screen_dump,
vmsvga_text_update, s);
vga_init_vbe(&s->vga);
rom_add_vga(VGABIOS_FILENAME);
}
| {
"code": [
" s->vga.ds = graphic_console_init(vmsvga_update_display,",
" vmsvga_invalidate_display,",
" vmsvga_screen_dump,",
" vmsvga_text_update, s);"
],
"line_no": [
31,
33,
35,
37
]
} | static void FUNC_0(struct vmsvga_state_s *VAR_0, int VAR_1)
{
VAR_0->scratch_size = SVGA_SCRATCH_SIZE;
VAR_0->scratch = qemu_malloc(VAR_0->scratch_size * 4);
vmsvga_reset(VAR_0);
VAR_0->fifo_size = SVGA_FIFO_SIZE;
VAR_0->fifo_offset = qemu_ram_alloc(VAR_0->fifo_size);
VAR_0->fifo_ptr = qemu_get_ram_ptr(VAR_0->fifo_offset);
vga_common_init(&VAR_0->vga, VAR_1);
vga_init(&VAR_0->vga);
vmstate_register(0, &vmstate_vga_common, &VAR_0->vga);
VAR_0->vga.ds = graphic_console_init(vmsvga_update_display,
vmsvga_invalidate_display,
vmsvga_screen_dump,
vmsvga_text_update, VAR_0);
vga_init_vbe(&VAR_0->vga);
rom_add_vga(VGABIOS_FILENAME);
}
| [
"static void FUNC_0(struct vmsvga_state_s *VAR_0, int VAR_1)\n{",
"VAR_0->scratch_size = SVGA_SCRATCH_SIZE;",
"VAR_0->scratch = qemu_malloc(VAR_0->scratch_size * 4);",
"vmsvga_reset(VAR_0);",
"VAR_0->fifo_size = SVGA_FIFO_SIZE;",
"VAR_0->fifo_offset = qemu_ram_alloc(VAR_0->fifo_size);",
"VAR_0->fifo_ptr = qemu_get_ram_ptr(VAR_0->fifo_offset);",
"vga_common_init(&VAR_0->vga, VAR_1);",
"vga_init(&VAR_0->vga);",
"vmstate_register(0, &vmstate_vga_common, &VAR_0->vga);",
"VAR_0->vga.ds = graphic_console_init(vmsvga_update_display,\nvmsvga_invalidate_display,\nvmsvga_screen_dump,\nvmsvga_text_update, VAR_0);",
"vga_init_vbe(&VAR_0->vga);",
"rom_add_vga(VGABIOS_FILENAME);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
31,
33,
35,
37
],
[
41
],
[
43
],
[
45
]
] |
3,217 | static uint32_t ehci_mem_readw(void *ptr, target_phys_addr_t addr)
{
EHCIState *s = ptr;
uint32_t val;
val = s->mmio[addr] | (s->mmio[addr+1] << 8);
return val;
}
| true | qemu | 3e4f910c8d490a1490409a7e381dbbb229f9d272 | static uint32_t ehci_mem_readw(void *ptr, target_phys_addr_t addr)
{
EHCIState *s = ptr;
uint32_t val;
val = s->mmio[addr] | (s->mmio[addr+1] << 8);
return val;
}
| {
"code": [
" uint32_t val;",
" return val;",
"static uint32_t ehci_mem_readw(void *ptr, target_phys_addr_t addr)",
" val = s->mmio[addr] | (s->mmio[addr+1] << 8);"
],
"line_no": [
7,
15,
1,
11
]
} | static uint32_t FUNC_0(void *ptr, target_phys_addr_t addr)
{
EHCIState *s = ptr;
uint32_t val;
val = s->mmio[addr] | (s->mmio[addr+1] << 8);
return val;
}
| [
"static uint32_t FUNC_0(void *ptr, target_phys_addr_t addr)\n{",
"EHCIState *s = ptr;",
"uint32_t val;",
"val = s->mmio[addr] | (s->mmio[addr+1] << 8);",
"return val;",
"}"
] | [
1,
0,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
]
] |
3,218 | static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVQcowState *s = bs->opaque;
int len, i, ret = 0;
QCowHeader header;
QemuOpts *opts;
Error *local_err = NULL;
uint64_t ext_end;
uint64_t l1_vm_state_index;
const char *opt_overlap_check;
int overlap_check_template = 0;
ret = bdrv_pread(bs->file, 0, &header, sizeof(header));
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read qcow2 header");
goto fail;
}
be32_to_cpus(&header.magic);
be32_to_cpus(&header.version);
be64_to_cpus(&header.backing_file_offset);
be32_to_cpus(&header.backing_file_size);
be64_to_cpus(&header.size);
be32_to_cpus(&header.cluster_bits);
be32_to_cpus(&header.crypt_method);
be64_to_cpus(&header.l1_table_offset);
be32_to_cpus(&header.l1_size);
be64_to_cpus(&header.refcount_table_offset);
be32_to_cpus(&header.refcount_table_clusters);
be64_to_cpus(&header.snapshots_offset);
be32_to_cpus(&header.nb_snapshots);
if (header.magic != QCOW_MAGIC) {
error_setg(errp, "Image is not in qcow2 format");
ret = -EINVAL;
goto fail;
}
if (header.version < 2 || header.version > 3) {
report_unsupported(bs, errp, "QCOW version %d", header.version);
ret = -ENOTSUP;
goto fail;
}
s->qcow_version = header.version;
/* Initialise version 3 header fields */
if (header.version == 2) {
header.incompatible_features = 0;
header.compatible_features = 0;
header.autoclear_features = 0;
header.refcount_order = 4;
header.header_length = 72;
} else {
be64_to_cpus(&header.incompatible_features);
be64_to_cpus(&header.compatible_features);
be64_to_cpus(&header.autoclear_features);
be32_to_cpus(&header.refcount_order);
be32_to_cpus(&header.header_length);
}
if (header.header_length > sizeof(header)) {
s->unknown_header_fields_size = header.header_length - sizeof(header);
s->unknown_header_fields = g_malloc(s->unknown_header_fields_size);
ret = bdrv_pread(bs->file, sizeof(header), s->unknown_header_fields,
s->unknown_header_fields_size);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read unknown qcow2 header "
"fields");
goto fail;
}
}
if (header.backing_file_offset) {
ext_end = header.backing_file_offset;
} else {
ext_end = 1 << header.cluster_bits;
}
/* Handle feature bits */
s->incompatible_features = header.incompatible_features;
s->compatible_features = header.compatible_features;
s->autoclear_features = header.autoclear_features;
if (s->incompatible_features & ~QCOW2_INCOMPAT_MASK) {
void *feature_table = NULL;
qcow2_read_extensions(bs, header.header_length, ext_end,
&feature_table, NULL);
report_unsupported_feature(bs, errp, feature_table,
s->incompatible_features &
~QCOW2_INCOMPAT_MASK);
ret = -ENOTSUP;
g_free(feature_table);
goto fail;
}
if (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT) {
/* Corrupt images may not be written to unless they are being repaired
*/
if ((flags & BDRV_O_RDWR) && !(flags & BDRV_O_CHECK)) {
error_setg(errp, "qcow2: Image is corrupt; cannot be opened "
"read/write");
ret = -EACCES;
goto fail;
}
}
/* Check support for various header values */
if (header.refcount_order != 4) {
report_unsupported(bs, errp, "%d bit reference counts",
1 << header.refcount_order);
ret = -ENOTSUP;
goto fail;
}
s->refcount_order = header.refcount_order;
if (header.cluster_bits < MIN_CLUSTER_BITS ||
header.cluster_bits > MAX_CLUSTER_BITS) {
error_setg(errp, "Unsupported cluster size: 2^%i", header.cluster_bits);
ret = -EINVAL;
goto fail;
}
if (header.crypt_method > QCOW_CRYPT_AES) {
error_setg(errp, "Unsupported encryption method: %i",
header.crypt_method);
ret = -EINVAL;
goto fail;
}
s->crypt_method_header = header.crypt_method;
if (s->crypt_method_header) {
bs->encrypted = 1;
}
s->cluster_bits = header.cluster_bits;
s->cluster_size = 1 << s->cluster_bits;
s->cluster_sectors = 1 << (s->cluster_bits - 9);
s->l2_bits = s->cluster_bits - 3; /* L2 is always one cluster */
s->l2_size = 1 << s->l2_bits;
bs->total_sectors = header.size / 512;
s->csize_shift = (62 - (s->cluster_bits - 8));
s->csize_mask = (1 << (s->cluster_bits - 8)) - 1;
s->cluster_offset_mask = (1LL << s->csize_shift) - 1;
s->refcount_table_offset = header.refcount_table_offset;
s->refcount_table_size =
header.refcount_table_clusters << (s->cluster_bits - 3);
s->snapshots_offset = header.snapshots_offset;
s->nb_snapshots = header.nb_snapshots;
/* read the level 1 table */
s->l1_size = header.l1_size;
l1_vm_state_index = size_to_l1(s, header.size);
if (l1_vm_state_index > INT_MAX) {
error_setg(errp, "Image is too big");
ret = -EFBIG;
goto fail;
}
s->l1_vm_state_index = l1_vm_state_index;
/* the L1 table must contain at least enough entries to put
header.size bytes */
if (s->l1_size < s->l1_vm_state_index) {
error_setg(errp, "L1 table is too small");
ret = -EINVAL;
goto fail;
}
s->l1_table_offset = header.l1_table_offset;
if (s->l1_size > 0) {
s->l1_table = g_malloc0(
align_offset(s->l1_size * sizeof(uint64_t), 512));
ret = bdrv_pread(bs->file, s->l1_table_offset, s->l1_table,
s->l1_size * sizeof(uint64_t));
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read L1 table");
goto fail;
}
for(i = 0;i < s->l1_size; i++) {
be64_to_cpus(&s->l1_table[i]);
}
}
/* alloc L2 table/refcount block cache */
s->l2_table_cache = qcow2_cache_create(bs, L2_CACHE_SIZE);
s->refcount_block_cache = qcow2_cache_create(bs, REFCOUNT_CACHE_SIZE);
s->cluster_cache = g_malloc(s->cluster_size);
/* one more sector for decompressed data alignment */
s->cluster_data = qemu_blockalign(bs, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size
+ 512);
s->cluster_cache_offset = -1;
s->flags = flags;
ret = qcow2_refcount_init(bs);
if (ret != 0) {
error_setg_errno(errp, -ret, "Could not initialize refcount handling");
goto fail;
}
QLIST_INIT(&s->cluster_allocs);
QTAILQ_INIT(&s->discards);
/* read qcow2 extensions */
if (qcow2_read_extensions(bs, header.header_length, ext_end, NULL,
&local_err)) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto fail;
}
/* read the backing file name */
if (header.backing_file_offset != 0) {
len = header.backing_file_size;
if (len > 1023) {
len = 1023;
}
ret = bdrv_pread(bs->file, header.backing_file_offset,
bs->backing_file, len);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read backing file name");
goto fail;
}
bs->backing_file[len] = '\0';
}
ret = qcow2_read_snapshots(bs);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read snapshots");
goto fail;
}
/* Clear unknown autoclear feature bits */
if (!bs->read_only && !(flags & BDRV_O_INCOMING) && s->autoclear_features) {
s->autoclear_features = 0;
ret = qcow2_update_header(bs);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not update qcow2 header");
goto fail;
}
}
/* Initialise locks */
qemu_co_mutex_init(&s->lock);
/* Repair image if dirty */
if (!(flags & (BDRV_O_CHECK | BDRV_O_INCOMING)) && !bs->read_only &&
(s->incompatible_features & QCOW2_INCOMPAT_DIRTY)) {
BdrvCheckResult result = {0};
ret = qcow2_check(bs, &result, BDRV_FIX_ERRORS);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not repair dirty image");
goto fail;
}
}
/* Enable lazy_refcounts according to image and command line options */
opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto fail;
}
s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS,
(s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS));
s->discard_passthrough[QCOW2_DISCARD_NEVER] = false;
s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true;
s->discard_passthrough[QCOW2_DISCARD_REQUEST] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST,
flags & BDRV_O_UNMAP);
s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true);
s->discard_passthrough[QCOW2_DISCARD_OTHER] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false);
opt_overlap_check = qemu_opt_get(opts, "overlap-check") ?: "cached";
if (!strcmp(opt_overlap_check, "none")) {
overlap_check_template = 0;
} else if (!strcmp(opt_overlap_check, "constant")) {
overlap_check_template = QCOW2_OL_CONSTANT;
} else if (!strcmp(opt_overlap_check, "cached")) {
overlap_check_template = QCOW2_OL_CACHED;
} else if (!strcmp(opt_overlap_check, "all")) {
overlap_check_template = QCOW2_OL_ALL;
} else {
error_setg(errp, "Unsupported value '%s' for qcow2 option "
"'overlap-check'. Allowed are either of the following: "
"none, constant, cached, all", opt_overlap_check);
qemu_opts_del(opts);
ret = -EINVAL;
goto fail;
}
s->overlap_check = 0;
for (i = 0; i < QCOW2_OL_MAX_BITNR; i++) {
/* overlap-check defines a template bitmask, but every flag may be
* overwritten through the associated boolean option */
s->overlap_check |=
qemu_opt_get_bool(opts, overlap_bool_option_names[i],
overlap_check_template & (1 << i)) << i;
}
qemu_opts_del(opts);
if (s->use_lazy_refcounts && s->qcow_version < 3) {
error_setg(errp, "Lazy refcounts require a qcow2 image with at least "
"qemu 1.1 compatibility level");
ret = -EINVAL;
goto fail;
}
#ifdef DEBUG_ALLOC
{
BdrvCheckResult result = {0};
qcow2_check_refcounts(bs, &result, 0);
}
#endif
return ret;
fail:
g_free(s->unknown_header_fields);
cleanup_unknown_header_ext(bs);
qcow2_free_snapshots(bs);
qcow2_refcount_close(bs);
g_free(s->l1_table);
/* else pre-write overlap checks in cache_destroy may crash */
s->l1_table = NULL;
if (s->l2_table_cache) {
qcow2_cache_destroy(bs, s->l2_table_cache);
}
if (s->refcount_block_cache) {
qcow2_cache_destroy(bs, s->refcount_block_cache);
}
g_free(s->cluster_cache);
qemu_vfree(s->cluster_data);
return ret;
}
| true | qemu | 24342f2cae47d03911e346fe1e520b00dc2818e0 | static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVQcowState *s = bs->opaque;
int len, i, ret = 0;
QCowHeader header;
QemuOpts *opts;
Error *local_err = NULL;
uint64_t ext_end;
uint64_t l1_vm_state_index;
const char *opt_overlap_check;
int overlap_check_template = 0;
ret = bdrv_pread(bs->file, 0, &header, sizeof(header));
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read qcow2 header");
goto fail;
}
be32_to_cpus(&header.magic);
be32_to_cpus(&header.version);
be64_to_cpus(&header.backing_file_offset);
be32_to_cpus(&header.backing_file_size);
be64_to_cpus(&header.size);
be32_to_cpus(&header.cluster_bits);
be32_to_cpus(&header.crypt_method);
be64_to_cpus(&header.l1_table_offset);
be32_to_cpus(&header.l1_size);
be64_to_cpus(&header.refcount_table_offset);
be32_to_cpus(&header.refcount_table_clusters);
be64_to_cpus(&header.snapshots_offset);
be32_to_cpus(&header.nb_snapshots);
if (header.magic != QCOW_MAGIC) {
error_setg(errp, "Image is not in qcow2 format");
ret = -EINVAL;
goto fail;
}
if (header.version < 2 || header.version > 3) {
report_unsupported(bs, errp, "QCOW version %d", header.version);
ret = -ENOTSUP;
goto fail;
}
s->qcow_version = header.version;
if (header.version == 2) {
header.incompatible_features = 0;
header.compatible_features = 0;
header.autoclear_features = 0;
header.refcount_order = 4;
header.header_length = 72;
} else {
be64_to_cpus(&header.incompatible_features);
be64_to_cpus(&header.compatible_features);
be64_to_cpus(&header.autoclear_features);
be32_to_cpus(&header.refcount_order);
be32_to_cpus(&header.header_length);
}
if (header.header_length > sizeof(header)) {
s->unknown_header_fields_size = header.header_length - sizeof(header);
s->unknown_header_fields = g_malloc(s->unknown_header_fields_size);
ret = bdrv_pread(bs->file, sizeof(header), s->unknown_header_fields,
s->unknown_header_fields_size);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read unknown qcow2 header "
"fields");
goto fail;
}
}
if (header.backing_file_offset) {
ext_end = header.backing_file_offset;
} else {
ext_end = 1 << header.cluster_bits;
}
s->incompatible_features = header.incompatible_features;
s->compatible_features = header.compatible_features;
s->autoclear_features = header.autoclear_features;
if (s->incompatible_features & ~QCOW2_INCOMPAT_MASK) {
void *feature_table = NULL;
qcow2_read_extensions(bs, header.header_length, ext_end,
&feature_table, NULL);
report_unsupported_feature(bs, errp, feature_table,
s->incompatible_features &
~QCOW2_INCOMPAT_MASK);
ret = -ENOTSUP;
g_free(feature_table);
goto fail;
}
if (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT) {
if ((flags & BDRV_O_RDWR) && !(flags & BDRV_O_CHECK)) {
error_setg(errp, "qcow2: Image is corrupt; cannot be opened "
"read/write");
ret = -EACCES;
goto fail;
}
}
if (header.refcount_order != 4) {
report_unsupported(bs, errp, "%d bit reference counts",
1 << header.refcount_order);
ret = -ENOTSUP;
goto fail;
}
s->refcount_order = header.refcount_order;
if (header.cluster_bits < MIN_CLUSTER_BITS ||
header.cluster_bits > MAX_CLUSTER_BITS) {
error_setg(errp, "Unsupported cluster size: 2^%i", header.cluster_bits);
ret = -EINVAL;
goto fail;
}
if (header.crypt_method > QCOW_CRYPT_AES) {
error_setg(errp, "Unsupported encryption method: %i",
header.crypt_method);
ret = -EINVAL;
goto fail;
}
s->crypt_method_header = header.crypt_method;
if (s->crypt_method_header) {
bs->encrypted = 1;
}
s->cluster_bits = header.cluster_bits;
s->cluster_size = 1 << s->cluster_bits;
s->cluster_sectors = 1 << (s->cluster_bits - 9);
s->l2_bits = s->cluster_bits - 3;
s->l2_size = 1 << s->l2_bits;
bs->total_sectors = header.size / 512;
s->csize_shift = (62 - (s->cluster_bits - 8));
s->csize_mask = (1 << (s->cluster_bits - 8)) - 1;
s->cluster_offset_mask = (1LL << s->csize_shift) - 1;
s->refcount_table_offset = header.refcount_table_offset;
s->refcount_table_size =
header.refcount_table_clusters << (s->cluster_bits - 3);
s->snapshots_offset = header.snapshots_offset;
s->nb_snapshots = header.nb_snapshots;
s->l1_size = header.l1_size;
l1_vm_state_index = size_to_l1(s, header.size);
if (l1_vm_state_index > INT_MAX) {
error_setg(errp, "Image is too big");
ret = -EFBIG;
goto fail;
}
s->l1_vm_state_index = l1_vm_state_index;
if (s->l1_size < s->l1_vm_state_index) {
error_setg(errp, "L1 table is too small");
ret = -EINVAL;
goto fail;
}
s->l1_table_offset = header.l1_table_offset;
if (s->l1_size > 0) {
s->l1_table = g_malloc0(
align_offset(s->l1_size * sizeof(uint64_t), 512));
ret = bdrv_pread(bs->file, s->l1_table_offset, s->l1_table,
s->l1_size * sizeof(uint64_t));
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read L1 table");
goto fail;
}
for(i = 0;i < s->l1_size; i++) {
be64_to_cpus(&s->l1_table[i]);
}
}
s->l2_table_cache = qcow2_cache_create(bs, L2_CACHE_SIZE);
s->refcount_block_cache = qcow2_cache_create(bs, REFCOUNT_CACHE_SIZE);
s->cluster_cache = g_malloc(s->cluster_size);
s->cluster_data = qemu_blockalign(bs, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size
+ 512);
s->cluster_cache_offset = -1;
s->flags = flags;
ret = qcow2_refcount_init(bs);
if (ret != 0) {
error_setg_errno(errp, -ret, "Could not initialize refcount handling");
goto fail;
}
QLIST_INIT(&s->cluster_allocs);
QTAILQ_INIT(&s->discards);
if (qcow2_read_extensions(bs, header.header_length, ext_end, NULL,
&local_err)) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto fail;
}
if (header.backing_file_offset != 0) {
len = header.backing_file_size;
if (len > 1023) {
len = 1023;
}
ret = bdrv_pread(bs->file, header.backing_file_offset,
bs->backing_file, len);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read backing file name");
goto fail;
}
bs->backing_file[len] = '\0';
}
ret = qcow2_read_snapshots(bs);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read snapshots");
goto fail;
}
if (!bs->read_only && !(flags & BDRV_O_INCOMING) && s->autoclear_features) {
s->autoclear_features = 0;
ret = qcow2_update_header(bs);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not update qcow2 header");
goto fail;
}
}
qemu_co_mutex_init(&s->lock);
if (!(flags & (BDRV_O_CHECK | BDRV_O_INCOMING)) && !bs->read_only &&
(s->incompatible_features & QCOW2_INCOMPAT_DIRTY)) {
BdrvCheckResult result = {0};
ret = qcow2_check(bs, &result, BDRV_FIX_ERRORS);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not repair dirty image");
goto fail;
}
}
opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto fail;
}
s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS,
(s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS));
s->discard_passthrough[QCOW2_DISCARD_NEVER] = false;
s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true;
s->discard_passthrough[QCOW2_DISCARD_REQUEST] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST,
flags & BDRV_O_UNMAP);
s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true);
s->discard_passthrough[QCOW2_DISCARD_OTHER] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false);
opt_overlap_check = qemu_opt_get(opts, "overlap-check") ?: "cached";
if (!strcmp(opt_overlap_check, "none")) {
overlap_check_template = 0;
} else if (!strcmp(opt_overlap_check, "constant")) {
overlap_check_template = QCOW2_OL_CONSTANT;
} else if (!strcmp(opt_overlap_check, "cached")) {
overlap_check_template = QCOW2_OL_CACHED;
} else if (!strcmp(opt_overlap_check, "all")) {
overlap_check_template = QCOW2_OL_ALL;
} else {
error_setg(errp, "Unsupported value '%s' for qcow2 option "
"'overlap-check'. Allowed are either of the following: "
"none, constant, cached, all", opt_overlap_check);
qemu_opts_del(opts);
ret = -EINVAL;
goto fail;
}
s->overlap_check = 0;
for (i = 0; i < QCOW2_OL_MAX_BITNR; i++) {
s->overlap_check |=
qemu_opt_get_bool(opts, overlap_bool_option_names[i],
overlap_check_template & (1 << i)) << i;
}
qemu_opts_del(opts);
if (s->use_lazy_refcounts && s->qcow_version < 3) {
error_setg(errp, "Lazy refcounts require a qcow2 image with at least "
"qemu 1.1 compatibility level");
ret = -EINVAL;
goto fail;
}
#ifdef DEBUG_ALLOC
{
BdrvCheckResult result = {0};
qcow2_check_refcounts(bs, &result, 0);
}
#endif
return ret;
fail:
g_free(s->unknown_header_fields);
cleanup_unknown_header_ext(bs);
qcow2_free_snapshots(bs);
qcow2_refcount_close(bs);
g_free(s->l1_table);
s->l1_table = NULL;
if (s->l2_table_cache) {
qcow2_cache_destroy(bs, s->l2_table_cache);
}
if (s->refcount_block_cache) {
qcow2_cache_destroy(bs, s->refcount_block_cache);
}
g_free(s->cluster_cache);
qemu_vfree(s->cluster_data);
return ret;
}
| {
"code": [
" if (header.cluster_bits < MIN_CLUSTER_BITS ||",
" header.cluster_bits > MAX_CLUSTER_BITS) {",
" error_setg(errp, \"Unsupported cluster size: 2^%i\", header.cluster_bits);",
" ret = -EINVAL;",
" goto fail;",
" s->cluster_bits = header.cluster_bits;",
" s->cluster_size = 1 << s->cluster_bits;",
" s->cluster_sectors = 1 << (s->cluster_bits - 9);"
],
"line_no": [
231,
233,
235,
69,
33,
263,
265,
267
]
} | static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,
Error **VAR_3)
{
BDRVQcowState *s = VAR_0->opaque;
int VAR_4, VAR_5, VAR_6 = 0;
QCowHeader header;
QemuOpts *opts;
Error *local_err = NULL;
uint64_t ext_end;
uint64_t l1_vm_state_index;
const char *VAR_7;
int VAR_8 = 0;
VAR_6 = bdrv_pread(VAR_0->file, 0, &header, sizeof(header));
if (VAR_6 < 0) {
error_setg_errno(VAR_3, -VAR_6, "Could not read qcow2 header");
goto fail;
}
be32_to_cpus(&header.magic);
be32_to_cpus(&header.version);
be64_to_cpus(&header.backing_file_offset);
be32_to_cpus(&header.backing_file_size);
be64_to_cpus(&header.size);
be32_to_cpus(&header.cluster_bits);
be32_to_cpus(&header.crypt_method);
be64_to_cpus(&header.l1_table_offset);
be32_to_cpus(&header.l1_size);
be64_to_cpus(&header.refcount_table_offset);
be32_to_cpus(&header.refcount_table_clusters);
be64_to_cpus(&header.snapshots_offset);
be32_to_cpus(&header.nb_snapshots);
if (header.magic != QCOW_MAGIC) {
error_setg(VAR_3, "Image is not in qcow2 format");
VAR_6 = -EINVAL;
goto fail;
}
if (header.version < 2 || header.version > 3) {
report_unsupported(VAR_0, VAR_3, "QCOW version %d", header.version);
VAR_6 = -ENOTSUP;
goto fail;
}
s->qcow_version = header.version;
if (header.version == 2) {
header.incompatible_features = 0;
header.compatible_features = 0;
header.autoclear_features = 0;
header.refcount_order = 4;
header.header_length = 72;
} else {
be64_to_cpus(&header.incompatible_features);
be64_to_cpus(&header.compatible_features);
be64_to_cpus(&header.autoclear_features);
be32_to_cpus(&header.refcount_order);
be32_to_cpus(&header.header_length);
}
if (header.header_length > sizeof(header)) {
s->unknown_header_fields_size = header.header_length - sizeof(header);
s->unknown_header_fields = g_malloc(s->unknown_header_fields_size);
VAR_6 = bdrv_pread(VAR_0->file, sizeof(header), s->unknown_header_fields,
s->unknown_header_fields_size);
if (VAR_6 < 0) {
error_setg_errno(VAR_3, -VAR_6, "Could not read unknown qcow2 header "
"fields");
goto fail;
}
}
if (header.backing_file_offset) {
ext_end = header.backing_file_offset;
} else {
ext_end = 1 << header.cluster_bits;
}
s->incompatible_features = header.incompatible_features;
s->compatible_features = header.compatible_features;
s->autoclear_features = header.autoclear_features;
if (s->incompatible_features & ~QCOW2_INCOMPAT_MASK) {
void *VAR_9 = NULL;
qcow2_read_extensions(VAR_0, header.header_length, ext_end,
&VAR_9, NULL);
report_unsupported_feature(VAR_0, VAR_3, VAR_9,
s->incompatible_features &
~QCOW2_INCOMPAT_MASK);
VAR_6 = -ENOTSUP;
g_free(VAR_9);
goto fail;
}
if (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT) {
if ((VAR_2 & BDRV_O_RDWR) && !(VAR_2 & BDRV_O_CHECK)) {
error_setg(VAR_3, "qcow2: Image is corrupt; cannot be opened "
"read/write");
VAR_6 = -EACCES;
goto fail;
}
}
if (header.refcount_order != 4) {
report_unsupported(VAR_0, VAR_3, "%d bit reference counts",
1 << header.refcount_order);
VAR_6 = -ENOTSUP;
goto fail;
}
s->refcount_order = header.refcount_order;
if (header.cluster_bits < MIN_CLUSTER_BITS ||
header.cluster_bits > MAX_CLUSTER_BITS) {
error_setg(VAR_3, "Unsupported cluster size: 2^%VAR_5", header.cluster_bits);
VAR_6 = -EINVAL;
goto fail;
}
if (header.crypt_method > QCOW_CRYPT_AES) {
error_setg(VAR_3, "Unsupported encryption method: %VAR_5",
header.crypt_method);
VAR_6 = -EINVAL;
goto fail;
}
s->crypt_method_header = header.crypt_method;
if (s->crypt_method_header) {
VAR_0->encrypted = 1;
}
s->cluster_bits = header.cluster_bits;
s->cluster_size = 1 << s->cluster_bits;
s->cluster_sectors = 1 << (s->cluster_bits - 9);
s->l2_bits = s->cluster_bits - 3;
s->l2_size = 1 << s->l2_bits;
VAR_0->total_sectors = header.size / 512;
s->csize_shift = (62 - (s->cluster_bits - 8));
s->csize_mask = (1 << (s->cluster_bits - 8)) - 1;
s->cluster_offset_mask = (1LL << s->csize_shift) - 1;
s->refcount_table_offset = header.refcount_table_offset;
s->refcount_table_size =
header.refcount_table_clusters << (s->cluster_bits - 3);
s->snapshots_offset = header.snapshots_offset;
s->nb_snapshots = header.nb_snapshots;
s->l1_size = header.l1_size;
l1_vm_state_index = size_to_l1(s, header.size);
if (l1_vm_state_index > INT_MAX) {
error_setg(VAR_3, "Image is too big");
VAR_6 = -EFBIG;
goto fail;
}
s->l1_vm_state_index = l1_vm_state_index;
if (s->l1_size < s->l1_vm_state_index) {
error_setg(VAR_3, "L1 table is too small");
VAR_6 = -EINVAL;
goto fail;
}
s->l1_table_offset = header.l1_table_offset;
if (s->l1_size > 0) {
s->l1_table = g_malloc0(
align_offset(s->l1_size * sizeof(uint64_t), 512));
VAR_6 = bdrv_pread(VAR_0->file, s->l1_table_offset, s->l1_table,
s->l1_size * sizeof(uint64_t));
if (VAR_6 < 0) {
error_setg_errno(VAR_3, -VAR_6, "Could not read L1 table");
goto fail;
}
for(VAR_5 = 0;VAR_5 < s->l1_size; VAR_5++) {
be64_to_cpus(&s->l1_table[VAR_5]);
}
}
s->l2_table_cache = qcow2_cache_create(VAR_0, L2_CACHE_SIZE);
s->refcount_block_cache = qcow2_cache_create(VAR_0, REFCOUNT_CACHE_SIZE);
s->cluster_cache = g_malloc(s->cluster_size);
s->cluster_data = qemu_blockalign(VAR_0, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size
+ 512);
s->cluster_cache_offset = -1;
s->VAR_2 = VAR_2;
VAR_6 = qcow2_refcount_init(VAR_0);
if (VAR_6 != 0) {
error_setg_errno(VAR_3, -VAR_6, "Could not initialize refcount handling");
goto fail;
}
QLIST_INIT(&s->cluster_allocs);
QTAILQ_INIT(&s->discards);
if (qcow2_read_extensions(VAR_0, header.header_length, ext_end, NULL,
&local_err)) {
error_propagate(VAR_3, local_err);
VAR_6 = -EINVAL;
goto fail;
}
if (header.backing_file_offset != 0) {
VAR_4 = header.backing_file_size;
if (VAR_4 > 1023) {
VAR_4 = 1023;
}
VAR_6 = bdrv_pread(VAR_0->file, header.backing_file_offset,
VAR_0->backing_file, VAR_4);
if (VAR_6 < 0) {
error_setg_errno(VAR_3, -VAR_6, "Could not read backing file name");
goto fail;
}
VAR_0->backing_file[VAR_4] = '\0';
}
VAR_6 = qcow2_read_snapshots(VAR_0);
if (VAR_6 < 0) {
error_setg_errno(VAR_3, -VAR_6, "Could not read snapshots");
goto fail;
}
if (!VAR_0->read_only && !(VAR_2 & BDRV_O_INCOMING) && s->autoclear_features) {
s->autoclear_features = 0;
VAR_6 = qcow2_update_header(VAR_0);
if (VAR_6 < 0) {
error_setg_errno(VAR_3, -VAR_6, "Could not update qcow2 header");
goto fail;
}
}
qemu_co_mutex_init(&s->lock);
if (!(VAR_2 & (BDRV_O_CHECK | BDRV_O_INCOMING)) && !VAR_0->read_only &&
(s->incompatible_features & QCOW2_INCOMPAT_DIRTY)) {
BdrvCheckResult result = {0};
VAR_6 = qcow2_check(VAR_0, &result, BDRV_FIX_ERRORS);
if (VAR_6 < 0) {
error_setg_errno(VAR_3, -VAR_6, "Could not repair dirty image");
goto fail;
}
}
opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, VAR_1, &local_err);
if (local_err) {
error_propagate(VAR_3, local_err);
VAR_6 = -EINVAL;
goto fail;
}
s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS,
(s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS));
s->discard_passthrough[QCOW2_DISCARD_NEVER] = false;
s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true;
s->discard_passthrough[QCOW2_DISCARD_REQUEST] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST,
VAR_2 & BDRV_O_UNMAP);
s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true);
s->discard_passthrough[QCOW2_DISCARD_OTHER] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false);
VAR_7 = qemu_opt_get(opts, "overlap-check") ?: "cached";
if (!strcmp(VAR_7, "none")) {
VAR_8 = 0;
} else if (!strcmp(VAR_7, "constant")) {
VAR_8 = QCOW2_OL_CONSTANT;
} else if (!strcmp(VAR_7, "cached")) {
VAR_8 = QCOW2_OL_CACHED;
} else if (!strcmp(VAR_7, "all")) {
VAR_8 = QCOW2_OL_ALL;
} else {
error_setg(VAR_3, "Unsupported value '%s' for qcow2 option "
"'overlap-check'. Allowed are either of the following: "
"none, constant, cached, all", VAR_7);
qemu_opts_del(opts);
VAR_6 = -EINVAL;
goto fail;
}
s->overlap_check = 0;
for (VAR_5 = 0; VAR_5 < QCOW2_OL_MAX_BITNR; VAR_5++) {
s->overlap_check |=
qemu_opt_get_bool(opts, overlap_bool_option_names[VAR_5],
VAR_8 & (1 << VAR_5)) << VAR_5;
}
qemu_opts_del(opts);
if (s->use_lazy_refcounts && s->qcow_version < 3) {
error_setg(VAR_3, "Lazy refcounts require a qcow2 image with at least "
"qemu 1.1 compatibility level");
VAR_6 = -EINVAL;
goto fail;
}
#ifdef DEBUG_ALLOC
{
BdrvCheckResult result = {0};
qcow2_check_refcounts(VAR_0, &result, 0);
}
#endif
return VAR_6;
fail:
g_free(s->unknown_header_fields);
cleanup_unknown_header_ext(VAR_0);
qcow2_free_snapshots(VAR_0);
qcow2_refcount_close(VAR_0);
g_free(s->l1_table);
s->l1_table = NULL;
if (s->l2_table_cache) {
qcow2_cache_destroy(VAR_0, s->l2_table_cache);
}
if (s->refcount_block_cache) {
qcow2_cache_destroy(VAR_0, s->refcount_block_cache);
}
g_free(s->cluster_cache);
qemu_vfree(s->cluster_data);
return VAR_6;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,\nError **VAR_3)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"int VAR_4, VAR_5, VAR_6 = 0;",
"QCowHeader header;",
"QemuOpts *opts;",
"Error *local_err = NULL;",
"uint64_t ext_end;",
"uint64_t l1_vm_state_index;",
"const char *VAR_7;",
"int VAR_8 = 0;",
"VAR_6 = bdrv_pread(VAR_0->file, 0, &header, sizeof(header));",
"if (VAR_6 < 0) {",
"error_setg_errno(VAR_3, -VAR_6, \"Could not read qcow2 header\");",
"goto fail;",
"}",
"be32_to_cpus(&header.magic);",
"be32_to_cpus(&header.version);",
"be64_to_cpus(&header.backing_file_offset);",
"be32_to_cpus(&header.backing_file_size);",
"be64_to_cpus(&header.size);",
"be32_to_cpus(&header.cluster_bits);",
"be32_to_cpus(&header.crypt_method);",
"be64_to_cpus(&header.l1_table_offset);",
"be32_to_cpus(&header.l1_size);",
"be64_to_cpus(&header.refcount_table_offset);",
"be32_to_cpus(&header.refcount_table_clusters);",
"be64_to_cpus(&header.snapshots_offset);",
"be32_to_cpus(&header.nb_snapshots);",
"if (header.magic != QCOW_MAGIC) {",
"error_setg(VAR_3, \"Image is not in qcow2 format\");",
"VAR_6 = -EINVAL;",
"goto fail;",
"}",
"if (header.version < 2 || header.version > 3) {",
"report_unsupported(VAR_0, VAR_3, \"QCOW version %d\", header.version);",
"VAR_6 = -ENOTSUP;",
"goto fail;",
"}",
"s->qcow_version = header.version;",
"if (header.version == 2) {",
"header.incompatible_features = 0;",
"header.compatible_features = 0;",
"header.autoclear_features = 0;",
"header.refcount_order = 4;",
"header.header_length = 72;",
"} else {",
"be64_to_cpus(&header.incompatible_features);",
"be64_to_cpus(&header.compatible_features);",
"be64_to_cpus(&header.autoclear_features);",
"be32_to_cpus(&header.refcount_order);",
"be32_to_cpus(&header.header_length);",
"}",
"if (header.header_length > sizeof(header)) {",
"s->unknown_header_fields_size = header.header_length - sizeof(header);",
"s->unknown_header_fields = g_malloc(s->unknown_header_fields_size);",
"VAR_6 = bdrv_pread(VAR_0->file, sizeof(header), s->unknown_header_fields,\ns->unknown_header_fields_size);",
"if (VAR_6 < 0) {",
"error_setg_errno(VAR_3, -VAR_6, \"Could not read unknown qcow2 header \"\n\"fields\");",
"goto fail;",
"}",
"}",
"if (header.backing_file_offset) {",
"ext_end = header.backing_file_offset;",
"} else {",
"ext_end = 1 << header.cluster_bits;",
"}",
"s->incompatible_features = header.incompatible_features;",
"s->compatible_features = header.compatible_features;",
"s->autoclear_features = header.autoclear_features;",
"if (s->incompatible_features & ~QCOW2_INCOMPAT_MASK) {",
"void *VAR_9 = NULL;",
"qcow2_read_extensions(VAR_0, header.header_length, ext_end,\n&VAR_9, NULL);",
"report_unsupported_feature(VAR_0, VAR_3, VAR_9,\ns->incompatible_features &\n~QCOW2_INCOMPAT_MASK);",
"VAR_6 = -ENOTSUP;",
"g_free(VAR_9);",
"goto fail;",
"}",
"if (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT) {",
"if ((VAR_2 & BDRV_O_RDWR) && !(VAR_2 & BDRV_O_CHECK)) {",
"error_setg(VAR_3, \"qcow2: Image is corrupt; cannot be opened \"",
"\"read/write\");",
"VAR_6 = -EACCES;",
"goto fail;",
"}",
"}",
"if (header.refcount_order != 4) {",
"report_unsupported(VAR_0, VAR_3, \"%d bit reference counts\",\n1 << header.refcount_order);",
"VAR_6 = -ENOTSUP;",
"goto fail;",
"}",
"s->refcount_order = header.refcount_order;",
"if (header.cluster_bits < MIN_CLUSTER_BITS ||\nheader.cluster_bits > MAX_CLUSTER_BITS) {",
"error_setg(VAR_3, \"Unsupported cluster size: 2^%VAR_5\", header.cluster_bits);",
"VAR_6 = -EINVAL;",
"goto fail;",
"}",
"if (header.crypt_method > QCOW_CRYPT_AES) {",
"error_setg(VAR_3, \"Unsupported encryption method: %VAR_5\",\nheader.crypt_method);",
"VAR_6 = -EINVAL;",
"goto fail;",
"}",
"s->crypt_method_header = header.crypt_method;",
"if (s->crypt_method_header) {",
"VAR_0->encrypted = 1;",
"}",
"s->cluster_bits = header.cluster_bits;",
"s->cluster_size = 1 << s->cluster_bits;",
"s->cluster_sectors = 1 << (s->cluster_bits - 9);",
"s->l2_bits = s->cluster_bits - 3;",
"s->l2_size = 1 << s->l2_bits;",
"VAR_0->total_sectors = header.size / 512;",
"s->csize_shift = (62 - (s->cluster_bits - 8));",
"s->csize_mask = (1 << (s->cluster_bits - 8)) - 1;",
"s->cluster_offset_mask = (1LL << s->csize_shift) - 1;",
"s->refcount_table_offset = header.refcount_table_offset;",
"s->refcount_table_size =\nheader.refcount_table_clusters << (s->cluster_bits - 3);",
"s->snapshots_offset = header.snapshots_offset;",
"s->nb_snapshots = header.nb_snapshots;",
"s->l1_size = header.l1_size;",
"l1_vm_state_index = size_to_l1(s, header.size);",
"if (l1_vm_state_index > INT_MAX) {",
"error_setg(VAR_3, \"Image is too big\");",
"VAR_6 = -EFBIG;",
"goto fail;",
"}",
"s->l1_vm_state_index = l1_vm_state_index;",
"if (s->l1_size < s->l1_vm_state_index) {",
"error_setg(VAR_3, \"L1 table is too small\");",
"VAR_6 = -EINVAL;",
"goto fail;",
"}",
"s->l1_table_offset = header.l1_table_offset;",
"if (s->l1_size > 0) {",
"s->l1_table = g_malloc0(\nalign_offset(s->l1_size * sizeof(uint64_t), 512));",
"VAR_6 = bdrv_pread(VAR_0->file, s->l1_table_offset, s->l1_table,\ns->l1_size * sizeof(uint64_t));",
"if (VAR_6 < 0) {",
"error_setg_errno(VAR_3, -VAR_6, \"Could not read L1 table\");",
"goto fail;",
"}",
"for(VAR_5 = 0;VAR_5 < s->l1_size; VAR_5++) {",
"be64_to_cpus(&s->l1_table[VAR_5]);",
"}",
"}",
"s->l2_table_cache = qcow2_cache_create(VAR_0, L2_CACHE_SIZE);",
"s->refcount_block_cache = qcow2_cache_create(VAR_0, REFCOUNT_CACHE_SIZE);",
"s->cluster_cache = g_malloc(s->cluster_size);",
"s->cluster_data = qemu_blockalign(VAR_0, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size\n+ 512);",
"s->cluster_cache_offset = -1;",
"s->VAR_2 = VAR_2;",
"VAR_6 = qcow2_refcount_init(VAR_0);",
"if (VAR_6 != 0) {",
"error_setg_errno(VAR_3, -VAR_6, \"Could not initialize refcount handling\");",
"goto fail;",
"}",
"QLIST_INIT(&s->cluster_allocs);",
"QTAILQ_INIT(&s->discards);",
"if (qcow2_read_extensions(VAR_0, header.header_length, ext_end, NULL,\n&local_err)) {",
"error_propagate(VAR_3, local_err);",
"VAR_6 = -EINVAL;",
"goto fail;",
"}",
"if (header.backing_file_offset != 0) {",
"VAR_4 = header.backing_file_size;",
"if (VAR_4 > 1023) {",
"VAR_4 = 1023;",
"}",
"VAR_6 = bdrv_pread(VAR_0->file, header.backing_file_offset,\nVAR_0->backing_file, VAR_4);",
"if (VAR_6 < 0) {",
"error_setg_errno(VAR_3, -VAR_6, \"Could not read backing file name\");",
"goto fail;",
"}",
"VAR_0->backing_file[VAR_4] = '\\0';",
"}",
"VAR_6 = qcow2_read_snapshots(VAR_0);",
"if (VAR_6 < 0) {",
"error_setg_errno(VAR_3, -VAR_6, \"Could not read snapshots\");",
"goto fail;",
"}",
"if (!VAR_0->read_only && !(VAR_2 & BDRV_O_INCOMING) && s->autoclear_features) {",
"s->autoclear_features = 0;",
"VAR_6 = qcow2_update_header(VAR_0);",
"if (VAR_6 < 0) {",
"error_setg_errno(VAR_3, -VAR_6, \"Could not update qcow2 header\");",
"goto fail;",
"}",
"}",
"qemu_co_mutex_init(&s->lock);",
"if (!(VAR_2 & (BDRV_O_CHECK | BDRV_O_INCOMING)) && !VAR_0->read_only &&\n(s->incompatible_features & QCOW2_INCOMPAT_DIRTY)) {",
"BdrvCheckResult result = {0};",
"VAR_6 = qcow2_check(VAR_0, &result, BDRV_FIX_ERRORS);",
"if (VAR_6 < 0) {",
"error_setg_errno(VAR_3, -VAR_6, \"Could not repair dirty image\");",
"goto fail;",
"}",
"}",
"opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort);",
"qemu_opts_absorb_qdict(opts, VAR_1, &local_err);",
"if (local_err) {",
"error_propagate(VAR_3, local_err);",
"VAR_6 = -EINVAL;",
"goto fail;",
"}",
"s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS,\n(s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS));",
"s->discard_passthrough[QCOW2_DISCARD_NEVER] = false;",
"s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true;",
"s->discard_passthrough[QCOW2_DISCARD_REQUEST] =\nqemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST,\nVAR_2 & BDRV_O_UNMAP);",
"s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] =\nqemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true);",
"s->discard_passthrough[QCOW2_DISCARD_OTHER] =\nqemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false);",
"VAR_7 = qemu_opt_get(opts, \"overlap-check\") ?: \"cached\";",
"if (!strcmp(VAR_7, \"none\")) {",
"VAR_8 = 0;",
"} else if (!strcmp(VAR_7, \"constant\")) {",
"VAR_8 = QCOW2_OL_CONSTANT;",
"} else if (!strcmp(VAR_7, \"cached\")) {",
"VAR_8 = QCOW2_OL_CACHED;",
"} else if (!strcmp(VAR_7, \"all\")) {",
"VAR_8 = QCOW2_OL_ALL;",
"} else {",
"error_setg(VAR_3, \"Unsupported value '%s' for qcow2 option \"\n\"'overlap-check'. Allowed are either of the following: \"\n\"none, constant, cached, all\", VAR_7);",
"qemu_opts_del(opts);",
"VAR_6 = -EINVAL;",
"goto fail;",
"}",
"s->overlap_check = 0;",
"for (VAR_5 = 0; VAR_5 < QCOW2_OL_MAX_BITNR; VAR_5++) {",
"s->overlap_check |=\nqemu_opt_get_bool(opts, overlap_bool_option_names[VAR_5],\nVAR_8 & (1 << VAR_5)) << VAR_5;",
"}",
"qemu_opts_del(opts);",
"if (s->use_lazy_refcounts && s->qcow_version < 3) {",
"error_setg(VAR_3, \"Lazy refcounts require a qcow2 image with at least \"\n\"qemu 1.1 compatibility level\");",
"VAR_6 = -EINVAL;",
"goto fail;",
"}",
"#ifdef DEBUG_ALLOC\n{",
"BdrvCheckResult result = {0};",
"qcow2_check_refcounts(VAR_0, &result, 0);",
"}",
"#endif\nreturn VAR_6;",
"fail:\ng_free(s->unknown_header_fields);",
"cleanup_unknown_header_ext(VAR_0);",
"qcow2_free_snapshots(VAR_0);",
"qcow2_refcount_close(VAR_0);",
"g_free(s->l1_table);",
"s->l1_table = NULL;",
"if (s->l2_table_cache) {",
"qcow2_cache_destroy(VAR_0, s->l2_table_cache);",
"}",
"if (s->refcount_block_cache) {",
"qcow2_cache_destroy(VAR_0, s->refcount_block_cache);",
"}",
"g_free(s->cluster_cache);",
"qemu_vfree(s->cluster_data);",
"return VAR_6;",
"}"
] | [
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,
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,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
127,
129
],
[
131
],
[
133,
135
],
[
137
],
[
139
],
[
141
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171,
173
],
[
175,
177,
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
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
],
[
289
],
[
291
],
[
297
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335,
337
],
[
339,
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
363
],
[
365
],
[
369
],
[
373,
375
],
[
377
],
[
379
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
395
],
[
397
],
[
403,
405
],
[
407
],
[
409
],
[
411
],
[
413
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429,
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
441
],
[
443
],
[
447
],
[
449
],
[
451
],
[
453
],
[
455
],
[
461
],
[
463
],
[
465
],
[
467
],
[
469
],
[
471
],
[
473
],
[
475
],
[
481
],
[
487,
489
],
[
491
],
[
495
],
[
497
],
[
499
],
[
501
],
[
503
],
[
505
],
[
511
],
[
513
],
[
515
],
[
517
],
[
519
],
[
521
],
[
523
],
[
527,
529
],
[
533
],
[
535
],
[
537,
539,
541
],
[
543,
545
],
[
547,
549
],
[
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
563
],
[
565
],
[
567
],
[
569
],
[
571
],
[
573,
575,
577
],
[
579
],
[
581
],
[
583
],
[
585
],
[
589
],
[
591
],
[
597,
599,
601
],
[
603
],
[
607
],
[
611
],
[
613,
615
],
[
617
],
[
619
],
[
621
],
[
625,
627
],
[
629
],
[
631
],
[
633
],
[
635,
637
],
[
641,
643
],
[
645
],
[
647
],
[
649
],
[
651
],
[
655
],
[
657
],
[
659
],
[
661
],
[
663
],
[
665
],
[
667
],
[
669
],
[
671
],
[
673
],
[
675
]
] |
3,220 | static void replay_save_event(Event *event, int checkpoint)
{
if (replay_mode != REPLAY_MODE_PLAY) {
/* put the event into the file */
replay_put_event(EVENT_ASYNC);
replay_put_byte(checkpoint);
replay_put_byte(event->event_kind);
/* save event-specific data */
switch (event->event_kind) {
case REPLAY_ASYNC_EVENT_BH:
replay_put_qword(event->id);
break;
case REPLAY_ASYNC_EVENT_INPUT:
replay_save_input_event(event->opaque);
break;
case REPLAY_ASYNC_EVENT_INPUT_SYNC:
break;
case REPLAY_ASYNC_EVENT_CHAR_READ:
replay_event_char_read_save(event->opaque);
break;
default:
error_report("Unknown ID %d of replay event", read_event_kind);
exit(1);
}
}
}
| true | qemu | 95b4aed5fd0bec00e2c3f754c86fec5ba7a83a20 | static void replay_save_event(Event *event, int checkpoint)
{
if (replay_mode != REPLAY_MODE_PLAY) {
replay_put_event(EVENT_ASYNC);
replay_put_byte(checkpoint);
replay_put_byte(event->event_kind);
switch (event->event_kind) {
case REPLAY_ASYNC_EVENT_BH:
replay_put_qword(event->id);
break;
case REPLAY_ASYNC_EVENT_INPUT:
replay_save_input_event(event->opaque);
break;
case REPLAY_ASYNC_EVENT_INPUT_SYNC:
break;
case REPLAY_ASYNC_EVENT_CHAR_READ:
replay_event_char_read_save(event->opaque);
break;
default:
error_report("Unknown ID %d of replay event", read_event_kind);
exit(1);
}
}
}
| {
"code": [
" error_report(\"Unknown ID %d of replay event\", read_event_kind);"
],
"line_no": [
45
]
} | static void FUNC_0(Event *VAR_0, int VAR_1)
{
if (replay_mode != REPLAY_MODE_PLAY) {
replay_put_event(EVENT_ASYNC);
replay_put_byte(VAR_1);
replay_put_byte(VAR_0->event_kind);
switch (VAR_0->event_kind) {
case REPLAY_ASYNC_EVENT_BH:
replay_put_qword(VAR_0->id);
break;
case REPLAY_ASYNC_EVENT_INPUT:
replay_save_input_event(VAR_0->opaque);
break;
case REPLAY_ASYNC_EVENT_INPUT_SYNC:
break;
case REPLAY_ASYNC_EVENT_CHAR_READ:
replay_event_char_read_save(VAR_0->opaque);
break;
default:
error_report("Unknown ID %d of replay VAR_0", read_event_kind);
exit(1);
}
}
}
| [
"static void FUNC_0(Event *VAR_0, int VAR_1)\n{",
"if (replay_mode != REPLAY_MODE_PLAY) {",
"replay_put_event(EVENT_ASYNC);",
"replay_put_byte(VAR_1);",
"replay_put_byte(VAR_0->event_kind);",
"switch (VAR_0->event_kind) {",
"case REPLAY_ASYNC_EVENT_BH:\nreplay_put_qword(VAR_0->id);",
"break;",
"case REPLAY_ASYNC_EVENT_INPUT:\nreplay_save_input_event(VAR_0->opaque);",
"break;",
"case REPLAY_ASYNC_EVENT_INPUT_SYNC:\nbreak;",
"case REPLAY_ASYNC_EVENT_CHAR_READ:\nreplay_event_char_read_save(VAR_0->opaque);",
"break;",
"default:\nerror_report(\"Unknown ID %d of replay VAR_0\", read_event_kind);",
"exit(1);",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
19
],
[
21,
23
],
[
25
],
[
27,
29
],
[
31
],
[
33,
35
],
[
37,
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
]
] |
3,221 | int avformat_alloc_output_context2(AVFormatContext **avctx, AVOutputFormat *oformat,
const char *format, const char *filename)
{
AVFormatContext *s = avformat_alloc_context();
int ret = 0;
*avctx = NULL;
if (!s)
goto nomem;
if (!oformat) {
if (format) {
oformat = av_guess_format(format, NULL, NULL);
if (!oformat) {
av_log(s, AV_LOG_ERROR, "Requested output format '%s' is not a suitable output format\n", format);
ret = AVERROR(EINVAL);
goto error;
}
} else {
oformat = av_guess_format(NULL, filename, NULL);
if (!oformat) {
ret = AVERROR(EINVAL);
av_log(s, AV_LOG_ERROR, "Unable to find a suitable output format for '%s'\n",
filename);
goto error;
}
}
}
s->oformat = oformat;
if (s->oformat->priv_data_size > 0) {
s->priv_data = av_mallocz(s->oformat->priv_data_size);
if (!s->priv_data)
goto nomem;
if (s->oformat->priv_class) {
*(const AVClass**)s->priv_data= s->oformat->priv_class;
av_opt_set_defaults(s->priv_data);
}
} else
s->priv_data = NULL;
if (filename)
av_strlcpy(s->filename, filename, sizeof(s->filename));
*avctx = s;
return 0;
nomem:
av_log(s, AV_LOG_ERROR, "Out of memory\n");
ret = AVERROR(ENOMEM);
error:
avformat_free_context(s);
return ret;
}
| false | FFmpeg | ea3672b7d67c432724bdbc8de0221f869b6a04c6 | int avformat_alloc_output_context2(AVFormatContext **avctx, AVOutputFormat *oformat,
const char *format, const char *filename)
{
AVFormatContext *s = avformat_alloc_context();
int ret = 0;
*avctx = NULL;
if (!s)
goto nomem;
if (!oformat) {
if (format) {
oformat = av_guess_format(format, NULL, NULL);
if (!oformat) {
av_log(s, AV_LOG_ERROR, "Requested output format '%s' is not a suitable output format\n", format);
ret = AVERROR(EINVAL);
goto error;
}
} else {
oformat = av_guess_format(NULL, filename, NULL);
if (!oformat) {
ret = AVERROR(EINVAL);
av_log(s, AV_LOG_ERROR, "Unable to find a suitable output format for '%s'\n",
filename);
goto error;
}
}
}
s->oformat = oformat;
if (s->oformat->priv_data_size > 0) {
s->priv_data = av_mallocz(s->oformat->priv_data_size);
if (!s->priv_data)
goto nomem;
if (s->oformat->priv_class) {
*(const AVClass**)s->priv_data= s->oformat->priv_class;
av_opt_set_defaults(s->priv_data);
}
} else
s->priv_data = NULL;
if (filename)
av_strlcpy(s->filename, filename, sizeof(s->filename));
*avctx = s;
return 0;
nomem:
av_log(s, AV_LOG_ERROR, "Out of memory\n");
ret = AVERROR(ENOMEM);
error:
avformat_free_context(s);
return ret;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVFormatContext **VAR_0, AVOutputFormat *VAR_1,
const char *VAR_2, const char *VAR_3)
{
AVFormatContext *s = avformat_alloc_context();
int VAR_4 = 0;
*VAR_0 = NULL;
if (!s)
goto nomem;
if (!VAR_1) {
if (VAR_2) {
VAR_1 = av_guess_format(VAR_2, NULL, NULL);
if (!VAR_1) {
av_log(s, AV_LOG_ERROR, "Requested output VAR_2 '%s' is not a suitable output VAR_2\n", VAR_2);
VAR_4 = AVERROR(EINVAL);
goto error;
}
} else {
VAR_1 = av_guess_format(NULL, VAR_3, NULL);
if (!VAR_1) {
VAR_4 = AVERROR(EINVAL);
av_log(s, AV_LOG_ERROR, "Unable to find a suitable output VAR_2 for '%s'\n",
VAR_3);
goto error;
}
}
}
s->VAR_1 = VAR_1;
if (s->VAR_1->priv_data_size > 0) {
s->priv_data = av_mallocz(s->VAR_1->priv_data_size);
if (!s->priv_data)
goto nomem;
if (s->VAR_1->priv_class) {
*(const AVClass**)s->priv_data= s->VAR_1->priv_class;
av_opt_set_defaults(s->priv_data);
}
} else
s->priv_data = NULL;
if (VAR_3)
av_strlcpy(s->VAR_3, VAR_3, sizeof(s->VAR_3));
*VAR_0 = s;
return 0;
nomem:
av_log(s, AV_LOG_ERROR, "Out of memory\n");
VAR_4 = AVERROR(ENOMEM);
error:
avformat_free_context(s);
return VAR_4;
}
| [
"int FUNC_0(AVFormatContext **VAR_0, AVOutputFormat *VAR_1,\nconst char *VAR_2, const char *VAR_3)\n{",
"AVFormatContext *s = avformat_alloc_context();",
"int VAR_4 = 0;",
"*VAR_0 = NULL;",
"if (!s)\ngoto nomem;",
"if (!VAR_1) {",
"if (VAR_2) {",
"VAR_1 = av_guess_format(VAR_2, NULL, NULL);",
"if (!VAR_1) {",
"av_log(s, AV_LOG_ERROR, \"Requested output VAR_2 '%s' is not a suitable output VAR_2\\n\", VAR_2);",
"VAR_4 = AVERROR(EINVAL);",
"goto error;",
"}",
"} else {",
"VAR_1 = av_guess_format(NULL, VAR_3, NULL);",
"if (!VAR_1) {",
"VAR_4 = AVERROR(EINVAL);",
"av_log(s, AV_LOG_ERROR, \"Unable to find a suitable output VAR_2 for '%s'\\n\",\nVAR_3);",
"goto error;",
"}",
"}",
"}",
"s->VAR_1 = VAR_1;",
"if (s->VAR_1->priv_data_size > 0) {",
"s->priv_data = av_mallocz(s->VAR_1->priv_data_size);",
"if (!s->priv_data)\ngoto nomem;",
"if (s->VAR_1->priv_class) {",
"*(const AVClass**)s->priv_data= s->VAR_1->priv_class;",
"av_opt_set_defaults(s->priv_data);",
"}",
"} else",
"s->priv_data = NULL;",
"if (VAR_3)\nav_strlcpy(s->VAR_3, VAR_3, sizeof(s->VAR_3));",
"*VAR_0 = s;",
"return 0;",
"nomem:\nav_log(s, AV_LOG_ERROR, \"Out of memory\\n\");",
"VAR_4 = AVERROR(ENOMEM);",
"error:\navformat_free_context(s);",
"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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83,
85
],
[
87
],
[
89
],
[
91,
93
],
[
95
],
[
97,
99
],
[
101
],
[
103
]
] |
3,222 | static av_cold int gif_encode_init(AVCodecContext *avctx)
{
GIFContext *s = avctx->priv_data;
if (avctx->width > 65535 || avctx->height > 65535) {
av_log(avctx, AV_LOG_ERROR, "GIF does not support resolutions above 65535x65535\n");
return AVERROR(EINVAL);
}
#if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
s->transparent_index = -1;
s->lzw = av_mallocz(ff_lzw_encode_state_size);
s->buf = av_malloc(avctx->width*avctx->height*2);
s->tmpl = av_malloc(avctx->width);
if (!s->tmpl || !s->buf || !s->lzw)
return AVERROR(ENOMEM);
if (avpriv_set_systematic_pal2(s->palette, avctx->pix_fmt) < 0)
av_assert0(avctx->pix_fmt == AV_PIX_FMT_PAL8);
return 0;
}
| false | FFmpeg | 03d83ba34b2070878909eae18dfac0f519503777 | static av_cold int gif_encode_init(AVCodecContext *avctx)
{
GIFContext *s = avctx->priv_data;
if (avctx->width > 65535 || avctx->height > 65535) {
av_log(avctx, AV_LOG_ERROR, "GIF does not support resolutions above 65535x65535\n");
return AVERROR(EINVAL);
}
#if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
s->transparent_index = -1;
s->lzw = av_mallocz(ff_lzw_encode_state_size);
s->buf = av_malloc(avctx->width*avctx->height*2);
s->tmpl = av_malloc(avctx->width);
if (!s->tmpl || !s->buf || !s->lzw)
return AVERROR(ENOMEM);
if (avpriv_set_systematic_pal2(s->palette, avctx->pix_fmt) < 0)
av_assert0(avctx->pix_fmt == AV_PIX_FMT_PAL8);
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
GIFContext *s = avctx->priv_data;
if (avctx->width > 65535 || avctx->height > 65535) {
av_log(avctx, AV_LOG_ERROR, "GIF does not support resolutions above 65535x65535\n");
return AVERROR(EINVAL);
}
#if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
s->transparent_index = -1;
s->lzw = av_mallocz(ff_lzw_encode_state_size);
s->buf = av_malloc(avctx->width*avctx->height*2);
s->tmpl = av_malloc(avctx->width);
if (!s->tmpl || !s->buf || !s->lzw)
return AVERROR(ENOMEM);
if (avpriv_set_systematic_pal2(s->palette, avctx->pix_fmt) < 0)
av_assert0(avctx->pix_fmt == AV_PIX_FMT_PAL8);
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"GIFContext *s = avctx->priv_data;",
"if (avctx->width > 65535 || avctx->height > 65535) {",
"av_log(avctx, AV_LOG_ERROR, \"GIF does not support resolutions above 65535x65535\\n\");",
"return AVERROR(EINVAL);",
"}",
"#if FF_API_CODED_FRAME\nFF_DISABLE_DEPRECATION_WARNINGS\navctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;",
"avctx->coded_frame->key_frame = 1;",
"FF_ENABLE_DEPRECATION_WARNINGS\n#endif\ns->transparent_index = -1;",
"s->lzw = av_mallocz(ff_lzw_encode_state_size);",
"s->buf = av_malloc(avctx->width*avctx->height*2);",
"s->tmpl = av_malloc(avctx->width);",
"if (!s->tmpl || !s->buf || !s->lzw)\nreturn AVERROR(ENOMEM);",
"if (avpriv_set_systematic_pal2(s->palette, avctx->pix_fmt) < 0)\nav_assert0(avctx->pix_fmt == AV_PIX_FMT_PAL8);",
"return 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,
31
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
47,
49
],
[
53
],
[
55
]
] |
3,223 | static int mpeg4_decode_sprite_trajectory(Mpeg4DecContext *ctx, GetBitContext *gb)
{
MpegEncContext *s = &ctx->m;
int a = 2 << s->sprite_warping_accuracy;
int rho = 3 - s->sprite_warping_accuracy;
int r = 16 / a;
int alpha = 0;
int beta = 0;
int w = s->width;
int h = s->height;
int min_ab, i, w2, h2, w3, h3;
int sprite_ref[4][2];
int virtual_ref[2][2];
// only true for rectangle shapes
const int vop_ref[4][2] = { { 0, 0 }, { s->width, 0 },
{ 0, s->height }, { s->width, s->height } };
int d[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } };
if (w <= 0 || h <= 0)
return AVERROR_INVALIDDATA;
for (i = 0; i < ctx->num_sprite_warping_points; i++) {
int length;
int x = 0, y = 0;
length = get_vlc2(gb, sprite_trajectory.table, SPRITE_TRAJ_VLC_BITS, 3);
if (length)
x = get_xbits(gb, length);
if (!(ctx->divx_version == 500 && ctx->divx_build == 413))
skip_bits1(gb); /* marker bit */
length = get_vlc2(gb, sprite_trajectory.table, SPRITE_TRAJ_VLC_BITS, 3);
if (length)
y = get_xbits(gb, length);
skip_bits1(gb); /* marker bit */
ctx->sprite_traj[i][0] = d[i][0] = x;
ctx->sprite_traj[i][1] = d[i][1] = y;
}
for (; i < 4; i++)
ctx->sprite_traj[i][0] = ctx->sprite_traj[i][1] = 0;
while ((1 << alpha) < w)
alpha++;
while ((1 << beta) < h)
beta++; /* typo in the mpeg4 std for the definition of w' and h' */
w2 = 1 << alpha;
h2 = 1 << beta;
// Note, the 4th point isn't used for GMC
if (ctx->divx_version == 500 && ctx->divx_build == 413) {
sprite_ref[0][0] = a * vop_ref[0][0] + d[0][0];
sprite_ref[0][1] = a * vop_ref[0][1] + d[0][1];
sprite_ref[1][0] = a * vop_ref[1][0] + d[0][0] + d[1][0];
sprite_ref[1][1] = a * vop_ref[1][1] + d[0][1] + d[1][1];
sprite_ref[2][0] = a * vop_ref[2][0] + d[0][0] + d[2][0];
sprite_ref[2][1] = a * vop_ref[2][1] + d[0][1] + d[2][1];
} else {
sprite_ref[0][0] = (a >> 1) * (2 * vop_ref[0][0] + d[0][0]);
sprite_ref[0][1] = (a >> 1) * (2 * vop_ref[0][1] + d[0][1]);
sprite_ref[1][0] = (a >> 1) * (2 * vop_ref[1][0] + d[0][0] + d[1][0]);
sprite_ref[1][1] = (a >> 1) * (2 * vop_ref[1][1] + d[0][1] + d[1][1]);
sprite_ref[2][0] = (a >> 1) * (2 * vop_ref[2][0] + d[0][0] + d[2][0]);
sprite_ref[2][1] = (a >> 1) * (2 * vop_ref[2][1] + d[0][1] + d[2][1]);
}
/* sprite_ref[3][0] = (a >> 1) * (2 * vop_ref[3][0] + d[0][0] + d[1][0] + d[2][0] + d[3][0]);
* sprite_ref[3][1] = (a >> 1) * (2 * vop_ref[3][1] + d[0][1] + d[1][1] + d[2][1] + d[3][1]); */
/* this is mostly identical to the mpeg4 std (and is totally unreadable
* because of that...). Perhaps it should be reordered to be more readable.
* The idea behind this virtual_ref mess is to be able to use shifts later
* per pixel instead of divides so the distance between points is converted
* from w&h based to w2&h2 based which are of the 2^x form. */
virtual_ref[0][0] = 16 * (vop_ref[0][0] + w2) +
ROUNDED_DIV(((w - w2) *
(r * sprite_ref[0][0] - 16 * vop_ref[0][0]) +
w2 * (r * sprite_ref[1][0] - 16 * vop_ref[1][0])), w);
virtual_ref[0][1] = 16 * vop_ref[0][1] +
ROUNDED_DIV(((w - w2) *
(r * sprite_ref[0][1] - 16 * vop_ref[0][1]) +
w2 * (r * sprite_ref[1][1] - 16 * vop_ref[1][1])), w);
virtual_ref[1][0] = 16 * vop_ref[0][0] +
ROUNDED_DIV(((h - h2) * (r * sprite_ref[0][0] - 16 * vop_ref[0][0]) +
h2 * (r * sprite_ref[2][0] - 16 * vop_ref[2][0])), h);
virtual_ref[1][1] = 16 * (vop_ref[0][1] + h2) +
ROUNDED_DIV(((h - h2) * (r * sprite_ref[0][1] - 16 * vop_ref[0][1]) +
h2 * (r * sprite_ref[2][1] - 16 * vop_ref[2][1])), h);
switch (ctx->num_sprite_warping_points) {
case 0:
s->sprite_offset[0][0] =
s->sprite_offset[0][1] =
s->sprite_offset[1][0] =
s->sprite_offset[1][1] = 0;
s->sprite_delta[0][0] = a;
s->sprite_delta[0][1] =
s->sprite_delta[1][0] = 0;
s->sprite_delta[1][1] = a;
ctx->sprite_shift[0] =
ctx->sprite_shift[1] = 0;
break;
case 1: // GMC only
s->sprite_offset[0][0] = sprite_ref[0][0] - a * vop_ref[0][0];
s->sprite_offset[0][1] = sprite_ref[0][1] - a * vop_ref[0][1];
s->sprite_offset[1][0] = ((sprite_ref[0][0] >> 1) | (sprite_ref[0][0] & 1)) -
a * (vop_ref[0][0] / 2);
s->sprite_offset[1][1] = ((sprite_ref[0][1] >> 1) | (sprite_ref[0][1] & 1)) -
a * (vop_ref[0][1] / 2);
s->sprite_delta[0][0] = a;
s->sprite_delta[0][1] =
s->sprite_delta[1][0] = 0;
s->sprite_delta[1][1] = a;
ctx->sprite_shift[0] =
ctx->sprite_shift[1] = 0;
break;
case 2:
s->sprite_offset[0][0] = (sprite_ref[0][0] << (alpha + rho)) +
(-r * sprite_ref[0][0] + virtual_ref[0][0]) *
(-vop_ref[0][0]) +
(r * sprite_ref[0][1] - virtual_ref[0][1]) *
(-vop_ref[0][1]) + (1 << (alpha + rho - 1));
s->sprite_offset[0][1] = (sprite_ref[0][1] << (alpha + rho)) +
(-r * sprite_ref[0][1] + virtual_ref[0][1]) *
(-vop_ref[0][0]) +
(-r * sprite_ref[0][0] + virtual_ref[0][0]) *
(-vop_ref[0][1]) + (1 << (alpha + rho - 1));
s->sprite_offset[1][0] = ((-r * sprite_ref[0][0] + virtual_ref[0][0]) *
(-2 * vop_ref[0][0] + 1) +
(r * sprite_ref[0][1] - virtual_ref[0][1]) *
(-2 * vop_ref[0][1] + 1) + 2 * w2 * r *
sprite_ref[0][0] - 16 * w2 + (1 << (alpha + rho + 1)));
s->sprite_offset[1][1] = ((-r * sprite_ref[0][1] + virtual_ref[0][1]) *
(-2 * vop_ref[0][0] + 1) +
(-r * sprite_ref[0][0] + virtual_ref[0][0]) *
(-2 * vop_ref[0][1] + 1) + 2 * w2 * r *
sprite_ref[0][1] - 16 * w2 + (1 << (alpha + rho + 1)));
s->sprite_delta[0][0] = (-r * sprite_ref[0][0] + virtual_ref[0][0]);
s->sprite_delta[0][1] = (+r * sprite_ref[0][1] - virtual_ref[0][1]);
s->sprite_delta[1][0] = (-r * sprite_ref[0][1] + virtual_ref[0][1]);
s->sprite_delta[1][1] = (-r * sprite_ref[0][0] + virtual_ref[0][0]);
ctx->sprite_shift[0] = alpha + rho;
ctx->sprite_shift[1] = alpha + rho + 2;
break;
case 3:
min_ab = FFMIN(alpha, beta);
w3 = w2 >> min_ab;
h3 = h2 >> min_ab;
s->sprite_offset[0][0] = (sprite_ref[0][0] << (alpha + beta + rho - min_ab)) +
(-r * sprite_ref[0][0] + virtual_ref[0][0]) *
h3 * (-vop_ref[0][0]) +
(-r * sprite_ref[0][0] + virtual_ref[1][0]) *
w3 * (-vop_ref[0][1]) +
(1 << (alpha + beta + rho - min_ab - 1));
s->sprite_offset[0][1] = (sprite_ref[0][1] << (alpha + beta + rho - min_ab)) +
(-r * sprite_ref[0][1] + virtual_ref[0][1]) *
h3 * (-vop_ref[0][0]) +
(-r * sprite_ref[0][1] + virtual_ref[1][1]) *
w3 * (-vop_ref[0][1]) +
(1 << (alpha + beta + rho - min_ab - 1));
s->sprite_offset[1][0] = (-r * sprite_ref[0][0] + virtual_ref[0][0]) *
h3 * (-2 * vop_ref[0][0] + 1) +
(-r * sprite_ref[0][0] + virtual_ref[1][0]) *
w3 * (-2 * vop_ref[0][1] + 1) + 2 * w2 * h3 *
r * sprite_ref[0][0] - 16 * w2 * h3 +
(1 << (alpha + beta + rho - min_ab + 1));
s->sprite_offset[1][1] = (-r * sprite_ref[0][1] + virtual_ref[0][1]) *
h3 * (-2 * vop_ref[0][0] + 1) +
(-r * sprite_ref[0][1] + virtual_ref[1][1]) *
w3 * (-2 * vop_ref[0][1] + 1) + 2 * w2 * h3 *
r * sprite_ref[0][1] - 16 * w2 * h3 +
(1 << (alpha + beta + rho - min_ab + 1));
s->sprite_delta[0][0] = (-r * sprite_ref[0][0] + virtual_ref[0][0]) * h3;
s->sprite_delta[0][1] = (-r * sprite_ref[0][0] + virtual_ref[1][0]) * w3;
s->sprite_delta[1][0] = (-r * sprite_ref[0][1] + virtual_ref[0][1]) * h3;
s->sprite_delta[1][1] = (-r * sprite_ref[0][1] + virtual_ref[1][1]) * w3;
ctx->sprite_shift[0] = alpha + beta + rho - min_ab;
ctx->sprite_shift[1] = alpha + beta + rho - min_ab + 2;
break;
}
/* try to simplify the situation */
if (s->sprite_delta[0][0] == a << ctx->sprite_shift[0] &&
s->sprite_delta[0][1] == 0 &&
s->sprite_delta[1][0] == 0 &&
s->sprite_delta[1][1] == a << ctx->sprite_shift[0]) {
s->sprite_offset[0][0] >>= ctx->sprite_shift[0];
s->sprite_offset[0][1] >>= ctx->sprite_shift[0];
s->sprite_offset[1][0] >>= ctx->sprite_shift[1];
s->sprite_offset[1][1] >>= ctx->sprite_shift[1];
s->sprite_delta[0][0] = a;
s->sprite_delta[0][1] = 0;
s->sprite_delta[1][0] = 0;
s->sprite_delta[1][1] = a;
ctx->sprite_shift[0] = 0;
ctx->sprite_shift[1] = 0;
s->real_sprite_warping_points = 1;
} else {
int shift_y = 16 - ctx->sprite_shift[0];
int shift_c = 16 - ctx->sprite_shift[1];
for (i = 0; i < 2; i++) {
s->sprite_offset[0][i] <<= shift_y;
s->sprite_offset[1][i] <<= shift_c;
s->sprite_delta[0][i] <<= shift_y;
s->sprite_delta[1][i] <<= shift_y;
ctx->sprite_shift[i] = 16;
}
s->real_sprite_warping_points = ctx->num_sprite_warping_points;
}
return 0;
}
| false | FFmpeg | 9a0f60a0f89a7a71839dfa9def5a26f2037aed62 | static int mpeg4_decode_sprite_trajectory(Mpeg4DecContext *ctx, GetBitContext *gb)
{
MpegEncContext *s = &ctx->m;
int a = 2 << s->sprite_warping_accuracy;
int rho = 3 - s->sprite_warping_accuracy;
int r = 16 / a;
int alpha = 0;
int beta = 0;
int w = s->width;
int h = s->height;
int min_ab, i, w2, h2, w3, h3;
int sprite_ref[4][2];
int virtual_ref[2][2];
const int vop_ref[4][2] = { { 0, 0 }, { s->width, 0 },
{ 0, s->height }, { s->width, s->height } };
int d[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } };
if (w <= 0 || h <= 0)
return AVERROR_INVALIDDATA;
for (i = 0; i < ctx->num_sprite_warping_points; i++) {
int length;
int x = 0, y = 0;
length = get_vlc2(gb, sprite_trajectory.table, SPRITE_TRAJ_VLC_BITS, 3);
if (length)
x = get_xbits(gb, length);
if (!(ctx->divx_version == 500 && ctx->divx_build == 413))
skip_bits1(gb);
length = get_vlc2(gb, sprite_trajectory.table, SPRITE_TRAJ_VLC_BITS, 3);
if (length)
y = get_xbits(gb, length);
skip_bits1(gb);
ctx->sprite_traj[i][0] = d[i][0] = x;
ctx->sprite_traj[i][1] = d[i][1] = y;
}
for (; i < 4; i++)
ctx->sprite_traj[i][0] = ctx->sprite_traj[i][1] = 0;
while ((1 << alpha) < w)
alpha++;
while ((1 << beta) < h)
beta++;
w2 = 1 << alpha;
h2 = 1 << beta;
if (ctx->divx_version == 500 && ctx->divx_build == 413) {
sprite_ref[0][0] = a * vop_ref[0][0] + d[0][0];
sprite_ref[0][1] = a * vop_ref[0][1] + d[0][1];
sprite_ref[1][0] = a * vop_ref[1][0] + d[0][0] + d[1][0];
sprite_ref[1][1] = a * vop_ref[1][1] + d[0][1] + d[1][1];
sprite_ref[2][0] = a * vop_ref[2][0] + d[0][0] + d[2][0];
sprite_ref[2][1] = a * vop_ref[2][1] + d[0][1] + d[2][1];
} else {
sprite_ref[0][0] = (a >> 1) * (2 * vop_ref[0][0] + d[0][0]);
sprite_ref[0][1] = (a >> 1) * (2 * vop_ref[0][1] + d[0][1]);
sprite_ref[1][0] = (a >> 1) * (2 * vop_ref[1][0] + d[0][0] + d[1][0]);
sprite_ref[1][1] = (a >> 1) * (2 * vop_ref[1][1] + d[0][1] + d[1][1]);
sprite_ref[2][0] = (a >> 1) * (2 * vop_ref[2][0] + d[0][0] + d[2][0]);
sprite_ref[2][1] = (a >> 1) * (2 * vop_ref[2][1] + d[0][1] + d[2][1]);
}
virtual_ref[0][0] = 16 * (vop_ref[0][0] + w2) +
ROUNDED_DIV(((w - w2) *
(r * sprite_ref[0][0] - 16 * vop_ref[0][0]) +
w2 * (r * sprite_ref[1][0] - 16 * vop_ref[1][0])), w);
virtual_ref[0][1] = 16 * vop_ref[0][1] +
ROUNDED_DIV(((w - w2) *
(r * sprite_ref[0][1] - 16 * vop_ref[0][1]) +
w2 * (r * sprite_ref[1][1] - 16 * vop_ref[1][1])), w);
virtual_ref[1][0] = 16 * vop_ref[0][0] +
ROUNDED_DIV(((h - h2) * (r * sprite_ref[0][0] - 16 * vop_ref[0][0]) +
h2 * (r * sprite_ref[2][0] - 16 * vop_ref[2][0])), h);
virtual_ref[1][1] = 16 * (vop_ref[0][1] + h2) +
ROUNDED_DIV(((h - h2) * (r * sprite_ref[0][1] - 16 * vop_ref[0][1]) +
h2 * (r * sprite_ref[2][1] - 16 * vop_ref[2][1])), h);
switch (ctx->num_sprite_warping_points) {
case 0:
s->sprite_offset[0][0] =
s->sprite_offset[0][1] =
s->sprite_offset[1][0] =
s->sprite_offset[1][1] = 0;
s->sprite_delta[0][0] = a;
s->sprite_delta[0][1] =
s->sprite_delta[1][0] = 0;
s->sprite_delta[1][1] = a;
ctx->sprite_shift[0] =
ctx->sprite_shift[1] = 0;
break;
case 1:
s->sprite_offset[0][0] = sprite_ref[0][0] - a * vop_ref[0][0];
s->sprite_offset[0][1] = sprite_ref[0][1] - a * vop_ref[0][1];
s->sprite_offset[1][0] = ((sprite_ref[0][0] >> 1) | (sprite_ref[0][0] & 1)) -
a * (vop_ref[0][0] / 2);
s->sprite_offset[1][1] = ((sprite_ref[0][1] >> 1) | (sprite_ref[0][1] & 1)) -
a * (vop_ref[0][1] / 2);
s->sprite_delta[0][0] = a;
s->sprite_delta[0][1] =
s->sprite_delta[1][0] = 0;
s->sprite_delta[1][1] = a;
ctx->sprite_shift[0] =
ctx->sprite_shift[1] = 0;
break;
case 2:
s->sprite_offset[0][0] = (sprite_ref[0][0] << (alpha + rho)) +
(-r * sprite_ref[0][0] + virtual_ref[0][0]) *
(-vop_ref[0][0]) +
(r * sprite_ref[0][1] - virtual_ref[0][1]) *
(-vop_ref[0][1]) + (1 << (alpha + rho - 1));
s->sprite_offset[0][1] = (sprite_ref[0][1] << (alpha + rho)) +
(-r * sprite_ref[0][1] + virtual_ref[0][1]) *
(-vop_ref[0][0]) +
(-r * sprite_ref[0][0] + virtual_ref[0][0]) *
(-vop_ref[0][1]) + (1 << (alpha + rho - 1));
s->sprite_offset[1][0] = ((-r * sprite_ref[0][0] + virtual_ref[0][0]) *
(-2 * vop_ref[0][0] + 1) +
(r * sprite_ref[0][1] - virtual_ref[0][1]) *
(-2 * vop_ref[0][1] + 1) + 2 * w2 * r *
sprite_ref[0][0] - 16 * w2 + (1 << (alpha + rho + 1)));
s->sprite_offset[1][1] = ((-r * sprite_ref[0][1] + virtual_ref[0][1]) *
(-2 * vop_ref[0][0] + 1) +
(-r * sprite_ref[0][0] + virtual_ref[0][0]) *
(-2 * vop_ref[0][1] + 1) + 2 * w2 * r *
sprite_ref[0][1] - 16 * w2 + (1 << (alpha + rho + 1)));
s->sprite_delta[0][0] = (-r * sprite_ref[0][0] + virtual_ref[0][0]);
s->sprite_delta[0][1] = (+r * sprite_ref[0][1] - virtual_ref[0][1]);
s->sprite_delta[1][0] = (-r * sprite_ref[0][1] + virtual_ref[0][1]);
s->sprite_delta[1][1] = (-r * sprite_ref[0][0] + virtual_ref[0][0]);
ctx->sprite_shift[0] = alpha + rho;
ctx->sprite_shift[1] = alpha + rho + 2;
break;
case 3:
min_ab = FFMIN(alpha, beta);
w3 = w2 >> min_ab;
h3 = h2 >> min_ab;
s->sprite_offset[0][0] = (sprite_ref[0][0] << (alpha + beta + rho - min_ab)) +
(-r * sprite_ref[0][0] + virtual_ref[0][0]) *
h3 * (-vop_ref[0][0]) +
(-r * sprite_ref[0][0] + virtual_ref[1][0]) *
w3 * (-vop_ref[0][1]) +
(1 << (alpha + beta + rho - min_ab - 1));
s->sprite_offset[0][1] = (sprite_ref[0][1] << (alpha + beta + rho - min_ab)) +
(-r * sprite_ref[0][1] + virtual_ref[0][1]) *
h3 * (-vop_ref[0][0]) +
(-r * sprite_ref[0][1] + virtual_ref[1][1]) *
w3 * (-vop_ref[0][1]) +
(1 << (alpha + beta + rho - min_ab - 1));
s->sprite_offset[1][0] = (-r * sprite_ref[0][0] + virtual_ref[0][0]) *
h3 * (-2 * vop_ref[0][0] + 1) +
(-r * sprite_ref[0][0] + virtual_ref[1][0]) *
w3 * (-2 * vop_ref[0][1] + 1) + 2 * w2 * h3 *
r * sprite_ref[0][0] - 16 * w2 * h3 +
(1 << (alpha + beta + rho - min_ab + 1));
s->sprite_offset[1][1] = (-r * sprite_ref[0][1] + virtual_ref[0][1]) *
h3 * (-2 * vop_ref[0][0] + 1) +
(-r * sprite_ref[0][1] + virtual_ref[1][1]) *
w3 * (-2 * vop_ref[0][1] + 1) + 2 * w2 * h3 *
r * sprite_ref[0][1] - 16 * w2 * h3 +
(1 << (alpha + beta + rho - min_ab + 1));
s->sprite_delta[0][0] = (-r * sprite_ref[0][0] + virtual_ref[0][0]) * h3;
s->sprite_delta[0][1] = (-r * sprite_ref[0][0] + virtual_ref[1][0]) * w3;
s->sprite_delta[1][0] = (-r * sprite_ref[0][1] + virtual_ref[0][1]) * h3;
s->sprite_delta[1][1] = (-r * sprite_ref[0][1] + virtual_ref[1][1]) * w3;
ctx->sprite_shift[0] = alpha + beta + rho - min_ab;
ctx->sprite_shift[1] = alpha + beta + rho - min_ab + 2;
break;
}
if (s->sprite_delta[0][0] == a << ctx->sprite_shift[0] &&
s->sprite_delta[0][1] == 0 &&
s->sprite_delta[1][0] == 0 &&
s->sprite_delta[1][1] == a << ctx->sprite_shift[0]) {
s->sprite_offset[0][0] >>= ctx->sprite_shift[0];
s->sprite_offset[0][1] >>= ctx->sprite_shift[0];
s->sprite_offset[1][0] >>= ctx->sprite_shift[1];
s->sprite_offset[1][1] >>= ctx->sprite_shift[1];
s->sprite_delta[0][0] = a;
s->sprite_delta[0][1] = 0;
s->sprite_delta[1][0] = 0;
s->sprite_delta[1][1] = a;
ctx->sprite_shift[0] = 0;
ctx->sprite_shift[1] = 0;
s->real_sprite_warping_points = 1;
} else {
int shift_y = 16 - ctx->sprite_shift[0];
int shift_c = 16 - ctx->sprite_shift[1];
for (i = 0; i < 2; i++) {
s->sprite_offset[0][i] <<= shift_y;
s->sprite_offset[1][i] <<= shift_c;
s->sprite_delta[0][i] <<= shift_y;
s->sprite_delta[1][i] <<= shift_y;
ctx->sprite_shift[i] = 16;
}
s->real_sprite_warping_points = ctx->num_sprite_warping_points;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(Mpeg4DecContext *VAR_0, GetBitContext *VAR_1)
{
MpegEncContext *s = &VAR_0->m;
int VAR_2 = 2 << s->sprite_warping_accuracy;
int VAR_3 = 3 - s->sprite_warping_accuracy;
int VAR_4 = 16 / VAR_2;
int VAR_5 = 0;
int VAR_6 = 0;
int VAR_7 = s->width;
int VAR_8 = s->height;
int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14;
int VAR_15[4][2];
int VAR_16[2][2];
const int VAR_17[4][2] = { { 0, 0 }, { s->width, 0 },
{ 0, s->height }, { s->width, s->height } };
int VAR_18[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } };
if (VAR_7 <= 0 || VAR_8 <= 0)
return AVERROR_INVALIDDATA;
for (VAR_10 = 0; VAR_10 < VAR_0->num_sprite_warping_points; VAR_10++) {
int length;
int x = 0, y = 0;
length = get_vlc2(VAR_1, sprite_trajectory.table, SPRITE_TRAJ_VLC_BITS, 3);
if (length)
x = get_xbits(VAR_1, length);
if (!(VAR_0->divx_version == 500 && VAR_0->divx_build == 413))
skip_bits1(VAR_1);
length = get_vlc2(VAR_1, sprite_trajectory.table, SPRITE_TRAJ_VLC_BITS, 3);
if (length)
y = get_xbits(VAR_1, length);
skip_bits1(VAR_1);
VAR_0->sprite_traj[VAR_10][0] = VAR_18[VAR_10][0] = x;
VAR_0->sprite_traj[VAR_10][1] = VAR_18[VAR_10][1] = y;
}
for (; VAR_10 < 4; VAR_10++)
VAR_0->sprite_traj[VAR_10][0] = VAR_0->sprite_traj[VAR_10][1] = 0;
while ((1 << VAR_5) < VAR_7)
VAR_5++;
while ((1 << VAR_6) < VAR_8)
VAR_6++;
VAR_11 = 1 << VAR_5;
VAR_12 = 1 << VAR_6;
if (VAR_0->divx_version == 500 && VAR_0->divx_build == 413) {
VAR_15[0][0] = VAR_2 * VAR_17[0][0] + VAR_18[0][0];
VAR_15[0][1] = VAR_2 * VAR_17[0][1] + VAR_18[0][1];
VAR_15[1][0] = VAR_2 * VAR_17[1][0] + VAR_18[0][0] + VAR_18[1][0];
VAR_15[1][1] = VAR_2 * VAR_17[1][1] + VAR_18[0][1] + VAR_18[1][1];
VAR_15[2][0] = VAR_2 * VAR_17[2][0] + VAR_18[0][0] + VAR_18[2][0];
VAR_15[2][1] = VAR_2 * VAR_17[2][1] + VAR_18[0][1] + VAR_18[2][1];
} else {
VAR_15[0][0] = (VAR_2 >> 1) * (2 * VAR_17[0][0] + VAR_18[0][0]);
VAR_15[0][1] = (VAR_2 >> 1) * (2 * VAR_17[0][1] + VAR_18[0][1]);
VAR_15[1][0] = (VAR_2 >> 1) * (2 * VAR_17[1][0] + VAR_18[0][0] + VAR_18[1][0]);
VAR_15[1][1] = (VAR_2 >> 1) * (2 * VAR_17[1][1] + VAR_18[0][1] + VAR_18[1][1]);
VAR_15[2][0] = (VAR_2 >> 1) * (2 * VAR_17[2][0] + VAR_18[0][0] + VAR_18[2][0]);
VAR_15[2][1] = (VAR_2 >> 1) * (2 * VAR_17[2][1] + VAR_18[0][1] + VAR_18[2][1]);
}
VAR_16[0][0] = 16 * (VAR_17[0][0] + VAR_11) +
ROUNDED_DIV(((VAR_7 - VAR_11) *
(VAR_4 * VAR_15[0][0] - 16 * VAR_17[0][0]) +
VAR_11 * (VAR_4 * VAR_15[1][0] - 16 * VAR_17[1][0])), VAR_7);
VAR_16[0][1] = 16 * VAR_17[0][1] +
ROUNDED_DIV(((VAR_7 - VAR_11) *
(VAR_4 * VAR_15[0][1] - 16 * VAR_17[0][1]) +
VAR_11 * (VAR_4 * VAR_15[1][1] - 16 * VAR_17[1][1])), VAR_7);
VAR_16[1][0] = 16 * VAR_17[0][0] +
ROUNDED_DIV(((VAR_8 - VAR_12) * (VAR_4 * VAR_15[0][0] - 16 * VAR_17[0][0]) +
VAR_12 * (VAR_4 * VAR_15[2][0] - 16 * VAR_17[2][0])), VAR_8);
VAR_16[1][1] = 16 * (VAR_17[0][1] + VAR_12) +
ROUNDED_DIV(((VAR_8 - VAR_12) * (VAR_4 * VAR_15[0][1] - 16 * VAR_17[0][1]) +
VAR_12 * (VAR_4 * VAR_15[2][1] - 16 * VAR_17[2][1])), VAR_8);
switch (VAR_0->num_sprite_warping_points) {
case 0:
s->sprite_offset[0][0] =
s->sprite_offset[0][1] =
s->sprite_offset[1][0] =
s->sprite_offset[1][1] = 0;
s->sprite_delta[0][0] = VAR_2;
s->sprite_delta[0][1] =
s->sprite_delta[1][0] = 0;
s->sprite_delta[1][1] = VAR_2;
VAR_0->sprite_shift[0] =
VAR_0->sprite_shift[1] = 0;
break;
case 1:
s->sprite_offset[0][0] = VAR_15[0][0] - VAR_2 * VAR_17[0][0];
s->sprite_offset[0][1] = VAR_15[0][1] - VAR_2 * VAR_17[0][1];
s->sprite_offset[1][0] = ((VAR_15[0][0] >> 1) | (VAR_15[0][0] & 1)) -
VAR_2 * (VAR_17[0][0] / 2);
s->sprite_offset[1][1] = ((VAR_15[0][1] >> 1) | (VAR_15[0][1] & 1)) -
VAR_2 * (VAR_17[0][1] / 2);
s->sprite_delta[0][0] = VAR_2;
s->sprite_delta[0][1] =
s->sprite_delta[1][0] = 0;
s->sprite_delta[1][1] = VAR_2;
VAR_0->sprite_shift[0] =
VAR_0->sprite_shift[1] = 0;
break;
case 2:
s->sprite_offset[0][0] = (VAR_15[0][0] << (VAR_5 + VAR_3)) +
(-VAR_4 * VAR_15[0][0] + VAR_16[0][0]) *
(-VAR_17[0][0]) +
(VAR_4 * VAR_15[0][1] - VAR_16[0][1]) *
(-VAR_17[0][1]) + (1 << (VAR_5 + VAR_3 - 1));
s->sprite_offset[0][1] = (VAR_15[0][1] << (VAR_5 + VAR_3)) +
(-VAR_4 * VAR_15[0][1] + VAR_16[0][1]) *
(-VAR_17[0][0]) +
(-VAR_4 * VAR_15[0][0] + VAR_16[0][0]) *
(-VAR_17[0][1]) + (1 << (VAR_5 + VAR_3 - 1));
s->sprite_offset[1][0] = ((-VAR_4 * VAR_15[0][0] + VAR_16[0][0]) *
(-2 * VAR_17[0][0] + 1) +
(VAR_4 * VAR_15[0][1] - VAR_16[0][1]) *
(-2 * VAR_17[0][1] + 1) + 2 * VAR_11 * VAR_4 *
VAR_15[0][0] - 16 * VAR_11 + (1 << (VAR_5 + VAR_3 + 1)));
s->sprite_offset[1][1] = ((-VAR_4 * VAR_15[0][1] + VAR_16[0][1]) *
(-2 * VAR_17[0][0] + 1) +
(-VAR_4 * VAR_15[0][0] + VAR_16[0][0]) *
(-2 * VAR_17[0][1] + 1) + 2 * VAR_11 * VAR_4 *
VAR_15[0][1] - 16 * VAR_11 + (1 << (VAR_5 + VAR_3 + 1)));
s->sprite_delta[0][0] = (-VAR_4 * VAR_15[0][0] + VAR_16[0][0]);
s->sprite_delta[0][1] = (+VAR_4 * VAR_15[0][1] - VAR_16[0][1]);
s->sprite_delta[1][0] = (-VAR_4 * VAR_15[0][1] + VAR_16[0][1]);
s->sprite_delta[1][1] = (-VAR_4 * VAR_15[0][0] + VAR_16[0][0]);
VAR_0->sprite_shift[0] = VAR_5 + VAR_3;
VAR_0->sprite_shift[1] = VAR_5 + VAR_3 + 2;
break;
case 3:
VAR_9 = FFMIN(VAR_5, VAR_6);
VAR_13 = VAR_11 >> VAR_9;
VAR_14 = VAR_12 >> VAR_9;
s->sprite_offset[0][0] = (VAR_15[0][0] << (VAR_5 + VAR_6 + VAR_3 - VAR_9)) +
(-VAR_4 * VAR_15[0][0] + VAR_16[0][0]) *
VAR_14 * (-VAR_17[0][0]) +
(-VAR_4 * VAR_15[0][0] + VAR_16[1][0]) *
VAR_13 * (-VAR_17[0][1]) +
(1 << (VAR_5 + VAR_6 + VAR_3 - VAR_9 - 1));
s->sprite_offset[0][1] = (VAR_15[0][1] << (VAR_5 + VAR_6 + VAR_3 - VAR_9)) +
(-VAR_4 * VAR_15[0][1] + VAR_16[0][1]) *
VAR_14 * (-VAR_17[0][0]) +
(-VAR_4 * VAR_15[0][1] + VAR_16[1][1]) *
VAR_13 * (-VAR_17[0][1]) +
(1 << (VAR_5 + VAR_6 + VAR_3 - VAR_9 - 1));
s->sprite_offset[1][0] = (-VAR_4 * VAR_15[0][0] + VAR_16[0][0]) *
VAR_14 * (-2 * VAR_17[0][0] + 1) +
(-VAR_4 * VAR_15[0][0] + VAR_16[1][0]) *
VAR_13 * (-2 * VAR_17[0][1] + 1) + 2 * VAR_11 * VAR_14 *
VAR_4 * VAR_15[0][0] - 16 * VAR_11 * VAR_14 +
(1 << (VAR_5 + VAR_6 + VAR_3 - VAR_9 + 1));
s->sprite_offset[1][1] = (-VAR_4 * VAR_15[0][1] + VAR_16[0][1]) *
VAR_14 * (-2 * VAR_17[0][0] + 1) +
(-VAR_4 * VAR_15[0][1] + VAR_16[1][1]) *
VAR_13 * (-2 * VAR_17[0][1] + 1) + 2 * VAR_11 * VAR_14 *
VAR_4 * VAR_15[0][1] - 16 * VAR_11 * VAR_14 +
(1 << (VAR_5 + VAR_6 + VAR_3 - VAR_9 + 1));
s->sprite_delta[0][0] = (-VAR_4 * VAR_15[0][0] + VAR_16[0][0]) * VAR_14;
s->sprite_delta[0][1] = (-VAR_4 * VAR_15[0][0] + VAR_16[1][0]) * VAR_13;
s->sprite_delta[1][0] = (-VAR_4 * VAR_15[0][1] + VAR_16[0][1]) * VAR_14;
s->sprite_delta[1][1] = (-VAR_4 * VAR_15[0][1] + VAR_16[1][1]) * VAR_13;
VAR_0->sprite_shift[0] = VAR_5 + VAR_6 + VAR_3 - VAR_9;
VAR_0->sprite_shift[1] = VAR_5 + VAR_6 + VAR_3 - VAR_9 + 2;
break;
}
if (s->sprite_delta[0][0] == VAR_2 << VAR_0->sprite_shift[0] &&
s->sprite_delta[0][1] == 0 &&
s->sprite_delta[1][0] == 0 &&
s->sprite_delta[1][1] == VAR_2 << VAR_0->sprite_shift[0]) {
s->sprite_offset[0][0] >>= VAR_0->sprite_shift[0];
s->sprite_offset[0][1] >>= VAR_0->sprite_shift[0];
s->sprite_offset[1][0] >>= VAR_0->sprite_shift[1];
s->sprite_offset[1][1] >>= VAR_0->sprite_shift[1];
s->sprite_delta[0][0] = VAR_2;
s->sprite_delta[0][1] = 0;
s->sprite_delta[1][0] = 0;
s->sprite_delta[1][1] = VAR_2;
VAR_0->sprite_shift[0] = 0;
VAR_0->sprite_shift[1] = 0;
s->real_sprite_warping_points = 1;
} else {
int VAR_19 = 16 - VAR_0->sprite_shift[0];
int VAR_20 = 16 - VAR_0->sprite_shift[1];
for (VAR_10 = 0; VAR_10 < 2; VAR_10++) {
s->sprite_offset[0][VAR_10] <<= VAR_19;
s->sprite_offset[1][VAR_10] <<= VAR_20;
s->sprite_delta[0][VAR_10] <<= VAR_19;
s->sprite_delta[1][VAR_10] <<= VAR_19;
VAR_0->sprite_shift[VAR_10] = 16;
}
s->real_sprite_warping_points = VAR_0->num_sprite_warping_points;
}
return 0;
}
| [
"static int FUNC_0(Mpeg4DecContext *VAR_0, GetBitContext *VAR_1)\n{",
"MpegEncContext *s = &VAR_0->m;",
"int VAR_2 = 2 << s->sprite_warping_accuracy;",
"int VAR_3 = 3 - s->sprite_warping_accuracy;",
"int VAR_4 = 16 / VAR_2;",
"int VAR_5 = 0;",
"int VAR_6 = 0;",
"int VAR_7 = s->width;",
"int VAR_8 = s->height;",
"int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14;",
"int VAR_15[4][2];",
"int VAR_16[2][2];",
"const int VAR_17[4][2] = { { 0, 0 }, { s->width, 0 },",
"{ 0, s->height }, { s->width, s->height } };",
"int VAR_18[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } };",
"if (VAR_7 <= 0 || VAR_8 <= 0)\nreturn AVERROR_INVALIDDATA;",
"for (VAR_10 = 0; VAR_10 < VAR_0->num_sprite_warping_points; VAR_10++) {",
"int length;",
"int x = 0, y = 0;",
"length = get_vlc2(VAR_1, sprite_trajectory.table, SPRITE_TRAJ_VLC_BITS, 3);",
"if (length)\nx = get_xbits(VAR_1, length);",
"if (!(VAR_0->divx_version == 500 && VAR_0->divx_build == 413))\nskip_bits1(VAR_1);",
"length = get_vlc2(VAR_1, sprite_trajectory.table, SPRITE_TRAJ_VLC_BITS, 3);",
"if (length)\ny = get_xbits(VAR_1, length);",
"skip_bits1(VAR_1);",
"VAR_0->sprite_traj[VAR_10][0] = VAR_18[VAR_10][0] = x;",
"VAR_0->sprite_traj[VAR_10][1] = VAR_18[VAR_10][1] = y;",
"}",
"for (; VAR_10 < 4; VAR_10++)",
"VAR_0->sprite_traj[VAR_10][0] = VAR_0->sprite_traj[VAR_10][1] = 0;",
"while ((1 << VAR_5) < VAR_7)\nVAR_5++;",
"while ((1 << VAR_6) < VAR_8)\nVAR_6++;",
"VAR_11 = 1 << VAR_5;",
"VAR_12 = 1 << VAR_6;",
"if (VAR_0->divx_version == 500 && VAR_0->divx_build == 413) {",
"VAR_15[0][0] = VAR_2 * VAR_17[0][0] + VAR_18[0][0];",
"VAR_15[0][1] = VAR_2 * VAR_17[0][1] + VAR_18[0][1];",
"VAR_15[1][0] = VAR_2 * VAR_17[1][0] + VAR_18[0][0] + VAR_18[1][0];",
"VAR_15[1][1] = VAR_2 * VAR_17[1][1] + VAR_18[0][1] + VAR_18[1][1];",
"VAR_15[2][0] = VAR_2 * VAR_17[2][0] + VAR_18[0][0] + VAR_18[2][0];",
"VAR_15[2][1] = VAR_2 * VAR_17[2][1] + VAR_18[0][1] + VAR_18[2][1];",
"} else {",
"VAR_15[0][0] = (VAR_2 >> 1) * (2 * VAR_17[0][0] + VAR_18[0][0]);",
"VAR_15[0][1] = (VAR_2 >> 1) * (2 * VAR_17[0][1] + VAR_18[0][1]);",
"VAR_15[1][0] = (VAR_2 >> 1) * (2 * VAR_17[1][0] + VAR_18[0][0] + VAR_18[1][0]);",
"VAR_15[1][1] = (VAR_2 >> 1) * (2 * VAR_17[1][1] + VAR_18[0][1] + VAR_18[1][1]);",
"VAR_15[2][0] = (VAR_2 >> 1) * (2 * VAR_17[2][0] + VAR_18[0][0] + VAR_18[2][0]);",
"VAR_15[2][1] = (VAR_2 >> 1) * (2 * VAR_17[2][1] + VAR_18[0][1] + VAR_18[2][1]);",
"}",
"VAR_16[0][0] = 16 * (VAR_17[0][0] + VAR_11) +\nROUNDED_DIV(((VAR_7 - VAR_11) *\n(VAR_4 * VAR_15[0][0] - 16 * VAR_17[0][0]) +\nVAR_11 * (VAR_4 * VAR_15[1][0] - 16 * VAR_17[1][0])), VAR_7);",
"VAR_16[0][1] = 16 * VAR_17[0][1] +\nROUNDED_DIV(((VAR_7 - VAR_11) *\n(VAR_4 * VAR_15[0][1] - 16 * VAR_17[0][1]) +\nVAR_11 * (VAR_4 * VAR_15[1][1] - 16 * VAR_17[1][1])), VAR_7);",
"VAR_16[1][0] = 16 * VAR_17[0][0] +\nROUNDED_DIV(((VAR_8 - VAR_12) * (VAR_4 * VAR_15[0][0] - 16 * VAR_17[0][0]) +\nVAR_12 * (VAR_4 * VAR_15[2][0] - 16 * VAR_17[2][0])), VAR_8);",
"VAR_16[1][1] = 16 * (VAR_17[0][1] + VAR_12) +\nROUNDED_DIV(((VAR_8 - VAR_12) * (VAR_4 * VAR_15[0][1] - 16 * VAR_17[0][1]) +\nVAR_12 * (VAR_4 * VAR_15[2][1] - 16 * VAR_17[2][1])), VAR_8);",
"switch (VAR_0->num_sprite_warping_points) {",
"case 0:\ns->sprite_offset[0][0] =\ns->sprite_offset[0][1] =\ns->sprite_offset[1][0] =\ns->sprite_offset[1][1] = 0;",
"s->sprite_delta[0][0] = VAR_2;",
"s->sprite_delta[0][1] =\ns->sprite_delta[1][0] = 0;",
"s->sprite_delta[1][1] = VAR_2;",
"VAR_0->sprite_shift[0] =\nVAR_0->sprite_shift[1] = 0;",
"break;",
"case 1:\ns->sprite_offset[0][0] = VAR_15[0][0] - VAR_2 * VAR_17[0][0];",
"s->sprite_offset[0][1] = VAR_15[0][1] - VAR_2 * VAR_17[0][1];",
"s->sprite_offset[1][0] = ((VAR_15[0][0] >> 1) | (VAR_15[0][0] & 1)) -\nVAR_2 * (VAR_17[0][0] / 2);",
"s->sprite_offset[1][1] = ((VAR_15[0][1] >> 1) | (VAR_15[0][1] & 1)) -\nVAR_2 * (VAR_17[0][1] / 2);",
"s->sprite_delta[0][0] = VAR_2;",
"s->sprite_delta[0][1] =\ns->sprite_delta[1][0] = 0;",
"s->sprite_delta[1][1] = VAR_2;",
"VAR_0->sprite_shift[0] =\nVAR_0->sprite_shift[1] = 0;",
"break;",
"case 2:\ns->sprite_offset[0][0] = (VAR_15[0][0] << (VAR_5 + VAR_3)) +\n(-VAR_4 * VAR_15[0][0] + VAR_16[0][0]) *\n(-VAR_17[0][0]) +\n(VAR_4 * VAR_15[0][1] - VAR_16[0][1]) *\n(-VAR_17[0][1]) + (1 << (VAR_5 + VAR_3 - 1));",
"s->sprite_offset[0][1] = (VAR_15[0][1] << (VAR_5 + VAR_3)) +\n(-VAR_4 * VAR_15[0][1] + VAR_16[0][1]) *\n(-VAR_17[0][0]) +\n(-VAR_4 * VAR_15[0][0] + VAR_16[0][0]) *\n(-VAR_17[0][1]) + (1 << (VAR_5 + VAR_3 - 1));",
"s->sprite_offset[1][0] = ((-VAR_4 * VAR_15[0][0] + VAR_16[0][0]) *\n(-2 * VAR_17[0][0] + 1) +\n(VAR_4 * VAR_15[0][1] - VAR_16[0][1]) *\n(-2 * VAR_17[0][1] + 1) + 2 * VAR_11 * VAR_4 *\nVAR_15[0][0] - 16 * VAR_11 + (1 << (VAR_5 + VAR_3 + 1)));",
"s->sprite_offset[1][1] = ((-VAR_4 * VAR_15[0][1] + VAR_16[0][1]) *\n(-2 * VAR_17[0][0] + 1) +\n(-VAR_4 * VAR_15[0][0] + VAR_16[0][0]) *\n(-2 * VAR_17[0][1] + 1) + 2 * VAR_11 * VAR_4 *\nVAR_15[0][1] - 16 * VAR_11 + (1 << (VAR_5 + VAR_3 + 1)));",
"s->sprite_delta[0][0] = (-VAR_4 * VAR_15[0][0] + VAR_16[0][0]);",
"s->sprite_delta[0][1] = (+VAR_4 * VAR_15[0][1] - VAR_16[0][1]);",
"s->sprite_delta[1][0] = (-VAR_4 * VAR_15[0][1] + VAR_16[0][1]);",
"s->sprite_delta[1][1] = (-VAR_4 * VAR_15[0][0] + VAR_16[0][0]);",
"VAR_0->sprite_shift[0] = VAR_5 + VAR_3;",
"VAR_0->sprite_shift[1] = VAR_5 + VAR_3 + 2;",
"break;",
"case 3:\nVAR_9 = FFMIN(VAR_5, VAR_6);",
"VAR_13 = VAR_11 >> VAR_9;",
"VAR_14 = VAR_12 >> VAR_9;",
"s->sprite_offset[0][0] = (VAR_15[0][0] << (VAR_5 + VAR_6 + VAR_3 - VAR_9)) +\n(-VAR_4 * VAR_15[0][0] + VAR_16[0][0]) *\nVAR_14 * (-VAR_17[0][0]) +\n(-VAR_4 * VAR_15[0][0] + VAR_16[1][0]) *\nVAR_13 * (-VAR_17[0][1]) +\n(1 << (VAR_5 + VAR_6 + VAR_3 - VAR_9 - 1));",
"s->sprite_offset[0][1] = (VAR_15[0][1] << (VAR_5 + VAR_6 + VAR_3 - VAR_9)) +\n(-VAR_4 * VAR_15[0][1] + VAR_16[0][1]) *\nVAR_14 * (-VAR_17[0][0]) +\n(-VAR_4 * VAR_15[0][1] + VAR_16[1][1]) *\nVAR_13 * (-VAR_17[0][1]) +\n(1 << (VAR_5 + VAR_6 + VAR_3 - VAR_9 - 1));",
"s->sprite_offset[1][0] = (-VAR_4 * VAR_15[0][0] + VAR_16[0][0]) *\nVAR_14 * (-2 * VAR_17[0][0] + 1) +\n(-VAR_4 * VAR_15[0][0] + VAR_16[1][0]) *\nVAR_13 * (-2 * VAR_17[0][1] + 1) + 2 * VAR_11 * VAR_14 *\nVAR_4 * VAR_15[0][0] - 16 * VAR_11 * VAR_14 +\n(1 << (VAR_5 + VAR_6 + VAR_3 - VAR_9 + 1));",
"s->sprite_offset[1][1] = (-VAR_4 * VAR_15[0][1] + VAR_16[0][1]) *\nVAR_14 * (-2 * VAR_17[0][0] + 1) +\n(-VAR_4 * VAR_15[0][1] + VAR_16[1][1]) *\nVAR_13 * (-2 * VAR_17[0][1] + 1) + 2 * VAR_11 * VAR_14 *\nVAR_4 * VAR_15[0][1] - 16 * VAR_11 * VAR_14 +\n(1 << (VAR_5 + VAR_6 + VAR_3 - VAR_9 + 1));",
"s->sprite_delta[0][0] = (-VAR_4 * VAR_15[0][0] + VAR_16[0][0]) * VAR_14;",
"s->sprite_delta[0][1] = (-VAR_4 * VAR_15[0][0] + VAR_16[1][0]) * VAR_13;",
"s->sprite_delta[1][0] = (-VAR_4 * VAR_15[0][1] + VAR_16[0][1]) * VAR_14;",
"s->sprite_delta[1][1] = (-VAR_4 * VAR_15[0][1] + VAR_16[1][1]) * VAR_13;",
"VAR_0->sprite_shift[0] = VAR_5 + VAR_6 + VAR_3 - VAR_9;",
"VAR_0->sprite_shift[1] = VAR_5 + VAR_6 + VAR_3 - VAR_9 + 2;",
"break;",
"}",
"if (s->sprite_delta[0][0] == VAR_2 << VAR_0->sprite_shift[0] &&\ns->sprite_delta[0][1] == 0 &&\ns->sprite_delta[1][0] == 0 &&\ns->sprite_delta[1][1] == VAR_2 << VAR_0->sprite_shift[0]) {",
"s->sprite_offset[0][0] >>= VAR_0->sprite_shift[0];",
"s->sprite_offset[0][1] >>= VAR_0->sprite_shift[0];",
"s->sprite_offset[1][0] >>= VAR_0->sprite_shift[1];",
"s->sprite_offset[1][1] >>= VAR_0->sprite_shift[1];",
"s->sprite_delta[0][0] = VAR_2;",
"s->sprite_delta[0][1] = 0;",
"s->sprite_delta[1][0] = 0;",
"s->sprite_delta[1][1] = VAR_2;",
"VAR_0->sprite_shift[0] = 0;",
"VAR_0->sprite_shift[1] = 0;",
"s->real_sprite_warping_points = 1;",
"} else {",
"int VAR_19 = 16 - VAR_0->sprite_shift[0];",
"int VAR_20 = 16 - VAR_0->sprite_shift[1];",
"for (VAR_10 = 0; VAR_10 < 2; VAR_10++) {",
"s->sprite_offset[0][VAR_10] <<= VAR_19;",
"s->sprite_offset[1][VAR_10] <<= VAR_20;",
"s->sprite_delta[0][VAR_10] <<= VAR_19;",
"s->sprite_delta[1][VAR_10] <<= VAR_19;",
"VAR_0->sprite_shift[VAR_10] = 16;",
"}",
"s->real_sprite_warping_points = VAR_0->num_sprite_warping_points;",
"}",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
31
],
[
33
],
[
35
],
[
39,
41
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55,
57
],
[
61,
63
],
[
67
],
[
69,
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89,
91
],
[
93,
95
],
[
97
],
[
99
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
151,
153,
155,
157
],
[
159,
161,
163,
165
],
[
167,
169,
171
],
[
173,
175,
177
],
[
181
],
[
183,
185,
187,
189,
191
],
[
193
],
[
195,
197
],
[
199
],
[
201,
203
],
[
205
],
[
207,
209
],
[
211
],
[
213,
215
],
[
217,
219
],
[
221
],
[
223,
225
],
[
227
],
[
229,
231
],
[
233
],
[
235,
237,
239,
241,
243,
245
],
[
247,
249,
251,
253,
255
],
[
257,
259,
261,
263,
265
],
[
267,
269,
271,
273,
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
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
],
[
361
],
[
363
],
[
365
],
[
369,
371,
373,
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
425
],
[
427
]
] |
3,225 | static int fchmodat_nofollow(int dirfd, const char *name, mode_t mode)
{
int fd, ret;
/* FIXME: this should be handled with fchmodat(AT_SYMLINK_NOFOLLOW).
* Unfortunately, the linux kernel doesn't implement it yet. As an
* alternative, let's open the file and use fchmod() instead. This
* may fail depending on the permissions of the file, but it is the
* best we can do to avoid TOCTTOU. We first try to open read-only
* in case name points to a directory. If that fails, we try write-only
* in case name doesn't point to a directory.
*/
fd = openat_file(dirfd, name, O_RDONLY, 0);
if (fd == -1) {
/* In case the file is writable-only and isn't a directory. */
if (errno == EACCES) {
fd = openat_file(dirfd, name, O_WRONLY, 0);
}
if (fd == -1 && errno == EISDIR) {
errno = EACCES;
}
}
if (fd == -1) {
return -1;
}
ret = fchmod(fd, mode);
close_preserve_errno(fd);
return ret;
}
| true | qemu | 4751fd5328dfcd4fe2f9055728a72a0e3ae56512 | static int fchmodat_nofollow(int dirfd, const char *name, mode_t mode)
{
int fd, ret;
fd = openat_file(dirfd, name, O_RDONLY, 0);
if (fd == -1) {
if (errno == EACCES) {
fd = openat_file(dirfd, name, O_WRONLY, 0);
}
if (fd == -1 && errno == EISDIR) {
errno = EACCES;
}
}
if (fd == -1) {
return -1;
}
ret = fchmod(fd, mode);
close_preserve_errno(fd);
return ret;
}
| {
"code": [
" fd = openat_file(dirfd, name, O_RDONLY, 0);"
],
"line_no": [
25
]
} | static int FUNC_0(int VAR_0, const char *VAR_1, mode_t VAR_2)
{
int VAR_3, VAR_4;
VAR_3 = openat_file(VAR_0, VAR_1, O_RDONLY, 0);
if (VAR_3 == -1) {
if (errno == EACCES) {
VAR_3 = openat_file(VAR_0, VAR_1, O_WRONLY, 0);
}
if (VAR_3 == -1 && errno == EISDIR) {
errno = EACCES;
}
}
if (VAR_3 == -1) {
return -1;
}
VAR_4 = fchmod(VAR_3, VAR_2);
close_preserve_errno(VAR_3);
return VAR_4;
}
| [
"static int FUNC_0(int VAR_0, const char *VAR_1, mode_t VAR_2)\n{",
"int VAR_3, VAR_4;",
"VAR_3 = openat_file(VAR_0, VAR_1, O_RDONLY, 0);",
"if (VAR_3 == -1) {",
"if (errno == EACCES) {",
"VAR_3 = openat_file(VAR_0, VAR_1, O_WRONLY, 0);",
"}",
"if (VAR_3 == -1 && errno == EISDIR) {",
"errno = EACCES;",
"}",
"}",
"if (VAR_3 == -1) {",
"return -1;",
"}",
"VAR_4 = fchmod(VAR_3, VAR_2);",
"close_preserve_errno(VAR_3);",
"return VAR_4;",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
]
] |
3,226 | void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
uint32_t event, uint32_t reason)
{
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
VirtIOSCSIReq *req;
VirtIOSCSIEvent *evt;
VirtIODevice *vdev = VIRTIO_DEVICE(s);
if (!(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) {
return;
}
if (s->dataplane_started) {
assert(s->ctx);
aio_context_acquire(s->ctx);
}
req = virtio_scsi_pop_req(s, vs->event_vq);
if (!req) {
s->events_dropped = true;
goto out;
}
if (s->events_dropped) {
event |= VIRTIO_SCSI_T_EVENTS_MISSED;
s->events_dropped = false;
}
if (virtio_scsi_parse_req(req, 0, sizeof(VirtIOSCSIEvent))) {
virtio_scsi_bad_req();
}
evt = &req->resp.event;
memset(evt, 0, sizeof(VirtIOSCSIEvent));
evt->event = virtio_tswap32(vdev, event);
evt->reason = virtio_tswap32(vdev, reason);
if (!dev) {
assert(event == VIRTIO_SCSI_T_EVENTS_MISSED);
} else {
evt->lun[0] = 1;
evt->lun[1] = dev->id;
/* Linux wants us to keep the same encoding we use for REPORT LUNS. */
if (dev->lun >= 256) {
evt->lun[2] = (dev->lun >> 8) | 0x40;
}
evt->lun[3] = dev->lun & 0xFF;
}
virtio_scsi_complete_req(req);
out:
if (s->dataplane_started) {
aio_context_release(s->ctx);
}
}
| true | qemu | 661e32fb3cb71c7e019daee375be4bb487b9917c | void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
uint32_t event, uint32_t reason)
{
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
VirtIOSCSIReq *req;
VirtIOSCSIEvent *evt;
VirtIODevice *vdev = VIRTIO_DEVICE(s);
if (!(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) {
return;
}
if (s->dataplane_started) {
assert(s->ctx);
aio_context_acquire(s->ctx);
}
req = virtio_scsi_pop_req(s, vs->event_vq);
if (!req) {
s->events_dropped = true;
goto out;
}
if (s->events_dropped) {
event |= VIRTIO_SCSI_T_EVENTS_MISSED;
s->events_dropped = false;
}
if (virtio_scsi_parse_req(req, 0, sizeof(VirtIOSCSIEvent))) {
virtio_scsi_bad_req();
}
evt = &req->resp.event;
memset(evt, 0, sizeof(VirtIOSCSIEvent));
evt->event = virtio_tswap32(vdev, event);
evt->reason = virtio_tswap32(vdev, reason);
if (!dev) {
assert(event == VIRTIO_SCSI_T_EVENTS_MISSED);
} else {
evt->lun[0] = 1;
evt->lun[1] = dev->id;
if (dev->lun >= 256) {
evt->lun[2] = (dev->lun >> 8) | 0x40;
}
evt->lun[3] = dev->lun & 0xFF;
}
virtio_scsi_complete_req(req);
out:
if (s->dataplane_started) {
aio_context_release(s->ctx);
}
}
| {
"code": [
" virtio_scsi_bad_req();",
" virtio_scsi_bad_req();"
],
"line_no": [
59,
59
]
} | void FUNC_0(VirtIOSCSI *VAR_0, SCSIDevice *VAR_1,
uint32_t VAR_2, uint32_t VAR_3)
{
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(VAR_0);
VirtIOSCSIReq *req;
VirtIOSCSIEvent *evt;
VirtIODevice *vdev = VIRTIO_DEVICE(VAR_0);
if (!(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) {
return;
}
if (VAR_0->dataplane_started) {
assert(VAR_0->ctx);
aio_context_acquire(VAR_0->ctx);
}
req = virtio_scsi_pop_req(VAR_0, vs->event_vq);
if (!req) {
VAR_0->events_dropped = true;
goto out;
}
if (VAR_0->events_dropped) {
VAR_2 |= VIRTIO_SCSI_T_EVENTS_MISSED;
VAR_0->events_dropped = false;
}
if (virtio_scsi_parse_req(req, 0, sizeof(VirtIOSCSIEvent))) {
virtio_scsi_bad_req();
}
evt = &req->resp.VAR_2;
memset(evt, 0, sizeof(VirtIOSCSIEvent));
evt->VAR_2 = virtio_tswap32(vdev, VAR_2);
evt->VAR_3 = virtio_tswap32(vdev, VAR_3);
if (!VAR_1) {
assert(VAR_2 == VIRTIO_SCSI_T_EVENTS_MISSED);
} else {
evt->lun[0] = 1;
evt->lun[1] = VAR_1->id;
if (VAR_1->lun >= 256) {
evt->lun[2] = (VAR_1->lun >> 8) | 0x40;
}
evt->lun[3] = VAR_1->lun & 0xFF;
}
virtio_scsi_complete_req(req);
out:
if (VAR_0->dataplane_started) {
aio_context_release(VAR_0->ctx);
}
}
| [
"void FUNC_0(VirtIOSCSI *VAR_0, SCSIDevice *VAR_1,\nuint32_t VAR_2, uint32_t VAR_3)\n{",
"VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(VAR_0);",
"VirtIOSCSIReq *req;",
"VirtIOSCSIEvent *evt;",
"VirtIODevice *vdev = VIRTIO_DEVICE(VAR_0);",
"if (!(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) {",
"return;",
"}",
"if (VAR_0->dataplane_started) {",
"assert(VAR_0->ctx);",
"aio_context_acquire(VAR_0->ctx);",
"}",
"req = virtio_scsi_pop_req(VAR_0, vs->event_vq);",
"if (!req) {",
"VAR_0->events_dropped = true;",
"goto out;",
"}",
"if (VAR_0->events_dropped) {",
"VAR_2 |= VIRTIO_SCSI_T_EVENTS_MISSED;",
"VAR_0->events_dropped = false;",
"}",
"if (virtio_scsi_parse_req(req, 0, sizeof(VirtIOSCSIEvent))) {",
"virtio_scsi_bad_req();",
"}",
"evt = &req->resp.VAR_2;",
"memset(evt, 0, sizeof(VirtIOSCSIEvent));",
"evt->VAR_2 = virtio_tswap32(vdev, VAR_2);",
"evt->VAR_3 = virtio_tswap32(vdev, VAR_3);",
"if (!VAR_1) {",
"assert(VAR_2 == VIRTIO_SCSI_T_EVENTS_MISSED);",
"} else {",
"evt->lun[0] = 1;",
"evt->lun[1] = VAR_1->id;",
"if (VAR_1->lun >= 256) {",
"evt->lun[2] = (VAR_1->lun >> 8) | 0x40;",
"}",
"evt->lun[3] = VAR_1->lun & 0xFF;",
"}",
"virtio_scsi_complete_req(req);",
"out:\nif (VAR_0->dataplane_started) {",
"aio_context_release(VAR_0->ctx);",
"}",
"}"
] | [
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99,
101
],
[
103
],
[
105
],
[
107
]
] |
3,229 | static int parse_int32(DeviceState *dev, Property *prop, const char *str)
{
int32_t *ptr = qdev_get_prop_ptr(dev, prop);
char *end;
*ptr = strtol(str, &end, 10);
if ((*end != '\0') || (end == str)) {
return -EINVAL;
}
return 0;
}
| true | qemu | 5cb9b56acfc0b50acf7ccd2d044ab4991c47fdde | static int parse_int32(DeviceState *dev, Property *prop, const char *str)
{
int32_t *ptr = qdev_get_prop_ptr(dev, prop);
char *end;
*ptr = strtol(str, &end, 10);
if ((*end != '\0') || (end == str)) {
return -EINVAL;
}
return 0;
}
| {
"code": [
" return -EINVAL;",
" return 0;",
" char *end;",
" if ((*end != '\\0') || (end == str)) {",
" return -EINVAL;",
" return 0;",
" char *end;",
" if ((*end != '\\0') || (end == str)) {",
" return -EINVAL;",
" return 0;",
" char *end;",
" if ((*end != '\\0') || (end == str)) {",
" return -EINVAL;",
" return 0;",
"static int parse_int32(DeviceState *dev, Property *prop, const char *str)",
" int32_t *ptr = qdev_get_prop_ptr(dev, prop);",
" char *end;",
" *ptr = strtol(str, &end, 10);",
" if ((*end != '\\0') || (end == str)) {",
" return -EINVAL;",
" return 0;",
" int32_t *ptr = qdev_get_prop_ptr(dev, prop);",
" char *end;",
" if ((*end != '\\0') || (end == str)) {",
" return -EINVAL;",
" return 0;",
" return -EINVAL;",
" return 0;"
],
"line_no": [
15,
21,
7,
13,
15,
21,
7,
13,
15,
21,
7,
13,
15,
21,
1,
5,
7,
11,
13,
15,
21,
5,
7,
13,
15,
21,
15,
21
]
} | static int FUNC_0(DeviceState *VAR_0, Property *VAR_1, const char *VAR_2)
{
int32_t *ptr = qdev_get_prop_ptr(VAR_0, VAR_1);
char *VAR_3;
*ptr = strtol(VAR_2, &VAR_3, 10);
if ((*VAR_3 != '\0') || (VAR_3 == VAR_2)) {
return -EINVAL;
}
return 0;
}
| [
"static int FUNC_0(DeviceState *VAR_0, Property *VAR_1, const char *VAR_2)\n{",
"int32_t *ptr = qdev_get_prop_ptr(VAR_0, VAR_1);",
"char *VAR_3;",
"*ptr = strtol(VAR_2, &VAR_3, 10);",
"if ((*VAR_3 != '\\0') || (VAR_3 == VAR_2)) {",
"return -EINVAL;",
"}",
"return 0;",
"}"
] | [
1,
1,
1,
1,
1,
1,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
]
] |
3,230 | static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
UtvideoContext *c = avctx->priv_data;
int i, j;
const uint8_t *plane_start[5];
int plane_size, max_slice_size = 0, slice_start, slice_end, slice_size;
int ret;
GetByteContext gb;
ThreadFrame frame = { .f = data };
if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)
return ret;
/* parse plane structure to get frame flags and validate slice offsets */
bytestream2_init(&gb, buf, buf_size);
for (i = 0; i < c->planes; i++) {
plane_start[i] = gb.buffer;
if (bytestream2_get_bytes_left(&gb) < 256 + 4 * c->slices) {
av_log(avctx, AV_LOG_ERROR, "Insufficient data for a plane\n");
return AVERROR_INVALIDDATA;
}
bytestream2_skipu(&gb, 256);
slice_start = 0;
slice_end = 0;
for (j = 0; j < c->slices; j++) {
slice_end = bytestream2_get_le32u(&gb);
slice_size = slice_end - slice_start;
if (slice_end < 0 || slice_size < 0 ||
bytestream2_get_bytes_left(&gb) < slice_end) {
av_log(avctx, AV_LOG_ERROR, "Incorrect slice size\n");
return AVERROR_INVALIDDATA;
}
slice_start = slice_end;
max_slice_size = FFMAX(max_slice_size, slice_size);
}
plane_size = slice_end;
bytestream2_skipu(&gb, plane_size);
}
plane_start[c->planes] = gb.buffer;
if (bytestream2_get_bytes_left(&gb) < c->frame_info_size) {
av_log(avctx, AV_LOG_ERROR, "Not enough data for frame information\n");
return AVERROR_INVALIDDATA;
}
c->frame_info = bytestream2_get_le32u(&gb);
av_log(avctx, AV_LOG_DEBUG, "frame information flags %"PRIX32"\n",
c->frame_info);
c->frame_pred = (c->frame_info >> 8) & 3;
if (c->frame_pred == PRED_GRADIENT) {
avpriv_request_sample(avctx, "Frame with gradient prediction");
return AVERROR_PATCHWELCOME;
}
av_fast_malloc(&c->slice_bits, &c->slice_bits_size,
max_slice_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!c->slice_bits) {
av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n");
return AVERROR(ENOMEM);
}
switch (c->avctx->pix_fmt) {
case AV_PIX_FMT_RGB24:
case AV_PIX_FMT_RGBA:
for (i = 0; i < c->planes; i++) {
ret = decode_plane(c, i, frame.f->data[0] + ff_ut_rgb_order[i],
c->planes, frame.f->linesize[0], avctx->width,
avctx->height, plane_start[i],
c->frame_pred == PRED_LEFT);
if (ret)
return ret;
if (c->frame_pred == PRED_MEDIAN) {
if (!c->interlaced) {
restore_median(frame.f->data[0] + ff_ut_rgb_order[i],
c->planes, frame.f->linesize[0], avctx->width,
avctx->height, c->slices, 0);
} else {
restore_median_il(frame.f->data[0] + ff_ut_rgb_order[i],
c->planes, frame.f->linesize[0],
avctx->width, avctx->height, c->slices,
0);
}
}
}
restore_rgb_planes(frame.f->data[0], c->planes, frame.f->linesize[0],
avctx->width, avctx->height);
break;
case AV_PIX_FMT_YUV420P:
for (i = 0; i < 3; i++) {
ret = decode_plane(c, i, frame.f->data[i], 1, frame.f->linesize[i],
avctx->width >> !!i, avctx->height >> !!i,
plane_start[i], c->frame_pred == PRED_LEFT);
if (ret)
return ret;
if (c->frame_pred == PRED_MEDIAN) {
if (!c->interlaced) {
restore_median(frame.f->data[i], 1, frame.f->linesize[i],
avctx->width >> !!i, avctx->height >> !!i,
c->slices, !i);
} else {
restore_median_il(frame.f->data[i], 1, frame.f->linesize[i],
avctx->width >> !!i,
avctx->height >> !!i,
c->slices, !i);
}
}
}
break;
case AV_PIX_FMT_YUV422P:
for (i = 0; i < 3; i++) {
ret = decode_plane(c, i, frame.f->data[i], 1, frame.f->linesize[i],
avctx->width >> !!i, avctx->height,
plane_start[i], c->frame_pred == PRED_LEFT);
if (ret)
return ret;
if (c->frame_pred == PRED_MEDIAN) {
if (!c->interlaced) {
restore_median(frame.f->data[i], 1, frame.f->linesize[i],
avctx->width >> !!i, avctx->height,
c->slices, 0);
} else {
restore_median_il(frame.f->data[i], 1, frame.f->linesize[i],
avctx->width >> !!i, avctx->height,
c->slices, 0);
}
}
}
break;
}
frame.f->key_frame = 1;
frame.f->pict_type = AV_PICTURE_TYPE_I;
frame.f->interlaced_frame = !!c->interlaced;
*got_frame = 1;
/* always report that the buffer was completely consumed */
return buf_size;
}
| true | FFmpeg | e86444b19d0b63c098298243fb20fd577f34cf34 | static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
UtvideoContext *c = avctx->priv_data;
int i, j;
const uint8_t *plane_start[5];
int plane_size, max_slice_size = 0, slice_start, slice_end, slice_size;
int ret;
GetByteContext gb;
ThreadFrame frame = { .f = data };
if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)
return ret;
bytestream2_init(&gb, buf, buf_size);
for (i = 0; i < c->planes; i++) {
plane_start[i] = gb.buffer;
if (bytestream2_get_bytes_left(&gb) < 256 + 4 * c->slices) {
av_log(avctx, AV_LOG_ERROR, "Insufficient data for a plane\n");
return AVERROR_INVALIDDATA;
}
bytestream2_skipu(&gb, 256);
slice_start = 0;
slice_end = 0;
for (j = 0; j < c->slices; j++) {
slice_end = bytestream2_get_le32u(&gb);
slice_size = slice_end - slice_start;
if (slice_end < 0 || slice_size < 0 ||
bytestream2_get_bytes_left(&gb) < slice_end) {
av_log(avctx, AV_LOG_ERROR, "Incorrect slice size\n");
return AVERROR_INVALIDDATA;
}
slice_start = slice_end;
max_slice_size = FFMAX(max_slice_size, slice_size);
}
plane_size = slice_end;
bytestream2_skipu(&gb, plane_size);
}
plane_start[c->planes] = gb.buffer;
if (bytestream2_get_bytes_left(&gb) < c->frame_info_size) {
av_log(avctx, AV_LOG_ERROR, "Not enough data for frame information\n");
return AVERROR_INVALIDDATA;
}
c->frame_info = bytestream2_get_le32u(&gb);
av_log(avctx, AV_LOG_DEBUG, "frame information flags %"PRIX32"\n",
c->frame_info);
c->frame_pred = (c->frame_info >> 8) & 3;
if (c->frame_pred == PRED_GRADIENT) {
avpriv_request_sample(avctx, "Frame with gradient prediction");
return AVERROR_PATCHWELCOME;
}
av_fast_malloc(&c->slice_bits, &c->slice_bits_size,
max_slice_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!c->slice_bits) {
av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n");
return AVERROR(ENOMEM);
}
switch (c->avctx->pix_fmt) {
case AV_PIX_FMT_RGB24:
case AV_PIX_FMT_RGBA:
for (i = 0; i < c->planes; i++) {
ret = decode_plane(c, i, frame.f->data[0] + ff_ut_rgb_order[i],
c->planes, frame.f->linesize[0], avctx->width,
avctx->height, plane_start[i],
c->frame_pred == PRED_LEFT);
if (ret)
return ret;
if (c->frame_pred == PRED_MEDIAN) {
if (!c->interlaced) {
restore_median(frame.f->data[0] + ff_ut_rgb_order[i],
c->planes, frame.f->linesize[0], avctx->width,
avctx->height, c->slices, 0);
} else {
restore_median_il(frame.f->data[0] + ff_ut_rgb_order[i],
c->planes, frame.f->linesize[0],
avctx->width, avctx->height, c->slices,
0);
}
}
}
restore_rgb_planes(frame.f->data[0], c->planes, frame.f->linesize[0],
avctx->width, avctx->height);
break;
case AV_PIX_FMT_YUV420P:
for (i = 0; i < 3; i++) {
ret = decode_plane(c, i, frame.f->data[i], 1, frame.f->linesize[i],
avctx->width >> !!i, avctx->height >> !!i,
plane_start[i], c->frame_pred == PRED_LEFT);
if (ret)
return ret;
if (c->frame_pred == PRED_MEDIAN) {
if (!c->interlaced) {
restore_median(frame.f->data[i], 1, frame.f->linesize[i],
avctx->width >> !!i, avctx->height >> !!i,
c->slices, !i);
} else {
restore_median_il(frame.f->data[i], 1, frame.f->linesize[i],
avctx->width >> !!i,
avctx->height >> !!i,
c->slices, !i);
}
}
}
break;
case AV_PIX_FMT_YUV422P:
for (i = 0; i < 3; i++) {
ret = decode_plane(c, i, frame.f->data[i], 1, frame.f->linesize[i],
avctx->width >> !!i, avctx->height,
plane_start[i], c->frame_pred == PRED_LEFT);
if (ret)
return ret;
if (c->frame_pred == PRED_MEDIAN) {
if (!c->interlaced) {
restore_median(frame.f->data[i], 1, frame.f->linesize[i],
avctx->width >> !!i, avctx->height,
c->slices, 0);
} else {
restore_median_il(frame.f->data[i], 1, frame.f->linesize[i],
avctx->width >> !!i, avctx->height,
c->slices, 0);
}
}
}
break;
}
frame.f->key_frame = 1;
frame.f->pict_type = AV_PICTURE_TYPE_I;
frame.f->interlaced_frame = !!c->interlaced;
*got_frame = 1;
return buf_size;
}
| {
"code": [
" slice_size = slice_end - slice_start;",
" if (slice_end < 0 || slice_size < 0 ||"
],
"line_no": [
59,
61
]
} | 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;
UtvideoContext *c = VAR_0->priv_data;
int VAR_6, VAR_7;
const uint8_t *VAR_8[5];
int VAR_9, VAR_10 = 0, VAR_11, VAR_12, VAR_13;
int VAR_14;
GetByteContext gb;
ThreadFrame frame = { .f = VAR_1 };
if ((VAR_14 = ff_thread_get_buffer(VAR_0, &frame, 0)) < 0)
return VAR_14;
bytestream2_init(&gb, VAR_4, VAR_5);
for (VAR_6 = 0; VAR_6 < c->planes; VAR_6++) {
VAR_8[VAR_6] = gb.buffer;
if (bytestream2_get_bytes_left(&gb) < 256 + 4 * c->slices) {
av_log(VAR_0, AV_LOG_ERROR, "Insufficient VAR_1 for a plane\n");
return AVERROR_INVALIDDATA;
}
bytestream2_skipu(&gb, 256);
VAR_11 = 0;
VAR_12 = 0;
for (VAR_7 = 0; VAR_7 < c->slices; VAR_7++) {
VAR_12 = bytestream2_get_le32u(&gb);
VAR_13 = VAR_12 - VAR_11;
if (VAR_12 < 0 || VAR_13 < 0 ||
bytestream2_get_bytes_left(&gb) < VAR_12) {
av_log(VAR_0, AV_LOG_ERROR, "Incorrect slice size\n");
return AVERROR_INVALIDDATA;
}
VAR_11 = VAR_12;
VAR_10 = FFMAX(VAR_10, VAR_13);
}
VAR_9 = VAR_12;
bytestream2_skipu(&gb, VAR_9);
}
VAR_8[c->planes] = gb.buffer;
if (bytestream2_get_bytes_left(&gb) < c->frame_info_size) {
av_log(VAR_0, AV_LOG_ERROR, "Not enough VAR_1 for frame information\n");
return AVERROR_INVALIDDATA;
}
c->frame_info = bytestream2_get_le32u(&gb);
av_log(VAR_0, AV_LOG_DEBUG, "frame information flags %"PRIX32"\n",
c->frame_info);
c->frame_pred = (c->frame_info >> 8) & 3;
if (c->frame_pred == PRED_GRADIENT) {
avpriv_request_sample(VAR_0, "Frame with gradient prediction");
return AVERROR_PATCHWELCOME;
}
av_fast_malloc(&c->slice_bits, &c->slice_bits_size,
VAR_10 + AV_INPUT_BUFFER_PADDING_SIZE);
if (!c->slice_bits) {
av_log(VAR_0, AV_LOG_ERROR, "Cannot allocate temporary buffer\n");
return AVERROR(ENOMEM);
}
switch (c->VAR_0->pix_fmt) {
case AV_PIX_FMT_RGB24:
case AV_PIX_FMT_RGBA:
for (VAR_6 = 0; VAR_6 < c->planes; VAR_6++) {
VAR_14 = decode_plane(c, VAR_6, frame.f->VAR_1[0] + ff_ut_rgb_order[VAR_6],
c->planes, frame.f->linesize[0], VAR_0->width,
VAR_0->height, VAR_8[VAR_6],
c->frame_pred == PRED_LEFT);
if (VAR_14)
return VAR_14;
if (c->frame_pred == PRED_MEDIAN) {
if (!c->interlaced) {
restore_median(frame.f->VAR_1[0] + ff_ut_rgb_order[VAR_6],
c->planes, frame.f->linesize[0], VAR_0->width,
VAR_0->height, c->slices, 0);
} else {
restore_median_il(frame.f->VAR_1[0] + ff_ut_rgb_order[VAR_6],
c->planes, frame.f->linesize[0],
VAR_0->width, VAR_0->height, c->slices,
0);
}
}
}
restore_rgb_planes(frame.f->VAR_1[0], c->planes, frame.f->linesize[0],
VAR_0->width, VAR_0->height);
break;
case AV_PIX_FMT_YUV420P:
for (VAR_6 = 0; VAR_6 < 3; VAR_6++) {
VAR_14 = decode_plane(c, VAR_6, frame.f->VAR_1[VAR_6], 1, frame.f->linesize[VAR_6],
VAR_0->width >> !!VAR_6, VAR_0->height >> !!VAR_6,
VAR_8[VAR_6], c->frame_pred == PRED_LEFT);
if (VAR_14)
return VAR_14;
if (c->frame_pred == PRED_MEDIAN) {
if (!c->interlaced) {
restore_median(frame.f->VAR_1[VAR_6], 1, frame.f->linesize[VAR_6],
VAR_0->width >> !!VAR_6, VAR_0->height >> !!VAR_6,
c->slices, !VAR_6);
} else {
restore_median_il(frame.f->VAR_1[VAR_6], 1, frame.f->linesize[VAR_6],
VAR_0->width >> !!VAR_6,
VAR_0->height >> !!VAR_6,
c->slices, !VAR_6);
}
}
}
break;
case AV_PIX_FMT_YUV422P:
for (VAR_6 = 0; VAR_6 < 3; VAR_6++) {
VAR_14 = decode_plane(c, VAR_6, frame.f->VAR_1[VAR_6], 1, frame.f->linesize[VAR_6],
VAR_0->width >> !!VAR_6, VAR_0->height,
VAR_8[VAR_6], c->frame_pred == PRED_LEFT);
if (VAR_14)
return VAR_14;
if (c->frame_pred == PRED_MEDIAN) {
if (!c->interlaced) {
restore_median(frame.f->VAR_1[VAR_6], 1, frame.f->linesize[VAR_6],
VAR_0->width >> !!VAR_6, VAR_0->height,
c->slices, 0);
} else {
restore_median_il(frame.f->VAR_1[VAR_6], 1, frame.f->linesize[VAR_6],
VAR_0->width >> !!VAR_6, VAR_0->height,
c->slices, 0);
}
}
}
break;
}
frame.f->key_frame = 1;
frame.f->pict_type = AV_PICTURE_TYPE_I;
frame.f->interlaced_frame = !!c->interlaced;
*VAR_2 = 1;
return VAR_5;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"UtvideoContext *c = VAR_0->priv_data;",
"int VAR_6, VAR_7;",
"const uint8_t *VAR_8[5];",
"int VAR_9, VAR_10 = 0, VAR_11, VAR_12, VAR_13;",
"int VAR_14;",
"GetByteContext gb;",
"ThreadFrame frame = { .f = VAR_1 };",
"if ((VAR_14 = ff_thread_get_buffer(VAR_0, &frame, 0)) < 0)\nreturn VAR_14;",
"bytestream2_init(&gb, VAR_4, VAR_5);",
"for (VAR_6 = 0; VAR_6 < c->planes; VAR_6++) {",
"VAR_8[VAR_6] = gb.buffer;",
"if (bytestream2_get_bytes_left(&gb) < 256 + 4 * c->slices) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Insufficient VAR_1 for a plane\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"bytestream2_skipu(&gb, 256);",
"VAR_11 = 0;",
"VAR_12 = 0;",
"for (VAR_7 = 0; VAR_7 < c->slices; VAR_7++) {",
"VAR_12 = bytestream2_get_le32u(&gb);",
"VAR_13 = VAR_12 - VAR_11;",
"if (VAR_12 < 0 || VAR_13 < 0 ||\nbytestream2_get_bytes_left(&gb) < VAR_12) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Incorrect slice size\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_11 = VAR_12;",
"VAR_10 = FFMAX(VAR_10, VAR_13);",
"}",
"VAR_9 = VAR_12;",
"bytestream2_skipu(&gb, VAR_9);",
"}",
"VAR_8[c->planes] = gb.buffer;",
"if (bytestream2_get_bytes_left(&gb) < c->frame_info_size) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Not enough VAR_1 for frame information\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"c->frame_info = bytestream2_get_le32u(&gb);",
"av_log(VAR_0, AV_LOG_DEBUG, \"frame information flags %\"PRIX32\"\\n\",\nc->frame_info);",
"c->frame_pred = (c->frame_info >> 8) & 3;",
"if (c->frame_pred == PRED_GRADIENT) {",
"avpriv_request_sample(VAR_0, \"Frame with gradient prediction\");",
"return AVERROR_PATCHWELCOME;",
"}",
"av_fast_malloc(&c->slice_bits, &c->slice_bits_size,\nVAR_10 + AV_INPUT_BUFFER_PADDING_SIZE);",
"if (!c->slice_bits) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Cannot allocate temporary buffer\\n\");",
"return AVERROR(ENOMEM);",
"}",
"switch (c->VAR_0->pix_fmt) {",
"case AV_PIX_FMT_RGB24:\ncase AV_PIX_FMT_RGBA:\nfor (VAR_6 = 0; VAR_6 < c->planes; VAR_6++) {",
"VAR_14 = decode_plane(c, VAR_6, frame.f->VAR_1[0] + ff_ut_rgb_order[VAR_6],\nc->planes, frame.f->linesize[0], VAR_0->width,\nVAR_0->height, VAR_8[VAR_6],\nc->frame_pred == PRED_LEFT);",
"if (VAR_14)\nreturn VAR_14;",
"if (c->frame_pred == PRED_MEDIAN) {",
"if (!c->interlaced) {",
"restore_median(frame.f->VAR_1[0] + ff_ut_rgb_order[VAR_6],\nc->planes, frame.f->linesize[0], VAR_0->width,\nVAR_0->height, c->slices, 0);",
"} else {",
"restore_median_il(frame.f->VAR_1[0] + ff_ut_rgb_order[VAR_6],\nc->planes, frame.f->linesize[0],\nVAR_0->width, VAR_0->height, c->slices,\n0);",
"}",
"}",
"}",
"restore_rgb_planes(frame.f->VAR_1[0], c->planes, frame.f->linesize[0],\nVAR_0->width, VAR_0->height);",
"break;",
"case AV_PIX_FMT_YUV420P:\nfor (VAR_6 = 0; VAR_6 < 3; VAR_6++) {",
"VAR_14 = decode_plane(c, VAR_6, frame.f->VAR_1[VAR_6], 1, frame.f->linesize[VAR_6],\nVAR_0->width >> !!VAR_6, VAR_0->height >> !!VAR_6,\nVAR_8[VAR_6], c->frame_pred == PRED_LEFT);",
"if (VAR_14)\nreturn VAR_14;",
"if (c->frame_pred == PRED_MEDIAN) {",
"if (!c->interlaced) {",
"restore_median(frame.f->VAR_1[VAR_6], 1, frame.f->linesize[VAR_6],\nVAR_0->width >> !!VAR_6, VAR_0->height >> !!VAR_6,\nc->slices, !VAR_6);",
"} else {",
"restore_median_il(frame.f->VAR_1[VAR_6], 1, frame.f->linesize[VAR_6],\nVAR_0->width >> !!VAR_6,\nVAR_0->height >> !!VAR_6,\nc->slices, !VAR_6);",
"}",
"}",
"}",
"break;",
"case AV_PIX_FMT_YUV422P:\nfor (VAR_6 = 0; VAR_6 < 3; VAR_6++) {",
"VAR_14 = decode_plane(c, VAR_6, frame.f->VAR_1[VAR_6], 1, frame.f->linesize[VAR_6],\nVAR_0->width >> !!VAR_6, VAR_0->height,\nVAR_8[VAR_6], c->frame_pred == PRED_LEFT);",
"if (VAR_14)\nreturn VAR_14;",
"if (c->frame_pred == PRED_MEDIAN) {",
"if (!c->interlaced) {",
"restore_median(frame.f->VAR_1[VAR_6], 1, frame.f->linesize[VAR_6],\nVAR_0->width >> !!VAR_6, VAR_0->height,\nc->slices, 0);",
"} else {",
"restore_median_il(frame.f->VAR_1[VAR_6], 1, frame.f->linesize[VAR_6],\nVAR_0->width >> !!VAR_6, VAR_0->height,\nc->slices, 0);",
"}",
"}",
"}",
"break;",
"}",
"frame.f->key_frame = 1;",
"frame.f->pict_type = AV_PICTURE_TYPE_I;",
"frame.f->interlaced_frame = !!c->interlaced;",
"*VAR_2 = 1;",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27,
29
],
[
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
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115,
117
],
[
121
],
[
123
],
[
125
],
[
127
],
[
131
],
[
133,
135,
137
],
[
139,
141,
143,
145
],
[
147,
149
],
[
151
],
[
153
],
[
155,
157,
159
],
[
161
],
[
163,
165,
167,
169
],
[
171
],
[
173
],
[
175
],
[
177,
179
],
[
181
],
[
183,
185
],
[
187,
189,
191
],
[
193,
195
],
[
197
],
[
199
],
[
201,
203,
205
],
[
207
],
[
209,
211,
213,
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225,
227
],
[
229,
231,
233
],
[
235,
237
],
[
239
],
[
241
],
[
243,
245,
247
],
[
249
],
[
251,
253,
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
269
],
[
271
],
[
273
],
[
277
],
[
283
],
[
285
]
] |
3,231 | static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx)
{
return ff_vaapi_encode_init(avctx, &vaapi_encode_type_h264);
}
| false | FFmpeg | 80a5d05108cb218e8cd2e25c6621a3bfef0a832e | static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx)
{
return ff_vaapi_encode_init(avctx, &vaapi_encode_type_h264);
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
return ff_vaapi_encode_init(avctx, &vaapi_encode_type_h264);
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"return ff_vaapi_encode_init(avctx, &vaapi_encode_type_h264);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
3,233 | static void test_qemu_strtoul_full_max(void)
{
const char *str = g_strdup_printf("%lu", ULONG_MAX);
unsigned long res = 999;
int err;
err = qemu_strtoul(str, NULL, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, ULONG_MAX);
}
| true | qemu | d6f723b513a0c3c4e58343b7c52a2f9850861fa0 | static void test_qemu_strtoul_full_max(void)
{
const char *str = g_strdup_printf("%lu", ULONG_MAX);
unsigned long res = 999;
int err;
err = qemu_strtoul(str, NULL, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, ULONG_MAX);
}
| {
"code": [
" const char *str = g_strdup_printf(\"%lu\", ULONG_MAX);",
" const char *str = g_strdup_printf(\"%lu\", ULONG_MAX);"
],
"line_no": [
5,
5
]
} | static void FUNC_0(void)
{
const char *VAR_0 = g_strdup_printf("%lu", ULONG_MAX);
unsigned long VAR_1 = 999;
int VAR_2;
VAR_2 = qemu_strtoul(VAR_0, NULL, 0, &VAR_1);
g_assert_cmpint(VAR_2, ==, 0);
g_assert_cmpint(VAR_1, ==, ULONG_MAX);
}
| [
"static void FUNC_0(void)\n{",
"const char *VAR_0 = g_strdup_printf(\"%lu\", ULONG_MAX);",
"unsigned long VAR_1 = 999;",
"int VAR_2;",
"VAR_2 = qemu_strtoul(VAR_0, NULL, 0, &VAR_1);",
"g_assert_cmpint(VAR_2, ==, 0);",
"g_assert_cmpint(VAR_1, ==, ULONG_MAX);",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
]
] |
3,235 | static int cloop_open(BlockDriverState *bs, int flags)
{
BDRVCloopState *s = bs->opaque;
uint32_t offsets_size, max_compressed_block_size = 1, i;
bs->read_only = 1;
/* read header */
if (bdrv_pread(bs->file, 128, &s->block_size, 4) < 4) {
goto cloop_close;
}
s->block_size = be32_to_cpu(s->block_size);
if (bdrv_pread(bs->file, 128 + 4, &s->n_blocks, 4) < 4) {
goto cloop_close;
}
s->n_blocks = be32_to_cpu(s->n_blocks);
/* read offsets */
offsets_size = s->n_blocks * sizeof(uint64_t);
s->offsets = g_malloc(offsets_size);
if (bdrv_pread(bs->file, 128 + 4 + 4, s->offsets, offsets_size) <
offsets_size) {
goto cloop_close;
}
for(i=0;i<s->n_blocks;i++) {
s->offsets[i] = be64_to_cpu(s->offsets[i]);
if (i > 0) {
uint32_t size = s->offsets[i] - s->offsets[i - 1];
if (size > max_compressed_block_size) {
max_compressed_block_size = size;
}
}
}
/* initialize zlib engine */
s->compressed_block = g_malloc(max_compressed_block_size + 1);
s->uncompressed_block = g_malloc(s->block_size);
if (inflateInit(&s->zstream) != Z_OK) {
goto cloop_close;
}
s->current_block = s->n_blocks;
s->sectors_per_block = s->block_size/512;
bs->total_sectors = s->n_blocks * s->sectors_per_block;
qemu_co_mutex_init(&s->lock);
return 0;
cloop_close:
return -1;
}
| true | qemu | 1a60657f5729bac57e70802eb17e67ad793400fd | static int cloop_open(BlockDriverState *bs, int flags)
{
BDRVCloopState *s = bs->opaque;
uint32_t offsets_size, max_compressed_block_size = 1, i;
bs->read_only = 1;
if (bdrv_pread(bs->file, 128, &s->block_size, 4) < 4) {
goto cloop_close;
}
s->block_size = be32_to_cpu(s->block_size);
if (bdrv_pread(bs->file, 128 + 4, &s->n_blocks, 4) < 4) {
goto cloop_close;
}
s->n_blocks = be32_to_cpu(s->n_blocks);
offsets_size = s->n_blocks * sizeof(uint64_t);
s->offsets = g_malloc(offsets_size);
if (bdrv_pread(bs->file, 128 + 4 + 4, s->offsets, offsets_size) <
offsets_size) {
goto cloop_close;
}
for(i=0;i<s->n_blocks;i++) {
s->offsets[i] = be64_to_cpu(s->offsets[i]);
if (i > 0) {
uint32_t size = s->offsets[i] - s->offsets[i - 1];
if (size > max_compressed_block_size) {
max_compressed_block_size = size;
}
}
}
s->compressed_block = g_malloc(max_compressed_block_size + 1);
s->uncompressed_block = g_malloc(s->block_size);
if (inflateInit(&s->zstream) != Z_OK) {
goto cloop_close;
}
s->current_block = s->n_blocks;
s->sectors_per_block = s->block_size/512;
bs->total_sectors = s->n_blocks * s->sectors_per_block;
qemu_co_mutex_init(&s->lock);
return 0;
cloop_close:
return -1;
}
| {
"code": [
" if (bdrv_pread(bs->file, 128, &s->block_size, 4) < 4) {",
" goto cloop_close;",
" if (bdrv_pread(bs->file, 128 + 4, &s->n_blocks, 4) < 4) {",
" goto cloop_close;",
" if (bdrv_pread(bs->file, 128 + 4 + 4, s->offsets, offsets_size) <",
" offsets_size) {",
" goto cloop_close;",
" goto cloop_close;",
"cloop_close:",
" return -1;"
],
"line_no": [
17,
19,
27,
19,
43,
45,
19,
19,
97,
99
]
} | static int FUNC_0(BlockDriverState *VAR_0, int VAR_1)
{
BDRVCloopState *s = VAR_0->opaque;
uint32_t offsets_size, max_compressed_block_size = 1, i;
VAR_0->read_only = 1;
if (bdrv_pread(VAR_0->file, 128, &s->block_size, 4) < 4) {
goto cloop_close;
}
s->block_size = be32_to_cpu(s->block_size);
if (bdrv_pread(VAR_0->file, 128 + 4, &s->n_blocks, 4) < 4) {
goto cloop_close;
}
s->n_blocks = be32_to_cpu(s->n_blocks);
offsets_size = s->n_blocks * sizeof(uint64_t);
s->offsets = g_malloc(offsets_size);
if (bdrv_pread(VAR_0->file, 128 + 4 + 4, s->offsets, offsets_size) <
offsets_size) {
goto cloop_close;
}
for(i=0;i<s->n_blocks;i++) {
s->offsets[i] = be64_to_cpu(s->offsets[i]);
if (i > 0) {
uint32_t size = s->offsets[i] - s->offsets[i - 1];
if (size > max_compressed_block_size) {
max_compressed_block_size = size;
}
}
}
s->compressed_block = g_malloc(max_compressed_block_size + 1);
s->uncompressed_block = g_malloc(s->block_size);
if (inflateInit(&s->zstream) != Z_OK) {
goto cloop_close;
}
s->current_block = s->n_blocks;
s->sectors_per_block = s->block_size/512;
VAR_0->total_sectors = s->n_blocks * s->sectors_per_block;
qemu_co_mutex_init(&s->lock);
return 0;
cloop_close:
return -1;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, int VAR_1)\n{",
"BDRVCloopState *s = VAR_0->opaque;",
"uint32_t offsets_size, max_compressed_block_size = 1, i;",
"VAR_0->read_only = 1;",
"if (bdrv_pread(VAR_0->file, 128, &s->block_size, 4) < 4) {",
"goto cloop_close;",
"}",
"s->block_size = be32_to_cpu(s->block_size);",
"if (bdrv_pread(VAR_0->file, 128 + 4, &s->n_blocks, 4) < 4) {",
"goto cloop_close;",
"}",
"s->n_blocks = be32_to_cpu(s->n_blocks);",
"offsets_size = s->n_blocks * sizeof(uint64_t);",
"s->offsets = g_malloc(offsets_size);",
"if (bdrv_pread(VAR_0->file, 128 + 4 + 4, s->offsets, offsets_size) <\noffsets_size) {",
"goto cloop_close;",
"}",
"for(i=0;i<s->n_blocks;i++) {",
"s->offsets[i] = be64_to_cpu(s->offsets[i]);",
"if (i > 0) {",
"uint32_t size = s->offsets[i] - s->offsets[i - 1];",
"if (size > max_compressed_block_size) {",
"max_compressed_block_size = size;",
"}",
"}",
"}",
"s->compressed_block = g_malloc(max_compressed_block_size + 1);",
"s->uncompressed_block = g_malloc(s->block_size);",
"if (inflateInit(&s->zstream) != Z_OK) {",
"goto cloop_close;",
"}",
"s->current_block = s->n_blocks;",
"s->sectors_per_block = s->block_size/512;",
"VAR_0->total_sectors = s->n_blocks * s->sectors_per_block;",
"qemu_co_mutex_init(&s->lock);",
"return 0;",
"cloop_close:\nreturn -1;",
"}"
] | [
0,
0,
0,
0,
1,
1,
0,
0,
1,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97,
99
],
[
101
]
] |
3,238 | static void monitor_find_completion(Monitor *mon,
const char *cmdline)
{
const char *cmdname;
char *args[MAX_ARGS];
int nb_args, i, len;
const char *ptype, *str;
const mon_cmd_t *cmd;
MonitorBlockComplete mbs;
parse_cmdline(cmdline, &nb_args, args);
#ifdef DEBUG_COMPLETION
for (i = 0; i < nb_args; i++) {
monitor_printf(mon, "arg%d = '%s'\n", i, args[i]);
}
#endif
/* if the line ends with a space, it means we want to complete the
next arg */
len = strlen(cmdline);
if (len > 0 && qemu_isspace(cmdline[len - 1])) {
if (nb_args >= MAX_ARGS) {
goto cleanup;
}
args[nb_args++] = g_strdup("");
}
if (nb_args <= 1) {
/* command completion */
if (nb_args == 0)
cmdname = "";
else
cmdname = args[0];
readline_set_completion_index(mon->rs, strlen(cmdname));
for (cmd = mon->cmd_table; cmd->name != NULL; cmd++) {
cmd_completion(mon, cmdname, cmd->name);
}
} else {
/* find the command */
for (cmd = mon->cmd_table; cmd->name != NULL; cmd++) {
if (compare_cmd(args[0], cmd->name)) {
break;
}
}
if (!cmd->name) {
goto cleanup;
}
ptype = next_arg_type(cmd->args_type);
for(i = 0; i < nb_args - 2; i++) {
if (*ptype != '\0') {
ptype = next_arg_type(ptype);
while (*ptype == '?')
ptype = next_arg_type(ptype);
}
}
str = args[nb_args - 1];
if (*ptype == '-' && ptype[1] != '\0') {
ptype = next_arg_type(ptype);
}
switch(*ptype) {
case 'F':
/* file completion */
readline_set_completion_index(mon->rs, strlen(str));
file_completion(mon, str);
break;
case 'B':
/* block device name completion */
mbs.mon = mon;
mbs.input = str;
readline_set_completion_index(mon->rs, strlen(str));
bdrv_iterate(block_completion_it, &mbs);
break;
case 's':
/* XXX: more generic ? */
if (!strcmp(cmd->name, "info")) {
readline_set_completion_index(mon->rs, strlen(str));
for(cmd = info_cmds; cmd->name != NULL; cmd++) {
cmd_completion(mon, str, cmd->name);
}
} else if (!strcmp(cmd->name, "sendkey")) {
char *sep = strrchr(str, '-');
if (sep)
str = sep + 1;
readline_set_completion_index(mon->rs, strlen(str));
for (i = 0; i < Q_KEY_CODE_MAX; i++) {
cmd_completion(mon, str, QKeyCode_lookup[i]);
}
} else if (!strcmp(cmd->name, "help|?")) {
readline_set_completion_index(mon->rs, strlen(str));
for (cmd = mon->cmd_table; cmd->name != NULL; cmd++) {
cmd_completion(mon, str, cmd->name);
}
}
break;
default:
break;
}
}
cleanup:
for (i = 0; i < nb_args; i++) {
g_free(args[i]);
}
}
| true | qemu | dcc70cdf0932172fc5cf27617a3b033ca58d0176 | static void monitor_find_completion(Monitor *mon,
const char *cmdline)
{
const char *cmdname;
char *args[MAX_ARGS];
int nb_args, i, len;
const char *ptype, *str;
const mon_cmd_t *cmd;
MonitorBlockComplete mbs;
parse_cmdline(cmdline, &nb_args, args);
#ifdef DEBUG_COMPLETION
for (i = 0; i < nb_args; i++) {
monitor_printf(mon, "arg%d = '%s'\n", i, args[i]);
}
#endif
len = strlen(cmdline);
if (len > 0 && qemu_isspace(cmdline[len - 1])) {
if (nb_args >= MAX_ARGS) {
goto cleanup;
}
args[nb_args++] = g_strdup("");
}
if (nb_args <= 1) {
if (nb_args == 0)
cmdname = "";
else
cmdname = args[0];
readline_set_completion_index(mon->rs, strlen(cmdname));
for (cmd = mon->cmd_table; cmd->name != NULL; cmd++) {
cmd_completion(mon, cmdname, cmd->name);
}
} else {
for (cmd = mon->cmd_table; cmd->name != NULL; cmd++) {
if (compare_cmd(args[0], cmd->name)) {
break;
}
}
if (!cmd->name) {
goto cleanup;
}
ptype = next_arg_type(cmd->args_type);
for(i = 0; i < nb_args - 2; i++) {
if (*ptype != '\0') {
ptype = next_arg_type(ptype);
while (*ptype == '?')
ptype = next_arg_type(ptype);
}
}
str = args[nb_args - 1];
if (*ptype == '-' && ptype[1] != '\0') {
ptype = next_arg_type(ptype);
}
switch(*ptype) {
case 'F':
readline_set_completion_index(mon->rs, strlen(str));
file_completion(mon, str);
break;
case 'B':
mbs.mon = mon;
mbs.input = str;
readline_set_completion_index(mon->rs, strlen(str));
bdrv_iterate(block_completion_it, &mbs);
break;
case 's':
if (!strcmp(cmd->name, "info")) {
readline_set_completion_index(mon->rs, strlen(str));
for(cmd = info_cmds; cmd->name != NULL; cmd++) {
cmd_completion(mon, str, cmd->name);
}
} else if (!strcmp(cmd->name, "sendkey")) {
char *sep = strrchr(str, '-');
if (sep)
str = sep + 1;
readline_set_completion_index(mon->rs, strlen(str));
for (i = 0; i < Q_KEY_CODE_MAX; i++) {
cmd_completion(mon, str, QKeyCode_lookup[i]);
}
} else if (!strcmp(cmd->name, "help|?")) {
readline_set_completion_index(mon->rs, strlen(str));
for (cmd = mon->cmd_table; cmd->name != NULL; cmd++) {
cmd_completion(mon, str, cmd->name);
}
}
break;
default:
break;
}
}
cleanup:
for (i = 0; i < nb_args; i++) {
g_free(args[i]);
}
}
| {
"code": [
" break;",
" break;",
" parse_cmdline(cmdline, &nb_args, args);",
" for (i = 0; i < nb_args; i++) {",
" g_free(args[i]);"
],
"line_no": [
129,
129,
21,
25,
203
]
} | static void FUNC_0(Monitor *VAR_0,
const char *VAR_1)
{
const char *VAR_2;
char *VAR_3[MAX_ARGS];
int VAR_4, VAR_5, VAR_6;
const char *VAR_7, *VAR_8;
const mon_cmd_t *VAR_9;
MonitorBlockComplete mbs;
parse_cmdline(VAR_1, &VAR_4, VAR_3);
#ifdef DEBUG_COMPLETION
for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {
monitor_printf(VAR_0, "arg%d = '%s'\n", VAR_5, VAR_3[VAR_5]);
}
#endif
VAR_6 = strlen(VAR_1);
if (VAR_6 > 0 && qemu_isspace(VAR_1[VAR_6 - 1])) {
if (VAR_4 >= MAX_ARGS) {
goto cleanup;
}
VAR_3[VAR_4++] = g_strdup("");
}
if (VAR_4 <= 1) {
if (VAR_4 == 0)
VAR_2 = "";
else
VAR_2 = VAR_3[0];
readline_set_completion_index(VAR_0->rs, strlen(VAR_2));
for (VAR_9 = VAR_0->cmd_table; VAR_9->name != NULL; VAR_9++) {
cmd_completion(VAR_0, VAR_2, VAR_9->name);
}
} else {
for (VAR_9 = VAR_0->cmd_table; VAR_9->name != NULL; VAR_9++) {
if (compare_cmd(VAR_3[0], VAR_9->name)) {
break;
}
}
if (!VAR_9->name) {
goto cleanup;
}
VAR_7 = next_arg_type(VAR_9->args_type);
for(VAR_5 = 0; VAR_5 < VAR_4 - 2; VAR_5++) {
if (*VAR_7 != '\0') {
VAR_7 = next_arg_type(VAR_7);
while (*VAR_7 == '?')
VAR_7 = next_arg_type(VAR_7);
}
}
VAR_8 = VAR_3[VAR_4 - 1];
if (*VAR_7 == '-' && VAR_7[1] != '\0') {
VAR_7 = next_arg_type(VAR_7);
}
switch(*VAR_7) {
case 'F':
readline_set_completion_index(VAR_0->rs, strlen(VAR_8));
file_completion(VAR_0, VAR_8);
break;
case 'B':
mbs.VAR_0 = VAR_0;
mbs.input = VAR_8;
readline_set_completion_index(VAR_0->rs, strlen(VAR_8));
bdrv_iterate(block_completion_it, &mbs);
break;
case 's':
if (!strcmp(VAR_9->name, "info")) {
readline_set_completion_index(VAR_0->rs, strlen(VAR_8));
for(VAR_9 = info_cmds; VAR_9->name != NULL; VAR_9++) {
cmd_completion(VAR_0, VAR_8, VAR_9->name);
}
} else if (!strcmp(VAR_9->name, "sendkey")) {
char *VAR_10 = strrchr(VAR_8, '-');
if (VAR_10)
VAR_8 = VAR_10 + 1;
readline_set_completion_index(VAR_0->rs, strlen(VAR_8));
for (VAR_5 = 0; VAR_5 < Q_KEY_CODE_MAX; VAR_5++) {
cmd_completion(VAR_0, VAR_8, QKeyCode_lookup[VAR_5]);
}
} else if (!strcmp(VAR_9->name, "help|?")) {
readline_set_completion_index(VAR_0->rs, strlen(VAR_8));
for (VAR_9 = VAR_0->cmd_table; VAR_9->name != NULL; VAR_9++) {
cmd_completion(VAR_0, VAR_8, VAR_9->name);
}
}
break;
default:
break;
}
}
cleanup:
for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {
g_free(VAR_3[VAR_5]);
}
}
| [
"static void FUNC_0(Monitor *VAR_0,\nconst char *VAR_1)\n{",
"const char *VAR_2;",
"char *VAR_3[MAX_ARGS];",
"int VAR_4, VAR_5, VAR_6;",
"const char *VAR_7, *VAR_8;",
"const mon_cmd_t *VAR_9;",
"MonitorBlockComplete mbs;",
"parse_cmdline(VAR_1, &VAR_4, VAR_3);",
"#ifdef DEBUG_COMPLETION\nfor (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {",
"monitor_printf(VAR_0, \"arg%d = '%s'\\n\", VAR_5, VAR_3[VAR_5]);",
"}",
"#endif\nVAR_6 = strlen(VAR_1);",
"if (VAR_6 > 0 && qemu_isspace(VAR_1[VAR_6 - 1])) {",
"if (VAR_4 >= MAX_ARGS) {",
"goto cleanup;",
"}",
"VAR_3[VAR_4++] = g_strdup(\"\");",
"}",
"if (VAR_4 <= 1) {",
"if (VAR_4 == 0)\nVAR_2 = \"\";",
"else\nVAR_2 = VAR_3[0];",
"readline_set_completion_index(VAR_0->rs, strlen(VAR_2));",
"for (VAR_9 = VAR_0->cmd_table; VAR_9->name != NULL; VAR_9++) {",
"cmd_completion(VAR_0, VAR_2, VAR_9->name);",
"}",
"} else {",
"for (VAR_9 = VAR_0->cmd_table; VAR_9->name != NULL; VAR_9++) {",
"if (compare_cmd(VAR_3[0], VAR_9->name)) {",
"break;",
"}",
"}",
"if (!VAR_9->name) {",
"goto cleanup;",
"}",
"VAR_7 = next_arg_type(VAR_9->args_type);",
"for(VAR_5 = 0; VAR_5 < VAR_4 - 2; VAR_5++) {",
"if (*VAR_7 != '\\0') {",
"VAR_7 = next_arg_type(VAR_7);",
"while (*VAR_7 == '?')\nVAR_7 = next_arg_type(VAR_7);",
"}",
"}",
"VAR_8 = VAR_3[VAR_4 - 1];",
"if (*VAR_7 == '-' && VAR_7[1] != '\\0') {",
"VAR_7 = next_arg_type(VAR_7);",
"}",
"switch(*VAR_7) {",
"case 'F':\nreadline_set_completion_index(VAR_0->rs, strlen(VAR_8));",
"file_completion(VAR_0, VAR_8);",
"break;",
"case 'B':\nmbs.VAR_0 = VAR_0;",
"mbs.input = VAR_8;",
"readline_set_completion_index(VAR_0->rs, strlen(VAR_8));",
"bdrv_iterate(block_completion_it, &mbs);",
"break;",
"case 's':\nif (!strcmp(VAR_9->name, \"info\")) {",
"readline_set_completion_index(VAR_0->rs, strlen(VAR_8));",
"for(VAR_9 = info_cmds; VAR_9->name != NULL; VAR_9++) {",
"cmd_completion(VAR_0, VAR_8, VAR_9->name);",
"}",
"} else if (!strcmp(VAR_9->name, \"sendkey\")) {",
"char *VAR_10 = strrchr(VAR_8, '-');",
"if (VAR_10)\nVAR_8 = VAR_10 + 1;",
"readline_set_completion_index(VAR_0->rs, strlen(VAR_8));",
"for (VAR_5 = 0; VAR_5 < Q_KEY_CODE_MAX; VAR_5++) {",
"cmd_completion(VAR_0, VAR_8, QKeyCode_lookup[VAR_5]);",
"}",
"} else if (!strcmp(VAR_9->name, \"help|?\")) {",
"readline_set_completion_index(VAR_0->rs, strlen(VAR_8));",
"for (VAR_9 = VAR_0->cmd_table; VAR_9->name != NULL; VAR_9++) {",
"cmd_completion(VAR_0, VAR_8, VAR_9->name);",
"}",
"}",
"break;",
"default:\nbreak;",
"}",
"}",
"cleanup:\nfor (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {",
"g_free(VAR_3[VAR_5]);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57,
59
],
[
61,
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103,
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121,
125
],
[
127
],
[
129
],
[
131,
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145,
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163,
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189,
191
],
[
193
],
[
195
],
[
199,
201
],
[
203
],
[
205
],
[
207
]
] |
3,239 | static void decode_channel_map(uint8_t layout_map[][3],
enum ChannelPosition type,
GetBitContext *gb, int n)
{
while (n--) {
enum RawDataBlockType syn_ele;
switch (type) {
case AAC_CHANNEL_FRONT:
case AAC_CHANNEL_BACK:
case AAC_CHANNEL_SIDE:
syn_ele = get_bits1(gb);
break;
case AAC_CHANNEL_CC:
skip_bits1(gb);
syn_ele = TYPE_CCE;
break;
case AAC_CHANNEL_LFE:
syn_ele = TYPE_LFE;
break;
}
layout_map[0][0] = syn_ele;
layout_map[0][1] = get_bits(gb, 4);
layout_map[0][2] = type;
layout_map++;
}
} | true | FFmpeg | a48b890392aa22033f182421ba9e3f3b3256461d | static void decode_channel_map(uint8_t layout_map[][3],
enum ChannelPosition type,
GetBitContext *gb, int n)
{
while (n--) {
enum RawDataBlockType syn_ele;
switch (type) {
case AAC_CHANNEL_FRONT:
case AAC_CHANNEL_BACK:
case AAC_CHANNEL_SIDE:
syn_ele = get_bits1(gb);
break;
case AAC_CHANNEL_CC:
skip_bits1(gb);
syn_ele = TYPE_CCE;
break;
case AAC_CHANNEL_LFE:
syn_ele = TYPE_LFE;
break;
}
layout_map[0][0] = syn_ele;
layout_map[0][1] = get_bits(gb, 4);
layout_map[0][2] = type;
layout_map++;
}
} | {
"code": [],
"line_no": []
} | static void FUNC_0(uint8_t VAR_0[][3],
enum ChannelPosition VAR_1,
GetBitContext *VAR_2, int VAR_3)
{
while (VAR_3--) {
enum RawDataBlockType VAR_4;
switch (VAR_1) {
case AAC_CHANNEL_FRONT:
case AAC_CHANNEL_BACK:
case AAC_CHANNEL_SIDE:
VAR_4 = get_bits1(VAR_2);
break;
case AAC_CHANNEL_CC:
skip_bits1(VAR_2);
VAR_4 = TYPE_CCE;
break;
case AAC_CHANNEL_LFE:
VAR_4 = TYPE_LFE;
break;
}
VAR_0[0][0] = VAR_4;
VAR_0[0][1] = get_bits(VAR_2, 4);
VAR_0[0][2] = VAR_1;
VAR_0++;
}
} | [
"static void FUNC_0(uint8_t VAR_0[][3],\nenum ChannelPosition VAR_1,\nGetBitContext *VAR_2, int VAR_3)\n{",
"while (VAR_3--) {",
"enum RawDataBlockType VAR_4;",
"switch (VAR_1) {",
"case AAC_CHANNEL_FRONT:\ncase AAC_CHANNEL_BACK:\ncase AAC_CHANNEL_SIDE:\nVAR_4 = get_bits1(VAR_2);",
"break;",
"case AAC_CHANNEL_CC:\nskip_bits1(VAR_2);",
"VAR_4 = TYPE_CCE;",
"break;",
"case AAC_CHANNEL_LFE:\nVAR_4 = TYPE_LFE;",
"break;",
"}",
"VAR_0[0][0] = VAR_4;",
"VAR_0[0][1] = get_bits(VAR_2, 4);",
"VAR_0[0][2] = VAR_1;",
"VAR_0++;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15,
17,
19,
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
]
] |
3,240 | int qemu_devtree_setprop_cell(void *fdt, const char *node_path,
const char *property, uint32_t val)
{
int offset;
offset = fdt_path_offset(fdt, node_path);
if (offset < 0)
return offset;
return fdt_setprop_cell(fdt, offset, property, val);
}
| true | qemu | ccbcfedd17fd2d13521fcee66810d0df464ec1cc | int qemu_devtree_setprop_cell(void *fdt, const char *node_path,
const char *property, uint32_t val)
{
int offset;
offset = fdt_path_offset(fdt, node_path);
if (offset < 0)
return offset;
return fdt_setprop_cell(fdt, offset, property, val);
}
| {
"code": [
" if (offset < 0)",
" return offset;",
" int offset;",
" offset = fdt_path_offset(fdt, node_path);",
" if (offset < 0)",
" return offset;",
" return fdt_setprop_cell(fdt, offset, property, val);",
" int offset;",
" offset = fdt_path_offset(fdt, node_path);",
" if (offset < 0)",
" return offset;",
" int offset;",
" offset = fdt_path_offset(fdt, node_path);",
" if (offset < 0)",
" return offset;",
" int offset;",
" return offset;"
],
"line_no": [
13,
15,
7,
11,
13,
15,
19,
7,
11,
13,
15,
7,
11,
13,
15,
7,
15
]
} | int FUNC_0(void *VAR_0, const char *VAR_1,
const char *VAR_2, uint32_t VAR_3)
{
int VAR_4;
VAR_4 = fdt_path_offset(VAR_0, VAR_1);
if (VAR_4 < 0)
return VAR_4;
return fdt_setprop_cell(VAR_0, VAR_4, VAR_2, VAR_3);
}
| [
"int FUNC_0(void *VAR_0, const char *VAR_1,\nconst char *VAR_2, uint32_t VAR_3)\n{",
"int VAR_4;",
"VAR_4 = fdt_path_offset(VAR_0, VAR_1);",
"if (VAR_4 < 0)\nreturn VAR_4;",
"return fdt_setprop_cell(VAR_0, VAR_4, VAR_2, VAR_3);",
"}"
] | [
0,
1,
1,
1,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13,
15
],
[
19
],
[
21
]
] |
3,241 | static void qed_copy_from_backing_file(BDRVQEDState *s, uint64_t pos,
uint64_t len, uint64_t offset,
BlockDriverCompletionFunc *cb,
void *opaque)
{
CopyFromBackingFileCB *copy_cb;
/* Skip copy entirely if there is no work to do */
if (len == 0) {
cb(opaque, 0);
return;
}
copy_cb = gencb_alloc(sizeof(*copy_cb), cb, opaque);
copy_cb->s = s;
copy_cb->offset = offset;
copy_cb->iov.iov_base = qemu_blockalign(s->bs, len);
copy_cb->iov.iov_len = len;
qemu_iovec_init_external(©_cb->qiov, ©_cb->iov, 1);
qed_read_backing_file(s, pos, ©_cb->qiov,
qed_copy_from_backing_file_write, copy_cb);
}
| true | qemu | f06ee3d4aa547df8d7d2317b2b6db7a88c1f3744 | static void qed_copy_from_backing_file(BDRVQEDState *s, uint64_t pos,
uint64_t len, uint64_t offset,
BlockDriverCompletionFunc *cb,
void *opaque)
{
CopyFromBackingFileCB *copy_cb;
if (len == 0) {
cb(opaque, 0);
return;
}
copy_cb = gencb_alloc(sizeof(*copy_cb), cb, opaque);
copy_cb->s = s;
copy_cb->offset = offset;
copy_cb->iov.iov_base = qemu_blockalign(s->bs, len);
copy_cb->iov.iov_len = len;
qemu_iovec_init_external(©_cb->qiov, ©_cb->iov, 1);
qed_read_backing_file(s, pos, ©_cb->qiov,
qed_copy_from_backing_file_write, copy_cb);
}
| {
"code": [
" qed_read_backing_file(s, pos, ©_cb->qiov,"
],
"line_no": [
41
]
} | static void FUNC_0(BDRVQEDState *VAR_0, uint64_t VAR_1,
uint64_t VAR_2, uint64_t VAR_3,
BlockDriverCompletionFunc *VAR_4,
void *VAR_5)
{
CopyFromBackingFileCB *copy_cb;
if (VAR_2 == 0) {
VAR_4(VAR_5, 0);
return;
}
copy_cb = gencb_alloc(sizeof(*copy_cb), VAR_4, VAR_5);
copy_cb->VAR_0 = VAR_0;
copy_cb->VAR_3 = VAR_3;
copy_cb->iov.iov_base = qemu_blockalign(VAR_0->bs, VAR_2);
copy_cb->iov.iov_len = VAR_2;
qemu_iovec_init_external(©_cb->qiov, ©_cb->iov, 1);
qed_read_backing_file(VAR_0, VAR_1, ©_cb->qiov,
qed_copy_from_backing_file_write, copy_cb);
}
| [
"static void FUNC_0(BDRVQEDState *VAR_0, uint64_t VAR_1,\nuint64_t VAR_2, uint64_t VAR_3,\nBlockDriverCompletionFunc *VAR_4,\nvoid *VAR_5)\n{",
"CopyFromBackingFileCB *copy_cb;",
"if (VAR_2 == 0) {",
"VAR_4(VAR_5, 0);",
"return;",
"}",
"copy_cb = gencb_alloc(sizeof(*copy_cb), VAR_4, VAR_5);",
"copy_cb->VAR_0 = VAR_0;",
"copy_cb->VAR_3 = VAR_3;",
"copy_cb->iov.iov_base = qemu_blockalign(VAR_0->bs, VAR_2);",
"copy_cb->iov.iov_len = VAR_2;",
"qemu_iovec_init_external(©_cb->qiov, ©_cb->iov, 1);",
"qed_read_backing_file(VAR_0, VAR_1, ©_cb->qiov,\nqed_copy_from_backing_file_write, copy_cb);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41,
43
],
[
45
]
] |
3,242 | void align_get_bits(GetBitContext *s)
{
int n= (-get_bits_count(s)) & 7;
if(n) skip_bits(s, n);
}
| false | FFmpeg | 5a7bd28335d502d90c727f69a50e6f251c305e72 | void align_get_bits(GetBitContext *s)
{
int n= (-get_bits_count(s)) & 7;
if(n) skip_bits(s, n);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(GetBitContext *VAR_0)
{
int VAR_1= (-get_bits_count(VAR_0)) & 7;
if(VAR_1) skip_bits(VAR_0, VAR_1);
}
| [
"void FUNC_0(GetBitContext *VAR_0)\n{",
"int VAR_1= (-get_bits_count(VAR_0)) & 7;",
"if(VAR_1) skip_bits(VAR_0, VAR_1);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
3,243 | static uint64_t do_cvttq(CPUAlphaState *env, uint64_t a, int roundmode)
{
uint64_t frac, ret = 0;
uint32_t exp, sign, exc = 0;
int shift;
sign = (a >> 63);
exp = (uint32_t)(a >> 52) & 0x7ff;
frac = a & 0xfffffffffffffull;
if (exp == 0) {
if (unlikely(frac != 0)) {
goto do_underflow;
}
} else if (exp == 0x7ff) {
exc = FPCR_INV;
} else {
/* Restore implicit bit. */
frac |= 0x10000000000000ull;
shift = exp - 1023 - 52;
if (shift >= 0) {
/* In this case the number is so large that we must shift
the fraction left. There is no rounding to do. */
if (shift < 64) {
ret = frac << shift;
}
/* Check for overflow. Note the special case of -0x1p63. */
if (shift >= 11 && a != 0xC3E0000000000000ull) {
exc = FPCR_IOV | FPCR_INE;
}
} else {
uint64_t round;
/* In this case the number is smaller than the fraction as
represented by the 52 bit number. Here we must think
about rounding the result. Handle this by shifting the
fractional part of the number into the high bits of ROUND.
This will let us efficiently handle round-to-nearest. */
shift = -shift;
if (shift < 63) {
ret = frac >> shift;
round = frac << (64 - shift);
} else {
/* The exponent is so small we shift out everything.
Leave a sticky bit for proper rounding below. */
do_underflow:
round = 1;
}
if (round) {
exc = FPCR_INE;
switch (roundmode) {
case float_round_nearest_even:
if (round == (1ull << 63)) {
/* Fraction is exactly 0.5; round to even. */
ret += (ret & 1);
} else if (round > (1ull << 63)) {
ret += 1;
}
break;
case float_round_to_zero:
break;
case float_round_up:
ret += 1 - sign;
break;
case float_round_down:
ret += sign;
break;
}
}
}
if (sign) {
ret = -ret;
}
}
env->error_code = exc;
return ret;
}
| true | qemu | 4ed069ab5334a495b49d0704795524fa34e8dbfc | static uint64_t do_cvttq(CPUAlphaState *env, uint64_t a, int roundmode)
{
uint64_t frac, ret = 0;
uint32_t exp, sign, exc = 0;
int shift;
sign = (a >> 63);
exp = (uint32_t)(a >> 52) & 0x7ff;
frac = a & 0xfffffffffffffull;
if (exp == 0) {
if (unlikely(frac != 0)) {
goto do_underflow;
}
} else if (exp == 0x7ff) {
exc = FPCR_INV;
} else {
frac |= 0x10000000000000ull;
shift = exp - 1023 - 52;
if (shift >= 0) {
if (shift < 64) {
ret = frac << shift;
}
if (shift >= 11 && a != 0xC3E0000000000000ull) {
exc = FPCR_IOV | FPCR_INE;
}
} else {
uint64_t round;
shift = -shift;
if (shift < 63) {
ret = frac >> shift;
round = frac << (64 - shift);
} else {
do_underflow:
round = 1;
}
if (round) {
exc = FPCR_INE;
switch (roundmode) {
case float_round_nearest_even:
if (round == (1ull << 63)) {
ret += (ret & 1);
} else if (round > (1ull << 63)) {
ret += 1;
}
break;
case float_round_to_zero:
break;
case float_round_up:
ret += 1 - sign;
break;
case float_round_down:
ret += sign;
break;
}
}
}
if (sign) {
ret = -ret;
}
}
env->error_code = exc;
return ret;
}
| {
"code": [
" if (unlikely(frac != 0)) {"
],
"line_no": [
23
]
} | static uint64_t FUNC_0(CPUAlphaState *env, uint64_t a, int roundmode)
{
uint64_t frac, ret = 0;
uint32_t exp, sign, exc = 0;
int VAR_0;
sign = (a >> 63);
exp = (uint32_t)(a >> 52) & 0x7ff;
frac = a & 0xfffffffffffffull;
if (exp == 0) {
if (unlikely(frac != 0)) {
goto do_underflow;
}
} else if (exp == 0x7ff) {
exc = FPCR_INV;
} else {
frac |= 0x10000000000000ull;
VAR_0 = exp - 1023 - 52;
if (VAR_0 >= 0) {
if (VAR_0 < 64) {
ret = frac << VAR_0;
}
if (VAR_0 >= 11 && a != 0xC3E0000000000000ull) {
exc = FPCR_IOV | FPCR_INE;
}
} else {
uint64_t round;
VAR_0 = -VAR_0;
if (VAR_0 < 63) {
ret = frac >> VAR_0;
round = frac << (64 - VAR_0);
} else {
do_underflow:
round = 1;
}
if (round) {
exc = FPCR_INE;
switch (roundmode) {
case float_round_nearest_even:
if (round == (1ull << 63)) {
ret += (ret & 1);
} else if (round > (1ull << 63)) {
ret += 1;
}
break;
case float_round_to_zero:
break;
case float_round_up:
ret += 1 - sign;
break;
case float_round_down:
ret += sign;
break;
}
}
}
if (sign) {
ret = -ret;
}
}
env->error_code = exc;
return ret;
}
| [
"static uint64_t FUNC_0(CPUAlphaState *env, uint64_t a, int roundmode)\n{",
"uint64_t frac, ret = 0;",
"uint32_t exp, sign, exc = 0;",
"int VAR_0;",
"sign = (a >> 63);",
"exp = (uint32_t)(a >> 52) & 0x7ff;",
"frac = a & 0xfffffffffffffull;",
"if (exp == 0) {",
"if (unlikely(frac != 0)) {",
"goto do_underflow;",
"}",
"} else if (exp == 0x7ff) {",
"exc = FPCR_INV;",
"} else {",
"frac |= 0x10000000000000ull;",
"VAR_0 = exp - 1023 - 52;",
"if (VAR_0 >= 0) {",
"if (VAR_0 < 64) {",
"ret = frac << VAR_0;",
"}",
"if (VAR_0 >= 11 && a != 0xC3E0000000000000ull) {",
"exc = FPCR_IOV | FPCR_INE;",
"}",
"} else {",
"uint64_t round;",
"VAR_0 = -VAR_0;",
"if (VAR_0 < 63) {",
"ret = frac >> VAR_0;",
"round = frac << (64 - VAR_0);",
"} else {",
"do_underflow:\nround = 1;",
"}",
"if (round) {",
"exc = FPCR_INE;",
"switch (roundmode) {",
"case float_round_nearest_even:\nif (round == (1ull << 63)) {",
"ret += (ret & 1);",
"} else if (round > (1ull << 63)) {",
"ret += 1;",
"}",
"break;",
"case float_round_to_zero:\nbreak;",
"case float_round_up:\nret += 1 - sign;",
"break;",
"case float_round_down:\nret += sign;",
"break;",
"}",
"}",
"}",
"if (sign) {",
"ret = -ret;",
"}",
"}",
"env->error_code = exc;",
"return ret;",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
41
],
[
43
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
93,
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107,
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123,
125
],
[
127,
129
],
[
131
],
[
133,
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
157
],
[
159
]
] |
3,244 | static inline void RENAME(rgb15to24)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint16_t *end;
#ifdef HAVE_MMX
const uint16_t *mm_end;
#endif
uint8_t *d = (uint8_t *)dst;
const uint16_t *s = (uint16_t *)src;
end = s + src_size/2;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*s):"memory");
mm_end = end - 7;
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movq %1, %%mm0\n\t"
"movq %1, %%mm1\n\t"
"movq %1, %%mm2\n\t"
"pand %2, %%mm0\n\t"
"pand %3, %%mm1\n\t"
"pand %4, %%mm2\n\t"
"psllq $3, %%mm0\n\t"
"psrlq $2, %%mm1\n\t"
"psrlq $7, %%mm2\n\t"
"movq %%mm0, %%mm3\n\t"
"movq %%mm1, %%mm4\n\t"
"movq %%mm2, %%mm5\n\t"
"punpcklwd %5, %%mm0\n\t"
"punpcklwd %5, %%mm1\n\t"
"punpcklwd %5, %%mm2\n\t"
"punpckhwd %5, %%mm3\n\t"
"punpckhwd %5, %%mm4\n\t"
"punpckhwd %5, %%mm5\n\t"
"psllq $8, %%mm1\n\t"
"psllq $16, %%mm2\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm2, %%mm0\n\t"
"psllq $8, %%mm4\n\t"
"psllq $16, %%mm5\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm5, %%mm3\n\t"
"movq %%mm0, %%mm6\n\t"
"movq %%mm3, %%mm7\n\t"
"movq 8%1, %%mm0\n\t"
"movq 8%1, %%mm1\n\t"
"movq 8%1, %%mm2\n\t"
"pand %2, %%mm0\n\t"
"pand %3, %%mm1\n\t"
"pand %4, %%mm2\n\t"
"psllq $3, %%mm0\n\t"
"psrlq $2, %%mm1\n\t"
"psrlq $7, %%mm2\n\t"
"movq %%mm0, %%mm3\n\t"
"movq %%mm1, %%mm4\n\t"
"movq %%mm2, %%mm5\n\t"
"punpcklwd %5, %%mm0\n\t"
"punpcklwd %5, %%mm1\n\t"
"punpcklwd %5, %%mm2\n\t"
"punpckhwd %5, %%mm3\n\t"
"punpckhwd %5, %%mm4\n\t"
"punpckhwd %5, %%mm5\n\t"
"psllq $8, %%mm1\n\t"
"psllq $16, %%mm2\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm2, %%mm0\n\t"
"psllq $8, %%mm4\n\t"
"psllq $16, %%mm5\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm5, %%mm3\n\t"
:"=m"(*d)
:"m"(*s),"m"(mask15b),"m"(mask15g),"m"(mask15r), "m"(mmx_null)
:"memory");
/* Borrowed 32 to 24 */
__asm __volatile(
"movq %%mm0, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"movq %%mm6, %%mm0\n\t"
"movq %%mm7, %%mm1\n\t"
"movq %%mm4, %%mm6\n\t"
"movq %%mm5, %%mm7\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm1, %%mm3\n\t"
"psrlq $8, %%mm2\n\t"
"psrlq $8, %%mm3\n\t"
"psrlq $8, %%mm6\n\t"
"psrlq $8, %%mm7\n\t"
"pand %2, %%mm0\n\t"
"pand %2, %%mm1\n\t"
"pand %2, %%mm4\n\t"
"pand %2, %%mm5\n\t"
"pand %3, %%mm2\n\t"
"pand %3, %%mm3\n\t"
"pand %3, %%mm6\n\t"
"pand %3, %%mm7\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm3, %%mm1\n\t"
"por %%mm6, %%mm4\n\t"
"por %%mm7, %%mm5\n\t"
"movq %%mm1, %%mm2\n\t"
"movq %%mm4, %%mm3\n\t"
"psllq $48, %%mm2\n\t"
"psllq $32, %%mm3\n\t"
"pand %4, %%mm2\n\t"
"pand %5, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"psrlq $16, %%mm1\n\t"
"psrlq $32, %%mm4\n\t"
"psllq $16, %%mm5\n\t"
"por %%mm3, %%mm1\n\t"
"pand %6, %%mm5\n\t"
"por %%mm5, %%mm4\n\t"
MOVNTQ" %%mm0, %0\n\t"
MOVNTQ" %%mm1, 8%0\n\t"
MOVNTQ" %%mm4, 16%0"
:"=m"(*d)
:"m"(*s),"m"(mask24l),"m"(mask24h),"m"(mask24hh),"m"(mask24hhh),"m"(mask24hhhh)
:"memory");
d += 24;
s += 8;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
register uint16_t bgr;
bgr = *s++;
*d++ = (bgr&0x1F)<<3;
*d++ = (bgr&0x3E0)>>2;
*d++ = (bgr&0x7C00)>>7;
}
}
| true | FFmpeg | 6e42e6c4b410dbef8b593c2d796a5dad95f89ee4 | static inline void RENAME(rgb15to24)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint16_t *end;
#ifdef HAVE_MMX
const uint16_t *mm_end;
#endif
uint8_t *d = (uint8_t *)dst;
const uint16_t *s = (uint16_t *)src;
end = s + src_size/2;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*s):"memory");
mm_end = end - 7;
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movq %1, %%mm0\n\t"
"movq %1, %%mm1\n\t"
"movq %1, %%mm2\n\t"
"pand %2, %%mm0\n\t"
"pand %3, %%mm1\n\t"
"pand %4, %%mm2\n\t"
"psllq $3, %%mm0\n\t"
"psrlq $2, %%mm1\n\t"
"psrlq $7, %%mm2\n\t"
"movq %%mm0, %%mm3\n\t"
"movq %%mm1, %%mm4\n\t"
"movq %%mm2, %%mm5\n\t"
"punpcklwd %5, %%mm0\n\t"
"punpcklwd %5, %%mm1\n\t"
"punpcklwd %5, %%mm2\n\t"
"punpckhwd %5, %%mm3\n\t"
"punpckhwd %5, %%mm4\n\t"
"punpckhwd %5, %%mm5\n\t"
"psllq $8, %%mm1\n\t"
"psllq $16, %%mm2\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm2, %%mm0\n\t"
"psllq $8, %%mm4\n\t"
"psllq $16, %%mm5\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm5, %%mm3\n\t"
"movq %%mm0, %%mm6\n\t"
"movq %%mm3, %%mm7\n\t"
"movq 8%1, %%mm0\n\t"
"movq 8%1, %%mm1\n\t"
"movq 8%1, %%mm2\n\t"
"pand %2, %%mm0\n\t"
"pand %3, %%mm1\n\t"
"pand %4, %%mm2\n\t"
"psllq $3, %%mm0\n\t"
"psrlq $2, %%mm1\n\t"
"psrlq $7, %%mm2\n\t"
"movq %%mm0, %%mm3\n\t"
"movq %%mm1, %%mm4\n\t"
"movq %%mm2, %%mm5\n\t"
"punpcklwd %5, %%mm0\n\t"
"punpcklwd %5, %%mm1\n\t"
"punpcklwd %5, %%mm2\n\t"
"punpckhwd %5, %%mm3\n\t"
"punpckhwd %5, %%mm4\n\t"
"punpckhwd %5, %%mm5\n\t"
"psllq $8, %%mm1\n\t"
"psllq $16, %%mm2\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm2, %%mm0\n\t"
"psllq $8, %%mm4\n\t"
"psllq $16, %%mm5\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm5, %%mm3\n\t"
:"=m"(*d)
:"m"(*s),"m"(mask15b),"m"(mask15g),"m"(mask15r), "m"(mmx_null)
:"memory");
__asm __volatile(
"movq %%mm0, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"movq %%mm6, %%mm0\n\t"
"movq %%mm7, %%mm1\n\t"
"movq %%mm4, %%mm6\n\t"
"movq %%mm5, %%mm7\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm1, %%mm3\n\t"
"psrlq $8, %%mm2\n\t"
"psrlq $8, %%mm3\n\t"
"psrlq $8, %%mm6\n\t"
"psrlq $8, %%mm7\n\t"
"pand %2, %%mm0\n\t"
"pand %2, %%mm1\n\t"
"pand %2, %%mm4\n\t"
"pand %2, %%mm5\n\t"
"pand %3, %%mm2\n\t"
"pand %3, %%mm3\n\t"
"pand %3, %%mm6\n\t"
"pand %3, %%mm7\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm3, %%mm1\n\t"
"por %%mm6, %%mm4\n\t"
"por %%mm7, %%mm5\n\t"
"movq %%mm1, %%mm2\n\t"
"movq %%mm4, %%mm3\n\t"
"psllq $48, %%mm2\n\t"
"psllq $32, %%mm3\n\t"
"pand %4, %%mm2\n\t"
"pand %5, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"psrlq $16, %%mm1\n\t"
"psrlq $32, %%mm4\n\t"
"psllq $16, %%mm5\n\t"
"por %%mm3, %%mm1\n\t"
"pand %6, %%mm5\n\t"
"por %%mm5, %%mm4\n\t"
MOVNTQ" %%mm0, %0\n\t"
MOVNTQ" %%mm1, 8%0\n\t"
MOVNTQ" %%mm4, 16%0"
:"=m"(*d)
:"m"(*s),"m"(mask24l),"m"(mask24h),"m"(mask24hh),"m"(mask24hhh),"m"(mask24hhhh)
:"memory");
d += 24;
s += 8;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
register uint16_t bgr;
bgr = *s++;
*d++ = (bgr&0x1F)<<3;
*d++ = (bgr&0x3E0)>>2;
*d++ = (bgr&0x7C00)>>7;
}
}
| {
"code": [
"\tconst uint16_t *end;",
"\tuint8_t *d = (uint8_t *)dst;",
"\tconst uint16_t *s = (uint16_t *)src;",
"\tend = s + src_size/2;",
"\twhile(s < end)",
"\t\tregister uint16_t bgr;",
"\t\tbgr = *s++;",
"\tconst uint16_t *end;",
"\tuint8_t *d = (uint8_t *)dst;",
"\tend = s + src_size/2;",
"\twhile(s < end)",
"\t\tregister uint16_t bgr;",
"\t\tbgr = *s++;",
"\t\t*d++ = (bgr&0x1F)<<3;",
"\tconst uint16_t *end;",
"\tuint8_t *d = (uint8_t *)dst;",
"\tend = s + src_size/2;",
"\twhile(s < end)",
"\t\tregister uint16_t bgr;",
"\t\tbgr = *s++;",
"\tconst uint16_t *end;",
"\tuint8_t *d = (uint8_t *)dst;",
"\tconst uint16_t *s = (uint16_t *)src;",
"\tend = s + src_size/2;",
"\twhile(s < end)",
"\t\tregister uint16_t bgr;",
"\t\tbgr = *s++;",
"\t\t*d++ = (bgr&0x7C00)>>7;",
"\t\t*d++ = (bgr&0x3E0)>>2;",
"\t\t*d++ = (bgr&0x1F)<<3;",
"#ifdef HAVE_MMX",
"#endif",
"#ifdef HAVE_MMX",
"#endif",
"#endif",
"#endif",
"\t\t\"movq\t%1, %%mm0\\n\\t\"",
"\t\t\"movq\t8%1, %%mm2\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\t:\"=m\"(*d)",
"\t\t\"movq\t%1, %%mm0\\n\\t\"",
"\t\t\"movq\t8%1, %%mm2\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\t:\"=m\"(*d)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"pand\t%2, %%mm0\\n\\t\"",
"\t\t\"psrlq\t$8, %%mm2\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"#endif",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"pand\t%2, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"pand\t%2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"#endif",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"pand\t%2, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"pand\t%2, %%mm0\\n\\t\"",
"\t\t\"psrlq\t$8, %%mm2\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"pand\t%2, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"pand\t%2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"pand\t%2, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\tconst uint16_t *end;",
"\tconst uint16_t *mm_end;",
"\tuint8_t *d = (uint8_t *)dst;",
"\tconst uint16_t *s = (uint16_t *)src;",
"\tend = s + src_size/2;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*s):\"memory\");",
"\tmm_end = end - 7;",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movq\t%1, %%mm0\\n\\t\"",
"\t\t\"movq\t%1, %%mm1\\n\\t\"",
"\t\t\"movq\t%1, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm0\\n\\t\"",
"\t\t\"pand\t%3, %%mm1\\n\\t\"",
"\t\t\"pand\t%4, %%mm2\\n\\t\"",
"\t\t\"psllq\t$3, %%mm0\\n\\t\"",
"\t\t\"psrlq\t$2, %%mm1\\n\\t\"",
"\t\t\"psrlq\t$7, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm1, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm2, %%mm5\\n\\t\"",
"\t\t\"punpcklwd %5, %%mm0\\n\\t\"",
"\t\t\"punpcklwd %5, %%mm1\\n\\t\"",
"\t\t\"punpcklwd %5, %%mm2\\n\\t\"",
"\t\t\"punpckhwd %5, %%mm3\\n\\t\"",
"\t\t\"punpckhwd %5, %%mm4\\n\\t\"",
"\t\t\"punpckhwd %5, %%mm5\\n\\t\"",
"\t\t\"psllq\t$8, %%mm1\\n\\t\"",
"\t\t\"psllq\t$16, %%mm2\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"psllq\t$8, %%mm4\\n\\t\"",
"\t\t\"psllq\t$16, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm6\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm7\\n\\t\"",
"\t\t\"movq\t8%1, %%mm0\\n\\t\"",
"\t\t\"movq\t8%1, %%mm1\\n\\t\"",
"\t\t\"movq\t8%1, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm0\\n\\t\"",
"\t\t\"pand\t%3, %%mm1\\n\\t\"",
"\t\t\"pand\t%4, %%mm2\\n\\t\"",
"\t\t\"psllq\t$3, %%mm0\\n\\t\"",
"\t\t\"psrlq\t$2, %%mm1\\n\\t\"",
"\t\t\"psrlq\t$7, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm1, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm2, %%mm5\\n\\t\"",
"\t\t\"punpcklwd %5, %%mm0\\n\\t\"",
"\t\t\"punpcklwd %5, %%mm1\\n\\t\"",
"\t\t\"punpcklwd %5, %%mm2\\n\\t\"",
"\t\t\"punpckhwd %5, %%mm3\\n\\t\"",
"\t\t\"punpckhwd %5, %%mm4\\n\\t\"",
"\t\t\"punpckhwd %5, %%mm5\\n\\t\"",
"\t\t\"psllq\t$8, %%mm1\\n\\t\"",
"\t\t\"psllq\t$16, %%mm2\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"psllq\t$8, %%mm4\\n\\t\"",
"\t\t\"psllq\t$16, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t:\"=m\"(*d)",
"\t\t:\"m\"(*s),\"m\"(mask15b),\"m\"(mask15g),\"m\"(mask15r), \"m\"(mmx_null)",
"\t\t:\"memory\");",
"\t __asm __volatile(",
"\t\t\"movq\t%%mm0, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"movq\t%%mm6, %%mm0\\n\\t\"",
"\t\t\"movq\t%%mm7, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm4, %%mm6\\n\\t\"",
"\t\t\"movq\t%%mm5, %%mm7\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm1, %%mm3\\n\\t\"",
"\t\t\"psrlq\t$8, %%mm2\\n\\t\"",
"\t\t\"psrlq\t$8, %%mm3\\n\\t\"",
"\t\t\"psrlq\t$8, %%mm6\\n\\t\"",
"\t\t\"psrlq\t$8, %%mm7\\n\\t\"",
"\t\t\"pand\t%2, %%mm0\\n\\t\"",
"\t\t\"pand\t%2, %%mm1\\n\\t\"",
"\t\t\"pand\t%2, %%mm4\\n\\t\"",
"\t\t\"pand\t%2, %%mm5\\n\\t\"",
"\t\t\"pand\t%3, %%mm2\\n\\t\"",
"\t\t\"pand\t%3, %%mm3\\n\\t\"",
"\t\t\"pand\t%3, %%mm6\\n\\t\"",
"\t\t\"pand\t%3, %%mm7\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm1\\n\\t\"",
"\t\t\"por\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"por\t%%mm7, %%mm5\\n\\t\"",
"\t\t\"movq\t%%mm1, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"psllq\t$48, %%mm2\\n\\t\"",
"\t\t\"psllq\t$32, %%mm3\\n\\t\"",
"\t\t\"pand\t%4, %%mm2\\n\\t\"",
"\t\t\"pand\t%5, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"psrlq\t$16, %%mm1\\n\\t\"",
"\t\t\"psrlq\t$32, %%mm4\\n\\t\"",
"\t\t\"psllq\t$16, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm1\\n\\t\"",
"\t\t\"pand\t%6, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm4\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm1, 8%0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm4, 16%0\"",
"\t\t:\"=m\"(*d)",
"\t\t:\"m\"(*s),\"m\"(mask24l),\"m\"(mask24h),\"m\"(mask24hh),\"m\"(mask24hhh),\"m\"(mask24hhhh)",
"\t\t:\"memory\");",
"\t\td += 24;",
"\t\ts += 8;",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\t\tregister uint16_t bgr;",
"\t\tbgr = *s++;",
"\t\t*d++ = (bgr&0x1F)<<3;",
"\t\t*d++ = (bgr&0x3E0)>>2;",
"\t\t*d++ = (bgr&0x7C00)>>7;",
"\tconst uint16_t *end;",
"\tconst uint16_t *mm_end;",
"\tuint8_t *d = (uint8_t *)dst;",
"\tend = s + src_size/2;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*s):\"memory\");",
"\tmm_end = end - 7;",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movq\t%1, %%mm0\\n\\t\"",
"\t\t\"movq\t%1, %%mm1\\n\\t\"",
"\t\t\"movq\t%1, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm0\\n\\t\"",
"\t\t\"pand\t%3, %%mm1\\n\\t\"",
"\t\t\"pand\t%4, %%mm2\\n\\t\"",
"\t\t\"psllq\t$3, %%mm0\\n\\t\"",
"\t\t\"psrlq\t$8, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm1, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm2, %%mm5\\n\\t\"",
"\t\t\"punpcklwd %5, %%mm0\\n\\t\"",
"\t\t\"punpcklwd %5, %%mm1\\n\\t\"",
"\t\t\"punpcklwd %5, %%mm2\\n\\t\"",
"\t\t\"punpckhwd %5, %%mm3\\n\\t\"",
"\t\t\"punpckhwd %5, %%mm4\\n\\t\"",
"\t\t\"punpckhwd %5, %%mm5\\n\\t\"",
"\t\t\"psllq\t$8, %%mm1\\n\\t\"",
"\t\t\"psllq\t$16, %%mm2\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"psllq\t$8, %%mm4\\n\\t\"",
"\t\t\"psllq\t$16, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm6\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm7\\n\\t\"",
"\t\t\"movq\t8%1, %%mm0\\n\\t\"",
"\t\t\"movq\t8%1, %%mm1\\n\\t\"",
"\t\t\"movq\t8%1, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm0\\n\\t\"",
"\t\t\"pand\t%3, %%mm1\\n\\t\"",
"\t\t\"pand\t%4, %%mm2\\n\\t\"",
"\t\t\"psllq\t$3, %%mm0\\n\\t\"",
"\t\t\"psrlq\t$8, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm1, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm2, %%mm5\\n\\t\"",
"\t\t\"punpcklwd %5, %%mm0\\n\\t\"",
"\t\t\"punpcklwd %5, %%mm1\\n\\t\"",
"\t\t\"punpcklwd %5, %%mm2\\n\\t\"",
"\t\t\"punpckhwd %5, %%mm3\\n\\t\"",
"\t\t\"punpckhwd %5, %%mm4\\n\\t\"",
"\t\t\"punpckhwd %5, %%mm5\\n\\t\"",
"\t\t\"psllq\t$8, %%mm1\\n\\t\"",
"\t\t\"psllq\t$16, %%mm2\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"psllq\t$8, %%mm4\\n\\t\"",
"\t\t\"psllq\t$16, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t:\"=m\"(*d)",
"\t\t:\"memory\");",
"\t __asm __volatile(",
"\t\t\"movq\t%%mm0, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"movq\t%%mm6, %%mm0\\n\\t\"",
"\t\t\"movq\t%%mm7, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm4, %%mm6\\n\\t\"",
"\t\t\"movq\t%%mm5, %%mm7\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm1, %%mm3\\n\\t\"",
"\t\t\"psrlq\t$8, %%mm2\\n\\t\"",
"\t\t\"psrlq\t$8, %%mm3\\n\\t\"",
"\t\t\"psrlq\t$8, %%mm6\\n\\t\"",
"\t\t\"psrlq\t$8, %%mm7\\n\\t\"",
"\t\t\"pand\t%2, %%mm0\\n\\t\"",
"\t\t\"pand\t%2, %%mm1\\n\\t\"",
"\t\t\"pand\t%2, %%mm4\\n\\t\"",
"\t\t\"pand\t%2, %%mm5\\n\\t\"",
"\t\t\"pand\t%3, %%mm2\\n\\t\"",
"\t\t\"pand\t%3, %%mm3\\n\\t\"",
"\t\t\"pand\t%3, %%mm6\\n\\t\"",
"\t\t\"pand\t%3, %%mm7\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm1\\n\\t\"",
"\t\t\"por\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"por\t%%mm7, %%mm5\\n\\t\"",
"\t\t\"movq\t%%mm1, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"psllq\t$48, %%mm2\\n\\t\"",
"\t\t\"psllq\t$32, %%mm3\\n\\t\"",
"\t\t\"pand\t%4, %%mm2\\n\\t\"",
"\t\t\"pand\t%5, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"psrlq\t$16, %%mm1\\n\\t\"",
"\t\t\"psrlq\t$32, %%mm4\\n\\t\"",
"\t\t\"psllq\t$16, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm1\\n\\t\"",
"\t\t\"pand\t%6, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm4\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm1, 8%0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm4, 16%0\"",
"\t\t:\"=m\"(*d)",
"\t\t:\"m\"(*s),\"m\"(mask24l),\"m\"(mask24h),\"m\"(mask24hh),\"m\"(mask24hhh),\"m\"(mask24hhhh)",
"\t\t:\"memory\");",
"\t\td += 24;",
"\t\ts += 8;",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\t\tregister uint16_t bgr;",
"\t\tbgr = *s++;",
"\t\t*d++ = (bgr&0x1F)<<3;",
"\tconst uint16_t *end;",
"\tconst uint16_t *mm_end;",
"\tuint8_t *d = (uint8_t *)dst;",
"\tend = s + src_size/2;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*s):\"memory\");",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movq\t%1, %%mm0\\n\\t\"",
"\t\t\"movq\t%1, %%mm1\\n\\t\"",
"\t\t\"movq\t%1, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm0\\n\\t\"",
"\t\t\"pand\t%3, %%mm1\\n\\t\"",
"\t\t\"pand\t%4, %%mm2\\n\\t\"",
"\t\t\"psllq\t$3, %%mm0\\n\\t\"",
"\t\t\"psrlq\t$2, %%mm1\\n\\t\"",
"\t\t\"psrlq\t$7, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm1, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm2, %%mm5\\n\\t\"",
"\t\t\"psllq\t$8, %%mm1\\n\\t\"",
"\t\t\"psllq\t$16, %%mm2\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"psllq\t$8, %%mm4\\n\\t\"",
"\t\t\"psllq\t$16, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\t:\"=m\"(*d)",
"\t\t:\"memory\");",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\t\tregister uint16_t bgr;",
"\t\tbgr = *s++;",
"\t\t*d++ = (bgr&0x7C00)>>7;",
"\t\t*d++ = (bgr&0x3E0)>>2;",
"\t\t*d++ = (bgr&0x1F)<<3;",
"\t\t*d++ = (bgr&0x1F)<<3;",
"\t\t*d++ = (bgr&0x3E0)>>2;",
"\t\t*d++ = (bgr&0x7C00)>>7;",
"\tconst uint16_t *end;",
"\tconst uint16_t *mm_end;",
"\tuint8_t *d = (uint8_t *)dst;",
"\tconst uint16_t *s = (uint16_t *)src;",
"\tend = s + src_size/2;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*s):\"memory\");",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movq\t%1, %%mm0\\n\\t\"",
"\t\t\"movq\t%1, %%mm1\\n\\t\"",
"\t\t\"movq\t%1, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm0\\n\\t\"",
"\t\t\"pand\t%3, %%mm1\\n\\t\"",
"\t\t\"pand\t%4, %%mm2\\n\\t\"",
"\t\t\"psllq\t$3, %%mm0\\n\\t\"",
"\t\t\"psrlq\t$8, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm1, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm2, %%mm5\\n\\t\"",
"\t\t\"psllq\t$8, %%mm1\\n\\t\"",
"\t\t\"psllq\t$16, %%mm2\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"psllq\t$8, %%mm4\\n\\t\"",
"\t\t\"psllq\t$16, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\t:\"=m\"(*d)",
"\t\t:\"memory\");",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\t\tregister uint16_t bgr;",
"\t\tbgr = *s++;",
"\t\t*d++ = (bgr&0x1F)<<3;",
"\t\t*d++ = (bgr&0x1F)<<3;",
"#endif",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm1, 8%0\\n\\t\"",
"\t\t:\"memory\");",
"#endif",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm1, 8%0\\n\\t\"",
"\t\t:\"memory\");",
"#endif",
"\t\t\"movq\t%%mm0, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm4, %%mm6\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm3\\n\\t\"",
"\t\t:\"memory\");",
"#endif"
],
"line_no": [
5,
13,
15,
17,
265,
269,
271,
5,
13,
17,
265,
269,
271,
273,
5,
13,
17,
265,
269,
271,
5,
13,
15,
17,
265,
269,
271,
277,
275,
273,
7,
11,
7,
11,
11,
11,
33,
97,
239,
147,
33,
97,
73,
239,
147,
25,
29,
31,
171,
159,
39,
177,
73,
81,
75,
83,
239,
11,
259,
261,
11,
265,
25,
29,
31,
171,
159,
191,
73,
81,
75,
83,
239,
259,
261,
11,
265,
25,
29,
31,
171,
159,
39,
73,
81,
75,
83,
239,
11,
259,
261,
11,
265,
25,
29,
31,
171,
159,
191,
73,
81,
75,
83,
239,
259,
261,
11,
265,
25,
29,
31,
171,
159,
39,
177,
73,
81,
75,
83,
239,
259,
261,
11,
265,
25,
29,
31,
171,
159,
191,
73,
81,
75,
83,
239,
259,
261,
11,
265,
25,
29,
31,
171,
159,
39,
73,
81,
75,
83,
239,
259,
261,
11,
265,
25,
29,
31,
171,
159,
191,
73,
81,
75,
83,
239,
259,
261,
11,
265,
5,
9,
13,
15,
17,
21,
23,
25,
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,
87,
89,
93,
95,
97,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,
79,
81,
83,
147,
149,
151,
29,
157,
159,
161,
163,
167,
169,
171,
173,
177,
179,
181,
183,
39,
187,
189,
191,
193,
195,
197,
199,
75,
203,
205,
207,
211,
213,
215,
217,
43,
221,
75,
225,
227,
79,
203,
233,
235,
239,
241,
243,
147,
249,
151,
253,
255,
259,
261,
11,
265,
269,
271,
273,
275,
277,
5,
9,
13,
17,
21,
23,
25,
29,
31,
33,
35,
37,
39,
41,
43,
45,
177,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,
79,
81,
83,
87,
89,
93,
95,
97,
39,
41,
43,
45,
177,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,
79,
81,
83,
147,
151,
29,
157,
159,
161,
163,
167,
169,
171,
173,
177,
179,
181,
183,
39,
187,
189,
191,
193,
195,
197,
199,
75,
203,
205,
207,
211,
213,
215,
217,
43,
221,
75,
225,
227,
79,
203,
233,
235,
239,
241,
243,
147,
249,
151,
253,
255,
259,
261,
11,
265,
269,
271,
273,
5,
9,
13,
17,
21,
25,
29,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
69,
71,
73,
75,
77,
79,
81,
83,
239,
147,
151,
259,
261,
11,
265,
269,
271,
277,
275,
273,
273,
275,
277,
5,
9,
13,
15,
17,
21,
25,
29,
31,
33,
35,
37,
39,
41,
43,
45,
177,
51,
53,
55,
69,
71,
73,
75,
77,
79,
81,
83,
239,
147,
151,
259,
261,
11,
265,
269,
271,
273,
273,
11,
259,
261,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
31,
239,
241,
151,
11,
31,
239,
241,
151,
11,
51,
167,
51,
51,
151,
11
]
} | static inline void FUNC_0(rgb15to24)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint16_t *VAR_0;
#ifdef HAVE_MMX
const uint16_t *mm_end;
#endif
uint8_t *d = (uint8_t *)dst;
const uint16_t *VAR_1 = (uint16_t *)src;
VAR_0 = VAR_1 + src_size/2;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*VAR_1):"memory");
mm_end = VAR_0 - 7;
while(VAR_1 < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movq %1, %%mm0\n\t"
"movq %1, %%mm1\n\t"
"movq %1, %%mm2\n\t"
"pand %2, %%mm0\n\t"
"pand %3, %%mm1\n\t"
"pand %4, %%mm2\n\t"
"psllq $3, %%mm0\n\t"
"psrlq $2, %%mm1\n\t"
"psrlq $7, %%mm2\n\t"
"movq %%mm0, %%mm3\n\t"
"movq %%mm1, %%mm4\n\t"
"movq %%mm2, %%mm5\n\t"
"punpcklwd %5, %%mm0\n\t"
"punpcklwd %5, %%mm1\n\t"
"punpcklwd %5, %%mm2\n\t"
"punpckhwd %5, %%mm3\n\t"
"punpckhwd %5, %%mm4\n\t"
"punpckhwd %5, %%mm5\n\t"
"psllq $8, %%mm1\n\t"
"psllq $16, %%mm2\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm2, %%mm0\n\t"
"psllq $8, %%mm4\n\t"
"psllq $16, %%mm5\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm5, %%mm3\n\t"
"movq %%mm0, %%mm6\n\t"
"movq %%mm3, %%mm7\n\t"
"movq 8%1, %%mm0\n\t"
"movq 8%1, %%mm1\n\t"
"movq 8%1, %%mm2\n\t"
"pand %2, %%mm0\n\t"
"pand %3, %%mm1\n\t"
"pand %4, %%mm2\n\t"
"psllq $3, %%mm0\n\t"
"psrlq $2, %%mm1\n\t"
"psrlq $7, %%mm2\n\t"
"movq %%mm0, %%mm3\n\t"
"movq %%mm1, %%mm4\n\t"
"movq %%mm2, %%mm5\n\t"
"punpcklwd %5, %%mm0\n\t"
"punpcklwd %5, %%mm1\n\t"
"punpcklwd %5, %%mm2\n\t"
"punpckhwd %5, %%mm3\n\t"
"punpckhwd %5, %%mm4\n\t"
"punpckhwd %5, %%mm5\n\t"
"psllq $8, %%mm1\n\t"
"psllq $16, %%mm2\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm2, %%mm0\n\t"
"psllq $8, %%mm4\n\t"
"psllq $16, %%mm5\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm5, %%mm3\n\t"
:"=m"(*d)
:"m"(*VAR_1),"m"(mask15b),"m"(mask15g),"m"(mask15r), "m"(mmx_null)
:"memory");
__asm __volatile(
"movq %%mm0, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"movq %%mm6, %%mm0\n\t"
"movq %%mm7, %%mm1\n\t"
"movq %%mm4, %%mm6\n\t"
"movq %%mm5, %%mm7\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm1, %%mm3\n\t"
"psrlq $8, %%mm2\n\t"
"psrlq $8, %%mm3\n\t"
"psrlq $8, %%mm6\n\t"
"psrlq $8, %%mm7\n\t"
"pand %2, %%mm0\n\t"
"pand %2, %%mm1\n\t"
"pand %2, %%mm4\n\t"
"pand %2, %%mm5\n\t"
"pand %3, %%mm2\n\t"
"pand %3, %%mm3\n\t"
"pand %3, %%mm6\n\t"
"pand %3, %%mm7\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm3, %%mm1\n\t"
"por %%mm6, %%mm4\n\t"
"por %%mm7, %%mm5\n\t"
"movq %%mm1, %%mm2\n\t"
"movq %%mm4, %%mm3\n\t"
"psllq $48, %%mm2\n\t"
"psllq $32, %%mm3\n\t"
"pand %4, %%mm2\n\t"
"pand %5, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"psrlq $16, %%mm1\n\t"
"psrlq $32, %%mm4\n\t"
"psllq $16, %%mm5\n\t"
"por %%mm3, %%mm1\n\t"
"pand %6, %%mm5\n\t"
"por %%mm5, %%mm4\n\t"
MOVNTQ" %%mm0, %0\n\t"
MOVNTQ" %%mm1, 8%0\n\t"
MOVNTQ" %%mm4, 16%0"
:"=m"(*d)
:"m"(*VAR_1),"m"(mask24l),"m"(mask24h),"m"(mask24hh),"m"(mask24hhh),"m"(mask24hhhh)
:"memory");
d += 24;
VAR_1 += 8;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(VAR_1 < VAR_0)
{
register uint16_t VAR_2;
VAR_2 = *VAR_1++;
*d++ = (VAR_2&0x1F)<<3;
*d++ = (VAR_2&0x3E0)>>2;
*d++ = (VAR_2&0x7C00)>>7;
}
}
| [
"static inline void FUNC_0(rgb15to24)(const uint8_t *src, uint8_t *dst, long src_size)\n{",
"const uint16_t *VAR_0;",
"#ifdef HAVE_MMX\nconst uint16_t *mm_end;",
"#endif\nuint8_t *d = (uint8_t *)dst;",
"const uint16_t *VAR_1 = (uint16_t *)src;",
"VAR_0 = VAR_1 + src_size/2;",
"#ifdef HAVE_MMX\n__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*VAR_1):\"memory\");",
"mm_end = VAR_0 - 7;",
"while(VAR_1 < mm_end)\n{",
"__asm __volatile(\nPREFETCH\" 32%1\\n\\t\"\n\"movq\t%1, %%mm0\\n\\t\"\n\"movq\t%1, %%mm1\\n\\t\"\n\"movq\t%1, %%mm2\\n\\t\"\n\"pand\t%2, %%mm0\\n\\t\"\n\"pand\t%3, %%mm1\\n\\t\"\n\"pand\t%4, %%mm2\\n\\t\"\n\"psllq\t$3, %%mm0\\n\\t\"\n\"psrlq\t$2, %%mm1\\n\\t\"\n\"psrlq\t$7, %%mm2\\n\\t\"\n\"movq\t%%mm0, %%mm3\\n\\t\"\n\"movq\t%%mm1, %%mm4\\n\\t\"\n\"movq\t%%mm2, %%mm5\\n\\t\"\n\"punpcklwd %5, %%mm0\\n\\t\"\n\"punpcklwd %5, %%mm1\\n\\t\"\n\"punpcklwd %5, %%mm2\\n\\t\"\n\"punpckhwd %5, %%mm3\\n\\t\"\n\"punpckhwd %5, %%mm4\\n\\t\"\n\"punpckhwd %5, %%mm5\\n\\t\"\n\"psllq\t$8, %%mm1\\n\\t\"\n\"psllq\t$16, %%mm2\\n\\t\"\n\"por\t%%mm1, %%mm0\\n\\t\"\n\"por\t%%mm2, %%mm0\\n\\t\"\n\"psllq\t$8, %%mm4\\n\\t\"\n\"psllq\t$16, %%mm5\\n\\t\"\n\"por\t%%mm4, %%mm3\\n\\t\"\n\"por\t%%mm5, %%mm3\\n\\t\"\n\"movq\t%%mm0, %%mm6\\n\\t\"\n\"movq\t%%mm3, %%mm7\\n\\t\"\n\"movq\t8%1, %%mm0\\n\\t\"\n\"movq\t8%1, %%mm1\\n\\t\"\n\"movq\t8%1, %%mm2\\n\\t\"\n\"pand\t%2, %%mm0\\n\\t\"\n\"pand\t%3, %%mm1\\n\\t\"\n\"pand\t%4, %%mm2\\n\\t\"\n\"psllq\t$3, %%mm0\\n\\t\"\n\"psrlq\t$2, %%mm1\\n\\t\"\n\"psrlq\t$7, %%mm2\\n\\t\"\n\"movq\t%%mm0, %%mm3\\n\\t\"\n\"movq\t%%mm1, %%mm4\\n\\t\"\n\"movq\t%%mm2, %%mm5\\n\\t\"\n\"punpcklwd %5, %%mm0\\n\\t\"\n\"punpcklwd %5, %%mm1\\n\\t\"\n\"punpcklwd %5, %%mm2\\n\\t\"\n\"punpckhwd %5, %%mm3\\n\\t\"\n\"punpckhwd %5, %%mm4\\n\\t\"\n\"punpckhwd %5, %%mm5\\n\\t\"\n\"psllq\t$8, %%mm1\\n\\t\"\n\"psllq\t$16, %%mm2\\n\\t\"\n\"por\t%%mm1, %%mm0\\n\\t\"\n\"por\t%%mm2, %%mm0\\n\\t\"\n\"psllq\t$8, %%mm4\\n\\t\"\n\"psllq\t$16, %%mm5\\n\\t\"\n\"por\t%%mm4, %%mm3\\n\\t\"\n\"por\t%%mm5, %%mm3\\n\\t\"\n:\"=m\"(*d)\n:\"m\"(*VAR_1),\"m\"(mask15b),\"m\"(mask15g),\"m\"(mask15r), \"m\"(mmx_null)\n:\"memory\");",
"__asm __volatile(\n\"movq\t%%mm0, %%mm4\\n\\t\"\n\"movq\t%%mm3, %%mm5\\n\\t\"\n\"movq\t%%mm6, %%mm0\\n\\t\"\n\"movq\t%%mm7, %%mm1\\n\\t\"\n\"movq\t%%mm4, %%mm6\\n\\t\"\n\"movq\t%%mm5, %%mm7\\n\\t\"\n\"movq\t%%mm0, %%mm2\\n\\t\"\n\"movq\t%%mm1, %%mm3\\n\\t\"\n\"psrlq\t$8, %%mm2\\n\\t\"\n\"psrlq\t$8, %%mm3\\n\\t\"\n\"psrlq\t$8, %%mm6\\n\\t\"\n\"psrlq\t$8, %%mm7\\n\\t\"\n\"pand\t%2, %%mm0\\n\\t\"\n\"pand\t%2, %%mm1\\n\\t\"\n\"pand\t%2, %%mm4\\n\\t\"\n\"pand\t%2, %%mm5\\n\\t\"\n\"pand\t%3, %%mm2\\n\\t\"\n\"pand\t%3, %%mm3\\n\\t\"\n\"pand\t%3, %%mm6\\n\\t\"\n\"pand\t%3, %%mm7\\n\\t\"\n\"por\t%%mm2, %%mm0\\n\\t\"\n\"por\t%%mm3, %%mm1\\n\\t\"\n\"por\t%%mm6, %%mm4\\n\\t\"\n\"por\t%%mm7, %%mm5\\n\\t\"\n\"movq\t%%mm1, %%mm2\\n\\t\"\n\"movq\t%%mm4, %%mm3\\n\\t\"\n\"psllq\t$48, %%mm2\\n\\t\"\n\"psllq\t$32, %%mm3\\n\\t\"\n\"pand\t%4, %%mm2\\n\\t\"\n\"pand\t%5, %%mm3\\n\\t\"\n\"por\t%%mm2, %%mm0\\n\\t\"\n\"psrlq\t$16, %%mm1\\n\\t\"\n\"psrlq\t$32, %%mm4\\n\\t\"\n\"psllq\t$16, %%mm5\\n\\t\"\n\"por\t%%mm3, %%mm1\\n\\t\"\n\"pand\t%6, %%mm5\\n\\t\"\n\"por\t%%mm5, %%mm4\\n\\t\"\nMOVNTQ\"\t%%mm0, %0\\n\\t\"\nMOVNTQ\"\t%%mm1, 8%0\\n\\t\"\nMOVNTQ\"\t%%mm4, 16%0\"\n:\"=m\"(*d)\n:\"m\"(*VAR_1),\"m\"(mask24l),\"m\"(mask24h),\"m\"(mask24hh),\"m\"(mask24hhh),\"m\"(mask24hhhh)\n:\"memory\");",
"d += 24;",
"VAR_1 += 8;",
"}",
"__asm __volatile(SFENCE:::\"memory\");",
"__asm __volatile(EMMS:::\"memory\");",
"#endif\nwhile(VAR_1 < VAR_0)\n{",
"register uint16_t VAR_2;",
"VAR_2 = *VAR_1++;",
"*d++ = (VAR_2&0x1F)<<3;",
"*d++ = (VAR_2&0x3E0)>>2;",
"*d++ = (VAR_2&0x7C00)>>7;",
"}",
"}"
] | [
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11,
13
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
25,
27
],
[
29,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,
79,
81,
83,
87,
89,
93,
95,
97,
99,
101,
103,
105,
107,
109,
111,
113,
115,
117,
119,
121,
123,
125,
127,
129,
131,
133,
135,
137,
139,
141,
143,
147,
149,
151
],
[
155,
157,
159,
161,
163,
167,
169,
171,
173,
177,
179,
181,
183,
185,
187,
189,
191,
193,
195,
197,
199,
201,
203,
205,
207,
211,
213,
215,
217,
219,
221,
223,
225,
227,
229,
231,
233,
235,
239,
241,
243,
247,
249,
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263,
265,
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
]
] |
3,245 | static int pick_geometry(FDrive *drv)
{
BlockBackend *blk = drv->blk;
const FDFormat *parse;
uint64_t nb_sectors, size;
int i;
int match, size_match, type_match;
bool magic = drv->drive == FLOPPY_DRIVE_TYPE_AUTO;
/* We can only pick a geometry if we have a diskette. */
if (!drv->blk || !blk_is_inserted(drv->blk) ||
drv->drive == FLOPPY_DRIVE_TYPE_NONE)
{
return -1;
}
/* We need to determine the likely geometry of the inserted medium.
* In order of preference, we look for:
* (1) The same drive type and number of sectors,
* (2) The same diskette size and number of sectors,
* (3) The same drive type.
*
* In all cases, matches that occur higher in the drive table will take
* precedence over matches that occur later in the table.
*/
blk_get_geometry(blk, &nb_sectors);
match = size_match = type_match = -1;
for (i = 0; ; i++) {
parse = &fd_formats[i];
if (parse->drive == FLOPPY_DRIVE_TYPE_NONE) {
break;
}
size = (parse->max_head + 1) * parse->max_track * parse->last_sect;
if (nb_sectors == size) {
if (magic || parse->drive == drv->drive) {
/* (1) perfect match -- nb_sectors and drive type */
goto out;
} else if (drive_size(parse->drive) == drive_size(drv->drive)) {
/* (2) size match -- nb_sectors and physical medium size */
match = (match == -1) ? i : match;
} else {
/* This is suspicious -- Did the user misconfigure? */
size_match = (size_match == -1) ? i : size_match;
}
} else if (type_match == -1) {
if ((parse->drive == drv->drive) ||
(magic && (parse->drive == get_fallback_drive_type(drv)))) {
/* (3) type match -- nb_sectors mismatch, but matches the type
* specified explicitly by the user, or matches the fallback
* default type when using the drive autodetect mechanism */
type_match = i;
}
}
}
/* No exact match found */
if (match == -1) {
if (size_match != -1) {
parse = &fd_formats[size_match];
FLOPPY_DPRINTF("User requested floppy drive type '%s', "
"but inserted medium appears to be a "
"%d sector '%s' type\n",
FloppyDriveType_lookup[drv->drive],
nb_sectors,
FloppyDriveType_lookup[parse->drive]);
}
match = type_match;
}
/* No match of any kind found -- fd_format is misconfigured, abort. */
if (match == -1) {
error_setg(&error_abort, "No candidate geometries present in table "
" for floppy drive type '%s'",
FloppyDriveType_lookup[drv->drive]);
}
parse = &(fd_formats[match]);
out:
if (parse->max_head == 0) {
drv->flags &= ~FDISK_DBL_SIDES;
} else {
drv->flags |= FDISK_DBL_SIDES;
}
drv->max_track = parse->max_track;
drv->last_sect = parse->last_sect;
drv->disk = parse->drive;
drv->media_rate = parse->rate;
return 0;
}
| true | qemu | c691320faa6a1749042134716a628e22abb81ed2 | static int pick_geometry(FDrive *drv)
{
BlockBackend *blk = drv->blk;
const FDFormat *parse;
uint64_t nb_sectors, size;
int i;
int match, size_match, type_match;
bool magic = drv->drive == FLOPPY_DRIVE_TYPE_AUTO;
if (!drv->blk || !blk_is_inserted(drv->blk) ||
drv->drive == FLOPPY_DRIVE_TYPE_NONE)
{
return -1;
}
blk_get_geometry(blk, &nb_sectors);
match = size_match = type_match = -1;
for (i = 0; ; i++) {
parse = &fd_formats[i];
if (parse->drive == FLOPPY_DRIVE_TYPE_NONE) {
break;
}
size = (parse->max_head + 1) * parse->max_track * parse->last_sect;
if (nb_sectors == size) {
if (magic || parse->drive == drv->drive) {
goto out;
} else if (drive_size(parse->drive) == drive_size(drv->drive)) {
match = (match == -1) ? i : match;
} else {
size_match = (size_match == -1) ? i : size_match;
}
} else if (type_match == -1) {
if ((parse->drive == drv->drive) ||
(magic && (parse->drive == get_fallback_drive_type(drv)))) {
type_match = i;
}
}
}
if (match == -1) {
if (size_match != -1) {
parse = &fd_formats[size_match];
FLOPPY_DPRINTF("User requested floppy drive type '%s', "
"but inserted medium appears to be a "
"%d sector '%s' type\n",
FloppyDriveType_lookup[drv->drive],
nb_sectors,
FloppyDriveType_lookup[parse->drive]);
}
match = type_match;
}
if (match == -1) {
error_setg(&error_abort, "No candidate geometries present in table "
" for floppy drive type '%s'",
FloppyDriveType_lookup[drv->drive]);
}
parse = &(fd_formats[match]);
out:
if (parse->max_head == 0) {
drv->flags &= ~FDISK_DBL_SIDES;
} else {
drv->flags |= FDISK_DBL_SIDES;
}
drv->max_track = parse->max_track;
drv->last_sect = parse->last_sect;
drv->disk = parse->drive;
drv->media_rate = parse->rate;
return 0;
}
| {
"code": [
" \"%d sector '%s' type\\n\","
],
"line_no": [
123
]
} | static int FUNC_0(FDrive *VAR_0)
{
BlockBackend *blk = VAR_0->blk;
const FDFormat *VAR_1;
uint64_t nb_sectors, size;
int VAR_2;
int VAR_3, VAR_4, VAR_5;
bool magic = VAR_0->drive == FLOPPY_DRIVE_TYPE_AUTO;
if (!VAR_0->blk || !blk_is_inserted(VAR_0->blk) ||
VAR_0->drive == FLOPPY_DRIVE_TYPE_NONE)
{
return -1;
}
blk_get_geometry(blk, &nb_sectors);
VAR_3 = VAR_4 = VAR_5 = -1;
for (VAR_2 = 0; ; VAR_2++) {
VAR_1 = &fd_formats[VAR_2];
if (VAR_1->drive == FLOPPY_DRIVE_TYPE_NONE) {
break;
}
size = (VAR_1->max_head + 1) * VAR_1->max_track * VAR_1->last_sect;
if (nb_sectors == size) {
if (magic || VAR_1->drive == VAR_0->drive) {
goto out;
} else if (drive_size(VAR_1->drive) == drive_size(VAR_0->drive)) {
VAR_3 = (VAR_3 == -1) ? VAR_2 : VAR_3;
} else {
VAR_4 = (VAR_4 == -1) ? VAR_2 : VAR_4;
}
} else if (VAR_5 == -1) {
if ((VAR_1->drive == VAR_0->drive) ||
(magic && (VAR_1->drive == get_fallback_drive_type(VAR_0)))) {
VAR_5 = VAR_2;
}
}
}
if (VAR_3 == -1) {
if (VAR_4 != -1) {
VAR_1 = &fd_formats[VAR_4];
FLOPPY_DPRINTF("User requested floppy drive type '%s', "
"but inserted medium appears to be a "
"%d sector '%s' type\n",
FloppyDriveType_lookup[VAR_0->drive],
nb_sectors,
FloppyDriveType_lookup[VAR_1->drive]);
}
VAR_3 = VAR_5;
}
if (VAR_3 == -1) {
error_setg(&error_abort, "No candidate geometries present in table "
" for floppy drive type '%s'",
FloppyDriveType_lookup[VAR_0->drive]);
}
VAR_1 = &(fd_formats[VAR_3]);
out:
if (VAR_1->max_head == 0) {
VAR_0->flags &= ~FDISK_DBL_SIDES;
} else {
VAR_0->flags |= FDISK_DBL_SIDES;
}
VAR_0->max_track = VAR_1->max_track;
VAR_0->last_sect = VAR_1->last_sect;
VAR_0->disk = VAR_1->drive;
VAR_0->media_rate = VAR_1->rate;
return 0;
}
| [
"static int FUNC_0(FDrive *VAR_0)\n{",
"BlockBackend *blk = VAR_0->blk;",
"const FDFormat *VAR_1;",
"uint64_t nb_sectors, size;",
"int VAR_2;",
"int VAR_3, VAR_4, VAR_5;",
"bool magic = VAR_0->drive == FLOPPY_DRIVE_TYPE_AUTO;",
"if (!VAR_0->blk || !blk_is_inserted(VAR_0->blk) ||\nVAR_0->drive == FLOPPY_DRIVE_TYPE_NONE)\n{",
"return -1;",
"}",
"blk_get_geometry(blk, &nb_sectors);",
"VAR_3 = VAR_4 = VAR_5 = -1;",
"for (VAR_2 = 0; ; VAR_2++) {",
"VAR_1 = &fd_formats[VAR_2];",
"if (VAR_1->drive == FLOPPY_DRIVE_TYPE_NONE) {",
"break;",
"}",
"size = (VAR_1->max_head + 1) * VAR_1->max_track * VAR_1->last_sect;",
"if (nb_sectors == size) {",
"if (magic || VAR_1->drive == VAR_0->drive) {",
"goto out;",
"} else if (drive_size(VAR_1->drive) == drive_size(VAR_0->drive)) {",
"VAR_3 = (VAR_3 == -1) ? VAR_2 : VAR_3;",
"} else {",
"VAR_4 = (VAR_4 == -1) ? VAR_2 : VAR_4;",
"}",
"} else if (VAR_5 == -1) {",
"if ((VAR_1->drive == VAR_0->drive) ||\n(magic && (VAR_1->drive == get_fallback_drive_type(VAR_0)))) {",
"VAR_5 = VAR_2;",
"}",
"}",
"}",
"if (VAR_3 == -1) {",
"if (VAR_4 != -1) {",
"VAR_1 = &fd_formats[VAR_4];",
"FLOPPY_DPRINTF(\"User requested floppy drive type '%s', \"\n\"but inserted medium appears to be a \"\n\"%d sector '%s' type\\n\",\nFloppyDriveType_lookup[VAR_0->drive],\nnb_sectors,\nFloppyDriveType_lookup[VAR_1->drive]);",
"}",
"VAR_3 = VAR_5;",
"}",
"if (VAR_3 == -1) {",
"error_setg(&error_abort, \"No candidate geometries present in table \"\n\" for floppy drive type '%s'\",\nFloppyDriveType_lookup[VAR_0->drive]);",
"}",
"VAR_1 = &(fd_formats[VAR_3]);",
"out:\nif (VAR_1->max_head == 0) {",
"VAR_0->flags &= ~FDISK_DBL_SIDES;",
"} else {",
"VAR_0->flags |= FDISK_DBL_SIDES;",
"}",
"VAR_0->max_track = VAR_1->max_track;",
"VAR_0->last_sect = VAR_1->last_sect;",
"VAR_0->disk = VAR_1->drive;",
"VAR_0->media_rate = VAR_1->rate;",
"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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
21,
23,
25
],
[
27
],
[
29
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91,
93
],
[
101
],
[
103
],
[
105
],
[
107
],
[
113
],
[
115
],
[
117
],
[
119,
121,
123,
125,
127,
129
],
[
131
],
[
133
],
[
135
],
[
141
],
[
143,
145,
147
],
[
149
],
[
153
],
[
157,
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
]
] |
3,246 | static int usbredir_get_bufpq(QEMUFile *f, void *priv, size_t unused)
{
struct endp_data *endp = priv;
USBRedirDevice *dev = endp->dev;
struct buf_packet *bufp;
int i;
endp->bufpq_size = qemu_get_be32(f);
for (i = 0; i < endp->bufpq_size; i++) {
bufp = g_malloc(sizeof(struct buf_packet));
bufp->len = qemu_get_be32(f);
bufp->status = qemu_get_be32(f);
bufp->offset = 0;
bufp->data = qemu_oom_check(malloc(bufp->len)); /* regular malloc! */
bufp->free_on_destroy = bufp->data;
qemu_get_buffer(f, bufp->data, bufp->len);
QTAILQ_INSERT_TAIL(&endp->bufpq, bufp, next);
DPRINTF("get_bufpq %d/%d len %d status %d\n", i + 1, endp->bufpq_size,
bufp->len, bufp->status);
}
return 0;
}
| true | qemu | 98f343395e937fa1db3a28dfb4f303f97cfddd6c | static int usbredir_get_bufpq(QEMUFile *f, void *priv, size_t unused)
{
struct endp_data *endp = priv;
USBRedirDevice *dev = endp->dev;
struct buf_packet *bufp;
int i;
endp->bufpq_size = qemu_get_be32(f);
for (i = 0; i < endp->bufpq_size; i++) {
bufp = g_malloc(sizeof(struct buf_packet));
bufp->len = qemu_get_be32(f);
bufp->status = qemu_get_be32(f);
bufp->offset = 0;
bufp->data = qemu_oom_check(malloc(bufp->len));
bufp->free_on_destroy = bufp->data;
qemu_get_buffer(f, bufp->data, bufp->len);
QTAILQ_INSERT_TAIL(&endp->bufpq, bufp, next);
DPRINTF("get_bufpq %d/%d len %d status %d\n", i + 1, endp->bufpq_size,
bufp->len, bufp->status);
}
return 0;
}
| {
"code": [
" bufp = g_malloc(sizeof(struct buf_packet));"
],
"line_no": [
19
]
} | static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2)
{
struct endp_data *VAR_3 = VAR_1;
USBRedirDevice *dev = VAR_3->dev;
struct buf_packet *VAR_4;
int VAR_5;
VAR_3->bufpq_size = qemu_get_be32(VAR_0);
for (VAR_5 = 0; VAR_5 < VAR_3->bufpq_size; VAR_5++) {
VAR_4 = g_malloc(sizeof(struct buf_packet));
VAR_4->len = qemu_get_be32(VAR_0);
VAR_4->status = qemu_get_be32(VAR_0);
VAR_4->offset = 0;
VAR_4->data = qemu_oom_check(malloc(VAR_4->len));
VAR_4->free_on_destroy = VAR_4->data;
qemu_get_buffer(VAR_0, VAR_4->data, VAR_4->len);
QTAILQ_INSERT_TAIL(&VAR_3->bufpq, VAR_4, next);
DPRINTF("get_bufpq %d/%d len %d status %d\n", VAR_5 + 1, VAR_3->bufpq_size,
VAR_4->len, VAR_4->status);
}
return 0;
}
| [
"static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2)\n{",
"struct endp_data *VAR_3 = VAR_1;",
"USBRedirDevice *dev = VAR_3->dev;",
"struct buf_packet *VAR_4;",
"int VAR_5;",
"VAR_3->bufpq_size = qemu_get_be32(VAR_0);",
"for (VAR_5 = 0; VAR_5 < VAR_3->bufpq_size; VAR_5++) {",
"VAR_4 = g_malloc(sizeof(struct buf_packet));",
"VAR_4->len = qemu_get_be32(VAR_0);",
"VAR_4->status = qemu_get_be32(VAR_0);",
"VAR_4->offset = 0;",
"VAR_4->data = qemu_oom_check(malloc(VAR_4->len));",
"VAR_4->free_on_destroy = VAR_4->data;",
"qemu_get_buffer(VAR_0, VAR_4->data, VAR_4->len);",
"QTAILQ_INSERT_TAIL(&VAR_3->bufpq, VAR_4, next);",
"DPRINTF(\"get_bufpq %d/%d len %d status %d\\n\", VAR_5 + 1, VAR_3->bufpq_size,\nVAR_4->len, VAR_4->status);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
]
] |
3,247 | static int vp8_packet(AVFormatContext *s, int idx)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
uint8_t *p = os->buf + os->pstart;
if ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) &&
!(os->flags & OGG_FLAG_EOS)) {
int seg;
int duration;
uint8_t *last_pkt = p;
uint8_t *next_pkt;
seg = os->segp;
duration = (last_pkt[0] >> 4) & 1;
next_pkt = last_pkt += os->psize;
for (; seg < os->nsegs; seg++) {
if (os->segments[seg] < 255) {
duration += (last_pkt[0] >> 4) & 1;
last_pkt = next_pkt + os->segments[seg];
}
next_pkt += os->segments[seg];
}
os->lastpts =
os->lastdts = vp8_gptopts(s, idx, os->granule, NULL) - duration;
if(s->streams[idx]->start_time == AV_NOPTS_VALUE) {
s->streams[idx]->start_time = os->lastpts;
if (s->streams[idx]->duration)
s->streams[idx]->duration -= s->streams[idx]->start_time;
}
}
if (os->psize > 0)
os->pduration = (p[0] >> 4) & 1;
return 0;
}
| true | FFmpeg | c5fd57f483d2ad8e34551b78509f1e14136f73c0 | static int vp8_packet(AVFormatContext *s, int idx)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
uint8_t *p = os->buf + os->pstart;
if ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) &&
!(os->flags & OGG_FLAG_EOS)) {
int seg;
int duration;
uint8_t *last_pkt = p;
uint8_t *next_pkt;
seg = os->segp;
duration = (last_pkt[0] >> 4) & 1;
next_pkt = last_pkt += os->psize;
for (; seg < os->nsegs; seg++) {
if (os->segments[seg] < 255) {
duration += (last_pkt[0] >> 4) & 1;
last_pkt = next_pkt + os->segments[seg];
}
next_pkt += os->segments[seg];
}
os->lastpts =
os->lastdts = vp8_gptopts(s, idx, os->granule, NULL) - duration;
if(s->streams[idx]->start_time == AV_NOPTS_VALUE) {
s->streams[idx]->start_time = os->lastpts;
if (s->streams[idx]->duration)
s->streams[idx]->duration -= s->streams[idx]->start_time;
}
}
if (os->psize > 0)
os->pduration = (p[0] >> 4) & 1;
return 0;
}
| {
"code": [
" if (s->streams[idx]->duration)"
],
"line_no": [
55
]
} | static int FUNC_0(AVFormatContext *VAR_0, int VAR_1)
{
struct VAR_2 *VAR_2 = VAR_0->priv_data;
struct ogg_stream *VAR_3 = VAR_2->streams + VAR_1;
uint8_t *p = VAR_3->buf + VAR_3->pstart;
if ((!VAR_3->lastpts || VAR_3->lastpts == AV_NOPTS_VALUE) &&
!(VAR_3->flags & OGG_FLAG_EOS)) {
int VAR_4;
int VAR_5;
uint8_t *last_pkt = p;
uint8_t *next_pkt;
VAR_4 = VAR_3->segp;
VAR_5 = (last_pkt[0] >> 4) & 1;
next_pkt = last_pkt += VAR_3->psize;
for (; VAR_4 < VAR_3->nsegs; VAR_4++) {
if (VAR_3->segments[VAR_4] < 255) {
VAR_5 += (last_pkt[0] >> 4) & 1;
last_pkt = next_pkt + VAR_3->segments[VAR_4];
}
next_pkt += VAR_3->segments[VAR_4];
}
VAR_3->lastpts =
VAR_3->lastdts = vp8_gptopts(VAR_0, VAR_1, VAR_3->granule, NULL) - VAR_5;
if(VAR_0->streams[VAR_1]->start_time == AV_NOPTS_VALUE) {
VAR_0->streams[VAR_1]->start_time = VAR_3->lastpts;
if (VAR_0->streams[VAR_1]->VAR_5)
VAR_0->streams[VAR_1]->VAR_5 -= VAR_0->streams[VAR_1]->start_time;
}
}
if (VAR_3->psize > 0)
VAR_3->pduration = (p[0] >> 4) & 1;
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, int VAR_1)\n{",
"struct VAR_2 *VAR_2 = VAR_0->priv_data;",
"struct ogg_stream *VAR_3 = VAR_2->streams + VAR_1;",
"uint8_t *p = VAR_3->buf + VAR_3->pstart;",
"if ((!VAR_3->lastpts || VAR_3->lastpts == AV_NOPTS_VALUE) &&\n!(VAR_3->flags & OGG_FLAG_EOS)) {",
"int VAR_4;",
"int VAR_5;",
"uint8_t *last_pkt = p;",
"uint8_t *next_pkt;",
"VAR_4 = VAR_3->segp;",
"VAR_5 = (last_pkt[0] >> 4) & 1;",
"next_pkt = last_pkt += VAR_3->psize;",
"for (; VAR_4 < VAR_3->nsegs; VAR_4++) {",
"if (VAR_3->segments[VAR_4] < 255) {",
"VAR_5 += (last_pkt[0] >> 4) & 1;",
"last_pkt = next_pkt + VAR_3->segments[VAR_4];",
"}",
"next_pkt += VAR_3->segments[VAR_4];",
"}",
"VAR_3->lastpts =\nVAR_3->lastdts = vp8_gptopts(VAR_0, VAR_1, VAR_3->granule, NULL) - VAR_5;",
"if(VAR_0->streams[VAR_1]->start_time == AV_NOPTS_VALUE) {",
"VAR_0->streams[VAR_1]->start_time = VAR_3->lastpts;",
"if (VAR_0->streams[VAR_1]->VAR_5)\nVAR_0->streams[VAR_1]->VAR_5 -= VAR_0->streams[VAR_1]->start_time;",
"}",
"}",
"if (VAR_3->psize > 0)\nVAR_3->pduration = (p[0] >> 4) & 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,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
65,
67
],
[
71
],
[
73
]
] |
3,248 | static int xen_pt_config_reg_init(XenPCIPassthroughState *s,
XenPTRegGroup *reg_grp, XenPTRegInfo *reg)
{
XenPTReg *reg_entry;
uint32_t data = 0;
int rc = 0;
reg_entry = g_new0(XenPTReg, 1);
reg_entry->reg = reg;
if (reg->init) {
/* initialize emulate register */
rc = reg->init(s, reg_entry->reg,
reg_grp->base_offset + reg->offset, &data);
if (rc < 0) {
free(reg_entry);
return rc;
}
if (data == XEN_PT_INVALID_REG) {
/* free unused BAR register entry */
free(reg_entry);
return 0;
}
/* set register value */
reg_entry->data = data;
}
/* list add register entry */
QLIST_INSERT_HEAD(®_grp->reg_tbl_list, reg_entry, entries);
return 0;
}
| true | qemu | c5633d998a27502ad8cc10c2d46f91b02555ae7a | static int xen_pt_config_reg_init(XenPCIPassthroughState *s,
XenPTRegGroup *reg_grp, XenPTRegInfo *reg)
{
XenPTReg *reg_entry;
uint32_t data = 0;
int rc = 0;
reg_entry = g_new0(XenPTReg, 1);
reg_entry->reg = reg;
if (reg->init) {
rc = reg->init(s, reg_entry->reg,
reg_grp->base_offset + reg->offset, &data);
if (rc < 0) {
free(reg_entry);
return rc;
}
if (data == XEN_PT_INVALID_REG) {
free(reg_entry);
return 0;
}
reg_entry->data = data;
}
QLIST_INSERT_HEAD(®_grp->reg_tbl_list, reg_entry, entries);
return 0;
}
| {
"code": [
" free(reg_entry);",
" free(reg_entry);"
],
"line_no": [
31,
31
]
} | static int FUNC_0(XenPCIPassthroughState *VAR_0,
XenPTRegGroup *VAR_1, XenPTRegInfo *VAR_2)
{
XenPTReg *reg_entry;
uint32_t data = 0;
int VAR_3 = 0;
reg_entry = g_new0(XenPTReg, 1);
reg_entry->VAR_2 = VAR_2;
if (VAR_2->init) {
VAR_3 = VAR_2->init(VAR_0, reg_entry->VAR_2,
VAR_1->base_offset + VAR_2->offset, &data);
if (VAR_3 < 0) {
free(reg_entry);
return VAR_3;
}
if (data == XEN_PT_INVALID_REG) {
free(reg_entry);
return 0;
}
reg_entry->data = data;
}
QLIST_INSERT_HEAD(&VAR_1->reg_tbl_list, reg_entry, entries);
return 0;
}
| [
"static int FUNC_0(XenPCIPassthroughState *VAR_0,\nXenPTRegGroup *VAR_1, XenPTRegInfo *VAR_2)\n{",
"XenPTReg *reg_entry;",
"uint32_t data = 0;",
"int VAR_3 = 0;",
"reg_entry = g_new0(XenPTReg, 1);",
"reg_entry->VAR_2 = VAR_2;",
"if (VAR_2->init) {",
"VAR_3 = VAR_2->init(VAR_0, reg_entry->VAR_2,\nVAR_1->base_offset + VAR_2->offset, &data);",
"if (VAR_3 < 0) {",
"free(reg_entry);",
"return VAR_3;",
"}",
"if (data == XEN_PT_INVALID_REG) {",
"free(reg_entry);",
"return 0;",
"}",
"reg_entry->data = data;",
"}",
"QLIST_INSERT_HEAD(&VAR_1->reg_tbl_list, reg_entry, entries);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
55
],
[
59
],
[
61
]
] |
3,250 | static void open_help(void)
{
printf(
"\n"
" opens a new file in the requested mode\n"
"\n"
" Example:\n"
" 'open -Cn /tmp/data' - creates/opens data file read-write and uncached\n"
"\n"
" Opens a file for subsequent use by all of the other qemu-io commands.\n"
" -r, -- open file read-only\n"
" -s, -- use snapshot file\n"
" -n, -- disable host cache\n"
" -o, -- options to be given to the block driver"
"\n");
}
| false | qemu | e4e12bb26d9f2e2de02ff888063f41cc1e1b3935 | static void open_help(void)
{
printf(
"\n"
" opens a new file in the requested mode\n"
"\n"
" Example:\n"
" 'open -Cn /tmp/data' - creates/opens data file read-write and uncached\n"
"\n"
" Opens a file for subsequent use by all of the other qemu-io commands.\n"
" -r, -- open file read-only\n"
" -s, -- use snapshot file\n"
" -n, -- disable host cache\n"
" -o, -- options to be given to the block driver"
"\n");
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
printf(
"\n"
" opens a new file in the requested mode\n"
"\n"
" Example:\n"
" 'open -Cn /tmp/data' - creates/opens data file read-write and uncached\n"
"\n"
" Opens a file for subsequent use by all of the other qemu-io commands.\n"
" -r, -- open file read-only\n"
" -s, -- use snapshot file\n"
" -n, -- disable host cache\n"
" -o, -- options to be given to the block driver"
"\n");
}
| [
"static void FUNC_0(void)\n{",
"printf(\n\"\\n\"\n\" opens a new file in the requested mode\\n\"\n\"\\n\"\n\" Example:\\n\"\n\" 'open -Cn /tmp/data' - creates/opens data file read-write and uncached\\n\"\n\"\\n\"\n\" Opens a file for subsequent use by all of the other qemu-io commands.\\n\"\n\" -r, -- open file read-only\\n\"\n\" -s, -- use snapshot file\\n\"\n\" -n, -- disable host cache\\n\"\n\" -o, -- options to be given to the block driver\"\n\"\\n\");",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5,
7,
9,
11,
13,
15,
17,
19,
21,
23,
25,
27,
29
],
[
31
]
] |
3,251 | static const char *scsi_command_name(uint8_t cmd)
{
static const char *names[] = {
[ TEST_UNIT_READY ] = "TEST_UNIT_READY",
[ REWIND ] = "REWIND",
[ REQUEST_SENSE ] = "REQUEST_SENSE",
[ FORMAT_UNIT ] = "FORMAT_UNIT",
[ READ_BLOCK_LIMITS ] = "READ_BLOCK_LIMITS",
[ REASSIGN_BLOCKS ] = "REASSIGN_BLOCKS",
[ READ_6 ] = "READ_6",
[ WRITE_6 ] = "WRITE_6",
[ SEEK_6 ] = "SEEK_6",
[ READ_REVERSE ] = "READ_REVERSE",
[ WRITE_FILEMARKS ] = "WRITE_FILEMARKS",
[ SPACE ] = "SPACE",
[ INQUIRY ] = "INQUIRY",
[ RECOVER_BUFFERED_DATA ] = "RECOVER_BUFFERED_DATA",
[ MAINTENANCE_IN ] = "MAINTENANCE_IN",
[ MAINTENANCE_OUT ] = "MAINTENANCE_OUT",
[ MODE_SELECT ] = "MODE_SELECT",
[ RESERVE ] = "RESERVE",
[ RELEASE ] = "RELEASE",
[ COPY ] = "COPY",
[ ERASE ] = "ERASE",
[ MODE_SENSE ] = "MODE_SENSE",
[ START_STOP ] = "START_STOP",
[ RECEIVE_DIAGNOSTIC ] = "RECEIVE_DIAGNOSTIC",
[ SEND_DIAGNOSTIC ] = "SEND_DIAGNOSTIC",
[ ALLOW_MEDIUM_REMOVAL ] = "ALLOW_MEDIUM_REMOVAL",
[ READ_CAPACITY_10 ] = "READ_CAPACITY_10",
[ READ_10 ] = "READ_10",
[ WRITE_10 ] = "WRITE_10",
[ SEEK_10 ] = "SEEK_10",
[ WRITE_VERIFY_10 ] = "WRITE_VERIFY_10",
[ VERIFY_10 ] = "VERIFY_10",
[ SEARCH_HIGH ] = "SEARCH_HIGH",
[ SEARCH_EQUAL ] = "SEARCH_EQUAL",
[ SEARCH_LOW ] = "SEARCH_LOW",
[ SET_LIMITS ] = "SET_LIMITS",
[ PRE_FETCH ] = "PRE_FETCH",
/* READ_POSITION and PRE_FETCH use the same operation code */
[ SYNCHRONIZE_CACHE ] = "SYNCHRONIZE_CACHE",
[ LOCK_UNLOCK_CACHE ] = "LOCK_UNLOCK_CACHE",
[ READ_DEFECT_DATA ] = "READ_DEFECT_DATA",
[ MEDIUM_SCAN ] = "MEDIUM_SCAN",
[ COMPARE ] = "COMPARE",
[ COPY_VERIFY ] = "COPY_VERIFY",
[ WRITE_BUFFER ] = "WRITE_BUFFER",
[ READ_BUFFER ] = "READ_BUFFER",
[ UPDATE_BLOCK ] = "UPDATE_BLOCK",
[ READ_LONG_10 ] = "READ_LONG_10",
[ WRITE_LONG_10 ] = "WRITE_LONG_10",
[ CHANGE_DEFINITION ] = "CHANGE_DEFINITION",
[ WRITE_SAME_10 ] = "WRITE_SAME_10",
[ UNMAP ] = "UNMAP",
[ READ_TOC ] = "READ_TOC",
[ REPORT_DENSITY_SUPPORT ] = "REPORT_DENSITY_SUPPORT",
[ GET_CONFIGURATION ] = "GET_CONFIGURATION",
[ LOG_SELECT ] = "LOG_SELECT",
[ LOG_SENSE ] = "LOG_SENSE",
[ MODE_SELECT_10 ] = "MODE_SELECT_10",
[ RESERVE_10 ] = "RESERVE_10",
[ RELEASE_10 ] = "RELEASE_10",
[ MODE_SENSE_10 ] = "MODE_SENSE_10",
[ PERSISTENT_RESERVE_IN ] = "PERSISTENT_RESERVE_IN",
[ PERSISTENT_RESERVE_OUT ] = "PERSISTENT_RESERVE_OUT",
[ WRITE_FILEMARKS_16 ] = "WRITE_FILEMARKS_16",
[ EXTENDED_COPY ] = "EXTENDED_COPY",
[ ATA_PASSTHROUGH ] = "ATA_PASSTHROUGH",
[ ACCESS_CONTROL_IN ] = "ACCESS_CONTROL_IN",
[ ACCESS_CONTROL_OUT ] = "ACCESS_CONTROL_OUT",
[ READ_16 ] = "READ_16",
[ COMPARE_AND_WRITE ] = "COMPARE_AND_WRITE",
[ WRITE_16 ] = "WRITE_16",
[ WRITE_VERIFY_16 ] = "WRITE_VERIFY_16",
[ VERIFY_16 ] = "VERIFY_16",
[ SYNCHRONIZE_CACHE_16 ] = "SYNCHRONIZE_CACHE_16",
[ LOCATE_16 ] = "LOCATE_16",
[ WRITE_SAME_16 ] = "WRITE_SAME_16",
[ ERASE_16 ] = "ERASE_16",
[ SERVICE_ACTION_IN_16 ] = "SERVICE_ACTION_IN_16",
[ WRITE_LONG_16 ] = "WRITE_LONG_16",
[ REPORT_LUNS ] = "REPORT_LUNS",
[ BLANK ] = "BLANK",
[ MAINTENANCE_IN ] = "MAINTENANCE_IN",
[ MAINTENANCE_OUT ] = "MAINTENANCE_OUT",
[ MOVE_MEDIUM ] = "MOVE_MEDIUM",
[ LOAD_UNLOAD ] = "LOAD_UNLOAD",
[ READ_12 ] = "READ_12",
[ WRITE_12 ] = "WRITE_12",
[ SERVICE_ACTION_IN_12 ] = "SERVICE_ACTION_IN_12",
[ WRITE_VERIFY_12 ] = "WRITE_VERIFY_12",
[ VERIFY_12 ] = "VERIFY_12",
[ SEARCH_HIGH_12 ] = "SEARCH_HIGH_12",
[ SEARCH_EQUAL_12 ] = "SEARCH_EQUAL_12",
[ SEARCH_LOW_12 ] = "SEARCH_LOW_12",
[ READ_ELEMENT_STATUS ] = "READ_ELEMENT_STATUS",
[ SEND_VOLUME_TAG ] = "SEND_VOLUME_TAG",
[ READ_DEFECT_DATA_12 ] = "READ_DEFECT_DATA_12",
[ SET_CD_SPEED ] = "SET_CD_SPEED",
};
if (cmd >= ARRAY_SIZE(names) || names[cmd] == NULL)
return "*UNKNOWN*";
return names[cmd];
}
| false | qemu | 48bb9f53f4944771bc5d7bf89bbaa61094ad4382 | static const char *scsi_command_name(uint8_t cmd)
{
static const char *names[] = {
[ TEST_UNIT_READY ] = "TEST_UNIT_READY",
[ REWIND ] = "REWIND",
[ REQUEST_SENSE ] = "REQUEST_SENSE",
[ FORMAT_UNIT ] = "FORMAT_UNIT",
[ READ_BLOCK_LIMITS ] = "READ_BLOCK_LIMITS",
[ REASSIGN_BLOCKS ] = "REASSIGN_BLOCKS",
[ READ_6 ] = "READ_6",
[ WRITE_6 ] = "WRITE_6",
[ SEEK_6 ] = "SEEK_6",
[ READ_REVERSE ] = "READ_REVERSE",
[ WRITE_FILEMARKS ] = "WRITE_FILEMARKS",
[ SPACE ] = "SPACE",
[ INQUIRY ] = "INQUIRY",
[ RECOVER_BUFFERED_DATA ] = "RECOVER_BUFFERED_DATA",
[ MAINTENANCE_IN ] = "MAINTENANCE_IN",
[ MAINTENANCE_OUT ] = "MAINTENANCE_OUT",
[ MODE_SELECT ] = "MODE_SELECT",
[ RESERVE ] = "RESERVE",
[ RELEASE ] = "RELEASE",
[ COPY ] = "COPY",
[ ERASE ] = "ERASE",
[ MODE_SENSE ] = "MODE_SENSE",
[ START_STOP ] = "START_STOP",
[ RECEIVE_DIAGNOSTIC ] = "RECEIVE_DIAGNOSTIC",
[ SEND_DIAGNOSTIC ] = "SEND_DIAGNOSTIC",
[ ALLOW_MEDIUM_REMOVAL ] = "ALLOW_MEDIUM_REMOVAL",
[ READ_CAPACITY_10 ] = "READ_CAPACITY_10",
[ READ_10 ] = "READ_10",
[ WRITE_10 ] = "WRITE_10",
[ SEEK_10 ] = "SEEK_10",
[ WRITE_VERIFY_10 ] = "WRITE_VERIFY_10",
[ VERIFY_10 ] = "VERIFY_10",
[ SEARCH_HIGH ] = "SEARCH_HIGH",
[ SEARCH_EQUAL ] = "SEARCH_EQUAL",
[ SEARCH_LOW ] = "SEARCH_LOW",
[ SET_LIMITS ] = "SET_LIMITS",
[ PRE_FETCH ] = "PRE_FETCH",
[ SYNCHRONIZE_CACHE ] = "SYNCHRONIZE_CACHE",
[ LOCK_UNLOCK_CACHE ] = "LOCK_UNLOCK_CACHE",
[ READ_DEFECT_DATA ] = "READ_DEFECT_DATA",
[ MEDIUM_SCAN ] = "MEDIUM_SCAN",
[ COMPARE ] = "COMPARE",
[ COPY_VERIFY ] = "COPY_VERIFY",
[ WRITE_BUFFER ] = "WRITE_BUFFER",
[ READ_BUFFER ] = "READ_BUFFER",
[ UPDATE_BLOCK ] = "UPDATE_BLOCK",
[ READ_LONG_10 ] = "READ_LONG_10",
[ WRITE_LONG_10 ] = "WRITE_LONG_10",
[ CHANGE_DEFINITION ] = "CHANGE_DEFINITION",
[ WRITE_SAME_10 ] = "WRITE_SAME_10",
[ UNMAP ] = "UNMAP",
[ READ_TOC ] = "READ_TOC",
[ REPORT_DENSITY_SUPPORT ] = "REPORT_DENSITY_SUPPORT",
[ GET_CONFIGURATION ] = "GET_CONFIGURATION",
[ LOG_SELECT ] = "LOG_SELECT",
[ LOG_SENSE ] = "LOG_SENSE",
[ MODE_SELECT_10 ] = "MODE_SELECT_10",
[ RESERVE_10 ] = "RESERVE_10",
[ RELEASE_10 ] = "RELEASE_10",
[ MODE_SENSE_10 ] = "MODE_SENSE_10",
[ PERSISTENT_RESERVE_IN ] = "PERSISTENT_RESERVE_IN",
[ PERSISTENT_RESERVE_OUT ] = "PERSISTENT_RESERVE_OUT",
[ WRITE_FILEMARKS_16 ] = "WRITE_FILEMARKS_16",
[ EXTENDED_COPY ] = "EXTENDED_COPY",
[ ATA_PASSTHROUGH ] = "ATA_PASSTHROUGH",
[ ACCESS_CONTROL_IN ] = "ACCESS_CONTROL_IN",
[ ACCESS_CONTROL_OUT ] = "ACCESS_CONTROL_OUT",
[ READ_16 ] = "READ_16",
[ COMPARE_AND_WRITE ] = "COMPARE_AND_WRITE",
[ WRITE_16 ] = "WRITE_16",
[ WRITE_VERIFY_16 ] = "WRITE_VERIFY_16",
[ VERIFY_16 ] = "VERIFY_16",
[ SYNCHRONIZE_CACHE_16 ] = "SYNCHRONIZE_CACHE_16",
[ LOCATE_16 ] = "LOCATE_16",
[ WRITE_SAME_16 ] = "WRITE_SAME_16",
[ ERASE_16 ] = "ERASE_16",
[ SERVICE_ACTION_IN_16 ] = "SERVICE_ACTION_IN_16",
[ WRITE_LONG_16 ] = "WRITE_LONG_16",
[ REPORT_LUNS ] = "REPORT_LUNS",
[ BLANK ] = "BLANK",
[ MAINTENANCE_IN ] = "MAINTENANCE_IN",
[ MAINTENANCE_OUT ] = "MAINTENANCE_OUT",
[ MOVE_MEDIUM ] = "MOVE_MEDIUM",
[ LOAD_UNLOAD ] = "LOAD_UNLOAD",
[ READ_12 ] = "READ_12",
[ WRITE_12 ] = "WRITE_12",
[ SERVICE_ACTION_IN_12 ] = "SERVICE_ACTION_IN_12",
[ WRITE_VERIFY_12 ] = "WRITE_VERIFY_12",
[ VERIFY_12 ] = "VERIFY_12",
[ SEARCH_HIGH_12 ] = "SEARCH_HIGH_12",
[ SEARCH_EQUAL_12 ] = "SEARCH_EQUAL_12",
[ SEARCH_LOW_12 ] = "SEARCH_LOW_12",
[ READ_ELEMENT_STATUS ] = "READ_ELEMENT_STATUS",
[ SEND_VOLUME_TAG ] = "SEND_VOLUME_TAG",
[ READ_DEFECT_DATA_12 ] = "READ_DEFECT_DATA_12",
[ SET_CD_SPEED ] = "SET_CD_SPEED",
};
if (cmd >= ARRAY_SIZE(names) || names[cmd] == NULL)
return "*UNKNOWN*";
return names[cmd];
}
| {
"code": [],
"line_no": []
} | static const char *FUNC_0(uint8_t VAR_0)
{
static const char *VAR_1[] = {
[ TEST_UNIT_READY ] = "TEST_UNIT_READY",
[ REWIND ] = "REWIND",
[ REQUEST_SENSE ] = "REQUEST_SENSE",
[ FORMAT_UNIT ] = "FORMAT_UNIT",
[ READ_BLOCK_LIMITS ] = "READ_BLOCK_LIMITS",
[ REASSIGN_BLOCKS ] = "REASSIGN_BLOCKS",
[ READ_6 ] = "READ_6",
[ WRITE_6 ] = "WRITE_6",
[ SEEK_6 ] = "SEEK_6",
[ READ_REVERSE ] = "READ_REVERSE",
[ WRITE_FILEMARKS ] = "WRITE_FILEMARKS",
[ SPACE ] = "SPACE",
[ INQUIRY ] = "INQUIRY",
[ RECOVER_BUFFERED_DATA ] = "RECOVER_BUFFERED_DATA",
[ MAINTENANCE_IN ] = "MAINTENANCE_IN",
[ MAINTENANCE_OUT ] = "MAINTENANCE_OUT",
[ MODE_SELECT ] = "MODE_SELECT",
[ RESERVE ] = "RESERVE",
[ RELEASE ] = "RELEASE",
[ COPY ] = "COPY",
[ ERASE ] = "ERASE",
[ MODE_SENSE ] = "MODE_SENSE",
[ START_STOP ] = "START_STOP",
[ RECEIVE_DIAGNOSTIC ] = "RECEIVE_DIAGNOSTIC",
[ SEND_DIAGNOSTIC ] = "SEND_DIAGNOSTIC",
[ ALLOW_MEDIUM_REMOVAL ] = "ALLOW_MEDIUM_REMOVAL",
[ READ_CAPACITY_10 ] = "READ_CAPACITY_10",
[ READ_10 ] = "READ_10",
[ WRITE_10 ] = "WRITE_10",
[ SEEK_10 ] = "SEEK_10",
[ WRITE_VERIFY_10 ] = "WRITE_VERIFY_10",
[ VERIFY_10 ] = "VERIFY_10",
[ SEARCH_HIGH ] = "SEARCH_HIGH",
[ SEARCH_EQUAL ] = "SEARCH_EQUAL",
[ SEARCH_LOW ] = "SEARCH_LOW",
[ SET_LIMITS ] = "SET_LIMITS",
[ PRE_FETCH ] = "PRE_FETCH",
[ SYNCHRONIZE_CACHE ] = "SYNCHRONIZE_CACHE",
[ LOCK_UNLOCK_CACHE ] = "LOCK_UNLOCK_CACHE",
[ READ_DEFECT_DATA ] = "READ_DEFECT_DATA",
[ MEDIUM_SCAN ] = "MEDIUM_SCAN",
[ COMPARE ] = "COMPARE",
[ COPY_VERIFY ] = "COPY_VERIFY",
[ WRITE_BUFFER ] = "WRITE_BUFFER",
[ READ_BUFFER ] = "READ_BUFFER",
[ UPDATE_BLOCK ] = "UPDATE_BLOCK",
[ READ_LONG_10 ] = "READ_LONG_10",
[ WRITE_LONG_10 ] = "WRITE_LONG_10",
[ CHANGE_DEFINITION ] = "CHANGE_DEFINITION",
[ WRITE_SAME_10 ] = "WRITE_SAME_10",
[ UNMAP ] = "UNMAP",
[ READ_TOC ] = "READ_TOC",
[ REPORT_DENSITY_SUPPORT ] = "REPORT_DENSITY_SUPPORT",
[ GET_CONFIGURATION ] = "GET_CONFIGURATION",
[ LOG_SELECT ] = "LOG_SELECT",
[ LOG_SENSE ] = "LOG_SENSE",
[ MODE_SELECT_10 ] = "MODE_SELECT_10",
[ RESERVE_10 ] = "RESERVE_10",
[ RELEASE_10 ] = "RELEASE_10",
[ MODE_SENSE_10 ] = "MODE_SENSE_10",
[ PERSISTENT_RESERVE_IN ] = "PERSISTENT_RESERVE_IN",
[ PERSISTENT_RESERVE_OUT ] = "PERSISTENT_RESERVE_OUT",
[ WRITE_FILEMARKS_16 ] = "WRITE_FILEMARKS_16",
[ EXTENDED_COPY ] = "EXTENDED_COPY",
[ ATA_PASSTHROUGH ] = "ATA_PASSTHROUGH",
[ ACCESS_CONTROL_IN ] = "ACCESS_CONTROL_IN",
[ ACCESS_CONTROL_OUT ] = "ACCESS_CONTROL_OUT",
[ READ_16 ] = "READ_16",
[ COMPARE_AND_WRITE ] = "COMPARE_AND_WRITE",
[ WRITE_16 ] = "WRITE_16",
[ WRITE_VERIFY_16 ] = "WRITE_VERIFY_16",
[ VERIFY_16 ] = "VERIFY_16",
[ SYNCHRONIZE_CACHE_16 ] = "SYNCHRONIZE_CACHE_16",
[ LOCATE_16 ] = "LOCATE_16",
[ WRITE_SAME_16 ] = "WRITE_SAME_16",
[ ERASE_16 ] = "ERASE_16",
[ SERVICE_ACTION_IN_16 ] = "SERVICE_ACTION_IN_16",
[ WRITE_LONG_16 ] = "WRITE_LONG_16",
[ REPORT_LUNS ] = "REPORT_LUNS",
[ BLANK ] = "BLANK",
[ MAINTENANCE_IN ] = "MAINTENANCE_IN",
[ MAINTENANCE_OUT ] = "MAINTENANCE_OUT",
[ MOVE_MEDIUM ] = "MOVE_MEDIUM",
[ LOAD_UNLOAD ] = "LOAD_UNLOAD",
[ READ_12 ] = "READ_12",
[ WRITE_12 ] = "WRITE_12",
[ SERVICE_ACTION_IN_12 ] = "SERVICE_ACTION_IN_12",
[ WRITE_VERIFY_12 ] = "WRITE_VERIFY_12",
[ VERIFY_12 ] = "VERIFY_12",
[ SEARCH_HIGH_12 ] = "SEARCH_HIGH_12",
[ SEARCH_EQUAL_12 ] = "SEARCH_EQUAL_12",
[ SEARCH_LOW_12 ] = "SEARCH_LOW_12",
[ READ_ELEMENT_STATUS ] = "READ_ELEMENT_STATUS",
[ SEND_VOLUME_TAG ] = "SEND_VOLUME_TAG",
[ READ_DEFECT_DATA_12 ] = "READ_DEFECT_DATA_12",
[ SET_CD_SPEED ] = "SET_CD_SPEED",
};
if (VAR_0 >= ARRAY_SIZE(VAR_1) || VAR_1[VAR_0] == NULL)
return "*UNKNOWN*";
return VAR_1[VAR_0];
}
| [
"static const char *FUNC_0(uint8_t VAR_0)\n{",
"static const char *VAR_1[] = {",
"[ TEST_UNIT_READY ] = \"TEST_UNIT_READY\",\n[ REWIND ] = \"REWIND\",\n[ REQUEST_SENSE ] = \"REQUEST_SENSE\",\n[ FORMAT_UNIT ] = \"FORMAT_UNIT\",\n[ READ_BLOCK_LIMITS ] = \"READ_BLOCK_LIMITS\",\n[ REASSIGN_BLOCKS ] = \"REASSIGN_BLOCKS\",\n[ READ_6 ] = \"READ_6\",\n[ WRITE_6 ] = \"WRITE_6\",\n[ SEEK_6 ] = \"SEEK_6\",\n[ READ_REVERSE ] = \"READ_REVERSE\",\n[ WRITE_FILEMARKS ] = \"WRITE_FILEMARKS\",\n[ SPACE ] = \"SPACE\",\n[ INQUIRY ] = \"INQUIRY\",\n[ RECOVER_BUFFERED_DATA ] = \"RECOVER_BUFFERED_DATA\",\n[ MAINTENANCE_IN ] = \"MAINTENANCE_IN\",\n[ MAINTENANCE_OUT ] = \"MAINTENANCE_OUT\",\n[ MODE_SELECT ] = \"MODE_SELECT\",\n[ RESERVE ] = \"RESERVE\",\n[ RELEASE ] = \"RELEASE\",\n[ COPY ] = \"COPY\",\n[ ERASE ] = \"ERASE\",\n[ MODE_SENSE ] = \"MODE_SENSE\",\n[ START_STOP ] = \"START_STOP\",\n[ RECEIVE_DIAGNOSTIC ] = \"RECEIVE_DIAGNOSTIC\",\n[ SEND_DIAGNOSTIC ] = \"SEND_DIAGNOSTIC\",\n[ ALLOW_MEDIUM_REMOVAL ] = \"ALLOW_MEDIUM_REMOVAL\",\n[ READ_CAPACITY_10 ] = \"READ_CAPACITY_10\",\n[ READ_10 ] = \"READ_10\",\n[ WRITE_10 ] = \"WRITE_10\",\n[ SEEK_10 ] = \"SEEK_10\",\n[ WRITE_VERIFY_10 ] = \"WRITE_VERIFY_10\",\n[ VERIFY_10 ] = \"VERIFY_10\",\n[ SEARCH_HIGH ] = \"SEARCH_HIGH\",\n[ SEARCH_EQUAL ] = \"SEARCH_EQUAL\",\n[ SEARCH_LOW ] = \"SEARCH_LOW\",\n[ SET_LIMITS ] = \"SET_LIMITS\",\n[ PRE_FETCH ] = \"PRE_FETCH\",\n[ SYNCHRONIZE_CACHE ] = \"SYNCHRONIZE_CACHE\",\n[ LOCK_UNLOCK_CACHE ] = \"LOCK_UNLOCK_CACHE\",\n[ READ_DEFECT_DATA ] = \"READ_DEFECT_DATA\",\n[ MEDIUM_SCAN ] = \"MEDIUM_SCAN\",\n[ COMPARE ] = \"COMPARE\",\n[ COPY_VERIFY ] = \"COPY_VERIFY\",\n[ WRITE_BUFFER ] = \"WRITE_BUFFER\",\n[ READ_BUFFER ] = \"READ_BUFFER\",\n[ UPDATE_BLOCK ] = \"UPDATE_BLOCK\",\n[ READ_LONG_10 ] = \"READ_LONG_10\",\n[ WRITE_LONG_10 ] = \"WRITE_LONG_10\",\n[ CHANGE_DEFINITION ] = \"CHANGE_DEFINITION\",\n[ WRITE_SAME_10 ] = \"WRITE_SAME_10\",\n[ UNMAP ] = \"UNMAP\",\n[ READ_TOC ] = \"READ_TOC\",\n[ REPORT_DENSITY_SUPPORT ] = \"REPORT_DENSITY_SUPPORT\",\n[ GET_CONFIGURATION ] = \"GET_CONFIGURATION\",\n[ LOG_SELECT ] = \"LOG_SELECT\",\n[ LOG_SENSE ] = \"LOG_SENSE\",\n[ MODE_SELECT_10 ] = \"MODE_SELECT_10\",\n[ RESERVE_10 ] = \"RESERVE_10\",\n[ RELEASE_10 ] = \"RELEASE_10\",\n[ MODE_SENSE_10 ] = \"MODE_SENSE_10\",\n[ PERSISTENT_RESERVE_IN ] = \"PERSISTENT_RESERVE_IN\",\n[ PERSISTENT_RESERVE_OUT ] = \"PERSISTENT_RESERVE_OUT\",\n[ WRITE_FILEMARKS_16 ] = \"WRITE_FILEMARKS_16\",\n[ EXTENDED_COPY ] = \"EXTENDED_COPY\",\n[ ATA_PASSTHROUGH ] = \"ATA_PASSTHROUGH\",\n[ ACCESS_CONTROL_IN ] = \"ACCESS_CONTROL_IN\",\n[ ACCESS_CONTROL_OUT ] = \"ACCESS_CONTROL_OUT\",\n[ READ_16 ] = \"READ_16\",\n[ COMPARE_AND_WRITE ] = \"COMPARE_AND_WRITE\",\n[ WRITE_16 ] = \"WRITE_16\",\n[ WRITE_VERIFY_16 ] = \"WRITE_VERIFY_16\",\n[ VERIFY_16 ] = \"VERIFY_16\",\n[ SYNCHRONIZE_CACHE_16 ] = \"SYNCHRONIZE_CACHE_16\",\n[ LOCATE_16 ] = \"LOCATE_16\",\n[ WRITE_SAME_16 ] = \"WRITE_SAME_16\",\n[ ERASE_16 ] = \"ERASE_16\",\n[ SERVICE_ACTION_IN_16 ] = \"SERVICE_ACTION_IN_16\",\n[ WRITE_LONG_16 ] = \"WRITE_LONG_16\",\n[ REPORT_LUNS ] = \"REPORT_LUNS\",\n[ BLANK ] = \"BLANK\",\n[ MAINTENANCE_IN ] = \"MAINTENANCE_IN\",\n[ MAINTENANCE_OUT ] = \"MAINTENANCE_OUT\",\n[ MOVE_MEDIUM ] = \"MOVE_MEDIUM\",\n[ LOAD_UNLOAD ] = \"LOAD_UNLOAD\",\n[ READ_12 ] = \"READ_12\",\n[ WRITE_12 ] = \"WRITE_12\",\n[ SERVICE_ACTION_IN_12 ] = \"SERVICE_ACTION_IN_12\",\n[ WRITE_VERIFY_12 ] = \"WRITE_VERIFY_12\",\n[ VERIFY_12 ] = \"VERIFY_12\",\n[ SEARCH_HIGH_12 ] = \"SEARCH_HIGH_12\",\n[ SEARCH_EQUAL_12 ] = \"SEARCH_EQUAL_12\",\n[ SEARCH_LOW_12 ] = \"SEARCH_LOW_12\",\n[ READ_ELEMENT_STATUS ] = \"READ_ELEMENT_STATUS\",\n[ SEND_VOLUME_TAG ] = \"SEND_VOLUME_TAG\",\n[ READ_DEFECT_DATA_12 ] = \"READ_DEFECT_DATA_12\",\n[ SET_CD_SPEED ] = \"SET_CD_SPEED\",\n};",
"if (VAR_0 >= ARRAY_SIZE(VAR_1) || VAR_1[VAR_0] == NULL)\nreturn \"*UNKNOWN*\";",
"return VAR_1[VAR_0];",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9,
11,
13,
15,
17,
19,
21,
23,
25,
27,
29,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,
79,
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
],
[
205,
207
],
[
209
],
[
211
]
] |
3,252 | static void intra_predict_vert_dc_8x8_msa(uint8_t *src, int32_t stride)
{
uint8_t lp_cnt;
uint32_t out0 = 0, out1 = 0;
v16u8 src_top;
v8u16 add;
v4u32 sum;
v4i32 res0, res1;
src_top = LD_UB(src - stride);
add = __msa_hadd_u_h(src_top, src_top);
sum = __msa_hadd_u_w(add, add);
sum = (v4u32) __msa_srari_w((v4i32) sum, 2);
res0 = (v4i32) __msa_splati_b((v16i8) sum, 0);
res1 = (v4i32) __msa_splati_b((v16i8) sum, 4);
out0 = __msa_copy_u_w(res0, 0);
out1 = __msa_copy_u_w(res1, 0);
for (lp_cnt = 8; lp_cnt--;) {
SW(out0, src);
SW(out1, src + 4);
src += stride;
}
}
| false | FFmpeg | d6737539e77e78fca9a04914d51996cfd1ccc55c | static void intra_predict_vert_dc_8x8_msa(uint8_t *src, int32_t stride)
{
uint8_t lp_cnt;
uint32_t out0 = 0, out1 = 0;
v16u8 src_top;
v8u16 add;
v4u32 sum;
v4i32 res0, res1;
src_top = LD_UB(src - stride);
add = __msa_hadd_u_h(src_top, src_top);
sum = __msa_hadd_u_w(add, add);
sum = (v4u32) __msa_srari_w((v4i32) sum, 2);
res0 = (v4i32) __msa_splati_b((v16i8) sum, 0);
res1 = (v4i32) __msa_splati_b((v16i8) sum, 4);
out0 = __msa_copy_u_w(res0, 0);
out1 = __msa_copy_u_w(res1, 0);
for (lp_cnt = 8; lp_cnt--;) {
SW(out0, src);
SW(out1, src + 4);
src += stride;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(uint8_t *VAR_0, int32_t VAR_1)
{
uint8_t lp_cnt;
uint32_t out0 = 0, out1 = 0;
v16u8 src_top;
v8u16 add;
v4u32 sum;
v4i32 res0, res1;
src_top = LD_UB(VAR_0 - VAR_1);
add = __msa_hadd_u_h(src_top, src_top);
sum = __msa_hadd_u_w(add, add);
sum = (v4u32) __msa_srari_w((v4i32) sum, 2);
res0 = (v4i32) __msa_splati_b((v16i8) sum, 0);
res1 = (v4i32) __msa_splati_b((v16i8) sum, 4);
out0 = __msa_copy_u_w(res0, 0);
out1 = __msa_copy_u_w(res1, 0);
for (lp_cnt = 8; lp_cnt--;) {
SW(out0, VAR_0);
SW(out1, VAR_0 + 4);
VAR_0 += VAR_1;
}
}
| [
"static void FUNC_0(uint8_t *VAR_0, int32_t VAR_1)\n{",
"uint8_t lp_cnt;",
"uint32_t out0 = 0, out1 = 0;",
"v16u8 src_top;",
"v8u16 add;",
"v4u32 sum;",
"v4i32 res0, res1;",
"src_top = LD_UB(VAR_0 - VAR_1);",
"add = __msa_hadd_u_h(src_top, src_top);",
"sum = __msa_hadd_u_w(add, add);",
"sum = (v4u32) __msa_srari_w((v4i32) sum, 2);",
"res0 = (v4i32) __msa_splati_b((v16i8) sum, 0);",
"res1 = (v4i32) __msa_splati_b((v16i8) sum, 4);",
"out0 = __msa_copy_u_w(res0, 0);",
"out1 = __msa_copy_u_w(res1, 0);",
"for (lp_cnt = 8; lp_cnt--;) {",
"SW(out0, VAR_0);",
"SW(out1, VAR_0 + 4);",
"VAR_0 += VAR_1;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
]
] |
3,253 | int bdrv_block_status(BlockDriverState *bs, int64_t offset, int64_t bytes,
int64_t *pnum, int64_t *map, BlockDriverState **file)
{
int64_t ret;
int n;
assert(QEMU_IS_ALIGNED(offset | bytes, BDRV_SECTOR_SIZE));
assert(pnum);
/*
* The contract allows us to return pnum smaller than bytes, even
* if the next query would see the same status; we truncate the
* request to avoid overflowing the driver's 32-bit interface.
*/
bytes = MIN(bytes, BDRV_REQUEST_MAX_BYTES);
ret = bdrv_get_block_status_above(bs, backing_bs(bs),
offset >> BDRV_SECTOR_BITS,
bytes >> BDRV_SECTOR_BITS, &n, file);
if (ret < 0) {
assert(INT_MIN <= ret);
*pnum = 0;
return ret;
}
*pnum = n * BDRV_SECTOR_SIZE;
if (map) {
*map = ret & BDRV_BLOCK_OFFSET_MASK;
} else {
ret &= ~BDRV_BLOCK_OFFSET_VALID;
}
return ret & ~BDRV_BLOCK_OFFSET_MASK;
}
| false | qemu | 3182664220571d11d4fe03ecdc10fcc1e842ed32 | int bdrv_block_status(BlockDriverState *bs, int64_t offset, int64_t bytes,
int64_t *pnum, int64_t *map, BlockDriverState **file)
{
int64_t ret;
int n;
assert(QEMU_IS_ALIGNED(offset | bytes, BDRV_SECTOR_SIZE));
assert(pnum);
bytes = MIN(bytes, BDRV_REQUEST_MAX_BYTES);
ret = bdrv_get_block_status_above(bs, backing_bs(bs),
offset >> BDRV_SECTOR_BITS,
bytes >> BDRV_SECTOR_BITS, &n, file);
if (ret < 0) {
assert(INT_MIN <= ret);
*pnum = 0;
return ret;
}
*pnum = n * BDRV_SECTOR_SIZE;
if (map) {
*map = ret & BDRV_BLOCK_OFFSET_MASK;
} else {
ret &= ~BDRV_BLOCK_OFFSET_VALID;
}
return ret & ~BDRV_BLOCK_OFFSET_MASK;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1, int64_t VAR_2,
int64_t *VAR_3, int64_t *VAR_4, BlockDriverState **VAR_5)
{
int64_t ret;
int VAR_6;
assert(QEMU_IS_ALIGNED(VAR_1 | VAR_2, BDRV_SECTOR_SIZE));
assert(VAR_3);
VAR_2 = MIN(VAR_2, BDRV_REQUEST_MAX_BYTES);
ret = bdrv_get_block_status_above(VAR_0, backing_bs(VAR_0),
VAR_1 >> BDRV_SECTOR_BITS,
VAR_2 >> BDRV_SECTOR_BITS, &VAR_6, VAR_5);
if (ret < 0) {
assert(INT_MIN <= ret);
*VAR_3 = 0;
return ret;
}
*VAR_3 = VAR_6 * BDRV_SECTOR_SIZE;
if (VAR_4) {
*VAR_4 = ret & BDRV_BLOCK_OFFSET_MASK;
} else {
ret &= ~BDRV_BLOCK_OFFSET_VALID;
}
return ret & ~BDRV_BLOCK_OFFSET_MASK;
}
| [
"int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1, int64_t VAR_2,\nint64_t *VAR_3, int64_t *VAR_4, BlockDriverState **VAR_5)\n{",
"int64_t ret;",
"int VAR_6;",
"assert(QEMU_IS_ALIGNED(VAR_1 | VAR_2, BDRV_SECTOR_SIZE));",
"assert(VAR_3);",
"VAR_2 = MIN(VAR_2, BDRV_REQUEST_MAX_BYTES);",
"ret = bdrv_get_block_status_above(VAR_0, backing_bs(VAR_0),\nVAR_1 >> BDRV_SECTOR_BITS,\nVAR_2 >> BDRV_SECTOR_BITS, &VAR_6, VAR_5);",
"if (ret < 0) {",
"assert(INT_MIN <= ret);",
"*VAR_3 = 0;",
"return ret;",
"}",
"*VAR_3 = VAR_6 * BDRV_SECTOR_SIZE;",
"if (VAR_4) {",
"*VAR_4 = ret & BDRV_BLOCK_OFFSET_MASK;",
"} else {",
"ret &= ~BDRV_BLOCK_OFFSET_VALID;",
"}",
"return ret & ~BDRV_BLOCK_OFFSET_MASK;",
"}"
] | [
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
],
[
27
],
[
29,
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
]
] |
3,254 | int css_do_csch(SubchDev *sch)
{
SCSW *s = &sch->curr_status.scsw;
PMCW *p = &sch->curr_status.pmcw;
int ret;
if (!(p->flags & (PMCW_FLAGS_MASK_DNV | PMCW_FLAGS_MASK_ENA))) {
ret = -ENODEV;
goto out;
}
/* Trigger the clear function. */
s->ctrl &= ~(SCSW_CTRL_MASK_FCTL | SCSW_CTRL_MASK_ACTL);
s->ctrl |= SCSW_FCTL_CLEAR_FUNC | SCSW_ACTL_CLEAR_PEND;
do_subchannel_work(sch, NULL);
ret = 0;
out:
return ret;
}
| false | qemu | c679e74d2e29fa08ede9121d59aee4e9675611d7 | int css_do_csch(SubchDev *sch)
{
SCSW *s = &sch->curr_status.scsw;
PMCW *p = &sch->curr_status.pmcw;
int ret;
if (!(p->flags & (PMCW_FLAGS_MASK_DNV | PMCW_FLAGS_MASK_ENA))) {
ret = -ENODEV;
goto out;
}
s->ctrl &= ~(SCSW_CTRL_MASK_FCTL | SCSW_CTRL_MASK_ACTL);
s->ctrl |= SCSW_FCTL_CLEAR_FUNC | SCSW_ACTL_CLEAR_PEND;
do_subchannel_work(sch, NULL);
ret = 0;
out:
return ret;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(SubchDev *VAR_0)
{
SCSW *s = &VAR_0->curr_status.scsw;
PMCW *p = &VAR_0->curr_status.pmcw;
int VAR_1;
if (!(p->flags & (PMCW_FLAGS_MASK_DNV | PMCW_FLAGS_MASK_ENA))) {
VAR_1 = -ENODEV;
goto out;
}
s->ctrl &= ~(SCSW_CTRL_MASK_FCTL | SCSW_CTRL_MASK_ACTL);
s->ctrl |= SCSW_FCTL_CLEAR_FUNC | SCSW_ACTL_CLEAR_PEND;
do_subchannel_work(VAR_0, NULL);
VAR_1 = 0;
out:
return VAR_1;
}
| [
"int FUNC_0(SubchDev *VAR_0)\n{",
"SCSW *s = &VAR_0->curr_status.scsw;",
"PMCW *p = &VAR_0->curr_status.pmcw;",
"int VAR_1;",
"if (!(p->flags & (PMCW_FLAGS_MASK_DNV | PMCW_FLAGS_MASK_ENA))) {",
"VAR_1 = -ENODEV;",
"goto out;",
"}",
"s->ctrl &= ~(SCSW_CTRL_MASK_FCTL | SCSW_CTRL_MASK_ACTL);",
"s->ctrl |= SCSW_FCTL_CLEAR_FUNC | SCSW_ACTL_CLEAR_PEND;",
"do_subchannel_work(VAR_0, NULL);",
"VAR_1 = 0;",
"out:\nreturn VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37,
39
],
[
41
]
] |
3,257 | build_dsdt(GArray *table_data, BIOSLinker *linker,
AcpiPmInfo *pm, AcpiMiscInfo *misc,
Range *pci_hole, Range *pci_hole64, MachineState *machine)
{
CrsRangeEntry *entry;
Aml *dsdt, *sb_scope, *scope, *dev, *method, *field, *pkg, *crs;
GPtrArray *mem_ranges = g_ptr_array_new_with_free_func(crs_range_free);
GPtrArray *io_ranges = g_ptr_array_new_with_free_func(crs_range_free);
PCMachineState *pcms = PC_MACHINE(machine);
PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(machine);
uint32_t nr_mem = machine->ram_slots;
int root_bus_limit = 0xFF;
PCIBus *bus = NULL;
int i;
dsdt = init_aml_allocator();
/* Reserve space for header */
acpi_data_push(dsdt->buf, sizeof(AcpiTableHeader));
build_dbg_aml(dsdt);
if (misc->is_piix4) {
sb_scope = aml_scope("_SB");
dev = aml_device("PCI0");
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A03")));
aml_append(dev, aml_name_decl("_ADR", aml_int(0)));
aml_append(dev, aml_name_decl("_UID", aml_int(1)));
aml_append(sb_scope, dev);
aml_append(dsdt, sb_scope);
build_hpet_aml(dsdt);
build_piix4_pm(dsdt);
build_piix4_isa_bridge(dsdt);
build_isa_devices_aml(dsdt);
build_piix4_pci_hotplug(dsdt);
build_piix4_pci0_int(dsdt);
} else {
sb_scope = aml_scope("_SB");
aml_append(sb_scope,
aml_operation_region("PCST", AML_SYSTEM_IO, aml_int(0xae00), 0x0c));
aml_append(sb_scope,
aml_operation_region("PCSB", AML_SYSTEM_IO, aml_int(0xae0c), 0x01));
field = aml_field("PCSB", AML_ANY_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
aml_append(field, aml_named_field("PCIB", 8));
aml_append(sb_scope, field);
aml_append(dsdt, sb_scope);
sb_scope = aml_scope("_SB");
dev = aml_device("PCI0");
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A08")));
aml_append(dev, aml_name_decl("_CID", aml_eisaid("PNP0A03")));
aml_append(dev, aml_name_decl("_ADR", aml_int(0)));
aml_append(dev, aml_name_decl("_UID", aml_int(1)));
aml_append(dev, aml_name_decl("SUPP", aml_int(0)));
aml_append(dev, aml_name_decl("CTRL", aml_int(0)));
aml_append(dev, build_q35_osc_method());
aml_append(sb_scope, dev);
aml_append(dsdt, sb_scope);
build_hpet_aml(dsdt);
build_q35_isa_bridge(dsdt);
build_isa_devices_aml(dsdt);
build_q35_pci0_int(dsdt);
}
if (pcmc->legacy_cpu_hotplug) {
build_legacy_cpu_hotplug_aml(dsdt, machine, pm->cpu_hp_io_base);
} else {
CPUHotplugFeatures opts = {
.apci_1_compatible = true, .has_legacy_cphp = true
};
build_cpus_aml(dsdt, machine, opts, pm->cpu_hp_io_base,
"\\_SB.PCI0", "\\_GPE._E02");
}
build_memory_hotplug_aml(dsdt, nr_mem, pm->mem_hp_io_base,
pm->mem_hp_io_len);
scope = aml_scope("_GPE");
{
aml_append(scope, aml_name_decl("_HID", aml_string("ACPI0006")));
if (misc->is_piix4) {
method = aml_method("_E01", 0, AML_NOTSERIALIZED);
aml_append(method,
aml_acquire(aml_name("\\_SB.PCI0.BLCK"), 0xFFFF));
aml_append(method, aml_call0("\\_SB.PCI0.PCNT"));
aml_append(method, aml_release(aml_name("\\_SB.PCI0.BLCK")));
aml_append(scope, method);
}
method = aml_method("_E03", 0, AML_NOTSERIALIZED);
aml_append(method, aml_call0(MEMORY_HOTPLUG_HANDLER_PATH));
aml_append(scope, method);
}
aml_append(dsdt, scope);
bus = PC_MACHINE(machine)->bus;
if (bus) {
QLIST_FOREACH(bus, &bus->child, sibling) {
uint8_t bus_num = pci_bus_num(bus);
uint8_t numa_node = pci_bus_numa_node(bus);
/* look only for expander root buses */
if (!pci_bus_is_root(bus)) {
continue;
}
if (bus_num < root_bus_limit) {
root_bus_limit = bus_num - 1;
}
scope = aml_scope("\\_SB");
dev = aml_device("PC%.02X", bus_num);
aml_append(dev, aml_name_decl("_UID", aml_int(bus_num)));
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A03")));
aml_append(dev, aml_name_decl("_BBN", aml_int(bus_num)));
if (numa_node != NUMA_NODE_UNASSIGNED) {
aml_append(dev, aml_name_decl("_PXM", aml_int(numa_node)));
}
aml_append(dev, build_prt(false));
crs = build_crs(PCI_HOST_BRIDGE(BUS(bus)->parent),
io_ranges, mem_ranges);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
aml_append(dsdt, scope);
}
}
scope = aml_scope("\\_SB.PCI0");
/* build PCI0._CRS */
crs = aml_resource_template();
aml_append(crs,
aml_word_bus_number(AML_MIN_FIXED, AML_MAX_FIXED, AML_POS_DECODE,
0x0000, 0x0, root_bus_limit,
0x0000, root_bus_limit + 1));
aml_append(crs, aml_io(AML_DECODE16, 0x0CF8, 0x0CF8, 0x01, 0x08));
aml_append(crs,
aml_word_io(AML_MIN_FIXED, AML_MAX_FIXED,
AML_POS_DECODE, AML_ENTIRE_RANGE,
0x0000, 0x0000, 0x0CF7, 0x0000, 0x0CF8));
crs_replace_with_free_ranges(io_ranges, 0x0D00, 0xFFFF);
for (i = 0; i < io_ranges->len; i++) {
entry = g_ptr_array_index(io_ranges, i);
aml_append(crs,
aml_word_io(AML_MIN_FIXED, AML_MAX_FIXED,
AML_POS_DECODE, AML_ENTIRE_RANGE,
0x0000, entry->base, entry->limit,
0x0000, entry->limit - entry->base + 1));
}
aml_append(crs,
aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
AML_CACHEABLE, AML_READ_WRITE,
0, 0x000A0000, 0x000BFFFF, 0, 0x00020000));
crs_replace_with_free_ranges(mem_ranges,
pci_hole->begin, pci_hole->end - 1);
for (i = 0; i < mem_ranges->len; i++) {
entry = g_ptr_array_index(mem_ranges, i);
aml_append(crs,
aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
AML_NON_CACHEABLE, AML_READ_WRITE,
0, entry->base, entry->limit,
0, entry->limit - entry->base + 1));
}
if (pci_hole64->begin) {
aml_append(crs,
aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
AML_CACHEABLE, AML_READ_WRITE,
0, pci_hole64->begin, pci_hole64->end - 1, 0,
pci_hole64->end - pci_hole64->begin));
}
if (misc->tpm_version != TPM_VERSION_UNSPEC) {
aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
}
aml_append(scope, aml_name_decl("_CRS", crs));
/* reserve GPE0 block resources */
dev = aml_device("GPE0");
aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
aml_append(dev, aml_name_decl("_UID", aml_string("GPE0 resources")));
/* device present, functioning, decoding, not shown in UI */
aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, pm->gpe0_blk, pm->gpe0_blk, 1, pm->gpe0_blk_len)
);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
g_ptr_array_free(io_ranges, true);
g_ptr_array_free(mem_ranges, true);
/* reserve PCIHP resources */
if (pm->pcihp_io_len) {
dev = aml_device("PHPR");
aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
aml_append(dev,
aml_name_decl("_UID", aml_string("PCI Hotplug resources")));
/* device present, functioning, decoding, not shown in UI */
aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, pm->pcihp_io_base, pm->pcihp_io_base, 1,
pm->pcihp_io_len)
);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
}
aml_append(dsdt, scope);
/* create S3_ / S4_ / S5_ packages if necessary */
scope = aml_scope("\\");
if (!pm->s3_disabled) {
pkg = aml_package(4);
aml_append(pkg, aml_int(1)); /* PM1a_CNT.SLP_TYP */
aml_append(pkg, aml_int(1)); /* PM1b_CNT.SLP_TYP, FIXME: not impl. */
aml_append(pkg, aml_int(0)); /* reserved */
aml_append(pkg, aml_int(0)); /* reserved */
aml_append(scope, aml_name_decl("_S3", pkg));
}
if (!pm->s4_disabled) {
pkg = aml_package(4);
aml_append(pkg, aml_int(pm->s4_val)); /* PM1a_CNT.SLP_TYP */
/* PM1b_CNT.SLP_TYP, FIXME: not impl. */
aml_append(pkg, aml_int(pm->s4_val));
aml_append(pkg, aml_int(0)); /* reserved */
aml_append(pkg, aml_int(0)); /* reserved */
aml_append(scope, aml_name_decl("_S4", pkg));
}
pkg = aml_package(4);
aml_append(pkg, aml_int(0)); /* PM1a_CNT.SLP_TYP */
aml_append(pkg, aml_int(0)); /* PM1b_CNT.SLP_TYP not impl. */
aml_append(pkg, aml_int(0)); /* reserved */
aml_append(pkg, aml_int(0)); /* reserved */
aml_append(scope, aml_name_decl("_S5", pkg));
aml_append(dsdt, scope);
/* create fw_cfg node, unconditionally */
{
/* when using port i/o, the 8-bit data register *always* overlaps
* with half of the 16-bit control register. Hence, the total size
* of the i/o region used is FW_CFG_CTL_SIZE; when using DMA, the
* DMA control register is located at FW_CFG_DMA_IO_BASE + 4 */
uint8_t io_size = object_property_get_bool(OBJECT(pcms->fw_cfg),
"dma_enabled", NULL) ?
ROUND_UP(FW_CFG_CTL_SIZE, 4) + sizeof(dma_addr_t) :
FW_CFG_CTL_SIZE;
scope = aml_scope("\\_SB.PCI0");
dev = aml_device("FWCF");
aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0002")));
/* device present, functioning, decoding, not shown in UI */
aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, FW_CFG_IO_BASE, FW_CFG_IO_BASE, 0x01, io_size)
);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
aml_append(dsdt, scope);
}
if (misc->applesmc_io_base) {
scope = aml_scope("\\_SB.PCI0.ISA");
dev = aml_device("SMC");
aml_append(dev, aml_name_decl("_HID", aml_eisaid("APP0001")));
/* device present, functioning, decoding, not shown in UI */
aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, misc->applesmc_io_base, misc->applesmc_io_base,
0x01, APPLESMC_MAX_DATA_LENGTH)
);
aml_append(crs, aml_irq_no_flags(6));
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
aml_append(dsdt, scope);
}
if (misc->pvpanic_port) {
scope = aml_scope("\\_SB.PCI0.ISA");
dev = aml_device("PEVT");
aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0001")));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, misc->pvpanic_port, misc->pvpanic_port, 1, 1)
);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(dev, aml_operation_region("PEOR", AML_SYSTEM_IO,
aml_int(misc->pvpanic_port), 1));
field = aml_field("PEOR", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);
aml_append(field, aml_named_field("PEPT", 8));
aml_append(dev, field);
/* device present, functioning, decoding, shown in UI */
aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
method = aml_method("RDPT", 0, AML_NOTSERIALIZED);
aml_append(method, aml_store(aml_name("PEPT"), aml_local(0)));
aml_append(method, aml_return(aml_local(0)));
aml_append(dev, method);
method = aml_method("WRPT", 1, AML_NOTSERIALIZED);
aml_append(method, aml_store(aml_arg(0), aml_name("PEPT")));
aml_append(dev, method);
aml_append(scope, dev);
aml_append(dsdt, scope);
}
sb_scope = aml_scope("\\_SB");
{
build_memory_devices(sb_scope, nr_mem, pm->mem_hp_io_base,
pm->mem_hp_io_len);
{
Object *pci_host;
PCIBus *bus = NULL;
pci_host = acpi_get_i386_pci_host();
if (pci_host) {
bus = PCI_HOST_BRIDGE(pci_host)->bus;
}
if (bus) {
Aml *scope = aml_scope("PCI0");
/* Scan all PCI buses. Generate tables to support hotplug. */
build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
if (misc->tpm_version != TPM_VERSION_UNSPEC) {
dev = aml_device("ISA.TPM");
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C31")));
aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
crs = aml_resource_template();
aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
/*
FIXME: TPM_TIS_IRQ=5 conflicts with PNP0C0F irqs,
Rewrite to take IRQ from TPM device model and
fix default IRQ value there to use some unused IRQ
*/
/* aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ)); */
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
}
aml_append(sb_scope, scope);
}
}
aml_append(dsdt, sb_scope);
}
/* copy AML table into ACPI tables blob and patch header there */
g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len);
build_header(linker, table_data,
(void *)(table_data->data + table_data->len - dsdt->buf->len),
"DSDT", dsdt->buf->len, 1, NULL, NULL);
free_aml_allocator();
}
| false | qemu | a0efbf16604770b9d805bcf210ec29942321134f | build_dsdt(GArray *table_data, BIOSLinker *linker,
AcpiPmInfo *pm, AcpiMiscInfo *misc,
Range *pci_hole, Range *pci_hole64, MachineState *machine)
{
CrsRangeEntry *entry;
Aml *dsdt, *sb_scope, *scope, *dev, *method, *field, *pkg, *crs;
GPtrArray *mem_ranges = g_ptr_array_new_with_free_func(crs_range_free);
GPtrArray *io_ranges = g_ptr_array_new_with_free_func(crs_range_free);
PCMachineState *pcms = PC_MACHINE(machine);
PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(machine);
uint32_t nr_mem = machine->ram_slots;
int root_bus_limit = 0xFF;
PCIBus *bus = NULL;
int i;
dsdt = init_aml_allocator();
acpi_data_push(dsdt->buf, sizeof(AcpiTableHeader));
build_dbg_aml(dsdt);
if (misc->is_piix4) {
sb_scope = aml_scope("_SB");
dev = aml_device("PCI0");
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A03")));
aml_append(dev, aml_name_decl("_ADR", aml_int(0)));
aml_append(dev, aml_name_decl("_UID", aml_int(1)));
aml_append(sb_scope, dev);
aml_append(dsdt, sb_scope);
build_hpet_aml(dsdt);
build_piix4_pm(dsdt);
build_piix4_isa_bridge(dsdt);
build_isa_devices_aml(dsdt);
build_piix4_pci_hotplug(dsdt);
build_piix4_pci0_int(dsdt);
} else {
sb_scope = aml_scope("_SB");
aml_append(sb_scope,
aml_operation_region("PCST", AML_SYSTEM_IO, aml_int(0xae00), 0x0c));
aml_append(sb_scope,
aml_operation_region("PCSB", AML_SYSTEM_IO, aml_int(0xae0c), 0x01));
field = aml_field("PCSB", AML_ANY_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
aml_append(field, aml_named_field("PCIB", 8));
aml_append(sb_scope, field);
aml_append(dsdt, sb_scope);
sb_scope = aml_scope("_SB");
dev = aml_device("PCI0");
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A08")));
aml_append(dev, aml_name_decl("_CID", aml_eisaid("PNP0A03")));
aml_append(dev, aml_name_decl("_ADR", aml_int(0)));
aml_append(dev, aml_name_decl("_UID", aml_int(1)));
aml_append(dev, aml_name_decl("SUPP", aml_int(0)));
aml_append(dev, aml_name_decl("CTRL", aml_int(0)));
aml_append(dev, build_q35_osc_method());
aml_append(sb_scope, dev);
aml_append(dsdt, sb_scope);
build_hpet_aml(dsdt);
build_q35_isa_bridge(dsdt);
build_isa_devices_aml(dsdt);
build_q35_pci0_int(dsdt);
}
if (pcmc->legacy_cpu_hotplug) {
build_legacy_cpu_hotplug_aml(dsdt, machine, pm->cpu_hp_io_base);
} else {
CPUHotplugFeatures opts = {
.apci_1_compatible = true, .has_legacy_cphp = true
};
build_cpus_aml(dsdt, machine, opts, pm->cpu_hp_io_base,
"\\_SB.PCI0", "\\_GPE._E02");
}
build_memory_hotplug_aml(dsdt, nr_mem, pm->mem_hp_io_base,
pm->mem_hp_io_len);
scope = aml_scope("_GPE");
{
aml_append(scope, aml_name_decl("_HID", aml_string("ACPI0006")));
if (misc->is_piix4) {
method = aml_method("_E01", 0, AML_NOTSERIALIZED);
aml_append(method,
aml_acquire(aml_name("\\_SB.PCI0.BLCK"), 0xFFFF));
aml_append(method, aml_call0("\\_SB.PCI0.PCNT"));
aml_append(method, aml_release(aml_name("\\_SB.PCI0.BLCK")));
aml_append(scope, method);
}
method = aml_method("_E03", 0, AML_NOTSERIALIZED);
aml_append(method, aml_call0(MEMORY_HOTPLUG_HANDLER_PATH));
aml_append(scope, method);
}
aml_append(dsdt, scope);
bus = PC_MACHINE(machine)->bus;
if (bus) {
QLIST_FOREACH(bus, &bus->child, sibling) {
uint8_t bus_num = pci_bus_num(bus);
uint8_t numa_node = pci_bus_numa_node(bus);
if (!pci_bus_is_root(bus)) {
continue;
}
if (bus_num < root_bus_limit) {
root_bus_limit = bus_num - 1;
}
scope = aml_scope("\\_SB");
dev = aml_device("PC%.02X", bus_num);
aml_append(dev, aml_name_decl("_UID", aml_int(bus_num)));
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A03")));
aml_append(dev, aml_name_decl("_BBN", aml_int(bus_num)));
if (numa_node != NUMA_NODE_UNASSIGNED) {
aml_append(dev, aml_name_decl("_PXM", aml_int(numa_node)));
}
aml_append(dev, build_prt(false));
crs = build_crs(PCI_HOST_BRIDGE(BUS(bus)->parent),
io_ranges, mem_ranges);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
aml_append(dsdt, scope);
}
}
scope = aml_scope("\\_SB.PCI0");
crs = aml_resource_template();
aml_append(crs,
aml_word_bus_number(AML_MIN_FIXED, AML_MAX_FIXED, AML_POS_DECODE,
0x0000, 0x0, root_bus_limit,
0x0000, root_bus_limit + 1));
aml_append(crs, aml_io(AML_DECODE16, 0x0CF8, 0x0CF8, 0x01, 0x08));
aml_append(crs,
aml_word_io(AML_MIN_FIXED, AML_MAX_FIXED,
AML_POS_DECODE, AML_ENTIRE_RANGE,
0x0000, 0x0000, 0x0CF7, 0x0000, 0x0CF8));
crs_replace_with_free_ranges(io_ranges, 0x0D00, 0xFFFF);
for (i = 0; i < io_ranges->len; i++) {
entry = g_ptr_array_index(io_ranges, i);
aml_append(crs,
aml_word_io(AML_MIN_FIXED, AML_MAX_FIXED,
AML_POS_DECODE, AML_ENTIRE_RANGE,
0x0000, entry->base, entry->limit,
0x0000, entry->limit - entry->base + 1));
}
aml_append(crs,
aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
AML_CACHEABLE, AML_READ_WRITE,
0, 0x000A0000, 0x000BFFFF, 0, 0x00020000));
crs_replace_with_free_ranges(mem_ranges,
pci_hole->begin, pci_hole->end - 1);
for (i = 0; i < mem_ranges->len; i++) {
entry = g_ptr_array_index(mem_ranges, i);
aml_append(crs,
aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
AML_NON_CACHEABLE, AML_READ_WRITE,
0, entry->base, entry->limit,
0, entry->limit - entry->base + 1));
}
if (pci_hole64->begin) {
aml_append(crs,
aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
AML_CACHEABLE, AML_READ_WRITE,
0, pci_hole64->begin, pci_hole64->end - 1, 0,
pci_hole64->end - pci_hole64->begin));
}
if (misc->tpm_version != TPM_VERSION_UNSPEC) {
aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
}
aml_append(scope, aml_name_decl("_CRS", crs));
dev = aml_device("GPE0");
aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
aml_append(dev, aml_name_decl("_UID", aml_string("GPE0 resources")));
aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, pm->gpe0_blk, pm->gpe0_blk, 1, pm->gpe0_blk_len)
);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
g_ptr_array_free(io_ranges, true);
g_ptr_array_free(mem_ranges, true);
if (pm->pcihp_io_len) {
dev = aml_device("PHPR");
aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
aml_append(dev,
aml_name_decl("_UID", aml_string("PCI Hotplug resources")));
aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, pm->pcihp_io_base, pm->pcihp_io_base, 1,
pm->pcihp_io_len)
);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
}
aml_append(dsdt, scope);
scope = aml_scope("\\");
if (!pm->s3_disabled) {
pkg = aml_package(4);
aml_append(pkg, aml_int(1));
aml_append(pkg, aml_int(1));
aml_append(pkg, aml_int(0));
aml_append(pkg, aml_int(0));
aml_append(scope, aml_name_decl("_S3", pkg));
}
if (!pm->s4_disabled) {
pkg = aml_package(4);
aml_append(pkg, aml_int(pm->s4_val));
aml_append(pkg, aml_int(pm->s4_val));
aml_append(pkg, aml_int(0));
aml_append(pkg, aml_int(0));
aml_append(scope, aml_name_decl("_S4", pkg));
}
pkg = aml_package(4);
aml_append(pkg, aml_int(0));
aml_append(pkg, aml_int(0));
aml_append(pkg, aml_int(0));
aml_append(pkg, aml_int(0));
aml_append(scope, aml_name_decl("_S5", pkg));
aml_append(dsdt, scope);
{
uint8_t io_size = object_property_get_bool(OBJECT(pcms->fw_cfg),
"dma_enabled", NULL) ?
ROUND_UP(FW_CFG_CTL_SIZE, 4) + sizeof(dma_addr_t) :
FW_CFG_CTL_SIZE;
scope = aml_scope("\\_SB.PCI0");
dev = aml_device("FWCF");
aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0002")));
aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, FW_CFG_IO_BASE, FW_CFG_IO_BASE, 0x01, io_size)
);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
aml_append(dsdt, scope);
}
if (misc->applesmc_io_base) {
scope = aml_scope("\\_SB.PCI0.ISA");
dev = aml_device("SMC");
aml_append(dev, aml_name_decl("_HID", aml_eisaid("APP0001")));
aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, misc->applesmc_io_base, misc->applesmc_io_base,
0x01, APPLESMC_MAX_DATA_LENGTH)
);
aml_append(crs, aml_irq_no_flags(6));
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
aml_append(dsdt, scope);
}
if (misc->pvpanic_port) {
scope = aml_scope("\\_SB.PCI0.ISA");
dev = aml_device("PEVT");
aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0001")));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, misc->pvpanic_port, misc->pvpanic_port, 1, 1)
);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(dev, aml_operation_region("PEOR", AML_SYSTEM_IO,
aml_int(misc->pvpanic_port), 1));
field = aml_field("PEOR", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);
aml_append(field, aml_named_field("PEPT", 8));
aml_append(dev, field);
aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
method = aml_method("RDPT", 0, AML_NOTSERIALIZED);
aml_append(method, aml_store(aml_name("PEPT"), aml_local(0)));
aml_append(method, aml_return(aml_local(0)));
aml_append(dev, method);
method = aml_method("WRPT", 1, AML_NOTSERIALIZED);
aml_append(method, aml_store(aml_arg(0), aml_name("PEPT")));
aml_append(dev, method);
aml_append(scope, dev);
aml_append(dsdt, scope);
}
sb_scope = aml_scope("\\_SB");
{
build_memory_devices(sb_scope, nr_mem, pm->mem_hp_io_base,
pm->mem_hp_io_len);
{
Object *pci_host;
PCIBus *bus = NULL;
pci_host = acpi_get_i386_pci_host();
if (pci_host) {
bus = PCI_HOST_BRIDGE(pci_host)->bus;
}
if (bus) {
Aml *scope = aml_scope("PCI0");
build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
if (misc->tpm_version != TPM_VERSION_UNSPEC) {
dev = aml_device("ISA.TPM");
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C31")));
aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
crs = aml_resource_template();
aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
}
aml_append(sb_scope, scope);
}
}
aml_append(dsdt, sb_scope);
}
g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len);
build_header(linker, table_data,
(void *)(table_data->data + table_data->len - dsdt->buf->len),
"DSDT", dsdt->buf->len, 1, NULL, NULL);
free_aml_allocator();
}
| {
"code": [],
"line_no": []
} | FUNC_0(GArray *VAR_0, BIOSLinker *VAR_1,
AcpiPmInfo *VAR_2, AcpiMiscInfo *VAR_3,
Range *VAR_4, Range *VAR_5, MachineState *VAR_6)
{
CrsRangeEntry *entry;
Aml *dsdt, *sb_scope, *scope, *dev, *method, *field, *pkg, *crs;
GPtrArray *mem_ranges = g_ptr_array_new_with_free_func(crs_range_free);
GPtrArray *io_ranges = g_ptr_array_new_with_free_func(crs_range_free);
PCMachineState *pcms = PC_MACHINE(VAR_6);
PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(VAR_6);
uint32_t nr_mem = VAR_6->ram_slots;
int VAR_7 = 0xFF;
PCIBus *bus = NULL;
int VAR_8;
dsdt = init_aml_allocator();
acpi_data_push(dsdt->buf, sizeof(AcpiTableHeader));
build_dbg_aml(dsdt);
if (VAR_3->is_piix4) {
sb_scope = aml_scope("_SB");
dev = aml_device("PCI0");
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A03")));
aml_append(dev, aml_name_decl("_ADR", aml_int(0)));
aml_append(dev, aml_name_decl("_UID", aml_int(1)));
aml_append(sb_scope, dev);
aml_append(dsdt, sb_scope);
build_hpet_aml(dsdt);
build_piix4_pm(dsdt);
build_piix4_isa_bridge(dsdt);
build_isa_devices_aml(dsdt);
build_piix4_pci_hotplug(dsdt);
build_piix4_pci0_int(dsdt);
} else {
sb_scope = aml_scope("_SB");
aml_append(sb_scope,
aml_operation_region("PCST", AML_SYSTEM_IO, aml_int(0xae00), 0x0c));
aml_append(sb_scope,
aml_operation_region("PCSB", AML_SYSTEM_IO, aml_int(0xae0c), 0x01));
field = aml_field("PCSB", AML_ANY_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
aml_append(field, aml_named_field("PCIB", 8));
aml_append(sb_scope, field);
aml_append(dsdt, sb_scope);
sb_scope = aml_scope("_SB");
dev = aml_device("PCI0");
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A08")));
aml_append(dev, aml_name_decl("_CID", aml_eisaid("PNP0A03")));
aml_append(dev, aml_name_decl("_ADR", aml_int(0)));
aml_append(dev, aml_name_decl("_UID", aml_int(1)));
aml_append(dev, aml_name_decl("SUPP", aml_int(0)));
aml_append(dev, aml_name_decl("CTRL", aml_int(0)));
aml_append(dev, build_q35_osc_method());
aml_append(sb_scope, dev);
aml_append(dsdt, sb_scope);
build_hpet_aml(dsdt);
build_q35_isa_bridge(dsdt);
build_isa_devices_aml(dsdt);
build_q35_pci0_int(dsdt);
}
if (pcmc->legacy_cpu_hotplug) {
build_legacy_cpu_hotplug_aml(dsdt, VAR_6, VAR_2->cpu_hp_io_base);
} else {
CPUHotplugFeatures opts = {
.apci_1_compatible = true, .has_legacy_cphp = true
};
build_cpus_aml(dsdt, VAR_6, opts, VAR_2->cpu_hp_io_base,
"\\_SB.PCI0", "\\_GPE._E02");
}
build_memory_hotplug_aml(dsdt, nr_mem, VAR_2->mem_hp_io_base,
VAR_2->mem_hp_io_len);
scope = aml_scope("_GPE");
{
aml_append(scope, aml_name_decl("_HID", aml_string("ACPI0006")));
if (VAR_3->is_piix4) {
method = aml_method("_E01", 0, AML_NOTSERIALIZED);
aml_append(method,
aml_acquire(aml_name("\\_SB.PCI0.BLCK"), 0xFFFF));
aml_append(method, aml_call0("\\_SB.PCI0.PCNT"));
aml_append(method, aml_release(aml_name("\\_SB.PCI0.BLCK")));
aml_append(scope, method);
}
method = aml_method("_E03", 0, AML_NOTSERIALIZED);
aml_append(method, aml_call0(MEMORY_HOTPLUG_HANDLER_PATH));
aml_append(scope, method);
}
aml_append(dsdt, scope);
bus = PC_MACHINE(VAR_6)->bus;
if (bus) {
QLIST_FOREACH(bus, &bus->child, sibling) {
uint8_t bus_num = pci_bus_num(bus);
uint8_t numa_node = pci_bus_numa_node(bus);
if (!pci_bus_is_root(bus)) {
continue;
}
if (bus_num < VAR_7) {
VAR_7 = bus_num - 1;
}
scope = aml_scope("\\_SB");
dev = aml_device("PC%.02X", bus_num);
aml_append(dev, aml_name_decl("_UID", aml_int(bus_num)));
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A03")));
aml_append(dev, aml_name_decl("_BBN", aml_int(bus_num)));
if (numa_node != NUMA_NODE_UNASSIGNED) {
aml_append(dev, aml_name_decl("_PXM", aml_int(numa_node)));
}
aml_append(dev, build_prt(false));
crs = build_crs(PCI_HOST_BRIDGE(BUS(bus)->parent),
io_ranges, mem_ranges);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
aml_append(dsdt, scope);
}
}
scope = aml_scope("\\_SB.PCI0");
crs = aml_resource_template();
aml_append(crs,
aml_word_bus_number(AML_MIN_FIXED, AML_MAX_FIXED, AML_POS_DECODE,
0x0000, 0x0, VAR_7,
0x0000, VAR_7 + 1));
aml_append(crs, aml_io(AML_DECODE16, 0x0CF8, 0x0CF8, 0x01, 0x08));
aml_append(crs,
aml_word_io(AML_MIN_FIXED, AML_MAX_FIXED,
AML_POS_DECODE, AML_ENTIRE_RANGE,
0x0000, 0x0000, 0x0CF7, 0x0000, 0x0CF8));
crs_replace_with_free_ranges(io_ranges, 0x0D00, 0xFFFF);
for (VAR_8 = 0; VAR_8 < io_ranges->len; VAR_8++) {
entry = g_ptr_array_index(io_ranges, VAR_8);
aml_append(crs,
aml_word_io(AML_MIN_FIXED, AML_MAX_FIXED,
AML_POS_DECODE, AML_ENTIRE_RANGE,
0x0000, entry->base, entry->limit,
0x0000, entry->limit - entry->base + 1));
}
aml_append(crs,
aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
AML_CACHEABLE, AML_READ_WRITE,
0, 0x000A0000, 0x000BFFFF, 0, 0x00020000));
crs_replace_with_free_ranges(mem_ranges,
VAR_4->begin, VAR_4->end - 1);
for (VAR_8 = 0; VAR_8 < mem_ranges->len; VAR_8++) {
entry = g_ptr_array_index(mem_ranges, VAR_8);
aml_append(crs,
aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
AML_NON_CACHEABLE, AML_READ_WRITE,
0, entry->base, entry->limit,
0, entry->limit - entry->base + 1));
}
if (VAR_5->begin) {
aml_append(crs,
aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
AML_CACHEABLE, AML_READ_WRITE,
0, VAR_5->begin, VAR_5->end - 1, 0,
VAR_5->end - VAR_5->begin));
}
if (VAR_3->tpm_version != TPM_VERSION_UNSPEC) {
aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
}
aml_append(scope, aml_name_decl("_CRS", crs));
dev = aml_device("GPE0");
aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
aml_append(dev, aml_name_decl("_UID", aml_string("GPE0 resources")));
aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, VAR_2->gpe0_blk, VAR_2->gpe0_blk, 1, VAR_2->gpe0_blk_len)
);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
g_ptr_array_free(io_ranges, true);
g_ptr_array_free(mem_ranges, true);
if (VAR_2->pcihp_io_len) {
dev = aml_device("PHPR");
aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
aml_append(dev,
aml_name_decl("_UID", aml_string("PCI Hotplug resources")));
aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, VAR_2->pcihp_io_base, VAR_2->pcihp_io_base, 1,
VAR_2->pcihp_io_len)
);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
}
aml_append(dsdt, scope);
scope = aml_scope("\\");
if (!VAR_2->s3_disabled) {
pkg = aml_package(4);
aml_append(pkg, aml_int(1));
aml_append(pkg, aml_int(1));
aml_append(pkg, aml_int(0));
aml_append(pkg, aml_int(0));
aml_append(scope, aml_name_decl("_S3", pkg));
}
if (!VAR_2->s4_disabled) {
pkg = aml_package(4);
aml_append(pkg, aml_int(VAR_2->s4_val));
aml_append(pkg, aml_int(VAR_2->s4_val));
aml_append(pkg, aml_int(0));
aml_append(pkg, aml_int(0));
aml_append(scope, aml_name_decl("_S4", pkg));
}
pkg = aml_package(4);
aml_append(pkg, aml_int(0));
aml_append(pkg, aml_int(0));
aml_append(pkg, aml_int(0));
aml_append(pkg, aml_int(0));
aml_append(scope, aml_name_decl("_S5", pkg));
aml_append(dsdt, scope);
{
uint8_t io_size = object_property_get_bool(OBJECT(pcms->fw_cfg),
"dma_enabled", NULL) ?
ROUND_UP(FW_CFG_CTL_SIZE, 4) + sizeof(dma_addr_t) :
FW_CFG_CTL_SIZE;
scope = aml_scope("\\_SB.PCI0");
dev = aml_device("FWCF");
aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0002")));
aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, FW_CFG_IO_BASE, FW_CFG_IO_BASE, 0x01, io_size)
);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
aml_append(dsdt, scope);
}
if (VAR_3->applesmc_io_base) {
scope = aml_scope("\\_SB.PCI0.ISA");
dev = aml_device("SMC");
aml_append(dev, aml_name_decl("_HID", aml_eisaid("APP0001")));
aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, VAR_3->applesmc_io_base, VAR_3->applesmc_io_base,
0x01, APPLESMC_MAX_DATA_LENGTH)
);
aml_append(crs, aml_irq_no_flags(6));
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
aml_append(dsdt, scope);
}
if (VAR_3->pvpanic_port) {
scope = aml_scope("\\_SB.PCI0.ISA");
dev = aml_device("PEVT");
aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0001")));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, VAR_3->pvpanic_port, VAR_3->pvpanic_port, 1, 1)
);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(dev, aml_operation_region("PEOR", AML_SYSTEM_IO,
aml_int(VAR_3->pvpanic_port), 1));
field = aml_field("PEOR", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);
aml_append(field, aml_named_field("PEPT", 8));
aml_append(dev, field);
aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
method = aml_method("RDPT", 0, AML_NOTSERIALIZED);
aml_append(method, aml_store(aml_name("PEPT"), aml_local(0)));
aml_append(method, aml_return(aml_local(0)));
aml_append(dev, method);
method = aml_method("WRPT", 1, AML_NOTSERIALIZED);
aml_append(method, aml_store(aml_arg(0), aml_name("PEPT")));
aml_append(dev, method);
aml_append(scope, dev);
aml_append(dsdt, scope);
}
sb_scope = aml_scope("\\_SB");
{
build_memory_devices(sb_scope, nr_mem, VAR_2->mem_hp_io_base,
VAR_2->mem_hp_io_len);
{
Object *pci_host;
PCIBus *bus = NULL;
pci_host = acpi_get_i386_pci_host();
if (pci_host) {
bus = PCI_HOST_BRIDGE(pci_host)->bus;
}
if (bus) {
Aml *scope = aml_scope("PCI0");
build_append_pci_bus_devices(scope, bus, VAR_2->pcihp_bridge_en);
if (VAR_3->tpm_version != TPM_VERSION_UNSPEC) {
dev = aml_device("ISA.TPM");
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C31")));
aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
crs = aml_resource_template();
aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
}
aml_append(sb_scope, scope);
}
}
aml_append(dsdt, sb_scope);
}
g_array_append_vals(VAR_0, dsdt->buf->data, dsdt->buf->len);
build_header(VAR_1, VAR_0,
(void *)(VAR_0->data + VAR_0->len - dsdt->buf->len),
"DSDT", dsdt->buf->len, 1, NULL, NULL);
free_aml_allocator();
}
| [
"FUNC_0(GArray *VAR_0, BIOSLinker *VAR_1,\nAcpiPmInfo *VAR_2, AcpiMiscInfo *VAR_3,\nRange *VAR_4, Range *VAR_5, MachineState *VAR_6)\n{",
"CrsRangeEntry *entry;",
"Aml *dsdt, *sb_scope, *scope, *dev, *method, *field, *pkg, *crs;",
"GPtrArray *mem_ranges = g_ptr_array_new_with_free_func(crs_range_free);",
"GPtrArray *io_ranges = g_ptr_array_new_with_free_func(crs_range_free);",
"PCMachineState *pcms = PC_MACHINE(VAR_6);",
"PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(VAR_6);",
"uint32_t nr_mem = VAR_6->ram_slots;",
"int VAR_7 = 0xFF;",
"PCIBus *bus = NULL;",
"int VAR_8;",
"dsdt = init_aml_allocator();",
"acpi_data_push(dsdt->buf, sizeof(AcpiTableHeader));",
"build_dbg_aml(dsdt);",
"if (VAR_3->is_piix4) {",
"sb_scope = aml_scope(\"_SB\");",
"dev = aml_device(\"PCI0\");",
"aml_append(dev, aml_name_decl(\"_HID\", aml_eisaid(\"PNP0A03\")));",
"aml_append(dev, aml_name_decl(\"_ADR\", aml_int(0)));",
"aml_append(dev, aml_name_decl(\"_UID\", aml_int(1)));",
"aml_append(sb_scope, dev);",
"aml_append(dsdt, sb_scope);",
"build_hpet_aml(dsdt);",
"build_piix4_pm(dsdt);",
"build_piix4_isa_bridge(dsdt);",
"build_isa_devices_aml(dsdt);",
"build_piix4_pci_hotplug(dsdt);",
"build_piix4_pci0_int(dsdt);",
"} else {",
"sb_scope = aml_scope(\"_SB\");",
"aml_append(sb_scope,\naml_operation_region(\"PCST\", AML_SYSTEM_IO, aml_int(0xae00), 0x0c));",
"aml_append(sb_scope,\naml_operation_region(\"PCSB\", AML_SYSTEM_IO, aml_int(0xae0c), 0x01));",
"field = aml_field(\"PCSB\", AML_ANY_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);",
"aml_append(field, aml_named_field(\"PCIB\", 8));",
"aml_append(sb_scope, field);",
"aml_append(dsdt, sb_scope);",
"sb_scope = aml_scope(\"_SB\");",
"dev = aml_device(\"PCI0\");",
"aml_append(dev, aml_name_decl(\"_HID\", aml_eisaid(\"PNP0A08\")));",
"aml_append(dev, aml_name_decl(\"_CID\", aml_eisaid(\"PNP0A03\")));",
"aml_append(dev, aml_name_decl(\"_ADR\", aml_int(0)));",
"aml_append(dev, aml_name_decl(\"_UID\", aml_int(1)));",
"aml_append(dev, aml_name_decl(\"SUPP\", aml_int(0)));",
"aml_append(dev, aml_name_decl(\"CTRL\", aml_int(0)));",
"aml_append(dev, build_q35_osc_method());",
"aml_append(sb_scope, dev);",
"aml_append(dsdt, sb_scope);",
"build_hpet_aml(dsdt);",
"build_q35_isa_bridge(dsdt);",
"build_isa_devices_aml(dsdt);",
"build_q35_pci0_int(dsdt);",
"}",
"if (pcmc->legacy_cpu_hotplug) {",
"build_legacy_cpu_hotplug_aml(dsdt, VAR_6, VAR_2->cpu_hp_io_base);",
"} else {",
"CPUHotplugFeatures opts = {",
".apci_1_compatible = true, .has_legacy_cphp = true\n};",
"build_cpus_aml(dsdt, VAR_6, opts, VAR_2->cpu_hp_io_base,\n\"\\\\_SB.PCI0\", \"\\\\_GPE._E02\");",
"}",
"build_memory_hotplug_aml(dsdt, nr_mem, VAR_2->mem_hp_io_base,\nVAR_2->mem_hp_io_len);",
"scope = aml_scope(\"_GPE\");",
"{",
"aml_append(scope, aml_name_decl(\"_HID\", aml_string(\"ACPI0006\")));",
"if (VAR_3->is_piix4) {",
"method = aml_method(\"_E01\", 0, AML_NOTSERIALIZED);",
"aml_append(method,\naml_acquire(aml_name(\"\\\\_SB.PCI0.BLCK\"), 0xFFFF));",
"aml_append(method, aml_call0(\"\\\\_SB.PCI0.PCNT\"));",
"aml_append(method, aml_release(aml_name(\"\\\\_SB.PCI0.BLCK\")));",
"aml_append(scope, method);",
"}",
"method = aml_method(\"_E03\", 0, AML_NOTSERIALIZED);",
"aml_append(method, aml_call0(MEMORY_HOTPLUG_HANDLER_PATH));",
"aml_append(scope, method);",
"}",
"aml_append(dsdt, scope);",
"bus = PC_MACHINE(VAR_6)->bus;",
"if (bus) {",
"QLIST_FOREACH(bus, &bus->child, sibling) {",
"uint8_t bus_num = pci_bus_num(bus);",
"uint8_t numa_node = pci_bus_numa_node(bus);",
"if (!pci_bus_is_root(bus)) {",
"continue;",
"}",
"if (bus_num < VAR_7) {",
"VAR_7 = bus_num - 1;",
"}",
"scope = aml_scope(\"\\\\_SB\");",
"dev = aml_device(\"PC%.02X\", bus_num);",
"aml_append(dev, aml_name_decl(\"_UID\", aml_int(bus_num)));",
"aml_append(dev, aml_name_decl(\"_HID\", aml_eisaid(\"PNP0A03\")));",
"aml_append(dev, aml_name_decl(\"_BBN\", aml_int(bus_num)));",
"if (numa_node != NUMA_NODE_UNASSIGNED) {",
"aml_append(dev, aml_name_decl(\"_PXM\", aml_int(numa_node)));",
"}",
"aml_append(dev, build_prt(false));",
"crs = build_crs(PCI_HOST_BRIDGE(BUS(bus)->parent),\nio_ranges, mem_ranges);",
"aml_append(dev, aml_name_decl(\"_CRS\", crs));",
"aml_append(scope, dev);",
"aml_append(dsdt, scope);",
"}",
"}",
"scope = aml_scope(\"\\\\_SB.PCI0\");",
"crs = aml_resource_template();",
"aml_append(crs,\naml_word_bus_number(AML_MIN_FIXED, AML_MAX_FIXED, AML_POS_DECODE,\n0x0000, 0x0, VAR_7,\n0x0000, VAR_7 + 1));",
"aml_append(crs, aml_io(AML_DECODE16, 0x0CF8, 0x0CF8, 0x01, 0x08));",
"aml_append(crs,\naml_word_io(AML_MIN_FIXED, AML_MAX_FIXED,\nAML_POS_DECODE, AML_ENTIRE_RANGE,\n0x0000, 0x0000, 0x0CF7, 0x0000, 0x0CF8));",
"crs_replace_with_free_ranges(io_ranges, 0x0D00, 0xFFFF);",
"for (VAR_8 = 0; VAR_8 < io_ranges->len; VAR_8++) {",
"entry = g_ptr_array_index(io_ranges, VAR_8);",
"aml_append(crs,\naml_word_io(AML_MIN_FIXED, AML_MAX_FIXED,\nAML_POS_DECODE, AML_ENTIRE_RANGE,\n0x0000, entry->base, entry->limit,\n0x0000, entry->limit - entry->base + 1));",
"}",
"aml_append(crs,\naml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,\nAML_CACHEABLE, AML_READ_WRITE,\n0, 0x000A0000, 0x000BFFFF, 0, 0x00020000));",
"crs_replace_with_free_ranges(mem_ranges,\nVAR_4->begin, VAR_4->end - 1);",
"for (VAR_8 = 0; VAR_8 < mem_ranges->len; VAR_8++) {",
"entry = g_ptr_array_index(mem_ranges, VAR_8);",
"aml_append(crs,\naml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,\nAML_NON_CACHEABLE, AML_READ_WRITE,\n0, entry->base, entry->limit,\n0, entry->limit - entry->base + 1));",
"}",
"if (VAR_5->begin) {",
"aml_append(crs,\naml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,\nAML_CACHEABLE, AML_READ_WRITE,\n0, VAR_5->begin, VAR_5->end - 1, 0,\nVAR_5->end - VAR_5->begin));",
"}",
"if (VAR_3->tpm_version != TPM_VERSION_UNSPEC) {",
"aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,\nTPM_TIS_ADDR_SIZE, AML_READ_WRITE));",
"}",
"aml_append(scope, aml_name_decl(\"_CRS\", crs));",
"dev = aml_device(\"GPE0\");",
"aml_append(dev, aml_name_decl(\"_HID\", aml_string(\"PNP0A06\")));",
"aml_append(dev, aml_name_decl(\"_UID\", aml_string(\"GPE0 resources\")));",
"aml_append(dev, aml_name_decl(\"_STA\", aml_int(0xB)));",
"crs = aml_resource_template();",
"aml_append(crs,\naml_io(AML_DECODE16, VAR_2->gpe0_blk, VAR_2->gpe0_blk, 1, VAR_2->gpe0_blk_len)\n);",
"aml_append(dev, aml_name_decl(\"_CRS\", crs));",
"aml_append(scope, dev);",
"g_ptr_array_free(io_ranges, true);",
"g_ptr_array_free(mem_ranges, true);",
"if (VAR_2->pcihp_io_len) {",
"dev = aml_device(\"PHPR\");",
"aml_append(dev, aml_name_decl(\"_HID\", aml_string(\"PNP0A06\")));",
"aml_append(dev,\naml_name_decl(\"_UID\", aml_string(\"PCI Hotplug resources\")));",
"aml_append(dev, aml_name_decl(\"_STA\", aml_int(0xB)));",
"crs = aml_resource_template();",
"aml_append(crs,\naml_io(AML_DECODE16, VAR_2->pcihp_io_base, VAR_2->pcihp_io_base, 1,\nVAR_2->pcihp_io_len)\n);",
"aml_append(dev, aml_name_decl(\"_CRS\", crs));",
"aml_append(scope, dev);",
"}",
"aml_append(dsdt, scope);",
"scope = aml_scope(\"\\\\\");",
"if (!VAR_2->s3_disabled) {",
"pkg = aml_package(4);",
"aml_append(pkg, aml_int(1));",
"aml_append(pkg, aml_int(1));",
"aml_append(pkg, aml_int(0));",
"aml_append(pkg, aml_int(0));",
"aml_append(scope, aml_name_decl(\"_S3\", pkg));",
"}",
"if (!VAR_2->s4_disabled) {",
"pkg = aml_package(4);",
"aml_append(pkg, aml_int(VAR_2->s4_val));",
"aml_append(pkg, aml_int(VAR_2->s4_val));",
"aml_append(pkg, aml_int(0));",
"aml_append(pkg, aml_int(0));",
"aml_append(scope, aml_name_decl(\"_S4\", pkg));",
"}",
"pkg = aml_package(4);",
"aml_append(pkg, aml_int(0));",
"aml_append(pkg, aml_int(0));",
"aml_append(pkg, aml_int(0));",
"aml_append(pkg, aml_int(0));",
"aml_append(scope, aml_name_decl(\"_S5\", pkg));",
"aml_append(dsdt, scope);",
"{",
"uint8_t io_size = object_property_get_bool(OBJECT(pcms->fw_cfg),\n\"dma_enabled\", NULL) ?\nROUND_UP(FW_CFG_CTL_SIZE, 4) + sizeof(dma_addr_t) :\nFW_CFG_CTL_SIZE;",
"scope = aml_scope(\"\\\\_SB.PCI0\");",
"dev = aml_device(\"FWCF\");",
"aml_append(dev, aml_name_decl(\"_HID\", aml_string(\"QEMU0002\")));",
"aml_append(dev, aml_name_decl(\"_STA\", aml_int(0xB)));",
"crs = aml_resource_template();",
"aml_append(crs,\naml_io(AML_DECODE16, FW_CFG_IO_BASE, FW_CFG_IO_BASE, 0x01, io_size)\n);",
"aml_append(dev, aml_name_decl(\"_CRS\", crs));",
"aml_append(scope, dev);",
"aml_append(dsdt, scope);",
"}",
"if (VAR_3->applesmc_io_base) {",
"scope = aml_scope(\"\\\\_SB.PCI0.ISA\");",
"dev = aml_device(\"SMC\");",
"aml_append(dev, aml_name_decl(\"_HID\", aml_eisaid(\"APP0001\")));",
"aml_append(dev, aml_name_decl(\"_STA\", aml_int(0xB)));",
"crs = aml_resource_template();",
"aml_append(crs,\naml_io(AML_DECODE16, VAR_3->applesmc_io_base, VAR_3->applesmc_io_base,\n0x01, APPLESMC_MAX_DATA_LENGTH)\n);",
"aml_append(crs, aml_irq_no_flags(6));",
"aml_append(dev, aml_name_decl(\"_CRS\", crs));",
"aml_append(scope, dev);",
"aml_append(dsdt, scope);",
"}",
"if (VAR_3->pvpanic_port) {",
"scope = aml_scope(\"\\\\_SB.PCI0.ISA\");",
"dev = aml_device(\"PEVT\");",
"aml_append(dev, aml_name_decl(\"_HID\", aml_string(\"QEMU0001\")));",
"crs = aml_resource_template();",
"aml_append(crs,\naml_io(AML_DECODE16, VAR_3->pvpanic_port, VAR_3->pvpanic_port, 1, 1)\n);",
"aml_append(dev, aml_name_decl(\"_CRS\", crs));",
"aml_append(dev, aml_operation_region(\"PEOR\", AML_SYSTEM_IO,\naml_int(VAR_3->pvpanic_port), 1));",
"field = aml_field(\"PEOR\", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);",
"aml_append(field, aml_named_field(\"PEPT\", 8));",
"aml_append(dev, field);",
"aml_append(dev, aml_name_decl(\"_STA\", aml_int(0xF)));",
"method = aml_method(\"RDPT\", 0, AML_NOTSERIALIZED);",
"aml_append(method, aml_store(aml_name(\"PEPT\"), aml_local(0)));",
"aml_append(method, aml_return(aml_local(0)));",
"aml_append(dev, method);",
"method = aml_method(\"WRPT\", 1, AML_NOTSERIALIZED);",
"aml_append(method, aml_store(aml_arg(0), aml_name(\"PEPT\")));",
"aml_append(dev, method);",
"aml_append(scope, dev);",
"aml_append(dsdt, scope);",
"}",
"sb_scope = aml_scope(\"\\\\_SB\");",
"{",
"build_memory_devices(sb_scope, nr_mem, VAR_2->mem_hp_io_base,\nVAR_2->mem_hp_io_len);",
"{",
"Object *pci_host;",
"PCIBus *bus = NULL;",
"pci_host = acpi_get_i386_pci_host();",
"if (pci_host) {",
"bus = PCI_HOST_BRIDGE(pci_host)->bus;",
"}",
"if (bus) {",
"Aml *scope = aml_scope(\"PCI0\");",
"build_append_pci_bus_devices(scope, bus, VAR_2->pcihp_bridge_en);",
"if (VAR_3->tpm_version != TPM_VERSION_UNSPEC) {",
"dev = aml_device(\"ISA.TPM\");",
"aml_append(dev, aml_name_decl(\"_HID\", aml_eisaid(\"PNP0C31\")));",
"aml_append(dev, aml_name_decl(\"_STA\", aml_int(0xF)));",
"crs = aml_resource_template();",
"aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,\nTPM_TIS_ADDR_SIZE, AML_READ_WRITE));",
"aml_append(dev, aml_name_decl(\"_CRS\", crs));",
"aml_append(scope, dev);",
"}",
"aml_append(sb_scope, scope);",
"}",
"}",
"aml_append(dsdt, sb_scope);",
"}",
"g_array_append_vals(VAR_0, dsdt->buf->data, dsdt->buf->len);",
"build_header(VAR_1, VAR_0,\n(void *)(VAR_0->data + VAR_0->len - dsdt->buf->len),\n\"DSDT\", dsdt->buf->len, 1, NULL, NULL);",
"free_aml_allocator();",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
81,
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139,
141
],
[
143,
145
],
[
147
],
[
149,
151
],
[
155
],
[
157
],
[
159
],
[
163
],
[
165
],
[
167,
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
207
],
[
209
],
[
211
],
[
215
],
[
217
],
[
219
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
235
],
[
237
],
[
239
],
[
243
],
[
245,
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
261
],
[
265
],
[
267,
269,
271,
273
],
[
275
],
[
279,
281,
283,
285
],
[
289
],
[
291
],
[
293
],
[
295,
297,
299,
301,
303
],
[
305
],
[
309,
311,
313,
315
],
[
319,
321
],
[
323
],
[
325
],
[
327,
329,
331,
333,
335
],
[
337
],
[
341
],
[
343,
345,
347,
349,
351
],
[
353
],
[
357
],
[
359,
361
],
[
363
],
[
365
],
[
371
],
[
373
],
[
375
],
[
379
],
[
381
],
[
383,
385,
387
],
[
389
],
[
391
],
[
395
],
[
397
],
[
403
],
[
405
],
[
407
],
[
409,
411
],
[
415
],
[
417
],
[
419,
421,
423,
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
449
],
[
451
],
[
453
],
[
455
],
[
459
],
[
461
],
[
463
],
[
467
],
[
469
],
[
471
],
[
473
],
[
475
],
[
479
],
[
481
],
[
483
],
[
485
],
[
487
],
[
489
],
[
491
],
[
497
],
[
507,
509,
511,
513
],
[
517
],
[
519
],
[
523
],
[
529
],
[
533
],
[
535,
537,
539
],
[
541
],
[
545
],
[
547
],
[
549
],
[
553
],
[
555
],
[
557
],
[
561
],
[
565
],
[
569
],
[
571,
573,
575,
577
],
[
579
],
[
581
],
[
585
],
[
587
],
[
589
],
[
593
],
[
595
],
[
599
],
[
601
],
[
605
],
[
607,
609,
611
],
[
613
],
[
617,
619
],
[
621
],
[
623
],
[
625
],
[
631
],
[
635
],
[
637
],
[
639
],
[
641
],
[
645
],
[
647
],
[
649
],
[
653
],
[
655
],
[
657
],
[
661
],
[
663
],
[
665,
667
],
[
671
],
[
673
],
[
675
],
[
679
],
[
681
],
[
683
],
[
685
],
[
689
],
[
691
],
[
695
],
[
699
],
[
701
],
[
703
],
[
705
],
[
707
],
[
709,
711
],
[
725
],
[
727
],
[
729
],
[
733
],
[
735
],
[
737
],
[
739
],
[
741
],
[
747
],
[
749,
751,
753
],
[
755
],
[
757
]
] |
3,258 | static void ics_kvm_realize(DeviceState *dev, Error **errp)
{
ICSState *ics = ICS_SIMPLE(dev);
if (!ics->nr_irqs) {
error_setg(errp, "Number of interrupts needs to be greater 0");
return;
}
ics->irqs = g_malloc0(ics->nr_irqs * sizeof(ICSIRQState));
ics->qirqs = qemu_allocate_irqs(ics_kvm_set_irq, ics, ics->nr_irqs);
qemu_register_reset(ics_kvm_reset, dev);
}
| false | qemu | 100f738850639a108d6767316ce4dcc1d1ea4ae4 | static void ics_kvm_realize(DeviceState *dev, Error **errp)
{
ICSState *ics = ICS_SIMPLE(dev);
if (!ics->nr_irqs) {
error_setg(errp, "Number of interrupts needs to be greater 0");
return;
}
ics->irqs = g_malloc0(ics->nr_irqs * sizeof(ICSIRQState));
ics->qirqs = qemu_allocate_irqs(ics_kvm_set_irq, ics, ics->nr_irqs);
qemu_register_reset(ics_kvm_reset, dev);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
ICSState *ics = ICS_SIMPLE(VAR_0);
if (!ics->nr_irqs) {
error_setg(VAR_1, "Number of interrupts needs to be greater 0");
return;
}
ics->irqs = g_malloc0(ics->nr_irqs * sizeof(ICSIRQState));
ics->qirqs = qemu_allocate_irqs(ics_kvm_set_irq, ics, ics->nr_irqs);
qemu_register_reset(ics_kvm_reset, VAR_0);
}
| [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"ICSState *ics = ICS_SIMPLE(VAR_0);",
"if (!ics->nr_irqs) {",
"error_setg(VAR_1, \"Number of interrupts needs to be greater 0\");",
"return;",
"}",
"ics->irqs = g_malloc0(ics->nr_irqs * sizeof(ICSIRQState));",
"ics->qirqs = qemu_allocate_irqs(ics_kvm_set_irq, ics, ics->nr_irqs);",
"qemu_register_reset(ics_kvm_reset, VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
]
] |
3,259 | ram_addr_t memory_region_get_ram_addr(MemoryRegion *mr)
{
assert(mr->backend_registered);
return mr->ram_addr;
}
| false | qemu | 26a83ad0e793465b74a8b06a65f2f6fdc5615413 | ram_addr_t memory_region_get_ram_addr(MemoryRegion *mr)
{
assert(mr->backend_registered);
return mr->ram_addr;
}
| {
"code": [],
"line_no": []
} | ram_addr_t FUNC_0(MemoryRegion *mr)
{
assert(mr->backend_registered);
return mr->ram_addr;
}
| [
"ram_addr_t FUNC_0(MemoryRegion *mr)\n{",
"assert(mr->backend_registered);",
"return mr->ram_addr;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
3,260 | static void tpm_passthrough_cancel_cmd(TPMBackend *tb)
{
/* cancelling an ongoing command is known not to work with some TPMs */
}
| false | qemu | 92dcc234ec1f266fb5d59bed77d66320c2c75965 | static void tpm_passthrough_cancel_cmd(TPMBackend *tb)
{
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TPMBackend *VAR_0)
{
}
| [
"static void FUNC_0(TPMBackend *VAR_0)\n{",
"}"
] | [
0,
0
] | [
[
1,
3
],
[
7
]
] |
3,261 | void hmp_info_spice(Monitor *mon, const QDict *qdict)
{
SpiceChannelList *chan;
SpiceInfo *info;
const char *channel_name;
const char * const channel_names[] = {
[SPICE_CHANNEL_MAIN] = "main",
[SPICE_CHANNEL_DISPLAY] = "display",
[SPICE_CHANNEL_INPUTS] = "inputs",
[SPICE_CHANNEL_CURSOR] = "cursor",
[SPICE_CHANNEL_PLAYBACK] = "playback",
[SPICE_CHANNEL_RECORD] = "record",
[SPICE_CHANNEL_TUNNEL] = "tunnel",
[SPICE_CHANNEL_SMARTCARD] = "smartcard",
[SPICE_CHANNEL_USBREDIR] = "usbredir",
[SPICE_CHANNEL_PORT] = "port",
#if 0
/* minimum spice-protocol is 0.12.3, webdav was added in 0.12.7,
* no easy way to #ifdef (SPICE_CHANNEL_* is a enum). Disable
* as quick fix for build failures with older versions. */
[SPICE_CHANNEL_WEBDAV] = "webdav",
#endif
};
info = qmp_query_spice(NULL);
if (!info->enabled) {
monitor_printf(mon, "Server: disabled\n");
goto out;
}
monitor_printf(mon, "Server:\n");
if (info->has_port) {
monitor_printf(mon, " address: %s:%" PRId64 "\n",
info->host, info->port);
}
if (info->has_tls_port) {
monitor_printf(mon, " address: %s:%" PRId64 " [tls]\n",
info->host, info->tls_port);
}
monitor_printf(mon, " migrated: %s\n",
info->migrated ? "true" : "false");
monitor_printf(mon, " auth: %s\n", info->auth);
monitor_printf(mon, " compiled: %s\n", info->compiled_version);
monitor_printf(mon, " mouse-mode: %s\n",
SpiceQueryMouseMode_lookup[info->mouse_mode]);
if (!info->has_channels || info->channels == NULL) {
monitor_printf(mon, "Channels: none\n");
} else {
for (chan = info->channels; chan; chan = chan->next) {
monitor_printf(mon, "Channel:\n");
monitor_printf(mon, " address: %s:%s%s\n",
chan->value->base->host, chan->value->base->port,
chan->value->tls ? " [tls]" : "");
monitor_printf(mon, " session: %" PRId64 "\n",
chan->value->connection_id);
monitor_printf(mon, " channel: %" PRId64 ":%" PRId64 "\n",
chan->value->channel_type, chan->value->channel_id);
channel_name = "unknown";
if (chan->value->channel_type > 0 &&
chan->value->channel_type < ARRAY_SIZE(channel_names) &&
channel_names[chan->value->channel_type]) {
channel_name = channel_names[chan->value->channel_type];
}
monitor_printf(mon, " channel name: %s\n", channel_name);
}
}
out:
qapi_free_SpiceInfo(info);
}
| false | qemu | ddf21908961073199f3d186204da4810f2ea150b | void hmp_info_spice(Monitor *mon, const QDict *qdict)
{
SpiceChannelList *chan;
SpiceInfo *info;
const char *channel_name;
const char * const channel_names[] = {
[SPICE_CHANNEL_MAIN] = "main",
[SPICE_CHANNEL_DISPLAY] = "display",
[SPICE_CHANNEL_INPUTS] = "inputs",
[SPICE_CHANNEL_CURSOR] = "cursor",
[SPICE_CHANNEL_PLAYBACK] = "playback",
[SPICE_CHANNEL_RECORD] = "record",
[SPICE_CHANNEL_TUNNEL] = "tunnel",
[SPICE_CHANNEL_SMARTCARD] = "smartcard",
[SPICE_CHANNEL_USBREDIR] = "usbredir",
[SPICE_CHANNEL_PORT] = "port",
#if 0
[SPICE_CHANNEL_WEBDAV] = "webdav",
#endif
};
info = qmp_query_spice(NULL);
if (!info->enabled) {
monitor_printf(mon, "Server: disabled\n");
goto out;
}
monitor_printf(mon, "Server:\n");
if (info->has_port) {
monitor_printf(mon, " address: %s:%" PRId64 "\n",
info->host, info->port);
}
if (info->has_tls_port) {
monitor_printf(mon, " address: %s:%" PRId64 " [tls]\n",
info->host, info->tls_port);
}
monitor_printf(mon, " migrated: %s\n",
info->migrated ? "true" : "false");
monitor_printf(mon, " auth: %s\n", info->auth);
monitor_printf(mon, " compiled: %s\n", info->compiled_version);
monitor_printf(mon, " mouse-mode: %s\n",
SpiceQueryMouseMode_lookup[info->mouse_mode]);
if (!info->has_channels || info->channels == NULL) {
monitor_printf(mon, "Channels: none\n");
} else {
for (chan = info->channels; chan; chan = chan->next) {
monitor_printf(mon, "Channel:\n");
monitor_printf(mon, " address: %s:%s%s\n",
chan->value->base->host, chan->value->base->port,
chan->value->tls ? " [tls]" : "");
monitor_printf(mon, " session: %" PRId64 "\n",
chan->value->connection_id);
monitor_printf(mon, " channel: %" PRId64 ":%" PRId64 "\n",
chan->value->channel_type, chan->value->channel_id);
channel_name = "unknown";
if (chan->value->channel_type > 0 &&
chan->value->channel_type < ARRAY_SIZE(channel_names) &&
channel_names[chan->value->channel_type]) {
channel_name = channel_names[chan->value->channel_type];
}
monitor_printf(mon, " channel name: %s\n", channel_name);
}
}
out:
qapi_free_SpiceInfo(info);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)
{
SpiceChannelList *chan;
SpiceInfo *info;
const char *VAR_2;
const char * const VAR_3[] = {
[SPICE_CHANNEL_MAIN] = "main",
[SPICE_CHANNEL_DISPLAY] = "display",
[SPICE_CHANNEL_INPUTS] = "inputs",
[SPICE_CHANNEL_CURSOR] = "cursor",
[SPICE_CHANNEL_PLAYBACK] = "playback",
[SPICE_CHANNEL_RECORD] = "record",
[SPICE_CHANNEL_TUNNEL] = "tunnel",
[SPICE_CHANNEL_SMARTCARD] = "smartcard",
[SPICE_CHANNEL_USBREDIR] = "usbredir",
[SPICE_CHANNEL_PORT] = "port",
#if 0
[SPICE_CHANNEL_WEBDAV] = "webdav",
#endif
};
info = qmp_query_spice(NULL);
if (!info->enabled) {
monitor_printf(VAR_0, "Server: disabled\n");
goto out;
}
monitor_printf(VAR_0, "Server:\n");
if (info->has_port) {
monitor_printf(VAR_0, " address: %s:%" PRId64 "\n",
info->host, info->port);
}
if (info->has_tls_port) {
monitor_printf(VAR_0, " address: %s:%" PRId64 " [tls]\n",
info->host, info->tls_port);
}
monitor_printf(VAR_0, " migrated: %s\n",
info->migrated ? "true" : "false");
monitor_printf(VAR_0, " auth: %s\n", info->auth);
monitor_printf(VAR_0, " compiled: %s\n", info->compiled_version);
monitor_printf(VAR_0, " mouse-mode: %s\n",
SpiceQueryMouseMode_lookup[info->mouse_mode]);
if (!info->has_channels || info->channels == NULL) {
monitor_printf(VAR_0, "Channels: none\n");
} else {
for (chan = info->channels; chan; chan = chan->next) {
monitor_printf(VAR_0, "Channel:\n");
monitor_printf(VAR_0, " address: %s:%s%s\n",
chan->value->base->host, chan->value->base->port,
chan->value->tls ? " [tls]" : "");
monitor_printf(VAR_0, " session: %" PRId64 "\n",
chan->value->connection_id);
monitor_printf(VAR_0, " channel: %" PRId64 ":%" PRId64 "\n",
chan->value->channel_type, chan->value->channel_id);
VAR_2 = "unknown";
if (chan->value->channel_type > 0 &&
chan->value->channel_type < ARRAY_SIZE(VAR_3) &&
VAR_3[chan->value->channel_type]) {
VAR_2 = VAR_3[chan->value->channel_type];
}
monitor_printf(VAR_0, " channel name: %s\n", VAR_2);
}
}
out:
qapi_free_SpiceInfo(info);
}
| [
"void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)\n{",
"SpiceChannelList *chan;",
"SpiceInfo *info;",
"const char *VAR_2;",
"const char * const VAR_3[] = {",
"[SPICE_CHANNEL_MAIN] = \"main\",\n[SPICE_CHANNEL_DISPLAY] = \"display\",\n[SPICE_CHANNEL_INPUTS] = \"inputs\",\n[SPICE_CHANNEL_CURSOR] = \"cursor\",\n[SPICE_CHANNEL_PLAYBACK] = \"playback\",\n[SPICE_CHANNEL_RECORD] = \"record\",\n[SPICE_CHANNEL_TUNNEL] = \"tunnel\",\n[SPICE_CHANNEL_SMARTCARD] = \"smartcard\",\n[SPICE_CHANNEL_USBREDIR] = \"usbredir\",\n[SPICE_CHANNEL_PORT] = \"port\",\n#if 0\n[SPICE_CHANNEL_WEBDAV] = \"webdav\",\n#endif\n};",
"info = qmp_query_spice(NULL);",
"if (!info->enabled) {",
"monitor_printf(VAR_0, \"Server: disabled\\n\");",
"goto out;",
"}",
"monitor_printf(VAR_0, \"Server:\\n\");",
"if (info->has_port) {",
"monitor_printf(VAR_0, \" address: %s:%\" PRId64 \"\\n\",\ninfo->host, info->port);",
"}",
"if (info->has_tls_port) {",
"monitor_printf(VAR_0, \" address: %s:%\" PRId64 \" [tls]\\n\",\ninfo->host, info->tls_port);",
"}",
"monitor_printf(VAR_0, \" migrated: %s\\n\",\ninfo->migrated ? \"true\" : \"false\");",
"monitor_printf(VAR_0, \" auth: %s\\n\", info->auth);",
"monitor_printf(VAR_0, \" compiled: %s\\n\", info->compiled_version);",
"monitor_printf(VAR_0, \" mouse-mode: %s\\n\",\nSpiceQueryMouseMode_lookup[info->mouse_mode]);",
"if (!info->has_channels || info->channels == NULL) {",
"monitor_printf(VAR_0, \"Channels: none\\n\");",
"} else {",
"for (chan = info->channels; chan; chan = chan->next) {",
"monitor_printf(VAR_0, \"Channel:\\n\");",
"monitor_printf(VAR_0, \" address: %s:%s%s\\n\",\nchan->value->base->host, chan->value->base->port,\nchan->value->tls ? \" [tls]\" : \"\");",
"monitor_printf(VAR_0, \" session: %\" PRId64 \"\\n\",\nchan->value->connection_id);",
"monitor_printf(VAR_0, \" channel: %\" PRId64 \":%\" PRId64 \"\\n\",\nchan->value->channel_type, chan->value->channel_id);",
"VAR_2 = \"unknown\";",
"if (chan->value->channel_type > 0 &&\nchan->value->channel_type < ARRAY_SIZE(VAR_3) &&\nVAR_3[chan->value->channel_type]) {",
"VAR_2 = VAR_3[chan->value->channel_type];",
"}",
"monitor_printf(VAR_0, \" channel name: %s\\n\", VAR_2);",
"}",
"}",
"out:\nqapi_free_SpiceInfo(info);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
41,
43,
45
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81,
83
],
[
85
],
[
87
],
[
89,
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105,
107,
109
],
[
111,
113
],
[
115,
117
],
[
121
],
[
123,
125,
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
143,
145
],
[
147
]
] |
3,262 | START_TEST(qdict_get_try_int_test)
{
int ret;
const int value = 100;
const char *key = "int";
qdict_put(tests_dict, key, qint_from_int(value));
ret = qdict_get_try_int(tests_dict, key, 0);
fail_unless(ret == value);
}
| false | qemu | ac531cb6e542b1e61d668604adf9dc5306a948c0 | START_TEST(qdict_get_try_int_test)
{
int ret;
const int value = 100;
const char *key = "int";
qdict_put(tests_dict, key, qint_from_int(value));
ret = qdict_get_try_int(tests_dict, key, 0);
fail_unless(ret == value);
}
| {
"code": [],
"line_no": []
} | FUNC_0(VAR_0)
{
int VAR_1;
const int VAR_2 = 100;
const char *VAR_3 = "int";
qdict_put(tests_dict, VAR_3, qint_from_int(VAR_2));
VAR_1 = qdict_get_try_int(tests_dict, VAR_3, 0);
fail_unless(VAR_1 == VAR_2);
}
| [
"FUNC_0(VAR_0)\n{",
"int VAR_1;",
"const int VAR_2 = 100;",
"const char *VAR_3 = \"int\";",
"qdict_put(tests_dict, VAR_3, qint_from_int(VAR_2));",
"VAR_1 = qdict_get_try_int(tests_dict, VAR_3, 0);",
"fail_unless(VAR_1 == VAR_2);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
]
] |
3,263 | static int get_cv_transfer_function(AVCodecContext *avctx,
CFStringRef *transfer_fnc,
CFNumberRef *gamma_level)
{
enum AVColorTransferCharacteristic trc = avctx->color_trc;
Float32 gamma;
*gamma_level = NULL;
switch (trc) {
case AVCOL_TRC_UNSPECIFIED:
*transfer_fnc = NULL;
break;
case AVCOL_TRC_BT709:
*transfer_fnc = kCVImageBufferTransferFunction_ITU_R_709_2;
break;
case AVCOL_TRC_SMPTE240M:
*transfer_fnc = kCVImageBufferTransferFunction_SMPTE_240M_1995;
break;
case AVCOL_TRC_GAMMA22:
gamma = 2.2;
*transfer_fnc = kCVImageBufferTransferFunction_UseGamma;
*gamma_level = CFNumberCreate(NULL, kCFNumberFloat32Type, &gamma);
break;
case AVCOL_TRC_GAMMA28:
gamma = 2.8;
*transfer_fnc = kCVImageBufferTransferFunction_UseGamma;
*gamma_level = CFNumberCreate(NULL, kCFNumberFloat32Type, &gamma);
break;
case AVCOL_TRC_BT2020_10:
case AVCOL_TRC_BT2020_12:
*transfer_fnc = kCVImageBufferTransferFunction_ITU_R_2020;
break;
default:
av_log(avctx, AV_LOG_ERROR, "Transfer function %s is not supported.\n", av_color_transfer_name(trc));
return -1;
}
return 0;
}
| false | FFmpeg | dcd3418a35aab7ef283b68ed9997ce4ac204094e | static int get_cv_transfer_function(AVCodecContext *avctx,
CFStringRef *transfer_fnc,
CFNumberRef *gamma_level)
{
enum AVColorTransferCharacteristic trc = avctx->color_trc;
Float32 gamma;
*gamma_level = NULL;
switch (trc) {
case AVCOL_TRC_UNSPECIFIED:
*transfer_fnc = NULL;
break;
case AVCOL_TRC_BT709:
*transfer_fnc = kCVImageBufferTransferFunction_ITU_R_709_2;
break;
case AVCOL_TRC_SMPTE240M:
*transfer_fnc = kCVImageBufferTransferFunction_SMPTE_240M_1995;
break;
case AVCOL_TRC_GAMMA22:
gamma = 2.2;
*transfer_fnc = kCVImageBufferTransferFunction_UseGamma;
*gamma_level = CFNumberCreate(NULL, kCFNumberFloat32Type, &gamma);
break;
case AVCOL_TRC_GAMMA28:
gamma = 2.8;
*transfer_fnc = kCVImageBufferTransferFunction_UseGamma;
*gamma_level = CFNumberCreate(NULL, kCFNumberFloat32Type, &gamma);
break;
case AVCOL_TRC_BT2020_10:
case AVCOL_TRC_BT2020_12:
*transfer_fnc = kCVImageBufferTransferFunction_ITU_R_2020;
break;
default:
av_log(avctx, AV_LOG_ERROR, "Transfer function %s is not supported.\n", av_color_transfer_name(trc));
return -1;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
CFStringRef *VAR_1,
CFNumberRef *VAR_2)
{
enum AVColorTransferCharacteristic VAR_3 = VAR_0->color_trc;
Float32 gamma;
*VAR_2 = NULL;
switch (VAR_3) {
case AVCOL_TRC_UNSPECIFIED:
*VAR_1 = NULL;
break;
case AVCOL_TRC_BT709:
*VAR_1 = kCVImageBufferTransferFunction_ITU_R_709_2;
break;
case AVCOL_TRC_SMPTE240M:
*VAR_1 = kCVImageBufferTransferFunction_SMPTE_240M_1995;
break;
case AVCOL_TRC_GAMMA22:
gamma = 2.2;
*VAR_1 = kCVImageBufferTransferFunction_UseGamma;
*VAR_2 = CFNumberCreate(NULL, kCFNumberFloat32Type, &gamma);
break;
case AVCOL_TRC_GAMMA28:
gamma = 2.8;
*VAR_1 = kCVImageBufferTransferFunction_UseGamma;
*VAR_2 = CFNumberCreate(NULL, kCFNumberFloat32Type, &gamma);
break;
case AVCOL_TRC_BT2020_10:
case AVCOL_TRC_BT2020_12:
*VAR_1 = kCVImageBufferTransferFunction_ITU_R_2020;
break;
default:
av_log(VAR_0, AV_LOG_ERROR, "Transfer function %s is not supported.\n", av_color_transfer_name(VAR_3));
return -1;
}
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nCFStringRef *VAR_1,\nCFNumberRef *VAR_2)\n{",
"enum AVColorTransferCharacteristic VAR_3 = VAR_0->color_trc;",
"Float32 gamma;",
"*VAR_2 = NULL;",
"switch (VAR_3) {",
"case AVCOL_TRC_UNSPECIFIED:\n*VAR_1 = NULL;",
"break;",
"case AVCOL_TRC_BT709:\n*VAR_1 = kCVImageBufferTransferFunction_ITU_R_709_2;",
"break;",
"case AVCOL_TRC_SMPTE240M:\n*VAR_1 = kCVImageBufferTransferFunction_SMPTE_240M_1995;",
"break;",
"case AVCOL_TRC_GAMMA22:\ngamma = 2.2;",
"*VAR_1 = kCVImageBufferTransferFunction_UseGamma;",
"*VAR_2 = CFNumberCreate(NULL, kCFNumberFloat32Type, &gamma);",
"break;",
"case AVCOL_TRC_GAMMA28:\ngamma = 2.8;",
"*VAR_1 = kCVImageBufferTransferFunction_UseGamma;",
"*VAR_2 = CFNumberCreate(NULL, kCFNumberFloat32Type, &gamma);",
"break;",
"case AVCOL_TRC_BT2020_10:\ncase AVCOL_TRC_BT2020_12:\n*VAR_1 = kCVImageBufferTransferFunction_ITU_R_2020;",
"break;",
"default:\nav_log(VAR_0, AV_LOG_ERROR, \"Transfer function %s is not supported.\\n\", av_color_transfer_name(VAR_3));",
"return -1;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19,
21
],
[
23
],
[
27,
29
],
[
31
],
[
35,
37
],
[
39
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
67,
69,
71
],
[
73
],
[
77,
79
],
[
81
],
[
83
],
[
87
],
[
89
]
] |
3,264 | void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd,
int64_t bps_wr,
int64_t iops,
int64_t iops_rd,
int64_t iops_wr,
bool has_bps_max,
int64_t bps_max,
bool has_bps_rd_max,
int64_t bps_rd_max,
bool has_bps_wr_max,
int64_t bps_wr_max,
bool has_iops_max,
int64_t iops_max,
bool has_iops_rd_max,
int64_t iops_rd_max,
bool has_iops_wr_max,
int64_t iops_wr_max,
bool has_iops_size,
int64_t iops_size,
bool has_group,
const char *group, Error **errp)
{
ThrottleConfig cfg;
BlockDriverState *bs;
BlockBackend *blk;
AioContext *aio_context;
blk = blk_by_name(device);
if (!blk) {
error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", device);
return;
}
aio_context = blk_get_aio_context(blk);
aio_context_acquire(aio_context);
bs = blk_bs(blk);
if (!bs) {
error_setg(errp, "Device '%s' has no medium", device);
goto out;
}
memset(&cfg, 0, sizeof(cfg));
cfg.buckets[THROTTLE_BPS_TOTAL].avg = bps;
cfg.buckets[THROTTLE_BPS_READ].avg = bps_rd;
cfg.buckets[THROTTLE_BPS_WRITE].avg = bps_wr;
cfg.buckets[THROTTLE_OPS_TOTAL].avg = iops;
cfg.buckets[THROTTLE_OPS_READ].avg = iops_rd;
cfg.buckets[THROTTLE_OPS_WRITE].avg = iops_wr;
if (has_bps_max) {
cfg.buckets[THROTTLE_BPS_TOTAL].max = bps_max;
}
if (has_bps_rd_max) {
cfg.buckets[THROTTLE_BPS_READ].max = bps_rd_max;
}
if (has_bps_wr_max) {
cfg.buckets[THROTTLE_BPS_WRITE].max = bps_wr_max;
}
if (has_iops_max) {
cfg.buckets[THROTTLE_OPS_TOTAL].max = iops_max;
}
if (has_iops_rd_max) {
cfg.buckets[THROTTLE_OPS_READ].max = iops_rd_max;
}
if (has_iops_wr_max) {
cfg.buckets[THROTTLE_OPS_WRITE].max = iops_wr_max;
}
if (has_iops_size) {
cfg.op_size = iops_size;
}
if (!check_throttle_config(&cfg, errp)) {
goto out;
}
if (throttle_enabled(&cfg)) {
/* Enable I/O limits if they're not enabled yet, otherwise
* just update the throttling group. */
if (!bs->io_limits_enabled) {
bdrv_io_limits_enable(bs, has_group ? group : device);
} else if (has_group) {
bdrv_io_limits_update_group(bs, group);
}
/* Set the new throttling configuration */
bdrv_set_io_limits(bs, &cfg);
} else if (bs->io_limits_enabled) {
/* If all throttling settings are set to 0, disable I/O limits */
bdrv_io_limits_disable(bs);
}
out:
aio_context_release(aio_context);
}
| false | qemu | a0d64a61db602696f4f1895a890c65eda5b3b618 | void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd,
int64_t bps_wr,
int64_t iops,
int64_t iops_rd,
int64_t iops_wr,
bool has_bps_max,
int64_t bps_max,
bool has_bps_rd_max,
int64_t bps_rd_max,
bool has_bps_wr_max,
int64_t bps_wr_max,
bool has_iops_max,
int64_t iops_max,
bool has_iops_rd_max,
int64_t iops_rd_max,
bool has_iops_wr_max,
int64_t iops_wr_max,
bool has_iops_size,
int64_t iops_size,
bool has_group,
const char *group, Error **errp)
{
ThrottleConfig cfg;
BlockDriverState *bs;
BlockBackend *blk;
AioContext *aio_context;
blk = blk_by_name(device);
if (!blk) {
error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", device);
return;
}
aio_context = blk_get_aio_context(blk);
aio_context_acquire(aio_context);
bs = blk_bs(blk);
if (!bs) {
error_setg(errp, "Device '%s' has no medium", device);
goto out;
}
memset(&cfg, 0, sizeof(cfg));
cfg.buckets[THROTTLE_BPS_TOTAL].avg = bps;
cfg.buckets[THROTTLE_BPS_READ].avg = bps_rd;
cfg.buckets[THROTTLE_BPS_WRITE].avg = bps_wr;
cfg.buckets[THROTTLE_OPS_TOTAL].avg = iops;
cfg.buckets[THROTTLE_OPS_READ].avg = iops_rd;
cfg.buckets[THROTTLE_OPS_WRITE].avg = iops_wr;
if (has_bps_max) {
cfg.buckets[THROTTLE_BPS_TOTAL].max = bps_max;
}
if (has_bps_rd_max) {
cfg.buckets[THROTTLE_BPS_READ].max = bps_rd_max;
}
if (has_bps_wr_max) {
cfg.buckets[THROTTLE_BPS_WRITE].max = bps_wr_max;
}
if (has_iops_max) {
cfg.buckets[THROTTLE_OPS_TOTAL].max = iops_max;
}
if (has_iops_rd_max) {
cfg.buckets[THROTTLE_OPS_READ].max = iops_rd_max;
}
if (has_iops_wr_max) {
cfg.buckets[THROTTLE_OPS_WRITE].max = iops_wr_max;
}
if (has_iops_size) {
cfg.op_size = iops_size;
}
if (!check_throttle_config(&cfg, errp)) {
goto out;
}
if (throttle_enabled(&cfg)) {
if (!bs->io_limits_enabled) {
bdrv_io_limits_enable(bs, has_group ? group : device);
} else if (has_group) {
bdrv_io_limits_update_group(bs, group);
}
bdrv_set_io_limits(bs, &cfg);
} else if (bs->io_limits_enabled) {
bdrv_io_limits_disable(bs);
}
out:
aio_context_release(aio_context);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(const char *VAR_0, int64_t VAR_1, int64_t VAR_2,
int64_t VAR_3,
int64_t VAR_4,
int64_t VAR_5,
int64_t VAR_6,
bool VAR_7,
int64_t VAR_8,
bool VAR_9,
int64_t VAR_10,
bool VAR_11,
int64_t VAR_12,
bool VAR_13,
int64_t VAR_14,
bool VAR_15,
int64_t VAR_16,
bool VAR_17,
int64_t VAR_18,
bool VAR_19,
int64_t VAR_20,
bool VAR_21,
const char *VAR_22, Error **VAR_23)
{
ThrottleConfig cfg;
BlockDriverState *bs;
BlockBackend *blk;
AioContext *aio_context;
blk = blk_by_name(VAR_0);
if (!blk) {
error_set(VAR_23, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", VAR_0);
return;
}
aio_context = blk_get_aio_context(blk);
aio_context_acquire(aio_context);
bs = blk_bs(blk);
if (!bs) {
error_setg(VAR_23, "Device '%s' has no medium", VAR_0);
goto out;
}
memset(&cfg, 0, sizeof(cfg));
cfg.buckets[THROTTLE_BPS_TOTAL].avg = VAR_1;
cfg.buckets[THROTTLE_BPS_READ].avg = VAR_2;
cfg.buckets[THROTTLE_BPS_WRITE].avg = VAR_3;
cfg.buckets[THROTTLE_OPS_TOTAL].avg = VAR_4;
cfg.buckets[THROTTLE_OPS_READ].avg = VAR_5;
cfg.buckets[THROTTLE_OPS_WRITE].avg = VAR_6;
if (VAR_7) {
cfg.buckets[THROTTLE_BPS_TOTAL].max = VAR_8;
}
if (VAR_9) {
cfg.buckets[THROTTLE_BPS_READ].max = VAR_10;
}
if (VAR_11) {
cfg.buckets[THROTTLE_BPS_WRITE].max = VAR_12;
}
if (VAR_13) {
cfg.buckets[THROTTLE_OPS_TOTAL].max = VAR_14;
}
if (VAR_15) {
cfg.buckets[THROTTLE_OPS_READ].max = VAR_16;
}
if (VAR_17) {
cfg.buckets[THROTTLE_OPS_WRITE].max = VAR_18;
}
if (VAR_19) {
cfg.op_size = VAR_20;
}
if (!check_throttle_config(&cfg, VAR_23)) {
goto out;
}
if (throttle_enabled(&cfg)) {
if (!bs->io_limits_enabled) {
bdrv_io_limits_enable(bs, VAR_21 ? VAR_22 : VAR_0);
} else if (VAR_21) {
bdrv_io_limits_update_group(bs, VAR_22);
}
bdrv_set_io_limits(bs, &cfg);
} else if (bs->io_limits_enabled) {
bdrv_io_limits_disable(bs);
}
out:
aio_context_release(aio_context);
}
| [
"void FUNC_0(const char *VAR_0, int64_t VAR_1, int64_t VAR_2,\nint64_t VAR_3,\nint64_t VAR_4,\nint64_t VAR_5,\nint64_t VAR_6,\nbool VAR_7,\nint64_t VAR_8,\nbool VAR_9,\nint64_t VAR_10,\nbool VAR_11,\nint64_t VAR_12,\nbool VAR_13,\nint64_t VAR_14,\nbool VAR_15,\nint64_t VAR_16,\nbool VAR_17,\nint64_t VAR_18,\nbool VAR_19,\nint64_t VAR_20,\nbool VAR_21,\nconst char *VAR_22, Error **VAR_23)\n{",
"ThrottleConfig cfg;",
"BlockDriverState *bs;",
"BlockBackend *blk;",
"AioContext *aio_context;",
"blk = blk_by_name(VAR_0);",
"if (!blk) {",
"error_set(VAR_23, ERROR_CLASS_DEVICE_NOT_FOUND,\n\"Device '%s' not found\", VAR_0);",
"return;",
"}",
"aio_context = blk_get_aio_context(blk);",
"aio_context_acquire(aio_context);",
"bs = blk_bs(blk);",
"if (!bs) {",
"error_setg(VAR_23, \"Device '%s' has no medium\", VAR_0);",
"goto out;",
"}",
"memset(&cfg, 0, sizeof(cfg));",
"cfg.buckets[THROTTLE_BPS_TOTAL].avg = VAR_1;",
"cfg.buckets[THROTTLE_BPS_READ].avg = VAR_2;",
"cfg.buckets[THROTTLE_BPS_WRITE].avg = VAR_3;",
"cfg.buckets[THROTTLE_OPS_TOTAL].avg = VAR_4;",
"cfg.buckets[THROTTLE_OPS_READ].avg = VAR_5;",
"cfg.buckets[THROTTLE_OPS_WRITE].avg = VAR_6;",
"if (VAR_7) {",
"cfg.buckets[THROTTLE_BPS_TOTAL].max = VAR_8;",
"}",
"if (VAR_9) {",
"cfg.buckets[THROTTLE_BPS_READ].max = VAR_10;",
"}",
"if (VAR_11) {",
"cfg.buckets[THROTTLE_BPS_WRITE].max = VAR_12;",
"}",
"if (VAR_13) {",
"cfg.buckets[THROTTLE_OPS_TOTAL].max = VAR_14;",
"}",
"if (VAR_15) {",
"cfg.buckets[THROTTLE_OPS_READ].max = VAR_16;",
"}",
"if (VAR_17) {",
"cfg.buckets[THROTTLE_OPS_WRITE].max = VAR_18;",
"}",
"if (VAR_19) {",
"cfg.op_size = VAR_20;",
"}",
"if (!check_throttle_config(&cfg, VAR_23)) {",
"goto out;",
"}",
"if (throttle_enabled(&cfg)) {",
"if (!bs->io_limits_enabled) {",
"bdrv_io_limits_enable(bs, VAR_21 ? VAR_22 : VAR_0);",
"} else if (VAR_21) {",
"bdrv_io_limits_update_group(bs, VAR_22);",
"}",
"bdrv_set_io_limits(bs, &cfg);",
"} else if (bs->io_limits_enabled) {",
"bdrv_io_limits_disable(bs);",
"}",
"out:\naio_context_release(aio_context);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
151
],
[
153
],
[
155
],
[
159
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
177
],
[
179
],
[
183
],
[
185
],
[
189,
191
],
[
193
]
] |
3,265 | static inline void gen_op_eval_fbue(TCGv dst, TCGv src,
unsigned int fcc_offset)
{
gen_mov_reg_FCC0(dst, src, fcc_offset);
gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset);
tcg_gen_xor_tl(dst, dst, cpu_tmp0);
tcg_gen_xori_tl(dst, dst, 0x1);
}
| false | qemu | de9e9d9f17a36ff76c1a02a5348835e5e0a081b0 | static inline void gen_op_eval_fbue(TCGv dst, TCGv src,
unsigned int fcc_offset)
{
gen_mov_reg_FCC0(dst, src, fcc_offset);
gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset);
tcg_gen_xor_tl(dst, dst, cpu_tmp0);
tcg_gen_xori_tl(dst, dst, 0x1);
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(TCGv VAR_0, TCGv VAR_1,
unsigned int VAR_2)
{
gen_mov_reg_FCC0(VAR_0, VAR_1, VAR_2);
gen_mov_reg_FCC1(cpu_tmp0, VAR_1, VAR_2);
tcg_gen_xor_tl(VAR_0, VAR_0, cpu_tmp0);
tcg_gen_xori_tl(VAR_0, VAR_0, 0x1);
}
| [
"static inline void FUNC_0(TCGv VAR_0, TCGv VAR_1,\nunsigned int VAR_2)\n{",
"gen_mov_reg_FCC0(VAR_0, VAR_1, VAR_2);",
"gen_mov_reg_FCC1(cpu_tmp0, VAR_1, VAR_2);",
"tcg_gen_xor_tl(VAR_0, VAR_0, cpu_tmp0);",
"tcg_gen_xori_tl(VAR_0, VAR_0, 0x1);",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
3,267 | static void vnc_client_error(VncState *vs)
{
vnc_client_io_error(vs, -1, EINVAL);
}
| false | qemu | 5fb6c7a8b26eab1a22207d24b4784bd2b39ab54b | static void vnc_client_error(VncState *vs)
{
vnc_client_io_error(vs, -1, EINVAL);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(VncState *VAR_0)
{
vnc_client_io_error(VAR_0, -1, EINVAL);
}
| [
"static void FUNC_0(VncState *VAR_0)\n{",
"vnc_client_io_error(VAR_0, -1, EINVAL);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
3,268 | static void msix_set_pending(PCIDevice *dev, int vector)
{
*msix_pending_byte(dev, vector) |= msix_pending_mask(vector);
}
| false | qemu | 70f8ee395afda6d96b15cb9a5b311af7720dded0 | static void msix_set_pending(PCIDevice *dev, int vector)
{
*msix_pending_byte(dev, vector) |= msix_pending_mask(vector);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(PCIDevice *VAR_0, int VAR_1)
{
*msix_pending_byte(VAR_0, VAR_1) |= msix_pending_mask(VAR_1);
}
| [
"static void FUNC_0(PCIDevice *VAR_0, int VAR_1)\n{",
"*msix_pending_byte(VAR_0, VAR_1) |= msix_pending_mask(VAR_1);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
3,269 | static void qlist_destroy_obj(QObject *obj)
{
QList *qlist;
QListEntry *entry, *next_entry;
assert(obj != NULL);
qlist = qobject_to_qlist(obj);
QTAILQ_FOREACH_SAFE(entry, &qlist->head, next, next_entry) {
QTAILQ_REMOVE(&qlist->head, entry, next);
qobject_decref(entry->value);
g_free(entry);
}
g_free(qlist);
}
| false | qemu | 55e1819c509b3d9c10a54678b9c585bbda13889e | static void qlist_destroy_obj(QObject *obj)
{
QList *qlist;
QListEntry *entry, *next_entry;
assert(obj != NULL);
qlist = qobject_to_qlist(obj);
QTAILQ_FOREACH_SAFE(entry, &qlist->head, next, next_entry) {
QTAILQ_REMOVE(&qlist->head, entry, next);
qobject_decref(entry->value);
g_free(entry);
}
g_free(qlist);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(QObject *VAR_0)
{
QList *qlist;
QListEntry *entry, *next_entry;
assert(VAR_0 != NULL);
qlist = qobject_to_qlist(VAR_0);
QTAILQ_FOREACH_SAFE(entry, &qlist->head, next, next_entry) {
QTAILQ_REMOVE(&qlist->head, entry, next);
qobject_decref(entry->value);
g_free(entry);
}
g_free(qlist);
}
| [
"static void FUNC_0(QObject *VAR_0)\n{",
"QList *qlist;",
"QListEntry *entry, *next_entry;",
"assert(VAR_0 != NULL);",
"qlist = qobject_to_qlist(VAR_0);",
"QTAILQ_FOREACH_SAFE(entry, &qlist->head, next, next_entry) {",
"QTAILQ_REMOVE(&qlist->head, entry, next);",
"qobject_decref(entry->value);",
"g_free(entry);",
"}",
"g_free(qlist);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
]
] |
3,271 | static int read_f(int argc, char **argv)
{
struct timeval t1, t2;
int Cflag = 0, pflag = 0, qflag = 0, vflag = 0;
int Pflag = 0, sflag = 0, lflag = 0, bflag = 0;
int c, cnt;
char *buf;
int64_t offset;
int count;
/* Some compilers get confused and warn if this is not initialized. */
int total = 0;
int pattern = 0, pattern_offset = 0, pattern_count = 0;
while ((c = getopt(argc, argv, "bCl:pP:qs:v")) != EOF) {
switch (c) {
case 'b':
bflag = 1;
break;
case 'C':
Cflag = 1;
break;
case 'l':
lflag = 1;
pattern_count = cvtnum(optarg);
if (pattern_count < 0) {
printf("non-numeric length argument -- %s\n", optarg);
return 0;
}
break;
case 'p':
pflag = 1;
break;
case 'P':
Pflag = 1;
pattern = parse_pattern(optarg);
if (pattern < 0) {
return 0;
}
break;
case 'q':
qflag = 1;
break;
case 's':
sflag = 1;
pattern_offset = cvtnum(optarg);
if (pattern_offset < 0) {
printf("non-numeric length argument -- %s\n", optarg);
return 0;
}
break;
case 'v':
vflag = 1;
break;
default:
return command_usage(&read_cmd);
}
}
if (optind != argc - 2) {
return command_usage(&read_cmd);
}
if (bflag && pflag) {
printf("-b and -p cannot be specified at the same time\n");
return 0;
}
offset = cvtnum(argv[optind]);
if (offset < 0) {
printf("non-numeric length argument -- %s\n", argv[optind]);
return 0;
}
optind++;
count = cvtnum(argv[optind]);
if (count < 0) {
printf("non-numeric length argument -- %s\n", argv[optind]);
return 0;
}
if (!Pflag && (lflag || sflag)) {
return command_usage(&read_cmd);
}
if (!lflag) {
pattern_count = count - pattern_offset;
}
if ((pattern_count < 0) || (pattern_count + pattern_offset > count)) {
printf("pattern verification range exceeds end of read data\n");
return 0;
}
if (!pflag) {
if (offset & 0x1ff) {
printf("offset %" PRId64 " is not sector aligned\n",
offset);
return 0;
}
if (count & 0x1ff) {
printf("count %d is not sector aligned\n",
count);
return 0;
}
}
buf = qemu_io_alloc(count, 0xab);
gettimeofday(&t1, NULL);
if (pflag) {
cnt = do_pread(buf, offset, count, &total);
} else if (bflag) {
cnt = do_load_vmstate(buf, offset, count, &total);
} else {
cnt = do_read(buf, offset, count, &total);
}
gettimeofday(&t2, NULL);
if (cnt < 0) {
printf("read failed: %s\n", strerror(-cnt));
goto out;
}
if (Pflag) {
void *cmp_buf = malloc(pattern_count);
memset(cmp_buf, pattern, pattern_count);
if (memcmp(buf + pattern_offset, cmp_buf, pattern_count)) {
printf("Pattern verification failed at offset %"
PRId64 ", %d bytes\n",
offset + pattern_offset, pattern_count);
}
free(cmp_buf);
}
if (qflag) {
goto out;
}
if (vflag) {
dump_buffer(buf, offset, count);
}
/* Finally, report back -- -C gives a parsable format */
t2 = tsub(t2, t1);
print_report("read", &t2, offset, count, total, cnt, Cflag);
out:
qemu_io_free(buf);
return 0;
}
| false | qemu | 031380d8770d2df6c386e4aeabd412007d3ebd54 | static int read_f(int argc, char **argv)
{
struct timeval t1, t2;
int Cflag = 0, pflag = 0, qflag = 0, vflag = 0;
int Pflag = 0, sflag = 0, lflag = 0, bflag = 0;
int c, cnt;
char *buf;
int64_t offset;
int count;
int total = 0;
int pattern = 0, pattern_offset = 0, pattern_count = 0;
while ((c = getopt(argc, argv, "bCl:pP:qs:v")) != EOF) {
switch (c) {
case 'b':
bflag = 1;
break;
case 'C':
Cflag = 1;
break;
case 'l':
lflag = 1;
pattern_count = cvtnum(optarg);
if (pattern_count < 0) {
printf("non-numeric length argument -- %s\n", optarg);
return 0;
}
break;
case 'p':
pflag = 1;
break;
case 'P':
Pflag = 1;
pattern = parse_pattern(optarg);
if (pattern < 0) {
return 0;
}
break;
case 'q':
qflag = 1;
break;
case 's':
sflag = 1;
pattern_offset = cvtnum(optarg);
if (pattern_offset < 0) {
printf("non-numeric length argument -- %s\n", optarg);
return 0;
}
break;
case 'v':
vflag = 1;
break;
default:
return command_usage(&read_cmd);
}
}
if (optind != argc - 2) {
return command_usage(&read_cmd);
}
if (bflag && pflag) {
printf("-b and -p cannot be specified at the same time\n");
return 0;
}
offset = cvtnum(argv[optind]);
if (offset < 0) {
printf("non-numeric length argument -- %s\n", argv[optind]);
return 0;
}
optind++;
count = cvtnum(argv[optind]);
if (count < 0) {
printf("non-numeric length argument -- %s\n", argv[optind]);
return 0;
}
if (!Pflag && (lflag || sflag)) {
return command_usage(&read_cmd);
}
if (!lflag) {
pattern_count = count - pattern_offset;
}
if ((pattern_count < 0) || (pattern_count + pattern_offset > count)) {
printf("pattern verification range exceeds end of read data\n");
return 0;
}
if (!pflag) {
if (offset & 0x1ff) {
printf("offset %" PRId64 " is not sector aligned\n",
offset);
return 0;
}
if (count & 0x1ff) {
printf("count %d is not sector aligned\n",
count);
return 0;
}
}
buf = qemu_io_alloc(count, 0xab);
gettimeofday(&t1, NULL);
if (pflag) {
cnt = do_pread(buf, offset, count, &total);
} else if (bflag) {
cnt = do_load_vmstate(buf, offset, count, &total);
} else {
cnt = do_read(buf, offset, count, &total);
}
gettimeofday(&t2, NULL);
if (cnt < 0) {
printf("read failed: %s\n", strerror(-cnt));
goto out;
}
if (Pflag) {
void *cmp_buf = malloc(pattern_count);
memset(cmp_buf, pattern, pattern_count);
if (memcmp(buf + pattern_offset, cmp_buf, pattern_count)) {
printf("Pattern verification failed at offset %"
PRId64 ", %d bytes\n",
offset + pattern_offset, pattern_count);
}
free(cmp_buf);
}
if (qflag) {
goto out;
}
if (vflag) {
dump_buffer(buf, offset, count);
}
t2 = tsub(t2, t1);
print_report("read", &t2, offset, count, total, cnt, Cflag);
out:
qemu_io_free(buf);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(int VAR_0, char **VAR_1)
{
struct timeval VAR_2, VAR_3;
int VAR_4 = 0, VAR_5 = 0, VAR_6 = 0, VAR_7 = 0;
int VAR_8 = 0, VAR_9 = 0, VAR_10 = 0, VAR_11 = 0;
int VAR_12, VAR_13;
char *VAR_14;
int64_t offset;
int VAR_15;
int VAR_16 = 0;
int VAR_17 = 0, VAR_18 = 0, VAR_19 = 0;
while ((VAR_12 = getopt(VAR_0, VAR_1, "bCl:pP:qs:v")) != EOF) {
switch (VAR_12) {
case 'b':
VAR_11 = 1;
break;
case 'C':
VAR_4 = 1;
break;
case 'l':
VAR_10 = 1;
VAR_19 = cvtnum(optarg);
if (VAR_19 < 0) {
printf("non-numeric length argument -- %s\n", optarg);
return 0;
}
break;
case 'p':
VAR_5 = 1;
break;
case 'P':
VAR_8 = 1;
VAR_17 = parse_pattern(optarg);
if (VAR_17 < 0) {
return 0;
}
break;
case 'q':
VAR_6 = 1;
break;
case 's':
VAR_9 = 1;
VAR_18 = cvtnum(optarg);
if (VAR_18 < 0) {
printf("non-numeric length argument -- %s\n", optarg);
return 0;
}
break;
case 'v':
VAR_7 = 1;
break;
default:
return command_usage(&read_cmd);
}
}
if (optind != VAR_0 - 2) {
return command_usage(&read_cmd);
}
if (VAR_11 && VAR_5) {
printf("-b and -p cannot be specified at the same time\n");
return 0;
}
offset = cvtnum(VAR_1[optind]);
if (offset < 0) {
printf("non-numeric length argument -- %s\n", VAR_1[optind]);
return 0;
}
optind++;
VAR_15 = cvtnum(VAR_1[optind]);
if (VAR_15 < 0) {
printf("non-numeric length argument -- %s\n", VAR_1[optind]);
return 0;
}
if (!VAR_8 && (VAR_10 || VAR_9)) {
return command_usage(&read_cmd);
}
if (!VAR_10) {
VAR_19 = VAR_15 - VAR_18;
}
if ((VAR_19 < 0) || (VAR_19 + VAR_18 > VAR_15)) {
printf("VAR_17 verification range exceeds end of read data\n");
return 0;
}
if (!VAR_5) {
if (offset & 0x1ff) {
printf("offset %" PRId64 " is not sector aligned\n",
offset);
return 0;
}
if (VAR_15 & 0x1ff) {
printf("VAR_15 %d is not sector aligned\n",
VAR_15);
return 0;
}
}
VAR_14 = qemu_io_alloc(VAR_15, 0xab);
gettimeofday(&VAR_2, NULL);
if (VAR_5) {
VAR_13 = do_pread(VAR_14, offset, VAR_15, &VAR_16);
} else if (VAR_11) {
VAR_13 = do_load_vmstate(VAR_14, offset, VAR_15, &VAR_16);
} else {
VAR_13 = do_read(VAR_14, offset, VAR_15, &VAR_16);
}
gettimeofday(&VAR_3, NULL);
if (VAR_13 < 0) {
printf("read failed: %s\n", strerror(-VAR_13));
goto out;
}
if (VAR_8) {
void *VAR_20 = malloc(VAR_19);
memset(VAR_20, VAR_17, VAR_19);
if (memcmp(VAR_14 + VAR_18, VAR_20, VAR_19)) {
printf("Pattern verification failed at offset %"
PRId64 ", %d bytes\n",
offset + VAR_18, VAR_19);
}
free(VAR_20);
}
if (VAR_6) {
goto out;
}
if (VAR_7) {
dump_buffer(VAR_14, offset, VAR_15);
}
VAR_3 = tsub(VAR_3, VAR_2);
print_report("read", &VAR_3, offset, VAR_15, VAR_16, VAR_13, VAR_4);
out:
qemu_io_free(VAR_14);
return 0;
}
| [
"static int FUNC_0(int VAR_0, char **VAR_1)\n{",
"struct timeval VAR_2, VAR_3;",
"int VAR_4 = 0, VAR_5 = 0, VAR_6 = 0, VAR_7 = 0;",
"int VAR_8 = 0, VAR_9 = 0, VAR_10 = 0, VAR_11 = 0;",
"int VAR_12, VAR_13;",
"char *VAR_14;",
"int64_t offset;",
"int VAR_15;",
"int VAR_16 = 0;",
"int VAR_17 = 0, VAR_18 = 0, VAR_19 = 0;",
"while ((VAR_12 = getopt(VAR_0, VAR_1, \"bCl:pP:qs:v\")) != EOF) {",
"switch (VAR_12) {",
"case 'b':\nVAR_11 = 1;",
"break;",
"case 'C':\nVAR_4 = 1;",
"break;",
"case 'l':\nVAR_10 = 1;",
"VAR_19 = cvtnum(optarg);",
"if (VAR_19 < 0) {",
"printf(\"non-numeric length argument -- %s\\n\", optarg);",
"return 0;",
"}",
"break;",
"case 'p':\nVAR_5 = 1;",
"break;",
"case 'P':\nVAR_8 = 1;",
"VAR_17 = parse_pattern(optarg);",
"if (VAR_17 < 0) {",
"return 0;",
"}",
"break;",
"case 'q':\nVAR_6 = 1;",
"break;",
"case 's':\nVAR_9 = 1;",
"VAR_18 = cvtnum(optarg);",
"if (VAR_18 < 0) {",
"printf(\"non-numeric length argument -- %s\\n\", optarg);",
"return 0;",
"}",
"break;",
"case 'v':\nVAR_7 = 1;",
"break;",
"default:\nreturn command_usage(&read_cmd);",
"}",
"}",
"if (optind != VAR_0 - 2) {",
"return command_usage(&read_cmd);",
"}",
"if (VAR_11 && VAR_5) {",
"printf(\"-b and -p cannot be specified at the same time\\n\");",
"return 0;",
"}",
"offset = cvtnum(VAR_1[optind]);",
"if (offset < 0) {",
"printf(\"non-numeric length argument -- %s\\n\", VAR_1[optind]);",
"return 0;",
"}",
"optind++;",
"VAR_15 = cvtnum(VAR_1[optind]);",
"if (VAR_15 < 0) {",
"printf(\"non-numeric length argument -- %s\\n\", VAR_1[optind]);",
"return 0;",
"}",
"if (!VAR_8 && (VAR_10 || VAR_9)) {",
"return command_usage(&read_cmd);",
"}",
"if (!VAR_10) {",
"VAR_19 = VAR_15 - VAR_18;",
"}",
"if ((VAR_19 < 0) || (VAR_19 + VAR_18 > VAR_15)) {",
"printf(\"VAR_17 verification range exceeds end of read data\\n\");",
"return 0;",
"}",
"if (!VAR_5) {",
"if (offset & 0x1ff) {",
"printf(\"offset %\" PRId64 \" is not sector aligned\\n\",\noffset);",
"return 0;",
"}",
"if (VAR_15 & 0x1ff) {",
"printf(\"VAR_15 %d is not sector aligned\\n\",\nVAR_15);",
"return 0;",
"}",
"}",
"VAR_14 = qemu_io_alloc(VAR_15, 0xab);",
"gettimeofday(&VAR_2, NULL);",
"if (VAR_5) {",
"VAR_13 = do_pread(VAR_14, offset, VAR_15, &VAR_16);",
"} else if (VAR_11) {",
"VAR_13 = do_load_vmstate(VAR_14, offset, VAR_15, &VAR_16);",
"} else {",
"VAR_13 = do_read(VAR_14, offset, VAR_15, &VAR_16);",
"}",
"gettimeofday(&VAR_3, NULL);",
"if (VAR_13 < 0) {",
"printf(\"read failed: %s\\n\", strerror(-VAR_13));",
"goto out;",
"}",
"if (VAR_8) {",
"void *VAR_20 = malloc(VAR_19);",
"memset(VAR_20, VAR_17, VAR_19);",
"if (memcmp(VAR_14 + VAR_18, VAR_20, VAR_19)) {",
"printf(\"Pattern verification failed at offset %\"\nPRId64 \", %d bytes\\n\",\noffset + VAR_18, VAR_19);",
"}",
"free(VAR_20);",
"}",
"if (VAR_6) {",
"goto out;",
"}",
"if (VAR_7) {",
"dump_buffer(VAR_14, offset, VAR_15);",
"}",
"VAR_3 = tsub(VAR_3, VAR_2);",
"print_report(\"read\", &VAR_3, offset, VAR_15, VAR_16, VAR_13, VAR_4);",
"out:\nqemu_io_free(VAR_14);",
"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,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37,
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
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
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
161
],
[
163
],
[
165
],
[
169
],
[
171
],
[
173
],
[
177
],
[
179
],
[
181
],
[
183
],
[
187
],
[
189
],
[
191,
193
],
[
195
],
[
197
],
[
199
],
[
201,
203
],
[
205
],
[
207
],
[
209
],
[
213
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
237
],
[
239
],
[
241
],
[
243
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255,
257,
259
],
[
261
],
[
263
],
[
265
],
[
269
],
[
271
],
[
273
],
[
277
],
[
279
],
[
281
],
[
287
],
[
289
],
[
293,
295
],
[
299
],
[
301
]
] |
3,272 | static void dec_barrel(DisasContext *dc)
{
TCGv t0;
unsigned int s, t;
if ((dc->tb_flags & MSR_EE_FLAG)
&& !(dc->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK)
&& !(dc->env->pvr.regs[0] & PVR0_USE_BARREL_MASK)) {
tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP);
t_gen_raise_exception(dc, EXCP_HW_EXCP);
return;
}
s = dc->imm & (1 << 10);
t = dc->imm & (1 << 9);
LOG_DIS("bs%s%s r%d r%d r%d\n",
s ? "l" : "r", t ? "a" : "l", dc->rd, dc->ra, dc->rb);
t0 = tcg_temp_new();
tcg_gen_mov_tl(t0, *(dec_alu_op_b(dc)));
tcg_gen_andi_tl(t0, t0, 31);
if (s)
tcg_gen_shl_tl(cpu_R[dc->rd], cpu_R[dc->ra], t0);
else {
if (t)
tcg_gen_sar_tl(cpu_R[dc->rd], cpu_R[dc->ra], t0);
else
tcg_gen_shr_tl(cpu_R[dc->rd], cpu_R[dc->ra], t0);
}
}
| false | qemu | 97f90cbfe810bb153fc44bde732d9639610783bb | static void dec_barrel(DisasContext *dc)
{
TCGv t0;
unsigned int s, t;
if ((dc->tb_flags & MSR_EE_FLAG)
&& !(dc->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK)
&& !(dc->env->pvr.regs[0] & PVR0_USE_BARREL_MASK)) {
tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP);
t_gen_raise_exception(dc, EXCP_HW_EXCP);
return;
}
s = dc->imm & (1 << 10);
t = dc->imm & (1 << 9);
LOG_DIS("bs%s%s r%d r%d r%d\n",
s ? "l" : "r", t ? "a" : "l", dc->rd, dc->ra, dc->rb);
t0 = tcg_temp_new();
tcg_gen_mov_tl(t0, *(dec_alu_op_b(dc)));
tcg_gen_andi_tl(t0, t0, 31);
if (s)
tcg_gen_shl_tl(cpu_R[dc->rd], cpu_R[dc->ra], t0);
else {
if (t)
tcg_gen_sar_tl(cpu_R[dc->rd], cpu_R[dc->ra], t0);
else
tcg_gen_shr_tl(cpu_R[dc->rd], cpu_R[dc->ra], t0);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0)
{
TCGv t0;
unsigned int VAR_1, VAR_2;
if ((VAR_0->tb_flags & MSR_EE_FLAG)
&& !(VAR_0->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK)
&& !(VAR_0->env->pvr.regs[0] & PVR0_USE_BARREL_MASK)) {
tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP);
t_gen_raise_exception(VAR_0, EXCP_HW_EXCP);
return;
}
VAR_1 = VAR_0->imm & (1 << 10);
VAR_2 = VAR_0->imm & (1 << 9);
LOG_DIS("bs%VAR_1%VAR_1 r%d r%d r%d\n",
VAR_1 ? "l" : "r", VAR_2 ? "a" : "l", VAR_0->rd, VAR_0->ra, VAR_0->rb);
t0 = tcg_temp_new();
tcg_gen_mov_tl(t0, *(dec_alu_op_b(VAR_0)));
tcg_gen_andi_tl(t0, t0, 31);
if (VAR_1)
tcg_gen_shl_tl(cpu_R[VAR_0->rd], cpu_R[VAR_0->ra], t0);
else {
if (VAR_2)
tcg_gen_sar_tl(cpu_R[VAR_0->rd], cpu_R[VAR_0->ra], t0);
else
tcg_gen_shr_tl(cpu_R[VAR_0->rd], cpu_R[VAR_0->ra], t0);
}
}
| [
"static void FUNC_0(DisasContext *VAR_0)\n{",
"TCGv t0;",
"unsigned int VAR_1, VAR_2;",
"if ((VAR_0->tb_flags & MSR_EE_FLAG)\n&& !(VAR_0->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK)\n&& !(VAR_0->env->pvr.regs[0] & PVR0_USE_BARREL_MASK)) {",
"tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP);",
"t_gen_raise_exception(VAR_0, EXCP_HW_EXCP);",
"return;",
"}",
"VAR_1 = VAR_0->imm & (1 << 10);",
"VAR_2 = VAR_0->imm & (1 << 9);",
"LOG_DIS(\"bs%VAR_1%VAR_1 r%d r%d r%d\\n\",\nVAR_1 ? \"l\" : \"r\", VAR_2 ? \"a\" : \"l\", VAR_0->rd, VAR_0->ra, VAR_0->rb);",
"t0 = tcg_temp_new();",
"tcg_gen_mov_tl(t0, *(dec_alu_op_b(VAR_0)));",
"tcg_gen_andi_tl(t0, t0, 31);",
"if (VAR_1)\ntcg_gen_shl_tl(cpu_R[VAR_0->rd], cpu_R[VAR_0->ra], t0);",
"else {",
"if (VAR_2)\ntcg_gen_sar_tl(cpu_R[VAR_0->rd], cpu_R[VAR_0->ra], t0);",
"else\ntcg_gen_shr_tl(cpu_R[VAR_0->rd], cpu_R[VAR_0->ra], t0);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
33,
35
],
[
39
],
[
43
],
[
45
],
[
49,
51
],
[
53
],
[
55,
57
],
[
59,
61
],
[
63
],
[
65
]
] |
3,273 | static void ide_dma_restart_cb(void *opaque, int running, int reason)
{
BMDMAState *bm = opaque;
if (!running)
return;
if (bm->status & BM_STATUS_DMA_RETRY) {
bm->status &= ~BM_STATUS_DMA_RETRY;
ide_dma_restart(bm->ide_if);
} else if (bm->status & BM_STATUS_PIO_RETRY) {
bm->status &= ~BM_STATUS_PIO_RETRY;
ide_sector_write(bm->ide_if);
}
}
| false | qemu | 213189ab65d83ecd9072f27c80a15dcb91b6bdbf | static void ide_dma_restart_cb(void *opaque, int running, int reason)
{
BMDMAState *bm = opaque;
if (!running)
return;
if (bm->status & BM_STATUS_DMA_RETRY) {
bm->status &= ~BM_STATUS_DMA_RETRY;
ide_dma_restart(bm->ide_if);
} else if (bm->status & BM_STATUS_PIO_RETRY) {
bm->status &= ~BM_STATUS_PIO_RETRY;
ide_sector_write(bm->ide_if);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, int VAR_1, int VAR_2)
{
BMDMAState *bm = VAR_0;
if (!VAR_1)
return;
if (bm->status & BM_STATUS_DMA_RETRY) {
bm->status &= ~BM_STATUS_DMA_RETRY;
ide_dma_restart(bm->ide_if);
} else if (bm->status & BM_STATUS_PIO_RETRY) {
bm->status &= ~BM_STATUS_PIO_RETRY;
ide_sector_write(bm->ide_if);
}
}
| [
"static void FUNC_0(void *VAR_0, int VAR_1, int VAR_2)\n{",
"BMDMAState *bm = VAR_0;",
"if (!VAR_1)\nreturn;",
"if (bm->status & BM_STATUS_DMA_RETRY) {",
"bm->status &= ~BM_STATUS_DMA_RETRY;",
"ide_dma_restart(bm->ide_if);",
"} else if (bm->status & BM_STATUS_PIO_RETRY) {",
"bm->status &= ~BM_STATUS_PIO_RETRY;",
"ide_sector_write(bm->ide_if);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
]
] |
3,276 | static int ahci_start_transfer(IDEDMA *dma)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
IDEState *s = &ad->port.ifs[0];
uint32_t size = (uint32_t)(s->data_end - s->data_ptr);
/* write == ram -> device */
uint32_t opts = le32_to_cpu(ad->cur_cmd->opts);
int is_write = opts & AHCI_CMD_WRITE;
int is_atapi = opts & AHCI_CMD_ATAPI;
int has_sglist = 0;
if (is_atapi && !ad->done_atapi_packet) {
/* already prepopulated iobuffer */
ad->done_atapi_packet = 1;
goto out;
}
if (!ahci_populate_sglist(ad, &s->sg)) {
has_sglist = 1;
}
DPRINTF(ad->port_no, "%sing %d bytes on %s w/%s sglist\n",
is_write ? "writ" : "read", size, is_atapi ? "atapi" : "ata",
has_sglist ? "" : "o");
if (has_sglist && size) {
if (is_write) {
dma_buf_write(s->data_ptr, size, &s->sg);
} else {
dma_buf_read(s->data_ptr, size, &s->sg);
}
}
/* update number of transferred bytes */
ad->cur_cmd->status = cpu_to_le32(le32_to_cpu(ad->cur_cmd->status) + size);
out:
/* declare that we processed everything */
s->data_ptr = s->data_end;
if (has_sglist) {
qemu_sglist_destroy(&s->sg);
}
s->end_transfer_func(s);
if (!(s->status & DRQ_STAT)) {
/* done with DMA */
ahci_trigger_irq(ad->hba, ad, PORT_IRQ_STAT_DSS);
}
return 0;
}
| true | qemu | 61f52e06f0a21bab782f98ef3ea789aa6d0aa046 | static int ahci_start_transfer(IDEDMA *dma)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
IDEState *s = &ad->port.ifs[0];
uint32_t size = (uint32_t)(s->data_end - s->data_ptr);
uint32_t opts = le32_to_cpu(ad->cur_cmd->opts);
int is_write = opts & AHCI_CMD_WRITE;
int is_atapi = opts & AHCI_CMD_ATAPI;
int has_sglist = 0;
if (is_atapi && !ad->done_atapi_packet) {
ad->done_atapi_packet = 1;
goto out;
}
if (!ahci_populate_sglist(ad, &s->sg)) {
has_sglist = 1;
}
DPRINTF(ad->port_no, "%sing %d bytes on %s w/%s sglist\n",
is_write ? "writ" : "read", size, is_atapi ? "atapi" : "ata",
has_sglist ? "" : "o");
if (has_sglist && size) {
if (is_write) {
dma_buf_write(s->data_ptr, size, &s->sg);
} else {
dma_buf_read(s->data_ptr, size, &s->sg);
}
}
ad->cur_cmd->status = cpu_to_le32(le32_to_cpu(ad->cur_cmd->status) + size);
out:
s->data_ptr = s->data_end;
if (has_sglist) {
qemu_sglist_destroy(&s->sg);
}
s->end_transfer_func(s);
if (!(s->status & DRQ_STAT)) {
ahci_trigger_irq(ad->hba, ad, PORT_IRQ_STAT_DSS);
}
return 0;
}
| {
"code": [
" if (!ahci_populate_sglist(ad, &s->sg)) {"
],
"line_no": [
35
]
} | static int FUNC_0(IDEDMA *VAR_0)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, VAR_0, VAR_0);
IDEState *s = &ad->port.ifs[0];
uint32_t size = (uint32_t)(s->data_end - s->data_ptr);
uint32_t opts = le32_to_cpu(ad->cur_cmd->opts);
int VAR_1 = opts & AHCI_CMD_WRITE;
int VAR_2 = opts & AHCI_CMD_ATAPI;
int VAR_3 = 0;
if (VAR_2 && !ad->done_atapi_packet) {
ad->done_atapi_packet = 1;
goto out;
}
if (!ahci_populate_sglist(ad, &s->sg)) {
VAR_3 = 1;
}
DPRINTF(ad->port_no, "%sing %d bytes on %s w/%s sglist\n",
VAR_1 ? "writ" : "read", size, VAR_2 ? "atapi" : "ata",
VAR_3 ? "" : "o");
if (VAR_3 && size) {
if (VAR_1) {
dma_buf_write(s->data_ptr, size, &s->sg);
} else {
dma_buf_read(s->data_ptr, size, &s->sg);
}
}
ad->cur_cmd->status = cpu_to_le32(le32_to_cpu(ad->cur_cmd->status) + size);
out:
s->data_ptr = s->data_end;
if (VAR_3) {
qemu_sglist_destroy(&s->sg);
}
s->end_transfer_func(s);
if (!(s->status & DRQ_STAT)) {
ahci_trigger_irq(ad->hba, ad, PORT_IRQ_STAT_DSS);
}
return 0;
}
| [
"static int FUNC_0(IDEDMA *VAR_0)\n{",
"AHCIDevice *ad = DO_UPCAST(AHCIDevice, VAR_0, VAR_0);",
"IDEState *s = &ad->port.ifs[0];",
"uint32_t size = (uint32_t)(s->data_end - s->data_ptr);",
"uint32_t opts = le32_to_cpu(ad->cur_cmd->opts);",
"int VAR_1 = opts & AHCI_CMD_WRITE;",
"int VAR_2 = opts & AHCI_CMD_ATAPI;",
"int VAR_3 = 0;",
"if (VAR_2 && !ad->done_atapi_packet) {",
"ad->done_atapi_packet = 1;",
"goto out;",
"}",
"if (!ahci_populate_sglist(ad, &s->sg)) {",
"VAR_3 = 1;",
"}",
"DPRINTF(ad->port_no, \"%sing %d bytes on %s w/%s sglist\\n\",\nVAR_1 ? \"writ\" : \"read\", size, VAR_2 ? \"atapi\" : \"ata\",\nVAR_3 ? \"\" : \"o\");",
"if (VAR_3 && size) {",
"if (VAR_1) {",
"dma_buf_write(s->data_ptr, size, &s->sg);",
"} else {",
"dma_buf_read(s->data_ptr, size, &s->sg);",
"}",
"}",
"ad->cur_cmd->status = cpu_to_le32(le32_to_cpu(ad->cur_cmd->status) + size);",
"out:\ns->data_ptr = s->data_end;",
"if (VAR_3) {",
"qemu_sglist_destroy(&s->sg);",
"}",
"s->end_transfer_func(s);",
"if (!(s->status & DRQ_STAT)) {",
"ahci_trigger_irq(ad->hba, ad, PORT_IRQ_STAT_DSS);",
"}",
"return 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
43,
45,
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
69
],
[
73,
77
],
[
81
],
[
83
],
[
85
],
[
89
],
[
93
],
[
97
],
[
99
],
[
103
],
[
105
]
] |
3,277 | SocketAddress *socket_address_flatten(SocketAddressLegacy *addr_legacy)
{
SocketAddress *addr = g_new(SocketAddress, 1);
if (!addr_legacy) {
return NULL;
}
switch (addr_legacy->type) {
case SOCKET_ADDRESS_LEGACY_KIND_INET:
addr->type = SOCKET_ADDRESS_TYPE_INET;
QAPI_CLONE_MEMBERS(InetSocketAddress, &addr->u.inet,
addr_legacy->u.inet.data);
break;
case SOCKET_ADDRESS_LEGACY_KIND_UNIX:
addr->type = SOCKET_ADDRESS_TYPE_UNIX;
QAPI_CLONE_MEMBERS(UnixSocketAddress, &addr->u.q_unix,
addr_legacy->u.q_unix.data);
break;
case SOCKET_ADDRESS_LEGACY_KIND_VSOCK:
addr->type = SOCKET_ADDRESS_TYPE_VSOCK;
QAPI_CLONE_MEMBERS(VsockSocketAddress, &addr->u.vsock,
addr_legacy->u.vsock.data);
break;
case SOCKET_ADDRESS_LEGACY_KIND_FD:
addr->type = SOCKET_ADDRESS_TYPE_FD;
QAPI_CLONE_MEMBERS(String, &addr->u.fd, addr_legacy->u.fd.data);
break;
default:
abort();
}
return addr;
}
| true | qemu | fc0f005958ac2cba0d1b081733e19ef055d59636 | SocketAddress *socket_address_flatten(SocketAddressLegacy *addr_legacy)
{
SocketAddress *addr = g_new(SocketAddress, 1);
if (!addr_legacy) {
return NULL;
}
switch (addr_legacy->type) {
case SOCKET_ADDRESS_LEGACY_KIND_INET:
addr->type = SOCKET_ADDRESS_TYPE_INET;
QAPI_CLONE_MEMBERS(InetSocketAddress, &addr->u.inet,
addr_legacy->u.inet.data);
break;
case SOCKET_ADDRESS_LEGACY_KIND_UNIX:
addr->type = SOCKET_ADDRESS_TYPE_UNIX;
QAPI_CLONE_MEMBERS(UnixSocketAddress, &addr->u.q_unix,
addr_legacy->u.q_unix.data);
break;
case SOCKET_ADDRESS_LEGACY_KIND_VSOCK:
addr->type = SOCKET_ADDRESS_TYPE_VSOCK;
QAPI_CLONE_MEMBERS(VsockSocketAddress, &addr->u.vsock,
addr_legacy->u.vsock.data);
break;
case SOCKET_ADDRESS_LEGACY_KIND_FD:
addr->type = SOCKET_ADDRESS_TYPE_FD;
QAPI_CLONE_MEMBERS(String, &addr->u.fd, addr_legacy->u.fd.data);
break;
default:
abort();
}
return addr;
}
| {
"code": [
" SocketAddress *addr = g_new(SocketAddress, 1);"
],
"line_no": [
5
]
} | SocketAddress *FUNC_0(SocketAddressLegacy *addr_legacy)
{
SocketAddress *addr = g_new(SocketAddress, 1);
if (!addr_legacy) {
return NULL;
}
switch (addr_legacy->type) {
case SOCKET_ADDRESS_LEGACY_KIND_INET:
addr->type = SOCKET_ADDRESS_TYPE_INET;
QAPI_CLONE_MEMBERS(InetSocketAddress, &addr->u.inet,
addr_legacy->u.inet.data);
break;
case SOCKET_ADDRESS_LEGACY_KIND_UNIX:
addr->type = SOCKET_ADDRESS_TYPE_UNIX;
QAPI_CLONE_MEMBERS(UnixSocketAddress, &addr->u.q_unix,
addr_legacy->u.q_unix.data);
break;
case SOCKET_ADDRESS_LEGACY_KIND_VSOCK:
addr->type = SOCKET_ADDRESS_TYPE_VSOCK;
QAPI_CLONE_MEMBERS(VsockSocketAddress, &addr->u.vsock,
addr_legacy->u.vsock.data);
break;
case SOCKET_ADDRESS_LEGACY_KIND_FD:
addr->type = SOCKET_ADDRESS_TYPE_FD;
QAPI_CLONE_MEMBERS(String, &addr->u.fd, addr_legacy->u.fd.data);
break;
default:
abort();
}
return addr;
}
| [
"SocketAddress *FUNC_0(SocketAddressLegacy *addr_legacy)\n{",
"SocketAddress *addr = g_new(SocketAddress, 1);",
"if (!addr_legacy) {",
"return NULL;",
"}",
"switch (addr_legacy->type) {",
"case SOCKET_ADDRESS_LEGACY_KIND_INET:\naddr->type = SOCKET_ADDRESS_TYPE_INET;",
"QAPI_CLONE_MEMBERS(InetSocketAddress, &addr->u.inet,\naddr_legacy->u.inet.data);",
"break;",
"case SOCKET_ADDRESS_LEGACY_KIND_UNIX:\naddr->type = SOCKET_ADDRESS_TYPE_UNIX;",
"QAPI_CLONE_MEMBERS(UnixSocketAddress, &addr->u.q_unix,\naddr_legacy->u.q_unix.data);",
"break;",
"case SOCKET_ADDRESS_LEGACY_KIND_VSOCK:\naddr->type = SOCKET_ADDRESS_TYPE_VSOCK;",
"QAPI_CLONE_MEMBERS(VsockSocketAddress, &addr->u.vsock,\naddr_legacy->u.vsock.data);",
"break;",
"case SOCKET_ADDRESS_LEGACY_KIND_FD:\naddr->type = SOCKET_ADDRESS_TYPE_FD;",
"QAPI_CLONE_MEMBERS(String, &addr->u.fd, addr_legacy->u.fd.data);",
"break;",
"default:\nabort();",
"}",
"return addr;",
"}"
] | [
0,
1,
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
],
[
17
],
[
19,
21
],
[
23,
25
],
[
27
],
[
29,
31
],
[
33,
35
],
[
37
],
[
39,
41
],
[
43,
45
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
65
],
[
67
]
] |
3,280 | static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)
{
sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(dev));
CPUCore *cc = CPU_CORE(OBJECT(dev));
const char *typename = object_class_get_name(sc->cpu_class);
size_t size = object_type_get_instance_size(typename);
Error *local_err = NULL;
Object *obj;
int i;
sc->threads = g_malloc0(size * cc->nr_threads);
for (i = 0; i < cc->nr_threads; i++) {
char id[32];
void *obj = sc->threads + i * size;
object_initialize(obj, size, typename);
snprintf(id, sizeof(id), "thread[%d]", i);
object_property_add_child(OBJECT(sc), id, obj, &local_err);
if (local_err) {
goto err;
}
}
object_child_foreach(OBJECT(dev), spapr_cpu_core_realize_child, &local_err);
if (local_err) {
goto err;
} else {
return;
}
err:
while (--i >= 0) {
obj = sc->threads + i * size;
object_unparent(obj);
}
g_free(sc->threads);
error_propagate(errp, local_err);
} | true | qemu | 8e758dee663bfda2ccfe0076914bf49108055386 | static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)
{
sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(dev));
CPUCore *cc = CPU_CORE(OBJECT(dev));
const char *typename = object_class_get_name(sc->cpu_class);
size_t size = object_type_get_instance_size(typename);
Error *local_err = NULL;
Object *obj;
int i;
sc->threads = g_malloc0(size * cc->nr_threads);
for (i = 0; i < cc->nr_threads; i++) {
char id[32];
void *obj = sc->threads + i * size;
object_initialize(obj, size, typename);
snprintf(id, sizeof(id), "thread[%d]", i);
object_property_add_child(OBJECT(sc), id, obj, &local_err);
if (local_err) {
goto err;
}
}
object_child_foreach(OBJECT(dev), spapr_cpu_core_realize_child, &local_err);
if (local_err) {
goto err;
} else {
return;
}
err:
while (--i >= 0) {
obj = sc->threads + i * size;
object_unparent(obj);
}
g_free(sc->threads);
error_propagate(errp, local_err);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(VAR_0));
CPUCore *cc = CPU_CORE(OBJECT(VAR_0));
const char *VAR_2 = object_class_get_name(sc->cpu_class);
size_t size = object_type_get_instance_size(VAR_2);
Error *local_err = NULL;
Object *obj;
int VAR_3;
sc->threads = g_malloc0(size * cc->nr_threads);
for (VAR_3 = 0; VAR_3 < cc->nr_threads; VAR_3++) {
char id[32];
void *obj = sc->threads + VAR_3 * size;
object_initialize(obj, size, VAR_2);
snprintf(id, sizeof(id), "thread[%d]", VAR_3);
object_property_add_child(OBJECT(sc), id, obj, &local_err);
if (local_err) {
goto err;
}
}
object_child_foreach(OBJECT(VAR_0), spapr_cpu_core_realize_child, &local_err);
if (local_err) {
goto err;
} else {
return;
}
err:
while (--VAR_3 >= 0) {
obj = sc->threads + VAR_3 * size;
object_unparent(obj);
}
g_free(sc->threads);
error_propagate(VAR_1, local_err);
} | [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(VAR_0));",
"CPUCore *cc = CPU_CORE(OBJECT(VAR_0));",
"const char *VAR_2 = object_class_get_name(sc->cpu_class);",
"size_t size = object_type_get_instance_size(VAR_2);",
"Error *local_err = NULL;",
"Object *obj;",
"int VAR_3;",
"sc->threads = g_malloc0(size * cc->nr_threads);",
"for (VAR_3 = 0; VAR_3 < cc->nr_threads; VAR_3++) {",
"char id[32];",
"void *obj = sc->threads + VAR_3 * size;",
"object_initialize(obj, size, VAR_2);",
"snprintf(id, sizeof(id), \"thread[%d]\", VAR_3);",
"object_property_add_child(OBJECT(sc), id, obj, &local_err);",
"if (local_err) {",
"goto err;",
"}",
"}",
"object_child_foreach(OBJECT(VAR_0), spapr_cpu_core_realize_child, &local_err);",
"if (local_err) {",
"goto err;",
"} else {",
"return;",
"}",
"err:\nwhile (--VAR_3 >= 0) {",
"obj = sc->threads + VAR_3 * size;",
"object_unparent(obj);",
"}",
"g_free(sc->threads);",
"error_propagate(VAR_1, local_err);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
44
],
[
46
],
[
48
],
[
50
],
[
52
],
[
54
],
[
56
],
[
60,
62
],
[
64
],
[
66
],
[
68
],
[
70
],
[
72
],
[
74
]
] |
3,281 | static inline void RENAME(vu9_to_vu12)(const uint8_t *src1, const uint8_t *src2,
uint8_t *dst1, uint8_t *dst2,
int width, int height,
int srcStride1, int srcStride2,
int dstStride1, int dstStride2)
{
x86_reg y;
int x,w,h;
w=width/2; h=height/2;
__asm__ volatile(
PREFETCH" %0 \n\t"
PREFETCH" %1 \n\t"
::"m"(*(src1+srcStride1)),"m"(*(src2+srcStride2)):"memory");
for (y=0;y<h;y++) {
const uint8_t* s1=src1+srcStride1*(y>>1);
uint8_t* d=dst1+dstStride1*y;
x=0;
for (;x<w-31;x+=32) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq 8%1, %%mm2 \n\t"
"movq 16%1, %%mm4 \n\t"
"movq 24%1, %%mm6 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"movq %%mm4, %%mm5 \n\t"
"movq %%mm6, %%mm7 \n\t"
"punpcklbw %%mm0, %%mm0 \n\t"
"punpckhbw %%mm1, %%mm1 \n\t"
"punpcklbw %%mm2, %%mm2 \n\t"
"punpckhbw %%mm3, %%mm3 \n\t"
"punpcklbw %%mm4, %%mm4 \n\t"
"punpckhbw %%mm5, %%mm5 \n\t"
"punpcklbw %%mm6, %%mm6 \n\t"
"punpckhbw %%mm7, %%mm7 \n\t"
MOVNTQ" %%mm0, %0 \n\t"
MOVNTQ" %%mm1, 8%0 \n\t"
MOVNTQ" %%mm2, 16%0 \n\t"
MOVNTQ" %%mm3, 24%0 \n\t"
MOVNTQ" %%mm4, 32%0 \n\t"
MOVNTQ" %%mm5, 40%0 \n\t"
MOVNTQ" %%mm6, 48%0 \n\t"
MOVNTQ" %%mm7, 56%0"
:"=m"(d[2*x])
:"m"(s1[x])
:"memory");
}
for (;x<w;x++) d[2*x]=d[2*x+1]=s1[x];
}
for (y=0;y<h;y++) {
const uint8_t* s2=src2+srcStride2*(y>>1);
uint8_t* d=dst2+dstStride2*y;
x=0;
for (;x<w-31;x+=32) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq 8%1, %%mm2 \n\t"
"movq 16%1, %%mm4 \n\t"
"movq 24%1, %%mm6 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"movq %%mm4, %%mm5 \n\t"
"movq %%mm6, %%mm7 \n\t"
"punpcklbw %%mm0, %%mm0 \n\t"
"punpckhbw %%mm1, %%mm1 \n\t"
"punpcklbw %%mm2, %%mm2 \n\t"
"punpckhbw %%mm3, %%mm3 \n\t"
"punpcklbw %%mm4, %%mm4 \n\t"
"punpckhbw %%mm5, %%mm5 \n\t"
"punpcklbw %%mm6, %%mm6 \n\t"
"punpckhbw %%mm7, %%mm7 \n\t"
MOVNTQ" %%mm0, %0 \n\t"
MOVNTQ" %%mm1, 8%0 \n\t"
MOVNTQ" %%mm2, 16%0 \n\t"
MOVNTQ" %%mm3, 24%0 \n\t"
MOVNTQ" %%mm4, 32%0 \n\t"
MOVNTQ" %%mm5, 40%0 \n\t"
MOVNTQ" %%mm6, 48%0 \n\t"
MOVNTQ" %%mm7, 56%0"
:"=m"(d[2*x])
:"m"(s2[x])
:"memory");
}
for (;x<w;x++) d[2*x]=d[2*x+1]=s2[x];
}
__asm__(
EMMS" \n\t"
SFENCE" \n\t"
::: "memory"
);
}
| true | FFmpeg | 90540c2d5ace46a1e9789c75fde0b1f7dbb12a9b | static inline void RENAME(vu9_to_vu12)(const uint8_t *src1, const uint8_t *src2,
uint8_t *dst1, uint8_t *dst2,
int width, int height,
int srcStride1, int srcStride2,
int dstStride1, int dstStride2)
{
x86_reg y;
int x,w,h;
w=width/2; h=height/2;
__asm__ volatile(
PREFETCH" %0 \n\t"
PREFETCH" %1 \n\t"
::"m"(*(src1+srcStride1)),"m"(*(src2+srcStride2)):"memory");
for (y=0;y<h;y++) {
const uint8_t* s1=src1+srcStride1*(y>>1);
uint8_t* d=dst1+dstStride1*y;
x=0;
for (;x<w-31;x+=32) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq 8%1, %%mm2 \n\t"
"movq 16%1, %%mm4 \n\t"
"movq 24%1, %%mm6 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"movq %%mm4, %%mm5 \n\t"
"movq %%mm6, %%mm7 \n\t"
"punpcklbw %%mm0, %%mm0 \n\t"
"punpckhbw %%mm1, %%mm1 \n\t"
"punpcklbw %%mm2, %%mm2 \n\t"
"punpckhbw %%mm3, %%mm3 \n\t"
"punpcklbw %%mm4, %%mm4 \n\t"
"punpckhbw %%mm5, %%mm5 \n\t"
"punpcklbw %%mm6, %%mm6 \n\t"
"punpckhbw %%mm7, %%mm7 \n\t"
MOVNTQ" %%mm0, %0 \n\t"
MOVNTQ" %%mm1, 8%0 \n\t"
MOVNTQ" %%mm2, 16%0 \n\t"
MOVNTQ" %%mm3, 24%0 \n\t"
MOVNTQ" %%mm4, 32%0 \n\t"
MOVNTQ" %%mm5, 40%0 \n\t"
MOVNTQ" %%mm6, 48%0 \n\t"
MOVNTQ" %%mm7, 56%0"
:"=m"(d[2*x])
:"m"(s1[x])
:"memory");
}
for (;x<w;x++) d[2*x]=d[2*x+1]=s1[x];
}
for (y=0;y<h;y++) {
const uint8_t* s2=src2+srcStride2*(y>>1);
uint8_t* d=dst2+dstStride2*y;
x=0;
for (;x<w-31;x+=32) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq 8%1, %%mm2 \n\t"
"movq 16%1, %%mm4 \n\t"
"movq 24%1, %%mm6 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"movq %%mm4, %%mm5 \n\t"
"movq %%mm6, %%mm7 \n\t"
"punpcklbw %%mm0, %%mm0 \n\t"
"punpckhbw %%mm1, %%mm1 \n\t"
"punpcklbw %%mm2, %%mm2 \n\t"
"punpckhbw %%mm3, %%mm3 \n\t"
"punpcklbw %%mm4, %%mm4 \n\t"
"punpckhbw %%mm5, %%mm5 \n\t"
"punpcklbw %%mm6, %%mm6 \n\t"
"punpckhbw %%mm7, %%mm7 \n\t"
MOVNTQ" %%mm0, %0 \n\t"
MOVNTQ" %%mm1, 8%0 \n\t"
MOVNTQ" %%mm2, 16%0 \n\t"
MOVNTQ" %%mm3, 24%0 \n\t"
MOVNTQ" %%mm4, 32%0 \n\t"
MOVNTQ" %%mm5, 40%0 \n\t"
MOVNTQ" %%mm6, 48%0 \n\t"
MOVNTQ" %%mm7, 56%0"
:"=m"(d[2*x])
:"m"(s2[x])
:"memory");
}
for (;x<w;x++) d[2*x]=d[2*x+1]=s2[x];
}
__asm__(
EMMS" \n\t"
SFENCE" \n\t"
::: "memory"
);
}
| {
"code": [
" x86_reg y;",
" int x,w,h;",
" PREFETCH\" 32%1 \\n\\t\"",
" \"movq %1, %%mm0 \\n\\t\"",
" \"movq 8%1, %%mm2 \\n\\t\"",
" \"movq 16%1, %%mm4 \\n\\t\"",
" \"movq 24%1, %%mm6 \\n\\t\"",
" MOVNTQ\" %%mm0, %0 \\n\\t\"",
" MOVNTQ\" %%mm1, 8%0 \\n\\t\"",
" MOVNTQ\" %%mm2, 16%0 \\n\\t\"",
" MOVNTQ\" %%mm3, 24%0 \\n\\t\"",
" MOVNTQ\" %%mm4, 32%0 \\n\\t\"",
" MOVNTQ\" %%mm5, 40%0 \\n\\t\"",
" MOVNTQ\" %%mm6, 48%0 \\n\\t\"",
" MOVNTQ\" %%mm7, 56%0\"",
" :\"=m\"(d[2*x])",
" :\"m\"(s1[x])",
" PREFETCH\" 32%1 \\n\\t\"",
" \"movq %1, %%mm0 \\n\\t\"",
" \"movq 8%1, %%mm2 \\n\\t\"",
" \"movq 16%1, %%mm4 \\n\\t\"",
" \"movq 24%1, %%mm6 \\n\\t\"",
" MOVNTQ\" %%mm0, %0 \\n\\t\"",
" MOVNTQ\" %%mm1, 8%0 \\n\\t\"",
" MOVNTQ\" %%mm2, 16%0 \\n\\t\"",
" MOVNTQ\" %%mm3, 24%0 \\n\\t\"",
" MOVNTQ\" %%mm4, 32%0 \\n\\t\"",
" MOVNTQ\" %%mm5, 40%0 \\n\\t\"",
" MOVNTQ\" %%mm6, 48%0 \\n\\t\"",
" MOVNTQ\" %%mm7, 56%0\"",
" :\"=m\"(d[2*x])",
" :\"m\"(s2[x])"
],
"line_no": [
13,
15,
39,
41,
43,
45,
47,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91,
39,
41,
43,
45,
47,
73,
75,
77,
79,
81,
83,
85,
87,
89,
165
]
} | static inline void FUNC_0(vu9_to_vu12)(const uint8_t *src1, const uint8_t *src2,
uint8_t *dst1, uint8_t *dst2,
int width, int height,
int srcStride1, int srcStride2,
int dstStride1, int dstStride2)
{
x86_reg y;
int VAR_0,VAR_1,VAR_2;
VAR_1=width/2; VAR_2=height/2;
__asm__ volatile(
PREFETCH" %0 \n\t"
PREFETCH" %1 \n\t"
::"m"(*(src1+srcStride1)),"m"(*(src2+srcStride2)):"memory");
for (y=0;y<VAR_2;y++) {
const uint8_t* s1=src1+srcStride1*(y>>1);
uint8_t* d=dst1+dstStride1*y;
VAR_0=0;
for (;VAR_0<VAR_1-31;VAR_0+=32) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq 8%1, %%mm2 \n\t"
"movq 16%1, %%mm4 \n\t"
"movq 24%1, %%mm6 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"movq %%mm4, %%mm5 \n\t"
"movq %%mm6, %%mm7 \n\t"
"punpcklbw %%mm0, %%mm0 \n\t"
"punpckhbw %%mm1, %%mm1 \n\t"
"punpcklbw %%mm2, %%mm2 \n\t"
"punpckhbw %%mm3, %%mm3 \n\t"
"punpcklbw %%mm4, %%mm4 \n\t"
"punpckhbw %%mm5, %%mm5 \n\t"
"punpcklbw %%mm6, %%mm6 \n\t"
"punpckhbw %%mm7, %%mm7 \n\t"
MOVNTQ" %%mm0, %0 \n\t"
MOVNTQ" %%mm1, 8%0 \n\t"
MOVNTQ" %%mm2, 16%0 \n\t"
MOVNTQ" %%mm3, 24%0 \n\t"
MOVNTQ" %%mm4, 32%0 \n\t"
MOVNTQ" %%mm5, 40%0 \n\t"
MOVNTQ" %%mm6, 48%0 \n\t"
MOVNTQ" %%mm7, 56%0"
:"=m"(d[2*VAR_0])
:"m"(s1[VAR_0])
:"memory");
}
for (;VAR_0<VAR_1;VAR_0++) d[2*VAR_0]=d[2*VAR_0+1]=s1[VAR_0];
}
for (y=0;y<VAR_2;y++) {
const uint8_t* s2=src2+srcStride2*(y>>1);
uint8_t* d=dst2+dstStride2*y;
VAR_0=0;
for (;VAR_0<VAR_1-31;VAR_0+=32) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq 8%1, %%mm2 \n\t"
"movq 16%1, %%mm4 \n\t"
"movq 24%1, %%mm6 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"movq %%mm4, %%mm5 \n\t"
"movq %%mm6, %%mm7 \n\t"
"punpcklbw %%mm0, %%mm0 \n\t"
"punpckhbw %%mm1, %%mm1 \n\t"
"punpcklbw %%mm2, %%mm2 \n\t"
"punpckhbw %%mm3, %%mm3 \n\t"
"punpcklbw %%mm4, %%mm4 \n\t"
"punpckhbw %%mm5, %%mm5 \n\t"
"punpcklbw %%mm6, %%mm6 \n\t"
"punpckhbw %%mm7, %%mm7 \n\t"
MOVNTQ" %%mm0, %0 \n\t"
MOVNTQ" %%mm1, 8%0 \n\t"
MOVNTQ" %%mm2, 16%0 \n\t"
MOVNTQ" %%mm3, 24%0 \n\t"
MOVNTQ" %%mm4, 32%0 \n\t"
MOVNTQ" %%mm5, 40%0 \n\t"
MOVNTQ" %%mm6, 48%0 \n\t"
MOVNTQ" %%mm7, 56%0"
:"=m"(d[2*VAR_0])
:"m"(s2[VAR_0])
:"memory");
}
for (;VAR_0<VAR_1;VAR_0++) d[2*VAR_0]=d[2*VAR_0+1]=s2[VAR_0];
}
__asm__(
EMMS" \n\t"
SFENCE" \n\t"
::: "memory"
);
}
| [
"static inline void FUNC_0(vu9_to_vu12)(const uint8_t *src1, const uint8_t *src2,\nuint8_t *dst1, uint8_t *dst2,\nint width, int height,\nint srcStride1, int srcStride2,\nint dstStride1, int dstStride2)\n{",
"x86_reg y;",
"int VAR_0,VAR_1,VAR_2;",
"VAR_1=width/2; VAR_2=height/2;",
"__asm__ volatile(\nPREFETCH\" %0 \\n\\t\"\nPREFETCH\" %1 \\n\\t\"\n::\"m\"(*(src1+srcStride1)),\"m\"(*(src2+srcStride2)):\"memory\");",
"for (y=0;y<VAR_2;y++) {",
"const uint8_t* s1=src1+srcStride1*(y>>1);",
"uint8_t* d=dst1+dstStride1*y;",
"VAR_0=0;",
"for (;VAR_0<VAR_1-31;VAR_0+=32) {",
"__asm__ volatile(\nPREFETCH\" 32%1 \\n\\t\"\n\"movq %1, %%mm0 \\n\\t\"\n\"movq 8%1, %%mm2 \\n\\t\"\n\"movq 16%1, %%mm4 \\n\\t\"\n\"movq 24%1, %%mm6 \\n\\t\"\n\"movq %%mm0, %%mm1 \\n\\t\"\n\"movq %%mm2, %%mm3 \\n\\t\"\n\"movq %%mm4, %%mm5 \\n\\t\"\n\"movq %%mm6, %%mm7 \\n\\t\"\n\"punpcklbw %%mm0, %%mm0 \\n\\t\"\n\"punpckhbw %%mm1, %%mm1 \\n\\t\"\n\"punpcklbw %%mm2, %%mm2 \\n\\t\"\n\"punpckhbw %%mm3, %%mm3 \\n\\t\"\n\"punpcklbw %%mm4, %%mm4 \\n\\t\"\n\"punpckhbw %%mm5, %%mm5 \\n\\t\"\n\"punpcklbw %%mm6, %%mm6 \\n\\t\"\n\"punpckhbw %%mm7, %%mm7 \\n\\t\"\nMOVNTQ\" %%mm0, %0 \\n\\t\"\nMOVNTQ\" %%mm1, 8%0 \\n\\t\"\nMOVNTQ\" %%mm2, 16%0 \\n\\t\"\nMOVNTQ\" %%mm3, 24%0 \\n\\t\"\nMOVNTQ\" %%mm4, 32%0 \\n\\t\"\nMOVNTQ\" %%mm5, 40%0 \\n\\t\"\nMOVNTQ\" %%mm6, 48%0 \\n\\t\"\nMOVNTQ\" %%mm7, 56%0\"\n:\"=m\"(d[2*VAR_0])\n:\"m\"(s1[VAR_0])\n:\"memory\");",
"}",
"for (;VAR_0<VAR_1;VAR_0++) d[2*VAR_0]=d[2*VAR_0+1]=s1[VAR_0];",
"}",
"for (y=0;y<VAR_2;y++) {",
"const uint8_t* s2=src2+srcStride2*(y>>1);",
"uint8_t* d=dst2+dstStride2*y;",
"VAR_0=0;",
"for (;VAR_0<VAR_1-31;VAR_0+=32) {",
"__asm__ volatile(\nPREFETCH\" 32%1 \\n\\t\"\n\"movq %1, %%mm0 \\n\\t\"\n\"movq 8%1, %%mm2 \\n\\t\"\n\"movq 16%1, %%mm4 \\n\\t\"\n\"movq 24%1, %%mm6 \\n\\t\"\n\"movq %%mm0, %%mm1 \\n\\t\"\n\"movq %%mm2, %%mm3 \\n\\t\"\n\"movq %%mm4, %%mm5 \\n\\t\"\n\"movq %%mm6, %%mm7 \\n\\t\"\n\"punpcklbw %%mm0, %%mm0 \\n\\t\"\n\"punpckhbw %%mm1, %%mm1 \\n\\t\"\n\"punpcklbw %%mm2, %%mm2 \\n\\t\"\n\"punpckhbw %%mm3, %%mm3 \\n\\t\"\n\"punpcklbw %%mm4, %%mm4 \\n\\t\"\n\"punpckhbw %%mm5, %%mm5 \\n\\t\"\n\"punpcklbw %%mm6, %%mm6 \\n\\t\"\n\"punpckhbw %%mm7, %%mm7 \\n\\t\"\nMOVNTQ\" %%mm0, %0 \\n\\t\"\nMOVNTQ\" %%mm1, 8%0 \\n\\t\"\nMOVNTQ\" %%mm2, 16%0 \\n\\t\"\nMOVNTQ\" %%mm3, 24%0 \\n\\t\"\nMOVNTQ\" %%mm4, 32%0 \\n\\t\"\nMOVNTQ\" %%mm5, 40%0 \\n\\t\"\nMOVNTQ\" %%mm6, 48%0 \\n\\t\"\nMOVNTQ\" %%mm7, 56%0\"\n:\"=m\"(d[2*VAR_0])\n:\"m\"(s2[VAR_0])\n:\"memory\");",
"}",
"for (;VAR_0<VAR_1;VAR_0++) d[2*VAR_0]=d[2*VAR_0+1]=s2[VAR_0];",
"}",
"__asm__(\nEMMS\" \\n\\t\"\nSFENCE\" \\n\\t\"\n::: \"memory\"\n);",
"}"
] | [
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15
],
[
17
],
[
19,
21,
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91,
93
],
[
95
],
[
97
],
[
99
],
[
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
]
] |
3,282 | void rgb16tobgr24(const uint8_t *src, uint8_t *dst, unsigned int src_size)
{
const uint16_t *end;
uint8_t *d = (uint8_t *)dst;
const uint16_t *s = (const uint16_t *)src;
end = s + src_size/2;
while(s < end)
{
register uint16_t bgr;
bgr = *s++;
*d++ = (bgr&0xF800)>>8;
*d++ = (bgr&0x7E0)>>3;
*d++ = (bgr&0x1F)<<3;
}
}
| true | FFmpeg | 7f526efd17973ec6d2204f7a47b6923e2be31363 | void rgb16tobgr24(const uint8_t *src, uint8_t *dst, unsigned int src_size)
{
const uint16_t *end;
uint8_t *d = (uint8_t *)dst;
const uint16_t *s = (const uint16_t *)src;
end = s + src_size/2;
while(s < end)
{
register uint16_t bgr;
bgr = *s++;
*d++ = (bgr&0xF800)>>8;
*d++ = (bgr&0x7E0)>>3;
*d++ = (bgr&0x1F)<<3;
}
}
| {
"code": [
"void rgb16tobgr24(const uint8_t *src, uint8_t *dst, unsigned int src_size)"
],
"line_no": [
1
]
} | void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, unsigned int VAR_2)
{
const uint16_t *VAR_3;
uint8_t *d = (uint8_t *)VAR_1;
const uint16_t *VAR_4 = (const uint16_t *)VAR_0;
VAR_3 = VAR_4 + VAR_2/2;
while(VAR_4 < VAR_3)
{
register uint16_t VAR_5;
VAR_5 = *VAR_4++;
*d++ = (VAR_5&0xF800)>>8;
*d++ = (VAR_5&0x7E0)>>3;
*d++ = (VAR_5&0x1F)<<3;
}
}
| [
"void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, unsigned int VAR_2)\n{",
"const uint16_t *VAR_3;",
"uint8_t *d = (uint8_t *)VAR_1;",
"const uint16_t *VAR_4 = (const uint16_t *)VAR_0;",
"VAR_3 = VAR_4 + VAR_2/2;",
"while(VAR_4 < VAR_3)\n{",
"register uint16_t VAR_5;",
"VAR_5 = *VAR_4++;",
"*d++ = (VAR_5&0xF800)>>8;",
"*d++ = (VAR_5&0x7E0)>>3;",
"*d++ = (VAR_5&0x1F)<<3;",
"}",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
3,283 | static int dyn_buf_write(void *opaque, uint8_t *buf, int buf_size)
{
DynBuffer *d = opaque;
int new_size, new_allocated_size;
/* reallocate buffer if needed */
new_size = d->pos + buf_size;
new_allocated_size = d->allocated_size;
if(new_size < d->pos || new_size > INT_MAX/2)
return -1;
while (new_size > new_allocated_size) {
if (!new_allocated_size)
new_allocated_size = new_size;
else
new_allocated_size += new_allocated_size / 2 + 1;
}
if (new_allocated_size > d->allocated_size) {
d->buffer = av_realloc(d->buffer, new_allocated_size);
if(d->buffer == NULL)
return -1234;
d->allocated_size = new_allocated_size;
}
memcpy(d->buffer + d->pos, buf, buf_size);
d->pos = new_size;
if (d->pos > d->size)
d->size = d->pos;
return buf_size;
}
| true | FFmpeg | 6bc03a695bc4c1ecd212263c4a3c9cf638d025e0 | static int dyn_buf_write(void *opaque, uint8_t *buf, int buf_size)
{
DynBuffer *d = opaque;
int new_size, new_allocated_size;
new_size = d->pos + buf_size;
new_allocated_size = d->allocated_size;
if(new_size < d->pos || new_size > INT_MAX/2)
return -1;
while (new_size > new_allocated_size) {
if (!new_allocated_size)
new_allocated_size = new_size;
else
new_allocated_size += new_allocated_size / 2 + 1;
}
if (new_allocated_size > d->allocated_size) {
d->buffer = av_realloc(d->buffer, new_allocated_size);
if(d->buffer == NULL)
return -1234;
d->allocated_size = new_allocated_size;
}
memcpy(d->buffer + d->pos, buf, buf_size);
d->pos = new_size;
if (d->pos > d->size)
d->size = d->pos;
return buf_size;
}
| {
"code": [
" int new_size, new_allocated_size;"
],
"line_no": [
7
]
} | static int FUNC_0(void *VAR_0, uint8_t *VAR_1, int VAR_2)
{
DynBuffer *d = VAR_0;
int VAR_3, VAR_4;
VAR_3 = d->pos + VAR_2;
VAR_4 = d->allocated_size;
if(VAR_3 < d->pos || VAR_3 > INT_MAX/2)
return -1;
while (VAR_3 > VAR_4) {
if (!VAR_4)
VAR_4 = VAR_3;
else
VAR_4 += VAR_4 / 2 + 1;
}
if (VAR_4 > d->allocated_size) {
d->buffer = av_realloc(d->buffer, VAR_4);
if(d->buffer == NULL)
return -1234;
d->allocated_size = VAR_4;
}
memcpy(d->buffer + d->pos, VAR_1, VAR_2);
d->pos = VAR_3;
if (d->pos > d->size)
d->size = d->pos;
return VAR_2;
}
| [
"static int FUNC_0(void *VAR_0, uint8_t *VAR_1, int VAR_2)\n{",
"DynBuffer *d = VAR_0;",
"int VAR_3, VAR_4;",
"VAR_3 = d->pos + VAR_2;",
"VAR_4 = d->allocated_size;",
"if(VAR_3 < d->pos || VAR_3 > INT_MAX/2)\nreturn -1;",
"while (VAR_3 > VAR_4) {",
"if (!VAR_4)\nVAR_4 = VAR_3;",
"else\nVAR_4 += VAR_4 / 2 + 1;",
"}",
"if (VAR_4 > d->allocated_size) {",
"d->buffer = av_realloc(d->buffer, VAR_4);",
"if(d->buffer == NULL)\nreturn -1234;",
"d->allocated_size = VAR_4;",
"}",
"memcpy(d->buffer + d->pos, VAR_1, VAR_2);",
"d->pos = VAR_3;",
"if (d->pos > d->size)\nd->size = d->pos;",
"return VAR_2;",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
13
],
[
15
],
[
17,
19
],
[
21
],
[
23,
25
],
[
27,
29
],
[
31
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
]
] |
3,285 | static void vfio_msi_enable(VFIOPCIDevice *vdev)
{
int ret, i;
vfio_disable_interrupts(vdev);
vdev->nr_vectors = msi_nr_vectors_allocated(&vdev->pdev);
retry:
vdev->msi_vectors = g_malloc0(vdev->nr_vectors * sizeof(VFIOMSIVector));
for (i = 0; i < vdev->nr_vectors; i++) {
VFIOMSIVector *vector = &vdev->msi_vectors[i];
MSIMessage msg = msi_get_message(&vdev->pdev, i);
vector->vdev = vdev;
vector->virq = -1;
vector->use = true;
if (event_notifier_init(&vector->interrupt, 0)) {
error_report("vfio: Error: event_notifier_init failed");
}
qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt),
vfio_msi_interrupt, NULL, vector);
/*
* Attempt to enable route through KVM irqchip,
* default to userspace handling if unavailable.
*/
vfio_add_kvm_msi_virq(vdev, vector, &msg, false);
}
/* Set interrupt type prior to possible interrupts */
vdev->interrupt = VFIO_INT_MSI;
ret = vfio_enable_vectors(vdev, false);
if (ret) {
if (ret < 0) {
error_report("vfio: Error: Failed to setup MSI fds: %m");
} else if (ret != vdev->nr_vectors) {
error_report("vfio: Error: Failed to enable %d "
"MSI vectors, retry with %d", vdev->nr_vectors, ret);
}
for (i = 0; i < vdev->nr_vectors; i++) {
VFIOMSIVector *vector = &vdev->msi_vectors[i];
if (vector->virq >= 0) {
vfio_remove_kvm_msi_virq(vector);
}
qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt),
NULL, NULL, NULL);
event_notifier_cleanup(&vector->interrupt);
}
g_free(vdev->msi_vectors);
if (ret > 0 && ret != vdev->nr_vectors) {
vdev->nr_vectors = ret;
goto retry;
}
vdev->nr_vectors = 0;
/*
* Failing to setup MSI doesn't really fall within any specification.
* Let's try leaving interrupts disabled and hope the guest figures
* out to fall back to INTx for this device.
*/
error_report("vfio: Error: Failed to enable MSI");
vdev->interrupt = VFIO_INT_NONE;
return;
}
trace_vfio_msi_enable(vdev->vbasedev.name, vdev->nr_vectors);
}
| true | qemu | bdd81addf4033ce26e6cd180b060f63095f3ded9 | static void vfio_msi_enable(VFIOPCIDevice *vdev)
{
int ret, i;
vfio_disable_interrupts(vdev);
vdev->nr_vectors = msi_nr_vectors_allocated(&vdev->pdev);
retry:
vdev->msi_vectors = g_malloc0(vdev->nr_vectors * sizeof(VFIOMSIVector));
for (i = 0; i < vdev->nr_vectors; i++) {
VFIOMSIVector *vector = &vdev->msi_vectors[i];
MSIMessage msg = msi_get_message(&vdev->pdev, i);
vector->vdev = vdev;
vector->virq = -1;
vector->use = true;
if (event_notifier_init(&vector->interrupt, 0)) {
error_report("vfio: Error: event_notifier_init failed");
}
qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt),
vfio_msi_interrupt, NULL, vector);
vfio_add_kvm_msi_virq(vdev, vector, &msg, false);
}
vdev->interrupt = VFIO_INT_MSI;
ret = vfio_enable_vectors(vdev, false);
if (ret) {
if (ret < 0) {
error_report("vfio: Error: Failed to setup MSI fds: %m");
} else if (ret != vdev->nr_vectors) {
error_report("vfio: Error: Failed to enable %d "
"MSI vectors, retry with %d", vdev->nr_vectors, ret);
}
for (i = 0; i < vdev->nr_vectors; i++) {
VFIOMSIVector *vector = &vdev->msi_vectors[i];
if (vector->virq >= 0) {
vfio_remove_kvm_msi_virq(vector);
}
qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt),
NULL, NULL, NULL);
event_notifier_cleanup(&vector->interrupt);
}
g_free(vdev->msi_vectors);
if (ret > 0 && ret != vdev->nr_vectors) {
vdev->nr_vectors = ret;
goto retry;
}
vdev->nr_vectors = 0;
error_report("vfio: Error: Failed to enable MSI");
vdev->interrupt = VFIO_INT_NONE;
return;
}
trace_vfio_msi_enable(vdev->vbasedev.name, vdev->nr_vectors);
}
| {
"code": [
" vdev->msi_vectors = g_malloc0(vdev->nr_vectors * sizeof(VFIOMSIVector));"
],
"line_no": [
17
]
} | static void FUNC_0(VFIOPCIDevice *VAR_0)
{
int VAR_1, VAR_2;
vfio_disable_interrupts(VAR_0);
VAR_0->nr_vectors = msi_nr_vectors_allocated(&VAR_0->pdev);
retry:
VAR_0->msi_vectors = g_malloc0(VAR_0->nr_vectors * sizeof(VFIOMSIVector));
for (VAR_2 = 0; VAR_2 < VAR_0->nr_vectors; VAR_2++) {
VFIOMSIVector *vector = &VAR_0->msi_vectors[VAR_2];
MSIMessage msg = msi_get_message(&VAR_0->pdev, VAR_2);
vector->VAR_0 = VAR_0;
vector->virq = -1;
vector->use = true;
if (event_notifier_init(&vector->interrupt, 0)) {
error_report("vfio: Error: event_notifier_init failed");
}
qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt),
vfio_msi_interrupt, NULL, vector);
vfio_add_kvm_msi_virq(VAR_0, vector, &msg, false);
}
VAR_0->interrupt = VFIO_INT_MSI;
VAR_1 = vfio_enable_vectors(VAR_0, false);
if (VAR_1) {
if (VAR_1 < 0) {
error_report("vfio: Error: Failed to setup MSI fds: %m");
} else if (VAR_1 != VAR_0->nr_vectors) {
error_report("vfio: Error: Failed to enable %d "
"MSI vectors, retry with %d", VAR_0->nr_vectors, VAR_1);
}
for (VAR_2 = 0; VAR_2 < VAR_0->nr_vectors; VAR_2++) {
VFIOMSIVector *vector = &VAR_0->msi_vectors[VAR_2];
if (vector->virq >= 0) {
vfio_remove_kvm_msi_virq(vector);
}
qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt),
NULL, NULL, NULL);
event_notifier_cleanup(&vector->interrupt);
}
g_free(VAR_0->msi_vectors);
if (VAR_1 > 0 && VAR_1 != VAR_0->nr_vectors) {
VAR_0->nr_vectors = VAR_1;
goto retry;
}
VAR_0->nr_vectors = 0;
error_report("vfio: Error: Failed to enable MSI");
VAR_0->interrupt = VFIO_INT_NONE;
return;
}
trace_vfio_msi_enable(VAR_0->vbasedev.name, VAR_0->nr_vectors);
}
| [
"static void FUNC_0(VFIOPCIDevice *VAR_0)\n{",
"int VAR_1, VAR_2;",
"vfio_disable_interrupts(VAR_0);",
"VAR_0->nr_vectors = msi_nr_vectors_allocated(&VAR_0->pdev);",
"retry:\nVAR_0->msi_vectors = g_malloc0(VAR_0->nr_vectors * sizeof(VFIOMSIVector));",
"for (VAR_2 = 0; VAR_2 < VAR_0->nr_vectors; VAR_2++) {",
"VFIOMSIVector *vector = &VAR_0->msi_vectors[VAR_2];",
"MSIMessage msg = msi_get_message(&VAR_0->pdev, VAR_2);",
"vector->VAR_0 = VAR_0;",
"vector->virq = -1;",
"vector->use = true;",
"if (event_notifier_init(&vector->interrupt, 0)) {",
"error_report(\"vfio: Error: event_notifier_init failed\");",
"}",
"qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt),\nvfio_msi_interrupt, NULL, vector);",
"vfio_add_kvm_msi_virq(VAR_0, vector, &msg, false);",
"}",
"VAR_0->interrupt = VFIO_INT_MSI;",
"VAR_1 = vfio_enable_vectors(VAR_0, false);",
"if (VAR_1) {",
"if (VAR_1 < 0) {",
"error_report(\"vfio: Error: Failed to setup MSI fds: %m\");",
"} else if (VAR_1 != VAR_0->nr_vectors) {",
"error_report(\"vfio: Error: Failed to enable %d \"\n\"MSI vectors, retry with %d\", VAR_0->nr_vectors, VAR_1);",
"}",
"for (VAR_2 = 0; VAR_2 < VAR_0->nr_vectors; VAR_2++) {",
"VFIOMSIVector *vector = &VAR_0->msi_vectors[VAR_2];",
"if (vector->virq >= 0) {",
"vfio_remove_kvm_msi_virq(vector);",
"}",
"qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt),\nNULL, NULL, NULL);",
"event_notifier_cleanup(&vector->interrupt);",
"}",
"g_free(VAR_0->msi_vectors);",
"if (VAR_1 > 0 && VAR_1 != VAR_0->nr_vectors) {",
"VAR_0->nr_vectors = VAR_1;",
"goto retry;",
"}",
"VAR_0->nr_vectors = 0;",
"error_report(\"vfio: Error: Failed to enable MSI\");",
"VAR_0->interrupt = VFIO_INT_NONE;",
"return;",
"}",
"trace_vfio_msi_enable(VAR_0->vbasedev.name, VAR_0->nr_vectors);",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15,
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
45,
47
],
[
59
],
[
61
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81,
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99,
101
],
[
103
],
[
105
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
135
],
[
137
],
[
141
],
[
143
],
[
147
],
[
149
]
] |
3,286 | static inline void RENAME(rgb32to24)(const uint8_t *src,uint8_t *dst,unsigned src_size)
{
uint8_t *dest = dst;
const uint8_t *s = src;
const uint8_t *end;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
end = s + src_size;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*s):"memory");
mm_end = end - 31;
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movq %1, %%mm0\n\t"
"movq 8%1, %%mm1\n\t"
"movq 16%1, %%mm4\n\t"
"movq 24%1, %%mm5\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm1, %%mm3\n\t"
"movq %%mm4, %%mm6\n\t"
"movq %%mm5, %%mm7\n\t"
"psrlq $8, %%mm2\n\t"
"psrlq $8, %%mm3\n\t"
"psrlq $8, %%mm6\n\t"
"psrlq $8, %%mm7\n\t"
"pand %2, %%mm0\n\t"
"pand %2, %%mm1\n\t"
"pand %2, %%mm4\n\t"
"pand %2, %%mm5\n\t"
"pand %3, %%mm2\n\t"
"pand %3, %%mm3\n\t"
"pand %3, %%mm6\n\t"
"pand %3, %%mm7\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm3, %%mm1\n\t"
"por %%mm6, %%mm4\n\t"
"por %%mm7, %%mm5\n\t"
"movq %%mm1, %%mm2\n\t"
"movq %%mm4, %%mm3\n\t"
"psllq $48, %%mm2\n\t"
"psllq $32, %%mm3\n\t"
"pand %4, %%mm2\n\t"
"pand %5, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"psrlq $16, %%mm1\n\t"
"psrlq $32, %%mm4\n\t"
"psllq $16, %%mm5\n\t"
"por %%mm3, %%mm1\n\t"
"pand %6, %%mm5\n\t"
"por %%mm5, %%mm4\n\t"
MOVNTQ" %%mm0, %0\n\t"
MOVNTQ" %%mm1, 8%0\n\t"
MOVNTQ" %%mm4, 16%0"
:"=m"(*dest)
:"m"(*s),"m"(mask24l),
"m"(mask24h),"m"(mask24hh),"m"(mask24hhh),"m"(mask24hhhh)
:"memory");
dest += 24;
s += 32;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
#ifdef WORDS_BIGENDIAN
s++;
*dest++ = *s++;
*dest++ = *s++;
*dest++ = *s++;
#else
*dest++ = *s++;
*dest++ = *s++;
*dest++ = *s++;
s++;
#endif
}
}
| true | FFmpeg | 7f526efd17973ec6d2204f7a47b6923e2be31363 | static inline void RENAME(rgb32to24)(const uint8_t *src,uint8_t *dst,unsigned src_size)
{
uint8_t *dest = dst;
const uint8_t *s = src;
const uint8_t *end;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
end = s + src_size;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*s):"memory");
mm_end = end - 31;
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movq %1, %%mm0\n\t"
"movq 8%1, %%mm1\n\t"
"movq 16%1, %%mm4\n\t"
"movq 24%1, %%mm5\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm1, %%mm3\n\t"
"movq %%mm4, %%mm6\n\t"
"movq %%mm5, %%mm7\n\t"
"psrlq $8, %%mm2\n\t"
"psrlq $8, %%mm3\n\t"
"psrlq $8, %%mm6\n\t"
"psrlq $8, %%mm7\n\t"
"pand %2, %%mm0\n\t"
"pand %2, %%mm1\n\t"
"pand %2, %%mm4\n\t"
"pand %2, %%mm5\n\t"
"pand %3, %%mm2\n\t"
"pand %3, %%mm3\n\t"
"pand %3, %%mm6\n\t"
"pand %3, %%mm7\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm3, %%mm1\n\t"
"por %%mm6, %%mm4\n\t"
"por %%mm7, %%mm5\n\t"
"movq %%mm1, %%mm2\n\t"
"movq %%mm4, %%mm3\n\t"
"psllq $48, %%mm2\n\t"
"psllq $32, %%mm3\n\t"
"pand %4, %%mm2\n\t"
"pand %5, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"psrlq $16, %%mm1\n\t"
"psrlq $32, %%mm4\n\t"
"psllq $16, %%mm5\n\t"
"por %%mm3, %%mm1\n\t"
"pand %6, %%mm5\n\t"
"por %%mm5, %%mm4\n\t"
MOVNTQ" %%mm0, %0\n\t"
MOVNTQ" %%mm1, 8%0\n\t"
MOVNTQ" %%mm4, 16%0"
:"=m"(*dest)
:"m"(*s),"m"(mask24l),
"m"(mask24h),"m"(mask24hh),"m"(mask24hhh),"m"(mask24hhhh)
:"memory");
dest += 24;
s += 32;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
#ifdef WORDS_BIGENDIAN
s++;
*dest++ = *s++;
*dest++ = *s++;
*dest++ = *s++;
#else
*dest++ = *s++;
*dest++ = *s++;
*dest++ = *s++;
s++;
#endif
}
}
| {
"code": [
"static inline void RENAME(rgb32to24)(const uint8_t *src,uint8_t *dst,unsigned src_size)"
],
"line_no": [
1
]
} | static inline void FUNC_0(rgb32to24)(const uint8_t *src,uint8_t *dst,unsigned src_size)
{
uint8_t *dest = dst;
const uint8_t *VAR_0 = src;
const uint8_t *VAR_1;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
VAR_1 = VAR_0 + src_size;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*VAR_0):"memory");
mm_end = VAR_1 - 31;
while(VAR_0 < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movq %1, %%mm0\n\t"
"movq 8%1, %%mm1\n\t"
"movq 16%1, %%mm4\n\t"
"movq 24%1, %%mm5\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm1, %%mm3\n\t"
"movq %%mm4, %%mm6\n\t"
"movq %%mm5, %%mm7\n\t"
"psrlq $8, %%mm2\n\t"
"psrlq $8, %%mm3\n\t"
"psrlq $8, %%mm6\n\t"
"psrlq $8, %%mm7\n\t"
"pand %2, %%mm0\n\t"
"pand %2, %%mm1\n\t"
"pand %2, %%mm4\n\t"
"pand %2, %%mm5\n\t"
"pand %3, %%mm2\n\t"
"pand %3, %%mm3\n\t"
"pand %3, %%mm6\n\t"
"pand %3, %%mm7\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm3, %%mm1\n\t"
"por %%mm6, %%mm4\n\t"
"por %%mm7, %%mm5\n\t"
"movq %%mm1, %%mm2\n\t"
"movq %%mm4, %%mm3\n\t"
"psllq $48, %%mm2\n\t"
"psllq $32, %%mm3\n\t"
"pand %4, %%mm2\n\t"
"pand %5, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"psrlq $16, %%mm1\n\t"
"psrlq $32, %%mm4\n\t"
"psllq $16, %%mm5\n\t"
"por %%mm3, %%mm1\n\t"
"pand %6, %%mm5\n\t"
"por %%mm5, %%mm4\n\t"
MOVNTQ" %%mm0, %0\n\t"
MOVNTQ" %%mm1, 8%0\n\t"
MOVNTQ" %%mm4, 16%0"
:"=m"(*dest)
:"m"(*VAR_0),"m"(mask24l),
"m"(mask24h),"m"(mask24hh),"m"(mask24hhh),"m"(mask24hhhh)
:"memory");
dest += 24;
VAR_0 += 32;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(VAR_0 < VAR_1)
{
#ifdef WORDS_BIGENDIAN
VAR_0++;
*dest++ = *VAR_0++;
*dest++ = *VAR_0++;
*dest++ = *VAR_0++;
#else
*dest++ = *VAR_0++;
*dest++ = *VAR_0++;
*dest++ = *VAR_0++;
VAR_0++;
#endif
}
}
| [
"static inline void FUNC_0(rgb32to24)(const uint8_t *src,uint8_t *dst,unsigned src_size)\n{",
"uint8_t *dest = dst;",
"const uint8_t *VAR_0 = src;",
"const uint8_t *VAR_1;",
"#ifdef HAVE_MMX\nconst uint8_t *mm_end;",
"#endif\nVAR_1 = VAR_0 + src_size;",
"#ifdef HAVE_MMX\n__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*VAR_0):\"memory\");",
"mm_end = VAR_1 - 31;",
"while(VAR_0 < mm_end)\n{",
"__asm __volatile(\nPREFETCH\"\t32%1\\n\\t\"\n\"movq\t%1, %%mm0\\n\\t\"\n\"movq\t8%1, %%mm1\\n\\t\"\n\"movq\t16%1, %%mm4\\n\\t\"\n\"movq\t24%1, %%mm5\\n\\t\"\n\"movq\t%%mm0, %%mm2\\n\\t\"\n\"movq\t%%mm1, %%mm3\\n\\t\"\n\"movq\t%%mm4, %%mm6\\n\\t\"\n\"movq\t%%mm5, %%mm7\\n\\t\"\n\"psrlq\t$8, %%mm2\\n\\t\"\n\"psrlq\t$8, %%mm3\\n\\t\"\n\"psrlq\t$8, %%mm6\\n\\t\"\n\"psrlq\t$8, %%mm7\\n\\t\"\n\"pand\t%2, %%mm0\\n\\t\"\n\"pand\t%2, %%mm1\\n\\t\"\n\"pand\t%2, %%mm4\\n\\t\"\n\"pand\t%2, %%mm5\\n\\t\"\n\"pand\t%3, %%mm2\\n\\t\"\n\"pand\t%3, %%mm3\\n\\t\"\n\"pand\t%3, %%mm6\\n\\t\"\n\"pand\t%3, %%mm7\\n\\t\"\n\"por\t%%mm2, %%mm0\\n\\t\"\n\"por\t%%mm3, %%mm1\\n\\t\"\n\"por\t%%mm6, %%mm4\\n\\t\"\n\"por\t%%mm7, %%mm5\\n\\t\"\n\"movq\t%%mm1, %%mm2\\n\\t\"\n\"movq\t%%mm4, %%mm3\\n\\t\"\n\"psllq\t$48, %%mm2\\n\\t\"\n\"psllq\t$32, %%mm3\\n\\t\"\n\"pand\t%4, %%mm2\\n\\t\"\n\"pand\t%5, %%mm3\\n\\t\"\n\"por\t%%mm2, %%mm0\\n\\t\"\n\"psrlq\t$16, %%mm1\\n\\t\"\n\"psrlq\t$32, %%mm4\\n\\t\"\n\"psllq\t$16, %%mm5\\n\\t\"\n\"por\t%%mm3, %%mm1\\n\\t\"\n\"pand\t%6, %%mm5\\n\\t\"\n\"por\t%%mm5, %%mm4\\n\\t\"\nMOVNTQ\"\t%%mm0, %0\\n\\t\"\nMOVNTQ\"\t%%mm1, 8%0\\n\\t\"\nMOVNTQ\"\t%%mm4, 16%0\"\n:\"=m\"(*dest)\n:\"m\"(*VAR_0),\"m\"(mask24l),\n\"m\"(mask24h),\"m\"(mask24hh),\"m\"(mask24hhh),\"m\"(mask24hhhh)\n:\"memory\");",
"dest += 24;",
"VAR_0 += 32;",
"}",
"__asm __volatile(SFENCE:::\"memory\");",
"__asm __volatile(EMMS:::\"memory\");",
"#endif\nwhile(VAR_0 < VAR_1)\n{",
"#ifdef WORDS_BIGENDIAN\nVAR_0++;",
"*dest++ = *VAR_0++;",
"*dest++ = *VAR_0++;",
"*dest++ = *VAR_0++;",
"#else\n*dest++ = *VAR_0++;",
"*dest++ = *VAR_0++;",
"*dest++ = *VAR_0++;",
"VAR_0++;",
"#endif\n}",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13
],
[
15,
17
],
[
19,
21
],
[
23
],
[
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,
83,
85,
87,
89,
91,
93,
95,
97,
99,
101,
103,
105,
107,
111,
113,
115,
117,
119,
121,
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135,
137,
139
],
[
141,
143
],
[
145
],
[
147
],
[
149
],
[
151,
153
],
[
155
],
[
157
],
[
159
],
[
161,
163
],
[
165
]
] |
3,287 | static void scsi_remove_request(SCSIDiskReq *r)
{
qemu_free(r->iov.iov_base);
scsi_req_free(&r->req);
}
| true | qemu | f8a83245d9ec685bc6aa6173d6765fe03e20688f | static void scsi_remove_request(SCSIDiskReq *r)
{
qemu_free(r->iov.iov_base);
scsi_req_free(&r->req);
}
| {
"code": [
" qemu_free(r->iov.iov_base);"
],
"line_no": [
5
]
} | static void FUNC_0(SCSIDiskReq *VAR_0)
{
qemu_free(VAR_0->iov.iov_base);
scsi_req_free(&VAR_0->req);
}
| [
"static void FUNC_0(SCSIDiskReq *VAR_0)\n{",
"qemu_free(VAR_0->iov.iov_base);",
"scsi_req_free(&VAR_0->req);",
"}"
] | [
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
3,289 | static void uncouple_channels(AC3DecodeContext * ctx)
{
ac3_audio_block *ab = &ctx->audio_block;
int ch, sbnd, bin;
int index;
int16_t mantissa;
/* uncouple channels */
for (ch = 0; ch < ctx->bsi.nfchans; ch++)
if (ab->chincpl & (1 << ch))
for (sbnd = ab->cplbegf; sbnd < 3 + ab->cplendf; sbnd++)
for (bin = 0; bin < 12; bin++) {
index = sbnd * 12 + bin + 37;
ab->transform_coeffs[ch + 1][index] = ab->cplcoeffs[index] * ab->cplco[ch][sbnd] * ab->chcoeffs[ch];
/* generate dither if required */
if (!ab->bap[ch][index] && (ab->chincpl & (1 << ch)) && (ab->dithflag & (1 << ch))) {
mantissa = dither_int16(&ctx->state);
ab->transform_coeffs[ch + 1][index] = to_float(ab->dexps[ch][index], mantissa) * ab->chcoeffs[ch];
}
}
}
| false | FFmpeg | 486637af8ef29ec215e0e0b7ecd3b5470f0e04e5 | static void uncouple_channels(AC3DecodeContext * ctx)
{
ac3_audio_block *ab = &ctx->audio_block;
int ch, sbnd, bin;
int index;
int16_t mantissa;
for (ch = 0; ch < ctx->bsi.nfchans; ch++)
if (ab->chincpl & (1 << ch))
for (sbnd = ab->cplbegf; sbnd < 3 + ab->cplendf; sbnd++)
for (bin = 0; bin < 12; bin++) {
index = sbnd * 12 + bin + 37;
ab->transform_coeffs[ch + 1][index] = ab->cplcoeffs[index] * ab->cplco[ch][sbnd] * ab->chcoeffs[ch];
if (!ab->bap[ch][index] && (ab->chincpl & (1 << ch)) && (ab->dithflag & (1 << ch))) {
mantissa = dither_int16(&ctx->state);
ab->transform_coeffs[ch + 1][index] = to_float(ab->dexps[ch][index], mantissa) * ab->chcoeffs[ch];
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AC3DecodeContext * VAR_0)
{
ac3_audio_block *ab = &VAR_0->audio_block;
int VAR_1, VAR_2, VAR_3;
int VAR_4;
int16_t mantissa;
for (VAR_1 = 0; VAR_1 < VAR_0->bsi.nfchans; VAR_1++)
if (ab->chincpl & (1 << VAR_1))
for (VAR_2 = ab->cplbegf; VAR_2 < 3 + ab->cplendf; VAR_2++)
for (VAR_3 = 0; VAR_3 < 12; VAR_3++) {
VAR_4 = VAR_2 * 12 + VAR_3 + 37;
ab->transform_coeffs[VAR_1 + 1][VAR_4] = ab->cplcoeffs[VAR_4] * ab->cplco[VAR_1][VAR_2] * ab->chcoeffs[VAR_1];
if (!ab->bap[VAR_1][VAR_4] && (ab->chincpl & (1 << VAR_1)) && (ab->dithflag & (1 << VAR_1))) {
mantissa = dither_int16(&VAR_0->state);
ab->transform_coeffs[VAR_1 + 1][VAR_4] = to_float(ab->dexps[VAR_1][VAR_4], mantissa) * ab->chcoeffs[VAR_1];
}
}
}
| [
"static void FUNC_0(AC3DecodeContext * VAR_0)\n{",
"ac3_audio_block *ab = &VAR_0->audio_block;",
"int VAR_1, VAR_2, VAR_3;",
"int VAR_4;",
"int16_t mantissa;",
"for (VAR_1 = 0; VAR_1 < VAR_0->bsi.nfchans; VAR_1++)",
"if (ab->chincpl & (1 << VAR_1))\nfor (VAR_2 = ab->cplbegf; VAR_2 < 3 + ab->cplendf; VAR_2++)",
"for (VAR_3 = 0; VAR_3 < 12; VAR_3++) {",
"VAR_4 = VAR_2 * 12 + VAR_3 + 37;",
"ab->transform_coeffs[VAR_1 + 1][VAR_4] = ab->cplcoeffs[VAR_4] * ab->cplco[VAR_1][VAR_2] * ab->chcoeffs[VAR_1];",
"if (!ab->bap[VAR_1][VAR_4] && (ab->chincpl & (1 << VAR_1)) && (ab->dithflag & (1 << VAR_1))) {",
"mantissa = dither_int16(&VAR_0->state);",
"ab->transform_coeffs[VAR_1 + 1][VAR_4] = to_float(ab->dexps[VAR_1][VAR_4], mantissa) * ab->chcoeffs[VAR_1];",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
]
] |
3,291 | void qemu_input_event_send_key_delay(uint32_t delay_ms)
{
if (!kbd_timer) {
kbd_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL, qemu_input_queue_process,
&kbd_queue);
if (queue_count < queue_limit) {
qemu_input_queue_delay(&kbd_queue, kbd_timer,
delay_ms ? delay_ms : kbd_default_delay_ms); | true | qemu | 05c6638b203fd7d8bbfa88ac6e6198e32ed0506f | void qemu_input_event_send_key_delay(uint32_t delay_ms)
{
if (!kbd_timer) {
kbd_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL, qemu_input_queue_process,
&kbd_queue);
if (queue_count < queue_limit) {
qemu_input_queue_delay(&kbd_queue, kbd_timer,
delay_ms ? delay_ms : kbd_default_delay_ms); | {
"code": [],
"line_no": []
} | void FUNC_0(uint32_t VAR_0)
{
if (!kbd_timer) {
kbd_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL, qemu_input_queue_process,
&kbd_queue);
if (queue_count < queue_limit) {
qemu_input_queue_delay(&kbd_queue, kbd_timer,
VAR_0 ? VAR_0 : kbd_default_delay_ms); | [
"void FUNC_0(uint32_t VAR_0)\n{",
"if (!kbd_timer) {",
"kbd_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL, qemu_input_queue_process,\n&kbd_queue);",
"if (queue_count < queue_limit) {",
"qemu_input_queue_delay(&kbd_queue, kbd_timer,\nVAR_0 ? VAR_0 : kbd_default_delay_ms);"
] | [
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4,
5
],
[
6
],
[
7,
8
]
] |
3,292 | static int pci_add_option_rom(PCIDevice *pdev)
{
int size;
char *path;
void *ptr;
char name[32];
if (!pdev->romfile)
return 0;
if (strlen(pdev->romfile) == 0)
return 0;
if (!pdev->rom_bar) {
/*
* Load rom via fw_cfg instead of creating a rom bar,
* for 0.11 compatibility.
*/
int class = pci_get_word(pdev->config + PCI_CLASS_DEVICE);
if (class == 0x0300) {
rom_add_vga(pdev->romfile);
} else {
rom_add_option(pdev->romfile);
}
return 0;
}
path = qemu_find_file(QEMU_FILE_TYPE_BIOS, pdev->romfile);
if (path == NULL) {
path = qemu_strdup(pdev->romfile);
}
size = get_image_size(path);
if (size < 0) {
error_report("%s: failed to find romfile \"%s\"",
__FUNCTION__, pdev->romfile);
return -1;
}
if (size & (size - 1)) {
size = 1 << qemu_fls(size);
}
if (pdev->qdev.info->vmsd)
snprintf(name, sizeof(name), "%s.rom", pdev->qdev.info->vmsd->name);
else
snprintf(name, sizeof(name), "%s.rom", pdev->qdev.info->name);
pdev->rom_offset = qemu_ram_alloc(&pdev->qdev, name, size);
ptr = qemu_get_ram_ptr(pdev->rom_offset);
load_image(path, ptr);
qemu_free(path);
pci_register_bar(pdev, PCI_ROM_SLOT, size,
0, pci_map_option_rom);
return 0;
}
| true | qemu | ab85ceb1ad8797af2fb4c06bdc70f0ce0cf9b34f | static int pci_add_option_rom(PCIDevice *pdev)
{
int size;
char *path;
void *ptr;
char name[32];
if (!pdev->romfile)
return 0;
if (strlen(pdev->romfile) == 0)
return 0;
if (!pdev->rom_bar) {
int class = pci_get_word(pdev->config + PCI_CLASS_DEVICE);
if (class == 0x0300) {
rom_add_vga(pdev->romfile);
} else {
rom_add_option(pdev->romfile);
}
return 0;
}
path = qemu_find_file(QEMU_FILE_TYPE_BIOS, pdev->romfile);
if (path == NULL) {
path = qemu_strdup(pdev->romfile);
}
size = get_image_size(path);
if (size < 0) {
error_report("%s: failed to find romfile \"%s\"",
__FUNCTION__, pdev->romfile);
return -1;
}
if (size & (size - 1)) {
size = 1 << qemu_fls(size);
}
if (pdev->qdev.info->vmsd)
snprintf(name, sizeof(name), "%s.rom", pdev->qdev.info->vmsd->name);
else
snprintf(name, sizeof(name), "%s.rom", pdev->qdev.info->name);
pdev->rom_offset = qemu_ram_alloc(&pdev->qdev, name, size);
ptr = qemu_get_ram_ptr(pdev->rom_offset);
load_image(path, ptr);
qemu_free(path);
pci_register_bar(pdev, PCI_ROM_SLOT, size,
0, pci_map_option_rom);
return 0;
}
| {
"code": [
"static int pci_add_option_rom(PCIDevice *pdev)"
],
"line_no": [
1
]
} | static int FUNC_0(PCIDevice *VAR_0)
{
int VAR_1;
char *VAR_2;
void *VAR_3;
char VAR_4[32];
if (!VAR_0->romfile)
return 0;
if (strlen(VAR_0->romfile) == 0)
return 0;
if (!VAR_0->rom_bar) {
int VAR_5 = pci_get_word(VAR_0->config + PCI_CLASS_DEVICE);
if (VAR_5 == 0x0300) {
rom_add_vga(VAR_0->romfile);
} else {
rom_add_option(VAR_0->romfile);
}
return 0;
}
VAR_2 = qemu_find_file(QEMU_FILE_TYPE_BIOS, VAR_0->romfile);
if (VAR_2 == NULL) {
VAR_2 = qemu_strdup(VAR_0->romfile);
}
VAR_1 = get_image_size(VAR_2);
if (VAR_1 < 0) {
error_report("%s: failed to find romfile \"%s\"",
__FUNCTION__, VAR_0->romfile);
return -1;
}
if (VAR_1 & (VAR_1 - 1)) {
VAR_1 = 1 << qemu_fls(VAR_1);
}
if (VAR_0->qdev.info->vmsd)
snprintf(VAR_4, sizeof(VAR_4), "%s.rom", VAR_0->qdev.info->vmsd->VAR_4);
else
snprintf(VAR_4, sizeof(VAR_4), "%s.rom", VAR_0->qdev.info->VAR_4);
VAR_0->rom_offset = qemu_ram_alloc(&VAR_0->qdev, VAR_4, VAR_1);
VAR_3 = qemu_get_ram_ptr(VAR_0->rom_offset);
load_image(VAR_2, VAR_3);
qemu_free(VAR_2);
pci_register_bar(VAR_0, PCI_ROM_SLOT, VAR_1,
0, pci_map_option_rom);
return 0;
}
| [
"static int FUNC_0(PCIDevice *VAR_0)\n{",
"int VAR_1;",
"char *VAR_2;",
"void *VAR_3;",
"char VAR_4[32];",
"if (!VAR_0->romfile)\nreturn 0;",
"if (strlen(VAR_0->romfile) == 0)\nreturn 0;",
"if (!VAR_0->rom_bar) {",
"int VAR_5 = pci_get_word(VAR_0->config + PCI_CLASS_DEVICE);",
"if (VAR_5 == 0x0300) {",
"rom_add_vga(VAR_0->romfile);",
"} else {",
"rom_add_option(VAR_0->romfile);",
"}",
"return 0;",
"}",
"VAR_2 = qemu_find_file(QEMU_FILE_TYPE_BIOS, VAR_0->romfile);",
"if (VAR_2 == NULL) {",
"VAR_2 = qemu_strdup(VAR_0->romfile);",
"}",
"VAR_1 = get_image_size(VAR_2);",
"if (VAR_1 < 0) {",
"error_report(\"%s: failed to find romfile \\\"%s\\\"\",\n__FUNCTION__, VAR_0->romfile);",
"return -1;",
"}",
"if (VAR_1 & (VAR_1 - 1)) {",
"VAR_1 = 1 << qemu_fls(VAR_1);",
"}",
"if (VAR_0->qdev.info->vmsd)\nsnprintf(VAR_4, sizeof(VAR_4), \"%s.rom\", VAR_0->qdev.info->vmsd->VAR_4);",
"else\nsnprintf(VAR_4, sizeof(VAR_4), \"%s.rom\", VAR_0->qdev.info->VAR_4);",
"VAR_0->rom_offset = qemu_ram_alloc(&VAR_0->qdev, VAR_4, VAR_1);",
"VAR_3 = qemu_get_ram_ptr(VAR_0->rom_offset);",
"load_image(VAR_2, VAR_3);",
"qemu_free(VAR_2);",
"pci_register_bar(VAR_0, PCI_ROM_SLOT, VAR_1,\n0, pci_map_option_rom);",
"return 0;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
19,
21
],
[
25
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83,
85
],
[
87,
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
103,
105
],
[
109
],
[
111
]
] |
3,294 | static int convert_zp2tf(AVFilterContext *ctx, int channels)
{
AudioIIRContext *s = ctx->priv;
int ch, i, j, ret;
for (ch = 0; ch < channels; ch++) {
IIRChannel *iir = &s->iir[ch];
double *topc, *botc;
topc = av_calloc((iir->nb_ab[0] + 1) * 2, sizeof(*topc));
botc = av_calloc((iir->nb_ab[1] + 1) * 2, sizeof(*botc));
if (!topc || !botc)
return AVERROR(ENOMEM);
ret = expand(ctx, iir->ab[0], iir->nb_ab[0], botc);
if (ret < 0) {
av_free(topc);
av_free(botc);
return ret;
}
ret = expand(ctx, iir->ab[1], iir->nb_ab[1], topc);
if (ret < 0) {
av_free(topc);
av_free(botc);
return ret;
}
for (j = 0, i = iir->nb_ab[1]; i >= 0; j++, i--) {
iir->ab[1][j] = topc[2 * i];
}
iir->nb_ab[1]++;
for (j = 0, i = iir->nb_ab[0]; i >= 0; j++, i--) {
iir->ab[0][j] = botc[2 * i];
}
iir->nb_ab[0]++;
av_free(topc);
av_free(botc);
}
return 0;
}
| true | FFmpeg | 3c29f68b4db316c5d2b126619220cfa4255eacd6 | static int convert_zp2tf(AVFilterContext *ctx, int channels)
{
AudioIIRContext *s = ctx->priv;
int ch, i, j, ret;
for (ch = 0; ch < channels; ch++) {
IIRChannel *iir = &s->iir[ch];
double *topc, *botc;
topc = av_calloc((iir->nb_ab[0] + 1) * 2, sizeof(*topc));
botc = av_calloc((iir->nb_ab[1] + 1) * 2, sizeof(*botc));
if (!topc || !botc)
return AVERROR(ENOMEM);
ret = expand(ctx, iir->ab[0], iir->nb_ab[0], botc);
if (ret < 0) {
av_free(topc);
av_free(botc);
return ret;
}
ret = expand(ctx, iir->ab[1], iir->nb_ab[1], topc);
if (ret < 0) {
av_free(topc);
av_free(botc);
return ret;
}
for (j = 0, i = iir->nb_ab[1]; i >= 0; j++, i--) {
iir->ab[1][j] = topc[2 * i];
}
iir->nb_ab[1]++;
for (j = 0, i = iir->nb_ab[0]; i >= 0; j++, i--) {
iir->ab[0][j] = botc[2 * i];
}
iir->nb_ab[0]++;
av_free(topc);
av_free(botc);
}
return 0;
}
| {
"code": [
" int ch, i, j, ret;",
" if (!topc || !botc)",
" return AVERROR(ENOMEM);",
" av_free(topc);",
" av_free(botc);",
" return ret;",
" av_free(topc);",
" av_free(botc);",
" return ret;",
" return 0;"
],
"line_no": [
7,
23,
25,
33,
35,
37,
33,
35,
37,
85
]
} | static int FUNC_0(AVFilterContext *VAR_0, int VAR_1)
{
AudioIIRContext *s = VAR_0->priv;
int VAR_2, VAR_3, VAR_4, VAR_5;
for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++) {
IIRChannel *iir = &s->iir[VAR_2];
double *VAR_6, *VAR_7;
VAR_6 = av_calloc((iir->nb_ab[0] + 1) * 2, sizeof(*VAR_6));
VAR_7 = av_calloc((iir->nb_ab[1] + 1) * 2, sizeof(*VAR_7));
if (!VAR_6 || !VAR_7)
return AVERROR(ENOMEM);
VAR_5 = expand(VAR_0, iir->ab[0], iir->nb_ab[0], VAR_7);
if (VAR_5 < 0) {
av_free(VAR_6);
av_free(VAR_7);
return VAR_5;
}
VAR_5 = expand(VAR_0, iir->ab[1], iir->nb_ab[1], VAR_6);
if (VAR_5 < 0) {
av_free(VAR_6);
av_free(VAR_7);
return VAR_5;
}
for (VAR_4 = 0, VAR_3 = iir->nb_ab[1]; VAR_3 >= 0; VAR_4++, VAR_3--) {
iir->ab[1][VAR_4] = VAR_6[2 * VAR_3];
}
iir->nb_ab[1]++;
for (VAR_4 = 0, VAR_3 = iir->nb_ab[0]; VAR_3 >= 0; VAR_4++, VAR_3--) {
iir->ab[0][VAR_4] = VAR_7[2 * VAR_3];
}
iir->nb_ab[0]++;
av_free(VAR_6);
av_free(VAR_7);
}
return 0;
}
| [
"static int FUNC_0(AVFilterContext *VAR_0, int VAR_1)\n{",
"AudioIIRContext *s = VAR_0->priv;",
"int VAR_2, VAR_3, VAR_4, VAR_5;",
"for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++) {",
"IIRChannel *iir = &s->iir[VAR_2];",
"double *VAR_6, *VAR_7;",
"VAR_6 = av_calloc((iir->nb_ab[0] + 1) * 2, sizeof(*VAR_6));",
"VAR_7 = av_calloc((iir->nb_ab[1] + 1) * 2, sizeof(*VAR_7));",
"if (!VAR_6 || !VAR_7)\nreturn AVERROR(ENOMEM);",
"VAR_5 = expand(VAR_0, iir->ab[0], iir->nb_ab[0], VAR_7);",
"if (VAR_5 < 0) {",
"av_free(VAR_6);",
"av_free(VAR_7);",
"return VAR_5;",
"}",
"VAR_5 = expand(VAR_0, iir->ab[1], iir->nb_ab[1], VAR_6);",
"if (VAR_5 < 0) {",
"av_free(VAR_6);",
"av_free(VAR_7);",
"return VAR_5;",
"}",
"for (VAR_4 = 0, VAR_3 = iir->nb_ab[1]; VAR_3 >= 0; VAR_4++, VAR_3--) {",
"iir->ab[1][VAR_4] = VAR_6[2 * VAR_3];",
"}",
"iir->nb_ab[1]++;",
"for (VAR_4 = 0, VAR_3 = iir->nb_ab[0]; VAR_3 >= 0; VAR_4++, VAR_3--) {",
"iir->ab[0][VAR_4] = VAR_7[2 * VAR_3];",
"}",
"iir->nb_ab[0]++;",
"av_free(VAR_6);",
"av_free(VAR_7);",
"}",
"return 0;",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
1,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23,
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
]
] |
3,295 | static int decode_hybrid(const uint8_t *sptr, uint8_t *dptr, int dx, int dy,
int h, int w, int stride, const uint32_t *pal)
{
int x, y;
const uint8_t *orig_src = sptr;
for (y = dx + h; y > dx; y--) {
uint8_t *dst = dptr + (y * stride) + dy * 3;
for (x = 0; x < w; x++) {
if (*sptr & 0x80) {
/* 15-bit color */
unsigned c = AV_RB16(sptr) & ~0x8000;
unsigned b = c & 0x1F;
unsigned g = (c >> 5) & 0x1F;
unsigned r = c >> 10;
/* 000aaabb -> aaabbaaa */
*dst++ = (b << 3) | (b >> 2);
*dst++ = (g << 3) | (g >> 2);
*dst++ = (r << 3) | (r >> 2);
sptr += 2;
} else {
/* palette index */
uint32_t c = pal[*sptr++];
bytestream_put_le24(&dst, c);
}
}
}
return sptr - orig_src;
}
| true | FFmpeg | a33c7dd21362a694692d0dc30fdbffae5a5d837e | static int decode_hybrid(const uint8_t *sptr, uint8_t *dptr, int dx, int dy,
int h, int w, int stride, const uint32_t *pal)
{
int x, y;
const uint8_t *orig_src = sptr;
for (y = dx + h; y > dx; y--) {
uint8_t *dst = dptr + (y * stride) + dy * 3;
for (x = 0; x < w; x++) {
if (*sptr & 0x80) {
unsigned c = AV_RB16(sptr) & ~0x8000;
unsigned b = c & 0x1F;
unsigned g = (c >> 5) & 0x1F;
unsigned r = c >> 10;
*dst++ = (b << 3) | (b >> 2);
*dst++ = (g << 3) | (g >> 2);
*dst++ = (r << 3) | (r >> 2);
sptr += 2;
} else {
uint32_t c = pal[*sptr++];
bytestream_put_le24(&dst, c);
}
}
}
return sptr - orig_src;
}
| {
"code": [
"static int decode_hybrid(const uint8_t *sptr, uint8_t *dptr, int dx, int dy,"
],
"line_no": [
1
]
} | static int FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, int VAR_2, int VAR_3,
int VAR_4, int VAR_5, int VAR_6, const uint32_t *VAR_7)
{
int VAR_8, VAR_9;
const uint8_t *VAR_10 = VAR_0;
for (VAR_9 = VAR_2 + VAR_4; VAR_9 > VAR_2; VAR_9--) {
uint8_t *dst = VAR_1 + (VAR_9 * VAR_6) + VAR_3 * 3;
for (VAR_8 = 0; VAR_8 < VAR_5; VAR_8++) {
if (*VAR_0 & 0x80) {
unsigned VAR_11 = AV_RB16(VAR_0) & ~0x8000;
unsigned VAR_12 = VAR_11 & 0x1F;
unsigned VAR_13 = (VAR_11 >> 5) & 0x1F;
unsigned VAR_14 = VAR_11 >> 10;
*dst++ = (VAR_12 << 3) | (VAR_12 >> 2);
*dst++ = (VAR_13 << 3) | (VAR_13 >> 2);
*dst++ = (VAR_14 << 3) | (VAR_14 >> 2);
VAR_0 += 2;
} else {
uint32_t VAR_11 = VAR_7[*VAR_0++];
bytestream_put_le24(&dst, VAR_11);
}
}
}
return VAR_0 - VAR_10;
}
| [
"static int FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, int VAR_2, int VAR_3,\nint VAR_4, int VAR_5, int VAR_6, const uint32_t *VAR_7)\n{",
"int VAR_8, VAR_9;",
"const uint8_t *VAR_10 = VAR_0;",
"for (VAR_9 = VAR_2 + VAR_4; VAR_9 > VAR_2; VAR_9--) {",
"uint8_t *dst = VAR_1 + (VAR_9 * VAR_6) + VAR_3 * 3;",
"for (VAR_8 = 0; VAR_8 < VAR_5; VAR_8++) {",
"if (*VAR_0 & 0x80) {",
"unsigned VAR_11 = AV_RB16(VAR_0) & ~0x8000;",
"unsigned VAR_12 = VAR_11 & 0x1F;",
"unsigned VAR_13 = (VAR_11 >> 5) & 0x1F;",
"unsigned VAR_14 = VAR_11 >> 10;",
"*dst++ = (VAR_12 << 3) | (VAR_12 >> 2);",
"*dst++ = (VAR_13 << 3) | (VAR_13 >> 2);",
"*dst++ = (VAR_14 << 3) | (VAR_14 >> 2);",
"VAR_0 += 2;",
"} else {",
"uint32_t VAR_11 = VAR_7[*VAR_0++];",
"bytestream_put_le24(&dst, VAR_11);",
"}",
"}",
"}",
"return VAR_0 - VAR_10;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
]
] |
3,296 | static void set_sensor_type(IPMIBmcSim *ibs,
uint8_t *cmd, unsigned int cmd_len,
uint8_t *rsp, unsigned int *rsp_len,
unsigned int max_rsp_len)
{
IPMISensor *sens;
IPMI_CHECK_CMD_LEN(5);
if ((cmd[2] > MAX_SENSORS) ||
!IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) {
rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;
return;
}
sens = ibs->sensors + cmd[2];
sens->sensor_type = cmd[3];
sens->evt_reading_type_code = cmd[4] & 0x7f;
}
| true | qemu | 73d60fa5fae60c8e07e1f295d8c7fd5d04320160 | static void set_sensor_type(IPMIBmcSim *ibs,
uint8_t *cmd, unsigned int cmd_len,
uint8_t *rsp, unsigned int *rsp_len,
unsigned int max_rsp_len)
{
IPMISensor *sens;
IPMI_CHECK_CMD_LEN(5);
if ((cmd[2] > MAX_SENSORS) ||
!IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) {
rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;
return;
}
sens = ibs->sensors + cmd[2];
sens->sensor_type = cmd[3];
sens->evt_reading_type_code = cmd[4] & 0x7f;
}
| {
"code": [
" if ((cmd[2] > MAX_SENSORS) ||",
" if ((cmd[2] > MAX_SENSORS) ||",
" if ((cmd[2] > MAX_SENSORS) ||",
" if ((cmd[2] > MAX_SENSORS) ||",
" if ((cmd[2] > MAX_SENSORS) ||",
" if ((cmd[2] > MAX_SENSORS) ||",
" if ((cmd[2] > MAX_SENSORS) ||"
],
"line_no": [
19,
19,
19,
19,
19,
19,
19
]
} | static void FUNC_0(IPMIBmcSim *VAR_0,
uint8_t *VAR_1, unsigned int VAR_2,
uint8_t *VAR_3, unsigned int *VAR_4,
unsigned int VAR_5)
{
IPMISensor *sens;
IPMI_CHECK_CMD_LEN(5);
if ((VAR_1[2] > MAX_SENSORS) ||
!IPMI_SENSOR_GET_PRESENT(VAR_0->sensors + VAR_1[2])) {
VAR_3[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;
return;
}
sens = VAR_0->sensors + VAR_1[2];
sens->sensor_type = VAR_1[3];
sens->evt_reading_type_code = VAR_1[4] & 0x7f;
}
| [
"static void FUNC_0(IPMIBmcSim *VAR_0,\nuint8_t *VAR_1, unsigned int VAR_2,\nuint8_t *VAR_3, unsigned int *VAR_4,\nunsigned int VAR_5)\n{",
"IPMISensor *sens;",
"IPMI_CHECK_CMD_LEN(5);",
"if ((VAR_1[2] > MAX_SENSORS) ||\n!IPMI_SENSOR_GET_PRESENT(VAR_0->sensors + VAR_1[2])) {",
"VAR_3[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;",
"return;",
"}",
"sens = VAR_0->sensors + VAR_1[2];",
"sens->sensor_type = VAR_1[3];",
"sens->evt_reading_type_code = VAR_1[4] & 0x7f;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
]
] |
3,297 | DescRing *desc_ring_alloc(Rocker *r, int index)
{
DescRing *ring;
ring = g_malloc0(sizeof(DescRing));
if (!ring) {
return NULL;
}
ring->r = r;
ring->index = index;
return ring;
}
| true | qemu | 778358d0a8f74a76488daea3c1b6fb327d8135b4 | DescRing *desc_ring_alloc(Rocker *r, int index)
{
DescRing *ring;
ring = g_malloc0(sizeof(DescRing));
if (!ring) {
return NULL;
}
ring->r = r;
ring->index = index;
return ring;
}
| {
"code": [
" ring = g_malloc0(sizeof(DescRing));"
],
"line_no": [
9
]
} | DescRing *FUNC_0(Rocker *r, int index)
{
DescRing *ring;
ring = g_malloc0(sizeof(DescRing));
if (!ring) {
return NULL;
}
ring->r = r;
ring->index = index;
return ring;
}
| [
"DescRing *FUNC_0(Rocker *r, int index)\n{",
"DescRing *ring;",
"ring = g_malloc0(sizeof(DescRing));",
"if (!ring) {",
"return NULL;",
"}",
"ring->r = r;",
"ring->index = index;",
"return ring;",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
25
],
[
27
]
] |
3,298 | START_TEST(vararg_string)
{
int i;
struct {
const char *decoded;
} test_cases[] = {
{ "hello world" },
{ "the quick brown fox jumped over the fence" },
{}
};
for (i = 0; test_cases[i].decoded; i++) {
QObject *obj;
QString *str;
obj = qobject_from_jsonf("%s", test_cases[i].decoded);
fail_unless(obj != NULL);
fail_unless(qobject_type(obj) == QTYPE_QSTRING);
str = qobject_to_qstring(obj);
fail_unless(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0);
QDECREF(str);
}
}
| false | qemu | ef76dc59fa5203d146a2acf85a0ad5a5971a4824 | START_TEST(vararg_string)
{
int i;
struct {
const char *decoded;
} test_cases[] = {
{ "hello world" },
{ "the quick brown fox jumped over the fence" },
{}
};
for (i = 0; test_cases[i].decoded; i++) {
QObject *obj;
QString *str;
obj = qobject_from_jsonf("%s", test_cases[i].decoded);
fail_unless(obj != NULL);
fail_unless(qobject_type(obj) == QTYPE_QSTRING);
str = qobject_to_qstring(obj);
fail_unless(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0);
QDECREF(str);
}
}
| {
"code": [],
"line_no": []
} | FUNC_0(VAR_0)
{
int VAR_1;
struct {
const char *decoded;
} VAR_2[] = {
{ "hello world" },
{ "the quick brown fox jumped over the fence" },
{}
};
for (VAR_1 = 0; VAR_2[VAR_1].decoded; VAR_1++) {
QObject *obj;
QString *str;
obj = qobject_from_jsonf("%s", VAR_2[VAR_1].decoded);
fail_unless(obj != NULL);
fail_unless(qobject_type(obj) == QTYPE_QSTRING);
str = qobject_to_qstring(obj);
fail_unless(strcmp(qstring_get_str(str), VAR_2[VAR_1].decoded) == 0);
QDECREF(str);
}
}
| [
"FUNC_0(VAR_0)\n{",
"int VAR_1;",
"struct {",
"const char *decoded;",
"} VAR_2[] = {",
"{ \"hello world\" },",
"{ \"the quick brown fox jumped over the fence\" },",
"{}",
"};",
"for (VAR_1 = 0; VAR_2[VAR_1].decoded; VAR_1++) {",
"QObject *obj;",
"QString *str;",
"obj = qobject_from_jsonf(\"%s\", VAR_2[VAR_1].decoded);",
"fail_unless(obj != NULL);",
"fail_unless(qobject_type(obj) == QTYPE_QSTRING);",
"str = qobject_to_qstring(obj);",
"fail_unless(strcmp(qstring_get_str(str), VAR_2[VAR_1].decoded) == 0);",
"QDECREF(str);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
31
],
[
35
],
[
37
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
]
] |
3,299 | static void t_gen_cris_dstep(TCGv d, TCGv a, TCGv b)
{
int l1;
l1 = gen_new_label();
/*
* d <<= 1
* if (d >= s)
* d -= s;
*/
tcg_gen_shli_tl(d, a, 1);
tcg_gen_brcond_tl(TCG_COND_LTU, d, b, l1);
tcg_gen_sub_tl(d, d, b);
gen_set_label(l1);
}
| false | qemu | 42a268c241183877192c376d03bd9b6d527407c7 | static void t_gen_cris_dstep(TCGv d, TCGv a, TCGv b)
{
int l1;
l1 = gen_new_label();
tcg_gen_shli_tl(d, a, 1);
tcg_gen_brcond_tl(TCG_COND_LTU, d, b, l1);
tcg_gen_sub_tl(d, d, b);
gen_set_label(l1);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TCGv VAR_0, TCGv VAR_1, TCGv VAR_2)
{
int VAR_3;
VAR_3 = gen_new_label();
tcg_gen_shli_tl(VAR_0, VAR_1, 1);
tcg_gen_brcond_tl(TCG_COND_LTU, VAR_0, VAR_2, VAR_3);
tcg_gen_sub_tl(VAR_0, VAR_0, VAR_2);
gen_set_label(VAR_3);
}
| [
"static void FUNC_0(TCGv VAR_0, TCGv VAR_1, TCGv VAR_2)\n{",
"int VAR_3;",
"VAR_3 = gen_new_label();",
"tcg_gen_shli_tl(VAR_0, VAR_1, 1);",
"tcg_gen_brcond_tl(TCG_COND_LTU, VAR_0, VAR_2, VAR_3);",
"tcg_gen_sub_tl(VAR_0, VAR_0, VAR_2);",
"gen_set_label(VAR_3);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
]
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.