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
|
---|---|---|---|---|---|---|---|---|---|---|
1,717 | void av_get_channel_layout_string(char *buf, int buf_size,
int nb_channels, int64_t channel_layout)
{
int i;
if (nb_channels <= 0)
nb_channels = av_get_channel_layout_nb_channels(channel_layout);
for (i = 0; channel_layout_map[i].name; i++)
if (nb_channels == channel_layout_map[i].nb_channels &&
channel_layout == channel_layout_map[i].layout) {
av_strlcpy(buf, channel_layout_map[i].name, buf_size);
return;
}
snprintf(buf, buf_size, "%d channels", nb_channels);
if (channel_layout) {
int i, ch;
av_strlcat(buf, " (", buf_size);
for (i = 0, ch = 0; i < 64; i++) {
if ((channel_layout & (1L << i))) {
const char *name = get_channel_name(i);
if (name) {
if (ch > 0)
av_strlcat(buf, "|", buf_size);
av_strlcat(buf, name, buf_size);
}
ch++;
}
}
av_strlcat(buf, ")", buf_size);
}
}
| false | FFmpeg | cc276c85d15272df6e44fb3252657a43cbd49555 | void av_get_channel_layout_string(char *buf, int buf_size,
int nb_channels, int64_t channel_layout)
{
int i;
if (nb_channels <= 0)
nb_channels = av_get_channel_layout_nb_channels(channel_layout);
for (i = 0; channel_layout_map[i].name; i++)
if (nb_channels == channel_layout_map[i].nb_channels &&
channel_layout == channel_layout_map[i].layout) {
av_strlcpy(buf, channel_layout_map[i].name, buf_size);
return;
}
snprintf(buf, buf_size, "%d channels", nb_channels);
if (channel_layout) {
int i, ch;
av_strlcat(buf, " (", buf_size);
for (i = 0, ch = 0; i < 64; i++) {
if ((channel_layout & (1L << i))) {
const char *name = get_channel_name(i);
if (name) {
if (ch > 0)
av_strlcat(buf, "|", buf_size);
av_strlcat(buf, name, buf_size);
}
ch++;
}
}
av_strlcat(buf, ")", buf_size);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(char *VAR_0, int VAR_1,
int VAR_2, int64_t VAR_3)
{
int VAR_5;
if (VAR_2 <= 0)
VAR_2 = av_get_channel_layout_nb_channels(VAR_3);
for (VAR_5 = 0; channel_layout_map[VAR_5].VAR_6; VAR_5++)
if (VAR_2 == channel_layout_map[VAR_5].VAR_2 &&
VAR_3 == channel_layout_map[VAR_5].layout) {
av_strlcpy(VAR_0, channel_layout_map[VAR_5].VAR_6, VAR_1);
return;
}
snprintf(VAR_0, VAR_1, "%d channels", VAR_2);
if (VAR_3) {
int VAR_5, VAR_5;
av_strlcat(VAR_0, " (", VAR_1);
for (VAR_5 = 0, VAR_5 = 0; VAR_5 < 64; VAR_5++) {
if ((VAR_3 & (1L << VAR_5))) {
const char *VAR_6 = get_channel_name(VAR_5);
if (VAR_6) {
if (VAR_5 > 0)
av_strlcat(VAR_0, "|", VAR_1);
av_strlcat(VAR_0, VAR_6, VAR_1);
}
VAR_5++;
}
}
av_strlcat(VAR_0, ")", VAR_1);
}
}
| [
"void FUNC_0(char *VAR_0, int VAR_1,\nint VAR_2, int64_t VAR_3)\n{",
"int VAR_5;",
"if (VAR_2 <= 0)\nVAR_2 = av_get_channel_layout_nb_channels(VAR_3);",
"for (VAR_5 = 0; channel_layout_map[VAR_5].VAR_6; VAR_5++)",
"if (VAR_2 == channel_layout_map[VAR_5].VAR_2 &&\nVAR_3 == channel_layout_map[VAR_5].layout) {",
"av_strlcpy(VAR_0, channel_layout_map[VAR_5].VAR_6, VAR_1);",
"return;",
"}",
"snprintf(VAR_0, VAR_1, \"%d channels\", VAR_2);",
"if (VAR_3) {",
"int VAR_5, VAR_5;",
"av_strlcat(VAR_0, \" (\", VAR_1);",
"for (VAR_5 = 0, VAR_5 = 0; VAR_5 < 64; VAR_5++) {",
"if ((VAR_3 & (1L << VAR_5))) {",
"const char *VAR_6 = get_channel_name(VAR_5);",
"if (VAR_6) {",
"if (VAR_5 > 0)\nav_strlcat(VAR_0, \"|\", VAR_1);",
"av_strlcat(VAR_0, VAR_6, VAR_1);",
"}",
"VAR_5++;",
"}",
"}",
"av_strlcat(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,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11,
13
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
]
] |
1,718 | void qemu_co_queue_run_restart(Coroutine *co)
{
Coroutine *next;
trace_qemu_co_queue_run_restart(co);
while ((next = QSIMPLEQ_FIRST(&co->co_queue_wakeup))) {
QSIMPLEQ_REMOVE_HEAD(&co->co_queue_wakeup, co_queue_next);
qemu_coroutine_enter(next, NULL);
}
}
| true | qemu | 0b8b8753e4d94901627b3e86431230f2319215c4 | void qemu_co_queue_run_restart(Coroutine *co)
{
Coroutine *next;
trace_qemu_co_queue_run_restart(co);
while ((next = QSIMPLEQ_FIRST(&co->co_queue_wakeup))) {
QSIMPLEQ_REMOVE_HEAD(&co->co_queue_wakeup, co_queue_next);
qemu_coroutine_enter(next, NULL);
}
}
| {
"code": [
" qemu_coroutine_enter(next, NULL);"
],
"line_no": [
15
]
} | void FUNC_0(Coroutine *VAR_0)
{
Coroutine *next;
trace_qemu_co_queue_run_restart(VAR_0);
while ((next = QSIMPLEQ_FIRST(&VAR_0->co_queue_wakeup))) {
QSIMPLEQ_REMOVE_HEAD(&VAR_0->co_queue_wakeup, co_queue_next);
qemu_coroutine_enter(next, NULL);
}
}
| [
"void FUNC_0(Coroutine *VAR_0)\n{",
"Coroutine *next;",
"trace_qemu_co_queue_run_restart(VAR_0);",
"while ((next = QSIMPLEQ_FIRST(&VAR_0->co_queue_wakeup))) {",
"QSIMPLEQ_REMOVE_HEAD(&VAR_0->co_queue_wakeup, co_queue_next);",
"qemu_coroutine_enter(next, NULL);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
1,719 | static inline void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)
{
#if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
asm volatile(
"movq "MANGLE(bm01010101)", %%mm4\n\t"
"mov %0, %%"REG_a" \n\t"
"1: \n\t"
"movq (%1, %%"REG_a",4), %%mm0 \n\t"
"movq 8(%1, %%"REG_a",4), %%mm1 \n\t"
"movq (%2, %%"REG_a",4), %%mm2 \n\t"
"movq 8(%2, %%"REG_a",4), %%mm3 \n\t"
PAVGB(%%mm2, %%mm0)
PAVGB(%%mm3, %%mm1)
"pand %%mm4, %%mm0 \n\t"
"pand %%mm4, %%mm1 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"movq %%mm0, %%mm1 \n\t"
"psrlw $8, %%mm0 \n\t"
"pand %%mm4, %%mm1 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"packuswb %%mm1, %%mm1 \n\t"
"movd %%mm0, (%4, %%"REG_a") \n\t"
"movd %%mm1, (%3, %%"REG_a") \n\t"
"add $4, %%"REG_a" \n\t"
" js 1b \n\t"
: : "g" ((long)-width), "r" (src1+width*4), "r" (src2+width*4), "r" (dstU+width), "r" (dstV+width)
: "%"REG_a
);
#else
int i;
for(i=0; i<width; i++)
{
dstU[i]= (src1[4*i + 0] + src2[4*i + 0])>>1;
dstV[i]= (src1[4*i + 2] + src2[4*i + 2])>>1;
}
#endif
}
| true | FFmpeg | 7f526efd17973ec6d2204f7a47b6923e2be31363 | static inline void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)
{
#if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
asm volatile(
"movq "MANGLE(bm01010101)", %%mm4\n\t"
"mov %0, %%"REG_a" \n\t"
"1: \n\t"
"movq (%1, %%"REG_a",4), %%mm0 \n\t"
"movq 8(%1, %%"REG_a",4), %%mm1 \n\t"
"movq (%2, %%"REG_a",4), %%mm2 \n\t"
"movq 8(%2, %%"REG_a",4), %%mm3 \n\t"
PAVGB(%%mm2, %%mm0)
PAVGB(%%mm3, %%mm1)
"pand %%mm4, %%mm0 \n\t"
"pand %%mm4, %%mm1 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"movq %%mm0, %%mm1 \n\t"
"psrlw $8, %%mm0 \n\t"
"pand %%mm4, %%mm1 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"packuswb %%mm1, %%mm1 \n\t"
"movd %%mm0, (%4, %%"REG_a") \n\t"
"movd %%mm1, (%3, %%"REG_a") \n\t"
"add $4, %%"REG_a" \n\t"
" js 1b \n\t"
: : "g" ((long)-width), "r" (src1+width*4), "r" (src2+width*4), "r" (dstU+width), "r" (dstV+width)
: "%"REG_a
);
#else
int i;
for(i=0; i<width; i++)
{
dstU[i]= (src1[4*i + 0] + src2[4*i + 0])>>1;
dstV[i]= (src1[4*i + 2] + src2[4*i + 2])>>1;
}
#endif
}
| {
"code": [
"\t\t: : \"g\" ((long)-width), \"r\" (src1+width*4), \"r\" (src2+width*4), \"r\" (dstU+width), \"r\" (dstV+width)",
"static inline void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)",
"\t\t: : \"g\" ((long)-width), \"r\" (src1+width*4), \"r\" (src2+width*4), \"r\" (dstU+width), \"r\" (dstV+width)"
],
"line_no": [
51,
1,
51
]
} | static inline void FUNC_0(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)
{
#if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
asm volatile(
"movq "MANGLE(bm01010101)", %%mm4\n\t"
"mov %0, %%"REG_a" \n\t"
"1: \n\t"
"movq (%1, %%"REG_a",4), %%mm0 \n\t"
"movq 8(%1, %%"REG_a",4), %%mm1 \n\t"
"movq (%2, %%"REG_a",4), %%mm2 \n\t"
"movq 8(%2, %%"REG_a",4), %%mm3 \n\t"
PAVGB(%%mm2, %%mm0)
PAVGB(%%mm3, %%mm1)
"pand %%mm4, %%mm0 \n\t"
"pand %%mm4, %%mm1 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"movq %%mm0, %%mm1 \n\t"
"psrlw $8, %%mm0 \n\t"
"pand %%mm4, %%mm1 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"packuswb %%mm1, %%mm1 \n\t"
"movd %%mm0, (%4, %%"REG_a") \n\t"
"movd %%mm1, (%3, %%"REG_a") \n\t"
"add $4, %%"REG_a" \n\t"
" js 1b \n\t"
: : "g" ((long)-width), "r" (src1+width*4), "r" (src2+width*4), "r" (dstU+width), "r" (dstV+width)
: "%"REG_a
);
#else
int VAR_0;
for(VAR_0=0; VAR_0<width; VAR_0++)
{
dstU[VAR_0]= (src1[4*VAR_0 + 0] + src2[4*VAR_0 + 0])>>1;
dstV[VAR_0]= (src1[4*VAR_0 + 2] + src2[4*VAR_0 + 2])>>1;
}
#endif
}
| [
"static inline void FUNC_0(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)\n{",
"#if defined (HAVE_MMX2) || defined (HAVE_3DNOW)\nasm volatile(\n\"movq \"MANGLE(bm01010101)\", %%mm4\\n\\t\"\n\"mov %0, %%\"REG_a\"\t\t\\n\\t\"\n\"1:\t\t\t\t\\n\\t\"\n\"movq (%1, %%\"REG_a\",4), %%mm0\t\\n\\t\"\n\"movq 8(%1, %%\"REG_a\",4), %%mm1\t\\n\\t\"\n\"movq (%2, %%\"REG_a\",4), %%mm2\t\\n\\t\"\n\"movq 8(%2, %%\"REG_a\",4), %%mm3\t\\n\\t\"\nPAVGB(%%mm2, %%mm0)\nPAVGB(%%mm3, %%mm1)\n\"pand %%mm4, %%mm0\t\t\\n\\t\"\n\"pand %%mm4, %%mm1\t\t\\n\\t\"\n\"packuswb %%mm1, %%mm0\t\t\\n\\t\"\n\"movq %%mm0, %%mm1\t\t\\n\\t\"\n\"psrlw $8, %%mm0\t\t\\n\\t\"\n\"pand %%mm4, %%mm1\t\t\\n\\t\"\n\"packuswb %%mm0, %%mm0\t\t\\n\\t\"\n\"packuswb %%mm1, %%mm1\t\t\\n\\t\"\n\"movd %%mm0, (%4, %%\"REG_a\")\t\\n\\t\"\n\"movd %%mm1, (%3, %%\"REG_a\")\t\\n\\t\"\n\"add $4, %%\"REG_a\"\t\t\\n\\t\"\n\" js 1b\t\t\t\t\\n\\t\"\n: : \"g\" ((long)-width), \"r\" (src1+width*4), \"r\" (src2+width*4), \"r\" (dstU+width), \"r\" (dstV+width)\n: \"%\"REG_a\n);",
"#else\nint VAR_0;",
"for(VAR_0=0; VAR_0<width; VAR_0++)",
"{",
"dstU[VAR_0]= (src1[4*VAR_0 + 0] + src2[4*VAR_0 + 0])>>1;",
"dstV[VAR_0]= (src1[4*VAR_0 + 2] + src2[4*VAR_0 + 2])>>1;",
"}",
"#endif\n}"
] | [
1,
1,
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
]
] |
1,720 | static void default_show_tags(WriterContext *wctx, AVDictionary *dict)
{
AVDictionaryEntry *tag = NULL;
while ((tag = av_dict_get(dict, "", tag, AV_DICT_IGNORE_SUFFIX))) {
printf("TAG:");
writer_print_string(wctx, tag->key, tag->value);
}
}
| false | FFmpeg | 0491a2a07a44f6e5e6f34081835e402c07025fd2 | static void default_show_tags(WriterContext *wctx, AVDictionary *dict)
{
AVDictionaryEntry *tag = NULL;
while ((tag = av_dict_get(dict, "", tag, AV_DICT_IGNORE_SUFFIX))) {
printf("TAG:");
writer_print_string(wctx, tag->key, tag->value);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(WriterContext *VAR_0, AVDictionary *VAR_1)
{
AVDictionaryEntry *tag = NULL;
while ((tag = av_dict_get(VAR_1, "", tag, AV_DICT_IGNORE_SUFFIX))) {
printf("TAG:");
writer_print_string(VAR_0, tag->key, tag->value);
}
}
| [
"static void FUNC_0(WriterContext *VAR_0, AVDictionary *VAR_1)\n{",
"AVDictionaryEntry *tag = NULL;",
"while ((tag = av_dict_get(VAR_1, \"\", tag, AV_DICT_IGNORE_SUFFIX))) {",
"printf(\"TAG:\");",
"writer_print_string(VAR_0, tag->key, tag->value);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
1,722 | static int decode_block(ALSDecContext *ctx, ALSBlockData *bd)
{
unsigned int smp;
// read block type flag and read the samples accordingly
if (*bd->const_block)
decode_const_block_data(ctx, bd);
else if (decode_var_block_data(ctx, bd))
return -1;
// TODO: read RLSLMS extension data
if (*bd->shift_lsbs)
for (smp = 0; smp < bd->block_length; smp++)
bd->raw_samples[smp] <<= *bd->shift_lsbs;
return 0;
}
| true | FFmpeg | ca488ad480360dfafcb5766f7bfbb567a0638979 | static int decode_block(ALSDecContext *ctx, ALSBlockData *bd)
{
unsigned int smp;
if (*bd->const_block)
decode_const_block_data(ctx, bd);
else if (decode_var_block_data(ctx, bd))
return -1;
if (*bd->shift_lsbs)
for (smp = 0; smp < bd->block_length; smp++)
bd->raw_samples[smp] <<= *bd->shift_lsbs;
return 0;
}
| {
"code": [
" return -1;",
" return -1;",
" return -1;",
" return -1;",
" return -1;",
" return -1;",
" return -1;",
" return 0;",
" else if (decode_var_block_data(ctx, bd))",
" return -1;",
" return -1;",
" return -1;",
" return -1;",
" return -1;",
" return -1;"
],
"line_no": [
17,
17,
17,
17,
17,
17,
17,
33,
15,
17,
17,
17,
17,
17,
17
]
} | static int FUNC_0(ALSDecContext *VAR_0, ALSBlockData *VAR_1)
{
unsigned int VAR_2;
if (*VAR_1->const_block)
decode_const_block_data(VAR_0, VAR_1);
else if (decode_var_block_data(VAR_0, VAR_1))
return -1;
if (*VAR_1->shift_lsbs)
for (VAR_2 = 0; VAR_2 < VAR_1->block_length; VAR_2++)
VAR_1->raw_samples[VAR_2] <<= *VAR_1->shift_lsbs;
return 0;
}
| [
"static int FUNC_0(ALSDecContext *VAR_0, ALSBlockData *VAR_1)\n{",
"unsigned int VAR_2;",
"if (*VAR_1->const_block)\ndecode_const_block_data(VAR_0, VAR_1);",
"else if (decode_var_block_data(VAR_0, VAR_1))\nreturn -1;",
"if (*VAR_1->shift_lsbs)\nfor (VAR_2 = 0; VAR_2 < VAR_1->block_length; VAR_2++)",
"VAR_1->raw_samples[VAR_2] <<= *VAR_1->shift_lsbs;",
"return 0;",
"}"
] | [
0,
0,
0,
1,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
11,
13
],
[
15,
17
],
[
25,
27
],
[
29
],
[
33
],
[
35
]
] |
1,723 | static void hdcd_reset(hdcd_state *state, unsigned rate, unsigned cdt_ms)
{
int i;
state->window = 0;
state->readahead = 32;
state->arg = 0;
state->control = 0;
state->running_gain = 0;
state->sustain = 0;
state->sustain_reset = cdt_ms*rate/1000;
state->code_counterA = 0;
state->code_counterA_almost = 0;
state->code_counterB = 0;
state->code_counterB_checkfails = 0;
state->code_counterC = 0;
state->code_counterC_unmatched = 0;
state->count_peak_extend = 0;
state->count_transient_filter = 0;
for(i = 0; i < 16; i++) state->gain_counts[i] = 0;
state->max_gain = 0;
state->count_sustain_expired = -1;
state->_ana_snb = 0;
}
| true | FFmpeg | 91be2ad756d658acc24fec5bc46c1775158d28b0 | static void hdcd_reset(hdcd_state *state, unsigned rate, unsigned cdt_ms)
{
int i;
state->window = 0;
state->readahead = 32;
state->arg = 0;
state->control = 0;
state->running_gain = 0;
state->sustain = 0;
state->sustain_reset = cdt_ms*rate/1000;
state->code_counterA = 0;
state->code_counterA_almost = 0;
state->code_counterB = 0;
state->code_counterB_checkfails = 0;
state->code_counterC = 0;
state->code_counterC_unmatched = 0;
state->count_peak_extend = 0;
state->count_transient_filter = 0;
for(i = 0; i < 16; i++) state->gain_counts[i] = 0;
state->max_gain = 0;
state->count_sustain_expired = -1;
state->_ana_snb = 0;
}
| {
"code": [
" state->sustain_reset = cdt_ms*rate/1000;"
],
"line_no": [
25
]
} | static void FUNC_0(hdcd_state *VAR_0, unsigned VAR_1, unsigned VAR_2)
{
int VAR_3;
VAR_0->window = 0;
VAR_0->readahead = 32;
VAR_0->arg = 0;
VAR_0->control = 0;
VAR_0->running_gain = 0;
VAR_0->sustain = 0;
VAR_0->sustain_reset = VAR_2*VAR_1/1000;
VAR_0->code_counterA = 0;
VAR_0->code_counterA_almost = 0;
VAR_0->code_counterB = 0;
VAR_0->code_counterB_checkfails = 0;
VAR_0->code_counterC = 0;
VAR_0->code_counterC_unmatched = 0;
VAR_0->count_peak_extend = 0;
VAR_0->count_transient_filter = 0;
for(VAR_3 = 0; VAR_3 < 16; VAR_3++) VAR_0->gain_counts[VAR_3] = 0;
VAR_0->max_gain = 0;
VAR_0->count_sustain_expired = -1;
VAR_0->_ana_snb = 0;
}
| [
"static void FUNC_0(hdcd_state *VAR_0, unsigned VAR_1, unsigned VAR_2)\n{",
"int VAR_3;",
"VAR_0->window = 0;",
"VAR_0->readahead = 32;",
"VAR_0->arg = 0;",
"VAR_0->control = 0;",
"VAR_0->running_gain = 0;",
"VAR_0->sustain = 0;",
"VAR_0->sustain_reset = VAR_2*VAR_1/1000;",
"VAR_0->code_counterA = 0;",
"VAR_0->code_counterA_almost = 0;",
"VAR_0->code_counterB = 0;",
"VAR_0->code_counterB_checkfails = 0;",
"VAR_0->code_counterC = 0;",
"VAR_0->code_counterC_unmatched = 0;",
"VAR_0->count_peak_extend = 0;",
"VAR_0->count_transient_filter = 0;",
"for(VAR_3 = 0; VAR_3 < 16; VAR_3++) VAR_0->gain_counts[VAR_3] = 0;",
"VAR_0->max_gain = 0;",
"VAR_0->count_sustain_expired = -1;",
"VAR_0->_ana_snb = 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
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
]
] |
1,724 | static int ehci_register_companion(USBBus *bus, USBPort *ports[],
uint32_t portcount, uint32_t firstport)
{
EHCIState *s = container_of(bus, EHCIState, bus);
uint32_t i;
if (firstport + portcount > NB_PORTS) {
qerror_report(QERR_INVALID_PARAMETER_VALUE, "firstport",
"firstport on masterbus");
error_printf_unless_qmp(
"firstport value of %u makes companion take ports %u - %u, which "
"is outside of the valid range of 0 - %u\n", firstport, firstport,
firstport + portcount - 1, NB_PORTS - 1);
return -1;
}
for (i = 0; i < portcount; i++) {
if (s->companion_ports[firstport + i]) {
qerror_report(QERR_INVALID_PARAMETER_VALUE, "masterbus",
"an USB masterbus");
error_printf_unless_qmp(
"port %u on masterbus %s already has a companion assigned\n",
firstport + i, bus->qbus.name);
return -1;
}
}
for (i = 0; i < portcount; i++) {
s->companion_ports[firstport + i] = ports[i];
s->ports[firstport + i].speedmask |=
USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL;
/* Ensure devs attached before the initial reset go to the companion */
s->portsc[firstport + i] = PORTSC_POWNER;
}
s->companion_count++;
s->mmio[0x05] = (s->companion_count << 4) | portcount;
return 0;
}
| true | qemu | 3e4f910c8d490a1490409a7e381dbbb229f9d272 | static int ehci_register_companion(USBBus *bus, USBPort *ports[],
uint32_t portcount, uint32_t firstport)
{
EHCIState *s = container_of(bus, EHCIState, bus);
uint32_t i;
if (firstport + portcount > NB_PORTS) {
qerror_report(QERR_INVALID_PARAMETER_VALUE, "firstport",
"firstport on masterbus");
error_printf_unless_qmp(
"firstport value of %u makes companion take ports %u - %u, which "
"is outside of the valid range of 0 - %u\n", firstport, firstport,
firstport + portcount - 1, NB_PORTS - 1);
return -1;
}
for (i = 0; i < portcount; i++) {
if (s->companion_ports[firstport + i]) {
qerror_report(QERR_INVALID_PARAMETER_VALUE, "masterbus",
"an USB masterbus");
error_printf_unless_qmp(
"port %u on masterbus %s already has a companion assigned\n",
firstport + i, bus->qbus.name);
return -1;
}
}
for (i = 0; i < portcount; i++) {
s->companion_ports[firstport + i] = ports[i];
s->ports[firstport + i].speedmask |=
USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL;
s->portsc[firstport + i] = PORTSC_POWNER;
}
s->companion_count++;
s->mmio[0x05] = (s->companion_count << 4) | portcount;
return 0;
}
| {
"code": [
" s->mmio[0x05] = (s->companion_count << 4) | portcount;"
],
"line_no": [
73
]
} | static int FUNC_0(USBBus *VAR_0, USBPort *VAR_1[],
uint32_t VAR_2, uint32_t VAR_3)
{
EHCIState *s = container_of(VAR_0, EHCIState, VAR_0);
uint32_t i;
if (VAR_3 + VAR_2 > NB_PORTS) {
qerror_report(QERR_INVALID_PARAMETER_VALUE, "VAR_3",
"VAR_3 on masterbus");
error_printf_unless_qmp(
"VAR_3 value of %u makes companion take VAR_1 %u - %u, which "
"is outside of the valid range of 0 - %u\n", VAR_3, VAR_3,
VAR_3 + VAR_2 - 1, NB_PORTS - 1);
return -1;
}
for (i = 0; i < VAR_2; i++) {
if (s->companion_ports[VAR_3 + i]) {
qerror_report(QERR_INVALID_PARAMETER_VALUE, "masterbus",
"an USB masterbus");
error_printf_unless_qmp(
"port %u on masterbus %s already has a companion assigned\n",
VAR_3 + i, VAR_0->qbus.name);
return -1;
}
}
for (i = 0; i < VAR_2; i++) {
s->companion_ports[VAR_3 + i] = VAR_1[i];
s->VAR_1[VAR_3 + i].speedmask |=
USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL;
s->portsc[VAR_3 + i] = PORTSC_POWNER;
}
s->companion_count++;
s->mmio[0x05] = (s->companion_count << 4) | VAR_2;
return 0;
}
| [
"static int FUNC_0(USBBus *VAR_0, USBPort *VAR_1[],\nuint32_t VAR_2, uint32_t VAR_3)\n{",
"EHCIState *s = container_of(VAR_0, EHCIState, VAR_0);",
"uint32_t i;",
"if (VAR_3 + VAR_2 > NB_PORTS) {",
"qerror_report(QERR_INVALID_PARAMETER_VALUE, \"VAR_3\",\n\"VAR_3 on masterbus\");",
"error_printf_unless_qmp(\n\"VAR_3 value of %u makes companion take VAR_1 %u - %u, which \"\n\"is outside of the valid range of 0 - %u\\n\", VAR_3, VAR_3,\nVAR_3 + VAR_2 - 1, NB_PORTS - 1);",
"return -1;",
"}",
"for (i = 0; i < VAR_2; i++) {",
"if (s->companion_ports[VAR_3 + i]) {",
"qerror_report(QERR_INVALID_PARAMETER_VALUE, \"masterbus\",\n\"an USB masterbus\");",
"error_printf_unless_qmp(\n\"port %u on masterbus %s already has a companion assigned\\n\",\nVAR_3 + i, VAR_0->qbus.name);",
"return -1;",
"}",
"}",
"for (i = 0; i < VAR_2; i++) {",
"s->companion_ports[VAR_3 + i] = VAR_1[i];",
"s->VAR_1[VAR_3 + i].speedmask |=\nUSB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL;",
"s->portsc[VAR_3 + i] = PORTSC_POWNER;",
"}",
"s->companion_count++;",
"s->mmio[0x05] = (s->companion_count << 4) | VAR_2;",
"return 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
],
[
13
],
[
15,
17
],
[
19,
21,
23,
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37,
39
],
[
41,
43,
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59,
61
],
[
65
],
[
67
],
[
71
],
[
73
],
[
77
],
[
79
]
] |
1,725 | static int ehci_execute(EHCIPacket *p, const char *action)
{
USBEndpoint *ep;
int ret;
int endp;
if (!(p->qtd.token & QTD_TOKEN_ACTIVE)) {
fprintf(stderr, "Attempting to execute inactive qtd\n");
return USB_RET_PROCERR;
}
p->tbytes = (p->qtd.token & QTD_TOKEN_TBYTES_MASK) >> QTD_TOKEN_TBYTES_SH;
if (p->tbytes > BUFF_SIZE) {
ehci_trace_guest_bug(p->queue->ehci,
"guest requested more bytes than allowed");
return USB_RET_PROCERR;
}
p->pid = (p->qtd.token & QTD_TOKEN_PID_MASK) >> QTD_TOKEN_PID_SH;
switch (p->pid) {
case 0:
p->pid = USB_TOKEN_OUT;
break;
case 1:
p->pid = USB_TOKEN_IN;
break;
case 2:
p->pid = USB_TOKEN_SETUP;
break;
default:
fprintf(stderr, "bad token\n");
break;
}
if (ehci_init_transfer(p) != 0) {
return USB_RET_PROCERR;
}
endp = get_field(p->queue->qh.epchar, QH_EPCHAR_EP);
ep = usb_ep_get(p->queue->dev, p->pid, endp);
usb_packet_setup(&p->packet, p->pid, ep, p->qtdaddr);
usb_packet_map(&p->packet, &p->sgl);
trace_usb_ehci_packet_action(p->queue, p, action);
ret = usb_handle_packet(p->queue->dev, &p->packet);
DPRINTF("submit: qh %x next %x qtd %x pid %x len %zd "
"(total %d) endp %x ret %d\n",
q->qhaddr, q->qh.next, q->qtdaddr, q->pid,
q->packet.iov.size, q->tbytes, endp, ret);
if (ret > BUFF_SIZE) {
fprintf(stderr, "ret from usb_handle_packet > BUFF_SIZE\n");
return USB_RET_PROCERR;
}
return ret;
}
| true | qemu | ef5b234477df80700b128f561f5877a0688a70c8 | static int ehci_execute(EHCIPacket *p, const char *action)
{
USBEndpoint *ep;
int ret;
int endp;
if (!(p->qtd.token & QTD_TOKEN_ACTIVE)) {
fprintf(stderr, "Attempting to execute inactive qtd\n");
return USB_RET_PROCERR;
}
p->tbytes = (p->qtd.token & QTD_TOKEN_TBYTES_MASK) >> QTD_TOKEN_TBYTES_SH;
if (p->tbytes > BUFF_SIZE) {
ehci_trace_guest_bug(p->queue->ehci,
"guest requested more bytes than allowed");
return USB_RET_PROCERR;
}
p->pid = (p->qtd.token & QTD_TOKEN_PID_MASK) >> QTD_TOKEN_PID_SH;
switch (p->pid) {
case 0:
p->pid = USB_TOKEN_OUT;
break;
case 1:
p->pid = USB_TOKEN_IN;
break;
case 2:
p->pid = USB_TOKEN_SETUP;
break;
default:
fprintf(stderr, "bad token\n");
break;
}
if (ehci_init_transfer(p) != 0) {
return USB_RET_PROCERR;
}
endp = get_field(p->queue->qh.epchar, QH_EPCHAR_EP);
ep = usb_ep_get(p->queue->dev, p->pid, endp);
usb_packet_setup(&p->packet, p->pid, ep, p->qtdaddr);
usb_packet_map(&p->packet, &p->sgl);
trace_usb_ehci_packet_action(p->queue, p, action);
ret = usb_handle_packet(p->queue->dev, &p->packet);
DPRINTF("submit: qh %x next %x qtd %x pid %x len %zd "
"(total %d) endp %x ret %d\n",
q->qhaddr, q->qh.next, q->qtdaddr, q->pid,
q->packet.iov.size, q->tbytes, endp, ret);
if (ret > BUFF_SIZE) {
fprintf(stderr, "ret from usb_handle_packet > BUFF_SIZE\n");
return USB_RET_PROCERR;
}
return ret;
}
| {
"code": [
" if (ehci_init_transfer(p) != 0) {",
" return USB_RET_PROCERR;",
" usb_packet_setup(&p->packet, p->pid, ep, p->qtdaddr);",
" usb_packet_map(&p->packet, &p->sgl);"
],
"line_no": [
69,
17,
83,
85
]
} | static int FUNC_0(EHCIPacket *VAR_0, const char *VAR_1)
{
USBEndpoint *ep;
int VAR_2;
int VAR_3;
if (!(VAR_0->qtd.token & QTD_TOKEN_ACTIVE)) {
fprintf(stderr, "Attempting to execute inactive qtd\n");
return USB_RET_PROCERR;
}
VAR_0->tbytes = (VAR_0->qtd.token & QTD_TOKEN_TBYTES_MASK) >> QTD_TOKEN_TBYTES_SH;
if (VAR_0->tbytes > BUFF_SIZE) {
ehci_trace_guest_bug(VAR_0->queue->ehci,
"guest requested more bytes than allowed");
return USB_RET_PROCERR;
}
VAR_0->pid = (VAR_0->qtd.token & QTD_TOKEN_PID_MASK) >> QTD_TOKEN_PID_SH;
switch (VAR_0->pid) {
case 0:
VAR_0->pid = USB_TOKEN_OUT;
break;
case 1:
VAR_0->pid = USB_TOKEN_IN;
break;
case 2:
VAR_0->pid = USB_TOKEN_SETUP;
break;
default:
fprintf(stderr, "bad token\n");
break;
}
if (ehci_init_transfer(VAR_0) != 0) {
return USB_RET_PROCERR;
}
VAR_3 = get_field(VAR_0->queue->qh.epchar, QH_EPCHAR_EP);
ep = usb_ep_get(VAR_0->queue->dev, VAR_0->pid, VAR_3);
usb_packet_setup(&VAR_0->packet, VAR_0->pid, ep, VAR_0->qtdaddr);
usb_packet_map(&VAR_0->packet, &VAR_0->sgl);
trace_usb_ehci_packet_action(VAR_0->queue, VAR_0, VAR_1);
VAR_2 = usb_handle_packet(VAR_0->queue->dev, &VAR_0->packet);
DPRINTF("submit: qh %x next %x qtd %x pid %x len %zd "
"(total %d) VAR_3 %x VAR_2 %d\n",
q->qhaddr, q->qh.next, q->qtdaddr, q->pid,
q->packet.iov.size, q->tbytes, VAR_3, VAR_2);
if (VAR_2 > BUFF_SIZE) {
fprintf(stderr, "VAR_2 from usb_handle_packet > BUFF_SIZE\n");
return USB_RET_PROCERR;
}
return VAR_2;
}
| [
"static int FUNC_0(EHCIPacket *VAR_0, const char *VAR_1)\n{",
"USBEndpoint *ep;",
"int VAR_2;",
"int VAR_3;",
"if (!(VAR_0->qtd.token & QTD_TOKEN_ACTIVE)) {",
"fprintf(stderr, \"Attempting to execute inactive qtd\\n\");",
"return USB_RET_PROCERR;",
"}",
"VAR_0->tbytes = (VAR_0->qtd.token & QTD_TOKEN_TBYTES_MASK) >> QTD_TOKEN_TBYTES_SH;",
"if (VAR_0->tbytes > BUFF_SIZE) {",
"ehci_trace_guest_bug(VAR_0->queue->ehci,\n\"guest requested more bytes than allowed\");",
"return USB_RET_PROCERR;",
"}",
"VAR_0->pid = (VAR_0->qtd.token & QTD_TOKEN_PID_MASK) >> QTD_TOKEN_PID_SH;",
"switch (VAR_0->pid) {",
"case 0:\nVAR_0->pid = USB_TOKEN_OUT;",
"break;",
"case 1:\nVAR_0->pid = USB_TOKEN_IN;",
"break;",
"case 2:\nVAR_0->pid = USB_TOKEN_SETUP;",
"break;",
"default:\nfprintf(stderr, \"bad token\\n\");",
"break;",
"}",
"if (ehci_init_transfer(VAR_0) != 0) {",
"return USB_RET_PROCERR;",
"}",
"VAR_3 = get_field(VAR_0->queue->qh.epchar, QH_EPCHAR_EP);",
"ep = usb_ep_get(VAR_0->queue->dev, VAR_0->pid, VAR_3);",
"usb_packet_setup(&VAR_0->packet, VAR_0->pid, ep, VAR_0->qtdaddr);",
"usb_packet_map(&VAR_0->packet, &VAR_0->sgl);",
"trace_usb_ehci_packet_action(VAR_0->queue, VAR_0, VAR_1);",
"VAR_2 = usb_handle_packet(VAR_0->queue->dev, &VAR_0->packet);",
"DPRINTF(\"submit: qh %x next %x qtd %x pid %x len %zd \"\n\"(total %d) VAR_3 %x VAR_2 %d\\n\",\nq->qhaddr, q->qh.next, q->qtdaddr, q->pid,\nq->packet.iov.size, q->tbytes, VAR_3, VAR_2);",
"if (VAR_2 > BUFF_SIZE) {",
"fprintf(stderr, \"VAR_2 from usb_handle_packet > BUFF_SIZE\\n\");",
"return USB_RET_PROCERR;",
"}",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47,
49
],
[
51
],
[
53,
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93,
95,
97,
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115
]
] |
1,727 | int ff_ivi_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
AVPacket *avpkt)
{
IVI45DecContext *ctx = avctx->priv_data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
int result, p, b;
init_get_bits(&ctx->gb, buf, buf_size * 8);
ctx->frame_data = buf;
ctx->frame_size = buf_size;
result = ctx->decode_pic_hdr(ctx, avctx);
if (result) {
av_log(avctx, AV_LOG_ERROR,
"Error while decoding picture header: %d\n", result);
return -1;
}
if (ctx->gop_invalid)
return AVERROR_INVALIDDATA;
if (ctx->gop_flags & IVI5_IS_PROTECTED) {
av_log(avctx, AV_LOG_ERROR, "Password-protected clip!\n");
return -1;
}
ctx->switch_buffers(ctx);
//{ START_TIMER;
if (ctx->is_nonnull_frame(ctx)) {
for (p = 0; p < 3; p++) {
for (b = 0; b < ctx->planes[p].num_bands; b++) {
result = decode_band(ctx, p, &ctx->planes[p].bands[b], avctx);
if (result) {
av_log(avctx, AV_LOG_ERROR,
"Error while decoding band: %d, plane: %d\n", b, p);
return -1;
}
}
}
}
//STOP_TIMER("decode_planes"); }
/* If the bidirectional mode is enabled, next I and the following P frame will */
/* be sent together. Unfortunately the approach below seems to be the only way */
/* to handle the B-frames mode. That's exactly the same Intel decoders do. */
if (avctx->codec_id == AV_CODEC_ID_INDEO4 && ctx->frame_type == 0/*FRAMETYPE_INTRA*/) {
while (get_bits(&ctx->gb, 8)); // skip version string
skip_bits_long(&ctx->gb, 64); // skip padding, TODO: implement correct 8-bytes alignment
if (get_bits_left(&ctx->gb) > 18 && show_bits(&ctx->gb, 18) == 0x3FFF8)
av_log(avctx, AV_LOG_ERROR, "Buffer contains IP frames!\n");
}
if (ctx->frame.data[0])
avctx->release_buffer(avctx, &ctx->frame);
ctx->frame.reference = 0;
if ((result = avctx->get_buffer(avctx, &ctx->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return result;
}
if (ctx->is_scalable) {
if (avctx->codec_id == AV_CODEC_ID_INDEO4)
ff_ivi_recompose_haar(&ctx->planes[0], ctx->frame.data[0], ctx->frame.linesize[0], 4);
else
ff_ivi_recompose53 (&ctx->planes[0], ctx->frame.data[0], ctx->frame.linesize[0], 4);
} else {
ff_ivi_output_plane(&ctx->planes[0], ctx->frame.data[0], ctx->frame.linesize[0]);
}
ff_ivi_output_plane(&ctx->planes[2], ctx->frame.data[1], ctx->frame.linesize[1]);
ff_ivi_output_plane(&ctx->planes[1], ctx->frame.data[2], ctx->frame.linesize[2]);
*data_size = sizeof(AVFrame);
*(AVFrame*)data = ctx->frame;
return buf_size;
} | true | FFmpeg | b146d74730ab9ec5abede9066f770ad851e45fbc | int ff_ivi_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
AVPacket *avpkt)
{
IVI45DecContext *ctx = avctx->priv_data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
int result, p, b;
init_get_bits(&ctx->gb, buf, buf_size * 8);
ctx->frame_data = buf;
ctx->frame_size = buf_size;
result = ctx->decode_pic_hdr(ctx, avctx);
if (result) {
av_log(avctx, AV_LOG_ERROR,
"Error while decoding picture header: %d\n", result);
return -1;
}
if (ctx->gop_invalid)
return AVERROR_INVALIDDATA;
if (ctx->gop_flags & IVI5_IS_PROTECTED) {
av_log(avctx, AV_LOG_ERROR, "Password-protected clip!\n");
return -1;
}
ctx->switch_buffers(ctx);
if (ctx->is_nonnull_frame(ctx)) {
for (p = 0; p < 3; p++) {
for (b = 0; b < ctx->planes[p].num_bands; b++) {
result = decode_band(ctx, p, &ctx->planes[p].bands[b], avctx);
if (result) {
av_log(avctx, AV_LOG_ERROR,
"Error while decoding band: %d, plane: %d\n", b, p);
return -1;
}
}
}
}
if (avctx->codec_id == AV_CODEC_ID_INDEO4 && ctx->frame_type == 0) {
while (get_bits(&ctx->gb, 8));
skip_bits_long(&ctx->gb, 64);
if (get_bits_left(&ctx->gb) > 18 && show_bits(&ctx->gb, 18) == 0x3FFF8)
av_log(avctx, AV_LOG_ERROR, "Buffer contains IP frames!\n");
}
if (ctx->frame.data[0])
avctx->release_buffer(avctx, &ctx->frame);
ctx->frame.reference = 0;
if ((result = avctx->get_buffer(avctx, &ctx->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return result;
}
if (ctx->is_scalable) {
if (avctx->codec_id == AV_CODEC_ID_INDEO4)
ff_ivi_recompose_haar(&ctx->planes[0], ctx->frame.data[0], ctx->frame.linesize[0], 4);
else
ff_ivi_recompose53 (&ctx->planes[0], ctx->frame.data[0], ctx->frame.linesize[0], 4);
} else {
ff_ivi_output_plane(&ctx->planes[0], ctx->frame.data[0], ctx->frame.linesize[0]);
}
ff_ivi_output_plane(&ctx->planes[2], ctx->frame.data[1], ctx->frame.linesize[1]);
ff_ivi_output_plane(&ctx->planes[1], ctx->frame.data[2], ctx->frame.linesize[2]);
*data_size = sizeof(AVFrame);
*(AVFrame*)data = ctx->frame;
return buf_size;
} | {
"code": [],
"line_no": []
} | int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
IVI45DecContext *ctx = VAR_0->priv_data;
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
int VAR_6, VAR_7, VAR_8;
init_get_bits(&ctx->gb, VAR_4, VAR_5 * 8);
ctx->frame_data = VAR_4;
ctx->frame_size = VAR_5;
VAR_6 = ctx->decode_pic_hdr(ctx, VAR_0);
if (VAR_6) {
av_log(VAR_0, AV_LOG_ERROR,
"Error while decoding picture header: %d\n", VAR_6);
return -1;
}
if (ctx->gop_invalid)
return AVERROR_INVALIDDATA;
if (ctx->gop_flags & IVI5_IS_PROTECTED) {
av_log(VAR_0, AV_LOG_ERROR, "Password-protected clip!\n");
return -1;
}
ctx->switch_buffers(ctx);
if (ctx->is_nonnull_frame(ctx)) {
for (VAR_7 = 0; VAR_7 < 3; VAR_7++) {
for (VAR_8 = 0; VAR_8 < ctx->planes[VAR_7].num_bands; VAR_8++) {
VAR_6 = decode_band(ctx, VAR_7, &ctx->planes[VAR_7].bands[VAR_8], VAR_0);
if (VAR_6) {
av_log(VAR_0, AV_LOG_ERROR,
"Error while decoding band: %d, plane: %d\n", VAR_8, VAR_7);
return -1;
}
}
}
}
if (VAR_0->codec_id == AV_CODEC_ID_INDEO4 && ctx->frame_type == 0) {
while (get_bits(&ctx->gb, 8));
skip_bits_long(&ctx->gb, 64);
if (get_bits_left(&ctx->gb) > 18 && show_bits(&ctx->gb, 18) == 0x3FFF8)
av_log(VAR_0, AV_LOG_ERROR, "Buffer contains IP frames!\n");
}
if (ctx->frame.VAR_1[0])
VAR_0->release_buffer(VAR_0, &ctx->frame);
ctx->frame.reference = 0;
if ((VAR_6 = VAR_0->get_buffer(VAR_0, &ctx->frame)) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");
return VAR_6;
}
if (ctx->is_scalable) {
if (VAR_0->codec_id == AV_CODEC_ID_INDEO4)
ff_ivi_recompose_haar(&ctx->planes[0], ctx->frame.VAR_1[0], ctx->frame.linesize[0], 4);
else
ff_ivi_recompose53 (&ctx->planes[0], ctx->frame.VAR_1[0], ctx->frame.linesize[0], 4);
} else {
ff_ivi_output_plane(&ctx->planes[0], ctx->frame.VAR_1[0], ctx->frame.linesize[0]);
}
ff_ivi_output_plane(&ctx->planes[2], ctx->frame.VAR_1[1], ctx->frame.linesize[1]);
ff_ivi_output_plane(&ctx->planes[1], ctx->frame.VAR_1[2], ctx->frame.linesize[2]);
*VAR_2 = sizeof(AVFrame);
*(AVFrame*)VAR_1 = ctx->frame;
return VAR_5;
} | [
"int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"IVI45DecContext *ctx = VAR_0->priv_data;",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"int VAR_6, VAR_7, VAR_8;",
"init_get_bits(&ctx->gb, VAR_4, VAR_5 * 8);",
"ctx->frame_data = VAR_4;",
"ctx->frame_size = VAR_5;",
"VAR_6 = ctx->decode_pic_hdr(ctx, VAR_0);",
"if (VAR_6) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Error while decoding picture header: %d\\n\", VAR_6);",
"return -1;",
"}",
"if (ctx->gop_invalid)\nreturn AVERROR_INVALIDDATA;",
"if (ctx->gop_flags & IVI5_IS_PROTECTED) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Password-protected clip!\\n\");",
"return -1;",
"}",
"ctx->switch_buffers(ctx);",
"if (ctx->is_nonnull_frame(ctx)) {",
"for (VAR_7 = 0; VAR_7 < 3; VAR_7++) {",
"for (VAR_8 = 0; VAR_8 < ctx->planes[VAR_7].num_bands; VAR_8++) {",
"VAR_6 = decode_band(ctx, VAR_7, &ctx->planes[VAR_7].bands[VAR_8], VAR_0);",
"if (VAR_6) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Error while decoding band: %d, plane: %d\\n\", VAR_8, VAR_7);",
"return -1;",
"}",
"}",
"}",
"}",
"if (VAR_0->codec_id == AV_CODEC_ID_INDEO4 && ctx->frame_type == 0) {",
"while (get_bits(&ctx->gb, 8));",
"skip_bits_long(&ctx->gb, 64);",
"if (get_bits_left(&ctx->gb) > 18 && show_bits(&ctx->gb, 18) == 0x3FFF8)\nav_log(VAR_0, AV_LOG_ERROR, \"Buffer contains IP frames!\\n\");",
"}",
"if (ctx->frame.VAR_1[0])\nVAR_0->release_buffer(VAR_0, &ctx->frame);",
"ctx->frame.reference = 0;",
"if ((VAR_6 = VAR_0->get_buffer(VAR_0, &ctx->frame)) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"get_buffer() failed\\n\");",
"return VAR_6;",
"}",
"if (ctx->is_scalable) {",
"if (VAR_0->codec_id == AV_CODEC_ID_INDEO4)\nff_ivi_recompose_haar(&ctx->planes[0], ctx->frame.VAR_1[0], ctx->frame.linesize[0], 4);",
"else\nff_ivi_recompose53 (&ctx->planes[0], ctx->frame.VAR_1[0], ctx->frame.linesize[0], 4);",
"} else {",
"ff_ivi_output_plane(&ctx->planes[0], ctx->frame.VAR_1[0], ctx->frame.linesize[0]);",
"}",
"ff_ivi_output_plane(&ctx->planes[2], ctx->frame.VAR_1[1], ctx->frame.linesize[1]);",
"ff_ivi_output_plane(&ctx->planes[1], ctx->frame.VAR_1[2], ctx->frame.linesize[2]);",
"*VAR_2 = sizeof(AVFrame);",
"*(AVFrame*)VAR_1 = ctx->frame;",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37,
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
97
],
[
99
],
[
101
],
[
103,
105
],
[
107
],
[
111,
113
],
[
117
],
[
120
],
[
122
],
[
124
],
[
126
],
[
130
],
[
132,
134
],
[
136,
138
],
[
140
],
[
142
],
[
144
],
[
148
],
[
150
],
[
154
],
[
156
],
[
160
],
[
162
]
] |
1,728 | static int avcodec_find_best_pix_fmt1(int64_t pix_fmt_mask,
int src_pix_fmt,
int has_alpha,
int loss_mask)
{
int dist, i, loss, min_dist, dst_pix_fmt;
/* find exact color match with smallest size */
dst_pix_fmt = -1;
min_dist = 0x7fffffff;
for(i = 0;i < PIX_FMT_NB; i++) {
if (pix_fmt_mask & (1 << i)) {
loss = avcodec_get_pix_fmt_loss(i, src_pix_fmt, has_alpha) & loss_mask;
if (loss == 0) {
dist = avg_bits_per_pixel(i);
if (dist < min_dist) {
min_dist = dist;
dst_pix_fmt = i;
}
}
}
}
return dst_pix_fmt;
}
| true | FFmpeg | 31c3a4dc7e15f993b0076c7231f80249a55ea146 | static int avcodec_find_best_pix_fmt1(int64_t pix_fmt_mask,
int src_pix_fmt,
int has_alpha,
int loss_mask)
{
int dist, i, loss, min_dist, dst_pix_fmt;
dst_pix_fmt = -1;
min_dist = 0x7fffffff;
for(i = 0;i < PIX_FMT_NB; i++) {
if (pix_fmt_mask & (1 << i)) {
loss = avcodec_get_pix_fmt_loss(i, src_pix_fmt, has_alpha) & loss_mask;
if (loss == 0) {
dist = avg_bits_per_pixel(i);
if (dist < min_dist) {
min_dist = dist;
dst_pix_fmt = i;
}
}
}
}
return dst_pix_fmt;
}
| {
"code": [
" if (pix_fmt_mask & (1 << i)) {"
],
"line_no": [
23
]
} | static int FUNC_0(int64_t VAR_0,
int VAR_1,
int VAR_2,
int VAR_3)
{
int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;
VAR_8 = -1;
VAR_7 = 0x7fffffff;
for(VAR_5 = 0;VAR_5 < PIX_FMT_NB; VAR_5++) {
if (VAR_0 & (1 << VAR_5)) {
VAR_6 = avcodec_get_pix_fmt_loss(VAR_5, VAR_1, VAR_2) & VAR_3;
if (VAR_6 == 0) {
VAR_4 = avg_bits_per_pixel(VAR_5);
if (VAR_4 < VAR_7) {
VAR_7 = VAR_4;
VAR_8 = VAR_5;
}
}
}
}
return VAR_8;
}
| [
"static int FUNC_0(int64_t VAR_0,\nint VAR_1,\nint VAR_2,\nint VAR_3)\n{",
"int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;",
"VAR_8 = -1;",
"VAR_7 = 0x7fffffff;",
"for(VAR_5 = 0;VAR_5 < PIX_FMT_NB; VAR_5++) {",
"if (VAR_0 & (1 << VAR_5)) {",
"VAR_6 = avcodec_get_pix_fmt_loss(VAR_5, VAR_1, VAR_2) & VAR_3;",
"if (VAR_6 == 0) {",
"VAR_4 = avg_bits_per_pixel(VAR_5);",
"if (VAR_4 < VAR_7) {",
"VAR_7 = VAR_4;",
"VAR_8 = VAR_5;",
"}",
"}",
"}",
"}",
"return VAR_8;",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
]
] |
1,729 | static int vorbis_parse_audio_packet(vorbis_context *vc)
{
GetBitContext *gb = &vc->gb;
FFTContext *mdct;
unsigned previous_window = vc->previous_window;
unsigned mode_number, blockflag, blocksize;
int i, j;
uint8_t no_residue[255];
uint8_t do_not_decode[255];
vorbis_mapping *mapping;
float *ch_res_ptr = vc->channel_residues;
float *ch_floor_ptr = vc->channel_floors;
uint8_t res_chan[255];
unsigned res_num = 0;
int retlen = 0;
int ch_left = vc->audio_channels;
if (get_bits1(gb)) {
av_log(vc->avccontext, AV_LOG_ERROR, "Not a Vorbis I audio packet.\n");
return AVERROR_INVALIDDATA; // packet type not audio
}
if (vc->mode_count == 1) {
mode_number = 0;
} else {
GET_VALIDATED_INDEX(mode_number, ilog(vc->mode_count-1), vc->mode_count)
}
vc->mode_number = mode_number;
mapping = &vc->mappings[vc->modes[mode_number].mapping];
av_dlog(NULL, " Mode number: %u , mapping: %d , blocktype %d\n", mode_number,
vc->modes[mode_number].mapping, vc->modes[mode_number].blockflag);
blockflag = vc->modes[mode_number].blockflag;
blocksize = vc->blocksize[blockflag];
if (blockflag)
skip_bits(gb, 2); // previous_window, next_window
memset(ch_res_ptr, 0, sizeof(float) * vc->audio_channels * blocksize / 2); //FIXME can this be removed ?
memset(ch_floor_ptr, 0, sizeof(float) * vc->audio_channels * blocksize / 2); //FIXME can this be removed ?
// Decode floor
for (i = 0; i < vc->audio_channels; ++i) {
vorbis_floor *floor;
int ret;
if (mapping->submaps > 1) {
floor = &vc->floors[mapping->submap_floor[mapping->mux[i]]];
} else {
floor = &vc->floors[mapping->submap_floor[0]];
}
ret = floor->decode(vc, &floor->data, ch_floor_ptr);
if (ret < 0) {
av_log(vc->avccontext, AV_LOG_ERROR, "Invalid codebook in vorbis_floor_decode.\n");
return AVERROR_INVALIDDATA;
}
no_residue[i] = ret;
ch_floor_ptr += blocksize / 2;
}
// Nonzero vector propagate
for (i = mapping->coupling_steps - 1; i >= 0; --i) {
if (!(no_residue[mapping->magnitude[i]] & no_residue[mapping->angle[i]])) {
no_residue[mapping->magnitude[i]] = 0;
no_residue[mapping->angle[i]] = 0;
}
}
// Decode residue
for (i = 0; i < mapping->submaps; ++i) {
vorbis_residue *residue;
unsigned ch = 0;
for (j = 0; j < vc->audio_channels; ++j) {
if ((mapping->submaps == 1) || (i == mapping->mux[j])) {
res_chan[j] = res_num;
if (no_residue[j]) {
do_not_decode[ch] = 1;
} else {
do_not_decode[ch] = 0;
}
++ch;
++res_num;
}
}
residue = &vc->residues[mapping->submap_residue[i]];
if (ch_left < ch) {
av_log(vc->avccontext, AV_LOG_ERROR, "Too many channels in vorbis_floor_decode.\n");
return -1;
}
vorbis_residue_decode(vc, residue, ch, do_not_decode, ch_res_ptr, blocksize/2);
ch_res_ptr += ch * blocksize / 2;
ch_left -= ch;
}
// Inverse coupling
for (i = mapping->coupling_steps - 1; i >= 0; --i) { //warning: i has to be signed
float *mag, *ang;
mag = vc->channel_residues+res_chan[mapping->magnitude[i]] * blocksize / 2;
ang = vc->channel_residues+res_chan[mapping->angle[i]] * blocksize / 2;
vc->dsp.vorbis_inverse_coupling(mag, ang, blocksize / 2);
}
// Dotproduct, MDCT
mdct = &vc->mdct[blockflag];
for (j = vc->audio_channels-1;j >= 0; j--) {
ch_floor_ptr = vc->channel_floors + j * blocksize / 2;
ch_res_ptr = vc->channel_residues + res_chan[j] * blocksize / 2;
vc->dsp.vector_fmul(ch_floor_ptr, ch_floor_ptr, ch_res_ptr, blocksize / 2);
mdct->imdct_half(mdct, ch_res_ptr, ch_floor_ptr);
}
// Overlap/add, save data for next overlapping FPMATH
retlen = (blocksize + vc->blocksize[previous_window]) / 4;
for (j = 0; j < vc->audio_channels; j++) {
unsigned bs0 = vc->blocksize[0];
unsigned bs1 = vc->blocksize[1];
float *residue = vc->channel_residues + res_chan[j] * blocksize / 2;
float *saved = vc->saved + j * bs1 / 4;
float *ret = vc->channel_floors + j * retlen;
float *buf = residue;
const float *win = vc->win[blockflag & previous_window];
if (blockflag == previous_window) {
vc->dsp.vector_fmul_window(ret, saved, buf, win, blocksize / 4);
} else if (blockflag > previous_window) {
vc->dsp.vector_fmul_window(ret, saved, buf, win, bs0 / 4);
memcpy(ret+bs0/2, buf+bs0/4, ((bs1-bs0)/4) * sizeof(float));
} else {
memcpy(ret, saved, ((bs1 - bs0) / 4) * sizeof(float));
vc->dsp.vector_fmul_window(ret + (bs1 - bs0) / 4, saved + (bs1 - bs0) / 4, buf, win, bs0 / 4);
}
memcpy(saved, buf + blocksize / 4, blocksize / 4 * sizeof(float));
}
vc->previous_window = blockflag;
return retlen;
}
| true | FFmpeg | f74ce3a60d6ef49080df85c44b54280357109f56 | static int vorbis_parse_audio_packet(vorbis_context *vc)
{
GetBitContext *gb = &vc->gb;
FFTContext *mdct;
unsigned previous_window = vc->previous_window;
unsigned mode_number, blockflag, blocksize;
int i, j;
uint8_t no_residue[255];
uint8_t do_not_decode[255];
vorbis_mapping *mapping;
float *ch_res_ptr = vc->channel_residues;
float *ch_floor_ptr = vc->channel_floors;
uint8_t res_chan[255];
unsigned res_num = 0;
int retlen = 0;
int ch_left = vc->audio_channels;
if (get_bits1(gb)) {
av_log(vc->avccontext, AV_LOG_ERROR, "Not a Vorbis I audio packet.\n");
return AVERROR_INVALIDDATA;
}
if (vc->mode_count == 1) {
mode_number = 0;
} else {
GET_VALIDATED_INDEX(mode_number, ilog(vc->mode_count-1), vc->mode_count)
}
vc->mode_number = mode_number;
mapping = &vc->mappings[vc->modes[mode_number].mapping];
av_dlog(NULL, " Mode number: %u , mapping: %d , blocktype %d\n", mode_number,
vc->modes[mode_number].mapping, vc->modes[mode_number].blockflag);
blockflag = vc->modes[mode_number].blockflag;
blocksize = vc->blocksize[blockflag];
if (blockflag)
skip_bits(gb, 2);
memset(ch_res_ptr, 0, sizeof(float) * vc->audio_channels * blocksize / 2);
memset(ch_floor_ptr, 0, sizeof(float) * vc->audio_channels * blocksize / 2);
for (i = 0; i < vc->audio_channels; ++i) {
vorbis_floor *floor;
int ret;
if (mapping->submaps > 1) {
floor = &vc->floors[mapping->submap_floor[mapping->mux[i]]];
} else {
floor = &vc->floors[mapping->submap_floor[0]];
}
ret = floor->decode(vc, &floor->data, ch_floor_ptr);
if (ret < 0) {
av_log(vc->avccontext, AV_LOG_ERROR, "Invalid codebook in vorbis_floor_decode.\n");
return AVERROR_INVALIDDATA;
}
no_residue[i] = ret;
ch_floor_ptr += blocksize / 2;
}
for (i = mapping->coupling_steps - 1; i >= 0; --i) {
if (!(no_residue[mapping->magnitude[i]] & no_residue[mapping->angle[i]])) {
no_residue[mapping->magnitude[i]] = 0;
no_residue[mapping->angle[i]] = 0;
}
}
for (i = 0; i < mapping->submaps; ++i) {
vorbis_residue *residue;
unsigned ch = 0;
for (j = 0; j < vc->audio_channels; ++j) {
if ((mapping->submaps == 1) || (i == mapping->mux[j])) {
res_chan[j] = res_num;
if (no_residue[j]) {
do_not_decode[ch] = 1;
} else {
do_not_decode[ch] = 0;
}
++ch;
++res_num;
}
}
residue = &vc->residues[mapping->submap_residue[i]];
if (ch_left < ch) {
av_log(vc->avccontext, AV_LOG_ERROR, "Too many channels in vorbis_floor_decode.\n");
return -1;
}
vorbis_residue_decode(vc, residue, ch, do_not_decode, ch_res_ptr, blocksize/2);
ch_res_ptr += ch * blocksize / 2;
ch_left -= ch;
}
for (i = mapping->coupling_steps - 1; i >= 0; --i) {
float *mag, *ang;
mag = vc->channel_residues+res_chan[mapping->magnitude[i]] * blocksize / 2;
ang = vc->channel_residues+res_chan[mapping->angle[i]] * blocksize / 2;
vc->dsp.vorbis_inverse_coupling(mag, ang, blocksize / 2);
}
mdct = &vc->mdct[blockflag];
for (j = vc->audio_channels-1;j >= 0; j--) {
ch_floor_ptr = vc->channel_floors + j * blocksize / 2;
ch_res_ptr = vc->channel_residues + res_chan[j] * blocksize / 2;
vc->dsp.vector_fmul(ch_floor_ptr, ch_floor_ptr, ch_res_ptr, blocksize / 2);
mdct->imdct_half(mdct, ch_res_ptr, ch_floor_ptr);
}
retlen = (blocksize + vc->blocksize[previous_window]) / 4;
for (j = 0; j < vc->audio_channels; j++) {
unsigned bs0 = vc->blocksize[0];
unsigned bs1 = vc->blocksize[1];
float *residue = vc->channel_residues + res_chan[j] * blocksize / 2;
float *saved = vc->saved + j * bs1 / 4;
float *ret = vc->channel_floors + j * retlen;
float *buf = residue;
const float *win = vc->win[blockflag & previous_window];
if (blockflag == previous_window) {
vc->dsp.vector_fmul_window(ret, saved, buf, win, blocksize / 4);
} else if (blockflag > previous_window) {
vc->dsp.vector_fmul_window(ret, saved, buf, win, bs0 / 4);
memcpy(ret+bs0/2, buf+bs0/4, ((bs1-bs0)/4) * sizeof(float));
} else {
memcpy(ret, saved, ((bs1 - bs0) / 4) * sizeof(float));
vc->dsp.vector_fmul_window(ret + (bs1 - bs0) / 4, saved + (bs1 - bs0) / 4, buf, win, bs0 / 4);
}
memcpy(saved, buf + blocksize / 4, blocksize / 4 * sizeof(float));
}
vc->previous_window = blockflag;
return retlen;
}
| {
"code": [
" int ch_left = vc->audio_channels;",
" ch_floor_ptr += blocksize / 2;",
" vorbis_residue_decode(vc, residue, ch, do_not_decode, ch_res_ptr, blocksize/2);",
" ch_res_ptr += ch * blocksize / 2;"
],
"line_no": [
31,
119,
189,
193
]
} | static int FUNC_0(vorbis_context *VAR_0)
{
GetBitContext *gb = &VAR_0->gb;
FFTContext *mdct;
unsigned VAR_1 = VAR_0->VAR_1;
unsigned VAR_2, VAR_3, VAR_4;
int VAR_5, VAR_6;
uint8_t no_residue[255];
uint8_t do_not_decode[255];
vorbis_mapping *mapping;
float *VAR_7 = VAR_0->channel_residues;
float *VAR_8 = VAR_0->channel_floors;
uint8_t res_chan[255];
unsigned VAR_9 = 0;
int VAR_10 = 0;
int VAR_11 = VAR_0->audio_channels;
if (get_bits1(gb)) {
av_log(VAR_0->avccontext, AV_LOG_ERROR, "Not a Vorbis I audio packet.\n");
return AVERROR_INVALIDDATA;
}
if (VAR_0->mode_count == 1) {
VAR_2 = 0;
} else {
GET_VALIDATED_INDEX(VAR_2, ilog(VAR_0->mode_count-1), VAR_0->mode_count)
}
VAR_0->VAR_2 = VAR_2;
mapping = &VAR_0->mappings[VAR_0->modes[VAR_2].mapping];
av_dlog(NULL, " Mode number: %u , mapping: %d , blocktype %d\n", VAR_2,
VAR_0->modes[VAR_2].mapping, VAR_0->modes[VAR_2].VAR_3);
VAR_3 = VAR_0->modes[VAR_2].VAR_3;
VAR_4 = VAR_0->VAR_4[VAR_3];
if (VAR_3)
skip_bits(gb, 2);
memset(VAR_7, 0, sizeof(float) * VAR_0->audio_channels * VAR_4 / 2);
memset(VAR_8, 0, sizeof(float) * VAR_0->audio_channels * VAR_4 / 2);
for (VAR_5 = 0; VAR_5 < VAR_0->audio_channels; ++VAR_5) {
vorbis_floor *floor;
int ret;
if (mapping->submaps > 1) {
floor = &VAR_0->floors[mapping->submap_floor[mapping->mux[VAR_5]]];
} else {
floor = &VAR_0->floors[mapping->submap_floor[0]];
}
ret = floor->decode(VAR_0, &floor->data, VAR_8);
if (ret < 0) {
av_log(VAR_0->avccontext, AV_LOG_ERROR, "Invalid codebook in vorbis_floor_decode.\n");
return AVERROR_INVALIDDATA;
}
no_residue[VAR_5] = ret;
VAR_8 += VAR_4 / 2;
}
for (VAR_5 = mapping->coupling_steps - 1; VAR_5 >= 0; --VAR_5) {
if (!(no_residue[mapping->magnitude[VAR_5]] & no_residue[mapping->angle[VAR_5]])) {
no_residue[mapping->magnitude[VAR_5]] = 0;
no_residue[mapping->angle[VAR_5]] = 0;
}
}
for (VAR_5 = 0; VAR_5 < mapping->submaps; ++VAR_5) {
vorbis_residue *residue;
unsigned ch = 0;
for (VAR_6 = 0; VAR_6 < VAR_0->audio_channels; ++VAR_6) {
if ((mapping->submaps == 1) || (VAR_5 == mapping->mux[VAR_6])) {
res_chan[VAR_6] = VAR_9;
if (no_residue[VAR_6]) {
do_not_decode[ch] = 1;
} else {
do_not_decode[ch] = 0;
}
++ch;
++VAR_9;
}
}
residue = &VAR_0->residues[mapping->submap_residue[VAR_5]];
if (VAR_11 < ch) {
av_log(VAR_0->avccontext, AV_LOG_ERROR, "Too many channels in vorbis_floor_decode.\n");
return -1;
}
vorbis_residue_decode(VAR_0, residue, ch, do_not_decode, VAR_7, VAR_4/2);
VAR_7 += ch * VAR_4 / 2;
VAR_11 -= ch;
}
for (VAR_5 = mapping->coupling_steps - 1; VAR_5 >= 0; --VAR_5) {
float *VAR_12, *VAR_13;
VAR_12 = VAR_0->channel_residues+res_chan[mapping->magnitude[VAR_5]] * VAR_4 / 2;
VAR_13 = VAR_0->channel_residues+res_chan[mapping->angle[VAR_5]] * VAR_4 / 2;
VAR_0->dsp.vorbis_inverse_coupling(VAR_12, VAR_13, VAR_4 / 2);
}
mdct = &VAR_0->mdct[VAR_3];
for (VAR_6 = VAR_0->audio_channels-1;VAR_6 >= 0; VAR_6--) {
VAR_8 = VAR_0->channel_floors + VAR_6 * VAR_4 / 2;
VAR_7 = VAR_0->channel_residues + res_chan[VAR_6] * VAR_4 / 2;
VAR_0->dsp.vector_fmul(VAR_8, VAR_8, VAR_7, VAR_4 / 2);
mdct->imdct_half(mdct, VAR_7, VAR_8);
}
VAR_10 = (VAR_4 + VAR_0->VAR_4[VAR_1]) / 4;
for (VAR_6 = 0; VAR_6 < VAR_0->audio_channels; VAR_6++) {
unsigned bs0 = VAR_0->VAR_4[0];
unsigned bs1 = VAR_0->VAR_4[1];
float *residue = VAR_0->channel_residues + res_chan[VAR_6] * VAR_4 / 2;
float *saved = VAR_0->saved + VAR_6 * bs1 / 4;
float *ret = VAR_0->channel_floors + VAR_6 * VAR_10;
float *buf = residue;
const float *win = VAR_0->win[VAR_3 & VAR_1];
if (VAR_3 == VAR_1) {
VAR_0->dsp.vector_fmul_window(ret, saved, buf, win, VAR_4 / 4);
} else if (VAR_3 > VAR_1) {
VAR_0->dsp.vector_fmul_window(ret, saved, buf, win, bs0 / 4);
memcpy(ret+bs0/2, buf+bs0/4, ((bs1-bs0)/4) * sizeof(float));
} else {
memcpy(ret, saved, ((bs1 - bs0) / 4) * sizeof(float));
VAR_0->dsp.vector_fmul_window(ret + (bs1 - bs0) / 4, saved + (bs1 - bs0) / 4, buf, win, bs0 / 4);
}
memcpy(saved, buf + VAR_4 / 4, VAR_4 / 4 * sizeof(float));
}
VAR_0->VAR_1 = VAR_3;
return VAR_10;
}
| [
"static int FUNC_0(vorbis_context *VAR_0)\n{",
"GetBitContext *gb = &VAR_0->gb;",
"FFTContext *mdct;",
"unsigned VAR_1 = VAR_0->VAR_1;",
"unsigned VAR_2, VAR_3, VAR_4;",
"int VAR_5, VAR_6;",
"uint8_t no_residue[255];",
"uint8_t do_not_decode[255];",
"vorbis_mapping *mapping;",
"float *VAR_7 = VAR_0->channel_residues;",
"float *VAR_8 = VAR_0->channel_floors;",
"uint8_t res_chan[255];",
"unsigned VAR_9 = 0;",
"int VAR_10 = 0;",
"int VAR_11 = VAR_0->audio_channels;",
"if (get_bits1(gb)) {",
"av_log(VAR_0->avccontext, AV_LOG_ERROR, \"Not a Vorbis I audio packet.\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_0->mode_count == 1) {",
"VAR_2 = 0;",
"} else {",
"GET_VALIDATED_INDEX(VAR_2, ilog(VAR_0->mode_count-1), VAR_0->mode_count)\n}",
"VAR_0->VAR_2 = VAR_2;",
"mapping = &VAR_0->mappings[VAR_0->modes[VAR_2].mapping];",
"av_dlog(NULL, \" Mode number: %u , mapping: %d , blocktype %d\\n\", VAR_2,\nVAR_0->modes[VAR_2].mapping, VAR_0->modes[VAR_2].VAR_3);",
"VAR_3 = VAR_0->modes[VAR_2].VAR_3;",
"VAR_4 = VAR_0->VAR_4[VAR_3];",
"if (VAR_3)\nskip_bits(gb, 2);",
"memset(VAR_7, 0, sizeof(float) * VAR_0->audio_channels * VAR_4 / 2);",
"memset(VAR_8, 0, sizeof(float) * VAR_0->audio_channels * VAR_4 / 2);",
"for (VAR_5 = 0; VAR_5 < VAR_0->audio_channels; ++VAR_5) {",
"vorbis_floor *floor;",
"int ret;",
"if (mapping->submaps > 1) {",
"floor = &VAR_0->floors[mapping->submap_floor[mapping->mux[VAR_5]]];",
"} else {",
"floor = &VAR_0->floors[mapping->submap_floor[0]];",
"}",
"ret = floor->decode(VAR_0, &floor->data, VAR_8);",
"if (ret < 0) {",
"av_log(VAR_0->avccontext, AV_LOG_ERROR, \"Invalid codebook in vorbis_floor_decode.\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"no_residue[VAR_5] = ret;",
"VAR_8 += VAR_4 / 2;",
"}",
"for (VAR_5 = mapping->coupling_steps - 1; VAR_5 >= 0; --VAR_5) {",
"if (!(no_residue[mapping->magnitude[VAR_5]] & no_residue[mapping->angle[VAR_5]])) {",
"no_residue[mapping->magnitude[VAR_5]] = 0;",
"no_residue[mapping->angle[VAR_5]] = 0;",
"}",
"}",
"for (VAR_5 = 0; VAR_5 < mapping->submaps; ++VAR_5) {",
"vorbis_residue *residue;",
"unsigned ch = 0;",
"for (VAR_6 = 0; VAR_6 < VAR_0->audio_channels; ++VAR_6) {",
"if ((mapping->submaps == 1) || (VAR_5 == mapping->mux[VAR_6])) {",
"res_chan[VAR_6] = VAR_9;",
"if (no_residue[VAR_6]) {",
"do_not_decode[ch] = 1;",
"} else {",
"do_not_decode[ch] = 0;",
"}",
"++ch;",
"++VAR_9;",
"}",
"}",
"residue = &VAR_0->residues[mapping->submap_residue[VAR_5]];",
"if (VAR_11 < ch) {",
"av_log(VAR_0->avccontext, AV_LOG_ERROR, \"Too many channels in vorbis_floor_decode.\\n\");",
"return -1;",
"}",
"vorbis_residue_decode(VAR_0, residue, ch, do_not_decode, VAR_7, VAR_4/2);",
"VAR_7 += ch * VAR_4 / 2;",
"VAR_11 -= ch;",
"}",
"for (VAR_5 = mapping->coupling_steps - 1; VAR_5 >= 0; --VAR_5) {",
"float *VAR_12, *VAR_13;",
"VAR_12 = VAR_0->channel_residues+res_chan[mapping->magnitude[VAR_5]] * VAR_4 / 2;",
"VAR_13 = VAR_0->channel_residues+res_chan[mapping->angle[VAR_5]] * VAR_4 / 2;",
"VAR_0->dsp.vorbis_inverse_coupling(VAR_12, VAR_13, VAR_4 / 2);",
"}",
"mdct = &VAR_0->mdct[VAR_3];",
"for (VAR_6 = VAR_0->audio_channels-1;VAR_6 >= 0; VAR_6--) {",
"VAR_8 = VAR_0->channel_floors + VAR_6 * VAR_4 / 2;",
"VAR_7 = VAR_0->channel_residues + res_chan[VAR_6] * VAR_4 / 2;",
"VAR_0->dsp.vector_fmul(VAR_8, VAR_8, VAR_7, VAR_4 / 2);",
"mdct->imdct_half(mdct, VAR_7, VAR_8);",
"}",
"VAR_10 = (VAR_4 + VAR_0->VAR_4[VAR_1]) / 4;",
"for (VAR_6 = 0; VAR_6 < VAR_0->audio_channels; VAR_6++) {",
"unsigned bs0 = VAR_0->VAR_4[0];",
"unsigned bs1 = VAR_0->VAR_4[1];",
"float *residue = VAR_0->channel_residues + res_chan[VAR_6] * VAR_4 / 2;",
"float *saved = VAR_0->saved + VAR_6 * bs1 / 4;",
"float *ret = VAR_0->channel_floors + VAR_6 * VAR_10;",
"float *buf = residue;",
"const float *win = VAR_0->win[VAR_3 & VAR_1];",
"if (VAR_3 == VAR_1) {",
"VAR_0->dsp.vector_fmul_window(ret, saved, buf, win, VAR_4 / 4);",
"} else if (VAR_3 > VAR_1) {",
"VAR_0->dsp.vector_fmul_window(ret, saved, buf, win, bs0 / 4);",
"memcpy(ret+bs0/2, buf+bs0/4, ((bs1-bs0)/4) * sizeof(float));",
"} else {",
"memcpy(ret, saved, ((bs1 - bs0) / 4) * sizeof(float));",
"VAR_0->dsp.vector_fmul_window(ret + (bs1 - bs0) / 4, saved + (bs1 - bs0) / 4, buf, win, bs0 / 4);",
"}",
"memcpy(saved, buf + VAR_4 / 4, VAR_4 / 4 * sizeof(float));",
"}",
"VAR_0->VAR_1 = VAR_3;",
"return VAR_10;",
"}"
] | [
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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
61,
63
],
[
67
],
[
69
],
[
71,
73
],
[
77
],
[
79
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
193
],
[
195
],
[
197
],
[
205
],
[
207
],
[
211
],
[
213
],
[
215
],
[
217
],
[
225
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
291
],
[
293
],
[
295
]
] |
1,730 | static int mpc8_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
{
AVStream *st = s->streams[stream_index];
MPCContext *c = s->priv_data;
int index = av_index_search_timestamp(st, timestamp, flags);
if(index < 0) return -1;
avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET);
c->frame = st->index_entries[index].timestamp;
return 0;
}
| true | FFmpeg | 88ad79415c3821e5c4f3cb4d5b289d772fcac621 | static int mpc8_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
{
AVStream *st = s->streams[stream_index];
MPCContext *c = s->priv_data;
int index = av_index_search_timestamp(st, timestamp, flags);
if(index < 0) return -1;
avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET);
c->frame = st->index_entries[index].timestamp;
return 0;
}
| {
"code": [
" avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET);"
],
"line_no": [
15
]
} | static int FUNC_0(AVFormatContext *VAR_0, int VAR_1, int64_t VAR_2, int VAR_3)
{
AVStream *st = VAR_0->streams[VAR_1];
MPCContext *c = VAR_0->priv_data;
int VAR_4 = av_index_search_timestamp(st, VAR_2, VAR_3);
if(VAR_4 < 0) return -1;
avio_seek(VAR_0->pb, st->index_entries[VAR_4].pos, SEEK_SET);
c->frame = st->index_entries[VAR_4].VAR_2;
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, int VAR_1, int64_t VAR_2, int VAR_3)\n{",
"AVStream *st = VAR_0->streams[VAR_1];",
"MPCContext *c = VAR_0->priv_data;",
"int VAR_4 = av_index_search_timestamp(st, VAR_2, VAR_3);",
"if(VAR_4 < 0) return -1;",
"avio_seek(VAR_0->pb, st->index_entries[VAR_4].pos, SEEK_SET);",
"c->frame = st->index_entries[VAR_4].VAR_2;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
1,731 | static void pred8x8_left_dc_rv40_c(uint8_t *src, int stride){
int i;
int dc0;
dc0=0;
for(i=0;i<8; i++)
dc0+= src[-1+i*stride];
dc0= 0x01010101*((dc0 + 4)>>3);
for(i=0; i<8; i++){
((uint32_t*)(src+i*stride))[0]=
((uint32_t*)(src+i*stride))[1]= dc0;
}
}
| true | FFmpeg | 60f10e0ad37418cc697765d85b0bc22db70f726a | static void pred8x8_left_dc_rv40_c(uint8_t *src, int stride){
int i;
int dc0;
dc0=0;
for(i=0;i<8; i++)
dc0+= src[-1+i*stride];
dc0= 0x01010101*((dc0 + 4)>>3);
for(i=0; i<8; i++){
((uint32_t*)(src+i*stride))[0]=
((uint32_t*)(src+i*stride))[1]= dc0;
}
}
| {
"code": [
" int dc0;",
" int dc0;"
],
"line_no": [
5,
5
]
} | static void FUNC_0(uint8_t *VAR_0, int VAR_1){
int VAR_2;
int VAR_3;
VAR_3=0;
for(VAR_2=0;VAR_2<8; VAR_2++)
VAR_3+= VAR_0[-1+VAR_2*VAR_1];
VAR_3= 0x01010101*((VAR_3 + 4)>>3);
for(VAR_2=0; VAR_2<8; VAR_2++){
((uint32_t*)(VAR_0+VAR_2*VAR_1))[0]=
((uint32_t*)(VAR_0+VAR_2*VAR_1))[1]= VAR_3;
}
}
| [
"static void FUNC_0(uint8_t *VAR_0, int VAR_1){",
"int VAR_2;",
"int VAR_3;",
"VAR_3=0;",
"for(VAR_2=0;VAR_2<8; VAR_2++)",
"VAR_3+= VAR_0[-1+VAR_2*VAR_1];",
"VAR_3= 0x01010101*((VAR_3 + 4)>>3);",
"for(VAR_2=0; VAR_2<8; VAR_2++){",
"((uint32_t*)(VAR_0+VAR_2*VAR_1))[0]=\n((uint32_t*)(VAR_0+VAR_2*VAR_1))[1]= VAR_3;",
"}",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21,
23
],
[
25
],
[
27
]
] |
1,732 | static void usb_msd_command_complete(SCSIBus *bus, int reason, uint32_t tag,
uint32_t arg)
{
MSDState *s = DO_UPCAST(MSDState, dev.qdev, bus->qbus.parent);
USBPacket *p = s->packet;
if (tag != s->tag) {
fprintf(stderr, "usb-msd: Unexpected SCSI Tag 0x%x\n", tag);
}
if (reason == SCSI_REASON_DONE) {
DPRINTF("Command complete %d\n", arg);
s->residue = s->data_len;
s->result = arg != 0;
if (s->packet) {
if (s->data_len == 0 && s->mode == USB_MSDM_DATAOUT) {
/* A deferred packet with no write data remaining must be
the status read packet. */
usb_msd_send_status(s, p);
s->mode = USB_MSDM_CBW;
} else {
if (s->data_len) {
s->data_len -= s->usb_len;
if (s->mode == USB_MSDM_DATAIN)
memset(s->usb_buf, 0, s->usb_len);
s->usb_len = 0;
}
if (s->data_len == 0)
s->mode = USB_MSDM_CSW;
}
s->packet = NULL;
usb_packet_complete(&s->dev, p);
} else if (s->data_len == 0) {
s->mode = USB_MSDM_CSW;
}
return;
}
s->scsi_len = arg;
s->scsi_buf = s->scsi_dev->info->get_buf(s->scsi_dev, tag);
if (p) {
usb_msd_copy_data(s);
if (s->usb_len == 0) {
/* Set s->packet to NULL before calling usb_packet_complete
because another request may be issued before
usb_packet_complete returns. */
DPRINTF("Packet complete %p\n", p);
s->packet = NULL;
usb_packet_complete(&s->dev, p);
}
}
}
| true | qemu | 5c6c0e513600ba57c3e73b7151d3c0664438f7b5 | static void usb_msd_command_complete(SCSIBus *bus, int reason, uint32_t tag,
uint32_t arg)
{
MSDState *s = DO_UPCAST(MSDState, dev.qdev, bus->qbus.parent);
USBPacket *p = s->packet;
if (tag != s->tag) {
fprintf(stderr, "usb-msd: Unexpected SCSI Tag 0x%x\n", tag);
}
if (reason == SCSI_REASON_DONE) {
DPRINTF("Command complete %d\n", arg);
s->residue = s->data_len;
s->result = arg != 0;
if (s->packet) {
if (s->data_len == 0 && s->mode == USB_MSDM_DATAOUT) {
usb_msd_send_status(s, p);
s->mode = USB_MSDM_CBW;
} else {
if (s->data_len) {
s->data_len -= s->usb_len;
if (s->mode == USB_MSDM_DATAIN)
memset(s->usb_buf, 0, s->usb_len);
s->usb_len = 0;
}
if (s->data_len == 0)
s->mode = USB_MSDM_CSW;
}
s->packet = NULL;
usb_packet_complete(&s->dev, p);
} else if (s->data_len == 0) {
s->mode = USB_MSDM_CSW;
}
return;
}
s->scsi_len = arg;
s->scsi_buf = s->scsi_dev->info->get_buf(s->scsi_dev, tag);
if (p) {
usb_msd_copy_data(s);
if (s->usb_len == 0) {
DPRINTF("Packet complete %p\n", p);
s->packet = NULL;
usb_packet_complete(&s->dev, p);
}
}
}
| {
"code": [
"static void usb_msd_command_complete(SCSIBus *bus, int reason, uint32_t tag,",
" uint32_t arg)",
" MSDState *s = DO_UPCAST(MSDState, dev.qdev, bus->qbus.parent);",
" if (tag != s->tag) {",
" fprintf(stderr, \"usb-msd: Unexpected SCSI Tag 0x%x\\n\", tag);",
" s->scsi_buf = s->scsi_dev->info->get_buf(s->scsi_dev, tag);"
],
"line_no": [
1,
3,
7,
13,
15,
75
]
} | static void FUNC_0(SCSIBus *VAR_0, int VAR_1, uint32_t VAR_2,
uint32_t VAR_3)
{
MSDState *s = DO_UPCAST(MSDState, dev.qdev, VAR_0->qbus.parent);
USBPacket *p = s->packet;
if (VAR_2 != s->VAR_2) {
fprintf(stderr, "usb-msd: Unexpected SCSI Tag 0x%x\n", VAR_2);
}
if (VAR_1 == SCSI_REASON_DONE) {
DPRINTF("Command complete %d\n", VAR_3);
s->residue = s->data_len;
s->result = VAR_3 != 0;
if (s->packet) {
if (s->data_len == 0 && s->mode == USB_MSDM_DATAOUT) {
usb_msd_send_status(s, p);
s->mode = USB_MSDM_CBW;
} else {
if (s->data_len) {
s->data_len -= s->usb_len;
if (s->mode == USB_MSDM_DATAIN)
memset(s->usb_buf, 0, s->usb_len);
s->usb_len = 0;
}
if (s->data_len == 0)
s->mode = USB_MSDM_CSW;
}
s->packet = NULL;
usb_packet_complete(&s->dev, p);
} else if (s->data_len == 0) {
s->mode = USB_MSDM_CSW;
}
return;
}
s->scsi_len = VAR_3;
s->scsi_buf = s->scsi_dev->info->get_buf(s->scsi_dev, VAR_2);
if (p) {
usb_msd_copy_data(s);
if (s->usb_len == 0) {
DPRINTF("Packet complete %p\n", p);
s->packet = NULL;
usb_packet_complete(&s->dev, p);
}
}
}
| [
"static void FUNC_0(SCSIBus *VAR_0, int VAR_1, uint32_t VAR_2,\nuint32_t VAR_3)\n{",
"MSDState *s = DO_UPCAST(MSDState, dev.qdev, VAR_0->qbus.parent);",
"USBPacket *p = s->packet;",
"if (VAR_2 != s->VAR_2) {",
"fprintf(stderr, \"usb-msd: Unexpected SCSI Tag 0x%x\\n\", VAR_2);",
"}",
"if (VAR_1 == SCSI_REASON_DONE) {",
"DPRINTF(\"Command complete %d\\n\", VAR_3);",
"s->residue = s->data_len;",
"s->result = VAR_3 != 0;",
"if (s->packet) {",
"if (s->data_len == 0 && s->mode == USB_MSDM_DATAOUT) {",
"usb_msd_send_status(s, p);",
"s->mode = USB_MSDM_CBW;",
"} else {",
"if (s->data_len) {",
"s->data_len -= s->usb_len;",
"if (s->mode == USB_MSDM_DATAIN)\nmemset(s->usb_buf, 0, s->usb_len);",
"s->usb_len = 0;",
"}",
"if (s->data_len == 0)\ns->mode = USB_MSDM_CSW;",
"}",
"s->packet = NULL;",
"usb_packet_complete(&s->dev, p);",
"} else if (s->data_len == 0) {",
"s->mode = USB_MSDM_CSW;",
"}",
"return;",
"}",
"s->scsi_len = VAR_3;",
"s->scsi_buf = s->scsi_dev->info->get_buf(s->scsi_dev, VAR_2);",
"if (p) {",
"usb_msd_copy_data(s);",
"if (s->usb_len == 0) {",
"DPRINTF(\"Packet complete %p\\n\", p);",
"s->packet = NULL;",
"usb_packet_complete(&s->dev, p);",
"}",
"}",
"}"
] | [
1,
1,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
]
] |
1,733 | static int latm_decode_frame(AVCodecContext *avctx, void *out, int *out_size,
AVPacket *avpkt)
{
struct LATMContext *latmctx = avctx->priv_data;
int muxlength, err;
GetBitContext gb;
if (avpkt->size == 0)
return 0;
init_get_bits(&gb, avpkt->data, avpkt->size * 8);
// check for LOAS sync word
if (get_bits(&gb, 11) != LOAS_SYNC_WORD)
return AVERROR_INVALIDDATA;
muxlength = get_bits(&gb, 13) + 3;
// not enough data, the parser should have sorted this
if (muxlength > avpkt->size)
return AVERROR_INVALIDDATA;
if ((err = read_audio_mux_element(latmctx, &gb)) < 0)
return err;
if (!latmctx->initialized) {
if (!avctx->extradata) {
*out_size = 0;
return avpkt->size;
} else {
if ((err = aac_decode_init(avctx)) < 0)
return err;
latmctx->initialized = 1;
}
}
if (show_bits(&gb, 12) == 0xfff) {
av_log(latmctx->aac_ctx.avctx, AV_LOG_ERROR,
"ADTS header detected, probably as result of configuration "
"misparsing\n");
return AVERROR_INVALIDDATA;
}
if ((err = aac_decode_frame_int(avctx, out, out_size, &gb)) < 0)
return err;
return muxlength;
} | true | FFmpeg | 42da8ea8e848e65611f0c606cd2c96d3a70c041d | static int latm_decode_frame(AVCodecContext *avctx, void *out, int *out_size,
AVPacket *avpkt)
{
struct LATMContext *latmctx = avctx->priv_data;
int muxlength, err;
GetBitContext gb;
if (avpkt->size == 0)
return 0;
init_get_bits(&gb, avpkt->data, avpkt->size * 8);
if (get_bits(&gb, 11) != LOAS_SYNC_WORD)
return AVERROR_INVALIDDATA;
muxlength = get_bits(&gb, 13) + 3;
if (muxlength > avpkt->size)
return AVERROR_INVALIDDATA;
if ((err = read_audio_mux_element(latmctx, &gb)) < 0)
return err;
if (!latmctx->initialized) {
if (!avctx->extradata) {
*out_size = 0;
return avpkt->size;
} else {
if ((err = aac_decode_init(avctx)) < 0)
return err;
latmctx->initialized = 1;
}
}
if (show_bits(&gb, 12) == 0xfff) {
av_log(latmctx->aac_ctx.avctx, AV_LOG_ERROR,
"ADTS header detected, probably as result of configuration "
"misparsing\n");
return AVERROR_INVALIDDATA;
}
if ((err = aac_decode_frame_int(avctx, out, out_size, &gb)) < 0)
return err;
return muxlength;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
struct LATMContext *VAR_4 = VAR_0->priv_data;
int VAR_5, VAR_6;
GetBitContext gb;
if (VAR_3->size == 0)
return 0;
init_get_bits(&gb, VAR_3->data, VAR_3->size * 8);
if (get_bits(&gb, 11) != LOAS_SYNC_WORD)
return AVERROR_INVALIDDATA;
VAR_5 = get_bits(&gb, 13) + 3;
if (VAR_5 > VAR_3->size)
return AVERROR_INVALIDDATA;
if ((VAR_6 = read_audio_mux_element(VAR_4, &gb)) < 0)
return VAR_6;
if (!VAR_4->initialized) {
if (!VAR_0->extradata) {
*VAR_2 = 0;
return VAR_3->size;
} else {
if ((VAR_6 = aac_decode_init(VAR_0)) < 0)
return VAR_6;
VAR_4->initialized = 1;
}
}
if (show_bits(&gb, 12) == 0xfff) {
av_log(VAR_4->aac_ctx.VAR_0, AV_LOG_ERROR,
"ADTS header detected, probably as result of configuration "
"misparsing\n");
return AVERROR_INVALIDDATA;
}
if ((VAR_6 = aac_decode_frame_int(VAR_0, VAR_1, VAR_2, &gb)) < 0)
return VAR_6;
return VAR_5;
} | [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"struct LATMContext *VAR_4 = VAR_0->priv_data;",
"int VAR_5, VAR_6;",
"GetBitContext gb;",
"if (VAR_3->size == 0)\nreturn 0;",
"init_get_bits(&gb, VAR_3->data, VAR_3->size * 8);",
"if (get_bits(&gb, 11) != LOAS_SYNC_WORD)\nreturn AVERROR_INVALIDDATA;",
"VAR_5 = get_bits(&gb, 13) + 3;",
"if (VAR_5 > VAR_3->size)\nreturn AVERROR_INVALIDDATA;",
"if ((VAR_6 = read_audio_mux_element(VAR_4, &gb)) < 0)\nreturn VAR_6;",
"if (!VAR_4->initialized) {",
"if (!VAR_0->extradata) {",
"*VAR_2 = 0;",
"return VAR_3->size;",
"} else {",
"if ((VAR_6 = aac_decode_init(VAR_0)) < 0)\nreturn VAR_6;",
"VAR_4->initialized = 1;",
"}",
"}",
"if (show_bits(&gb, 12) == 0xfff) {",
"av_log(VAR_4->aac_ctx.VAR_0, AV_LOG_ERROR,\n\"ADTS header detected, probably as result of configuration \"\n\"misparsing\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if ((VAR_6 = aac_decode_frame_int(VAR_0, VAR_1, VAR_2, &gb)) < 0)\nreturn VAR_6;",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
21
],
[
27,
29
],
[
33
],
[
37,
39
],
[
43,
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
60,
62
],
[
64
],
[
66
],
[
68
],
[
72
],
[
74,
76,
78
],
[
80
],
[
82
],
[
86,
88
],
[
92
],
[
94
]
] |
1,734 | static void quantize_and_encode_band_mips(struct AACEncContext *s, PutBitContext *pb,
const float *in, float *out, int size, int scale_idx,
int cb, const float lambda, int rtz)
{
quantize_and_encode_band_cost(s, pb, in, out, NULL, size, scale_idx, cb, lambda,
INFINITY, NULL, (rtz) ? ROUND_TO_ZERO : ROUND_STANDARD);
}
| true | FFmpeg | 01ecb7172b684f1c4b3e748f95c5a9a494ca36ec | static void quantize_and_encode_band_mips(struct AACEncContext *s, PutBitContext *pb,
const float *in, float *out, int size, int scale_idx,
int cb, const float lambda, int rtz)
{
quantize_and_encode_band_cost(s, pb, in, out, NULL, size, scale_idx, cb, lambda,
INFINITY, NULL, (rtz) ? ROUND_TO_ZERO : ROUND_STANDARD);
}
| {
"code": [
" INFINITY, NULL, (rtz) ? ROUND_TO_ZERO : ROUND_STANDARD);"
],
"line_no": [
11
]
} | static void FUNC_0(struct AACEncContext *VAR_0, PutBitContext *VAR_1,
const float *VAR_2, float *VAR_3, int VAR_4, int VAR_5,
int VAR_6, const float VAR_7, int VAR_8)
{
quantize_and_encode_band_cost(VAR_0, VAR_1, VAR_2, VAR_3, NULL, VAR_4, VAR_5, VAR_6, VAR_7,
INFINITY, NULL, (VAR_8) ? ROUND_TO_ZERO : ROUND_STANDARD);
}
| [
"static void FUNC_0(struct AACEncContext *VAR_0, PutBitContext *VAR_1,\nconst float *VAR_2, float *VAR_3, int VAR_4, int VAR_5,\nint VAR_6, const float VAR_7, int VAR_8)\n{",
"quantize_and_encode_band_cost(VAR_0, VAR_1, VAR_2, VAR_3, NULL, VAR_4, VAR_5, VAR_6, VAR_7,\nINFINITY, NULL, (VAR_8) ? ROUND_TO_ZERO : ROUND_STANDARD);",
"}"
] | [
0,
1,
0
] | [
[
1,
3,
5,
7
],
[
9,
11
],
[
13
]
] |
1,735 | void visit_type_number(Visitor *v, double *obj, const char *name, Error **errp)
{
if (!error_is_set(errp)) {
v->type_number(v, obj, name, errp);
}
}
| true | qemu | 297a3646c2947ee64a6d42ca264039732c6218e0 | void visit_type_number(Visitor *v, double *obj, const char *name, Error **errp)
{
if (!error_is_set(errp)) {
v->type_number(v, obj, name, errp);
}
}
| {
"code": [
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" v->type_number(v, obj, name, errp);",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {"
],
"line_no": [
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
7,
5,
5,
5,
5
]
} | void FUNC_0(Visitor *VAR_0, double *VAR_1, const char *VAR_2, Error **VAR_3)
{
if (!error_is_set(VAR_3)) {
VAR_0->type_number(VAR_0, VAR_1, VAR_2, VAR_3);
}
}
| [
"void FUNC_0(Visitor *VAR_0, double *VAR_1, const char *VAR_2, Error **VAR_3)\n{",
"if (!error_is_set(VAR_3)) {",
"VAR_0->type_number(VAR_0, VAR_1, VAR_2, VAR_3);",
"}",
"}"
] | [
0,
1,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
1,737 | static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)
{
int32_t offset;
int rs, rt, rd, sa;
uint32_t op, op1, op2;
int16_t imm;
/* make sure instructions are on a word boundary */
if (ctx->pc & 0x3) {
env->CP0_BadVAddr = ctx->pc;
generate_exception(ctx, EXCP_AdEL);
return;
}
/* Handle blikely not taken case */
if ((ctx->hflags & MIPS_HFLAG_BMASK_BASE) == MIPS_HFLAG_BL) {
int l1 = gen_new_label();
MIPS_DEBUG("blikely condition (" TARGET_FMT_lx ")", ctx->pc + 4);
tcg_gen_brcondi_tl(TCG_COND_NE, bcond, 0, l1);
tcg_gen_movi_i32(hflags, ctx->hflags & ~MIPS_HFLAG_BMASK);
gen_goto_tb(ctx, 1, ctx->pc + 4);
gen_set_label(l1);
}
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_debug_insn_start(ctx->pc);
}
op = MASK_OP_MAJOR(ctx->opcode);
rs = (ctx->opcode >> 21) & 0x1f;
rt = (ctx->opcode >> 16) & 0x1f;
rd = (ctx->opcode >> 11) & 0x1f;
sa = (ctx->opcode >> 6) & 0x1f;
imm = (int16_t)ctx->opcode;
switch (op) {
case OPC_SPECIAL:
op1 = MASK_SPECIAL(ctx->opcode);
switch (op1) {
case OPC_SLL: /* Shift with immediate */
case OPC_SRA:
gen_shift_imm(ctx, op1, rd, rt, sa);
break;
case OPC_SRL:
switch ((ctx->opcode >> 21) & 0x1f) {
case 1:
/* rotr is decoded as srl on non-R2 CPUs */
if (ctx->insn_flags & ISA_MIPS32R2) {
op1 = OPC_ROTR;
}
/* Fallthrough */
case 0:
gen_shift_imm(ctx, op1, rd, rt, sa);
break;
default:
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_MOVN: /* Conditional move */
case OPC_MOVZ:
check_insn(ctx, ISA_MIPS4 | ISA_MIPS32 |
INSN_LOONGSON2E | INSN_LOONGSON2F);
gen_cond_move(ctx, op1, rd, rs, rt);
break;
case OPC_ADD ... OPC_SUBU:
gen_arith(ctx, op1, rd, rs, rt);
break;
case OPC_SLLV: /* Shifts */
case OPC_SRAV:
gen_shift(ctx, op1, rd, rs, rt);
break;
case OPC_SRLV:
switch ((ctx->opcode >> 6) & 0x1f) {
case 1:
/* rotrv is decoded as srlv on non-R2 CPUs */
if (ctx->insn_flags & ISA_MIPS32R2) {
op1 = OPC_ROTRV;
}
/* Fallthrough */
case 0:
gen_shift(ctx, op1, rd, rs, rt);
break;
default:
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_SLT: /* Set on less than */
case OPC_SLTU:
gen_slt(ctx, op1, rd, rs, rt);
break;
case OPC_AND: /* Logic*/
case OPC_OR:
case OPC_NOR:
case OPC_XOR:
gen_logic(ctx, op1, rd, rs, rt);
break;
case OPC_MULT:
case OPC_MULTU:
if (sa) {
check_insn(ctx, INSN_VR54XX);
op1 = MASK_MUL_VR54XX(ctx->opcode);
gen_mul_vr54xx(ctx, op1, rd, rs, rt);
} else {
gen_muldiv(ctx, op1, rd & 3, rs, rt);
}
break;
case OPC_DIV:
case OPC_DIVU:
gen_muldiv(ctx, op1, 0, rs, rt);
break;
case OPC_JR ... OPC_JALR:
gen_compute_branch(ctx, op1, 4, rs, rd, sa);
*is_branch = 1;
break;
case OPC_TGE ... OPC_TEQ: /* Traps */
case OPC_TNE:
gen_trap(ctx, op1, rs, rt, -1);
break;
case OPC_MFHI: /* Move from HI/LO */
case OPC_MFLO:
gen_HILO(ctx, op1, rs & 3, rd);
break;
case OPC_MTHI:
case OPC_MTLO: /* Move to HI/LO */
gen_HILO(ctx, op1, rd & 3, rs);
break;
case OPC_PMON: /* Pmon entry point, also R4010 selsl */
#ifdef MIPS_STRICT_STANDARD
MIPS_INVAL("PMON / selsl");
generate_exception(ctx, EXCP_RI);
#else
gen_helper_0e0i(pmon, sa);
#endif
break;
case OPC_SYSCALL:
generate_exception(ctx, EXCP_SYSCALL);
ctx->bstate = BS_STOP;
break;
case OPC_BREAK:
generate_exception(ctx, EXCP_BREAK);
break;
case OPC_SPIM:
#ifdef MIPS_STRICT_STANDARD
MIPS_INVAL("SPIM");
generate_exception(ctx, EXCP_RI);
#else
/* Implemented as RI exception for now. */
MIPS_INVAL("spim (unofficial)");
generate_exception(ctx, EXCP_RI);
#endif
break;
case OPC_SYNC:
/* Treat as NOP. */
break;
case OPC_MOVCI:
check_insn(ctx, ISA_MIPS4 | ISA_MIPS32);
if (env->CP0_Config1 & (1 << CP0C1_FP)) {
check_cp1_enabled(ctx);
gen_movci(ctx, rd, rs, (ctx->opcode >> 18) & 0x7,
(ctx->opcode >> 16) & 1);
} else {
generate_exception_err(ctx, EXCP_CpU, 1);
}
break;
#if defined(TARGET_MIPS64)
/* MIPS64 specific opcodes */
case OPC_DSLL:
case OPC_DSRA:
case OPC_DSLL32:
case OPC_DSRA32:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_shift_imm(ctx, op1, rd, rt, sa);
break;
case OPC_DSRL:
switch ((ctx->opcode >> 21) & 0x1f) {
case 1:
/* drotr is decoded as dsrl on non-R2 CPUs */
if (ctx->insn_flags & ISA_MIPS32R2) {
op1 = OPC_DROTR;
}
/* Fallthrough */
case 0:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_shift_imm(ctx, op1, rd, rt, sa);
break;
default:
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_DSRL32:
switch ((ctx->opcode >> 21) & 0x1f) {
case 1:
/* drotr32 is decoded as dsrl32 on non-R2 CPUs */
if (ctx->insn_flags & ISA_MIPS32R2) {
op1 = OPC_DROTR32;
}
/* Fallthrough */
case 0:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_shift_imm(ctx, op1, rd, rt, sa);
break;
default:
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_DADD ... OPC_DSUBU:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_arith(ctx, op1, rd, rs, rt);
break;
case OPC_DSLLV:
case OPC_DSRAV:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_shift(ctx, op1, rd, rs, rt);
break;
case OPC_DSRLV:
switch ((ctx->opcode >> 6) & 0x1f) {
case 1:
/* drotrv is decoded as dsrlv on non-R2 CPUs */
if (ctx->insn_flags & ISA_MIPS32R2) {
op1 = OPC_DROTRV;
}
/* Fallthrough */
case 0:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_shift(ctx, op1, rd, rs, rt);
break;
default:
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_DMULT ... OPC_DDIVU:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_muldiv(ctx, op1, 0, rs, rt);
break;
#endif
default: /* Invalid */
MIPS_INVAL("special");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_SPECIAL2:
op1 = MASK_SPECIAL2(ctx->opcode);
switch (op1) {
case OPC_MADD ... OPC_MADDU: /* Multiply and add/sub */
case OPC_MSUB ... OPC_MSUBU:
check_insn(ctx, ISA_MIPS32);
gen_muldiv(ctx, op1, rd & 3, rs, rt);
break;
case OPC_MUL:
gen_arith(ctx, op1, rd, rs, rt);
break;
case OPC_CLO:
case OPC_CLZ:
check_insn(ctx, ISA_MIPS32);
gen_cl(ctx, op1, rd, rs);
break;
case OPC_SDBBP:
/* XXX: not clear which exception should be raised
* when in debug mode...
*/
check_insn(ctx, ISA_MIPS32);
if (!(ctx->hflags & MIPS_HFLAG_DM)) {
generate_exception(ctx, EXCP_DBp);
} else {
generate_exception(ctx, EXCP_DBp);
}
/* Treat as NOP. */
break;
case OPC_DIV_G_2F:
case OPC_DIVU_G_2F:
case OPC_MULT_G_2F:
case OPC_MULTU_G_2F:
case OPC_MOD_G_2F:
case OPC_MODU_G_2F:
check_insn(ctx, INSN_LOONGSON2F);
gen_loongson_integer(ctx, op1, rd, rs, rt);
break;
#if defined(TARGET_MIPS64)
case OPC_DCLO:
case OPC_DCLZ:
check_insn(ctx, ISA_MIPS64);
check_mips_64(ctx);
gen_cl(ctx, op1, rd, rs);
break;
case OPC_DMULT_G_2F:
case OPC_DMULTU_G_2F:
case OPC_DDIV_G_2F:
case OPC_DDIVU_G_2F:
case OPC_DMOD_G_2F:
case OPC_DMODU_G_2F:
check_insn(ctx, INSN_LOONGSON2F);
gen_loongson_integer(ctx, op1, rd, rs, rt);
break;
#endif
default: /* Invalid */
MIPS_INVAL("special2");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_SPECIAL3:
op1 = MASK_SPECIAL3(ctx->opcode);
switch (op1) {
case OPC_EXT:
case OPC_INS:
check_insn(ctx, ISA_MIPS32R2);
gen_bitops(ctx, op1, rt, rs, sa, rd);
break;
case OPC_BSHFL:
check_insn(ctx, ISA_MIPS32R2);
op2 = MASK_BSHFL(ctx->opcode);
gen_bshfl(ctx, op2, rt, rd);
break;
case OPC_RDHWR:
gen_rdhwr(ctx, rt, rd);
break;
case OPC_FORK:
check_insn(ctx, ASE_MT);
{
TCGv t0 = tcg_temp_new();
TCGv t1 = tcg_temp_new();
gen_load_gpr(t0, rt);
gen_load_gpr(t1, rs);
gen_helper_fork(t0, t1);
tcg_temp_free(t0);
tcg_temp_free(t1);
}
break;
case OPC_YIELD:
check_insn(ctx, ASE_MT);
{
TCGv t0 = tcg_temp_new();
save_cpu_state(ctx, 1);
gen_load_gpr(t0, rs);
gen_helper_yield(t0, cpu_env, t0);
gen_store_gpr(t0, rd);
tcg_temp_free(t0);
}
break;
case OPC_DIV_G_2E ... OPC_DIVU_G_2E:
case OPC_MOD_G_2E ... OPC_MODU_G_2E:
case OPC_MULT_G_2E ... OPC_MULTU_G_2E:
/* OPC_MULT_G_2E, OPC_ADDUH_QB_DSP, OPC_MUL_PH_DSP have
* the same mask and op1. */
if ((ctx->insn_flags & ASE_DSPR2) && (op1 == OPC_MULT_G_2E)) {
op2 = MASK_ADDUH_QB(ctx->opcode);
switch (op2) {
case OPC_ADDUH_QB:
case OPC_ADDUH_R_QB:
case OPC_ADDQH_PH:
case OPC_ADDQH_R_PH:
case OPC_ADDQH_W:
case OPC_ADDQH_R_W:
case OPC_SUBUH_QB:
case OPC_SUBUH_R_QB:
case OPC_SUBQH_PH:
case OPC_SUBQH_R_PH:
case OPC_SUBQH_W:
case OPC_SUBQH_R_W:
gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt);
break;
case OPC_MUL_PH:
case OPC_MUL_S_PH:
case OPC_MULQ_S_W:
case OPC_MULQ_RS_W:
gen_mipsdsp_multiply(ctx, op1, op2, rd, rs, rt, 1);
break;
default:
MIPS_INVAL("MASK ADDUH.QB");
generate_exception(ctx, EXCP_RI);
break;
}
} else if (ctx->insn_flags & INSN_LOONGSON2E) {
gen_loongson_integer(ctx, op1, rd, rs, rt);
} else {
generate_exception(ctx, EXCP_RI);
}
break;
case OPC_LX_DSP:
op2 = MASK_LX(ctx->opcode);
switch (op2) {
#if defined(TARGET_MIPS64)
case OPC_LDX:
#endif
case OPC_LBUX:
case OPC_LHX:
case OPC_LWX:
gen_mipsdsp_ld(ctx, op2, rd, rs, rt);
break;
default: /* Invalid */
MIPS_INVAL("MASK LX");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_ABSQ_S_PH_DSP:
op2 = MASK_ABSQ_S_PH(ctx->opcode);
switch (op2) {
case OPC_ABSQ_S_QB:
case OPC_ABSQ_S_PH:
case OPC_ABSQ_S_W:
case OPC_PRECEQ_W_PHL:
case OPC_PRECEQ_W_PHR:
case OPC_PRECEQU_PH_QBL:
case OPC_PRECEQU_PH_QBR:
case OPC_PRECEQU_PH_QBLA:
case OPC_PRECEQU_PH_QBRA:
case OPC_PRECEU_PH_QBL:
case OPC_PRECEU_PH_QBR:
case OPC_PRECEU_PH_QBLA:
case OPC_PRECEU_PH_QBRA:
gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt);
break;
case OPC_BITREV:
case OPC_REPL_QB:
case OPC_REPLV_QB:
case OPC_REPL_PH:
case OPC_REPLV_PH:
gen_mipsdsp_bitinsn(ctx, op1, op2, rd, rt);
break;
default:
MIPS_INVAL("MASK ABSQ_S.PH");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_ADDU_QB_DSP:
op2 = MASK_ADDU_QB(ctx->opcode);
switch (op2) {
case OPC_ADDQ_PH:
case OPC_ADDQ_S_PH:
case OPC_ADDQ_S_W:
case OPC_ADDU_QB:
case OPC_ADDU_S_QB:
case OPC_ADDU_PH:
case OPC_ADDU_S_PH:
case OPC_SUBQ_PH:
case OPC_SUBQ_S_PH:
case OPC_SUBQ_S_W:
case OPC_SUBU_QB:
case OPC_SUBU_S_QB:
case OPC_SUBU_PH:
case OPC_SUBU_S_PH:
case OPC_ADDSC:
case OPC_ADDWC:
case OPC_MODSUB:
case OPC_RADDU_W_QB:
gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt);
break;
case OPC_MULEU_S_PH_QBL:
case OPC_MULEU_S_PH_QBR:
case OPC_MULQ_RS_PH:
case OPC_MULEQ_S_W_PHL:
case OPC_MULEQ_S_W_PHR:
case OPC_MULQ_S_PH:
gen_mipsdsp_multiply(ctx, op1, op2, rd, rs, rt, 1);
break;
default: /* Invalid */
MIPS_INVAL("MASK ADDU.QB");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_CMPU_EQ_QB_DSP:
op2 = MASK_CMPU_EQ_QB(ctx->opcode);
switch (op2) {
case OPC_PRECR_SRA_PH_W:
case OPC_PRECR_SRA_R_PH_W:
gen_mipsdsp_arith(ctx, op1, op2, rt, rs, rd);
break;
case OPC_PRECR_QB_PH:
case OPC_PRECRQ_QB_PH:
case OPC_PRECRQ_PH_W:
case OPC_PRECRQ_RS_PH_W:
case OPC_PRECRQU_S_QB_PH:
gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt);
break;
case OPC_CMPU_EQ_QB:
case OPC_CMPU_LT_QB:
case OPC_CMPU_LE_QB:
case OPC_CMP_EQ_PH:
case OPC_CMP_LT_PH:
case OPC_CMP_LE_PH:
gen_mipsdsp_add_cmp_pick(ctx, op1, op2, rd, rs, rt, 0);
break;
case OPC_CMPGU_EQ_QB:
case OPC_CMPGU_LT_QB:
case OPC_CMPGU_LE_QB:
case OPC_CMPGDU_EQ_QB:
case OPC_CMPGDU_LT_QB:
case OPC_CMPGDU_LE_QB:
case OPC_PICK_QB:
case OPC_PICK_PH:
case OPC_PACKRL_PH:
gen_mipsdsp_add_cmp_pick(ctx, op1, op2, rd, rs, rt, 1);
break;
default: /* Invalid */
MIPS_INVAL("MASK CMPU.EQ.QB");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_SHLL_QB_DSP:
gen_mipsdsp_shift(ctx, op1, rd, rs, rt);
break;
case OPC_DPA_W_PH_DSP:
op2 = MASK_DPA_W_PH(ctx->opcode);
switch (op2) {
case OPC_DPAU_H_QBL:
case OPC_DPAU_H_QBR:
case OPC_DPSU_H_QBL:
case OPC_DPSU_H_QBR:
case OPC_DPA_W_PH:
case OPC_DPAX_W_PH:
case OPC_DPAQ_S_W_PH:
case OPC_DPAQX_S_W_PH:
case OPC_DPAQX_SA_W_PH:
case OPC_DPS_W_PH:
case OPC_DPSX_W_PH:
case OPC_DPSQ_S_W_PH:
case OPC_DPSQX_S_W_PH:
case OPC_DPSQX_SA_W_PH:
case OPC_MULSAQ_S_W_PH:
case OPC_DPAQ_SA_L_W:
case OPC_DPSQ_SA_L_W:
case OPC_MAQ_S_W_PHL:
case OPC_MAQ_S_W_PHR:
case OPC_MAQ_SA_W_PHL:
case OPC_MAQ_SA_W_PHR:
case OPC_MULSA_W_PH:
gen_mipsdsp_multiply(ctx, op1, op2, rd, rs, rt, 0);
break;
default: /* Invalid */
MIPS_INVAL("MASK DPAW.PH");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_INSV_DSP:
op2 = MASK_INSV(ctx->opcode);
switch (op2) {
case OPC_INSV:
check_dsp(ctx);
{
TCGv t0, t1;
if (rt == 0) {
MIPS_DEBUG("NOP");
break;
}
t0 = tcg_temp_new();
t1 = tcg_temp_new();
gen_load_gpr(t0, rt);
gen_load_gpr(t1, rs);
gen_helper_insv(cpu_gpr[rt], cpu_env, t1, t0);
tcg_temp_free(t0);
tcg_temp_free(t1);
break;
}
default: /* Invalid */
MIPS_INVAL("MASK INSV");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_APPEND_DSP:
gen_mipsdsp_append(env, ctx, op1, rt, rs, rd);
break;
case OPC_EXTR_W_DSP:
op2 = MASK_EXTR_W(ctx->opcode);
switch (op2) {
case OPC_EXTR_W:
case OPC_EXTR_R_W:
case OPC_EXTR_RS_W:
case OPC_EXTR_S_H:
case OPC_EXTRV_S_H:
case OPC_EXTRV_W:
case OPC_EXTRV_R_W:
case OPC_EXTRV_RS_W:
case OPC_EXTP:
case OPC_EXTPV:
case OPC_EXTPDP:
case OPC_EXTPDPV:
gen_mipsdsp_accinsn(ctx, op1, op2, rt, rs, rd, 1);
break;
case OPC_RDDSP:
gen_mipsdsp_accinsn(ctx, op1, op2, rd, rs, rt, 1);
break;
case OPC_SHILO:
case OPC_SHILOV:
case OPC_MTHLIP:
case OPC_WRDSP:
gen_mipsdsp_accinsn(ctx, op1, op2, rd, rs, rt, 0);
break;
default: /* Invalid */
MIPS_INVAL("MASK EXTR.W");
generate_exception(ctx, EXCP_RI);
break;
}
break;
#if defined(TARGET_MIPS64)
case OPC_DEXTM ... OPC_DEXT:
case OPC_DINSM ... OPC_DINS:
check_insn(ctx, ISA_MIPS64R2);
check_mips_64(ctx);
gen_bitops(ctx, op1, rt, rs, sa, rd);
break;
case OPC_DBSHFL:
check_insn(ctx, ISA_MIPS64R2);
check_mips_64(ctx);
op2 = MASK_DBSHFL(ctx->opcode);
gen_bshfl(ctx, op2, rt, rd);
break;
case OPC_DDIV_G_2E ... OPC_DDIVU_G_2E:
case OPC_DMULT_G_2E ... OPC_DMULTU_G_2E:
case OPC_DMOD_G_2E ... OPC_DMODU_G_2E:
check_insn(ctx, INSN_LOONGSON2E);
gen_loongson_integer(ctx, op1, rd, rs, rt);
break;
case OPC_ABSQ_S_QH_DSP:
op2 = MASK_ABSQ_S_QH(ctx->opcode);
switch (op2) {
case OPC_PRECEQ_L_PWL:
case OPC_PRECEQ_L_PWR:
case OPC_PRECEQ_PW_QHL:
case OPC_PRECEQ_PW_QHR:
case OPC_PRECEQ_PW_QHLA:
case OPC_PRECEQ_PW_QHRA:
case OPC_PRECEQU_QH_OBL:
case OPC_PRECEQU_QH_OBR:
case OPC_PRECEQU_QH_OBLA:
case OPC_PRECEQU_QH_OBRA:
case OPC_PRECEU_QH_OBL:
case OPC_PRECEU_QH_OBR:
case OPC_PRECEU_QH_OBLA:
case OPC_PRECEU_QH_OBRA:
case OPC_ABSQ_S_OB:
case OPC_ABSQ_S_PW:
case OPC_ABSQ_S_QH:
gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt);
break;
case OPC_REPL_OB:
case OPC_REPL_PW:
case OPC_REPL_QH:
case OPC_REPLV_OB:
case OPC_REPLV_PW:
case OPC_REPLV_QH:
gen_mipsdsp_bitinsn(ctx, op1, op2, rd, rt);
break;
default: /* Invalid */
MIPS_INVAL("MASK ABSQ_S.QH");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_ADDU_OB_DSP:
op2 = MASK_ADDU_OB(ctx->opcode);
switch (op2) {
case OPC_RADDU_L_OB:
case OPC_SUBQ_PW:
case OPC_SUBQ_S_PW:
case OPC_SUBQ_QH:
case OPC_SUBQ_S_QH:
case OPC_SUBU_OB:
case OPC_SUBU_S_OB:
case OPC_SUBU_QH:
case OPC_SUBU_S_QH:
case OPC_SUBUH_OB:
case OPC_SUBUH_R_OB:
case OPC_ADDQ_PW:
case OPC_ADDQ_S_PW:
case OPC_ADDQ_QH:
case OPC_ADDQ_S_QH:
case OPC_ADDU_OB:
case OPC_ADDU_S_OB:
case OPC_ADDU_QH:
case OPC_ADDU_S_QH:
case OPC_ADDUH_OB:
case OPC_ADDUH_R_OB:
gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt);
break;
case OPC_MULEQ_S_PW_QHL:
case OPC_MULEQ_S_PW_QHR:
case OPC_MULEU_S_QH_OBL:
case OPC_MULEU_S_QH_OBR:
case OPC_MULQ_RS_QH:
gen_mipsdsp_multiply(ctx, op1, op2, rd, rs, rt, 1);
break;
default: /* Invalid */
MIPS_INVAL("MASK ADDU.OB");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_CMPU_EQ_OB_DSP:
op2 = MASK_CMPU_EQ_OB(ctx->opcode);
switch (op2) {
case OPC_PRECR_SRA_QH_PW:
case OPC_PRECR_SRA_R_QH_PW:
/* Return value is rt. */
gen_mipsdsp_arith(ctx, op1, op2, rt, rs, rd);
break;
case OPC_PRECR_OB_QH:
case OPC_PRECRQ_OB_QH:
case OPC_PRECRQ_PW_L:
case OPC_PRECRQ_QH_PW:
case OPC_PRECRQ_RS_QH_PW:
case OPC_PRECRQU_S_OB_QH:
gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt);
break;
case OPC_CMPU_EQ_OB:
case OPC_CMPU_LT_OB:
case OPC_CMPU_LE_OB:
case OPC_CMP_EQ_QH:
case OPC_CMP_LT_QH:
case OPC_CMP_LE_QH:
case OPC_CMP_EQ_PW:
case OPC_CMP_LT_PW:
case OPC_CMP_LE_PW:
gen_mipsdsp_add_cmp_pick(ctx, op1, op2, rd, rs, rt, 0);
break;
case OPC_CMPGDU_EQ_OB:
case OPC_CMPGDU_LT_OB:
case OPC_CMPGDU_LE_OB:
case OPC_CMPGU_EQ_OB:
case OPC_CMPGU_LT_OB:
case OPC_CMPGU_LE_OB:
case OPC_PACKRL_PW:
case OPC_PICK_OB:
case OPC_PICK_PW:
case OPC_PICK_QH:
gen_mipsdsp_add_cmp_pick(ctx, op1, op2, rd, rs, rt, 1);
break;
default: /* Invalid */
MIPS_INVAL("MASK CMPU_EQ.OB");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_DAPPEND_DSP:
gen_mipsdsp_append(env, ctx, op1, rt, rs, rd);
break;
case OPC_DEXTR_W_DSP:
op2 = MASK_DEXTR_W(ctx->opcode);
switch (op2) {
case OPC_DEXTP:
case OPC_DEXTPDP:
case OPC_DEXTPDPV:
case OPC_DEXTPV:
case OPC_DEXTR_L:
case OPC_DEXTR_R_L:
case OPC_DEXTR_RS_L:
case OPC_DEXTR_W:
case OPC_DEXTR_R_W:
case OPC_DEXTR_RS_W:
case OPC_DEXTR_S_H:
case OPC_DEXTRV_L:
case OPC_DEXTRV_R_L:
case OPC_DEXTRV_RS_L:
case OPC_DEXTRV_S_H:
case OPC_DEXTRV_W:
case OPC_DEXTRV_R_W:
case OPC_DEXTRV_RS_W:
gen_mipsdsp_accinsn(ctx, op1, op2, rt, rs, rd, 1);
break;
case OPC_DMTHLIP:
case OPC_DSHILO:
case OPC_DSHILOV:
gen_mipsdsp_accinsn(ctx, op1, op2, rd, rs, rt, 0);
break;
default: /* Invalid */
MIPS_INVAL("MASK EXTR.W");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_DPAQ_W_QH_DSP:
op2 = MASK_DPAQ_W_QH(ctx->opcode);
switch (op2) {
case OPC_DPAU_H_OBL:
case OPC_DPAU_H_OBR:
case OPC_DPSU_H_OBL:
case OPC_DPSU_H_OBR:
case OPC_DPA_W_QH:
case OPC_DPAQ_S_W_QH:
case OPC_DPS_W_QH:
case OPC_DPSQ_S_W_QH:
case OPC_MULSAQ_S_W_QH:
case OPC_DPAQ_SA_L_PW:
case OPC_DPSQ_SA_L_PW:
case OPC_MULSAQ_S_L_PW:
gen_mipsdsp_multiply(ctx, op1, op2, rd, rs, rt, 0);
break;
case OPC_MAQ_S_W_QHLL:
case OPC_MAQ_S_W_QHLR:
case OPC_MAQ_S_W_QHRL:
case OPC_MAQ_S_W_QHRR:
case OPC_MAQ_SA_W_QHLL:
case OPC_MAQ_SA_W_QHLR:
case OPC_MAQ_SA_W_QHRL:
case OPC_MAQ_SA_W_QHRR:
case OPC_MAQ_S_L_PWL:
case OPC_MAQ_S_L_PWR:
case OPC_DMADD:
case OPC_DMADDU:
case OPC_DMSUB:
case OPC_DMSUBU:
gen_mipsdsp_multiply(ctx, op1, op2, rd, rs, rt, 0);
break;
default: /* Invalid */
MIPS_INVAL("MASK DPAQ.W.QH");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_DINSV_DSP:
op2 = MASK_INSV(ctx->opcode);
switch (op2) {
case OPC_DINSV:
{
TCGv t0, t1;
if (rt == 0) {
MIPS_DEBUG("NOP");
break;
}
check_dsp(ctx);
t0 = tcg_temp_new();
t1 = tcg_temp_new();
gen_load_gpr(t0, rt);
gen_load_gpr(t1, rs);
gen_helper_dinsv(cpu_gpr[rt], cpu_env, t1, t0);
break;
}
default: /* Invalid */
MIPS_INVAL("MASK DINSV");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_SHLL_OB_DSP:
gen_mipsdsp_shift(ctx, op1, rd, rs, rt);
break;
#endif
default: /* Invalid */
MIPS_INVAL("special3");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_REGIMM:
op1 = MASK_REGIMM(ctx->opcode);
switch (op1) {
case OPC_BLTZ ... OPC_BGEZL: /* REGIMM branches */
case OPC_BLTZAL ... OPC_BGEZALL:
gen_compute_branch(ctx, op1, 4, rs, -1, imm << 2);
*is_branch = 1;
break;
case OPC_TGEI ... OPC_TEQI: /* REGIMM traps */
case OPC_TNEI:
gen_trap(ctx, op1, rs, -1, imm);
break;
case OPC_SYNCI:
check_insn(ctx, ISA_MIPS32R2);
/* Treat as NOP. */
break;
case OPC_BPOSGE32: /* MIPS DSP branch */
#if defined(TARGET_MIPS64)
case OPC_BPOSGE64:
#endif
check_dsp(ctx);
gen_compute_branch(ctx, op1, 4, -1, -2, (int32_t)imm << 2);
*is_branch = 1;
break;
default: /* Invalid */
MIPS_INVAL("regimm");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_CP0:
check_cp0_enabled(ctx);
op1 = MASK_CP0(ctx->opcode);
switch (op1) {
case OPC_MFC0:
case OPC_MTC0:
case OPC_MFTR:
case OPC_MTTR:
#if defined(TARGET_MIPS64)
case OPC_DMFC0:
case OPC_DMTC0:
#endif
#ifndef CONFIG_USER_ONLY
gen_cp0(env, ctx, op1, rt, rd);
#endif /* !CONFIG_USER_ONLY */
break;
case OPC_C0_FIRST ... OPC_C0_LAST:
#ifndef CONFIG_USER_ONLY
gen_cp0(env, ctx, MASK_C0(ctx->opcode), rt, rd);
#endif /* !CONFIG_USER_ONLY */
break;
case OPC_MFMC0:
#ifndef CONFIG_USER_ONLY
{
TCGv t0 = tcg_temp_new();
op2 = MASK_MFMC0(ctx->opcode);
switch (op2) {
case OPC_DMT:
check_insn(ctx, ASE_MT);
gen_helper_dmt(t0);
gen_store_gpr(t0, rt);
break;
case OPC_EMT:
check_insn(ctx, ASE_MT);
gen_helper_emt(t0);
gen_store_gpr(t0, rt);
break;
case OPC_DVPE:
check_insn(ctx, ASE_MT);
gen_helper_dvpe(t0, cpu_env);
gen_store_gpr(t0, rt);
break;
case OPC_EVPE:
check_insn(ctx, ASE_MT);
gen_helper_evpe(t0, cpu_env);
gen_store_gpr(t0, rt);
break;
case OPC_DI:
check_insn(ctx, ISA_MIPS32R2);
save_cpu_state(ctx, 1);
gen_helper_di(t0, cpu_env);
gen_store_gpr(t0, rt);
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
break;
case OPC_EI:
check_insn(ctx, ISA_MIPS32R2);
save_cpu_state(ctx, 1);
gen_helper_ei(t0, cpu_env);
gen_store_gpr(t0, rt);
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
break;
default: /* Invalid */
MIPS_INVAL("mfmc0");
generate_exception(ctx, EXCP_RI);
break;
}
tcg_temp_free(t0);
}
#endif /* !CONFIG_USER_ONLY */
break;
case OPC_RDPGPR:
check_insn(ctx, ISA_MIPS32R2);
gen_load_srsgpr(rt, rd);
break;
case OPC_WRPGPR:
check_insn(ctx, ISA_MIPS32R2);
gen_store_srsgpr(rt, rd);
break;
default:
MIPS_INVAL("cp0");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_ADDI: /* Arithmetic with immediate opcode */
case OPC_ADDIU:
gen_arith_imm(ctx, op, rt, rs, imm);
break;
case OPC_SLTI: /* Set on less than with immediate opcode */
case OPC_SLTIU:
gen_slt_imm(ctx, op, rt, rs, imm);
break;
case OPC_ANDI: /* Arithmetic with immediate opcode */
case OPC_LUI:
case OPC_ORI:
case OPC_XORI:
gen_logic_imm(ctx, op, rt, rs, imm);
break;
case OPC_J ... OPC_JAL: /* Jump */
offset = (int32_t)(ctx->opcode & 0x3FFFFFF) << 2;
gen_compute_branch(ctx, op, 4, rs, rt, offset);
*is_branch = 1;
break;
case OPC_BEQ ... OPC_BGTZ: /* Branch */
case OPC_BEQL ... OPC_BGTZL:
gen_compute_branch(ctx, op, 4, rs, rt, imm << 2);
*is_branch = 1;
break;
case OPC_LB ... OPC_LWR: /* Load and stores */
case OPC_LL:
gen_ld(ctx, op, rt, rs, imm);
break;
case OPC_SB ... OPC_SW:
case OPC_SWR:
gen_st(ctx, op, rt, rs, imm);
break;
case OPC_SC:
gen_st_cond(ctx, op, rt, rs, imm);
break;
case OPC_CACHE:
check_cp0_enabled(ctx);
check_insn(ctx, ISA_MIPS3 | ISA_MIPS32);
/* Treat as NOP. */
break;
case OPC_PREF:
check_insn(ctx, ISA_MIPS4 | ISA_MIPS32);
/* Treat as NOP. */
break;
/* Floating point (COP1). */
case OPC_LWC1:
case OPC_LDC1:
case OPC_SWC1:
case OPC_SDC1:
gen_cop1_ldst(env, ctx, op, rt, rs, imm);
break;
case OPC_CP1:
if (env->CP0_Config1 & (1 << CP0C1_FP)) {
check_cp1_enabled(ctx);
op1 = MASK_CP1(ctx->opcode);
switch (op1) {
case OPC_MFHC1:
case OPC_MTHC1:
check_insn(ctx, ISA_MIPS32R2);
case OPC_MFC1:
case OPC_CFC1:
case OPC_MTC1:
case OPC_CTC1:
gen_cp1(ctx, op1, rt, rd);
break;
#if defined(TARGET_MIPS64)
case OPC_DMFC1:
case OPC_DMTC1:
check_insn(ctx, ISA_MIPS3);
gen_cp1(ctx, op1, rt, rd);
break;
#endif
case OPC_BC1ANY2:
case OPC_BC1ANY4:
check_cop1x(ctx);
check_insn(ctx, ASE_MIPS3D);
/* fall through */
case OPC_BC1:
gen_compute_branch1(ctx, MASK_BC1(ctx->opcode),
(rt >> 2) & 0x7, imm << 2);
*is_branch = 1;
break;
case OPC_S_FMT:
case OPC_D_FMT:
case OPC_W_FMT:
case OPC_L_FMT:
case OPC_PS_FMT:
gen_farith(ctx, ctx->opcode & FOP(0x3f, 0x1f), rt, rd, sa,
(imm >> 8) & 0x7);
break;
default:
MIPS_INVAL("cp1");
generate_exception (ctx, EXCP_RI);
break;
}
} else {
generate_exception_err(ctx, EXCP_CpU, 1);
}
break;
/* COP2. */
case OPC_LWC2:
case OPC_LDC2:
case OPC_SWC2:
case OPC_SDC2:
/* COP2: Not implemented. */
generate_exception_err(ctx, EXCP_CpU, 2);
break;
case OPC_CP2:
check_insn(ctx, INSN_LOONGSON2F);
/* Note that these instructions use different fields. */
gen_loongson_multimedia(ctx, sa, rd, rt);
break;
case OPC_CP3:
if (env->CP0_Config1 & (1 << CP0C1_FP)) {
check_cp1_enabled(ctx);
op1 = MASK_CP3(ctx->opcode);
switch (op1) {
case OPC_LWXC1:
case OPC_LDXC1:
case OPC_LUXC1:
case OPC_SWXC1:
case OPC_SDXC1:
case OPC_SUXC1:
gen_flt3_ldst(ctx, op1, sa, rd, rs, rt);
break;
case OPC_PREFX:
/* Treat as NOP. */
break;
case OPC_ALNV_PS:
case OPC_MADD_S:
case OPC_MADD_D:
case OPC_MADD_PS:
case OPC_MSUB_S:
case OPC_MSUB_D:
case OPC_MSUB_PS:
case OPC_NMADD_S:
case OPC_NMADD_D:
case OPC_NMADD_PS:
case OPC_NMSUB_S:
case OPC_NMSUB_D:
case OPC_NMSUB_PS:
gen_flt3_arith(ctx, op1, sa, rs, rd, rt);
break;
default:
MIPS_INVAL("cp3");
generate_exception (ctx, EXCP_RI);
break;
}
} else {
generate_exception_err(ctx, EXCP_CpU, 1);
}
break;
#if defined(TARGET_MIPS64)
/* MIPS64 opcodes */
case OPC_LWU:
case OPC_LDL ... OPC_LDR:
case OPC_LLD:
case OPC_LD:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_ld(ctx, op, rt, rs, imm);
break;
case OPC_SDL ... OPC_SDR:
case OPC_SD:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_st(ctx, op, rt, rs, imm);
break;
case OPC_SCD:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_st_cond(ctx, op, rt, rs, imm);
break;
case OPC_DADDI:
case OPC_DADDIU:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_arith_imm(ctx, op, rt, rs, imm);
break;
#endif
case OPC_JALX:
check_insn(ctx, ASE_MIPS16 | ASE_MICROMIPS);
offset = (int32_t)(ctx->opcode & 0x3FFFFFF) << 2;
gen_compute_branch(ctx, op, 4, rs, rt, offset);
*is_branch = 1;
break;
case OPC_MDMX:
check_insn(ctx, ASE_MDMX);
/* MDMX: Not implemented. */
default: /* Invalid */
MIPS_INVAL("major opcode");
generate_exception(ctx, EXCP_RI);
break;
}
}
| true | qemu | 240ce26a0533a6e5ee472789fbfbd9f7f939197e | static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)
{
int32_t offset;
int rs, rt, rd, sa;
uint32_t op, op1, op2;
int16_t imm;
if (ctx->pc & 0x3) {
env->CP0_BadVAddr = ctx->pc;
generate_exception(ctx, EXCP_AdEL);
return;
}
if ((ctx->hflags & MIPS_HFLAG_BMASK_BASE) == MIPS_HFLAG_BL) {
int l1 = gen_new_label();
MIPS_DEBUG("blikely condition (" TARGET_FMT_lx ")", ctx->pc + 4);
tcg_gen_brcondi_tl(TCG_COND_NE, bcond, 0, l1);
tcg_gen_movi_i32(hflags, ctx->hflags & ~MIPS_HFLAG_BMASK);
gen_goto_tb(ctx, 1, ctx->pc + 4);
gen_set_label(l1);
}
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_debug_insn_start(ctx->pc);
}
op = MASK_OP_MAJOR(ctx->opcode);
rs = (ctx->opcode >> 21) & 0x1f;
rt = (ctx->opcode >> 16) & 0x1f;
rd = (ctx->opcode >> 11) & 0x1f;
sa = (ctx->opcode >> 6) & 0x1f;
imm = (int16_t)ctx->opcode;
switch (op) {
case OPC_SPECIAL:
op1 = MASK_SPECIAL(ctx->opcode);
switch (op1) {
case OPC_SLL:
case OPC_SRA:
gen_shift_imm(ctx, op1, rd, rt, sa);
break;
case OPC_SRL:
switch ((ctx->opcode >> 21) & 0x1f) {
case 1:
if (ctx->insn_flags & ISA_MIPS32R2) {
op1 = OPC_ROTR;
}
case 0:
gen_shift_imm(ctx, op1, rd, rt, sa);
break;
default:
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_MOVN:
case OPC_MOVZ:
check_insn(ctx, ISA_MIPS4 | ISA_MIPS32 |
INSN_LOONGSON2E | INSN_LOONGSON2F);
gen_cond_move(ctx, op1, rd, rs, rt);
break;
case OPC_ADD ... OPC_SUBU:
gen_arith(ctx, op1, rd, rs, rt);
break;
case OPC_SLLV:
case OPC_SRAV:
gen_shift(ctx, op1, rd, rs, rt);
break;
case OPC_SRLV:
switch ((ctx->opcode >> 6) & 0x1f) {
case 1:
if (ctx->insn_flags & ISA_MIPS32R2) {
op1 = OPC_ROTRV;
}
case 0:
gen_shift(ctx, op1, rd, rs, rt);
break;
default:
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_SLT:
case OPC_SLTU:
gen_slt(ctx, op1, rd, rs, rt);
break;
case OPC_AND:
case OPC_OR:
case OPC_NOR:
case OPC_XOR:
gen_logic(ctx, op1, rd, rs, rt);
break;
case OPC_MULT:
case OPC_MULTU:
if (sa) {
check_insn(ctx, INSN_VR54XX);
op1 = MASK_MUL_VR54XX(ctx->opcode);
gen_mul_vr54xx(ctx, op1, rd, rs, rt);
} else {
gen_muldiv(ctx, op1, rd & 3, rs, rt);
}
break;
case OPC_DIV:
case OPC_DIVU:
gen_muldiv(ctx, op1, 0, rs, rt);
break;
case OPC_JR ... OPC_JALR:
gen_compute_branch(ctx, op1, 4, rs, rd, sa);
*is_branch = 1;
break;
case OPC_TGE ... OPC_TEQ:
case OPC_TNE:
gen_trap(ctx, op1, rs, rt, -1);
break;
case OPC_MFHI:
case OPC_MFLO:
gen_HILO(ctx, op1, rs & 3, rd);
break;
case OPC_MTHI:
case OPC_MTLO:
gen_HILO(ctx, op1, rd & 3, rs);
break;
case OPC_PMON:
#ifdef MIPS_STRICT_STANDARD
MIPS_INVAL("PMON / selsl");
generate_exception(ctx, EXCP_RI);
#else
gen_helper_0e0i(pmon, sa);
#endif
break;
case OPC_SYSCALL:
generate_exception(ctx, EXCP_SYSCALL);
ctx->bstate = BS_STOP;
break;
case OPC_BREAK:
generate_exception(ctx, EXCP_BREAK);
break;
case OPC_SPIM:
#ifdef MIPS_STRICT_STANDARD
MIPS_INVAL("SPIM");
generate_exception(ctx, EXCP_RI);
#else
MIPS_INVAL("spim (unofficial)");
generate_exception(ctx, EXCP_RI);
#endif
break;
case OPC_SYNC:
break;
case OPC_MOVCI:
check_insn(ctx, ISA_MIPS4 | ISA_MIPS32);
if (env->CP0_Config1 & (1 << CP0C1_FP)) {
check_cp1_enabled(ctx);
gen_movci(ctx, rd, rs, (ctx->opcode >> 18) & 0x7,
(ctx->opcode >> 16) & 1);
} else {
generate_exception_err(ctx, EXCP_CpU, 1);
}
break;
#if defined(TARGET_MIPS64)
case OPC_DSLL:
case OPC_DSRA:
case OPC_DSLL32:
case OPC_DSRA32:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_shift_imm(ctx, op1, rd, rt, sa);
break;
case OPC_DSRL:
switch ((ctx->opcode >> 21) & 0x1f) {
case 1:
if (ctx->insn_flags & ISA_MIPS32R2) {
op1 = OPC_DROTR;
}
case 0:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_shift_imm(ctx, op1, rd, rt, sa);
break;
default:
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_DSRL32:
switch ((ctx->opcode >> 21) & 0x1f) {
case 1:
if (ctx->insn_flags & ISA_MIPS32R2) {
op1 = OPC_DROTR32;
}
case 0:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_shift_imm(ctx, op1, rd, rt, sa);
break;
default:
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_DADD ... OPC_DSUBU:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_arith(ctx, op1, rd, rs, rt);
break;
case OPC_DSLLV:
case OPC_DSRAV:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_shift(ctx, op1, rd, rs, rt);
break;
case OPC_DSRLV:
switch ((ctx->opcode >> 6) & 0x1f) {
case 1:
if (ctx->insn_flags & ISA_MIPS32R2) {
op1 = OPC_DROTRV;
}
case 0:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_shift(ctx, op1, rd, rs, rt);
break;
default:
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_DMULT ... OPC_DDIVU:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_muldiv(ctx, op1, 0, rs, rt);
break;
#endif
default:
MIPS_INVAL("special");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_SPECIAL2:
op1 = MASK_SPECIAL2(ctx->opcode);
switch (op1) {
case OPC_MADD ... OPC_MADDU:
case OPC_MSUB ... OPC_MSUBU:
check_insn(ctx, ISA_MIPS32);
gen_muldiv(ctx, op1, rd & 3, rs, rt);
break;
case OPC_MUL:
gen_arith(ctx, op1, rd, rs, rt);
break;
case OPC_CLO:
case OPC_CLZ:
check_insn(ctx, ISA_MIPS32);
gen_cl(ctx, op1, rd, rs);
break;
case OPC_SDBBP:
check_insn(ctx, ISA_MIPS32);
if (!(ctx->hflags & MIPS_HFLAG_DM)) {
generate_exception(ctx, EXCP_DBp);
} else {
generate_exception(ctx, EXCP_DBp);
}
break;
case OPC_DIV_G_2F:
case OPC_DIVU_G_2F:
case OPC_MULT_G_2F:
case OPC_MULTU_G_2F:
case OPC_MOD_G_2F:
case OPC_MODU_G_2F:
check_insn(ctx, INSN_LOONGSON2F);
gen_loongson_integer(ctx, op1, rd, rs, rt);
break;
#if defined(TARGET_MIPS64)
case OPC_DCLO:
case OPC_DCLZ:
check_insn(ctx, ISA_MIPS64);
check_mips_64(ctx);
gen_cl(ctx, op1, rd, rs);
break;
case OPC_DMULT_G_2F:
case OPC_DMULTU_G_2F:
case OPC_DDIV_G_2F:
case OPC_DDIVU_G_2F:
case OPC_DMOD_G_2F:
case OPC_DMODU_G_2F:
check_insn(ctx, INSN_LOONGSON2F);
gen_loongson_integer(ctx, op1, rd, rs, rt);
break;
#endif
default:
MIPS_INVAL("special2");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_SPECIAL3:
op1 = MASK_SPECIAL3(ctx->opcode);
switch (op1) {
case OPC_EXT:
case OPC_INS:
check_insn(ctx, ISA_MIPS32R2);
gen_bitops(ctx, op1, rt, rs, sa, rd);
break;
case OPC_BSHFL:
check_insn(ctx, ISA_MIPS32R2);
op2 = MASK_BSHFL(ctx->opcode);
gen_bshfl(ctx, op2, rt, rd);
break;
case OPC_RDHWR:
gen_rdhwr(ctx, rt, rd);
break;
case OPC_FORK:
check_insn(ctx, ASE_MT);
{
TCGv t0 = tcg_temp_new();
TCGv t1 = tcg_temp_new();
gen_load_gpr(t0, rt);
gen_load_gpr(t1, rs);
gen_helper_fork(t0, t1);
tcg_temp_free(t0);
tcg_temp_free(t1);
}
break;
case OPC_YIELD:
check_insn(ctx, ASE_MT);
{
TCGv t0 = tcg_temp_new();
save_cpu_state(ctx, 1);
gen_load_gpr(t0, rs);
gen_helper_yield(t0, cpu_env, t0);
gen_store_gpr(t0, rd);
tcg_temp_free(t0);
}
break;
case OPC_DIV_G_2E ... OPC_DIVU_G_2E:
case OPC_MOD_G_2E ... OPC_MODU_G_2E:
case OPC_MULT_G_2E ... OPC_MULTU_G_2E:
if ((ctx->insn_flags & ASE_DSPR2) && (op1 == OPC_MULT_G_2E)) {
op2 = MASK_ADDUH_QB(ctx->opcode);
switch (op2) {
case OPC_ADDUH_QB:
case OPC_ADDUH_R_QB:
case OPC_ADDQH_PH:
case OPC_ADDQH_R_PH:
case OPC_ADDQH_W:
case OPC_ADDQH_R_W:
case OPC_SUBUH_QB:
case OPC_SUBUH_R_QB:
case OPC_SUBQH_PH:
case OPC_SUBQH_R_PH:
case OPC_SUBQH_W:
case OPC_SUBQH_R_W:
gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt);
break;
case OPC_MUL_PH:
case OPC_MUL_S_PH:
case OPC_MULQ_S_W:
case OPC_MULQ_RS_W:
gen_mipsdsp_multiply(ctx, op1, op2, rd, rs, rt, 1);
break;
default:
MIPS_INVAL("MASK ADDUH.QB");
generate_exception(ctx, EXCP_RI);
break;
}
} else if (ctx->insn_flags & INSN_LOONGSON2E) {
gen_loongson_integer(ctx, op1, rd, rs, rt);
} else {
generate_exception(ctx, EXCP_RI);
}
break;
case OPC_LX_DSP:
op2 = MASK_LX(ctx->opcode);
switch (op2) {
#if defined(TARGET_MIPS64)
case OPC_LDX:
#endif
case OPC_LBUX:
case OPC_LHX:
case OPC_LWX:
gen_mipsdsp_ld(ctx, op2, rd, rs, rt);
break;
default:
MIPS_INVAL("MASK LX");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_ABSQ_S_PH_DSP:
op2 = MASK_ABSQ_S_PH(ctx->opcode);
switch (op2) {
case OPC_ABSQ_S_QB:
case OPC_ABSQ_S_PH:
case OPC_ABSQ_S_W:
case OPC_PRECEQ_W_PHL:
case OPC_PRECEQ_W_PHR:
case OPC_PRECEQU_PH_QBL:
case OPC_PRECEQU_PH_QBR:
case OPC_PRECEQU_PH_QBLA:
case OPC_PRECEQU_PH_QBRA:
case OPC_PRECEU_PH_QBL:
case OPC_PRECEU_PH_QBR:
case OPC_PRECEU_PH_QBLA:
case OPC_PRECEU_PH_QBRA:
gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt);
break;
case OPC_BITREV:
case OPC_REPL_QB:
case OPC_REPLV_QB:
case OPC_REPL_PH:
case OPC_REPLV_PH:
gen_mipsdsp_bitinsn(ctx, op1, op2, rd, rt);
break;
default:
MIPS_INVAL("MASK ABSQ_S.PH");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_ADDU_QB_DSP:
op2 = MASK_ADDU_QB(ctx->opcode);
switch (op2) {
case OPC_ADDQ_PH:
case OPC_ADDQ_S_PH:
case OPC_ADDQ_S_W:
case OPC_ADDU_QB:
case OPC_ADDU_S_QB:
case OPC_ADDU_PH:
case OPC_ADDU_S_PH:
case OPC_SUBQ_PH:
case OPC_SUBQ_S_PH:
case OPC_SUBQ_S_W:
case OPC_SUBU_QB:
case OPC_SUBU_S_QB:
case OPC_SUBU_PH:
case OPC_SUBU_S_PH:
case OPC_ADDSC:
case OPC_ADDWC:
case OPC_MODSUB:
case OPC_RADDU_W_QB:
gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt);
break;
case OPC_MULEU_S_PH_QBL:
case OPC_MULEU_S_PH_QBR:
case OPC_MULQ_RS_PH:
case OPC_MULEQ_S_W_PHL:
case OPC_MULEQ_S_W_PHR:
case OPC_MULQ_S_PH:
gen_mipsdsp_multiply(ctx, op1, op2, rd, rs, rt, 1);
break;
default:
MIPS_INVAL("MASK ADDU.QB");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_CMPU_EQ_QB_DSP:
op2 = MASK_CMPU_EQ_QB(ctx->opcode);
switch (op2) {
case OPC_PRECR_SRA_PH_W:
case OPC_PRECR_SRA_R_PH_W:
gen_mipsdsp_arith(ctx, op1, op2, rt, rs, rd);
break;
case OPC_PRECR_QB_PH:
case OPC_PRECRQ_QB_PH:
case OPC_PRECRQ_PH_W:
case OPC_PRECRQ_RS_PH_W:
case OPC_PRECRQU_S_QB_PH:
gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt);
break;
case OPC_CMPU_EQ_QB:
case OPC_CMPU_LT_QB:
case OPC_CMPU_LE_QB:
case OPC_CMP_EQ_PH:
case OPC_CMP_LT_PH:
case OPC_CMP_LE_PH:
gen_mipsdsp_add_cmp_pick(ctx, op1, op2, rd, rs, rt, 0);
break;
case OPC_CMPGU_EQ_QB:
case OPC_CMPGU_LT_QB:
case OPC_CMPGU_LE_QB:
case OPC_CMPGDU_EQ_QB:
case OPC_CMPGDU_LT_QB:
case OPC_CMPGDU_LE_QB:
case OPC_PICK_QB:
case OPC_PICK_PH:
case OPC_PACKRL_PH:
gen_mipsdsp_add_cmp_pick(ctx, op1, op2, rd, rs, rt, 1);
break;
default:
MIPS_INVAL("MASK CMPU.EQ.QB");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_SHLL_QB_DSP:
gen_mipsdsp_shift(ctx, op1, rd, rs, rt);
break;
case OPC_DPA_W_PH_DSP:
op2 = MASK_DPA_W_PH(ctx->opcode);
switch (op2) {
case OPC_DPAU_H_QBL:
case OPC_DPAU_H_QBR:
case OPC_DPSU_H_QBL:
case OPC_DPSU_H_QBR:
case OPC_DPA_W_PH:
case OPC_DPAX_W_PH:
case OPC_DPAQ_S_W_PH:
case OPC_DPAQX_S_W_PH:
case OPC_DPAQX_SA_W_PH:
case OPC_DPS_W_PH:
case OPC_DPSX_W_PH:
case OPC_DPSQ_S_W_PH:
case OPC_DPSQX_S_W_PH:
case OPC_DPSQX_SA_W_PH:
case OPC_MULSAQ_S_W_PH:
case OPC_DPAQ_SA_L_W:
case OPC_DPSQ_SA_L_W:
case OPC_MAQ_S_W_PHL:
case OPC_MAQ_S_W_PHR:
case OPC_MAQ_SA_W_PHL:
case OPC_MAQ_SA_W_PHR:
case OPC_MULSA_W_PH:
gen_mipsdsp_multiply(ctx, op1, op2, rd, rs, rt, 0);
break;
default:
MIPS_INVAL("MASK DPAW.PH");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_INSV_DSP:
op2 = MASK_INSV(ctx->opcode);
switch (op2) {
case OPC_INSV:
check_dsp(ctx);
{
TCGv t0, t1;
if (rt == 0) {
MIPS_DEBUG("NOP");
break;
}
t0 = tcg_temp_new();
t1 = tcg_temp_new();
gen_load_gpr(t0, rt);
gen_load_gpr(t1, rs);
gen_helper_insv(cpu_gpr[rt], cpu_env, t1, t0);
tcg_temp_free(t0);
tcg_temp_free(t1);
break;
}
default:
MIPS_INVAL("MASK INSV");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_APPEND_DSP:
gen_mipsdsp_append(env, ctx, op1, rt, rs, rd);
break;
case OPC_EXTR_W_DSP:
op2 = MASK_EXTR_W(ctx->opcode);
switch (op2) {
case OPC_EXTR_W:
case OPC_EXTR_R_W:
case OPC_EXTR_RS_W:
case OPC_EXTR_S_H:
case OPC_EXTRV_S_H:
case OPC_EXTRV_W:
case OPC_EXTRV_R_W:
case OPC_EXTRV_RS_W:
case OPC_EXTP:
case OPC_EXTPV:
case OPC_EXTPDP:
case OPC_EXTPDPV:
gen_mipsdsp_accinsn(ctx, op1, op2, rt, rs, rd, 1);
break;
case OPC_RDDSP:
gen_mipsdsp_accinsn(ctx, op1, op2, rd, rs, rt, 1);
break;
case OPC_SHILO:
case OPC_SHILOV:
case OPC_MTHLIP:
case OPC_WRDSP:
gen_mipsdsp_accinsn(ctx, op1, op2, rd, rs, rt, 0);
break;
default:
MIPS_INVAL("MASK EXTR.W");
generate_exception(ctx, EXCP_RI);
break;
}
break;
#if defined(TARGET_MIPS64)
case OPC_DEXTM ... OPC_DEXT:
case OPC_DINSM ... OPC_DINS:
check_insn(ctx, ISA_MIPS64R2);
check_mips_64(ctx);
gen_bitops(ctx, op1, rt, rs, sa, rd);
break;
case OPC_DBSHFL:
check_insn(ctx, ISA_MIPS64R2);
check_mips_64(ctx);
op2 = MASK_DBSHFL(ctx->opcode);
gen_bshfl(ctx, op2, rt, rd);
break;
case OPC_DDIV_G_2E ... OPC_DDIVU_G_2E:
case OPC_DMULT_G_2E ... OPC_DMULTU_G_2E:
case OPC_DMOD_G_2E ... OPC_DMODU_G_2E:
check_insn(ctx, INSN_LOONGSON2E);
gen_loongson_integer(ctx, op1, rd, rs, rt);
break;
case OPC_ABSQ_S_QH_DSP:
op2 = MASK_ABSQ_S_QH(ctx->opcode);
switch (op2) {
case OPC_PRECEQ_L_PWL:
case OPC_PRECEQ_L_PWR:
case OPC_PRECEQ_PW_QHL:
case OPC_PRECEQ_PW_QHR:
case OPC_PRECEQ_PW_QHLA:
case OPC_PRECEQ_PW_QHRA:
case OPC_PRECEQU_QH_OBL:
case OPC_PRECEQU_QH_OBR:
case OPC_PRECEQU_QH_OBLA:
case OPC_PRECEQU_QH_OBRA:
case OPC_PRECEU_QH_OBL:
case OPC_PRECEU_QH_OBR:
case OPC_PRECEU_QH_OBLA:
case OPC_PRECEU_QH_OBRA:
case OPC_ABSQ_S_OB:
case OPC_ABSQ_S_PW:
case OPC_ABSQ_S_QH:
gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt);
break;
case OPC_REPL_OB:
case OPC_REPL_PW:
case OPC_REPL_QH:
case OPC_REPLV_OB:
case OPC_REPLV_PW:
case OPC_REPLV_QH:
gen_mipsdsp_bitinsn(ctx, op1, op2, rd, rt);
break;
default:
MIPS_INVAL("MASK ABSQ_S.QH");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_ADDU_OB_DSP:
op2 = MASK_ADDU_OB(ctx->opcode);
switch (op2) {
case OPC_RADDU_L_OB:
case OPC_SUBQ_PW:
case OPC_SUBQ_S_PW:
case OPC_SUBQ_QH:
case OPC_SUBQ_S_QH:
case OPC_SUBU_OB:
case OPC_SUBU_S_OB:
case OPC_SUBU_QH:
case OPC_SUBU_S_QH:
case OPC_SUBUH_OB:
case OPC_SUBUH_R_OB:
case OPC_ADDQ_PW:
case OPC_ADDQ_S_PW:
case OPC_ADDQ_QH:
case OPC_ADDQ_S_QH:
case OPC_ADDU_OB:
case OPC_ADDU_S_OB:
case OPC_ADDU_QH:
case OPC_ADDU_S_QH:
case OPC_ADDUH_OB:
case OPC_ADDUH_R_OB:
gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt);
break;
case OPC_MULEQ_S_PW_QHL:
case OPC_MULEQ_S_PW_QHR:
case OPC_MULEU_S_QH_OBL:
case OPC_MULEU_S_QH_OBR:
case OPC_MULQ_RS_QH:
gen_mipsdsp_multiply(ctx, op1, op2, rd, rs, rt, 1);
break;
default:
MIPS_INVAL("MASK ADDU.OB");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_CMPU_EQ_OB_DSP:
op2 = MASK_CMPU_EQ_OB(ctx->opcode);
switch (op2) {
case OPC_PRECR_SRA_QH_PW:
case OPC_PRECR_SRA_R_QH_PW:
gen_mipsdsp_arith(ctx, op1, op2, rt, rs, rd);
break;
case OPC_PRECR_OB_QH:
case OPC_PRECRQ_OB_QH:
case OPC_PRECRQ_PW_L:
case OPC_PRECRQ_QH_PW:
case OPC_PRECRQ_RS_QH_PW:
case OPC_PRECRQU_S_OB_QH:
gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt);
break;
case OPC_CMPU_EQ_OB:
case OPC_CMPU_LT_OB:
case OPC_CMPU_LE_OB:
case OPC_CMP_EQ_QH:
case OPC_CMP_LT_QH:
case OPC_CMP_LE_QH:
case OPC_CMP_EQ_PW:
case OPC_CMP_LT_PW:
case OPC_CMP_LE_PW:
gen_mipsdsp_add_cmp_pick(ctx, op1, op2, rd, rs, rt, 0);
break;
case OPC_CMPGDU_EQ_OB:
case OPC_CMPGDU_LT_OB:
case OPC_CMPGDU_LE_OB:
case OPC_CMPGU_EQ_OB:
case OPC_CMPGU_LT_OB:
case OPC_CMPGU_LE_OB:
case OPC_PACKRL_PW:
case OPC_PICK_OB:
case OPC_PICK_PW:
case OPC_PICK_QH:
gen_mipsdsp_add_cmp_pick(ctx, op1, op2, rd, rs, rt, 1);
break;
default:
MIPS_INVAL("MASK CMPU_EQ.OB");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_DAPPEND_DSP:
gen_mipsdsp_append(env, ctx, op1, rt, rs, rd);
break;
case OPC_DEXTR_W_DSP:
op2 = MASK_DEXTR_W(ctx->opcode);
switch (op2) {
case OPC_DEXTP:
case OPC_DEXTPDP:
case OPC_DEXTPDPV:
case OPC_DEXTPV:
case OPC_DEXTR_L:
case OPC_DEXTR_R_L:
case OPC_DEXTR_RS_L:
case OPC_DEXTR_W:
case OPC_DEXTR_R_W:
case OPC_DEXTR_RS_W:
case OPC_DEXTR_S_H:
case OPC_DEXTRV_L:
case OPC_DEXTRV_R_L:
case OPC_DEXTRV_RS_L:
case OPC_DEXTRV_S_H:
case OPC_DEXTRV_W:
case OPC_DEXTRV_R_W:
case OPC_DEXTRV_RS_W:
gen_mipsdsp_accinsn(ctx, op1, op2, rt, rs, rd, 1);
break;
case OPC_DMTHLIP:
case OPC_DSHILO:
case OPC_DSHILOV:
gen_mipsdsp_accinsn(ctx, op1, op2, rd, rs, rt, 0);
break;
default:
MIPS_INVAL("MASK EXTR.W");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_DPAQ_W_QH_DSP:
op2 = MASK_DPAQ_W_QH(ctx->opcode);
switch (op2) {
case OPC_DPAU_H_OBL:
case OPC_DPAU_H_OBR:
case OPC_DPSU_H_OBL:
case OPC_DPSU_H_OBR:
case OPC_DPA_W_QH:
case OPC_DPAQ_S_W_QH:
case OPC_DPS_W_QH:
case OPC_DPSQ_S_W_QH:
case OPC_MULSAQ_S_W_QH:
case OPC_DPAQ_SA_L_PW:
case OPC_DPSQ_SA_L_PW:
case OPC_MULSAQ_S_L_PW:
gen_mipsdsp_multiply(ctx, op1, op2, rd, rs, rt, 0);
break;
case OPC_MAQ_S_W_QHLL:
case OPC_MAQ_S_W_QHLR:
case OPC_MAQ_S_W_QHRL:
case OPC_MAQ_S_W_QHRR:
case OPC_MAQ_SA_W_QHLL:
case OPC_MAQ_SA_W_QHLR:
case OPC_MAQ_SA_W_QHRL:
case OPC_MAQ_SA_W_QHRR:
case OPC_MAQ_S_L_PWL:
case OPC_MAQ_S_L_PWR:
case OPC_DMADD:
case OPC_DMADDU:
case OPC_DMSUB:
case OPC_DMSUBU:
gen_mipsdsp_multiply(ctx, op1, op2, rd, rs, rt, 0);
break;
default:
MIPS_INVAL("MASK DPAQ.W.QH");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_DINSV_DSP:
op2 = MASK_INSV(ctx->opcode);
switch (op2) {
case OPC_DINSV:
{
TCGv t0, t1;
if (rt == 0) {
MIPS_DEBUG("NOP");
break;
}
check_dsp(ctx);
t0 = tcg_temp_new();
t1 = tcg_temp_new();
gen_load_gpr(t0, rt);
gen_load_gpr(t1, rs);
gen_helper_dinsv(cpu_gpr[rt], cpu_env, t1, t0);
break;
}
default:
MIPS_INVAL("MASK DINSV");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_SHLL_OB_DSP:
gen_mipsdsp_shift(ctx, op1, rd, rs, rt);
break;
#endif
default:
MIPS_INVAL("special3");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_REGIMM:
op1 = MASK_REGIMM(ctx->opcode);
switch (op1) {
case OPC_BLTZ ... OPC_BGEZL:
case OPC_BLTZAL ... OPC_BGEZALL:
gen_compute_branch(ctx, op1, 4, rs, -1, imm << 2);
*is_branch = 1;
break;
case OPC_TGEI ... OPC_TEQI:
case OPC_TNEI:
gen_trap(ctx, op1, rs, -1, imm);
break;
case OPC_SYNCI:
check_insn(ctx, ISA_MIPS32R2);
break;
case OPC_BPOSGE32:
#if defined(TARGET_MIPS64)
case OPC_BPOSGE64:
#endif
check_dsp(ctx);
gen_compute_branch(ctx, op1, 4, -1, -2, (int32_t)imm << 2);
*is_branch = 1;
break;
default:
MIPS_INVAL("regimm");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_CP0:
check_cp0_enabled(ctx);
op1 = MASK_CP0(ctx->opcode);
switch (op1) {
case OPC_MFC0:
case OPC_MTC0:
case OPC_MFTR:
case OPC_MTTR:
#if defined(TARGET_MIPS64)
case OPC_DMFC0:
case OPC_DMTC0:
#endif
#ifndef CONFIG_USER_ONLY
gen_cp0(env, ctx, op1, rt, rd);
#endif
break;
case OPC_C0_FIRST ... OPC_C0_LAST:
#ifndef CONFIG_USER_ONLY
gen_cp0(env, ctx, MASK_C0(ctx->opcode), rt, rd);
#endif
break;
case OPC_MFMC0:
#ifndef CONFIG_USER_ONLY
{
TCGv t0 = tcg_temp_new();
op2 = MASK_MFMC0(ctx->opcode);
switch (op2) {
case OPC_DMT:
check_insn(ctx, ASE_MT);
gen_helper_dmt(t0);
gen_store_gpr(t0, rt);
break;
case OPC_EMT:
check_insn(ctx, ASE_MT);
gen_helper_emt(t0);
gen_store_gpr(t0, rt);
break;
case OPC_DVPE:
check_insn(ctx, ASE_MT);
gen_helper_dvpe(t0, cpu_env);
gen_store_gpr(t0, rt);
break;
case OPC_EVPE:
check_insn(ctx, ASE_MT);
gen_helper_evpe(t0, cpu_env);
gen_store_gpr(t0, rt);
break;
case OPC_DI:
check_insn(ctx, ISA_MIPS32R2);
save_cpu_state(ctx, 1);
gen_helper_di(t0, cpu_env);
gen_store_gpr(t0, rt);
ctx->bstate = BS_STOP;
break;
case OPC_EI:
check_insn(ctx, ISA_MIPS32R2);
save_cpu_state(ctx, 1);
gen_helper_ei(t0, cpu_env);
gen_store_gpr(t0, rt);
ctx->bstate = BS_STOP;
break;
default:
MIPS_INVAL("mfmc0");
generate_exception(ctx, EXCP_RI);
break;
}
tcg_temp_free(t0);
}
#endif
break;
case OPC_RDPGPR:
check_insn(ctx, ISA_MIPS32R2);
gen_load_srsgpr(rt, rd);
break;
case OPC_WRPGPR:
check_insn(ctx, ISA_MIPS32R2);
gen_store_srsgpr(rt, rd);
break;
default:
MIPS_INVAL("cp0");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_ADDI:
case OPC_ADDIU:
gen_arith_imm(ctx, op, rt, rs, imm);
break;
case OPC_SLTI:
case OPC_SLTIU:
gen_slt_imm(ctx, op, rt, rs, imm);
break;
case OPC_ANDI:
case OPC_LUI:
case OPC_ORI:
case OPC_XORI:
gen_logic_imm(ctx, op, rt, rs, imm);
break;
case OPC_J ... OPC_JAL:
offset = (int32_t)(ctx->opcode & 0x3FFFFFF) << 2;
gen_compute_branch(ctx, op, 4, rs, rt, offset);
*is_branch = 1;
break;
case OPC_BEQ ... OPC_BGTZ:
case OPC_BEQL ... OPC_BGTZL:
gen_compute_branch(ctx, op, 4, rs, rt, imm << 2);
*is_branch = 1;
break;
case OPC_LB ... OPC_LWR:
case OPC_LL:
gen_ld(ctx, op, rt, rs, imm);
break;
case OPC_SB ... OPC_SW:
case OPC_SWR:
gen_st(ctx, op, rt, rs, imm);
break;
case OPC_SC:
gen_st_cond(ctx, op, rt, rs, imm);
break;
case OPC_CACHE:
check_cp0_enabled(ctx);
check_insn(ctx, ISA_MIPS3 | ISA_MIPS32);
break;
case OPC_PREF:
check_insn(ctx, ISA_MIPS4 | ISA_MIPS32);
break;
case OPC_LWC1:
case OPC_LDC1:
case OPC_SWC1:
case OPC_SDC1:
gen_cop1_ldst(env, ctx, op, rt, rs, imm);
break;
case OPC_CP1:
if (env->CP0_Config1 & (1 << CP0C1_FP)) {
check_cp1_enabled(ctx);
op1 = MASK_CP1(ctx->opcode);
switch (op1) {
case OPC_MFHC1:
case OPC_MTHC1:
check_insn(ctx, ISA_MIPS32R2);
case OPC_MFC1:
case OPC_CFC1:
case OPC_MTC1:
case OPC_CTC1:
gen_cp1(ctx, op1, rt, rd);
break;
#if defined(TARGET_MIPS64)
case OPC_DMFC1:
case OPC_DMTC1:
check_insn(ctx, ISA_MIPS3);
gen_cp1(ctx, op1, rt, rd);
break;
#endif
case OPC_BC1ANY2:
case OPC_BC1ANY4:
check_cop1x(ctx);
check_insn(ctx, ASE_MIPS3D);
case OPC_BC1:
gen_compute_branch1(ctx, MASK_BC1(ctx->opcode),
(rt >> 2) & 0x7, imm << 2);
*is_branch = 1;
break;
case OPC_S_FMT:
case OPC_D_FMT:
case OPC_W_FMT:
case OPC_L_FMT:
case OPC_PS_FMT:
gen_farith(ctx, ctx->opcode & FOP(0x3f, 0x1f), rt, rd, sa,
(imm >> 8) & 0x7);
break;
default:
MIPS_INVAL("cp1");
generate_exception (ctx, EXCP_RI);
break;
}
} else {
generate_exception_err(ctx, EXCP_CpU, 1);
}
break;
case OPC_LWC2:
case OPC_LDC2:
case OPC_SWC2:
case OPC_SDC2:
generate_exception_err(ctx, EXCP_CpU, 2);
break;
case OPC_CP2:
check_insn(ctx, INSN_LOONGSON2F);
gen_loongson_multimedia(ctx, sa, rd, rt);
break;
case OPC_CP3:
if (env->CP0_Config1 & (1 << CP0C1_FP)) {
check_cp1_enabled(ctx);
op1 = MASK_CP3(ctx->opcode);
switch (op1) {
case OPC_LWXC1:
case OPC_LDXC1:
case OPC_LUXC1:
case OPC_SWXC1:
case OPC_SDXC1:
case OPC_SUXC1:
gen_flt3_ldst(ctx, op1, sa, rd, rs, rt);
break;
case OPC_PREFX:
break;
case OPC_ALNV_PS:
case OPC_MADD_S:
case OPC_MADD_D:
case OPC_MADD_PS:
case OPC_MSUB_S:
case OPC_MSUB_D:
case OPC_MSUB_PS:
case OPC_NMADD_S:
case OPC_NMADD_D:
case OPC_NMADD_PS:
case OPC_NMSUB_S:
case OPC_NMSUB_D:
case OPC_NMSUB_PS:
gen_flt3_arith(ctx, op1, sa, rs, rd, rt);
break;
default:
MIPS_INVAL("cp3");
generate_exception (ctx, EXCP_RI);
break;
}
} else {
generate_exception_err(ctx, EXCP_CpU, 1);
}
break;
#if defined(TARGET_MIPS64)
case OPC_LWU:
case OPC_LDL ... OPC_LDR:
case OPC_LLD:
case OPC_LD:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_ld(ctx, op, rt, rs, imm);
break;
case OPC_SDL ... OPC_SDR:
case OPC_SD:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_st(ctx, op, rt, rs, imm);
break;
case OPC_SCD:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_st_cond(ctx, op, rt, rs, imm);
break;
case OPC_DADDI:
case OPC_DADDIU:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
gen_arith_imm(ctx, op, rt, rs, imm);
break;
#endif
case OPC_JALX:
check_insn(ctx, ASE_MIPS16 | ASE_MICROMIPS);
offset = (int32_t)(ctx->opcode & 0x3FFFFFF) << 2;
gen_compute_branch(ctx, op, 4, rs, rt, offset);
*is_branch = 1;
break;
case OPC_MDMX:
check_insn(ctx, ASE_MDMX);
default:
MIPS_INVAL("major opcode");
generate_exception(ctx, EXCP_RI);
break;
}
}
| {
"code": [
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;",
"static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;"
],
"line_no": [
2363,
2363,
2363,
229,
229,
229,
229,
2363,
2363,
2363,
2363,
2363,
2363,
2363,
2363,
1,
229,
229,
229,
2019,
2019,
2149,
2363
]
} | static void FUNC_0 (CPUMIPSState *VAR_0, DisasContext *VAR_1, int *VAR_2)
{
int32_t offset;
int VAR_3, VAR_4, VAR_5, VAR_6;
uint32_t op, op1, op2;
int16_t imm;
if (VAR_1->pc & 0x3) {
VAR_0->CP0_BadVAddr = VAR_1->pc;
generate_exception(VAR_1, EXCP_AdEL);
return;
}
if ((VAR_1->hflags & MIPS_HFLAG_BMASK_BASE) == MIPS_HFLAG_BL) {
int VAR_7 = gen_new_label();
MIPS_DEBUG("blikely condition (" TARGET_FMT_lx ")", VAR_1->pc + 4);
tcg_gen_brcondi_tl(TCG_COND_NE, bcond, 0, VAR_7);
tcg_gen_movi_i32(hflags, VAR_1->hflags & ~MIPS_HFLAG_BMASK);
gen_goto_tb(VAR_1, 1, VAR_1->pc + 4);
gen_set_label(VAR_7);
}
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_debug_insn_start(VAR_1->pc);
}
op = MASK_OP_MAJOR(VAR_1->opcode);
VAR_3 = (VAR_1->opcode >> 21) & 0x1f;
VAR_4 = (VAR_1->opcode >> 16) & 0x1f;
VAR_5 = (VAR_1->opcode >> 11) & 0x1f;
VAR_6 = (VAR_1->opcode >> 6) & 0x1f;
imm = (int16_t)VAR_1->opcode;
switch (op) {
case OPC_SPECIAL:
op1 = MASK_SPECIAL(VAR_1->opcode);
switch (op1) {
case OPC_SLL:
case OPC_SRA:
gen_shift_imm(VAR_1, op1, VAR_5, VAR_4, VAR_6);
break;
case OPC_SRL:
switch ((VAR_1->opcode >> 21) & 0x1f) {
case 1:
if (VAR_1->insn_flags & ISA_MIPS32R2) {
op1 = OPC_ROTR;
}
case 0:
gen_shift_imm(VAR_1, op1, VAR_5, VAR_4, VAR_6);
break;
default:
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case OPC_MOVN:
case OPC_MOVZ:
check_insn(VAR_1, ISA_MIPS4 | ISA_MIPS32 |
INSN_LOONGSON2E | INSN_LOONGSON2F);
gen_cond_move(VAR_1, op1, VAR_5, VAR_3, VAR_4);
break;
case OPC_ADD ... OPC_SUBU:
gen_arith(VAR_1, op1, VAR_5, VAR_3, VAR_4);
break;
case OPC_SLLV:
case OPC_SRAV:
gen_shift(VAR_1, op1, VAR_5, VAR_3, VAR_4);
break;
case OPC_SRLV:
switch ((VAR_1->opcode >> 6) & 0x1f) {
case 1:
if (VAR_1->insn_flags & ISA_MIPS32R2) {
op1 = OPC_ROTRV;
}
case 0:
gen_shift(VAR_1, op1, VAR_5, VAR_3, VAR_4);
break;
default:
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case OPC_SLT:
case OPC_SLTU:
gen_slt(VAR_1, op1, VAR_5, VAR_3, VAR_4);
break;
case OPC_AND:
case OPC_OR:
case OPC_NOR:
case OPC_XOR:
gen_logic(VAR_1, op1, VAR_5, VAR_3, VAR_4);
break;
case OPC_MULT:
case OPC_MULTU:
if (VAR_6) {
check_insn(VAR_1, INSN_VR54XX);
op1 = MASK_MUL_VR54XX(VAR_1->opcode);
gen_mul_vr54xx(VAR_1, op1, VAR_5, VAR_3, VAR_4);
} else {
gen_muldiv(VAR_1, op1, VAR_5 & 3, VAR_3, VAR_4);
}
break;
case OPC_DIV:
case OPC_DIVU:
gen_muldiv(VAR_1, op1, 0, VAR_3, VAR_4);
break;
case OPC_JR ... OPC_JALR:
gen_compute_branch(VAR_1, op1, 4, VAR_3, VAR_5, VAR_6);
*VAR_2 = 1;
break;
case OPC_TGE ... OPC_TEQ:
case OPC_TNE:
gen_trap(VAR_1, op1, VAR_3, VAR_4, -1);
break;
case OPC_MFHI:
case OPC_MFLO:
gen_HILO(VAR_1, op1, VAR_3 & 3, VAR_5);
break;
case OPC_MTHI:
case OPC_MTLO:
gen_HILO(VAR_1, op1, VAR_5 & 3, VAR_3);
break;
case OPC_PMON:
#ifdef MIPS_STRICT_STANDARD
MIPS_INVAL("PMON / selsl");
generate_exception(VAR_1, EXCP_RI);
#else
gen_helper_0e0i(pmon, VAR_6);
#endif
break;
case OPC_SYSCALL:
generate_exception(VAR_1, EXCP_SYSCALL);
VAR_1->bstate = BS_STOP;
break;
case OPC_BREAK:
generate_exception(VAR_1, EXCP_BREAK);
break;
case OPC_SPIM:
#ifdef MIPS_STRICT_STANDARD
MIPS_INVAL("SPIM");
generate_exception(VAR_1, EXCP_RI);
#else
MIPS_INVAL("spim (unofficial)");
generate_exception(VAR_1, EXCP_RI);
#endif
break;
case OPC_SYNC:
break;
case OPC_MOVCI:
check_insn(VAR_1, ISA_MIPS4 | ISA_MIPS32);
if (VAR_0->CP0_Config1 & (1 << CP0C1_FP)) {
check_cp1_enabled(VAR_1);
gen_movci(VAR_1, VAR_5, VAR_3, (VAR_1->opcode >> 18) & 0x7,
(VAR_1->opcode >> 16) & 1);
} else {
generate_exception_err(VAR_1, EXCP_CpU, 1);
}
break;
#if defined(TARGET_MIPS64)
case OPC_DSLL:
case OPC_DSRA:
case OPC_DSLL32:
case OPC_DSRA32:
check_insn(VAR_1, ISA_MIPS3);
check_mips_64(VAR_1);
gen_shift_imm(VAR_1, op1, VAR_5, VAR_4, VAR_6);
break;
case OPC_DSRL:
switch ((VAR_1->opcode >> 21) & 0x1f) {
case 1:
if (VAR_1->insn_flags & ISA_MIPS32R2) {
op1 = OPC_DROTR;
}
case 0:
check_insn(VAR_1, ISA_MIPS3);
check_mips_64(VAR_1);
gen_shift_imm(VAR_1, op1, VAR_5, VAR_4, VAR_6);
break;
default:
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case OPC_DSRL32:
switch ((VAR_1->opcode >> 21) & 0x1f) {
case 1:
if (VAR_1->insn_flags & ISA_MIPS32R2) {
op1 = OPC_DROTR32;
}
case 0:
check_insn(VAR_1, ISA_MIPS3);
check_mips_64(VAR_1);
gen_shift_imm(VAR_1, op1, VAR_5, VAR_4, VAR_6);
break;
default:
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case OPC_DADD ... OPC_DSUBU:
check_insn(VAR_1, ISA_MIPS3);
check_mips_64(VAR_1);
gen_arith(VAR_1, op1, VAR_5, VAR_3, VAR_4);
break;
case OPC_DSLLV:
case OPC_DSRAV:
check_insn(VAR_1, ISA_MIPS3);
check_mips_64(VAR_1);
gen_shift(VAR_1, op1, VAR_5, VAR_3, VAR_4);
break;
case OPC_DSRLV:
switch ((VAR_1->opcode >> 6) & 0x1f) {
case 1:
if (VAR_1->insn_flags & ISA_MIPS32R2) {
op1 = OPC_DROTRV;
}
case 0:
check_insn(VAR_1, ISA_MIPS3);
check_mips_64(VAR_1);
gen_shift(VAR_1, op1, VAR_5, VAR_3, VAR_4);
break;
default:
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case OPC_DMULT ... OPC_DDIVU:
check_insn(VAR_1, ISA_MIPS3);
check_mips_64(VAR_1);
gen_muldiv(VAR_1, op1, 0, VAR_3, VAR_4);
break;
#endif
default:
MIPS_INVAL("special");
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case OPC_SPECIAL2:
op1 = MASK_SPECIAL2(VAR_1->opcode);
switch (op1) {
case OPC_MADD ... OPC_MADDU:
case OPC_MSUB ... OPC_MSUBU:
check_insn(VAR_1, ISA_MIPS32);
gen_muldiv(VAR_1, op1, VAR_5 & 3, VAR_3, VAR_4);
break;
case OPC_MUL:
gen_arith(VAR_1, op1, VAR_5, VAR_3, VAR_4);
break;
case OPC_CLO:
case OPC_CLZ:
check_insn(VAR_1, ISA_MIPS32);
gen_cl(VAR_1, op1, VAR_5, VAR_3);
break;
case OPC_SDBBP:
check_insn(VAR_1, ISA_MIPS32);
if (!(VAR_1->hflags & MIPS_HFLAG_DM)) {
generate_exception(VAR_1, EXCP_DBp);
} else {
generate_exception(VAR_1, EXCP_DBp);
}
break;
case OPC_DIV_G_2F:
case OPC_DIVU_G_2F:
case OPC_MULT_G_2F:
case OPC_MULTU_G_2F:
case OPC_MOD_G_2F:
case OPC_MODU_G_2F:
check_insn(VAR_1, INSN_LOONGSON2F);
gen_loongson_integer(VAR_1, op1, VAR_5, VAR_3, VAR_4);
break;
#if defined(TARGET_MIPS64)
case OPC_DCLO:
case OPC_DCLZ:
check_insn(VAR_1, ISA_MIPS64);
check_mips_64(VAR_1);
gen_cl(VAR_1, op1, VAR_5, VAR_3);
break;
case OPC_DMULT_G_2F:
case OPC_DMULTU_G_2F:
case OPC_DDIV_G_2F:
case OPC_DDIVU_G_2F:
case OPC_DMOD_G_2F:
case OPC_DMODU_G_2F:
check_insn(VAR_1, INSN_LOONGSON2F);
gen_loongson_integer(VAR_1, op1, VAR_5, VAR_3, VAR_4);
break;
#endif
default:
MIPS_INVAL("special2");
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case OPC_SPECIAL3:
op1 = MASK_SPECIAL3(VAR_1->opcode);
switch (op1) {
case OPC_EXT:
case OPC_INS:
check_insn(VAR_1, ISA_MIPS32R2);
gen_bitops(VAR_1, op1, VAR_4, VAR_3, VAR_6, VAR_5);
break;
case OPC_BSHFL:
check_insn(VAR_1, ISA_MIPS32R2);
op2 = MASK_BSHFL(VAR_1->opcode);
gen_bshfl(VAR_1, op2, VAR_4, VAR_5);
break;
case OPC_RDHWR:
gen_rdhwr(VAR_1, VAR_4, VAR_5);
break;
case OPC_FORK:
check_insn(VAR_1, ASE_MT);
{
TCGv t0 = tcg_temp_new();
TCGv t1 = tcg_temp_new();
gen_load_gpr(t0, VAR_4);
gen_load_gpr(t1, VAR_3);
gen_helper_fork(t0, t1);
tcg_temp_free(t0);
tcg_temp_free(t1);
}
break;
case OPC_YIELD:
check_insn(VAR_1, ASE_MT);
{
TCGv t0 = tcg_temp_new();
save_cpu_state(VAR_1, 1);
gen_load_gpr(t0, VAR_3);
gen_helper_yield(t0, cpu_env, t0);
gen_store_gpr(t0, VAR_5);
tcg_temp_free(t0);
}
break;
case OPC_DIV_G_2E ... OPC_DIVU_G_2E:
case OPC_MOD_G_2E ... OPC_MODU_G_2E:
case OPC_MULT_G_2E ... OPC_MULTU_G_2E:
if ((VAR_1->insn_flags & ASE_DSPR2) && (op1 == OPC_MULT_G_2E)) {
op2 = MASK_ADDUH_QB(VAR_1->opcode);
switch (op2) {
case OPC_ADDUH_QB:
case OPC_ADDUH_R_QB:
case OPC_ADDQH_PH:
case OPC_ADDQH_R_PH:
case OPC_ADDQH_W:
case OPC_ADDQH_R_W:
case OPC_SUBUH_QB:
case OPC_SUBUH_R_QB:
case OPC_SUBQH_PH:
case OPC_SUBQH_R_PH:
case OPC_SUBQH_W:
case OPC_SUBQH_R_W:
gen_mipsdsp_arith(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4);
break;
case OPC_MUL_PH:
case OPC_MUL_S_PH:
case OPC_MULQ_S_W:
case OPC_MULQ_RS_W:
gen_mipsdsp_multiply(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 1);
break;
default:
MIPS_INVAL("MASK ADDUH.QB");
generate_exception(VAR_1, EXCP_RI);
break;
}
} else if (VAR_1->insn_flags & INSN_LOONGSON2E) {
gen_loongson_integer(VAR_1, op1, VAR_5, VAR_3, VAR_4);
} else {
generate_exception(VAR_1, EXCP_RI);
}
break;
case OPC_LX_DSP:
op2 = MASK_LX(VAR_1->opcode);
switch (op2) {
#if defined(TARGET_MIPS64)
case OPC_LDX:
#endif
case OPC_LBUX:
case OPC_LHX:
case OPC_LWX:
gen_mipsdsp_ld(VAR_1, op2, VAR_5, VAR_3, VAR_4);
break;
default:
MIPS_INVAL("MASK LX");
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case OPC_ABSQ_S_PH_DSP:
op2 = MASK_ABSQ_S_PH(VAR_1->opcode);
switch (op2) {
case OPC_ABSQ_S_QB:
case OPC_ABSQ_S_PH:
case OPC_ABSQ_S_W:
case OPC_PRECEQ_W_PHL:
case OPC_PRECEQ_W_PHR:
case OPC_PRECEQU_PH_QBL:
case OPC_PRECEQU_PH_QBR:
case OPC_PRECEQU_PH_QBLA:
case OPC_PRECEQU_PH_QBRA:
case OPC_PRECEU_PH_QBL:
case OPC_PRECEU_PH_QBR:
case OPC_PRECEU_PH_QBLA:
case OPC_PRECEU_PH_QBRA:
gen_mipsdsp_arith(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4);
break;
case OPC_BITREV:
case OPC_REPL_QB:
case OPC_REPLV_QB:
case OPC_REPL_PH:
case OPC_REPLV_PH:
gen_mipsdsp_bitinsn(VAR_1, op1, op2, VAR_5, VAR_4);
break;
default:
MIPS_INVAL("MASK ABSQ_S.PH");
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case OPC_ADDU_QB_DSP:
op2 = MASK_ADDU_QB(VAR_1->opcode);
switch (op2) {
case OPC_ADDQ_PH:
case OPC_ADDQ_S_PH:
case OPC_ADDQ_S_W:
case OPC_ADDU_QB:
case OPC_ADDU_S_QB:
case OPC_ADDU_PH:
case OPC_ADDU_S_PH:
case OPC_SUBQ_PH:
case OPC_SUBQ_S_PH:
case OPC_SUBQ_S_W:
case OPC_SUBU_QB:
case OPC_SUBU_S_QB:
case OPC_SUBU_PH:
case OPC_SUBU_S_PH:
case OPC_ADDSC:
case OPC_ADDWC:
case OPC_MODSUB:
case OPC_RADDU_W_QB:
gen_mipsdsp_arith(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4);
break;
case OPC_MULEU_S_PH_QBL:
case OPC_MULEU_S_PH_QBR:
case OPC_MULQ_RS_PH:
case OPC_MULEQ_S_W_PHL:
case OPC_MULEQ_S_W_PHR:
case OPC_MULQ_S_PH:
gen_mipsdsp_multiply(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 1);
break;
default:
MIPS_INVAL("MASK ADDU.QB");
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case OPC_CMPU_EQ_QB_DSP:
op2 = MASK_CMPU_EQ_QB(VAR_1->opcode);
switch (op2) {
case OPC_PRECR_SRA_PH_W:
case OPC_PRECR_SRA_R_PH_W:
gen_mipsdsp_arith(VAR_1, op1, op2, VAR_4, VAR_3, VAR_5);
break;
case OPC_PRECR_QB_PH:
case OPC_PRECRQ_QB_PH:
case OPC_PRECRQ_PH_W:
case OPC_PRECRQ_RS_PH_W:
case OPC_PRECRQU_S_QB_PH:
gen_mipsdsp_arith(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4);
break;
case OPC_CMPU_EQ_QB:
case OPC_CMPU_LT_QB:
case OPC_CMPU_LE_QB:
case OPC_CMP_EQ_PH:
case OPC_CMP_LT_PH:
case OPC_CMP_LE_PH:
gen_mipsdsp_add_cmp_pick(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 0);
break;
case OPC_CMPGU_EQ_QB:
case OPC_CMPGU_LT_QB:
case OPC_CMPGU_LE_QB:
case OPC_CMPGDU_EQ_QB:
case OPC_CMPGDU_LT_QB:
case OPC_CMPGDU_LE_QB:
case OPC_PICK_QB:
case OPC_PICK_PH:
case OPC_PACKRL_PH:
gen_mipsdsp_add_cmp_pick(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 1);
break;
default:
MIPS_INVAL("MASK CMPU.EQ.QB");
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case OPC_SHLL_QB_DSP:
gen_mipsdsp_shift(VAR_1, op1, VAR_5, VAR_3, VAR_4);
break;
case OPC_DPA_W_PH_DSP:
op2 = MASK_DPA_W_PH(VAR_1->opcode);
switch (op2) {
case OPC_DPAU_H_QBL:
case OPC_DPAU_H_QBR:
case OPC_DPSU_H_QBL:
case OPC_DPSU_H_QBR:
case OPC_DPA_W_PH:
case OPC_DPAX_W_PH:
case OPC_DPAQ_S_W_PH:
case OPC_DPAQX_S_W_PH:
case OPC_DPAQX_SA_W_PH:
case OPC_DPS_W_PH:
case OPC_DPSX_W_PH:
case OPC_DPSQ_S_W_PH:
case OPC_DPSQX_S_W_PH:
case OPC_DPSQX_SA_W_PH:
case OPC_MULSAQ_S_W_PH:
case OPC_DPAQ_SA_L_W:
case OPC_DPSQ_SA_L_W:
case OPC_MAQ_S_W_PHL:
case OPC_MAQ_S_W_PHR:
case OPC_MAQ_SA_W_PHL:
case OPC_MAQ_SA_W_PHR:
case OPC_MULSA_W_PH:
gen_mipsdsp_multiply(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 0);
break;
default:
MIPS_INVAL("MASK DPAW.PH");
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case OPC_INSV_DSP:
op2 = MASK_INSV(VAR_1->opcode);
switch (op2) {
case OPC_INSV:
check_dsp(VAR_1);
{
TCGv t0, t1;
if (VAR_4 == 0) {
MIPS_DEBUG("NOP");
break;
}
t0 = tcg_temp_new();
t1 = tcg_temp_new();
gen_load_gpr(t0, VAR_4);
gen_load_gpr(t1, VAR_3);
gen_helper_insv(cpu_gpr[VAR_4], cpu_env, t1, t0);
tcg_temp_free(t0);
tcg_temp_free(t1);
break;
}
default:
MIPS_INVAL("MASK INSV");
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case OPC_APPEND_DSP:
gen_mipsdsp_append(VAR_0, VAR_1, op1, VAR_4, VAR_3, VAR_5);
break;
case OPC_EXTR_W_DSP:
op2 = MASK_EXTR_W(VAR_1->opcode);
switch (op2) {
case OPC_EXTR_W:
case OPC_EXTR_R_W:
case OPC_EXTR_RS_W:
case OPC_EXTR_S_H:
case OPC_EXTRV_S_H:
case OPC_EXTRV_W:
case OPC_EXTRV_R_W:
case OPC_EXTRV_RS_W:
case OPC_EXTP:
case OPC_EXTPV:
case OPC_EXTPDP:
case OPC_EXTPDPV:
gen_mipsdsp_accinsn(VAR_1, op1, op2, VAR_4, VAR_3, VAR_5, 1);
break;
case OPC_RDDSP:
gen_mipsdsp_accinsn(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 1);
break;
case OPC_SHILO:
case OPC_SHILOV:
case OPC_MTHLIP:
case OPC_WRDSP:
gen_mipsdsp_accinsn(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 0);
break;
default:
MIPS_INVAL("MASK EXTR.W");
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
#if defined(TARGET_MIPS64)
case OPC_DEXTM ... OPC_DEXT:
case OPC_DINSM ... OPC_DINS:
check_insn(VAR_1, ISA_MIPS64R2);
check_mips_64(VAR_1);
gen_bitops(VAR_1, op1, VAR_4, VAR_3, VAR_6, VAR_5);
break;
case OPC_DBSHFL:
check_insn(VAR_1, ISA_MIPS64R2);
check_mips_64(VAR_1);
op2 = MASK_DBSHFL(VAR_1->opcode);
gen_bshfl(VAR_1, op2, VAR_4, VAR_5);
break;
case OPC_DDIV_G_2E ... OPC_DDIVU_G_2E:
case OPC_DMULT_G_2E ... OPC_DMULTU_G_2E:
case OPC_DMOD_G_2E ... OPC_DMODU_G_2E:
check_insn(VAR_1, INSN_LOONGSON2E);
gen_loongson_integer(VAR_1, op1, VAR_5, VAR_3, VAR_4);
break;
case OPC_ABSQ_S_QH_DSP:
op2 = MASK_ABSQ_S_QH(VAR_1->opcode);
switch (op2) {
case OPC_PRECEQ_L_PWL:
case OPC_PRECEQ_L_PWR:
case OPC_PRECEQ_PW_QHL:
case OPC_PRECEQ_PW_QHR:
case OPC_PRECEQ_PW_QHLA:
case OPC_PRECEQ_PW_QHRA:
case OPC_PRECEQU_QH_OBL:
case OPC_PRECEQU_QH_OBR:
case OPC_PRECEQU_QH_OBLA:
case OPC_PRECEQU_QH_OBRA:
case OPC_PRECEU_QH_OBL:
case OPC_PRECEU_QH_OBR:
case OPC_PRECEU_QH_OBLA:
case OPC_PRECEU_QH_OBRA:
case OPC_ABSQ_S_OB:
case OPC_ABSQ_S_PW:
case OPC_ABSQ_S_QH:
gen_mipsdsp_arith(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4);
break;
case OPC_REPL_OB:
case OPC_REPL_PW:
case OPC_REPL_QH:
case OPC_REPLV_OB:
case OPC_REPLV_PW:
case OPC_REPLV_QH:
gen_mipsdsp_bitinsn(VAR_1, op1, op2, VAR_5, VAR_4);
break;
default:
MIPS_INVAL("MASK ABSQ_S.QH");
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case OPC_ADDU_OB_DSP:
op2 = MASK_ADDU_OB(VAR_1->opcode);
switch (op2) {
case OPC_RADDU_L_OB:
case OPC_SUBQ_PW:
case OPC_SUBQ_S_PW:
case OPC_SUBQ_QH:
case OPC_SUBQ_S_QH:
case OPC_SUBU_OB:
case OPC_SUBU_S_OB:
case OPC_SUBU_QH:
case OPC_SUBU_S_QH:
case OPC_SUBUH_OB:
case OPC_SUBUH_R_OB:
case OPC_ADDQ_PW:
case OPC_ADDQ_S_PW:
case OPC_ADDQ_QH:
case OPC_ADDQ_S_QH:
case OPC_ADDU_OB:
case OPC_ADDU_S_OB:
case OPC_ADDU_QH:
case OPC_ADDU_S_QH:
case OPC_ADDUH_OB:
case OPC_ADDUH_R_OB:
gen_mipsdsp_arith(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4);
break;
case OPC_MULEQ_S_PW_QHL:
case OPC_MULEQ_S_PW_QHR:
case OPC_MULEU_S_QH_OBL:
case OPC_MULEU_S_QH_OBR:
case OPC_MULQ_RS_QH:
gen_mipsdsp_multiply(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 1);
break;
default:
MIPS_INVAL("MASK ADDU.OB");
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case OPC_CMPU_EQ_OB_DSP:
op2 = MASK_CMPU_EQ_OB(VAR_1->opcode);
switch (op2) {
case OPC_PRECR_SRA_QH_PW:
case OPC_PRECR_SRA_R_QH_PW:
gen_mipsdsp_arith(VAR_1, op1, op2, VAR_4, VAR_3, VAR_5);
break;
case OPC_PRECR_OB_QH:
case OPC_PRECRQ_OB_QH:
case OPC_PRECRQ_PW_L:
case OPC_PRECRQ_QH_PW:
case OPC_PRECRQ_RS_QH_PW:
case OPC_PRECRQU_S_OB_QH:
gen_mipsdsp_arith(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4);
break;
case OPC_CMPU_EQ_OB:
case OPC_CMPU_LT_OB:
case OPC_CMPU_LE_OB:
case OPC_CMP_EQ_QH:
case OPC_CMP_LT_QH:
case OPC_CMP_LE_QH:
case OPC_CMP_EQ_PW:
case OPC_CMP_LT_PW:
case OPC_CMP_LE_PW:
gen_mipsdsp_add_cmp_pick(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 0);
break;
case OPC_CMPGDU_EQ_OB:
case OPC_CMPGDU_LT_OB:
case OPC_CMPGDU_LE_OB:
case OPC_CMPGU_EQ_OB:
case OPC_CMPGU_LT_OB:
case OPC_CMPGU_LE_OB:
case OPC_PACKRL_PW:
case OPC_PICK_OB:
case OPC_PICK_PW:
case OPC_PICK_QH:
gen_mipsdsp_add_cmp_pick(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 1);
break;
default:
MIPS_INVAL("MASK CMPU_EQ.OB");
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case OPC_DAPPEND_DSP:
gen_mipsdsp_append(VAR_0, VAR_1, op1, VAR_4, VAR_3, VAR_5);
break;
case OPC_DEXTR_W_DSP:
op2 = MASK_DEXTR_W(VAR_1->opcode);
switch (op2) {
case OPC_DEXTP:
case OPC_DEXTPDP:
case OPC_DEXTPDPV:
case OPC_DEXTPV:
case OPC_DEXTR_L:
case OPC_DEXTR_R_L:
case OPC_DEXTR_RS_L:
case OPC_DEXTR_W:
case OPC_DEXTR_R_W:
case OPC_DEXTR_RS_W:
case OPC_DEXTR_S_H:
case OPC_DEXTRV_L:
case OPC_DEXTRV_R_L:
case OPC_DEXTRV_RS_L:
case OPC_DEXTRV_S_H:
case OPC_DEXTRV_W:
case OPC_DEXTRV_R_W:
case OPC_DEXTRV_RS_W:
gen_mipsdsp_accinsn(VAR_1, op1, op2, VAR_4, VAR_3, VAR_5, 1);
break;
case OPC_DMTHLIP:
case OPC_DSHILO:
case OPC_DSHILOV:
gen_mipsdsp_accinsn(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 0);
break;
default:
MIPS_INVAL("MASK EXTR.W");
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case OPC_DPAQ_W_QH_DSP:
op2 = MASK_DPAQ_W_QH(VAR_1->opcode);
switch (op2) {
case OPC_DPAU_H_OBL:
case OPC_DPAU_H_OBR:
case OPC_DPSU_H_OBL:
case OPC_DPSU_H_OBR:
case OPC_DPA_W_QH:
case OPC_DPAQ_S_W_QH:
case OPC_DPS_W_QH:
case OPC_DPSQ_S_W_QH:
case OPC_MULSAQ_S_W_QH:
case OPC_DPAQ_SA_L_PW:
case OPC_DPSQ_SA_L_PW:
case OPC_MULSAQ_S_L_PW:
gen_mipsdsp_multiply(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 0);
break;
case OPC_MAQ_S_W_QHLL:
case OPC_MAQ_S_W_QHLR:
case OPC_MAQ_S_W_QHRL:
case OPC_MAQ_S_W_QHRR:
case OPC_MAQ_SA_W_QHLL:
case OPC_MAQ_SA_W_QHLR:
case OPC_MAQ_SA_W_QHRL:
case OPC_MAQ_SA_W_QHRR:
case OPC_MAQ_S_L_PWL:
case OPC_MAQ_S_L_PWR:
case OPC_DMADD:
case OPC_DMADDU:
case OPC_DMSUB:
case OPC_DMSUBU:
gen_mipsdsp_multiply(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 0);
break;
default:
MIPS_INVAL("MASK DPAQ.W.QH");
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case OPC_DINSV_DSP:
op2 = MASK_INSV(VAR_1->opcode);
switch (op2) {
case OPC_DINSV:
{
TCGv t0, t1;
if (VAR_4 == 0) {
MIPS_DEBUG("NOP");
break;
}
check_dsp(VAR_1);
t0 = tcg_temp_new();
t1 = tcg_temp_new();
gen_load_gpr(t0, VAR_4);
gen_load_gpr(t1, VAR_3);
gen_helper_dinsv(cpu_gpr[VAR_4], cpu_env, t1, t0);
break;
}
default:
MIPS_INVAL("MASK DINSV");
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case OPC_SHLL_OB_DSP:
gen_mipsdsp_shift(VAR_1, op1, VAR_5, VAR_3, VAR_4);
break;
#endif
default:
MIPS_INVAL("special3");
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case OPC_REGIMM:
op1 = MASK_REGIMM(VAR_1->opcode);
switch (op1) {
case OPC_BLTZ ... OPC_BGEZL:
case OPC_BLTZAL ... OPC_BGEZALL:
gen_compute_branch(VAR_1, op1, 4, VAR_3, -1, imm << 2);
*VAR_2 = 1;
break;
case OPC_TGEI ... OPC_TEQI:
case OPC_TNEI:
gen_trap(VAR_1, op1, VAR_3, -1, imm);
break;
case OPC_SYNCI:
check_insn(VAR_1, ISA_MIPS32R2);
break;
case OPC_BPOSGE32:
#if defined(TARGET_MIPS64)
case OPC_BPOSGE64:
#endif
check_dsp(VAR_1);
gen_compute_branch(VAR_1, op1, 4, -1, -2, (int32_t)imm << 2);
*VAR_2 = 1;
break;
default:
MIPS_INVAL("regimm");
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case OPC_CP0:
check_cp0_enabled(VAR_1);
op1 = MASK_CP0(VAR_1->opcode);
switch (op1) {
case OPC_MFC0:
case OPC_MTC0:
case OPC_MFTR:
case OPC_MTTR:
#if defined(TARGET_MIPS64)
case OPC_DMFC0:
case OPC_DMTC0:
#endif
#ifndef CONFIG_USER_ONLY
gen_cp0(VAR_0, VAR_1, op1, VAR_4, VAR_5);
#endif
break;
case OPC_C0_FIRST ... OPC_C0_LAST:
#ifndef CONFIG_USER_ONLY
gen_cp0(VAR_0, VAR_1, MASK_C0(VAR_1->opcode), VAR_4, VAR_5);
#endif
break;
case OPC_MFMC0:
#ifndef CONFIG_USER_ONLY
{
TCGv t0 = tcg_temp_new();
op2 = MASK_MFMC0(VAR_1->opcode);
switch (op2) {
case OPC_DMT:
check_insn(VAR_1, ASE_MT);
gen_helper_dmt(t0);
gen_store_gpr(t0, VAR_4);
break;
case OPC_EMT:
check_insn(VAR_1, ASE_MT);
gen_helper_emt(t0);
gen_store_gpr(t0, VAR_4);
break;
case OPC_DVPE:
check_insn(VAR_1, ASE_MT);
gen_helper_dvpe(t0, cpu_env);
gen_store_gpr(t0, VAR_4);
break;
case OPC_EVPE:
check_insn(VAR_1, ASE_MT);
gen_helper_evpe(t0, cpu_env);
gen_store_gpr(t0, VAR_4);
break;
case OPC_DI:
check_insn(VAR_1, ISA_MIPS32R2);
save_cpu_state(VAR_1, 1);
gen_helper_di(t0, cpu_env);
gen_store_gpr(t0, VAR_4);
VAR_1->bstate = BS_STOP;
break;
case OPC_EI:
check_insn(VAR_1, ISA_MIPS32R2);
save_cpu_state(VAR_1, 1);
gen_helper_ei(t0, cpu_env);
gen_store_gpr(t0, VAR_4);
VAR_1->bstate = BS_STOP;
break;
default:
MIPS_INVAL("mfmc0");
generate_exception(VAR_1, EXCP_RI);
break;
}
tcg_temp_free(t0);
}
#endif
break;
case OPC_RDPGPR:
check_insn(VAR_1, ISA_MIPS32R2);
gen_load_srsgpr(VAR_4, VAR_5);
break;
case OPC_WRPGPR:
check_insn(VAR_1, ISA_MIPS32R2);
gen_store_srsgpr(VAR_4, VAR_5);
break;
default:
MIPS_INVAL("cp0");
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case OPC_ADDI:
case OPC_ADDIU:
gen_arith_imm(VAR_1, op, VAR_4, VAR_3, imm);
break;
case OPC_SLTI:
case OPC_SLTIU:
gen_slt_imm(VAR_1, op, VAR_4, VAR_3, imm);
break;
case OPC_ANDI:
case OPC_LUI:
case OPC_ORI:
case OPC_XORI:
gen_logic_imm(VAR_1, op, VAR_4, VAR_3, imm);
break;
case OPC_J ... OPC_JAL:
offset = (int32_t)(VAR_1->opcode & 0x3FFFFFF) << 2;
gen_compute_branch(VAR_1, op, 4, VAR_3, VAR_4, offset);
*VAR_2 = 1;
break;
case OPC_BEQ ... OPC_BGTZ:
case OPC_BEQL ... OPC_BGTZL:
gen_compute_branch(VAR_1, op, 4, VAR_3, VAR_4, imm << 2);
*VAR_2 = 1;
break;
case OPC_LB ... OPC_LWR:
case OPC_LL:
gen_ld(VAR_1, op, VAR_4, VAR_3, imm);
break;
case OPC_SB ... OPC_SW:
case OPC_SWR:
gen_st(VAR_1, op, VAR_4, VAR_3, imm);
break;
case OPC_SC:
gen_st_cond(VAR_1, op, VAR_4, VAR_3, imm);
break;
case OPC_CACHE:
check_cp0_enabled(VAR_1);
check_insn(VAR_1, ISA_MIPS3 | ISA_MIPS32);
break;
case OPC_PREF:
check_insn(VAR_1, ISA_MIPS4 | ISA_MIPS32);
break;
case OPC_LWC1:
case OPC_LDC1:
case OPC_SWC1:
case OPC_SDC1:
gen_cop1_ldst(VAR_0, VAR_1, op, VAR_4, VAR_3, imm);
break;
case OPC_CP1:
if (VAR_0->CP0_Config1 & (1 << CP0C1_FP)) {
check_cp1_enabled(VAR_1);
op1 = MASK_CP1(VAR_1->opcode);
switch (op1) {
case OPC_MFHC1:
case OPC_MTHC1:
check_insn(VAR_1, ISA_MIPS32R2);
case OPC_MFC1:
case OPC_CFC1:
case OPC_MTC1:
case OPC_CTC1:
gen_cp1(VAR_1, op1, VAR_4, VAR_5);
break;
#if defined(TARGET_MIPS64)
case OPC_DMFC1:
case OPC_DMTC1:
check_insn(VAR_1, ISA_MIPS3);
gen_cp1(VAR_1, op1, VAR_4, VAR_5);
break;
#endif
case OPC_BC1ANY2:
case OPC_BC1ANY4:
check_cop1x(VAR_1);
check_insn(VAR_1, ASE_MIPS3D);
case OPC_BC1:
gen_compute_branch1(VAR_1, MASK_BC1(VAR_1->opcode),
(VAR_4 >> 2) & 0x7, imm << 2);
*VAR_2 = 1;
break;
case OPC_S_FMT:
case OPC_D_FMT:
case OPC_W_FMT:
case OPC_L_FMT:
case OPC_PS_FMT:
gen_farith(VAR_1, VAR_1->opcode & FOP(0x3f, 0x1f), VAR_4, VAR_5, VAR_6,
(imm >> 8) & 0x7);
break;
default:
MIPS_INVAL("cp1");
generate_exception (VAR_1, EXCP_RI);
break;
}
} else {
generate_exception_err(VAR_1, EXCP_CpU, 1);
}
break;
case OPC_LWC2:
case OPC_LDC2:
case OPC_SWC2:
case OPC_SDC2:
generate_exception_err(VAR_1, EXCP_CpU, 2);
break;
case OPC_CP2:
check_insn(VAR_1, INSN_LOONGSON2F);
gen_loongson_multimedia(VAR_1, VAR_6, VAR_5, VAR_4);
break;
case OPC_CP3:
if (VAR_0->CP0_Config1 & (1 << CP0C1_FP)) {
check_cp1_enabled(VAR_1);
op1 = MASK_CP3(VAR_1->opcode);
switch (op1) {
case OPC_LWXC1:
case OPC_LDXC1:
case OPC_LUXC1:
case OPC_SWXC1:
case OPC_SDXC1:
case OPC_SUXC1:
gen_flt3_ldst(VAR_1, op1, VAR_6, VAR_5, VAR_3, VAR_4);
break;
case OPC_PREFX:
break;
case OPC_ALNV_PS:
case OPC_MADD_S:
case OPC_MADD_D:
case OPC_MADD_PS:
case OPC_MSUB_S:
case OPC_MSUB_D:
case OPC_MSUB_PS:
case OPC_NMADD_S:
case OPC_NMADD_D:
case OPC_NMADD_PS:
case OPC_NMSUB_S:
case OPC_NMSUB_D:
case OPC_NMSUB_PS:
gen_flt3_arith(VAR_1, op1, VAR_6, VAR_3, VAR_5, VAR_4);
break;
default:
MIPS_INVAL("cp3");
generate_exception (VAR_1, EXCP_RI);
break;
}
} else {
generate_exception_err(VAR_1, EXCP_CpU, 1);
}
break;
#if defined(TARGET_MIPS64)
case OPC_LWU:
case OPC_LDL ... OPC_LDR:
case OPC_LLD:
case OPC_LD:
check_insn(VAR_1, ISA_MIPS3);
check_mips_64(VAR_1);
gen_ld(VAR_1, op, VAR_4, VAR_3, imm);
break;
case OPC_SDL ... OPC_SDR:
case OPC_SD:
check_insn(VAR_1, ISA_MIPS3);
check_mips_64(VAR_1);
gen_st(VAR_1, op, VAR_4, VAR_3, imm);
break;
case OPC_SCD:
check_insn(VAR_1, ISA_MIPS3);
check_mips_64(VAR_1);
gen_st_cond(VAR_1, op, VAR_4, VAR_3, imm);
break;
case OPC_DADDI:
case OPC_DADDIU:
check_insn(VAR_1, ISA_MIPS3);
check_mips_64(VAR_1);
gen_arith_imm(VAR_1, op, VAR_4, VAR_3, imm);
break;
#endif
case OPC_JALX:
check_insn(VAR_1, ASE_MIPS16 | ASE_MICROMIPS);
offset = (int32_t)(VAR_1->opcode & 0x3FFFFFF) << 2;
gen_compute_branch(VAR_1, op, 4, VAR_3, VAR_4, offset);
*VAR_2 = 1;
break;
case OPC_MDMX:
check_insn(VAR_1, ASE_MDMX);
default:
MIPS_INVAL("major opcode");
generate_exception(VAR_1, EXCP_RI);
break;
}
}
| [
"static void FUNC_0 (CPUMIPSState *VAR_0, DisasContext *VAR_1, int *VAR_2)\n{",
"int32_t offset;",
"int VAR_3, VAR_4, VAR_5, VAR_6;",
"uint32_t op, op1, op2;",
"int16_t imm;",
"if (VAR_1->pc & 0x3) {",
"VAR_0->CP0_BadVAddr = VAR_1->pc;",
"generate_exception(VAR_1, EXCP_AdEL);",
"return;",
"}",
"if ((VAR_1->hflags & MIPS_HFLAG_BMASK_BASE) == MIPS_HFLAG_BL) {",
"int VAR_7 = gen_new_label();",
"MIPS_DEBUG(\"blikely condition (\" TARGET_FMT_lx \")\", VAR_1->pc + 4);",
"tcg_gen_brcondi_tl(TCG_COND_NE, bcond, 0, VAR_7);",
"tcg_gen_movi_i32(hflags, VAR_1->hflags & ~MIPS_HFLAG_BMASK);",
"gen_goto_tb(VAR_1, 1, VAR_1->pc + 4);",
"gen_set_label(VAR_7);",
"}",
"if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {",
"tcg_gen_debug_insn_start(VAR_1->pc);",
"}",
"op = MASK_OP_MAJOR(VAR_1->opcode);",
"VAR_3 = (VAR_1->opcode >> 21) & 0x1f;",
"VAR_4 = (VAR_1->opcode >> 16) & 0x1f;",
"VAR_5 = (VAR_1->opcode >> 11) & 0x1f;",
"VAR_6 = (VAR_1->opcode >> 6) & 0x1f;",
"imm = (int16_t)VAR_1->opcode;",
"switch (op) {",
"case OPC_SPECIAL:\nop1 = MASK_SPECIAL(VAR_1->opcode);",
"switch (op1) {",
"case OPC_SLL:\ncase OPC_SRA:\ngen_shift_imm(VAR_1, op1, VAR_5, VAR_4, VAR_6);",
"break;",
"case OPC_SRL:\nswitch ((VAR_1->opcode >> 21) & 0x1f) {",
"case 1:\nif (VAR_1->insn_flags & ISA_MIPS32R2) {",
"op1 = OPC_ROTR;",
"}",
"case 0:\ngen_shift_imm(VAR_1, op1, VAR_5, VAR_4, VAR_6);",
"break;",
"default:\ngenerate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case OPC_MOVN:\ncase OPC_MOVZ:\ncheck_insn(VAR_1, ISA_MIPS4 | ISA_MIPS32 |\nINSN_LOONGSON2E | INSN_LOONGSON2F);",
"gen_cond_move(VAR_1, op1, VAR_5, VAR_3, VAR_4);",
"break;",
"case OPC_ADD ... OPC_SUBU:\ngen_arith(VAR_1, op1, VAR_5, VAR_3, VAR_4);",
"break;",
"case OPC_SLLV:\ncase OPC_SRAV:\ngen_shift(VAR_1, op1, VAR_5, VAR_3, VAR_4);",
"break;",
"case OPC_SRLV:\nswitch ((VAR_1->opcode >> 6) & 0x1f) {",
"case 1:\nif (VAR_1->insn_flags & ISA_MIPS32R2) {",
"op1 = OPC_ROTRV;",
"}",
"case 0:\ngen_shift(VAR_1, op1, VAR_5, VAR_3, VAR_4);",
"break;",
"default:\ngenerate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case OPC_SLT:\ncase OPC_SLTU:\ngen_slt(VAR_1, op1, VAR_5, VAR_3, VAR_4);",
"break;",
"case OPC_AND:\ncase OPC_OR:\ncase OPC_NOR:\ncase OPC_XOR:\ngen_logic(VAR_1, op1, VAR_5, VAR_3, VAR_4);",
"break;",
"case OPC_MULT:\ncase OPC_MULTU:\nif (VAR_6) {",
"check_insn(VAR_1, INSN_VR54XX);",
"op1 = MASK_MUL_VR54XX(VAR_1->opcode);",
"gen_mul_vr54xx(VAR_1, op1, VAR_5, VAR_3, VAR_4);",
"} else {",
"gen_muldiv(VAR_1, op1, VAR_5 & 3, VAR_3, VAR_4);",
"}",
"break;",
"case OPC_DIV:\ncase OPC_DIVU:\ngen_muldiv(VAR_1, op1, 0, VAR_3, VAR_4);",
"break;",
"case OPC_JR ... OPC_JALR:\ngen_compute_branch(VAR_1, op1, 4, VAR_3, VAR_5, VAR_6);",
"*VAR_2 = 1;",
"break;",
"case OPC_TGE ... OPC_TEQ:\ncase OPC_TNE:\ngen_trap(VAR_1, op1, VAR_3, VAR_4, -1);",
"break;",
"case OPC_MFHI:\ncase OPC_MFLO:\ngen_HILO(VAR_1, op1, VAR_3 & 3, VAR_5);",
"break;",
"case OPC_MTHI:\ncase OPC_MTLO:\ngen_HILO(VAR_1, op1, VAR_5 & 3, VAR_3);",
"break;",
"case OPC_PMON:\n#ifdef MIPS_STRICT_STANDARD\nMIPS_INVAL(\"PMON / selsl\");",
"generate_exception(VAR_1, EXCP_RI);",
"#else\ngen_helper_0e0i(pmon, VAR_6);",
"#endif\nbreak;",
"case OPC_SYSCALL:\ngenerate_exception(VAR_1, EXCP_SYSCALL);",
"VAR_1->bstate = BS_STOP;",
"break;",
"case OPC_BREAK:\ngenerate_exception(VAR_1, EXCP_BREAK);",
"break;",
"case OPC_SPIM:\n#ifdef MIPS_STRICT_STANDARD\nMIPS_INVAL(\"SPIM\");",
"generate_exception(VAR_1, EXCP_RI);",
"#else\nMIPS_INVAL(\"spim (unofficial)\");",
"generate_exception(VAR_1, EXCP_RI);",
"#endif\nbreak;",
"case OPC_SYNC:\nbreak;",
"case OPC_MOVCI:\ncheck_insn(VAR_1, ISA_MIPS4 | ISA_MIPS32);",
"if (VAR_0->CP0_Config1 & (1 << CP0C1_FP)) {",
"check_cp1_enabled(VAR_1);",
"gen_movci(VAR_1, VAR_5, VAR_3, (VAR_1->opcode >> 18) & 0x7,\n(VAR_1->opcode >> 16) & 1);",
"} else {",
"generate_exception_err(VAR_1, EXCP_CpU, 1);",
"}",
"break;",
"#if defined(TARGET_MIPS64)\ncase OPC_DSLL:\ncase OPC_DSRA:\ncase OPC_DSLL32:\ncase OPC_DSRA32:\ncheck_insn(VAR_1, ISA_MIPS3);",
"check_mips_64(VAR_1);",
"gen_shift_imm(VAR_1, op1, VAR_5, VAR_4, VAR_6);",
"break;",
"case OPC_DSRL:\nswitch ((VAR_1->opcode >> 21) & 0x1f) {",
"case 1:\nif (VAR_1->insn_flags & ISA_MIPS32R2) {",
"op1 = OPC_DROTR;",
"}",
"case 0:\ncheck_insn(VAR_1, ISA_MIPS3);",
"check_mips_64(VAR_1);",
"gen_shift_imm(VAR_1, op1, VAR_5, VAR_4, VAR_6);",
"break;",
"default:\ngenerate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case OPC_DSRL32:\nswitch ((VAR_1->opcode >> 21) & 0x1f) {",
"case 1:\nif (VAR_1->insn_flags & ISA_MIPS32R2) {",
"op1 = OPC_DROTR32;",
"}",
"case 0:\ncheck_insn(VAR_1, ISA_MIPS3);",
"check_mips_64(VAR_1);",
"gen_shift_imm(VAR_1, op1, VAR_5, VAR_4, VAR_6);",
"break;",
"default:\ngenerate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case OPC_DADD ... OPC_DSUBU:\ncheck_insn(VAR_1, ISA_MIPS3);",
"check_mips_64(VAR_1);",
"gen_arith(VAR_1, op1, VAR_5, VAR_3, VAR_4);",
"break;",
"case OPC_DSLLV:\ncase OPC_DSRAV:\ncheck_insn(VAR_1, ISA_MIPS3);",
"check_mips_64(VAR_1);",
"gen_shift(VAR_1, op1, VAR_5, VAR_3, VAR_4);",
"break;",
"case OPC_DSRLV:\nswitch ((VAR_1->opcode >> 6) & 0x1f) {",
"case 1:\nif (VAR_1->insn_flags & ISA_MIPS32R2) {",
"op1 = OPC_DROTRV;",
"}",
"case 0:\ncheck_insn(VAR_1, ISA_MIPS3);",
"check_mips_64(VAR_1);",
"gen_shift(VAR_1, op1, VAR_5, VAR_3, VAR_4);",
"break;",
"default:\ngenerate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case OPC_DMULT ... OPC_DDIVU:\ncheck_insn(VAR_1, ISA_MIPS3);",
"check_mips_64(VAR_1);",
"gen_muldiv(VAR_1, op1, 0, VAR_3, VAR_4);",
"break;",
"#endif\ndefault:\nMIPS_INVAL(\"special\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case OPC_SPECIAL2:\nop1 = MASK_SPECIAL2(VAR_1->opcode);",
"switch (op1) {",
"case OPC_MADD ... OPC_MADDU:\ncase OPC_MSUB ... OPC_MSUBU:\ncheck_insn(VAR_1, ISA_MIPS32);",
"gen_muldiv(VAR_1, op1, VAR_5 & 3, VAR_3, VAR_4);",
"break;",
"case OPC_MUL:\ngen_arith(VAR_1, op1, VAR_5, VAR_3, VAR_4);",
"break;",
"case OPC_CLO:\ncase OPC_CLZ:\ncheck_insn(VAR_1, ISA_MIPS32);",
"gen_cl(VAR_1, op1, VAR_5, VAR_3);",
"break;",
"case OPC_SDBBP:\ncheck_insn(VAR_1, ISA_MIPS32);",
"if (!(VAR_1->hflags & MIPS_HFLAG_DM)) {",
"generate_exception(VAR_1, EXCP_DBp);",
"} else {",
"generate_exception(VAR_1, EXCP_DBp);",
"}",
"break;",
"case OPC_DIV_G_2F:\ncase OPC_DIVU_G_2F:\ncase OPC_MULT_G_2F:\ncase OPC_MULTU_G_2F:\ncase OPC_MOD_G_2F:\ncase OPC_MODU_G_2F:\ncheck_insn(VAR_1, INSN_LOONGSON2F);",
"gen_loongson_integer(VAR_1, op1, VAR_5, VAR_3, VAR_4);",
"break;",
"#if defined(TARGET_MIPS64)\ncase OPC_DCLO:\ncase OPC_DCLZ:\ncheck_insn(VAR_1, ISA_MIPS64);",
"check_mips_64(VAR_1);",
"gen_cl(VAR_1, op1, VAR_5, VAR_3);",
"break;",
"case OPC_DMULT_G_2F:\ncase OPC_DMULTU_G_2F:\ncase OPC_DDIV_G_2F:\ncase OPC_DDIVU_G_2F:\ncase OPC_DMOD_G_2F:\ncase OPC_DMODU_G_2F:\ncheck_insn(VAR_1, INSN_LOONGSON2F);",
"gen_loongson_integer(VAR_1, op1, VAR_5, VAR_3, VAR_4);",
"break;",
"#endif\ndefault:\nMIPS_INVAL(\"special2\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case OPC_SPECIAL3:\nop1 = MASK_SPECIAL3(VAR_1->opcode);",
"switch (op1) {",
"case OPC_EXT:\ncase OPC_INS:\ncheck_insn(VAR_1, ISA_MIPS32R2);",
"gen_bitops(VAR_1, op1, VAR_4, VAR_3, VAR_6, VAR_5);",
"break;",
"case OPC_BSHFL:\ncheck_insn(VAR_1, ISA_MIPS32R2);",
"op2 = MASK_BSHFL(VAR_1->opcode);",
"gen_bshfl(VAR_1, op2, VAR_4, VAR_5);",
"break;",
"case OPC_RDHWR:\ngen_rdhwr(VAR_1, VAR_4, VAR_5);",
"break;",
"case OPC_FORK:\ncheck_insn(VAR_1, ASE_MT);",
"{",
"TCGv t0 = tcg_temp_new();",
"TCGv t1 = tcg_temp_new();",
"gen_load_gpr(t0, VAR_4);",
"gen_load_gpr(t1, VAR_3);",
"gen_helper_fork(t0, t1);",
"tcg_temp_free(t0);",
"tcg_temp_free(t1);",
"}",
"break;",
"case OPC_YIELD:\ncheck_insn(VAR_1, ASE_MT);",
"{",
"TCGv t0 = tcg_temp_new();",
"save_cpu_state(VAR_1, 1);",
"gen_load_gpr(t0, VAR_3);",
"gen_helper_yield(t0, cpu_env, t0);",
"gen_store_gpr(t0, VAR_5);",
"tcg_temp_free(t0);",
"}",
"break;",
"case OPC_DIV_G_2E ... OPC_DIVU_G_2E:\ncase OPC_MOD_G_2E ... OPC_MODU_G_2E:\ncase OPC_MULT_G_2E ... OPC_MULTU_G_2E:\nif ((VAR_1->insn_flags & ASE_DSPR2) && (op1 == OPC_MULT_G_2E)) {",
"op2 = MASK_ADDUH_QB(VAR_1->opcode);",
"switch (op2) {",
"case OPC_ADDUH_QB:\ncase OPC_ADDUH_R_QB:\ncase OPC_ADDQH_PH:\ncase OPC_ADDQH_R_PH:\ncase OPC_ADDQH_W:\ncase OPC_ADDQH_R_W:\ncase OPC_SUBUH_QB:\ncase OPC_SUBUH_R_QB:\ncase OPC_SUBQH_PH:\ncase OPC_SUBQH_R_PH:\ncase OPC_SUBQH_W:\ncase OPC_SUBQH_R_W:\ngen_mipsdsp_arith(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4);",
"break;",
"case OPC_MUL_PH:\ncase OPC_MUL_S_PH:\ncase OPC_MULQ_S_W:\ncase OPC_MULQ_RS_W:\ngen_mipsdsp_multiply(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 1);",
"break;",
"default:\nMIPS_INVAL(\"MASK ADDUH.QB\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"} else if (VAR_1->insn_flags & INSN_LOONGSON2E) {",
"gen_loongson_integer(VAR_1, op1, VAR_5, VAR_3, VAR_4);",
"} else {",
"generate_exception(VAR_1, EXCP_RI);",
"}",
"break;",
"case OPC_LX_DSP:\nop2 = MASK_LX(VAR_1->opcode);",
"switch (op2) {",
"#if defined(TARGET_MIPS64)\ncase OPC_LDX:\n#endif\ncase OPC_LBUX:\ncase OPC_LHX:\ncase OPC_LWX:\ngen_mipsdsp_ld(VAR_1, op2, VAR_5, VAR_3, VAR_4);",
"break;",
"default:\nMIPS_INVAL(\"MASK LX\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case OPC_ABSQ_S_PH_DSP:\nop2 = MASK_ABSQ_S_PH(VAR_1->opcode);",
"switch (op2) {",
"case OPC_ABSQ_S_QB:\ncase OPC_ABSQ_S_PH:\ncase OPC_ABSQ_S_W:\ncase OPC_PRECEQ_W_PHL:\ncase OPC_PRECEQ_W_PHR:\ncase OPC_PRECEQU_PH_QBL:\ncase OPC_PRECEQU_PH_QBR:\ncase OPC_PRECEQU_PH_QBLA:\ncase OPC_PRECEQU_PH_QBRA:\ncase OPC_PRECEU_PH_QBL:\ncase OPC_PRECEU_PH_QBR:\ncase OPC_PRECEU_PH_QBLA:\ncase OPC_PRECEU_PH_QBRA:\ngen_mipsdsp_arith(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4);",
"break;",
"case OPC_BITREV:\ncase OPC_REPL_QB:\ncase OPC_REPLV_QB:\ncase OPC_REPL_PH:\ncase OPC_REPLV_PH:\ngen_mipsdsp_bitinsn(VAR_1, op1, op2, VAR_5, VAR_4);",
"break;",
"default:\nMIPS_INVAL(\"MASK ABSQ_S.PH\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case OPC_ADDU_QB_DSP:\nop2 = MASK_ADDU_QB(VAR_1->opcode);",
"switch (op2) {",
"case OPC_ADDQ_PH:\ncase OPC_ADDQ_S_PH:\ncase OPC_ADDQ_S_W:\ncase OPC_ADDU_QB:\ncase OPC_ADDU_S_QB:\ncase OPC_ADDU_PH:\ncase OPC_ADDU_S_PH:\ncase OPC_SUBQ_PH:\ncase OPC_SUBQ_S_PH:\ncase OPC_SUBQ_S_W:\ncase OPC_SUBU_QB:\ncase OPC_SUBU_S_QB:\ncase OPC_SUBU_PH:\ncase OPC_SUBU_S_PH:\ncase OPC_ADDSC:\ncase OPC_ADDWC:\ncase OPC_MODSUB:\ncase OPC_RADDU_W_QB:\ngen_mipsdsp_arith(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4);",
"break;",
"case OPC_MULEU_S_PH_QBL:\ncase OPC_MULEU_S_PH_QBR:\ncase OPC_MULQ_RS_PH:\ncase OPC_MULEQ_S_W_PHL:\ncase OPC_MULEQ_S_W_PHR:\ncase OPC_MULQ_S_PH:\ngen_mipsdsp_multiply(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 1);",
"break;",
"default:\nMIPS_INVAL(\"MASK ADDU.QB\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case OPC_CMPU_EQ_QB_DSP:\nop2 = MASK_CMPU_EQ_QB(VAR_1->opcode);",
"switch (op2) {",
"case OPC_PRECR_SRA_PH_W:\ncase OPC_PRECR_SRA_R_PH_W:\ngen_mipsdsp_arith(VAR_1, op1, op2, VAR_4, VAR_3, VAR_5);",
"break;",
"case OPC_PRECR_QB_PH:\ncase OPC_PRECRQ_QB_PH:\ncase OPC_PRECRQ_PH_W:\ncase OPC_PRECRQ_RS_PH_W:\ncase OPC_PRECRQU_S_QB_PH:\ngen_mipsdsp_arith(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4);",
"break;",
"case OPC_CMPU_EQ_QB:\ncase OPC_CMPU_LT_QB:\ncase OPC_CMPU_LE_QB:\ncase OPC_CMP_EQ_PH:\ncase OPC_CMP_LT_PH:\ncase OPC_CMP_LE_PH:\ngen_mipsdsp_add_cmp_pick(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 0);",
"break;",
"case OPC_CMPGU_EQ_QB:\ncase OPC_CMPGU_LT_QB:\ncase OPC_CMPGU_LE_QB:\ncase OPC_CMPGDU_EQ_QB:\ncase OPC_CMPGDU_LT_QB:\ncase OPC_CMPGDU_LE_QB:\ncase OPC_PICK_QB:\ncase OPC_PICK_PH:\ncase OPC_PACKRL_PH:\ngen_mipsdsp_add_cmp_pick(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 1);",
"break;",
"default:\nMIPS_INVAL(\"MASK CMPU.EQ.QB\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case OPC_SHLL_QB_DSP:\ngen_mipsdsp_shift(VAR_1, op1, VAR_5, VAR_3, VAR_4);",
"break;",
"case OPC_DPA_W_PH_DSP:\nop2 = MASK_DPA_W_PH(VAR_1->opcode);",
"switch (op2) {",
"case OPC_DPAU_H_QBL:\ncase OPC_DPAU_H_QBR:\ncase OPC_DPSU_H_QBL:\ncase OPC_DPSU_H_QBR:\ncase OPC_DPA_W_PH:\ncase OPC_DPAX_W_PH:\ncase OPC_DPAQ_S_W_PH:\ncase OPC_DPAQX_S_W_PH:\ncase OPC_DPAQX_SA_W_PH:\ncase OPC_DPS_W_PH:\ncase OPC_DPSX_W_PH:\ncase OPC_DPSQ_S_W_PH:\ncase OPC_DPSQX_S_W_PH:\ncase OPC_DPSQX_SA_W_PH:\ncase OPC_MULSAQ_S_W_PH:\ncase OPC_DPAQ_SA_L_W:\ncase OPC_DPSQ_SA_L_W:\ncase OPC_MAQ_S_W_PHL:\ncase OPC_MAQ_S_W_PHR:\ncase OPC_MAQ_SA_W_PHL:\ncase OPC_MAQ_SA_W_PHR:\ncase OPC_MULSA_W_PH:\ngen_mipsdsp_multiply(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 0);",
"break;",
"default:\nMIPS_INVAL(\"MASK DPAW.PH\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case OPC_INSV_DSP:\nop2 = MASK_INSV(VAR_1->opcode);",
"switch (op2) {",
"case OPC_INSV:\ncheck_dsp(VAR_1);",
"{",
"TCGv t0, t1;",
"if (VAR_4 == 0) {",
"MIPS_DEBUG(\"NOP\");",
"break;",
"}",
"t0 = tcg_temp_new();",
"t1 = tcg_temp_new();",
"gen_load_gpr(t0, VAR_4);",
"gen_load_gpr(t1, VAR_3);",
"gen_helper_insv(cpu_gpr[VAR_4], cpu_env, t1, t0);",
"tcg_temp_free(t0);",
"tcg_temp_free(t1);",
"break;",
"}",
"default:\nMIPS_INVAL(\"MASK INSV\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case OPC_APPEND_DSP:\ngen_mipsdsp_append(VAR_0, VAR_1, op1, VAR_4, VAR_3, VAR_5);",
"break;",
"case OPC_EXTR_W_DSP:\nop2 = MASK_EXTR_W(VAR_1->opcode);",
"switch (op2) {",
"case OPC_EXTR_W:\ncase OPC_EXTR_R_W:\ncase OPC_EXTR_RS_W:\ncase OPC_EXTR_S_H:\ncase OPC_EXTRV_S_H:\ncase OPC_EXTRV_W:\ncase OPC_EXTRV_R_W:\ncase OPC_EXTRV_RS_W:\ncase OPC_EXTP:\ncase OPC_EXTPV:\ncase OPC_EXTPDP:\ncase OPC_EXTPDPV:\ngen_mipsdsp_accinsn(VAR_1, op1, op2, VAR_4, VAR_3, VAR_5, 1);",
"break;",
"case OPC_RDDSP:\ngen_mipsdsp_accinsn(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 1);",
"break;",
"case OPC_SHILO:\ncase OPC_SHILOV:\ncase OPC_MTHLIP:\ncase OPC_WRDSP:\ngen_mipsdsp_accinsn(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 0);",
"break;",
"default:\nMIPS_INVAL(\"MASK EXTR.W\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"#if defined(TARGET_MIPS64)\ncase OPC_DEXTM ... OPC_DEXT:\ncase OPC_DINSM ... OPC_DINS:\ncheck_insn(VAR_1, ISA_MIPS64R2);",
"check_mips_64(VAR_1);",
"gen_bitops(VAR_1, op1, VAR_4, VAR_3, VAR_6, VAR_5);",
"break;",
"case OPC_DBSHFL:\ncheck_insn(VAR_1, ISA_MIPS64R2);",
"check_mips_64(VAR_1);",
"op2 = MASK_DBSHFL(VAR_1->opcode);",
"gen_bshfl(VAR_1, op2, VAR_4, VAR_5);",
"break;",
"case OPC_DDIV_G_2E ... OPC_DDIVU_G_2E:\ncase OPC_DMULT_G_2E ... OPC_DMULTU_G_2E:\ncase OPC_DMOD_G_2E ... OPC_DMODU_G_2E:\ncheck_insn(VAR_1, INSN_LOONGSON2E);",
"gen_loongson_integer(VAR_1, op1, VAR_5, VAR_3, VAR_4);",
"break;",
"case OPC_ABSQ_S_QH_DSP:\nop2 = MASK_ABSQ_S_QH(VAR_1->opcode);",
"switch (op2) {",
"case OPC_PRECEQ_L_PWL:\ncase OPC_PRECEQ_L_PWR:\ncase OPC_PRECEQ_PW_QHL:\ncase OPC_PRECEQ_PW_QHR:\ncase OPC_PRECEQ_PW_QHLA:\ncase OPC_PRECEQ_PW_QHRA:\ncase OPC_PRECEQU_QH_OBL:\ncase OPC_PRECEQU_QH_OBR:\ncase OPC_PRECEQU_QH_OBLA:\ncase OPC_PRECEQU_QH_OBRA:\ncase OPC_PRECEU_QH_OBL:\ncase OPC_PRECEU_QH_OBR:\ncase OPC_PRECEU_QH_OBLA:\ncase OPC_PRECEU_QH_OBRA:\ncase OPC_ABSQ_S_OB:\ncase OPC_ABSQ_S_PW:\ncase OPC_ABSQ_S_QH:\ngen_mipsdsp_arith(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4);",
"break;",
"case OPC_REPL_OB:\ncase OPC_REPL_PW:\ncase OPC_REPL_QH:\ncase OPC_REPLV_OB:\ncase OPC_REPLV_PW:\ncase OPC_REPLV_QH:\ngen_mipsdsp_bitinsn(VAR_1, op1, op2, VAR_5, VAR_4);",
"break;",
"default:\nMIPS_INVAL(\"MASK ABSQ_S.QH\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case OPC_ADDU_OB_DSP:\nop2 = MASK_ADDU_OB(VAR_1->opcode);",
"switch (op2) {",
"case OPC_RADDU_L_OB:\ncase OPC_SUBQ_PW:\ncase OPC_SUBQ_S_PW:\ncase OPC_SUBQ_QH:\ncase OPC_SUBQ_S_QH:\ncase OPC_SUBU_OB:\ncase OPC_SUBU_S_OB:\ncase OPC_SUBU_QH:\ncase OPC_SUBU_S_QH:\ncase OPC_SUBUH_OB:\ncase OPC_SUBUH_R_OB:\ncase OPC_ADDQ_PW:\ncase OPC_ADDQ_S_PW:\ncase OPC_ADDQ_QH:\ncase OPC_ADDQ_S_QH:\ncase OPC_ADDU_OB:\ncase OPC_ADDU_S_OB:\ncase OPC_ADDU_QH:\ncase OPC_ADDU_S_QH:\ncase OPC_ADDUH_OB:\ncase OPC_ADDUH_R_OB:\ngen_mipsdsp_arith(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4);",
"break;",
"case OPC_MULEQ_S_PW_QHL:\ncase OPC_MULEQ_S_PW_QHR:\ncase OPC_MULEU_S_QH_OBL:\ncase OPC_MULEU_S_QH_OBR:\ncase OPC_MULQ_RS_QH:\ngen_mipsdsp_multiply(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 1);",
"break;",
"default:\nMIPS_INVAL(\"MASK ADDU.OB\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case OPC_CMPU_EQ_OB_DSP:\nop2 = MASK_CMPU_EQ_OB(VAR_1->opcode);",
"switch (op2) {",
"case OPC_PRECR_SRA_QH_PW:\ncase OPC_PRECR_SRA_R_QH_PW:\ngen_mipsdsp_arith(VAR_1, op1, op2, VAR_4, VAR_3, VAR_5);",
"break;",
"case OPC_PRECR_OB_QH:\ncase OPC_PRECRQ_OB_QH:\ncase OPC_PRECRQ_PW_L:\ncase OPC_PRECRQ_QH_PW:\ncase OPC_PRECRQ_RS_QH_PW:\ncase OPC_PRECRQU_S_OB_QH:\ngen_mipsdsp_arith(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4);",
"break;",
"case OPC_CMPU_EQ_OB:\ncase OPC_CMPU_LT_OB:\ncase OPC_CMPU_LE_OB:\ncase OPC_CMP_EQ_QH:\ncase OPC_CMP_LT_QH:\ncase OPC_CMP_LE_QH:\ncase OPC_CMP_EQ_PW:\ncase OPC_CMP_LT_PW:\ncase OPC_CMP_LE_PW:\ngen_mipsdsp_add_cmp_pick(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 0);",
"break;",
"case OPC_CMPGDU_EQ_OB:\ncase OPC_CMPGDU_LT_OB:\ncase OPC_CMPGDU_LE_OB:\ncase OPC_CMPGU_EQ_OB:\ncase OPC_CMPGU_LT_OB:\ncase OPC_CMPGU_LE_OB:\ncase OPC_PACKRL_PW:\ncase OPC_PICK_OB:\ncase OPC_PICK_PW:\ncase OPC_PICK_QH:\ngen_mipsdsp_add_cmp_pick(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 1);",
"break;",
"default:\nMIPS_INVAL(\"MASK CMPU_EQ.OB\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case OPC_DAPPEND_DSP:\ngen_mipsdsp_append(VAR_0, VAR_1, op1, VAR_4, VAR_3, VAR_5);",
"break;",
"case OPC_DEXTR_W_DSP:\nop2 = MASK_DEXTR_W(VAR_1->opcode);",
"switch (op2) {",
"case OPC_DEXTP:\ncase OPC_DEXTPDP:\ncase OPC_DEXTPDPV:\ncase OPC_DEXTPV:\ncase OPC_DEXTR_L:\ncase OPC_DEXTR_R_L:\ncase OPC_DEXTR_RS_L:\ncase OPC_DEXTR_W:\ncase OPC_DEXTR_R_W:\ncase OPC_DEXTR_RS_W:\ncase OPC_DEXTR_S_H:\ncase OPC_DEXTRV_L:\ncase OPC_DEXTRV_R_L:\ncase OPC_DEXTRV_RS_L:\ncase OPC_DEXTRV_S_H:\ncase OPC_DEXTRV_W:\ncase OPC_DEXTRV_R_W:\ncase OPC_DEXTRV_RS_W:\ngen_mipsdsp_accinsn(VAR_1, op1, op2, VAR_4, VAR_3, VAR_5, 1);",
"break;",
"case OPC_DMTHLIP:\ncase OPC_DSHILO:\ncase OPC_DSHILOV:\ngen_mipsdsp_accinsn(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 0);",
"break;",
"default:\nMIPS_INVAL(\"MASK EXTR.W\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case OPC_DPAQ_W_QH_DSP:\nop2 = MASK_DPAQ_W_QH(VAR_1->opcode);",
"switch (op2) {",
"case OPC_DPAU_H_OBL:\ncase OPC_DPAU_H_OBR:\ncase OPC_DPSU_H_OBL:\ncase OPC_DPSU_H_OBR:\ncase OPC_DPA_W_QH:\ncase OPC_DPAQ_S_W_QH:\ncase OPC_DPS_W_QH:\ncase OPC_DPSQ_S_W_QH:\ncase OPC_MULSAQ_S_W_QH:\ncase OPC_DPAQ_SA_L_PW:\ncase OPC_DPSQ_SA_L_PW:\ncase OPC_MULSAQ_S_L_PW:\ngen_mipsdsp_multiply(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 0);",
"break;",
"case OPC_MAQ_S_W_QHLL:\ncase OPC_MAQ_S_W_QHLR:\ncase OPC_MAQ_S_W_QHRL:\ncase OPC_MAQ_S_W_QHRR:\ncase OPC_MAQ_SA_W_QHLL:\ncase OPC_MAQ_SA_W_QHLR:\ncase OPC_MAQ_SA_W_QHRL:\ncase OPC_MAQ_SA_W_QHRR:\ncase OPC_MAQ_S_L_PWL:\ncase OPC_MAQ_S_L_PWR:\ncase OPC_DMADD:\ncase OPC_DMADDU:\ncase OPC_DMSUB:\ncase OPC_DMSUBU:\ngen_mipsdsp_multiply(VAR_1, op1, op2, VAR_5, VAR_3, VAR_4, 0);",
"break;",
"default:\nMIPS_INVAL(\"MASK DPAQ.W.QH\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case OPC_DINSV_DSP:\nop2 = MASK_INSV(VAR_1->opcode);",
"switch (op2) {",
"case OPC_DINSV:\n{",
"TCGv t0, t1;",
"if (VAR_4 == 0) {",
"MIPS_DEBUG(\"NOP\");",
"break;",
"}",
"check_dsp(VAR_1);",
"t0 = tcg_temp_new();",
"t1 = tcg_temp_new();",
"gen_load_gpr(t0, VAR_4);",
"gen_load_gpr(t1, VAR_3);",
"gen_helper_dinsv(cpu_gpr[VAR_4], cpu_env, t1, t0);",
"break;",
"}",
"default:\nMIPS_INVAL(\"MASK DINSV\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case OPC_SHLL_OB_DSP:\ngen_mipsdsp_shift(VAR_1, op1, VAR_5, VAR_3, VAR_4);",
"break;",
"#endif\ndefault:\nMIPS_INVAL(\"special3\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case OPC_REGIMM:\nop1 = MASK_REGIMM(VAR_1->opcode);",
"switch (op1) {",
"case OPC_BLTZ ... OPC_BGEZL:\ncase OPC_BLTZAL ... OPC_BGEZALL:\ngen_compute_branch(VAR_1, op1, 4, VAR_3, -1, imm << 2);",
"*VAR_2 = 1;",
"break;",
"case OPC_TGEI ... OPC_TEQI:\ncase OPC_TNEI:\ngen_trap(VAR_1, op1, VAR_3, -1, imm);",
"break;",
"case OPC_SYNCI:\ncheck_insn(VAR_1, ISA_MIPS32R2);",
"break;",
"case OPC_BPOSGE32:\n#if defined(TARGET_MIPS64)\ncase OPC_BPOSGE64:\n#endif\ncheck_dsp(VAR_1);",
"gen_compute_branch(VAR_1, op1, 4, -1, -2, (int32_t)imm << 2);",
"*VAR_2 = 1;",
"break;",
"default:\nMIPS_INVAL(\"regimm\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case OPC_CP0:\ncheck_cp0_enabled(VAR_1);",
"op1 = MASK_CP0(VAR_1->opcode);",
"switch (op1) {",
"case OPC_MFC0:\ncase OPC_MTC0:\ncase OPC_MFTR:\ncase OPC_MTTR:\n#if defined(TARGET_MIPS64)\ncase OPC_DMFC0:\ncase OPC_DMTC0:\n#endif\n#ifndef CONFIG_USER_ONLY\ngen_cp0(VAR_0, VAR_1, op1, VAR_4, VAR_5);",
"#endif\nbreak;",
"case OPC_C0_FIRST ... OPC_C0_LAST:\n#ifndef CONFIG_USER_ONLY\ngen_cp0(VAR_0, VAR_1, MASK_C0(VAR_1->opcode), VAR_4, VAR_5);",
"#endif\nbreak;",
"case OPC_MFMC0:\n#ifndef CONFIG_USER_ONLY\n{",
"TCGv t0 = tcg_temp_new();",
"op2 = MASK_MFMC0(VAR_1->opcode);",
"switch (op2) {",
"case OPC_DMT:\ncheck_insn(VAR_1, ASE_MT);",
"gen_helper_dmt(t0);",
"gen_store_gpr(t0, VAR_4);",
"break;",
"case OPC_EMT:\ncheck_insn(VAR_1, ASE_MT);",
"gen_helper_emt(t0);",
"gen_store_gpr(t0, VAR_4);",
"break;",
"case OPC_DVPE:\ncheck_insn(VAR_1, ASE_MT);",
"gen_helper_dvpe(t0, cpu_env);",
"gen_store_gpr(t0, VAR_4);",
"break;",
"case OPC_EVPE:\ncheck_insn(VAR_1, ASE_MT);",
"gen_helper_evpe(t0, cpu_env);",
"gen_store_gpr(t0, VAR_4);",
"break;",
"case OPC_DI:\ncheck_insn(VAR_1, ISA_MIPS32R2);",
"save_cpu_state(VAR_1, 1);",
"gen_helper_di(t0, cpu_env);",
"gen_store_gpr(t0, VAR_4);",
"VAR_1->bstate = BS_STOP;",
"break;",
"case OPC_EI:\ncheck_insn(VAR_1, ISA_MIPS32R2);",
"save_cpu_state(VAR_1, 1);",
"gen_helper_ei(t0, cpu_env);",
"gen_store_gpr(t0, VAR_4);",
"VAR_1->bstate = BS_STOP;",
"break;",
"default:\nMIPS_INVAL(\"mfmc0\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"tcg_temp_free(t0);",
"}",
"#endif\nbreak;",
"case OPC_RDPGPR:\ncheck_insn(VAR_1, ISA_MIPS32R2);",
"gen_load_srsgpr(VAR_4, VAR_5);",
"break;",
"case OPC_WRPGPR:\ncheck_insn(VAR_1, ISA_MIPS32R2);",
"gen_store_srsgpr(VAR_4, VAR_5);",
"break;",
"default:\nMIPS_INVAL(\"cp0\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case OPC_ADDI:\ncase OPC_ADDIU:\ngen_arith_imm(VAR_1, op, VAR_4, VAR_3, imm);",
"break;",
"case OPC_SLTI:\ncase OPC_SLTIU:\ngen_slt_imm(VAR_1, op, VAR_4, VAR_3, imm);",
"break;",
"case OPC_ANDI:\ncase OPC_LUI:\ncase OPC_ORI:\ncase OPC_XORI:\ngen_logic_imm(VAR_1, op, VAR_4, VAR_3, imm);",
"break;",
"case OPC_J ... OPC_JAL:\noffset = (int32_t)(VAR_1->opcode & 0x3FFFFFF) << 2;",
"gen_compute_branch(VAR_1, op, 4, VAR_3, VAR_4, offset);",
"*VAR_2 = 1;",
"break;",
"case OPC_BEQ ... OPC_BGTZ:\ncase OPC_BEQL ... OPC_BGTZL:\ngen_compute_branch(VAR_1, op, 4, VAR_3, VAR_4, imm << 2);",
"*VAR_2 = 1;",
"break;",
"case OPC_LB ... OPC_LWR:\ncase OPC_LL:\ngen_ld(VAR_1, op, VAR_4, VAR_3, imm);",
"break;",
"case OPC_SB ... OPC_SW:\ncase OPC_SWR:\ngen_st(VAR_1, op, VAR_4, VAR_3, imm);",
"break;",
"case OPC_SC:\ngen_st_cond(VAR_1, op, VAR_4, VAR_3, imm);",
"break;",
"case OPC_CACHE:\ncheck_cp0_enabled(VAR_1);",
"check_insn(VAR_1, ISA_MIPS3 | ISA_MIPS32);",
"break;",
"case OPC_PREF:\ncheck_insn(VAR_1, ISA_MIPS4 | ISA_MIPS32);",
"break;",
"case OPC_LWC1:\ncase OPC_LDC1:\ncase OPC_SWC1:\ncase OPC_SDC1:\ngen_cop1_ldst(VAR_0, VAR_1, op, VAR_4, VAR_3, imm);",
"break;",
"case OPC_CP1:\nif (VAR_0->CP0_Config1 & (1 << CP0C1_FP)) {",
"check_cp1_enabled(VAR_1);",
"op1 = MASK_CP1(VAR_1->opcode);",
"switch (op1) {",
"case OPC_MFHC1:\ncase OPC_MTHC1:\ncheck_insn(VAR_1, ISA_MIPS32R2);",
"case OPC_MFC1:\ncase OPC_CFC1:\ncase OPC_MTC1:\ncase OPC_CTC1:\ngen_cp1(VAR_1, op1, VAR_4, VAR_5);",
"break;",
"#if defined(TARGET_MIPS64)\ncase OPC_DMFC1:\ncase OPC_DMTC1:\ncheck_insn(VAR_1, ISA_MIPS3);",
"gen_cp1(VAR_1, op1, VAR_4, VAR_5);",
"break;",
"#endif\ncase OPC_BC1ANY2:\ncase OPC_BC1ANY4:\ncheck_cop1x(VAR_1);",
"check_insn(VAR_1, ASE_MIPS3D);",
"case OPC_BC1:\ngen_compute_branch1(VAR_1, MASK_BC1(VAR_1->opcode),\n(VAR_4 >> 2) & 0x7, imm << 2);",
"*VAR_2 = 1;",
"break;",
"case OPC_S_FMT:\ncase OPC_D_FMT:\ncase OPC_W_FMT:\ncase OPC_L_FMT:\ncase OPC_PS_FMT:\ngen_farith(VAR_1, VAR_1->opcode & FOP(0x3f, 0x1f), VAR_4, VAR_5, VAR_6,\n(imm >> 8) & 0x7);",
"break;",
"default:\nMIPS_INVAL(\"cp1\");",
"generate_exception (VAR_1, EXCP_RI);",
"break;",
"}",
"} else {",
"generate_exception_err(VAR_1, EXCP_CpU, 1);",
"}",
"break;",
"case OPC_LWC2:\ncase OPC_LDC2:\ncase OPC_SWC2:\ncase OPC_SDC2:\ngenerate_exception_err(VAR_1, EXCP_CpU, 2);",
"break;",
"case OPC_CP2:\ncheck_insn(VAR_1, INSN_LOONGSON2F);",
"gen_loongson_multimedia(VAR_1, VAR_6, VAR_5, VAR_4);",
"break;",
"case OPC_CP3:\nif (VAR_0->CP0_Config1 & (1 << CP0C1_FP)) {",
"check_cp1_enabled(VAR_1);",
"op1 = MASK_CP3(VAR_1->opcode);",
"switch (op1) {",
"case OPC_LWXC1:\ncase OPC_LDXC1:\ncase OPC_LUXC1:\ncase OPC_SWXC1:\ncase OPC_SDXC1:\ncase OPC_SUXC1:\ngen_flt3_ldst(VAR_1, op1, VAR_6, VAR_5, VAR_3, VAR_4);",
"break;",
"case OPC_PREFX:\nbreak;",
"case OPC_ALNV_PS:\ncase OPC_MADD_S:\ncase OPC_MADD_D:\ncase OPC_MADD_PS:\ncase OPC_MSUB_S:\ncase OPC_MSUB_D:\ncase OPC_MSUB_PS:\ncase OPC_NMADD_S:\ncase OPC_NMADD_D:\ncase OPC_NMADD_PS:\ncase OPC_NMSUB_S:\ncase OPC_NMSUB_D:\ncase OPC_NMSUB_PS:\ngen_flt3_arith(VAR_1, op1, VAR_6, VAR_3, VAR_5, VAR_4);",
"break;",
"default:\nMIPS_INVAL(\"cp3\");",
"generate_exception (VAR_1, EXCP_RI);",
"break;",
"}",
"} else {",
"generate_exception_err(VAR_1, EXCP_CpU, 1);",
"}",
"break;",
"#if defined(TARGET_MIPS64)\ncase OPC_LWU:\ncase OPC_LDL ... OPC_LDR:\ncase OPC_LLD:\ncase OPC_LD:\ncheck_insn(VAR_1, ISA_MIPS3);",
"check_mips_64(VAR_1);",
"gen_ld(VAR_1, op, VAR_4, VAR_3, imm);",
"break;",
"case OPC_SDL ... OPC_SDR:\ncase OPC_SD:\ncheck_insn(VAR_1, ISA_MIPS3);",
"check_mips_64(VAR_1);",
"gen_st(VAR_1, op, VAR_4, VAR_3, imm);",
"break;",
"case OPC_SCD:\ncheck_insn(VAR_1, ISA_MIPS3);",
"check_mips_64(VAR_1);",
"gen_st_cond(VAR_1, op, VAR_4, VAR_3, imm);",
"break;",
"case OPC_DADDI:\ncase OPC_DADDIU:\ncheck_insn(VAR_1, ISA_MIPS3);",
"check_mips_64(VAR_1);",
"gen_arith_imm(VAR_1, op, VAR_4, VAR_3, imm);",
"break;",
"#endif\ncase OPC_JALX:\ncheck_insn(VAR_1, ASE_MIPS16 | ASE_MICROMIPS);",
"offset = (int32_t)(VAR_1->opcode & 0x3FFFFFF) << 2;",
"gen_compute_branch(VAR_1, op, 4, VAR_3, VAR_4, offset);",
"*VAR_2 = 1;",
"break;",
"case OPC_MDMX:\ncheck_insn(VAR_1, ASE_MDMX);",
"default:\nMIPS_INVAL(\"major opcode\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"}"
] | [
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,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
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,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73,
75
],
[
77
],
[
79,
81,
83
],
[
85
],
[
87,
89
],
[
91,
95
],
[
97
],
[
99
],
[
103,
105
],
[
107
],
[
109,
111
],
[
113
],
[
115
],
[
117
],
[
119,
121,
123,
125
],
[
127
],
[
129
],
[
131,
133
],
[
135
],
[
137,
139,
141
],
[
143
],
[
145,
147
],
[
149,
153
],
[
155
],
[
157
],
[
161,
163
],
[
165
],
[
167,
169
],
[
171
],
[
173
],
[
175
],
[
177,
179,
181
],
[
183
],
[
185,
187,
189,
191,
193
],
[
195
],
[
197,
199,
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217,
219,
221
],
[
223
],
[
225,
227
],
[
229
],
[
231
],
[
233,
235,
237
],
[
239
],
[
241,
243,
245
],
[
247
],
[
249,
251,
253
],
[
255
],
[
257,
259,
261
],
[
263
],
[
265,
267
],
[
269,
271
],
[
273,
275
],
[
277
],
[
279
],
[
281,
283
],
[
285
],
[
287,
289,
291
],
[
293
],
[
295,
299
],
[
301
],
[
303,
305
],
[
307,
311
],
[
315,
317
],
[
319
],
[
321
],
[
323,
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
337,
341,
343,
345,
347,
349
],
[
351
],
[
353
],
[
355
],
[
357,
359
],
[
361,
365
],
[
367
],
[
369
],
[
373,
375
],
[
377
],
[
379
],
[
381
],
[
383,
385
],
[
387
],
[
389
],
[
391
],
[
393,
395
],
[
397,
401
],
[
403
],
[
405
],
[
409,
411
],
[
413
],
[
415
],
[
417
],
[
419,
421
],
[
423
],
[
425
],
[
427
],
[
429,
431
],
[
433
],
[
435
],
[
437
],
[
439,
441,
443
],
[
445
],
[
447
],
[
449
],
[
451,
453
],
[
455,
459
],
[
461
],
[
463
],
[
467,
469
],
[
471
],
[
473
],
[
475
],
[
477,
479
],
[
481
],
[
483
],
[
485
],
[
487,
489
],
[
491
],
[
493
],
[
495
],
[
497,
499,
501
],
[
503
],
[
505
],
[
507
],
[
509
],
[
511,
513
],
[
515
],
[
517,
519,
521
],
[
523
],
[
525
],
[
527,
529
],
[
531
],
[
533,
535,
537
],
[
539
],
[
541
],
[
543,
551
],
[
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
565
],
[
567,
569,
571,
573,
575,
577,
579
],
[
581
],
[
583
],
[
585,
587,
589,
591
],
[
593
],
[
595
],
[
597
],
[
599,
601,
603,
605,
607,
609,
611
],
[
613
],
[
615
],
[
617,
619,
621
],
[
623
],
[
625
],
[
627
],
[
629
],
[
631,
633
],
[
635
],
[
637,
639,
641
],
[
643
],
[
645
],
[
647,
649
],
[
651
],
[
653
],
[
655
],
[
657,
659
],
[
661
],
[
663,
665
],
[
667
],
[
669
],
[
671
],
[
675
],
[
677
],
[
679
],
[
681
],
[
683
],
[
685
],
[
687
],
[
689,
691
],
[
693
],
[
695
],
[
699
],
[
701
],
[
703
],
[
705
],
[
707
],
[
709
],
[
711
],
[
713,
715,
717,
723
],
[
725
],
[
727
],
[
729,
731,
733,
735,
737,
739,
741,
743,
745,
747,
749,
751,
753
],
[
755
],
[
757,
759,
761,
763,
765
],
[
767
],
[
769,
771
],
[
773
],
[
775
],
[
777
],
[
779
],
[
781
],
[
783
],
[
785
],
[
787
],
[
789
],
[
791,
793
],
[
795
],
[
797,
799,
801,
803,
805,
807,
809
],
[
811
],
[
813,
815
],
[
817
],
[
819
],
[
821
],
[
823
],
[
825,
827
],
[
829
],
[
831,
833,
835,
837,
839,
841,
843,
845,
847,
849,
851,
853,
855,
857
],
[
859
],
[
861,
863,
865,
867,
869,
871
],
[
873
],
[
875,
877
],
[
879
],
[
881
],
[
883
],
[
885
],
[
887,
889
],
[
891
],
[
893,
895,
897,
899,
901,
903,
905,
907,
909,
911,
913,
915,
917,
919,
921,
923,
925,
927,
929
],
[
931
],
[
933,
935,
937,
939,
941,
943,
945
],
[
947
],
[
949,
951
],
[
953
],
[
955
],
[
959
],
[
961
],
[
963,
965
],
[
967
],
[
969,
971,
973
],
[
975
],
[
977,
979,
981,
983,
985,
987
],
[
989
],
[
991,
993,
995,
997,
999,
1001,
1003
],
[
1005
],
[
1007,
1009,
1011,
1013,
1015,
1017,
1019,
1021,
1023,
1025
],
[
1027
],
[
1029,
1031
],
[
1033
],
[
1035
],
[
1037
],
[
1039
],
[
1041,
1043
],
[
1045
],
[
1047,
1049
],
[
1051
],
[
1053,
1055,
1057,
1059,
1061,
1063,
1065,
1067,
1069,
1071,
1073,
1075,
1077,
1079,
1081,
1083,
1085,
1087,
1089,
1091,
1093,
1095,
1097
],
[
1099
],
[
1101,
1103
],
[
1105
],
[
1107
],
[
1109
],
[
1111
],
[
1113,
1115
],
[
1117
],
[
1119,
1121
],
[
1123
],
[
1125
],
[
1129
],
[
1131
],
[
1133
],
[
1135
],
[
1139
],
[
1141
],
[
1145
],
[
1147
],
[
1151
],
[
1155
],
[
1157
],
[
1159
],
[
1161
],
[
1163,
1165
],
[
1167
],
[
1169
],
[
1171
],
[
1173
],
[
1175,
1177
],
[
1179
],
[
1181,
1183
],
[
1185
],
[
1187,
1189,
1191,
1193,
1195,
1197,
1199,
1201,
1203,
1205,
1207,
1209,
1211
],
[
1213
],
[
1215,
1217
],
[
1219
],
[
1221,
1223,
1225,
1227,
1229
],
[
1231
],
[
1233,
1235
],
[
1237
],
[
1239
],
[
1241
],
[
1243
],
[
1245,
1247,
1249,
1251
],
[
1253
],
[
1255
],
[
1257
],
[
1259,
1261
],
[
1263
],
[
1265
],
[
1267
],
[
1269
],
[
1271,
1273,
1275,
1277
],
[
1279
],
[
1281
],
[
1283,
1285
],
[
1287
],
[
1289,
1291,
1293,
1295,
1297,
1299,
1301,
1303,
1305,
1307,
1309,
1311,
1313,
1315,
1317,
1319,
1321,
1323
],
[
1325
],
[
1327,
1329,
1331,
1333,
1335,
1337,
1339
],
[
1341
],
[
1343,
1345
],
[
1347
],
[
1349
],
[
1351
],
[
1353
],
[
1355,
1357
],
[
1359
],
[
1361,
1363,
1365,
1367,
1369,
1371,
1373,
1375,
1377,
1379,
1381,
1383,
1385,
1387,
1389,
1391,
1393,
1395,
1397,
1399,
1401,
1403
],
[
1405
],
[
1407,
1409,
1411,
1413,
1415,
1417
],
[
1419
],
[
1421,
1423
],
[
1425
],
[
1427
],
[
1429
],
[
1431
],
[
1433,
1435
],
[
1437
],
[
1439,
1441,
1445
],
[
1447
],
[
1449,
1451,
1453,
1455,
1457,
1459,
1461
],
[
1463
],
[
1465,
1467,
1469,
1471,
1473,
1475,
1477,
1479,
1481,
1483
],
[
1485
],
[
1487,
1489,
1491,
1493,
1495,
1497,
1499,
1501,
1503,
1505,
1507
],
[
1509
],
[
1511,
1513
],
[
1515
],
[
1517
],
[
1519
],
[
1521
],
[
1523,
1525
],
[
1527
],
[
1529,
1531
],
[
1533
],
[
1535,
1537,
1539,
1541,
1543,
1545,
1547,
1549,
1551,
1553,
1555,
1557,
1559,
1561,
1563,
1565,
1567,
1569,
1571
],
[
1573
],
[
1575,
1577,
1579,
1581
],
[
1583
],
[
1585,
1587
],
[
1589
],
[
1591
],
[
1593
],
[
1595
],
[
1597,
1599
],
[
1601
],
[
1603,
1605,
1607,
1609,
1611,
1613,
1615,
1617,
1619,
1621,
1623,
1625,
1627
],
[
1629
],
[
1631,
1633,
1635,
1637,
1639,
1641,
1643,
1645,
1647,
1649,
1651,
1653,
1655,
1657,
1659
],
[
1661
],
[
1663,
1665
],
[
1667
],
[
1669
],
[
1671
],
[
1673
],
[
1675,
1677
],
[
1679
],
[
1681,
1683
],
[
1685
],
[
1689
],
[
1691
],
[
1693
],
[
1695
],
[
1697
],
[
1701
],
[
1703
],
[
1707
],
[
1709
],
[
1713
],
[
1715
],
[
1717
],
[
1719,
1721
],
[
1723
],
[
1725
],
[
1727
],
[
1729
],
[
1731,
1733
],
[
1735
],
[
1737,
1739,
1741
],
[
1743
],
[
1745
],
[
1747
],
[
1749
],
[
1751,
1753
],
[
1755
],
[
1757,
1759,
1761
],
[
1763
],
[
1765
],
[
1767,
1769,
1771
],
[
1773
],
[
1775,
1777
],
[
1781
],
[
1783,
1785,
1787,
1789,
1791
],
[
1793
],
[
1795
],
[
1797
],
[
1799,
1801
],
[
1803
],
[
1805
],
[
1807
],
[
1809
],
[
1811,
1813
],
[
1815
],
[
1817
],
[
1819,
1821,
1823,
1825,
1827,
1829,
1831,
1833,
1835,
1837
],
[
1839,
1841
],
[
1843,
1845,
1847
],
[
1849,
1851
],
[
1853,
1855,
1857
],
[
1859
],
[
1863
],
[
1865
],
[
1867,
1869
],
[
1871
],
[
1873
],
[
1875
],
[
1877,
1879
],
[
1881
],
[
1883
],
[
1885
],
[
1887,
1889
],
[
1891
],
[
1893
],
[
1895
],
[
1897,
1899
],
[
1901
],
[
1903
],
[
1905
],
[
1907,
1909
],
[
1911
],
[
1913
],
[
1915
],
[
1919
],
[
1921
],
[
1923,
1925
],
[
1927
],
[
1929
],
[
1931
],
[
1935
],
[
1937
],
[
1939,
1941
],
[
1943
],
[
1945
],
[
1947
],
[
1949
],
[
1951
],
[
1953,
1955
],
[
1957,
1959
],
[
1961
],
[
1963
],
[
1965,
1967
],
[
1969
],
[
1971
],
[
1973,
1975
],
[
1977
],
[
1979
],
[
1981
],
[
1983
],
[
1985,
1987,
1989
],
[
1991
],
[
1993,
1995,
1997
],
[
1999
],
[
2001,
2003,
2005,
2007,
2009
],
[
2011
],
[
2013,
2015
],
[
2017
],
[
2019
],
[
2021
],
[
2023,
2025,
2027
],
[
2029
],
[
2031
],
[
2033,
2035,
2037
],
[
2039
],
[
2041,
2043,
2045
],
[
2047
],
[
2049,
2051
],
[
2053
],
[
2055,
2057
],
[
2059
],
[
2063
],
[
2065,
2067
],
[
2071
],
[
2077,
2079,
2081,
2083,
2085
],
[
2087
],
[
2091,
2093
],
[
2095
],
[
2097
],
[
2099
],
[
2101,
2103,
2105
],
[
2107,
2109,
2111,
2113,
2115
],
[
2117
],
[
2119,
2121,
2123,
2125
],
[
2127
],
[
2129
],
[
2131,
2133,
2135,
2137
],
[
2139
],
[
2143,
2145,
2147
],
[
2149
],
[
2151
],
[
2153,
2155,
2157,
2159,
2161,
2163,
2165
],
[
2167
],
[
2169,
2171
],
[
2173
],
[
2175
],
[
2177
],
[
2179
],
[
2181
],
[
2183
],
[
2185
],
[
2191,
2193,
2195,
2197,
2201
],
[
2203
],
[
2205,
2207
],
[
2211
],
[
2213
],
[
2217,
2219
],
[
2221
],
[
2223
],
[
2225
],
[
2227,
2229,
2231,
2233,
2235,
2237,
2239
],
[
2241
],
[
2243,
2247
],
[
2249,
2251,
2253,
2255,
2257,
2259,
2261,
2263,
2265,
2267,
2269,
2271,
2273,
2275
],
[
2277
],
[
2279,
2281
],
[
2283
],
[
2285
],
[
2287
],
[
2289
],
[
2291
],
[
2293
],
[
2295
],
[
2299,
2303,
2305,
2307,
2309,
2311
],
[
2313
],
[
2315
],
[
2317
],
[
2319,
2321,
2323
],
[
2325
],
[
2327
],
[
2329
],
[
2331,
2333
],
[
2335
],
[
2337
],
[
2339
],
[
2341,
2343,
2345
],
[
2347
],
[
2349
],
[
2351
],
[
2353,
2355,
2357
],
[
2359
],
[
2361
],
[
2363
],
[
2365
],
[
2367,
2369
],
[
2373,
2375
],
[
2377
],
[
2379
],
[
2381
],
[
2383
]
] |
1,738 | static int lzw_get_code(struct LZWState * s)
{
int c;
if(s->mode == FF_LZW_GIF) {
while (s->bbits < s->cursize) {
if (!s->bs) {
s->bs = *s->pbuf++;
if(!s->bs) {
s->eob_reached = 1;
break;
}
}
s->bbuf |= (*s->pbuf++) << s->bbits;
s->bbits += 8;
s->bs--;
}
c = s->bbuf & s->curmask;
s->bbuf >>= s->cursize;
} else { // TIFF
while (s->bbits < s->cursize) {
if (s->pbuf >= s->ebuf) {
s->eob_reached = 1;
}
s->bbuf = (s->bbuf << 8) | (*s->pbuf++);
s->bbits += 8;
}
c = (s->bbuf >> (s->bbits - s->cursize)) & s->curmask;
}
s->bbits -= s->cursize;
return c;
}
| true | FFmpeg | 5f01beb54846de8764c15206aa63086238dde493 | static int lzw_get_code(struct LZWState * s)
{
int c;
if(s->mode == FF_LZW_GIF) {
while (s->bbits < s->cursize) {
if (!s->bs) {
s->bs = *s->pbuf++;
if(!s->bs) {
s->eob_reached = 1;
break;
}
}
s->bbuf |= (*s->pbuf++) << s->bbits;
s->bbits += 8;
s->bs--;
}
c = s->bbuf & s->curmask;
s->bbuf >>= s->cursize;
} else {
while (s->bbits < s->cursize) {
if (s->pbuf >= s->ebuf) {
s->eob_reached = 1;
}
s->bbuf = (s->bbuf << 8) | (*s->pbuf++);
s->bbits += 8;
}
c = (s->bbuf >> (s->bbits - s->cursize)) & s->curmask;
}
s->bbits -= s->cursize;
return c;
}
| {
"code": [
" if(!s->bs) {",
" s->eob_reached = 1;",
" break;",
" if (s->pbuf >= s->ebuf) {",
" s->eob_reached = 1;"
],
"line_no": [
17,
19,
21,
43,
45
]
} | static int FUNC_0(struct LZWState * VAR_0)
{
int VAR_1;
if(VAR_0->mode == FF_LZW_GIF) {
while (VAR_0->bbits < VAR_0->cursize) {
if (!VAR_0->bs) {
VAR_0->bs = *VAR_0->pbuf++;
if(!VAR_0->bs) {
VAR_0->eob_reached = 1;
break;
}
}
VAR_0->bbuf |= (*VAR_0->pbuf++) << VAR_0->bbits;
VAR_0->bbits += 8;
VAR_0->bs--;
}
VAR_1 = VAR_0->bbuf & VAR_0->curmask;
VAR_0->bbuf >>= VAR_0->cursize;
} else {
while (VAR_0->bbits < VAR_0->cursize) {
if (VAR_0->pbuf >= VAR_0->ebuf) {
VAR_0->eob_reached = 1;
}
VAR_0->bbuf = (VAR_0->bbuf << 8) | (*VAR_0->pbuf++);
VAR_0->bbits += 8;
}
VAR_1 = (VAR_0->bbuf >> (VAR_0->bbits - VAR_0->cursize)) & VAR_0->curmask;
}
VAR_0->bbits -= VAR_0->cursize;
return VAR_1;
}
| [
"static int FUNC_0(struct LZWState * VAR_0)\n{",
"int VAR_1;",
"if(VAR_0->mode == FF_LZW_GIF) {",
"while (VAR_0->bbits < VAR_0->cursize) {",
"if (!VAR_0->bs) {",
"VAR_0->bs = *VAR_0->pbuf++;",
"if(!VAR_0->bs) {",
"VAR_0->eob_reached = 1;",
"break;",
"}",
"}",
"VAR_0->bbuf |= (*VAR_0->pbuf++) << VAR_0->bbits;",
"VAR_0->bbits += 8;",
"VAR_0->bs--;",
"}",
"VAR_1 = VAR_0->bbuf & VAR_0->curmask;",
"VAR_0->bbuf >>= VAR_0->cursize;",
"} else {",
"while (VAR_0->bbits < VAR_0->cursize) {",
"if (VAR_0->pbuf >= VAR_0->ebuf) {",
"VAR_0->eob_reached = 1;",
"}",
"VAR_0->bbuf = (VAR_0->bbuf << 8) | (*VAR_0->pbuf++);",
"VAR_0->bbits += 8;",
"}",
"VAR_1 = (VAR_0->bbuf >> (VAR_0->bbits - VAR_0->cursize)) & VAR_0->curmask;",
"}",
"VAR_0->bbits -= VAR_0->cursize;",
"return VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
]
] |
1,739 | static av_cold int yop_decode_init(AVCodecContext *avctx)
{
YopDecContext *s = avctx->priv_data;
s->avctx = avctx;
if (avctx->width & 1 || avctx->height & 1 ||
av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0) {
av_log(avctx, AV_LOG_ERROR, "YOP has invalid dimensions\n");
return -1;
avctx->pix_fmt = PIX_FMT_PAL8;
avcodec_get_frame_defaults(&s->frame);
s->num_pal_colors = avctx->extradata[0];
s->first_color[0] = avctx->extradata[1];
s->first_color[1] = avctx->extradata[2];
if (s->num_pal_colors + s->first_color[0] > 256 ||
s->num_pal_colors + s->first_color[1] > 256) {
av_log(avctx, AV_LOG_ERROR,
"YOP: palette parameters invalid, header probably corrupt\n");
return 0; | true | FFmpeg | 77a4c8b959fa9bc6bcaa42b40a0b046cdf3fec38 | static av_cold int yop_decode_init(AVCodecContext *avctx)
{
YopDecContext *s = avctx->priv_data;
s->avctx = avctx;
if (avctx->width & 1 || avctx->height & 1 ||
av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0) {
av_log(avctx, AV_LOG_ERROR, "YOP has invalid dimensions\n");
return -1;
avctx->pix_fmt = PIX_FMT_PAL8;
avcodec_get_frame_defaults(&s->frame);
s->num_pal_colors = avctx->extradata[0];
s->first_color[0] = avctx->extradata[1];
s->first_color[1] = avctx->extradata[2];
if (s->num_pal_colors + s->first_color[0] > 256 ||
s->num_pal_colors + s->first_color[1] > 256) {
av_log(avctx, AV_LOG_ERROR,
"YOP: palette parameters invalid, header probably corrupt\n");
return 0; | {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
YopDecContext *s = avctx->priv_data;
s->avctx = avctx;
if (avctx->width & 1 || avctx->height & 1 ||
av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0) {
av_log(avctx, AV_LOG_ERROR, "YOP has invalid dimensions\n");
return -1;
avctx->pix_fmt = PIX_FMT_PAL8;
avcodec_get_frame_defaults(&s->frame);
s->num_pal_colors = avctx->extradata[0];
s->first_color[0] = avctx->extradata[1];
s->first_color[1] = avctx->extradata[2];
if (s->num_pal_colors + s->first_color[0] > 256 ||
s->num_pal_colors + s->first_color[1] > 256) {
av_log(avctx, AV_LOG_ERROR,
"YOP: palette parameters invalid, header probably corrupt\n");
return 0; | [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"YopDecContext *s = avctx->priv_data;",
"s->avctx = avctx;",
"if (avctx->width & 1 || avctx->height & 1 ||\nav_image_check_size(avctx->width, avctx->height, 0, avctx) < 0) {",
"av_log(avctx, AV_LOG_ERROR, \"YOP has invalid dimensions\\n\");",
"return -1;",
"avctx->pix_fmt = PIX_FMT_PAL8;",
"avcodec_get_frame_defaults(&s->frame);",
"s->num_pal_colors = avctx->extradata[0];",
"s->first_color[0] = avctx->extradata[1];",
"s->first_color[1] = avctx->extradata[2];",
"if (s->num_pal_colors + s->first_color[0] > 256 ||\ns->num_pal_colors + s->first_color[1] > 256) {",
"av_log(avctx, AV_LOG_ERROR,\n\"YOP: palette parameters invalid, header probably corrupt\\n\");",
"return 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
]
] |
1,740 | static int local_open(FsContext *ctx, V9fsPath *fs_path,
int flags, V9fsFidOpenState *fs)
{
char *buffer;
char *path = fs_path->data;
int fd;
buffer = rpath(ctx, path);
fd = open(buffer, flags | O_NOFOLLOW);
g_free(buffer);
if (fd == -1) {
return -1;
}
fs->fd = fd;
return fs->fd;
}
| true | qemu | 996a0d76d7e756e4023ef79bc37bfe629b9eaca7 | static int local_open(FsContext *ctx, V9fsPath *fs_path,
int flags, V9fsFidOpenState *fs)
{
char *buffer;
char *path = fs_path->data;
int fd;
buffer = rpath(ctx, path);
fd = open(buffer, flags | O_NOFOLLOW);
g_free(buffer);
if (fd == -1) {
return -1;
}
fs->fd = fd;
return fs->fd;
}
| {
"code": [
" char *buffer;",
" char *path = fs_path->data;",
" buffer = rpath(ctx, path);",
" fd = open(buffer, flags | O_NOFOLLOW);",
" g_free(buffer);",
" char *buffer;",
" char *path = fs_path->data;",
" buffer = rpath(ctx, path);",
" g_free(buffer);"
],
"line_no": [
7,
9,
15,
17,
19,
7,
9,
15,
19
]
} | static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1,
int VAR_2, V9fsFidOpenState *VAR_3)
{
char *VAR_4;
char *VAR_5 = VAR_1->data;
int VAR_6;
VAR_4 = rpath(VAR_0, VAR_5);
VAR_6 = open(VAR_4, VAR_2 | O_NOFOLLOW);
g_free(VAR_4);
if (VAR_6 == -1) {
return -1;
}
VAR_3->VAR_6 = VAR_6;
return VAR_3->VAR_6;
}
| [
"static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1,\nint VAR_2, V9fsFidOpenState *VAR_3)\n{",
"char *VAR_4;",
"char *VAR_5 = VAR_1->data;",
"int VAR_6;",
"VAR_4 = rpath(VAR_0, VAR_5);",
"VAR_6 = open(VAR_4, VAR_2 | O_NOFOLLOW);",
"g_free(VAR_4);",
"if (VAR_6 == -1) {",
"return -1;",
"}",
"VAR_3->VAR_6 = VAR_6;",
"return VAR_3->VAR_6;",
"}"
] | [
0,
1,
1,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
]
] |
1,741 | static int local_lstat(FsContext *fs_ctx, V9fsPath *fs_path, struct stat *stbuf)
{
int err;
char *buffer;
char *path = fs_path->data;
buffer = rpath(fs_ctx, path);
err = lstat(buffer, stbuf);
if (err) {
goto err_out;
}
if (fs_ctx->export_flags & V9FS_SM_MAPPED) {
/* Actual credentials are part of extended attrs */
uid_t tmp_uid;
gid_t tmp_gid;
mode_t tmp_mode;
dev_t tmp_dev;
if (getxattr(buffer, "user.virtfs.uid", &tmp_uid, sizeof(uid_t)) > 0) {
stbuf->st_uid = le32_to_cpu(tmp_uid);
}
if (getxattr(buffer, "user.virtfs.gid", &tmp_gid, sizeof(gid_t)) > 0) {
stbuf->st_gid = le32_to_cpu(tmp_gid);
}
if (getxattr(buffer, "user.virtfs.mode",
&tmp_mode, sizeof(mode_t)) > 0) {
stbuf->st_mode = le32_to_cpu(tmp_mode);
}
if (getxattr(buffer, "user.virtfs.rdev", &tmp_dev, sizeof(dev_t)) > 0) {
stbuf->st_rdev = le64_to_cpu(tmp_dev);
}
} else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) {
local_mapped_file_attr(fs_ctx, path, stbuf);
}
err_out:
g_free(buffer);
return err;
}
| true | qemu | f9aef99b3e6df88036436b0d3dc3d504b9346c8c | static int local_lstat(FsContext *fs_ctx, V9fsPath *fs_path, struct stat *stbuf)
{
int err;
char *buffer;
char *path = fs_path->data;
buffer = rpath(fs_ctx, path);
err = lstat(buffer, stbuf);
if (err) {
goto err_out;
}
if (fs_ctx->export_flags & V9FS_SM_MAPPED) {
uid_t tmp_uid;
gid_t tmp_gid;
mode_t tmp_mode;
dev_t tmp_dev;
if (getxattr(buffer, "user.virtfs.uid", &tmp_uid, sizeof(uid_t)) > 0) {
stbuf->st_uid = le32_to_cpu(tmp_uid);
}
if (getxattr(buffer, "user.virtfs.gid", &tmp_gid, sizeof(gid_t)) > 0) {
stbuf->st_gid = le32_to_cpu(tmp_gid);
}
if (getxattr(buffer, "user.virtfs.mode",
&tmp_mode, sizeof(mode_t)) > 0) {
stbuf->st_mode = le32_to_cpu(tmp_mode);
}
if (getxattr(buffer, "user.virtfs.rdev", &tmp_dev, sizeof(dev_t)) > 0) {
stbuf->st_rdev = le64_to_cpu(tmp_dev);
}
} else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) {
local_mapped_file_attr(fs_ctx, path, stbuf);
}
err_out:
g_free(buffer);
return err;
}
| {
"code": [
" int err;",
" char *buffer;",
" char *path = fs_path->data;",
" buffer = rpath(fs_ctx, path);",
" err = lstat(buffer, stbuf);",
" if (getxattr(buffer, \"user.virtfs.uid\", &tmp_uid, sizeof(uid_t)) > 0) {",
" if (getxattr(buffer, \"user.virtfs.gid\", &tmp_gid, sizeof(gid_t)) > 0) {",
" if (getxattr(buffer, \"user.virtfs.mode\",",
" &tmp_mode, sizeof(mode_t)) > 0) {",
" if (getxattr(buffer, \"user.virtfs.rdev\", &tmp_dev, sizeof(dev_t)) > 0) {",
" local_mapped_file_attr(fs_ctx, path, stbuf);",
" g_free(buffer);"
],
"line_no": [
5,
7,
9,
13,
15,
35,
41,
47,
49,
55,
63,
71
]
} | static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1, struct stat *VAR_2)
{
int VAR_3;
char *VAR_4;
char *VAR_5 = VAR_1->data;
VAR_4 = rpath(VAR_0, VAR_5);
VAR_3 = lstat(VAR_4, VAR_2);
if (VAR_3) {
goto err_out;
}
if (VAR_0->export_flags & V9FS_SM_MAPPED) {
uid_t tmp_uid;
gid_t tmp_gid;
mode_t tmp_mode;
dev_t tmp_dev;
if (getxattr(VAR_4, "user.virtfs.uid", &tmp_uid, sizeof(uid_t)) > 0) {
VAR_2->st_uid = le32_to_cpu(tmp_uid);
}
if (getxattr(VAR_4, "user.virtfs.gid", &tmp_gid, sizeof(gid_t)) > 0) {
VAR_2->st_gid = le32_to_cpu(tmp_gid);
}
if (getxattr(VAR_4, "user.virtfs.mode",
&tmp_mode, sizeof(mode_t)) > 0) {
VAR_2->st_mode = le32_to_cpu(tmp_mode);
}
if (getxattr(VAR_4, "user.virtfs.rdev", &tmp_dev, sizeof(dev_t)) > 0) {
VAR_2->st_rdev = le64_to_cpu(tmp_dev);
}
} else if (VAR_0->export_flags & V9FS_SM_MAPPED_FILE) {
local_mapped_file_attr(VAR_0, VAR_5, VAR_2);
}
err_out:
g_free(VAR_4);
return VAR_3;
}
| [
"static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1, struct stat *VAR_2)\n{",
"int VAR_3;",
"char *VAR_4;",
"char *VAR_5 = VAR_1->data;",
"VAR_4 = rpath(VAR_0, VAR_5);",
"VAR_3 = lstat(VAR_4, VAR_2);",
"if (VAR_3) {",
"goto err_out;",
"}",
"if (VAR_0->export_flags & V9FS_SM_MAPPED) {",
"uid_t tmp_uid;",
"gid_t tmp_gid;",
"mode_t tmp_mode;",
"dev_t tmp_dev;",
"if (getxattr(VAR_4, \"user.virtfs.uid\", &tmp_uid, sizeof(uid_t)) > 0) {",
"VAR_2->st_uid = le32_to_cpu(tmp_uid);",
"}",
"if (getxattr(VAR_4, \"user.virtfs.gid\", &tmp_gid, sizeof(gid_t)) > 0) {",
"VAR_2->st_gid = le32_to_cpu(tmp_gid);",
"}",
"if (getxattr(VAR_4, \"user.virtfs.mode\",\n&tmp_mode, sizeof(mode_t)) > 0) {",
"VAR_2->st_mode = le32_to_cpu(tmp_mode);",
"}",
"if (getxattr(VAR_4, \"user.virtfs.rdev\", &tmp_dev, sizeof(dev_t)) > 0) {",
"VAR_2->st_rdev = le64_to_cpu(tmp_dev);",
"}",
"} else if (VAR_0->export_flags & V9FS_SM_MAPPED_FILE) {",
"local_mapped_file_attr(VAR_0, VAR_5, VAR_2);",
"}",
"err_out:\ng_free(VAR_4);",
"return VAR_3;",
"}"
] | [
0,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
1,
0,
0,
1,
0,
0,
1,
0,
0,
0,
1,
0,
1,
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
],
[
63
],
[
65
],
[
69,
71
],
[
73
],
[
75
]
] |
1,742 | int vnc_tls_set_x509_creds_dir(VncDisplay *vd,
const char *certdir)
{
if (vnc_set_x509_credential(vd, certdir, X509_CA_CERT_FILE, &vd->tls.x509cacert, 0) < 0)
goto cleanup;
if (vnc_set_x509_credential(vd, certdir, X509_CA_CRL_FILE, &vd->tls.x509cacrl, 1) < 0)
goto cleanup;
if (vnc_set_x509_credential(vd, certdir, X509_SERVER_CERT_FILE, &vd->tls.x509cert, 0) < 0)
goto cleanup;
if (vnc_set_x509_credential(vd, certdir, X509_SERVER_KEY_FILE, &vd->tls.x509key, 0) < 0)
goto cleanup;
return 0;
cleanup:
g_free(vd->tls.x509cacert);
g_free(vd->tls.x509cacrl);
g_free(vd->tls.x509cert);
g_free(vd->tls.x509key);
vd->tls.x509cacert = vd->tls.x509cacrl = vd->tls.x509cert = vd->tls.x509key = NULL;
return -1;
}
| true | qemu | 3e305e4a4752f70c0b5c3cf5b43ec957881714f7 | int vnc_tls_set_x509_creds_dir(VncDisplay *vd,
const char *certdir)
{
if (vnc_set_x509_credential(vd, certdir, X509_CA_CERT_FILE, &vd->tls.x509cacert, 0) < 0)
goto cleanup;
if (vnc_set_x509_credential(vd, certdir, X509_CA_CRL_FILE, &vd->tls.x509cacrl, 1) < 0)
goto cleanup;
if (vnc_set_x509_credential(vd, certdir, X509_SERVER_CERT_FILE, &vd->tls.x509cert, 0) < 0)
goto cleanup;
if (vnc_set_x509_credential(vd, certdir, X509_SERVER_KEY_FILE, &vd->tls.x509key, 0) < 0)
goto cleanup;
return 0;
cleanup:
g_free(vd->tls.x509cacert);
g_free(vd->tls.x509cacrl);
g_free(vd->tls.x509cert);
g_free(vd->tls.x509key);
vd->tls.x509cacert = vd->tls.x509cacrl = vd->tls.x509cert = vd->tls.x509key = NULL;
return -1;
}
| {
"code": [
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
"int vnc_tls_set_x509_creds_dir(VncDisplay *vd,",
" const char *certdir)",
" if (vnc_set_x509_credential(vd, certdir, X509_CA_CERT_FILE, &vd->tls.x509cacert, 0) < 0)",
" goto cleanup;",
" if (vnc_set_x509_credential(vd, certdir, X509_CA_CRL_FILE, &vd->tls.x509cacrl, 1) < 0)",
" goto cleanup;",
" if (vnc_set_x509_credential(vd, certdir, X509_SERVER_CERT_FILE, &vd->tls.x509cert, 0) < 0)",
" goto cleanup;",
" if (vnc_set_x509_credential(vd, certdir, X509_SERVER_KEY_FILE, &vd->tls.x509key, 0) < 0)",
" goto cleanup;",
" return 0;",
" cleanup:",
" g_free(vd->tls.x509cacert);",
" g_free(vd->tls.x509cacrl);",
" g_free(vd->tls.x509cert);",
" g_free(vd->tls.x509key);",
" vd->tls.x509cacert = vd->tls.x509cacrl = vd->tls.x509cert = vd->tls.x509key = NULL;",
" return -1;",
"int vnc_tls_set_x509_creds_dir(VncDisplay *vd,"
],
"line_no": [
25,
25,
25,
25,
25,
1,
3,
7,
9,
11,
9,
15,
9,
19,
9,
25,
29,
31,
33,
35,
37,
39,
41,
1
]
} | int FUNC_0(VncDisplay *VAR_0,
const char *VAR_1)
{
if (vnc_set_x509_credential(VAR_0, VAR_1, X509_CA_CERT_FILE, &VAR_0->tls.x509cacert, 0) < 0)
goto cleanup;
if (vnc_set_x509_credential(VAR_0, VAR_1, X509_CA_CRL_FILE, &VAR_0->tls.x509cacrl, 1) < 0)
goto cleanup;
if (vnc_set_x509_credential(VAR_0, VAR_1, X509_SERVER_CERT_FILE, &VAR_0->tls.x509cert, 0) < 0)
goto cleanup;
if (vnc_set_x509_credential(VAR_0, VAR_1, X509_SERVER_KEY_FILE, &VAR_0->tls.x509key, 0) < 0)
goto cleanup;
return 0;
cleanup:
g_free(VAR_0->tls.x509cacert);
g_free(VAR_0->tls.x509cacrl);
g_free(VAR_0->tls.x509cert);
g_free(VAR_0->tls.x509key);
VAR_0->tls.x509cacert = VAR_0->tls.x509cacrl = VAR_0->tls.x509cert = VAR_0->tls.x509key = NULL;
return -1;
}
| [
"int FUNC_0(VncDisplay *VAR_0,\nconst char *VAR_1)\n{",
"if (vnc_set_x509_credential(VAR_0, VAR_1, X509_CA_CERT_FILE, &VAR_0->tls.x509cacert, 0) < 0)\ngoto cleanup;",
"if (vnc_set_x509_credential(VAR_0, VAR_1, X509_CA_CRL_FILE, &VAR_0->tls.x509cacrl, 1) < 0)\ngoto cleanup;",
"if (vnc_set_x509_credential(VAR_0, VAR_1, X509_SERVER_CERT_FILE, &VAR_0->tls.x509cert, 0) < 0)\ngoto cleanup;",
"if (vnc_set_x509_credential(VAR_0, VAR_1, X509_SERVER_KEY_FILE, &VAR_0->tls.x509key, 0) < 0)\ngoto cleanup;",
"return 0;",
"cleanup:\ng_free(VAR_0->tls.x509cacert);",
"g_free(VAR_0->tls.x509cacrl);",
"g_free(VAR_0->tls.x509cert);",
"g_free(VAR_0->tls.x509key);",
"VAR_0->tls.x509cacert = VAR_0->tls.x509cacrl = VAR_0->tls.x509cert = VAR_0->tls.x509key = NULL;",
"return -1;",
"}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0
] | [
[
1,
3,
5
],
[
7,
9
],
[
11,
13
],
[
15,
17
],
[
19,
21
],
[
25
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
]
] |
1,743 | int mm_support(void)
{
int rval;
int eax, ebx, ecx, edx;
__asm__ __volatile__ (
/* See if CPUID instruction is supported ... */
/* ... Get copies of EFLAGS into eax and ecx */
"pushf\n\t"
"pop %0\n\t"
"movl %0, %1\n\t"
/* ... Toggle the ID bit in one copy and store */
/* to the EFLAGS reg */
"xorl $0x200000, %0\n\t"
"push %0\n\t"
"popf\n\t"
/* ... Get the (hopefully modified) EFLAGS */
"pushf\n\t"
"pop %0\n\t"
: "=a" (eax), "=c" (ecx)
:
: "cc"
);
if (eax == ecx)
return 0; /* CPUID not supported */
cpuid(0, eax, ebx, ecx, edx);
if (ebx == 0x756e6547 &&
edx == 0x49656e69 &&
ecx == 0x6c65746e) {
/* intel */
inteltest:
cpuid(1, eax, ebx, ecx, edx);
if ((edx & 0x00800000) == 0)
return 0;
rval = MM_MMX;
if (edx & 0x02000000)
rval |= MM_MMXEXT | MM_SSE;
if (edx & 0x04000000)
rval |= MM_SSE2;
return rval;
} else if (ebx == 0x68747541 &&
edx == 0x69746e65 &&
ecx == 0x444d4163) {
/* AMD */
cpuid(0x80000000, eax, ebx, ecx, edx);
if ((unsigned)eax < 0x80000001)
goto inteltest;
cpuid(0x80000001, eax, ebx, ecx, edx);
if ((edx & 0x00800000) == 0)
return 0;
rval = MM_MMX;
if (edx & 0x80000000)
rval |= MM_3DNOW;
if (edx & 0x00400000)
rval |= MM_MMXEXT;
return rval;
} else if (ebx == 0x746e6543 &&
edx == 0x48727561 &&
ecx == 0x736c7561) { /* "CentaurHauls" */
/* VIA C3 */
cpuid(0x80000000, eax, ebx, ecx, edx);
if ((unsigned)eax < 0x80000001)
goto inteltest;
cpuid(0x80000001, eax, ebx, ecx, edx);
rval = 0;
if( edx & ( 1 << 31) )
rval |= MM_3DNOW;
if( edx & ( 1 << 23) )
rval |= MM_MMX;
if( edx & ( 1 << 24) )
rval |= MM_MMXEXT;
if(rval==0)
goto inteltest;
return rval;
} else if (ebx == 0x69727943 &&
edx == 0x736e4978 &&
ecx == 0x64616574) {
/* Cyrix Section */
/* See if extended CPUID level 80000001 is supported */
/* The value of CPUID/80000001 for the 6x86MX is undefined
according to the Cyrix CPU Detection Guide (Preliminary
Rev. 1.01 table 1), so we'll check the value of eax for
CPUID/0 to see if standard CPUID level 2 is supported.
According to the table, the only CPU which supports level
2 is also the only one which supports extended CPUID levels.
*/
if (eax != 2)
goto inteltest;
cpuid(0x80000001, eax, ebx, ecx, edx);
if ((eax & 0x00800000) == 0)
return 0;
rval = MM_MMX;
if (eax & 0x01000000)
rval |= MM_MMXEXT;
return rval;
} else if (ebx == 0x756e6547 &&
edx == 0x54656e69 &&
ecx == 0x3638784d) {
/* Tranmeta Crusoe */
cpuid(0x80000000, eax, ebx, ecx, edx);
if ((unsigned)eax < 0x80000001)
return 0;
cpuid(0x80000001, eax, ebx, ecx, edx);
if ((edx & 0x00800000) == 0)
return 0;
return MM_MMX;
} else {
return 0;
}
}
| false | FFmpeg | 8b4d077fc9de4d57ee874ca9007ed1553f224853 | int mm_support(void)
{
int rval;
int eax, ebx, ecx, edx;
__asm__ __volatile__ (
"pushf\n\t"
"pop %0\n\t"
"movl %0, %1\n\t"
"xorl $0x200000, %0\n\t"
"push %0\n\t"
"popf\n\t"
"pushf\n\t"
"pop %0\n\t"
: "=a" (eax), "=c" (ecx)
:
: "cc"
);
if (eax == ecx)
return 0;
cpuid(0, eax, ebx, ecx, edx);
if (ebx == 0x756e6547 &&
edx == 0x49656e69 &&
ecx == 0x6c65746e) {
inteltest:
cpuid(1, eax, ebx, ecx, edx);
if ((edx & 0x00800000) == 0)
return 0;
rval = MM_MMX;
if (edx & 0x02000000)
rval |= MM_MMXEXT | MM_SSE;
if (edx & 0x04000000)
rval |= MM_SSE2;
return rval;
} else if (ebx == 0x68747541 &&
edx == 0x69746e65 &&
ecx == 0x444d4163) {
cpuid(0x80000000, eax, ebx, ecx, edx);
if ((unsigned)eax < 0x80000001)
goto inteltest;
cpuid(0x80000001, eax, ebx, ecx, edx);
if ((edx & 0x00800000) == 0)
return 0;
rval = MM_MMX;
if (edx & 0x80000000)
rval |= MM_3DNOW;
if (edx & 0x00400000)
rval |= MM_MMXEXT;
return rval;
} else if (ebx == 0x746e6543 &&
edx == 0x48727561 &&
ecx == 0x736c7561) {
cpuid(0x80000000, eax, ebx, ecx, edx);
if ((unsigned)eax < 0x80000001)
goto inteltest;
cpuid(0x80000001, eax, ebx, ecx, edx);
rval = 0;
if( edx & ( 1 << 31) )
rval |= MM_3DNOW;
if( edx & ( 1 << 23) )
rval |= MM_MMX;
if( edx & ( 1 << 24) )
rval |= MM_MMXEXT;
if(rval==0)
goto inteltest;
return rval;
} else if (ebx == 0x69727943 &&
edx == 0x736e4978 &&
ecx == 0x64616574) {
if (eax != 2)
goto inteltest;
cpuid(0x80000001, eax, ebx, ecx, edx);
if ((eax & 0x00800000) == 0)
return 0;
rval = MM_MMX;
if (eax & 0x01000000)
rval |= MM_MMXEXT;
return rval;
} else if (ebx == 0x756e6547 &&
edx == 0x54656e69 &&
ecx == 0x3638784d) {
cpuid(0x80000000, eax, ebx, ecx, edx);
if ((unsigned)eax < 0x80000001)
return 0;
cpuid(0x80000001, eax, ebx, ecx, edx);
if ((edx & 0x00800000) == 0)
return 0;
return MM_MMX;
} else {
return 0;
}
}
| {
"code": [],
"line_no": []
} | int FUNC_0(void)
{
int VAR_0;
int VAR_1, VAR_2, VAR_3, VAR_4;
__asm__ __volatile__ (
"pushf\n\t"
"pop %0\n\t"
"movl %0, %1\n\t"
"xorl $0x200000, %0\n\t"
"push %0\n\t"
"popf\n\t"
"pushf\n\t"
"pop %0\n\t"
: "=a" (VAR_1), "=c" (VAR_3)
:
: "cc"
);
if (VAR_1 == VAR_3)
return 0;
cpuid(0, VAR_1, VAR_2, VAR_3, VAR_4);
if (VAR_2 == 0x756e6547 &&
VAR_4 == 0x49656e69 &&
VAR_3 == 0x6c65746e) {
inteltest:
cpuid(1, VAR_1, VAR_2, VAR_3, VAR_4);
if ((VAR_4 & 0x00800000) == 0)
return 0;
VAR_0 = MM_MMX;
if (VAR_4 & 0x02000000)
VAR_0 |= MM_MMXEXT | MM_SSE;
if (VAR_4 & 0x04000000)
VAR_0 |= MM_SSE2;
return VAR_0;
} else if (VAR_2 == 0x68747541 &&
VAR_4 == 0x69746e65 &&
VAR_3 == 0x444d4163) {
cpuid(0x80000000, VAR_1, VAR_2, VAR_3, VAR_4);
if ((unsigned)VAR_1 < 0x80000001)
goto inteltest;
cpuid(0x80000001, VAR_1, VAR_2, VAR_3, VAR_4);
if ((VAR_4 & 0x00800000) == 0)
return 0;
VAR_0 = MM_MMX;
if (VAR_4 & 0x80000000)
VAR_0 |= MM_3DNOW;
if (VAR_4 & 0x00400000)
VAR_0 |= MM_MMXEXT;
return VAR_0;
} else if (VAR_2 == 0x746e6543 &&
VAR_4 == 0x48727561 &&
VAR_3 == 0x736c7561) {
cpuid(0x80000000, VAR_1, VAR_2, VAR_3, VAR_4);
if ((unsigned)VAR_1 < 0x80000001)
goto inteltest;
cpuid(0x80000001, VAR_1, VAR_2, VAR_3, VAR_4);
VAR_0 = 0;
if( VAR_4 & ( 1 << 31) )
VAR_0 |= MM_3DNOW;
if( VAR_4 & ( 1 << 23) )
VAR_0 |= MM_MMX;
if( VAR_4 & ( 1 << 24) )
VAR_0 |= MM_MMXEXT;
if(VAR_0==0)
goto inteltest;
return VAR_0;
} else if (VAR_2 == 0x69727943 &&
VAR_4 == 0x736e4978 &&
VAR_3 == 0x64616574) {
if (VAR_1 != 2)
goto inteltest;
cpuid(0x80000001, VAR_1, VAR_2, VAR_3, VAR_4);
if ((VAR_1 & 0x00800000) == 0)
return 0;
VAR_0 = MM_MMX;
if (VAR_1 & 0x01000000)
VAR_0 |= MM_MMXEXT;
return VAR_0;
} else if (VAR_2 == 0x756e6547 &&
VAR_4 == 0x54656e69 &&
VAR_3 == 0x3638784d) {
cpuid(0x80000000, VAR_1, VAR_2, VAR_3, VAR_4);
if ((unsigned)VAR_1 < 0x80000001)
return 0;
cpuid(0x80000001, VAR_1, VAR_2, VAR_3, VAR_4);
if ((VAR_4 & 0x00800000) == 0)
return 0;
return MM_MMX;
} else {
return 0;
}
}
| [
"int FUNC_0(void)\n{",
"int VAR_0;",
"int VAR_1, VAR_2, VAR_3, VAR_4;",
"__asm__ __volatile__ (\n\"pushf\\n\\t\"\n\"pop %0\\n\\t\"\n\"movl %0, %1\\n\\t\"\n\"xorl $0x200000, %0\\n\\t\"\n\"push %0\\n\\t\"\n\"popf\\n\\t\"\n\"pushf\\n\\t\"\n\"pop %0\\n\\t\"\n: \"=a\" (VAR_1), \"=c\" (VAR_3)\n:\n: \"cc\"\n);",
"if (VAR_1 == VAR_3)\nreturn 0;",
"cpuid(0, VAR_1, VAR_2, VAR_3, VAR_4);",
"if (VAR_2 == 0x756e6547 &&\nVAR_4 == 0x49656e69 &&\nVAR_3 == 0x6c65746e) {",
"inteltest:\ncpuid(1, VAR_1, VAR_2, VAR_3, VAR_4);",
"if ((VAR_4 & 0x00800000) == 0)\nreturn 0;",
"VAR_0 = MM_MMX;",
"if (VAR_4 & 0x02000000)\nVAR_0 |= MM_MMXEXT | MM_SSE;",
"if (VAR_4 & 0x04000000)\nVAR_0 |= MM_SSE2;",
"return VAR_0;",
"} else if (VAR_2 == 0x68747541 &&",
"VAR_4 == 0x69746e65 &&\nVAR_3 == 0x444d4163) {",
"cpuid(0x80000000, VAR_1, VAR_2, VAR_3, VAR_4);",
"if ((unsigned)VAR_1 < 0x80000001)\ngoto inteltest;",
"cpuid(0x80000001, VAR_1, VAR_2, VAR_3, VAR_4);",
"if ((VAR_4 & 0x00800000) == 0)\nreturn 0;",
"VAR_0 = MM_MMX;",
"if (VAR_4 & 0x80000000)\nVAR_0 |= MM_3DNOW;",
"if (VAR_4 & 0x00400000)\nVAR_0 |= MM_MMXEXT;",
"return VAR_0;",
"} else if (VAR_2 == 0x746e6543 &&",
"VAR_4 == 0x48727561 &&\nVAR_3 == 0x736c7561) {",
"cpuid(0x80000000, VAR_1, VAR_2, VAR_3, VAR_4);",
"if ((unsigned)VAR_1 < 0x80000001)\ngoto inteltest;",
"cpuid(0x80000001, VAR_1, VAR_2, VAR_3, VAR_4);",
"VAR_0 = 0;",
"if( VAR_4 & ( 1 << 31) )\nVAR_0 |= MM_3DNOW;",
"if( VAR_4 & ( 1 << 23) )\nVAR_0 |= MM_MMX;",
"if( VAR_4 & ( 1 << 24) )\nVAR_0 |= MM_MMXEXT;",
"if(VAR_0==0)\ngoto inteltest;",
"return VAR_0;",
"} else if (VAR_2 == 0x69727943 &&",
"VAR_4 == 0x736e4978 &&\nVAR_3 == 0x64616574) {",
"if (VAR_1 != 2)\ngoto inteltest;",
"cpuid(0x80000001, VAR_1, VAR_2, VAR_3, VAR_4);",
"if ((VAR_1 & 0x00800000) == 0)\nreturn 0;",
"VAR_0 = MM_MMX;",
"if (VAR_1 & 0x01000000)\nVAR_0 |= MM_MMXEXT;",
"return VAR_0;",
"} else if (VAR_2 == 0x756e6547 &&",
"VAR_4 == 0x54656e69 &&\nVAR_3 == 0x3638784d) {",
"cpuid(0x80000000, VAR_1, VAR_2, VAR_3, VAR_4);",
"if ((unsigned)VAR_1 < 0x80000001)\nreturn 0;",
"cpuid(0x80000001, VAR_1, VAR_2, VAR_3, VAR_4);",
"if ((VAR_4 & 0x00800000) == 0)\nreturn 0;",
"return MM_MMX;",
"} else {",
"return 0;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
17,
19,
21,
29,
31,
33,
39,
41,
43,
45,
47,
49
],
[
53,
55
],
[
59
],
[
63,
65,
67
],
[
73,
75
],
[
77,
79
],
[
81
],
[
83,
85
],
[
87,
89
],
[
91
],
[
93
],
[
95,
97
],
[
101
],
[
103,
105
],
[
107
],
[
109,
111
],
[
113
],
[
115,
117
],
[
119,
121
],
[
123
],
[
125
],
[
127,
129
],
[
133
],
[
135,
137
],
[
139
],
[
141
],
[
143,
145
],
[
147,
149
],
[
151,
153
],
[
155,
157
],
[
159
],
[
161
],
[
163,
165
],
[
185,
187
],
[
189
],
[
191,
193
],
[
195
],
[
197,
199
],
[
201
],
[
203
],
[
205,
207
],
[
211
],
[
213,
215
],
[
217
],
[
219,
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
]
] |
1,744 | static uint64_t xscom_read(void *opaque, hwaddr addr, unsigned width)
{
PnvChip *chip = opaque;
uint32_t pcba = pnv_xscom_pcba(chip, addr);
uint64_t val = 0;
MemTxResult result;
/* Handle some SCOMs here before dispatch */
val = xscom_read_default(chip, pcba);
if (val != -1) {
goto complete;
}
val = address_space_ldq(&chip->xscom_as, pcba << 3, MEMTXATTRS_UNSPECIFIED,
&result);
if (result != MEMTX_OK) {
qemu_log_mask(LOG_GUEST_ERROR, "XSCOM read failed at @0x%"
HWADDR_PRIx " pcba=0x%08x\n", addr, pcba);
xscom_complete(current_cpu, HMER_XSCOM_FAIL | HMER_XSCOM_DONE);
return 0;
}
complete:
xscom_complete(current_cpu, HMER_XSCOM_DONE);
return val;
}
| true | qemu | f81e551229070f01bf747eda3f05960182db9d2a | static uint64_t xscom_read(void *opaque, hwaddr addr, unsigned width)
{
PnvChip *chip = opaque;
uint32_t pcba = pnv_xscom_pcba(chip, addr);
uint64_t val = 0;
MemTxResult result;
val = xscom_read_default(chip, pcba);
if (val != -1) {
goto complete;
}
val = address_space_ldq(&chip->xscom_as, pcba << 3, MEMTXATTRS_UNSPECIFIED,
&result);
if (result != MEMTX_OK) {
qemu_log_mask(LOG_GUEST_ERROR, "XSCOM read failed at @0x%"
HWADDR_PRIx " pcba=0x%08x\n", addr, pcba);
xscom_complete(current_cpu, HMER_XSCOM_FAIL | HMER_XSCOM_DONE);
return 0;
}
complete:
xscom_complete(current_cpu, HMER_XSCOM_DONE);
return val;
}
| {
"code": [
" val = address_space_ldq(&chip->xscom_as, pcba << 3, MEMTXATTRS_UNSPECIFIED,",
" &result);"
],
"line_no": [
27,
29
]
} | static uint64_t FUNC_0(void *opaque, hwaddr addr, unsigned width)
{
PnvChip *chip = opaque;
uint32_t pcba = pnv_xscom_pcba(chip, addr);
uint64_t val = 0;
MemTxResult result;
val = xscom_read_default(chip, pcba);
if (val != -1) {
goto complete;
}
val = address_space_ldq(&chip->xscom_as, pcba << 3, MEMTXATTRS_UNSPECIFIED,
&result);
if (result != MEMTX_OK) {
qemu_log_mask(LOG_GUEST_ERROR, "XSCOM read failed at @0x%"
HWADDR_PRIx " pcba=0x%08x\n", addr, pcba);
xscom_complete(current_cpu, HMER_XSCOM_FAIL | HMER_XSCOM_DONE);
return 0;
}
complete:
xscom_complete(current_cpu, HMER_XSCOM_DONE);
return val;
}
| [
"static uint64_t FUNC_0(void *opaque, hwaddr addr, unsigned width)\n{",
"PnvChip *chip = opaque;",
"uint32_t pcba = pnv_xscom_pcba(chip, addr);",
"uint64_t val = 0;",
"MemTxResult result;",
"val = xscom_read_default(chip, pcba);",
"if (val != -1) {",
"goto complete;",
"}",
"val = address_space_ldq(&chip->xscom_as, pcba << 3, MEMTXATTRS_UNSPECIFIED,\n&result);",
"if (result != MEMTX_OK) {",
"qemu_log_mask(LOG_GUEST_ERROR, \"XSCOM read failed at @0x%\"\nHWADDR_PRIx \" pcba=0x%08x\\n\", addr, pcba);",
"xscom_complete(current_cpu, HMER_XSCOM_FAIL | HMER_XSCOM_DONE);",
"return 0;",
"}",
"complete:\nxscom_complete(current_cpu, HMER_XSCOM_DONE);",
"return val;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27,
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
45,
47
],
[
49
],
[
51
]
] |
1,745 | static int remove_mapping(BDRVVVFATState* s, int mapping_index)
{
mapping_t* mapping = array_get(&(s->mapping), mapping_index);
mapping_t* first_mapping = array_get(&(s->mapping), 0);
/* free mapping */
if (mapping->first_mapping_index < 0)
free(mapping->path);
/* remove from s->mapping */
array_remove(&(s->mapping), mapping_index);
/* adjust all references to mappings */
adjust_mapping_indices(s, mapping_index, -1);
if (s->current_mapping && first_mapping != (mapping_t*)s->mapping.pointer)
s->current_mapping = array_get(&(s->mapping),
s->current_mapping - first_mapping);
return 0;
}
| true | qemu | ce137829e7e58fcdc5ba63b5e256f972e80be438 | static int remove_mapping(BDRVVVFATState* s, int mapping_index)
{
mapping_t* mapping = array_get(&(s->mapping), mapping_index);
mapping_t* first_mapping = array_get(&(s->mapping), 0);
if (mapping->first_mapping_index < 0)
free(mapping->path);
array_remove(&(s->mapping), mapping_index);
adjust_mapping_indices(s, mapping_index, -1);
if (s->current_mapping && first_mapping != (mapping_t*)s->mapping.pointer)
s->current_mapping = array_get(&(s->mapping),
s->current_mapping - first_mapping);
return 0;
}
| {
"code": [
" if (mapping->first_mapping_index < 0)",
"\tfree(mapping->path);"
],
"line_no": [
13,
15
]
} | static int FUNC_0(BDRVVVFATState* VAR_0, int VAR_1)
{
mapping_t* mapping = array_get(&(VAR_0->mapping), VAR_1);
mapping_t* first_mapping = array_get(&(VAR_0->mapping), 0);
if (mapping->first_mapping_index < 0)
free(mapping->path);
array_remove(&(VAR_0->mapping), VAR_1);
adjust_mapping_indices(VAR_0, VAR_1, -1);
if (VAR_0->current_mapping && first_mapping != (mapping_t*)VAR_0->mapping.pointer)
VAR_0->current_mapping = array_get(&(VAR_0->mapping),
VAR_0->current_mapping - first_mapping);
return 0;
}
| [
"static int FUNC_0(BDRVVVFATState* VAR_0, int VAR_1)\n{",
"mapping_t* mapping = array_get(&(VAR_0->mapping), VAR_1);",
"mapping_t* first_mapping = array_get(&(VAR_0->mapping), 0);",
"if (mapping->first_mapping_index < 0)\nfree(mapping->path);",
"array_remove(&(VAR_0->mapping), VAR_1);",
"adjust_mapping_indices(VAR_0, VAR_1, -1);",
"if (VAR_0->current_mapping && first_mapping != (mapping_t*)VAR_0->mapping.pointer)\nVAR_0->current_mapping = array_get(&(VAR_0->mapping),\nVAR_0->current_mapping - first_mapping);",
"return 0;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
13,
15
],
[
21
],
[
27
],
[
31,
33,
35
],
[
39
],
[
41
]
] |
1,746 | static void test_redirector_tx(void)
{
#ifndef _WIN32
/* socketpair(PF_UNIX) which does not exist on windows */
int backend_sock[2], recv_sock;
char *cmdline;
uint32_t ret = 0, len = 0;
char send_buf[] = "Hello!!";
char sock_path0[] = "filter-redirector0.XXXXXX";
char sock_path1[] = "filter-redirector1.XXXXXX";
char *recv_buf;
uint32_t size = sizeof(send_buf);
size = htonl(size);
ret = socketpair(PF_UNIX, SOCK_STREAM, 0, backend_sock);
g_assert_cmpint(ret, !=, -1);
ret = mkstemp(sock_path0);
g_assert_cmpint(ret, !=, -1);
ret = mkstemp(sock_path1);
g_assert_cmpint(ret, !=, -1);
cmdline = g_strdup_printf("-netdev socket,id=qtest-bn0,fd=%d "
"-device rtl8139,netdev=qtest-bn0,id=qtest-e0 "
"-chardev socket,id=redirector0,path=%s,server,nowait "
"-chardev socket,id=redirector1,path=%s,server,nowait "
"-chardev socket,id=redirector2,path=%s,nowait "
"-object filter-redirector,id=qtest-f0,netdev=qtest-bn0,"
"queue=tx,outdev=redirector0 "
"-object filter-redirector,id=qtest-f1,netdev=qtest-bn0,"
"queue=tx,indev=redirector2 "
"-object filter-redirector,id=qtest-f2,netdev=qtest-bn0,"
"queue=tx,outdev=redirector1 "
, backend_sock[1], sock_path0, sock_path1, sock_path0);
qtest_start(cmdline);
g_free(cmdline);
recv_sock = unix_connect(sock_path1, NULL);
g_assert_cmpint(recv_sock, !=, -1);
/* send a qmp command to guarantee that 'connected' is setting to true. */
qmp("{ 'execute' : 'query-status'}");
struct iovec iov[] = {
{
.iov_base = &size,
.iov_len = sizeof(size),
}, {
.iov_base = send_buf,
.iov_len = sizeof(send_buf),
},
};
ret = iov_send(backend_sock[0], iov, 2, 0, sizeof(size) + sizeof(send_buf));
g_assert_cmpint(ret, ==, sizeof(send_buf) + sizeof(size));
close(backend_sock[0]);
ret = qemu_recv(recv_sock, &len, sizeof(len), 0);
g_assert_cmpint(ret, ==, sizeof(len));
len = ntohl(len);
g_assert_cmpint(len, ==, sizeof(send_buf));
recv_buf = g_malloc(len);
ret = qemu_recv(recv_sock, recv_buf, len, 0);
g_assert_cmpstr(recv_buf, ==, send_buf);
g_free(recv_buf);
close(recv_sock);
unlink(sock_path0);
unlink(sock_path1);
qtest_end();
#endif
}
| true | qemu | dc491fead04a92a612df93b85b0ebf9dcc3f6684 | static void test_redirector_tx(void)
{
#ifndef _WIN32
int backend_sock[2], recv_sock;
char *cmdline;
uint32_t ret = 0, len = 0;
char send_buf[] = "Hello!!";
char sock_path0[] = "filter-redirector0.XXXXXX";
char sock_path1[] = "filter-redirector1.XXXXXX";
char *recv_buf;
uint32_t size = sizeof(send_buf);
size = htonl(size);
ret = socketpair(PF_UNIX, SOCK_STREAM, 0, backend_sock);
g_assert_cmpint(ret, !=, -1);
ret = mkstemp(sock_path0);
g_assert_cmpint(ret, !=, -1);
ret = mkstemp(sock_path1);
g_assert_cmpint(ret, !=, -1);
cmdline = g_strdup_printf("-netdev socket,id=qtest-bn0,fd=%d "
"-device rtl8139,netdev=qtest-bn0,id=qtest-e0 "
"-chardev socket,id=redirector0,path=%s,server,nowait "
"-chardev socket,id=redirector1,path=%s,server,nowait "
"-chardev socket,id=redirector2,path=%s,nowait "
"-object filter-redirector,id=qtest-f0,netdev=qtest-bn0,"
"queue=tx,outdev=redirector0 "
"-object filter-redirector,id=qtest-f1,netdev=qtest-bn0,"
"queue=tx,indev=redirector2 "
"-object filter-redirector,id=qtest-f2,netdev=qtest-bn0,"
"queue=tx,outdev=redirector1 "
, backend_sock[1], sock_path0, sock_path1, sock_path0);
qtest_start(cmdline);
g_free(cmdline);
recv_sock = unix_connect(sock_path1, NULL);
g_assert_cmpint(recv_sock, !=, -1);
qmp("{ 'execute' : 'query-status'}");
struct iovec iov[] = {
{
.iov_base = &size,
.iov_len = sizeof(size),
}, {
.iov_base = send_buf,
.iov_len = sizeof(send_buf),
},
};
ret = iov_send(backend_sock[0], iov, 2, 0, sizeof(size) + sizeof(send_buf));
g_assert_cmpint(ret, ==, sizeof(send_buf) + sizeof(size));
close(backend_sock[0]);
ret = qemu_recv(recv_sock, &len, sizeof(len), 0);
g_assert_cmpint(ret, ==, sizeof(len));
len = ntohl(len);
g_assert_cmpint(len, ==, sizeof(send_buf));
recv_buf = g_malloc(len);
ret = qemu_recv(recv_sock, recv_buf, len, 0);
g_assert_cmpstr(recv_buf, ==, send_buf);
g_free(recv_buf);
close(recv_sock);
unlink(sock_path0);
unlink(sock_path1);
qtest_end();
#endif
}
| {
"code": [
" qmp(\"{ 'execute' : 'query-status'}\");",
" qmp(\"{ 'execute' : 'query-status'}\");",
" qmp(\"{ 'execute' : 'query-status'}\");"
],
"line_no": [
85,
85,
85
]
} | static void FUNC_0(void)
{
#ifndef _WIN32
int VAR_0[2], VAR_1;
char *VAR_2;
uint32_t ret = 0, len = 0;
char VAR_3[] = "Hello!!";
char VAR_4[] = "filter-redirector0.XXXXXX";
char VAR_5[] = "filter-redirector1.XXXXXX";
char *VAR_6;
uint32_t size = sizeof(VAR_3);
size = htonl(size);
ret = socketpair(PF_UNIX, SOCK_STREAM, 0, VAR_0);
g_assert_cmpint(ret, !=, -1);
ret = mkstemp(VAR_4);
g_assert_cmpint(ret, !=, -1);
ret = mkstemp(VAR_5);
g_assert_cmpint(ret, !=, -1);
VAR_2 = g_strdup_printf("-netdev socket,id=qtest-bn0,fd=%d "
"-device rtl8139,netdev=qtest-bn0,id=qtest-e0 "
"-chardev socket,id=redirector0,path=%s,server,nowait "
"-chardev socket,id=redirector1,path=%s,server,nowait "
"-chardev socket,id=redirector2,path=%s,nowait "
"-object filter-redirector,id=qtest-f0,netdev=qtest-bn0,"
"queue=tx,outdev=redirector0 "
"-object filter-redirector,id=qtest-f1,netdev=qtest-bn0,"
"queue=tx,indev=redirector2 "
"-object filter-redirector,id=qtest-f2,netdev=qtest-bn0,"
"queue=tx,outdev=redirector1 "
, VAR_0[1], VAR_4, VAR_5, VAR_4);
qtest_start(VAR_2);
g_free(VAR_2);
VAR_1 = unix_connect(VAR_5, NULL);
g_assert_cmpint(VAR_1, !=, -1);
qmp("{ 'execute' : 'query-status'}");
struct iovec VAR_7[] = {
{
.iov_base = &size,
.iov_len = sizeof(size),
}, {
.iov_base = VAR_3,
.iov_len = sizeof(VAR_3),
},
};
ret = iov_send(VAR_0[0], VAR_7, 2, 0, sizeof(size) + sizeof(VAR_3));
g_assert_cmpint(ret, ==, sizeof(VAR_3) + sizeof(size));
close(VAR_0[0]);
ret = qemu_recv(VAR_1, &len, sizeof(len), 0);
g_assert_cmpint(ret, ==, sizeof(len));
len = ntohl(len);
g_assert_cmpint(len, ==, sizeof(VAR_3));
VAR_6 = g_malloc(len);
ret = qemu_recv(VAR_1, VAR_6, len, 0);
g_assert_cmpstr(VAR_6, ==, VAR_3);
g_free(VAR_6);
close(VAR_1);
unlink(VAR_4);
unlink(VAR_5);
qtest_end();
#endif
}
| [
"static void FUNC_0(void)\n{",
"#ifndef _WIN32\nint VAR_0[2], VAR_1;",
"char *VAR_2;",
"uint32_t ret = 0, len = 0;",
"char VAR_3[] = \"Hello!!\";",
"char VAR_4[] = \"filter-redirector0.XXXXXX\";",
"char VAR_5[] = \"filter-redirector1.XXXXXX\";",
"char *VAR_6;",
"uint32_t size = sizeof(VAR_3);",
"size = htonl(size);",
"ret = socketpair(PF_UNIX, SOCK_STREAM, 0, VAR_0);",
"g_assert_cmpint(ret, !=, -1);",
"ret = mkstemp(VAR_4);",
"g_assert_cmpint(ret, !=, -1);",
"ret = mkstemp(VAR_5);",
"g_assert_cmpint(ret, !=, -1);",
"VAR_2 = g_strdup_printf(\"-netdev socket,id=qtest-bn0,fd=%d \"\n\"-device rtl8139,netdev=qtest-bn0,id=qtest-e0 \"\n\"-chardev socket,id=redirector0,path=%s,server,nowait \"\n\"-chardev socket,id=redirector1,path=%s,server,nowait \"\n\"-chardev socket,id=redirector2,path=%s,nowait \"\n\"-object filter-redirector,id=qtest-f0,netdev=qtest-bn0,\"\n\"queue=tx,outdev=redirector0 \"\n\"-object filter-redirector,id=qtest-f1,netdev=qtest-bn0,\"\n\"queue=tx,indev=redirector2 \"\n\"-object filter-redirector,id=qtest-f2,netdev=qtest-bn0,\"\n\"queue=tx,outdev=redirector1 \"\n, VAR_0[1], VAR_4, VAR_5, VAR_4);",
"qtest_start(VAR_2);",
"g_free(VAR_2);",
"VAR_1 = unix_connect(VAR_5, NULL);",
"g_assert_cmpint(VAR_1, !=, -1);",
"qmp(\"{ 'execute' : 'query-status'}\");",
"struct iovec VAR_7[] = {",
"{",
".iov_base = &size,\n.iov_len = sizeof(size),\n}, {",
".iov_base = VAR_3,\n.iov_len = sizeof(VAR_3),\n},",
"};",
"ret = iov_send(VAR_0[0], VAR_7, 2, 0, sizeof(size) + sizeof(VAR_3));",
"g_assert_cmpint(ret, ==, sizeof(VAR_3) + sizeof(size));",
"close(VAR_0[0]);",
"ret = qemu_recv(VAR_1, &len, sizeof(len), 0);",
"g_assert_cmpint(ret, ==, sizeof(len));",
"len = ntohl(len);",
"g_assert_cmpint(len, ==, sizeof(VAR_3));",
"VAR_6 = g_malloc(len);",
"ret = qemu_recv(VAR_1, VAR_6, len, 0);",
"g_assert_cmpstr(VAR_6, ==, VAR_3);",
"g_free(VAR_6);",
"close(VAR_1);",
"unlink(VAR_4);",
"unlink(VAR_5);",
"qtest_end();",
"#endif\n}"
] | [
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
] | [
[
1,
3
],
[
5,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47,
49,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
85
],
[
89
],
[
91
],
[
93,
95,
97
],
[
99,
101,
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147,
149
]
] |
1,747 | void do_divduo (void)
{
if (likely((uint64_t)T1 != 0)) {
xer_ov = 0;
T0 = (uint64_t)T0 / (uint64_t)T1;
} else {
xer_so = 1;
xer_ov = 1;
T0 = 0;
}
}
| true | qemu | 966439a67830239a6c520c5df6c55627b8153c8b | void do_divduo (void)
{
if (likely((uint64_t)T1 != 0)) {
xer_ov = 0;
T0 = (uint64_t)T0 / (uint64_t)T1;
} else {
xer_so = 1;
xer_ov = 1;
T0 = 0;
}
}
| {
"code": [
" xer_so = 1;",
" xer_so = 1;",
" xer_so = 1;",
" xer_so = 1;",
" xer_so = 1;",
" xer_so = 1;",
" xer_so = 1;",
" xer_so = 1;",
" xer_so = 1;",
" xer_so = 1;",
" xer_so = 1;",
" xer_so = 1;"
],
"line_no": [
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13
]
} | void FUNC_0 (void)
{
if (likely((uint64_t)T1 != 0)) {
xer_ov = 0;
T0 = (uint64_t)T0 / (uint64_t)T1;
} else {
xer_so = 1;
xer_ov = 1;
T0 = 0;
}
}
| [
"void FUNC_0 (void)\n{",
"if (likely((uint64_t)T1 != 0)) {",
"xer_ov = 0;",
"T0 = (uint64_t)T0 / (uint64_t)T1;",
"} else {",
"xer_so = 1;",
"xer_ov = 1;",
"T0 = 0;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
1,748 | static int megasas_dcmd_cfg_read(MegasasState *s, MegasasCmd *cmd)
{
uint8_t data[4096];
struct mfi_config_data *info;
int num_pd_disks = 0, array_offset, ld_offset;
BusChild *kid;
if (cmd->iov_size > 4096) {
return MFI_STAT_INVALID_PARAMETER;
}
QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) {
num_pd_disks++;
}
info = (struct mfi_config_data *)&data;
/*
* Array mapping:
* - One array per SCSI device
* - One logical drive per SCSI device
* spanning the entire device
*/
info->array_count = num_pd_disks;
info->array_size = sizeof(struct mfi_array) * num_pd_disks;
info->log_drv_count = num_pd_disks;
info->log_drv_size = sizeof(struct mfi_ld_config) * num_pd_disks;
info->spares_count = 0;
info->spares_size = sizeof(struct mfi_spare);
info->size = sizeof(struct mfi_config_data) + info->array_size +
info->log_drv_size;
if (info->size > 4096) {
return MFI_STAT_INVALID_PARAMETER;
}
array_offset = sizeof(struct mfi_config_data);
ld_offset = array_offset + sizeof(struct mfi_array) * num_pd_disks;
QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) {
SCSIDevice *sdev = SCSI_DEVICE(kid->child);
uint16_t sdev_id = ((sdev->id & 0xFF) << 8) | (sdev->lun & 0xFF);
struct mfi_array *array;
struct mfi_ld_config *ld;
uint64_t pd_size;
int i;
array = (struct mfi_array *)(data + array_offset);
blk_get_geometry(sdev->conf.blk, &pd_size);
array->size = cpu_to_le64(pd_size);
array->num_drives = 1;
array->array_ref = cpu_to_le16(sdev_id);
array->pd[0].ref.v.device_id = cpu_to_le16(sdev_id);
array->pd[0].ref.v.seq_num = 0;
array->pd[0].fw_state = MFI_PD_STATE_ONLINE;
array->pd[0].encl.pd = 0xFF;
array->pd[0].encl.slot = (sdev->id & 0xFF);
for (i = 1; i < MFI_MAX_ROW_SIZE; i++) {
array->pd[i].ref.v.device_id = 0xFFFF;
array->pd[i].ref.v.seq_num = 0;
array->pd[i].fw_state = MFI_PD_STATE_UNCONFIGURED_GOOD;
array->pd[i].encl.pd = 0xFF;
array->pd[i].encl.slot = 0xFF;
}
array_offset += sizeof(struct mfi_array);
ld = (struct mfi_ld_config *)(data + ld_offset);
memset(ld, 0, sizeof(struct mfi_ld_config));
ld->properties.ld.v.target_id = sdev->id;
ld->properties.default_cache_policy = MR_LD_CACHE_READ_AHEAD |
MR_LD_CACHE_READ_ADAPTIVE;
ld->properties.current_cache_policy = MR_LD_CACHE_READ_AHEAD |
MR_LD_CACHE_READ_ADAPTIVE;
ld->params.state = MFI_LD_STATE_OPTIMAL;
ld->params.stripe_size = 3;
ld->params.num_drives = 1;
ld->params.span_depth = 1;
ld->params.is_consistent = 1;
ld->span[0].start_block = 0;
ld->span[0].num_blocks = cpu_to_le64(pd_size);
ld->span[0].array_ref = cpu_to_le16(sdev_id);
ld_offset += sizeof(struct mfi_ld_config);
}
cmd->iov_size -= dma_buf_read((uint8_t *)data, info->size, &cmd->qsg);
return MFI_STAT_OK;
}
| true | qemu | d37af740730dbbb93960cd318e040372d04d6dcf | static int megasas_dcmd_cfg_read(MegasasState *s, MegasasCmd *cmd)
{
uint8_t data[4096];
struct mfi_config_data *info;
int num_pd_disks = 0, array_offset, ld_offset;
BusChild *kid;
if (cmd->iov_size > 4096) {
return MFI_STAT_INVALID_PARAMETER;
}
QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) {
num_pd_disks++;
}
info = (struct mfi_config_data *)&data;
info->array_count = num_pd_disks;
info->array_size = sizeof(struct mfi_array) * num_pd_disks;
info->log_drv_count = num_pd_disks;
info->log_drv_size = sizeof(struct mfi_ld_config) * num_pd_disks;
info->spares_count = 0;
info->spares_size = sizeof(struct mfi_spare);
info->size = sizeof(struct mfi_config_data) + info->array_size +
info->log_drv_size;
if (info->size > 4096) {
return MFI_STAT_INVALID_PARAMETER;
}
array_offset = sizeof(struct mfi_config_data);
ld_offset = array_offset + sizeof(struct mfi_array) * num_pd_disks;
QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) {
SCSIDevice *sdev = SCSI_DEVICE(kid->child);
uint16_t sdev_id = ((sdev->id & 0xFF) << 8) | (sdev->lun & 0xFF);
struct mfi_array *array;
struct mfi_ld_config *ld;
uint64_t pd_size;
int i;
array = (struct mfi_array *)(data + array_offset);
blk_get_geometry(sdev->conf.blk, &pd_size);
array->size = cpu_to_le64(pd_size);
array->num_drives = 1;
array->array_ref = cpu_to_le16(sdev_id);
array->pd[0].ref.v.device_id = cpu_to_le16(sdev_id);
array->pd[0].ref.v.seq_num = 0;
array->pd[0].fw_state = MFI_PD_STATE_ONLINE;
array->pd[0].encl.pd = 0xFF;
array->pd[0].encl.slot = (sdev->id & 0xFF);
for (i = 1; i < MFI_MAX_ROW_SIZE; i++) {
array->pd[i].ref.v.device_id = 0xFFFF;
array->pd[i].ref.v.seq_num = 0;
array->pd[i].fw_state = MFI_PD_STATE_UNCONFIGURED_GOOD;
array->pd[i].encl.pd = 0xFF;
array->pd[i].encl.slot = 0xFF;
}
array_offset += sizeof(struct mfi_array);
ld = (struct mfi_ld_config *)(data + ld_offset);
memset(ld, 0, sizeof(struct mfi_ld_config));
ld->properties.ld.v.target_id = sdev->id;
ld->properties.default_cache_policy = MR_LD_CACHE_READ_AHEAD |
MR_LD_CACHE_READ_ADAPTIVE;
ld->properties.current_cache_policy = MR_LD_CACHE_READ_AHEAD |
MR_LD_CACHE_READ_ADAPTIVE;
ld->params.state = MFI_LD_STATE_OPTIMAL;
ld->params.stripe_size = 3;
ld->params.num_drives = 1;
ld->params.span_depth = 1;
ld->params.is_consistent = 1;
ld->span[0].start_block = 0;
ld->span[0].num_blocks = cpu_to_le64(pd_size);
ld->span[0].array_ref = cpu_to_le16(sdev_id);
ld_offset += sizeof(struct mfi_ld_config);
}
cmd->iov_size -= dma_buf_read((uint8_t *)data, info->size, &cmd->qsg);
return MFI_STAT_OK;
}
| {
"code": [
" uint8_t data[4096];"
],
"line_no": [
5
]
} | static int FUNC_0(MegasasState *VAR_0, MegasasCmd *VAR_1)
{
uint8_t data[4096];
struct mfi_config_data *VAR_2;
int VAR_3 = 0, VAR_4, VAR_5;
BusChild *kid;
if (VAR_1->iov_size > 4096) {
return MFI_STAT_INVALID_PARAMETER;
}
QTAILQ_FOREACH(kid, &VAR_0->bus.qbus.children, sibling) {
VAR_3++;
}
VAR_2 = (struct mfi_config_data *)&data;
VAR_2->array_count = VAR_3;
VAR_2->array_size = sizeof(struct mfi_array) * VAR_3;
VAR_2->log_drv_count = VAR_3;
VAR_2->log_drv_size = sizeof(struct mfi_ld_config) * VAR_3;
VAR_2->spares_count = 0;
VAR_2->spares_size = sizeof(struct mfi_spare);
VAR_2->size = sizeof(struct mfi_config_data) + VAR_2->array_size +
VAR_2->log_drv_size;
if (VAR_2->size > 4096) {
return MFI_STAT_INVALID_PARAMETER;
}
VAR_4 = sizeof(struct mfi_config_data);
VAR_5 = VAR_4 + sizeof(struct mfi_array) * VAR_3;
QTAILQ_FOREACH(kid, &VAR_0->bus.qbus.children, sibling) {
SCSIDevice *sdev = SCSI_DEVICE(kid->child);
uint16_t sdev_id = ((sdev->id & 0xFF) << 8) | (sdev->lun & 0xFF);
struct mfi_array *array;
struct mfi_ld_config *ld;
uint64_t pd_size;
int i;
array = (struct mfi_array *)(data + VAR_4);
blk_get_geometry(sdev->conf.blk, &pd_size);
array->size = cpu_to_le64(pd_size);
array->num_drives = 1;
array->array_ref = cpu_to_le16(sdev_id);
array->pd[0].ref.v.device_id = cpu_to_le16(sdev_id);
array->pd[0].ref.v.seq_num = 0;
array->pd[0].fw_state = MFI_PD_STATE_ONLINE;
array->pd[0].encl.pd = 0xFF;
array->pd[0].encl.slot = (sdev->id & 0xFF);
for (i = 1; i < MFI_MAX_ROW_SIZE; i++) {
array->pd[i].ref.v.device_id = 0xFFFF;
array->pd[i].ref.v.seq_num = 0;
array->pd[i].fw_state = MFI_PD_STATE_UNCONFIGURED_GOOD;
array->pd[i].encl.pd = 0xFF;
array->pd[i].encl.slot = 0xFF;
}
VAR_4 += sizeof(struct mfi_array);
ld = (struct mfi_ld_config *)(data + VAR_5);
memset(ld, 0, sizeof(struct mfi_ld_config));
ld->properties.ld.v.target_id = sdev->id;
ld->properties.default_cache_policy = MR_LD_CACHE_READ_AHEAD |
MR_LD_CACHE_READ_ADAPTIVE;
ld->properties.current_cache_policy = MR_LD_CACHE_READ_AHEAD |
MR_LD_CACHE_READ_ADAPTIVE;
ld->params.state = MFI_LD_STATE_OPTIMAL;
ld->params.stripe_size = 3;
ld->params.num_drives = 1;
ld->params.span_depth = 1;
ld->params.is_consistent = 1;
ld->span[0].start_block = 0;
ld->span[0].num_blocks = cpu_to_le64(pd_size);
ld->span[0].array_ref = cpu_to_le16(sdev_id);
VAR_5 += sizeof(struct mfi_ld_config);
}
VAR_1->iov_size -= dma_buf_read((uint8_t *)data, VAR_2->size, &VAR_1->qsg);
return MFI_STAT_OK;
}
| [
"static int FUNC_0(MegasasState *VAR_0, MegasasCmd *VAR_1)\n{",
"uint8_t data[4096];",
"struct mfi_config_data *VAR_2;",
"int VAR_3 = 0, VAR_4, VAR_5;",
"BusChild *kid;",
"if (VAR_1->iov_size > 4096) {",
"return MFI_STAT_INVALID_PARAMETER;",
"}",
"QTAILQ_FOREACH(kid, &VAR_0->bus.qbus.children, sibling) {",
"VAR_3++;",
"}",
"VAR_2 = (struct mfi_config_data *)&data;",
"VAR_2->array_count = VAR_3;",
"VAR_2->array_size = sizeof(struct mfi_array) * VAR_3;",
"VAR_2->log_drv_count = VAR_3;",
"VAR_2->log_drv_size = sizeof(struct mfi_ld_config) * VAR_3;",
"VAR_2->spares_count = 0;",
"VAR_2->spares_size = sizeof(struct mfi_spare);",
"VAR_2->size = sizeof(struct mfi_config_data) + VAR_2->array_size +\nVAR_2->log_drv_size;",
"if (VAR_2->size > 4096) {",
"return MFI_STAT_INVALID_PARAMETER;",
"}",
"VAR_4 = sizeof(struct mfi_config_data);",
"VAR_5 = VAR_4 + sizeof(struct mfi_array) * VAR_3;",
"QTAILQ_FOREACH(kid, &VAR_0->bus.qbus.children, sibling) {",
"SCSIDevice *sdev = SCSI_DEVICE(kid->child);",
"uint16_t sdev_id = ((sdev->id & 0xFF) << 8) | (sdev->lun & 0xFF);",
"struct mfi_array *array;",
"struct mfi_ld_config *ld;",
"uint64_t pd_size;",
"int i;",
"array = (struct mfi_array *)(data + VAR_4);",
"blk_get_geometry(sdev->conf.blk, &pd_size);",
"array->size = cpu_to_le64(pd_size);",
"array->num_drives = 1;",
"array->array_ref = cpu_to_le16(sdev_id);",
"array->pd[0].ref.v.device_id = cpu_to_le16(sdev_id);",
"array->pd[0].ref.v.seq_num = 0;",
"array->pd[0].fw_state = MFI_PD_STATE_ONLINE;",
"array->pd[0].encl.pd = 0xFF;",
"array->pd[0].encl.slot = (sdev->id & 0xFF);",
"for (i = 1; i < MFI_MAX_ROW_SIZE; i++) {",
"array->pd[i].ref.v.device_id = 0xFFFF;",
"array->pd[i].ref.v.seq_num = 0;",
"array->pd[i].fw_state = MFI_PD_STATE_UNCONFIGURED_GOOD;",
"array->pd[i].encl.pd = 0xFF;",
"array->pd[i].encl.slot = 0xFF;",
"}",
"VAR_4 += sizeof(struct mfi_array);",
"ld = (struct mfi_ld_config *)(data + VAR_5);",
"memset(ld, 0, sizeof(struct mfi_ld_config));",
"ld->properties.ld.v.target_id = sdev->id;",
"ld->properties.default_cache_policy = MR_LD_CACHE_READ_AHEAD |\nMR_LD_CACHE_READ_ADAPTIVE;",
"ld->properties.current_cache_policy = MR_LD_CACHE_READ_AHEAD |\nMR_LD_CACHE_READ_ADAPTIVE;",
"ld->params.state = MFI_LD_STATE_OPTIMAL;",
"ld->params.stripe_size = 3;",
"ld->params.num_drives = 1;",
"ld->params.span_depth = 1;",
"ld->params.is_consistent = 1;",
"ld->span[0].start_block = 0;",
"ld->span[0].num_blocks = cpu_to_le64(pd_size);",
"ld->span[0].array_ref = cpu_to_le16(sdev_id);",
"VAR_5 += sizeof(struct mfi_ld_config);",
"}",
"VAR_1->iov_size -= dma_buf_read((uint8_t *)data, VAR_2->size, &VAR_1->qsg);",
"return MFI_STAT_OK;",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
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
],
[
161
],
[
163
],
[
165
]
] |
1,749 | static void lsi_do_msgout(LSIState *s)
{
uint8_t msg;
int len;
uint32_t current_tag;
SCSIDevice *current_dev;
lsi_request *p, *p_next;
int id;
if (s->current) {
current_tag = s->current->tag;
} else {
current_tag = s->select_tag;
}
id = (current_tag >> 8) & 0xf;
current_dev = s->bus.devs[id];
DPRINTF("MSG out len=%d\n", s->dbc);
while (s->dbc) {
msg = lsi_get_msgbyte(s);
s->sfbr = msg;
switch (msg) {
case 0x04:
DPRINTF("MSG: Disconnect\n");
lsi_disconnect(s);
break;
case 0x08:
DPRINTF("MSG: No Operation\n");
lsi_set_phase(s, PHASE_CMD);
break;
case 0x01:
len = lsi_get_msgbyte(s);
msg = lsi_get_msgbyte(s);
(void)len; /* avoid a warning about unused variable*/
DPRINTF("Extended message 0x%x (len %d)\n", msg, len);
switch (msg) {
case 1:
DPRINTF("SDTR (ignored)\n");
lsi_skip_msgbytes(s, 2);
break;
case 3:
DPRINTF("WDTR (ignored)\n");
lsi_skip_msgbytes(s, 1);
break;
default:
goto bad;
}
break;
case 0x20: /* SIMPLE queue */
s->select_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID;
DPRINTF("SIMPLE queue tag=0x%x\n", s->select_tag & 0xff);
break;
case 0x21: /* HEAD of queue */
BADF("HEAD queue not implemented\n");
s->select_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID;
break;
case 0x22: /* ORDERED queue */
BADF("ORDERED queue not implemented\n");
s->select_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID;
break;
case 0x0d:
/* The ABORT TAG message clears the current I/O process only. */
DPRINTF("MSG: ABORT TAG tag=0x%x\n", current_tag);
current_dev->info->cancel_io(current_dev, current_tag);
lsi_disconnect(s);
break;
case 0x06:
case 0x0e:
case 0x0c:
/* The ABORT message clears all I/O processes for the selecting
initiator on the specified logical unit of the target. */
if (msg == 0x06) {
DPRINTF("MSG: ABORT tag=0x%x\n", current_tag);
}
/* The CLEAR QUEUE message clears all I/O processes for all
initiators on the specified logical unit of the target. */
if (msg == 0x0e) {
DPRINTF("MSG: CLEAR QUEUE tag=0x%x\n", current_tag);
}
/* The BUS DEVICE RESET message clears all I/O processes for all
initiators on all logical units of the target. */
if (msg == 0x0c) {
DPRINTF("MSG: BUS DEVICE RESET tag=0x%x\n", current_tag);
}
/* clear the current I/O process */
current_dev->info->cancel_io(current_dev, current_tag);
/* As the current implemented devices scsi_disk and scsi_generic
only support one LUN, we don't need to keep track of LUNs.
Clearing I/O processes for other initiators could be possible
for scsi_generic by sending a SG_SCSI_RESET to the /dev/sgX
device, but this is currently not implemented (and seems not
to be really necessary). So let's simply clear all queued
commands for the current device: */
id = current_tag & 0x0000ff00;
QTAILQ_FOREACH_SAFE(p, &s->queue, next, p_next) {
if ((p->tag & 0x0000ff00) == id) {
current_dev->info->cancel_io(current_dev, p->tag);
QTAILQ_REMOVE(&s->queue, p, next);
}
}
lsi_disconnect(s);
break;
default:
if ((msg & 0x80) == 0) {
goto bad;
}
s->current_lun = msg & 7;
DPRINTF("Select LUN %d\n", s->current_lun);
lsi_set_phase(s, PHASE_CMD);
break;
}
}
return;
bad:
BADF("Unimplemented message 0x%02x\n", msg);
lsi_set_phase(s, PHASE_MI);
lsi_add_msg_byte(s, 7); /* MESSAGE REJECT */
s->msg_action = 0;
}
| true | qemu | 5c6c0e513600ba57c3e73b7151d3c0664438f7b5 | static void lsi_do_msgout(LSIState *s)
{
uint8_t msg;
int len;
uint32_t current_tag;
SCSIDevice *current_dev;
lsi_request *p, *p_next;
int id;
if (s->current) {
current_tag = s->current->tag;
} else {
current_tag = s->select_tag;
}
id = (current_tag >> 8) & 0xf;
current_dev = s->bus.devs[id];
DPRINTF("MSG out len=%d\n", s->dbc);
while (s->dbc) {
msg = lsi_get_msgbyte(s);
s->sfbr = msg;
switch (msg) {
case 0x04:
DPRINTF("MSG: Disconnect\n");
lsi_disconnect(s);
break;
case 0x08:
DPRINTF("MSG: No Operation\n");
lsi_set_phase(s, PHASE_CMD);
break;
case 0x01:
len = lsi_get_msgbyte(s);
msg = lsi_get_msgbyte(s);
(void)len;
DPRINTF("Extended message 0x%x (len %d)\n", msg, len);
switch (msg) {
case 1:
DPRINTF("SDTR (ignored)\n");
lsi_skip_msgbytes(s, 2);
break;
case 3:
DPRINTF("WDTR (ignored)\n");
lsi_skip_msgbytes(s, 1);
break;
default:
goto bad;
}
break;
case 0x20:
s->select_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID;
DPRINTF("SIMPLE queue tag=0x%x\n", s->select_tag & 0xff);
break;
case 0x21:
BADF("HEAD queue not implemented\n");
s->select_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID;
break;
case 0x22:
BADF("ORDERED queue not implemented\n");
s->select_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID;
break;
case 0x0d:
DPRINTF("MSG: ABORT TAG tag=0x%x\n", current_tag);
current_dev->info->cancel_io(current_dev, current_tag);
lsi_disconnect(s);
break;
case 0x06:
case 0x0e:
case 0x0c:
if (msg == 0x06) {
DPRINTF("MSG: ABORT tag=0x%x\n", current_tag);
}
if (msg == 0x0e) {
DPRINTF("MSG: CLEAR QUEUE tag=0x%x\n", current_tag);
}
if (msg == 0x0c) {
DPRINTF("MSG: BUS DEVICE RESET tag=0x%x\n", current_tag);
}
current_dev->info->cancel_io(current_dev, current_tag);
id = current_tag & 0x0000ff00;
QTAILQ_FOREACH_SAFE(p, &s->queue, next, p_next) {
if ((p->tag & 0x0000ff00) == id) {
current_dev->info->cancel_io(current_dev, p->tag);
QTAILQ_REMOVE(&s->queue, p, next);
}
}
lsi_disconnect(s);
break;
default:
if ((msg & 0x80) == 0) {
goto bad;
}
s->current_lun = msg & 7;
DPRINTF("Select LUN %d\n", s->current_lun);
lsi_set_phase(s, PHASE_CMD);
break;
}
}
return;
bad:
BADF("Unimplemented message 0x%02x\n", msg);
lsi_set_phase(s, PHASE_MI);
lsi_add_msg_byte(s, 7);
s->msg_action = 0;
}
| {
"code": [
" lsi_request *p, *p_next;",
" current_dev->info->cancel_io(current_dev, current_tag);",
" current_dev->info->cancel_io(current_dev, current_tag);",
" current_dev->info->cancel_io(current_dev, p->tag);"
],
"line_no": [
13,
129,
129,
199
]
} | static void FUNC_0(LSIState *VAR_0)
{
uint8_t msg;
int VAR_1;
uint32_t current_tag;
SCSIDevice *current_dev;
lsi_request *p, *p_next;
int VAR_2;
if (VAR_0->current) {
current_tag = VAR_0->current->tag;
} else {
current_tag = VAR_0->select_tag;
}
VAR_2 = (current_tag >> 8) & 0xf;
current_dev = VAR_0->bus.devs[VAR_2];
DPRINTF("MSG out VAR_1=%d\n", VAR_0->dbc);
while (VAR_0->dbc) {
msg = lsi_get_msgbyte(VAR_0);
VAR_0->sfbr = msg;
switch (msg) {
case 0x04:
DPRINTF("MSG: Disconnect\n");
lsi_disconnect(VAR_0);
break;
case 0x08:
DPRINTF("MSG: No Operation\n");
lsi_set_phase(VAR_0, PHASE_CMD);
break;
case 0x01:
VAR_1 = lsi_get_msgbyte(VAR_0);
msg = lsi_get_msgbyte(VAR_0);
(void)VAR_1;
DPRINTF("Extended message 0x%x (VAR_1 %d)\n", msg, VAR_1);
switch (msg) {
case 1:
DPRINTF("SDTR (ignored)\n");
lsi_skip_msgbytes(VAR_0, 2);
break;
case 3:
DPRINTF("WDTR (ignored)\n");
lsi_skip_msgbytes(VAR_0, 1);
break;
default:
goto bad;
}
break;
case 0x20:
VAR_0->select_tag |= lsi_get_msgbyte(VAR_0) | LSI_TAG_VALID;
DPRINTF("SIMPLE queue tag=0x%x\n", VAR_0->select_tag & 0xff);
break;
case 0x21:
BADF("HEAD queue not implemented\n");
VAR_0->select_tag |= lsi_get_msgbyte(VAR_0) | LSI_TAG_VALID;
break;
case 0x22:
BADF("ORDERED queue not implemented\n");
VAR_0->select_tag |= lsi_get_msgbyte(VAR_0) | LSI_TAG_VALID;
break;
case 0x0d:
DPRINTF("MSG: ABORT TAG tag=0x%x\n", current_tag);
current_dev->info->cancel_io(current_dev, current_tag);
lsi_disconnect(VAR_0);
break;
case 0x06:
case 0x0e:
case 0x0c:
if (msg == 0x06) {
DPRINTF("MSG: ABORT tag=0x%x\n", current_tag);
}
if (msg == 0x0e) {
DPRINTF("MSG: CLEAR QUEUE tag=0x%x\n", current_tag);
}
if (msg == 0x0c) {
DPRINTF("MSG: BUS DEVICE RESET tag=0x%x\n", current_tag);
}
current_dev->info->cancel_io(current_dev, current_tag);
VAR_2 = current_tag & 0x0000ff00;
QTAILQ_FOREACH_SAFE(p, &VAR_0->queue, next, p_next) {
if ((p->tag & 0x0000ff00) == VAR_2) {
current_dev->info->cancel_io(current_dev, p->tag);
QTAILQ_REMOVE(&VAR_0->queue, p, next);
}
}
lsi_disconnect(VAR_0);
break;
default:
if ((msg & 0x80) == 0) {
goto bad;
}
VAR_0->current_lun = msg & 7;
DPRINTF("Select LUN %d\n", VAR_0->current_lun);
lsi_set_phase(VAR_0, PHASE_CMD);
break;
}
}
return;
bad:
BADF("Unimplemented message 0x%02x\n", msg);
lsi_set_phase(VAR_0, PHASE_MI);
lsi_add_msg_byte(VAR_0, 7);
VAR_0->msg_action = 0;
}
| [
"static void FUNC_0(LSIState *VAR_0)\n{",
"uint8_t msg;",
"int VAR_1;",
"uint32_t current_tag;",
"SCSIDevice *current_dev;",
"lsi_request *p, *p_next;",
"int VAR_2;",
"if (VAR_0->current) {",
"current_tag = VAR_0->current->tag;",
"} else {",
"current_tag = VAR_0->select_tag;",
"}",
"VAR_2 = (current_tag >> 8) & 0xf;",
"current_dev = VAR_0->bus.devs[VAR_2];",
"DPRINTF(\"MSG out VAR_1=%d\\n\", VAR_0->dbc);",
"while (VAR_0->dbc) {",
"msg = lsi_get_msgbyte(VAR_0);",
"VAR_0->sfbr = msg;",
"switch (msg) {",
"case 0x04:\nDPRINTF(\"MSG: Disconnect\\n\");",
"lsi_disconnect(VAR_0);",
"break;",
"case 0x08:\nDPRINTF(\"MSG: No Operation\\n\");",
"lsi_set_phase(VAR_0, PHASE_CMD);",
"break;",
"case 0x01:\nVAR_1 = lsi_get_msgbyte(VAR_0);",
"msg = lsi_get_msgbyte(VAR_0);",
"(void)VAR_1;",
"DPRINTF(\"Extended message 0x%x (VAR_1 %d)\\n\", msg, VAR_1);",
"switch (msg) {",
"case 1:\nDPRINTF(\"SDTR (ignored)\\n\");",
"lsi_skip_msgbytes(VAR_0, 2);",
"break;",
"case 3:\nDPRINTF(\"WDTR (ignored)\\n\");",
"lsi_skip_msgbytes(VAR_0, 1);",
"break;",
"default:\ngoto bad;",
"}",
"break;",
"case 0x20:\nVAR_0->select_tag |= lsi_get_msgbyte(VAR_0) | LSI_TAG_VALID;",
"DPRINTF(\"SIMPLE queue tag=0x%x\\n\", VAR_0->select_tag & 0xff);",
"break;",
"case 0x21:\nBADF(\"HEAD queue not implemented\\n\");",
"VAR_0->select_tag |= lsi_get_msgbyte(VAR_0) | LSI_TAG_VALID;",
"break;",
"case 0x22:\nBADF(\"ORDERED queue not implemented\\n\");",
"VAR_0->select_tag |= lsi_get_msgbyte(VAR_0) | LSI_TAG_VALID;",
"break;",
"case 0x0d:\nDPRINTF(\"MSG: ABORT TAG tag=0x%x\\n\", current_tag);",
"current_dev->info->cancel_io(current_dev, current_tag);",
"lsi_disconnect(VAR_0);",
"break;",
"case 0x06:\ncase 0x0e:\ncase 0x0c:\nif (msg == 0x06) {",
"DPRINTF(\"MSG: ABORT tag=0x%x\\n\", current_tag);",
"}",
"if (msg == 0x0e) {",
"DPRINTF(\"MSG: CLEAR QUEUE tag=0x%x\\n\", current_tag);",
"}",
"if (msg == 0x0c) {",
"DPRINTF(\"MSG: BUS DEVICE RESET tag=0x%x\\n\", current_tag);",
"}",
"current_dev->info->cancel_io(current_dev, current_tag);",
"VAR_2 = current_tag & 0x0000ff00;",
"QTAILQ_FOREACH_SAFE(p, &VAR_0->queue, next, p_next) {",
"if ((p->tag & 0x0000ff00) == VAR_2) {",
"current_dev->info->cancel_io(current_dev, p->tag);",
"QTAILQ_REMOVE(&VAR_0->queue, p, next);",
"}",
"}",
"lsi_disconnect(VAR_0);",
"break;",
"default:\nif ((msg & 0x80) == 0) {",
"goto bad;",
"}",
"VAR_0->current_lun = msg & 7;",
"DPRINTF(\"Select LUN %d\\n\", VAR_0->current_lun);",
"lsi_set_phase(VAR_0, PHASE_CMD);",
"break;",
"}",
"}",
"return;",
"bad:\nBADF(\"Unimplemented message 0x%02x\\n\", msg);",
"lsi_set_phase(VAR_0, PHASE_MI);",
"lsi_add_msg_byte(VAR_0, 7);",
"VAR_0->msg_action = 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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
83,
85
],
[
87
],
[
89
],
[
91,
93
],
[
95
],
[
97
],
[
99,
101
],
[
103
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
115,
117
],
[
119
],
[
121
],
[
123,
127
],
[
129
],
[
131
],
[
133
],
[
135,
137,
139,
145
],
[
147
],
[
149
],
[
155
],
[
157
],
[
159
],
[
165
],
[
167
],
[
169
],
[
175
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
209
],
[
211
],
[
213,
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235,
237
],
[
239
],
[
241
],
[
243
],
[
245
]
] |
1,751 | static void local_mapped_file_attr(FsContext *ctx, const char *path,
struct stat *stbuf)
{
FILE *fp;
char buf[ATTR_MAX];
char attr_path[PATH_MAX];
local_mapped_attr_path(ctx, path, attr_path);
fp = local_fopen(attr_path, "r");
if (!fp) {
return;
}
memset(buf, 0, ATTR_MAX);
while (fgets(buf, ATTR_MAX, fp)) {
if (!strncmp(buf, "virtfs.uid", 10)) {
stbuf->st_uid = atoi(buf+11);
} else if (!strncmp(buf, "virtfs.gid", 10)) {
stbuf->st_gid = atoi(buf+11);
} else if (!strncmp(buf, "virtfs.mode", 11)) {
stbuf->st_mode = atoi(buf+12);
} else if (!strncmp(buf, "virtfs.rdev", 11)) {
stbuf->st_rdev = atoi(buf+12);
}
memset(buf, 0, ATTR_MAX);
}
fclose(fp);
}
| false | qemu | 4fa4ce7107c6ec432f185307158c5df91ce54308 | static void local_mapped_file_attr(FsContext *ctx, const char *path,
struct stat *stbuf)
{
FILE *fp;
char buf[ATTR_MAX];
char attr_path[PATH_MAX];
local_mapped_attr_path(ctx, path, attr_path);
fp = local_fopen(attr_path, "r");
if (!fp) {
return;
}
memset(buf, 0, ATTR_MAX);
while (fgets(buf, ATTR_MAX, fp)) {
if (!strncmp(buf, "virtfs.uid", 10)) {
stbuf->st_uid = atoi(buf+11);
} else if (!strncmp(buf, "virtfs.gid", 10)) {
stbuf->st_gid = atoi(buf+11);
} else if (!strncmp(buf, "virtfs.mode", 11)) {
stbuf->st_mode = atoi(buf+12);
} else if (!strncmp(buf, "virtfs.rdev", 11)) {
stbuf->st_rdev = atoi(buf+12);
}
memset(buf, 0, ATTR_MAX);
}
fclose(fp);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(FsContext *VAR_0, const char *VAR_1,
struct stat *VAR_2)
{
FILE *fp;
char VAR_3[ATTR_MAX];
char VAR_4[PATH_MAX];
local_mapped_attr_path(VAR_0, VAR_1, VAR_4);
fp = local_fopen(VAR_4, "r");
if (!fp) {
return;
}
memset(VAR_3, 0, ATTR_MAX);
while (fgets(VAR_3, ATTR_MAX, fp)) {
if (!strncmp(VAR_3, "virtfs.uid", 10)) {
VAR_2->st_uid = atoi(VAR_3+11);
} else if (!strncmp(VAR_3, "virtfs.gid", 10)) {
VAR_2->st_gid = atoi(VAR_3+11);
} else if (!strncmp(VAR_3, "virtfs.mode", 11)) {
VAR_2->st_mode = atoi(VAR_3+12);
} else if (!strncmp(VAR_3, "virtfs.rdev", 11)) {
VAR_2->st_rdev = atoi(VAR_3+12);
}
memset(VAR_3, 0, ATTR_MAX);
}
fclose(fp);
}
| [
"static void FUNC_0(FsContext *VAR_0, const char *VAR_1,\nstruct stat *VAR_2)\n{",
"FILE *fp;",
"char VAR_3[ATTR_MAX];",
"char VAR_4[PATH_MAX];",
"local_mapped_attr_path(VAR_0, VAR_1, VAR_4);",
"fp = local_fopen(VAR_4, \"r\");",
"if (!fp) {",
"return;",
"}",
"memset(VAR_3, 0, ATTR_MAX);",
"while (fgets(VAR_3, ATTR_MAX, fp)) {",
"if (!strncmp(VAR_3, \"virtfs.uid\", 10)) {",
"VAR_2->st_uid = atoi(VAR_3+11);",
"} else if (!strncmp(VAR_3, \"virtfs.gid\", 10)) {",
"VAR_2->st_gid = atoi(VAR_3+11);",
"} else if (!strncmp(VAR_3, \"virtfs.mode\", 11)) {",
"VAR_2->st_mode = atoi(VAR_3+12);",
"} else if (!strncmp(VAR_3, \"virtfs.rdev\", 11)) {",
"VAR_2->st_rdev = atoi(VAR_3+12);",
"}",
"memset(VAR_3, 0, ATTR_MAX);",
"}",
"fclose(fp);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
]
] |
1,752 | static int qemu_rbd_parsename(const char *filename,
char *pool, int pool_len,
char *snap, int snap_len,
char *name, int name_len,
char *conf, int conf_len,
Error **errp)
{
const char *start;
char *p, *buf;
int ret = 0;
char *found_str;
Error *local_err = NULL;
if (!strstart(filename, "rbd:", &start)) {
error_setg(errp, "File name must start with 'rbd:'");
return -EINVAL;
}
buf = g_strdup(start);
p = buf;
*snap = '\0';
*conf = '\0';
found_str = qemu_rbd_next_tok(pool_len, p,
'/', "pool name", &p, &local_err);
if (local_err) {
goto done;
}
if (!p) {
ret = -EINVAL;
error_setg(errp, "Pool name is required");
goto done;
}
qemu_rbd_unescape(found_str);
g_strlcpy(pool, found_str, pool_len);
if (strchr(p, '@')) {
found_str = qemu_rbd_next_tok(name_len, p,
'@', "object name", &p, &local_err);
if (local_err) {
goto done;
}
qemu_rbd_unescape(found_str);
g_strlcpy(name, found_str, name_len);
found_str = qemu_rbd_next_tok(snap_len, p,
':', "snap name", &p, &local_err);
if (local_err) {
goto done;
}
qemu_rbd_unescape(found_str);
g_strlcpy(snap, found_str, snap_len);
} else {
found_str = qemu_rbd_next_tok(name_len, p,
':', "object name", &p, &local_err);
if (local_err) {
goto done;
}
qemu_rbd_unescape(found_str);
g_strlcpy(name, found_str, name_len);
}
if (!p) {
goto done;
}
found_str = qemu_rbd_next_tok(conf_len, p,
'\0', "configuration", &p, &local_err);
if (local_err) {
goto done;
}
g_strlcpy(conf, found_str, conf_len);
done:
if (local_err) {
ret = -EINVAL;
error_propagate(errp, local_err);
}
g_free(buf);
return ret;
}
| false | qemu | c7cacb3e7a2e9fdf929c993b98268e4179147cbb | static int qemu_rbd_parsename(const char *filename,
char *pool, int pool_len,
char *snap, int snap_len,
char *name, int name_len,
char *conf, int conf_len,
Error **errp)
{
const char *start;
char *p, *buf;
int ret = 0;
char *found_str;
Error *local_err = NULL;
if (!strstart(filename, "rbd:", &start)) {
error_setg(errp, "File name must start with 'rbd:'");
return -EINVAL;
}
buf = g_strdup(start);
p = buf;
*snap = '\0';
*conf = '\0';
found_str = qemu_rbd_next_tok(pool_len, p,
'/', "pool name", &p, &local_err);
if (local_err) {
goto done;
}
if (!p) {
ret = -EINVAL;
error_setg(errp, "Pool name is required");
goto done;
}
qemu_rbd_unescape(found_str);
g_strlcpy(pool, found_str, pool_len);
if (strchr(p, '@')) {
found_str = qemu_rbd_next_tok(name_len, p,
'@', "object name", &p, &local_err);
if (local_err) {
goto done;
}
qemu_rbd_unescape(found_str);
g_strlcpy(name, found_str, name_len);
found_str = qemu_rbd_next_tok(snap_len, p,
':', "snap name", &p, &local_err);
if (local_err) {
goto done;
}
qemu_rbd_unescape(found_str);
g_strlcpy(snap, found_str, snap_len);
} else {
found_str = qemu_rbd_next_tok(name_len, p,
':', "object name", &p, &local_err);
if (local_err) {
goto done;
}
qemu_rbd_unescape(found_str);
g_strlcpy(name, found_str, name_len);
}
if (!p) {
goto done;
}
found_str = qemu_rbd_next_tok(conf_len, p,
'\0', "configuration", &p, &local_err);
if (local_err) {
goto done;
}
g_strlcpy(conf, found_str, conf_len);
done:
if (local_err) {
ret = -EINVAL;
error_propagate(errp, local_err);
}
g_free(buf);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(const char *VAR_0,
char *VAR_1, int VAR_2,
char *VAR_3, int VAR_4,
char *VAR_5, int VAR_6,
char *VAR_7, int VAR_8,
Error **VAR_9)
{
const char *VAR_10;
char *VAR_11, *VAR_12;
int VAR_13 = 0;
char *VAR_14;
Error *local_err = NULL;
if (!strstart(VAR_0, "rbd:", &VAR_10)) {
error_setg(VAR_9, "File VAR_5 must VAR_10 with 'rbd:'");
return -EINVAL;
}
VAR_12 = g_strdup(VAR_10);
VAR_11 = VAR_12;
*VAR_3 = '\0';
*VAR_7 = '\0';
VAR_14 = qemu_rbd_next_tok(VAR_2, VAR_11,
'/', "VAR_1 VAR_5", &VAR_11, &local_err);
if (local_err) {
goto done;
}
if (!VAR_11) {
VAR_13 = -EINVAL;
error_setg(VAR_9, "Pool VAR_5 is required");
goto done;
}
qemu_rbd_unescape(VAR_14);
g_strlcpy(VAR_1, VAR_14, VAR_2);
if (strchr(VAR_11, '@')) {
VAR_14 = qemu_rbd_next_tok(VAR_6, VAR_11,
'@', "object VAR_5", &VAR_11, &local_err);
if (local_err) {
goto done;
}
qemu_rbd_unescape(VAR_14);
g_strlcpy(VAR_5, VAR_14, VAR_6);
VAR_14 = qemu_rbd_next_tok(VAR_4, VAR_11,
':', "VAR_3 VAR_5", &VAR_11, &local_err);
if (local_err) {
goto done;
}
qemu_rbd_unescape(VAR_14);
g_strlcpy(VAR_3, VAR_14, VAR_4);
} else {
VAR_14 = qemu_rbd_next_tok(VAR_6, VAR_11,
':', "object VAR_5", &VAR_11, &local_err);
if (local_err) {
goto done;
}
qemu_rbd_unescape(VAR_14);
g_strlcpy(VAR_5, VAR_14, VAR_6);
}
if (!VAR_11) {
goto done;
}
VAR_14 = qemu_rbd_next_tok(VAR_8, VAR_11,
'\0', "configuration", &VAR_11, &local_err);
if (local_err) {
goto done;
}
g_strlcpy(VAR_7, VAR_14, VAR_8);
done:
if (local_err) {
VAR_13 = -EINVAL;
error_propagate(VAR_9, local_err);
}
g_free(VAR_12);
return VAR_13;
}
| [
"static int FUNC_0(const char *VAR_0,\nchar *VAR_1, int VAR_2,\nchar *VAR_3, int VAR_4,\nchar *VAR_5, int VAR_6,\nchar *VAR_7, int VAR_8,\nError **VAR_9)\n{",
"const char *VAR_10;",
"char *VAR_11, *VAR_12;",
"int VAR_13 = 0;",
"char *VAR_14;",
"Error *local_err = NULL;",
"if (!strstart(VAR_0, \"rbd:\", &VAR_10)) {",
"error_setg(VAR_9, \"File VAR_5 must VAR_10 with 'rbd:'\");",
"return -EINVAL;",
"}",
"VAR_12 = g_strdup(VAR_10);",
"VAR_11 = VAR_12;",
"*VAR_3 = '\\0';",
"*VAR_7 = '\\0';",
"VAR_14 = qemu_rbd_next_tok(VAR_2, VAR_11,\n'/', \"VAR_1 VAR_5\", &VAR_11, &local_err);",
"if (local_err) {",
"goto done;",
"}",
"if (!VAR_11) {",
"VAR_13 = -EINVAL;",
"error_setg(VAR_9, \"Pool VAR_5 is required\");",
"goto done;",
"}",
"qemu_rbd_unescape(VAR_14);",
"g_strlcpy(VAR_1, VAR_14, VAR_2);",
"if (strchr(VAR_11, '@')) {",
"VAR_14 = qemu_rbd_next_tok(VAR_6, VAR_11,\n'@', \"object VAR_5\", &VAR_11, &local_err);",
"if (local_err) {",
"goto done;",
"}",
"qemu_rbd_unescape(VAR_14);",
"g_strlcpy(VAR_5, VAR_14, VAR_6);",
"VAR_14 = qemu_rbd_next_tok(VAR_4, VAR_11,\n':', \"VAR_3 VAR_5\", &VAR_11, &local_err);",
"if (local_err) {",
"goto done;",
"}",
"qemu_rbd_unescape(VAR_14);",
"g_strlcpy(VAR_3, VAR_14, VAR_4);",
"} else {",
"VAR_14 = qemu_rbd_next_tok(VAR_6, VAR_11,\n':', \"object VAR_5\", &VAR_11, &local_err);",
"if (local_err) {",
"goto done;",
"}",
"qemu_rbd_unescape(VAR_14);",
"g_strlcpy(VAR_5, VAR_14, VAR_6);",
"}",
"if (!VAR_11) {",
"goto done;",
"}",
"VAR_14 = qemu_rbd_next_tok(VAR_8, VAR_11,\n'\\0', \"configuration\", &VAR_11, &local_err);",
"if (local_err) {",
"goto done;",
"}",
"g_strlcpy(VAR_7, VAR_14, VAR_8);",
"done:\nif (local_err) {",
"VAR_13 = -EINVAL;",
"error_propagate(VAR_9, local_err);",
"}",
"g_free(VAR_12);",
"return VAR_13;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91,
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
131,
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
145,
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
]
] |
1,753 | static void vtd_realize(DeviceState *dev, Error **errp)
{
MachineState *ms = MACHINE(qdev_get_machine());
MachineClass *mc = MACHINE_GET_CLASS(ms);
PCMachineState *pcms =
PC_MACHINE(object_dynamic_cast(OBJECT(ms), TYPE_PC_MACHINE));
PCIBus *bus;
IntelIOMMUState *s = INTEL_IOMMU_DEVICE(dev);
X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(dev);
if (!pcms) {
error_setg(errp, "Machine-type '%s' not supported by intel-iommu",
mc->name);
return;
}
bus = pcms->bus;
x86_iommu->type = TYPE_INTEL;
if (!vtd_decide_config(s, errp)) {
return;
}
QLIST_INIT(&s->notifiers_list);
memset(s->vtd_as_by_bus_num, 0, sizeof(s->vtd_as_by_bus_num));
memory_region_init_io(&s->csrmem, OBJECT(s), &vtd_mem_ops, s,
"intel_iommu", DMAR_REG_SIZE);
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->csrmem);
/* No corresponding destroy */
s->iotlb = g_hash_table_new_full(vtd_uint64_hash, vtd_uint64_equal,
g_free, g_free);
s->vtd_as_by_busptr = g_hash_table_new_full(vtd_uint64_hash, vtd_uint64_equal,
g_free, g_free);
vtd_init(s);
sysbus_mmio_map(SYS_BUS_DEVICE(s), 0, Q35_HOST_BRIDGE_IOMMU_ADDR);
pci_setup_iommu(bus, vtd_host_dma_iommu, dev);
/* Pseudo address space under root PCI bus. */
pcms->ioapic_as = vtd_host_dma_iommu(bus, s, Q35_PSEUDO_DEVFN_IOAPIC);
}
| false | qemu | 29396ed9acfaee9936377ddece4b05452b417861 | static void vtd_realize(DeviceState *dev, Error **errp)
{
MachineState *ms = MACHINE(qdev_get_machine());
MachineClass *mc = MACHINE_GET_CLASS(ms);
PCMachineState *pcms =
PC_MACHINE(object_dynamic_cast(OBJECT(ms), TYPE_PC_MACHINE));
PCIBus *bus;
IntelIOMMUState *s = INTEL_IOMMU_DEVICE(dev);
X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(dev);
if (!pcms) {
error_setg(errp, "Machine-type '%s' not supported by intel-iommu",
mc->name);
return;
}
bus = pcms->bus;
x86_iommu->type = TYPE_INTEL;
if (!vtd_decide_config(s, errp)) {
return;
}
QLIST_INIT(&s->notifiers_list);
memset(s->vtd_as_by_bus_num, 0, sizeof(s->vtd_as_by_bus_num));
memory_region_init_io(&s->csrmem, OBJECT(s), &vtd_mem_ops, s,
"intel_iommu", DMAR_REG_SIZE);
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->csrmem);
s->iotlb = g_hash_table_new_full(vtd_uint64_hash, vtd_uint64_equal,
g_free, g_free);
s->vtd_as_by_busptr = g_hash_table_new_full(vtd_uint64_hash, vtd_uint64_equal,
g_free, g_free);
vtd_init(s);
sysbus_mmio_map(SYS_BUS_DEVICE(s), 0, Q35_HOST_BRIDGE_IOMMU_ADDR);
pci_setup_iommu(bus, vtd_host_dma_iommu, dev);
pcms->ioapic_as = vtd_host_dma_iommu(bus, s, Q35_PSEUDO_DEVFN_IOAPIC);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
MachineState *ms = MACHINE(qdev_get_machine());
MachineClass *mc = MACHINE_GET_CLASS(ms);
PCMachineState *pcms =
PC_MACHINE(object_dynamic_cast(OBJECT(ms), TYPE_PC_MACHINE));
PCIBus *bus;
IntelIOMMUState *s = INTEL_IOMMU_DEVICE(VAR_0);
X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(VAR_0);
if (!pcms) {
error_setg(VAR_1, "Machine-type '%s' not supported by intel-iommu",
mc->name);
return;
}
bus = pcms->bus;
x86_iommu->type = TYPE_INTEL;
if (!vtd_decide_config(s, VAR_1)) {
return;
}
QLIST_INIT(&s->notifiers_list);
memset(s->vtd_as_by_bus_num, 0, sizeof(s->vtd_as_by_bus_num));
memory_region_init_io(&s->csrmem, OBJECT(s), &vtd_mem_ops, s,
"intel_iommu", DMAR_REG_SIZE);
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->csrmem);
s->iotlb = g_hash_table_new_full(vtd_uint64_hash, vtd_uint64_equal,
g_free, g_free);
s->vtd_as_by_busptr = g_hash_table_new_full(vtd_uint64_hash, vtd_uint64_equal,
g_free, g_free);
vtd_init(s);
sysbus_mmio_map(SYS_BUS_DEVICE(s), 0, Q35_HOST_BRIDGE_IOMMU_ADDR);
pci_setup_iommu(bus, vtd_host_dma_iommu, VAR_0);
pcms->ioapic_as = vtd_host_dma_iommu(bus, s, Q35_PSEUDO_DEVFN_IOAPIC);
}
| [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"MachineState *ms = MACHINE(qdev_get_machine());",
"MachineClass *mc = MACHINE_GET_CLASS(ms);",
"PCMachineState *pcms =\nPC_MACHINE(object_dynamic_cast(OBJECT(ms), TYPE_PC_MACHINE));",
"PCIBus *bus;",
"IntelIOMMUState *s = INTEL_IOMMU_DEVICE(VAR_0);",
"X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(VAR_0);",
"if (!pcms) {",
"error_setg(VAR_1, \"Machine-type '%s' not supported by intel-iommu\",\nmc->name);",
"return;",
"}",
"bus = pcms->bus;",
"x86_iommu->type = TYPE_INTEL;",
"if (!vtd_decide_config(s, VAR_1)) {",
"return;",
"}",
"QLIST_INIT(&s->notifiers_list);",
"memset(s->vtd_as_by_bus_num, 0, sizeof(s->vtd_as_by_bus_num));",
"memory_region_init_io(&s->csrmem, OBJECT(s), &vtd_mem_ops, s,\n\"intel_iommu\", DMAR_REG_SIZE);",
"sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->csrmem);",
"s->iotlb = g_hash_table_new_full(vtd_uint64_hash, vtd_uint64_equal,\ng_free, g_free);",
"s->vtd_as_by_busptr = g_hash_table_new_full(vtd_uint64_hash, vtd_uint64_equal,\ng_free, g_free);",
"vtd_init(s);",
"sysbus_mmio_map(SYS_BUS_DEVICE(s), 0, Q35_HOST_BRIDGE_IOMMU_ADDR);",
"pci_setup_iommu(bus, vtd_host_dma_iommu, VAR_0);",
"pcms->ioapic_as = vtd_host_dma_iommu(bus, s, Q35_PSEUDO_DEVFN_IOAPIC);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51,
53
],
[
55
],
[
59,
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
]
] |
1,754 | void s390x_cpu_timer(void *opaque)
{
S390CPU *cpu = opaque;
CPUS390XState *env = &cpu->env;
env->pending_int |= INTERRUPT_CPUTIMER;
cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD);
}
| false | qemu | 6482b0ffd12ce83810c10b1a3884a75eba2ade1a | void s390x_cpu_timer(void *opaque)
{
S390CPU *cpu = opaque;
CPUS390XState *env = &cpu->env;
env->pending_int |= INTERRUPT_CPUTIMER;
cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(void *VAR_0)
{
S390CPU *cpu = VAR_0;
CPUS390XState *env = &cpu->env;
env->pending_int |= INTERRUPT_CPUTIMER;
cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD);
}
| [
"void FUNC_0(void *VAR_0)\n{",
"S390CPU *cpu = VAR_0;",
"CPUS390XState *env = &cpu->env;",
"env->pending_int |= INTERRUPT_CPUTIMER;",
"cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD);",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
]
] |
1,755 | static int ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
IDEState *s = &ad->port.ifs[0];
ahci_populate_sglist(ad, &s->sg, 0);
s->io_buffer_size = s->sg.size;
DPRINTF(ad->port_no, "len=%#x\n", s->io_buffer_size);
return s->io_buffer_size != 0;
}
| false | qemu | bef1301acb74d177b42890116e4eeaf26047b9e3 | static int ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
IDEState *s = &ad->port.ifs[0];
ahci_populate_sglist(ad, &s->sg, 0);
s->io_buffer_size = s->sg.size;
DPRINTF(ad->port_no, "len=%#x\n", s->io_buffer_size);
return s->io_buffer_size != 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(IDEDMA *VAR_0, int VAR_1)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, VAR_0, VAR_0);
IDEState *s = &ad->port.ifs[0];
ahci_populate_sglist(ad, &s->sg, 0);
s->io_buffer_size = s->sg.size;
DPRINTF(ad->port_no, "len=%#x\n", s->io_buffer_size);
return s->io_buffer_size != 0;
}
| [
"static int FUNC_0(IDEDMA *VAR_0, int VAR_1)\n{",
"AHCIDevice *ad = DO_UPCAST(AHCIDevice, VAR_0, VAR_0);",
"IDEState *s = &ad->port.ifs[0];",
"ahci_populate_sglist(ad, &s->sg, 0);",
"s->io_buffer_size = s->sg.size;",
"DPRINTF(ad->port_no, \"len=%#x\\n\", s->io_buffer_size);",
"return s->io_buffer_size != 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
]
] |
1,756 | void tcp_start_incoming_migration(const char *host_port, Error **errp)
{
Error *err = NULL;
SocketAddressLegacy *saddr = tcp_build_address(host_port, &err);
if (!err) {
socket_start_incoming_migration(saddr, &err);
}
error_propagate(errp, err);
}
| false | qemu | bd269ebc82fbaa5fe7ce5bc7c1770ac8acecd884 | void tcp_start_incoming_migration(const char *host_port, Error **errp)
{
Error *err = NULL;
SocketAddressLegacy *saddr = tcp_build_address(host_port, &err);
if (!err) {
socket_start_incoming_migration(saddr, &err);
}
error_propagate(errp, err);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(const char *VAR_0, Error **VAR_1)
{
Error *err = NULL;
SocketAddressLegacy *saddr = tcp_build_address(VAR_0, &err);
if (!err) {
socket_start_incoming_migration(saddr, &err);
}
error_propagate(VAR_1, err);
}
| [
"void FUNC_0(const char *VAR_0, Error **VAR_1)\n{",
"Error *err = NULL;",
"SocketAddressLegacy *saddr = tcp_build_address(VAR_0, &err);",
"if (!err) {",
"socket_start_incoming_migration(saddr, &err);",
"}",
"error_propagate(VAR_1, err);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
1,757 | static void init_quantization(Jpeg2000EncoderContext *s)
{
int compno, reslevelno, bandno;
Jpeg2000QuantStyle *qntsty = &s->qntsty;
Jpeg2000CodingStyle *codsty = &s->codsty;
for (compno = 0; compno < s->ncomponents; compno++){
int gbandno = 0;
for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){
int nbands, lev = codsty->nreslevels - reslevelno - 1;
nbands = reslevelno ? 3 : 1;
for (bandno = 0; bandno < nbands; bandno++, gbandno++){
int expn, mant;
if (codsty->transform == FF_DWT97){
int bandpos = bandno + (reslevelno>0),
ss = 81920000 / dwt_norms[0][bandpos][lev],
log = av_log2(ss);
mant = (11 - log < 0 ? ss >> log - 11 : ss << 11 - log) & 0x7ff;
expn = s->cbps[compno] - log + 13;
} else
expn = ((bandno&2)>>1) + (reslevelno>0) + s->cbps[compno];
qntsty->expn[gbandno] = expn;
qntsty->mant[gbandno] = mant;
}
}
}
}
| false | FFmpeg | 83fd377c94d8fbffdb3e69fb3efe1976ff897a88 | static void init_quantization(Jpeg2000EncoderContext *s)
{
int compno, reslevelno, bandno;
Jpeg2000QuantStyle *qntsty = &s->qntsty;
Jpeg2000CodingStyle *codsty = &s->codsty;
for (compno = 0; compno < s->ncomponents; compno++){
int gbandno = 0;
for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){
int nbands, lev = codsty->nreslevels - reslevelno - 1;
nbands = reslevelno ? 3 : 1;
for (bandno = 0; bandno < nbands; bandno++, gbandno++){
int expn, mant;
if (codsty->transform == FF_DWT97){
int bandpos = bandno + (reslevelno>0),
ss = 81920000 / dwt_norms[0][bandpos][lev],
log = av_log2(ss);
mant = (11 - log < 0 ? ss >> log - 11 : ss << 11 - log) & 0x7ff;
expn = s->cbps[compno] - log + 13;
} else
expn = ((bandno&2)>>1) + (reslevelno>0) + s->cbps[compno];
qntsty->expn[gbandno] = expn;
qntsty->mant[gbandno] = mant;
}
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Jpeg2000EncoderContext *VAR_0)
{
int VAR_1, VAR_2, VAR_3;
Jpeg2000QuantStyle *qntsty = &VAR_0->qntsty;
Jpeg2000CodingStyle *codsty = &VAR_0->codsty;
for (VAR_1 = 0; VAR_1 < VAR_0->ncomponents; VAR_1++){
int gbandno = 0;
for (VAR_2 = 0; VAR_2 < codsty->nreslevels; VAR_2++){
int nbands, lev = codsty->nreslevels - VAR_2 - 1;
nbands = VAR_2 ? 3 : 1;
for (VAR_3 = 0; VAR_3 < nbands; VAR_3++, gbandno++){
int expn, mant;
if (codsty->transform == FF_DWT97){
int bandpos = VAR_3 + (VAR_2>0),
ss = 81920000 / dwt_norms[0][bandpos][lev],
log = av_log2(ss);
mant = (11 - log < 0 ? ss >> log - 11 : ss << 11 - log) & 0x7ff;
expn = VAR_0->cbps[VAR_1] - log + 13;
} else
expn = ((VAR_3&2)>>1) + (VAR_2>0) + VAR_0->cbps[VAR_1];
qntsty->expn[gbandno] = expn;
qntsty->mant[gbandno] = mant;
}
}
}
}
| [
"static void FUNC_0(Jpeg2000EncoderContext *VAR_0)\n{",
"int VAR_1, VAR_2, VAR_3;",
"Jpeg2000QuantStyle *qntsty = &VAR_0->qntsty;",
"Jpeg2000CodingStyle *codsty = &VAR_0->codsty;",
"for (VAR_1 = 0; VAR_1 < VAR_0->ncomponents; VAR_1++){",
"int gbandno = 0;",
"for (VAR_2 = 0; VAR_2 < codsty->nreslevels; VAR_2++){",
"int nbands, lev = codsty->nreslevels - VAR_2 - 1;",
"nbands = VAR_2 ? 3 : 1;",
"for (VAR_3 = 0; VAR_3 < nbands; VAR_3++, gbandno++){",
"int expn, mant;",
"if (codsty->transform == FF_DWT97){",
"int bandpos = VAR_3 + (VAR_2>0),\nss = 81920000 / dwt_norms[0][bandpos][lev],\nlog = av_log2(ss);",
"mant = (11 - log < 0 ? ss >> log - 11 : ss << 11 - log) & 0x7ff;",
"expn = VAR_0->cbps[VAR_1] - log + 13;",
"} else",
"expn = ((VAR_3&2)>>1) + (VAR_2>0) + VAR_0->cbps[VAR_1];",
"qntsty->expn[gbandno] = expn;",
"qntsty->mant[gbandno] = mant;",
"}",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31,
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
]
] |
1,758 | static BlockDriverState *bdrv_open_inherit(const char *filename,
const char *reference,
QDict *options, int flags,
BlockDriverState *parent,
const BdrvChildRole *child_role,
Error **errp)
{
int ret;
BdrvChild *file = NULL;
BlockDriverState *bs;
BlockDriver *drv = NULL;
const char *drvname;
const char *backing;
Error *local_err = NULL;
QDict *snapshot_options = NULL;
int snapshot_flags = 0;
assert(!child_role || !flags);
assert(!child_role == !parent);
if (reference) {
bool options_non_empty = options ? qdict_size(options) : false;
QDECREF(options);
if (filename || options_non_empty) {
error_setg(errp, "Cannot reference an existing block device with "
"additional options or a new filename");
return NULL;
}
bs = bdrv_lookup_bs(reference, reference, errp);
if (!bs) {
return NULL;
}
bdrv_ref(bs);
return bs;
}
bs = bdrv_new();
/* NULL means an empty set of options */
if (options == NULL) {
options = qdict_new();
}
/* json: syntax counts as explicit options, as if in the QDict */
parse_json_protocol(options, &filename, &local_err);
if (local_err) {
goto fail;
}
bs->explicit_options = qdict_clone_shallow(options);
if (child_role) {
bs->inherits_from = parent;
child_role->inherit_options(&flags, options,
parent->open_flags, parent->options);
}
ret = bdrv_fill_options(&options, filename, &flags, &local_err);
if (local_err) {
goto fail;
}
/* Set the BDRV_O_RDWR and BDRV_O_ALLOW_RDWR flags.
* FIXME: we're parsing the QDict to avoid having to create a
* QemuOpts just for this, but neither option is optimal. */
if (g_strcmp0(qdict_get_try_str(options, BDRV_OPT_READ_ONLY), "on") &&
!qdict_get_try_bool(options, BDRV_OPT_READ_ONLY, false)) {
flags |= (BDRV_O_RDWR | BDRV_O_ALLOW_RDWR);
} else {
flags &= ~BDRV_O_RDWR;
}
if (flags & BDRV_O_SNAPSHOT) {
snapshot_options = qdict_new();
bdrv_temp_snapshot_options(&snapshot_flags, snapshot_options,
flags, options);
/* Let bdrv_backing_options() override "read-only" */
qdict_del(options, BDRV_OPT_READ_ONLY);
bdrv_backing_options(&flags, options, flags, options);
}
bs->open_flags = flags;
bs->options = options;
options = qdict_clone_shallow(options);
/* Find the right image format driver */
drvname = qdict_get_try_str(options, "driver");
if (drvname) {
drv = bdrv_find_format(drvname);
if (!drv) {
error_setg(errp, "Unknown driver: '%s'", drvname);
goto fail;
}
}
assert(drvname || !(flags & BDRV_O_PROTOCOL));
backing = qdict_get_try_str(options, "backing");
if (backing && *backing == '\0') {
flags |= BDRV_O_NO_BACKING;
qdict_del(options, "backing");
}
/* Open image file without format layer */
if ((flags & BDRV_O_PROTOCOL) == 0) {
file = bdrv_open_child(filename, options, "file", bs,
&child_file, true, &local_err);
if (local_err) {
goto fail;
}
}
/* Image format probing */
bs->probed = !drv;
if (!drv && file) {
ret = find_image_format(file, filename, &drv, &local_err);
if (ret < 0) {
goto fail;
}
/*
* This option update would logically belong in bdrv_fill_options(),
* but we first need to open bs->file for the probing to work, while
* opening bs->file already requires the (mostly) final set of options
* so that cache mode etc. can be inherited.
*
* Adding the driver later is somewhat ugly, but it's not an option
* that would ever be inherited, so it's correct. We just need to make
* sure to update both bs->options (which has the full effective
* options for bs) and options (which has file.* already removed).
*/
qdict_put(bs->options, "driver", qstring_from_str(drv->format_name));
qdict_put(options, "driver", qstring_from_str(drv->format_name));
} else if (!drv) {
error_setg(errp, "Must specify either driver or file");
goto fail;
}
/* BDRV_O_PROTOCOL must be set iff a protocol BDS is about to be created */
assert(!!(flags & BDRV_O_PROTOCOL) == !!drv->bdrv_file_open);
/* file must be NULL if a protocol BDS is about to be created
* (the inverse results in an error message from bdrv_open_common()) */
assert(!(flags & BDRV_O_PROTOCOL) || !file);
/* Open the image */
ret = bdrv_open_common(bs, file, options, &local_err);
if (ret < 0) {
goto fail;
}
if (file && (bs->file != file)) {
bdrv_unref_child(bs, file);
file = NULL;
}
/* If there is a backing file, use it */
if ((flags & BDRV_O_NO_BACKING) == 0) {
ret = bdrv_open_backing_file(bs, options, "backing", &local_err);
if (ret < 0) {
goto close_and_fail;
}
}
bdrv_refresh_filename(bs);
/* Check if any unknown options were used */
if (options && (qdict_size(options) != 0)) {
const QDictEntry *entry = qdict_first(options);
if (flags & BDRV_O_PROTOCOL) {
error_setg(errp, "Block protocol '%s' doesn't support the option "
"'%s'", drv->format_name, entry->key);
} else {
error_setg(errp,
"Block format '%s' does not support the option '%s'",
drv->format_name, entry->key);
}
goto close_and_fail;
}
if (!bdrv_key_required(bs)) {
bdrv_parent_cb_change_media(bs, true);
} else if (!runstate_check(RUN_STATE_PRELAUNCH)
&& !runstate_check(RUN_STATE_INMIGRATE)
&& !runstate_check(RUN_STATE_PAUSED)) { /* HACK */
error_setg(errp,
"Guest must be stopped for opening of encrypted image");
goto close_and_fail;
}
QDECREF(options);
/* For snapshot=on, create a temporary qcow2 overlay. bs points to the
* temporary snapshot afterwards. */
if (snapshot_flags) {
BlockDriverState *snapshot_bs;
snapshot_bs = bdrv_append_temp_snapshot(bs, snapshot_flags,
snapshot_options, &local_err);
snapshot_options = NULL;
if (local_err) {
goto close_and_fail;
}
/* We are not going to return bs but the overlay on top of it
* (snapshot_bs); thus, we have to drop the strong reference to bs
* (which we obtained by calling bdrv_new()). bs will not be deleted,
* though, because the overlay still has a reference to it. */
bdrv_unref(bs);
bs = snapshot_bs;
}
return bs;
fail:
if (file != NULL) {
bdrv_unref_child(bs, file);
}
QDECREF(snapshot_options);
QDECREF(bs->explicit_options);
QDECREF(bs->options);
QDECREF(options);
bs->options = NULL;
bdrv_unref(bs);
error_propagate(errp, local_err);
return NULL;
close_and_fail:
bdrv_unref(bs);
QDECREF(snapshot_options);
QDECREF(options);
error_propagate(errp, local_err);
return NULL;
}
| false | qemu | 7ad2757feffd13b8000826ae3df2a3bc929d688d | static BlockDriverState *bdrv_open_inherit(const char *filename,
const char *reference,
QDict *options, int flags,
BlockDriverState *parent,
const BdrvChildRole *child_role,
Error **errp)
{
int ret;
BdrvChild *file = NULL;
BlockDriverState *bs;
BlockDriver *drv = NULL;
const char *drvname;
const char *backing;
Error *local_err = NULL;
QDict *snapshot_options = NULL;
int snapshot_flags = 0;
assert(!child_role || !flags);
assert(!child_role == !parent);
if (reference) {
bool options_non_empty = options ? qdict_size(options) : false;
QDECREF(options);
if (filename || options_non_empty) {
error_setg(errp, "Cannot reference an existing block device with "
"additional options or a new filename");
return NULL;
}
bs = bdrv_lookup_bs(reference, reference, errp);
if (!bs) {
return NULL;
}
bdrv_ref(bs);
return bs;
}
bs = bdrv_new();
if (options == NULL) {
options = qdict_new();
}
parse_json_protocol(options, &filename, &local_err);
if (local_err) {
goto fail;
}
bs->explicit_options = qdict_clone_shallow(options);
if (child_role) {
bs->inherits_from = parent;
child_role->inherit_options(&flags, options,
parent->open_flags, parent->options);
}
ret = bdrv_fill_options(&options, filename, &flags, &local_err);
if (local_err) {
goto fail;
}
if (g_strcmp0(qdict_get_try_str(options, BDRV_OPT_READ_ONLY), "on") &&
!qdict_get_try_bool(options, BDRV_OPT_READ_ONLY, false)) {
flags |= (BDRV_O_RDWR | BDRV_O_ALLOW_RDWR);
} else {
flags &= ~BDRV_O_RDWR;
}
if (flags & BDRV_O_SNAPSHOT) {
snapshot_options = qdict_new();
bdrv_temp_snapshot_options(&snapshot_flags, snapshot_options,
flags, options);
qdict_del(options, BDRV_OPT_READ_ONLY);
bdrv_backing_options(&flags, options, flags, options);
}
bs->open_flags = flags;
bs->options = options;
options = qdict_clone_shallow(options);
drvname = qdict_get_try_str(options, "driver");
if (drvname) {
drv = bdrv_find_format(drvname);
if (!drv) {
error_setg(errp, "Unknown driver: '%s'", drvname);
goto fail;
}
}
assert(drvname || !(flags & BDRV_O_PROTOCOL));
backing = qdict_get_try_str(options, "backing");
if (backing && *backing == '\0') {
flags |= BDRV_O_NO_BACKING;
qdict_del(options, "backing");
}
if ((flags & BDRV_O_PROTOCOL) == 0) {
file = bdrv_open_child(filename, options, "file", bs,
&child_file, true, &local_err);
if (local_err) {
goto fail;
}
}
bs->probed = !drv;
if (!drv && file) {
ret = find_image_format(file, filename, &drv, &local_err);
if (ret < 0) {
goto fail;
}
qdict_put(bs->options, "driver", qstring_from_str(drv->format_name));
qdict_put(options, "driver", qstring_from_str(drv->format_name));
} else if (!drv) {
error_setg(errp, "Must specify either driver or file");
goto fail;
}
assert(!!(flags & BDRV_O_PROTOCOL) == !!drv->bdrv_file_open);
assert(!(flags & BDRV_O_PROTOCOL) || !file);
ret = bdrv_open_common(bs, file, options, &local_err);
if (ret < 0) {
goto fail;
}
if (file && (bs->file != file)) {
bdrv_unref_child(bs, file);
file = NULL;
}
if ((flags & BDRV_O_NO_BACKING) == 0) {
ret = bdrv_open_backing_file(bs, options, "backing", &local_err);
if (ret < 0) {
goto close_and_fail;
}
}
bdrv_refresh_filename(bs);
if (options && (qdict_size(options) != 0)) {
const QDictEntry *entry = qdict_first(options);
if (flags & BDRV_O_PROTOCOL) {
error_setg(errp, "Block protocol '%s' doesn't support the option "
"'%s'", drv->format_name, entry->key);
} else {
error_setg(errp,
"Block format '%s' does not support the option '%s'",
drv->format_name, entry->key);
}
goto close_and_fail;
}
if (!bdrv_key_required(bs)) {
bdrv_parent_cb_change_media(bs, true);
} else if (!runstate_check(RUN_STATE_PRELAUNCH)
&& !runstate_check(RUN_STATE_INMIGRATE)
&& !runstate_check(RUN_STATE_PAUSED)) {
error_setg(errp,
"Guest must be stopped for opening of encrypted image");
goto close_and_fail;
}
QDECREF(options);
if (snapshot_flags) {
BlockDriverState *snapshot_bs;
snapshot_bs = bdrv_append_temp_snapshot(bs, snapshot_flags,
snapshot_options, &local_err);
snapshot_options = NULL;
if (local_err) {
goto close_and_fail;
}
bdrv_unref(bs);
bs = snapshot_bs;
}
return bs;
fail:
if (file != NULL) {
bdrv_unref_child(bs, file);
}
QDECREF(snapshot_options);
QDECREF(bs->explicit_options);
QDECREF(bs->options);
QDECREF(options);
bs->options = NULL;
bdrv_unref(bs);
error_propagate(errp, local_err);
return NULL;
close_and_fail:
bdrv_unref(bs);
QDECREF(snapshot_options);
QDECREF(options);
error_propagate(errp, local_err);
return NULL;
}
| {
"code": [],
"line_no": []
} | static BlockDriverState *FUNC_0(const char *filename,
const char *reference,
QDict *options, int flags,
BlockDriverState *parent,
const BdrvChildRole *child_role,
Error **errp)
{
int VAR_0;
BdrvChild *file = NULL;
BlockDriverState *bs;
BlockDriver *drv = NULL;
const char *VAR_1;
const char *VAR_2;
Error *local_err = NULL;
QDict *snapshot_options = NULL;
int VAR_3 = 0;
assert(!child_role || !flags);
assert(!child_role == !parent);
if (reference) {
bool options_non_empty = options ? qdict_size(options) : false;
QDECREF(options);
if (filename || options_non_empty) {
error_setg(errp, "Cannot reference an existing block device with "
"additional options or a new filename");
return NULL;
}
bs = bdrv_lookup_bs(reference, reference, errp);
if (!bs) {
return NULL;
}
bdrv_ref(bs);
return bs;
}
bs = bdrv_new();
if (options == NULL) {
options = qdict_new();
}
parse_json_protocol(options, &filename, &local_err);
if (local_err) {
goto fail;
}
bs->explicit_options = qdict_clone_shallow(options);
if (child_role) {
bs->inherits_from = parent;
child_role->inherit_options(&flags, options,
parent->open_flags, parent->options);
}
VAR_0 = bdrv_fill_options(&options, filename, &flags, &local_err);
if (local_err) {
goto fail;
}
if (g_strcmp0(qdict_get_try_str(options, BDRV_OPT_READ_ONLY), "on") &&
!qdict_get_try_bool(options, BDRV_OPT_READ_ONLY, false)) {
flags |= (BDRV_O_RDWR | BDRV_O_ALLOW_RDWR);
} else {
flags &= ~BDRV_O_RDWR;
}
if (flags & BDRV_O_SNAPSHOT) {
snapshot_options = qdict_new();
bdrv_temp_snapshot_options(&VAR_3, snapshot_options,
flags, options);
qdict_del(options, BDRV_OPT_READ_ONLY);
bdrv_backing_options(&flags, options, flags, options);
}
bs->open_flags = flags;
bs->options = options;
options = qdict_clone_shallow(options);
VAR_1 = qdict_get_try_str(options, "driver");
if (VAR_1) {
drv = bdrv_find_format(VAR_1);
if (!drv) {
error_setg(errp, "Unknown driver: '%s'", VAR_1);
goto fail;
}
}
assert(VAR_1 || !(flags & BDRV_O_PROTOCOL));
VAR_2 = qdict_get_try_str(options, "VAR_2");
if (VAR_2 && *VAR_2 == '\0') {
flags |= BDRV_O_NO_BACKING;
qdict_del(options, "VAR_2");
}
if ((flags & BDRV_O_PROTOCOL) == 0) {
file = bdrv_open_child(filename, options, "file", bs,
&child_file, true, &local_err);
if (local_err) {
goto fail;
}
}
bs->probed = !drv;
if (!drv && file) {
VAR_0 = find_image_format(file, filename, &drv, &local_err);
if (VAR_0 < 0) {
goto fail;
}
qdict_put(bs->options, "driver", qstring_from_str(drv->format_name));
qdict_put(options, "driver", qstring_from_str(drv->format_name));
} else if (!drv) {
error_setg(errp, "Must specify either driver or file");
goto fail;
}
assert(!!(flags & BDRV_O_PROTOCOL) == !!drv->bdrv_file_open);
assert(!(flags & BDRV_O_PROTOCOL) || !file);
VAR_0 = bdrv_open_common(bs, file, options, &local_err);
if (VAR_0 < 0) {
goto fail;
}
if (file && (bs->file != file)) {
bdrv_unref_child(bs, file);
file = NULL;
}
if ((flags & BDRV_O_NO_BACKING) == 0) {
VAR_0 = bdrv_open_backing_file(bs, options, "VAR_2", &local_err);
if (VAR_0 < 0) {
goto close_and_fail;
}
}
bdrv_refresh_filename(bs);
if (options && (qdict_size(options) != 0)) {
const QDictEntry *VAR_4 = qdict_first(options);
if (flags & BDRV_O_PROTOCOL) {
error_setg(errp, "Block protocol '%s' doesn't support the option "
"'%s'", drv->format_name, VAR_4->key);
} else {
error_setg(errp,
"Block format '%s' does not support the option '%s'",
drv->format_name, VAR_4->key);
}
goto close_and_fail;
}
if (!bdrv_key_required(bs)) {
bdrv_parent_cb_change_media(bs, true);
} else if (!runstate_check(RUN_STATE_PRELAUNCH)
&& !runstate_check(RUN_STATE_INMIGRATE)
&& !runstate_check(RUN_STATE_PAUSED)) {
error_setg(errp,
"Guest must be stopped for opening of encrypted image");
goto close_and_fail;
}
QDECREF(options);
if (VAR_3) {
BlockDriverState *snapshot_bs;
snapshot_bs = bdrv_append_temp_snapshot(bs, VAR_3,
snapshot_options, &local_err);
snapshot_options = NULL;
if (local_err) {
goto close_and_fail;
}
bdrv_unref(bs);
bs = snapshot_bs;
}
return bs;
fail:
if (file != NULL) {
bdrv_unref_child(bs, file);
}
QDECREF(snapshot_options);
QDECREF(bs->explicit_options);
QDECREF(bs->options);
QDECREF(options);
bs->options = NULL;
bdrv_unref(bs);
error_propagate(errp, local_err);
return NULL;
close_and_fail:
bdrv_unref(bs);
QDECREF(snapshot_options);
QDECREF(options);
error_propagate(errp, local_err);
return NULL;
}
| [
"static BlockDriverState *FUNC_0(const char *filename,\nconst char *reference,\nQDict *options, int flags,\nBlockDriverState *parent,\nconst BdrvChildRole *child_role,\nError **errp)\n{",
"int VAR_0;",
"BdrvChild *file = NULL;",
"BlockDriverState *bs;",
"BlockDriver *drv = NULL;",
"const char *VAR_1;",
"const char *VAR_2;",
"Error *local_err = NULL;",
"QDict *snapshot_options = NULL;",
"int VAR_3 = 0;",
"assert(!child_role || !flags);",
"assert(!child_role == !parent);",
"if (reference) {",
"bool options_non_empty = options ? qdict_size(options) : false;",
"QDECREF(options);",
"if (filename || options_non_empty) {",
"error_setg(errp, \"Cannot reference an existing block device with \"\n\"additional options or a new filename\");",
"return NULL;",
"}",
"bs = bdrv_lookup_bs(reference, reference, errp);",
"if (!bs) {",
"return NULL;",
"}",
"bdrv_ref(bs);",
"return bs;",
"}",
"bs = bdrv_new();",
"if (options == NULL) {",
"options = qdict_new();",
"}",
"parse_json_protocol(options, &filename, &local_err);",
"if (local_err) {",
"goto fail;",
"}",
"bs->explicit_options = qdict_clone_shallow(options);",
"if (child_role) {",
"bs->inherits_from = parent;",
"child_role->inherit_options(&flags, options,\nparent->open_flags, parent->options);",
"}",
"VAR_0 = bdrv_fill_options(&options, filename, &flags, &local_err);",
"if (local_err) {",
"goto fail;",
"}",
"if (g_strcmp0(qdict_get_try_str(options, BDRV_OPT_READ_ONLY), \"on\") &&\n!qdict_get_try_bool(options, BDRV_OPT_READ_ONLY, false)) {",
"flags |= (BDRV_O_RDWR | BDRV_O_ALLOW_RDWR);",
"} else {",
"flags &= ~BDRV_O_RDWR;",
"}",
"if (flags & BDRV_O_SNAPSHOT) {",
"snapshot_options = qdict_new();",
"bdrv_temp_snapshot_options(&VAR_3, snapshot_options,\nflags, options);",
"qdict_del(options, BDRV_OPT_READ_ONLY);",
"bdrv_backing_options(&flags, options, flags, options);",
"}",
"bs->open_flags = flags;",
"bs->options = options;",
"options = qdict_clone_shallow(options);",
"VAR_1 = qdict_get_try_str(options, \"driver\");",
"if (VAR_1) {",
"drv = bdrv_find_format(VAR_1);",
"if (!drv) {",
"error_setg(errp, \"Unknown driver: '%s'\", VAR_1);",
"goto fail;",
"}",
"}",
"assert(VAR_1 || !(flags & BDRV_O_PROTOCOL));",
"VAR_2 = qdict_get_try_str(options, \"VAR_2\");",
"if (VAR_2 && *VAR_2 == '\\0') {",
"flags |= BDRV_O_NO_BACKING;",
"qdict_del(options, \"VAR_2\");",
"}",
"if ((flags & BDRV_O_PROTOCOL) == 0) {",
"file = bdrv_open_child(filename, options, \"file\", bs,\n&child_file, true, &local_err);",
"if (local_err) {",
"goto fail;",
"}",
"}",
"bs->probed = !drv;",
"if (!drv && file) {",
"VAR_0 = find_image_format(file, filename, &drv, &local_err);",
"if (VAR_0 < 0) {",
"goto fail;",
"}",
"qdict_put(bs->options, \"driver\", qstring_from_str(drv->format_name));",
"qdict_put(options, \"driver\", qstring_from_str(drv->format_name));",
"} else if (!drv) {",
"error_setg(errp, \"Must specify either driver or file\");",
"goto fail;",
"}",
"assert(!!(flags & BDRV_O_PROTOCOL) == !!drv->bdrv_file_open);",
"assert(!(flags & BDRV_O_PROTOCOL) || !file);",
"VAR_0 = bdrv_open_common(bs, file, options, &local_err);",
"if (VAR_0 < 0) {",
"goto fail;",
"}",
"if (file && (bs->file != file)) {",
"bdrv_unref_child(bs, file);",
"file = NULL;",
"}",
"if ((flags & BDRV_O_NO_BACKING) == 0) {",
"VAR_0 = bdrv_open_backing_file(bs, options, \"VAR_2\", &local_err);",
"if (VAR_0 < 0) {",
"goto close_and_fail;",
"}",
"}",
"bdrv_refresh_filename(bs);",
"if (options && (qdict_size(options) != 0)) {",
"const QDictEntry *VAR_4 = qdict_first(options);",
"if (flags & BDRV_O_PROTOCOL) {",
"error_setg(errp, \"Block protocol '%s' doesn't support the option \"\n\"'%s'\", drv->format_name, VAR_4->key);",
"} else {",
"error_setg(errp,\n\"Block format '%s' does not support the option '%s'\",\ndrv->format_name, VAR_4->key);",
"}",
"goto close_and_fail;",
"}",
"if (!bdrv_key_required(bs)) {",
"bdrv_parent_cb_change_media(bs, true);",
"} else if (!runstate_check(RUN_STATE_PRELAUNCH)",
"&& !runstate_check(RUN_STATE_INMIGRATE)\n&& !runstate_check(RUN_STATE_PAUSED)) {",
"error_setg(errp,\n\"Guest must be stopped for opening of encrypted image\");",
"goto close_and_fail;",
"}",
"QDECREF(options);",
"if (VAR_3) {",
"BlockDriverState *snapshot_bs;",
"snapshot_bs = bdrv_append_temp_snapshot(bs, VAR_3,\nsnapshot_options, &local_err);",
"snapshot_options = NULL;",
"if (local_err) {",
"goto close_and_fail;",
"}",
"bdrv_unref(bs);",
"bs = snapshot_bs;",
"}",
"return bs;",
"fail:\nif (file != NULL) {",
"bdrv_unref_child(bs, file);",
"}",
"QDECREF(snapshot_options);",
"QDECREF(bs->explicit_options);",
"QDECREF(bs->options);",
"QDECREF(options);",
"bs->options = NULL;",
"bdrv_unref(bs);",
"error_propagate(errp, local_err);",
"return NULL;",
"close_and_fail:\nbdrv_unref(bs);",
"QDECREF(snapshot_options);",
"QDECREF(options);",
"error_propagate(errp, local_err);",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
79
],
[
85
],
[
87
],
[
89
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
109
],
[
111
],
[
113,
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
127
],
[
137,
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
151
],
[
153
],
[
155,
157
],
[
161
],
[
163
],
[
165
],
[
169
],
[
171
],
[
173
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
197
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
215
],
[
217,
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
283
],
[
289
],
[
295
],
[
297
],
[
299
],
[
301
],
[
305
],
[
307
],
[
309
],
[
311
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
331
],
[
337
],
[
339
],
[
341
],
[
343,
345
],
[
347
],
[
349,
351,
353
],
[
355
],
[
359
],
[
361
],
[
365
],
[
367
],
[
369
],
[
371,
373
],
[
375,
377
],
[
379
],
[
381
],
[
385
],
[
393
],
[
395
],
[
397,
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
417
],
[
419
],
[
421
],
[
425
],
[
429,
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
449
],
[
451
],
[
455,
457
],
[
459
],
[
461
],
[
463
],
[
465
],
[
467
]
] |
1,759 | AlphaCPU *cpu_alpha_init(const char *cpu_model)
{
AlphaCPU *cpu;
ObjectClass *cpu_class;
cpu_class = alpha_cpu_class_by_name(cpu_model);
if (cpu_class == NULL) {
/* Default to ev67; no reason not to emulate insns by default. */
cpu_class = object_class_by_name(TYPE("ev67"));
}
cpu = ALPHA_CPU(object_new(object_class_get_name(cpu_class)));
object_property_set_bool(OBJECT(cpu), true, "realized", NULL);
return cpu;
}
| false | qemu | 82a3d1f81f8e401c6c34cba541970197aba2bb9a | AlphaCPU *cpu_alpha_init(const char *cpu_model)
{
AlphaCPU *cpu;
ObjectClass *cpu_class;
cpu_class = alpha_cpu_class_by_name(cpu_model);
if (cpu_class == NULL) {
cpu_class = object_class_by_name(TYPE("ev67"));
}
cpu = ALPHA_CPU(object_new(object_class_get_name(cpu_class)));
object_property_set_bool(OBJECT(cpu), true, "realized", NULL);
return cpu;
}
| {
"code": [],
"line_no": []
} | AlphaCPU *FUNC_0(const char *cpu_model)
{
AlphaCPU *cpu;
ObjectClass *cpu_class;
cpu_class = alpha_cpu_class_by_name(cpu_model);
if (cpu_class == NULL) {
cpu_class = object_class_by_name(TYPE("ev67"));
}
cpu = ALPHA_CPU(object_new(object_class_get_name(cpu_class)));
object_property_set_bool(OBJECT(cpu), true, "realized", NULL);
return cpu;
}
| [
"AlphaCPU *FUNC_0(const char *cpu_model)\n{",
"AlphaCPU *cpu;",
"ObjectClass *cpu_class;",
"cpu_class = alpha_cpu_class_by_name(cpu_model);",
"if (cpu_class == NULL) {",
"cpu_class = object_class_by_name(TYPE(\"ev67\"));",
"}",
"cpu = ALPHA_CPU(object_new(object_class_get_name(cpu_class)));",
"object_property_set_bool(OBJECT(cpu), true, \"realized\", NULL);",
"return cpu;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
]
] |
1,761 | static void xen_pt_pci_write_config(PCIDevice *d, uint32_t addr,
uint32_t val, int len)
{
XenPCIPassthroughState *s = DO_UPCAST(XenPCIPassthroughState, dev, d);
int index = 0;
XenPTRegGroup *reg_grp_entry = NULL;
int rc = 0;
uint32_t read_val = 0, wb_mask;
int emul_len = 0;
XenPTReg *reg_entry = NULL;
uint32_t find_addr = addr;
XenPTRegInfo *reg = NULL;
if (xen_pt_pci_config_access_check(d, addr, len)) {
return;
}
XEN_PT_LOG_CONFIG(d, addr, val, len);
/* check unused BAR register */
index = xen_pt_bar_offset_to_index(addr);
if ((index >= 0) && (val > 0 && val < XEN_PT_BAR_ALLF) &&
(s->bases[index].bar_flag == XEN_PT_BAR_FLAG_UNUSED)) {
XEN_PT_WARN(d, "Guest attempt to set address to unused Base Address "
"Register. (addr: 0x%02x, len: %d)\n", addr, len);
}
/* find register group entry */
reg_grp_entry = xen_pt_find_reg_grp(s, addr);
if (reg_grp_entry) {
/* check 0-Hardwired register group */
if (reg_grp_entry->reg_grp->grp_type == XEN_PT_GRP_TYPE_HARDWIRED) {
/* ignore silently */
XEN_PT_WARN(d, "Access to 0-Hardwired register. "
"(addr: 0x%02x, len: %d)\n", addr, len);
return;
}
}
rc = xen_host_pci_get_block(&s->real_device, addr,
(uint8_t *)&read_val, len);
if (rc < 0) {
XEN_PT_ERR(d, "pci_read_block failed. return value: %d.\n", rc);
memset(&read_val, 0xff, len);
wb_mask = 0;
} else {
wb_mask = 0xFFFFFFFF >> ((4 - len) << 3);
}
/* pass directly to the real device for passthrough type register group */
if (reg_grp_entry == NULL) {
goto out;
}
memory_region_transaction_begin();
pci_default_write_config(d, addr, val, len);
/* adjust the read and write value to appropriate CFC-CFF window */
read_val <<= (addr & 3) << 3;
val <<= (addr & 3) << 3;
emul_len = len;
/* loop around the guest requested size */
while (emul_len > 0) {
/* find register entry to be emulated */
reg_entry = xen_pt_find_reg(reg_grp_entry, find_addr);
if (reg_entry) {
reg = reg_entry->reg;
uint32_t real_offset = reg_grp_entry->base_offset + reg->offset;
uint32_t valid_mask = 0xFFFFFFFF >> ((4 - emul_len) << 3);
uint8_t *ptr_val = NULL;
valid_mask <<= (find_addr - real_offset) << 3;
ptr_val = (uint8_t *)&val + (real_offset & 3);
if (reg->emu_mask == (0xFFFFFFFF >> ((4 - reg->size) << 3))) {
wb_mask &= ~((reg->emu_mask
>> ((find_addr - real_offset) << 3))
<< ((len - emul_len) << 3));
}
/* do emulation based on register size */
switch (reg->size) {
case 1:
if (reg->u.b.write) {
rc = reg->u.b.write(s, reg_entry, ptr_val,
read_val >> ((real_offset & 3) << 3),
valid_mask);
}
break;
case 2:
if (reg->u.w.write) {
rc = reg->u.w.write(s, reg_entry, (uint16_t *)ptr_val,
(read_val >> ((real_offset & 3) << 3)),
valid_mask);
}
break;
case 4:
if (reg->u.dw.write) {
rc = reg->u.dw.write(s, reg_entry, (uint32_t *)ptr_val,
(read_val >> ((real_offset & 3) << 3)),
valid_mask);
}
break;
}
if (rc < 0) {
xen_shutdown_fatal_error("Internal error: Invalid write"
" emulation. (%s, rc: %d)\n",
__func__, rc);
return;
}
/* calculate next address to find */
emul_len -= reg->size;
if (emul_len > 0) {
find_addr = real_offset + reg->size;
}
} else {
/* nothing to do with passthrough type register,
* continue to find next byte */
emul_len--;
find_addr++;
}
}
/* need to shift back before passing them to xen_host_pci_device */
val >>= (addr & 3) << 3;
memory_region_transaction_commit();
out:
for (index = 0; wb_mask; index += len) {
/* unknown regs are passed through */
while (!(wb_mask & 0xff)) {
index++;
wb_mask >>= 8;
}
len = 0;
do {
len++;
wb_mask >>= 8;
} while (wb_mask & 0xff);
rc = xen_host_pci_set_block(&s->real_device, addr + index,
(uint8_t *)&val + index, len);
if (rc < 0) {
XEN_PT_ERR(d, "pci_write_block failed. return value: %d.\n", rc);
}
}
}
| false | qemu | c25bbf1545a53ac051f9e51d4140e397660c10ae | static void xen_pt_pci_write_config(PCIDevice *d, uint32_t addr,
uint32_t val, int len)
{
XenPCIPassthroughState *s = DO_UPCAST(XenPCIPassthroughState, dev, d);
int index = 0;
XenPTRegGroup *reg_grp_entry = NULL;
int rc = 0;
uint32_t read_val = 0, wb_mask;
int emul_len = 0;
XenPTReg *reg_entry = NULL;
uint32_t find_addr = addr;
XenPTRegInfo *reg = NULL;
if (xen_pt_pci_config_access_check(d, addr, len)) {
return;
}
XEN_PT_LOG_CONFIG(d, addr, val, len);
index = xen_pt_bar_offset_to_index(addr);
if ((index >= 0) && (val > 0 && val < XEN_PT_BAR_ALLF) &&
(s->bases[index].bar_flag == XEN_PT_BAR_FLAG_UNUSED)) {
XEN_PT_WARN(d, "Guest attempt to set address to unused Base Address "
"Register. (addr: 0x%02x, len: %d)\n", addr, len);
}
reg_grp_entry = xen_pt_find_reg_grp(s, addr);
if (reg_grp_entry) {
if (reg_grp_entry->reg_grp->grp_type == XEN_PT_GRP_TYPE_HARDWIRED) {
XEN_PT_WARN(d, "Access to 0-Hardwired register. "
"(addr: 0x%02x, len: %d)\n", addr, len);
return;
}
}
rc = xen_host_pci_get_block(&s->real_device, addr,
(uint8_t *)&read_val, len);
if (rc < 0) {
XEN_PT_ERR(d, "pci_read_block failed. return value: %d.\n", rc);
memset(&read_val, 0xff, len);
wb_mask = 0;
} else {
wb_mask = 0xFFFFFFFF >> ((4 - len) << 3);
}
if (reg_grp_entry == NULL) {
goto out;
}
memory_region_transaction_begin();
pci_default_write_config(d, addr, val, len);
read_val <<= (addr & 3) << 3;
val <<= (addr & 3) << 3;
emul_len = len;
while (emul_len > 0) {
reg_entry = xen_pt_find_reg(reg_grp_entry, find_addr);
if (reg_entry) {
reg = reg_entry->reg;
uint32_t real_offset = reg_grp_entry->base_offset + reg->offset;
uint32_t valid_mask = 0xFFFFFFFF >> ((4 - emul_len) << 3);
uint8_t *ptr_val = NULL;
valid_mask <<= (find_addr - real_offset) << 3;
ptr_val = (uint8_t *)&val + (real_offset & 3);
if (reg->emu_mask == (0xFFFFFFFF >> ((4 - reg->size) << 3))) {
wb_mask &= ~((reg->emu_mask
>> ((find_addr - real_offset) << 3))
<< ((len - emul_len) << 3));
}
switch (reg->size) {
case 1:
if (reg->u.b.write) {
rc = reg->u.b.write(s, reg_entry, ptr_val,
read_val >> ((real_offset & 3) << 3),
valid_mask);
}
break;
case 2:
if (reg->u.w.write) {
rc = reg->u.w.write(s, reg_entry, (uint16_t *)ptr_val,
(read_val >> ((real_offset & 3) << 3)),
valid_mask);
}
break;
case 4:
if (reg->u.dw.write) {
rc = reg->u.dw.write(s, reg_entry, (uint32_t *)ptr_val,
(read_val >> ((real_offset & 3) << 3)),
valid_mask);
}
break;
}
if (rc < 0) {
xen_shutdown_fatal_error("Internal error: Invalid write"
" emulation. (%s, rc: %d)\n",
__func__, rc);
return;
}
emul_len -= reg->size;
if (emul_len > 0) {
find_addr = real_offset + reg->size;
}
} else {
emul_len--;
find_addr++;
}
}
val >>= (addr & 3) << 3;
memory_region_transaction_commit();
out:
for (index = 0; wb_mask; index += len) {
while (!(wb_mask & 0xff)) {
index++;
wb_mask >>= 8;
}
len = 0;
do {
len++;
wb_mask >>= 8;
} while (wb_mask & 0xff);
rc = xen_host_pci_set_block(&s->real_device, addr + index,
(uint8_t *)&val + index, len);
if (rc < 0) {
XEN_PT_ERR(d, "pci_write_block failed. return value: %d.\n", rc);
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(PCIDevice *VAR_0, uint32_t VAR_1,
uint32_t VAR_2, int VAR_3)
{
XenPCIPassthroughState *s = DO_UPCAST(XenPCIPassthroughState, dev, VAR_0);
int VAR_4 = 0;
XenPTRegGroup *reg_grp_entry = NULL;
int VAR_5 = 0;
uint32_t read_val = 0, wb_mask;
int VAR_6 = 0;
XenPTReg *reg_entry = NULL;
uint32_t find_addr = VAR_1;
XenPTRegInfo *reg = NULL;
if (xen_pt_pci_config_access_check(VAR_0, VAR_1, VAR_3)) {
return;
}
XEN_PT_LOG_CONFIG(VAR_0, VAR_1, VAR_2, VAR_3);
VAR_4 = xen_pt_bar_offset_to_index(VAR_1);
if ((VAR_4 >= 0) && (VAR_2 > 0 && VAR_2 < XEN_PT_BAR_ALLF) &&
(s->bases[VAR_4].bar_flag == XEN_PT_BAR_FLAG_UNUSED)) {
XEN_PT_WARN(VAR_0, "Guest attempt to set address to unused Base Address "
"Register. (VAR_1: 0x%02x, VAR_3: %VAR_0)\n", VAR_1, VAR_3);
}
reg_grp_entry = xen_pt_find_reg_grp(s, VAR_1);
if (reg_grp_entry) {
if (reg_grp_entry->reg_grp->grp_type == XEN_PT_GRP_TYPE_HARDWIRED) {
XEN_PT_WARN(VAR_0, "Access to 0-Hardwired register. "
"(VAR_1: 0x%02x, VAR_3: %VAR_0)\n", VAR_1, VAR_3);
return;
}
}
VAR_5 = xen_host_pci_get_block(&s->real_device, VAR_1,
(uint8_t *)&read_val, VAR_3);
if (VAR_5 < 0) {
XEN_PT_ERR(VAR_0, "pci_read_block failed. return value: %VAR_0.\n", VAR_5);
memset(&read_val, 0xff, VAR_3);
wb_mask = 0;
} else {
wb_mask = 0xFFFFFFFF >> ((4 - VAR_3) << 3);
}
if (reg_grp_entry == NULL) {
goto out;
}
memory_region_transaction_begin();
pci_default_write_config(VAR_0, VAR_1, VAR_2, VAR_3);
read_val <<= (VAR_1 & 3) << 3;
VAR_2 <<= (VAR_1 & 3) << 3;
VAR_6 = VAR_3;
while (VAR_6 > 0) {
reg_entry = xen_pt_find_reg(reg_grp_entry, find_addr);
if (reg_entry) {
reg = reg_entry->reg;
uint32_t real_offset = reg_grp_entry->base_offset + reg->offset;
uint32_t valid_mask = 0xFFFFFFFF >> ((4 - VAR_6) << 3);
uint8_t *ptr_val = NULL;
valid_mask <<= (find_addr - real_offset) << 3;
ptr_val = (uint8_t *)&VAR_2 + (real_offset & 3);
if (reg->emu_mask == (0xFFFFFFFF >> ((4 - reg->size) << 3))) {
wb_mask &= ~((reg->emu_mask
>> ((find_addr - real_offset) << 3))
<< ((VAR_3 - VAR_6) << 3));
}
switch (reg->size) {
case 1:
if (reg->u.b.write) {
VAR_5 = reg->u.b.write(s, reg_entry, ptr_val,
read_val >> ((real_offset & 3) << 3),
valid_mask);
}
break;
case 2:
if (reg->u.w.write) {
VAR_5 = reg->u.w.write(s, reg_entry, (uint16_t *)ptr_val,
(read_val >> ((real_offset & 3) << 3)),
valid_mask);
}
break;
case 4:
if (reg->u.dw.write) {
VAR_5 = reg->u.dw.write(s, reg_entry, (uint32_t *)ptr_val,
(read_val >> ((real_offset & 3) << 3)),
valid_mask);
}
break;
}
if (VAR_5 < 0) {
xen_shutdown_fatal_error("Internal error: Invalid write"
" emulation. (%s, VAR_5: %VAR_0)\n",
__func__, VAR_5);
return;
}
VAR_6 -= reg->size;
if (VAR_6 > 0) {
find_addr = real_offset + reg->size;
}
} else {
VAR_6--;
find_addr++;
}
}
VAR_2 >>= (VAR_1 & 3) << 3;
memory_region_transaction_commit();
out:
for (VAR_4 = 0; wb_mask; VAR_4 += VAR_3) {
while (!(wb_mask & 0xff)) {
VAR_4++;
wb_mask >>= 8;
}
VAR_3 = 0;
do {
VAR_3++;
wb_mask >>= 8;
} while (wb_mask & 0xff);
VAR_5 = xen_host_pci_set_block(&s->real_device, VAR_1 + VAR_4,
(uint8_t *)&VAR_2 + VAR_4, VAR_3);
if (VAR_5 < 0) {
XEN_PT_ERR(VAR_0, "pci_write_block failed. return value: %VAR_0.\n", VAR_5);
}
}
}
| [
"static void FUNC_0(PCIDevice *VAR_0, uint32_t VAR_1,\nuint32_t VAR_2, int VAR_3)\n{",
"XenPCIPassthroughState *s = DO_UPCAST(XenPCIPassthroughState, dev, VAR_0);",
"int VAR_4 = 0;",
"XenPTRegGroup *reg_grp_entry = NULL;",
"int VAR_5 = 0;",
"uint32_t read_val = 0, wb_mask;",
"int VAR_6 = 0;",
"XenPTReg *reg_entry = NULL;",
"uint32_t find_addr = VAR_1;",
"XenPTRegInfo *reg = NULL;",
"if (xen_pt_pci_config_access_check(VAR_0, VAR_1, VAR_3)) {",
"return;",
"}",
"XEN_PT_LOG_CONFIG(VAR_0, VAR_1, VAR_2, VAR_3);",
"VAR_4 = xen_pt_bar_offset_to_index(VAR_1);",
"if ((VAR_4 >= 0) && (VAR_2 > 0 && VAR_2 < XEN_PT_BAR_ALLF) &&\n(s->bases[VAR_4].bar_flag == XEN_PT_BAR_FLAG_UNUSED)) {",
"XEN_PT_WARN(VAR_0, \"Guest attempt to set address to unused Base Address \"\n\"Register. (VAR_1: 0x%02x, VAR_3: %VAR_0)\\n\", VAR_1, VAR_3);",
"}",
"reg_grp_entry = xen_pt_find_reg_grp(s, VAR_1);",
"if (reg_grp_entry) {",
"if (reg_grp_entry->reg_grp->grp_type == XEN_PT_GRP_TYPE_HARDWIRED) {",
"XEN_PT_WARN(VAR_0, \"Access to 0-Hardwired register. \"\n\"(VAR_1: 0x%02x, VAR_3: %VAR_0)\\n\", VAR_1, VAR_3);",
"return;",
"}",
"}",
"VAR_5 = xen_host_pci_get_block(&s->real_device, VAR_1,\n(uint8_t *)&read_val, VAR_3);",
"if (VAR_5 < 0) {",
"XEN_PT_ERR(VAR_0, \"pci_read_block failed. return value: %VAR_0.\\n\", VAR_5);",
"memset(&read_val, 0xff, VAR_3);",
"wb_mask = 0;",
"} else {",
"wb_mask = 0xFFFFFFFF >> ((4 - VAR_3) << 3);",
"}",
"if (reg_grp_entry == NULL) {",
"goto out;",
"}",
"memory_region_transaction_begin();",
"pci_default_write_config(VAR_0, VAR_1, VAR_2, VAR_3);",
"read_val <<= (VAR_1 & 3) << 3;",
"VAR_2 <<= (VAR_1 & 3) << 3;",
"VAR_6 = VAR_3;",
"while (VAR_6 > 0) {",
"reg_entry = xen_pt_find_reg(reg_grp_entry, find_addr);",
"if (reg_entry) {",
"reg = reg_entry->reg;",
"uint32_t real_offset = reg_grp_entry->base_offset + reg->offset;",
"uint32_t valid_mask = 0xFFFFFFFF >> ((4 - VAR_6) << 3);",
"uint8_t *ptr_val = NULL;",
"valid_mask <<= (find_addr - real_offset) << 3;",
"ptr_val = (uint8_t *)&VAR_2 + (real_offset & 3);",
"if (reg->emu_mask == (0xFFFFFFFF >> ((4 - reg->size) << 3))) {",
"wb_mask &= ~((reg->emu_mask\n>> ((find_addr - real_offset) << 3))\n<< ((VAR_3 - VAR_6) << 3));",
"}",
"switch (reg->size) {",
"case 1:\nif (reg->u.b.write) {",
"VAR_5 = reg->u.b.write(s, reg_entry, ptr_val,\nread_val >> ((real_offset & 3) << 3),\nvalid_mask);",
"}",
"break;",
"case 2:\nif (reg->u.w.write) {",
"VAR_5 = reg->u.w.write(s, reg_entry, (uint16_t *)ptr_val,\n(read_val >> ((real_offset & 3) << 3)),\nvalid_mask);",
"}",
"break;",
"case 4:\nif (reg->u.dw.write) {",
"VAR_5 = reg->u.dw.write(s, reg_entry, (uint32_t *)ptr_val,\n(read_val >> ((real_offset & 3) << 3)),\nvalid_mask);",
"}",
"break;",
"}",
"if (VAR_5 < 0) {",
"xen_shutdown_fatal_error(\"Internal error: Invalid write\"\n\" emulation. (%s, VAR_5: %VAR_0)\\n\",\n__func__, VAR_5);",
"return;",
"}",
"VAR_6 -= reg->size;",
"if (VAR_6 > 0) {",
"find_addr = real_offset + reg->size;",
"}",
"} else {",
"VAR_6--;",
"find_addr++;",
"}",
"}",
"VAR_2 >>= (VAR_1 & 3) << 3;",
"memory_region_transaction_commit();",
"out:\nfor (VAR_4 = 0; wb_mask; VAR_4 += VAR_3) {",
"while (!(wb_mask & 0xff)) {",
"VAR_4++;",
"wb_mask >>= 8;",
"}",
"VAR_3 = 0;",
"do {",
"VAR_3++;",
"wb_mask >>= 8;",
"} while (wb_mask & 0xff);",
"VAR_5 = xen_host_pci_set_block(&s->real_device, VAR_1 + VAR_4,\n(uint8_t *)&VAR_2 + VAR_4, VAR_3);",
"if (VAR_5 < 0) {",
"XEN_PT_ERR(VAR_0, \"pci_write_block failed. return value: %VAR_0.\\n\", VAR_5);",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
35
],
[
41
],
[
43,
45
],
[
47,
49
],
[
51
],
[
57
],
[
59
],
[
63
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
79,
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
117
],
[
119
],
[
121
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
145
],
[
147
],
[
149
],
[
151,
153,
155
],
[
157
],
[
163
],
[
165,
167
],
[
169,
171,
173
],
[
175
],
[
177
],
[
179,
181
],
[
183,
185,
187
],
[
189
],
[
191
],
[
193,
195
],
[
197,
199,
201
],
[
203
],
[
205
],
[
207
],
[
211
],
[
213,
215,
217
],
[
219
],
[
221
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
241
],
[
243
],
[
245
],
[
247
],
[
253
],
[
257
],
[
261,
263
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285,
287
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
]
] |
1,762 | static void test_hash_base64(void)
{
size_t i;
g_assert(qcrypto_init(NULL) == 0);
for (i = 0; i < G_N_ELEMENTS(expected_outputs) ; i++) {
int ret;
char *digest;
ret = qcrypto_hash_base64(i,
INPUT_TEXT,
strlen(INPUT_TEXT),
&digest,
NULL);
g_assert(ret == 0);
g_assert(g_str_equal(digest, expected_outputs_b64[i]));
g_free(digest);
}
}
| false | qemu | 0c16c056a4f9dec18fdd56feec82a5db9ff3c15e | static void test_hash_base64(void)
{
size_t i;
g_assert(qcrypto_init(NULL) == 0);
for (i = 0; i < G_N_ELEMENTS(expected_outputs) ; i++) {
int ret;
char *digest;
ret = qcrypto_hash_base64(i,
INPUT_TEXT,
strlen(INPUT_TEXT),
&digest,
NULL);
g_assert(ret == 0);
g_assert(g_str_equal(digest, expected_outputs_b64[i]));
g_free(digest);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
size_t i;
g_assert(qcrypto_init(NULL) == 0);
for (i = 0; i < G_N_ELEMENTS(expected_outputs) ; i++) {
int ret;
char *digest;
ret = qcrypto_hash_base64(i,
INPUT_TEXT,
strlen(INPUT_TEXT),
&digest,
NULL);
g_assert(ret == 0);
g_assert(g_str_equal(digest, expected_outputs_b64[i]));
g_free(digest);
}
}
| [
"static void FUNC_0(void)\n{",
"size_t i;",
"g_assert(qcrypto_init(NULL) == 0);",
"for (i = 0; i < G_N_ELEMENTS(expected_outputs) ; i++) {",
"int ret;",
"char *digest;",
"ret = qcrypto_hash_base64(i,\nINPUT_TEXT,\nstrlen(INPUT_TEXT),\n&digest,\nNULL);",
"g_assert(ret == 0);",
"g_assert(g_str_equal(digest, expected_outputs_b64[i]));",
"g_free(digest);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21,
23,
25,
27,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
]
] |
1,763 | static void virtio_ccw_serial_realize(VirtioCcwDevice *ccw_dev, Error **errp)
{
VirtioSerialCcw *dev = VIRTIO_SERIAL_CCW(ccw_dev);
DeviceState *vdev = DEVICE(&dev->vdev);
DeviceState *proxy = DEVICE(ccw_dev);
Error *err = NULL;
char *bus_name;
/*
* For command line compatibility, this sets the virtio-serial-device bus
* name as before.
*/
if (proxy->id) {
bus_name = g_strdup_printf("%s.0", proxy->id);
virtio_device_set_child_bus_name(VIRTIO_DEVICE(vdev), bus_name);
g_free(bus_name);
}
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
if (err) {
error_propagate(errp, err);
}
}
| false | qemu | 621ff94d5074d88253a5818c6b9c4db718fbfc65 | static void virtio_ccw_serial_realize(VirtioCcwDevice *ccw_dev, Error **errp)
{
VirtioSerialCcw *dev = VIRTIO_SERIAL_CCW(ccw_dev);
DeviceState *vdev = DEVICE(&dev->vdev);
DeviceState *proxy = DEVICE(ccw_dev);
Error *err = NULL;
char *bus_name;
if (proxy->id) {
bus_name = g_strdup_printf("%s.0", proxy->id);
virtio_device_set_child_bus_name(VIRTIO_DEVICE(vdev), bus_name);
g_free(bus_name);
}
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
if (err) {
error_propagate(errp, err);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(VirtioCcwDevice *VAR_0, Error **VAR_1)
{
VirtioSerialCcw *dev = VIRTIO_SERIAL_CCW(VAR_0);
DeviceState *vdev = DEVICE(&dev->vdev);
DeviceState *proxy = DEVICE(VAR_0);
Error *err = NULL;
char *VAR_2;
if (proxy->id) {
VAR_2 = g_strdup_printf("%s.0", proxy->id);
virtio_device_set_child_bus_name(VIRTIO_DEVICE(vdev), VAR_2);
g_free(VAR_2);
}
qdev_set_parent_bus(vdev, BUS(&VAR_0->bus));
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
if (err) {
error_propagate(VAR_1, err);
}
}
| [
"static void FUNC_0(VirtioCcwDevice *VAR_0, Error **VAR_1)\n{",
"VirtioSerialCcw *dev = VIRTIO_SERIAL_CCW(VAR_0);",
"DeviceState *vdev = DEVICE(&dev->vdev);",
"DeviceState *proxy = DEVICE(VAR_0);",
"Error *err = NULL;",
"char *VAR_2;",
"if (proxy->id) {",
"VAR_2 = g_strdup_printf(\"%s.0\", proxy->id);",
"virtio_device_set_child_bus_name(VIRTIO_DEVICE(vdev), VAR_2);",
"g_free(VAR_2);",
"}",
"qdev_set_parent_bus(vdev, BUS(&VAR_0->bus));",
"object_property_set_bool(OBJECT(vdev), true, \"realized\", &err);",
"if (err) {",
"error_propagate(VAR_1, err);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
]
] |
1,764 | uint32_t kvmppc_get_vmx(void)
{
return kvmppc_read_int_cpu_dt("ibm,vmx");
}
| false | qemu | 3f2ca480eb872b4946baf77f756236b637a5b15a | uint32_t kvmppc_get_vmx(void)
{
return kvmppc_read_int_cpu_dt("ibm,vmx");
}
| {
"code": [],
"line_no": []
} | uint32_t FUNC_0(void)
{
return kvmppc_read_int_cpu_dt("ibm,vmx");
}
| [
"uint32_t FUNC_0(void)\n{",
"return kvmppc_read_int_cpu_dt(\"ibm,vmx\");",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
1,765 | static void check_reserved_space (target_phys_addr_t *start,
target_phys_addr_t *length)
{
target_phys_addr_t begin = *start;
target_phys_addr_t end = *start + *length;
if (end >= 0x1e000000LL && end < 0x1f100000LL)
end = 0x1e000000LL;
if (begin >= 0x1e000000LL && begin < 0x1f100000LL)
begin = 0x1f100000LL;
if (end >= 0x1fc00000LL && end < 0x1fd00000LL)
end = 0x1fc00000LL;
if (begin >= 0x1fc00000LL && begin < 0x1fd00000LL)
begin = 0x1fd00000LL;
/* XXX: This is broken when a reserved range splits the requested range */
if (end >= 0x1f100000LL && begin < 0x1e000000LL)
end = 0x1e000000LL;
if (end >= 0x1fd00000LL && begin < 0x1fc00000LL)
end = 0x1fc00000LL;
*start = begin;
*length = end - begin;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void check_reserved_space (target_phys_addr_t *start,
target_phys_addr_t *length)
{
target_phys_addr_t begin = *start;
target_phys_addr_t end = *start + *length;
if (end >= 0x1e000000LL && end < 0x1f100000LL)
end = 0x1e000000LL;
if (begin >= 0x1e000000LL && begin < 0x1f100000LL)
begin = 0x1f100000LL;
if (end >= 0x1fc00000LL && end < 0x1fd00000LL)
end = 0x1fc00000LL;
if (begin >= 0x1fc00000LL && begin < 0x1fd00000LL)
begin = 0x1fd00000LL;
if (end >= 0x1f100000LL && begin < 0x1e000000LL)
end = 0x1e000000LL;
if (end >= 0x1fd00000LL && begin < 0x1fc00000LL)
end = 0x1fc00000LL;
*start = begin;
*length = end - begin;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0 (target_phys_addr_t *VAR_0,
target_phys_addr_t *VAR_1)
{
target_phys_addr_t begin = *VAR_0;
target_phys_addr_t end = *VAR_0 + *VAR_1;
if (end >= 0x1e000000LL && end < 0x1f100000LL)
end = 0x1e000000LL;
if (begin >= 0x1e000000LL && begin < 0x1f100000LL)
begin = 0x1f100000LL;
if (end >= 0x1fc00000LL && end < 0x1fd00000LL)
end = 0x1fc00000LL;
if (begin >= 0x1fc00000LL && begin < 0x1fd00000LL)
begin = 0x1fd00000LL;
if (end >= 0x1f100000LL && begin < 0x1e000000LL)
end = 0x1e000000LL;
if (end >= 0x1fd00000LL && begin < 0x1fc00000LL)
end = 0x1fc00000LL;
*VAR_0 = begin;
*VAR_1 = end - begin;
}
| [
"static void FUNC_0 (target_phys_addr_t *VAR_0,\ntarget_phys_addr_t *VAR_1)\n{",
"target_phys_addr_t begin = *VAR_0;",
"target_phys_addr_t end = *VAR_0 + *VAR_1;",
"if (end >= 0x1e000000LL && end < 0x1f100000LL)\nend = 0x1e000000LL;",
"if (begin >= 0x1e000000LL && begin < 0x1f100000LL)\nbegin = 0x1f100000LL;",
"if (end >= 0x1fc00000LL && end < 0x1fd00000LL)\nend = 0x1fc00000LL;",
"if (begin >= 0x1fc00000LL && begin < 0x1fd00000LL)\nbegin = 0x1fd00000LL;",
"if (end >= 0x1f100000LL && begin < 0x1e000000LL)\nend = 0x1e000000LL;",
"if (end >= 0x1fd00000LL && begin < 0x1fc00000LL)\nend = 0x1fc00000LL;",
"*VAR_0 = begin;",
"*VAR_1 = end - begin;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13,
15
],
[
17,
19
],
[
21,
23
],
[
25,
27
],
[
31,
33
],
[
35,
37
],
[
41
],
[
43
],
[
45
]
] |
1,766 | CharDriverState *qemu_chr_open_msmouse(void)
{
CharDriverState *chr;
chr = g_malloc0(sizeof(CharDriverState));
chr->chr_write = msmouse_chr_write;
chr->chr_close = msmouse_chr_close;
chr->explicit_be_open = true;
qemu_add_mouse_event_handler(msmouse_event, chr, 0, "QEMU Microsoft Mouse");
return chr;
}
| false | qemu | db39fcf1f690b02d612e2bfc00980700887abe03 | CharDriverState *qemu_chr_open_msmouse(void)
{
CharDriverState *chr;
chr = g_malloc0(sizeof(CharDriverState));
chr->chr_write = msmouse_chr_write;
chr->chr_close = msmouse_chr_close;
chr->explicit_be_open = true;
qemu_add_mouse_event_handler(msmouse_event, chr, 0, "QEMU Microsoft Mouse");
return chr;
}
| {
"code": [],
"line_no": []
} | CharDriverState *FUNC_0(void)
{
CharDriverState *chr;
chr = g_malloc0(sizeof(CharDriverState));
chr->chr_write = msmouse_chr_write;
chr->chr_close = msmouse_chr_close;
chr->explicit_be_open = true;
qemu_add_mouse_event_handler(msmouse_event, chr, 0, "QEMU Microsoft Mouse");
return chr;
}
| [
"CharDriverState *FUNC_0(void)\n{",
"CharDriverState *chr;",
"chr = g_malloc0(sizeof(CharDriverState));",
"chr->chr_write = msmouse_chr_write;",
"chr->chr_close = msmouse_chr_close;",
"chr->explicit_be_open = true;",
"qemu_add_mouse_event_handler(msmouse_event, chr, 0, \"QEMU Microsoft Mouse\");",
"return chr;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23
],
[
25
]
] |
1,767 | void vfio_pci_write_config(PCIDevice *pdev,
uint32_t addr, uint32_t val, int len)
{
VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
uint32_t val_le = cpu_to_le32(val);
trace_vfio_pci_write_config(vdev->vbasedev.name, addr, val, len);
/* Write everything to VFIO, let it filter out what we can't write */
if (pwrite(vdev->vbasedev.fd, &val_le, len, vdev->config_offset + addr)
!= len) {
error_report("%s(%04x:%02x:%02x.%x, 0x%x, 0x%x, 0x%x) failed: %m",
__func__, vdev->host.domain, vdev->host.bus,
vdev->host.slot, vdev->host.function, addr, val, len);
}
/* MSI/MSI-X Enabling/Disabling */
if (pdev->cap_present & QEMU_PCI_CAP_MSI &&
ranges_overlap(addr, len, pdev->msi_cap, vdev->msi_cap_size)) {
int is_enabled, was_enabled = msi_enabled(pdev);
pci_default_write_config(pdev, addr, val, len);
is_enabled = msi_enabled(pdev);
if (!was_enabled) {
if (is_enabled) {
vfio_msi_enable(vdev);
}
} else {
if (!is_enabled) {
vfio_msi_disable(vdev);
} else {
vfio_update_msi(vdev);
}
}
} else if (pdev->cap_present & QEMU_PCI_CAP_MSIX &&
ranges_overlap(addr, len, pdev->msix_cap, MSIX_CAP_LENGTH)) {
int is_enabled, was_enabled = msix_enabled(pdev);
pci_default_write_config(pdev, addr, val, len);
is_enabled = msix_enabled(pdev);
if (!was_enabled && is_enabled) {
vfio_msix_enable(vdev);
} else if (was_enabled && !is_enabled) {
vfio_msix_disable(vdev);
}
} else {
/* Write everything to QEMU to keep emulated bits correct */
pci_default_write_config(pdev, addr, val, len);
}
}
| false | qemu | 7df9381b7aa56c897e344f3bfe43bf5848bbd3e0 | void vfio_pci_write_config(PCIDevice *pdev,
uint32_t addr, uint32_t val, int len)
{
VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
uint32_t val_le = cpu_to_le32(val);
trace_vfio_pci_write_config(vdev->vbasedev.name, addr, val, len);
if (pwrite(vdev->vbasedev.fd, &val_le, len, vdev->config_offset + addr)
!= len) {
error_report("%s(%04x:%02x:%02x.%x, 0x%x, 0x%x, 0x%x) failed: %m",
__func__, vdev->host.domain, vdev->host.bus,
vdev->host.slot, vdev->host.function, addr, val, len);
}
if (pdev->cap_present & QEMU_PCI_CAP_MSI &&
ranges_overlap(addr, len, pdev->msi_cap, vdev->msi_cap_size)) {
int is_enabled, was_enabled = msi_enabled(pdev);
pci_default_write_config(pdev, addr, val, len);
is_enabled = msi_enabled(pdev);
if (!was_enabled) {
if (is_enabled) {
vfio_msi_enable(vdev);
}
} else {
if (!is_enabled) {
vfio_msi_disable(vdev);
} else {
vfio_update_msi(vdev);
}
}
} else if (pdev->cap_present & QEMU_PCI_CAP_MSIX &&
ranges_overlap(addr, len, pdev->msix_cap, MSIX_CAP_LENGTH)) {
int is_enabled, was_enabled = msix_enabled(pdev);
pci_default_write_config(pdev, addr, val, len);
is_enabled = msix_enabled(pdev);
if (!was_enabled && is_enabled) {
vfio_msix_enable(vdev);
} else if (was_enabled && !is_enabled) {
vfio_msix_disable(vdev);
}
} else {
pci_default_write_config(pdev, addr, val, len);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(PCIDevice *VAR_0,
uint32_t VAR_1, uint32_t VAR_2, int VAR_3)
{
VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, VAR_0, VAR_0);
uint32_t val_le = cpu_to_le32(VAR_2);
trace_vfio_pci_write_config(vdev->vbasedev.name, VAR_1, VAR_2, VAR_3);
if (pwrite(vdev->vbasedev.fd, &val_le, VAR_3, vdev->config_offset + VAR_1)
!= VAR_3) {
error_report("%s(%04x:%02x:%02x.%x, 0x%x, 0x%x, 0x%x) failed: %m",
__func__, vdev->host.domain, vdev->host.bus,
vdev->host.slot, vdev->host.function, VAR_1, VAR_2, VAR_3);
}
if (VAR_0->cap_present & QEMU_PCI_CAP_MSI &&
ranges_overlap(VAR_1, VAR_3, VAR_0->msi_cap, vdev->msi_cap_size)) {
int VAR_6, VAR_6 = msi_enabled(VAR_0);
pci_default_write_config(VAR_0, VAR_1, VAR_2, VAR_3);
VAR_6 = msi_enabled(VAR_0);
if (!VAR_6) {
if (VAR_6) {
vfio_msi_enable(vdev);
}
} else {
if (!VAR_6) {
vfio_msi_disable(vdev);
} else {
vfio_update_msi(vdev);
}
}
} else if (VAR_0->cap_present & QEMU_PCI_CAP_MSIX &&
ranges_overlap(VAR_1, VAR_3, VAR_0->msix_cap, MSIX_CAP_LENGTH)) {
int VAR_6, VAR_6 = msix_enabled(VAR_0);
pci_default_write_config(VAR_0, VAR_1, VAR_2, VAR_3);
VAR_6 = msix_enabled(VAR_0);
if (!VAR_6 && VAR_6) {
vfio_msix_enable(vdev);
} else if (VAR_6 && !VAR_6) {
vfio_msix_disable(vdev);
}
} else {
pci_default_write_config(VAR_0, VAR_1, VAR_2, VAR_3);
}
}
| [
"void FUNC_0(PCIDevice *VAR_0,\nuint32_t VAR_1, uint32_t VAR_2, int VAR_3)\n{",
"VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, VAR_0, VAR_0);",
"uint32_t val_le = cpu_to_le32(VAR_2);",
"trace_vfio_pci_write_config(vdev->vbasedev.name, VAR_1, VAR_2, VAR_3);",
"if (pwrite(vdev->vbasedev.fd, &val_le, VAR_3, vdev->config_offset + VAR_1)\n!= VAR_3) {",
"error_report(\"%s(%04x:%02x:%02x.%x, 0x%x, 0x%x, 0x%x) failed: %m\",\n__func__, vdev->host.domain, vdev->host.bus,\nvdev->host.slot, vdev->host.function, VAR_1, VAR_2, VAR_3);",
"}",
"if (VAR_0->cap_present & QEMU_PCI_CAP_MSI &&\nranges_overlap(VAR_1, VAR_3, VAR_0->msi_cap, vdev->msi_cap_size)) {",
"int VAR_6, VAR_6 = msi_enabled(VAR_0);",
"pci_default_write_config(VAR_0, VAR_1, VAR_2, VAR_3);",
"VAR_6 = msi_enabled(VAR_0);",
"if (!VAR_6) {",
"if (VAR_6) {",
"vfio_msi_enable(vdev);",
"}",
"} else {",
"if (!VAR_6) {",
"vfio_msi_disable(vdev);",
"} else {",
"vfio_update_msi(vdev);",
"}",
"}",
"} else if (VAR_0->cap_present & QEMU_PCI_CAP_MSIX &&",
"ranges_overlap(VAR_1, VAR_3, VAR_0->msix_cap, MSIX_CAP_LENGTH)) {",
"int VAR_6, VAR_6 = msix_enabled(VAR_0);",
"pci_default_write_config(VAR_0, VAR_1, VAR_2, VAR_3);",
"VAR_6 = msix_enabled(VAR_0);",
"if (!VAR_6 && VAR_6) {",
"vfio_msix_enable(vdev);",
"} else if (VAR_6 && !VAR_6) {",
"vfio_msix_disable(vdev);",
"}",
"} else {",
"pci_default_write_config(VAR_0, VAR_1, VAR_2, VAR_3);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
19,
21
],
[
23,
25,
27
],
[
29
],
[
35,
37
],
[
39
],
[
43
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
]
] |
1,768 | static int sap_fetch_packet(AVFormatContext *s, AVPacket *pkt)
{
struct SAPState *sap = s->priv_data;
int fd = url_get_file_handle(sap->ann_fd);
int n, ret;
fd_set rfds;
struct timeval tv;
uint8_t recvbuf[1500];
if (sap->eof)
return AVERROR_EOF;
while (1) {
FD_ZERO(&rfds);
FD_SET(fd, &rfds);
tv.tv_sec = tv.tv_usec = 0;
n = select(fd + 1, &rfds, NULL, NULL, &tv);
if (n <= 0 || !FD_ISSET(fd, &rfds))
break;
ret = url_read(sap->ann_fd, recvbuf, sizeof(recvbuf));
if (ret >= 8) {
uint16_t hash = AV_RB16(&recvbuf[2]);
/* Should ideally check the source IP address, too */
if (recvbuf[0] & 0x04 && hash == sap->hash) {
/* Stream deletion */
sap->eof = 1;
return AVERROR_EOF;
}
}
}
ret = av_read_frame(sap->sdp_ctx, pkt);
if (ret < 0)
return ret;
if (s->ctx_flags & AVFMTCTX_NOHEADER) {
while (sap->sdp_ctx->nb_streams > s->nb_streams) {
int i = s->nb_streams;
AVStream *st = av_new_stream(s, i);
if (!st) {
av_free_packet(pkt);
return AVERROR(ENOMEM);
}
avcodec_copy_context(st->codec, sap->sdp_ctx->streams[i]->codec);
st->time_base = sap->sdp_ctx->streams[i]->time_base;
}
}
return ret;
}
| false | FFmpeg | a8475bbdb64e638bd8161df9647876fd23f8a29a | static int sap_fetch_packet(AVFormatContext *s, AVPacket *pkt)
{
struct SAPState *sap = s->priv_data;
int fd = url_get_file_handle(sap->ann_fd);
int n, ret;
fd_set rfds;
struct timeval tv;
uint8_t recvbuf[1500];
if (sap->eof)
return AVERROR_EOF;
while (1) {
FD_ZERO(&rfds);
FD_SET(fd, &rfds);
tv.tv_sec = tv.tv_usec = 0;
n = select(fd + 1, &rfds, NULL, NULL, &tv);
if (n <= 0 || !FD_ISSET(fd, &rfds))
break;
ret = url_read(sap->ann_fd, recvbuf, sizeof(recvbuf));
if (ret >= 8) {
uint16_t hash = AV_RB16(&recvbuf[2]);
if (recvbuf[0] & 0x04 && hash == sap->hash) {
sap->eof = 1;
return AVERROR_EOF;
}
}
}
ret = av_read_frame(sap->sdp_ctx, pkt);
if (ret < 0)
return ret;
if (s->ctx_flags & AVFMTCTX_NOHEADER) {
while (sap->sdp_ctx->nb_streams > s->nb_streams) {
int i = s->nb_streams;
AVStream *st = av_new_stream(s, i);
if (!st) {
av_free_packet(pkt);
return AVERROR(ENOMEM);
}
avcodec_copy_context(st->codec, sap->sdp_ctx->streams[i]->codec);
st->time_base = sap->sdp_ctx->streams[i]->time_base;
}
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{
struct SAPState *VAR_2 = VAR_0->priv_data;
int VAR_3 = url_get_file_handle(VAR_2->ann_fd);
int VAR_4, VAR_5;
fd_set rfds;
struct timeval VAR_6;
uint8_t recvbuf[1500];
if (VAR_2->eof)
return AVERROR_EOF;
while (1) {
FD_ZERO(&rfds);
FD_SET(VAR_3, &rfds);
VAR_6.tv_sec = VAR_6.tv_usec = 0;
VAR_4 = select(VAR_3 + 1, &rfds, NULL, NULL, &VAR_6);
if (VAR_4 <= 0 || !FD_ISSET(VAR_3, &rfds))
break;
VAR_5 = url_read(VAR_2->ann_fd, recvbuf, sizeof(recvbuf));
if (VAR_5 >= 8) {
uint16_t hash = AV_RB16(&recvbuf[2]);
if (recvbuf[0] & 0x04 && hash == VAR_2->hash) {
VAR_2->eof = 1;
return AVERROR_EOF;
}
}
}
VAR_5 = av_read_frame(VAR_2->sdp_ctx, VAR_1);
if (VAR_5 < 0)
return VAR_5;
if (VAR_0->ctx_flags & AVFMTCTX_NOHEADER) {
while (VAR_2->sdp_ctx->nb_streams > VAR_0->nb_streams) {
int VAR_7 = VAR_0->nb_streams;
AVStream *st = av_new_stream(VAR_0, VAR_7);
if (!st) {
av_free_packet(VAR_1);
return AVERROR(ENOMEM);
}
avcodec_copy_context(st->codec, VAR_2->sdp_ctx->streams[VAR_7]->codec);
st->time_base = VAR_2->sdp_ctx->streams[VAR_7]->time_base;
}
}
return VAR_5;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{",
"struct SAPState *VAR_2 = VAR_0->priv_data;",
"int VAR_3 = url_get_file_handle(VAR_2->ann_fd);",
"int VAR_4, VAR_5;",
"fd_set rfds;",
"struct timeval VAR_6;",
"uint8_t recvbuf[1500];",
"if (VAR_2->eof)\nreturn AVERROR_EOF;",
"while (1) {",
"FD_ZERO(&rfds);",
"FD_SET(VAR_3, &rfds);",
"VAR_6.tv_sec = VAR_6.tv_usec = 0;",
"VAR_4 = select(VAR_3 + 1, &rfds, NULL, NULL, &VAR_6);",
"if (VAR_4 <= 0 || !FD_ISSET(VAR_3, &rfds))\nbreak;",
"VAR_5 = url_read(VAR_2->ann_fd, recvbuf, sizeof(recvbuf));",
"if (VAR_5 >= 8) {",
"uint16_t hash = AV_RB16(&recvbuf[2]);",
"if (recvbuf[0] & 0x04 && hash == VAR_2->hash) {",
"VAR_2->eof = 1;",
"return AVERROR_EOF;",
"}",
"}",
"}",
"VAR_5 = av_read_frame(VAR_2->sdp_ctx, VAR_1);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"if (VAR_0->ctx_flags & AVFMTCTX_NOHEADER) {",
"while (VAR_2->sdp_ctx->nb_streams > VAR_0->nb_streams) {",
"int VAR_7 = VAR_0->nb_streams;",
"AVStream *st = av_new_stream(VAR_0, VAR_7);",
"if (!st) {",
"av_free_packet(VAR_1);",
"return AVERROR(ENOMEM);",
"}",
"avcodec_copy_context(st->codec, VAR_2->sdp_ctx->streams[VAR_7]->codec);",
"st->time_base = VAR_2->sdp_ctx->streams[VAR_7]->time_base;",
"}",
"}",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
]
] |
1,769 | static void run_dependent_requests(BDRVQcowState *s, QCowL2Meta *m)
{
/* Take the request off the list of running requests */
if (m->nb_clusters != 0) {
QLIST_REMOVE(m, next_in_flight);
}
/* Restart all dependent requests */
if (!qemu_co_queue_empty(&m->dependent_requests)) {
qemu_co_mutex_unlock(&s->lock);
while(qemu_co_queue_next(&m->dependent_requests));
qemu_co_mutex_lock(&s->lock);
}
}
| false | qemu | e8ee5e4c476d5b0654d8f1271a2b7c065acc486e | static void run_dependent_requests(BDRVQcowState *s, QCowL2Meta *m)
{
if (m->nb_clusters != 0) {
QLIST_REMOVE(m, next_in_flight);
}
if (!qemu_co_queue_empty(&m->dependent_requests)) {
qemu_co_mutex_unlock(&s->lock);
while(qemu_co_queue_next(&m->dependent_requests));
qemu_co_mutex_lock(&s->lock);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(BDRVQcowState *VAR_0, QCowL2Meta *VAR_1)
{
if (VAR_1->nb_clusters != 0) {
QLIST_REMOVE(VAR_1, next_in_flight);
}
if (!qemu_co_queue_empty(&VAR_1->dependent_requests)) {
qemu_co_mutex_unlock(&VAR_0->lock);
while(qemu_co_queue_next(&VAR_1->dependent_requests));
qemu_co_mutex_lock(&VAR_0->lock);
}
}
| [
"static void FUNC_0(BDRVQcowState *VAR_0, QCowL2Meta *VAR_1)\n{",
"if (VAR_1->nb_clusters != 0) {",
"QLIST_REMOVE(VAR_1, next_in_flight);",
"}",
"if (!qemu_co_queue_empty(&VAR_1->dependent_requests)) {",
"qemu_co_mutex_unlock(&VAR_0->lock);",
"while(qemu_co_queue_next(&VAR_1->dependent_requests));",
"qemu_co_mutex_lock(&VAR_0->lock);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
9
],
[
11
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
1,771 | uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
uint32_t index, int reg)
{
struct kvm_cpuid2 *cpuid;
int max;
uint32_t ret = 0;
uint32_t cpuid_1_edx;
bool found = false;
max = 1;
while ((cpuid = try_get_cpuid(s, max)) == NULL) {
max *= 2;
}
struct kvm_cpuid_entry2 *entry = cpuid_find_entry(cpuid, function, index);
if (entry) {
found = true;
ret = cpuid_entry_get_reg(entry, reg);
}
/* Fixups for the data returned by KVM, below */
if (reg == R_EDX) {
switch (function) {
case 1:
/* KVM before 2.6.30 misreports the following features */
ret |= CPUID_MTRR | CPUID_PAT | CPUID_MCE | CPUID_MCA;
break;
case 0x80000001:
/* On Intel, kvm returns cpuid according to the Intel spec,
* so add missing bits according to the AMD spec:
*/
cpuid_1_edx = kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX);
ret |= cpuid_1_edx & CPUID_EXT2_AMD_ALIASES;
break;
}
}
g_free(cpuid);
/* fallback for older kernels */
if ((function == KVM_CPUID_FEATURES) && !found) {
ret = get_para_features(s);
}
return ret;
}
| false | qemu | dd87f8a690330777363f9a8680fce8f2ec544414 | uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
uint32_t index, int reg)
{
struct kvm_cpuid2 *cpuid;
int max;
uint32_t ret = 0;
uint32_t cpuid_1_edx;
bool found = false;
max = 1;
while ((cpuid = try_get_cpuid(s, max)) == NULL) {
max *= 2;
}
struct kvm_cpuid_entry2 *entry = cpuid_find_entry(cpuid, function, index);
if (entry) {
found = true;
ret = cpuid_entry_get_reg(entry, reg);
}
if (reg == R_EDX) {
switch (function) {
case 1:
ret |= CPUID_MTRR | CPUID_PAT | CPUID_MCE | CPUID_MCA;
break;
case 0x80000001:
cpuid_1_edx = kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX);
ret |= cpuid_1_edx & CPUID_EXT2_AMD_ALIASES;
break;
}
}
g_free(cpuid);
if ((function == KVM_CPUID_FEATURES) && !found) {
ret = get_para_features(s);
}
return ret;
}
| {
"code": [],
"line_no": []
} | uint32_t FUNC_0(KVMState *s, uint32_t function,
uint32_t index, int reg)
{
struct kvm_cpuid2 *VAR_0;
int VAR_1;
uint32_t ret = 0;
uint32_t cpuid_1_edx;
bool found = false;
VAR_1 = 1;
while ((VAR_0 = try_get_cpuid(s, VAR_1)) == NULL) {
VAR_1 *= 2;
}
struct kvm_cpuid_entry2 *VAR_2 = cpuid_find_entry(VAR_0, function, index);
if (VAR_2) {
found = true;
ret = cpuid_entry_get_reg(VAR_2, reg);
}
if (reg == R_EDX) {
switch (function) {
case 1:
ret |= CPUID_MTRR | CPUID_PAT | CPUID_MCE | CPUID_MCA;
break;
case 0x80000001:
cpuid_1_edx = FUNC_0(s, 1, 0, R_EDX);
ret |= cpuid_1_edx & CPUID_EXT2_AMD_ALIASES;
break;
}
}
g_free(VAR_0);
if ((function == KVM_CPUID_FEATURES) && !found) {
ret = get_para_features(s);
}
return ret;
}
| [
"uint32_t FUNC_0(KVMState *s, uint32_t function,\nuint32_t index, int reg)\n{",
"struct kvm_cpuid2 *VAR_0;",
"int VAR_1;",
"uint32_t ret = 0;",
"uint32_t cpuid_1_edx;",
"bool found = false;",
"VAR_1 = 1;",
"while ((VAR_0 = try_get_cpuid(s, VAR_1)) == NULL) {",
"VAR_1 *= 2;",
"}",
"struct kvm_cpuid_entry2 *VAR_2 = cpuid_find_entry(VAR_0, function, index);",
"if (VAR_2) {",
"found = true;",
"ret = cpuid_entry_get_reg(VAR_2, reg);",
"}",
"if (reg == R_EDX) {",
"switch (function) {",
"case 1:\nret |= CPUID_MTRR | CPUID_PAT | CPUID_MCE | CPUID_MCA;",
"break;",
"case 0x80000001:\ncpuid_1_edx = FUNC_0(s, 1, 0, R_EDX);",
"ret |= cpuid_1_edx & CPUID_EXT2_AMD_ALIASES;",
"break;",
"}",
"}",
"g_free(VAR_0);",
"if ((function == KVM_CPUID_FEATURES) && !found) {",
"ret = get_para_features(s);",
"}",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
45
],
[
47
],
[
49,
53
],
[
55
],
[
57,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
]
] |
1,772 | static abi_long do_socketcall(int num, abi_ulong vptr)
{
abi_long ret;
const int n = sizeof(abi_ulong);
switch(num) {
case SOCKOP_socket:
{
abi_ulong domain, type, protocol;
if (get_user_ual(domain, vptr)
|| get_user_ual(type, vptr + n)
|| get_user_ual(protocol, vptr + 2 * n))
return -TARGET_EFAULT;
ret = do_socket(domain, type, protocol);
}
break;
case SOCKOP_bind:
{
abi_ulong sockfd;
abi_ulong target_addr;
socklen_t addrlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(target_addr, vptr + n)
|| get_user_ual(addrlen, vptr + 2 * n))
return -TARGET_EFAULT;
ret = do_bind(sockfd, target_addr, addrlen);
}
break;
case SOCKOP_connect:
{
abi_ulong sockfd;
abi_ulong target_addr;
socklen_t addrlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(target_addr, vptr + n)
|| get_user_ual(addrlen, vptr + 2 * n))
return -TARGET_EFAULT;
ret = do_connect(sockfd, target_addr, addrlen);
}
break;
case SOCKOP_listen:
{
abi_ulong sockfd, backlog;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(backlog, vptr + n))
return -TARGET_EFAULT;
ret = get_errno(listen(sockfd, backlog));
}
break;
case SOCKOP_accept:
{
abi_ulong sockfd;
abi_ulong target_addr, target_addrlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(target_addr, vptr + n)
|| get_user_ual(target_addrlen, vptr + 2 * n))
return -TARGET_EFAULT;
ret = do_accept4(sockfd, target_addr, target_addrlen, 0);
}
break;
case SOCKOP_accept4:
{
abi_ulong sockfd;
abi_ulong target_addr, target_addrlen;
abi_ulong flags;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(target_addr, vptr + n)
|| get_user_ual(target_addrlen, vptr + 2 * n)
|| get_user_ual(flags, vptr + 3 * n)) {
return -TARGET_EFAULT;
}
ret = do_accept4(sockfd, target_addr, target_addrlen, flags);
}
break;
case SOCKOP_getsockname:
{
abi_ulong sockfd;
abi_ulong target_addr, target_addrlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(target_addr, vptr + n)
|| get_user_ual(target_addrlen, vptr + 2 * n))
return -TARGET_EFAULT;
ret = do_getsockname(sockfd, target_addr, target_addrlen);
}
break;
case SOCKOP_getpeername:
{
abi_ulong sockfd;
abi_ulong target_addr, target_addrlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(target_addr, vptr + n)
|| get_user_ual(target_addrlen, vptr + 2 * n))
return -TARGET_EFAULT;
ret = do_getpeername(sockfd, target_addr, target_addrlen);
}
break;
case SOCKOP_socketpair:
{
abi_ulong domain, type, protocol;
abi_ulong tab;
if (get_user_ual(domain, vptr)
|| get_user_ual(type, vptr + n)
|| get_user_ual(protocol, vptr + 2 * n)
|| get_user_ual(tab, vptr + 3 * n))
return -TARGET_EFAULT;
ret = do_socketpair(domain, type, protocol, tab);
}
break;
case SOCKOP_send:
{
abi_ulong sockfd;
abi_ulong msg;
size_t len;
abi_ulong flags;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(msg, vptr + n)
|| get_user_ual(len, vptr + 2 * n)
|| get_user_ual(flags, vptr + 3 * n))
return -TARGET_EFAULT;
ret = do_sendto(sockfd, msg, len, flags, 0, 0);
}
break;
case SOCKOP_recv:
{
abi_ulong sockfd;
abi_ulong msg;
size_t len;
abi_ulong flags;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(msg, vptr + n)
|| get_user_ual(len, vptr + 2 * n)
|| get_user_ual(flags, vptr + 3 * n))
return -TARGET_EFAULT;
ret = do_recvfrom(sockfd, msg, len, flags, 0, 0);
}
break;
case SOCKOP_sendto:
{
abi_ulong sockfd;
abi_ulong msg;
size_t len;
abi_ulong flags;
abi_ulong addr;
abi_ulong addrlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(msg, vptr + n)
|| get_user_ual(len, vptr + 2 * n)
|| get_user_ual(flags, vptr + 3 * n)
|| get_user_ual(addr, vptr + 4 * n)
|| get_user_ual(addrlen, vptr + 5 * n))
return -TARGET_EFAULT;
ret = do_sendto(sockfd, msg, len, flags, addr, addrlen);
}
break;
case SOCKOP_recvfrom:
{
abi_ulong sockfd;
abi_ulong msg;
size_t len;
abi_ulong flags;
abi_ulong addr;
socklen_t addrlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(msg, vptr + n)
|| get_user_ual(len, vptr + 2 * n)
|| get_user_ual(flags, vptr + 3 * n)
|| get_user_ual(addr, vptr + 4 * n)
|| get_user_ual(addrlen, vptr + 5 * n))
return -TARGET_EFAULT;
ret = do_recvfrom(sockfd, msg, len, flags, addr, addrlen);
}
break;
case SOCKOP_shutdown:
{
abi_ulong sockfd, how;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(how, vptr + n))
return -TARGET_EFAULT;
ret = get_errno(shutdown(sockfd, how));
}
break;
case SOCKOP_sendmsg:
case SOCKOP_recvmsg:
{
abi_ulong fd;
abi_ulong target_msg;
abi_ulong flags;
if (get_user_ual(fd, vptr)
|| get_user_ual(target_msg, vptr + n)
|| get_user_ual(flags, vptr + 2 * n))
return -TARGET_EFAULT;
ret = do_sendrecvmsg(fd, target_msg, flags,
(num == SOCKOP_sendmsg));
}
break;
case SOCKOP_setsockopt:
{
abi_ulong sockfd;
abi_ulong level;
abi_ulong optname;
abi_ulong optval;
abi_ulong optlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(level, vptr + n)
|| get_user_ual(optname, vptr + 2 * n)
|| get_user_ual(optval, vptr + 3 * n)
|| get_user_ual(optlen, vptr + 4 * n))
return -TARGET_EFAULT;
ret = do_setsockopt(sockfd, level, optname, optval, optlen);
}
break;
case SOCKOP_getsockopt:
{
abi_ulong sockfd;
abi_ulong level;
abi_ulong optname;
abi_ulong optval;
socklen_t optlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(level, vptr + n)
|| get_user_ual(optname, vptr + 2 * n)
|| get_user_ual(optval, vptr + 3 * n)
|| get_user_ual(optlen, vptr + 4 * n))
return -TARGET_EFAULT;
ret = do_getsockopt(sockfd, level, optname, optval, optlen);
}
break;
default:
gemu_log("Unsupported socketcall: %d\n", num);
ret = -TARGET_ENOSYS;
break;
}
return ret;
}
| false | qemu | 62dc90c668fc4e17639f594b70a1001780f59a9b | static abi_long do_socketcall(int num, abi_ulong vptr)
{
abi_long ret;
const int n = sizeof(abi_ulong);
switch(num) {
case SOCKOP_socket:
{
abi_ulong domain, type, protocol;
if (get_user_ual(domain, vptr)
|| get_user_ual(type, vptr + n)
|| get_user_ual(protocol, vptr + 2 * n))
return -TARGET_EFAULT;
ret = do_socket(domain, type, protocol);
}
break;
case SOCKOP_bind:
{
abi_ulong sockfd;
abi_ulong target_addr;
socklen_t addrlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(target_addr, vptr + n)
|| get_user_ual(addrlen, vptr + 2 * n))
return -TARGET_EFAULT;
ret = do_bind(sockfd, target_addr, addrlen);
}
break;
case SOCKOP_connect:
{
abi_ulong sockfd;
abi_ulong target_addr;
socklen_t addrlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(target_addr, vptr + n)
|| get_user_ual(addrlen, vptr + 2 * n))
return -TARGET_EFAULT;
ret = do_connect(sockfd, target_addr, addrlen);
}
break;
case SOCKOP_listen:
{
abi_ulong sockfd, backlog;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(backlog, vptr + n))
return -TARGET_EFAULT;
ret = get_errno(listen(sockfd, backlog));
}
break;
case SOCKOP_accept:
{
abi_ulong sockfd;
abi_ulong target_addr, target_addrlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(target_addr, vptr + n)
|| get_user_ual(target_addrlen, vptr + 2 * n))
return -TARGET_EFAULT;
ret = do_accept4(sockfd, target_addr, target_addrlen, 0);
}
break;
case SOCKOP_accept4:
{
abi_ulong sockfd;
abi_ulong target_addr, target_addrlen;
abi_ulong flags;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(target_addr, vptr + n)
|| get_user_ual(target_addrlen, vptr + 2 * n)
|| get_user_ual(flags, vptr + 3 * n)) {
return -TARGET_EFAULT;
}
ret = do_accept4(sockfd, target_addr, target_addrlen, flags);
}
break;
case SOCKOP_getsockname:
{
abi_ulong sockfd;
abi_ulong target_addr, target_addrlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(target_addr, vptr + n)
|| get_user_ual(target_addrlen, vptr + 2 * n))
return -TARGET_EFAULT;
ret = do_getsockname(sockfd, target_addr, target_addrlen);
}
break;
case SOCKOP_getpeername:
{
abi_ulong sockfd;
abi_ulong target_addr, target_addrlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(target_addr, vptr + n)
|| get_user_ual(target_addrlen, vptr + 2 * n))
return -TARGET_EFAULT;
ret = do_getpeername(sockfd, target_addr, target_addrlen);
}
break;
case SOCKOP_socketpair:
{
abi_ulong domain, type, protocol;
abi_ulong tab;
if (get_user_ual(domain, vptr)
|| get_user_ual(type, vptr + n)
|| get_user_ual(protocol, vptr + 2 * n)
|| get_user_ual(tab, vptr + 3 * n))
return -TARGET_EFAULT;
ret = do_socketpair(domain, type, protocol, tab);
}
break;
case SOCKOP_send:
{
abi_ulong sockfd;
abi_ulong msg;
size_t len;
abi_ulong flags;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(msg, vptr + n)
|| get_user_ual(len, vptr + 2 * n)
|| get_user_ual(flags, vptr + 3 * n))
return -TARGET_EFAULT;
ret = do_sendto(sockfd, msg, len, flags, 0, 0);
}
break;
case SOCKOP_recv:
{
abi_ulong sockfd;
abi_ulong msg;
size_t len;
abi_ulong flags;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(msg, vptr + n)
|| get_user_ual(len, vptr + 2 * n)
|| get_user_ual(flags, vptr + 3 * n))
return -TARGET_EFAULT;
ret = do_recvfrom(sockfd, msg, len, flags, 0, 0);
}
break;
case SOCKOP_sendto:
{
abi_ulong sockfd;
abi_ulong msg;
size_t len;
abi_ulong flags;
abi_ulong addr;
abi_ulong addrlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(msg, vptr + n)
|| get_user_ual(len, vptr + 2 * n)
|| get_user_ual(flags, vptr + 3 * n)
|| get_user_ual(addr, vptr + 4 * n)
|| get_user_ual(addrlen, vptr + 5 * n))
return -TARGET_EFAULT;
ret = do_sendto(sockfd, msg, len, flags, addr, addrlen);
}
break;
case SOCKOP_recvfrom:
{
abi_ulong sockfd;
abi_ulong msg;
size_t len;
abi_ulong flags;
abi_ulong addr;
socklen_t addrlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(msg, vptr + n)
|| get_user_ual(len, vptr + 2 * n)
|| get_user_ual(flags, vptr + 3 * n)
|| get_user_ual(addr, vptr + 4 * n)
|| get_user_ual(addrlen, vptr + 5 * n))
return -TARGET_EFAULT;
ret = do_recvfrom(sockfd, msg, len, flags, addr, addrlen);
}
break;
case SOCKOP_shutdown:
{
abi_ulong sockfd, how;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(how, vptr + n))
return -TARGET_EFAULT;
ret = get_errno(shutdown(sockfd, how));
}
break;
case SOCKOP_sendmsg:
case SOCKOP_recvmsg:
{
abi_ulong fd;
abi_ulong target_msg;
abi_ulong flags;
if (get_user_ual(fd, vptr)
|| get_user_ual(target_msg, vptr + n)
|| get_user_ual(flags, vptr + 2 * n))
return -TARGET_EFAULT;
ret = do_sendrecvmsg(fd, target_msg, flags,
(num == SOCKOP_sendmsg));
}
break;
case SOCKOP_setsockopt:
{
abi_ulong sockfd;
abi_ulong level;
abi_ulong optname;
abi_ulong optval;
abi_ulong optlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(level, vptr + n)
|| get_user_ual(optname, vptr + 2 * n)
|| get_user_ual(optval, vptr + 3 * n)
|| get_user_ual(optlen, vptr + 4 * n))
return -TARGET_EFAULT;
ret = do_setsockopt(sockfd, level, optname, optval, optlen);
}
break;
case SOCKOP_getsockopt:
{
abi_ulong sockfd;
abi_ulong level;
abi_ulong optname;
abi_ulong optval;
socklen_t optlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(level, vptr + n)
|| get_user_ual(optname, vptr + 2 * n)
|| get_user_ual(optval, vptr + 3 * n)
|| get_user_ual(optlen, vptr + 4 * n))
return -TARGET_EFAULT;
ret = do_getsockopt(sockfd, level, optname, optval, optlen);
}
break;
default:
gemu_log("Unsupported socketcall: %d\n", num);
ret = -TARGET_ENOSYS;
break;
}
return ret;
}
| {
"code": [],
"line_no": []
} | static abi_long FUNC_0(int num, abi_ulong vptr)
{
abi_long ret;
const int VAR_0 = sizeof(abi_ulong);
switch(num) {
case SOCKOP_socket:
{
abi_ulong domain, type, protocol;
if (get_user_ual(domain, vptr)
|| get_user_ual(type, vptr + VAR_0)
|| get_user_ual(protocol, vptr + 2 * VAR_0))
return -TARGET_EFAULT;
ret = do_socket(domain, type, protocol);
}
break;
case SOCKOP_bind:
{
abi_ulong sockfd;
abi_ulong target_addr;
socklen_t addrlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(target_addr, vptr + VAR_0)
|| get_user_ual(addrlen, vptr + 2 * VAR_0))
return -TARGET_EFAULT;
ret = do_bind(sockfd, target_addr, addrlen);
}
break;
case SOCKOP_connect:
{
abi_ulong sockfd;
abi_ulong target_addr;
socklen_t addrlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(target_addr, vptr + VAR_0)
|| get_user_ual(addrlen, vptr + 2 * VAR_0))
return -TARGET_EFAULT;
ret = do_connect(sockfd, target_addr, addrlen);
}
break;
case SOCKOP_listen:
{
abi_ulong sockfd, backlog;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(backlog, vptr + VAR_0))
return -TARGET_EFAULT;
ret = get_errno(listen(sockfd, backlog));
}
break;
case SOCKOP_accept:
{
abi_ulong sockfd;
abi_ulong target_addr, target_addrlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(target_addr, vptr + VAR_0)
|| get_user_ual(target_addrlen, vptr + 2 * VAR_0))
return -TARGET_EFAULT;
ret = do_accept4(sockfd, target_addr, target_addrlen, 0);
}
break;
case SOCKOP_accept4:
{
abi_ulong sockfd;
abi_ulong target_addr, target_addrlen;
abi_ulong flags;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(target_addr, vptr + VAR_0)
|| get_user_ual(target_addrlen, vptr + 2 * VAR_0)
|| get_user_ual(flags, vptr + 3 * VAR_0)) {
return -TARGET_EFAULT;
}
ret = do_accept4(sockfd, target_addr, target_addrlen, flags);
}
break;
case SOCKOP_getsockname:
{
abi_ulong sockfd;
abi_ulong target_addr, target_addrlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(target_addr, vptr + VAR_0)
|| get_user_ual(target_addrlen, vptr + 2 * VAR_0))
return -TARGET_EFAULT;
ret = do_getsockname(sockfd, target_addr, target_addrlen);
}
break;
case SOCKOP_getpeername:
{
abi_ulong sockfd;
abi_ulong target_addr, target_addrlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(target_addr, vptr + VAR_0)
|| get_user_ual(target_addrlen, vptr + 2 * VAR_0))
return -TARGET_EFAULT;
ret = do_getpeername(sockfd, target_addr, target_addrlen);
}
break;
case SOCKOP_socketpair:
{
abi_ulong domain, type, protocol;
abi_ulong tab;
if (get_user_ual(domain, vptr)
|| get_user_ual(type, vptr + VAR_0)
|| get_user_ual(protocol, vptr + 2 * VAR_0)
|| get_user_ual(tab, vptr + 3 * VAR_0))
return -TARGET_EFAULT;
ret = do_socketpair(domain, type, protocol, tab);
}
break;
case SOCKOP_send:
{
abi_ulong sockfd;
abi_ulong msg;
size_t len;
abi_ulong flags;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(msg, vptr + VAR_0)
|| get_user_ual(len, vptr + 2 * VAR_0)
|| get_user_ual(flags, vptr + 3 * VAR_0))
return -TARGET_EFAULT;
ret = do_sendto(sockfd, msg, len, flags, 0, 0);
}
break;
case SOCKOP_recv:
{
abi_ulong sockfd;
abi_ulong msg;
size_t len;
abi_ulong flags;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(msg, vptr + VAR_0)
|| get_user_ual(len, vptr + 2 * VAR_0)
|| get_user_ual(flags, vptr + 3 * VAR_0))
return -TARGET_EFAULT;
ret = do_recvfrom(sockfd, msg, len, flags, 0, 0);
}
break;
case SOCKOP_sendto:
{
abi_ulong sockfd;
abi_ulong msg;
size_t len;
abi_ulong flags;
abi_ulong addr;
abi_ulong addrlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(msg, vptr + VAR_0)
|| get_user_ual(len, vptr + 2 * VAR_0)
|| get_user_ual(flags, vptr + 3 * VAR_0)
|| get_user_ual(addr, vptr + 4 * VAR_0)
|| get_user_ual(addrlen, vptr + 5 * VAR_0))
return -TARGET_EFAULT;
ret = do_sendto(sockfd, msg, len, flags, addr, addrlen);
}
break;
case SOCKOP_recvfrom:
{
abi_ulong sockfd;
abi_ulong msg;
size_t len;
abi_ulong flags;
abi_ulong addr;
socklen_t addrlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(msg, vptr + VAR_0)
|| get_user_ual(len, vptr + 2 * VAR_0)
|| get_user_ual(flags, vptr + 3 * VAR_0)
|| get_user_ual(addr, vptr + 4 * VAR_0)
|| get_user_ual(addrlen, vptr + 5 * VAR_0))
return -TARGET_EFAULT;
ret = do_recvfrom(sockfd, msg, len, flags, addr, addrlen);
}
break;
case SOCKOP_shutdown:
{
abi_ulong sockfd, how;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(how, vptr + VAR_0))
return -TARGET_EFAULT;
ret = get_errno(shutdown(sockfd, how));
}
break;
case SOCKOP_sendmsg:
case SOCKOP_recvmsg:
{
abi_ulong fd;
abi_ulong target_msg;
abi_ulong flags;
if (get_user_ual(fd, vptr)
|| get_user_ual(target_msg, vptr + VAR_0)
|| get_user_ual(flags, vptr + 2 * VAR_0))
return -TARGET_EFAULT;
ret = do_sendrecvmsg(fd, target_msg, flags,
(num == SOCKOP_sendmsg));
}
break;
case SOCKOP_setsockopt:
{
abi_ulong sockfd;
abi_ulong level;
abi_ulong optname;
abi_ulong optval;
abi_ulong optlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(level, vptr + VAR_0)
|| get_user_ual(optname, vptr + 2 * VAR_0)
|| get_user_ual(optval, vptr + 3 * VAR_0)
|| get_user_ual(optlen, vptr + 4 * VAR_0))
return -TARGET_EFAULT;
ret = do_setsockopt(sockfd, level, optname, optval, optlen);
}
break;
case SOCKOP_getsockopt:
{
abi_ulong sockfd;
abi_ulong level;
abi_ulong optname;
abi_ulong optval;
socklen_t optlen;
if (get_user_ual(sockfd, vptr)
|| get_user_ual(level, vptr + VAR_0)
|| get_user_ual(optname, vptr + 2 * VAR_0)
|| get_user_ual(optval, vptr + 3 * VAR_0)
|| get_user_ual(optlen, vptr + 4 * VAR_0))
return -TARGET_EFAULT;
ret = do_getsockopt(sockfd, level, optname, optval, optlen);
}
break;
default:
gemu_log("Unsupported socketcall: %d\VAR_0", num);
ret = -TARGET_ENOSYS;
break;
}
return ret;
}
| [
"static abi_long FUNC_0(int num, abi_ulong vptr)\n{",
"abi_long ret;",
"const int VAR_0 = sizeof(abi_ulong);",
"switch(num) {",
"case SOCKOP_socket:\n{",
"abi_ulong domain, type, protocol;",
"if (get_user_ual(domain, vptr)\n|| get_user_ual(type, vptr + VAR_0)\n|| get_user_ual(protocol, vptr + 2 * VAR_0))\nreturn -TARGET_EFAULT;",
"ret = do_socket(domain, type, protocol);",
"}",
"break;",
"case SOCKOP_bind:\n{",
"abi_ulong sockfd;",
"abi_ulong target_addr;",
"socklen_t addrlen;",
"if (get_user_ual(sockfd, vptr)\n|| get_user_ual(target_addr, vptr + VAR_0)\n|| get_user_ual(addrlen, vptr + 2 * VAR_0))\nreturn -TARGET_EFAULT;",
"ret = do_bind(sockfd, target_addr, addrlen);",
"}",
"break;",
"case SOCKOP_connect:\n{",
"abi_ulong sockfd;",
"abi_ulong target_addr;",
"socklen_t addrlen;",
"if (get_user_ual(sockfd, vptr)\n|| get_user_ual(target_addr, vptr + VAR_0)\n|| get_user_ual(addrlen, vptr + 2 * VAR_0))\nreturn -TARGET_EFAULT;",
"ret = do_connect(sockfd, target_addr, addrlen);",
"}",
"break;",
"case SOCKOP_listen:\n{",
"abi_ulong sockfd, backlog;",
"if (get_user_ual(sockfd, vptr)\n|| get_user_ual(backlog, vptr + VAR_0))\nreturn -TARGET_EFAULT;",
"ret = get_errno(listen(sockfd, backlog));",
"}",
"break;",
"case SOCKOP_accept:\n{",
"abi_ulong sockfd;",
"abi_ulong target_addr, target_addrlen;",
"if (get_user_ual(sockfd, vptr)\n|| get_user_ual(target_addr, vptr + VAR_0)\n|| get_user_ual(target_addrlen, vptr + 2 * VAR_0))\nreturn -TARGET_EFAULT;",
"ret = do_accept4(sockfd, target_addr, target_addrlen, 0);",
"}",
"break;",
"case SOCKOP_accept4:\n{",
"abi_ulong sockfd;",
"abi_ulong target_addr, target_addrlen;",
"abi_ulong flags;",
"if (get_user_ual(sockfd, vptr)\n|| get_user_ual(target_addr, vptr + VAR_0)\n|| get_user_ual(target_addrlen, vptr + 2 * VAR_0)\n|| get_user_ual(flags, vptr + 3 * VAR_0)) {",
"return -TARGET_EFAULT;",
"}",
"ret = do_accept4(sockfd, target_addr, target_addrlen, flags);",
"}",
"break;",
"case SOCKOP_getsockname:\n{",
"abi_ulong sockfd;",
"abi_ulong target_addr, target_addrlen;",
"if (get_user_ual(sockfd, vptr)\n|| get_user_ual(target_addr, vptr + VAR_0)\n|| get_user_ual(target_addrlen, vptr + 2 * VAR_0))\nreturn -TARGET_EFAULT;",
"ret = do_getsockname(sockfd, target_addr, target_addrlen);",
"}",
"break;",
"case SOCKOP_getpeername:\n{",
"abi_ulong sockfd;",
"abi_ulong target_addr, target_addrlen;",
"if (get_user_ual(sockfd, vptr)\n|| get_user_ual(target_addr, vptr + VAR_0)\n|| get_user_ual(target_addrlen, vptr + 2 * VAR_0))\nreturn -TARGET_EFAULT;",
"ret = do_getpeername(sockfd, target_addr, target_addrlen);",
"}",
"break;",
"case SOCKOP_socketpair:\n{",
"abi_ulong domain, type, protocol;",
"abi_ulong tab;",
"if (get_user_ual(domain, vptr)\n|| get_user_ual(type, vptr + VAR_0)\n|| get_user_ual(protocol, vptr + 2 * VAR_0)\n|| get_user_ual(tab, vptr + 3 * VAR_0))\nreturn -TARGET_EFAULT;",
"ret = do_socketpair(domain, type, protocol, tab);",
"}",
"break;",
"case SOCKOP_send:\n{",
"abi_ulong sockfd;",
"abi_ulong msg;",
"size_t len;",
"abi_ulong flags;",
"if (get_user_ual(sockfd, vptr)\n|| get_user_ual(msg, vptr + VAR_0)\n|| get_user_ual(len, vptr + 2 * VAR_0)\n|| get_user_ual(flags, vptr + 3 * VAR_0))\nreturn -TARGET_EFAULT;",
"ret = do_sendto(sockfd, msg, len, flags, 0, 0);",
"}",
"break;",
"case SOCKOP_recv:\n{",
"abi_ulong sockfd;",
"abi_ulong msg;",
"size_t len;",
"abi_ulong flags;",
"if (get_user_ual(sockfd, vptr)\n|| get_user_ual(msg, vptr + VAR_0)\n|| get_user_ual(len, vptr + 2 * VAR_0)\n|| get_user_ual(flags, vptr + 3 * VAR_0))\nreturn -TARGET_EFAULT;",
"ret = do_recvfrom(sockfd, msg, len, flags, 0, 0);",
"}",
"break;",
"case SOCKOP_sendto:\n{",
"abi_ulong sockfd;",
"abi_ulong msg;",
"size_t len;",
"abi_ulong flags;",
"abi_ulong addr;",
"abi_ulong addrlen;",
"if (get_user_ual(sockfd, vptr)\n|| get_user_ual(msg, vptr + VAR_0)\n|| get_user_ual(len, vptr + 2 * VAR_0)\n|| get_user_ual(flags, vptr + 3 * VAR_0)\n|| get_user_ual(addr, vptr + 4 * VAR_0)\n|| get_user_ual(addrlen, vptr + 5 * VAR_0))\nreturn -TARGET_EFAULT;",
"ret = do_sendto(sockfd, msg, len, flags, addr, addrlen);",
"}",
"break;",
"case SOCKOP_recvfrom:\n{",
"abi_ulong sockfd;",
"abi_ulong msg;",
"size_t len;",
"abi_ulong flags;",
"abi_ulong addr;",
"socklen_t addrlen;",
"if (get_user_ual(sockfd, vptr)\n|| get_user_ual(msg, vptr + VAR_0)\n|| get_user_ual(len, vptr + 2 * VAR_0)\n|| get_user_ual(flags, vptr + 3 * VAR_0)\n|| get_user_ual(addr, vptr + 4 * VAR_0)\n|| get_user_ual(addrlen, vptr + 5 * VAR_0))\nreturn -TARGET_EFAULT;",
"ret = do_recvfrom(sockfd, msg, len, flags, addr, addrlen);",
"}",
"break;",
"case SOCKOP_shutdown:\n{",
"abi_ulong sockfd, how;",
"if (get_user_ual(sockfd, vptr)\n|| get_user_ual(how, vptr + VAR_0))\nreturn -TARGET_EFAULT;",
"ret = get_errno(shutdown(sockfd, how));",
"}",
"break;",
"case SOCKOP_sendmsg:\ncase SOCKOP_recvmsg:\n{",
"abi_ulong fd;",
"abi_ulong target_msg;",
"abi_ulong flags;",
"if (get_user_ual(fd, vptr)\n|| get_user_ual(target_msg, vptr + VAR_0)\n|| get_user_ual(flags, vptr + 2 * VAR_0))\nreturn -TARGET_EFAULT;",
"ret = do_sendrecvmsg(fd, target_msg, flags,\n(num == SOCKOP_sendmsg));",
"}",
"break;",
"case SOCKOP_setsockopt:\n{",
"abi_ulong sockfd;",
"abi_ulong level;",
"abi_ulong optname;",
"abi_ulong optval;",
"abi_ulong optlen;",
"if (get_user_ual(sockfd, vptr)\n|| get_user_ual(level, vptr + VAR_0)\n|| get_user_ual(optname, vptr + 2 * VAR_0)\n|| get_user_ual(optval, vptr + 3 * VAR_0)\n|| get_user_ual(optlen, vptr + 4 * VAR_0))\nreturn -TARGET_EFAULT;",
"ret = do_setsockopt(sockfd, level, optname, optval, optlen);",
"}",
"break;",
"case SOCKOP_getsockopt:\n{",
"abi_ulong sockfd;",
"abi_ulong level;",
"abi_ulong optname;",
"abi_ulong optval;",
"socklen_t optlen;",
"if (get_user_ual(sockfd, vptr)\n|| get_user_ual(level, vptr + VAR_0)\n|| get_user_ual(optname, vptr + 2 * VAR_0)\n|| get_user_ual(optval, vptr + 3 * VAR_0)\n|| get_user_ual(optlen, vptr + 4 * VAR_0))\nreturn -TARGET_EFAULT;",
"ret = do_getsockopt(sockfd, level, optname, optval, optlen);",
"}",
"break;",
"default:\ngemu_log(\"Unsupported socketcall: %d\\VAR_0\", num);",
"ret = -TARGET_ENOSYS;",
"break;",
"}",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
17
],
[
21,
23,
25,
27
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
49,
51,
53,
55
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
77,
79,
81,
83
],
[
87
],
[
89
],
[
91
],
[
93,
95
],
[
97
],
[
101,
103,
105
],
[
109
],
[
111
],
[
113
],
[
115,
117
],
[
119
],
[
121
],
[
125,
127,
129,
131
],
[
135
],
[
137
],
[
139
],
[
141,
143
],
[
145
],
[
147
],
[
149
],
[
153,
155,
157,
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
173,
175
],
[
177
],
[
179
],
[
183,
185,
187,
189
],
[
193
],
[
195
],
[
197
],
[
199,
201
],
[
203
],
[
205
],
[
209,
211,
213,
215
],
[
219
],
[
221
],
[
223
],
[
225,
227
],
[
229
],
[
231
],
[
235,
237,
239,
241,
243
],
[
247
],
[
249
],
[
251
],
[
253,
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
267,
269,
271,
273,
275
],
[
279
],
[
281
],
[
283
],
[
285,
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
299,
301,
303,
305,
307
],
[
311
],
[
313
],
[
315
],
[
317,
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
335,
337,
339,
341,
343,
345,
347
],
[
351
],
[
353
],
[
355
],
[
357,
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
375,
377,
379,
381,
383,
385,
387
],
[
391
],
[
393
],
[
395
],
[
397,
399
],
[
401
],
[
405,
407,
409
],
[
413
],
[
415
],
[
417
],
[
419,
421,
423
],
[
425
],
[
427
],
[
429
],
[
433,
435,
437,
439
],
[
443,
445
],
[
447
],
[
449
],
[
451,
453
],
[
455
],
[
457
],
[
459
],
[
461
],
[
463
],
[
467,
469,
471,
473,
475,
477
],
[
481
],
[
483
],
[
485
],
[
487,
489
],
[
491
],
[
493
],
[
495
],
[
497
],
[
499
],
[
503,
505,
507,
509,
511,
513
],
[
517
],
[
519
],
[
521
],
[
523,
525
],
[
527
],
[
529
],
[
531
],
[
533
],
[
535
]
] |
1,773 | static int nbd_send_rep_list(int csock, NBDExport *exp)
{
uint64_t magic, name_len;
uint32_t opt, type, len;
name_len = strlen(exp->name);
magic = cpu_to_be64(NBD_REP_MAGIC);
if (write_sync(csock, &magic, sizeof(magic)) != sizeof(magic)) {
LOG("write failed (magic)");
return -EINVAL;
}
opt = cpu_to_be32(NBD_OPT_LIST);
if (write_sync(csock, &opt, sizeof(opt)) != sizeof(opt)) {
LOG("write failed (opt)");
return -EINVAL;
}
type = cpu_to_be32(NBD_REP_SERVER);
if (write_sync(csock, &type, sizeof(type)) != sizeof(type)) {
LOG("write failed (reply type)");
return -EINVAL;
}
len = cpu_to_be32(name_len + sizeof(len));
if (write_sync(csock, &len, sizeof(len)) != sizeof(len)) {
LOG("write failed (length)");
return -EINVAL;
}
len = cpu_to_be32(name_len);
if (write_sync(csock, &len, sizeof(len)) != sizeof(len)) {
LOG("write failed (length)");
return -EINVAL;
}
if (write_sync(csock, exp->name, name_len) != name_len) {
LOG("write failed (buffer)");
return -EINVAL;
}
return 0;
}
| false | qemu | 1a6245a5b0b4e8d822c739b403fc67c8a7bc8d12 | static int nbd_send_rep_list(int csock, NBDExport *exp)
{
uint64_t magic, name_len;
uint32_t opt, type, len;
name_len = strlen(exp->name);
magic = cpu_to_be64(NBD_REP_MAGIC);
if (write_sync(csock, &magic, sizeof(magic)) != sizeof(magic)) {
LOG("write failed (magic)");
return -EINVAL;
}
opt = cpu_to_be32(NBD_OPT_LIST);
if (write_sync(csock, &opt, sizeof(opt)) != sizeof(opt)) {
LOG("write failed (opt)");
return -EINVAL;
}
type = cpu_to_be32(NBD_REP_SERVER);
if (write_sync(csock, &type, sizeof(type)) != sizeof(type)) {
LOG("write failed (reply type)");
return -EINVAL;
}
len = cpu_to_be32(name_len + sizeof(len));
if (write_sync(csock, &len, sizeof(len)) != sizeof(len)) {
LOG("write failed (length)");
return -EINVAL;
}
len = cpu_to_be32(name_len);
if (write_sync(csock, &len, sizeof(len)) != sizeof(len)) {
LOG("write failed (length)");
return -EINVAL;
}
if (write_sync(csock, exp->name, name_len) != name_len) {
LOG("write failed (buffer)");
return -EINVAL;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(int VAR_0, NBDExport *VAR_1)
{
uint64_t magic, name_len;
uint32_t opt, type, len;
name_len = strlen(VAR_1->name);
magic = cpu_to_be64(NBD_REP_MAGIC);
if (write_sync(VAR_0, &magic, sizeof(magic)) != sizeof(magic)) {
LOG("write failed (magic)");
return -EINVAL;
}
opt = cpu_to_be32(NBD_OPT_LIST);
if (write_sync(VAR_0, &opt, sizeof(opt)) != sizeof(opt)) {
LOG("write failed (opt)");
return -EINVAL;
}
type = cpu_to_be32(NBD_REP_SERVER);
if (write_sync(VAR_0, &type, sizeof(type)) != sizeof(type)) {
LOG("write failed (reply type)");
return -EINVAL;
}
len = cpu_to_be32(name_len + sizeof(len));
if (write_sync(VAR_0, &len, sizeof(len)) != sizeof(len)) {
LOG("write failed (length)");
return -EINVAL;
}
len = cpu_to_be32(name_len);
if (write_sync(VAR_0, &len, sizeof(len)) != sizeof(len)) {
LOG("write failed (length)");
return -EINVAL;
}
if (write_sync(VAR_0, VAR_1->name, name_len) != name_len) {
LOG("write failed (buffer)");
return -EINVAL;
}
return 0;
}
| [
"static int FUNC_0(int VAR_0, NBDExport *VAR_1)\n{",
"uint64_t magic, name_len;",
"uint32_t opt, type, len;",
"name_len = strlen(VAR_1->name);",
"magic = cpu_to_be64(NBD_REP_MAGIC);",
"if (write_sync(VAR_0, &magic, sizeof(magic)) != sizeof(magic)) {",
"LOG(\"write failed (magic)\");",
"return -EINVAL;",
"}",
"opt = cpu_to_be32(NBD_OPT_LIST);",
"if (write_sync(VAR_0, &opt, sizeof(opt)) != sizeof(opt)) {",
"LOG(\"write failed (opt)\");",
"return -EINVAL;",
"}",
"type = cpu_to_be32(NBD_REP_SERVER);",
"if (write_sync(VAR_0, &type, sizeof(type)) != sizeof(type)) {",
"LOG(\"write failed (reply type)\");",
"return -EINVAL;",
"}",
"len = cpu_to_be32(name_len + sizeof(len));",
"if (write_sync(VAR_0, &len, sizeof(len)) != sizeof(len)) {",
"LOG(\"write failed (length)\");",
"return -EINVAL;",
"}",
"len = cpu_to_be32(name_len);",
"if (write_sync(VAR_0, &len, sizeof(len)) != sizeof(len)) {",
"LOG(\"write failed (length)\");",
"return -EINVAL;",
"}",
"if (write_sync(VAR_0, VAR_1->name, name_len) != name_len) {",
"LOG(\"write failed (buffer)\");",
"return -EINVAL;",
"}",
"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,
3
],
[
5
],
[
7
],
[
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
]
] |
1,774 | static int nic_init(PCIDevice *pci_dev, uint32_t device)
{
PCIEEPRO100State *d = DO_UPCAST(PCIEEPRO100State, dev, pci_dev);
EEPRO100State *s;
logout("\n");
d->dev.unregister = pci_nic_uninit;
s = &d->eepro100;
s->device = device;
s->pci_dev = &d->dev;
pci_reset(s);
/* Add 64 * 2 EEPROM. i82557 and i82558 support a 64 word EEPROM,
* i82559 and later support 64 or 256 word EEPROM. */
s->eeprom = eeprom93xx_new(EEPROM_SIZE);
/* Handler for memory-mapped I/O */
d->eepro100.mmio_index =
cpu_register_io_memory(pci_mmio_read, pci_mmio_write, s);
pci_register_bar(&d->dev, 0, PCI_MEM_SIZE,
PCI_ADDRESS_SPACE_MEM |
PCI_ADDRESS_SPACE_MEM_PREFETCH, pci_mmio_map);
pci_register_bar(&d->dev, 1, PCI_IO_SIZE, PCI_ADDRESS_SPACE_IO,
pci_map);
pci_register_bar(&d->dev, 2, PCI_FLASH_SIZE, PCI_ADDRESS_SPACE_MEM,
pci_mmio_map);
qdev_get_macaddr(&d->dev.qdev, s->macaddr);
logout("macaddr: %s\n", nic_dump(&s->macaddr[0], 6));
assert(s->region[1] == 0);
nic_reset(s);
s->vc = qdev_get_vlan_client(&d->dev.qdev,
nic_can_receive, nic_receive, NULL,
nic_cleanup, s);
qemu_format_nic_info_str(s->vc, s->macaddr);
qemu_register_reset(nic_reset, s);
register_savevm(s->vc->model, -1, 3, nic_save, nic_load, s);
return 0;
}
| false | qemu | 273a2142176098fe2c27f263d86ad66b133b43cb | static int nic_init(PCIDevice *pci_dev, uint32_t device)
{
PCIEEPRO100State *d = DO_UPCAST(PCIEEPRO100State, dev, pci_dev);
EEPRO100State *s;
logout("\n");
d->dev.unregister = pci_nic_uninit;
s = &d->eepro100;
s->device = device;
s->pci_dev = &d->dev;
pci_reset(s);
s->eeprom = eeprom93xx_new(EEPROM_SIZE);
d->eepro100.mmio_index =
cpu_register_io_memory(pci_mmio_read, pci_mmio_write, s);
pci_register_bar(&d->dev, 0, PCI_MEM_SIZE,
PCI_ADDRESS_SPACE_MEM |
PCI_ADDRESS_SPACE_MEM_PREFETCH, pci_mmio_map);
pci_register_bar(&d->dev, 1, PCI_IO_SIZE, PCI_ADDRESS_SPACE_IO,
pci_map);
pci_register_bar(&d->dev, 2, PCI_FLASH_SIZE, PCI_ADDRESS_SPACE_MEM,
pci_mmio_map);
qdev_get_macaddr(&d->dev.qdev, s->macaddr);
logout("macaddr: %s\n", nic_dump(&s->macaddr[0], 6));
assert(s->region[1] == 0);
nic_reset(s);
s->vc = qdev_get_vlan_client(&d->dev.qdev,
nic_can_receive, nic_receive, NULL,
nic_cleanup, s);
qemu_format_nic_info_str(s->vc, s->macaddr);
qemu_register_reset(nic_reset, s);
register_savevm(s->vc->model, -1, 3, nic_save, nic_load, s);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(PCIDevice *VAR_0, uint32_t VAR_1)
{
PCIEEPRO100State *d = DO_UPCAST(PCIEEPRO100State, dev, VAR_0);
EEPRO100State *s;
logout("\n");
d->dev.unregister = pci_nic_uninit;
s = &d->eepro100;
s->VAR_1 = VAR_1;
s->VAR_0 = &d->dev;
pci_reset(s);
s->eeprom = eeprom93xx_new(EEPROM_SIZE);
d->eepro100.mmio_index =
cpu_register_io_memory(pci_mmio_read, pci_mmio_write, s);
pci_register_bar(&d->dev, 0, PCI_MEM_SIZE,
PCI_ADDRESS_SPACE_MEM |
PCI_ADDRESS_SPACE_MEM_PREFETCH, pci_mmio_map);
pci_register_bar(&d->dev, 1, PCI_IO_SIZE, PCI_ADDRESS_SPACE_IO,
pci_map);
pci_register_bar(&d->dev, 2, PCI_FLASH_SIZE, PCI_ADDRESS_SPACE_MEM,
pci_mmio_map);
qdev_get_macaddr(&d->dev.qdev, s->macaddr);
logout("macaddr: %s\n", nic_dump(&s->macaddr[0], 6));
assert(s->region[1] == 0);
nic_reset(s);
s->vc = qdev_get_vlan_client(&d->dev.qdev,
nic_can_receive, nic_receive, NULL,
nic_cleanup, s);
qemu_format_nic_info_str(s->vc, s->macaddr);
qemu_register_reset(nic_reset, s);
register_savevm(s->vc->model, -1, 3, nic_save, nic_load, s);
return 0;
}
| [
"static int FUNC_0(PCIDevice *VAR_0, uint32_t VAR_1)\n{",
"PCIEEPRO100State *d = DO_UPCAST(PCIEEPRO100State, dev, VAR_0);",
"EEPRO100State *s;",
"logout(\"\\n\");",
"d->dev.unregister = pci_nic_uninit;",
"s = &d->eepro100;",
"s->VAR_1 = VAR_1;",
"s->VAR_0 = &d->dev;",
"pci_reset(s);",
"s->eeprom = eeprom93xx_new(EEPROM_SIZE);",
"d->eepro100.mmio_index =\ncpu_register_io_memory(pci_mmio_read, pci_mmio_write, s);",
"pci_register_bar(&d->dev, 0, PCI_MEM_SIZE,\nPCI_ADDRESS_SPACE_MEM |\nPCI_ADDRESS_SPACE_MEM_PREFETCH, pci_mmio_map);",
"pci_register_bar(&d->dev, 1, PCI_IO_SIZE, PCI_ADDRESS_SPACE_IO,\npci_map);",
"pci_register_bar(&d->dev, 2, PCI_FLASH_SIZE, PCI_ADDRESS_SPACE_MEM,\npci_mmio_map);",
"qdev_get_macaddr(&d->dev.qdev, s->macaddr);",
"logout(\"macaddr: %s\\n\", nic_dump(&s->macaddr[0], 6));",
"assert(s->region[1] == 0);",
"nic_reset(s);",
"s->vc = qdev_get_vlan_client(&d->dev.qdev,\nnic_can_receive, nic_receive, NULL,\nnic_cleanup, s);",
"qemu_format_nic_info_str(s->vc, s->macaddr);",
"qemu_register_reset(nic_reset, s);",
"register_savevm(s->vc->model, -1, 3, nic_save, nic_load, s);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23
],
[
27
],
[
35
],
[
41,
43
],
[
47,
49,
51
],
[
53,
55
],
[
57,
59
],
[
63
],
[
65
],
[
67
],
[
71
],
[
75,
77,
79
],
[
83
],
[
87
],
[
91
],
[
93
],
[
95
]
] |
1,775 | static uint64_t pchip_read(void *opaque, target_phys_addr_t addr, unsigned size)
{
TyphoonState *s = opaque;
uint64_t ret = 0;
if (addr & 4) {
return s->latch_tmp;
}
switch (addr) {
case 0x0000:
/* WSBA0: Window Space Base Address Register. */
ret = s->pchip.win[0].base_addr;
break;
case 0x0040:
/* WSBA1 */
ret = s->pchip.win[1].base_addr;
break;
case 0x0080:
/* WSBA2 */
ret = s->pchip.win[2].base_addr;
break;
case 0x00c0:
/* WSBA3 */
ret = s->pchip.win[3].base_addr;
break;
case 0x0100:
/* WSM0: Window Space Mask Register. */
ret = s->pchip.win[0].mask;
break;
case 0x0140:
/* WSM1 */
ret = s->pchip.win[1].mask;
break;
case 0x0180:
/* WSM2 */
ret = s->pchip.win[2].mask;
break;
case 0x01c0:
/* WSM3 */
ret = s->pchip.win[3].mask;
break;
case 0x0200:
/* TBA0: Translated Base Address Register. */
ret = (uint64_t)s->pchip.win[0].translated_base_pfn << 10;
break;
case 0x0240:
/* TBA1 */
ret = (uint64_t)s->pchip.win[1].translated_base_pfn << 10;
break;
case 0x0280:
/* TBA2 */
ret = (uint64_t)s->pchip.win[2].translated_base_pfn << 10;
break;
case 0x02c0:
/* TBA3 */
ret = (uint64_t)s->pchip.win[3].translated_base_pfn << 10;
break;
case 0x0300:
/* PCTL: Pchip Control Register. */
ret = s->pchip.ctl;
break;
case 0x0340:
/* PLAT: Pchip Master Latency Register. */
break;
case 0x03c0:
/* PERROR: Pchip Error Register. */
break;
case 0x0400:
/* PERRMASK: Pchip Error Mask Register. */
break;
case 0x0440:
/* PERRSET: Pchip Error Set Register. */
break;
case 0x0480:
/* TLBIV: Translation Buffer Invalidate Virtual Register (WO). */
break;
case 0x04c0:
/* TLBIA: Translation Buffer Invalidate All Register (WO). */
break;
case 0x0500: /* PMONCTL */
case 0x0540: /* PMONCNT */
case 0x0800: /* SPRST */
break;
default:
cpu_unassigned_access(cpu_single_env, addr, 0, 0, 0, size);
return -1;
}
s->latch_tmp = ret >> 32;
return ret;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t pchip_read(void *opaque, target_phys_addr_t addr, unsigned size)
{
TyphoonState *s = opaque;
uint64_t ret = 0;
if (addr & 4) {
return s->latch_tmp;
}
switch (addr) {
case 0x0000:
ret = s->pchip.win[0].base_addr;
break;
case 0x0040:
ret = s->pchip.win[1].base_addr;
break;
case 0x0080:
ret = s->pchip.win[2].base_addr;
break;
case 0x00c0:
ret = s->pchip.win[3].base_addr;
break;
case 0x0100:
ret = s->pchip.win[0].mask;
break;
case 0x0140:
ret = s->pchip.win[1].mask;
break;
case 0x0180:
ret = s->pchip.win[2].mask;
break;
case 0x01c0:
ret = s->pchip.win[3].mask;
break;
case 0x0200:
ret = (uint64_t)s->pchip.win[0].translated_base_pfn << 10;
break;
case 0x0240:
ret = (uint64_t)s->pchip.win[1].translated_base_pfn << 10;
break;
case 0x0280:
ret = (uint64_t)s->pchip.win[2].translated_base_pfn << 10;
break;
case 0x02c0:
ret = (uint64_t)s->pchip.win[3].translated_base_pfn << 10;
break;
case 0x0300:
ret = s->pchip.ctl;
break;
case 0x0340:
break;
case 0x03c0:
break;
case 0x0400:
break;
case 0x0440:
break;
case 0x0480:
break;
case 0x04c0:
break;
case 0x0500:
case 0x0540:
case 0x0800:
break;
default:
cpu_unassigned_access(cpu_single_env, addr, 0, 0, 0, size);
return -1;
}
s->latch_tmp = ret >> 32;
return ret;
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr, unsigned size)
{
TyphoonState *s = opaque;
uint64_t ret = 0;
if (addr & 4) {
return s->latch_tmp;
}
switch (addr) {
case 0x0000:
ret = s->pchip.win[0].base_addr;
break;
case 0x0040:
ret = s->pchip.win[1].base_addr;
break;
case 0x0080:
ret = s->pchip.win[2].base_addr;
break;
case 0x00c0:
ret = s->pchip.win[3].base_addr;
break;
case 0x0100:
ret = s->pchip.win[0].mask;
break;
case 0x0140:
ret = s->pchip.win[1].mask;
break;
case 0x0180:
ret = s->pchip.win[2].mask;
break;
case 0x01c0:
ret = s->pchip.win[3].mask;
break;
case 0x0200:
ret = (uint64_t)s->pchip.win[0].translated_base_pfn << 10;
break;
case 0x0240:
ret = (uint64_t)s->pchip.win[1].translated_base_pfn << 10;
break;
case 0x0280:
ret = (uint64_t)s->pchip.win[2].translated_base_pfn << 10;
break;
case 0x02c0:
ret = (uint64_t)s->pchip.win[3].translated_base_pfn << 10;
break;
case 0x0300:
ret = s->pchip.ctl;
break;
case 0x0340:
break;
case 0x03c0:
break;
case 0x0400:
break;
case 0x0440:
break;
case 0x0480:
break;
case 0x04c0:
break;
case 0x0500:
case 0x0540:
case 0x0800:
break;
default:
cpu_unassigned_access(cpu_single_env, addr, 0, 0, 0, size);
return -1;
}
s->latch_tmp = ret >> 32;
return ret;
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr, unsigned size)\n{",
"TyphoonState *s = opaque;",
"uint64_t ret = 0;",
"if (addr & 4) {",
"return s->latch_tmp;",
"}",
"switch (addr) {",
"case 0x0000:\nret = s->pchip.win[0].base_addr;",
"break;",
"case 0x0040:\nret = s->pchip.win[1].base_addr;",
"break;",
"case 0x0080:\nret = s->pchip.win[2].base_addr;",
"break;",
"case 0x00c0:\nret = s->pchip.win[3].base_addr;",
"break;",
"case 0x0100:\nret = s->pchip.win[0].mask;",
"break;",
"case 0x0140:\nret = s->pchip.win[1].mask;",
"break;",
"case 0x0180:\nret = s->pchip.win[2].mask;",
"break;",
"case 0x01c0:\nret = s->pchip.win[3].mask;",
"break;",
"case 0x0200:\nret = (uint64_t)s->pchip.win[0].translated_base_pfn << 10;",
"break;",
"case 0x0240:\nret = (uint64_t)s->pchip.win[1].translated_base_pfn << 10;",
"break;",
"case 0x0280:\nret = (uint64_t)s->pchip.win[2].translated_base_pfn << 10;",
"break;",
"case 0x02c0:\nret = (uint64_t)s->pchip.win[3].translated_base_pfn << 10;",
"break;",
"case 0x0300:\nret = s->pchip.ctl;",
"break;",
"case 0x0340:\nbreak;",
"case 0x03c0:\nbreak;",
"case 0x0400:\nbreak;",
"case 0x0440:\nbreak;",
"case 0x0480:\nbreak;",
"case 0x04c0:\nbreak;",
"case 0x0500:\ncase 0x0540:\ncase 0x0800:\nbreak;",
"default:\ncpu_unassigned_access(cpu_single_env, addr, 0, 0, 0, size);",
"return -1;",
"}",
"s->latch_tmp = ret >> 32;",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21,
25
],
[
27
],
[
29,
33
],
[
35
],
[
37,
41
],
[
43
],
[
45,
49
],
[
51
],
[
55,
59
],
[
61
],
[
63,
67
],
[
69
],
[
71,
75
],
[
77
],
[
79,
83
],
[
85
],
[
89,
93
],
[
95
],
[
97,
101
],
[
103
],
[
105,
109
],
[
111
],
[
113,
117
],
[
119
],
[
123,
127
],
[
129
],
[
131,
135
],
[
137,
141
],
[
143,
147
],
[
149,
153
],
[
155,
159
],
[
161,
165
],
[
167,
169,
171,
173
],
[
177,
179
],
[
181
],
[
183
],
[
187
],
[
189
],
[
191
]
] |
1,777 | static void curl_close(BlockDriverState *bs)
{
BDRVCURLState *s = bs->opaque;
DPRINTF("CURL: Close\n");
curl_detach_aio_context(bs);
qemu_mutex_destroy(&s->mutex);
g_free(s->cookie);
g_free(s->url);
} | true | qemu | 996922de45299878cdc4c15b72b19edf2bc618a4 | static void curl_close(BlockDriverState *bs)
{
BDRVCURLState *s = bs->opaque;
DPRINTF("CURL: Close\n");
curl_detach_aio_context(bs);
qemu_mutex_destroy(&s->mutex);
g_free(s->cookie);
g_free(s->url);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(BlockDriverState *VAR_0)
{
BDRVCURLState *s = VAR_0->opaque;
DPRINTF("CURL: Close\n");
curl_detach_aio_context(VAR_0);
qemu_mutex_destroy(&s->mutex);
g_free(s->cookie);
g_free(s->url);
} | [
"static void FUNC_0(BlockDriverState *VAR_0)\n{",
"BDRVCURLState *s = VAR_0->opaque;",
"DPRINTF(\"CURL: Close\\n\");",
"curl_detach_aio_context(VAR_0);",
"qemu_mutex_destroy(&s->mutex);",
"g_free(s->cookie);",
"g_free(s->url);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
24
]
] |
1,778 | int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size)
{
int len;
len = s->buf_end - s->buf_ptr;
if (len == 0) {
fill_buffer(s);
len = s->buf_end - s->buf_ptr;
}
if (len > size)
len = size;
memcpy(buf, s->buf_ptr, len);
s->buf_ptr += len;
return len;
} | true | FFmpeg | 0ecca7a49f8e254c12a3a1de048d738bfbb614c6 | int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size)
{
int len;
len = s->buf_end - s->buf_ptr;
if (len == 0) {
fill_buffer(s);
len = s->buf_end - s->buf_ptr;
}
if (len > size)
len = size;
memcpy(buf, s->buf_ptr, len);
s->buf_ptr += len;
return len;
} | {
"code": [],
"line_no": []
} | int FUNC_0(ByteIOContext *VAR_0, unsigned char *VAR_1, int VAR_2)
{
int VAR_3;
VAR_3 = VAR_0->buf_end - VAR_0->buf_ptr;
if (VAR_3 == 0) {
fill_buffer(VAR_0);
VAR_3 = VAR_0->buf_end - VAR_0->buf_ptr;
}
if (VAR_3 > VAR_2)
VAR_3 = VAR_2;
memcpy(VAR_1, VAR_0->buf_ptr, VAR_3);
VAR_0->buf_ptr += VAR_3;
return VAR_3;
} | [
"int FUNC_0(ByteIOContext *VAR_0, unsigned char *VAR_1, int VAR_2)\n{",
"int VAR_3;",
"VAR_3 = VAR_0->buf_end - VAR_0->buf_ptr;",
"if (VAR_3 == 0) {",
"fill_buffer(VAR_0);",
"VAR_3 = VAR_0->buf_end - VAR_0->buf_ptr;",
"}",
"if (VAR_3 > VAR_2)\nVAR_3 = VAR_2;",
"memcpy(VAR_1, VAR_0->buf_ptr, VAR_3);",
"VAR_0->buf_ptr += VAR_3;",
"return VAR_3;",
"}"
] | [
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
]
] |
1,779 | static int decode_cce(AACContext *ac, GetBitContext *gb, ChannelElement *che)
{
int num_gain = 0;
int c, g, sfb, ret;
int sign;
INTFLOAT scale;
SingleChannelElement *sce = &che->ch[0];
ChannelCoupling *coup = &che->coup;
coup->coupling_point = 2 * get_bits1(gb);
coup->num_coupled = get_bits(gb, 3);
for (c = 0; c <= coup->num_coupled; c++) {
num_gain++;
coup->type[c] = get_bits1(gb) ? TYPE_CPE : TYPE_SCE;
coup->id_select[c] = get_bits(gb, 4);
if (coup->type[c] == TYPE_CPE) {
coup->ch_select[c] = get_bits(gb, 2);
if (coup->ch_select[c] == 3)
num_gain++;
} else
coup->ch_select[c] = 2;
}
coup->coupling_point += get_bits1(gb) || (coup->coupling_point >> 1);
sign = get_bits(gb, 1);
scale = AAC_RENAME(cce_scale)[get_bits(gb, 2)];
if ((ret = decode_ics(ac, sce, gb, 0, 0)))
return ret;
for (c = 0; c < num_gain; c++) {
int idx = 0;
int cge = 1;
int gain = 0;
INTFLOAT gain_cache = FIXR10(1.);
if (c) {
cge = coup->coupling_point == AFTER_IMDCT ? 1 : get_bits1(gb);
gain = cge ? get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60: 0;
gain_cache = GET_GAIN(scale, gain);
}
if (coup->coupling_point == AFTER_IMDCT) {
coup->gain[c][0] = gain_cache;
} else {
for (g = 0; g < sce->ics.num_window_groups; g++) {
for (sfb = 0; sfb < sce->ics.max_sfb; sfb++, idx++) {
if (sce->band_type[idx] != ZERO_BT) {
if (!cge) {
int t = get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60;
if (t) {
int s = 1;
t = gain += t;
if (sign) {
s -= 2 * (t & 0x1);
t >>= 1;
}
gain_cache = GET_GAIN(scale, t) * s;
}
}
coup->gain[c][idx] = gain_cache;
}
}
}
}
}
return 0;
}
| true | FFmpeg | 53a502206a9ea698926694d7252526fe00d1ea44 | static int decode_cce(AACContext *ac, GetBitContext *gb, ChannelElement *che)
{
int num_gain = 0;
int c, g, sfb, ret;
int sign;
INTFLOAT scale;
SingleChannelElement *sce = &che->ch[0];
ChannelCoupling *coup = &che->coup;
coup->coupling_point = 2 * get_bits1(gb);
coup->num_coupled = get_bits(gb, 3);
for (c = 0; c <= coup->num_coupled; c++) {
num_gain++;
coup->type[c] = get_bits1(gb) ? TYPE_CPE : TYPE_SCE;
coup->id_select[c] = get_bits(gb, 4);
if (coup->type[c] == TYPE_CPE) {
coup->ch_select[c] = get_bits(gb, 2);
if (coup->ch_select[c] == 3)
num_gain++;
} else
coup->ch_select[c] = 2;
}
coup->coupling_point += get_bits1(gb) || (coup->coupling_point >> 1);
sign = get_bits(gb, 1);
scale = AAC_RENAME(cce_scale)[get_bits(gb, 2)];
if ((ret = decode_ics(ac, sce, gb, 0, 0)))
return ret;
for (c = 0; c < num_gain; c++) {
int idx = 0;
int cge = 1;
int gain = 0;
INTFLOAT gain_cache = FIXR10(1.);
if (c) {
cge = coup->coupling_point == AFTER_IMDCT ? 1 : get_bits1(gb);
gain = cge ? get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60: 0;
gain_cache = GET_GAIN(scale, gain);
}
if (coup->coupling_point == AFTER_IMDCT) {
coup->gain[c][0] = gain_cache;
} else {
for (g = 0; g < sce->ics.num_window_groups; g++) {
for (sfb = 0; sfb < sce->ics.max_sfb; sfb++, idx++) {
if (sce->band_type[idx] != ZERO_BT) {
if (!cge) {
int t = get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60;
if (t) {
int s = 1;
t = gain += t;
if (sign) {
s -= 2 * (t & 0x1);
t >>= 1;
}
gain_cache = GET_GAIN(scale, t) * s;
}
}
coup->gain[c][idx] = gain_cache;
}
}
}
}
}
return 0;
}
| {
"code": [
" scale = AAC_RENAME(cce_scale)[get_bits(gb, 2)];"
],
"line_no": [
51
]
} | static int FUNC_0(AACContext *VAR_0, GetBitContext *VAR_1, ChannelElement *VAR_2)
{
int VAR_3 = 0;
int VAR_4, VAR_5, VAR_6, VAR_7;
int VAR_8;
INTFLOAT scale;
SingleChannelElement *sce = &VAR_2->ch[0];
ChannelCoupling *coup = &VAR_2->coup;
coup->coupling_point = 2 * get_bits1(VAR_1);
coup->num_coupled = get_bits(VAR_1, 3);
for (VAR_4 = 0; VAR_4 <= coup->num_coupled; VAR_4++) {
VAR_3++;
coup->type[VAR_4] = get_bits1(VAR_1) ? TYPE_CPE : TYPE_SCE;
coup->id_select[VAR_4] = get_bits(VAR_1, 4);
if (coup->type[VAR_4] == TYPE_CPE) {
coup->ch_select[VAR_4] = get_bits(VAR_1, 2);
if (coup->ch_select[VAR_4] == 3)
VAR_3++;
} else
coup->ch_select[VAR_4] = 2;
}
coup->coupling_point += get_bits1(VAR_1) || (coup->coupling_point >> 1);
VAR_8 = get_bits(VAR_1, 1);
scale = AAC_RENAME(cce_scale)[get_bits(VAR_1, 2)];
if ((VAR_7 = decode_ics(VAR_0, sce, VAR_1, 0, 0)))
return VAR_7;
for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) {
int VAR_9 = 0;
int VAR_10 = 1;
int VAR_11 = 0;
INTFLOAT gain_cache = FIXR10(1.);
if (VAR_4) {
VAR_10 = coup->coupling_point == AFTER_IMDCT ? 1 : get_bits1(VAR_1);
VAR_11 = VAR_10 ? get_vlc2(VAR_1, vlc_scalefactors.table, 7, 3) - 60: 0;
gain_cache = GET_GAIN(scale, VAR_11);
}
if (coup->coupling_point == AFTER_IMDCT) {
coup->VAR_11[VAR_4][0] = gain_cache;
} else {
for (VAR_5 = 0; VAR_5 < sce->ics.num_window_groups; VAR_5++) {
for (VAR_6 = 0; VAR_6 < sce->ics.max_sfb; VAR_6++, VAR_9++) {
if (sce->band_type[VAR_9] != ZERO_BT) {
if (!VAR_10) {
int t = get_vlc2(VAR_1, vlc_scalefactors.table, 7, 3) - 60;
if (t) {
int s = 1;
t = VAR_11 += t;
if (VAR_8) {
s -= 2 * (t & 0x1);
t >>= 1;
}
gain_cache = GET_GAIN(scale, t) * s;
}
}
coup->VAR_11[VAR_4][VAR_9] = gain_cache;
}
}
}
}
}
return 0;
}
| [
"static int FUNC_0(AACContext *VAR_0, GetBitContext *VAR_1, ChannelElement *VAR_2)\n{",
"int VAR_3 = 0;",
"int VAR_4, VAR_5, VAR_6, VAR_7;",
"int VAR_8;",
"INTFLOAT scale;",
"SingleChannelElement *sce = &VAR_2->ch[0];",
"ChannelCoupling *coup = &VAR_2->coup;",
"coup->coupling_point = 2 * get_bits1(VAR_1);",
"coup->num_coupled = get_bits(VAR_1, 3);",
"for (VAR_4 = 0; VAR_4 <= coup->num_coupled; VAR_4++) {",
"VAR_3++;",
"coup->type[VAR_4] = get_bits1(VAR_1) ? TYPE_CPE : TYPE_SCE;",
"coup->id_select[VAR_4] = get_bits(VAR_1, 4);",
"if (coup->type[VAR_4] == TYPE_CPE) {",
"coup->ch_select[VAR_4] = get_bits(VAR_1, 2);",
"if (coup->ch_select[VAR_4] == 3)\nVAR_3++;",
"} else",
"coup->ch_select[VAR_4] = 2;",
"}",
"coup->coupling_point += get_bits1(VAR_1) || (coup->coupling_point >> 1);",
"VAR_8 = get_bits(VAR_1, 1);",
"scale = AAC_RENAME(cce_scale)[get_bits(VAR_1, 2)];",
"if ((VAR_7 = decode_ics(VAR_0, sce, VAR_1, 0, 0)))\nreturn VAR_7;",
"for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) {",
"int VAR_9 = 0;",
"int VAR_10 = 1;",
"int VAR_11 = 0;",
"INTFLOAT gain_cache = FIXR10(1.);",
"if (VAR_4) {",
"VAR_10 = coup->coupling_point == AFTER_IMDCT ? 1 : get_bits1(VAR_1);",
"VAR_11 = VAR_10 ? get_vlc2(VAR_1, vlc_scalefactors.table, 7, 3) - 60: 0;",
"gain_cache = GET_GAIN(scale, VAR_11);",
"}",
"if (coup->coupling_point == AFTER_IMDCT) {",
"coup->VAR_11[VAR_4][0] = gain_cache;",
"} else {",
"for (VAR_5 = 0; VAR_5 < sce->ics.num_window_groups; VAR_5++) {",
"for (VAR_6 = 0; VAR_6 < sce->ics.max_sfb; VAR_6++, VAR_9++) {",
"if (sce->band_type[VAR_9] != ZERO_BT) {",
"if (!VAR_10) {",
"int t = get_vlc2(VAR_1, vlc_scalefactors.table, 7, 3) - 60;",
"if (t) {",
"int s = 1;",
"t = VAR_11 += t;",
"if (VAR_8) {",
"s -= 2 * (t & 0x1);",
"t >>= 1;",
"}",
"gain_cache = GET_GAIN(scale, t) * s;",
"}",
"}",
"coup->VAR_11[VAR_4][VAR_9] = gain_cache;",
"}",
"}",
"}",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
55,
57
],
[
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
]
] |
1,780 | static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque)
{
VirtualConsole *vc = opaque;
GtkDisplayState *s = vc->s;
int gdk_keycode = key->hardware_keycode;
int qemu_keycode;
int i;
if (key->keyval == GDK_KEY_Pause) {
qemu_input_event_send_key_qcode(vc->gfx.dcl.con, Q_KEY_CODE_PAUSE,
key->type == GDK_KEY_PRESS);
qemu_keycode = gd_map_keycode(s, gtk_widget_get_display(widget),
gdk_keycode);
trace_gd_key_event(vc->label, gdk_keycode, qemu_keycode,
(key->type == GDK_KEY_PRESS) ? "down" : "up");
for (i = 0; i < ARRAY_SIZE(modifier_keycode); i++) {
if (qemu_keycode == modifier_keycode[i]) {
s->modifier_pressed[i] = (key->type == GDK_KEY_PRESS);
qemu_input_event_send_key_number(vc->gfx.dcl.con, qemu_keycode,
key->type == GDK_KEY_PRESS); | true | qemu | 1a01716a307387e5cf1336f61a96f772dddadc90 | static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque)
{
VirtualConsole *vc = opaque;
GtkDisplayState *s = vc->s;
int gdk_keycode = key->hardware_keycode;
int qemu_keycode;
int i;
if (key->keyval == GDK_KEY_Pause) {
qemu_input_event_send_key_qcode(vc->gfx.dcl.con, Q_KEY_CODE_PAUSE,
key->type == GDK_KEY_PRESS);
qemu_keycode = gd_map_keycode(s, gtk_widget_get_display(widget),
gdk_keycode);
trace_gd_key_event(vc->label, gdk_keycode, qemu_keycode,
(key->type == GDK_KEY_PRESS) ? "down" : "up");
for (i = 0; i < ARRAY_SIZE(modifier_keycode); i++) {
if (qemu_keycode == modifier_keycode[i]) {
s->modifier_pressed[i] = (key->type == GDK_KEY_PRESS);
qemu_input_event_send_key_number(vc->gfx.dcl.con, qemu_keycode,
key->type == GDK_KEY_PRESS); | {
"code": [],
"line_no": []
} | static gboolean FUNC_0(GtkWidget *widget, GdkEventKey *key, void *opaque)
{
VirtualConsole *vc = opaque;
GtkDisplayState *s = vc->s;
int VAR_0 = key->hardware_keycode;
int VAR_1;
int VAR_2;
if (key->keyval == GDK_KEY_Pause) {
qemu_input_event_send_key_qcode(vc->gfx.dcl.con, Q_KEY_CODE_PAUSE,
key->type == GDK_KEY_PRESS);
VAR_1 = gd_map_keycode(s, gtk_widget_get_display(widget),
VAR_0);
trace_gd_key_event(vc->label, VAR_0, VAR_1,
(key->type == GDK_KEY_PRESS) ? "down" : "up");
for (VAR_2 = 0; VAR_2 < ARRAY_SIZE(modifier_keycode); VAR_2++) {
if (VAR_1 == modifier_keycode[VAR_2]) {
s->modifier_pressed[VAR_2] = (key->type == GDK_KEY_PRESS);
qemu_input_event_send_key_number(vc->gfx.dcl.con, VAR_1,
key->type == GDK_KEY_PRESS); | [
"static gboolean FUNC_0(GtkWidget *widget, GdkEventKey *key, void *opaque)\n{",
"VirtualConsole *vc = opaque;",
"GtkDisplayState *s = vc->s;",
"int VAR_0 = key->hardware_keycode;",
"int VAR_1;",
"int VAR_2;",
"if (key->keyval == GDK_KEY_Pause) {",
"qemu_input_event_send_key_qcode(vc->gfx.dcl.con, Q_KEY_CODE_PAUSE,\nkey->type == GDK_KEY_PRESS);",
"VAR_1 = gd_map_keycode(s, gtk_widget_get_display(widget),\nVAR_0);",
"trace_gd_key_event(vc->label, VAR_0, VAR_1,\n(key->type == GDK_KEY_PRESS) ? \"down\" : \"up\");",
"for (VAR_2 = 0; VAR_2 < ARRAY_SIZE(modifier_keycode); VAR_2++) {",
"if (VAR_1 == modifier_keycode[VAR_2]) {",
"s->modifier_pressed[VAR_2] = (key->type == GDK_KEY_PRESS);",
"qemu_input_event_send_key_number(vc->gfx.dcl.con, VAR_1,\nkey->type == GDK_KEY_PRESS);"
] | [
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
]
] |
1,781 | void *pl110_init(DisplayState *ds, uint32_t base, qemu_irq irq,
int versatile)
{
pl110_state *s;
int iomemtype;
s = (pl110_state *)qemu_mallocz(sizeof(pl110_state));
iomemtype = cpu_register_io_memory(0, pl110_readfn,
pl110_writefn, s);
cpu_register_physical_memory(base, 0x00000fff, iomemtype);
s->base = base;
s->ds = ds;
s->versatile = versatile;
s->irq = irq;
graphic_console_init(ds, pl110_update_display, pl110_invalidate_display,
NULL, s);
/* ??? Save/restore. */
return s;
}
| true | qemu | 187337f8b0ec0813dd3876d1efe37d415fb81c2e | void *pl110_init(DisplayState *ds, uint32_t base, qemu_irq irq,
int versatile)
{
pl110_state *s;
int iomemtype;
s = (pl110_state *)qemu_mallocz(sizeof(pl110_state));
iomemtype = cpu_register_io_memory(0, pl110_readfn,
pl110_writefn, s);
cpu_register_physical_memory(base, 0x00000fff, iomemtype);
s->base = base;
s->ds = ds;
s->versatile = versatile;
s->irq = irq;
graphic_console_init(ds, pl110_update_display, pl110_invalidate_display,
NULL, s);
return 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(DisplayState *VAR_0, uint32_t VAR_1, qemu_irq VAR_2,
int VAR_3)
{
pl110_state *s;
int VAR_4;
s = (pl110_state *)qemu_mallocz(sizeof(pl110_state));
VAR_4 = cpu_register_io_memory(0, pl110_readfn,
pl110_writefn, s);
cpu_register_physical_memory(VAR_1, 0x00000fff, VAR_4);
s->VAR_1 = VAR_1;
s->VAR_0 = VAR_0;
s->VAR_3 = VAR_3;
s->VAR_2 = VAR_2;
graphic_console_init(VAR_0, pl110_update_display, pl110_invalidate_display,
NULL, s);
return s;
}
| [
"void *FUNC_0(DisplayState *VAR_0, uint32_t VAR_1, qemu_irq VAR_2,\nint VAR_3)\n{",
"pl110_state *s;",
"int VAR_4;",
"s = (pl110_state *)qemu_mallocz(sizeof(pl110_state));",
"VAR_4 = cpu_register_io_memory(0, pl110_readfn,\npl110_writefn, s);",
"cpu_register_physical_memory(VAR_1, 0x00000fff, VAR_4);",
"s->VAR_1 = VAR_1;",
"s->VAR_0 = VAR_0;",
"s->VAR_3 = VAR_3;",
"s->VAR_2 = VAR_2;",
"graphic_console_init(VAR_0, pl110_update_display, pl110_invalidate_display,\nNULL, s);",
"return 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
],
[
37
]
] |
1,782 | void rgb16tobgr15(const uint8_t *src, uint8_t *dst, long src_size)
{
long i;
long num_pixels = src_size >> 1;
for(i=0; i<num_pixels; i++)
{
unsigned b,g,r;
register uint16_t rgb;
rgb = src[2*i];
r = rgb&0x1F;
g = (rgb&0x7E0)>>5;
b = (rgb&0xF800)>>11;
dst[2*i] = (b&0x1F) | ((g&0x1F)<<5) | ((r&0x1F)<<10);
}
}
| true | FFmpeg | 6e42e6c4b410dbef8b593c2d796a5dad95f89ee4 | void rgb16tobgr15(const uint8_t *src, uint8_t *dst, long src_size)
{
long i;
long num_pixels = src_size >> 1;
for(i=0; i<num_pixels; i++)
{
unsigned b,g,r;
register uint16_t rgb;
rgb = src[2*i];
r = rgb&0x1F;
g = (rgb&0x7E0)>>5;
b = (rgb&0xF800)>>11;
dst[2*i] = (b&0x1F) | ((g&0x1F)<<5) | ((r&0x1F)<<10);
}
}
| {
"code": [
"\tlong i;",
"\tfor(i=0; i<num_pixels; i++)",
"\tfor(i=0; i<num_pixels; i++)",
"\tlong i;",
"\tfor(i=0; i<num_pixels; i++)",
"\tlong i;",
"\tfor(i=0; i<num_pixels; i++)",
"\tfor(i=0; i<num_pixels; i++)",
"\tlong i;",
"\tfor(i=0; i<num_pixels; i++)",
"\tfor(i=0; i<num_pixels; i++)",
"\tlong i;",
"\tfor(i=0; i<num_pixels; i++)",
"\tlong i;",
"\tfor(i=0; i<num_pixels; i++)",
"\tlong i;",
"\tfor(i=0; i<num_pixels; i++)",
"\tlong i;",
"\tfor(i=0; i<num_pixels; i++)",
"\tlong i;",
"\tfor(i=0; i<num_pixels; i++)",
"\tlong i;",
"\tlong i;",
"\tlong num_pixels = src_size >> 1;",
"\tfor(i=0; i<num_pixels; i++)",
"\t unsigned b,g,r;",
"\t register uint16_t rgb;",
"\t rgb = src[2*i];",
"\t r = rgb&0x1F;",
"\t g = (rgb&0x7E0)>>5;",
"\t b = (rgb&0xF800)>>11;",
"\tlong i;",
"\tlong num_pixels = src_size >> 1;",
"\tfor(i=0; i<num_pixels; i++)",
"\t unsigned b,g,r;",
"\t register uint16_t rgb;",
"\t rgb = src[2*i];",
"\t r = rgb&0x1F;",
"\t g = (rgb&0x7E0)>>5;",
"\t b = (rgb&0xF800)>>11;",
"\t dst[2*i] = (b&0x1F) | ((g&0x1F)<<5) | ((r&0x1F)<<10);",
"\tlong i;",
"\tlong num_pixels = src_size >> 1;",
"\tfor(i=0; i<num_pixels; i++)",
"\t unsigned b,g,r;",
"\t register uint16_t rgb;",
"\t rgb = src[2*i];",
"\t r = rgb&0x1F;",
"\tlong i;",
"\tlong num_pixels = src_size >> 1;",
"\tfor(i=0; i<num_pixels; i++)",
"\t unsigned b,g,r;",
"\t register uint16_t rgb;",
"\t rgb = src[2*i];",
"\t r = rgb&0x1F;",
"\t dst[2*i] = (b&0x1F) | ((g&0x1F)<<5) | ((r&0x1F)<<10);",
"\tlong i;",
"\tfor(i=0; i<num_pixels; i++)",
"\t unsigned b,g,r;"
],
"line_no": [
5,
11,
11,
5,
11,
5,
11,
11,
5,
11,
11,
5,
11,
5,
11,
5,
11,
5,
11,
5,
11,
5,
5,
7,
11,
15,
17,
19,
21,
23,
25,
5,
7,
11,
15,
17,
19,
21,
23,
25,
27,
5,
7,
11,
15,
17,
19,
21,
5,
7,
11,
15,
17,
19,
21,
27,
5,
11,
15
]
} | void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, long VAR_2)
{
long VAR_3;
long VAR_4 = VAR_2 >> 1;
for(VAR_3=0; VAR_3<VAR_4; VAR_3++)
{
unsigned VAR_5,VAR_6,VAR_7;
register uint16_t VAR_8;
VAR_8 = VAR_0[2*VAR_3];
VAR_7 = VAR_8&0x1F;
VAR_6 = (VAR_8&0x7E0)>>5;
VAR_5 = (VAR_8&0xF800)>>11;
VAR_1[2*VAR_3] = (VAR_5&0x1F) | ((VAR_6&0x1F)<<5) | ((VAR_7&0x1F)<<10);
}
}
| [
"void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, long VAR_2)\n{",
"long VAR_3;",
"long VAR_4 = VAR_2 >> 1;",
"for(VAR_3=0; VAR_3<VAR_4; VAR_3++)",
"{",
"unsigned VAR_5,VAR_6,VAR_7;",
"register uint16_t VAR_8;",
"VAR_8 = VAR_0[2*VAR_3];",
"VAR_7 = VAR_8&0x1F;",
"VAR_6 = (VAR_8&0x7E0)>>5;",
"VAR_5 = (VAR_8&0xF800)>>11;",
"VAR_1[2*VAR_3] = (VAR_5&0x1F) | ((VAR_6&0x1F)<<5) | ((VAR_7&0x1F)<<10);",
"}",
"}"
] | [
0,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
]
] |
1,784 | static void replication_start(ReplicationState *rs, ReplicationMode mode,
Error **errp)
{
BlockDriverState *bs = rs->opaque;
BDRVReplicationState *s;
BlockDriverState *top_bs;
int64_t active_length, hidden_length, disk_length;
AioContext *aio_context;
Error *local_err = NULL;
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
s = bs->opaque;
if (s->replication_state != BLOCK_REPLICATION_NONE) {
error_setg(errp, "Block replication is running or done");
aio_context_release(aio_context);
return;
}
if (s->mode != mode) {
error_setg(errp, "The parameter mode's value is invalid, needs %d,"
" but got %d", s->mode, mode);
aio_context_release(aio_context);
return;
}
switch (s->mode) {
case REPLICATION_MODE_PRIMARY:
break;
case REPLICATION_MODE_SECONDARY:
s->active_disk = bs->file;
if (!s->active_disk || !s->active_disk->bs ||
!s->active_disk->bs->backing) {
error_setg(errp, "Active disk doesn't have backing file");
aio_context_release(aio_context);
return;
}
s->hidden_disk = s->active_disk->bs->backing;
if (!s->hidden_disk->bs || !s->hidden_disk->bs->backing) {
error_setg(errp, "Hidden disk doesn't have backing file");
aio_context_release(aio_context);
return;
}
s->secondary_disk = s->hidden_disk->bs->backing;
if (!s->secondary_disk->bs || !bdrv_has_blk(s->secondary_disk->bs)) {
error_setg(errp, "The secondary disk doesn't have block backend");
aio_context_release(aio_context);
return;
}
/* verify the length */
active_length = bdrv_getlength(s->active_disk->bs);
hidden_length = bdrv_getlength(s->hidden_disk->bs);
disk_length = bdrv_getlength(s->secondary_disk->bs);
if (active_length < 0 || hidden_length < 0 || disk_length < 0 ||
active_length != hidden_length || hidden_length != disk_length) {
error_setg(errp, "Active disk, hidden disk, secondary disk's length"
" are not the same");
aio_context_release(aio_context);
return;
}
if (!s->active_disk->bs->drv->bdrv_make_empty ||
!s->hidden_disk->bs->drv->bdrv_make_empty) {
error_setg(errp,
"Active disk or hidden disk doesn't support make_empty");
aio_context_release(aio_context);
return;
}
/* reopen the backing file in r/w mode */
reopen_backing_file(bs, true, &local_err);
if (local_err) {
error_propagate(errp, local_err);
aio_context_release(aio_context);
return;
}
/* start backup job now */
error_setg(&s->blocker,
"Block device is in use by internal backup job");
top_bs = bdrv_lookup_bs(s->top_id, s->top_id, NULL);
if (!top_bs || !bdrv_is_root_node(top_bs) ||
!check_top_bs(top_bs, bs)) {
error_setg(errp, "No top_bs or it is invalid");
reopen_backing_file(bs, false, NULL);
aio_context_release(aio_context);
return;
}
bdrv_op_block_all(top_bs, s->blocker);
bdrv_op_unblock(top_bs, BLOCK_OP_TYPE_DATAPLANE, s->blocker);
backup_start(NULL, s->secondary_disk->bs, s->hidden_disk->bs, 0,
MIRROR_SYNC_MODE_NONE, NULL, false,
BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
BLOCK_JOB_INTERNAL, backup_job_completed, bs,
NULL, &local_err);
if (local_err) {
error_propagate(errp, local_err);
backup_job_cleanup(bs);
aio_context_release(aio_context);
return;
}
break;
default:
aio_context_release(aio_context);
abort();
}
s->replication_state = BLOCK_REPLICATION_RUNNING;
if (s->mode == REPLICATION_MODE_SECONDARY) {
secondary_do_checkpoint(s, errp);
}
s->error = 0;
aio_context_release(aio_context);
}
| true | qemu | 111049a4ecefc9cf1ac75c773f4c5c165f27fe63 | static void replication_start(ReplicationState *rs, ReplicationMode mode,
Error **errp)
{
BlockDriverState *bs = rs->opaque;
BDRVReplicationState *s;
BlockDriverState *top_bs;
int64_t active_length, hidden_length, disk_length;
AioContext *aio_context;
Error *local_err = NULL;
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
s = bs->opaque;
if (s->replication_state != BLOCK_REPLICATION_NONE) {
error_setg(errp, "Block replication is running or done");
aio_context_release(aio_context);
return;
}
if (s->mode != mode) {
error_setg(errp, "The parameter mode's value is invalid, needs %d,"
" but got %d", s->mode, mode);
aio_context_release(aio_context);
return;
}
switch (s->mode) {
case REPLICATION_MODE_PRIMARY:
break;
case REPLICATION_MODE_SECONDARY:
s->active_disk = bs->file;
if (!s->active_disk || !s->active_disk->bs ||
!s->active_disk->bs->backing) {
error_setg(errp, "Active disk doesn't have backing file");
aio_context_release(aio_context);
return;
}
s->hidden_disk = s->active_disk->bs->backing;
if (!s->hidden_disk->bs || !s->hidden_disk->bs->backing) {
error_setg(errp, "Hidden disk doesn't have backing file");
aio_context_release(aio_context);
return;
}
s->secondary_disk = s->hidden_disk->bs->backing;
if (!s->secondary_disk->bs || !bdrv_has_blk(s->secondary_disk->bs)) {
error_setg(errp, "The secondary disk doesn't have block backend");
aio_context_release(aio_context);
return;
}
active_length = bdrv_getlength(s->active_disk->bs);
hidden_length = bdrv_getlength(s->hidden_disk->bs);
disk_length = bdrv_getlength(s->secondary_disk->bs);
if (active_length < 0 || hidden_length < 0 || disk_length < 0 ||
active_length != hidden_length || hidden_length != disk_length) {
error_setg(errp, "Active disk, hidden disk, secondary disk's length"
" are not the same");
aio_context_release(aio_context);
return;
}
if (!s->active_disk->bs->drv->bdrv_make_empty ||
!s->hidden_disk->bs->drv->bdrv_make_empty) {
error_setg(errp,
"Active disk or hidden disk doesn't support make_empty");
aio_context_release(aio_context);
return;
}
reopen_backing_file(bs, true, &local_err);
if (local_err) {
error_propagate(errp, local_err);
aio_context_release(aio_context);
return;
}
error_setg(&s->blocker,
"Block device is in use by internal backup job");
top_bs = bdrv_lookup_bs(s->top_id, s->top_id, NULL);
if (!top_bs || !bdrv_is_root_node(top_bs) ||
!check_top_bs(top_bs, bs)) {
error_setg(errp, "No top_bs or it is invalid");
reopen_backing_file(bs, false, NULL);
aio_context_release(aio_context);
return;
}
bdrv_op_block_all(top_bs, s->blocker);
bdrv_op_unblock(top_bs, BLOCK_OP_TYPE_DATAPLANE, s->blocker);
backup_start(NULL, s->secondary_disk->bs, s->hidden_disk->bs, 0,
MIRROR_SYNC_MODE_NONE, NULL, false,
BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
BLOCK_JOB_INTERNAL, backup_job_completed, bs,
NULL, &local_err);
if (local_err) {
error_propagate(errp, local_err);
backup_job_cleanup(bs);
aio_context_release(aio_context);
return;
}
break;
default:
aio_context_release(aio_context);
abort();
}
s->replication_state = BLOCK_REPLICATION_RUNNING;
if (s->mode == REPLICATION_MODE_SECONDARY) {
secondary_do_checkpoint(s, errp);
}
s->error = 0;
aio_context_release(aio_context);
}
| {
"code": [
" backup_start(NULL, s->secondary_disk->bs, s->hidden_disk->bs, 0,",
" MIRROR_SYNC_MODE_NONE, NULL, false,",
" BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,",
" BLOCK_JOB_INTERNAL, backup_job_completed, bs,",
" NULL, &local_err);"
],
"line_no": [
193,
195,
197,
199,
201
]
} | static void FUNC_0(ReplicationState *VAR_0, ReplicationMode VAR_1,
Error **VAR_2)
{
BlockDriverState *bs = VAR_0->opaque;
BDRVReplicationState *s;
BlockDriverState *top_bs;
int64_t active_length, hidden_length, disk_length;
AioContext *aio_context;
Error *local_err = NULL;
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
s = bs->opaque;
if (s->replication_state != BLOCK_REPLICATION_NONE) {
error_setg(VAR_2, "Block replication is running or done");
aio_context_release(aio_context);
return;
}
if (s->VAR_1 != VAR_1) {
error_setg(VAR_2, "The parameter VAR_1's value is invalid, needs %d,"
" but got %d", s->VAR_1, VAR_1);
aio_context_release(aio_context);
return;
}
switch (s->VAR_1) {
case REPLICATION_MODE_PRIMARY:
break;
case REPLICATION_MODE_SECONDARY:
s->active_disk = bs->file;
if (!s->active_disk || !s->active_disk->bs ||
!s->active_disk->bs->backing) {
error_setg(VAR_2, "Active disk doesn't have backing file");
aio_context_release(aio_context);
return;
}
s->hidden_disk = s->active_disk->bs->backing;
if (!s->hidden_disk->bs || !s->hidden_disk->bs->backing) {
error_setg(VAR_2, "Hidden disk doesn't have backing file");
aio_context_release(aio_context);
return;
}
s->secondary_disk = s->hidden_disk->bs->backing;
if (!s->secondary_disk->bs || !bdrv_has_blk(s->secondary_disk->bs)) {
error_setg(VAR_2, "The secondary disk doesn't have block backend");
aio_context_release(aio_context);
return;
}
active_length = bdrv_getlength(s->active_disk->bs);
hidden_length = bdrv_getlength(s->hidden_disk->bs);
disk_length = bdrv_getlength(s->secondary_disk->bs);
if (active_length < 0 || hidden_length < 0 || disk_length < 0 ||
active_length != hidden_length || hidden_length != disk_length) {
error_setg(VAR_2, "Active disk, hidden disk, secondary disk's length"
" are not the same");
aio_context_release(aio_context);
return;
}
if (!s->active_disk->bs->drv->bdrv_make_empty ||
!s->hidden_disk->bs->drv->bdrv_make_empty) {
error_setg(VAR_2,
"Active disk or hidden disk doesn't support make_empty");
aio_context_release(aio_context);
return;
}
reopen_backing_file(bs, true, &local_err);
if (local_err) {
error_propagate(VAR_2, local_err);
aio_context_release(aio_context);
return;
}
error_setg(&s->blocker,
"Block device is in use by internal backup job");
top_bs = bdrv_lookup_bs(s->top_id, s->top_id, NULL);
if (!top_bs || !bdrv_is_root_node(top_bs) ||
!check_top_bs(top_bs, bs)) {
error_setg(VAR_2, "No top_bs or it is invalid");
reopen_backing_file(bs, false, NULL);
aio_context_release(aio_context);
return;
}
bdrv_op_block_all(top_bs, s->blocker);
bdrv_op_unblock(top_bs, BLOCK_OP_TYPE_DATAPLANE, s->blocker);
backup_start(NULL, s->secondary_disk->bs, s->hidden_disk->bs, 0,
MIRROR_SYNC_MODE_NONE, NULL, false,
BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
BLOCK_JOB_INTERNAL, backup_job_completed, bs,
NULL, &local_err);
if (local_err) {
error_propagate(VAR_2, local_err);
backup_job_cleanup(bs);
aio_context_release(aio_context);
return;
}
break;
default:
aio_context_release(aio_context);
abort();
}
s->replication_state = BLOCK_REPLICATION_RUNNING;
if (s->VAR_1 == REPLICATION_MODE_SECONDARY) {
secondary_do_checkpoint(s, VAR_2);
}
s->error = 0;
aio_context_release(aio_context);
}
| [
"static void FUNC_0(ReplicationState *VAR_0, ReplicationMode VAR_1,\nError **VAR_2)\n{",
"BlockDriverState *bs = VAR_0->opaque;",
"BDRVReplicationState *s;",
"BlockDriverState *top_bs;",
"int64_t active_length, hidden_length, disk_length;",
"AioContext *aio_context;",
"Error *local_err = NULL;",
"aio_context = bdrv_get_aio_context(bs);",
"aio_context_acquire(aio_context);",
"s = bs->opaque;",
"if (s->replication_state != BLOCK_REPLICATION_NONE) {",
"error_setg(VAR_2, \"Block replication is running or done\");",
"aio_context_release(aio_context);",
"return;",
"}",
"if (s->VAR_1 != VAR_1) {",
"error_setg(VAR_2, \"The parameter VAR_1's value is invalid, needs %d,\"\n\" but got %d\", s->VAR_1, VAR_1);",
"aio_context_release(aio_context);",
"return;",
"}",
"switch (s->VAR_1) {",
"case REPLICATION_MODE_PRIMARY:\nbreak;",
"case REPLICATION_MODE_SECONDARY:\ns->active_disk = bs->file;",
"if (!s->active_disk || !s->active_disk->bs ||\n!s->active_disk->bs->backing) {",
"error_setg(VAR_2, \"Active disk doesn't have backing file\");",
"aio_context_release(aio_context);",
"return;",
"}",
"s->hidden_disk = s->active_disk->bs->backing;",
"if (!s->hidden_disk->bs || !s->hidden_disk->bs->backing) {",
"error_setg(VAR_2, \"Hidden disk doesn't have backing file\");",
"aio_context_release(aio_context);",
"return;",
"}",
"s->secondary_disk = s->hidden_disk->bs->backing;",
"if (!s->secondary_disk->bs || !bdrv_has_blk(s->secondary_disk->bs)) {",
"error_setg(VAR_2, \"The secondary disk doesn't have block backend\");",
"aio_context_release(aio_context);",
"return;",
"}",
"active_length = bdrv_getlength(s->active_disk->bs);",
"hidden_length = bdrv_getlength(s->hidden_disk->bs);",
"disk_length = bdrv_getlength(s->secondary_disk->bs);",
"if (active_length < 0 || hidden_length < 0 || disk_length < 0 ||\nactive_length != hidden_length || hidden_length != disk_length) {",
"error_setg(VAR_2, \"Active disk, hidden disk, secondary disk's length\"\n\" are not the same\");",
"aio_context_release(aio_context);",
"return;",
"}",
"if (!s->active_disk->bs->drv->bdrv_make_empty ||\n!s->hidden_disk->bs->drv->bdrv_make_empty) {",
"error_setg(VAR_2,\n\"Active disk or hidden disk doesn't support make_empty\");",
"aio_context_release(aio_context);",
"return;",
"}",
"reopen_backing_file(bs, true, &local_err);",
"if (local_err) {",
"error_propagate(VAR_2, local_err);",
"aio_context_release(aio_context);",
"return;",
"}",
"error_setg(&s->blocker,\n\"Block device is in use by internal backup job\");",
"top_bs = bdrv_lookup_bs(s->top_id, s->top_id, NULL);",
"if (!top_bs || !bdrv_is_root_node(top_bs) ||\n!check_top_bs(top_bs, bs)) {",
"error_setg(VAR_2, \"No top_bs or it is invalid\");",
"reopen_backing_file(bs, false, NULL);",
"aio_context_release(aio_context);",
"return;",
"}",
"bdrv_op_block_all(top_bs, s->blocker);",
"bdrv_op_unblock(top_bs, BLOCK_OP_TYPE_DATAPLANE, s->blocker);",
"backup_start(NULL, s->secondary_disk->bs, s->hidden_disk->bs, 0,\nMIRROR_SYNC_MODE_NONE, NULL, false,\nBLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,\nBLOCK_JOB_INTERNAL, backup_job_completed, bs,\nNULL, &local_err);",
"if (local_err) {",
"error_propagate(VAR_2, local_err);",
"backup_job_cleanup(bs);",
"aio_context_release(aio_context);",
"return;",
"}",
"break;",
"default:\naio_context_release(aio_context);",
"abort();",
"}",
"s->replication_state = BLOCK_REPLICATION_RUNNING;",
"if (s->VAR_1 == REPLICATION_MODE_SECONDARY) {",
"secondary_do_checkpoint(s, VAR_2);",
"}",
"s->error = 0;",
"aio_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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57,
59
],
[
61,
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
109
],
[
111
],
[
113
],
[
115,
117
],
[
119,
121
],
[
123
],
[
125
],
[
127
],
[
131,
133
],
[
135,
137
],
[
139
],
[
141
],
[
143
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
165,
167
],
[
171
],
[
173,
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
193,
195,
197,
199,
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217,
219
],
[
221
],
[
223
],
[
227
],
[
231
],
[
233
],
[
235
],
[
239
],
[
241
],
[
243
]
] |
1,785 | static inline void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused)
{
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(
"movq "MANGLE(bm01010101)", %%mm4 \n\t"
"mov %0, %%"REG_a" \n\t"
"1: \n\t"
"movq (%1, %%"REG_a",4), %%mm0 \n\t"
"movq 8(%1, %%"REG_a",4), %%mm1 \n\t"
"pand %%mm4, %%mm0 \n\t"
"pand %%mm4, %%mm1 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"movq %%mm0, %%mm1 \n\t"
"psrlw $8, %%mm0 \n\t"
"pand %%mm4, %%mm1 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"packuswb %%mm1, %%mm1 \n\t"
"movd %%mm0, (%3, %%"REG_a") \n\t"
"movd %%mm1, (%2, %%"REG_a") \n\t"
"add $4, %%"REG_a" \n\t"
" js 1b \n\t"
: : "g" ((x86_reg)-width), "r" (src1+width*4), "r" (dstU+width), "r" (dstV+width)
: "%"REG_a
);
#else
int i;
for (i=0; i<width; i++) {
dstU[i]= src1[4*i + 0];
dstV[i]= src1[4*i + 2];
}
#endif
assert(src1 == src2);
}
| true | FFmpeg | c3ab0004ae4dffc32494ae84dd15cfaa909a7884 | static inline void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused)
{
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(
"movq "MANGLE(bm01010101)", %%mm4 \n\t"
"mov %0, %%"REG_a" \n\t"
"1: \n\t"
"movq (%1, %%"REG_a",4), %%mm0 \n\t"
"movq 8(%1, %%"REG_a",4), %%mm1 \n\t"
"pand %%mm4, %%mm0 \n\t"
"pand %%mm4, %%mm1 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"movq %%mm0, %%mm1 \n\t"
"psrlw $8, %%mm0 \n\t"
"pand %%mm4, %%mm1 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"packuswb %%mm1, %%mm1 \n\t"
"movd %%mm0, (%3, %%"REG_a") \n\t"
"movd %%mm1, (%2, %%"REG_a") \n\t"
"add $4, %%"REG_a" \n\t"
" js 1b \n\t"
: : "g" ((x86_reg)-width), "r" (src1+width*4), "r" (dstU+width), "r" (dstV+width)
: "%"REG_a
);
#else
int i;
for (i=0; i<width; i++) {
dstU[i]= src1[4*i + 0];
dstV[i]= src1[4*i + 2];
}
#endif
assert(src1 == src2);
}
| {
"code": [
"static inline void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused)"
],
"line_no": [
1
]
} | static inline void FUNC_0(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused)
{
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(
"movq "MANGLE(bm01010101)", %%mm4 \n\t"
"mov %0, %%"REG_a" \n\t"
"1: \n\t"
"movq (%1, %%"REG_a",4), %%mm0 \n\t"
"movq 8(%1, %%"REG_a",4), %%mm1 \n\t"
"pand %%mm4, %%mm0 \n\t"
"pand %%mm4, %%mm1 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"movq %%mm0, %%mm1 \n\t"
"psrlw $8, %%mm0 \n\t"
"pand %%mm4, %%mm1 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"packuswb %%mm1, %%mm1 \n\t"
"movd %%mm0, (%3, %%"REG_a") \n\t"
"movd %%mm1, (%2, %%"REG_a") \n\t"
"add $4, %%"REG_a" \n\t"
" js 1b \n\t"
: : "g" ((x86_reg)-width), "r" (src1+width*4), "r" (dstU+width), "r" (dstV+width)
: "%"REG_a
);
#else
int VAR_0;
for (VAR_0=0; VAR_0<width; VAR_0++) {
dstU[VAR_0]= src1[4*VAR_0 + 0];
dstV[VAR_0]= src1[4*VAR_0 + 2];
}
#endif
assert(src1 == src2);
}
| [
"static inline void FUNC_0(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused)\n{",
"#if COMPILE_TEMPLATE_MMX\n__asm__ volatile(\n\"movq \"MANGLE(bm01010101)\", %%mm4 \\n\\t\"\n\"mov %0, %%\"REG_a\" \\n\\t\"\n\"1: \\n\\t\"\n\"movq (%1, %%\"REG_a\",4), %%mm0 \\n\\t\"\n\"movq 8(%1, %%\"REG_a\",4), %%mm1 \\n\\t\"\n\"pand %%mm4, %%mm0 \\n\\t\"\n\"pand %%mm4, %%mm1 \\n\\t\"\n\"packuswb %%mm1, %%mm0 \\n\\t\"\n\"movq %%mm0, %%mm1 \\n\\t\"\n\"psrlw $8, %%mm0 \\n\\t\"\n\"pand %%mm4, %%mm1 \\n\\t\"\n\"packuswb %%mm0, %%mm0 \\n\\t\"\n\"packuswb %%mm1, %%mm1 \\n\\t\"\n\"movd %%mm0, (%3, %%\"REG_a\") \\n\\t\"\n\"movd %%mm1, (%2, %%\"REG_a\") \\n\\t\"\n\"add $4, %%\"REG_a\" \\n\\t\"\n\" js 1b \\n\\t\"\n: : \"g\" ((x86_reg)-width), \"r\" (src1+width*4), \"r\" (dstU+width), \"r\" (dstV+width)\n: \"%\"REG_a\n);",
"#else\nint VAR_0;",
"for (VAR_0=0; VAR_0<width; VAR_0++) {",
"dstU[VAR_0]= src1[4*VAR_0 + 0];",
"dstV[VAR_0]= src1[4*VAR_0 + 2];",
"}",
"#endif\nassert(src1 == src2);",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7,
9,
11,
13,
15,
17,
19,
21,
23,
25,
27,
29,
31,
33,
35,
37,
39,
41,
43,
45,
47
],
[
49,
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[
65
]
] |
1,786 | uint32_t vga_mem_readb(VGACommonState *s, hwaddr addr)
{
int memory_map_mode, plane;
uint32_t ret;
/* convert to VGA memory offset */
memory_map_mode = (s->gr[VGA_GFX_MISC] >> 2) & 3;
addr &= 0x1ffff;
switch(memory_map_mode) {
case 0:
break;
case 1:
if (addr >= 0x10000)
return 0xff;
addr += s->bank_offset;
break;
case 2:
addr -= 0x10000;
if (addr >= 0x8000)
return 0xff;
break;
default:
case 3:
addr -= 0x18000;
if (addr >= 0x8000)
return 0xff;
break;
}
if (s->sr[VGA_SEQ_MEMORY_MODE] & VGA_SR04_CHN_4M) {
/* chain 4 mode : simplest access */
ret = s->vram_ptr[addr];
} else if (s->gr[VGA_GFX_MODE] & 0x10) {
/* odd/even mode (aka text mode mapping) */
plane = (s->gr[VGA_GFX_PLANE_READ] & 2) | (addr & 1);
ret = s->vram_ptr[((addr & ~1) << 1) | plane];
} else {
/* standard VGA latched access */
s->latch = ((uint32_t *)s->vram_ptr)[addr];
if (!(s->gr[VGA_GFX_MODE] & 0x08)) {
/* read mode 0 */
plane = s->gr[VGA_GFX_PLANE_READ];
ret = GET_PLANE(s->latch, plane);
} else {
/* read mode 1 */
ret = (s->latch ^ mask16[s->gr[VGA_GFX_COMPARE_VALUE]]) &
mask16[s->gr[VGA_GFX_COMPARE_MASK]];
ret |= ret >> 16;
ret |= ret >> 8;
ret = (~ret) & 0xff;
}
}
return ret;
}
| true | qemu | 3bf1817079bb0d80c0d8a86a7c7dd0bfe90eb82e | uint32_t vga_mem_readb(VGACommonState *s, hwaddr addr)
{
int memory_map_mode, plane;
uint32_t ret;
memory_map_mode = (s->gr[VGA_GFX_MISC] >> 2) & 3;
addr &= 0x1ffff;
switch(memory_map_mode) {
case 0:
break;
case 1:
if (addr >= 0x10000)
return 0xff;
addr += s->bank_offset;
break;
case 2:
addr -= 0x10000;
if (addr >= 0x8000)
return 0xff;
break;
default:
case 3:
addr -= 0x18000;
if (addr >= 0x8000)
return 0xff;
break;
}
if (s->sr[VGA_SEQ_MEMORY_MODE] & VGA_SR04_CHN_4M) {
ret = s->vram_ptr[addr];
} else if (s->gr[VGA_GFX_MODE] & 0x10) {
plane = (s->gr[VGA_GFX_PLANE_READ] & 2) | (addr & 1);
ret = s->vram_ptr[((addr & ~1) << 1) | plane];
} else {
s->latch = ((uint32_t *)s->vram_ptr)[addr];
if (!(s->gr[VGA_GFX_MODE] & 0x08)) {
plane = s->gr[VGA_GFX_PLANE_READ];
ret = GET_PLANE(s->latch, plane);
} else {
ret = (s->latch ^ mask16[s->gr[VGA_GFX_COMPARE_VALUE]]) &
mask16[s->gr[VGA_GFX_COMPARE_MASK]];
ret |= ret >> 16;
ret |= ret >> 8;
ret = (~ret) & 0xff;
}
}
return ret;
}
| {
"code": [
" ret = s->vram_ptr[((addr & ~1) << 1) | plane];"
],
"line_no": [
71
]
} | uint32_t FUNC_0(VGACommonState *s, hwaddr addr)
{
int VAR_0, VAR_1;
uint32_t ret;
VAR_0 = (s->gr[VGA_GFX_MISC] >> 2) & 3;
addr &= 0x1ffff;
switch(VAR_0) {
case 0:
break;
case 1:
if (addr >= 0x10000)
return 0xff;
addr += s->bank_offset;
break;
case 2:
addr -= 0x10000;
if (addr >= 0x8000)
return 0xff;
break;
default:
case 3:
addr -= 0x18000;
if (addr >= 0x8000)
return 0xff;
break;
}
if (s->sr[VGA_SEQ_MEMORY_MODE] & VGA_SR04_CHN_4M) {
ret = s->vram_ptr[addr];
} else if (s->gr[VGA_GFX_MODE] & 0x10) {
VAR_1 = (s->gr[VGA_GFX_PLANE_READ] & 2) | (addr & 1);
ret = s->vram_ptr[((addr & ~1) << 1) | VAR_1];
} else {
s->latch = ((uint32_t *)s->vram_ptr)[addr];
if (!(s->gr[VGA_GFX_MODE] & 0x08)) {
VAR_1 = s->gr[VGA_GFX_PLANE_READ];
ret = GET_PLANE(s->latch, VAR_1);
} else {
ret = (s->latch ^ mask16[s->gr[VGA_GFX_COMPARE_VALUE]]) &
mask16[s->gr[VGA_GFX_COMPARE_MASK]];
ret |= ret >> 16;
ret |= ret >> 8;
ret = (~ret) & 0xff;
}
}
return ret;
}
| [
"uint32_t FUNC_0(VGACommonState *s, hwaddr addr)\n{",
"int VAR_0, VAR_1;",
"uint32_t ret;",
"VAR_0 = (s->gr[VGA_GFX_MISC] >> 2) & 3;",
"addr &= 0x1ffff;",
"switch(VAR_0) {",
"case 0:\nbreak;",
"case 1:\nif (addr >= 0x10000)\nreturn 0xff;",
"addr += s->bank_offset;",
"break;",
"case 2:\naddr -= 0x10000;",
"if (addr >= 0x8000)\nreturn 0xff;",
"break;",
"default:\ncase 3:\naddr -= 0x18000;",
"if (addr >= 0x8000)\nreturn 0xff;",
"break;",
"}",
"if (s->sr[VGA_SEQ_MEMORY_MODE] & VGA_SR04_CHN_4M) {",
"ret = s->vram_ptr[addr];",
"} else if (s->gr[VGA_GFX_MODE] & 0x10) {",
"VAR_1 = (s->gr[VGA_GFX_PLANE_READ] & 2) | (addr & 1);",
"ret = s->vram_ptr[((addr & ~1) << 1) | VAR_1];",
"} else {",
"s->latch = ((uint32_t *)s->vram_ptr)[addr];",
"if (!(s->gr[VGA_GFX_MODE] & 0x08)) {",
"VAR_1 = s->gr[VGA_GFX_PLANE_READ];",
"ret = GET_PLANE(s->latch, VAR_1);",
"} else {",
"ret = (s->latch ^ mask16[s->gr[VGA_GFX_COMPARE_VALUE]]) &\nmask16[s->gr[VGA_GFX_COMPARE_MASK]];",
"ret |= ret >> 16;",
"ret |= ret >> 8;",
"ret = (~ret) & 0xff;",
"}",
"}",
"return ret;",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
13
],
[
15
],
[
17
],
[
19,
21
],
[
23,
25,
27
],
[
29
],
[
31
],
[
33,
35
],
[
37,
39
],
[
41
],
[
43,
45,
47
],
[
49,
51
],
[
53
],
[
55
],
[
59
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
77
],
[
81
],
[
85
],
[
87
],
[
89
],
[
93,
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
]
] |
1,788 | static av_cold int libx265_encode_close(AVCodecContext *avctx)
{
libx265Context *ctx = avctx->priv_data;
av_frame_free(&avctx->coded_frame);
ctx->api->param_free(ctx->params);
if (ctx->encoder)
ctx->api->encoder_close(ctx->encoder);
return 0;
}
| false | FFmpeg | d6604b29ef544793479d7fb4e05ef6622bb3e534 | static av_cold int libx265_encode_close(AVCodecContext *avctx)
{
libx265Context *ctx = avctx->priv_data;
av_frame_free(&avctx->coded_frame);
ctx->api->param_free(ctx->params);
if (ctx->encoder)
ctx->api->encoder_close(ctx->encoder);
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
libx265Context *ctx = avctx->priv_data;
av_frame_free(&avctx->coded_frame);
ctx->api->param_free(ctx->params);
if (ctx->encoder)
ctx->api->encoder_close(ctx->encoder);
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"libx265Context *ctx = avctx->priv_data;",
"av_frame_free(&avctx->coded_frame);",
"ctx->api->param_free(ctx->params);",
"if (ctx->encoder)\nctx->api->encoder_close(ctx->encoder);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
17,
19
],
[
23
],
[
25
]
] |
1,789 | static void dvbsub_parse_pixel_data_block(AVCodecContext *avctx, DVBSubObjectDisplay *display,
const uint8_t *buf, int buf_size, int top_bottom, int non_mod)
{
DVBSubContext *ctx = avctx->priv_data;
DVBSubRegion *region = get_region(ctx, display->region_id);
const uint8_t *buf_end = buf + buf_size;
uint8_t *pbuf;
int x_pos, y_pos;
int i;
uint8_t map2to4[] = { 0x0, 0x7, 0x8, 0xf};
uint8_t map2to8[] = {0x00, 0x77, 0x88, 0xff};
uint8_t map4to8[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};
uint8_t *map_table;
#if 0
av_dlog(avctx, "DVB pixel block size %d, %s field:\n", buf_size,
top_bottom ? "bottom" : "top");
for (i = 0; i < buf_size; i++) {
if (i % 16 == 0)
av_dlog(avctx, "0x%8p: ", buf+i);
av_dlog(avctx, "%02x ", buf[i]);
if (i % 16 == 15)
av_dlog(avctx, "\n");
}
if (i % 16)
av_dlog(avctx, "\n");
#endif
if (region == 0)
return;
pbuf = region->pbuf;
region->dirty = 1;
x_pos = display->x_pos;
y_pos = display->y_pos;
if ((y_pos & 1) != top_bottom)
y_pos++;
while (buf < buf_end) {
if (x_pos > region->width || y_pos > region->height) {
av_log(avctx, AV_LOG_ERROR, "Invalid object location!\n");
return;
}
switch (*buf++) {
case 0x10:
if (region->depth == 8)
map_table = map2to8;
else if (region->depth == 4)
map_table = map2to4;
else
map_table = NULL;
x_pos += dvbsub_read_2bit_string(pbuf + (y_pos * region->width) + x_pos,
region->width - x_pos, &buf, buf_end - buf,
non_mod, map_table);
break;
case 0x11:
if (region->depth < 4) {
av_log(avctx, AV_LOG_ERROR, "4-bit pixel string in %d-bit region!\n", region->depth);
return;
}
if (region->depth == 8)
map_table = map4to8;
else
map_table = NULL;
x_pos += dvbsub_read_4bit_string(pbuf + (y_pos * region->width) + x_pos,
region->width - x_pos, &buf, buf_end - buf,
non_mod, map_table);
break;
case 0x12:
if (region->depth < 8) {
av_log(avctx, AV_LOG_ERROR, "8-bit pixel string in %d-bit region!\n", region->depth);
return;
}
x_pos += dvbsub_read_8bit_string(pbuf + (y_pos * region->width) + x_pos,
region->width - x_pos, &buf, buf_end - buf,
non_mod, NULL);
break;
case 0x20:
map2to4[0] = (*buf) >> 4;
map2to4[1] = (*buf++) & 0xf;
map2to4[2] = (*buf) >> 4;
map2to4[3] = (*buf++) & 0xf;
break;
case 0x21:
for (i = 0; i < 4; i++)
map2to8[i] = *buf++;
break;
case 0x22:
for (i = 0; i < 16; i++)
map4to8[i] = *buf++;
break;
case 0xf0:
x_pos = display->x_pos;
y_pos += 2;
break;
default:
av_log(avctx, AV_LOG_INFO, "Unknown/unsupported pixel block 0x%x\n", *(buf-1));
}
}
}
| false | FFmpeg | 55f17d3175e5d0e6541ef432a88154e0210a9c10 | static void dvbsub_parse_pixel_data_block(AVCodecContext *avctx, DVBSubObjectDisplay *display,
const uint8_t *buf, int buf_size, int top_bottom, int non_mod)
{
DVBSubContext *ctx = avctx->priv_data;
DVBSubRegion *region = get_region(ctx, display->region_id);
const uint8_t *buf_end = buf + buf_size;
uint8_t *pbuf;
int x_pos, y_pos;
int i;
uint8_t map2to4[] = { 0x0, 0x7, 0x8, 0xf};
uint8_t map2to8[] = {0x00, 0x77, 0x88, 0xff};
uint8_t map4to8[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};
uint8_t *map_table;
#if 0
av_dlog(avctx, "DVB pixel block size %d, %s field:\n", buf_size,
top_bottom ? "bottom" : "top");
for (i = 0; i < buf_size; i++) {
if (i % 16 == 0)
av_dlog(avctx, "0x%8p: ", buf+i);
av_dlog(avctx, "%02x ", buf[i]);
if (i % 16 == 15)
av_dlog(avctx, "\n");
}
if (i % 16)
av_dlog(avctx, "\n");
#endif
if (region == 0)
return;
pbuf = region->pbuf;
region->dirty = 1;
x_pos = display->x_pos;
y_pos = display->y_pos;
if ((y_pos & 1) != top_bottom)
y_pos++;
while (buf < buf_end) {
if (x_pos > region->width || y_pos > region->height) {
av_log(avctx, AV_LOG_ERROR, "Invalid object location!\n");
return;
}
switch (*buf++) {
case 0x10:
if (region->depth == 8)
map_table = map2to8;
else if (region->depth == 4)
map_table = map2to4;
else
map_table = NULL;
x_pos += dvbsub_read_2bit_string(pbuf + (y_pos * region->width) + x_pos,
region->width - x_pos, &buf, buf_end - buf,
non_mod, map_table);
break;
case 0x11:
if (region->depth < 4) {
av_log(avctx, AV_LOG_ERROR, "4-bit pixel string in %d-bit region!\n", region->depth);
return;
}
if (region->depth == 8)
map_table = map4to8;
else
map_table = NULL;
x_pos += dvbsub_read_4bit_string(pbuf + (y_pos * region->width) + x_pos,
region->width - x_pos, &buf, buf_end - buf,
non_mod, map_table);
break;
case 0x12:
if (region->depth < 8) {
av_log(avctx, AV_LOG_ERROR, "8-bit pixel string in %d-bit region!\n", region->depth);
return;
}
x_pos += dvbsub_read_8bit_string(pbuf + (y_pos * region->width) + x_pos,
region->width - x_pos, &buf, buf_end - buf,
non_mod, NULL);
break;
case 0x20:
map2to4[0] = (*buf) >> 4;
map2to4[1] = (*buf++) & 0xf;
map2to4[2] = (*buf) >> 4;
map2to4[3] = (*buf++) & 0xf;
break;
case 0x21:
for (i = 0; i < 4; i++)
map2to8[i] = *buf++;
break;
case 0x22:
for (i = 0; i < 16; i++)
map4to8[i] = *buf++;
break;
case 0xf0:
x_pos = display->x_pos;
y_pos += 2;
break;
default:
av_log(avctx, AV_LOG_INFO, "Unknown/unsupported pixel block 0x%x\n", *(buf-1));
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVCodecContext *VAR_0, DVBSubObjectDisplay *VAR_1,
const uint8_t *VAR_2, int VAR_3, int VAR_4, int VAR_5)
{
DVBSubContext *ctx = VAR_0->priv_data;
DVBSubRegion *region = get_region(ctx, VAR_1->region_id);
const uint8_t *VAR_6 = VAR_2 + VAR_3;
uint8_t *pbuf;
int VAR_7, VAR_8;
int VAR_9;
uint8_t map2to4[] = { 0x0, 0x7, 0x8, 0xf};
uint8_t map2to8[] = {0x00, 0x77, 0x88, 0xff};
uint8_t map4to8[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};
uint8_t *map_table;
#if 0
av_dlog(VAR_0, "DVB pixel block size %d, %s field:\n", VAR_3,
VAR_4 ? "bottom" : "top");
for (VAR_9 = 0; VAR_9 < VAR_3; VAR_9++) {
if (VAR_9 % 16 == 0)
av_dlog(VAR_0, "0x%8p: ", VAR_2+VAR_9);
av_dlog(VAR_0, "%02x ", VAR_2[VAR_9]);
if (VAR_9 % 16 == 15)
av_dlog(VAR_0, "\n");
}
if (VAR_9 % 16)
av_dlog(VAR_0, "\n");
#endif
if (region == 0)
return;
pbuf = region->pbuf;
region->dirty = 1;
VAR_7 = VAR_1->VAR_7;
VAR_8 = VAR_1->VAR_8;
if ((VAR_8 & 1) != VAR_4)
VAR_8++;
while (VAR_2 < VAR_6) {
if (VAR_7 > region->width || VAR_8 > region->height) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid object location!\n");
return;
}
switch (*VAR_2++) {
case 0x10:
if (region->depth == 8)
map_table = map2to8;
else if (region->depth == 4)
map_table = map2to4;
else
map_table = NULL;
VAR_7 += dvbsub_read_2bit_string(pbuf + (VAR_8 * region->width) + VAR_7,
region->width - VAR_7, &VAR_2, VAR_6 - VAR_2,
VAR_5, map_table);
break;
case 0x11:
if (region->depth < 4) {
av_log(VAR_0, AV_LOG_ERROR, "4-bit pixel string in %d-bit region!\n", region->depth);
return;
}
if (region->depth == 8)
map_table = map4to8;
else
map_table = NULL;
VAR_7 += dvbsub_read_4bit_string(pbuf + (VAR_8 * region->width) + VAR_7,
region->width - VAR_7, &VAR_2, VAR_6 - VAR_2,
VAR_5, map_table);
break;
case 0x12:
if (region->depth < 8) {
av_log(VAR_0, AV_LOG_ERROR, "8-bit pixel string in %d-bit region!\n", region->depth);
return;
}
VAR_7 += dvbsub_read_8bit_string(pbuf + (VAR_8 * region->width) + VAR_7,
region->width - VAR_7, &VAR_2, VAR_6 - VAR_2,
VAR_5, NULL);
break;
case 0x20:
map2to4[0] = (*VAR_2) >> 4;
map2to4[1] = (*VAR_2++) & 0xf;
map2to4[2] = (*VAR_2) >> 4;
map2to4[3] = (*VAR_2++) & 0xf;
break;
case 0x21:
for (VAR_9 = 0; VAR_9 < 4; VAR_9++)
map2to8[VAR_9] = *VAR_2++;
break;
case 0x22:
for (VAR_9 = 0; VAR_9 < 16; VAR_9++)
map4to8[VAR_9] = *VAR_2++;
break;
case 0xf0:
VAR_7 = VAR_1->VAR_7;
VAR_8 += 2;
break;
default:
av_log(VAR_0, AV_LOG_INFO, "Unknown/unsupported pixel block 0x%x\n", *(VAR_2-1));
}
}
}
| [
"static void FUNC_0(AVCodecContext *VAR_0, DVBSubObjectDisplay *VAR_1,\nconst uint8_t *VAR_2, int VAR_3, int VAR_4, int VAR_5)\n{",
"DVBSubContext *ctx = VAR_0->priv_data;",
"DVBSubRegion *region = get_region(ctx, VAR_1->region_id);",
"const uint8_t *VAR_6 = VAR_2 + VAR_3;",
"uint8_t *pbuf;",
"int VAR_7, VAR_8;",
"int VAR_9;",
"uint8_t map2to4[] = { 0x0, 0x7, 0x8, 0xf};",
"uint8_t map2to8[] = {0x00, 0x77, 0x88, 0xff};",
"uint8_t map4to8[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,",
"0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};",
"uint8_t *map_table;",
"#if 0\nav_dlog(VAR_0, \"DVB pixel block size %d, %s field:\\n\", VAR_3,\nVAR_4 ? \"bottom\" : \"top\");",
"for (VAR_9 = 0; VAR_9 < VAR_3; VAR_9++) {",
"if (VAR_9 % 16 == 0)\nav_dlog(VAR_0, \"0x%8p: \", VAR_2+VAR_9);",
"av_dlog(VAR_0, \"%02x \", VAR_2[VAR_9]);",
"if (VAR_9 % 16 == 15)\nav_dlog(VAR_0, \"\\n\");",
"}",
"if (VAR_9 % 16)\nav_dlog(VAR_0, \"\\n\");",
"#endif\nif (region == 0)\nreturn;",
"pbuf = region->pbuf;",
"region->dirty = 1;",
"VAR_7 = VAR_1->VAR_7;",
"VAR_8 = VAR_1->VAR_8;",
"if ((VAR_8 & 1) != VAR_4)\nVAR_8++;",
"while (VAR_2 < VAR_6) {",
"if (VAR_7 > region->width || VAR_8 > region->height) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid object location!\\n\");",
"return;",
"}",
"switch (*VAR_2++) {",
"case 0x10:\nif (region->depth == 8)\nmap_table = map2to8;",
"else if (region->depth == 4)\nmap_table = map2to4;",
"else\nmap_table = NULL;",
"VAR_7 += dvbsub_read_2bit_string(pbuf + (VAR_8 * region->width) + VAR_7,\nregion->width - VAR_7, &VAR_2, VAR_6 - VAR_2,\nVAR_5, map_table);",
"break;",
"case 0x11:\nif (region->depth < 4) {",
"av_log(VAR_0, AV_LOG_ERROR, \"4-bit pixel string in %d-bit region!\\n\", region->depth);",
"return;",
"}",
"if (region->depth == 8)\nmap_table = map4to8;",
"else\nmap_table = NULL;",
"VAR_7 += dvbsub_read_4bit_string(pbuf + (VAR_8 * region->width) + VAR_7,\nregion->width - VAR_7, &VAR_2, VAR_6 - VAR_2,\nVAR_5, map_table);",
"break;",
"case 0x12:\nif (region->depth < 8) {",
"av_log(VAR_0, AV_LOG_ERROR, \"8-bit pixel string in %d-bit region!\\n\", region->depth);",
"return;",
"}",
"VAR_7 += dvbsub_read_8bit_string(pbuf + (VAR_8 * region->width) + VAR_7,\nregion->width - VAR_7, &VAR_2, VAR_6 - VAR_2,\nVAR_5, NULL);",
"break;",
"case 0x20:\nmap2to4[0] = (*VAR_2) >> 4;",
"map2to4[1] = (*VAR_2++) & 0xf;",
"map2to4[2] = (*VAR_2) >> 4;",
"map2to4[3] = (*VAR_2++) & 0xf;",
"break;",
"case 0x21:\nfor (VAR_9 = 0; VAR_9 < 4; VAR_9++)",
"map2to8[VAR_9] = *VAR_2++;",
"break;",
"case 0x22:\nfor (VAR_9 = 0; VAR_9 < 16; VAR_9++)",
"map4to8[VAR_9] = *VAR_2++;",
"break;",
"case 0xf0:\nVAR_7 = VAR_1->VAR_7;",
"VAR_8 += 2;",
"break;",
"default:\nav_log(VAR_0, AV_LOG_INFO, \"Unknown/unsupported pixel block 0x%x\\n\", *(VAR_2-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
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35,
37,
39
],
[
43
],
[
45,
47
],
[
51
],
[
53,
55
],
[
57
],
[
61,
63
],
[
65,
69,
71
],
[
75
],
[
77
],
[
81
],
[
83
],
[
87,
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107,
109,
111
],
[
113,
115
],
[
117,
119
],
[
123,
125,
127
],
[
129
],
[
131,
133
],
[
135
],
[
137
],
[
139
],
[
143,
145
],
[
147,
149
],
[
153,
155,
157
],
[
159
],
[
161,
163
],
[
165
],
[
167
],
[
169
],
[
173,
175,
177
],
[
179
],
[
183,
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195,
197
],
[
199
],
[
201
],
[
203,
205
],
[
207
],
[
209
],
[
213,
215
],
[
217
],
[
219
],
[
221,
223
],
[
225
],
[
227
],
[
231
]
] |
1,790 | static void assert_file_overwrite(const char *filename)
{
if (file_overwrite && file_skip) {
fprintf(stderr, "Error, both -y and -n supplied. Exiting.\n");
exit_program(1);
}
if (!file_overwrite &&
(strchr(filename, ':') == NULL || filename[1] == ':' ||
av_strstart(filename, "file:", NULL))) {
if (avio_check(filename, 0) == 0) {
if (!using_stdin && !file_skip) {
fprintf(stderr,"File '%s' already exists. Overwrite ? [y/N] ", filename);
fflush(stderr);
if (!read_yesno()) {
fprintf(stderr, "Not overwriting - exiting\n");
exit_program(1);
}
}
else {
fprintf(stderr,"File '%s' already exists. Exiting.\n", filename);
exit_program(1);
}
}
}
}
| false | FFmpeg | f929ab0569ff31ed5a59b0b0adb7ce09df3fca39 | static void assert_file_overwrite(const char *filename)
{
if (file_overwrite && file_skip) {
fprintf(stderr, "Error, both -y and -n supplied. Exiting.\n");
exit_program(1);
}
if (!file_overwrite &&
(strchr(filename, ':') == NULL || filename[1] == ':' ||
av_strstart(filename, "file:", NULL))) {
if (avio_check(filename, 0) == 0) {
if (!using_stdin && !file_skip) {
fprintf(stderr,"File '%s' already exists. Overwrite ? [y/N] ", filename);
fflush(stderr);
if (!read_yesno()) {
fprintf(stderr, "Not overwriting - exiting\n");
exit_program(1);
}
}
else {
fprintf(stderr,"File '%s' already exists. Exiting.\n", filename);
exit_program(1);
}
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const char *VAR_0)
{
if (file_overwrite && file_skip) {
fprintf(stderr, "Error, both -y and -n supplied. Exiting.\n");
exit_program(1);
}
if (!file_overwrite &&
(strchr(VAR_0, ':') == NULL || VAR_0[1] == ':' ||
av_strstart(VAR_0, "file:", NULL))) {
if (avio_check(VAR_0, 0) == 0) {
if (!using_stdin && !file_skip) {
fprintf(stderr,"File '%s' already exists. Overwrite ? [y/N] ", VAR_0);
fflush(stderr);
if (!read_yesno()) {
fprintf(stderr, "Not overwriting - exiting\n");
exit_program(1);
}
}
else {
fprintf(stderr,"File '%s' already exists. Exiting.\n", VAR_0);
exit_program(1);
}
}
}
}
| [
"static void FUNC_0(const char *VAR_0)\n{",
"if (file_overwrite && file_skip) {",
"fprintf(stderr, \"Error, both -y and -n supplied. Exiting.\\n\");",
"exit_program(1);",
"}",
"if (!file_overwrite &&\n(strchr(VAR_0, ':') == NULL || VAR_0[1] == ':' ||\nav_strstart(VAR_0, \"file:\", NULL))) {",
"if (avio_check(VAR_0, 0) == 0) {",
"if (!using_stdin && !file_skip) {",
"fprintf(stderr,\"File '%s' already exists. Overwrite ? [y/N] \", VAR_0);",
"fflush(stderr);",
"if (!read_yesno()) {",
"fprintf(stderr, \"Not overwriting - exiting\\n\");",
"exit_program(1);",
"}",
"}",
"else {",
"fprintf(stderr,\"File '%s' already exists. Exiting.\\n\", VAR_0);",
"exit_program(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
],
[
11
],
[
15,
17,
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
]
] |
1,792 | static void tlb_info(Monitor *mon)
{
CPUState *env;
int l1, l2;
uint32_t pgd, pde, pte;
env = mon_get_cpu();
if (!(env->cr[0] & CR0_PG_MASK)) {
monitor_printf(mon, "PG disabled\n");
return;
}
pgd = env->cr[3] & ~0xfff;
for(l1 = 0; l1 < 1024; l1++) {
cpu_physical_memory_read(pgd + l1 * 4, (uint8_t *)&pde, 4);
pde = le32_to_cpu(pde);
if (pde & PG_PRESENT_MASK) {
if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {
print_pte(mon, (l1 << 22), pde, ~((1 << 20) - 1));
} else {
for(l2 = 0; l2 < 1024; l2++) {
cpu_physical_memory_read((pde & ~0xfff) + l2 * 4,
(uint8_t *)&pte, 4);
pte = le32_to_cpu(pte);
if (pte & PG_PRESENT_MASK) {
print_pte(mon, (l1 << 22) + (l2 << 12),
pte & ~PG_PSE_MASK,
~0xfff);
}
}
}
}
}
}
| true | qemu | d65aaf3773e4be7ae97df9d867cbe9b36e2fb8a1 | static void tlb_info(Monitor *mon)
{
CPUState *env;
int l1, l2;
uint32_t pgd, pde, pte;
env = mon_get_cpu();
if (!(env->cr[0] & CR0_PG_MASK)) {
monitor_printf(mon, "PG disabled\n");
return;
}
pgd = env->cr[3] & ~0xfff;
for(l1 = 0; l1 < 1024; l1++) {
cpu_physical_memory_read(pgd + l1 * 4, (uint8_t *)&pde, 4);
pde = le32_to_cpu(pde);
if (pde & PG_PRESENT_MASK) {
if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {
print_pte(mon, (l1 << 22), pde, ~((1 << 20) - 1));
} else {
for(l2 = 0; l2 < 1024; l2++) {
cpu_physical_memory_read((pde & ~0xfff) + l2 * 4,
(uint8_t *)&pte, 4);
pte = le32_to_cpu(pte);
if (pte & PG_PRESENT_MASK) {
print_pte(mon, (l1 << 22) + (l2 << 12),
pte & ~PG_PSE_MASK,
~0xfff);
}
}
}
}
}
}
| {
"code": [
"static void tlb_info(Monitor *mon)",
" CPUState *env;",
" env = mon_get_cpu();",
" if (!(env->cr[0] & CR0_PG_MASK)) {",
" monitor_printf(mon, \"PG disabled\\n\");",
" print_pte(mon, (l1 << 22), pde, ~((1 << 20) - 1));"
],
"line_no": [
1,
5,
13,
17,
19,
37
]
} | static void FUNC_0(Monitor *VAR_0)
{
CPUState *env;
int VAR_1, VAR_2;
uint32_t pgd, pde, pte;
env = mon_get_cpu();
if (!(env->cr[0] & CR0_PG_MASK)) {
monitor_printf(VAR_0, "PG disabled\n");
return;
}
pgd = env->cr[3] & ~0xfff;
for(VAR_1 = 0; VAR_1 < 1024; VAR_1++) {
cpu_physical_memory_read(pgd + VAR_1 * 4, (uint8_t *)&pde, 4);
pde = le32_to_cpu(pde);
if (pde & PG_PRESENT_MASK) {
if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {
print_pte(VAR_0, (VAR_1 << 22), pde, ~((1 << 20) - 1));
} else {
for(VAR_2 = 0; VAR_2 < 1024; VAR_2++) {
cpu_physical_memory_read((pde & ~0xfff) + VAR_2 * 4,
(uint8_t *)&pte, 4);
pte = le32_to_cpu(pte);
if (pte & PG_PRESENT_MASK) {
print_pte(VAR_0, (VAR_1 << 22) + (VAR_2 << 12),
pte & ~PG_PSE_MASK,
~0xfff);
}
}
}
}
}
}
| [
"static void FUNC_0(Monitor *VAR_0)\n{",
"CPUState *env;",
"int VAR_1, VAR_2;",
"uint32_t pgd, pde, pte;",
"env = mon_get_cpu();",
"if (!(env->cr[0] & CR0_PG_MASK)) {",
"monitor_printf(VAR_0, \"PG disabled\\n\");",
"return;",
"}",
"pgd = env->cr[3] & ~0xfff;",
"for(VAR_1 = 0; VAR_1 < 1024; VAR_1++) {",
"cpu_physical_memory_read(pgd + VAR_1 * 4, (uint8_t *)&pde, 4);",
"pde = le32_to_cpu(pde);",
"if (pde & PG_PRESENT_MASK) {",
"if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {",
"print_pte(VAR_0, (VAR_1 << 22), pde, ~((1 << 20) - 1));",
"} else {",
"for(VAR_2 = 0; VAR_2 < 1024; VAR_2++) {",
"cpu_physical_memory_read((pde & ~0xfff) + VAR_2 * 4,\n(uint8_t *)&pte, 4);",
"pte = le32_to_cpu(pte);",
"if (pte & PG_PRESENT_MASK) {",
"print_pte(VAR_0, (VAR_1 << 22) + (VAR_2 << 12),\npte & ~PG_PSE_MASK,\n~0xfff);",
"}",
"}",
"}",
"}",
"}",
"}"
] | [
1,
1,
0,
0,
1,
1,
1,
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
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51,
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
]
] |
1,793 | static void parse_option_number(const char *name, const char *value,
uint64_t *ret, Error **errp)
{
char *postfix;
uint64_t number;
number = strtoull(value, &postfix, 0);
if (*postfix != '\0') {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a number");
return;
}
*ret = number;
}
| true | qemu | 3403e5eb884f3a74c40fe7cccc103f848c040215 | static void parse_option_number(const char *name, const char *value,
uint64_t *ret, Error **errp)
{
char *postfix;
uint64_t number;
number = strtoull(value, &postfix, 0);
if (*postfix != '\0') {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a number");
return;
}
*ret = number;
}
| {
"code": [
" char *postfix;",
" number = strtoull(value, &postfix, 0);",
" if (*postfix != '\\0') {"
],
"line_no": [
7,
13,
15
]
} | static void FUNC_0(const char *VAR_0, const char *VAR_1,
uint64_t *VAR_2, Error **VAR_3)
{
char *VAR_4;
uint64_t number;
number = strtoull(VAR_1, &VAR_4, 0);
if (*VAR_4 != '\0') {
error_setg(VAR_3, QERR_INVALID_PARAMETER_VALUE, VAR_0, "a number");
return;
}
*VAR_2 = number;
}
| [
"static void FUNC_0(const char *VAR_0, const char *VAR_1,\nuint64_t *VAR_2, Error **VAR_3)\n{",
"char *VAR_4;",
"uint64_t number;",
"number = strtoull(VAR_1, &VAR_4, 0);",
"if (*VAR_4 != '\\0') {",
"error_setg(VAR_3, QERR_INVALID_PARAMETER_VALUE, VAR_0, \"a number\");",
"return;",
"}",
"*VAR_2 = number;",
"}"
] | [
0,
1,
0,
1,
1,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
]
] |
1,794 | static int decode_vol_header(MpegEncContext *s, GetBitContext *gb){
int width, height, vo_ver_id;
/* vol header */
skip_bits(gb, 1); /* random access */
s->vo_type= get_bits(gb, 8);
if (get_bits1(gb) != 0) { /* is_ol_id */
vo_ver_id = get_bits(gb, 4); /* vo_ver_id */
skip_bits(gb, 3); /* vo_priority */
} else {
vo_ver_id = 1;
//printf("vo type:%d\n",s->vo_type);
s->aspect_ratio_info= get_bits(gb, 4);
if(s->aspect_ratio_info == FF_ASPECT_EXTENDED){
s->avctx->sample_aspect_ratio.num= get_bits(gb, 8); // par_width
s->avctx->sample_aspect_ratio.den= get_bits(gb, 8); // par_height
}else{
s->avctx->sample_aspect_ratio= pixel_aspect[s->aspect_ratio_info];
if ((s->vol_control_parameters=get_bits1(gb))) { /* vol control parameter */
int chroma_format= get_bits(gb, 2);
if(chroma_format!=1){
av_log(s->avctx, AV_LOG_ERROR, "illegal chroma format\n");
s->low_delay= get_bits1(gb);
if(get_bits1(gb)){ /* vbv parameters */
get_bits(gb, 15); /* first_half_bitrate */
skip_bits1(gb); /* marker */
get_bits(gb, 15); /* latter_half_bitrate */
skip_bits1(gb); /* marker */
get_bits(gb, 15); /* first_half_vbv_buffer_size */
skip_bits1(gb); /* marker */
get_bits(gb, 3); /* latter_half_vbv_buffer_size */
get_bits(gb, 11); /* first_half_vbv_occupancy */
skip_bits1(gb); /* marker */
get_bits(gb, 15); /* latter_half_vbv_occupancy */
skip_bits1(gb); /* marker */
}else{
// set low delay flag only once the smartest? low delay detection won't be overriden
if(s->picture_number==0)
s->low_delay=0;
s->shape = get_bits(gb, 2); /* vol shape */
if(s->shape != RECT_SHAPE) av_log(s->avctx, AV_LOG_ERROR, "only rectangular vol supported\n");
if(s->shape == GRAY_SHAPE && vo_ver_id != 1){
av_log(s->avctx, AV_LOG_ERROR, "Gray shape not supported\n");
skip_bits(gb, 4); //video_object_layer_shape_extension
check_marker(gb, "before time_increment_resolution");
s->avctx->time_base.den = get_bits(gb, 16);
if(!s->avctx->time_base.den){
av_log(s->avctx, AV_LOG_ERROR, "time_base.den==0\n");
s->time_increment_bits = av_log2(s->avctx->time_base.den - 1) + 1;
if (s->time_increment_bits < 1)
s->time_increment_bits = 1;
check_marker(gb, "before fixed_vop_rate");
if (get_bits1(gb) != 0) { /* fixed_vop_rate */
s->avctx->time_base.num = get_bits(gb, s->time_increment_bits);
}else
s->avctx->time_base.num = 1;
s->t_frame=0;
if (s->shape != BIN_ONLY_SHAPE) {
if (s->shape == RECT_SHAPE) {
skip_bits1(gb); /* marker */
width = get_bits(gb, 13);
skip_bits1(gb); /* marker */
height = get_bits(gb, 13);
skip_bits1(gb); /* marker */
if(width && height && !(s->width && s->codec_tag == ff_get_fourcc("MP4S"))){ /* they should be non zero but who knows ... */
s->width = width;
s->height = height;
// printf("width/height: %d %d\n", width, height);
s->progressive_sequence=
s->progressive_frame= get_bits1(gb)^1;
s->interlaced_dct=0;
if(!get_bits1(gb) && (s->avctx->debug & FF_DEBUG_PICT_INFO))
av_log(s->avctx, AV_LOG_INFO, "MPEG4 OBMC not supported (very likely buggy encoder)\n"); /* OBMC Disable */
if (vo_ver_id == 1) {
s->vol_sprite_usage = get_bits1(gb); /* vol_sprite_usage */
} else {
s->vol_sprite_usage = get_bits(gb, 2); /* vol_sprite_usage */
if(s->vol_sprite_usage==STATIC_SPRITE) av_log(s->avctx, AV_LOG_ERROR, "Static Sprites not supported\n");
if(s->vol_sprite_usage==STATIC_SPRITE || s->vol_sprite_usage==GMC_SPRITE){
if(s->vol_sprite_usage==STATIC_SPRITE){
s->sprite_width = get_bits(gb, 13);
skip_bits1(gb); /* marker */
s->sprite_height= get_bits(gb, 13);
skip_bits1(gb); /* marker */
s->sprite_left = get_bits(gb, 13);
skip_bits1(gb); /* marker */
s->sprite_top = get_bits(gb, 13);
skip_bits1(gb); /* marker */
s->num_sprite_warping_points= get_bits(gb, 6);
s->sprite_warping_accuracy = get_bits(gb, 2);
s->sprite_brightness_change= get_bits1(gb);
if(s->vol_sprite_usage==STATIC_SPRITE)
s->low_latency_sprite= get_bits1(gb);
// FIXME sadct disable bit if verid!=1 && shape not rect
if (get_bits1(gb) == 1) { /* not_8_bit */
s->quant_precision = get_bits(gb, 4); /* quant_precision */
if(get_bits(gb, 4)!=8) av_log(s->avctx, AV_LOG_ERROR, "N-bit not supported\n"); /* bits_per_pixel */
if(s->quant_precision!=5) av_log(s->avctx, AV_LOG_ERROR, "quant precision %d\n", s->quant_precision);
} else {
s->quant_precision = 5;
// FIXME a bunch of grayscale shape things
if((s->mpeg_quant=get_bits1(gb))){ /* vol_quant_type */
int i, v;
/* load default matrixes */
for(i=0; i<64; i++){
int j= s->dsp.idct_permutation[i];
v= ff_mpeg4_default_intra_matrix[i];
s->intra_matrix[j]= v;
s->chroma_intra_matrix[j]= v;
v= ff_mpeg4_default_non_intra_matrix[i];
s->inter_matrix[j]= v;
s->chroma_inter_matrix[j]= v;
/* load custom intra matrix */
if(get_bits1(gb)){
int last=0;
for(i=0; i<64; i++){
int j;
v= get_bits(gb, 8);
if(v==0) break;
last= v;
j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
s->intra_matrix[j]= v;
s->chroma_intra_matrix[j]= v;
/* replicate last value */
for(; i<64; i++){
int j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
s->intra_matrix[j]= last;
s->chroma_intra_matrix[j]= last;
/* load custom non intra matrix */
if(get_bits1(gb)){
int last=0;
for(i=0; i<64; i++){
int j;
v= get_bits(gb, 8);
if(v==0) break;
last= v;
j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
s->inter_matrix[j]= v;
s->chroma_inter_matrix[j]= v;
/* replicate last value */
for(; i<64; i++){
int j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
s->inter_matrix[j]= last;
s->chroma_inter_matrix[j]= last;
// FIXME a bunch of grayscale shape things
if(vo_ver_id != 1)
s->quarter_sample= get_bits1(gb);
else s->quarter_sample=0;
if(!get_bits1(gb)) av_log(s->avctx, AV_LOG_ERROR, "Complexity estimation not supported\n");
s->resync_marker= !get_bits1(gb); /* resync_marker_disabled */
s->data_partitioning= get_bits1(gb);
if(s->data_partitioning){
s->rvlc= get_bits1(gb);
if(vo_ver_id != 1) {
s->new_pred= get_bits1(gb);
if(s->new_pred){
av_log(s->avctx, AV_LOG_ERROR, "new pred not supported\n");
skip_bits(gb, 2); /* requested upstream message type */
skip_bits1(gb); /* newpred segment type */
s->reduced_res_vop= get_bits1(gb);
if(s->reduced_res_vop) av_log(s->avctx, AV_LOG_ERROR, "reduced resolution VOP not supported\n");
else{
s->new_pred=0;
s->reduced_res_vop= 0;
s->scalability= get_bits1(gb);
if (s->scalability) {
GetBitContext bak= *gb;
int ref_layer_id;
int ref_layer_sampling_dir;
int h_sampling_factor_n;
int h_sampling_factor_m;
int v_sampling_factor_n;
int v_sampling_factor_m;
s->hierachy_type= get_bits1(gb);
ref_layer_id= get_bits(gb, 4);
ref_layer_sampling_dir= get_bits1(gb);
h_sampling_factor_n= get_bits(gb, 5);
h_sampling_factor_m= get_bits(gb, 5);
v_sampling_factor_n= get_bits(gb, 5);
v_sampling_factor_m= get_bits(gb, 5);
s->enhancement_type= get_bits1(gb);
if( h_sampling_factor_n==0 || h_sampling_factor_m==0
|| v_sampling_factor_n==0 || v_sampling_factor_m==0){
// fprintf(stderr, "illegal scalability header (VERY broken encoder), trying to workaround\n");
s->scalability=0;
*gb= bak;
}else
av_log(s->avctx, AV_LOG_ERROR, "scalability not supported\n");
// bin shape stuff FIXME
return 0;
| true | FFmpeg | beac8235b92cdd322266e1709fbfe6f9e945e031 | static int decode_vol_header(MpegEncContext *s, GetBitContext *gb){
int width, height, vo_ver_id;
skip_bits(gb, 1);
s->vo_type= get_bits(gb, 8);
if (get_bits1(gb) != 0) {
vo_ver_id = get_bits(gb, 4);
skip_bits(gb, 3);
} else {
vo_ver_id = 1;
s->aspect_ratio_info= get_bits(gb, 4);
if(s->aspect_ratio_info == FF_ASPECT_EXTENDED){
s->avctx->sample_aspect_ratio.num= get_bits(gb, 8);
s->avctx->sample_aspect_ratio.den= get_bits(gb, 8);
}else{
s->avctx->sample_aspect_ratio= pixel_aspect[s->aspect_ratio_info];
if ((s->vol_control_parameters=get_bits1(gb))) {
int chroma_format= get_bits(gb, 2);
if(chroma_format!=1){
av_log(s->avctx, AV_LOG_ERROR, "illegal chroma format\n");
s->low_delay= get_bits1(gb);
if(get_bits1(gb)){
get_bits(gb, 15);
skip_bits1(gb);
get_bits(gb, 15);
skip_bits1(gb);
get_bits(gb, 15);
skip_bits1(gb);
get_bits(gb, 3);
get_bits(gb, 11);
skip_bits1(gb);
get_bits(gb, 15);
skip_bits1(gb);
}else{
if(s->picture_number==0)
s->low_delay=0;
s->shape = get_bits(gb, 2);
if(s->shape != RECT_SHAPE) av_log(s->avctx, AV_LOG_ERROR, "only rectangular vol supported\n");
if(s->shape == GRAY_SHAPE && vo_ver_id != 1){
av_log(s->avctx, AV_LOG_ERROR, "Gray shape not supported\n");
skip_bits(gb, 4);
check_marker(gb, "before time_increment_resolution");
s->avctx->time_base.den = get_bits(gb, 16);
if(!s->avctx->time_base.den){
av_log(s->avctx, AV_LOG_ERROR, "time_base.den==0\n");
s->time_increment_bits = av_log2(s->avctx->time_base.den - 1) + 1;
if (s->time_increment_bits < 1)
s->time_increment_bits = 1;
check_marker(gb, "before fixed_vop_rate");
if (get_bits1(gb) != 0) {
s->avctx->time_base.num = get_bits(gb, s->time_increment_bits);
}else
s->avctx->time_base.num = 1;
s->t_frame=0;
if (s->shape != BIN_ONLY_SHAPE) {
if (s->shape == RECT_SHAPE) {
skip_bits1(gb);
width = get_bits(gb, 13);
skip_bits1(gb);
height = get_bits(gb, 13);
skip_bits1(gb);
if(width && height && !(s->width && s->codec_tag == ff_get_fourcc("MP4S"))){
s->width = width;
s->height = height;
s->progressive_sequence=
s->progressive_frame= get_bits1(gb)^1;
s->interlaced_dct=0;
if(!get_bits1(gb) && (s->avctx->debug & FF_DEBUG_PICT_INFO))
av_log(s->avctx, AV_LOG_INFO, "MPEG4 OBMC not supported (very likely buggy encoder)\n");
if (vo_ver_id == 1) {
s->vol_sprite_usage = get_bits1(gb);
} else {
s->vol_sprite_usage = get_bits(gb, 2);
if(s->vol_sprite_usage==STATIC_SPRITE) av_log(s->avctx, AV_LOG_ERROR, "Static Sprites not supported\n");
if(s->vol_sprite_usage==STATIC_SPRITE || s->vol_sprite_usage==GMC_SPRITE){
if(s->vol_sprite_usage==STATIC_SPRITE){
s->sprite_width = get_bits(gb, 13);
skip_bits1(gb);
s->sprite_height= get_bits(gb, 13);
skip_bits1(gb);
s->sprite_left = get_bits(gb, 13);
skip_bits1(gb);
s->sprite_top = get_bits(gb, 13);
skip_bits1(gb);
s->num_sprite_warping_points= get_bits(gb, 6);
s->sprite_warping_accuracy = get_bits(gb, 2);
s->sprite_brightness_change= get_bits1(gb);
if(s->vol_sprite_usage==STATIC_SPRITE)
s->low_latency_sprite= get_bits1(gb);
if (get_bits1(gb) == 1) {
s->quant_precision = get_bits(gb, 4);
if(get_bits(gb, 4)!=8) av_log(s->avctx, AV_LOG_ERROR, "N-bit not supported\n");
if(s->quant_precision!=5) av_log(s->avctx, AV_LOG_ERROR, "quant precision %d\n", s->quant_precision);
} else {
s->quant_precision = 5;
if((s->mpeg_quant=get_bits1(gb))){
int i, v;
for(i=0; i<64; i++){
int j= s->dsp.idct_permutation[i];
v= ff_mpeg4_default_intra_matrix[i];
s->intra_matrix[j]= v;
s->chroma_intra_matrix[j]= v;
v= ff_mpeg4_default_non_intra_matrix[i];
s->inter_matrix[j]= v;
s->chroma_inter_matrix[j]= v;
if(get_bits1(gb)){
int last=0;
for(i=0; i<64; i++){
int j;
v= get_bits(gb, 8);
if(v==0) break;
last= v;
j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
s->intra_matrix[j]= v;
s->chroma_intra_matrix[j]= v;
for(; i<64; i++){
int j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
s->intra_matrix[j]= last;
s->chroma_intra_matrix[j]= last;
if(get_bits1(gb)){
int last=0;
for(i=0; i<64; i++){
int j;
v= get_bits(gb, 8);
if(v==0) break;
last= v;
j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
s->inter_matrix[j]= v;
s->chroma_inter_matrix[j]= v;
for(; i<64; i++){
int j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
s->inter_matrix[j]= last;
s->chroma_inter_matrix[j]= last;
if(vo_ver_id != 1)
s->quarter_sample= get_bits1(gb);
else s->quarter_sample=0;
if(!get_bits1(gb)) av_log(s->avctx, AV_LOG_ERROR, "Complexity estimation not supported\n");
s->resync_marker= !get_bits1(gb);
s->data_partitioning= get_bits1(gb);
if(s->data_partitioning){
s->rvlc= get_bits1(gb);
if(vo_ver_id != 1) {
s->new_pred= get_bits1(gb);
if(s->new_pred){
av_log(s->avctx, AV_LOG_ERROR, "new pred not supported\n");
skip_bits(gb, 2);
skip_bits1(gb);
s->reduced_res_vop= get_bits1(gb);
if(s->reduced_res_vop) av_log(s->avctx, AV_LOG_ERROR, "reduced resolution VOP not supported\n");
else{
s->new_pred=0;
s->reduced_res_vop= 0;
s->scalability= get_bits1(gb);
if (s->scalability) {
GetBitContext bak= *gb;
int ref_layer_id;
int ref_layer_sampling_dir;
int h_sampling_factor_n;
int h_sampling_factor_m;
int v_sampling_factor_n;
int v_sampling_factor_m;
s->hierachy_type= get_bits1(gb);
ref_layer_id= get_bits(gb, 4);
ref_layer_sampling_dir= get_bits1(gb);
h_sampling_factor_n= get_bits(gb, 5);
h_sampling_factor_m= get_bits(gb, 5);
v_sampling_factor_n= get_bits(gb, 5);
v_sampling_factor_m= get_bits(gb, 5);
s->enhancement_type= get_bits1(gb);
if( h_sampling_factor_n==0 || h_sampling_factor_m==0
|| v_sampling_factor_n==0 || v_sampling_factor_m==0){
s->scalability=0;
*gb= bak;
}else
av_log(s->avctx, AV_LOG_ERROR, "scalability not supported\n");
return 0;
| {
"code": [],
"line_no": []
} | static int FUNC_0(MpegEncContext *VAR_0, GetBitContext *VAR_1){
int VAR_2, VAR_3, VAR_4;
skip_bits(VAR_1, 1);
VAR_0->vo_type= get_bits(VAR_1, 8);
if (get_bits1(VAR_1) != 0) {
VAR_4 = get_bits(VAR_1, 4);
skip_bits(VAR_1, 3);
} else {
VAR_4 = 1;
VAR_0->aspect_ratio_info= get_bits(VAR_1, 4);
if(VAR_0->aspect_ratio_info == FF_ASPECT_EXTENDED){
VAR_0->avctx->sample_aspect_ratio.num= get_bits(VAR_1, 8);
VAR_0->avctx->sample_aspect_ratio.den= get_bits(VAR_1, 8);
}else{
VAR_0->avctx->sample_aspect_ratio= pixel_aspect[VAR_0->aspect_ratio_info];
if ((VAR_0->vol_control_parameters=get_bits1(VAR_1))) {
int VAR_5= get_bits(VAR_1, 2);
if(VAR_5!=1){
av_log(VAR_0->avctx, AV_LOG_ERROR, "illegal chroma format\n");
VAR_0->low_delay= get_bits1(VAR_1);
if(get_bits1(VAR_1)){
get_bits(VAR_1, 15);
skip_bits1(VAR_1);
get_bits(VAR_1, 15);
skip_bits1(VAR_1);
get_bits(VAR_1, 15);
skip_bits1(VAR_1);
get_bits(VAR_1, 3);
get_bits(VAR_1, 11);
skip_bits1(VAR_1);
get_bits(VAR_1, 15);
skip_bits1(VAR_1);
}else{
if(VAR_0->picture_number==0)
VAR_0->low_delay=0;
VAR_0->shape = get_bits(VAR_1, 2);
if(VAR_0->shape != RECT_SHAPE) av_log(VAR_0->avctx, AV_LOG_ERROR, "only rectangular vol supported\n");
if(VAR_0->shape == GRAY_SHAPE && VAR_4 != 1){
av_log(VAR_0->avctx, AV_LOG_ERROR, "Gray shape not supported\n");
skip_bits(VAR_1, 4);
check_marker(VAR_1, "before time_increment_resolution");
VAR_0->avctx->time_base.den = get_bits(VAR_1, 16);
if(!VAR_0->avctx->time_base.den){
av_log(VAR_0->avctx, AV_LOG_ERROR, "time_base.den==0\n");
VAR_0->time_increment_bits = av_log2(VAR_0->avctx->time_base.den - 1) + 1;
if (VAR_0->time_increment_bits < 1)
VAR_0->time_increment_bits = 1;
check_marker(VAR_1, "before fixed_vop_rate");
if (get_bits1(VAR_1) != 0) {
VAR_0->avctx->time_base.num = get_bits(VAR_1, VAR_0->time_increment_bits);
}else
VAR_0->avctx->time_base.num = 1;
VAR_0->t_frame=0;
if (VAR_0->shape != BIN_ONLY_SHAPE) {
if (VAR_0->shape == RECT_SHAPE) {
skip_bits1(VAR_1);
VAR_2 = get_bits(VAR_1, 13);
skip_bits1(VAR_1);
VAR_3 = get_bits(VAR_1, 13);
skip_bits1(VAR_1);
if(VAR_2 && VAR_3 && !(VAR_0->VAR_2 && VAR_0->codec_tag == ff_get_fourcc("MP4S"))){
VAR_0->VAR_2 = VAR_2;
VAR_0->VAR_3 = VAR_3;
VAR_0->progressive_sequence=
VAR_0->progressive_frame= get_bits1(VAR_1)^1;
VAR_0->interlaced_dct=0;
if(!get_bits1(VAR_1) && (VAR_0->avctx->debug & FF_DEBUG_PICT_INFO))
av_log(VAR_0->avctx, AV_LOG_INFO, "MPEG4 OBMC not supported (very likely buggy encoder)\n");
if (VAR_4 == 1) {
VAR_0->vol_sprite_usage = get_bits1(VAR_1);
} else {
VAR_0->vol_sprite_usage = get_bits(VAR_1, 2);
if(VAR_0->vol_sprite_usage==STATIC_SPRITE) av_log(VAR_0->avctx, AV_LOG_ERROR, "Static Sprites not supported\n");
if(VAR_0->vol_sprite_usage==STATIC_SPRITE || VAR_0->vol_sprite_usage==GMC_SPRITE){
if(VAR_0->vol_sprite_usage==STATIC_SPRITE){
VAR_0->sprite_width = get_bits(VAR_1, 13);
skip_bits1(VAR_1);
VAR_0->sprite_height= get_bits(VAR_1, 13);
skip_bits1(VAR_1);
VAR_0->sprite_left = get_bits(VAR_1, 13);
skip_bits1(VAR_1);
VAR_0->sprite_top = get_bits(VAR_1, 13);
skip_bits1(VAR_1);
VAR_0->num_sprite_warping_points= get_bits(VAR_1, 6);
VAR_0->sprite_warping_accuracy = get_bits(VAR_1, 2);
VAR_0->sprite_brightness_change= get_bits1(VAR_1);
if(VAR_0->vol_sprite_usage==STATIC_SPRITE)
VAR_0->low_latency_sprite= get_bits1(VAR_1);
if (get_bits1(VAR_1) == 1) {
VAR_0->quant_precision = get_bits(VAR_1, 4);
if(get_bits(VAR_1, 4)!=8) av_log(VAR_0->avctx, AV_LOG_ERROR, "N-bit not supported\n");
if(VAR_0->quant_precision!=5) av_log(VAR_0->avctx, AV_LOG_ERROR, "quant precision %d\n", VAR_0->quant_precision);
} else {
VAR_0->quant_precision = 5;
if((VAR_0->mpeg_quant=get_bits1(VAR_1))){
int VAR_6, VAR_7;
for(VAR_6=0; VAR_6<64; VAR_6++){
int VAR_10= VAR_0->dsp.idct_permutation[VAR_6];
VAR_7= ff_mpeg4_default_intra_matrix[VAR_6];
VAR_0->intra_matrix[VAR_10]= VAR_7;
VAR_0->chroma_intra_matrix[VAR_10]= VAR_7;
VAR_7= ff_mpeg4_default_non_intra_matrix[VAR_6];
VAR_0->inter_matrix[VAR_10]= VAR_7;
VAR_0->chroma_inter_matrix[VAR_10]= VAR_7;
if(get_bits1(VAR_1)){
int VAR_10=0;
for(VAR_6=0; VAR_6<64; VAR_6++){
int VAR_10;
VAR_7= get_bits(VAR_1, 8);
if(VAR_7==0) break;
VAR_10= VAR_7;
VAR_10= VAR_0->dsp.idct_permutation[ ff_zigzag_direct[VAR_6] ];
VAR_0->intra_matrix[VAR_10]= VAR_7;
VAR_0->chroma_intra_matrix[VAR_10]= VAR_7;
for(; VAR_6<64; VAR_6++){
int VAR_10= VAR_0->dsp.idct_permutation[ ff_zigzag_direct[VAR_6] ];
VAR_0->intra_matrix[VAR_10]= VAR_10;
VAR_0->chroma_intra_matrix[VAR_10]= VAR_10;
if(get_bits1(VAR_1)){
int VAR_10=0;
for(VAR_6=0; VAR_6<64; VAR_6++){
int VAR_10;
VAR_7= get_bits(VAR_1, 8);
if(VAR_7==0) break;
VAR_10= VAR_7;
VAR_10= VAR_0->dsp.idct_permutation[ ff_zigzag_direct[VAR_6] ];
VAR_0->inter_matrix[VAR_10]= VAR_7;
VAR_0->chroma_inter_matrix[VAR_10]= VAR_7;
for(; VAR_6<64; VAR_6++){
int VAR_10= VAR_0->dsp.idct_permutation[ ff_zigzag_direct[VAR_6] ];
VAR_0->inter_matrix[VAR_10]= VAR_10;
VAR_0->chroma_inter_matrix[VAR_10]= VAR_10;
if(VAR_4 != 1)
VAR_0->quarter_sample= get_bits1(VAR_1);
else VAR_0->quarter_sample=0;
if(!get_bits1(VAR_1)) av_log(VAR_0->avctx, AV_LOG_ERROR, "Complexity estimation not supported\n");
VAR_0->resync_marker= !get_bits1(VAR_1);
VAR_0->data_partitioning= get_bits1(VAR_1);
if(VAR_0->data_partitioning){
VAR_0->rvlc= get_bits1(VAR_1);
if(VAR_4 != 1) {
VAR_0->new_pred= get_bits1(VAR_1);
if(VAR_0->new_pred){
av_log(VAR_0->avctx, AV_LOG_ERROR, "new pred not supported\n");
skip_bits(VAR_1, 2);
skip_bits1(VAR_1);
VAR_0->reduced_res_vop= get_bits1(VAR_1);
if(VAR_0->reduced_res_vop) av_log(VAR_0->avctx, AV_LOG_ERROR, "reduced resolution VOP not supported\n");
else{
VAR_0->new_pred=0;
VAR_0->reduced_res_vop= 0;
VAR_0->scalability= get_bits1(VAR_1);
if (VAR_0->scalability) {
GetBitContext bak= *VAR_1;
int VAR_10;
int VAR_11;
int VAR_12;
int VAR_13;
int VAR_14;
int VAR_15;
VAR_0->hierachy_type= get_bits1(VAR_1);
VAR_10= get_bits(VAR_1, 4);
VAR_11= get_bits1(VAR_1);
VAR_12= get_bits(VAR_1, 5);
VAR_13= get_bits(VAR_1, 5);
VAR_14= get_bits(VAR_1, 5);
VAR_15= get_bits(VAR_1, 5);
VAR_0->enhancement_type= get_bits1(VAR_1);
if( VAR_12==0 || VAR_13==0
|| VAR_14==0 || VAR_15==0){
VAR_0->scalability=0;
*VAR_1= bak;
}else
av_log(VAR_0->avctx, AV_LOG_ERROR, "scalability not supported\n");
return 0;
| [
"static int FUNC_0(MpegEncContext *VAR_0, GetBitContext *VAR_1){",
"int VAR_2, VAR_3, VAR_4;",
"skip_bits(VAR_1, 1);",
"VAR_0->vo_type= get_bits(VAR_1, 8);",
"if (get_bits1(VAR_1) != 0) {",
"VAR_4 = get_bits(VAR_1, 4);",
"skip_bits(VAR_1, 3);",
"} else {",
"VAR_4 = 1;",
"VAR_0->aspect_ratio_info= get_bits(VAR_1, 4);",
"if(VAR_0->aspect_ratio_info == FF_ASPECT_EXTENDED){",
"VAR_0->avctx->sample_aspect_ratio.num= get_bits(VAR_1, 8);",
"VAR_0->avctx->sample_aspect_ratio.den= get_bits(VAR_1, 8);",
"}else{",
"VAR_0->avctx->sample_aspect_ratio= pixel_aspect[VAR_0->aspect_ratio_info];",
"if ((VAR_0->vol_control_parameters=get_bits1(VAR_1))) {",
"int VAR_5= get_bits(VAR_1, 2);",
"if(VAR_5!=1){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"illegal chroma format\\n\");",
"VAR_0->low_delay= get_bits1(VAR_1);",
"if(get_bits1(VAR_1)){",
"get_bits(VAR_1, 15);",
"skip_bits1(VAR_1);",
"get_bits(VAR_1, 15);",
"skip_bits1(VAR_1);",
"get_bits(VAR_1, 15);",
"skip_bits1(VAR_1);",
"get_bits(VAR_1, 3);",
"get_bits(VAR_1, 11);",
"skip_bits1(VAR_1);",
"get_bits(VAR_1, 15);",
"skip_bits1(VAR_1);",
"}else{",
"if(VAR_0->picture_number==0)\nVAR_0->low_delay=0;",
"VAR_0->shape = get_bits(VAR_1, 2);",
"if(VAR_0->shape != RECT_SHAPE) av_log(VAR_0->avctx, AV_LOG_ERROR, \"only rectangular vol supported\\n\");",
"if(VAR_0->shape == GRAY_SHAPE && VAR_4 != 1){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Gray shape not supported\\n\");",
"skip_bits(VAR_1, 4);",
"check_marker(VAR_1, \"before time_increment_resolution\");",
"VAR_0->avctx->time_base.den = get_bits(VAR_1, 16);",
"if(!VAR_0->avctx->time_base.den){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"time_base.den==0\\n\");",
"VAR_0->time_increment_bits = av_log2(VAR_0->avctx->time_base.den - 1) + 1;",
"if (VAR_0->time_increment_bits < 1)\nVAR_0->time_increment_bits = 1;",
"check_marker(VAR_1, \"before fixed_vop_rate\");",
"if (get_bits1(VAR_1) != 0) {",
"VAR_0->avctx->time_base.num = get_bits(VAR_1, VAR_0->time_increment_bits);",
"}else",
"VAR_0->avctx->time_base.num = 1;",
"VAR_0->t_frame=0;",
"if (VAR_0->shape != BIN_ONLY_SHAPE) {",
"if (VAR_0->shape == RECT_SHAPE) {",
"skip_bits1(VAR_1);",
"VAR_2 = get_bits(VAR_1, 13);",
"skip_bits1(VAR_1);",
"VAR_3 = get_bits(VAR_1, 13);",
"skip_bits1(VAR_1);",
"if(VAR_2 && VAR_3 && !(VAR_0->VAR_2 && VAR_0->codec_tag == ff_get_fourcc(\"MP4S\"))){",
"VAR_0->VAR_2 = VAR_2;",
"VAR_0->VAR_3 = VAR_3;",
"VAR_0->progressive_sequence=\nVAR_0->progressive_frame= get_bits1(VAR_1)^1;",
"VAR_0->interlaced_dct=0;",
"if(!get_bits1(VAR_1) && (VAR_0->avctx->debug & FF_DEBUG_PICT_INFO))\nav_log(VAR_0->avctx, AV_LOG_INFO, \"MPEG4 OBMC not supported (very likely buggy encoder)\\n\");",
"if (VAR_4 == 1) {",
"VAR_0->vol_sprite_usage = get_bits1(VAR_1);",
"} else {",
"VAR_0->vol_sprite_usage = get_bits(VAR_1, 2);",
"if(VAR_0->vol_sprite_usage==STATIC_SPRITE) av_log(VAR_0->avctx, AV_LOG_ERROR, \"Static Sprites not supported\\n\");",
"if(VAR_0->vol_sprite_usage==STATIC_SPRITE || VAR_0->vol_sprite_usage==GMC_SPRITE){",
"if(VAR_0->vol_sprite_usage==STATIC_SPRITE){",
"VAR_0->sprite_width = get_bits(VAR_1, 13);",
"skip_bits1(VAR_1);",
"VAR_0->sprite_height= get_bits(VAR_1, 13);",
"skip_bits1(VAR_1);",
"VAR_0->sprite_left = get_bits(VAR_1, 13);",
"skip_bits1(VAR_1);",
"VAR_0->sprite_top = get_bits(VAR_1, 13);",
"skip_bits1(VAR_1);",
"VAR_0->num_sprite_warping_points= get_bits(VAR_1, 6);",
"VAR_0->sprite_warping_accuracy = get_bits(VAR_1, 2);",
"VAR_0->sprite_brightness_change= get_bits1(VAR_1);",
"if(VAR_0->vol_sprite_usage==STATIC_SPRITE)\nVAR_0->low_latency_sprite= get_bits1(VAR_1);",
"if (get_bits1(VAR_1) == 1) {",
"VAR_0->quant_precision = get_bits(VAR_1, 4);",
"if(get_bits(VAR_1, 4)!=8) av_log(VAR_0->avctx, AV_LOG_ERROR, \"N-bit not supported\\n\");",
"if(VAR_0->quant_precision!=5) av_log(VAR_0->avctx, AV_LOG_ERROR, \"quant precision %d\\n\", VAR_0->quant_precision);",
"} else {",
"VAR_0->quant_precision = 5;",
"if((VAR_0->mpeg_quant=get_bits1(VAR_1))){",
"int VAR_6, VAR_7;",
"for(VAR_6=0; VAR_6<64; VAR_6++){",
"int VAR_10= VAR_0->dsp.idct_permutation[VAR_6];",
"VAR_7= ff_mpeg4_default_intra_matrix[VAR_6];",
"VAR_0->intra_matrix[VAR_10]= VAR_7;",
"VAR_0->chroma_intra_matrix[VAR_10]= VAR_7;",
"VAR_7= ff_mpeg4_default_non_intra_matrix[VAR_6];",
"VAR_0->inter_matrix[VAR_10]= VAR_7;",
"VAR_0->chroma_inter_matrix[VAR_10]= VAR_7;",
"if(get_bits1(VAR_1)){",
"int VAR_10=0;",
"for(VAR_6=0; VAR_6<64; VAR_6++){",
"int VAR_10;",
"VAR_7= get_bits(VAR_1, 8);",
"if(VAR_7==0) break;",
"VAR_10= VAR_7;",
"VAR_10= VAR_0->dsp.idct_permutation[ ff_zigzag_direct[VAR_6] ];",
"VAR_0->intra_matrix[VAR_10]= VAR_7;",
"VAR_0->chroma_intra_matrix[VAR_10]= VAR_7;",
"for(; VAR_6<64; VAR_6++){",
"int VAR_10= VAR_0->dsp.idct_permutation[ ff_zigzag_direct[VAR_6] ];",
"VAR_0->intra_matrix[VAR_10]= VAR_10;",
"VAR_0->chroma_intra_matrix[VAR_10]= VAR_10;",
"if(get_bits1(VAR_1)){",
"int VAR_10=0;",
"for(VAR_6=0; VAR_6<64; VAR_6++){",
"int VAR_10;",
"VAR_7= get_bits(VAR_1, 8);",
"if(VAR_7==0) break;",
"VAR_10= VAR_7;",
"VAR_10= VAR_0->dsp.idct_permutation[ ff_zigzag_direct[VAR_6] ];",
"VAR_0->inter_matrix[VAR_10]= VAR_7;",
"VAR_0->chroma_inter_matrix[VAR_10]= VAR_7;",
"for(; VAR_6<64; VAR_6++){",
"int VAR_10= VAR_0->dsp.idct_permutation[ ff_zigzag_direct[VAR_6] ];",
"VAR_0->inter_matrix[VAR_10]= VAR_10;",
"VAR_0->chroma_inter_matrix[VAR_10]= VAR_10;",
"if(VAR_4 != 1)\nVAR_0->quarter_sample= get_bits1(VAR_1);",
"else VAR_0->quarter_sample=0;",
"if(!get_bits1(VAR_1)) av_log(VAR_0->avctx, AV_LOG_ERROR, \"Complexity estimation not supported\\n\");",
"VAR_0->resync_marker= !get_bits1(VAR_1);",
"VAR_0->data_partitioning= get_bits1(VAR_1);",
"if(VAR_0->data_partitioning){",
"VAR_0->rvlc= get_bits1(VAR_1);",
"if(VAR_4 != 1) {",
"VAR_0->new_pred= get_bits1(VAR_1);",
"if(VAR_0->new_pred){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"new pred not supported\\n\");",
"skip_bits(VAR_1, 2);",
"skip_bits1(VAR_1);",
"VAR_0->reduced_res_vop= get_bits1(VAR_1);",
"if(VAR_0->reduced_res_vop) av_log(VAR_0->avctx, AV_LOG_ERROR, \"reduced resolution VOP not supported\\n\");",
"else{",
"VAR_0->new_pred=0;",
"VAR_0->reduced_res_vop= 0;",
"VAR_0->scalability= get_bits1(VAR_1);",
"if (VAR_0->scalability) {",
"GetBitContext bak= *VAR_1;",
"int VAR_10;",
"int VAR_11;",
"int VAR_12;",
"int VAR_13;",
"int VAR_14;",
"int VAR_15;",
"VAR_0->hierachy_type= get_bits1(VAR_1);",
"VAR_10= get_bits(VAR_1, 4);",
"VAR_11= get_bits1(VAR_1);",
"VAR_12= get_bits(VAR_1, 5);",
"VAR_13= get_bits(VAR_1, 5);",
"VAR_14= get_bits(VAR_1, 5);",
"VAR_15= get_bits(VAR_1, 5);",
"VAR_0->enhancement_type= get_bits1(VAR_1);",
"if( VAR_12==0 || VAR_13==0\n|| VAR_14==0 || VAR_15==0){",
"VAR_0->scalability=0;",
"*VAR_1= bak;",
"}else",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"scalability not supported\\n\");",
"return 0;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
26
],
[
28
],
[
30
],
[
32
],
[
34
],
[
36
],
[
41
],
[
43
],
[
45
],
[
47
],
[
50
],
[
52
],
[
54
],
[
56
],
[
58
],
[
60
],
[
62
],
[
64
],
[
66
],
[
68
],
[
70
],
[
72
],
[
74
],
[
77
],
[
81,
83
],
[
88
],
[
90
],
[
92
],
[
94
],
[
96
],
[
101
],
[
105
],
[
107
],
[
109
],
[
115
],
[
117,
119
],
[
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
167,
169
],
[
171
],
[
173,
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
186
],
[
188
],
[
190
],
[
192
],
[
194
],
[
196
],
[
198
],
[
200
],
[
202
],
[
204
],
[
206
],
[
209
],
[
216
],
[
218
],
[
220,
222
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
248
],
[
250
],
[
256
],
[
258
],
[
260
],
[
262
],
[
264
],
[
268
],
[
270
],
[
272
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
293
],
[
295
],
[
297
],
[
299
],
[
306
],
[
308
],
[
310
],
[
312
],
[
320
],
[
322
],
[
324
],
[
326
],
[
328
],
[
330
],
[
334
],
[
336
],
[
338
],
[
340
],
[
347
],
[
349
],
[
351
],
[
353
],
[
364,
366
],
[
368
],
[
372
],
[
376
],
[
380
],
[
382
],
[
384
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
402
],
[
404
],
[
407
],
[
409
],
[
411
],
[
416
],
[
420
],
[
422
],
[
424
],
[
426
],
[
428
],
[
430
],
[
432
],
[
434
],
[
438
],
[
440
],
[
442
],
[
444
],
[
446
],
[
448
],
[
450
],
[
452
],
[
456,
458
],
[
464
],
[
468
],
[
470
],
[
472
],
[
480
]
] |
1,795 | static int scsi_disk_initfn(SCSIDevice *dev)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
int is_cd;
DriveInfo *dinfo;
if (!s->qdev.conf.bs) {
error_report("scsi-disk: drive property not set");
s->bs = s->qdev.conf.bs;
is_cd = bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM;
if (bdrv_get_on_error(s->bs, 1) != BLOCK_ERR_REPORT) {
error_report("Device doesn't support drive option rerror");
if (!s->serial) {
/* try to fall back to value set with legacy -drive serial=... */
dinfo = drive_get_by_blockdev(s->bs);
s->serial = qemu_strdup(*dinfo->serial ? dinfo->serial : "0");
if (!s->version) {
s->version = qemu_strdup(QEMU_VERSION);
if (bdrv_is_sg(s->bs)) {
error_report("scsi-disk: unwanted /dev/sg*");
if (is_cd) {
s->qdev.blocksize = 2048;
} else {
s->qdev.blocksize = s->qdev.conf.logical_block_size;
s->cluster_size = s->qdev.blocksize / 512;
s->qdev.type = TYPE_DISK;
qemu_add_vm_change_state_handler(scsi_dma_restart_cb, s);
bdrv_set_removable(s->bs, is_cd);
return 0; | true | qemu | 98f28ad7a7d26e5e77c5cb37b262d76d6ccd963d | static int scsi_disk_initfn(SCSIDevice *dev)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
int is_cd;
DriveInfo *dinfo;
if (!s->qdev.conf.bs) {
error_report("scsi-disk: drive property not set");
s->bs = s->qdev.conf.bs;
is_cd = bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM;
if (bdrv_get_on_error(s->bs, 1) != BLOCK_ERR_REPORT) {
error_report("Device doesn't support drive option rerror");
if (!s->serial) {
dinfo = drive_get_by_blockdev(s->bs);
s->serial = qemu_strdup(*dinfo->serial ? dinfo->serial : "0");
if (!s->version) {
s->version = qemu_strdup(QEMU_VERSION);
if (bdrv_is_sg(s->bs)) {
error_report("scsi-disk: unwanted /dev/sg*");
if (is_cd) {
s->qdev.blocksize = 2048;
} else {
s->qdev.blocksize = s->qdev.conf.logical_block_size;
s->cluster_size = s->qdev.blocksize / 512;
s->qdev.type = TYPE_DISK;
qemu_add_vm_change_state_handler(scsi_dma_restart_cb, s);
bdrv_set_removable(s->bs, is_cd);
return 0; | {
"code": [],
"line_no": []
} | static int FUNC_0(SCSIDevice *VAR_0)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, VAR_0);
int VAR_1;
DriveInfo *dinfo;
if (!s->qdev.conf.bs) {
error_report("scsi-disk: drive property not set");
s->bs = s->qdev.conf.bs;
VAR_1 = bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM;
if (bdrv_get_on_error(s->bs, 1) != BLOCK_ERR_REPORT) {
error_report("Device doesn't support drive option rerror");
if (!s->serial) {
dinfo = drive_get_by_blockdev(s->bs);
s->serial = qemu_strdup(*dinfo->serial ? dinfo->serial : "0");
if (!s->version) {
s->version = qemu_strdup(QEMU_VERSION);
if (bdrv_is_sg(s->bs)) {
error_report("scsi-disk: unwanted /VAR_0/sg*");
if (VAR_1) {
s->qdev.blocksize = 2048;
} else {
s->qdev.blocksize = s->qdev.conf.logical_block_size;
s->cluster_size = s->qdev.blocksize / 512;
s->qdev.type = TYPE_DISK;
qemu_add_vm_change_state_handler(scsi_dma_restart_cb, s);
bdrv_set_removable(s->bs, VAR_1);
return 0; | [
"static int FUNC_0(SCSIDevice *VAR_0)\n{",
"SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, VAR_0);",
"int VAR_1;",
"DriveInfo *dinfo;",
"if (!s->qdev.conf.bs) {",
"error_report(\"scsi-disk: drive property not set\");",
"s->bs = s->qdev.conf.bs;",
"VAR_1 = bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM;",
"if (bdrv_get_on_error(s->bs, 1) != BLOCK_ERR_REPORT) {",
"error_report(\"Device doesn't support drive option rerror\");",
"if (!s->serial) {",
"dinfo = drive_get_by_blockdev(s->bs);",
"s->serial = qemu_strdup(*dinfo->serial ? dinfo->serial : \"0\");",
"if (!s->version) {",
"s->version = qemu_strdup(QEMU_VERSION);",
"if (bdrv_is_sg(s->bs)) {",
"error_report(\"scsi-disk: unwanted /VAR_0/sg*\");",
"if (VAR_1) {",
"s->qdev.blocksize = 2048;",
"} else {",
"s->qdev.blocksize = s->qdev.conf.logical_block_size;",
"s->cluster_size = s->qdev.blocksize / 512;",
"s->qdev.type = TYPE_DISK;",
"qemu_add_vm_change_state_handler(scsi_dma_restart_cb, s);",
"bdrv_set_removable(s->bs, 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
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20
],
[
21
],
[
22
],
[
23
],
[
24
],
[
25
],
[
26
],
[
27
],
[
28
]
] |
1,796 | static av_cold int dvdsub_init(AVCodecContext *avctx)
{
DVDSubContext *ctx = avctx->priv_data;
char *data, *cur;
if (!avctx->extradata || !avctx->extradata_size)
return 0;
data = av_malloc(avctx->extradata_size + 1);
if (!data)
return AVERROR(ENOMEM);
memcpy(data, avctx->extradata, avctx->extradata_size);
data[avctx->extradata_size] = '\0';
cur = data;
while (*cur) {
if (strncmp("palette:", cur, 8) == 0) {
int i;
char *p = cur + 8;
ctx->has_palette = 1;
for (i = 0; i < 16; i++) {
ctx->palette[i] = strtoul(p, &p, 16);
while (*p == ',' || av_isspace(*p))
p++;
}
} else if (!strncmp("size:", cur, 5)) {
int w, h;
if (sscanf(cur + 5, "%dx%d", &w, &h) == 2) {
int ret = ff_set_dimensions(avctx, w, h);
if (ret < 0)
return ret;
}
}
cur += strcspn(cur, "\n\r");
cur += strspn(cur, "\n\r");
}
av_free(data);
return 0;
}
| true | FFmpeg | d466d82faaf6e0e57a3a4be5e38e3902ef251ac3 | static av_cold int dvdsub_init(AVCodecContext *avctx)
{
DVDSubContext *ctx = avctx->priv_data;
char *data, *cur;
if (!avctx->extradata || !avctx->extradata_size)
return 0;
data = av_malloc(avctx->extradata_size + 1);
if (!data)
return AVERROR(ENOMEM);
memcpy(data, avctx->extradata, avctx->extradata_size);
data[avctx->extradata_size] = '\0';
cur = data;
while (*cur) {
if (strncmp("palette:", cur, 8) == 0) {
int i;
char *p = cur + 8;
ctx->has_palette = 1;
for (i = 0; i < 16; i++) {
ctx->palette[i] = strtoul(p, &p, 16);
while (*p == ',' || av_isspace(*p))
p++;
}
} else if (!strncmp("size:", cur, 5)) {
int w, h;
if (sscanf(cur + 5, "%dx%d", &w, &h) == 2) {
int ret = ff_set_dimensions(avctx, w, h);
if (ret < 0)
return ret;
}
}
cur += strcspn(cur, "\n\r");
cur += strspn(cur, "\n\r");
}
av_free(data);
return 0;
}
| {
"code": [
" int ret = ff_set_dimensions(avctx, w, h);",
" return ret;",
" return 0;"
],
"line_no": [
57,
61,
75
]
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
DVDSubContext *ctx = avctx->priv_data;
char *VAR_0, *VAR_1;
if (!avctx->extradata || !avctx->extradata_size)
return 0;
VAR_0 = av_malloc(avctx->extradata_size + 1);
if (!VAR_0)
return AVERROR(ENOMEM);
memcpy(VAR_0, avctx->extradata, avctx->extradata_size);
VAR_0[avctx->extradata_size] = '\0';
VAR_1 = VAR_0;
while (*VAR_1) {
if (strncmp("palette:", VAR_1, 8) == 0) {
int VAR_2;
char *VAR_3 = VAR_1 + 8;
ctx->has_palette = 1;
for (VAR_2 = 0; VAR_2 < 16; VAR_2++) {
ctx->palette[VAR_2] = strtoul(VAR_3, &VAR_3, 16);
while (*VAR_3 == ',' || av_isspace(*VAR_3))
VAR_3++;
}
} else if (!strncmp("size:", VAR_1, 5)) {
int VAR_4, VAR_5;
if (sscanf(VAR_1 + 5, "%dx%d", &VAR_4, &VAR_5) == 2) {
int VAR_6 = ff_set_dimensions(avctx, VAR_4, VAR_5);
if (VAR_6 < 0)
return VAR_6;
}
}
VAR_1 += strcspn(VAR_1, "\n\r");
VAR_1 += strspn(VAR_1, "\n\r");
}
av_free(VAR_0);
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"DVDSubContext *ctx = avctx->priv_data;",
"char *VAR_0, *VAR_1;",
"if (!avctx->extradata || !avctx->extradata_size)\nreturn 0;",
"VAR_0 = av_malloc(avctx->extradata_size + 1);",
"if (!VAR_0)\nreturn AVERROR(ENOMEM);",
"memcpy(VAR_0, avctx->extradata, avctx->extradata_size);",
"VAR_0[avctx->extradata_size] = '\\0';",
"VAR_1 = VAR_0;",
"while (*VAR_1) {",
"if (strncmp(\"palette:\", VAR_1, 8) == 0) {",
"int VAR_2;",
"char *VAR_3 = VAR_1 + 8;",
"ctx->has_palette = 1;",
"for (VAR_2 = 0; VAR_2 < 16; VAR_2++) {",
"ctx->palette[VAR_2] = strtoul(VAR_3, &VAR_3, 16);",
"while (*VAR_3 == ',' || av_isspace(*VAR_3))\nVAR_3++;",
"}",
"} else if (!strncmp(\"size:\", VAR_1, 5)) {",
"int VAR_4, VAR_5;",
"if (sscanf(VAR_1 + 5, \"%dx%d\", &VAR_4, &VAR_5) == 2) {",
"int VAR_6 = ff_set_dimensions(avctx, VAR_4, VAR_5);",
"if (VAR_6 < 0)\nreturn VAR_6;",
"}",
"}",
"VAR_1 += strcspn(VAR_1, \"\\n\\r\");",
"VAR_1 += strspn(VAR_1, \"\\n\\r\");",
"}",
"av_free(VAR_0);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
]
] |
1,797 | static void mxf_write_random_index_pack(AVFormatContext *s)
{
MXFContext *mxf = s->priv_data;
AVIOContext *pb = s->pb;
uint64_t pos = avio_tell(pb);
int i;
avio_write(pb, random_index_pack_key, 16);
klv_encode_ber_length(pb, 28 + 12*mxf->body_partitions_count);
if (mxf->edit_unit_byte_count)
avio_wb32(pb, 1); // BodySID of header partition
else
avio_wb32(pb, 0);
avio_wb64(pb, 0); // offset of header partition
for (i = 0; i < mxf->body_partitions_count; i++) {
avio_wb32(pb, 1); // BodySID
avio_wb64(pb, mxf->body_partition_offset[i]);
}
avio_wb32(pb, 0); // BodySID of footer partition
avio_wb64(pb, mxf->footer_partition_offset);
avio_wb32(pb, avio_tell(pb) - pos + 4);
}
| true | FFmpeg | 7df3b426bbfbd7efd9a0f56393e3cc78413b0869 | static void mxf_write_random_index_pack(AVFormatContext *s)
{
MXFContext *mxf = s->priv_data;
AVIOContext *pb = s->pb;
uint64_t pos = avio_tell(pb);
int i;
avio_write(pb, random_index_pack_key, 16);
klv_encode_ber_length(pb, 28 + 12*mxf->body_partitions_count);
if (mxf->edit_unit_byte_count)
avio_wb32(pb, 1);
else
avio_wb32(pb, 0);
avio_wb64(pb, 0);
for (i = 0; i < mxf->body_partitions_count; i++) {
avio_wb32(pb, 1);
avio_wb64(pb, mxf->body_partition_offset[i]);
}
avio_wb32(pb, 0); of footer partition
avio_wb64(pb, mxf->footer_partition_offset);
avio_wb32(pb, avio_tell(pb) - pos + 4);
}
| {
"code": [
" klv_encode_ber_length(pb, 28 + 12*mxf->body_partitions_count);"
],
"line_no": [
17
]
} | static void FUNC_0(AVFormatContext *VAR_0)
{
MXFContext *mxf = VAR_0->priv_data;
AVIOContext *pb = VAR_0->pb;
uint64_t pos = avio_tell(pb);
int VAR_1;
avio_write(pb, random_index_pack_key, 16);
klv_encode_ber_length(pb, 28 + 12*mxf->body_partitions_count);
if (mxf->edit_unit_byte_count)
avio_wb32(pb, 1);
else
avio_wb32(pb, 0);
avio_wb64(pb, 0);
for (VAR_1 = 0; VAR_1 < mxf->body_partitions_count; VAR_1++) {
avio_wb32(pb, 1);
avio_wb64(pb, mxf->body_partition_offset[VAR_1]);
}
avio_wb32(pb, 0); of footer partition
avio_wb64(pb, mxf->footer_partition_offset);
avio_wb32(pb, avio_tell(pb) - pos + 4);
}
| [
"static void FUNC_0(AVFormatContext *VAR_0)\n{",
"MXFContext *mxf = VAR_0->priv_data;",
"AVIOContext *pb = VAR_0->pb;",
"uint64_t pos = avio_tell(pb);",
"int VAR_1;",
"avio_write(pb, random_index_pack_key, 16);",
"klv_encode_ber_length(pb, 28 + 12*mxf->body_partitions_count);",
"if (mxf->edit_unit_byte_count)\navio_wb32(pb, 1);",
"else\navio_wb32(pb, 0);",
"avio_wb64(pb, 0);",
"for (VAR_1 = 0; VAR_1 < mxf->body_partitions_count; VAR_1++) {",
"avio_wb32(pb, 1);",
"avio_wb64(pb, mxf->body_partition_offset[VAR_1]);",
"}",
"avio_wb32(pb, 0); of footer partition",
"avio_wb64(pb, mxf->footer_partition_offset);",
"avio_wb32(pb, avio_tell(pb) - pos + 4);",
"}"
] | [
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,
23
],
[
25,
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
49
],
[
51
]
] |
1,799 | static int qcow2_mark_clean(BlockDriverState *bs)
{
BDRVQcowState *s = bs->opaque;
if (s->incompatible_features & QCOW2_INCOMPAT_DIRTY) {
int ret = bdrv_flush(bs);
if (ret < 0) {
return ret;
}
s->incompatible_features &= ~QCOW2_INCOMPAT_DIRTY;
return qcow2_update_header(bs);
}
return 0;
}
| true | qemu | 4c2e5f8f46a17966dc45b5a3e07b97434c0eabdf | static int qcow2_mark_clean(BlockDriverState *bs)
{
BDRVQcowState *s = bs->opaque;
if (s->incompatible_features & QCOW2_INCOMPAT_DIRTY) {
int ret = bdrv_flush(bs);
if (ret < 0) {
return ret;
}
s->incompatible_features &= ~QCOW2_INCOMPAT_DIRTY;
return qcow2_update_header(bs);
}
return 0;
}
| {
"code": [
" int ret = bdrv_flush(bs);",
" s->incompatible_features &= ~QCOW2_INCOMPAT_DIRTY;"
],
"line_no": [
11,
21
]
} | static int FUNC_0(BlockDriverState *VAR_0)
{
BDRVQcowState *s = VAR_0->opaque;
if (s->incompatible_features & QCOW2_INCOMPAT_DIRTY) {
int VAR_1 = bdrv_flush(VAR_0);
if (VAR_1 < 0) {
return VAR_1;
}
s->incompatible_features &= ~QCOW2_INCOMPAT_DIRTY;
return qcow2_update_header(VAR_0);
}
return 0;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"if (s->incompatible_features & QCOW2_INCOMPAT_DIRTY) {",
"int VAR_1 = bdrv_flush(VAR_0);",
"if (VAR_1 < 0) {",
"return VAR_1;",
"}",
"s->incompatible_features &= ~QCOW2_INCOMPAT_DIRTY;",
"return qcow2_update_header(VAR_0);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
1,801 | static int config_props(AVFilterLink *link)
{
YADIFContext *yadif = link->src->priv;
link->time_base.num = link->src->inputs[0]->time_base.num;
link->time_base.den = link->src->inputs[0]->time_base.den * 2;
link->w = link->src->inputs[0]->w;
link->h = link->src->inputs[0]->h;
if(yadif->mode&1)
link->frame_rate = av_mul_q(link->src->inputs[0]->frame_rate, (AVRational){2,1});
return 0;
}
| true | FFmpeg | 4ea7c179325f61736040f2ff22c2f27c702727d4 | static int config_props(AVFilterLink *link)
{
YADIFContext *yadif = link->src->priv;
link->time_base.num = link->src->inputs[0]->time_base.num;
link->time_base.den = link->src->inputs[0]->time_base.den * 2;
link->w = link->src->inputs[0]->w;
link->h = link->src->inputs[0]->h;
if(yadif->mode&1)
link->frame_rate = av_mul_q(link->src->inputs[0]->frame_rate, (AVRational){2,1});
return 0;
}
| {
"code": [
" YADIFContext *yadif = link->src->priv;"
],
"line_no": [
5
]
} | static int FUNC_0(AVFilterLink *VAR_0)
{
YADIFContext *yadif = VAR_0->src->priv;
VAR_0->time_base.num = VAR_0->src->inputs[0]->time_base.num;
VAR_0->time_base.den = VAR_0->src->inputs[0]->time_base.den * 2;
VAR_0->w = VAR_0->src->inputs[0]->w;
VAR_0->h = VAR_0->src->inputs[0]->h;
if(yadif->mode&1)
VAR_0->frame_rate = av_mul_q(VAR_0->src->inputs[0]->frame_rate, (AVRational){2,1});
return 0;
}
| [
"static int FUNC_0(AVFilterLink *VAR_0)\n{",
"YADIFContext *yadif = VAR_0->src->priv;",
"VAR_0->time_base.num = VAR_0->src->inputs[0]->time_base.num;",
"VAR_0->time_base.den = VAR_0->src->inputs[0]->time_base.den * 2;",
"VAR_0->w = VAR_0->src->inputs[0]->w;",
"VAR_0->h = VAR_0->src->inputs[0]->h;",
"if(yadif->mode&1)\nVAR_0->frame_rate = av_mul_q(VAR_0->src->inputs[0]->frame_rate, (AVRational){2,1});",
"return 0;",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
21
],
[
25
],
[
27
]
] |
1,803 | void qemu_system_powerdown(void)
{
if(pm_state->pmen & PWRBTN_EN) {
pm_state->pmsts |= PWRBTN_EN;
pm_update_sci(pm_state);
}
}
| true | qemu | 9669d3c570c7a2129c6d6d4e32b856a2d155eb54 | void qemu_system_powerdown(void)
{
if(pm_state->pmen & PWRBTN_EN) {
pm_state->pmsts |= PWRBTN_EN;
pm_update_sci(pm_state);
}
}
| {
"code": [
" if(pm_state->pmen & PWRBTN_EN) {"
],
"line_no": [
5
]
} | void FUNC_0(void)
{
if(pm_state->pmen & PWRBTN_EN) {
pm_state->pmsts |= PWRBTN_EN;
pm_update_sci(pm_state);
}
}
| [
"void FUNC_0(void)\n{",
"if(pm_state->pmen & PWRBTN_EN) {",
"pm_state->pmsts |= PWRBTN_EN;",
"pm_update_sci(pm_state);",
"}",
"}"
] | [
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
1,805 | static int alloc_table(VLC *vlc, int size)
{
int index;
index = vlc->table_size;
vlc->table_size += size;
if (vlc->table_size > vlc->table_allocated) {
vlc->table_allocated += (1 << vlc->bits);
vlc->table = av_realloc(vlc->table,
sizeof(VLC_TYPE) * 2 * vlc->table_allocated);
if (!vlc->table)
return -1;
}
return index;
}
| true | FFmpeg | 073c2593c9f0aa4445a6fc1b9b24e6e52a8cc2c1 | static int alloc_table(VLC *vlc, int size)
{
int index;
index = vlc->table_size;
vlc->table_size += size;
if (vlc->table_size > vlc->table_allocated) {
vlc->table_allocated += (1 << vlc->bits);
vlc->table = av_realloc(vlc->table,
sizeof(VLC_TYPE) * 2 * vlc->table_allocated);
if (!vlc->table)
return -1;
}
return index;
}
| {
"code": [
"static int alloc_table(VLC *vlc, int size)",
" vlc->table = av_realloc(vlc->table,",
" sizeof(VLC_TYPE) * 2 * vlc->table_allocated);"
],
"line_no": [
1,
15,
17
]
} | static int FUNC_0(VLC *VAR_0, int VAR_1)
{
int VAR_2;
VAR_2 = VAR_0->table_size;
VAR_0->table_size += VAR_1;
if (VAR_0->table_size > VAR_0->table_allocated) {
VAR_0->table_allocated += (1 << VAR_0->bits);
VAR_0->table = av_realloc(VAR_0->table,
sizeof(VLC_TYPE) * 2 * VAR_0->table_allocated);
if (!VAR_0->table)
return -1;
}
return VAR_2;
}
| [
"static int FUNC_0(VLC *VAR_0, int VAR_1)\n{",
"int VAR_2;",
"VAR_2 = VAR_0->table_size;",
"VAR_0->table_size += VAR_1;",
"if (VAR_0->table_size > VAR_0->table_allocated) {",
"VAR_0->table_allocated += (1 << VAR_0->bits);",
"VAR_0->table = av_realloc(VAR_0->table,\nsizeof(VLC_TYPE) * 2 * VAR_0->table_allocated);",
"if (!VAR_0->table)\nreturn -1;",
"}",
"return VAR_2;",
"}"
] | [
1,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15,
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
]
] |
1,806 | int net_slirp_smb(const char *exported_dir)
{
struct in_addr vserver_addr = { .s_addr = 0 };
if (legacy_smb_export) {
fprintf(stderr, "-smb given twice\n");
return -1;
}
legacy_smb_export = exported_dir;
if (!QTAILQ_EMPTY(&slirp_stacks)) {
return slirp_smb(QTAILQ_FIRST(&slirp_stacks), exported_dir,
vserver_addr);
}
return 0;
}
| true | qemu | 5c843af22604edecda10d4bb89d4eede9e1bd3d0 | int net_slirp_smb(const char *exported_dir)
{
struct in_addr vserver_addr = { .s_addr = 0 };
if (legacy_smb_export) {
fprintf(stderr, "-smb given twice\n");
return -1;
}
legacy_smb_export = exported_dir;
if (!QTAILQ_EMPTY(&slirp_stacks)) {
return slirp_smb(QTAILQ_FIRST(&slirp_stacks), exported_dir,
vserver_addr);
}
return 0;
}
| {
"code": [
" return slirp_smb(QTAILQ_FIRST(&slirp_stacks), exported_dir,",
" vserver_addr);"
],
"line_no": [
21,
23
]
} | int FUNC_0(const char *VAR_0)
{
struct in_addr VAR_1 = { .s_addr = 0 };
if (legacy_smb_export) {
fprintf(stderr, "-smb given twice\n");
return -1;
}
legacy_smb_export = VAR_0;
if (!QTAILQ_EMPTY(&slirp_stacks)) {
return slirp_smb(QTAILQ_FIRST(&slirp_stacks), VAR_0,
VAR_1);
}
return 0;
}
| [
"int FUNC_0(const char *VAR_0)\n{",
"struct in_addr VAR_1 = { .s_addr = 0 };",
"if (legacy_smb_export) {",
"fprintf(stderr, \"-smb given twice\\n\");",
"return -1;",
"}",
"legacy_smb_export = VAR_0;",
"if (!QTAILQ_EMPTY(&slirp_stacks)) {",
"return slirp_smb(QTAILQ_FIRST(&slirp_stacks), VAR_0,\nVAR_1);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
]
] |
1,807 | static void set_int32(Object *obj, Visitor *v, void *opaque,
const char *name, Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
int32_t *ptr = qdev_get_prop_ptr(dev, prop);
Error *local_err = NULL;
int64_t value;
if (dev->state != DEV_STATE_CREATED) {
error_set(errp, QERR_PERMISSION_DENIED);
return;
}
visit_type_int(v, &value, name, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
if (value > prop->info->min && value <= prop->info->max) {
*ptr = value;
} else {
error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
dev->id?:"", name, value, prop->info->min,
prop->info->max);
}
}
| true | qemu | 6350b0904615cc0531cc3059ea34db5c009c88aa | static void set_int32(Object *obj, Visitor *v, void *opaque,
const char *name, Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
int32_t *ptr = qdev_get_prop_ptr(dev, prop);
Error *local_err = NULL;
int64_t value;
if (dev->state != DEV_STATE_CREATED) {
error_set(errp, QERR_PERMISSION_DENIED);
return;
}
visit_type_int(v, &value, name, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
if (value > prop->info->min && value <= prop->info->max) {
*ptr = value;
} else {
error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
dev->id?:"", name, value, prop->info->min,
prop->info->max);
}
}
| {
"code": [
" if (value > prop->info->min && value <= prop->info->max) {",
" if (value > prop->info->min && value <= prop->info->max) {",
" if (value > prop->info->min && value <= prop->info->max) {"
],
"line_no": [
39,
39,
39
]
} | static void FUNC_0(Object *VAR_0, Visitor *VAR_1, void *VAR_2,
const char *VAR_3, Error **VAR_4)
{
DeviceState *dev = DEVICE(VAR_0);
Property *prop = VAR_2;
int32_t *ptr = qdev_get_prop_ptr(dev, prop);
Error *local_err = NULL;
int64_t value;
if (dev->state != DEV_STATE_CREATED) {
error_set(VAR_4, QERR_PERMISSION_DENIED);
return;
}
visit_type_int(VAR_1, &value, VAR_3, &local_err);
if (local_err) {
error_propagate(VAR_4, local_err);
return;
}
if (value > prop->info->min && value <= prop->info->max) {
*ptr = value;
} else {
error_set(VAR_4, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
dev->id?:"", VAR_3, value, prop->info->min,
prop->info->max);
}
}
| [
"static void FUNC_0(Object *VAR_0, Visitor *VAR_1, void *VAR_2,\nconst char *VAR_3, Error **VAR_4)\n{",
"DeviceState *dev = DEVICE(VAR_0);",
"Property *prop = VAR_2;",
"int32_t *ptr = qdev_get_prop_ptr(dev, prop);",
"Error *local_err = NULL;",
"int64_t value;",
"if (dev->state != DEV_STATE_CREATED) {",
"error_set(VAR_4, QERR_PERMISSION_DENIED);",
"return;",
"}",
"visit_type_int(VAR_1, &value, VAR_3, &local_err);",
"if (local_err) {",
"error_propagate(VAR_4, local_err);",
"return;",
"}",
"if (value > prop->info->min && value <= prop->info->max) {",
"*ptr = value;",
"} else {",
"error_set(VAR_4, QERR_PROPERTY_VALUE_OUT_OF_RANGE,\ndev->id?:\"\", VAR_3, value, prop->info->min,\nprop->info->max);",
"}",
"}"
] | [
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
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45,
47,
49
],
[
51
],
[
53
]
] |
1,808 | static av_cold int smvjpeg_decode_init(AVCodecContext *avctx)
{
SMVJpegDecodeContext *s = avctx->priv_data;
AVCodec *codec;
AVDictionary *thread_opt = NULL;
int ret = 0;
s->frames_per_jpeg = 0;
s->picture[0] = av_frame_alloc();
if (!s->picture[0])
return AVERROR(ENOMEM);
s->picture[1] = av_frame_alloc();
if (!s->picture[1])
return AVERROR(ENOMEM);
s->jpg.picture_ptr = s->picture[0];
if (avctx->extradata_size >= 4)
s->frames_per_jpeg = AV_RL32(avctx->extradata);
if (s->frames_per_jpeg <= 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid number of frames per jpeg.\n");
ret = -1;
}
codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG);
if (!codec) {
av_log(avctx, AV_LOG_ERROR, "MJPEG codec not found\n");
ret = -1;
}
s->avctx = avcodec_alloc_context3(codec);
av_dict_set(&thread_opt, "threads", "1", 0);
s->avctx->refcounted_frames = 1;
s->avctx->flags = avctx->flags;
s->avctx->idct_algo = avctx->idct_algo;
if (ff_codec_open2_recursive(s->avctx, codec, &thread_opt) < 0) {
av_log(avctx, AV_LOG_ERROR, "MJPEG codec failed to open\n");
ret = -1;
}
av_dict_free(&thread_opt);
return ret;
}
| true | FFmpeg | 02cb7d4c9c3adfae84ef0d5646c2de944176f849 | static av_cold int smvjpeg_decode_init(AVCodecContext *avctx)
{
SMVJpegDecodeContext *s = avctx->priv_data;
AVCodec *codec;
AVDictionary *thread_opt = NULL;
int ret = 0;
s->frames_per_jpeg = 0;
s->picture[0] = av_frame_alloc();
if (!s->picture[0])
return AVERROR(ENOMEM);
s->picture[1] = av_frame_alloc();
if (!s->picture[1])
return AVERROR(ENOMEM);
s->jpg.picture_ptr = s->picture[0];
if (avctx->extradata_size >= 4)
s->frames_per_jpeg = AV_RL32(avctx->extradata);
if (s->frames_per_jpeg <= 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid number of frames per jpeg.\n");
ret = -1;
}
codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG);
if (!codec) {
av_log(avctx, AV_LOG_ERROR, "MJPEG codec not found\n");
ret = -1;
}
s->avctx = avcodec_alloc_context3(codec);
av_dict_set(&thread_opt, "threads", "1", 0);
s->avctx->refcounted_frames = 1;
s->avctx->flags = avctx->flags;
s->avctx->idct_algo = avctx->idct_algo;
if (ff_codec_open2_recursive(s->avctx, codec, &thread_opt) < 0) {
av_log(avctx, AV_LOG_ERROR, "MJPEG codec failed to open\n");
ret = -1;
}
av_dict_free(&thread_opt);
return ret;
}
| {
"code": [
" if (!s->picture[1])",
" SMVJpegDecodeContext *s = avctx->priv_data;",
" return ret;"
],
"line_no": [
29,
5,
91
]
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
SMVJpegDecodeContext *s = avctx->priv_data;
AVCodec *codec;
AVDictionary *thread_opt = NULL;
int VAR_0 = 0;
s->frames_per_jpeg = 0;
s->picture[0] = av_frame_alloc();
if (!s->picture[0])
return AVERROR(ENOMEM);
s->picture[1] = av_frame_alloc();
if (!s->picture[1])
return AVERROR(ENOMEM);
s->jpg.picture_ptr = s->picture[0];
if (avctx->extradata_size >= 4)
s->frames_per_jpeg = AV_RL32(avctx->extradata);
if (s->frames_per_jpeg <= 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid number of frames per jpeg.\n");
VAR_0 = -1;
}
codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG);
if (!codec) {
av_log(avctx, AV_LOG_ERROR, "MJPEG codec not found\n");
VAR_0 = -1;
}
s->avctx = avcodec_alloc_context3(codec);
av_dict_set(&thread_opt, "threads", "1", 0);
s->avctx->refcounted_frames = 1;
s->avctx->flags = avctx->flags;
s->avctx->idct_algo = avctx->idct_algo;
if (ff_codec_open2_recursive(s->avctx, codec, &thread_opt) < 0) {
av_log(avctx, AV_LOG_ERROR, "MJPEG codec failed to open\n");
VAR_0 = -1;
}
av_dict_free(&thread_opt);
return VAR_0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"SMVJpegDecodeContext *s = avctx->priv_data;",
"AVCodec *codec;",
"AVDictionary *thread_opt = NULL;",
"int VAR_0 = 0;",
"s->frames_per_jpeg = 0;",
"s->picture[0] = av_frame_alloc();",
"if (!s->picture[0])\nreturn AVERROR(ENOMEM);",
"s->picture[1] = av_frame_alloc();",
"if (!s->picture[1])\nreturn AVERROR(ENOMEM);",
"s->jpg.picture_ptr = s->picture[0];",
"if (avctx->extradata_size >= 4)\ns->frames_per_jpeg = AV_RL32(avctx->extradata);",
"if (s->frames_per_jpeg <= 0) {",
"av_log(avctx, AV_LOG_ERROR, \"Invalid number of frames per jpeg.\\n\");",
"VAR_0 = -1;",
"}",
"codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG);",
"if (!codec) {",
"av_log(avctx, AV_LOG_ERROR, \"MJPEG codec not found\\n\");",
"VAR_0 = -1;",
"}",
"s->avctx = avcodec_alloc_context3(codec);",
"av_dict_set(&thread_opt, \"threads\", \"1\", 0);",
"s->avctx->refcounted_frames = 1;",
"s->avctx->flags = avctx->flags;",
"s->avctx->idct_algo = avctx->idct_algo;",
"if (ff_codec_open2_recursive(s->avctx, codec, &thread_opt) < 0) {",
"av_log(avctx, AV_LOG_ERROR, \"MJPEG codec failed to open\\n\");",
"VAR_0 = -1;",
"}",
"av_dict_free(&thread_opt);",
"return VAR_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,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21,
23
],
[
27
],
[
29,
31
],
[
35
],
[
39,
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
]
] |
1,809 | static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const char *vfilters)
{
static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE };
char sws_flags_str[128];
char buffersrc_args[256];
int ret;
AVBufferSinkParams *buffersink_params = av_buffersink_params_alloc();
AVFilterContext *filt_src = NULL, *filt_out = NULL, *filt_format, *filt_crop;
AVCodecContext *codec = is->video_st->codec;
snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%d", sws_flags);
graph->scale_sws_opts = av_strdup(sws_flags_str);
snprintf(buffersrc_args, sizeof(buffersrc_args),
"video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d",
codec->width, codec->height, codec->pix_fmt,
is->video_st->time_base.num, is->video_st->time_base.den,
codec->sample_aspect_ratio.num, codec->sample_aspect_ratio.den);
if ((ret = avfilter_graph_create_filter(&filt_src,
avfilter_get_by_name("buffer"),
"ffplay_buffer", buffersrc_args, NULL,
graph)) < 0)
return ret;
buffersink_params->pixel_fmts = pix_fmts;
ret = avfilter_graph_create_filter(&filt_out,
avfilter_get_by_name("ffbuffersink"),
"ffplay_buffersink", NULL, buffersink_params, graph);
av_freep(&buffersink_params);
if (ret < 0)
return ret;
/* SDL YUV code is not handling odd width/height for some driver
* combinations, therefore we crop the picture to an even width/height. */
if ((ret = avfilter_graph_create_filter(&filt_crop,
avfilter_get_by_name("crop"),
"ffplay_crop", "floor(in_w/2)*2:floor(in_h/2)*2", NULL, graph)) < 0)
return ret;
if ((ret = avfilter_graph_create_filter(&filt_format,
avfilter_get_by_name("format"),
"format", "yuv420p", NULL, graph)) < 0)
return ret;
if ((ret = avfilter_link(filt_crop, 0, filt_format, 0)) < 0)
return ret;
if ((ret = avfilter_link(filt_format, 0, filt_out, 0)) < 0)
return ret;
if ((ret = configure_filtergraph(graph, vfilters, filt_src, filt_crop)) < 0)
return ret;
is->in_video_filter = filt_src;
is->out_video_filter = filt_out;
return ret;
}
| true | FFmpeg | a63d7213b3eb96a35fdf34b05f45e5675107d8f9 | static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const char *vfilters)
{
static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE };
char sws_flags_str[128];
char buffersrc_args[256];
int ret;
AVBufferSinkParams *buffersink_params = av_buffersink_params_alloc();
AVFilterContext *filt_src = NULL, *filt_out = NULL, *filt_format, *filt_crop;
AVCodecContext *codec = is->video_st->codec;
snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%d", sws_flags);
graph->scale_sws_opts = av_strdup(sws_flags_str);
snprintf(buffersrc_args, sizeof(buffersrc_args),
"video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d",
codec->width, codec->height, codec->pix_fmt,
is->video_st->time_base.num, is->video_st->time_base.den,
codec->sample_aspect_ratio.num, codec->sample_aspect_ratio.den);
if ((ret = avfilter_graph_create_filter(&filt_src,
avfilter_get_by_name("buffer"),
"ffplay_buffer", buffersrc_args, NULL,
graph)) < 0)
return ret;
buffersink_params->pixel_fmts = pix_fmts;
ret = avfilter_graph_create_filter(&filt_out,
avfilter_get_by_name("ffbuffersink"),
"ffplay_buffersink", NULL, buffersink_params, graph);
av_freep(&buffersink_params);
if (ret < 0)
return ret;
if ((ret = avfilter_graph_create_filter(&filt_crop,
avfilter_get_by_name("crop"),
"ffplay_crop", "floor(in_w/2)*2:floor(in_h/2)*2", NULL, graph)) < 0)
return ret;
if ((ret = avfilter_graph_create_filter(&filt_format,
avfilter_get_by_name("format"),
"format", "yuv420p", NULL, graph)) < 0)
return ret;
if ((ret = avfilter_link(filt_crop, 0, filt_format, 0)) < 0)
return ret;
if ((ret = avfilter_link(filt_format, 0, filt_out, 0)) < 0)
return ret;
if ((ret = configure_filtergraph(graph, vfilters, filt_src, filt_crop)) < 0)
return ret;
is->in_video_filter = filt_src;
is->out_video_filter = filt_out;
return ret;
}
| {
"code": [
" codec->sample_aspect_ratio.num, codec->sample_aspect_ratio.den);"
],
"line_no": [
35
]
} | static int FUNC_0(AVFilterGraph *VAR_0, VideoState *VAR_1, const char *VAR_2)
{
static const enum AVPixelFormat VAR_3[] = { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE };
char VAR_4[128];
char VAR_5[256];
int VAR_6;
AVBufferSinkParams *buffersink_params = av_buffersink_params_alloc();
AVFilterContext *filt_src = NULL, *filt_out = NULL, *filt_format, *filt_crop;
AVCodecContext *codec = VAR_1->video_st->codec;
snprintf(VAR_4, sizeof(VAR_4), "flags=%d", sws_flags);
VAR_0->scale_sws_opts = av_strdup(VAR_4);
snprintf(VAR_5, sizeof(VAR_5),
"video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d",
codec->width, codec->height, codec->pix_fmt,
VAR_1->video_st->time_base.num, VAR_1->video_st->time_base.den,
codec->sample_aspect_ratio.num, codec->sample_aspect_ratio.den);
if ((VAR_6 = avfilter_graph_create_filter(&filt_src,
avfilter_get_by_name("buffer"),
"ffplay_buffer", VAR_5, NULL,
VAR_0)) < 0)
return VAR_6;
buffersink_params->pixel_fmts = VAR_3;
VAR_6 = avfilter_graph_create_filter(&filt_out,
avfilter_get_by_name("ffbuffersink"),
"ffplay_buffersink", NULL, buffersink_params, VAR_0);
av_freep(&buffersink_params);
if (VAR_6 < 0)
return VAR_6;
if ((VAR_6 = avfilter_graph_create_filter(&filt_crop,
avfilter_get_by_name("crop"),
"ffplay_crop", "floor(in_w/2)*2:floor(in_h/2)*2", NULL, VAR_0)) < 0)
return VAR_6;
if ((VAR_6 = avfilter_graph_create_filter(&filt_format,
avfilter_get_by_name("format"),
"format", "yuv420p", NULL, VAR_0)) < 0)
return VAR_6;
if ((VAR_6 = avfilter_link(filt_crop, 0, filt_format, 0)) < 0)
return VAR_6;
if ((VAR_6 = avfilter_link(filt_format, 0, filt_out, 0)) < 0)
return VAR_6;
if ((VAR_6 = configure_filtergraph(VAR_0, VAR_2, filt_src, filt_crop)) < 0)
return VAR_6;
VAR_1->in_video_filter = filt_src;
VAR_1->out_video_filter = filt_out;
return VAR_6;
}
| [
"static int FUNC_0(AVFilterGraph *VAR_0, VideoState *VAR_1, const char *VAR_2)\n{",
"static const enum AVPixelFormat VAR_3[] = { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE };",
"char VAR_4[128];",
"char VAR_5[256];",
"int VAR_6;",
"AVBufferSinkParams *buffersink_params = av_buffersink_params_alloc();",
"AVFilterContext *filt_src = NULL, *filt_out = NULL, *filt_format, *filt_crop;",
"AVCodecContext *codec = VAR_1->video_st->codec;",
"snprintf(VAR_4, sizeof(VAR_4), \"flags=%d\", sws_flags);",
"VAR_0->scale_sws_opts = av_strdup(VAR_4);",
"snprintf(VAR_5, sizeof(VAR_5),\n\"video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d\",\ncodec->width, codec->height, codec->pix_fmt,\nVAR_1->video_st->time_base.num, VAR_1->video_st->time_base.den,\ncodec->sample_aspect_ratio.num, codec->sample_aspect_ratio.den);",
"if ((VAR_6 = avfilter_graph_create_filter(&filt_src,\navfilter_get_by_name(\"buffer\"),\n\"ffplay_buffer\", VAR_5, NULL,\nVAR_0)) < 0)\nreturn VAR_6;",
"buffersink_params->pixel_fmts = VAR_3;",
"VAR_6 = avfilter_graph_create_filter(&filt_out,\navfilter_get_by_name(\"ffbuffersink\"),\n\"ffplay_buffersink\", NULL, buffersink_params, VAR_0);",
"av_freep(&buffersink_params);",
"if (VAR_6 < 0)\nreturn VAR_6;",
"if ((VAR_6 = avfilter_graph_create_filter(&filt_crop,\navfilter_get_by_name(\"crop\"),\n\"ffplay_crop\", \"floor(in_w/2)*2:floor(in_h/2)*2\", NULL, VAR_0)) < 0)\nreturn VAR_6;",
"if ((VAR_6 = avfilter_graph_create_filter(&filt_format,\navfilter_get_by_name(\"format\"),\n\"format\", \"yuv420p\", NULL, VAR_0)) < 0)\nreturn VAR_6;",
"if ((VAR_6 = avfilter_link(filt_crop, 0, filt_format, 0)) < 0)\nreturn VAR_6;",
"if ((VAR_6 = avfilter_link(filt_format, 0, filt_out, 0)) < 0)\nreturn VAR_6;",
"if ((VAR_6 = configure_filtergraph(VAR_0, VAR_2, filt_src, filt_crop)) < 0)\nreturn VAR_6;",
"VAR_1->in_video_filter = filt_src;",
"VAR_1->out_video_filter = filt_out;",
"return VAR_6;",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
27,
29,
31,
33,
35
],
[
39,
41,
43,
45,
47
],
[
51
],
[
53,
55,
57
],
[
59
],
[
61,
63
],
[
71,
73,
75,
77
],
[
79,
81,
83,
85
],
[
87,
89
],
[
91,
93
],
[
97,
99
],
[
103
],
[
105
],
[
109
],
[
111
]
] |
1,810 | static void pxa2xx_pcmcia_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
dc->realize = pxa2xx_pcmcia_realize;
}
| true | qemu | 7797a73947d5c0e63dd5552b348cf66c384b4555 | static void pxa2xx_pcmcia_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
dc->realize = pxa2xx_pcmcia_realize;
}
| {
"code": [
"static void pxa2xx_pcmcia_class_init(ObjectClass *oc, void *data)",
" DeviceClass *dc = DEVICE_CLASS(oc);",
" dc->realize = pxa2xx_pcmcia_realize;"
],
"line_no": [
1,
5,
9
]
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
DeviceClass *dc = DEVICE_CLASS(VAR_0);
dc->realize = pxa2xx_pcmcia_realize;
}
| [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"DeviceClass *dc = DEVICE_CLASS(VAR_0);",
"dc->realize = pxa2xx_pcmcia_realize;",
"}"
] | [
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
]
] |
1,811 | static void cuvid_flush(AVCodecContext *avctx)
{
CuvidContext *ctx = avctx->priv_data;
AVHWDeviceContext *device_ctx = (AVHWDeviceContext*)ctx->hwdevice->data;
AVCUDADeviceContext *device_hwctx = device_ctx->hwctx;
CUcontext dummy, cuda_ctx = device_hwctx->cuda_ctx;
CUVIDSOURCEDATAPACKET seq_pkt = { 0 };
int ret;
ctx->ever_flushed = 1;
ret = CHECK_CU(cuCtxPushCurrent(cuda_ctx));
if (ret < 0)
goto error;
av_fifo_freep(&ctx->frame_queue);
ctx->frame_queue = av_fifo_alloc(MAX_FRAME_COUNT * sizeof(CuvidParsedFrame));
if (!ctx->frame_queue) {
av_log(avctx, AV_LOG_ERROR, "Failed to recreate frame queue on flush\n");
return;
}
if (ctx->cudecoder) {
cuvidDestroyDecoder(ctx->cudecoder);
ctx->cudecoder = NULL;
}
if (ctx->cuparser) {
cuvidDestroyVideoParser(ctx->cuparser);
ctx->cuparser = NULL;
}
ret = CHECK_CU(cuvidCreateVideoParser(&ctx->cuparser, &ctx->cuparseinfo));
if (ret < 0)
goto error;
seq_pkt.payload = ctx->cuparse_ext.raw_seqhdr_data;
seq_pkt.payload_size = ctx->cuparse_ext.format.seqhdr_data_length;
if (seq_pkt.payload && seq_pkt.payload_size) {
ret = CHECK_CU(cuvidParseVideoData(ctx->cuparser, &seq_pkt));
if (ret < 0)
goto error;
}
ret = CHECK_CU(cuCtxPopCurrent(&dummy));
if (ret < 0)
goto error;
ctx->prev_pts = INT64_MIN;
ctx->decoder_flushing = 0;
return;
error:
av_log(avctx, AV_LOG_ERROR, "CUDA reinit on flush failed\n");
}
| false | FFmpeg | 49511501aa06ac98e41f0aa30c75ec2868a7dbd2 | static void cuvid_flush(AVCodecContext *avctx)
{
CuvidContext *ctx = avctx->priv_data;
AVHWDeviceContext *device_ctx = (AVHWDeviceContext*)ctx->hwdevice->data;
AVCUDADeviceContext *device_hwctx = device_ctx->hwctx;
CUcontext dummy, cuda_ctx = device_hwctx->cuda_ctx;
CUVIDSOURCEDATAPACKET seq_pkt = { 0 };
int ret;
ctx->ever_flushed = 1;
ret = CHECK_CU(cuCtxPushCurrent(cuda_ctx));
if (ret < 0)
goto error;
av_fifo_freep(&ctx->frame_queue);
ctx->frame_queue = av_fifo_alloc(MAX_FRAME_COUNT * sizeof(CuvidParsedFrame));
if (!ctx->frame_queue) {
av_log(avctx, AV_LOG_ERROR, "Failed to recreate frame queue on flush\n");
return;
}
if (ctx->cudecoder) {
cuvidDestroyDecoder(ctx->cudecoder);
ctx->cudecoder = NULL;
}
if (ctx->cuparser) {
cuvidDestroyVideoParser(ctx->cuparser);
ctx->cuparser = NULL;
}
ret = CHECK_CU(cuvidCreateVideoParser(&ctx->cuparser, &ctx->cuparseinfo));
if (ret < 0)
goto error;
seq_pkt.payload = ctx->cuparse_ext.raw_seqhdr_data;
seq_pkt.payload_size = ctx->cuparse_ext.format.seqhdr_data_length;
if (seq_pkt.payload && seq_pkt.payload_size) {
ret = CHECK_CU(cuvidParseVideoData(ctx->cuparser, &seq_pkt));
if (ret < 0)
goto error;
}
ret = CHECK_CU(cuCtxPopCurrent(&dummy));
if (ret < 0)
goto error;
ctx->prev_pts = INT64_MIN;
ctx->decoder_flushing = 0;
return;
error:
av_log(avctx, AV_LOG_ERROR, "CUDA reinit on flush failed\n");
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVCodecContext *VAR_0)
{
CuvidContext *ctx = VAR_0->priv_data;
AVHWDeviceContext *device_ctx = (AVHWDeviceContext*)ctx->hwdevice->data;
AVCUDADeviceContext *device_hwctx = device_ctx->hwctx;
CUcontext dummy, cuda_ctx = device_hwctx->cuda_ctx;
CUVIDSOURCEDATAPACKET seq_pkt = { 0 };
int VAR_1;
ctx->ever_flushed = 1;
VAR_1 = CHECK_CU(cuCtxPushCurrent(cuda_ctx));
if (VAR_1 < 0)
goto error;
av_fifo_freep(&ctx->frame_queue);
ctx->frame_queue = av_fifo_alloc(MAX_FRAME_COUNT * sizeof(CuvidParsedFrame));
if (!ctx->frame_queue) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to recreate frame queue on flush\n");
return;
}
if (ctx->cudecoder) {
cuvidDestroyDecoder(ctx->cudecoder);
ctx->cudecoder = NULL;
}
if (ctx->cuparser) {
cuvidDestroyVideoParser(ctx->cuparser);
ctx->cuparser = NULL;
}
VAR_1 = CHECK_CU(cuvidCreateVideoParser(&ctx->cuparser, &ctx->cuparseinfo));
if (VAR_1 < 0)
goto error;
seq_pkt.payload = ctx->cuparse_ext.raw_seqhdr_data;
seq_pkt.payload_size = ctx->cuparse_ext.format.seqhdr_data_length;
if (seq_pkt.payload && seq_pkt.payload_size) {
VAR_1 = CHECK_CU(cuvidParseVideoData(ctx->cuparser, &seq_pkt));
if (VAR_1 < 0)
goto error;
}
VAR_1 = CHECK_CU(cuCtxPopCurrent(&dummy));
if (VAR_1 < 0)
goto error;
ctx->prev_pts = INT64_MIN;
ctx->decoder_flushing = 0;
return;
error:
av_log(VAR_0, AV_LOG_ERROR, "CUDA reinit on flush failed\n");
}
| [
"static void FUNC_0(AVCodecContext *VAR_0)\n{",
"CuvidContext *ctx = VAR_0->priv_data;",
"AVHWDeviceContext *device_ctx = (AVHWDeviceContext*)ctx->hwdevice->data;",
"AVCUDADeviceContext *device_hwctx = device_ctx->hwctx;",
"CUcontext dummy, cuda_ctx = device_hwctx->cuda_ctx;",
"CUVIDSOURCEDATAPACKET seq_pkt = { 0 };",
"int VAR_1;",
"ctx->ever_flushed = 1;",
"VAR_1 = CHECK_CU(cuCtxPushCurrent(cuda_ctx));",
"if (VAR_1 < 0)\ngoto error;",
"av_fifo_freep(&ctx->frame_queue);",
"ctx->frame_queue = av_fifo_alloc(MAX_FRAME_COUNT * sizeof(CuvidParsedFrame));",
"if (!ctx->frame_queue) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to recreate frame queue on flush\\n\");",
"return;",
"}",
"if (ctx->cudecoder) {",
"cuvidDestroyDecoder(ctx->cudecoder);",
"ctx->cudecoder = NULL;",
"}",
"if (ctx->cuparser) {",
"cuvidDestroyVideoParser(ctx->cuparser);",
"ctx->cuparser = NULL;",
"}",
"VAR_1 = CHECK_CU(cuvidCreateVideoParser(&ctx->cuparser, &ctx->cuparseinfo));",
"if (VAR_1 < 0)\ngoto error;",
"seq_pkt.payload = ctx->cuparse_ext.raw_seqhdr_data;",
"seq_pkt.payload_size = ctx->cuparse_ext.format.seqhdr_data_length;",
"if (seq_pkt.payload && seq_pkt.payload_size) {",
"VAR_1 = CHECK_CU(cuvidParseVideoData(ctx->cuparser, &seq_pkt));",
"if (VAR_1 < 0)\ngoto error;",
"}",
"VAR_1 = CHECK_CU(cuCtxPopCurrent(&dummy));",
"if (VAR_1 < 0)\ngoto error;",
"ctx->prev_pts = INT64_MIN;",
"ctx->decoder_flushing = 0;",
"return;",
"error:\nav_log(VAR_0, AV_LOG_ERROR, \"CUDA reinit on flush failed\\n\");",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23
],
[
25,
27
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69,
71
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85,
87
],
[
89
],
[
93
],
[
95,
97
],
[
101
],
[
103
],
[
107
],
[
109,
111
],
[
113
]
] |
1,812 | void ff_avg_h264_qpel8_mc00_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avg_width8_msa(src, stride, dst, stride, 8);
}
| false | FFmpeg | 0105ed551cb9610c62b6920a301125781e1161a0 | void ff_avg_h264_qpel8_mc00_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avg_width8_msa(src, stride, dst, stride, 8);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,
ptrdiff_t VAR_2)
{
avg_width8_msa(VAR_1, VAR_2, VAR_0, VAR_2, 8);
}
| [
"void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,\nptrdiff_t VAR_2)\n{",
"avg_width8_msa(VAR_1, VAR_2, VAR_0, VAR_2, 8);",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
]
] |
1,813 | static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet)
{
TiffEncoderContext *s = avctx->priv_data;
const AVFrame *const p = pict;
int i;
uint8_t *ptr;
uint8_t *offset;
uint32_t strips;
uint32_t *strip_sizes = NULL;
uint32_t *strip_offsets = NULL;
int bytes_per_row;
uint32_t res[2] = { 72, 1 }; // image resolution (72/1)
uint16_t bpp_tab[] = { 8, 8, 8, 8 };
int ret;
int is_yuv = 0;
uint8_t *yuv_line = NULL;
int shift_h, shift_v;
int packet_size;
const AVPixFmtDescriptor *pfd;
s->avctx = avctx;
s->width = avctx->width;
s->height = avctx->height;
s->subsampling[0] = 1;
s->subsampling[1] = 1;
switch (avctx->pix_fmt) {
case AV_PIX_FMT_RGB48LE:
case AV_PIX_FMT_GRAY16LE:
case AV_PIX_FMT_RGBA:
case AV_PIX_FMT_RGB24:
case AV_PIX_FMT_GRAY8:
case AV_PIX_FMT_PAL8:
pfd = av_pix_fmt_desc_get(avctx->pix_fmt);
s->bpp = av_get_bits_per_pixel(pfd);
if (pfd->flags & AV_PIX_FMT_FLAG_PAL)
s->photometric_interpretation = TIFF_PHOTOMETRIC_PALETTE;
else if (pfd->flags & AV_PIX_FMT_FLAG_RGB)
s->photometric_interpretation = TIFF_PHOTOMETRIC_RGB;
else
s->photometric_interpretation = TIFF_PHOTOMETRIC_BLACK_IS_ZERO;
s->bpp_tab_size = pfd->nb_components;
for (i = 0; i < s->bpp_tab_size; i++)
bpp_tab[i] = s->bpp / s->bpp_tab_size;
break;
case AV_PIX_FMT_MONOBLACK:
s->bpp = 1;
s->photometric_interpretation = TIFF_PHOTOMETRIC_BLACK_IS_ZERO;
s->bpp_tab_size = 0;
break;
case AV_PIX_FMT_MONOWHITE:
s->bpp = 1;
s->photometric_interpretation = TIFF_PHOTOMETRIC_WHITE_IS_ZERO;
s->bpp_tab_size = 0;
break;
case AV_PIX_FMT_YUV420P:
case AV_PIX_FMT_YUV422P:
case AV_PIX_FMT_YUV444P:
case AV_PIX_FMT_YUV410P:
case AV_PIX_FMT_YUV411P:
av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &shift_h, &shift_v);
s->photometric_interpretation = TIFF_PHOTOMETRIC_YCBCR;
s->bpp = 8 + (16 >> (shift_h + shift_v));
s->subsampling[0] = 1 << shift_h;
s->subsampling[1] = 1 << shift_v;
s->bpp_tab_size = 3;
is_yuv = 1;
break;
default:
av_log(s->avctx, AV_LOG_ERROR,
"This colors format is not supported\n");
return -1;
}
if (s->compr == TIFF_DEFLATE ||
s->compr == TIFF_ADOBE_DEFLATE ||
s->compr == TIFF_LZW)
// best choice for DEFLATE
s->rps = s->height;
else
// suggest size of strip
s->rps = FFMAX(8192 / (((s->width * s->bpp) >> 3) + 1), 1);
// round rps up
s->rps = ((s->rps - 1) / s->subsampling[1] + 1) * s->subsampling[1];
strips = (s->height - 1) / s->rps + 1;
packet_size = avctx->height * ((avctx->width * s->bpp + 7) >> 3) * 2 +
avctx->height * 4 + FF_MIN_BUFFER_SIZE;
if (!pkt->data &&
(ret = av_new_packet(pkt, packet_size)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
return ret;
}
ptr = pkt->data;
s->buf_start = pkt->data;
s->buf = &ptr;
s->buf_size = pkt->size;
if (check_size(s, 8))
goto fail;
// write header
bytestream_put_le16(&ptr, 0x4949);
bytestream_put_le16(&ptr, 42);
offset = ptr;
bytestream_put_le32(&ptr, 0);
strip_sizes = av_mallocz_array(strips, sizeof(*strip_sizes));
strip_offsets = av_mallocz_array(strips, sizeof(*strip_offsets));
if (!strip_sizes || !strip_offsets) {
ret = AVERROR(ENOMEM);
goto fail;
}
bytes_per_row = (((s->width - 1) / s->subsampling[0] + 1) * s->bpp *
s->subsampling[0] * s->subsampling[1] + 7) >> 3;
if (is_yuv) {
yuv_line = av_malloc(bytes_per_row);
if (!yuv_line) {
av_log(s->avctx, AV_LOG_ERROR, "Not enough memory\n");
ret = AVERROR(ENOMEM);
goto fail;
}
}
#if CONFIG_ZLIB
if (s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE) {
uint8_t *zbuf;
int zlen, zn;
int j;
zlen = bytes_per_row * s->rps;
zbuf = av_malloc(zlen);
if (!zbuf) {
ret = AVERROR(ENOMEM);
goto fail;
}
strip_offsets[0] = ptr - pkt->data;
zn = 0;
for (j = 0; j < s->rps; j++) {
if (is_yuv) {
pack_yuv(s, p, yuv_line, j);
memcpy(zbuf + zn, yuv_line, bytes_per_row);
j += s->subsampling[1] - 1;
} else
memcpy(zbuf + j * bytes_per_row,
p->data[0] + j * p->linesize[0], bytes_per_row);
zn += bytes_per_row;
}
ret = encode_strip(s, zbuf, ptr, zn, s->compr);
av_free(zbuf);
if (ret < 0) {
av_log(s->avctx, AV_LOG_ERROR, "Encode strip failed\n");
goto fail;
}
ptr += ret;
strip_sizes[0] = ptr - pkt->data - strip_offsets[0];
} else
#endif
if (s->compr == TIFF_LZW) {
s->lzws = av_malloc(ff_lzw_encode_state_size);
if (!s->lzws) {
ret = AVERROR(ENOMEM);
goto fail;
}
}
for (i = 0; i < s->height; i++) {
if (strip_sizes[i / s->rps] == 0) {
if (s->compr == TIFF_LZW) {
ff_lzw_encode_init(s->lzws, ptr,
s->buf_size - (*s->buf - s->buf_start),
12, FF_LZW_TIFF, put_bits);
}
strip_offsets[i / s->rps] = ptr - pkt->data;
}
if (is_yuv) {
pack_yuv(s, p, yuv_line, i);
ret = encode_strip(s, yuv_line, ptr, bytes_per_row, s->compr);
i += s->subsampling[1] - 1;
} else
ret = encode_strip(s, p->data[0] + i * p->linesize[0],
ptr, bytes_per_row, s->compr);
if (ret < 0) {
av_log(s->avctx, AV_LOG_ERROR, "Encode strip failed\n");
goto fail;
}
strip_sizes[i / s->rps] += ret;
ptr += ret;
if (s->compr == TIFF_LZW &&
(i == s->height - 1 || i % s->rps == s->rps - 1)) {
ret = ff_lzw_encode_flush(s->lzws, flush_put_bits);
strip_sizes[(i / s->rps)] += ret;
ptr += ret;
}
}
if (s->compr == TIFF_LZW)
av_free(s->lzws);
s->num_entries = 0;
add_entry1(s, TIFF_SUBFILE, TIFF_LONG, 0);
add_entry1(s, TIFF_WIDTH, TIFF_LONG, s->width);
add_entry1(s, TIFF_HEIGHT, TIFF_LONG, s->height);
if (s->bpp_tab_size)
add_entry(s, TIFF_BPP, TIFF_SHORT, s->bpp_tab_size, bpp_tab);
add_entry1(s, TIFF_COMPR, TIFF_SHORT, s->compr);
add_entry1(s, TIFF_PHOTOMETRIC, TIFF_SHORT, s->photometric_interpretation);
add_entry(s, TIFF_STRIP_OFFS, TIFF_LONG, strips, strip_offsets);
if (s->bpp_tab_size)
add_entry1(s, TIFF_SAMPLES_PER_PIXEL, TIFF_SHORT, s->bpp_tab_size);
add_entry1(s, TIFF_ROWSPERSTRIP, TIFF_LONG, s->rps);
add_entry(s, TIFF_STRIP_SIZE, TIFF_LONG, strips, strip_sizes);
add_entry(s, TIFF_XRES, TIFF_RATIONAL, 1, res);
add_entry(s, TIFF_YRES, TIFF_RATIONAL, 1, res);
add_entry1(s, TIFF_RES_UNIT, TIFF_SHORT, 2);
if (!(avctx->flags & CODEC_FLAG_BITEXACT))
add_entry(s, TIFF_SOFTWARE_NAME, TIFF_STRING,
strlen(LIBAVCODEC_IDENT) + 1, LIBAVCODEC_IDENT);
if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
uint16_t pal[256 * 3];
for (i = 0; i < 256; i++) {
uint32_t rgb = *(uint32_t *) (p->data[1] + i * 4);
pal[i] = ((rgb >> 16) & 0xff) * 257;
pal[i + 256] = ((rgb >> 8) & 0xff) * 257;
pal[i + 512] = (rgb & 0xff) * 257;
}
add_entry(s, TIFF_PAL, TIFF_SHORT, 256 * 3, pal);
}
if (is_yuv) {
/** according to CCIR Recommendation 601.1 */
uint32_t refbw[12] = { 15, 1, 235, 1, 128, 1, 240, 1, 128, 1, 240, 1 };
add_entry(s, TIFF_YCBCR_SUBSAMPLING, TIFF_SHORT, 2, s->subsampling);
add_entry(s, TIFF_REFERENCE_BW, TIFF_RATIONAL, 6, refbw);
}
// write offset to dir
bytestream_put_le32(&offset, ptr - pkt->data);
if (check_size(s, 6 + s->num_entries * 12)) {
ret = AVERROR(EINVAL);
goto fail;
}
bytestream_put_le16(&ptr, s->num_entries); // write tag count
bytestream_put_buffer(&ptr, s->entries, s->num_entries * 12);
bytestream_put_le32(&ptr, 0);
pkt->size = ptr - pkt->data;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
fail:
av_free(strip_sizes);
av_free(strip_offsets);
av_free(yuv_line);
return ret;
}
| false | FFmpeg | 0562887a984388fdc7a9b71c9374ff9c756fb4f1 | static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet)
{
TiffEncoderContext *s = avctx->priv_data;
const AVFrame *const p = pict;
int i;
uint8_t *ptr;
uint8_t *offset;
uint32_t strips;
uint32_t *strip_sizes = NULL;
uint32_t *strip_offsets = NULL;
int bytes_per_row;
uint32_t res[2] = { 72, 1 };
uint16_t bpp_tab[] = { 8, 8, 8, 8 };
int ret;
int is_yuv = 0;
uint8_t *yuv_line = NULL;
int shift_h, shift_v;
int packet_size;
const AVPixFmtDescriptor *pfd;
s->avctx = avctx;
s->width = avctx->width;
s->height = avctx->height;
s->subsampling[0] = 1;
s->subsampling[1] = 1;
switch (avctx->pix_fmt) {
case AV_PIX_FMT_RGB48LE:
case AV_PIX_FMT_GRAY16LE:
case AV_PIX_FMT_RGBA:
case AV_PIX_FMT_RGB24:
case AV_PIX_FMT_GRAY8:
case AV_PIX_FMT_PAL8:
pfd = av_pix_fmt_desc_get(avctx->pix_fmt);
s->bpp = av_get_bits_per_pixel(pfd);
if (pfd->flags & AV_PIX_FMT_FLAG_PAL)
s->photometric_interpretation = TIFF_PHOTOMETRIC_PALETTE;
else if (pfd->flags & AV_PIX_FMT_FLAG_RGB)
s->photometric_interpretation = TIFF_PHOTOMETRIC_RGB;
else
s->photometric_interpretation = TIFF_PHOTOMETRIC_BLACK_IS_ZERO;
s->bpp_tab_size = pfd->nb_components;
for (i = 0; i < s->bpp_tab_size; i++)
bpp_tab[i] = s->bpp / s->bpp_tab_size;
break;
case AV_PIX_FMT_MONOBLACK:
s->bpp = 1;
s->photometric_interpretation = TIFF_PHOTOMETRIC_BLACK_IS_ZERO;
s->bpp_tab_size = 0;
break;
case AV_PIX_FMT_MONOWHITE:
s->bpp = 1;
s->photometric_interpretation = TIFF_PHOTOMETRIC_WHITE_IS_ZERO;
s->bpp_tab_size = 0;
break;
case AV_PIX_FMT_YUV420P:
case AV_PIX_FMT_YUV422P:
case AV_PIX_FMT_YUV444P:
case AV_PIX_FMT_YUV410P:
case AV_PIX_FMT_YUV411P:
av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &shift_h, &shift_v);
s->photometric_interpretation = TIFF_PHOTOMETRIC_YCBCR;
s->bpp = 8 + (16 >> (shift_h + shift_v));
s->subsampling[0] = 1 << shift_h;
s->subsampling[1] = 1 << shift_v;
s->bpp_tab_size = 3;
is_yuv = 1;
break;
default:
av_log(s->avctx, AV_LOG_ERROR,
"This colors format is not supported\n");
return -1;
}
if (s->compr == TIFF_DEFLATE ||
s->compr == TIFF_ADOBE_DEFLATE ||
s->compr == TIFF_LZW)
s->rps = s->height;
else
s->rps = FFMAX(8192 / (((s->width * s->bpp) >> 3) + 1), 1);
s->rps = ((s->rps - 1) / s->subsampling[1] + 1) * s->subsampling[1];
strips = (s->height - 1) / s->rps + 1;
packet_size = avctx->height * ((avctx->width * s->bpp + 7) >> 3) * 2 +
avctx->height * 4 + FF_MIN_BUFFER_SIZE;
if (!pkt->data &&
(ret = av_new_packet(pkt, packet_size)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
return ret;
}
ptr = pkt->data;
s->buf_start = pkt->data;
s->buf = &ptr;
s->buf_size = pkt->size;
if (check_size(s, 8))
goto fail;
bytestream_put_le16(&ptr, 0x4949);
bytestream_put_le16(&ptr, 42);
offset = ptr;
bytestream_put_le32(&ptr, 0);
strip_sizes = av_mallocz_array(strips, sizeof(*strip_sizes));
strip_offsets = av_mallocz_array(strips, sizeof(*strip_offsets));
if (!strip_sizes || !strip_offsets) {
ret = AVERROR(ENOMEM);
goto fail;
}
bytes_per_row = (((s->width - 1) / s->subsampling[0] + 1) * s->bpp *
s->subsampling[0] * s->subsampling[1] + 7) >> 3;
if (is_yuv) {
yuv_line = av_malloc(bytes_per_row);
if (!yuv_line) {
av_log(s->avctx, AV_LOG_ERROR, "Not enough memory\n");
ret = AVERROR(ENOMEM);
goto fail;
}
}
#if CONFIG_ZLIB
if (s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE) {
uint8_t *zbuf;
int zlen, zn;
int j;
zlen = bytes_per_row * s->rps;
zbuf = av_malloc(zlen);
if (!zbuf) {
ret = AVERROR(ENOMEM);
goto fail;
}
strip_offsets[0] = ptr - pkt->data;
zn = 0;
for (j = 0; j < s->rps; j++) {
if (is_yuv) {
pack_yuv(s, p, yuv_line, j);
memcpy(zbuf + zn, yuv_line, bytes_per_row);
j += s->subsampling[1] - 1;
} else
memcpy(zbuf + j * bytes_per_row,
p->data[0] + j * p->linesize[0], bytes_per_row);
zn += bytes_per_row;
}
ret = encode_strip(s, zbuf, ptr, zn, s->compr);
av_free(zbuf);
if (ret < 0) {
av_log(s->avctx, AV_LOG_ERROR, "Encode strip failed\n");
goto fail;
}
ptr += ret;
strip_sizes[0] = ptr - pkt->data - strip_offsets[0];
} else
#endif
if (s->compr == TIFF_LZW) {
s->lzws = av_malloc(ff_lzw_encode_state_size);
if (!s->lzws) {
ret = AVERROR(ENOMEM);
goto fail;
}
}
for (i = 0; i < s->height; i++) {
if (strip_sizes[i / s->rps] == 0) {
if (s->compr == TIFF_LZW) {
ff_lzw_encode_init(s->lzws, ptr,
s->buf_size - (*s->buf - s->buf_start),
12, FF_LZW_TIFF, put_bits);
}
strip_offsets[i / s->rps] = ptr - pkt->data;
}
if (is_yuv) {
pack_yuv(s, p, yuv_line, i);
ret = encode_strip(s, yuv_line, ptr, bytes_per_row, s->compr);
i += s->subsampling[1] - 1;
} else
ret = encode_strip(s, p->data[0] + i * p->linesize[0],
ptr, bytes_per_row, s->compr);
if (ret < 0) {
av_log(s->avctx, AV_LOG_ERROR, "Encode strip failed\n");
goto fail;
}
strip_sizes[i / s->rps] += ret;
ptr += ret;
if (s->compr == TIFF_LZW &&
(i == s->height - 1 || i % s->rps == s->rps - 1)) {
ret = ff_lzw_encode_flush(s->lzws, flush_put_bits);
strip_sizes[(i / s->rps)] += ret;
ptr += ret;
}
}
if (s->compr == TIFF_LZW)
av_free(s->lzws);
s->num_entries = 0;
add_entry1(s, TIFF_SUBFILE, TIFF_LONG, 0);
add_entry1(s, TIFF_WIDTH, TIFF_LONG, s->width);
add_entry1(s, TIFF_HEIGHT, TIFF_LONG, s->height);
if (s->bpp_tab_size)
add_entry(s, TIFF_BPP, TIFF_SHORT, s->bpp_tab_size, bpp_tab);
add_entry1(s, TIFF_COMPR, TIFF_SHORT, s->compr);
add_entry1(s, TIFF_PHOTOMETRIC, TIFF_SHORT, s->photometric_interpretation);
add_entry(s, TIFF_STRIP_OFFS, TIFF_LONG, strips, strip_offsets);
if (s->bpp_tab_size)
add_entry1(s, TIFF_SAMPLES_PER_PIXEL, TIFF_SHORT, s->bpp_tab_size);
add_entry1(s, TIFF_ROWSPERSTRIP, TIFF_LONG, s->rps);
add_entry(s, TIFF_STRIP_SIZE, TIFF_LONG, strips, strip_sizes);
add_entry(s, TIFF_XRES, TIFF_RATIONAL, 1, res);
add_entry(s, TIFF_YRES, TIFF_RATIONAL, 1, res);
add_entry1(s, TIFF_RES_UNIT, TIFF_SHORT, 2);
if (!(avctx->flags & CODEC_FLAG_BITEXACT))
add_entry(s, TIFF_SOFTWARE_NAME, TIFF_STRING,
strlen(LIBAVCODEC_IDENT) + 1, LIBAVCODEC_IDENT);
if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
uint16_t pal[256 * 3];
for (i = 0; i < 256; i++) {
uint32_t rgb = *(uint32_t *) (p->data[1] + i * 4);
pal[i] = ((rgb >> 16) & 0xff) * 257;
pal[i + 256] = ((rgb >> 8) & 0xff) * 257;
pal[i + 512] = (rgb & 0xff) * 257;
}
add_entry(s, TIFF_PAL, TIFF_SHORT, 256 * 3, pal);
}
if (is_yuv) {
uint32_t refbw[12] = { 15, 1, 235, 1, 128, 1, 240, 1, 128, 1, 240, 1 };
add_entry(s, TIFF_YCBCR_SUBSAMPLING, TIFF_SHORT, 2, s->subsampling);
add_entry(s, TIFF_REFERENCE_BW, TIFF_RATIONAL, 6, refbw);
}
bytestream_put_le32(&offset, ptr - pkt->data);
if (check_size(s, 6 + s->num_entries * 12)) {
ret = AVERROR(EINVAL);
goto fail;
}
bytestream_put_le16(&ptr, s->num_entries);
bytestream_put_buffer(&ptr, s->entries, s->num_entries * 12);
bytestream_put_le32(&ptr, 0);
pkt->size = ptr - pkt->data;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
fail:
av_free(strip_sizes);
av_free(strip_offsets);
av_free(yuv_line);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,
const AVFrame *VAR_2, int *VAR_3)
{
TiffEncoderContext *s = VAR_0->priv_data;
const AVFrame *const VAR_4 = VAR_2;
int VAR_5;
uint8_t *ptr;
uint8_t *offset;
uint32_t strips;
uint32_t *strip_sizes = NULL;
uint32_t *strip_offsets = NULL;
int VAR_6;
uint32_t res[2] = { 72, 1 };
uint16_t bpp_tab[] = { 8, 8, 8, 8 };
int VAR_7;
int VAR_8 = 0;
uint8_t *yuv_line = NULL;
int VAR_9, VAR_10;
int VAR_11;
const AVPixFmtDescriptor *VAR_12;
s->VAR_0 = VAR_0;
s->width = VAR_0->width;
s->height = VAR_0->height;
s->subsampling[0] = 1;
s->subsampling[1] = 1;
switch (VAR_0->pix_fmt) {
case AV_PIX_FMT_RGB48LE:
case AV_PIX_FMT_GRAY16LE:
case AV_PIX_FMT_RGBA:
case AV_PIX_FMT_RGB24:
case AV_PIX_FMT_GRAY8:
case AV_PIX_FMT_PAL8:
VAR_12 = av_pix_fmt_desc_get(VAR_0->pix_fmt);
s->bpp = av_get_bits_per_pixel(VAR_12);
if (VAR_12->flags & AV_PIX_FMT_FLAG_PAL)
s->photometric_interpretation = TIFF_PHOTOMETRIC_PALETTE;
else if (VAR_12->flags & AV_PIX_FMT_FLAG_RGB)
s->photometric_interpretation = TIFF_PHOTOMETRIC_RGB;
else
s->photometric_interpretation = TIFF_PHOTOMETRIC_BLACK_IS_ZERO;
s->bpp_tab_size = VAR_12->nb_components;
for (VAR_5 = 0; VAR_5 < s->bpp_tab_size; VAR_5++)
bpp_tab[VAR_5] = s->bpp / s->bpp_tab_size;
break;
case AV_PIX_FMT_MONOBLACK:
s->bpp = 1;
s->photometric_interpretation = TIFF_PHOTOMETRIC_BLACK_IS_ZERO;
s->bpp_tab_size = 0;
break;
case AV_PIX_FMT_MONOWHITE:
s->bpp = 1;
s->photometric_interpretation = TIFF_PHOTOMETRIC_WHITE_IS_ZERO;
s->bpp_tab_size = 0;
break;
case AV_PIX_FMT_YUV420P:
case AV_PIX_FMT_YUV422P:
case AV_PIX_FMT_YUV444P:
case AV_PIX_FMT_YUV410P:
case AV_PIX_FMT_YUV411P:
av_pix_fmt_get_chroma_sub_sample(VAR_0->pix_fmt, &VAR_9, &VAR_10);
s->photometric_interpretation = TIFF_PHOTOMETRIC_YCBCR;
s->bpp = 8 + (16 >> (VAR_9 + VAR_10));
s->subsampling[0] = 1 << VAR_9;
s->subsampling[1] = 1 << VAR_10;
s->bpp_tab_size = 3;
VAR_8 = 1;
break;
default:
av_log(s->VAR_0, AV_LOG_ERROR,
"This colors format is not supported\n");
return -1;
}
if (s->compr == TIFF_DEFLATE ||
s->compr == TIFF_ADOBE_DEFLATE ||
s->compr == TIFF_LZW)
s->rps = s->height;
else
s->rps = FFMAX(8192 / (((s->width * s->bpp) >> 3) + 1), 1);
s->rps = ((s->rps - 1) / s->subsampling[1] + 1) * s->subsampling[1];
strips = (s->height - 1) / s->rps + 1;
VAR_11 = VAR_0->height * ((VAR_0->width * s->bpp + 7) >> 3) * 2 +
VAR_0->height * 4 + FF_MIN_BUFFER_SIZE;
if (!VAR_1->data &&
(VAR_7 = av_new_packet(VAR_1, VAR_11)) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Error getting output packet.\n");
return VAR_7;
}
ptr = VAR_1->data;
s->buf_start = VAR_1->data;
s->buf = &ptr;
s->buf_size = VAR_1->size;
if (check_size(s, 8))
goto fail;
bytestream_put_le16(&ptr, 0x4949);
bytestream_put_le16(&ptr, 42);
offset = ptr;
bytestream_put_le32(&ptr, 0);
strip_sizes = av_mallocz_array(strips, sizeof(*strip_sizes));
strip_offsets = av_mallocz_array(strips, sizeof(*strip_offsets));
if (!strip_sizes || !strip_offsets) {
VAR_7 = AVERROR(ENOMEM);
goto fail;
}
VAR_6 = (((s->width - 1) / s->subsampling[0] + 1) * s->bpp *
s->subsampling[0] * s->subsampling[1] + 7) >> 3;
if (VAR_8) {
yuv_line = av_malloc(VAR_6);
if (!yuv_line) {
av_log(s->VAR_0, AV_LOG_ERROR, "Not enough memory\n");
VAR_7 = AVERROR(ENOMEM);
goto fail;
}
}
#if CONFIG_ZLIB
if (s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE) {
uint8_t *zbuf;
int zlen, zn;
int j;
zlen = VAR_6 * s->rps;
zbuf = av_malloc(zlen);
if (!zbuf) {
VAR_7 = AVERROR(ENOMEM);
goto fail;
}
strip_offsets[0] = ptr - VAR_1->data;
zn = 0;
for (j = 0; j < s->rps; j++) {
if (VAR_8) {
pack_yuv(s, VAR_4, yuv_line, j);
memcpy(zbuf + zn, yuv_line, VAR_6);
j += s->subsampling[1] - 1;
} else
memcpy(zbuf + j * VAR_6,
VAR_4->data[0] + j * VAR_4->linesize[0], VAR_6);
zn += VAR_6;
}
VAR_7 = encode_strip(s, zbuf, ptr, zn, s->compr);
av_free(zbuf);
if (VAR_7 < 0) {
av_log(s->VAR_0, AV_LOG_ERROR, "Encode strip failed\n");
goto fail;
}
ptr += VAR_7;
strip_sizes[0] = ptr - VAR_1->data - strip_offsets[0];
} else
#endif
if (s->compr == TIFF_LZW) {
s->lzws = av_malloc(ff_lzw_encode_state_size);
if (!s->lzws) {
VAR_7 = AVERROR(ENOMEM);
goto fail;
}
}
for (VAR_5 = 0; VAR_5 < s->height; VAR_5++) {
if (strip_sizes[VAR_5 / s->rps] == 0) {
if (s->compr == TIFF_LZW) {
ff_lzw_encode_init(s->lzws, ptr,
s->buf_size - (*s->buf - s->buf_start),
12, FF_LZW_TIFF, put_bits);
}
strip_offsets[VAR_5 / s->rps] = ptr - VAR_1->data;
}
if (VAR_8) {
pack_yuv(s, VAR_4, yuv_line, VAR_5);
VAR_7 = encode_strip(s, yuv_line, ptr, VAR_6, s->compr);
VAR_5 += s->subsampling[1] - 1;
} else
VAR_7 = encode_strip(s, VAR_4->data[0] + VAR_5 * VAR_4->linesize[0],
ptr, VAR_6, s->compr);
if (VAR_7 < 0) {
av_log(s->VAR_0, AV_LOG_ERROR, "Encode strip failed\n");
goto fail;
}
strip_sizes[VAR_5 / s->rps] += VAR_7;
ptr += VAR_7;
if (s->compr == TIFF_LZW &&
(VAR_5 == s->height - 1 || VAR_5 % s->rps == s->rps - 1)) {
VAR_7 = ff_lzw_encode_flush(s->lzws, flush_put_bits);
strip_sizes[(VAR_5 / s->rps)] += VAR_7;
ptr += VAR_7;
}
}
if (s->compr == TIFF_LZW)
av_free(s->lzws);
s->num_entries = 0;
add_entry1(s, TIFF_SUBFILE, TIFF_LONG, 0);
add_entry1(s, TIFF_WIDTH, TIFF_LONG, s->width);
add_entry1(s, TIFF_HEIGHT, TIFF_LONG, s->height);
if (s->bpp_tab_size)
add_entry(s, TIFF_BPP, TIFF_SHORT, s->bpp_tab_size, bpp_tab);
add_entry1(s, TIFF_COMPR, TIFF_SHORT, s->compr);
add_entry1(s, TIFF_PHOTOMETRIC, TIFF_SHORT, s->photometric_interpretation);
add_entry(s, TIFF_STRIP_OFFS, TIFF_LONG, strips, strip_offsets);
if (s->bpp_tab_size)
add_entry1(s, TIFF_SAMPLES_PER_PIXEL, TIFF_SHORT, s->bpp_tab_size);
add_entry1(s, TIFF_ROWSPERSTRIP, TIFF_LONG, s->rps);
add_entry(s, TIFF_STRIP_SIZE, TIFF_LONG, strips, strip_sizes);
add_entry(s, TIFF_XRES, TIFF_RATIONAL, 1, res);
add_entry(s, TIFF_YRES, TIFF_RATIONAL, 1, res);
add_entry1(s, TIFF_RES_UNIT, TIFF_SHORT, 2);
if (!(VAR_0->flags & CODEC_FLAG_BITEXACT))
add_entry(s, TIFF_SOFTWARE_NAME, TIFF_STRING,
strlen(LIBAVCODEC_IDENT) + 1, LIBAVCODEC_IDENT);
if (VAR_0->pix_fmt == AV_PIX_FMT_PAL8) {
uint16_t pal[256 * 3];
for (VAR_5 = 0; VAR_5 < 256; VAR_5++) {
uint32_t rgb = *(uint32_t *) (VAR_4->data[1] + VAR_5 * 4);
pal[VAR_5] = ((rgb >> 16) & 0xff) * 257;
pal[VAR_5 + 256] = ((rgb >> 8) & 0xff) * 257;
pal[VAR_5 + 512] = (rgb & 0xff) * 257;
}
add_entry(s, TIFF_PAL, TIFF_SHORT, 256 * 3, pal);
}
if (VAR_8) {
uint32_t refbw[12] = { 15, 1, 235, 1, 128, 1, 240, 1, 128, 1, 240, 1 };
add_entry(s, TIFF_YCBCR_SUBSAMPLING, TIFF_SHORT, 2, s->subsampling);
add_entry(s, TIFF_REFERENCE_BW, TIFF_RATIONAL, 6, refbw);
}
bytestream_put_le32(&offset, ptr - VAR_1->data);
if (check_size(s, 6 + s->num_entries * 12)) {
VAR_7 = AVERROR(EINVAL);
goto fail;
}
bytestream_put_le16(&ptr, s->num_entries);
bytestream_put_buffer(&ptr, s->entries, s->num_entries * 12);
bytestream_put_le32(&ptr, 0);
VAR_1->size = ptr - VAR_1->data;
VAR_1->flags |= AV_PKT_FLAG_KEY;
*VAR_3 = 1;
fail:
av_free(strip_sizes);
av_free(strip_offsets);
av_free(yuv_line);
return VAR_7;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,\nconst AVFrame *VAR_2, int *VAR_3)\n{",
"TiffEncoderContext *s = VAR_0->priv_data;",
"const AVFrame *const VAR_4 = VAR_2;",
"int VAR_5;",
"uint8_t *ptr;",
"uint8_t *offset;",
"uint32_t strips;",
"uint32_t *strip_sizes = NULL;",
"uint32_t *strip_offsets = NULL;",
"int VAR_6;",
"uint32_t res[2] = { 72, 1 };",
"uint16_t bpp_tab[] = { 8, 8, 8, 8 };",
"int VAR_7;",
"int VAR_8 = 0;",
"uint8_t *yuv_line = NULL;",
"int VAR_9, VAR_10;",
"int VAR_11;",
"const AVPixFmtDescriptor *VAR_12;",
"s->VAR_0 = VAR_0;",
"s->width = VAR_0->width;",
"s->height = VAR_0->height;",
"s->subsampling[0] = 1;",
"s->subsampling[1] = 1;",
"switch (VAR_0->pix_fmt) {",
"case AV_PIX_FMT_RGB48LE:\ncase AV_PIX_FMT_GRAY16LE:\ncase AV_PIX_FMT_RGBA:\ncase AV_PIX_FMT_RGB24:\ncase AV_PIX_FMT_GRAY8:\ncase AV_PIX_FMT_PAL8:\nVAR_12 = av_pix_fmt_desc_get(VAR_0->pix_fmt);",
"s->bpp = av_get_bits_per_pixel(VAR_12);",
"if (VAR_12->flags & AV_PIX_FMT_FLAG_PAL)\ns->photometric_interpretation = TIFF_PHOTOMETRIC_PALETTE;",
"else if (VAR_12->flags & AV_PIX_FMT_FLAG_RGB)\ns->photometric_interpretation = TIFF_PHOTOMETRIC_RGB;",
"else\ns->photometric_interpretation = TIFF_PHOTOMETRIC_BLACK_IS_ZERO;",
"s->bpp_tab_size = VAR_12->nb_components;",
"for (VAR_5 = 0; VAR_5 < s->bpp_tab_size; VAR_5++)",
"bpp_tab[VAR_5] = s->bpp / s->bpp_tab_size;",
"break;",
"case AV_PIX_FMT_MONOBLACK:\ns->bpp = 1;",
"s->photometric_interpretation = TIFF_PHOTOMETRIC_BLACK_IS_ZERO;",
"s->bpp_tab_size = 0;",
"break;",
"case AV_PIX_FMT_MONOWHITE:\ns->bpp = 1;",
"s->photometric_interpretation = TIFF_PHOTOMETRIC_WHITE_IS_ZERO;",
"s->bpp_tab_size = 0;",
"break;",
"case AV_PIX_FMT_YUV420P:\ncase AV_PIX_FMT_YUV422P:\ncase AV_PIX_FMT_YUV444P:\ncase AV_PIX_FMT_YUV410P:\ncase AV_PIX_FMT_YUV411P:\nav_pix_fmt_get_chroma_sub_sample(VAR_0->pix_fmt, &VAR_9, &VAR_10);",
"s->photometric_interpretation = TIFF_PHOTOMETRIC_YCBCR;",
"s->bpp = 8 + (16 >> (VAR_9 + VAR_10));",
"s->subsampling[0] = 1 << VAR_9;",
"s->subsampling[1] = 1 << VAR_10;",
"s->bpp_tab_size = 3;",
"VAR_8 = 1;",
"break;",
"default:\nav_log(s->VAR_0, AV_LOG_ERROR,\n\"This colors format is not supported\\n\");",
"return -1;",
"}",
"if (s->compr == TIFF_DEFLATE ||\ns->compr == TIFF_ADOBE_DEFLATE ||\ns->compr == TIFF_LZW)\ns->rps = s->height;",
"else\ns->rps = FFMAX(8192 / (((s->width * s->bpp) >> 3) + 1), 1);",
"s->rps = ((s->rps - 1) / s->subsampling[1] + 1) * s->subsampling[1];",
"strips = (s->height - 1) / s->rps + 1;",
"VAR_11 = VAR_0->height * ((VAR_0->width * s->bpp + 7) >> 3) * 2 +\nVAR_0->height * 4 + FF_MIN_BUFFER_SIZE;",
"if (!VAR_1->data &&\n(VAR_7 = av_new_packet(VAR_1, VAR_11)) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error getting output packet.\\n\");",
"return VAR_7;",
"}",
"ptr = VAR_1->data;",
"s->buf_start = VAR_1->data;",
"s->buf = &ptr;",
"s->buf_size = VAR_1->size;",
"if (check_size(s, 8))\ngoto fail;",
"bytestream_put_le16(&ptr, 0x4949);",
"bytestream_put_le16(&ptr, 42);",
"offset = ptr;",
"bytestream_put_le32(&ptr, 0);",
"strip_sizes = av_mallocz_array(strips, sizeof(*strip_sizes));",
"strip_offsets = av_mallocz_array(strips, sizeof(*strip_offsets));",
"if (!strip_sizes || !strip_offsets) {",
"VAR_7 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"VAR_6 = (((s->width - 1) / s->subsampling[0] + 1) * s->bpp *\ns->subsampling[0] * s->subsampling[1] + 7) >> 3;",
"if (VAR_8) {",
"yuv_line = av_malloc(VAR_6);",
"if (!yuv_line) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \"Not enough memory\\n\");",
"VAR_7 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"}",
"#if CONFIG_ZLIB\nif (s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE) {",
"uint8_t *zbuf;",
"int zlen, zn;",
"int j;",
"zlen = VAR_6 * s->rps;",
"zbuf = av_malloc(zlen);",
"if (!zbuf) {",
"VAR_7 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"strip_offsets[0] = ptr - VAR_1->data;",
"zn = 0;",
"for (j = 0; j < s->rps; j++) {",
"if (VAR_8) {",
"pack_yuv(s, VAR_4, yuv_line, j);",
"memcpy(zbuf + zn, yuv_line, VAR_6);",
"j += s->subsampling[1] - 1;",
"} else",
"memcpy(zbuf + j * VAR_6,\nVAR_4->data[0] + j * VAR_4->linesize[0], VAR_6);",
"zn += VAR_6;",
"}",
"VAR_7 = encode_strip(s, zbuf, ptr, zn, s->compr);",
"av_free(zbuf);",
"if (VAR_7 < 0) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \"Encode strip failed\\n\");",
"goto fail;",
"}",
"ptr += VAR_7;",
"strip_sizes[0] = ptr - VAR_1->data - strip_offsets[0];",
"} else",
"#endif\nif (s->compr == TIFF_LZW) {",
"s->lzws = av_malloc(ff_lzw_encode_state_size);",
"if (!s->lzws) {",
"VAR_7 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"}",
"for (VAR_5 = 0; VAR_5 < s->height; VAR_5++) {",
"if (strip_sizes[VAR_5 / s->rps] == 0) {",
"if (s->compr == TIFF_LZW) {",
"ff_lzw_encode_init(s->lzws, ptr,\ns->buf_size - (*s->buf - s->buf_start),\n12, FF_LZW_TIFF, put_bits);",
"}",
"strip_offsets[VAR_5 / s->rps] = ptr - VAR_1->data;",
"}",
"if (VAR_8) {",
"pack_yuv(s, VAR_4, yuv_line, VAR_5);",
"VAR_7 = encode_strip(s, yuv_line, ptr, VAR_6, s->compr);",
"VAR_5 += s->subsampling[1] - 1;",
"} else",
"VAR_7 = encode_strip(s, VAR_4->data[0] + VAR_5 * VAR_4->linesize[0],\nptr, VAR_6, s->compr);",
"if (VAR_7 < 0) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \"Encode strip failed\\n\");",
"goto fail;",
"}",
"strip_sizes[VAR_5 / s->rps] += VAR_7;",
"ptr += VAR_7;",
"if (s->compr == TIFF_LZW &&\n(VAR_5 == s->height - 1 || VAR_5 % s->rps == s->rps - 1)) {",
"VAR_7 = ff_lzw_encode_flush(s->lzws, flush_put_bits);",
"strip_sizes[(VAR_5 / s->rps)] += VAR_7;",
"ptr += VAR_7;",
"}",
"}",
"if (s->compr == TIFF_LZW)\nav_free(s->lzws);",
"s->num_entries = 0;",
"add_entry1(s, TIFF_SUBFILE, TIFF_LONG, 0);",
"add_entry1(s, TIFF_WIDTH, TIFF_LONG, s->width);",
"add_entry1(s, TIFF_HEIGHT, TIFF_LONG, s->height);",
"if (s->bpp_tab_size)\nadd_entry(s, TIFF_BPP, TIFF_SHORT, s->bpp_tab_size, bpp_tab);",
"add_entry1(s, TIFF_COMPR, TIFF_SHORT, s->compr);",
"add_entry1(s, TIFF_PHOTOMETRIC, TIFF_SHORT, s->photometric_interpretation);",
"add_entry(s, TIFF_STRIP_OFFS, TIFF_LONG, strips, strip_offsets);",
"if (s->bpp_tab_size)\nadd_entry1(s, TIFF_SAMPLES_PER_PIXEL, TIFF_SHORT, s->bpp_tab_size);",
"add_entry1(s, TIFF_ROWSPERSTRIP, TIFF_LONG, s->rps);",
"add_entry(s, TIFF_STRIP_SIZE, TIFF_LONG, strips, strip_sizes);",
"add_entry(s, TIFF_XRES, TIFF_RATIONAL, 1, res);",
"add_entry(s, TIFF_YRES, TIFF_RATIONAL, 1, res);",
"add_entry1(s, TIFF_RES_UNIT, TIFF_SHORT, 2);",
"if (!(VAR_0->flags & CODEC_FLAG_BITEXACT))\nadd_entry(s, TIFF_SOFTWARE_NAME, TIFF_STRING,\nstrlen(LIBAVCODEC_IDENT) + 1, LIBAVCODEC_IDENT);",
"if (VAR_0->pix_fmt == AV_PIX_FMT_PAL8) {",
"uint16_t pal[256 * 3];",
"for (VAR_5 = 0; VAR_5 < 256; VAR_5++) {",
"uint32_t rgb = *(uint32_t *) (VAR_4->data[1] + VAR_5 * 4);",
"pal[VAR_5] = ((rgb >> 16) & 0xff) * 257;",
"pal[VAR_5 + 256] = ((rgb >> 8) & 0xff) * 257;",
"pal[VAR_5 + 512] = (rgb & 0xff) * 257;",
"}",
"add_entry(s, TIFF_PAL, TIFF_SHORT, 256 * 3, pal);",
"}",
"if (VAR_8) {",
"uint32_t refbw[12] = { 15, 1, 235, 1, 128, 1, 240, 1, 128, 1, 240, 1 };",
"add_entry(s, TIFF_YCBCR_SUBSAMPLING, TIFF_SHORT, 2, s->subsampling);",
"add_entry(s, TIFF_REFERENCE_BW, TIFF_RATIONAL, 6, refbw);",
"}",
"bytestream_put_le32(&offset, ptr - VAR_1->data);",
"if (check_size(s, 6 + s->num_entries * 12)) {",
"VAR_7 = AVERROR(EINVAL);",
"goto fail;",
"}",
"bytestream_put_le16(&ptr, s->num_entries);",
"bytestream_put_buffer(&ptr, s->entries, s->num_entries * 12);",
"bytestream_put_le32(&ptr, 0);",
"VAR_1->size = ptr - VAR_1->data;",
"VAR_1->flags |= AV_PKT_FLAG_KEY;",
"*VAR_3 = 1;",
"fail:\nav_free(strip_sizes);",
"av_free(strip_offsets);",
"av_free(yuv_line);",
"return VAR_7;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
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
],
[
153,
155,
157,
161
],
[
163,
167
],
[
171
],
[
175
],
[
179,
181
],
[
185,
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
205,
207
],
[
213
],
[
215
],
[
219
],
[
221
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
239,
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
261,
263
],
[
265
],
[
267
],
[
269
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301,
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327,
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349,
351,
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371,
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387,
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401,
403
],
[
407
],
[
411
],
[
413
],
[
415
],
[
419,
421
],
[
425
],
[
427
],
[
429
],
[
433,
435
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
451,
453,
455
],
[
459
],
[
461
],
[
463
],
[
465
],
[
467
],
[
469
],
[
471
],
[
473
],
[
475
],
[
477
],
[
479
],
[
483
],
[
485
],
[
487
],
[
489
],
[
493
],
[
497
],
[
499
],
[
501
],
[
503
],
[
505
],
[
507
],
[
509
],
[
513
],
[
515
],
[
517
],
[
521,
523
],
[
525
],
[
527
],
[
529
],
[
531
]
] |
1,814 | static int parse_key(DBEContext *s)
{
int key = 0;
if (s->key_present && s->input_size > 0)
key = AV_RB24(s->input) >> 24 - s->word_bits;
skip_input(s, s->key_present);
return key;
}
| true | FFmpeg | 5e715b583dab85735660b15a8d217a69164675fe | static int parse_key(DBEContext *s)
{
int key = 0;
if (s->key_present && s->input_size > 0)
key = AV_RB24(s->input) >> 24 - s->word_bits;
skip_input(s, s->key_present);
return key;
}
| {
"code": [
" int key = 0;",
" if (s->key_present && s->input_size > 0)",
" key = AV_RB24(s->input) >> 24 - s->word_bits;",
" skip_input(s, s->key_present);",
" return key;"
],
"line_no": [
5,
9,
11,
15,
17
]
} | static int FUNC_0(DBEContext *VAR_0)
{
int VAR_1 = 0;
if (VAR_0->key_present && VAR_0->input_size > 0)
VAR_1 = AV_RB24(VAR_0->input) >> 24 - VAR_0->word_bits;
skip_input(VAR_0, VAR_0->key_present);
return VAR_1;
}
| [
"static int FUNC_0(DBEContext *VAR_0)\n{",
"int VAR_1 = 0;",
"if (VAR_0->key_present && VAR_0->input_size > 0)\nVAR_1 = AV_RB24(VAR_0->input) >> 24 - VAR_0->word_bits;",
"skip_input(VAR_0, VAR_0->key_present);",
"return VAR_1;",
"}"
] | [
0,
1,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
15
],
[
17
],
[
19
]
] |
1,815 | static int vaapi_encode_issue(AVCodecContext *avctx,
VAAPIEncodePicture *pic)
{
VAAPIEncodeContext *ctx = avctx->priv_data;
VAAPIEncodeSlice *slice;
VAStatus vas;
int err, i;
char data[MAX_PARAM_BUFFER_SIZE];
size_t bit_len;
av_log(avctx, AV_LOG_DEBUG, "Issuing encode for pic %"PRId64"/%"PRId64" "
"as type %s.\n", pic->display_order, pic->encode_order,
picture_type_name[pic->type]);
if (pic->nb_refs == 0) {
av_log(avctx, AV_LOG_DEBUG, "No reference pictures.\n");
} else {
av_log(avctx, AV_LOG_DEBUG, "Refers to:");
for (i = 0; i < pic->nb_refs; i++) {
av_log(avctx, AV_LOG_DEBUG, " %"PRId64"/%"PRId64,
pic->refs[i]->display_order, pic->refs[i]->encode_order);
}
av_log(avctx, AV_LOG_DEBUG, ".\n");
}
av_assert0(pic->input_available && !pic->encode_issued);
for (i = 0; i < pic->nb_refs; i++) {
av_assert0(pic->refs[i]);
// If we are serialised then the references must have already
// completed. If not, they must have been issued but need not
// have completed yet.
if (ctx->issue_mode == ISSUE_MODE_SERIALISE_EVERYTHING)
av_assert0(pic->refs[i]->encode_complete);
else
av_assert0(pic->refs[i]->encode_issued);
}
av_log(avctx, AV_LOG_DEBUG, "Input surface is %#x.\n", pic->input_surface);
pic->recon_image = av_frame_alloc();
if (!pic->recon_image) {
err = AVERROR(ENOMEM);
goto fail;
}
err = av_hwframe_get_buffer(ctx->recon_frames_ref, pic->recon_image, 0);
if (err < 0) {
err = AVERROR(ENOMEM);
goto fail;
}
pic->recon_surface = (VASurfaceID)(uintptr_t)pic->recon_image->data[3];
av_log(avctx, AV_LOG_DEBUG, "Recon surface is %#x.\n", pic->recon_surface);
pic->output_buffer_ref = av_buffer_pool_get(ctx->output_buffer_pool);
if (!pic->output_buffer_ref) {
err = AVERROR(ENOMEM);
goto fail;
}
pic->output_buffer = (VABufferID)(uintptr_t)pic->output_buffer_ref->data;
av_log(avctx, AV_LOG_DEBUG, "Output buffer is %#x.\n",
pic->output_buffer);
if (ctx->codec->picture_params_size > 0) {
pic->codec_picture_params = av_malloc(ctx->codec->picture_params_size);
if (!pic->codec_picture_params)
goto fail;
memcpy(pic->codec_picture_params, ctx->codec_picture_params,
ctx->codec->picture_params_size);
} else {
av_assert0(!ctx->codec_picture_params);
}
pic->nb_param_buffers = 0;
if (pic->encode_order == 0) {
// Global parameter buffers are set on the first picture only.
for (i = 0; i < ctx->nb_global_params; i++) {
err = vaapi_encode_make_param_buffer(avctx, pic,
VAEncMiscParameterBufferType,
(char*)ctx->global_params[i],
ctx->global_params_size[i]);
if (err < 0)
goto fail;
}
}
if (pic->type == PICTURE_TYPE_IDR && ctx->codec->init_sequence_params) {
err = vaapi_encode_make_param_buffer(avctx, pic,
VAEncSequenceParameterBufferType,
ctx->codec_sequence_params,
ctx->codec->sequence_params_size);
if (err < 0)
goto fail;
}
if (ctx->codec->init_picture_params) {
err = ctx->codec->init_picture_params(avctx, pic);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to initialise picture "
"parameters: %d.\n", err);
goto fail;
}
err = vaapi_encode_make_param_buffer(avctx, pic,
VAEncPictureParameterBufferType,
pic->codec_picture_params,
ctx->codec->picture_params_size);
if (err < 0)
goto fail;
}
if (pic->type == PICTURE_TYPE_IDR) {
if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_SEQUENCE &&
ctx->codec->write_sequence_header) {
bit_len = 8 * sizeof(data);
err = ctx->codec->write_sequence_header(avctx, data, &bit_len);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to write per-sequence "
"header: %d.\n", err);
goto fail;
}
err = vaapi_encode_make_packed_header(avctx, pic,
ctx->codec->sequence_header_type,
data, bit_len);
if (err < 0)
goto fail;
}
}
if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_PICTURE &&
ctx->codec->write_picture_header) {
bit_len = 8 * sizeof(data);
err = ctx->codec->write_picture_header(avctx, pic, data, &bit_len);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to write per-picture "
"header: %d.\n", err);
goto fail;
}
err = vaapi_encode_make_packed_header(avctx, pic,
ctx->codec->picture_header_type,
data, bit_len);
if (err < 0)
goto fail;
}
if (ctx->codec->write_extra_buffer) {
for (i = 0;; i++) {
size_t len = sizeof(data);
int type;
err = ctx->codec->write_extra_buffer(avctx, pic, i, &type,
data, &len);
if (err == AVERROR_EOF)
break;
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to write extra "
"buffer %d: %d.\n", i, err);
goto fail;
}
err = vaapi_encode_make_param_buffer(avctx, pic, type,
data, len);
if (err < 0)
goto fail;
}
}
if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_MISC &&
ctx->codec->write_extra_header) {
for (i = 0;; i++) {
int type;
bit_len = 8 * sizeof(data);
err = ctx->codec->write_extra_header(avctx, pic, i, &type,
data, &bit_len);
if (err == AVERROR_EOF)
break;
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to write extra "
"header %d: %d.\n", i, err);
goto fail;
}
err = vaapi_encode_make_packed_header(avctx, pic, type,
data, bit_len);
if (err < 0)
goto fail;
}
}
av_assert0(pic->nb_slices <= MAX_PICTURE_SLICES);
for (i = 0; i < pic->nb_slices; i++) {
slice = av_mallocz(sizeof(*slice));
if (!slice) {
err = AVERROR(ENOMEM);
goto fail;
}
slice->index = i;
pic->slices[i] = slice;
if (ctx->codec->slice_params_size > 0) {
slice->codec_slice_params = av_mallocz(ctx->codec->slice_params_size);
if (!slice->codec_slice_params) {
err = AVERROR(ENOMEM);
goto fail;
}
}
if (ctx->codec->init_slice_params) {
err = ctx->codec->init_slice_params(avctx, pic, slice);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to initalise slice "
"parameters: %d.\n", err);
goto fail;
}
}
if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_SLICE &&
ctx->codec->write_slice_header) {
bit_len = 8 * sizeof(data);
err = ctx->codec->write_slice_header(avctx, pic, slice,
data, &bit_len);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to write per-slice "
"header: %d.\n", err);
goto fail;
}
err = vaapi_encode_make_packed_header(avctx, pic,
ctx->codec->slice_header_type,
data, bit_len);
if (err < 0)
goto fail;
}
if (ctx->codec->init_slice_params) {
err = vaapi_encode_make_param_buffer(avctx, pic,
VAEncSliceParameterBufferType,
slice->codec_slice_params,
ctx->codec->slice_params_size);
if (err < 0)
goto fail;
}
}
vas = vaBeginPicture(ctx->hwctx->display, ctx->va_context,
pic->input_surface);
if (vas != VA_STATUS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "Failed to begin picture encode issue: "
"%d (%s).\n", vas, vaErrorStr(vas));
err = AVERROR(EIO);
goto fail_with_picture;
}
vas = vaRenderPicture(ctx->hwctx->display, ctx->va_context,
pic->param_buffers, pic->nb_param_buffers);
if (vas != VA_STATUS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "Failed to upload encode parameters: "
"%d (%s).\n", vas, vaErrorStr(vas));
err = AVERROR(EIO);
goto fail_with_picture;
}
vas = vaEndPicture(ctx->hwctx->display, ctx->va_context);
if (vas != VA_STATUS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "Failed to end picture encode issue: "
"%d (%s).\n", vas, vaErrorStr(vas));
err = AVERROR(EIO);
// vaRenderPicture() has been called here, so we should not destroy
// the parameter buffers unless separate destruction is required.
if (ctx->hwctx->driver_quirks &
AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS)
goto fail;
else
goto fail_at_end;
}
if (ctx->hwctx->driver_quirks &
AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS) {
for (i = 0; i < pic->nb_param_buffers; i++) {
vas = vaDestroyBuffer(ctx->hwctx->display,
pic->param_buffers[i]);
if (vas != VA_STATUS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "Failed to destroy "
"param buffer %#x: %d (%s).\n",
pic->param_buffers[i], vas, vaErrorStr(vas));
// And ignore.
}
}
}
pic->encode_issued = 1;
if (ctx->issue_mode == ISSUE_MODE_SERIALISE_EVERYTHING)
return vaapi_encode_wait(avctx, pic);
else
return 0;
fail_with_picture:
vaEndPicture(ctx->hwctx->display, ctx->va_context);
fail:
for(i = 0; i < pic->nb_param_buffers; i++)
vaDestroyBuffer(ctx->hwctx->display, pic->param_buffers[i]);
fail_at_end:
av_freep(&pic->codec_picture_params);
av_frame_free(&pic->recon_image);
return err;
} | true | FFmpeg | 17aeee5832b9188b570c3d3de4197e4cdc54c634 | static int vaapi_encode_issue(AVCodecContext *avctx,
VAAPIEncodePicture *pic)
{
VAAPIEncodeContext *ctx = avctx->priv_data;
VAAPIEncodeSlice *slice;
VAStatus vas;
int err, i;
char data[MAX_PARAM_BUFFER_SIZE];
size_t bit_len;
av_log(avctx, AV_LOG_DEBUG, "Issuing encode for pic %"PRId64"/%"PRId64" "
"as type %s.\n", pic->display_order, pic->encode_order,
picture_type_name[pic->type]);
if (pic->nb_refs == 0) {
av_log(avctx, AV_LOG_DEBUG, "No reference pictures.\n");
} else {
av_log(avctx, AV_LOG_DEBUG, "Refers to:");
for (i = 0; i < pic->nb_refs; i++) {
av_log(avctx, AV_LOG_DEBUG, " %"PRId64"/%"PRId64,
pic->refs[i]->display_order, pic->refs[i]->encode_order);
}
av_log(avctx, AV_LOG_DEBUG, ".\n");
}
av_assert0(pic->input_available && !pic->encode_issued);
for (i = 0; i < pic->nb_refs; i++) {
av_assert0(pic->refs[i]);
if (ctx->issue_mode == ISSUE_MODE_SERIALISE_EVERYTHING)
av_assert0(pic->refs[i]->encode_complete);
else
av_assert0(pic->refs[i]->encode_issued);
}
av_log(avctx, AV_LOG_DEBUG, "Input surface is %#x.\n", pic->input_surface);
pic->recon_image = av_frame_alloc();
if (!pic->recon_image) {
err = AVERROR(ENOMEM);
goto fail;
}
err = av_hwframe_get_buffer(ctx->recon_frames_ref, pic->recon_image, 0);
if (err < 0) {
err = AVERROR(ENOMEM);
goto fail;
}
pic->recon_surface = (VASurfaceID)(uintptr_t)pic->recon_image->data[3];
av_log(avctx, AV_LOG_DEBUG, "Recon surface is %#x.\n", pic->recon_surface);
pic->output_buffer_ref = av_buffer_pool_get(ctx->output_buffer_pool);
if (!pic->output_buffer_ref) {
err = AVERROR(ENOMEM);
goto fail;
}
pic->output_buffer = (VABufferID)(uintptr_t)pic->output_buffer_ref->data;
av_log(avctx, AV_LOG_DEBUG, "Output buffer is %#x.\n",
pic->output_buffer);
if (ctx->codec->picture_params_size > 0) {
pic->codec_picture_params = av_malloc(ctx->codec->picture_params_size);
if (!pic->codec_picture_params)
goto fail;
memcpy(pic->codec_picture_params, ctx->codec_picture_params,
ctx->codec->picture_params_size);
} else {
av_assert0(!ctx->codec_picture_params);
}
pic->nb_param_buffers = 0;
if (pic->encode_order == 0) {
for (i = 0; i < ctx->nb_global_params; i++) {
err = vaapi_encode_make_param_buffer(avctx, pic,
VAEncMiscParameterBufferType,
(char*)ctx->global_params[i],
ctx->global_params_size[i]);
if (err < 0)
goto fail;
}
}
if (pic->type == PICTURE_TYPE_IDR && ctx->codec->init_sequence_params) {
err = vaapi_encode_make_param_buffer(avctx, pic,
VAEncSequenceParameterBufferType,
ctx->codec_sequence_params,
ctx->codec->sequence_params_size);
if (err < 0)
goto fail;
}
if (ctx->codec->init_picture_params) {
err = ctx->codec->init_picture_params(avctx, pic);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to initialise picture "
"parameters: %d.\n", err);
goto fail;
}
err = vaapi_encode_make_param_buffer(avctx, pic,
VAEncPictureParameterBufferType,
pic->codec_picture_params,
ctx->codec->picture_params_size);
if (err < 0)
goto fail;
}
if (pic->type == PICTURE_TYPE_IDR) {
if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_SEQUENCE &&
ctx->codec->write_sequence_header) {
bit_len = 8 * sizeof(data);
err = ctx->codec->write_sequence_header(avctx, data, &bit_len);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to write per-sequence "
"header: %d.\n", err);
goto fail;
}
err = vaapi_encode_make_packed_header(avctx, pic,
ctx->codec->sequence_header_type,
data, bit_len);
if (err < 0)
goto fail;
}
}
if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_PICTURE &&
ctx->codec->write_picture_header) {
bit_len = 8 * sizeof(data);
err = ctx->codec->write_picture_header(avctx, pic, data, &bit_len);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to write per-picture "
"header: %d.\n", err);
goto fail;
}
err = vaapi_encode_make_packed_header(avctx, pic,
ctx->codec->picture_header_type,
data, bit_len);
if (err < 0)
goto fail;
}
if (ctx->codec->write_extra_buffer) {
for (i = 0;; i++) {
size_t len = sizeof(data);
int type;
err = ctx->codec->write_extra_buffer(avctx, pic, i, &type,
data, &len);
if (err == AVERROR_EOF)
break;
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to write extra "
"buffer %d: %d.\n", i, err);
goto fail;
}
err = vaapi_encode_make_param_buffer(avctx, pic, type,
data, len);
if (err < 0)
goto fail;
}
}
if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_MISC &&
ctx->codec->write_extra_header) {
for (i = 0;; i++) {
int type;
bit_len = 8 * sizeof(data);
err = ctx->codec->write_extra_header(avctx, pic, i, &type,
data, &bit_len);
if (err == AVERROR_EOF)
break;
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to write extra "
"header %d: %d.\n", i, err);
goto fail;
}
err = vaapi_encode_make_packed_header(avctx, pic, type,
data, bit_len);
if (err < 0)
goto fail;
}
}
av_assert0(pic->nb_slices <= MAX_PICTURE_SLICES);
for (i = 0; i < pic->nb_slices; i++) {
slice = av_mallocz(sizeof(*slice));
if (!slice) {
err = AVERROR(ENOMEM);
goto fail;
}
slice->index = i;
pic->slices[i] = slice;
if (ctx->codec->slice_params_size > 0) {
slice->codec_slice_params = av_mallocz(ctx->codec->slice_params_size);
if (!slice->codec_slice_params) {
err = AVERROR(ENOMEM);
goto fail;
}
}
if (ctx->codec->init_slice_params) {
err = ctx->codec->init_slice_params(avctx, pic, slice);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to initalise slice "
"parameters: %d.\n", err);
goto fail;
}
}
if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_SLICE &&
ctx->codec->write_slice_header) {
bit_len = 8 * sizeof(data);
err = ctx->codec->write_slice_header(avctx, pic, slice,
data, &bit_len);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to write per-slice "
"header: %d.\n", err);
goto fail;
}
err = vaapi_encode_make_packed_header(avctx, pic,
ctx->codec->slice_header_type,
data, bit_len);
if (err < 0)
goto fail;
}
if (ctx->codec->init_slice_params) {
err = vaapi_encode_make_param_buffer(avctx, pic,
VAEncSliceParameterBufferType,
slice->codec_slice_params,
ctx->codec->slice_params_size);
if (err < 0)
goto fail;
}
}
vas = vaBeginPicture(ctx->hwctx->display, ctx->va_context,
pic->input_surface);
if (vas != VA_STATUS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "Failed to begin picture encode issue: "
"%d (%s).\n", vas, vaErrorStr(vas));
err = AVERROR(EIO);
goto fail_with_picture;
}
vas = vaRenderPicture(ctx->hwctx->display, ctx->va_context,
pic->param_buffers, pic->nb_param_buffers);
if (vas != VA_STATUS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "Failed to upload encode parameters: "
"%d (%s).\n", vas, vaErrorStr(vas));
err = AVERROR(EIO);
goto fail_with_picture;
}
vas = vaEndPicture(ctx->hwctx->display, ctx->va_context);
if (vas != VA_STATUS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "Failed to end picture encode issue: "
"%d (%s).\n", vas, vaErrorStr(vas));
err = AVERROR(EIO);
if (ctx->hwctx->driver_quirks &
AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS)
goto fail;
else
goto fail_at_end;
}
if (ctx->hwctx->driver_quirks &
AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS) {
for (i = 0; i < pic->nb_param_buffers; i++) {
vas = vaDestroyBuffer(ctx->hwctx->display,
pic->param_buffers[i]);
if (vas != VA_STATUS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "Failed to destroy "
"param buffer %#x: %d (%s).\n",
pic->param_buffers[i], vas, vaErrorStr(vas));
}
}
}
pic->encode_issued = 1;
if (ctx->issue_mode == ISSUE_MODE_SERIALISE_EVERYTHING)
return vaapi_encode_wait(avctx, pic);
else
return 0;
fail_with_picture:
vaEndPicture(ctx->hwctx->display, ctx->va_context);
fail:
for(i = 0; i < pic->nb_param_buffers; i++)
vaDestroyBuffer(ctx->hwctx->display, pic->param_buffers[i]);
fail_at_end:
av_freep(&pic->codec_picture_params);
av_frame_free(&pic->recon_image);
return err;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
VAAPIEncodePicture *VAR_1)
{
VAAPIEncodeContext *ctx = VAR_0->priv_data;
VAAPIEncodeSlice *slice;
VAStatus vas;
int VAR_2, VAR_3;
char VAR_4[MAX_PARAM_BUFFER_SIZE];
size_t bit_len;
av_log(VAR_0, AV_LOG_DEBUG, "Issuing encode for VAR_1 %"PRId64"/%"PRId64" "
"as VAR_6 %s.\n", VAR_1->display_order, VAR_1->encode_order,
picture_type_name[VAR_1->VAR_6]);
if (VAR_1->nb_refs == 0) {
av_log(VAR_0, AV_LOG_DEBUG, "No reference pictures.\n");
} else {
av_log(VAR_0, AV_LOG_DEBUG, "Refers to:");
for (VAR_3 = 0; VAR_3 < VAR_1->nb_refs; VAR_3++) {
av_log(VAR_0, AV_LOG_DEBUG, " %"PRId64"/%"PRId64,
VAR_1->refs[VAR_3]->display_order, VAR_1->refs[VAR_3]->encode_order);
}
av_log(VAR_0, AV_LOG_DEBUG, ".\n");
}
av_assert0(VAR_1->input_available && !VAR_1->encode_issued);
for (VAR_3 = 0; VAR_3 < VAR_1->nb_refs; VAR_3++) {
av_assert0(VAR_1->refs[VAR_3]);
if (ctx->issue_mode == ISSUE_MODE_SERIALISE_EVERYTHING)
av_assert0(VAR_1->refs[VAR_3]->encode_complete);
else
av_assert0(VAR_1->refs[VAR_3]->encode_issued);
}
av_log(VAR_0, AV_LOG_DEBUG, "Input surface is %#x.\n", VAR_1->input_surface);
VAR_1->recon_image = av_frame_alloc();
if (!VAR_1->recon_image) {
VAR_2 = AVERROR(ENOMEM);
goto fail;
}
VAR_2 = av_hwframe_get_buffer(ctx->recon_frames_ref, VAR_1->recon_image, 0);
if (VAR_2 < 0) {
VAR_2 = AVERROR(ENOMEM);
goto fail;
}
VAR_1->recon_surface = (VASurfaceID)(uintptr_t)VAR_1->recon_image->VAR_4[3];
av_log(VAR_0, AV_LOG_DEBUG, "Recon surface is %#x.\n", VAR_1->recon_surface);
VAR_1->output_buffer_ref = av_buffer_pool_get(ctx->output_buffer_pool);
if (!VAR_1->output_buffer_ref) {
VAR_2 = AVERROR(ENOMEM);
goto fail;
}
VAR_1->output_buffer = (VABufferID)(uintptr_t)VAR_1->output_buffer_ref->VAR_4;
av_log(VAR_0, AV_LOG_DEBUG, "Output buffer is %#x.\n",
VAR_1->output_buffer);
if (ctx->codec->picture_params_size > 0) {
VAR_1->codec_picture_params = av_malloc(ctx->codec->picture_params_size);
if (!VAR_1->codec_picture_params)
goto fail;
memcpy(VAR_1->codec_picture_params, ctx->codec_picture_params,
ctx->codec->picture_params_size);
} else {
av_assert0(!ctx->codec_picture_params);
}
VAR_1->nb_param_buffers = 0;
if (VAR_1->encode_order == 0) {
for (VAR_3 = 0; VAR_3 < ctx->nb_global_params; VAR_3++) {
VAR_2 = vaapi_encode_make_param_buffer(VAR_0, VAR_1,
VAEncMiscParameterBufferType,
(char*)ctx->global_params[VAR_3],
ctx->global_params_size[VAR_3]);
if (VAR_2 < 0)
goto fail;
}
}
if (VAR_1->VAR_6 == PICTURE_TYPE_IDR && ctx->codec->init_sequence_params) {
VAR_2 = vaapi_encode_make_param_buffer(VAR_0, VAR_1,
VAEncSequenceParameterBufferType,
ctx->codec_sequence_params,
ctx->codec->sequence_params_size);
if (VAR_2 < 0)
goto fail;
}
if (ctx->codec->init_picture_params) {
VAR_2 = ctx->codec->init_picture_params(VAR_0, VAR_1);
if (VAR_2 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to initialise picture "
"parameters: %d.\n", VAR_2);
goto fail;
}
VAR_2 = vaapi_encode_make_param_buffer(VAR_0, VAR_1,
VAEncPictureParameterBufferType,
VAR_1->codec_picture_params,
ctx->codec->picture_params_size);
if (VAR_2 < 0)
goto fail;
}
if (VAR_1->VAR_6 == PICTURE_TYPE_IDR) {
if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_SEQUENCE &&
ctx->codec->write_sequence_header) {
bit_len = 8 * sizeof(VAR_4);
VAR_2 = ctx->codec->write_sequence_header(VAR_0, VAR_4, &bit_len);
if (VAR_2 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to write per-sequence "
"header: %d.\n", VAR_2);
goto fail;
}
VAR_2 = vaapi_encode_make_packed_header(VAR_0, VAR_1,
ctx->codec->sequence_header_type,
VAR_4, bit_len);
if (VAR_2 < 0)
goto fail;
}
}
if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_PICTURE &&
ctx->codec->write_picture_header) {
bit_len = 8 * sizeof(VAR_4);
VAR_2 = ctx->codec->write_picture_header(VAR_0, VAR_1, VAR_4, &bit_len);
if (VAR_2 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to write per-picture "
"header: %d.\n", VAR_2);
goto fail;
}
VAR_2 = vaapi_encode_make_packed_header(VAR_0, VAR_1,
ctx->codec->picture_header_type,
VAR_4, bit_len);
if (VAR_2 < 0)
goto fail;
}
if (ctx->codec->write_extra_buffer) {
for (VAR_3 = 0;; VAR_3++) {
size_t len = sizeof(VAR_4);
int VAR_6;
VAR_2 = ctx->codec->write_extra_buffer(VAR_0, VAR_1, VAR_3, &VAR_6,
VAR_4, &len);
if (VAR_2 == AVERROR_EOF)
break;
if (VAR_2 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to write extra "
"buffer %d: %d.\n", VAR_3, VAR_2);
goto fail;
}
VAR_2 = vaapi_encode_make_param_buffer(VAR_0, VAR_1, VAR_6,
VAR_4, len);
if (VAR_2 < 0)
goto fail;
}
}
if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_MISC &&
ctx->codec->write_extra_header) {
for (VAR_3 = 0;; VAR_3++) {
int VAR_6;
bit_len = 8 * sizeof(VAR_4);
VAR_2 = ctx->codec->write_extra_header(VAR_0, VAR_1, VAR_3, &VAR_6,
VAR_4, &bit_len);
if (VAR_2 == AVERROR_EOF)
break;
if (VAR_2 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to write extra "
"header %d: %d.\n", VAR_3, VAR_2);
goto fail;
}
VAR_2 = vaapi_encode_make_packed_header(VAR_0, VAR_1, VAR_6,
VAR_4, bit_len);
if (VAR_2 < 0)
goto fail;
}
}
av_assert0(VAR_1->nb_slices <= MAX_PICTURE_SLICES);
for (VAR_3 = 0; VAR_3 < VAR_1->nb_slices; VAR_3++) {
slice = av_mallocz(sizeof(*slice));
if (!slice) {
VAR_2 = AVERROR(ENOMEM);
goto fail;
}
slice->index = VAR_3;
VAR_1->slices[VAR_3] = slice;
if (ctx->codec->slice_params_size > 0) {
slice->codec_slice_params = av_mallocz(ctx->codec->slice_params_size);
if (!slice->codec_slice_params) {
VAR_2 = AVERROR(ENOMEM);
goto fail;
}
}
if (ctx->codec->init_slice_params) {
VAR_2 = ctx->codec->init_slice_params(VAR_0, VAR_1, slice);
if (VAR_2 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to initalise slice "
"parameters: %d.\n", VAR_2);
goto fail;
}
}
if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_SLICE &&
ctx->codec->write_slice_header) {
bit_len = 8 * sizeof(VAR_4);
VAR_2 = ctx->codec->write_slice_header(VAR_0, VAR_1, slice,
VAR_4, &bit_len);
if (VAR_2 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to write per-slice "
"header: %d.\n", VAR_2);
goto fail;
}
VAR_2 = vaapi_encode_make_packed_header(VAR_0, VAR_1,
ctx->codec->slice_header_type,
VAR_4, bit_len);
if (VAR_2 < 0)
goto fail;
}
if (ctx->codec->init_slice_params) {
VAR_2 = vaapi_encode_make_param_buffer(VAR_0, VAR_1,
VAEncSliceParameterBufferType,
slice->codec_slice_params,
ctx->codec->slice_params_size);
if (VAR_2 < 0)
goto fail;
}
}
vas = vaBeginPicture(ctx->hwctx->display, ctx->va_context,
VAR_1->input_surface);
if (vas != VA_STATUS_SUCCESS) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to begin picture encode issue: "
"%d (%s).\n", vas, vaErrorStr(vas));
VAR_2 = AVERROR(EIO);
goto fail_with_picture;
}
vas = vaRenderPicture(ctx->hwctx->display, ctx->va_context,
VAR_1->param_buffers, VAR_1->nb_param_buffers);
if (vas != VA_STATUS_SUCCESS) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to upload encode parameters: "
"%d (%s).\n", vas, vaErrorStr(vas));
VAR_2 = AVERROR(EIO);
goto fail_with_picture;
}
vas = vaEndPicture(ctx->hwctx->display, ctx->va_context);
if (vas != VA_STATUS_SUCCESS) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to end picture encode issue: "
"%d (%s).\n", vas, vaErrorStr(vas));
VAR_2 = AVERROR(EIO);
if (ctx->hwctx->driver_quirks &
AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS)
goto fail;
else
goto fail_at_end;
}
if (ctx->hwctx->driver_quirks &
AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS) {
for (VAR_3 = 0; VAR_3 < VAR_1->nb_param_buffers; VAR_3++) {
vas = vaDestroyBuffer(ctx->hwctx->display,
VAR_1->param_buffers[VAR_3]);
if (vas != VA_STATUS_SUCCESS) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to destroy "
"param buffer %#x: %d (%s).\n",
VAR_1->param_buffers[VAR_3], vas, vaErrorStr(vas));
}
}
}
VAR_1->encode_issued = 1;
if (ctx->issue_mode == ISSUE_MODE_SERIALISE_EVERYTHING)
return vaapi_encode_wait(VAR_0, VAR_1);
else
return 0;
fail_with_picture:
vaEndPicture(ctx->hwctx->display, ctx->va_context);
fail:
for(VAR_3 = 0; VAR_3 < VAR_1->nb_param_buffers; VAR_3++)
vaDestroyBuffer(ctx->hwctx->display, VAR_1->param_buffers[VAR_3]);
fail_at_end:
av_freep(&VAR_1->codec_picture_params);
av_frame_free(&VAR_1->recon_image);
return VAR_2;
} | [
"static int FUNC_0(AVCodecContext *VAR_0,\nVAAPIEncodePicture *VAR_1)\n{",
"VAAPIEncodeContext *ctx = VAR_0->priv_data;",
"VAAPIEncodeSlice *slice;",
"VAStatus vas;",
"int VAR_2, VAR_3;",
"char VAR_4[MAX_PARAM_BUFFER_SIZE];",
"size_t bit_len;",
"av_log(VAR_0, AV_LOG_DEBUG, \"Issuing encode for VAR_1 %\"PRId64\"/%\"PRId64\" \"\n\"as VAR_6 %s.\\n\", VAR_1->display_order, VAR_1->encode_order,\npicture_type_name[VAR_1->VAR_6]);",
"if (VAR_1->nb_refs == 0) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"No reference pictures.\\n\");",
"} else {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Refers to:\");",
"for (VAR_3 = 0; VAR_3 < VAR_1->nb_refs; VAR_3++) {",
"av_log(VAR_0, AV_LOG_DEBUG, \" %\"PRId64\"/%\"PRId64,\nVAR_1->refs[VAR_3]->display_order, VAR_1->refs[VAR_3]->encode_order);",
"}",
"av_log(VAR_0, AV_LOG_DEBUG, \".\\n\");",
"}",
"av_assert0(VAR_1->input_available && !VAR_1->encode_issued);",
"for (VAR_3 = 0; VAR_3 < VAR_1->nb_refs; VAR_3++) {",
"av_assert0(VAR_1->refs[VAR_3]);",
"if (ctx->issue_mode == ISSUE_MODE_SERIALISE_EVERYTHING)\nav_assert0(VAR_1->refs[VAR_3]->encode_complete);",
"else\nav_assert0(VAR_1->refs[VAR_3]->encode_issued);",
"}",
"av_log(VAR_0, AV_LOG_DEBUG, \"Input surface is %#x.\\n\", VAR_1->input_surface);",
"VAR_1->recon_image = av_frame_alloc();",
"if (!VAR_1->recon_image) {",
"VAR_2 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"VAR_2 = av_hwframe_get_buffer(ctx->recon_frames_ref, VAR_1->recon_image, 0);",
"if (VAR_2 < 0) {",
"VAR_2 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"VAR_1->recon_surface = (VASurfaceID)(uintptr_t)VAR_1->recon_image->VAR_4[3];",
"av_log(VAR_0, AV_LOG_DEBUG, \"Recon surface is %#x.\\n\", VAR_1->recon_surface);",
"VAR_1->output_buffer_ref = av_buffer_pool_get(ctx->output_buffer_pool);",
"if (!VAR_1->output_buffer_ref) {",
"VAR_2 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"VAR_1->output_buffer = (VABufferID)(uintptr_t)VAR_1->output_buffer_ref->VAR_4;",
"av_log(VAR_0, AV_LOG_DEBUG, \"Output buffer is %#x.\\n\",\nVAR_1->output_buffer);",
"if (ctx->codec->picture_params_size > 0) {",
"VAR_1->codec_picture_params = av_malloc(ctx->codec->picture_params_size);",
"if (!VAR_1->codec_picture_params)\ngoto fail;",
"memcpy(VAR_1->codec_picture_params, ctx->codec_picture_params,\nctx->codec->picture_params_size);",
"} else {",
"av_assert0(!ctx->codec_picture_params);",
"}",
"VAR_1->nb_param_buffers = 0;",
"if (VAR_1->encode_order == 0) {",
"for (VAR_3 = 0; VAR_3 < ctx->nb_global_params; VAR_3++) {",
"VAR_2 = vaapi_encode_make_param_buffer(VAR_0, VAR_1,\nVAEncMiscParameterBufferType,\n(char*)ctx->global_params[VAR_3],\nctx->global_params_size[VAR_3]);",
"if (VAR_2 < 0)\ngoto fail;",
"}",
"}",
"if (VAR_1->VAR_6 == PICTURE_TYPE_IDR && ctx->codec->init_sequence_params) {",
"VAR_2 = vaapi_encode_make_param_buffer(VAR_0, VAR_1,\nVAEncSequenceParameterBufferType,\nctx->codec_sequence_params,\nctx->codec->sequence_params_size);",
"if (VAR_2 < 0)\ngoto fail;",
"}",
"if (ctx->codec->init_picture_params) {",
"VAR_2 = ctx->codec->init_picture_params(VAR_0, VAR_1);",
"if (VAR_2 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to initialise picture \"\n\"parameters: %d.\\n\", VAR_2);",
"goto fail;",
"}",
"VAR_2 = vaapi_encode_make_param_buffer(VAR_0, VAR_1,\nVAEncPictureParameterBufferType,\nVAR_1->codec_picture_params,\nctx->codec->picture_params_size);",
"if (VAR_2 < 0)\ngoto fail;",
"}",
"if (VAR_1->VAR_6 == PICTURE_TYPE_IDR) {",
"if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_SEQUENCE &&\nctx->codec->write_sequence_header) {",
"bit_len = 8 * sizeof(VAR_4);",
"VAR_2 = ctx->codec->write_sequence_header(VAR_0, VAR_4, &bit_len);",
"if (VAR_2 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to write per-sequence \"\n\"header: %d.\\n\", VAR_2);",
"goto fail;",
"}",
"VAR_2 = vaapi_encode_make_packed_header(VAR_0, VAR_1,\nctx->codec->sequence_header_type,\nVAR_4, bit_len);",
"if (VAR_2 < 0)\ngoto fail;",
"}",
"}",
"if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_PICTURE &&\nctx->codec->write_picture_header) {",
"bit_len = 8 * sizeof(VAR_4);",
"VAR_2 = ctx->codec->write_picture_header(VAR_0, VAR_1, VAR_4, &bit_len);",
"if (VAR_2 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to write per-picture \"\n\"header: %d.\\n\", VAR_2);",
"goto fail;",
"}",
"VAR_2 = vaapi_encode_make_packed_header(VAR_0, VAR_1,\nctx->codec->picture_header_type,\nVAR_4, bit_len);",
"if (VAR_2 < 0)\ngoto fail;",
"}",
"if (ctx->codec->write_extra_buffer) {",
"for (VAR_3 = 0;; VAR_3++) {",
"size_t len = sizeof(VAR_4);",
"int VAR_6;",
"VAR_2 = ctx->codec->write_extra_buffer(VAR_0, VAR_1, VAR_3, &VAR_6,\nVAR_4, &len);",
"if (VAR_2 == AVERROR_EOF)\nbreak;",
"if (VAR_2 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to write extra \"\n\"buffer %d: %d.\\n\", VAR_3, VAR_2);",
"goto fail;",
"}",
"VAR_2 = vaapi_encode_make_param_buffer(VAR_0, VAR_1, VAR_6,\nVAR_4, len);",
"if (VAR_2 < 0)\ngoto fail;",
"}",
"}",
"if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_MISC &&\nctx->codec->write_extra_header) {",
"for (VAR_3 = 0;; VAR_3++) {",
"int VAR_6;",
"bit_len = 8 * sizeof(VAR_4);",
"VAR_2 = ctx->codec->write_extra_header(VAR_0, VAR_1, VAR_3, &VAR_6,\nVAR_4, &bit_len);",
"if (VAR_2 == AVERROR_EOF)\nbreak;",
"if (VAR_2 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to write extra \"\n\"header %d: %d.\\n\", VAR_3, VAR_2);",
"goto fail;",
"}",
"VAR_2 = vaapi_encode_make_packed_header(VAR_0, VAR_1, VAR_6,\nVAR_4, bit_len);",
"if (VAR_2 < 0)\ngoto fail;",
"}",
"}",
"av_assert0(VAR_1->nb_slices <= MAX_PICTURE_SLICES);",
"for (VAR_3 = 0; VAR_3 < VAR_1->nb_slices; VAR_3++) {",
"slice = av_mallocz(sizeof(*slice));",
"if (!slice) {",
"VAR_2 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"slice->index = VAR_3;",
"VAR_1->slices[VAR_3] = slice;",
"if (ctx->codec->slice_params_size > 0) {",
"slice->codec_slice_params = av_mallocz(ctx->codec->slice_params_size);",
"if (!slice->codec_slice_params) {",
"VAR_2 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"}",
"if (ctx->codec->init_slice_params) {",
"VAR_2 = ctx->codec->init_slice_params(VAR_0, VAR_1, slice);",
"if (VAR_2 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to initalise slice \"\n\"parameters: %d.\\n\", VAR_2);",
"goto fail;",
"}",
"}",
"if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_SLICE &&\nctx->codec->write_slice_header) {",
"bit_len = 8 * sizeof(VAR_4);",
"VAR_2 = ctx->codec->write_slice_header(VAR_0, VAR_1, slice,\nVAR_4, &bit_len);",
"if (VAR_2 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to write per-slice \"\n\"header: %d.\\n\", VAR_2);",
"goto fail;",
"}",
"VAR_2 = vaapi_encode_make_packed_header(VAR_0, VAR_1,\nctx->codec->slice_header_type,\nVAR_4, bit_len);",
"if (VAR_2 < 0)\ngoto fail;",
"}",
"if (ctx->codec->init_slice_params) {",
"VAR_2 = vaapi_encode_make_param_buffer(VAR_0, VAR_1,\nVAEncSliceParameterBufferType,\nslice->codec_slice_params,\nctx->codec->slice_params_size);",
"if (VAR_2 < 0)\ngoto fail;",
"}",
"}",
"vas = vaBeginPicture(ctx->hwctx->display, ctx->va_context,\nVAR_1->input_surface);",
"if (vas != VA_STATUS_SUCCESS) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to begin picture encode issue: \"\n\"%d (%s).\\n\", vas, vaErrorStr(vas));",
"VAR_2 = AVERROR(EIO);",
"goto fail_with_picture;",
"}",
"vas = vaRenderPicture(ctx->hwctx->display, ctx->va_context,\nVAR_1->param_buffers, VAR_1->nb_param_buffers);",
"if (vas != VA_STATUS_SUCCESS) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to upload encode parameters: \"\n\"%d (%s).\\n\", vas, vaErrorStr(vas));",
"VAR_2 = AVERROR(EIO);",
"goto fail_with_picture;",
"}",
"vas = vaEndPicture(ctx->hwctx->display, ctx->va_context);",
"if (vas != VA_STATUS_SUCCESS) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to end picture encode issue: \"\n\"%d (%s).\\n\", vas, vaErrorStr(vas));",
"VAR_2 = AVERROR(EIO);",
"if (ctx->hwctx->driver_quirks &\nAV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS)\ngoto fail;",
"else\ngoto fail_at_end;",
"}",
"if (ctx->hwctx->driver_quirks &\nAV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS) {",
"for (VAR_3 = 0; VAR_3 < VAR_1->nb_param_buffers; VAR_3++) {",
"vas = vaDestroyBuffer(ctx->hwctx->display,\nVAR_1->param_buffers[VAR_3]);",
"if (vas != VA_STATUS_SUCCESS) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to destroy \"\n\"param buffer %#x: %d (%s).\\n\",\nVAR_1->param_buffers[VAR_3], vas, vaErrorStr(vas));",
"}",
"}",
"}",
"VAR_1->encode_issued = 1;",
"if (ctx->issue_mode == ISSUE_MODE_SERIALISE_EVERYTHING)\nreturn vaapi_encode_wait(VAR_0, VAR_1);",
"else\nreturn 0;",
"fail_with_picture:\nvaEndPicture(ctx->hwctx->display, ctx->va_context);",
"fail:\nfor(VAR_3 = 0; VAR_3 < VAR_1->nb_param_buffers; VAR_3++)",
"vaDestroyBuffer(ctx->hwctx->display, VAR_1->param_buffers[VAR_3]);",
"fail_at_end:\nav_freep(&VAR_1->codec_picture_params);",
"av_frame_free(&VAR_1->recon_image);",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21,
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
61,
63
],
[
65,
67
],
[
69
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117,
119
],
[
123
],
[
125
],
[
127,
129
],
[
131,
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
147
],
[
153
],
[
155,
157,
159,
161
],
[
163,
165
],
[
167
],
[
169
],
[
173
],
[
175,
177,
179,
181
],
[
183,
185
],
[
187
],
[
191
],
[
193
],
[
195
],
[
197,
199
],
[
201
],
[
203
],
[
205,
207,
209,
211
],
[
213,
215
],
[
217
],
[
221
],
[
223,
225
],
[
227
],
[
229
],
[
231
],
[
233,
235
],
[
237
],
[
239
],
[
241,
243,
245
],
[
247,
249
],
[
251
],
[
253
],
[
257,
259
],
[
261
],
[
263
],
[
265
],
[
267,
269
],
[
271
],
[
273
],
[
275,
277,
279
],
[
281,
283
],
[
285
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297,
299
],
[
301,
303
],
[
305
],
[
307,
309
],
[
311
],
[
313
],
[
317,
319
],
[
321,
323
],
[
325
],
[
327
],
[
331,
333
],
[
335
],
[
337
],
[
339
],
[
341,
343
],
[
345,
347
],
[
349
],
[
351,
353
],
[
355
],
[
357
],
[
361,
363
],
[
365,
367
],
[
369
],
[
371
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
411
],
[
413
],
[
415
],
[
417,
419
],
[
421
],
[
423
],
[
425
],
[
429,
431
],
[
433
],
[
435,
437
],
[
439
],
[
441,
443
],
[
445
],
[
447
],
[
449,
451,
453
],
[
455,
457
],
[
459
],
[
463
],
[
465,
467,
469,
471
],
[
473,
475
],
[
477
],
[
479
],
[
483,
485
],
[
487
],
[
489,
491
],
[
493
],
[
495
],
[
497
],
[
501,
503
],
[
505
],
[
507,
509
],
[
511
],
[
513
],
[
515
],
[
519
],
[
521
],
[
523,
525
],
[
527
],
[
533,
535,
537
],
[
539,
541
],
[
543
],
[
547,
549
],
[
551
],
[
553,
555
],
[
557
],
[
559,
561,
563
],
[
567
],
[
569
],
[
571
],
[
575
],
[
579,
581
],
[
583,
585
],
[
589,
591
],
[
593,
595
],
[
597
],
[
599,
601
],
[
603
],
[
607
],
[
609
]
] |
1,816 | static void pc_q35_machine_options(MachineClass *m)
{
m->family = "pc_q35";
m->desc = "Standard PC (Q35 + ICH9, 2009)";
m->hot_add_cpu = pc_hot_add_cpu;
m->units_per_default_bus = 1;
m->default_machine_opts = "firmware=bios-256k.bin";
m->default_display = "std";
m->no_floppy = 1;
} | true | qemu | bf8d492405feaee2c1685b3b9d5e03228ed3e47f | static void pc_q35_machine_options(MachineClass *m)
{
m->family = "pc_q35";
m->desc = "Standard PC (Q35 + ICH9, 2009)";
m->hot_add_cpu = pc_hot_add_cpu;
m->units_per_default_bus = 1;
m->default_machine_opts = "firmware=bios-256k.bin";
m->default_display = "std";
m->no_floppy = 1;
} | {
"code": [],
"line_no": []
} | static void FUNC_0(MachineClass *VAR_0)
{
VAR_0->family = "pc_q35";
VAR_0->desc = "Standard PC (Q35 + ICH9, 2009)";
VAR_0->hot_add_cpu = pc_hot_add_cpu;
VAR_0->units_per_default_bus = 1;
VAR_0->default_machine_opts = "firmware=bios-256k.bin";
VAR_0->default_display = "std";
VAR_0->no_floppy = 1;
} | [
"static void FUNC_0(MachineClass *VAR_0)\n{",
"VAR_0->family = \"pc_q35\";",
"VAR_0->desc = \"Standard PC (Q35 + ICH9, 2009)\";",
"VAR_0->hot_add_cpu = pc_hot_add_cpu;",
"VAR_0->units_per_default_bus = 1;",
"VAR_0->default_machine_opts = \"firmware=bios-256k.bin\";",
"VAR_0->default_display = \"std\";",
"VAR_0->no_floppy = 1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
20
]
] |
1,818 | static int check_protocol_support(bool *has_ipv4, bool *has_ipv6)
{
struct sockaddr_in sin = {
.sin_family = AF_INET,
.sin_addr = { .s_addr = htonl(INADDR_LOOPBACK) },
};
struct sockaddr_in6 sin6 = {
.sin6_family = AF_INET6,
.sin6_addr = IN6ADDR_LOOPBACK_INIT,
};
if (check_bind((struct sockaddr *)&sin, sizeof(sin), has_ipv4) < 0) {
return -1;
}
if (check_bind((struct sockaddr *)&sin6, sizeof(sin6), has_ipv6) < 0) {
return -1;
}
return 0;
}
| true | qemu | cfd47a71df51047833d182e9e97244e7816b57da | static int check_protocol_support(bool *has_ipv4, bool *has_ipv6)
{
struct sockaddr_in sin = {
.sin_family = AF_INET,
.sin_addr = { .s_addr = htonl(INADDR_LOOPBACK) },
};
struct sockaddr_in6 sin6 = {
.sin6_family = AF_INET6,
.sin6_addr = IN6ADDR_LOOPBACK_INIT,
};
if (check_bind((struct sockaddr *)&sin, sizeof(sin), has_ipv4) < 0) {
return -1;
}
if (check_bind((struct sockaddr *)&sin6, sizeof(sin6), has_ipv6) < 0) {
return -1;
}
return 0;
}
| {
"code": [
" return -1;",
" return -1;",
" return 0;",
" struct sockaddr_in sin = {",
" .sin_family = AF_INET,",
" .sin_addr = { .s_addr = htonl(INADDR_LOOPBACK) },",
" };",
" struct sockaddr_in6 sin6 = {",
" .sin6_family = AF_INET6,",
" .sin6_addr = IN6ADDR_LOOPBACK_INIT,",
" };",
" if (check_bind((struct sockaddr *)&sin, sizeof(sin), has_ipv4) < 0) {",
" if (check_bind((struct sockaddr *)&sin6, sizeof(sin6), has_ipv6) < 0) {"
],
"line_no": [
25,
25,
37,
5,
7,
9,
11,
13,
15,
17,
11,
23,
29
]
} | static int FUNC_0(bool *VAR_0, bool *VAR_1)
{
struct sockaddr_in VAR_2 = {
.sin_family = AF_INET,
.sin_addr = { .s_addr = htonl(INADDR_LOOPBACK) },
};
struct sockaddr_in6 VAR_3 = {
.sin6_family = AF_INET6,
.sin6_addr = IN6ADDR_LOOPBACK_INIT,
};
if (check_bind((struct sockaddr *)&VAR_2, sizeof(VAR_2), VAR_0) < 0) {
return -1;
}
if (check_bind((struct sockaddr *)&VAR_3, sizeof(VAR_3), VAR_1) < 0) {
return -1;
}
return 0;
}
| [
"static int FUNC_0(bool *VAR_0, bool *VAR_1)\n{",
"struct sockaddr_in VAR_2 = {",
".sin_family = AF_INET,\n.sin_addr = { .s_addr = htonl(INADDR_LOOPBACK) },",
"};",
"struct sockaddr_in6 VAR_3 = {",
".sin6_family = AF_INET6,\n.sin6_addr = IN6ADDR_LOOPBACK_INIT,\n};",
"if (check_bind((struct sockaddr *)&VAR_2, sizeof(VAR_2), VAR_0) < 0) {",
"return -1;",
"}",
"if (check_bind((struct sockaddr *)&VAR_3, sizeof(VAR_3), VAR_1) < 0) {",
"return -1;",
"}",
"return 0;",
"}"
] | [
0,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11
],
[
13
],
[
15,
17,
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
]
] |
1,819 | static inline void RENAME(rgb24to32)(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 - 23;
__asm __volatile("movq %0, %%mm7"::"m"(mask32):"memory");
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"punpckldq 3%1, %%mm0\n\t"
"movd 6%1, %%mm1\n\t"
"punpckldq 9%1, %%mm1\n\t"
"movd 12%1, %%mm2\n\t"
"punpckldq 15%1, %%mm2\n\t"
"movd 18%1, %%mm3\n\t"
"punpckldq 21%1, %%mm3\n\t"
"pand %%mm7, %%mm0\n\t"
"pand %%mm7, %%mm1\n\t"
"pand %%mm7, %%mm2\n\t"
"pand %%mm7, %%mm3\n\t"
MOVNTQ" %%mm0, %0\n\t"
MOVNTQ" %%mm1, 8%0\n\t"
MOVNTQ" %%mm2, 16%0\n\t"
MOVNTQ" %%mm3, 24%0"
:"=m"(*dest)
:"m"(*s)
:"memory");
dest += 32;
s += 24;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
#ifdef WORDS_BIGENDIAN
*dest++ = 0;
*dest++ = *s++;
*dest++ = *s++;
*dest++ = *s++;
#else
*dest++ = *s++;
*dest++ = *s++;
*dest++ = *s++;
*dest++ = 0;
#endif
}
}
| true | FFmpeg | 7f526efd17973ec6d2204f7a47b6923e2be31363 | static inline void RENAME(rgb24to32)(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 - 23;
__asm __volatile("movq %0, %%mm7"::"m"(mask32):"memory");
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"punpckldq 3%1, %%mm0\n\t"
"movd 6%1, %%mm1\n\t"
"punpckldq 9%1, %%mm1\n\t"
"movd 12%1, %%mm2\n\t"
"punpckldq 15%1, %%mm2\n\t"
"movd 18%1, %%mm3\n\t"
"punpckldq 21%1, %%mm3\n\t"
"pand %%mm7, %%mm0\n\t"
"pand %%mm7, %%mm1\n\t"
"pand %%mm7, %%mm2\n\t"
"pand %%mm7, %%mm3\n\t"
MOVNTQ" %%mm0, %0\n\t"
MOVNTQ" %%mm1, 8%0\n\t"
MOVNTQ" %%mm2, 16%0\n\t"
MOVNTQ" %%mm3, 24%0"
:"=m"(*dest)
:"m"(*s)
:"memory");
dest += 32;
s += 24;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
#ifdef WORDS_BIGENDIAN
*dest++ = 0;
*dest++ = *s++;
*dest++ = *s++;
*dest++ = *s++;
#else
*dest++ = *s++;
*dest++ = *s++;
*dest++ = *s++;
*dest++ = 0;
#endif
}
}
| {
"code": [
"static inline void RENAME(rgb24to32)(const uint8_t *src,uint8_t *dst,unsigned src_size)"
],
"line_no": [
1
]
} | static inline void FUNC_0(rgb24to32)(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 - 23;
__asm __volatile("movq %0, %%mm7"::"m"(mask32):"memory");
while(VAR_0 < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"punpckldq 3%1, %%mm0\n\t"
"movd 6%1, %%mm1\n\t"
"punpckldq 9%1, %%mm1\n\t"
"movd 12%1, %%mm2\n\t"
"punpckldq 15%1, %%mm2\n\t"
"movd 18%1, %%mm3\n\t"
"punpckldq 21%1, %%mm3\n\t"
"pand %%mm7, %%mm0\n\t"
"pand %%mm7, %%mm1\n\t"
"pand %%mm7, %%mm2\n\t"
"pand %%mm7, %%mm3\n\t"
MOVNTQ" %%mm0, %0\n\t"
MOVNTQ" %%mm1, 8%0\n\t"
MOVNTQ" %%mm2, 16%0\n\t"
MOVNTQ" %%mm3, 24%0"
:"=m"(*dest)
:"m"(*VAR_0)
:"memory");
dest += 32;
VAR_0 += 24;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(VAR_0 < VAR_1)
{
#ifdef WORDS_BIGENDIAN
*dest++ = 0;
*dest++ = *VAR_0++;
*dest++ = *VAR_0++;
*dest++ = *VAR_0++;
#else
*dest++ = *VAR_0++;
*dest++ = *VAR_0++;
*dest++ = *VAR_0++;
*dest++ = 0;
#endif
}
}
| [
"static inline void FUNC_0(rgb24to32)(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 - 23;",
"__asm __volatile(\"movq\t%0, %%mm7\"::\"m\"(mask32):\"memory\");",
"while(VAR_0 < mm_end)\n{",
"__asm __volatile(\nPREFETCH\"\t32%1\\n\\t\"\n\"movd\t%1, %%mm0\\n\\t\"\n\"punpckldq 3%1, %%mm0\\n\\t\"\n\"movd\t6%1, %%mm1\\n\\t\"\n\"punpckldq 9%1, %%mm1\\n\\t\"\n\"movd\t12%1, %%mm2\\n\\t\"\n\"punpckldq 15%1, %%mm2\\n\\t\"\n\"movd\t18%1, %%mm3\\n\\t\"\n\"punpckldq 21%1, %%mm3\\n\\t\"\n\"pand\t%%mm7, %%mm0\\n\\t\"\n\"pand\t%%mm7, %%mm1\\n\\t\"\n\"pand\t%%mm7, %%mm2\\n\\t\"\n\"pand\t%%mm7, %%mm3\\n\\t\"\nMOVNTQ\"\t%%mm0, %0\\n\\t\"\nMOVNTQ\"\t%%mm1, 8%0\\n\\t\"\nMOVNTQ\"\t%%mm2, 16%0\\n\\t\"\nMOVNTQ\"\t%%mm3, 24%0\"\n:\"=m\"(*dest)\n:\"m\"(*VAR_0)\n:\"memory\");",
"dest += 32;",
"VAR_0 += 24;",
"}",
"__asm __volatile(SFENCE:::\"memory\");",
"__asm __volatile(EMMS:::\"memory\");",
"#endif\nwhile(VAR_0 < VAR_1)\n{",
"#ifdef WORDS_BIGENDIAN\n*dest++ = 0;",
"*dest++ = *VAR_0++;",
"*dest++ = *VAR_0++;",
"*dest++ = *VAR_0++;",
"#else\n*dest++ = *VAR_0++;",
"*dest++ = *VAR_0++;",
"*dest++ = *VAR_0++;",
"*dest++ = 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,
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
]
] |
1,820 | static int encode_picture(MpegEncContext *s, int picture_number)
{
int i, ret;
int bits;
int context_count = s->slice_context_count;
s->picture_number = picture_number;
/* Reset the average MB variance */
s->me.mb_var_sum_temp =
s->me.mc_mb_var_sum_temp = 0;
/* we need to initialize some time vars before we can encode b-frames */
// RAL: Condition added for MPEG1VIDEO
if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO || s->codec_id == AV_CODEC_ID_MPEG2VIDEO || (s->h263_pred && !s->msmpeg4_version))
set_frame_distances(s);
if(CONFIG_MPEG4_ENCODER && s->codec_id == AV_CODEC_ID_MPEG4)
ff_set_mpeg4_time(s);
s->me.scene_change_score=0;
// s->lambda= s->current_picture_ptr->quality; //FIXME qscale / ... stuff for ME rate distortion
if(s->pict_type==AV_PICTURE_TYPE_I){
if(s->msmpeg4_version >= 3) s->no_rounding=1;
else s->no_rounding=0;
}else if(s->pict_type!=AV_PICTURE_TYPE_B){
if(s->flipflop_rounding || s->codec_id == AV_CODEC_ID_H263P || s->codec_id == AV_CODEC_ID_MPEG4)
s->no_rounding ^= 1;
}
if(s->flags & CODEC_FLAG_PASS2){
if (estimate_qp(s,1) < 0)
return -1;
ff_get_2pass_fcode(s);
}else if(!(s->flags & CODEC_FLAG_QSCALE)){
if(s->pict_type==AV_PICTURE_TYPE_B)
s->lambda= s->last_lambda_for[s->pict_type];
else
s->lambda= s->last_lambda_for[s->last_non_b_pict_type];
update_qscale(s);
}
if(s->codec_id != AV_CODEC_ID_AMV && s->codec_id != AV_CODEC_ID_MJPEG){
if(s->q_chroma_intra_matrix != s->q_intra_matrix ) av_freep(&s->q_chroma_intra_matrix);
if(s->q_chroma_intra_matrix16 != s->q_intra_matrix16) av_freep(&s->q_chroma_intra_matrix16);
s->q_chroma_intra_matrix = s->q_intra_matrix;
s->q_chroma_intra_matrix16 = s->q_intra_matrix16;
}
s->mb_intra=0; //for the rate distortion & bit compare functions
for(i=1; i<context_count; i++){
ret = ff_update_duplicate_context(s->thread_context[i], s);
if (ret < 0)
return ret;
}
if(ff_init_me(s)<0)
return -1;
/* Estimate motion for every MB */
if(s->pict_type != AV_PICTURE_TYPE_I){
s->lambda = (s->lambda * s->avctx->me_penalty_compensation + 128)>>8;
s->lambda2= (s->lambda2* (int64_t)s->avctx->me_penalty_compensation + 128)>>8;
if (s->pict_type != AV_PICTURE_TYPE_B) {
if((s->avctx->pre_me && s->last_non_b_pict_type==AV_PICTURE_TYPE_I) || s->avctx->pre_me==2){
s->avctx->execute(s->avctx, pre_estimate_motion_thread, &s->thread_context[0], NULL, context_count, sizeof(void*));
}
}
s->avctx->execute(s->avctx, estimate_motion_thread, &s->thread_context[0], NULL, context_count, sizeof(void*));
}else /* if(s->pict_type == AV_PICTURE_TYPE_I) */{
/* I-Frame */
for(i=0; i<s->mb_stride*s->mb_height; i++)
s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA;
if(!s->fixed_qscale){
/* finding spatial complexity for I-frame rate control */
s->avctx->execute(s->avctx, mb_var_thread, &s->thread_context[0], NULL, context_count, sizeof(void*));
}
}
for(i=1; i<context_count; i++){
merge_context_after_me(s, s->thread_context[i]);
}
s->current_picture.mc_mb_var_sum= s->current_picture_ptr->mc_mb_var_sum= s->me.mc_mb_var_sum_temp;
s->current_picture. mb_var_sum= s->current_picture_ptr-> mb_var_sum= s->me. mb_var_sum_temp;
emms_c();
if(s->me.scene_change_score > s->avctx->scenechange_threshold && s->pict_type == AV_PICTURE_TYPE_P){
s->pict_type= AV_PICTURE_TYPE_I;
for(i=0; i<s->mb_stride*s->mb_height; i++)
s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA;
if(s->msmpeg4_version >= 3)
s->no_rounding=1;
av_dlog(s, "Scene change detected, encoding as I Frame %d %d\n",
s->current_picture.mb_var_sum, s->current_picture.mc_mb_var_sum);
}
if(!s->umvplus){
if(s->pict_type==AV_PICTURE_TYPE_P || s->pict_type==AV_PICTURE_TYPE_S) {
s->f_code= ff_get_best_fcode(s, s->p_mv_table, CANDIDATE_MB_TYPE_INTER);
if(s->flags & CODEC_FLAG_INTERLACED_ME){
int a,b;
a= ff_get_best_fcode(s, s->p_field_mv_table[0][0], CANDIDATE_MB_TYPE_INTER_I); //FIXME field_select
b= ff_get_best_fcode(s, s->p_field_mv_table[1][1], CANDIDATE_MB_TYPE_INTER_I);
s->f_code= FFMAX3(s->f_code, a, b);
}
ff_fix_long_p_mvs(s);
ff_fix_long_mvs(s, NULL, 0, s->p_mv_table, s->f_code, CANDIDATE_MB_TYPE_INTER, 0);
if(s->flags & CODEC_FLAG_INTERLACED_ME){
int j;
for(i=0; i<2; i++){
for(j=0; j<2; j++)
ff_fix_long_mvs(s, s->p_field_select_table[i], j,
s->p_field_mv_table[i][j], s->f_code, CANDIDATE_MB_TYPE_INTER_I, 0);
}
}
}
if(s->pict_type==AV_PICTURE_TYPE_B){
int a, b;
a = ff_get_best_fcode(s, s->b_forw_mv_table, CANDIDATE_MB_TYPE_FORWARD);
b = ff_get_best_fcode(s, s->b_bidir_forw_mv_table, CANDIDATE_MB_TYPE_BIDIR);
s->f_code = FFMAX(a, b);
a = ff_get_best_fcode(s, s->b_back_mv_table, CANDIDATE_MB_TYPE_BACKWARD);
b = ff_get_best_fcode(s, s->b_bidir_back_mv_table, CANDIDATE_MB_TYPE_BIDIR);
s->b_code = FFMAX(a, b);
ff_fix_long_mvs(s, NULL, 0, s->b_forw_mv_table, s->f_code, CANDIDATE_MB_TYPE_FORWARD, 1);
ff_fix_long_mvs(s, NULL, 0, s->b_back_mv_table, s->b_code, CANDIDATE_MB_TYPE_BACKWARD, 1);
ff_fix_long_mvs(s, NULL, 0, s->b_bidir_forw_mv_table, s->f_code, CANDIDATE_MB_TYPE_BIDIR, 1);
ff_fix_long_mvs(s, NULL, 0, s->b_bidir_back_mv_table, s->b_code, CANDIDATE_MB_TYPE_BIDIR, 1);
if(s->flags & CODEC_FLAG_INTERLACED_ME){
int dir, j;
for(dir=0; dir<2; dir++){
for(i=0; i<2; i++){
for(j=0; j<2; j++){
int type= dir ? (CANDIDATE_MB_TYPE_BACKWARD_I|CANDIDATE_MB_TYPE_BIDIR_I)
: (CANDIDATE_MB_TYPE_FORWARD_I |CANDIDATE_MB_TYPE_BIDIR_I);
ff_fix_long_mvs(s, s->b_field_select_table[dir][i], j,
s->b_field_mv_table[dir][i][j], dir ? s->b_code : s->f_code, type, 1);
}
}
}
}
}
}
if (estimate_qp(s, 0) < 0)
return -1;
if(s->qscale < 3 && s->max_qcoeff<=128 && s->pict_type==AV_PICTURE_TYPE_I && !(s->flags & CODEC_FLAG_QSCALE))
s->qscale= 3; //reduce clipping problems
if (s->out_format == FMT_MJPEG) {
const uint16_t * luma_matrix = ff_mpeg1_default_intra_matrix;
const uint16_t *chroma_matrix = ff_mpeg1_default_intra_matrix;
if (s->avctx->intra_matrix) {
chroma_matrix =
luma_matrix = s->avctx->intra_matrix;
}
if (s->avctx->chroma_intra_matrix)
chroma_matrix = s->avctx->chroma_intra_matrix;
/* for mjpeg, we do include qscale in the matrix */
for(i=1;i<64;i++){
int j= s->dsp.idct_permutation[i];
s->chroma_intra_matrix[j] = av_clip_uint8((chroma_matrix[i] * s->qscale) >> 3);
s-> intra_matrix[j] = av_clip_uint8(( luma_matrix[i] * s->qscale) >> 3);
}
s->y_dc_scale_table=
s->c_dc_scale_table= ff_mpeg2_dc_scale_table[s->intra_dc_precision];
s->chroma_intra_matrix[0] =
s->intra_matrix[0] = ff_mpeg2_dc_scale_table[s->intra_dc_precision][8];
ff_convert_matrix(&s->dsp, s->q_intra_matrix, s->q_intra_matrix16,
s->intra_matrix, s->intra_quant_bias, 8, 8, 1);
ff_convert_matrix(&s->dsp, s->q_chroma_intra_matrix, s->q_chroma_intra_matrix16,
s->chroma_intra_matrix, s->intra_quant_bias, 8, 8, 1);
s->qscale= 8;
}
if(s->codec_id == AV_CODEC_ID_AMV){
static const uint8_t y[32]={13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13};
static const uint8_t c[32]={14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14};
for(i=1;i<64;i++){
int j= s->dsp.idct_permutation[ff_zigzag_direct[i]];
s->intra_matrix[j] = sp5x_quant_table[5*2+0][i];
s->chroma_intra_matrix[j] = sp5x_quant_table[5*2+1][i];
}
s->y_dc_scale_table= y;
s->c_dc_scale_table= c;
s->intra_matrix[0] = 13;
s->chroma_intra_matrix[0] = 14;
ff_convert_matrix(&s->dsp, s->q_intra_matrix, s->q_intra_matrix16,
s->intra_matrix, s->intra_quant_bias, 8, 8, 1);
ff_convert_matrix(&s->dsp, s->q_chroma_intra_matrix, s->q_chroma_intra_matrix16,
s->chroma_intra_matrix, s->intra_quant_bias, 8, 8, 1);
s->qscale= 8;
}
//FIXME var duplication
s->current_picture_ptr->f.key_frame =
s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I; //FIXME pic_ptr
s->current_picture_ptr->f.pict_type =
s->current_picture.f.pict_type = s->pict_type;
if (s->current_picture.f.key_frame)
s->picture_in_gop_number=0;
s->mb_x = s->mb_y = 0;
s->last_bits= put_bits_count(&s->pb);
switch(s->out_format) {
case FMT_MJPEG:
if (CONFIG_MJPEG_ENCODER)
ff_mjpeg_encode_picture_header(s->avctx, &s->pb, &s->intra_scantable,
s->intra_matrix, s->chroma_intra_matrix);
break;
case FMT_H261:
if (CONFIG_H261_ENCODER)
ff_h261_encode_picture_header(s, picture_number);
break;
case FMT_H263:
if (CONFIG_WMV2_ENCODER && s->codec_id == AV_CODEC_ID_WMV2)
ff_wmv2_encode_picture_header(s, picture_number);
else if (CONFIG_MSMPEG4_ENCODER && s->msmpeg4_version)
ff_msmpeg4_encode_picture_header(s, picture_number);
else if (CONFIG_MPEG4_ENCODER && s->h263_pred)
ff_mpeg4_encode_picture_header(s, picture_number);
else if (CONFIG_RV10_ENCODER && s->codec_id == AV_CODEC_ID_RV10)
ff_rv10_encode_picture_header(s, picture_number);
else if (CONFIG_RV20_ENCODER && s->codec_id == AV_CODEC_ID_RV20)
ff_rv20_encode_picture_header(s, picture_number);
else if (CONFIG_FLV_ENCODER && s->codec_id == AV_CODEC_ID_FLV1)
ff_flv_encode_picture_header(s, picture_number);
else if (CONFIG_H263_ENCODER)
ff_h263_encode_picture_header(s, picture_number);
break;
case FMT_MPEG1:
if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER)
ff_mpeg1_encode_picture_header(s, picture_number);
break;
default:
av_assert0(0);
}
bits= put_bits_count(&s->pb);
s->header_bits= bits - s->last_bits;
for(i=1; i<context_count; i++){
update_duplicate_context_after_me(s->thread_context[i], s);
}
s->avctx->execute(s->avctx, encode_thread, &s->thread_context[0], NULL, context_count, sizeof(void*));
for(i=1; i<context_count; i++){
merge_context_after_encode(s, s->thread_context[i]);
}
emms_c();
return 0;
}
| true | FFmpeg | e92a78a4095d69d876bef189225608a35166dc4a | static int encode_picture(MpegEncContext *s, int picture_number)
{
int i, ret;
int bits;
int context_count = s->slice_context_count;
s->picture_number = picture_number;
s->me.mb_var_sum_temp =
s->me.mc_mb_var_sum_temp = 0;
if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO || s->codec_id == AV_CODEC_ID_MPEG2VIDEO || (s->h263_pred && !s->msmpeg4_version))
set_frame_distances(s);
if(CONFIG_MPEG4_ENCODER && s->codec_id == AV_CODEC_ID_MPEG4)
ff_set_mpeg4_time(s);
s->me.scene_change_score=0;
if(s->pict_type==AV_PICTURE_TYPE_I){
if(s->msmpeg4_version >= 3) s->no_rounding=1;
else s->no_rounding=0;
}else if(s->pict_type!=AV_PICTURE_TYPE_B){
if(s->flipflop_rounding || s->codec_id == AV_CODEC_ID_H263P || s->codec_id == AV_CODEC_ID_MPEG4)
s->no_rounding ^= 1;
}
if(s->flags & CODEC_FLAG_PASS2){
if (estimate_qp(s,1) < 0)
return -1;
ff_get_2pass_fcode(s);
}else if(!(s->flags & CODEC_FLAG_QSCALE)){
if(s->pict_type==AV_PICTURE_TYPE_B)
s->lambda= s->last_lambda_for[s->pict_type];
else
s->lambda= s->last_lambda_for[s->last_non_b_pict_type];
update_qscale(s);
}
if(s->codec_id != AV_CODEC_ID_AMV && s->codec_id != AV_CODEC_ID_MJPEG){
if(s->q_chroma_intra_matrix != s->q_intra_matrix ) av_freep(&s->q_chroma_intra_matrix);
if(s->q_chroma_intra_matrix16 != s->q_intra_matrix16) av_freep(&s->q_chroma_intra_matrix16);
s->q_chroma_intra_matrix = s->q_intra_matrix;
s->q_chroma_intra_matrix16 = s->q_intra_matrix16;
}
s->mb_intra=0;
for(i=1; i<context_count; i++){
ret = ff_update_duplicate_context(s->thread_context[i], s);
if (ret < 0)
return ret;
}
if(ff_init_me(s)<0)
return -1;
if(s->pict_type != AV_PICTURE_TYPE_I){
s->lambda = (s->lambda * s->avctx->me_penalty_compensation + 128)>>8;
s->lambda2= (s->lambda2* (int64_t)s->avctx->me_penalty_compensation + 128)>>8;
if (s->pict_type != AV_PICTURE_TYPE_B) {
if((s->avctx->pre_me && s->last_non_b_pict_type==AV_PICTURE_TYPE_I) || s->avctx->pre_me==2){
s->avctx->execute(s->avctx, pre_estimate_motion_thread, &s->thread_context[0], NULL, context_count, sizeof(void*));
}
}
s->avctx->execute(s->avctx, estimate_motion_thread, &s->thread_context[0], NULL, context_count, sizeof(void*));
}else {
for(i=0; i<s->mb_stride*s->mb_height; i++)
s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA;
if(!s->fixed_qscale){
s->avctx->execute(s->avctx, mb_var_thread, &s->thread_context[0], NULL, context_count, sizeof(void*));
}
}
for(i=1; i<context_count; i++){
merge_context_after_me(s, s->thread_context[i]);
}
s->current_picture.mc_mb_var_sum= s->current_picture_ptr->mc_mb_var_sum= s->me.mc_mb_var_sum_temp;
s->current_picture. mb_var_sum= s->current_picture_ptr-> mb_var_sum= s->me. mb_var_sum_temp;
emms_c();
if(s->me.scene_change_score > s->avctx->scenechange_threshold && s->pict_type == AV_PICTURE_TYPE_P){
s->pict_type= AV_PICTURE_TYPE_I;
for(i=0; i<s->mb_stride*s->mb_height; i++)
s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA;
if(s->msmpeg4_version >= 3)
s->no_rounding=1;
av_dlog(s, "Scene change detected, encoding as I Frame %d %d\n",
s->current_picture.mb_var_sum, s->current_picture.mc_mb_var_sum);
}
if(!s->umvplus){
if(s->pict_type==AV_PICTURE_TYPE_P || s->pict_type==AV_PICTURE_TYPE_S) {
s->f_code= ff_get_best_fcode(s, s->p_mv_table, CANDIDATE_MB_TYPE_INTER);
if(s->flags & CODEC_FLAG_INTERLACED_ME){
int a,b;
a= ff_get_best_fcode(s, s->p_field_mv_table[0][0], CANDIDATE_MB_TYPE_INTER_I);
b= ff_get_best_fcode(s, s->p_field_mv_table[1][1], CANDIDATE_MB_TYPE_INTER_I);
s->f_code= FFMAX3(s->f_code, a, b);
}
ff_fix_long_p_mvs(s);
ff_fix_long_mvs(s, NULL, 0, s->p_mv_table, s->f_code, CANDIDATE_MB_TYPE_INTER, 0);
if(s->flags & CODEC_FLAG_INTERLACED_ME){
int j;
for(i=0; i<2; i++){
for(j=0; j<2; j++)
ff_fix_long_mvs(s, s->p_field_select_table[i], j,
s->p_field_mv_table[i][j], s->f_code, CANDIDATE_MB_TYPE_INTER_I, 0);
}
}
}
if(s->pict_type==AV_PICTURE_TYPE_B){
int a, b;
a = ff_get_best_fcode(s, s->b_forw_mv_table, CANDIDATE_MB_TYPE_FORWARD);
b = ff_get_best_fcode(s, s->b_bidir_forw_mv_table, CANDIDATE_MB_TYPE_BIDIR);
s->f_code = FFMAX(a, b);
a = ff_get_best_fcode(s, s->b_back_mv_table, CANDIDATE_MB_TYPE_BACKWARD);
b = ff_get_best_fcode(s, s->b_bidir_back_mv_table, CANDIDATE_MB_TYPE_BIDIR);
s->b_code = FFMAX(a, b);
ff_fix_long_mvs(s, NULL, 0, s->b_forw_mv_table, s->f_code, CANDIDATE_MB_TYPE_FORWARD, 1);
ff_fix_long_mvs(s, NULL, 0, s->b_back_mv_table, s->b_code, CANDIDATE_MB_TYPE_BACKWARD, 1);
ff_fix_long_mvs(s, NULL, 0, s->b_bidir_forw_mv_table, s->f_code, CANDIDATE_MB_TYPE_BIDIR, 1);
ff_fix_long_mvs(s, NULL, 0, s->b_bidir_back_mv_table, s->b_code, CANDIDATE_MB_TYPE_BIDIR, 1);
if(s->flags & CODEC_FLAG_INTERLACED_ME){
int dir, j;
for(dir=0; dir<2; dir++){
for(i=0; i<2; i++){
for(j=0; j<2; j++){
int type= dir ? (CANDIDATE_MB_TYPE_BACKWARD_I|CANDIDATE_MB_TYPE_BIDIR_I)
: (CANDIDATE_MB_TYPE_FORWARD_I |CANDIDATE_MB_TYPE_BIDIR_I);
ff_fix_long_mvs(s, s->b_field_select_table[dir][i], j,
s->b_field_mv_table[dir][i][j], dir ? s->b_code : s->f_code, type, 1);
}
}
}
}
}
}
if (estimate_qp(s, 0) < 0)
return -1;
if(s->qscale < 3 && s->max_qcoeff<=128 && s->pict_type==AV_PICTURE_TYPE_I && !(s->flags & CODEC_FLAG_QSCALE))
s->qscale= 3;
if (s->out_format == FMT_MJPEG) {
const uint16_t * luma_matrix = ff_mpeg1_default_intra_matrix;
const uint16_t *chroma_matrix = ff_mpeg1_default_intra_matrix;
if (s->avctx->intra_matrix) {
chroma_matrix =
luma_matrix = s->avctx->intra_matrix;
}
if (s->avctx->chroma_intra_matrix)
chroma_matrix = s->avctx->chroma_intra_matrix;
for(i=1;i<64;i++){
int j= s->dsp.idct_permutation[i];
s->chroma_intra_matrix[j] = av_clip_uint8((chroma_matrix[i] * s->qscale) >> 3);
s-> intra_matrix[j] = av_clip_uint8(( luma_matrix[i] * s->qscale) >> 3);
}
s->y_dc_scale_table=
s->c_dc_scale_table= ff_mpeg2_dc_scale_table[s->intra_dc_precision];
s->chroma_intra_matrix[0] =
s->intra_matrix[0] = ff_mpeg2_dc_scale_table[s->intra_dc_precision][8];
ff_convert_matrix(&s->dsp, s->q_intra_matrix, s->q_intra_matrix16,
s->intra_matrix, s->intra_quant_bias, 8, 8, 1);
ff_convert_matrix(&s->dsp, s->q_chroma_intra_matrix, s->q_chroma_intra_matrix16,
s->chroma_intra_matrix, s->intra_quant_bias, 8, 8, 1);
s->qscale= 8;
}
if(s->codec_id == AV_CODEC_ID_AMV){
static const uint8_t y[32]={13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13};
static const uint8_t c[32]={14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14};
for(i=1;i<64;i++){
int j= s->dsp.idct_permutation[ff_zigzag_direct[i]];
s->intra_matrix[j] = sp5x_quant_table[5*2+0][i];
s->chroma_intra_matrix[j] = sp5x_quant_table[5*2+1][i];
}
s->y_dc_scale_table= y;
s->c_dc_scale_table= c;
s->intra_matrix[0] = 13;
s->chroma_intra_matrix[0] = 14;
ff_convert_matrix(&s->dsp, s->q_intra_matrix, s->q_intra_matrix16,
s->intra_matrix, s->intra_quant_bias, 8, 8, 1);
ff_convert_matrix(&s->dsp, s->q_chroma_intra_matrix, s->q_chroma_intra_matrix16,
s->chroma_intra_matrix, s->intra_quant_bias, 8, 8, 1);
s->qscale= 8;
}
s->current_picture_ptr->f.key_frame =
s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
s->current_picture_ptr->f.pict_type =
s->current_picture.f.pict_type = s->pict_type;
if (s->current_picture.f.key_frame)
s->picture_in_gop_number=0;
s->mb_x = s->mb_y = 0;
s->last_bits= put_bits_count(&s->pb);
switch(s->out_format) {
case FMT_MJPEG:
if (CONFIG_MJPEG_ENCODER)
ff_mjpeg_encode_picture_header(s->avctx, &s->pb, &s->intra_scantable,
s->intra_matrix, s->chroma_intra_matrix);
break;
case FMT_H261:
if (CONFIG_H261_ENCODER)
ff_h261_encode_picture_header(s, picture_number);
break;
case FMT_H263:
if (CONFIG_WMV2_ENCODER && s->codec_id == AV_CODEC_ID_WMV2)
ff_wmv2_encode_picture_header(s, picture_number);
else if (CONFIG_MSMPEG4_ENCODER && s->msmpeg4_version)
ff_msmpeg4_encode_picture_header(s, picture_number);
else if (CONFIG_MPEG4_ENCODER && s->h263_pred)
ff_mpeg4_encode_picture_header(s, picture_number);
else if (CONFIG_RV10_ENCODER && s->codec_id == AV_CODEC_ID_RV10)
ff_rv10_encode_picture_header(s, picture_number);
else if (CONFIG_RV20_ENCODER && s->codec_id == AV_CODEC_ID_RV20)
ff_rv20_encode_picture_header(s, picture_number);
else if (CONFIG_FLV_ENCODER && s->codec_id == AV_CODEC_ID_FLV1)
ff_flv_encode_picture_header(s, picture_number);
else if (CONFIG_H263_ENCODER)
ff_h263_encode_picture_header(s, picture_number);
break;
case FMT_MPEG1:
if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER)
ff_mpeg1_encode_picture_header(s, picture_number);
break;
default:
av_assert0(0);
}
bits= put_bits_count(&s->pb);
s->header_bits= bits - s->last_bits;
for(i=1; i<context_count; i++){
update_duplicate_context_after_me(s->thread_context[i], s);
}
s->avctx->execute(s->avctx, encode_thread, &s->thread_context[0], NULL, context_count, sizeof(void*));
for(i=1; i<context_count; i++){
merge_context_after_encode(s, s->thread_context[i]);
}
emms_c();
return 0;
}
| {
"code": [
" av_dlog(s, \"Scene change detected, encoding as I Frame %d %d\\n\","
],
"line_no": [
189
]
} | static int FUNC_0(MpegEncContext *VAR_0, int VAR_1)
{
int VAR_2, VAR_3;
int VAR_4;
int VAR_5 = VAR_0->slice_context_count;
VAR_0->VAR_1 = VAR_1;
VAR_0->me.mb_var_sum_temp =
VAR_0->me.mc_mb_var_sum_temp = 0;
if (VAR_0->codec_id == AV_CODEC_ID_MPEG1VIDEO || VAR_0->codec_id == AV_CODEC_ID_MPEG2VIDEO || (VAR_0->h263_pred && !VAR_0->msmpeg4_version))
set_frame_distances(VAR_0);
if(CONFIG_MPEG4_ENCODER && VAR_0->codec_id == AV_CODEC_ID_MPEG4)
ff_set_mpeg4_time(VAR_0);
VAR_0->me.scene_change_score=0;
if(VAR_0->pict_type==AV_PICTURE_TYPE_I){
if(VAR_0->msmpeg4_version >= 3) VAR_0->no_rounding=1;
else VAR_0->no_rounding=0;
}else if(VAR_0->pict_type!=AV_PICTURE_TYPE_B){
if(VAR_0->flipflop_rounding || VAR_0->codec_id == AV_CODEC_ID_H263P || VAR_0->codec_id == AV_CODEC_ID_MPEG4)
VAR_0->no_rounding ^= 1;
}
if(VAR_0->flags & CODEC_FLAG_PASS2){
if (estimate_qp(VAR_0,1) < 0)
return -1;
ff_get_2pass_fcode(VAR_0);
}else if(!(VAR_0->flags & CODEC_FLAG_QSCALE)){
if(VAR_0->pict_type==AV_PICTURE_TYPE_B)
VAR_0->lambda= VAR_0->last_lambda_for[VAR_0->pict_type];
else
VAR_0->lambda= VAR_0->last_lambda_for[VAR_0->last_non_b_pict_type];
update_qscale(VAR_0);
}
if(VAR_0->codec_id != AV_CODEC_ID_AMV && VAR_0->codec_id != AV_CODEC_ID_MJPEG){
if(VAR_0->q_chroma_intra_matrix != VAR_0->q_intra_matrix ) av_freep(&VAR_0->q_chroma_intra_matrix);
if(VAR_0->q_chroma_intra_matrix16 != VAR_0->q_intra_matrix16) av_freep(&VAR_0->q_chroma_intra_matrix16);
VAR_0->q_chroma_intra_matrix = VAR_0->q_intra_matrix;
VAR_0->q_chroma_intra_matrix16 = VAR_0->q_intra_matrix16;
}
VAR_0->mb_intra=0;
for(VAR_2=1; VAR_2<VAR_5; VAR_2++){
VAR_3 = ff_update_duplicate_context(VAR_0->thread_context[VAR_2], VAR_0);
if (VAR_3 < 0)
return VAR_3;
}
if(ff_init_me(VAR_0)<0)
return -1;
if(VAR_0->pict_type != AV_PICTURE_TYPE_I){
VAR_0->lambda = (VAR_0->lambda * VAR_0->avctx->me_penalty_compensation + 128)>>8;
VAR_0->lambda2= (VAR_0->lambda2* (int64_t)VAR_0->avctx->me_penalty_compensation + 128)>>8;
if (VAR_0->pict_type != AV_PICTURE_TYPE_B) {
if((VAR_0->avctx->pre_me && VAR_0->last_non_b_pict_type==AV_PICTURE_TYPE_I) || VAR_0->avctx->pre_me==2){
VAR_0->avctx->execute(VAR_0->avctx, pre_estimate_motion_thread, &VAR_0->thread_context[0], NULL, VAR_5, sizeof(void*));
}
}
VAR_0->avctx->execute(VAR_0->avctx, estimate_motion_thread, &VAR_0->thread_context[0], NULL, VAR_5, sizeof(void*));
}else {
for(VAR_2=0; VAR_2<VAR_0->mb_stride*VAR_0->mb_height; VAR_2++)
VAR_0->mb_type[VAR_2]= CANDIDATE_MB_TYPE_INTRA;
if(!VAR_0->fixed_qscale){
VAR_0->avctx->execute(VAR_0->avctx, mb_var_thread, &VAR_0->thread_context[0], NULL, VAR_5, sizeof(void*));
}
}
for(VAR_2=1; VAR_2<VAR_5; VAR_2++){
merge_context_after_me(VAR_0, VAR_0->thread_context[VAR_2]);
}
VAR_0->current_picture.mc_mb_var_sum= VAR_0->current_picture_ptr->mc_mb_var_sum= VAR_0->me.mc_mb_var_sum_temp;
VAR_0->current_picture. mb_var_sum= VAR_0->current_picture_ptr-> mb_var_sum= VAR_0->me. mb_var_sum_temp;
emms_c();
if(VAR_0->me.scene_change_score > VAR_0->avctx->scenechange_threshold && VAR_0->pict_type == AV_PICTURE_TYPE_P){
VAR_0->pict_type= AV_PICTURE_TYPE_I;
for(VAR_2=0; VAR_2<VAR_0->mb_stride*VAR_0->mb_height; VAR_2++)
VAR_0->mb_type[VAR_2]= CANDIDATE_MB_TYPE_INTRA;
if(VAR_0->msmpeg4_version >= 3)
VAR_0->no_rounding=1;
av_dlog(VAR_0, "Scene change detected, encoding as I Frame %d %d\n",
VAR_0->current_picture.mb_var_sum, VAR_0->current_picture.mc_mb_var_sum);
}
if(!VAR_0->umvplus){
if(VAR_0->pict_type==AV_PICTURE_TYPE_P || VAR_0->pict_type==AV_PICTURE_TYPE_S) {
VAR_0->f_code= ff_get_best_fcode(VAR_0, VAR_0->p_mv_table, CANDIDATE_MB_TYPE_INTER);
if(VAR_0->flags & CODEC_FLAG_INTERLACED_ME){
int VAR_9,VAR_9;
VAR_9= ff_get_best_fcode(VAR_0, VAR_0->p_field_mv_table[0][0], CANDIDATE_MB_TYPE_INTER_I);
VAR_9= ff_get_best_fcode(VAR_0, VAR_0->p_field_mv_table[1][1], CANDIDATE_MB_TYPE_INTER_I);
VAR_0->f_code= FFMAX3(VAR_0->f_code, VAR_9, VAR_9);
}
ff_fix_long_p_mvs(VAR_0);
ff_fix_long_mvs(VAR_0, NULL, 0, VAR_0->p_mv_table, VAR_0->f_code, CANDIDATE_MB_TYPE_INTER, 0);
if(VAR_0->flags & CODEC_FLAG_INTERLACED_ME){
int VAR_15;
for(VAR_2=0; VAR_2<2; VAR_2++){
for(VAR_15=0; VAR_15<2; VAR_15++)
ff_fix_long_mvs(VAR_0, VAR_0->p_field_select_table[VAR_2], VAR_15,
VAR_0->p_field_mv_table[VAR_2][VAR_15], VAR_0->f_code, CANDIDATE_MB_TYPE_INTER_I, 0);
}
}
}
if(VAR_0->pict_type==AV_PICTURE_TYPE_B){
int VAR_9, VAR_9;
VAR_9 = ff_get_best_fcode(VAR_0, VAR_0->b_forw_mv_table, CANDIDATE_MB_TYPE_FORWARD);
VAR_9 = ff_get_best_fcode(VAR_0, VAR_0->b_bidir_forw_mv_table, CANDIDATE_MB_TYPE_BIDIR);
VAR_0->f_code = FFMAX(VAR_9, VAR_9);
VAR_9 = ff_get_best_fcode(VAR_0, VAR_0->b_back_mv_table, CANDIDATE_MB_TYPE_BACKWARD);
VAR_9 = ff_get_best_fcode(VAR_0, VAR_0->b_bidir_back_mv_table, CANDIDATE_MB_TYPE_BIDIR);
VAR_0->b_code = FFMAX(VAR_9, VAR_9);
ff_fix_long_mvs(VAR_0, NULL, 0, VAR_0->b_forw_mv_table, VAR_0->f_code, CANDIDATE_MB_TYPE_FORWARD, 1);
ff_fix_long_mvs(VAR_0, NULL, 0, VAR_0->b_back_mv_table, VAR_0->b_code, CANDIDATE_MB_TYPE_BACKWARD, 1);
ff_fix_long_mvs(VAR_0, NULL, 0, VAR_0->b_bidir_forw_mv_table, VAR_0->f_code, CANDIDATE_MB_TYPE_BIDIR, 1);
ff_fix_long_mvs(VAR_0, NULL, 0, VAR_0->b_bidir_back_mv_table, VAR_0->b_code, CANDIDATE_MB_TYPE_BIDIR, 1);
if(VAR_0->flags & CODEC_FLAG_INTERLACED_ME){
int VAR_9, VAR_15;
for(VAR_9=0; VAR_9<2; VAR_9++){
for(VAR_2=0; VAR_2<2; VAR_2++){
for(VAR_15=0; VAR_15<2; VAR_15++){
int VAR_10= VAR_9 ? (CANDIDATE_MB_TYPE_BACKWARD_I|CANDIDATE_MB_TYPE_BIDIR_I)
: (CANDIDATE_MB_TYPE_FORWARD_I |CANDIDATE_MB_TYPE_BIDIR_I);
ff_fix_long_mvs(VAR_0, VAR_0->b_field_select_table[VAR_9][VAR_2], VAR_15,
VAR_0->b_field_mv_table[VAR_9][VAR_2][VAR_15], VAR_9 ? VAR_0->b_code : VAR_0->f_code, VAR_10, 1);
}
}
}
}
}
}
if (estimate_qp(VAR_0, 0) < 0)
return -1;
if(VAR_0->qscale < 3 && VAR_0->max_qcoeff<=128 && VAR_0->pict_type==AV_PICTURE_TYPE_I && !(VAR_0->flags & CODEC_FLAG_QSCALE))
VAR_0->qscale= 3;
if (VAR_0->out_format == FMT_MJPEG) {
const uint16_t * VAR_11 = ff_mpeg1_default_intra_matrix;
const uint16_t *VAR_12 = ff_mpeg1_default_intra_matrix;
if (VAR_0->avctx->intra_matrix) {
VAR_12 =
VAR_11 = VAR_0->avctx->intra_matrix;
}
if (VAR_0->avctx->chroma_intra_matrix)
VAR_12 = VAR_0->avctx->chroma_intra_matrix;
for(VAR_2=1;VAR_2<64;VAR_2++){
int VAR_15= VAR_0->dsp.idct_permutation[VAR_2];
VAR_0->chroma_intra_matrix[VAR_15] = av_clip_uint8((VAR_12[VAR_2] * VAR_0->qscale) >> 3);
VAR_0-> intra_matrix[VAR_15] = av_clip_uint8(( VAR_11[VAR_2] * VAR_0->qscale) >> 3);
}
VAR_0->y_dc_scale_table=
VAR_0->c_dc_scale_table= ff_mpeg2_dc_scale_table[VAR_0->intra_dc_precision];
VAR_0->chroma_intra_matrix[0] =
VAR_0->intra_matrix[0] = ff_mpeg2_dc_scale_table[VAR_0->intra_dc_precision][8];
ff_convert_matrix(&VAR_0->dsp, VAR_0->q_intra_matrix, VAR_0->q_intra_matrix16,
VAR_0->intra_matrix, VAR_0->intra_quant_bias, 8, 8, 1);
ff_convert_matrix(&VAR_0->dsp, VAR_0->q_chroma_intra_matrix, VAR_0->q_chroma_intra_matrix16,
VAR_0->chroma_intra_matrix, VAR_0->intra_quant_bias, 8, 8, 1);
VAR_0->qscale= 8;
}
if(VAR_0->codec_id == AV_CODEC_ID_AMV){
static const uint8_t VAR_13[32]={13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13};
static const uint8_t VAR_14[32]={14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14};
for(VAR_2=1;VAR_2<64;VAR_2++){
int VAR_15= VAR_0->dsp.idct_permutation[ff_zigzag_direct[VAR_2]];
VAR_0->intra_matrix[VAR_15] = sp5x_quant_table[5*2+0][VAR_2];
VAR_0->chroma_intra_matrix[VAR_15] = sp5x_quant_table[5*2+1][VAR_2];
}
VAR_0->y_dc_scale_table= VAR_13;
VAR_0->c_dc_scale_table= VAR_14;
VAR_0->intra_matrix[0] = 13;
VAR_0->chroma_intra_matrix[0] = 14;
ff_convert_matrix(&VAR_0->dsp, VAR_0->q_intra_matrix, VAR_0->q_intra_matrix16,
VAR_0->intra_matrix, VAR_0->intra_quant_bias, 8, 8, 1);
ff_convert_matrix(&VAR_0->dsp, VAR_0->q_chroma_intra_matrix, VAR_0->q_chroma_intra_matrix16,
VAR_0->chroma_intra_matrix, VAR_0->intra_quant_bias, 8, 8, 1);
VAR_0->qscale= 8;
}
VAR_0->current_picture_ptr->f.key_frame =
VAR_0->current_picture.f.key_frame = VAR_0->pict_type == AV_PICTURE_TYPE_I;
VAR_0->current_picture_ptr->f.pict_type =
VAR_0->current_picture.f.pict_type = VAR_0->pict_type;
if (VAR_0->current_picture.f.key_frame)
VAR_0->picture_in_gop_number=0;
VAR_0->mb_x = VAR_0->mb_y = 0;
VAR_0->last_bits= put_bits_count(&VAR_0->pb);
switch(VAR_0->out_format) {
case FMT_MJPEG:
if (CONFIG_MJPEG_ENCODER)
ff_mjpeg_encode_picture_header(VAR_0->avctx, &VAR_0->pb, &VAR_0->intra_scantable,
VAR_0->intra_matrix, VAR_0->chroma_intra_matrix);
break;
case FMT_H261:
if (CONFIG_H261_ENCODER)
ff_h261_encode_picture_header(VAR_0, VAR_1);
break;
case FMT_H263:
if (CONFIG_WMV2_ENCODER && VAR_0->codec_id == AV_CODEC_ID_WMV2)
ff_wmv2_encode_picture_header(VAR_0, VAR_1);
else if (CONFIG_MSMPEG4_ENCODER && VAR_0->msmpeg4_version)
ff_msmpeg4_encode_picture_header(VAR_0, VAR_1);
else if (CONFIG_MPEG4_ENCODER && VAR_0->h263_pred)
ff_mpeg4_encode_picture_header(VAR_0, VAR_1);
else if (CONFIG_RV10_ENCODER && VAR_0->codec_id == AV_CODEC_ID_RV10)
ff_rv10_encode_picture_header(VAR_0, VAR_1);
else if (CONFIG_RV20_ENCODER && VAR_0->codec_id == AV_CODEC_ID_RV20)
ff_rv20_encode_picture_header(VAR_0, VAR_1);
else if (CONFIG_FLV_ENCODER && VAR_0->codec_id == AV_CODEC_ID_FLV1)
ff_flv_encode_picture_header(VAR_0, VAR_1);
else if (CONFIG_H263_ENCODER)
ff_h263_encode_picture_header(VAR_0, VAR_1);
break;
case FMT_MPEG1:
if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER)
ff_mpeg1_encode_picture_header(VAR_0, VAR_1);
break;
default:
av_assert0(0);
}
VAR_4= put_bits_count(&VAR_0->pb);
VAR_0->header_bits= VAR_4 - VAR_0->last_bits;
for(VAR_2=1; VAR_2<VAR_5; VAR_2++){
update_duplicate_context_after_me(VAR_0->thread_context[VAR_2], VAR_0);
}
VAR_0->avctx->execute(VAR_0->avctx, encode_thread, &VAR_0->thread_context[0], NULL, VAR_5, sizeof(void*));
for(VAR_2=1; VAR_2<VAR_5; VAR_2++){
merge_context_after_encode(VAR_0, VAR_0->thread_context[VAR_2]);
}
emms_c();
return 0;
}
| [
"static int FUNC_0(MpegEncContext *VAR_0, int VAR_1)\n{",
"int VAR_2, VAR_3;",
"int VAR_4;",
"int VAR_5 = VAR_0->slice_context_count;",
"VAR_0->VAR_1 = VAR_1;",
"VAR_0->me.mb_var_sum_temp =\nVAR_0->me.mc_mb_var_sum_temp = 0;",
"if (VAR_0->codec_id == AV_CODEC_ID_MPEG1VIDEO || VAR_0->codec_id == AV_CODEC_ID_MPEG2VIDEO || (VAR_0->h263_pred && !VAR_0->msmpeg4_version))\nset_frame_distances(VAR_0);",
"if(CONFIG_MPEG4_ENCODER && VAR_0->codec_id == AV_CODEC_ID_MPEG4)\nff_set_mpeg4_time(VAR_0);",
"VAR_0->me.scene_change_score=0;",
"if(VAR_0->pict_type==AV_PICTURE_TYPE_I){",
"if(VAR_0->msmpeg4_version >= 3) VAR_0->no_rounding=1;",
"else VAR_0->no_rounding=0;",
"}else if(VAR_0->pict_type!=AV_PICTURE_TYPE_B){",
"if(VAR_0->flipflop_rounding || VAR_0->codec_id == AV_CODEC_ID_H263P || VAR_0->codec_id == AV_CODEC_ID_MPEG4)\nVAR_0->no_rounding ^= 1;",
"}",
"if(VAR_0->flags & CODEC_FLAG_PASS2){",
"if (estimate_qp(VAR_0,1) < 0)\nreturn -1;",
"ff_get_2pass_fcode(VAR_0);",
"}else if(!(VAR_0->flags & CODEC_FLAG_QSCALE)){",
"if(VAR_0->pict_type==AV_PICTURE_TYPE_B)\nVAR_0->lambda= VAR_0->last_lambda_for[VAR_0->pict_type];",
"else\nVAR_0->lambda= VAR_0->last_lambda_for[VAR_0->last_non_b_pict_type];",
"update_qscale(VAR_0);",
"}",
"if(VAR_0->codec_id != AV_CODEC_ID_AMV && VAR_0->codec_id != AV_CODEC_ID_MJPEG){",
"if(VAR_0->q_chroma_intra_matrix != VAR_0->q_intra_matrix ) av_freep(&VAR_0->q_chroma_intra_matrix);",
"if(VAR_0->q_chroma_intra_matrix16 != VAR_0->q_intra_matrix16) av_freep(&VAR_0->q_chroma_intra_matrix16);",
"VAR_0->q_chroma_intra_matrix = VAR_0->q_intra_matrix;",
"VAR_0->q_chroma_intra_matrix16 = VAR_0->q_intra_matrix16;",
"}",
"VAR_0->mb_intra=0;",
"for(VAR_2=1; VAR_2<VAR_5; VAR_2++){",
"VAR_3 = ff_update_duplicate_context(VAR_0->thread_context[VAR_2], VAR_0);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"}",
"if(ff_init_me(VAR_0)<0)\nreturn -1;",
"if(VAR_0->pict_type != AV_PICTURE_TYPE_I){",
"VAR_0->lambda = (VAR_0->lambda * VAR_0->avctx->me_penalty_compensation + 128)>>8;",
"VAR_0->lambda2= (VAR_0->lambda2* (int64_t)VAR_0->avctx->me_penalty_compensation + 128)>>8;",
"if (VAR_0->pict_type != AV_PICTURE_TYPE_B) {",
"if((VAR_0->avctx->pre_me && VAR_0->last_non_b_pict_type==AV_PICTURE_TYPE_I) || VAR_0->avctx->pre_me==2){",
"VAR_0->avctx->execute(VAR_0->avctx, pre_estimate_motion_thread, &VAR_0->thread_context[0], NULL, VAR_5, sizeof(void*));",
"}",
"}",
"VAR_0->avctx->execute(VAR_0->avctx, estimate_motion_thread, &VAR_0->thread_context[0], NULL, VAR_5, sizeof(void*));",
"}else {",
"for(VAR_2=0; VAR_2<VAR_0->mb_stride*VAR_0->mb_height; VAR_2++)",
"VAR_0->mb_type[VAR_2]= CANDIDATE_MB_TYPE_INTRA;",
"if(!VAR_0->fixed_qscale){",
"VAR_0->avctx->execute(VAR_0->avctx, mb_var_thread, &VAR_0->thread_context[0], NULL, VAR_5, sizeof(void*));",
"}",
"}",
"for(VAR_2=1; VAR_2<VAR_5; VAR_2++){",
"merge_context_after_me(VAR_0, VAR_0->thread_context[VAR_2]);",
"}",
"VAR_0->current_picture.mc_mb_var_sum= VAR_0->current_picture_ptr->mc_mb_var_sum= VAR_0->me.mc_mb_var_sum_temp;",
"VAR_0->current_picture. mb_var_sum= VAR_0->current_picture_ptr-> mb_var_sum= VAR_0->me. mb_var_sum_temp;",
"emms_c();",
"if(VAR_0->me.scene_change_score > VAR_0->avctx->scenechange_threshold && VAR_0->pict_type == AV_PICTURE_TYPE_P){",
"VAR_0->pict_type= AV_PICTURE_TYPE_I;",
"for(VAR_2=0; VAR_2<VAR_0->mb_stride*VAR_0->mb_height; VAR_2++)",
"VAR_0->mb_type[VAR_2]= CANDIDATE_MB_TYPE_INTRA;",
"if(VAR_0->msmpeg4_version >= 3)\nVAR_0->no_rounding=1;",
"av_dlog(VAR_0, \"Scene change detected, encoding as I Frame %d %d\\n\",\nVAR_0->current_picture.mb_var_sum, VAR_0->current_picture.mc_mb_var_sum);",
"}",
"if(!VAR_0->umvplus){",
"if(VAR_0->pict_type==AV_PICTURE_TYPE_P || VAR_0->pict_type==AV_PICTURE_TYPE_S) {",
"VAR_0->f_code= ff_get_best_fcode(VAR_0, VAR_0->p_mv_table, CANDIDATE_MB_TYPE_INTER);",
"if(VAR_0->flags & CODEC_FLAG_INTERLACED_ME){",
"int VAR_9,VAR_9;",
"VAR_9= ff_get_best_fcode(VAR_0, VAR_0->p_field_mv_table[0][0], CANDIDATE_MB_TYPE_INTER_I);",
"VAR_9= ff_get_best_fcode(VAR_0, VAR_0->p_field_mv_table[1][1], CANDIDATE_MB_TYPE_INTER_I);",
"VAR_0->f_code= FFMAX3(VAR_0->f_code, VAR_9, VAR_9);",
"}",
"ff_fix_long_p_mvs(VAR_0);",
"ff_fix_long_mvs(VAR_0, NULL, 0, VAR_0->p_mv_table, VAR_0->f_code, CANDIDATE_MB_TYPE_INTER, 0);",
"if(VAR_0->flags & CODEC_FLAG_INTERLACED_ME){",
"int VAR_15;",
"for(VAR_2=0; VAR_2<2; VAR_2++){",
"for(VAR_15=0; VAR_15<2; VAR_15++)",
"ff_fix_long_mvs(VAR_0, VAR_0->p_field_select_table[VAR_2], VAR_15,\nVAR_0->p_field_mv_table[VAR_2][VAR_15], VAR_0->f_code, CANDIDATE_MB_TYPE_INTER_I, 0);",
"}",
"}",
"}",
"if(VAR_0->pict_type==AV_PICTURE_TYPE_B){",
"int VAR_9, VAR_9;",
"VAR_9 = ff_get_best_fcode(VAR_0, VAR_0->b_forw_mv_table, CANDIDATE_MB_TYPE_FORWARD);",
"VAR_9 = ff_get_best_fcode(VAR_0, VAR_0->b_bidir_forw_mv_table, CANDIDATE_MB_TYPE_BIDIR);",
"VAR_0->f_code = FFMAX(VAR_9, VAR_9);",
"VAR_9 = ff_get_best_fcode(VAR_0, VAR_0->b_back_mv_table, CANDIDATE_MB_TYPE_BACKWARD);",
"VAR_9 = ff_get_best_fcode(VAR_0, VAR_0->b_bidir_back_mv_table, CANDIDATE_MB_TYPE_BIDIR);",
"VAR_0->b_code = FFMAX(VAR_9, VAR_9);",
"ff_fix_long_mvs(VAR_0, NULL, 0, VAR_0->b_forw_mv_table, VAR_0->f_code, CANDIDATE_MB_TYPE_FORWARD, 1);",
"ff_fix_long_mvs(VAR_0, NULL, 0, VAR_0->b_back_mv_table, VAR_0->b_code, CANDIDATE_MB_TYPE_BACKWARD, 1);",
"ff_fix_long_mvs(VAR_0, NULL, 0, VAR_0->b_bidir_forw_mv_table, VAR_0->f_code, CANDIDATE_MB_TYPE_BIDIR, 1);",
"ff_fix_long_mvs(VAR_0, NULL, 0, VAR_0->b_bidir_back_mv_table, VAR_0->b_code, CANDIDATE_MB_TYPE_BIDIR, 1);",
"if(VAR_0->flags & CODEC_FLAG_INTERLACED_ME){",
"int VAR_9, VAR_15;",
"for(VAR_9=0; VAR_9<2; VAR_9++){",
"for(VAR_2=0; VAR_2<2; VAR_2++){",
"for(VAR_15=0; VAR_15<2; VAR_15++){",
"int VAR_10= VAR_9 ? (CANDIDATE_MB_TYPE_BACKWARD_I|CANDIDATE_MB_TYPE_BIDIR_I)\n: (CANDIDATE_MB_TYPE_FORWARD_I |CANDIDATE_MB_TYPE_BIDIR_I);",
"ff_fix_long_mvs(VAR_0, VAR_0->b_field_select_table[VAR_9][VAR_2], VAR_15,\nVAR_0->b_field_mv_table[VAR_9][VAR_2][VAR_15], VAR_9 ? VAR_0->b_code : VAR_0->f_code, VAR_10, 1);",
"}",
"}",
"}",
"}",
"}",
"}",
"if (estimate_qp(VAR_0, 0) < 0)\nreturn -1;",
"if(VAR_0->qscale < 3 && VAR_0->max_qcoeff<=128 && VAR_0->pict_type==AV_PICTURE_TYPE_I && !(VAR_0->flags & CODEC_FLAG_QSCALE))\nVAR_0->qscale= 3;",
"if (VAR_0->out_format == FMT_MJPEG) {",
"const uint16_t * VAR_11 = ff_mpeg1_default_intra_matrix;",
"const uint16_t *VAR_12 = ff_mpeg1_default_intra_matrix;",
"if (VAR_0->avctx->intra_matrix) {",
"VAR_12 =\nVAR_11 = VAR_0->avctx->intra_matrix;",
"}",
"if (VAR_0->avctx->chroma_intra_matrix)\nVAR_12 = VAR_0->avctx->chroma_intra_matrix;",
"for(VAR_2=1;VAR_2<64;VAR_2++){",
"int VAR_15= VAR_0->dsp.idct_permutation[VAR_2];",
"VAR_0->chroma_intra_matrix[VAR_15] = av_clip_uint8((VAR_12[VAR_2] * VAR_0->qscale) >> 3);",
"VAR_0-> intra_matrix[VAR_15] = av_clip_uint8(( VAR_11[VAR_2] * VAR_0->qscale) >> 3);",
"}",
"VAR_0->y_dc_scale_table=\nVAR_0->c_dc_scale_table= ff_mpeg2_dc_scale_table[VAR_0->intra_dc_precision];",
"VAR_0->chroma_intra_matrix[0] =\nVAR_0->intra_matrix[0] = ff_mpeg2_dc_scale_table[VAR_0->intra_dc_precision][8];",
"ff_convert_matrix(&VAR_0->dsp, VAR_0->q_intra_matrix, VAR_0->q_intra_matrix16,\nVAR_0->intra_matrix, VAR_0->intra_quant_bias, 8, 8, 1);",
"ff_convert_matrix(&VAR_0->dsp, VAR_0->q_chroma_intra_matrix, VAR_0->q_chroma_intra_matrix16,\nVAR_0->chroma_intra_matrix, VAR_0->intra_quant_bias, 8, 8, 1);",
"VAR_0->qscale= 8;",
"}",
"if(VAR_0->codec_id == AV_CODEC_ID_AMV){",
"static const uint8_t VAR_13[32]={13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13};",
"static const uint8_t VAR_14[32]={14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14};",
"for(VAR_2=1;VAR_2<64;VAR_2++){",
"int VAR_15= VAR_0->dsp.idct_permutation[ff_zigzag_direct[VAR_2]];",
"VAR_0->intra_matrix[VAR_15] = sp5x_quant_table[5*2+0][VAR_2];",
"VAR_0->chroma_intra_matrix[VAR_15] = sp5x_quant_table[5*2+1][VAR_2];",
"}",
"VAR_0->y_dc_scale_table= VAR_13;",
"VAR_0->c_dc_scale_table= VAR_14;",
"VAR_0->intra_matrix[0] = 13;",
"VAR_0->chroma_intra_matrix[0] = 14;",
"ff_convert_matrix(&VAR_0->dsp, VAR_0->q_intra_matrix, VAR_0->q_intra_matrix16,\nVAR_0->intra_matrix, VAR_0->intra_quant_bias, 8, 8, 1);",
"ff_convert_matrix(&VAR_0->dsp, VAR_0->q_chroma_intra_matrix, VAR_0->q_chroma_intra_matrix16,\nVAR_0->chroma_intra_matrix, VAR_0->intra_quant_bias, 8, 8, 1);",
"VAR_0->qscale= 8;",
"}",
"VAR_0->current_picture_ptr->f.key_frame =\nVAR_0->current_picture.f.key_frame = VAR_0->pict_type == AV_PICTURE_TYPE_I;",
"VAR_0->current_picture_ptr->f.pict_type =\nVAR_0->current_picture.f.pict_type = VAR_0->pict_type;",
"if (VAR_0->current_picture.f.key_frame)\nVAR_0->picture_in_gop_number=0;",
"VAR_0->mb_x = VAR_0->mb_y = 0;",
"VAR_0->last_bits= put_bits_count(&VAR_0->pb);",
"switch(VAR_0->out_format) {",
"case FMT_MJPEG:\nif (CONFIG_MJPEG_ENCODER)\nff_mjpeg_encode_picture_header(VAR_0->avctx, &VAR_0->pb, &VAR_0->intra_scantable,\nVAR_0->intra_matrix, VAR_0->chroma_intra_matrix);",
"break;",
"case FMT_H261:\nif (CONFIG_H261_ENCODER)\nff_h261_encode_picture_header(VAR_0, VAR_1);",
"break;",
"case FMT_H263:\nif (CONFIG_WMV2_ENCODER && VAR_0->codec_id == AV_CODEC_ID_WMV2)\nff_wmv2_encode_picture_header(VAR_0, VAR_1);",
"else if (CONFIG_MSMPEG4_ENCODER && VAR_0->msmpeg4_version)\nff_msmpeg4_encode_picture_header(VAR_0, VAR_1);",
"else if (CONFIG_MPEG4_ENCODER && VAR_0->h263_pred)\nff_mpeg4_encode_picture_header(VAR_0, VAR_1);",
"else if (CONFIG_RV10_ENCODER && VAR_0->codec_id == AV_CODEC_ID_RV10)\nff_rv10_encode_picture_header(VAR_0, VAR_1);",
"else if (CONFIG_RV20_ENCODER && VAR_0->codec_id == AV_CODEC_ID_RV20)\nff_rv20_encode_picture_header(VAR_0, VAR_1);",
"else if (CONFIG_FLV_ENCODER && VAR_0->codec_id == AV_CODEC_ID_FLV1)\nff_flv_encode_picture_header(VAR_0, VAR_1);",
"else if (CONFIG_H263_ENCODER)\nff_h263_encode_picture_header(VAR_0, VAR_1);",
"break;",
"case FMT_MPEG1:\nif (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER)\nff_mpeg1_encode_picture_header(VAR_0, VAR_1);",
"break;",
"default:\nav_assert0(0);",
"}",
"VAR_4= put_bits_count(&VAR_0->pb);",
"VAR_0->header_bits= VAR_4 - VAR_0->last_bits;",
"for(VAR_2=1; VAR_2<VAR_5; VAR_2++){",
"update_duplicate_context_after_me(VAR_0->thread_context[VAR_2], VAR_0);",
"}",
"VAR_0->avctx->execute(VAR_0->avctx, encode_thread, &VAR_0->thread_context[0], NULL, VAR_5, sizeof(void*));",
"for(VAR_2=1; VAR_2<VAR_5; VAR_2++){",
"merge_context_after_encode(VAR_0, VAR_0->thread_context[VAR_2]);",
"}",
"emms_c();",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
19,
21
],
[
29,
31
],
[
33,
35
],
[
39
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73,
75
],
[
77,
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107,
109
],
[
111
],
[
115,
117
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
147
],
[
149
],
[
153
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185,
187
],
[
189,
191
],
[
193
],
[
197
],
[
199
],
[
201
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231,
233
],
[
235
],
[
237
],
[
239
],
[
243
],
[
245
],
[
249
],
[
251
],
[
253
],
[
257
],
[
259
],
[
261
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283,
285
],
[
287,
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
305,
307
],
[
311,
313
],
[
317
],
[
319
],
[
321
],
[
325
],
[
327,
329
],
[
331
],
[
333,
335
],
[
341
],
[
343
],
[
347
],
[
349
],
[
351
],
[
353,
355
],
[
357,
359
],
[
361,
363
],
[
365,
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399,
401
],
[
403,
405
],
[
407
],
[
409
],
[
415,
417
],
[
419,
421
],
[
425,
427
],
[
431
],
[
433
],
[
435
],
[
437,
439,
441,
443
],
[
445
],
[
447,
449,
451
],
[
453
],
[
455,
457,
459
],
[
461,
463
],
[
465,
467
],
[
469,
471
],
[
473,
475
],
[
477,
479
],
[
481,
483
],
[
485
],
[
487,
489,
491
],
[
493
],
[
495,
497
],
[
499
],
[
501
],
[
503
],
[
507
],
[
509
],
[
511
],
[
513
],
[
515
],
[
517
],
[
519
],
[
521
],
[
523
],
[
525
]
] |
1,821 | static inline int compare_masked(uint64_t x, uint64_t y, uint64_t mask)
{
return (x & mask) == (y & mask);
}
| true | qemu | 299b520cd4092be3c53f8380b81315c33927d9d3 | static inline int compare_masked(uint64_t x, uint64_t y, uint64_t mask)
{
return (x & mask) == (y & mask);
}
| {
"code": [
"static inline int compare_masked(uint64_t x, uint64_t y, uint64_t mask)",
" return (x & mask) == (y & mask);"
],
"line_no": [
1,
5
]
} | static inline int FUNC_0(uint64_t VAR_0, uint64_t VAR_1, uint64_t VAR_2)
{
return (VAR_0 & VAR_2) == (VAR_1 & VAR_2);
}
| [
"static inline int FUNC_0(uint64_t VAR_0, uint64_t VAR_1, uint64_t VAR_2)\n{",
"return (VAR_0 & VAR_2) == (VAR_1 & VAR_2);",
"}"
] | [
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
1,823 | static int asf_build_simple_index(AVFormatContext *s, int stream_index)
{
ff_asf_guid g;
ASFContext *asf = s->priv_data;
int64_t current_pos = avio_tell(s->pb);
int64_t ret;
if((ret = avio_seek(s->pb, asf->data_object_offset + asf->data_object_size, SEEK_SET)) < 0) {
return ret;
if ((ret = ff_get_guid(s->pb, &g)) < 0)
/* the data object can be followed by other top-level objects,
* skip them until the simple index object is reached */
while (ff_guidcmp(&g, &ff_asf_simple_index_header)) {
int64_t gsize = avio_rl64(s->pb);
if (gsize < 24 || avio_feof(s->pb)) {
avio_skip(s->pb, gsize - 24);
if ((ret = ff_get_guid(s->pb, &g)) < 0)
{
int64_t itime, last_pos = -1;
int pct, ict;
int i;
int64_t av_unused gsize = avio_rl64(s->pb);
if ((ret = ff_get_guid(s->pb, &g)) < 0)
itime = avio_rl64(s->pb);
pct = avio_rl32(s->pb);
ict = avio_rl32(s->pb);
av_log(s, AV_LOG_DEBUG,
"itime:0x%"PRIx64", pct:%d, ict:%d\n", itime, pct, ict);
for (i = 0; i < ict; i++) {
int pktnum = avio_rl32(s->pb);
int pktct = avio_rl16(s->pb);
int64_t pos = s->internal->data_offset + s->packet_size * (int64_t)pktnum;
int64_t index_pts = FFMAX(av_rescale(itime, i, 10000) - asf->hdr.preroll, 0);
if (pos != last_pos) {
av_log(s, AV_LOG_DEBUG, "pktnum:%d, pktct:%d pts: %"PRId64"\n",
pktnum, pktct, index_pts);
av_add_index_entry(s->streams[stream_index], pos, index_pts,
s->packet_size, 0, AVINDEX_KEYFRAME);
last_pos = pos;
asf->index_read = ict > 1;
end:
// if (avio_feof(s->pb)) {
// ret = 0;
// }
avio_seek(s->pb, current_pos, SEEK_SET);
return ret; | true | FFmpeg | afc9c683ed9db01edb357bc8c19edad4282b3a97 | static int asf_build_simple_index(AVFormatContext *s, int stream_index)
{
ff_asf_guid g;
ASFContext *asf = s->priv_data;
int64_t current_pos = avio_tell(s->pb);
int64_t ret;
if((ret = avio_seek(s->pb, asf->data_object_offset + asf->data_object_size, SEEK_SET)) < 0) {
return ret;
if ((ret = ff_get_guid(s->pb, &g)) < 0)
while (ff_guidcmp(&g, &ff_asf_simple_index_header)) {
int64_t gsize = avio_rl64(s->pb);
if (gsize < 24 || avio_feof(s->pb)) {
avio_skip(s->pb, gsize - 24);
if ((ret = ff_get_guid(s->pb, &g)) < 0)
{
int64_t itime, last_pos = -1;
int pct, ict;
int i;
int64_t av_unused gsize = avio_rl64(s->pb);
if ((ret = ff_get_guid(s->pb, &g)) < 0)
itime = avio_rl64(s->pb);
pct = avio_rl32(s->pb);
ict = avio_rl32(s->pb);
av_log(s, AV_LOG_DEBUG,
"itime:0x%"PRIx64", pct:%d, ict:%d\n", itime, pct, ict);
for (i = 0; i < ict; i++) {
int pktnum = avio_rl32(s->pb);
int pktct = avio_rl16(s->pb);
int64_t pos = s->internal->data_offset + s->packet_size * (int64_t)pktnum;
int64_t index_pts = FFMAX(av_rescale(itime, i, 10000) - asf->hdr.preroll, 0);
if (pos != last_pos) {
av_log(s, AV_LOG_DEBUG, "pktnum:%d, pktct:%d pts: %"PRId64"\n",
pktnum, pktct, index_pts);
av_add_index_entry(s->streams[stream_index], pos, index_pts,
s->packet_size, 0, AVINDEX_KEYFRAME);
last_pos = pos;
asf->index_read = ict > 1;
end:
avio_seek(s->pb, current_pos, SEEK_SET);
return ret; | {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, int VAR_1)
{
ff_asf_guid g;
ASFContext *asf = VAR_0->priv_data;
int64_t current_pos = avio_tell(VAR_0->pb);
int64_t ret;
if((ret = avio_seek(VAR_0->pb, asf->data_object_offset + asf->data_object_size, SEEK_SET)) < 0) {
return ret;
if ((ret = ff_get_guid(VAR_0->pb, &g)) < 0)
while (ff_guidcmp(&g, &ff_asf_simple_index_header)) {
int64_t gsize = avio_rl64(VAR_0->pb);
if (gsize < 24 || avio_feof(VAR_0->pb)) {
avio_skip(VAR_0->pb, gsize - 24);
if ((ret = ff_get_guid(VAR_0->pb, &g)) < 0)
{
int64_t itime, last_pos = -1;
int VAR_2, VAR_3;
int VAR_4;
int64_t av_unused gsize = avio_rl64(VAR_0->pb);
if ((ret = ff_get_guid(VAR_0->pb, &g)) < 0)
itime = avio_rl64(VAR_0->pb);
VAR_2 = avio_rl32(VAR_0->pb);
VAR_3 = avio_rl32(VAR_0->pb);
av_log(VAR_0, AV_LOG_DEBUG,
"itime:0x%"PRIx64", VAR_2:%d, VAR_3:%d\n", itime, VAR_2, VAR_3);
for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) {
int VAR_5 = avio_rl32(VAR_0->pb);
int VAR_6 = avio_rl16(VAR_0->pb);
int64_t pos = VAR_0->internal->data_offset + VAR_0->packet_size * (int64_t)VAR_5;
int64_t index_pts = FFMAX(av_rescale(itime, VAR_4, 10000) - asf->hdr.preroll, 0);
if (pos != last_pos) {
av_log(VAR_0, AV_LOG_DEBUG, "VAR_5:%d, VAR_6:%d pts: %"PRId64"\n",
VAR_5, VAR_6, index_pts);
av_add_index_entry(VAR_0->streams[VAR_1], pos, index_pts,
VAR_0->packet_size, 0, AVINDEX_KEYFRAME);
last_pos = pos;
asf->index_read = VAR_3 > 1;
end:
avio_seek(VAR_0->pb, current_pos, SEEK_SET);
return ret; | [
"static int FUNC_0(AVFormatContext *VAR_0, int VAR_1)\n{",
"ff_asf_guid g;",
"ASFContext *asf = VAR_0->priv_data;",
"int64_t current_pos = avio_tell(VAR_0->pb);",
"int64_t ret;",
"if((ret = avio_seek(VAR_0->pb, asf->data_object_offset + asf->data_object_size, SEEK_SET)) < 0) {",
"return ret;",
"if ((ret = ff_get_guid(VAR_0->pb, &g)) < 0)\nwhile (ff_guidcmp(&g, &ff_asf_simple_index_header)) {",
"int64_t gsize = avio_rl64(VAR_0->pb);",
"if (gsize < 24 || avio_feof(VAR_0->pb)) {",
"avio_skip(VAR_0->pb, gsize - 24);",
"if ((ret = ff_get_guid(VAR_0->pb, &g)) < 0)\n{",
"int64_t itime, last_pos = -1;",
"int VAR_2, VAR_3;",
"int VAR_4;",
"int64_t av_unused gsize = avio_rl64(VAR_0->pb);",
"if ((ret = ff_get_guid(VAR_0->pb, &g)) < 0)\nitime = avio_rl64(VAR_0->pb);",
"VAR_2 = avio_rl32(VAR_0->pb);",
"VAR_3 = avio_rl32(VAR_0->pb);",
"av_log(VAR_0, AV_LOG_DEBUG,\n\"itime:0x%\"PRIx64\", VAR_2:%d, VAR_3:%d\\n\", itime, VAR_2, VAR_3);",
"for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) {",
"int VAR_5 = avio_rl32(VAR_0->pb);",
"int VAR_6 = avio_rl16(VAR_0->pb);",
"int64_t pos = VAR_0->internal->data_offset + VAR_0->packet_size * (int64_t)VAR_5;",
"int64_t index_pts = FFMAX(av_rescale(itime, VAR_4, 10000) - asf->hdr.preroll, 0);",
"if (pos != last_pos) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"VAR_5:%d, VAR_6:%d pts: %\"PRId64\"\\n\",\nVAR_5, VAR_6, index_pts);",
"av_add_index_entry(VAR_0->streams[VAR_1], pos, index_pts,\nVAR_0->packet_size, 0, AVINDEX_KEYFRAME);",
"last_pos = pos;",
"asf->index_read = VAR_3 > 1;",
"end:\navio_seek(VAR_0->pb, current_pos, SEEK_SET);",
"return ret;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9,
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,
44
],
[
45
]
] |
1,824 | static void ppc_cpu_initfn(Object *obj)
{
CPUState *cs = CPU(obj);
PowerPCCPU *cpu = POWERPC_CPU(obj);
PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
CPUPPCState *env = &cpu->env;
cs->env_ptr = env;
cpu_exec_init(env, &error_abort);
cpu->cpu_dt_id = cs->cpu_index;
env->msr_mask = pcc->msr_mask;
env->mmu_model = pcc->mmu_model;
env->excp_model = pcc->excp_model;
env->bus_model = pcc->bus_model;
env->insns_flags = pcc->insns_flags;
env->insns_flags2 = pcc->insns_flags2;
env->flags = pcc->flags;
env->bfd_mach = pcc->bfd_mach;
env->check_pow = pcc->check_pow;
#if defined(TARGET_PPC64)
if (pcc->sps) {
env->sps = *pcc->sps;
} else if (env->mmu_model & POWERPC_MMU_64) {
/* Use default sets of page sizes */
static const struct ppc_segment_page_sizes defsps = {
.sps = {
{ .page_shift = 12, /* 4K */
.slb_enc = 0,
.enc = { { .page_shift = 12, .pte_enc = 0 } }
},
{ .page_shift = 24, /* 16M */
.slb_enc = 0x100,
.enc = { { .page_shift = 24, .pte_enc = 0 } }
},
},
};
env->sps = defsps;
}
#endif /* defined(TARGET_PPC64) */
if (tcg_enabled()) {
ppc_translate_init();
}
}
| true | qemu | 6dd0f8342ddfbd8db3e3de1a17686cedbc14e9f1 | static void ppc_cpu_initfn(Object *obj)
{
CPUState *cs = CPU(obj);
PowerPCCPU *cpu = POWERPC_CPU(obj);
PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
CPUPPCState *env = &cpu->env;
cs->env_ptr = env;
cpu_exec_init(env, &error_abort);
cpu->cpu_dt_id = cs->cpu_index;
env->msr_mask = pcc->msr_mask;
env->mmu_model = pcc->mmu_model;
env->excp_model = pcc->excp_model;
env->bus_model = pcc->bus_model;
env->insns_flags = pcc->insns_flags;
env->insns_flags2 = pcc->insns_flags2;
env->flags = pcc->flags;
env->bfd_mach = pcc->bfd_mach;
env->check_pow = pcc->check_pow;
#if defined(TARGET_PPC64)
if (pcc->sps) {
env->sps = *pcc->sps;
} else if (env->mmu_model & POWERPC_MMU_64) {
static const struct ppc_segment_page_sizes defsps = {
.sps = {
{ .page_shift = 12,
.slb_enc = 0,
.enc = { { .page_shift = 12, .pte_enc = 0 } }
},
{ .page_shift = 24,
.slb_enc = 0x100,
.enc = { { .page_shift = 24, .pte_enc = 0 } }
},
},
};
env->sps = defsps;
}
#endif
if (tcg_enabled()) {
ppc_translate_init();
}
}
| {
"code": [
" cpu_exec_init(env, &error_abort);",
" cpu->cpu_dt_id = cs->cpu_index;"
],
"line_no": [
17,
19
]
} | static void FUNC_0(Object *VAR_0)
{
CPUState *cs = CPU(VAR_0);
PowerPCCPU *cpu = POWERPC_CPU(VAR_0);
PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
CPUPPCState *env = &cpu->env;
cs->env_ptr = env;
cpu_exec_init(env, &error_abort);
cpu->cpu_dt_id = cs->cpu_index;
env->msr_mask = pcc->msr_mask;
env->mmu_model = pcc->mmu_model;
env->excp_model = pcc->excp_model;
env->bus_model = pcc->bus_model;
env->insns_flags = pcc->insns_flags;
env->insns_flags2 = pcc->insns_flags2;
env->flags = pcc->flags;
env->bfd_mach = pcc->bfd_mach;
env->check_pow = pcc->check_pow;
#if defined(TARGET_PPC64)
if (pcc->sps) {
env->sps = *pcc->sps;
} else if (env->mmu_model & POWERPC_MMU_64) {
static const struct ppc_segment_page_sizes defsps = {
.sps = {
{ .page_shift = 12,
.slb_enc = 0,
.enc = { { .page_shift = 12, .pte_enc = 0 } }
},
{ .page_shift = 24,
.slb_enc = 0x100,
.enc = { { .page_shift = 24, .pte_enc = 0 } }
},
},
};
env->sps = defsps;
}
#endif
if (tcg_enabled()) {
ppc_translate_init();
}
}
| [
"static void FUNC_0(Object *VAR_0)\n{",
"CPUState *cs = CPU(VAR_0);",
"PowerPCCPU *cpu = POWERPC_CPU(VAR_0);",
"PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);",
"CPUPPCState *env = &cpu->env;",
"cs->env_ptr = env;",
"cpu_exec_init(env, &error_abort);",
"cpu->cpu_dt_id = cs->cpu_index;",
"env->msr_mask = pcc->msr_mask;",
"env->mmu_model = pcc->mmu_model;",
"env->excp_model = pcc->excp_model;",
"env->bus_model = pcc->bus_model;",
"env->insns_flags = pcc->insns_flags;",
"env->insns_flags2 = pcc->insns_flags2;",
"env->flags = pcc->flags;",
"env->bfd_mach = pcc->bfd_mach;",
"env->check_pow = pcc->check_pow;",
"#if defined(TARGET_PPC64)\nif (pcc->sps) {",
"env->sps = *pcc->sps;",
"} else if (env->mmu_model & POWERPC_MMU_64) {",
"static const struct ppc_segment_page_sizes defsps = {",
".sps = {",
"{ .page_shift = 12,",
".slb_enc = 0,\n.enc = { { .page_shift = 12, .pte_enc = 0 } }",
"},",
"{ .page_shift = 24,",
".slb_enc = 0x100,\n.enc = { { .page_shift = 24, .pte_enc = 0 } }",
"},",
"},",
"};",
"env->sps = defsps;",
"}",
"#endif\nif (tcg_enabled()) {",
"ppc_translate_init();",
"}",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43,
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81,
85
],
[
87
],
[
89
],
[
91
]
] |
1,825 | static void vhost_user_cleanup(NetClientState *nc)
{
VhostUserState *s = DO_UPCAST(VhostUserState, nc, nc);
if (s->vhost_net) {
vhost_net_cleanup(s->vhost_net);
g_free(s->vhost_net);
s->vhost_net = NULL;
if (nc->queue_index == 0) {
qemu_chr_fe_deinit(&s->chr, true);
qemu_purge_queued_packets(nc);
| true | qemu | 41d4e5ec9f77acaca706d00ee4baaf5324274da5 | static void vhost_user_cleanup(NetClientState *nc)
{
VhostUserState *s = DO_UPCAST(VhostUserState, nc, nc);
if (s->vhost_net) {
vhost_net_cleanup(s->vhost_net);
g_free(s->vhost_net);
s->vhost_net = NULL;
if (nc->queue_index == 0) {
qemu_chr_fe_deinit(&s->chr, true);
qemu_purge_queued_packets(nc);
| {
"code": [],
"line_no": []
} | static void FUNC_0(NetClientState *VAR_0)
{
VhostUserState *s = DO_UPCAST(VhostUserState, VAR_0, VAR_0);
if (s->vhost_net) {
vhost_net_cleanup(s->vhost_net);
g_free(s->vhost_net);
s->vhost_net = NULL;
if (VAR_0->queue_index == 0) {
qemu_chr_fe_deinit(&s->chr, true);
qemu_purge_queued_packets(VAR_0);
| [
"static void FUNC_0(NetClientState *VAR_0)\n{",
"VhostUserState *s = DO_UPCAST(VhostUserState, VAR_0, VAR_0);",
"if (s->vhost_net) {",
"vhost_net_cleanup(s->vhost_net);",
"g_free(s->vhost_net);",
"s->vhost_net = NULL;",
"if (VAR_0->queue_index == 0) {",
"qemu_chr_fe_deinit(&s->chr, true);",
"qemu_purge_queued_packets(VAR_0);"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
18
],
[
24
],
[
29
]
] |
1,827 | int av_base64_decode(uint8_t *out, const char *in, int out_size)
{
int i, v;
uint8_t *dst = out;
v = 0;
for (i = 0; in[i] && in[i] != '='; i++) {
unsigned int index= in[i]-43;
if (index>=FF_ARRAY_ELEMS(map2) || map2[index] == 0xff)
return -1;
v = (v << 6) + map2[index];
if (i & 3) {
if (dst - out < out_size) {
*dst++ = v >> (6 - 2 * (i & 3));
}
}
}
return dst - out;
}
| true | FFmpeg | dd3b73f3905c61c99f1d3fb58bc7ee380eb8aa2e | int av_base64_decode(uint8_t *out, const char *in, int out_size)
{
int i, v;
uint8_t *dst = out;
v = 0;
for (i = 0; in[i] && in[i] != '='; i++) {
unsigned int index= in[i]-43;
if (index>=FF_ARRAY_ELEMS(map2) || map2[index] == 0xff)
return -1;
v = (v << 6) + map2[index];
if (i & 3) {
if (dst - out < out_size) {
*dst++ = v >> (6 - 2 * (i & 3));
}
}
}
return dst - out;
}
| {
"code": [
" int i, v;",
" v = 0;"
],
"line_no": [
5,
11
]
} | int FUNC_0(uint8_t *VAR_0, const char *VAR_1, int VAR_2)
{
int VAR_3, VAR_4;
uint8_t *dst = VAR_0;
VAR_4 = 0;
for (VAR_3 = 0; VAR_1[VAR_3] && VAR_1[VAR_3] != '='; VAR_3++) {
unsigned int VAR_5= VAR_1[VAR_3]-43;
if (VAR_5>=FF_ARRAY_ELEMS(map2) || map2[VAR_5] == 0xff)
return -1;
VAR_4 = (VAR_4 << 6) + map2[VAR_5];
if (VAR_3 & 3) {
if (dst - VAR_0 < VAR_2) {
*dst++ = VAR_4 >> (6 - 2 * (VAR_3 & 3));
}
}
}
return dst - VAR_0;
}
| [
"int FUNC_0(uint8_t *VAR_0, const char *VAR_1, int VAR_2)\n{",
"int VAR_3, VAR_4;",
"uint8_t *dst = VAR_0;",
"VAR_4 = 0;",
"for (VAR_3 = 0; VAR_1[VAR_3] && VAR_1[VAR_3] != '='; VAR_3++) {",
"unsigned int VAR_5= VAR_1[VAR_3]-43;",
"if (VAR_5>=FF_ARRAY_ELEMS(map2) || map2[VAR_5] == 0xff)\nreturn -1;",
"VAR_4 = (VAR_4 << 6) + map2[VAR_5];",
"if (VAR_3 & 3) {",
"if (dst - VAR_0 < VAR_2) {",
"*dst++ = VAR_4 >> (6 - 2 * (VAR_3 & 3));",
"}",
"}",
"}",
"return dst - VAR_0;",
"}"
] | [
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17,
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
]
] |
1,828 | static int process_input(int file_index)
{
InputFile *ifile = input_files[file_index];
AVFormatContext *is;
InputStream *ist;
AVPacket pkt;
int ret, i, j;
is = ifile->ctx;
ret = get_input_packet(ifile, &pkt);
if (ret == AVERROR(EAGAIN)) {
ifile->eagain = 1;
return ret;
}
if (ret < 0) {
if (ret != AVERROR_EOF) {
print_error(is->filename, ret);
if (exit_on_error)
exit_program(1);
}
ifile->eof_reached = 1;
for (i = 0; i < ifile->nb_streams; i++) {
ist = input_streams[ifile->ist_index + i];
if (ist->decoding_needed)
output_packet(ist, NULL);
/* mark all outputs that don't go through lavfi as finished */
for (j = 0; j < nb_output_streams; j++) {
OutputStream *ost = output_streams[j];
if (ost->source_index == ifile->ist_index + i &&
(ost->stream_copy || ost->enc->type == AVMEDIA_TYPE_SUBTITLE))
close_output_stream(ost);
}
}
return AVERROR(EAGAIN);
}
reset_eagain();
if (do_pkt_dump) {
av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump,
is->streams[pkt.stream_index]);
}
/* the following test is needed in case new streams appear
dynamically in stream : we ignore them */
if (pkt.stream_index >= ifile->nb_streams) {
report_new_stream(file_index, &pkt);
goto discard_packet;
}
ist = input_streams[ifile->ist_index + pkt.stream_index];
if (ist->discard)
goto discard_packet;
if(!ist->wrap_correction_done && input_files[file_index]->ctx->start_time != AV_NOPTS_VALUE && ist->st->pts_wrap_bits < 64){
uint64_t stime = av_rescale_q(input_files[file_index]->ctx->start_time, AV_TIME_BASE_Q, ist->st->time_base);
uint64_t stime2= stime + (1LL<<ist->st->pts_wrap_bits);
ist->wrap_correction_done = 1;
if(pkt.dts != AV_NOPTS_VALUE && pkt.dts > stime && pkt.dts - stime > stime2 - pkt.dts) {
pkt.dts -= 1LL<<ist->st->pts_wrap_bits;
ist->wrap_correction_done = 0;
}
if(pkt.pts != AV_NOPTS_VALUE && pkt.pts > stime && pkt.pts - stime > stime2 - pkt.pts) {
pkt.pts -= 1LL<<ist->st->pts_wrap_bits;
ist->wrap_correction_done = 0;
}
}
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts *= ist->ts_scale;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts *= ist->ts_scale;
if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "demuxer -> ist_index:%d type:%s "
"next_dts:%s next_dts_time:%s next_pts:%s next_pts_time:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s off:%"PRId64"\n",
ifile->ist_index + pkt.stream_index, av_get_media_type_string(ist->st->codec->codec_type),
av_ts2str(ist->next_dts), av_ts2timestr(ist->next_dts, &AV_TIME_BASE_Q),
av_ts2str(ist->next_pts), av_ts2timestr(ist->next_pts, &AV_TIME_BASE_Q),
av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ist->st->time_base),
av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ist->st->time_base),
input_files[ist->file_index]->ts_offset);
}
if (pkt.dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE &&
!copy_ts) {
int64_t pkt_dts = av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);
int64_t delta = pkt_dts - ist->next_dts;
if (is->iformat->flags & AVFMT_TS_DISCONT) {
if(delta < -1LL*dts_delta_threshold*AV_TIME_BASE ||
(delta > 1LL*dts_delta_threshold*AV_TIME_BASE &&
ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) ||
pkt_dts+1<ist->pts){
ifile->ts_offset -= delta;
av_log(NULL, AV_LOG_DEBUG,
"timestamp discontinuity %"PRId64", new offset= %"PRId64"\n",
delta, ifile->ts_offset);
pkt.dts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
}
} else {
if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE ||
(delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE)
) {
av_log(NULL, AV_LOG_WARNING, "DTS %"PRId64", next:%"PRId64" st:%d invalid dropping\n", pkt.dts, ist->next_dts, pkt.stream_index);
pkt.dts = AV_NOPTS_VALUE;
}
if (pkt.pts != AV_NOPTS_VALUE){
int64_t pkt_pts = av_rescale_q(pkt.pts, ist->st->time_base, AV_TIME_BASE_Q);
delta = pkt_pts - ist->next_dts;
if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE ||
(delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE)
) {
av_log(NULL, AV_LOG_WARNING, "PTS %"PRId64", next:%"PRId64" invalid dropping st:%d\n", pkt.pts, ist->next_dts, pkt.stream_index);
pkt.pts = AV_NOPTS_VALUE;
}
}
}
}
sub2video_heartbeat(ist, pkt.pts);
ret = output_packet(ist, &pkt);
if (ret < 0) {
char buf[128];
av_strerror(ret, buf, sizeof(buf));
av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d: %s\n",
ist->file_index, ist->st->index, buf);
if (exit_on_error)
exit_program(1);
}
discard_packet:
av_free_packet(&pkt);
return 0;
}
| true | FFmpeg | 91c18beb9d670a2f64f3ffbc1d60d443eb2ef858 | static int process_input(int file_index)
{
InputFile *ifile = input_files[file_index];
AVFormatContext *is;
InputStream *ist;
AVPacket pkt;
int ret, i, j;
is = ifile->ctx;
ret = get_input_packet(ifile, &pkt);
if (ret == AVERROR(EAGAIN)) {
ifile->eagain = 1;
return ret;
}
if (ret < 0) {
if (ret != AVERROR_EOF) {
print_error(is->filename, ret);
if (exit_on_error)
exit_program(1);
}
ifile->eof_reached = 1;
for (i = 0; i < ifile->nb_streams; i++) {
ist = input_streams[ifile->ist_index + i];
if (ist->decoding_needed)
output_packet(ist, NULL);
for (j = 0; j < nb_output_streams; j++) {
OutputStream *ost = output_streams[j];
if (ost->source_index == ifile->ist_index + i &&
(ost->stream_copy || ost->enc->type == AVMEDIA_TYPE_SUBTITLE))
close_output_stream(ost);
}
}
return AVERROR(EAGAIN);
}
reset_eagain();
if (do_pkt_dump) {
av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump,
is->streams[pkt.stream_index]);
}
if (pkt.stream_index >= ifile->nb_streams) {
report_new_stream(file_index, &pkt);
goto discard_packet;
}
ist = input_streams[ifile->ist_index + pkt.stream_index];
if (ist->discard)
goto discard_packet;
if(!ist->wrap_correction_done && input_files[file_index]->ctx->start_time != AV_NOPTS_VALUE && ist->st->pts_wrap_bits < 64){
uint64_t stime = av_rescale_q(input_files[file_index]->ctx->start_time, AV_TIME_BASE_Q, ist->st->time_base);
uint64_t stime2= stime + (1LL<<ist->st->pts_wrap_bits);
ist->wrap_correction_done = 1;
if(pkt.dts != AV_NOPTS_VALUE && pkt.dts > stime && pkt.dts - stime > stime2 - pkt.dts) {
pkt.dts -= 1LL<<ist->st->pts_wrap_bits;
ist->wrap_correction_done = 0;
}
if(pkt.pts != AV_NOPTS_VALUE && pkt.pts > stime && pkt.pts - stime > stime2 - pkt.pts) {
pkt.pts -= 1LL<<ist->st->pts_wrap_bits;
ist->wrap_correction_done = 0;
}
}
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts *= ist->ts_scale;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts *= ist->ts_scale;
if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "demuxer -> ist_index:%d type:%s "
"next_dts:%s next_dts_time:%s next_pts:%s next_pts_time:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s off:%"PRId64"\n",
ifile->ist_index + pkt.stream_index, av_get_media_type_string(ist->st->codec->codec_type),
av_ts2str(ist->next_dts), av_ts2timestr(ist->next_dts, &AV_TIME_BASE_Q),
av_ts2str(ist->next_pts), av_ts2timestr(ist->next_pts, &AV_TIME_BASE_Q),
av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ist->st->time_base),
av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ist->st->time_base),
input_files[ist->file_index]->ts_offset);
}
if (pkt.dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE &&
!copy_ts) {
int64_t pkt_dts = av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);
int64_t delta = pkt_dts - ist->next_dts;
if (is->iformat->flags & AVFMT_TS_DISCONT) {
if(delta < -1LL*dts_delta_threshold*AV_TIME_BASE ||
(delta > 1LL*dts_delta_threshold*AV_TIME_BASE &&
ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) ||
pkt_dts+1<ist->pts){
ifile->ts_offset -= delta;
av_log(NULL, AV_LOG_DEBUG,
"timestamp discontinuity %"PRId64", new offset= %"PRId64"\n",
delta, ifile->ts_offset);
pkt.dts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
}
} else {
if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE ||
(delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE)
) {
av_log(NULL, AV_LOG_WARNING, "DTS %"PRId64", next:%"PRId64" st:%d invalid dropping\n", pkt.dts, ist->next_dts, pkt.stream_index);
pkt.dts = AV_NOPTS_VALUE;
}
if (pkt.pts != AV_NOPTS_VALUE){
int64_t pkt_pts = av_rescale_q(pkt.pts, ist->st->time_base, AV_TIME_BASE_Q);
delta = pkt_pts - ist->next_dts;
if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE ||
(delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE)
) {
av_log(NULL, AV_LOG_WARNING, "PTS %"PRId64", next:%"PRId64" invalid dropping st:%d\n", pkt.pts, ist->next_dts, pkt.stream_index);
pkt.pts = AV_NOPTS_VALUE;
}
}
}
}
sub2video_heartbeat(ist, pkt.pts);
ret = output_packet(ist, &pkt);
if (ret < 0) {
char buf[128];
av_strerror(ret, buf, sizeof(buf));
av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d: %s\n",
ist->file_index, ist->st->index, buf);
if (exit_on_error)
exit_program(1);
}
discard_packet:
av_free_packet(&pkt);
return 0;
}
| {
"code": [
" uint64_t stime = av_rescale_q(input_files[file_index]->ctx->start_time, AV_TIME_BASE_Q, ist->st->time_base);",
" uint64_t stime2= stime + (1LL<<ist->st->pts_wrap_bits);",
" if(pkt.dts != AV_NOPTS_VALUE && pkt.dts > stime && pkt.dts - stime > stime2 - pkt.dts) {",
" pkt.dts -= 1LL<<ist->st->pts_wrap_bits;",
" if(pkt.pts != AV_NOPTS_VALUE && pkt.pts > stime && pkt.pts - stime > stime2 - pkt.pts) {",
" pkt.pts -= 1LL<<ist->st->pts_wrap_bits;"
],
"line_no": [
119,
121,
125,
127,
133,
135
]
} | static int FUNC_0(int VAR_0)
{
InputFile *ifile = input_files[VAR_0];
AVFormatContext *is;
InputStream *ist;
AVPacket pkt;
int VAR_1, VAR_2, VAR_3;
is = ifile->ctx;
VAR_1 = get_input_packet(ifile, &pkt);
if (VAR_1 == AVERROR(EAGAIN)) {
ifile->eagain = 1;
return VAR_1;
}
if (VAR_1 < 0) {
if (VAR_1 != AVERROR_EOF) {
print_error(is->filename, VAR_1);
if (exit_on_error)
exit_program(1);
}
ifile->eof_reached = 1;
for (VAR_2 = 0; VAR_2 < ifile->nb_streams; VAR_2++) {
ist = input_streams[ifile->ist_index + VAR_2];
if (ist->decoding_needed)
output_packet(ist, NULL);
for (VAR_3 = 0; VAR_3 < nb_output_streams; VAR_3++) {
OutputStream *ost = output_streams[VAR_3];
if (ost->source_index == ifile->ist_index + VAR_2 &&
(ost->stream_copy || ost->enc->type == AVMEDIA_TYPE_SUBTITLE))
close_output_stream(ost);
}
}
return AVERROR(EAGAIN);
}
reset_eagain();
if (do_pkt_dump) {
av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump,
is->streams[pkt.stream_index]);
}
if (pkt.stream_index >= ifile->nb_streams) {
report_new_stream(VAR_0, &pkt);
goto discard_packet;
}
ist = input_streams[ifile->ist_index + pkt.stream_index];
if (ist->discard)
goto discard_packet;
if(!ist->wrap_correction_done && input_files[VAR_0]->ctx->start_time != AV_NOPTS_VALUE && ist->st->pts_wrap_bits < 64){
uint64_t stime = av_rescale_q(input_files[VAR_0]->ctx->start_time, AV_TIME_BASE_Q, ist->st->time_base);
uint64_t stime2= stime + (1LL<<ist->st->pts_wrap_bits);
ist->wrap_correction_done = 1;
if(pkt.dts != AV_NOPTS_VALUE && pkt.dts > stime && pkt.dts - stime > stime2 - pkt.dts) {
pkt.dts -= 1LL<<ist->st->pts_wrap_bits;
ist->wrap_correction_done = 0;
}
if(pkt.pts != AV_NOPTS_VALUE && pkt.pts > stime && pkt.pts - stime > stime2 - pkt.pts) {
pkt.pts -= 1LL<<ist->st->pts_wrap_bits;
ist->wrap_correction_done = 0;
}
}
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts *= ist->ts_scale;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts *= ist->ts_scale;
if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "demuxer -> ist_index:%d type:%s "
"next_dts:%s next_dts_time:%s next_pts:%s next_pts_time:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s off:%"PRId64"\n",
ifile->ist_index + pkt.stream_index, av_get_media_type_string(ist->st->codec->codec_type),
av_ts2str(ist->next_dts), av_ts2timestr(ist->next_dts, &AV_TIME_BASE_Q),
av_ts2str(ist->next_pts), av_ts2timestr(ist->next_pts, &AV_TIME_BASE_Q),
av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ist->st->time_base),
av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ist->st->time_base),
input_files[ist->VAR_0]->ts_offset);
}
if (pkt.dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE &&
!copy_ts) {
int64_t pkt_dts = av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);
int64_t delta = pkt_dts - ist->next_dts;
if (is->iformat->flags & AVFMT_TS_DISCONT) {
if(delta < -1LL*dts_delta_threshold*AV_TIME_BASE ||
(delta > 1LL*dts_delta_threshold*AV_TIME_BASE &&
ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) ||
pkt_dts+1<ist->pts){
ifile->ts_offset -= delta;
av_log(NULL, AV_LOG_DEBUG,
"timestamp discontinuity %"PRId64", new offset= %"PRId64"\n",
delta, ifile->ts_offset);
pkt.dts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
}
} else {
if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE ||
(delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE)
) {
av_log(NULL, AV_LOG_WARNING, "DTS %"PRId64", next:%"PRId64" st:%d invalid dropping\n", pkt.dts, ist->next_dts, pkt.stream_index);
pkt.dts = AV_NOPTS_VALUE;
}
if (pkt.pts != AV_NOPTS_VALUE){
int64_t pkt_pts = av_rescale_q(pkt.pts, ist->st->time_base, AV_TIME_BASE_Q);
delta = pkt_pts - ist->next_dts;
if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE ||
(delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE)
) {
av_log(NULL, AV_LOG_WARNING, "PTS %"PRId64", next:%"PRId64" invalid dropping st:%d\n", pkt.pts, ist->next_dts, pkt.stream_index);
pkt.pts = AV_NOPTS_VALUE;
}
}
}
}
sub2video_heartbeat(ist, pkt.pts);
VAR_1 = output_packet(ist, &pkt);
if (VAR_1 < 0) {
char VAR_4[128];
av_strerror(VAR_1, VAR_4, sizeof(VAR_4));
av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d: %s\n",
ist->VAR_0, ist->st->index, VAR_4);
if (exit_on_error)
exit_program(1);
}
discard_packet:
av_free_packet(&pkt);
return 0;
}
| [
"static int FUNC_0(int VAR_0)\n{",
"InputFile *ifile = input_files[VAR_0];",
"AVFormatContext *is;",
"InputStream *ist;",
"AVPacket pkt;",
"int VAR_1, VAR_2, VAR_3;",
"is = ifile->ctx;",
"VAR_1 = get_input_packet(ifile, &pkt);",
"if (VAR_1 == AVERROR(EAGAIN)) {",
"ifile->eagain = 1;",
"return VAR_1;",
"}",
"if (VAR_1 < 0) {",
"if (VAR_1 != AVERROR_EOF) {",
"print_error(is->filename, VAR_1);",
"if (exit_on_error)\nexit_program(1);",
"}",
"ifile->eof_reached = 1;",
"for (VAR_2 = 0; VAR_2 < ifile->nb_streams; VAR_2++) {",
"ist = input_streams[ifile->ist_index + VAR_2];",
"if (ist->decoding_needed)\noutput_packet(ist, NULL);",
"for (VAR_3 = 0; VAR_3 < nb_output_streams; VAR_3++) {",
"OutputStream *ost = output_streams[VAR_3];",
"if (ost->source_index == ifile->ist_index + VAR_2 &&\n(ost->stream_copy || ost->enc->type == AVMEDIA_TYPE_SUBTITLE))\nclose_output_stream(ost);",
"}",
"}",
"return AVERROR(EAGAIN);",
"}",
"reset_eagain();",
"if (do_pkt_dump) {",
"av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump,\nis->streams[pkt.stream_index]);",
"}",
"if (pkt.stream_index >= ifile->nb_streams) {",
"report_new_stream(VAR_0, &pkt);",
"goto discard_packet;",
"}",
"ist = input_streams[ifile->ist_index + pkt.stream_index];",
"if (ist->discard)\ngoto discard_packet;",
"if(!ist->wrap_correction_done && input_files[VAR_0]->ctx->start_time != AV_NOPTS_VALUE && ist->st->pts_wrap_bits < 64){",
"uint64_t stime = av_rescale_q(input_files[VAR_0]->ctx->start_time, AV_TIME_BASE_Q, ist->st->time_base);",
"uint64_t stime2= stime + (1LL<<ist->st->pts_wrap_bits);",
"ist->wrap_correction_done = 1;",
"if(pkt.dts != AV_NOPTS_VALUE && pkt.dts > stime && pkt.dts - stime > stime2 - pkt.dts) {",
"pkt.dts -= 1LL<<ist->st->pts_wrap_bits;",
"ist->wrap_correction_done = 0;",
"}",
"if(pkt.pts != AV_NOPTS_VALUE && pkt.pts > stime && pkt.pts - stime > stime2 - pkt.pts) {",
"pkt.pts -= 1LL<<ist->st->pts_wrap_bits;",
"ist->wrap_correction_done = 0;",
"}",
"}",
"if (pkt.dts != AV_NOPTS_VALUE)\npkt.dts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);",
"if (pkt.pts != AV_NOPTS_VALUE)\npkt.pts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);",
"if (pkt.pts != AV_NOPTS_VALUE)\npkt.pts *= ist->ts_scale;",
"if (pkt.dts != AV_NOPTS_VALUE)\npkt.dts *= ist->ts_scale;",
"if (debug_ts) {",
"av_log(NULL, AV_LOG_INFO, \"demuxer -> ist_index:%d type:%s \"\n\"next_dts:%s next_dts_time:%s next_pts:%s next_pts_time:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s off:%\"PRId64\"\\n\",\nifile->ist_index + pkt.stream_index, av_get_media_type_string(ist->st->codec->codec_type),\nav_ts2str(ist->next_dts), av_ts2timestr(ist->next_dts, &AV_TIME_BASE_Q),\nav_ts2str(ist->next_pts), av_ts2timestr(ist->next_pts, &AV_TIME_BASE_Q),\nav_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ist->st->time_base),\nav_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ist->st->time_base),\ninput_files[ist->VAR_0]->ts_offset);",
"}",
"if (pkt.dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE &&\n!copy_ts) {",
"int64_t pkt_dts = av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);",
"int64_t delta = pkt_dts - ist->next_dts;",
"if (is->iformat->flags & AVFMT_TS_DISCONT) {",
"if(delta < -1LL*dts_delta_threshold*AV_TIME_BASE ||\n(delta > 1LL*dts_delta_threshold*AV_TIME_BASE &&\nist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) ||\npkt_dts+1<ist->pts){",
"ifile->ts_offset -= delta;",
"av_log(NULL, AV_LOG_DEBUG,\n\"timestamp discontinuity %\"PRId64\", new offset= %\"PRId64\"\\n\",\ndelta, ifile->ts_offset);",
"pkt.dts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);",
"if (pkt.pts != AV_NOPTS_VALUE)\npkt.pts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);",
"}",
"} else {",
"if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE ||\n(delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE)\n) {",
"av_log(NULL, AV_LOG_WARNING, \"DTS %\"PRId64\", next:%\"PRId64\" st:%d invalid dropping\\n\", pkt.dts, ist->next_dts, pkt.stream_index);",
"pkt.dts = AV_NOPTS_VALUE;",
"}",
"if (pkt.pts != AV_NOPTS_VALUE){",
"int64_t pkt_pts = av_rescale_q(pkt.pts, ist->st->time_base, AV_TIME_BASE_Q);",
"delta = pkt_pts - ist->next_dts;",
"if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE ||\n(delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE)\n) {",
"av_log(NULL, AV_LOG_WARNING, \"PTS %\"PRId64\", next:%\"PRId64\" invalid dropping st:%d\\n\", pkt.pts, ist->next_dts, pkt.stream_index);",
"pkt.pts = AV_NOPTS_VALUE;",
"}",
"}",
"}",
"}",
"sub2video_heartbeat(ist, pkt.pts);",
"VAR_1 = output_packet(ist, &pkt);",
"if (VAR_1 < 0) {",
"char VAR_4[128];",
"av_strerror(VAR_1, VAR_4, sizeof(VAR_4));",
"av_log(NULL, AV_LOG_ERROR, \"Error while decoding stream #%d:%d: %s\\n\",\nist->VAR_0, ist->st->index, VAR_4);",
"if (exit_on_error)\nexit_program(1);",
"}",
"discard_packet:\nav_free_packet(&pkt);",
"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,
1,
1,
0,
1,
1,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51,
53
],
[
59
],
[
61
],
[
65,
67,
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
83
],
[
87
],
[
89,
91
],
[
93
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111,
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
145,
147
],
[
149,
151
],
[
155,
157
],
[
159,
161
],
[
165
],
[
167,
169,
171,
173,
175,
177,
179,
181
],
[
183
],
[
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
],
[
261
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273,
275
],
[
277,
279
],
[
281
],
[
285,
287
],
[
291
],
[
293
]
] |
1,829 | void visit_type_int8(Visitor *v, int8_t *obj, const char *name, Error **errp)
{
int64_t value;
if (!error_is_set(errp)) {
if (v->type_int8) {
v->type_int8(v, obj, name, errp);
} else {
value = *obj;
v->type_int(v, &value, name, errp);
if (value < INT8_MIN || value > INT8_MAX) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
"int8_t");
return;
}
*obj = value;
}
}
}
| true | qemu | 297a3646c2947ee64a6d42ca264039732c6218e0 | void visit_type_int8(Visitor *v, int8_t *obj, const char *name, Error **errp)
{
int64_t value;
if (!error_is_set(errp)) {
if (v->type_int8) {
v->type_int8(v, obj, name, errp);
} else {
value = *obj;
v->type_int(v, &value, name, errp);
if (value < INT8_MIN || value > INT8_MAX) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
"int8_t");
return;
}
*obj = value;
}
}
}
| {
"code": [
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" } else {",
" value = *obj;",
" v->type_int(v, &value, name, errp);",
" error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : \"null\",",
" *obj = value;",
" if (!error_is_set(errp)) {",
" } else {",
" value = *obj;",
" v->type_int(v, &value, name, errp);",
" error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : \"null\",",
" *obj = value;",
" if (!error_is_set(errp)) {",
" } else {",
" value = *obj;",
" v->type_int(v, &value, name, errp);",
" error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : \"null\",",
" *obj = value;",
" if (!error_is_set(errp)) {",
" } else {",
" value = *obj;",
" v->type_int(v, &value, name, errp);",
" *obj = value;",
" if (!error_is_set(errp)) {",
" if (v->type_int8) {",
" v->type_int8(v, obj, name, errp);",
" } else {",
" value = *obj;",
" v->type_int(v, &value, name, errp);",
" if (value < INT8_MIN || value > INT8_MAX) {",
" error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : \"null\",",
" \"int8_t\");",
" *obj = value;",
" if (!error_is_set(errp)) {",
" } else {",
" value = *obj;",
" v->type_int(v, &value, name, errp);",
" error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : \"null\",",
" *obj = value;",
" if (!error_is_set(errp)) {",
" } else {",
" value = *obj;",
" v->type_int(v, &value, name, errp);",
" error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : \"null\",",
" *obj = value;",
" if (!error_is_set(errp)) {",
" } else {",
" if (!error_is_set(errp)) {",
" } else {",
" value = *obj;",
" v->type_int(v, &value, name, errp);",
" *obj = value;",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {"
],
"line_no": [
7,
7,
7,
7,
7,
7,
13,
15,
17,
21,
29,
7,
13,
15,
17,
21,
29,
7,
13,
15,
17,
21,
29,
7,
13,
15,
17,
29,
7,
9,
11,
13,
15,
17,
19,
21,
23,
29,
7,
13,
15,
17,
21,
29,
7,
13,
15,
17,
21,
29,
7,
13,
7,
13,
15,
17,
29,
7,
7,
7,
7,
7,
7,
7
]
} | void FUNC_0(Visitor *VAR_0, int8_t *VAR_1, const char *VAR_2, Error **VAR_3)
{
int64_t value;
if (!error_is_set(VAR_3)) {
if (VAR_0->type_int8) {
VAR_0->type_int8(VAR_0, VAR_1, VAR_2, VAR_3);
} else {
value = *VAR_1;
VAR_0->type_int(VAR_0, &value, VAR_2, VAR_3);
if (value < INT8_MIN || value > INT8_MAX) {
error_set(VAR_3, QERR_INVALID_PARAMETER_VALUE, VAR_2 ? VAR_2 : "null",
"int8_t");
return;
}
*VAR_1 = value;
}
}
}
| [
"void FUNC_0(Visitor *VAR_0, int8_t *VAR_1, const char *VAR_2, Error **VAR_3)\n{",
"int64_t value;",
"if (!error_is_set(VAR_3)) {",
"if (VAR_0->type_int8) {",
"VAR_0->type_int8(VAR_0, VAR_1, VAR_2, VAR_3);",
"} else {",
"value = *VAR_1;",
"VAR_0->type_int(VAR_0, &value, VAR_2, VAR_3);",
"if (value < INT8_MIN || value > INT8_MAX) {",
"error_set(VAR_3, QERR_INVALID_PARAMETER_VALUE, VAR_2 ? VAR_2 : \"null\",\n\"int8_t\");",
"return;",
"}",
"*VAR_1 = value;",
"}",
"}",
"}"
] | [
0,
0,
1,
1,
1,
0,
1,
1,
1,
1,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
]
] |
1,831 | static void roq_encode_video(RoqContext *enc)
{
RoqTempdata *tempData = enc->tmpData;
int i;
memset(tempData, 0, sizeof(*tempData));
create_cel_evals(enc, tempData);
generate_new_codebooks(enc, tempData);
if (enc->framesSinceKeyframe >= 1) {
motion_search(enc, 8);
motion_search(enc, 4);
}
retry_encode:
for (i=0; i<enc->width*enc->height/64; i++)
gather_data_for_cel(tempData->cel_evals + i, enc, tempData);
/* Quake 3 can't handle chunks bigger than 65536 bytes */
if (tempData->mainChunkSize/8 > 65536) {
enc->lambda *= .8;
goto retry_encode;
}
remap_codebooks(enc, tempData);
write_codebooks(enc, tempData);
reconstruct_and_encode_image(enc, tempData, enc->width, enc->height,
enc->width*enc->height/64);
enc->avctx->coded_frame = enc->current_frame;
/* Rotate frame history */
FFSWAP(AVFrame *, enc->current_frame, enc->last_frame);
FFSWAP(motion_vect *, enc->last_motion4, enc->this_motion4);
FFSWAP(motion_vect *, enc->last_motion8, enc->this_motion8);
av_free(tempData->cel_evals);
av_free(tempData->closest_cb2);
enc->framesSinceKeyframe++;
}
| false | FFmpeg | ee26abf2a4884bb56959bac8215758195776c553 | static void roq_encode_video(RoqContext *enc)
{
RoqTempdata *tempData = enc->tmpData;
int i;
memset(tempData, 0, sizeof(*tempData));
create_cel_evals(enc, tempData);
generate_new_codebooks(enc, tempData);
if (enc->framesSinceKeyframe >= 1) {
motion_search(enc, 8);
motion_search(enc, 4);
}
retry_encode:
for (i=0; i<enc->width*enc->height/64; i++)
gather_data_for_cel(tempData->cel_evals + i, enc, tempData);
if (tempData->mainChunkSize/8 > 65536) {
enc->lambda *= .8;
goto retry_encode;
}
remap_codebooks(enc, tempData);
write_codebooks(enc, tempData);
reconstruct_and_encode_image(enc, tempData, enc->width, enc->height,
enc->width*enc->height/64);
enc->avctx->coded_frame = enc->current_frame;
FFSWAP(AVFrame *, enc->current_frame, enc->last_frame);
FFSWAP(motion_vect *, enc->last_motion4, enc->this_motion4);
FFSWAP(motion_vect *, enc->last_motion8, enc->this_motion8);
av_free(tempData->cel_evals);
av_free(tempData->closest_cb2);
enc->framesSinceKeyframe++;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(RoqContext *VAR_0)
{
RoqTempdata *tempData = VAR_0->tmpData;
int VAR_1;
memset(tempData, 0, sizeof(*tempData));
create_cel_evals(VAR_0, tempData);
generate_new_codebooks(VAR_0, tempData);
if (VAR_0->framesSinceKeyframe >= 1) {
motion_search(VAR_0, 8);
motion_search(VAR_0, 4);
}
retry_encode:
for (VAR_1=0; VAR_1<VAR_0->width*VAR_0->height/64; VAR_1++)
gather_data_for_cel(tempData->cel_evals + VAR_1, VAR_0, tempData);
if (tempData->mainChunkSize/8 > 65536) {
VAR_0->lambda *= .8;
goto retry_encode;
}
remap_codebooks(VAR_0, tempData);
write_codebooks(VAR_0, tempData);
reconstruct_and_encode_image(VAR_0, tempData, VAR_0->width, VAR_0->height,
VAR_0->width*VAR_0->height/64);
VAR_0->avctx->coded_frame = VAR_0->current_frame;
FFSWAP(AVFrame *, VAR_0->current_frame, VAR_0->last_frame);
FFSWAP(motion_vect *, VAR_0->last_motion4, VAR_0->this_motion4);
FFSWAP(motion_vect *, VAR_0->last_motion8, VAR_0->this_motion8);
av_free(tempData->cel_evals);
av_free(tempData->closest_cb2);
VAR_0->framesSinceKeyframe++;
}
| [
"static void FUNC_0(RoqContext *VAR_0)\n{",
"RoqTempdata *tempData = VAR_0->tmpData;",
"int VAR_1;",
"memset(tempData, 0, sizeof(*tempData));",
"create_cel_evals(VAR_0, tempData);",
"generate_new_codebooks(VAR_0, tempData);",
"if (VAR_0->framesSinceKeyframe >= 1) {",
"motion_search(VAR_0, 8);",
"motion_search(VAR_0, 4);",
"}",
"retry_encode:\nfor (VAR_1=0; VAR_1<VAR_0->width*VAR_0->height/64; VAR_1++)",
"gather_data_for_cel(tempData->cel_evals + VAR_1, VAR_0, tempData);",
"if (tempData->mainChunkSize/8 > 65536) {",
"VAR_0->lambda *= .8;",
"goto retry_encode;",
"}",
"remap_codebooks(VAR_0, tempData);",
"write_codebooks(VAR_0, tempData);",
"reconstruct_and_encode_image(VAR_0, tempData, VAR_0->width, VAR_0->height,\nVAR_0->width*VAR_0->height/64);",
"VAR_0->avctx->coded_frame = VAR_0->current_frame;",
"FFSWAP(AVFrame *, VAR_0->current_frame, VAR_0->last_frame);",
"FFSWAP(motion_vect *, VAR_0->last_motion4, VAR_0->this_motion4);",
"FFSWAP(motion_vect *, VAR_0->last_motion8, VAR_0->this_motion8);",
"av_free(tempData->cel_evals);",
"av_free(tempData->closest_cb2);",
"VAR_0->framesSinceKeyframe++;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33,
35
],
[
37
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
57
],
[
61,
63
],
[
67
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
87
],
[
89
]
] |
1,832 | static int packet_alloc(AVBufferRef **buf, int size)
{
int ret;
if ((unsigned)size >= (unsigned)size + AV_INPUT_BUFFER_PADDING_SIZE)
return AVERROR(EINVAL);
ret = av_buffer_realloc(buf, size + AV_INPUT_BUFFER_PADDING_SIZE);
if (ret < 0)
return ret;
memset((*buf)->data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
return 0;
}
| true | FFmpeg | da3c3c446cb434be9d0025f519e00c2385135c85 | static int packet_alloc(AVBufferRef **buf, int size)
{
int ret;
if ((unsigned)size >= (unsigned)size + AV_INPUT_BUFFER_PADDING_SIZE)
return AVERROR(EINVAL);
ret = av_buffer_realloc(buf, size + AV_INPUT_BUFFER_PADDING_SIZE);
if (ret < 0)
return ret;
memset((*buf)->data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
return 0;
}
| {
"code": [
" if ((unsigned)size >= (unsigned)size + AV_INPUT_BUFFER_PADDING_SIZE)"
],
"line_no": [
7
]
} | static int FUNC_0(AVBufferRef **VAR_0, int VAR_1)
{
int VAR_2;
if ((unsigned)VAR_1 >= (unsigned)VAR_1 + AV_INPUT_BUFFER_PADDING_SIZE)
return AVERROR(EINVAL);
VAR_2 = av_buffer_realloc(VAR_0, VAR_1 + AV_INPUT_BUFFER_PADDING_SIZE);
if (VAR_2 < 0)
return VAR_2;
memset((*VAR_0)->data + VAR_1, 0, AV_INPUT_BUFFER_PADDING_SIZE);
return 0;
}
| [
"static int FUNC_0(AVBufferRef **VAR_0, int VAR_1)\n{",
"int VAR_2;",
"if ((unsigned)VAR_1 >= (unsigned)VAR_1 + AV_INPUT_BUFFER_PADDING_SIZE)\nreturn AVERROR(EINVAL);",
"VAR_2 = av_buffer_realloc(VAR_0, VAR_1 + AV_INPUT_BUFFER_PADDING_SIZE);",
"if (VAR_2 < 0)\nreturn VAR_2;",
"memset((*VAR_0)->data + VAR_1, 0, AV_INPUT_BUFFER_PADDING_SIZE);",
"return 0;",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
13
],
[
15,
17
],
[
21
],
[
25
],
[
27
]
] |
1,833 | static void m4sl_cb(MpegTSFilter *filter, const uint8_t *section,
int section_len)
{
MpegTSContext *ts = filter->u.section_filter.opaque;
MpegTSSectionFilter *tssf = &filter->u.section_filter;
SectionHeader h;
const uint8_t *p, *p_end;
AVIOContext pb;
int mp4_descr_count = 0;
Mp4Descr mp4_descr[MAX_MP4_DESCR_COUNT] = { { 0 } };
int i, pid;
AVFormatContext *s = ts->stream;
p_end = section + section_len - 4;
p = section;
if (parse_section_header(&h, &p, p_end) < 0)
return;
if (h.tid != M4OD_TID)
return;
if (h.version == tssf->last_ver)
return;
tssf->last_ver = h.version;
mp4_read_od(s, p, (unsigned) (p_end - p), mp4_descr, &mp4_descr_count,
MAX_MP4_DESCR_COUNT);
for (pid = 0; pid < NB_PID_MAX; pid++) {
if (!ts->pids[pid])
continue;
for (i = 0; i < mp4_descr_count; i++) {
PESContext *pes;
AVStream *st;
if (ts->pids[pid]->es_id != mp4_descr[i].es_id)
continue;
if (ts->pids[pid]->type != MPEGTS_PES) {
av_log(s, AV_LOG_ERROR, "pid %x is not PES\n", pid);
continue;
}
pes = ts->pids[pid]->u.pes_filter.opaque;
st = pes->st;
if (!st)
continue;
pes->sl = mp4_descr[i].sl;
ffio_init_context(&pb, mp4_descr[i].dec_config_descr,
mp4_descr[i].dec_config_descr_len, 0,
NULL, NULL, NULL, NULL);
ff_mp4_read_dec_config_descr(s, st, &pb);
if (st->codec->codec_id == AV_CODEC_ID_AAC &&
st->codec->extradata_size > 0)
st->need_parsing = 0;
if (st->codec->codec_id == AV_CODEC_ID_H264 &&
st->codec->extradata_size > 0)
st->need_parsing = 0;
if (st->codec->codec_id <= AV_CODEC_ID_NONE) {
// do nothing
} else if (st->codec->codec_id < AV_CODEC_ID_FIRST_AUDIO)
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
else if (st->codec->codec_id < AV_CODEC_ID_FIRST_SUBTITLE)
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
else if (st->codec->codec_id < AV_CODEC_ID_FIRST_UNKNOWN)
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
}
}
for (i = 0; i < mp4_descr_count; i++)
av_free(mp4_descr[i].dec_config_descr);
}
| false | FFmpeg | 4e8d01f20ce82b49f47c704a461c5d30866affaf | static void m4sl_cb(MpegTSFilter *filter, const uint8_t *section,
int section_len)
{
MpegTSContext *ts = filter->u.section_filter.opaque;
MpegTSSectionFilter *tssf = &filter->u.section_filter;
SectionHeader h;
const uint8_t *p, *p_end;
AVIOContext pb;
int mp4_descr_count = 0;
Mp4Descr mp4_descr[MAX_MP4_DESCR_COUNT] = { { 0 } };
int i, pid;
AVFormatContext *s = ts->stream;
p_end = section + section_len - 4;
p = section;
if (parse_section_header(&h, &p, p_end) < 0)
return;
if (h.tid != M4OD_TID)
return;
if (h.version == tssf->last_ver)
return;
tssf->last_ver = h.version;
mp4_read_od(s, p, (unsigned) (p_end - p), mp4_descr, &mp4_descr_count,
MAX_MP4_DESCR_COUNT);
for (pid = 0; pid < NB_PID_MAX; pid++) {
if (!ts->pids[pid])
continue;
for (i = 0; i < mp4_descr_count; i++) {
PESContext *pes;
AVStream *st;
if (ts->pids[pid]->es_id != mp4_descr[i].es_id)
continue;
if (ts->pids[pid]->type != MPEGTS_PES) {
av_log(s, AV_LOG_ERROR, "pid %x is not PES\n", pid);
continue;
}
pes = ts->pids[pid]->u.pes_filter.opaque;
st = pes->st;
if (!st)
continue;
pes->sl = mp4_descr[i].sl;
ffio_init_context(&pb, mp4_descr[i].dec_config_descr,
mp4_descr[i].dec_config_descr_len, 0,
NULL, NULL, NULL, NULL);
ff_mp4_read_dec_config_descr(s, st, &pb);
if (st->codec->codec_id == AV_CODEC_ID_AAC &&
st->codec->extradata_size > 0)
st->need_parsing = 0;
if (st->codec->codec_id == AV_CODEC_ID_H264 &&
st->codec->extradata_size > 0)
st->need_parsing = 0;
if (st->codec->codec_id <= AV_CODEC_ID_NONE) {
} else if (st->codec->codec_id < AV_CODEC_ID_FIRST_AUDIO)
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
else if (st->codec->codec_id < AV_CODEC_ID_FIRST_SUBTITLE)
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
else if (st->codec->codec_id < AV_CODEC_ID_FIRST_UNKNOWN)
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
}
}
for (i = 0; i < mp4_descr_count; i++)
av_free(mp4_descr[i].dec_config_descr);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(MpegTSFilter *VAR_0, const uint8_t *VAR_1,
int VAR_2)
{
MpegTSContext *ts = VAR_0->u.section_filter.opaque;
MpegTSSectionFilter *tssf = &VAR_0->u.section_filter;
SectionHeader h;
const uint8_t *VAR_3, *p_end;
AVIOContext pb;
int VAR_4 = 0;
Mp4Descr mp4_descr[MAX_MP4_DESCR_COUNT] = { { 0 } };
int VAR_5, VAR_6;
AVFormatContext *s = ts->stream;
p_end = VAR_1 + VAR_2 - 4;
VAR_3 = VAR_1;
if (parse_section_header(&h, &VAR_3, p_end) < 0)
return;
if (h.tid != M4OD_TID)
return;
if (h.version == tssf->last_ver)
return;
tssf->last_ver = h.version;
mp4_read_od(s, VAR_3, (unsigned) (p_end - VAR_3), mp4_descr, &VAR_4,
MAX_MP4_DESCR_COUNT);
for (VAR_6 = 0; VAR_6 < NB_PID_MAX; VAR_6++) {
if (!ts->pids[VAR_6])
continue;
for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {
PESContext *pes;
AVStream *st;
if (ts->pids[VAR_6]->es_id != mp4_descr[VAR_5].es_id)
continue;
if (ts->pids[VAR_6]->type != MPEGTS_PES) {
av_log(s, AV_LOG_ERROR, "VAR_6 %x is not PES\n", VAR_6);
continue;
}
pes = ts->pids[VAR_6]->u.pes_filter.opaque;
st = pes->st;
if (!st)
continue;
pes->sl = mp4_descr[VAR_5].sl;
ffio_init_context(&pb, mp4_descr[VAR_5].dec_config_descr,
mp4_descr[VAR_5].dec_config_descr_len, 0,
NULL, NULL, NULL, NULL);
ff_mp4_read_dec_config_descr(s, st, &pb);
if (st->codec->codec_id == AV_CODEC_ID_AAC &&
st->codec->extradata_size > 0)
st->need_parsing = 0;
if (st->codec->codec_id == AV_CODEC_ID_H264 &&
st->codec->extradata_size > 0)
st->need_parsing = 0;
if (st->codec->codec_id <= AV_CODEC_ID_NONE) {
} else if (st->codec->codec_id < AV_CODEC_ID_FIRST_AUDIO)
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
else if (st->codec->codec_id < AV_CODEC_ID_FIRST_SUBTITLE)
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
else if (st->codec->codec_id < AV_CODEC_ID_FIRST_UNKNOWN)
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
}
}
for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++)
av_free(mp4_descr[VAR_5].dec_config_descr);
}
| [
"static void FUNC_0(MpegTSFilter *VAR_0, const uint8_t *VAR_1,\nint VAR_2)\n{",
"MpegTSContext *ts = VAR_0->u.section_filter.opaque;",
"MpegTSSectionFilter *tssf = &VAR_0->u.section_filter;",
"SectionHeader h;",
"const uint8_t *VAR_3, *p_end;",
"AVIOContext pb;",
"int VAR_4 = 0;",
"Mp4Descr mp4_descr[MAX_MP4_DESCR_COUNT] = { { 0 } };",
"int VAR_5, VAR_6;",
"AVFormatContext *s = ts->stream;",
"p_end = VAR_1 + VAR_2 - 4;",
"VAR_3 = VAR_1;",
"if (parse_section_header(&h, &VAR_3, p_end) < 0)\nreturn;",
"if (h.tid != M4OD_TID)\nreturn;",
"if (h.version == tssf->last_ver)\nreturn;",
"tssf->last_ver = h.version;",
"mp4_read_od(s, VAR_3, (unsigned) (p_end - VAR_3), mp4_descr, &VAR_4,\nMAX_MP4_DESCR_COUNT);",
"for (VAR_6 = 0; VAR_6 < NB_PID_MAX; VAR_6++) {",
"if (!ts->pids[VAR_6])\ncontinue;",
"for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {",
"PESContext *pes;",
"AVStream *st;",
"if (ts->pids[VAR_6]->es_id != mp4_descr[VAR_5].es_id)\ncontinue;",
"if (ts->pids[VAR_6]->type != MPEGTS_PES) {",
"av_log(s, AV_LOG_ERROR, \"VAR_6 %x is not PES\\n\", VAR_6);",
"continue;",
"}",
"pes = ts->pids[VAR_6]->u.pes_filter.opaque;",
"st = pes->st;",
"if (!st)\ncontinue;",
"pes->sl = mp4_descr[VAR_5].sl;",
"ffio_init_context(&pb, mp4_descr[VAR_5].dec_config_descr,\nmp4_descr[VAR_5].dec_config_descr_len, 0,\nNULL, NULL, NULL, NULL);",
"ff_mp4_read_dec_config_descr(s, st, &pb);",
"if (st->codec->codec_id == AV_CODEC_ID_AAC &&\nst->codec->extradata_size > 0)\nst->need_parsing = 0;",
"if (st->codec->codec_id == AV_CODEC_ID_H264 &&\nst->codec->extradata_size > 0)\nst->need_parsing = 0;",
"if (st->codec->codec_id <= AV_CODEC_ID_NONE) {",
"} else if (st->codec->codec_id < AV_CODEC_ID_FIRST_AUDIO)",
"st->codec->codec_type = AVMEDIA_TYPE_VIDEO;",
"else if (st->codec->codec_id < AV_CODEC_ID_FIRST_SUBTITLE)\nst->codec->codec_type = AVMEDIA_TYPE_AUDIO;",
"else if (st->codec->codec_id < AV_CODEC_ID_FIRST_UNKNOWN)\nst->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;",
"}",
"}",
"for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++)",
"av_free(mp4_descr[VAR_5].dec_config_descr);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
47,
49
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81,
83
],
[
87
],
[
91,
93,
95
],
[
97
],
[
99,
101,
103
],
[
105,
107,
109
],
[
113
],
[
117
],
[
119
],
[
121,
123
],
[
125,
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
]
] |
1,834 | static int ffat_encode(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr)
{
ATDecodeContext *at = avctx->priv_data;
OSStatus ret;
AudioBufferList out_buffers = {
.mNumberBuffers = 1,
.mBuffers = {
{
.mNumberChannels = avctx->channels,
.mDataByteSize = at->pkt_size,
}
}
};
AudioStreamPacketDescription out_pkt_desc = {0};
if ((ret = ff_alloc_packet2(avctx, avpkt, at->pkt_size, 0)) < 0)
return ret;
av_frame_unref(&at->new_in_frame);
if (frame) {
if ((ret = ff_af_queue_add(&at->afq, frame)) < 0)
return ret;
if ((ret = av_frame_ref(&at->new_in_frame, frame)) < 0)
return ret;
} else {
at->eof = 1;
}
out_buffers.mBuffers[0].mData = avpkt->data;
*got_packet_ptr = avctx->frame_size / at->frame_size;
ret = AudioConverterFillComplexBuffer(at->converter, ffat_encode_callback, avctx,
got_packet_ptr, &out_buffers,
(avctx->frame_size > at->frame_size) ? NULL : &out_pkt_desc);
if ((!ret || ret == 1) && *got_packet_ptr) {
avpkt->size = out_buffers.mBuffers[0].mDataByteSize;
ff_af_queue_remove(&at->afq, out_pkt_desc.mVariableFramesInPacket ?
out_pkt_desc.mVariableFramesInPacket :
avctx->frame_size,
&avpkt->pts,
&avpkt->duration);
} else if (ret && ret != 1) {
av_log(avctx, AV_LOG_WARNING, "Encode error: %i\n", ret);
}
return 0;
}
| false | FFmpeg | 143685a42bbc8861b626457ce4cb8b1ce4b0c436 | static int ffat_encode(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr)
{
ATDecodeContext *at = avctx->priv_data;
OSStatus ret;
AudioBufferList out_buffers = {
.mNumberBuffers = 1,
.mBuffers = {
{
.mNumberChannels = avctx->channels,
.mDataByteSize = at->pkt_size,
}
}
};
AudioStreamPacketDescription out_pkt_desc = {0};
if ((ret = ff_alloc_packet2(avctx, avpkt, at->pkt_size, 0)) < 0)
return ret;
av_frame_unref(&at->new_in_frame);
if (frame) {
if ((ret = ff_af_queue_add(&at->afq, frame)) < 0)
return ret;
if ((ret = av_frame_ref(&at->new_in_frame, frame)) < 0)
return ret;
} else {
at->eof = 1;
}
out_buffers.mBuffers[0].mData = avpkt->data;
*got_packet_ptr = avctx->frame_size / at->frame_size;
ret = AudioConverterFillComplexBuffer(at->converter, ffat_encode_callback, avctx,
got_packet_ptr, &out_buffers,
(avctx->frame_size > at->frame_size) ? NULL : &out_pkt_desc);
if ((!ret || ret == 1) && *got_packet_ptr) {
avpkt->size = out_buffers.mBuffers[0].mDataByteSize;
ff_af_queue_remove(&at->afq, out_pkt_desc.mVariableFramesInPacket ?
out_pkt_desc.mVariableFramesInPacket :
avctx->frame_size,
&avpkt->pts,
&avpkt->duration);
} else if (ret && ret != 1) {
av_log(avctx, AV_LOG_WARNING, "Encode error: %i\n", ret);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,
const AVFrame *VAR_2, int *VAR_3)
{
ATDecodeContext *at = VAR_0->priv_data;
OSStatus ret;
AudioBufferList out_buffers = {
.mNumberBuffers = 1,
.mBuffers = {
{
.mNumberChannels = VAR_0->channels,
.mDataByteSize = at->pkt_size,
}
}
};
AudioStreamPacketDescription out_pkt_desc = {0};
if ((ret = ff_alloc_packet2(VAR_0, VAR_1, at->pkt_size, 0)) < 0)
return ret;
av_frame_unref(&at->new_in_frame);
if (VAR_2) {
if ((ret = ff_af_queue_add(&at->afq, VAR_2)) < 0)
return ret;
if ((ret = av_frame_ref(&at->new_in_frame, VAR_2)) < 0)
return ret;
} else {
at->eof = 1;
}
out_buffers.mBuffers[0].mData = VAR_1->data;
*VAR_3 = VAR_0->frame_size / at->frame_size;
ret = AudioConverterFillComplexBuffer(at->converter, ffat_encode_callback, VAR_0,
VAR_3, &out_buffers,
(VAR_0->frame_size > at->frame_size) ? NULL : &out_pkt_desc);
if ((!ret || ret == 1) && *VAR_3) {
VAR_1->size = out_buffers.mBuffers[0].mDataByteSize;
ff_af_queue_remove(&at->afq, out_pkt_desc.mVariableFramesInPacket ?
out_pkt_desc.mVariableFramesInPacket :
VAR_0->frame_size,
&VAR_1->pts,
&VAR_1->duration);
} else if (ret && ret != 1) {
av_log(VAR_0, AV_LOG_WARNING, "Encode error: %i\n", ret);
}
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,\nconst AVFrame *VAR_2, int *VAR_3)\n{",
"ATDecodeContext *at = VAR_0->priv_data;",
"OSStatus ret;",
"AudioBufferList out_buffers = {",
".mNumberBuffers = 1,\n.mBuffers = {",
"{",
".mNumberChannels = VAR_0->channels,\n.mDataByteSize = at->pkt_size,\n}",
"}",
"};",
"AudioStreamPacketDescription out_pkt_desc = {0};",
"if ((ret = ff_alloc_packet2(VAR_0, VAR_1, at->pkt_size, 0)) < 0)\nreturn ret;",
"av_frame_unref(&at->new_in_frame);",
"if (VAR_2) {",
"if ((ret = ff_af_queue_add(&at->afq, VAR_2)) < 0)\nreturn ret;",
"if ((ret = av_frame_ref(&at->new_in_frame, VAR_2)) < 0)\nreturn ret;",
"} else {",
"at->eof = 1;",
"}",
"out_buffers.mBuffers[0].mData = VAR_1->data;",
"*VAR_3 = VAR_0->frame_size / at->frame_size;",
"ret = AudioConverterFillComplexBuffer(at->converter, ffat_encode_callback, VAR_0,\nVAR_3, &out_buffers,\n(VAR_0->frame_size > at->frame_size) ? NULL : &out_pkt_desc);",
"if ((!ret || ret == 1) && *VAR_3) {",
"VAR_1->size = out_buffers.mBuffers[0].mDataByteSize;",
"ff_af_queue_remove(&at->afq, out_pkt_desc.mVariableFramesInPacket ?\nout_pkt_desc.mVariableFramesInPacket :\nVAR_0->frame_size,\n&VAR_1->pts,\n&VAR_1->duration);",
"} else if (ret && ret != 1) {",
"av_log(VAR_0, AV_LOG_WARNING, \"Encode error: %i\\n\", ret);",
"}",
"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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
19
],
[
21,
23,
25
],
[
27
],
[
29
],
[
31
],
[
35,
37
],
[
41
],
[
45
],
[
47,
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
67
],
[
71,
73,
75
],
[
77
],
[
79
],
[
81,
83,
85,
87,
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
]
] |